diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 437646f..d27330a 100755 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -3,10 +3,10 @@ id: 7a2c976b-8158-4d12-8b59-c491e9e10cfd management: docChecksum: c2a5d8222f4117f238343d6187ef2751 docVersion: 1.0.0 - speakeasyVersion: 1.396.9 - generationVersion: 2.415.7 - releaseVersion: 0.10.1 - configChecksum: a68288d69c12eb463780e5b2bad8aecb + speakeasyVersion: 1.401.2 + generationVersion: 2.421.3 + releaseVersion: 0.10.2 + configChecksum: 75f496efee76d9a28559f2ff3845bd63 repoURL: https://github.com/ding-live/ding-typescript.git repoSubDirectory: . installationURL: https://github.com/ding-live/ding-typescript @@ -14,7 +14,7 @@ management: features: typescript: additionalDependencies: 0.1.0 - core: 3.17.3 + core: 3.17.6 defaultEnabledRetries: 0.1.0 enumUnions: 0.1.0 envVarSecurityUsage: 0.1.1 diff --git a/RELEASES.md b/RELEASES.md index 957b5b3..d66bb77 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -456,4 +456,14 @@ Based on: ### Generated - [typescript v0.10.1] . ### Releases -- [NPM v0.10.1] https://www.npmjs.com/package/@ding-live/ding/v/0.10.1 - . \ No newline at end of file +- [NPM v0.10.1] https://www.npmjs.com/package/@ding-live/ding/v/0.10.1 - . + +## 2024-09-21 00:03:16 +### Changes +Based on: +- OpenAPI Doc 1.0.0 +- Speakeasy CLI 1.401.2 (2.421.3) https://github.com/speakeasy-api/speakeasy +### Generated +- [typescript v0.10.2] . +### Releases +- [NPM v0.10.2] https://www.npmjs.com/package/@ding-live/ding/v/0.10.2 - . \ No newline at end of file diff --git a/docs/models/components/createauthenticationrequest.md b/docs/models/components/createauthenticationrequest.md index afe6421..07df44c 100644 --- a/docs/models/components/createauthenticationrequest.md +++ b/docs/models/components/createauthenticationrequest.md @@ -6,7 +6,7 @@ import { CreateAuthenticationRequest } from "@ding-live/ding/models/components"; let value: CreateAuthenticationRequest = { - customerUuid: "73920592-9396-4fea-b596-eb10faaa2352", + customerUuid: "35d1d1f7-f9b0-4414-9156-1b94819e5a2b", phoneNumber: "+1234567890", }; ``` diff --git a/docs/models/components/createcheckrequest.md b/docs/models/components/createcheckrequest.md index 8b0e0db..5e565cd 100644 --- a/docs/models/components/createcheckrequest.md +++ b/docs/models/components/createcheckrequest.md @@ -6,9 +6,9 @@ import { CreateCheckRequest } from "@ding-live/ding/models/components"; let value: CreateCheckRequest = { - authenticationUuid: "89bd9d8d-69a6-474e-8f46-7cc8796ed151", + authenticationUuid: "8b986a7e-f6c8-49e1-910d-cdfc7c1a2f86", checkCode: "123456", - customerUuid: "a05dfc2d-df7c-4c78-8a1b-a928fc816742", + customerUuid: "c790999f-a56b-40aa-8325-597f132a4732", }; ``` diff --git a/docs/models/components/devicetype.md b/docs/models/components/devicetype.md index 6a2dc88..77284fe 100644 --- a/docs/models/components/devicetype.md +++ b/docs/models/components/devicetype.md @@ -7,7 +7,7 @@ The type of device the user is using. ```typescript import { DeviceType } from "@ding-live/ding/models/components"; -let value: DeviceType = "WEB"; +let value: DeviceType = "IOS"; ``` ## Values diff --git a/docs/models/components/feedbackrequest.md b/docs/models/components/feedbackrequest.md index 9eaa29e..dec7514 100644 --- a/docs/models/components/feedbackrequest.md +++ b/docs/models/components/feedbackrequest.md @@ -6,7 +6,7 @@ import { FeedbackRequest } from "@ding-live/ding/models/components"; let value: FeedbackRequest = { - customerUuid: "c5955907-aff1-4a3a-afa9-467739251aa5", + customerUuid: "290d0a4b-f399-493f-a7db-4d6e9ebb8fa6", phoneNumber: "+1234567890", status: "onboarded", }; diff --git a/docs/models/components/retryauthenticationrequest.md b/docs/models/components/retryauthenticationrequest.md index 361a784..23fd3df 100644 --- a/docs/models/components/retryauthenticationrequest.md +++ b/docs/models/components/retryauthenticationrequest.md @@ -6,8 +6,8 @@ import { RetryAuthenticationRequest } from "@ding-live/ding/models/components"; let value: RetryAuthenticationRequest = { - authenticationUuid: "2c3f5ad0-19da-41ff-a78f-097b0074f154", - customerUuid: "71b5e6e1-3b99-4d48-8e1e-91e450ad2abd", + authenticationUuid: "04a49624-999a-4a6e-b56e-cb1ebf2d291d", + customerUuid: "961b7bdf-d05b-4280-a30c-35eb02993e98", }; ``` diff --git a/docs/models/components/status.md b/docs/models/components/status.md index 35aff77..a96ebd3 100644 --- a/docs/models/components/status.md +++ b/docs/models/components/status.md @@ -11,7 +11,7 @@ The status of the authentication. Possible values are: ```typescript import { Status } from "@ding-live/ding/models/components"; -let value: Status = "spam_detected"; +let value: Status = "rate_limited"; ``` ## Values diff --git a/docs/models/operations/lookuprequest.md b/docs/models/operations/lookuprequest.md index cc24613..b4ace40 100644 --- a/docs/models/operations/lookuprequest.md +++ b/docs/models/operations/lookuprequest.md @@ -6,7 +6,7 @@ import { LookupRequest } from "@ding-live/ding/models/operations"; let value: LookupRequest = { - customerUuid: "44269802-d502-4a94-bb4f-63c969e9a3ef", + customerUuid: "b4632fb7-3406-44b6-a201-a78ef3a40c56", phoneNumber: "", }; ``` diff --git a/gen.yaml b/gen.yaml index 0ad1e88..f97917f 100644 --- a/gen.yaml +++ b/gen.yaml @@ -10,7 +10,7 @@ generation: auth: oAuth2ClientCredentialsEnabled: false typescript: - version: 0.10.1 + version: 0.10.2 additionalDependencies: dependencies: {} devDependencies: {} diff --git a/jsr.json b/jsr.json index 74eb57a..8323865 100644 --- a/jsr.json +++ b/jsr.json @@ -2,7 +2,7 @@ { "name": "@ding-live/ding", - "version": "0.10.1", + "version": "0.10.2", "exports": { ".": "./src/index.ts", "./models/errors": "./src/models/errors/index.ts", diff --git a/package.json b/package.json index c760fe4..3a15663 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ding-live/ding", - "version": "0.10.1", + "version": "0.10.2", "author": "Ding", "main": "./index.js", "sideEffects": false, diff --git a/src/funcs/lookupLookup.ts b/src/funcs/lookupLookup.ts index a61741d..a981054 100644 --- a/src/funcs/lookupLookup.ts +++ b/src/funcs/lookupLookup.ts @@ -3,9 +3,9 @@ */ import { DingCore } from "../core.js"; -import { encodeSimple as encodeSimple$ } from "../lib/encodings.js"; -import * as m$ from "../lib/matchers.js"; -import * as schemas$ from "../lib/schemas.js"; +import { encodeSimple } from "../lib/encodings.js"; +import * as M from "../lib/matchers.js"; +import { safeParse } from "../lib/schemas.js"; import { RequestOptions } from "../lib/sdks.js"; import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; import { pathToFunc } from "../lib/url.js"; @@ -27,7 +27,7 @@ import { Result } from "../types/fp.js"; * Perform a phone number lookup */ export async function lookupLookup( - client$: DingCore, + client: DingCore, customerUuid: string, phoneNumber: string, options?: RequestOptions, @@ -44,66 +44,66 @@ export async function lookupLookup( | ConnectionError > > { - const input$: operations.LookupRequest = { + const input: operations.LookupRequest = { customerUuid: customerUuid, phoneNumber: phoneNumber, }; - const parsed$ = schemas$.safeParse( - input$, - (value$) => operations.LookupRequest$outboundSchema.parse(value$), + const parsed = safeParse( + input, + (value) => operations.LookupRequest$outboundSchema.parse(value), "Input validation failed", ); - if (!parsed$.ok) { - return parsed$; + if (!parsed.ok) { + return parsed; } - const payload$ = parsed$.value; - const body$ = null; + const payload = parsed.value; + const body = null; - const pathParams$ = { - phone_number: encodeSimple$("phone_number", payload$.phone_number, { + const pathParams = { + phone_number: encodeSimple("phone_number", payload.phone_number, { explode: false, charEncoding: "percent", }), }; - const path$ = pathToFunc("/lookup/{phone_number}")(pathParams$); + const path = pathToFunc("/lookup/{phone_number}")(pathParams); - const headers$ = new Headers({ + const headers = new Headers({ Accept: "application/json", - "customer-uuid": encodeSimple$("customer-uuid", payload$["customer-uuid"], { + "customer-uuid": encodeSimple("customer-uuid", payload["customer-uuid"], { explode: false, charEncoding: "none", }), }); - const apiKey$ = await extractSecurity(client$.options$.apiKey); - const security$ = apiKey$ == null ? {} : { apiKey: apiKey$ }; + const secConfig = await extractSecurity(client._options.apiKey); + const securityInput = secConfig == null ? {} : { apiKey: secConfig }; const context = { operationID: "lookup", oAuth2Scopes: [], - securitySource: client$.options$.apiKey, + securitySource: client._options.apiKey, }; - const securitySettings$ = resolveGlobalSecurity(security$); + const requestSecurity = resolveGlobalSecurity(securityInput); - const requestRes = client$.createRequest$(context, { - security: securitySettings$, + const requestRes = client._createRequest(context, { + security: requestSecurity, method: "GET", - path: path$, - headers: headers$, - body: body$, - timeoutMs: options?.timeoutMs || client$.options$.timeoutMs || -1, + path: path, + headers: headers, + body: body, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { return requestRes; } - const request$ = requestRes.value; + const req = requestRes.value; - const doResult = await client$.do$(request$, { + const doResult = await client._do(req, { context, errorCodes: ["400", "4XX", "5XX"], retryConfig: options?.retries - || client$.options$.retryConfig, + || client._options.retryConfig, retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }); if (!doResult.ok) { @@ -111,11 +111,11 @@ export async function lookupLookup( } const response = doResult.value; - const responseFields$ = { - HttpMeta: { Response: response, Request: request$ }, + const responseFields = { + HttpMeta: { Response: response, Request: req }, }; - const [result$] = await m$.match< + const [result] = await M.match< components.LookupResponse, | errors.ErrorResponse | SDKError @@ -126,13 +126,13 @@ export async function lookupLookup( | RequestTimeoutError | ConnectionError >( - m$.json(200, components.LookupResponse$inboundSchema), - m$.jsonErr(400, errors.ErrorResponse$inboundSchema), - m$.fail(["4XX", "5XX"]), - )(response, { extraFields: responseFields$ }); - if (!result$.ok) { - return result$; + M.json(200, components.LookupResponse$inboundSchema), + M.jsonErr(400, errors.ErrorResponse$inboundSchema), + M.fail(["4XX", "5XX"]), + )(response, { extraFields: responseFields }); + if (!result.ok) { + return result; } - return result$; + return result; } diff --git a/src/funcs/otpCheck.ts b/src/funcs/otpCheck.ts index a0617fd..9f6f0ee 100644 --- a/src/funcs/otpCheck.ts +++ b/src/funcs/otpCheck.ts @@ -3,9 +3,9 @@ */ import { DingCore } from "../core.js"; -import { encodeJSON as encodeJSON$ } from "../lib/encodings.js"; -import * as m$ from "../lib/matchers.js"; -import * as schemas$ from "../lib/schemas.js"; +import { encodeJSON } from "../lib/encodings.js"; +import * as M from "../lib/matchers.js"; +import { safeParse } from "../lib/schemas.js"; import { RequestOptions } from "../lib/sdks.js"; import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; import { pathToFunc } from "../lib/url.js"; @@ -26,7 +26,7 @@ import { Result } from "../types/fp.js"; * Check a code */ export async function otpCheck( - client$: DingCore, + client: DingCore, request?: components.CreateCheckRequest | undefined, options?: RequestOptions, ): Promise< @@ -42,56 +42,56 @@ export async function otpCheck( | ConnectionError > > { - const input$ = request; + const input = request; - const parsed$ = schemas$.safeParse( - input$, - (value$) => - components.CreateCheckRequest$outboundSchema.optional().parse(value$), + const parsed = safeParse( + input, + (value) => + components.CreateCheckRequest$outboundSchema.optional().parse(value), "Input validation failed", ); - if (!parsed$.ok) { - return parsed$; + if (!parsed.ok) { + return parsed; } - const payload$ = parsed$.value; - const body$ = payload$ === undefined + const payload = parsed.value; + const body = payload === undefined ? null - : encodeJSON$("body", payload$, { explode: true }); + : encodeJSON("body", payload, { explode: true }); - const path$ = pathToFunc("/check")(); + const path = pathToFunc("/check")(); - const headers$ = new Headers({ + const headers = new Headers({ "Content-Type": "application/json", Accept: "application/json", }); - const apiKey$ = await extractSecurity(client$.options$.apiKey); - const security$ = apiKey$ == null ? {} : { apiKey: apiKey$ }; + const secConfig = await extractSecurity(client._options.apiKey); + const securityInput = secConfig == null ? {} : { apiKey: secConfig }; const context = { operationID: "check", oAuth2Scopes: [], - securitySource: client$.options$.apiKey, + securitySource: client._options.apiKey, }; - const securitySettings$ = resolveGlobalSecurity(security$); + const requestSecurity = resolveGlobalSecurity(securityInput); - const requestRes = client$.createRequest$(context, { - security: securitySettings$, + const requestRes = client._createRequest(context, { + security: requestSecurity, method: "POST", - path: path$, - headers: headers$, - body: body$, - timeoutMs: options?.timeoutMs || client$.options$.timeoutMs || -1, + path: path, + headers: headers, + body: body, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { return requestRes; } - const request$ = requestRes.value; + const req = requestRes.value; - const doResult = await client$.do$(request$, { + const doResult = await client._do(req, { context, errorCodes: ["400", "4XX", "5XX"], retryConfig: options?.retries - || client$.options$.retryConfig, + || client._options.retryConfig, retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }); if (!doResult.ok) { @@ -99,11 +99,11 @@ export async function otpCheck( } const response = doResult.value; - const responseFields$ = { - HttpMeta: { Response: response, Request: request$ }, + const responseFields = { + HttpMeta: { Response: response, Request: req }, }; - const [result$] = await m$.match< + const [result] = await M.match< components.CreateCheckResponse, | errors.ErrorResponse | SDKError @@ -114,13 +114,13 @@ export async function otpCheck( | RequestTimeoutError | ConnectionError >( - m$.json(200, components.CreateCheckResponse$inboundSchema), - m$.jsonErr(400, errors.ErrorResponse$inboundSchema), - m$.fail(["4XX", "5XX"]), - )(response, { extraFields: responseFields$ }); - if (!result$.ok) { - return result$; + M.json(200, components.CreateCheckResponse$inboundSchema), + M.jsonErr(400, errors.ErrorResponse$inboundSchema), + M.fail(["4XX", "5XX"]), + )(response, { extraFields: responseFields }); + if (!result.ok) { + return result; } - return result$; + return result; } diff --git a/src/funcs/otpCreateAuthentication.ts b/src/funcs/otpCreateAuthentication.ts index 7551ace..fe64b79 100644 --- a/src/funcs/otpCreateAuthentication.ts +++ b/src/funcs/otpCreateAuthentication.ts @@ -3,9 +3,9 @@ */ import { DingCore } from "../core.js"; -import { encodeJSON as encodeJSON$ } from "../lib/encodings.js"; -import * as m$ from "../lib/matchers.js"; -import * as schemas$ from "../lib/schemas.js"; +import { encodeJSON } from "../lib/encodings.js"; +import * as M from "../lib/matchers.js"; +import { safeParse } from "../lib/schemas.js"; import { RequestOptions } from "../lib/sdks.js"; import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; import { pathToFunc } from "../lib/url.js"; @@ -26,7 +26,7 @@ import { Result } from "../types/fp.js"; * Send a code */ export async function otpCreateAuthentication( - client$: DingCore, + client: DingCore, request?: components.CreateAuthenticationRequest | undefined, options?: RequestOptions, ): Promise< @@ -42,58 +42,58 @@ export async function otpCreateAuthentication( | ConnectionError > > { - const input$ = request; + const input = request; - const parsed$ = schemas$.safeParse( - input$, - (value$) => + const parsed = safeParse( + input, + (value) => components.CreateAuthenticationRequest$outboundSchema.optional().parse( - value$, + value, ), "Input validation failed", ); - if (!parsed$.ok) { - return parsed$; + if (!parsed.ok) { + return parsed; } - const payload$ = parsed$.value; - const body$ = payload$ === undefined + const payload = parsed.value; + const body = payload === undefined ? null - : encodeJSON$("body", payload$, { explode: true }); + : encodeJSON("body", payload, { explode: true }); - const path$ = pathToFunc("/authentication")(); + const path = pathToFunc("/authentication")(); - const headers$ = new Headers({ + const headers = new Headers({ "Content-Type": "application/json", Accept: "application/json", }); - const apiKey$ = await extractSecurity(client$.options$.apiKey); - const security$ = apiKey$ == null ? {} : { apiKey: apiKey$ }; + const secConfig = await extractSecurity(client._options.apiKey); + const securityInput = secConfig == null ? {} : { apiKey: secConfig }; const context = { operationID: "create-authentication", oAuth2Scopes: [], - securitySource: client$.options$.apiKey, + securitySource: client._options.apiKey, }; - const securitySettings$ = resolveGlobalSecurity(security$); + const requestSecurity = resolveGlobalSecurity(securityInput); - const requestRes = client$.createRequest$(context, { - security: securitySettings$, + const requestRes = client._createRequest(context, { + security: requestSecurity, method: "POST", - path: path$, - headers: headers$, - body: body$, - timeoutMs: options?.timeoutMs || client$.options$.timeoutMs || -1, + path: path, + headers: headers, + body: body, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { return requestRes; } - const request$ = requestRes.value; + const req = requestRes.value; - const doResult = await client$.do$(request$, { + const doResult = await client._do(req, { context, errorCodes: ["400", "4XX", "5XX"], retryConfig: options?.retries - || client$.options$.retryConfig, + || client._options.retryConfig, retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }); if (!doResult.ok) { @@ -101,11 +101,11 @@ export async function otpCreateAuthentication( } const response = doResult.value; - const responseFields$ = { - HttpMeta: { Response: response, Request: request$ }, + const responseFields = { + HttpMeta: { Response: response, Request: req }, }; - const [result$] = await m$.match< + const [result] = await M.match< components.CreateAuthenticationResponse, | errors.ErrorResponse | SDKError @@ -116,13 +116,13 @@ export async function otpCreateAuthentication( | RequestTimeoutError | ConnectionError >( - m$.json(200, components.CreateAuthenticationResponse$inboundSchema), - m$.jsonErr(400, errors.ErrorResponse$inboundSchema), - m$.fail(["4XX", "5XX"]), - )(response, { extraFields: responseFields$ }); - if (!result$.ok) { - return result$; + M.json(200, components.CreateAuthenticationResponse$inboundSchema), + M.jsonErr(400, errors.ErrorResponse$inboundSchema), + M.fail(["4XX", "5XX"]), + )(response, { extraFields: responseFields }); + if (!result.ok) { + return result; } - return result$; + return result; } diff --git a/src/funcs/otpFeedback.ts b/src/funcs/otpFeedback.ts index 0ca8386..691147c 100644 --- a/src/funcs/otpFeedback.ts +++ b/src/funcs/otpFeedback.ts @@ -3,9 +3,9 @@ */ import { DingCore } from "../core.js"; -import { encodeJSON as encodeJSON$ } from "../lib/encodings.js"; -import * as m$ from "../lib/matchers.js"; -import * as schemas$ from "../lib/schemas.js"; +import { encodeJSON } from "../lib/encodings.js"; +import * as M from "../lib/matchers.js"; +import { safeParse } from "../lib/schemas.js"; import { RequestOptions } from "../lib/sdks.js"; import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; import { pathToFunc } from "../lib/url.js"; @@ -26,7 +26,7 @@ import { Result } from "../types/fp.js"; * Send feedback */ export async function otpFeedback( - client$: DingCore, + client: DingCore, request?: components.FeedbackRequest | undefined, options?: RequestOptions, ): Promise< @@ -41,56 +41,56 @@ export async function otpFeedback( | ConnectionError > > { - const input$ = request; + const input = request; - const parsed$ = schemas$.safeParse( - input$, - (value$) => - components.FeedbackRequest$outboundSchema.optional().parse(value$), + const parsed = safeParse( + input, + (value) => + components.FeedbackRequest$outboundSchema.optional().parse(value), "Input validation failed", ); - if (!parsed$.ok) { - return parsed$; + if (!parsed.ok) { + return parsed; } - const payload$ = parsed$.value; - const body$ = payload$ === undefined + const payload = parsed.value; + const body = payload === undefined ? null - : encodeJSON$("body", payload$, { explode: true }); + : encodeJSON("body", payload, { explode: true }); - const path$ = pathToFunc("/authentication/feedback")(); + const path = pathToFunc("/authentication/feedback")(); - const headers$ = new Headers({ + const headers = new Headers({ "Content-Type": "application/json", Accept: "application/json", }); - const apiKey$ = await extractSecurity(client$.options$.apiKey); - const security$ = apiKey$ == null ? {} : { apiKey: apiKey$ }; + const secConfig = await extractSecurity(client._options.apiKey); + const securityInput = secConfig == null ? {} : { apiKey: secConfig }; const context = { operationID: "feedback", oAuth2Scopes: [], - securitySource: client$.options$.apiKey, + securitySource: client._options.apiKey, }; - const securitySettings$ = resolveGlobalSecurity(security$); + const requestSecurity = resolveGlobalSecurity(securityInput); - const requestRes = client$.createRequest$(context, { - security: securitySettings$, + const requestRes = client._createRequest(context, { + security: requestSecurity, method: "POST", - path: path$, - headers: headers$, - body: body$, - timeoutMs: options?.timeoutMs || client$.options$.timeoutMs || -1, + path: path, + headers: headers, + body: body, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { return requestRes; } - const request$ = requestRes.value; + const req = requestRes.value; - const doResult = await client$.do$(request$, { + const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], retryConfig: options?.retries - || client$.options$.retryConfig, + || client._options.retryConfig, retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }); if (!doResult.ok) { @@ -98,7 +98,7 @@ export async function otpFeedback( } const response = doResult.value; - const [result$] = await m$.match< + const [result] = await M.match< operations.FeedbackResponse, | SDKError | SDKValidationError @@ -108,13 +108,13 @@ export async function otpFeedback( | RequestTimeoutError | ConnectionError >( - m$.json(200, operations.FeedbackResponse$inboundSchema), - m$.fail(["4XX", "5XX"]), - m$.json("default", operations.FeedbackResponse$inboundSchema), + M.json(200, operations.FeedbackResponse$inboundSchema), + M.fail(["4XX", "5XX"]), + M.json("default", operations.FeedbackResponse$inboundSchema), )(response); - if (!result$.ok) { - return result$; + if (!result.ok) { + return result; } - return result$; + return result; } diff --git a/src/funcs/otpRetry.ts b/src/funcs/otpRetry.ts index f530e24..c3e51f1 100644 --- a/src/funcs/otpRetry.ts +++ b/src/funcs/otpRetry.ts @@ -3,9 +3,9 @@ */ import { DingCore } from "../core.js"; -import { encodeJSON as encodeJSON$ } from "../lib/encodings.js"; -import * as m$ from "../lib/matchers.js"; -import * as schemas$ from "../lib/schemas.js"; +import { encodeJSON } from "../lib/encodings.js"; +import * as M from "../lib/matchers.js"; +import { safeParse } from "../lib/schemas.js"; import { RequestOptions } from "../lib/sdks.js"; import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; import { pathToFunc } from "../lib/url.js"; @@ -26,7 +26,7 @@ import { Result } from "../types/fp.js"; * Perform a retry */ export async function otpRetry( - client$: DingCore, + client: DingCore, request?: components.RetryAuthenticationRequest | undefined, options?: RequestOptions, ): Promise< @@ -42,58 +42,58 @@ export async function otpRetry( | ConnectionError > > { - const input$ = request; + const input = request; - const parsed$ = schemas$.safeParse( - input$, - (value$) => + const parsed = safeParse( + input, + (value) => components.RetryAuthenticationRequest$outboundSchema.optional().parse( - value$, + value, ), "Input validation failed", ); - if (!parsed$.ok) { - return parsed$; + if (!parsed.ok) { + return parsed; } - const payload$ = parsed$.value; - const body$ = payload$ === undefined + const payload = parsed.value; + const body = payload === undefined ? null - : encodeJSON$("body", payload$, { explode: true }); + : encodeJSON("body", payload, { explode: true }); - const path$ = pathToFunc("/retry")(); + const path = pathToFunc("/retry")(); - const headers$ = new Headers({ + const headers = new Headers({ "Content-Type": "application/json", Accept: "application/json", }); - const apiKey$ = await extractSecurity(client$.options$.apiKey); - const security$ = apiKey$ == null ? {} : { apiKey: apiKey$ }; + const secConfig = await extractSecurity(client._options.apiKey); + const securityInput = secConfig == null ? {} : { apiKey: secConfig }; const context = { operationID: "retry", oAuth2Scopes: [], - securitySource: client$.options$.apiKey, + securitySource: client._options.apiKey, }; - const securitySettings$ = resolveGlobalSecurity(security$); + const requestSecurity = resolveGlobalSecurity(securityInput); - const requestRes = client$.createRequest$(context, { - security: securitySettings$, + const requestRes = client._createRequest(context, { + security: requestSecurity, method: "POST", - path: path$, - headers: headers$, - body: body$, - timeoutMs: options?.timeoutMs || client$.options$.timeoutMs || -1, + path: path, + headers: headers, + body: body, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { return requestRes; } - const request$ = requestRes.value; + const req = requestRes.value; - const doResult = await client$.do$(request$, { + const doResult = await client._do(req, { context, errorCodes: ["400", "4XX", "5XX"], retryConfig: options?.retries - || client$.options$.retryConfig, + || client._options.retryConfig, retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }); if (!doResult.ok) { @@ -101,11 +101,11 @@ export async function otpRetry( } const response = doResult.value; - const responseFields$ = { - HttpMeta: { Response: response, Request: request$ }, + const responseFields = { + HttpMeta: { Response: response, Request: req }, }; - const [result$] = await m$.match< + const [result] = await M.match< components.RetryAuthenticationResponse, | errors.ErrorResponse | SDKError @@ -116,13 +116,13 @@ export async function otpRetry( | RequestTimeoutError | ConnectionError >( - m$.json(200, components.RetryAuthenticationResponse$inboundSchema), - m$.jsonErr(400, errors.ErrorResponse$inboundSchema), - m$.fail(["4XX", "5XX"]), - )(response, { extraFields: responseFields$ }); - if (!result$.ok) { - return result$; + M.json(200, components.RetryAuthenticationResponse$inboundSchema), + M.jsonErr(400, errors.ErrorResponse$inboundSchema), + M.fail(["4XX", "5XX"]), + )(response, { extraFields: responseFields }); + if (!result.ok) { + return result; } - return result$; + return result; } diff --git a/src/lib/config.ts b/src/lib/config.ts index 14e6094..97728a2 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -57,7 +57,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null { export const SDK_METADATA = { language: "typescript", openapiDocVersion: "1.0.0", - sdkVersion: "0.10.1", - genVersion: "2.415.7", - userAgent: "speakeasy-sdk/typescript 0.10.1 2.415.7 1.0.0 @ding-live/ding", + sdkVersion: "0.10.2", + genVersion: "2.421.3", + userAgent: "speakeasy-sdk/typescript 0.10.2 2.421.3 1.0.0 @ding-live/ding", } as const; diff --git a/src/lib/sdks.ts b/src/lib/sdks.ts index 5e2a890..a0f4de1 100644 --- a/src/lib/sdks.ts +++ b/src/lib/sdks.ts @@ -71,11 +71,11 @@ const isBrowserLike = webWorkerLike || (typeof window === "object" && typeof window.document !== "undefined"); export class ClientSDK { - private readonly httpClient: HTTPClient; - protected readonly baseURL: URL | null; - protected readonly hooks$: SDKHooks; - protected readonly logger?: Logger | undefined; - public readonly options$: SDKOptions & { hooks?: SDKHooks }; + readonly #httpClient: HTTPClient; + readonly #hooks: SDKHooks; + readonly #logger?: Logger | undefined; + protected readonly _baseURL: URL | null; + public readonly _options: SDKOptions & { hooks?: SDKHooks }; constructor(options: SDKOptions = {}) { const opt = options as unknown; @@ -85,33 +85,33 @@ export class ClientSDK { && "hooks" in opt && opt.hooks instanceof SDKHooks ) { - this.hooks$ = opt.hooks; + this.#hooks = opt.hooks; } else { - this.hooks$ = new SDKHooks(); + this.#hooks = new SDKHooks(); } - this.options$ = { ...options, hooks: this.hooks$ }; + this._options = { ...options, hooks: this.#hooks }; const url = serverURLFromOptions(options); if (url) { url.pathname = url.pathname.replace(/\/+$/, "") + "/"; } - const { baseURL, client } = this.hooks$.sdkInit({ + const { baseURL, client } = this.#hooks.sdkInit({ baseURL: url, client: options.httpClient || new HTTPClient(), }); - this.baseURL = baseURL; - this.httpClient = client; - this.logger = options.debugLogger; + this._baseURL = baseURL; + this.#httpClient = client; + this.#logger = options.debugLogger; } - public createRequest$( + public _createRequest( context: HookContext, conf: RequestConfig, options?: RequestOptions, ): Result { const { method, path, query, headers: opHeaders, security } = conf; - const base = conf.baseURL ?? this.baseURL; + const base = conf.baseURL ?? this._baseURL; if (!base) { return ERR(new InvalidRequestError("No base URL provided for operation")); } @@ -195,7 +195,7 @@ export class ClientSDK { let input; try { - input = this.hooks$.beforeCreateRequest(context, { + input = this.#hooks.beforeCreateRequest(context, { url: reqURL, options: { ...fetchOptions, @@ -215,7 +215,7 @@ export class ClientSDK { return OK(new Request(input.url, input.options)); } - public async do$( + public async _do( request: Request, options: { context: HookContext; @@ -238,25 +238,25 @@ export class ClientSDK { return retry( async () => { - const req = await this.hooks$.beforeRequest(context, request.clone()); - await logRequest(this.logger, req).catch((e) => - this.logger?.log("Failed to log request:", e) + const req = await this.#hooks.beforeRequest(context, request.clone()); + await logRequest(this.#logger, req).catch((e) => + this.#logger?.log("Failed to log request:", e) ); - let response = await this.httpClient.request(req); + let response = await this.#httpClient.request(req); if (matchStatusCode(response, errorCodes)) { - const result = await this.hooks$.afterError(context, response, null); + 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); + response = await this.#hooks.afterSuccess(context, response); } - await logResponse(this.logger, response, req) - .catch(e => this.logger?.log("Failed to log response:", e)); + await logResponse(this.#logger, response, req) + .catch(e => this.#logger?.log("Failed to log response:", e)); return response; }, diff --git a/src/sdk/sdk.ts b/src/sdk/sdk.ts index b83bd4d..5e221d8 100644 --- a/src/sdk/sdk.ts +++ b/src/sdk/sdk.ts @@ -9,11 +9,11 @@ import { Otp } from "./otp.js"; export class Ding extends ClientSDK { private _otp?: Otp; get otp(): Otp { - return (this._otp ??= new Otp(this.options$)); + return (this._otp ??= new Otp(this._options)); } private _lookup?: Lookup; get lookup(): Lookup { - return (this._lookup ??= new Lookup(this.options$)); + return (this._lookup ??= new Lookup(this._options)); } }