From 59c7a7a30c8b00a03bb12cfda0198e607ef519c4 Mon Sep 17 00:00:00 2001 From: Raghd Hamzeh Date: Tue, 14 Jan 2025 14:14:28 -0500 Subject: [PATCH 1/3] chore(js-sdk): minor cleanup --- .../clients/js/template/credentials/credentials.ts.mustache | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/config/clients/js/template/credentials/credentials.ts.mustache b/config/clients/js/template/credentials/credentials.ts.mustache index c7a57cd8..d63449a2 100644 --- a/config/clients/js/template/credentials/credentials.ts.mustache +++ b/config/clients/js/template/credentials/credentials.ts.mustache @@ -3,11 +3,10 @@ import globalAxios, { AxiosInstance } from "axios"; import { assertParamExists, isWellFormedUriString } from "../validation"; -import { FgaApiAuthenticationError, FgaApiError, FgaError, FgaValidationError } from "../errors"; +import { FgaApiAuthenticationError, FgaApiError, FgaValidationError } from "../errors"; import { attemptHttpRequest } from "../common"; import { AuthCredentialsConfig, ClientCredentialsConfig, CredentialsMethod } from "./types"; import { TelemetryAttributes } from "../telemetry/attributes"; -import { MetricRecorder } from "../telemetry/metrics"; import { TelemetryCounters } from "../telemetry/counters"; import { TelemetryConfiguration } from "../telemetry/configuration"; @@ -169,7 +168,7 @@ export class Credentials { attributes = TelemetryAttributes.fromResponse({ response, - attributes, + attributes, }); attributes = TelemetryAttributes.prepare(attributes, this.telemetryConfig.metrics?.counterCredentialsRequest?.attributes); From 144863e4ad74f14ebd5740415e7684246f52081a Mon Sep 17 00:00:00 2001 From: Raghd Hamzeh Date: Tue, 14 Jan 2025 14:14:46 -0500 Subject: [PATCH 2/3] feat(js-sdk): add support for contextual tuples in Expand --- config/clients/js/template/client.mustache | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/config/clients/js/template/client.mustache b/config/clients/js/template/client.mustache index f6da0bbb..fe9dbc19 100644 --- a/config/clients/js/template/client.mustache +++ b/config/clients/js/template/client.mustache @@ -17,6 +17,7 @@ import { ContextualTupleKeys, CreateStoreRequest, CreateStoreResponse, + ExpandRequest, ExpandRequestTupleKey, ExpandResponse, GetStoreResponse, @@ -213,7 +214,9 @@ export interface ClientReadChangesRequest { startTime?: string; } -export type ClientExpandRequest = ExpandRequestTupleKey; +export type ClientExpandRequest = ExpandRequestTupleKey & Omit & { + contextualTuples?: Array +}; export type ClientReadRequest = ReadRequestTupleKey; export type ClientListObjectsRequest = Omit & { contextualTuples?: Array @@ -769,7 +772,11 @@ export class {{appShortName}}Client extends BaseAPI { async expand(body: ClientExpandRequest, options: ClientRequestOptsWithConsistency = {}): PromiseResult { 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); } From 33664f90a1e9db6ed5ec574d126e978e8308931f Mon Sep 17 00:00:00 2001 From: Raghd Hamzeh Date: Tue, 14 Jan 2025 13:49:52 -0500 Subject: [PATCH 3/3] release(js-sdk): v0.8.0 --- .editorconfig | 2 +- config/clients/js/CHANGELOG.md.mustache | 26 ++++++++++++++++--------- config/clients/js/config.overrides.json | 2 +- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/.editorconfig b/.editorconfig index ab020176..2304f17f 100644 --- a/.editorconfig +++ b/.editorconfig @@ -12,7 +12,7 @@ indent_style = tab indent_style = space indent_size = 4 -[*.{js,ts}] +[*.{js,ts,mjs}] indent_style = space indent_size = 2 diff --git a/config/clients/js/CHANGELOG.md.mustache b/config/clients/js/CHANGELOG.md.mustache index 8b25dc96..f41a6b77 100644 --- a/config/clients/js/CHANGELOG.md.mustache +++ b/config/clients/js/CHANGELOG.md.mustache @@ -3,15 +3,23 @@ ## [Unreleased](https://github.com/openfga/js-sdk/compare/v{{packageVersion}}...HEAD) -- fix: error correctly if apiUrl is not provided (#161) -- fix: use provided axios instance in credentials refresh (#193) -- feat: add support for `start_time` parameter in `ReadChanges` endpoint -- BREAKING: As of this release, the min node version required by the SDK is now v16.15.0 -- feat!: add support for server-side `BatchCheck` method. - -BREAKING CHNAGES: - -- The minimum noce version required by this SDK is now v16.15.0 +## v0.8.0 + +### [0.8.0](https://github.com/openfga/js-sdk/compare/v0.7.0...v0.8.0) (2025-01-14) + +- feat!: add support for server-side `BatchCheck` method. This is a more efficient way to check on multiple tuples than calling the existing client-side `BatchCheck`. Using this method requires an OpenFGA [v1.8.0+](https://github.com/openfga/openfga/releases/tag/v1.8.0) server. + - The existing `BatchCheck` method has been renamed to `clientBatchCheck` and it now bundles the results in a field called `result` instead of `responses`. + - The existing `BatchCheckResponse` has been renamed to `ClientBatchCheckResponse`. +- feat: add support for startTime` parameter in `ReadChanges` endpoint +- feat: support contextual tuples and context in assertions +- feat: support contextual tuples in Expand +- fix: error correctly if apiUrl is not provided - thanks @Waheedsys (#161) +- fix: use provided axios instance in credentials refresh - thanks @Siddhant-K-code (#193) +- fix!: The minimum node version required by this SDK is now v16.15.0 +- chore(docs): various cleanup and improvements - thanks @tmsagarofficial (#164), @vil02 (https://github.com/openfga/sdk-generator/pull/424, https://github.com/openfga/sdk-generator/pull/422), @sccalabr (https://github.com/openfga/sdk-generator/pull/433) + +BREAKING CHANGES: +- The minimum node version required by this SDK is now v16.15.0 - Usage of the existing `batchCheck` method should now use the `clientBatchCheck` method. The existing `BatchCheckResponse` has been renamed to `ClientBatchCheckResponse` and it now bundles the results in a field called `result` instead of `responses`. ## v0.7.0 diff --git a/config/clients/js/config.overrides.json b/config/clients/js/config.overrides.json index 498cdd21..a3284dcd 100644 --- a/config/clients/js/config.overrides.json +++ b/config/clients/js/config.overrides.json @@ -2,7 +2,7 @@ "sdkId": "js", "gitRepoId": "js-sdk", "packageName": "@openfga/sdk", - "packageVersion": "0.7.0", + "packageVersion": "0.8.0", "packageDescription": "JavaScript and Node.js SDK for OpenFGA", "packageDetailedDescription": "This is an autogenerated JavaScript SDK for OpenFGA. It provides a wrapper around the [OpenFGA API definition](https://openfga.dev/api), and includes TS typings.", "npmRegistry": "https://registry.npmjs.org/",