Skip to content

Commit b35df26

Browse files
committed
chore: reduce generated code
1 parent 557bf4e commit b35df26

29 files changed

Lines changed: 194 additions & 389 deletions

.openapi-generator-ignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
.npmignore
2+
configuration.ts
3+
common.ts
4+
base.ts

.openapi-generator/FILES

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,17 @@
11
.codecov.yml
2-
.eslintignore
3-
.eslintrc.js
4-
.fossa.yml
52
.github/CODEOWNERS
63
.github/ISSUE_TEMPLATE/bug_report.yaml
74
.github/ISSUE_TEMPLATE/config.yaml
85
.github/ISSUE_TEMPLATE/feature_request.yaml
9-
.github/dependabot.yaml
106
.gitignore
117
.gitignore
12-
.madgerc
138
.npmrc
14-
CHANGELOG.md
159
CONTRIBUTING.md
1610
LICENSE
17-
NOTICE.txt
1811
README.md
1912
VERSION.txt
2013
api.ts
2114
apiModel.ts
22-
base.ts
23-
client.ts
24-
common.ts
25-
configuration.ts
26-
credentials/credentials.ts
27-
credentials/index.ts
28-
credentials/types.ts
29-
docs/opentelemetry.md
30-
errors.ts
31-
example/Makefile
32-
example/README.md
33-
example/example1/example1.mjs
34-
example/example1/package.json
35-
example/opentelemetry/.env.example
36-
example/opentelemetry/.npmrc
37-
example/opentelemetry/README.md
38-
example/opentelemetry/instrumentation.mjs
39-
example/opentelemetry/opentelemetry.mjs
40-
example/opentelemetry/package.json
15+
constants/index.ts
4116
git_push.sh
4217
index.ts
43-
package.json
44-
telemetry/attributes.ts
45-
telemetry/configuration.ts
46-
telemetry/counters.ts
47-
telemetry/histograms.ts
48-
telemetry/metrics.ts
49-
tests/client.test.ts
50-
tests/helpers/default-config.ts
51-
tests/helpers/index.ts
52-
tests/helpers/nocks.ts
53-
tests/index.test.ts
54-
tests/jest.config.js
55-
tests/telemetry/attributes.test.ts
56-
tests/telemetry/configuration.test.ts
57-
tests/telemetry/counters.test.ts
58-
tests/telemetry/histograms.test.ts
59-
tests/telemetry/metrics.test.ts
60-
tests/tsconfig.spec.json
61-
tests/validation.test.ts
62-
tsconfig.json
63-
utils/assert-never.ts
64-
utils/chunk-array.ts
65-
utils/generate-random-id.ts
66-
utils/index.ts
67-
utils/set-header-if-not-set.ts
68-
utils/set-not-enumerable-property.ts
69-
validation.ts

CONTRIBUTING.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,23 @@ By participating and contributing to this project, you are expected to uphold ou
2323

2424
### Making Changes
2525

26-
When contributing to a repository, the first step is to open an issue on [sdk-generator](https://github.com/openfga/sdk-generator) to discuss the change you wish to make before making them.
26+
When contributing to a repository, the first step is to open [an issue](https://github.com/openfga/js-sdk/issues) to discuss the change you wish to make before making them.
2727

2828
### Opening Issues
2929

3030
Before you submit a new issue please make sure to search all open and closed issues. It is possible your feature request/issue has already been answered. Make sure to also check the [OpenFGA discussions](https://github.com/orgs/openfga/discussions).
3131

32-
That repo includes an issue template that will walk through all the places to check before submitting your issue here. Please follow the instructions there to make sure this is not a duplicate issue and that we have everything we need to research and reproduce this problem.
32+
The repo includes an issue template that will walk through all the places to check before submitting your issue here. Please follow the instructions there to make sure this is not a duplicate issue and that we have everything we need to research and reproduce this problem.
33+
34+
If you have found a bug or if you have a feature request, please report them in the [repo issues](https://github.com/openfga/js-sdk/issues). Cross-SDK bugs and feature requests can be additionally reported in the [sdk-generator repo](https://github.com/openfga/sdk-generator/issues) issues section, where the individual SDK issue is then linked.
35+
36+
**Please do not report security vulnerabilities on the public GitHub issue tracker.**
3337

3438
### Submitting Pull Requests
3539

36-
While we accept Pull Requests on this repository, the SDKs are autogenerated so please consider additionally submitting your Pull Requests to the [sdk-generator](https://github.com/openfga/sdk-generator) and linking the two PRs together and to the corresponding issue. This will greatly assist the OpenFGA team in being able to give timely reviews as well as deploying fixes and updates to our other SDKs as well.
40+
Feel free to submit a Pull Request against this repository. Please make sure to follow the existing code style and include tests where applicable.
41+
42+
Some files in this repository are autogenerated. These files have a comment at the top indicating that they are autogenerated and should not be modified directly - the files are usually identified by a header marking them as such, or by their inclusion in [`.openapi-generator/FILES`](./.openapi-generator/FILES). Changes to these files should be made in the [sdk-generator](https://github.com/openfga/sdk-generator) repository in tandem, so please consider additionally submitting your Pull Requests to the [sdk-generator](https://github.com/openfga/sdk-generator) and linking the two PRs together and to the corresponding issue. This will greatly assist the OpenFGA team in being able to give timely reviews as well as deploying fixes and updates to our other SDKs as well.
3743

3844
## Getting in touch
3945

README.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fopenfga%2Fjs-sdk.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fopenfga%2Fjs-sdk?ref=badge_shield)
77
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/openfga/js-sdk/badge)](https://securityscorecards.dev/viewer/?uri=github.com/openfga/js-sdk)
88
[![Join our community](https://img.shields.io/badge/slack-cncf_%23openfga-40abb8.svg?logo=slack)](https://openfga.dev/community)
9-
[![X](https://img.shields.io/twitter/follow/openfga?color=%23179CF0&logo=twitter&style=flat-square "@openfga on Twitter")](https://x.com/openfga)
9+
[![X](https://img.shields.io/twitter/follow/openfga?color=%23179CF0&logo=x&style=flat-square "@openfga on X")](https://x.com/openfga)
1010

1111
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.
1212

@@ -17,6 +17,7 @@ This is an autogenerated JavaScript SDK for OpenFGA. It provides a wrapper aroun
1717
- [Installation](#installation)
1818
- [Getting Started](#getting-started)
1919
- [Initializing the API Client](#initializing-the-api-client)
20+
- [Custom Headers](#custom-headers)
2021
- [Get your Store ID](#get-your-store-id)
2122
- [Calling the API](#calling-the-api)
2223
- [Stores](#stores)
@@ -63,7 +64,7 @@ OpenFGA is designed to make it easy for application builders to model their perm
6364

6465
- [OpenFGA Documentation](https://openfga.dev/docs)
6566
- [OpenFGA API Documentation](https://openfga.dev/api/service)
66-
- [Twitter](https://twitter.com/openfga)
67+
- [X](https://x.com/openfga)
6768
- [OpenFGA Community](https://openfga.dev/community)
6869
- [Zanzibar Academy](https://zanzibar.academy)
6970
- [Google's Zanzibar Paper (2019)](https://research.google/pubs/pub48190/)
@@ -829,13 +830,7 @@ This SDK supports producing metrics that can be consumed as part of an [OpenTele
829830

830831
## Contributing
831832

832-
### Issues
833-
834-
If you have found a bug or if you have a feature request, please report them on the [sdk-generator repo](https://github.com/openfga/sdk-generator/issues) issues section. Please do not report security vulnerabilities on the public GitHub issue tracker.
835-
836-
### Pull Requests
837-
838-
While we accept Pull Requests on this repository, the SDKs are autogenerated so please consider additionally submitting your Pull Requests to the [sdk-generator](https://github.com/openfga/sdk-generator) and linking the two PRs together and to the corresponding issue. This will greatly assist the OpenFGA team in being able to give timely reviews as well as deploying fixes and updates to our other SDKs as well.
833+
See [CONTRIBUTING](./CONTRIBUTING.md) for details.
839834

840835
## Author
841836

base.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
1-
/**
2-
* JavaScript and Node.js SDK for OpenFGA
3-
*
4-
* API version: 1.x
5-
* Website: https://openfga.dev
6-
* Documentation: https://openfga.dev/docs
7-
* Support: https://openfga.dev/community
8-
* License: [Apache-2.0](https://github.com/openfga/js-sdk/blob/main/LICENSE)
9-
*
10-
* NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT.
11-
*/
12-
13-
14-
// Some imports not used depending on template conditions
151
import globalAxios, { AxiosInstance } from "axios";
162
import * as http from "http";
173
import * as https from "https";

client.ts

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,3 @@
1-
/**
2-
* JavaScript and Node.js SDK for OpenFGA
3-
*
4-
* API version: 1.x
5-
* Website: https://openfga.dev
6-
* Documentation: https://openfga.dev/docs
7-
* Support: https://openfga.dev/community
8-
* License: [Apache-2.0](https://github.com/openfga/js-sdk/blob/main/LICENSE)
9-
*
10-
* NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT.
11-
*/
12-
13-
141
import { AxiosResponse, AxiosInstance } from "axios";
152
import asyncPool = require("tiny-async-pool");
163

@@ -60,6 +47,7 @@ import {
6047
setHeaderIfNotSet,
6148
} from "./utils";
6249
import { isWellFormedUlidString } from "./validation";
50+
import {SdkConstants} from "./constants";
6351

6452
export type UserClientConfigurationParams = UserConfigurationParams & {
6553
storeId?: string;
@@ -101,10 +89,10 @@ export class ClientConfiguration extends Configuration {
10189
}
10290
}
10391

104-
const DEFAULT_MAX_METHOD_PARALLEL_REQS = 10;
105-
const DEFAULT_MAX_BATCH_SIZE = 50;
106-
const CLIENT_METHOD_HEADER = "X-OpenFGA-Client-Method";
107-
const CLIENT_BULK_REQUEST_ID_HEADER = "X-OpenFGA-Client-Bulk-Request-Id";
92+
const DEFAULT_MAX_METHOD_PARALLEL_REQS = SdkConstants.ClientMaxMethodParallelRequests;
93+
const DEFAULT_MAX_BATCH_SIZE = SdkConstants.ClientMaxBatchSize;
94+
const CLIENT_METHOD_HEADER = SdkConstants.ClientMethodHeader;
95+
const CLIENT_BULK_REQUEST_ID_HEADER = SdkConstants.ClientBulkRequestIdHeader;
10896

10997
export interface ClientRequestOpts {
11098
retryParams?: RetryParams;

common.ts

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,7 @@
1-
/**
2-
* JavaScript and Node.js SDK for OpenFGA
3-
*
4-
* API version: 1.x
5-
* Website: https://openfga.dev
6-
* Documentation: https://openfga.dev/docs
7-
* Support: https://openfga.dev/community
8-
* License: [Apache-2.0](https://github.com/openfga/js-sdk/blob/main/LICENSE)
9-
*
10-
* NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT.
11-
*/
12-
13-
141
import { AxiosInstance, AxiosRequestConfig, AxiosResponse } from "axios";
152

163
import { Configuration } from "./configuration";
4+
import { SdkConstants } from "./constants";
175
import type { Credentials } from "./credentials";
186
import {
197
FgaApiError,
@@ -26,14 +14,13 @@ import {
2614
} from "./errors";
2715
import { setNotEnumerableProperty } from "./utils";
2816
import { TelemetryAttribute, TelemetryAttributes } from "./telemetry/attributes";
29-
import { MetricRecorder } from "./telemetry/metrics";
3017
import { TelemetryHistograms } from "./telemetry/histograms";
3118

3219
/**
3320
*
3421
* @export
3522
*/
36-
export const DUMMY_BASE_URL = "https://example.com";
23+
export const DUMMY_BASE_URL = `https://${SdkConstants.SampleBaseDomain}`;
3724

3825
/**
3926
*

configuration.ts

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,16 @@
1-
/**
2-
* JavaScript and Node.js SDK for OpenFGA
3-
*
4-
* API version: 1.x
5-
* Website: https://openfga.dev
6-
* Documentation: https://openfga.dev/docs
7-
* Support: https://openfga.dev/community
8-
* License: [Apache-2.0](https://github.com/openfga/js-sdk/blob/main/LICENSE)
9-
*
10-
* NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT.
11-
*/
12-
13-
141
import { ApiTokenConfig, AuthCredentialsConfig, ClientCredentialsConfig, CredentialsMethod } from "./credentials/types";
152
import { FgaValidationError, } from "./errors";
16-
import { assertParamExists, isWellFormedUlidString, isWellFormedUriString } from "./validation";
3+
import { assertParamExists, isWellFormedUriString } from "./validation";
174
import { TelemetryConfig, TelemetryConfiguration } from "./telemetry/configuration";
5+
import {SdkConstants} from "./constants";
186

197
// default maximum number of retry
20-
const DEFAULT_MAX_RETRY = 3;
8+
const DEFAULT_MAX_RETRY = SdkConstants.DefaultMaxRetry;
219

2210
// default minimum wait period in retry - but will backoff exponentially
23-
const DEFAULT_MIN_WAIT_MS = 100;
11+
const DEFAULT_MIN_WAIT_MS = SdkConstants.DefaultMinWaitInMs;
2412

25-
const DEFAULT_USER_AGENT = "openfga-sdk js/0.9.0";
13+
const DEFAULT_USER_AGENT = SdkConstants.UserAgent;
2614

2715
export interface RetryParams {
2816
maxRetry?: number;
@@ -45,7 +33,7 @@ export interface UserConfigurationParams {
4533
telemetry?: TelemetryConfig;
4634
}
4735

48-
export function GetDefaultRetryParams (maxRetry = DEFAULT_MAX_RETRY, minWaitInMs = DEFAULT_MIN_WAIT_MS) {
36+
export function GetDefaultRetryParams (maxRetry: number = DEFAULT_MAX_RETRY, minWaitInMs: number = DEFAULT_MIN_WAIT_MS) {
4937
return {
5038
maxRetry: maxRetry,
5139
minWaitInMs: minWaitInMs,
@@ -75,7 +63,7 @@ export class Configuration {
7563
* @type {string}
7664
* @memberof Configuration
7765
*/
78-
private static sdkVersion = "0.9.0";
66+
private static sdkVersion = SdkConstants.SdkVersion;
7967

8068
/**
8169
* provide the full api URL (e.g. `https://api.fga.example`)

0 commit comments

Comments
 (0)