diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index e90e49d..48a6ca2 100755 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,12 +1,12 @@ lockVersion: 2.0.0 id: f42cb8e6-e2ce-4565-b975-5a9f38b94d5a management: - docChecksum: a9cd06bdac5fb6851149f5b0e9776c5d - docVersion: 1.2.7 - speakeasyVersion: 1.649.0 - generationVersion: 2.739.1 - releaseVersion: 0.29.0 - configChecksum: a3da09b990d249ff9f5561aee1b535d2 + docChecksum: 977565cbc407bbb9f442751a237b5f0a + docVersion: 1.2.10 + speakeasyVersion: 1.656.2 + generationVersion: 2.753.6 + releaseVersion: 0.29.1 + configChecksum: fd4b3da7ec98081721e05f14d2904fec repoURL: https://github.com/Unstructured-IO/unstructured-js-client.git repoSubDirectory: . installationURL: https://github.com/Unstructured-IO/unstructured-js-client @@ -16,7 +16,7 @@ features: acceptHeaders: 2.81.2 additionalDependencies: 0.1.0 constsAndDefaults: 0.1.12 - core: 3.26.0 + core: 3.26.6 defaultEnabledRetries: 0.1.0 enumUnions: 0.1.0 envVarSecurityUsage: 0.1.2 @@ -139,4 +139,3 @@ examples: application/json: {"detail": "An error occurred"} examplesVersion: 1.0.2 generatedTests: {} -releaseNotes: "## Typescript SDK Changes Detected:\n* `unstructured_client.general.partition()`: \n * `request.partitionParameters.doNotBreakSimilarityOnFooterHeader` **Added**\n" diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 9ec5765..a65eb69 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,21 +1,21 @@ -speakeasyVersion: 1.649.0 +speakeasyVersion: 1.656.2 sources: my-source: sourceNamespace: my-source - sourceRevisionDigest: sha256:6a1d1cac95c1b8f6ed4f055dffa907f1f96bf75b5d5bfa190f4a437048ef4865 - sourceBlobDigest: sha256:e8c9fd0a7a559a840d32944c7eccb9fadbade798336b70ecd0d507e27e014d34 + sourceRevisionDigest: sha256:7d9ebd7f9cc67f35397af568068c796fc20c935e029dbd0fd72d8af5cda68246 + sourceBlobDigest: sha256:8f996e834b9acfe6684d9512a9f5c5a1e2859eeb6a6069d49f4860cc6ced6261 tags: - latest - - speakeasy-sdk-regen-1761265716 - - 1.2.7 + - speakeasy-sdk-regen-1762993955 + - 1.2.10 targets: unstructed-typescript: source: my-source sourceNamespace: my-source - sourceRevisionDigest: sha256:6a1d1cac95c1b8f6ed4f055dffa907f1f96bf75b5d5bfa190f4a437048ef4865 - sourceBlobDigest: sha256:e8c9fd0a7a559a840d32944c7eccb9fadbade798336b70ecd0d507e27e014d34 + sourceRevisionDigest: sha256:7d9ebd7f9cc67f35397af568068c796fc20c935e029dbd0fd72d8af5cda68246 + sourceBlobDigest: sha256:8f996e834b9acfe6684d9512a9f5c5a1e2859eeb6a6069d49f4860cc6ced6261 codeSamplesNamespace: my-source-typescript-code-samples - codeSamplesRevisionDigest: sha256:eb4fafeb42461e65141860fa0a1c8a24a89a9b8d13a43aea73f857cf2a51d7a6 + codeSamplesRevisionDigest: sha256:1d693802df2a09ddd3b39ba2f5b1b008450975403724e73e3daef65c4f1da5bf workflow: workflowVersion: 1.0.0 speakeasyVersion: latest diff --git a/RELEASES.md b/RELEASES.md index 0b1534d..40efbe6 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -714,4 +714,14 @@ Based on: ### Generated - [typescript v0.29.0] . ### Releases -- [NPM v0.29.0] https://www.npmjs.com/package/unstructured-client/v/0.29.0 - . \ No newline at end of file +- [NPM v0.29.0] https://www.npmjs.com/package/unstructured-client/v/0.29.0 - . + +## 2025-11-14 00:32:40 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.656.2 (2.753.6) https://github.com/speakeasy-api/speakeasy +### Generated +- [typescript v0.29.1] . +### Releases +- [NPM v0.29.1] https://www.npmjs.com/package/unstructured-client/v/0.29.1 - . \ No newline at end of file diff --git a/examples/package-lock.json b/examples/package-lock.json index f341b5d..bf9146f 100644 --- a/examples/package-lock.json +++ b/examples/package-lock.json @@ -18,7 +18,7 @@ }, "..": { "name": "unstructured-client", - "version": "0.29.0", + "version": "0.29.1", "dependencies": { "async": "^3.2.5", "pdf-lib": "^1.17.1", diff --git a/gen.yaml b/gen.yaml index 254809b..fb96cf9 100644 --- a/gen.yaml +++ b/gen.yaml @@ -16,12 +16,13 @@ generation: hoistGlobalSecurity: true schemas: allOfMergeStrategy: shallowMerge + requestBodyFieldName: "" tests: generateTests: true generateNewTests: false skipResponseBodyAssertions: false typescript: - version: 0.29.0 + version: 0.29.1 acceptHeaderEnum: true additionalDependencies: dependencies: @@ -33,6 +34,7 @@ typescript: peerDependencies: {} additionalPackageJSON: {} additionalScripts: {} + alwaysIncludeInboundAndOutbound: false author: Unstructured baseErrorName: UnstructuredClientError clientServerStatusCodesAsErrors: true @@ -42,6 +44,7 @@ typescript: enableMCPServer: true enableReactQuery: false enumFormat: enum + exportZodModelNamespace: false flattenGlobalSecurity: false flatteningOrder: body-first generateExamples: true @@ -65,6 +68,7 @@ typescript: responseFormat: flat sseFlatResponse: false templateVersion: v2 + unionStrategy: left-to-right usageSDKInitImports: [] useIndexModules: true zodVersion: v3 diff --git a/jsr.json b/jsr.json index ccafdc4..775ce59 100644 --- a/jsr.json +++ b/jsr.json @@ -2,7 +2,7 @@ { "name": "unstructured-client", - "version": "0.29.0", + "version": "0.29.1", "exports": { ".": "./src/index.ts", "./sdk/models/errors": "./src/sdk/models/errors/index.ts", diff --git a/package-lock.json b/package-lock.json index 63d8653..cd6d9da 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "unstructured-client", - "version": "0.29.0", + "version": "0.29.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "unstructured-client", - "version": "0.29.0", + "version": "0.29.1", "dependencies": { "async": "^3.2.5", "pdf-lib": "^1.17.1", diff --git a/package.json b/package.json index fc6798c..f219a04 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "unstructured-client", - "version": "0.29.0", + "version": "0.29.1", "author": "Unstructured", "type": "module", "bin": { diff --git a/src/lib/config.ts b/src/lib/config.ts index f67ea15..e8d58c3 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -67,9 +67,9 @@ export function serverURLFromOptions(options: SDKOptions): URL | null { export const SDK_METADATA = { language: "typescript", - openapiDocVersion: "1.2.7", - sdkVersion: "0.29.0", - genVersion: "2.739.1", + openapiDocVersion: "1.2.10", + sdkVersion: "0.29.1", + genVersion: "2.753.6", userAgent: - "speakeasy-sdk/typescript 0.29.0 2.739.1 1.2.7 unstructured-client", + "speakeasy-sdk/typescript 0.29.1 2.753.6 1.2.10 unstructured-client", } as const; diff --git a/src/mcp-server/mcp-server.ts b/src/mcp-server/mcp-server.ts index ba4f87e..7853e25 100644 --- a/src/mcp-server/mcp-server.ts +++ b/src/mcp-server/mcp-server.ts @@ -19,7 +19,7 @@ const routes = buildRouteMap({ export const app = buildApplication(routes, { name: "mcp", versionInfo: { - currentVersion: "0.29.0", + currentVersion: "0.29.1", }, }); diff --git a/src/mcp-server/server.ts b/src/mcp-server/server.ts index 4642c74..c9882f4 100644 --- a/src/mcp-server/server.ts +++ b/src/mcp-server/server.ts @@ -27,7 +27,7 @@ export function createMCPServer(deps: { }) { const server = new McpServer({ name: "UnstructuredClient", - version: "0.29.0", + version: "0.29.1", }); const client = new UnstructuredClientCore({ diff --git a/src/sdk/models/errors/httpvalidationerror.ts b/src/sdk/models/errors/httpvalidationerror.ts index bb6fce6..11da774 100644 --- a/src/sdk/models/errors/httpvalidationerror.ts +++ b/src/sdk/models/errors/httpvalidationerror.ts @@ -39,7 +39,6 @@ export class HTTPValidationError extends UnstructuredClientError { /** @internal */ export const Detail$inboundSchema: z.ZodType = z .union([z.array(shared.ValidationError$inboundSchema), z.string()]); - /** @internal */ export type Detail$Outbound = Array | string; @@ -50,23 +49,9 @@ export const Detail$outboundSchema: z.ZodType< unknown > = z.union([z.array(shared.ValidationError$outboundSchema), 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 Detail$ { - /** @deprecated use `Detail$inboundSchema` instead. */ - export const inboundSchema = Detail$inboundSchema; - /** @deprecated use `Detail$outboundSchema` instead. */ - export const outboundSchema = Detail$outboundSchema; - /** @deprecated use `Detail$Outbound` instead. */ - export type Outbound = Detail$Outbound; -} - export function detailToJSON(detail: Detail): string { return JSON.stringify(Detail$outboundSchema.parse(detail)); } - export function detailFromJSON( jsonString: string, ): SafeParseResult { @@ -115,16 +100,3 @@ export const HTTPValidationError$outboundSchema: z.ZodType< 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 HTTPValidationError$ { - /** @deprecated use `HTTPValidationError$inboundSchema` instead. */ - export const inboundSchema = HTTPValidationError$inboundSchema; - /** @deprecated use `HTTPValidationError$outboundSchema` instead. */ - export const outboundSchema = HTTPValidationError$outboundSchema; - /** @deprecated use `HTTPValidationError$Outbound` instead. */ - export type Outbound = HTTPValidationError$Outbound; -} diff --git a/src/sdk/models/errors/servererror.ts b/src/sdk/models/errors/servererror.ts index 29995d4..fb8c00b 100644 --- a/src/sdk/models/errors/servererror.ts +++ b/src/sdk/models/errors/servererror.ts @@ -64,16 +64,3 @@ export const ServerError$outboundSchema: z.ZodType< .pipe(z.object({ detail: 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 ServerError$ { - /** @deprecated use `ServerError$inboundSchema` instead. */ - export const inboundSchema = ServerError$inboundSchema; - /** @deprecated use `ServerError$outboundSchema` instead. */ - export const outboundSchema = ServerError$outboundSchema; - /** @deprecated use `ServerError$Outbound` instead. */ - export type Outbound = ServerError$Outbound; -} diff --git a/src/sdk/models/operations/partition.ts b/src/sdk/models/operations/partition.ts index d733c76..715a4c1 100644 --- a/src/sdk/models/operations/partition.ts +++ b/src/sdk/models/operations/partition.ts @@ -30,7 +30,6 @@ export const PartitionRequest$inboundSchema: z.ZodType< "unstructured-api-key": "unstructuredApiKey", }); }); - /** @internal */ export type PartitionRequest$Outbound = { partition_parameters: shared.PartitionParameters$Outbound; @@ -52,19 +51,6 @@ export const PartitionRequest$outboundSchema: z.ZodType< }); }); -/** - * @internal - * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. - */ -export namespace PartitionRequest$ { - /** @deprecated use `PartitionRequest$inboundSchema` instead. */ - export const inboundSchema = PartitionRequest$inboundSchema; - /** @deprecated use `PartitionRequest$outboundSchema` instead. */ - export const outboundSchema = PartitionRequest$outboundSchema; - /** @deprecated use `PartitionRequest$Outbound` instead. */ - export type Outbound = PartitionRequest$Outbound; -} - export function partitionRequestToJSON( partitionRequest: PartitionRequest, ): string { @@ -72,7 +58,6 @@ export function partitionRequestToJSON( PartitionRequest$outboundSchema.parse(partitionRequest), ); } - export function partitionRequestFromJSON( jsonString: string, ): SafeParseResult { @@ -89,7 +74,6 @@ export const PartitionResponse$inboundSchema: z.ZodType< z.ZodTypeDef, unknown > = z.union([z.string(), z.array(z.record(z.any()))]); - /** @internal */ export type PartitionResponse$Outbound = string | Array<{ [k: string]: any }>; @@ -100,19 +84,6 @@ export const PartitionResponse$outboundSchema: z.ZodType< PartitionResponse > = z.union([z.string(), z.array(z.record(z.any()))]); -/** - * @internal - * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. - */ -export namespace PartitionResponse$ { - /** @deprecated use `PartitionResponse$inboundSchema` instead. */ - export const inboundSchema = PartitionResponse$inboundSchema; - /** @deprecated use `PartitionResponse$outboundSchema` instead. */ - export const outboundSchema = PartitionResponse$outboundSchema; - /** @deprecated use `PartitionResponse$Outbound` instead. */ - export type Outbound = PartitionResponse$Outbound; -} - export function partitionResponseToJSON( partitionResponse: PartitionResponse, ): string { @@ -120,7 +91,6 @@ export function partitionResponseToJSON( PartitionResponse$outboundSchema.parse(partitionResponse), ); } - export function partitionResponseFromJSON( jsonString: string, ): SafeParseResult { diff --git a/src/sdk/models/shared/partitionparameters.ts b/src/sdk/models/shared/partitionparameters.ts index 663407c..5ea8de1 100644 --- a/src/sdk/models/shared/partitionparameters.ts +++ b/src/sdk/models/shared/partitionparameters.ts @@ -6,11 +6,8 @@ import * as z from "zod/v3"; import { remap as remap$ } from "../../../lib/primitives.js"; import { safeParse } from "../../../lib/schemas.js"; import { blobLikeSchema } from "../../types/blobs.js"; -import { - catchUnrecognizedEnum, - OpenEnum, - Unrecognized, -} from "../../types/enums.js"; +import * as openEnums from "../../types/enums.js"; +import { OpenEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; @@ -234,7 +231,6 @@ export const Files$inboundSchema: z.ZodType = z ]), fileName: z.string(), }); - /** @internal */ export type Files$Outbound = { content: ReadableStream | Blob | ArrayBuffer | Uint8Array; @@ -256,23 +252,9 @@ export const Files$outboundSchema: z.ZodType< fileName: 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 Files$ { - /** @deprecated use `Files$inboundSchema` instead. */ - export const inboundSchema = Files$inboundSchema; - /** @deprecated use `Files$outboundSchema` instead. */ - export const outboundSchema = Files$outboundSchema; - /** @deprecated use `Files$Outbound` instead. */ - export type Outbound = Files$Outbound; -} - export function filesToJSON(files: Files): string { return JSON.stringify(Files$outboundSchema.parse(files)); } - export function filesFromJSON( jsonString: string, ): SafeParseResult { @@ -288,96 +270,39 @@ export const OutputFormat$inboundSchema: z.ZodType< OutputFormatOpen, z.ZodTypeDef, unknown -> = z - .union([ - z.nativeEnum(OutputFormat), - z.string().transform(catchUnrecognizedEnum), - ]); - +> = openEnums.inboundSchema(OutputFormat); /** @internal */ export const OutputFormat$outboundSchema: z.ZodType< - OutputFormatOpen, + string, z.ZodTypeDef, OutputFormatOpen -> = z.union([ - z.nativeEnum(OutputFormat), - z.string().and(z.custom>()), -]); - -/** - * @internal - * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. - */ -export namespace OutputFormat$ { - /** @deprecated use `OutputFormat$inboundSchema` instead. */ - export const inboundSchema = OutputFormat$inboundSchema; - /** @deprecated use `OutputFormat$outboundSchema` instead. */ - export const outboundSchema = OutputFormat$outboundSchema; -} +> = openEnums.outboundSchema(OutputFormat); /** @internal */ export const Strategy$inboundSchema: z.ZodType< StrategyOpen, z.ZodTypeDef, unknown -> = z - .union([ - z.nativeEnum(Strategy), - z.string().transform(catchUnrecognizedEnum), - ]); - +> = openEnums.inboundSchema(Strategy); /** @internal */ export const Strategy$outboundSchema: z.ZodType< - StrategyOpen, + string, z.ZodTypeDef, StrategyOpen -> = z.union([ - z.nativeEnum(Strategy), - z.string().and(z.custom>()), -]); - -/** - * @internal - * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. - */ -export namespace Strategy$ { - /** @deprecated use `Strategy$inboundSchema` instead. */ - export const inboundSchema = Strategy$inboundSchema; - /** @deprecated use `Strategy$outboundSchema` instead. */ - export const outboundSchema = Strategy$outboundSchema; -} +> = openEnums.outboundSchema(Strategy); /** @internal */ export const VLMModelProvider$inboundSchema: z.ZodType< VLMModelProviderOpen, z.ZodTypeDef, unknown -> = z - .union([ - z.nativeEnum(VLMModelProvider), - z.string().transform(catchUnrecognizedEnum), - ]); - +> = openEnums.inboundSchema(VLMModelProvider); /** @internal */ export const VLMModelProvider$outboundSchema: z.ZodType< - VLMModelProviderOpen, + string, z.ZodTypeDef, VLMModelProviderOpen -> = z.union([ - z.nativeEnum(VLMModelProvider), - z.string().and(z.custom>()), -]); - -/** - * @internal - * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. - */ -export namespace VLMModelProvider$ { - /** @deprecated use `VLMModelProvider$inboundSchema` instead. */ - export const inboundSchema = VLMModelProvider$inboundSchema; - /** @deprecated use `VLMModelProvider$outboundSchema` instead. */ - export const outboundSchema = VLMModelProvider$outboundSchema; -} +> = openEnums.outboundSchema(VLMModelProvider); /** @internal */ export const PartitionParameters$inboundSchema: z.ZodType< @@ -464,7 +389,6 @@ export const PartitionParameters$inboundSchema: z.ZodType< "xml_keep_tags": "xmlKeepTags", }); }); - /** @internal */ export type PartitionParameters$Outbound = { chunking_strategy?: string | null | undefined; @@ -594,19 +518,6 @@ export const PartitionParameters$outboundSchema: z.ZodType< }); }); -/** - * @internal - * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. - */ -export namespace PartitionParameters$ { - /** @deprecated use `PartitionParameters$inboundSchema` instead. */ - export const inboundSchema = PartitionParameters$inboundSchema; - /** @deprecated use `PartitionParameters$outboundSchema` instead. */ - export const outboundSchema = PartitionParameters$outboundSchema; - /** @deprecated use `PartitionParameters$Outbound` instead. */ - export type Outbound = PartitionParameters$Outbound; -} - export function partitionParametersToJSON( partitionParameters: PartitionParameters, ): string { @@ -614,7 +525,6 @@ export function partitionParametersToJSON( PartitionParameters$outboundSchema.parse(partitionParameters), ); } - export function partitionParametersFromJSON( jsonString: string, ): SafeParseResult { diff --git a/src/sdk/models/shared/security.ts b/src/sdk/models/shared/security.ts index 0081414..86863c0 100644 --- a/src/sdk/models/shared/security.ts +++ b/src/sdk/models/shared/security.ts @@ -24,7 +24,6 @@ export const Security$inboundSchema: z.ZodType< "ApiKeyAuth": "apiKeyAuth", }); }); - /** @internal */ export type Security$Outbound = { ApiKeyAuth?: string | undefined; @@ -43,23 +42,9 @@ export const Security$outboundSchema: z.ZodType< }); }); -/** - * @internal - * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. - */ -export namespace Security$ { - /** @deprecated use `Security$inboundSchema` instead. */ - export const inboundSchema = Security$inboundSchema; - /** @deprecated use `Security$outboundSchema` instead. */ - export const outboundSchema = Security$outboundSchema; - /** @deprecated use `Security$Outbound` instead. */ - export type Outbound = Security$Outbound; -} - export function securityToJSON(security: Security): string { return JSON.stringify(Security$outboundSchema.parse(security)); } - export function securityFromJSON( jsonString: string, ): SafeParseResult { diff --git a/src/sdk/models/shared/validationerror.ts b/src/sdk/models/shared/validationerror.ts index 79a50ed..1ee6f12 100644 --- a/src/sdk/models/shared/validationerror.ts +++ b/src/sdk/models/shared/validationerror.ts @@ -19,7 +19,6 @@ export type ValidationError = { export const Loc$inboundSchema: z.ZodType = z.union( [z.string(), z.number().int()], ); - /** @internal */ export type Loc$Outbound = string | number; @@ -27,23 +26,9 @@ export type Loc$Outbound = string | number; export const Loc$outboundSchema: z.ZodType = z .union([z.string(), z.number().int()]); -/** - * @internal - * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. - */ -export namespace Loc$ { - /** @deprecated use `Loc$inboundSchema` instead. */ - export const inboundSchema = Loc$inboundSchema; - /** @deprecated use `Loc$outboundSchema` instead. */ - export const outboundSchema = Loc$outboundSchema; - /** @deprecated use `Loc$Outbound` instead. */ - export type Outbound = Loc$Outbound; -} - export function locToJSON(loc: Loc): string { return JSON.stringify(Loc$outboundSchema.parse(loc)); } - export function locFromJSON( jsonString: string, ): SafeParseResult { @@ -64,7 +49,6 @@ export const ValidationError$inboundSchema: z.ZodType< msg: z.string(), type: z.string(), }); - /** @internal */ export type ValidationError$Outbound = { loc: Array; @@ -83,25 +67,11 @@ export const ValidationError$outboundSchema: z.ZodType< type: 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 ValidationError$ { - /** @deprecated use `ValidationError$inboundSchema` instead. */ - export const inboundSchema = ValidationError$inboundSchema; - /** @deprecated use `ValidationError$outboundSchema` instead. */ - export const outboundSchema = ValidationError$outboundSchema; - /** @deprecated use `ValidationError$Outbound` instead. */ - export type Outbound = ValidationError$Outbound; -} - export function validationErrorToJSON( validationError: ValidationError, ): string { return JSON.stringify(ValidationError$outboundSchema.parse(validationError)); } - export function validationErrorFromJSON( jsonString: string, ): SafeParseResult { diff --git a/src/sdk/types/enums.ts b/src/sdk/types/enums.ts index 6fb6d91..32ad7bc 100644 --- a/src/sdk/types/enums.ts +++ b/src/sdk/types/enums.ts @@ -2,15 +2,64 @@ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import * as z from "zod/v3"; + declare const __brand: unique symbol; export type Unrecognized = T & { [__brand]: "unrecognized" }; +export type ClosedEnum>> = + T[keyof T]; +export type OpenEnum>> = + | T[keyof T] + | Unrecognized; -export function catchUnrecognizedEnum(value: T): Unrecognized { +function unrecognized(value: T): Unrecognized { + unrecognizedCount++; return value as Unrecognized; } -type Prettify = { [K in keyof T]: T[K] } & {}; -export type ClosedEnum = T[keyof T]; -export type OpenEnum = - | Prettify - | Unrecognized; +let unrecognizedCount = 0; +let refCount = 0; +export function unrecognizedCounter() { + refCount++; + const start = unrecognizedCount; + return { + count: () => { + const count = unrecognizedCount - start; + if (--refCount === 0) unrecognizedCount = 0; + return count; + }, + }; +} + +export function inboundSchema>( + enumObj: T, +): z.ZodType, z.ZodTypeDef, unknown> { + const options = Object.values(enumObj); + return z.union([ + ...options.map(x => z.literal(x)), + z.string().transform(x => unrecognized(x)), + ] as any); +} + +export function inboundSchemaInt>( + enumObj: T, +): z.ZodType, z.ZodTypeDef, unknown> { + // For numeric enums, Object.values returns both numbers and string keys + const options = Object.values(enumObj).filter(v => typeof v === "number"); + return z.union([ + ...options.map(x => z.literal(x)), + z.number().int().transform(x => unrecognized(x)), + ] as any); +} + +export function outboundSchema>( + _: T, +): z.ZodType> { + return z.string() as any; +} + +export function outboundSchemaInt>( + _: T, +): z.ZodType> { + return z.number().int() as any; +} diff --git a/src/sdk/types/index.ts b/src/sdk/types/index.ts index e124e81..92d9f73 100644 --- a/src/sdk/types/index.ts +++ b/src/sdk/types/index.ts @@ -3,7 +3,6 @@ */ export { blobLikeSchema, isBlobLike } from "./blobs.js"; -export { catchUnrecognizedEnum } from "./enums.js"; export type { ClosedEnum, OpenEnum, Unrecognized } from "./enums.js"; export type { Result } from "./fp.js"; export type { PageIterator, Paginator } from "./operations.js";