Skip to content

Commit

Permalink
feat(js-sdk): add support for contextual tuples in Expand
Browse files Browse the repository at this point in the history
  • Loading branch information
rhamzeh committed Jan 14, 2025
1 parent 59c7a7a commit 144863e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions config/clients/js/template/client.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
ContextualTupleKeys,
CreateStoreRequest,
CreateStoreResponse,
ExpandRequest,
ExpandRequestTupleKey,
ExpandResponse,
GetStoreResponse,
Expand Down Expand Up @@ -213,7 +214,9 @@ export interface ClientReadChangesRequest {
startTime?: string;
}

export type ClientExpandRequest = ExpandRequestTupleKey;
export type ClientExpandRequest = ExpandRequestTupleKey & Omit<ExpandRequest, "tuple_key" | "authorization_model_id" | "contextual_tuples" | "consistency"> & {
contextualTuples?: Array<TupleKey>
};
export type ClientReadRequest = ReadRequestTupleKey;
export type ClientListObjectsRequest = Omit<ListObjectsRequest, "authorization_model_id" | "contextual_tuples" | "consistency"> & {
contextualTuples?: Array<TupleKey>
Expand Down Expand Up @@ -769,7 +772,11 @@ export class {{appShortName}}Client extends BaseAPI {
async expand(body: ClientExpandRequest, options: ClientRequestOptsWithConsistency = {}): PromiseResult<ExpandResponse> {
return this.api.expand(this.getStoreId(options)!, {
authorization_model_id: this.getAuthorizationModelId(options),
tuple_key: body,
tuple_key: {
object: body.object,
relation: body.relation,
},
contextual_tuples: { tuple_keys: body.contextualTuples || [] },
consistency: options.consistency
}, options);
}
Expand Down

0 comments on commit 144863e

Please sign in to comment.