integrate-sdk 0.8.39 → 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 +6 -5
- package/dist/adapters/base-handler.js +0 -561
- package/dist/ai/cloudflare.d.ts +0 -158
- package/dist/ai/cloudflare.d.ts.map +0 -1
- package/dist/ai/cloudflare.js +0 -4249
- package/dist/ai/langchain.d.ts +0 -139
- package/dist/ai/langchain.d.ts.map +0 -1
- package/dist/ai/langchain.js +0 -4237
- package/dist/ai/llamaindex.d.ts +0 -125
- package/dist/ai/llamaindex.d.ts.map +0 -1
- package/dist/ai/llamaindex.js +0 -4236
- package/dist/ai/mastra.d.ts +0 -138
- package/dist/ai/mastra.d.ts.map +0 -1
- package/dist/ai/mastra.js +0 -4240
- package/dist/src/ai/cloudflare.d.ts +0 -158
- package/dist/src/ai/cloudflare.d.ts.map +0 -1
- package/dist/src/ai/langchain.d.ts +0 -139
- package/dist/src/ai/langchain.d.ts.map +0 -1
- package/dist/src/ai/llamaindex.d.ts +0 -125
- package/dist/src/ai/llamaindex.d.ts.map +0 -1
- package/dist/src/ai/mastra.d.ts +0 -138
- package/dist/src/ai/mastra.d.ts.map +0 -1
- package/dist/src/integrations/vercel-ai.d.ts +0 -127
- package/dist/src/integrations/vercel-ai.d.ts.map +0 -1
- package/dist/src/plugins/generic.d.ts +0 -99
- package/dist/src/plugins/generic.d.ts.map +0 -1
- package/dist/src/plugins/github-client.d.ts +0 -320
- package/dist/src/plugins/github-client.d.ts.map +0 -1
- package/dist/src/plugins/github.d.ts +0 -89
- package/dist/src/plugins/github.d.ts.map +0 -1
- package/dist/src/plugins/gmail-client.d.ts +0 -106
- package/dist/src/plugins/gmail-client.d.ts.map +0 -1
- package/dist/src/plugins/gmail.d.ts +0 -87
- package/dist/src/plugins/gmail.d.ts.map +0 -1
- package/dist/src/plugins/server-client.d.ts +0 -18
- package/dist/src/plugins/server-client.d.ts.map +0 -1
- package/dist/src/plugins/types.d.ts +0 -70
- package/dist/src/plugins/types.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -8061,6 +8061,1410 @@ var init_vercel_ai = __esm(() => {
|
|
|
8061
8061
|
init_trigger_tools();
|
|
8062
8062
|
});
|
|
8063
8063
|
|
|
8064
|
+
// node_modules/zod-to-json-schema/dist/esm/Options.js
|
|
8065
|
+
var ignoreOverride, defaultOptions, getDefaultOptions = (options) => typeof options === "string" ? {
|
|
8066
|
+
...defaultOptions,
|
|
8067
|
+
name: options
|
|
8068
|
+
} : {
|
|
8069
|
+
...defaultOptions,
|
|
8070
|
+
...options
|
|
8071
|
+
};
|
|
8072
|
+
var init_Options = __esm(() => {
|
|
8073
|
+
ignoreOverride = Symbol("Let zodToJsonSchema decide on which parser to use");
|
|
8074
|
+
defaultOptions = {
|
|
8075
|
+
name: undefined,
|
|
8076
|
+
$refStrategy: "root",
|
|
8077
|
+
basePath: ["#"],
|
|
8078
|
+
effectStrategy: "input",
|
|
8079
|
+
pipeStrategy: "all",
|
|
8080
|
+
dateStrategy: "format:date-time",
|
|
8081
|
+
mapStrategy: "entries",
|
|
8082
|
+
removeAdditionalStrategy: "passthrough",
|
|
8083
|
+
allowedAdditionalProperties: true,
|
|
8084
|
+
rejectedAdditionalProperties: false,
|
|
8085
|
+
definitionPath: "definitions",
|
|
8086
|
+
target: "jsonSchema7",
|
|
8087
|
+
strictUnions: false,
|
|
8088
|
+
definitions: {},
|
|
8089
|
+
errorMessages: false,
|
|
8090
|
+
markdownDescription: false,
|
|
8091
|
+
patternStrategy: "escape",
|
|
8092
|
+
applyRegexFlags: false,
|
|
8093
|
+
emailStrategy: "format:email",
|
|
8094
|
+
base64Strategy: "contentEncoding:base64",
|
|
8095
|
+
nameStrategy: "ref",
|
|
8096
|
+
openAiAnyTypeName: "OpenAiAnyType"
|
|
8097
|
+
};
|
|
8098
|
+
});
|
|
8099
|
+
|
|
8100
|
+
// node_modules/zod-to-json-schema/dist/esm/Refs.js
|
|
8101
|
+
var getRefs = (options) => {
|
|
8102
|
+
const _options = getDefaultOptions(options);
|
|
8103
|
+
const currentPath = _options.name !== undefined ? [..._options.basePath, _options.definitionPath, _options.name] : _options.basePath;
|
|
8104
|
+
return {
|
|
8105
|
+
..._options,
|
|
8106
|
+
flags: { hasReferencedOpenAiAnyType: false },
|
|
8107
|
+
currentPath,
|
|
8108
|
+
propertyPath: undefined,
|
|
8109
|
+
seen: new Map(Object.entries(_options.definitions).map(([name, def]) => [
|
|
8110
|
+
def._def,
|
|
8111
|
+
{
|
|
8112
|
+
def: def._def,
|
|
8113
|
+
path: [..._options.basePath, _options.definitionPath, name],
|
|
8114
|
+
jsonSchema: undefined
|
|
8115
|
+
}
|
|
8116
|
+
]))
|
|
8117
|
+
};
|
|
8118
|
+
};
|
|
8119
|
+
var init_Refs = __esm(() => {
|
|
8120
|
+
init_Options();
|
|
8121
|
+
});
|
|
8122
|
+
|
|
8123
|
+
// node_modules/zod-to-json-schema/dist/esm/errorMessages.js
|
|
8124
|
+
function addErrorMessage(res, key, errorMessage, refs) {
|
|
8125
|
+
if (!refs?.errorMessages)
|
|
8126
|
+
return;
|
|
8127
|
+
if (errorMessage) {
|
|
8128
|
+
res.errorMessage = {
|
|
8129
|
+
...res.errorMessage,
|
|
8130
|
+
[key]: errorMessage
|
|
8131
|
+
};
|
|
8132
|
+
}
|
|
8133
|
+
}
|
|
8134
|
+
function setResponseValueAndErrors(res, key, value, errorMessage, refs) {
|
|
8135
|
+
res[key] = value;
|
|
8136
|
+
addErrorMessage(res, key, errorMessage, refs);
|
|
8137
|
+
}
|
|
8138
|
+
|
|
8139
|
+
// node_modules/zod-to-json-schema/dist/esm/getRelativePath.js
|
|
8140
|
+
var getRelativePath = (pathA, pathB) => {
|
|
8141
|
+
let i = 0;
|
|
8142
|
+
for (;i < pathA.length && i < pathB.length; i++) {
|
|
8143
|
+
if (pathA[i] !== pathB[i])
|
|
8144
|
+
break;
|
|
8145
|
+
}
|
|
8146
|
+
return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
|
|
8147
|
+
};
|
|
8148
|
+
|
|
8149
|
+
// node_modules/zod/v3/index.js
|
|
8150
|
+
var init_v3 = __esm(() => {
|
|
8151
|
+
init_external();
|
|
8152
|
+
});
|
|
8153
|
+
|
|
8154
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/any.js
|
|
8155
|
+
function parseAnyDef(refs) {
|
|
8156
|
+
if (refs.target !== "openAi") {
|
|
8157
|
+
return {};
|
|
8158
|
+
}
|
|
8159
|
+
const anyDefinitionPath = [
|
|
8160
|
+
...refs.basePath,
|
|
8161
|
+
refs.definitionPath,
|
|
8162
|
+
refs.openAiAnyTypeName
|
|
8163
|
+
];
|
|
8164
|
+
refs.flags.hasReferencedOpenAiAnyType = true;
|
|
8165
|
+
return {
|
|
8166
|
+
$ref: refs.$refStrategy === "relative" ? getRelativePath(anyDefinitionPath, refs.currentPath) : anyDefinitionPath.join("/")
|
|
8167
|
+
};
|
|
8168
|
+
}
|
|
8169
|
+
var init_any = () => {};
|
|
8170
|
+
|
|
8171
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/array.js
|
|
8172
|
+
function parseArrayDef(def, refs) {
|
|
8173
|
+
const res = {
|
|
8174
|
+
type: "array"
|
|
8175
|
+
};
|
|
8176
|
+
if (def.type?._def && def.type?._def?.typeName !== ZodFirstPartyTypeKind.ZodAny) {
|
|
8177
|
+
res.items = parseDef(def.type._def, {
|
|
8178
|
+
...refs,
|
|
8179
|
+
currentPath: [...refs.currentPath, "items"]
|
|
8180
|
+
});
|
|
8181
|
+
}
|
|
8182
|
+
if (def.minLength) {
|
|
8183
|
+
setResponseValueAndErrors(res, "minItems", def.minLength.value, def.minLength.message, refs);
|
|
8184
|
+
}
|
|
8185
|
+
if (def.maxLength) {
|
|
8186
|
+
setResponseValueAndErrors(res, "maxItems", def.maxLength.value, def.maxLength.message, refs);
|
|
8187
|
+
}
|
|
8188
|
+
if (def.exactLength) {
|
|
8189
|
+
setResponseValueAndErrors(res, "minItems", def.exactLength.value, def.exactLength.message, refs);
|
|
8190
|
+
setResponseValueAndErrors(res, "maxItems", def.exactLength.value, def.exactLength.message, refs);
|
|
8191
|
+
}
|
|
8192
|
+
return res;
|
|
8193
|
+
}
|
|
8194
|
+
var init_array = __esm(() => {
|
|
8195
|
+
init_v3();
|
|
8196
|
+
init_parseDef();
|
|
8197
|
+
});
|
|
8198
|
+
|
|
8199
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js
|
|
8200
|
+
function parseBigintDef(def, refs) {
|
|
8201
|
+
const res = {
|
|
8202
|
+
type: "integer",
|
|
8203
|
+
format: "int64"
|
|
8204
|
+
};
|
|
8205
|
+
if (!def.checks)
|
|
8206
|
+
return res;
|
|
8207
|
+
for (const check of def.checks) {
|
|
8208
|
+
switch (check.kind) {
|
|
8209
|
+
case "min":
|
|
8210
|
+
if (refs.target === "jsonSchema7") {
|
|
8211
|
+
if (check.inclusive) {
|
|
8212
|
+
setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
8213
|
+
} else {
|
|
8214
|
+
setResponseValueAndErrors(res, "exclusiveMinimum", check.value, check.message, refs);
|
|
8215
|
+
}
|
|
8216
|
+
} else {
|
|
8217
|
+
if (!check.inclusive) {
|
|
8218
|
+
res.exclusiveMinimum = true;
|
|
8219
|
+
}
|
|
8220
|
+
setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
8221
|
+
}
|
|
8222
|
+
break;
|
|
8223
|
+
case "max":
|
|
8224
|
+
if (refs.target === "jsonSchema7") {
|
|
8225
|
+
if (check.inclusive) {
|
|
8226
|
+
setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
8227
|
+
} else {
|
|
8228
|
+
setResponseValueAndErrors(res, "exclusiveMaximum", check.value, check.message, refs);
|
|
8229
|
+
}
|
|
8230
|
+
} else {
|
|
8231
|
+
if (!check.inclusive) {
|
|
8232
|
+
res.exclusiveMaximum = true;
|
|
8233
|
+
}
|
|
8234
|
+
setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
8235
|
+
}
|
|
8236
|
+
break;
|
|
8237
|
+
case "multipleOf":
|
|
8238
|
+
setResponseValueAndErrors(res, "multipleOf", check.value, check.message, refs);
|
|
8239
|
+
break;
|
|
8240
|
+
}
|
|
8241
|
+
}
|
|
8242
|
+
return res;
|
|
8243
|
+
}
|
|
8244
|
+
var init_bigint = () => {};
|
|
8245
|
+
|
|
8246
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js
|
|
8247
|
+
function parseBooleanDef() {
|
|
8248
|
+
return {
|
|
8249
|
+
type: "boolean"
|
|
8250
|
+
};
|
|
8251
|
+
}
|
|
8252
|
+
|
|
8253
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/branded.js
|
|
8254
|
+
function parseBrandedDef(_def, refs) {
|
|
8255
|
+
return parseDef(_def.type._def, refs);
|
|
8256
|
+
}
|
|
8257
|
+
var init_branded = __esm(() => {
|
|
8258
|
+
init_parseDef();
|
|
8259
|
+
});
|
|
8260
|
+
|
|
8261
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/catch.js
|
|
8262
|
+
var parseCatchDef = (def, refs) => {
|
|
8263
|
+
return parseDef(def.innerType._def, refs);
|
|
8264
|
+
};
|
|
8265
|
+
var init_catch = __esm(() => {
|
|
8266
|
+
init_parseDef();
|
|
8267
|
+
});
|
|
8268
|
+
|
|
8269
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/date.js
|
|
8270
|
+
function parseDateDef(def, refs, overrideDateStrategy) {
|
|
8271
|
+
const strategy = overrideDateStrategy ?? refs.dateStrategy;
|
|
8272
|
+
if (Array.isArray(strategy)) {
|
|
8273
|
+
return {
|
|
8274
|
+
anyOf: strategy.map((item, i) => parseDateDef(def, refs, item))
|
|
8275
|
+
};
|
|
8276
|
+
}
|
|
8277
|
+
switch (strategy) {
|
|
8278
|
+
case "string":
|
|
8279
|
+
case "format:date-time":
|
|
8280
|
+
return {
|
|
8281
|
+
type: "string",
|
|
8282
|
+
format: "date-time"
|
|
8283
|
+
};
|
|
8284
|
+
case "format:date":
|
|
8285
|
+
return {
|
|
8286
|
+
type: "string",
|
|
8287
|
+
format: "date"
|
|
8288
|
+
};
|
|
8289
|
+
case "integer":
|
|
8290
|
+
return integerDateParser(def, refs);
|
|
8291
|
+
}
|
|
8292
|
+
}
|
|
8293
|
+
var integerDateParser = (def, refs) => {
|
|
8294
|
+
const res = {
|
|
8295
|
+
type: "integer",
|
|
8296
|
+
format: "unix-time"
|
|
8297
|
+
};
|
|
8298
|
+
if (refs.target === "openApi3") {
|
|
8299
|
+
return res;
|
|
8300
|
+
}
|
|
8301
|
+
for (const check of def.checks) {
|
|
8302
|
+
switch (check.kind) {
|
|
8303
|
+
case "min":
|
|
8304
|
+
setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
8305
|
+
break;
|
|
8306
|
+
case "max":
|
|
8307
|
+
setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
8308
|
+
break;
|
|
8309
|
+
}
|
|
8310
|
+
}
|
|
8311
|
+
return res;
|
|
8312
|
+
};
|
|
8313
|
+
var init_date = () => {};
|
|
8314
|
+
|
|
8315
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/default.js
|
|
8316
|
+
function parseDefaultDef(_def, refs) {
|
|
8317
|
+
return {
|
|
8318
|
+
...parseDef(_def.innerType._def, refs),
|
|
8319
|
+
default: _def.defaultValue()
|
|
8320
|
+
};
|
|
8321
|
+
}
|
|
8322
|
+
var init_default = __esm(() => {
|
|
8323
|
+
init_parseDef();
|
|
8324
|
+
});
|
|
8325
|
+
|
|
8326
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/effects.js
|
|
8327
|
+
function parseEffectsDef(_def, refs) {
|
|
8328
|
+
return refs.effectStrategy === "input" ? parseDef(_def.schema._def, refs) : parseAnyDef(refs);
|
|
8329
|
+
}
|
|
8330
|
+
var init_effects = __esm(() => {
|
|
8331
|
+
init_parseDef();
|
|
8332
|
+
init_any();
|
|
8333
|
+
});
|
|
8334
|
+
|
|
8335
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/enum.js
|
|
8336
|
+
function parseEnumDef(def) {
|
|
8337
|
+
return {
|
|
8338
|
+
type: "string",
|
|
8339
|
+
enum: Array.from(def.values)
|
|
8340
|
+
};
|
|
8341
|
+
}
|
|
8342
|
+
|
|
8343
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js
|
|
8344
|
+
function parseIntersectionDef(def, refs) {
|
|
8345
|
+
const allOf = [
|
|
8346
|
+
parseDef(def.left._def, {
|
|
8347
|
+
...refs,
|
|
8348
|
+
currentPath: [...refs.currentPath, "allOf", "0"]
|
|
8349
|
+
}),
|
|
8350
|
+
parseDef(def.right._def, {
|
|
8351
|
+
...refs,
|
|
8352
|
+
currentPath: [...refs.currentPath, "allOf", "1"]
|
|
8353
|
+
})
|
|
8354
|
+
].filter((x) => !!x);
|
|
8355
|
+
let unevaluatedProperties = refs.target === "jsonSchema2019-09" ? { unevaluatedProperties: false } : undefined;
|
|
8356
|
+
const mergedAllOf = [];
|
|
8357
|
+
allOf.forEach((schema) => {
|
|
8358
|
+
if (isJsonSchema7AllOfType(schema)) {
|
|
8359
|
+
mergedAllOf.push(...schema.allOf);
|
|
8360
|
+
if (schema.unevaluatedProperties === undefined) {
|
|
8361
|
+
unevaluatedProperties = undefined;
|
|
8362
|
+
}
|
|
8363
|
+
} else {
|
|
8364
|
+
let nestedSchema = schema;
|
|
8365
|
+
if ("additionalProperties" in schema && schema.additionalProperties === false) {
|
|
8366
|
+
const { additionalProperties, ...rest } = schema;
|
|
8367
|
+
nestedSchema = rest;
|
|
8368
|
+
} else {
|
|
8369
|
+
unevaluatedProperties = undefined;
|
|
8370
|
+
}
|
|
8371
|
+
mergedAllOf.push(nestedSchema);
|
|
8372
|
+
}
|
|
8373
|
+
});
|
|
8374
|
+
return mergedAllOf.length ? {
|
|
8375
|
+
allOf: mergedAllOf,
|
|
8376
|
+
...unevaluatedProperties
|
|
8377
|
+
} : undefined;
|
|
8378
|
+
}
|
|
8379
|
+
var isJsonSchema7AllOfType = (type) => {
|
|
8380
|
+
if ("type" in type && type.type === "string")
|
|
8381
|
+
return false;
|
|
8382
|
+
return "allOf" in type;
|
|
8383
|
+
};
|
|
8384
|
+
var init_intersection = __esm(() => {
|
|
8385
|
+
init_parseDef();
|
|
8386
|
+
});
|
|
8387
|
+
|
|
8388
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/literal.js
|
|
8389
|
+
function parseLiteralDef(def, refs) {
|
|
8390
|
+
const parsedType = typeof def.value;
|
|
8391
|
+
if (parsedType !== "bigint" && parsedType !== "number" && parsedType !== "boolean" && parsedType !== "string") {
|
|
8392
|
+
return {
|
|
8393
|
+
type: Array.isArray(def.value) ? "array" : "object"
|
|
8394
|
+
};
|
|
8395
|
+
}
|
|
8396
|
+
if (refs.target === "openApi3") {
|
|
8397
|
+
return {
|
|
8398
|
+
type: parsedType === "bigint" ? "integer" : parsedType,
|
|
8399
|
+
enum: [def.value]
|
|
8400
|
+
};
|
|
8401
|
+
}
|
|
8402
|
+
return {
|
|
8403
|
+
type: parsedType === "bigint" ? "integer" : parsedType,
|
|
8404
|
+
const: def.value
|
|
8405
|
+
};
|
|
8406
|
+
}
|
|
8407
|
+
|
|
8408
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/string.js
|
|
8409
|
+
function parseStringDef(def, refs) {
|
|
8410
|
+
const res = {
|
|
8411
|
+
type: "string"
|
|
8412
|
+
};
|
|
8413
|
+
if (def.checks) {
|
|
8414
|
+
for (const check of def.checks) {
|
|
8415
|
+
switch (check.kind) {
|
|
8416
|
+
case "min":
|
|
8417
|
+
setResponseValueAndErrors(res, "minLength", typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value, check.message, refs);
|
|
8418
|
+
break;
|
|
8419
|
+
case "max":
|
|
8420
|
+
setResponseValueAndErrors(res, "maxLength", typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);
|
|
8421
|
+
break;
|
|
8422
|
+
case "email":
|
|
8423
|
+
switch (refs.emailStrategy) {
|
|
8424
|
+
case "format:email":
|
|
8425
|
+
addFormat(res, "email", check.message, refs);
|
|
8426
|
+
break;
|
|
8427
|
+
case "format:idn-email":
|
|
8428
|
+
addFormat(res, "idn-email", check.message, refs);
|
|
8429
|
+
break;
|
|
8430
|
+
case "pattern:zod":
|
|
8431
|
+
addPattern(res, zodPatterns.email, check.message, refs);
|
|
8432
|
+
break;
|
|
8433
|
+
}
|
|
8434
|
+
break;
|
|
8435
|
+
case "url":
|
|
8436
|
+
addFormat(res, "uri", check.message, refs);
|
|
8437
|
+
break;
|
|
8438
|
+
case "uuid":
|
|
8439
|
+
addFormat(res, "uuid", check.message, refs);
|
|
8440
|
+
break;
|
|
8441
|
+
case "regex":
|
|
8442
|
+
addPattern(res, check.regex, check.message, refs);
|
|
8443
|
+
break;
|
|
8444
|
+
case "cuid":
|
|
8445
|
+
addPattern(res, zodPatterns.cuid, check.message, refs);
|
|
8446
|
+
break;
|
|
8447
|
+
case "cuid2":
|
|
8448
|
+
addPattern(res, zodPatterns.cuid2, check.message, refs);
|
|
8449
|
+
break;
|
|
8450
|
+
case "startsWith":
|
|
8451
|
+
addPattern(res, RegExp(`^${escapeLiteralCheckValue(check.value, refs)}`), check.message, refs);
|
|
8452
|
+
break;
|
|
8453
|
+
case "endsWith":
|
|
8454
|
+
addPattern(res, RegExp(`${escapeLiteralCheckValue(check.value, refs)}$`), check.message, refs);
|
|
8455
|
+
break;
|
|
8456
|
+
case "datetime":
|
|
8457
|
+
addFormat(res, "date-time", check.message, refs);
|
|
8458
|
+
break;
|
|
8459
|
+
case "date":
|
|
8460
|
+
addFormat(res, "date", check.message, refs);
|
|
8461
|
+
break;
|
|
8462
|
+
case "time":
|
|
8463
|
+
addFormat(res, "time", check.message, refs);
|
|
8464
|
+
break;
|
|
8465
|
+
case "duration":
|
|
8466
|
+
addFormat(res, "duration", check.message, refs);
|
|
8467
|
+
break;
|
|
8468
|
+
case "length":
|
|
8469
|
+
setResponseValueAndErrors(res, "minLength", typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value, check.message, refs);
|
|
8470
|
+
setResponseValueAndErrors(res, "maxLength", typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);
|
|
8471
|
+
break;
|
|
8472
|
+
case "includes": {
|
|
8473
|
+
addPattern(res, RegExp(escapeLiteralCheckValue(check.value, refs)), check.message, refs);
|
|
8474
|
+
break;
|
|
8475
|
+
}
|
|
8476
|
+
case "ip": {
|
|
8477
|
+
if (check.version !== "v6") {
|
|
8478
|
+
addFormat(res, "ipv4", check.message, refs);
|
|
8479
|
+
}
|
|
8480
|
+
if (check.version !== "v4") {
|
|
8481
|
+
addFormat(res, "ipv6", check.message, refs);
|
|
8482
|
+
}
|
|
8483
|
+
break;
|
|
8484
|
+
}
|
|
8485
|
+
case "base64url":
|
|
8486
|
+
addPattern(res, zodPatterns.base64url, check.message, refs);
|
|
8487
|
+
break;
|
|
8488
|
+
case "jwt":
|
|
8489
|
+
addPattern(res, zodPatterns.jwt, check.message, refs);
|
|
8490
|
+
break;
|
|
8491
|
+
case "cidr": {
|
|
8492
|
+
if (check.version !== "v6") {
|
|
8493
|
+
addPattern(res, zodPatterns.ipv4Cidr, check.message, refs);
|
|
8494
|
+
}
|
|
8495
|
+
if (check.version !== "v4") {
|
|
8496
|
+
addPattern(res, zodPatterns.ipv6Cidr, check.message, refs);
|
|
8497
|
+
}
|
|
8498
|
+
break;
|
|
8499
|
+
}
|
|
8500
|
+
case "emoji":
|
|
8501
|
+
addPattern(res, zodPatterns.emoji(), check.message, refs);
|
|
8502
|
+
break;
|
|
8503
|
+
case "ulid": {
|
|
8504
|
+
addPattern(res, zodPatterns.ulid, check.message, refs);
|
|
8505
|
+
break;
|
|
8506
|
+
}
|
|
8507
|
+
case "base64": {
|
|
8508
|
+
switch (refs.base64Strategy) {
|
|
8509
|
+
case "format:binary": {
|
|
8510
|
+
addFormat(res, "binary", check.message, refs);
|
|
8511
|
+
break;
|
|
8512
|
+
}
|
|
8513
|
+
case "contentEncoding:base64": {
|
|
8514
|
+
setResponseValueAndErrors(res, "contentEncoding", "base64", check.message, refs);
|
|
8515
|
+
break;
|
|
8516
|
+
}
|
|
8517
|
+
case "pattern:zod": {
|
|
8518
|
+
addPattern(res, zodPatterns.base64, check.message, refs);
|
|
8519
|
+
break;
|
|
8520
|
+
}
|
|
8521
|
+
}
|
|
8522
|
+
break;
|
|
8523
|
+
}
|
|
8524
|
+
case "nanoid": {
|
|
8525
|
+
addPattern(res, zodPatterns.nanoid, check.message, refs);
|
|
8526
|
+
}
|
|
8527
|
+
case "toLowerCase":
|
|
8528
|
+
case "toUpperCase":
|
|
8529
|
+
case "trim":
|
|
8530
|
+
break;
|
|
8531
|
+
default:
|
|
8532
|
+
((_) => {})(check);
|
|
8533
|
+
}
|
|
8534
|
+
}
|
|
8535
|
+
}
|
|
8536
|
+
return res;
|
|
8537
|
+
}
|
|
8538
|
+
function escapeLiteralCheckValue(literal, refs) {
|
|
8539
|
+
return refs.patternStrategy === "escape" ? escapeNonAlphaNumeric(literal) : literal;
|
|
8540
|
+
}
|
|
8541
|
+
function escapeNonAlphaNumeric(source) {
|
|
8542
|
+
let result = "";
|
|
8543
|
+
for (let i = 0;i < source.length; i++) {
|
|
8544
|
+
if (!ALPHA_NUMERIC.has(source[i])) {
|
|
8545
|
+
result += "\\";
|
|
8546
|
+
}
|
|
8547
|
+
result += source[i];
|
|
8548
|
+
}
|
|
8549
|
+
return result;
|
|
8550
|
+
}
|
|
8551
|
+
function addFormat(schema, value, message, refs) {
|
|
8552
|
+
if (schema.format || schema.anyOf?.some((x) => x.format)) {
|
|
8553
|
+
if (!schema.anyOf) {
|
|
8554
|
+
schema.anyOf = [];
|
|
8555
|
+
}
|
|
8556
|
+
if (schema.format) {
|
|
8557
|
+
schema.anyOf.push({
|
|
8558
|
+
format: schema.format,
|
|
8559
|
+
...schema.errorMessage && refs.errorMessages && {
|
|
8560
|
+
errorMessage: { format: schema.errorMessage.format }
|
|
8561
|
+
}
|
|
8562
|
+
});
|
|
8563
|
+
delete schema.format;
|
|
8564
|
+
if (schema.errorMessage) {
|
|
8565
|
+
delete schema.errorMessage.format;
|
|
8566
|
+
if (Object.keys(schema.errorMessage).length === 0) {
|
|
8567
|
+
delete schema.errorMessage;
|
|
8568
|
+
}
|
|
8569
|
+
}
|
|
8570
|
+
}
|
|
8571
|
+
schema.anyOf.push({
|
|
8572
|
+
format: value,
|
|
8573
|
+
...message && refs.errorMessages && { errorMessage: { format: message } }
|
|
8574
|
+
});
|
|
8575
|
+
} else {
|
|
8576
|
+
setResponseValueAndErrors(schema, "format", value, message, refs);
|
|
8577
|
+
}
|
|
8578
|
+
}
|
|
8579
|
+
function addPattern(schema, regex, message, refs) {
|
|
8580
|
+
if (schema.pattern || schema.allOf?.some((x) => x.pattern)) {
|
|
8581
|
+
if (!schema.allOf) {
|
|
8582
|
+
schema.allOf = [];
|
|
8583
|
+
}
|
|
8584
|
+
if (schema.pattern) {
|
|
8585
|
+
schema.allOf.push({
|
|
8586
|
+
pattern: schema.pattern,
|
|
8587
|
+
...schema.errorMessage && refs.errorMessages && {
|
|
8588
|
+
errorMessage: { pattern: schema.errorMessage.pattern }
|
|
8589
|
+
}
|
|
8590
|
+
});
|
|
8591
|
+
delete schema.pattern;
|
|
8592
|
+
if (schema.errorMessage) {
|
|
8593
|
+
delete schema.errorMessage.pattern;
|
|
8594
|
+
if (Object.keys(schema.errorMessage).length === 0) {
|
|
8595
|
+
delete schema.errorMessage;
|
|
8596
|
+
}
|
|
8597
|
+
}
|
|
8598
|
+
}
|
|
8599
|
+
schema.allOf.push({
|
|
8600
|
+
pattern: stringifyRegExpWithFlags(regex, refs),
|
|
8601
|
+
...message && refs.errorMessages && { errorMessage: { pattern: message } }
|
|
8602
|
+
});
|
|
8603
|
+
} else {
|
|
8604
|
+
setResponseValueAndErrors(schema, "pattern", stringifyRegExpWithFlags(regex, refs), message, refs);
|
|
8605
|
+
}
|
|
8606
|
+
}
|
|
8607
|
+
function stringifyRegExpWithFlags(regex, refs) {
|
|
8608
|
+
if (!refs.applyRegexFlags || !regex.flags) {
|
|
8609
|
+
return regex.source;
|
|
8610
|
+
}
|
|
8611
|
+
const flags = {
|
|
8612
|
+
i: regex.flags.includes("i"),
|
|
8613
|
+
m: regex.flags.includes("m"),
|
|
8614
|
+
s: regex.flags.includes("s")
|
|
8615
|
+
};
|
|
8616
|
+
const source = flags.i ? regex.source.toLowerCase() : regex.source;
|
|
8617
|
+
let pattern = "";
|
|
8618
|
+
let isEscaped = false;
|
|
8619
|
+
let inCharGroup = false;
|
|
8620
|
+
let inCharRange = false;
|
|
8621
|
+
for (let i = 0;i < source.length; i++) {
|
|
8622
|
+
if (isEscaped) {
|
|
8623
|
+
pattern += source[i];
|
|
8624
|
+
isEscaped = false;
|
|
8625
|
+
continue;
|
|
8626
|
+
}
|
|
8627
|
+
if (flags.i) {
|
|
8628
|
+
if (inCharGroup) {
|
|
8629
|
+
if (source[i].match(/[a-z]/)) {
|
|
8630
|
+
if (inCharRange) {
|
|
8631
|
+
pattern += source[i];
|
|
8632
|
+
pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
|
|
8633
|
+
inCharRange = false;
|
|
8634
|
+
} else if (source[i + 1] === "-" && source[i + 2]?.match(/[a-z]/)) {
|
|
8635
|
+
pattern += source[i];
|
|
8636
|
+
inCharRange = true;
|
|
8637
|
+
} else {
|
|
8638
|
+
pattern += `${source[i]}${source[i].toUpperCase()}`;
|
|
8639
|
+
}
|
|
8640
|
+
continue;
|
|
8641
|
+
}
|
|
8642
|
+
} else if (source[i].match(/[a-z]/)) {
|
|
8643
|
+
pattern += `[${source[i]}${source[i].toUpperCase()}]`;
|
|
8644
|
+
continue;
|
|
8645
|
+
}
|
|
8646
|
+
}
|
|
8647
|
+
if (flags.m) {
|
|
8648
|
+
if (source[i] === "^") {
|
|
8649
|
+
pattern += `(^|(?<=[\r
|
|
8650
|
+
]))`;
|
|
8651
|
+
continue;
|
|
8652
|
+
} else if (source[i] === "$") {
|
|
8653
|
+
pattern += `($|(?=[\r
|
|
8654
|
+
]))`;
|
|
8655
|
+
continue;
|
|
8656
|
+
}
|
|
8657
|
+
}
|
|
8658
|
+
if (flags.s && source[i] === ".") {
|
|
8659
|
+
pattern += inCharGroup ? `${source[i]}\r
|
|
8660
|
+
` : `[${source[i]}\r
|
|
8661
|
+
]`;
|
|
8662
|
+
continue;
|
|
8663
|
+
}
|
|
8664
|
+
pattern += source[i];
|
|
8665
|
+
if (source[i] === "\\") {
|
|
8666
|
+
isEscaped = true;
|
|
8667
|
+
} else if (inCharGroup && source[i] === "]") {
|
|
8668
|
+
inCharGroup = false;
|
|
8669
|
+
} else if (!inCharGroup && source[i] === "[") {
|
|
8670
|
+
inCharGroup = true;
|
|
8671
|
+
}
|
|
8672
|
+
}
|
|
8673
|
+
try {
|
|
8674
|
+
new RegExp(pattern);
|
|
8675
|
+
} catch {
|
|
8676
|
+
console.warn(`Could not convert regex pattern at ${refs.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`);
|
|
8677
|
+
return regex.source;
|
|
8678
|
+
}
|
|
8679
|
+
return pattern;
|
|
8680
|
+
}
|
|
8681
|
+
var emojiRegex2 = undefined, zodPatterns, ALPHA_NUMERIC;
|
|
8682
|
+
var init_string = __esm(() => {
|
|
8683
|
+
zodPatterns = {
|
|
8684
|
+
cuid: /^[cC][^\s-]{8,}$/,
|
|
8685
|
+
cuid2: /^[0-9a-z]+$/,
|
|
8686
|
+
ulid: /^[0-9A-HJKMNP-TV-Z]{26}$/,
|
|
8687
|
+
email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,
|
|
8688
|
+
emoji: () => {
|
|
8689
|
+
if (emojiRegex2 === undefined) {
|
|
8690
|
+
emojiRegex2 = RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u");
|
|
8691
|
+
}
|
|
8692
|
+
return emojiRegex2;
|
|
8693
|
+
},
|
|
8694
|
+
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}$/,
|
|
8695
|
+
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])$/,
|
|
8696
|
+
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])$/,
|
|
8697
|
+
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})))$/,
|
|
8698
|
+
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])$/,
|
|
8699
|
+
base64: /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,
|
|
8700
|
+
base64url: /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,
|
|
8701
|
+
nanoid: /^[a-zA-Z0-9_-]{21}$/,
|
|
8702
|
+
jwt: /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/
|
|
8703
|
+
};
|
|
8704
|
+
ALPHA_NUMERIC = new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
|
|
8705
|
+
});
|
|
8706
|
+
|
|
8707
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/record.js
|
|
8708
|
+
function parseRecordDef(def, refs) {
|
|
8709
|
+
if (refs.target === "openAi") {
|
|
8710
|
+
console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.");
|
|
8711
|
+
}
|
|
8712
|
+
if (refs.target === "openApi3" && def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodEnum) {
|
|
8713
|
+
return {
|
|
8714
|
+
type: "object",
|
|
8715
|
+
required: def.keyType._def.values,
|
|
8716
|
+
properties: def.keyType._def.values.reduce((acc, key) => ({
|
|
8717
|
+
...acc,
|
|
8718
|
+
[key]: parseDef(def.valueType._def, {
|
|
8719
|
+
...refs,
|
|
8720
|
+
currentPath: [...refs.currentPath, "properties", key]
|
|
8721
|
+
}) ?? parseAnyDef(refs)
|
|
8722
|
+
}), {}),
|
|
8723
|
+
additionalProperties: refs.rejectedAdditionalProperties
|
|
8724
|
+
};
|
|
8725
|
+
}
|
|
8726
|
+
const schema = {
|
|
8727
|
+
type: "object",
|
|
8728
|
+
additionalProperties: parseDef(def.valueType._def, {
|
|
8729
|
+
...refs,
|
|
8730
|
+
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
8731
|
+
}) ?? refs.allowedAdditionalProperties
|
|
8732
|
+
};
|
|
8733
|
+
if (refs.target === "openApi3") {
|
|
8734
|
+
return schema;
|
|
8735
|
+
}
|
|
8736
|
+
if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodString && def.keyType._def.checks?.length) {
|
|
8737
|
+
const { type, ...keyType } = parseStringDef(def.keyType._def, refs);
|
|
8738
|
+
return {
|
|
8739
|
+
...schema,
|
|
8740
|
+
propertyNames: keyType
|
|
8741
|
+
};
|
|
8742
|
+
} else if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodEnum) {
|
|
8743
|
+
return {
|
|
8744
|
+
...schema,
|
|
8745
|
+
propertyNames: {
|
|
8746
|
+
enum: def.keyType._def.values
|
|
8747
|
+
}
|
|
8748
|
+
};
|
|
8749
|
+
} else if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodBranded && def.keyType._def.type._def.typeName === ZodFirstPartyTypeKind.ZodString && def.keyType._def.type._def.checks?.length) {
|
|
8750
|
+
const { type, ...keyType } = parseBrandedDef(def.keyType._def, refs);
|
|
8751
|
+
return {
|
|
8752
|
+
...schema,
|
|
8753
|
+
propertyNames: keyType
|
|
8754
|
+
};
|
|
8755
|
+
}
|
|
8756
|
+
return schema;
|
|
8757
|
+
}
|
|
8758
|
+
var init_record = __esm(() => {
|
|
8759
|
+
init_v3();
|
|
8760
|
+
init_parseDef();
|
|
8761
|
+
init_string();
|
|
8762
|
+
init_branded();
|
|
8763
|
+
init_any();
|
|
8764
|
+
});
|
|
8765
|
+
|
|
8766
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/map.js
|
|
8767
|
+
function parseMapDef(def, refs) {
|
|
8768
|
+
if (refs.mapStrategy === "record") {
|
|
8769
|
+
return parseRecordDef(def, refs);
|
|
8770
|
+
}
|
|
8771
|
+
const keys = parseDef(def.keyType._def, {
|
|
8772
|
+
...refs,
|
|
8773
|
+
currentPath: [...refs.currentPath, "items", "items", "0"]
|
|
8774
|
+
}) || parseAnyDef(refs);
|
|
8775
|
+
const values = parseDef(def.valueType._def, {
|
|
8776
|
+
...refs,
|
|
8777
|
+
currentPath: [...refs.currentPath, "items", "items", "1"]
|
|
8778
|
+
}) || parseAnyDef(refs);
|
|
8779
|
+
return {
|
|
8780
|
+
type: "array",
|
|
8781
|
+
maxItems: 125,
|
|
8782
|
+
items: {
|
|
8783
|
+
type: "array",
|
|
8784
|
+
items: [keys, values],
|
|
8785
|
+
minItems: 2,
|
|
8786
|
+
maxItems: 2
|
|
8787
|
+
}
|
|
8788
|
+
};
|
|
8789
|
+
}
|
|
8790
|
+
var init_map = __esm(() => {
|
|
8791
|
+
init_parseDef();
|
|
8792
|
+
init_record();
|
|
8793
|
+
init_any();
|
|
8794
|
+
});
|
|
8795
|
+
|
|
8796
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js
|
|
8797
|
+
function parseNativeEnumDef(def) {
|
|
8798
|
+
const object = def.values;
|
|
8799
|
+
const actualKeys = Object.keys(def.values).filter((key) => {
|
|
8800
|
+
return typeof object[object[key]] !== "number";
|
|
8801
|
+
});
|
|
8802
|
+
const actualValues = actualKeys.map((key) => object[key]);
|
|
8803
|
+
const parsedTypes = Array.from(new Set(actualValues.map((values) => typeof values)));
|
|
8804
|
+
return {
|
|
8805
|
+
type: parsedTypes.length === 1 ? parsedTypes[0] === "string" ? "string" : "number" : ["string", "number"],
|
|
8806
|
+
enum: actualValues
|
|
8807
|
+
};
|
|
8808
|
+
}
|
|
8809
|
+
|
|
8810
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/never.js
|
|
8811
|
+
function parseNeverDef(refs) {
|
|
8812
|
+
return refs.target === "openAi" ? undefined : {
|
|
8813
|
+
not: parseAnyDef({
|
|
8814
|
+
...refs,
|
|
8815
|
+
currentPath: [...refs.currentPath, "not"]
|
|
8816
|
+
})
|
|
8817
|
+
};
|
|
8818
|
+
}
|
|
8819
|
+
var init_never = __esm(() => {
|
|
8820
|
+
init_any();
|
|
8821
|
+
});
|
|
8822
|
+
|
|
8823
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/null.js
|
|
8824
|
+
function parseNullDef(refs) {
|
|
8825
|
+
return refs.target === "openApi3" ? {
|
|
8826
|
+
enum: ["null"],
|
|
8827
|
+
nullable: true
|
|
8828
|
+
} : {
|
|
8829
|
+
type: "null"
|
|
8830
|
+
};
|
|
8831
|
+
}
|
|
8832
|
+
|
|
8833
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/union.js
|
|
8834
|
+
function parseUnionDef(def, refs) {
|
|
8835
|
+
if (refs.target === "openApi3")
|
|
8836
|
+
return asAnyOf(def, refs);
|
|
8837
|
+
const options = def.options instanceof Map ? Array.from(def.options.values()) : def.options;
|
|
8838
|
+
if (options.every((x) => (x._def.typeName in primitiveMappings) && (!x._def.checks || !x._def.checks.length))) {
|
|
8839
|
+
const types2 = options.reduce((types3, x) => {
|
|
8840
|
+
const type = primitiveMappings[x._def.typeName];
|
|
8841
|
+
return type && !types3.includes(type) ? [...types3, type] : types3;
|
|
8842
|
+
}, []);
|
|
8843
|
+
return {
|
|
8844
|
+
type: types2.length > 1 ? types2 : types2[0]
|
|
8845
|
+
};
|
|
8846
|
+
} else if (options.every((x) => x._def.typeName === "ZodLiteral" && !x.description)) {
|
|
8847
|
+
const types2 = options.reduce((acc, x) => {
|
|
8848
|
+
const type = typeof x._def.value;
|
|
8849
|
+
switch (type) {
|
|
8850
|
+
case "string":
|
|
8851
|
+
case "number":
|
|
8852
|
+
case "boolean":
|
|
8853
|
+
return [...acc, type];
|
|
8854
|
+
case "bigint":
|
|
8855
|
+
return [...acc, "integer"];
|
|
8856
|
+
case "object":
|
|
8857
|
+
if (x._def.value === null)
|
|
8858
|
+
return [...acc, "null"];
|
|
8859
|
+
case "symbol":
|
|
8860
|
+
case "undefined":
|
|
8861
|
+
case "function":
|
|
8862
|
+
default:
|
|
8863
|
+
return acc;
|
|
8864
|
+
}
|
|
8865
|
+
}, []);
|
|
8866
|
+
if (types2.length === options.length) {
|
|
8867
|
+
const uniqueTypes = types2.filter((x, i, a) => a.indexOf(x) === i);
|
|
8868
|
+
return {
|
|
8869
|
+
type: uniqueTypes.length > 1 ? uniqueTypes : uniqueTypes[0],
|
|
8870
|
+
enum: options.reduce((acc, x) => {
|
|
8871
|
+
return acc.includes(x._def.value) ? acc : [...acc, x._def.value];
|
|
8872
|
+
}, [])
|
|
8873
|
+
};
|
|
8874
|
+
}
|
|
8875
|
+
} else if (options.every((x) => x._def.typeName === "ZodEnum")) {
|
|
8876
|
+
return {
|
|
8877
|
+
type: "string",
|
|
8878
|
+
enum: options.reduce((acc, x) => [
|
|
8879
|
+
...acc,
|
|
8880
|
+
...x._def.values.filter((x2) => !acc.includes(x2))
|
|
8881
|
+
], [])
|
|
8882
|
+
};
|
|
8883
|
+
}
|
|
8884
|
+
return asAnyOf(def, refs);
|
|
8885
|
+
}
|
|
8886
|
+
var primitiveMappings, asAnyOf = (def, refs) => {
|
|
8887
|
+
const anyOf = (def.options instanceof Map ? Array.from(def.options.values()) : def.options).map((x, i) => parseDef(x._def, {
|
|
8888
|
+
...refs,
|
|
8889
|
+
currentPath: [...refs.currentPath, "anyOf", `${i}`]
|
|
8890
|
+
})).filter((x) => !!x && (!refs.strictUnions || typeof x === "object" && Object.keys(x).length > 0));
|
|
8891
|
+
return anyOf.length ? { anyOf } : undefined;
|
|
8892
|
+
};
|
|
8893
|
+
var init_union = __esm(() => {
|
|
8894
|
+
init_parseDef();
|
|
8895
|
+
primitiveMappings = {
|
|
8896
|
+
ZodString: "string",
|
|
8897
|
+
ZodNumber: "number",
|
|
8898
|
+
ZodBigInt: "integer",
|
|
8899
|
+
ZodBoolean: "boolean",
|
|
8900
|
+
ZodNull: "null"
|
|
8901
|
+
};
|
|
8902
|
+
});
|
|
8903
|
+
|
|
8904
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js
|
|
8905
|
+
function parseNullableDef(def, refs) {
|
|
8906
|
+
if (["ZodString", "ZodNumber", "ZodBigInt", "ZodBoolean", "ZodNull"].includes(def.innerType._def.typeName) && (!def.innerType._def.checks || !def.innerType._def.checks.length)) {
|
|
8907
|
+
if (refs.target === "openApi3") {
|
|
8908
|
+
return {
|
|
8909
|
+
type: primitiveMappings[def.innerType._def.typeName],
|
|
8910
|
+
nullable: true
|
|
8911
|
+
};
|
|
8912
|
+
}
|
|
8913
|
+
return {
|
|
8914
|
+
type: [
|
|
8915
|
+
primitiveMappings[def.innerType._def.typeName],
|
|
8916
|
+
"null"
|
|
8917
|
+
]
|
|
8918
|
+
};
|
|
8919
|
+
}
|
|
8920
|
+
if (refs.target === "openApi3") {
|
|
8921
|
+
const base2 = parseDef(def.innerType._def, {
|
|
8922
|
+
...refs,
|
|
8923
|
+
currentPath: [...refs.currentPath]
|
|
8924
|
+
});
|
|
8925
|
+
if (base2 && "$ref" in base2)
|
|
8926
|
+
return { allOf: [base2], nullable: true };
|
|
8927
|
+
return base2 && { ...base2, nullable: true };
|
|
8928
|
+
}
|
|
8929
|
+
const base = parseDef(def.innerType._def, {
|
|
8930
|
+
...refs,
|
|
8931
|
+
currentPath: [...refs.currentPath, "anyOf", "0"]
|
|
8932
|
+
});
|
|
8933
|
+
return base && { anyOf: [base, { type: "null" }] };
|
|
8934
|
+
}
|
|
8935
|
+
var init_nullable = __esm(() => {
|
|
8936
|
+
init_parseDef();
|
|
8937
|
+
init_union();
|
|
8938
|
+
});
|
|
8939
|
+
|
|
8940
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/number.js
|
|
8941
|
+
function parseNumberDef(def, refs) {
|
|
8942
|
+
const res = {
|
|
8943
|
+
type: "number"
|
|
8944
|
+
};
|
|
8945
|
+
if (!def.checks)
|
|
8946
|
+
return res;
|
|
8947
|
+
for (const check of def.checks) {
|
|
8948
|
+
switch (check.kind) {
|
|
8949
|
+
case "int":
|
|
8950
|
+
res.type = "integer";
|
|
8951
|
+
addErrorMessage(res, "type", check.message, refs);
|
|
8952
|
+
break;
|
|
8953
|
+
case "min":
|
|
8954
|
+
if (refs.target === "jsonSchema7") {
|
|
8955
|
+
if (check.inclusive) {
|
|
8956
|
+
setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
8957
|
+
} else {
|
|
8958
|
+
setResponseValueAndErrors(res, "exclusiveMinimum", check.value, check.message, refs);
|
|
8959
|
+
}
|
|
8960
|
+
} else {
|
|
8961
|
+
if (!check.inclusive) {
|
|
8962
|
+
res.exclusiveMinimum = true;
|
|
8963
|
+
}
|
|
8964
|
+
setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
8965
|
+
}
|
|
8966
|
+
break;
|
|
8967
|
+
case "max":
|
|
8968
|
+
if (refs.target === "jsonSchema7") {
|
|
8969
|
+
if (check.inclusive) {
|
|
8970
|
+
setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
8971
|
+
} else {
|
|
8972
|
+
setResponseValueAndErrors(res, "exclusiveMaximum", check.value, check.message, refs);
|
|
8973
|
+
}
|
|
8974
|
+
} else {
|
|
8975
|
+
if (!check.inclusive) {
|
|
8976
|
+
res.exclusiveMaximum = true;
|
|
8977
|
+
}
|
|
8978
|
+
setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
8979
|
+
}
|
|
8980
|
+
break;
|
|
8981
|
+
case "multipleOf":
|
|
8982
|
+
setResponseValueAndErrors(res, "multipleOf", check.value, check.message, refs);
|
|
8983
|
+
break;
|
|
8984
|
+
}
|
|
8985
|
+
}
|
|
8986
|
+
return res;
|
|
8987
|
+
}
|
|
8988
|
+
var init_number = () => {};
|
|
8989
|
+
|
|
8990
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/object.js
|
|
8991
|
+
function parseObjectDef(def, refs) {
|
|
8992
|
+
const forceOptionalIntoNullable = refs.target === "openAi";
|
|
8993
|
+
const result = {
|
|
8994
|
+
type: "object",
|
|
8995
|
+
properties: {}
|
|
8996
|
+
};
|
|
8997
|
+
const required = [];
|
|
8998
|
+
const shape = def.shape();
|
|
8999
|
+
for (const propName in shape) {
|
|
9000
|
+
let propDef = shape[propName];
|
|
9001
|
+
if (propDef === undefined || propDef._def === undefined) {
|
|
9002
|
+
continue;
|
|
9003
|
+
}
|
|
9004
|
+
let propOptional = safeIsOptional(propDef);
|
|
9005
|
+
if (propOptional && forceOptionalIntoNullable) {
|
|
9006
|
+
if (propDef._def.typeName === "ZodOptional") {
|
|
9007
|
+
propDef = propDef._def.innerType;
|
|
9008
|
+
}
|
|
9009
|
+
if (!propDef.isNullable()) {
|
|
9010
|
+
propDef = propDef.nullable();
|
|
9011
|
+
}
|
|
9012
|
+
propOptional = false;
|
|
9013
|
+
}
|
|
9014
|
+
const parsedDef = parseDef(propDef._def, {
|
|
9015
|
+
...refs,
|
|
9016
|
+
currentPath: [...refs.currentPath, "properties", propName],
|
|
9017
|
+
propertyPath: [...refs.currentPath, "properties", propName]
|
|
9018
|
+
});
|
|
9019
|
+
if (parsedDef === undefined) {
|
|
9020
|
+
continue;
|
|
9021
|
+
}
|
|
9022
|
+
result.properties[propName] = parsedDef;
|
|
9023
|
+
if (!propOptional) {
|
|
9024
|
+
required.push(propName);
|
|
9025
|
+
}
|
|
9026
|
+
}
|
|
9027
|
+
if (required.length) {
|
|
9028
|
+
result.required = required;
|
|
9029
|
+
}
|
|
9030
|
+
const additionalProperties = decideAdditionalProperties(def, refs);
|
|
9031
|
+
if (additionalProperties !== undefined) {
|
|
9032
|
+
result.additionalProperties = additionalProperties;
|
|
9033
|
+
}
|
|
9034
|
+
return result;
|
|
9035
|
+
}
|
|
9036
|
+
function decideAdditionalProperties(def, refs) {
|
|
9037
|
+
if (def.catchall._def.typeName !== "ZodNever") {
|
|
9038
|
+
return parseDef(def.catchall._def, {
|
|
9039
|
+
...refs,
|
|
9040
|
+
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
9041
|
+
});
|
|
9042
|
+
}
|
|
9043
|
+
switch (def.unknownKeys) {
|
|
9044
|
+
case "passthrough":
|
|
9045
|
+
return refs.allowedAdditionalProperties;
|
|
9046
|
+
case "strict":
|
|
9047
|
+
return refs.rejectedAdditionalProperties;
|
|
9048
|
+
case "strip":
|
|
9049
|
+
return refs.removeAdditionalStrategy === "strict" ? refs.allowedAdditionalProperties : refs.rejectedAdditionalProperties;
|
|
9050
|
+
}
|
|
9051
|
+
}
|
|
9052
|
+
function safeIsOptional(schema) {
|
|
9053
|
+
try {
|
|
9054
|
+
return schema.isOptional();
|
|
9055
|
+
} catch {
|
|
9056
|
+
return true;
|
|
9057
|
+
}
|
|
9058
|
+
}
|
|
9059
|
+
var init_object = __esm(() => {
|
|
9060
|
+
init_parseDef();
|
|
9061
|
+
});
|
|
9062
|
+
|
|
9063
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/optional.js
|
|
9064
|
+
var parseOptionalDef = (def, refs) => {
|
|
9065
|
+
if (refs.currentPath.toString() === refs.propertyPath?.toString()) {
|
|
9066
|
+
return parseDef(def.innerType._def, refs);
|
|
9067
|
+
}
|
|
9068
|
+
const innerSchema = parseDef(def.innerType._def, {
|
|
9069
|
+
...refs,
|
|
9070
|
+
currentPath: [...refs.currentPath, "anyOf", "1"]
|
|
9071
|
+
});
|
|
9072
|
+
return innerSchema ? {
|
|
9073
|
+
anyOf: [
|
|
9074
|
+
{
|
|
9075
|
+
not: parseAnyDef(refs)
|
|
9076
|
+
},
|
|
9077
|
+
innerSchema
|
|
9078
|
+
]
|
|
9079
|
+
} : parseAnyDef(refs);
|
|
9080
|
+
};
|
|
9081
|
+
var init_optional = __esm(() => {
|
|
9082
|
+
init_parseDef();
|
|
9083
|
+
init_any();
|
|
9084
|
+
});
|
|
9085
|
+
|
|
9086
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js
|
|
9087
|
+
var parsePipelineDef = (def, refs) => {
|
|
9088
|
+
if (refs.pipeStrategy === "input") {
|
|
9089
|
+
return parseDef(def.in._def, refs);
|
|
9090
|
+
} else if (refs.pipeStrategy === "output") {
|
|
9091
|
+
return parseDef(def.out._def, refs);
|
|
9092
|
+
}
|
|
9093
|
+
const a = parseDef(def.in._def, {
|
|
9094
|
+
...refs,
|
|
9095
|
+
currentPath: [...refs.currentPath, "allOf", "0"]
|
|
9096
|
+
});
|
|
9097
|
+
const b = parseDef(def.out._def, {
|
|
9098
|
+
...refs,
|
|
9099
|
+
currentPath: [...refs.currentPath, "allOf", a ? "1" : "0"]
|
|
9100
|
+
});
|
|
9101
|
+
return {
|
|
9102
|
+
allOf: [a, b].filter((x) => x !== undefined)
|
|
9103
|
+
};
|
|
9104
|
+
};
|
|
9105
|
+
var init_pipeline = __esm(() => {
|
|
9106
|
+
init_parseDef();
|
|
9107
|
+
});
|
|
9108
|
+
|
|
9109
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/promise.js
|
|
9110
|
+
function parsePromiseDef(def, refs) {
|
|
9111
|
+
return parseDef(def.type._def, refs);
|
|
9112
|
+
}
|
|
9113
|
+
var init_promise = __esm(() => {
|
|
9114
|
+
init_parseDef();
|
|
9115
|
+
});
|
|
9116
|
+
|
|
9117
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/set.js
|
|
9118
|
+
function parseSetDef(def, refs) {
|
|
9119
|
+
const items = parseDef(def.valueType._def, {
|
|
9120
|
+
...refs,
|
|
9121
|
+
currentPath: [...refs.currentPath, "items"]
|
|
9122
|
+
});
|
|
9123
|
+
const schema = {
|
|
9124
|
+
type: "array",
|
|
9125
|
+
uniqueItems: true,
|
|
9126
|
+
items
|
|
9127
|
+
};
|
|
9128
|
+
if (def.minSize) {
|
|
9129
|
+
setResponseValueAndErrors(schema, "minItems", def.minSize.value, def.minSize.message, refs);
|
|
9130
|
+
}
|
|
9131
|
+
if (def.maxSize) {
|
|
9132
|
+
setResponseValueAndErrors(schema, "maxItems", def.maxSize.value, def.maxSize.message, refs);
|
|
9133
|
+
}
|
|
9134
|
+
return schema;
|
|
9135
|
+
}
|
|
9136
|
+
var init_set = __esm(() => {
|
|
9137
|
+
init_parseDef();
|
|
9138
|
+
});
|
|
9139
|
+
|
|
9140
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js
|
|
9141
|
+
function parseTupleDef(def, refs) {
|
|
9142
|
+
if (def.rest) {
|
|
9143
|
+
return {
|
|
9144
|
+
type: "array",
|
|
9145
|
+
minItems: def.items.length,
|
|
9146
|
+
items: def.items.map((x, i) => parseDef(x._def, {
|
|
9147
|
+
...refs,
|
|
9148
|
+
currentPath: [...refs.currentPath, "items", `${i}`]
|
|
9149
|
+
})).reduce((acc, x) => x === undefined ? acc : [...acc, x], []),
|
|
9150
|
+
additionalItems: parseDef(def.rest._def, {
|
|
9151
|
+
...refs,
|
|
9152
|
+
currentPath: [...refs.currentPath, "additionalItems"]
|
|
9153
|
+
})
|
|
9154
|
+
};
|
|
9155
|
+
} else {
|
|
9156
|
+
return {
|
|
9157
|
+
type: "array",
|
|
9158
|
+
minItems: def.items.length,
|
|
9159
|
+
maxItems: def.items.length,
|
|
9160
|
+
items: def.items.map((x, i) => parseDef(x._def, {
|
|
9161
|
+
...refs,
|
|
9162
|
+
currentPath: [...refs.currentPath, "items", `${i}`]
|
|
9163
|
+
})).reduce((acc, x) => x === undefined ? acc : [...acc, x], [])
|
|
9164
|
+
};
|
|
9165
|
+
}
|
|
9166
|
+
}
|
|
9167
|
+
var init_tuple = __esm(() => {
|
|
9168
|
+
init_parseDef();
|
|
9169
|
+
});
|
|
9170
|
+
|
|
9171
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js
|
|
9172
|
+
function parseUndefinedDef(refs) {
|
|
9173
|
+
return {
|
|
9174
|
+
not: parseAnyDef(refs)
|
|
9175
|
+
};
|
|
9176
|
+
}
|
|
9177
|
+
var init_undefined = __esm(() => {
|
|
9178
|
+
init_any();
|
|
9179
|
+
});
|
|
9180
|
+
|
|
9181
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js
|
|
9182
|
+
function parseUnknownDef(refs) {
|
|
9183
|
+
return parseAnyDef(refs);
|
|
9184
|
+
}
|
|
9185
|
+
var init_unknown = __esm(() => {
|
|
9186
|
+
init_any();
|
|
9187
|
+
});
|
|
9188
|
+
|
|
9189
|
+
// node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js
|
|
9190
|
+
var parseReadonlyDef = (def, refs) => {
|
|
9191
|
+
return parseDef(def.innerType._def, refs);
|
|
9192
|
+
};
|
|
9193
|
+
var init_readonly = __esm(() => {
|
|
9194
|
+
init_parseDef();
|
|
9195
|
+
});
|
|
9196
|
+
|
|
9197
|
+
// node_modules/zod-to-json-schema/dist/esm/selectParser.js
|
|
9198
|
+
var selectParser = (def, typeName, refs) => {
|
|
9199
|
+
switch (typeName) {
|
|
9200
|
+
case ZodFirstPartyTypeKind.ZodString:
|
|
9201
|
+
return parseStringDef(def, refs);
|
|
9202
|
+
case ZodFirstPartyTypeKind.ZodNumber:
|
|
9203
|
+
return parseNumberDef(def, refs);
|
|
9204
|
+
case ZodFirstPartyTypeKind.ZodObject:
|
|
9205
|
+
return parseObjectDef(def, refs);
|
|
9206
|
+
case ZodFirstPartyTypeKind.ZodBigInt:
|
|
9207
|
+
return parseBigintDef(def, refs);
|
|
9208
|
+
case ZodFirstPartyTypeKind.ZodBoolean:
|
|
9209
|
+
return parseBooleanDef();
|
|
9210
|
+
case ZodFirstPartyTypeKind.ZodDate:
|
|
9211
|
+
return parseDateDef(def, refs);
|
|
9212
|
+
case ZodFirstPartyTypeKind.ZodUndefined:
|
|
9213
|
+
return parseUndefinedDef(refs);
|
|
9214
|
+
case ZodFirstPartyTypeKind.ZodNull:
|
|
9215
|
+
return parseNullDef(refs);
|
|
9216
|
+
case ZodFirstPartyTypeKind.ZodArray:
|
|
9217
|
+
return parseArrayDef(def, refs);
|
|
9218
|
+
case ZodFirstPartyTypeKind.ZodUnion:
|
|
9219
|
+
case ZodFirstPartyTypeKind.ZodDiscriminatedUnion:
|
|
9220
|
+
return parseUnionDef(def, refs);
|
|
9221
|
+
case ZodFirstPartyTypeKind.ZodIntersection:
|
|
9222
|
+
return parseIntersectionDef(def, refs);
|
|
9223
|
+
case ZodFirstPartyTypeKind.ZodTuple:
|
|
9224
|
+
return parseTupleDef(def, refs);
|
|
9225
|
+
case ZodFirstPartyTypeKind.ZodRecord:
|
|
9226
|
+
return parseRecordDef(def, refs);
|
|
9227
|
+
case ZodFirstPartyTypeKind.ZodLiteral:
|
|
9228
|
+
return parseLiteralDef(def, refs);
|
|
9229
|
+
case ZodFirstPartyTypeKind.ZodEnum:
|
|
9230
|
+
return parseEnumDef(def);
|
|
9231
|
+
case ZodFirstPartyTypeKind.ZodNativeEnum:
|
|
9232
|
+
return parseNativeEnumDef(def);
|
|
9233
|
+
case ZodFirstPartyTypeKind.ZodNullable:
|
|
9234
|
+
return parseNullableDef(def, refs);
|
|
9235
|
+
case ZodFirstPartyTypeKind.ZodOptional:
|
|
9236
|
+
return parseOptionalDef(def, refs);
|
|
9237
|
+
case ZodFirstPartyTypeKind.ZodMap:
|
|
9238
|
+
return parseMapDef(def, refs);
|
|
9239
|
+
case ZodFirstPartyTypeKind.ZodSet:
|
|
9240
|
+
return parseSetDef(def, refs);
|
|
9241
|
+
case ZodFirstPartyTypeKind.ZodLazy:
|
|
9242
|
+
return () => def.getter()._def;
|
|
9243
|
+
case ZodFirstPartyTypeKind.ZodPromise:
|
|
9244
|
+
return parsePromiseDef(def, refs);
|
|
9245
|
+
case ZodFirstPartyTypeKind.ZodNaN:
|
|
9246
|
+
case ZodFirstPartyTypeKind.ZodNever:
|
|
9247
|
+
return parseNeverDef(refs);
|
|
9248
|
+
case ZodFirstPartyTypeKind.ZodEffects:
|
|
9249
|
+
return parseEffectsDef(def, refs);
|
|
9250
|
+
case ZodFirstPartyTypeKind.ZodAny:
|
|
9251
|
+
return parseAnyDef(refs);
|
|
9252
|
+
case ZodFirstPartyTypeKind.ZodUnknown:
|
|
9253
|
+
return parseUnknownDef(refs);
|
|
9254
|
+
case ZodFirstPartyTypeKind.ZodDefault:
|
|
9255
|
+
return parseDefaultDef(def, refs);
|
|
9256
|
+
case ZodFirstPartyTypeKind.ZodBranded:
|
|
9257
|
+
return parseBrandedDef(def, refs);
|
|
9258
|
+
case ZodFirstPartyTypeKind.ZodReadonly:
|
|
9259
|
+
return parseReadonlyDef(def, refs);
|
|
9260
|
+
case ZodFirstPartyTypeKind.ZodCatch:
|
|
9261
|
+
return parseCatchDef(def, refs);
|
|
9262
|
+
case ZodFirstPartyTypeKind.ZodPipeline:
|
|
9263
|
+
return parsePipelineDef(def, refs);
|
|
9264
|
+
case ZodFirstPartyTypeKind.ZodFunction:
|
|
9265
|
+
case ZodFirstPartyTypeKind.ZodVoid:
|
|
9266
|
+
case ZodFirstPartyTypeKind.ZodSymbol:
|
|
9267
|
+
return;
|
|
9268
|
+
default:
|
|
9269
|
+
return ((_) => {
|
|
9270
|
+
return;
|
|
9271
|
+
})(typeName);
|
|
9272
|
+
}
|
|
9273
|
+
};
|
|
9274
|
+
var init_selectParser = __esm(() => {
|
|
9275
|
+
init_v3();
|
|
9276
|
+
init_any();
|
|
9277
|
+
init_array();
|
|
9278
|
+
init_bigint();
|
|
9279
|
+
init_branded();
|
|
9280
|
+
init_catch();
|
|
9281
|
+
init_date();
|
|
9282
|
+
init_default();
|
|
9283
|
+
init_effects();
|
|
9284
|
+
init_intersection();
|
|
9285
|
+
init_map();
|
|
9286
|
+
init_never();
|
|
9287
|
+
init_nullable();
|
|
9288
|
+
init_number();
|
|
9289
|
+
init_object();
|
|
9290
|
+
init_optional();
|
|
9291
|
+
init_pipeline();
|
|
9292
|
+
init_promise();
|
|
9293
|
+
init_record();
|
|
9294
|
+
init_set();
|
|
9295
|
+
init_string();
|
|
9296
|
+
init_tuple();
|
|
9297
|
+
init_undefined();
|
|
9298
|
+
init_union();
|
|
9299
|
+
init_unknown();
|
|
9300
|
+
init_readonly();
|
|
9301
|
+
});
|
|
9302
|
+
|
|
9303
|
+
// node_modules/zod-to-json-schema/dist/esm/parseDef.js
|
|
9304
|
+
function parseDef(def, refs, forceResolution = false) {
|
|
9305
|
+
const seenItem = refs.seen.get(def);
|
|
9306
|
+
if (refs.override) {
|
|
9307
|
+
const overrideResult = refs.override?.(def, refs, seenItem, forceResolution);
|
|
9308
|
+
if (overrideResult !== ignoreOverride) {
|
|
9309
|
+
return overrideResult;
|
|
9310
|
+
}
|
|
9311
|
+
}
|
|
9312
|
+
if (seenItem && !forceResolution) {
|
|
9313
|
+
const seenSchema = get$ref(seenItem, refs);
|
|
9314
|
+
if (seenSchema !== undefined) {
|
|
9315
|
+
return seenSchema;
|
|
9316
|
+
}
|
|
9317
|
+
}
|
|
9318
|
+
const newItem = { def, path: refs.currentPath, jsonSchema: undefined };
|
|
9319
|
+
refs.seen.set(def, newItem);
|
|
9320
|
+
const jsonSchemaOrGetter = selectParser(def, def.typeName, refs);
|
|
9321
|
+
const jsonSchema = typeof jsonSchemaOrGetter === "function" ? parseDef(jsonSchemaOrGetter(), refs) : jsonSchemaOrGetter;
|
|
9322
|
+
if (jsonSchema) {
|
|
9323
|
+
addMeta(def, refs, jsonSchema);
|
|
9324
|
+
}
|
|
9325
|
+
if (refs.postProcess) {
|
|
9326
|
+
const postProcessResult = refs.postProcess(jsonSchema, def, refs);
|
|
9327
|
+
newItem.jsonSchema = jsonSchema;
|
|
9328
|
+
return postProcessResult;
|
|
9329
|
+
}
|
|
9330
|
+
newItem.jsonSchema = jsonSchema;
|
|
9331
|
+
return jsonSchema;
|
|
9332
|
+
}
|
|
9333
|
+
var get$ref = (item, refs) => {
|
|
9334
|
+
switch (refs.$refStrategy) {
|
|
9335
|
+
case "root":
|
|
9336
|
+
return { $ref: item.path.join("/") };
|
|
9337
|
+
case "relative":
|
|
9338
|
+
return { $ref: getRelativePath(refs.currentPath, item.path) };
|
|
9339
|
+
case "none":
|
|
9340
|
+
case "seen": {
|
|
9341
|
+
if (item.path.length < refs.currentPath.length && item.path.every((value, index) => refs.currentPath[index] === value)) {
|
|
9342
|
+
console.warn(`Recursive reference detected at ${refs.currentPath.join("/")}! Defaulting to any`);
|
|
9343
|
+
return parseAnyDef(refs);
|
|
9344
|
+
}
|
|
9345
|
+
return refs.$refStrategy === "seen" ? parseAnyDef(refs) : undefined;
|
|
9346
|
+
}
|
|
9347
|
+
}
|
|
9348
|
+
}, addMeta = (def, refs, jsonSchema) => {
|
|
9349
|
+
if (def.description) {
|
|
9350
|
+
jsonSchema.description = def.description;
|
|
9351
|
+
if (refs.markdownDescription) {
|
|
9352
|
+
jsonSchema.markdownDescription = def.description;
|
|
9353
|
+
}
|
|
9354
|
+
}
|
|
9355
|
+
return jsonSchema;
|
|
9356
|
+
};
|
|
9357
|
+
var init_parseDef = __esm(() => {
|
|
9358
|
+
init_Options();
|
|
9359
|
+
init_selectParser();
|
|
9360
|
+
init_any();
|
|
9361
|
+
});
|
|
9362
|
+
|
|
9363
|
+
// node_modules/zod-to-json-schema/dist/esm/parseTypes.js
|
|
9364
|
+
var init_parseTypes = () => {};
|
|
9365
|
+
|
|
9366
|
+
// node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js
|
|
9367
|
+
var zodToJsonSchema = (schema, options) => {
|
|
9368
|
+
const refs = getRefs(options);
|
|
9369
|
+
let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name2, schema2]) => ({
|
|
9370
|
+
...acc,
|
|
9371
|
+
[name2]: parseDef(schema2._def, {
|
|
9372
|
+
...refs,
|
|
9373
|
+
currentPath: [...refs.basePath, refs.definitionPath, name2]
|
|
9374
|
+
}, true) ?? parseAnyDef(refs)
|
|
9375
|
+
}), {}) : undefined;
|
|
9376
|
+
const name = typeof options === "string" ? options : options?.nameStrategy === "title" ? undefined : options?.name;
|
|
9377
|
+
const main = parseDef(schema._def, name === undefined ? refs : {
|
|
9378
|
+
...refs,
|
|
9379
|
+
currentPath: [...refs.basePath, refs.definitionPath, name]
|
|
9380
|
+
}, false) ?? parseAnyDef(refs);
|
|
9381
|
+
const title = typeof options === "object" && options.name !== undefined && options.nameStrategy === "title" ? options.name : undefined;
|
|
9382
|
+
if (title !== undefined) {
|
|
9383
|
+
main.title = title;
|
|
9384
|
+
}
|
|
9385
|
+
if (refs.flags.hasReferencedOpenAiAnyType) {
|
|
9386
|
+
if (!definitions) {
|
|
9387
|
+
definitions = {};
|
|
9388
|
+
}
|
|
9389
|
+
if (!definitions[refs.openAiAnyTypeName]) {
|
|
9390
|
+
definitions[refs.openAiAnyTypeName] = {
|
|
9391
|
+
type: ["string", "number", "integer", "boolean", "array", "null"],
|
|
9392
|
+
items: {
|
|
9393
|
+
$ref: refs.$refStrategy === "relative" ? "1" : [
|
|
9394
|
+
...refs.basePath,
|
|
9395
|
+
refs.definitionPath,
|
|
9396
|
+
refs.openAiAnyTypeName
|
|
9397
|
+
].join("/")
|
|
9398
|
+
}
|
|
9399
|
+
};
|
|
9400
|
+
}
|
|
9401
|
+
}
|
|
9402
|
+
const combined = name === undefined ? definitions ? {
|
|
9403
|
+
...main,
|
|
9404
|
+
[refs.definitionPath]: definitions
|
|
9405
|
+
} : main : {
|
|
9406
|
+
$ref: [
|
|
9407
|
+
...refs.$refStrategy === "relative" ? [] : refs.basePath,
|
|
9408
|
+
refs.definitionPath,
|
|
9409
|
+
name
|
|
9410
|
+
].join("/"),
|
|
9411
|
+
[refs.definitionPath]: {
|
|
9412
|
+
...definitions,
|
|
9413
|
+
[name]: main
|
|
9414
|
+
}
|
|
9415
|
+
};
|
|
9416
|
+
if (refs.target === "jsonSchema7") {
|
|
9417
|
+
combined.$schema = "http://json-schema.org/draft-07/schema#";
|
|
9418
|
+
} else if (refs.target === "jsonSchema2019-09" || refs.target === "openAi") {
|
|
9419
|
+
combined.$schema = "https://json-schema.org/draft/2019-09/schema#";
|
|
9420
|
+
}
|
|
9421
|
+
if (refs.target === "openAi" && (("anyOf" in combined) || ("oneOf" in combined) || ("allOf" in combined) || ("type" in combined) && Array.isArray(combined.type))) {
|
|
9422
|
+
console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property.");
|
|
9423
|
+
}
|
|
9424
|
+
return combined;
|
|
9425
|
+
};
|
|
9426
|
+
var init_zodToJsonSchema = __esm(() => {
|
|
9427
|
+
init_parseDef();
|
|
9428
|
+
init_Refs();
|
|
9429
|
+
init_any();
|
|
9430
|
+
});
|
|
9431
|
+
|
|
9432
|
+
// node_modules/zod-to-json-schema/dist/esm/index.js
|
|
9433
|
+
var init_esm = __esm(() => {
|
|
9434
|
+
init_zodToJsonSchema();
|
|
9435
|
+
init_Options();
|
|
9436
|
+
init_Refs();
|
|
9437
|
+
init_parseDef();
|
|
9438
|
+
init_parseTypes();
|
|
9439
|
+
init_any();
|
|
9440
|
+
init_array();
|
|
9441
|
+
init_bigint();
|
|
9442
|
+
init_branded();
|
|
9443
|
+
init_catch();
|
|
9444
|
+
init_date();
|
|
9445
|
+
init_default();
|
|
9446
|
+
init_effects();
|
|
9447
|
+
init_intersection();
|
|
9448
|
+
init_map();
|
|
9449
|
+
init_never();
|
|
9450
|
+
init_nullable();
|
|
9451
|
+
init_number();
|
|
9452
|
+
init_object();
|
|
9453
|
+
init_optional();
|
|
9454
|
+
init_pipeline();
|
|
9455
|
+
init_promise();
|
|
9456
|
+
init_readonly();
|
|
9457
|
+
init_record();
|
|
9458
|
+
init_set();
|
|
9459
|
+
init_string();
|
|
9460
|
+
init_tuple();
|
|
9461
|
+
init_undefined();
|
|
9462
|
+
init_union();
|
|
9463
|
+
init_unknown();
|
|
9464
|
+
init_selectParser();
|
|
9465
|
+
init_zodToJsonSchema();
|
|
9466
|
+
});
|
|
9467
|
+
|
|
8064
9468
|
// src/ai/openai.ts
|
|
8065
9469
|
function convertMCPToolToOpenAI(mcpTool, _client, options) {
|
|
8066
9470
|
const inputParams = mcpTool.inputSchema;
|
|
@@ -8088,7 +9492,10 @@ async function getOpenAITools(client, options) {
|
|
|
8088
9492
|
const triggerTools = createTriggerTools(triggerConfig, options?.context);
|
|
8089
9493
|
for (const [name, tool] of Object.entries(triggerTools)) {
|
|
8090
9494
|
const zodSchema = tool.inputSchema;
|
|
8091
|
-
const jsonSchema = zodToJsonSchema(zodSchema
|
|
9495
|
+
const jsonSchema = zodToJsonSchema(zodSchema, {
|
|
9496
|
+
target: "openApi3",
|
|
9497
|
+
$refStrategy: "none"
|
|
9498
|
+
});
|
|
8092
9499
|
openaiTools.push({
|
|
8093
9500
|
type: "function",
|
|
8094
9501
|
name,
|
|
@@ -8100,26 +9507,6 @@ async function getOpenAITools(client, options) {
|
|
|
8100
9507
|
}
|
|
8101
9508
|
return openaiTools;
|
|
8102
9509
|
}
|
|
8103
|
-
function zodToJsonSchema(schema) {
|
|
8104
|
-
if (schema._def?.typeName === "ZodObject") {
|
|
8105
|
-
const shape = schema._def.shape();
|
|
8106
|
-
const properties = {};
|
|
8107
|
-
const required = [];
|
|
8108
|
-
for (const [key, value] of Object.entries(shape)) {
|
|
8109
|
-
const fieldSchema = value;
|
|
8110
|
-
properties[key] = { type: "string" };
|
|
8111
|
-
if (fieldSchema._def?.typeName !== "ZodOptional") {
|
|
8112
|
-
required.push(key);
|
|
8113
|
-
}
|
|
8114
|
-
}
|
|
8115
|
-
return {
|
|
8116
|
-
type: "object",
|
|
8117
|
-
properties,
|
|
8118
|
-
...required.length > 0 ? { required } : {}
|
|
8119
|
-
};
|
|
8120
|
-
}
|
|
8121
|
-
return { type: "object" };
|
|
8122
|
-
}
|
|
8123
9510
|
async function handleOpenAIToolCalls(client, toolCalls, options) {
|
|
8124
9511
|
const toolOutputs = [];
|
|
8125
9512
|
const triggerConfig = client.__triggerConfig;
|
|
@@ -8175,6 +9562,7 @@ async function handleOpenAIResponse(client, response, options) {
|
|
|
8175
9562
|
var init_openai = __esm(() => {
|
|
8176
9563
|
init_utils();
|
|
8177
9564
|
init_trigger_tools();
|
|
9565
|
+
init_esm();
|
|
8178
9566
|
});
|
|
8179
9567
|
|
|
8180
9568
|
// src/ai/anthropic.ts
|
|
@@ -8236,7 +9624,10 @@ async function getAnthropicTools(client, options) {
|
|
|
8236
9624
|
const triggerTools = createTriggerTools(triggerConfig, options?.context);
|
|
8237
9625
|
for (const [name, tool] of Object.entries(triggerTools)) {
|
|
8238
9626
|
const zodSchema = tool.inputSchema;
|
|
8239
|
-
const jsonSchema =
|
|
9627
|
+
const jsonSchema = zodToJsonSchema(zodSchema, {
|
|
9628
|
+
target: "openApi3",
|
|
9629
|
+
$refStrategy: "none"
|
|
9630
|
+
});
|
|
8240
9631
|
anthropicTools.push({
|
|
8241
9632
|
name,
|
|
8242
9633
|
description: tool.description || `Execute ${name}`,
|
|
@@ -8246,26 +9637,6 @@ async function getAnthropicTools(client, options) {
|
|
|
8246
9637
|
}
|
|
8247
9638
|
return anthropicTools;
|
|
8248
9639
|
}
|
|
8249
|
-
function zodToAnthropicSchema(schema) {
|
|
8250
|
-
if (schema._def?.typeName === "ZodObject") {
|
|
8251
|
-
const shape = schema._def.shape();
|
|
8252
|
-
const properties = {};
|
|
8253
|
-
const required = [];
|
|
8254
|
-
for (const [key, value] of Object.entries(shape)) {
|
|
8255
|
-
const fieldSchema = value;
|
|
8256
|
-
properties[key] = { type: "string" };
|
|
8257
|
-
if (fieldSchema._def?.typeName !== "ZodOptional") {
|
|
8258
|
-
required.push(key);
|
|
8259
|
-
}
|
|
8260
|
-
}
|
|
8261
|
-
return {
|
|
8262
|
-
type: "object",
|
|
8263
|
-
properties,
|
|
8264
|
-
...required.length > 0 ? { required } : {}
|
|
8265
|
-
};
|
|
8266
|
-
}
|
|
8267
|
-
return { type: "object", properties: {}, required: [] };
|
|
8268
|
-
}
|
|
8269
9640
|
async function handleAnthropicMessage(client, message, options) {
|
|
8270
9641
|
let providerTokens = options?.providerTokens;
|
|
8271
9642
|
if (!providerTokens) {
|
|
@@ -8292,6 +9663,7 @@ async function handleAnthropicMessage(client, message, options) {
|
|
|
8292
9663
|
var init_anthropic = __esm(() => {
|
|
8293
9664
|
init_utils();
|
|
8294
9665
|
init_trigger_tools();
|
|
9666
|
+
init_esm();
|
|
8295
9667
|
});
|
|
8296
9668
|
|
|
8297
9669
|
// src/ai/google.ts
|
|
@@ -8408,39 +9780,78 @@ async function getGoogleTools(client, options) {
|
|
|
8408
9780
|
const TypeEnum = await getGoogleType();
|
|
8409
9781
|
for (const [name, tool] of Object.entries(triggerTools)) {
|
|
8410
9782
|
const zodSchema = tool.inputSchema;
|
|
8411
|
-
const jsonSchema =
|
|
9783
|
+
const jsonSchema = zodToJsonSchema(zodSchema, {
|
|
9784
|
+
target: "openApi3",
|
|
9785
|
+
$refStrategy: "none"
|
|
9786
|
+
});
|
|
9787
|
+
const googleSchema = convertJsonSchemaToGoogleSchema(jsonSchema, TypeEnum);
|
|
8412
9788
|
googleTools.push({
|
|
8413
9789
|
name,
|
|
8414
9790
|
description: tool.description || `Execute ${name}`,
|
|
8415
|
-
parameters:
|
|
9791
|
+
parameters: googleSchema
|
|
8416
9792
|
});
|
|
8417
9793
|
}
|
|
8418
9794
|
}
|
|
8419
9795
|
return googleTools;
|
|
8420
9796
|
}
|
|
8421
|
-
function
|
|
8422
|
-
|
|
8423
|
-
|
|
8424
|
-
|
|
8425
|
-
|
|
8426
|
-
|
|
8427
|
-
|
|
8428
|
-
|
|
8429
|
-
if (
|
|
8430
|
-
|
|
9797
|
+
function convertJsonSchemaToGoogleSchema(jsonSchema, TypeEnum) {
|
|
9798
|
+
const result = {
|
|
9799
|
+
type: TypeEnum.OBJECT
|
|
9800
|
+
};
|
|
9801
|
+
if (jsonSchema.properties) {
|
|
9802
|
+
const googleProperties = {};
|
|
9803
|
+
for (const [key, prop] of Object.entries(jsonSchema.properties)) {
|
|
9804
|
+
const googleProp = {};
|
|
9805
|
+
if (prop.type) {
|
|
9806
|
+
switch (prop.type) {
|
|
9807
|
+
case "string":
|
|
9808
|
+
googleProp.type = TypeEnum.STRING;
|
|
9809
|
+
break;
|
|
9810
|
+
case "number":
|
|
9811
|
+
googleProp.type = TypeEnum.NUMBER;
|
|
9812
|
+
break;
|
|
9813
|
+
case "integer":
|
|
9814
|
+
googleProp.type = TypeEnum.INTEGER;
|
|
9815
|
+
break;
|
|
9816
|
+
case "boolean":
|
|
9817
|
+
googleProp.type = TypeEnum.BOOLEAN;
|
|
9818
|
+
break;
|
|
9819
|
+
case "array":
|
|
9820
|
+
googleProp.type = TypeEnum.ARRAY;
|
|
9821
|
+
if (prop.items) {
|
|
9822
|
+
googleProp.items = convertJsonSchemaToGoogleSchema(prop.items, TypeEnum);
|
|
9823
|
+
}
|
|
9824
|
+
break;
|
|
9825
|
+
case "object":
|
|
9826
|
+
googleProp.type = TypeEnum.OBJECT;
|
|
9827
|
+
if (prop.properties) {
|
|
9828
|
+
googleProp.properties = Object.fromEntries(Object.entries(prop.properties).map(([k, v]) => [
|
|
9829
|
+
k,
|
|
9830
|
+
convertJsonSchemaToGoogleSchema(v, TypeEnum)
|
|
9831
|
+
]));
|
|
9832
|
+
}
|
|
9833
|
+
break;
|
|
9834
|
+
default:
|
|
9835
|
+
googleProp.type = TypeEnum.STRING;
|
|
9836
|
+
}
|
|
8431
9837
|
}
|
|
9838
|
+
if (prop.description)
|
|
9839
|
+
googleProp.description = prop.description;
|
|
9840
|
+
if (prop.enum)
|
|
9841
|
+
googleProp.enum = prop.enum;
|
|
9842
|
+
googleProperties[key] = googleProp;
|
|
8432
9843
|
}
|
|
8433
|
-
|
|
8434
|
-
|
|
8435
|
-
|
|
8436
|
-
|
|
8437
|
-
};
|
|
9844
|
+
result.properties = googleProperties;
|
|
9845
|
+
}
|
|
9846
|
+
if (jsonSchema.required && Array.isArray(jsonSchema.required)) {
|
|
9847
|
+
result.required = jsonSchema.required;
|
|
8438
9848
|
}
|
|
8439
|
-
return
|
|
9849
|
+
return result;
|
|
8440
9850
|
}
|
|
8441
9851
|
var init_google = __esm(() => {
|
|
8442
9852
|
init_utils();
|
|
8443
9853
|
init_trigger_tools();
|
|
9854
|
+
init_esm();
|
|
8444
9855
|
});
|
|
8445
9856
|
|
|
8446
9857
|
// src/ai/index.ts
|