@hey-api/openapi-ts 0.92.4 → 0.93.1
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/clients/angular/types.ts +2 -1
- package/dist/clients/axios/types.ts +2 -1
- package/dist/clients/core/params.ts +1 -1
- package/dist/clients/fetch/types.ts +2 -1
- package/dist/clients/ky/types.ts +2 -1
- package/dist/clients/next/types.ts +2 -1
- package/dist/clients/nuxt/types.ts +1 -1
- package/dist/clients/nuxt/utils.ts +4 -0
- package/dist/clients/ofetch/types.ts +1 -1
- package/dist/index.d.mts +120 -89
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/{init-BxMu9GWq.mjs → init-CuDouDN2.mjs} +1892 -1406
- package/dist/init-CuDouDN2.mjs.map +1 -0
- package/dist/internal.mjs +1 -1
- package/dist/run.mjs +5 -5
- package/dist/run.mjs.map +1 -1
- package/dist/{src-BqiDMJko.mjs → src-DRRrhVf_.mjs} +8 -4
- package/dist/src-DRRrhVf_.mjs.map +1 -0
- package/package.json +5 -5
- package/dist/init-BxMu9GWq.mjs.map +0 -1
- package/dist/src-BqiDMJko.mjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
import { StructureModel, detectInteractiveSession, fromRef, isNode, isRef, isSymbol, loadConfigFile, log, nodeBrand, ref, refs } from "@hey-api/codegen-core";
|
|
3
|
-
import { ConfigError, OperationPath, OperationStrategy, applyNaming, createOperationKey, createSchemaProcessor, deduplicateSchema, definePluginConfig, dependencyFactory, ensureDirSync, escapeComment, findTsConfigPath, getInput, getLogs, getParser, hasOperationDataRequired, hasParameterGroupObjectRequired, loadTsConfig, mappers, operationPagination, operationResponsesMap, parseUrl, pathToJsonPointer, pathToName, refToName, resolveSource, satisfies, statusCodeToGroup, toCase, valueToObject } from "@hey-api/shared";
|
|
3
|
+
import { ConfigError, OperationPath, OperationStrategy, applyNaming, childContext, createOperationKey, createSchemaProcessor, createSchemaWalker, deduplicateSchema, definePluginConfig, dependencyFactory, ensureDirSync, escapeComment, findTsConfigPath, getInput, getLogs, getParser, hasOperationDataRequired, hasParameterGroupObjectRequired, loadTsConfig, mappers, operationPagination, operationResponsesMap, parseUrl, pathToJsonPointer, pathToName, refToName, resolveSource, satisfies, statusCodeToGroup, toCase, valueToObject } from "@hey-api/shared";
|
|
4
4
|
import colors from "ansi-colors";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
@@ -2627,18 +2627,18 @@ f.await.set((...args) => new AwaitTsDsl(...args));
|
|
|
2627
2627
|
const Mixed$27 = ArgsMixin(AsMixin(ExprMixin(TypeArgsMixin(TsDsl))));
|
|
2628
2628
|
var CallTsDsl = class extends Mixed$27 {
|
|
2629
2629
|
"~dsl" = "CallTsDsl";
|
|
2630
|
-
|
|
2631
|
-
constructor(
|
|
2630
|
+
_callee;
|
|
2631
|
+
constructor(callee, ...args) {
|
|
2632
2632
|
super();
|
|
2633
|
-
this.
|
|
2633
|
+
this._callee = ref(callee);
|
|
2634
2634
|
this.args(...args);
|
|
2635
2635
|
}
|
|
2636
2636
|
analyze(ctx$1) {
|
|
2637
2637
|
super.analyze(ctx$1);
|
|
2638
|
-
ctx$1.analyze(this.
|
|
2638
|
+
ctx$1.analyze(this._callee);
|
|
2639
2639
|
}
|
|
2640
2640
|
toAst() {
|
|
2641
|
-
return ts.factory.createCallExpression(this.$node(this.
|
|
2641
|
+
return ts.factory.createCallExpression(this.$node(this._callee), this.$generics(), this.$args());
|
|
2642
2642
|
}
|
|
2643
2643
|
};
|
|
2644
2644
|
f.call.set((...args) => new CallTsDsl(...args));
|
|
@@ -4401,7 +4401,7 @@ function getSignatureParameters({ operation }) {
|
|
|
4401
4401
|
const property = properties[originalName];
|
|
4402
4402
|
const name = conflicts.has(originalName) ? `${location}_${originalName}` : originalName;
|
|
4403
4403
|
const signatureParameter = {
|
|
4404
|
-
isRequired:
|
|
4404
|
+
isRequired: operation.body.schema.required?.includes(originalName) ?? false,
|
|
4405
4405
|
name,
|
|
4406
4406
|
schema: property
|
|
4407
4407
|
};
|
|
@@ -4827,7 +4827,7 @@ function implementFn(args) {
|
|
|
4827
4827
|
role: "response"
|
|
4828
4828
|
}), (t$1, s) => t$1.extends(s).default(s), (t$1) => t$1.default("undefined"))), (m) => m.generic("ThrowOnError", (t) => t.extends("boolean").default(("throwOnError" in client.config ? client.config.throwOnError : false) ?? false))).params(...opParameters.parameters).do(...statements);
|
|
4829
4829
|
}
|
|
4830
|
-
function toNode(model, plugin) {
|
|
4830
|
+
function toNode$1(model, plugin) {
|
|
4831
4831
|
if (model.virtual) {
|
|
4832
4832
|
const nodes$1 = [];
|
|
4833
4833
|
for (const item of model.itemsFrom(source$1)) {
|
|
@@ -5337,6 +5337,16 @@ function getClientBundlePaths(pluginName) {
|
|
|
5337
5337
|
};
|
|
5338
5338
|
}
|
|
5339
5339
|
/**
|
|
5340
|
+
* Converts an {@link OutputHeader} value to a string prefix for file content.
|
|
5341
|
+
* Returns an empty string when the header is null, undefined, or a function
|
|
5342
|
+
* (functions require a render context which is not available for bundled files).
|
|
5343
|
+
*/
|
|
5344
|
+
function outputHeaderToPrefix(header) {
|
|
5345
|
+
if (header == null || typeof header === "function") return "";
|
|
5346
|
+
const content = (typeof header === "string" ? header.split(/\r?\n/) : header.flatMap((line) => line.split(/\r?\n/))).join("\n");
|
|
5347
|
+
return content ? `${content}\n\n` : "";
|
|
5348
|
+
}
|
|
5349
|
+
/**
|
|
5340
5350
|
* Returns absolute path to the client folder. This is hard-coded for now.
|
|
5341
5351
|
*/
|
|
5342
5352
|
function clientFolderAbsolutePath(config) {
|
|
@@ -5372,7 +5382,7 @@ function renameFile({ filePath, project, renamed }) {
|
|
|
5372
5382
|
renamed.set(name, renamedName);
|
|
5373
5383
|
}
|
|
5374
5384
|
}
|
|
5375
|
-
function replaceImports({ filePath, isDevMode: isDevMode$1, meta, renamed }) {
|
|
5385
|
+
function replaceImports({ filePath, header, isDevMode: isDevMode$1, meta, renamed }) {
|
|
5376
5386
|
let content = fs.readFileSync(filePath, "utf8");
|
|
5377
5387
|
if (isDevMode$1) {
|
|
5378
5388
|
content = content.replace(/from\s+['"]\.\.\/\.\.\/client-core\/bundle\//g, "from '../core/");
|
|
@@ -5386,17 +5396,16 @@ function replaceImports({ filePath, isDevMode: isDevMode$1, meta, renamed }) {
|
|
|
5386
5396
|
const replacedName = (renamed.get(fileName) ?? fileName) + (meta.importFileExtension ? meta.importFileExtension : extension);
|
|
5387
5397
|
return match.slice(0, importIndex) + [importDir, replacedName].filter(Boolean).join("/") + match.slice(importIndex + importPath.length);
|
|
5388
5398
|
});
|
|
5389
|
-
content =
|
|
5390
|
-
|
|
5391
|
-
${content}`;
|
|
5399
|
+
content = `${header ?? ""}${content}`;
|
|
5392
5400
|
fs.writeFileSync(filePath, content, "utf8");
|
|
5393
5401
|
}
|
|
5394
5402
|
/**
|
|
5395
5403
|
* Creates a `client` folder containing the same modules as the client package.
|
|
5396
5404
|
*/
|
|
5397
|
-
function generateClientBundle({ meta, outputPath, plugin, project }) {
|
|
5405
|
+
function generateClientBundle({ header, meta, outputPath, plugin, project }) {
|
|
5398
5406
|
const renamed = /* @__PURE__ */ new Map();
|
|
5399
5407
|
const devMode = isDevMode();
|
|
5408
|
+
const headerPrefix = outputHeaderToPrefix(header);
|
|
5400
5409
|
if (plugin.name.startsWith("@hey-api/client-")) {
|
|
5401
5410
|
const { clientPath, corePath } = getClientBundlePaths(plugin.name);
|
|
5402
5411
|
const coreOutputPath = path.resolve(outputPath, "core");
|
|
@@ -5422,6 +5431,7 @@ function generateClientBundle({ meta, outputPath, plugin, project }) {
|
|
|
5422
5431
|
const coreFiles = fs.readdirSync(coreOutputPath);
|
|
5423
5432
|
for (const file of coreFiles) replaceImports({
|
|
5424
5433
|
filePath: path.resolve(coreOutputPath, file),
|
|
5434
|
+
header: headerPrefix,
|
|
5425
5435
|
isDevMode: devMode,
|
|
5426
5436
|
meta,
|
|
5427
5437
|
renamed
|
|
@@ -5429,6 +5439,7 @@ function generateClientBundle({ meta, outputPath, plugin, project }) {
|
|
|
5429
5439
|
const clientFiles = fs.readdirSync(clientOutputPath);
|
|
5430
5440
|
for (const file of clientFiles) replaceImports({
|
|
5431
5441
|
filePath: path.resolve(clientOutputPath, file),
|
|
5442
|
+
header: headerPrefix,
|
|
5432
5443
|
isDevMode: devMode,
|
|
5433
5444
|
meta,
|
|
5434
5445
|
renamed
|
|
@@ -5488,7 +5499,7 @@ const createClient = ({ plugin }) => {
|
|
|
5488
5499
|
if ("throwOnError" in plugin.config && plugin.config.throwOnError) defaultVals.prop("throwOnError", $.literal(true));
|
|
5489
5500
|
const createConfigParameters = [$(symbolCreateConfig).call(defaultVals.hasProps() ? defaultVals : void 0).generic(symbolClientOptions)];
|
|
5490
5501
|
const symbolClient = plugin.symbol("client", { meta: { category: "client" } });
|
|
5491
|
-
const statement = $.const(symbolClient).export().assign($(symbolCreateClient).$if(symbolCreateClientConfig, (c, s) => c.call($(s).call(...createConfigParameters)), (c) => c.call(...createConfigParameters)));
|
|
5502
|
+
const statement = $.const(symbolClient).export().assign($(symbolCreateClient).$if(symbolCreateClientConfig, (c, s) => c.call($.await($(s).call(...createConfigParameters))), (c) => c.call(...createConfigParameters)));
|
|
5492
5503
|
plugin.node(statement);
|
|
5493
5504
|
};
|
|
5494
5505
|
|
|
@@ -5517,7 +5528,7 @@ const createClientConfigType = ({ plugin }) => {
|
|
|
5517
5528
|
"You may want to initialize your client this way instead of calling",
|
|
5518
5529
|
"`setConfig()`. This is useful for example if you're using Next.js",
|
|
5519
5530
|
"to ensure your client always has the correct values."
|
|
5520
|
-
]).generic("T", (g) => g.extends(symbolDefaultClientOptions).default(symbolClientOptions)).type($.type.func().param("override", (p) => p.optional().type($.type(symbolConfig).generic($.type.and(symbolDefaultClientOptions, "T")))).returns($.type(symbolConfig).generic($.type.and($.type("Required").generic(symbolDefaultClientOptions), "T"))));
|
|
5531
|
+
]).generic("T", (g) => g.extends(symbolDefaultClientOptions).default(symbolClientOptions)).type($.type.func().param("override", (p) => p.optional().type($.type(symbolConfig).generic($.type.and(symbolDefaultClientOptions, "T")))).returns($.type.or($.type(symbolConfig).generic($.type.and($.type("Required").generic(symbolDefaultClientOptions), "T")), $.type("Promise").generic($.type(symbolConfig).generic($.type.and($.type("Required").generic(symbolDefaultClientOptions), "T"))))));
|
|
5521
5532
|
plugin.node(typeCreateClientConfig);
|
|
5522
5533
|
};
|
|
5523
5534
|
|
|
@@ -6185,7 +6196,7 @@ const handlerV1$2 = ({ plugin }) => {
|
|
|
6185
6196
|
const allDependencies = [];
|
|
6186
6197
|
const allNodes = [];
|
|
6187
6198
|
for (const node of structure.walk()) {
|
|
6188
|
-
const { dependencies, nodes } = toNode(node, plugin);
|
|
6199
|
+
const { dependencies, nodes } = toNode$1(node, plugin);
|
|
6189
6200
|
allDependencies.push(...dependencies ?? []);
|
|
6190
6201
|
allNodes.push(...nodes);
|
|
6191
6202
|
}
|
|
@@ -6646,7 +6657,7 @@ const operationToDataType$1 = ({ operation, plugin, state }) => {
|
|
|
6646
6657
|
tags: fromRef(state.tags),
|
|
6647
6658
|
tool: "typescript"
|
|
6648
6659
|
} });
|
|
6649
|
-
const node = $.type.alias(symbol).export().type(irSchemaToAst$
|
|
6660
|
+
const node = $.type.alias(symbol).export().type(irSchemaToAst$1({
|
|
6650
6661
|
plugin,
|
|
6651
6662
|
schema: data,
|
|
6652
6663
|
state
|
|
@@ -6670,7 +6681,7 @@ const operationToType = ({ operation, plugin, state }) => {
|
|
|
6670
6681
|
tags: fromRef(state.tags),
|
|
6671
6682
|
tool: "typescript"
|
|
6672
6683
|
} });
|
|
6673
|
-
const node = $.type.alias(symbolErrors).export().type(irSchemaToAst$
|
|
6684
|
+
const node = $.type.alias(symbolErrors).export().type(irSchemaToAst$1({
|
|
6674
6685
|
plugin,
|
|
6675
6686
|
schema: errors,
|
|
6676
6687
|
state
|
|
@@ -6703,7 +6714,7 @@ const operationToType = ({ operation, plugin, state }) => {
|
|
|
6703
6714
|
tags: fromRef(state.tags),
|
|
6704
6715
|
tool: "typescript"
|
|
6705
6716
|
} });
|
|
6706
|
-
const node = $.type.alias(symbolResponses).export().type(irSchemaToAst$
|
|
6717
|
+
const node = $.type.alias(symbolResponses).export().type(irSchemaToAst$1({
|
|
6707
6718
|
plugin,
|
|
6708
6719
|
schema: responses,
|
|
6709
6720
|
state
|
|
@@ -6747,7 +6758,7 @@ const operationToDataType = ({ operation, plugin, state }) => {
|
|
|
6747
6758
|
tags: fromRef(state.tags),
|
|
6748
6759
|
tool: "typescript"
|
|
6749
6760
|
} });
|
|
6750
|
-
const node$1 = $.type.alias(symbolWebhookPayload).export().$if(plugin.config.comments && createSchemaComment(operation.body.schema), (t, v) => t.doc(v)).type(irSchemaToAst$
|
|
6761
|
+
const node$1 = $.type.alias(symbolWebhookPayload).export().$if(plugin.config.comments && createSchemaComment(operation.body.schema), (t, v) => t.doc(v)).type(irSchemaToAst$1({
|
|
6751
6762
|
plugin,
|
|
6752
6763
|
schema: operation.body.schema,
|
|
6753
6764
|
state
|
|
@@ -6773,7 +6784,7 @@ const operationToDataType = ({ operation, plugin, state }) => {
|
|
|
6773
6784
|
tags: fromRef(state.tags),
|
|
6774
6785
|
tool: "typescript"
|
|
6775
6786
|
} });
|
|
6776
|
-
const node = $.type.alias(symbolWebhookRequest).export().type(irSchemaToAst$
|
|
6787
|
+
const node = $.type.alias(symbolWebhookRequest).export().type(irSchemaToAst$1({
|
|
6777
6788
|
plugin,
|
|
6778
6789
|
schema: data,
|
|
6779
6790
|
state
|
|
@@ -6791,7 +6802,7 @@ const webhookToType = ({ operation, plugin, state }) => {
|
|
|
6791
6802
|
|
|
6792
6803
|
//#endregion
|
|
6793
6804
|
//#region src/plugins/@hey-api/typescript/v1/toAst/array.ts
|
|
6794
|
-
|
|
6805
|
+
function arrayToAst$3({ plugin, schema, state }) {
|
|
6795
6806
|
if (!schema.items) return $.type("Array").generic($.type(plugin.config.topType));
|
|
6796
6807
|
schema = deduplicateSchema({
|
|
6797
6808
|
detectFormat: true,
|
|
@@ -6799,7 +6810,7 @@ const arrayToAst$4 = ({ plugin, schema, state }) => {
|
|
|
6799
6810
|
});
|
|
6800
6811
|
const itemTypes = [];
|
|
6801
6812
|
if (schema.items) schema.items.forEach((item, index) => {
|
|
6802
|
-
const type = irSchemaToAst$
|
|
6813
|
+
const type = irSchemaToAst$1({
|
|
6803
6814
|
plugin,
|
|
6804
6815
|
schema: item,
|
|
6805
6816
|
state: {
|
|
@@ -6815,19 +6826,19 @@ const arrayToAst$4 = ({ plugin, schema, state }) => {
|
|
|
6815
6826
|
});
|
|
6816
6827
|
if (itemTypes.length === 1) return $.type("Array").generic(itemTypes[0]);
|
|
6817
6828
|
return schema.logicalOperator === "and" ? $.type("Array").generic($.type.and(...itemTypes)) : $.type("Array").generic($.type.or(...itemTypes));
|
|
6818
|
-
}
|
|
6829
|
+
}
|
|
6819
6830
|
|
|
6820
6831
|
//#endregion
|
|
6821
6832
|
//#region src/plugins/@hey-api/typescript/v1/toAst/boolean.ts
|
|
6822
|
-
function booleanToAst$
|
|
6833
|
+
function booleanToAst$3({ schema }) {
|
|
6823
6834
|
if (schema.const !== void 0) return $.type.literal(schema.const);
|
|
6824
6835
|
return $.type("boolean");
|
|
6825
6836
|
}
|
|
6826
6837
|
|
|
6827
6838
|
//#endregion
|
|
6828
6839
|
//#region src/plugins/@hey-api/typescript/v1/toAst/enum.ts
|
|
6829
|
-
|
|
6830
|
-
return irSchemaToAst$
|
|
6840
|
+
function enumToAst$3({ plugin, schema, state }) {
|
|
6841
|
+
return irSchemaToAst$1({
|
|
6831
6842
|
plugin,
|
|
6832
6843
|
schema: {
|
|
6833
6844
|
...schema,
|
|
@@ -6835,17 +6846,17 @@ const enumToAst$4 = ({ plugin, schema, state }) => {
|
|
|
6835
6846
|
},
|
|
6836
6847
|
state
|
|
6837
6848
|
});
|
|
6838
|
-
}
|
|
6849
|
+
}
|
|
6839
6850
|
|
|
6840
6851
|
//#endregion
|
|
6841
6852
|
//#region src/plugins/@hey-api/typescript/v1/toAst/never.ts
|
|
6842
|
-
const neverToAst$
|
|
6853
|
+
const neverToAst$3 = (_args) => {
|
|
6843
6854
|
return $.type("never");
|
|
6844
6855
|
};
|
|
6845
6856
|
|
|
6846
6857
|
//#endregion
|
|
6847
6858
|
//#region src/plugins/@hey-api/typescript/v1/toAst/null.ts
|
|
6848
|
-
const nullToAst$
|
|
6859
|
+
const nullToAst$4 = (_args) => {
|
|
6849
6860
|
return $.type.literal(null);
|
|
6850
6861
|
};
|
|
6851
6862
|
|
|
@@ -6861,14 +6872,14 @@ const numberToAst = ({ plugin, schema }) => {
|
|
|
6861
6872
|
|
|
6862
6873
|
//#endregion
|
|
6863
6874
|
//#region src/plugins/@hey-api/typescript/v1/toAst/object.ts
|
|
6864
|
-
|
|
6875
|
+
function objectToAst$4({ plugin, schema, state }) {
|
|
6865
6876
|
const shape = $.type.object();
|
|
6866
6877
|
const required = schema.required ?? [];
|
|
6867
6878
|
let indexSchemas = [];
|
|
6868
6879
|
let hasOptionalProperties = false;
|
|
6869
6880
|
for (const name in schema.properties) {
|
|
6870
6881
|
const property = schema.properties[name];
|
|
6871
|
-
const propertyType = irSchemaToAst$
|
|
6882
|
+
const propertyType = irSchemaToAst$1({
|
|
6872
6883
|
plugin,
|
|
6873
6884
|
schema: property,
|
|
6874
6885
|
state: {
|
|
@@ -6894,14 +6905,15 @@ const objectToAst$5 = ({ plugin, schema, state }) => {
|
|
|
6894
6905
|
const addPropsObj = addPropsRaw !== false && addPropsRaw ? addPropsRaw : void 0;
|
|
6895
6906
|
if (hasPatterns || !!addPropsObj && (addPropsObj.type !== "never" || !indexSchemas.length)) {
|
|
6896
6907
|
const addProps = addPropsObj;
|
|
6897
|
-
if (addProps && addProps.type !== "never") indexSchemas.
|
|
6908
|
+
if (addProps && addProps.type !== "never") if (addProps.type === "unknown") indexSchemas = [addProps, ...schema.patternProperties ? Object.values(schema.patternProperties) : []];
|
|
6909
|
+
else indexSchemas.unshift(addProps);
|
|
6898
6910
|
else if (!hasPatterns && !indexSchemas.length && addProps && addProps.type === "never") indexSchemas = [addProps];
|
|
6899
|
-
if (hasOptionalProperties) indexSchemas.push({ type: "undefined" });
|
|
6900
|
-
const type = indexSchemas.length === 1 ? irSchemaToAst$
|
|
6911
|
+
if (hasOptionalProperties && addProps?.type !== "unknown") indexSchemas.push({ type: "undefined" });
|
|
6912
|
+
const type = indexSchemas.length === 1 ? irSchemaToAst$1({
|
|
6901
6913
|
plugin,
|
|
6902
6914
|
schema: indexSchemas[0],
|
|
6903
6915
|
state
|
|
6904
|
-
}) : irSchemaToAst$
|
|
6916
|
+
}) : irSchemaToAst$1({
|
|
6905
6917
|
plugin,
|
|
6906
6918
|
schema: {
|
|
6907
6919
|
items: indexSchemas,
|
|
@@ -6909,7 +6921,7 @@ const objectToAst$5 = ({ plugin, schema, state }) => {
|
|
|
6909
6921
|
},
|
|
6910
6922
|
state
|
|
6911
6923
|
});
|
|
6912
|
-
if (schema.propertyNames?.$ref) return $.type.mapped("key").key(irSchemaToAst$
|
|
6924
|
+
if (schema.propertyNames?.$ref) return $.type.mapped("key").key(irSchemaToAst$1({
|
|
6913
6925
|
plugin,
|
|
6914
6926
|
schema: { $ref: schema.propertyNames.$ref },
|
|
6915
6927
|
state
|
|
@@ -6917,7 +6929,7 @@ const objectToAst$5 = ({ plugin, schema, state }) => {
|
|
|
6917
6929
|
shape.idxSig("key", (i) => i.key("string").type(type));
|
|
6918
6930
|
}
|
|
6919
6931
|
return shape;
|
|
6920
|
-
}
|
|
6932
|
+
}
|
|
6921
6933
|
|
|
6922
6934
|
//#endregion
|
|
6923
6935
|
//#region src/plugins/@hey-api/typescript/v1/toAst/string.ts
|
|
@@ -6964,11 +6976,11 @@ const stringToAst$1 = ({ plugin, schema }) => {
|
|
|
6964
6976
|
|
|
6965
6977
|
//#endregion
|
|
6966
6978
|
//#region src/plugins/@hey-api/typescript/v1/toAst/tuple.ts
|
|
6967
|
-
|
|
6979
|
+
function tupleToAst$3({ plugin, schema, state }) {
|
|
6968
6980
|
let itemTypes = [];
|
|
6969
6981
|
if (schema.const && Array.isArray(schema.const)) itemTypes = schema.const.map((value) => $.type.fromValue(value));
|
|
6970
6982
|
else if (schema.items) schema.items.forEach((item, index) => {
|
|
6971
|
-
const type = irSchemaToAst$
|
|
6983
|
+
const type = irSchemaToAst$1({
|
|
6972
6984
|
plugin,
|
|
6973
6985
|
schema: item,
|
|
6974
6986
|
state: {
|
|
@@ -6983,44 +6995,44 @@ const tupleToAst$4 = ({ plugin, schema, state }) => {
|
|
|
6983
6995
|
itemTypes.push(type);
|
|
6984
6996
|
});
|
|
6985
6997
|
return $.type.tuple(...itemTypes);
|
|
6986
|
-
}
|
|
6998
|
+
}
|
|
6987
6999
|
|
|
6988
7000
|
//#endregion
|
|
6989
7001
|
//#region src/plugins/@hey-api/typescript/v1/toAst/undefined.ts
|
|
6990
|
-
const undefinedToAst$
|
|
7002
|
+
const undefinedToAst$3 = (_args) => {
|
|
6991
7003
|
return $.type("undefined");
|
|
6992
7004
|
};
|
|
6993
7005
|
|
|
6994
7006
|
//#endregion
|
|
6995
7007
|
//#region src/plugins/@hey-api/typescript/v1/toAst/unknown.ts
|
|
6996
|
-
|
|
7008
|
+
function unknownToAst$3({ plugin }) {
|
|
6997
7009
|
return $.type(plugin.config.topType);
|
|
6998
|
-
}
|
|
7010
|
+
}
|
|
6999
7011
|
|
|
7000
7012
|
//#endregion
|
|
7001
7013
|
//#region src/plugins/@hey-api/typescript/v1/toAst/void.ts
|
|
7002
|
-
const voidToAst$
|
|
7014
|
+
const voidToAst$3 = (_args) => {
|
|
7003
7015
|
return $.type("void");
|
|
7004
7016
|
};
|
|
7005
7017
|
|
|
7006
7018
|
//#endregion
|
|
7007
7019
|
//#region src/plugins/@hey-api/typescript/v1/toAst/index.ts
|
|
7008
|
-
function irSchemaWithTypeToAst$
|
|
7020
|
+
function irSchemaWithTypeToAst$1({ schema, ...args }) {
|
|
7009
7021
|
const transformersPlugin = args.plugin.getPlugin("@hey-api/transformers");
|
|
7010
7022
|
if (transformersPlugin?.config.typeTransformers) for (const typeTransformer of transformersPlugin.config.typeTransformers) {
|
|
7011
7023
|
const typeNode = typeTransformer({ schema });
|
|
7012
7024
|
if (typeNode) return typeNode;
|
|
7013
7025
|
}
|
|
7014
7026
|
switch (schema.type) {
|
|
7015
|
-
case "array": return arrayToAst$
|
|
7027
|
+
case "array": return arrayToAst$3({
|
|
7016
7028
|
...args,
|
|
7017
7029
|
schema
|
|
7018
7030
|
});
|
|
7019
|
-
case "boolean": return booleanToAst$
|
|
7031
|
+
case "boolean": return booleanToAst$3({
|
|
7020
7032
|
...args,
|
|
7021
7033
|
schema
|
|
7022
7034
|
});
|
|
7023
|
-
case "enum": return enumToAst$
|
|
7035
|
+
case "enum": return enumToAst$3({
|
|
7024
7036
|
...args,
|
|
7025
7037
|
schema
|
|
7026
7038
|
});
|
|
@@ -7029,15 +7041,15 @@ function irSchemaWithTypeToAst$5({ schema, ...args }) {
|
|
|
7029
7041
|
...args,
|
|
7030
7042
|
schema
|
|
7031
7043
|
});
|
|
7032
|
-
case "never": return neverToAst$
|
|
7044
|
+
case "never": return neverToAst$3({
|
|
7033
7045
|
...args,
|
|
7034
7046
|
schema
|
|
7035
7047
|
});
|
|
7036
|
-
case "null": return nullToAst$
|
|
7048
|
+
case "null": return nullToAst$4({
|
|
7037
7049
|
...args,
|
|
7038
7050
|
schema
|
|
7039
7051
|
});
|
|
7040
|
-
case "object": return objectToAst$
|
|
7052
|
+
case "object": return objectToAst$4({
|
|
7041
7053
|
...args,
|
|
7042
7054
|
schema
|
|
7043
7055
|
});
|
|
@@ -7045,19 +7057,19 @@ function irSchemaWithTypeToAst$5({ schema, ...args }) {
|
|
|
7045
7057
|
...args,
|
|
7046
7058
|
schema
|
|
7047
7059
|
});
|
|
7048
|
-
case "tuple": return tupleToAst$
|
|
7060
|
+
case "tuple": return tupleToAst$3({
|
|
7049
7061
|
...args,
|
|
7050
7062
|
schema
|
|
7051
7063
|
});
|
|
7052
|
-
case "undefined": return undefinedToAst$
|
|
7064
|
+
case "undefined": return undefinedToAst$3({
|
|
7053
7065
|
...args,
|
|
7054
7066
|
schema
|
|
7055
7067
|
});
|
|
7056
|
-
case "unknown": return unknownToAst$
|
|
7068
|
+
case "unknown": return unknownToAst$3({
|
|
7057
7069
|
...args,
|
|
7058
7070
|
schema
|
|
7059
7071
|
});
|
|
7060
|
-
case "void": return voidToAst$
|
|
7072
|
+
case "void": return voidToAst$3({
|
|
7061
7073
|
...args,
|
|
7062
7074
|
schema
|
|
7063
7075
|
});
|
|
@@ -7066,7 +7078,7 @@ function irSchemaWithTypeToAst$5({ schema, ...args }) {
|
|
|
7066
7078
|
|
|
7067
7079
|
//#endregion
|
|
7068
7080
|
//#region src/plugins/@hey-api/typescript/v1/plugin.ts
|
|
7069
|
-
function irSchemaToAst$
|
|
7081
|
+
function irSchemaToAst$1({ plugin, schema, schemaExtractor, state }) {
|
|
7070
7082
|
if (schemaExtractor && !schema.$ref) {
|
|
7071
7083
|
const extracted = schemaExtractor({
|
|
7072
7084
|
meta: {
|
|
@@ -7099,7 +7111,7 @@ function irSchemaToAst$5({ plugin, schema, schemaExtractor, state }) {
|
|
|
7099
7111
|
}
|
|
7100
7112
|
return baseType;
|
|
7101
7113
|
}
|
|
7102
|
-
if (schema.type) return irSchemaWithTypeToAst$
|
|
7114
|
+
if (schema.type) return irSchemaWithTypeToAst$1({
|
|
7103
7115
|
plugin,
|
|
7104
7116
|
schema,
|
|
7105
7117
|
state
|
|
@@ -7110,20 +7122,20 @@ function irSchemaToAst$5({ plugin, schema, schemaExtractor, state }) {
|
|
|
7110
7122
|
schema
|
|
7111
7123
|
});
|
|
7112
7124
|
if (schema.items) {
|
|
7113
|
-
const itemTypes = schema.items.map((item) => irSchemaToAst$
|
|
7125
|
+
const itemTypes = schema.items.map((item) => irSchemaToAst$1({
|
|
7114
7126
|
plugin,
|
|
7115
7127
|
schema: item,
|
|
7116
7128
|
state
|
|
7117
7129
|
}));
|
|
7118
7130
|
return schema.logicalOperator === "and" ? $.type.and(...itemTypes) : $.type.or(...itemTypes);
|
|
7119
7131
|
}
|
|
7120
|
-
return irSchemaToAst$
|
|
7132
|
+
return irSchemaToAst$1({
|
|
7121
7133
|
plugin,
|
|
7122
7134
|
schema,
|
|
7123
7135
|
state
|
|
7124
7136
|
});
|
|
7125
7137
|
}
|
|
7126
|
-
return irSchemaWithTypeToAst$
|
|
7138
|
+
return irSchemaWithTypeToAst$1({
|
|
7127
7139
|
plugin,
|
|
7128
7140
|
schema: { type: "unknown" },
|
|
7129
7141
|
state
|
|
@@ -7134,7 +7146,7 @@ function handleComponent$1({ plugin, schema, state }) {
|
|
|
7134
7146
|
plugin,
|
|
7135
7147
|
schema,
|
|
7136
7148
|
state,
|
|
7137
|
-
type: irSchemaToAst$
|
|
7149
|
+
type: irSchemaToAst$1({
|
|
7138
7150
|
plugin,
|
|
7139
7151
|
schema,
|
|
7140
7152
|
state
|
|
@@ -7213,7 +7225,7 @@ const handlerV1$1 = ({ plugin }) => {
|
|
|
7213
7225
|
//#region src/plugins/@hey-api/typescript/api.ts
|
|
7214
7226
|
var Api$3 = class {
|
|
7215
7227
|
schemaToType(args) {
|
|
7216
|
-
return irSchemaToAst$
|
|
7228
|
+
return irSchemaToAst$1(args);
|
|
7217
7229
|
}
|
|
7218
7230
|
};
|
|
7219
7231
|
|
|
@@ -7835,6 +7847,7 @@ const createInfiniteQueryOptions = ({ operation, plugin }) => {
|
|
|
7835
7847
|
//#endregion
|
|
7836
7848
|
//#region src/plugins/@tanstack/query-core/v5/mutationOptions.ts
|
|
7837
7849
|
const createMutationOptions = ({ operation, plugin }) => {
|
|
7850
|
+
if (hasOperationSse({ operation })) return;
|
|
7838
7851
|
const symbolMutationOptionsType = plugin.external(`${plugin.name}.MutationOptions`);
|
|
7839
7852
|
const typeData = useTypeData({
|
|
7840
7853
|
operation,
|
|
@@ -8556,7 +8569,7 @@ function exportAst$2({ ast, plugin, schema, symbol, typeInferSymbol }) {
|
|
|
8556
8569
|
|
|
8557
8570
|
//#endregion
|
|
8558
8571
|
//#region src/plugins/arktype/v2/toAst/null.ts
|
|
8559
|
-
const nullToAst$
|
|
8572
|
+
const nullToAst$3 = (_args) => {
|
|
8560
8573
|
const result = {};
|
|
8561
8574
|
result.def = identifiers$2.primitives.null;
|
|
8562
8575
|
return result;
|
|
@@ -8564,14 +8577,14 @@ const nullToAst$4 = (_args) => {
|
|
|
8564
8577
|
|
|
8565
8578
|
//#endregion
|
|
8566
8579
|
//#region src/plugins/arktype/v2/toAst/object.ts
|
|
8567
|
-
|
|
8580
|
+
function objectToAst$3({ plugin, schema, state }) {
|
|
8568
8581
|
const result = {};
|
|
8569
8582
|
const shape = $.object().pretty();
|
|
8570
8583
|
const required = schema.required ?? [];
|
|
8571
8584
|
for (const name in schema.properties) {
|
|
8572
8585
|
const property = schema.properties[name];
|
|
8573
8586
|
const isRequired = required.includes(name);
|
|
8574
|
-
const propertyAst = irSchemaToAst
|
|
8587
|
+
const propertyAst = irSchemaToAst({
|
|
8575
8588
|
optional: !isRequired,
|
|
8576
8589
|
plugin,
|
|
8577
8590
|
schema: property,
|
|
@@ -8588,7 +8601,7 @@ const objectToAst$4 = ({ plugin, schema, state }) => {
|
|
|
8588
8601
|
shape.prop(isRequired ? name : `${name}?`, propertyAst.expression);
|
|
8589
8602
|
}
|
|
8590
8603
|
if (schema.additionalProperties && (!schema.properties || !Object.keys(schema.properties).length)) {
|
|
8591
|
-
const additionalAst = irSchemaToAst
|
|
8604
|
+
const additionalAst = irSchemaToAst({
|
|
8592
8605
|
plugin,
|
|
8593
8606
|
schema: schema.additionalProperties,
|
|
8594
8607
|
state: {
|
|
@@ -8606,7 +8619,7 @@ const objectToAst$4 = ({ plugin, schema, state }) => {
|
|
|
8606
8619
|
typeName: "TODO"
|
|
8607
8620
|
};
|
|
8608
8621
|
return result;
|
|
8609
|
-
}
|
|
8622
|
+
}
|
|
8610
8623
|
|
|
8611
8624
|
//#endregion
|
|
8612
8625
|
//#region src/plugins/arktype/v2/toAst/string.ts
|
|
@@ -8651,13 +8664,13 @@ const stringToAst = ({ schema }) => {
|
|
|
8651
8664
|
|
|
8652
8665
|
//#endregion
|
|
8653
8666
|
//#region src/plugins/arktype/v2/toAst/index.ts
|
|
8654
|
-
function irSchemaWithTypeToAst
|
|
8667
|
+
function irSchemaWithTypeToAst({ schema, ...args }) {
|
|
8655
8668
|
switch (schema.type) {
|
|
8656
|
-
case "null": return nullToAst$
|
|
8669
|
+
case "null": return nullToAst$3({
|
|
8657
8670
|
...args,
|
|
8658
8671
|
schema
|
|
8659
8672
|
});
|
|
8660
|
-
case "object": return objectToAst$
|
|
8673
|
+
case "object": return objectToAst$3({
|
|
8661
8674
|
...args,
|
|
8662
8675
|
schema
|
|
8663
8676
|
});
|
|
@@ -8675,7 +8688,7 @@ function irSchemaWithTypeToAst$4({ schema, ...args }) {
|
|
|
8675
8688
|
|
|
8676
8689
|
//#endregion
|
|
8677
8690
|
//#region src/plugins/arktype/v2/plugin.ts
|
|
8678
|
-
function irSchemaToAst
|
|
8691
|
+
function irSchemaToAst({ plugin, schema, schemaExtractor, state }) {
|
|
8679
8692
|
if (schemaExtractor && !schema.$ref) {
|
|
8680
8693
|
const extracted = schemaExtractor({
|
|
8681
8694
|
meta: {
|
|
@@ -8706,7 +8719,7 @@ function irSchemaToAst$4({ plugin, schema, schemaExtractor, state }) {
|
|
|
8706
8719
|
state.hasLazyExpression["~ref"] = true;
|
|
8707
8720
|
}
|
|
8708
8721
|
} else if (schema.type) {
|
|
8709
|
-
const typeAst = irSchemaWithTypeToAst
|
|
8722
|
+
const typeAst = irSchemaWithTypeToAst({
|
|
8710
8723
|
plugin,
|
|
8711
8724
|
schema,
|
|
8712
8725
|
state
|
|
@@ -8717,13 +8730,13 @@ function irSchemaToAst$4({ plugin, schema, schemaExtractor, state }) {
|
|
|
8717
8730
|
if (plugin.config.metadata && schema.description) {}
|
|
8718
8731
|
} else if (schema.items) {
|
|
8719
8732
|
schema = deduplicateSchema({ schema });
|
|
8720
|
-
if (schema.items) {} else ast = irSchemaToAst
|
|
8733
|
+
if (schema.items) {} else ast = irSchemaToAst({
|
|
8721
8734
|
plugin,
|
|
8722
8735
|
schema,
|
|
8723
8736
|
state
|
|
8724
8737
|
});
|
|
8725
8738
|
} else {
|
|
8726
|
-
const typeAst = irSchemaWithTypeToAst
|
|
8739
|
+
const typeAst = irSchemaWithTypeToAst({
|
|
8727
8740
|
plugin,
|
|
8728
8741
|
schema: { type: "unknown" },
|
|
8729
8742
|
state
|
|
@@ -8732,7 +8745,7 @@ function irSchemaToAst$4({ plugin, schema, schemaExtractor, state }) {
|
|
|
8732
8745
|
ast.expression = typeAst.expression;
|
|
8733
8746
|
}
|
|
8734
8747
|
if (!ast.expression) {
|
|
8735
|
-
const typeAst = irSchemaWithTypeToAst
|
|
8748
|
+
const typeAst = irSchemaWithTypeToAst({
|
|
8736
8749
|
plugin,
|
|
8737
8750
|
schema: { type: "unknown" },
|
|
8738
8751
|
state
|
|
@@ -8743,7 +8756,7 @@ function irSchemaToAst$4({ plugin, schema, schemaExtractor, state }) {
|
|
|
8743
8756
|
}
|
|
8744
8757
|
function handleComponent({ plugin, schema, state }) {
|
|
8745
8758
|
const $ref = pathToJsonPointer(fromRef(state.path));
|
|
8746
|
-
const ast = irSchemaToAst
|
|
8759
|
+
const ast = irSchemaToAst({
|
|
8747
8760
|
plugin,
|
|
8748
8761
|
schema,
|
|
8749
8762
|
state
|
|
@@ -9476,23 +9489,33 @@ const identifiers$1 = {
|
|
|
9476
9489
|
|
|
9477
9490
|
//#endregion
|
|
9478
9491
|
//#region src/plugins/valibot/shared/pipes.ts
|
|
9479
|
-
|
|
9492
|
+
function push(target, result) {
|
|
9493
|
+
if (result === void 0) return target;
|
|
9494
|
+
if (result instanceof Array) target.push(...result);
|
|
9495
|
+
else target.push(result);
|
|
9496
|
+
return target;
|
|
9497
|
+
}
|
|
9498
|
+
function toNode(pipes$1, plugin) {
|
|
9480
9499
|
if (!(pipes$1 instanceof Array)) return pipes$1;
|
|
9500
|
+
if (pipes$1.length === 0) return $(plugin.external("valibot.v")).attr(identifiers$1.schemas.unknown).call();
|
|
9481
9501
|
if (pipes$1.length === 1) return pipes$1[0];
|
|
9482
9502
|
return $(plugin.external("valibot.v")).attr(identifiers$1.methods.pipe).call(...pipes$1);
|
|
9483
|
-
}
|
|
9484
|
-
const pushPipes = (target, pipes$1) => {
|
|
9485
|
-
if (pipes$1 instanceof Array) target.push(...pipes$1);
|
|
9486
|
-
else target.push(pipes$1);
|
|
9487
|
-
return target;
|
|
9488
|
-
};
|
|
9503
|
+
}
|
|
9489
9504
|
/**
|
|
9490
9505
|
* Functions for working with pipes.
|
|
9491
9506
|
*/
|
|
9492
9507
|
const pipes = {
|
|
9493
|
-
push
|
|
9494
|
-
toNode
|
|
9508
|
+
push,
|
|
9509
|
+
toNode
|
|
9495
9510
|
};
|
|
9511
|
+
/**
|
|
9512
|
+
* Convenience function for converting pipes to a node.
|
|
9513
|
+
*
|
|
9514
|
+
* Re-exported for backward compatibility.
|
|
9515
|
+
*/
|
|
9516
|
+
function pipesToNode(p, plugin) {
|
|
9517
|
+
return toNode(p, plugin);
|
|
9518
|
+
}
|
|
9496
9519
|
|
|
9497
9520
|
//#endregion
|
|
9498
9521
|
//#region src/plugins/valibot/v1/api.ts
|
|
@@ -9572,19 +9595,6 @@ var Api$1 = class {
|
|
|
9572
9595
|
}
|
|
9573
9596
|
};
|
|
9574
9597
|
|
|
9575
|
-
//#endregion
|
|
9576
|
-
//#region src/plugins/shared/utils/coerce.ts
|
|
9577
|
-
const shouldCoerceToBigInt = (format) => format === "int64" || format === "uint64";
|
|
9578
|
-
const maybeBigInt = (value, format) => {
|
|
9579
|
-
if (!shouldCoerceToBigInt(format)) return $.fromValue(value);
|
|
9580
|
-
if (typeof value === "string") {
|
|
9581
|
-
if (value.endsWith("n")) value = value.slice(0, -1);
|
|
9582
|
-
return $("BigInt").call($.fromValue(value));
|
|
9583
|
-
}
|
|
9584
|
-
if (typeof value === "number") return $("BigInt").call($.fromValue(value));
|
|
9585
|
-
return $.fromValue(value);
|
|
9586
|
-
};
|
|
9587
|
-
|
|
9588
9598
|
//#endregion
|
|
9589
9599
|
//#region src/plugins/valibot/shared/operation-schema.ts
|
|
9590
9600
|
function buildOperationSchema$1(operation) {
|
|
@@ -9694,7 +9704,7 @@ function irWebhookToAst$1({ operation, path: path$1, plugin, processor, tags })
|
|
|
9694
9704
|
|
|
9695
9705
|
//#endregion
|
|
9696
9706
|
//#region src/plugins/valibot/shared/export.ts
|
|
9697
|
-
function exportAst$1({
|
|
9707
|
+
function exportAst$1({ final, meta, naming, namingAnchor, path: path$1, plugin, schema, tags }) {
|
|
9698
9708
|
const v = plugin.external("valibot.v");
|
|
9699
9709
|
const name = pathToName(path$1, { anchor: namingAnchor });
|
|
9700
9710
|
const symbol = plugin.symbol(applyNaming(name, naming), { meta: {
|
|
@@ -9704,132 +9714,114 @@ function exportAst$1({ ast, meta, naming, namingAnchor, path: path$1, plugin, sc
|
|
|
9704
9714
|
tool: "valibot",
|
|
9705
9715
|
...meta
|
|
9706
9716
|
} });
|
|
9707
|
-
const statement = $.const(symbol).export().$if(plugin.config.comments && createSchemaComment(schema), (c, v$1) => c.doc(v$1)).$if(
|
|
9717
|
+
const statement = $.const(symbol).export().$if(plugin.config.comments && createSchemaComment(schema), (c, v$1) => c.doc(v$1)).$if(final.typeName, (c) => c.type($.type(v).attr(final.typeName))).assign(pipesToNode(final.pipes, plugin));
|
|
9708
9718
|
plugin.node(statement);
|
|
9709
9719
|
}
|
|
9710
9720
|
|
|
9711
9721
|
//#endregion
|
|
9712
|
-
//#region src/plugins/
|
|
9713
|
-
|
|
9714
|
-
|
|
9715
|
-
|
|
9716
|
-
|
|
9717
|
-
if (
|
|
9718
|
-
|
|
9719
|
-
process$1({
|
|
9720
|
-
namingAnchor: processor.context.anchor,
|
|
9721
|
-
tags: processor.context.tags,
|
|
9722
|
-
...ctx$1
|
|
9723
|
-
});
|
|
9724
|
-
return { $ref: pathToJsonPointer(ctx$1.path) };
|
|
9725
|
-
}
|
|
9726
|
-
return ctx$1.schema;
|
|
9727
|
-
}
|
|
9728
|
-
function process$1(ctx$1) {
|
|
9729
|
-
if (!processor.markEmitted(ctx$1.path)) return;
|
|
9730
|
-
processor.withContext({
|
|
9731
|
-
anchor: ctx$1.namingAnchor,
|
|
9732
|
-
tags: ctx$1.tags
|
|
9733
|
-
}, () => {
|
|
9734
|
-
const state = refs({
|
|
9735
|
-
hasLazyExpression: false,
|
|
9736
|
-
path: ctx$1.path,
|
|
9737
|
-
tags: ctx$1.tags
|
|
9738
|
-
});
|
|
9739
|
-
const ast = irSchemaToAst$3({
|
|
9740
|
-
plugin,
|
|
9741
|
-
schema: ctx$1.schema,
|
|
9742
|
-
schemaExtractor: extractor,
|
|
9743
|
-
state
|
|
9744
|
-
});
|
|
9745
|
-
exportAst$1({
|
|
9746
|
-
...ctx$1,
|
|
9747
|
-
ast,
|
|
9748
|
-
plugin,
|
|
9749
|
-
state
|
|
9750
|
-
});
|
|
9751
|
-
});
|
|
9722
|
+
//#region src/plugins/shared/utils/coerce.ts
|
|
9723
|
+
const shouldCoerceToBigInt = (format) => format === "int64" || format === "uint64";
|
|
9724
|
+
const maybeBigInt = (value, format) => {
|
|
9725
|
+
if (!shouldCoerceToBigInt(format)) return $.fromValue(value);
|
|
9726
|
+
if (typeof value === "string") {
|
|
9727
|
+
if (value.endsWith("n")) value = value.slice(0, -1);
|
|
9728
|
+
return $("BigInt").call($.fromValue(value));
|
|
9752
9729
|
}
|
|
9753
|
-
|
|
9730
|
+
if (typeof value === "number") return $("BigInt").call($.fromValue(value));
|
|
9731
|
+
return $.fromValue(value);
|
|
9732
|
+
};
|
|
9733
|
+
|
|
9734
|
+
//#endregion
|
|
9735
|
+
//#region src/plugins/valibot/shared/meta.ts
|
|
9736
|
+
/**
|
|
9737
|
+
* Creates default metadata from a schema.
|
|
9738
|
+
*/
|
|
9739
|
+
function defaultMeta(schema) {
|
|
9740
|
+
return {
|
|
9741
|
+
default: schema.default,
|
|
9742
|
+
format: schema.format,
|
|
9743
|
+
hasLazy: false,
|
|
9744
|
+
nullable: false,
|
|
9745
|
+
readonly: schema.accessScope === "read"
|
|
9746
|
+
};
|
|
9747
|
+
}
|
|
9748
|
+
/**
|
|
9749
|
+
* Composes metadata from child results.
|
|
9750
|
+
*
|
|
9751
|
+
* Automatically propagates hasLazy, nullable, readonly from children.
|
|
9752
|
+
*
|
|
9753
|
+
* @param children - Results from walking child schemas
|
|
9754
|
+
* @param overrides - Explicit overrides (e.g., from parent schema)
|
|
9755
|
+
*/
|
|
9756
|
+
function composeMeta(children, overrides) {
|
|
9757
|
+
return {
|
|
9758
|
+
default: overrides?.default,
|
|
9759
|
+
format: overrides?.format,
|
|
9760
|
+
hasLazy: overrides?.hasLazy ?? children.some((c) => c.meta.hasLazy),
|
|
9761
|
+
nullable: overrides?.nullable ?? children.some((c) => c.meta.nullable),
|
|
9762
|
+
readonly: overrides?.readonly ?? children.some((c) => c.meta.readonly)
|
|
9763
|
+
};
|
|
9764
|
+
}
|
|
9765
|
+
/**
|
|
9766
|
+
* Merges parent schema metadata with composed child metadata.
|
|
9767
|
+
*
|
|
9768
|
+
* @param parent - The parent schema
|
|
9769
|
+
* @param children - Results from walking child schemas
|
|
9770
|
+
*/
|
|
9771
|
+
function inheritMeta(parent, children) {
|
|
9772
|
+
return composeMeta(children, {
|
|
9773
|
+
default: parent.default,
|
|
9774
|
+
format: parent.format,
|
|
9775
|
+
nullable: false,
|
|
9776
|
+
readonly: parent.accessScope === "read"
|
|
9777
|
+
});
|
|
9754
9778
|
}
|
|
9755
9779
|
|
|
9756
9780
|
//#endregion
|
|
9757
9781
|
//#region src/plugins/valibot/v1/toAst/unknown.ts
|
|
9758
|
-
function
|
|
9782
|
+
function unknownToPipes({ plugin }) {
|
|
9759
9783
|
return $(plugin.external("valibot.v")).attr(identifiers$1.schemas.unknown).call();
|
|
9760
9784
|
}
|
|
9761
9785
|
|
|
9762
9786
|
//#endregion
|
|
9763
9787
|
//#region src/plugins/valibot/v1/toAst/array.ts
|
|
9764
|
-
function
|
|
9765
|
-
const { plugin } =
|
|
9766
|
-
let { schema } =
|
|
9767
|
-
const result = { pipes: [] };
|
|
9788
|
+
function arrayToPipes(ctx$1) {
|
|
9789
|
+
const { plugin, walk, walkerCtx } = ctx$1;
|
|
9790
|
+
let { schema } = ctx$1;
|
|
9768
9791
|
const v = plugin.external("valibot.v");
|
|
9769
|
-
const
|
|
9770
|
-
|
|
9771
|
-
|
|
9772
|
-
|
|
9773
|
-
|
|
9774
|
-
}));
|
|
9775
|
-
result.pipes.push(expression);
|
|
9776
|
-
} else {
|
|
9792
|
+
const arrayFn = $(v).attr(identifiers$1.schemas.array);
|
|
9793
|
+
const childResults = [];
|
|
9794
|
+
const resultPipes = [];
|
|
9795
|
+
if (!schema.items) resultPipes.push(arrayFn.call(unknownToPipes({ plugin })));
|
|
9796
|
+
else {
|
|
9777
9797
|
schema = deduplicateSchema({ schema });
|
|
9778
|
-
|
|
9779
|
-
const
|
|
9780
|
-
|
|
9781
|
-
|
|
9782
|
-
state: {
|
|
9783
|
-
...options.state,
|
|
9784
|
-
path: ref([
|
|
9785
|
-
...fromRef(options.state.path),
|
|
9786
|
-
"items",
|
|
9787
|
-
index
|
|
9788
|
-
])
|
|
9789
|
-
}
|
|
9790
|
-
});
|
|
9791
|
-
if (itemAst.hasLazyExpression) result.hasLazyExpression = true;
|
|
9792
|
-
return pipesToNode(itemAst.pipes, plugin);
|
|
9793
|
-
});
|
|
9794
|
-
if (itemExpressions.length === 1) {
|
|
9795
|
-
const expression = functionName.call(...itemExpressions);
|
|
9796
|
-
result.pipes.push(expression);
|
|
9797
|
-
} else {
|
|
9798
|
-
if (schema.logicalOperator === "and") {}
|
|
9799
|
-
const expression = functionName.call(unknownToAst$3({
|
|
9800
|
-
...options,
|
|
9801
|
-
schema: { type: "unknown" }
|
|
9802
|
-
}));
|
|
9803
|
-
result.pipes.push(expression);
|
|
9798
|
+
for (let i = 0; i < schema.items.length; i++) {
|
|
9799
|
+
const item = schema.items[i];
|
|
9800
|
+
const result = walk(item, childContext(walkerCtx, "items", i));
|
|
9801
|
+
childResults.push(result);
|
|
9804
9802
|
}
|
|
9803
|
+
if (childResults.length === 1) {
|
|
9804
|
+
const itemNode = pipesToNode(ctx$1.applyModifiers(childResults[0]).pipes, plugin);
|
|
9805
|
+
resultPipes.push(arrayFn.call(itemNode));
|
|
9806
|
+
} else resultPipes.push(arrayFn.call(unknownToPipes({ plugin })));
|
|
9805
9807
|
}
|
|
9806
|
-
if (schema.minItems === schema.maxItems && schema.minItems !== void 0)
|
|
9807
|
-
|
|
9808
|
-
|
|
9809
|
-
|
|
9810
|
-
if (schema.minItems !== void 0) {
|
|
9811
|
-
const expression = $(v).attr(identifiers$1.actions.minLength).call($.fromValue(schema.minItems));
|
|
9812
|
-
result.pipes.push(expression);
|
|
9813
|
-
}
|
|
9814
|
-
if (schema.maxItems !== void 0) {
|
|
9815
|
-
const expression = $(v).attr(identifiers$1.actions.maxLength).call($.fromValue(schema.maxItems));
|
|
9816
|
-
result.pipes.push(expression);
|
|
9817
|
-
}
|
|
9808
|
+
if (schema.minItems === schema.maxItems && schema.minItems !== void 0) resultPipes.push($(v).attr(identifiers$1.actions.length).call($.fromValue(schema.minItems)));
|
|
9809
|
+
else {
|
|
9810
|
+
if (schema.minItems !== void 0) resultPipes.push($(v).attr(identifiers$1.actions.minLength).call($.fromValue(schema.minItems)));
|
|
9811
|
+
if (schema.maxItems !== void 0) resultPipes.push($(v).attr(identifiers$1.actions.maxLength).call($.fromValue(schema.maxItems)));
|
|
9818
9812
|
}
|
|
9819
|
-
return
|
|
9813
|
+
return {
|
|
9814
|
+
childResults,
|
|
9815
|
+
pipes: resultPipes
|
|
9816
|
+
};
|
|
9820
9817
|
}
|
|
9821
9818
|
|
|
9822
9819
|
//#endregion
|
|
9823
9820
|
//#region src/plugins/valibot/v1/toAst/boolean.ts
|
|
9824
|
-
function
|
|
9825
|
-
const pipes$1 = [];
|
|
9821
|
+
function booleanToPipes({ plugin, schema }) {
|
|
9826
9822
|
const v = plugin.external("valibot.v");
|
|
9827
|
-
if (typeof schema.const === "boolean")
|
|
9828
|
-
|
|
9829
|
-
return pipesToNode(pipes$1, plugin);
|
|
9830
|
-
}
|
|
9831
|
-
pipes$1.push($(v).attr(identifiers$1.schemas.boolean).call());
|
|
9832
|
-
return pipesToNode(pipes$1, plugin);
|
|
9823
|
+
if (typeof schema.const === "boolean") return $(v).attr(identifiers$1.schemas.literal).call($.literal(schema.const));
|
|
9824
|
+
return $(v).attr(identifiers$1.schemas.boolean).call();
|
|
9833
9825
|
}
|
|
9834
9826
|
|
|
9835
9827
|
//#endregion
|
|
@@ -9851,31 +9843,20 @@ function baseNode$15(ctx$1) {
|
|
|
9851
9843
|
const { enumMembers } = ctx$1.nodes.items(ctx$1);
|
|
9852
9844
|
return $(v).attr(identifiers$1.schemas.picklist).call($.array(...enumMembers));
|
|
9853
9845
|
}
|
|
9854
|
-
function nullableNode$3(ctx$1) {
|
|
9855
|
-
const { symbols } = ctx$1;
|
|
9856
|
-
const { v } = symbols;
|
|
9857
|
-
const { isNullable } = ctx$1.nodes.items(ctx$1);
|
|
9858
|
-
if (!isNullable) return;
|
|
9859
|
-
const currentNode = ctx$1.pipes.toNode(ctx$1.pipes.current, ctx$1.plugin);
|
|
9860
|
-
return $(v).attr(identifiers$1.schemas.nullable).call(currentNode);
|
|
9861
|
-
}
|
|
9862
9846
|
function enumResolver$3(ctx$1) {
|
|
9863
9847
|
const { enumMembers } = ctx$1.nodes.items(ctx$1);
|
|
9864
9848
|
if (!enumMembers.length) return ctx$1.pipes.current;
|
|
9865
9849
|
const baseExpression = ctx$1.nodes.base(ctx$1);
|
|
9866
9850
|
ctx$1.pipes.push(ctx$1.pipes.current, baseExpression);
|
|
9867
|
-
const nullableExpression = ctx$1.nodes.nullable(ctx$1);
|
|
9868
|
-
if (nullableExpression) return nullableExpression;
|
|
9869
9851
|
return ctx$1.pipes.current;
|
|
9870
9852
|
}
|
|
9871
|
-
function
|
|
9853
|
+
function enumToPipes({ plugin, schema }) {
|
|
9872
9854
|
const v = plugin.external("valibot.v");
|
|
9873
|
-
const { enumMembers } = itemsNode$3({
|
|
9855
|
+
const { enumMembers, isNullable } = itemsNode$3({
|
|
9874
9856
|
$,
|
|
9875
9857
|
nodes: {
|
|
9876
9858
|
base: baseNode$15,
|
|
9877
|
-
items: itemsNode$3
|
|
9878
|
-
nullable: nullableNode$3
|
|
9859
|
+
items: itemsNode$3
|
|
9879
9860
|
},
|
|
9880
9861
|
pipes: {
|
|
9881
9862
|
...pipes,
|
|
@@ -9883,20 +9864,17 @@ function enumToAst$3({ plugin, schema, state }) {
|
|
|
9883
9864
|
},
|
|
9884
9865
|
plugin,
|
|
9885
9866
|
schema,
|
|
9886
|
-
symbols: { v }
|
|
9887
|
-
utils: { state }
|
|
9888
|
-
});
|
|
9889
|
-
if (!enumMembers.length) return unknownToAst$3({
|
|
9890
|
-
plugin,
|
|
9891
|
-
schema: { type: "unknown" },
|
|
9892
|
-
state
|
|
9867
|
+
symbols: { v }
|
|
9893
9868
|
});
|
|
9869
|
+
if (!enumMembers.length) return {
|
|
9870
|
+
isNullable,
|
|
9871
|
+
pipe: unknownToPipes({ plugin })
|
|
9872
|
+
};
|
|
9894
9873
|
const ctx$1 = {
|
|
9895
9874
|
$,
|
|
9896
9875
|
nodes: {
|
|
9897
9876
|
base: baseNode$15,
|
|
9898
|
-
items: itemsNode$3
|
|
9899
|
-
nullable: nullableNode$3
|
|
9877
|
+
items: itemsNode$3
|
|
9900
9878
|
},
|
|
9901
9879
|
pipes: {
|
|
9902
9880
|
...pipes,
|
|
@@ -9904,23 +9882,25 @@ function enumToAst$3({ plugin, schema, state }) {
|
|
|
9904
9882
|
},
|
|
9905
9883
|
plugin,
|
|
9906
9884
|
schema,
|
|
9907
|
-
symbols: { v }
|
|
9908
|
-
utils: { state }
|
|
9885
|
+
symbols: { v }
|
|
9909
9886
|
};
|
|
9910
9887
|
const resolver = plugin.config["~resolvers"]?.enum;
|
|
9911
9888
|
const node = resolver?.(ctx$1) ?? enumResolver$3(ctx$1);
|
|
9912
|
-
return
|
|
9889
|
+
return {
|
|
9890
|
+
isNullable,
|
|
9891
|
+
pipe: ctx$1.pipes.toNode(node, plugin)
|
|
9892
|
+
};
|
|
9913
9893
|
}
|
|
9914
9894
|
|
|
9915
9895
|
//#endregion
|
|
9916
9896
|
//#region src/plugins/valibot/v1/toAst/never.ts
|
|
9917
|
-
function
|
|
9897
|
+
function neverToPipes({ plugin }) {
|
|
9918
9898
|
return $(plugin.external("valibot.v")).attr(identifiers$1.schemas.never).call();
|
|
9919
9899
|
}
|
|
9920
9900
|
|
|
9921
9901
|
//#endregion
|
|
9922
9902
|
//#region src/plugins/valibot/v1/toAst/null.ts
|
|
9923
|
-
function
|
|
9903
|
+
function nullToPipes({ plugin }) {
|
|
9924
9904
|
return $(plugin.external("valibot.v")).attr(identifiers$1.schemas.null).call();
|
|
9925
9905
|
}
|
|
9926
9906
|
|
|
@@ -9958,10 +9938,10 @@ function baseNode$14(ctx$1) {
|
|
|
9958
9938
|
const { schema, symbols } = ctx$1;
|
|
9959
9939
|
const { v } = symbols;
|
|
9960
9940
|
if (ctx$1.utils.shouldCoerceToBigInt(schema.format)) return [$(v).attr(identifiers$1.schemas.union).call($.array($(v).attr(identifiers$1.schemas.number).call(), $(v).attr(identifiers$1.schemas.string).call(), $(v).attr(identifiers$1.schemas.bigInt).call())), $(v).attr(identifiers$1.actions.transform).call($.func().param("x").do($("BigInt").call("x").return()))];
|
|
9961
|
-
const
|
|
9962
|
-
|
|
9963
|
-
if (schema.type === "integer")
|
|
9964
|
-
return
|
|
9941
|
+
const result = [];
|
|
9942
|
+
result.push($(v).attr(identifiers$1.schemas.number).call());
|
|
9943
|
+
if (schema.type === "integer") result.push($(v).attr(identifiers$1.actions.integer).call());
|
|
9944
|
+
return result;
|
|
9965
9945
|
}
|
|
9966
9946
|
function constNode$7(ctx$1) {
|
|
9967
9947
|
const { schema, symbols } = ctx$1;
|
|
@@ -9986,17 +9966,17 @@ function minNode$3(ctx$1) {
|
|
|
9986
9966
|
if (limit) return $(v).attr(identifiers$1.actions.minValue).call(ctx$1.utils.maybeBigInt(limit.minValue, schema.format), $.literal(limit.minError));
|
|
9987
9967
|
}
|
|
9988
9968
|
function numberResolver$3(ctx$1) {
|
|
9989
|
-
const
|
|
9990
|
-
if (
|
|
9991
|
-
const
|
|
9992
|
-
if (
|
|
9993
|
-
const
|
|
9994
|
-
if (
|
|
9995
|
-
const
|
|
9996
|
-
if (
|
|
9969
|
+
const constResult = ctx$1.nodes.const(ctx$1);
|
|
9970
|
+
if (constResult) return ctx$1.pipes.push(ctx$1.pipes.current, constResult);
|
|
9971
|
+
const baseResult = ctx$1.nodes.base(ctx$1);
|
|
9972
|
+
if (baseResult) ctx$1.pipes.push(ctx$1.pipes.current, baseResult);
|
|
9973
|
+
const minResult = ctx$1.nodes.min(ctx$1);
|
|
9974
|
+
if (minResult) ctx$1.pipes.push(ctx$1.pipes.current, minResult);
|
|
9975
|
+
const maxResult = ctx$1.nodes.max(ctx$1);
|
|
9976
|
+
if (maxResult) ctx$1.pipes.push(ctx$1.pipes.current, maxResult);
|
|
9997
9977
|
return ctx$1.pipes.current;
|
|
9998
9978
|
}
|
|
9999
|
-
function
|
|
9979
|
+
function numberToPipes({ plugin, schema }) {
|
|
10000
9980
|
const ctx$1 = {
|
|
10001
9981
|
$,
|
|
10002
9982
|
nodes: {
|
|
@@ -10026,25 +10006,17 @@ function numberToNode$3({ plugin, schema }) {
|
|
|
10026
10006
|
//#endregion
|
|
10027
10007
|
//#region src/plugins/valibot/v1/toAst/object.ts
|
|
10028
10008
|
function additionalPropertiesNode$3(ctx$1) {
|
|
10029
|
-
const {
|
|
10009
|
+
const { schema } = ctx$1;
|
|
10030
10010
|
if (!schema.additionalProperties || !schema.additionalProperties.type) return;
|
|
10031
10011
|
if (schema.additionalProperties.type === "never") return null;
|
|
10032
|
-
const
|
|
10033
|
-
|
|
10034
|
-
|
|
10035
|
-
state: {
|
|
10036
|
-
...ctx$1.utils.state,
|
|
10037
|
-
path: ref([...fromRef(ctx$1.utils.state.path), "additionalProperties"])
|
|
10038
|
-
}
|
|
10039
|
-
});
|
|
10040
|
-
if (additionalAst.hasLazyExpression) ctx$1.utils.ast.hasLazyExpression = true;
|
|
10041
|
-
return pipes.toNode(additionalAst.pipes, plugin);
|
|
10012
|
+
const additionalResult = ctx$1.walk(schema.additionalProperties, childContext(ctx$1.walkerCtx, "additionalProperties"));
|
|
10013
|
+
ctx$1._childResults.push(additionalResult);
|
|
10014
|
+
return pipesToNode(additionalResult.pipes, ctx$1.plugin);
|
|
10042
10015
|
}
|
|
10043
10016
|
function baseNode$13(ctx$1) {
|
|
10044
|
-
const {
|
|
10045
|
-
const
|
|
10046
|
-
const
|
|
10047
|
-
const shape = nodes.shape(ctx$1);
|
|
10017
|
+
const { v } = ctx$1.symbols;
|
|
10018
|
+
const additional = ctx$1.nodes.additionalProperties(ctx$1);
|
|
10019
|
+
const shape = ctx$1.nodes.shape(ctx$1);
|
|
10048
10020
|
if (additional === null) return $(v).attr(identifiers$1.schemas.strictObject).call(shape);
|
|
10049
10021
|
if (additional) {
|
|
10050
10022
|
if (shape.isEmpty) return $(v).attr(identifiers$1.schemas.record).call($(v).attr(identifiers$1.schemas.string).call(), additional);
|
|
@@ -10056,33 +10028,25 @@ function objectResolver$3(ctx$1) {
|
|
|
10056
10028
|
return ctx$1.nodes.base(ctx$1);
|
|
10057
10029
|
}
|
|
10058
10030
|
function shapeNode$3(ctx$1) {
|
|
10059
|
-
const {
|
|
10031
|
+
const { schema } = ctx$1;
|
|
10060
10032
|
const shape = $.object().pretty();
|
|
10061
10033
|
for (const name in schema.properties) {
|
|
10062
10034
|
const property = schema.properties[name];
|
|
10063
|
-
const
|
|
10064
|
-
|
|
10065
|
-
|
|
10066
|
-
|
|
10067
|
-
|
|
10068
|
-
...ctx$1.utils.state,
|
|
10069
|
-
path: ref([
|
|
10070
|
-
...fromRef(ctx$1.utils.state.path),
|
|
10071
|
-
"properties",
|
|
10072
|
-
name
|
|
10073
|
-
])
|
|
10074
|
-
}
|
|
10075
|
-
});
|
|
10076
|
-
if (propertyAst.hasLazyExpression) ctx$1.utils.ast.hasLazyExpression = true;
|
|
10077
|
-
shape.prop(name, pipes.toNode(propertyAst.pipes, plugin));
|
|
10035
|
+
const isOptional = !schema.required?.includes(name);
|
|
10036
|
+
const propertyResult = ctx$1.walk(property, childContext(ctx$1.walkerCtx, "properties", name));
|
|
10037
|
+
ctx$1._childResults.push(propertyResult);
|
|
10038
|
+
const finalExpr = ctx$1.applyModifiers(propertyResult, { optional: isOptional });
|
|
10039
|
+
shape.prop(name, pipesToNode(finalExpr.pipes, ctx$1.plugin));
|
|
10078
10040
|
}
|
|
10079
10041
|
return shape;
|
|
10080
10042
|
}
|
|
10081
|
-
function
|
|
10082
|
-
const { plugin } =
|
|
10083
|
-
const
|
|
10084
|
-
|
|
10043
|
+
function objectToPipes(ctx$1) {
|
|
10044
|
+
const { applyModifiers, plugin, schema, walk, walkerCtx } = ctx$1;
|
|
10045
|
+
const childResults = [];
|
|
10046
|
+
const extendedCtx = {
|
|
10085
10047
|
$,
|
|
10048
|
+
_childResults: childResults,
|
|
10049
|
+
applyModifiers,
|
|
10086
10050
|
nodes: {
|
|
10087
10051
|
additionalProperties: additionalPropertiesNode$3,
|
|
10088
10052
|
base: baseNode$13,
|
|
@@ -10092,16 +10056,19 @@ function objectToAst$3(options) {
|
|
|
10092
10056
|
...pipes,
|
|
10093
10057
|
current: []
|
|
10094
10058
|
},
|
|
10059
|
+
plugin,
|
|
10060
|
+
schema,
|
|
10095
10061
|
symbols: { v: plugin.external("valibot.v") },
|
|
10096
|
-
utils: {
|
|
10097
|
-
|
|
10098
|
-
|
|
10099
|
-
}
|
|
10062
|
+
utils: { ast: {} },
|
|
10063
|
+
walk,
|
|
10064
|
+
walkerCtx
|
|
10100
10065
|
};
|
|
10101
10066
|
const resolver = plugin.config["~resolvers"]?.object;
|
|
10102
|
-
const node = resolver?.(
|
|
10103
|
-
|
|
10104
|
-
|
|
10067
|
+
const node = resolver?.(extendedCtx) ?? objectResolver$3(extendedCtx);
|
|
10068
|
+
return {
|
|
10069
|
+
childResults,
|
|
10070
|
+
pipes: [extendedCtx.pipes.toNode(node, plugin)]
|
|
10071
|
+
};
|
|
10105
10072
|
}
|
|
10106
10073
|
|
|
10107
10074
|
//#endregion
|
|
@@ -10152,7 +10119,8 @@ function patternNode$3(ctx$1) {
|
|
|
10152
10119
|
const { schema, symbols } = ctx$1;
|
|
10153
10120
|
const { v } = symbols;
|
|
10154
10121
|
if (!schema.pattern) return;
|
|
10155
|
-
|
|
10122
|
+
const flags = /\\[pP]\{/.test(schema.pattern) ? "u" : void 0;
|
|
10123
|
+
return $(v).attr(identifiers$1.actions.regex).call($.regexp(schema.pattern, flags));
|
|
10156
10124
|
}
|
|
10157
10125
|
function stringResolver$3(ctx$1) {
|
|
10158
10126
|
const constNode$8 = ctx$1.nodes.const(ctx$1);
|
|
@@ -10173,7 +10141,14 @@ function stringResolver$3(ctx$1) {
|
|
|
10173
10141
|
if (patternNode$4) ctx$1.pipes.push(ctx$1.pipes.current, patternNode$4);
|
|
10174
10142
|
return ctx$1.pipes.current;
|
|
10175
10143
|
}
|
|
10176
|
-
function
|
|
10144
|
+
function stringToPipes({ plugin, schema }) {
|
|
10145
|
+
if (shouldCoerceToBigInt(schema.format)) return numberToPipes({
|
|
10146
|
+
plugin,
|
|
10147
|
+
schema: {
|
|
10148
|
+
...schema,
|
|
10149
|
+
type: "number"
|
|
10150
|
+
}
|
|
10151
|
+
});
|
|
10177
10152
|
const ctx$1 = {
|
|
10178
10153
|
$,
|
|
10179
10154
|
nodes: {
|
|
@@ -10200,215 +10175,361 @@ function stringToNode$3({ plugin, schema }) {
|
|
|
10200
10175
|
|
|
10201
10176
|
//#endregion
|
|
10202
10177
|
//#region src/plugins/valibot/v1/toAst/tuple.ts
|
|
10203
|
-
function
|
|
10204
|
-
const { plugin, schema } =
|
|
10205
|
-
const result = {};
|
|
10178
|
+
function tupleToPipes(ctx$1) {
|
|
10179
|
+
const { plugin, schema, walk, walkerCtx } = ctx$1;
|
|
10206
10180
|
const v = plugin.external("valibot.v");
|
|
10181
|
+
const childResults = [];
|
|
10207
10182
|
if (schema.const && Array.isArray(schema.const)) {
|
|
10208
10183
|
const tupleElements = schema.const.map((value) => $(v).attr(identifiers$1.schemas.literal).call($.fromValue(value)));
|
|
10209
|
-
|
|
10210
|
-
|
|
10184
|
+
return {
|
|
10185
|
+
childResults: [],
|
|
10186
|
+
pipes: [$(v).attr(identifiers$1.schemas.tuple).call($.array(...tupleElements))]
|
|
10187
|
+
};
|
|
10211
10188
|
}
|
|
10212
10189
|
if (schema.items) {
|
|
10213
|
-
|
|
10214
|
-
const
|
|
10215
|
-
|
|
10216
|
-
|
|
10217
|
-
|
|
10218
|
-
|
|
10219
|
-
|
|
10220
|
-
|
|
10221
|
-
|
|
10222
|
-
|
|
10223
|
-
])
|
|
10224
|
-
}
|
|
10225
|
-
});
|
|
10226
|
-
if (schemaPipes.hasLazyExpression) result.hasLazyExpression = true;
|
|
10227
|
-
return pipesToNode(schemaPipes.pipes, plugin);
|
|
10228
|
-
});
|
|
10229
|
-
result.pipes = [$(v).attr(identifiers$1.schemas.tuple).call($.array(...tupleElements))];
|
|
10230
|
-
return result;
|
|
10190
|
+
for (let i = 0; i < schema.items.length; i++) {
|
|
10191
|
+
const item = schema.items[i];
|
|
10192
|
+
const result = walk(item, childContext(walkerCtx, "items", i));
|
|
10193
|
+
childResults.push(result);
|
|
10194
|
+
}
|
|
10195
|
+
const tupleElements = childResults.map((r) => pipesToNode(ctx$1.applyModifiers(r).pipes, plugin));
|
|
10196
|
+
return {
|
|
10197
|
+
childResults,
|
|
10198
|
+
pipes: [$(v).attr(identifiers$1.schemas.tuple).call($.array(...tupleElements))]
|
|
10199
|
+
};
|
|
10231
10200
|
}
|
|
10232
|
-
return {
|
|
10233
|
-
|
|
10234
|
-
|
|
10235
|
-
}
|
|
10201
|
+
return {
|
|
10202
|
+
childResults: [],
|
|
10203
|
+
pipes: [unknownToPipes({ plugin })]
|
|
10204
|
+
};
|
|
10236
10205
|
}
|
|
10237
10206
|
|
|
10238
10207
|
//#endregion
|
|
10239
10208
|
//#region src/plugins/valibot/v1/toAst/undefined.ts
|
|
10240
|
-
function
|
|
10209
|
+
function undefinedToPipes({ plugin }) {
|
|
10241
10210
|
return $(plugin.external("valibot.v")).attr(identifiers$1.schemas.undefined).call();
|
|
10242
10211
|
}
|
|
10243
10212
|
|
|
10244
10213
|
//#endregion
|
|
10245
10214
|
//#region src/plugins/valibot/v1/toAst/void.ts
|
|
10246
|
-
function
|
|
10215
|
+
function voidToPipes({ plugin }) {
|
|
10247
10216
|
return $(plugin.external("valibot.v")).attr(identifiers$1.schemas.void).call();
|
|
10248
10217
|
}
|
|
10249
10218
|
|
|
10250
10219
|
//#endregion
|
|
10251
|
-
//#region src/plugins/valibot/v1/
|
|
10252
|
-
function
|
|
10253
|
-
|
|
10254
|
-
case "array": return { expression: pipesToNode(arrayToAst$3({
|
|
10255
|
-
...args,
|
|
10256
|
-
schema
|
|
10257
|
-
}).pipes, args.plugin) };
|
|
10258
|
-
case "boolean": return { expression: booleanToAst$3({
|
|
10259
|
-
...args,
|
|
10260
|
-
schema
|
|
10261
|
-
}) };
|
|
10262
|
-
case "enum": return { expression: enumToAst$3({
|
|
10263
|
-
...args,
|
|
10264
|
-
schema
|
|
10265
|
-
}) };
|
|
10266
|
-
case "integer":
|
|
10267
|
-
case "number": return { expression: numberToNode$3({
|
|
10268
|
-
...args,
|
|
10269
|
-
schema
|
|
10270
|
-
}) };
|
|
10271
|
-
case "never": return { expression: neverToAst$3({
|
|
10272
|
-
...args,
|
|
10273
|
-
schema
|
|
10274
|
-
}) };
|
|
10275
|
-
case "null": return { expression: nullToAst$3({
|
|
10276
|
-
...args,
|
|
10277
|
-
schema
|
|
10278
|
-
}) };
|
|
10279
|
-
case "object": return { expression: pipesToNode(objectToAst$3({
|
|
10280
|
-
...args,
|
|
10281
|
-
schema
|
|
10282
|
-
}).pipes, args.plugin) };
|
|
10283
|
-
case "string": return { expression: shouldCoerceToBigInt(schema.format) ? numberToNode$3({
|
|
10284
|
-
...args,
|
|
10285
|
-
schema: {
|
|
10286
|
-
...schema,
|
|
10287
|
-
type: "number"
|
|
10288
|
-
}
|
|
10289
|
-
}) : stringToNode$3({
|
|
10290
|
-
...args,
|
|
10291
|
-
schema
|
|
10292
|
-
}) };
|
|
10293
|
-
case "tuple": return { expression: pipesToNode(tupleToAst$3({
|
|
10294
|
-
...args,
|
|
10295
|
-
schema
|
|
10296
|
-
}).pipes, args.plugin) };
|
|
10297
|
-
case "undefined": return { expression: undefinedToAst$3({
|
|
10298
|
-
...args,
|
|
10299
|
-
schema
|
|
10300
|
-
}) };
|
|
10301
|
-
case "unknown": return { expression: unknownToAst$3({
|
|
10302
|
-
...args,
|
|
10303
|
-
schema
|
|
10304
|
-
}) };
|
|
10305
|
-
case "void": return { expression: voidToAst$3({
|
|
10306
|
-
...args,
|
|
10307
|
-
schema
|
|
10308
|
-
}) };
|
|
10309
|
-
}
|
|
10220
|
+
//#region src/plugins/valibot/v1/walker.ts
|
|
10221
|
+
function getDefaultValue(meta) {
|
|
10222
|
+
return meta.format ? maybeBigInt(meta.default, meta.format) : $.fromValue(meta.default);
|
|
10310
10223
|
}
|
|
10311
|
-
|
|
10312
|
-
|
|
10313
|
-
|
|
10314
|
-
|
|
10315
|
-
|
|
10316
|
-
|
|
10317
|
-
|
|
10318
|
-
|
|
10319
|
-
|
|
10320
|
-
|
|
10321
|
-
|
|
10322
|
-
|
|
10323
|
-
|
|
10324
|
-
|
|
10325
|
-
|
|
10326
|
-
|
|
10327
|
-
|
|
10328
|
-
|
|
10329
|
-
|
|
10330
|
-
|
|
10331
|
-
|
|
10332
|
-
|
|
10333
|
-
|
|
10334
|
-
|
|
10335
|
-
|
|
10336
|
-
|
|
10337
|
-
|
|
10338
|
-
|
|
10339
|
-
|
|
10340
|
-
|
|
10341
|
-
|
|
10342
|
-
|
|
10343
|
-
|
|
10344
|
-
|
|
10345
|
-
|
|
10346
|
-
|
|
10347
|
-
|
|
10348
|
-
|
|
10349
|
-
|
|
10350
|
-
|
|
10351
|
-
|
|
10352
|
-
|
|
10353
|
-
|
|
10354
|
-
|
|
10355
|
-
|
|
10356
|
-
|
|
10357
|
-
|
|
10358
|
-
}
|
|
10359
|
-
|
|
10360
|
-
|
|
10361
|
-
|
|
10362
|
-
|
|
10363
|
-
|
|
10364
|
-
|
|
10365
|
-
|
|
10366
|
-
|
|
10367
|
-
|
|
10368
|
-
|
|
10369
|
-
|
|
10370
|
-
|
|
10371
|
-
|
|
10372
|
-
|
|
10373
|
-
|
|
10374
|
-
|
|
10375
|
-
|
|
10224
|
+
function createVisitor$3(config) {
|
|
10225
|
+
const { schemaExtractor } = config;
|
|
10226
|
+
return {
|
|
10227
|
+
applyModifiers(result, ctx$1, options = {}) {
|
|
10228
|
+
const { optional } = options;
|
|
10229
|
+
const v = ctx$1.plugin.external("valibot.v");
|
|
10230
|
+
const pipes$1 = [...result.pipes];
|
|
10231
|
+
if (result.meta.readonly) pipes$1.push($(v).attr(identifiers$1.actions.readonly).call());
|
|
10232
|
+
const hasDefault = result.meta.default !== void 0;
|
|
10233
|
+
const needsOptional = optional || hasDefault;
|
|
10234
|
+
const needsNullable = result.meta.nullable;
|
|
10235
|
+
const innerNode = pipesToNode(pipes$1, ctx$1.plugin);
|
|
10236
|
+
let finalPipes;
|
|
10237
|
+
if (needsOptional && needsNullable) if (hasDefault) finalPipes = [$(v).attr(identifiers$1.schemas.nullish).call(innerNode, getDefaultValue(result.meta))];
|
|
10238
|
+
else finalPipes = [$(v).attr(identifiers$1.schemas.nullish).call(innerNode)];
|
|
10239
|
+
else if (needsOptional) if (hasDefault) finalPipes = [$(v).attr(identifiers$1.schemas.optional).call(innerNode, getDefaultValue(result.meta))];
|
|
10240
|
+
else finalPipes = [$(v).attr(identifiers$1.schemas.optional).call(innerNode)];
|
|
10241
|
+
else if (needsNullable) finalPipes = [$(v).attr(identifiers$1.schemas.nullable).call(innerNode)];
|
|
10242
|
+
else finalPipes = pipes$1;
|
|
10243
|
+
return {
|
|
10244
|
+
pipes: finalPipes,
|
|
10245
|
+
typeName: result.meta.hasLazy ? identifiers$1.types.GenericSchema : void 0
|
|
10246
|
+
};
|
|
10247
|
+
},
|
|
10248
|
+
array(schema, ctx$1, walk) {
|
|
10249
|
+
const applyModifiers = (result, opts) => this.applyModifiers(result, ctx$1, opts);
|
|
10250
|
+
const { childResults, pipes: pipes$1 } = arrayToPipes({
|
|
10251
|
+
applyModifiers,
|
|
10252
|
+
plugin: ctx$1.plugin,
|
|
10253
|
+
schema,
|
|
10254
|
+
walk,
|
|
10255
|
+
walkerCtx: ctx$1
|
|
10256
|
+
});
|
|
10257
|
+
return {
|
|
10258
|
+
meta: inheritMeta(schema, childResults),
|
|
10259
|
+
pipes: pipes$1
|
|
10260
|
+
};
|
|
10261
|
+
},
|
|
10262
|
+
boolean(schema, ctx$1) {
|
|
10263
|
+
const pipe = booleanToPipes({
|
|
10264
|
+
plugin: ctx$1.plugin,
|
|
10265
|
+
schema
|
|
10266
|
+
});
|
|
10267
|
+
return {
|
|
10268
|
+
meta: defaultMeta(schema),
|
|
10269
|
+
pipes: [pipe]
|
|
10270
|
+
};
|
|
10271
|
+
},
|
|
10272
|
+
enum(schema, ctx$1) {
|
|
10273
|
+
const { isNullable, pipe } = enumToPipes({
|
|
10274
|
+
plugin: ctx$1.plugin,
|
|
10275
|
+
schema
|
|
10276
|
+
});
|
|
10277
|
+
return {
|
|
10278
|
+
meta: {
|
|
10279
|
+
...defaultMeta(schema),
|
|
10280
|
+
nullable: isNullable
|
|
10281
|
+
},
|
|
10282
|
+
pipes: [pipe]
|
|
10283
|
+
};
|
|
10284
|
+
},
|
|
10285
|
+
integer(schema, ctx$1) {
|
|
10286
|
+
const pipe = numberToPipes({
|
|
10287
|
+
plugin: ctx$1.plugin,
|
|
10288
|
+
schema
|
|
10376
10289
|
});
|
|
10377
|
-
|
|
10378
|
-
|
|
10379
|
-
|
|
10380
|
-
}
|
|
10381
|
-
|
|
10382
|
-
|
|
10290
|
+
return {
|
|
10291
|
+
meta: defaultMeta(schema),
|
|
10292
|
+
pipes: [pipe]
|
|
10293
|
+
};
|
|
10294
|
+
},
|
|
10295
|
+
intercept(schema, ctx$1, walk) {
|
|
10296
|
+
if (schemaExtractor && !schema.$ref) {
|
|
10297
|
+
const extracted = schemaExtractor({
|
|
10298
|
+
meta: {
|
|
10299
|
+
resource: "definition",
|
|
10300
|
+
resourceId: pathToJsonPointer(fromRef(ctx$1.path))
|
|
10301
|
+
},
|
|
10302
|
+
naming: ctx$1.plugin.config.definitions,
|
|
10303
|
+
path: fromRef(ctx$1.path),
|
|
10304
|
+
plugin: ctx$1.plugin,
|
|
10305
|
+
schema
|
|
10306
|
+
});
|
|
10307
|
+
if (extracted !== schema) return walk(extracted, ctx$1);
|
|
10383
10308
|
}
|
|
10384
|
-
}
|
|
10385
|
-
|
|
10386
|
-
|
|
10309
|
+
},
|
|
10310
|
+
intersection(items, schemas, parentSchema, ctx$1) {
|
|
10311
|
+
const v = ctx$1.plugin.external("valibot.v");
|
|
10312
|
+
const itemNodes = items.map((item) => pipesToNode(item.pipes, ctx$1.plugin));
|
|
10313
|
+
return {
|
|
10314
|
+
meta: composeMeta(items, { default: parentSchema.default }),
|
|
10315
|
+
pipes: [$(v).attr(identifiers$1.schemas.intersect).call($.array(...itemNodes))]
|
|
10316
|
+
};
|
|
10317
|
+
},
|
|
10318
|
+
never(schema, ctx$1) {
|
|
10319
|
+
const pipe = neverToPipes({
|
|
10320
|
+
plugin: ctx$1.plugin,
|
|
10321
|
+
schema
|
|
10322
|
+
});
|
|
10323
|
+
return {
|
|
10324
|
+
meta: {
|
|
10325
|
+
...defaultMeta(schema),
|
|
10326
|
+
nullable: false,
|
|
10327
|
+
readonly: false
|
|
10328
|
+
},
|
|
10329
|
+
pipes: [pipe]
|
|
10330
|
+
};
|
|
10331
|
+
},
|
|
10332
|
+
null(schema, ctx$1) {
|
|
10333
|
+
const pipe = nullToPipes({
|
|
10334
|
+
plugin: ctx$1.plugin,
|
|
10335
|
+
schema
|
|
10336
|
+
});
|
|
10337
|
+
return {
|
|
10338
|
+
meta: {
|
|
10339
|
+
...defaultMeta(schema),
|
|
10340
|
+
nullable: false,
|
|
10341
|
+
readonly: false
|
|
10342
|
+
},
|
|
10343
|
+
pipes: [pipe]
|
|
10344
|
+
};
|
|
10345
|
+
},
|
|
10346
|
+
number(schema, ctx$1) {
|
|
10347
|
+
const pipe = numberToPipes({
|
|
10348
|
+
plugin: ctx$1.plugin,
|
|
10349
|
+
schema
|
|
10350
|
+
});
|
|
10351
|
+
return {
|
|
10352
|
+
meta: defaultMeta(schema),
|
|
10353
|
+
pipes: [pipe]
|
|
10354
|
+
};
|
|
10355
|
+
},
|
|
10356
|
+
object(schema, ctx$1, walk) {
|
|
10357
|
+
const applyModifiers = (result, opts) => this.applyModifiers(result, ctx$1, opts);
|
|
10358
|
+
const { childResults, pipes: pipes$1 } = objectToPipes({
|
|
10359
|
+
applyModifiers,
|
|
10360
|
+
plugin: ctx$1.plugin,
|
|
10387
10361
|
schema,
|
|
10388
|
-
|
|
10362
|
+
walk,
|
|
10363
|
+
walkerCtx: ctx$1
|
|
10364
|
+
});
|
|
10365
|
+
return {
|
|
10366
|
+
meta: inheritMeta(schema, childResults),
|
|
10367
|
+
pipes: pipes$1
|
|
10368
|
+
};
|
|
10369
|
+
},
|
|
10370
|
+
postProcess(result, schema, ctx$1) {
|
|
10371
|
+
if (ctx$1.plugin.config.metadata && schema.description) {
|
|
10372
|
+
const metadataExpr = $(ctx$1.plugin.external("valibot.v")).attr(identifiers$1.actions.metadata).call($.object().prop("description", $.literal(schema.description)));
|
|
10373
|
+
return {
|
|
10374
|
+
meta: result.meta,
|
|
10375
|
+
pipes: [...result.pipes, metadataExpr]
|
|
10376
|
+
};
|
|
10377
|
+
}
|
|
10378
|
+
return result;
|
|
10379
|
+
},
|
|
10380
|
+
reference($ref, schema, ctx$1) {
|
|
10381
|
+
const v = ctx$1.plugin.external("valibot.v");
|
|
10382
|
+
const query = {
|
|
10383
|
+
category: "schema",
|
|
10384
|
+
resource: "definition",
|
|
10385
|
+
resourceId: $ref,
|
|
10386
|
+
tool: "valibot"
|
|
10387
|
+
};
|
|
10388
|
+
const refSymbol = ctx$1.plugin.referenceSymbol(query);
|
|
10389
|
+
if (ctx$1.plugin.isSymbolRegistered(query)) return {
|
|
10390
|
+
meta: defaultMeta(schema),
|
|
10391
|
+
pipes: [$(refSymbol)]
|
|
10392
|
+
};
|
|
10393
|
+
return {
|
|
10394
|
+
meta: {
|
|
10395
|
+
...defaultMeta(schema),
|
|
10396
|
+
hasLazy: true
|
|
10397
|
+
},
|
|
10398
|
+
pipes: [$(v).attr(identifiers$1.schemas.lazy).call($.func().do($(refSymbol).return()))]
|
|
10399
|
+
};
|
|
10400
|
+
},
|
|
10401
|
+
string(schema, ctx$1) {
|
|
10402
|
+
const pipe = stringToPipes({
|
|
10403
|
+
plugin: ctx$1.plugin,
|
|
10404
|
+
schema
|
|
10405
|
+
});
|
|
10406
|
+
return {
|
|
10407
|
+
meta: defaultMeta(schema),
|
|
10408
|
+
pipes: [pipe]
|
|
10409
|
+
};
|
|
10410
|
+
},
|
|
10411
|
+
tuple(schema, ctx$1, walk) {
|
|
10412
|
+
const applyModifiers = (result, opts) => this.applyModifiers(result, ctx$1, opts);
|
|
10413
|
+
const { childResults, pipes: pipes$1 } = tupleToPipes({
|
|
10414
|
+
applyModifiers,
|
|
10415
|
+
plugin: ctx$1.plugin,
|
|
10416
|
+
schema,
|
|
10417
|
+
walk,
|
|
10418
|
+
walkerCtx: ctx$1
|
|
10419
|
+
});
|
|
10420
|
+
return {
|
|
10421
|
+
meta: inheritMeta(schema, childResults),
|
|
10422
|
+
pipes: pipes$1
|
|
10423
|
+
};
|
|
10424
|
+
},
|
|
10425
|
+
undefined(schema, ctx$1) {
|
|
10426
|
+
const pipe = undefinedToPipes({
|
|
10427
|
+
plugin: ctx$1.plugin,
|
|
10428
|
+
schema
|
|
10429
|
+
});
|
|
10430
|
+
return {
|
|
10431
|
+
meta: {
|
|
10432
|
+
...defaultMeta(schema),
|
|
10433
|
+
nullable: false,
|
|
10434
|
+
readonly: false
|
|
10435
|
+
},
|
|
10436
|
+
pipes: [pipe]
|
|
10437
|
+
};
|
|
10438
|
+
},
|
|
10439
|
+
union(items, schemas, parentSchema, ctx$1) {
|
|
10440
|
+
const v = ctx$1.plugin.external("valibot.v");
|
|
10441
|
+
const hasNull = schemas.some((s) => s.type === "null") || items.some((i) => i.meta.nullable);
|
|
10442
|
+
const nonNullItems = [];
|
|
10443
|
+
items.forEach((item, index) => {
|
|
10444
|
+
if (schemas[index].type !== "null") nonNullItems.push(item);
|
|
10445
|
+
});
|
|
10446
|
+
let pipes$1;
|
|
10447
|
+
if (nonNullItems.length === 0) pipes$1 = [$(v).attr(identifiers$1.schemas.null).call()];
|
|
10448
|
+
else if (nonNullItems.length === 1) pipes$1 = nonNullItems[0].pipes;
|
|
10449
|
+
else {
|
|
10450
|
+
const itemNodes = nonNullItems.map((i) => pipesToNode(i.pipes, ctx$1.plugin));
|
|
10451
|
+
pipes$1 = [$(v).attr(identifiers$1.schemas.union).call($.array(...itemNodes))];
|
|
10452
|
+
}
|
|
10453
|
+
return {
|
|
10454
|
+
meta: composeMeta(items, {
|
|
10455
|
+
default: parentSchema.default,
|
|
10456
|
+
nullable: hasNull
|
|
10457
|
+
}),
|
|
10458
|
+
pipes: pipes$1
|
|
10459
|
+
};
|
|
10460
|
+
},
|
|
10461
|
+
unknown(schema, ctx$1) {
|
|
10462
|
+
const pipe = unknownToPipes({ plugin: ctx$1.plugin });
|
|
10463
|
+
return {
|
|
10464
|
+
meta: {
|
|
10465
|
+
...defaultMeta(schema),
|
|
10466
|
+
nullable: false,
|
|
10467
|
+
readonly: false
|
|
10468
|
+
},
|
|
10469
|
+
pipes: [pipe]
|
|
10470
|
+
};
|
|
10471
|
+
},
|
|
10472
|
+
void(schema, ctx$1) {
|
|
10473
|
+
const pipe = voidToPipes({
|
|
10474
|
+
plugin: ctx$1.plugin,
|
|
10475
|
+
schema
|
|
10389
10476
|
});
|
|
10390
|
-
|
|
10477
|
+
return {
|
|
10478
|
+
meta: {
|
|
10479
|
+
...defaultMeta(schema),
|
|
10480
|
+
nullable: false,
|
|
10481
|
+
readonly: false
|
|
10482
|
+
},
|
|
10483
|
+
pipes: [pipe]
|
|
10484
|
+
};
|
|
10391
10485
|
}
|
|
10392
|
-
}
|
|
10393
|
-
|
|
10394
|
-
|
|
10395
|
-
|
|
10396
|
-
|
|
10397
|
-
|
|
10398
|
-
|
|
10399
|
-
|
|
10400
|
-
|
|
10401
|
-
|
|
10402
|
-
|
|
10403
|
-
|
|
10404
|
-
|
|
10405
|
-
|
|
10486
|
+
};
|
|
10487
|
+
}
|
|
10488
|
+
|
|
10489
|
+
//#endregion
|
|
10490
|
+
//#region src/plugins/valibot/v1/processor.ts
|
|
10491
|
+
function createProcessor$3(plugin) {
|
|
10492
|
+
const processor = createSchemaProcessor();
|
|
10493
|
+
const hooks = [plugin.config["~hooks"]?.schemas, plugin.context.config.parser.hooks.schemas];
|
|
10494
|
+
function extractor(ctx$1) {
|
|
10495
|
+
if (processor.hasEmitted(ctx$1.path)) return ctx$1.schema;
|
|
10496
|
+
for (const hook of hooks) if (hook?.shouldExtract?.(ctx$1)) {
|
|
10497
|
+
process$1({
|
|
10498
|
+
namingAnchor: processor.context.anchor,
|
|
10499
|
+
tags: processor.context.tags,
|
|
10500
|
+
...ctx$1
|
|
10501
|
+
});
|
|
10502
|
+
return { $ref: pathToJsonPointer(ctx$1.path) };
|
|
10406
10503
|
}
|
|
10407
|
-
|
|
10408
|
-
else if (optional) ast.pipes = [$(v).attr(identifiers$1.schemas.optional).call(pipesToNode(ast.pipes, plugin))];
|
|
10504
|
+
return ctx$1.schema;
|
|
10409
10505
|
}
|
|
10410
|
-
|
|
10506
|
+
function process$1(ctx$1) {
|
|
10507
|
+
if (!processor.markEmitted(ctx$1.path)) return;
|
|
10508
|
+
processor.withContext({
|
|
10509
|
+
anchor: ctx$1.namingAnchor,
|
|
10510
|
+
tags: ctx$1.tags
|
|
10511
|
+
}, () => {
|
|
10512
|
+
const visitor = createVisitor$3({ schemaExtractor: extractor });
|
|
10513
|
+
const result = createSchemaWalker(visitor)(ctx$1.schema, {
|
|
10514
|
+
path: ref(ctx$1.path),
|
|
10515
|
+
plugin
|
|
10516
|
+
});
|
|
10517
|
+
const final = visitor.applyModifiers(result, {
|
|
10518
|
+
path: ref(ctx$1.path),
|
|
10519
|
+
plugin
|
|
10520
|
+
});
|
|
10521
|
+
exportAst$1({
|
|
10522
|
+
...ctx$1,
|
|
10523
|
+
final,
|
|
10524
|
+
plugin
|
|
10525
|
+
});
|
|
10526
|
+
});
|
|
10527
|
+
}
|
|
10528
|
+
return { process: process$1 };
|
|
10411
10529
|
}
|
|
10530
|
+
|
|
10531
|
+
//#endregion
|
|
10532
|
+
//#region src/plugins/valibot/v1/plugin.ts
|
|
10412
10533
|
const handlerV1 = ({ plugin }) => {
|
|
10413
10534
|
plugin.symbol("v", {
|
|
10414
10535
|
external: "valibot",
|
|
@@ -10546,8 +10667,10 @@ const defineConfig$1 = definePluginConfig(defaultConfig$1);
|
|
|
10546
10667
|
//#endregion
|
|
10547
10668
|
//#region src/plugins/zod/constants.ts
|
|
10548
10669
|
const identifiers = {
|
|
10670
|
+
AnyZodObject: "AnyZodObject",
|
|
10549
10671
|
ZodMiniOptional: "ZodMiniOptional",
|
|
10550
10672
|
ZodOptional: "ZodOptional",
|
|
10673
|
+
ZodTypeAny: "ZodTypeAny",
|
|
10551
10674
|
_default: "_default",
|
|
10552
10675
|
and: "and",
|
|
10553
10676
|
array: "array",
|
|
@@ -10585,6 +10708,7 @@ const identifiers = {
|
|
|
10585
10708
|
never: "never",
|
|
10586
10709
|
null: "null",
|
|
10587
10710
|
nullable: "nullable",
|
|
10711
|
+
nullish: "nullish",
|
|
10588
10712
|
number: "number",
|
|
10589
10713
|
object: "object",
|
|
10590
10714
|
optional: "optional",
|
|
@@ -10945,7 +11069,7 @@ function irWebhookToAst({ operation, path: path$1, plugin, processor, tags }) {
|
|
|
10945
11069
|
|
|
10946
11070
|
//#endregion
|
|
10947
11071
|
//#region src/plugins/zod/shared/export.ts
|
|
10948
|
-
function exportAst({ ast, meta, naming, namingAnchor, path: path$1, plugin, schema, tags }) {
|
|
11072
|
+
function exportAst({ ast, meta, naming, namingAnchor, path: path$1, plugin, schema, state, tags }) {
|
|
10949
11073
|
const z = plugin.external("zod.z");
|
|
10950
11074
|
const name = pathToName(path$1, { anchor: namingAnchor });
|
|
10951
11075
|
const symbol = plugin.symbol(applyNaming(name, naming), { meta: {
|
|
@@ -10963,7 +11087,7 @@ function exportAst({ ast, meta, naming, namingAnchor, path: path$1, plugin, sche
|
|
|
10963
11087
|
variant: "infer",
|
|
10964
11088
|
...meta
|
|
10965
11089
|
} }) : void 0;
|
|
10966
|
-
const statement = $.const(symbol).export().$if(plugin.config.comments && createSchemaComment(schema), (c, v) => c.doc(v)).$if(
|
|
11090
|
+
const statement = $.const(symbol).export().$if(plugin.config.comments && createSchemaComment(schema), (c, v) => c.doc(v)).$if(state.hasLazyExpression["~ref"] && state.anyType?.["~ref"], (c, v) => c.type($.type(z).attr(v))).assign(ast.expression);
|
|
10967
11091
|
plugin.node(statement);
|
|
10968
11092
|
if (typeInferSymbol) {
|
|
10969
11093
|
const inferType = $.type.alias(typeInferSymbol).export().type($.type(z).attr(identifiers.infer).generic($(symbol).typeofType()));
|
|
@@ -10971,88 +11095,36 @@ function exportAst({ ast, meta, naming, namingAnchor, path: path$1, plugin, sche
|
|
|
10971
11095
|
}
|
|
10972
11096
|
}
|
|
10973
11097
|
|
|
10974
|
-
//#endregion
|
|
10975
|
-
//#region src/plugins/zod/mini/processor.ts
|
|
10976
|
-
function createProcessor$2(plugin) {
|
|
10977
|
-
const processor = createSchemaProcessor();
|
|
10978
|
-
const hooks = [plugin.config["~hooks"]?.schemas, plugin.context.config.parser.hooks.schemas];
|
|
10979
|
-
function extractor(ctx$1) {
|
|
10980
|
-
if (processor.hasEmitted(ctx$1.path)) return ctx$1.schema;
|
|
10981
|
-
for (const hook of hooks) if (hook?.shouldExtract?.(ctx$1)) {
|
|
10982
|
-
process$1({
|
|
10983
|
-
namingAnchor: processor.context.anchor,
|
|
10984
|
-
tags: processor.context.tags,
|
|
10985
|
-
...ctx$1
|
|
10986
|
-
});
|
|
10987
|
-
return { $ref: pathToJsonPointer(ctx$1.path) };
|
|
10988
|
-
}
|
|
10989
|
-
return ctx$1.schema;
|
|
10990
|
-
}
|
|
10991
|
-
function process$1(ctx$1) {
|
|
10992
|
-
if (!processor.markEmitted(ctx$1.path)) return;
|
|
10993
|
-
processor.withContext({
|
|
10994
|
-
anchor: ctx$1.namingAnchor,
|
|
10995
|
-
tags: ctx$1.tags
|
|
10996
|
-
}, () => {
|
|
10997
|
-
const state = refs({
|
|
10998
|
-
hasLazyExpression: false,
|
|
10999
|
-
path: ctx$1.path,
|
|
11000
|
-
tags: ctx$1.tags
|
|
11001
|
-
});
|
|
11002
|
-
const ast = irSchemaToAst$2({
|
|
11003
|
-
plugin,
|
|
11004
|
-
schema: ctx$1.schema,
|
|
11005
|
-
schemaExtractor: extractor,
|
|
11006
|
-
state
|
|
11007
|
-
});
|
|
11008
|
-
exportAst({
|
|
11009
|
-
...ctx$1,
|
|
11010
|
-
ast,
|
|
11011
|
-
plugin,
|
|
11012
|
-
state
|
|
11013
|
-
});
|
|
11014
|
-
});
|
|
11015
|
-
}
|
|
11016
|
-
return { process: process$1 };
|
|
11017
|
-
}
|
|
11018
|
-
|
|
11019
11098
|
//#endregion
|
|
11020
11099
|
//#region src/plugins/zod/mini/toAst/unknown.ts
|
|
11021
|
-
|
|
11100
|
+
function unknownToAst$2({ plugin }) {
|
|
11022
11101
|
const z = plugin.external("zod.z");
|
|
11023
11102
|
const result = {};
|
|
11024
11103
|
result.expression = $(z).attr(identifiers.unknown).call();
|
|
11025
11104
|
return result;
|
|
11026
|
-
}
|
|
11105
|
+
}
|
|
11027
11106
|
|
|
11028
11107
|
//#endregion
|
|
11029
11108
|
//#region src/plugins/zod/mini/toAst/array.ts
|
|
11030
|
-
|
|
11031
|
-
const
|
|
11109
|
+
function arrayToAst$2(options) {
|
|
11110
|
+
const { applyModifiers, plugin, walk } = options;
|
|
11111
|
+
let { schema } = options;
|
|
11032
11112
|
const result = {};
|
|
11113
|
+
const z = plugin.external("zod.z");
|
|
11033
11114
|
const functionName = $(z).attr(identifiers.array);
|
|
11034
11115
|
if (!schema.items) result.expression = functionName.call(unknownToAst$2({
|
|
11035
|
-
|
|
11036
|
-
schema: { type: "unknown" }
|
|
11037
|
-
state
|
|
11116
|
+
...options,
|
|
11117
|
+
schema: { type: "unknown" }
|
|
11038
11118
|
}).expression);
|
|
11039
11119
|
else {
|
|
11040
11120
|
schema = deduplicateSchema({ schema });
|
|
11041
11121
|
const itemExpressions = schema.items.map((item, index) => {
|
|
11042
|
-
const
|
|
11043
|
-
|
|
11044
|
-
|
|
11045
|
-
|
|
11046
|
-
|
|
11047
|
-
|
|
11048
|
-
...fromRef(state.path),
|
|
11049
|
-
"items",
|
|
11050
|
-
index
|
|
11051
|
-
])
|
|
11052
|
-
}
|
|
11053
|
-
});
|
|
11054
|
-
if (itemAst.hasLazyExpression) result.hasLazyExpression = true;
|
|
11055
|
-
return itemAst.expression;
|
|
11122
|
+
const itemResult = walk(item, childContext({
|
|
11123
|
+
path: options.state.path,
|
|
11124
|
+
plugin: options.plugin
|
|
11125
|
+
}, "items", index));
|
|
11126
|
+
if (itemResult.hasLazyExpression) result.hasLazyExpression = true;
|
|
11127
|
+
return applyModifiers(itemResult, { optional: false }).expression;
|
|
11056
11128
|
});
|
|
11057
11129
|
if (itemExpressions.length === 1) result.expression = functionName.call(...itemExpressions);
|
|
11058
11130
|
else if (schema.logicalOperator === "and") {
|
|
@@ -11074,7 +11146,7 @@ const arrayToAst$2 = ({ plugin, schema, state }) => {
|
|
|
11074
11146
|
}
|
|
11075
11147
|
if (checks.length > 0) result.expression = result.expression.attr(identifiers.check).call(...checks);
|
|
11076
11148
|
return result;
|
|
11077
|
-
}
|
|
11149
|
+
}
|
|
11078
11150
|
|
|
11079
11151
|
//#endregion
|
|
11080
11152
|
//#region src/plugins/zod/mini/toAst/boolean.ts
|
|
@@ -11129,31 +11201,21 @@ function baseNode$11(ctx$1) {
|
|
|
11129
11201
|
else if (literalMembers.length === 1) return literalMembers[0];
|
|
11130
11202
|
else return $(z).attr(identifiers.union).call($.array(...literalMembers));
|
|
11131
11203
|
}
|
|
11132
|
-
function nullableNode$2(ctx$1) {
|
|
11133
|
-
const { chain, symbols } = ctx$1;
|
|
11134
|
-
const { z } = symbols;
|
|
11135
|
-
const { isNullable } = ctx$1.nodes.items(ctx$1);
|
|
11136
|
-
if (!isNullable) return;
|
|
11137
|
-
return $(z).attr(identifiers.nullable).call(chain.current);
|
|
11138
|
-
}
|
|
11139
11204
|
function enumResolver$2(ctx$1) {
|
|
11140
11205
|
const { literalMembers } = ctx$1.nodes.items(ctx$1);
|
|
11141
11206
|
if (!literalMembers.length) return ctx$1.chain.current;
|
|
11142
11207
|
const baseExpression = ctx$1.nodes.base(ctx$1);
|
|
11143
11208
|
ctx$1.chain.current = baseExpression;
|
|
11144
|
-
const nullableExpression = ctx$1.nodes.nullable(ctx$1);
|
|
11145
|
-
if (nullableExpression) ctx$1.chain.current = nullableExpression;
|
|
11146
11209
|
return ctx$1.chain.current;
|
|
11147
11210
|
}
|
|
11148
|
-
|
|
11211
|
+
function enumToAst$2({ plugin, schema, state }) {
|
|
11149
11212
|
const z = plugin.external("zod.z");
|
|
11150
11213
|
const { literalMembers } = itemsNode$2({
|
|
11151
11214
|
$,
|
|
11152
11215
|
chain: { current: $(z) },
|
|
11153
11216
|
nodes: {
|
|
11154
11217
|
base: baseNode$11,
|
|
11155
|
-
items: itemsNode$2
|
|
11156
|
-
nullable: nullableNode$2
|
|
11218
|
+
items: itemsNode$2
|
|
11157
11219
|
},
|
|
11158
11220
|
plugin,
|
|
11159
11221
|
schema,
|
|
@@ -11165,16 +11227,14 @@ const enumToAst$2 = ({ plugin, schema, state }) => {
|
|
|
11165
11227
|
});
|
|
11166
11228
|
if (!literalMembers.length) return unknownToAst$2({
|
|
11167
11229
|
plugin,
|
|
11168
|
-
schema: { type: "unknown" }
|
|
11169
|
-
state
|
|
11230
|
+
schema: { type: "unknown" }
|
|
11170
11231
|
});
|
|
11171
11232
|
const ctx$1 = {
|
|
11172
11233
|
$,
|
|
11173
11234
|
chain: { current: $(z) },
|
|
11174
11235
|
nodes: {
|
|
11175
11236
|
base: baseNode$11,
|
|
11176
|
-
items: itemsNode$2
|
|
11177
|
-
nullable: nullableNode$2
|
|
11237
|
+
items: itemsNode$2
|
|
11178
11238
|
},
|
|
11179
11239
|
plugin,
|
|
11180
11240
|
schema,
|
|
@@ -11186,25 +11246,25 @@ const enumToAst$2 = ({ plugin, schema, state }) => {
|
|
|
11186
11246
|
};
|
|
11187
11247
|
const resolver = plugin.config["~resolvers"]?.enum;
|
|
11188
11248
|
return { expression: resolver?.(ctx$1) ?? enumResolver$2(ctx$1) };
|
|
11189
|
-
}
|
|
11249
|
+
}
|
|
11190
11250
|
|
|
11191
11251
|
//#endregion
|
|
11192
11252
|
//#region src/plugins/zod/mini/toAst/never.ts
|
|
11193
|
-
|
|
11253
|
+
function neverToAst$2({ plugin }) {
|
|
11194
11254
|
const z = plugin.external("zod.z");
|
|
11195
11255
|
const result = {};
|
|
11196
11256
|
result.expression = $(z).attr(identifiers.never).call();
|
|
11197
11257
|
return result;
|
|
11198
|
-
}
|
|
11258
|
+
}
|
|
11199
11259
|
|
|
11200
11260
|
//#endregion
|
|
11201
11261
|
//#region src/plugins/zod/mini/toAst/null.ts
|
|
11202
|
-
|
|
11262
|
+
function nullToAst$2({ plugin }) {
|
|
11203
11263
|
const z = plugin.external("zod.z");
|
|
11204
11264
|
const result = {};
|
|
11205
11265
|
result.expression = $(z).attr(identifiers.null).call();
|
|
11206
11266
|
return result;
|
|
11207
|
-
}
|
|
11267
|
+
}
|
|
11208
11268
|
|
|
11209
11269
|
//#endregion
|
|
11210
11270
|
//#region src/plugins/zod/mini/toAst/number.ts
|
|
@@ -11254,7 +11314,7 @@ function numberResolver$2(ctx$1) {
|
|
|
11254
11314
|
if (checks.length > 0) ctx$1.chain.current = ctx$1.chain.current.attr(identifiers.check).call(...checks);
|
|
11255
11315
|
return ctx$1.chain.current;
|
|
11256
11316
|
}
|
|
11257
|
-
|
|
11317
|
+
function numberToNode$2({ plugin, schema, state }) {
|
|
11258
11318
|
const ast = {};
|
|
11259
11319
|
const z = plugin.external("zod.z");
|
|
11260
11320
|
const ctx$1 = {
|
|
@@ -11280,23 +11340,16 @@ const numberToNode$2 = ({ plugin, schema, state }) => {
|
|
|
11280
11340
|
const resolver = plugin.config["~resolvers"]?.number;
|
|
11281
11341
|
ast.expression = resolver?.(ctx$1) ?? numberResolver$2(ctx$1);
|
|
11282
11342
|
return ast;
|
|
11283
|
-
}
|
|
11343
|
+
}
|
|
11284
11344
|
|
|
11285
11345
|
//#endregion
|
|
11286
11346
|
//#region src/plugins/zod/mini/toAst/object.ts
|
|
11287
11347
|
function additionalPropertiesNode$2(ctx$1) {
|
|
11288
|
-
const {
|
|
11348
|
+
const { applyModifiers, schema, walk, walkerCtx } = ctx$1;
|
|
11289
11349
|
if (!schema.additionalProperties || schema.properties && Object.keys(schema.properties).length > 0) return;
|
|
11290
|
-
const
|
|
11291
|
-
|
|
11292
|
-
|
|
11293
|
-
state: {
|
|
11294
|
-
...ctx$1.utils.state,
|
|
11295
|
-
path: ref([...fromRef(ctx$1.utils.state.path), "additionalProperties"])
|
|
11296
|
-
}
|
|
11297
|
-
});
|
|
11298
|
-
if (additionalAst.hasLazyExpression) ctx$1.utils.ast.hasLazyExpression = true;
|
|
11299
|
-
return additionalAst.expression;
|
|
11350
|
+
const additionalResult = walk(schema.additionalProperties, childContext(walkerCtx, "additionalProperties"));
|
|
11351
|
+
if (additionalResult.hasLazyExpression) ctx$1.utils.ast.hasLazyExpression = true;
|
|
11352
|
+
return applyModifiers(additionalResult, {}).expression;
|
|
11300
11353
|
}
|
|
11301
11354
|
function baseNode$9(ctx$1) {
|
|
11302
11355
|
const { nodes, symbols } = ctx$1;
|
|
@@ -11310,34 +11363,27 @@ function objectResolver$2(ctx$1) {
|
|
|
11310
11363
|
return ctx$1.nodes.base(ctx$1);
|
|
11311
11364
|
}
|
|
11312
11365
|
function shapeNode$2(ctx$1) {
|
|
11313
|
-
const {
|
|
11366
|
+
const { applyModifiers, schema, walk, walkerCtx } = ctx$1;
|
|
11314
11367
|
const shape = $.object().pretty();
|
|
11315
11368
|
for (const name in schema.properties) {
|
|
11316
11369
|
const property = schema.properties[name];
|
|
11317
|
-
const
|
|
11318
|
-
|
|
11319
|
-
|
|
11320
|
-
|
|
11321
|
-
|
|
11322
|
-
...ctx$1.utils.state,
|
|
11323
|
-
path: ref([
|
|
11324
|
-
...fromRef(ctx$1.utils.state.path),
|
|
11325
|
-
"properties",
|
|
11326
|
-
name
|
|
11327
|
-
])
|
|
11328
|
-
}
|
|
11329
|
-
});
|
|
11330
|
-
if (propertyAst.hasLazyExpression) {
|
|
11370
|
+
const isOptional = !schema.required?.includes(name);
|
|
11371
|
+
const propertyResult = walk(property, childContext(walkerCtx, "properties", name));
|
|
11372
|
+
if (propertyResult.hasLazyExpression) ctx$1.utils.ast.hasLazyExpression = true;
|
|
11373
|
+
const ast = applyModifiers(propertyResult, { optional: isOptional });
|
|
11374
|
+
if (ast.hasLazyExpression) {
|
|
11331
11375
|
ctx$1.utils.ast.hasLazyExpression = true;
|
|
11332
|
-
shape.getter(name,
|
|
11333
|
-
} else shape.prop(name,
|
|
11376
|
+
shape.getter(name, ast.expression.return());
|
|
11377
|
+
} else shape.prop(name, ast.expression);
|
|
11334
11378
|
}
|
|
11335
11379
|
return shape;
|
|
11336
11380
|
}
|
|
11337
|
-
|
|
11381
|
+
function objectToAst$2(options) {
|
|
11382
|
+
const { plugin } = options;
|
|
11338
11383
|
const ast = {};
|
|
11339
11384
|
const z = plugin.external("zod.z");
|
|
11340
11385
|
const ctx$1 = {
|
|
11386
|
+
...options,
|
|
11341
11387
|
$,
|
|
11342
11388
|
chain: { current: $(z) },
|
|
11343
11389
|
nodes: {
|
|
@@ -11346,17 +11392,16 @@ const objectToAst$2 = ({ plugin, schema, state }) => {
|
|
|
11346
11392
|
shape: shapeNode$2
|
|
11347
11393
|
},
|
|
11348
11394
|
plugin,
|
|
11349
|
-
schema,
|
|
11350
11395
|
symbols: { z },
|
|
11351
11396
|
utils: {
|
|
11352
11397
|
ast,
|
|
11353
|
-
state
|
|
11398
|
+
state: options.state
|
|
11354
11399
|
}
|
|
11355
11400
|
};
|
|
11356
11401
|
const resolver = plugin.config["~resolvers"]?.object;
|
|
11357
11402
|
ast.expression = resolver?.(ctx$1) ?? objectResolver$2(ctx$1);
|
|
11358
11403
|
return ast;
|
|
11359
|
-
}
|
|
11404
|
+
}
|
|
11360
11405
|
|
|
11361
11406
|
//#endregion
|
|
11362
11407
|
//#region src/plugins/zod/mini/toAst/string.ts
|
|
@@ -11409,7 +11454,8 @@ function patternNode$2(ctx$1) {
|
|
|
11409
11454
|
const { schema, symbols } = ctx$1;
|
|
11410
11455
|
const { z } = symbols;
|
|
11411
11456
|
if (!schema.pattern) return;
|
|
11412
|
-
|
|
11457
|
+
const flags = /\\[pP]\{/.test(schema.pattern) ? "u" : void 0;
|
|
11458
|
+
return $(z).attr(identifiers.regex).call($.regexp(schema.pattern, flags));
|
|
11413
11459
|
}
|
|
11414
11460
|
function stringResolver$2(ctx$1) {
|
|
11415
11461
|
const constNode$8 = ctx$1.nodes.const(ctx$1);
|
|
@@ -11435,7 +11481,7 @@ function stringResolver$2(ctx$1) {
|
|
|
11435
11481
|
if (checks.length > 0) ctx$1.chain.current = ctx$1.chain.current.attr(identifiers.check).call(...checks);
|
|
11436
11482
|
return ctx$1.chain.current;
|
|
11437
11483
|
}
|
|
11438
|
-
|
|
11484
|
+
function stringToNode$2({ plugin, schema }) {
|
|
11439
11485
|
const z = plugin.external("zod.z");
|
|
11440
11486
|
const ctx$1 = {
|
|
11441
11487
|
$,
|
|
@@ -11455,13 +11501,14 @@ const stringToNode$2 = ({ plugin, schema }) => {
|
|
|
11455
11501
|
};
|
|
11456
11502
|
const resolver = plugin.config["~resolvers"]?.string;
|
|
11457
11503
|
return { expression: resolver?.(ctx$1) ?? stringResolver$2(ctx$1) };
|
|
11458
|
-
}
|
|
11504
|
+
}
|
|
11459
11505
|
|
|
11460
11506
|
//#endregion
|
|
11461
11507
|
//#region src/plugins/zod/mini/toAst/tuple.ts
|
|
11462
|
-
|
|
11463
|
-
const
|
|
11508
|
+
function tupleToAst$2(options) {
|
|
11509
|
+
const { applyModifiers, plugin, schema, walk } = options;
|
|
11464
11510
|
const result = {};
|
|
11511
|
+
const z = plugin.external("zod.z");
|
|
11465
11512
|
if (schema.const && Array.isArray(schema.const)) {
|
|
11466
11513
|
const tupleElements$1 = schema.const.map((value) => $(z).attr(identifiers.literal).call($.fromValue(value)));
|
|
11467
11514
|
result.expression = $(z).attr(identifiers.tuple).call($.array(...tupleElements$1));
|
|
@@ -11469,347 +11516,490 @@ const tupleToAst$2 = ({ plugin, schema, state }) => {
|
|
|
11469
11516
|
}
|
|
11470
11517
|
const tupleElements = [];
|
|
11471
11518
|
if (schema.items) schema.items.forEach((item, index) => {
|
|
11472
|
-
const
|
|
11473
|
-
|
|
11474
|
-
|
|
11475
|
-
|
|
11476
|
-
|
|
11477
|
-
|
|
11478
|
-
|
|
11479
|
-
"items",
|
|
11480
|
-
index
|
|
11481
|
-
])
|
|
11482
|
-
}
|
|
11483
|
-
});
|
|
11484
|
-
tupleElements.push(itemSchema.expression);
|
|
11485
|
-
if (itemSchema.hasLazyExpression) result.hasLazyExpression = true;
|
|
11519
|
+
const itemResult = walk(item, childContext({
|
|
11520
|
+
path: options.state.path,
|
|
11521
|
+
plugin: options.plugin
|
|
11522
|
+
}, "items", index));
|
|
11523
|
+
if (itemResult.hasLazyExpression) result.hasLazyExpression = true;
|
|
11524
|
+
const finalExpr = applyModifiers(itemResult, { optional: false });
|
|
11525
|
+
tupleElements.push(finalExpr.expression);
|
|
11486
11526
|
});
|
|
11487
11527
|
result.expression = $(z).attr(identifiers.tuple).call($.array(...tupleElements));
|
|
11488
11528
|
return result;
|
|
11489
|
-
}
|
|
11529
|
+
}
|
|
11490
11530
|
|
|
11491
11531
|
//#endregion
|
|
11492
11532
|
//#region src/plugins/zod/mini/toAst/undefined.ts
|
|
11493
|
-
|
|
11533
|
+
function undefinedToAst$2({ plugin }) {
|
|
11494
11534
|
const z = plugin.external("zod.z");
|
|
11495
11535
|
const result = {};
|
|
11496
11536
|
result.expression = $(z).attr(identifiers.undefined).call();
|
|
11497
11537
|
return result;
|
|
11498
|
-
}
|
|
11538
|
+
}
|
|
11499
11539
|
|
|
11500
11540
|
//#endregion
|
|
11501
11541
|
//#region src/plugins/zod/mini/toAst/void.ts
|
|
11502
|
-
|
|
11542
|
+
function voidToAst$2({ plugin }) {
|
|
11503
11543
|
const z = plugin.external("zod.z");
|
|
11504
11544
|
const result = {};
|
|
11505
11545
|
result.expression = $(z).attr(identifiers.void).call();
|
|
11506
11546
|
return result;
|
|
11507
|
-
};
|
|
11508
|
-
|
|
11509
|
-
//#endregion
|
|
11510
|
-
//#region src/plugins/zod/mini/toAst/index.ts
|
|
11511
|
-
function irSchemaWithTypeToAst$2({ schema, ...args }) {
|
|
11512
|
-
switch (schema.type) {
|
|
11513
|
-
case "array": return arrayToAst$2({
|
|
11514
|
-
...args,
|
|
11515
|
-
schema
|
|
11516
|
-
});
|
|
11517
|
-
case "boolean": return booleanToAst$2({
|
|
11518
|
-
...args,
|
|
11519
|
-
schema
|
|
11520
|
-
});
|
|
11521
|
-
case "enum": return enumToAst$2({
|
|
11522
|
-
...args,
|
|
11523
|
-
schema
|
|
11524
|
-
});
|
|
11525
|
-
case "integer":
|
|
11526
|
-
case "number": return numberToNode$2({
|
|
11527
|
-
...args,
|
|
11528
|
-
schema
|
|
11529
|
-
});
|
|
11530
|
-
case "never": return neverToAst$2({
|
|
11531
|
-
...args,
|
|
11532
|
-
schema
|
|
11533
|
-
});
|
|
11534
|
-
case "null": return nullToAst$2({
|
|
11535
|
-
...args,
|
|
11536
|
-
schema
|
|
11537
|
-
});
|
|
11538
|
-
case "object": return objectToAst$2({
|
|
11539
|
-
...args,
|
|
11540
|
-
schema
|
|
11541
|
-
});
|
|
11542
|
-
case "string": return shouldCoerceToBigInt(schema.format) ? numberToNode$2({
|
|
11543
|
-
...args,
|
|
11544
|
-
schema: {
|
|
11545
|
-
...schema,
|
|
11546
|
-
type: "number"
|
|
11547
|
-
}
|
|
11548
|
-
}) : stringToNode$2({
|
|
11549
|
-
...args,
|
|
11550
|
-
schema
|
|
11551
|
-
});
|
|
11552
|
-
case "tuple": return tupleToAst$2({
|
|
11553
|
-
...args,
|
|
11554
|
-
schema
|
|
11555
|
-
});
|
|
11556
|
-
case "undefined": return undefinedToAst$2({
|
|
11557
|
-
...args,
|
|
11558
|
-
schema
|
|
11559
|
-
});
|
|
11560
|
-
case "unknown": return unknownToAst$2({
|
|
11561
|
-
...args,
|
|
11562
|
-
schema
|
|
11563
|
-
});
|
|
11564
|
-
case "void": return voidToAst$2({
|
|
11565
|
-
...args,
|
|
11566
|
-
schema
|
|
11567
|
-
});
|
|
11568
|
-
}
|
|
11569
|
-
}
|
|
11570
|
-
|
|
11571
|
-
//#endregion
|
|
11572
|
-
//#region src/plugins/zod/mini/plugin.ts
|
|
11573
|
-
function irSchemaToAst$2({ optional, plugin, schema, schemaExtractor, state }) {
|
|
11574
|
-
if (schemaExtractor && !schema.$ref) {
|
|
11575
|
-
const extracted = schemaExtractor({
|
|
11576
|
-
meta: {
|
|
11577
|
-
resource: "definition",
|
|
11578
|
-
resourceId: pathToJsonPointer(fromRef(state.path))
|
|
11579
|
-
},
|
|
11580
|
-
naming: plugin.config.definitions,
|
|
11581
|
-
path: fromRef(state.path),
|
|
11582
|
-
plugin,
|
|
11583
|
-
schema
|
|
11584
|
-
});
|
|
11585
|
-
if (extracted !== schema) schema = extracted;
|
|
11586
|
-
}
|
|
11587
|
-
let ast = {};
|
|
11588
|
-
const z = plugin.external("zod.z");
|
|
11589
|
-
if (schema.$ref) {
|
|
11590
|
-
const query = {
|
|
11591
|
-
category: "schema",
|
|
11592
|
-
resource: "definition",
|
|
11593
|
-
resourceId: schema.$ref,
|
|
11594
|
-
tool: "zod"
|
|
11595
|
-
};
|
|
11596
|
-
const refSymbol = plugin.referenceSymbol(query);
|
|
11597
|
-
if (plugin.isSymbolRegistered(query)) ast.expression = $(refSymbol);
|
|
11598
|
-
else {
|
|
11599
|
-
ast.expression = $(z).attr(identifiers.lazy).call($.func().returns("any").do($(refSymbol).return()));
|
|
11600
|
-
ast.hasLazyExpression = true;
|
|
11601
|
-
state.hasLazyExpression["~ref"] = true;
|
|
11602
|
-
}
|
|
11603
|
-
} else if (schema.type) {
|
|
11604
|
-
const typeAst = irSchemaWithTypeToAst$2({
|
|
11605
|
-
plugin,
|
|
11606
|
-
schema,
|
|
11607
|
-
state
|
|
11608
|
-
});
|
|
11609
|
-
ast.expression = typeAst.expression;
|
|
11610
|
-
ast.hasLazyExpression = typeAst.hasLazyExpression;
|
|
11611
|
-
if (plugin.config.metadata && schema.description) ast.expression = ast.expression.attr(identifiers.register).call($(z).attr(identifiers.globalRegistry), $.object().pretty().prop("description", $.literal(schema.description)));
|
|
11612
|
-
} else if (schema.items) {
|
|
11613
|
-
schema = deduplicateSchema({ schema });
|
|
11614
|
-
if (schema.items) {
|
|
11615
|
-
const itemSchemas = schema.items.map((item, index) => irSchemaToAst$2({
|
|
11616
|
-
plugin,
|
|
11617
|
-
schema: item,
|
|
11618
|
-
state: {
|
|
11619
|
-
...state,
|
|
11620
|
-
path: ref([
|
|
11621
|
-
...fromRef(state.path),
|
|
11622
|
-
"items",
|
|
11623
|
-
index
|
|
11624
|
-
])
|
|
11625
|
-
}
|
|
11626
|
-
}));
|
|
11627
|
-
if (schema.logicalOperator === "and") {
|
|
11628
|
-
const firstSchema = schema.items[0];
|
|
11629
|
-
if (firstSchema.logicalOperator === "or" || firstSchema.type && firstSchema.type !== "object") ast.expression = $(z).attr(identifiers.intersection).call(...itemSchemas.map((schema$1) => schema$1.expression));
|
|
11630
|
-
else {
|
|
11631
|
-
ast.expression = itemSchemas[0].expression;
|
|
11632
|
-
itemSchemas.slice(1).forEach((schema$1) => {
|
|
11633
|
-
ast.expression = $(z).attr(identifiers.intersection).call(ast.expression, schema$1.hasLazyExpression ? $(z).attr(identifiers.lazy).call($.func().do(schema$1.expression.return())) : schema$1.expression);
|
|
11634
|
-
});
|
|
11635
|
-
}
|
|
11636
|
-
} else ast.expression = $(z).attr(identifiers.union).call($.array().pretty().elements(...itemSchemas.map((schema$1) => schema$1.expression)));
|
|
11637
|
-
} else ast = irSchemaToAst$2({
|
|
11638
|
-
plugin,
|
|
11639
|
-
schema,
|
|
11640
|
-
state
|
|
11641
|
-
});
|
|
11642
|
-
} else {
|
|
11643
|
-
const typeAst = irSchemaWithTypeToAst$2({
|
|
11644
|
-
plugin,
|
|
11645
|
-
schema: { type: "unknown" },
|
|
11646
|
-
state
|
|
11647
|
-
});
|
|
11648
|
-
ast.expression = typeAst.expression;
|
|
11649
|
-
}
|
|
11650
|
-
if (ast.expression) {
|
|
11651
|
-
if (schema.accessScope === "read") ast.expression = $(z).attr(identifiers.readonly).call(ast.expression);
|
|
11652
|
-
if (optional) {
|
|
11653
|
-
ast.expression = $(z).attr(identifiers.optional).call(ast.expression);
|
|
11654
|
-
ast.typeName = identifiers.ZodMiniOptional;
|
|
11655
|
-
}
|
|
11656
|
-
if (schema.default !== void 0) ast.expression = $(z).attr(identifiers._default).call(ast.expression, schema.type === "integer" || schema.type === "number" ? maybeBigInt(schema.default, schema.format) : $.fromValue(schema.default));
|
|
11657
|
-
}
|
|
11658
|
-
return ast;
|
|
11659
11547
|
}
|
|
11660
|
-
const handlerMini = ({ plugin }) => {
|
|
11661
|
-
plugin.symbol("z", {
|
|
11662
|
-
external: getZodModule({ plugin }),
|
|
11663
|
-
importKind: "namespace",
|
|
11664
|
-
meta: {
|
|
11665
|
-
category: "external",
|
|
11666
|
-
resource: "zod.z"
|
|
11667
|
-
}
|
|
11668
|
-
});
|
|
11669
|
-
const processor = createProcessor$2(plugin);
|
|
11670
|
-
plugin.forEach("operation", "parameter", "requestBody", "schema", "webhook", (event) => {
|
|
11671
|
-
switch (event.type) {
|
|
11672
|
-
case "operation":
|
|
11673
|
-
irOperationToAst({
|
|
11674
|
-
operation: event.operation,
|
|
11675
|
-
path: event._path,
|
|
11676
|
-
plugin,
|
|
11677
|
-
processor,
|
|
11678
|
-
tags: event.tags
|
|
11679
|
-
});
|
|
11680
|
-
break;
|
|
11681
|
-
case "parameter":
|
|
11682
|
-
processor.process({
|
|
11683
|
-
meta: {
|
|
11684
|
-
resource: "definition",
|
|
11685
|
-
resourceId: pathToJsonPointer(event._path)
|
|
11686
|
-
},
|
|
11687
|
-
naming: plugin.config.definitions,
|
|
11688
|
-
path: event._path,
|
|
11689
|
-
plugin,
|
|
11690
|
-
schema: event.parameter.schema,
|
|
11691
|
-
tags: event.tags
|
|
11692
|
-
});
|
|
11693
|
-
break;
|
|
11694
|
-
case "requestBody":
|
|
11695
|
-
processor.process({
|
|
11696
|
-
meta: {
|
|
11697
|
-
resource: "definition",
|
|
11698
|
-
resourceId: pathToJsonPointer(event._path)
|
|
11699
|
-
},
|
|
11700
|
-
naming: plugin.config.definitions,
|
|
11701
|
-
path: event._path,
|
|
11702
|
-
plugin,
|
|
11703
|
-
schema: event.requestBody.schema,
|
|
11704
|
-
tags: event.tags
|
|
11705
|
-
});
|
|
11706
|
-
break;
|
|
11707
|
-
case "schema":
|
|
11708
|
-
processor.process({
|
|
11709
|
-
meta: {
|
|
11710
|
-
resource: "definition",
|
|
11711
|
-
resourceId: pathToJsonPointer(event._path)
|
|
11712
|
-
},
|
|
11713
|
-
naming: plugin.config.definitions,
|
|
11714
|
-
path: event._path,
|
|
11715
|
-
plugin,
|
|
11716
|
-
schema: event.schema,
|
|
11717
|
-
tags: event.tags
|
|
11718
|
-
});
|
|
11719
|
-
break;
|
|
11720
|
-
case "webhook":
|
|
11721
|
-
irWebhookToAst({
|
|
11722
|
-
operation: event.operation,
|
|
11723
|
-
path: event._path,
|
|
11724
|
-
plugin,
|
|
11725
|
-
processor,
|
|
11726
|
-
tags: event.tags
|
|
11727
|
-
});
|
|
11728
|
-
break;
|
|
11729
|
-
}
|
|
11730
|
-
});
|
|
11731
|
-
};
|
|
11732
11548
|
|
|
11733
11549
|
//#endregion
|
|
11734
|
-
//#region src/plugins/zod/
|
|
11735
|
-
function
|
|
11736
|
-
const
|
|
11737
|
-
|
|
11738
|
-
|
|
11739
|
-
|
|
11740
|
-
|
|
11741
|
-
|
|
11742
|
-
|
|
11743
|
-
|
|
11744
|
-
|
|
11550
|
+
//#region src/plugins/zod/mini/walker.ts
|
|
11551
|
+
function createVisitor$2(config) {
|
|
11552
|
+
const { schemaExtractor, state } = config;
|
|
11553
|
+
return {
|
|
11554
|
+
applyModifiers(result, ctx$1, options = {}) {
|
|
11555
|
+
const { optional } = options;
|
|
11556
|
+
const z = ctx$1.plugin.external("zod.z");
|
|
11557
|
+
let expression = result.expression.expression;
|
|
11558
|
+
if (result.readonly) expression = $(z).attr(identifiers.readonly).call(expression);
|
|
11559
|
+
const hasDefault = result.default !== void 0;
|
|
11560
|
+
const needsNullable = result.nullable;
|
|
11561
|
+
if (optional && needsNullable) expression = $(z).attr(identifiers.nullish).call(expression);
|
|
11562
|
+
else if (optional) expression = $(z).attr(identifiers.optional).call(expression);
|
|
11563
|
+
else if (needsNullable) expression = $(z).attr(identifiers.nullable).call(expression);
|
|
11564
|
+
if (hasDefault) expression = $(z).attr(identifiers._default).call(expression, result.format ? maybeBigInt(result.default, result.format) : $.fromValue(result.default));
|
|
11565
|
+
return { expression };
|
|
11566
|
+
},
|
|
11567
|
+
array(schema, ctx$1, walk) {
|
|
11568
|
+
const applyModifiers = (result, opts) => this.applyModifiers(result, ctx$1, opts);
|
|
11569
|
+
const ast = arrayToAst$2({
|
|
11570
|
+
...ctx$1,
|
|
11571
|
+
applyModifiers,
|
|
11572
|
+
schema,
|
|
11573
|
+
state,
|
|
11574
|
+
walk
|
|
11745
11575
|
});
|
|
11746
|
-
return {
|
|
11747
|
-
|
|
11748
|
-
|
|
11749
|
-
|
|
11750
|
-
|
|
11751
|
-
|
|
11752
|
-
|
|
11753
|
-
|
|
11754
|
-
|
|
11755
|
-
|
|
11756
|
-
|
|
11757
|
-
|
|
11758
|
-
path: ctx$1.path,
|
|
11759
|
-
tags: ctx$1.tags
|
|
11576
|
+
return {
|
|
11577
|
+
default: schema.default,
|
|
11578
|
+
expression: ast,
|
|
11579
|
+
hasLazyExpression: state.hasLazyExpression["~ref"],
|
|
11580
|
+
nullable: false,
|
|
11581
|
+
readonly: schema.accessScope === "read"
|
|
11582
|
+
};
|
|
11583
|
+
},
|
|
11584
|
+
boolean(schema, ctx$1) {
|
|
11585
|
+
const ast = booleanToAst$2({
|
|
11586
|
+
...ctx$1,
|
|
11587
|
+
schema
|
|
11760
11588
|
});
|
|
11761
|
-
|
|
11762
|
-
|
|
11763
|
-
|
|
11764
|
-
|
|
11589
|
+
return {
|
|
11590
|
+
default: schema.default,
|
|
11591
|
+
expression: ast,
|
|
11592
|
+
nullable: false,
|
|
11593
|
+
readonly: schema.accessScope === "read"
|
|
11594
|
+
};
|
|
11595
|
+
},
|
|
11596
|
+
enum(schema, ctx$1) {
|
|
11597
|
+
const ast = enumToAst$2({
|
|
11598
|
+
...ctx$1,
|
|
11599
|
+
schema,
|
|
11765
11600
|
state
|
|
11766
11601
|
});
|
|
11767
|
-
|
|
11602
|
+
const hasNull = schema.items?.some((item) => item.type === "null" || item.const === null) ?? false;
|
|
11603
|
+
return {
|
|
11604
|
+
default: schema.default,
|
|
11605
|
+
expression: ast,
|
|
11606
|
+
nullable: hasNull,
|
|
11607
|
+
readonly: schema.accessScope === "read"
|
|
11608
|
+
};
|
|
11609
|
+
},
|
|
11610
|
+
integer(schema, ctx$1) {
|
|
11611
|
+
const ast = numberToNode$2({
|
|
11768
11612
|
...ctx$1,
|
|
11769
|
-
|
|
11770
|
-
plugin,
|
|
11613
|
+
schema,
|
|
11771
11614
|
state
|
|
11772
11615
|
});
|
|
11773
|
-
|
|
11774
|
-
|
|
11775
|
-
|
|
11776
|
-
|
|
11777
|
-
|
|
11778
|
-
|
|
11779
|
-
|
|
11780
|
-
|
|
11781
|
-
|
|
11616
|
+
return {
|
|
11617
|
+
default: schema.default,
|
|
11618
|
+
expression: ast,
|
|
11619
|
+
format: schema.format,
|
|
11620
|
+
nullable: false,
|
|
11621
|
+
readonly: schema.accessScope === "read"
|
|
11622
|
+
};
|
|
11623
|
+
},
|
|
11624
|
+
intercept(schema, ctx$1, walk) {
|
|
11625
|
+
if (schemaExtractor && !schema.$ref) {
|
|
11626
|
+
const extracted = schemaExtractor({
|
|
11627
|
+
meta: {
|
|
11628
|
+
resource: "definition",
|
|
11629
|
+
resourceId: pathToJsonPointer(fromRef(ctx$1.path))
|
|
11630
|
+
},
|
|
11631
|
+
naming: ctx$1.plugin.config.definitions,
|
|
11632
|
+
path: fromRef(ctx$1.path),
|
|
11633
|
+
plugin: ctx$1.plugin,
|
|
11634
|
+
schema
|
|
11635
|
+
});
|
|
11636
|
+
if (extracted !== schema) return walk(extracted, ctx$1);
|
|
11637
|
+
}
|
|
11638
|
+
},
|
|
11639
|
+
intersection(items, schemas, parentSchema, ctx$1) {
|
|
11640
|
+
const z = ctx$1.plugin.external("zod.z");
|
|
11641
|
+
const hasAnyLazy = items.some((item) => item.hasLazyExpression);
|
|
11642
|
+
let expression = items[0].expression.expression;
|
|
11643
|
+
items.slice(1).forEach((item) => {
|
|
11644
|
+
expression = $(z).attr(identifiers.intersection).call(expression, item.hasLazyExpression ? $(z).attr(identifiers.lazy).call($.func().do(item.expression.expression.return())) : item.expression.expression);
|
|
11645
|
+
});
|
|
11646
|
+
return {
|
|
11647
|
+
default: parentSchema.default,
|
|
11648
|
+
expression: { expression },
|
|
11649
|
+
hasLazyExpression: hasAnyLazy,
|
|
11650
|
+
nullable: items.some((i) => i.nullable),
|
|
11651
|
+
readonly: items.some((i) => i.readonly)
|
|
11652
|
+
};
|
|
11653
|
+
},
|
|
11654
|
+
never(schema, ctx$1) {
|
|
11655
|
+
const ast = neverToAst$2({
|
|
11656
|
+
...ctx$1,
|
|
11657
|
+
schema
|
|
11658
|
+
});
|
|
11659
|
+
return {
|
|
11660
|
+
default: schema.default,
|
|
11661
|
+
expression: ast,
|
|
11662
|
+
nullable: false,
|
|
11663
|
+
readonly: false
|
|
11664
|
+
};
|
|
11665
|
+
},
|
|
11666
|
+
null(schema, ctx$1) {
|
|
11667
|
+
const ast = nullToAst$2({
|
|
11668
|
+
...ctx$1,
|
|
11669
|
+
schema
|
|
11670
|
+
});
|
|
11671
|
+
return {
|
|
11672
|
+
default: schema.default,
|
|
11673
|
+
expression: ast,
|
|
11674
|
+
nullable: false,
|
|
11675
|
+
readonly: false
|
|
11676
|
+
};
|
|
11677
|
+
},
|
|
11678
|
+
number(schema, ctx$1) {
|
|
11679
|
+
const ast = numberToNode$2({
|
|
11680
|
+
...ctx$1,
|
|
11681
|
+
schema,
|
|
11682
|
+
state
|
|
11683
|
+
});
|
|
11684
|
+
return {
|
|
11685
|
+
default: schema.default,
|
|
11686
|
+
expression: ast,
|
|
11687
|
+
format: schema.format,
|
|
11688
|
+
nullable: false,
|
|
11689
|
+
readonly: schema.accessScope === "read"
|
|
11690
|
+
};
|
|
11691
|
+
},
|
|
11692
|
+
object(schema, ctx$1, walk) {
|
|
11693
|
+
const applyModifiers = (result, opts) => this.applyModifiers(result, ctx$1, opts);
|
|
11694
|
+
const ast = objectToAst$2({
|
|
11695
|
+
applyModifiers,
|
|
11696
|
+
plugin: ctx$1.plugin,
|
|
11697
|
+
schema,
|
|
11698
|
+
state,
|
|
11699
|
+
walk,
|
|
11700
|
+
walkerCtx: ctx$1
|
|
11701
|
+
});
|
|
11702
|
+
return {
|
|
11703
|
+
default: schema.default,
|
|
11704
|
+
expression: ast,
|
|
11705
|
+
hasLazyExpression: state.hasLazyExpression["~ref"],
|
|
11706
|
+
nullable: false,
|
|
11707
|
+
readonly: schema.accessScope === "read"
|
|
11708
|
+
};
|
|
11709
|
+
},
|
|
11710
|
+
postProcess(result, schema, ctx$1) {
|
|
11711
|
+
if (ctx$1.plugin.config.metadata && schema.description) {
|
|
11712
|
+
const z = ctx$1.plugin.external("zod.z");
|
|
11713
|
+
return {
|
|
11714
|
+
...result,
|
|
11715
|
+
expression: { expression: result.expression.expression.attr(identifiers.register).call($(z).attr(identifiers.globalRegistry), $.object().pretty().prop("description", $.literal(schema.description))) }
|
|
11716
|
+
};
|
|
11717
|
+
}
|
|
11718
|
+
return result;
|
|
11719
|
+
},
|
|
11720
|
+
reference($ref, schema, ctx$1) {
|
|
11721
|
+
const z = ctx$1.plugin.external("zod.z");
|
|
11722
|
+
const query = {
|
|
11723
|
+
category: "schema",
|
|
11724
|
+
resource: "definition",
|
|
11725
|
+
resourceId: $ref,
|
|
11726
|
+
tool: "zod"
|
|
11727
|
+
};
|
|
11728
|
+
const refSymbol = ctx$1.plugin.referenceSymbol(query);
|
|
11729
|
+
if (ctx$1.plugin.isSymbolRegistered(query)) return {
|
|
11730
|
+
default: schema.default,
|
|
11731
|
+
expression: { expression: $(refSymbol) },
|
|
11732
|
+
nullable: false,
|
|
11733
|
+
readonly: schema.accessScope === "read"
|
|
11734
|
+
};
|
|
11735
|
+
state.hasLazyExpression["~ref"] = true;
|
|
11736
|
+
return {
|
|
11737
|
+
default: schema.default,
|
|
11738
|
+
expression: { expression: $(z).attr(identifiers.lazy).call($.func().returns("any").do($(refSymbol).return())) },
|
|
11739
|
+
hasLazyExpression: true,
|
|
11740
|
+
nullable: false,
|
|
11741
|
+
readonly: schema.accessScope === "read"
|
|
11742
|
+
};
|
|
11743
|
+
},
|
|
11744
|
+
string(schema, ctx$1) {
|
|
11745
|
+
if (shouldCoerceToBigInt(schema.format)) {
|
|
11746
|
+
const ast$1 = numberToNode$2({
|
|
11747
|
+
plugin: ctx$1.plugin,
|
|
11748
|
+
schema: {
|
|
11749
|
+
...schema,
|
|
11750
|
+
type: "number"
|
|
11751
|
+
},
|
|
11752
|
+
state
|
|
11753
|
+
});
|
|
11754
|
+
return {
|
|
11755
|
+
default: schema.default,
|
|
11756
|
+
expression: ast$1,
|
|
11757
|
+
nullable: false,
|
|
11758
|
+
readonly: schema.accessScope === "read"
|
|
11759
|
+
};
|
|
11760
|
+
}
|
|
11761
|
+
const ast = stringToNode$2({
|
|
11762
|
+
...ctx$1,
|
|
11763
|
+
schema
|
|
11764
|
+
});
|
|
11765
|
+
return {
|
|
11766
|
+
default: schema.default,
|
|
11767
|
+
expression: ast,
|
|
11768
|
+
nullable: false,
|
|
11769
|
+
readonly: schema.accessScope === "read"
|
|
11770
|
+
};
|
|
11771
|
+
},
|
|
11772
|
+
tuple(schema, ctx$1, walk) {
|
|
11773
|
+
const applyModifiers = (result, opts) => this.applyModifiers(result, ctx$1, opts);
|
|
11774
|
+
const ast = tupleToAst$2({
|
|
11775
|
+
...ctx$1,
|
|
11776
|
+
applyModifiers,
|
|
11777
|
+
schema,
|
|
11778
|
+
state,
|
|
11779
|
+
walk
|
|
11780
|
+
});
|
|
11781
|
+
return {
|
|
11782
|
+
default: schema.default,
|
|
11783
|
+
expression: ast,
|
|
11784
|
+
hasLazyExpression: state.hasLazyExpression["~ref"],
|
|
11785
|
+
nullable: false,
|
|
11786
|
+
readonly: schema.accessScope === "read"
|
|
11787
|
+
};
|
|
11788
|
+
},
|
|
11789
|
+
undefined(schema, ctx$1) {
|
|
11790
|
+
const ast = undefinedToAst$2({
|
|
11791
|
+
...ctx$1,
|
|
11792
|
+
schema
|
|
11793
|
+
});
|
|
11794
|
+
return {
|
|
11795
|
+
default: schema.default,
|
|
11796
|
+
expression: ast,
|
|
11797
|
+
nullable: false,
|
|
11798
|
+
readonly: false
|
|
11799
|
+
};
|
|
11800
|
+
},
|
|
11801
|
+
union(items, schemas, parentSchema, ctx$1) {
|
|
11802
|
+
const z = ctx$1.plugin.external("zod.z");
|
|
11803
|
+
const hasAnyLazy = items.some((item) => item.hasLazyExpression);
|
|
11804
|
+
const hasNull = schemas.some((s) => s.type === "null") || items.some((i) => i.nullable);
|
|
11805
|
+
const nonNullItems = [];
|
|
11806
|
+
items.forEach((item, index) => {
|
|
11807
|
+
if (schemas[index].type !== "null") nonNullItems.push(item);
|
|
11808
|
+
});
|
|
11809
|
+
let expression;
|
|
11810
|
+
if (nonNullItems.length === 0) expression = { expression: $(z).attr(identifiers.null).call() };
|
|
11811
|
+
else if (nonNullItems.length === 1) expression = nonNullItems[0].expression;
|
|
11812
|
+
else expression = { expression: $(z).attr(identifiers.union).call($.array().pretty().elements(...nonNullItems.map((item) => item.expression.expression))) };
|
|
11813
|
+
return {
|
|
11814
|
+
default: parentSchema.default,
|
|
11815
|
+
expression,
|
|
11816
|
+
hasLazyExpression: hasAnyLazy,
|
|
11817
|
+
nullable: hasNull,
|
|
11818
|
+
readonly: items.some((i) => i.readonly)
|
|
11819
|
+
};
|
|
11820
|
+
},
|
|
11821
|
+
unknown(schema, ctx$1) {
|
|
11822
|
+
const ast = unknownToAst$2({
|
|
11823
|
+
...ctx$1,
|
|
11824
|
+
schema
|
|
11825
|
+
});
|
|
11826
|
+
return {
|
|
11827
|
+
default: schema.default,
|
|
11828
|
+
expression: ast,
|
|
11829
|
+
nullable: false,
|
|
11830
|
+
readonly: false
|
|
11831
|
+
};
|
|
11832
|
+
},
|
|
11833
|
+
void(schema, ctx$1) {
|
|
11834
|
+
const ast = voidToAst$2({
|
|
11835
|
+
...ctx$1,
|
|
11836
|
+
schema
|
|
11837
|
+
});
|
|
11838
|
+
return {
|
|
11839
|
+
default: schema.default,
|
|
11840
|
+
expression: ast,
|
|
11841
|
+
nullable: false,
|
|
11842
|
+
readonly: false
|
|
11843
|
+
};
|
|
11844
|
+
}
|
|
11845
|
+
};
|
|
11846
|
+
}
|
|
11847
|
+
|
|
11848
|
+
//#endregion
|
|
11849
|
+
//#region src/plugins/zod/mini/processor.ts
|
|
11850
|
+
function createProcessor$2(plugin) {
|
|
11851
|
+
const processor = createSchemaProcessor();
|
|
11852
|
+
const hooks = [plugin.config["~hooks"]?.schemas, plugin.context.config.parser.hooks.schemas];
|
|
11853
|
+
function extractor(ctx$1) {
|
|
11854
|
+
if (processor.hasEmitted(ctx$1.path)) return ctx$1.schema;
|
|
11855
|
+
for (const hook of hooks) if (hook?.shouldExtract?.(ctx$1)) {
|
|
11856
|
+
process$1({
|
|
11857
|
+
namingAnchor: processor.context.anchor,
|
|
11858
|
+
tags: processor.context.tags,
|
|
11859
|
+
...ctx$1
|
|
11860
|
+
});
|
|
11861
|
+
return { $ref: pathToJsonPointer(ctx$1.path) };
|
|
11862
|
+
}
|
|
11863
|
+
return ctx$1.schema;
|
|
11864
|
+
}
|
|
11865
|
+
function process$1(ctx$1) {
|
|
11866
|
+
if (!processor.markEmitted(ctx$1.path)) return;
|
|
11867
|
+
processor.withContext({
|
|
11868
|
+
anchor: ctx$1.namingAnchor,
|
|
11869
|
+
tags: ctx$1.tags
|
|
11870
|
+
}, () => {
|
|
11871
|
+
const state = refs({
|
|
11872
|
+
hasLazyExpression: false,
|
|
11873
|
+
path: ctx$1.path,
|
|
11874
|
+
tags: ctx$1.tags
|
|
11875
|
+
});
|
|
11876
|
+
const visitor = createVisitor$2({
|
|
11877
|
+
schemaExtractor: extractor,
|
|
11878
|
+
state
|
|
11879
|
+
});
|
|
11880
|
+
const result = createSchemaWalker(visitor)(ctx$1.schema, {
|
|
11881
|
+
path: ref(ctx$1.path),
|
|
11882
|
+
plugin
|
|
11883
|
+
});
|
|
11884
|
+
const ast = visitor.applyModifiers(result, {
|
|
11885
|
+
path: ref(ctx$1.path),
|
|
11886
|
+
plugin
|
|
11887
|
+
}) ?? result.expression;
|
|
11888
|
+
if (result.hasLazyExpression) state.hasLazyExpression["~ref"] = true;
|
|
11889
|
+
exportAst({
|
|
11890
|
+
...ctx$1,
|
|
11891
|
+
ast,
|
|
11892
|
+
plugin,
|
|
11893
|
+
state
|
|
11894
|
+
});
|
|
11895
|
+
});
|
|
11896
|
+
}
|
|
11897
|
+
return { process: process$1 };
|
|
11898
|
+
}
|
|
11899
|
+
|
|
11900
|
+
//#endregion
|
|
11901
|
+
//#region src/plugins/zod/mini/plugin.ts
|
|
11902
|
+
const handlerMini = ({ plugin }) => {
|
|
11903
|
+
plugin.symbol("z", {
|
|
11904
|
+
external: getZodModule({ plugin }),
|
|
11905
|
+
importKind: "namespace",
|
|
11906
|
+
meta: {
|
|
11907
|
+
category: "external",
|
|
11908
|
+
resource: "zod.z"
|
|
11909
|
+
}
|
|
11910
|
+
});
|
|
11911
|
+
const processor = createProcessor$2(plugin);
|
|
11912
|
+
plugin.forEach("operation", "parameter", "requestBody", "schema", "webhook", (event) => {
|
|
11913
|
+
switch (event.type) {
|
|
11914
|
+
case "operation":
|
|
11915
|
+
irOperationToAst({
|
|
11916
|
+
operation: event.operation,
|
|
11917
|
+
path: event._path,
|
|
11918
|
+
plugin,
|
|
11919
|
+
processor,
|
|
11920
|
+
tags: event.tags
|
|
11921
|
+
});
|
|
11922
|
+
break;
|
|
11923
|
+
case "parameter":
|
|
11924
|
+
processor.process({
|
|
11925
|
+
meta: {
|
|
11926
|
+
resource: "definition",
|
|
11927
|
+
resourceId: pathToJsonPointer(event._path)
|
|
11928
|
+
},
|
|
11929
|
+
naming: plugin.config.definitions,
|
|
11930
|
+
path: event._path,
|
|
11931
|
+
plugin,
|
|
11932
|
+
schema: event.parameter.schema,
|
|
11933
|
+
tags: event.tags
|
|
11934
|
+
});
|
|
11935
|
+
break;
|
|
11936
|
+
case "requestBody":
|
|
11937
|
+
processor.process({
|
|
11938
|
+
meta: {
|
|
11939
|
+
resource: "definition",
|
|
11940
|
+
resourceId: pathToJsonPointer(event._path)
|
|
11941
|
+
},
|
|
11942
|
+
naming: plugin.config.definitions,
|
|
11943
|
+
path: event._path,
|
|
11944
|
+
plugin,
|
|
11945
|
+
schema: event.requestBody.schema,
|
|
11946
|
+
tags: event.tags
|
|
11947
|
+
});
|
|
11948
|
+
break;
|
|
11949
|
+
case "schema":
|
|
11950
|
+
processor.process({
|
|
11951
|
+
meta: {
|
|
11952
|
+
resource: "definition",
|
|
11953
|
+
resourceId: pathToJsonPointer(event._path)
|
|
11954
|
+
},
|
|
11955
|
+
naming: plugin.config.definitions,
|
|
11956
|
+
path: event._path,
|
|
11957
|
+
plugin,
|
|
11958
|
+
schema: event.schema,
|
|
11959
|
+
tags: event.tags
|
|
11960
|
+
});
|
|
11961
|
+
break;
|
|
11962
|
+
case "webhook":
|
|
11963
|
+
irWebhookToAst({
|
|
11964
|
+
operation: event.operation,
|
|
11965
|
+
path: event._path,
|
|
11966
|
+
plugin,
|
|
11967
|
+
processor,
|
|
11968
|
+
tags: event.tags
|
|
11969
|
+
});
|
|
11970
|
+
break;
|
|
11971
|
+
}
|
|
11972
|
+
});
|
|
11782
11973
|
};
|
|
11783
11974
|
|
|
11975
|
+
//#endregion
|
|
11976
|
+
//#region src/plugins/zod/v3/toAst/unknown.ts
|
|
11977
|
+
function unknownToAst$1({ plugin }) {
|
|
11978
|
+
return $(plugin.external("zod.z")).attr(identifiers.unknown).call();
|
|
11979
|
+
}
|
|
11980
|
+
|
|
11784
11981
|
//#endregion
|
|
11785
11982
|
//#region src/plugins/zod/v3/toAst/array.ts
|
|
11786
|
-
|
|
11983
|
+
function arrayToAst$1(options) {
|
|
11984
|
+
const { applyModifiers, plugin, walk } = options;
|
|
11985
|
+
let { schema } = options;
|
|
11787
11986
|
const z = plugin.external("zod.z");
|
|
11788
11987
|
const functionName = $(z).attr(identifiers.array);
|
|
11789
11988
|
let arrayExpression;
|
|
11790
11989
|
let hasLazyExpression = false;
|
|
11791
11990
|
if (!schema.items) arrayExpression = functionName.call(unknownToAst$1({
|
|
11792
|
-
|
|
11793
|
-
schema: { type: "unknown" }
|
|
11794
|
-
state
|
|
11991
|
+
...options,
|
|
11992
|
+
schema: { type: "unknown" }
|
|
11795
11993
|
}));
|
|
11796
11994
|
else {
|
|
11797
11995
|
schema = deduplicateSchema({ schema });
|
|
11798
11996
|
const itemExpressions = schema.items.map((item, index) => {
|
|
11799
|
-
const
|
|
11800
|
-
|
|
11801
|
-
|
|
11802
|
-
|
|
11803
|
-
|
|
11804
|
-
|
|
11805
|
-
...fromRef(state.path),
|
|
11806
|
-
"items",
|
|
11807
|
-
index
|
|
11808
|
-
])
|
|
11809
|
-
}
|
|
11810
|
-
});
|
|
11811
|
-
if (itemAst.hasLazyExpression) hasLazyExpression = true;
|
|
11812
|
-
return itemAst.expression;
|
|
11997
|
+
const itemResult = walk(item, childContext({
|
|
11998
|
+
path: options.state.path,
|
|
11999
|
+
plugin: options.plugin
|
|
12000
|
+
}, "items", index));
|
|
12001
|
+
if (itemResult.hasLazyExpression) hasLazyExpression = true;
|
|
12002
|
+
return applyModifiers(itemResult, { optional: false }).expression;
|
|
11813
12003
|
});
|
|
11814
12004
|
if (itemExpressions.length === 1) arrayExpression = functionName.call(...itemExpressions);
|
|
11815
12005
|
else if (schema.logicalOperator === "and") {
|
|
@@ -11832,7 +12022,7 @@ const arrayToAst$1 = ({ plugin, schema, state }) => {
|
|
|
11832
12022
|
expression: arrayExpression,
|
|
11833
12023
|
hasLazyExpression
|
|
11834
12024
|
};
|
|
11835
|
-
}
|
|
12025
|
+
}
|
|
11836
12026
|
|
|
11837
12027
|
//#endregion
|
|
11838
12028
|
//#region src/plugins/zod/v3/toAst/boolean.ts
|
|
@@ -11884,30 +12074,21 @@ function baseNode$7(ctx$1) {
|
|
|
11884
12074
|
else if (literalMembers.length === 1) return literalMembers[0];
|
|
11885
12075
|
else return $(z).attr(identifiers.union).call($.array(...literalMembers));
|
|
11886
12076
|
}
|
|
11887
|
-
function nullableNode$1(ctx$1) {
|
|
11888
|
-
const { chain } = ctx$1;
|
|
11889
|
-
const { isNullable } = ctx$1.nodes.items(ctx$1);
|
|
11890
|
-
if (!isNullable) return;
|
|
11891
|
-
return chain.current.attr(identifiers.nullable).call();
|
|
11892
|
-
}
|
|
11893
12077
|
function enumResolver$1(ctx$1) {
|
|
11894
12078
|
const { literalMembers } = ctx$1.nodes.items(ctx$1);
|
|
11895
12079
|
if (!literalMembers.length) return ctx$1.chain.current;
|
|
11896
12080
|
const baseExpression = ctx$1.nodes.base(ctx$1);
|
|
11897
12081
|
ctx$1.chain.current = baseExpression;
|
|
11898
|
-
const nullableExpression = ctx$1.nodes.nullable(ctx$1);
|
|
11899
|
-
if (nullableExpression) ctx$1.chain.current = nullableExpression;
|
|
11900
12082
|
return ctx$1.chain.current;
|
|
11901
12083
|
}
|
|
11902
|
-
|
|
12084
|
+
function enumToAst$1({ plugin, schema, state }) {
|
|
11903
12085
|
const z = plugin.external("zod.z");
|
|
11904
12086
|
const { literalMembers } = itemsNode$1({
|
|
11905
12087
|
$,
|
|
11906
12088
|
chain: { current: $(z) },
|
|
11907
12089
|
nodes: {
|
|
11908
12090
|
base: baseNode$7,
|
|
11909
|
-
items: itemsNode$1
|
|
11910
|
-
nullable: nullableNode$1
|
|
12091
|
+
items: itemsNode$1
|
|
11911
12092
|
},
|
|
11912
12093
|
plugin,
|
|
11913
12094
|
schema,
|
|
@@ -11919,16 +12100,14 @@ const enumToAst$1 = ({ plugin, schema, state }) => {
|
|
|
11919
12100
|
});
|
|
11920
12101
|
if (!literalMembers.length) return unknownToAst$1({
|
|
11921
12102
|
plugin,
|
|
11922
|
-
schema: { type: "unknown" }
|
|
11923
|
-
state
|
|
12103
|
+
schema: { type: "unknown" }
|
|
11924
12104
|
});
|
|
11925
12105
|
const ctx$1 = {
|
|
11926
12106
|
$,
|
|
11927
12107
|
chain: { current: $(z) },
|
|
11928
12108
|
nodes: {
|
|
11929
12109
|
base: baseNode$7,
|
|
11930
|
-
items: itemsNode$1
|
|
11931
|
-
nullable: nullableNode$1
|
|
12110
|
+
items: itemsNode$1
|
|
11932
12111
|
},
|
|
11933
12112
|
plugin,
|
|
11934
12113
|
schema,
|
|
@@ -11940,19 +12119,19 @@ const enumToAst$1 = ({ plugin, schema, state }) => {
|
|
|
11940
12119
|
};
|
|
11941
12120
|
const resolver = plugin.config["~resolvers"]?.enum;
|
|
11942
12121
|
return resolver?.(ctx$1) ?? enumResolver$1(ctx$1);
|
|
11943
|
-
}
|
|
12122
|
+
}
|
|
11944
12123
|
|
|
11945
12124
|
//#endregion
|
|
11946
12125
|
//#region src/plugins/zod/v3/toAst/never.ts
|
|
11947
|
-
|
|
12126
|
+
function neverToAst$1({ plugin }) {
|
|
11948
12127
|
return $(plugin.external("zod.z")).attr(identifiers.never).call();
|
|
11949
|
-
}
|
|
12128
|
+
}
|
|
11950
12129
|
|
|
11951
12130
|
//#endregion
|
|
11952
12131
|
//#region src/plugins/zod/v3/toAst/null.ts
|
|
11953
|
-
|
|
12132
|
+
function nullToAst$1({ plugin }) {
|
|
11954
12133
|
return $(plugin.external("zod.z")).attr(identifiers.null).call();
|
|
11955
|
-
}
|
|
12134
|
+
}
|
|
11956
12135
|
|
|
11957
12136
|
//#endregion
|
|
11958
12137
|
//#region src/plugins/zod/v3/toAst/number.ts
|
|
@@ -11998,7 +12177,7 @@ function numberResolver$1(ctx$1) {
|
|
|
11998
12177
|
if (maxNode$4) ctx$1.chain.current = maxNode$4;
|
|
11999
12178
|
return ctx$1.chain.current;
|
|
12000
12179
|
}
|
|
12001
|
-
|
|
12180
|
+
function numberToNode$1({ plugin, schema, state }) {
|
|
12002
12181
|
const ast = {};
|
|
12003
12182
|
const z = plugin.external("zod.z");
|
|
12004
12183
|
const ctx$1 = {
|
|
@@ -12023,23 +12202,16 @@ const numberToNode$1 = ({ plugin, schema, state }) => {
|
|
|
12023
12202
|
};
|
|
12024
12203
|
const resolver = plugin.config["~resolvers"]?.number;
|
|
12025
12204
|
return resolver?.(ctx$1) ?? numberResolver$1(ctx$1);
|
|
12026
|
-
}
|
|
12205
|
+
}
|
|
12027
12206
|
|
|
12028
12207
|
//#endregion
|
|
12029
12208
|
//#region src/plugins/zod/v3/toAst/object.ts
|
|
12030
12209
|
function additionalPropertiesNode$1(ctx$1) {
|
|
12031
|
-
const {
|
|
12210
|
+
const { applyModifiers, schema, walk, walkerCtx } = ctx$1;
|
|
12032
12211
|
if (!schema.additionalProperties || schema.properties && Object.keys(schema.properties).length > 0) return;
|
|
12033
|
-
const
|
|
12034
|
-
|
|
12035
|
-
|
|
12036
|
-
state: {
|
|
12037
|
-
...ctx$1.utils.state,
|
|
12038
|
-
path: ref([...fromRef(ctx$1.utils.state.path), "additionalProperties"])
|
|
12039
|
-
}
|
|
12040
|
-
});
|
|
12041
|
-
if (additionalAst.hasLazyExpression) ctx$1.utils.ast.hasLazyExpression = true;
|
|
12042
|
-
return additionalAst.expression;
|
|
12212
|
+
const additionalResult = walk(schema.additionalProperties, childContext(walkerCtx, "additionalProperties"));
|
|
12213
|
+
if (additionalResult.hasLazyExpression) ctx$1.utils.ast.hasLazyExpression = true;
|
|
12214
|
+
return applyModifiers(additionalResult, {}).expression;
|
|
12043
12215
|
}
|
|
12044
12216
|
function baseNode$5(ctx$1) {
|
|
12045
12217
|
const { nodes, symbols } = ctx$1;
|
|
@@ -12053,32 +12225,25 @@ function objectResolver$1(ctx$1) {
|
|
|
12053
12225
|
return ctx$1.nodes.base(ctx$1);
|
|
12054
12226
|
}
|
|
12055
12227
|
function shapeNode$1(ctx$1) {
|
|
12056
|
-
const {
|
|
12228
|
+
const { applyModifiers, schema, walk, walkerCtx } = ctx$1;
|
|
12057
12229
|
const shape = $.object().pretty();
|
|
12058
12230
|
for (const name in schema.properties) {
|
|
12059
12231
|
const property = schema.properties[name];
|
|
12060
|
-
const
|
|
12061
|
-
|
|
12062
|
-
|
|
12063
|
-
|
|
12064
|
-
|
|
12065
|
-
|
|
12066
|
-
path: ref([
|
|
12067
|
-
...fromRef(ctx$1.utils.state.path),
|
|
12068
|
-
"properties",
|
|
12069
|
-
name
|
|
12070
|
-
])
|
|
12071
|
-
}
|
|
12072
|
-
});
|
|
12073
|
-
if (propertyAst.hasLazyExpression) ctx$1.utils.ast.hasLazyExpression = true;
|
|
12074
|
-
shape.prop(name, propertyAst.expression);
|
|
12232
|
+
const isOptional = !schema.required?.includes(name);
|
|
12233
|
+
const propertyResult = walk(property, childContext(walkerCtx, "properties", name));
|
|
12234
|
+
if (propertyResult.hasLazyExpression) ctx$1.utils.ast.hasLazyExpression = true;
|
|
12235
|
+
const ast = applyModifiers(propertyResult, { optional: isOptional });
|
|
12236
|
+
if (ast.hasLazyExpression) ctx$1.utils.ast.hasLazyExpression = true;
|
|
12237
|
+
shape.prop(name, ast.expression);
|
|
12075
12238
|
}
|
|
12076
12239
|
return shape;
|
|
12077
12240
|
}
|
|
12078
|
-
|
|
12241
|
+
function objectToAst$1(options) {
|
|
12242
|
+
const { plugin } = options;
|
|
12079
12243
|
const ast = {};
|
|
12080
12244
|
const z = plugin.external("zod.z");
|
|
12081
12245
|
const ctx$1 = {
|
|
12246
|
+
...options,
|
|
12082
12247
|
$,
|
|
12083
12248
|
chain: { current: $(z) },
|
|
12084
12249
|
nodes: {
|
|
@@ -12087,20 +12252,19 @@ const objectToAst$1 = ({ plugin, schema, state }) => {
|
|
|
12087
12252
|
shape: shapeNode$1
|
|
12088
12253
|
},
|
|
12089
12254
|
plugin,
|
|
12090
|
-
schema,
|
|
12091
12255
|
symbols: { z },
|
|
12092
12256
|
utils: {
|
|
12093
12257
|
ast,
|
|
12094
|
-
state
|
|
12258
|
+
state: options.state
|
|
12095
12259
|
}
|
|
12096
12260
|
};
|
|
12097
12261
|
const resolver = plugin.config["~resolvers"]?.object;
|
|
12098
12262
|
ast.expression = resolver?.(ctx$1) ?? objectResolver$1(ctx$1);
|
|
12099
12263
|
return {
|
|
12100
12264
|
...ast,
|
|
12101
|
-
anyType:
|
|
12265
|
+
anyType: identifiers.AnyZodObject
|
|
12102
12266
|
};
|
|
12103
|
-
}
|
|
12267
|
+
}
|
|
12104
12268
|
|
|
12105
12269
|
//#endregion
|
|
12106
12270
|
//#region src/plugins/zod/v3/toAst/string.ts
|
|
@@ -12148,7 +12312,8 @@ function minLengthNode$1(ctx$1) {
|
|
|
12148
12312
|
function patternNode$1(ctx$1) {
|
|
12149
12313
|
const { chain, schema } = ctx$1;
|
|
12150
12314
|
if (!schema.pattern) return;
|
|
12151
|
-
|
|
12315
|
+
const flags = /\\[pP]\{/.test(schema.pattern) ? "u" : void 0;
|
|
12316
|
+
return chain.current.attr(identifiers.regex).call($.regexp(schema.pattern, flags));
|
|
12152
12317
|
}
|
|
12153
12318
|
function stringResolver$1(ctx$1) {
|
|
12154
12319
|
const constNode$8 = ctx$1.nodes.const(ctx$1);
|
|
@@ -12172,7 +12337,7 @@ function stringResolver$1(ctx$1) {
|
|
|
12172
12337
|
if (patternNode$4) ctx$1.chain.current = patternNode$4;
|
|
12173
12338
|
return ctx$1.chain.current;
|
|
12174
12339
|
}
|
|
12175
|
-
|
|
12340
|
+
function stringToNode$1({ plugin, schema }) {
|
|
12176
12341
|
const z = plugin.external("zod.z");
|
|
12177
12342
|
const ctx$1 = {
|
|
12178
12343
|
$,
|
|
@@ -12192,11 +12357,12 @@ const stringToNode$1 = ({ plugin, schema }) => {
|
|
|
12192
12357
|
};
|
|
12193
12358
|
const resolver = plugin.config["~resolvers"]?.string;
|
|
12194
12359
|
return resolver?.(ctx$1) ?? stringResolver$1(ctx$1);
|
|
12195
|
-
}
|
|
12360
|
+
}
|
|
12196
12361
|
|
|
12197
12362
|
//#endregion
|
|
12198
12363
|
//#region src/plugins/zod/v3/toAst/tuple.ts
|
|
12199
|
-
|
|
12364
|
+
function tupleToAst$1(options) {
|
|
12365
|
+
const { applyModifiers, plugin, schema, walk } = options;
|
|
12200
12366
|
const z = plugin.external("zod.z");
|
|
12201
12367
|
let hasLazyExpression = false;
|
|
12202
12368
|
if (schema.const && Array.isArray(schema.const)) {
|
|
@@ -12208,193 +12374,391 @@ const tupleToAst$1 = ({ plugin, schema, state }) => {
|
|
|
12208
12374
|
}
|
|
12209
12375
|
const tupleElements = [];
|
|
12210
12376
|
if (schema.items) schema.items.forEach((item, index) => {
|
|
12211
|
-
const
|
|
12212
|
-
|
|
12213
|
-
|
|
12214
|
-
|
|
12215
|
-
|
|
12216
|
-
|
|
12217
|
-
|
|
12218
|
-
"items",
|
|
12219
|
-
index
|
|
12220
|
-
])
|
|
12221
|
-
}
|
|
12222
|
-
});
|
|
12223
|
-
tupleElements.push(itemSchema.expression);
|
|
12224
|
-
if (itemSchema.hasLazyExpression) hasLazyExpression = true;
|
|
12377
|
+
const itemResult = walk(item, childContext({
|
|
12378
|
+
path: options.state.path,
|
|
12379
|
+
plugin: options.plugin
|
|
12380
|
+
}, "items", index));
|
|
12381
|
+
if (itemResult.hasLazyExpression) hasLazyExpression = true;
|
|
12382
|
+
const finalExpr = applyModifiers(itemResult, { optional: false });
|
|
12383
|
+
tupleElements.push(finalExpr.expression);
|
|
12225
12384
|
});
|
|
12226
12385
|
return {
|
|
12227
12386
|
expression: $(z).attr(identifiers.tuple).call($.array(...tupleElements)),
|
|
12228
12387
|
hasLazyExpression
|
|
12229
12388
|
};
|
|
12230
|
-
}
|
|
12389
|
+
}
|
|
12231
12390
|
|
|
12232
12391
|
//#endregion
|
|
12233
12392
|
//#region src/plugins/zod/v3/toAst/undefined.ts
|
|
12234
|
-
|
|
12393
|
+
function undefinedToAst$1({ plugin }) {
|
|
12235
12394
|
return $(plugin.external("zod.z")).attr(identifiers.undefined).call();
|
|
12236
|
-
}
|
|
12395
|
+
}
|
|
12237
12396
|
|
|
12238
12397
|
//#endregion
|
|
12239
12398
|
//#region src/plugins/zod/v3/toAst/void.ts
|
|
12240
|
-
|
|
12399
|
+
function voidToAst$1({ plugin }) {
|
|
12241
12400
|
return $(plugin.external("zod.z")).attr(identifiers.void).call();
|
|
12242
|
-
}
|
|
12401
|
+
}
|
|
12243
12402
|
|
|
12244
12403
|
//#endregion
|
|
12245
|
-
//#region src/plugins/zod/v3/
|
|
12246
|
-
function
|
|
12247
|
-
|
|
12248
|
-
|
|
12249
|
-
|
|
12250
|
-
|
|
12251
|
-
|
|
12252
|
-
|
|
12253
|
-
|
|
12254
|
-
|
|
12255
|
-
|
|
12256
|
-
|
|
12257
|
-
|
|
12258
|
-
|
|
12259
|
-
|
|
12260
|
-
|
|
12261
|
-
|
|
12262
|
-
|
|
12263
|
-
|
|
12264
|
-
|
|
12265
|
-
|
|
12266
|
-
|
|
12267
|
-
|
|
12268
|
-
|
|
12269
|
-
|
|
12270
|
-
|
|
12271
|
-
|
|
12272
|
-
|
|
12273
|
-
|
|
12274
|
-
|
|
12275
|
-
|
|
12276
|
-
|
|
12277
|
-
|
|
12278
|
-
|
|
12279
|
-
|
|
12280
|
-
...
|
|
12281
|
-
|
|
12404
|
+
//#region src/plugins/zod/v3/walker.ts
|
|
12405
|
+
function createVisitor$1(config) {
|
|
12406
|
+
const { schemaExtractor, state } = config;
|
|
12407
|
+
return {
|
|
12408
|
+
applyModifiers(result, ctx$1, options = {}) {
|
|
12409
|
+
const { optional } = options;
|
|
12410
|
+
let expression = result.expression.expression;
|
|
12411
|
+
if (result.readonly) expression = expression.attr(identifiers.readonly).call();
|
|
12412
|
+
const hasDefault = result.default !== void 0;
|
|
12413
|
+
const needsNullable = result.nullable;
|
|
12414
|
+
if (optional && needsNullable) expression = expression.attr(identifiers.nullish).call();
|
|
12415
|
+
else if (optional) expression = expression.attr(identifiers.optional).call();
|
|
12416
|
+
else if (needsNullable) expression = expression.attr(identifiers.nullable).call();
|
|
12417
|
+
if (hasDefault) expression = expression.attr(identifiers.default).call(result.format ? maybeBigInt(result.default, result.format) : $.fromValue(result.default));
|
|
12418
|
+
return { expression };
|
|
12419
|
+
},
|
|
12420
|
+
array(schema, ctx$1, walk) {
|
|
12421
|
+
const applyModifiers = (result, opts) => this.applyModifiers(result, ctx$1, opts);
|
|
12422
|
+
const ast = arrayToAst$1({
|
|
12423
|
+
...ctx$1,
|
|
12424
|
+
applyModifiers,
|
|
12425
|
+
schema,
|
|
12426
|
+
state,
|
|
12427
|
+
walk
|
|
12428
|
+
});
|
|
12429
|
+
return {
|
|
12430
|
+
default: schema.default,
|
|
12431
|
+
expression: ast,
|
|
12432
|
+
hasLazyExpression: state.hasLazyExpression["~ref"],
|
|
12433
|
+
nullable: false,
|
|
12434
|
+
readonly: schema.accessScope === "read"
|
|
12435
|
+
};
|
|
12436
|
+
},
|
|
12437
|
+
boolean(schema, ctx$1) {
|
|
12438
|
+
const ast = booleanToAst$1({
|
|
12439
|
+
...ctx$1,
|
|
12440
|
+
schema
|
|
12441
|
+
});
|
|
12442
|
+
return {
|
|
12443
|
+
default: schema.default,
|
|
12444
|
+
expression: { expression: ast },
|
|
12445
|
+
nullable: false,
|
|
12446
|
+
readonly: schema.accessScope === "read"
|
|
12447
|
+
};
|
|
12448
|
+
},
|
|
12449
|
+
enum(schema, ctx$1) {
|
|
12450
|
+
const ast = enumToAst$1({
|
|
12451
|
+
...ctx$1,
|
|
12452
|
+
schema,
|
|
12453
|
+
state
|
|
12454
|
+
});
|
|
12455
|
+
const hasNull = schema.items?.some((item) => item.type === "null" || item.const === null) ?? false;
|
|
12456
|
+
return {
|
|
12457
|
+
default: schema.default,
|
|
12458
|
+
expression: { expression: ast },
|
|
12459
|
+
nullable: hasNull,
|
|
12460
|
+
readonly: schema.accessScope === "read"
|
|
12461
|
+
};
|
|
12462
|
+
},
|
|
12463
|
+
integer(schema, ctx$1) {
|
|
12464
|
+
const ast = numberToNode$1({
|
|
12465
|
+
...ctx$1,
|
|
12466
|
+
schema,
|
|
12467
|
+
state
|
|
12468
|
+
});
|
|
12469
|
+
return {
|
|
12470
|
+
default: schema.default,
|
|
12471
|
+
expression: { expression: ast },
|
|
12472
|
+
format: schema.format,
|
|
12473
|
+
nullable: false,
|
|
12474
|
+
readonly: schema.accessScope === "read"
|
|
12475
|
+
};
|
|
12476
|
+
},
|
|
12477
|
+
intercept(schema, ctx$1, walk) {
|
|
12478
|
+
if (schemaExtractor && !schema.$ref) {
|
|
12479
|
+
const extracted = schemaExtractor({
|
|
12480
|
+
meta: {
|
|
12481
|
+
resource: "definition",
|
|
12482
|
+
resourceId: pathToJsonPointer(fromRef(ctx$1.path))
|
|
12483
|
+
},
|
|
12484
|
+
naming: ctx$1.plugin.config.definitions,
|
|
12485
|
+
path: fromRef(ctx$1.path),
|
|
12486
|
+
plugin: ctx$1.plugin,
|
|
12487
|
+
schema
|
|
12488
|
+
});
|
|
12489
|
+
if (extracted !== schema) return walk(extracted, ctx$1);
|
|
12282
12490
|
}
|
|
12283
|
-
}
|
|
12284
|
-
|
|
12285
|
-
|
|
12286
|
-
|
|
12287
|
-
|
|
12288
|
-
|
|
12289
|
-
|
|
12290
|
-
|
|
12291
|
-
|
|
12292
|
-
|
|
12293
|
-
|
|
12294
|
-
|
|
12295
|
-
|
|
12296
|
-
|
|
12297
|
-
|
|
12298
|
-
|
|
12299
|
-
|
|
12300
|
-
|
|
12301
|
-
|
|
12302
|
-
|
|
12303
|
-
|
|
12491
|
+
},
|
|
12492
|
+
intersection(items, schemas, parentSchema, ctx$1) {
|
|
12493
|
+
const z = ctx$1.plugin.external("zod.z");
|
|
12494
|
+
const hasAnyLazy = items.some((item) => item.hasLazyExpression);
|
|
12495
|
+
if (hasAnyLazy) state.anyType = ref(identifiers.ZodTypeAny);
|
|
12496
|
+
const firstSchema = schemas[0];
|
|
12497
|
+
let expression;
|
|
12498
|
+
if (firstSchema?.logicalOperator === "or" || firstSchema?.type && firstSchema.type !== "object") expression = { expression: $(z).attr(identifiers.intersection).call(...items.map((item) => item.expression.expression)) };
|
|
12499
|
+
else {
|
|
12500
|
+
expression = items[0].expression;
|
|
12501
|
+
items.slice(1).forEach((item) => {
|
|
12502
|
+
expression = { expression: expression.expression.attr(identifiers.and).call(item.hasLazyExpression && !item.isLazy ? $(z).attr(identifiers.lazy).call($.func().do(item.expression.expression.return())) : item.expression.expression) };
|
|
12503
|
+
});
|
|
12504
|
+
}
|
|
12505
|
+
return {
|
|
12506
|
+
default: parentSchema.default,
|
|
12507
|
+
expression,
|
|
12508
|
+
hasLazyExpression: hasAnyLazy,
|
|
12509
|
+
nullable: items.some((i) => i.nullable),
|
|
12510
|
+
readonly: items.some((i) => i.readonly)
|
|
12511
|
+
};
|
|
12512
|
+
},
|
|
12513
|
+
never(schema, ctx$1) {
|
|
12514
|
+
const ast = neverToAst$1({
|
|
12515
|
+
...ctx$1,
|
|
12516
|
+
schema
|
|
12517
|
+
});
|
|
12518
|
+
return {
|
|
12519
|
+
default: schema.default,
|
|
12520
|
+
expression: { expression: ast },
|
|
12521
|
+
nullable: false,
|
|
12522
|
+
readonly: false
|
|
12523
|
+
};
|
|
12524
|
+
},
|
|
12525
|
+
null(schema, ctx$1) {
|
|
12526
|
+
const ast = nullToAst$1({
|
|
12527
|
+
...ctx$1,
|
|
12528
|
+
schema
|
|
12529
|
+
});
|
|
12530
|
+
return {
|
|
12531
|
+
default: schema.default,
|
|
12532
|
+
expression: { expression: ast },
|
|
12533
|
+
nullable: false,
|
|
12534
|
+
readonly: false
|
|
12535
|
+
};
|
|
12536
|
+
},
|
|
12537
|
+
number(schema, ctx$1) {
|
|
12538
|
+
const ast = numberToNode$1({
|
|
12539
|
+
...ctx$1,
|
|
12540
|
+
schema,
|
|
12541
|
+
state
|
|
12542
|
+
});
|
|
12543
|
+
return {
|
|
12544
|
+
default: schema.default,
|
|
12545
|
+
expression: { expression: ast },
|
|
12546
|
+
format: schema.format,
|
|
12547
|
+
nullable: false,
|
|
12548
|
+
readonly: schema.accessScope === "read"
|
|
12549
|
+
};
|
|
12550
|
+
},
|
|
12551
|
+
object(schema, ctx$1, walk) {
|
|
12552
|
+
const applyModifiers = (result, opts) => this.applyModifiers(result, ctx$1, opts);
|
|
12553
|
+
const ast = objectToAst$1({
|
|
12554
|
+
applyModifiers,
|
|
12555
|
+
plugin: ctx$1.plugin,
|
|
12556
|
+
schema,
|
|
12557
|
+
state,
|
|
12558
|
+
walk,
|
|
12559
|
+
walkerCtx: ctx$1
|
|
12560
|
+
});
|
|
12561
|
+
if (state.hasLazyExpression["~ref"] && ast.anyType) state.anyType = ref(ast.anyType);
|
|
12562
|
+
return {
|
|
12563
|
+
default: schema.default,
|
|
12564
|
+
expression: ast,
|
|
12565
|
+
hasLazyExpression: state.hasLazyExpression["~ref"],
|
|
12566
|
+
nullable: false,
|
|
12567
|
+
readonly: schema.accessScope === "read"
|
|
12568
|
+
};
|
|
12569
|
+
},
|
|
12570
|
+
postProcess(result, schema, ctx$1) {
|
|
12571
|
+
if (ctx$1.plugin.config.metadata && schema.description) return {
|
|
12572
|
+
...result,
|
|
12573
|
+
expression: { expression: result.expression.expression.attr(identifiers.describe).call($.literal(schema.description)) }
|
|
12574
|
+
};
|
|
12575
|
+
return result;
|
|
12576
|
+
},
|
|
12577
|
+
reference($ref, schema, ctx$1) {
|
|
12578
|
+
const z = ctx$1.plugin.external("zod.z");
|
|
12579
|
+
const query = {
|
|
12580
|
+
category: "schema",
|
|
12581
|
+
resource: "definition",
|
|
12582
|
+
resourceId: $ref,
|
|
12583
|
+
tool: "zod"
|
|
12584
|
+
};
|
|
12585
|
+
const refSymbol = ctx$1.plugin.referenceSymbol(query);
|
|
12586
|
+
if (ctx$1.plugin.isSymbolRegistered(query)) return {
|
|
12587
|
+
default: schema.default,
|
|
12588
|
+
expression: { expression: $(refSymbol) },
|
|
12589
|
+
nullable: false,
|
|
12590
|
+
readonly: schema.accessScope === "read"
|
|
12591
|
+
};
|
|
12592
|
+
state.hasLazyExpression["~ref"] = true;
|
|
12593
|
+
state.anyType = ref(identifiers.ZodTypeAny);
|
|
12594
|
+
return {
|
|
12595
|
+
default: schema.default,
|
|
12596
|
+
expression: { expression: $(z).attr(identifiers.lazy).call($.func().do($(refSymbol).return())) },
|
|
12597
|
+
hasLazyExpression: true,
|
|
12598
|
+
isLazy: true,
|
|
12599
|
+
nullable: false,
|
|
12600
|
+
readonly: schema.accessScope === "read"
|
|
12601
|
+
};
|
|
12602
|
+
},
|
|
12603
|
+
string(schema, ctx$1) {
|
|
12604
|
+
if (shouldCoerceToBigInt(schema.format)) {
|
|
12605
|
+
const ast$1 = numberToNode$1({
|
|
12606
|
+
plugin: ctx$1.plugin,
|
|
12607
|
+
schema: {
|
|
12608
|
+
...schema,
|
|
12609
|
+
type: "number"
|
|
12610
|
+
},
|
|
12611
|
+
state
|
|
12612
|
+
});
|
|
12613
|
+
return {
|
|
12614
|
+
default: schema.default,
|
|
12615
|
+
expression: { expression: ast$1 },
|
|
12616
|
+
nullable: false,
|
|
12617
|
+
readonly: schema.accessScope === "read"
|
|
12618
|
+
};
|
|
12619
|
+
}
|
|
12620
|
+
const ast = stringToNode$1({
|
|
12621
|
+
...ctx$1,
|
|
12622
|
+
schema
|
|
12623
|
+
});
|
|
12624
|
+
return {
|
|
12625
|
+
default: schema.default,
|
|
12626
|
+
expression: { expression: ast },
|
|
12627
|
+
nullable: false,
|
|
12628
|
+
readonly: schema.accessScope === "read"
|
|
12629
|
+
};
|
|
12630
|
+
},
|
|
12631
|
+
tuple(schema, ctx$1, walk) {
|
|
12632
|
+
const applyModifiers = (result, opts) => this.applyModifiers(result, ctx$1, opts);
|
|
12633
|
+
const ast = tupleToAst$1({
|
|
12634
|
+
...ctx$1,
|
|
12635
|
+
applyModifiers,
|
|
12636
|
+
schema,
|
|
12637
|
+
state,
|
|
12638
|
+
walk
|
|
12639
|
+
});
|
|
12640
|
+
return {
|
|
12641
|
+
default: schema.default,
|
|
12642
|
+
expression: ast,
|
|
12643
|
+
hasLazyExpression: state.hasLazyExpression["~ref"],
|
|
12644
|
+
nullable: false,
|
|
12645
|
+
readonly: schema.accessScope === "read"
|
|
12646
|
+
};
|
|
12647
|
+
},
|
|
12648
|
+
undefined(schema, ctx$1) {
|
|
12649
|
+
const ast = undefinedToAst$1({
|
|
12650
|
+
...ctx$1,
|
|
12651
|
+
schema
|
|
12652
|
+
});
|
|
12653
|
+
return {
|
|
12654
|
+
default: schema.default,
|
|
12655
|
+
expression: { expression: ast },
|
|
12656
|
+
nullable: false,
|
|
12657
|
+
readonly: false
|
|
12658
|
+
};
|
|
12659
|
+
},
|
|
12660
|
+
union(items, schemas, parentSchema, ctx$1) {
|
|
12661
|
+
const z = ctx$1.plugin.external("zod.z");
|
|
12662
|
+
const hasAnyLazy = items.some((item) => item.hasLazyExpression);
|
|
12663
|
+
const hasNull = schemas.some((s) => s.type === "null") || items.some((i) => i.nullable);
|
|
12664
|
+
if (hasAnyLazy) state.anyType = ref(identifiers.ZodTypeAny);
|
|
12665
|
+
const nonNullItems = [];
|
|
12666
|
+
items.forEach((item, index) => {
|
|
12667
|
+
if (schemas[index].type !== "null") nonNullItems.push(item);
|
|
12668
|
+
});
|
|
12669
|
+
let expression;
|
|
12670
|
+
if (nonNullItems.length === 0) expression = { expression: $(z).attr(identifiers.null).call() };
|
|
12671
|
+
else if (nonNullItems.length === 1) expression = nonNullItems[0].expression;
|
|
12672
|
+
else expression = { expression: $(z).attr(identifiers.union).call($.array().pretty().elements(...nonNullItems.map((item) => item.expression.expression))) };
|
|
12673
|
+
return {
|
|
12674
|
+
default: parentSchema.default,
|
|
12675
|
+
expression,
|
|
12676
|
+
hasLazyExpression: hasAnyLazy,
|
|
12677
|
+
nullable: hasNull,
|
|
12678
|
+
readonly: items.some((i) => i.readonly)
|
|
12679
|
+
};
|
|
12680
|
+
},
|
|
12681
|
+
unknown(schema, ctx$1) {
|
|
12682
|
+
const ast = unknownToAst$1({
|
|
12683
|
+
...ctx$1,
|
|
12684
|
+
schema
|
|
12685
|
+
});
|
|
12686
|
+
return {
|
|
12687
|
+
default: schema.default,
|
|
12688
|
+
expression: { expression: ast },
|
|
12689
|
+
nullable: false,
|
|
12690
|
+
readonly: false
|
|
12691
|
+
};
|
|
12692
|
+
},
|
|
12693
|
+
void(schema, ctx$1) {
|
|
12694
|
+
const ast = voidToAst$1({
|
|
12695
|
+
...ctx$1,
|
|
12696
|
+
schema
|
|
12697
|
+
});
|
|
12698
|
+
return {
|
|
12699
|
+
default: schema.default,
|
|
12700
|
+
expression: { expression: ast },
|
|
12701
|
+
nullable: false,
|
|
12702
|
+
readonly: false
|
|
12703
|
+
};
|
|
12704
|
+
}
|
|
12705
|
+
};
|
|
12304
12706
|
}
|
|
12305
12707
|
|
|
12306
12708
|
//#endregion
|
|
12307
|
-
//#region src/plugins/zod/v3/
|
|
12308
|
-
function
|
|
12309
|
-
|
|
12310
|
-
|
|
12311
|
-
|
|
12312
|
-
|
|
12313
|
-
|
|
12314
|
-
|
|
12315
|
-
|
|
12316
|
-
|
|
12317
|
-
|
|
12318
|
-
|
|
12319
|
-
|
|
12320
|
-
if (extracted !== schema) schema = extracted;
|
|
12321
|
-
}
|
|
12322
|
-
let ast = {};
|
|
12323
|
-
const z = plugin.external("zod.z");
|
|
12324
|
-
if (schema.$ref) {
|
|
12325
|
-
const query = {
|
|
12326
|
-
category: "schema",
|
|
12327
|
-
resource: "definition",
|
|
12328
|
-
resourceId: schema.$ref,
|
|
12329
|
-
tool: "zod"
|
|
12330
|
-
};
|
|
12331
|
-
const refSymbol = plugin.referenceSymbol(query);
|
|
12332
|
-
if (plugin.isSymbolRegistered(query)) ast.expression = $(refSymbol);
|
|
12333
|
-
else {
|
|
12334
|
-
ast.expression = $(z).attr(identifiers.lazy).call($.func().do($(refSymbol).return()));
|
|
12335
|
-
ast.hasLazyExpression = true;
|
|
12336
|
-
state.hasLazyExpression["~ref"] = true;
|
|
12709
|
+
//#region src/plugins/zod/v3/processor.ts
|
|
12710
|
+
function createProcessor$1(plugin) {
|
|
12711
|
+
const processor = createSchemaProcessor();
|
|
12712
|
+
const hooks = [plugin.config["~hooks"]?.schemas, plugin.context.config.parser.hooks.schemas];
|
|
12713
|
+
function extractor(ctx$1) {
|
|
12714
|
+
if (processor.hasEmitted(ctx$1.path)) return ctx$1.schema;
|
|
12715
|
+
for (const hook of hooks) if (hook?.shouldExtract?.(ctx$1)) {
|
|
12716
|
+
process$1({
|
|
12717
|
+
namingAnchor: processor.context.anchor,
|
|
12718
|
+
tags: processor.context.tags,
|
|
12719
|
+
...ctx$1
|
|
12720
|
+
});
|
|
12721
|
+
return { $ref: pathToJsonPointer(ctx$1.path) };
|
|
12337
12722
|
}
|
|
12338
|
-
|
|
12339
|
-
|
|
12340
|
-
|
|
12341
|
-
|
|
12342
|
-
|
|
12343
|
-
|
|
12344
|
-
|
|
12345
|
-
|
|
12346
|
-
|
|
12347
|
-
|
|
12348
|
-
|
|
12349
|
-
|
|
12350
|
-
|
|
12351
|
-
|
|
12352
|
-
|
|
12353
|
-
|
|
12354
|
-
|
|
12355
|
-
|
|
12356
|
-
|
|
12357
|
-
|
|
12358
|
-
|
|
12359
|
-
|
|
12360
|
-
|
|
12361
|
-
|
|
12362
|
-
|
|
12723
|
+
return ctx$1.schema;
|
|
12724
|
+
}
|
|
12725
|
+
function process$1(ctx$1) {
|
|
12726
|
+
if (!processor.markEmitted(ctx$1.path)) return;
|
|
12727
|
+
processor.withContext({
|
|
12728
|
+
anchor: ctx$1.namingAnchor,
|
|
12729
|
+
tags: ctx$1.tags
|
|
12730
|
+
}, () => {
|
|
12731
|
+
const state = refs({
|
|
12732
|
+
hasLazyExpression: false,
|
|
12733
|
+
path: ctx$1.path,
|
|
12734
|
+
tags: ctx$1.tags
|
|
12735
|
+
});
|
|
12736
|
+
const visitor = createVisitor$1({
|
|
12737
|
+
schemaExtractor: extractor,
|
|
12738
|
+
state
|
|
12739
|
+
});
|
|
12740
|
+
const result = createSchemaWalker(visitor)(ctx$1.schema, {
|
|
12741
|
+
path: ref(ctx$1.path),
|
|
12742
|
+
plugin
|
|
12743
|
+
});
|
|
12744
|
+
const ast = visitor.applyModifiers(result, {
|
|
12745
|
+
path: ref(ctx$1.path),
|
|
12746
|
+
plugin
|
|
12747
|
+
}) ?? result.expression;
|
|
12748
|
+
if (result.hasLazyExpression) state.hasLazyExpression["~ref"] = true;
|
|
12749
|
+
exportAst({
|
|
12750
|
+
...ctx$1,
|
|
12751
|
+
ast,
|
|
12752
|
+
plugin,
|
|
12753
|
+
state
|
|
12363
12754
|
});
|
|
12364
|
-
if (schema.logicalOperator === "and") {
|
|
12365
|
-
const firstSchema = schema.items[0];
|
|
12366
|
-
if (firstSchema.logicalOperator === "or" || firstSchema.type && firstSchema.type !== "object") ast.expression = $(z).attr(identifiers.intersection).call(...itemTypes);
|
|
12367
|
-
else {
|
|
12368
|
-
ast.expression = itemTypes[0];
|
|
12369
|
-
itemTypes.slice(1).forEach((item) => {
|
|
12370
|
-
ast.expression = ast.expression.attr(identifiers.and).call(item);
|
|
12371
|
-
});
|
|
12372
|
-
}
|
|
12373
|
-
} else ast.expression = $(z).attr(identifiers.union).call($.array().pretty().elements(...itemTypes));
|
|
12374
|
-
} else ast = irSchemaToAst$1({
|
|
12375
|
-
plugin,
|
|
12376
|
-
schema,
|
|
12377
|
-
state
|
|
12378
|
-
});
|
|
12379
|
-
} else {
|
|
12380
|
-
const typeAst = irSchemaWithTypeToAst$1({
|
|
12381
|
-
plugin,
|
|
12382
|
-
schema: { type: "unknown" },
|
|
12383
|
-
state
|
|
12384
12755
|
});
|
|
12385
|
-
ast.expression = typeAst.expression;
|
|
12386
|
-
ast.typeName = typeAst.anyType;
|
|
12387
12756
|
}
|
|
12388
|
-
|
|
12389
|
-
if (schema.accessScope === "read") ast.expression = ast.expression.attr(identifiers.readonly).call();
|
|
12390
|
-
if (optional) ast.expression = ast.expression.attr(identifiers.optional).call();
|
|
12391
|
-
if (schema.default !== void 0) ast.expression = ast.expression.attr(identifiers.default).call(schema.type === "integer" || schema.type === "number" ? maybeBigInt(schema.default, schema.format) : $.fromValue(schema.default));
|
|
12392
|
-
}
|
|
12393
|
-
if (state.hasLazyExpression["~ref"]) {
|
|
12394
|
-
if (!ast.typeName) ast.typeName = "ZodTypeAny";
|
|
12395
|
-
} else if (ast.typeName) ast.typeName = void 0;
|
|
12396
|
-
return ast;
|
|
12757
|
+
return { process: process$1 };
|
|
12397
12758
|
}
|
|
12759
|
+
|
|
12760
|
+
//#endregion
|
|
12761
|
+
//#region src/plugins/zod/v3/plugin.ts
|
|
12398
12762
|
const handlerV3 = ({ plugin }) => {
|
|
12399
12763
|
plugin.symbol("z", {
|
|
12400
12764
|
external: getZodModule({ plugin }),
|
|
@@ -12467,87 +12831,35 @@ const handlerV3 = ({ plugin }) => {
|
|
|
12467
12831
|
});
|
|
12468
12832
|
};
|
|
12469
12833
|
|
|
12470
|
-
//#endregion
|
|
12471
|
-
//#region src/plugins/zod/v4/processor.ts
|
|
12472
|
-
function createProcessor(plugin) {
|
|
12473
|
-
const processor = createSchemaProcessor();
|
|
12474
|
-
const hooks = [plugin.config["~hooks"]?.schemas, plugin.context.config.parser.hooks.schemas];
|
|
12475
|
-
function extractor(ctx$1) {
|
|
12476
|
-
if (processor.hasEmitted(ctx$1.path)) return ctx$1.schema;
|
|
12477
|
-
for (const hook of hooks) if (hook?.shouldExtract?.(ctx$1)) {
|
|
12478
|
-
process$1({
|
|
12479
|
-
namingAnchor: processor.context.anchor,
|
|
12480
|
-
tags: processor.context.tags,
|
|
12481
|
-
...ctx$1
|
|
12482
|
-
});
|
|
12483
|
-
return { $ref: pathToJsonPointer(ctx$1.path) };
|
|
12484
|
-
}
|
|
12485
|
-
return ctx$1.schema;
|
|
12486
|
-
}
|
|
12487
|
-
function process$1(ctx$1) {
|
|
12488
|
-
if (!processor.markEmitted(ctx$1.path)) return;
|
|
12489
|
-
processor.withContext({
|
|
12490
|
-
anchor: ctx$1.namingAnchor,
|
|
12491
|
-
tags: ctx$1.tags
|
|
12492
|
-
}, () => {
|
|
12493
|
-
const state = refs({
|
|
12494
|
-
hasLazyExpression: false,
|
|
12495
|
-
path: ctx$1.path,
|
|
12496
|
-
tags: ctx$1.tags
|
|
12497
|
-
});
|
|
12498
|
-
const ast = irSchemaToAst({
|
|
12499
|
-
plugin,
|
|
12500
|
-
schema: ctx$1.schema,
|
|
12501
|
-
schemaExtractor: extractor,
|
|
12502
|
-
state
|
|
12503
|
-
});
|
|
12504
|
-
exportAst({
|
|
12505
|
-
...ctx$1,
|
|
12506
|
-
ast,
|
|
12507
|
-
plugin,
|
|
12508
|
-
state
|
|
12509
|
-
});
|
|
12510
|
-
});
|
|
12511
|
-
}
|
|
12512
|
-
return { process: process$1 };
|
|
12513
|
-
}
|
|
12514
|
-
|
|
12515
12834
|
//#endregion
|
|
12516
12835
|
//#region src/plugins/zod/v4/toAst/unknown.ts
|
|
12517
|
-
|
|
12836
|
+
function unknownToAst({ plugin }) {
|
|
12518
12837
|
const result = {};
|
|
12519
12838
|
result.expression = $(plugin.external("zod.z")).attr(identifiers.unknown).call();
|
|
12520
12839
|
return result;
|
|
12521
|
-
}
|
|
12840
|
+
}
|
|
12522
12841
|
|
|
12523
12842
|
//#endregion
|
|
12524
12843
|
//#region src/plugins/zod/v4/toAst/array.ts
|
|
12525
|
-
|
|
12844
|
+
function arrayToAst(options) {
|
|
12845
|
+
const { applyModifiers, plugin, walk } = options;
|
|
12846
|
+
let { schema } = options;
|
|
12526
12847
|
const result = {};
|
|
12527
12848
|
const z = plugin.external("zod.z");
|
|
12528
12849
|
const functionName = $(z).attr(identifiers.array);
|
|
12529
12850
|
if (!schema.items) result.expression = functionName.call(unknownToAst({
|
|
12530
|
-
|
|
12531
|
-
schema: { type: "unknown" }
|
|
12532
|
-
state
|
|
12851
|
+
...options,
|
|
12852
|
+
schema: { type: "unknown" }
|
|
12533
12853
|
}).expression);
|
|
12534
12854
|
else {
|
|
12535
12855
|
schema = deduplicateSchema({ schema });
|
|
12536
12856
|
const itemExpressions = schema.items.map((item, index) => {
|
|
12537
|
-
const
|
|
12538
|
-
|
|
12539
|
-
|
|
12540
|
-
|
|
12541
|
-
|
|
12542
|
-
|
|
12543
|
-
...fromRef(state.path),
|
|
12544
|
-
"items",
|
|
12545
|
-
index
|
|
12546
|
-
])
|
|
12547
|
-
}
|
|
12548
|
-
});
|
|
12549
|
-
if (itemAst.hasLazyExpression) result.hasLazyExpression = true;
|
|
12550
|
-
return itemAst.expression;
|
|
12857
|
+
const itemResult = walk(item, childContext({
|
|
12858
|
+
path: options.state.path,
|
|
12859
|
+
plugin: options.plugin
|
|
12860
|
+
}, "items", index));
|
|
12861
|
+
if (itemResult.hasLazyExpression) result.hasLazyExpression = true;
|
|
12862
|
+
return applyModifiers(itemResult, { optional: false }).expression;
|
|
12551
12863
|
});
|
|
12552
12864
|
if (itemExpressions.length === 1) result.expression = functionName.call(...itemExpressions);
|
|
12553
12865
|
else if (schema.logicalOperator === "and") {
|
|
@@ -12567,7 +12879,7 @@ const arrayToAst = ({ plugin, schema, state }) => {
|
|
|
12567
12879
|
if (schema.maxItems !== void 0) result.expression = result.expression.attr(identifiers.max).call($.fromValue(schema.maxItems));
|
|
12568
12880
|
}
|
|
12569
12881
|
return result;
|
|
12570
|
-
}
|
|
12882
|
+
}
|
|
12571
12883
|
|
|
12572
12884
|
//#endregion
|
|
12573
12885
|
//#region src/plugins/zod/v4/toAst/boolean.ts
|
|
@@ -12622,31 +12934,21 @@ function baseNode$3(ctx$1) {
|
|
|
12622
12934
|
else if (literalMembers.length === 1) return literalMembers[0];
|
|
12623
12935
|
else return $(z).attr(identifiers.union).call($.array(...literalMembers));
|
|
12624
12936
|
}
|
|
12625
|
-
function nullableNode(ctx$1) {
|
|
12626
|
-
const { chain, symbols } = ctx$1;
|
|
12627
|
-
const { z } = symbols;
|
|
12628
|
-
const { isNullable } = ctx$1.nodes.items(ctx$1);
|
|
12629
|
-
if (!isNullable) return;
|
|
12630
|
-
return $(z).attr(identifiers.nullable).call(chain.current);
|
|
12631
|
-
}
|
|
12632
12937
|
function enumResolver(ctx$1) {
|
|
12633
12938
|
const { literalMembers } = ctx$1.nodes.items(ctx$1);
|
|
12634
12939
|
if (!literalMembers.length) return ctx$1.chain.current;
|
|
12635
12940
|
const baseExpression = ctx$1.nodes.base(ctx$1);
|
|
12636
12941
|
ctx$1.chain.current = baseExpression;
|
|
12637
|
-
const nullableExpression = ctx$1.nodes.nullable(ctx$1);
|
|
12638
|
-
if (nullableExpression) ctx$1.chain.current = nullableExpression;
|
|
12639
12942
|
return ctx$1.chain.current;
|
|
12640
12943
|
}
|
|
12641
|
-
|
|
12944
|
+
function enumToAst({ plugin, schema, state }) {
|
|
12642
12945
|
const z = plugin.external("zod.z");
|
|
12643
12946
|
const { literalMembers } = itemsNode({
|
|
12644
12947
|
$,
|
|
12645
12948
|
chain: { current: $(z) },
|
|
12646
12949
|
nodes: {
|
|
12647
12950
|
base: baseNode$3,
|
|
12648
|
-
items: itemsNode
|
|
12649
|
-
nullable: nullableNode
|
|
12951
|
+
items: itemsNode
|
|
12650
12952
|
},
|
|
12651
12953
|
plugin,
|
|
12652
12954
|
schema,
|
|
@@ -12658,16 +12960,14 @@ const enumToAst = ({ plugin, schema, state }) => {
|
|
|
12658
12960
|
});
|
|
12659
12961
|
if (!literalMembers.length) return unknownToAst({
|
|
12660
12962
|
plugin,
|
|
12661
|
-
schema: { type: "unknown" }
|
|
12662
|
-
state
|
|
12963
|
+
schema: { type: "unknown" }
|
|
12663
12964
|
});
|
|
12664
12965
|
const ctx$1 = {
|
|
12665
12966
|
$,
|
|
12666
12967
|
chain: { current: $(z) },
|
|
12667
12968
|
nodes: {
|
|
12668
12969
|
base: baseNode$3,
|
|
12669
|
-
items: itemsNode
|
|
12670
|
-
nullable: nullableNode
|
|
12970
|
+
items: itemsNode
|
|
12671
12971
|
},
|
|
12672
12972
|
plugin,
|
|
12673
12973
|
schema,
|
|
@@ -12679,23 +12979,23 @@ const enumToAst = ({ plugin, schema, state }) => {
|
|
|
12679
12979
|
};
|
|
12680
12980
|
const resolver = plugin.config["~resolvers"]?.enum;
|
|
12681
12981
|
return { expression: resolver?.(ctx$1) ?? enumResolver(ctx$1) };
|
|
12682
|
-
}
|
|
12982
|
+
}
|
|
12683
12983
|
|
|
12684
12984
|
//#endregion
|
|
12685
12985
|
//#region src/plugins/zod/v4/toAst/never.ts
|
|
12686
|
-
|
|
12986
|
+
function neverToAst({ plugin }) {
|
|
12687
12987
|
const result = {};
|
|
12688
12988
|
result.expression = $(plugin.external("zod.z")).attr(identifiers.never).call();
|
|
12689
12989
|
return result;
|
|
12690
|
-
}
|
|
12990
|
+
}
|
|
12691
12991
|
|
|
12692
12992
|
//#endregion
|
|
12693
12993
|
//#region src/plugins/zod/v4/toAst/null.ts
|
|
12694
|
-
|
|
12994
|
+
function nullToAst({ plugin }) {
|
|
12695
12995
|
const result = {};
|
|
12696
12996
|
result.expression = $(plugin.external("zod.z")).attr(identifiers.null).call();
|
|
12697
12997
|
return result;
|
|
12698
|
-
}
|
|
12998
|
+
}
|
|
12699
12999
|
|
|
12700
13000
|
//#endregion
|
|
12701
13001
|
//#region src/plugins/zod/v4/toAst/number.ts
|
|
@@ -12741,7 +13041,7 @@ function numberResolver(ctx$1) {
|
|
|
12741
13041
|
if (maxNode$4) ctx$1.chain.current = maxNode$4;
|
|
12742
13042
|
return ctx$1.chain.current;
|
|
12743
13043
|
}
|
|
12744
|
-
|
|
13044
|
+
function numberToNode({ plugin, schema, state }) {
|
|
12745
13045
|
const ast = {};
|
|
12746
13046
|
const z = plugin.external("zod.z");
|
|
12747
13047
|
const ctx$1 = {
|
|
@@ -12767,23 +13067,16 @@ const numberToNode = ({ plugin, schema, state }) => {
|
|
|
12767
13067
|
const resolver = plugin.config["~resolvers"]?.number;
|
|
12768
13068
|
ast.expression = resolver?.(ctx$1) ?? numberResolver(ctx$1);
|
|
12769
13069
|
return ast;
|
|
12770
|
-
}
|
|
13070
|
+
}
|
|
12771
13071
|
|
|
12772
13072
|
//#endregion
|
|
12773
13073
|
//#region src/plugins/zod/v4/toAst/object.ts
|
|
12774
13074
|
function additionalPropertiesNode(ctx$1) {
|
|
12775
|
-
const {
|
|
13075
|
+
const { applyModifiers, schema, walk, walkerCtx } = ctx$1;
|
|
12776
13076
|
if (!schema.additionalProperties || schema.properties && Object.keys(schema.properties).length > 0) return;
|
|
12777
|
-
const
|
|
12778
|
-
|
|
12779
|
-
|
|
12780
|
-
state: {
|
|
12781
|
-
...ctx$1.utils.state,
|
|
12782
|
-
path: ref([...fromRef(ctx$1.utils.state.path), "additionalProperties"])
|
|
12783
|
-
}
|
|
12784
|
-
});
|
|
12785
|
-
if (additionalAst.hasLazyExpression) ctx$1.utils.ast.hasLazyExpression = true;
|
|
12786
|
-
return additionalAst.expression;
|
|
13077
|
+
const additionalResult = walk(schema.additionalProperties, childContext(walkerCtx, "additionalProperties"));
|
|
13078
|
+
if (additionalResult.hasLazyExpression) ctx$1.utils.ast.hasLazyExpression = true;
|
|
13079
|
+
return applyModifiers(additionalResult, {}).expression;
|
|
12787
13080
|
}
|
|
12788
13081
|
function baseNode$1(ctx$1) {
|
|
12789
13082
|
const { nodes, symbols } = ctx$1;
|
|
@@ -12797,34 +13090,27 @@ function objectResolver(ctx$1) {
|
|
|
12797
13090
|
return ctx$1.nodes.base(ctx$1);
|
|
12798
13091
|
}
|
|
12799
13092
|
function shapeNode(ctx$1) {
|
|
12800
|
-
const {
|
|
13093
|
+
const { applyModifiers, schema, walk, walkerCtx } = ctx$1;
|
|
12801
13094
|
const shape = $.object().pretty();
|
|
12802
13095
|
for (const name in schema.properties) {
|
|
12803
13096
|
const property = schema.properties[name];
|
|
12804
|
-
const
|
|
12805
|
-
|
|
12806
|
-
|
|
12807
|
-
|
|
12808
|
-
|
|
12809
|
-
...ctx$1.utils.state,
|
|
12810
|
-
path: ref([
|
|
12811
|
-
...fromRef(ctx$1.utils.state.path),
|
|
12812
|
-
"properties",
|
|
12813
|
-
name
|
|
12814
|
-
])
|
|
12815
|
-
}
|
|
12816
|
-
});
|
|
12817
|
-
if (propertyAst.hasLazyExpression) {
|
|
13097
|
+
const isOptional = !schema.required?.includes(name);
|
|
13098
|
+
const propertyResult = walk(property, childContext(walkerCtx, "properties", name));
|
|
13099
|
+
if (propertyResult.hasLazyExpression) ctx$1.utils.ast.hasLazyExpression = true;
|
|
13100
|
+
const ast = applyModifiers(propertyResult, { optional: isOptional });
|
|
13101
|
+
if (ast.hasLazyExpression) {
|
|
12818
13102
|
ctx$1.utils.ast.hasLazyExpression = true;
|
|
12819
|
-
shape.getter(name,
|
|
12820
|
-
} else shape.prop(name,
|
|
13103
|
+
shape.getter(name, ast.expression.return());
|
|
13104
|
+
} else shape.prop(name, ast.expression);
|
|
12821
13105
|
}
|
|
12822
13106
|
return shape;
|
|
12823
13107
|
}
|
|
12824
|
-
|
|
13108
|
+
function objectToAst(options) {
|
|
13109
|
+
const { plugin } = options;
|
|
12825
13110
|
const ast = {};
|
|
12826
13111
|
const z = plugin.external("zod.z");
|
|
12827
13112
|
const ctx$1 = {
|
|
13113
|
+
...options,
|
|
12828
13114
|
$,
|
|
12829
13115
|
chain: { current: $(z) },
|
|
12830
13116
|
nodes: {
|
|
@@ -12833,17 +13119,16 @@ const objectToAst = ({ plugin, schema, state }) => {
|
|
|
12833
13119
|
shape: shapeNode
|
|
12834
13120
|
},
|
|
12835
13121
|
plugin,
|
|
12836
|
-
schema,
|
|
12837
13122
|
symbols: { z },
|
|
12838
13123
|
utils: {
|
|
12839
13124
|
ast,
|
|
12840
|
-
state
|
|
13125
|
+
state: options.state
|
|
12841
13126
|
}
|
|
12842
13127
|
};
|
|
12843
13128
|
const resolver = plugin.config["~resolvers"]?.object;
|
|
12844
13129
|
ast.expression = resolver?.(ctx$1) ?? objectResolver(ctx$1);
|
|
12845
13130
|
return ast;
|
|
12846
|
-
}
|
|
13131
|
+
}
|
|
12847
13132
|
|
|
12848
13133
|
//#endregion
|
|
12849
13134
|
//#region src/plugins/zod/v4/toAst/string.ts
|
|
@@ -12892,7 +13177,8 @@ function minLengthNode(ctx$1) {
|
|
|
12892
13177
|
function patternNode(ctx$1) {
|
|
12893
13178
|
const { chain, schema } = ctx$1;
|
|
12894
13179
|
if (!schema.pattern) return;
|
|
12895
|
-
|
|
13180
|
+
const flags = /\\[pP]\{/.test(schema.pattern) ? "u" : void 0;
|
|
13181
|
+
return chain.current.attr(identifiers.regex).call($.regexp(schema.pattern, flags));
|
|
12896
13182
|
}
|
|
12897
13183
|
function stringResolver(ctx$1) {
|
|
12898
13184
|
const constNode$8 = ctx$1.nodes.const(ctx$1);
|
|
@@ -12916,7 +13202,7 @@ function stringResolver(ctx$1) {
|
|
|
12916
13202
|
if (patternNode$4) ctx$1.chain.current = patternNode$4;
|
|
12917
13203
|
return ctx$1.chain.current;
|
|
12918
13204
|
}
|
|
12919
|
-
|
|
13205
|
+
function stringToNode({ plugin, schema }) {
|
|
12920
13206
|
const z = plugin.external("zod.z");
|
|
12921
13207
|
const ctx$1 = {
|
|
12922
13208
|
$,
|
|
@@ -12936,11 +13222,12 @@ const stringToNode = ({ plugin, schema }) => {
|
|
|
12936
13222
|
};
|
|
12937
13223
|
const resolver = plugin.config["~resolvers"]?.string;
|
|
12938
13224
|
return { expression: resolver?.(ctx$1) ?? stringResolver(ctx$1) };
|
|
12939
|
-
}
|
|
13225
|
+
}
|
|
12940
13226
|
|
|
12941
13227
|
//#endregion
|
|
12942
13228
|
//#region src/plugins/zod/v4/toAst/tuple.ts
|
|
12943
|
-
|
|
13229
|
+
function tupleToAst(options) {
|
|
13230
|
+
const { applyModifiers, plugin, schema, walk } = options;
|
|
12944
13231
|
const result = {};
|
|
12945
13232
|
const z = plugin.external("zod.z");
|
|
12946
13233
|
if (schema.const && Array.isArray(schema.const)) {
|
|
@@ -12950,192 +13237,391 @@ const tupleToAst = ({ plugin, schema, state }) => {
|
|
|
12950
13237
|
}
|
|
12951
13238
|
const tupleElements = [];
|
|
12952
13239
|
if (schema.items) schema.items.forEach((item, index) => {
|
|
12953
|
-
const
|
|
12954
|
-
|
|
12955
|
-
|
|
12956
|
-
|
|
12957
|
-
|
|
12958
|
-
|
|
12959
|
-
|
|
12960
|
-
"items",
|
|
12961
|
-
index
|
|
12962
|
-
])
|
|
12963
|
-
}
|
|
12964
|
-
});
|
|
12965
|
-
tupleElements.push(itemSchema.expression);
|
|
12966
|
-
if (itemSchema.hasLazyExpression) result.hasLazyExpression = true;
|
|
13240
|
+
const itemResult = walk(item, childContext({
|
|
13241
|
+
path: options.state.path,
|
|
13242
|
+
plugin: options.plugin
|
|
13243
|
+
}, "items", index));
|
|
13244
|
+
if (itemResult.hasLazyExpression) result.hasLazyExpression = true;
|
|
13245
|
+
const finalExpr = applyModifiers(itemResult, { optional: false });
|
|
13246
|
+
tupleElements.push(finalExpr.expression);
|
|
12967
13247
|
});
|
|
12968
13248
|
result.expression = $(z).attr(identifiers.tuple).call($.array(...tupleElements));
|
|
12969
13249
|
return result;
|
|
12970
|
-
}
|
|
13250
|
+
}
|
|
12971
13251
|
|
|
12972
13252
|
//#endregion
|
|
12973
13253
|
//#region src/plugins/zod/v4/toAst/undefined.ts
|
|
12974
|
-
|
|
13254
|
+
function undefinedToAst({ plugin }) {
|
|
12975
13255
|
const result = {};
|
|
12976
13256
|
result.expression = $(plugin.external("zod.z")).attr(identifiers.undefined).call();
|
|
12977
13257
|
return result;
|
|
12978
|
-
}
|
|
13258
|
+
}
|
|
12979
13259
|
|
|
12980
13260
|
//#endregion
|
|
12981
13261
|
//#region src/plugins/zod/v4/toAst/void.ts
|
|
12982
|
-
|
|
13262
|
+
function voidToAst({ plugin }) {
|
|
12983
13263
|
const result = {};
|
|
12984
13264
|
result.expression = $(plugin.external("zod.z")).attr(identifiers.void).call();
|
|
12985
13265
|
return result;
|
|
12986
|
-
}
|
|
13266
|
+
}
|
|
12987
13267
|
|
|
12988
13268
|
//#endregion
|
|
12989
|
-
//#region src/plugins/zod/v4/
|
|
12990
|
-
function
|
|
12991
|
-
|
|
12992
|
-
|
|
12993
|
-
|
|
12994
|
-
|
|
12995
|
-
|
|
12996
|
-
|
|
12997
|
-
|
|
12998
|
-
|
|
12999
|
-
|
|
13000
|
-
|
|
13001
|
-
|
|
13002
|
-
|
|
13003
|
-
|
|
13004
|
-
|
|
13005
|
-
|
|
13006
|
-
|
|
13007
|
-
|
|
13008
|
-
|
|
13009
|
-
|
|
13010
|
-
|
|
13011
|
-
|
|
13012
|
-
|
|
13013
|
-
|
|
13014
|
-
|
|
13015
|
-
|
|
13016
|
-
|
|
13017
|
-
|
|
13018
|
-
|
|
13019
|
-
|
|
13020
|
-
|
|
13021
|
-
|
|
13022
|
-
|
|
13023
|
-
|
|
13024
|
-
...
|
|
13025
|
-
|
|
13269
|
+
//#region src/plugins/zod/v4/walker.ts
|
|
13270
|
+
function createVisitor(config) {
|
|
13271
|
+
const { schemaExtractor, state } = config;
|
|
13272
|
+
return {
|
|
13273
|
+
applyModifiers(result, ctx$1, options = {}) {
|
|
13274
|
+
const { optional } = options;
|
|
13275
|
+
let expression = result.expression.expression;
|
|
13276
|
+
if (result.readonly) expression = expression.attr(identifiers.readonly).call();
|
|
13277
|
+
const hasDefault = result.default !== void 0;
|
|
13278
|
+
const needsNullable = result.nullable;
|
|
13279
|
+
if (optional && needsNullable) expression = expression.attr(identifiers.nullish).call();
|
|
13280
|
+
else if (optional) expression = expression.attr(identifiers.optional).call();
|
|
13281
|
+
else if (needsNullable) expression = expression.attr(identifiers.nullable).call();
|
|
13282
|
+
if (hasDefault) expression = expression.attr(identifiers.default).call(result.format ? maybeBigInt(result.default, result.format) : $.fromValue(result.default));
|
|
13283
|
+
return { expression };
|
|
13284
|
+
},
|
|
13285
|
+
array(schema, ctx$1, walk) {
|
|
13286
|
+
const applyModifiers = (result, opts) => this.applyModifiers(result, ctx$1, opts);
|
|
13287
|
+
const ast = arrayToAst({
|
|
13288
|
+
...ctx$1,
|
|
13289
|
+
applyModifiers,
|
|
13290
|
+
schema,
|
|
13291
|
+
state,
|
|
13292
|
+
walk
|
|
13293
|
+
});
|
|
13294
|
+
return {
|
|
13295
|
+
default: schema.default,
|
|
13296
|
+
expression: ast,
|
|
13297
|
+
hasLazyExpression: state.hasLazyExpression["~ref"],
|
|
13298
|
+
nullable: false,
|
|
13299
|
+
readonly: schema.accessScope === "read"
|
|
13300
|
+
};
|
|
13301
|
+
},
|
|
13302
|
+
boolean(schema, ctx$1) {
|
|
13303
|
+
const ast = booleanToAst({
|
|
13304
|
+
...ctx$1,
|
|
13305
|
+
schema
|
|
13306
|
+
});
|
|
13307
|
+
return {
|
|
13308
|
+
default: schema.default,
|
|
13309
|
+
expression: ast,
|
|
13310
|
+
nullable: false,
|
|
13311
|
+
readonly: schema.accessScope === "read"
|
|
13312
|
+
};
|
|
13313
|
+
},
|
|
13314
|
+
enum(schema, ctx$1) {
|
|
13315
|
+
const ast = enumToAst({
|
|
13316
|
+
...ctx$1,
|
|
13317
|
+
schema,
|
|
13318
|
+
state
|
|
13319
|
+
});
|
|
13320
|
+
const hasNull = schema.items?.some((item) => item.type === "null" || item.const === null) ?? false;
|
|
13321
|
+
return {
|
|
13322
|
+
default: schema.default,
|
|
13323
|
+
expression: ast,
|
|
13324
|
+
nullable: hasNull,
|
|
13325
|
+
readonly: schema.accessScope === "read"
|
|
13326
|
+
};
|
|
13327
|
+
},
|
|
13328
|
+
integer(schema, ctx$1) {
|
|
13329
|
+
const ast = numberToNode({
|
|
13330
|
+
...ctx$1,
|
|
13331
|
+
schema,
|
|
13332
|
+
state
|
|
13333
|
+
});
|
|
13334
|
+
return {
|
|
13335
|
+
default: schema.default,
|
|
13336
|
+
expression: ast,
|
|
13337
|
+
format: schema.format,
|
|
13338
|
+
nullable: false,
|
|
13339
|
+
readonly: schema.accessScope === "read"
|
|
13340
|
+
};
|
|
13341
|
+
},
|
|
13342
|
+
intercept(schema, ctx$1, walk) {
|
|
13343
|
+
if (schemaExtractor && !schema.$ref) {
|
|
13344
|
+
const extracted = schemaExtractor({
|
|
13345
|
+
meta: {
|
|
13346
|
+
resource: "definition",
|
|
13347
|
+
resourceId: pathToJsonPointer(fromRef(ctx$1.path))
|
|
13348
|
+
},
|
|
13349
|
+
naming: ctx$1.plugin.config.definitions,
|
|
13350
|
+
path: fromRef(ctx$1.path),
|
|
13351
|
+
plugin: ctx$1.plugin,
|
|
13352
|
+
schema
|
|
13353
|
+
});
|
|
13354
|
+
if (extracted !== schema) return walk(extracted, ctx$1);
|
|
13026
13355
|
}
|
|
13027
|
-
}
|
|
13028
|
-
|
|
13029
|
-
|
|
13030
|
-
|
|
13031
|
-
|
|
13032
|
-
|
|
13033
|
-
|
|
13034
|
-
|
|
13035
|
-
|
|
13036
|
-
|
|
13037
|
-
|
|
13038
|
-
|
|
13039
|
-
|
|
13040
|
-
|
|
13041
|
-
|
|
13042
|
-
|
|
13043
|
-
|
|
13044
|
-
|
|
13045
|
-
|
|
13046
|
-
|
|
13047
|
-
|
|
13356
|
+
},
|
|
13357
|
+
intersection(items, schemas, parentSchema, ctx$1) {
|
|
13358
|
+
const z = ctx$1.plugin.external("zod.z");
|
|
13359
|
+
const hasAnyLazy = items.some((item) => item.hasLazyExpression);
|
|
13360
|
+
const firstSchema = schemas[0];
|
|
13361
|
+
let expression;
|
|
13362
|
+
if (firstSchema?.logicalOperator === "or" || firstSchema?.type && firstSchema.type !== "object") expression = { expression: $(z).attr(identifiers.intersection).call(...items.map((item) => item.expression.expression)) };
|
|
13363
|
+
else {
|
|
13364
|
+
expression = items[0].expression;
|
|
13365
|
+
items.slice(1).forEach((item) => {
|
|
13366
|
+
expression = { expression: expression.expression.attr(identifiers.and).call(item.hasLazyExpression ? $(z).attr(identifiers.lazy).call($.func().do(item.expression.expression.return())) : item.expression.expression) };
|
|
13367
|
+
});
|
|
13368
|
+
}
|
|
13369
|
+
return {
|
|
13370
|
+
default: parentSchema.default,
|
|
13371
|
+
expression,
|
|
13372
|
+
hasLazyExpression: hasAnyLazy,
|
|
13373
|
+
nullable: items.some((i) => i.nullable),
|
|
13374
|
+
readonly: items.some((i) => i.readonly)
|
|
13375
|
+
};
|
|
13376
|
+
},
|
|
13377
|
+
never(schema, ctx$1) {
|
|
13378
|
+
const ast = neverToAst({
|
|
13379
|
+
...ctx$1,
|
|
13380
|
+
schema
|
|
13381
|
+
});
|
|
13382
|
+
return {
|
|
13383
|
+
default: schema.default,
|
|
13384
|
+
expression: ast,
|
|
13385
|
+
nullable: false,
|
|
13386
|
+
readonly: false
|
|
13387
|
+
};
|
|
13388
|
+
},
|
|
13389
|
+
null(schema, ctx$1) {
|
|
13390
|
+
const ast = nullToAst({
|
|
13391
|
+
...ctx$1,
|
|
13392
|
+
schema
|
|
13393
|
+
});
|
|
13394
|
+
return {
|
|
13395
|
+
default: schema.default,
|
|
13396
|
+
expression: ast,
|
|
13397
|
+
nullable: false,
|
|
13398
|
+
readonly: false
|
|
13399
|
+
};
|
|
13400
|
+
},
|
|
13401
|
+
number(schema, ctx$1) {
|
|
13402
|
+
const ast = numberToNode({
|
|
13403
|
+
...ctx$1,
|
|
13404
|
+
schema,
|
|
13405
|
+
state
|
|
13406
|
+
});
|
|
13407
|
+
return {
|
|
13408
|
+
default: schema.default,
|
|
13409
|
+
expression: ast,
|
|
13410
|
+
format: schema.format,
|
|
13411
|
+
nullable: false,
|
|
13412
|
+
readonly: schema.accessScope === "read"
|
|
13413
|
+
};
|
|
13414
|
+
},
|
|
13415
|
+
object(schema, ctx$1, walk) {
|
|
13416
|
+
const applyModifiers = (result, opts) => this.applyModifiers(result, ctx$1, opts);
|
|
13417
|
+
const ast = objectToAst({
|
|
13418
|
+
applyModifiers,
|
|
13419
|
+
plugin: ctx$1.plugin,
|
|
13420
|
+
schema,
|
|
13421
|
+
state,
|
|
13422
|
+
walk,
|
|
13423
|
+
walkerCtx: ctx$1
|
|
13424
|
+
});
|
|
13425
|
+
return {
|
|
13426
|
+
default: schema.default,
|
|
13427
|
+
expression: ast,
|
|
13428
|
+
hasLazyExpression: state.hasLazyExpression["~ref"],
|
|
13429
|
+
nullable: false,
|
|
13430
|
+
readonly: schema.accessScope === "read"
|
|
13431
|
+
};
|
|
13432
|
+
},
|
|
13433
|
+
postProcess(result, schema, ctx$1) {
|
|
13434
|
+
if (ctx$1.plugin.config.metadata && schema.description) {
|
|
13435
|
+
const z = ctx$1.plugin.external("zod.z");
|
|
13436
|
+
return {
|
|
13437
|
+
...result,
|
|
13438
|
+
expression: { expression: result.expression.expression.attr(identifiers.register).call($(z).attr(identifiers.globalRegistry), $.object().pretty().prop("description", $.literal(schema.description))) }
|
|
13439
|
+
};
|
|
13440
|
+
}
|
|
13441
|
+
return result;
|
|
13442
|
+
},
|
|
13443
|
+
reference($ref, schema, ctx$1) {
|
|
13444
|
+
const z = ctx$1.plugin.external("zod.z");
|
|
13445
|
+
const query = {
|
|
13446
|
+
category: "schema",
|
|
13447
|
+
resource: "definition",
|
|
13448
|
+
resourceId: $ref,
|
|
13449
|
+
tool: "zod"
|
|
13450
|
+
};
|
|
13451
|
+
const refSymbol = ctx$1.plugin.referenceSymbol(query);
|
|
13452
|
+
if (ctx$1.plugin.isSymbolRegistered(query)) return {
|
|
13453
|
+
default: schema.default,
|
|
13454
|
+
expression: { expression: $(refSymbol) },
|
|
13455
|
+
nullable: false,
|
|
13456
|
+
readonly: schema.accessScope === "read"
|
|
13457
|
+
};
|
|
13458
|
+
state.hasLazyExpression["~ref"] = true;
|
|
13459
|
+
return {
|
|
13460
|
+
default: schema.default,
|
|
13461
|
+
expression: { expression: $(z).attr(identifiers.lazy).call($.func().returns("any").do($(refSymbol).return())) },
|
|
13462
|
+
hasLazyExpression: true,
|
|
13463
|
+
nullable: false,
|
|
13464
|
+
readonly: schema.accessScope === "read"
|
|
13465
|
+
};
|
|
13466
|
+
},
|
|
13467
|
+
string(schema, ctx$1) {
|
|
13468
|
+
if (shouldCoerceToBigInt(schema.format)) {
|
|
13469
|
+
const ast$1 = numberToNode({
|
|
13470
|
+
plugin: ctx$1.plugin,
|
|
13471
|
+
schema: {
|
|
13472
|
+
...schema,
|
|
13473
|
+
type: "number"
|
|
13474
|
+
},
|
|
13475
|
+
state
|
|
13476
|
+
});
|
|
13477
|
+
return {
|
|
13478
|
+
default: schema.default,
|
|
13479
|
+
expression: ast$1,
|
|
13480
|
+
nullable: false,
|
|
13481
|
+
readonly: schema.accessScope === "read"
|
|
13482
|
+
};
|
|
13483
|
+
}
|
|
13484
|
+
const ast = stringToNode({
|
|
13485
|
+
...ctx$1,
|
|
13486
|
+
schema
|
|
13487
|
+
});
|
|
13488
|
+
return {
|
|
13489
|
+
default: schema.default,
|
|
13490
|
+
expression: ast,
|
|
13491
|
+
nullable: false,
|
|
13492
|
+
readonly: schema.accessScope === "read"
|
|
13493
|
+
};
|
|
13494
|
+
},
|
|
13495
|
+
tuple(schema, ctx$1, walk) {
|
|
13496
|
+
const applyModifiers = (result, opts) => this.applyModifiers(result, ctx$1, opts);
|
|
13497
|
+
const ast = tupleToAst({
|
|
13498
|
+
...ctx$1,
|
|
13499
|
+
applyModifiers,
|
|
13500
|
+
schema,
|
|
13501
|
+
state,
|
|
13502
|
+
walk
|
|
13503
|
+
});
|
|
13504
|
+
return {
|
|
13505
|
+
default: schema.default,
|
|
13506
|
+
expression: ast,
|
|
13507
|
+
hasLazyExpression: state.hasLazyExpression["~ref"],
|
|
13508
|
+
nullable: false,
|
|
13509
|
+
readonly: schema.accessScope === "read"
|
|
13510
|
+
};
|
|
13511
|
+
},
|
|
13512
|
+
undefined(schema, ctx$1) {
|
|
13513
|
+
const ast = undefinedToAst({
|
|
13514
|
+
...ctx$1,
|
|
13515
|
+
schema
|
|
13516
|
+
});
|
|
13517
|
+
return {
|
|
13518
|
+
default: schema.default,
|
|
13519
|
+
expression: ast,
|
|
13520
|
+
nullable: false,
|
|
13521
|
+
readonly: false
|
|
13522
|
+
};
|
|
13523
|
+
},
|
|
13524
|
+
union(items, schemas, parentSchema, ctx$1) {
|
|
13525
|
+
const z = ctx$1.plugin.external("zod.z");
|
|
13526
|
+
const hasAnyLazy = items.some((item) => item.hasLazyExpression);
|
|
13527
|
+
const hasNull = schemas.some((s) => s.type === "null") || items.some((i) => i.nullable);
|
|
13528
|
+
const nonNullItems = [];
|
|
13529
|
+
items.forEach((item, index) => {
|
|
13530
|
+
if (schemas[index].type !== "null") nonNullItems.push(item);
|
|
13531
|
+
});
|
|
13532
|
+
let expression;
|
|
13533
|
+
if (nonNullItems.length === 0) expression = { expression: $(z).attr(identifiers.null).call() };
|
|
13534
|
+
else if (nonNullItems.length === 1) expression = nonNullItems[0].expression;
|
|
13535
|
+
else expression = { expression: $(z).attr(identifiers.union).call($.array().pretty().elements(...nonNullItems.map((item) => item.expression.expression))) };
|
|
13536
|
+
return {
|
|
13537
|
+
default: parentSchema.default,
|
|
13538
|
+
expression,
|
|
13539
|
+
hasLazyExpression: hasAnyLazy,
|
|
13540
|
+
nullable: hasNull,
|
|
13541
|
+
readonly: items.some((i) => i.readonly)
|
|
13542
|
+
};
|
|
13543
|
+
},
|
|
13544
|
+
unknown(schema, ctx$1) {
|
|
13545
|
+
const ast = unknownToAst({
|
|
13546
|
+
...ctx$1,
|
|
13547
|
+
schema
|
|
13548
|
+
});
|
|
13549
|
+
return {
|
|
13550
|
+
default: schema.default,
|
|
13551
|
+
expression: ast,
|
|
13552
|
+
nullable: false,
|
|
13553
|
+
readonly: false
|
|
13554
|
+
};
|
|
13555
|
+
},
|
|
13556
|
+
void(schema, ctx$1) {
|
|
13557
|
+
const ast = voidToAst({
|
|
13558
|
+
...ctx$1,
|
|
13559
|
+
schema
|
|
13560
|
+
});
|
|
13561
|
+
return {
|
|
13562
|
+
default: schema.default,
|
|
13563
|
+
expression: ast,
|
|
13564
|
+
nullable: false,
|
|
13565
|
+
readonly: false
|
|
13566
|
+
};
|
|
13567
|
+
}
|
|
13568
|
+
};
|
|
13048
13569
|
}
|
|
13049
13570
|
|
|
13050
13571
|
//#endregion
|
|
13051
|
-
//#region src/plugins/zod/v4/
|
|
13052
|
-
function
|
|
13053
|
-
|
|
13054
|
-
|
|
13055
|
-
|
|
13056
|
-
|
|
13057
|
-
|
|
13058
|
-
|
|
13059
|
-
|
|
13060
|
-
|
|
13061
|
-
|
|
13062
|
-
|
|
13063
|
-
|
|
13064
|
-
if (extracted !== schema) schema = extracted;
|
|
13065
|
-
}
|
|
13066
|
-
let ast = {};
|
|
13067
|
-
const z = plugin.external("zod.z");
|
|
13068
|
-
if (schema.$ref) {
|
|
13069
|
-
const query = {
|
|
13070
|
-
category: "schema",
|
|
13071
|
-
resource: "definition",
|
|
13072
|
-
resourceId: schema.$ref,
|
|
13073
|
-
tool: "zod"
|
|
13074
|
-
};
|
|
13075
|
-
const refSymbol = plugin.referenceSymbol(query);
|
|
13076
|
-
if (plugin.isSymbolRegistered(query)) ast.expression = $(refSymbol);
|
|
13077
|
-
else {
|
|
13078
|
-
ast.expression = $(z).attr(identifiers.lazy).call($.func().returns("any").do($(refSymbol).return()));
|
|
13079
|
-
ast.hasLazyExpression = true;
|
|
13080
|
-
state.hasLazyExpression["~ref"] = true;
|
|
13572
|
+
//#region src/plugins/zod/v4/processor.ts
|
|
13573
|
+
function createProcessor(plugin) {
|
|
13574
|
+
const processor = createSchemaProcessor();
|
|
13575
|
+
const hooks = [plugin.config["~hooks"]?.schemas, plugin.context.config.parser.hooks.schemas];
|
|
13576
|
+
function extractor(ctx$1) {
|
|
13577
|
+
if (processor.hasEmitted(ctx$1.path)) return ctx$1.schema;
|
|
13578
|
+
for (const hook of hooks) if (hook?.shouldExtract?.(ctx$1)) {
|
|
13579
|
+
process$1({
|
|
13580
|
+
namingAnchor: processor.context.anchor,
|
|
13581
|
+
tags: processor.context.tags,
|
|
13582
|
+
...ctx$1
|
|
13583
|
+
});
|
|
13584
|
+
return { $ref: pathToJsonPointer(ctx$1.path) };
|
|
13081
13585
|
}
|
|
13082
|
-
|
|
13083
|
-
|
|
13084
|
-
|
|
13085
|
-
|
|
13086
|
-
|
|
13087
|
-
|
|
13088
|
-
|
|
13089
|
-
|
|
13090
|
-
|
|
13091
|
-
|
|
13092
|
-
|
|
13093
|
-
|
|
13094
|
-
|
|
13586
|
+
return ctx$1.schema;
|
|
13587
|
+
}
|
|
13588
|
+
function process$1(ctx$1) {
|
|
13589
|
+
if (!processor.markEmitted(ctx$1.path)) return;
|
|
13590
|
+
processor.withContext({
|
|
13591
|
+
anchor: ctx$1.namingAnchor,
|
|
13592
|
+
tags: ctx$1.tags
|
|
13593
|
+
}, () => {
|
|
13594
|
+
const state = refs({
|
|
13595
|
+
hasLazyExpression: false,
|
|
13596
|
+
path: ctx$1.path,
|
|
13597
|
+
tags: ctx$1.tags
|
|
13598
|
+
});
|
|
13599
|
+
const visitor = createVisitor({
|
|
13600
|
+
schemaExtractor: extractor,
|
|
13601
|
+
state
|
|
13602
|
+
});
|
|
13603
|
+
const result = createSchemaWalker(visitor)(ctx$1.schema, {
|
|
13604
|
+
path: ref(ctx$1.path),
|
|
13605
|
+
plugin
|
|
13606
|
+
});
|
|
13607
|
+
const ast = visitor.applyModifiers(result, {
|
|
13608
|
+
path: ref(ctx$1.path),
|
|
13609
|
+
plugin
|
|
13610
|
+
}) ?? result.expression;
|
|
13611
|
+
if (result.hasLazyExpression) state.hasLazyExpression["~ref"] = true;
|
|
13612
|
+
exportAst({
|
|
13613
|
+
...ctx$1,
|
|
13614
|
+
ast,
|
|
13095
13615
|
plugin,
|
|
13096
|
-
|
|
13097
|
-
|
|
13098
|
-
...state,
|
|
13099
|
-
path: ref([
|
|
13100
|
-
...fromRef(state.path),
|
|
13101
|
-
"items",
|
|
13102
|
-
index
|
|
13103
|
-
])
|
|
13104
|
-
}
|
|
13105
|
-
}));
|
|
13106
|
-
if (schema.logicalOperator === "and") {
|
|
13107
|
-
const firstSchema = schema.items[0];
|
|
13108
|
-
if (firstSchema.logicalOperator === "or" || firstSchema.type && firstSchema.type !== "object") ast.expression = $(z).attr(identifiers.intersection).call(...itemSchemas.map((schema$1) => schema$1.expression));
|
|
13109
|
-
else {
|
|
13110
|
-
ast.expression = itemSchemas[0].expression;
|
|
13111
|
-
itemSchemas.slice(1).forEach((schema$1) => {
|
|
13112
|
-
ast.expression = ast.expression.attr(identifiers.and).call(schema$1.hasLazyExpression ? $(z).attr(identifiers.lazy).call($.func().do(schema$1.expression.return())) : schema$1.expression);
|
|
13113
|
-
});
|
|
13114
|
-
}
|
|
13115
|
-
} else ast.expression = $(z).attr(identifiers.union).call($.array().pretty().elements(...itemSchemas.map((schema$1) => schema$1.expression)));
|
|
13116
|
-
} else ast = irSchemaToAst({
|
|
13117
|
-
plugin,
|
|
13118
|
-
schema,
|
|
13119
|
-
state
|
|
13120
|
-
});
|
|
13121
|
-
} else {
|
|
13122
|
-
const typeAst = irSchemaWithTypeToAst({
|
|
13123
|
-
plugin,
|
|
13124
|
-
schema: { type: "unknown" },
|
|
13125
|
-
state
|
|
13616
|
+
state
|
|
13617
|
+
});
|
|
13126
13618
|
});
|
|
13127
|
-
ast.expression = typeAst.expression;
|
|
13128
|
-
}
|
|
13129
|
-
if (ast.expression) {
|
|
13130
|
-
if (schema.accessScope === "read") ast.expression = ast.expression.attr(identifiers.readonly).call();
|
|
13131
|
-
if (optional) {
|
|
13132
|
-
ast.expression = $(z).attr(identifiers.optional).call(ast.expression);
|
|
13133
|
-
ast.typeName = identifiers.ZodOptional;
|
|
13134
|
-
}
|
|
13135
|
-
if (schema.default !== void 0) ast.expression = ast.expression.attr(identifiers.default).call(schema.type === "integer" || schema.type === "number" ? maybeBigInt(schema.default, schema.format) : $.fromValue(schema.default));
|
|
13136
13619
|
}
|
|
13137
|
-
return
|
|
13620
|
+
return { process: process$1 };
|
|
13138
13621
|
}
|
|
13622
|
+
|
|
13623
|
+
//#endregion
|
|
13624
|
+
//#region src/plugins/zod/v4/plugin.ts
|
|
13139
13625
|
const handlerV4 = ({ plugin }) => {
|
|
13140
13626
|
plugin.symbol("z", {
|
|
13141
13627
|
external: getZodModule({ plugin }),
|
|
@@ -13638,4 +14124,4 @@ async function resolveJobs({ logger, userConfigs }) {
|
|
|
13638
14124
|
|
|
13639
14125
|
//#endregion
|
|
13640
14126
|
export { postProcessors as _, clientDefaultConfig as a, TypeScriptRenderer as c, reserved as d, keywords as f, getTypedConfig as g, getClientPlugin as h, generateClientBundle as i, TsDslContext as l, TsDsl as m, defaultPlugins as n, clientDefaultMeta as o, regexp as p, clientPluginHandler as r, $ as s, resolveJobs as t, ctx as u };
|
|
13641
|
-
//# sourceMappingURL=init-
|
|
14127
|
+
//# sourceMappingURL=init-CuDouDN2.mjs.map
|