diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 67fda8f..a65c623 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,9 +1,9 @@ -speakeasyVersion: 1.326.0 +speakeasyVersion: 1.326.3 sources: source1: sourceNamespace: source-1 - sourceRevisionDigest: sha256:fa12d729164441d38e10168379d030992371d56c5c1e450902936678b79e872c - sourceBlobDigest: sha256:7d5025103f5f83ffe0d1a94b5a28b4f06a7e9c9516a5b5ea19fd5d2b48db83ea + sourceRevisionDigest: sha256:ac49c0f4c6476fb2b93161605a5d4f97663215a7835cac19e7c0d16cd2e9d39b + sourceBlobDigest: sha256:ee8b7da07674ee2a33ec867b19b8c8a8d3cd5490061478d253dea544ac5d2d75 tags: - latest - main @@ -23,8 +23,8 @@ targets: lending: source: source1 sourceNamespace: source-1 - sourceRevisionDigest: sha256:fa12d729164441d38e10168379d030992371d56c5c1e450902936678b79e872c - sourceBlobDigest: sha256:7d5025103f5f83ffe0d1a94b5a28b4f06a7e9c9516a5b5ea19fd5d2b48db83ea + sourceRevisionDigest: sha256:ac49c0f4c6476fb2b93161605a5d4f97663215a7835cac19e7c0d16cd2e9d39b + sourceBlobDigest: sha256:ee8b7da07674ee2a33ec867b19b8c8a8d3cd5490061478d253dea544ac5d2d75 outLocation: lending workflow: workflowVersion: 1.0.0 diff --git a/lending/.speakeasy/gen.lock b/lending/.speakeasy/gen.lock index 3319cb7..c1470cd 100755 --- a/lending/.speakeasy/gen.lock +++ b/lending/.speakeasy/gen.lock @@ -3,10 +3,10 @@ id: 7caa457a-d738-4713-931d-4e4f19784732 management: docChecksum: 1bdb7a6f8bf3995d4b40475228403253 docVersion: 1.0.0 - speakeasyVersion: 1.326.0 - generationVersion: 2.359.0 - releaseVersion: 0.0.15 - configChecksum: 492e7e7fbc6bd7641e87827be058016d + speakeasyVersion: 1.326.3 + generationVersion: 2.359.6 + releaseVersion: 0.0.16 + configChecksum: 0368e5830f9c2a4b6b705a6ad5ce4534 repoURL: https://github.com/ryan-timothy-albert/sample-ts-monorepo.git repoSubDirectory: lending installationURL: https://gitpkg.now.sh/ryan-timothy-albert/sample-ts-monorepo/lending @@ -14,7 +14,7 @@ management: features: typescript: additionalDependencies: 0.1.0 - core: 3.11.0 + core: 3.11.3 globalSecurityCallbacks: 0.1.0 globalServerURLs: 2.82.4 responseFormat: 0.2.3 diff --git a/lending/.speakeasy/gen.yaml b/lending/.speakeasy/gen.yaml index 89d3783..b11952b 100644 --- a/lending/.speakeasy/gen.yaml +++ b/lending/.speakeasy/gen.yaml @@ -12,7 +12,7 @@ generation: auth: oAuth2ClientCredentialsEnabled: true typescript: - version: 0.0.15 + version: 0.0.16 additionalDependencies: dependencies: {} devDependencies: {} diff --git a/lending/RELEASES.md b/lending/RELEASES.md index 897bb74..91c5075 100644 --- a/lending/RELEASES.md +++ b/lending/RELEASES.md @@ -98,4 +98,14 @@ Based on: ### Generated - [typescript v0.0.15] lending ### Releases -- [NPM v0.0.15] https://www.npmjs.com/package/ryan-lending/v/0.0.15 - lending \ No newline at end of file +- [NPM v0.0.15] https://www.npmjs.com/package/ryan-lending/v/0.0.15 - lending + +## 2024-07-05 00:50:00 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.326.3 (2.359.6) https://github.com/speakeasy-api/speakeasy +### Generated +- [typescript v0.0.16] lending +### Releases +- [NPM v0.0.16] https://www.npmjs.com/package/ryan-lending/v/0.0.16 - lending \ No newline at end of file diff --git a/lending/jsr.json b/lending/jsr.json index 214c132..25369f2 100644 --- a/lending/jsr.json +++ b/lending/jsr.json @@ -2,7 +2,7 @@ { "name": "ryan-lending", - "version": "0.0.15", + "version": "0.0.16", "exports": { ".": "./src/index.ts", "./models/errors": "./src/models/errors/index.ts", diff --git a/lending/package-lock.json b/lending/package-lock.json index 1cad74b..123194b 100644 --- a/lending/package-lock.json +++ b/lending/package-lock.json @@ -1,12 +1,12 @@ { "name": "ryan-lending", - "version": "0.0.15", + "version": "0.0.16", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "ryan-lending", - "version": "0.0.15", + "version": "0.0.16", "devDependencies": { "@types/jsonpath": "^0.2.4", "@typescript-eslint/eslint-plugin": "^7.7.1", diff --git a/lending/package.json b/lending/package.json index cac3e63..1c3bc1e 100644 --- a/lending/package.json +++ b/lending/package.json @@ -1,6 +1,6 @@ { "name": "ryan-lending", - "version": "0.0.15", + "version": "0.0.16", "author": "ryan-timothy-albert", "main": "./index.js", "sideEffects": false, diff --git a/lending/src/lib/config.ts b/lending/src/lib/config.ts index 15e96f7..e4e8a53 100644 --- a/lending/src/lib/config.ts +++ b/lending/src/lib/config.ts @@ -47,7 +47,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null { export const SDK_METADATA = { language: "typescript", openapiDocVersion: "1.0.0", - sdkVersion: "0.0.15", - genVersion: "2.359.0", - userAgent: "speakeasy-sdk/typescript 0.0.15 2.359.0 1.0.0 ryan-lending", + sdkVersion: "0.0.16", + genVersion: "2.359.6", + userAgent: "speakeasy-sdk/typescript 0.0.16 2.359.6 1.0.0 ryan-lending", } as const; diff --git a/lending/src/lib/sdks.ts b/lending/src/lib/sdks.ts index cbda9d8..40007f5 100644 --- a/lending/src/lib/sdks.ts +++ b/lending/src/lib/sdks.ts @@ -7,6 +7,7 @@ import { SecurityState, resolveSecurity } from "./security.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"; @@ -22,8 +23,20 @@ type RequestConfig = { body?: RequestInit["body"]; headers?: HeadersInit; security?: SecurityState | null; + uaHeader?: string; }; +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"; + export class ClientSDK { private readonly client: HTTPClient; protected readonly baseURL: URL | null; @@ -100,6 +113,12 @@ 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); + } + const input = this.hooks$.beforeCreateRequest(context, { url: reqURL, options: { diff --git a/lending/src/sdk/pets.ts b/lending/src/sdk/pets.ts index ddd5cc3..2b2dd6b 100644 --- a/lending/src/sdk/pets.ts +++ b/lending/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,9 +50,6 @@ 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$, @@ -67,16 +64,19 @@ 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$ }, options ); - const response = await this.do$(request$, doOptions); + const response = await this.do$(request$, { context, errorCodes: ["4XX", "5XX"] }); const responseFields$ = { HttpMeta: { Response: response, Request: request$ }, @@ -99,10 +99,6 @@ 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$, @@ -115,16 +111,20 @@ 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$ }, options ); - const response = await this.do$(request$, doOptions); + const response = await this.do$(request$, { context, errorCodes: ["4XX", "5XX"] }); const [result$] = await this.matcher() .void(201, components.ErrorT$.inboundSchema.optional()) @@ -143,9 +143,6 @@ 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$, @@ -164,16 +161,19 @@ 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$ }, options ); - const response = await this.do$(request$, doOptions); + const response = await this.do$(request$, { context, errorCodes: ["4XX", "5XX"] }); const [result$] = await this.matcher() .json(200, operations.ShowPetByIdResponse$)