diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 3c54024..927f9a4 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -2,8 +2,8 @@ speakeasyVersion: 1.335.2 sources: source1: sourceNamespace: source-1 - sourceRevisionDigest: sha256:70427d8936519bbb31834da18b6a64ce50e62c8caa39ab27fadf1279d25bb412 - sourceBlobDigest: sha256:41d6992001501dc4f8757117e3902f01178807fd20fbd9ce3a0b33ac2a99e283 + sourceRevisionDigest: sha256:eabb4a6af01606d6e6fb07e6381921ecc0b25e031e2d172afa497a17aa8d4e1b + sourceBlobDigest: sha256:614ef27789e2ab0d262263d1dbf21398cb6240c4c4173bddad2fa3fcff4cada0 tags: - latest - main @@ -11,9 +11,9 @@ targets: accounting: source: source1 sourceNamespace: source-1 - sourceRevisionDigest: sha256:43d9d3d838fac17eddc84d2acb5dcb0b499fd6e5bff338951c547b24d496da97 - sourceBlobDigest: sha256:5ac74c70fd06c09876fd12094a844951d898b9c3aead02a8d50b3db56ed4f135 - outLocation: accounting + sourceRevisionDigest: sha256:eabb4a6af01606d6e6fb07e6381921ecc0b25e031e2d172afa497a17aa8d4e1b + sourceBlobDigest: sha256:614ef27789e2ab0d262263d1dbf21398cb6240c4c4173bddad2fa3fcff4cada0 + outLocation: ./accounting finance: source: source1 sourceNamespace: source-1 diff --git a/accounting/.speakeasy/gen.lock b/accounting/.speakeasy/gen.lock index 69b72c8..7e30257 100755 --- a/accounting/.speakeasy/gen.lock +++ b/accounting/.speakeasy/gen.lock @@ -3,17 +3,23 @@ id: de44aa14-d51e-4f37-b22e-356d78ca0ebc management: docChecksum: 1bdb7a6f8bf3995d4b40475228403253 docVersion: 1.0.0 - speakeasyVersion: 1.326.0 - generationVersion: 2.359.0 - releaseVersion: 0.0.1 - configChecksum: a855a32d4cdc76e6341a97559e3b249f + speakeasyVersion: 1.335.2 + generationVersion: 2.372.3 + releaseVersion: 0.1.0 + configChecksum: e98d0a9ce123c36dd6a76567c68850cf + repoURL: https://github.com/ryan-timothy-albert/sample-ts-monorepo.git + repoSubDirectory: accounting + installationURL: https://gitpkg.now.sh/ryan-timothy-albert/sample-ts-monorepo/accounting + published: true features: typescript: additionalDependencies: 0.1.0 - core: 3.11.0 + core: 3.11.6 + defaultEnabledRetries: 0.1.0 globalSecurityCallbacks: 0.1.0 globalServerURLs: 2.82.4 responseFormat: 0.2.3 + retries: 2.83.0 sdkHooks: 0.1.0 generatedFiles: - src/sdk/pets.ts @@ -59,6 +65,7 @@ generatedFiles: - docs/models/components/pet.md - docs/models/components/errort.md - docs/sdks/accountingsdk/README.md + - docs/lib/utils/retryconfig.md - docs/sdks/pets/README.md - USAGE.md - .gitattributes diff --git a/accounting/.speakeasy/gen.yaml b/accounting/.speakeasy/gen.yaml index b28b87f..110316d 100644 --- a/accounting/.speakeasy/gen.yaml +++ b/accounting/.speakeasy/gen.yaml @@ -12,7 +12,7 @@ generation: auth: oAuth2ClientCredentialsEnabled: true typescript: - version: 0.0.1 + version: 0.1.0 additionalDependencies: dependencies: {} devDependencies: {} diff --git a/accounting/README.md b/accounting/README.md index ba42da0..134e9a5 100644 --- a/accounting/README.md +++ b/accounting/README.md @@ -22,25 +22,25 @@ It has been generated successfully based on your OpenAPI spec. However, it is no ### NPM ```bash -npm add +npm add ryan-accounting ``` ### PNPM ```bash -pnpm add +pnpm add ryan-accounting ``` ### Bun ```bash -bun add +bun add ryan-accounting ``` ### Yarn ```bash -yarn add zod +yarn add ryan-accounting zod # Note that Yarn does not install peer dependencies automatically. You will need # to install zod as shown above. @@ -233,6 +233,71 @@ const sdk = new AccountingSDK({ httpClient }); ``` + +## Retries + +Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK. + +To change the default retry strategy for a single API call, simply provide a retryConfig object to the call: +```typescript +import { AccountingSDK } from "ryan-accounting"; + +const accountingSDK = new AccountingSDK(); + +async function run() { + const result = await accountingSDK.pets.listPets( + {}, + { + retries: { + strategy: "backoff", + backoff: { + initialInterval: 1, + maxInterval: 50, + exponent: 1.1, + maxElapsedTime: 100, + }, + retryConnectionErrors: false, + }, + } + ); + + // Handle the result + console.log(result); +} + +run(); + +``` + +If you'd like to override the default retry strategy for all operations that support retries, you can provide a retryConfig at SDK initialization: +```typescript +import { AccountingSDK } from "ryan-accounting"; + +const accountingSDK = new AccountingSDK({ + retryConfig: { + strategy: "backoff", + backoff: { + initialInterval: 1, + maxInterval: 50, + exponent: 1.1, + maxElapsedTime: 100, + }, + retryConnectionErrors: false, + }, +}); + +async function run() { + const result = await accountingSDK.pets.listPets({}); + + // Handle the result + console.log(result); +} + +run(); + +``` + + # Development diff --git a/accounting/RELEASES.md b/accounting/RELEASES.md new file mode 100644 index 0000000..e4f729d --- /dev/null +++ b/accounting/RELEASES.md @@ -0,0 +1,11 @@ + + +## 2024-07-15 19:38:00 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.335.2 (2.372.3) https://github.com/speakeasy-api/speakeasy +### Generated +- [typescript v0.1.0] accounting +### Releases +- [NPM v0.1.0] https://www.npmjs.com/package/ryan-accounting/v/0.1.0 - accounting \ No newline at end of file diff --git a/accounting/RUNTIMES.md b/accounting/RUNTIMES.md index 71fa3da..d08a0c0 100644 --- a/accounting/RUNTIMES.md +++ b/accounting/RUNTIMES.md @@ -3,7 +3,7 @@ This SDK is intended to be used in JavaScript runtimes that support the following features: * [Web Fetch API][web-fetch] -* [Web Streams API](web-streams) and in particular `ReadableStream` +* [Web Streams API][web-streams] and in particular `ReadableStream` * [Async iterables][async-iter] using `Symbol.asyncIterator` [web-fetch]: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API diff --git a/accounting/docs/lib/utils/retryconfig.md b/accounting/docs/lib/utils/retryconfig.md new file mode 100644 index 0000000..08f95f4 --- /dev/null +++ b/accounting/docs/lib/utils/retryconfig.md @@ -0,0 +1,24 @@ +# RetryConfig + +Allows customizing the default retry configuration. It is only permitted in methods that accept retry policies. + +## Fields + +| Name | Type | Description | Example | +| ------------------------- | ----------------------------------- | ------------------------------------------------------------------------------------------ | ----------- | +| `strategy` | `"backoff" | "none"` | The retry strategy to use. | `"backoff"` | +| `backoff` | [BackoffStrategy](#backoffstrategy) | When strategy is "backoff", this configurates for the backoff parameters. | | +| `retryConnectionErrors` | `*boolean*` | When strategy is "backoff", this determines whether or not to retry on connection errors. | `true` | + +## BackoffStrategy + +The backoff strategy allows retrying a request with an exponential backoff between each retry. + +### Fields + +| Name | Type | Description | Example | +| ------------------ | ------------ | ----------------------------------------- | -------- | +| `initialInterval` | `*number*` | The initial interval in milliseconds. | `500` | +| `maxInterval` | `*number*` | The maximum interval in milliseconds. | `60000` | +| `exponent` | `*number*` | The exponent to use for the backoff. | `1.5` | +| `maxElapsedTime` | `*number*` | The maximum elapsed time in milliseconds. | `300000` | \ No newline at end of file diff --git a/accounting/docs/sdks/pets/README.md b/accounting/docs/sdks/pets/README.md index c3f8b03..125feac 100644 --- a/accounting/docs/sdks/pets/README.md +++ b/accounting/docs/sdks/pets/README.md @@ -35,6 +35,7 @@ run(); | `request` | [operations.ListPetsRequest](../../models/operations/listpetsrequest.md) | :heavy_check_mark: | The request object to use for the request. | | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | +| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | ### Response @@ -77,6 +78,7 @@ run(); | `request` | [components.Pet](../../models/components/pet.md) | :heavy_check_mark: | The request object to use for the request. | | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | +| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | ### Response @@ -118,6 +120,7 @@ run(); | `request` | [operations.ShowPetByIdRequest](../../models/operations/showpetbyidrequest.md) | :heavy_check_mark: | The request object to use for the request. | | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | +| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | ### Response diff --git a/accounting/jsr.json b/accounting/jsr.json index f547d29..d2cfcab 100644 --- a/accounting/jsr.json +++ b/accounting/jsr.json @@ -2,7 +2,7 @@ { "name": "ryan-accounting", - "version": "0.0.1", + "version": "0.1.0", "exports": { ".": "./src/index.ts", "./models/errors": "./src/models/errors/index.ts", diff --git a/accounting/package-lock.json b/accounting/package-lock.json index 42c6f00..6024380 100644 --- a/accounting/package-lock.json +++ b/accounting/package-lock.json @@ -1,14 +1,13 @@ { "name": "ryan-accounting", - "version": "0.0.1", + "version": "0.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "ryan-accounting", - "version": "0.0.1", + "version": "0.1.0", "devDependencies": { - "@types/jsonpath": "^0.2.4", "@typescript-eslint/eslint-plugin": "^7.7.1", "@typescript-eslint/parser": "^7.7.1", "eslint": "^8.57.0", @@ -197,12 +196,6 @@ "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", "dev": true }, - "node_modules/@types/jsonpath": { - "version": "0.2.4", - "resolved": "https://registry.npmjs.org/@types/jsonpath/-/jsonpath-0.2.4.tgz", - "integrity": "sha512-K3hxB8Blw0qgW6ExKgMbXQv2UPZBoE2GqLpVY+yr7nMD2Pq86lsuIzyAaiQ7eMqFL5B6di6pxSkogLJEyEHoGA==", - "dev": true - }, "node_modules/@typescript-eslint/eslint-plugin": { "version": "7.15.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.15.0.tgz", @@ -3216,12 +3209,6 @@ "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", "dev": true }, - "@types/jsonpath": { - "version": "0.2.4", - "resolved": "https://registry.npmjs.org/@types/jsonpath/-/jsonpath-0.2.4.tgz", - "integrity": "sha512-K3hxB8Blw0qgW6ExKgMbXQv2UPZBoE2GqLpVY+yr7nMD2Pq86lsuIzyAaiQ7eMqFL5B6di6pxSkogLJEyEHoGA==", - "dev": true - }, "@typescript-eslint/eslint-plugin": { "version": "7.15.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.15.0.tgz", diff --git a/accounting/package.json b/accounting/package.json index 4e1ae19..c89bb00 100644 --- a/accounting/package.json +++ b/accounting/package.json @@ -1,9 +1,14 @@ { "name": "ryan-accounting", - "version": "0.0.1", + "version": "0.1.0", "author": "ryan-timothy-albert", "main": "./index.js", "sideEffects": false, + "repository": { + "type": "git", + "url": "https://github.com/ryan-timothy-albert/sample-ts-monorepo.git", + "directory": "accounting" + }, "scripts": { "lint": "eslint --max-warnings=0 src", "build": "tsc", @@ -13,7 +18,6 @@ "zod": ">= 3" }, "devDependencies": { - "@types/jsonpath": "^0.2.4", "@typescript-eslint/eslint-plugin": "^7.7.1", "@typescript-eslint/parser": "^7.7.1", "eslint": "^8.57.0", diff --git a/accounting/src/lib/config.ts b/accounting/src/lib/config.ts index ae97070..c5d2b3c 100644 --- a/accounting/src/lib/config.ts +++ b/accounting/src/lib/config.ts @@ -25,6 +25,7 @@ export type SDKOptions = { * Allows overriding the default retry config used by the SDK */ retryConfig?: RetryConfig; + timeoutMs?: number; }; export function serverURLFromOptions(options: SDKOptions): URL | null { @@ -47,7 +48,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null { export const SDK_METADATA = { language: "typescript", openapiDocVersion: "1.0.0", - sdkVersion: "0.0.1", - genVersion: "2.359.0", - userAgent: "speakeasy-sdk/typescript 0.0.1 2.359.0 1.0.0 ryan-accounting", + sdkVersion: "0.1.0", + genVersion: "2.372.3", + userAgent: "speakeasy-sdk/typescript 0.1.0 2.372.3 1.0.0 ryan-accounting", } as const; diff --git a/accounting/src/lib/sdks.ts b/accounting/src/lib/sdks.ts index cbda9d8..22d8a5c 100644 --- a/accounting/src/lib/sdks.ts +++ b/accounting/src/lib/sdks.ts @@ -4,13 +4,33 @@ import { ResponseMatcher, HTTPClient, matchStatusCode } from "./http.js"; import { SecurityState, resolveSecurity } from "./security.js"; +import { retry, RetryConfig } from "./retries.js"; import { pathToFunc } from "./url.js"; import { encodeForm } from "./encodings.js"; import { stringToBase64 } from "./base64.js"; +import { SDK_METADATA } from "./config.js"; import { SDKHooks } from "../hooks/hooks.js"; import { HookContext } from "../hooks/types.js"; export type RequestOptions = { + /** + * Sets a timeout, in milliseconds, on HTTP requests made by an SDK method. If + * `fetchOptions.signal` is set then it will take precedence over this option. + */ + timeoutMs?: number; + /** + * Set or override a retry policy on HTTP calls. + */ + retries?: RetryConfig; + /** + * Specifies the status codes which should be retried using the given retry policy. + */ + retryCodes?: string[]; + /** + * Sets various request options on the `fetch` call made by an SDK method. + * + * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options|Request} + */ fetchOptions?: Omit; }; @@ -22,8 +42,21 @@ type RequestConfig = { body?: RequestInit["body"]; headers?: HeadersInit; security?: SecurityState | null; + uaHeader?: string; + timeoutMs?: number; }; +const gt: unknown = typeof globalThis === "undefined" ? null : globalThis; +const webWorkerLike = + typeof gt === "object" && + gt != null && + "importScripts" in gt && + typeof gt["importScripts"] === "function"; +const isBrowserLike = + webWorkerLike || + (typeof navigator !== "undefined" && "serviceWorker" in navigator) || + (typeof window === "object" && typeof window.document !== "undefined"); + export class ClientSDK { private readonly client: HTTPClient; protected readonly baseURL: URL | null; @@ -100,10 +133,26 @@ export class ClientSDK { headers.set(k, v); } + // Only set user agent header in non-browser-like environments since CORS + // policy disallows setting it in browsers e.g. Chrome throws an error. + if (!isBrowserLike) { + headers.set(conf.uaHeader ?? "user-agent", SDK_METADATA.userAgent); + } + + let fetchOptions = options?.fetchOptions; + if (!fetchOptions?.signal && conf.timeoutMs && conf.timeoutMs > 0) { + const timeoutSignal = AbortSignal.timeout(conf.timeoutMs); + if (!fetchOptions) { + fetchOptions = { signal: timeoutSignal }; + } else { + fetchOptions.signal = timeoutSignal; + } + } + const input = this.hooks$.beforeCreateRequest(context, { url: reqURL, options: { - ...options?.fetchOptions, + ...fetchOptions, body: conf.body ?? null, headers, method, @@ -114,27 +163,40 @@ export class ClientSDK { } protected async do$( - req: Request, + request: Request, options: { context: HookContext; errorCodes: number | string | (number | string)[]; + retryConfig?: RetryConfig | undefined; + retryCodes?: string[] | undefined; } ): Promise { const { context, errorCodes } = options; - - let response = await this.client.request(await this.hooks$.beforeRequest(context, req)); - - if (matchStatusCode(response, errorCodes)) { - const result = await this.hooks$.afterError(context, response, null); - if (result.error) { - throw result.error; - } - response = result.response || response; - } else { - response = await this.hooks$.afterSuccess(context, response); - } - - return response; + const retryConfig = options.retryConfig || { strategy: "none" }; + const retryCodes = options.retryCodes || []; + + return retry( + async () => { + const req = request.clone(); + + let response = await this.client.request( + await this.hooks$.beforeRequest(context, req) + ); + + if (matchStatusCode(response, errorCodes)) { + const result = await this.hooks$.afterError(context, response, null); + if (result.error) { + throw result.error; + } + response = result.response || response; + } else { + response = await this.hooks$.afterSuccess(context, response); + } + + return response; + }, + { config: retryConfig, statusCodes: retryCodes } + ); } protected matcher(): ResponseMatcher { diff --git a/accounting/src/models/components/error.ts b/accounting/src/models/components/error.ts index 1ebc730..ccf0cfb 100644 --- a/accounting/src/models/components/error.ts +++ b/accounting/src/models/components/error.ts @@ -10,19 +10,32 @@ export type ErrorT = { }; /** @internal */ -export namespace ErrorT$ { - export const inboundSchema: z.ZodType = z.object({ - code: z.number().int(), - message: z.string(), - }); +export const ErrorT$inboundSchema: z.ZodType = z.object({ + code: z.number().int(), + message: z.string(), +}); - export type Outbound = { - code: number; - message: string; - }; +/** @internal */ +export type ErrorT$Outbound = { + code: number; + message: string; +}; - export const outboundSchema: z.ZodType = z.object({ - code: z.number().int(), - message: z.string(), - }); +/** @internal */ +export const ErrorT$outboundSchema: z.ZodType = z.object({ + code: z.number().int(), + message: z.string(), +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace ErrorT$ { + /** @deprecated use `ErrorT$inboundSchema` instead. */ + export const inboundSchema = ErrorT$inboundSchema; + /** @deprecated use `ErrorT$outboundSchema` instead. */ + export const outboundSchema = ErrorT$outboundSchema; + /** @deprecated use `ErrorT$Outbound` instead. */ + export type Outbound = ErrorT$Outbound; } diff --git a/accounting/src/models/components/pet.ts b/accounting/src/models/components/pet.ts index 4b766b0..2c80376 100644 --- a/accounting/src/models/components/pet.ts +++ b/accounting/src/models/components/pet.ts @@ -11,22 +11,35 @@ export type Pet = { }; /** @internal */ -export namespace Pet$ { - export const inboundSchema: z.ZodType = z.object({ - id: z.number().int(), - name: z.string(), - tag: z.string().optional(), - }); +export const Pet$inboundSchema: z.ZodType = z.object({ + id: z.number().int(), + name: z.string(), + tag: z.string().optional(), +}); + +/** @internal */ +export type Pet$Outbound = { + id: number; + name: string; + tag?: string | undefined; +}; - export type Outbound = { - id: number; - name: string; - tag?: string | undefined; - }; +/** @internal */ +export const Pet$outboundSchema: z.ZodType = z.object({ + id: z.number().int(), + name: z.string(), + tag: z.string().optional(), +}); - export const outboundSchema: z.ZodType = z.object({ - id: z.number().int(), - name: z.string(), - tag: z.string().optional(), - }); +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace Pet$ { + /** @deprecated use `Pet$inboundSchema` instead. */ + export const inboundSchema = Pet$inboundSchema; + /** @deprecated use `Pet$outboundSchema` instead. */ + export const outboundSchema = Pet$outboundSchema; + /** @deprecated use `Pet$Outbound` instead. */ + export type Outbound = Pet$Outbound; } diff --git a/accounting/src/models/operations/listpets.ts b/accounting/src/models/operations/listpets.ts index 0ca1dc9..c2f0dae 100644 --- a/accounting/src/models/operations/listpets.ts +++ b/accounting/src/models/operations/listpets.ts @@ -21,66 +21,115 @@ export type ListPetsResponse = { }; /** @internal */ -export namespace ListPetsRequest$ { - export const inboundSchema: z.ZodType = z.object({ +export const ListPetsRequest$inboundSchema: z.ZodType = + z.object({ limit: z.number().int().optional(), }); - export type Outbound = { - limit?: number | undefined; - }; +/** @internal */ +export type ListPetsRequest$Outbound = { + limit?: number | undefined; +}; - export const outboundSchema: z.ZodType = z.object({ - limit: z.number().int().optional(), - }); +/** @internal */ +export const ListPetsRequest$outboundSchema: z.ZodType< + ListPetsRequest$Outbound, + z.ZodTypeDef, + ListPetsRequest +> = z.object({ + limit: z.number().int().optional(), +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace ListPetsRequest$ { + /** @deprecated use `ListPetsRequest$inboundSchema` instead. */ + export const inboundSchema = ListPetsRequest$inboundSchema; + /** @deprecated use `ListPetsRequest$outboundSchema` instead. */ + export const outboundSchema = ListPetsRequest$outboundSchema; + /** @deprecated use `ListPetsRequest$Outbound` instead. */ + export type Outbound = ListPetsRequest$Outbound; } /** @internal */ +export const ListPetsResponseResult$inboundSchema: z.ZodType< + ListPetsResponseResult, + z.ZodTypeDef, + unknown +> = z.union([components.ErrorT$inboundSchema, z.array(components.Pet$inboundSchema)]); + +/** @internal */ +export type ListPetsResponseResult$Outbound = + | components.ErrorT$Outbound + | Array; + +/** @internal */ +export const ListPetsResponseResult$outboundSchema: z.ZodType< + ListPetsResponseResult$Outbound, + z.ZodTypeDef, + ListPetsResponseResult +> = z.union([components.ErrorT$outboundSchema, z.array(components.Pet$outboundSchema)]); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ export namespace ListPetsResponseResult$ { - export const inboundSchema: z.ZodType = z.union([ - components.ErrorT$.inboundSchema, - z.array(components.Pet$.inboundSchema), - ]); - - export type Outbound = components.ErrorT$.Outbound | Array; - export const outboundSchema: z.ZodType = - z.union([components.ErrorT$.outboundSchema, z.array(components.Pet$.outboundSchema)]); + /** @deprecated use `ListPetsResponseResult$inboundSchema` instead. */ + export const inboundSchema = ListPetsResponseResult$inboundSchema; + /** @deprecated use `ListPetsResponseResult$outboundSchema` instead. */ + export const outboundSchema = ListPetsResponseResult$outboundSchema; + /** @deprecated use `ListPetsResponseResult$Outbound` instead. */ + export type Outbound = ListPetsResponseResult$Outbound; } /** @internal */ -export namespace ListPetsResponse$ { - export const inboundSchema: z.ZodType = z - .object({ - Headers: z.record(z.array(z.string())), - Result: z.union([ - components.ErrorT$.inboundSchema, - z.array(components.Pet$.inboundSchema), - ]), - }) - .transform((v) => { - return remap$(v, { - Headers: "headers", - Result: "result", - }); +export const ListPetsResponse$inboundSchema: z.ZodType = z + .object({ + Headers: z.record(z.array(z.string())), + Result: z.union([components.ErrorT$inboundSchema, z.array(components.Pet$inboundSchema)]), + }) + .transform((v) => { + return remap$(v, { + Headers: "headers", + Result: "result", }); + }); - export type Outbound = { - Headers: { [k: string]: Array }; - Result: components.ErrorT$.Outbound | Array; - }; - - export const outboundSchema: z.ZodType = z - .object({ - headers: z.record(z.array(z.string())), - result: z.union([ - components.ErrorT$.outboundSchema, - z.array(components.Pet$.outboundSchema), - ]), - }) - .transform((v) => { - return remap$(v, { - headers: "Headers", - result: "Result", - }); +/** @internal */ +export type ListPetsResponse$Outbound = { + Headers: { [k: string]: Array }; + Result: components.ErrorT$Outbound | Array; +}; + +/** @internal */ +export const ListPetsResponse$outboundSchema: z.ZodType< + ListPetsResponse$Outbound, + z.ZodTypeDef, + ListPetsResponse +> = z + .object({ + headers: z.record(z.array(z.string())), + result: z.union([components.ErrorT$outboundSchema, z.array(components.Pet$outboundSchema)]), + }) + .transform((v) => { + return remap$(v, { + headers: "Headers", + result: "Result", }); + }); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace ListPetsResponse$ { + /** @deprecated use `ListPetsResponse$inboundSchema` instead. */ + export const inboundSchema = ListPetsResponse$inboundSchema; + /** @deprecated use `ListPetsResponse$outboundSchema` instead. */ + export const outboundSchema = ListPetsResponse$outboundSchema; + /** @deprecated use `ListPetsResponse$Outbound` instead. */ + export type Outbound = ListPetsResponse$Outbound; } diff --git a/accounting/src/models/operations/showpetbyid.ts b/accounting/src/models/operations/showpetbyid.ts index faabaef..852ca9f 100644 --- a/accounting/src/models/operations/showpetbyid.ts +++ b/accounting/src/models/operations/showpetbyid.ts @@ -15,30 +15,67 @@ export type ShowPetByIdRequest = { export type ShowPetByIdResponse = components.ErrorT | components.Pet; /** @internal */ -export namespace ShowPetByIdRequest$ { - export const inboundSchema: z.ZodType = z.object({ - petId: z.string(), - }); +export const ShowPetByIdRequest$inboundSchema: z.ZodType< + ShowPetByIdRequest, + z.ZodTypeDef, + unknown +> = z.object({ + petId: z.string(), +}); - export type Outbound = { - petId: string; - }; +/** @internal */ +export type ShowPetByIdRequest$Outbound = { + petId: string; +}; - export const outboundSchema: z.ZodType = z.object({ - petId: z.string(), - }); +/** @internal */ +export const ShowPetByIdRequest$outboundSchema: z.ZodType< + ShowPetByIdRequest$Outbound, + z.ZodTypeDef, + ShowPetByIdRequest +> = z.object({ + petId: z.string(), +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace ShowPetByIdRequest$ { + /** @deprecated use `ShowPetByIdRequest$inboundSchema` instead. */ + export const inboundSchema = ShowPetByIdRequest$inboundSchema; + /** @deprecated use `ShowPetByIdRequest$outboundSchema` instead. */ + export const outboundSchema = ShowPetByIdRequest$outboundSchema; + /** @deprecated use `ShowPetByIdRequest$Outbound` instead. */ + export type Outbound = ShowPetByIdRequest$Outbound; } /** @internal */ +export const ShowPetByIdResponse$inboundSchema: z.ZodType< + ShowPetByIdResponse, + z.ZodTypeDef, + unknown +> = z.union([components.ErrorT$inboundSchema, components.Pet$inboundSchema]); + +/** @internal */ +export type ShowPetByIdResponse$Outbound = components.ErrorT$Outbound | components.Pet$Outbound; + +/** @internal */ +export const ShowPetByIdResponse$outboundSchema: z.ZodType< + ShowPetByIdResponse$Outbound, + z.ZodTypeDef, + ShowPetByIdResponse +> = z.union([components.ErrorT$outboundSchema, components.Pet$outboundSchema]); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ export namespace ShowPetByIdResponse$ { - export const inboundSchema: z.ZodType = z.union([ - components.ErrorT$.inboundSchema, - components.Pet$.inboundSchema, - ]); - - export type Outbound = components.ErrorT$.Outbound | components.Pet$.Outbound; - export const outboundSchema: z.ZodType = z.union([ - components.ErrorT$.outboundSchema, - components.Pet$.outboundSchema, - ]); + /** @deprecated use `ShowPetByIdResponse$inboundSchema` instead. */ + export const inboundSchema = ShowPetByIdResponse$inboundSchema; + /** @deprecated use `ShowPetByIdResponse$outboundSchema` instead. */ + export const outboundSchema = ShowPetByIdResponse$outboundSchema; + /** @deprecated use `ShowPetByIdResponse$Outbound` instead. */ + export type Outbound = ShowPetByIdResponse$Outbound; } diff --git a/accounting/src/sdk/pets.ts b/accounting/src/sdk/pets.ts index ddd5cc3..8023a12 100644 --- a/accounting/src/sdk/pets.ts +++ b/accounting/src/sdk/pets.ts @@ -3,7 +3,7 @@ */ import { SDKHooks } from "../hooks/hooks.js"; -import { SDK_METADATA, SDKOptions, serverURLFromOptions } from "../lib/config.js"; +import { SDKOptions, serverURLFromOptions } from "../lib/config.js"; import { encodeFormQuery as encodeFormQuery$, encodeJSON as encodeJSON$, @@ -50,13 +50,10 @@ export class Pets extends ClientSDK { options?: RequestOptions ): Promise { const input$ = typeof request === "undefined" ? {} : request; - const headers$ = new Headers(); - headers$.set("user-agent", SDK_METADATA.userAgent); - headers$.set("Accept", "application/json"); const payload$ = schemas$.parse( input$, - (value$) => operations.ListPetsRequest$.outboundSchema.parse(value$), + (value$) => operations.ListPetsRequest$outboundSchema.parse(value$), "Input validation failed" ); const body$ = null; @@ -67,25 +64,40 @@ export class Pets extends ClientSDK { limit: payload$.limit, }); + const headers$ = new Headers({ + Accept: "application/json", + }); + const context = { operationID: "listPets", oAuth2Scopes: [], securitySource: null }; - const doOptions = { context, errorCodes: ["4XX", "5XX"] }; const request$ = this.createRequest$( context, - { method: "GET", path: path$, headers: headers$, query: query$, body: body$ }, + { + method: "GET", + path: path$, + headers: headers$, + query: query$, + body: body$, + timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1, + }, options ); - const response = await this.do$(request$, doOptions); + const response = await this.do$(request$, { + context, + errorCodes: ["4XX", "5XX"], + retryConfig: options?.retries || this.options$.retryConfig, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + }); const responseFields$ = { HttpMeta: { Response: response, Request: request$ }, }; const [result$] = await this.matcher() - .json(200, operations.ListPetsResponse$, { hdrs: true, key: "Result" }) + .json(200, operations.ListPetsResponse$inboundSchema, { hdrs: true, key: "Result" }) .fail(["4XX", "5XX"]) - .json("default", operations.ListPetsResponse$, { key: "Result" }) + .json("default", operations.ListPetsResponse$inboundSchema, { key: "Result" }) .match(response, { extraFields: responseFields$ }); return result$; @@ -99,14 +111,10 @@ export class Pets extends ClientSDK { options?: RequestOptions ): Promise { const input$ = request; - const headers$ = new Headers(); - headers$.set("user-agent", SDK_METADATA.userAgent); - headers$.set("Content-Type", "application/json"); - headers$.set("Accept", "application/json"); const payload$ = schemas$.parse( input$, - (value$) => components.Pet$.outboundSchema.parse(value$), + (value$) => components.Pet$outboundSchema.parse(value$), "Input validation failed" ); const body$ = encodeJSON$("body", payload$, { explode: true }); @@ -115,21 +123,37 @@ export class Pets extends ClientSDK { const query$ = ""; + const headers$ = new Headers({ + "Content-Type": "application/json", + Accept: "application/json", + }); + const context = { operationID: "createPets", oAuth2Scopes: [], securitySource: null }; - const doOptions = { context, errorCodes: ["4XX", "5XX"] }; const request$ = this.createRequest$( context, - { method: "POST", path: path$, headers: headers$, query: query$, body: body$ }, + { + method: "POST", + path: path$, + headers: headers$, + query: query$, + body: body$, + timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1, + }, options ); - const response = await this.do$(request$, doOptions); + const response = await this.do$(request$, { + context, + errorCodes: ["4XX", "5XX"], + retryConfig: options?.retries || this.options$.retryConfig, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + }); const [result$] = await this.matcher() - .void(201, components.ErrorT$.inboundSchema.optional()) + .void(201, components.ErrorT$inboundSchema.optional()) .fail(["4XX", "5XX"]) - .json("default", components.ErrorT$.inboundSchema.optional()) + .json("default", components.ErrorT$inboundSchema.optional()) .match(response); return result$; @@ -143,13 +167,10 @@ export class Pets extends ClientSDK { options?: RequestOptions ): Promise { const input$ = request; - const headers$ = new Headers(); - headers$.set("user-agent", SDK_METADATA.userAgent); - headers$.set("Accept", "application/json"); const payload$ = schemas$.parse( input$, - (value$) => operations.ShowPetByIdRequest$.outboundSchema.parse(value$), + (value$) => operations.ShowPetByIdRequest$outboundSchema.parse(value$), "Input validation failed" ); const body$ = null; @@ -164,21 +185,36 @@ export class Pets extends ClientSDK { const query$ = ""; + const headers$ = new Headers({ + Accept: "application/json", + }); + const context = { operationID: "showPetById", oAuth2Scopes: [], securitySource: null }; - const doOptions = { context, errorCodes: ["4XX", "5XX"] }; const request$ = this.createRequest$( context, - { method: "GET", path: path$, headers: headers$, query: query$, body: body$ }, + { + method: "GET", + path: path$, + headers: headers$, + query: query$, + body: body$, + timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1, + }, options ); - const response = await this.do$(request$, doOptions); + const response = await this.do$(request$, { + context, + errorCodes: ["4XX", "5XX"], + retryConfig: options?.retries || this.options$.retryConfig, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + }); const [result$] = await this.matcher() - .json(200, operations.ShowPetByIdResponse$) + .json(200, operations.ShowPetByIdResponse$inboundSchema) .fail(["4XX", "5XX"]) - .json("default", operations.ShowPetByIdResponse$) + .json("default", operations.ShowPetByIdResponse$inboundSchema) .match(response); return result$;