@elevasis/sdk 1.53.0 → 1.55.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-FUOIYRIZ.js → chunk-72ZGICTR.js} +304 -71
- package/dist/{chunk-HB7DC5LT.js → chunk-QF2RNYYX.js} +1 -8
- package/dist/{chunk-B2KAVPNB.js → chunk-R3J6BEPO.js} +116 -2069
- package/dist/cli.cjs +477 -362
- package/dist/index.d.ts +142 -49
- package/dist/index.js +2 -2
- package/dist/node/index.js +1 -1
- package/dist/test-utils/index.js +5 -3
- package/dist/worker/index.d.ts +11 -2
- package/dist/worker/index.js +3 -3
- package/package.json +14 -6
- package/reference/_navigation.md +1 -1
- package/reference/packages/core/src/knowledge/README.md +1 -1
- package/reference/scaffold/core/organization-model.mdx +1 -1
- package/reference/scaffold/recipes/extend-lead-gen.md +2 -1
- package/reference/scaffold/reference/contracts.md +239 -226
- package/reference/sdk/cli-management.mdx +2 -0
- package/reference/sdk/define-builders.mdx +28 -15
- package/reference/sdk/exports.mdx +1 -1
- package/reference/sdk/index.mdx +1 -1
- package/reference/sdk/platform-tools/adapters-platform.mdx +1 -1
- package/reference/sdk/project-deployment-spec.mdx +17 -1
|
@@ -1,19 +1,33 @@
|
|
|
1
|
-
import { __require } from './chunk-HB7DC5LT.js';
|
|
2
1
|
import { z, ZodError } from 'zod';
|
|
2
|
+
import { zodToJsonSchema } from '@alcyone-labs/zod-to-json-schema';
|
|
3
3
|
|
|
4
4
|
// src/define-contract.ts
|
|
5
5
|
function defineContract(contract) {
|
|
6
6
|
return contract;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
// src/define-step.ts
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
// src/define-single-step-workflow.ts
|
|
10
|
+
function defineSingleStepWorkflow(options) {
|
|
11
|
+
const { config, inputSchema, outputSchema, step, ...optional } = options;
|
|
12
|
+
const workflowStep = {
|
|
13
|
+
id: step.id,
|
|
14
|
+
name: step.name,
|
|
15
|
+
description: step.description,
|
|
16
|
+
inputSchema,
|
|
17
|
+
outputSchema,
|
|
18
|
+
// The engine validates `rawInput` against this same `inputSchema` before invoking the
|
|
19
|
+
// handler (see `Workflow.execute`), so the cast here is safe -- it is the one place that
|
|
20
|
+
// ceremony now lives, instead of at every workflow's handler body.
|
|
21
|
+
handler: (async (rawInput, context) => step.handler(rawInput, context)),
|
|
22
|
+
next: null
|
|
23
|
+
};
|
|
24
|
+
return {
|
|
25
|
+
config,
|
|
26
|
+
contract: { inputSchema, outputSchema },
|
|
27
|
+
steps: { [step.id]: workflowStep },
|
|
28
|
+
entryPoint: step.id,
|
|
29
|
+
...optional
|
|
30
|
+
};
|
|
17
31
|
}
|
|
18
32
|
var OntologyKindSchema = z.enum([
|
|
19
33
|
"object",
|
|
@@ -800,14 +814,25 @@ var SystemEntrySchema = z.object({
|
|
|
800
814
|
* position-derived paths. Both still exist on this schema for backward compat.
|
|
801
815
|
*/
|
|
802
816
|
systems: z.lazy(() => z.record(z.string().trim().min(1).max(100), SystemEntrySchema)).optional(),
|
|
803
|
-
/**
|
|
817
|
+
/**
|
|
818
|
+
* @deprecated Use systems. Accepted as a compatibility alias during the ontology bridge.
|
|
819
|
+
*
|
|
820
|
+
* Accepted on INPUT only. Parsing used to mirror `systems` into this key so that
|
|
821
|
+
* either spelling could be read off a parsed model, which meant every parsed System
|
|
822
|
+
* carried the same children twice. Readers that walked both keys then visited each
|
|
823
|
+
* nested System twice -- `getOrgOsRouteContractSystems` reported 11 checked paths
|
|
824
|
+
* against command-center's 7 real Systems and would have raised every nested-System
|
|
825
|
+
* failure as two failures -- and readers that walked this key alone looked correct
|
|
826
|
+
* while depending entirely on the mirror. Both defects were live. The mirror is gone:
|
|
827
|
+
* a parsed model now carries children under whichever key the author wrote, so read
|
|
828
|
+
* `system.systems ?? system.subsystems` (helpers.ts, validation.ts, ontology.ts,
|
|
829
|
+
* selectDeclaredSystems.ts, validateManifests.ts and SystemOpsView.tsx all do).
|
|
830
|
+
*/
|
|
804
831
|
subsystems: z.lazy(() => z.record(z.string().trim().min(1).max(100), SystemEntrySchema)).optional()
|
|
805
832
|
}).strict().refine((system) => system.label !== void 0 || system.title !== void 0, {
|
|
806
833
|
path: ["label"],
|
|
807
834
|
message: "System must provide label or title"
|
|
808
|
-
})
|
|
809
|
-
(system) => system.systems !== void 0 && system.subsystems === void 0 ? { ...system, subsystems: system.systems } : system
|
|
810
|
-
);
|
|
835
|
+
});
|
|
811
836
|
z.record(z.string(), SystemEntrySchema).refine((record) => Object.entries(record).every(([key, entry]) => entry.id === key), {
|
|
812
837
|
message: "Each system entry id must match its map key"
|
|
813
838
|
}).default({});
|
|
@@ -1722,6 +1747,29 @@ var ToolingError = class extends ExecutionError {
|
|
|
1722
1747
|
this.details = details;
|
|
1723
1748
|
}
|
|
1724
1749
|
};
|
|
1750
|
+
|
|
1751
|
+
// ../core/src/platform/utils/concurrency.ts
|
|
1752
|
+
async function allSettledWithConcurrency(items, limit, task) {
|
|
1753
|
+
if (items.length === 0) return [];
|
|
1754
|
+
const bound = Math.max(1, Math.floor(limit));
|
|
1755
|
+
if (bound >= items.length) {
|
|
1756
|
+
return Promise.allSettled(items.map((item, index) => task(item, index)));
|
|
1757
|
+
}
|
|
1758
|
+
const results = new Array(items.length);
|
|
1759
|
+
let cursor = 0;
|
|
1760
|
+
const worker = async () => {
|
|
1761
|
+
while (cursor < items.length) {
|
|
1762
|
+
const index = cursor++;
|
|
1763
|
+
try {
|
|
1764
|
+
results[index] = { status: "fulfilled", value: await task(items[index], index) };
|
|
1765
|
+
} catch (reason) {
|
|
1766
|
+
results[index] = { status: "rejected", reason };
|
|
1767
|
+
}
|
|
1768
|
+
}
|
|
1769
|
+
};
|
|
1770
|
+
await Promise.all(Array.from({ length: bound }, worker));
|
|
1771
|
+
return results;
|
|
1772
|
+
}
|
|
1725
1773
|
function errorToString(error) {
|
|
1726
1774
|
if (error instanceof ZodError) {
|
|
1727
1775
|
return JSON.stringify(error.issues, null, 2);
|
|
@@ -1771,6 +1819,14 @@ z.object({
|
|
|
1771
1819
|
limit: z.coerce.number().int().min(1).max(100).default(20),
|
|
1772
1820
|
offset: z.coerce.number().int().min(0).default(0)
|
|
1773
1821
|
});
|
|
1822
|
+
var DEFAULT_PAGE_LIMIT = 50;
|
|
1823
|
+
var MAX_PAGE_LIMIT = 100;
|
|
1824
|
+
var PageLimitSchema = z.coerce.number().int().min(1).max(MAX_PAGE_LIMIT);
|
|
1825
|
+
var PageOffsetSchema = z.coerce.number().int().min(0).default(0);
|
|
1826
|
+
z.object({
|
|
1827
|
+
limit: PageLimitSchema.default(DEFAULT_PAGE_LIMIT),
|
|
1828
|
+
offset: PageOffsetSchema
|
|
1829
|
+
});
|
|
1774
1830
|
z.string().datetime();
|
|
1775
1831
|
z.object({
|
|
1776
1832
|
startDate: z.string().datetime(),
|
|
@@ -1784,2058 +1840,6 @@ function isReservedResourceId(resourceId) {
|
|
|
1784
1840
|
return RESERVED_RESOURCE_IDS.has(resourceId);
|
|
1785
1841
|
}
|
|
1786
1842
|
|
|
1787
|
-
// ../../node_modules/.pnpm/@alcyone-labs+zod-to-json-schema@4.0.10_zod@4.1.12/node_modules/@alcyone-labs/zod-to-json-schema/dist/esm/Options.js
|
|
1788
|
-
var ignoreOverride = /* @__PURE__ */ Symbol("Let zodToJsonSchema decide on which parser to use");
|
|
1789
|
-
var defaultOptions = {
|
|
1790
|
-
name: void 0,
|
|
1791
|
-
$refStrategy: "root",
|
|
1792
|
-
basePath: ["#"],
|
|
1793
|
-
effectStrategy: "input",
|
|
1794
|
-
pipeStrategy: "all",
|
|
1795
|
-
dateStrategy: "format:date-time",
|
|
1796
|
-
mapStrategy: "entries",
|
|
1797
|
-
removeAdditionalStrategy: "passthrough",
|
|
1798
|
-
allowedAdditionalProperties: true,
|
|
1799
|
-
rejectedAdditionalProperties: false,
|
|
1800
|
-
definitionPath: "definitions",
|
|
1801
|
-
target: "jsonSchema7",
|
|
1802
|
-
strictUnions: false,
|
|
1803
|
-
definitions: {},
|
|
1804
|
-
errorMessages: false,
|
|
1805
|
-
markdownDescription: false,
|
|
1806
|
-
patternStrategy: "escape",
|
|
1807
|
-
applyRegexFlags: false,
|
|
1808
|
-
emailStrategy: "format:email",
|
|
1809
|
-
base64Strategy: "contentEncoding:base64",
|
|
1810
|
-
nameStrategy: "ref",
|
|
1811
|
-
openAiAnyTypeName: "OpenAiAnyType"
|
|
1812
|
-
};
|
|
1813
|
-
var getDefaultOptions = (options) => typeof options === "string" ? {
|
|
1814
|
-
...defaultOptions,
|
|
1815
|
-
name: options
|
|
1816
|
-
} : {
|
|
1817
|
-
...defaultOptions,
|
|
1818
|
-
...options
|
|
1819
|
-
};
|
|
1820
|
-
|
|
1821
|
-
// ../../node_modules/.pnpm/@alcyone-labs+zod-to-json-schema@4.0.10_zod@4.1.12/node_modules/@alcyone-labs/zod-to-json-schema/dist/esm/Refs.js
|
|
1822
|
-
var getRefs = (options) => {
|
|
1823
|
-
const _options = getDefaultOptions(options);
|
|
1824
|
-
const currentPath = _options.name !== void 0 ? [..._options.basePath, _options.definitionPath, _options.name] : _options.basePath;
|
|
1825
|
-
return {
|
|
1826
|
-
..._options,
|
|
1827
|
-
flags: { hasReferencedOpenAiAnyType: false },
|
|
1828
|
-
currentPath,
|
|
1829
|
-
propertyPath: void 0,
|
|
1830
|
-
seen: new Map(Object.entries(_options.definitions).map(([name, def]) => [
|
|
1831
|
-
def._def,
|
|
1832
|
-
{
|
|
1833
|
-
def: def._def,
|
|
1834
|
-
path: [..._options.basePath, _options.definitionPath, name],
|
|
1835
|
-
// Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
|
|
1836
|
-
jsonSchema: void 0
|
|
1837
|
-
}
|
|
1838
|
-
]))
|
|
1839
|
-
};
|
|
1840
|
-
};
|
|
1841
|
-
|
|
1842
|
-
// ../../node_modules/.pnpm/@alcyone-labs+zod-to-json-schema@4.0.10_zod@4.1.12/node_modules/@alcyone-labs/zod-to-json-schema/dist/esm/errorMessages.js
|
|
1843
|
-
function addErrorMessage(res, key, errorMessage, refs) {
|
|
1844
|
-
if (!refs?.errorMessages)
|
|
1845
|
-
return;
|
|
1846
|
-
if (errorMessage) {
|
|
1847
|
-
res.errorMessage = {
|
|
1848
|
-
...res.errorMessage,
|
|
1849
|
-
[key]: errorMessage
|
|
1850
|
-
};
|
|
1851
|
-
}
|
|
1852
|
-
}
|
|
1853
|
-
function setResponseValueAndErrors(res, key, value, errorMessage, refs) {
|
|
1854
|
-
res[key] = value;
|
|
1855
|
-
addErrorMessage(res, key, errorMessage, refs);
|
|
1856
|
-
}
|
|
1857
|
-
|
|
1858
|
-
// ../../node_modules/.pnpm/@alcyone-labs+zod-to-json-schema@4.0.10_zod@4.1.12/node_modules/@alcyone-labs/zod-to-json-schema/dist/esm/getRelativePath.js
|
|
1859
|
-
var getRelativePath = (pathA, pathB) => {
|
|
1860
|
-
let i = 0;
|
|
1861
|
-
for (; i < pathA.length && i < pathB.length; i++) {
|
|
1862
|
-
if (pathA[i] !== pathB[i])
|
|
1863
|
-
break;
|
|
1864
|
-
}
|
|
1865
|
-
return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
|
|
1866
|
-
};
|
|
1867
|
-
|
|
1868
|
-
// ../../node_modules/.pnpm/@alcyone-labs+zod-to-json-schema@4.0.10_zod@4.1.12/node_modules/@alcyone-labs/zod-to-json-schema/dist/esm/zodV3V4Compat.js
|
|
1869
|
-
var ZodFirstPartyTypeKindFromZod;
|
|
1870
|
-
try {
|
|
1871
|
-
const zodImport = __require("zod");
|
|
1872
|
-
ZodFirstPartyTypeKindFromZod = zodImport.ZodFirstPartyTypeKind;
|
|
1873
|
-
} catch {
|
|
1874
|
-
}
|
|
1875
|
-
var ZodFirstPartyTypeKind = ZodFirstPartyTypeKindFromZod || {
|
|
1876
|
-
ZodNumber: "ZodNumber",
|
|
1877
|
-
ZodBigInt: "ZodBigInt",
|
|
1878
|
-
ZodBoolean: "ZodBoolean",
|
|
1879
|
-
ZodDate: "ZodDate",
|
|
1880
|
-
ZodUndefined: "ZodUndefined",
|
|
1881
|
-
ZodNull: "ZodNull",
|
|
1882
|
-
ZodVoid: "ZodVoid",
|
|
1883
|
-
ZodAny: "ZodAny",
|
|
1884
|
-
ZodUnknown: "ZodUnknown",
|
|
1885
|
-
ZodNever: "ZodNever",
|
|
1886
|
-
ZodArray: "ZodArray",
|
|
1887
|
-
ZodObject: "ZodObject",
|
|
1888
|
-
ZodUnion: "ZodUnion",
|
|
1889
|
-
ZodDiscriminatedUnion: "ZodDiscriminatedUnion",
|
|
1890
|
-
ZodIntersection: "ZodIntersection",
|
|
1891
|
-
ZodTuple: "ZodTuple",
|
|
1892
|
-
ZodRecord: "ZodRecord",
|
|
1893
|
-
ZodMap: "ZodMap",
|
|
1894
|
-
ZodSet: "ZodSet",
|
|
1895
|
-
ZodFunction: "ZodFunction",
|
|
1896
|
-
ZodLazy: "ZodLazy",
|
|
1897
|
-
ZodLiteral: "ZodLiteral",
|
|
1898
|
-
ZodEnum: "ZodEnum",
|
|
1899
|
-
ZodNativeEnum: "ZodNativeEnum",
|
|
1900
|
-
ZodPromise: "ZodPromise",
|
|
1901
|
-
ZodEffects: "ZodEffects",
|
|
1902
|
-
ZodOptional: "ZodOptional",
|
|
1903
|
-
ZodNullable: "ZodNullable",
|
|
1904
|
-
ZodDefault: "ZodDefault",
|
|
1905
|
-
ZodCatch: "ZodCatch",
|
|
1906
|
-
ZodReadonly: "ZodReadonly",
|
|
1907
|
-
ZodBranded: "ZodBranded",
|
|
1908
|
-
ZodPipeline: "ZodPipeline"};
|
|
1909
|
-
function getDefTypeName(def) {
|
|
1910
|
-
return def?.typeName || def?.type;
|
|
1911
|
-
}
|
|
1912
|
-
function getInnerTypeDef(wrapperDef) {
|
|
1913
|
-
if (!wrapperDef?.innerType)
|
|
1914
|
-
return void 0;
|
|
1915
|
-
return wrapperDef.innerType.def || wrapperDef.innerType._def;
|
|
1916
|
-
}
|
|
1917
|
-
function isNullableType(def) {
|
|
1918
|
-
const typeName = getDefTypeName(def);
|
|
1919
|
-
return typeName === "nullable" || typeName === "ZodNullable";
|
|
1920
|
-
}
|
|
1921
|
-
function getAllPrimitiveTypeNames() {
|
|
1922
|
-
return [
|
|
1923
|
-
// V3 names
|
|
1924
|
-
"ZodString",
|
|
1925
|
-
"ZodNumber",
|
|
1926
|
-
"ZodBigInt",
|
|
1927
|
-
"ZodBoolean",
|
|
1928
|
-
"ZodNull",
|
|
1929
|
-
// V4 names
|
|
1930
|
-
"string",
|
|
1931
|
-
"number",
|
|
1932
|
-
"bigint",
|
|
1933
|
-
"boolean",
|
|
1934
|
-
"null"
|
|
1935
|
-
];
|
|
1936
|
-
}
|
|
1937
|
-
function extractMetadata(schema) {
|
|
1938
|
-
let metadata = {};
|
|
1939
|
-
if (schema?._def?.description) {
|
|
1940
|
-
metadata.description = schema._def.description;
|
|
1941
|
-
}
|
|
1942
|
-
if (typeof schema?.meta === "function") {
|
|
1943
|
-
try {
|
|
1944
|
-
const meta = schema.meta();
|
|
1945
|
-
if (meta && typeof meta === "object") {
|
|
1946
|
-
metadata = { ...metadata, ...meta };
|
|
1947
|
-
}
|
|
1948
|
-
} catch {
|
|
1949
|
-
}
|
|
1950
|
-
}
|
|
1951
|
-
if (!metadata.description && schema?.description) {
|
|
1952
|
-
metadata.description = schema.description;
|
|
1953
|
-
}
|
|
1954
|
-
return metadata;
|
|
1955
|
-
}
|
|
1956
|
-
var primitiveMappings = {
|
|
1957
|
-
// V3 mappings
|
|
1958
|
-
ZodString: "string",
|
|
1959
|
-
ZodNumber: "number",
|
|
1960
|
-
ZodBigInt: "string",
|
|
1961
|
-
// BigInt is represented as string in JSON
|
|
1962
|
-
ZodBoolean: "boolean",
|
|
1963
|
-
ZodNull: "null",
|
|
1964
|
-
// V4 mappings
|
|
1965
|
-
string: "string",
|
|
1966
|
-
number: "number",
|
|
1967
|
-
bigint: "string",
|
|
1968
|
-
// BigInt is represented as string in JSON
|
|
1969
|
-
boolean: "boolean",
|
|
1970
|
-
null: "null"
|
|
1971
|
-
};
|
|
1972
|
-
|
|
1973
|
-
// ../../node_modules/.pnpm/@alcyone-labs+zod-to-json-schema@4.0.10_zod@4.1.12/node_modules/@alcyone-labs/zod-to-json-schema/dist/esm/parsers/any.js
|
|
1974
|
-
function parseAnyDef(refs) {
|
|
1975
|
-
if (refs.target !== "openAi") {
|
|
1976
|
-
return {};
|
|
1977
|
-
}
|
|
1978
|
-
const anyDefinitionPath = [
|
|
1979
|
-
...refs.basePath,
|
|
1980
|
-
refs.definitionPath,
|
|
1981
|
-
refs.openAiAnyTypeName
|
|
1982
|
-
];
|
|
1983
|
-
refs.flags.hasReferencedOpenAiAnyType = true;
|
|
1984
|
-
return {
|
|
1985
|
-
$ref: refs.$refStrategy === "relative" ? getRelativePath(anyDefinitionPath, refs.currentPath) : anyDefinitionPath.join("/")
|
|
1986
|
-
};
|
|
1987
|
-
}
|
|
1988
|
-
|
|
1989
|
-
// ../../node_modules/.pnpm/@alcyone-labs+zod-to-json-schema@4.0.10_zod@4.1.12/node_modules/@alcyone-labs/zod-to-json-schema/dist/esm/parsers/array.js
|
|
1990
|
-
function parseArrayDef(def, refs) {
|
|
1991
|
-
const res = {
|
|
1992
|
-
type: "array"
|
|
1993
|
-
};
|
|
1994
|
-
const elementType = def.element || def.type;
|
|
1995
|
-
const elementDef = elementType?.def || elementType?._def;
|
|
1996
|
-
const elementTypeName = elementDef?.type || elementDef?.typeName;
|
|
1997
|
-
if (elementDef && elementTypeName !== "any" && elementTypeName !== "ZodAny") {
|
|
1998
|
-
res.items = parseDef(elementDef, {
|
|
1999
|
-
...refs,
|
|
2000
|
-
currentPath: [...refs.currentPath, "items"]
|
|
2001
|
-
});
|
|
2002
|
-
}
|
|
2003
|
-
if (def.checks) {
|
|
2004
|
-
for (const check of def.checks) {
|
|
2005
|
-
const checkDef = check._zod?.def;
|
|
2006
|
-
if (checkDef) {
|
|
2007
|
-
let message = checkDef.message;
|
|
2008
|
-
if (!message && checkDef.error && typeof checkDef.error === "function") {
|
|
2009
|
-
try {
|
|
2010
|
-
message = checkDef.error();
|
|
2011
|
-
} catch (e) {
|
|
2012
|
-
}
|
|
2013
|
-
}
|
|
2014
|
-
switch (checkDef.check) {
|
|
2015
|
-
case "min_length":
|
|
2016
|
-
setResponseValueAndErrors(res, "minItems", checkDef.minimum, message, refs);
|
|
2017
|
-
break;
|
|
2018
|
-
case "max_length":
|
|
2019
|
-
setResponseValueAndErrors(res, "maxItems", checkDef.maximum, message, refs);
|
|
2020
|
-
break;
|
|
2021
|
-
case "length_equals":
|
|
2022
|
-
const length = checkDef.length;
|
|
2023
|
-
if (length !== void 0) {
|
|
2024
|
-
setResponseValueAndErrors(res, "minItems", length, message, refs);
|
|
2025
|
-
setResponseValueAndErrors(res, "maxItems", length, message, refs);
|
|
2026
|
-
}
|
|
2027
|
-
break;
|
|
2028
|
-
}
|
|
2029
|
-
}
|
|
2030
|
-
}
|
|
2031
|
-
}
|
|
2032
|
-
if (def.minLength) {
|
|
2033
|
-
setResponseValueAndErrors(res, "minItems", def.minLength.value, def.minLength.message, refs);
|
|
2034
|
-
}
|
|
2035
|
-
if (def.maxLength) {
|
|
2036
|
-
setResponseValueAndErrors(res, "maxItems", def.maxLength.value, def.maxLength.message, refs);
|
|
2037
|
-
}
|
|
2038
|
-
if (def.exactLength) {
|
|
2039
|
-
setResponseValueAndErrors(res, "minItems", def.exactLength.value, def.exactLength.message, refs);
|
|
2040
|
-
setResponseValueAndErrors(res, "maxItems", def.exactLength.value, def.exactLength.message, refs);
|
|
2041
|
-
}
|
|
2042
|
-
return res;
|
|
2043
|
-
}
|
|
2044
|
-
|
|
2045
|
-
// ../../node_modules/.pnpm/@alcyone-labs+zod-to-json-schema@4.0.10_zod@4.1.12/node_modules/@alcyone-labs/zod-to-json-schema/dist/esm/parsers/bigint.js
|
|
2046
|
-
function parseBigintDef(def, refs) {
|
|
2047
|
-
const res = {
|
|
2048
|
-
type: "integer",
|
|
2049
|
-
format: "int64"
|
|
2050
|
-
};
|
|
2051
|
-
if (!def.checks)
|
|
2052
|
-
return res;
|
|
2053
|
-
for (const check of def.checks) {
|
|
2054
|
-
const checkDef = check._zod?.def;
|
|
2055
|
-
if (checkDef) {
|
|
2056
|
-
let message = checkDef.message;
|
|
2057
|
-
if (!message && checkDef.error && typeof checkDef.error === "function") {
|
|
2058
|
-
try {
|
|
2059
|
-
message = checkDef.error();
|
|
2060
|
-
} catch (e) {
|
|
2061
|
-
}
|
|
2062
|
-
}
|
|
2063
|
-
switch (checkDef.check) {
|
|
2064
|
-
case "greater_than":
|
|
2065
|
-
const minValue = checkDef.value;
|
|
2066
|
-
if (refs.target === "jsonSchema7") {
|
|
2067
|
-
if (checkDef.inclusive) {
|
|
2068
|
-
setResponseValueAndErrors(res, "minimum", minValue, message, refs);
|
|
2069
|
-
} else {
|
|
2070
|
-
setResponseValueAndErrors(res, "exclusiveMinimum", minValue, message, refs);
|
|
2071
|
-
}
|
|
2072
|
-
} else {
|
|
2073
|
-
if (!checkDef.inclusive) {
|
|
2074
|
-
res.exclusiveMinimum = true;
|
|
2075
|
-
}
|
|
2076
|
-
setResponseValueAndErrors(res, "minimum", minValue, message, refs);
|
|
2077
|
-
}
|
|
2078
|
-
break;
|
|
2079
|
-
case "less_than":
|
|
2080
|
-
const maxValue = checkDef.value;
|
|
2081
|
-
if (refs.target === "jsonSchema7") {
|
|
2082
|
-
if (checkDef.inclusive) {
|
|
2083
|
-
setResponseValueAndErrors(res, "maximum", maxValue, message, refs);
|
|
2084
|
-
} else {
|
|
2085
|
-
setResponseValueAndErrors(res, "exclusiveMaximum", maxValue, message, refs);
|
|
2086
|
-
}
|
|
2087
|
-
} else {
|
|
2088
|
-
if (!checkDef.inclusive) {
|
|
2089
|
-
res.exclusiveMaximum = true;
|
|
2090
|
-
}
|
|
2091
|
-
setResponseValueAndErrors(res, "maximum", maxValue, message, refs);
|
|
2092
|
-
}
|
|
2093
|
-
break;
|
|
2094
|
-
case "multiple_of":
|
|
2095
|
-
const multipleValue = checkDef.value;
|
|
2096
|
-
setResponseValueAndErrors(res, "multipleOf", multipleValue, message, refs);
|
|
2097
|
-
break;
|
|
2098
|
-
}
|
|
2099
|
-
} else {
|
|
2100
|
-
switch (check.kind) {
|
|
2101
|
-
case "min":
|
|
2102
|
-
if (refs.target === "jsonSchema7") {
|
|
2103
|
-
if (check.inclusive) {
|
|
2104
|
-
setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
2105
|
-
} else {
|
|
2106
|
-
setResponseValueAndErrors(res, "exclusiveMinimum", check.value, check.message, refs);
|
|
2107
|
-
}
|
|
2108
|
-
} else {
|
|
2109
|
-
if (!check.inclusive) {
|
|
2110
|
-
res.exclusiveMinimum = true;
|
|
2111
|
-
}
|
|
2112
|
-
setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
2113
|
-
}
|
|
2114
|
-
break;
|
|
2115
|
-
case "max":
|
|
2116
|
-
if (refs.target === "jsonSchema7") {
|
|
2117
|
-
if (check.inclusive) {
|
|
2118
|
-
setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
2119
|
-
} else {
|
|
2120
|
-
setResponseValueAndErrors(res, "exclusiveMaximum", check.value, check.message, refs);
|
|
2121
|
-
}
|
|
2122
|
-
} else {
|
|
2123
|
-
if (!check.inclusive) {
|
|
2124
|
-
res.exclusiveMaximum = true;
|
|
2125
|
-
}
|
|
2126
|
-
setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
2127
|
-
}
|
|
2128
|
-
break;
|
|
2129
|
-
case "multipleOf":
|
|
2130
|
-
setResponseValueAndErrors(res, "multipleOf", check.value, check.message, refs);
|
|
2131
|
-
break;
|
|
2132
|
-
}
|
|
2133
|
-
}
|
|
2134
|
-
}
|
|
2135
|
-
return res;
|
|
2136
|
-
}
|
|
2137
|
-
|
|
2138
|
-
// ../../node_modules/.pnpm/@alcyone-labs+zod-to-json-schema@4.0.10_zod@4.1.12/node_modules/@alcyone-labs/zod-to-json-schema/dist/esm/parsers/boolean.js
|
|
2139
|
-
function parseBooleanDef() {
|
|
2140
|
-
return {
|
|
2141
|
-
type: "boolean"
|
|
2142
|
-
};
|
|
2143
|
-
}
|
|
2144
|
-
|
|
2145
|
-
// ../../node_modules/.pnpm/@alcyone-labs+zod-to-json-schema@4.0.10_zod@4.1.12/node_modules/@alcyone-labs/zod-to-json-schema/dist/esm/parsers/branded.js
|
|
2146
|
-
function parseBrandedDef(_def, refs) {
|
|
2147
|
-
if (_def.type && _def.type._def) {
|
|
2148
|
-
return parseDef(_def.type._def, refs);
|
|
2149
|
-
} else {
|
|
2150
|
-
return parseDef(_def, refs);
|
|
2151
|
-
}
|
|
2152
|
-
}
|
|
2153
|
-
|
|
2154
|
-
// ../../node_modules/.pnpm/@alcyone-labs+zod-to-json-schema@4.0.10_zod@4.1.12/node_modules/@alcyone-labs/zod-to-json-schema/dist/esm/parsers/catch.js
|
|
2155
|
-
var parseCatchDef = (def, refs) => {
|
|
2156
|
-
return parseDef(def.innerType._def, refs);
|
|
2157
|
-
};
|
|
2158
|
-
|
|
2159
|
-
// ../../node_modules/.pnpm/@alcyone-labs+zod-to-json-schema@4.0.10_zod@4.1.12/node_modules/@alcyone-labs/zod-to-json-schema/dist/esm/parsers/date.js
|
|
2160
|
-
function parseDateDef(def, refs, overrideDateStrategy) {
|
|
2161
|
-
const strategy = overrideDateStrategy ?? refs.dateStrategy;
|
|
2162
|
-
if (Array.isArray(strategy)) {
|
|
2163
|
-
return {
|
|
2164
|
-
anyOf: strategy.map((item, i) => parseDateDef(def, refs, item))
|
|
2165
|
-
};
|
|
2166
|
-
}
|
|
2167
|
-
switch (strategy) {
|
|
2168
|
-
case "string":
|
|
2169
|
-
case "format:date-time":
|
|
2170
|
-
return {
|
|
2171
|
-
type: "string",
|
|
2172
|
-
format: "date-time"
|
|
2173
|
-
};
|
|
2174
|
-
case "format:date":
|
|
2175
|
-
return {
|
|
2176
|
-
type: "string",
|
|
2177
|
-
format: "date"
|
|
2178
|
-
};
|
|
2179
|
-
case "integer":
|
|
2180
|
-
return integerDateParser(def, refs);
|
|
2181
|
-
}
|
|
2182
|
-
}
|
|
2183
|
-
var integerDateParser = (def, refs) => {
|
|
2184
|
-
const res = {
|
|
2185
|
-
type: "integer",
|
|
2186
|
-
format: "unix-time"
|
|
2187
|
-
};
|
|
2188
|
-
if (refs.target === "openApi3") {
|
|
2189
|
-
return res;
|
|
2190
|
-
}
|
|
2191
|
-
if (def.checks) {
|
|
2192
|
-
for (const check of def.checks) {
|
|
2193
|
-
const checkDef = check._zod?.def;
|
|
2194
|
-
if (checkDef) {
|
|
2195
|
-
let message = checkDef.message;
|
|
2196
|
-
if (!message && checkDef.error && typeof checkDef.error === "function") {
|
|
2197
|
-
try {
|
|
2198
|
-
message = checkDef.error();
|
|
2199
|
-
} catch (e) {
|
|
2200
|
-
}
|
|
2201
|
-
}
|
|
2202
|
-
switch (checkDef.check) {
|
|
2203
|
-
case "greater_than":
|
|
2204
|
-
const minValue = checkDef.value instanceof Date ? checkDef.value.getTime() : checkDef.value;
|
|
2205
|
-
setResponseValueAndErrors(res, "minimum", minValue, message, refs);
|
|
2206
|
-
break;
|
|
2207
|
-
case "less_than":
|
|
2208
|
-
const maxValue = checkDef.value instanceof Date ? checkDef.value.getTime() : checkDef.value;
|
|
2209
|
-
setResponseValueAndErrors(res, "maximum", maxValue, message, refs);
|
|
2210
|
-
break;
|
|
2211
|
-
}
|
|
2212
|
-
} else {
|
|
2213
|
-
switch (check.kind) {
|
|
2214
|
-
case "min":
|
|
2215
|
-
setResponseValueAndErrors(
|
|
2216
|
-
res,
|
|
2217
|
-
"minimum",
|
|
2218
|
-
check.value,
|
|
2219
|
-
// This is in milliseconds
|
|
2220
|
-
check.message,
|
|
2221
|
-
refs
|
|
2222
|
-
);
|
|
2223
|
-
break;
|
|
2224
|
-
case "max":
|
|
2225
|
-
setResponseValueAndErrors(
|
|
2226
|
-
res,
|
|
2227
|
-
"maximum",
|
|
2228
|
-
check.value,
|
|
2229
|
-
// This is in milliseconds
|
|
2230
|
-
check.message,
|
|
2231
|
-
refs
|
|
2232
|
-
);
|
|
2233
|
-
break;
|
|
2234
|
-
}
|
|
2235
|
-
}
|
|
2236
|
-
}
|
|
2237
|
-
}
|
|
2238
|
-
return res;
|
|
2239
|
-
};
|
|
2240
|
-
|
|
2241
|
-
// ../../node_modules/.pnpm/@alcyone-labs+zod-to-json-schema@4.0.10_zod@4.1.12/node_modules/@alcyone-labs/zod-to-json-schema/dist/esm/parsers/default.js
|
|
2242
|
-
function parseDefaultDef(_def, refs) {
|
|
2243
|
-
return {
|
|
2244
|
-
...parseDef(_def.innerType._def, refs),
|
|
2245
|
-
default: _def.defaultValue
|
|
2246
|
-
};
|
|
2247
|
-
}
|
|
2248
|
-
|
|
2249
|
-
// ../../node_modules/.pnpm/@alcyone-labs+zod-to-json-schema@4.0.10_zod@4.1.12/node_modules/@alcyone-labs/zod-to-json-schema/dist/esm/parsers/effects.js
|
|
2250
|
-
function parseEffectsDef(_def, refs) {
|
|
2251
|
-
if (_def.type === "pipe") {
|
|
2252
|
-
return refs.effectStrategy === "input" ? parseDef(_def.in?.def || _def.in?._def, refs) : parseAnyDef(refs);
|
|
2253
|
-
}
|
|
2254
|
-
if (_def.schema) {
|
|
2255
|
-
return refs.effectStrategy === "input" ? parseDef(_def.schema._def || _def.schema.def, refs) : parseAnyDef(refs);
|
|
2256
|
-
}
|
|
2257
|
-
return parseAnyDef(refs);
|
|
2258
|
-
}
|
|
2259
|
-
|
|
2260
|
-
// ../../node_modules/.pnpm/@alcyone-labs+zod-to-json-schema@4.0.10_zod@4.1.12/node_modules/@alcyone-labs/zod-to-json-schema/dist/esm/parsers/enum.js
|
|
2261
|
-
function parseEnumDef(def) {
|
|
2262
|
-
const values = def.entries ? Object.values(def.entries) : def.values;
|
|
2263
|
-
return {
|
|
2264
|
-
type: "string",
|
|
2265
|
-
enum: Array.from(values)
|
|
2266
|
-
};
|
|
2267
|
-
}
|
|
2268
|
-
|
|
2269
|
-
// ../../node_modules/.pnpm/@alcyone-labs+zod-to-json-schema@4.0.10_zod@4.1.12/node_modules/@alcyone-labs/zod-to-json-schema/dist/esm/parsers/intersection.js
|
|
2270
|
-
var isJsonSchema7AllOfType = (type) => {
|
|
2271
|
-
if ("type" in type && type.type === "string")
|
|
2272
|
-
return false;
|
|
2273
|
-
return "allOf" in type;
|
|
2274
|
-
};
|
|
2275
|
-
function parseIntersectionDef(def, refs) {
|
|
2276
|
-
const allOf = [
|
|
2277
|
-
parseDef(def.left._def, {
|
|
2278
|
-
...refs,
|
|
2279
|
-
currentPath: [...refs.currentPath, "allOf", "0"]
|
|
2280
|
-
}),
|
|
2281
|
-
parseDef(def.right._def, {
|
|
2282
|
-
...refs,
|
|
2283
|
-
currentPath: [...refs.currentPath, "allOf", "1"]
|
|
2284
|
-
})
|
|
2285
|
-
].filter((x) => !!x);
|
|
2286
|
-
let unevaluatedProperties = refs.target === "jsonSchema2019-09" ? { unevaluatedProperties: false } : void 0;
|
|
2287
|
-
const mergedAllOf = [];
|
|
2288
|
-
allOf.forEach((schema) => {
|
|
2289
|
-
if (isJsonSchema7AllOfType(schema)) {
|
|
2290
|
-
mergedAllOf.push(...schema.allOf);
|
|
2291
|
-
if (schema.unevaluatedProperties === void 0) {
|
|
2292
|
-
unevaluatedProperties = void 0;
|
|
2293
|
-
}
|
|
2294
|
-
} else {
|
|
2295
|
-
let nestedSchema = schema;
|
|
2296
|
-
if ("additionalProperties" in schema && schema.additionalProperties === false) {
|
|
2297
|
-
const { additionalProperties, ...rest } = schema;
|
|
2298
|
-
nestedSchema = rest;
|
|
2299
|
-
} else {
|
|
2300
|
-
unevaluatedProperties = void 0;
|
|
2301
|
-
}
|
|
2302
|
-
mergedAllOf.push(nestedSchema);
|
|
2303
|
-
}
|
|
2304
|
-
});
|
|
2305
|
-
return mergedAllOf.length ? {
|
|
2306
|
-
allOf: mergedAllOf,
|
|
2307
|
-
...unevaluatedProperties
|
|
2308
|
-
} : void 0;
|
|
2309
|
-
}
|
|
2310
|
-
|
|
2311
|
-
// ../../node_modules/.pnpm/@alcyone-labs+zod-to-json-schema@4.0.10_zod@4.1.12/node_modules/@alcyone-labs/zod-to-json-schema/dist/esm/parsers/literal.js
|
|
2312
|
-
function parseLiteralDef(def, refs) {
|
|
2313
|
-
const value = def.values ? def.values[0] : def.value;
|
|
2314
|
-
const parsedType = typeof value;
|
|
2315
|
-
if (parsedType !== "bigint" && parsedType !== "number" && parsedType !== "boolean" && parsedType !== "string") {
|
|
2316
|
-
return {
|
|
2317
|
-
type: Array.isArray(value) ? "array" : "object"
|
|
2318
|
-
};
|
|
2319
|
-
}
|
|
2320
|
-
if (refs.target === "openApi3") {
|
|
2321
|
-
return {
|
|
2322
|
-
type: parsedType === "bigint" ? "integer" : parsedType,
|
|
2323
|
-
enum: [value]
|
|
2324
|
-
};
|
|
2325
|
-
}
|
|
2326
|
-
return {
|
|
2327
|
-
type: parsedType === "bigint" ? "integer" : parsedType,
|
|
2328
|
-
const: value
|
|
2329
|
-
};
|
|
2330
|
-
}
|
|
2331
|
-
|
|
2332
|
-
// ../../node_modules/.pnpm/@alcyone-labs+zod-to-json-schema@4.0.10_zod@4.1.12/node_modules/@alcyone-labs/zod-to-json-schema/dist/esm/parsers/string.js
|
|
2333
|
-
var emojiRegex = void 0;
|
|
2334
|
-
var zodPatterns = {
|
|
2335
|
-
/**
|
|
2336
|
-
* `c` was changed to `[cC]` to replicate /i flag
|
|
2337
|
-
*/
|
|
2338
|
-
cuid: /^[cC][^\s-]{8,}$/,
|
|
2339
|
-
cuid2: /^[0-9a-z]+$/,
|
|
2340
|
-
ulid: /^[0-9A-HJKMNP-TV-Z]{26}$/,
|
|
2341
|
-
/**
|
|
2342
|
-
* `a-z` was added to replicate /i flag
|
|
2343
|
-
*/
|
|
2344
|
-
email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,
|
|
2345
|
-
/**
|
|
2346
|
-
* Constructed a valid Unicode RegExp
|
|
2347
|
-
*
|
|
2348
|
-
* Lazily instantiate since this type of regex isn't supported
|
|
2349
|
-
* in all envs (e.g. React Native).
|
|
2350
|
-
*
|
|
2351
|
-
* See:
|
|
2352
|
-
* https://github.com/colinhacks/zod/issues/2433
|
|
2353
|
-
* Fix in Zod:
|
|
2354
|
-
* https://github.com/colinhacks/zod/commit/9340fd51e48576a75adc919bff65dbc4a5d4c99b
|
|
2355
|
-
*/
|
|
2356
|
-
emoji: () => {
|
|
2357
|
-
if (emojiRegex === void 0) {
|
|
2358
|
-
emojiRegex = RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u");
|
|
2359
|
-
}
|
|
2360
|
-
return emojiRegex;
|
|
2361
|
-
},
|
|
2362
|
-
/**
|
|
2363
|
-
* Unused
|
|
2364
|
-
*/
|
|
2365
|
-
uuid: /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,
|
|
2366
|
-
/**
|
|
2367
|
-
* Unused
|
|
2368
|
-
*/
|
|
2369
|
-
ipv4: /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,
|
|
2370
|
-
ipv4Cidr: /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,
|
|
2371
|
-
/**
|
|
2372
|
-
* Unused
|
|
2373
|
-
*/
|
|
2374
|
-
ipv6: /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,
|
|
2375
|
-
ipv6Cidr: /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,
|
|
2376
|
-
base64: /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,
|
|
2377
|
-
base64url: /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,
|
|
2378
|
-
nanoid: /^[a-zA-Z0-9_-]{21}$/,
|
|
2379
|
-
jwt: /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/
|
|
2380
|
-
};
|
|
2381
|
-
function parseStringDef(def, refs) {
|
|
2382
|
-
const res = {
|
|
2383
|
-
type: "string"
|
|
2384
|
-
};
|
|
2385
|
-
if (def.checks) {
|
|
2386
|
-
for (const check of def.checks) {
|
|
2387
|
-
const checkDef = check._zod?.def;
|
|
2388
|
-
if (checkDef) {
|
|
2389
|
-
switch (checkDef.check) {
|
|
2390
|
-
case "min_length":
|
|
2391
|
-
let minLengthMessage = checkDef.message;
|
|
2392
|
-
if (!minLengthMessage && checkDef.error && typeof checkDef.error === "function") {
|
|
2393
|
-
try {
|
|
2394
|
-
minLengthMessage = checkDef.error();
|
|
2395
|
-
} catch (e) {
|
|
2396
|
-
}
|
|
2397
|
-
}
|
|
2398
|
-
setResponseValueAndErrors(res, "minLength", typeof res.minLength === "number" ? Math.max(res.minLength, checkDef.minimum) : checkDef.minimum, minLengthMessage, refs);
|
|
2399
|
-
break;
|
|
2400
|
-
case "max_length":
|
|
2401
|
-
let maxLengthMessage = checkDef.message;
|
|
2402
|
-
if (!maxLengthMessage && checkDef.error && typeof checkDef.error === "function") {
|
|
2403
|
-
try {
|
|
2404
|
-
maxLengthMessage = checkDef.error();
|
|
2405
|
-
} catch (e) {
|
|
2406
|
-
}
|
|
2407
|
-
}
|
|
2408
|
-
setResponseValueAndErrors(res, "maxLength", typeof res.maxLength === "number" ? Math.min(res.maxLength, checkDef.maximum) : checkDef.maximum, maxLengthMessage, refs);
|
|
2409
|
-
break;
|
|
2410
|
-
case "length_equals":
|
|
2411
|
-
let message = checkDef.message;
|
|
2412
|
-
if (!message && checkDef.error && typeof checkDef.error === "function") {
|
|
2413
|
-
try {
|
|
2414
|
-
message = checkDef.error();
|
|
2415
|
-
} catch (e) {
|
|
2416
|
-
}
|
|
2417
|
-
}
|
|
2418
|
-
const length = checkDef.length;
|
|
2419
|
-
if (length !== void 0) {
|
|
2420
|
-
setResponseValueAndErrors(res, "minLength", typeof res.minLength === "number" ? Math.max(res.minLength, length) : length, message, refs);
|
|
2421
|
-
setResponseValueAndErrors(res, "maxLength", typeof res.maxLength === "number" ? Math.min(res.maxLength, length) : length, message, refs);
|
|
2422
|
-
}
|
|
2423
|
-
break;
|
|
2424
|
-
case "string_format":
|
|
2425
|
-
let formatMessage = checkDef.message;
|
|
2426
|
-
if (!formatMessage && checkDef.error && typeof checkDef.error === "function") {
|
|
2427
|
-
try {
|
|
2428
|
-
formatMessage = checkDef.error();
|
|
2429
|
-
} catch (e) {
|
|
2430
|
-
}
|
|
2431
|
-
}
|
|
2432
|
-
const format = checkDef.format;
|
|
2433
|
-
if (format === "email") {
|
|
2434
|
-
switch (refs.emailStrategy) {
|
|
2435
|
-
case "format:email":
|
|
2436
|
-
addFormat(res, "email", formatMessage, refs);
|
|
2437
|
-
break;
|
|
2438
|
-
case "format:idn-email":
|
|
2439
|
-
addFormat(res, "idn-email", formatMessage, refs);
|
|
2440
|
-
break;
|
|
2441
|
-
case "pattern:zod":
|
|
2442
|
-
addPattern(res, zodPatterns.email, formatMessage, refs);
|
|
2443
|
-
break;
|
|
2444
|
-
}
|
|
2445
|
-
} else if (format === "uri") {
|
|
2446
|
-
addFormat(res, "uri", formatMessage, refs);
|
|
2447
|
-
} else if (format === "url") {
|
|
2448
|
-
addFormat(res, "uri", formatMessage, refs);
|
|
2449
|
-
} else if (format === "uuid") {
|
|
2450
|
-
addFormat(res, "uuid", formatMessage, refs);
|
|
2451
|
-
} else if (format === "date-time") {
|
|
2452
|
-
addFormat(res, "date-time", formatMessage, refs);
|
|
2453
|
-
} else if (format === "date") {
|
|
2454
|
-
addFormat(res, "date", formatMessage, refs);
|
|
2455
|
-
} else if (format === "time") {
|
|
2456
|
-
addFormat(res, "time", formatMessage, refs);
|
|
2457
|
-
} else if (format === "duration") {
|
|
2458
|
-
addFormat(res, "duration", formatMessage, refs);
|
|
2459
|
-
} else if (format === "datetime") {
|
|
2460
|
-
addFormat(res, "date-time", formatMessage, refs);
|
|
2461
|
-
} else if (format === "ipv4") {
|
|
2462
|
-
addFormat(res, "ipv4", formatMessage, refs);
|
|
2463
|
-
} else if (format === "ipv6") {
|
|
2464
|
-
addFormat(res, "ipv6", formatMessage, refs);
|
|
2465
|
-
} else if (format === "ulid") {
|
|
2466
|
-
addPattern(res, zodPatterns.ulid, formatMessage, refs);
|
|
2467
|
-
} else if (format === "nanoid") {
|
|
2468
|
-
addPattern(res, zodPatterns.nanoid, formatMessage, refs);
|
|
2469
|
-
} else if (format === "cuid") {
|
|
2470
|
-
addPattern(res, zodPatterns.cuid, formatMessage, refs);
|
|
2471
|
-
} else if (format === "cuid2") {
|
|
2472
|
-
addPattern(res, zodPatterns.cuid2, formatMessage, refs);
|
|
2473
|
-
} else if (format === "base64") {
|
|
2474
|
-
switch (refs.base64Strategy) {
|
|
2475
|
-
case "format:binary":
|
|
2476
|
-
addFormat(res, "binary", formatMessage, refs);
|
|
2477
|
-
break;
|
|
2478
|
-
case "contentEncoding:base64":
|
|
2479
|
-
default:
|
|
2480
|
-
if (formatMessage && refs.errorMessages) {
|
|
2481
|
-
res.errorMessage = {
|
|
2482
|
-
...res.errorMessage,
|
|
2483
|
-
contentEncoding: formatMessage
|
|
2484
|
-
};
|
|
2485
|
-
}
|
|
2486
|
-
res.contentEncoding = "base64";
|
|
2487
|
-
break;
|
|
2488
|
-
case "pattern:zod":
|
|
2489
|
-
addPattern(res, zodPatterns.base64, formatMessage, refs);
|
|
2490
|
-
break;
|
|
2491
|
-
}
|
|
2492
|
-
} else if (format === "regex" && checkDef.pattern) {
|
|
2493
|
-
let message2 = checkDef.message;
|
|
2494
|
-
if (!message2 && checkDef.error && typeof checkDef.error === "function") {
|
|
2495
|
-
try {
|
|
2496
|
-
message2 = checkDef.error();
|
|
2497
|
-
} catch (e) {
|
|
2498
|
-
}
|
|
2499
|
-
}
|
|
2500
|
-
addPattern(res, checkDef.pattern, message2, refs);
|
|
2501
|
-
} else if (checkDef.pattern) {
|
|
2502
|
-
let message2 = checkDef.message;
|
|
2503
|
-
if (!message2 && checkDef.error && typeof checkDef.error === "function") {
|
|
2504
|
-
try {
|
|
2505
|
-
message2 = checkDef.error();
|
|
2506
|
-
} catch (e) {
|
|
2507
|
-
}
|
|
2508
|
-
}
|
|
2509
|
-
if (refs.patternStrategy === "preserve") {
|
|
2510
|
-
let preservedPattern;
|
|
2511
|
-
if (checkDef.prefix !== void 0) {
|
|
2512
|
-
preservedPattern = `^${checkDef.prefix}`;
|
|
2513
|
-
} else if (checkDef.suffix !== void 0) {
|
|
2514
|
-
preservedPattern = `${checkDef.suffix}$`;
|
|
2515
|
-
} else if (checkDef.includes !== void 0) {
|
|
2516
|
-
preservedPattern = checkDef.includes;
|
|
2517
|
-
}
|
|
2518
|
-
if (preservedPattern !== void 0) {
|
|
2519
|
-
addPattern(res, new RegExp(preservedPattern), message2, refs);
|
|
2520
|
-
break;
|
|
2521
|
-
}
|
|
2522
|
-
}
|
|
2523
|
-
let normalizedPattern = checkDef.pattern;
|
|
2524
|
-
const patternSource = checkDef.pattern.source;
|
|
2525
|
-
if (patternSource.startsWith("^") && patternSource.endsWith(".*")) {
|
|
2526
|
-
normalizedPattern = new RegExp(patternSource.slice(0, -2), checkDef.pattern.flags);
|
|
2527
|
-
} else if (patternSource.startsWith(".*") && patternSource.endsWith("$")) {
|
|
2528
|
-
normalizedPattern = new RegExp(patternSource.slice(2), checkDef.pattern.flags);
|
|
2529
|
-
}
|
|
2530
|
-
addPattern(res, normalizedPattern, message2, refs);
|
|
2531
|
-
}
|
|
2532
|
-
break;
|
|
2533
|
-
}
|
|
2534
|
-
continue;
|
|
2535
|
-
}
|
|
2536
|
-
if (check.kind) {
|
|
2537
|
-
switch (check.kind) {
|
|
2538
|
-
case "min":
|
|
2539
|
-
setResponseValueAndErrors(res, "minLength", typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value, check.message, refs);
|
|
2540
|
-
break;
|
|
2541
|
-
case "max":
|
|
2542
|
-
setResponseValueAndErrors(res, "maxLength", typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);
|
|
2543
|
-
break;
|
|
2544
|
-
case "email":
|
|
2545
|
-
switch (refs.emailStrategy) {
|
|
2546
|
-
case "format:email":
|
|
2547
|
-
addFormat(res, "email", check.message, refs);
|
|
2548
|
-
break;
|
|
2549
|
-
case "format:idn-email":
|
|
2550
|
-
addFormat(res, "idn-email", check.message, refs);
|
|
2551
|
-
break;
|
|
2552
|
-
case "pattern:zod":
|
|
2553
|
-
addPattern(res, zodPatterns.email, check.message, refs);
|
|
2554
|
-
break;
|
|
2555
|
-
}
|
|
2556
|
-
break;
|
|
2557
|
-
case "url":
|
|
2558
|
-
addFormat(res, "uri", check.message, refs);
|
|
2559
|
-
break;
|
|
2560
|
-
case "uuid":
|
|
2561
|
-
addFormat(res, "uuid", check.message, refs);
|
|
2562
|
-
break;
|
|
2563
|
-
case "regex":
|
|
2564
|
-
addPattern(res, check.regex, check.message, refs);
|
|
2565
|
-
break;
|
|
2566
|
-
case "cuid":
|
|
2567
|
-
addPattern(res, zodPatterns.cuid, check.message, refs);
|
|
2568
|
-
break;
|
|
2569
|
-
case "cuid2":
|
|
2570
|
-
addPattern(res, zodPatterns.cuid2, check.message, refs);
|
|
2571
|
-
break;
|
|
2572
|
-
case "startsWith":
|
|
2573
|
-
addPattern(res, RegExp(`^${escapeLiteralCheckValue(check.value, refs)}`), check.message, refs);
|
|
2574
|
-
break;
|
|
2575
|
-
case "endsWith":
|
|
2576
|
-
addPattern(res, RegExp(`${escapeLiteralCheckValue(check.value, refs)}$`), check.message, refs);
|
|
2577
|
-
break;
|
|
2578
|
-
case "datetime":
|
|
2579
|
-
addFormat(res, "date-time", check.message, refs);
|
|
2580
|
-
break;
|
|
2581
|
-
case "date":
|
|
2582
|
-
addFormat(res, "date", check.message, refs);
|
|
2583
|
-
break;
|
|
2584
|
-
case "time":
|
|
2585
|
-
addFormat(res, "time", check.message, refs);
|
|
2586
|
-
break;
|
|
2587
|
-
case "duration":
|
|
2588
|
-
addFormat(res, "duration", check.message, refs);
|
|
2589
|
-
break;
|
|
2590
|
-
case "length":
|
|
2591
|
-
setResponseValueAndErrors(res, "minLength", typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value, check.message, refs);
|
|
2592
|
-
setResponseValueAndErrors(res, "maxLength", typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);
|
|
2593
|
-
break;
|
|
2594
|
-
case "includes": {
|
|
2595
|
-
addPattern(res, RegExp(escapeLiteralCheckValue(check.value, refs)), check.message, refs);
|
|
2596
|
-
break;
|
|
2597
|
-
}
|
|
2598
|
-
case "ip": {
|
|
2599
|
-
if (check.version !== "v6") {
|
|
2600
|
-
addFormat(res, "ipv4", check.message, refs);
|
|
2601
|
-
}
|
|
2602
|
-
if (check.version !== "v4") {
|
|
2603
|
-
addFormat(res, "ipv6", check.message, refs);
|
|
2604
|
-
}
|
|
2605
|
-
break;
|
|
2606
|
-
}
|
|
2607
|
-
case "base64url":
|
|
2608
|
-
addPattern(res, zodPatterns.base64url, check.message, refs);
|
|
2609
|
-
break;
|
|
2610
|
-
case "jwt":
|
|
2611
|
-
addPattern(res, zodPatterns.jwt, check.message, refs);
|
|
2612
|
-
break;
|
|
2613
|
-
case "cidr": {
|
|
2614
|
-
if (check.version !== "v6") {
|
|
2615
|
-
addPattern(res, zodPatterns.ipv4Cidr, check.message, refs);
|
|
2616
|
-
}
|
|
2617
|
-
if (check.version !== "v4") {
|
|
2618
|
-
addPattern(res, zodPatterns.ipv6Cidr, check.message, refs);
|
|
2619
|
-
}
|
|
2620
|
-
break;
|
|
2621
|
-
}
|
|
2622
|
-
case "emoji":
|
|
2623
|
-
addPattern(res, zodPatterns.emoji(), check.message, refs);
|
|
2624
|
-
break;
|
|
2625
|
-
case "ulid": {
|
|
2626
|
-
addPattern(res, zodPatterns.ulid, check.message, refs);
|
|
2627
|
-
break;
|
|
2628
|
-
}
|
|
2629
|
-
case "base64": {
|
|
2630
|
-
switch (refs.base64Strategy) {
|
|
2631
|
-
case "format:binary": {
|
|
2632
|
-
addFormat(res, "binary", check.message, refs);
|
|
2633
|
-
break;
|
|
2634
|
-
}
|
|
2635
|
-
case "contentEncoding:base64": {
|
|
2636
|
-
setResponseValueAndErrors(res, "contentEncoding", "base64", check.message, refs);
|
|
2637
|
-
break;
|
|
2638
|
-
}
|
|
2639
|
-
case "pattern:zod": {
|
|
2640
|
-
addPattern(res, zodPatterns.base64, check.message, refs);
|
|
2641
|
-
break;
|
|
2642
|
-
}
|
|
2643
|
-
}
|
|
2644
|
-
break;
|
|
2645
|
-
}
|
|
2646
|
-
case "nanoid": {
|
|
2647
|
-
addPattern(res, zodPatterns.nanoid, check.message, refs);
|
|
2648
|
-
}
|
|
2649
|
-
}
|
|
2650
|
-
}
|
|
2651
|
-
}
|
|
2652
|
-
}
|
|
2653
|
-
return res;
|
|
2654
|
-
}
|
|
2655
|
-
function escapeLiteralCheckValue(literal, refs) {
|
|
2656
|
-
return refs.patternStrategy === "escape" ? escapeNonAlphaNumeric(literal) : literal;
|
|
2657
|
-
}
|
|
2658
|
-
var ALPHA_NUMERIC = new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
|
|
2659
|
-
function escapeNonAlphaNumeric(source) {
|
|
2660
|
-
let result = "";
|
|
2661
|
-
for (let i = 0; i < source.length; i++) {
|
|
2662
|
-
if (!ALPHA_NUMERIC.has(source[i])) {
|
|
2663
|
-
result += "\\";
|
|
2664
|
-
}
|
|
2665
|
-
result += source[i];
|
|
2666
|
-
}
|
|
2667
|
-
return result;
|
|
2668
|
-
}
|
|
2669
|
-
function addFormat(schema, value, message, refs) {
|
|
2670
|
-
if (schema.format || schema.anyOf?.some((x) => x.format)) {
|
|
2671
|
-
if (!schema.anyOf) {
|
|
2672
|
-
schema.anyOf = [];
|
|
2673
|
-
}
|
|
2674
|
-
if (schema.format) {
|
|
2675
|
-
schema.anyOf.push({
|
|
2676
|
-
format: schema.format,
|
|
2677
|
-
...schema.errorMessage && refs.errorMessages && {
|
|
2678
|
-
errorMessage: { format: schema.errorMessage.format }
|
|
2679
|
-
}
|
|
2680
|
-
});
|
|
2681
|
-
delete schema.format;
|
|
2682
|
-
if (schema.errorMessage) {
|
|
2683
|
-
delete schema.errorMessage.format;
|
|
2684
|
-
if (Object.keys(schema.errorMessage).length === 0) {
|
|
2685
|
-
delete schema.errorMessage;
|
|
2686
|
-
}
|
|
2687
|
-
}
|
|
2688
|
-
}
|
|
2689
|
-
schema.anyOf.push({
|
|
2690
|
-
format: value,
|
|
2691
|
-
...message && refs.errorMessages && { errorMessage: { format: message } }
|
|
2692
|
-
});
|
|
2693
|
-
} else {
|
|
2694
|
-
setResponseValueAndErrors(schema, "format", value, message, refs);
|
|
2695
|
-
}
|
|
2696
|
-
}
|
|
2697
|
-
function addPattern(schema, regex, message, refs) {
|
|
2698
|
-
if (schema.pattern || schema.allOf?.some((x) => x.pattern)) {
|
|
2699
|
-
if (!schema.allOf) {
|
|
2700
|
-
schema.allOf = [];
|
|
2701
|
-
}
|
|
2702
|
-
if (schema.pattern) {
|
|
2703
|
-
schema.allOf.push({
|
|
2704
|
-
pattern: schema.pattern,
|
|
2705
|
-
...schema.errorMessage && refs.errorMessages && {
|
|
2706
|
-
errorMessage: { pattern: schema.errorMessage.pattern }
|
|
2707
|
-
}
|
|
2708
|
-
});
|
|
2709
|
-
delete schema.pattern;
|
|
2710
|
-
if (schema.errorMessage) {
|
|
2711
|
-
delete schema.errorMessage.pattern;
|
|
2712
|
-
if (Object.keys(schema.errorMessage).length === 0) {
|
|
2713
|
-
delete schema.errorMessage;
|
|
2714
|
-
}
|
|
2715
|
-
}
|
|
2716
|
-
}
|
|
2717
|
-
schema.allOf.push({
|
|
2718
|
-
pattern: stringifyRegExpWithFlags(regex, refs),
|
|
2719
|
-
...message && refs.errorMessages && { errorMessage: { pattern: message } }
|
|
2720
|
-
});
|
|
2721
|
-
} else {
|
|
2722
|
-
setResponseValueAndErrors(schema, "pattern", stringifyRegExpWithFlags(regex, refs), message, refs);
|
|
2723
|
-
}
|
|
2724
|
-
}
|
|
2725
|
-
function stringifyRegExpWithFlags(regex, refs) {
|
|
2726
|
-
if (!refs.applyRegexFlags || !regex.flags) {
|
|
2727
|
-
return regex.source;
|
|
2728
|
-
}
|
|
2729
|
-
const flags = {
|
|
2730
|
-
i: regex.flags.includes("i"),
|
|
2731
|
-
// Case-insensitive
|
|
2732
|
-
m: regex.flags.includes("m"),
|
|
2733
|
-
// `^` and `$` matches adjacent to newline characters
|
|
2734
|
-
s: regex.flags.includes("s")
|
|
2735
|
-
// `.` matches newlines
|
|
2736
|
-
};
|
|
2737
|
-
const source = flags.i ? regex.source.toLowerCase() : regex.source;
|
|
2738
|
-
let pattern = "";
|
|
2739
|
-
let isEscaped = false;
|
|
2740
|
-
let inCharGroup = false;
|
|
2741
|
-
let inCharRange = false;
|
|
2742
|
-
for (let i = 0; i < source.length; i++) {
|
|
2743
|
-
if (isEscaped) {
|
|
2744
|
-
pattern += source[i];
|
|
2745
|
-
isEscaped = false;
|
|
2746
|
-
continue;
|
|
2747
|
-
}
|
|
2748
|
-
if (flags.i) {
|
|
2749
|
-
if (inCharGroup) {
|
|
2750
|
-
if (source[i].match(/[a-z]/)) {
|
|
2751
|
-
if (inCharRange) {
|
|
2752
|
-
pattern += source[i];
|
|
2753
|
-
pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
|
|
2754
|
-
inCharRange = false;
|
|
2755
|
-
} else if (source[i + 1] === "-" && source[i + 2]?.match(/[a-z]/)) {
|
|
2756
|
-
pattern += source[i];
|
|
2757
|
-
inCharRange = true;
|
|
2758
|
-
} else {
|
|
2759
|
-
pattern += `${source[i]}${source[i].toUpperCase()}`;
|
|
2760
|
-
}
|
|
2761
|
-
continue;
|
|
2762
|
-
}
|
|
2763
|
-
} else if (source[i].match(/[a-z]/)) {
|
|
2764
|
-
pattern += `[${source[i]}${source[i].toUpperCase()}]`;
|
|
2765
|
-
continue;
|
|
2766
|
-
}
|
|
2767
|
-
}
|
|
2768
|
-
if (flags.m) {
|
|
2769
|
-
if (source[i] === "^") {
|
|
2770
|
-
pattern += `(^|(?<=[\r
|
|
2771
|
-
]))`;
|
|
2772
|
-
continue;
|
|
2773
|
-
} else if (source[i] === "$") {
|
|
2774
|
-
pattern += `($|(?=[\r
|
|
2775
|
-
]))`;
|
|
2776
|
-
continue;
|
|
2777
|
-
}
|
|
2778
|
-
}
|
|
2779
|
-
if (flags.s && source[i] === ".") {
|
|
2780
|
-
pattern += inCharGroup ? `${source[i]}\r
|
|
2781
|
-
` : `[${source[i]}\r
|
|
2782
|
-
]`;
|
|
2783
|
-
continue;
|
|
2784
|
-
}
|
|
2785
|
-
pattern += source[i];
|
|
2786
|
-
if (source[i] === "\\") {
|
|
2787
|
-
isEscaped = true;
|
|
2788
|
-
} else if (inCharGroup && source[i] === "]") {
|
|
2789
|
-
inCharGroup = false;
|
|
2790
|
-
} else if (!inCharGroup && source[i] === "[") {
|
|
2791
|
-
inCharGroup = true;
|
|
2792
|
-
}
|
|
2793
|
-
}
|
|
2794
|
-
try {
|
|
2795
|
-
new RegExp(pattern);
|
|
2796
|
-
} catch {
|
|
2797
|
-
console.warn(`Could not convert regex pattern at ${refs.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`);
|
|
2798
|
-
return regex.source;
|
|
2799
|
-
}
|
|
2800
|
-
return pattern;
|
|
2801
|
-
}
|
|
2802
|
-
|
|
2803
|
-
// ../../node_modules/.pnpm/@alcyone-labs+zod-to-json-schema@4.0.10_zod@4.1.12/node_modules/@alcyone-labs/zod-to-json-schema/dist/esm/parsers/record.js
|
|
2804
|
-
function parseRecordDef(def, refs) {
|
|
2805
|
-
if (refs.target === "openAi") {
|
|
2806
|
-
console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.");
|
|
2807
|
-
}
|
|
2808
|
-
const keyTypeDef = def.keyType?.def || def.keyType?._def;
|
|
2809
|
-
const keyTypeType = keyTypeDef?.type || keyTypeDef?.typeName;
|
|
2810
|
-
if (refs.target === "openApi3" && (keyTypeType === "enum" || keyTypeType === "ZodEnum")) {
|
|
2811
|
-
const enumValues = keyTypeDef?.entries ? Object.values(keyTypeDef.entries) : keyTypeDef?.values;
|
|
2812
|
-
const valueTypeDef2 = def.valueType?.def || def.valueType?._def;
|
|
2813
|
-
if (enumValues && Array.isArray(enumValues)) {
|
|
2814
|
-
return {
|
|
2815
|
-
type: "object",
|
|
2816
|
-
required: enumValues,
|
|
2817
|
-
properties: enumValues.reduce((acc, key) => ({
|
|
2818
|
-
...acc,
|
|
2819
|
-
[key]: parseDef(valueTypeDef2, {
|
|
2820
|
-
...refs,
|
|
2821
|
-
currentPath: [...refs.currentPath, "properties", key]
|
|
2822
|
-
}) ?? parseAnyDef(refs)
|
|
2823
|
-
}), {}),
|
|
2824
|
-
additionalProperties: refs.rejectedAdditionalProperties
|
|
2825
|
-
};
|
|
2826
|
-
}
|
|
2827
|
-
}
|
|
2828
|
-
const actualValueType = def.valueType || def.keyType;
|
|
2829
|
-
const valueTypeDef = actualValueType?.def || actualValueType?._def;
|
|
2830
|
-
const schema = {
|
|
2831
|
-
type: "object",
|
|
2832
|
-
additionalProperties: valueTypeDef ? parseDef(valueTypeDef, {
|
|
2833
|
-
...refs,
|
|
2834
|
-
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
2835
|
-
}) : refs.allowedAdditionalProperties
|
|
2836
|
-
};
|
|
2837
|
-
if (refs.target === "openApi3") {
|
|
2838
|
-
return schema;
|
|
2839
|
-
}
|
|
2840
|
-
if ((keyTypeType === "string" || keyTypeType === "ZodString") && keyTypeDef?.checks?.length) {
|
|
2841
|
-
const { type, ...keyType } = parseStringDef(keyTypeDef, refs);
|
|
2842
|
-
return {
|
|
2843
|
-
...schema,
|
|
2844
|
-
propertyNames: keyType
|
|
2845
|
-
};
|
|
2846
|
-
} else if (keyTypeType === "enum" || keyTypeType === "ZodEnum") {
|
|
2847
|
-
const enumValues = keyTypeDef?.entries ? Object.values(keyTypeDef.entries) : keyTypeDef?.values;
|
|
2848
|
-
return {
|
|
2849
|
-
...schema,
|
|
2850
|
-
propertyNames: {
|
|
2851
|
-
enum: enumValues
|
|
2852
|
-
}
|
|
2853
|
-
};
|
|
2854
|
-
} else if ((keyTypeType === "branded" || keyTypeType === "ZodBranded") && keyTypeDef?.type) {
|
|
2855
|
-
const brandedTypeDef = keyTypeDef.type?.def || keyTypeDef.type?._def;
|
|
2856
|
-
const brandedTypeType = brandedTypeDef?.type || brandedTypeDef?.typeName;
|
|
2857
|
-
if ((brandedTypeType === "string" || brandedTypeType === "ZodString") && brandedTypeDef?.checks?.length) {
|
|
2858
|
-
const { type, ...keyType } = parseBrandedDef(keyTypeDef, refs);
|
|
2859
|
-
return {
|
|
2860
|
-
...schema,
|
|
2861
|
-
propertyNames: keyType
|
|
2862
|
-
};
|
|
2863
|
-
}
|
|
2864
|
-
}
|
|
2865
|
-
return schema;
|
|
2866
|
-
}
|
|
2867
|
-
|
|
2868
|
-
// ../../node_modules/.pnpm/@alcyone-labs+zod-to-json-schema@4.0.10_zod@4.1.12/node_modules/@alcyone-labs/zod-to-json-schema/dist/esm/parsers/map.js
|
|
2869
|
-
function parseMapDef(def, refs) {
|
|
2870
|
-
if (refs.mapStrategy === "record") {
|
|
2871
|
-
return parseRecordDef(def, refs);
|
|
2872
|
-
}
|
|
2873
|
-
const keys = parseDef(def.keyType._def, {
|
|
2874
|
-
...refs,
|
|
2875
|
-
currentPath: [...refs.currentPath, "items", "items", "0"]
|
|
2876
|
-
}) || parseAnyDef(refs);
|
|
2877
|
-
const values = parseDef(def.valueType._def, {
|
|
2878
|
-
...refs,
|
|
2879
|
-
currentPath: [...refs.currentPath, "items", "items", "1"]
|
|
2880
|
-
}) || parseAnyDef(refs);
|
|
2881
|
-
return {
|
|
2882
|
-
type: "array",
|
|
2883
|
-
maxItems: 125,
|
|
2884
|
-
items: {
|
|
2885
|
-
type: "array",
|
|
2886
|
-
items: [keys, values],
|
|
2887
|
-
minItems: 2,
|
|
2888
|
-
maxItems: 2
|
|
2889
|
-
}
|
|
2890
|
-
};
|
|
2891
|
-
}
|
|
2892
|
-
|
|
2893
|
-
// ../../node_modules/.pnpm/@alcyone-labs+zod-to-json-schema@4.0.10_zod@4.1.12/node_modules/@alcyone-labs/zod-to-json-schema/dist/esm/parsers/nativeEnum.js
|
|
2894
|
-
function parseNativeEnumDef(def) {
|
|
2895
|
-
const object = def.entries || def.values;
|
|
2896
|
-
const actualKeys = Object.keys(object).filter((key) => {
|
|
2897
|
-
return typeof object[object[key]] !== "number";
|
|
2898
|
-
});
|
|
2899
|
-
const actualValues = actualKeys.map((key) => object[key]);
|
|
2900
|
-
const parsedTypes = Array.from(new Set(actualValues.map((values) => typeof values)));
|
|
2901
|
-
return {
|
|
2902
|
-
type: parsedTypes.length === 1 ? parsedTypes[0] === "string" ? "string" : "number" : ["string", "number"],
|
|
2903
|
-
enum: actualValues
|
|
2904
|
-
};
|
|
2905
|
-
}
|
|
2906
|
-
|
|
2907
|
-
// ../../node_modules/.pnpm/@alcyone-labs+zod-to-json-schema@4.0.10_zod@4.1.12/node_modules/@alcyone-labs/zod-to-json-schema/dist/esm/parsers/never.js
|
|
2908
|
-
function parseNeverDef(refs) {
|
|
2909
|
-
return refs.target === "openAi" ? void 0 : {
|
|
2910
|
-
not: parseAnyDef({
|
|
2911
|
-
...refs,
|
|
2912
|
-
currentPath: [...refs.currentPath, "not"]
|
|
2913
|
-
})
|
|
2914
|
-
};
|
|
2915
|
-
}
|
|
2916
|
-
|
|
2917
|
-
// ../../node_modules/.pnpm/@alcyone-labs+zod-to-json-schema@4.0.10_zod@4.1.12/node_modules/@alcyone-labs/zod-to-json-schema/dist/esm/parsers/null.js
|
|
2918
|
-
function parseNullDef(refs) {
|
|
2919
|
-
return refs.target === "openApi3" ? {
|
|
2920
|
-
enum: ["null"],
|
|
2921
|
-
nullable: true
|
|
2922
|
-
} : {
|
|
2923
|
-
type: "null"
|
|
2924
|
-
};
|
|
2925
|
-
}
|
|
2926
|
-
|
|
2927
|
-
// ../../node_modules/.pnpm/@alcyone-labs+zod-to-json-schema@4.0.10_zod@4.1.12/node_modules/@alcyone-labs/zod-to-json-schema/dist/esm/parsers/nullable.js
|
|
2928
|
-
function parseNullableDef(def, refs) {
|
|
2929
|
-
const innerTypeDef = getInnerTypeDef(def);
|
|
2930
|
-
const innerTypeKey = getDefTypeName(innerTypeDef);
|
|
2931
|
-
if (innerTypeKey && getAllPrimitiveTypeNames().includes(innerTypeKey) && (!innerTypeDef.checks || !innerTypeDef.checks.length)) {
|
|
2932
|
-
if (refs.target === "openApi3") {
|
|
2933
|
-
return {
|
|
2934
|
-
type: primitiveMappings[innerTypeKey],
|
|
2935
|
-
nullable: true
|
|
2936
|
-
};
|
|
2937
|
-
}
|
|
2938
|
-
return {
|
|
2939
|
-
type: [
|
|
2940
|
-
primitiveMappings[innerTypeKey],
|
|
2941
|
-
"null"
|
|
2942
|
-
]
|
|
2943
|
-
};
|
|
2944
|
-
}
|
|
2945
|
-
if (refs.target === "openApi3") {
|
|
2946
|
-
const base2 = parseDef(innerTypeDef, {
|
|
2947
|
-
...refs,
|
|
2948
|
-
currentPath: [...refs.currentPath]
|
|
2949
|
-
});
|
|
2950
|
-
if (base2 && "$ref" in base2) {
|
|
2951
|
-
const result = { allOf: [base2], nullable: true };
|
|
2952
|
-
const refPath = base2.$ref;
|
|
2953
|
-
if (refPath && refPath.includes(refs.definitionPath)) {
|
|
2954
|
-
const pathParts = refPath.split("/");
|
|
2955
|
-
const defName = pathParts[pathParts.length - 1];
|
|
2956
|
-
const definitionSchema = refs.definitions[defName];
|
|
2957
|
-
if (definitionSchema) {
|
|
2958
|
-
let description;
|
|
2959
|
-
if (typeof definitionSchema.meta === "function") {
|
|
2960
|
-
try {
|
|
2961
|
-
const meta = definitionSchema.meta();
|
|
2962
|
-
if (meta && meta.description) {
|
|
2963
|
-
description = meta.description;
|
|
2964
|
-
}
|
|
2965
|
-
} catch (e) {
|
|
2966
|
-
}
|
|
2967
|
-
}
|
|
2968
|
-
if (!description && definitionSchema.description) {
|
|
2969
|
-
description = definitionSchema.description;
|
|
2970
|
-
}
|
|
2971
|
-
if (description) {
|
|
2972
|
-
result.description = description;
|
|
2973
|
-
}
|
|
2974
|
-
}
|
|
2975
|
-
}
|
|
2976
|
-
return result;
|
|
2977
|
-
}
|
|
2978
|
-
return base2 && { ...base2, nullable: true };
|
|
2979
|
-
}
|
|
2980
|
-
const base = parseDef(innerTypeDef, {
|
|
2981
|
-
...refs,
|
|
2982
|
-
currentPath: [...refs.currentPath, "anyOf", "0"]
|
|
2983
|
-
});
|
|
2984
|
-
return base && { anyOf: [base, { type: "null" }] };
|
|
2985
|
-
}
|
|
2986
|
-
|
|
2987
|
-
// ../../node_modules/.pnpm/@alcyone-labs+zod-to-json-schema@4.0.10_zod@4.1.12/node_modules/@alcyone-labs/zod-to-json-schema/dist/esm/parsers/number.js
|
|
2988
|
-
function parseNumberDef(def, refs) {
|
|
2989
|
-
const res = {
|
|
2990
|
-
type: "number"
|
|
2991
|
-
};
|
|
2992
|
-
if (!def.checks)
|
|
2993
|
-
return res;
|
|
2994
|
-
for (const check of def.checks) {
|
|
2995
|
-
const checkDef = check._zod?.def;
|
|
2996
|
-
if (checkDef) {
|
|
2997
|
-
let message = checkDef.message;
|
|
2998
|
-
if (!message && checkDef.error && typeof checkDef.error === "function") {
|
|
2999
|
-
try {
|
|
3000
|
-
message = checkDef.error();
|
|
3001
|
-
} catch (e) {
|
|
3002
|
-
}
|
|
3003
|
-
}
|
|
3004
|
-
switch (checkDef.check) {
|
|
3005
|
-
case "number_format":
|
|
3006
|
-
if (checkDef.format === "safeint") {
|
|
3007
|
-
res.type = "integer";
|
|
3008
|
-
addErrorMessage(res, "type", message, refs);
|
|
3009
|
-
}
|
|
3010
|
-
break;
|
|
3011
|
-
case "greater_than":
|
|
3012
|
-
if (refs.target === "jsonSchema7") {
|
|
3013
|
-
if (checkDef.inclusive) {
|
|
3014
|
-
setResponseValueAndErrors(res, "minimum", checkDef.value, message, refs);
|
|
3015
|
-
} else {
|
|
3016
|
-
setResponseValueAndErrors(res, "exclusiveMinimum", checkDef.value, message, refs);
|
|
3017
|
-
}
|
|
3018
|
-
} else {
|
|
3019
|
-
if (!checkDef.inclusive) {
|
|
3020
|
-
res.exclusiveMinimum = true;
|
|
3021
|
-
}
|
|
3022
|
-
setResponseValueAndErrors(res, "minimum", checkDef.value, message, refs);
|
|
3023
|
-
}
|
|
3024
|
-
break;
|
|
3025
|
-
case "less_than":
|
|
3026
|
-
if (refs.target === "jsonSchema7") {
|
|
3027
|
-
if (checkDef.inclusive) {
|
|
3028
|
-
setResponseValueAndErrors(res, "maximum", checkDef.value, message, refs);
|
|
3029
|
-
} else {
|
|
3030
|
-
setResponseValueAndErrors(res, "exclusiveMaximum", checkDef.value, message, refs);
|
|
3031
|
-
}
|
|
3032
|
-
} else {
|
|
3033
|
-
if (!checkDef.inclusive) {
|
|
3034
|
-
res.exclusiveMaximum = true;
|
|
3035
|
-
}
|
|
3036
|
-
setResponseValueAndErrors(res, "maximum", checkDef.value, message, refs);
|
|
3037
|
-
}
|
|
3038
|
-
break;
|
|
3039
|
-
case "multiple_of":
|
|
3040
|
-
setResponseValueAndErrors(res, "multipleOf", checkDef.value, message, refs);
|
|
3041
|
-
break;
|
|
3042
|
-
}
|
|
3043
|
-
} else {
|
|
3044
|
-
switch (check.kind) {
|
|
3045
|
-
case "int":
|
|
3046
|
-
res.type = "integer";
|
|
3047
|
-
addErrorMessage(res, "type", check.message, refs);
|
|
3048
|
-
break;
|
|
3049
|
-
case "min":
|
|
3050
|
-
if (refs.target === "jsonSchema7") {
|
|
3051
|
-
if (check.inclusive) {
|
|
3052
|
-
setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
3053
|
-
} else {
|
|
3054
|
-
setResponseValueAndErrors(res, "exclusiveMinimum", check.value, check.message, refs);
|
|
3055
|
-
}
|
|
3056
|
-
} else {
|
|
3057
|
-
if (!check.inclusive) {
|
|
3058
|
-
res.exclusiveMinimum = true;
|
|
3059
|
-
}
|
|
3060
|
-
setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
3061
|
-
}
|
|
3062
|
-
break;
|
|
3063
|
-
case "max":
|
|
3064
|
-
if (refs.target === "jsonSchema7") {
|
|
3065
|
-
if (check.inclusive) {
|
|
3066
|
-
setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
3067
|
-
} else {
|
|
3068
|
-
setResponseValueAndErrors(res, "exclusiveMaximum", check.value, check.message, refs);
|
|
3069
|
-
}
|
|
3070
|
-
} else {
|
|
3071
|
-
if (!check.inclusive) {
|
|
3072
|
-
res.exclusiveMaximum = true;
|
|
3073
|
-
}
|
|
3074
|
-
setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
3075
|
-
}
|
|
3076
|
-
break;
|
|
3077
|
-
case "multipleOf":
|
|
3078
|
-
setResponseValueAndErrors(res, "multipleOf", check.value, check.message, refs);
|
|
3079
|
-
break;
|
|
3080
|
-
}
|
|
3081
|
-
}
|
|
3082
|
-
}
|
|
3083
|
-
return res;
|
|
3084
|
-
}
|
|
3085
|
-
|
|
3086
|
-
// ../../node_modules/.pnpm/@alcyone-labs+zod-to-json-schema@4.0.10_zod@4.1.12/node_modules/@alcyone-labs/zod-to-json-schema/dist/esm/parsers/object.js
|
|
3087
|
-
function parseObjectDef(def, refs) {
|
|
3088
|
-
const forceOptionalIntoNullable = refs.target === "openAi";
|
|
3089
|
-
const result = {
|
|
3090
|
-
type: "object",
|
|
3091
|
-
properties: {}
|
|
3092
|
-
};
|
|
3093
|
-
const required = [];
|
|
3094
|
-
const shape = def.shape;
|
|
3095
|
-
for (const propName in shape) {
|
|
3096
|
-
let propDef = shape[propName];
|
|
3097
|
-
const propDefInner = propDef.def || propDef._def;
|
|
3098
|
-
if (propDef === void 0 || propDefInner === void 0) {
|
|
3099
|
-
continue;
|
|
3100
|
-
}
|
|
3101
|
-
let propOptional = safeIsOptional(propDef);
|
|
3102
|
-
let parsedDef;
|
|
3103
|
-
if (propOptional && forceOptionalIntoNullable) {
|
|
3104
|
-
const typeName = propDefInner.typeName || propDefInner.type;
|
|
3105
|
-
if (typeName === "ZodOptional" || typeName === "optional") {
|
|
3106
|
-
const innerType = propDefInner.innerType;
|
|
3107
|
-
if (innerType) {
|
|
3108
|
-
const innerTypeDef = innerType.def || innerType._def;
|
|
3109
|
-
innerTypeDef?.type || innerTypeDef?.typeName;
|
|
3110
|
-
const innerParsed = parseDef(innerTypeDef, {
|
|
3111
|
-
...refs,
|
|
3112
|
-
currentPath: [...refs.currentPath, "properties", propName],
|
|
3113
|
-
propertyPath: [...refs.currentPath, "properties", propName]
|
|
3114
|
-
});
|
|
3115
|
-
if (innerParsed && typeof innerParsed === "object" && "type" in innerParsed) {
|
|
3116
|
-
if (typeof innerParsed.type === "string") {
|
|
3117
|
-
parsedDef = {
|
|
3118
|
-
...innerParsed,
|
|
3119
|
-
type: [innerParsed.type, "null"]
|
|
3120
|
-
};
|
|
3121
|
-
} else {
|
|
3122
|
-
parsedDef = innerParsed;
|
|
3123
|
-
}
|
|
3124
|
-
} else {
|
|
3125
|
-
parsedDef = innerParsed;
|
|
3126
|
-
}
|
|
3127
|
-
}
|
|
3128
|
-
}
|
|
3129
|
-
propOptional = false;
|
|
3130
|
-
} else {
|
|
3131
|
-
parsedDef = parseDef(propDefInner, {
|
|
3132
|
-
...refs,
|
|
3133
|
-
currentPath: [...refs.currentPath, "properties", propName],
|
|
3134
|
-
propertyPath: [...refs.currentPath, "properties", propName]
|
|
3135
|
-
});
|
|
3136
|
-
}
|
|
3137
|
-
if (parsedDef === void 0) {
|
|
3138
|
-
continue;
|
|
3139
|
-
}
|
|
3140
|
-
result.properties[propName] = parsedDef;
|
|
3141
|
-
if (!propOptional) {
|
|
3142
|
-
required.push(propName);
|
|
3143
|
-
}
|
|
3144
|
-
}
|
|
3145
|
-
if (required.length) {
|
|
3146
|
-
result.required = required;
|
|
3147
|
-
}
|
|
3148
|
-
const additionalProperties = decideAdditionalProperties(def, refs);
|
|
3149
|
-
if (additionalProperties !== void 0) {
|
|
3150
|
-
result.additionalProperties = additionalProperties;
|
|
3151
|
-
}
|
|
3152
|
-
return result;
|
|
3153
|
-
}
|
|
3154
|
-
function decideAdditionalProperties(def, refs) {
|
|
3155
|
-
if (def.catchall) {
|
|
3156
|
-
const catchallDef = def.catchall.def || def.catchall._def;
|
|
3157
|
-
const catchallType = catchallDef?.type || catchallDef?.typeName;
|
|
3158
|
-
if (catchallType === "never" || catchallType === "ZodNever") {
|
|
3159
|
-
return refs.rejectedAdditionalProperties;
|
|
3160
|
-
} else if (catchallType === "unknown" || catchallType === "ZodUnknown") {
|
|
3161
|
-
return refs.allowedAdditionalProperties;
|
|
3162
|
-
} else {
|
|
3163
|
-
return parseDef(catchallDef, {
|
|
3164
|
-
...refs,
|
|
3165
|
-
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
3166
|
-
});
|
|
3167
|
-
}
|
|
3168
|
-
}
|
|
3169
|
-
switch (def.unknownKeys) {
|
|
3170
|
-
case "passthrough":
|
|
3171
|
-
return refs.allowedAdditionalProperties;
|
|
3172
|
-
case "strict":
|
|
3173
|
-
return refs.rejectedAdditionalProperties;
|
|
3174
|
-
case "strip":
|
|
3175
|
-
return refs.removeAdditionalStrategy === "strict" ? refs.allowedAdditionalProperties : refs.rejectedAdditionalProperties;
|
|
3176
|
-
}
|
|
3177
|
-
return refs.removeAdditionalStrategy === "strict" ? refs.allowedAdditionalProperties : refs.rejectedAdditionalProperties;
|
|
3178
|
-
}
|
|
3179
|
-
function safeIsOptional(schema) {
|
|
3180
|
-
try {
|
|
3181
|
-
return schema.isOptional();
|
|
3182
|
-
} catch {
|
|
3183
|
-
return true;
|
|
3184
|
-
}
|
|
3185
|
-
}
|
|
3186
|
-
|
|
3187
|
-
// ../../node_modules/.pnpm/@alcyone-labs+zod-to-json-schema@4.0.10_zod@4.1.12/node_modules/@alcyone-labs/zod-to-json-schema/dist/esm/parsers/optional.js
|
|
3188
|
-
var parseOptionalDef = (def, refs) => {
|
|
3189
|
-
if (refs.currentPath.toString() === refs.propertyPath?.toString()) {
|
|
3190
|
-
return parseDef(def.innerType._def, refs);
|
|
3191
|
-
}
|
|
3192
|
-
const innerSchema = parseDef(def.innerType._def, {
|
|
3193
|
-
...refs,
|
|
3194
|
-
currentPath: [...refs.currentPath, "anyOf", "1"]
|
|
3195
|
-
});
|
|
3196
|
-
return innerSchema ? {
|
|
3197
|
-
anyOf: [
|
|
3198
|
-
{
|
|
3199
|
-
not: parseAnyDef(refs)
|
|
3200
|
-
},
|
|
3201
|
-
innerSchema
|
|
3202
|
-
]
|
|
3203
|
-
} : parseAnyDef(refs);
|
|
3204
|
-
};
|
|
3205
|
-
|
|
3206
|
-
// ../../node_modules/.pnpm/@alcyone-labs+zod-to-json-schema@4.0.10_zod@4.1.12/node_modules/@alcyone-labs/zod-to-json-schema/dist/esm/parsers/pipeline.js
|
|
3207
|
-
var parsePipelineDef = (def, refs) => {
|
|
3208
|
-
const inDef = def.in?.def || def.in?._def;
|
|
3209
|
-
const outDef = def.out?.def || def.out?._def;
|
|
3210
|
-
const isTransformLike = inDef?.type === "transform" || outDef?.type === "transform";
|
|
3211
|
-
if (isTransformLike) {
|
|
3212
|
-
if (refs.effectStrategy === "input") {
|
|
3213
|
-
return inDef?.type === "transform" ? parseDef(outDef, refs) : parseDef(inDef, refs);
|
|
3214
|
-
} else {
|
|
3215
|
-
return {};
|
|
3216
|
-
}
|
|
3217
|
-
}
|
|
3218
|
-
if (refs.pipeStrategy === "input") {
|
|
3219
|
-
return parseDef(inDef, refs);
|
|
3220
|
-
} else if (refs.pipeStrategy === "output") {
|
|
3221
|
-
return parseDef(outDef, refs);
|
|
3222
|
-
}
|
|
3223
|
-
const a = parseDef(inDef, {
|
|
3224
|
-
...refs,
|
|
3225
|
-
currentPath: [...refs.currentPath, "allOf", "0"]
|
|
3226
|
-
});
|
|
3227
|
-
const b = parseDef(outDef, {
|
|
3228
|
-
...refs,
|
|
3229
|
-
currentPath: [...refs.currentPath, "allOf", a ? "1" : "0"]
|
|
3230
|
-
});
|
|
3231
|
-
return {
|
|
3232
|
-
allOf: [a, b].filter((x) => x !== void 0)
|
|
3233
|
-
};
|
|
3234
|
-
};
|
|
3235
|
-
|
|
3236
|
-
// ../../node_modules/.pnpm/@alcyone-labs+zod-to-json-schema@4.0.10_zod@4.1.12/node_modules/@alcyone-labs/zod-to-json-schema/dist/esm/parsers/promise.js
|
|
3237
|
-
function parsePromiseDef(def, refs) {
|
|
3238
|
-
const innerType = def.innerType || def.type;
|
|
3239
|
-
const innerDef = innerType?.def || innerType?._def;
|
|
3240
|
-
return parseDef(innerDef, refs);
|
|
3241
|
-
}
|
|
3242
|
-
|
|
3243
|
-
// ../../node_modules/.pnpm/@alcyone-labs+zod-to-json-schema@4.0.10_zod@4.1.12/node_modules/@alcyone-labs/zod-to-json-schema/dist/esm/parsers/set.js
|
|
3244
|
-
function parseSetDef(def, refs) {
|
|
3245
|
-
const valueTypeDef = def.valueType?.def || def.valueType?._def;
|
|
3246
|
-
const items = parseDef(valueTypeDef, {
|
|
3247
|
-
...refs,
|
|
3248
|
-
currentPath: [...refs.currentPath, "items"]
|
|
3249
|
-
});
|
|
3250
|
-
const schema = {
|
|
3251
|
-
type: "array",
|
|
3252
|
-
uniqueItems: true,
|
|
3253
|
-
items
|
|
3254
|
-
};
|
|
3255
|
-
if (def.checks) {
|
|
3256
|
-
for (const check of def.checks) {
|
|
3257
|
-
const checkDef = check._zod?.def;
|
|
3258
|
-
if (checkDef) {
|
|
3259
|
-
let message = checkDef.message;
|
|
3260
|
-
if (!message && checkDef.error && typeof checkDef.error === "function") {
|
|
3261
|
-
try {
|
|
3262
|
-
message = checkDef.error();
|
|
3263
|
-
} catch (e) {
|
|
3264
|
-
}
|
|
3265
|
-
}
|
|
3266
|
-
switch (checkDef.check) {
|
|
3267
|
-
case "min_size":
|
|
3268
|
-
setResponseValueAndErrors(schema, "minItems", checkDef.minimum, message, refs);
|
|
3269
|
-
break;
|
|
3270
|
-
case "max_size":
|
|
3271
|
-
setResponseValueAndErrors(schema, "maxItems", checkDef.maximum, message, refs);
|
|
3272
|
-
break;
|
|
3273
|
-
}
|
|
3274
|
-
}
|
|
3275
|
-
}
|
|
3276
|
-
}
|
|
3277
|
-
if (def.minSize) {
|
|
3278
|
-
setResponseValueAndErrors(schema, "minItems", def.minSize.value, def.minSize.message, refs);
|
|
3279
|
-
}
|
|
3280
|
-
if (def.maxSize) {
|
|
3281
|
-
setResponseValueAndErrors(schema, "maxItems", def.maxSize.value, def.maxSize.message, refs);
|
|
3282
|
-
}
|
|
3283
|
-
return schema;
|
|
3284
|
-
}
|
|
3285
|
-
|
|
3286
|
-
// ../../node_modules/.pnpm/@alcyone-labs+zod-to-json-schema@4.0.10_zod@4.1.12/node_modules/@alcyone-labs/zod-to-json-schema/dist/esm/parsers/tuple.js
|
|
3287
|
-
function parseTupleDef(def, refs) {
|
|
3288
|
-
if (def.rest) {
|
|
3289
|
-
return {
|
|
3290
|
-
type: "array",
|
|
3291
|
-
minItems: def.items.length,
|
|
3292
|
-
items: def.items.map((x, i) => parseDef(x._def, {
|
|
3293
|
-
...refs,
|
|
3294
|
-
currentPath: [...refs.currentPath, "items", `${i}`]
|
|
3295
|
-
})).reduce((acc, x) => x === void 0 ? acc : [...acc, x], []),
|
|
3296
|
-
additionalItems: parseDef(def.rest._def, {
|
|
3297
|
-
...refs,
|
|
3298
|
-
currentPath: [...refs.currentPath, "additionalItems"]
|
|
3299
|
-
})
|
|
3300
|
-
};
|
|
3301
|
-
} else {
|
|
3302
|
-
return {
|
|
3303
|
-
type: "array",
|
|
3304
|
-
minItems: def.items.length,
|
|
3305
|
-
maxItems: def.items.length,
|
|
3306
|
-
items: def.items.map((x, i) => parseDef(x._def, {
|
|
3307
|
-
...refs,
|
|
3308
|
-
currentPath: [...refs.currentPath, "items", `${i}`]
|
|
3309
|
-
})).reduce((acc, x) => x === void 0 ? acc : [...acc, x], [])
|
|
3310
|
-
};
|
|
3311
|
-
}
|
|
3312
|
-
}
|
|
3313
|
-
|
|
3314
|
-
// ../../node_modules/.pnpm/@alcyone-labs+zod-to-json-schema@4.0.10_zod@4.1.12/node_modules/@alcyone-labs/zod-to-json-schema/dist/esm/parsers/undefined.js
|
|
3315
|
-
function parseUndefinedDef(refs) {
|
|
3316
|
-
return {
|
|
3317
|
-
not: parseAnyDef(refs)
|
|
3318
|
-
};
|
|
3319
|
-
}
|
|
3320
|
-
|
|
3321
|
-
// ../../node_modules/.pnpm/@alcyone-labs+zod-to-json-schema@4.0.10_zod@4.1.12/node_modules/@alcyone-labs/zod-to-json-schema/dist/esm/parsers/union.js
|
|
3322
|
-
var primitiveMappings2 = {
|
|
3323
|
-
// Zod V3 type names
|
|
3324
|
-
ZodString: "string",
|
|
3325
|
-
ZodNumber: "number",
|
|
3326
|
-
ZodBigInt: "integer",
|
|
3327
|
-
ZodBoolean: "boolean",
|
|
3328
|
-
ZodNull: "null",
|
|
3329
|
-
// Zod V4 type names
|
|
3330
|
-
string: "string",
|
|
3331
|
-
number: "number",
|
|
3332
|
-
bigint: "integer",
|
|
3333
|
-
boolean: "boolean",
|
|
3334
|
-
null: "null"
|
|
3335
|
-
};
|
|
3336
|
-
var extractMetaInfoForSchema = (schema) => {
|
|
3337
|
-
if (!schema || !schema._def)
|
|
3338
|
-
return;
|
|
3339
|
-
let metaInfo = {};
|
|
3340
|
-
if (schema.description) {
|
|
3341
|
-
metaInfo.description = schema.description;
|
|
3342
|
-
}
|
|
3343
|
-
if (typeof schema.meta === "function") {
|
|
3344
|
-
try {
|
|
3345
|
-
const meta = schema.meta();
|
|
3346
|
-
if (meta && typeof meta === "object") {
|
|
3347
|
-
metaInfo = { ...metaInfo, ...meta };
|
|
3348
|
-
}
|
|
3349
|
-
} catch (e) {
|
|
3350
|
-
}
|
|
3351
|
-
}
|
|
3352
|
-
if (Object.keys(metaInfo).length > 0) {
|
|
3353
|
-
setSchemaMetaInfo(schema._def, metaInfo);
|
|
3354
|
-
}
|
|
3355
|
-
};
|
|
3356
|
-
function parseUnionDef(def, refs) {
|
|
3357
|
-
if (refs.target === "openApi3")
|
|
3358
|
-
return asAnyOf(def, refs);
|
|
3359
|
-
const options = def.options instanceof Map ? Array.from(def.options.values()) : def.options;
|
|
3360
|
-
options.forEach((option) => extractMetaInfoForSchema(option));
|
|
3361
|
-
if (options.every((x) => {
|
|
3362
|
-
const typeKey = getDefTypeName(x._def);
|
|
3363
|
-
return typeKey && typeKey in primitiveMappings2 && (!x._def.checks || !x._def.checks.length);
|
|
3364
|
-
})) {
|
|
3365
|
-
const types = options.reduce((types2, x) => {
|
|
3366
|
-
const typeKey = getDefTypeName(x._def);
|
|
3367
|
-
const type = typeKey ? primitiveMappings2[typeKey] : void 0;
|
|
3368
|
-
return type && !types2.includes(type) ? [...types2, type] : types2;
|
|
3369
|
-
}, []);
|
|
3370
|
-
return {
|
|
3371
|
-
type: types.length > 1 ? types : types[0]
|
|
3372
|
-
};
|
|
3373
|
-
} else if (options.every((x) => {
|
|
3374
|
-
const typeKey = getDefTypeName(x._def);
|
|
3375
|
-
const hasDescription = x.description || getSchemaMetaInfo(x._def)?.description;
|
|
3376
|
-
return typeKey && (typeKey === "ZodLiteral" || typeKey === "literal") && !hasDescription;
|
|
3377
|
-
})) {
|
|
3378
|
-
const types = options.reduce((acc, x) => {
|
|
3379
|
-
const value = x._def.values ? x._def.values[0] : x._def.value;
|
|
3380
|
-
const type = typeof value;
|
|
3381
|
-
switch (type) {
|
|
3382
|
-
case "string":
|
|
3383
|
-
case "number":
|
|
3384
|
-
case "boolean":
|
|
3385
|
-
return [...acc, type];
|
|
3386
|
-
case "bigint":
|
|
3387
|
-
return [...acc, "integer"];
|
|
3388
|
-
case "object":
|
|
3389
|
-
if (value === null)
|
|
3390
|
-
return [...acc, "null"];
|
|
3391
|
-
case "symbol":
|
|
3392
|
-
case "undefined":
|
|
3393
|
-
case "function":
|
|
3394
|
-
default:
|
|
3395
|
-
return acc;
|
|
3396
|
-
}
|
|
3397
|
-
}, []);
|
|
3398
|
-
if (types.length === options.length) {
|
|
3399
|
-
const uniqueTypes = types.filter((x, i, a) => a.indexOf(x) === i);
|
|
3400
|
-
return {
|
|
3401
|
-
type: uniqueTypes.length > 1 ? uniqueTypes : uniqueTypes[0],
|
|
3402
|
-
enum: options.reduce((acc, x) => {
|
|
3403
|
-
const value = x._def.values ? x._def.values[0] : x._def.value;
|
|
3404
|
-
return acc.includes(value) ? acc : [...acc, value];
|
|
3405
|
-
}, [])
|
|
3406
|
-
};
|
|
3407
|
-
}
|
|
3408
|
-
} else if (options.every((x) => {
|
|
3409
|
-
const typeKey = getDefTypeName(x._def);
|
|
3410
|
-
return typeKey === "ZodEnum" || typeKey === "enum";
|
|
3411
|
-
})) {
|
|
3412
|
-
return {
|
|
3413
|
-
type: "string",
|
|
3414
|
-
enum: options.reduce((acc, x) => {
|
|
3415
|
-
const values = x._def.entries ? Object.values(x._def.entries) : x._def.values;
|
|
3416
|
-
return [...acc, ...values.filter((x2) => !acc.includes(x2))];
|
|
3417
|
-
}, [])
|
|
3418
|
-
};
|
|
3419
|
-
}
|
|
3420
|
-
return asAnyOf(def, refs);
|
|
3421
|
-
}
|
|
3422
|
-
var asAnyOf = (def, refs) => {
|
|
3423
|
-
const anyOf = (def.options instanceof Map ? Array.from(def.options.values()) : def.options).map((x, i) => parseDef(x._def, {
|
|
3424
|
-
...refs,
|
|
3425
|
-
currentPath: [...refs.currentPath, "anyOf", `${i}`]
|
|
3426
|
-
})).filter((x) => !!x && (!refs.strictUnions || typeof x === "object" && Object.keys(x).length > 0));
|
|
3427
|
-
return anyOf.length ? { anyOf } : void 0;
|
|
3428
|
-
};
|
|
3429
|
-
|
|
3430
|
-
// ../../node_modules/.pnpm/@alcyone-labs+zod-to-json-schema@4.0.10_zod@4.1.12/node_modules/@alcyone-labs/zod-to-json-schema/dist/esm/parsers/unknown.js
|
|
3431
|
-
function parseUnknownDef(refs) {
|
|
3432
|
-
return parseAnyDef(refs);
|
|
3433
|
-
}
|
|
3434
|
-
|
|
3435
|
-
// ../../node_modules/.pnpm/@alcyone-labs+zod-to-json-schema@4.0.10_zod@4.1.12/node_modules/@alcyone-labs/zod-to-json-schema/dist/esm/parsers/readonly.js
|
|
3436
|
-
var parseReadonlyDef = (def, refs) => {
|
|
3437
|
-
return parseDef(def.innerType._def, refs);
|
|
3438
|
-
};
|
|
3439
|
-
|
|
3440
|
-
// ../../node_modules/.pnpm/@alcyone-labs+zod-to-json-schema@4.0.10_zod@4.1.12/node_modules/@alcyone-labs/zod-to-json-schema/dist/esm/selectParser.js
|
|
3441
|
-
var selectParser = (def, typeName, refs) => {
|
|
3442
|
-
const actualType = typeName || def.type;
|
|
3443
|
-
switch (actualType) {
|
|
3444
|
-
case "ZodString":
|
|
3445
|
-
case "string":
|
|
3446
|
-
return parseStringDef(def, refs);
|
|
3447
|
-
case "ZodNumber":
|
|
3448
|
-
case "number":
|
|
3449
|
-
case ZodFirstPartyTypeKind.ZodNumber:
|
|
3450
|
-
return parseNumberDef(def, refs);
|
|
3451
|
-
case "ZodObject":
|
|
3452
|
-
case "object":
|
|
3453
|
-
case ZodFirstPartyTypeKind.ZodObject:
|
|
3454
|
-
return parseObjectDef(def, refs);
|
|
3455
|
-
case "ZodBigInt":
|
|
3456
|
-
case "bigint":
|
|
3457
|
-
case ZodFirstPartyTypeKind.ZodBigInt:
|
|
3458
|
-
return parseBigintDef(def, refs);
|
|
3459
|
-
case "ZodBoolean":
|
|
3460
|
-
case "boolean":
|
|
3461
|
-
case ZodFirstPartyTypeKind.ZodBoolean:
|
|
3462
|
-
return parseBooleanDef();
|
|
3463
|
-
case "ZodDate":
|
|
3464
|
-
case "date":
|
|
3465
|
-
case ZodFirstPartyTypeKind.ZodDate:
|
|
3466
|
-
return parseDateDef(def, refs);
|
|
3467
|
-
case "ZodUndefined":
|
|
3468
|
-
case "undefined":
|
|
3469
|
-
case ZodFirstPartyTypeKind.ZodUndefined:
|
|
3470
|
-
return parseUndefinedDef(refs);
|
|
3471
|
-
case "ZodNull":
|
|
3472
|
-
case "null":
|
|
3473
|
-
case ZodFirstPartyTypeKind.ZodNull:
|
|
3474
|
-
return parseNullDef(refs);
|
|
3475
|
-
case "ZodArray":
|
|
3476
|
-
case "array":
|
|
3477
|
-
case ZodFirstPartyTypeKind.ZodArray:
|
|
3478
|
-
return parseArrayDef(def, refs);
|
|
3479
|
-
case "ZodUnion":
|
|
3480
|
-
case "union":
|
|
3481
|
-
case "ZodDiscriminatedUnion":
|
|
3482
|
-
case "discriminatedUnion":
|
|
3483
|
-
case ZodFirstPartyTypeKind.ZodUnion:
|
|
3484
|
-
case ZodFirstPartyTypeKind.ZodDiscriminatedUnion:
|
|
3485
|
-
return parseUnionDef(def, refs);
|
|
3486
|
-
case "ZodIntersection":
|
|
3487
|
-
case "intersection":
|
|
3488
|
-
case ZodFirstPartyTypeKind.ZodIntersection:
|
|
3489
|
-
return parseIntersectionDef(def, refs);
|
|
3490
|
-
case "ZodTuple":
|
|
3491
|
-
case "tuple":
|
|
3492
|
-
case ZodFirstPartyTypeKind.ZodTuple:
|
|
3493
|
-
return parseTupleDef(def, refs);
|
|
3494
|
-
case "ZodRecord":
|
|
3495
|
-
case "record":
|
|
3496
|
-
case ZodFirstPartyTypeKind.ZodRecord:
|
|
3497
|
-
return parseRecordDef(def, refs);
|
|
3498
|
-
case "ZodLiteral":
|
|
3499
|
-
case "literal":
|
|
3500
|
-
case ZodFirstPartyTypeKind.ZodLiteral:
|
|
3501
|
-
return parseLiteralDef(def, refs);
|
|
3502
|
-
case "ZodEnum":
|
|
3503
|
-
case "enum":
|
|
3504
|
-
case ZodFirstPartyTypeKind.ZodEnum:
|
|
3505
|
-
if (def.entries) {
|
|
3506
|
-
const keys = Object.keys(def.entries);
|
|
3507
|
-
const values = Object.values(def.entries);
|
|
3508
|
-
const isNativeEnum = !keys.every((k, i) => k === values[i]);
|
|
3509
|
-
if (isNativeEnum) {
|
|
3510
|
-
return parseNativeEnumDef(def);
|
|
3511
|
-
}
|
|
3512
|
-
}
|
|
3513
|
-
return parseEnumDef(def);
|
|
3514
|
-
case "ZodNativeEnum":
|
|
3515
|
-
case "nativeEnum":
|
|
3516
|
-
case ZodFirstPartyTypeKind.ZodNativeEnum:
|
|
3517
|
-
return parseNativeEnumDef(def);
|
|
3518
|
-
case "ZodNullable":
|
|
3519
|
-
case "nullable":
|
|
3520
|
-
case ZodFirstPartyTypeKind.ZodNullable:
|
|
3521
|
-
return parseNullableDef(def, refs);
|
|
3522
|
-
case "ZodOptional":
|
|
3523
|
-
case "optional":
|
|
3524
|
-
case ZodFirstPartyTypeKind.ZodOptional:
|
|
3525
|
-
return parseOptionalDef(def, refs);
|
|
3526
|
-
case "ZodMap":
|
|
3527
|
-
case "map":
|
|
3528
|
-
case ZodFirstPartyTypeKind.ZodMap:
|
|
3529
|
-
return parseMapDef(def, refs);
|
|
3530
|
-
case "ZodSet":
|
|
3531
|
-
case "set":
|
|
3532
|
-
case ZodFirstPartyTypeKind.ZodSet:
|
|
3533
|
-
return parseSetDef(def, refs);
|
|
3534
|
-
case "ZodLazy":
|
|
3535
|
-
case "lazy":
|
|
3536
|
-
case ZodFirstPartyTypeKind.ZodLazy:
|
|
3537
|
-
return () => def.getter()._def;
|
|
3538
|
-
case "ZodPromise":
|
|
3539
|
-
case "promise":
|
|
3540
|
-
case ZodFirstPartyTypeKind.ZodPromise:
|
|
3541
|
-
return parsePromiseDef(def, refs);
|
|
3542
|
-
case "ZodNaN":
|
|
3543
|
-
case "nan":
|
|
3544
|
-
case "ZodNever":
|
|
3545
|
-
case "never":
|
|
3546
|
-
case ZodFirstPartyTypeKind.ZodNaN:
|
|
3547
|
-
case ZodFirstPartyTypeKind.ZodNever:
|
|
3548
|
-
return parseNeverDef(refs);
|
|
3549
|
-
case "ZodEffects":
|
|
3550
|
-
case "effects":
|
|
3551
|
-
case ZodFirstPartyTypeKind.ZodEffects:
|
|
3552
|
-
return parseEffectsDef(def, refs);
|
|
3553
|
-
case "ZodAny":
|
|
3554
|
-
case "any":
|
|
3555
|
-
case ZodFirstPartyTypeKind.ZodAny:
|
|
3556
|
-
return parseAnyDef(refs);
|
|
3557
|
-
case "ZodUnknown":
|
|
3558
|
-
case "unknown":
|
|
3559
|
-
case ZodFirstPartyTypeKind.ZodUnknown:
|
|
3560
|
-
return parseUnknownDef(refs);
|
|
3561
|
-
case "ZodDefault":
|
|
3562
|
-
case "default":
|
|
3563
|
-
case ZodFirstPartyTypeKind.ZodDefault:
|
|
3564
|
-
return parseDefaultDef(def, refs);
|
|
3565
|
-
case "ZodBranded":
|
|
3566
|
-
case "branded":
|
|
3567
|
-
case ZodFirstPartyTypeKind.ZodBranded:
|
|
3568
|
-
return parseBrandedDef(def, refs);
|
|
3569
|
-
case "ZodReadonly":
|
|
3570
|
-
case "readonly":
|
|
3571
|
-
case ZodFirstPartyTypeKind.ZodReadonly:
|
|
3572
|
-
return parseReadonlyDef(def, refs);
|
|
3573
|
-
case "ZodCatch":
|
|
3574
|
-
case "catch":
|
|
3575
|
-
case ZodFirstPartyTypeKind.ZodCatch:
|
|
3576
|
-
return parseCatchDef(def, refs);
|
|
3577
|
-
case "ZodPipeline":
|
|
3578
|
-
case "pipeline":
|
|
3579
|
-
case "pipe":
|
|
3580
|
-
// Zod V4 uses "pipe" instead of "pipeline"
|
|
3581
|
-
case ZodFirstPartyTypeKind.ZodPipeline:
|
|
3582
|
-
return parsePipelineDef(def, refs);
|
|
3583
|
-
case "ZodFunction":
|
|
3584
|
-
case "function":
|
|
3585
|
-
case "ZodVoid":
|
|
3586
|
-
case "void":
|
|
3587
|
-
case "ZodSymbol":
|
|
3588
|
-
case "symbol":
|
|
3589
|
-
case ZodFirstPartyTypeKind.ZodFunction:
|
|
3590
|
-
case ZodFirstPartyTypeKind.ZodVoid:
|
|
3591
|
-
case ZodFirstPartyTypeKind.ZodSymbol:
|
|
3592
|
-
return void 0;
|
|
3593
|
-
case "custom":
|
|
3594
|
-
return parseAnyDef(refs);
|
|
3595
|
-
default:
|
|
3596
|
-
return void 0;
|
|
3597
|
-
}
|
|
3598
|
-
};
|
|
3599
|
-
|
|
3600
|
-
// ../../node_modules/.pnpm/@alcyone-labs+zod-to-json-schema@4.0.10_zod@4.1.12/node_modules/@alcyone-labs/zod-to-json-schema/dist/esm/parseDef.js
|
|
3601
|
-
var schemaMetaMap = /* @__PURE__ */ new WeakMap();
|
|
3602
|
-
var setSchemaMetaInfo = (def, metaInfo) => {
|
|
3603
|
-
schemaMetaMap.set(def, metaInfo);
|
|
3604
|
-
};
|
|
3605
|
-
var getSchemaMetaInfo = (def) => {
|
|
3606
|
-
return schemaMetaMap.get(def);
|
|
3607
|
-
};
|
|
3608
|
-
function parseDef(def, refs, forceResolution = false) {
|
|
3609
|
-
const seenItem = refs.seen.get(def);
|
|
3610
|
-
if (refs.override) {
|
|
3611
|
-
const overrideResult = refs.override?.(def, refs, seenItem, forceResolution);
|
|
3612
|
-
if (overrideResult !== ignoreOverride) {
|
|
3613
|
-
return overrideResult;
|
|
3614
|
-
}
|
|
3615
|
-
}
|
|
3616
|
-
if (seenItem && !forceResolution) {
|
|
3617
|
-
const seenSchema = get$ref(seenItem, refs);
|
|
3618
|
-
if (seenSchema !== void 0) {
|
|
3619
|
-
getDefTypeName(def);
|
|
3620
|
-
if (isNullableType(def) && refs.target === "openApi3" && "$ref" in seenSchema) {
|
|
3621
|
-
const metaInfo = getSchemaMetaInfo(def);
|
|
3622
|
-
const innerTypeDef = getInnerTypeDef(def);
|
|
3623
|
-
const innerSeenItem = innerTypeDef ? refs.seen.get(innerTypeDef) : null;
|
|
3624
|
-
const hasOwnDescription = metaInfo?.description;
|
|
3625
|
-
const innerMetaInfo = innerTypeDef ? getSchemaMetaInfo(innerTypeDef) : null;
|
|
3626
|
-
const hasInnerDescription = innerMetaInfo?.description;
|
|
3627
|
-
let referencedDefinitionDescription;
|
|
3628
|
-
if (innerSeenItem && innerSeenItem.path.includes(refs.definitionPath)) {
|
|
3629
|
-
const defName = innerSeenItem.path[innerSeenItem.path.length - 1];
|
|
3630
|
-
const definitionSchema = refs.definitions[defName];
|
|
3631
|
-
if (definitionSchema) {
|
|
3632
|
-
if (typeof definitionSchema.meta === "function") {
|
|
3633
|
-
try {
|
|
3634
|
-
const meta = definitionSchema.meta();
|
|
3635
|
-
if (meta && meta.description) {
|
|
3636
|
-
referencedDefinitionDescription = meta.description;
|
|
3637
|
-
}
|
|
3638
|
-
} catch (e) {
|
|
3639
|
-
}
|
|
3640
|
-
}
|
|
3641
|
-
if (!referencedDefinitionDescription && definitionSchema.description) {
|
|
3642
|
-
referencedDefinitionDescription = definitionSchema.description;
|
|
3643
|
-
}
|
|
3644
|
-
}
|
|
3645
|
-
}
|
|
3646
|
-
if (hasOwnDescription || hasInnerDescription || referencedDefinitionDescription) {
|
|
3647
|
-
let refToUse = seenSchema;
|
|
3648
|
-
if (innerSeenItem && innerSeenItem.path.includes(refs.definitionPath)) {
|
|
3649
|
-
refToUse = { $ref: innerSeenItem.path.join("/") };
|
|
3650
|
-
}
|
|
3651
|
-
const result = { allOf: [refToUse], nullable: true };
|
|
3652
|
-
const currentPathStr = refs.currentPath.join("/");
|
|
3653
|
-
if (hasOwnDescription && !currentPathStr.includes("group")) {
|
|
3654
|
-
result.description = metaInfo.description;
|
|
3655
|
-
} else if (hasInnerDescription && !hasOwnDescription) {
|
|
3656
|
-
result.description = innerMetaInfo.description;
|
|
3657
|
-
} else if (referencedDefinitionDescription && !hasOwnDescription) {
|
|
3658
|
-
result.description = referencedDefinitionDescription;
|
|
3659
|
-
}
|
|
3660
|
-
return result;
|
|
3661
|
-
}
|
|
3662
|
-
return seenSchema;
|
|
3663
|
-
}
|
|
3664
|
-
return seenSchema;
|
|
3665
|
-
}
|
|
3666
|
-
}
|
|
3667
|
-
const newItem = { def, path: refs.currentPath, jsonSchema: void 0 };
|
|
3668
|
-
refs.seen.set(def, newItem);
|
|
3669
|
-
const typeName = getDefTypeName(def);
|
|
3670
|
-
const jsonSchemaOrGetter = selectParser(def, typeName, refs);
|
|
3671
|
-
const jsonSchema = typeof jsonSchemaOrGetter === "function" ? parseDef(jsonSchemaOrGetter(), refs) : jsonSchemaOrGetter;
|
|
3672
|
-
if (jsonSchema) {
|
|
3673
|
-
addMeta(def, refs, jsonSchema);
|
|
3674
|
-
}
|
|
3675
|
-
if (refs.postProcess) {
|
|
3676
|
-
const postProcessResult = refs.postProcess(jsonSchema, def, refs);
|
|
3677
|
-
newItem.jsonSchema = jsonSchema;
|
|
3678
|
-
return postProcessResult;
|
|
3679
|
-
}
|
|
3680
|
-
newItem.jsonSchema = jsonSchema;
|
|
3681
|
-
return jsonSchema;
|
|
3682
|
-
}
|
|
3683
|
-
var get$ref = (item, refs) => {
|
|
3684
|
-
switch (refs.$refStrategy) {
|
|
3685
|
-
case "root":
|
|
3686
|
-
return { $ref: item.path.join("/") };
|
|
3687
|
-
case "relative":
|
|
3688
|
-
return { $ref: getRelativePath(refs.currentPath, item.path) };
|
|
3689
|
-
case "none":
|
|
3690
|
-
case "seen": {
|
|
3691
|
-
if (item.path.length < refs.currentPath.length && item.path.every((value, index) => refs.currentPath[index] === value)) {
|
|
3692
|
-
console.warn(`Recursive reference detected at ${refs.currentPath.join("/")}! Defaulting to any`);
|
|
3693
|
-
return parseAnyDef(refs);
|
|
3694
|
-
}
|
|
3695
|
-
return refs.$refStrategy === "seen" ? parseAnyDef(refs) : void 0;
|
|
3696
|
-
}
|
|
3697
|
-
}
|
|
3698
|
-
};
|
|
3699
|
-
var addMeta = (def, refs, jsonSchema) => {
|
|
3700
|
-
if (def.description) {
|
|
3701
|
-
jsonSchema.description = def.description;
|
|
3702
|
-
if (refs.markdownDescription) {
|
|
3703
|
-
jsonSchema.markdownDescription = def.description;
|
|
3704
|
-
}
|
|
3705
|
-
}
|
|
3706
|
-
const metaInfo = getSchemaMetaInfo(def);
|
|
3707
|
-
if (metaInfo) {
|
|
3708
|
-
if (metaInfo.description) {
|
|
3709
|
-
jsonSchema.description = metaInfo.description;
|
|
3710
|
-
if (refs.markdownDescription) {
|
|
3711
|
-
jsonSchema.markdownDescription = metaInfo.description;
|
|
3712
|
-
}
|
|
3713
|
-
}
|
|
3714
|
-
if (metaInfo.title) {
|
|
3715
|
-
jsonSchema.title = metaInfo.title;
|
|
3716
|
-
}
|
|
3717
|
-
if (metaInfo.examples) {
|
|
3718
|
-
jsonSchema.examples = metaInfo.examples;
|
|
3719
|
-
}
|
|
3720
|
-
for (const [key, value] of Object.entries(metaInfo)) {
|
|
3721
|
-
if (key !== "description" && key !== "title" && key !== "examples") {
|
|
3722
|
-
jsonSchema[key] = value;
|
|
3723
|
-
}
|
|
3724
|
-
}
|
|
3725
|
-
}
|
|
3726
|
-
return jsonSchema;
|
|
3727
|
-
};
|
|
3728
|
-
|
|
3729
|
-
// ../../node_modules/.pnpm/@alcyone-labs+zod-to-json-schema@4.0.10_zod@4.1.12/node_modules/@alcyone-labs/zod-to-json-schema/dist/esm/zodToJsonSchema.js
|
|
3730
|
-
var extractAndStoreMetaInfo = (schema) => {
|
|
3731
|
-
if (!schema || !schema._def)
|
|
3732
|
-
return;
|
|
3733
|
-
const metaInfo = extractMetadata(schema);
|
|
3734
|
-
if (Object.keys(metaInfo).length > 0) {
|
|
3735
|
-
setSchemaMetaInfo(schema._def, metaInfo);
|
|
3736
|
-
}
|
|
3737
|
-
if (schema._def.innerType) {
|
|
3738
|
-
extractAndStoreMetaInfo(schema._def.innerType);
|
|
3739
|
-
}
|
|
3740
|
-
if (schema._def.options && Array.isArray(schema._def.options)) {
|
|
3741
|
-
schema._def.options.forEach((option) => extractAndStoreMetaInfo(option));
|
|
3742
|
-
}
|
|
3743
|
-
if (schema._def.left) {
|
|
3744
|
-
extractAndStoreMetaInfo(schema._def.left);
|
|
3745
|
-
}
|
|
3746
|
-
if (schema._def.right) {
|
|
3747
|
-
extractAndStoreMetaInfo(schema._def.right);
|
|
3748
|
-
}
|
|
3749
|
-
if (schema._def.schema) {
|
|
3750
|
-
extractAndStoreMetaInfo(schema._def.schema);
|
|
3751
|
-
}
|
|
3752
|
-
if (schema._def.type) {
|
|
3753
|
-
extractAndStoreMetaInfo(schema._def.type);
|
|
3754
|
-
}
|
|
3755
|
-
if (schema._def.shape && typeof schema._def.shape === "object") {
|
|
3756
|
-
Object.values(schema._def.shape).forEach((propSchema) => {
|
|
3757
|
-
extractAndStoreMetaInfo(propSchema);
|
|
3758
|
-
});
|
|
3759
|
-
}
|
|
3760
|
-
if (schema._def.element) {
|
|
3761
|
-
extractAndStoreMetaInfo(schema._def.element);
|
|
3762
|
-
}
|
|
3763
|
-
if (schema._def.shape && typeof schema._def.shape === "object") {
|
|
3764
|
-
Object.values(schema._def.shape).forEach((propertySchema) => {
|
|
3765
|
-
extractAndStoreMetaInfo(propertySchema);
|
|
3766
|
-
});
|
|
3767
|
-
}
|
|
3768
|
-
if (schema._def.type && schema._def.type._def) {
|
|
3769
|
-
extractAndStoreMetaInfo(schema._def.type);
|
|
3770
|
-
}
|
|
3771
|
-
};
|
|
3772
|
-
var zodToJsonSchema = (schema, options) => {
|
|
3773
|
-
const refs = getRefs(options);
|
|
3774
|
-
extractAndStoreMetaInfo(schema);
|
|
3775
|
-
if (typeof options === "object" && options.definitions) {
|
|
3776
|
-
Object.values(options.definitions).forEach((defSchema) => {
|
|
3777
|
-
extractAndStoreMetaInfo(defSchema);
|
|
3778
|
-
});
|
|
3779
|
-
}
|
|
3780
|
-
let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name2, schema2]) => ({
|
|
3781
|
-
...acc,
|
|
3782
|
-
[name2]: parseDef(schema2._def, {
|
|
3783
|
-
...refs,
|
|
3784
|
-
currentPath: [...refs.basePath, refs.definitionPath, name2]
|
|
3785
|
-
}, true) ?? parseAnyDef(refs)
|
|
3786
|
-
}), {}) : void 0;
|
|
3787
|
-
const name = typeof options === "string" ? options : options?.nameStrategy === "title" ? void 0 : options?.name;
|
|
3788
|
-
const main = parseDef(schema._def, name === void 0 ? refs : {
|
|
3789
|
-
...refs,
|
|
3790
|
-
currentPath: [...refs.basePath, refs.definitionPath, name]
|
|
3791
|
-
}, false) ?? parseAnyDef(refs);
|
|
3792
|
-
const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
|
|
3793
|
-
if (title !== void 0) {
|
|
3794
|
-
main.title = title;
|
|
3795
|
-
}
|
|
3796
|
-
if (refs.flags.hasReferencedOpenAiAnyType) {
|
|
3797
|
-
if (!definitions) {
|
|
3798
|
-
definitions = {};
|
|
3799
|
-
}
|
|
3800
|
-
if (!definitions[refs.openAiAnyTypeName]) {
|
|
3801
|
-
definitions[refs.openAiAnyTypeName] = {
|
|
3802
|
-
// Skipping "object" as no properties can be defined and additionalProperties must be "false"
|
|
3803
|
-
type: ["string", "number", "integer", "boolean", "array", "null"],
|
|
3804
|
-
items: {
|
|
3805
|
-
$ref: refs.$refStrategy === "relative" ? "1" : [
|
|
3806
|
-
...refs.basePath,
|
|
3807
|
-
refs.definitionPath,
|
|
3808
|
-
refs.openAiAnyTypeName
|
|
3809
|
-
].join("/")
|
|
3810
|
-
}
|
|
3811
|
-
};
|
|
3812
|
-
}
|
|
3813
|
-
}
|
|
3814
|
-
const combined = name === void 0 ? definitions ? {
|
|
3815
|
-
...main,
|
|
3816
|
-
[refs.definitionPath]: definitions
|
|
3817
|
-
} : main : {
|
|
3818
|
-
$ref: [
|
|
3819
|
-
...refs.$refStrategy === "relative" ? [] : refs.basePath,
|
|
3820
|
-
refs.definitionPath,
|
|
3821
|
-
name
|
|
3822
|
-
].join("/"),
|
|
3823
|
-
[refs.definitionPath]: {
|
|
3824
|
-
...definitions,
|
|
3825
|
-
[name]: main
|
|
3826
|
-
}
|
|
3827
|
-
};
|
|
3828
|
-
if (refs.target === "jsonSchema7") {
|
|
3829
|
-
combined.$schema = "http://json-schema.org/draft-07/schema#";
|
|
3830
|
-
} else if (refs.target === "jsonSchema2019-09" || refs.target === "openAi") {
|
|
3831
|
-
combined.$schema = "https://json-schema.org/draft/2019-09/schema#";
|
|
3832
|
-
}
|
|
3833
|
-
if (refs.target === "openAi" && ("anyOf" in combined || "oneOf" in combined || "allOf" in combined || "type" in combined && Array.isArray(combined.type))) {
|
|
3834
|
-
console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property.");
|
|
3835
|
-
}
|
|
3836
|
-
return combined;
|
|
3837
|
-
};
|
|
3838
|
-
|
|
3839
1843
|
// ../core/src/execution/engine/base/errors.ts
|
|
3840
1844
|
var ExecutionError2 = class extends Error {
|
|
3841
1845
|
/**
|
|
@@ -3999,6 +2003,8 @@ var AnthropicConfigSchema = z.discriminatedUnion("model", [
|
|
|
3999
2003
|
AnthropicClaude5ConfigSchema,
|
|
4000
2004
|
AnthropicStandardConfigSchema
|
|
4001
2005
|
]);
|
|
2006
|
+
var ANTHROPIC_CACHE_READ_RATE_MULTIPLIER = 0.1;
|
|
2007
|
+
var OPENAI_CACHE_READ_RATE_MULTIPLIER = 0.5;
|
|
4002
2008
|
var GPT56_CACHE_READ_RATE_MULTIPLIER = 0.1;
|
|
4003
2009
|
var CACHE_CREATION_RATE_MULTIPLIER = 1.25;
|
|
4004
2010
|
var MODEL_INFO = {
|
|
@@ -4195,6 +2201,30 @@ function getModelInfo(model) {
|
|
|
4195
2201
|
}
|
|
4196
2202
|
return void 0;
|
|
4197
2203
|
}
|
|
2204
|
+
function cacheReadRateMultiplier(model, info) {
|
|
2205
|
+
if (info?.cacheReadRateMultiplier !== void 0) return info.cacheReadRateMultiplier;
|
|
2206
|
+
return model.startsWith("claude-") ? ANTHROPIC_CACHE_READ_RATE_MULTIPLIER : OPENAI_CACHE_READ_RATE_MULTIPLIER;
|
|
2207
|
+
}
|
|
2208
|
+
function cacheCreationRateMultiplier(info) {
|
|
2209
|
+
return info?.cacheCreationRateMultiplier ?? CACHE_CREATION_RATE_MULTIPLIER;
|
|
2210
|
+
}
|
|
2211
|
+
function calculateCost(model, inputTokens, outputTokens, cacheReadInputTokens = 0, cacheCreationInputTokens = 0) {
|
|
2212
|
+
const info = getModelInfo(model);
|
|
2213
|
+
if (!info) {
|
|
2214
|
+
console.warn(
|
|
2215
|
+
`[CostCalculator] Unknown model '${model}' - cannot calculate cost. Available models:`,
|
|
2216
|
+
Object.keys(MODEL_INFO)
|
|
2217
|
+
);
|
|
2218
|
+
return 0;
|
|
2219
|
+
}
|
|
2220
|
+
const baseInputRate = info.inputCostPer1M / 100;
|
|
2221
|
+
const inputCostUsd = inputTokens / 1e6 * baseInputRate;
|
|
2222
|
+
const cacheReadCostUsd = cacheReadInputTokens / 1e6 * baseInputRate * cacheReadRateMultiplier(model, info);
|
|
2223
|
+
const cacheCreationCostUsd = cacheCreationInputTokens / 1e6 * baseInputRate * cacheCreationRateMultiplier(info);
|
|
2224
|
+
const outputCostUsd = outputTokens / 1e6 * (info.outputCostPer1M / 100);
|
|
2225
|
+
const totalCostUsd = inputCostUsd + cacheReadCostUsd + cacheCreationCostUsd + outputCostUsd;
|
|
2226
|
+
return totalCostUsd;
|
|
2227
|
+
}
|
|
4198
2228
|
function validateModelConfig(config) {
|
|
4199
2229
|
const model = config.model;
|
|
4200
2230
|
if (!model) {
|
|
@@ -4622,6 +2652,18 @@ var WorkflowTimeoutError = class extends ExecutionError2 {
|
|
|
4622
2652
|
return false;
|
|
4623
2653
|
}
|
|
4624
2654
|
};
|
|
2655
|
+
var WorkflowStepTimeoutError = class extends ExecutionError2 {
|
|
2656
|
+
type = "workflow_step_timeout_error";
|
|
2657
|
+
severity = "critical";
|
|
2658
|
+
category = "workflow";
|
|
2659
|
+
constructor(message, context) {
|
|
2660
|
+
super(message, context);
|
|
2661
|
+
}
|
|
2662
|
+
/** The run still had budget; a slow dependency is exactly the case a retry exists for. */
|
|
2663
|
+
isRetryable() {
|
|
2664
|
+
return true;
|
|
2665
|
+
}
|
|
2666
|
+
};
|
|
4625
2667
|
var WorkflowStalledError = class extends ExecutionError2 {
|
|
4626
2668
|
type = "workflow_stalled_error";
|
|
4627
2669
|
severity = "critical";
|
|
@@ -6750,7 +4792,9 @@ z.object({
|
|
|
6750
4792
|
batch: z.string().trim().min(1).max(255).optional(),
|
|
6751
4793
|
staleSince: z.string().datetime().optional(),
|
|
6752
4794
|
search: z.string().optional(),
|
|
6753
|
-
|
|
4795
|
+
// Was unbounded (`.positive()`, no ceiling) — the one schema in this audit with no cap at all,
|
|
4796
|
+
// worse than the hand-invented-max sites. Now shares the standard ceiling.
|
|
4797
|
+
limit: PageLimitSchema.default(50),
|
|
6754
4798
|
offset: z.coerce.number().int().min(0).default(0)
|
|
6755
4799
|
}).strict();
|
|
6756
4800
|
z.object({
|
|
@@ -7241,7 +5285,7 @@ z.object({
|
|
|
7241
5285
|
batchId: z.string().trim().min(1).max(255).optional(),
|
|
7242
5286
|
status: AcqCompanyStatusSchema.optional(),
|
|
7243
5287
|
includeAll: QueryBooleanSchema.optional(),
|
|
7244
|
-
limit: z.coerce.number().int().min(1).max(5e3).default(
|
|
5288
|
+
limit: z.coerce.number().int().min(1).max(5e3).default(DEFAULT_PAGE_LIMIT),
|
|
7245
5289
|
offset: z.coerce.number().int().min(0).default(0)
|
|
7246
5290
|
}).strict();
|
|
7247
5291
|
z.object({
|
|
@@ -7250,7 +5294,10 @@ z.object({
|
|
|
7250
5294
|
openingLineIsNull: QueryBooleanSchema.optional(),
|
|
7251
5295
|
batchId: z.string().trim().min(1).max(255).optional(),
|
|
7252
5296
|
contactStatus: AcqContactStatusSchema.optional(),
|
|
7253
|
-
|
|
5297
|
+
// Defect: default equaled the max (5000), so every unqualified "list contacts" call fetched
|
|
5298
|
+
// up to 5000 rows by default. The 5000 ceiling stays for callers that deliberately ask for a
|
|
5299
|
+
// large page (mirrors ListCompaniesQuerySchema above); the default now matches it too.
|
|
5300
|
+
limit: z.coerce.number().int().min(1).max(5e3).default(DEFAULT_PAGE_LIMIT),
|
|
7254
5301
|
offset: z.coerce.number().int().min(0).default(0)
|
|
7255
5302
|
}).strict();
|
|
7256
5303
|
z.object({
|
|
@@ -7964,4 +6011,4 @@ function defineWorkflowConfig(resourceId, descriptors, actionRegistry = []) {
|
|
|
7964
6011
|
}
|
|
7965
6012
|
var ListBuilderStageKeySchema = z.string().min(1);
|
|
7966
6013
|
|
|
7967
|
-
export { ActivityEventSchema, BuildPlanSnapshotStepSchema, ContractRefResolutionError, CrmStageKeySchema, CrmStateKeySchema, EmailSchema, ExecutionError, ExecutionError2, LLMResponseParseError, ListBuilderStageKeySchema, ProcessingStageStatusSchema, ProspectingBuildTemplateSchema, RegistryValidationError, ResourceRegistry, StepType, ToolingError, WorkflowCancellationError, WorkflowStalledError, WorkflowStepError, WorkflowTimeoutError, bindResourceDescriptor, buildIterationResponseSchema, compileBusinessOntologyValidationIndex, concurrentPool, createLeadGenStageValidators, defineContract, defineResource, defineResourceOntology, defineResources,
|
|
6014
|
+
export { ActivityEventSchema, BuildPlanSnapshotStepSchema, ContractRefResolutionError, CrmStageKeySchema, CrmStateKeySchema, EmailSchema, ExecutionError, ExecutionError2, LLMResponseParseError, ListBuilderStageKeySchema, ProcessingStageStatusSchema, ProspectingBuildTemplateSchema, RegistryValidationError, ResourceRegistry, StepType, ToolingError, WorkflowCancellationError, WorkflowStalledError, WorkflowStepError, WorkflowStepTimeoutError, WorkflowTimeoutError, allSettledWithConcurrency, bindResourceDescriptor, buildIterationResponseSchema, calculateCost, compileBusinessOntologyValidationIndex, concurrentPool, createLeadGenStageValidators, defineContract, defineResource, defineResourceOntology, defineResources, defineSingleStepWorkflow, defineTopology, defineTopologyRelationship, defineWorkflowConfig, deriveActions, detectCycle, determineNextStep, diagnosticOutput, errorToString, estimateTokens, getErrorDetails, integrationInput, isBuiltInReadinessProfile, isZodType, logExecutionPath, logStepFailure, logStepStart, logStepSuccess, logWorkflowFailure, logWorkflowStart, logWorkflowSuccess, lookupReadinessProfile, parseTopologyNodeRef, registerReadinessProfile, resolveContractRef, runDiagnostic, splitName, topologyRef, topologyRelationship, truncationCharBudget, validateDeclaredSystemInterfaceReadiness, validateDeploymentSpec, validateEntryPoint, validateRelationships, validateResourceGovernance, validateStepReferences, validateTerminalOutput, validateTerminalSteps };
|