@hey-api/openapi-ts 0.97.1 → 0.97.2
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/README.md +16 -8
- package/dist/clients/angular/client.ts +1 -4
- package/dist/clients/angular/utils.ts +7 -8
- package/dist/clients/axios/client.ts +1 -4
- package/dist/clients/axios/utils.ts +6 -8
- package/dist/clients/fetch/client.ts +1 -4
- package/dist/clients/fetch/utils.ts +6 -8
- package/dist/clients/ky/client.ts +1 -4
- package/dist/clients/ky/utils.ts +6 -8
- package/dist/clients/next/client.ts +1 -4
- package/dist/clients/next/utils.ts +6 -8
- package/dist/clients/nuxt/client.ts +7 -6
- package/dist/clients/nuxt/utils.ts +6 -8
- package/dist/clients/ofetch/client.ts +1 -4
- package/dist/clients/ofetch/utils.ts +6 -8
- package/dist/index.d.mts +312 -101
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/{init-Bi6_Uyy_.mjs → init-CitwzRmB.mjs} +747 -353
- package/dist/init-CitwzRmB.mjs.map +1 -0
- package/dist/internal.mjs +1 -1
- package/dist/run.mjs +2 -2
- package/dist/{src-CSz9FXkH.mjs → src-DEol_iHK.mjs} +2 -2
- package/dist/{src-CSz9FXkH.mjs.map → src-DEol_iHK.mjs.map} +1 -1
- package/package.json +6 -6
- package/dist/init-Bi6_Uyy_.mjs.map +0 -1
|
@@ -2164,6 +2164,7 @@ var EnumTsDsl = class extends Mixed$40 {
|
|
|
2164
2164
|
const Mixed$39 = AbstractMixin(AsMixin(AsyncMixin(DecoratorMixin(DoMixin(DocMixin(ExportMixin(ParamMixin(PrivateMixin(ProtectedMixin(PublicMixin(StaticMixin(TypeParamsMixin(TypeReturnsMixin(TsDsl))))))))))))));
|
|
2165
2165
|
var ImplFuncTsDsl = class extends Mixed$39 {
|
|
2166
2166
|
"~dsl" = "FuncTsDsl";
|
|
2167
|
+
"~mode";
|
|
2167
2168
|
nameSanitizer = safeRuntimeName;
|
|
2168
2169
|
mode;
|
|
2169
2170
|
constructor(name, fn) {
|
|
@@ -4132,6 +4133,7 @@ f.type.tupleMember.set((name) => new TypeTupleMemberTsDsl(name));
|
|
|
4132
4133
|
var LazyTsDsl = class extends TsDsl {
|
|
4133
4134
|
"~dsl" = "LazyTsDsl";
|
|
4134
4135
|
_thunk;
|
|
4136
|
+
_result;
|
|
4135
4137
|
constructor(thunk) {
|
|
4136
4138
|
super();
|
|
4137
4139
|
this._thunk = thunk;
|
|
@@ -4141,7 +4143,8 @@ var LazyTsDsl = class extends TsDsl {
|
|
|
4141
4143
|
ctx.analyze(this.toResult());
|
|
4142
4144
|
}
|
|
4143
4145
|
toResult() {
|
|
4144
|
-
|
|
4146
|
+
this._result ??= this._thunk(ctx);
|
|
4147
|
+
return this._result;
|
|
4145
4148
|
}
|
|
4146
4149
|
toAst() {
|
|
4147
4150
|
return this.toResult().toAst();
|
|
@@ -4523,6 +4526,67 @@ const operationAuth = ({ operation, plugin }) => {
|
|
|
4523
4526
|
return auth;
|
|
4524
4527
|
};
|
|
4525
4528
|
//#endregion
|
|
4529
|
+
//#region src/plugins/@hey-api/sdk/shared/transformer.ts
|
|
4530
|
+
function createResponseTransformer({ operation, plugin }) {
|
|
4531
|
+
if (!plugin.config.transformer.response) return;
|
|
4532
|
+
const transformer = plugin.getPluginOrThrow(plugin.config.transformer.response);
|
|
4533
|
+
if (transformer.api?.createResponseTransformer && typeof transformer.api.createResponseTransformer === "function") return transformer.api.createResponseTransformer({
|
|
4534
|
+
operation,
|
|
4535
|
+
plugin: transformer
|
|
4536
|
+
});
|
|
4537
|
+
const query = {
|
|
4538
|
+
category: "transform",
|
|
4539
|
+
resource: "operation",
|
|
4540
|
+
resourceId: operation.id,
|
|
4541
|
+
role: "response"
|
|
4542
|
+
};
|
|
4543
|
+
if (plugin.isSymbolRegistered(query)) return $(plugin.referenceSymbol(query));
|
|
4544
|
+
}
|
|
4545
|
+
//#endregion
|
|
4546
|
+
//#region src/plugins/@hey-api/sdk/shared/validator.ts
|
|
4547
|
+
function createRequestValidator({ plugin, ...args }) {
|
|
4548
|
+
if (!plugin.config.validator.request) return;
|
|
4549
|
+
const validator = plugin.getPluginOrThrow(plugin.config.validator.request);
|
|
4550
|
+
if (!validator.api.createRequestValidator) return;
|
|
4551
|
+
return validator.api.createRequestValidator({
|
|
4552
|
+
...args,
|
|
4553
|
+
plugin: validator
|
|
4554
|
+
});
|
|
4555
|
+
}
|
|
4556
|
+
function createResponseValidator({ operation, plugin }) {
|
|
4557
|
+
if (!plugin.config.validator.response) return;
|
|
4558
|
+
const validator = plugin.getPluginOrThrow(plugin.config.validator.response);
|
|
4559
|
+
if (!validator.api.createResponseValidator) return;
|
|
4560
|
+
return validator.api.createResponseValidator({
|
|
4561
|
+
operation,
|
|
4562
|
+
plugin: validator
|
|
4563
|
+
});
|
|
4564
|
+
}
|
|
4565
|
+
//#endregion
|
|
4566
|
+
//#region src/plugins/@hey-api/sdk/shared/handlers.ts
|
|
4567
|
+
function createResponseHandlers({ operation, plugin }) {
|
|
4568
|
+
let handlers;
|
|
4569
|
+
const responseTransformer = plugin.config.transformer.response;
|
|
4570
|
+
if (responseTransformer && responseTransformer === plugin.config.validator.response) {
|
|
4571
|
+
const handler = plugin.getPluginOrThrow(responseTransformer);
|
|
4572
|
+
if (handler.api?.createResponseHandlers) handlers = handler.api.createResponseHandlers({
|
|
4573
|
+
operation,
|
|
4574
|
+
plugin: handler
|
|
4575
|
+
});
|
|
4576
|
+
}
|
|
4577
|
+
if (!handlers) handlers = {
|
|
4578
|
+
transformer: createResponseTransformer({
|
|
4579
|
+
operation,
|
|
4580
|
+
plugin
|
|
4581
|
+
}),
|
|
4582
|
+
validator: createResponseValidator({
|
|
4583
|
+
operation,
|
|
4584
|
+
plugin
|
|
4585
|
+
})
|
|
4586
|
+
};
|
|
4587
|
+
return handlers;
|
|
4588
|
+
}
|
|
4589
|
+
//#endregion
|
|
4526
4590
|
//#region src/plugins/@hey-api/sdk/shared/signature.ts
|
|
4527
4591
|
/**
|
|
4528
4592
|
* Collects and resolves all operation parameters for flattened SDK signatures.
|
|
@@ -4629,26 +4693,6 @@ function getSignatureParameters({ operation }) {
|
|
|
4629
4693
|
};
|
|
4630
4694
|
}
|
|
4631
4695
|
//#endregion
|
|
4632
|
-
//#region src/plugins/@hey-api/sdk/shared/validator.ts
|
|
4633
|
-
function createRequestValidator({ plugin, ...args }) {
|
|
4634
|
-
if (!plugin.config.validator.request) return;
|
|
4635
|
-
const validator = plugin.getPluginOrThrow(plugin.config.validator.request);
|
|
4636
|
-
if (!validator.api.createRequestValidator) return;
|
|
4637
|
-
return validator.api.createRequestValidator({
|
|
4638
|
-
...args,
|
|
4639
|
-
plugin: validator
|
|
4640
|
-
});
|
|
4641
|
-
}
|
|
4642
|
-
function createResponseValidator({ operation, plugin }) {
|
|
4643
|
-
if (!plugin.config.validator.response) return;
|
|
4644
|
-
const validator = plugin.getPluginOrThrow(plugin.config.validator.response);
|
|
4645
|
-
if (!validator.api.createResponseValidator) return;
|
|
4646
|
-
return validator.api.createResponseValidator({
|
|
4647
|
-
operation,
|
|
4648
|
-
plugin: validator
|
|
4649
|
-
});
|
|
4650
|
-
}
|
|
4651
|
-
//#endregion
|
|
4652
4696
|
//#region src/plugins/@hey-api/sdk/shared/operation.ts
|
|
4653
4697
|
/** TODO: needs complete refactor */
|
|
4654
4698
|
const operationOptionsType = ({ isDataAllowed = true, operation, plugin, throwOnError }) => {
|
|
@@ -4797,23 +4841,12 @@ function operationStatements({ isRequiredOptions, opParameters, operation, plugi
|
|
|
4797
4841
|
operation,
|
|
4798
4842
|
plugin
|
|
4799
4843
|
});
|
|
4800
|
-
const
|
|
4844
|
+
const responseHandlers = createResponseHandlers({
|
|
4801
4845
|
operation,
|
|
4802
4846
|
plugin
|
|
4803
4847
|
});
|
|
4804
|
-
if (requestValidator) reqOptions.prop("requestValidator", requestValidator
|
|
4805
|
-
if (
|
|
4806
|
-
const query = {
|
|
4807
|
-
category: "transform",
|
|
4808
|
-
resource: "operation",
|
|
4809
|
-
resourceId: operation.id,
|
|
4810
|
-
role: "response"
|
|
4811
|
-
};
|
|
4812
|
-
if (plugin.isSymbolRegistered(query)) {
|
|
4813
|
-
const ref = plugin.referenceSymbol(query);
|
|
4814
|
-
reqOptions.prop("responseTransformer", $(ref));
|
|
4815
|
-
}
|
|
4816
|
-
}
|
|
4848
|
+
if (requestValidator) reqOptions.prop("requestValidator", requestValidator);
|
|
4849
|
+
if (responseHandlers.transformer) reqOptions.prop("responseTransformer", responseHandlers.transformer);
|
|
4817
4850
|
let hasServerSentEvents = false;
|
|
4818
4851
|
let responseTypeValue;
|
|
4819
4852
|
for (const statusCode in operation.responses) {
|
|
@@ -4826,7 +4859,7 @@ function operationStatements({ isRequiredOptions, opParameters, operation, plugi
|
|
|
4826
4859
|
}
|
|
4827
4860
|
if (response.mediaType === "text/event-stream") hasServerSentEvents = true;
|
|
4828
4861
|
}
|
|
4829
|
-
if (
|
|
4862
|
+
if (responseHandlers.validator) reqOptions.prop("responseValidator", responseHandlers.validator);
|
|
4830
4863
|
if (plugin.config.responseStyle === "data") reqOptions.prop("responseStyle", $.literal(plugin.config.responseStyle));
|
|
4831
4864
|
const auth = operationAuth({
|
|
4832
4865
|
context: plugin.context,
|
|
@@ -6314,15 +6347,16 @@ const defaultConfig$16 = {
|
|
|
6314
6347
|
if (typeof plugin.config.client === "boolean") plugin.config.client = context.pluginByTag("client", { defaultPlugin: "@hey-api/client-fetch" });
|
|
6315
6348
|
plugin.dependencies.add(plugin.config.client);
|
|
6316
6349
|
} else plugin.config.client = false;
|
|
6317
|
-
if (plugin.config.transformer
|
|
6318
|
-
|
|
6319
|
-
plugin.
|
|
6350
|
+
if (typeof plugin.config.transformer !== "object") plugin.config.transformer = { response: plugin.config.transformer };
|
|
6351
|
+
if (plugin.config.transformer.response) if (typeof plugin.config.transformer.response === "boolean") try {
|
|
6352
|
+
plugin.config.transformer.response = context.pluginByTag("transformer");
|
|
6353
|
+
plugin.dependencies.add(plugin.config.transformer.response);
|
|
6320
6354
|
} catch {
|
|
6321
6355
|
log.warn(transformerInferWarn);
|
|
6322
|
-
plugin.config.transformer = false;
|
|
6356
|
+
plugin.config.transformer.response = false;
|
|
6323
6357
|
}
|
|
6324
|
-
else plugin.dependencies.add(plugin.config.transformer);
|
|
6325
|
-
else plugin.config.transformer = false;
|
|
6358
|
+
else plugin.dependencies.add(plugin.config.transformer.response);
|
|
6359
|
+
else plugin.config.transformer.response = false;
|
|
6326
6360
|
if (typeof plugin.config.validator !== "object") plugin.config.validator = {
|
|
6327
6361
|
request: plugin.config.validator,
|
|
6328
6362
|
response: plugin.config.validator
|
|
@@ -6590,7 +6624,14 @@ const createSchemaComment = (schema) => {
|
|
|
6590
6624
|
return comments.length ? comments : void 0;
|
|
6591
6625
|
};
|
|
6592
6626
|
//#endregion
|
|
6593
|
-
//#region src/plugins/@hey-api/typescript/shared/
|
|
6627
|
+
//#region src/plugins/@hey-api/typescript/shared/enum.ts
|
|
6628
|
+
function createSymbolMeta(args) {
|
|
6629
|
+
return {
|
|
6630
|
+
...args,
|
|
6631
|
+
resource: "definition",
|
|
6632
|
+
tool: "typescript"
|
|
6633
|
+
};
|
|
6634
|
+
}
|
|
6594
6635
|
function resolveEnumKey({ baseName, duplicateAttempt, plugin }) {
|
|
6595
6636
|
let key = toCase(baseName, plugin.config.enums.case, { stripLeadingSeparators: false });
|
|
6596
6637
|
regexp.number.lastIndex = 0;
|
|
@@ -6602,59 +6643,57 @@ function resolveEnumKey({ baseName, duplicateAttempt, plugin }) {
|
|
|
6602
6643
|
attempt: duplicateAttempt,
|
|
6603
6644
|
baseName: key
|
|
6604
6645
|
});
|
|
6605
|
-
|
|
6606
|
-
else key = `${key}${duplicateAttempt + 1}`;
|
|
6646
|
+
key = resolvedName !== null ? resolvedName : `${key}${duplicateAttempt + 1}`;
|
|
6607
6647
|
} else key = `${key}${duplicateAttempt + 1}`;
|
|
6608
6648
|
}
|
|
6609
6649
|
return key;
|
|
6610
6650
|
}
|
|
6611
|
-
function
|
|
6612
|
-
if (!enumData || enumData.mode === "type") return false;
|
|
6613
|
-
const mode = enumData.mode;
|
|
6614
|
-
const items = enumData.items;
|
|
6651
|
+
function resolveItemsWithKeys(items, plugin) {
|
|
6615
6652
|
const duplicateCounts = {};
|
|
6616
|
-
|
|
6617
|
-
const
|
|
6618
|
-
|
|
6619
|
-
|
|
6653
|
+
return items.map((item) => {
|
|
6654
|
+
const baseKey = resolveEnumKey({
|
|
6655
|
+
baseName: item.key,
|
|
6656
|
+
duplicateAttempt: 0,
|
|
6657
|
+
plugin
|
|
6658
|
+
});
|
|
6620
6659
|
const duplicateAttempt = duplicateCounts[baseKey] ?? 0;
|
|
6621
6660
|
duplicateCounts[baseKey] = duplicateAttempt + 1;
|
|
6622
6661
|
return {
|
|
6623
|
-
|
|
6624
|
-
|
|
6625
|
-
|
|
6662
|
+
item,
|
|
6663
|
+
key: duplicateAttempt === 0 ? baseKey : resolveEnumKey({
|
|
6664
|
+
baseName: item.key,
|
|
6665
|
+
duplicateAttempt,
|
|
6666
|
+
plugin
|
|
6667
|
+
})
|
|
6626
6668
|
};
|
|
6627
6669
|
});
|
|
6670
|
+
}
|
|
6671
|
+
function exportEnumAst({ enumData, name, plugin, resourceId, schema }) {
|
|
6672
|
+
if (!enumData || enumData.mode === "type") return false;
|
|
6673
|
+
const { items, mode } = enumData;
|
|
6674
|
+
const itemsWithKeys = resolveItemsWithKeys(items, plugin);
|
|
6628
6675
|
if (mode === "javascript") {
|
|
6629
6676
|
const filteredItems = plugin.config.enums.constantsIgnoreNull && items.some((item) => item.schema.const === null) ? items.filter((item) => item.schema.const !== null) : items;
|
|
6630
6677
|
const symbolObject = plugin.registerSymbol(buildSymbolIn({
|
|
6631
|
-
meta: {
|
|
6678
|
+
meta: createSymbolMeta({
|
|
6632
6679
|
category: "utility",
|
|
6633
|
-
|
|
6634
|
-
|
|
6635
|
-
tool: "typescript"
|
|
6636
|
-
},
|
|
6680
|
+
resourceId
|
|
6681
|
+
}),
|
|
6637
6682
|
name,
|
|
6638
6683
|
naming: plugin.config.definitions,
|
|
6639
6684
|
plugin,
|
|
6640
6685
|
schema
|
|
6641
6686
|
}));
|
|
6642
|
-
const objectNode = $.const(symbolObject).export().$if(plugin.config.comments && createSchemaComment(schema), (c, v) => c.doc(v)).assign($.object(...
|
|
6687
|
+
const objectNode = $.const(symbolObject).export().$if(plugin.config.comments && createSchemaComment(schema), (c, v) => c.doc(v)).assign($.object(...itemsWithKeys.filter(({ item }) => filteredItems.includes(item)).map(({ item, key }) => $.prop({
|
|
6643
6688
|
kind: "prop",
|
|
6644
|
-
name:
|
|
6645
|
-
baseName: item.key,
|
|
6646
|
-
duplicateAttempt,
|
|
6647
|
-
plugin
|
|
6648
|
-
})
|
|
6689
|
+
name: key
|
|
6649
6690
|
}).$if(plugin.config.comments && createSchemaComment(item.schema), (p, v) => p.doc(v)).value($.fromValue(item.schema.const)))).as("const"));
|
|
6650
6691
|
plugin.node(objectNode);
|
|
6651
6692
|
const symbol = plugin.registerSymbol(buildSymbolIn({
|
|
6652
|
-
meta: {
|
|
6693
|
+
meta: createSymbolMeta({
|
|
6653
6694
|
category: "type",
|
|
6654
|
-
|
|
6655
|
-
|
|
6656
|
-
tool: "typescript"
|
|
6657
|
-
},
|
|
6695
|
+
resourceId
|
|
6696
|
+
}),
|
|
6658
6697
|
name,
|
|
6659
6698
|
naming: plugin.config.definitions,
|
|
6660
6699
|
plugin,
|
|
@@ -6667,31 +6706,27 @@ function buildEnumExport({ enumData, name, plugin, resourceId, schema }) {
|
|
|
6667
6706
|
if (mode === "typescript" || mode === "typescript-const") {
|
|
6668
6707
|
if (items.some((item) => typeof item.schema.const !== "number" && typeof item.schema.const !== "string")) return false;
|
|
6669
6708
|
const symbol = plugin.registerSymbol(buildSymbolIn({
|
|
6670
|
-
meta: {
|
|
6709
|
+
meta: createSymbolMeta({
|
|
6671
6710
|
category: "type",
|
|
6672
|
-
|
|
6673
|
-
|
|
6674
|
-
tool: "typescript"
|
|
6675
|
-
},
|
|
6711
|
+
resourceId
|
|
6712
|
+
}),
|
|
6676
6713
|
name,
|
|
6677
6714
|
naming: plugin.config.definitions,
|
|
6678
6715
|
plugin,
|
|
6679
6716
|
schema
|
|
6680
6717
|
}));
|
|
6681
|
-
const enumNode = $.enum(symbol).export().$if(plugin.config.comments && createSchemaComment(schema), (e, v) => e.doc(v)).const(mode === "typescript-const").members(...
|
|
6682
|
-
baseName: item.key,
|
|
6683
|
-
duplicateAttempt,
|
|
6684
|
-
plugin
|
|
6685
|
-
})).$if(plugin.config.comments && createSchemaComment(item.schema), (m, v) => m.doc(v)).value($.fromValue(item.schema.const))));
|
|
6718
|
+
const enumNode = $.enum(symbol).export().$if(plugin.config.comments && createSchemaComment(schema), (e, v) => e.doc(v)).const(mode === "typescript-const").members(...itemsWithKeys.map(({ item, key }) => $.member(key).$if(plugin.config.comments && createSchemaComment(item.schema), (m, v) => m.doc(v)).value($.fromValue(item.schema.const))));
|
|
6686
6719
|
plugin.node(enumNode);
|
|
6687
6720
|
return true;
|
|
6688
6721
|
}
|
|
6689
6722
|
return false;
|
|
6690
6723
|
}
|
|
6724
|
+
//#endregion
|
|
6725
|
+
//#region src/plugins/@hey-api/typescript/shared/export.ts
|
|
6691
6726
|
function exportAst$3({ final, meta, naming, namingAnchor, path, plugin, schema, tags }) {
|
|
6692
6727
|
const $ref = meta.resourceId || pathToJsonPointer(path);
|
|
6693
6728
|
const name = pathToName(path, { anchor: namingAnchor });
|
|
6694
|
-
if (
|
|
6729
|
+
if (exportEnumAst({
|
|
6695
6730
|
enumData: final.enumData,
|
|
6696
6731
|
name,
|
|
6697
6732
|
plugin,
|
|
@@ -7228,7 +7263,7 @@ function voidToAst$3({ plugin, schema }) {
|
|
|
7228
7263
|
return resolver?.(ctx) ?? voidResolver$4(ctx);
|
|
7229
7264
|
}
|
|
7230
7265
|
//#endregion
|
|
7231
|
-
//#region src/plugins/@hey-api/typescript/v1/
|
|
7266
|
+
//#region src/plugins/@hey-api/typescript/v1/visitor.ts
|
|
7232
7267
|
function createVisitor$4(config = {}) {
|
|
7233
7268
|
const { schemaExtractor } = config;
|
|
7234
7269
|
return {
|
|
@@ -8053,7 +8088,7 @@ const createMutationOptions$1 = ({ operation, plugin }) => {
|
|
|
8053
8088
|
};
|
|
8054
8089
|
//#endregion
|
|
8055
8090
|
//#region src/plugins/@pinia/colada/queryKey.ts
|
|
8056
|
-
const TOptionsType$
|
|
8091
|
+
const TOptionsType$2 = "TOptions";
|
|
8057
8092
|
const createQueryKeyFunction$1 = ({ plugin }) => {
|
|
8058
8093
|
const symbolCreateQueryKey = plugin.symbol(applyNaming("createQueryKey", { case: plugin.config.case }), { meta: {
|
|
8059
8094
|
category: "utility",
|
|
@@ -8066,7 +8101,7 @@ const createQueryKeyFunction$1 = ({ plugin }) => {
|
|
|
8066
8101
|
tool: plugin.name
|
|
8067
8102
|
});
|
|
8068
8103
|
const symbolJsonValue = plugin.external(`${plugin.name}._JSONValue`);
|
|
8069
|
-
const returnType = $.type(symbolQueryKeyType).generic(TOptionsType$
|
|
8104
|
+
const returnType = $.type(symbolQueryKeyType).generic(TOptionsType$2).idx(0);
|
|
8070
8105
|
const baseUrlKey = getClientBaseUrlKey(getTypedConfig(plugin));
|
|
8071
8106
|
const symbolOptions = plugin.referenceSymbol({
|
|
8072
8107
|
category: "type",
|
|
@@ -8076,7 +8111,7 @@ const createQueryKeyFunction$1 = ({ plugin }) => {
|
|
|
8076
8111
|
const symbolClient = plugin.querySymbol({ category: "client" });
|
|
8077
8112
|
const clientModule = clientFolderAbsolutePath(getTypedConfig(plugin));
|
|
8078
8113
|
const symbolSerializeQueryValue = plugin.symbol("serializeQueryKeyValue", { external: clientModule });
|
|
8079
|
-
const fn = $.const(symbolCreateQueryKey).assign($.func().param("id", (p) => p.type("string")).param("options", (p) => p.optional().type(TOptionsType$
|
|
8114
|
+
const fn = $.const(symbolCreateQueryKey).assign($.func().param("id", (p) => p.type("string")).param("options", (p) => p.optional().type(TOptionsType$2)).param("tags", (p) => p.optional().type("ReadonlyArray<string>")).returns($.type.tuple(returnType)).generic(TOptionsType$2, (g) => g.extends(symbolOptions)).do($.const("params").type(returnType).assign($.object().prop("_id", "id").prop(baseUrlKey, $("options").attr(baseUrlKey).optional().or($("options").attr("client").optional().$if(symbolClient, (a, v) => a.coalesce(v)).attr("getConfig").call().attr(baseUrlKey))).as(returnType)), $.if("tags").do($("params").attr("tags").assign($("tags").as("unknown").as(symbolJsonValue))), $.if($("options").attr("body").optional().neq($.id("undefined"))).do($.const("normalizedBody").assign($(symbolSerializeQueryValue).call($("options").attr("body"))), $.if($("normalizedBody").neq($.id("undefined"))).do($("params").attr("body").assign("normalizedBody"))), $.if($("options").attr("path").optional()).do($("params").attr("path").assign($("options").attr("path"))), $.if($("options").attr("query").optional().neq($.id("undefined"))).do($.const("normalizedQuery").assign($(symbolSerializeQueryValue).call($("options").attr("query"))), $.if($("normalizedQuery").neq($.id("undefined"))).do($("params").attr("query").assign("normalizedQuery"))), $.return($.array($("params")))));
|
|
8080
8115
|
plugin.node(fn);
|
|
8081
8116
|
};
|
|
8082
8117
|
const createQueryKeyLiteral$1 = ({ id, operation, plugin }) => {
|
|
@@ -8101,7 +8136,7 @@ const createQueryKeyType$1 = ({ plugin }) => {
|
|
|
8101
8136
|
resource: "QueryKey",
|
|
8102
8137
|
tool: plugin.name
|
|
8103
8138
|
} });
|
|
8104
|
-
const queryKeyType = $.type.alias(symbolQueryKeyType).export().generic(TOptionsType$
|
|
8139
|
+
const queryKeyType = $.type.alias(symbolQueryKeyType).export().generic(TOptionsType$2, (g) => g.extends($.type(symbolOptions))).type($.type.tuple($.type.and($.type(`Pick<${TOptionsType$2}, 'path'>`), $.type.object().prop("_id", (p) => p.type("string")).prop(getClientBaseUrlKey(getTypedConfig(plugin)), (p) => p.optional().type(symbolJsonValue)).prop("body", (p) => p.optional().type(symbolJsonValue)).prop("query", (p) => p.optional().type(symbolJsonValue)).prop("tags", (p) => p.optional().type(symbolJsonValue)))));
|
|
8105
8140
|
plugin.node(queryKeyType);
|
|
8106
8141
|
};
|
|
8107
8142
|
const queryKeyStatement$1 = ({ operation, plugin, symbol }) => {
|
|
@@ -8299,8 +8334,8 @@ const useTypeResponse = ({ operation, plugin }) => {
|
|
|
8299
8334
|
};
|
|
8300
8335
|
//#endregion
|
|
8301
8336
|
//#region src/plugins/@tanstack/query-core/queryKey.ts
|
|
8302
|
-
const TOptionsType = "TOptions";
|
|
8303
|
-
|
|
8337
|
+
const TOptionsType$1 = "TOptions";
|
|
8338
|
+
function createQueryKeyFunction({ plugin }) {
|
|
8304
8339
|
const symbolCreateQueryKey = plugin.symbol(applyNaming("createQueryKey", { case: plugin.config.case }), { meta: {
|
|
8305
8340
|
category: "utility",
|
|
8306
8341
|
resource: "createQueryKey",
|
|
@@ -8318,11 +8353,11 @@ const createQueryKeyFunction = ({ plugin }) => {
|
|
|
8318
8353
|
resource: "client-options",
|
|
8319
8354
|
tool: "sdk"
|
|
8320
8355
|
});
|
|
8321
|
-
const returnType = $.type(symbolQueryKeyType).generic(TOptionsType).idx(0);
|
|
8322
|
-
const fn = $.const(symbolCreateQueryKey).assign($.func().param("id", (p) => p.type("string")).param("options", (p) => p.optional().type(TOptionsType)).param("infinite", (p) => p.optional().type("boolean")).param("tags", (p) => p.optional().type("ReadonlyArray<string>")).generic(TOptionsType, (g) => g.extends(symbolOptions)).returns($.type.tuple(returnType)).do($.const("params").type(returnType).assign($.object().prop("_id", "id").prop(baseUrlKey, $("options").attr(baseUrlKey).optional().or($("options").attr("client").optional().$if(symbolClient, (a, v) => a.coalesce(v)).attr("getConfig").call().attr(baseUrlKey))).as(returnType)), $.if("infinite").do($("params").attr("_infinite").assign("infinite")), $.if("tags").do($("params").attr("tags").assign("tags")), $.if($("options").attr("body").optional()).do($("params").attr("body").assign($("options").attr("body"))), $.if($("options").attr("headers").optional()).do($("params").attr("headers").assign($("options").attr("headers"))), $.if($("options").attr("path").optional()).do($("params").attr("path").assign($("options").attr("path"))), $.if($("options").attr("query").optional()).do($("params").attr("query").assign($("options").attr("query"))), $.return($.array().element($("params")))));
|
|
8356
|
+
const returnType = $.type(symbolQueryKeyType).generic(TOptionsType$1).idx(0);
|
|
8357
|
+
const fn = $.const(symbolCreateQueryKey).assign($.func().param("id", (p) => p.type("string")).param("options", (p) => p.optional().type(TOptionsType$1)).param("infinite", (p) => p.optional().type("boolean")).param("tags", (p) => p.optional().type("ReadonlyArray<string>")).generic(TOptionsType$1, (g) => g.extends(symbolOptions)).returns($.type.tuple(returnType)).do($.const("params").type(returnType).assign($.object().prop("_id", "id").prop(baseUrlKey, $("options").attr(baseUrlKey).optional().or($("options").attr("client").optional().$if(symbolClient, (a, v) => a.coalesce(v)).attr("getConfig").call().attr(baseUrlKey))).as(returnType)), $.if("infinite").do($("params").attr("_infinite").assign("infinite")), $.if("tags").do($("params").attr("tags").assign("tags")), $.if($("options").attr("body").optional()).do($("params").attr("body").assign($("options").attr("body"))), $.if($("options").attr("headers").optional()).do($("params").attr("headers").assign($("options").attr("headers"))), $.if($("options").attr("path").optional()).do($("params").attr("path").assign($("options").attr("path"))), $.if($("options").attr("query").optional()).do($("params").attr("query").assign($("options").attr("query"))), $.return($.array().element($("params")))));
|
|
8323
8358
|
plugin.node(fn);
|
|
8324
|
-
}
|
|
8325
|
-
|
|
8359
|
+
}
|
|
8360
|
+
function createQueryKeyLiteral({ id, isInfinite, operation, plugin }) {
|
|
8326
8361
|
const config = isInfinite ? plugin.config.infiniteQueryKeys : plugin.config.queryKeys;
|
|
8327
8362
|
let tagsArray;
|
|
8328
8363
|
if (config.tags && operation.tags && operation.tags.length) tagsArray = $.array().elements(...operation.tags);
|
|
@@ -8331,8 +8366,8 @@ const createQueryKeyLiteral = ({ id, isInfinite, operation, plugin }) => {
|
|
|
8331
8366
|
resource: "createQueryKey",
|
|
8332
8367
|
tool: plugin.name
|
|
8333
8368
|
})).call($.literal(id), "options", isInfinite || tagsArray ? $.literal(Boolean(isInfinite)) : void 0, tagsArray);
|
|
8334
|
-
}
|
|
8335
|
-
|
|
8369
|
+
}
|
|
8370
|
+
function createQueryKeyType({ plugin }) {
|
|
8336
8371
|
const symbolOptions = plugin.referenceSymbol({
|
|
8337
8372
|
category: "type",
|
|
8338
8373
|
resource: "client-options",
|
|
@@ -8343,10 +8378,10 @@ const createQueryKeyType = ({ plugin }) => {
|
|
|
8343
8378
|
resource: "QueryKey",
|
|
8344
8379
|
tool: plugin.name
|
|
8345
8380
|
} });
|
|
8346
|
-
const queryKeyType = $.type.alias(symbolQueryKeyType).export().generic(TOptionsType, (g) => g.extends(symbolOptions)).type($.type.tuple($.type.and($.type(`Pick<${TOptionsType}, '${getClientBaseUrlKey(getTypedConfig(plugin))}' | 'body' | 'headers' | 'path' | 'query'>`), $.type.object().prop("_id", (p) => p.type("string")).prop("_infinite", (p) => p.optional().type("boolean")).prop("tags", (p) => p.optional().type("ReadonlyArray<string>")))));
|
|
8381
|
+
const queryKeyType = $.type.alias(symbolQueryKeyType).export().generic(TOptionsType$1, (g) => g.extends(symbolOptions)).type($.type.tuple($.type.and($.type(`Pick<${TOptionsType$1}, '${getClientBaseUrlKey(getTypedConfig(plugin))}' | 'body' | 'headers' | 'path' | 'query'>`), $.type.object().prop("_id", (p) => p.type("string")).prop("_infinite", (p) => p.optional().type("boolean")).prop("tags", (p) => p.optional().type("ReadonlyArray<string>")))));
|
|
8347
8382
|
plugin.node(queryKeyType);
|
|
8348
|
-
}
|
|
8349
|
-
|
|
8383
|
+
}
|
|
8384
|
+
function queryKeyStatement({ isInfinite, operation, plugin, symbol, typeQueryKey }) {
|
|
8350
8385
|
const typeData = useTypeData({
|
|
8351
8386
|
operation,
|
|
8352
8387
|
plugin
|
|
@@ -8357,7 +8392,7 @@ const queryKeyStatement = ({ isInfinite, operation, plugin, symbol, typeQueryKey
|
|
|
8357
8392
|
operation,
|
|
8358
8393
|
plugin
|
|
8359
8394
|
}).return()));
|
|
8360
|
-
}
|
|
8395
|
+
}
|
|
8361
8396
|
//#endregion
|
|
8362
8397
|
//#region src/plugins/@tanstack/query-core/shared/meta.ts
|
|
8363
8398
|
const handleMeta = (plugin, operation, configPath) => {
|
|
@@ -8450,9 +8485,77 @@ function createInfiniteQueryOptions({ operation, plugin }) {
|
|
|
8450
8485
|
plugin.node(statement);
|
|
8451
8486
|
}
|
|
8452
8487
|
//#endregion
|
|
8488
|
+
//#region src/plugins/@tanstack/query-core/mutationKey.ts
|
|
8489
|
+
const TOptionsType = "TOptions";
|
|
8490
|
+
function createMutationKeyFunction({ plugin }) {
|
|
8491
|
+
const symbolCreateMutationKey = plugin.symbol(applyNaming("createMutationKey", { case: plugin.config.case }), { meta: {
|
|
8492
|
+
category: "utility",
|
|
8493
|
+
resource: "createMutationKey",
|
|
8494
|
+
tool: plugin.name
|
|
8495
|
+
} });
|
|
8496
|
+
const symbolMutationKeyType = plugin.referenceSymbol({
|
|
8497
|
+
category: "type",
|
|
8498
|
+
resource: "MutationKey",
|
|
8499
|
+
tool: plugin.name
|
|
8500
|
+
});
|
|
8501
|
+
const baseUrlKey = getClientBaseUrlKey(getTypedConfig(plugin));
|
|
8502
|
+
const symbolClient = plugin.querySymbol({ category: "client" });
|
|
8503
|
+
const symbolOptions = plugin.referenceSymbol({
|
|
8504
|
+
category: "type",
|
|
8505
|
+
resource: "client-options",
|
|
8506
|
+
tool: "sdk"
|
|
8507
|
+
});
|
|
8508
|
+
const returnType = $.type(symbolMutationKeyType).generic(TOptionsType).idx(0);
|
|
8509
|
+
const fn = $.const(symbolCreateMutationKey).assign($.func().param("id", (p) => p.type("string")).param("options", (p) => p.optional().type(TOptionsType)).param("tags", (p) => p.optional().type("ReadonlyArray<string>")).generic(TOptionsType, (g) => g.extends($.type("Partial").generic(symbolOptions))).returns($.type.tuple(returnType)).do($.const("params").type(returnType).assign($.object().prop("_id", "id").prop(baseUrlKey, $("options").attr(baseUrlKey).optional().or($("options").attr("client").optional().$if(symbolClient, (a, v) => a.coalesce(v)).attr("getConfig").call().attr(baseUrlKey)))), $.if("tags").do($("params").attr("tags").assign("tags")), $.if($("options").attr("body").optional()).do($("params").attr("body").assign($("options").attr("body"))), $.if($("options").attr("headers").optional()).do($("params").attr("headers").assign($("options").attr("headers"))), $.if($("options").attr("path").optional()).do($("params").attr("path").assign($("options").attr("path"))), $.if($("options").attr("query").optional()).do($("params").attr("query").assign($("options").attr("query"))), $.return($.array().element($("params")))));
|
|
8510
|
+
plugin.node(fn);
|
|
8511
|
+
}
|
|
8512
|
+
function createMutationKeyLiteral({ id, operation, plugin }) {
|
|
8513
|
+
const config = plugin.config.mutationKeys;
|
|
8514
|
+
let tagsArray;
|
|
8515
|
+
if (config.tags && operation.tags && operation.tags.length) tagsArray = $.array().elements(...operation.tags);
|
|
8516
|
+
return $(plugin.referenceSymbol({
|
|
8517
|
+
category: "utility",
|
|
8518
|
+
resource: "createMutationKey",
|
|
8519
|
+
tool: plugin.name
|
|
8520
|
+
})).call($.literal(id), "options", tagsArray);
|
|
8521
|
+
}
|
|
8522
|
+
function createMutationKeyType({ plugin }) {
|
|
8523
|
+
const symbolOptions = plugin.referenceSymbol({
|
|
8524
|
+
category: "type",
|
|
8525
|
+
resource: "client-options",
|
|
8526
|
+
tool: "sdk"
|
|
8527
|
+
});
|
|
8528
|
+
const symbolMutationKeyType = plugin.symbol("MutationKey", { meta: {
|
|
8529
|
+
category: "type",
|
|
8530
|
+
resource: "MutationKey",
|
|
8531
|
+
tool: plugin.name
|
|
8532
|
+
} });
|
|
8533
|
+
const mutationKeyType = $.type.alias(symbolMutationKeyType).export().generic(TOptionsType, (g) => g.extends($.type("Partial").generic(symbolOptions))).type($.type.tuple($.type.and($.type(`Pick<${TOptionsType}, '${getClientBaseUrlKey(getTypedConfig(plugin))}' | 'body' | 'headers' | 'path' | 'query'>`), $.type.object().prop("_id", (p) => p.type("string")).prop("tags", (p) => p.optional().type("ReadonlyArray<string>")))));
|
|
8534
|
+
plugin.node(mutationKeyType);
|
|
8535
|
+
}
|
|
8536
|
+
function mutationKeyStatement({ operation, plugin, symbol }) {
|
|
8537
|
+
const typeData = useTypeData({
|
|
8538
|
+
operation,
|
|
8539
|
+
plugin
|
|
8540
|
+
});
|
|
8541
|
+
return $.const(symbol).export().assign($.func().param("options", (p) => p.optional().type($.type("Partial").generic(typeData))).do(createMutationKeyLiteral({
|
|
8542
|
+
id: operation.id,
|
|
8543
|
+
operation,
|
|
8544
|
+
plugin
|
|
8545
|
+
}).return()));
|
|
8546
|
+
}
|
|
8547
|
+
//#endregion
|
|
8453
8548
|
//#region src/plugins/@tanstack/query-core/v5/mutationOptions.ts
|
|
8454
8549
|
function createMutationOptions({ operation, plugin }) {
|
|
8455
8550
|
if (hasOperationSse({ operation })) return;
|
|
8551
|
+
if (plugin.config.mutationKeys.enabled && !plugin.querySymbol({
|
|
8552
|
+
category: "utility",
|
|
8553
|
+
resource: "createMutationKey",
|
|
8554
|
+
tool: plugin.name
|
|
8555
|
+
})) {
|
|
8556
|
+
createMutationKeyType({ plugin });
|
|
8557
|
+
createMutationKeyFunction({ plugin });
|
|
8558
|
+
}
|
|
8456
8559
|
const symbolMutationOptionsType = plugin.external(`${plugin.name}.MutationOptions`);
|
|
8457
8560
|
const typeData = useTypeData({
|
|
8458
8561
|
operation,
|
|
@@ -8474,6 +8577,16 @@ function createMutationOptions({ operation, plugin }) {
|
|
|
8474
8577
|
const statements = [];
|
|
8475
8578
|
if (plugin.getPluginOrThrow("@hey-api/sdk").config.responseStyle === "data") statements.push($.return(awaitSdkFn));
|
|
8476
8579
|
else statements.push($.const().object("data").assign(awaitSdkFn), $.return("data"));
|
|
8580
|
+
let symbolMutationKey;
|
|
8581
|
+
if (plugin.config.mutationKeys.enabled) {
|
|
8582
|
+
symbolMutationKey = plugin.symbol(applyNaming(operation.id, plugin.config.mutationKeys));
|
|
8583
|
+
const node = mutationKeyStatement({
|
|
8584
|
+
operation,
|
|
8585
|
+
plugin,
|
|
8586
|
+
symbol: symbolMutationKey
|
|
8587
|
+
});
|
|
8588
|
+
plugin.node(node);
|
|
8589
|
+
}
|
|
8477
8590
|
const mutationOptionsFn = "mutationOptions";
|
|
8478
8591
|
const symbolMutationOptions = plugin.symbol(applyNaming(operation.id, plugin.config.mutationOptions), { meta: {
|
|
8479
8592
|
category: "hook",
|
|
@@ -8482,7 +8595,7 @@ function createMutationOptions({ operation, plugin }) {
|
|
|
8482
8595
|
role: "mutationOptions",
|
|
8483
8596
|
tool: plugin.name
|
|
8484
8597
|
} });
|
|
8485
|
-
const statement = $.const(symbolMutationOptions).export(plugin.config.mutationOptions.exported).$if(plugin.config.comments && createOperationComment(operation), (c, v) => c.doc(v)).assign($.func().param("options", (p) => p.optional().type($.type("Partial").generic(typeData))).returns(mutationType).do($.const(mutationOptionsFn).type(mutationType).assign($.object().pretty().prop("mutationFn", $.func().async().param(fnOptions).do(...statements)).$if(handleMeta(plugin, operation, "mutationOptions"), (c, v) => c.prop("meta", v))), $(mutationOptionsFn).return()));
|
|
8598
|
+
const statement = $.const(symbolMutationOptions).export(plugin.config.mutationOptions.exported).$if(plugin.config.comments && createOperationComment(operation), (c, v) => c.doc(v)).assign($.func().param("options", (p) => p.optional().type($.type("Partial").generic(typeData))).returns(mutationType).do($.const(mutationOptionsFn).type(mutationType).assign($.object().pretty().prop("mutationFn", $.func().async().param(fnOptions).do(...statements)).$if(symbolMutationKey, (c, v) => c.prop("mutationKey", $(v).call("options"))).$if(handleMeta(plugin, operation, "mutationOptions"), (c, v) => c.prop("meta", v))), $(mutationOptionsFn).return()));
|
|
8486
8599
|
plugin.node(statement);
|
|
8487
8600
|
}
|
|
8488
8601
|
//#endregion
|
|
@@ -8778,6 +8891,16 @@ const defaultConfig$12 = {
|
|
|
8778
8891
|
mappers,
|
|
8779
8892
|
value: plugin.config.infiniteQueryOptions
|
|
8780
8893
|
});
|
|
8894
|
+
plugin.config.mutationKeys = context.valueToObject({
|
|
8895
|
+
defaultValue: {
|
|
8896
|
+
case: plugin.config.case ?? "camelCase",
|
|
8897
|
+
enabled: false,
|
|
8898
|
+
name: "{{name}}MutationKey",
|
|
8899
|
+
tags: false
|
|
8900
|
+
},
|
|
8901
|
+
mappers,
|
|
8902
|
+
value: plugin.config.mutationKeys
|
|
8903
|
+
});
|
|
8781
8904
|
plugin.config.mutationOptions = context.valueToObject({
|
|
8782
8905
|
defaultValue: {
|
|
8783
8906
|
case: plugin.config.case ?? "camelCase",
|
|
@@ -8865,6 +8988,16 @@ const defaultConfig$11 = {
|
|
|
8865
8988
|
mappers,
|
|
8866
8989
|
value: plugin.config.infiniteQueryOptions
|
|
8867
8990
|
});
|
|
8991
|
+
plugin.config.mutationKeys = context.valueToObject({
|
|
8992
|
+
defaultValue: {
|
|
8993
|
+
case: plugin.config.case ?? "camelCase",
|
|
8994
|
+
enabled: false,
|
|
8995
|
+
name: "{{name}}MutationKey",
|
|
8996
|
+
tags: false
|
|
8997
|
+
},
|
|
8998
|
+
mappers,
|
|
8999
|
+
value: plugin.config.mutationKeys
|
|
9000
|
+
});
|
|
8868
9001
|
plugin.config.mutationOptions = context.valueToObject({
|
|
8869
9002
|
defaultValue: {
|
|
8870
9003
|
case: plugin.config.case ?? "camelCase",
|
|
@@ -9033,6 +9166,16 @@ const defaultConfig$10 = {
|
|
|
9033
9166
|
mappers,
|
|
9034
9167
|
value: plugin.config.infiniteQueryOptions
|
|
9035
9168
|
});
|
|
9169
|
+
plugin.config.mutationKeys = context.valueToObject({
|
|
9170
|
+
defaultValue: {
|
|
9171
|
+
case: plugin.config.case ?? "camelCase",
|
|
9172
|
+
enabled: false,
|
|
9173
|
+
name: "{{name}}MutationKey",
|
|
9174
|
+
tags: false
|
|
9175
|
+
},
|
|
9176
|
+
mappers,
|
|
9177
|
+
value: plugin.config.mutationKeys
|
|
9178
|
+
});
|
|
9036
9179
|
plugin.config.mutationOptions = context.valueToObject({
|
|
9037
9180
|
defaultValue: {
|
|
9038
9181
|
case: plugin.config.case ?? "camelCase",
|
|
@@ -9201,6 +9344,16 @@ const defaultConfig$9 = {
|
|
|
9201
9344
|
mappers,
|
|
9202
9345
|
value: plugin.config.infiniteQueryOptions
|
|
9203
9346
|
});
|
|
9347
|
+
plugin.config.mutationKeys = context.valueToObject({
|
|
9348
|
+
defaultValue: {
|
|
9349
|
+
case: plugin.config.case ?? "camelCase",
|
|
9350
|
+
enabled: false,
|
|
9351
|
+
name: "{{name}}MutationKey",
|
|
9352
|
+
tags: false
|
|
9353
|
+
},
|
|
9354
|
+
mappers,
|
|
9355
|
+
value: plugin.config.mutationKeys
|
|
9356
|
+
});
|
|
9204
9357
|
plugin.config.mutationOptions = context.valueToObject({
|
|
9205
9358
|
defaultValue: {
|
|
9206
9359
|
case: plugin.config.case ?? "camelCase",
|
|
@@ -9288,6 +9441,16 @@ const defaultConfig$8 = {
|
|
|
9288
9441
|
mappers,
|
|
9289
9442
|
value: plugin.config.infiniteQueryOptions
|
|
9290
9443
|
});
|
|
9444
|
+
plugin.config.mutationKeys = context.valueToObject({
|
|
9445
|
+
defaultValue: {
|
|
9446
|
+
case: plugin.config.case ?? "camelCase",
|
|
9447
|
+
enabled: false,
|
|
9448
|
+
name: "{{name}}MutationKey",
|
|
9449
|
+
tags: false
|
|
9450
|
+
},
|
|
9451
|
+
mappers,
|
|
9452
|
+
value: plugin.config.mutationKeys
|
|
9453
|
+
});
|
|
9291
9454
|
plugin.config.mutationOptions = context.valueToObject({
|
|
9292
9455
|
defaultValue: {
|
|
9293
9456
|
case: plugin.config.case ?? "camelCase",
|
|
@@ -9375,6 +9538,16 @@ const defaultConfig$7 = {
|
|
|
9375
9538
|
mappers,
|
|
9376
9539
|
value: plugin.config.infiniteQueryOptions
|
|
9377
9540
|
});
|
|
9541
|
+
plugin.config.mutationKeys = context.valueToObject({
|
|
9542
|
+
defaultValue: {
|
|
9543
|
+
case: plugin.config.case ?? "camelCase",
|
|
9544
|
+
enabled: false,
|
|
9545
|
+
name: "{{name}}MutationKey",
|
|
9546
|
+
tags: false
|
|
9547
|
+
},
|
|
9548
|
+
mappers,
|
|
9549
|
+
value: plugin.config.mutationKeys
|
|
9550
|
+
});
|
|
9378
9551
|
plugin.config.mutationOptions = context.valueToObject({
|
|
9379
9552
|
defaultValue: {
|
|
9380
9553
|
case: plugin.config.case ?? "camelCase",
|
|
@@ -11049,6 +11222,7 @@ function createRequestSchemaContext$3(ctx) {
|
|
|
11049
11222
|
empty: emptyNode$3,
|
|
11050
11223
|
optional: optionalNode$3
|
|
11051
11224
|
},
|
|
11225
|
+
path: ref([]),
|
|
11052
11226
|
pipes: {
|
|
11053
11227
|
...pipes,
|
|
11054
11228
|
current: []
|
|
@@ -11104,6 +11278,7 @@ function createResponseValidatorV1({ operation, plugin }) {
|
|
|
11104
11278
|
return runResponseResolver$3({
|
|
11105
11279
|
$,
|
|
11106
11280
|
operation,
|
|
11281
|
+
path: ref([]),
|
|
11107
11282
|
pipes: {
|
|
11108
11283
|
...pipes,
|
|
11109
11284
|
current: []
|
|
@@ -11115,6 +11290,15 @@ function createResponseValidatorV1({ operation, plugin }) {
|
|
|
11115
11290
|
}
|
|
11116
11291
|
});
|
|
11117
11292
|
}
|
|
11293
|
+
function createResponseTransformerV1(ctx) {
|
|
11294
|
+
return createResponseValidatorV1(ctx);
|
|
11295
|
+
}
|
|
11296
|
+
function createResponseHandlersV1(ctx) {
|
|
11297
|
+
return {
|
|
11298
|
+
transformer: createResponseTransformerV1(ctx),
|
|
11299
|
+
validator: void 0
|
|
11300
|
+
};
|
|
11301
|
+
}
|
|
11118
11302
|
//#endregion
|
|
11119
11303
|
//#region src/plugins/valibot/api.ts
|
|
11120
11304
|
var Api$1 = class {
|
|
@@ -11123,13 +11307,19 @@ var Api$1 = class {
|
|
|
11123
11307
|
if (!plugin.config.requests.enabled) return;
|
|
11124
11308
|
return createRequestSchemaV1(ctx);
|
|
11125
11309
|
}
|
|
11126
|
-
createRequestValidator(
|
|
11127
|
-
const { plugin } =
|
|
11310
|
+
createRequestValidator(ctx) {
|
|
11311
|
+
const { plugin } = ctx;
|
|
11128
11312
|
if (!plugin.config.requests.enabled) return;
|
|
11129
|
-
return createRequestValidatorV1(
|
|
11313
|
+
return createRequestValidatorV1(ctx);
|
|
11130
11314
|
}
|
|
11131
|
-
|
|
11132
|
-
return
|
|
11315
|
+
createResponseHandlers(ctx) {
|
|
11316
|
+
return createResponseHandlersV1(ctx);
|
|
11317
|
+
}
|
|
11318
|
+
createResponseTransformer(ctx) {
|
|
11319
|
+
return createResponseTransformerV1(ctx);
|
|
11320
|
+
}
|
|
11321
|
+
createResponseValidator(ctx) {
|
|
11322
|
+
return createResponseValidatorV1(ctx);
|
|
11133
11323
|
}
|
|
11134
11324
|
};
|
|
11135
11325
|
//#endregion
|
|
@@ -11296,10 +11486,11 @@ function unknownResolver$3(ctx) {
|
|
|
11296
11486
|
ctx.pipes.push(ctx.pipes.current, base);
|
|
11297
11487
|
return ctx.pipes.current;
|
|
11298
11488
|
}
|
|
11299
|
-
function unknownToPipes({ plugin, schema }) {
|
|
11489
|
+
function unknownToPipes({ path, plugin, schema }) {
|
|
11300
11490
|
const ctx = {
|
|
11301
11491
|
$,
|
|
11302
11492
|
nodes: { base: baseNode$55 },
|
|
11493
|
+
path,
|
|
11303
11494
|
pipes: {
|
|
11304
11495
|
...pipes,
|
|
11305
11496
|
current: []
|
|
@@ -11315,24 +11506,32 @@ function unknownToPipes({ plugin, schema }) {
|
|
|
11315
11506
|
//#endregion
|
|
11316
11507
|
//#region src/plugins/valibot/v1/toAst/array.ts
|
|
11317
11508
|
function baseNode$54(ctx) {
|
|
11318
|
-
const { plugin, symbols } = ctx;
|
|
11509
|
+
const { applyModifiers, path, pipes, plugin, symbols, walk } = ctx;
|
|
11319
11510
|
const { v } = symbols;
|
|
11320
11511
|
const arrayFn = $(v).attr(identifiers$1.schemas.array);
|
|
11321
11512
|
let { schema: normalizedSchema } = ctx;
|
|
11322
11513
|
if (normalizedSchema.items) normalizedSchema = deduplicateSchema({ schema: normalizedSchema });
|
|
11323
|
-
if (!normalizedSchema.items) return arrayFn.call(unknownToPipes({
|
|
11514
|
+
if (!normalizedSchema.items) return arrayFn.call(unknownToPipes({
|
|
11515
|
+
path,
|
|
11516
|
+
plugin
|
|
11517
|
+
}));
|
|
11324
11518
|
const childResults = [];
|
|
11325
|
-
const { applyModifiers, pipes, walk, walkerCtx } = ctx;
|
|
11326
11519
|
for (let i = 0; i < normalizedSchema.items.length; i++) {
|
|
11327
11520
|
const item = normalizedSchema.items[i];
|
|
11328
|
-
const result = walk(item, childContext(
|
|
11521
|
+
const result = walk(item, childContext({
|
|
11522
|
+
path,
|
|
11523
|
+
plugin
|
|
11524
|
+
}, "items", i));
|
|
11329
11525
|
childResults.push(result);
|
|
11330
11526
|
}
|
|
11331
11527
|
if (childResults.length === 1) {
|
|
11332
11528
|
const itemNode = pipes.toNode(applyModifiers(childResults[0]).pipes, plugin);
|
|
11333
11529
|
return arrayFn.call(itemNode);
|
|
11334
11530
|
}
|
|
11335
|
-
return arrayFn.call(unknownToPipes({
|
|
11531
|
+
return arrayFn.call(unknownToPipes({
|
|
11532
|
+
path,
|
|
11533
|
+
plugin
|
|
11534
|
+
}));
|
|
11336
11535
|
}
|
|
11337
11536
|
function lengthNode$7(ctx) {
|
|
11338
11537
|
const { schema, symbols } = ctx;
|
|
@@ -11365,13 +11564,16 @@ function arrayResolver$3(ctx) {
|
|
|
11365
11564
|
return ctx.pipes.current;
|
|
11366
11565
|
}
|
|
11367
11566
|
function arrayToPipes(ctx) {
|
|
11368
|
-
const { plugin, schema, walk
|
|
11567
|
+
const { path, plugin, schema, walk } = ctx;
|
|
11369
11568
|
const childResults = [];
|
|
11370
11569
|
if (schema.items) {
|
|
11371
11570
|
const normalizedSchema = deduplicateSchema({ schema });
|
|
11372
11571
|
for (let i = 0; i < normalizedSchema.items.length; i++) {
|
|
11373
11572
|
const item = normalizedSchema.items[i];
|
|
11374
|
-
const result = walk(item, childContext(
|
|
11573
|
+
const result = walk(item, childContext({
|
|
11574
|
+
path,
|
|
11575
|
+
plugin
|
|
11576
|
+
}, "items", i));
|
|
11375
11577
|
childResults.push(result);
|
|
11376
11578
|
}
|
|
11377
11579
|
}
|
|
@@ -11384,6 +11586,7 @@ function arrayToPipes(ctx) {
|
|
|
11384
11586
|
maxLength: maxLengthNode$7,
|
|
11385
11587
|
minLength: minLengthNode$7
|
|
11386
11588
|
},
|
|
11589
|
+
path,
|
|
11387
11590
|
pipes: {
|
|
11388
11591
|
...pipes,
|
|
11389
11592
|
current: []
|
|
@@ -11391,8 +11594,7 @@ function arrayToPipes(ctx) {
|
|
|
11391
11594
|
plugin,
|
|
11392
11595
|
schema,
|
|
11393
11596
|
symbols: { v: plugin.external("valibot.v") },
|
|
11394
|
-
walk
|
|
11395
|
-
walkerCtx
|
|
11597
|
+
walk
|
|
11396
11598
|
};
|
|
11397
11599
|
const resolver = plugin.config["~resolvers"]?.array;
|
|
11398
11600
|
const node = resolver?.(resolverCtx) ?? arrayResolver$3(resolverCtx);
|
|
@@ -11421,13 +11623,14 @@ function booleanResolver$3(ctx) {
|
|
|
11421
11623
|
if (baseResult) ctx.pipes.push(ctx.pipes.current, baseResult);
|
|
11422
11624
|
return ctx.pipes.current;
|
|
11423
11625
|
}
|
|
11424
|
-
function booleanToPipes({ plugin, schema }) {
|
|
11626
|
+
function booleanToPipes({ path, plugin, schema }) {
|
|
11425
11627
|
const ctx = {
|
|
11426
11628
|
$,
|
|
11427
11629
|
nodes: {
|
|
11428
11630
|
base: baseNode$53,
|
|
11429
11631
|
const: constNode$15
|
|
11430
11632
|
},
|
|
11633
|
+
path,
|
|
11431
11634
|
pipes: {
|
|
11432
11635
|
...pipes,
|
|
11433
11636
|
current: []
|
|
@@ -11445,53 +11648,48 @@ function booleanToPipes({ plugin, schema }) {
|
|
|
11445
11648
|
function itemsNode$3(ctx) {
|
|
11446
11649
|
const { schema } = ctx;
|
|
11447
11650
|
const enumMembers = [];
|
|
11448
|
-
|
|
11449
|
-
|
|
11450
|
-
|
|
11451
|
-
|
|
11452
|
-
|
|
11453
|
-
|
|
11454
|
-
}
|
|
11651
|
+
for (const item of schema.items ?? []) if (item.type === "string" && typeof item.const === "string") {
|
|
11652
|
+
const literal = $.literal(item.const);
|
|
11653
|
+
enumMembers.push(literal);
|
|
11654
|
+
} else if ((item.type === "number" || item.type === "integer") && typeof item.const === "number") {
|
|
11655
|
+
const literal = $.literal(item.const);
|
|
11656
|
+
enumMembers.push(literal);
|
|
11657
|
+
} else if (item.type === "boolean" && typeof item.const === "boolean") {
|
|
11658
|
+
const literal = $.literal(item.const);
|
|
11659
|
+
enumMembers.push(literal);
|
|
11660
|
+
}
|
|
11661
|
+
return { enumMembers };
|
|
11455
11662
|
}
|
|
11456
11663
|
function baseNode$52(ctx) {
|
|
11664
|
+
const { enumMembers } = ctx.nodes.items(ctx);
|
|
11665
|
+
if (!enumMembers.length) return unknownToPipes({
|
|
11666
|
+
path: ctx.path,
|
|
11667
|
+
plugin: ctx.plugin
|
|
11668
|
+
});
|
|
11457
11669
|
const { symbols } = ctx;
|
|
11458
11670
|
const { v } = symbols;
|
|
11459
|
-
const
|
|
11671
|
+
const def = ctx.plugin.querySymbols({
|
|
11672
|
+
resource: "definition",
|
|
11673
|
+
resourceId: pathToJsonPointer(fromRef(ctx.path)),
|
|
11674
|
+
tool: "typescript"
|
|
11675
|
+
}).filter((symbol) => symbol.kind === "var" || symbol.kind === "enum" && !symbol.node.hasModifier("const"))[0];
|
|
11676
|
+
if (def) return $(v).attr(identifiers$1.schemas.enum).call(def);
|
|
11460
11677
|
return $(v).attr(identifiers$1.schemas.picklist).call($.array(...enumMembers));
|
|
11461
11678
|
}
|
|
11462
11679
|
function enumResolver$3(ctx) {
|
|
11463
|
-
const { enumMembers } = ctx.nodes.items(ctx);
|
|
11464
|
-
if (!enumMembers.length) return ctx.pipes.current;
|
|
11465
11680
|
const baseExpression = ctx.nodes.base(ctx);
|
|
11466
11681
|
ctx.pipes.push(ctx.pipes.current, baseExpression);
|
|
11467
11682
|
return ctx.pipes.current;
|
|
11468
11683
|
}
|
|
11469
|
-
function enumToPipes({ plugin, schema }) {
|
|
11684
|
+
function enumToPipes({ path, plugin, schema }) {
|
|
11470
11685
|
const v = plugin.external("valibot.v");
|
|
11471
|
-
const { enumMembers, isNullable } = itemsNode$3({
|
|
11472
|
-
$,
|
|
11473
|
-
nodes: {
|
|
11474
|
-
base: baseNode$52,
|
|
11475
|
-
items: itemsNode$3
|
|
11476
|
-
},
|
|
11477
|
-
pipes: {
|
|
11478
|
-
...pipes,
|
|
11479
|
-
current: []
|
|
11480
|
-
},
|
|
11481
|
-
plugin,
|
|
11482
|
-
schema,
|
|
11483
|
-
symbols: { v }
|
|
11484
|
-
});
|
|
11485
|
-
if (!enumMembers.length) return {
|
|
11486
|
-
isNullable,
|
|
11487
|
-
pipe: unknownToPipes({ plugin })
|
|
11488
|
-
};
|
|
11489
11686
|
const ctx = {
|
|
11490
11687
|
$,
|
|
11491
11688
|
nodes: {
|
|
11492
11689
|
base: baseNode$52,
|
|
11493
11690
|
items: itemsNode$3
|
|
11494
11691
|
},
|
|
11692
|
+
path,
|
|
11495
11693
|
pipes: {
|
|
11496
11694
|
...pipes,
|
|
11497
11695
|
current: []
|
|
@@ -11502,10 +11700,7 @@ function enumToPipes({ plugin, schema }) {
|
|
|
11502
11700
|
};
|
|
11503
11701
|
const resolver = plugin.config["~resolvers"]?.enum;
|
|
11504
11702
|
const node = resolver?.(ctx) ?? enumResolver$3(ctx);
|
|
11505
|
-
return
|
|
11506
|
-
isNullable,
|
|
11507
|
-
pipe: ctx.pipes.toNode(node, plugin)
|
|
11508
|
-
};
|
|
11703
|
+
return ctx.pipes.toNode(node, plugin);
|
|
11509
11704
|
}
|
|
11510
11705
|
//#endregion
|
|
11511
11706
|
//#region src/plugins/valibot/v1/toAst/intersection.ts
|
|
@@ -11522,14 +11717,14 @@ function intersectionResolver$3(ctx) {
|
|
|
11522
11717
|
if (base) ctx.pipes.push(ctx.pipes.current, base);
|
|
11523
11718
|
return ctx.pipes.current;
|
|
11524
11719
|
}
|
|
11525
|
-
function intersectionToPipes(
|
|
11526
|
-
const { applyModifiers, childResults, parentSchema, plugin } = ctx;
|
|
11720
|
+
function intersectionToPipes({ applyModifiers, childResults, parentSchema, path, plugin }) {
|
|
11527
11721
|
const resolverCtx = {
|
|
11528
11722
|
$,
|
|
11529
11723
|
applyModifiers,
|
|
11530
11724
|
childResults,
|
|
11531
11725
|
nodes: { base: baseNode$51 },
|
|
11532
11726
|
parentSchema,
|
|
11727
|
+
path,
|
|
11533
11728
|
pipes: {
|
|
11534
11729
|
...pipes,
|
|
11535
11730
|
current: []
|
|
@@ -11557,10 +11752,11 @@ function neverResolver$3(ctx) {
|
|
|
11557
11752
|
ctx.pipes.push(ctx.pipes.current, base);
|
|
11558
11753
|
return ctx.pipes.current;
|
|
11559
11754
|
}
|
|
11560
|
-
function neverToPipes({ plugin, schema }) {
|
|
11755
|
+
function neverToPipes({ path, plugin, schema }) {
|
|
11561
11756
|
const ctx = {
|
|
11562
11757
|
$,
|
|
11563
11758
|
nodes: { base: baseNode$50 },
|
|
11759
|
+
path,
|
|
11564
11760
|
pipes: {
|
|
11565
11761
|
...pipes,
|
|
11566
11762
|
current: []
|
|
@@ -11585,10 +11781,11 @@ function nullResolver$3(ctx) {
|
|
|
11585
11781
|
ctx.pipes.push(ctx.pipes.current, base);
|
|
11586
11782
|
return ctx.pipes.current;
|
|
11587
11783
|
}
|
|
11588
|
-
function nullToPipes({ plugin, schema }) {
|
|
11784
|
+
function nullToPipes({ path, plugin, schema }) {
|
|
11589
11785
|
const ctx = {
|
|
11590
11786
|
$,
|
|
11591
11787
|
nodes: { base: baseNode$49 },
|
|
11788
|
+
path,
|
|
11592
11789
|
pipes: {
|
|
11593
11790
|
...pipes,
|
|
11594
11791
|
current: []
|
|
@@ -11672,7 +11869,7 @@ function numberResolver$3(ctx) {
|
|
|
11672
11869
|
if (maxResult) ctx.pipes.push(ctx.pipes.current, maxResult);
|
|
11673
11870
|
return ctx.pipes.current;
|
|
11674
11871
|
}
|
|
11675
|
-
function numberToPipes({ plugin, schema }) {
|
|
11872
|
+
function numberToPipes({ path, plugin, schema }) {
|
|
11676
11873
|
const ctx = {
|
|
11677
11874
|
$,
|
|
11678
11875
|
nodes: {
|
|
@@ -11681,6 +11878,7 @@ function numberToPipes({ plugin, schema }) {
|
|
|
11681
11878
|
max: maxNode$3,
|
|
11682
11879
|
min: minNode$3
|
|
11683
11880
|
},
|
|
11881
|
+
path,
|
|
11684
11882
|
pipes: {
|
|
11685
11883
|
...pipes,
|
|
11686
11884
|
current: []
|
|
@@ -11701,10 +11899,13 @@ function numberToPipes({ plugin, schema }) {
|
|
|
11701
11899
|
//#endregion
|
|
11702
11900
|
//#region src/plugins/valibot/v1/toAst/object.ts
|
|
11703
11901
|
function additionalPropertiesNode$3(ctx) {
|
|
11704
|
-
const { pipes, schema } = ctx;
|
|
11902
|
+
const { path, pipes, plugin, schema } = ctx;
|
|
11705
11903
|
if (!schema.additionalProperties || !schema.additionalProperties.type) return;
|
|
11706
11904
|
if (schema.additionalProperties.type === "never") return null;
|
|
11707
|
-
const additionalResult = ctx.walk(schema.additionalProperties, childContext(
|
|
11905
|
+
const additionalResult = ctx.walk(schema.additionalProperties, childContext({
|
|
11906
|
+
path,
|
|
11907
|
+
plugin
|
|
11908
|
+
}, "additionalProperties"));
|
|
11708
11909
|
ctx._childResults.push(additionalResult);
|
|
11709
11910
|
return pipes.toNode(additionalResult.pipes, ctx.plugin);
|
|
11710
11911
|
}
|
|
@@ -11723,12 +11924,15 @@ function objectResolver$3(ctx) {
|
|
|
11723
11924
|
return ctx.nodes.base(ctx);
|
|
11724
11925
|
}
|
|
11725
11926
|
function shapeNode$3(ctx) {
|
|
11726
|
-
const { pipes, schema } = ctx;
|
|
11927
|
+
const { path, pipes, plugin, schema } = ctx;
|
|
11727
11928
|
const shape = $.object().pretty();
|
|
11728
11929
|
for (const name in schema.properties) {
|
|
11729
11930
|
const property = schema.properties[name];
|
|
11730
11931
|
const isOptional = !schema.required?.includes(name);
|
|
11731
|
-
const propertyResult = ctx.walk(property, childContext(
|
|
11932
|
+
const propertyResult = ctx.walk(property, childContext({
|
|
11933
|
+
path,
|
|
11934
|
+
plugin
|
|
11935
|
+
}, "properties", name));
|
|
11732
11936
|
ctx._childResults.push(propertyResult);
|
|
11733
11937
|
const finalExpr = ctx.applyModifiers(propertyResult, { optional: isOptional });
|
|
11734
11938
|
shape.prop(name, pipes.toNode(finalExpr.pipes, ctx.plugin));
|
|
@@ -11736,7 +11940,7 @@ function shapeNode$3(ctx) {
|
|
|
11736
11940
|
return shape;
|
|
11737
11941
|
}
|
|
11738
11942
|
function objectToPipes(ctx) {
|
|
11739
|
-
const { applyModifiers, plugin, schema, walk
|
|
11943
|
+
const { applyModifiers, path, plugin, schema, walk } = ctx;
|
|
11740
11944
|
const childResults = [];
|
|
11741
11945
|
const resolverCtx = {
|
|
11742
11946
|
$,
|
|
@@ -11747,6 +11951,7 @@ function objectToPipes(ctx) {
|
|
|
11747
11951
|
base: baseNode$47,
|
|
11748
11952
|
shape: shapeNode$3
|
|
11749
11953
|
},
|
|
11954
|
+
path,
|
|
11750
11955
|
pipes: {
|
|
11751
11956
|
...pipes,
|
|
11752
11957
|
current: []
|
|
@@ -11754,8 +11959,7 @@ function objectToPipes(ctx) {
|
|
|
11754
11959
|
plugin,
|
|
11755
11960
|
schema,
|
|
11756
11961
|
symbols: { v: plugin.external("valibot.v") },
|
|
11757
|
-
walk
|
|
11758
|
-
walkerCtx
|
|
11962
|
+
walk
|
|
11759
11963
|
};
|
|
11760
11964
|
const resolver = plugin.config["~resolvers"]?.object;
|
|
11761
11965
|
const node = resolver?.(resolverCtx) ?? objectResolver$3(resolverCtx);
|
|
@@ -11834,8 +12038,9 @@ function stringResolver$3(ctx) {
|
|
|
11834
12038
|
if (patternNode) ctx.pipes.push(ctx.pipes.current, patternNode);
|
|
11835
12039
|
return ctx.pipes.current;
|
|
11836
12040
|
}
|
|
11837
|
-
function stringToPipes({ plugin, schema }) {
|
|
12041
|
+
function stringToPipes({ path, plugin, schema }) {
|
|
11838
12042
|
if (shouldCoerceToBigInt(schema.format)) return numberToPipes({
|
|
12043
|
+
path,
|
|
11839
12044
|
plugin,
|
|
11840
12045
|
schema: {
|
|
11841
12046
|
...schema,
|
|
@@ -11853,6 +12058,7 @@ function stringToPipes({ plugin, schema }) {
|
|
|
11853
12058
|
minLength: minLengthNode$6,
|
|
11854
12059
|
pattern: patternNode$3
|
|
11855
12060
|
},
|
|
12061
|
+
path,
|
|
11856
12062
|
pipes: {
|
|
11857
12063
|
...pipes,
|
|
11858
12064
|
current: []
|
|
@@ -11868,13 +12074,19 @@ function stringToPipes({ plugin, schema }) {
|
|
|
11868
12074
|
//#endregion
|
|
11869
12075
|
//#region src/plugins/valibot/v1/toAst/tuple.ts
|
|
11870
12076
|
function baseNode$45(ctx) {
|
|
11871
|
-
const { applyModifiers, pipes, plugin, schema, symbols, walk
|
|
11872
|
-
if (!schema.items) return unknownToPipes({
|
|
12077
|
+
const { applyModifiers, path, pipes, plugin, schema, symbols, walk } = ctx;
|
|
12078
|
+
if (!schema.items) return unknownToPipes({
|
|
12079
|
+
path,
|
|
12080
|
+
plugin
|
|
12081
|
+
});
|
|
11873
12082
|
const { v } = symbols;
|
|
11874
12083
|
const childResults = [];
|
|
11875
12084
|
for (let i = 0; i < schema.items.length; i++) {
|
|
11876
12085
|
const item = schema.items[i];
|
|
11877
|
-
const result = walk(item, childContext(
|
|
12086
|
+
const result = walk(item, childContext({
|
|
12087
|
+
path,
|
|
12088
|
+
plugin
|
|
12089
|
+
}, "items", i));
|
|
11878
12090
|
childResults.push(result);
|
|
11879
12091
|
}
|
|
11880
12092
|
const tupleElements = childResults.map((r) => pipes.toNode(applyModifiers(r).pipes, plugin));
|
|
@@ -11895,11 +12107,14 @@ function tupleResolver$3(ctx) {
|
|
|
11895
12107
|
return ctx.pipes.current;
|
|
11896
12108
|
}
|
|
11897
12109
|
function tupleToPipes(ctx) {
|
|
11898
|
-
const { plugin, schema, walk
|
|
12110
|
+
const { path, plugin, schema, walk } = ctx;
|
|
11899
12111
|
const childResults = [];
|
|
11900
12112
|
if (schema.items) for (let i = 0; i < schema.items.length; i++) {
|
|
11901
12113
|
const item = schema.items[i];
|
|
11902
|
-
const result = walk(item, childContext(
|
|
12114
|
+
const result = walk(item, childContext({
|
|
12115
|
+
path,
|
|
12116
|
+
plugin
|
|
12117
|
+
}, "items", i));
|
|
11903
12118
|
childResults.push(result);
|
|
11904
12119
|
}
|
|
11905
12120
|
const resolverCtx = {
|
|
@@ -11909,6 +12124,7 @@ function tupleToPipes(ctx) {
|
|
|
11909
12124
|
base: baseNode$45,
|
|
11910
12125
|
const: constNode$12
|
|
11911
12126
|
},
|
|
12127
|
+
path,
|
|
11912
12128
|
pipes: {
|
|
11913
12129
|
...pipes,
|
|
11914
12130
|
current: []
|
|
@@ -11916,8 +12132,7 @@ function tupleToPipes(ctx) {
|
|
|
11916
12132
|
plugin,
|
|
11917
12133
|
schema,
|
|
11918
12134
|
symbols: { v: plugin.external("valibot.v") },
|
|
11919
|
-
walk
|
|
11920
|
-
walkerCtx
|
|
12135
|
+
walk
|
|
11921
12136
|
};
|
|
11922
12137
|
const resolver = plugin.config["~resolvers"]?.tuple;
|
|
11923
12138
|
const node = resolver?.(resolverCtx) ?? tupleResolver$3(resolverCtx);
|
|
@@ -11938,10 +12153,11 @@ function undefinedResolver$3(ctx) {
|
|
|
11938
12153
|
ctx.pipes.push(ctx.pipes.current, base);
|
|
11939
12154
|
return ctx.pipes.current;
|
|
11940
12155
|
}
|
|
11941
|
-
function undefinedToPipes({ plugin, schema }) {
|
|
12156
|
+
function undefinedToPipes({ path, plugin, schema }) {
|
|
11942
12157
|
const ctx = {
|
|
11943
12158
|
$,
|
|
11944
12159
|
nodes: { base: baseNode$44 },
|
|
12160
|
+
path,
|
|
11945
12161
|
pipes: {
|
|
11946
12162
|
...pipes,
|
|
11947
12163
|
current: []
|
|
@@ -11996,14 +12212,14 @@ function unionResolver$3(ctx) {
|
|
|
11996
12212
|
if (base) ctx.pipes.push(ctx.pipes.current, base);
|
|
11997
12213
|
return ctx.pipes.current;
|
|
11998
12214
|
}
|
|
11999
|
-
function unionToPipes(
|
|
12000
|
-
const { applyModifiers, childResults, parentSchema, plugin, schemas } = ctx;
|
|
12215
|
+
function unionToPipes({ applyModifiers, childResults, parentSchema, path, plugin, schemas }) {
|
|
12001
12216
|
const resolverCtx = {
|
|
12002
12217
|
$,
|
|
12003
12218
|
applyModifiers,
|
|
12004
12219
|
childResults,
|
|
12005
12220
|
nodes: { base: baseNode$43 },
|
|
12006
12221
|
parentSchema,
|
|
12222
|
+
path,
|
|
12007
12223
|
pipes: {
|
|
12008
12224
|
...pipes,
|
|
12009
12225
|
current: []
|
|
@@ -12032,10 +12248,11 @@ function voidResolver$3(ctx) {
|
|
|
12032
12248
|
ctx.pipes.push(ctx.pipes.current, base);
|
|
12033
12249
|
return ctx.pipes.current;
|
|
12034
12250
|
}
|
|
12035
|
-
function voidToPipes({ plugin, schema }) {
|
|
12251
|
+
function voidToPipes({ path, plugin, schema }) {
|
|
12036
12252
|
const ctx = {
|
|
12037
12253
|
$,
|
|
12038
12254
|
nodes: { base: baseNode$42 },
|
|
12255
|
+
path,
|
|
12039
12256
|
pipes: {
|
|
12040
12257
|
...pipes,
|
|
12041
12258
|
current: []
|
|
@@ -12049,7 +12266,7 @@ function voidToPipes({ plugin, schema }) {
|
|
|
12049
12266
|
return ctx.pipes.toNode(node, plugin);
|
|
12050
12267
|
}
|
|
12051
12268
|
//#endregion
|
|
12052
|
-
//#region src/plugins/valibot/v1/
|
|
12269
|
+
//#region src/plugins/valibot/v1/visitor.ts
|
|
12053
12270
|
function getDefaultValue$3(meta) {
|
|
12054
12271
|
return meta.format ? maybeBigInt(meta.default, meta.format) : $.fromValue(meta.default);
|
|
12055
12272
|
}
|
|
@@ -12081,10 +12298,10 @@ function createVisitor$3(config = {}) {
|
|
|
12081
12298
|
const applyModifiers = (result, opts) => this.applyModifiers(result, ctx, opts);
|
|
12082
12299
|
const { childResults, pipes } = arrayToPipes({
|
|
12083
12300
|
applyModifiers,
|
|
12301
|
+
path: ctx.path,
|
|
12084
12302
|
plugin: ctx.plugin,
|
|
12085
12303
|
schema,
|
|
12086
|
-
walk
|
|
12087
|
-
walkerCtx: ctx
|
|
12304
|
+
walk
|
|
12088
12305
|
});
|
|
12089
12306
|
return {
|
|
12090
12307
|
meta: inheritMeta$1(schema, childResults),
|
|
@@ -12093,6 +12310,7 @@ function createVisitor$3(config = {}) {
|
|
|
12093
12310
|
},
|
|
12094
12311
|
boolean(schema, ctx) {
|
|
12095
12312
|
const pipe = booleanToPipes({
|
|
12313
|
+
path: ctx.path,
|
|
12096
12314
|
plugin: ctx.plugin,
|
|
12097
12315
|
schema
|
|
12098
12316
|
});
|
|
@@ -12102,10 +12320,12 @@ function createVisitor$3(config = {}) {
|
|
|
12102
12320
|
};
|
|
12103
12321
|
},
|
|
12104
12322
|
enum(schema, ctx) {
|
|
12105
|
-
const
|
|
12323
|
+
const pipe = enumToPipes({
|
|
12324
|
+
path: ctx.path,
|
|
12106
12325
|
plugin: ctx.plugin,
|
|
12107
12326
|
schema
|
|
12108
12327
|
});
|
|
12328
|
+
const isNullable = schema.items?.some((item) => item.type === "null" || item.const === null) ?? false;
|
|
12109
12329
|
return {
|
|
12110
12330
|
meta: {
|
|
12111
12331
|
...defaultMeta$1(schema),
|
|
@@ -12116,6 +12336,7 @@ function createVisitor$3(config = {}) {
|
|
|
12116
12336
|
},
|
|
12117
12337
|
integer(schema, ctx) {
|
|
12118
12338
|
const pipe = numberToPipes({
|
|
12339
|
+
path: ctx.path,
|
|
12119
12340
|
plugin: ctx.plugin,
|
|
12120
12341
|
schema
|
|
12121
12342
|
});
|
|
@@ -12149,6 +12370,7 @@ function createVisitor$3(config = {}) {
|
|
|
12149
12370
|
applyModifiers,
|
|
12150
12371
|
childResults: items,
|
|
12151
12372
|
parentSchema,
|
|
12373
|
+
path: ctx.path,
|
|
12152
12374
|
plugin: ctx.plugin
|
|
12153
12375
|
});
|
|
12154
12376
|
return {
|
|
@@ -12158,6 +12380,7 @@ function createVisitor$3(config = {}) {
|
|
|
12158
12380
|
},
|
|
12159
12381
|
never(schema, ctx) {
|
|
12160
12382
|
const pipe = neverToPipes({
|
|
12383
|
+
path: ctx.path,
|
|
12161
12384
|
plugin: ctx.plugin,
|
|
12162
12385
|
schema
|
|
12163
12386
|
});
|
|
@@ -12172,6 +12395,7 @@ function createVisitor$3(config = {}) {
|
|
|
12172
12395
|
},
|
|
12173
12396
|
null(schema, ctx) {
|
|
12174
12397
|
const pipe = nullToPipes({
|
|
12398
|
+
path: ctx.path,
|
|
12175
12399
|
plugin: ctx.plugin,
|
|
12176
12400
|
schema
|
|
12177
12401
|
});
|
|
@@ -12186,6 +12410,7 @@ function createVisitor$3(config = {}) {
|
|
|
12186
12410
|
},
|
|
12187
12411
|
number(schema, ctx) {
|
|
12188
12412
|
const pipe = numberToPipes({
|
|
12413
|
+
path: ctx.path,
|
|
12189
12414
|
plugin: ctx.plugin,
|
|
12190
12415
|
schema
|
|
12191
12416
|
});
|
|
@@ -12198,10 +12423,10 @@ function createVisitor$3(config = {}) {
|
|
|
12198
12423
|
const applyModifiers = (result, opts) => this.applyModifiers(result, ctx, opts);
|
|
12199
12424
|
const { childResults, pipes } = objectToPipes({
|
|
12200
12425
|
applyModifiers,
|
|
12426
|
+
path: ctx.path,
|
|
12201
12427
|
plugin: ctx.plugin,
|
|
12202
12428
|
schema,
|
|
12203
|
-
walk
|
|
12204
|
-
walkerCtx: ctx
|
|
12429
|
+
walk
|
|
12205
12430
|
});
|
|
12206
12431
|
return {
|
|
12207
12432
|
meta: inheritMeta$1(schema, childResults),
|
|
@@ -12248,6 +12473,7 @@ function createVisitor$3(config = {}) {
|
|
|
12248
12473
|
},
|
|
12249
12474
|
string(schema, ctx) {
|
|
12250
12475
|
const pipe = stringToPipes({
|
|
12476
|
+
path: ctx.path,
|
|
12251
12477
|
plugin: ctx.plugin,
|
|
12252
12478
|
schema
|
|
12253
12479
|
});
|
|
@@ -12260,10 +12486,10 @@ function createVisitor$3(config = {}) {
|
|
|
12260
12486
|
const applyModifiers = (result, opts) => this.applyModifiers(result, ctx, opts);
|
|
12261
12487
|
const { childResults, pipes } = tupleToPipes({
|
|
12262
12488
|
applyModifiers,
|
|
12489
|
+
path: ctx.path,
|
|
12263
12490
|
plugin: ctx.plugin,
|
|
12264
12491
|
schema,
|
|
12265
|
-
walk
|
|
12266
|
-
walkerCtx: ctx
|
|
12492
|
+
walk
|
|
12267
12493
|
});
|
|
12268
12494
|
return {
|
|
12269
12495
|
meta: inheritMeta$1(schema, childResults),
|
|
@@ -12272,6 +12498,7 @@ function createVisitor$3(config = {}) {
|
|
|
12272
12498
|
},
|
|
12273
12499
|
undefined(schema, ctx) {
|
|
12274
12500
|
const pipe = undefinedToPipes({
|
|
12501
|
+
path: ctx.path,
|
|
12275
12502
|
plugin: ctx.plugin,
|
|
12276
12503
|
schema
|
|
12277
12504
|
});
|
|
@@ -12291,6 +12518,7 @@ function createVisitor$3(config = {}) {
|
|
|
12291
12518
|
applyModifiers,
|
|
12292
12519
|
childResults: items,
|
|
12293
12520
|
parentSchema,
|
|
12521
|
+
path: ctx.path,
|
|
12294
12522
|
plugin: ctx.plugin,
|
|
12295
12523
|
schemas
|
|
12296
12524
|
});
|
|
@@ -12303,7 +12531,10 @@ function createVisitor$3(config = {}) {
|
|
|
12303
12531
|
};
|
|
12304
12532
|
},
|
|
12305
12533
|
unknown(schema, ctx) {
|
|
12306
|
-
const pipe = unknownToPipes({
|
|
12534
|
+
const pipe = unknownToPipes({
|
|
12535
|
+
path: ctx.path,
|
|
12536
|
+
plugin: ctx.plugin
|
|
12537
|
+
});
|
|
12307
12538
|
return {
|
|
12308
12539
|
meta: {
|
|
12309
12540
|
...defaultMeta$1(schema),
|
|
@@ -12315,6 +12546,7 @@ function createVisitor$3(config = {}) {
|
|
|
12315
12546
|
},
|
|
12316
12547
|
void(schema, ctx) {
|
|
12317
12548
|
const pipe = voidToPipes({
|
|
12549
|
+
path: ctx.path,
|
|
12318
12550
|
plugin: ctx.plugin,
|
|
12319
12551
|
schema
|
|
12320
12552
|
});
|
|
@@ -12545,7 +12777,7 @@ const defaultConfig$1 = {
|
|
|
12545
12777
|
value: plugin.config.webhooks
|
|
12546
12778
|
});
|
|
12547
12779
|
},
|
|
12548
|
-
tags: ["validator"]
|
|
12780
|
+
tags: ["transformer", "validator"]
|
|
12549
12781
|
};
|
|
12550
12782
|
definePluginConfig(defaultConfig$1);
|
|
12551
12783
|
//#endregion
|
|
@@ -12593,6 +12825,7 @@ const identifiers = {
|
|
|
12593
12825
|
min: "min",
|
|
12594
12826
|
minLength: "minLength",
|
|
12595
12827
|
minimum: "minimum",
|
|
12828
|
+
nativeEnum: "nativeEnum",
|
|
12596
12829
|
never: "never",
|
|
12597
12830
|
null: "null",
|
|
12598
12831
|
nullable: "nullable",
|
|
@@ -12851,6 +13084,7 @@ function createRequestSchemaContext$2(ctx) {
|
|
|
12851
13084
|
empty: emptyNode$2,
|
|
12852
13085
|
optional: optionalNode$2
|
|
12853
13086
|
},
|
|
13087
|
+
path: ref([]),
|
|
12854
13088
|
symbols: {
|
|
12855
13089
|
schema: $(""),
|
|
12856
13090
|
z
|
|
@@ -12903,6 +13137,7 @@ function createResponseValidatorMini({ operation, plugin }) {
|
|
|
12903
13137
|
$,
|
|
12904
13138
|
chain: { current: $(z) },
|
|
12905
13139
|
operation,
|
|
13140
|
+
path: ref([]),
|
|
12906
13141
|
plugin,
|
|
12907
13142
|
symbols: {
|
|
12908
13143
|
schema: symbol,
|
|
@@ -12910,6 +13145,15 @@ function createResponseValidatorMini({ operation, plugin }) {
|
|
|
12910
13145
|
}
|
|
12911
13146
|
});
|
|
12912
13147
|
}
|
|
13148
|
+
function createResponseTransformerMini(ctx) {
|
|
13149
|
+
return createResponseValidatorMini(ctx);
|
|
13150
|
+
}
|
|
13151
|
+
function createResponseHandlersMini(ctx) {
|
|
13152
|
+
return {
|
|
13153
|
+
transformer: createResponseTransformerMini(ctx),
|
|
13154
|
+
validator: void 0
|
|
13155
|
+
};
|
|
13156
|
+
}
|
|
12913
13157
|
//#endregion
|
|
12914
13158
|
//#region src/plugins/zod/v3/api.ts
|
|
12915
13159
|
function emptyNode$1(ctx) {
|
|
@@ -12995,6 +13239,7 @@ function createRequestSchemaContext$1(ctx) {
|
|
|
12995
13239
|
empty: emptyNode$1,
|
|
12996
13240
|
optional: optionalNode$1
|
|
12997
13241
|
},
|
|
13242
|
+
path: ref([]),
|
|
12998
13243
|
symbols: {
|
|
12999
13244
|
schema: $(""),
|
|
13000
13245
|
z
|
|
@@ -13047,6 +13292,7 @@ function createResponseValidatorV3({ operation, plugin }) {
|
|
|
13047
13292
|
$,
|
|
13048
13293
|
chain: { current: $(z) },
|
|
13049
13294
|
operation,
|
|
13295
|
+
path: ref([]),
|
|
13050
13296
|
plugin,
|
|
13051
13297
|
symbols: {
|
|
13052
13298
|
schema: symbol,
|
|
@@ -13054,6 +13300,15 @@ function createResponseValidatorV3({ operation, plugin }) {
|
|
|
13054
13300
|
}
|
|
13055
13301
|
});
|
|
13056
13302
|
}
|
|
13303
|
+
function createResponseTransformerV3(ctx) {
|
|
13304
|
+
return createResponseValidatorV3(ctx);
|
|
13305
|
+
}
|
|
13306
|
+
function createResponseHandlersV3(ctx) {
|
|
13307
|
+
return {
|
|
13308
|
+
transformer: createResponseTransformerV3(ctx),
|
|
13309
|
+
validator: void 0
|
|
13310
|
+
};
|
|
13311
|
+
}
|
|
13057
13312
|
//#endregion
|
|
13058
13313
|
//#region src/plugins/zod/v4/api.ts
|
|
13059
13314
|
function emptyNode(ctx) {
|
|
@@ -13139,6 +13394,7 @@ function createRequestSchemaContext(ctx) {
|
|
|
13139
13394
|
empty: emptyNode,
|
|
13140
13395
|
optional: optionalNode
|
|
13141
13396
|
},
|
|
13397
|
+
path: ref([]),
|
|
13142
13398
|
symbols: {
|
|
13143
13399
|
schema: $(""),
|
|
13144
13400
|
z
|
|
@@ -13191,6 +13447,7 @@ function createResponseValidatorV4({ operation, plugin }) {
|
|
|
13191
13447
|
$,
|
|
13192
13448
|
chain: { current: $(z) },
|
|
13193
13449
|
operation,
|
|
13450
|
+
path: ref([]),
|
|
13194
13451
|
plugin,
|
|
13195
13452
|
symbols: {
|
|
13196
13453
|
schema: symbol,
|
|
@@ -13198,6 +13455,15 @@ function createResponseValidatorV4({ operation, plugin }) {
|
|
|
13198
13455
|
}
|
|
13199
13456
|
});
|
|
13200
13457
|
}
|
|
13458
|
+
function createResponseTransformerV4(ctx) {
|
|
13459
|
+
return createResponseValidatorV4(ctx);
|
|
13460
|
+
}
|
|
13461
|
+
function createResponseHandlersV4(ctx) {
|
|
13462
|
+
return {
|
|
13463
|
+
transformer: createResponseTransformerV4(ctx),
|
|
13464
|
+
validator: void 0
|
|
13465
|
+
};
|
|
13466
|
+
}
|
|
13201
13467
|
//#endregion
|
|
13202
13468
|
//#region src/plugins/zod/api.ts
|
|
13203
13469
|
var Api = class {
|
|
@@ -13219,6 +13485,22 @@ var Api = class {
|
|
|
13219
13485
|
default: return createRequestValidatorV4(ctx);
|
|
13220
13486
|
}
|
|
13221
13487
|
}
|
|
13488
|
+
createResponseHandlers(ctx) {
|
|
13489
|
+
const { plugin } = ctx;
|
|
13490
|
+
switch (plugin.config.compatibilityVersion) {
|
|
13491
|
+
case 3: return createResponseHandlersV3(ctx);
|
|
13492
|
+
case "mini": return createResponseHandlersMini(ctx);
|
|
13493
|
+
default: return createResponseHandlersV4(ctx);
|
|
13494
|
+
}
|
|
13495
|
+
}
|
|
13496
|
+
createResponseTransformer(ctx) {
|
|
13497
|
+
const { plugin } = ctx;
|
|
13498
|
+
switch (plugin.config.compatibilityVersion) {
|
|
13499
|
+
case 3: return createResponseTransformerV3(ctx);
|
|
13500
|
+
case "mini": return createResponseTransformerMini(ctx);
|
|
13501
|
+
default: return createResponseTransformerV4(ctx);
|
|
13502
|
+
}
|
|
13503
|
+
}
|
|
13222
13504
|
createResponseValidator(ctx) {
|
|
13223
13505
|
const { plugin } = ctx;
|
|
13224
13506
|
switch (plugin.config.compatibilityVersion) {
|
|
@@ -13405,12 +13687,13 @@ function unknownResolver$2(ctx) {
|
|
|
13405
13687
|
ctx.chain.current = baseResult;
|
|
13406
13688
|
return ctx.chain.current;
|
|
13407
13689
|
}
|
|
13408
|
-
function unknownToAst$2({ plugin, schema }) {
|
|
13690
|
+
function unknownToAst$2({ path, plugin, schema }) {
|
|
13409
13691
|
const z = plugin.external("zod.z");
|
|
13410
13692
|
const ctx = {
|
|
13411
13693
|
$,
|
|
13412
13694
|
chain: { current: $(z) },
|
|
13413
13695
|
nodes: { base: baseNode$41 },
|
|
13696
|
+
path,
|
|
13414
13697
|
plugin,
|
|
13415
13698
|
schema,
|
|
13416
13699
|
symbols: { z }
|
|
@@ -13421,12 +13704,13 @@ function unknownToAst$2({ plugin, schema }) {
|
|
|
13421
13704
|
//#endregion
|
|
13422
13705
|
//#region src/plugins/zod/mini/toAst/array.ts
|
|
13423
13706
|
function baseNode$40(ctx) {
|
|
13424
|
-
const { applyModifiers, childResults, plugin, schema, symbols } = ctx;
|
|
13707
|
+
const { applyModifiers, childResults, path, plugin, schema, symbols } = ctx;
|
|
13425
13708
|
const { z } = symbols;
|
|
13426
13709
|
const arrayFn = $(z).attr(identifiers.array);
|
|
13427
13710
|
let normalizedSchema = schema;
|
|
13428
13711
|
if (normalizedSchema.items) normalizedSchema = deduplicateSchema({ schema: normalizedSchema });
|
|
13429
13712
|
if (!normalizedSchema.items) return arrayFn.call(unknownToAst$2({
|
|
13713
|
+
path,
|
|
13430
13714
|
plugin,
|
|
13431
13715
|
schema: { type: "unknown" }
|
|
13432
13716
|
}));
|
|
@@ -13440,6 +13724,7 @@ function baseNode$40(ctx) {
|
|
|
13440
13724
|
else return arrayFn.call($(z).attr(identifiers.union).call($.array(...itemExpressions)));
|
|
13441
13725
|
}
|
|
13442
13726
|
return arrayFn.call(unknownToAst$2({
|
|
13727
|
+
path,
|
|
13443
13728
|
plugin,
|
|
13444
13729
|
schema: { type: "unknown" }
|
|
13445
13730
|
}));
|
|
@@ -13474,14 +13759,17 @@ function arrayResolver$2(ctx) {
|
|
|
13474
13759
|
}
|
|
13475
13760
|
return ctx.chain.current;
|
|
13476
13761
|
}
|
|
13477
|
-
function arrayToAst$2({ applyModifiers, plugin, schema, walk
|
|
13762
|
+
function arrayToAst$2({ applyModifiers, path, plugin, schema, walk }) {
|
|
13478
13763
|
const childResults = [];
|
|
13479
13764
|
let schemaCopy = schema;
|
|
13480
13765
|
const z = plugin.external("zod.z");
|
|
13481
13766
|
if (schemaCopy.items) {
|
|
13482
13767
|
schemaCopy = deduplicateSchema({ schema: schemaCopy });
|
|
13483
13768
|
schemaCopy.items.forEach((item, index) => {
|
|
13484
|
-
const itemResult = walk(item, childContext(
|
|
13769
|
+
const itemResult = walk(item, childContext({
|
|
13770
|
+
path,
|
|
13771
|
+
plugin
|
|
13772
|
+
}, "items", index));
|
|
13485
13773
|
childResults.push(itemResult);
|
|
13486
13774
|
});
|
|
13487
13775
|
}
|
|
@@ -13496,11 +13784,11 @@ function arrayToAst$2({ applyModifiers, plugin, schema, walk, walkerCtx }) {
|
|
|
13496
13784
|
maxLength: maxLengthNode$5,
|
|
13497
13785
|
minLength: minLengthNode$5
|
|
13498
13786
|
},
|
|
13787
|
+
path,
|
|
13499
13788
|
plugin,
|
|
13500
13789
|
schema,
|
|
13501
13790
|
symbols: { z },
|
|
13502
|
-
walk
|
|
13503
|
-
walkerCtx
|
|
13791
|
+
walk
|
|
13504
13792
|
};
|
|
13505
13793
|
const resolver = plugin.config["~resolvers"]?.array;
|
|
13506
13794
|
return {
|
|
@@ -13531,7 +13819,7 @@ function booleanResolver$2(ctx) {
|
|
|
13531
13819
|
ctx.chain.current = baseResult;
|
|
13532
13820
|
return ctx.chain.current;
|
|
13533
13821
|
}
|
|
13534
|
-
function booleanToAst$2({ plugin, schema }) {
|
|
13822
|
+
function booleanToAst$2({ path, plugin, schema }) {
|
|
13535
13823
|
const z = plugin.external("zod.z");
|
|
13536
13824
|
const ctx = {
|
|
13537
13825
|
$,
|
|
@@ -13540,6 +13828,7 @@ function booleanToAst$2({ plugin, schema }) {
|
|
|
13540
13828
|
base: baseNode$39,
|
|
13541
13829
|
const: constNode$11
|
|
13542
13830
|
},
|
|
13831
|
+
path,
|
|
13543
13832
|
plugin,
|
|
13544
13833
|
schema,
|
|
13545
13834
|
symbols: { z }
|
|
@@ -13553,45 +13842,48 @@ function itemsNode$2(ctx) {
|
|
|
13553
13842
|
const { schema, symbols } = ctx;
|
|
13554
13843
|
const { z } = symbols;
|
|
13555
13844
|
const enumMembers = [];
|
|
13556
|
-
const
|
|
13557
|
-
let isNullable = false;
|
|
13558
|
-
let allStrings = true;
|
|
13845
|
+
const literalSchemas = [];
|
|
13559
13846
|
for (const item of schema.items ?? []) if (item.type === "string" && typeof item.const === "string") {
|
|
13560
13847
|
const literal = $.literal(item.const);
|
|
13561
13848
|
enumMembers.push(literal);
|
|
13562
|
-
|
|
13849
|
+
literalSchemas.push($(z).attr(identifiers.literal).call(literal));
|
|
13563
13850
|
} else if ((item.type === "number" || item.type === "integer") && typeof item.const === "number") {
|
|
13564
|
-
allStrings = false;
|
|
13565
13851
|
const literal = $.literal(item.const);
|
|
13566
|
-
|
|
13852
|
+
literalSchemas.push($(z).attr(identifiers.literal).call(literal));
|
|
13567
13853
|
} else if (item.type === "boolean" && typeof item.const === "boolean") {
|
|
13568
|
-
allStrings = false;
|
|
13569
13854
|
const literal = $.literal(item.const);
|
|
13570
|
-
|
|
13571
|
-
}
|
|
13855
|
+
literalSchemas.push($(z).attr(identifiers.literal).call(literal));
|
|
13856
|
+
}
|
|
13572
13857
|
return {
|
|
13573
|
-
allStrings,
|
|
13574
13858
|
enumMembers,
|
|
13575
|
-
|
|
13576
|
-
literalMembers
|
|
13859
|
+
literalSchemas
|
|
13577
13860
|
};
|
|
13578
13861
|
}
|
|
13579
13862
|
function baseNode$38(ctx) {
|
|
13863
|
+
const { enumMembers, literalSchemas } = ctx.nodes.items(ctx);
|
|
13864
|
+
if (!literalSchemas.length) return unknownToAst$2({
|
|
13865
|
+
path: ctx.path,
|
|
13866
|
+
plugin: ctx.plugin,
|
|
13867
|
+
schema: { type: "unknown" }
|
|
13868
|
+
});
|
|
13580
13869
|
const { symbols } = ctx;
|
|
13581
13870
|
const { z } = symbols;
|
|
13582
|
-
const
|
|
13583
|
-
|
|
13584
|
-
|
|
13585
|
-
|
|
13871
|
+
const def = ctx.plugin.querySymbols({
|
|
13872
|
+
resource: "definition",
|
|
13873
|
+
resourceId: pathToJsonPointer(fromRef(ctx.path)),
|
|
13874
|
+
tool: "typescript"
|
|
13875
|
+
}).filter((symbol) => symbol.kind === "var" || symbol.kind === "enum" && !symbol.node.hasModifier("const"))[0];
|
|
13876
|
+
if (def) return $(z).attr(identifiers.enum).call(def);
|
|
13877
|
+
if (enumMembers.length > 0 && enumMembers.length === literalSchemas.length) return $(z).attr(identifiers.enum).call($.array(...enumMembers));
|
|
13878
|
+
if (literalSchemas.length === 1) return literalSchemas[0];
|
|
13879
|
+
return $(z).attr(identifiers.union).call($.array(...literalSchemas));
|
|
13586
13880
|
}
|
|
13587
13881
|
function enumResolver$2(ctx) {
|
|
13588
|
-
const { literalMembers } = ctx.nodes.items(ctx);
|
|
13589
|
-
if (!literalMembers.length) return ctx.chain.current;
|
|
13590
13882
|
const baseExpression = ctx.nodes.base(ctx);
|
|
13591
13883
|
ctx.chain.current = baseExpression;
|
|
13592
13884
|
return ctx.chain.current;
|
|
13593
13885
|
}
|
|
13594
|
-
function enumToAst$2({ plugin, schema }) {
|
|
13886
|
+
function enumToAst$2({ path, plugin, schema }) {
|
|
13595
13887
|
const z = plugin.external("zod.z");
|
|
13596
13888
|
const ctx = {
|
|
13597
13889
|
$,
|
|
@@ -13600,15 +13892,11 @@ function enumToAst$2({ plugin, schema }) {
|
|
|
13600
13892
|
base: baseNode$38,
|
|
13601
13893
|
items: itemsNode$2
|
|
13602
13894
|
},
|
|
13895
|
+
path,
|
|
13603
13896
|
plugin,
|
|
13604
13897
|
schema,
|
|
13605
13898
|
symbols: { z }
|
|
13606
13899
|
};
|
|
13607
|
-
const { literalMembers } = itemsNode$2(ctx);
|
|
13608
|
-
if (!literalMembers.length) return unknownToAst$2({
|
|
13609
|
-
plugin,
|
|
13610
|
-
schema: { type: "unknown" }
|
|
13611
|
-
});
|
|
13612
13900
|
const resolver = plugin.config["~resolvers"]?.enum;
|
|
13613
13901
|
return resolver?.(ctx) ?? enumResolver$2(ctx);
|
|
13614
13902
|
}
|
|
@@ -13629,7 +13917,7 @@ function intersectionResolver$2(ctx) {
|
|
|
13629
13917
|
ctx.chain.current = baseResult;
|
|
13630
13918
|
return ctx.chain.current;
|
|
13631
13919
|
}
|
|
13632
|
-
function intersectionToAst$2({ childResults, parentSchema, plugin, schemas }) {
|
|
13920
|
+
function intersectionToAst$2({ childResults, parentSchema, path, plugin, schemas }) {
|
|
13633
13921
|
const z = plugin.external("zod.z");
|
|
13634
13922
|
const ctx = {
|
|
13635
13923
|
$,
|
|
@@ -13637,6 +13925,7 @@ function intersectionToAst$2({ childResults, parentSchema, plugin, schemas }) {
|
|
|
13637
13925
|
childResults,
|
|
13638
13926
|
nodes: { base: baseNode$37 },
|
|
13639
13927
|
parentSchema,
|
|
13928
|
+
path,
|
|
13640
13929
|
plugin,
|
|
13641
13930
|
schema: parentSchema,
|
|
13642
13931
|
schemas,
|
|
@@ -13660,12 +13949,13 @@ function neverResolver$2(ctx) {
|
|
|
13660
13949
|
ctx.chain.current = baseResult;
|
|
13661
13950
|
return ctx.chain.current;
|
|
13662
13951
|
}
|
|
13663
|
-
function neverToAst$2({ plugin, schema }) {
|
|
13952
|
+
function neverToAst$2({ path, plugin, schema }) {
|
|
13664
13953
|
const z = plugin.external("zod.z");
|
|
13665
13954
|
const ctx = {
|
|
13666
13955
|
$,
|
|
13667
13956
|
chain: { current: $(z) },
|
|
13668
13957
|
nodes: { base: baseNode$36 },
|
|
13958
|
+
path,
|
|
13669
13959
|
plugin,
|
|
13670
13960
|
schema,
|
|
13671
13961
|
symbols: { z }
|
|
@@ -13685,12 +13975,13 @@ function nullResolver$2(ctx) {
|
|
|
13685
13975
|
ctx.chain.current = baseResult;
|
|
13686
13976
|
return ctx.chain.current;
|
|
13687
13977
|
}
|
|
13688
|
-
function nullToAst$2({ plugin, schema }) {
|
|
13978
|
+
function nullToAst$2({ path, plugin, schema }) {
|
|
13689
13979
|
const z = plugin.external("zod.z");
|
|
13690
13980
|
const ctx = {
|
|
13691
13981
|
$,
|
|
13692
13982
|
chain: { current: $(z) },
|
|
13693
13983
|
nodes: { base: baseNode$35 },
|
|
13984
|
+
path,
|
|
13694
13985
|
plugin,
|
|
13695
13986
|
schema,
|
|
13696
13987
|
symbols: { z }
|
|
@@ -13746,7 +14037,7 @@ function numberResolver$2(ctx) {
|
|
|
13746
14037
|
if (checks.length) ctx.chain.current = ctx.chain.current.attr(identifiers.check).call(...checks);
|
|
13747
14038
|
return ctx.chain.current;
|
|
13748
14039
|
}
|
|
13749
|
-
function numberToNode$2({ plugin, schema }) {
|
|
14040
|
+
function numberToNode$2({ path, plugin, schema }) {
|
|
13750
14041
|
const z = plugin.external("zod.z");
|
|
13751
14042
|
const ctx = {
|
|
13752
14043
|
$,
|
|
@@ -13757,6 +14048,7 @@ function numberToNode$2({ plugin, schema }) {
|
|
|
13757
14048
|
max: maxNode$2,
|
|
13758
14049
|
min: minNode$2
|
|
13759
14050
|
},
|
|
14051
|
+
path,
|
|
13760
14052
|
plugin,
|
|
13761
14053
|
schema,
|
|
13762
14054
|
symbols: { z },
|
|
@@ -13772,9 +14064,12 @@ function numberToNode$2({ plugin, schema }) {
|
|
|
13772
14064
|
//#endregion
|
|
13773
14065
|
//#region src/plugins/zod/mini/toAst/object.ts
|
|
13774
14066
|
function additionalPropertiesNode$2(ctx) {
|
|
13775
|
-
const { _childResults, applyModifiers, schema, walk
|
|
14067
|
+
const { _childResults, applyModifiers, path, plugin, schema, walk } = ctx;
|
|
13776
14068
|
if (!schema.additionalProperties || schema.properties && Object.keys(schema.properties).length) return;
|
|
13777
|
-
const additionalResult = walk(schema.additionalProperties, childContext(
|
|
14069
|
+
const additionalResult = walk(schema.additionalProperties, childContext({
|
|
14070
|
+
path,
|
|
14071
|
+
plugin
|
|
14072
|
+
}, "additionalProperties"));
|
|
13778
14073
|
_childResults.push(additionalResult);
|
|
13779
14074
|
return applyModifiers(additionalResult, {}).expression;
|
|
13780
14075
|
}
|
|
@@ -13790,12 +14085,15 @@ function objectResolver$2(ctx) {
|
|
|
13790
14085
|
return ctx.nodes.base(ctx);
|
|
13791
14086
|
}
|
|
13792
14087
|
function shapeNode$2(ctx) {
|
|
13793
|
-
const { _childResults, applyModifiers, schema, walk
|
|
14088
|
+
const { _childResults, applyModifiers, path, plugin, schema, walk } = ctx;
|
|
13794
14089
|
const shape = $.object().pretty();
|
|
13795
14090
|
for (const name in schema.properties) {
|
|
13796
14091
|
const property = schema.properties[name];
|
|
13797
14092
|
const isOptional = !schema.required?.includes(name);
|
|
13798
|
-
const propertyResult = walk(property, childContext(
|
|
14093
|
+
const propertyResult = walk(property, childContext({
|
|
14094
|
+
path,
|
|
14095
|
+
plugin
|
|
14096
|
+
}, "properties", name));
|
|
13799
14097
|
_childResults.push(propertyResult);
|
|
13800
14098
|
const finalExpr = applyModifiers(propertyResult, { optional: isOptional });
|
|
13801
14099
|
shape.prop(name, finalExpr.expression);
|
|
@@ -13803,7 +14101,7 @@ function shapeNode$2(ctx) {
|
|
|
13803
14101
|
return shape;
|
|
13804
14102
|
}
|
|
13805
14103
|
function objectToAst$2(options) {
|
|
13806
|
-
const { applyModifiers, plugin, schema, walk
|
|
14104
|
+
const { applyModifiers, path, plugin, schema, walk } = options;
|
|
13807
14105
|
const childResults = [];
|
|
13808
14106
|
const z = plugin.external("zod.z");
|
|
13809
14107
|
const ctx = {
|
|
@@ -13816,11 +14114,11 @@ function objectToAst$2(options) {
|
|
|
13816
14114
|
base: baseNode$33,
|
|
13817
14115
|
shape: shapeNode$2
|
|
13818
14116
|
},
|
|
14117
|
+
path,
|
|
13819
14118
|
plugin,
|
|
13820
14119
|
schema,
|
|
13821
14120
|
symbols: { z },
|
|
13822
|
-
walk
|
|
13823
|
-
walkerCtx
|
|
14121
|
+
walk
|
|
13824
14122
|
};
|
|
13825
14123
|
const resolver = plugin.config["~resolvers"]?.object;
|
|
13826
14124
|
return {
|
|
@@ -13907,7 +14205,7 @@ function stringResolver$2(ctx) {
|
|
|
13907
14205
|
if (checks.length) ctx.chain.current = ctx.chain.current.attr(identifiers.check).call(...checks);
|
|
13908
14206
|
return ctx.chain.current;
|
|
13909
14207
|
}
|
|
13910
|
-
function stringToNode$2({ plugin, schema }) {
|
|
14208
|
+
function stringToNode$2({ path, plugin, schema }) {
|
|
13911
14209
|
const z = plugin.external("zod.z");
|
|
13912
14210
|
const ctx = {
|
|
13913
14211
|
$,
|
|
@@ -13921,6 +14219,7 @@ function stringToNode$2({ plugin, schema }) {
|
|
|
13921
14219
|
minLength: minLengthNode$4,
|
|
13922
14220
|
pattern: patternNode$2
|
|
13923
14221
|
},
|
|
14222
|
+
path,
|
|
13924
14223
|
plugin,
|
|
13925
14224
|
schema,
|
|
13926
14225
|
symbols: { z }
|
|
@@ -13955,11 +14254,14 @@ function tupleResolver$2(ctx) {
|
|
|
13955
14254
|
ctx.chain.current = baseResult;
|
|
13956
14255
|
return ctx.chain.current;
|
|
13957
14256
|
}
|
|
13958
|
-
function tupleToAst$2({ applyModifiers, plugin, schema, walk
|
|
14257
|
+
function tupleToAst$2({ applyModifiers, path, plugin, schema, walk }) {
|
|
13959
14258
|
const childResults = [];
|
|
13960
14259
|
const z = plugin.external("zod.z");
|
|
13961
14260
|
if (schema.items) schema.items.forEach((item, index) => {
|
|
13962
|
-
const itemResult = walk(item, childContext(
|
|
14261
|
+
const itemResult = walk(item, childContext({
|
|
14262
|
+
path,
|
|
14263
|
+
plugin
|
|
14264
|
+
}, "items", index));
|
|
13963
14265
|
childResults.push(itemResult);
|
|
13964
14266
|
});
|
|
13965
14267
|
const ctx = {
|
|
@@ -13971,11 +14273,11 @@ function tupleToAst$2({ applyModifiers, plugin, schema, walk, walkerCtx }) {
|
|
|
13971
14273
|
base: baseNode$31,
|
|
13972
14274
|
const: constNode$8
|
|
13973
14275
|
},
|
|
14276
|
+
path,
|
|
13974
14277
|
plugin,
|
|
13975
14278
|
schema,
|
|
13976
14279
|
symbols: { z },
|
|
13977
|
-
walk
|
|
13978
|
-
walkerCtx
|
|
14280
|
+
walk
|
|
13979
14281
|
};
|
|
13980
14282
|
const resolver = plugin.config["~resolvers"]?.tuple;
|
|
13981
14283
|
return {
|
|
@@ -13995,12 +14297,13 @@ function undefinedResolver$2(ctx) {
|
|
|
13995
14297
|
ctx.chain.current = baseResult;
|
|
13996
14298
|
return ctx.chain.current;
|
|
13997
14299
|
}
|
|
13998
|
-
function undefinedToAst$2({ plugin, schema }) {
|
|
14300
|
+
function undefinedToAst$2({ path, plugin, schema }) {
|
|
13999
14301
|
const z = plugin.external("zod.z");
|
|
14000
14302
|
const ctx = {
|
|
14001
14303
|
$,
|
|
14002
14304
|
chain: { current: $(z) },
|
|
14003
14305
|
nodes: { base: baseNode$30 },
|
|
14306
|
+
path,
|
|
14004
14307
|
plugin,
|
|
14005
14308
|
schema,
|
|
14006
14309
|
symbols: { z }
|
|
@@ -14076,7 +14379,7 @@ function unionResolver$2(ctx) {
|
|
|
14076
14379
|
ctx.chain.current = baseResult;
|
|
14077
14380
|
return ctx.chain.current;
|
|
14078
14381
|
}
|
|
14079
|
-
function unionToAst$2({ childResults, parentSchema, plugin, schemas }) {
|
|
14382
|
+
function unionToAst$2({ childResults, parentSchema, path, plugin, schemas }) {
|
|
14080
14383
|
const z = plugin.external("zod.z");
|
|
14081
14384
|
const ctx = {
|
|
14082
14385
|
$,
|
|
@@ -14084,6 +14387,7 @@ function unionToAst$2({ childResults, parentSchema, plugin, schemas }) {
|
|
|
14084
14387
|
childResults,
|
|
14085
14388
|
nodes: { base: baseNode$29 },
|
|
14086
14389
|
parentSchema,
|
|
14390
|
+
path,
|
|
14087
14391
|
plugin,
|
|
14088
14392
|
schema: parentSchema,
|
|
14089
14393
|
schemas,
|
|
@@ -14107,12 +14411,13 @@ function voidResolver$2(ctx) {
|
|
|
14107
14411
|
ctx.chain.current = baseResult;
|
|
14108
14412
|
return ctx.chain.current;
|
|
14109
14413
|
}
|
|
14110
|
-
function voidToAst$2({ plugin, schema }) {
|
|
14414
|
+
function voidToAst$2({ path, plugin, schema }) {
|
|
14111
14415
|
const z = plugin.external("zod.z");
|
|
14112
14416
|
const ctx = {
|
|
14113
14417
|
$,
|
|
14114
14418
|
chain: { current: $(z) },
|
|
14115
14419
|
nodes: { base: baseNode$28 },
|
|
14420
|
+
path,
|
|
14116
14421
|
plugin,
|
|
14117
14422
|
schema,
|
|
14118
14423
|
symbols: { z }
|
|
@@ -14121,7 +14426,7 @@ function voidToAst$2({ plugin, schema }) {
|
|
|
14121
14426
|
return resolver?.(ctx) ?? voidResolver$2(ctx);
|
|
14122
14427
|
}
|
|
14123
14428
|
//#endregion
|
|
14124
|
-
//#region src/plugins/zod/mini/
|
|
14429
|
+
//#region src/plugins/zod/mini/visitor.ts
|
|
14125
14430
|
function getDefaultValue$2(meta) {
|
|
14126
14431
|
return meta.format ? maybeBigInt(meta.default, meta.format) : $.fromValue(meta.default);
|
|
14127
14432
|
}
|
|
@@ -14145,10 +14450,10 @@ function createVisitor$2(config = {}) {
|
|
|
14145
14450
|
const applyModifiers = (result, opts) => this.applyModifiers(result, ctx, opts);
|
|
14146
14451
|
const { childResults, expression } = arrayToAst$2({
|
|
14147
14452
|
applyModifiers,
|
|
14453
|
+
path: ctx.path,
|
|
14148
14454
|
plugin: ctx.plugin,
|
|
14149
14455
|
schema,
|
|
14150
|
-
walk
|
|
14151
|
-
walkerCtx: ctx
|
|
14456
|
+
walk
|
|
14152
14457
|
});
|
|
14153
14458
|
return {
|
|
14154
14459
|
expression,
|
|
@@ -14158,6 +14463,7 @@ function createVisitor$2(config = {}) {
|
|
|
14158
14463
|
boolean(schema, ctx) {
|
|
14159
14464
|
return {
|
|
14160
14465
|
expression: booleanToAst$2({
|
|
14466
|
+
path: ctx.path,
|
|
14161
14467
|
plugin: ctx.plugin,
|
|
14162
14468
|
schema
|
|
14163
14469
|
}),
|
|
@@ -14166,6 +14472,7 @@ function createVisitor$2(config = {}) {
|
|
|
14166
14472
|
},
|
|
14167
14473
|
enum(schema, ctx) {
|
|
14168
14474
|
const expression = enumToAst$2({
|
|
14475
|
+
path: ctx.path,
|
|
14169
14476
|
plugin: ctx.plugin,
|
|
14170
14477
|
schema
|
|
14171
14478
|
});
|
|
@@ -14181,6 +14488,7 @@ function createVisitor$2(config = {}) {
|
|
|
14181
14488
|
integer(schema, ctx) {
|
|
14182
14489
|
return {
|
|
14183
14490
|
expression: numberToNode$2({
|
|
14491
|
+
path: ctx.path,
|
|
14184
14492
|
plugin: ctx.plugin,
|
|
14185
14493
|
schema
|
|
14186
14494
|
}),
|
|
@@ -14214,6 +14522,7 @@ function createVisitor$2(config = {}) {
|
|
|
14214
14522
|
const { expression } = intersectionToAst$2({
|
|
14215
14523
|
childResults: items,
|
|
14216
14524
|
parentSchema,
|
|
14525
|
+
path: ctx.path,
|
|
14217
14526
|
plugin: ctx.plugin,
|
|
14218
14527
|
schemas
|
|
14219
14528
|
});
|
|
@@ -14233,6 +14542,7 @@ function createVisitor$2(config = {}) {
|
|
|
14233
14542
|
never(schema, ctx) {
|
|
14234
14543
|
return {
|
|
14235
14544
|
expression: neverToAst$2({
|
|
14545
|
+
path: ctx.path,
|
|
14236
14546
|
plugin: ctx.plugin,
|
|
14237
14547
|
schema
|
|
14238
14548
|
}),
|
|
@@ -14246,6 +14556,7 @@ function createVisitor$2(config = {}) {
|
|
|
14246
14556
|
null(schema, ctx) {
|
|
14247
14557
|
return {
|
|
14248
14558
|
expression: nullToAst$2({
|
|
14559
|
+
path: ctx.path,
|
|
14249
14560
|
plugin: ctx.plugin,
|
|
14250
14561
|
schema
|
|
14251
14562
|
}),
|
|
@@ -14259,6 +14570,7 @@ function createVisitor$2(config = {}) {
|
|
|
14259
14570
|
number(schema, ctx) {
|
|
14260
14571
|
return {
|
|
14261
14572
|
expression: numberToNode$2({
|
|
14573
|
+
path: ctx.path,
|
|
14262
14574
|
plugin: ctx.plugin,
|
|
14263
14575
|
schema
|
|
14264
14576
|
}),
|
|
@@ -14272,10 +14584,10 @@ function createVisitor$2(config = {}) {
|
|
|
14272
14584
|
const applyModifiers = (result, opts) => this.applyModifiers(result, ctx, opts);
|
|
14273
14585
|
const { childResults, expression } = objectToAst$2({
|
|
14274
14586
|
applyModifiers,
|
|
14587
|
+
path: ctx.path,
|
|
14275
14588
|
plugin: ctx.plugin,
|
|
14276
14589
|
schema,
|
|
14277
|
-
walk
|
|
14278
|
-
walkerCtx: ctx
|
|
14590
|
+
walk
|
|
14279
14591
|
});
|
|
14280
14592
|
return {
|
|
14281
14593
|
expression,
|
|
@@ -14326,6 +14638,7 @@ function createVisitor$2(config = {}) {
|
|
|
14326
14638
|
string(schema, ctx) {
|
|
14327
14639
|
if (shouldCoerceToBigInt(schema.format)) return {
|
|
14328
14640
|
expression: numberToNode$2({
|
|
14641
|
+
path: ctx.path,
|
|
14329
14642
|
plugin: ctx.plugin,
|
|
14330
14643
|
schema: {
|
|
14331
14644
|
...schema,
|
|
@@ -14336,6 +14649,7 @@ function createVisitor$2(config = {}) {
|
|
|
14336
14649
|
};
|
|
14337
14650
|
return {
|
|
14338
14651
|
expression: stringToNode$2({
|
|
14652
|
+
path: ctx.path,
|
|
14339
14653
|
plugin: ctx.plugin,
|
|
14340
14654
|
schema
|
|
14341
14655
|
}),
|
|
@@ -14346,10 +14660,10 @@ function createVisitor$2(config = {}) {
|
|
|
14346
14660
|
const applyModifiers = (result, opts) => this.applyModifiers(result, ctx, opts);
|
|
14347
14661
|
const { childResults, expression } = tupleToAst$2({
|
|
14348
14662
|
applyModifiers,
|
|
14663
|
+
path: ctx.path,
|
|
14349
14664
|
plugin: ctx.plugin,
|
|
14350
14665
|
schema,
|
|
14351
|
-
walk
|
|
14352
|
-
walkerCtx: ctx
|
|
14666
|
+
walk
|
|
14353
14667
|
});
|
|
14354
14668
|
return {
|
|
14355
14669
|
expression,
|
|
@@ -14359,6 +14673,7 @@ function createVisitor$2(config = {}) {
|
|
|
14359
14673
|
undefined(schema, ctx) {
|
|
14360
14674
|
return {
|
|
14361
14675
|
expression: undefinedToAst$2({
|
|
14676
|
+
path: ctx.path,
|
|
14362
14677
|
plugin: ctx.plugin,
|
|
14363
14678
|
schema
|
|
14364
14679
|
}),
|
|
@@ -14375,6 +14690,7 @@ function createVisitor$2(config = {}) {
|
|
|
14375
14690
|
const { expression } = unionToAst$2({
|
|
14376
14691
|
childResults: items,
|
|
14377
14692
|
parentSchema,
|
|
14693
|
+
path: ctx.path,
|
|
14378
14694
|
plugin: ctx.plugin,
|
|
14379
14695
|
schemas
|
|
14380
14696
|
});
|
|
@@ -14394,6 +14710,7 @@ function createVisitor$2(config = {}) {
|
|
|
14394
14710
|
unknown(schema, ctx) {
|
|
14395
14711
|
return {
|
|
14396
14712
|
expression: unknownToAst$2({
|
|
14713
|
+
path: ctx.path,
|
|
14397
14714
|
plugin: ctx.plugin,
|
|
14398
14715
|
schema
|
|
14399
14716
|
}),
|
|
@@ -14407,6 +14724,7 @@ function createVisitor$2(config = {}) {
|
|
|
14407
14724
|
void(schema, ctx) {
|
|
14408
14725
|
return {
|
|
14409
14726
|
expression: voidToAst$2({
|
|
14727
|
+
path: ctx.path,
|
|
14410
14728
|
plugin: ctx.plugin,
|
|
14411
14729
|
schema
|
|
14412
14730
|
}),
|
|
@@ -14552,12 +14870,13 @@ function unknownResolver$1(ctx) {
|
|
|
14552
14870
|
ctx.chain.current = baseResult;
|
|
14553
14871
|
return ctx.chain.current;
|
|
14554
14872
|
}
|
|
14555
|
-
function unknownToAst$1({ plugin, schema }) {
|
|
14873
|
+
function unknownToAst$1({ path, plugin, schema }) {
|
|
14556
14874
|
const z = plugin.external("zod.z");
|
|
14557
14875
|
const ctx = {
|
|
14558
14876
|
$,
|
|
14559
14877
|
chain: { current: $(z) },
|
|
14560
14878
|
nodes: { base: baseNode$27 },
|
|
14879
|
+
path,
|
|
14561
14880
|
plugin,
|
|
14562
14881
|
schema,
|
|
14563
14882
|
symbols: { z }
|
|
@@ -14568,12 +14887,13 @@ function unknownToAst$1({ plugin, schema }) {
|
|
|
14568
14887
|
//#endregion
|
|
14569
14888
|
//#region src/plugins/zod/v3/toAst/array.ts
|
|
14570
14889
|
function baseNode$26(ctx) {
|
|
14571
|
-
const { applyModifiers, childResults, plugin, schema, symbols } = ctx;
|
|
14890
|
+
const { applyModifiers, childResults, path, plugin, schema, symbols } = ctx;
|
|
14572
14891
|
const { z } = symbols;
|
|
14573
14892
|
const arrayFn = $(z).attr(identifiers.array);
|
|
14574
14893
|
let normalizedSchema = schema;
|
|
14575
14894
|
if (normalizedSchema.items) normalizedSchema = deduplicateSchema({ schema: normalizedSchema });
|
|
14576
14895
|
if (!normalizedSchema.items) return arrayFn.call(unknownToAst$1({
|
|
14896
|
+
path,
|
|
14577
14897
|
plugin,
|
|
14578
14898
|
schema: { type: "unknown" }
|
|
14579
14899
|
}));
|
|
@@ -14595,6 +14915,7 @@ function baseNode$26(ctx) {
|
|
|
14595
14915
|
} else return arrayFn.call($(z).attr(identifiers.union).call($.array(...itemExpressions)));
|
|
14596
14916
|
}
|
|
14597
14917
|
return arrayFn.call(unknownToAst$1({
|
|
14918
|
+
path,
|
|
14598
14919
|
plugin,
|
|
14599
14920
|
schema: { type: "unknown" }
|
|
14600
14921
|
}));
|
|
@@ -14626,14 +14947,17 @@ function arrayResolver$1(ctx) {
|
|
|
14626
14947
|
}
|
|
14627
14948
|
return ctx.chain.current;
|
|
14628
14949
|
}
|
|
14629
|
-
function arrayToAst$1({ applyModifiers, plugin, schema, walk
|
|
14950
|
+
function arrayToAst$1({ applyModifiers, path, plugin, schema, walk }) {
|
|
14630
14951
|
const childResults = [];
|
|
14631
14952
|
let schemaCopy = schema;
|
|
14632
14953
|
const z = plugin.external("zod.z");
|
|
14633
14954
|
if (schemaCopy.items) {
|
|
14634
14955
|
schemaCopy = deduplicateSchema({ schema: schemaCopy });
|
|
14635
14956
|
schemaCopy.items.forEach((item, index) => {
|
|
14636
|
-
const itemResult = walk(item, childContext(
|
|
14957
|
+
const itemResult = walk(item, childContext({
|
|
14958
|
+
path,
|
|
14959
|
+
plugin
|
|
14960
|
+
}, "items", index));
|
|
14637
14961
|
childResults.push(itemResult);
|
|
14638
14962
|
});
|
|
14639
14963
|
}
|
|
@@ -14648,11 +14972,11 @@ function arrayToAst$1({ applyModifiers, plugin, schema, walk, walkerCtx }) {
|
|
|
14648
14972
|
maxLength: maxLengthNode$3,
|
|
14649
14973
|
minLength: minLengthNode$3
|
|
14650
14974
|
},
|
|
14975
|
+
path,
|
|
14651
14976
|
plugin,
|
|
14652
14977
|
schema,
|
|
14653
14978
|
symbols: { z },
|
|
14654
|
-
walk
|
|
14655
|
-
walkerCtx
|
|
14979
|
+
walk
|
|
14656
14980
|
};
|
|
14657
14981
|
const resolver = plugin.config["~resolvers"]?.array;
|
|
14658
14982
|
return {
|
|
@@ -14683,7 +15007,7 @@ function booleanResolver$1(ctx) {
|
|
|
14683
15007
|
ctx.chain.current = baseResult;
|
|
14684
15008
|
return ctx.chain.current;
|
|
14685
15009
|
}
|
|
14686
|
-
function booleanToAst$1({ plugin, schema }) {
|
|
15010
|
+
function booleanToAst$1({ path, plugin, schema }) {
|
|
14687
15011
|
const z = plugin.external("zod.z");
|
|
14688
15012
|
const ctx = {
|
|
14689
15013
|
$,
|
|
@@ -14692,6 +15016,7 @@ function booleanToAst$1({ plugin, schema }) {
|
|
|
14692
15016
|
base: baseNode$25,
|
|
14693
15017
|
const: constNode$7
|
|
14694
15018
|
},
|
|
15019
|
+
path,
|
|
14695
15020
|
plugin,
|
|
14696
15021
|
schema,
|
|
14697
15022
|
symbols: { z }
|
|
@@ -14705,45 +15030,48 @@ function itemsNode$1(ctx) {
|
|
|
14705
15030
|
const { schema, symbols } = ctx;
|
|
14706
15031
|
const { z } = symbols;
|
|
14707
15032
|
const enumMembers = [];
|
|
14708
|
-
const
|
|
14709
|
-
let isNullable = false;
|
|
14710
|
-
let allStrings = true;
|
|
15033
|
+
const literalSchemas = [];
|
|
14711
15034
|
for (const item of schema.items ?? []) if (item.type === "string" && typeof item.const === "string") {
|
|
14712
15035
|
const literal = $.literal(item.const);
|
|
14713
15036
|
enumMembers.push(literal);
|
|
14714
|
-
|
|
15037
|
+
literalSchemas.push($(z).attr(identifiers.literal).call(literal));
|
|
14715
15038
|
} else if ((item.type === "number" || item.type === "integer") && typeof item.const === "number") {
|
|
14716
|
-
allStrings = false;
|
|
14717
15039
|
const literal = $.literal(item.const);
|
|
14718
|
-
|
|
15040
|
+
literalSchemas.push($(z).attr(identifiers.literal).call(literal));
|
|
14719
15041
|
} else if (item.type === "boolean" && typeof item.const === "boolean") {
|
|
14720
|
-
allStrings = false;
|
|
14721
15042
|
const literal = $.literal(item.const);
|
|
14722
|
-
|
|
14723
|
-
}
|
|
15043
|
+
literalSchemas.push($(z).attr(identifiers.literal).call(literal));
|
|
15044
|
+
}
|
|
14724
15045
|
return {
|
|
14725
|
-
allStrings,
|
|
14726
15046
|
enumMembers,
|
|
14727
|
-
|
|
14728
|
-
literalMembers
|
|
15047
|
+
literalSchemas
|
|
14729
15048
|
};
|
|
14730
15049
|
}
|
|
14731
15050
|
function baseNode$24(ctx) {
|
|
15051
|
+
const { enumMembers, literalSchemas } = ctx.nodes.items(ctx);
|
|
15052
|
+
if (!literalSchemas.length) return unknownToAst$1({
|
|
15053
|
+
path: ctx.path,
|
|
15054
|
+
plugin: ctx.plugin,
|
|
15055
|
+
schema: { type: "unknown" }
|
|
15056
|
+
});
|
|
14732
15057
|
const { symbols } = ctx;
|
|
14733
15058
|
const { z } = symbols;
|
|
14734
|
-
const
|
|
14735
|
-
|
|
14736
|
-
|
|
14737
|
-
|
|
15059
|
+
const def = ctx.plugin.querySymbols({
|
|
15060
|
+
resource: "definition",
|
|
15061
|
+
resourceId: pathToJsonPointer(fromRef(ctx.path)),
|
|
15062
|
+
tool: "typescript"
|
|
15063
|
+
}).filter((symbol) => symbol.kind === "var" || symbol.kind === "enum" && !symbol.node.hasModifier("const"))[0];
|
|
15064
|
+
if (def) return $(z).attr(identifiers.nativeEnum).call(def);
|
|
15065
|
+
if (enumMembers.length > 0 && enumMembers.length === literalSchemas.length) return $(z).attr(identifiers.enum).call($.array(...enumMembers));
|
|
15066
|
+
if (literalSchemas.length === 1) return literalSchemas[0];
|
|
15067
|
+
return $(z).attr(identifiers.union).call($.array(...literalSchemas));
|
|
14738
15068
|
}
|
|
14739
15069
|
function enumResolver$1(ctx) {
|
|
14740
|
-
const { literalMembers } = ctx.nodes.items(ctx);
|
|
14741
|
-
if (!literalMembers.length) return ctx.chain.current;
|
|
14742
15070
|
const baseExpression = ctx.nodes.base(ctx);
|
|
14743
15071
|
ctx.chain.current = baseExpression;
|
|
14744
15072
|
return ctx.chain.current;
|
|
14745
15073
|
}
|
|
14746
|
-
function enumToAst$1({ plugin, schema }) {
|
|
15074
|
+
function enumToAst$1({ path, plugin, schema }) {
|
|
14747
15075
|
const z = plugin.external("zod.z");
|
|
14748
15076
|
const ctx = {
|
|
14749
15077
|
$,
|
|
@@ -14752,6 +15080,7 @@ function enumToAst$1({ plugin, schema }) {
|
|
|
14752
15080
|
base: baseNode$24,
|
|
14753
15081
|
items: itemsNode$1
|
|
14754
15082
|
},
|
|
15083
|
+
path,
|
|
14755
15084
|
plugin,
|
|
14756
15085
|
schema,
|
|
14757
15086
|
symbols: { z }
|
|
@@ -14778,7 +15107,7 @@ function intersectionResolver$1(ctx) {
|
|
|
14778
15107
|
ctx.chain.current = baseResult;
|
|
14779
15108
|
return ctx.chain.current;
|
|
14780
15109
|
}
|
|
14781
|
-
function intersectionToAst$1({ childResults, parentSchema, plugin, schemas }) {
|
|
15110
|
+
function intersectionToAst$1({ childResults, parentSchema, path, plugin, schemas }) {
|
|
14782
15111
|
const z = plugin.external("zod.z");
|
|
14783
15112
|
const ctx = {
|
|
14784
15113
|
$,
|
|
@@ -14786,6 +15115,7 @@ function intersectionToAst$1({ childResults, parentSchema, plugin, schemas }) {
|
|
|
14786
15115
|
childResults,
|
|
14787
15116
|
nodes: { base: baseNode$23 },
|
|
14788
15117
|
parentSchema,
|
|
15118
|
+
path,
|
|
14789
15119
|
plugin,
|
|
14790
15120
|
schema: parentSchema,
|
|
14791
15121
|
schemas,
|
|
@@ -14809,12 +15139,13 @@ function neverResolver$1(ctx) {
|
|
|
14809
15139
|
ctx.chain.current = baseResult;
|
|
14810
15140
|
return ctx.chain.current;
|
|
14811
15141
|
}
|
|
14812
|
-
function neverToAst$1({ plugin, schema }) {
|
|
15142
|
+
function neverToAst$1({ path, plugin, schema }) {
|
|
14813
15143
|
const z = plugin.external("zod.z");
|
|
14814
15144
|
const ctx = {
|
|
14815
15145
|
$,
|
|
14816
15146
|
chain: { current: $(z) },
|
|
14817
15147
|
nodes: { base: baseNode$22 },
|
|
15148
|
+
path,
|
|
14818
15149
|
plugin,
|
|
14819
15150
|
schema,
|
|
14820
15151
|
symbols: { z }
|
|
@@ -14834,12 +15165,13 @@ function nullResolver$1(ctx) {
|
|
|
14834
15165
|
ctx.chain.current = baseResult;
|
|
14835
15166
|
return ctx.chain.current;
|
|
14836
15167
|
}
|
|
14837
|
-
function nullToAst$1({ plugin, schema }) {
|
|
15168
|
+
function nullToAst$1({ path, plugin, schema }) {
|
|
14838
15169
|
const z = plugin.external("zod.z");
|
|
14839
15170
|
const ctx = {
|
|
14840
15171
|
$,
|
|
14841
15172
|
chain: { current: $(z) },
|
|
14842
15173
|
nodes: { base: baseNode$21 },
|
|
15174
|
+
path,
|
|
14843
15175
|
plugin,
|
|
14844
15176
|
schema,
|
|
14845
15177
|
symbols: { z }
|
|
@@ -14891,7 +15223,7 @@ function numberResolver$1(ctx) {
|
|
|
14891
15223
|
if (maxNode) ctx.chain.current = maxNode;
|
|
14892
15224
|
return ctx.chain.current;
|
|
14893
15225
|
}
|
|
14894
|
-
function numberToNode$1({ plugin, schema }) {
|
|
15226
|
+
function numberToNode$1({ path, plugin, schema }) {
|
|
14895
15227
|
const z = plugin.external("zod.z");
|
|
14896
15228
|
const ctx = {
|
|
14897
15229
|
$,
|
|
@@ -14902,6 +15234,7 @@ function numberToNode$1({ plugin, schema }) {
|
|
|
14902
15234
|
max: maxNode$1,
|
|
14903
15235
|
min: minNode$1
|
|
14904
15236
|
},
|
|
15237
|
+
path,
|
|
14905
15238
|
plugin,
|
|
14906
15239
|
schema,
|
|
14907
15240
|
symbols: { z },
|
|
@@ -14917,9 +15250,12 @@ function numberToNode$1({ plugin, schema }) {
|
|
|
14917
15250
|
//#endregion
|
|
14918
15251
|
//#region src/plugins/zod/v3/toAst/object.ts
|
|
14919
15252
|
function additionalPropertiesNode$1(ctx) {
|
|
14920
|
-
const { applyModifiers, schema, walk
|
|
15253
|
+
const { applyModifiers, path, plugin, schema, walk } = ctx;
|
|
14921
15254
|
if (!schema.additionalProperties || schema.properties && Object.keys(schema.properties).length) return;
|
|
14922
|
-
const additionalResult = walk(schema.additionalProperties, childContext(
|
|
15255
|
+
const additionalResult = walk(schema.additionalProperties, childContext({
|
|
15256
|
+
path,
|
|
15257
|
+
plugin
|
|
15258
|
+
}, "additionalProperties"));
|
|
14923
15259
|
ctx._childResults.push(additionalResult);
|
|
14924
15260
|
return applyModifiers(additionalResult, {}).expression;
|
|
14925
15261
|
}
|
|
@@ -14935,12 +15271,15 @@ function objectResolver$1(ctx) {
|
|
|
14935
15271
|
return ctx.nodes.base(ctx);
|
|
14936
15272
|
}
|
|
14937
15273
|
function shapeNode$1(ctx) {
|
|
14938
|
-
const { applyModifiers, schema, walk
|
|
15274
|
+
const { applyModifiers, path, plugin, schema, walk } = ctx;
|
|
14939
15275
|
const shape = $.object().pretty();
|
|
14940
15276
|
for (const name in schema.properties) {
|
|
14941
15277
|
const property = schema.properties[name];
|
|
14942
15278
|
const isOptional = !schema.required?.includes(name);
|
|
14943
|
-
const propertyResult = walk(property, childContext(
|
|
15279
|
+
const propertyResult = walk(property, childContext({
|
|
15280
|
+
path,
|
|
15281
|
+
plugin
|
|
15282
|
+
}, "properties", name));
|
|
14944
15283
|
ctx._childResults.push(propertyResult);
|
|
14945
15284
|
const finalExpr = applyModifiers(propertyResult, { optional: isOptional });
|
|
14946
15285
|
shape.prop(name, finalExpr.expression);
|
|
@@ -14948,7 +15287,7 @@ function shapeNode$1(ctx) {
|
|
|
14948
15287
|
return shape;
|
|
14949
15288
|
}
|
|
14950
15289
|
function objectToAst$1(options) {
|
|
14951
|
-
const { applyModifiers, plugin, schema, walk
|
|
15290
|
+
const { applyModifiers, path, plugin, schema, walk } = options;
|
|
14952
15291
|
const childResults = [];
|
|
14953
15292
|
const z = plugin.external("zod.z");
|
|
14954
15293
|
const ctx = {
|
|
@@ -14961,11 +15300,11 @@ function objectToAst$1(options) {
|
|
|
14961
15300
|
base: baseNode$19,
|
|
14962
15301
|
shape: shapeNode$1
|
|
14963
15302
|
},
|
|
15303
|
+
path,
|
|
14964
15304
|
plugin,
|
|
14965
15305
|
schema,
|
|
14966
15306
|
symbols: { z },
|
|
14967
|
-
walk
|
|
14968
|
-
walkerCtx
|
|
15307
|
+
walk
|
|
14969
15308
|
};
|
|
14970
15309
|
const resolver = plugin.config["~resolvers"]?.object;
|
|
14971
15310
|
return {
|
|
@@ -15044,7 +15383,7 @@ function stringResolver$1(ctx) {
|
|
|
15044
15383
|
if (patternNode) ctx.chain.current = patternNode;
|
|
15045
15384
|
return ctx.chain.current;
|
|
15046
15385
|
}
|
|
15047
|
-
function stringToNode$1({ plugin, schema }) {
|
|
15386
|
+
function stringToNode$1({ path, plugin, schema }) {
|
|
15048
15387
|
const z = plugin.external("zod.z");
|
|
15049
15388
|
const ctx = {
|
|
15050
15389
|
$,
|
|
@@ -15058,6 +15397,7 @@ function stringToNode$1({ plugin, schema }) {
|
|
|
15058
15397
|
minLength: minLengthNode$2,
|
|
15059
15398
|
pattern: patternNode$1
|
|
15060
15399
|
},
|
|
15400
|
+
path,
|
|
15061
15401
|
plugin,
|
|
15062
15402
|
schema,
|
|
15063
15403
|
symbols: { z }
|
|
@@ -15092,11 +15432,14 @@ function tupleResolver$1(ctx) {
|
|
|
15092
15432
|
ctx.chain.current = baseResult;
|
|
15093
15433
|
return ctx.chain.current;
|
|
15094
15434
|
}
|
|
15095
|
-
function tupleToAst$1({ applyModifiers, plugin, schema, walk
|
|
15435
|
+
function tupleToAst$1({ applyModifiers, path, plugin, schema, walk }) {
|
|
15096
15436
|
const childResults = [];
|
|
15097
15437
|
const z = plugin.external("zod.z");
|
|
15098
15438
|
if (schema.items) schema.items.forEach((item, index) => {
|
|
15099
|
-
const itemResult = walk(item, childContext(
|
|
15439
|
+
const itemResult = walk(item, childContext({
|
|
15440
|
+
path,
|
|
15441
|
+
plugin
|
|
15442
|
+
}, "items", index));
|
|
15100
15443
|
childResults.push(itemResult);
|
|
15101
15444
|
});
|
|
15102
15445
|
const ctx = {
|
|
@@ -15108,11 +15451,11 @@ function tupleToAst$1({ applyModifiers, plugin, schema, walk, walkerCtx }) {
|
|
|
15108
15451
|
base: baseNode$17,
|
|
15109
15452
|
const: constNode$4
|
|
15110
15453
|
},
|
|
15454
|
+
path,
|
|
15111
15455
|
plugin,
|
|
15112
15456
|
schema,
|
|
15113
15457
|
symbols: { z },
|
|
15114
|
-
walk
|
|
15115
|
-
walkerCtx
|
|
15458
|
+
walk
|
|
15116
15459
|
};
|
|
15117
15460
|
const resolver = plugin.config["~resolvers"]?.tuple;
|
|
15118
15461
|
return {
|
|
@@ -15132,12 +15475,13 @@ function undefinedResolver$1(ctx) {
|
|
|
15132
15475
|
ctx.chain.current = baseResult;
|
|
15133
15476
|
return ctx.chain.current;
|
|
15134
15477
|
}
|
|
15135
|
-
function undefinedToAst$1({ plugin, schema }) {
|
|
15478
|
+
function undefinedToAst$1({ path, plugin, schema }) {
|
|
15136
15479
|
const z = plugin.external("zod.z");
|
|
15137
15480
|
const ctx = {
|
|
15138
15481
|
$,
|
|
15139
15482
|
chain: { current: $(z) },
|
|
15140
15483
|
nodes: { base: baseNode$16 },
|
|
15484
|
+
path,
|
|
15141
15485
|
plugin,
|
|
15142
15486
|
schema,
|
|
15143
15487
|
symbols: { z }
|
|
@@ -15175,7 +15519,7 @@ function unionResolver$1(ctx) {
|
|
|
15175
15519
|
ctx.chain.current = baseResult;
|
|
15176
15520
|
return ctx.chain.current;
|
|
15177
15521
|
}
|
|
15178
|
-
function unionToAst$1({ childResults, parentSchema, plugin, schemas }) {
|
|
15522
|
+
function unionToAst$1({ childResults, parentSchema, path, plugin, schemas }) {
|
|
15179
15523
|
const z = plugin.external("zod.z");
|
|
15180
15524
|
const ctx = {
|
|
15181
15525
|
$,
|
|
@@ -15183,6 +15527,7 @@ function unionToAst$1({ childResults, parentSchema, plugin, schemas }) {
|
|
|
15183
15527
|
childResults,
|
|
15184
15528
|
nodes: { base: baseNode$15 },
|
|
15185
15529
|
parentSchema,
|
|
15530
|
+
path,
|
|
15186
15531
|
plugin,
|
|
15187
15532
|
schema: parentSchema,
|
|
15188
15533
|
schemas,
|
|
@@ -15206,12 +15551,13 @@ function voidResolver$1(ctx) {
|
|
|
15206
15551
|
ctx.chain.current = baseResult;
|
|
15207
15552
|
return ctx.chain.current;
|
|
15208
15553
|
}
|
|
15209
|
-
function voidToAst$1({ plugin, schema }) {
|
|
15554
|
+
function voidToAst$1({ path, plugin, schema }) {
|
|
15210
15555
|
const z = plugin.external("zod.z");
|
|
15211
15556
|
const ctx = {
|
|
15212
15557
|
$,
|
|
15213
15558
|
chain: { current: $(z) },
|
|
15214
15559
|
nodes: { base: baseNode$14 },
|
|
15560
|
+
path,
|
|
15215
15561
|
plugin,
|
|
15216
15562
|
schema,
|
|
15217
15563
|
symbols: { z }
|
|
@@ -15220,7 +15566,7 @@ function voidToAst$1({ plugin, schema }) {
|
|
|
15220
15566
|
return resolver?.(ctx) ?? voidResolver$1(ctx);
|
|
15221
15567
|
}
|
|
15222
15568
|
//#endregion
|
|
15223
|
-
//#region src/plugins/zod/v3/
|
|
15569
|
+
//#region src/plugins/zod/v3/visitor.ts
|
|
15224
15570
|
function getDefaultValue$1(meta) {
|
|
15225
15571
|
return meta.format ? maybeBigInt(meta.default, meta.format) : $.fromValue(meta.default);
|
|
15226
15572
|
}
|
|
@@ -15246,10 +15592,10 @@ function createVisitor$1(config = {}) {
|
|
|
15246
15592
|
const applyModifiers = (result, opts) => this.applyModifiers(result, ctx, opts);
|
|
15247
15593
|
const { childResults, expression } = arrayToAst$1({
|
|
15248
15594
|
applyModifiers,
|
|
15595
|
+
path: ctx.path,
|
|
15249
15596
|
plugin: ctx.plugin,
|
|
15250
15597
|
schema,
|
|
15251
|
-
walk
|
|
15252
|
-
walkerCtx: ctx
|
|
15598
|
+
walk
|
|
15253
15599
|
});
|
|
15254
15600
|
return {
|
|
15255
15601
|
expression,
|
|
@@ -15259,6 +15605,7 @@ function createVisitor$1(config = {}) {
|
|
|
15259
15605
|
boolean(schema, ctx) {
|
|
15260
15606
|
return {
|
|
15261
15607
|
expression: booleanToAst$1({
|
|
15608
|
+
path: ctx.path,
|
|
15262
15609
|
plugin: ctx.plugin,
|
|
15263
15610
|
schema
|
|
15264
15611
|
}),
|
|
@@ -15267,6 +15614,7 @@ function createVisitor$1(config = {}) {
|
|
|
15267
15614
|
},
|
|
15268
15615
|
enum(schema, ctx) {
|
|
15269
15616
|
const expression = enumToAst$1({
|
|
15617
|
+
path: ctx.path,
|
|
15270
15618
|
plugin: ctx.plugin,
|
|
15271
15619
|
schema
|
|
15272
15620
|
});
|
|
@@ -15282,6 +15630,7 @@ function createVisitor$1(config = {}) {
|
|
|
15282
15630
|
integer(schema, ctx) {
|
|
15283
15631
|
return {
|
|
15284
15632
|
expression: numberToNode$1({
|
|
15633
|
+
path: ctx.path,
|
|
15285
15634
|
plugin: ctx.plugin,
|
|
15286
15635
|
schema
|
|
15287
15636
|
}),
|
|
@@ -15315,6 +15664,7 @@ function createVisitor$1(config = {}) {
|
|
|
15315
15664
|
const { expression } = intersectionToAst$1({
|
|
15316
15665
|
childResults: items,
|
|
15317
15666
|
parentSchema,
|
|
15667
|
+
path: ctx.path,
|
|
15318
15668
|
plugin: ctx.plugin,
|
|
15319
15669
|
schemas
|
|
15320
15670
|
});
|
|
@@ -15334,6 +15684,7 @@ function createVisitor$1(config = {}) {
|
|
|
15334
15684
|
never(schema, ctx) {
|
|
15335
15685
|
return {
|
|
15336
15686
|
expression: neverToAst$1({
|
|
15687
|
+
path: ctx.path,
|
|
15337
15688
|
plugin: ctx.plugin,
|
|
15338
15689
|
schema
|
|
15339
15690
|
}),
|
|
@@ -15347,6 +15698,7 @@ function createVisitor$1(config = {}) {
|
|
|
15347
15698
|
null(schema, ctx) {
|
|
15348
15699
|
return {
|
|
15349
15700
|
expression: nullToAst$1({
|
|
15701
|
+
path: ctx.path,
|
|
15350
15702
|
plugin: ctx.plugin,
|
|
15351
15703
|
schema
|
|
15352
15704
|
}),
|
|
@@ -15360,6 +15712,7 @@ function createVisitor$1(config = {}) {
|
|
|
15360
15712
|
number(schema, ctx) {
|
|
15361
15713
|
return {
|
|
15362
15714
|
expression: numberToNode$1({
|
|
15715
|
+
path: ctx.path,
|
|
15363
15716
|
plugin: ctx.plugin,
|
|
15364
15717
|
schema
|
|
15365
15718
|
}),
|
|
@@ -15373,10 +15726,10 @@ function createVisitor$1(config = {}) {
|
|
|
15373
15726
|
const applyModifiers = (result, opts) => this.applyModifiers(result, ctx, opts);
|
|
15374
15727
|
const { childResults, expression } = objectToAst$1({
|
|
15375
15728
|
applyModifiers,
|
|
15729
|
+
path: ctx.path,
|
|
15376
15730
|
plugin: ctx.plugin,
|
|
15377
15731
|
schema,
|
|
15378
|
-
walk
|
|
15379
|
-
walkerCtx: ctx
|
|
15732
|
+
walk
|
|
15380
15733
|
});
|
|
15381
15734
|
return {
|
|
15382
15735
|
expression,
|
|
@@ -15418,6 +15771,7 @@ function createVisitor$1(config = {}) {
|
|
|
15418
15771
|
string(schema, ctx) {
|
|
15419
15772
|
if (shouldCoerceToBigInt(schema.format)) return {
|
|
15420
15773
|
expression: numberToNode$1({
|
|
15774
|
+
path: ctx.path,
|
|
15421
15775
|
plugin: ctx.plugin,
|
|
15422
15776
|
schema: {
|
|
15423
15777
|
...schema,
|
|
@@ -15428,6 +15782,7 @@ function createVisitor$1(config = {}) {
|
|
|
15428
15782
|
};
|
|
15429
15783
|
return {
|
|
15430
15784
|
expression: stringToNode$1({
|
|
15785
|
+
path: ctx.path,
|
|
15431
15786
|
plugin: ctx.plugin,
|
|
15432
15787
|
schema
|
|
15433
15788
|
}),
|
|
@@ -15438,10 +15793,10 @@ function createVisitor$1(config = {}) {
|
|
|
15438
15793
|
const applyModifiers = (result, opts) => this.applyModifiers(result, ctx, opts);
|
|
15439
15794
|
const { childResults, expression } = tupleToAst$1({
|
|
15440
15795
|
applyModifiers,
|
|
15796
|
+
path: ctx.path,
|
|
15441
15797
|
plugin: ctx.plugin,
|
|
15442
15798
|
schema,
|
|
15443
|
-
walk
|
|
15444
|
-
walkerCtx: ctx
|
|
15799
|
+
walk
|
|
15445
15800
|
});
|
|
15446
15801
|
return {
|
|
15447
15802
|
expression,
|
|
@@ -15451,6 +15806,7 @@ function createVisitor$1(config = {}) {
|
|
|
15451
15806
|
undefined(schema, ctx) {
|
|
15452
15807
|
return {
|
|
15453
15808
|
expression: undefinedToAst$1({
|
|
15809
|
+
path: ctx.path,
|
|
15454
15810
|
plugin: ctx.plugin,
|
|
15455
15811
|
schema
|
|
15456
15812
|
}),
|
|
@@ -15467,6 +15823,7 @@ function createVisitor$1(config = {}) {
|
|
|
15467
15823
|
const { expression } = unionToAst$1({
|
|
15468
15824
|
childResults: items,
|
|
15469
15825
|
parentSchema,
|
|
15826
|
+
path: ctx.path,
|
|
15470
15827
|
plugin: ctx.plugin,
|
|
15471
15828
|
schemas
|
|
15472
15829
|
});
|
|
@@ -15486,6 +15843,7 @@ function createVisitor$1(config = {}) {
|
|
|
15486
15843
|
unknown(schema, ctx) {
|
|
15487
15844
|
return {
|
|
15488
15845
|
expression: unknownToAst$1({
|
|
15846
|
+
path: ctx.path,
|
|
15489
15847
|
plugin: ctx.plugin,
|
|
15490
15848
|
schema
|
|
15491
15849
|
}),
|
|
@@ -15499,6 +15857,7 @@ function createVisitor$1(config = {}) {
|
|
|
15499
15857
|
void(schema, ctx) {
|
|
15500
15858
|
return {
|
|
15501
15859
|
expression: voidToAst$1({
|
|
15860
|
+
path: ctx.path,
|
|
15502
15861
|
plugin: ctx.plugin,
|
|
15503
15862
|
schema
|
|
15504
15863
|
}),
|
|
@@ -15643,12 +16002,13 @@ function unknownResolver(ctx) {
|
|
|
15643
16002
|
ctx.chain.current = baseResult;
|
|
15644
16003
|
return ctx.chain.current;
|
|
15645
16004
|
}
|
|
15646
|
-
function unknownToAst({ plugin, schema }) {
|
|
16005
|
+
function unknownToAst({ path, plugin, schema }) {
|
|
15647
16006
|
const z = plugin.external("zod.z");
|
|
15648
16007
|
const ctx = {
|
|
15649
16008
|
$,
|
|
15650
16009
|
chain: { current: $(z) },
|
|
15651
16010
|
nodes: { base: baseNode$13 },
|
|
16011
|
+
path,
|
|
15652
16012
|
plugin,
|
|
15653
16013
|
schema,
|
|
15654
16014
|
symbols: { z }
|
|
@@ -15659,12 +16019,13 @@ function unknownToAst({ plugin, schema }) {
|
|
|
15659
16019
|
//#endregion
|
|
15660
16020
|
//#region src/plugins/zod/v4/toAst/array.ts
|
|
15661
16021
|
function baseNode$12(ctx) {
|
|
15662
|
-
const { applyModifiers, childResults, plugin, schema, symbols } = ctx;
|
|
16022
|
+
const { applyModifiers, childResults, path, plugin, schema, symbols } = ctx;
|
|
15663
16023
|
const { z } = symbols;
|
|
15664
16024
|
const arrayFn = $(z).attr(identifiers.array);
|
|
15665
16025
|
let normalizedSchema = schema;
|
|
15666
16026
|
if (normalizedSchema.items) normalizedSchema = deduplicateSchema({ schema: normalizedSchema });
|
|
15667
16027
|
if (!normalizedSchema.items) return arrayFn.call(unknownToAst({
|
|
16028
|
+
path,
|
|
15668
16029
|
plugin,
|
|
15669
16030
|
schema: { type: "unknown" }
|
|
15670
16031
|
}));
|
|
@@ -15686,6 +16047,7 @@ function baseNode$12(ctx) {
|
|
|
15686
16047
|
} else return arrayFn.call($(z).attr(identifiers.union).call($.array(...itemExpressions)));
|
|
15687
16048
|
}
|
|
15688
16049
|
return arrayFn.call(unknownToAst({
|
|
16050
|
+
path,
|
|
15689
16051
|
plugin,
|
|
15690
16052
|
schema: { type: "unknown" }
|
|
15691
16053
|
}));
|
|
@@ -15717,14 +16079,17 @@ function arrayResolver(ctx) {
|
|
|
15717
16079
|
}
|
|
15718
16080
|
return ctx.chain.current;
|
|
15719
16081
|
}
|
|
15720
|
-
function arrayToAst({ applyModifiers, plugin, schema, walk
|
|
16082
|
+
function arrayToAst({ applyModifiers, path, plugin, schema, walk }) {
|
|
15721
16083
|
const childResults = [];
|
|
15722
16084
|
let schemaCopy = schema;
|
|
15723
16085
|
const z = plugin.external("zod.z");
|
|
15724
16086
|
if (schemaCopy.items) {
|
|
15725
16087
|
schemaCopy = deduplicateSchema({ schema: schemaCopy });
|
|
15726
16088
|
schemaCopy.items.forEach((item, index) => {
|
|
15727
|
-
const itemResult = walk(item, childContext(
|
|
16089
|
+
const itemResult = walk(item, childContext({
|
|
16090
|
+
path,
|
|
16091
|
+
plugin
|
|
16092
|
+
}, "items", index));
|
|
15728
16093
|
childResults.push(itemResult);
|
|
15729
16094
|
});
|
|
15730
16095
|
}
|
|
@@ -15739,11 +16104,11 @@ function arrayToAst({ applyModifiers, plugin, schema, walk, walkerCtx }) {
|
|
|
15739
16104
|
maxLength: maxLengthNode$1,
|
|
15740
16105
|
minLength: minLengthNode$1
|
|
15741
16106
|
},
|
|
16107
|
+
path,
|
|
15742
16108
|
plugin,
|
|
15743
16109
|
schema,
|
|
15744
16110
|
symbols: { z },
|
|
15745
|
-
walk
|
|
15746
|
-
walkerCtx
|
|
16111
|
+
walk
|
|
15747
16112
|
};
|
|
15748
16113
|
const resolver = plugin.config["~resolvers"]?.array;
|
|
15749
16114
|
return {
|
|
@@ -15774,7 +16139,7 @@ function booleanResolver(ctx) {
|
|
|
15774
16139
|
ctx.chain.current = baseResult;
|
|
15775
16140
|
return ctx.chain.current;
|
|
15776
16141
|
}
|
|
15777
|
-
function booleanToAst({ plugin, schema }) {
|
|
16142
|
+
function booleanToAst({ path, plugin, schema }) {
|
|
15778
16143
|
const z = plugin.external("zod.z");
|
|
15779
16144
|
const ctx = {
|
|
15780
16145
|
$,
|
|
@@ -15783,6 +16148,7 @@ function booleanToAst({ plugin, schema }) {
|
|
|
15783
16148
|
base: baseNode$11,
|
|
15784
16149
|
const: constNode$3
|
|
15785
16150
|
},
|
|
16151
|
+
path,
|
|
15786
16152
|
plugin,
|
|
15787
16153
|
schema,
|
|
15788
16154
|
symbols: { z }
|
|
@@ -15796,45 +16162,48 @@ function itemsNode(ctx) {
|
|
|
15796
16162
|
const { schema, symbols } = ctx;
|
|
15797
16163
|
const { z } = symbols;
|
|
15798
16164
|
const enumMembers = [];
|
|
15799
|
-
const
|
|
15800
|
-
let isNullable = false;
|
|
15801
|
-
let allStrings = true;
|
|
16165
|
+
const literalSchemas = [];
|
|
15802
16166
|
for (const item of schema.items ?? []) if (item.type === "string" && typeof item.const === "string") {
|
|
15803
16167
|
const literal = $.literal(item.const);
|
|
15804
16168
|
enumMembers.push(literal);
|
|
15805
|
-
|
|
16169
|
+
literalSchemas.push($(z).attr(identifiers.literal).call(literal));
|
|
15806
16170
|
} else if ((item.type === "number" || item.type === "integer") && typeof item.const === "number") {
|
|
15807
|
-
allStrings = false;
|
|
15808
16171
|
const literal = $.literal(item.const);
|
|
15809
|
-
|
|
16172
|
+
literalSchemas.push($(z).attr(identifiers.literal).call(literal));
|
|
15810
16173
|
} else if (item.type === "boolean" && typeof item.const === "boolean") {
|
|
15811
|
-
allStrings = false;
|
|
15812
16174
|
const literal = $.literal(item.const);
|
|
15813
|
-
|
|
15814
|
-
}
|
|
16175
|
+
literalSchemas.push($(z).attr(identifiers.literal).call(literal));
|
|
16176
|
+
}
|
|
15815
16177
|
return {
|
|
15816
|
-
allStrings,
|
|
15817
16178
|
enumMembers,
|
|
15818
|
-
|
|
15819
|
-
literalMembers
|
|
16179
|
+
literalSchemas
|
|
15820
16180
|
};
|
|
15821
16181
|
}
|
|
15822
16182
|
function baseNode$10(ctx) {
|
|
16183
|
+
const { enumMembers, literalSchemas } = ctx.nodes.items(ctx);
|
|
16184
|
+
if (!literalSchemas.length) return unknownToAst({
|
|
16185
|
+
path: ctx.path,
|
|
16186
|
+
plugin: ctx.plugin,
|
|
16187
|
+
schema: { type: "unknown" }
|
|
16188
|
+
});
|
|
15823
16189
|
const { symbols } = ctx;
|
|
15824
16190
|
const { z } = symbols;
|
|
15825
|
-
const
|
|
15826
|
-
|
|
15827
|
-
|
|
15828
|
-
|
|
16191
|
+
const def = ctx.plugin.querySymbols({
|
|
16192
|
+
resource: "definition",
|
|
16193
|
+
resourceId: pathToJsonPointer(fromRef(ctx.path)),
|
|
16194
|
+
tool: "typescript"
|
|
16195
|
+
}).filter((symbol) => symbol.kind === "var" || symbol.kind === "enum" && !symbol.node.hasModifier("const"))[0];
|
|
16196
|
+
if (def) return $(z).attr(identifiers.enum).call(def);
|
|
16197
|
+
if (enumMembers.length > 0 && enumMembers.length === literalSchemas.length) return $(z).attr(identifiers.enum).call($.array(...enumMembers));
|
|
16198
|
+
if (literalSchemas.length === 1) return literalSchemas[0];
|
|
16199
|
+
return $(z).attr(identifiers.union).call($.array(...literalSchemas));
|
|
15829
16200
|
}
|
|
15830
16201
|
function enumResolver(ctx) {
|
|
15831
|
-
const { literalMembers } = ctx.nodes.items(ctx);
|
|
15832
|
-
if (!literalMembers.length) return ctx.chain.current;
|
|
15833
16202
|
const baseExpression = ctx.nodes.base(ctx);
|
|
15834
16203
|
ctx.chain.current = baseExpression;
|
|
15835
16204
|
return ctx.chain.current;
|
|
15836
16205
|
}
|
|
15837
|
-
function enumToAst({ plugin, schema }) {
|
|
16206
|
+
function enumToAst({ path, plugin, schema }) {
|
|
15838
16207
|
const z = plugin.external("zod.z");
|
|
15839
16208
|
const ctx = {
|
|
15840
16209
|
$,
|
|
@@ -15843,15 +16212,11 @@ function enumToAst({ plugin, schema }) {
|
|
|
15843
16212
|
base: baseNode$10,
|
|
15844
16213
|
items: itemsNode
|
|
15845
16214
|
},
|
|
16215
|
+
path,
|
|
15846
16216
|
plugin,
|
|
15847
16217
|
schema,
|
|
15848
16218
|
symbols: { z }
|
|
15849
16219
|
};
|
|
15850
|
-
const { literalMembers } = itemsNode(ctx);
|
|
15851
|
-
if (!literalMembers.length) return unknownToAst({
|
|
15852
|
-
plugin,
|
|
15853
|
-
schema: { type: "unknown" }
|
|
15854
|
-
});
|
|
15855
16220
|
const resolver = plugin.config["~resolvers"]?.enum;
|
|
15856
16221
|
return resolver?.(ctx) ?? enumResolver(ctx);
|
|
15857
16222
|
}
|
|
@@ -15874,7 +16239,7 @@ function intersectionResolver(ctx) {
|
|
|
15874
16239
|
ctx.chain.current = baseResult;
|
|
15875
16240
|
return ctx.chain.current;
|
|
15876
16241
|
}
|
|
15877
|
-
function intersectionToAst({ childResults, parentSchema, plugin, schemas }) {
|
|
16242
|
+
function intersectionToAst({ childResults, parentSchema, path, plugin, schemas }) {
|
|
15878
16243
|
const z = plugin.external("zod.z");
|
|
15879
16244
|
const ctx = {
|
|
15880
16245
|
$,
|
|
@@ -15882,6 +16247,7 @@ function intersectionToAst({ childResults, parentSchema, plugin, schemas }) {
|
|
|
15882
16247
|
childResults,
|
|
15883
16248
|
nodes: { base: baseNode$9 },
|
|
15884
16249
|
parentSchema,
|
|
16250
|
+
path,
|
|
15885
16251
|
plugin,
|
|
15886
16252
|
schema: parentSchema,
|
|
15887
16253
|
schemas,
|
|
@@ -15905,12 +16271,13 @@ function neverResolver(ctx) {
|
|
|
15905
16271
|
ctx.chain.current = baseResult;
|
|
15906
16272
|
return ctx.chain.current;
|
|
15907
16273
|
}
|
|
15908
|
-
function neverToAst({ plugin, schema }) {
|
|
16274
|
+
function neverToAst({ path, plugin, schema }) {
|
|
15909
16275
|
const z = plugin.external("zod.z");
|
|
15910
16276
|
const ctx = {
|
|
15911
16277
|
$,
|
|
15912
16278
|
chain: { current: $(z) },
|
|
15913
16279
|
nodes: { base: baseNode$8 },
|
|
16280
|
+
path,
|
|
15914
16281
|
plugin,
|
|
15915
16282
|
schema,
|
|
15916
16283
|
symbols: { z }
|
|
@@ -15930,12 +16297,13 @@ function nullResolver(ctx) {
|
|
|
15930
16297
|
ctx.chain.current = baseResult;
|
|
15931
16298
|
return ctx.chain.current;
|
|
15932
16299
|
}
|
|
15933
|
-
function nullToAst({ plugin, schema }) {
|
|
16300
|
+
function nullToAst({ path, plugin, schema }) {
|
|
15934
16301
|
const z = plugin.external("zod.z");
|
|
15935
16302
|
const ctx = {
|
|
15936
16303
|
$,
|
|
15937
16304
|
chain: { current: $(z) },
|
|
15938
16305
|
nodes: { base: baseNode$7 },
|
|
16306
|
+
path,
|
|
15939
16307
|
plugin,
|
|
15940
16308
|
schema,
|
|
15941
16309
|
symbols: { z }
|
|
@@ -15987,7 +16355,7 @@ function numberResolver(ctx) {
|
|
|
15987
16355
|
if (maxNode) ctx.chain.current = maxNode;
|
|
15988
16356
|
return ctx.chain.current;
|
|
15989
16357
|
}
|
|
15990
|
-
function numberToNode({ plugin, schema }) {
|
|
16358
|
+
function numberToNode({ path, plugin, schema }) {
|
|
15991
16359
|
const z = plugin.external("zod.z");
|
|
15992
16360
|
const ctx = {
|
|
15993
16361
|
$,
|
|
@@ -15998,6 +16366,7 @@ function numberToNode({ plugin, schema }) {
|
|
|
15998
16366
|
max: maxNode,
|
|
15999
16367
|
min: minNode
|
|
16000
16368
|
},
|
|
16369
|
+
path,
|
|
16001
16370
|
plugin,
|
|
16002
16371
|
schema,
|
|
16003
16372
|
symbols: { z },
|
|
@@ -16013,9 +16382,12 @@ function numberToNode({ plugin, schema }) {
|
|
|
16013
16382
|
//#endregion
|
|
16014
16383
|
//#region src/plugins/zod/v4/toAst/object.ts
|
|
16015
16384
|
function additionalPropertiesNode(ctx) {
|
|
16016
|
-
const { _childResults, applyModifiers, schema, walk
|
|
16385
|
+
const { _childResults, applyModifiers, path, plugin, schema, walk } = ctx;
|
|
16017
16386
|
if (!schema.additionalProperties || schema.properties && Object.keys(schema.properties).length) return;
|
|
16018
|
-
const additionalResult = walk(schema.additionalProperties, childContext(
|
|
16387
|
+
const additionalResult = walk(schema.additionalProperties, childContext({
|
|
16388
|
+
path,
|
|
16389
|
+
plugin
|
|
16390
|
+
}, "additionalProperties"));
|
|
16019
16391
|
_childResults.push(additionalResult);
|
|
16020
16392
|
return applyModifiers(additionalResult, {}).expression;
|
|
16021
16393
|
}
|
|
@@ -16031,20 +16403,22 @@ function objectResolver(ctx) {
|
|
|
16031
16403
|
return ctx.nodes.base(ctx);
|
|
16032
16404
|
}
|
|
16033
16405
|
function shapeNode(ctx) {
|
|
16034
|
-
const { _childResults, applyModifiers, schema, walk
|
|
16406
|
+
const { _childResults, applyModifiers, path, plugin, schema, walk } = ctx;
|
|
16035
16407
|
const shape = $.object().pretty();
|
|
16036
16408
|
for (const name in schema.properties) {
|
|
16037
16409
|
const property = schema.properties[name];
|
|
16038
16410
|
const isOptional = !schema.required?.includes(name);
|
|
16039
|
-
const propertyResult = walk(property, childContext(
|
|
16411
|
+
const propertyResult = walk(property, childContext({
|
|
16412
|
+
path,
|
|
16413
|
+
plugin
|
|
16414
|
+
}, "properties", name));
|
|
16040
16415
|
_childResults.push(propertyResult);
|
|
16041
16416
|
const finalExpr = applyModifiers(propertyResult, { optional: isOptional });
|
|
16042
16417
|
shape.prop(name, finalExpr.expression);
|
|
16043
16418
|
}
|
|
16044
16419
|
return shape;
|
|
16045
16420
|
}
|
|
16046
|
-
function objectToAst(
|
|
16047
|
-
const { applyModifiers, plugin, schema, walk, walkerCtx } = options;
|
|
16421
|
+
function objectToAst({ applyModifiers, path, plugin, schema, walk }) {
|
|
16048
16422
|
const childResults = [];
|
|
16049
16423
|
const z = plugin.external("zod.z");
|
|
16050
16424
|
const ctx = {
|
|
@@ -16057,11 +16431,11 @@ function objectToAst(options) {
|
|
|
16057
16431
|
base: baseNode$5,
|
|
16058
16432
|
shape: shapeNode
|
|
16059
16433
|
},
|
|
16434
|
+
path,
|
|
16060
16435
|
plugin,
|
|
16061
16436
|
schema,
|
|
16062
16437
|
symbols: { z },
|
|
16063
|
-
walk
|
|
16064
|
-
walkerCtx
|
|
16438
|
+
walk
|
|
16065
16439
|
};
|
|
16066
16440
|
const resolver = plugin.config["~resolvers"]?.object;
|
|
16067
16441
|
return {
|
|
@@ -16142,7 +16516,7 @@ function stringResolver(ctx) {
|
|
|
16142
16516
|
if (patternNode) ctx.chain.current = patternNode;
|
|
16143
16517
|
return ctx.chain.current;
|
|
16144
16518
|
}
|
|
16145
|
-
function stringToNode({ plugin, schema }) {
|
|
16519
|
+
function stringToNode({ path, plugin, schema }) {
|
|
16146
16520
|
const z = plugin.external("zod.z");
|
|
16147
16521
|
const ctx = {
|
|
16148
16522
|
$,
|
|
@@ -16156,6 +16530,7 @@ function stringToNode({ plugin, schema }) {
|
|
|
16156
16530
|
minLength: minLengthNode,
|
|
16157
16531
|
pattern: patternNode
|
|
16158
16532
|
},
|
|
16533
|
+
path,
|
|
16159
16534
|
plugin,
|
|
16160
16535
|
schema,
|
|
16161
16536
|
symbols: { z }
|
|
@@ -16190,11 +16565,14 @@ function tupleResolver(ctx) {
|
|
|
16190
16565
|
ctx.chain.current = baseResult;
|
|
16191
16566
|
return ctx.chain.current;
|
|
16192
16567
|
}
|
|
16193
|
-
function tupleToAst({ applyModifiers, plugin, schema, walk
|
|
16568
|
+
function tupleToAst({ applyModifiers, path, plugin, schema, walk }) {
|
|
16194
16569
|
const childResults = [];
|
|
16195
16570
|
const z = plugin.external("zod.z");
|
|
16196
16571
|
if (schema.items) schema.items.forEach((item, index) => {
|
|
16197
|
-
const itemResult = walk(item, childContext(
|
|
16572
|
+
const itemResult = walk(item, childContext({
|
|
16573
|
+
path,
|
|
16574
|
+
plugin
|
|
16575
|
+
}, "items", index));
|
|
16198
16576
|
childResults.push(itemResult);
|
|
16199
16577
|
});
|
|
16200
16578
|
const ctx = {
|
|
@@ -16206,11 +16584,11 @@ function tupleToAst({ applyModifiers, plugin, schema, walk, walkerCtx }) {
|
|
|
16206
16584
|
base: baseNode$3,
|
|
16207
16585
|
const: constNode
|
|
16208
16586
|
},
|
|
16587
|
+
path,
|
|
16209
16588
|
plugin,
|
|
16210
16589
|
schema,
|
|
16211
16590
|
symbols: { z },
|
|
16212
|
-
walk
|
|
16213
|
-
walkerCtx
|
|
16591
|
+
walk
|
|
16214
16592
|
};
|
|
16215
16593
|
const resolver = plugin.config["~resolvers"]?.tuple;
|
|
16216
16594
|
return {
|
|
@@ -16230,12 +16608,13 @@ function undefinedResolver(ctx) {
|
|
|
16230
16608
|
ctx.chain.current = baseResult;
|
|
16231
16609
|
return ctx.chain.current;
|
|
16232
16610
|
}
|
|
16233
|
-
function undefinedToAst({ plugin, schema }) {
|
|
16611
|
+
function undefinedToAst({ path, plugin, schema }) {
|
|
16234
16612
|
const z = plugin.external("zod.z");
|
|
16235
16613
|
const ctx = {
|
|
16236
16614
|
$,
|
|
16237
16615
|
chain: { current: $(z) },
|
|
16238
16616
|
nodes: { base: baseNode$2 },
|
|
16617
|
+
path,
|
|
16239
16618
|
plugin,
|
|
16240
16619
|
schema,
|
|
16241
16620
|
symbols: { z }
|
|
@@ -16276,7 +16655,7 @@ function unionResolver(ctx) {
|
|
|
16276
16655
|
ctx.chain.current = baseResult;
|
|
16277
16656
|
return ctx.chain.current;
|
|
16278
16657
|
}
|
|
16279
|
-
function unionToAst({ childResults, parentSchema, plugin, schemas }) {
|
|
16658
|
+
function unionToAst({ childResults, parentSchema, path, plugin, schemas }) {
|
|
16280
16659
|
const z = plugin.external("zod.z");
|
|
16281
16660
|
const ctx = {
|
|
16282
16661
|
$,
|
|
@@ -16284,6 +16663,7 @@ function unionToAst({ childResults, parentSchema, plugin, schemas }) {
|
|
|
16284
16663
|
childResults,
|
|
16285
16664
|
nodes: { base: baseNode$1 },
|
|
16286
16665
|
parentSchema,
|
|
16666
|
+
path,
|
|
16287
16667
|
plugin,
|
|
16288
16668
|
schema: parentSchema,
|
|
16289
16669
|
schemas,
|
|
@@ -16307,12 +16687,13 @@ function voidResolver(ctx) {
|
|
|
16307
16687
|
ctx.chain.current = baseResult;
|
|
16308
16688
|
return ctx.chain.current;
|
|
16309
16689
|
}
|
|
16310
|
-
function voidToAst({ plugin, schema }) {
|
|
16690
|
+
function voidToAst({ path, plugin, schema }) {
|
|
16311
16691
|
const z = plugin.external("zod.z");
|
|
16312
16692
|
const ctx = {
|
|
16313
16693
|
$,
|
|
16314
16694
|
chain: { current: $(z) },
|
|
16315
16695
|
nodes: { base: baseNode },
|
|
16696
|
+
path,
|
|
16316
16697
|
plugin,
|
|
16317
16698
|
schema,
|
|
16318
16699
|
symbols: { z }
|
|
@@ -16321,7 +16702,7 @@ function voidToAst({ plugin, schema }) {
|
|
|
16321
16702
|
return resolver?.(ctx) ?? voidResolver(ctx);
|
|
16322
16703
|
}
|
|
16323
16704
|
//#endregion
|
|
16324
|
-
//#region src/plugins/zod/v4/
|
|
16705
|
+
//#region src/plugins/zod/v4/visitor.ts
|
|
16325
16706
|
function getDefaultValue(meta) {
|
|
16326
16707
|
return meta.format ? maybeBigInt(meta.default, meta.format) : $.fromValue(meta.default);
|
|
16327
16708
|
}
|
|
@@ -16344,10 +16725,10 @@ function createVisitor(config = {}) {
|
|
|
16344
16725
|
const applyModifiers = (result, opts) => this.applyModifiers(result, ctx, opts);
|
|
16345
16726
|
const { childResults, expression } = arrayToAst({
|
|
16346
16727
|
applyModifiers,
|
|
16728
|
+
path: ctx.path,
|
|
16347
16729
|
plugin: ctx.plugin,
|
|
16348
16730
|
schema,
|
|
16349
|
-
walk
|
|
16350
|
-
walkerCtx: ctx
|
|
16731
|
+
walk
|
|
16351
16732
|
});
|
|
16352
16733
|
return {
|
|
16353
16734
|
expression,
|
|
@@ -16357,6 +16738,7 @@ function createVisitor(config = {}) {
|
|
|
16357
16738
|
boolean(schema, ctx) {
|
|
16358
16739
|
return {
|
|
16359
16740
|
expression: booleanToAst({
|
|
16741
|
+
path: ctx.path,
|
|
16360
16742
|
plugin: ctx.plugin,
|
|
16361
16743
|
schema
|
|
16362
16744
|
}),
|
|
@@ -16365,6 +16747,7 @@ function createVisitor(config = {}) {
|
|
|
16365
16747
|
},
|
|
16366
16748
|
enum(schema, ctx) {
|
|
16367
16749
|
const expression = enumToAst({
|
|
16750
|
+
path: ctx.path,
|
|
16368
16751
|
plugin: ctx.plugin,
|
|
16369
16752
|
schema
|
|
16370
16753
|
});
|
|
@@ -16380,6 +16763,7 @@ function createVisitor(config = {}) {
|
|
|
16380
16763
|
integer(schema, ctx) {
|
|
16381
16764
|
return {
|
|
16382
16765
|
expression: numberToNode({
|
|
16766
|
+
path: ctx.path,
|
|
16383
16767
|
plugin: ctx.plugin,
|
|
16384
16768
|
schema
|
|
16385
16769
|
}),
|
|
@@ -16413,6 +16797,7 @@ function createVisitor(config = {}) {
|
|
|
16413
16797
|
const { expression } = intersectionToAst({
|
|
16414
16798
|
childResults: items,
|
|
16415
16799
|
parentSchema,
|
|
16800
|
+
path: ctx.path,
|
|
16416
16801
|
plugin: ctx.plugin,
|
|
16417
16802
|
schemas
|
|
16418
16803
|
});
|
|
@@ -16432,6 +16817,7 @@ function createVisitor(config = {}) {
|
|
|
16432
16817
|
never(schema, ctx) {
|
|
16433
16818
|
return {
|
|
16434
16819
|
expression: neverToAst({
|
|
16820
|
+
path: ctx.path,
|
|
16435
16821
|
plugin: ctx.plugin,
|
|
16436
16822
|
schema
|
|
16437
16823
|
}),
|
|
@@ -16445,6 +16831,7 @@ function createVisitor(config = {}) {
|
|
|
16445
16831
|
null(schema, ctx) {
|
|
16446
16832
|
return {
|
|
16447
16833
|
expression: nullToAst({
|
|
16834
|
+
path: ctx.path,
|
|
16448
16835
|
plugin: ctx.plugin,
|
|
16449
16836
|
schema
|
|
16450
16837
|
}),
|
|
@@ -16458,6 +16845,7 @@ function createVisitor(config = {}) {
|
|
|
16458
16845
|
number(schema, ctx) {
|
|
16459
16846
|
return {
|
|
16460
16847
|
expression: numberToNode({
|
|
16848
|
+
path: ctx.path,
|
|
16461
16849
|
plugin: ctx.plugin,
|
|
16462
16850
|
schema
|
|
16463
16851
|
}),
|
|
@@ -16471,10 +16859,10 @@ function createVisitor(config = {}) {
|
|
|
16471
16859
|
const applyModifiers = (result, opts) => this.applyModifiers(result, ctx, opts);
|
|
16472
16860
|
const { childResults, expression } = objectToAst({
|
|
16473
16861
|
applyModifiers,
|
|
16862
|
+
path: ctx.path,
|
|
16474
16863
|
plugin: ctx.plugin,
|
|
16475
16864
|
schema,
|
|
16476
|
-
walk
|
|
16477
|
-
walkerCtx: ctx
|
|
16865
|
+
walk
|
|
16478
16866
|
});
|
|
16479
16867
|
return {
|
|
16480
16868
|
expression,
|
|
@@ -16525,6 +16913,7 @@ function createVisitor(config = {}) {
|
|
|
16525
16913
|
string(schema, ctx) {
|
|
16526
16914
|
if (shouldCoerceToBigInt(schema.format)) return {
|
|
16527
16915
|
expression: numberToNode({
|
|
16916
|
+
path: ctx.path,
|
|
16528
16917
|
plugin: ctx.plugin,
|
|
16529
16918
|
schema: {
|
|
16530
16919
|
...schema,
|
|
@@ -16535,6 +16924,7 @@ function createVisitor(config = {}) {
|
|
|
16535
16924
|
};
|
|
16536
16925
|
return {
|
|
16537
16926
|
expression: stringToNode({
|
|
16927
|
+
path: ctx.path,
|
|
16538
16928
|
plugin: ctx.plugin,
|
|
16539
16929
|
schema
|
|
16540
16930
|
}),
|
|
@@ -16545,10 +16935,10 @@ function createVisitor(config = {}) {
|
|
|
16545
16935
|
const applyModifiers = (result, opts) => this.applyModifiers(result, ctx, opts);
|
|
16546
16936
|
const { childResults, expression } = tupleToAst({
|
|
16547
16937
|
applyModifiers,
|
|
16938
|
+
path: ctx.path,
|
|
16548
16939
|
plugin: ctx.plugin,
|
|
16549
16940
|
schema,
|
|
16550
|
-
walk
|
|
16551
|
-
walkerCtx: ctx
|
|
16941
|
+
walk
|
|
16552
16942
|
});
|
|
16553
16943
|
return {
|
|
16554
16944
|
expression,
|
|
@@ -16558,6 +16948,7 @@ function createVisitor(config = {}) {
|
|
|
16558
16948
|
undefined(schema, ctx) {
|
|
16559
16949
|
return {
|
|
16560
16950
|
expression: undefinedToAst({
|
|
16951
|
+
path: ctx.path,
|
|
16561
16952
|
plugin: ctx.plugin,
|
|
16562
16953
|
schema
|
|
16563
16954
|
}),
|
|
@@ -16574,6 +16965,7 @@ function createVisitor(config = {}) {
|
|
|
16574
16965
|
const { expression } = unionToAst({
|
|
16575
16966
|
childResults: items,
|
|
16576
16967
|
parentSchema,
|
|
16968
|
+
path: ctx.path,
|
|
16577
16969
|
plugin: ctx.plugin,
|
|
16578
16970
|
schemas
|
|
16579
16971
|
});
|
|
@@ -16593,6 +16985,7 @@ function createVisitor(config = {}) {
|
|
|
16593
16985
|
unknown(schema, ctx) {
|
|
16594
16986
|
return {
|
|
16595
16987
|
expression: unknownToAst({
|
|
16988
|
+
path: ctx.path,
|
|
16596
16989
|
plugin: ctx.plugin,
|
|
16597
16990
|
schema
|
|
16598
16991
|
}),
|
|
@@ -16606,6 +16999,7 @@ function createVisitor(config = {}) {
|
|
|
16606
16999
|
void(schema, ctx) {
|
|
16607
17000
|
return {
|
|
16608
17001
|
expression: voidToAst({
|
|
17002
|
+
path: ctx.path,
|
|
16609
17003
|
plugin: ctx.plugin,
|
|
16610
17004
|
schema
|
|
16611
17005
|
}),
|
|
@@ -17319,7 +17713,7 @@ const defaultConfig = {
|
|
|
17319
17713
|
value: plugin.config.webhooks
|
|
17320
17714
|
});
|
|
17321
17715
|
},
|
|
17322
|
-
tags: ["validator"]
|
|
17716
|
+
tags: ["transformer", "validator"]
|
|
17323
17717
|
};
|
|
17324
17718
|
definePluginConfig(defaultConfig);
|
|
17325
17719
|
//#endregion
|
|
@@ -17530,4 +17924,4 @@ async function resolveJobs({ logger, userConfigs }) {
|
|
|
17530
17924
|
//#endregion
|
|
17531
17925
|
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 };
|
|
17532
17926
|
|
|
17533
|
-
//# sourceMappingURL=init-
|
|
17927
|
+
//# sourceMappingURL=init-CitwzRmB.mjs.map
|