@hey-api/openapi-ts 0.97.0 → 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 +419 -208
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/{init-EigcXVTH.mjs → init-CitwzRmB.mjs} +751 -356
- package/dist/init-CitwzRmB.mjs.map +1 -0
- package/dist/internal.mjs +1 -1
- package/dist/run.mjs +2 -2
- package/dist/{src-ErSC87Z1.mjs → src-DEol_iHK.mjs} +2 -2
- package/dist/{src-ErSC87Z1.mjs.map → src-DEol_iHK.mjs.map} +1 -1
- package/package.json +4 -4
- package/dist/init-EigcXVTH.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) {
|
|
@@ -3178,8 +3179,8 @@ var ImplForTsDsl = class extends Mixed$20 {
|
|
|
3178
3179
|
analyze(ctx) {
|
|
3179
3180
|
ctx.analyze(this._condition);
|
|
3180
3181
|
ctx.analyze(this._iterableOrUpdate);
|
|
3181
|
-
ctx.analyze(this._variableOrInit);
|
|
3182
3182
|
ctx.pushScope();
|
|
3183
|
+
ctx.analyze(this._variableOrInit);
|
|
3183
3184
|
try {
|
|
3184
3185
|
super.analyze(ctx);
|
|
3185
3186
|
} finally {
|
|
@@ -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
|
|
@@ -6451,14 +6485,15 @@ function processSchemaType({ dataExpression, plugin, schema }) {
|
|
|
6451
6485
|
else nodes.push($.if(propertyAccessExpression).do(...propertyNodes));
|
|
6452
6486
|
}
|
|
6453
6487
|
if (schema.additionalProperties && dataExpression) {
|
|
6488
|
+
const key = plugin.symbol("key");
|
|
6454
6489
|
const entryValueNodes = processSchemaType({
|
|
6455
|
-
dataExpression: $(dataExpression).attr(
|
|
6490
|
+
dataExpression: $(dataExpression).attr(key).computed(),
|
|
6456
6491
|
plugin,
|
|
6457
6492
|
schema: schema.additionalProperties
|
|
6458
6493
|
});
|
|
6459
6494
|
if (entryValueNodes.length) {
|
|
6460
6495
|
const properties = Object.keys(schema.properties ?? {});
|
|
6461
|
-
nodes.push($.for($.const(
|
|
6496
|
+
nodes.push($.for($.const(key)).of($("Object").attr("keys").call(dataExpression)).$if(properties.length, (f) => f.do($.if($.not($.array(...properties).attr("includes").call(key))).do(...entryValueNodes)), (f) => f.do(...entryValueNodes)));
|
|
6462
6497
|
}
|
|
6463
6498
|
}
|
|
6464
6499
|
return nodes;
|
|
@@ -6589,7 +6624,14 @@ const createSchemaComment = (schema) => {
|
|
|
6589
6624
|
return comments.length ? comments : void 0;
|
|
6590
6625
|
};
|
|
6591
6626
|
//#endregion
|
|
6592
|
-
//#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
|
+
}
|
|
6593
6635
|
function resolveEnumKey({ baseName, duplicateAttempt, plugin }) {
|
|
6594
6636
|
let key = toCase(baseName, plugin.config.enums.case, { stripLeadingSeparators: false });
|
|
6595
6637
|
regexp.number.lastIndex = 0;
|
|
@@ -6601,59 +6643,57 @@ function resolveEnumKey({ baseName, duplicateAttempt, plugin }) {
|
|
|
6601
6643
|
attempt: duplicateAttempt,
|
|
6602
6644
|
baseName: key
|
|
6603
6645
|
});
|
|
6604
|
-
|
|
6605
|
-
else key = `${key}${duplicateAttempt + 1}`;
|
|
6646
|
+
key = resolvedName !== null ? resolvedName : `${key}${duplicateAttempt + 1}`;
|
|
6606
6647
|
} else key = `${key}${duplicateAttempt + 1}`;
|
|
6607
6648
|
}
|
|
6608
6649
|
return key;
|
|
6609
6650
|
}
|
|
6610
|
-
function
|
|
6611
|
-
if (!enumData || enumData.mode === "type") return false;
|
|
6612
|
-
const mode = enumData.mode;
|
|
6613
|
-
const items = enumData.items;
|
|
6651
|
+
function resolveItemsWithKeys(items, plugin) {
|
|
6614
6652
|
const duplicateCounts = {};
|
|
6615
|
-
|
|
6616
|
-
const
|
|
6617
|
-
|
|
6618
|
-
|
|
6653
|
+
return items.map((item) => {
|
|
6654
|
+
const baseKey = resolveEnumKey({
|
|
6655
|
+
baseName: item.key,
|
|
6656
|
+
duplicateAttempt: 0,
|
|
6657
|
+
plugin
|
|
6658
|
+
});
|
|
6619
6659
|
const duplicateAttempt = duplicateCounts[baseKey] ?? 0;
|
|
6620
6660
|
duplicateCounts[baseKey] = duplicateAttempt + 1;
|
|
6621
6661
|
return {
|
|
6622
|
-
|
|
6623
|
-
|
|
6624
|
-
|
|
6662
|
+
item,
|
|
6663
|
+
key: duplicateAttempt === 0 ? baseKey : resolveEnumKey({
|
|
6664
|
+
baseName: item.key,
|
|
6665
|
+
duplicateAttempt,
|
|
6666
|
+
plugin
|
|
6667
|
+
})
|
|
6625
6668
|
};
|
|
6626
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);
|
|
6627
6675
|
if (mode === "javascript") {
|
|
6628
6676
|
const filteredItems = plugin.config.enums.constantsIgnoreNull && items.some((item) => item.schema.const === null) ? items.filter((item) => item.schema.const !== null) : items;
|
|
6629
6677
|
const symbolObject = plugin.registerSymbol(buildSymbolIn({
|
|
6630
|
-
meta: {
|
|
6678
|
+
meta: createSymbolMeta({
|
|
6631
6679
|
category: "utility",
|
|
6632
|
-
|
|
6633
|
-
|
|
6634
|
-
tool: "typescript"
|
|
6635
|
-
},
|
|
6680
|
+
resourceId
|
|
6681
|
+
}),
|
|
6636
6682
|
name,
|
|
6637
6683
|
naming: plugin.config.definitions,
|
|
6638
6684
|
plugin,
|
|
6639
6685
|
schema
|
|
6640
6686
|
}));
|
|
6641
|
-
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({
|
|
6642
6688
|
kind: "prop",
|
|
6643
|
-
name:
|
|
6644
|
-
baseName: item.key,
|
|
6645
|
-
duplicateAttempt,
|
|
6646
|
-
plugin
|
|
6647
|
-
})
|
|
6689
|
+
name: key
|
|
6648
6690
|
}).$if(plugin.config.comments && createSchemaComment(item.schema), (p, v) => p.doc(v)).value($.fromValue(item.schema.const)))).as("const"));
|
|
6649
6691
|
plugin.node(objectNode);
|
|
6650
6692
|
const symbol = plugin.registerSymbol(buildSymbolIn({
|
|
6651
|
-
meta: {
|
|
6693
|
+
meta: createSymbolMeta({
|
|
6652
6694
|
category: "type",
|
|
6653
|
-
|
|
6654
|
-
|
|
6655
|
-
tool: "typescript"
|
|
6656
|
-
},
|
|
6695
|
+
resourceId
|
|
6696
|
+
}),
|
|
6657
6697
|
name,
|
|
6658
6698
|
naming: plugin.config.definitions,
|
|
6659
6699
|
plugin,
|
|
@@ -6666,31 +6706,27 @@ function buildEnumExport({ enumData, name, plugin, resourceId, schema }) {
|
|
|
6666
6706
|
if (mode === "typescript" || mode === "typescript-const") {
|
|
6667
6707
|
if (items.some((item) => typeof item.schema.const !== "number" && typeof item.schema.const !== "string")) return false;
|
|
6668
6708
|
const symbol = plugin.registerSymbol(buildSymbolIn({
|
|
6669
|
-
meta: {
|
|
6709
|
+
meta: createSymbolMeta({
|
|
6670
6710
|
category: "type",
|
|
6671
|
-
|
|
6672
|
-
|
|
6673
|
-
tool: "typescript"
|
|
6674
|
-
},
|
|
6711
|
+
resourceId
|
|
6712
|
+
}),
|
|
6675
6713
|
name,
|
|
6676
6714
|
naming: plugin.config.definitions,
|
|
6677
6715
|
plugin,
|
|
6678
6716
|
schema
|
|
6679
6717
|
}));
|
|
6680
|
-
const enumNode = $.enum(symbol).export().$if(plugin.config.comments && createSchemaComment(schema), (e, v) => e.doc(v)).const(mode === "typescript-const").members(...
|
|
6681
|
-
baseName: item.key,
|
|
6682
|
-
duplicateAttempt,
|
|
6683
|
-
plugin
|
|
6684
|
-
})).$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))));
|
|
6685
6719
|
plugin.node(enumNode);
|
|
6686
6720
|
return true;
|
|
6687
6721
|
}
|
|
6688
6722
|
return false;
|
|
6689
6723
|
}
|
|
6724
|
+
//#endregion
|
|
6725
|
+
//#region src/plugins/@hey-api/typescript/shared/export.ts
|
|
6690
6726
|
function exportAst$3({ final, meta, naming, namingAnchor, path, plugin, schema, tags }) {
|
|
6691
6727
|
const $ref = meta.resourceId || pathToJsonPointer(path);
|
|
6692
6728
|
const name = pathToName(path, { anchor: namingAnchor });
|
|
6693
|
-
if (
|
|
6729
|
+
if (exportEnumAst({
|
|
6694
6730
|
enumData: final.enumData,
|
|
6695
6731
|
name,
|
|
6696
6732
|
plugin,
|
|
@@ -7227,7 +7263,7 @@ function voidToAst$3({ plugin, schema }) {
|
|
|
7227
7263
|
return resolver?.(ctx) ?? voidResolver$4(ctx);
|
|
7228
7264
|
}
|
|
7229
7265
|
//#endregion
|
|
7230
|
-
//#region src/plugins/@hey-api/typescript/v1/
|
|
7266
|
+
//#region src/plugins/@hey-api/typescript/v1/visitor.ts
|
|
7231
7267
|
function createVisitor$4(config = {}) {
|
|
7232
7268
|
const { schemaExtractor } = config;
|
|
7233
7269
|
return {
|
|
@@ -8052,7 +8088,7 @@ const createMutationOptions$1 = ({ operation, plugin }) => {
|
|
|
8052
8088
|
};
|
|
8053
8089
|
//#endregion
|
|
8054
8090
|
//#region src/plugins/@pinia/colada/queryKey.ts
|
|
8055
|
-
const TOptionsType$
|
|
8091
|
+
const TOptionsType$2 = "TOptions";
|
|
8056
8092
|
const createQueryKeyFunction$1 = ({ plugin }) => {
|
|
8057
8093
|
const symbolCreateQueryKey = plugin.symbol(applyNaming("createQueryKey", { case: plugin.config.case }), { meta: {
|
|
8058
8094
|
category: "utility",
|
|
@@ -8065,7 +8101,7 @@ const createQueryKeyFunction$1 = ({ plugin }) => {
|
|
|
8065
8101
|
tool: plugin.name
|
|
8066
8102
|
});
|
|
8067
8103
|
const symbolJsonValue = plugin.external(`${plugin.name}._JSONValue`);
|
|
8068
|
-
const returnType = $.type(symbolQueryKeyType).generic(TOptionsType$
|
|
8104
|
+
const returnType = $.type(symbolQueryKeyType).generic(TOptionsType$2).idx(0);
|
|
8069
8105
|
const baseUrlKey = getClientBaseUrlKey(getTypedConfig(plugin));
|
|
8070
8106
|
const symbolOptions = plugin.referenceSymbol({
|
|
8071
8107
|
category: "type",
|
|
@@ -8075,7 +8111,7 @@ const createQueryKeyFunction$1 = ({ plugin }) => {
|
|
|
8075
8111
|
const symbolClient = plugin.querySymbol({ category: "client" });
|
|
8076
8112
|
const clientModule = clientFolderAbsolutePath(getTypedConfig(plugin));
|
|
8077
8113
|
const symbolSerializeQueryValue = plugin.symbol("serializeQueryKeyValue", { external: clientModule });
|
|
8078
|
-
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")))));
|
|
8079
8115
|
plugin.node(fn);
|
|
8080
8116
|
};
|
|
8081
8117
|
const createQueryKeyLiteral$1 = ({ id, operation, plugin }) => {
|
|
@@ -8100,7 +8136,7 @@ const createQueryKeyType$1 = ({ plugin }) => {
|
|
|
8100
8136
|
resource: "QueryKey",
|
|
8101
8137
|
tool: plugin.name
|
|
8102
8138
|
} });
|
|
8103
|
-
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)))));
|
|
8104
8140
|
plugin.node(queryKeyType);
|
|
8105
8141
|
};
|
|
8106
8142
|
const queryKeyStatement$1 = ({ operation, plugin, symbol }) => {
|
|
@@ -8298,8 +8334,8 @@ const useTypeResponse = ({ operation, plugin }) => {
|
|
|
8298
8334
|
};
|
|
8299
8335
|
//#endregion
|
|
8300
8336
|
//#region src/plugins/@tanstack/query-core/queryKey.ts
|
|
8301
|
-
const TOptionsType = "TOptions";
|
|
8302
|
-
|
|
8337
|
+
const TOptionsType$1 = "TOptions";
|
|
8338
|
+
function createQueryKeyFunction({ plugin }) {
|
|
8303
8339
|
const symbolCreateQueryKey = plugin.symbol(applyNaming("createQueryKey", { case: plugin.config.case }), { meta: {
|
|
8304
8340
|
category: "utility",
|
|
8305
8341
|
resource: "createQueryKey",
|
|
@@ -8317,11 +8353,11 @@ const createQueryKeyFunction = ({ plugin }) => {
|
|
|
8317
8353
|
resource: "client-options",
|
|
8318
8354
|
tool: "sdk"
|
|
8319
8355
|
});
|
|
8320
|
-
const returnType = $.type(symbolQueryKeyType).generic(TOptionsType).idx(0);
|
|
8321
|
-
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")))));
|
|
8322
8358
|
plugin.node(fn);
|
|
8323
|
-
}
|
|
8324
|
-
|
|
8359
|
+
}
|
|
8360
|
+
function createQueryKeyLiteral({ id, isInfinite, operation, plugin }) {
|
|
8325
8361
|
const config = isInfinite ? plugin.config.infiniteQueryKeys : plugin.config.queryKeys;
|
|
8326
8362
|
let tagsArray;
|
|
8327
8363
|
if (config.tags && operation.tags && operation.tags.length) tagsArray = $.array().elements(...operation.tags);
|
|
@@ -8330,8 +8366,8 @@ const createQueryKeyLiteral = ({ id, isInfinite, operation, plugin }) => {
|
|
|
8330
8366
|
resource: "createQueryKey",
|
|
8331
8367
|
tool: plugin.name
|
|
8332
8368
|
})).call($.literal(id), "options", isInfinite || tagsArray ? $.literal(Boolean(isInfinite)) : void 0, tagsArray);
|
|
8333
|
-
}
|
|
8334
|
-
|
|
8369
|
+
}
|
|
8370
|
+
function createQueryKeyType({ plugin }) {
|
|
8335
8371
|
const symbolOptions = plugin.referenceSymbol({
|
|
8336
8372
|
category: "type",
|
|
8337
8373
|
resource: "client-options",
|
|
@@ -8342,10 +8378,10 @@ const createQueryKeyType = ({ plugin }) => {
|
|
|
8342
8378
|
resource: "QueryKey",
|
|
8343
8379
|
tool: plugin.name
|
|
8344
8380
|
} });
|
|
8345
|
-
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>")))));
|
|
8346
8382
|
plugin.node(queryKeyType);
|
|
8347
|
-
}
|
|
8348
|
-
|
|
8383
|
+
}
|
|
8384
|
+
function queryKeyStatement({ isInfinite, operation, plugin, symbol, typeQueryKey }) {
|
|
8349
8385
|
const typeData = useTypeData({
|
|
8350
8386
|
operation,
|
|
8351
8387
|
plugin
|
|
@@ -8356,7 +8392,7 @@ const queryKeyStatement = ({ isInfinite, operation, plugin, symbol, typeQueryKey
|
|
|
8356
8392
|
operation,
|
|
8357
8393
|
plugin
|
|
8358
8394
|
}).return()));
|
|
8359
|
-
}
|
|
8395
|
+
}
|
|
8360
8396
|
//#endregion
|
|
8361
8397
|
//#region src/plugins/@tanstack/query-core/shared/meta.ts
|
|
8362
8398
|
const handleMeta = (plugin, operation, configPath) => {
|
|
@@ -8449,9 +8485,77 @@ function createInfiniteQueryOptions({ operation, plugin }) {
|
|
|
8449
8485
|
plugin.node(statement);
|
|
8450
8486
|
}
|
|
8451
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
|
|
8452
8548
|
//#region src/plugins/@tanstack/query-core/v5/mutationOptions.ts
|
|
8453
8549
|
function createMutationOptions({ operation, plugin }) {
|
|
8454
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
|
+
}
|
|
8455
8559
|
const symbolMutationOptionsType = plugin.external(`${plugin.name}.MutationOptions`);
|
|
8456
8560
|
const typeData = useTypeData({
|
|
8457
8561
|
operation,
|
|
@@ -8473,6 +8577,16 @@ function createMutationOptions({ operation, plugin }) {
|
|
|
8473
8577
|
const statements = [];
|
|
8474
8578
|
if (plugin.getPluginOrThrow("@hey-api/sdk").config.responseStyle === "data") statements.push($.return(awaitSdkFn));
|
|
8475
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
|
+
}
|
|
8476
8590
|
const mutationOptionsFn = "mutationOptions";
|
|
8477
8591
|
const symbolMutationOptions = plugin.symbol(applyNaming(operation.id, plugin.config.mutationOptions), { meta: {
|
|
8478
8592
|
category: "hook",
|
|
@@ -8481,7 +8595,7 @@ function createMutationOptions({ operation, plugin }) {
|
|
|
8481
8595
|
role: "mutationOptions",
|
|
8482
8596
|
tool: plugin.name
|
|
8483
8597
|
} });
|
|
8484
|
-
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()));
|
|
8485
8599
|
plugin.node(statement);
|
|
8486
8600
|
}
|
|
8487
8601
|
//#endregion
|
|
@@ -8777,6 +8891,16 @@ const defaultConfig$12 = {
|
|
|
8777
8891
|
mappers,
|
|
8778
8892
|
value: plugin.config.infiniteQueryOptions
|
|
8779
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
|
+
});
|
|
8780
8904
|
plugin.config.mutationOptions = context.valueToObject({
|
|
8781
8905
|
defaultValue: {
|
|
8782
8906
|
case: plugin.config.case ?? "camelCase",
|
|
@@ -8864,6 +8988,16 @@ const defaultConfig$11 = {
|
|
|
8864
8988
|
mappers,
|
|
8865
8989
|
value: plugin.config.infiniteQueryOptions
|
|
8866
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
|
+
});
|
|
8867
9001
|
plugin.config.mutationOptions = context.valueToObject({
|
|
8868
9002
|
defaultValue: {
|
|
8869
9003
|
case: plugin.config.case ?? "camelCase",
|
|
@@ -9032,6 +9166,16 @@ const defaultConfig$10 = {
|
|
|
9032
9166
|
mappers,
|
|
9033
9167
|
value: plugin.config.infiniteQueryOptions
|
|
9034
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
|
+
});
|
|
9035
9179
|
plugin.config.mutationOptions = context.valueToObject({
|
|
9036
9180
|
defaultValue: {
|
|
9037
9181
|
case: plugin.config.case ?? "camelCase",
|
|
@@ -9200,6 +9344,16 @@ const defaultConfig$9 = {
|
|
|
9200
9344
|
mappers,
|
|
9201
9345
|
value: plugin.config.infiniteQueryOptions
|
|
9202
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
|
+
});
|
|
9203
9357
|
plugin.config.mutationOptions = context.valueToObject({
|
|
9204
9358
|
defaultValue: {
|
|
9205
9359
|
case: plugin.config.case ?? "camelCase",
|
|
@@ -9287,6 +9441,16 @@ const defaultConfig$8 = {
|
|
|
9287
9441
|
mappers,
|
|
9288
9442
|
value: plugin.config.infiniteQueryOptions
|
|
9289
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
|
+
});
|
|
9290
9454
|
plugin.config.mutationOptions = context.valueToObject({
|
|
9291
9455
|
defaultValue: {
|
|
9292
9456
|
case: plugin.config.case ?? "camelCase",
|
|
@@ -9374,6 +9538,16 @@ const defaultConfig$7 = {
|
|
|
9374
9538
|
mappers,
|
|
9375
9539
|
value: plugin.config.infiniteQueryOptions
|
|
9376
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
|
+
});
|
|
9377
9551
|
plugin.config.mutationOptions = context.valueToObject({
|
|
9378
9552
|
defaultValue: {
|
|
9379
9553
|
case: plugin.config.case ?? "camelCase",
|
|
@@ -11048,6 +11222,7 @@ function createRequestSchemaContext$3(ctx) {
|
|
|
11048
11222
|
empty: emptyNode$3,
|
|
11049
11223
|
optional: optionalNode$3
|
|
11050
11224
|
},
|
|
11225
|
+
path: ref([]),
|
|
11051
11226
|
pipes: {
|
|
11052
11227
|
...pipes,
|
|
11053
11228
|
current: []
|
|
@@ -11103,6 +11278,7 @@ function createResponseValidatorV1({ operation, plugin }) {
|
|
|
11103
11278
|
return runResponseResolver$3({
|
|
11104
11279
|
$,
|
|
11105
11280
|
operation,
|
|
11281
|
+
path: ref([]),
|
|
11106
11282
|
pipes: {
|
|
11107
11283
|
...pipes,
|
|
11108
11284
|
current: []
|
|
@@ -11114,6 +11290,15 @@ function createResponseValidatorV1({ operation, plugin }) {
|
|
|
11114
11290
|
}
|
|
11115
11291
|
});
|
|
11116
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
|
+
}
|
|
11117
11302
|
//#endregion
|
|
11118
11303
|
//#region src/plugins/valibot/api.ts
|
|
11119
11304
|
var Api$1 = class {
|
|
@@ -11122,13 +11307,19 @@ var Api$1 = class {
|
|
|
11122
11307
|
if (!plugin.config.requests.enabled) return;
|
|
11123
11308
|
return createRequestSchemaV1(ctx);
|
|
11124
11309
|
}
|
|
11125
|
-
createRequestValidator(
|
|
11126
|
-
const { plugin } =
|
|
11310
|
+
createRequestValidator(ctx) {
|
|
11311
|
+
const { plugin } = ctx;
|
|
11127
11312
|
if (!plugin.config.requests.enabled) return;
|
|
11128
|
-
return createRequestValidatorV1(
|
|
11313
|
+
return createRequestValidatorV1(ctx);
|
|
11129
11314
|
}
|
|
11130
|
-
|
|
11131
|
-
return
|
|
11315
|
+
createResponseHandlers(ctx) {
|
|
11316
|
+
return createResponseHandlersV1(ctx);
|
|
11317
|
+
}
|
|
11318
|
+
createResponseTransformer(ctx) {
|
|
11319
|
+
return createResponseTransformerV1(ctx);
|
|
11320
|
+
}
|
|
11321
|
+
createResponseValidator(ctx) {
|
|
11322
|
+
return createResponseValidatorV1(ctx);
|
|
11132
11323
|
}
|
|
11133
11324
|
};
|
|
11134
11325
|
//#endregion
|
|
@@ -11295,10 +11486,11 @@ function unknownResolver$3(ctx) {
|
|
|
11295
11486
|
ctx.pipes.push(ctx.pipes.current, base);
|
|
11296
11487
|
return ctx.pipes.current;
|
|
11297
11488
|
}
|
|
11298
|
-
function unknownToPipes({ plugin, schema }) {
|
|
11489
|
+
function unknownToPipes({ path, plugin, schema }) {
|
|
11299
11490
|
const ctx = {
|
|
11300
11491
|
$,
|
|
11301
11492
|
nodes: { base: baseNode$55 },
|
|
11493
|
+
path,
|
|
11302
11494
|
pipes: {
|
|
11303
11495
|
...pipes,
|
|
11304
11496
|
current: []
|
|
@@ -11314,24 +11506,32 @@ function unknownToPipes({ plugin, schema }) {
|
|
|
11314
11506
|
//#endregion
|
|
11315
11507
|
//#region src/plugins/valibot/v1/toAst/array.ts
|
|
11316
11508
|
function baseNode$54(ctx) {
|
|
11317
|
-
const { plugin, symbols } = ctx;
|
|
11509
|
+
const { applyModifiers, path, pipes, plugin, symbols, walk } = ctx;
|
|
11318
11510
|
const { v } = symbols;
|
|
11319
11511
|
const arrayFn = $(v).attr(identifiers$1.schemas.array);
|
|
11320
11512
|
let { schema: normalizedSchema } = ctx;
|
|
11321
11513
|
if (normalizedSchema.items) normalizedSchema = deduplicateSchema({ schema: normalizedSchema });
|
|
11322
|
-
if (!normalizedSchema.items) return arrayFn.call(unknownToPipes({
|
|
11514
|
+
if (!normalizedSchema.items) return arrayFn.call(unknownToPipes({
|
|
11515
|
+
path,
|
|
11516
|
+
plugin
|
|
11517
|
+
}));
|
|
11323
11518
|
const childResults = [];
|
|
11324
|
-
const { applyModifiers, pipes, walk, walkerCtx } = ctx;
|
|
11325
11519
|
for (let i = 0; i < normalizedSchema.items.length; i++) {
|
|
11326
11520
|
const item = normalizedSchema.items[i];
|
|
11327
|
-
const result = walk(item, childContext(
|
|
11521
|
+
const result = walk(item, childContext({
|
|
11522
|
+
path,
|
|
11523
|
+
plugin
|
|
11524
|
+
}, "items", i));
|
|
11328
11525
|
childResults.push(result);
|
|
11329
11526
|
}
|
|
11330
11527
|
if (childResults.length === 1) {
|
|
11331
11528
|
const itemNode = pipes.toNode(applyModifiers(childResults[0]).pipes, plugin);
|
|
11332
11529
|
return arrayFn.call(itemNode);
|
|
11333
11530
|
}
|
|
11334
|
-
return arrayFn.call(unknownToPipes({
|
|
11531
|
+
return arrayFn.call(unknownToPipes({
|
|
11532
|
+
path,
|
|
11533
|
+
plugin
|
|
11534
|
+
}));
|
|
11335
11535
|
}
|
|
11336
11536
|
function lengthNode$7(ctx) {
|
|
11337
11537
|
const { schema, symbols } = ctx;
|
|
@@ -11364,13 +11564,16 @@ function arrayResolver$3(ctx) {
|
|
|
11364
11564
|
return ctx.pipes.current;
|
|
11365
11565
|
}
|
|
11366
11566
|
function arrayToPipes(ctx) {
|
|
11367
|
-
const { plugin, schema, walk
|
|
11567
|
+
const { path, plugin, schema, walk } = ctx;
|
|
11368
11568
|
const childResults = [];
|
|
11369
11569
|
if (schema.items) {
|
|
11370
11570
|
const normalizedSchema = deduplicateSchema({ schema });
|
|
11371
11571
|
for (let i = 0; i < normalizedSchema.items.length; i++) {
|
|
11372
11572
|
const item = normalizedSchema.items[i];
|
|
11373
|
-
const result = walk(item, childContext(
|
|
11573
|
+
const result = walk(item, childContext({
|
|
11574
|
+
path,
|
|
11575
|
+
plugin
|
|
11576
|
+
}, "items", i));
|
|
11374
11577
|
childResults.push(result);
|
|
11375
11578
|
}
|
|
11376
11579
|
}
|
|
@@ -11383,6 +11586,7 @@ function arrayToPipes(ctx) {
|
|
|
11383
11586
|
maxLength: maxLengthNode$7,
|
|
11384
11587
|
minLength: minLengthNode$7
|
|
11385
11588
|
},
|
|
11589
|
+
path,
|
|
11386
11590
|
pipes: {
|
|
11387
11591
|
...pipes,
|
|
11388
11592
|
current: []
|
|
@@ -11390,8 +11594,7 @@ function arrayToPipes(ctx) {
|
|
|
11390
11594
|
plugin,
|
|
11391
11595
|
schema,
|
|
11392
11596
|
symbols: { v: plugin.external("valibot.v") },
|
|
11393
|
-
walk
|
|
11394
|
-
walkerCtx
|
|
11597
|
+
walk
|
|
11395
11598
|
};
|
|
11396
11599
|
const resolver = plugin.config["~resolvers"]?.array;
|
|
11397
11600
|
const node = resolver?.(resolverCtx) ?? arrayResolver$3(resolverCtx);
|
|
@@ -11420,13 +11623,14 @@ function booleanResolver$3(ctx) {
|
|
|
11420
11623
|
if (baseResult) ctx.pipes.push(ctx.pipes.current, baseResult);
|
|
11421
11624
|
return ctx.pipes.current;
|
|
11422
11625
|
}
|
|
11423
|
-
function booleanToPipes({ plugin, schema }) {
|
|
11626
|
+
function booleanToPipes({ path, plugin, schema }) {
|
|
11424
11627
|
const ctx = {
|
|
11425
11628
|
$,
|
|
11426
11629
|
nodes: {
|
|
11427
11630
|
base: baseNode$53,
|
|
11428
11631
|
const: constNode$15
|
|
11429
11632
|
},
|
|
11633
|
+
path,
|
|
11430
11634
|
pipes: {
|
|
11431
11635
|
...pipes,
|
|
11432
11636
|
current: []
|
|
@@ -11444,53 +11648,48 @@ function booleanToPipes({ plugin, schema }) {
|
|
|
11444
11648
|
function itemsNode$3(ctx) {
|
|
11445
11649
|
const { schema } = ctx;
|
|
11446
11650
|
const enumMembers = [];
|
|
11447
|
-
|
|
11448
|
-
|
|
11449
|
-
|
|
11450
|
-
|
|
11451
|
-
|
|
11452
|
-
|
|
11453
|
-
}
|
|
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 };
|
|
11454
11662
|
}
|
|
11455
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
|
+
});
|
|
11456
11669
|
const { symbols } = ctx;
|
|
11457
11670
|
const { v } = symbols;
|
|
11458
|
-
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);
|
|
11459
11677
|
return $(v).attr(identifiers$1.schemas.picklist).call($.array(...enumMembers));
|
|
11460
11678
|
}
|
|
11461
11679
|
function enumResolver$3(ctx) {
|
|
11462
|
-
const { enumMembers } = ctx.nodes.items(ctx);
|
|
11463
|
-
if (!enumMembers.length) return ctx.pipes.current;
|
|
11464
11680
|
const baseExpression = ctx.nodes.base(ctx);
|
|
11465
11681
|
ctx.pipes.push(ctx.pipes.current, baseExpression);
|
|
11466
11682
|
return ctx.pipes.current;
|
|
11467
11683
|
}
|
|
11468
|
-
function enumToPipes({ plugin, schema }) {
|
|
11684
|
+
function enumToPipes({ path, plugin, schema }) {
|
|
11469
11685
|
const v = plugin.external("valibot.v");
|
|
11470
|
-
const { enumMembers, isNullable } = itemsNode$3({
|
|
11471
|
-
$,
|
|
11472
|
-
nodes: {
|
|
11473
|
-
base: baseNode$52,
|
|
11474
|
-
items: itemsNode$3
|
|
11475
|
-
},
|
|
11476
|
-
pipes: {
|
|
11477
|
-
...pipes,
|
|
11478
|
-
current: []
|
|
11479
|
-
},
|
|
11480
|
-
plugin,
|
|
11481
|
-
schema,
|
|
11482
|
-
symbols: { v }
|
|
11483
|
-
});
|
|
11484
|
-
if (!enumMembers.length) return {
|
|
11485
|
-
isNullable,
|
|
11486
|
-
pipe: unknownToPipes({ plugin })
|
|
11487
|
-
};
|
|
11488
11686
|
const ctx = {
|
|
11489
11687
|
$,
|
|
11490
11688
|
nodes: {
|
|
11491
11689
|
base: baseNode$52,
|
|
11492
11690
|
items: itemsNode$3
|
|
11493
11691
|
},
|
|
11692
|
+
path,
|
|
11494
11693
|
pipes: {
|
|
11495
11694
|
...pipes,
|
|
11496
11695
|
current: []
|
|
@@ -11501,10 +11700,7 @@ function enumToPipes({ plugin, schema }) {
|
|
|
11501
11700
|
};
|
|
11502
11701
|
const resolver = plugin.config["~resolvers"]?.enum;
|
|
11503
11702
|
const node = resolver?.(ctx) ?? enumResolver$3(ctx);
|
|
11504
|
-
return
|
|
11505
|
-
isNullable,
|
|
11506
|
-
pipe: ctx.pipes.toNode(node, plugin)
|
|
11507
|
-
};
|
|
11703
|
+
return ctx.pipes.toNode(node, plugin);
|
|
11508
11704
|
}
|
|
11509
11705
|
//#endregion
|
|
11510
11706
|
//#region src/plugins/valibot/v1/toAst/intersection.ts
|
|
@@ -11521,14 +11717,14 @@ function intersectionResolver$3(ctx) {
|
|
|
11521
11717
|
if (base) ctx.pipes.push(ctx.pipes.current, base);
|
|
11522
11718
|
return ctx.pipes.current;
|
|
11523
11719
|
}
|
|
11524
|
-
function intersectionToPipes(
|
|
11525
|
-
const { applyModifiers, childResults, parentSchema, plugin } = ctx;
|
|
11720
|
+
function intersectionToPipes({ applyModifiers, childResults, parentSchema, path, plugin }) {
|
|
11526
11721
|
const resolverCtx = {
|
|
11527
11722
|
$,
|
|
11528
11723
|
applyModifiers,
|
|
11529
11724
|
childResults,
|
|
11530
11725
|
nodes: { base: baseNode$51 },
|
|
11531
11726
|
parentSchema,
|
|
11727
|
+
path,
|
|
11532
11728
|
pipes: {
|
|
11533
11729
|
...pipes,
|
|
11534
11730
|
current: []
|
|
@@ -11556,10 +11752,11 @@ function neverResolver$3(ctx) {
|
|
|
11556
11752
|
ctx.pipes.push(ctx.pipes.current, base);
|
|
11557
11753
|
return ctx.pipes.current;
|
|
11558
11754
|
}
|
|
11559
|
-
function neverToPipes({ plugin, schema }) {
|
|
11755
|
+
function neverToPipes({ path, plugin, schema }) {
|
|
11560
11756
|
const ctx = {
|
|
11561
11757
|
$,
|
|
11562
11758
|
nodes: { base: baseNode$50 },
|
|
11759
|
+
path,
|
|
11563
11760
|
pipes: {
|
|
11564
11761
|
...pipes,
|
|
11565
11762
|
current: []
|
|
@@ -11584,10 +11781,11 @@ function nullResolver$3(ctx) {
|
|
|
11584
11781
|
ctx.pipes.push(ctx.pipes.current, base);
|
|
11585
11782
|
return ctx.pipes.current;
|
|
11586
11783
|
}
|
|
11587
|
-
function nullToPipes({ plugin, schema }) {
|
|
11784
|
+
function nullToPipes({ path, plugin, schema }) {
|
|
11588
11785
|
const ctx = {
|
|
11589
11786
|
$,
|
|
11590
11787
|
nodes: { base: baseNode$49 },
|
|
11788
|
+
path,
|
|
11591
11789
|
pipes: {
|
|
11592
11790
|
...pipes,
|
|
11593
11791
|
current: []
|
|
@@ -11671,7 +11869,7 @@ function numberResolver$3(ctx) {
|
|
|
11671
11869
|
if (maxResult) ctx.pipes.push(ctx.pipes.current, maxResult);
|
|
11672
11870
|
return ctx.pipes.current;
|
|
11673
11871
|
}
|
|
11674
|
-
function numberToPipes({ plugin, schema }) {
|
|
11872
|
+
function numberToPipes({ path, plugin, schema }) {
|
|
11675
11873
|
const ctx = {
|
|
11676
11874
|
$,
|
|
11677
11875
|
nodes: {
|
|
@@ -11680,6 +11878,7 @@ function numberToPipes({ plugin, schema }) {
|
|
|
11680
11878
|
max: maxNode$3,
|
|
11681
11879
|
min: minNode$3
|
|
11682
11880
|
},
|
|
11881
|
+
path,
|
|
11683
11882
|
pipes: {
|
|
11684
11883
|
...pipes,
|
|
11685
11884
|
current: []
|
|
@@ -11700,10 +11899,13 @@ function numberToPipes({ plugin, schema }) {
|
|
|
11700
11899
|
//#endregion
|
|
11701
11900
|
//#region src/plugins/valibot/v1/toAst/object.ts
|
|
11702
11901
|
function additionalPropertiesNode$3(ctx) {
|
|
11703
|
-
const { pipes, schema } = ctx;
|
|
11902
|
+
const { path, pipes, plugin, schema } = ctx;
|
|
11704
11903
|
if (!schema.additionalProperties || !schema.additionalProperties.type) return;
|
|
11705
11904
|
if (schema.additionalProperties.type === "never") return null;
|
|
11706
|
-
const additionalResult = ctx.walk(schema.additionalProperties, childContext(
|
|
11905
|
+
const additionalResult = ctx.walk(schema.additionalProperties, childContext({
|
|
11906
|
+
path,
|
|
11907
|
+
plugin
|
|
11908
|
+
}, "additionalProperties"));
|
|
11707
11909
|
ctx._childResults.push(additionalResult);
|
|
11708
11910
|
return pipes.toNode(additionalResult.pipes, ctx.plugin);
|
|
11709
11911
|
}
|
|
@@ -11722,12 +11924,15 @@ function objectResolver$3(ctx) {
|
|
|
11722
11924
|
return ctx.nodes.base(ctx);
|
|
11723
11925
|
}
|
|
11724
11926
|
function shapeNode$3(ctx) {
|
|
11725
|
-
const { pipes, schema } = ctx;
|
|
11927
|
+
const { path, pipes, plugin, schema } = ctx;
|
|
11726
11928
|
const shape = $.object().pretty();
|
|
11727
11929
|
for (const name in schema.properties) {
|
|
11728
11930
|
const property = schema.properties[name];
|
|
11729
11931
|
const isOptional = !schema.required?.includes(name);
|
|
11730
|
-
const propertyResult = ctx.walk(property, childContext(
|
|
11932
|
+
const propertyResult = ctx.walk(property, childContext({
|
|
11933
|
+
path,
|
|
11934
|
+
plugin
|
|
11935
|
+
}, "properties", name));
|
|
11731
11936
|
ctx._childResults.push(propertyResult);
|
|
11732
11937
|
const finalExpr = ctx.applyModifiers(propertyResult, { optional: isOptional });
|
|
11733
11938
|
shape.prop(name, pipes.toNode(finalExpr.pipes, ctx.plugin));
|
|
@@ -11735,7 +11940,7 @@ function shapeNode$3(ctx) {
|
|
|
11735
11940
|
return shape;
|
|
11736
11941
|
}
|
|
11737
11942
|
function objectToPipes(ctx) {
|
|
11738
|
-
const { applyModifiers, plugin, schema, walk
|
|
11943
|
+
const { applyModifiers, path, plugin, schema, walk } = ctx;
|
|
11739
11944
|
const childResults = [];
|
|
11740
11945
|
const resolverCtx = {
|
|
11741
11946
|
$,
|
|
@@ -11746,6 +11951,7 @@ function objectToPipes(ctx) {
|
|
|
11746
11951
|
base: baseNode$47,
|
|
11747
11952
|
shape: shapeNode$3
|
|
11748
11953
|
},
|
|
11954
|
+
path,
|
|
11749
11955
|
pipes: {
|
|
11750
11956
|
...pipes,
|
|
11751
11957
|
current: []
|
|
@@ -11753,8 +11959,7 @@ function objectToPipes(ctx) {
|
|
|
11753
11959
|
plugin,
|
|
11754
11960
|
schema,
|
|
11755
11961
|
symbols: { v: plugin.external("valibot.v") },
|
|
11756
|
-
walk
|
|
11757
|
-
walkerCtx
|
|
11962
|
+
walk
|
|
11758
11963
|
};
|
|
11759
11964
|
const resolver = plugin.config["~resolvers"]?.object;
|
|
11760
11965
|
const node = resolver?.(resolverCtx) ?? objectResolver$3(resolverCtx);
|
|
@@ -11833,8 +12038,9 @@ function stringResolver$3(ctx) {
|
|
|
11833
12038
|
if (patternNode) ctx.pipes.push(ctx.pipes.current, patternNode);
|
|
11834
12039
|
return ctx.pipes.current;
|
|
11835
12040
|
}
|
|
11836
|
-
function stringToPipes({ plugin, schema }) {
|
|
12041
|
+
function stringToPipes({ path, plugin, schema }) {
|
|
11837
12042
|
if (shouldCoerceToBigInt(schema.format)) return numberToPipes({
|
|
12043
|
+
path,
|
|
11838
12044
|
plugin,
|
|
11839
12045
|
schema: {
|
|
11840
12046
|
...schema,
|
|
@@ -11852,6 +12058,7 @@ function stringToPipes({ plugin, schema }) {
|
|
|
11852
12058
|
minLength: minLengthNode$6,
|
|
11853
12059
|
pattern: patternNode$3
|
|
11854
12060
|
},
|
|
12061
|
+
path,
|
|
11855
12062
|
pipes: {
|
|
11856
12063
|
...pipes,
|
|
11857
12064
|
current: []
|
|
@@ -11867,13 +12074,19 @@ function stringToPipes({ plugin, schema }) {
|
|
|
11867
12074
|
//#endregion
|
|
11868
12075
|
//#region src/plugins/valibot/v1/toAst/tuple.ts
|
|
11869
12076
|
function baseNode$45(ctx) {
|
|
11870
|
-
const { applyModifiers, pipes, plugin, schema, symbols, walk
|
|
11871
|
-
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
|
+
});
|
|
11872
12082
|
const { v } = symbols;
|
|
11873
12083
|
const childResults = [];
|
|
11874
12084
|
for (let i = 0; i < schema.items.length; i++) {
|
|
11875
12085
|
const item = schema.items[i];
|
|
11876
|
-
const result = walk(item, childContext(
|
|
12086
|
+
const result = walk(item, childContext({
|
|
12087
|
+
path,
|
|
12088
|
+
plugin
|
|
12089
|
+
}, "items", i));
|
|
11877
12090
|
childResults.push(result);
|
|
11878
12091
|
}
|
|
11879
12092
|
const tupleElements = childResults.map((r) => pipes.toNode(applyModifiers(r).pipes, plugin));
|
|
@@ -11894,11 +12107,14 @@ function tupleResolver$3(ctx) {
|
|
|
11894
12107
|
return ctx.pipes.current;
|
|
11895
12108
|
}
|
|
11896
12109
|
function tupleToPipes(ctx) {
|
|
11897
|
-
const { plugin, schema, walk
|
|
12110
|
+
const { path, plugin, schema, walk } = ctx;
|
|
11898
12111
|
const childResults = [];
|
|
11899
12112
|
if (schema.items) for (let i = 0; i < schema.items.length; i++) {
|
|
11900
12113
|
const item = schema.items[i];
|
|
11901
|
-
const result = walk(item, childContext(
|
|
12114
|
+
const result = walk(item, childContext({
|
|
12115
|
+
path,
|
|
12116
|
+
plugin
|
|
12117
|
+
}, "items", i));
|
|
11902
12118
|
childResults.push(result);
|
|
11903
12119
|
}
|
|
11904
12120
|
const resolverCtx = {
|
|
@@ -11908,6 +12124,7 @@ function tupleToPipes(ctx) {
|
|
|
11908
12124
|
base: baseNode$45,
|
|
11909
12125
|
const: constNode$12
|
|
11910
12126
|
},
|
|
12127
|
+
path,
|
|
11911
12128
|
pipes: {
|
|
11912
12129
|
...pipes,
|
|
11913
12130
|
current: []
|
|
@@ -11915,8 +12132,7 @@ function tupleToPipes(ctx) {
|
|
|
11915
12132
|
plugin,
|
|
11916
12133
|
schema,
|
|
11917
12134
|
symbols: { v: plugin.external("valibot.v") },
|
|
11918
|
-
walk
|
|
11919
|
-
walkerCtx
|
|
12135
|
+
walk
|
|
11920
12136
|
};
|
|
11921
12137
|
const resolver = plugin.config["~resolvers"]?.tuple;
|
|
11922
12138
|
const node = resolver?.(resolverCtx) ?? tupleResolver$3(resolverCtx);
|
|
@@ -11937,10 +12153,11 @@ function undefinedResolver$3(ctx) {
|
|
|
11937
12153
|
ctx.pipes.push(ctx.pipes.current, base);
|
|
11938
12154
|
return ctx.pipes.current;
|
|
11939
12155
|
}
|
|
11940
|
-
function undefinedToPipes({ plugin, schema }) {
|
|
12156
|
+
function undefinedToPipes({ path, plugin, schema }) {
|
|
11941
12157
|
const ctx = {
|
|
11942
12158
|
$,
|
|
11943
12159
|
nodes: { base: baseNode$44 },
|
|
12160
|
+
path,
|
|
11944
12161
|
pipes: {
|
|
11945
12162
|
...pipes,
|
|
11946
12163
|
current: []
|
|
@@ -11995,14 +12212,14 @@ function unionResolver$3(ctx) {
|
|
|
11995
12212
|
if (base) ctx.pipes.push(ctx.pipes.current, base);
|
|
11996
12213
|
return ctx.pipes.current;
|
|
11997
12214
|
}
|
|
11998
|
-
function unionToPipes(
|
|
11999
|
-
const { applyModifiers, childResults, parentSchema, plugin, schemas } = ctx;
|
|
12215
|
+
function unionToPipes({ applyModifiers, childResults, parentSchema, path, plugin, schemas }) {
|
|
12000
12216
|
const resolverCtx = {
|
|
12001
12217
|
$,
|
|
12002
12218
|
applyModifiers,
|
|
12003
12219
|
childResults,
|
|
12004
12220
|
nodes: { base: baseNode$43 },
|
|
12005
12221
|
parentSchema,
|
|
12222
|
+
path,
|
|
12006
12223
|
pipes: {
|
|
12007
12224
|
...pipes,
|
|
12008
12225
|
current: []
|
|
@@ -12031,10 +12248,11 @@ function voidResolver$3(ctx) {
|
|
|
12031
12248
|
ctx.pipes.push(ctx.pipes.current, base);
|
|
12032
12249
|
return ctx.pipes.current;
|
|
12033
12250
|
}
|
|
12034
|
-
function voidToPipes({ plugin, schema }) {
|
|
12251
|
+
function voidToPipes({ path, plugin, schema }) {
|
|
12035
12252
|
const ctx = {
|
|
12036
12253
|
$,
|
|
12037
12254
|
nodes: { base: baseNode$42 },
|
|
12255
|
+
path,
|
|
12038
12256
|
pipes: {
|
|
12039
12257
|
...pipes,
|
|
12040
12258
|
current: []
|
|
@@ -12048,7 +12266,7 @@ function voidToPipes({ plugin, schema }) {
|
|
|
12048
12266
|
return ctx.pipes.toNode(node, plugin);
|
|
12049
12267
|
}
|
|
12050
12268
|
//#endregion
|
|
12051
|
-
//#region src/plugins/valibot/v1/
|
|
12269
|
+
//#region src/plugins/valibot/v1/visitor.ts
|
|
12052
12270
|
function getDefaultValue$3(meta) {
|
|
12053
12271
|
return meta.format ? maybeBigInt(meta.default, meta.format) : $.fromValue(meta.default);
|
|
12054
12272
|
}
|
|
@@ -12080,10 +12298,10 @@ function createVisitor$3(config = {}) {
|
|
|
12080
12298
|
const applyModifiers = (result, opts) => this.applyModifiers(result, ctx, opts);
|
|
12081
12299
|
const { childResults, pipes } = arrayToPipes({
|
|
12082
12300
|
applyModifiers,
|
|
12301
|
+
path: ctx.path,
|
|
12083
12302
|
plugin: ctx.plugin,
|
|
12084
12303
|
schema,
|
|
12085
|
-
walk
|
|
12086
|
-
walkerCtx: ctx
|
|
12304
|
+
walk
|
|
12087
12305
|
});
|
|
12088
12306
|
return {
|
|
12089
12307
|
meta: inheritMeta$1(schema, childResults),
|
|
@@ -12092,6 +12310,7 @@ function createVisitor$3(config = {}) {
|
|
|
12092
12310
|
},
|
|
12093
12311
|
boolean(schema, ctx) {
|
|
12094
12312
|
const pipe = booleanToPipes({
|
|
12313
|
+
path: ctx.path,
|
|
12095
12314
|
plugin: ctx.plugin,
|
|
12096
12315
|
schema
|
|
12097
12316
|
});
|
|
@@ -12101,10 +12320,12 @@ function createVisitor$3(config = {}) {
|
|
|
12101
12320
|
};
|
|
12102
12321
|
},
|
|
12103
12322
|
enum(schema, ctx) {
|
|
12104
|
-
const
|
|
12323
|
+
const pipe = enumToPipes({
|
|
12324
|
+
path: ctx.path,
|
|
12105
12325
|
plugin: ctx.plugin,
|
|
12106
12326
|
schema
|
|
12107
12327
|
});
|
|
12328
|
+
const isNullable = schema.items?.some((item) => item.type === "null" || item.const === null) ?? false;
|
|
12108
12329
|
return {
|
|
12109
12330
|
meta: {
|
|
12110
12331
|
...defaultMeta$1(schema),
|
|
@@ -12115,6 +12336,7 @@ function createVisitor$3(config = {}) {
|
|
|
12115
12336
|
},
|
|
12116
12337
|
integer(schema, ctx) {
|
|
12117
12338
|
const pipe = numberToPipes({
|
|
12339
|
+
path: ctx.path,
|
|
12118
12340
|
plugin: ctx.plugin,
|
|
12119
12341
|
schema
|
|
12120
12342
|
});
|
|
@@ -12148,6 +12370,7 @@ function createVisitor$3(config = {}) {
|
|
|
12148
12370
|
applyModifiers,
|
|
12149
12371
|
childResults: items,
|
|
12150
12372
|
parentSchema,
|
|
12373
|
+
path: ctx.path,
|
|
12151
12374
|
plugin: ctx.plugin
|
|
12152
12375
|
});
|
|
12153
12376
|
return {
|
|
@@ -12157,6 +12380,7 @@ function createVisitor$3(config = {}) {
|
|
|
12157
12380
|
},
|
|
12158
12381
|
never(schema, ctx) {
|
|
12159
12382
|
const pipe = neverToPipes({
|
|
12383
|
+
path: ctx.path,
|
|
12160
12384
|
plugin: ctx.plugin,
|
|
12161
12385
|
schema
|
|
12162
12386
|
});
|
|
@@ -12171,6 +12395,7 @@ function createVisitor$3(config = {}) {
|
|
|
12171
12395
|
},
|
|
12172
12396
|
null(schema, ctx) {
|
|
12173
12397
|
const pipe = nullToPipes({
|
|
12398
|
+
path: ctx.path,
|
|
12174
12399
|
plugin: ctx.plugin,
|
|
12175
12400
|
schema
|
|
12176
12401
|
});
|
|
@@ -12185,6 +12410,7 @@ function createVisitor$3(config = {}) {
|
|
|
12185
12410
|
},
|
|
12186
12411
|
number(schema, ctx) {
|
|
12187
12412
|
const pipe = numberToPipes({
|
|
12413
|
+
path: ctx.path,
|
|
12188
12414
|
plugin: ctx.plugin,
|
|
12189
12415
|
schema
|
|
12190
12416
|
});
|
|
@@ -12197,10 +12423,10 @@ function createVisitor$3(config = {}) {
|
|
|
12197
12423
|
const applyModifiers = (result, opts) => this.applyModifiers(result, ctx, opts);
|
|
12198
12424
|
const { childResults, pipes } = objectToPipes({
|
|
12199
12425
|
applyModifiers,
|
|
12426
|
+
path: ctx.path,
|
|
12200
12427
|
plugin: ctx.plugin,
|
|
12201
12428
|
schema,
|
|
12202
|
-
walk
|
|
12203
|
-
walkerCtx: ctx
|
|
12429
|
+
walk
|
|
12204
12430
|
});
|
|
12205
12431
|
return {
|
|
12206
12432
|
meta: inheritMeta$1(schema, childResults),
|
|
@@ -12247,6 +12473,7 @@ function createVisitor$3(config = {}) {
|
|
|
12247
12473
|
},
|
|
12248
12474
|
string(schema, ctx) {
|
|
12249
12475
|
const pipe = stringToPipes({
|
|
12476
|
+
path: ctx.path,
|
|
12250
12477
|
plugin: ctx.plugin,
|
|
12251
12478
|
schema
|
|
12252
12479
|
});
|
|
@@ -12259,10 +12486,10 @@ function createVisitor$3(config = {}) {
|
|
|
12259
12486
|
const applyModifiers = (result, opts) => this.applyModifiers(result, ctx, opts);
|
|
12260
12487
|
const { childResults, pipes } = tupleToPipes({
|
|
12261
12488
|
applyModifiers,
|
|
12489
|
+
path: ctx.path,
|
|
12262
12490
|
plugin: ctx.plugin,
|
|
12263
12491
|
schema,
|
|
12264
|
-
walk
|
|
12265
|
-
walkerCtx: ctx
|
|
12492
|
+
walk
|
|
12266
12493
|
});
|
|
12267
12494
|
return {
|
|
12268
12495
|
meta: inheritMeta$1(schema, childResults),
|
|
@@ -12271,6 +12498,7 @@ function createVisitor$3(config = {}) {
|
|
|
12271
12498
|
},
|
|
12272
12499
|
undefined(schema, ctx) {
|
|
12273
12500
|
const pipe = undefinedToPipes({
|
|
12501
|
+
path: ctx.path,
|
|
12274
12502
|
plugin: ctx.plugin,
|
|
12275
12503
|
schema
|
|
12276
12504
|
});
|
|
@@ -12290,6 +12518,7 @@ function createVisitor$3(config = {}) {
|
|
|
12290
12518
|
applyModifiers,
|
|
12291
12519
|
childResults: items,
|
|
12292
12520
|
parentSchema,
|
|
12521
|
+
path: ctx.path,
|
|
12293
12522
|
plugin: ctx.plugin,
|
|
12294
12523
|
schemas
|
|
12295
12524
|
});
|
|
@@ -12302,7 +12531,10 @@ function createVisitor$3(config = {}) {
|
|
|
12302
12531
|
};
|
|
12303
12532
|
},
|
|
12304
12533
|
unknown(schema, ctx) {
|
|
12305
|
-
const pipe = unknownToPipes({
|
|
12534
|
+
const pipe = unknownToPipes({
|
|
12535
|
+
path: ctx.path,
|
|
12536
|
+
plugin: ctx.plugin
|
|
12537
|
+
});
|
|
12306
12538
|
return {
|
|
12307
12539
|
meta: {
|
|
12308
12540
|
...defaultMeta$1(schema),
|
|
@@ -12314,6 +12546,7 @@ function createVisitor$3(config = {}) {
|
|
|
12314
12546
|
},
|
|
12315
12547
|
void(schema, ctx) {
|
|
12316
12548
|
const pipe = voidToPipes({
|
|
12549
|
+
path: ctx.path,
|
|
12317
12550
|
plugin: ctx.plugin,
|
|
12318
12551
|
schema
|
|
12319
12552
|
});
|
|
@@ -12544,7 +12777,7 @@ const defaultConfig$1 = {
|
|
|
12544
12777
|
value: plugin.config.webhooks
|
|
12545
12778
|
});
|
|
12546
12779
|
},
|
|
12547
|
-
tags: ["validator"]
|
|
12780
|
+
tags: ["transformer", "validator"]
|
|
12548
12781
|
};
|
|
12549
12782
|
definePluginConfig(defaultConfig$1);
|
|
12550
12783
|
//#endregion
|
|
@@ -12592,6 +12825,7 @@ const identifiers = {
|
|
|
12592
12825
|
min: "min",
|
|
12593
12826
|
minLength: "minLength",
|
|
12594
12827
|
minimum: "minimum",
|
|
12828
|
+
nativeEnum: "nativeEnum",
|
|
12595
12829
|
never: "never",
|
|
12596
12830
|
null: "null",
|
|
12597
12831
|
nullable: "nullable",
|
|
@@ -12850,6 +13084,7 @@ function createRequestSchemaContext$2(ctx) {
|
|
|
12850
13084
|
empty: emptyNode$2,
|
|
12851
13085
|
optional: optionalNode$2
|
|
12852
13086
|
},
|
|
13087
|
+
path: ref([]),
|
|
12853
13088
|
symbols: {
|
|
12854
13089
|
schema: $(""),
|
|
12855
13090
|
z
|
|
@@ -12902,6 +13137,7 @@ function createResponseValidatorMini({ operation, plugin }) {
|
|
|
12902
13137
|
$,
|
|
12903
13138
|
chain: { current: $(z) },
|
|
12904
13139
|
operation,
|
|
13140
|
+
path: ref([]),
|
|
12905
13141
|
plugin,
|
|
12906
13142
|
symbols: {
|
|
12907
13143
|
schema: symbol,
|
|
@@ -12909,6 +13145,15 @@ function createResponseValidatorMini({ operation, plugin }) {
|
|
|
12909
13145
|
}
|
|
12910
13146
|
});
|
|
12911
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
|
+
}
|
|
12912
13157
|
//#endregion
|
|
12913
13158
|
//#region src/plugins/zod/v3/api.ts
|
|
12914
13159
|
function emptyNode$1(ctx) {
|
|
@@ -12994,6 +13239,7 @@ function createRequestSchemaContext$1(ctx) {
|
|
|
12994
13239
|
empty: emptyNode$1,
|
|
12995
13240
|
optional: optionalNode$1
|
|
12996
13241
|
},
|
|
13242
|
+
path: ref([]),
|
|
12997
13243
|
symbols: {
|
|
12998
13244
|
schema: $(""),
|
|
12999
13245
|
z
|
|
@@ -13046,6 +13292,7 @@ function createResponseValidatorV3({ operation, plugin }) {
|
|
|
13046
13292
|
$,
|
|
13047
13293
|
chain: { current: $(z) },
|
|
13048
13294
|
operation,
|
|
13295
|
+
path: ref([]),
|
|
13049
13296
|
plugin,
|
|
13050
13297
|
symbols: {
|
|
13051
13298
|
schema: symbol,
|
|
@@ -13053,6 +13300,15 @@ function createResponseValidatorV3({ operation, plugin }) {
|
|
|
13053
13300
|
}
|
|
13054
13301
|
});
|
|
13055
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
|
+
}
|
|
13056
13312
|
//#endregion
|
|
13057
13313
|
//#region src/plugins/zod/v4/api.ts
|
|
13058
13314
|
function emptyNode(ctx) {
|
|
@@ -13138,6 +13394,7 @@ function createRequestSchemaContext(ctx) {
|
|
|
13138
13394
|
empty: emptyNode,
|
|
13139
13395
|
optional: optionalNode
|
|
13140
13396
|
},
|
|
13397
|
+
path: ref([]),
|
|
13141
13398
|
symbols: {
|
|
13142
13399
|
schema: $(""),
|
|
13143
13400
|
z
|
|
@@ -13190,6 +13447,7 @@ function createResponseValidatorV4({ operation, plugin }) {
|
|
|
13190
13447
|
$,
|
|
13191
13448
|
chain: { current: $(z) },
|
|
13192
13449
|
operation,
|
|
13450
|
+
path: ref([]),
|
|
13193
13451
|
plugin,
|
|
13194
13452
|
symbols: {
|
|
13195
13453
|
schema: symbol,
|
|
@@ -13197,6 +13455,15 @@ function createResponseValidatorV4({ operation, plugin }) {
|
|
|
13197
13455
|
}
|
|
13198
13456
|
});
|
|
13199
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
|
+
}
|
|
13200
13467
|
//#endregion
|
|
13201
13468
|
//#region src/plugins/zod/api.ts
|
|
13202
13469
|
var Api = class {
|
|
@@ -13218,6 +13485,22 @@ var Api = class {
|
|
|
13218
13485
|
default: return createRequestValidatorV4(ctx);
|
|
13219
13486
|
}
|
|
13220
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
|
+
}
|
|
13221
13504
|
createResponseValidator(ctx) {
|
|
13222
13505
|
const { plugin } = ctx;
|
|
13223
13506
|
switch (plugin.config.compatibilityVersion) {
|
|
@@ -13404,12 +13687,13 @@ function unknownResolver$2(ctx) {
|
|
|
13404
13687
|
ctx.chain.current = baseResult;
|
|
13405
13688
|
return ctx.chain.current;
|
|
13406
13689
|
}
|
|
13407
|
-
function unknownToAst$2({ plugin, schema }) {
|
|
13690
|
+
function unknownToAst$2({ path, plugin, schema }) {
|
|
13408
13691
|
const z = plugin.external("zod.z");
|
|
13409
13692
|
const ctx = {
|
|
13410
13693
|
$,
|
|
13411
13694
|
chain: { current: $(z) },
|
|
13412
13695
|
nodes: { base: baseNode$41 },
|
|
13696
|
+
path,
|
|
13413
13697
|
plugin,
|
|
13414
13698
|
schema,
|
|
13415
13699
|
symbols: { z }
|
|
@@ -13420,12 +13704,13 @@ function unknownToAst$2({ plugin, schema }) {
|
|
|
13420
13704
|
//#endregion
|
|
13421
13705
|
//#region src/plugins/zod/mini/toAst/array.ts
|
|
13422
13706
|
function baseNode$40(ctx) {
|
|
13423
|
-
const { applyModifiers, childResults, plugin, schema, symbols } = ctx;
|
|
13707
|
+
const { applyModifiers, childResults, path, plugin, schema, symbols } = ctx;
|
|
13424
13708
|
const { z } = symbols;
|
|
13425
13709
|
const arrayFn = $(z).attr(identifiers.array);
|
|
13426
13710
|
let normalizedSchema = schema;
|
|
13427
13711
|
if (normalizedSchema.items) normalizedSchema = deduplicateSchema({ schema: normalizedSchema });
|
|
13428
13712
|
if (!normalizedSchema.items) return arrayFn.call(unknownToAst$2({
|
|
13713
|
+
path,
|
|
13429
13714
|
plugin,
|
|
13430
13715
|
schema: { type: "unknown" }
|
|
13431
13716
|
}));
|
|
@@ -13439,6 +13724,7 @@ function baseNode$40(ctx) {
|
|
|
13439
13724
|
else return arrayFn.call($(z).attr(identifiers.union).call($.array(...itemExpressions)));
|
|
13440
13725
|
}
|
|
13441
13726
|
return arrayFn.call(unknownToAst$2({
|
|
13727
|
+
path,
|
|
13442
13728
|
plugin,
|
|
13443
13729
|
schema: { type: "unknown" }
|
|
13444
13730
|
}));
|
|
@@ -13473,14 +13759,17 @@ function arrayResolver$2(ctx) {
|
|
|
13473
13759
|
}
|
|
13474
13760
|
return ctx.chain.current;
|
|
13475
13761
|
}
|
|
13476
|
-
function arrayToAst$2({ applyModifiers, plugin, schema, walk
|
|
13762
|
+
function arrayToAst$2({ applyModifiers, path, plugin, schema, walk }) {
|
|
13477
13763
|
const childResults = [];
|
|
13478
13764
|
let schemaCopy = schema;
|
|
13479
13765
|
const z = plugin.external("zod.z");
|
|
13480
13766
|
if (schemaCopy.items) {
|
|
13481
13767
|
schemaCopy = deduplicateSchema({ schema: schemaCopy });
|
|
13482
13768
|
schemaCopy.items.forEach((item, index) => {
|
|
13483
|
-
const itemResult = walk(item, childContext(
|
|
13769
|
+
const itemResult = walk(item, childContext({
|
|
13770
|
+
path,
|
|
13771
|
+
plugin
|
|
13772
|
+
}, "items", index));
|
|
13484
13773
|
childResults.push(itemResult);
|
|
13485
13774
|
});
|
|
13486
13775
|
}
|
|
@@ -13495,11 +13784,11 @@ function arrayToAst$2({ applyModifiers, plugin, schema, walk, walkerCtx }) {
|
|
|
13495
13784
|
maxLength: maxLengthNode$5,
|
|
13496
13785
|
minLength: minLengthNode$5
|
|
13497
13786
|
},
|
|
13787
|
+
path,
|
|
13498
13788
|
plugin,
|
|
13499
13789
|
schema,
|
|
13500
13790
|
symbols: { z },
|
|
13501
|
-
walk
|
|
13502
|
-
walkerCtx
|
|
13791
|
+
walk
|
|
13503
13792
|
};
|
|
13504
13793
|
const resolver = plugin.config["~resolvers"]?.array;
|
|
13505
13794
|
return {
|
|
@@ -13530,7 +13819,7 @@ function booleanResolver$2(ctx) {
|
|
|
13530
13819
|
ctx.chain.current = baseResult;
|
|
13531
13820
|
return ctx.chain.current;
|
|
13532
13821
|
}
|
|
13533
|
-
function booleanToAst$2({ plugin, schema }) {
|
|
13822
|
+
function booleanToAst$2({ path, plugin, schema }) {
|
|
13534
13823
|
const z = plugin.external("zod.z");
|
|
13535
13824
|
const ctx = {
|
|
13536
13825
|
$,
|
|
@@ -13539,6 +13828,7 @@ function booleanToAst$2({ plugin, schema }) {
|
|
|
13539
13828
|
base: baseNode$39,
|
|
13540
13829
|
const: constNode$11
|
|
13541
13830
|
},
|
|
13831
|
+
path,
|
|
13542
13832
|
plugin,
|
|
13543
13833
|
schema,
|
|
13544
13834
|
symbols: { z }
|
|
@@ -13552,45 +13842,48 @@ function itemsNode$2(ctx) {
|
|
|
13552
13842
|
const { schema, symbols } = ctx;
|
|
13553
13843
|
const { z } = symbols;
|
|
13554
13844
|
const enumMembers = [];
|
|
13555
|
-
const
|
|
13556
|
-
let isNullable = false;
|
|
13557
|
-
let allStrings = true;
|
|
13845
|
+
const literalSchemas = [];
|
|
13558
13846
|
for (const item of schema.items ?? []) if (item.type === "string" && typeof item.const === "string") {
|
|
13559
13847
|
const literal = $.literal(item.const);
|
|
13560
13848
|
enumMembers.push(literal);
|
|
13561
|
-
|
|
13849
|
+
literalSchemas.push($(z).attr(identifiers.literal).call(literal));
|
|
13562
13850
|
} else if ((item.type === "number" || item.type === "integer") && typeof item.const === "number") {
|
|
13563
|
-
allStrings = false;
|
|
13564
13851
|
const literal = $.literal(item.const);
|
|
13565
|
-
|
|
13852
|
+
literalSchemas.push($(z).attr(identifiers.literal).call(literal));
|
|
13566
13853
|
} else if (item.type === "boolean" && typeof item.const === "boolean") {
|
|
13567
|
-
allStrings = false;
|
|
13568
13854
|
const literal = $.literal(item.const);
|
|
13569
|
-
|
|
13570
|
-
}
|
|
13855
|
+
literalSchemas.push($(z).attr(identifiers.literal).call(literal));
|
|
13856
|
+
}
|
|
13571
13857
|
return {
|
|
13572
|
-
allStrings,
|
|
13573
13858
|
enumMembers,
|
|
13574
|
-
|
|
13575
|
-
literalMembers
|
|
13859
|
+
literalSchemas
|
|
13576
13860
|
};
|
|
13577
13861
|
}
|
|
13578
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
|
+
});
|
|
13579
13869
|
const { symbols } = ctx;
|
|
13580
13870
|
const { z } = symbols;
|
|
13581
|
-
const
|
|
13582
|
-
|
|
13583
|
-
|
|
13584
|
-
|
|
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));
|
|
13585
13880
|
}
|
|
13586
13881
|
function enumResolver$2(ctx) {
|
|
13587
|
-
const { literalMembers } = ctx.nodes.items(ctx);
|
|
13588
|
-
if (!literalMembers.length) return ctx.chain.current;
|
|
13589
13882
|
const baseExpression = ctx.nodes.base(ctx);
|
|
13590
13883
|
ctx.chain.current = baseExpression;
|
|
13591
13884
|
return ctx.chain.current;
|
|
13592
13885
|
}
|
|
13593
|
-
function enumToAst$2({ plugin, schema }) {
|
|
13886
|
+
function enumToAst$2({ path, plugin, schema }) {
|
|
13594
13887
|
const z = plugin.external("zod.z");
|
|
13595
13888
|
const ctx = {
|
|
13596
13889
|
$,
|
|
@@ -13599,15 +13892,11 @@ function enumToAst$2({ plugin, schema }) {
|
|
|
13599
13892
|
base: baseNode$38,
|
|
13600
13893
|
items: itemsNode$2
|
|
13601
13894
|
},
|
|
13895
|
+
path,
|
|
13602
13896
|
plugin,
|
|
13603
13897
|
schema,
|
|
13604
13898
|
symbols: { z }
|
|
13605
13899
|
};
|
|
13606
|
-
const { literalMembers } = itemsNode$2(ctx);
|
|
13607
|
-
if (!literalMembers.length) return unknownToAst$2({
|
|
13608
|
-
plugin,
|
|
13609
|
-
schema: { type: "unknown" }
|
|
13610
|
-
});
|
|
13611
13900
|
const resolver = plugin.config["~resolvers"]?.enum;
|
|
13612
13901
|
return resolver?.(ctx) ?? enumResolver$2(ctx);
|
|
13613
13902
|
}
|
|
@@ -13628,7 +13917,7 @@ function intersectionResolver$2(ctx) {
|
|
|
13628
13917
|
ctx.chain.current = baseResult;
|
|
13629
13918
|
return ctx.chain.current;
|
|
13630
13919
|
}
|
|
13631
|
-
function intersectionToAst$2({ childResults, parentSchema, plugin, schemas }) {
|
|
13920
|
+
function intersectionToAst$2({ childResults, parentSchema, path, plugin, schemas }) {
|
|
13632
13921
|
const z = plugin.external("zod.z");
|
|
13633
13922
|
const ctx = {
|
|
13634
13923
|
$,
|
|
@@ -13636,6 +13925,7 @@ function intersectionToAst$2({ childResults, parentSchema, plugin, schemas }) {
|
|
|
13636
13925
|
childResults,
|
|
13637
13926
|
nodes: { base: baseNode$37 },
|
|
13638
13927
|
parentSchema,
|
|
13928
|
+
path,
|
|
13639
13929
|
plugin,
|
|
13640
13930
|
schema: parentSchema,
|
|
13641
13931
|
schemas,
|
|
@@ -13659,12 +13949,13 @@ function neverResolver$2(ctx) {
|
|
|
13659
13949
|
ctx.chain.current = baseResult;
|
|
13660
13950
|
return ctx.chain.current;
|
|
13661
13951
|
}
|
|
13662
|
-
function neverToAst$2({ plugin, schema }) {
|
|
13952
|
+
function neverToAst$2({ path, plugin, schema }) {
|
|
13663
13953
|
const z = plugin.external("zod.z");
|
|
13664
13954
|
const ctx = {
|
|
13665
13955
|
$,
|
|
13666
13956
|
chain: { current: $(z) },
|
|
13667
13957
|
nodes: { base: baseNode$36 },
|
|
13958
|
+
path,
|
|
13668
13959
|
plugin,
|
|
13669
13960
|
schema,
|
|
13670
13961
|
symbols: { z }
|
|
@@ -13684,12 +13975,13 @@ function nullResolver$2(ctx) {
|
|
|
13684
13975
|
ctx.chain.current = baseResult;
|
|
13685
13976
|
return ctx.chain.current;
|
|
13686
13977
|
}
|
|
13687
|
-
function nullToAst$2({ plugin, schema }) {
|
|
13978
|
+
function nullToAst$2({ path, plugin, schema }) {
|
|
13688
13979
|
const z = plugin.external("zod.z");
|
|
13689
13980
|
const ctx = {
|
|
13690
13981
|
$,
|
|
13691
13982
|
chain: { current: $(z) },
|
|
13692
13983
|
nodes: { base: baseNode$35 },
|
|
13984
|
+
path,
|
|
13693
13985
|
plugin,
|
|
13694
13986
|
schema,
|
|
13695
13987
|
symbols: { z }
|
|
@@ -13745,7 +14037,7 @@ function numberResolver$2(ctx) {
|
|
|
13745
14037
|
if (checks.length) ctx.chain.current = ctx.chain.current.attr(identifiers.check).call(...checks);
|
|
13746
14038
|
return ctx.chain.current;
|
|
13747
14039
|
}
|
|
13748
|
-
function numberToNode$2({ plugin, schema }) {
|
|
14040
|
+
function numberToNode$2({ path, plugin, schema }) {
|
|
13749
14041
|
const z = plugin.external("zod.z");
|
|
13750
14042
|
const ctx = {
|
|
13751
14043
|
$,
|
|
@@ -13756,6 +14048,7 @@ function numberToNode$2({ plugin, schema }) {
|
|
|
13756
14048
|
max: maxNode$2,
|
|
13757
14049
|
min: minNode$2
|
|
13758
14050
|
},
|
|
14051
|
+
path,
|
|
13759
14052
|
plugin,
|
|
13760
14053
|
schema,
|
|
13761
14054
|
symbols: { z },
|
|
@@ -13771,9 +14064,12 @@ function numberToNode$2({ plugin, schema }) {
|
|
|
13771
14064
|
//#endregion
|
|
13772
14065
|
//#region src/plugins/zod/mini/toAst/object.ts
|
|
13773
14066
|
function additionalPropertiesNode$2(ctx) {
|
|
13774
|
-
const { _childResults, applyModifiers, schema, walk
|
|
14067
|
+
const { _childResults, applyModifiers, path, plugin, schema, walk } = ctx;
|
|
13775
14068
|
if (!schema.additionalProperties || schema.properties && Object.keys(schema.properties).length) return;
|
|
13776
|
-
const additionalResult = walk(schema.additionalProperties, childContext(
|
|
14069
|
+
const additionalResult = walk(schema.additionalProperties, childContext({
|
|
14070
|
+
path,
|
|
14071
|
+
plugin
|
|
14072
|
+
}, "additionalProperties"));
|
|
13777
14073
|
_childResults.push(additionalResult);
|
|
13778
14074
|
return applyModifiers(additionalResult, {}).expression;
|
|
13779
14075
|
}
|
|
@@ -13789,12 +14085,15 @@ function objectResolver$2(ctx) {
|
|
|
13789
14085
|
return ctx.nodes.base(ctx);
|
|
13790
14086
|
}
|
|
13791
14087
|
function shapeNode$2(ctx) {
|
|
13792
|
-
const { _childResults, applyModifiers, schema, walk
|
|
14088
|
+
const { _childResults, applyModifiers, path, plugin, schema, walk } = ctx;
|
|
13793
14089
|
const shape = $.object().pretty();
|
|
13794
14090
|
for (const name in schema.properties) {
|
|
13795
14091
|
const property = schema.properties[name];
|
|
13796
14092
|
const isOptional = !schema.required?.includes(name);
|
|
13797
|
-
const propertyResult = walk(property, childContext(
|
|
14093
|
+
const propertyResult = walk(property, childContext({
|
|
14094
|
+
path,
|
|
14095
|
+
plugin
|
|
14096
|
+
}, "properties", name));
|
|
13798
14097
|
_childResults.push(propertyResult);
|
|
13799
14098
|
const finalExpr = applyModifiers(propertyResult, { optional: isOptional });
|
|
13800
14099
|
shape.prop(name, finalExpr.expression);
|
|
@@ -13802,7 +14101,7 @@ function shapeNode$2(ctx) {
|
|
|
13802
14101
|
return shape;
|
|
13803
14102
|
}
|
|
13804
14103
|
function objectToAst$2(options) {
|
|
13805
|
-
const { applyModifiers, plugin, schema, walk
|
|
14104
|
+
const { applyModifiers, path, plugin, schema, walk } = options;
|
|
13806
14105
|
const childResults = [];
|
|
13807
14106
|
const z = plugin.external("zod.z");
|
|
13808
14107
|
const ctx = {
|
|
@@ -13815,11 +14114,11 @@ function objectToAst$2(options) {
|
|
|
13815
14114
|
base: baseNode$33,
|
|
13816
14115
|
shape: shapeNode$2
|
|
13817
14116
|
},
|
|
14117
|
+
path,
|
|
13818
14118
|
plugin,
|
|
13819
14119
|
schema,
|
|
13820
14120
|
symbols: { z },
|
|
13821
|
-
walk
|
|
13822
|
-
walkerCtx
|
|
14121
|
+
walk
|
|
13823
14122
|
};
|
|
13824
14123
|
const resolver = plugin.config["~resolvers"]?.object;
|
|
13825
14124
|
return {
|
|
@@ -13906,7 +14205,7 @@ function stringResolver$2(ctx) {
|
|
|
13906
14205
|
if (checks.length) ctx.chain.current = ctx.chain.current.attr(identifiers.check).call(...checks);
|
|
13907
14206
|
return ctx.chain.current;
|
|
13908
14207
|
}
|
|
13909
|
-
function stringToNode$2({ plugin, schema }) {
|
|
14208
|
+
function stringToNode$2({ path, plugin, schema }) {
|
|
13910
14209
|
const z = plugin.external("zod.z");
|
|
13911
14210
|
const ctx = {
|
|
13912
14211
|
$,
|
|
@@ -13920,6 +14219,7 @@ function stringToNode$2({ plugin, schema }) {
|
|
|
13920
14219
|
minLength: minLengthNode$4,
|
|
13921
14220
|
pattern: patternNode$2
|
|
13922
14221
|
},
|
|
14222
|
+
path,
|
|
13923
14223
|
plugin,
|
|
13924
14224
|
schema,
|
|
13925
14225
|
symbols: { z }
|
|
@@ -13954,11 +14254,14 @@ function tupleResolver$2(ctx) {
|
|
|
13954
14254
|
ctx.chain.current = baseResult;
|
|
13955
14255
|
return ctx.chain.current;
|
|
13956
14256
|
}
|
|
13957
|
-
function tupleToAst$2({ applyModifiers, plugin, schema, walk
|
|
14257
|
+
function tupleToAst$2({ applyModifiers, path, plugin, schema, walk }) {
|
|
13958
14258
|
const childResults = [];
|
|
13959
14259
|
const z = plugin.external("zod.z");
|
|
13960
14260
|
if (schema.items) schema.items.forEach((item, index) => {
|
|
13961
|
-
const itemResult = walk(item, childContext(
|
|
14261
|
+
const itemResult = walk(item, childContext({
|
|
14262
|
+
path,
|
|
14263
|
+
plugin
|
|
14264
|
+
}, "items", index));
|
|
13962
14265
|
childResults.push(itemResult);
|
|
13963
14266
|
});
|
|
13964
14267
|
const ctx = {
|
|
@@ -13970,11 +14273,11 @@ function tupleToAst$2({ applyModifiers, plugin, schema, walk, walkerCtx }) {
|
|
|
13970
14273
|
base: baseNode$31,
|
|
13971
14274
|
const: constNode$8
|
|
13972
14275
|
},
|
|
14276
|
+
path,
|
|
13973
14277
|
plugin,
|
|
13974
14278
|
schema,
|
|
13975
14279
|
symbols: { z },
|
|
13976
|
-
walk
|
|
13977
|
-
walkerCtx
|
|
14280
|
+
walk
|
|
13978
14281
|
};
|
|
13979
14282
|
const resolver = plugin.config["~resolvers"]?.tuple;
|
|
13980
14283
|
return {
|
|
@@ -13994,12 +14297,13 @@ function undefinedResolver$2(ctx) {
|
|
|
13994
14297
|
ctx.chain.current = baseResult;
|
|
13995
14298
|
return ctx.chain.current;
|
|
13996
14299
|
}
|
|
13997
|
-
function undefinedToAst$2({ plugin, schema }) {
|
|
14300
|
+
function undefinedToAst$2({ path, plugin, schema }) {
|
|
13998
14301
|
const z = plugin.external("zod.z");
|
|
13999
14302
|
const ctx = {
|
|
14000
14303
|
$,
|
|
14001
14304
|
chain: { current: $(z) },
|
|
14002
14305
|
nodes: { base: baseNode$30 },
|
|
14306
|
+
path,
|
|
14003
14307
|
plugin,
|
|
14004
14308
|
schema,
|
|
14005
14309
|
symbols: { z }
|
|
@@ -14075,7 +14379,7 @@ function unionResolver$2(ctx) {
|
|
|
14075
14379
|
ctx.chain.current = baseResult;
|
|
14076
14380
|
return ctx.chain.current;
|
|
14077
14381
|
}
|
|
14078
|
-
function unionToAst$2({ childResults, parentSchema, plugin, schemas }) {
|
|
14382
|
+
function unionToAst$2({ childResults, parentSchema, path, plugin, schemas }) {
|
|
14079
14383
|
const z = plugin.external("zod.z");
|
|
14080
14384
|
const ctx = {
|
|
14081
14385
|
$,
|
|
@@ -14083,6 +14387,7 @@ function unionToAst$2({ childResults, parentSchema, plugin, schemas }) {
|
|
|
14083
14387
|
childResults,
|
|
14084
14388
|
nodes: { base: baseNode$29 },
|
|
14085
14389
|
parentSchema,
|
|
14390
|
+
path,
|
|
14086
14391
|
plugin,
|
|
14087
14392
|
schema: parentSchema,
|
|
14088
14393
|
schemas,
|
|
@@ -14106,12 +14411,13 @@ function voidResolver$2(ctx) {
|
|
|
14106
14411
|
ctx.chain.current = baseResult;
|
|
14107
14412
|
return ctx.chain.current;
|
|
14108
14413
|
}
|
|
14109
|
-
function voidToAst$2({ plugin, schema }) {
|
|
14414
|
+
function voidToAst$2({ path, plugin, schema }) {
|
|
14110
14415
|
const z = plugin.external("zod.z");
|
|
14111
14416
|
const ctx = {
|
|
14112
14417
|
$,
|
|
14113
14418
|
chain: { current: $(z) },
|
|
14114
14419
|
nodes: { base: baseNode$28 },
|
|
14420
|
+
path,
|
|
14115
14421
|
plugin,
|
|
14116
14422
|
schema,
|
|
14117
14423
|
symbols: { z }
|
|
@@ -14120,7 +14426,7 @@ function voidToAst$2({ plugin, schema }) {
|
|
|
14120
14426
|
return resolver?.(ctx) ?? voidResolver$2(ctx);
|
|
14121
14427
|
}
|
|
14122
14428
|
//#endregion
|
|
14123
|
-
//#region src/plugins/zod/mini/
|
|
14429
|
+
//#region src/plugins/zod/mini/visitor.ts
|
|
14124
14430
|
function getDefaultValue$2(meta) {
|
|
14125
14431
|
return meta.format ? maybeBigInt(meta.default, meta.format) : $.fromValue(meta.default);
|
|
14126
14432
|
}
|
|
@@ -14144,10 +14450,10 @@ function createVisitor$2(config = {}) {
|
|
|
14144
14450
|
const applyModifiers = (result, opts) => this.applyModifiers(result, ctx, opts);
|
|
14145
14451
|
const { childResults, expression } = arrayToAst$2({
|
|
14146
14452
|
applyModifiers,
|
|
14453
|
+
path: ctx.path,
|
|
14147
14454
|
plugin: ctx.plugin,
|
|
14148
14455
|
schema,
|
|
14149
|
-
walk
|
|
14150
|
-
walkerCtx: ctx
|
|
14456
|
+
walk
|
|
14151
14457
|
});
|
|
14152
14458
|
return {
|
|
14153
14459
|
expression,
|
|
@@ -14157,6 +14463,7 @@ function createVisitor$2(config = {}) {
|
|
|
14157
14463
|
boolean(schema, ctx) {
|
|
14158
14464
|
return {
|
|
14159
14465
|
expression: booleanToAst$2({
|
|
14466
|
+
path: ctx.path,
|
|
14160
14467
|
plugin: ctx.plugin,
|
|
14161
14468
|
schema
|
|
14162
14469
|
}),
|
|
@@ -14165,6 +14472,7 @@ function createVisitor$2(config = {}) {
|
|
|
14165
14472
|
},
|
|
14166
14473
|
enum(schema, ctx) {
|
|
14167
14474
|
const expression = enumToAst$2({
|
|
14475
|
+
path: ctx.path,
|
|
14168
14476
|
plugin: ctx.plugin,
|
|
14169
14477
|
schema
|
|
14170
14478
|
});
|
|
@@ -14180,6 +14488,7 @@ function createVisitor$2(config = {}) {
|
|
|
14180
14488
|
integer(schema, ctx) {
|
|
14181
14489
|
return {
|
|
14182
14490
|
expression: numberToNode$2({
|
|
14491
|
+
path: ctx.path,
|
|
14183
14492
|
plugin: ctx.plugin,
|
|
14184
14493
|
schema
|
|
14185
14494
|
}),
|
|
@@ -14213,6 +14522,7 @@ function createVisitor$2(config = {}) {
|
|
|
14213
14522
|
const { expression } = intersectionToAst$2({
|
|
14214
14523
|
childResults: items,
|
|
14215
14524
|
parentSchema,
|
|
14525
|
+
path: ctx.path,
|
|
14216
14526
|
plugin: ctx.plugin,
|
|
14217
14527
|
schemas
|
|
14218
14528
|
});
|
|
@@ -14232,6 +14542,7 @@ function createVisitor$2(config = {}) {
|
|
|
14232
14542
|
never(schema, ctx) {
|
|
14233
14543
|
return {
|
|
14234
14544
|
expression: neverToAst$2({
|
|
14545
|
+
path: ctx.path,
|
|
14235
14546
|
plugin: ctx.plugin,
|
|
14236
14547
|
schema
|
|
14237
14548
|
}),
|
|
@@ -14245,6 +14556,7 @@ function createVisitor$2(config = {}) {
|
|
|
14245
14556
|
null(schema, ctx) {
|
|
14246
14557
|
return {
|
|
14247
14558
|
expression: nullToAst$2({
|
|
14559
|
+
path: ctx.path,
|
|
14248
14560
|
plugin: ctx.plugin,
|
|
14249
14561
|
schema
|
|
14250
14562
|
}),
|
|
@@ -14258,6 +14570,7 @@ function createVisitor$2(config = {}) {
|
|
|
14258
14570
|
number(schema, ctx) {
|
|
14259
14571
|
return {
|
|
14260
14572
|
expression: numberToNode$2({
|
|
14573
|
+
path: ctx.path,
|
|
14261
14574
|
plugin: ctx.plugin,
|
|
14262
14575
|
schema
|
|
14263
14576
|
}),
|
|
@@ -14271,10 +14584,10 @@ function createVisitor$2(config = {}) {
|
|
|
14271
14584
|
const applyModifiers = (result, opts) => this.applyModifiers(result, ctx, opts);
|
|
14272
14585
|
const { childResults, expression } = objectToAst$2({
|
|
14273
14586
|
applyModifiers,
|
|
14587
|
+
path: ctx.path,
|
|
14274
14588
|
plugin: ctx.plugin,
|
|
14275
14589
|
schema,
|
|
14276
|
-
walk
|
|
14277
|
-
walkerCtx: ctx
|
|
14590
|
+
walk
|
|
14278
14591
|
});
|
|
14279
14592
|
return {
|
|
14280
14593
|
expression,
|
|
@@ -14325,6 +14638,7 @@ function createVisitor$2(config = {}) {
|
|
|
14325
14638
|
string(schema, ctx) {
|
|
14326
14639
|
if (shouldCoerceToBigInt(schema.format)) return {
|
|
14327
14640
|
expression: numberToNode$2({
|
|
14641
|
+
path: ctx.path,
|
|
14328
14642
|
plugin: ctx.plugin,
|
|
14329
14643
|
schema: {
|
|
14330
14644
|
...schema,
|
|
@@ -14335,6 +14649,7 @@ function createVisitor$2(config = {}) {
|
|
|
14335
14649
|
};
|
|
14336
14650
|
return {
|
|
14337
14651
|
expression: stringToNode$2({
|
|
14652
|
+
path: ctx.path,
|
|
14338
14653
|
plugin: ctx.plugin,
|
|
14339
14654
|
schema
|
|
14340
14655
|
}),
|
|
@@ -14345,10 +14660,10 @@ function createVisitor$2(config = {}) {
|
|
|
14345
14660
|
const applyModifiers = (result, opts) => this.applyModifiers(result, ctx, opts);
|
|
14346
14661
|
const { childResults, expression } = tupleToAst$2({
|
|
14347
14662
|
applyModifiers,
|
|
14663
|
+
path: ctx.path,
|
|
14348
14664
|
plugin: ctx.plugin,
|
|
14349
14665
|
schema,
|
|
14350
|
-
walk
|
|
14351
|
-
walkerCtx: ctx
|
|
14666
|
+
walk
|
|
14352
14667
|
});
|
|
14353
14668
|
return {
|
|
14354
14669
|
expression,
|
|
@@ -14358,6 +14673,7 @@ function createVisitor$2(config = {}) {
|
|
|
14358
14673
|
undefined(schema, ctx) {
|
|
14359
14674
|
return {
|
|
14360
14675
|
expression: undefinedToAst$2({
|
|
14676
|
+
path: ctx.path,
|
|
14361
14677
|
plugin: ctx.plugin,
|
|
14362
14678
|
schema
|
|
14363
14679
|
}),
|
|
@@ -14374,6 +14690,7 @@ function createVisitor$2(config = {}) {
|
|
|
14374
14690
|
const { expression } = unionToAst$2({
|
|
14375
14691
|
childResults: items,
|
|
14376
14692
|
parentSchema,
|
|
14693
|
+
path: ctx.path,
|
|
14377
14694
|
plugin: ctx.plugin,
|
|
14378
14695
|
schemas
|
|
14379
14696
|
});
|
|
@@ -14393,6 +14710,7 @@ function createVisitor$2(config = {}) {
|
|
|
14393
14710
|
unknown(schema, ctx) {
|
|
14394
14711
|
return {
|
|
14395
14712
|
expression: unknownToAst$2({
|
|
14713
|
+
path: ctx.path,
|
|
14396
14714
|
plugin: ctx.plugin,
|
|
14397
14715
|
schema
|
|
14398
14716
|
}),
|
|
@@ -14406,6 +14724,7 @@ function createVisitor$2(config = {}) {
|
|
|
14406
14724
|
void(schema, ctx) {
|
|
14407
14725
|
return {
|
|
14408
14726
|
expression: voidToAst$2({
|
|
14727
|
+
path: ctx.path,
|
|
14409
14728
|
plugin: ctx.plugin,
|
|
14410
14729
|
schema
|
|
14411
14730
|
}),
|
|
@@ -14551,12 +14870,13 @@ function unknownResolver$1(ctx) {
|
|
|
14551
14870
|
ctx.chain.current = baseResult;
|
|
14552
14871
|
return ctx.chain.current;
|
|
14553
14872
|
}
|
|
14554
|
-
function unknownToAst$1({ plugin, schema }) {
|
|
14873
|
+
function unknownToAst$1({ path, plugin, schema }) {
|
|
14555
14874
|
const z = plugin.external("zod.z");
|
|
14556
14875
|
const ctx = {
|
|
14557
14876
|
$,
|
|
14558
14877
|
chain: { current: $(z) },
|
|
14559
14878
|
nodes: { base: baseNode$27 },
|
|
14879
|
+
path,
|
|
14560
14880
|
plugin,
|
|
14561
14881
|
schema,
|
|
14562
14882
|
symbols: { z }
|
|
@@ -14567,12 +14887,13 @@ function unknownToAst$1({ plugin, schema }) {
|
|
|
14567
14887
|
//#endregion
|
|
14568
14888
|
//#region src/plugins/zod/v3/toAst/array.ts
|
|
14569
14889
|
function baseNode$26(ctx) {
|
|
14570
|
-
const { applyModifiers, childResults, plugin, schema, symbols } = ctx;
|
|
14890
|
+
const { applyModifiers, childResults, path, plugin, schema, symbols } = ctx;
|
|
14571
14891
|
const { z } = symbols;
|
|
14572
14892
|
const arrayFn = $(z).attr(identifiers.array);
|
|
14573
14893
|
let normalizedSchema = schema;
|
|
14574
14894
|
if (normalizedSchema.items) normalizedSchema = deduplicateSchema({ schema: normalizedSchema });
|
|
14575
14895
|
if (!normalizedSchema.items) return arrayFn.call(unknownToAst$1({
|
|
14896
|
+
path,
|
|
14576
14897
|
plugin,
|
|
14577
14898
|
schema: { type: "unknown" }
|
|
14578
14899
|
}));
|
|
@@ -14594,6 +14915,7 @@ function baseNode$26(ctx) {
|
|
|
14594
14915
|
} else return arrayFn.call($(z).attr(identifiers.union).call($.array(...itemExpressions)));
|
|
14595
14916
|
}
|
|
14596
14917
|
return arrayFn.call(unknownToAst$1({
|
|
14918
|
+
path,
|
|
14597
14919
|
plugin,
|
|
14598
14920
|
schema: { type: "unknown" }
|
|
14599
14921
|
}));
|
|
@@ -14625,14 +14947,17 @@ function arrayResolver$1(ctx) {
|
|
|
14625
14947
|
}
|
|
14626
14948
|
return ctx.chain.current;
|
|
14627
14949
|
}
|
|
14628
|
-
function arrayToAst$1({ applyModifiers, plugin, schema, walk
|
|
14950
|
+
function arrayToAst$1({ applyModifiers, path, plugin, schema, walk }) {
|
|
14629
14951
|
const childResults = [];
|
|
14630
14952
|
let schemaCopy = schema;
|
|
14631
14953
|
const z = plugin.external("zod.z");
|
|
14632
14954
|
if (schemaCopy.items) {
|
|
14633
14955
|
schemaCopy = deduplicateSchema({ schema: schemaCopy });
|
|
14634
14956
|
schemaCopy.items.forEach((item, index) => {
|
|
14635
|
-
const itemResult = walk(item, childContext(
|
|
14957
|
+
const itemResult = walk(item, childContext({
|
|
14958
|
+
path,
|
|
14959
|
+
plugin
|
|
14960
|
+
}, "items", index));
|
|
14636
14961
|
childResults.push(itemResult);
|
|
14637
14962
|
});
|
|
14638
14963
|
}
|
|
@@ -14647,11 +14972,11 @@ function arrayToAst$1({ applyModifiers, plugin, schema, walk, walkerCtx }) {
|
|
|
14647
14972
|
maxLength: maxLengthNode$3,
|
|
14648
14973
|
minLength: minLengthNode$3
|
|
14649
14974
|
},
|
|
14975
|
+
path,
|
|
14650
14976
|
plugin,
|
|
14651
14977
|
schema,
|
|
14652
14978
|
symbols: { z },
|
|
14653
|
-
walk
|
|
14654
|
-
walkerCtx
|
|
14979
|
+
walk
|
|
14655
14980
|
};
|
|
14656
14981
|
const resolver = plugin.config["~resolvers"]?.array;
|
|
14657
14982
|
return {
|
|
@@ -14682,7 +15007,7 @@ function booleanResolver$1(ctx) {
|
|
|
14682
15007
|
ctx.chain.current = baseResult;
|
|
14683
15008
|
return ctx.chain.current;
|
|
14684
15009
|
}
|
|
14685
|
-
function booleanToAst$1({ plugin, schema }) {
|
|
15010
|
+
function booleanToAst$1({ path, plugin, schema }) {
|
|
14686
15011
|
const z = plugin.external("zod.z");
|
|
14687
15012
|
const ctx = {
|
|
14688
15013
|
$,
|
|
@@ -14691,6 +15016,7 @@ function booleanToAst$1({ plugin, schema }) {
|
|
|
14691
15016
|
base: baseNode$25,
|
|
14692
15017
|
const: constNode$7
|
|
14693
15018
|
},
|
|
15019
|
+
path,
|
|
14694
15020
|
plugin,
|
|
14695
15021
|
schema,
|
|
14696
15022
|
symbols: { z }
|
|
@@ -14704,45 +15030,48 @@ function itemsNode$1(ctx) {
|
|
|
14704
15030
|
const { schema, symbols } = ctx;
|
|
14705
15031
|
const { z } = symbols;
|
|
14706
15032
|
const enumMembers = [];
|
|
14707
|
-
const
|
|
14708
|
-
let isNullable = false;
|
|
14709
|
-
let allStrings = true;
|
|
15033
|
+
const literalSchemas = [];
|
|
14710
15034
|
for (const item of schema.items ?? []) if (item.type === "string" && typeof item.const === "string") {
|
|
14711
15035
|
const literal = $.literal(item.const);
|
|
14712
15036
|
enumMembers.push(literal);
|
|
14713
|
-
|
|
15037
|
+
literalSchemas.push($(z).attr(identifiers.literal).call(literal));
|
|
14714
15038
|
} else if ((item.type === "number" || item.type === "integer") && typeof item.const === "number") {
|
|
14715
|
-
allStrings = false;
|
|
14716
15039
|
const literal = $.literal(item.const);
|
|
14717
|
-
|
|
15040
|
+
literalSchemas.push($(z).attr(identifiers.literal).call(literal));
|
|
14718
15041
|
} else if (item.type === "boolean" && typeof item.const === "boolean") {
|
|
14719
|
-
allStrings = false;
|
|
14720
15042
|
const literal = $.literal(item.const);
|
|
14721
|
-
|
|
14722
|
-
}
|
|
15043
|
+
literalSchemas.push($(z).attr(identifiers.literal).call(literal));
|
|
15044
|
+
}
|
|
14723
15045
|
return {
|
|
14724
|
-
allStrings,
|
|
14725
15046
|
enumMembers,
|
|
14726
|
-
|
|
14727
|
-
literalMembers
|
|
15047
|
+
literalSchemas
|
|
14728
15048
|
};
|
|
14729
15049
|
}
|
|
14730
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
|
+
});
|
|
14731
15057
|
const { symbols } = ctx;
|
|
14732
15058
|
const { z } = symbols;
|
|
14733
|
-
const
|
|
14734
|
-
|
|
14735
|
-
|
|
14736
|
-
|
|
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));
|
|
14737
15068
|
}
|
|
14738
15069
|
function enumResolver$1(ctx) {
|
|
14739
|
-
const { literalMembers } = ctx.nodes.items(ctx);
|
|
14740
|
-
if (!literalMembers.length) return ctx.chain.current;
|
|
14741
15070
|
const baseExpression = ctx.nodes.base(ctx);
|
|
14742
15071
|
ctx.chain.current = baseExpression;
|
|
14743
15072
|
return ctx.chain.current;
|
|
14744
15073
|
}
|
|
14745
|
-
function enumToAst$1({ plugin, schema }) {
|
|
15074
|
+
function enumToAst$1({ path, plugin, schema }) {
|
|
14746
15075
|
const z = plugin.external("zod.z");
|
|
14747
15076
|
const ctx = {
|
|
14748
15077
|
$,
|
|
@@ -14751,6 +15080,7 @@ function enumToAst$1({ plugin, schema }) {
|
|
|
14751
15080
|
base: baseNode$24,
|
|
14752
15081
|
items: itemsNode$1
|
|
14753
15082
|
},
|
|
15083
|
+
path,
|
|
14754
15084
|
plugin,
|
|
14755
15085
|
schema,
|
|
14756
15086
|
symbols: { z }
|
|
@@ -14777,7 +15107,7 @@ function intersectionResolver$1(ctx) {
|
|
|
14777
15107
|
ctx.chain.current = baseResult;
|
|
14778
15108
|
return ctx.chain.current;
|
|
14779
15109
|
}
|
|
14780
|
-
function intersectionToAst$1({ childResults, parentSchema, plugin, schemas }) {
|
|
15110
|
+
function intersectionToAst$1({ childResults, parentSchema, path, plugin, schemas }) {
|
|
14781
15111
|
const z = plugin.external("zod.z");
|
|
14782
15112
|
const ctx = {
|
|
14783
15113
|
$,
|
|
@@ -14785,6 +15115,7 @@ function intersectionToAst$1({ childResults, parentSchema, plugin, schemas }) {
|
|
|
14785
15115
|
childResults,
|
|
14786
15116
|
nodes: { base: baseNode$23 },
|
|
14787
15117
|
parentSchema,
|
|
15118
|
+
path,
|
|
14788
15119
|
plugin,
|
|
14789
15120
|
schema: parentSchema,
|
|
14790
15121
|
schemas,
|
|
@@ -14808,12 +15139,13 @@ function neverResolver$1(ctx) {
|
|
|
14808
15139
|
ctx.chain.current = baseResult;
|
|
14809
15140
|
return ctx.chain.current;
|
|
14810
15141
|
}
|
|
14811
|
-
function neverToAst$1({ plugin, schema }) {
|
|
15142
|
+
function neverToAst$1({ path, plugin, schema }) {
|
|
14812
15143
|
const z = plugin.external("zod.z");
|
|
14813
15144
|
const ctx = {
|
|
14814
15145
|
$,
|
|
14815
15146
|
chain: { current: $(z) },
|
|
14816
15147
|
nodes: { base: baseNode$22 },
|
|
15148
|
+
path,
|
|
14817
15149
|
plugin,
|
|
14818
15150
|
schema,
|
|
14819
15151
|
symbols: { z }
|
|
@@ -14833,12 +15165,13 @@ function nullResolver$1(ctx) {
|
|
|
14833
15165
|
ctx.chain.current = baseResult;
|
|
14834
15166
|
return ctx.chain.current;
|
|
14835
15167
|
}
|
|
14836
|
-
function nullToAst$1({ plugin, schema }) {
|
|
15168
|
+
function nullToAst$1({ path, plugin, schema }) {
|
|
14837
15169
|
const z = plugin.external("zod.z");
|
|
14838
15170
|
const ctx = {
|
|
14839
15171
|
$,
|
|
14840
15172
|
chain: { current: $(z) },
|
|
14841
15173
|
nodes: { base: baseNode$21 },
|
|
15174
|
+
path,
|
|
14842
15175
|
plugin,
|
|
14843
15176
|
schema,
|
|
14844
15177
|
symbols: { z }
|
|
@@ -14890,7 +15223,7 @@ function numberResolver$1(ctx) {
|
|
|
14890
15223
|
if (maxNode) ctx.chain.current = maxNode;
|
|
14891
15224
|
return ctx.chain.current;
|
|
14892
15225
|
}
|
|
14893
|
-
function numberToNode$1({ plugin, schema }) {
|
|
15226
|
+
function numberToNode$1({ path, plugin, schema }) {
|
|
14894
15227
|
const z = plugin.external("zod.z");
|
|
14895
15228
|
const ctx = {
|
|
14896
15229
|
$,
|
|
@@ -14901,6 +15234,7 @@ function numberToNode$1({ plugin, schema }) {
|
|
|
14901
15234
|
max: maxNode$1,
|
|
14902
15235
|
min: minNode$1
|
|
14903
15236
|
},
|
|
15237
|
+
path,
|
|
14904
15238
|
plugin,
|
|
14905
15239
|
schema,
|
|
14906
15240
|
symbols: { z },
|
|
@@ -14916,9 +15250,12 @@ function numberToNode$1({ plugin, schema }) {
|
|
|
14916
15250
|
//#endregion
|
|
14917
15251
|
//#region src/plugins/zod/v3/toAst/object.ts
|
|
14918
15252
|
function additionalPropertiesNode$1(ctx) {
|
|
14919
|
-
const { applyModifiers, schema, walk
|
|
15253
|
+
const { applyModifiers, path, plugin, schema, walk } = ctx;
|
|
14920
15254
|
if (!schema.additionalProperties || schema.properties && Object.keys(schema.properties).length) return;
|
|
14921
|
-
const additionalResult = walk(schema.additionalProperties, childContext(
|
|
15255
|
+
const additionalResult = walk(schema.additionalProperties, childContext({
|
|
15256
|
+
path,
|
|
15257
|
+
plugin
|
|
15258
|
+
}, "additionalProperties"));
|
|
14922
15259
|
ctx._childResults.push(additionalResult);
|
|
14923
15260
|
return applyModifiers(additionalResult, {}).expression;
|
|
14924
15261
|
}
|
|
@@ -14934,12 +15271,15 @@ function objectResolver$1(ctx) {
|
|
|
14934
15271
|
return ctx.nodes.base(ctx);
|
|
14935
15272
|
}
|
|
14936
15273
|
function shapeNode$1(ctx) {
|
|
14937
|
-
const { applyModifiers, schema, walk
|
|
15274
|
+
const { applyModifiers, path, plugin, schema, walk } = ctx;
|
|
14938
15275
|
const shape = $.object().pretty();
|
|
14939
15276
|
for (const name in schema.properties) {
|
|
14940
15277
|
const property = schema.properties[name];
|
|
14941
15278
|
const isOptional = !schema.required?.includes(name);
|
|
14942
|
-
const propertyResult = walk(property, childContext(
|
|
15279
|
+
const propertyResult = walk(property, childContext({
|
|
15280
|
+
path,
|
|
15281
|
+
plugin
|
|
15282
|
+
}, "properties", name));
|
|
14943
15283
|
ctx._childResults.push(propertyResult);
|
|
14944
15284
|
const finalExpr = applyModifiers(propertyResult, { optional: isOptional });
|
|
14945
15285
|
shape.prop(name, finalExpr.expression);
|
|
@@ -14947,7 +15287,7 @@ function shapeNode$1(ctx) {
|
|
|
14947
15287
|
return shape;
|
|
14948
15288
|
}
|
|
14949
15289
|
function objectToAst$1(options) {
|
|
14950
|
-
const { applyModifiers, plugin, schema, walk
|
|
15290
|
+
const { applyModifiers, path, plugin, schema, walk } = options;
|
|
14951
15291
|
const childResults = [];
|
|
14952
15292
|
const z = plugin.external("zod.z");
|
|
14953
15293
|
const ctx = {
|
|
@@ -14960,11 +15300,11 @@ function objectToAst$1(options) {
|
|
|
14960
15300
|
base: baseNode$19,
|
|
14961
15301
|
shape: shapeNode$1
|
|
14962
15302
|
},
|
|
15303
|
+
path,
|
|
14963
15304
|
plugin,
|
|
14964
15305
|
schema,
|
|
14965
15306
|
symbols: { z },
|
|
14966
|
-
walk
|
|
14967
|
-
walkerCtx
|
|
15307
|
+
walk
|
|
14968
15308
|
};
|
|
14969
15309
|
const resolver = plugin.config["~resolvers"]?.object;
|
|
14970
15310
|
return {
|
|
@@ -15043,7 +15383,7 @@ function stringResolver$1(ctx) {
|
|
|
15043
15383
|
if (patternNode) ctx.chain.current = patternNode;
|
|
15044
15384
|
return ctx.chain.current;
|
|
15045
15385
|
}
|
|
15046
|
-
function stringToNode$1({ plugin, schema }) {
|
|
15386
|
+
function stringToNode$1({ path, plugin, schema }) {
|
|
15047
15387
|
const z = plugin.external("zod.z");
|
|
15048
15388
|
const ctx = {
|
|
15049
15389
|
$,
|
|
@@ -15057,6 +15397,7 @@ function stringToNode$1({ plugin, schema }) {
|
|
|
15057
15397
|
minLength: minLengthNode$2,
|
|
15058
15398
|
pattern: patternNode$1
|
|
15059
15399
|
},
|
|
15400
|
+
path,
|
|
15060
15401
|
plugin,
|
|
15061
15402
|
schema,
|
|
15062
15403
|
symbols: { z }
|
|
@@ -15091,11 +15432,14 @@ function tupleResolver$1(ctx) {
|
|
|
15091
15432
|
ctx.chain.current = baseResult;
|
|
15092
15433
|
return ctx.chain.current;
|
|
15093
15434
|
}
|
|
15094
|
-
function tupleToAst$1({ applyModifiers, plugin, schema, walk
|
|
15435
|
+
function tupleToAst$1({ applyModifiers, path, plugin, schema, walk }) {
|
|
15095
15436
|
const childResults = [];
|
|
15096
15437
|
const z = plugin.external("zod.z");
|
|
15097
15438
|
if (schema.items) schema.items.forEach((item, index) => {
|
|
15098
|
-
const itemResult = walk(item, childContext(
|
|
15439
|
+
const itemResult = walk(item, childContext({
|
|
15440
|
+
path,
|
|
15441
|
+
plugin
|
|
15442
|
+
}, "items", index));
|
|
15099
15443
|
childResults.push(itemResult);
|
|
15100
15444
|
});
|
|
15101
15445
|
const ctx = {
|
|
@@ -15107,11 +15451,11 @@ function tupleToAst$1({ applyModifiers, plugin, schema, walk, walkerCtx }) {
|
|
|
15107
15451
|
base: baseNode$17,
|
|
15108
15452
|
const: constNode$4
|
|
15109
15453
|
},
|
|
15454
|
+
path,
|
|
15110
15455
|
plugin,
|
|
15111
15456
|
schema,
|
|
15112
15457
|
symbols: { z },
|
|
15113
|
-
walk
|
|
15114
|
-
walkerCtx
|
|
15458
|
+
walk
|
|
15115
15459
|
};
|
|
15116
15460
|
const resolver = plugin.config["~resolvers"]?.tuple;
|
|
15117
15461
|
return {
|
|
@@ -15131,12 +15475,13 @@ function undefinedResolver$1(ctx) {
|
|
|
15131
15475
|
ctx.chain.current = baseResult;
|
|
15132
15476
|
return ctx.chain.current;
|
|
15133
15477
|
}
|
|
15134
|
-
function undefinedToAst$1({ plugin, schema }) {
|
|
15478
|
+
function undefinedToAst$1({ path, plugin, schema }) {
|
|
15135
15479
|
const z = plugin.external("zod.z");
|
|
15136
15480
|
const ctx = {
|
|
15137
15481
|
$,
|
|
15138
15482
|
chain: { current: $(z) },
|
|
15139
15483
|
nodes: { base: baseNode$16 },
|
|
15484
|
+
path,
|
|
15140
15485
|
plugin,
|
|
15141
15486
|
schema,
|
|
15142
15487
|
symbols: { z }
|
|
@@ -15174,7 +15519,7 @@ function unionResolver$1(ctx) {
|
|
|
15174
15519
|
ctx.chain.current = baseResult;
|
|
15175
15520
|
return ctx.chain.current;
|
|
15176
15521
|
}
|
|
15177
|
-
function unionToAst$1({ childResults, parentSchema, plugin, schemas }) {
|
|
15522
|
+
function unionToAst$1({ childResults, parentSchema, path, plugin, schemas }) {
|
|
15178
15523
|
const z = plugin.external("zod.z");
|
|
15179
15524
|
const ctx = {
|
|
15180
15525
|
$,
|
|
@@ -15182,6 +15527,7 @@ function unionToAst$1({ childResults, parentSchema, plugin, schemas }) {
|
|
|
15182
15527
|
childResults,
|
|
15183
15528
|
nodes: { base: baseNode$15 },
|
|
15184
15529
|
parentSchema,
|
|
15530
|
+
path,
|
|
15185
15531
|
plugin,
|
|
15186
15532
|
schema: parentSchema,
|
|
15187
15533
|
schemas,
|
|
@@ -15205,12 +15551,13 @@ function voidResolver$1(ctx) {
|
|
|
15205
15551
|
ctx.chain.current = baseResult;
|
|
15206
15552
|
return ctx.chain.current;
|
|
15207
15553
|
}
|
|
15208
|
-
function voidToAst$1({ plugin, schema }) {
|
|
15554
|
+
function voidToAst$1({ path, plugin, schema }) {
|
|
15209
15555
|
const z = plugin.external("zod.z");
|
|
15210
15556
|
const ctx = {
|
|
15211
15557
|
$,
|
|
15212
15558
|
chain: { current: $(z) },
|
|
15213
15559
|
nodes: { base: baseNode$14 },
|
|
15560
|
+
path,
|
|
15214
15561
|
plugin,
|
|
15215
15562
|
schema,
|
|
15216
15563
|
symbols: { z }
|
|
@@ -15219,7 +15566,7 @@ function voidToAst$1({ plugin, schema }) {
|
|
|
15219
15566
|
return resolver?.(ctx) ?? voidResolver$1(ctx);
|
|
15220
15567
|
}
|
|
15221
15568
|
//#endregion
|
|
15222
|
-
//#region src/plugins/zod/v3/
|
|
15569
|
+
//#region src/plugins/zod/v3/visitor.ts
|
|
15223
15570
|
function getDefaultValue$1(meta) {
|
|
15224
15571
|
return meta.format ? maybeBigInt(meta.default, meta.format) : $.fromValue(meta.default);
|
|
15225
15572
|
}
|
|
@@ -15245,10 +15592,10 @@ function createVisitor$1(config = {}) {
|
|
|
15245
15592
|
const applyModifiers = (result, opts) => this.applyModifiers(result, ctx, opts);
|
|
15246
15593
|
const { childResults, expression } = arrayToAst$1({
|
|
15247
15594
|
applyModifiers,
|
|
15595
|
+
path: ctx.path,
|
|
15248
15596
|
plugin: ctx.plugin,
|
|
15249
15597
|
schema,
|
|
15250
|
-
walk
|
|
15251
|
-
walkerCtx: ctx
|
|
15598
|
+
walk
|
|
15252
15599
|
});
|
|
15253
15600
|
return {
|
|
15254
15601
|
expression,
|
|
@@ -15258,6 +15605,7 @@ function createVisitor$1(config = {}) {
|
|
|
15258
15605
|
boolean(schema, ctx) {
|
|
15259
15606
|
return {
|
|
15260
15607
|
expression: booleanToAst$1({
|
|
15608
|
+
path: ctx.path,
|
|
15261
15609
|
plugin: ctx.plugin,
|
|
15262
15610
|
schema
|
|
15263
15611
|
}),
|
|
@@ -15266,6 +15614,7 @@ function createVisitor$1(config = {}) {
|
|
|
15266
15614
|
},
|
|
15267
15615
|
enum(schema, ctx) {
|
|
15268
15616
|
const expression = enumToAst$1({
|
|
15617
|
+
path: ctx.path,
|
|
15269
15618
|
plugin: ctx.plugin,
|
|
15270
15619
|
schema
|
|
15271
15620
|
});
|
|
@@ -15281,6 +15630,7 @@ function createVisitor$1(config = {}) {
|
|
|
15281
15630
|
integer(schema, ctx) {
|
|
15282
15631
|
return {
|
|
15283
15632
|
expression: numberToNode$1({
|
|
15633
|
+
path: ctx.path,
|
|
15284
15634
|
plugin: ctx.plugin,
|
|
15285
15635
|
schema
|
|
15286
15636
|
}),
|
|
@@ -15314,6 +15664,7 @@ function createVisitor$1(config = {}) {
|
|
|
15314
15664
|
const { expression } = intersectionToAst$1({
|
|
15315
15665
|
childResults: items,
|
|
15316
15666
|
parentSchema,
|
|
15667
|
+
path: ctx.path,
|
|
15317
15668
|
plugin: ctx.plugin,
|
|
15318
15669
|
schemas
|
|
15319
15670
|
});
|
|
@@ -15333,6 +15684,7 @@ function createVisitor$1(config = {}) {
|
|
|
15333
15684
|
never(schema, ctx) {
|
|
15334
15685
|
return {
|
|
15335
15686
|
expression: neverToAst$1({
|
|
15687
|
+
path: ctx.path,
|
|
15336
15688
|
plugin: ctx.plugin,
|
|
15337
15689
|
schema
|
|
15338
15690
|
}),
|
|
@@ -15346,6 +15698,7 @@ function createVisitor$1(config = {}) {
|
|
|
15346
15698
|
null(schema, ctx) {
|
|
15347
15699
|
return {
|
|
15348
15700
|
expression: nullToAst$1({
|
|
15701
|
+
path: ctx.path,
|
|
15349
15702
|
plugin: ctx.plugin,
|
|
15350
15703
|
schema
|
|
15351
15704
|
}),
|
|
@@ -15359,6 +15712,7 @@ function createVisitor$1(config = {}) {
|
|
|
15359
15712
|
number(schema, ctx) {
|
|
15360
15713
|
return {
|
|
15361
15714
|
expression: numberToNode$1({
|
|
15715
|
+
path: ctx.path,
|
|
15362
15716
|
plugin: ctx.plugin,
|
|
15363
15717
|
schema
|
|
15364
15718
|
}),
|
|
@@ -15372,10 +15726,10 @@ function createVisitor$1(config = {}) {
|
|
|
15372
15726
|
const applyModifiers = (result, opts) => this.applyModifiers(result, ctx, opts);
|
|
15373
15727
|
const { childResults, expression } = objectToAst$1({
|
|
15374
15728
|
applyModifiers,
|
|
15729
|
+
path: ctx.path,
|
|
15375
15730
|
plugin: ctx.plugin,
|
|
15376
15731
|
schema,
|
|
15377
|
-
walk
|
|
15378
|
-
walkerCtx: ctx
|
|
15732
|
+
walk
|
|
15379
15733
|
});
|
|
15380
15734
|
return {
|
|
15381
15735
|
expression,
|
|
@@ -15417,6 +15771,7 @@ function createVisitor$1(config = {}) {
|
|
|
15417
15771
|
string(schema, ctx) {
|
|
15418
15772
|
if (shouldCoerceToBigInt(schema.format)) return {
|
|
15419
15773
|
expression: numberToNode$1({
|
|
15774
|
+
path: ctx.path,
|
|
15420
15775
|
plugin: ctx.plugin,
|
|
15421
15776
|
schema: {
|
|
15422
15777
|
...schema,
|
|
@@ -15427,6 +15782,7 @@ function createVisitor$1(config = {}) {
|
|
|
15427
15782
|
};
|
|
15428
15783
|
return {
|
|
15429
15784
|
expression: stringToNode$1({
|
|
15785
|
+
path: ctx.path,
|
|
15430
15786
|
plugin: ctx.plugin,
|
|
15431
15787
|
schema
|
|
15432
15788
|
}),
|
|
@@ -15437,10 +15793,10 @@ function createVisitor$1(config = {}) {
|
|
|
15437
15793
|
const applyModifiers = (result, opts) => this.applyModifiers(result, ctx, opts);
|
|
15438
15794
|
const { childResults, expression } = tupleToAst$1({
|
|
15439
15795
|
applyModifiers,
|
|
15796
|
+
path: ctx.path,
|
|
15440
15797
|
plugin: ctx.plugin,
|
|
15441
15798
|
schema,
|
|
15442
|
-
walk
|
|
15443
|
-
walkerCtx: ctx
|
|
15799
|
+
walk
|
|
15444
15800
|
});
|
|
15445
15801
|
return {
|
|
15446
15802
|
expression,
|
|
@@ -15450,6 +15806,7 @@ function createVisitor$1(config = {}) {
|
|
|
15450
15806
|
undefined(schema, ctx) {
|
|
15451
15807
|
return {
|
|
15452
15808
|
expression: undefinedToAst$1({
|
|
15809
|
+
path: ctx.path,
|
|
15453
15810
|
plugin: ctx.plugin,
|
|
15454
15811
|
schema
|
|
15455
15812
|
}),
|
|
@@ -15466,6 +15823,7 @@ function createVisitor$1(config = {}) {
|
|
|
15466
15823
|
const { expression } = unionToAst$1({
|
|
15467
15824
|
childResults: items,
|
|
15468
15825
|
parentSchema,
|
|
15826
|
+
path: ctx.path,
|
|
15469
15827
|
plugin: ctx.plugin,
|
|
15470
15828
|
schemas
|
|
15471
15829
|
});
|
|
@@ -15485,6 +15843,7 @@ function createVisitor$1(config = {}) {
|
|
|
15485
15843
|
unknown(schema, ctx) {
|
|
15486
15844
|
return {
|
|
15487
15845
|
expression: unknownToAst$1({
|
|
15846
|
+
path: ctx.path,
|
|
15488
15847
|
plugin: ctx.plugin,
|
|
15489
15848
|
schema
|
|
15490
15849
|
}),
|
|
@@ -15498,6 +15857,7 @@ function createVisitor$1(config = {}) {
|
|
|
15498
15857
|
void(schema, ctx) {
|
|
15499
15858
|
return {
|
|
15500
15859
|
expression: voidToAst$1({
|
|
15860
|
+
path: ctx.path,
|
|
15501
15861
|
plugin: ctx.plugin,
|
|
15502
15862
|
schema
|
|
15503
15863
|
}),
|
|
@@ -15642,12 +16002,13 @@ function unknownResolver(ctx) {
|
|
|
15642
16002
|
ctx.chain.current = baseResult;
|
|
15643
16003
|
return ctx.chain.current;
|
|
15644
16004
|
}
|
|
15645
|
-
function unknownToAst({ plugin, schema }) {
|
|
16005
|
+
function unknownToAst({ path, plugin, schema }) {
|
|
15646
16006
|
const z = plugin.external("zod.z");
|
|
15647
16007
|
const ctx = {
|
|
15648
16008
|
$,
|
|
15649
16009
|
chain: { current: $(z) },
|
|
15650
16010
|
nodes: { base: baseNode$13 },
|
|
16011
|
+
path,
|
|
15651
16012
|
plugin,
|
|
15652
16013
|
schema,
|
|
15653
16014
|
symbols: { z }
|
|
@@ -15658,12 +16019,13 @@ function unknownToAst({ plugin, schema }) {
|
|
|
15658
16019
|
//#endregion
|
|
15659
16020
|
//#region src/plugins/zod/v4/toAst/array.ts
|
|
15660
16021
|
function baseNode$12(ctx) {
|
|
15661
|
-
const { applyModifiers, childResults, plugin, schema, symbols } = ctx;
|
|
16022
|
+
const { applyModifiers, childResults, path, plugin, schema, symbols } = ctx;
|
|
15662
16023
|
const { z } = symbols;
|
|
15663
16024
|
const arrayFn = $(z).attr(identifiers.array);
|
|
15664
16025
|
let normalizedSchema = schema;
|
|
15665
16026
|
if (normalizedSchema.items) normalizedSchema = deduplicateSchema({ schema: normalizedSchema });
|
|
15666
16027
|
if (!normalizedSchema.items) return arrayFn.call(unknownToAst({
|
|
16028
|
+
path,
|
|
15667
16029
|
plugin,
|
|
15668
16030
|
schema: { type: "unknown" }
|
|
15669
16031
|
}));
|
|
@@ -15685,6 +16047,7 @@ function baseNode$12(ctx) {
|
|
|
15685
16047
|
} else return arrayFn.call($(z).attr(identifiers.union).call($.array(...itemExpressions)));
|
|
15686
16048
|
}
|
|
15687
16049
|
return arrayFn.call(unknownToAst({
|
|
16050
|
+
path,
|
|
15688
16051
|
plugin,
|
|
15689
16052
|
schema: { type: "unknown" }
|
|
15690
16053
|
}));
|
|
@@ -15716,14 +16079,17 @@ function arrayResolver(ctx) {
|
|
|
15716
16079
|
}
|
|
15717
16080
|
return ctx.chain.current;
|
|
15718
16081
|
}
|
|
15719
|
-
function arrayToAst({ applyModifiers, plugin, schema, walk
|
|
16082
|
+
function arrayToAst({ applyModifiers, path, plugin, schema, walk }) {
|
|
15720
16083
|
const childResults = [];
|
|
15721
16084
|
let schemaCopy = schema;
|
|
15722
16085
|
const z = plugin.external("zod.z");
|
|
15723
16086
|
if (schemaCopy.items) {
|
|
15724
16087
|
schemaCopy = deduplicateSchema({ schema: schemaCopy });
|
|
15725
16088
|
schemaCopy.items.forEach((item, index) => {
|
|
15726
|
-
const itemResult = walk(item, childContext(
|
|
16089
|
+
const itemResult = walk(item, childContext({
|
|
16090
|
+
path,
|
|
16091
|
+
plugin
|
|
16092
|
+
}, "items", index));
|
|
15727
16093
|
childResults.push(itemResult);
|
|
15728
16094
|
});
|
|
15729
16095
|
}
|
|
@@ -15738,11 +16104,11 @@ function arrayToAst({ applyModifiers, plugin, schema, walk, walkerCtx }) {
|
|
|
15738
16104
|
maxLength: maxLengthNode$1,
|
|
15739
16105
|
minLength: minLengthNode$1
|
|
15740
16106
|
},
|
|
16107
|
+
path,
|
|
15741
16108
|
plugin,
|
|
15742
16109
|
schema,
|
|
15743
16110
|
symbols: { z },
|
|
15744
|
-
walk
|
|
15745
|
-
walkerCtx
|
|
16111
|
+
walk
|
|
15746
16112
|
};
|
|
15747
16113
|
const resolver = plugin.config["~resolvers"]?.array;
|
|
15748
16114
|
return {
|
|
@@ -15773,7 +16139,7 @@ function booleanResolver(ctx) {
|
|
|
15773
16139
|
ctx.chain.current = baseResult;
|
|
15774
16140
|
return ctx.chain.current;
|
|
15775
16141
|
}
|
|
15776
|
-
function booleanToAst({ plugin, schema }) {
|
|
16142
|
+
function booleanToAst({ path, plugin, schema }) {
|
|
15777
16143
|
const z = plugin.external("zod.z");
|
|
15778
16144
|
const ctx = {
|
|
15779
16145
|
$,
|
|
@@ -15782,6 +16148,7 @@ function booleanToAst({ plugin, schema }) {
|
|
|
15782
16148
|
base: baseNode$11,
|
|
15783
16149
|
const: constNode$3
|
|
15784
16150
|
},
|
|
16151
|
+
path,
|
|
15785
16152
|
plugin,
|
|
15786
16153
|
schema,
|
|
15787
16154
|
symbols: { z }
|
|
@@ -15795,45 +16162,48 @@ function itemsNode(ctx) {
|
|
|
15795
16162
|
const { schema, symbols } = ctx;
|
|
15796
16163
|
const { z } = symbols;
|
|
15797
16164
|
const enumMembers = [];
|
|
15798
|
-
const
|
|
15799
|
-
let isNullable = false;
|
|
15800
|
-
let allStrings = true;
|
|
16165
|
+
const literalSchemas = [];
|
|
15801
16166
|
for (const item of schema.items ?? []) if (item.type === "string" && typeof item.const === "string") {
|
|
15802
16167
|
const literal = $.literal(item.const);
|
|
15803
16168
|
enumMembers.push(literal);
|
|
15804
|
-
|
|
16169
|
+
literalSchemas.push($(z).attr(identifiers.literal).call(literal));
|
|
15805
16170
|
} else if ((item.type === "number" || item.type === "integer") && typeof item.const === "number") {
|
|
15806
|
-
allStrings = false;
|
|
15807
16171
|
const literal = $.literal(item.const);
|
|
15808
|
-
|
|
16172
|
+
literalSchemas.push($(z).attr(identifiers.literal).call(literal));
|
|
15809
16173
|
} else if (item.type === "boolean" && typeof item.const === "boolean") {
|
|
15810
|
-
allStrings = false;
|
|
15811
16174
|
const literal = $.literal(item.const);
|
|
15812
|
-
|
|
15813
|
-
}
|
|
16175
|
+
literalSchemas.push($(z).attr(identifiers.literal).call(literal));
|
|
16176
|
+
}
|
|
15814
16177
|
return {
|
|
15815
|
-
allStrings,
|
|
15816
16178
|
enumMembers,
|
|
15817
|
-
|
|
15818
|
-
literalMembers
|
|
16179
|
+
literalSchemas
|
|
15819
16180
|
};
|
|
15820
16181
|
}
|
|
15821
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
|
+
});
|
|
15822
16189
|
const { symbols } = ctx;
|
|
15823
16190
|
const { z } = symbols;
|
|
15824
|
-
const
|
|
15825
|
-
|
|
15826
|
-
|
|
15827
|
-
|
|
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));
|
|
15828
16200
|
}
|
|
15829
16201
|
function enumResolver(ctx) {
|
|
15830
|
-
const { literalMembers } = ctx.nodes.items(ctx);
|
|
15831
|
-
if (!literalMembers.length) return ctx.chain.current;
|
|
15832
16202
|
const baseExpression = ctx.nodes.base(ctx);
|
|
15833
16203
|
ctx.chain.current = baseExpression;
|
|
15834
16204
|
return ctx.chain.current;
|
|
15835
16205
|
}
|
|
15836
|
-
function enumToAst({ plugin, schema }) {
|
|
16206
|
+
function enumToAst({ path, plugin, schema }) {
|
|
15837
16207
|
const z = plugin.external("zod.z");
|
|
15838
16208
|
const ctx = {
|
|
15839
16209
|
$,
|
|
@@ -15842,15 +16212,11 @@ function enumToAst({ plugin, schema }) {
|
|
|
15842
16212
|
base: baseNode$10,
|
|
15843
16213
|
items: itemsNode
|
|
15844
16214
|
},
|
|
16215
|
+
path,
|
|
15845
16216
|
plugin,
|
|
15846
16217
|
schema,
|
|
15847
16218
|
symbols: { z }
|
|
15848
16219
|
};
|
|
15849
|
-
const { literalMembers } = itemsNode(ctx);
|
|
15850
|
-
if (!literalMembers.length) return unknownToAst({
|
|
15851
|
-
plugin,
|
|
15852
|
-
schema: { type: "unknown" }
|
|
15853
|
-
});
|
|
15854
16220
|
const resolver = plugin.config["~resolvers"]?.enum;
|
|
15855
16221
|
return resolver?.(ctx) ?? enumResolver(ctx);
|
|
15856
16222
|
}
|
|
@@ -15873,7 +16239,7 @@ function intersectionResolver(ctx) {
|
|
|
15873
16239
|
ctx.chain.current = baseResult;
|
|
15874
16240
|
return ctx.chain.current;
|
|
15875
16241
|
}
|
|
15876
|
-
function intersectionToAst({ childResults, parentSchema, plugin, schemas }) {
|
|
16242
|
+
function intersectionToAst({ childResults, parentSchema, path, plugin, schemas }) {
|
|
15877
16243
|
const z = plugin.external("zod.z");
|
|
15878
16244
|
const ctx = {
|
|
15879
16245
|
$,
|
|
@@ -15881,6 +16247,7 @@ function intersectionToAst({ childResults, parentSchema, plugin, schemas }) {
|
|
|
15881
16247
|
childResults,
|
|
15882
16248
|
nodes: { base: baseNode$9 },
|
|
15883
16249
|
parentSchema,
|
|
16250
|
+
path,
|
|
15884
16251
|
plugin,
|
|
15885
16252
|
schema: parentSchema,
|
|
15886
16253
|
schemas,
|
|
@@ -15904,12 +16271,13 @@ function neverResolver(ctx) {
|
|
|
15904
16271
|
ctx.chain.current = baseResult;
|
|
15905
16272
|
return ctx.chain.current;
|
|
15906
16273
|
}
|
|
15907
|
-
function neverToAst({ plugin, schema }) {
|
|
16274
|
+
function neverToAst({ path, plugin, schema }) {
|
|
15908
16275
|
const z = plugin.external("zod.z");
|
|
15909
16276
|
const ctx = {
|
|
15910
16277
|
$,
|
|
15911
16278
|
chain: { current: $(z) },
|
|
15912
16279
|
nodes: { base: baseNode$8 },
|
|
16280
|
+
path,
|
|
15913
16281
|
plugin,
|
|
15914
16282
|
schema,
|
|
15915
16283
|
symbols: { z }
|
|
@@ -15929,12 +16297,13 @@ function nullResolver(ctx) {
|
|
|
15929
16297
|
ctx.chain.current = baseResult;
|
|
15930
16298
|
return ctx.chain.current;
|
|
15931
16299
|
}
|
|
15932
|
-
function nullToAst({ plugin, schema }) {
|
|
16300
|
+
function nullToAst({ path, plugin, schema }) {
|
|
15933
16301
|
const z = plugin.external("zod.z");
|
|
15934
16302
|
const ctx = {
|
|
15935
16303
|
$,
|
|
15936
16304
|
chain: { current: $(z) },
|
|
15937
16305
|
nodes: { base: baseNode$7 },
|
|
16306
|
+
path,
|
|
15938
16307
|
plugin,
|
|
15939
16308
|
schema,
|
|
15940
16309
|
symbols: { z }
|
|
@@ -15986,7 +16355,7 @@ function numberResolver(ctx) {
|
|
|
15986
16355
|
if (maxNode) ctx.chain.current = maxNode;
|
|
15987
16356
|
return ctx.chain.current;
|
|
15988
16357
|
}
|
|
15989
|
-
function numberToNode({ plugin, schema }) {
|
|
16358
|
+
function numberToNode({ path, plugin, schema }) {
|
|
15990
16359
|
const z = plugin.external("zod.z");
|
|
15991
16360
|
const ctx = {
|
|
15992
16361
|
$,
|
|
@@ -15997,6 +16366,7 @@ function numberToNode({ plugin, schema }) {
|
|
|
15997
16366
|
max: maxNode,
|
|
15998
16367
|
min: minNode
|
|
15999
16368
|
},
|
|
16369
|
+
path,
|
|
16000
16370
|
plugin,
|
|
16001
16371
|
schema,
|
|
16002
16372
|
symbols: { z },
|
|
@@ -16012,9 +16382,12 @@ function numberToNode({ plugin, schema }) {
|
|
|
16012
16382
|
//#endregion
|
|
16013
16383
|
//#region src/plugins/zod/v4/toAst/object.ts
|
|
16014
16384
|
function additionalPropertiesNode(ctx) {
|
|
16015
|
-
const { _childResults, applyModifiers, schema, walk
|
|
16385
|
+
const { _childResults, applyModifiers, path, plugin, schema, walk } = ctx;
|
|
16016
16386
|
if (!schema.additionalProperties || schema.properties && Object.keys(schema.properties).length) return;
|
|
16017
|
-
const additionalResult = walk(schema.additionalProperties, childContext(
|
|
16387
|
+
const additionalResult = walk(schema.additionalProperties, childContext({
|
|
16388
|
+
path,
|
|
16389
|
+
plugin
|
|
16390
|
+
}, "additionalProperties"));
|
|
16018
16391
|
_childResults.push(additionalResult);
|
|
16019
16392
|
return applyModifiers(additionalResult, {}).expression;
|
|
16020
16393
|
}
|
|
@@ -16030,20 +16403,22 @@ function objectResolver(ctx) {
|
|
|
16030
16403
|
return ctx.nodes.base(ctx);
|
|
16031
16404
|
}
|
|
16032
16405
|
function shapeNode(ctx) {
|
|
16033
|
-
const { _childResults, applyModifiers, schema, walk
|
|
16406
|
+
const { _childResults, applyModifiers, path, plugin, schema, walk } = ctx;
|
|
16034
16407
|
const shape = $.object().pretty();
|
|
16035
16408
|
for (const name in schema.properties) {
|
|
16036
16409
|
const property = schema.properties[name];
|
|
16037
16410
|
const isOptional = !schema.required?.includes(name);
|
|
16038
|
-
const propertyResult = walk(property, childContext(
|
|
16411
|
+
const propertyResult = walk(property, childContext({
|
|
16412
|
+
path,
|
|
16413
|
+
plugin
|
|
16414
|
+
}, "properties", name));
|
|
16039
16415
|
_childResults.push(propertyResult);
|
|
16040
16416
|
const finalExpr = applyModifiers(propertyResult, { optional: isOptional });
|
|
16041
16417
|
shape.prop(name, finalExpr.expression);
|
|
16042
16418
|
}
|
|
16043
16419
|
return shape;
|
|
16044
16420
|
}
|
|
16045
|
-
function objectToAst(
|
|
16046
|
-
const { applyModifiers, plugin, schema, walk, walkerCtx } = options;
|
|
16421
|
+
function objectToAst({ applyModifiers, path, plugin, schema, walk }) {
|
|
16047
16422
|
const childResults = [];
|
|
16048
16423
|
const z = plugin.external("zod.z");
|
|
16049
16424
|
const ctx = {
|
|
@@ -16056,11 +16431,11 @@ function objectToAst(options) {
|
|
|
16056
16431
|
base: baseNode$5,
|
|
16057
16432
|
shape: shapeNode
|
|
16058
16433
|
},
|
|
16434
|
+
path,
|
|
16059
16435
|
plugin,
|
|
16060
16436
|
schema,
|
|
16061
16437
|
symbols: { z },
|
|
16062
|
-
walk
|
|
16063
|
-
walkerCtx
|
|
16438
|
+
walk
|
|
16064
16439
|
};
|
|
16065
16440
|
const resolver = plugin.config["~resolvers"]?.object;
|
|
16066
16441
|
return {
|
|
@@ -16141,7 +16516,7 @@ function stringResolver(ctx) {
|
|
|
16141
16516
|
if (patternNode) ctx.chain.current = patternNode;
|
|
16142
16517
|
return ctx.chain.current;
|
|
16143
16518
|
}
|
|
16144
|
-
function stringToNode({ plugin, schema }) {
|
|
16519
|
+
function stringToNode({ path, plugin, schema }) {
|
|
16145
16520
|
const z = plugin.external("zod.z");
|
|
16146
16521
|
const ctx = {
|
|
16147
16522
|
$,
|
|
@@ -16155,6 +16530,7 @@ function stringToNode({ plugin, schema }) {
|
|
|
16155
16530
|
minLength: minLengthNode,
|
|
16156
16531
|
pattern: patternNode
|
|
16157
16532
|
},
|
|
16533
|
+
path,
|
|
16158
16534
|
plugin,
|
|
16159
16535
|
schema,
|
|
16160
16536
|
symbols: { z }
|
|
@@ -16189,11 +16565,14 @@ function tupleResolver(ctx) {
|
|
|
16189
16565
|
ctx.chain.current = baseResult;
|
|
16190
16566
|
return ctx.chain.current;
|
|
16191
16567
|
}
|
|
16192
|
-
function tupleToAst({ applyModifiers, plugin, schema, walk
|
|
16568
|
+
function tupleToAst({ applyModifiers, path, plugin, schema, walk }) {
|
|
16193
16569
|
const childResults = [];
|
|
16194
16570
|
const z = plugin.external("zod.z");
|
|
16195
16571
|
if (schema.items) schema.items.forEach((item, index) => {
|
|
16196
|
-
const itemResult = walk(item, childContext(
|
|
16572
|
+
const itemResult = walk(item, childContext({
|
|
16573
|
+
path,
|
|
16574
|
+
plugin
|
|
16575
|
+
}, "items", index));
|
|
16197
16576
|
childResults.push(itemResult);
|
|
16198
16577
|
});
|
|
16199
16578
|
const ctx = {
|
|
@@ -16205,11 +16584,11 @@ function tupleToAst({ applyModifiers, plugin, schema, walk, walkerCtx }) {
|
|
|
16205
16584
|
base: baseNode$3,
|
|
16206
16585
|
const: constNode
|
|
16207
16586
|
},
|
|
16587
|
+
path,
|
|
16208
16588
|
plugin,
|
|
16209
16589
|
schema,
|
|
16210
16590
|
symbols: { z },
|
|
16211
|
-
walk
|
|
16212
|
-
walkerCtx
|
|
16591
|
+
walk
|
|
16213
16592
|
};
|
|
16214
16593
|
const resolver = plugin.config["~resolvers"]?.tuple;
|
|
16215
16594
|
return {
|
|
@@ -16229,12 +16608,13 @@ function undefinedResolver(ctx) {
|
|
|
16229
16608
|
ctx.chain.current = baseResult;
|
|
16230
16609
|
return ctx.chain.current;
|
|
16231
16610
|
}
|
|
16232
|
-
function undefinedToAst({ plugin, schema }) {
|
|
16611
|
+
function undefinedToAst({ path, plugin, schema }) {
|
|
16233
16612
|
const z = plugin.external("zod.z");
|
|
16234
16613
|
const ctx = {
|
|
16235
16614
|
$,
|
|
16236
16615
|
chain: { current: $(z) },
|
|
16237
16616
|
nodes: { base: baseNode$2 },
|
|
16617
|
+
path,
|
|
16238
16618
|
plugin,
|
|
16239
16619
|
schema,
|
|
16240
16620
|
symbols: { z }
|
|
@@ -16275,7 +16655,7 @@ function unionResolver(ctx) {
|
|
|
16275
16655
|
ctx.chain.current = baseResult;
|
|
16276
16656
|
return ctx.chain.current;
|
|
16277
16657
|
}
|
|
16278
|
-
function unionToAst({ childResults, parentSchema, plugin, schemas }) {
|
|
16658
|
+
function unionToAst({ childResults, parentSchema, path, plugin, schemas }) {
|
|
16279
16659
|
const z = plugin.external("zod.z");
|
|
16280
16660
|
const ctx = {
|
|
16281
16661
|
$,
|
|
@@ -16283,6 +16663,7 @@ function unionToAst({ childResults, parentSchema, plugin, schemas }) {
|
|
|
16283
16663
|
childResults,
|
|
16284
16664
|
nodes: { base: baseNode$1 },
|
|
16285
16665
|
parentSchema,
|
|
16666
|
+
path,
|
|
16286
16667
|
plugin,
|
|
16287
16668
|
schema: parentSchema,
|
|
16288
16669
|
schemas,
|
|
@@ -16306,12 +16687,13 @@ function voidResolver(ctx) {
|
|
|
16306
16687
|
ctx.chain.current = baseResult;
|
|
16307
16688
|
return ctx.chain.current;
|
|
16308
16689
|
}
|
|
16309
|
-
function voidToAst({ plugin, schema }) {
|
|
16690
|
+
function voidToAst({ path, plugin, schema }) {
|
|
16310
16691
|
const z = plugin.external("zod.z");
|
|
16311
16692
|
const ctx = {
|
|
16312
16693
|
$,
|
|
16313
16694
|
chain: { current: $(z) },
|
|
16314
16695
|
nodes: { base: baseNode },
|
|
16696
|
+
path,
|
|
16315
16697
|
plugin,
|
|
16316
16698
|
schema,
|
|
16317
16699
|
symbols: { z }
|
|
@@ -16320,7 +16702,7 @@ function voidToAst({ plugin, schema }) {
|
|
|
16320
16702
|
return resolver?.(ctx) ?? voidResolver(ctx);
|
|
16321
16703
|
}
|
|
16322
16704
|
//#endregion
|
|
16323
|
-
//#region src/plugins/zod/v4/
|
|
16705
|
+
//#region src/plugins/zod/v4/visitor.ts
|
|
16324
16706
|
function getDefaultValue(meta) {
|
|
16325
16707
|
return meta.format ? maybeBigInt(meta.default, meta.format) : $.fromValue(meta.default);
|
|
16326
16708
|
}
|
|
@@ -16343,10 +16725,10 @@ function createVisitor(config = {}) {
|
|
|
16343
16725
|
const applyModifiers = (result, opts) => this.applyModifiers(result, ctx, opts);
|
|
16344
16726
|
const { childResults, expression } = arrayToAst({
|
|
16345
16727
|
applyModifiers,
|
|
16728
|
+
path: ctx.path,
|
|
16346
16729
|
plugin: ctx.plugin,
|
|
16347
16730
|
schema,
|
|
16348
|
-
walk
|
|
16349
|
-
walkerCtx: ctx
|
|
16731
|
+
walk
|
|
16350
16732
|
});
|
|
16351
16733
|
return {
|
|
16352
16734
|
expression,
|
|
@@ -16356,6 +16738,7 @@ function createVisitor(config = {}) {
|
|
|
16356
16738
|
boolean(schema, ctx) {
|
|
16357
16739
|
return {
|
|
16358
16740
|
expression: booleanToAst({
|
|
16741
|
+
path: ctx.path,
|
|
16359
16742
|
plugin: ctx.plugin,
|
|
16360
16743
|
schema
|
|
16361
16744
|
}),
|
|
@@ -16364,6 +16747,7 @@ function createVisitor(config = {}) {
|
|
|
16364
16747
|
},
|
|
16365
16748
|
enum(schema, ctx) {
|
|
16366
16749
|
const expression = enumToAst({
|
|
16750
|
+
path: ctx.path,
|
|
16367
16751
|
plugin: ctx.plugin,
|
|
16368
16752
|
schema
|
|
16369
16753
|
});
|
|
@@ -16379,6 +16763,7 @@ function createVisitor(config = {}) {
|
|
|
16379
16763
|
integer(schema, ctx) {
|
|
16380
16764
|
return {
|
|
16381
16765
|
expression: numberToNode({
|
|
16766
|
+
path: ctx.path,
|
|
16382
16767
|
plugin: ctx.plugin,
|
|
16383
16768
|
schema
|
|
16384
16769
|
}),
|
|
@@ -16412,6 +16797,7 @@ function createVisitor(config = {}) {
|
|
|
16412
16797
|
const { expression } = intersectionToAst({
|
|
16413
16798
|
childResults: items,
|
|
16414
16799
|
parentSchema,
|
|
16800
|
+
path: ctx.path,
|
|
16415
16801
|
plugin: ctx.plugin,
|
|
16416
16802
|
schemas
|
|
16417
16803
|
});
|
|
@@ -16431,6 +16817,7 @@ function createVisitor(config = {}) {
|
|
|
16431
16817
|
never(schema, ctx) {
|
|
16432
16818
|
return {
|
|
16433
16819
|
expression: neverToAst({
|
|
16820
|
+
path: ctx.path,
|
|
16434
16821
|
plugin: ctx.plugin,
|
|
16435
16822
|
schema
|
|
16436
16823
|
}),
|
|
@@ -16444,6 +16831,7 @@ function createVisitor(config = {}) {
|
|
|
16444
16831
|
null(schema, ctx) {
|
|
16445
16832
|
return {
|
|
16446
16833
|
expression: nullToAst({
|
|
16834
|
+
path: ctx.path,
|
|
16447
16835
|
plugin: ctx.plugin,
|
|
16448
16836
|
schema
|
|
16449
16837
|
}),
|
|
@@ -16457,6 +16845,7 @@ function createVisitor(config = {}) {
|
|
|
16457
16845
|
number(schema, ctx) {
|
|
16458
16846
|
return {
|
|
16459
16847
|
expression: numberToNode({
|
|
16848
|
+
path: ctx.path,
|
|
16460
16849
|
plugin: ctx.plugin,
|
|
16461
16850
|
schema
|
|
16462
16851
|
}),
|
|
@@ -16470,10 +16859,10 @@ function createVisitor(config = {}) {
|
|
|
16470
16859
|
const applyModifiers = (result, opts) => this.applyModifiers(result, ctx, opts);
|
|
16471
16860
|
const { childResults, expression } = objectToAst({
|
|
16472
16861
|
applyModifiers,
|
|
16862
|
+
path: ctx.path,
|
|
16473
16863
|
plugin: ctx.plugin,
|
|
16474
16864
|
schema,
|
|
16475
|
-
walk
|
|
16476
|
-
walkerCtx: ctx
|
|
16865
|
+
walk
|
|
16477
16866
|
});
|
|
16478
16867
|
return {
|
|
16479
16868
|
expression,
|
|
@@ -16524,6 +16913,7 @@ function createVisitor(config = {}) {
|
|
|
16524
16913
|
string(schema, ctx) {
|
|
16525
16914
|
if (shouldCoerceToBigInt(schema.format)) return {
|
|
16526
16915
|
expression: numberToNode({
|
|
16916
|
+
path: ctx.path,
|
|
16527
16917
|
plugin: ctx.plugin,
|
|
16528
16918
|
schema: {
|
|
16529
16919
|
...schema,
|
|
@@ -16534,6 +16924,7 @@ function createVisitor(config = {}) {
|
|
|
16534
16924
|
};
|
|
16535
16925
|
return {
|
|
16536
16926
|
expression: stringToNode({
|
|
16927
|
+
path: ctx.path,
|
|
16537
16928
|
plugin: ctx.plugin,
|
|
16538
16929
|
schema
|
|
16539
16930
|
}),
|
|
@@ -16544,10 +16935,10 @@ function createVisitor(config = {}) {
|
|
|
16544
16935
|
const applyModifiers = (result, opts) => this.applyModifiers(result, ctx, opts);
|
|
16545
16936
|
const { childResults, expression } = tupleToAst({
|
|
16546
16937
|
applyModifiers,
|
|
16938
|
+
path: ctx.path,
|
|
16547
16939
|
plugin: ctx.plugin,
|
|
16548
16940
|
schema,
|
|
16549
|
-
walk
|
|
16550
|
-
walkerCtx: ctx
|
|
16941
|
+
walk
|
|
16551
16942
|
});
|
|
16552
16943
|
return {
|
|
16553
16944
|
expression,
|
|
@@ -16557,6 +16948,7 @@ function createVisitor(config = {}) {
|
|
|
16557
16948
|
undefined(schema, ctx) {
|
|
16558
16949
|
return {
|
|
16559
16950
|
expression: undefinedToAst({
|
|
16951
|
+
path: ctx.path,
|
|
16560
16952
|
plugin: ctx.plugin,
|
|
16561
16953
|
schema
|
|
16562
16954
|
}),
|
|
@@ -16573,6 +16965,7 @@ function createVisitor(config = {}) {
|
|
|
16573
16965
|
const { expression } = unionToAst({
|
|
16574
16966
|
childResults: items,
|
|
16575
16967
|
parentSchema,
|
|
16968
|
+
path: ctx.path,
|
|
16576
16969
|
plugin: ctx.plugin,
|
|
16577
16970
|
schemas
|
|
16578
16971
|
});
|
|
@@ -16592,6 +16985,7 @@ function createVisitor(config = {}) {
|
|
|
16592
16985
|
unknown(schema, ctx) {
|
|
16593
16986
|
return {
|
|
16594
16987
|
expression: unknownToAst({
|
|
16988
|
+
path: ctx.path,
|
|
16595
16989
|
plugin: ctx.plugin,
|
|
16596
16990
|
schema
|
|
16597
16991
|
}),
|
|
@@ -16605,6 +16999,7 @@ function createVisitor(config = {}) {
|
|
|
16605
16999
|
void(schema, ctx) {
|
|
16606
17000
|
return {
|
|
16607
17001
|
expression: voidToAst({
|
|
17002
|
+
path: ctx.path,
|
|
16608
17003
|
plugin: ctx.plugin,
|
|
16609
17004
|
schema
|
|
16610
17005
|
}),
|
|
@@ -17318,7 +17713,7 @@ const defaultConfig = {
|
|
|
17318
17713
|
value: plugin.config.webhooks
|
|
17319
17714
|
});
|
|
17320
17715
|
},
|
|
17321
|
-
tags: ["validator"]
|
|
17716
|
+
tags: ["transformer", "validator"]
|
|
17322
17717
|
};
|
|
17323
17718
|
definePluginConfig(defaultConfig);
|
|
17324
17719
|
//#endregion
|
|
@@ -17529,4 +17924,4 @@ async function resolveJobs({ logger, userConfigs }) {
|
|
|
17529
17924
|
//#endregion
|
|
17530
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 };
|
|
17531
17926
|
|
|
17532
|
-
//# sourceMappingURL=init-
|
|
17927
|
+
//# sourceMappingURL=init-CitwzRmB.mjs.map
|