@@ -20,6 +20,7 @@ import {
20
20
CheckRequest ,
21
21
CheckRequestTupleKey ,
22
22
CheckResponse ,
23
+ ConsistencyPreference ,
23
24
CreateStoreRequest ,
24
25
CreateStoreResponse ,
25
26
ExpandRequestTupleKey ,
@@ -111,8 +112,13 @@ export interface AuthorizationModelIdOpts {
111
112
authorizationModelId ?: string ;
112
113
}
113
114
115
+ export interface ConsistencyOpts {
116
+ consistency ?: ConsistencyPreference
117
+ }
118
+
114
119
export type ClientRequestOptsWithStoreId = ClientRequestOpts & StoreIdOpts ;
115
120
export type ClientRequestOptsWithAuthZModelId = ClientRequestOpts & StoreIdOpts & AuthorizationModelIdOpts ;
121
+ export type ClientRequestOptsWithConsistency = ClientRequestOpts & StoreIdOpts & AuthorizationModelIdOpts & ConsistencyOpts ;
116
122
117
123
export type PaginationOptions = { pageSize ?: number , continuationToken ?: string ; } ;
118
124
@@ -179,13 +185,13 @@ export interface ClientReadChangesRequest {
179
185
180
186
export type ClientExpandRequest = ExpandRequestTupleKey ;
181
187
export type ClientReadRequest = ReadRequestTupleKey ;
182
- export type ClientListObjectsRequest = Omit < ListObjectsRequest , "authorization_model_id" | "contextual_tuples" > & {
188
+ export type ClientListObjectsRequest = Omit < ListObjectsRequest , "authorization_model_id" | "contextual_tuples" | "consistency" > & {
183
189
contextualTuples ?: Array < TupleKey >
184
190
} ;
185
- export type ClientListUsersRequest = Omit < ListUsersRequest , "authorization_model_id" | "contextual_tuples" > & {
191
+ export type ClientListUsersRequest = Omit < ListUsersRequest , "authorization_model_id" | "contextual_tuples" | "consistency" > & {
186
192
contextualTuples ?: Array < TupleKey >
187
193
} ;
188
- export type ClientListRelationsRequest = Omit < ClientCheckRequest , "relation" > & {
194
+ export type ClientListRelationsRequest = Omit < ClientCheckRequest , "relation" | "consistency" > & {
189
195
relations ?: string [ ] ,
190
196
} ;
191
197
export type ClientWriteAssertionsRequest = ( CheckRequestTupleKey & Pick < Assertion , "expectation" > ) [ ] ;
@@ -398,15 +404,16 @@ export class OpenFgaClient extends BaseAPI {
398
404
/**
399
405
* Read - Read tuples previously written to the store (does not evaluate)
400
406
* @param {ClientReadRequest } body
401
- * @param {ClientRequestOpts & PaginationOptions } [options]
407
+ * @param {ClientRequestOpts & PaginationOptions & ConsistencyOpts } [options]
402
408
* @param {number } [options.pageSize]
403
409
* @param {string } [options.continuationToken]
404
410
* @param {object } [options.headers] - Custom headers to send alongside the request
411
+ * @param {ConsistencyPreference } [options.consistency] - The consistency preference to use
405
412
* @param {object } [options.retryParams] - Override the retry parameters for this request
406
413
* @param {number } [options.retryParams.maxRetry] - Override the max number of retries on each API request
407
414
* @param {number } [options.retryParams.minWaitInMs] - Override the minimum wait before a retry is initiated
408
415
*/
409
- async read ( body : ClientReadRequest = { } , options : ClientRequestOptsWithStoreId & PaginationOptions = { } ) : PromiseResult < ReadResponse > {
416
+ async read ( body : ClientReadRequest = { } , options : ClientRequestOptsWithStoreId & PaginationOptions & ConsistencyOpts = { } ) : PromiseResult < ReadResponse > {
410
417
const readRequest : ReadRequest = {
411
418
page_size : options . pageSize ,
412
419
continuation_token : options . continuationToken ,
@@ -556,14 +563,15 @@ export class OpenFgaClient extends BaseAPI {
556
563
/**
557
564
* Check - Check if a user has a particular relation with an object (evaluates)
558
565
* @param {ClientCheckRequest } body
559
- * @param {ClientRequestOptsWithAuthZModelId } [options]
566
+ * @param {ClientRequestOptsWithConsistency } [options]
560
567
* @param {string } [options.authorizationModelId] - Overrides the authorization model id in the configuration
561
568
* @param {object } [options.headers] - Custom headers to send alongside the request
569
+ * @param {ConsistencyPreference } [options.consistency] - The consistency preference to use
562
570
* @param {object } [options.retryParams] - Override the retry parameters for this request
563
571
* @param {number } [options.retryParams.maxRetry] - Override the max number of retries on each API request
564
572
* @param {number } [options.retryParams.minWaitInMs] - Override the minimum wait before a retry is initiated
565
573
*/
566
- async check ( body : ClientCheckRequest , options : ClientRequestOptsWithAuthZModelId = { } ) : PromiseResult < CheckResponse > {
574
+ async check ( body : ClientCheckRequest , options : ClientRequestOptsWithConsistency = { } ) : PromiseResult < CheckResponse > {
567
575
return this . api . check ( this . getStoreId ( options ) ! , {
568
576
tuple_key : {
569
577
user : body . user ,
@@ -587,7 +595,7 @@ export class OpenFgaClient extends BaseAPI {
587
595
* @param {number } [options.retryParams.maxRetry] - Override the max number of retries on each API request
588
596
* @param {number } [options.retryParams.minWaitInMs] - Override the minimum wait before a retry is initiated
589
597
*/
590
- async batchCheck ( body : ClientBatchCheckRequest , options : ClientRequestOptsWithAuthZModelId & BatchCheckRequestOpts = { } ) : Promise < ClientBatchCheckResponse > {
598
+ async batchCheck ( body : ClientBatchCheckRequest , options : ClientRequestOptsWithConsistency & BatchCheckRequestOpts = { } ) : Promise < ClientBatchCheckResponse > {
591
599
const { headers = { } , maxParallelRequests = DEFAULT_MAX_METHOD_PARALLEL_REQS } = options ;
592
600
setHeaderIfNotSet ( headers , CLIENT_METHOD_HEADER , "BatchCheck" ) ;
593
601
setHeaderIfNotSet ( headers , CLIENT_BULK_REQUEST_ID_HEADER , generateRandomIdWithNonUniqueFallback ( ) ) ;
@@ -621,14 +629,15 @@ export class OpenFgaClient extends BaseAPI {
621
629
* @param {ClientExpandRequest } body
622
630
* @param {string } body.relation The relation
623
631
* @param {string } body.object The object, must be of the form: `<type>:<id>`
624
- * @param {ClientRequestOptsWithAuthZModelId } [options]
632
+ * @param {ClientRequestOptsWithConsistency } [options]
625
633
* @param {string } [options.authorizationModelId] - Overrides the authorization model id in the configuration
626
634
* @param {object } [options.headers] - Custom headers to send alongside the request
635
+ * @param {ConsistencyPreference } [options.consistency] - The consistency preference to use
627
636
* @param {object } [options.retryParams] - Override the retry parameters for this request
628
637
* @param {number } [options.retryParams.maxRetry] - Override the max number of retries on each API request
629
638
* @param {number } [options.retryParams.minWaitInMs] - Override the minimum wait before a retry is initiated
630
639
*/
631
- async expand ( body : ClientExpandRequest , options : ClientRequestOptsWithAuthZModelId = { } ) : PromiseResult < ExpandResponse > {
640
+ async expand ( body : ClientExpandRequest , options : ClientRequestOptsWithConsistency = { } ) : PromiseResult < ExpandResponse > {
632
641
return this . api . expand ( this . getStoreId ( options ) ! , {
633
642
authorization_model_id : this . getAuthorizationModelId ( options ) ,
634
643
tuple_key : body ,
@@ -638,14 +647,15 @@ export class OpenFgaClient extends BaseAPI {
638
647
/**
639
648
* ListObjects - List the objects of a particular type that the user has a certain relation to (evaluates)
640
649
* @param {ClientListObjectsRequest } body
641
- * @param {ClientRequestOptsWithAuthZModelId } [options]
650
+ * @param {ClientRequestOptsWithConsistency } [options]
642
651
* @param {string } [options.authorizationModelId] - Overrides the authorization model id in the configuration
643
652
* @param {object } [options.headers] - Custom headers to send alongside the request
653
+ * @param {ConsistencyPreference } [options.consistency] - The consistency preference to use
644
654
* @param {object } [options.retryParams] - Override the retry parameters for this request
645
655
* @param {number } [options.retryParams.maxRetry] - Override the max number of retries on each API request
646
656
* @param {number } [options.retryParams.minWaitInMs] - Override the minimum wait before a retry is initiated
647
657
*/
648
- async listObjects ( body : ClientListObjectsRequest , options : ClientRequestOptsWithAuthZModelId = { } ) : PromiseResult < ListObjectsResponse > {
658
+ async listObjects ( body : ClientListObjectsRequest , options : ClientRequestOptsWithConsistency = { } ) : PromiseResult < ListObjectsResponse > {
649
659
return this . api . listObjects ( this . getStoreId ( options ) ! , {
650
660
authorization_model_id : this . getAuthorizationModelId ( options ) ,
651
661
user : body . user ,
@@ -666,7 +676,7 @@ export class OpenFgaClient extends BaseAPI {
666
676
* @param {object } listRelationsRequest.context The contextual tuples to send
667
677
* @param options
668
678
*/
669
- async listRelations ( listRelationsRequest : ClientListRelationsRequest , options : ClientRequestOptsWithAuthZModelId & BatchCheckRequestOpts = { } ) : Promise < ClientListRelationsResponse > {
679
+ async listRelations ( listRelationsRequest : ClientListRelationsRequest , options : ClientRequestOptsWithConsistency & BatchCheckRequestOpts = { } ) : Promise < ClientListRelationsResponse > {
670
680
const { user, object, relations, contextualTuples, context } = listRelationsRequest ;
671
681
const { headers = { } , maxParallelRequests = DEFAULT_MAX_METHOD_PARALLEL_REQS } = options ;
672
682
setHeaderIfNotSet ( headers , CLIENT_METHOD_HEADER , "ListRelations" ) ;
@@ -695,14 +705,15 @@ export class OpenFgaClient extends BaseAPI {
695
705
/**
696
706
* ListUsers - List the objects of a particular type that the user has a certain relation to (evaluates)
697
707
* @param {ClientListUsersRequest } body
698
- * @param {ClientRequestOptsWithAuthZModelId } [options]
708
+ * @param {ClientRequestOptsWithConsistency } [options]
699
709
* @param {string } [options.authorizationModelId] - Overrides the authorization model id in the configuration
700
710
* @param {object } [options.headers] - Custom headers to send alongside the request
711
+ * @param {ConsistencyPreference } [options.consistency] - The consistency preference to use
701
712
* @param {object } [options.retryParams] - Override the retry parameters for this request
702
713
* @param {number } [options.retryParams.maxRetry] - Override the max number of retries on each API request
703
714
* @param {number } [options.retryParams.minWaitInMs] - Override the minimum wait before a retry is initiated
704
715
*/
705
- async listUsers ( body : ClientListUsersRequest , options : ClientRequestOptsWithAuthZModelId = { } ) : PromiseResult < ListUsersResponse > {
716
+ async listUsers ( body : ClientListUsersRequest , options : ClientRequestOptsWithConsistency = { } ) : PromiseResult < ListUsersResponse > {
706
717
return this . api . listUsers ( this . getStoreId ( options ) ! , {
707
718
authorization_model_id : this . getAuthorizationModelId ( options ) ,
708
719
relation : body . relation ,
0 commit comments