Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release: v0.8.0 #196

Merged
merged 3 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
# Changelog


## [Unreleased](https://github.com/openfga/js-sdk/compare/v0.7.0...HEAD)
## [Unreleased](https://github.com/openfga/js-sdk/compare/v0.8.0...HEAD)

- fix: error correctly if apiUrl is not provided (#161)
- 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.
## v0.8.0

BREAKING CHNAGES:
### [0.8.0](https://github.com/openfga/js-sdk/compare/v0.7.0...v0.8.0) (2025-01-14)

- The minimum noce version required by this SDK is now v16.15.0
- 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
Expand Down
8 changes: 4 additions & 4 deletions api.ts

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions apiModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,12 @@ export interface ExpandRequest {
* @memberof ExpandRequest
*/
consistency?: ConsistencyPreference;
/**
*
* @type {ContextualTupleKeys}
* @memberof ExpandRequest
*/
contextual_tuples?: ContextualTupleKeys;
}


Expand Down
11 changes: 9 additions & 2 deletions client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
ContextualTupleKeys,
CreateStoreRequest,
CreateStoreResponse,
ExpandRequest,
ExpandRequestTupleKey,
ExpandResponse,
GetStoreResponse,
Expand Down Expand Up @@ -224,7 +225,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 @@ -780,7 +783,11 @@ export class OpenFgaClient 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
4 changes: 2 additions & 2 deletions configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const DEFAULT_MAX_RETRY = 3;
// default minimum wait period in retry - but will backoff exponentially
const DEFAULT_MIN_WAIT_MS = 100;

const DEFAULT_USER_AGENT = "openfga-sdk js/0.7.0";
const DEFAULT_USER_AGENT = "openfga-sdk js/0.8.0";

export interface RetryParams {
maxRetry?: number;
Expand Down Expand Up @@ -75,7 +75,7 @@ export class Configuration {
* @type {string}
* @memberof Configuration
*/
private static sdkVersion = "0.7.0";
private static sdkVersion = "0.8.0";

/**
* provide the full api URL (e.g. `https://api.fga.example`)
Expand Down
5 changes: 2 additions & 3 deletions credentials/credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,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";

Expand All @@ -28,7 +27,7 @@ export class Credentials {

public static init(configuration: { credentials: AuthCredentialsConfig, telemetry: TelemetryConfiguration, baseOptions?: any }, axios: AxiosInstance = globalAxios): Credentials {
return new Credentials(configuration.credentials, axios, configuration.telemetry, configuration.baseOptions);
}
}

public constructor(private authConfig: AuthCredentialsConfig, private axios: AxiosInstance = globalAxios, private telemetryConfig: TelemetryConfiguration, private baseOptions?: any) {
this.initConfig();
Expand Down
2 changes: 1 addition & 1 deletion example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Steps
2. In the Example `package.json` change the `@openfga/sdk` dependency from a semver range like below
```json
"dependencies": {
"@openfga/sdk": "^0.7.0"
"@openfga/sdk": "^0.8.0"
}
```
to a `file:` reference like below
Expand Down
2 changes: 1 addition & 1 deletion example/example1/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"start": "node example1.mjs"
},
"dependencies": {
"@openfga/sdk": "^0.7.0"
"@openfga/sdk": "^0.8.0"
},
"engines": {
"node": ">=16.13.0"
Expand Down
Loading
Loading