integrate-sdk 0.8.37 → 0.8.41-dev.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/adapters/auto-routes.js +1471 -60
- package/dist/adapters/index.js +1471 -60
- package/dist/adapters/nextjs.js +1471 -60
- package/dist/adapters/node.js +1471 -60
- package/dist/adapters/svelte-kit.js +1471 -60
- package/dist/adapters/tanstack-start.js +1471 -60
- package/dist/ai/anthropic.d.ts.map +1 -1
- package/dist/ai/anthropic.js +1240 -21
- package/dist/ai/google.d.ts.map +1 -1
- package/dist/ai/google.js +1292 -18
- package/dist/ai/index.js +1300 -60
- package/dist/ai/openai.d.ts.map +1 -1
- package/dist/ai/openai.js +1240 -21
- package/dist/index.js +1471 -60
- package/dist/oauth.js +1471 -60
- package/dist/server.js +1471 -60
- package/dist/src/ai/anthropic.d.ts.map +1 -1
- package/dist/src/ai/google.d.ts.map +1 -1
- package/dist/src/ai/openai.d.ts.map +1 -1
- package/package.json +5 -4
package/dist/adapters/index.js
CHANGED
|
@@ -7692,6 +7692,1410 @@ var init_vercel_ai = __esm(() => {
|
|
|
7692
7692
|
init_trigger_tools();
|
|
7693
7693
|
});
|
|
7694
7694
|
|
|
7695
|
+
// ../../node_modules/zod-to-json-schema/dist/esm/Options.js
|
|
7696
|
+
var ignoreOverride, defaultOptions, getDefaultOptions = (options) => typeof options === "string" ? {
|
|
7697
|
+
...defaultOptions,
|
|
7698
|
+
name: options
|
|
7699
|
+
} : {
|
|
7700
|
+
...defaultOptions,
|
|
7701
|
+
...options
|
|
7702
|
+
};
|
|
7703
|
+
var init_Options = __esm(() => {
|
|
7704
|
+
ignoreOverride = Symbol("Let zodToJsonSchema decide on which parser to use");
|
|
7705
|
+
defaultOptions = {
|
|
7706
|
+
name: undefined,
|
|
7707
|
+
$refStrategy: "root",
|
|
7708
|
+
basePath: ["#"],
|
|
7709
|
+
effectStrategy: "input",
|
|
7710
|
+
pipeStrategy: "all",
|
|
7711
|
+
dateStrategy: "format:date-time",
|
|
7712
|
+
mapStrategy: "entries",
|
|
7713
|
+
removeAdditionalStrategy: "passthrough",
|
|
7714
|
+
allowedAdditionalProperties: true,
|
|
7715
|
+
rejectedAdditionalProperties: false,
|
|
7716
|
+
definitionPath: "definitions",
|
|
7717
|
+
target: "jsonSchema7",
|
|
7718
|
+
strictUnions: false,
|
|
7719
|
+
definitions: {},
|
|
7720
|
+
errorMessages: false,
|
|
7721
|
+
markdownDescription: false,
|
|
7722
|
+
patternStrategy: "escape",
|
|
7723
|
+
applyRegexFlags: false,
|
|
7724
|
+
emailStrategy: "format:email",
|
|
7725
|
+
base64Strategy: "contentEncoding:base64",
|
|
7726
|
+
nameStrategy: "ref",
|
|
7727
|
+
openAiAnyTypeName: "OpenAiAnyType"
|
|
7728
|
+
};
|
|
7729
|
+
});
|
|
7730
|
+
|
|
7731
|
+
// ../../node_modules/zod-to-json-schema/dist/esm/Refs.js
|
|
7732
|
+
var getRefs = (options) => {
|
|
7733
|
+
const _options = getDefaultOptions(options);
|
|
7734
|
+
const currentPath = _options.name !== undefined ? [..._options.basePath, _options.definitionPath, _options.name] : _options.basePath;
|
|
7735
|
+
return {
|
|
7736
|
+
..._options,
|
|
7737
|
+
flags: { hasReferencedOpenAiAnyType: false },
|
|
7738
|
+
currentPath,
|
|
7739
|
+
propertyPath: undefined,
|
|
7740
|
+
seen: new Map(Object.entries(_options.definitions).map(([name, def]) => [
|
|
7741
|
+
def._def,
|
|
7742
|
+
{
|
|
7743
|
+
def: def._def,
|
|
7744
|
+
path: [..._options.basePath, _options.definitionPath, name],
|
|
7745
|
+
jsonSchema: undefined
|
|
7746
|
+
}
|
|
7747
|
+
]))
|
|
7748
|
+
};
|
|
7749
|
+
};
|
|
7750
|
+
var init_Refs = __esm(() => {
|
|
7751
|
+
init_Options();
|
|
7752
|
+
});
|
|
7753
|
+
|
|
7754
|
+
// ../../node_modules/zod-to-json-schema/dist/esm/errorMessages.js
|
|
7755
|
+
function addErrorMessage(res, key, errorMessage, refs) {
|
|
7756
|
+
if (!refs?.errorMessages)
|
|
7757
|
+
return;
|
|
7758
|
+
if (errorMessage) {
|
|
7759
|
+
res.errorMessage = {
|
|
7760
|
+
...res.errorMessage,
|
|
7761
|
+
[key]: errorMessage
|
|
7762
|
+
};
|
|
7763
|
+
}
|
|
7764
|
+
}
|
|
7765
|
+
function setResponseValueAndErrors(res, key, value, errorMessage, refs) {
|
|
7766
|
+
res[key] = value;
|
|
7767
|
+
addErrorMessage(res, key, errorMessage, refs);
|
|
7768
|
+
}
|
|
7769
|
+
|
|
7770
|
+
// ../../node_modules/zod-to-json-schema/dist/esm/getRelativePath.js
|
|
7771
|
+
var getRelativePath = (pathA, pathB) => {
|
|
7772
|
+
let i = 0;
|
|
7773
|
+
for (;i < pathA.length && i < pathB.length; i++) {
|
|
7774
|
+
if (pathA[i] !== pathB[i])
|
|
7775
|
+
break;
|
|
7776
|
+
}
|
|
7777
|
+
return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
|
|
7778
|
+
};
|
|
7779
|
+
|
|
7780
|
+
// ../../node_modules/zod/v3/index.js
|
|
7781
|
+
var init_v3 = __esm(() => {
|
|
7782
|
+
init_external();
|
|
7783
|
+
});
|
|
7784
|
+
|
|
7785
|
+
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/any.js
|
|
7786
|
+
function parseAnyDef(refs) {
|
|
7787
|
+
if (refs.target !== "openAi") {
|
|
7788
|
+
return {};
|
|
7789
|
+
}
|
|
7790
|
+
const anyDefinitionPath = [
|
|
7791
|
+
...refs.basePath,
|
|
7792
|
+
refs.definitionPath,
|
|
7793
|
+
refs.openAiAnyTypeName
|
|
7794
|
+
];
|
|
7795
|
+
refs.flags.hasReferencedOpenAiAnyType = true;
|
|
7796
|
+
return {
|
|
7797
|
+
$ref: refs.$refStrategy === "relative" ? getRelativePath(anyDefinitionPath, refs.currentPath) : anyDefinitionPath.join("/")
|
|
7798
|
+
};
|
|
7799
|
+
}
|
|
7800
|
+
var init_any = () => {};
|
|
7801
|
+
|
|
7802
|
+
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/array.js
|
|
7803
|
+
function parseArrayDef(def, refs) {
|
|
7804
|
+
const res = {
|
|
7805
|
+
type: "array"
|
|
7806
|
+
};
|
|
7807
|
+
if (def.type?._def && def.type?._def?.typeName !== ZodFirstPartyTypeKind.ZodAny) {
|
|
7808
|
+
res.items = parseDef(def.type._def, {
|
|
7809
|
+
...refs,
|
|
7810
|
+
currentPath: [...refs.currentPath, "items"]
|
|
7811
|
+
});
|
|
7812
|
+
}
|
|
7813
|
+
if (def.minLength) {
|
|
7814
|
+
setResponseValueAndErrors(res, "minItems", def.minLength.value, def.minLength.message, refs);
|
|
7815
|
+
}
|
|
7816
|
+
if (def.maxLength) {
|
|
7817
|
+
setResponseValueAndErrors(res, "maxItems", def.maxLength.value, def.maxLength.message, refs);
|
|
7818
|
+
}
|
|
7819
|
+
if (def.exactLength) {
|
|
7820
|
+
setResponseValueAndErrors(res, "minItems", def.exactLength.value, def.exactLength.message, refs);
|
|
7821
|
+
setResponseValueAndErrors(res, "maxItems", def.exactLength.value, def.exactLength.message, refs);
|
|
7822
|
+
}
|
|
7823
|
+
return res;
|
|
7824
|
+
}
|
|
7825
|
+
var init_array = __esm(() => {
|
|
7826
|
+
init_v3();
|
|
7827
|
+
init_parseDef();
|
|
7828
|
+
});
|
|
7829
|
+
|
|
7830
|
+
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js
|
|
7831
|
+
function parseBigintDef(def, refs) {
|
|
7832
|
+
const res = {
|
|
7833
|
+
type: "integer",
|
|
7834
|
+
format: "int64"
|
|
7835
|
+
};
|
|
7836
|
+
if (!def.checks)
|
|
7837
|
+
return res;
|
|
7838
|
+
for (const check of def.checks) {
|
|
7839
|
+
switch (check.kind) {
|
|
7840
|
+
case "min":
|
|
7841
|
+
if (refs.target === "jsonSchema7") {
|
|
7842
|
+
if (check.inclusive) {
|
|
7843
|
+
setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
7844
|
+
} else {
|
|
7845
|
+
setResponseValueAndErrors(res, "exclusiveMinimum", check.value, check.message, refs);
|
|
7846
|
+
}
|
|
7847
|
+
} else {
|
|
7848
|
+
if (!check.inclusive) {
|
|
7849
|
+
res.exclusiveMinimum = true;
|
|
7850
|
+
}
|
|
7851
|
+
setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
7852
|
+
}
|
|
7853
|
+
break;
|
|
7854
|
+
case "max":
|
|
7855
|
+
if (refs.target === "jsonSchema7") {
|
|
7856
|
+
if (check.inclusive) {
|
|
7857
|
+
setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
7858
|
+
} else {
|
|
7859
|
+
setResponseValueAndErrors(res, "exclusiveMaximum", check.value, check.message, refs);
|
|
7860
|
+
}
|
|
7861
|
+
} else {
|
|
7862
|
+
if (!check.inclusive) {
|
|
7863
|
+
res.exclusiveMaximum = true;
|
|
7864
|
+
}
|
|
7865
|
+
setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
7866
|
+
}
|
|
7867
|
+
break;
|
|
7868
|
+
case "multipleOf":
|
|
7869
|
+
setResponseValueAndErrors(res, "multipleOf", check.value, check.message, refs);
|
|
7870
|
+
break;
|
|
7871
|
+
}
|
|
7872
|
+
}
|
|
7873
|
+
return res;
|
|
7874
|
+
}
|
|
7875
|
+
var init_bigint = () => {};
|
|
7876
|
+
|
|
7877
|
+
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js
|
|
7878
|
+
function parseBooleanDef() {
|
|
7879
|
+
return {
|
|
7880
|
+
type: "boolean"
|
|
7881
|
+
};
|
|
7882
|
+
}
|
|
7883
|
+
|
|
7884
|
+
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/branded.js
|
|
7885
|
+
function parseBrandedDef(_def, refs) {
|
|
7886
|
+
return parseDef(_def.type._def, refs);
|
|
7887
|
+
}
|
|
7888
|
+
var init_branded = __esm(() => {
|
|
7889
|
+
init_parseDef();
|
|
7890
|
+
});
|
|
7891
|
+
|
|
7892
|
+
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/catch.js
|
|
7893
|
+
var parseCatchDef = (def, refs) => {
|
|
7894
|
+
return parseDef(def.innerType._def, refs);
|
|
7895
|
+
};
|
|
7896
|
+
var init_catch = __esm(() => {
|
|
7897
|
+
init_parseDef();
|
|
7898
|
+
});
|
|
7899
|
+
|
|
7900
|
+
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/date.js
|
|
7901
|
+
function parseDateDef(def, refs, overrideDateStrategy) {
|
|
7902
|
+
const strategy = overrideDateStrategy ?? refs.dateStrategy;
|
|
7903
|
+
if (Array.isArray(strategy)) {
|
|
7904
|
+
return {
|
|
7905
|
+
anyOf: strategy.map((item, i) => parseDateDef(def, refs, item))
|
|
7906
|
+
};
|
|
7907
|
+
}
|
|
7908
|
+
switch (strategy) {
|
|
7909
|
+
case "string":
|
|
7910
|
+
case "format:date-time":
|
|
7911
|
+
return {
|
|
7912
|
+
type: "string",
|
|
7913
|
+
format: "date-time"
|
|
7914
|
+
};
|
|
7915
|
+
case "format:date":
|
|
7916
|
+
return {
|
|
7917
|
+
type: "string",
|
|
7918
|
+
format: "date"
|
|
7919
|
+
};
|
|
7920
|
+
case "integer":
|
|
7921
|
+
return integerDateParser(def, refs);
|
|
7922
|
+
}
|
|
7923
|
+
}
|
|
7924
|
+
var integerDateParser = (def, refs) => {
|
|
7925
|
+
const res = {
|
|
7926
|
+
type: "integer",
|
|
7927
|
+
format: "unix-time"
|
|
7928
|
+
};
|
|
7929
|
+
if (refs.target === "openApi3") {
|
|
7930
|
+
return res;
|
|
7931
|
+
}
|
|
7932
|
+
for (const check of def.checks) {
|
|
7933
|
+
switch (check.kind) {
|
|
7934
|
+
case "min":
|
|
7935
|
+
setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
7936
|
+
break;
|
|
7937
|
+
case "max":
|
|
7938
|
+
setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
7939
|
+
break;
|
|
7940
|
+
}
|
|
7941
|
+
}
|
|
7942
|
+
return res;
|
|
7943
|
+
};
|
|
7944
|
+
var init_date = () => {};
|
|
7945
|
+
|
|
7946
|
+
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/default.js
|
|
7947
|
+
function parseDefaultDef(_def, refs) {
|
|
7948
|
+
return {
|
|
7949
|
+
...parseDef(_def.innerType._def, refs),
|
|
7950
|
+
default: _def.defaultValue()
|
|
7951
|
+
};
|
|
7952
|
+
}
|
|
7953
|
+
var init_default = __esm(() => {
|
|
7954
|
+
init_parseDef();
|
|
7955
|
+
});
|
|
7956
|
+
|
|
7957
|
+
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/effects.js
|
|
7958
|
+
function parseEffectsDef(_def, refs) {
|
|
7959
|
+
return refs.effectStrategy === "input" ? parseDef(_def.schema._def, refs) : parseAnyDef(refs);
|
|
7960
|
+
}
|
|
7961
|
+
var init_effects = __esm(() => {
|
|
7962
|
+
init_parseDef();
|
|
7963
|
+
init_any();
|
|
7964
|
+
});
|
|
7965
|
+
|
|
7966
|
+
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/enum.js
|
|
7967
|
+
function parseEnumDef(def) {
|
|
7968
|
+
return {
|
|
7969
|
+
type: "string",
|
|
7970
|
+
enum: Array.from(def.values)
|
|
7971
|
+
};
|
|
7972
|
+
}
|
|
7973
|
+
|
|
7974
|
+
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js
|
|
7975
|
+
function parseIntersectionDef(def, refs) {
|
|
7976
|
+
const allOf = [
|
|
7977
|
+
parseDef(def.left._def, {
|
|
7978
|
+
...refs,
|
|
7979
|
+
currentPath: [...refs.currentPath, "allOf", "0"]
|
|
7980
|
+
}),
|
|
7981
|
+
parseDef(def.right._def, {
|
|
7982
|
+
...refs,
|
|
7983
|
+
currentPath: [...refs.currentPath, "allOf", "1"]
|
|
7984
|
+
})
|
|
7985
|
+
].filter((x) => !!x);
|
|
7986
|
+
let unevaluatedProperties = refs.target === "jsonSchema2019-09" ? { unevaluatedProperties: false } : undefined;
|
|
7987
|
+
const mergedAllOf = [];
|
|
7988
|
+
allOf.forEach((schema) => {
|
|
7989
|
+
if (isJsonSchema7AllOfType(schema)) {
|
|
7990
|
+
mergedAllOf.push(...schema.allOf);
|
|
7991
|
+
if (schema.unevaluatedProperties === undefined) {
|
|
7992
|
+
unevaluatedProperties = undefined;
|
|
7993
|
+
}
|
|
7994
|
+
} else {
|
|
7995
|
+
let nestedSchema = schema;
|
|
7996
|
+
if ("additionalProperties" in schema && schema.additionalProperties === false) {
|
|
7997
|
+
const { additionalProperties, ...rest } = schema;
|
|
7998
|
+
nestedSchema = rest;
|
|
7999
|
+
} else {
|
|
8000
|
+
unevaluatedProperties = undefined;
|
|
8001
|
+
}
|
|
8002
|
+
mergedAllOf.push(nestedSchema);
|
|
8003
|
+
}
|
|
8004
|
+
});
|
|
8005
|
+
return mergedAllOf.length ? {
|
|
8006
|
+
allOf: mergedAllOf,
|
|
8007
|
+
...unevaluatedProperties
|
|
8008
|
+
} : undefined;
|
|
8009
|
+
}
|
|
8010
|
+
var isJsonSchema7AllOfType = (type) => {
|
|
8011
|
+
if ("type" in type && type.type === "string")
|
|
8012
|
+
return false;
|
|
8013
|
+
return "allOf" in type;
|
|
8014
|
+
};
|
|
8015
|
+
var init_intersection = __esm(() => {
|
|
8016
|
+
init_parseDef();
|
|
8017
|
+
});
|
|
8018
|
+
|
|
8019
|
+
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/literal.js
|
|
8020
|
+
function parseLiteralDef(def, refs) {
|
|
8021
|
+
const parsedType = typeof def.value;
|
|
8022
|
+
if (parsedType !== "bigint" && parsedType !== "number" && parsedType !== "boolean" && parsedType !== "string") {
|
|
8023
|
+
return {
|
|
8024
|
+
type: Array.isArray(def.value) ? "array" : "object"
|
|
8025
|
+
};
|
|
8026
|
+
}
|
|
8027
|
+
if (refs.target === "openApi3") {
|
|
8028
|
+
return {
|
|
8029
|
+
type: parsedType === "bigint" ? "integer" : parsedType,
|
|
8030
|
+
enum: [def.value]
|
|
8031
|
+
};
|
|
8032
|
+
}
|
|
8033
|
+
return {
|
|
8034
|
+
type: parsedType === "bigint" ? "integer" : parsedType,
|
|
8035
|
+
const: def.value
|
|
8036
|
+
};
|
|
8037
|
+
}
|
|
8038
|
+
|
|
8039
|
+
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/string.js
|
|
8040
|
+
function parseStringDef(def, refs) {
|
|
8041
|
+
const res = {
|
|
8042
|
+
type: "string"
|
|
8043
|
+
};
|
|
8044
|
+
if (def.checks) {
|
|
8045
|
+
for (const check of def.checks) {
|
|
8046
|
+
switch (check.kind) {
|
|
8047
|
+
case "min":
|
|
8048
|
+
setResponseValueAndErrors(res, "minLength", typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value, check.message, refs);
|
|
8049
|
+
break;
|
|
8050
|
+
case "max":
|
|
8051
|
+
setResponseValueAndErrors(res, "maxLength", typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);
|
|
8052
|
+
break;
|
|
8053
|
+
case "email":
|
|
8054
|
+
switch (refs.emailStrategy) {
|
|
8055
|
+
case "format:email":
|
|
8056
|
+
addFormat(res, "email", check.message, refs);
|
|
8057
|
+
break;
|
|
8058
|
+
case "format:idn-email":
|
|
8059
|
+
addFormat(res, "idn-email", check.message, refs);
|
|
8060
|
+
break;
|
|
8061
|
+
case "pattern:zod":
|
|
8062
|
+
addPattern(res, zodPatterns.email, check.message, refs);
|
|
8063
|
+
break;
|
|
8064
|
+
}
|
|
8065
|
+
break;
|
|
8066
|
+
case "url":
|
|
8067
|
+
addFormat(res, "uri", check.message, refs);
|
|
8068
|
+
break;
|
|
8069
|
+
case "uuid":
|
|
8070
|
+
addFormat(res, "uuid", check.message, refs);
|
|
8071
|
+
break;
|
|
8072
|
+
case "regex":
|
|
8073
|
+
addPattern(res, check.regex, check.message, refs);
|
|
8074
|
+
break;
|
|
8075
|
+
case "cuid":
|
|
8076
|
+
addPattern(res, zodPatterns.cuid, check.message, refs);
|
|
8077
|
+
break;
|
|
8078
|
+
case "cuid2":
|
|
8079
|
+
addPattern(res, zodPatterns.cuid2, check.message, refs);
|
|
8080
|
+
break;
|
|
8081
|
+
case "startsWith":
|
|
8082
|
+
addPattern(res, RegExp(`^${escapeLiteralCheckValue(check.value, refs)}`), check.message, refs);
|
|
8083
|
+
break;
|
|
8084
|
+
case "endsWith":
|
|
8085
|
+
addPattern(res, RegExp(`${escapeLiteralCheckValue(check.value, refs)}$`), check.message, refs);
|
|
8086
|
+
break;
|
|
8087
|
+
case "datetime":
|
|
8088
|
+
addFormat(res, "date-time", check.message, refs);
|
|
8089
|
+
break;
|
|
8090
|
+
case "date":
|
|
8091
|
+
addFormat(res, "date", check.message, refs);
|
|
8092
|
+
break;
|
|
8093
|
+
case "time":
|
|
8094
|
+
addFormat(res, "time", check.message, refs);
|
|
8095
|
+
break;
|
|
8096
|
+
case "duration":
|
|
8097
|
+
addFormat(res, "duration", check.message, refs);
|
|
8098
|
+
break;
|
|
8099
|
+
case "length":
|
|
8100
|
+
setResponseValueAndErrors(res, "minLength", typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value, check.message, refs);
|
|
8101
|
+
setResponseValueAndErrors(res, "maxLength", typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);
|
|
8102
|
+
break;
|
|
8103
|
+
case "includes": {
|
|
8104
|
+
addPattern(res, RegExp(escapeLiteralCheckValue(check.value, refs)), check.message, refs);
|
|
8105
|
+
break;
|
|
8106
|
+
}
|
|
8107
|
+
case "ip": {
|
|
8108
|
+
if (check.version !== "v6") {
|
|
8109
|
+
addFormat(res, "ipv4", check.message, refs);
|
|
8110
|
+
}
|
|
8111
|
+
if (check.version !== "v4") {
|
|
8112
|
+
addFormat(res, "ipv6", check.message, refs);
|
|
8113
|
+
}
|
|
8114
|
+
break;
|
|
8115
|
+
}
|
|
8116
|
+
case "base64url":
|
|
8117
|
+
addPattern(res, zodPatterns.base64url, check.message, refs);
|
|
8118
|
+
break;
|
|
8119
|
+
case "jwt":
|
|
8120
|
+
addPattern(res, zodPatterns.jwt, check.message, refs);
|
|
8121
|
+
break;
|
|
8122
|
+
case "cidr": {
|
|
8123
|
+
if (check.version !== "v6") {
|
|
8124
|
+
addPattern(res, zodPatterns.ipv4Cidr, check.message, refs);
|
|
8125
|
+
}
|
|
8126
|
+
if (check.version !== "v4") {
|
|
8127
|
+
addPattern(res, zodPatterns.ipv6Cidr, check.message, refs);
|
|
8128
|
+
}
|
|
8129
|
+
break;
|
|
8130
|
+
}
|
|
8131
|
+
case "emoji":
|
|
8132
|
+
addPattern(res, zodPatterns.emoji(), check.message, refs);
|
|
8133
|
+
break;
|
|
8134
|
+
case "ulid": {
|
|
8135
|
+
addPattern(res, zodPatterns.ulid, check.message, refs);
|
|
8136
|
+
break;
|
|
8137
|
+
}
|
|
8138
|
+
case "base64": {
|
|
8139
|
+
switch (refs.base64Strategy) {
|
|
8140
|
+
case "format:binary": {
|
|
8141
|
+
addFormat(res, "binary", check.message, refs);
|
|
8142
|
+
break;
|
|
8143
|
+
}
|
|
8144
|
+
case "contentEncoding:base64": {
|
|
8145
|
+
setResponseValueAndErrors(res, "contentEncoding", "base64", check.message, refs);
|
|
8146
|
+
break;
|
|
8147
|
+
}
|
|
8148
|
+
case "pattern:zod": {
|
|
8149
|
+
addPattern(res, zodPatterns.base64, check.message, refs);
|
|
8150
|
+
break;
|
|
8151
|
+
}
|
|
8152
|
+
}
|
|
8153
|
+
break;
|
|
8154
|
+
}
|
|
8155
|
+
case "nanoid": {
|
|
8156
|
+
addPattern(res, zodPatterns.nanoid, check.message, refs);
|
|
8157
|
+
}
|
|
8158
|
+
case "toLowerCase":
|
|
8159
|
+
case "toUpperCase":
|
|
8160
|
+
case "trim":
|
|
8161
|
+
break;
|
|
8162
|
+
default:
|
|
8163
|
+
((_) => {})(check);
|
|
8164
|
+
}
|
|
8165
|
+
}
|
|
8166
|
+
}
|
|
8167
|
+
return res;
|
|
8168
|
+
}
|
|
8169
|
+
function escapeLiteralCheckValue(literal, refs) {
|
|
8170
|
+
return refs.patternStrategy === "escape" ? escapeNonAlphaNumeric(literal) : literal;
|
|
8171
|
+
}
|
|
8172
|
+
function escapeNonAlphaNumeric(source) {
|
|
8173
|
+
let result = "";
|
|
8174
|
+
for (let i = 0;i < source.length; i++) {
|
|
8175
|
+
if (!ALPHA_NUMERIC.has(source[i])) {
|
|
8176
|
+
result += "\\";
|
|
8177
|
+
}
|
|
8178
|
+
result += source[i];
|
|
8179
|
+
}
|
|
8180
|
+
return result;
|
|
8181
|
+
}
|
|
8182
|
+
function addFormat(schema, value, message, refs) {
|
|
8183
|
+
if (schema.format || schema.anyOf?.some((x) => x.format)) {
|
|
8184
|
+
if (!schema.anyOf) {
|
|
8185
|
+
schema.anyOf = [];
|
|
8186
|
+
}
|
|
8187
|
+
if (schema.format) {
|
|
8188
|
+
schema.anyOf.push({
|
|
8189
|
+
format: schema.format,
|
|
8190
|
+
...schema.errorMessage && refs.errorMessages && {
|
|
8191
|
+
errorMessage: { format: schema.errorMessage.format }
|
|
8192
|
+
}
|
|
8193
|
+
});
|
|
8194
|
+
delete schema.format;
|
|
8195
|
+
if (schema.errorMessage) {
|
|
8196
|
+
delete schema.errorMessage.format;
|
|
8197
|
+
if (Object.keys(schema.errorMessage).length === 0) {
|
|
8198
|
+
delete schema.errorMessage;
|
|
8199
|
+
}
|
|
8200
|
+
}
|
|
8201
|
+
}
|
|
8202
|
+
schema.anyOf.push({
|
|
8203
|
+
format: value,
|
|
8204
|
+
...message && refs.errorMessages && { errorMessage: { format: message } }
|
|
8205
|
+
});
|
|
8206
|
+
} else {
|
|
8207
|
+
setResponseValueAndErrors(schema, "format", value, message, refs);
|
|
8208
|
+
}
|
|
8209
|
+
}
|
|
8210
|
+
function addPattern(schema, regex, message, refs) {
|
|
8211
|
+
if (schema.pattern || schema.allOf?.some((x) => x.pattern)) {
|
|
8212
|
+
if (!schema.allOf) {
|
|
8213
|
+
schema.allOf = [];
|
|
8214
|
+
}
|
|
8215
|
+
if (schema.pattern) {
|
|
8216
|
+
schema.allOf.push({
|
|
8217
|
+
pattern: schema.pattern,
|
|
8218
|
+
...schema.errorMessage && refs.errorMessages && {
|
|
8219
|
+
errorMessage: { pattern: schema.errorMessage.pattern }
|
|
8220
|
+
}
|
|
8221
|
+
});
|
|
8222
|
+
delete schema.pattern;
|
|
8223
|
+
if (schema.errorMessage) {
|
|
8224
|
+
delete schema.errorMessage.pattern;
|
|
8225
|
+
if (Object.keys(schema.errorMessage).length === 0) {
|
|
8226
|
+
delete schema.errorMessage;
|
|
8227
|
+
}
|
|
8228
|
+
}
|
|
8229
|
+
}
|
|
8230
|
+
schema.allOf.push({
|
|
8231
|
+
pattern: stringifyRegExpWithFlags(regex, refs),
|
|
8232
|
+
...message && refs.errorMessages && { errorMessage: { pattern: message } }
|
|
8233
|
+
});
|
|
8234
|
+
} else {
|
|
8235
|
+
setResponseValueAndErrors(schema, "pattern", stringifyRegExpWithFlags(regex, refs), message, refs);
|
|
8236
|
+
}
|
|
8237
|
+
}
|
|
8238
|
+
function stringifyRegExpWithFlags(regex, refs) {
|
|
8239
|
+
if (!refs.applyRegexFlags || !regex.flags) {
|
|
8240
|
+
return regex.source;
|
|
8241
|
+
}
|
|
8242
|
+
const flags = {
|
|
8243
|
+
i: regex.flags.includes("i"),
|
|
8244
|
+
m: regex.flags.includes("m"),
|
|
8245
|
+
s: regex.flags.includes("s")
|
|
8246
|
+
};
|
|
8247
|
+
const source = flags.i ? regex.source.toLowerCase() : regex.source;
|
|
8248
|
+
let pattern = "";
|
|
8249
|
+
let isEscaped = false;
|
|
8250
|
+
let inCharGroup = false;
|
|
8251
|
+
let inCharRange = false;
|
|
8252
|
+
for (let i = 0;i < source.length; i++) {
|
|
8253
|
+
if (isEscaped) {
|
|
8254
|
+
pattern += source[i];
|
|
8255
|
+
isEscaped = false;
|
|
8256
|
+
continue;
|
|
8257
|
+
}
|
|
8258
|
+
if (flags.i) {
|
|
8259
|
+
if (inCharGroup) {
|
|
8260
|
+
if (source[i].match(/[a-z]/)) {
|
|
8261
|
+
if (inCharRange) {
|
|
8262
|
+
pattern += source[i];
|
|
8263
|
+
pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
|
|
8264
|
+
inCharRange = false;
|
|
8265
|
+
} else if (source[i + 1] === "-" && source[i + 2]?.match(/[a-z]/)) {
|
|
8266
|
+
pattern += source[i];
|
|
8267
|
+
inCharRange = true;
|
|
8268
|
+
} else {
|
|
8269
|
+
pattern += `${source[i]}${source[i].toUpperCase()}`;
|
|
8270
|
+
}
|
|
8271
|
+
continue;
|
|
8272
|
+
}
|
|
8273
|
+
} else if (source[i].match(/[a-z]/)) {
|
|
8274
|
+
pattern += `[${source[i]}${source[i].toUpperCase()}]`;
|
|
8275
|
+
continue;
|
|
8276
|
+
}
|
|
8277
|
+
}
|
|
8278
|
+
if (flags.m) {
|
|
8279
|
+
if (source[i] === "^") {
|
|
8280
|
+
pattern += `(^|(?<=[\r
|
|
8281
|
+
]))`;
|
|
8282
|
+
continue;
|
|
8283
|
+
} else if (source[i] === "$") {
|
|
8284
|
+
pattern += `($|(?=[\r
|
|
8285
|
+
]))`;
|
|
8286
|
+
continue;
|
|
8287
|
+
}
|
|
8288
|
+
}
|
|
8289
|
+
if (flags.s && source[i] === ".") {
|
|
8290
|
+
pattern += inCharGroup ? `${source[i]}\r
|
|
8291
|
+
` : `[${source[i]}\r
|
|
8292
|
+
]`;
|
|
8293
|
+
continue;
|
|
8294
|
+
}
|
|
8295
|
+
pattern += source[i];
|
|
8296
|
+
if (source[i] === "\\") {
|
|
8297
|
+
isEscaped = true;
|
|
8298
|
+
} else if (inCharGroup && source[i] === "]") {
|
|
8299
|
+
inCharGroup = false;
|
|
8300
|
+
} else if (!inCharGroup && source[i] === "[") {
|
|
8301
|
+
inCharGroup = true;
|
|
8302
|
+
}
|
|
8303
|
+
}
|
|
8304
|
+
try {
|
|
8305
|
+
new RegExp(pattern);
|
|
8306
|
+
} catch {
|
|
8307
|
+
console.warn(`Could not convert regex pattern at ${refs.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`);
|
|
8308
|
+
return regex.source;
|
|
8309
|
+
}
|
|
8310
|
+
return pattern;
|
|
8311
|
+
}
|
|
8312
|
+
var emojiRegex2 = undefined, zodPatterns, ALPHA_NUMERIC;
|
|
8313
|
+
var init_string = __esm(() => {
|
|
8314
|
+
zodPatterns = {
|
|
8315
|
+
cuid: /^[cC][^\s-]{8,}$/,
|
|
8316
|
+
cuid2: /^[0-9a-z]+$/,
|
|
8317
|
+
ulid: /^[0-9A-HJKMNP-TV-Z]{26}$/,
|
|
8318
|
+
email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,
|
|
8319
|
+
emoji: () => {
|
|
8320
|
+
if (emojiRegex2 === undefined) {
|
|
8321
|
+
emojiRegex2 = RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u");
|
|
8322
|
+
}
|
|
8323
|
+
return emojiRegex2;
|
|
8324
|
+
},
|
|
8325
|
+
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}$/,
|
|
8326
|
+
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])$/,
|
|
8327
|
+
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])$/,
|
|
8328
|
+
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})))$/,
|
|
8329
|
+
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])$/,
|
|
8330
|
+
base64: /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,
|
|
8331
|
+
base64url: /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,
|
|
8332
|
+
nanoid: /^[a-zA-Z0-9_-]{21}$/,
|
|
8333
|
+
jwt: /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/
|
|
8334
|
+
};
|
|
8335
|
+
ALPHA_NUMERIC = new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
|
|
8336
|
+
});
|
|
8337
|
+
|
|
8338
|
+
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/record.js
|
|
8339
|
+
function parseRecordDef(def, refs) {
|
|
8340
|
+
if (refs.target === "openAi") {
|
|
8341
|
+
console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.");
|
|
8342
|
+
}
|
|
8343
|
+
if (refs.target === "openApi3" && def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodEnum) {
|
|
8344
|
+
return {
|
|
8345
|
+
type: "object",
|
|
8346
|
+
required: def.keyType._def.values,
|
|
8347
|
+
properties: def.keyType._def.values.reduce((acc, key) => ({
|
|
8348
|
+
...acc,
|
|
8349
|
+
[key]: parseDef(def.valueType._def, {
|
|
8350
|
+
...refs,
|
|
8351
|
+
currentPath: [...refs.currentPath, "properties", key]
|
|
8352
|
+
}) ?? parseAnyDef(refs)
|
|
8353
|
+
}), {}),
|
|
8354
|
+
additionalProperties: refs.rejectedAdditionalProperties
|
|
8355
|
+
};
|
|
8356
|
+
}
|
|
8357
|
+
const schema = {
|
|
8358
|
+
type: "object",
|
|
8359
|
+
additionalProperties: parseDef(def.valueType._def, {
|
|
8360
|
+
...refs,
|
|
8361
|
+
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
8362
|
+
}) ?? refs.allowedAdditionalProperties
|
|
8363
|
+
};
|
|
8364
|
+
if (refs.target === "openApi3") {
|
|
8365
|
+
return schema;
|
|
8366
|
+
}
|
|
8367
|
+
if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodString && def.keyType._def.checks?.length) {
|
|
8368
|
+
const { type, ...keyType } = parseStringDef(def.keyType._def, refs);
|
|
8369
|
+
return {
|
|
8370
|
+
...schema,
|
|
8371
|
+
propertyNames: keyType
|
|
8372
|
+
};
|
|
8373
|
+
} else if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodEnum) {
|
|
8374
|
+
return {
|
|
8375
|
+
...schema,
|
|
8376
|
+
propertyNames: {
|
|
8377
|
+
enum: def.keyType._def.values
|
|
8378
|
+
}
|
|
8379
|
+
};
|
|
8380
|
+
} else if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodBranded && def.keyType._def.type._def.typeName === ZodFirstPartyTypeKind.ZodString && def.keyType._def.type._def.checks?.length) {
|
|
8381
|
+
const { type, ...keyType } = parseBrandedDef(def.keyType._def, refs);
|
|
8382
|
+
return {
|
|
8383
|
+
...schema,
|
|
8384
|
+
propertyNames: keyType
|
|
8385
|
+
};
|
|
8386
|
+
}
|
|
8387
|
+
return schema;
|
|
8388
|
+
}
|
|
8389
|
+
var init_record = __esm(() => {
|
|
8390
|
+
init_v3();
|
|
8391
|
+
init_parseDef();
|
|
8392
|
+
init_string();
|
|
8393
|
+
init_branded();
|
|
8394
|
+
init_any();
|
|
8395
|
+
});
|
|
8396
|
+
|
|
8397
|
+
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/map.js
|
|
8398
|
+
function parseMapDef(def, refs) {
|
|
8399
|
+
if (refs.mapStrategy === "record") {
|
|
8400
|
+
return parseRecordDef(def, refs);
|
|
8401
|
+
}
|
|
8402
|
+
const keys = parseDef(def.keyType._def, {
|
|
8403
|
+
...refs,
|
|
8404
|
+
currentPath: [...refs.currentPath, "items", "items", "0"]
|
|
8405
|
+
}) || parseAnyDef(refs);
|
|
8406
|
+
const values = parseDef(def.valueType._def, {
|
|
8407
|
+
...refs,
|
|
8408
|
+
currentPath: [...refs.currentPath, "items", "items", "1"]
|
|
8409
|
+
}) || parseAnyDef(refs);
|
|
8410
|
+
return {
|
|
8411
|
+
type: "array",
|
|
8412
|
+
maxItems: 125,
|
|
8413
|
+
items: {
|
|
8414
|
+
type: "array",
|
|
8415
|
+
items: [keys, values],
|
|
8416
|
+
minItems: 2,
|
|
8417
|
+
maxItems: 2
|
|
8418
|
+
}
|
|
8419
|
+
};
|
|
8420
|
+
}
|
|
8421
|
+
var init_map = __esm(() => {
|
|
8422
|
+
init_parseDef();
|
|
8423
|
+
init_record();
|
|
8424
|
+
init_any();
|
|
8425
|
+
});
|
|
8426
|
+
|
|
8427
|
+
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js
|
|
8428
|
+
function parseNativeEnumDef(def) {
|
|
8429
|
+
const object = def.values;
|
|
8430
|
+
const actualKeys = Object.keys(def.values).filter((key) => {
|
|
8431
|
+
return typeof object[object[key]] !== "number";
|
|
8432
|
+
});
|
|
8433
|
+
const actualValues = actualKeys.map((key) => object[key]);
|
|
8434
|
+
const parsedTypes = Array.from(new Set(actualValues.map((values) => typeof values)));
|
|
8435
|
+
return {
|
|
8436
|
+
type: parsedTypes.length === 1 ? parsedTypes[0] === "string" ? "string" : "number" : ["string", "number"],
|
|
8437
|
+
enum: actualValues
|
|
8438
|
+
};
|
|
8439
|
+
}
|
|
8440
|
+
|
|
8441
|
+
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/never.js
|
|
8442
|
+
function parseNeverDef(refs) {
|
|
8443
|
+
return refs.target === "openAi" ? undefined : {
|
|
8444
|
+
not: parseAnyDef({
|
|
8445
|
+
...refs,
|
|
8446
|
+
currentPath: [...refs.currentPath, "not"]
|
|
8447
|
+
})
|
|
8448
|
+
};
|
|
8449
|
+
}
|
|
8450
|
+
var init_never = __esm(() => {
|
|
8451
|
+
init_any();
|
|
8452
|
+
});
|
|
8453
|
+
|
|
8454
|
+
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/null.js
|
|
8455
|
+
function parseNullDef(refs) {
|
|
8456
|
+
return refs.target === "openApi3" ? {
|
|
8457
|
+
enum: ["null"],
|
|
8458
|
+
nullable: true
|
|
8459
|
+
} : {
|
|
8460
|
+
type: "null"
|
|
8461
|
+
};
|
|
8462
|
+
}
|
|
8463
|
+
|
|
8464
|
+
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/union.js
|
|
8465
|
+
function parseUnionDef(def, refs) {
|
|
8466
|
+
if (refs.target === "openApi3")
|
|
8467
|
+
return asAnyOf(def, refs);
|
|
8468
|
+
const options = def.options instanceof Map ? Array.from(def.options.values()) : def.options;
|
|
8469
|
+
if (options.every((x) => (x._def.typeName in primitiveMappings) && (!x._def.checks || !x._def.checks.length))) {
|
|
8470
|
+
const types2 = options.reduce((types3, x) => {
|
|
8471
|
+
const type = primitiveMappings[x._def.typeName];
|
|
8472
|
+
return type && !types3.includes(type) ? [...types3, type] : types3;
|
|
8473
|
+
}, []);
|
|
8474
|
+
return {
|
|
8475
|
+
type: types2.length > 1 ? types2 : types2[0]
|
|
8476
|
+
};
|
|
8477
|
+
} else if (options.every((x) => x._def.typeName === "ZodLiteral" && !x.description)) {
|
|
8478
|
+
const types2 = options.reduce((acc, x) => {
|
|
8479
|
+
const type = typeof x._def.value;
|
|
8480
|
+
switch (type) {
|
|
8481
|
+
case "string":
|
|
8482
|
+
case "number":
|
|
8483
|
+
case "boolean":
|
|
8484
|
+
return [...acc, type];
|
|
8485
|
+
case "bigint":
|
|
8486
|
+
return [...acc, "integer"];
|
|
8487
|
+
case "object":
|
|
8488
|
+
if (x._def.value === null)
|
|
8489
|
+
return [...acc, "null"];
|
|
8490
|
+
case "symbol":
|
|
8491
|
+
case "undefined":
|
|
8492
|
+
case "function":
|
|
8493
|
+
default:
|
|
8494
|
+
return acc;
|
|
8495
|
+
}
|
|
8496
|
+
}, []);
|
|
8497
|
+
if (types2.length === options.length) {
|
|
8498
|
+
const uniqueTypes = types2.filter((x, i, a) => a.indexOf(x) === i);
|
|
8499
|
+
return {
|
|
8500
|
+
type: uniqueTypes.length > 1 ? uniqueTypes : uniqueTypes[0],
|
|
8501
|
+
enum: options.reduce((acc, x) => {
|
|
8502
|
+
return acc.includes(x._def.value) ? acc : [...acc, x._def.value];
|
|
8503
|
+
}, [])
|
|
8504
|
+
};
|
|
8505
|
+
}
|
|
8506
|
+
} else if (options.every((x) => x._def.typeName === "ZodEnum")) {
|
|
8507
|
+
return {
|
|
8508
|
+
type: "string",
|
|
8509
|
+
enum: options.reduce((acc, x) => [
|
|
8510
|
+
...acc,
|
|
8511
|
+
...x._def.values.filter((x2) => !acc.includes(x2))
|
|
8512
|
+
], [])
|
|
8513
|
+
};
|
|
8514
|
+
}
|
|
8515
|
+
return asAnyOf(def, refs);
|
|
8516
|
+
}
|
|
8517
|
+
var primitiveMappings, asAnyOf = (def, refs) => {
|
|
8518
|
+
const anyOf = (def.options instanceof Map ? Array.from(def.options.values()) : def.options).map((x, i) => parseDef(x._def, {
|
|
8519
|
+
...refs,
|
|
8520
|
+
currentPath: [...refs.currentPath, "anyOf", `${i}`]
|
|
8521
|
+
})).filter((x) => !!x && (!refs.strictUnions || typeof x === "object" && Object.keys(x).length > 0));
|
|
8522
|
+
return anyOf.length ? { anyOf } : undefined;
|
|
8523
|
+
};
|
|
8524
|
+
var init_union = __esm(() => {
|
|
8525
|
+
init_parseDef();
|
|
8526
|
+
primitiveMappings = {
|
|
8527
|
+
ZodString: "string",
|
|
8528
|
+
ZodNumber: "number",
|
|
8529
|
+
ZodBigInt: "integer",
|
|
8530
|
+
ZodBoolean: "boolean",
|
|
8531
|
+
ZodNull: "null"
|
|
8532
|
+
};
|
|
8533
|
+
});
|
|
8534
|
+
|
|
8535
|
+
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js
|
|
8536
|
+
function parseNullableDef(def, refs) {
|
|
8537
|
+
if (["ZodString", "ZodNumber", "ZodBigInt", "ZodBoolean", "ZodNull"].includes(def.innerType._def.typeName) && (!def.innerType._def.checks || !def.innerType._def.checks.length)) {
|
|
8538
|
+
if (refs.target === "openApi3") {
|
|
8539
|
+
return {
|
|
8540
|
+
type: primitiveMappings[def.innerType._def.typeName],
|
|
8541
|
+
nullable: true
|
|
8542
|
+
};
|
|
8543
|
+
}
|
|
8544
|
+
return {
|
|
8545
|
+
type: [
|
|
8546
|
+
primitiveMappings[def.innerType._def.typeName],
|
|
8547
|
+
"null"
|
|
8548
|
+
]
|
|
8549
|
+
};
|
|
8550
|
+
}
|
|
8551
|
+
if (refs.target === "openApi3") {
|
|
8552
|
+
const base2 = parseDef(def.innerType._def, {
|
|
8553
|
+
...refs,
|
|
8554
|
+
currentPath: [...refs.currentPath]
|
|
8555
|
+
});
|
|
8556
|
+
if (base2 && "$ref" in base2)
|
|
8557
|
+
return { allOf: [base2], nullable: true };
|
|
8558
|
+
return base2 && { ...base2, nullable: true };
|
|
8559
|
+
}
|
|
8560
|
+
const base = parseDef(def.innerType._def, {
|
|
8561
|
+
...refs,
|
|
8562
|
+
currentPath: [...refs.currentPath, "anyOf", "0"]
|
|
8563
|
+
});
|
|
8564
|
+
return base && { anyOf: [base, { type: "null" }] };
|
|
8565
|
+
}
|
|
8566
|
+
var init_nullable = __esm(() => {
|
|
8567
|
+
init_parseDef();
|
|
8568
|
+
init_union();
|
|
8569
|
+
});
|
|
8570
|
+
|
|
8571
|
+
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/number.js
|
|
8572
|
+
function parseNumberDef(def, refs) {
|
|
8573
|
+
const res = {
|
|
8574
|
+
type: "number"
|
|
8575
|
+
};
|
|
8576
|
+
if (!def.checks)
|
|
8577
|
+
return res;
|
|
8578
|
+
for (const check of def.checks) {
|
|
8579
|
+
switch (check.kind) {
|
|
8580
|
+
case "int":
|
|
8581
|
+
res.type = "integer";
|
|
8582
|
+
addErrorMessage(res, "type", check.message, refs);
|
|
8583
|
+
break;
|
|
8584
|
+
case "min":
|
|
8585
|
+
if (refs.target === "jsonSchema7") {
|
|
8586
|
+
if (check.inclusive) {
|
|
8587
|
+
setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
8588
|
+
} else {
|
|
8589
|
+
setResponseValueAndErrors(res, "exclusiveMinimum", check.value, check.message, refs);
|
|
8590
|
+
}
|
|
8591
|
+
} else {
|
|
8592
|
+
if (!check.inclusive) {
|
|
8593
|
+
res.exclusiveMinimum = true;
|
|
8594
|
+
}
|
|
8595
|
+
setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
8596
|
+
}
|
|
8597
|
+
break;
|
|
8598
|
+
case "max":
|
|
8599
|
+
if (refs.target === "jsonSchema7") {
|
|
8600
|
+
if (check.inclusive) {
|
|
8601
|
+
setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
8602
|
+
} else {
|
|
8603
|
+
setResponseValueAndErrors(res, "exclusiveMaximum", check.value, check.message, refs);
|
|
8604
|
+
}
|
|
8605
|
+
} else {
|
|
8606
|
+
if (!check.inclusive) {
|
|
8607
|
+
res.exclusiveMaximum = true;
|
|
8608
|
+
}
|
|
8609
|
+
setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
8610
|
+
}
|
|
8611
|
+
break;
|
|
8612
|
+
case "multipleOf":
|
|
8613
|
+
setResponseValueAndErrors(res, "multipleOf", check.value, check.message, refs);
|
|
8614
|
+
break;
|
|
8615
|
+
}
|
|
8616
|
+
}
|
|
8617
|
+
return res;
|
|
8618
|
+
}
|
|
8619
|
+
var init_number = () => {};
|
|
8620
|
+
|
|
8621
|
+
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/object.js
|
|
8622
|
+
function parseObjectDef(def, refs) {
|
|
8623
|
+
const forceOptionalIntoNullable = refs.target === "openAi";
|
|
8624
|
+
const result = {
|
|
8625
|
+
type: "object",
|
|
8626
|
+
properties: {}
|
|
8627
|
+
};
|
|
8628
|
+
const required = [];
|
|
8629
|
+
const shape = def.shape();
|
|
8630
|
+
for (const propName in shape) {
|
|
8631
|
+
let propDef = shape[propName];
|
|
8632
|
+
if (propDef === undefined || propDef._def === undefined) {
|
|
8633
|
+
continue;
|
|
8634
|
+
}
|
|
8635
|
+
let propOptional = safeIsOptional(propDef);
|
|
8636
|
+
if (propOptional && forceOptionalIntoNullable) {
|
|
8637
|
+
if (propDef._def.typeName === "ZodOptional") {
|
|
8638
|
+
propDef = propDef._def.innerType;
|
|
8639
|
+
}
|
|
8640
|
+
if (!propDef.isNullable()) {
|
|
8641
|
+
propDef = propDef.nullable();
|
|
8642
|
+
}
|
|
8643
|
+
propOptional = false;
|
|
8644
|
+
}
|
|
8645
|
+
const parsedDef = parseDef(propDef._def, {
|
|
8646
|
+
...refs,
|
|
8647
|
+
currentPath: [...refs.currentPath, "properties", propName],
|
|
8648
|
+
propertyPath: [...refs.currentPath, "properties", propName]
|
|
8649
|
+
});
|
|
8650
|
+
if (parsedDef === undefined) {
|
|
8651
|
+
continue;
|
|
8652
|
+
}
|
|
8653
|
+
result.properties[propName] = parsedDef;
|
|
8654
|
+
if (!propOptional) {
|
|
8655
|
+
required.push(propName);
|
|
8656
|
+
}
|
|
8657
|
+
}
|
|
8658
|
+
if (required.length) {
|
|
8659
|
+
result.required = required;
|
|
8660
|
+
}
|
|
8661
|
+
const additionalProperties = decideAdditionalProperties(def, refs);
|
|
8662
|
+
if (additionalProperties !== undefined) {
|
|
8663
|
+
result.additionalProperties = additionalProperties;
|
|
8664
|
+
}
|
|
8665
|
+
return result;
|
|
8666
|
+
}
|
|
8667
|
+
function decideAdditionalProperties(def, refs) {
|
|
8668
|
+
if (def.catchall._def.typeName !== "ZodNever") {
|
|
8669
|
+
return parseDef(def.catchall._def, {
|
|
8670
|
+
...refs,
|
|
8671
|
+
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
8672
|
+
});
|
|
8673
|
+
}
|
|
8674
|
+
switch (def.unknownKeys) {
|
|
8675
|
+
case "passthrough":
|
|
8676
|
+
return refs.allowedAdditionalProperties;
|
|
8677
|
+
case "strict":
|
|
8678
|
+
return refs.rejectedAdditionalProperties;
|
|
8679
|
+
case "strip":
|
|
8680
|
+
return refs.removeAdditionalStrategy === "strict" ? refs.allowedAdditionalProperties : refs.rejectedAdditionalProperties;
|
|
8681
|
+
}
|
|
8682
|
+
}
|
|
8683
|
+
function safeIsOptional(schema) {
|
|
8684
|
+
try {
|
|
8685
|
+
return schema.isOptional();
|
|
8686
|
+
} catch {
|
|
8687
|
+
return true;
|
|
8688
|
+
}
|
|
8689
|
+
}
|
|
8690
|
+
var init_object = __esm(() => {
|
|
8691
|
+
init_parseDef();
|
|
8692
|
+
});
|
|
8693
|
+
|
|
8694
|
+
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/optional.js
|
|
8695
|
+
var parseOptionalDef = (def, refs) => {
|
|
8696
|
+
if (refs.currentPath.toString() === refs.propertyPath?.toString()) {
|
|
8697
|
+
return parseDef(def.innerType._def, refs);
|
|
8698
|
+
}
|
|
8699
|
+
const innerSchema = parseDef(def.innerType._def, {
|
|
8700
|
+
...refs,
|
|
8701
|
+
currentPath: [...refs.currentPath, "anyOf", "1"]
|
|
8702
|
+
});
|
|
8703
|
+
return innerSchema ? {
|
|
8704
|
+
anyOf: [
|
|
8705
|
+
{
|
|
8706
|
+
not: parseAnyDef(refs)
|
|
8707
|
+
},
|
|
8708
|
+
innerSchema
|
|
8709
|
+
]
|
|
8710
|
+
} : parseAnyDef(refs);
|
|
8711
|
+
};
|
|
8712
|
+
var init_optional = __esm(() => {
|
|
8713
|
+
init_parseDef();
|
|
8714
|
+
init_any();
|
|
8715
|
+
});
|
|
8716
|
+
|
|
8717
|
+
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js
|
|
8718
|
+
var parsePipelineDef = (def, refs) => {
|
|
8719
|
+
if (refs.pipeStrategy === "input") {
|
|
8720
|
+
return parseDef(def.in._def, refs);
|
|
8721
|
+
} else if (refs.pipeStrategy === "output") {
|
|
8722
|
+
return parseDef(def.out._def, refs);
|
|
8723
|
+
}
|
|
8724
|
+
const a = parseDef(def.in._def, {
|
|
8725
|
+
...refs,
|
|
8726
|
+
currentPath: [...refs.currentPath, "allOf", "0"]
|
|
8727
|
+
});
|
|
8728
|
+
const b = parseDef(def.out._def, {
|
|
8729
|
+
...refs,
|
|
8730
|
+
currentPath: [...refs.currentPath, "allOf", a ? "1" : "0"]
|
|
8731
|
+
});
|
|
8732
|
+
return {
|
|
8733
|
+
allOf: [a, b].filter((x) => x !== undefined)
|
|
8734
|
+
};
|
|
8735
|
+
};
|
|
8736
|
+
var init_pipeline = __esm(() => {
|
|
8737
|
+
init_parseDef();
|
|
8738
|
+
});
|
|
8739
|
+
|
|
8740
|
+
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/promise.js
|
|
8741
|
+
function parsePromiseDef(def, refs) {
|
|
8742
|
+
return parseDef(def.type._def, refs);
|
|
8743
|
+
}
|
|
8744
|
+
var init_promise = __esm(() => {
|
|
8745
|
+
init_parseDef();
|
|
8746
|
+
});
|
|
8747
|
+
|
|
8748
|
+
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/set.js
|
|
8749
|
+
function parseSetDef(def, refs) {
|
|
8750
|
+
const items = parseDef(def.valueType._def, {
|
|
8751
|
+
...refs,
|
|
8752
|
+
currentPath: [...refs.currentPath, "items"]
|
|
8753
|
+
});
|
|
8754
|
+
const schema = {
|
|
8755
|
+
type: "array",
|
|
8756
|
+
uniqueItems: true,
|
|
8757
|
+
items
|
|
8758
|
+
};
|
|
8759
|
+
if (def.minSize) {
|
|
8760
|
+
setResponseValueAndErrors(schema, "minItems", def.minSize.value, def.minSize.message, refs);
|
|
8761
|
+
}
|
|
8762
|
+
if (def.maxSize) {
|
|
8763
|
+
setResponseValueAndErrors(schema, "maxItems", def.maxSize.value, def.maxSize.message, refs);
|
|
8764
|
+
}
|
|
8765
|
+
return schema;
|
|
8766
|
+
}
|
|
8767
|
+
var init_set = __esm(() => {
|
|
8768
|
+
init_parseDef();
|
|
8769
|
+
});
|
|
8770
|
+
|
|
8771
|
+
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js
|
|
8772
|
+
function parseTupleDef(def, refs) {
|
|
8773
|
+
if (def.rest) {
|
|
8774
|
+
return {
|
|
8775
|
+
type: "array",
|
|
8776
|
+
minItems: def.items.length,
|
|
8777
|
+
items: def.items.map((x, i) => parseDef(x._def, {
|
|
8778
|
+
...refs,
|
|
8779
|
+
currentPath: [...refs.currentPath, "items", `${i}`]
|
|
8780
|
+
})).reduce((acc, x) => x === undefined ? acc : [...acc, x], []),
|
|
8781
|
+
additionalItems: parseDef(def.rest._def, {
|
|
8782
|
+
...refs,
|
|
8783
|
+
currentPath: [...refs.currentPath, "additionalItems"]
|
|
8784
|
+
})
|
|
8785
|
+
};
|
|
8786
|
+
} else {
|
|
8787
|
+
return {
|
|
8788
|
+
type: "array",
|
|
8789
|
+
minItems: def.items.length,
|
|
8790
|
+
maxItems: def.items.length,
|
|
8791
|
+
items: def.items.map((x, i) => parseDef(x._def, {
|
|
8792
|
+
...refs,
|
|
8793
|
+
currentPath: [...refs.currentPath, "items", `${i}`]
|
|
8794
|
+
})).reduce((acc, x) => x === undefined ? acc : [...acc, x], [])
|
|
8795
|
+
};
|
|
8796
|
+
}
|
|
8797
|
+
}
|
|
8798
|
+
var init_tuple = __esm(() => {
|
|
8799
|
+
init_parseDef();
|
|
8800
|
+
});
|
|
8801
|
+
|
|
8802
|
+
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js
|
|
8803
|
+
function parseUndefinedDef(refs) {
|
|
8804
|
+
return {
|
|
8805
|
+
not: parseAnyDef(refs)
|
|
8806
|
+
};
|
|
8807
|
+
}
|
|
8808
|
+
var init_undefined = __esm(() => {
|
|
8809
|
+
init_any();
|
|
8810
|
+
});
|
|
8811
|
+
|
|
8812
|
+
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js
|
|
8813
|
+
function parseUnknownDef(refs) {
|
|
8814
|
+
return parseAnyDef(refs);
|
|
8815
|
+
}
|
|
8816
|
+
var init_unknown = __esm(() => {
|
|
8817
|
+
init_any();
|
|
8818
|
+
});
|
|
8819
|
+
|
|
8820
|
+
// ../../node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js
|
|
8821
|
+
var parseReadonlyDef = (def, refs) => {
|
|
8822
|
+
return parseDef(def.innerType._def, refs);
|
|
8823
|
+
};
|
|
8824
|
+
var init_readonly = __esm(() => {
|
|
8825
|
+
init_parseDef();
|
|
8826
|
+
});
|
|
8827
|
+
|
|
8828
|
+
// ../../node_modules/zod-to-json-schema/dist/esm/selectParser.js
|
|
8829
|
+
var selectParser = (def, typeName, refs) => {
|
|
8830
|
+
switch (typeName) {
|
|
8831
|
+
case ZodFirstPartyTypeKind.ZodString:
|
|
8832
|
+
return parseStringDef(def, refs);
|
|
8833
|
+
case ZodFirstPartyTypeKind.ZodNumber:
|
|
8834
|
+
return parseNumberDef(def, refs);
|
|
8835
|
+
case ZodFirstPartyTypeKind.ZodObject:
|
|
8836
|
+
return parseObjectDef(def, refs);
|
|
8837
|
+
case ZodFirstPartyTypeKind.ZodBigInt:
|
|
8838
|
+
return parseBigintDef(def, refs);
|
|
8839
|
+
case ZodFirstPartyTypeKind.ZodBoolean:
|
|
8840
|
+
return parseBooleanDef();
|
|
8841
|
+
case ZodFirstPartyTypeKind.ZodDate:
|
|
8842
|
+
return parseDateDef(def, refs);
|
|
8843
|
+
case ZodFirstPartyTypeKind.ZodUndefined:
|
|
8844
|
+
return parseUndefinedDef(refs);
|
|
8845
|
+
case ZodFirstPartyTypeKind.ZodNull:
|
|
8846
|
+
return parseNullDef(refs);
|
|
8847
|
+
case ZodFirstPartyTypeKind.ZodArray:
|
|
8848
|
+
return parseArrayDef(def, refs);
|
|
8849
|
+
case ZodFirstPartyTypeKind.ZodUnion:
|
|
8850
|
+
case ZodFirstPartyTypeKind.ZodDiscriminatedUnion:
|
|
8851
|
+
return parseUnionDef(def, refs);
|
|
8852
|
+
case ZodFirstPartyTypeKind.ZodIntersection:
|
|
8853
|
+
return parseIntersectionDef(def, refs);
|
|
8854
|
+
case ZodFirstPartyTypeKind.ZodTuple:
|
|
8855
|
+
return parseTupleDef(def, refs);
|
|
8856
|
+
case ZodFirstPartyTypeKind.ZodRecord:
|
|
8857
|
+
return parseRecordDef(def, refs);
|
|
8858
|
+
case ZodFirstPartyTypeKind.ZodLiteral:
|
|
8859
|
+
return parseLiteralDef(def, refs);
|
|
8860
|
+
case ZodFirstPartyTypeKind.ZodEnum:
|
|
8861
|
+
return parseEnumDef(def);
|
|
8862
|
+
case ZodFirstPartyTypeKind.ZodNativeEnum:
|
|
8863
|
+
return parseNativeEnumDef(def);
|
|
8864
|
+
case ZodFirstPartyTypeKind.ZodNullable:
|
|
8865
|
+
return parseNullableDef(def, refs);
|
|
8866
|
+
case ZodFirstPartyTypeKind.ZodOptional:
|
|
8867
|
+
return parseOptionalDef(def, refs);
|
|
8868
|
+
case ZodFirstPartyTypeKind.ZodMap:
|
|
8869
|
+
return parseMapDef(def, refs);
|
|
8870
|
+
case ZodFirstPartyTypeKind.ZodSet:
|
|
8871
|
+
return parseSetDef(def, refs);
|
|
8872
|
+
case ZodFirstPartyTypeKind.ZodLazy:
|
|
8873
|
+
return () => def.getter()._def;
|
|
8874
|
+
case ZodFirstPartyTypeKind.ZodPromise:
|
|
8875
|
+
return parsePromiseDef(def, refs);
|
|
8876
|
+
case ZodFirstPartyTypeKind.ZodNaN:
|
|
8877
|
+
case ZodFirstPartyTypeKind.ZodNever:
|
|
8878
|
+
return parseNeverDef(refs);
|
|
8879
|
+
case ZodFirstPartyTypeKind.ZodEffects:
|
|
8880
|
+
return parseEffectsDef(def, refs);
|
|
8881
|
+
case ZodFirstPartyTypeKind.ZodAny:
|
|
8882
|
+
return parseAnyDef(refs);
|
|
8883
|
+
case ZodFirstPartyTypeKind.ZodUnknown:
|
|
8884
|
+
return parseUnknownDef(refs);
|
|
8885
|
+
case ZodFirstPartyTypeKind.ZodDefault:
|
|
8886
|
+
return parseDefaultDef(def, refs);
|
|
8887
|
+
case ZodFirstPartyTypeKind.ZodBranded:
|
|
8888
|
+
return parseBrandedDef(def, refs);
|
|
8889
|
+
case ZodFirstPartyTypeKind.ZodReadonly:
|
|
8890
|
+
return parseReadonlyDef(def, refs);
|
|
8891
|
+
case ZodFirstPartyTypeKind.ZodCatch:
|
|
8892
|
+
return parseCatchDef(def, refs);
|
|
8893
|
+
case ZodFirstPartyTypeKind.ZodPipeline:
|
|
8894
|
+
return parsePipelineDef(def, refs);
|
|
8895
|
+
case ZodFirstPartyTypeKind.ZodFunction:
|
|
8896
|
+
case ZodFirstPartyTypeKind.ZodVoid:
|
|
8897
|
+
case ZodFirstPartyTypeKind.ZodSymbol:
|
|
8898
|
+
return;
|
|
8899
|
+
default:
|
|
8900
|
+
return ((_) => {
|
|
8901
|
+
return;
|
|
8902
|
+
})(typeName);
|
|
8903
|
+
}
|
|
8904
|
+
};
|
|
8905
|
+
var init_selectParser = __esm(() => {
|
|
8906
|
+
init_v3();
|
|
8907
|
+
init_any();
|
|
8908
|
+
init_array();
|
|
8909
|
+
init_bigint();
|
|
8910
|
+
init_branded();
|
|
8911
|
+
init_catch();
|
|
8912
|
+
init_date();
|
|
8913
|
+
init_default();
|
|
8914
|
+
init_effects();
|
|
8915
|
+
init_intersection();
|
|
8916
|
+
init_map();
|
|
8917
|
+
init_never();
|
|
8918
|
+
init_nullable();
|
|
8919
|
+
init_number();
|
|
8920
|
+
init_object();
|
|
8921
|
+
init_optional();
|
|
8922
|
+
init_pipeline();
|
|
8923
|
+
init_promise();
|
|
8924
|
+
init_record();
|
|
8925
|
+
init_set();
|
|
8926
|
+
init_string();
|
|
8927
|
+
init_tuple();
|
|
8928
|
+
init_undefined();
|
|
8929
|
+
init_union();
|
|
8930
|
+
init_unknown();
|
|
8931
|
+
init_readonly();
|
|
8932
|
+
});
|
|
8933
|
+
|
|
8934
|
+
// ../../node_modules/zod-to-json-schema/dist/esm/parseDef.js
|
|
8935
|
+
function parseDef(def, refs, forceResolution = false) {
|
|
8936
|
+
const seenItem = refs.seen.get(def);
|
|
8937
|
+
if (refs.override) {
|
|
8938
|
+
const overrideResult = refs.override?.(def, refs, seenItem, forceResolution);
|
|
8939
|
+
if (overrideResult !== ignoreOverride) {
|
|
8940
|
+
return overrideResult;
|
|
8941
|
+
}
|
|
8942
|
+
}
|
|
8943
|
+
if (seenItem && !forceResolution) {
|
|
8944
|
+
const seenSchema = get$ref(seenItem, refs);
|
|
8945
|
+
if (seenSchema !== undefined) {
|
|
8946
|
+
return seenSchema;
|
|
8947
|
+
}
|
|
8948
|
+
}
|
|
8949
|
+
const newItem = { def, path: refs.currentPath, jsonSchema: undefined };
|
|
8950
|
+
refs.seen.set(def, newItem);
|
|
8951
|
+
const jsonSchemaOrGetter = selectParser(def, def.typeName, refs);
|
|
8952
|
+
const jsonSchema = typeof jsonSchemaOrGetter === "function" ? parseDef(jsonSchemaOrGetter(), refs) : jsonSchemaOrGetter;
|
|
8953
|
+
if (jsonSchema) {
|
|
8954
|
+
addMeta(def, refs, jsonSchema);
|
|
8955
|
+
}
|
|
8956
|
+
if (refs.postProcess) {
|
|
8957
|
+
const postProcessResult = refs.postProcess(jsonSchema, def, refs);
|
|
8958
|
+
newItem.jsonSchema = jsonSchema;
|
|
8959
|
+
return postProcessResult;
|
|
8960
|
+
}
|
|
8961
|
+
newItem.jsonSchema = jsonSchema;
|
|
8962
|
+
return jsonSchema;
|
|
8963
|
+
}
|
|
8964
|
+
var get$ref = (item, refs) => {
|
|
8965
|
+
switch (refs.$refStrategy) {
|
|
8966
|
+
case "root":
|
|
8967
|
+
return { $ref: item.path.join("/") };
|
|
8968
|
+
case "relative":
|
|
8969
|
+
return { $ref: getRelativePath(refs.currentPath, item.path) };
|
|
8970
|
+
case "none":
|
|
8971
|
+
case "seen": {
|
|
8972
|
+
if (item.path.length < refs.currentPath.length && item.path.every((value, index) => refs.currentPath[index] === value)) {
|
|
8973
|
+
console.warn(`Recursive reference detected at ${refs.currentPath.join("/")}! Defaulting to any`);
|
|
8974
|
+
return parseAnyDef(refs);
|
|
8975
|
+
}
|
|
8976
|
+
return refs.$refStrategy === "seen" ? parseAnyDef(refs) : undefined;
|
|
8977
|
+
}
|
|
8978
|
+
}
|
|
8979
|
+
}, addMeta = (def, refs, jsonSchema) => {
|
|
8980
|
+
if (def.description) {
|
|
8981
|
+
jsonSchema.description = def.description;
|
|
8982
|
+
if (refs.markdownDescription) {
|
|
8983
|
+
jsonSchema.markdownDescription = def.description;
|
|
8984
|
+
}
|
|
8985
|
+
}
|
|
8986
|
+
return jsonSchema;
|
|
8987
|
+
};
|
|
8988
|
+
var init_parseDef = __esm(() => {
|
|
8989
|
+
init_Options();
|
|
8990
|
+
init_selectParser();
|
|
8991
|
+
init_any();
|
|
8992
|
+
});
|
|
8993
|
+
|
|
8994
|
+
// ../../node_modules/zod-to-json-schema/dist/esm/parseTypes.js
|
|
8995
|
+
var init_parseTypes = () => {};
|
|
8996
|
+
|
|
8997
|
+
// ../../node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js
|
|
8998
|
+
var zodToJsonSchema = (schema, options) => {
|
|
8999
|
+
const refs = getRefs(options);
|
|
9000
|
+
let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name2, schema2]) => ({
|
|
9001
|
+
...acc,
|
|
9002
|
+
[name2]: parseDef(schema2._def, {
|
|
9003
|
+
...refs,
|
|
9004
|
+
currentPath: [...refs.basePath, refs.definitionPath, name2]
|
|
9005
|
+
}, true) ?? parseAnyDef(refs)
|
|
9006
|
+
}), {}) : undefined;
|
|
9007
|
+
const name = typeof options === "string" ? options : options?.nameStrategy === "title" ? undefined : options?.name;
|
|
9008
|
+
const main = parseDef(schema._def, name === undefined ? refs : {
|
|
9009
|
+
...refs,
|
|
9010
|
+
currentPath: [...refs.basePath, refs.definitionPath, name]
|
|
9011
|
+
}, false) ?? parseAnyDef(refs);
|
|
9012
|
+
const title = typeof options === "object" && options.name !== undefined && options.nameStrategy === "title" ? options.name : undefined;
|
|
9013
|
+
if (title !== undefined) {
|
|
9014
|
+
main.title = title;
|
|
9015
|
+
}
|
|
9016
|
+
if (refs.flags.hasReferencedOpenAiAnyType) {
|
|
9017
|
+
if (!definitions) {
|
|
9018
|
+
definitions = {};
|
|
9019
|
+
}
|
|
9020
|
+
if (!definitions[refs.openAiAnyTypeName]) {
|
|
9021
|
+
definitions[refs.openAiAnyTypeName] = {
|
|
9022
|
+
type: ["string", "number", "integer", "boolean", "array", "null"],
|
|
9023
|
+
items: {
|
|
9024
|
+
$ref: refs.$refStrategy === "relative" ? "1" : [
|
|
9025
|
+
...refs.basePath,
|
|
9026
|
+
refs.definitionPath,
|
|
9027
|
+
refs.openAiAnyTypeName
|
|
9028
|
+
].join("/")
|
|
9029
|
+
}
|
|
9030
|
+
};
|
|
9031
|
+
}
|
|
9032
|
+
}
|
|
9033
|
+
const combined = name === undefined ? definitions ? {
|
|
9034
|
+
...main,
|
|
9035
|
+
[refs.definitionPath]: definitions
|
|
9036
|
+
} : main : {
|
|
9037
|
+
$ref: [
|
|
9038
|
+
...refs.$refStrategy === "relative" ? [] : refs.basePath,
|
|
9039
|
+
refs.definitionPath,
|
|
9040
|
+
name
|
|
9041
|
+
].join("/"),
|
|
9042
|
+
[refs.definitionPath]: {
|
|
9043
|
+
...definitions,
|
|
9044
|
+
[name]: main
|
|
9045
|
+
}
|
|
9046
|
+
};
|
|
9047
|
+
if (refs.target === "jsonSchema7") {
|
|
9048
|
+
combined.$schema = "http://json-schema.org/draft-07/schema#";
|
|
9049
|
+
} else if (refs.target === "jsonSchema2019-09" || refs.target === "openAi") {
|
|
9050
|
+
combined.$schema = "https://json-schema.org/draft/2019-09/schema#";
|
|
9051
|
+
}
|
|
9052
|
+
if (refs.target === "openAi" && (("anyOf" in combined) || ("oneOf" in combined) || ("allOf" in combined) || ("type" in combined) && Array.isArray(combined.type))) {
|
|
9053
|
+
console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property.");
|
|
9054
|
+
}
|
|
9055
|
+
return combined;
|
|
9056
|
+
};
|
|
9057
|
+
var init_zodToJsonSchema = __esm(() => {
|
|
9058
|
+
init_parseDef();
|
|
9059
|
+
init_Refs();
|
|
9060
|
+
init_any();
|
|
9061
|
+
});
|
|
9062
|
+
|
|
9063
|
+
// ../../node_modules/zod-to-json-schema/dist/esm/index.js
|
|
9064
|
+
var init_esm = __esm(() => {
|
|
9065
|
+
init_zodToJsonSchema();
|
|
9066
|
+
init_Options();
|
|
9067
|
+
init_Refs();
|
|
9068
|
+
init_parseDef();
|
|
9069
|
+
init_parseTypes();
|
|
9070
|
+
init_any();
|
|
9071
|
+
init_array();
|
|
9072
|
+
init_bigint();
|
|
9073
|
+
init_branded();
|
|
9074
|
+
init_catch();
|
|
9075
|
+
init_date();
|
|
9076
|
+
init_default();
|
|
9077
|
+
init_effects();
|
|
9078
|
+
init_intersection();
|
|
9079
|
+
init_map();
|
|
9080
|
+
init_never();
|
|
9081
|
+
init_nullable();
|
|
9082
|
+
init_number();
|
|
9083
|
+
init_object();
|
|
9084
|
+
init_optional();
|
|
9085
|
+
init_pipeline();
|
|
9086
|
+
init_promise();
|
|
9087
|
+
init_readonly();
|
|
9088
|
+
init_record();
|
|
9089
|
+
init_set();
|
|
9090
|
+
init_string();
|
|
9091
|
+
init_tuple();
|
|
9092
|
+
init_undefined();
|
|
9093
|
+
init_union();
|
|
9094
|
+
init_unknown();
|
|
9095
|
+
init_selectParser();
|
|
9096
|
+
init_zodToJsonSchema();
|
|
9097
|
+
});
|
|
9098
|
+
|
|
7695
9099
|
// ../ai/openai.ts
|
|
7696
9100
|
function convertMCPToolToOpenAI(mcpTool, _client, options) {
|
|
7697
9101
|
const inputParams = mcpTool.inputSchema;
|
|
@@ -7719,7 +9123,10 @@ async function getOpenAITools(client, options) {
|
|
|
7719
9123
|
const triggerTools = createTriggerTools(triggerConfig, options?.context);
|
|
7720
9124
|
for (const [name, tool] of Object.entries(triggerTools)) {
|
|
7721
9125
|
const zodSchema = tool.inputSchema;
|
|
7722
|
-
const jsonSchema = zodToJsonSchema(zodSchema
|
|
9126
|
+
const jsonSchema = zodToJsonSchema(zodSchema, {
|
|
9127
|
+
target: "openApi3",
|
|
9128
|
+
$refStrategy: "none"
|
|
9129
|
+
});
|
|
7723
9130
|
openaiTools.push({
|
|
7724
9131
|
type: "function",
|
|
7725
9132
|
name,
|
|
@@ -7731,26 +9138,6 @@ async function getOpenAITools(client, options) {
|
|
|
7731
9138
|
}
|
|
7732
9139
|
return openaiTools;
|
|
7733
9140
|
}
|
|
7734
|
-
function zodToJsonSchema(schema) {
|
|
7735
|
-
if (schema._def?.typeName === "ZodObject") {
|
|
7736
|
-
const shape = schema._def.shape();
|
|
7737
|
-
const properties = {};
|
|
7738
|
-
const required = [];
|
|
7739
|
-
for (const [key, value] of Object.entries(shape)) {
|
|
7740
|
-
const fieldSchema = value;
|
|
7741
|
-
properties[key] = { type: "string" };
|
|
7742
|
-
if (fieldSchema._def?.typeName !== "ZodOptional") {
|
|
7743
|
-
required.push(key);
|
|
7744
|
-
}
|
|
7745
|
-
}
|
|
7746
|
-
return {
|
|
7747
|
-
type: "object",
|
|
7748
|
-
properties,
|
|
7749
|
-
...required.length > 0 ? { required } : {}
|
|
7750
|
-
};
|
|
7751
|
-
}
|
|
7752
|
-
return { type: "object" };
|
|
7753
|
-
}
|
|
7754
9141
|
async function handleOpenAIToolCalls(client, toolCalls, options) {
|
|
7755
9142
|
const toolOutputs = [];
|
|
7756
9143
|
const triggerConfig = client.__triggerConfig;
|
|
@@ -7806,6 +9193,7 @@ async function handleOpenAIResponse(client, response, options) {
|
|
|
7806
9193
|
var init_openai = __esm(() => {
|
|
7807
9194
|
init_utils();
|
|
7808
9195
|
init_trigger_tools();
|
|
9196
|
+
init_esm();
|
|
7809
9197
|
});
|
|
7810
9198
|
|
|
7811
9199
|
// ../ai/anthropic.ts
|
|
@@ -7867,7 +9255,10 @@ async function getAnthropicTools(client, options) {
|
|
|
7867
9255
|
const triggerTools = createTriggerTools(triggerConfig, options?.context);
|
|
7868
9256
|
for (const [name, tool] of Object.entries(triggerTools)) {
|
|
7869
9257
|
const zodSchema = tool.inputSchema;
|
|
7870
|
-
const jsonSchema =
|
|
9258
|
+
const jsonSchema = zodToJsonSchema(zodSchema, {
|
|
9259
|
+
target: "openApi3",
|
|
9260
|
+
$refStrategy: "none"
|
|
9261
|
+
});
|
|
7871
9262
|
anthropicTools.push({
|
|
7872
9263
|
name,
|
|
7873
9264
|
description: tool.description || `Execute ${name}`,
|
|
@@ -7877,26 +9268,6 @@ async function getAnthropicTools(client, options) {
|
|
|
7877
9268
|
}
|
|
7878
9269
|
return anthropicTools;
|
|
7879
9270
|
}
|
|
7880
|
-
function zodToAnthropicSchema(schema) {
|
|
7881
|
-
if (schema._def?.typeName === "ZodObject") {
|
|
7882
|
-
const shape = schema._def.shape();
|
|
7883
|
-
const properties = {};
|
|
7884
|
-
const required = [];
|
|
7885
|
-
for (const [key, value] of Object.entries(shape)) {
|
|
7886
|
-
const fieldSchema = value;
|
|
7887
|
-
properties[key] = { type: "string" };
|
|
7888
|
-
if (fieldSchema._def?.typeName !== "ZodOptional") {
|
|
7889
|
-
required.push(key);
|
|
7890
|
-
}
|
|
7891
|
-
}
|
|
7892
|
-
return {
|
|
7893
|
-
type: "object",
|
|
7894
|
-
properties,
|
|
7895
|
-
...required.length > 0 ? { required } : {}
|
|
7896
|
-
};
|
|
7897
|
-
}
|
|
7898
|
-
return { type: "object", properties: {}, required: [] };
|
|
7899
|
-
}
|
|
7900
9271
|
async function handleAnthropicMessage(client, message, options) {
|
|
7901
9272
|
let providerTokens = options?.providerTokens;
|
|
7902
9273
|
if (!providerTokens) {
|
|
@@ -7923,6 +9294,7 @@ async function handleAnthropicMessage(client, message, options) {
|
|
|
7923
9294
|
var init_anthropic = __esm(() => {
|
|
7924
9295
|
init_utils();
|
|
7925
9296
|
init_trigger_tools();
|
|
9297
|
+
init_esm();
|
|
7926
9298
|
});
|
|
7927
9299
|
|
|
7928
9300
|
// ../ai/google.ts
|
|
@@ -8039,39 +9411,78 @@ async function getGoogleTools(client, options) {
|
|
|
8039
9411
|
const TypeEnum = await getGoogleType();
|
|
8040
9412
|
for (const [name, tool] of Object.entries(triggerTools)) {
|
|
8041
9413
|
const zodSchema = tool.inputSchema;
|
|
8042
|
-
const jsonSchema =
|
|
9414
|
+
const jsonSchema = zodToJsonSchema(zodSchema, {
|
|
9415
|
+
target: "openApi3",
|
|
9416
|
+
$refStrategy: "none"
|
|
9417
|
+
});
|
|
9418
|
+
const googleSchema = convertJsonSchemaToGoogleSchema(jsonSchema, TypeEnum);
|
|
8043
9419
|
googleTools.push({
|
|
8044
9420
|
name,
|
|
8045
9421
|
description: tool.description || `Execute ${name}`,
|
|
8046
|
-
parameters:
|
|
9422
|
+
parameters: googleSchema
|
|
8047
9423
|
});
|
|
8048
9424
|
}
|
|
8049
9425
|
}
|
|
8050
9426
|
return googleTools;
|
|
8051
9427
|
}
|
|
8052
|
-
function
|
|
8053
|
-
|
|
8054
|
-
|
|
8055
|
-
|
|
8056
|
-
|
|
8057
|
-
|
|
8058
|
-
|
|
8059
|
-
|
|
8060
|
-
if (
|
|
8061
|
-
|
|
9428
|
+
function convertJsonSchemaToGoogleSchema(jsonSchema, TypeEnum) {
|
|
9429
|
+
const result = {
|
|
9430
|
+
type: TypeEnum.OBJECT
|
|
9431
|
+
};
|
|
9432
|
+
if (jsonSchema.properties) {
|
|
9433
|
+
const googleProperties = {};
|
|
9434
|
+
for (const [key, prop] of Object.entries(jsonSchema.properties)) {
|
|
9435
|
+
const googleProp = {};
|
|
9436
|
+
if (prop.type) {
|
|
9437
|
+
switch (prop.type) {
|
|
9438
|
+
case "string":
|
|
9439
|
+
googleProp.type = TypeEnum.STRING;
|
|
9440
|
+
break;
|
|
9441
|
+
case "number":
|
|
9442
|
+
googleProp.type = TypeEnum.NUMBER;
|
|
9443
|
+
break;
|
|
9444
|
+
case "integer":
|
|
9445
|
+
googleProp.type = TypeEnum.INTEGER;
|
|
9446
|
+
break;
|
|
9447
|
+
case "boolean":
|
|
9448
|
+
googleProp.type = TypeEnum.BOOLEAN;
|
|
9449
|
+
break;
|
|
9450
|
+
case "array":
|
|
9451
|
+
googleProp.type = TypeEnum.ARRAY;
|
|
9452
|
+
if (prop.items) {
|
|
9453
|
+
googleProp.items = convertJsonSchemaToGoogleSchema(prop.items, TypeEnum);
|
|
9454
|
+
}
|
|
9455
|
+
break;
|
|
9456
|
+
case "object":
|
|
9457
|
+
googleProp.type = TypeEnum.OBJECT;
|
|
9458
|
+
if (prop.properties) {
|
|
9459
|
+
googleProp.properties = Object.fromEntries(Object.entries(prop.properties).map(([k, v]) => [
|
|
9460
|
+
k,
|
|
9461
|
+
convertJsonSchemaToGoogleSchema(v, TypeEnum)
|
|
9462
|
+
]));
|
|
9463
|
+
}
|
|
9464
|
+
break;
|
|
9465
|
+
default:
|
|
9466
|
+
googleProp.type = TypeEnum.STRING;
|
|
9467
|
+
}
|
|
8062
9468
|
}
|
|
9469
|
+
if (prop.description)
|
|
9470
|
+
googleProp.description = prop.description;
|
|
9471
|
+
if (prop.enum)
|
|
9472
|
+
googleProp.enum = prop.enum;
|
|
9473
|
+
googleProperties[key] = googleProp;
|
|
8063
9474
|
}
|
|
8064
|
-
|
|
8065
|
-
|
|
8066
|
-
|
|
8067
|
-
|
|
8068
|
-
};
|
|
9475
|
+
result.properties = googleProperties;
|
|
9476
|
+
}
|
|
9477
|
+
if (jsonSchema.required && Array.isArray(jsonSchema.required)) {
|
|
9478
|
+
result.required = jsonSchema.required;
|
|
8069
9479
|
}
|
|
8070
|
-
return
|
|
9480
|
+
return result;
|
|
8071
9481
|
}
|
|
8072
9482
|
var init_google = __esm(() => {
|
|
8073
9483
|
init_utils();
|
|
8074
9484
|
init_trigger_tools();
|
|
9485
|
+
init_esm();
|
|
8075
9486
|
});
|
|
8076
9487
|
|
|
8077
9488
|
// ../ai/index.ts
|