From bfcc1dd4cb8cc5a923d7f1aaa5ee3f724fae329e Mon Sep 17 00:00:00 2001 From: Sami Belkadi Date: Thu, 12 Dec 2024 11:06:29 -0500 Subject: [PATCH 1/7] Add tests for parsing frontmatter logo --- .../src/__test__/parseImagePaths.test.ts | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/packages/cli/docs-markdown-utils/src/__test__/parseImagePaths.test.ts b/packages/cli/docs-markdown-utils/src/__test__/parseImagePaths.test.ts index 92e69f88611..50e49488c24 100644 --- a/packages/cli/docs-markdown-utils/src/__test__/parseImagePaths.test.ts +++ b/packages/cli/docs-markdown-utils/src/__test__/parseImagePaths.test.ts @@ -140,6 +140,90 @@ describe("parseImagePaths", () => { ); }); + it("should parse logo from frontmatter text", () => { + const page = '---\nlogo: "path/to/image.png"\n---'; + const result = parseImagePaths(page, PATHS); + expect(result.filepaths).toEqual(["/Volume/git/fern/my/docs/folder/path/to/image.png"]); + expect(result.markdown.trim()).toMatchInlineSnapshot( + ` + "--- + logo: + type: fileId + value: /Volume/git/fern/my/docs/folder/path/to/image.png + ---" + ` + ); + }); + + it("should parse url logo from frontmatter text", () => { + const page = '---\nlogo: "https://someurl.com"\n---'; + const result = parseImagePaths(page, PATHS); + expect(result.filepaths).toEqual([]); + expect(result.markdown.trim()).toMatchInlineSnapshot( + ` + "--- + logo: + type: url + value: 'https://someurl.com' + ---" + ` + ); + }); + + it("should parse light and dark logo from frontmatter json", () => { + const page = '---\nlogo:\n light: "path/to/light-image.png"\n dark: "path/to/dark-image.png"\n---'; + const result = parseImagePaths(page, PATHS); + expect(result.filepaths).toEqual([ + "/Volume/git/fern/my/docs/folder/path/to/light-image.png", + "/Volume/git/fern/my/docs/folder/path/to/dark-image.png" + ]); + expect(result.markdown.trim()).toMatchInlineSnapshot( + ` + "--- + logo: + light: + type: fileId + value: /Volume/git/fern/my/docs/folder/path/to/light-image.png + dark: + type: fileId + value: /Volume/git/fern/my/docs/folder/path/to/dark-image.png + ---" + ` + ); + }); + + it("should parse light logo from frontmatter json", () => { + const page = '---\nlogo:\n light: "path/to/light-image.png"\n---'; + const result = parseImagePaths(page, PATHS); + expect(result.filepaths).toEqual(["/Volume/git/fern/my/docs/folder/path/to/light-image.png"]); + expect(result.markdown.trim()).toMatchInlineSnapshot( + ` + "--- + logo: + light: + type: fileId + value: /Volume/git/fern/my/docs/folder/path/to/light-image.png + ---" + ` + ); + }); + + it("should parse dark logo from frontmatter json", () => { + const page = '---\nlogo:\n dark: "path/to/dark-image.png"\n---'; + const result = parseImagePaths(page, PATHS); + expect(result.filepaths).toEqual(["/Volume/git/fern/my/docs/folder/path/to/dark-image.png"]); + expect(result.markdown.trim()).toMatchInlineSnapshot( + ` + "--- + logo: + dark: + type: fileId + value: /Volume/git/fern/my/docs/folder/path/to/dark-image.png + ---" + ` + ); + }); + it("should parse the same result when run twice for frontmatter text", () => { const page = '---\nimage: "path/to/image.png"\n---'; const result = parseImagePaths(page, PATHS); From df6dbc46ef4e328a62b52aa5303a514440924293 Mon Sep 17 00:00:00 2001 From: Sami Belkadi Date: Thu, 12 Dec 2024 11:08:28 -0500 Subject: [PATCH 2/7] Parse logo from frontmatter --- .../src/parseImagePaths.ts | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/packages/cli/docs-markdown-utils/src/parseImagePaths.ts b/packages/cli/docs-markdown-utils/src/parseImagePaths.ts index 229987f341c..ce567afb0a4 100644 --- a/packages/cli/docs-markdown-utils/src/parseImagePaths.ts +++ b/packages/cli/docs-markdown-utils/src/parseImagePaths.ts @@ -48,6 +48,7 @@ export function parseImagePaths( } visitFrontmatterImages(data, ["image", "og:image", "og:logo", "twitter:image"], mapImage); + parseFrontmatterImagesforLogo(data, mapImage); const tree = parseMarkdownToTree(content); @@ -206,6 +207,7 @@ export function replaceImagePathsAndUrls( } visitFrontmatterImages(data, ["image", "og:image", "og:logo", "twitter:image"], mapImage); + replaceFrontmatterImagesforLogo(data, mapImage); visit(tree, (node) => { if (node.position == null) { @@ -402,3 +404,81 @@ function visitFrontmatterImages( } } } + +function parseFrontmatterImagesforLogo( + data: Record, + mapImage: (image: string | undefined) => string | undefined +) { + const value = data.logo; + if (value != null) { + if (typeof value === "string") { + const mappedImage = mapImage(value); + data.logo = mappedImage + ? { + type: "fileId", + value: CjsFdrSdk.FileId(mappedImage) + } + : { + type: "url", + value: CjsFdrSdk.Url(value) + }; + } else if (typeof value === "object") { + if ("light" in value && typeof value.light === "string") { + const mappedImage = mapImage(value.light); + data.logo.light = mappedImage + ? { + type: "fileId", + value: CjsFdrSdk.FileId(mappedImage) + } + : { + type: "url", + value: CjsFdrSdk.Url(value.light) + }; + } + if ("dark" in value && typeof value.dark === "string") { + const mappedImage = mapImage(value.dark); + data.logo.dark = mappedImage + ? { + type: "fileId", + value: CjsFdrSdk.FileId(mappedImage) + } + : { + type: "url", + value: CjsFdrSdk.Url(value.dark) + }; + } + } + } +} + +function replaceFrontmatterImagesforLogo( + data: Record, + mapImage: (image: string | undefined) => string | undefined +) { + const value = data.logo; + if (value != null && typeof value === "object") { + if ("type" in value && value.type === "fileId") { + data.logo = { + type: "fileId", + value: CjsFdrSdk.FileId(mapImage(value.value) ?? value.value) + }; + } else { + if ("light" in value && value.light != null) { + if ("type" in value.light && value.light.type === "fileId") { + data.logo.light = { + type: "fileId", + value: CjsFdrSdk.FileId(mapImage(value.light.value) ?? value.light.value) + }; + } + } + if ("dark" in value && value.dark != null) { + if ("type" in value.dark && value.dark.type === "fileId") { + data.logo.dark = { + type: "fileId", + value: CjsFdrSdk.FileId(mapImage(value.dark.value) ?? value.dark.value) + }; + } + } + } + } +} From 2c5076ab07f08733003fd0722b23f6d0057aec7e Mon Sep 17 00:00:00 2001 From: Sami Belkadi Date: Thu, 12 Dec 2024 15:45:41 -0500 Subject: [PATCH 3/7] Add docs for frontmatter logo --- fern/pages/fern-docs/content/front-matter.mdx | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/fern/pages/fern-docs/content/front-matter.mdx b/fern/pages/fern-docs/content/front-matter.mdx index 06a1c0fd86c..d22bc260b9b 100644 --- a/fern/pages/fern-docs/content/front-matter.mdx +++ b/fern/pages/fern-docs/content/front-matter.mdx @@ -177,6 +177,28 @@ Controls the conditional rendering of the on-page feedback form at the bottom of On-page feedback feature +## Page logo + +**Name**: `logo`
+**Type**: object
+**Default**: None + +You can override the site-wide logo for a page by setting a field named `logo` in any page's frontmatter like this: + + + +```mdx +--- +logo: + light: /path/to/page-logo.png + dark: /path/to/page-logo.png +--- +``` + + + +This field specifies the logo for this page. If no logo is set, the site-wide [logo configuration](/learn/docs/getting-started/global-configuration#logo-configuration) is used. + ## SEO metadata Fern also supports adding SEO-specific metadata in the frontmatter. From 62a99c3a1f84c9eb9094ec8e171836d3c4d771dd Mon Sep 17 00:00:00 2001 From: dsinghvi Date: Fri, 13 Dec 2024 19:55:51 -0500 Subject: [PATCH 4/7] fix --- packages/cli/docs-markdown-utils/package.json | 3 +- .../src/parseImagePaths.ts | 115 ++++++++---------- pnpm-lock.yaml | 3 + 3 files changed, 58 insertions(+), 63 deletions(-) diff --git a/packages/cli/docs-markdown-utils/package.json b/packages/cli/docs-markdown-utils/package.json index d85f1317673..3e157089867 100644 --- a/packages/cli/docs-markdown-utils/package.json +++ b/packages/cli/docs-markdown-utils/package.json @@ -46,6 +46,7 @@ "organize-imports-cli": "^0.10.0", "prettier": "^2.7.1", "typescript": "4.6.4", - "vitest": "^2.0.5" + "vitest": "^2.0.5", + "zod": "^3.22.3" } } diff --git a/packages/cli/docs-markdown-utils/src/parseImagePaths.ts b/packages/cli/docs-markdown-utils/src/parseImagePaths.ts index ce567afb0a4..48305a293e7 100644 --- a/packages/cli/docs-markdown-utils/src/parseImagePaths.ts +++ b/packages/cli/docs-markdown-utils/src/parseImagePaths.ts @@ -7,6 +7,7 @@ import { mdxFromMarkdown } from "mdast-util-mdx"; import { mdx } from "micromark-extension-mdx"; import { visit } from "unist-util-visit"; import { parseMarkdownToTree } from "./parseMarkdownToTree"; +import { z } from "zod"; interface AbsolutePathMetadata { absolutePathToMdx: AbsoluteFilePath; @@ -405,48 +406,48 @@ function visitFrontmatterImages( } } +const LogoOverrideFrontmatterSchema = z.union([ + z.string(), + z.object({ + light: z.string().optional(), + dark: z.string().optional() + }) +]); + +export function convertImageToFileIdOrUrl( + value: string, + mapImage: (image: string | undefined) => string | undefined +): CjsFdrSdk.docs.latest.FileIdOrUrl { + const mappedImage = mapImage(value); + return mappedImage + ? { + type: "fileId", + value: CjsFdrSdk.FileId(mappedImage) + } + : { + type: "url", + value: CjsFdrSdk.Url(value) + }; +} + function parseFrontmatterImagesforLogo( data: Record, mapImage: (image: string | undefined) => string | undefined ) { - const value = data.logo; - if (value != null) { - if (typeof value === "string") { - const mappedImage = mapImage(value); - data.logo = mappedImage - ? { - type: "fileId", - value: CjsFdrSdk.FileId(mappedImage) - } - : { - type: "url", - value: CjsFdrSdk.Url(value) - }; - } else if (typeof value === "object") { - if ("light" in value && typeof value.light === "string") { - const mappedImage = mapImage(value.light); - data.logo.light = mappedImage - ? { - type: "fileId", - value: CjsFdrSdk.FileId(mappedImage) - } - : { - type: "url", - value: CjsFdrSdk.Url(value.light) - }; - } - if ("dark" in value && typeof value.dark === "string") { - const mappedImage = mapImage(value.dark); - data.logo.dark = mappedImage - ? { - type: "fileId", - value: CjsFdrSdk.FileId(mappedImage) - } - : { - type: "url", - value: CjsFdrSdk.Url(value.dark) - }; - } + const parsedValue = LogoOverrideFrontmatterSchema.safeParse(data.logo); + if (!parsedValue.success) { + return; + } + const parsedFrontmatterLogo = parsedValue.data; + + if (typeof parsedFrontmatterLogo === "string") { + data.logo = convertImageToFileIdOrUrl(parsedFrontmatterLogo, mapImage); + } else { + if (parsedFrontmatterLogo.light != null) { + data.logo.light = convertImageToFileIdOrUrl(parsedFrontmatterLogo.light, mapImage); + } + if (parsedFrontmatterLogo.dark != null) { + data.logo.dark = convertImageToFileIdOrUrl(parsedFrontmatterLogo.dark, mapImage); } } } @@ -455,30 +456,20 @@ function replaceFrontmatterImagesforLogo( data: Record, mapImage: (image: string | undefined) => string | undefined ) { - const value = data.logo; - if (value != null && typeof value === "object") { - if ("type" in value && value.type === "fileId") { - data.logo = { - type: "fileId", - value: CjsFdrSdk.FileId(mapImage(value.value) ?? value.value) - }; - } else { - if ("light" in value && value.light != null) { - if ("type" in value.light && value.light.type === "fileId") { - data.logo.light = { - type: "fileId", - value: CjsFdrSdk.FileId(mapImage(value.light.value) ?? value.light.value) - }; - } - } - if ("dark" in value && value.dark != null) { - if ("type" in value.dark && value.dark.type === "fileId") { - data.logo.dark = { - type: "fileId", - value: CjsFdrSdk.FileId(mapImage(value.dark.value) ?? value.dark.value) - }; - } - } + const parsedValue = LogoOverrideFrontmatterSchema.safeParse(data.logo); + if (!parsedValue.success) { + return; + } + const parsedFrontmatterLogo = parsedValue.data; + + if (typeof parsedFrontmatterLogo === "string") { + data.logo = convertImageToFileIdOrUrl(parsedFrontmatterLogo, mapImage); + } else { + if (parsedFrontmatterLogo.light != null) { + data.logo.light = convertImageToFileIdOrUrl(parsedFrontmatterLogo.light, mapImage); + } + if (parsedFrontmatterLogo.dark != null) { + data.logo.dark = convertImageToFileIdOrUrl(parsedFrontmatterLogo.dark, mapImage); } } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 534de0d8a89..054ec7ffa30 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4492,6 +4492,9 @@ importers: vitest: specifier: ^2.0.5 version: 2.0.5(@types/node@18.7.18)(jsdom@20.0.3)(sass@1.72.0)(terser@5.31.5) + zod: + specifier: ^3.22.3 + version: 3.23.8 packages/cli/docs-preview: dependencies: From 6ec3a3382d8890602e4ca371c1eef0688a9d3047 Mon Sep 17 00:00:00 2001 From: dsinghvi Date: Fri, 13 Dec 2024 19:57:27 -0500 Subject: [PATCH 5/7] remove logic --- .../src/parseImagePaths.ts | 24 +- .../streaming/no-serde-layer/dist/Client.d.ts | 26 ++ .../streaming/no-serde-layer/dist/Client.js | 17 ++ .../no-serde-layer/dist/api/index.d.ts | 1 + .../no-serde-layer/dist/api/index.js | 17 ++ .../api/resources/dummy/client/Client.d.ts | 35 +++ .../dist/api/resources/dummy/client/Client.js | 155 +++++++++++ .../api/resources/dummy/client/index.d.ts | 1 + .../dist/api/resources/dummy/client/index.js | 17 ++ .../requests/GenerateStreamRequest.d.ts | 6 + .../client/requests/GenerateStreamRequest.js | 5 + .../dummy/client/requests/Generateequest.d.ts | 12 + .../dummy/client/requests/Generateequest.js | 5 + .../dummy/client/requests/index.d.ts | 2 + .../resources/dummy/client/requests/index.js | 2 + .../dist/api/resources/dummy/index.d.ts | 2 + .../dist/api/resources/dummy/index.js | 18 ++ .../resources/dummy/types/StreamResponse.d.ts | 7 + .../resources/dummy/types/StreamResponse.js | 5 + .../dist/api/resources/dummy/types/index.d.ts | 1 + .../dist/api/resources/dummy/types/index.js | 17 ++ .../dist/api/resources/index.d.ts | 3 + .../dist/api/resources/index.js | 32 +++ .../dist/core/fetcher/APIResponse.d.ts | 10 + .../dist/core/fetcher/APIResponse.js | 2 + .../dist/core/fetcher/Fetcher.d.ts | 39 +++ .../dist/core/fetcher/Fetcher.js | 99 +++++++ .../dist/core/fetcher/Supplier.d.ts | 4 + .../dist/core/fetcher/Supplier.js | 22 ++ .../dist/core/fetcher/createRequestUrl.d.ts | 1 + .../dist/core/fetcher/createRequestUrl.js | 13 + .../dist/core/fetcher/getFetchFn.d.ts | 4 + .../dist/core/fetcher/getFetchFn.js | 59 ++++ .../dist/core/fetcher/getHeader.d.ts | 1 + .../dist/core/fetcher/getHeader.js | 12 + .../dist/core/fetcher/getRequestBody.d.ts | 7 + .../dist/core/fetcher/getRequestBody.js | 23 ++ .../dist/core/fetcher/getResponseBody.d.ts | 1 + .../dist/core/fetcher/getResponseBody.js | 55 ++++ .../dist/core/fetcher/index.d.ts | 5 + .../no-serde-layer/dist/core/fetcher/index.js | 9 + .../dist/core/fetcher/makeRequest.d.ts | 1 + .../dist/core/fetcher/makeRequest.js | 42 +++ .../dist/core/fetcher/requestWithRetries.d.ts | 1 + .../dist/core/fetcher/requestWithRetries.js | 41 +++ .../dist/core/fetcher/signals.d.ts | 12 + .../dist/core/fetcher/signals.js | 37 +++ .../Node18UniversalStreamWrapper.d.ts | 30 ++ .../Node18UniversalStreamWrapper.js | 247 +++++++++++++++++ .../NodePre18StreamWrapper.d.ts | 22 ++ .../stream-wrappers/NodePre18StreamWrapper.js | 124 +++++++++ .../stream-wrappers/UndiciStreamWrapper.d.ts | 31 +++ .../stream-wrappers/UndiciStreamWrapper.js | 229 +++++++++++++++ .../stream-wrappers/chooseStreamWrapper.d.ts | 18 ++ .../stream-wrappers/chooseStreamWrapper.js | 50 ++++ .../no-serde-layer/dist/core/index.d.ts | 4 + .../no-serde-layer/dist/core/index.js | 33 +++ .../dist/core/runtime/index.d.ts | 1 + .../no-serde-layer/dist/core/runtime/index.js | 5 + .../dist/core/runtime/runtime.d.ts | 9 + .../dist/core/runtime/runtime.js | 93 +++++++ .../dist/core/schemas/Schema.d.ts | 85 ++++++ .../dist/core/schemas/Schema.js | 22 ++ .../core/schemas/builders/bigint/bigint.d.ts | 2 + .../core/schemas/builders/bigint/bigint.js | 50 ++++ .../core/schemas/builders/bigint/index.d.ts | 1 + .../core/schemas/builders/bigint/index.js | 5 + .../dist/core/schemas/builders/date/date.d.ts | 2 + .../dist/core/schemas/builders/date/date.js | 63 +++++ .../core/schemas/builders/date/index.d.ts | 1 + .../dist/core/schemas/builders/date/index.js | 5 + .../dist/core/schemas/builders/enum/enum.d.ts | 2 + .../dist/core/schemas/builders/enum/enum.js | 39 +++ .../core/schemas/builders/enum/index.d.ts | 1 + .../dist/core/schemas/builders/enum/index.js | 5 + .../dist/core/schemas/builders/index.d.ts | 14 + .../dist/core/schemas/builders/index.js | 30 ++ .../core/schemas/builders/lazy/index.d.ts | 3 + .../dist/core/schemas/builders/lazy/index.js | 7 + .../dist/core/schemas/builders/lazy/lazy.d.ts | 5 + .../dist/core/schemas/builders/lazy/lazy.js | 25 ++ .../schemas/builders/lazy/lazyObject.d.ts | 3 + .../core/schemas/builders/lazy/lazyObject.js | 12 + .../core/schemas/builders/list/index.d.ts | 1 + .../dist/core/schemas/builders/list/index.js | 5 + .../dist/core/schemas/builders/list/list.d.ts | 2 + .../dist/core/schemas/builders/list/list.js | 55 ++++ .../builders/literals/booleanLiteral.d.ts | 2 + .../builders/literals/booleanLiteral.js | 29 ++ .../core/schemas/builders/literals/index.d.ts | 2 + .../core/schemas/builders/literals/index.js | 7 + .../builders/literals/stringLiteral.d.ts | 2 + .../builders/literals/stringLiteral.js | 29 ++ .../object-like/getObjectLikeUtils.d.ts | 9 + .../object-like/getObjectLikeUtils.js | 54 ++++ .../schemas/builders/object-like/index.d.ts | 2 + .../schemas/builders/object-like/index.js | 6 + .../schemas/builders/object-like/types.d.ts | 7 + .../schemas/builders/object-like/types.js | 2 + .../core/schemas/builders/object/index.d.ts | 6 + .../core/schemas/builders/object/index.js | 11 + .../core/schemas/builders/object/object.d.ts | 3 + .../core/schemas/builders/object/object.js | 261 ++++++++++++++++++ .../objectWithoutOptionalProperties.d.ts | 6 + .../object/objectWithoutOptionalProperties.js | 8 + .../schemas/builders/object/property.d.ts | 8 + .../core/schemas/builders/object/property.js | 16 ++ .../core/schemas/builders/object/types.d.ts | 31 +++ .../core/schemas/builders/object/types.js | 2 + .../core/schemas/builders/primitives/any.d.ts | 1 + .../core/schemas/builders/primitives/any.js | 6 + .../schemas/builders/primitives/boolean.d.ts | 1 + .../schemas/builders/primitives/boolean.js | 25 ++ .../schemas/builders/primitives/index.d.ts | 5 + .../core/schemas/builders/primitives/index.js | 13 + .../schemas/builders/primitives/number.d.ts | 1 + .../schemas/builders/primitives/number.js | 25 ++ .../schemas/builders/primitives/string.d.ts | 1 + .../schemas/builders/primitives/string.js | 25 ++ .../schemas/builders/primitives/unknown.d.ts | 1 + .../schemas/builders/primitives/unknown.js | 6 + .../core/schemas/builders/record/index.d.ts | 2 + .../core/schemas/builders/record/index.js | 5 + .../core/schemas/builders/record/record.d.ts | 3 + .../core/schemas/builders/record/record.js | 95 +++++++ .../core/schemas/builders/record/types.d.ts | 4 + .../core/schemas/builders/record/types.js | 2 + .../builders/schema-utils/JsonError.d.ts | 5 + .../builders/schema-utils/JsonError.js | 12 + .../builders/schema-utils/ParseError.d.ts | 5 + .../builders/schema-utils/ParseError.js | 12 + .../builders/schema-utils/getSchemaUtils.d.ts | 17 ++ .../builders/schema-utils/getSchemaUtils.js | 82 ++++++ .../schemas/builders/schema-utils/index.d.ts | 4 + .../schemas/builders/schema-utils/index.js | 11 + .../stringifyValidationErrors.d.ts | 2 + .../schema-utils/stringifyValidationErrors.js | 10 + .../dist/core/schemas/builders/set/index.d.ts | 1 + .../dist/core/schemas/builders/set/index.js | 5 + .../dist/core/schemas/builders/set/set.d.ts | 2 + .../dist/core/schemas/builders/set/set.js | 44 +++ .../builders/undiscriminated-union/index.d.ts | 2 + .../builders/undiscriminated-union/index.js | 5 + .../builders/undiscriminated-union/types.d.ts | 4 + .../builders/undiscriminated-union/types.js | 2 + .../undiscriminatedUnion.d.ts | 3 + .../undiscriminatedUnion.js | 40 +++ .../schemas/builders/union/discriminant.d.ts | 5 + .../schemas/builders/union/discriminant.js | 10 + .../core/schemas/builders/union/index.d.ts | 4 + .../dist/core/schemas/builders/union/index.js | 7 + .../core/schemas/builders/union/types.d.ts | 13 + .../dist/core/schemas/builders/union/types.js | 2 + .../core/schemas/builders/union/union.d.ts | 4 + .../dist/core/schemas/builders/union/union.js | 130 +++++++++ .../dist/core/schemas/index.d.ts | 2 + .../no-serde-layer/dist/core/schemas/index.js | 17 ++ .../dist/core/schemas/utils/MaybePromise.d.ts | 1 + .../dist/core/schemas/utils/MaybePromise.js | 2 + .../addQuestionMarksToNullableProperties.d.ts | 7 + .../addQuestionMarksToNullableProperties.js | 2 + .../utils/createIdentitySchemaCreator.d.ts | 2 + .../utils/createIdentitySchemaCreator.js | 16 ++ .../dist/core/schemas/utils/entries.d.ts | 1 + .../dist/core/schemas/utils/entries.js | 7 + .../dist/core/schemas/utils/filterObject.d.ts | 1 + .../dist/core/schemas/utils/filterObject.js | 14 + .../getErrorMessageForIncorrectType.d.ts | 1 + .../utils/getErrorMessageForIncorrectType.js | 28 ++ .../core/schemas/utils/isPlainObject.d.ts | 1 + .../dist/core/schemas/utils/isPlainObject.js | 18 ++ .../dist/core/schemas/utils/keys.d.ts | 1 + .../dist/core/schemas/utils/keys.js | 7 + .../schemas/utils/maybeSkipValidation.d.ts | 2 + .../core/schemas/utils/maybeSkipValidation.js | 28 ++ .../dist/core/schemas/utils/partition.d.ts | 1 + .../dist/core/schemas/utils/partition.js | 16 ++ .../dist/core/streaming-fetcher/Stream.d.ts | 48 ++++ .../dist/core/streaming-fetcher/Stream.js | 170 ++++++++++++ .../dist/core/streaming-fetcher/index.d.ts | 1 + .../dist/core/streaming-fetcher/index.js | 5 + .../dist/errors/SeedStreamingError.d.ts | 12 + .../dist/errors/SeedStreamingError.js | 32 +++ .../errors/SeedStreamingTimeoutError.d.ts | 6 + .../dist/errors/SeedStreamingTimeoutError.js | 13 + .../no-serde-layer/dist/errors/index.d.ts | 2 + .../no-serde-layer/dist/errors/index.js | 7 + .../streaming/no-serde-layer/dist/index.d.ts | 3 + .../streaming/no-serde-layer/dist/index.js | 32 +++ .../dist/serialization/index.d.ts | 1 + .../dist/serialization/index.js | 17 ++ .../resources/dummy/client/index.d.ts | 1 + .../resources/dummy/client/index.js | 17 ++ .../requests/GenerateStreamRequest.d.ts | 12 + .../client/requests/GenerateStreamRequest.js | 33 +++ .../dummy/client/requests/Generateequest.d.ts | 12 + .../dummy/client/requests/Generateequest.js | 33 +++ .../dummy/client/requests/index.d.ts | 2 + .../resources/dummy/client/requests/index.js | 7 + .../serialization/resources/dummy/index.d.ts | 2 + .../serialization/resources/dummy/index.js | 18 ++ .../resources/dummy/types/StreamResponse.d.ts | 13 + .../resources/dummy/types/StreamResponse.js | 34 +++ .../resources/dummy/types/index.d.ts | 1 + .../resources/dummy/types/index.js | 17 ++ .../dist/serialization/resources/index.d.ts | 3 + .../dist/serialization/resources/index.js | 32 +++ .../no-serde-layer/dist/version.d.ts | 1 + .../streaming/no-serde-layer/dist/version.js | 4 + 209 files changed, 4161 insertions(+), 23 deletions(-) create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/Client.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/Client.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/api/index.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/api/index.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/client/Client.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/client/Client.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/client/index.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/client/index.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/client/requests/GenerateStreamRequest.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/client/requests/GenerateStreamRequest.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/client/requests/Generateequest.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/client/requests/Generateequest.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/client/requests/index.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/client/requests/index.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/index.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/index.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/types/StreamResponse.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/types/StreamResponse.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/types/index.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/types/index.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/index.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/index.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/APIResponse.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/APIResponse.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/Fetcher.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/Fetcher.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/Supplier.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/Supplier.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/createRequestUrl.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/createRequestUrl.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/getFetchFn.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/getFetchFn.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/getHeader.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/getHeader.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/getRequestBody.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/getRequestBody.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/getResponseBody.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/getResponseBody.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/index.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/index.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/makeRequest.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/makeRequest.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/requestWithRetries.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/requestWithRetries.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/signals.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/signals.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/stream-wrappers/NodePre18StreamWrapper.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/stream-wrappers/NodePre18StreamWrapper.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/stream-wrappers/UndiciStreamWrapper.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/stream-wrappers/UndiciStreamWrapper.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/stream-wrappers/chooseStreamWrapper.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/stream-wrappers/chooseStreamWrapper.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/index.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/index.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/runtime/index.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/runtime/index.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/runtime/runtime.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/runtime/runtime.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/Schema.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/Schema.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/bigint/bigint.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/bigint/bigint.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/bigint/index.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/bigint/index.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/date/date.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/date/date.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/date/index.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/date/index.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/enum/enum.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/enum/enum.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/enum/index.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/enum/index.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/index.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/index.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/lazy/index.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/lazy/index.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/lazy/lazy.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/lazy/lazy.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/lazy/lazyObject.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/lazy/lazyObject.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/list/index.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/list/index.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/list/list.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/list/list.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/literals/booleanLiteral.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/literals/booleanLiteral.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/literals/index.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/literals/index.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/literals/stringLiteral.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/literals/stringLiteral.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object-like/getObjectLikeUtils.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object-like/getObjectLikeUtils.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object-like/index.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object-like/index.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object-like/types.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object-like/types.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object/index.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object/index.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object/object.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object/object.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object/objectWithoutOptionalProperties.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object/objectWithoutOptionalProperties.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object/property.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object/property.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object/types.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object/types.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/any.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/any.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/boolean.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/boolean.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/index.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/index.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/number.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/number.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/string.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/string.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/unknown.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/unknown.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/record/index.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/record/index.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/record/record.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/record/record.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/record/types.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/record/types.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/schema-utils/JsonError.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/schema-utils/JsonError.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/schema-utils/ParseError.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/schema-utils/ParseError.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/schema-utils/getSchemaUtils.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/schema-utils/getSchemaUtils.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/schema-utils/index.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/schema-utils/index.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/schema-utils/stringifyValidationErrors.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/schema-utils/stringifyValidationErrors.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/set/index.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/set/index.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/set/set.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/set/set.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/undiscriminated-union/index.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/undiscriminated-union/index.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/undiscriminated-union/types.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/undiscriminated-union/types.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/union/discriminant.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/union/discriminant.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/union/index.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/union/index.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/union/types.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/union/types.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/union/union.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/union/union.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/index.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/index.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/MaybePromise.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/MaybePromise.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/addQuestionMarksToNullableProperties.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/addQuestionMarksToNullableProperties.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/createIdentitySchemaCreator.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/createIdentitySchemaCreator.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/entries.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/entries.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/filterObject.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/filterObject.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/getErrorMessageForIncorrectType.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/getErrorMessageForIncorrectType.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/isPlainObject.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/isPlainObject.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/keys.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/keys.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/maybeSkipValidation.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/maybeSkipValidation.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/partition.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/partition.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/streaming-fetcher/Stream.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/streaming-fetcher/Stream.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/streaming-fetcher/index.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/core/streaming-fetcher/index.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/errors/SeedStreamingError.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/errors/SeedStreamingError.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/errors/SeedStreamingTimeoutError.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/errors/SeedStreamingTimeoutError.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/errors/index.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/errors/index.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/index.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/index.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/serialization/index.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/serialization/index.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/client/index.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/client/index.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/client/requests/GenerateStreamRequest.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/client/requests/GenerateStreamRequest.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/client/requests/Generateequest.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/client/requests/Generateequest.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/client/requests/index.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/client/requests/index.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/index.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/index.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/types/StreamResponse.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/types/StreamResponse.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/types/index.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/types/index.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/index.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/index.js create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/version.d.ts create mode 100644 seed/ts-sdk/streaming/no-serde-layer/dist/version.js diff --git a/packages/cli/docs-markdown-utils/src/parseImagePaths.ts b/packages/cli/docs-markdown-utils/src/parseImagePaths.ts index 48305a293e7..d828cfbfa23 100644 --- a/packages/cli/docs-markdown-utils/src/parseImagePaths.ts +++ b/packages/cli/docs-markdown-utils/src/parseImagePaths.ts @@ -49,7 +49,7 @@ export function parseImagePaths( } visitFrontmatterImages(data, ["image", "og:image", "og:logo", "twitter:image"], mapImage); - parseFrontmatterImagesforLogo(data, mapImage); + replaceFrontmatterImagesforLogo(data, mapImage); const tree = parseMarkdownToTree(content); @@ -430,28 +430,6 @@ export function convertImageToFileIdOrUrl( }; } -function parseFrontmatterImagesforLogo( - data: Record, - mapImage: (image: string | undefined) => string | undefined -) { - const parsedValue = LogoOverrideFrontmatterSchema.safeParse(data.logo); - if (!parsedValue.success) { - return; - } - const parsedFrontmatterLogo = parsedValue.data; - - if (typeof parsedFrontmatterLogo === "string") { - data.logo = convertImageToFileIdOrUrl(parsedFrontmatterLogo, mapImage); - } else { - if (parsedFrontmatterLogo.light != null) { - data.logo.light = convertImageToFileIdOrUrl(parsedFrontmatterLogo.light, mapImage); - } - if (parsedFrontmatterLogo.dark != null) { - data.logo.dark = convertImageToFileIdOrUrl(parsedFrontmatterLogo.dark, mapImage); - } - } -} - function replaceFrontmatterImagesforLogo( data: Record, mapImage: (image: string | undefined) => string | undefined diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/Client.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/Client.d.ts new file mode 100644 index 00000000000..46a1e41f2d2 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/Client.d.ts @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +import * as core from "./core"; +import { Dummy } from "./api/resources/dummy/client/Client"; +export declare namespace SeedStreamingClient { + interface Options { + environment: core.Supplier; + } + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Additional headers to include in the request. */ + headers?: Record; + } +} +export declare class SeedStreamingClient { + protected readonly _options: SeedStreamingClient.Options; + protected _dummy: Dummy | undefined; + constructor(_options: SeedStreamingClient.Options); + get dummy(): Dummy; +} diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/Client.js b/seed/ts-sdk/streaming/no-serde-layer/dist/Client.js new file mode 100644 index 00000000000..bcb73bdc0f8 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/Client.js @@ -0,0 +1,17 @@ +"use strict"; +/** + * This file was auto-generated by Fern from our API Definition. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SeedStreamingClient = void 0; +const Client_1 = require("./api/resources/dummy/client/Client"); +class SeedStreamingClient { + constructor(_options) { + this._options = _options; + } + get dummy() { + var _a; + return ((_a = this._dummy) !== null && _a !== void 0 ? _a : (this._dummy = new Client_1.Dummy(this._options))); + } +} +exports.SeedStreamingClient = SeedStreamingClient; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/api/index.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/api/index.d.ts new file mode 100644 index 00000000000..3e5335fe421 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/api/index.d.ts @@ -0,0 +1 @@ +export * from "./resources"; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/api/index.js b/seed/ts-sdk/streaming/no-serde-layer/dist/api/index.js new file mode 100644 index 00000000000..b88cbd1080b --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/api/index.js @@ -0,0 +1,17 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +__exportStar(require("./resources"), exports); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/client/Client.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/client/Client.d.ts new file mode 100644 index 00000000000..54099bf73cf --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/client/Client.d.ts @@ -0,0 +1,35 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +import * as core from "../../../../core"; +import * as SeedStreaming from "../../../index"; +export declare namespace Dummy { + interface Options { + environment: core.Supplier; + } + interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Additional headers to include in the request. */ + headers?: Record; + } +} +export declare class Dummy { + protected readonly _options: Dummy.Options; + constructor(_options: Dummy.Options); + generateStream(request: SeedStreaming.GenerateStreamRequest, requestOptions?: Dummy.RequestOptions): Promise>; + /** + * @param {SeedStreaming.Generateequest} request + * @param {Dummy.RequestOptions} requestOptions - Request-specific configuration. + * + * @example + * await client.dummy.generate({ + * numEvents: 5 + * }) + */ + generate(request: SeedStreaming.Generateequest, requestOptions?: Dummy.RequestOptions): Promise; +} diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/client/Client.js b/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/client/Client.js new file mode 100644 index 00000000000..c2fa4ea8bac --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/client/Client.js @@ -0,0 +1,155 @@ +"use strict"; +/** + * This file was auto-generated by Fern from our API Definition. + */ +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Dummy = void 0; +const core = __importStar(require("../../../../core")); +const serializers = __importStar(require("../../../../serialization/index")); +const url_join_1 = __importDefault(require("url-join")); +const errors = __importStar(require("../../../../errors/index")); +class Dummy { + constructor(_options) { + this._options = _options; + } + generateStream(request, requestOptions) { + return __awaiter(this, void 0, void 0, function* () { + const _response = yield core.fetcher({ + url: (0, url_join_1.default)(yield core.Supplier.get(this._options.environment), "generate-stream"), + method: "POST", + headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@fern/streaming", "X-Fern-SDK-Version": "0.0.1", "User-Agent": "@fern/streaming/0.0.1", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers), + contentType: "application/json", + requestType: "json", + body: Object.assign(Object.assign({}, serializers.GenerateStreamRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" })), { stream: true }), + responseType: "sse", + timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries, + abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal, + }); + if (_response.ok) { + return new core.Stream({ + stream: _response.body, + parse: (data) => __awaiter(this, void 0, void 0, function* () { + return serializers.StreamResponse.parseOrThrow(data, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + breadcrumbsPrefix: ["response"], + }); + }), + signal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal, + eventShape: { + type: "json", + messageTerminator: "\n", + }, + }); + } + if (_response.error.reason === "status-code") { + throw new errors.SeedStreamingError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + switch (_response.error.reason) { + case "non-json": + throw new errors.SeedStreamingError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.SeedStreamingTimeoutError("Timeout exceeded when calling POST /generate-stream."); + case "unknown": + throw new errors.SeedStreamingError({ + message: _response.error.errorMessage, + }); + } + }); + } + /** + * @param {SeedStreaming.Generateequest} request + * @param {Dummy.RequestOptions} requestOptions - Request-specific configuration. + * + * @example + * await client.dummy.generate({ + * numEvents: 5 + * }) + */ + generate(request, requestOptions) { + return __awaiter(this, void 0, void 0, function* () { + const _response = yield core.fetcher({ + url: (0, url_join_1.default)(yield core.Supplier.get(this._options.environment), "generate"), + method: "POST", + headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@fern/streaming", "X-Fern-SDK-Version": "0.0.1", "User-Agent": "@fern/streaming/0.0.1", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers), + contentType: "application/json", + requestType: "json", + body: Object.assign(Object.assign({}, serializers.Generateequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" })), { stream: false }), + timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries, + abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal, + }); + if (_response.ok) { + return serializers.StreamResponse.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + breadcrumbsPrefix: ["response"], + }); + } + if (_response.error.reason === "status-code") { + throw new errors.SeedStreamingError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + switch (_response.error.reason) { + case "non-json": + throw new errors.SeedStreamingError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.SeedStreamingTimeoutError("Timeout exceeded when calling POST /generate."); + case "unknown": + throw new errors.SeedStreamingError({ + message: _response.error.errorMessage, + }); + } + }); + } +} +exports.Dummy = Dummy; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/client/index.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/client/index.d.ts new file mode 100644 index 00000000000..415726b7fea --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/client/index.d.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/client/index.js b/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/client/index.js new file mode 100644 index 00000000000..6df4ebb9efc --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/client/index.js @@ -0,0 +1,17 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +__exportStar(require("./requests"), exports); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/client/requests/GenerateStreamRequest.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/client/requests/GenerateStreamRequest.d.ts new file mode 100644 index 00000000000..25cf26224f4 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/client/requests/GenerateStreamRequest.d.ts @@ -0,0 +1,6 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +export interface GenerateStreamRequest { + numEvents: number; +} diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/client/requests/GenerateStreamRequest.js b/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/client/requests/GenerateStreamRequest.js new file mode 100644 index 00000000000..33e43da19c8 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/client/requests/GenerateStreamRequest.js @@ -0,0 +1,5 @@ +"use strict"; +/** + * This file was auto-generated by Fern from our API Definition. + */ +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/client/requests/Generateequest.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/client/requests/Generateequest.d.ts new file mode 100644 index 00000000000..f3a4698e68f --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/client/requests/Generateequest.d.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +/** + * @example + * { + * numEvents: 5 + * } + */ +export interface Generateequest { + numEvents: number; +} diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/client/requests/Generateequest.js b/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/client/requests/Generateequest.js new file mode 100644 index 00000000000..33e43da19c8 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/client/requests/Generateequest.js @@ -0,0 +1,5 @@ +"use strict"; +/** + * This file was auto-generated by Fern from our API Definition. + */ +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/client/requests/index.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/client/requests/index.d.ts new file mode 100644 index 00000000000..1f08e1aa534 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/client/requests/index.d.ts @@ -0,0 +1,2 @@ +export { type GenerateStreamRequest } from "./GenerateStreamRequest"; +export { type Generateequest } from "./Generateequest"; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/client/requests/index.js b/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/client/requests/index.js new file mode 100644 index 00000000000..c8ad2e549bd --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/client/requests/index.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/index.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/index.d.ts new file mode 100644 index 00000000000..c9240f83b48 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/index.d.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./client"; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/index.js b/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/index.js new file mode 100644 index 00000000000..88ae7e19dce --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/index.js @@ -0,0 +1,18 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +__exportStar(require("./types"), exports); +__exportStar(require("./client"), exports); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/types/StreamResponse.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/types/StreamResponse.d.ts new file mode 100644 index 00000000000..f2455bb9eda --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/types/StreamResponse.d.ts @@ -0,0 +1,7 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +export interface StreamResponse { + id: string; + name?: string; +} diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/types/StreamResponse.js b/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/types/StreamResponse.js new file mode 100644 index 00000000000..33e43da19c8 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/types/StreamResponse.js @@ -0,0 +1,5 @@ +"use strict"; +/** + * This file was auto-generated by Fern from our API Definition. + */ +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/types/index.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/types/index.d.ts new file mode 100644 index 00000000000..7fff739f1bd --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/types/index.d.ts @@ -0,0 +1 @@ +export * from "./StreamResponse"; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/types/index.js b/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/types/index.js new file mode 100644 index 00000000000..386bf7a27fe --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/dummy/types/index.js @@ -0,0 +1,17 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +__exportStar(require("./StreamResponse"), exports); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/index.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/index.d.ts new file mode 100644 index 00000000000..77295c8c70d --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/index.d.ts @@ -0,0 +1,3 @@ +export * as dummy from "./dummy"; +export * from "./dummy/types"; +export * from "./dummy/client/requests"; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/index.js b/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/index.js new file mode 100644 index 00000000000..57694533bd4 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/api/resources/index.js @@ -0,0 +1,32 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.dummy = void 0; +exports.dummy = __importStar(require("./dummy")); +__exportStar(require("./dummy/types"), exports); +__exportStar(require("./dummy/client/requests"), exports); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/APIResponse.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/APIResponse.d.ts new file mode 100644 index 00000000000..43981835033 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/APIResponse.d.ts @@ -0,0 +1,10 @@ +export declare type APIResponse = SuccessfulResponse | FailedResponse; +export interface SuccessfulResponse { + ok: true; + body: T; + headers?: Record; +} +export interface FailedResponse { + ok: false; + error: T; +} diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/APIResponse.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/APIResponse.js new file mode 100644 index 00000000000..c8ad2e549bd --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/APIResponse.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/Fetcher.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/Fetcher.d.ts new file mode 100644 index 00000000000..0afcdfafbe1 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/Fetcher.d.ts @@ -0,0 +1,39 @@ +import { APIResponse } from "./APIResponse"; +export declare type FetchFunction = (args: Fetcher.Args) => Promise>; +export declare namespace Fetcher { + interface Args { + url: string; + method: string; + contentType?: string; + headers?: Record; + queryParameters?: Record; + body?: unknown; + timeoutMs?: number; + maxRetries?: number; + withCredentials?: boolean; + abortSignal?: AbortSignal; + requestType?: "json" | "file" | "bytes"; + responseType?: "json" | "blob" | "sse" | "streaming" | "text" | "arrayBuffer"; + duplex?: "half"; + } + type Error = FailedStatusCodeError | NonJsonError | TimeoutError | UnknownError; + interface FailedStatusCodeError { + reason: "status-code"; + statusCode: number; + body: unknown; + } + interface NonJsonError { + reason: "non-json"; + statusCode: number; + rawBody: string; + } + interface TimeoutError { + reason: "timeout"; + } + interface UnknownError { + reason: "unknown"; + errorMessage: string; + } +} +export declare function fetcherImpl(args: Fetcher.Args): Promise>; +export declare const fetcher: FetchFunction; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/Fetcher.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/Fetcher.js new file mode 100644 index 00000000000..c96816840ab --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/Fetcher.js @@ -0,0 +1,99 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.fetcher = exports.fetcherImpl = void 0; +const createRequestUrl_1 = require("./createRequestUrl"); +const getFetchFn_1 = require("./getFetchFn"); +const getRequestBody_1 = require("./getRequestBody"); +const getResponseBody_1 = require("./getResponseBody"); +const makeRequest_1 = require("./makeRequest"); +const requestWithRetries_1 = require("./requestWithRetries"); +function fetcherImpl(args) { + return __awaiter(this, void 0, void 0, function* () { + const headers = {}; + if (args.body !== undefined && args.contentType != null) { + headers["Content-Type"] = args.contentType; + } + if (args.headers != null) { + for (const [key, value] of Object.entries(args.headers)) { + if (value != null) { + headers[key] = value; + } + } + } + const url = (0, createRequestUrl_1.createRequestUrl)(args.url, args.queryParameters); + let requestBody = yield (0, getRequestBody_1.getRequestBody)({ + body: args.body, + type: args.requestType === "json" ? "json" : "other", + }); + const fetchFn = yield (0, getFetchFn_1.getFetchFn)(); + try { + const response = yield (0, requestWithRetries_1.requestWithRetries)(() => __awaiter(this, void 0, void 0, function* () { + return (0, makeRequest_1.makeRequest)(fetchFn, url, args.method, headers, requestBody, args.timeoutMs, args.abortSignal, args.withCredentials, args.duplex); + }), args.maxRetries); + let responseBody = yield (0, getResponseBody_1.getResponseBody)(response, args.responseType); + if (response.status >= 200 && response.status < 400) { + return { + ok: true, + body: responseBody, + headers: response.headers, + }; + } + else { + return { + ok: false, + error: { + reason: "status-code", + statusCode: response.status, + body: responseBody, + }, + }; + } + } + catch (error) { + if (args.abortSignal != null && args.abortSignal.aborted) { + return { + ok: false, + error: { + reason: "unknown", + errorMessage: "The user aborted a request", + }, + }; + } + else if (error instanceof Error && error.name === "AbortError") { + return { + ok: false, + error: { + reason: "timeout", + }, + }; + } + else if (error instanceof Error) { + return { + ok: false, + error: { + reason: "unknown", + errorMessage: error.message, + }, + }; + } + return { + ok: false, + error: { + reason: "unknown", + errorMessage: JSON.stringify(error), + }, + }; + } + }); +} +exports.fetcherImpl = fetcherImpl; +exports.fetcher = fetcherImpl; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/Supplier.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/Supplier.d.ts new file mode 100644 index 00000000000..432b4da2f06 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/Supplier.d.ts @@ -0,0 +1,4 @@ +export declare type Supplier = T | Promise | (() => T | Promise); +export declare const Supplier: { + get: (supplier: Supplier) => Promise; +}; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/Supplier.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/Supplier.js new file mode 100644 index 00000000000..c73ef538a49 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/Supplier.js @@ -0,0 +1,22 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Supplier = void 0; +exports.Supplier = { + get: (supplier) => __awaiter(void 0, void 0, void 0, function* () { + if (typeof supplier === "function") { + return supplier(); + } + else { + return supplier; + } + }), +}; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/createRequestUrl.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/createRequestUrl.d.ts new file mode 100644 index 00000000000..619344bc4d5 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/createRequestUrl.d.ts @@ -0,0 +1 @@ +export declare function createRequestUrl(baseUrl: string, queryParameters?: Record): string; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/createRequestUrl.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/createRequestUrl.js new file mode 100644 index 00000000000..6cee45097f6 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/createRequestUrl.js @@ -0,0 +1,13 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.createRequestUrl = void 0; +const qs_1 = __importDefault(require("qs")); +function createRequestUrl(baseUrl, queryParameters) { + return Object.keys(queryParameters !== null && queryParameters !== void 0 ? queryParameters : {}).length > 0 + ? `${baseUrl}?${qs_1.default.stringify(queryParameters, { arrayFormat: "repeat" })}` + : baseUrl; +} +exports.createRequestUrl = createRequestUrl; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/getFetchFn.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/getFetchFn.d.ts new file mode 100644 index 00000000000..000d5f1b90a --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/getFetchFn.d.ts @@ -0,0 +1,4 @@ +/** + * Returns a fetch function based on the runtime + */ +export declare function getFetchFn(): Promise; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/getFetchFn.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/getFetchFn.js new file mode 100644 index 00000000000..d90c4bb8b17 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/getFetchFn.js @@ -0,0 +1,59 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getFetchFn = void 0; +const runtime_1 = require("../runtime"); +/** + * Returns a fetch function based on the runtime + */ +function getFetchFn() { + return __awaiter(this, void 0, void 0, function* () { + // In Node.js 18+ environments, use native fetch + if (runtime_1.RUNTIME.type === "node" && runtime_1.RUNTIME.parsedVersion != null && runtime_1.RUNTIME.parsedVersion >= 18) { + return fetch; + } + // In Node.js 18 or lower environments, the SDK always uses`node-fetch`. + if (runtime_1.RUNTIME.type === "node") { + return (yield Promise.resolve().then(() => __importStar(require("node-fetch")))).default; + } + // Otherwise the SDK uses global fetch if available, + // and falls back to node-fetch. + if (typeof fetch == "function") { + return fetch; + } + // Defaults to node `node-fetch` if global fetch isn't available + return (yield Promise.resolve().then(() => __importStar(require("node-fetch")))).default; + }); +} +exports.getFetchFn = getFetchFn; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/getHeader.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/getHeader.d.ts new file mode 100644 index 00000000000..7d00d1319c2 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/getHeader.d.ts @@ -0,0 +1 @@ +export declare function getHeader(headers: Record, header: string): string | undefined; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/getHeader.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/getHeader.js new file mode 100644 index 00000000000..32728aa1a57 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/getHeader.js @@ -0,0 +1,12 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getHeader = void 0; +function getHeader(headers, header) { + for (const [headerKey, headerValue] of Object.entries(headers)) { + if (headerKey.toLowerCase() === header.toLowerCase()) { + return headerValue; + } + } + return undefined; +} +exports.getHeader = getHeader; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/getRequestBody.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/getRequestBody.d.ts new file mode 100644 index 00000000000..d9ebb588e3e --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/getRequestBody.d.ts @@ -0,0 +1,7 @@ +export declare namespace GetRequestBody { + interface Args { + body: unknown; + type: "json" | "file" | "bytes" | "other"; + } +} +export declare function getRequestBody({ body, type }: GetRequestBody.Args): Promise; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/getRequestBody.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/getRequestBody.js new file mode 100644 index 00000000000..01576950c8d --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/getRequestBody.js @@ -0,0 +1,23 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getRequestBody = void 0; +function getRequestBody({ body, type }) { + return __awaiter(this, void 0, void 0, function* () { + if (type.includes("json")) { + return JSON.stringify(body); + } + else { + return body; + } + }); +} +exports.getRequestBody = getRequestBody; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/getResponseBody.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/getResponseBody.d.ts new file mode 100644 index 00000000000..63c704b0594 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/getResponseBody.d.ts @@ -0,0 +1 @@ +export declare function getResponseBody(response: Response, responseType?: string): Promise; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/getResponseBody.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/getResponseBody.js new file mode 100644 index 00000000000..0d5c61a379b --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/getResponseBody.js @@ -0,0 +1,55 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getResponseBody = void 0; +const chooseStreamWrapper_1 = require("./stream-wrappers/chooseStreamWrapper"); +function getResponseBody(response, responseType) { + return __awaiter(this, void 0, void 0, function* () { + if (response.body != null && responseType === "blob") { + return yield response.blob(); + } + else if (response.body != null && responseType === "arrayBuffer") { + return yield response.arrayBuffer(); + } + else if (response.body != null && responseType === "sse") { + return response.body; + } + else if (response.body != null && responseType === "streaming") { + return (0, chooseStreamWrapper_1.chooseStreamWrapper)(response.body); + } + else if (response.body != null && responseType === "text") { + return yield response.text(); + } + else { + const text = yield response.text(); + if (text.length > 0) { + try { + let responseBody = JSON.parse(text); + return responseBody; + } + catch (err) { + return { + ok: false, + error: { + reason: "non-json", + statusCode: response.status, + rawBody: text, + }, + }; + } + } + else { + return undefined; + } + } + }); +} +exports.getResponseBody = getResponseBody; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/index.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/index.d.ts new file mode 100644 index 00000000000..2d658ca48f9 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/index.d.ts @@ -0,0 +1,5 @@ +export type { APIResponse } from "./APIResponse"; +export { fetcher } from "./Fetcher"; +export type { Fetcher, FetchFunction } from "./Fetcher"; +export { getHeader } from "./getHeader"; +export { Supplier } from "./Supplier"; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/index.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/index.js new file mode 100644 index 00000000000..9e7d5753c8a --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/index.js @@ -0,0 +1,9 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Supplier = exports.getHeader = exports.fetcher = void 0; +var Fetcher_1 = require("./Fetcher"); +Object.defineProperty(exports, "fetcher", { enumerable: true, get: function () { return Fetcher_1.fetcher; } }); +var getHeader_1 = require("./getHeader"); +Object.defineProperty(exports, "getHeader", { enumerable: true, get: function () { return getHeader_1.getHeader; } }); +var Supplier_1 = require("./Supplier"); +Object.defineProperty(exports, "Supplier", { enumerable: true, get: function () { return Supplier_1.Supplier; } }); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/makeRequest.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/makeRequest.d.ts new file mode 100644 index 00000000000..8b8eb4ba5bc --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/makeRequest.d.ts @@ -0,0 +1 @@ +export declare const makeRequest: (fetchFn: (url: string, init: RequestInit) => Promise, url: string, method: string, headers: Record, requestBody: BodyInit | undefined, timeoutMs?: number | undefined, abortSignal?: AbortSignal | undefined, withCredentials?: boolean | undefined, duplex?: "half" | undefined) => Promise; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/makeRequest.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/makeRequest.js new file mode 100644 index 00000000000..be608196e91 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/makeRequest.js @@ -0,0 +1,42 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.makeRequest = void 0; +const signals_1 = require("./signals"); +const makeRequest = (fetchFn, url, method, headers, requestBody, timeoutMs, abortSignal, withCredentials, duplex) => __awaiter(void 0, void 0, void 0, function* () { + const signals = []; + // Add timeout signal + let timeoutAbortId = undefined; + if (timeoutMs != null) { + const { signal, abortId } = (0, signals_1.getTimeoutSignal)(timeoutMs); + timeoutAbortId = abortId; + signals.push(signal); + } + // Add arbitrary signal + if (abortSignal != null) { + signals.push(abortSignal); + } + let newSignals = (0, signals_1.anySignal)(signals); + const response = yield fetchFn(url, { + method: method, + headers, + body: requestBody, + signal: newSignals, + credentials: withCredentials ? "include" : undefined, + // @ts-ignore + duplex, + }); + if (timeoutAbortId != null) { + clearTimeout(timeoutAbortId); + } + return response; +}); +exports.makeRequest = makeRequest; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/requestWithRetries.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/requestWithRetries.d.ts new file mode 100644 index 00000000000..e0683914d51 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/requestWithRetries.d.ts @@ -0,0 +1 @@ +export declare function requestWithRetries(requestFn: () => Promise, maxRetries?: number): Promise; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/requestWithRetries.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/requestWithRetries.js new file mode 100644 index 00000000000..dfc97f4e142 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/requestWithRetries.js @@ -0,0 +1,41 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.requestWithRetries = void 0; +const INITIAL_RETRY_DELAY = 1000; // in milliseconds +const MAX_RETRY_DELAY = 60000; // in milliseconds +const DEFAULT_MAX_RETRIES = 2; +const JITTER_FACTOR = 0.2; // 20% random jitter +function addJitter(delay) { + // Generate a random value between -JITTER_FACTOR and +JITTER_FACTOR + const jitterMultiplier = 1 + (Math.random() * 2 - 1) * JITTER_FACTOR; + return delay * jitterMultiplier; +} +function requestWithRetries(requestFn, maxRetries = DEFAULT_MAX_RETRIES) { + return __awaiter(this, void 0, void 0, function* () { + let response = yield requestFn(); + for (let i = 0; i < maxRetries; ++i) { + if ([408, 409, 429].includes(response.status) || response.status >= 500) { + // Calculate base delay using exponential backoff (in milliseconds) + const baseDelay = Math.min(INITIAL_RETRY_DELAY * Math.pow(2, i), MAX_RETRY_DELAY); + // Add jitter to the delay + const delayWithJitter = addJitter(baseDelay); + yield new Promise((resolve) => setTimeout(resolve, delayWithJitter)); + response = yield requestFn(); + } + else { + break; + } + } + return response; + }); +} +exports.requestWithRetries = requestWithRetries; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/signals.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/signals.d.ts new file mode 100644 index 00000000000..4a44ff1213a --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/signals.d.ts @@ -0,0 +1,12 @@ +/// +export declare function getTimeoutSignal(timeoutMs: number): { + signal: AbortSignal; + abortId: NodeJS.Timeout; +}; +/** + * Returns an abort signal that is getting aborted when + * at least one of the specified abort signals is aborted. + * + * Requires at least node.js 18. + */ +export declare function anySignal(...args: AbortSignal[] | [AbortSignal[]]): AbortSignal; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/signals.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/signals.js new file mode 100644 index 00000000000..bc73e73e8ee --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/signals.js @@ -0,0 +1,37 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.anySignal = exports.getTimeoutSignal = void 0; +const TIMEOUT = "timeout"; +function getTimeoutSignal(timeoutMs) { + const controller = new AbortController(); + const abortId = setTimeout(() => controller.abort(TIMEOUT), timeoutMs); + return { signal: controller.signal, abortId }; +} +exports.getTimeoutSignal = getTimeoutSignal; +/** + * Returns an abort signal that is getting aborted when + * at least one of the specified abort signals is aborted. + * + * Requires at least node.js 18. + */ +function anySignal(...args) { + // Allowing signals to be passed either as array + // of signals or as multiple arguments. + const signals = (args.length === 1 && Array.isArray(args[0]) ? args[0] : args); + const controller = new AbortController(); + for (const signal of signals) { + if (signal.aborted) { + // Exiting early if one of the signals + // is already aborted. + controller.abort(signal === null || signal === void 0 ? void 0 : signal.reason); + break; + } + // Listening for signals and removing the listeners + // when at least one symbol is aborted. + signal.addEventListener("abort", () => controller.abort(signal === null || signal === void 0 ? void 0 : signal.reason), { + signal: controller.signal, + }); + } + return controller.signal; +} +exports.anySignal = anySignal; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.d.ts new file mode 100644 index 00000000000..0554b6a4ccb --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.d.ts @@ -0,0 +1,30 @@ +import type { Writable } from "readable-stream"; +import { EventCallback, StreamWrapper } from "./chooseStreamWrapper"; +export declare class Node18UniversalStreamWrapper implements StreamWrapper | Writable | WritableStream, ReadFormat> { + private readableStream; + private reader; + private events; + private paused; + private resumeCallback; + private encoding; + constructor(readableStream: ReadableStream); + on(event: string, callback: EventCallback): void; + off(event: string, callback: EventCallback): void; + pipe(dest: Node18UniversalStreamWrapper | Writable | WritableStream): Node18UniversalStreamWrapper | Writable | WritableStream; + pipeTo(dest: Node18UniversalStreamWrapper | Writable | WritableStream): Node18UniversalStreamWrapper | Writable | WritableStream; + unpipe(dest: Node18UniversalStreamWrapper | Writable | WritableStream): void; + destroy(error?: Error): void; + pause(): void; + resume(): void; + get isPaused(): boolean; + read(): Promise; + setEncoding(encoding: string): void; + text(): Promise; + json(): Promise; + private _write; + private _end; + private _error; + private _emit; + private _startReading; + [Symbol.asyncIterator](): AsyncIterableIterator; +} diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.js new file mode 100644 index 00000000000..4f6aeb05ca3 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.js @@ -0,0 +1,247 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Node18UniversalStreamWrapper = void 0; +class Node18UniversalStreamWrapper { + constructor(readableStream) { + this.readableStream = readableStream; + this.reader = this.readableStream.getReader(); + this.events = { + data: [], + end: [], + error: [], + readable: [], + close: [], + pause: [], + resume: [], + }; + this.paused = false; + this.resumeCallback = null; + this.encoding = null; + } + on(event, callback) { + var _a; + (_a = this.events[event]) === null || _a === void 0 ? void 0 : _a.push(callback); + } + off(event, callback) { + var _a; + this.events[event] = (_a = this.events[event]) === null || _a === void 0 ? void 0 : _a.filter((cb) => cb !== callback); + } + pipe(dest) { + this.on("data", (chunk) => __awaiter(this, void 0, void 0, function* () { + if (dest instanceof Node18UniversalStreamWrapper) { + dest._write(chunk); + } + else if (dest instanceof WritableStream) { + const writer = dest.getWriter(); + writer.write(chunk).then(() => writer.releaseLock()); + } + else { + dest.write(chunk); + } + })); + this.on("end", () => __awaiter(this, void 0, void 0, function* () { + if (dest instanceof Node18UniversalStreamWrapper) { + dest._end(); + } + else if (dest instanceof WritableStream) { + const writer = dest.getWriter(); + writer.close(); + } + else { + dest.end(); + } + })); + this.on("error", (error) => __awaiter(this, void 0, void 0, function* () { + if (dest instanceof Node18UniversalStreamWrapper) { + dest._error(error); + } + else if (dest instanceof WritableStream) { + const writer = dest.getWriter(); + writer.abort(error); + } + else { + dest.destroy(error); + } + })); + this._startReading(); + return dest; + } + pipeTo(dest) { + return this.pipe(dest); + } + unpipe(dest) { + this.off("data", (chunk) => __awaiter(this, void 0, void 0, function* () { + if (dest instanceof Node18UniversalStreamWrapper) { + dest._write(chunk); + } + else if (dest instanceof WritableStream) { + const writer = dest.getWriter(); + writer.write(chunk).then(() => writer.releaseLock()); + } + else { + dest.write(chunk); + } + })); + this.off("end", () => __awaiter(this, void 0, void 0, function* () { + if (dest instanceof Node18UniversalStreamWrapper) { + dest._end(); + } + else if (dest instanceof WritableStream) { + const writer = dest.getWriter(); + writer.close(); + } + else { + dest.end(); + } + })); + this.off("error", (error) => __awaiter(this, void 0, void 0, function* () { + if (dest instanceof Node18UniversalStreamWrapper) { + dest._error(error); + } + else if (dest instanceof WritableStream) { + const writer = dest.getWriter(); + writer.abort(error); + } + else { + dest.destroy(error); + } + })); + } + destroy(error) { + this.reader + .cancel(error) + .then(() => { + this._emit("close"); + }) + .catch((err) => { + this._emit("error", err); + }); + } + pause() { + this.paused = true; + this._emit("pause"); + } + resume() { + if (this.paused) { + this.paused = false; + this._emit("resume"); + if (this.resumeCallback) { + this.resumeCallback(); + this.resumeCallback = null; + } + } + } + get isPaused() { + return this.paused; + } + read() { + return __awaiter(this, void 0, void 0, function* () { + if (this.paused) { + yield new Promise((resolve) => { + this.resumeCallback = resolve; + }); + } + const { done, value } = yield this.reader.read(); + if (done) { + return undefined; + } + return value; + }); + } + setEncoding(encoding) { + this.encoding = encoding; + } + text() { + return __awaiter(this, void 0, void 0, function* () { + const chunks = []; + while (true) { + const { done, value } = yield this.reader.read(); + if (done) { + break; + } + if (value) { + chunks.push(value); + } + } + const decoder = new TextDecoder(this.encoding || "utf-8"); + return decoder.decode(yield new Blob(chunks).arrayBuffer()); + }); + } + json() { + return __awaiter(this, void 0, void 0, function* () { + const text = yield this.text(); + return JSON.parse(text); + }); + } + _write(chunk) { + this._emit("data", chunk); + } + _end() { + this._emit("end"); + } + _error(error) { + this._emit("error", error); + } + _emit(event, data) { + if (this.events[event]) { + for (const callback of this.events[event] || []) { + callback(data); + } + } + } + _startReading() { + return __awaiter(this, void 0, void 0, function* () { + try { + this._emit("readable"); + while (true) { + if (this.paused) { + yield new Promise((resolve) => { + this.resumeCallback = resolve; + }); + } + const { done, value } = yield this.reader.read(); + if (done) { + this._emit("end"); + this._emit("close"); + break; + } + if (value) { + this._emit("data", value); + } + } + } + catch (error) { + this._emit("error", error); + } + }); + } + [Symbol.asyncIterator]() { + return { + next: () => __awaiter(this, void 0, void 0, function* () { + if (this.paused) { + yield new Promise((resolve) => { + this.resumeCallback = resolve; + }); + } + const { done, value } = yield this.reader.read(); + if (done) { + return { done: true, value: undefined }; + } + return { done: false, value }; + }), + [Symbol.asyncIterator]() { + return this; + }, + }; + } +} +exports.Node18UniversalStreamWrapper = Node18UniversalStreamWrapper; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/stream-wrappers/NodePre18StreamWrapper.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/stream-wrappers/NodePre18StreamWrapper.d.ts new file mode 100644 index 00000000000..fb9858be9a7 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/stream-wrappers/NodePre18StreamWrapper.d.ts @@ -0,0 +1,22 @@ +/// +import type { Readable, Writable } from "readable-stream"; +import { EventCallback, StreamWrapper } from "./chooseStreamWrapper"; +export declare class NodePre18StreamWrapper implements StreamWrapper { + private readableStream; + private encoding; + constructor(readableStream: Readable); + on(event: string, callback: EventCallback): void; + off(event: string, callback: EventCallback): void; + pipe(dest: Writable): Writable; + pipeTo(dest: Writable): Writable; + unpipe(dest?: Writable): void; + destroy(error?: Error): void; + pause(): void; + resume(): void; + get isPaused(): boolean; + read(): Promise; + setEncoding(encoding?: string): void; + text(): Promise; + json(): Promise; + [Symbol.asyncIterator](): AsyncIterableIterator; +} diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/stream-wrappers/NodePre18StreamWrapper.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/stream-wrappers/NodePre18StreamWrapper.js new file mode 100644 index 00000000000..d2ee999cbc2 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/stream-wrappers/NodePre18StreamWrapper.js @@ -0,0 +1,124 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __asyncValues = (this && this.__asyncValues) || function (o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.NodePre18StreamWrapper = void 0; +class NodePre18StreamWrapper { + constructor(readableStream) { + this.readableStream = readableStream; + } + on(event, callback) { + this.readableStream.on(event, callback); + } + off(event, callback) { + this.readableStream.off(event, callback); + } + pipe(dest) { + this.readableStream.pipe(dest); + return dest; + } + pipeTo(dest) { + return this.pipe(dest); + } + unpipe(dest) { + if (dest) { + this.readableStream.unpipe(dest); + } + else { + this.readableStream.unpipe(); + } + } + destroy(error) { + this.readableStream.destroy(error); + } + pause() { + this.readableStream.pause(); + } + resume() { + this.readableStream.resume(); + } + get isPaused() { + return this.readableStream.isPaused(); + } + read() { + return __awaiter(this, void 0, void 0, function* () { + return new Promise((resolve, reject) => { + const chunk = this.readableStream.read(); + if (chunk) { + resolve(chunk); + } + else { + this.readableStream.once("readable", () => { + const chunk = this.readableStream.read(); + resolve(chunk); + }); + this.readableStream.once("error", reject); + } + }); + }); + } + setEncoding(encoding) { + this.readableStream.setEncoding(encoding); + this.encoding = encoding; + } + text() { + var e_1, _a; + return __awaiter(this, void 0, void 0, function* () { + const chunks = []; + const encoder = new TextEncoder(); + this.readableStream.setEncoding((this.encoding || "utf-8")); + try { + for (var _b = __asyncValues(this.readableStream), _c; _c = yield _b.next(), !_c.done;) { + const chunk = _c.value; + chunks.push(encoder.encode(chunk)); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) yield _a.call(_b); + } + finally { if (e_1) throw e_1.error; } + } + const decoder = new TextDecoder(this.encoding || "utf-8"); + return decoder.decode(Buffer.concat(chunks)); + }); + } + json() { + return __awaiter(this, void 0, void 0, function* () { + const text = yield this.text(); + return JSON.parse(text); + }); + } + [Symbol.asyncIterator]() { + const readableStream = this.readableStream; + const iterator = readableStream[Symbol.asyncIterator](); + // Create and return an async iterator that yields buffers + return { + next() { + return __awaiter(this, void 0, void 0, function* () { + const { value, done } = yield iterator.next(); + return { value: value, done }; + }); + }, + [Symbol.asyncIterator]() { + return this; + }, + }; + } +} +exports.NodePre18StreamWrapper = NodePre18StreamWrapper; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/stream-wrappers/UndiciStreamWrapper.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/stream-wrappers/UndiciStreamWrapper.d.ts new file mode 100644 index 00000000000..434b355783e --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/stream-wrappers/UndiciStreamWrapper.d.ts @@ -0,0 +1,31 @@ +import { StreamWrapper } from "./chooseStreamWrapper"; +declare type EventCallback = (data?: any) => void; +export declare class UndiciStreamWrapper implements StreamWrapper | WritableStream, ReadFormat> { + private readableStream; + private reader; + private events; + private paused; + private resumeCallback; + private encoding; + constructor(readableStream: ReadableStream); + on(event: string, callback: EventCallback): void; + off(event: string, callback: EventCallback): void; + pipe(dest: UndiciStreamWrapper | WritableStream): UndiciStreamWrapper | WritableStream; + pipeTo(dest: UndiciStreamWrapper | WritableStream): UndiciStreamWrapper | WritableStream; + unpipe(dest: UndiciStreamWrapper | WritableStream): void; + destroy(error?: Error): void; + pause(): void; + resume(): void; + get isPaused(): boolean; + read(): Promise; + setEncoding(encoding: string): void; + text(): Promise; + json(): Promise; + private _write; + private _end; + private _error; + private _emit; + private _startReading; + [Symbol.asyncIterator](): AsyncIterableIterator; +} +export {}; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/stream-wrappers/UndiciStreamWrapper.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/stream-wrappers/UndiciStreamWrapper.js new file mode 100644 index 00000000000..1d90f01f8ca --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/stream-wrappers/UndiciStreamWrapper.js @@ -0,0 +1,229 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.UndiciStreamWrapper = void 0; +class UndiciStreamWrapper { + constructor(readableStream) { + this.readableStream = readableStream; + this.reader = this.readableStream.getReader(); + this.events = { + data: [], + end: [], + error: [], + readable: [], + close: [], + pause: [], + resume: [], + }; + this.paused = false; + this.resumeCallback = null; + this.encoding = null; + } + on(event, callback) { + var _a; + (_a = this.events[event]) === null || _a === void 0 ? void 0 : _a.push(callback); + } + off(event, callback) { + var _a; + this.events[event] = (_a = this.events[event]) === null || _a === void 0 ? void 0 : _a.filter((cb) => cb !== callback); + } + pipe(dest) { + this.on("data", (chunk) => { + if (dest instanceof UndiciStreamWrapper) { + dest._write(chunk); + } + else { + const writer = dest.getWriter(); + writer.write(chunk).then(() => writer.releaseLock()); + } + }); + this.on("end", () => { + if (dest instanceof UndiciStreamWrapper) { + dest._end(); + } + else { + const writer = dest.getWriter(); + writer.close(); + } + }); + this.on("error", (error) => { + if (dest instanceof UndiciStreamWrapper) { + dest._error(error); + } + else { + const writer = dest.getWriter(); + writer.abort(error); + } + }); + this._startReading(); + return dest; + } + pipeTo(dest) { + return this.pipe(dest); + } + unpipe(dest) { + this.off("data", (chunk) => { + if (dest instanceof UndiciStreamWrapper) { + dest._write(chunk); + } + else { + const writer = dest.getWriter(); + writer.write(chunk).then(() => writer.releaseLock()); + } + }); + this.off("end", () => { + if (dest instanceof UndiciStreamWrapper) { + dest._end(); + } + else { + const writer = dest.getWriter(); + writer.close(); + } + }); + this.off("error", (error) => { + if (dest instanceof UndiciStreamWrapper) { + dest._error(error); + } + else { + const writer = dest.getWriter(); + writer.abort(error); + } + }); + } + destroy(error) { + this.reader + .cancel(error) + .then(() => { + this._emit("close"); + }) + .catch((err) => { + this._emit("error", err); + }); + } + pause() { + this.paused = true; + this._emit("pause"); + } + resume() { + if (this.paused) { + this.paused = false; + this._emit("resume"); + if (this.resumeCallback) { + this.resumeCallback(); + this.resumeCallback = null; + } + } + } + get isPaused() { + return this.paused; + } + read() { + return __awaiter(this, void 0, void 0, function* () { + if (this.paused) { + yield new Promise((resolve) => { + this.resumeCallback = resolve; + }); + } + const { done, value } = yield this.reader.read(); + if (done) { + return undefined; + } + return value; + }); + } + setEncoding(encoding) { + this.encoding = encoding; + } + text() { + return __awaiter(this, void 0, void 0, function* () { + const chunks = []; + while (true) { + const { done, value } = yield this.reader.read(); + if (done) { + break; + } + if (value) { + chunks.push(value); + } + } + const decoder = new TextDecoder(this.encoding || "utf-8"); + return decoder.decode(yield new Blob(chunks).arrayBuffer()); + }); + } + json() { + return __awaiter(this, void 0, void 0, function* () { + const text = yield this.text(); + return JSON.parse(text); + }); + } + _write(chunk) { + this._emit("data", chunk); + } + _end() { + this._emit("end"); + } + _error(error) { + this._emit("error", error); + } + _emit(event, data) { + if (this.events[event]) { + for (const callback of this.events[event] || []) { + callback(data); + } + } + } + _startReading() { + return __awaiter(this, void 0, void 0, function* () { + try { + this._emit("readable"); + while (true) { + if (this.paused) { + yield new Promise((resolve) => { + this.resumeCallback = resolve; + }); + } + const { done, value } = yield this.reader.read(); + if (done) { + this._emit("end"); + this._emit("close"); + break; + } + if (value) { + this._emit("data", value); + } + } + } + catch (error) { + this._emit("error", error); + } + }); + } + [Symbol.asyncIterator]() { + return { + next: () => __awaiter(this, void 0, void 0, function* () { + if (this.paused) { + yield new Promise((resolve) => { + this.resumeCallback = resolve; + }); + } + const { done, value } = yield this.reader.read(); + if (done) { + return { done: true, value: undefined }; + } + return { done: false, value }; + }), + [Symbol.asyncIterator]() { + return this; + }, + }; + } +} +exports.UndiciStreamWrapper = UndiciStreamWrapper; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/stream-wrappers/chooseStreamWrapper.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/stream-wrappers/chooseStreamWrapper.d.ts new file mode 100644 index 00000000000..939c617d706 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/stream-wrappers/chooseStreamWrapper.d.ts @@ -0,0 +1,18 @@ +export declare type EventCallback = (data?: any) => void; +export interface StreamWrapper { + setEncoding(encoding?: string): void; + on(event: string, callback: EventCallback): void; + off(event: string, callback: EventCallback): void; + pipe(dest: WritableStream): WritableStream; + pipeTo(dest: WritableStream): WritableStream; + unpipe(dest?: WritableStream): void; + destroy(error?: Error): void; + pause(): void; + resume(): void; + get isPaused(): boolean; + read(): Promise; + text(): Promise; + json(): Promise; + [Symbol.asyncIterator](): AsyncIterableIterator; +} +export declare function chooseStreamWrapper(responseBody: any): Promise>>; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/stream-wrappers/chooseStreamWrapper.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/stream-wrappers/chooseStreamWrapper.js new file mode 100644 index 00000000000..d13c468c0a8 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/fetcher/stream-wrappers/chooseStreamWrapper.js @@ -0,0 +1,50 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.chooseStreamWrapper = void 0; +const runtime_1 = require("../../runtime"); +function chooseStreamWrapper(responseBody) { + return __awaiter(this, void 0, void 0, function* () { + if (runtime_1.RUNTIME.type === "node" && runtime_1.RUNTIME.parsedVersion != null && runtime_1.RUNTIME.parsedVersion >= 18) { + return new (yield Promise.resolve().then(() => __importStar(require("./Node18UniversalStreamWrapper")))).Node18UniversalStreamWrapper(responseBody); + } + else if (runtime_1.RUNTIME.type !== "node" && typeof fetch === "function") { + return new (yield Promise.resolve().then(() => __importStar(require("./UndiciStreamWrapper")))).UndiciStreamWrapper(responseBody); + } + else { + return new (yield Promise.resolve().then(() => __importStar(require("./NodePre18StreamWrapper")))).NodePre18StreamWrapper(responseBody); + } + }); +} +exports.chooseStreamWrapper = chooseStreamWrapper; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/index.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/index.d.ts new file mode 100644 index 00000000000..34cdfa58863 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/index.d.ts @@ -0,0 +1,4 @@ +export * from "./fetcher"; +export * from "./streaming-fetcher"; +export * from "./runtime"; +export * as serialization from "./schemas"; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/index.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/index.js new file mode 100644 index 00000000000..eba4353ca9c --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/index.js @@ -0,0 +1,33 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.serialization = void 0; +__exportStar(require("./fetcher"), exports); +__exportStar(require("./streaming-fetcher"), exports); +__exportStar(require("./runtime"), exports); +exports.serialization = __importStar(require("./schemas")); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/runtime/index.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/runtime/index.d.ts new file mode 100644 index 00000000000..5c76dbb133f --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/runtime/index.d.ts @@ -0,0 +1 @@ +export { RUNTIME } from "./runtime"; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/runtime/index.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/runtime/index.js new file mode 100644 index 00000000000..918280da99c --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/runtime/index.js @@ -0,0 +1,5 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.RUNTIME = void 0; +var runtime_1 = require("./runtime"); +Object.defineProperty(exports, "RUNTIME", { enumerable: true, get: function () { return runtime_1.RUNTIME; } }); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/runtime/runtime.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/runtime/runtime.d.ts new file mode 100644 index 00000000000..8b586355a62 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/runtime/runtime.d.ts @@ -0,0 +1,9 @@ +/** + * A constant that indicates which environment and version the SDK is running in. + */ +export declare const RUNTIME: Runtime; +export interface Runtime { + type: "browser" | "web-worker" | "deno" | "bun" | "node" | "react-native" | "unknown" | "workerd"; + version?: string; + parsedVersion?: number; +} diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/runtime/runtime.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/runtime/runtime.js new file mode 100644 index 00000000000..bcd02ab031f --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/runtime/runtime.js @@ -0,0 +1,93 @@ +"use strict"; +var _a, _b, _c, _d, _e; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.RUNTIME = void 0; +/** + * A constant that indicates whether the environment the code is running is a Web Browser. + */ +const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined"; +/** + * A constant that indicates whether the environment the code is running is a Web Worker. + */ +const isWebWorker = typeof self === "object" && + // @ts-ignore + typeof (self === null || self === void 0 ? void 0 : self.importScripts) === "function" && + (((_a = self.constructor) === null || _a === void 0 ? void 0 : _a.name) === "DedicatedWorkerGlobalScope" || + ((_b = self.constructor) === null || _b === void 0 ? void 0 : _b.name) === "ServiceWorkerGlobalScope" || + ((_c = self.constructor) === null || _c === void 0 ? void 0 : _c.name) === "SharedWorkerGlobalScope"); +/** + * A constant that indicates whether the environment the code is running is Deno. + */ +const isDeno = typeof Deno !== "undefined" && typeof Deno.version !== "undefined" && typeof Deno.version.deno !== "undefined"; +/** + * A constant that indicates whether the environment the code is running is Bun.sh. + */ +const isBun = typeof Bun !== "undefined" && typeof Bun.version !== "undefined"; +/** + * A constant that indicates whether the environment the code is running is Node.JS. + */ +const isNode = typeof process !== "undefined" && + Boolean(process.version) && + Boolean((_d = process.versions) === null || _d === void 0 ? void 0 : _d.node) && + // Deno spoofs process.versions.node, see https://deno.land/std@0.177.0/node/process.ts?s=versions + !isDeno && + !isBun; +/** + * A constant that indicates whether the environment the code is running is in React-Native. + * https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Core/setUpNavigator.js + */ +const isReactNative = typeof navigator !== "undefined" && (navigator === null || navigator === void 0 ? void 0 : navigator.product) === "ReactNative"; +/** + * A constant that indicates whether the environment the code is running is Cloudflare. + * https://developers.cloudflare.com/workers/runtime-apis/web-standards/#navigatoruseragent + */ +const isCloudflare = typeof globalThis !== "undefined" && ((_e = globalThis === null || globalThis === void 0 ? void 0 : globalThis.navigator) === null || _e === void 0 ? void 0 : _e.userAgent) === "Cloudflare-Workers"; +/** + * A constant that indicates which environment and version the SDK is running in. + */ +exports.RUNTIME = evaluateRuntime(); +function evaluateRuntime() { + if (isBrowser) { + return { + type: "browser", + version: window.navigator.userAgent, + }; + } + if (isCloudflare) { + return { + type: "workerd", + }; + } + if (isWebWorker) { + return { + type: "web-worker", + }; + } + if (isDeno) { + return { + type: "deno", + version: Deno.version.deno, + }; + } + if (isBun) { + return { + type: "bun", + version: Bun.version, + }; + } + if (isNode) { + return { + type: "node", + version: process.versions.node, + parsedVersion: Number(process.versions.node.split(".")[0]), + }; + } + if (isReactNative) { + return { + type: "react-native", + }; + } + return { + type: "unknown", + }; +} diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/Schema.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/Schema.d.ts new file mode 100644 index 00000000000..e58726b3fc5 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/Schema.d.ts @@ -0,0 +1,85 @@ +import { SchemaUtils } from "./builders"; +export declare type Schema = BaseSchema & SchemaUtils; +export declare type inferRaw = S extends Schema ? Raw : never; +export declare type inferParsed = S extends Schema ? Parsed : never; +export interface BaseSchema { + parse: (raw: unknown, opts?: SchemaOptions) => MaybeValid; + json: (parsed: unknown, opts?: SchemaOptions) => MaybeValid; + getType: () => SchemaType | SchemaType; +} +export declare const SchemaType: { + readonly BIGINT: "bigint"; + readonly DATE: "date"; + readonly ENUM: "enum"; + readonly LIST: "list"; + readonly STRING_LITERAL: "stringLiteral"; + readonly BOOLEAN_LITERAL: "booleanLiteral"; + readonly OBJECT: "object"; + readonly ANY: "any"; + readonly BOOLEAN: "boolean"; + readonly NUMBER: "number"; + readonly STRING: "string"; + readonly UNKNOWN: "unknown"; + readonly RECORD: "record"; + readonly SET: "set"; + readonly UNION: "union"; + readonly UNDISCRIMINATED_UNION: "undiscriminatedUnion"; + readonly OPTIONAL: "optional"; +}; +export declare type SchemaType = typeof SchemaType[keyof typeof SchemaType]; +export declare type MaybeValid = Valid | Invalid; +export interface Valid { + ok: true; + value: T; +} +export interface Invalid { + ok: false; + errors: ValidationError[]; +} +export interface ValidationError { + path: string[]; + message: string; +} +export interface SchemaOptions { + /** + * how to handle unrecognized keys in objects + * + * @default "fail" + */ + unrecognizedObjectKeys?: "fail" | "passthrough" | "strip"; + /** + * whether to fail when an unrecognized discriminant value is + * encountered in a union + * + * @default false + */ + allowUnrecognizedUnionMembers?: boolean; + /** + * whether to fail when an unrecognized enum value is encountered + * + * @default false + */ + allowUnrecognizedEnumValues?: boolean; + /** + * whether to allow data that doesn't conform to the schema. + * invalid data is passed through without transformation. + * + * when this is enabled, .parse() and .json() will always + * return `ok: true`. `.parseOrThrow()` and `.jsonOrThrow()` + * will never fail. + * + * @default false + */ + skipValidation?: boolean; + /** + * each validation failure contains a "path" property, which is + * the breadcrumbs to the offending node in the JSON. you can supply + * a prefix that is prepended to all the errors' paths. this can be + * helpful for zurg's internal debug logging. + */ + breadcrumbsPrefix?: string[]; + /** + * whether to send 'null' for optional properties explicitly set to 'undefined'. + */ + omitUndefined?: boolean; +} diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/Schema.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/Schema.js new file mode 100644 index 00000000000..7a8403ec7a5 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/Schema.js @@ -0,0 +1,22 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SchemaType = void 0; +exports.SchemaType = { + BIGINT: "bigint", + DATE: "date", + ENUM: "enum", + LIST: "list", + STRING_LITERAL: "stringLiteral", + BOOLEAN_LITERAL: "booleanLiteral", + OBJECT: "object", + ANY: "any", + BOOLEAN: "boolean", + NUMBER: "number", + STRING: "string", + UNKNOWN: "unknown", + RECORD: "record", + SET: "set", + UNION: "union", + UNDISCRIMINATED_UNION: "undiscriminatedUnion", + OPTIONAL: "optional", +}; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/bigint/bigint.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/bigint/bigint.d.ts new file mode 100644 index 00000000000..89561b41fb0 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/bigint/bigint.d.ts @@ -0,0 +1,2 @@ +import { Schema } from "../../Schema"; +export declare function bigint(): Schema; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/bigint/bigint.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/bigint/bigint.js new file mode 100644 index 00000000000..bb9aac11a73 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/bigint/bigint.js @@ -0,0 +1,50 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.bigint = void 0; +const Schema_1 = require("../../Schema"); +const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType"); +const maybeSkipValidation_1 = require("../../utils/maybeSkipValidation"); +const schema_utils_1 = require("../schema-utils"); +function bigint() { + const baseSchema = { + parse: (raw, { breadcrumbsPrefix = [] } = {}) => { + if (typeof raw !== "string") { + return { + ok: false, + errors: [ + { + path: breadcrumbsPrefix, + message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(raw, "string"), + }, + ], + }; + } + return { + ok: true, + value: BigInt(raw), + }; + }, + json: (bigint, { breadcrumbsPrefix = [] } = {}) => { + if (typeof bigint === "bigint") { + return { + ok: true, + value: bigint.toString(), + }; + } + else { + return { + ok: false, + errors: [ + { + path: breadcrumbsPrefix, + message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(bigint, "bigint"), + }, + ], + }; + } + }, + getType: () => Schema_1.SchemaType.BIGINT, + }; + return Object.assign(Object.assign({}, (0, maybeSkipValidation_1.maybeSkipValidation)(baseSchema)), (0, schema_utils_1.getSchemaUtils)(baseSchema)); +} +exports.bigint = bigint; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/bigint/index.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/bigint/index.d.ts new file mode 100644 index 00000000000..e5843043fcb --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/bigint/index.d.ts @@ -0,0 +1 @@ +export { bigint } from "./bigint"; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/bigint/index.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/bigint/index.js new file mode 100644 index 00000000000..705e4ba2038 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/bigint/index.js @@ -0,0 +1,5 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.bigint = void 0; +var bigint_1 = require("./bigint"); +Object.defineProperty(exports, "bigint", { enumerable: true, get: function () { return bigint_1.bigint; } }); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/date/date.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/date/date.d.ts new file mode 100644 index 00000000000..26359d1c519 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/date/date.d.ts @@ -0,0 +1,2 @@ +import { Schema } from "../../Schema"; +export declare function date(): Schema; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/date/date.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/date/date.js new file mode 100644 index 00000000000..b0995da0e11 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/date/date.js @@ -0,0 +1,63 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.date = void 0; +const Schema_1 = require("../../Schema"); +const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType"); +const maybeSkipValidation_1 = require("../../utils/maybeSkipValidation"); +const schema_utils_1 = require("../schema-utils"); +// https://stackoverflow.com/questions/12756159/regex-and-iso8601-formatted-datetime +const ISO_8601_REGEX = /^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/; +function date() { + const baseSchema = { + parse: (raw, { breadcrumbsPrefix = [] } = {}) => { + if (typeof raw !== "string") { + return { + ok: false, + errors: [ + { + path: breadcrumbsPrefix, + message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(raw, "string"), + }, + ], + }; + } + if (!ISO_8601_REGEX.test(raw)) { + return { + ok: false, + errors: [ + { + path: breadcrumbsPrefix, + message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(raw, "ISO 8601 date string"), + }, + ], + }; + } + return { + ok: true, + value: new Date(raw), + }; + }, + json: (date, { breadcrumbsPrefix = [] } = {}) => { + if (date instanceof Date) { + return { + ok: true, + value: date.toISOString(), + }; + } + else { + return { + ok: false, + errors: [ + { + path: breadcrumbsPrefix, + message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(date, "Date object"), + }, + ], + }; + } + }, + getType: () => Schema_1.SchemaType.DATE, + }; + return Object.assign(Object.assign({}, (0, maybeSkipValidation_1.maybeSkipValidation)(baseSchema)), (0, schema_utils_1.getSchemaUtils)(baseSchema)); +} +exports.date = date; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/date/index.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/date/index.d.ts new file mode 100644 index 00000000000..187b29040f6 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/date/index.d.ts @@ -0,0 +1 @@ +export { date } from "./date"; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/date/index.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/date/index.js new file mode 100644 index 00000000000..2c6cc4e57c0 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/date/index.js @@ -0,0 +1,5 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.date = void 0; +var date_1 = require("./date"); +Object.defineProperty(exports, "date", { enumerable: true, get: function () { return date_1.date; } }); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/enum/enum.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/enum/enum.d.ts new file mode 100644 index 00000000000..b5d6f40a3d0 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/enum/enum.d.ts @@ -0,0 +1,2 @@ +import { Schema } from "../../Schema"; +export declare function enum_(values: E): Schema; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/enum/enum.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/enum/enum.js new file mode 100644 index 00000000000..b11f05f78a3 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/enum/enum.js @@ -0,0 +1,39 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.enum_ = void 0; +const Schema_1 = require("../../Schema"); +const createIdentitySchemaCreator_1 = require("../../utils/createIdentitySchemaCreator"); +const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType"); +function enum_(values) { + const validValues = new Set(values); + const schemaCreator = (0, createIdentitySchemaCreator_1.createIdentitySchemaCreator)(Schema_1.SchemaType.ENUM, (value, { allowUnrecognizedEnumValues, breadcrumbsPrefix = [] } = {}) => { + if (typeof value !== "string") { + return { + ok: false, + errors: [ + { + path: breadcrumbsPrefix, + message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(value, "string"), + }, + ], + }; + } + if (!validValues.has(value) && !allowUnrecognizedEnumValues) { + return { + ok: false, + errors: [ + { + path: breadcrumbsPrefix, + message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(value, "enum"), + }, + ], + }; + } + return { + ok: true, + value: value, + }; + }); + return schemaCreator(); +} +exports.enum_ = enum_; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/enum/index.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/enum/index.d.ts new file mode 100644 index 00000000000..fe6faed93e3 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/enum/index.d.ts @@ -0,0 +1 @@ +export { enum_ } from "./enum"; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/enum/index.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/enum/index.js new file mode 100644 index 00000000000..e34b1715609 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/enum/index.js @@ -0,0 +1,5 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.enum_ = void 0; +var enum_1 = require("./enum"); +Object.defineProperty(exports, "enum_", { enumerable: true, get: function () { return enum_1.enum_; } }); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/index.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/index.d.ts new file mode 100644 index 00000000000..65211f92522 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/index.d.ts @@ -0,0 +1,14 @@ +export * from "./bigint"; +export * from "./date"; +export * from "./enum"; +export * from "./lazy"; +export * from "./list"; +export * from "./literals"; +export * from "./object"; +export * from "./object-like"; +export * from "./primitives"; +export * from "./record"; +export * from "./schema-utils"; +export * from "./set"; +export * from "./undiscriminated-union"; +export * from "./union"; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/index.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/index.js new file mode 100644 index 00000000000..eb8d9805dd5 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/index.js @@ -0,0 +1,30 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +__exportStar(require("./bigint"), exports); +__exportStar(require("./date"), exports); +__exportStar(require("./enum"), exports); +__exportStar(require("./lazy"), exports); +__exportStar(require("./list"), exports); +__exportStar(require("./literals"), exports); +__exportStar(require("./object"), exports); +__exportStar(require("./object-like"), exports); +__exportStar(require("./primitives"), exports); +__exportStar(require("./record"), exports); +__exportStar(require("./schema-utils"), exports); +__exportStar(require("./set"), exports); +__exportStar(require("./undiscriminated-union"), exports); +__exportStar(require("./union"), exports); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/lazy/index.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/lazy/index.d.ts new file mode 100644 index 00000000000..77420fb031c --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/lazy/index.d.ts @@ -0,0 +1,3 @@ +export { lazy } from "./lazy"; +export type { SchemaGetter } from "./lazy"; +export { lazyObject } from "./lazyObject"; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/lazy/index.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/lazy/index.js new file mode 100644 index 00000000000..a590a44bc34 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/lazy/index.js @@ -0,0 +1,7 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.lazyObject = exports.lazy = void 0; +var lazy_1 = require("./lazy"); +Object.defineProperty(exports, "lazy", { enumerable: true, get: function () { return lazy_1.lazy; } }); +var lazyObject_1 = require("./lazyObject"); +Object.defineProperty(exports, "lazyObject", { enumerable: true, get: function () { return lazyObject_1.lazyObject; } }); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/lazy/lazy.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/lazy/lazy.d.ts new file mode 100644 index 00000000000..c5dc4f6e262 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/lazy/lazy.d.ts @@ -0,0 +1,5 @@ +import { BaseSchema, Schema } from "../../Schema"; +export declare type SchemaGetter> = () => SchemaType; +export declare function lazy(getter: SchemaGetter>): Schema; +export declare function constructLazyBaseSchema(getter: SchemaGetter>): BaseSchema; +export declare function getMemoizedSchema>(getter: SchemaGetter): SchemaType; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/lazy/lazy.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/lazy/lazy.js new file mode 100644 index 00000000000..16283aa9e87 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/lazy/lazy.js @@ -0,0 +1,25 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getMemoizedSchema = exports.constructLazyBaseSchema = exports.lazy = void 0; +const schema_utils_1 = require("../schema-utils"); +function lazy(getter) { + const baseSchema = constructLazyBaseSchema(getter); + return Object.assign(Object.assign({}, baseSchema), (0, schema_utils_1.getSchemaUtils)(baseSchema)); +} +exports.lazy = lazy; +function constructLazyBaseSchema(getter) { + return { + parse: (raw, opts) => getMemoizedSchema(getter).parse(raw, opts), + json: (parsed, opts) => getMemoizedSchema(getter).json(parsed, opts), + getType: () => getMemoizedSchema(getter).getType(), + }; +} +exports.constructLazyBaseSchema = constructLazyBaseSchema; +function getMemoizedSchema(getter) { + const castedGetter = getter; + if (castedGetter.__zurg_memoized == null) { + castedGetter.__zurg_memoized = getter(); + } + return castedGetter.__zurg_memoized; +} +exports.getMemoizedSchema = getMemoizedSchema; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/lazy/lazyObject.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/lazy/lazyObject.d.ts new file mode 100644 index 00000000000..0276841dab1 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/lazy/lazyObject.d.ts @@ -0,0 +1,3 @@ +import { ObjectSchema } from "../object/types"; +import { SchemaGetter } from "./lazy"; +export declare function lazyObject(getter: SchemaGetter>): ObjectSchema; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/lazy/lazyObject.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/lazy/lazyObject.js new file mode 100644 index 00000000000..26ce4f0fca3 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/lazy/lazyObject.js @@ -0,0 +1,12 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.lazyObject = void 0; +const object_1 = require("../object"); +const object_like_1 = require("../object-like"); +const schema_utils_1 = require("../schema-utils"); +const lazy_1 = require("./lazy"); +function lazyObject(getter) { + const baseSchema = Object.assign(Object.assign({}, (0, lazy_1.constructLazyBaseSchema)(getter)), { _getRawProperties: () => (0, lazy_1.getMemoizedSchema)(getter)._getRawProperties(), _getParsedProperties: () => (0, lazy_1.getMemoizedSchema)(getter)._getParsedProperties() }); + return Object.assign(Object.assign(Object.assign(Object.assign({}, baseSchema), (0, schema_utils_1.getSchemaUtils)(baseSchema)), (0, object_like_1.getObjectLikeUtils)(baseSchema)), (0, object_1.getObjectUtils)(baseSchema)); +} +exports.lazyObject = lazyObject; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/list/index.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/list/index.d.ts new file mode 100644 index 00000000000..25f4bcc1737 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/list/index.d.ts @@ -0,0 +1 @@ +export { list } from "./list"; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/list/index.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/list/index.js new file mode 100644 index 00000000000..e57fb7d9a50 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/list/index.js @@ -0,0 +1,5 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.list = void 0; +var list_1 = require("./list"); +Object.defineProperty(exports, "list", { enumerable: true, get: function () { return list_1.list; } }); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/list/list.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/list/list.d.ts new file mode 100644 index 00000000000..66db572f91d --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/list/list.d.ts @@ -0,0 +1,2 @@ +import { Schema } from "../../Schema"; +export declare function list(schema: Schema): Schema; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/list/list.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/list/list.js new file mode 100644 index 00000000000..712e54351fd --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/list/list.js @@ -0,0 +1,55 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.list = void 0; +const Schema_1 = require("../../Schema"); +const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType"); +const maybeSkipValidation_1 = require("../../utils/maybeSkipValidation"); +const schema_utils_1 = require("../schema-utils"); +function list(schema) { + const baseSchema = { + parse: (raw, opts) => validateAndTransformArray(raw, (item, index) => { + var _a; + return schema.parse(item, Object.assign(Object.assign({}, opts), { breadcrumbsPrefix: [...((_a = opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix) !== null && _a !== void 0 ? _a : []), `[${index}]`] })); + }), + json: (parsed, opts) => validateAndTransformArray(parsed, (item, index) => { + var _a; + return schema.json(item, Object.assign(Object.assign({}, opts), { breadcrumbsPrefix: [...((_a = opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix) !== null && _a !== void 0 ? _a : []), `[${index}]`] })); + }), + getType: () => Schema_1.SchemaType.LIST, + }; + return Object.assign(Object.assign({}, (0, maybeSkipValidation_1.maybeSkipValidation)(baseSchema)), (0, schema_utils_1.getSchemaUtils)(baseSchema)); +} +exports.list = list; +function validateAndTransformArray(value, transformItem) { + if (!Array.isArray(value)) { + return { + ok: false, + errors: [ + { + message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(value, "list"), + path: [], + }, + ], + }; + } + const maybeValidItems = value.map((item, index) => transformItem(item, index)); + return maybeValidItems.reduce((acc, item) => { + if (acc.ok && item.ok) { + return { + ok: true, + value: [...acc.value, item.value], + }; + } + const errors = []; + if (!acc.ok) { + errors.push(...acc.errors); + } + if (!item.ok) { + errors.push(...item.errors); + } + return { + ok: false, + errors, + }; + }, { ok: true, value: [] }); +} diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/literals/booleanLiteral.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/literals/booleanLiteral.d.ts new file mode 100644 index 00000000000..e975bcd96ec --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/literals/booleanLiteral.d.ts @@ -0,0 +1,2 @@ +import { Schema } from "../../Schema"; +export declare function booleanLiteral(literal: V): Schema; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/literals/booleanLiteral.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/literals/booleanLiteral.js new file mode 100644 index 00000000000..57a2d3d7e7c --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/literals/booleanLiteral.js @@ -0,0 +1,29 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.booleanLiteral = void 0; +const Schema_1 = require("../../Schema"); +const createIdentitySchemaCreator_1 = require("../../utils/createIdentitySchemaCreator"); +const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType"); +function booleanLiteral(literal) { + const schemaCreator = (0, createIdentitySchemaCreator_1.createIdentitySchemaCreator)(Schema_1.SchemaType.BOOLEAN_LITERAL, (value, { breadcrumbsPrefix = [] } = {}) => { + if (value === literal) { + return { + ok: true, + value: literal, + }; + } + else { + return { + ok: false, + errors: [ + { + path: breadcrumbsPrefix, + message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(value, `${literal.toString()}`), + }, + ], + }; + } + }); + return schemaCreator(); +} +exports.booleanLiteral = booleanLiteral; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/literals/index.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/literals/index.d.ts new file mode 100644 index 00000000000..d2bf08fc6ca --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/literals/index.d.ts @@ -0,0 +1,2 @@ +export { stringLiteral } from "./stringLiteral"; +export { booleanLiteral } from "./booleanLiteral"; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/literals/index.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/literals/index.js new file mode 100644 index 00000000000..13f9a144310 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/literals/index.js @@ -0,0 +1,7 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.booleanLiteral = exports.stringLiteral = void 0; +var stringLiteral_1 = require("./stringLiteral"); +Object.defineProperty(exports, "stringLiteral", { enumerable: true, get: function () { return stringLiteral_1.stringLiteral; } }); +var booleanLiteral_1 = require("./booleanLiteral"); +Object.defineProperty(exports, "booleanLiteral", { enumerable: true, get: function () { return booleanLiteral_1.booleanLiteral; } }); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/literals/stringLiteral.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/literals/stringLiteral.d.ts new file mode 100644 index 00000000000..2fb94be5fdc --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/literals/stringLiteral.d.ts @@ -0,0 +1,2 @@ +import { Schema } from "../../Schema"; +export declare function stringLiteral(literal: V): Schema; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/literals/stringLiteral.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/literals/stringLiteral.js new file mode 100644 index 00000000000..4da909ba678 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/literals/stringLiteral.js @@ -0,0 +1,29 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.stringLiteral = void 0; +const Schema_1 = require("../../Schema"); +const createIdentitySchemaCreator_1 = require("../../utils/createIdentitySchemaCreator"); +const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType"); +function stringLiteral(literal) { + const schemaCreator = (0, createIdentitySchemaCreator_1.createIdentitySchemaCreator)(Schema_1.SchemaType.STRING_LITERAL, (value, { breadcrumbsPrefix = [] } = {}) => { + if (value === literal) { + return { + ok: true, + value: literal, + }; + } + else { + return { + ok: false, + errors: [ + { + path: breadcrumbsPrefix, + message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(value, `"${literal}"`), + }, + ], + }; + } + }); + return schemaCreator(); +} +exports.stringLiteral = stringLiteral; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object-like/getObjectLikeUtils.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object-like/getObjectLikeUtils.d.ts new file mode 100644 index 00000000000..47fa3aa2c18 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object-like/getObjectLikeUtils.d.ts @@ -0,0 +1,9 @@ +import { BaseSchema } from "../../Schema"; +import { ObjectLikeSchema, ObjectLikeUtils } from "./types"; +export declare function getObjectLikeUtils(schema: BaseSchema): ObjectLikeUtils; +/** + * object-like utils are defined in one file to resolve issues with circular imports + */ +export declare function withParsedProperties(objectLike: BaseSchema, properties: { + [K in keyof Properties]: Properties[K] | ((parsed: ParsedObjectShape) => Properties[K]); +}): ObjectLikeSchema; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object-like/getObjectLikeUtils.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object-like/getObjectLikeUtils.js new file mode 100644 index 00000000000..aa7620752ec --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object-like/getObjectLikeUtils.js @@ -0,0 +1,54 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.withParsedProperties = exports.getObjectLikeUtils = void 0; +const filterObject_1 = require("../../utils/filterObject"); +const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType"); +const isPlainObject_1 = require("../../utils/isPlainObject"); +const schema_utils_1 = require("../schema-utils"); +function getObjectLikeUtils(schema) { + return { + withParsedProperties: (properties) => withParsedProperties(schema, properties), + }; +} +exports.getObjectLikeUtils = getObjectLikeUtils; +/** + * object-like utils are defined in one file to resolve issues with circular imports + */ +function withParsedProperties(objectLike, properties) { + const objectSchema = { + parse: (raw, opts) => { + const parsedObject = objectLike.parse(raw, opts); + if (!parsedObject.ok) { + return parsedObject; + } + const additionalProperties = Object.entries(properties).reduce((processed, [key, value]) => { + return Object.assign(Object.assign({}, processed), { [key]: typeof value === "function" ? value(parsedObject.value) : value }); + }, {}); + return { + ok: true, + value: Object.assign(Object.assign({}, parsedObject.value), additionalProperties), + }; + }, + json: (parsed, opts) => { + var _a; + if (!(0, isPlainObject_1.isPlainObject)(parsed)) { + return { + ok: false, + errors: [ + { + path: (_a = opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix) !== null && _a !== void 0 ? _a : [], + message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(parsed, "object"), + }, + ], + }; + } + // strip out added properties + const addedPropertyKeys = new Set(Object.keys(properties)); + const parsedWithoutAddedProperties = (0, filterObject_1.filterObject)(parsed, Object.keys(parsed).filter((key) => !addedPropertyKeys.has(key))); + return objectLike.json(parsedWithoutAddedProperties, opts); + }, + getType: () => objectLike.getType(), + }; + return Object.assign(Object.assign(Object.assign({}, objectSchema), (0, schema_utils_1.getSchemaUtils)(objectSchema)), getObjectLikeUtils(objectSchema)); +} +exports.withParsedProperties = withParsedProperties; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object-like/index.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object-like/index.d.ts new file mode 100644 index 00000000000..c342e72cf9d --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object-like/index.d.ts @@ -0,0 +1,2 @@ +export { getObjectLikeUtils, withParsedProperties } from "./getObjectLikeUtils"; +export type { ObjectLikeSchema, ObjectLikeUtils } from "./types"; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object-like/index.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object-like/index.js new file mode 100644 index 00000000000..8b013d0f8aa --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object-like/index.js @@ -0,0 +1,6 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.withParsedProperties = exports.getObjectLikeUtils = void 0; +var getObjectLikeUtils_1 = require("./getObjectLikeUtils"); +Object.defineProperty(exports, "getObjectLikeUtils", { enumerable: true, get: function () { return getObjectLikeUtils_1.getObjectLikeUtils; } }); +Object.defineProperty(exports, "withParsedProperties", { enumerable: true, get: function () { return getObjectLikeUtils_1.withParsedProperties; } }); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object-like/types.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object-like/types.d.ts new file mode 100644 index 00000000000..c6ceea76642 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object-like/types.d.ts @@ -0,0 +1,7 @@ +import { BaseSchema, Schema } from "../../Schema"; +export declare type ObjectLikeSchema = Schema & BaseSchema & ObjectLikeUtils; +export interface ObjectLikeUtils { + withParsedProperties: >(properties: { + [K in keyof T]: T[K] | ((parsed: Parsed) => T[K]); + }) => ObjectLikeSchema; +} diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object-like/types.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object-like/types.js new file mode 100644 index 00000000000..c8ad2e549bd --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object-like/types.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object/index.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object/index.d.ts new file mode 100644 index 00000000000..488cdcdf304 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object/index.d.ts @@ -0,0 +1,6 @@ +export { getObjectUtils, object } from "./object"; +export { objectWithoutOptionalProperties } from "./objectWithoutOptionalProperties"; +export type { inferObjectWithoutOptionalPropertiesSchemaFromPropertySchemas, inferParsedObjectWithoutOptionalPropertiesFromPropertySchemas, } from "./objectWithoutOptionalProperties"; +export { isProperty, property } from "./property"; +export type { Property } from "./property"; +export type { BaseObjectSchema, inferObjectSchemaFromPropertySchemas, inferParsedObject, inferParsedObjectFromPropertySchemas, inferParsedPropertySchema, inferRawKey, inferRawObject, inferRawObjectFromPropertySchemas, inferRawPropertySchema, ObjectSchema, ObjectUtils, PropertySchemas, } from "./types"; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object/index.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object/index.js new file mode 100644 index 00000000000..e6ee4518638 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object/index.js @@ -0,0 +1,11 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.property = exports.isProperty = exports.objectWithoutOptionalProperties = exports.object = exports.getObjectUtils = void 0; +var object_1 = require("./object"); +Object.defineProperty(exports, "getObjectUtils", { enumerable: true, get: function () { return object_1.getObjectUtils; } }); +Object.defineProperty(exports, "object", { enumerable: true, get: function () { return object_1.object; } }); +var objectWithoutOptionalProperties_1 = require("./objectWithoutOptionalProperties"); +Object.defineProperty(exports, "objectWithoutOptionalProperties", { enumerable: true, get: function () { return objectWithoutOptionalProperties_1.objectWithoutOptionalProperties; } }); +var property_1 = require("./property"); +Object.defineProperty(exports, "isProperty", { enumerable: true, get: function () { return property_1.isProperty; } }); +Object.defineProperty(exports, "property", { enumerable: true, get: function () { return property_1.property; } }); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object/object.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object/object.d.ts new file mode 100644 index 00000000000..9f22bb09813 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object/object.d.ts @@ -0,0 +1,3 @@ +import { BaseObjectSchema, inferObjectSchemaFromPropertySchemas, ObjectUtils, PropertySchemas } from "./types"; +export declare function object>(schemas: T): inferObjectSchemaFromPropertySchemas; +export declare function getObjectUtils(schema: BaseObjectSchema): ObjectUtils; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object/object.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object/object.js new file mode 100644 index 00000000000..0ba84910ccb --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object/object.js @@ -0,0 +1,261 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getObjectUtils = exports.object = void 0; +const Schema_1 = require("../../Schema"); +const entries_1 = require("../../utils/entries"); +const filterObject_1 = require("../../utils/filterObject"); +const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType"); +const isPlainObject_1 = require("../../utils/isPlainObject"); +const keys_1 = require("../../utils/keys"); +const maybeSkipValidation_1 = require("../../utils/maybeSkipValidation"); +const partition_1 = require("../../utils/partition"); +const object_like_1 = require("../object-like"); +const schema_utils_1 = require("../schema-utils"); +const property_1 = require("./property"); +function object(schemas) { + const baseSchema = { + _getRawProperties: () => Object.entries(schemas).map(([parsedKey, propertySchema]) => (0, property_1.isProperty)(propertySchema) ? propertySchema.rawKey : parsedKey), + _getParsedProperties: () => (0, keys_1.keys)(schemas), + parse: (raw, opts) => { + const rawKeyToProperty = {}; + const requiredKeys = []; + for (const [parsedKey, schemaOrObjectProperty] of (0, entries_1.entries)(schemas)) { + const rawKey = (0, property_1.isProperty)(schemaOrObjectProperty) ? schemaOrObjectProperty.rawKey : parsedKey; + const valueSchema = (0, property_1.isProperty)(schemaOrObjectProperty) + ? schemaOrObjectProperty.valueSchema + : schemaOrObjectProperty; + const property = { + rawKey, + parsedKey: parsedKey, + valueSchema, + }; + rawKeyToProperty[rawKey] = property; + if (isSchemaRequired(valueSchema)) { + requiredKeys.push(rawKey); + } + } + return validateAndTransformObject({ + value: raw, + requiredKeys, + getProperty: (rawKey) => { + const property = rawKeyToProperty[rawKey]; + if (property == null) { + return undefined; + } + return { + transformedKey: property.parsedKey, + transform: (propertyValue) => { + var _a; + return property.valueSchema.parse(propertyValue, Object.assign(Object.assign({}, opts), { breadcrumbsPrefix: [...((_a = opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix) !== null && _a !== void 0 ? _a : []), rawKey] })); + }, + }; + }, + unrecognizedObjectKeys: opts === null || opts === void 0 ? void 0 : opts.unrecognizedObjectKeys, + skipValidation: opts === null || opts === void 0 ? void 0 : opts.skipValidation, + breadcrumbsPrefix: opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix, + omitUndefined: opts === null || opts === void 0 ? void 0 : opts.omitUndefined, + }); + }, + json: (parsed, opts) => { + const requiredKeys = []; + for (const [parsedKey, schemaOrObjectProperty] of (0, entries_1.entries)(schemas)) { + const valueSchema = (0, property_1.isProperty)(schemaOrObjectProperty) + ? schemaOrObjectProperty.valueSchema + : schemaOrObjectProperty; + if (isSchemaRequired(valueSchema)) { + requiredKeys.push(parsedKey); + } + } + return validateAndTransformObject({ + value: parsed, + requiredKeys, + getProperty: (parsedKey) => { + const property = schemas[parsedKey]; + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + if (property == null) { + return undefined; + } + if ((0, property_1.isProperty)(property)) { + return { + transformedKey: property.rawKey, + transform: (propertyValue) => { + var _a; + return property.valueSchema.json(propertyValue, Object.assign(Object.assign({}, opts), { breadcrumbsPrefix: [...((_a = opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix) !== null && _a !== void 0 ? _a : []), parsedKey] })); + }, + }; + } + else { + return { + transformedKey: parsedKey, + transform: (propertyValue) => { + var _a; + return property.json(propertyValue, Object.assign(Object.assign({}, opts), { breadcrumbsPrefix: [...((_a = opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix) !== null && _a !== void 0 ? _a : []), parsedKey] })); + }, + }; + } + }, + unrecognizedObjectKeys: opts === null || opts === void 0 ? void 0 : opts.unrecognizedObjectKeys, + skipValidation: opts === null || opts === void 0 ? void 0 : opts.skipValidation, + breadcrumbsPrefix: opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix, + omitUndefined: opts === null || opts === void 0 ? void 0 : opts.omitUndefined, + }); + }, + getType: () => Schema_1.SchemaType.OBJECT, + }; + return Object.assign(Object.assign(Object.assign(Object.assign({}, (0, maybeSkipValidation_1.maybeSkipValidation)(baseSchema)), (0, schema_utils_1.getSchemaUtils)(baseSchema)), (0, object_like_1.getObjectLikeUtils)(baseSchema)), getObjectUtils(baseSchema)); +} +exports.object = object; +function validateAndTransformObject({ value, requiredKeys, getProperty, unrecognizedObjectKeys = "fail", skipValidation = false, breadcrumbsPrefix = [], }) { + if (!(0, isPlainObject_1.isPlainObject)(value)) { + return { + ok: false, + errors: [ + { + path: breadcrumbsPrefix, + message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(value, "object"), + }, + ], + }; + } + const missingRequiredKeys = new Set(requiredKeys); + const errors = []; + const transformed = {}; + for (const [preTransformedKey, preTransformedItemValue] of Object.entries(value)) { + const property = getProperty(preTransformedKey); + if (property != null) { + missingRequiredKeys.delete(preTransformedKey); + const value = property.transform(preTransformedItemValue); + if (value.ok) { + transformed[property.transformedKey] = value.value; + } + else { + transformed[preTransformedKey] = preTransformedItemValue; + errors.push(...value.errors); + } + } + else { + switch (unrecognizedObjectKeys) { + case "fail": + errors.push({ + path: [...breadcrumbsPrefix, preTransformedKey], + message: `Unexpected key "${preTransformedKey}"`, + }); + break; + case "strip": + break; + case "passthrough": + transformed[preTransformedKey] = preTransformedItemValue; + break; + } + } + } + errors.push(...requiredKeys + .filter((key) => missingRequiredKeys.has(key)) + .map((key) => ({ + path: breadcrumbsPrefix, + message: `Missing required key "${key}"`, + }))); + if (errors.length === 0 || skipValidation) { + return { + ok: true, + value: transformed, + }; + } + else { + return { + ok: false, + errors, + }; + } +} +function getObjectUtils(schema) { + return { + extend: (extension) => { + const baseSchema = { + _getParsedProperties: () => [...schema._getParsedProperties(), ...extension._getParsedProperties()], + _getRawProperties: () => [...schema._getRawProperties(), ...extension._getRawProperties()], + parse: (raw, opts) => { + return validateAndTransformExtendedObject({ + extensionKeys: extension._getRawProperties(), + value: raw, + transformBase: (rawBase) => schema.parse(rawBase, opts), + transformExtension: (rawExtension) => extension.parse(rawExtension, opts), + }); + }, + json: (parsed, opts) => { + return validateAndTransformExtendedObject({ + extensionKeys: extension._getParsedProperties(), + value: parsed, + transformBase: (parsedBase) => schema.json(parsedBase, opts), + transformExtension: (parsedExtension) => extension.json(parsedExtension, opts), + }); + }, + getType: () => Schema_1.SchemaType.OBJECT, + }; + return Object.assign(Object.assign(Object.assign(Object.assign({}, baseSchema), (0, schema_utils_1.getSchemaUtils)(baseSchema)), (0, object_like_1.getObjectLikeUtils)(baseSchema)), getObjectUtils(baseSchema)); + }, + passthrough: () => { + const baseSchema = { + _getParsedProperties: () => schema._getParsedProperties(), + _getRawProperties: () => schema._getRawProperties(), + parse: (raw, opts) => { + const transformed = schema.parse(raw, Object.assign(Object.assign({}, opts), { unrecognizedObjectKeys: "passthrough" })); + if (!transformed.ok) { + return transformed; + } + return { + ok: true, + value: Object.assign(Object.assign({}, raw), transformed.value), + }; + }, + json: (parsed, opts) => { + const transformed = schema.json(parsed, Object.assign(Object.assign({}, opts), { unrecognizedObjectKeys: "passthrough" })); + if (!transformed.ok) { + return transformed; + } + return { + ok: true, + value: Object.assign(Object.assign({}, parsed), transformed.value), + }; + }, + getType: () => Schema_1.SchemaType.OBJECT, + }; + return Object.assign(Object.assign(Object.assign(Object.assign({}, baseSchema), (0, schema_utils_1.getSchemaUtils)(baseSchema)), (0, object_like_1.getObjectLikeUtils)(baseSchema)), getObjectUtils(baseSchema)); + }, + }; +} +exports.getObjectUtils = getObjectUtils; +function validateAndTransformExtendedObject({ extensionKeys, value, transformBase, transformExtension, }) { + const extensionPropertiesSet = new Set(extensionKeys); + const [extensionProperties, baseProperties] = (0, partition_1.partition)((0, keys_1.keys)(value), (key) => extensionPropertiesSet.has(key)); + const transformedBase = transformBase((0, filterObject_1.filterObject)(value, baseProperties)); + const transformedExtension = transformExtension((0, filterObject_1.filterObject)(value, extensionProperties)); + if (transformedBase.ok && transformedExtension.ok) { + return { + ok: true, + value: Object.assign(Object.assign({}, transformedBase.value), transformedExtension.value), + }; + } + else { + return { + ok: false, + errors: [ + ...(transformedBase.ok ? [] : transformedBase.errors), + ...(transformedExtension.ok ? [] : transformedExtension.errors), + ], + }; + } +} +function isSchemaRequired(schema) { + return !isSchemaOptional(schema); +} +function isSchemaOptional(schema) { + switch (schema.getType()) { + case Schema_1.SchemaType.ANY: + case Schema_1.SchemaType.UNKNOWN: + case Schema_1.SchemaType.OPTIONAL: + return true; + default: + return false; + } +} diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object/objectWithoutOptionalProperties.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object/objectWithoutOptionalProperties.d.ts new file mode 100644 index 00000000000..6c6e2cf17f5 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object/objectWithoutOptionalProperties.d.ts @@ -0,0 +1,6 @@ +import { inferParsedPropertySchema, inferRawObjectFromPropertySchemas, ObjectSchema, PropertySchemas } from "./types"; +export declare function objectWithoutOptionalProperties>(schemas: T): inferObjectWithoutOptionalPropertiesSchemaFromPropertySchemas; +export declare type inferObjectWithoutOptionalPropertiesSchemaFromPropertySchemas> = ObjectSchema, inferParsedObjectWithoutOptionalPropertiesFromPropertySchemas>; +export declare type inferParsedObjectWithoutOptionalPropertiesFromPropertySchemas> = { + [K in keyof T]: inferParsedPropertySchema; +}; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object/objectWithoutOptionalProperties.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object/objectWithoutOptionalProperties.js new file mode 100644 index 00000000000..1ad8dfec53c --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object/objectWithoutOptionalProperties.js @@ -0,0 +1,8 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.objectWithoutOptionalProperties = void 0; +const object_1 = require("./object"); +function objectWithoutOptionalProperties(schemas) { + return (0, object_1.object)(schemas); +} +exports.objectWithoutOptionalProperties = objectWithoutOptionalProperties; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object/property.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object/property.d.ts new file mode 100644 index 00000000000..a334cf48605 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object/property.d.ts @@ -0,0 +1,8 @@ +import { Schema } from "../../Schema"; +export declare function property(rawKey: RawKey, valueSchema: Schema): Property; +export interface Property { + rawKey: RawKey; + valueSchema: Schema; + isProperty: true; +} +export declare function isProperty>(maybeProperty: unknown): maybeProperty is O; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object/property.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object/property.js new file mode 100644 index 00000000000..a269a9493c8 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object/property.js @@ -0,0 +1,16 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.isProperty = exports.property = void 0; +function property(rawKey, valueSchema) { + return { + rawKey, + valueSchema, + isProperty: true, + }; +} +exports.property = property; +function isProperty(maybeProperty) { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + return maybeProperty.isProperty; +} +exports.isProperty = isProperty; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object/types.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object/types.d.ts new file mode 100644 index 00000000000..7d81da64f49 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object/types.d.ts @@ -0,0 +1,31 @@ +import { BaseSchema, inferParsed, inferRaw, Schema } from "../../Schema"; +import { addQuestionMarksToNullableProperties } from "../../utils/addQuestionMarksToNullableProperties"; +import { ObjectLikeUtils } from "../object-like"; +import { SchemaUtils } from "../schema-utils"; +import { Property } from "./property"; +export declare type ObjectSchema = BaseObjectSchema & ObjectLikeUtils & ObjectUtils & SchemaUtils; +export interface BaseObjectSchema extends BaseSchema { + _getRawProperties: () => (keyof Raw)[]; + _getParsedProperties: () => (keyof Parsed)[]; +} +export interface ObjectUtils { + extend: (schemas: ObjectSchema) => ObjectSchema; + passthrough: () => ObjectSchema; +} +export declare type inferRawObject> = O extends ObjectSchema ? Raw : never; +export declare type inferParsedObject> = O extends ObjectSchema ? Parsed : never; +export declare type inferObjectSchemaFromPropertySchemas> = ObjectSchema, inferParsedObjectFromPropertySchemas>; +export declare type inferRawObjectFromPropertySchemas> = addQuestionMarksToNullableProperties<{ + [ParsedKey in keyof T as inferRawKey]: inferRawPropertySchema; +}>; +export declare type inferParsedObjectFromPropertySchemas> = addQuestionMarksToNullableProperties<{ + [K in keyof T]: inferParsedPropertySchema; +}>; +export declare type PropertySchemas = Record | Schema>; +export declare type inferRawPropertySchema

| Schema> = P extends Property ? Raw : P extends Schema ? inferRaw

: never; +export declare type inferParsedPropertySchema

| Schema> = P extends Property ? Parsed : P extends Schema ? inferParsed

: never; +export declare type inferRawKey | Schema> = P extends Property ? Raw : ParsedKey; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object/types.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object/types.js new file mode 100644 index 00000000000..c8ad2e549bd --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/object/types.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/any.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/any.d.ts new file mode 100644 index 00000000000..e818e346703 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/any.d.ts @@ -0,0 +1 @@ +export declare const any: () => import("../../Schema").Schema; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/any.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/any.js new file mode 100644 index 00000000000..0c6fe3c126f --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/any.js @@ -0,0 +1,6 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.any = void 0; +const Schema_1 = require("../../Schema"); +const createIdentitySchemaCreator_1 = require("../../utils/createIdentitySchemaCreator"); +exports.any = (0, createIdentitySchemaCreator_1.createIdentitySchemaCreator)(Schema_1.SchemaType.ANY, (value) => ({ ok: true, value })); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/boolean.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/boolean.d.ts new file mode 100644 index 00000000000..0efe0adbe7b --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/boolean.d.ts @@ -0,0 +1 @@ +export declare const boolean: () => import("../../Schema").Schema; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/boolean.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/boolean.js new file mode 100644 index 00000000000..81152deff52 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/boolean.js @@ -0,0 +1,25 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.boolean = void 0; +const Schema_1 = require("../../Schema"); +const createIdentitySchemaCreator_1 = require("../../utils/createIdentitySchemaCreator"); +const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType"); +exports.boolean = (0, createIdentitySchemaCreator_1.createIdentitySchemaCreator)(Schema_1.SchemaType.BOOLEAN, (value, { breadcrumbsPrefix = [] } = {}) => { + if (typeof value === "boolean") { + return { + ok: true, + value, + }; + } + else { + return { + ok: false, + errors: [ + { + path: breadcrumbsPrefix, + message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(value, "boolean"), + }, + ], + }; + } +}); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/index.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/index.d.ts new file mode 100644 index 00000000000..788f9416bfe --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/index.d.ts @@ -0,0 +1,5 @@ +export { any } from "./any"; +export { boolean } from "./boolean"; +export { number } from "./number"; +export { string } from "./string"; +export { unknown } from "./unknown"; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/index.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/index.js new file mode 100644 index 00000000000..1cb8b3802c1 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/index.js @@ -0,0 +1,13 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.unknown = exports.string = exports.number = exports.boolean = exports.any = void 0; +var any_1 = require("./any"); +Object.defineProperty(exports, "any", { enumerable: true, get: function () { return any_1.any; } }); +var boolean_1 = require("./boolean"); +Object.defineProperty(exports, "boolean", { enumerable: true, get: function () { return boolean_1.boolean; } }); +var number_1 = require("./number"); +Object.defineProperty(exports, "number", { enumerable: true, get: function () { return number_1.number; } }); +var string_1 = require("./string"); +Object.defineProperty(exports, "string", { enumerable: true, get: function () { return string_1.string; } }); +var unknown_1 = require("./unknown"); +Object.defineProperty(exports, "unknown", { enumerable: true, get: function () { return unknown_1.unknown; } }); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/number.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/number.d.ts new file mode 100644 index 00000000000..e1de2f52639 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/number.d.ts @@ -0,0 +1 @@ +export declare const number: () => import("../../Schema").Schema; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/number.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/number.js new file mode 100644 index 00000000000..40095cc867c --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/number.js @@ -0,0 +1,25 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.number = void 0; +const Schema_1 = require("../../Schema"); +const createIdentitySchemaCreator_1 = require("../../utils/createIdentitySchemaCreator"); +const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType"); +exports.number = (0, createIdentitySchemaCreator_1.createIdentitySchemaCreator)(Schema_1.SchemaType.NUMBER, (value, { breadcrumbsPrefix = [] } = {}) => { + if (typeof value === "number") { + return { + ok: true, + value, + }; + } + else { + return { + ok: false, + errors: [ + { + path: breadcrumbsPrefix, + message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(value, "number"), + }, + ], + }; + } +}); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/string.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/string.d.ts new file mode 100644 index 00000000000..03817da8f43 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/string.d.ts @@ -0,0 +1 @@ +export declare const string: () => import("../../Schema").Schema; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/string.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/string.js new file mode 100644 index 00000000000..32782ea7632 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/string.js @@ -0,0 +1,25 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.string = void 0; +const Schema_1 = require("../../Schema"); +const createIdentitySchemaCreator_1 = require("../../utils/createIdentitySchemaCreator"); +const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType"); +exports.string = (0, createIdentitySchemaCreator_1.createIdentitySchemaCreator)(Schema_1.SchemaType.STRING, (value, { breadcrumbsPrefix = [] } = {}) => { + if (typeof value === "string") { + return { + ok: true, + value, + }; + } + else { + return { + ok: false, + errors: [ + { + path: breadcrumbsPrefix, + message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(value, "string"), + }, + ], + }; + } +}); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/unknown.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/unknown.d.ts new file mode 100644 index 00000000000..411d10eff92 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/unknown.d.ts @@ -0,0 +1 @@ +export declare const unknown: () => import("../../Schema").Schema; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/unknown.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/unknown.js new file mode 100644 index 00000000000..631d07c835d --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/primitives/unknown.js @@ -0,0 +1,6 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.unknown = void 0; +const Schema_1 = require("../../Schema"); +const createIdentitySchemaCreator_1 = require("../../utils/createIdentitySchemaCreator"); +exports.unknown = (0, createIdentitySchemaCreator_1.createIdentitySchemaCreator)(Schema_1.SchemaType.UNKNOWN, (value) => ({ ok: true, value })); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/record/index.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/record/index.d.ts new file mode 100644 index 00000000000..82e25c5c2af --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/record/index.d.ts @@ -0,0 +1,2 @@ +export { record } from "./record"; +export type { BaseRecordSchema, RecordSchema } from "./types"; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/record/index.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/record/index.js new file mode 100644 index 00000000000..96633da9b83 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/record/index.js @@ -0,0 +1,5 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.record = void 0; +var record_1 = require("./record"); +Object.defineProperty(exports, "record", { enumerable: true, get: function () { return record_1.record; } }); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/record/record.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/record/record.d.ts new file mode 100644 index 00000000000..843be20783e --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/record/record.d.ts @@ -0,0 +1,3 @@ +import { Schema } from "../../Schema"; +import { RecordSchema } from "./types"; +export declare function record(keySchema: Schema, valueSchema: Schema): RecordSchema; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/record/record.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/record/record.js new file mode 100644 index 00000000000..5d6d6af92b9 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/record/record.js @@ -0,0 +1,95 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.record = void 0; +const Schema_1 = require("../../Schema"); +const entries_1 = require("../../utils/entries"); +const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType"); +const isPlainObject_1 = require("../../utils/isPlainObject"); +const maybeSkipValidation_1 = require("../../utils/maybeSkipValidation"); +const schema_utils_1 = require("../schema-utils"); +function record(keySchema, valueSchema) { + const baseSchema = { + parse: (raw, opts) => { + return validateAndTransformRecord({ + value: raw, + isKeyNumeric: keySchema.getType() === Schema_1.SchemaType.NUMBER, + transformKey: (key) => { + var _a; + return keySchema.parse(key, Object.assign(Object.assign({}, opts), { breadcrumbsPrefix: [...((_a = opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix) !== null && _a !== void 0 ? _a : []), `${key} (key)`] })); + }, + transformValue: (value, key) => { + var _a; + return valueSchema.parse(value, Object.assign(Object.assign({}, opts), { breadcrumbsPrefix: [...((_a = opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix) !== null && _a !== void 0 ? _a : []), `${key}`] })); + }, + breadcrumbsPrefix: opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix, + }); + }, + json: (parsed, opts) => { + return validateAndTransformRecord({ + value: parsed, + isKeyNumeric: keySchema.getType() === Schema_1.SchemaType.NUMBER, + transformKey: (key) => { + var _a; + return keySchema.json(key, Object.assign(Object.assign({}, opts), { breadcrumbsPrefix: [...((_a = opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix) !== null && _a !== void 0 ? _a : []), `${key} (key)`] })); + }, + transformValue: (value, key) => { + var _a; + return valueSchema.json(value, Object.assign(Object.assign({}, opts), { breadcrumbsPrefix: [...((_a = opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix) !== null && _a !== void 0 ? _a : []), `${key}`] })); + }, + breadcrumbsPrefix: opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix, + }); + }, + getType: () => Schema_1.SchemaType.RECORD, + }; + return Object.assign(Object.assign({}, (0, maybeSkipValidation_1.maybeSkipValidation)(baseSchema)), (0, schema_utils_1.getSchemaUtils)(baseSchema)); +} +exports.record = record; +function validateAndTransformRecord({ value, isKeyNumeric, transformKey, transformValue, breadcrumbsPrefix = [], }) { + if (!(0, isPlainObject_1.isPlainObject)(value)) { + return { + ok: false, + errors: [ + { + path: breadcrumbsPrefix, + message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(value, "object"), + }, + ], + }; + } + return (0, entries_1.entries)(value).reduce((accPromise, [stringKey, value]) => { + // skip nullish keys + if (value == null) { + return accPromise; + } + const acc = accPromise; + let key = stringKey; + if (isKeyNumeric) { + const numberKey = stringKey.length > 0 ? Number(stringKey) : NaN; + if (!isNaN(numberKey)) { + key = numberKey; + } + } + const transformedKey = transformKey(key); + const transformedValue = transformValue(value, key); + if (acc.ok && transformedKey.ok && transformedValue.ok) { + return { + ok: true, + value: Object.assign(Object.assign({}, acc.value), { [transformedKey.value]: transformedValue.value }), + }; + } + const errors = []; + if (!acc.ok) { + errors.push(...acc.errors); + } + if (!transformedKey.ok) { + errors.push(...transformedKey.errors); + } + if (!transformedValue.ok) { + errors.push(...transformedValue.errors); + } + return { + ok: false, + errors, + }; + }, { ok: true, value: {} }); +} diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/record/types.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/record/types.d.ts new file mode 100644 index 00000000000..e4ed1b903e2 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/record/types.d.ts @@ -0,0 +1,4 @@ +import { BaseSchema } from "../../Schema"; +import { SchemaUtils } from "../schema-utils"; +export declare type RecordSchema = BaseRecordSchema & SchemaUtils, Record>; +export declare type BaseRecordSchema = BaseSchema, Record>; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/record/types.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/record/types.js new file mode 100644 index 00000000000..c8ad2e549bd --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/record/types.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/schema-utils/JsonError.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/schema-utils/JsonError.d.ts new file mode 100644 index 00000000000..40796c8fc84 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/schema-utils/JsonError.d.ts @@ -0,0 +1,5 @@ +import { ValidationError } from "../../Schema"; +export declare class JsonError extends Error { + readonly errors: ValidationError[]; + constructor(errors: ValidationError[]); +} diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/schema-utils/JsonError.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/schema-utils/JsonError.js new file mode 100644 index 00000000000..5f010626993 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/schema-utils/JsonError.js @@ -0,0 +1,12 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.JsonError = void 0; +const stringifyValidationErrors_1 = require("./stringifyValidationErrors"); +class JsonError extends Error { + constructor(errors) { + super(errors.map(stringifyValidationErrors_1.stringifyValidationError).join("; ")); + this.errors = errors; + Object.setPrototypeOf(this, JsonError.prototype); + } +} +exports.JsonError = JsonError; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/schema-utils/ParseError.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/schema-utils/ParseError.d.ts new file mode 100644 index 00000000000..182193e4dc5 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/schema-utils/ParseError.d.ts @@ -0,0 +1,5 @@ +import { ValidationError } from "../../Schema"; +export declare class ParseError extends Error { + readonly errors: ValidationError[]; + constructor(errors: ValidationError[]); +} diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/schema-utils/ParseError.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/schema-utils/ParseError.js new file mode 100644 index 00000000000..9ef24e27ec7 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/schema-utils/ParseError.js @@ -0,0 +1,12 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ParseError = void 0; +const stringifyValidationErrors_1 = require("./stringifyValidationErrors"); +class ParseError extends Error { + constructor(errors) { + super(errors.map(stringifyValidationErrors_1.stringifyValidationError).join("; ")); + this.errors = errors; + Object.setPrototypeOf(this, ParseError.prototype); + } +} +exports.ParseError = ParseError; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/schema-utils/getSchemaUtils.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/schema-utils/getSchemaUtils.d.ts new file mode 100644 index 00000000000..dfc074e2746 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/schema-utils/getSchemaUtils.d.ts @@ -0,0 +1,17 @@ +import { BaseSchema, Schema, SchemaOptions } from "../../Schema"; +export interface SchemaUtils { + optional: () => Schema; + transform: (transformer: SchemaTransformer) => Schema; + parseOrThrow: (raw: unknown, opts?: SchemaOptions) => Parsed; + jsonOrThrow: (raw: unknown, opts?: SchemaOptions) => Raw; +} +export interface SchemaTransformer { + transform: (parsed: Parsed) => Transformed; + untransform: (transformed: any) => Parsed; +} +export declare function getSchemaUtils(schema: BaseSchema): SchemaUtils; +/** + * schema utils are defined in one file to resolve issues with circular imports + */ +export declare function optional(schema: BaseSchema): Schema; +export declare function transform(schema: BaseSchema, transformer: SchemaTransformer): Schema; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/schema-utils/getSchemaUtils.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/schema-utils/getSchemaUtils.js new file mode 100644 index 00000000000..ad0c354ae38 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/schema-utils/getSchemaUtils.js @@ -0,0 +1,82 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.transform = exports.optional = exports.getSchemaUtils = void 0; +const Schema_1 = require("../../Schema"); +const JsonError_1 = require("./JsonError"); +const ParseError_1 = require("./ParseError"); +function getSchemaUtils(schema) { + return { + optional: () => optional(schema), + transform: (transformer) => transform(schema, transformer), + parseOrThrow: (raw, opts) => { + const parsed = schema.parse(raw, opts); + if (parsed.ok) { + return parsed.value; + } + throw new ParseError_1.ParseError(parsed.errors); + }, + jsonOrThrow: (parsed, opts) => { + const raw = schema.json(parsed, opts); + if (raw.ok) { + return raw.value; + } + throw new JsonError_1.JsonError(raw.errors); + }, + }; +} +exports.getSchemaUtils = getSchemaUtils; +/** + * schema utils are defined in one file to resolve issues with circular imports + */ +function optional(schema) { + const baseSchema = { + parse: (raw, opts) => { + if (raw == null) { + return { + ok: true, + value: undefined, + }; + } + return schema.parse(raw, opts); + }, + json: (parsed, opts) => { + if ((opts === null || opts === void 0 ? void 0 : opts.omitUndefined) && parsed === undefined) { + return { + ok: true, + value: undefined, + }; + } + if (parsed == null) { + return { + ok: true, + value: null, + }; + } + return schema.json(parsed, opts); + }, + getType: () => Schema_1.SchemaType.OPTIONAL, + }; + return Object.assign(Object.assign({}, baseSchema), getSchemaUtils(baseSchema)); +} +exports.optional = optional; +function transform(schema, transformer) { + const baseSchema = { + parse: (raw, opts) => { + const parsed = schema.parse(raw, opts); + if (!parsed.ok) { + return parsed; + } + return { + ok: true, + value: transformer.transform(parsed.value), + }; + }, + json: (transformed, opts) => { + const parsed = transformer.untransform(transformed); + return schema.json(parsed, opts); + }, + getType: () => schema.getType(), + }; + return Object.assign(Object.assign({}, baseSchema), getSchemaUtils(baseSchema)); +} +exports.transform = transform; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/schema-utils/index.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/schema-utils/index.d.ts new file mode 100644 index 00000000000..aa04e051dfa --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/schema-utils/index.d.ts @@ -0,0 +1,4 @@ +export { getSchemaUtils, optional, transform } from "./getSchemaUtils"; +export type { SchemaUtils } from "./getSchemaUtils"; +export { JsonError } from "./JsonError"; +export { ParseError } from "./ParseError"; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/schema-utils/index.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/schema-utils/index.js new file mode 100644 index 00000000000..e0260b1a5dd --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/schema-utils/index.js @@ -0,0 +1,11 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ParseError = exports.JsonError = exports.transform = exports.optional = exports.getSchemaUtils = void 0; +var getSchemaUtils_1 = require("./getSchemaUtils"); +Object.defineProperty(exports, "getSchemaUtils", { enumerable: true, get: function () { return getSchemaUtils_1.getSchemaUtils; } }); +Object.defineProperty(exports, "optional", { enumerable: true, get: function () { return getSchemaUtils_1.optional; } }); +Object.defineProperty(exports, "transform", { enumerable: true, get: function () { return getSchemaUtils_1.transform; } }); +var JsonError_1 = require("./JsonError"); +Object.defineProperty(exports, "JsonError", { enumerable: true, get: function () { return JsonError_1.JsonError; } }); +var ParseError_1 = require("./ParseError"); +Object.defineProperty(exports, "ParseError", { enumerable: true, get: function () { return ParseError_1.ParseError; } }); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/schema-utils/stringifyValidationErrors.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/schema-utils/stringifyValidationErrors.d.ts new file mode 100644 index 00000000000..e24cad9c2e8 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/schema-utils/stringifyValidationErrors.d.ts @@ -0,0 +1,2 @@ +import { ValidationError } from "../../Schema"; +export declare function stringifyValidationError(error: ValidationError): string; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/schema-utils/stringifyValidationErrors.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/schema-utils/stringifyValidationErrors.js new file mode 100644 index 00000000000..93b543cfcc5 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/schema-utils/stringifyValidationErrors.js @@ -0,0 +1,10 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.stringifyValidationError = void 0; +function stringifyValidationError(error) { + if (error.path.length === 0) { + return error.message; + } + return `${error.path.join(" -> ")}: ${error.message}`; +} +exports.stringifyValidationError = stringifyValidationError; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/set/index.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/set/index.d.ts new file mode 100644 index 00000000000..f3310e8bdad --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/set/index.d.ts @@ -0,0 +1 @@ +export { set } from "./set"; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/set/index.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/set/index.js new file mode 100644 index 00000000000..9f2833249c1 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/set/index.js @@ -0,0 +1,5 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.set = void 0; +var set_1 = require("./set"); +Object.defineProperty(exports, "set", { enumerable: true, get: function () { return set_1.set; } }); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/set/set.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/set/set.d.ts new file mode 100644 index 00000000000..d96a62c5239 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/set/set.d.ts @@ -0,0 +1,2 @@ +import { Schema } from "../../Schema"; +export declare function set(schema: Schema): Schema>; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/set/set.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/set/set.js new file mode 100644 index 00000000000..326dac1ae7a --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/set/set.js @@ -0,0 +1,44 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.set = void 0; +const Schema_1 = require("../../Schema"); +const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType"); +const maybeSkipValidation_1 = require("../../utils/maybeSkipValidation"); +const list_1 = require("../list"); +const schema_utils_1 = require("../schema-utils"); +function set(schema) { + const listSchema = (0, list_1.list)(schema); + const baseSchema = { + parse: (raw, opts) => { + const parsedList = listSchema.parse(raw, opts); + if (parsedList.ok) { + return { + ok: true, + value: new Set(parsedList.value), + }; + } + else { + return parsedList; + } + }, + json: (parsed, opts) => { + var _a; + if (!(parsed instanceof Set)) { + return { + ok: false, + errors: [ + { + path: (_a = opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix) !== null && _a !== void 0 ? _a : [], + message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(parsed, "Set"), + }, + ], + }; + } + const jsonList = listSchema.json([...parsed], opts); + return jsonList; + }, + getType: () => Schema_1.SchemaType.SET, + }; + return Object.assign(Object.assign({}, (0, maybeSkipValidation_1.maybeSkipValidation)(baseSchema)), (0, schema_utils_1.getSchemaUtils)(baseSchema)); +} +exports.set = set; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/undiscriminated-union/index.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/undiscriminated-union/index.d.ts new file mode 100644 index 00000000000..70dc2108ed4 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/undiscriminated-union/index.d.ts @@ -0,0 +1,2 @@ +export type { inferParsedUnidiscriminatedUnionSchema, inferRawUnidiscriminatedUnionSchema, UndiscriminatedUnionSchema, } from "./types"; +export { undiscriminatedUnion } from "./undiscriminatedUnion"; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/undiscriminated-union/index.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/undiscriminated-union/index.js new file mode 100644 index 00000000000..7003b2d0baf --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/undiscriminated-union/index.js @@ -0,0 +1,5 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.undiscriminatedUnion = void 0; +var undiscriminatedUnion_1 = require("./undiscriminatedUnion"); +Object.defineProperty(exports, "undiscriminatedUnion", { enumerable: true, get: function () { return undiscriminatedUnion_1.undiscriminatedUnion; } }); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/undiscriminated-union/types.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/undiscriminated-union/types.d.ts new file mode 100644 index 00000000000..9ec34a7a32d --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/undiscriminated-union/types.d.ts @@ -0,0 +1,4 @@ +import { inferParsed, inferRaw, Schema } from "../../Schema"; +export declare type UndiscriminatedUnionSchema = Schema, inferParsedUnidiscriminatedUnionSchema>; +export declare type inferRawUnidiscriminatedUnionSchema = inferRaw; +export declare type inferParsedUnidiscriminatedUnionSchema = inferParsed; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/undiscriminated-union/types.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/undiscriminated-union/types.js new file mode 100644 index 00000000000..c8ad2e549bd --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/undiscriminated-union/types.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.d.ts new file mode 100644 index 00000000000..c7c0e8b4c93 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.d.ts @@ -0,0 +1,3 @@ +import { Schema } from "../../Schema"; +import { inferParsedUnidiscriminatedUnionSchema, inferRawUnidiscriminatedUnionSchema } from "./types"; +export declare function undiscriminatedUnion, ...Schema[]]>(schemas: Schemas): Schema, inferParsedUnidiscriminatedUnionSchema>; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.js new file mode 100644 index 00000000000..eedb88f1b0b --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.js @@ -0,0 +1,40 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.undiscriminatedUnion = void 0; +const Schema_1 = require("../../Schema"); +const maybeSkipValidation_1 = require("../../utils/maybeSkipValidation"); +const schema_utils_1 = require("../schema-utils"); +function undiscriminatedUnion(schemas) { + const baseSchema = { + parse: (raw, opts) => { + return validateAndTransformUndiscriminatedUnion((schema, opts) => schema.parse(raw, opts), schemas, opts); + }, + json: (parsed, opts) => { + return validateAndTransformUndiscriminatedUnion((schema, opts) => schema.json(parsed, opts), schemas, opts); + }, + getType: () => Schema_1.SchemaType.UNDISCRIMINATED_UNION, + }; + return Object.assign(Object.assign({}, (0, maybeSkipValidation_1.maybeSkipValidation)(baseSchema)), (0, schema_utils_1.getSchemaUtils)(baseSchema)); +} +exports.undiscriminatedUnion = undiscriminatedUnion; +function validateAndTransformUndiscriminatedUnion(transform, schemas, opts) { + const errors = []; + for (const [index, schema] of schemas.entries()) { + const transformed = transform(schema, Object.assign(Object.assign({}, opts), { skipValidation: false })); + if (transformed.ok) { + return transformed; + } + else { + for (const error of transformed.errors) { + errors.push({ + path: error.path, + message: `[Variant ${index}] ${error.message}`, + }); + } + } + } + return { + ok: false, + errors, + }; +} diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/union/discriminant.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/union/discriminant.d.ts new file mode 100644 index 00000000000..656c7d0ff57 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/union/discriminant.d.ts @@ -0,0 +1,5 @@ +export declare function discriminant(parsedDiscriminant: ParsedDiscriminant, rawDiscriminant: RawDiscriminant): Discriminant; +export interface Discriminant { + parsedDiscriminant: ParsedDiscriminant; + rawDiscriminant: RawDiscriminant; +} diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/union/discriminant.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/union/discriminant.js new file mode 100644 index 00000000000..9f033e93718 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/union/discriminant.js @@ -0,0 +1,10 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.discriminant = void 0; +function discriminant(parsedDiscriminant, rawDiscriminant) { + return { + parsedDiscriminant, + rawDiscriminant, + }; +} +exports.discriminant = discriminant; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/union/index.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/union/index.d.ts new file mode 100644 index 00000000000..626d9af4b48 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/union/index.d.ts @@ -0,0 +1,4 @@ +export { discriminant } from "./discriminant"; +export type { Discriminant } from "./discriminant"; +export type { inferParsedDiscriminant, inferParsedUnion, inferRawDiscriminant, inferRawUnion, UnionSubtypes, } from "./types"; +export { union } from "./union"; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/union/index.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/union/index.js new file mode 100644 index 00000000000..54416d3192d --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/union/index.js @@ -0,0 +1,7 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.union = exports.discriminant = void 0; +var discriminant_1 = require("./discriminant"); +Object.defineProperty(exports, "discriminant", { enumerable: true, get: function () { return discriminant_1.discriminant; } }); +var union_1 = require("./union"); +Object.defineProperty(exports, "union", { enumerable: true, get: function () { return union_1.union; } }); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/union/types.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/union/types.d.ts new file mode 100644 index 00000000000..4c0016aa987 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/union/types.d.ts @@ -0,0 +1,13 @@ +import { inferParsedObject, inferRawObject, ObjectSchema } from "../object"; +import { Discriminant } from "./discriminant"; +export declare type UnionSubtypes = { + [K in DiscriminantValues]: ObjectSchema; +}; +export declare type inferRawUnion, U extends UnionSubtypes> = { + [K in keyof U]: Record, K> & inferRawObject; +}[keyof U]; +export declare type inferParsedUnion, U extends UnionSubtypes> = { + [K in keyof U]: Record, K> & inferParsedObject; +}[keyof U]; +export declare type inferRawDiscriminant> = D extends string ? D : D extends Discriminant ? Raw : never; +export declare type inferParsedDiscriminant> = D extends string ? D : D extends Discriminant ? Parsed : never; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/union/types.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/union/types.js new file mode 100644 index 00000000000..c8ad2e549bd --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/union/types.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/union/union.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/union/union.d.ts new file mode 100644 index 00000000000..6ebd091ab3a --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/union/union.d.ts @@ -0,0 +1,4 @@ +import { ObjectLikeSchema } from "../object-like"; +import { Discriminant } from "./discriminant"; +import { inferParsedUnion, inferRawUnion, UnionSubtypes } from "./types"; +export declare function union, U extends UnionSubtypes>(discriminant: D, union: U): ObjectLikeSchema, inferParsedUnion>; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/union/union.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/union/union.js new file mode 100644 index 00000000000..446fb6b953e --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/builders/union/union.js @@ -0,0 +1,130 @@ +"use strict"; +var __rest = (this && this.__rest) || function (s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { + if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) + t[p[i]] = s[p[i]]; + } + return t; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.union = void 0; +const Schema_1 = require("../../Schema"); +const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType"); +const isPlainObject_1 = require("../../utils/isPlainObject"); +const keys_1 = require("../../utils/keys"); +const maybeSkipValidation_1 = require("../../utils/maybeSkipValidation"); +const enum_1 = require("../enum"); +const object_like_1 = require("../object-like"); +const schema_utils_1 = require("../schema-utils"); +function union(discriminant, union) { + const rawDiscriminant = typeof discriminant === "string" ? discriminant : discriminant.rawDiscriminant; + const parsedDiscriminant = typeof discriminant === "string" + ? discriminant + : discriminant.parsedDiscriminant; + const discriminantValueSchema = (0, enum_1.enum_)((0, keys_1.keys)(union)); + const baseSchema = { + parse: (raw, opts) => { + return transformAndValidateUnion({ + value: raw, + discriminant: rawDiscriminant, + transformedDiscriminant: parsedDiscriminant, + transformDiscriminantValue: (discriminantValue) => { + var _a; + return discriminantValueSchema.parse(discriminantValue, { + allowUnrecognizedEnumValues: opts === null || opts === void 0 ? void 0 : opts.allowUnrecognizedUnionMembers, + breadcrumbsPrefix: [...((_a = opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix) !== null && _a !== void 0 ? _a : []), rawDiscriminant], + }); + }, + getAdditionalPropertiesSchema: (discriminantValue) => union[discriminantValue], + allowUnrecognizedUnionMembers: opts === null || opts === void 0 ? void 0 : opts.allowUnrecognizedUnionMembers, + transformAdditionalProperties: (additionalProperties, additionalPropertiesSchema) => additionalPropertiesSchema.parse(additionalProperties, opts), + breadcrumbsPrefix: opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix, + }); + }, + json: (parsed, opts) => { + return transformAndValidateUnion({ + value: parsed, + discriminant: parsedDiscriminant, + transformedDiscriminant: rawDiscriminant, + transformDiscriminantValue: (discriminantValue) => { + var _a; + return discriminantValueSchema.json(discriminantValue, { + allowUnrecognizedEnumValues: opts === null || opts === void 0 ? void 0 : opts.allowUnrecognizedUnionMembers, + breadcrumbsPrefix: [...((_a = opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix) !== null && _a !== void 0 ? _a : []), parsedDiscriminant], + }); + }, + getAdditionalPropertiesSchema: (discriminantValue) => union[discriminantValue], + allowUnrecognizedUnionMembers: opts === null || opts === void 0 ? void 0 : opts.allowUnrecognizedUnionMembers, + transformAdditionalProperties: (additionalProperties, additionalPropertiesSchema) => additionalPropertiesSchema.json(additionalProperties, opts), + breadcrumbsPrefix: opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix, + }); + }, + getType: () => Schema_1.SchemaType.UNION, + }; + return Object.assign(Object.assign(Object.assign({}, (0, maybeSkipValidation_1.maybeSkipValidation)(baseSchema)), (0, schema_utils_1.getSchemaUtils)(baseSchema)), (0, object_like_1.getObjectLikeUtils)(baseSchema)); +} +exports.union = union; +function transformAndValidateUnion({ value, discriminant, transformedDiscriminant, transformDiscriminantValue, getAdditionalPropertiesSchema, allowUnrecognizedUnionMembers = false, transformAdditionalProperties, breadcrumbsPrefix = [], }) { + if (!(0, isPlainObject_1.isPlainObject)(value)) { + return { + ok: false, + errors: [ + { + path: breadcrumbsPrefix, + message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(value, "object"), + }, + ], + }; + } + const _a = value, _b = discriminant, discriminantValue = _a[_b], additionalProperties = __rest(_a, [typeof _b === "symbol" ? _b : _b + ""]); + if (discriminantValue == null) { + return { + ok: false, + errors: [ + { + path: breadcrumbsPrefix, + message: `Missing discriminant ("${discriminant}")`, + }, + ], + }; + } + const transformedDiscriminantValue = transformDiscriminantValue(discriminantValue); + if (!transformedDiscriminantValue.ok) { + return { + ok: false, + errors: transformedDiscriminantValue.errors, + }; + } + const additionalPropertiesSchema = getAdditionalPropertiesSchema(transformedDiscriminantValue.value); + if (additionalPropertiesSchema == null) { + if (allowUnrecognizedUnionMembers) { + return { + ok: true, + value: Object.assign({ [transformedDiscriminant]: transformedDiscriminantValue.value }, additionalProperties), + }; + } + else { + return { + ok: false, + errors: [ + { + path: [...breadcrumbsPrefix, discriminant], + message: "Unexpected discriminant value", + }, + ], + }; + } + } + const transformedAdditionalProperties = transformAdditionalProperties(additionalProperties, additionalPropertiesSchema); + if (!transformedAdditionalProperties.ok) { + return transformedAdditionalProperties; + } + return { + ok: true, + value: Object.assign({ [transformedDiscriminant]: discriminantValue }, transformedAdditionalProperties.value), + }; +} diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/index.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/index.d.ts new file mode 100644 index 00000000000..5429d8b43eb --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/index.d.ts @@ -0,0 +1,2 @@ +export * from "./builders"; +export type { inferParsed, inferRaw, Schema, SchemaOptions } from "./Schema"; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/index.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/index.js new file mode 100644 index 00000000000..3b189fb4900 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/index.js @@ -0,0 +1,17 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +__exportStar(require("./builders"), exports); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/MaybePromise.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/MaybePromise.d.ts new file mode 100644 index 00000000000..6377c71b8d0 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/MaybePromise.d.ts @@ -0,0 +1 @@ +export declare type MaybePromise = T | Promise; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/MaybePromise.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/MaybePromise.js new file mode 100644 index 00000000000..c8ad2e549bd --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/MaybePromise.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/addQuestionMarksToNullableProperties.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/addQuestionMarksToNullableProperties.d.ts new file mode 100644 index 00000000000..1717fb115e7 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/addQuestionMarksToNullableProperties.d.ts @@ -0,0 +1,7 @@ +export declare type addQuestionMarksToNullableProperties = { + [K in OptionalKeys]?: T[K]; +} & Pick>; +export declare type OptionalKeys = { + [K in keyof T]-?: undefined extends T[K] ? K : null extends T[K] ? K : 1 extends (any extends T[K] ? 0 : 1) ? never : K; +}[keyof T]; +export declare type RequiredKeys = Exclude>; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/addQuestionMarksToNullableProperties.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/addQuestionMarksToNullableProperties.js new file mode 100644 index 00000000000..c8ad2e549bd --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/addQuestionMarksToNullableProperties.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/createIdentitySchemaCreator.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/createIdentitySchemaCreator.d.ts new file mode 100644 index 00000000000..362c9e27bbf --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/createIdentitySchemaCreator.d.ts @@ -0,0 +1,2 @@ +import { MaybeValid, Schema, SchemaOptions, SchemaType } from "../Schema"; +export declare function createIdentitySchemaCreator(schemaType: SchemaType, validate: (value: unknown, opts?: SchemaOptions) => MaybeValid): () => Schema; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/createIdentitySchemaCreator.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/createIdentitySchemaCreator.js new file mode 100644 index 00000000000..b846a7c433a --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/createIdentitySchemaCreator.js @@ -0,0 +1,16 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.createIdentitySchemaCreator = void 0; +const schema_utils_1 = require("../builders/schema-utils"); +const maybeSkipValidation_1 = require("./maybeSkipValidation"); +function createIdentitySchemaCreator(schemaType, validate) { + return () => { + const baseSchema = { + parse: validate, + json: validate, + getType: () => schemaType, + }; + return Object.assign(Object.assign({}, (0, maybeSkipValidation_1.maybeSkipValidation)(baseSchema)), (0, schema_utils_1.getSchemaUtils)(baseSchema)); + }; +} +exports.createIdentitySchemaCreator = createIdentitySchemaCreator; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/entries.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/entries.d.ts new file mode 100644 index 00000000000..918cae50160 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/entries.d.ts @@ -0,0 +1 @@ +export declare function entries(object: T): [keyof T, T[keyof T]][]; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/entries.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/entries.js new file mode 100644 index 00000000000..afa129c5301 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/entries.js @@ -0,0 +1,7 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.entries = void 0; +function entries(object) { + return Object.entries(object); +} +exports.entries = entries; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/filterObject.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/filterObject.d.ts new file mode 100644 index 00000000000..6ac9051d1b5 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/filterObject.d.ts @@ -0,0 +1 @@ +export declare function filterObject(obj: T, keysToInclude: K[]): Pick; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/filterObject.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/filterObject.js new file mode 100644 index 00000000000..e54657c95f2 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/filterObject.js @@ -0,0 +1,14 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.filterObject = void 0; +function filterObject(obj, keysToInclude) { + const keysToIncludeSet = new Set(keysToInclude); + return Object.entries(obj).reduce((acc, [key, value]) => { + if (keysToIncludeSet.has(key)) { + acc[key] = value; + } + return acc; + // eslint-disable-next-line @typescript-eslint/prefer-reduce-type-parameter + }, {}); +} +exports.filterObject = filterObject; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/getErrorMessageForIncorrectType.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/getErrorMessageForIncorrectType.d.ts new file mode 100644 index 00000000000..396f11f768f --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/getErrorMessageForIncorrectType.d.ts @@ -0,0 +1 @@ +export declare function getErrorMessageForIncorrectType(value: unknown, expectedType: string): string; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/getErrorMessageForIncorrectType.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/getErrorMessageForIncorrectType.js new file mode 100644 index 00000000000..82dbf6005db --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/getErrorMessageForIncorrectType.js @@ -0,0 +1,28 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getErrorMessageForIncorrectType = void 0; +function getErrorMessageForIncorrectType(value, expectedType) { + return `Expected ${expectedType}. Received ${getTypeAsString(value)}.`; +} +exports.getErrorMessageForIncorrectType = getErrorMessageForIncorrectType; +function getTypeAsString(value) { + if (Array.isArray(value)) { + return "list"; + } + if (value === null) { + return "null"; + } + if (value instanceof BigInt) { + return "BigInt"; + } + switch (typeof value) { + case "string": + return `"${value}"`; + case "bigint": + case "number": + case "boolean": + case "undefined": + return `${value}`; + } + return typeof value; +} diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/isPlainObject.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/isPlainObject.d.ts new file mode 100644 index 00000000000..d35eee6b671 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/isPlainObject.d.ts @@ -0,0 +1 @@ +export declare function isPlainObject(value: unknown): value is Record; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/isPlainObject.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/isPlainObject.js new file mode 100644 index 00000000000..69594242d4c --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/isPlainObject.js @@ -0,0 +1,18 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.isPlainObject = void 0; +// borrowed from https://github.com/lodash/lodash/blob/master/isPlainObject.js +function isPlainObject(value) { + if (typeof value !== "object" || value === null) { + return false; + } + if (Object.getPrototypeOf(value) === null) { + return true; + } + let proto = value; + while (Object.getPrototypeOf(proto) !== null) { + proto = Object.getPrototypeOf(proto); + } + return Object.getPrototypeOf(value) === proto; +} +exports.isPlainObject = isPlainObject; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/keys.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/keys.d.ts new file mode 100644 index 00000000000..375c673c009 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/keys.d.ts @@ -0,0 +1 @@ +export declare function keys(object: T): (keyof T)[]; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/keys.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/keys.js new file mode 100644 index 00000000000..8dbeb0fd754 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/keys.js @@ -0,0 +1,7 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.keys = void 0; +function keys(object) { + return Object.keys(object); +} +exports.keys = keys; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/maybeSkipValidation.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/maybeSkipValidation.d.ts new file mode 100644 index 00000000000..3b0dc64cab3 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/maybeSkipValidation.d.ts @@ -0,0 +1,2 @@ +import { BaseSchema } from "../Schema"; +export declare function maybeSkipValidation, Raw, Parsed>(schema: S): S; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/maybeSkipValidation.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/maybeSkipValidation.js new file mode 100644 index 00000000000..8aa9556e395 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/maybeSkipValidation.js @@ -0,0 +1,28 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.maybeSkipValidation = void 0; +function maybeSkipValidation(schema) { + return Object.assign(Object.assign({}, schema), { json: transformAndMaybeSkipValidation(schema.json), parse: transformAndMaybeSkipValidation(schema.parse) }); +} +exports.maybeSkipValidation = maybeSkipValidation; +function transformAndMaybeSkipValidation(transform) { + return (value, opts) => { + const transformed = transform(value, opts); + const { skipValidation = false } = opts !== null && opts !== void 0 ? opts : {}; + if (!transformed.ok && skipValidation) { + // eslint-disable-next-line no-console + console.warn([ + "Failed to validate.", + ...transformed.errors.map((error) => " - " + + (error.path.length > 0 ? `${error.path.join(".")}: ${error.message}` : error.message)), + ].join("\n")); + return { + ok: true, + value: value, + }; + } + else { + return transformed; + } + }; +} diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/partition.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/partition.d.ts new file mode 100644 index 00000000000..d091e48ebf4 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/partition.d.ts @@ -0,0 +1 @@ +export declare function partition(items: readonly T[], predicate: (item: T) => boolean): [T[], T[]]; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/partition.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/partition.js new file mode 100644 index 00000000000..fa9e5fde56d --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/schemas/utils/partition.js @@ -0,0 +1,16 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.partition = void 0; +function partition(items, predicate) { + const trueItems = [], falseItems = []; + for (const item of items) { + if (predicate(item)) { + trueItems.push(item); + } + else { + falseItems.push(item); + } + } + return [trueItems, falseItems]; +} +exports.partition = partition; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/streaming-fetcher/Stream.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/streaming-fetcher/Stream.d.ts new file mode 100644 index 00000000000..60ce88f75e0 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/streaming-fetcher/Stream.d.ts @@ -0,0 +1,48 @@ +/// +import { Readable } from "stream"; +export declare namespace Stream { + interface Args { + /** + * The HTTP response stream to read from. + */ + stream: Readable | ReadableStream; + /** + * The event shape to use for parsing the stream data. + */ + eventShape: JsonEvent | SseEvent; + /** + * An abort signal to stop the stream. + */ + signal?: AbortSignal; + } + interface JsonEvent { + type: "json"; + messageTerminator: string; + } + interface SseEvent { + type: "sse"; + streamTerminator?: string; + } +} +export declare class Stream implements AsyncIterable { + private stream; + private parse; + /** + * The prefix to use for each message. For example, + * for SSE, the prefix is "data: ". + */ + private prefix; + private messageTerminator; + private streamTerminator; + private controller; + constructor({ stream, parse, eventShape, signal }: Stream.Args & { + parse: (val: unknown) => Promise; + }); + private iterMessages; + [Symbol.asyncIterator](): AsyncIterator; + private decodeChunk; +} +/** + * Browser polyfill for ReadableStream + */ +export declare function readableStreamAsyncIterable(stream: any): AsyncIterableIterator; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/streaming-fetcher/Stream.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/streaming-fetcher/Stream.js new file mode 100644 index 00000000000..c7dd82d9b06 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/streaming-fetcher/Stream.js @@ -0,0 +1,170 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __asyncValues = (this && this.__asyncValues) || function (o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } +}; +var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), i, q = []; + return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.readableStreamAsyncIterable = exports.Stream = void 0; +const runtime_1 = require("../runtime"); +const DATA_PREFIX = "data:"; +class Stream { + constructor({ stream, parse, eventShape, signal }) { + this.controller = new AbortController(); + this.stream = stream; + this.parse = parse; + if (eventShape.type === "sse") { + this.prefix = DATA_PREFIX; + this.messageTerminator = "\n"; + this.streamTerminator = eventShape.streamTerminator; + } + else { + this.messageTerminator = eventShape.messageTerminator; + } + signal === null || signal === void 0 ? void 0 : signal.addEventListener("abort", () => this.controller.abort()); + } + iterMessages() { + return __asyncGenerator(this, arguments, function* iterMessages_1() { + var e_1, _a; + this.controller.signal; + const stream = readableStreamAsyncIterable(this.stream); + let buf = ""; + let prefixSeen = false; + try { + for (var stream_1 = __asyncValues(stream), stream_1_1; stream_1_1 = yield __await(stream_1.next()), !stream_1_1.done;) { + const chunk = stream_1_1.value; + buf += this.decodeChunk(chunk); + let terminatorIndex; + // Parse the chunk into as many messages as possible + while ((terminatorIndex = buf.indexOf(this.messageTerminator)) >= 0) { + // Extract the line from the buffer + let line = buf.slice(0, terminatorIndex + 1); + buf = buf.slice(terminatorIndex + 1); + // Skip empty lines + if (line.length === 0) { + continue; + } + // Skip the chunk until the prefix is found + if (!prefixSeen && this.prefix != null) { + const prefixIndex = line.indexOf(this.prefix); + if (prefixIndex === -1) { + continue; + } + prefixSeen = true; + line = line.slice(prefixIndex + this.prefix.length); + } + // If the stream terminator is present, return + if (this.streamTerminator != null && line.includes(this.streamTerminator)) { + return yield __await(void 0); + } + // Otherwise, yield message from the prefix to the terminator + const message = yield __await(this.parse(JSON.parse(line))); + yield yield __await(message); + prefixSeen = false; + } + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (stream_1_1 && !stream_1_1.done && (_a = stream_1.return)) yield __await(_a.call(stream_1)); + } + finally { if (e_1) throw e_1.error; } + } + }); + } + [Symbol.asyncIterator]() { + return __asyncGenerator(this, arguments, function* _a() { + var e_2, _b; + try { + for (var _c = __asyncValues(this.iterMessages()), _d; _d = yield __await(_c.next()), !_d.done;) { + const message = _d.value; + yield yield __await(message); + } + } + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (_d && !_d.done && (_b = _c.return)) yield __await(_b.call(_c)); + } + finally { if (e_2) throw e_2.error; } + } + }); + } + decodeChunk(chunk) { + let decoded = ""; + // If TextDecoder is present, use it + if (typeof TextDecoder !== "undefined") { + const decoder = new TextDecoder("utf8"); + decoded += decoder.decode(chunk); + } + // Buffer is present in Node.js environment + else if (runtime_1.RUNTIME.type === "node" && typeof chunk != "undefined") { + decoded += Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk); + } + return decoded; + } +} +exports.Stream = Stream; +/** + * Browser polyfill for ReadableStream + */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function readableStreamAsyncIterable(stream) { + if (stream[Symbol.asyncIterator]) { + return stream; + } + const reader = stream.getReader(); + return { + next() { + return __awaiter(this, void 0, void 0, function* () { + try { + const result = yield reader.read(); + if (result === null || result === void 0 ? void 0 : result.done) { + reader.releaseLock(); + } // release lock when stream becomes closed + return result; + } + catch (e) { + reader.releaseLock(); // release lock when stream becomes errored + throw e; + } + }); + }, + return() { + return __awaiter(this, void 0, void 0, function* () { + const cancelPromise = reader.cancel(); + reader.releaseLock(); + yield cancelPromise; + return { done: true, value: undefined }; + }); + }, + [Symbol.asyncIterator]() { + return this; + }, + }; +} +exports.readableStreamAsyncIterable = readableStreamAsyncIterable; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/streaming-fetcher/index.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/core/streaming-fetcher/index.d.ts new file mode 100644 index 00000000000..7cbb4d156fc --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/streaming-fetcher/index.d.ts @@ -0,0 +1 @@ +export { Stream } from "./Stream"; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/core/streaming-fetcher/index.js b/seed/ts-sdk/streaming/no-serde-layer/dist/core/streaming-fetcher/index.js new file mode 100644 index 00000000000..63a00330ede --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/core/streaming-fetcher/index.js @@ -0,0 +1,5 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Stream = void 0; +var Stream_1 = require("./Stream"); +Object.defineProperty(exports, "Stream", { enumerable: true, get: function () { return Stream_1.Stream; } }); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/errors/SeedStreamingError.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/errors/SeedStreamingError.d.ts new file mode 100644 index 00000000000..7112e1bc022 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/errors/SeedStreamingError.d.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +export declare class SeedStreamingError extends Error { + readonly statusCode?: number; + readonly body?: unknown; + constructor({ message, statusCode, body }: { + message?: string; + statusCode?: number; + body?: unknown; + }); +} diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/errors/SeedStreamingError.js b/seed/ts-sdk/streaming/no-serde-layer/dist/errors/SeedStreamingError.js new file mode 100644 index 00000000000..2efe786b8d9 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/errors/SeedStreamingError.js @@ -0,0 +1,32 @@ +"use strict"; +/** + * This file was auto-generated by Fern from our API Definition. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SeedStreamingError = void 0; +class SeedStreamingError extends Error { + constructor({ message, statusCode, body }) { + super(buildMessage({ message, statusCode, body })); + Object.setPrototypeOf(this, SeedStreamingError.prototype); + if (statusCode != null) { + this.statusCode = statusCode; + } + if (body !== undefined) { + this.body = body; + } + } +} +exports.SeedStreamingError = SeedStreamingError; +function buildMessage({ message, statusCode, body, }) { + let lines = []; + if (message != null) { + lines.push(message); + } + if (statusCode != null) { + lines.push(`Status code: ${statusCode.toString()}`); + } + if (body != null) { + lines.push(`Body: ${JSON.stringify(body, undefined, 2)}`); + } + return lines.join("\n"); +} diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/errors/SeedStreamingTimeoutError.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/errors/SeedStreamingTimeoutError.d.ts new file mode 100644 index 00000000000..b8b9cd305ad --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/errors/SeedStreamingTimeoutError.d.ts @@ -0,0 +1,6 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +export declare class SeedStreamingTimeoutError extends Error { + constructor(message: string); +} diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/errors/SeedStreamingTimeoutError.js b/seed/ts-sdk/streaming/no-serde-layer/dist/errors/SeedStreamingTimeoutError.js new file mode 100644 index 00000000000..3bc0488dae3 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/errors/SeedStreamingTimeoutError.js @@ -0,0 +1,13 @@ +"use strict"; +/** + * This file was auto-generated by Fern from our API Definition. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SeedStreamingTimeoutError = void 0; +class SeedStreamingTimeoutError extends Error { + constructor(message) { + super(message); + Object.setPrototypeOf(this, SeedStreamingTimeoutError.prototype); + } +} +exports.SeedStreamingTimeoutError = SeedStreamingTimeoutError; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/errors/index.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/errors/index.d.ts new file mode 100644 index 00000000000..e145481dbf4 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/errors/index.d.ts @@ -0,0 +1,2 @@ +export { SeedStreamingError } from "./SeedStreamingError"; +export { SeedStreamingTimeoutError } from "./SeedStreamingTimeoutError"; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/errors/index.js b/seed/ts-sdk/streaming/no-serde-layer/dist/errors/index.js new file mode 100644 index 00000000000..e895b8e3d1c --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/errors/index.js @@ -0,0 +1,7 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SeedStreamingTimeoutError = exports.SeedStreamingError = void 0; +var SeedStreamingError_1 = require("./SeedStreamingError"); +Object.defineProperty(exports, "SeedStreamingError", { enumerable: true, get: function () { return SeedStreamingError_1.SeedStreamingError; } }); +var SeedStreamingTimeoutError_1 = require("./SeedStreamingTimeoutError"); +Object.defineProperty(exports, "SeedStreamingTimeoutError", { enumerable: true, get: function () { return SeedStreamingTimeoutError_1.SeedStreamingTimeoutError; } }); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/index.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/index.d.ts new file mode 100644 index 00000000000..96a115e39ca --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/index.d.ts @@ -0,0 +1,3 @@ +export * as SeedStreaming from "./api"; +export { SeedStreamingClient } from "./Client"; +export { SeedStreamingError, SeedStreamingTimeoutError } from "./errors"; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/index.js b/seed/ts-sdk/streaming/no-serde-layer/dist/index.js new file mode 100644 index 00000000000..7d85b021959 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/index.js @@ -0,0 +1,32 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SeedStreamingTimeoutError = exports.SeedStreamingError = exports.SeedStreamingClient = exports.SeedStreaming = void 0; +exports.SeedStreaming = __importStar(require("./api")); +var Client_1 = require("./Client"); +Object.defineProperty(exports, "SeedStreamingClient", { enumerable: true, get: function () { return Client_1.SeedStreamingClient; } }); +var errors_1 = require("./errors"); +Object.defineProperty(exports, "SeedStreamingError", { enumerable: true, get: function () { return errors_1.SeedStreamingError; } }); +Object.defineProperty(exports, "SeedStreamingTimeoutError", { enumerable: true, get: function () { return errors_1.SeedStreamingTimeoutError; } }); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/index.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/index.d.ts new file mode 100644 index 00000000000..3e5335fe421 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/index.d.ts @@ -0,0 +1 @@ +export * from "./resources"; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/index.js b/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/index.js new file mode 100644 index 00000000000..b88cbd1080b --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/index.js @@ -0,0 +1,17 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +__exportStar(require("./resources"), exports); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/client/index.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/client/index.d.ts new file mode 100644 index 00000000000..415726b7fea --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/client/index.d.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/client/index.js b/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/client/index.js new file mode 100644 index 00000000000..6df4ebb9efc --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/client/index.js @@ -0,0 +1,17 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +__exportStar(require("./requests"), exports); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/client/requests/GenerateStreamRequest.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/client/requests/GenerateStreamRequest.d.ts new file mode 100644 index 00000000000..4386b213ada --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/client/requests/GenerateStreamRequest.d.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +import * as serializers from "../../../../index"; +import * as SeedStreaming from "../../../../../api/index"; +import * as core from "../../../../../core"; +export declare const GenerateStreamRequest: core.serialization.Schema; +export declare namespace GenerateStreamRequest { + interface Raw { + num_events: number; + } +} diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/client/requests/GenerateStreamRequest.js b/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/client/requests/GenerateStreamRequest.js new file mode 100644 index 00000000000..6a645848a6b --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/client/requests/GenerateStreamRequest.js @@ -0,0 +1,33 @@ +"use strict"; +/** + * This file was auto-generated by Fern from our API Definition. + */ +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.GenerateStreamRequest = void 0; +const core = __importStar(require("../../../../../core")); +exports.GenerateStreamRequest = core.serialization.object({ + numEvents: core.serialization.property("num_events", core.serialization.number()), +}); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/client/requests/Generateequest.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/client/requests/Generateequest.d.ts new file mode 100644 index 00000000000..5965e56eb44 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/client/requests/Generateequest.d.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +import * as serializers from "../../../../index"; +import * as SeedStreaming from "../../../../../api/index"; +import * as core from "../../../../../core"; +export declare const Generateequest: core.serialization.Schema; +export declare namespace Generateequest { + interface Raw { + num_events: number; + } +} diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/client/requests/Generateequest.js b/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/client/requests/Generateequest.js new file mode 100644 index 00000000000..dc415151be5 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/client/requests/Generateequest.js @@ -0,0 +1,33 @@ +"use strict"; +/** + * This file was auto-generated by Fern from our API Definition. + */ +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Generateequest = void 0; +const core = __importStar(require("../../../../../core")); +exports.Generateequest = core.serialization.object({ + numEvents: core.serialization.property("num_events", core.serialization.number()), +}); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/client/requests/index.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/client/requests/index.d.ts new file mode 100644 index 00000000000..952e9fbd60d --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/client/requests/index.d.ts @@ -0,0 +1,2 @@ +export { GenerateStreamRequest } from "./GenerateStreamRequest"; +export { Generateequest } from "./Generateequest"; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/client/requests/index.js b/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/client/requests/index.js new file mode 100644 index 00000000000..7f06833269a --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/client/requests/index.js @@ -0,0 +1,7 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Generateequest = exports.GenerateStreamRequest = void 0; +var GenerateStreamRequest_1 = require("./GenerateStreamRequest"); +Object.defineProperty(exports, "GenerateStreamRequest", { enumerable: true, get: function () { return GenerateStreamRequest_1.GenerateStreamRequest; } }); +var Generateequest_1 = require("./Generateequest"); +Object.defineProperty(exports, "Generateequest", { enumerable: true, get: function () { return Generateequest_1.Generateequest; } }); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/index.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/index.d.ts new file mode 100644 index 00000000000..c9240f83b48 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/index.d.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./client"; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/index.js b/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/index.js new file mode 100644 index 00000000000..88ae7e19dce --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/index.js @@ -0,0 +1,18 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +__exportStar(require("./types"), exports); +__exportStar(require("./client"), exports); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/types/StreamResponse.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/types/StreamResponse.d.ts new file mode 100644 index 00000000000..2d099cef1cf --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/types/StreamResponse.d.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +import * as serializers from "../../../index"; +import * as SeedStreaming from "../../../../api/index"; +import * as core from "../../../../core"; +export declare const StreamResponse: core.serialization.ObjectSchema; +export declare namespace StreamResponse { + interface Raw { + id: string; + name?: string | null; + } +} diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/types/StreamResponse.js b/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/types/StreamResponse.js new file mode 100644 index 00000000000..4bd61a87bc8 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/types/StreamResponse.js @@ -0,0 +1,34 @@ +"use strict"; +/** + * This file was auto-generated by Fern from our API Definition. + */ +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.StreamResponse = void 0; +const core = __importStar(require("../../../../core")); +exports.StreamResponse = core.serialization.object({ + id: core.serialization.string(), + name: core.serialization.string().optional(), +}); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/types/index.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/types/index.d.ts new file mode 100644 index 00000000000..7fff739f1bd --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/types/index.d.ts @@ -0,0 +1 @@ +export * from "./StreamResponse"; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/types/index.js b/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/types/index.js new file mode 100644 index 00000000000..386bf7a27fe --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/dummy/types/index.js @@ -0,0 +1,17 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +__exportStar(require("./StreamResponse"), exports); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/index.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/index.d.ts new file mode 100644 index 00000000000..77295c8c70d --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/index.d.ts @@ -0,0 +1,3 @@ +export * as dummy from "./dummy"; +export * from "./dummy/types"; +export * from "./dummy/client/requests"; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/index.js b/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/index.js new file mode 100644 index 00000000000..57694533bd4 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/serialization/resources/index.js @@ -0,0 +1,32 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.dummy = void 0; +exports.dummy = __importStar(require("./dummy")); +__exportStar(require("./dummy/types"), exports); +__exportStar(require("./dummy/client/requests"), exports); diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/version.d.ts b/seed/ts-sdk/streaming/no-serde-layer/dist/version.d.ts new file mode 100644 index 00000000000..9329a4edb73 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/version.d.ts @@ -0,0 +1 @@ +export declare const SDK_VERSION = "0.0.1"; diff --git a/seed/ts-sdk/streaming/no-serde-layer/dist/version.js b/seed/ts-sdk/streaming/no-serde-layer/dist/version.js new file mode 100644 index 00000000000..45bf23c75a1 --- /dev/null +++ b/seed/ts-sdk/streaming/no-serde-layer/dist/version.js @@ -0,0 +1,4 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SDK_VERSION = void 0; +exports.SDK_VERSION = "0.0.1"; From 866903fb2be4afbef5942e84f7c1124de6cc6941 Mon Sep 17 00:00:00 2001 From: dsinghvi Date: Fri, 13 Dec 2024 20:07:49 -0500 Subject: [PATCH 6/7] add versions.yml --- packages/cli/cli/versions.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/packages/cli/cli/versions.yml b/packages/cli/cli/versions.yml index f289eff7a57..61f88673cdf 100644 --- a/packages/cli/cli/versions.yml +++ b/packages/cli/cli/versions.yml @@ -1,3 +1,29 @@ +- changelogEntry: + - summary: | + The Fern CLI now supports parsing a `logo` option from your frontmatter. If + you would like to override logo on a specific page you can do so by adding + the following: + + ```markdown intro.mdx + --- + logo: /path/to/my/logo + --- + ``` + + or + + ```markdown intro.mdx + --- + logo: + light: /path/to/my/light/logo + dark: /path/to/my/dark/logo + --- + ``` + + type: feature + irVersion: 53 + version: 0.46.2 + - changelogEntry: - summary: | Add support for setting the `User-Agent` header value for Go generators. From 6e32d4667fc23602a2395eab10c282d8fa3eecfb Mon Sep 17 00:00:00 2001 From: Deep Singhvi Date: Fri, 13 Dec 2024 20:37:18 -0500 Subject: [PATCH 7/7] Update versions.yml --- packages/cli/cli/versions.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/cli/versions.yml b/packages/cli/cli/versions.yml index 61f88673cdf..e29058c9734 100644 --- a/packages/cli/cli/versions.yml +++ b/packages/cli/cli/versions.yml @@ -20,7 +20,7 @@ --- ``` - type: feature + type: feat irVersion: 53 version: 0.46.2