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/oauth.js
CHANGED
|
@@ -7896,6 +7896,1410 @@ var init_vercel_ai = __esm(() => {
|
|
|
7896
7896
|
init_trigger_tools();
|
|
7897
7897
|
});
|
|
7898
7898
|
|
|
7899
|
+
// node_modules/zod-to-json-schema/dist/esm/Options.js
|
|
7900
|
+
var ignoreOverride, defaultOptions, getDefaultOptions = (options) => typeof options === "string" ? {
|
|
7901
|
+
...defaultOptions,
|
|
7902
|
+
name: options
|
|
7903
|
+
} : {
|
|
7904
|
+
...defaultOptions,
|
|
7905
|
+
...options
|
|
7906
|
+
};
|
|
7907
|
+
var init_Options = __esm(() => {
|
|
7908
|
+
ignoreOverride = Symbol("Let zodToJsonSchema decide on which parser to use");
|
|
7909
|
+
defaultOptions = {
|
|
7910
|
+
name: undefined,
|
|
7911
|
+
$refStrategy: "root",
|
|
7912
|
+
basePath: ["#"],
|
|
7913
|
+
effectStrategy: "input",
|
|
7914
|
+
pipeStrategy: "all",
|
|
7915
|
+
dateStrategy: "format:date-time",
|
|
7916
|
+
mapStrategy: "entries",
|
|
7917
|
+
removeAdditionalStrategy: "passthrough",
|
|
7918
|
+
allowedAdditionalProperties: true,
|
|
7919
|
+
rejectedAdditionalProperties: false,
|
|
7920
|
+
definitionPath: "definitions",
|
|
7921
|
+
target: "jsonSchema7",
|
|
7922
|
+
strictUnions: false,
|
|
7923
|
+
definitions: {},
|
|
7924
|
+
errorMessages: false,
|
|
7925
|
+
markdownDescription: false,
|
|
7926
|
+
patternStrategy: "escape",
|
|
7927
|
+
applyRegexFlags: false,
|
|
7928
|
+
emailStrategy: "format:email",
|
|
7929
|
+
base64Strategy: "contentEncoding:base64",
|
|
7930
|
+
nameStrategy: "ref",
|
|
7931
|
+
openAiAnyTypeName: "OpenAiAnyType"
|
|
7932
|
+
};
|
|
7933
|
+
});
|
|
7934
|
+
|
|
7935
|
+
// node_modules/zod-to-json-schema/dist/esm/Refs.js
|
|
7936
|
+
var getRefs = (options) => {
|
|
7937
|
+
const _options = getDefaultOptions(options);
|
|
7938
|
+
const currentPath = _options.name !== undefined ? [..._options.basePath, _options.definitionPath, _options.name] : _options.basePath;
|
|
7939
|
+
return {
|
|
7940
|
+
..._options,
|
|
7941
|
+
flags: { hasReferencedOpenAiAnyType: false },
|
|
7942
|
+
currentPath,
|
|
7943
|
+
propertyPath: undefined,
|
|
7944
|
+
seen: new Map(Object.entries(_options.definitions).map(([name, def]) => [
|
|
7945
|
+
def._def,
|
|
7946
|
+
{
|
|
7947
|
+
def: def._def,
|
|
7948
|
+
path: [..._options.basePath, _options.definitionPath, name],
|
|
7949
|
+
jsonSchema: undefined
|
|
7950
|
+
}
|
|
7951
|
+
]))
|
|
7952
|
+
};
|
|
7953
|
+
};
|
|
7954
|
+
var init_Refs = __esm(() => {
|
|
7955
|
+
init_Options();
|
|
7956
|
+
});
|
|
7957
|
+
|
|
7958
|
+
// node_modules/zod-to-json-schema/dist/esm/errorMessages.js
|
|
7959
|
+
function addErrorMessage(res, key, errorMessage, refs) {
|
|
7960
|
+
if (!refs?.errorMessages)
|
|
7961
|
+
return;
|
|
7962
|
+
if (errorMessage) {
|
|
7963
|
+
res.errorMessage = {
|
|
7964
|
+
...res.errorMessage,
|
|
7965
|
+
[key]: errorMessage
|
|
7966
|
+
};
|
|
7967
|
+
}
|
|
7968
|
+
}
|
|
7969
|
+
function setResponseValueAndErrors(res, key, value, errorMessage, refs) {
|
|
7970
|
+
res[key] = value;
|
|
7971
|
+
addErrorMessage(res, key, errorMessage, refs);
|
|
7972
|
+
}
|
|
7973
|
+
|
|
7974
|
+
// node_modules/zod-to-json-schema/dist/esm/getRelativePath.js
|
|
7975
|
+
var getRelativePath = (pathA, pathB) => {
|
|
7976
|
+
let i = 0;
|
|
7977
|
+
for (;i < pathA.length && i < pathB.length; i++) {
|
|
7978
|
+
if (pathA[i] !== pathB[i])
|
|
7979
|
+
break;
|
|
7980
|
+
}
|
|
7981
|
+
return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
|
|
7982
|
+
};
|
|
7983
|
+
|
|
7984
|
+
// node_modules/zod/v3/index.js
|
|
7985
|
+
var init_v3 = __esm(() => {
|
|
7986
|
+
init_external();
|
|
7987
|
+
});
|
|
7988
|
+
|
|
7989
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/any.js
|
|
7990
|
+
function parseAnyDef(refs) {
|
|
7991
|
+
if (refs.target !== "openAi") {
|
|
7992
|
+
return {};
|
|
7993
|
+
}
|
|
7994
|
+
const anyDefinitionPath = [
|
|
7995
|
+
...refs.basePath,
|
|
7996
|
+
refs.definitionPath,
|
|
7997
|
+
refs.openAiAnyTypeName
|
|
7998
|
+
];
|
|
7999
|
+
refs.flags.hasReferencedOpenAiAnyType = true;
|
|
8000
|
+
return {
|
|
8001
|
+
$ref: refs.$refStrategy === "relative" ? getRelativePath(anyDefinitionPath, refs.currentPath) : anyDefinitionPath.join("/")
|
|
8002
|
+
};
|
|
8003
|
+
}
|
|
8004
|
+
var init_any = () => {};
|
|
8005
|
+
|
|
8006
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/array.js
|
|
8007
|
+
function parseArrayDef(def, refs) {
|
|
8008
|
+
const res = {
|
|
8009
|
+
type: "array"
|
|
8010
|
+
};
|
|
8011
|
+
if (def.type?._def && def.type?._def?.typeName !== ZodFirstPartyTypeKind.ZodAny) {
|
|
8012
|
+
res.items = parseDef(def.type._def, {
|
|
8013
|
+
...refs,
|
|
8014
|
+
currentPath: [...refs.currentPath, "items"]
|
|
8015
|
+
});
|
|
8016
|
+
}
|
|
8017
|
+
if (def.minLength) {
|
|
8018
|
+
setResponseValueAndErrors(res, "minItems", def.minLength.value, def.minLength.message, refs);
|
|
8019
|
+
}
|
|
8020
|
+
if (def.maxLength) {
|
|
8021
|
+
setResponseValueAndErrors(res, "maxItems", def.maxLength.value, def.maxLength.message, refs);
|
|
8022
|
+
}
|
|
8023
|
+
if (def.exactLength) {
|
|
8024
|
+
setResponseValueAndErrors(res, "minItems", def.exactLength.value, def.exactLength.message, refs);
|
|
8025
|
+
setResponseValueAndErrors(res, "maxItems", def.exactLength.value, def.exactLength.message, refs);
|
|
8026
|
+
}
|
|
8027
|
+
return res;
|
|
8028
|
+
}
|
|
8029
|
+
var init_array = __esm(() => {
|
|
8030
|
+
init_v3();
|
|
8031
|
+
init_parseDef();
|
|
8032
|
+
});
|
|
8033
|
+
|
|
8034
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js
|
|
8035
|
+
function parseBigintDef(def, refs) {
|
|
8036
|
+
const res = {
|
|
8037
|
+
type: "integer",
|
|
8038
|
+
format: "int64"
|
|
8039
|
+
};
|
|
8040
|
+
if (!def.checks)
|
|
8041
|
+
return res;
|
|
8042
|
+
for (const check of def.checks) {
|
|
8043
|
+
switch (check.kind) {
|
|
8044
|
+
case "min":
|
|
8045
|
+
if (refs.target === "jsonSchema7") {
|
|
8046
|
+
if (check.inclusive) {
|
|
8047
|
+
setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
8048
|
+
} else {
|
|
8049
|
+
setResponseValueAndErrors(res, "exclusiveMinimum", check.value, check.message, refs);
|
|
8050
|
+
}
|
|
8051
|
+
} else {
|
|
8052
|
+
if (!check.inclusive) {
|
|
8053
|
+
res.exclusiveMinimum = true;
|
|
8054
|
+
}
|
|
8055
|
+
setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
8056
|
+
}
|
|
8057
|
+
break;
|
|
8058
|
+
case "max":
|
|
8059
|
+
if (refs.target === "jsonSchema7") {
|
|
8060
|
+
if (check.inclusive) {
|
|
8061
|
+
setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
8062
|
+
} else {
|
|
8063
|
+
setResponseValueAndErrors(res, "exclusiveMaximum", check.value, check.message, refs);
|
|
8064
|
+
}
|
|
8065
|
+
} else {
|
|
8066
|
+
if (!check.inclusive) {
|
|
8067
|
+
res.exclusiveMaximum = true;
|
|
8068
|
+
}
|
|
8069
|
+
setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
8070
|
+
}
|
|
8071
|
+
break;
|
|
8072
|
+
case "multipleOf":
|
|
8073
|
+
setResponseValueAndErrors(res, "multipleOf", check.value, check.message, refs);
|
|
8074
|
+
break;
|
|
8075
|
+
}
|
|
8076
|
+
}
|
|
8077
|
+
return res;
|
|
8078
|
+
}
|
|
8079
|
+
var init_bigint = () => {};
|
|
8080
|
+
|
|
8081
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js
|
|
8082
|
+
function parseBooleanDef() {
|
|
8083
|
+
return {
|
|
8084
|
+
type: "boolean"
|
|
8085
|
+
};
|
|
8086
|
+
}
|
|
8087
|
+
|
|
8088
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/branded.js
|
|
8089
|
+
function parseBrandedDef(_def, refs) {
|
|
8090
|
+
return parseDef(_def.type._def, refs);
|
|
8091
|
+
}
|
|
8092
|
+
var init_branded = __esm(() => {
|
|
8093
|
+
init_parseDef();
|
|
8094
|
+
});
|
|
8095
|
+
|
|
8096
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/catch.js
|
|
8097
|
+
var parseCatchDef = (def, refs) => {
|
|
8098
|
+
return parseDef(def.innerType._def, refs);
|
|
8099
|
+
};
|
|
8100
|
+
var init_catch = __esm(() => {
|
|
8101
|
+
init_parseDef();
|
|
8102
|
+
});
|
|
8103
|
+
|
|
8104
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/date.js
|
|
8105
|
+
function parseDateDef(def, refs, overrideDateStrategy) {
|
|
8106
|
+
const strategy = overrideDateStrategy ?? refs.dateStrategy;
|
|
8107
|
+
if (Array.isArray(strategy)) {
|
|
8108
|
+
return {
|
|
8109
|
+
anyOf: strategy.map((item, i) => parseDateDef(def, refs, item))
|
|
8110
|
+
};
|
|
8111
|
+
}
|
|
8112
|
+
switch (strategy) {
|
|
8113
|
+
case "string":
|
|
8114
|
+
case "format:date-time":
|
|
8115
|
+
return {
|
|
8116
|
+
type: "string",
|
|
8117
|
+
format: "date-time"
|
|
8118
|
+
};
|
|
8119
|
+
case "format:date":
|
|
8120
|
+
return {
|
|
8121
|
+
type: "string",
|
|
8122
|
+
format: "date"
|
|
8123
|
+
};
|
|
8124
|
+
case "integer":
|
|
8125
|
+
return integerDateParser(def, refs);
|
|
8126
|
+
}
|
|
8127
|
+
}
|
|
8128
|
+
var integerDateParser = (def, refs) => {
|
|
8129
|
+
const res = {
|
|
8130
|
+
type: "integer",
|
|
8131
|
+
format: "unix-time"
|
|
8132
|
+
};
|
|
8133
|
+
if (refs.target === "openApi3") {
|
|
8134
|
+
return res;
|
|
8135
|
+
}
|
|
8136
|
+
for (const check of def.checks) {
|
|
8137
|
+
switch (check.kind) {
|
|
8138
|
+
case "min":
|
|
8139
|
+
setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
8140
|
+
break;
|
|
8141
|
+
case "max":
|
|
8142
|
+
setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
8143
|
+
break;
|
|
8144
|
+
}
|
|
8145
|
+
}
|
|
8146
|
+
return res;
|
|
8147
|
+
};
|
|
8148
|
+
var init_date = () => {};
|
|
8149
|
+
|
|
8150
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/default.js
|
|
8151
|
+
function parseDefaultDef(_def, refs) {
|
|
8152
|
+
return {
|
|
8153
|
+
...parseDef(_def.innerType._def, refs),
|
|
8154
|
+
default: _def.defaultValue()
|
|
8155
|
+
};
|
|
8156
|
+
}
|
|
8157
|
+
var init_default = __esm(() => {
|
|
8158
|
+
init_parseDef();
|
|
8159
|
+
});
|
|
8160
|
+
|
|
8161
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/effects.js
|
|
8162
|
+
function parseEffectsDef(_def, refs) {
|
|
8163
|
+
return refs.effectStrategy === "input" ? parseDef(_def.schema._def, refs) : parseAnyDef(refs);
|
|
8164
|
+
}
|
|
8165
|
+
var init_effects = __esm(() => {
|
|
8166
|
+
init_parseDef();
|
|
8167
|
+
init_any();
|
|
8168
|
+
});
|
|
8169
|
+
|
|
8170
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/enum.js
|
|
8171
|
+
function parseEnumDef(def) {
|
|
8172
|
+
return {
|
|
8173
|
+
type: "string",
|
|
8174
|
+
enum: Array.from(def.values)
|
|
8175
|
+
};
|
|
8176
|
+
}
|
|
8177
|
+
|
|
8178
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js
|
|
8179
|
+
function parseIntersectionDef(def, refs) {
|
|
8180
|
+
const allOf = [
|
|
8181
|
+
parseDef(def.left._def, {
|
|
8182
|
+
...refs,
|
|
8183
|
+
currentPath: [...refs.currentPath, "allOf", "0"]
|
|
8184
|
+
}),
|
|
8185
|
+
parseDef(def.right._def, {
|
|
8186
|
+
...refs,
|
|
8187
|
+
currentPath: [...refs.currentPath, "allOf", "1"]
|
|
8188
|
+
})
|
|
8189
|
+
].filter((x) => !!x);
|
|
8190
|
+
let unevaluatedProperties = refs.target === "jsonSchema2019-09" ? { unevaluatedProperties: false } : undefined;
|
|
8191
|
+
const mergedAllOf = [];
|
|
8192
|
+
allOf.forEach((schema) => {
|
|
8193
|
+
if (isJsonSchema7AllOfType(schema)) {
|
|
8194
|
+
mergedAllOf.push(...schema.allOf);
|
|
8195
|
+
if (schema.unevaluatedProperties === undefined) {
|
|
8196
|
+
unevaluatedProperties = undefined;
|
|
8197
|
+
}
|
|
8198
|
+
} else {
|
|
8199
|
+
let nestedSchema = schema;
|
|
8200
|
+
if ("additionalProperties" in schema && schema.additionalProperties === false) {
|
|
8201
|
+
const { additionalProperties, ...rest } = schema;
|
|
8202
|
+
nestedSchema = rest;
|
|
8203
|
+
} else {
|
|
8204
|
+
unevaluatedProperties = undefined;
|
|
8205
|
+
}
|
|
8206
|
+
mergedAllOf.push(nestedSchema);
|
|
8207
|
+
}
|
|
8208
|
+
});
|
|
8209
|
+
return mergedAllOf.length ? {
|
|
8210
|
+
allOf: mergedAllOf,
|
|
8211
|
+
...unevaluatedProperties
|
|
8212
|
+
} : undefined;
|
|
8213
|
+
}
|
|
8214
|
+
var isJsonSchema7AllOfType = (type) => {
|
|
8215
|
+
if ("type" in type && type.type === "string")
|
|
8216
|
+
return false;
|
|
8217
|
+
return "allOf" in type;
|
|
8218
|
+
};
|
|
8219
|
+
var init_intersection = __esm(() => {
|
|
8220
|
+
init_parseDef();
|
|
8221
|
+
});
|
|
8222
|
+
|
|
8223
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/literal.js
|
|
8224
|
+
function parseLiteralDef(def, refs) {
|
|
8225
|
+
const parsedType = typeof def.value;
|
|
8226
|
+
if (parsedType !== "bigint" && parsedType !== "number" && parsedType !== "boolean" && parsedType !== "string") {
|
|
8227
|
+
return {
|
|
8228
|
+
type: Array.isArray(def.value) ? "array" : "object"
|
|
8229
|
+
};
|
|
8230
|
+
}
|
|
8231
|
+
if (refs.target === "openApi3") {
|
|
8232
|
+
return {
|
|
8233
|
+
type: parsedType === "bigint" ? "integer" : parsedType,
|
|
8234
|
+
enum: [def.value]
|
|
8235
|
+
};
|
|
8236
|
+
}
|
|
8237
|
+
return {
|
|
8238
|
+
type: parsedType === "bigint" ? "integer" : parsedType,
|
|
8239
|
+
const: def.value
|
|
8240
|
+
};
|
|
8241
|
+
}
|
|
8242
|
+
|
|
8243
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/string.js
|
|
8244
|
+
function parseStringDef(def, refs) {
|
|
8245
|
+
const res = {
|
|
8246
|
+
type: "string"
|
|
8247
|
+
};
|
|
8248
|
+
if (def.checks) {
|
|
8249
|
+
for (const check of def.checks) {
|
|
8250
|
+
switch (check.kind) {
|
|
8251
|
+
case "min":
|
|
8252
|
+
setResponseValueAndErrors(res, "minLength", typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value, check.message, refs);
|
|
8253
|
+
break;
|
|
8254
|
+
case "max":
|
|
8255
|
+
setResponseValueAndErrors(res, "maxLength", typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);
|
|
8256
|
+
break;
|
|
8257
|
+
case "email":
|
|
8258
|
+
switch (refs.emailStrategy) {
|
|
8259
|
+
case "format:email":
|
|
8260
|
+
addFormat(res, "email", check.message, refs);
|
|
8261
|
+
break;
|
|
8262
|
+
case "format:idn-email":
|
|
8263
|
+
addFormat(res, "idn-email", check.message, refs);
|
|
8264
|
+
break;
|
|
8265
|
+
case "pattern:zod":
|
|
8266
|
+
addPattern(res, zodPatterns.email, check.message, refs);
|
|
8267
|
+
break;
|
|
8268
|
+
}
|
|
8269
|
+
break;
|
|
8270
|
+
case "url":
|
|
8271
|
+
addFormat(res, "uri", check.message, refs);
|
|
8272
|
+
break;
|
|
8273
|
+
case "uuid":
|
|
8274
|
+
addFormat(res, "uuid", check.message, refs);
|
|
8275
|
+
break;
|
|
8276
|
+
case "regex":
|
|
8277
|
+
addPattern(res, check.regex, check.message, refs);
|
|
8278
|
+
break;
|
|
8279
|
+
case "cuid":
|
|
8280
|
+
addPattern(res, zodPatterns.cuid, check.message, refs);
|
|
8281
|
+
break;
|
|
8282
|
+
case "cuid2":
|
|
8283
|
+
addPattern(res, zodPatterns.cuid2, check.message, refs);
|
|
8284
|
+
break;
|
|
8285
|
+
case "startsWith":
|
|
8286
|
+
addPattern(res, RegExp(`^${escapeLiteralCheckValue(check.value, refs)}`), check.message, refs);
|
|
8287
|
+
break;
|
|
8288
|
+
case "endsWith":
|
|
8289
|
+
addPattern(res, RegExp(`${escapeLiteralCheckValue(check.value, refs)}$`), check.message, refs);
|
|
8290
|
+
break;
|
|
8291
|
+
case "datetime":
|
|
8292
|
+
addFormat(res, "date-time", check.message, refs);
|
|
8293
|
+
break;
|
|
8294
|
+
case "date":
|
|
8295
|
+
addFormat(res, "date", check.message, refs);
|
|
8296
|
+
break;
|
|
8297
|
+
case "time":
|
|
8298
|
+
addFormat(res, "time", check.message, refs);
|
|
8299
|
+
break;
|
|
8300
|
+
case "duration":
|
|
8301
|
+
addFormat(res, "duration", check.message, refs);
|
|
8302
|
+
break;
|
|
8303
|
+
case "length":
|
|
8304
|
+
setResponseValueAndErrors(res, "minLength", typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value, check.message, refs);
|
|
8305
|
+
setResponseValueAndErrors(res, "maxLength", typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);
|
|
8306
|
+
break;
|
|
8307
|
+
case "includes": {
|
|
8308
|
+
addPattern(res, RegExp(escapeLiteralCheckValue(check.value, refs)), check.message, refs);
|
|
8309
|
+
break;
|
|
8310
|
+
}
|
|
8311
|
+
case "ip": {
|
|
8312
|
+
if (check.version !== "v6") {
|
|
8313
|
+
addFormat(res, "ipv4", check.message, refs);
|
|
8314
|
+
}
|
|
8315
|
+
if (check.version !== "v4") {
|
|
8316
|
+
addFormat(res, "ipv6", check.message, refs);
|
|
8317
|
+
}
|
|
8318
|
+
break;
|
|
8319
|
+
}
|
|
8320
|
+
case "base64url":
|
|
8321
|
+
addPattern(res, zodPatterns.base64url, check.message, refs);
|
|
8322
|
+
break;
|
|
8323
|
+
case "jwt":
|
|
8324
|
+
addPattern(res, zodPatterns.jwt, check.message, refs);
|
|
8325
|
+
break;
|
|
8326
|
+
case "cidr": {
|
|
8327
|
+
if (check.version !== "v6") {
|
|
8328
|
+
addPattern(res, zodPatterns.ipv4Cidr, check.message, refs);
|
|
8329
|
+
}
|
|
8330
|
+
if (check.version !== "v4") {
|
|
8331
|
+
addPattern(res, zodPatterns.ipv6Cidr, check.message, refs);
|
|
8332
|
+
}
|
|
8333
|
+
break;
|
|
8334
|
+
}
|
|
8335
|
+
case "emoji":
|
|
8336
|
+
addPattern(res, zodPatterns.emoji(), check.message, refs);
|
|
8337
|
+
break;
|
|
8338
|
+
case "ulid": {
|
|
8339
|
+
addPattern(res, zodPatterns.ulid, check.message, refs);
|
|
8340
|
+
break;
|
|
8341
|
+
}
|
|
8342
|
+
case "base64": {
|
|
8343
|
+
switch (refs.base64Strategy) {
|
|
8344
|
+
case "format:binary": {
|
|
8345
|
+
addFormat(res, "binary", check.message, refs);
|
|
8346
|
+
break;
|
|
8347
|
+
}
|
|
8348
|
+
case "contentEncoding:base64": {
|
|
8349
|
+
setResponseValueAndErrors(res, "contentEncoding", "base64", check.message, refs);
|
|
8350
|
+
break;
|
|
8351
|
+
}
|
|
8352
|
+
case "pattern:zod": {
|
|
8353
|
+
addPattern(res, zodPatterns.base64, check.message, refs);
|
|
8354
|
+
break;
|
|
8355
|
+
}
|
|
8356
|
+
}
|
|
8357
|
+
break;
|
|
8358
|
+
}
|
|
8359
|
+
case "nanoid": {
|
|
8360
|
+
addPattern(res, zodPatterns.nanoid, check.message, refs);
|
|
8361
|
+
}
|
|
8362
|
+
case "toLowerCase":
|
|
8363
|
+
case "toUpperCase":
|
|
8364
|
+
case "trim":
|
|
8365
|
+
break;
|
|
8366
|
+
default:
|
|
8367
|
+
((_) => {})(check);
|
|
8368
|
+
}
|
|
8369
|
+
}
|
|
8370
|
+
}
|
|
8371
|
+
return res;
|
|
8372
|
+
}
|
|
8373
|
+
function escapeLiteralCheckValue(literal, refs) {
|
|
8374
|
+
return refs.patternStrategy === "escape" ? escapeNonAlphaNumeric(literal) : literal;
|
|
8375
|
+
}
|
|
8376
|
+
function escapeNonAlphaNumeric(source) {
|
|
8377
|
+
let result = "";
|
|
8378
|
+
for (let i = 0;i < source.length; i++) {
|
|
8379
|
+
if (!ALPHA_NUMERIC.has(source[i])) {
|
|
8380
|
+
result += "\\";
|
|
8381
|
+
}
|
|
8382
|
+
result += source[i];
|
|
8383
|
+
}
|
|
8384
|
+
return result;
|
|
8385
|
+
}
|
|
8386
|
+
function addFormat(schema, value, message, refs) {
|
|
8387
|
+
if (schema.format || schema.anyOf?.some((x) => x.format)) {
|
|
8388
|
+
if (!schema.anyOf) {
|
|
8389
|
+
schema.anyOf = [];
|
|
8390
|
+
}
|
|
8391
|
+
if (schema.format) {
|
|
8392
|
+
schema.anyOf.push({
|
|
8393
|
+
format: schema.format,
|
|
8394
|
+
...schema.errorMessage && refs.errorMessages && {
|
|
8395
|
+
errorMessage: { format: schema.errorMessage.format }
|
|
8396
|
+
}
|
|
8397
|
+
});
|
|
8398
|
+
delete schema.format;
|
|
8399
|
+
if (schema.errorMessage) {
|
|
8400
|
+
delete schema.errorMessage.format;
|
|
8401
|
+
if (Object.keys(schema.errorMessage).length === 0) {
|
|
8402
|
+
delete schema.errorMessage;
|
|
8403
|
+
}
|
|
8404
|
+
}
|
|
8405
|
+
}
|
|
8406
|
+
schema.anyOf.push({
|
|
8407
|
+
format: value,
|
|
8408
|
+
...message && refs.errorMessages && { errorMessage: { format: message } }
|
|
8409
|
+
});
|
|
8410
|
+
} else {
|
|
8411
|
+
setResponseValueAndErrors(schema, "format", value, message, refs);
|
|
8412
|
+
}
|
|
8413
|
+
}
|
|
8414
|
+
function addPattern(schema, regex, message, refs) {
|
|
8415
|
+
if (schema.pattern || schema.allOf?.some((x) => x.pattern)) {
|
|
8416
|
+
if (!schema.allOf) {
|
|
8417
|
+
schema.allOf = [];
|
|
8418
|
+
}
|
|
8419
|
+
if (schema.pattern) {
|
|
8420
|
+
schema.allOf.push({
|
|
8421
|
+
pattern: schema.pattern,
|
|
8422
|
+
...schema.errorMessage && refs.errorMessages && {
|
|
8423
|
+
errorMessage: { pattern: schema.errorMessage.pattern }
|
|
8424
|
+
}
|
|
8425
|
+
});
|
|
8426
|
+
delete schema.pattern;
|
|
8427
|
+
if (schema.errorMessage) {
|
|
8428
|
+
delete schema.errorMessage.pattern;
|
|
8429
|
+
if (Object.keys(schema.errorMessage).length === 0) {
|
|
8430
|
+
delete schema.errorMessage;
|
|
8431
|
+
}
|
|
8432
|
+
}
|
|
8433
|
+
}
|
|
8434
|
+
schema.allOf.push({
|
|
8435
|
+
pattern: stringifyRegExpWithFlags(regex, refs),
|
|
8436
|
+
...message && refs.errorMessages && { errorMessage: { pattern: message } }
|
|
8437
|
+
});
|
|
8438
|
+
} else {
|
|
8439
|
+
setResponseValueAndErrors(schema, "pattern", stringifyRegExpWithFlags(regex, refs), message, refs);
|
|
8440
|
+
}
|
|
8441
|
+
}
|
|
8442
|
+
function stringifyRegExpWithFlags(regex, refs) {
|
|
8443
|
+
if (!refs.applyRegexFlags || !regex.flags) {
|
|
8444
|
+
return regex.source;
|
|
8445
|
+
}
|
|
8446
|
+
const flags = {
|
|
8447
|
+
i: regex.flags.includes("i"),
|
|
8448
|
+
m: regex.flags.includes("m"),
|
|
8449
|
+
s: regex.flags.includes("s")
|
|
8450
|
+
};
|
|
8451
|
+
const source = flags.i ? regex.source.toLowerCase() : regex.source;
|
|
8452
|
+
let pattern = "";
|
|
8453
|
+
let isEscaped = false;
|
|
8454
|
+
let inCharGroup = false;
|
|
8455
|
+
let inCharRange = false;
|
|
8456
|
+
for (let i = 0;i < source.length; i++) {
|
|
8457
|
+
if (isEscaped) {
|
|
8458
|
+
pattern += source[i];
|
|
8459
|
+
isEscaped = false;
|
|
8460
|
+
continue;
|
|
8461
|
+
}
|
|
8462
|
+
if (flags.i) {
|
|
8463
|
+
if (inCharGroup) {
|
|
8464
|
+
if (source[i].match(/[a-z]/)) {
|
|
8465
|
+
if (inCharRange) {
|
|
8466
|
+
pattern += source[i];
|
|
8467
|
+
pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
|
|
8468
|
+
inCharRange = false;
|
|
8469
|
+
} else if (source[i + 1] === "-" && source[i + 2]?.match(/[a-z]/)) {
|
|
8470
|
+
pattern += source[i];
|
|
8471
|
+
inCharRange = true;
|
|
8472
|
+
} else {
|
|
8473
|
+
pattern += `${source[i]}${source[i].toUpperCase()}`;
|
|
8474
|
+
}
|
|
8475
|
+
continue;
|
|
8476
|
+
}
|
|
8477
|
+
} else if (source[i].match(/[a-z]/)) {
|
|
8478
|
+
pattern += `[${source[i]}${source[i].toUpperCase()}]`;
|
|
8479
|
+
continue;
|
|
8480
|
+
}
|
|
8481
|
+
}
|
|
8482
|
+
if (flags.m) {
|
|
8483
|
+
if (source[i] === "^") {
|
|
8484
|
+
pattern += `(^|(?<=[\r
|
|
8485
|
+
]))`;
|
|
8486
|
+
continue;
|
|
8487
|
+
} else if (source[i] === "$") {
|
|
8488
|
+
pattern += `($|(?=[\r
|
|
8489
|
+
]))`;
|
|
8490
|
+
continue;
|
|
8491
|
+
}
|
|
8492
|
+
}
|
|
8493
|
+
if (flags.s && source[i] === ".") {
|
|
8494
|
+
pattern += inCharGroup ? `${source[i]}\r
|
|
8495
|
+
` : `[${source[i]}\r
|
|
8496
|
+
]`;
|
|
8497
|
+
continue;
|
|
8498
|
+
}
|
|
8499
|
+
pattern += source[i];
|
|
8500
|
+
if (source[i] === "\\") {
|
|
8501
|
+
isEscaped = true;
|
|
8502
|
+
} else if (inCharGroup && source[i] === "]") {
|
|
8503
|
+
inCharGroup = false;
|
|
8504
|
+
} else if (!inCharGroup && source[i] === "[") {
|
|
8505
|
+
inCharGroup = true;
|
|
8506
|
+
}
|
|
8507
|
+
}
|
|
8508
|
+
try {
|
|
8509
|
+
new RegExp(pattern);
|
|
8510
|
+
} catch {
|
|
8511
|
+
console.warn(`Could not convert regex pattern at ${refs.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`);
|
|
8512
|
+
return regex.source;
|
|
8513
|
+
}
|
|
8514
|
+
return pattern;
|
|
8515
|
+
}
|
|
8516
|
+
var emojiRegex2 = undefined, zodPatterns, ALPHA_NUMERIC;
|
|
8517
|
+
var init_string = __esm(() => {
|
|
8518
|
+
zodPatterns = {
|
|
8519
|
+
cuid: /^[cC][^\s-]{8,}$/,
|
|
8520
|
+
cuid2: /^[0-9a-z]+$/,
|
|
8521
|
+
ulid: /^[0-9A-HJKMNP-TV-Z]{26}$/,
|
|
8522
|
+
email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,
|
|
8523
|
+
emoji: () => {
|
|
8524
|
+
if (emojiRegex2 === undefined) {
|
|
8525
|
+
emojiRegex2 = RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u");
|
|
8526
|
+
}
|
|
8527
|
+
return emojiRegex2;
|
|
8528
|
+
},
|
|
8529
|
+
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}$/,
|
|
8530
|
+
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])$/,
|
|
8531
|
+
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])$/,
|
|
8532
|
+
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})))$/,
|
|
8533
|
+
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])$/,
|
|
8534
|
+
base64: /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,
|
|
8535
|
+
base64url: /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,
|
|
8536
|
+
nanoid: /^[a-zA-Z0-9_-]{21}$/,
|
|
8537
|
+
jwt: /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/
|
|
8538
|
+
};
|
|
8539
|
+
ALPHA_NUMERIC = new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
|
|
8540
|
+
});
|
|
8541
|
+
|
|
8542
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/record.js
|
|
8543
|
+
function parseRecordDef(def, refs) {
|
|
8544
|
+
if (refs.target === "openAi") {
|
|
8545
|
+
console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.");
|
|
8546
|
+
}
|
|
8547
|
+
if (refs.target === "openApi3" && def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodEnum) {
|
|
8548
|
+
return {
|
|
8549
|
+
type: "object",
|
|
8550
|
+
required: def.keyType._def.values,
|
|
8551
|
+
properties: def.keyType._def.values.reduce((acc, key) => ({
|
|
8552
|
+
...acc,
|
|
8553
|
+
[key]: parseDef(def.valueType._def, {
|
|
8554
|
+
...refs,
|
|
8555
|
+
currentPath: [...refs.currentPath, "properties", key]
|
|
8556
|
+
}) ?? parseAnyDef(refs)
|
|
8557
|
+
}), {}),
|
|
8558
|
+
additionalProperties: refs.rejectedAdditionalProperties
|
|
8559
|
+
};
|
|
8560
|
+
}
|
|
8561
|
+
const schema = {
|
|
8562
|
+
type: "object",
|
|
8563
|
+
additionalProperties: parseDef(def.valueType._def, {
|
|
8564
|
+
...refs,
|
|
8565
|
+
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
8566
|
+
}) ?? refs.allowedAdditionalProperties
|
|
8567
|
+
};
|
|
8568
|
+
if (refs.target === "openApi3") {
|
|
8569
|
+
return schema;
|
|
8570
|
+
}
|
|
8571
|
+
if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodString && def.keyType._def.checks?.length) {
|
|
8572
|
+
const { type, ...keyType } = parseStringDef(def.keyType._def, refs);
|
|
8573
|
+
return {
|
|
8574
|
+
...schema,
|
|
8575
|
+
propertyNames: keyType
|
|
8576
|
+
};
|
|
8577
|
+
} else if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodEnum) {
|
|
8578
|
+
return {
|
|
8579
|
+
...schema,
|
|
8580
|
+
propertyNames: {
|
|
8581
|
+
enum: def.keyType._def.values
|
|
8582
|
+
}
|
|
8583
|
+
};
|
|
8584
|
+
} else if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodBranded && def.keyType._def.type._def.typeName === ZodFirstPartyTypeKind.ZodString && def.keyType._def.type._def.checks?.length) {
|
|
8585
|
+
const { type, ...keyType } = parseBrandedDef(def.keyType._def, refs);
|
|
8586
|
+
return {
|
|
8587
|
+
...schema,
|
|
8588
|
+
propertyNames: keyType
|
|
8589
|
+
};
|
|
8590
|
+
}
|
|
8591
|
+
return schema;
|
|
8592
|
+
}
|
|
8593
|
+
var init_record = __esm(() => {
|
|
8594
|
+
init_v3();
|
|
8595
|
+
init_parseDef();
|
|
8596
|
+
init_string();
|
|
8597
|
+
init_branded();
|
|
8598
|
+
init_any();
|
|
8599
|
+
});
|
|
8600
|
+
|
|
8601
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/map.js
|
|
8602
|
+
function parseMapDef(def, refs) {
|
|
8603
|
+
if (refs.mapStrategy === "record") {
|
|
8604
|
+
return parseRecordDef(def, refs);
|
|
8605
|
+
}
|
|
8606
|
+
const keys = parseDef(def.keyType._def, {
|
|
8607
|
+
...refs,
|
|
8608
|
+
currentPath: [...refs.currentPath, "items", "items", "0"]
|
|
8609
|
+
}) || parseAnyDef(refs);
|
|
8610
|
+
const values = parseDef(def.valueType._def, {
|
|
8611
|
+
...refs,
|
|
8612
|
+
currentPath: [...refs.currentPath, "items", "items", "1"]
|
|
8613
|
+
}) || parseAnyDef(refs);
|
|
8614
|
+
return {
|
|
8615
|
+
type: "array",
|
|
8616
|
+
maxItems: 125,
|
|
8617
|
+
items: {
|
|
8618
|
+
type: "array",
|
|
8619
|
+
items: [keys, values],
|
|
8620
|
+
minItems: 2,
|
|
8621
|
+
maxItems: 2
|
|
8622
|
+
}
|
|
8623
|
+
};
|
|
8624
|
+
}
|
|
8625
|
+
var init_map = __esm(() => {
|
|
8626
|
+
init_parseDef();
|
|
8627
|
+
init_record();
|
|
8628
|
+
init_any();
|
|
8629
|
+
});
|
|
8630
|
+
|
|
8631
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js
|
|
8632
|
+
function parseNativeEnumDef(def) {
|
|
8633
|
+
const object = def.values;
|
|
8634
|
+
const actualKeys = Object.keys(def.values).filter((key) => {
|
|
8635
|
+
return typeof object[object[key]] !== "number";
|
|
8636
|
+
});
|
|
8637
|
+
const actualValues = actualKeys.map((key) => object[key]);
|
|
8638
|
+
const parsedTypes = Array.from(new Set(actualValues.map((values) => typeof values)));
|
|
8639
|
+
return {
|
|
8640
|
+
type: parsedTypes.length === 1 ? parsedTypes[0] === "string" ? "string" : "number" : ["string", "number"],
|
|
8641
|
+
enum: actualValues
|
|
8642
|
+
};
|
|
8643
|
+
}
|
|
8644
|
+
|
|
8645
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/never.js
|
|
8646
|
+
function parseNeverDef(refs) {
|
|
8647
|
+
return refs.target === "openAi" ? undefined : {
|
|
8648
|
+
not: parseAnyDef({
|
|
8649
|
+
...refs,
|
|
8650
|
+
currentPath: [...refs.currentPath, "not"]
|
|
8651
|
+
})
|
|
8652
|
+
};
|
|
8653
|
+
}
|
|
8654
|
+
var init_never = __esm(() => {
|
|
8655
|
+
init_any();
|
|
8656
|
+
});
|
|
8657
|
+
|
|
8658
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/null.js
|
|
8659
|
+
function parseNullDef(refs) {
|
|
8660
|
+
return refs.target === "openApi3" ? {
|
|
8661
|
+
enum: ["null"],
|
|
8662
|
+
nullable: true
|
|
8663
|
+
} : {
|
|
8664
|
+
type: "null"
|
|
8665
|
+
};
|
|
8666
|
+
}
|
|
8667
|
+
|
|
8668
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/union.js
|
|
8669
|
+
function parseUnionDef(def, refs) {
|
|
8670
|
+
if (refs.target === "openApi3")
|
|
8671
|
+
return asAnyOf(def, refs);
|
|
8672
|
+
const options = def.options instanceof Map ? Array.from(def.options.values()) : def.options;
|
|
8673
|
+
if (options.every((x) => (x._def.typeName in primitiveMappings) && (!x._def.checks || !x._def.checks.length))) {
|
|
8674
|
+
const types2 = options.reduce((types3, x) => {
|
|
8675
|
+
const type = primitiveMappings[x._def.typeName];
|
|
8676
|
+
return type && !types3.includes(type) ? [...types3, type] : types3;
|
|
8677
|
+
}, []);
|
|
8678
|
+
return {
|
|
8679
|
+
type: types2.length > 1 ? types2 : types2[0]
|
|
8680
|
+
};
|
|
8681
|
+
} else if (options.every((x) => x._def.typeName === "ZodLiteral" && !x.description)) {
|
|
8682
|
+
const types2 = options.reduce((acc, x) => {
|
|
8683
|
+
const type = typeof x._def.value;
|
|
8684
|
+
switch (type) {
|
|
8685
|
+
case "string":
|
|
8686
|
+
case "number":
|
|
8687
|
+
case "boolean":
|
|
8688
|
+
return [...acc, type];
|
|
8689
|
+
case "bigint":
|
|
8690
|
+
return [...acc, "integer"];
|
|
8691
|
+
case "object":
|
|
8692
|
+
if (x._def.value === null)
|
|
8693
|
+
return [...acc, "null"];
|
|
8694
|
+
case "symbol":
|
|
8695
|
+
case "undefined":
|
|
8696
|
+
case "function":
|
|
8697
|
+
default:
|
|
8698
|
+
return acc;
|
|
8699
|
+
}
|
|
8700
|
+
}, []);
|
|
8701
|
+
if (types2.length === options.length) {
|
|
8702
|
+
const uniqueTypes = types2.filter((x, i, a) => a.indexOf(x) === i);
|
|
8703
|
+
return {
|
|
8704
|
+
type: uniqueTypes.length > 1 ? uniqueTypes : uniqueTypes[0],
|
|
8705
|
+
enum: options.reduce((acc, x) => {
|
|
8706
|
+
return acc.includes(x._def.value) ? acc : [...acc, x._def.value];
|
|
8707
|
+
}, [])
|
|
8708
|
+
};
|
|
8709
|
+
}
|
|
8710
|
+
} else if (options.every((x) => x._def.typeName === "ZodEnum")) {
|
|
8711
|
+
return {
|
|
8712
|
+
type: "string",
|
|
8713
|
+
enum: options.reduce((acc, x) => [
|
|
8714
|
+
...acc,
|
|
8715
|
+
...x._def.values.filter((x2) => !acc.includes(x2))
|
|
8716
|
+
], [])
|
|
8717
|
+
};
|
|
8718
|
+
}
|
|
8719
|
+
return asAnyOf(def, refs);
|
|
8720
|
+
}
|
|
8721
|
+
var primitiveMappings, asAnyOf = (def, refs) => {
|
|
8722
|
+
const anyOf = (def.options instanceof Map ? Array.from(def.options.values()) : def.options).map((x, i) => parseDef(x._def, {
|
|
8723
|
+
...refs,
|
|
8724
|
+
currentPath: [...refs.currentPath, "anyOf", `${i}`]
|
|
8725
|
+
})).filter((x) => !!x && (!refs.strictUnions || typeof x === "object" && Object.keys(x).length > 0));
|
|
8726
|
+
return anyOf.length ? { anyOf } : undefined;
|
|
8727
|
+
};
|
|
8728
|
+
var init_union = __esm(() => {
|
|
8729
|
+
init_parseDef();
|
|
8730
|
+
primitiveMappings = {
|
|
8731
|
+
ZodString: "string",
|
|
8732
|
+
ZodNumber: "number",
|
|
8733
|
+
ZodBigInt: "integer",
|
|
8734
|
+
ZodBoolean: "boolean",
|
|
8735
|
+
ZodNull: "null"
|
|
8736
|
+
};
|
|
8737
|
+
});
|
|
8738
|
+
|
|
8739
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js
|
|
8740
|
+
function parseNullableDef(def, refs) {
|
|
8741
|
+
if (["ZodString", "ZodNumber", "ZodBigInt", "ZodBoolean", "ZodNull"].includes(def.innerType._def.typeName) && (!def.innerType._def.checks || !def.innerType._def.checks.length)) {
|
|
8742
|
+
if (refs.target === "openApi3") {
|
|
8743
|
+
return {
|
|
8744
|
+
type: primitiveMappings[def.innerType._def.typeName],
|
|
8745
|
+
nullable: true
|
|
8746
|
+
};
|
|
8747
|
+
}
|
|
8748
|
+
return {
|
|
8749
|
+
type: [
|
|
8750
|
+
primitiveMappings[def.innerType._def.typeName],
|
|
8751
|
+
"null"
|
|
8752
|
+
]
|
|
8753
|
+
};
|
|
8754
|
+
}
|
|
8755
|
+
if (refs.target === "openApi3") {
|
|
8756
|
+
const base2 = parseDef(def.innerType._def, {
|
|
8757
|
+
...refs,
|
|
8758
|
+
currentPath: [...refs.currentPath]
|
|
8759
|
+
});
|
|
8760
|
+
if (base2 && "$ref" in base2)
|
|
8761
|
+
return { allOf: [base2], nullable: true };
|
|
8762
|
+
return base2 && { ...base2, nullable: true };
|
|
8763
|
+
}
|
|
8764
|
+
const base = parseDef(def.innerType._def, {
|
|
8765
|
+
...refs,
|
|
8766
|
+
currentPath: [...refs.currentPath, "anyOf", "0"]
|
|
8767
|
+
});
|
|
8768
|
+
return base && { anyOf: [base, { type: "null" }] };
|
|
8769
|
+
}
|
|
8770
|
+
var init_nullable = __esm(() => {
|
|
8771
|
+
init_parseDef();
|
|
8772
|
+
init_union();
|
|
8773
|
+
});
|
|
8774
|
+
|
|
8775
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/number.js
|
|
8776
|
+
function parseNumberDef(def, refs) {
|
|
8777
|
+
const res = {
|
|
8778
|
+
type: "number"
|
|
8779
|
+
};
|
|
8780
|
+
if (!def.checks)
|
|
8781
|
+
return res;
|
|
8782
|
+
for (const check of def.checks) {
|
|
8783
|
+
switch (check.kind) {
|
|
8784
|
+
case "int":
|
|
8785
|
+
res.type = "integer";
|
|
8786
|
+
addErrorMessage(res, "type", check.message, refs);
|
|
8787
|
+
break;
|
|
8788
|
+
case "min":
|
|
8789
|
+
if (refs.target === "jsonSchema7") {
|
|
8790
|
+
if (check.inclusive) {
|
|
8791
|
+
setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
8792
|
+
} else {
|
|
8793
|
+
setResponseValueAndErrors(res, "exclusiveMinimum", check.value, check.message, refs);
|
|
8794
|
+
}
|
|
8795
|
+
} else {
|
|
8796
|
+
if (!check.inclusive) {
|
|
8797
|
+
res.exclusiveMinimum = true;
|
|
8798
|
+
}
|
|
8799
|
+
setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
8800
|
+
}
|
|
8801
|
+
break;
|
|
8802
|
+
case "max":
|
|
8803
|
+
if (refs.target === "jsonSchema7") {
|
|
8804
|
+
if (check.inclusive) {
|
|
8805
|
+
setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
8806
|
+
} else {
|
|
8807
|
+
setResponseValueAndErrors(res, "exclusiveMaximum", check.value, check.message, refs);
|
|
8808
|
+
}
|
|
8809
|
+
} else {
|
|
8810
|
+
if (!check.inclusive) {
|
|
8811
|
+
res.exclusiveMaximum = true;
|
|
8812
|
+
}
|
|
8813
|
+
setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
8814
|
+
}
|
|
8815
|
+
break;
|
|
8816
|
+
case "multipleOf":
|
|
8817
|
+
setResponseValueAndErrors(res, "multipleOf", check.value, check.message, refs);
|
|
8818
|
+
break;
|
|
8819
|
+
}
|
|
8820
|
+
}
|
|
8821
|
+
return res;
|
|
8822
|
+
}
|
|
8823
|
+
var init_number = () => {};
|
|
8824
|
+
|
|
8825
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/object.js
|
|
8826
|
+
function parseObjectDef(def, refs) {
|
|
8827
|
+
const forceOptionalIntoNullable = refs.target === "openAi";
|
|
8828
|
+
const result = {
|
|
8829
|
+
type: "object",
|
|
8830
|
+
properties: {}
|
|
8831
|
+
};
|
|
8832
|
+
const required = [];
|
|
8833
|
+
const shape = def.shape();
|
|
8834
|
+
for (const propName in shape) {
|
|
8835
|
+
let propDef = shape[propName];
|
|
8836
|
+
if (propDef === undefined || propDef._def === undefined) {
|
|
8837
|
+
continue;
|
|
8838
|
+
}
|
|
8839
|
+
let propOptional = safeIsOptional(propDef);
|
|
8840
|
+
if (propOptional && forceOptionalIntoNullable) {
|
|
8841
|
+
if (propDef._def.typeName === "ZodOptional") {
|
|
8842
|
+
propDef = propDef._def.innerType;
|
|
8843
|
+
}
|
|
8844
|
+
if (!propDef.isNullable()) {
|
|
8845
|
+
propDef = propDef.nullable();
|
|
8846
|
+
}
|
|
8847
|
+
propOptional = false;
|
|
8848
|
+
}
|
|
8849
|
+
const parsedDef = parseDef(propDef._def, {
|
|
8850
|
+
...refs,
|
|
8851
|
+
currentPath: [...refs.currentPath, "properties", propName],
|
|
8852
|
+
propertyPath: [...refs.currentPath, "properties", propName]
|
|
8853
|
+
});
|
|
8854
|
+
if (parsedDef === undefined) {
|
|
8855
|
+
continue;
|
|
8856
|
+
}
|
|
8857
|
+
result.properties[propName] = parsedDef;
|
|
8858
|
+
if (!propOptional) {
|
|
8859
|
+
required.push(propName);
|
|
8860
|
+
}
|
|
8861
|
+
}
|
|
8862
|
+
if (required.length) {
|
|
8863
|
+
result.required = required;
|
|
8864
|
+
}
|
|
8865
|
+
const additionalProperties = decideAdditionalProperties(def, refs);
|
|
8866
|
+
if (additionalProperties !== undefined) {
|
|
8867
|
+
result.additionalProperties = additionalProperties;
|
|
8868
|
+
}
|
|
8869
|
+
return result;
|
|
8870
|
+
}
|
|
8871
|
+
function decideAdditionalProperties(def, refs) {
|
|
8872
|
+
if (def.catchall._def.typeName !== "ZodNever") {
|
|
8873
|
+
return parseDef(def.catchall._def, {
|
|
8874
|
+
...refs,
|
|
8875
|
+
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
8876
|
+
});
|
|
8877
|
+
}
|
|
8878
|
+
switch (def.unknownKeys) {
|
|
8879
|
+
case "passthrough":
|
|
8880
|
+
return refs.allowedAdditionalProperties;
|
|
8881
|
+
case "strict":
|
|
8882
|
+
return refs.rejectedAdditionalProperties;
|
|
8883
|
+
case "strip":
|
|
8884
|
+
return refs.removeAdditionalStrategy === "strict" ? refs.allowedAdditionalProperties : refs.rejectedAdditionalProperties;
|
|
8885
|
+
}
|
|
8886
|
+
}
|
|
8887
|
+
function safeIsOptional(schema) {
|
|
8888
|
+
try {
|
|
8889
|
+
return schema.isOptional();
|
|
8890
|
+
} catch {
|
|
8891
|
+
return true;
|
|
8892
|
+
}
|
|
8893
|
+
}
|
|
8894
|
+
var init_object = __esm(() => {
|
|
8895
|
+
init_parseDef();
|
|
8896
|
+
});
|
|
8897
|
+
|
|
8898
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/optional.js
|
|
8899
|
+
var parseOptionalDef = (def, refs) => {
|
|
8900
|
+
if (refs.currentPath.toString() === refs.propertyPath?.toString()) {
|
|
8901
|
+
return parseDef(def.innerType._def, refs);
|
|
8902
|
+
}
|
|
8903
|
+
const innerSchema = parseDef(def.innerType._def, {
|
|
8904
|
+
...refs,
|
|
8905
|
+
currentPath: [...refs.currentPath, "anyOf", "1"]
|
|
8906
|
+
});
|
|
8907
|
+
return innerSchema ? {
|
|
8908
|
+
anyOf: [
|
|
8909
|
+
{
|
|
8910
|
+
not: parseAnyDef(refs)
|
|
8911
|
+
},
|
|
8912
|
+
innerSchema
|
|
8913
|
+
]
|
|
8914
|
+
} : parseAnyDef(refs);
|
|
8915
|
+
};
|
|
8916
|
+
var init_optional = __esm(() => {
|
|
8917
|
+
init_parseDef();
|
|
8918
|
+
init_any();
|
|
8919
|
+
});
|
|
8920
|
+
|
|
8921
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js
|
|
8922
|
+
var parsePipelineDef = (def, refs) => {
|
|
8923
|
+
if (refs.pipeStrategy === "input") {
|
|
8924
|
+
return parseDef(def.in._def, refs);
|
|
8925
|
+
} else if (refs.pipeStrategy === "output") {
|
|
8926
|
+
return parseDef(def.out._def, refs);
|
|
8927
|
+
}
|
|
8928
|
+
const a = parseDef(def.in._def, {
|
|
8929
|
+
...refs,
|
|
8930
|
+
currentPath: [...refs.currentPath, "allOf", "0"]
|
|
8931
|
+
});
|
|
8932
|
+
const b = parseDef(def.out._def, {
|
|
8933
|
+
...refs,
|
|
8934
|
+
currentPath: [...refs.currentPath, "allOf", a ? "1" : "0"]
|
|
8935
|
+
});
|
|
8936
|
+
return {
|
|
8937
|
+
allOf: [a, b].filter((x) => x !== undefined)
|
|
8938
|
+
};
|
|
8939
|
+
};
|
|
8940
|
+
var init_pipeline = __esm(() => {
|
|
8941
|
+
init_parseDef();
|
|
8942
|
+
});
|
|
8943
|
+
|
|
8944
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/promise.js
|
|
8945
|
+
function parsePromiseDef(def, refs) {
|
|
8946
|
+
return parseDef(def.type._def, refs);
|
|
8947
|
+
}
|
|
8948
|
+
var init_promise = __esm(() => {
|
|
8949
|
+
init_parseDef();
|
|
8950
|
+
});
|
|
8951
|
+
|
|
8952
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/set.js
|
|
8953
|
+
function parseSetDef(def, refs) {
|
|
8954
|
+
const items = parseDef(def.valueType._def, {
|
|
8955
|
+
...refs,
|
|
8956
|
+
currentPath: [...refs.currentPath, "items"]
|
|
8957
|
+
});
|
|
8958
|
+
const schema = {
|
|
8959
|
+
type: "array",
|
|
8960
|
+
uniqueItems: true,
|
|
8961
|
+
items
|
|
8962
|
+
};
|
|
8963
|
+
if (def.minSize) {
|
|
8964
|
+
setResponseValueAndErrors(schema, "minItems", def.minSize.value, def.minSize.message, refs);
|
|
8965
|
+
}
|
|
8966
|
+
if (def.maxSize) {
|
|
8967
|
+
setResponseValueAndErrors(schema, "maxItems", def.maxSize.value, def.maxSize.message, refs);
|
|
8968
|
+
}
|
|
8969
|
+
return schema;
|
|
8970
|
+
}
|
|
8971
|
+
var init_set = __esm(() => {
|
|
8972
|
+
init_parseDef();
|
|
8973
|
+
});
|
|
8974
|
+
|
|
8975
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js
|
|
8976
|
+
function parseTupleDef(def, refs) {
|
|
8977
|
+
if (def.rest) {
|
|
8978
|
+
return {
|
|
8979
|
+
type: "array",
|
|
8980
|
+
minItems: def.items.length,
|
|
8981
|
+
items: def.items.map((x, i) => parseDef(x._def, {
|
|
8982
|
+
...refs,
|
|
8983
|
+
currentPath: [...refs.currentPath, "items", `${i}`]
|
|
8984
|
+
})).reduce((acc, x) => x === undefined ? acc : [...acc, x], []),
|
|
8985
|
+
additionalItems: parseDef(def.rest._def, {
|
|
8986
|
+
...refs,
|
|
8987
|
+
currentPath: [...refs.currentPath, "additionalItems"]
|
|
8988
|
+
})
|
|
8989
|
+
};
|
|
8990
|
+
} else {
|
|
8991
|
+
return {
|
|
8992
|
+
type: "array",
|
|
8993
|
+
minItems: def.items.length,
|
|
8994
|
+
maxItems: def.items.length,
|
|
8995
|
+
items: def.items.map((x, i) => parseDef(x._def, {
|
|
8996
|
+
...refs,
|
|
8997
|
+
currentPath: [...refs.currentPath, "items", `${i}`]
|
|
8998
|
+
})).reduce((acc, x) => x === undefined ? acc : [...acc, x], [])
|
|
8999
|
+
};
|
|
9000
|
+
}
|
|
9001
|
+
}
|
|
9002
|
+
var init_tuple = __esm(() => {
|
|
9003
|
+
init_parseDef();
|
|
9004
|
+
});
|
|
9005
|
+
|
|
9006
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js
|
|
9007
|
+
function parseUndefinedDef(refs) {
|
|
9008
|
+
return {
|
|
9009
|
+
not: parseAnyDef(refs)
|
|
9010
|
+
};
|
|
9011
|
+
}
|
|
9012
|
+
var init_undefined = __esm(() => {
|
|
9013
|
+
init_any();
|
|
9014
|
+
});
|
|
9015
|
+
|
|
9016
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js
|
|
9017
|
+
function parseUnknownDef(refs) {
|
|
9018
|
+
return parseAnyDef(refs);
|
|
9019
|
+
}
|
|
9020
|
+
var init_unknown = __esm(() => {
|
|
9021
|
+
init_any();
|
|
9022
|
+
});
|
|
9023
|
+
|
|
9024
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js
|
|
9025
|
+
var parseReadonlyDef = (def, refs) => {
|
|
9026
|
+
return parseDef(def.innerType._def, refs);
|
|
9027
|
+
};
|
|
9028
|
+
var init_readonly = __esm(() => {
|
|
9029
|
+
init_parseDef();
|
|
9030
|
+
});
|
|
9031
|
+
|
|
9032
|
+
// node_modules/zod-to-json-schema/dist/esm/selectParser.js
|
|
9033
|
+
var selectParser = (def, typeName, refs) => {
|
|
9034
|
+
switch (typeName) {
|
|
9035
|
+
case ZodFirstPartyTypeKind.ZodString:
|
|
9036
|
+
return parseStringDef(def, refs);
|
|
9037
|
+
case ZodFirstPartyTypeKind.ZodNumber:
|
|
9038
|
+
return parseNumberDef(def, refs);
|
|
9039
|
+
case ZodFirstPartyTypeKind.ZodObject:
|
|
9040
|
+
return parseObjectDef(def, refs);
|
|
9041
|
+
case ZodFirstPartyTypeKind.ZodBigInt:
|
|
9042
|
+
return parseBigintDef(def, refs);
|
|
9043
|
+
case ZodFirstPartyTypeKind.ZodBoolean:
|
|
9044
|
+
return parseBooleanDef();
|
|
9045
|
+
case ZodFirstPartyTypeKind.ZodDate:
|
|
9046
|
+
return parseDateDef(def, refs);
|
|
9047
|
+
case ZodFirstPartyTypeKind.ZodUndefined:
|
|
9048
|
+
return parseUndefinedDef(refs);
|
|
9049
|
+
case ZodFirstPartyTypeKind.ZodNull:
|
|
9050
|
+
return parseNullDef(refs);
|
|
9051
|
+
case ZodFirstPartyTypeKind.ZodArray:
|
|
9052
|
+
return parseArrayDef(def, refs);
|
|
9053
|
+
case ZodFirstPartyTypeKind.ZodUnion:
|
|
9054
|
+
case ZodFirstPartyTypeKind.ZodDiscriminatedUnion:
|
|
9055
|
+
return parseUnionDef(def, refs);
|
|
9056
|
+
case ZodFirstPartyTypeKind.ZodIntersection:
|
|
9057
|
+
return parseIntersectionDef(def, refs);
|
|
9058
|
+
case ZodFirstPartyTypeKind.ZodTuple:
|
|
9059
|
+
return parseTupleDef(def, refs);
|
|
9060
|
+
case ZodFirstPartyTypeKind.ZodRecord:
|
|
9061
|
+
return parseRecordDef(def, refs);
|
|
9062
|
+
case ZodFirstPartyTypeKind.ZodLiteral:
|
|
9063
|
+
return parseLiteralDef(def, refs);
|
|
9064
|
+
case ZodFirstPartyTypeKind.ZodEnum:
|
|
9065
|
+
return parseEnumDef(def);
|
|
9066
|
+
case ZodFirstPartyTypeKind.ZodNativeEnum:
|
|
9067
|
+
return parseNativeEnumDef(def);
|
|
9068
|
+
case ZodFirstPartyTypeKind.ZodNullable:
|
|
9069
|
+
return parseNullableDef(def, refs);
|
|
9070
|
+
case ZodFirstPartyTypeKind.ZodOptional:
|
|
9071
|
+
return parseOptionalDef(def, refs);
|
|
9072
|
+
case ZodFirstPartyTypeKind.ZodMap:
|
|
9073
|
+
return parseMapDef(def, refs);
|
|
9074
|
+
case ZodFirstPartyTypeKind.ZodSet:
|
|
9075
|
+
return parseSetDef(def, refs);
|
|
9076
|
+
case ZodFirstPartyTypeKind.ZodLazy:
|
|
9077
|
+
return () => def.getter()._def;
|
|
9078
|
+
case ZodFirstPartyTypeKind.ZodPromise:
|
|
9079
|
+
return parsePromiseDef(def, refs);
|
|
9080
|
+
case ZodFirstPartyTypeKind.ZodNaN:
|
|
9081
|
+
case ZodFirstPartyTypeKind.ZodNever:
|
|
9082
|
+
return parseNeverDef(refs);
|
|
9083
|
+
case ZodFirstPartyTypeKind.ZodEffects:
|
|
9084
|
+
return parseEffectsDef(def, refs);
|
|
9085
|
+
case ZodFirstPartyTypeKind.ZodAny:
|
|
9086
|
+
return parseAnyDef(refs);
|
|
9087
|
+
case ZodFirstPartyTypeKind.ZodUnknown:
|
|
9088
|
+
return parseUnknownDef(refs);
|
|
9089
|
+
case ZodFirstPartyTypeKind.ZodDefault:
|
|
9090
|
+
return parseDefaultDef(def, refs);
|
|
9091
|
+
case ZodFirstPartyTypeKind.ZodBranded:
|
|
9092
|
+
return parseBrandedDef(def, refs);
|
|
9093
|
+
case ZodFirstPartyTypeKind.ZodReadonly:
|
|
9094
|
+
return parseReadonlyDef(def, refs);
|
|
9095
|
+
case ZodFirstPartyTypeKind.ZodCatch:
|
|
9096
|
+
return parseCatchDef(def, refs);
|
|
9097
|
+
case ZodFirstPartyTypeKind.ZodPipeline:
|
|
9098
|
+
return parsePipelineDef(def, refs);
|
|
9099
|
+
case ZodFirstPartyTypeKind.ZodFunction:
|
|
9100
|
+
case ZodFirstPartyTypeKind.ZodVoid:
|
|
9101
|
+
case ZodFirstPartyTypeKind.ZodSymbol:
|
|
9102
|
+
return;
|
|
9103
|
+
default:
|
|
9104
|
+
return ((_) => {
|
|
9105
|
+
return;
|
|
9106
|
+
})(typeName);
|
|
9107
|
+
}
|
|
9108
|
+
};
|
|
9109
|
+
var init_selectParser = __esm(() => {
|
|
9110
|
+
init_v3();
|
|
9111
|
+
init_any();
|
|
9112
|
+
init_array();
|
|
9113
|
+
init_bigint();
|
|
9114
|
+
init_branded();
|
|
9115
|
+
init_catch();
|
|
9116
|
+
init_date();
|
|
9117
|
+
init_default();
|
|
9118
|
+
init_effects();
|
|
9119
|
+
init_intersection();
|
|
9120
|
+
init_map();
|
|
9121
|
+
init_never();
|
|
9122
|
+
init_nullable();
|
|
9123
|
+
init_number();
|
|
9124
|
+
init_object();
|
|
9125
|
+
init_optional();
|
|
9126
|
+
init_pipeline();
|
|
9127
|
+
init_promise();
|
|
9128
|
+
init_record();
|
|
9129
|
+
init_set();
|
|
9130
|
+
init_string();
|
|
9131
|
+
init_tuple();
|
|
9132
|
+
init_undefined();
|
|
9133
|
+
init_union();
|
|
9134
|
+
init_unknown();
|
|
9135
|
+
init_readonly();
|
|
9136
|
+
});
|
|
9137
|
+
|
|
9138
|
+
// node_modules/zod-to-json-schema/dist/esm/parseDef.js
|
|
9139
|
+
function parseDef(def, refs, forceResolution = false) {
|
|
9140
|
+
const seenItem = refs.seen.get(def);
|
|
9141
|
+
if (refs.override) {
|
|
9142
|
+
const overrideResult = refs.override?.(def, refs, seenItem, forceResolution);
|
|
9143
|
+
if (overrideResult !== ignoreOverride) {
|
|
9144
|
+
return overrideResult;
|
|
9145
|
+
}
|
|
9146
|
+
}
|
|
9147
|
+
if (seenItem && !forceResolution) {
|
|
9148
|
+
const seenSchema = get$ref(seenItem, refs);
|
|
9149
|
+
if (seenSchema !== undefined) {
|
|
9150
|
+
return seenSchema;
|
|
9151
|
+
}
|
|
9152
|
+
}
|
|
9153
|
+
const newItem = { def, path: refs.currentPath, jsonSchema: undefined };
|
|
9154
|
+
refs.seen.set(def, newItem);
|
|
9155
|
+
const jsonSchemaOrGetter = selectParser(def, def.typeName, refs);
|
|
9156
|
+
const jsonSchema = typeof jsonSchemaOrGetter === "function" ? parseDef(jsonSchemaOrGetter(), refs) : jsonSchemaOrGetter;
|
|
9157
|
+
if (jsonSchema) {
|
|
9158
|
+
addMeta(def, refs, jsonSchema);
|
|
9159
|
+
}
|
|
9160
|
+
if (refs.postProcess) {
|
|
9161
|
+
const postProcessResult = refs.postProcess(jsonSchema, def, refs);
|
|
9162
|
+
newItem.jsonSchema = jsonSchema;
|
|
9163
|
+
return postProcessResult;
|
|
9164
|
+
}
|
|
9165
|
+
newItem.jsonSchema = jsonSchema;
|
|
9166
|
+
return jsonSchema;
|
|
9167
|
+
}
|
|
9168
|
+
var get$ref = (item, refs) => {
|
|
9169
|
+
switch (refs.$refStrategy) {
|
|
9170
|
+
case "root":
|
|
9171
|
+
return { $ref: item.path.join("/") };
|
|
9172
|
+
case "relative":
|
|
9173
|
+
return { $ref: getRelativePath(refs.currentPath, item.path) };
|
|
9174
|
+
case "none":
|
|
9175
|
+
case "seen": {
|
|
9176
|
+
if (item.path.length < refs.currentPath.length && item.path.every((value, index) => refs.currentPath[index] === value)) {
|
|
9177
|
+
console.warn(`Recursive reference detected at ${refs.currentPath.join("/")}! Defaulting to any`);
|
|
9178
|
+
return parseAnyDef(refs);
|
|
9179
|
+
}
|
|
9180
|
+
return refs.$refStrategy === "seen" ? parseAnyDef(refs) : undefined;
|
|
9181
|
+
}
|
|
9182
|
+
}
|
|
9183
|
+
}, addMeta = (def, refs, jsonSchema) => {
|
|
9184
|
+
if (def.description) {
|
|
9185
|
+
jsonSchema.description = def.description;
|
|
9186
|
+
if (refs.markdownDescription) {
|
|
9187
|
+
jsonSchema.markdownDescription = def.description;
|
|
9188
|
+
}
|
|
9189
|
+
}
|
|
9190
|
+
return jsonSchema;
|
|
9191
|
+
};
|
|
9192
|
+
var init_parseDef = __esm(() => {
|
|
9193
|
+
init_Options();
|
|
9194
|
+
init_selectParser();
|
|
9195
|
+
init_any();
|
|
9196
|
+
});
|
|
9197
|
+
|
|
9198
|
+
// node_modules/zod-to-json-schema/dist/esm/parseTypes.js
|
|
9199
|
+
var init_parseTypes = () => {};
|
|
9200
|
+
|
|
9201
|
+
// node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js
|
|
9202
|
+
var zodToJsonSchema = (schema, options) => {
|
|
9203
|
+
const refs = getRefs(options);
|
|
9204
|
+
let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name2, schema2]) => ({
|
|
9205
|
+
...acc,
|
|
9206
|
+
[name2]: parseDef(schema2._def, {
|
|
9207
|
+
...refs,
|
|
9208
|
+
currentPath: [...refs.basePath, refs.definitionPath, name2]
|
|
9209
|
+
}, true) ?? parseAnyDef(refs)
|
|
9210
|
+
}), {}) : undefined;
|
|
9211
|
+
const name = typeof options === "string" ? options : options?.nameStrategy === "title" ? undefined : options?.name;
|
|
9212
|
+
const main = parseDef(schema._def, name === undefined ? refs : {
|
|
9213
|
+
...refs,
|
|
9214
|
+
currentPath: [...refs.basePath, refs.definitionPath, name]
|
|
9215
|
+
}, false) ?? parseAnyDef(refs);
|
|
9216
|
+
const title = typeof options === "object" && options.name !== undefined && options.nameStrategy === "title" ? options.name : undefined;
|
|
9217
|
+
if (title !== undefined) {
|
|
9218
|
+
main.title = title;
|
|
9219
|
+
}
|
|
9220
|
+
if (refs.flags.hasReferencedOpenAiAnyType) {
|
|
9221
|
+
if (!definitions) {
|
|
9222
|
+
definitions = {};
|
|
9223
|
+
}
|
|
9224
|
+
if (!definitions[refs.openAiAnyTypeName]) {
|
|
9225
|
+
definitions[refs.openAiAnyTypeName] = {
|
|
9226
|
+
type: ["string", "number", "integer", "boolean", "array", "null"],
|
|
9227
|
+
items: {
|
|
9228
|
+
$ref: refs.$refStrategy === "relative" ? "1" : [
|
|
9229
|
+
...refs.basePath,
|
|
9230
|
+
refs.definitionPath,
|
|
9231
|
+
refs.openAiAnyTypeName
|
|
9232
|
+
].join("/")
|
|
9233
|
+
}
|
|
9234
|
+
};
|
|
9235
|
+
}
|
|
9236
|
+
}
|
|
9237
|
+
const combined = name === undefined ? definitions ? {
|
|
9238
|
+
...main,
|
|
9239
|
+
[refs.definitionPath]: definitions
|
|
9240
|
+
} : main : {
|
|
9241
|
+
$ref: [
|
|
9242
|
+
...refs.$refStrategy === "relative" ? [] : refs.basePath,
|
|
9243
|
+
refs.definitionPath,
|
|
9244
|
+
name
|
|
9245
|
+
].join("/"),
|
|
9246
|
+
[refs.definitionPath]: {
|
|
9247
|
+
...definitions,
|
|
9248
|
+
[name]: main
|
|
9249
|
+
}
|
|
9250
|
+
};
|
|
9251
|
+
if (refs.target === "jsonSchema7") {
|
|
9252
|
+
combined.$schema = "http://json-schema.org/draft-07/schema#";
|
|
9253
|
+
} else if (refs.target === "jsonSchema2019-09" || refs.target === "openAi") {
|
|
9254
|
+
combined.$schema = "https://json-schema.org/draft/2019-09/schema#";
|
|
9255
|
+
}
|
|
9256
|
+
if (refs.target === "openAi" && (("anyOf" in combined) || ("oneOf" in combined) || ("allOf" in combined) || ("type" in combined) && Array.isArray(combined.type))) {
|
|
9257
|
+
console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property.");
|
|
9258
|
+
}
|
|
9259
|
+
return combined;
|
|
9260
|
+
};
|
|
9261
|
+
var init_zodToJsonSchema = __esm(() => {
|
|
9262
|
+
init_parseDef();
|
|
9263
|
+
init_Refs();
|
|
9264
|
+
init_any();
|
|
9265
|
+
});
|
|
9266
|
+
|
|
9267
|
+
// node_modules/zod-to-json-schema/dist/esm/index.js
|
|
9268
|
+
var init_esm = __esm(() => {
|
|
9269
|
+
init_zodToJsonSchema();
|
|
9270
|
+
init_Options();
|
|
9271
|
+
init_Refs();
|
|
9272
|
+
init_parseDef();
|
|
9273
|
+
init_parseTypes();
|
|
9274
|
+
init_any();
|
|
9275
|
+
init_array();
|
|
9276
|
+
init_bigint();
|
|
9277
|
+
init_branded();
|
|
9278
|
+
init_catch();
|
|
9279
|
+
init_date();
|
|
9280
|
+
init_default();
|
|
9281
|
+
init_effects();
|
|
9282
|
+
init_intersection();
|
|
9283
|
+
init_map();
|
|
9284
|
+
init_never();
|
|
9285
|
+
init_nullable();
|
|
9286
|
+
init_number();
|
|
9287
|
+
init_object();
|
|
9288
|
+
init_optional();
|
|
9289
|
+
init_pipeline();
|
|
9290
|
+
init_promise();
|
|
9291
|
+
init_readonly();
|
|
9292
|
+
init_record();
|
|
9293
|
+
init_set();
|
|
9294
|
+
init_string();
|
|
9295
|
+
init_tuple();
|
|
9296
|
+
init_undefined();
|
|
9297
|
+
init_union();
|
|
9298
|
+
init_unknown();
|
|
9299
|
+
init_selectParser();
|
|
9300
|
+
init_zodToJsonSchema();
|
|
9301
|
+
});
|
|
9302
|
+
|
|
7899
9303
|
// src/ai/openai.ts
|
|
7900
9304
|
function convertMCPToolToOpenAI(mcpTool, _client, options) {
|
|
7901
9305
|
const inputParams = mcpTool.inputSchema;
|
|
@@ -7923,7 +9327,10 @@ async function getOpenAITools(client, options) {
|
|
|
7923
9327
|
const triggerTools = createTriggerTools(triggerConfig, options?.context);
|
|
7924
9328
|
for (const [name, tool] of Object.entries(triggerTools)) {
|
|
7925
9329
|
const zodSchema = tool.inputSchema;
|
|
7926
|
-
const jsonSchema = zodToJsonSchema(zodSchema
|
|
9330
|
+
const jsonSchema = zodToJsonSchema(zodSchema, {
|
|
9331
|
+
target: "openApi3",
|
|
9332
|
+
$refStrategy: "none"
|
|
9333
|
+
});
|
|
7927
9334
|
openaiTools.push({
|
|
7928
9335
|
type: "function",
|
|
7929
9336
|
name,
|
|
@@ -7935,26 +9342,6 @@ async function getOpenAITools(client, options) {
|
|
|
7935
9342
|
}
|
|
7936
9343
|
return openaiTools;
|
|
7937
9344
|
}
|
|
7938
|
-
function zodToJsonSchema(schema) {
|
|
7939
|
-
if (schema._def?.typeName === "ZodObject") {
|
|
7940
|
-
const shape = schema._def.shape();
|
|
7941
|
-
const properties = {};
|
|
7942
|
-
const required = [];
|
|
7943
|
-
for (const [key, value] of Object.entries(shape)) {
|
|
7944
|
-
const fieldSchema = value;
|
|
7945
|
-
properties[key] = { type: "string" };
|
|
7946
|
-
if (fieldSchema._def?.typeName !== "ZodOptional") {
|
|
7947
|
-
required.push(key);
|
|
7948
|
-
}
|
|
7949
|
-
}
|
|
7950
|
-
return {
|
|
7951
|
-
type: "object",
|
|
7952
|
-
properties,
|
|
7953
|
-
...required.length > 0 ? { required } : {}
|
|
7954
|
-
};
|
|
7955
|
-
}
|
|
7956
|
-
return { type: "object" };
|
|
7957
|
-
}
|
|
7958
9345
|
async function handleOpenAIToolCalls(client, toolCalls, options) {
|
|
7959
9346
|
const toolOutputs = [];
|
|
7960
9347
|
const triggerConfig = client.__triggerConfig;
|
|
@@ -8010,6 +9397,7 @@ async function handleOpenAIResponse(client, response, options) {
|
|
|
8010
9397
|
var init_openai = __esm(() => {
|
|
8011
9398
|
init_utils();
|
|
8012
9399
|
init_trigger_tools();
|
|
9400
|
+
init_esm();
|
|
8013
9401
|
});
|
|
8014
9402
|
|
|
8015
9403
|
// src/ai/anthropic.ts
|
|
@@ -8071,7 +9459,10 @@ async function getAnthropicTools(client, options) {
|
|
|
8071
9459
|
const triggerTools = createTriggerTools(triggerConfig, options?.context);
|
|
8072
9460
|
for (const [name, tool] of Object.entries(triggerTools)) {
|
|
8073
9461
|
const zodSchema = tool.inputSchema;
|
|
8074
|
-
const jsonSchema =
|
|
9462
|
+
const jsonSchema = zodToJsonSchema(zodSchema, {
|
|
9463
|
+
target: "openApi3",
|
|
9464
|
+
$refStrategy: "none"
|
|
9465
|
+
});
|
|
8075
9466
|
anthropicTools.push({
|
|
8076
9467
|
name,
|
|
8077
9468
|
description: tool.description || `Execute ${name}`,
|
|
@@ -8081,26 +9472,6 @@ async function getAnthropicTools(client, options) {
|
|
|
8081
9472
|
}
|
|
8082
9473
|
return anthropicTools;
|
|
8083
9474
|
}
|
|
8084
|
-
function zodToAnthropicSchema(schema) {
|
|
8085
|
-
if (schema._def?.typeName === "ZodObject") {
|
|
8086
|
-
const shape = schema._def.shape();
|
|
8087
|
-
const properties = {};
|
|
8088
|
-
const required = [];
|
|
8089
|
-
for (const [key, value] of Object.entries(shape)) {
|
|
8090
|
-
const fieldSchema = value;
|
|
8091
|
-
properties[key] = { type: "string" };
|
|
8092
|
-
if (fieldSchema._def?.typeName !== "ZodOptional") {
|
|
8093
|
-
required.push(key);
|
|
8094
|
-
}
|
|
8095
|
-
}
|
|
8096
|
-
return {
|
|
8097
|
-
type: "object",
|
|
8098
|
-
properties,
|
|
8099
|
-
...required.length > 0 ? { required } : {}
|
|
8100
|
-
};
|
|
8101
|
-
}
|
|
8102
|
-
return { type: "object", properties: {}, required: [] };
|
|
8103
|
-
}
|
|
8104
9475
|
async function handleAnthropicMessage(client, message, options) {
|
|
8105
9476
|
let providerTokens = options?.providerTokens;
|
|
8106
9477
|
if (!providerTokens) {
|
|
@@ -8127,6 +9498,7 @@ async function handleAnthropicMessage(client, message, options) {
|
|
|
8127
9498
|
var init_anthropic = __esm(() => {
|
|
8128
9499
|
init_utils();
|
|
8129
9500
|
init_trigger_tools();
|
|
9501
|
+
init_esm();
|
|
8130
9502
|
});
|
|
8131
9503
|
|
|
8132
9504
|
// src/ai/google.ts
|
|
@@ -8243,39 +9615,78 @@ async function getGoogleTools(client, options) {
|
|
|
8243
9615
|
const TypeEnum = await getGoogleType();
|
|
8244
9616
|
for (const [name, tool] of Object.entries(triggerTools)) {
|
|
8245
9617
|
const zodSchema = tool.inputSchema;
|
|
8246
|
-
const jsonSchema =
|
|
9618
|
+
const jsonSchema = zodToJsonSchema(zodSchema, {
|
|
9619
|
+
target: "openApi3",
|
|
9620
|
+
$refStrategy: "none"
|
|
9621
|
+
});
|
|
9622
|
+
const googleSchema = convertJsonSchemaToGoogleSchema(jsonSchema, TypeEnum);
|
|
8247
9623
|
googleTools.push({
|
|
8248
9624
|
name,
|
|
8249
9625
|
description: tool.description || `Execute ${name}`,
|
|
8250
|
-
parameters:
|
|
9626
|
+
parameters: googleSchema
|
|
8251
9627
|
});
|
|
8252
9628
|
}
|
|
8253
9629
|
}
|
|
8254
9630
|
return googleTools;
|
|
8255
9631
|
}
|
|
8256
|
-
function
|
|
8257
|
-
|
|
8258
|
-
|
|
8259
|
-
|
|
8260
|
-
|
|
8261
|
-
|
|
8262
|
-
|
|
8263
|
-
|
|
8264
|
-
if (
|
|
8265
|
-
|
|
9632
|
+
function convertJsonSchemaToGoogleSchema(jsonSchema, TypeEnum) {
|
|
9633
|
+
const result = {
|
|
9634
|
+
type: TypeEnum.OBJECT
|
|
9635
|
+
};
|
|
9636
|
+
if (jsonSchema.properties) {
|
|
9637
|
+
const googleProperties = {};
|
|
9638
|
+
for (const [key, prop] of Object.entries(jsonSchema.properties)) {
|
|
9639
|
+
const googleProp = {};
|
|
9640
|
+
if (prop.type) {
|
|
9641
|
+
switch (prop.type) {
|
|
9642
|
+
case "string":
|
|
9643
|
+
googleProp.type = TypeEnum.STRING;
|
|
9644
|
+
break;
|
|
9645
|
+
case "number":
|
|
9646
|
+
googleProp.type = TypeEnum.NUMBER;
|
|
9647
|
+
break;
|
|
9648
|
+
case "integer":
|
|
9649
|
+
googleProp.type = TypeEnum.INTEGER;
|
|
9650
|
+
break;
|
|
9651
|
+
case "boolean":
|
|
9652
|
+
googleProp.type = TypeEnum.BOOLEAN;
|
|
9653
|
+
break;
|
|
9654
|
+
case "array":
|
|
9655
|
+
googleProp.type = TypeEnum.ARRAY;
|
|
9656
|
+
if (prop.items) {
|
|
9657
|
+
googleProp.items = convertJsonSchemaToGoogleSchema(prop.items, TypeEnum);
|
|
9658
|
+
}
|
|
9659
|
+
break;
|
|
9660
|
+
case "object":
|
|
9661
|
+
googleProp.type = TypeEnum.OBJECT;
|
|
9662
|
+
if (prop.properties) {
|
|
9663
|
+
googleProp.properties = Object.fromEntries(Object.entries(prop.properties).map(([k, v]) => [
|
|
9664
|
+
k,
|
|
9665
|
+
convertJsonSchemaToGoogleSchema(v, TypeEnum)
|
|
9666
|
+
]));
|
|
9667
|
+
}
|
|
9668
|
+
break;
|
|
9669
|
+
default:
|
|
9670
|
+
googleProp.type = TypeEnum.STRING;
|
|
9671
|
+
}
|
|
8266
9672
|
}
|
|
9673
|
+
if (prop.description)
|
|
9674
|
+
googleProp.description = prop.description;
|
|
9675
|
+
if (prop.enum)
|
|
9676
|
+
googleProp.enum = prop.enum;
|
|
9677
|
+
googleProperties[key] = googleProp;
|
|
8267
9678
|
}
|
|
8268
|
-
|
|
8269
|
-
|
|
8270
|
-
|
|
8271
|
-
|
|
8272
|
-
};
|
|
9679
|
+
result.properties = googleProperties;
|
|
9680
|
+
}
|
|
9681
|
+
if (jsonSchema.required && Array.isArray(jsonSchema.required)) {
|
|
9682
|
+
result.required = jsonSchema.required;
|
|
8273
9683
|
}
|
|
8274
|
-
return
|
|
9684
|
+
return result;
|
|
8275
9685
|
}
|
|
8276
9686
|
var init_google = __esm(() => {
|
|
8277
9687
|
init_utils();
|
|
8278
9688
|
init_trigger_tools();
|
|
9689
|
+
init_esm();
|
|
8279
9690
|
});
|
|
8280
9691
|
|
|
8281
9692
|
// src/ai/index.ts
|