@hey-api/openapi-ts 0.96.0 → 0.96.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import { createRequire } from "node:module";
2
2
  import { StructureModel, detectInteractiveSession, fromRef, isNode, isRef, isSymbol, loadConfigFile, log, nodeBrand, ref, refs } from "@hey-api/codegen-core";
3
- import { ConfigError, OperationPath, OperationStrategy, applyNaming, buildSymbolIn, childContext, createOperationKey, createSchemaProcessor, createSchemaWalker, deduplicateSchema, definePluginConfig, dependencyFactory, ensureDirSync, escapeComment, findTsConfigPath, getInput, getLogs, getParser, hasOperationDataRequired, hasParameterGroupObjectRequired, isEnvironment, mappers, operationPagination, operationResponsesMap, outputHeaderToPrefix, parseUrl, pathToJsonPointer, pathToName, refToName, requestValidatorLayers, resolveSource, resolveValidatorLayer, satisfies, statusCodeToGroup, toCase, valueToObject } from "@hey-api/shared";
3
+ import { ConfigError, OperationPath, OperationStrategy, applyNaming, buildSymbolIn, childContext, createOperationKey, createSchemaProcessor, createSchemaWalker, deduplicateSchema, definePluginConfig, dependencyFactory, ensureDirSync, escapeComment, findTsConfigPath, getInput, getLogs, getParser, hasOperationDataRequired, hasParameterGroupObjectRequired, isEnvironment, mappers, operationPagination, operationResponsesMap, outputHeaderToPrefix, parseUrl, pathToJsonPointer, pathToName, refToName, requestValidatorLayers, resolveSource, resolveValidatorLayer, satisfies, statusCodeToGroup, toCase, valueToObject, warnOnConflictingDuplicatePlugins } from "@hey-api/shared";
4
4
  import colors from "ansi-colors";
5
5
  import path from "node:path";
6
6
  import { fileURLToPath } from "node:url";
@@ -5740,7 +5740,7 @@ const defaultConfig$18 = {
5740
5740
  definePluginConfig(defaultConfig$18);
5741
5741
  //#endregion
5742
5742
  //#region src/plugins/@hey-api/schemas/plugin.ts
5743
- const stripSchema = ({ plugin, schema }) => {
5743
+ function stripSchema({ plugin, schema }) {
5744
5744
  if (plugin.config.type === "form") {
5745
5745
  if (schema.description) delete schema.description;
5746
5746
  if (schema["x-enum-descriptions"]) delete schema["x-enum-descriptions"];
@@ -5748,18 +5748,15 @@ const stripSchema = ({ plugin, schema }) => {
5748
5748
  if (schema["x-enumNames"]) delete schema["x-enumNames"];
5749
5749
  if (schema.title) delete schema.title;
5750
5750
  }
5751
- };
5752
- const schemaToJsonSchemaDraft_04 = ({ context, plugin, schema: _schema }) => {
5751
+ }
5752
+ function schemaToJsonSchemaDraft_04({ context, plugin, schema: _schema }) {
5753
5753
  if (Array.isArray(_schema)) return _schema.map((item) => schemaToJsonSchemaDraft_04({
5754
5754
  context,
5755
5755
  plugin,
5756
5756
  schema: item
5757
5757
  }));
5758
5758
  const schema = structuredClone(_schema);
5759
- if (schema.$ref) {
5760
- schema.$ref = decodeURI(schema.$ref);
5761
- return schema;
5762
- }
5759
+ if (schema.$ref) return schema;
5763
5760
  stripSchema({
5764
5761
  plugin,
5765
5762
  schema
@@ -5788,18 +5785,15 @@ const schemaToJsonSchemaDraft_04 = ({ context, plugin, schema: _schema }) => {
5788
5785
  });
5789
5786
  }
5790
5787
  return schema;
5791
- };
5792
- const schemaToJsonSchemaDraft_05 = ({ context, plugin, schema: _schema }) => {
5788
+ }
5789
+ function schemaToJsonSchemaDraft_05({ context, plugin, schema: _schema }) {
5793
5790
  if (Array.isArray(_schema)) return _schema.map((item) => schemaToJsonSchemaDraft_05({
5794
5791
  context,
5795
5792
  plugin,
5796
5793
  schema: item
5797
5794
  }));
5798
5795
  const schema = structuredClone(_schema);
5799
- if ("$ref" in schema) {
5800
- schema.$ref = decodeURI(schema.$ref);
5801
- return schema;
5802
- }
5796
+ if ("$ref" in schema) return schema;
5803
5797
  stripSchema({
5804
5798
  plugin,
5805
5799
  schema
@@ -5838,8 +5832,8 @@ const schemaToJsonSchemaDraft_05 = ({ context, plugin, schema: _schema }) => {
5838
5832
  });
5839
5833
  }
5840
5834
  return schema;
5841
- };
5842
- const schemaToJsonSchema2020_12 = ({ context, plugin, schema: _schema }) => {
5835
+ }
5836
+ function schemaToJsonSchema2020_12({ context, plugin, schema: _schema }) {
5843
5837
  if (Array.isArray(_schema)) return _schema.map((item) => schemaToJsonSchema2020_12({
5844
5838
  context,
5845
5839
  plugin,
@@ -5850,7 +5844,6 @@ const schemaToJsonSchema2020_12 = ({ context, plugin, schema: _schema }) => {
5850
5844
  plugin,
5851
5845
  schema
5852
5846
  });
5853
- if (schema.$ref) schema.$ref = decodeURI(schema.$ref);
5854
5847
  if (schema.additionalProperties && typeof schema.additionalProperties !== "boolean") schema.additionalProperties = schemaToJsonSchema2020_12({
5855
5848
  context,
5856
5849
  plugin,
@@ -5890,15 +5883,15 @@ const schemaToJsonSchema2020_12 = ({ context, plugin, schema: _schema }) => {
5890
5883
  });
5891
5884
  }
5892
5885
  return schema;
5893
- };
5894
- const schemaName = ({ name, plugin, schema }) => {
5886
+ }
5887
+ function schemaName({ name, plugin, schema }) {
5895
5888
  let customName = "";
5896
5889
  if (plugin.config.nameBuilder) if (typeof plugin.config.nameBuilder === "function") customName = plugin.config.nameBuilder(name, schema);
5897
5890
  else customName = plugin.config.nameBuilder.replace("{{name}}", name);
5898
5891
  if (!customName) customName = `${name}Schema`;
5899
5892
  return customName;
5900
- };
5901
- const schemasV2_0_X = ({ context, plugin }) => {
5893
+ }
5894
+ function schemasV2_0_X({ context, plugin }) {
5902
5895
  if (!context.spec.definitions) return;
5903
5896
  for (const name in context.spec.definitions) {
5904
5897
  const schema = context.spec.definitions[name];
@@ -5920,8 +5913,8 @@ const schemasV2_0_X = ({ context, plugin }) => {
5920
5913
  const statement = $.const(symbol).export().assign($($.fromValue(obj, { layout: "pretty" })).as("const"));
5921
5914
  plugin.node(statement);
5922
5915
  }
5923
- };
5924
- const schemasV3_0_X = ({ context, plugin }) => {
5916
+ }
5917
+ function schemasV3_0_X({ context, plugin }) {
5925
5918
  if (!context.spec.components) return;
5926
5919
  for (const name in context.spec.components.schemas) {
5927
5920
  const schema = context.spec.components.schemas[name];
@@ -5943,8 +5936,8 @@ const schemasV3_0_X = ({ context, plugin }) => {
5943
5936
  const statement = $.const(symbol).export().assign($($.fromValue(obj, { layout: "pretty" })).as("const"));
5944
5937
  plugin.node(statement);
5945
5938
  }
5946
- };
5947
- const schemasV3_1_X = ({ context, plugin }) => {
5939
+ }
5940
+ function schemasV3_1_X({ context, plugin }) {
5948
5941
  if (!context.spec.components) return;
5949
5942
  for (const name in context.spec.components.schemas) {
5950
5943
  const schema = context.spec.components.schemas[name];
@@ -5966,7 +5959,7 @@ const schemasV3_1_X = ({ context, plugin }) => {
5966
5959
  const statement = $.const(symbol).export().assign($($.fromValue(obj, { layout: "pretty" })).as("const"));
5967
5960
  plugin.node(statement);
5968
5961
  }
5969
- };
5962
+ }
5970
5963
  const handler$12 = ({ plugin }) => {
5971
5964
  if ("swagger" in plugin.context.spec) {
5972
5965
  schemasV2_0_X({
@@ -6739,7 +6732,7 @@ function inheritMeta$2(parent, children) {
6739
6732
  }
6740
6733
  //#endregion
6741
6734
  //#region src/plugins/@hey-api/typescript/v1/toAst/array.ts
6742
- function baseNode$63(ctx) {
6735
+ function baseNode$69(ctx) {
6743
6736
  const { plugin, schema, walk } = ctx;
6744
6737
  if (!schema.items) return $.type("Array").generic($.type(plugin.config.topType));
6745
6738
  const dedupedSchema = deduplicateSchema({
@@ -6760,7 +6753,7 @@ function arrayResolver$4(ctx) {
6760
6753
  function arrayToAst$3({ plugin, schema, walk, walkerCtx }) {
6761
6754
  const ctx = {
6762
6755
  $,
6763
- nodes: { base: baseNode$63 },
6756
+ nodes: { base: baseNode$69 },
6764
6757
  plugin,
6765
6758
  schema,
6766
6759
  walk,
@@ -6771,7 +6764,7 @@ function arrayToAst$3({ plugin, schema, walk, walkerCtx }) {
6771
6764
  }
6772
6765
  //#endregion
6773
6766
  //#region src/plugins/@hey-api/typescript/v1/toAst/boolean.ts
6774
- function baseNode$62() {
6767
+ function baseNode$68() {
6775
6768
  return $.type("boolean");
6776
6769
  }
6777
6770
  function constNode$19(ctx) {
@@ -6787,7 +6780,7 @@ function booleanToAst$3({ plugin, schema }) {
6787
6780
  const ctx = {
6788
6781
  $,
6789
6782
  nodes: {
6790
- base: baseNode$62,
6783
+ base: baseNode$68,
6791
6784
  const: constNode$19
6792
6785
  },
6793
6786
  plugin,
@@ -6832,7 +6825,7 @@ function itemsNode$4(ctx) {
6832
6825
  isNullable
6833
6826
  };
6834
6827
  }
6835
- function baseNode$61(ctx) {
6828
+ function baseNode$67(ctx) {
6836
6829
  const { schema } = ctx;
6837
6830
  const items = schema.items ?? [];
6838
6831
  if (!items.length) return $.type("never");
@@ -6847,7 +6840,7 @@ function enumToAst$3({ plugin, schema }) {
6847
6840
  const ctx = {
6848
6841
  $,
6849
6842
  nodes: {
6850
- base: baseNode$61,
6843
+ base: baseNode$67,
6851
6844
  items: itemsNode$4
6852
6845
  },
6853
6846
  plugin,
@@ -6861,29 +6854,29 @@ function enumToAst$3({ plugin, schema }) {
6861
6854
  }
6862
6855
  //#endregion
6863
6856
  //#region src/plugins/@hey-api/typescript/v1/toAst/intersection.ts
6864
- function baseNode$60(ctx) {
6857
+ function baseNode$66(ctx) {
6865
6858
  const { childResults } = ctx;
6866
6859
  if (childResults.length === 1) return childResults[0].type;
6867
6860
  return $.type.and(...childResults.map((r) => r.type));
6868
6861
  }
6869
- function intersectionResolver$1(ctx) {
6862
+ function intersectionResolver$4(ctx) {
6870
6863
  return ctx.nodes.base(ctx);
6871
6864
  }
6872
- function intersectionToAst({ childResults, parentSchema, plugin, schemas }) {
6865
+ function intersectionToAst$3({ childResults, parentSchema, plugin, schemas }) {
6873
6866
  const ctx = {
6874
6867
  $,
6875
6868
  childResults,
6876
- nodes: { base: baseNode$60 },
6869
+ nodes: { base: baseNode$66 },
6877
6870
  parentSchema,
6878
6871
  plugin,
6879
6872
  schemas
6880
6873
  };
6881
6874
  const resolver = plugin.config["~resolvers"]?.intersection;
6882
- return resolver?.(ctx) ?? intersectionResolver$1(ctx);
6875
+ return resolver?.(ctx) ?? intersectionResolver$4(ctx);
6883
6876
  }
6884
6877
  //#endregion
6885
6878
  //#region src/plugins/@hey-api/typescript/v1/toAst/never.ts
6886
- function baseNode$59() {
6879
+ function baseNode$65() {
6887
6880
  return $.type("never");
6888
6881
  }
6889
6882
  function neverResolver$4(ctx) {
@@ -6892,7 +6885,7 @@ function neverResolver$4(ctx) {
6892
6885
  function neverToAst$3({ plugin, schema }) {
6893
6886
  const ctx = {
6894
6887
  $,
6895
- nodes: { base: baseNode$59 },
6888
+ nodes: { base: baseNode$65 },
6896
6889
  plugin,
6897
6890
  schema
6898
6891
  };
@@ -6901,7 +6894,7 @@ function neverToAst$3({ plugin, schema }) {
6901
6894
  }
6902
6895
  //#endregion
6903
6896
  //#region src/plugins/@hey-api/typescript/v1/toAst/null.ts
6904
- function baseNode$58() {
6897
+ function baseNode$64() {
6905
6898
  return $.type.literal(null);
6906
6899
  }
6907
6900
  function nullResolver$4(ctx) {
@@ -6910,7 +6903,7 @@ function nullResolver$4(ctx) {
6910
6903
  function nullToAst$4({ plugin, schema }) {
6911
6904
  const ctx = {
6912
6905
  $,
6913
- nodes: { base: baseNode$58 },
6906
+ nodes: { base: baseNode$64 },
6914
6907
  plugin,
6915
6908
  schema
6916
6909
  };
@@ -6923,7 +6916,7 @@ function constNode$18(ctx) {
6923
6916
  const { schema } = ctx;
6924
6917
  if (schema.const !== void 0) return $.type.fromValue(schema.const);
6925
6918
  }
6926
- function baseNode$57(ctx) {
6919
+ function baseNode$63(ctx) {
6927
6920
  const { plugin, schema } = ctx;
6928
6921
  if (schema.type === "integer" && schema.format === "int64") {
6929
6922
  if (plugin.getPlugin("@hey-api/transformers")?.config.bigInt) return $.type("bigint");
@@ -6939,7 +6932,7 @@ function numberToAst({ plugin, schema }) {
6939
6932
  const ctx = {
6940
6933
  $,
6941
6934
  nodes: {
6942
- base: baseNode$57,
6935
+ base: baseNode$63,
6943
6936
  const: constNode$18
6944
6937
  },
6945
6938
  plugin,
@@ -6965,7 +6958,7 @@ function shapeNode$4(ctx) {
6965
6958
  }
6966
6959
  return shape;
6967
6960
  }
6968
- function baseNode$56(ctx) {
6961
+ function baseNode$62(ctx) {
6969
6962
  const { schema, walk, walkerCtx } = ctx;
6970
6963
  const shape = shapeNode$4(ctx);
6971
6964
  const required = schema.required ?? [];
@@ -7017,7 +7010,7 @@ function objectToAst$4({ plugin, schema, walk, walkerCtx }) {
7017
7010
  const ctx = {
7018
7011
  $,
7019
7012
  nodes: {
7020
- base: baseNode$56,
7013
+ base: baseNode$62,
7021
7014
  shape: shapeNode$4
7022
7015
  },
7023
7016
  plugin,
@@ -7072,7 +7065,7 @@ function formatNode$4(ctx) {
7072
7065
  return $.type(plugin.referenceSymbol(typeidQuery));
7073
7066
  }
7074
7067
  }
7075
- function baseNode$55(ctx) {
7068
+ function baseNode$61(ctx) {
7076
7069
  return $.type("string");
7077
7070
  }
7078
7071
  function stringResolver$4(ctx) {
@@ -7088,7 +7081,7 @@ function stringToAst$1({ plugin, schema }) {
7088
7081
  const ctx = {
7089
7082
  $,
7090
7083
  nodes: {
7091
- base: baseNode$55,
7084
+ base: baseNode$61,
7092
7085
  const: constNode$17,
7093
7086
  format: formatNode$4
7094
7087
  },
@@ -7100,7 +7093,7 @@ function stringToAst$1({ plugin, schema }) {
7100
7093
  }
7101
7094
  //#endregion
7102
7095
  //#region src/plugins/@hey-api/typescript/v1/toAst/tuple.ts
7103
- function baseNode$54(ctx) {
7096
+ function baseNode$60(ctx) {
7104
7097
  const { plugin, schema, walk } = ctx;
7105
7098
  const itemTypes = [];
7106
7099
  if (schema.items) schema.items.forEach((item) => {
@@ -7127,7 +7120,7 @@ function tupleToAst$3({ plugin, schema, walk, walkerCtx }) {
7127
7120
  const ctx = {
7128
7121
  $,
7129
7122
  nodes: {
7130
- base: baseNode$54,
7123
+ base: baseNode$60,
7131
7124
  const: constNode$16
7132
7125
  },
7133
7126
  plugin,
@@ -7140,7 +7133,7 @@ function tupleToAst$3({ plugin, schema, walk, walkerCtx }) {
7140
7133
  }
7141
7134
  //#endregion
7142
7135
  //#region src/plugins/@hey-api/typescript/v1/toAst/undefined.ts
7143
- function baseNode$53() {
7136
+ function baseNode$59() {
7144
7137
  return $.type("undefined");
7145
7138
  }
7146
7139
  function undefinedResolver$4(ctx) {
@@ -7149,7 +7142,7 @@ function undefinedResolver$4(ctx) {
7149
7142
  function undefinedToAst$3({ plugin, schema }) {
7150
7143
  const ctx = {
7151
7144
  $,
7152
- nodes: { base: baseNode$53 },
7145
+ nodes: { base: baseNode$59 },
7153
7146
  plugin,
7154
7147
  schema
7155
7148
  };
@@ -7158,29 +7151,29 @@ function undefinedToAst$3({ plugin, schema }) {
7158
7151
  }
7159
7152
  //#endregion
7160
7153
  //#region src/plugins/@hey-api/typescript/v1/toAst/union.ts
7161
- function baseNode$52(ctx) {
7154
+ function baseNode$58(ctx) {
7162
7155
  const { childResults } = ctx;
7163
7156
  if (childResults.length === 1) return childResults[0].type;
7164
7157
  return $.type.or(...childResults.map((r) => r.type));
7165
7158
  }
7166
- function unionResolver$1(ctx) {
7159
+ function unionResolver$4(ctx) {
7167
7160
  return ctx.nodes.base(ctx);
7168
7161
  }
7169
- function unionToAst({ childResults, parentSchema, plugin, schemas }) {
7162
+ function unionToAst$3({ childResults, parentSchema, plugin, schemas }) {
7170
7163
  const ctx = {
7171
7164
  $,
7172
7165
  childResults,
7173
- nodes: { base: baseNode$52 },
7166
+ nodes: { base: baseNode$58 },
7174
7167
  parentSchema,
7175
7168
  plugin,
7176
7169
  schemas
7177
7170
  };
7178
7171
  const resolver = plugin.config["~resolvers"]?.union;
7179
- return resolver?.(ctx) ?? unionResolver$1(ctx);
7172
+ return resolver?.(ctx) ?? unionResolver$4(ctx);
7180
7173
  }
7181
7174
  //#endregion
7182
7175
  //#region src/plugins/@hey-api/typescript/v1/toAst/unknown.ts
7183
- function baseNode$51(ctx) {
7176
+ function baseNode$57(ctx) {
7184
7177
  return $.type(ctx.plugin.config.topType);
7185
7178
  }
7186
7179
  function unknownResolver$4(ctx) {
@@ -7189,7 +7182,7 @@ function unknownResolver$4(ctx) {
7189
7182
  function unknownToAst$3({ plugin, schema }) {
7190
7183
  const ctx = {
7191
7184
  $,
7192
- nodes: { base: baseNode$51 },
7185
+ nodes: { base: baseNode$57 },
7193
7186
  plugin,
7194
7187
  schema
7195
7188
  };
@@ -7198,7 +7191,7 @@ function unknownToAst$3({ plugin, schema }) {
7198
7191
  }
7199
7192
  //#endregion
7200
7193
  //#region src/plugins/@hey-api/typescript/v1/toAst/void.ts
7201
- function baseNode$50() {
7194
+ function baseNode$56() {
7202
7195
  return $.type("void");
7203
7196
  }
7204
7197
  function voidResolver$4(ctx) {
@@ -7207,7 +7200,7 @@ function voidResolver$4(ctx) {
7207
7200
  function voidToAst$3({ plugin, schema }) {
7208
7201
  const ctx = {
7209
7202
  $,
7210
- nodes: { base: baseNode$50 },
7203
+ nodes: { base: baseNode$56 },
7211
7204
  plugin,
7212
7205
  schema
7213
7206
  };
@@ -7296,7 +7289,7 @@ function createVisitor$4(config = {}) {
7296
7289
  }
7297
7290
  },
7298
7291
  intersection(items, schemas, parentSchema, ctx) {
7299
- const type = intersectionToAst({
7292
+ const type = intersectionToAst$3({
7300
7293
  childResults: items,
7301
7294
  parentSchema,
7302
7295
  plugin: ctx.plugin,
@@ -7403,7 +7396,7 @@ function createVisitor$4(config = {}) {
7403
7396
  };
7404
7397
  },
7405
7398
  union(items, schemas, parentSchema, ctx) {
7406
- const type = unionToAst({
7399
+ const type = unionToAst$3({
7407
7400
  childResults: items,
7408
7401
  parentSchema,
7409
7402
  plugin: ctx.plugin,
@@ -10994,7 +10987,7 @@ function inheritMeta$1(parent, children) {
10994
10987
  }
10995
10988
  //#endregion
10996
10989
  //#region src/plugins/valibot/v1/toAst/unknown.ts
10997
- function baseNode$49(ctx) {
10990
+ function baseNode$55(ctx) {
10998
10991
  const { symbols } = ctx;
10999
10992
  const { v } = symbols;
11000
10993
  return $(v).attr(identifiers$1.schemas.unknown).call();
@@ -11007,7 +11000,7 @@ function unknownResolver$3(ctx) {
11007
11000
  function unknownToPipes({ plugin, schema }) {
11008
11001
  const ctx = {
11009
11002
  $,
11010
- nodes: { base: baseNode$49 },
11003
+ nodes: { base: baseNode$55 },
11011
11004
  pipes: {
11012
11005
  ...pipes,
11013
11006
  current: []
@@ -11022,7 +11015,7 @@ function unknownToPipes({ plugin, schema }) {
11022
11015
  }
11023
11016
  //#endregion
11024
11017
  //#region src/plugins/valibot/v1/toAst/array.ts
11025
- function baseNode$48(ctx) {
11018
+ function baseNode$54(ctx) {
11026
11019
  const { plugin, symbols } = ctx;
11027
11020
  const { v } = symbols;
11028
11021
  const arrayFn = $(v).attr(identifiers$1.schemas.array);
@@ -11087,7 +11080,7 @@ function arrayToPipes(ctx) {
11087
11080
  $,
11088
11081
  applyModifiers: ctx.applyModifiers,
11089
11082
  nodes: {
11090
- base: baseNode$48,
11083
+ base: baseNode$54,
11091
11084
  length: lengthNode$7,
11092
11085
  maxLength: maxLengthNode$7,
11093
11086
  minLength: minLengthNode$7
@@ -11111,7 +11104,7 @@ function arrayToPipes(ctx) {
11111
11104
  }
11112
11105
  //#endregion
11113
11106
  //#region src/plugins/valibot/v1/toAst/boolean.ts
11114
- function baseNode$47(ctx) {
11107
+ function baseNode$53(ctx) {
11115
11108
  const { symbols } = ctx;
11116
11109
  const { v } = symbols;
11117
11110
  return $(v).attr(identifiers$1.schemas.boolean).call();
@@ -11133,7 +11126,7 @@ function booleanToPipes({ plugin, schema }) {
11133
11126
  const ctx = {
11134
11127
  $,
11135
11128
  nodes: {
11136
- base: baseNode$47,
11129
+ base: baseNode$53,
11137
11130
  const: constNode$15
11138
11131
  },
11139
11132
  pipes: {
@@ -11161,7 +11154,7 @@ function itemsNode$3(ctx) {
11161
11154
  isNullable
11162
11155
  };
11163
11156
  }
11164
- function baseNode$46(ctx) {
11157
+ function baseNode$52(ctx) {
11165
11158
  const { symbols } = ctx;
11166
11159
  const { v } = symbols;
11167
11160
  const { enumMembers } = ctx.nodes.items(ctx);
@@ -11179,7 +11172,7 @@ function enumToPipes({ plugin, schema }) {
11179
11172
  const { enumMembers, isNullable } = itemsNode$3({
11180
11173
  $,
11181
11174
  nodes: {
11182
- base: baseNode$46,
11175
+ base: baseNode$52,
11183
11176
  items: itemsNode$3
11184
11177
  },
11185
11178
  pipes: {
@@ -11197,7 +11190,7 @@ function enumToPipes({ plugin, schema }) {
11197
11190
  const ctx = {
11198
11191
  $,
11199
11192
  nodes: {
11200
- base: baseNode$46,
11193
+ base: baseNode$52,
11201
11194
  items: itemsNode$3
11202
11195
  },
11203
11196
  pipes: {
@@ -11217,7 +11210,7 @@ function enumToPipes({ plugin, schema }) {
11217
11210
  }
11218
11211
  //#endregion
11219
11212
  //#region src/plugins/valibot/v1/toAst/intersection.ts
11220
- function baseNode$45(ctx) {
11213
+ function baseNode$51(ctx) {
11221
11214
  const { applyModifiers, childResults, plugin, symbols } = ctx;
11222
11215
  const { v } = symbols;
11223
11216
  if (!childResults.length) return $(v).attr(identifiers$1.schemas.any).call();
@@ -11225,7 +11218,7 @@ function baseNode$45(ctx) {
11225
11218
  const itemNodes = childResults.map((item) => pipesToNode(item.pipes, plugin));
11226
11219
  return $(v).attr(identifiers$1.schemas.intersect).call($.array(...itemNodes));
11227
11220
  }
11228
- function intersectionResolver(ctx) {
11221
+ function intersectionResolver$3(ctx) {
11229
11222
  const base = ctx.nodes.base(ctx);
11230
11223
  if (base) ctx.pipes.push(ctx.pipes.current, base);
11231
11224
  return ctx.pipes.current;
@@ -11236,7 +11229,7 @@ function intersectionToPipes(ctx) {
11236
11229
  $,
11237
11230
  applyModifiers,
11238
11231
  childResults,
11239
- nodes: { base: baseNode$45 },
11232
+ nodes: { base: baseNode$51 },
11240
11233
  parentSchema,
11241
11234
  pipes: {
11242
11235
  ...pipes,
@@ -11247,7 +11240,7 @@ function intersectionToPipes(ctx) {
11247
11240
  symbols: { v: plugin.external("valibot.v") }
11248
11241
  };
11249
11242
  const resolver = plugin.config["~resolvers"]?.intersection;
11250
- const node = resolver?.(resolverCtx) ?? intersectionResolver(resolverCtx);
11243
+ const node = resolver?.(resolverCtx) ?? intersectionResolver$3(resolverCtx);
11251
11244
  return {
11252
11245
  childResults,
11253
11246
  pipes: [resolverCtx.pipes.toNode(node, plugin)]
@@ -11255,7 +11248,7 @@ function intersectionToPipes(ctx) {
11255
11248
  }
11256
11249
  //#endregion
11257
11250
  //#region src/plugins/valibot/v1/toAst/never.ts
11258
- function baseNode$44(ctx) {
11251
+ function baseNode$50(ctx) {
11259
11252
  const { symbols } = ctx;
11260
11253
  const { v } = symbols;
11261
11254
  return $(v).attr(identifiers$1.schemas.never).call();
@@ -11268,7 +11261,7 @@ function neverResolver$3(ctx) {
11268
11261
  function neverToPipes({ plugin, schema }) {
11269
11262
  const ctx = {
11270
11263
  $,
11271
- nodes: { base: baseNode$44 },
11264
+ nodes: { base: baseNode$50 },
11272
11265
  pipes: {
11273
11266
  ...pipes,
11274
11267
  current: []
@@ -11283,7 +11276,7 @@ function neverToPipes({ plugin, schema }) {
11283
11276
  }
11284
11277
  //#endregion
11285
11278
  //#region src/plugins/valibot/v1/toAst/null.ts
11286
- function baseNode$43(ctx) {
11279
+ function baseNode$49(ctx) {
11287
11280
  const { symbols } = ctx;
11288
11281
  const { v } = symbols;
11289
11282
  return $(v).attr(identifiers$1.schemas.null).call();
@@ -11296,7 +11289,7 @@ function nullResolver$3(ctx) {
11296
11289
  function nullToPipes({ plugin, schema }) {
11297
11290
  const ctx = {
11298
11291
  $,
11299
- nodes: { base: baseNode$43 },
11292
+ nodes: { base: baseNode$49 },
11300
11293
  pipes: {
11301
11294
  ...pipes,
11302
11295
  current: []
@@ -11338,7 +11331,7 @@ const getIntegerLimit = (format) => {
11338
11331
  };
11339
11332
  //#endregion
11340
11333
  //#region src/plugins/valibot/v1/toAst/number.ts
11341
- function baseNode$42(ctx) {
11334
+ function baseNode$48(ctx) {
11342
11335
  const { schema, symbols } = ctx;
11343
11336
  const { v } = symbols;
11344
11337
  if (ctx.utils.shouldCoerceToBigInt(schema.format)) return [$(v).attr(identifiers$1.schemas.union).call($.array($(v).attr(identifiers$1.schemas.number).call(), $(v).attr(identifiers$1.schemas.string).call(), $(v).attr(identifiers$1.schemas.bigInt).call())), $(v).attr(identifiers$1.actions.transform).call($.func().param("x").do($("BigInt").call("x").return()))];
@@ -11384,7 +11377,7 @@ function numberToPipes({ plugin, schema }) {
11384
11377
  const ctx = {
11385
11378
  $,
11386
11379
  nodes: {
11387
- base: baseNode$42,
11380
+ base: baseNode$48,
11388
11381
  const: constNode$14,
11389
11382
  max: maxNode$3,
11390
11383
  min: minNode$3
@@ -11416,7 +11409,7 @@ function additionalPropertiesNode$3(ctx) {
11416
11409
  ctx._childResults.push(additionalResult);
11417
11410
  return pipes.toNode(additionalResult.pipes, ctx.plugin);
11418
11411
  }
11419
- function baseNode$41(ctx) {
11412
+ function baseNode$47(ctx) {
11420
11413
  const { v } = ctx.symbols;
11421
11414
  const additional = ctx.nodes.additionalProperties(ctx);
11422
11415
  const shape = ctx.nodes.shape(ctx);
@@ -11452,7 +11445,7 @@ function objectToPipes(ctx) {
11452
11445
  applyModifiers,
11453
11446
  nodes: {
11454
11447
  additionalProperties: additionalPropertiesNode$3,
11455
- base: baseNode$41,
11448
+ base: baseNode$47,
11456
11449
  shape: shapeNode$3
11457
11450
  },
11458
11451
  pipes: {
@@ -11474,7 +11467,7 @@ function objectToPipes(ctx) {
11474
11467
  }
11475
11468
  //#endregion
11476
11469
  //#region src/plugins/valibot/v1/toAst/string.ts
11477
- function baseNode$40(ctx) {
11470
+ function baseNode$46(ctx) {
11478
11471
  const { v } = ctx.symbols;
11479
11472
  return $(v).attr(identifiers$1.schemas.string).call();
11480
11473
  }
@@ -11553,7 +11546,7 @@ function stringToPipes({ plugin, schema }) {
11553
11546
  const ctx = {
11554
11547
  $,
11555
11548
  nodes: {
11556
- base: baseNode$40,
11549
+ base: baseNode$46,
11557
11550
  const: constNode$13,
11558
11551
  format: formatNode$3,
11559
11552
  length: lengthNode$6,
@@ -11575,7 +11568,7 @@ function stringToPipes({ plugin, schema }) {
11575
11568
  }
11576
11569
  //#endregion
11577
11570
  //#region src/plugins/valibot/v1/toAst/tuple.ts
11578
- function baseNode$39(ctx) {
11571
+ function baseNode$45(ctx) {
11579
11572
  const { applyModifiers, pipes, plugin, schema, symbols, walk, walkerCtx } = ctx;
11580
11573
  if (!schema.items) return unknownToPipes({ plugin });
11581
11574
  const { v } = symbols;
@@ -11614,7 +11607,7 @@ function tupleToPipes(ctx) {
11614
11607
  $,
11615
11608
  applyModifiers: ctx.applyModifiers,
11616
11609
  nodes: {
11617
- base: baseNode$39,
11610
+ base: baseNode$45,
11618
11611
  const: constNode$12
11619
11612
  },
11620
11613
  pipes: {
@@ -11636,7 +11629,7 @@ function tupleToPipes(ctx) {
11636
11629
  }
11637
11630
  //#endregion
11638
11631
  //#region src/plugins/valibot/v1/toAst/undefined.ts
11639
- function baseNode$38(ctx) {
11632
+ function baseNode$44(ctx) {
11640
11633
  const { symbols } = ctx;
11641
11634
  const { v } = symbols;
11642
11635
  return $(v).attr(identifiers$1.schemas.undefined).call();
@@ -11649,7 +11642,7 @@ function undefinedResolver$3(ctx) {
11649
11642
  function undefinedToPipes({ plugin, schema }) {
11650
11643
  const ctx = {
11651
11644
  $,
11652
- nodes: { base: baseNode$38 },
11645
+ nodes: { base: baseNode$44 },
11653
11646
  pipes: {
11654
11647
  ...pipes,
11655
11648
  current: []
@@ -11663,9 +11656,24 @@ function undefinedToPipes({ plugin, schema }) {
11663
11656
  return ctx.pipes.toNode(node, plugin);
11664
11657
  }
11665
11658
  //#endregion
11659
+ //#region src/plugins/valibot/shared/discriminated-union.ts
11660
+ function hasIntersectionDiscriminatorBranches({ items, parentSchema, schemas }) {
11661
+ const discriminatorKey = parentSchema.discriminator?.propertyName;
11662
+ if (!discriminatorKey) return false;
11663
+ for (let index = 0; index < schemas.length; index++) {
11664
+ const schema = schemas[index];
11665
+ if (schema.type === "null" || schema.const === null) continue;
11666
+ if (schema.logicalOperator !== "and" || !schema.items || schema.items.length !== 2) continue;
11667
+ const item = items[index];
11668
+ const discriminatedValue = schema.items[0].properties?.[discriminatorKey]?.const;
11669
+ if (item.meta.hasLazy || discriminatedValue !== void 0) return true;
11670
+ }
11671
+ return false;
11672
+ }
11673
+ //#endregion
11666
11674
  //#region src/plugins/valibot/v1/toAst/union.ts
11667
- function baseNode$37(ctx) {
11668
- const { childResults, plugin, schemas, symbols } = ctx;
11675
+ function baseNode$43(ctx) {
11676
+ const { childResults, parentSchema, plugin, schemas, symbols } = ctx;
11669
11677
  const { v } = symbols;
11670
11678
  const nonNullItems = [];
11671
11679
  childResults.forEach((item, index) => {
@@ -11675,9 +11683,16 @@ function baseNode$37(ctx) {
11675
11683
  if (!nonNullItems.length) return $(v).attr(identifiers$1.schemas.null).call();
11676
11684
  if (nonNullItems.length === 1) return nonNullItems[0].pipes;
11677
11685
  const itemNodes = nonNullItems.map((i) => pipesToNode(i.pipes, plugin));
11686
+ const hasIntersectionBranch = hasIntersectionDiscriminatorBranches({
11687
+ items: childResults,
11688
+ parentSchema,
11689
+ schemas
11690
+ });
11691
+ const discriminatorKey = parentSchema.discriminator?.propertyName;
11692
+ if (discriminatorKey && !hasIntersectionBranch) return $(v).attr(identifiers$1.schemas.variant).call($.literal(discriminatorKey), $.array(...itemNodes));
11678
11693
  return $(v).attr(identifiers$1.schemas.union).call($.array(...itemNodes));
11679
11694
  }
11680
- function unionResolver(ctx) {
11695
+ function unionResolver$3(ctx) {
11681
11696
  const base = ctx.nodes.base(ctx);
11682
11697
  if (base) ctx.pipes.push(ctx.pipes.current, base);
11683
11698
  return ctx.pipes.current;
@@ -11688,7 +11703,7 @@ function unionToPipes(ctx) {
11688
11703
  $,
11689
11704
  applyModifiers,
11690
11705
  childResults,
11691
- nodes: { base: baseNode$37 },
11706
+ nodes: { base: baseNode$43 },
11692
11707
  parentSchema,
11693
11708
  pipes: {
11694
11709
  ...pipes,
@@ -11700,7 +11715,7 @@ function unionToPipes(ctx) {
11700
11715
  symbols: { v: plugin.external("valibot.v") }
11701
11716
  };
11702
11717
  const resolver = plugin.config["~resolvers"]?.union;
11703
- const node = resolver?.(resolverCtx) ?? unionResolver(resolverCtx);
11718
+ const node = resolver?.(resolverCtx) ?? unionResolver$3(resolverCtx);
11704
11719
  return {
11705
11720
  childResults,
11706
11721
  pipes: [resolverCtx.pipes.toNode(node, plugin)]
@@ -11708,7 +11723,7 @@ function unionToPipes(ctx) {
11708
11723
  }
11709
11724
  //#endregion
11710
11725
  //#region src/plugins/valibot/v1/toAst/void.ts
11711
- function baseNode$36(ctx) {
11726
+ function baseNode$42(ctx) {
11712
11727
  const { symbols } = ctx;
11713
11728
  const { v } = symbols;
11714
11729
  return $(v).attr(identifiers$1.schemas.void).call();
@@ -11721,7 +11736,7 @@ function voidResolver$3(ctx) {
11721
11736
  function voidToPipes({ plugin, schema }) {
11722
11737
  const ctx = {
11723
11738
  $,
11724
- nodes: { base: baseNode$36 },
11739
+ nodes: { base: baseNode$42 },
11725
11740
  pipes: {
11726
11741
  ...pipes,
11727
11742
  current: []
@@ -11736,7 +11751,7 @@ function voidToPipes({ plugin, schema }) {
11736
11751
  }
11737
11752
  //#endregion
11738
11753
  //#region src/plugins/valibot/v1/walker.ts
11739
- function getDefaultValue(meta) {
11754
+ function getDefaultValue$3(meta) {
11740
11755
  return meta.format ? maybeBigInt(meta.default, meta.format) : $.fromValue(meta.default);
11741
11756
  }
11742
11757
  function createVisitor$3(config = {}) {
@@ -11747,14 +11762,14 @@ function createVisitor$3(config = {}) {
11747
11762
  const v = ctx.plugin.external("valibot.v");
11748
11763
  const pipes = [...result.pipes];
11749
11764
  if (result.meta.readonly) pipes.push($(v).attr(identifiers$1.actions.readonly).call());
11750
- const hasDefault = result.meta.default !== void 0;
11751
- const needsOptional = optional || hasDefault;
11765
+ const needsDefault = result.meta.default !== void 0;
11766
+ const needsOptional = optional || needsDefault;
11752
11767
  const needsNullable = result.meta.nullable;
11753
11768
  const innerNode = pipesToNode(pipes, ctx.plugin);
11754
11769
  let finalPipes;
11755
- if (needsOptional && needsNullable) if (hasDefault) finalPipes = [$(v).attr(identifiers$1.schemas.nullish).call(innerNode, getDefaultValue(result.meta))];
11770
+ if (needsOptional && needsNullable) if (needsDefault) finalPipes = [$(v).attr(identifiers$1.schemas.nullish).call(innerNode, getDefaultValue$3(result.meta))];
11756
11771
  else finalPipes = [$(v).attr(identifiers$1.schemas.nullish).call(innerNode)];
11757
- else if (needsOptional) if (hasDefault) finalPipes = [$(v).attr(identifiers$1.schemas.optional).call(innerNode, getDefaultValue(result.meta))];
11772
+ else if (needsOptional) if (needsDefault) finalPipes = [$(v).attr(identifiers$1.schemas.optional).call(innerNode, getDefaultValue$3(result.meta))];
11758
11773
  else finalPipes = [$(v).attr(identifiers$1.schemas.optional).call(innerNode)];
11759
11774
  else if (needsNullable) finalPipes = [$(v).attr(identifiers$1.schemas.nullable).call(innerNode)];
11760
11775
  else finalPipes = pipes;
@@ -12252,13 +12267,16 @@ const identifiers = {
12252
12267
  datetime: "datetime",
12253
12268
  default: "default",
12254
12269
  describe: "describe",
12270
+ discriminatedUnion: "discriminatedUnion",
12255
12271
  email: "email",
12256
12272
  enum: "enum",
12273
+ extend: "extend",
12257
12274
  globalRegistry: "globalRegistry",
12258
12275
  gt: "gt",
12259
12276
  gte: "gte",
12260
12277
  guid: "guid",
12261
12278
  infer: "infer",
12279
+ input: "input",
12262
12280
  int: "int",
12263
12281
  intersection: "intersection",
12264
12282
  ip: "ip",
@@ -12283,6 +12301,7 @@ const identifiers = {
12283
12301
  number: "number",
12284
12302
  object: "object",
12285
12303
  optional: "optional",
12304
+ output: "output",
12286
12305
  parseAsync: "parseAsync",
12287
12306
  readonly: "readonly",
12288
12307
  record: "record",
@@ -12316,6 +12335,8 @@ function exportAst({ final, meta, naming, namingAnchor, path, plugin, schema, ta
12316
12335
  plugin,
12317
12336
  schema
12318
12337
  }));
12338
+ const statement = $.const(symbol).export().$if(plugin.config.comments && createSchemaComment(schema), (c, v) => c.doc(v)).$if(final.typeName, (c) => c.type($.type(z).attr(final.typeName))).assign(final.expression);
12339
+ plugin.node(statement);
12319
12340
  const typeInferSymbol = naming.types.infer.enabled ? plugin.registerSymbol(buildSymbolIn({
12320
12341
  meta: {
12321
12342
  category: "type",
@@ -12330,12 +12351,46 @@ function exportAst({ final, meta, naming, namingAnchor, path, plugin, schema, ta
12330
12351
  plugin,
12331
12352
  schema
12332
12353
  })) : void 0;
12333
- const statement = $.const(symbol).export().$if(plugin.config.comments && createSchemaComment(schema), (c, v) => c.doc(v)).$if(final.typeName, (c) => c.type($.type(z).attr(final.typeName))).assign(final.expression);
12334
- plugin.node(statement);
12335
12354
  if (typeInferSymbol) {
12336
12355
  const inferType = $.type.alias(typeInferSymbol).export().type($.type(z).attr(identifiers.infer).generic($(symbol).typeofType()));
12337
12356
  plugin.node(inferType);
12338
12357
  }
12358
+ const typeInputSymbol = naming.types.input.enabled ? plugin.registerSymbol(buildSymbolIn({
12359
+ meta: {
12360
+ category: "type",
12361
+ path,
12362
+ tags,
12363
+ tool: "zod",
12364
+ variant: "input",
12365
+ ...meta
12366
+ },
12367
+ name,
12368
+ naming: naming.types.input,
12369
+ plugin,
12370
+ schema
12371
+ })) : void 0;
12372
+ if (typeInputSymbol) {
12373
+ const inputType = $.type.alias(typeInputSymbol).export().type($.type(z).attr(identifiers.input).generic($(symbol).typeofType()));
12374
+ plugin.node(inputType);
12375
+ }
12376
+ const typeOutputSymbol = naming.types.output.enabled ? plugin.registerSymbol(buildSymbolIn({
12377
+ meta: {
12378
+ category: "type",
12379
+ path,
12380
+ tags,
12381
+ tool: "zod",
12382
+ variant: "output",
12383
+ ...meta
12384
+ },
12385
+ name,
12386
+ naming: naming.types.output,
12387
+ plugin,
12388
+ schema
12389
+ })) : void 0;
12390
+ if (typeOutputSymbol) {
12391
+ const outputType = $.type.alias(typeOutputSymbol).export().type($.type(z).attr(identifiers.output).generic($(symbol).typeofType()));
12392
+ plugin.node(outputType);
12393
+ }
12339
12394
  return symbol;
12340
12395
  }
12341
12396
  //#endregion
@@ -13039,7 +13094,7 @@ function inheritMeta(parent, children) {
13039
13094
  }
13040
13095
  //#endregion
13041
13096
  //#region src/plugins/zod/mini/toAst/unknown.ts
13042
- function baseNode$35(ctx) {
13097
+ function baseNode$41(ctx) {
13043
13098
  const { symbols } = ctx;
13044
13099
  const { z } = symbols;
13045
13100
  return $(z).attr(identifiers.unknown).call();
@@ -13054,7 +13109,7 @@ function unknownToAst$2({ plugin, schema }) {
13054
13109
  const ctx = {
13055
13110
  $,
13056
13111
  chain: { current: $(z) },
13057
- nodes: { base: baseNode$35 },
13112
+ nodes: { base: baseNode$41 },
13058
13113
  plugin,
13059
13114
  schema,
13060
13115
  symbols: { z }
@@ -13064,7 +13119,7 @@ function unknownToAst$2({ plugin, schema }) {
13064
13119
  }
13065
13120
  //#endregion
13066
13121
  //#region src/plugins/zod/mini/toAst/array.ts
13067
- function baseNode$34(ctx) {
13122
+ function baseNode$40(ctx) {
13068
13123
  const { applyModifiers, childResults, plugin, schema, symbols } = ctx;
13069
13124
  const { z } = symbols;
13070
13125
  const arrayFn = $(z).attr(identifiers.array);
@@ -13135,7 +13190,7 @@ function arrayToAst$2({ applyModifiers, plugin, schema, walk, walkerCtx }) {
13135
13190
  chain: { current: $(z) },
13136
13191
  childResults,
13137
13192
  nodes: {
13138
- base: baseNode$34,
13193
+ base: baseNode$40,
13139
13194
  length: lengthNode$5,
13140
13195
  maxLength: maxLengthNode$5,
13141
13196
  minLength: minLengthNode$5
@@ -13154,7 +13209,7 @@ function arrayToAst$2({ applyModifiers, plugin, schema, walk, walkerCtx }) {
13154
13209
  }
13155
13210
  //#endregion
13156
13211
  //#region src/plugins/zod/mini/toAst/boolean.ts
13157
- function baseNode$33(ctx) {
13212
+ function baseNode$39(ctx) {
13158
13213
  const { symbols } = ctx;
13159
13214
  const { z } = symbols;
13160
13215
  return $(z).attr(identifiers.boolean).call();
@@ -13181,7 +13236,7 @@ function booleanToAst$2({ plugin, schema }) {
13181
13236
  $,
13182
13237
  chain: { current: $(z) },
13183
13238
  nodes: {
13184
- base: baseNode$33,
13239
+ base: baseNode$39,
13185
13240
  const: constNode$11
13186
13241
  },
13187
13242
  plugin,
@@ -13220,7 +13275,7 @@ function itemsNode$2(ctx) {
13220
13275
  literalMembers
13221
13276
  };
13222
13277
  }
13223
- function baseNode$32(ctx) {
13278
+ function baseNode$38(ctx) {
13224
13279
  const { symbols } = ctx;
13225
13280
  const { z } = symbols;
13226
13281
  const { allStrings, enumMembers, literalMembers } = ctx.nodes.items(ctx);
@@ -13241,7 +13296,7 @@ function enumToAst$2({ plugin, schema }) {
13241
13296
  $,
13242
13297
  chain: { current: $(z) },
13243
13298
  nodes: {
13244
- base: baseNode$32,
13299
+ base: baseNode$38,
13245
13300
  items: itemsNode$2
13246
13301
  },
13247
13302
  plugin,
@@ -13257,8 +13312,44 @@ function enumToAst$2({ plugin, schema }) {
13257
13312
  return resolver?.(ctx) ?? enumResolver$2(ctx);
13258
13313
  }
13259
13314
  //#endregion
13315
+ //#region src/plugins/zod/mini/toAst/intersection.ts
13316
+ function baseNode$37(ctx) {
13317
+ const { childResults, symbols } = ctx;
13318
+ const { z } = symbols;
13319
+ if (!childResults.length) return $(z).attr(identifiers.never).call();
13320
+ let expression = childResults[0].expression;
13321
+ childResults.slice(1).forEach((item) => {
13322
+ expression = $(z).attr(identifiers.intersection).call(expression, item.meta.hasLazy ? $(z).attr(identifiers.lazy).call($.func().do(item.expression.return())) : item.expression);
13323
+ });
13324
+ return expression;
13325
+ }
13326
+ function intersectionResolver$2(ctx) {
13327
+ const baseResult = ctx.nodes.base(ctx);
13328
+ ctx.chain.current = baseResult;
13329
+ return ctx.chain.current;
13330
+ }
13331
+ function intersectionToAst$2({ childResults, parentSchema, plugin, schemas }) {
13332
+ const z = plugin.external("zod.z");
13333
+ const ctx = {
13334
+ $,
13335
+ chain: { current: $(z) },
13336
+ childResults,
13337
+ nodes: { base: baseNode$37 },
13338
+ parentSchema,
13339
+ plugin,
13340
+ schema: parentSchema,
13341
+ schemas,
13342
+ symbols: { z }
13343
+ };
13344
+ const resolver = plugin.config["~resolvers"]?.intersection;
13345
+ return {
13346
+ childResults,
13347
+ expression: resolver?.(ctx) ?? intersectionResolver$2(ctx)
13348
+ };
13349
+ }
13350
+ //#endregion
13260
13351
  //#region src/plugins/zod/mini/toAst/never.ts
13261
- function baseNode$31(ctx) {
13352
+ function baseNode$36(ctx) {
13262
13353
  const { symbols } = ctx;
13263
13354
  const { z } = symbols;
13264
13355
  return $(z).attr(identifiers.never).call();
@@ -13273,7 +13364,7 @@ function neverToAst$2({ plugin, schema }) {
13273
13364
  const ctx = {
13274
13365
  $,
13275
13366
  chain: { current: $(z) },
13276
- nodes: { base: baseNode$31 },
13367
+ nodes: { base: baseNode$36 },
13277
13368
  plugin,
13278
13369
  schema,
13279
13370
  symbols: { z }
@@ -13283,7 +13374,7 @@ function neverToAst$2({ plugin, schema }) {
13283
13374
  }
13284
13375
  //#endregion
13285
13376
  //#region src/plugins/zod/mini/toAst/null.ts
13286
- function baseNode$30(ctx) {
13377
+ function baseNode$35(ctx) {
13287
13378
  const { symbols } = ctx;
13288
13379
  const { z } = symbols;
13289
13380
  return $(z).attr(identifiers.null).call();
@@ -13298,7 +13389,7 @@ function nullToAst$2({ plugin, schema }) {
13298
13389
  const ctx = {
13299
13390
  $,
13300
13391
  chain: { current: $(z) },
13301
- nodes: { base: baseNode$30 },
13392
+ nodes: { base: baseNode$35 },
13302
13393
  plugin,
13303
13394
  schema,
13304
13395
  symbols: { z }
@@ -13308,7 +13399,7 @@ function nullToAst$2({ plugin, schema }) {
13308
13399
  }
13309
13400
  //#endregion
13310
13401
  //#region src/plugins/zod/mini/toAst/number.ts
13311
- function baseNode$29(ctx) {
13402
+ function baseNode$34(ctx) {
13312
13403
  const { schema, symbols } = ctx;
13313
13404
  const { z } = symbols;
13314
13405
  if (ctx.utils.shouldCoerceToBigInt(schema.format)) return $(z).attr(identifiers.coerce).attr(identifiers.bigint).call();
@@ -13360,7 +13451,7 @@ function numberToNode$2({ plugin, schema }) {
13360
13451
  $,
13361
13452
  chain: { current: $(z) },
13362
13453
  nodes: {
13363
- base: baseNode$29,
13454
+ base: baseNode$34,
13364
13455
  const: constNode$10,
13365
13456
  max: maxNode$2,
13366
13457
  min: minNode$2
@@ -13386,7 +13477,7 @@ function additionalPropertiesNode$2(ctx) {
13386
13477
  _childResults.push(additionalResult);
13387
13478
  return applyModifiers(additionalResult, {}).expression;
13388
13479
  }
13389
- function baseNode$28(ctx) {
13480
+ function baseNode$33(ctx) {
13390
13481
  const { nodes, symbols } = ctx;
13391
13482
  const { z } = symbols;
13392
13483
  const additional = nodes.additionalProperties(ctx);
@@ -13421,7 +13512,7 @@ function objectToAst$2(options) {
13421
13512
  chain: { current: $(z) },
13422
13513
  nodes: {
13423
13514
  additionalProperties: additionalPropertiesNode$2,
13424
- base: baseNode$28,
13515
+ base: baseNode$33,
13425
13516
  shape: shapeNode$2
13426
13517
  },
13427
13518
  plugin,
@@ -13438,7 +13529,7 @@ function objectToAst$2(options) {
13438
13529
  }
13439
13530
  //#endregion
13440
13531
  //#region src/plugins/zod/mini/toAst/string.ts
13441
- function baseNode$27(ctx) {
13532
+ function baseNode$32(ctx) {
13442
13533
  const { z } = ctx.symbols;
13443
13534
  return $(z).attr(identifiers.string).call();
13444
13535
  }
@@ -13521,7 +13612,7 @@ function stringToNode$2({ plugin, schema }) {
13521
13612
  $,
13522
13613
  chain: { current: $(z) },
13523
13614
  nodes: {
13524
- base: baseNode$27,
13615
+ base: baseNode$32,
13525
13616
  const: constNode$9,
13526
13617
  format: formatNode$2,
13527
13618
  length: lengthNode$4,
@@ -13538,7 +13629,7 @@ function stringToNode$2({ plugin, schema }) {
13538
13629
  }
13539
13630
  //#endregion
13540
13631
  //#region src/plugins/zod/mini/toAst/tuple.ts
13541
- function baseNode$26(ctx) {
13632
+ function baseNode$31(ctx) {
13542
13633
  const { applyModifiers, childResults, symbols } = ctx;
13543
13634
  const { z } = symbols;
13544
13635
  const tupleFn = $(z).attr(identifiers.tuple);
@@ -13576,7 +13667,7 @@ function tupleToAst$2({ applyModifiers, plugin, schema, walk, walkerCtx }) {
13576
13667
  chain: { current: $(z) },
13577
13668
  childResults,
13578
13669
  nodes: {
13579
- base: baseNode$26,
13670
+ base: baseNode$31,
13580
13671
  const: constNode$8
13581
13672
  },
13582
13673
  plugin,
@@ -13593,7 +13684,7 @@ function tupleToAst$2({ applyModifiers, plugin, schema, walk, walkerCtx }) {
13593
13684
  }
13594
13685
  //#endregion
13595
13686
  //#region src/plugins/zod/mini/toAst/undefined.ts
13596
- function baseNode$25(ctx) {
13687
+ function baseNode$30(ctx) {
13597
13688
  const { symbols } = ctx;
13598
13689
  const { z } = symbols;
13599
13690
  return $(z).attr(identifiers.undefined).call();
@@ -13608,7 +13699,7 @@ function undefinedToAst$2({ plugin, schema }) {
13608
13699
  const ctx = {
13609
13700
  $,
13610
13701
  chain: { current: $(z) },
13611
- nodes: { base: baseNode$25 },
13702
+ nodes: { base: baseNode$30 },
13612
13703
  plugin,
13613
13704
  schema,
13614
13705
  symbols: { z }
@@ -13617,8 +13708,92 @@ function undefinedToAst$2({ plugin, schema }) {
13617
13708
  return resolver?.(ctx) ?? undefinedResolver$2(ctx);
13618
13709
  }
13619
13710
  //#endregion
13711
+ //#region src/plugins/zod/shared/discriminated-union.ts
13712
+ function tryBuildDiscriminatedUnion({ items, parentSchema, plugin, schemas }) {
13713
+ const discriminatorKey = parentSchema.discriminator?.propertyName;
13714
+ if (!discriminatorKey) return null;
13715
+ const members = [];
13716
+ for (let index = 0; index < schemas.length; index++) {
13717
+ const schema = schemas[index];
13718
+ if (schema.type === "null" || schema.const === null) continue;
13719
+ if (schema.logicalOperator !== "and" || !schema.items || schema.items.length !== 2) return null;
13720
+ const refPart = schema.items[1];
13721
+ const discriminatedValue = schema.items[0].properties?.[discriminatorKey]?.const;
13722
+ if (discriminatedValue === void 0 || items[index].meta.hasLazy) return null;
13723
+ let refExpression;
13724
+ if (refPart.symbolRef) refExpression = $(refPart.symbolRef);
13725
+ else if (refPart.$ref) {
13726
+ const query = {
13727
+ category: "schema",
13728
+ resource: "definition",
13729
+ resourceId: refPart.$ref,
13730
+ tool: "zod"
13731
+ };
13732
+ refExpression = $(plugin.referenceSymbol(query));
13733
+ } else return null;
13734
+ members.push({
13735
+ discriminatedValue,
13736
+ refExpression
13737
+ });
13738
+ }
13739
+ if (!members.length) return null;
13740
+ return {
13741
+ discriminatorKey,
13742
+ members
13743
+ };
13744
+ }
13745
+ //#endregion
13746
+ //#region src/plugins/zod/mini/toAst/union.ts
13747
+ function baseNode$29(ctx) {
13748
+ const { childResults, parentSchema, plugin, schemas, symbols } = ctx;
13749
+ const { z } = symbols;
13750
+ if (!childResults.length) return $(z).attr(identifiers.null).call();
13751
+ const nonNullItems = [];
13752
+ childResults.forEach((result, index) => {
13753
+ const schema = schemas[index];
13754
+ if (schema.type !== "null" && schema.const !== null) nonNullItems.push(result);
13755
+ });
13756
+ if (!nonNullItems.length) return $(z).attr(identifiers.null).call();
13757
+ if (nonNullItems.length === 1) return nonNullItems[0].expression;
13758
+ const discriminatedExpression = tryBuildDiscriminatedUnion({
13759
+ items: childResults,
13760
+ parentSchema,
13761
+ plugin,
13762
+ schemas
13763
+ });
13764
+ if (discriminatedExpression) {
13765
+ const unionMembers = discriminatedExpression.members.map((member) => $(z).attr(identifiers.extend).call(member.refExpression, $.object().prop(discriminatedExpression.discriminatorKey, $(z).attr(identifiers.literal).call($.fromValue(member.discriminatedValue)))));
13766
+ return $(z).attr(identifiers.discriminatedUnion).call($.literal(discriminatedExpression.discriminatorKey), $.array().pretty().elements(...unionMembers));
13767
+ }
13768
+ return $(z).attr(identifiers.union).call($.array().pretty().elements(...nonNullItems.map((item) => item.expression)));
13769
+ }
13770
+ function unionResolver$2(ctx) {
13771
+ const baseResult = ctx.nodes.base(ctx);
13772
+ ctx.chain.current = baseResult;
13773
+ return ctx.chain.current;
13774
+ }
13775
+ function unionToAst$2({ childResults, parentSchema, plugin, schemas }) {
13776
+ const z = plugin.external("zod.z");
13777
+ const ctx = {
13778
+ $,
13779
+ chain: { current: $(z) },
13780
+ childResults,
13781
+ nodes: { base: baseNode$29 },
13782
+ parentSchema,
13783
+ plugin,
13784
+ schema: parentSchema,
13785
+ schemas,
13786
+ symbols: { z }
13787
+ };
13788
+ const resolver = plugin.config["~resolvers"]?.union;
13789
+ return {
13790
+ childResults,
13791
+ expression: resolver?.(ctx) ?? unionResolver$2(ctx)
13792
+ };
13793
+ }
13794
+ //#endregion
13620
13795
  //#region src/plugins/zod/mini/toAst/void.ts
13621
- function baseNode$24(ctx) {
13796
+ function baseNode$28(ctx) {
13622
13797
  const { symbols } = ctx;
13623
13798
  const { z } = symbols;
13624
13799
  return $(z).attr(identifiers.void).call();
@@ -13633,7 +13808,7 @@ function voidToAst$2({ plugin, schema }) {
13633
13808
  const ctx = {
13634
13809
  $,
13635
13810
  chain: { current: $(z) },
13636
- nodes: { base: baseNode$24 },
13811
+ nodes: { base: baseNode$28 },
13637
13812
  plugin,
13638
13813
  schema,
13639
13814
  symbols: { z }
@@ -13643,6 +13818,9 @@ function voidToAst$2({ plugin, schema }) {
13643
13818
  }
13644
13819
  //#endregion
13645
13820
  //#region src/plugins/zod/mini/walker.ts
13821
+ function getDefaultValue$2(meta) {
13822
+ return meta.format ? maybeBigInt(meta.default, meta.format) : $.fromValue(meta.default);
13823
+ }
13646
13824
  function createVisitor$2(config = {}) {
13647
13825
  const { schemaExtractor } = config;
13648
13826
  return {
@@ -13651,12 +13829,12 @@ function createVisitor$2(config = {}) {
13651
13829
  const z = ctx.plugin.external("zod.z");
13652
13830
  let expression = result.expression;
13653
13831
  if (result.meta.readonly) expression = $(z).attr(identifiers.readonly).call(expression);
13654
- const hasDefault = result.meta.default !== void 0;
13832
+ const needsDefault = result.meta.default !== void 0;
13655
13833
  const needsNullable = result.meta.nullable;
13656
13834
  if (optional && needsNullable) expression = $(z).attr(identifiers.nullish).call(expression);
13657
13835
  else if (optional) expression = $(z).attr(identifiers.optional).call(expression);
13658
13836
  else if (needsNullable) expression = $(z).attr(identifiers.nullable).call(expression);
13659
- if (hasDefault) expression = $(z).attr(identifiers._default).call(expression, result.meta.format ? maybeBigInt(result.meta.default, result.meta.format) : $.fromValue(result.meta.default));
13837
+ if (needsDefault) expression = $(z).attr(identifiers._default).call(expression, getDefaultValue$2(result.meta));
13660
13838
  return { expression };
13661
13839
  },
13662
13840
  array(schema, ctx, walk) {
@@ -13728,11 +13906,12 @@ function createVisitor$2(config = {}) {
13728
13906
  };
13729
13907
  },
13730
13908
  intersection(items, schemas, parentSchema, ctx) {
13731
- const z = ctx.plugin.external("zod.z");
13732
13909
  const hasAnyLazy = items.some((item) => item.meta.hasLazy);
13733
- let expression = items[0].expression;
13734
- items.slice(1).forEach((item) => {
13735
- expression = $(z).attr(identifiers.intersection).call(expression, item.meta.hasLazy ? $(z).attr(identifiers.lazy).call($.func().do(item.expression.return())) : item.expression);
13910
+ const { expression } = intersectionToAst$2({
13911
+ childResults: items,
13912
+ parentSchema,
13913
+ plugin: ctx.plugin,
13914
+ schemas
13736
13915
  });
13737
13916
  return {
13738
13917
  expression,
@@ -13886,18 +14065,14 @@ function createVisitor$2(config = {}) {
13886
14065
  };
13887
14066
  },
13888
14067
  union(items, schemas, parentSchema, ctx) {
13889
- const z = ctx.plugin.external("zod.z");
13890
14068
  const hasAnyLazy = items.some((item) => item.meta.hasLazy);
13891
14069
  const hasNull = schemas.some((s) => s.type === "null") || items.some((i) => i.meta.nullable);
13892
- const nonNullItems = [];
13893
- items.forEach((item, index) => {
13894
- const schema = schemas[index];
13895
- if (schema.type !== "null" && schema.const !== null) nonNullItems.push(item);
14070
+ const { expression } = unionToAst$2({
14071
+ childResults: items,
14072
+ parentSchema,
14073
+ plugin: ctx.plugin,
14074
+ schemas
13896
14075
  });
13897
- let expression;
13898
- if (!nonNullItems.length) expression = $(z).attr(identifiers.null).call();
13899
- else if (nonNullItems.length === 1) expression = nonNullItems[0].expression;
13900
- else expression = $(z).attr(identifiers.union).call($.array().pretty().elements(...nonNullItems.map((item) => item.expression)));
13901
14076
  return {
13902
14077
  expression,
13903
14078
  meta: {
@@ -14057,7 +14232,7 @@ const handlerMini = ({ plugin }) => {
14057
14232
  };
14058
14233
  //#endregion
14059
14234
  //#region src/plugins/zod/v3/toAst/unknown.ts
14060
- function baseNode$23(ctx) {
14235
+ function baseNode$27(ctx) {
14061
14236
  const { symbols } = ctx;
14062
14237
  const { z } = symbols;
14063
14238
  return $(z).attr(identifiers.unknown).call();
@@ -14072,7 +14247,7 @@ function unknownToAst$1({ plugin, schema }) {
14072
14247
  const ctx = {
14073
14248
  $,
14074
14249
  chain: { current: $(z) },
14075
- nodes: { base: baseNode$23 },
14250
+ nodes: { base: baseNode$27 },
14076
14251
  plugin,
14077
14252
  schema,
14078
14253
  symbols: { z }
@@ -14082,7 +14257,7 @@ function unknownToAst$1({ plugin, schema }) {
14082
14257
  }
14083
14258
  //#endregion
14084
14259
  //#region src/plugins/zod/v3/toAst/array.ts
14085
- function baseNode$22(ctx) {
14260
+ function baseNode$26(ctx) {
14086
14261
  const { applyModifiers, childResults, plugin, schema, symbols } = ctx;
14087
14262
  const { z } = symbols;
14088
14263
  const arrayFn = $(z).attr(identifiers.array);
@@ -14158,7 +14333,7 @@ function arrayToAst$1({ applyModifiers, plugin, schema, walk, walkerCtx }) {
14158
14333
  chain: { current: $(z) },
14159
14334
  childResults,
14160
14335
  nodes: {
14161
- base: baseNode$22,
14336
+ base: baseNode$26,
14162
14337
  length: lengthNode$3,
14163
14338
  maxLength: maxLengthNode$3,
14164
14339
  minLength: minLengthNode$3
@@ -14177,7 +14352,7 @@ function arrayToAst$1({ applyModifiers, plugin, schema, walk, walkerCtx }) {
14177
14352
  }
14178
14353
  //#endregion
14179
14354
  //#region src/plugins/zod/v3/toAst/boolean.ts
14180
- function baseNode$21(ctx) {
14355
+ function baseNode$25(ctx) {
14181
14356
  const { symbols } = ctx;
14182
14357
  const { z } = symbols;
14183
14358
  return $(z).attr(identifiers.boolean).call();
@@ -14204,7 +14379,7 @@ function booleanToAst$1({ plugin, schema }) {
14204
14379
  $,
14205
14380
  chain: { current: $(z) },
14206
14381
  nodes: {
14207
- base: baseNode$21,
14382
+ base: baseNode$25,
14208
14383
  const: constNode$7
14209
14384
  },
14210
14385
  plugin,
@@ -14243,7 +14418,7 @@ function itemsNode$1(ctx) {
14243
14418
  literalMembers
14244
14419
  };
14245
14420
  }
14246
- function baseNode$20(ctx) {
14421
+ function baseNode$24(ctx) {
14247
14422
  const { symbols } = ctx;
14248
14423
  const { z } = symbols;
14249
14424
  const { allStrings, enumMembers, literalMembers } = ctx.nodes.items(ctx);
@@ -14264,7 +14439,7 @@ function enumToAst$1({ plugin, schema }) {
14264
14439
  $,
14265
14440
  chain: { current: $(z) },
14266
14441
  nodes: {
14267
- base: baseNode$20,
14442
+ base: baseNode$24,
14268
14443
  items: itemsNode$1
14269
14444
  },
14270
14445
  plugin,
@@ -14275,8 +14450,46 @@ function enumToAst$1({ plugin, schema }) {
14275
14450
  return resolver?.(ctx) ?? enumResolver$1(ctx);
14276
14451
  }
14277
14452
  //#endregion
14453
+ //#region src/plugins/zod/v3/toAst/intersection.ts
14454
+ function baseNode$23(ctx) {
14455
+ const { childResults, schemas, symbols } = ctx;
14456
+ const { z } = symbols;
14457
+ if (!childResults.length) return $(z).attr(identifiers.never).call();
14458
+ const firstSchema = schemas[0];
14459
+ if (firstSchema?.logicalOperator === "or" || firstSchema?.type && firstSchema.type !== "object") return $(z).attr(identifiers.intersection).call(...childResults.map((result) => result.expression));
14460
+ let expression = childResults[0].expression;
14461
+ childResults.slice(1).forEach((item) => {
14462
+ expression = expression.attr(identifiers.and).call(item.meta.hasLazy && !item.meta.isLazy ? $(z).attr(identifiers.lazy).call($.func().do(item.expression.return())) : item.expression);
14463
+ });
14464
+ return expression;
14465
+ }
14466
+ function intersectionResolver$1(ctx) {
14467
+ const baseResult = ctx.nodes.base(ctx);
14468
+ ctx.chain.current = baseResult;
14469
+ return ctx.chain.current;
14470
+ }
14471
+ function intersectionToAst$1({ childResults, parentSchema, plugin, schemas }) {
14472
+ const z = plugin.external("zod.z");
14473
+ const ctx = {
14474
+ $,
14475
+ chain: { current: $(z) },
14476
+ childResults,
14477
+ nodes: { base: baseNode$23 },
14478
+ parentSchema,
14479
+ plugin,
14480
+ schema: parentSchema,
14481
+ schemas,
14482
+ symbols: { z }
14483
+ };
14484
+ const resolver = plugin.config["~resolvers"]?.intersection;
14485
+ return {
14486
+ childResults,
14487
+ expression: resolver?.(ctx) ?? intersectionResolver$1(ctx)
14488
+ };
14489
+ }
14490
+ //#endregion
14278
14491
  //#region src/plugins/zod/v3/toAst/never.ts
14279
- function baseNode$19(ctx) {
14492
+ function baseNode$22(ctx) {
14280
14493
  const { symbols } = ctx;
14281
14494
  const { z } = symbols;
14282
14495
  return $(z).attr(identifiers.never).call();
@@ -14291,7 +14504,7 @@ function neverToAst$1({ plugin, schema }) {
14291
14504
  const ctx = {
14292
14505
  $,
14293
14506
  chain: { current: $(z) },
14294
- nodes: { base: baseNode$19 },
14507
+ nodes: { base: baseNode$22 },
14295
14508
  plugin,
14296
14509
  schema,
14297
14510
  symbols: { z }
@@ -14301,7 +14514,7 @@ function neverToAst$1({ plugin, schema }) {
14301
14514
  }
14302
14515
  //#endregion
14303
14516
  //#region src/plugins/zod/v3/toAst/null.ts
14304
- function baseNode$18(ctx) {
14517
+ function baseNode$21(ctx) {
14305
14518
  const { symbols } = ctx;
14306
14519
  const { z } = symbols;
14307
14520
  return $(z).attr(identifiers.null).call();
@@ -14316,7 +14529,7 @@ function nullToAst$1({ plugin, schema }) {
14316
14529
  const ctx = {
14317
14530
  $,
14318
14531
  chain: { current: $(z) },
14319
- nodes: { base: baseNode$18 },
14532
+ nodes: { base: baseNode$21 },
14320
14533
  plugin,
14321
14534
  schema,
14322
14535
  symbols: { z }
@@ -14326,7 +14539,7 @@ function nullToAst$1({ plugin, schema }) {
14326
14539
  }
14327
14540
  //#endregion
14328
14541
  //#region src/plugins/zod/v3/toAst/number.ts
14329
- function baseNode$17(ctx) {
14542
+ function baseNode$20(ctx) {
14330
14543
  const { schema, symbols } = ctx;
14331
14544
  const { z } = symbols;
14332
14545
  if (ctx.utils.shouldCoerceToBigInt(schema.format)) return $(z).attr(identifiers.coerce).attr(identifiers.bigint).call();
@@ -14374,7 +14587,7 @@ function numberToNode$1({ plugin, schema }) {
14374
14587
  $,
14375
14588
  chain: { current: $(z) },
14376
14589
  nodes: {
14377
- base: baseNode$17,
14590
+ base: baseNode$20,
14378
14591
  const: constNode$6,
14379
14592
  max: maxNode$1,
14380
14593
  min: minNode$1
@@ -14400,7 +14613,7 @@ function additionalPropertiesNode$1(ctx) {
14400
14613
  ctx._childResults.push(additionalResult);
14401
14614
  return applyModifiers(additionalResult, {}).expression;
14402
14615
  }
14403
- function baseNode$16(ctx) {
14616
+ function baseNode$19(ctx) {
14404
14617
  const { nodes, symbols } = ctx;
14405
14618
  const { z } = symbols;
14406
14619
  const additional = nodes.additionalProperties(ctx);
@@ -14435,7 +14648,7 @@ function objectToAst$1(options) {
14435
14648
  chain: { current: $(z) },
14436
14649
  nodes: {
14437
14650
  additionalProperties: additionalPropertiesNode$1,
14438
- base: baseNode$16,
14651
+ base: baseNode$19,
14439
14652
  shape: shapeNode$1
14440
14653
  },
14441
14654
  plugin,
@@ -14452,7 +14665,7 @@ function objectToAst$1(options) {
14452
14665
  }
14453
14666
  //#endregion
14454
14667
  //#region src/plugins/zod/v3/toAst/string.ts
14455
- function baseNode$15(ctx) {
14668
+ function baseNode$18(ctx) {
14456
14669
  const { z } = ctx.symbols;
14457
14670
  return $(z).attr(identifiers.string).call();
14458
14671
  }
@@ -14527,7 +14740,7 @@ function stringToNode$1({ plugin, schema }) {
14527
14740
  $,
14528
14741
  chain: { current: $(z) },
14529
14742
  nodes: {
14530
- base: baseNode$15,
14743
+ base: baseNode$18,
14531
14744
  const: constNode$5,
14532
14745
  format: formatNode$1,
14533
14746
  length: lengthNode$2,
@@ -14544,7 +14757,7 @@ function stringToNode$1({ plugin, schema }) {
14544
14757
  }
14545
14758
  //#endregion
14546
14759
  //#region src/plugins/zod/v3/toAst/tuple.ts
14547
- function baseNode$14(ctx) {
14760
+ function baseNode$17(ctx) {
14548
14761
  const { applyModifiers, childResults, symbols } = ctx;
14549
14762
  const { z } = symbols;
14550
14763
  const tupleFn = $(z).attr(identifiers.tuple);
@@ -14582,7 +14795,7 @@ function tupleToAst$1({ applyModifiers, plugin, schema, walk, walkerCtx }) {
14582
14795
  chain: { current: $(z) },
14583
14796
  childResults,
14584
14797
  nodes: {
14585
- base: baseNode$14,
14798
+ base: baseNode$17,
14586
14799
  const: constNode$4
14587
14800
  },
14588
14801
  plugin,
@@ -14599,7 +14812,7 @@ function tupleToAst$1({ applyModifiers, plugin, schema, walk, walkerCtx }) {
14599
14812
  }
14600
14813
  //#endregion
14601
14814
  //#region src/plugins/zod/v3/toAst/undefined.ts
14602
- function baseNode$13(ctx) {
14815
+ function baseNode$16(ctx) {
14603
14816
  const { symbols } = ctx;
14604
14817
  const { z } = symbols;
14605
14818
  return $(z).attr(identifiers.undefined).call();
@@ -14614,7 +14827,7 @@ function undefinedToAst$1({ plugin, schema }) {
14614
14827
  const ctx = {
14615
14828
  $,
14616
14829
  chain: { current: $(z) },
14617
- nodes: { base: baseNode$13 },
14830
+ nodes: { base: baseNode$16 },
14618
14831
  plugin,
14619
14832
  schema,
14620
14833
  symbols: { z }
@@ -14623,8 +14836,57 @@ function undefinedToAst$1({ plugin, schema }) {
14623
14836
  return resolver?.(ctx) ?? undefinedResolver$1(ctx);
14624
14837
  }
14625
14838
  //#endregion
14839
+ //#region src/plugins/zod/v3/toAst/union.ts
14840
+ function baseNode$15(ctx) {
14841
+ const { childResults, parentSchema, plugin, schemas, symbols } = ctx;
14842
+ const { z } = symbols;
14843
+ if (!childResults.length) return $(z).attr(identifiers.null).call();
14844
+ const nonNullItems = [];
14845
+ childResults.forEach((result, index) => {
14846
+ const schema = schemas[index];
14847
+ if (schema.type !== "null" && schema.const !== null) nonNullItems.push(result);
14848
+ });
14849
+ if (!nonNullItems.length) return $(z).attr(identifiers.null).call();
14850
+ if (nonNullItems.length === 1) return nonNullItems[0].expression;
14851
+ const discriminatedExpression = tryBuildDiscriminatedUnion({
14852
+ items: childResults,
14853
+ parentSchema,
14854
+ plugin,
14855
+ schemas
14856
+ });
14857
+ if (discriminatedExpression) {
14858
+ const unionMembers = discriminatedExpression.members.map((member) => member.refExpression.attr(identifiers.extend).call($.object().prop(discriminatedExpression.discriminatorKey, $(z).attr(identifiers.literal).call($.fromValue(member.discriminatedValue)))));
14859
+ return $(z).attr(identifiers.discriminatedUnion).call($.literal(discriminatedExpression.discriminatorKey), $.array().pretty().elements(...unionMembers));
14860
+ }
14861
+ return $(z).attr(identifiers.union).call($.array().pretty().elements(...nonNullItems.map((item) => item.expression)));
14862
+ }
14863
+ function unionResolver$1(ctx) {
14864
+ const baseResult = ctx.nodes.base(ctx);
14865
+ ctx.chain.current = baseResult;
14866
+ return ctx.chain.current;
14867
+ }
14868
+ function unionToAst$1({ childResults, parentSchema, plugin, schemas }) {
14869
+ const z = plugin.external("zod.z");
14870
+ const ctx = {
14871
+ $,
14872
+ chain: { current: $(z) },
14873
+ childResults,
14874
+ nodes: { base: baseNode$15 },
14875
+ parentSchema,
14876
+ plugin,
14877
+ schema: parentSchema,
14878
+ schemas,
14879
+ symbols: { z }
14880
+ };
14881
+ const resolver = plugin.config["~resolvers"]?.union;
14882
+ return {
14883
+ childResults,
14884
+ expression: resolver?.(ctx) ?? unionResolver$1(ctx)
14885
+ };
14886
+ }
14887
+ //#endregion
14626
14888
  //#region src/plugins/zod/v3/toAst/void.ts
14627
- function baseNode$12(ctx) {
14889
+ function baseNode$14(ctx) {
14628
14890
  const { symbols } = ctx;
14629
14891
  const { z } = symbols;
14630
14892
  return $(z).attr(identifiers.void).call();
@@ -14639,7 +14901,7 @@ function voidToAst$1({ plugin, schema }) {
14639
14901
  const ctx = {
14640
14902
  $,
14641
14903
  chain: { current: $(z) },
14642
- nodes: { base: baseNode$12 },
14904
+ nodes: { base: baseNode$14 },
14643
14905
  plugin,
14644
14906
  schema,
14645
14907
  symbols: { z }
@@ -14649,6 +14911,9 @@ function voidToAst$1({ plugin, schema }) {
14649
14911
  }
14650
14912
  //#endregion
14651
14913
  //#region src/plugins/zod/v3/walker.ts
14914
+ function getDefaultValue$1(meta) {
14915
+ return meta.format ? maybeBigInt(meta.default, meta.format) : $.fromValue(meta.default);
14916
+ }
14652
14917
  function createVisitor$1(config = {}) {
14653
14918
  const { schemaExtractor } = config;
14654
14919
  return {
@@ -14656,12 +14921,12 @@ function createVisitor$1(config = {}) {
14656
14921
  const { optional } = options;
14657
14922
  let expression = result.expression;
14658
14923
  if (result.meta.readonly) expression = expression.attr(identifiers.readonly).call();
14659
- const hasDefault = result.meta.default !== void 0;
14924
+ const needsDefault = result.meta.default !== void 0;
14660
14925
  const needsNullable = result.meta.nullable;
14661
14926
  if (optional && needsNullable) expression = expression.attr(identifiers.nullish).call();
14662
14927
  else if (optional) expression = expression.attr(identifiers.optional).call();
14663
14928
  else if (needsNullable) expression = expression.attr(identifiers.nullable).call();
14664
- if (hasDefault) expression = expression.attr(identifiers.default).call(result.meta.format ? maybeBigInt(result.meta.default, result.meta.format) : $.fromValue(result.meta.default));
14929
+ if (needsDefault) expression = expression.attr(identifiers.default).call(getDefaultValue$1(result.meta));
14665
14930
  return {
14666
14931
  expression,
14667
14932
  typeName: result.meta.hasLazy ? result.meta.isObject ? identifiers.AnyZodObject : identifiers.ZodTypeAny : void 0
@@ -14736,17 +15001,13 @@ function createVisitor$1(config = {}) {
14736
15001
  };
14737
15002
  },
14738
15003
  intersection(items, schemas, parentSchema, ctx) {
14739
- const z = ctx.plugin.external("zod.z");
14740
15004
  const hasAnyLazy = items.some((item) => item.meta.hasLazy);
14741
- const firstSchema = schemas[0];
14742
- let expression;
14743
- if (firstSchema?.logicalOperator === "or" || firstSchema?.type && firstSchema.type !== "object") expression = $(z).attr(identifiers.intersection).call(...items.map((item) => item.expression));
14744
- else {
14745
- expression = items[0].expression;
14746
- items.slice(1).forEach((item) => {
14747
- expression = expression.attr(identifiers.and).call(item.meta.hasLazy && !item.meta.isLazy ? $(z).attr(identifiers.lazy).call($.func().do(item.expression.return())) : item.expression);
14748
- });
14749
- }
15005
+ const { expression } = intersectionToAst$1({
15006
+ childResults: items,
15007
+ parentSchema,
15008
+ plugin: ctx.plugin,
15009
+ schemas
15010
+ });
14750
15011
  return {
14751
15012
  expression,
14752
15013
  meta: {
@@ -14890,18 +15151,14 @@ function createVisitor$1(config = {}) {
14890
15151
  };
14891
15152
  },
14892
15153
  union(items, schemas, parentSchema, ctx) {
14893
- const z = ctx.plugin.external("zod.z");
14894
15154
  const hasAnyLazy = items.some((item) => item.meta.hasLazy);
14895
15155
  const hasNull = schemas.some((s) => s.type === "null") || items.some((i) => i.meta.nullable);
14896
- const nonNullItems = [];
14897
- items.forEach((item, index) => {
14898
- const schema = schemas[index];
14899
- if (schema.type !== "null" && schema.const !== null) nonNullItems.push(item);
15156
+ const { expression } = unionToAst$1({
15157
+ childResults: items,
15158
+ parentSchema,
15159
+ plugin: ctx.plugin,
15160
+ schemas
14900
15161
  });
14901
- let expression;
14902
- if (!nonNullItems.length) expression = $(z).attr(identifiers.null).call();
14903
- else if (nonNullItems.length === 1) expression = nonNullItems[0].expression;
14904
- else expression = $(z).attr(identifiers.union).call($.array().pretty().elements(...nonNullItems.map((item) => item.expression)));
14905
15162
  return {
14906
15163
  expression,
14907
15164
  meta: {
@@ -15060,7 +15317,7 @@ const handlerV3 = ({ plugin }) => {
15060
15317
  };
15061
15318
  //#endregion
15062
15319
  //#region src/plugins/zod/v4/toAst/unknown.ts
15063
- function baseNode$11(ctx) {
15320
+ function baseNode$13(ctx) {
15064
15321
  const { symbols } = ctx;
15065
15322
  const { z } = symbols;
15066
15323
  return $(z).attr(identifiers.unknown).call();
@@ -15075,7 +15332,7 @@ function unknownToAst({ plugin, schema }) {
15075
15332
  const ctx = {
15076
15333
  $,
15077
15334
  chain: { current: $(z) },
15078
- nodes: { base: baseNode$11 },
15335
+ nodes: { base: baseNode$13 },
15079
15336
  plugin,
15080
15337
  schema,
15081
15338
  symbols: { z }
@@ -15085,7 +15342,7 @@ function unknownToAst({ plugin, schema }) {
15085
15342
  }
15086
15343
  //#endregion
15087
15344
  //#region src/plugins/zod/v4/toAst/array.ts
15088
- function baseNode$10(ctx) {
15345
+ function baseNode$12(ctx) {
15089
15346
  const { applyModifiers, childResults, plugin, schema, symbols } = ctx;
15090
15347
  const { z } = symbols;
15091
15348
  const arrayFn = $(z).attr(identifiers.array);
@@ -15161,7 +15418,7 @@ function arrayToAst({ applyModifiers, plugin, schema, walk, walkerCtx }) {
15161
15418
  chain: { current: $(z) },
15162
15419
  childResults,
15163
15420
  nodes: {
15164
- base: baseNode$10,
15421
+ base: baseNode$12,
15165
15422
  length: lengthNode$1,
15166
15423
  maxLength: maxLengthNode$1,
15167
15424
  minLength: minLengthNode$1
@@ -15180,7 +15437,7 @@ function arrayToAst({ applyModifiers, plugin, schema, walk, walkerCtx }) {
15180
15437
  }
15181
15438
  //#endregion
15182
15439
  //#region src/plugins/zod/v4/toAst/boolean.ts
15183
- function baseNode$9(ctx) {
15440
+ function baseNode$11(ctx) {
15184
15441
  const { symbols } = ctx;
15185
15442
  const { z } = symbols;
15186
15443
  return $(z).attr(identifiers.boolean).call();
@@ -15207,7 +15464,7 @@ function booleanToAst({ plugin, schema }) {
15207
15464
  $,
15208
15465
  chain: { current: $(z) },
15209
15466
  nodes: {
15210
- base: baseNode$9,
15467
+ base: baseNode$11,
15211
15468
  const: constNode$3
15212
15469
  },
15213
15470
  plugin,
@@ -15246,7 +15503,7 @@ function itemsNode(ctx) {
15246
15503
  literalMembers
15247
15504
  };
15248
15505
  }
15249
- function baseNode$8(ctx) {
15506
+ function baseNode$10(ctx) {
15250
15507
  const { symbols } = ctx;
15251
15508
  const { z } = symbols;
15252
15509
  const { allStrings, enumMembers, literalMembers } = ctx.nodes.items(ctx);
@@ -15267,7 +15524,7 @@ function enumToAst({ plugin, schema }) {
15267
15524
  $,
15268
15525
  chain: { current: $(z) },
15269
15526
  nodes: {
15270
- base: baseNode$8,
15527
+ base: baseNode$10,
15271
15528
  items: itemsNode
15272
15529
  },
15273
15530
  plugin,
@@ -15283,8 +15540,46 @@ function enumToAst({ plugin, schema }) {
15283
15540
  return resolver?.(ctx) ?? enumResolver(ctx);
15284
15541
  }
15285
15542
  //#endregion
15543
+ //#region src/plugins/zod/v4/toAst/intersection.ts
15544
+ function baseNode$9(ctx) {
15545
+ const { childResults, schemas, symbols } = ctx;
15546
+ const { z } = symbols;
15547
+ if (!childResults.length) return $(z).attr(identifiers.never).call();
15548
+ const firstSchema = schemas[0];
15549
+ if (firstSchema?.logicalOperator === "or" || firstSchema?.type && firstSchema.type !== "object") return $(z).attr(identifiers.intersection).call(...childResults.map((result) => result.expression));
15550
+ let expression = childResults[0].expression;
15551
+ childResults.slice(1).forEach((item) => {
15552
+ expression = expression.attr(identifiers.and).call(item.meta.hasLazy ? $(z).attr(identifiers.lazy).call($.func().do(item.expression.return())) : item.expression);
15553
+ });
15554
+ return expression;
15555
+ }
15556
+ function intersectionResolver(ctx) {
15557
+ const baseResult = ctx.nodes.base(ctx);
15558
+ ctx.chain.current = baseResult;
15559
+ return ctx.chain.current;
15560
+ }
15561
+ function intersectionToAst({ childResults, parentSchema, plugin, schemas }) {
15562
+ const z = plugin.external("zod.z");
15563
+ const ctx = {
15564
+ $,
15565
+ chain: { current: $(z) },
15566
+ childResults,
15567
+ nodes: { base: baseNode$9 },
15568
+ parentSchema,
15569
+ plugin,
15570
+ schema: parentSchema,
15571
+ schemas,
15572
+ symbols: { z }
15573
+ };
15574
+ const resolver = plugin.config["~resolvers"]?.intersection;
15575
+ return {
15576
+ childResults,
15577
+ expression: resolver?.(ctx) ?? intersectionResolver(ctx)
15578
+ };
15579
+ }
15580
+ //#endregion
15286
15581
  //#region src/plugins/zod/v4/toAst/never.ts
15287
- function baseNode$7(ctx) {
15582
+ function baseNode$8(ctx) {
15288
15583
  const { symbols } = ctx;
15289
15584
  const { z } = symbols;
15290
15585
  return $(z).attr(identifiers.never).call();
@@ -15299,7 +15594,7 @@ function neverToAst({ plugin, schema }) {
15299
15594
  const ctx = {
15300
15595
  $,
15301
15596
  chain: { current: $(z) },
15302
- nodes: { base: baseNode$7 },
15597
+ nodes: { base: baseNode$8 },
15303
15598
  plugin,
15304
15599
  schema,
15305
15600
  symbols: { z }
@@ -15309,7 +15604,7 @@ function neverToAst({ plugin, schema }) {
15309
15604
  }
15310
15605
  //#endregion
15311
15606
  //#region src/plugins/zod/v4/toAst/null.ts
15312
- function baseNode$6(ctx) {
15607
+ function baseNode$7(ctx) {
15313
15608
  const { symbols } = ctx;
15314
15609
  const { z } = symbols;
15315
15610
  return $(z).attr(identifiers.null).call();
@@ -15324,7 +15619,7 @@ function nullToAst({ plugin, schema }) {
15324
15619
  const ctx = {
15325
15620
  $,
15326
15621
  chain: { current: $(z) },
15327
- nodes: { base: baseNode$6 },
15622
+ nodes: { base: baseNode$7 },
15328
15623
  plugin,
15329
15624
  schema,
15330
15625
  symbols: { z }
@@ -15334,7 +15629,7 @@ function nullToAst({ plugin, schema }) {
15334
15629
  }
15335
15630
  //#endregion
15336
15631
  //#region src/plugins/zod/v4/toAst/number.ts
15337
- function baseNode$5(ctx) {
15632
+ function baseNode$6(ctx) {
15338
15633
  const { schema, symbols } = ctx;
15339
15634
  const { z } = symbols;
15340
15635
  if (ctx.utils.shouldCoerceToBigInt(schema.format)) return $(z).attr(identifiers.coerce).attr(identifiers.bigint).call();
@@ -15382,7 +15677,7 @@ function numberToNode({ plugin, schema }) {
15382
15677
  $,
15383
15678
  chain: { current: $(z) },
15384
15679
  nodes: {
15385
- base: baseNode$5,
15680
+ base: baseNode$6,
15386
15681
  const: constNode$2,
15387
15682
  max: maxNode,
15388
15683
  min: minNode
@@ -15408,7 +15703,7 @@ function additionalPropertiesNode(ctx) {
15408
15703
  _childResults.push(additionalResult);
15409
15704
  return applyModifiers(additionalResult, {}).expression;
15410
15705
  }
15411
- function baseNode$4(ctx) {
15706
+ function baseNode$5(ctx) {
15412
15707
  const { nodes, symbols } = ctx;
15413
15708
  const { z } = symbols;
15414
15709
  const additional = nodes.additionalProperties(ctx);
@@ -15443,7 +15738,7 @@ function objectToAst(options) {
15443
15738
  chain: { current: $(z) },
15444
15739
  nodes: {
15445
15740
  additionalProperties: additionalPropertiesNode,
15446
- base: baseNode$4,
15741
+ base: baseNode$5,
15447
15742
  shape: shapeNode
15448
15743
  },
15449
15744
  plugin,
@@ -15460,7 +15755,7 @@ function objectToAst(options) {
15460
15755
  }
15461
15756
  //#endregion
15462
15757
  //#region src/plugins/zod/v4/toAst/string.ts
15463
- function baseNode$3(ctx) {
15758
+ function baseNode$4(ctx) {
15464
15759
  const { z } = ctx.symbols;
15465
15760
  return $(z).attr(identifiers.string).call();
15466
15761
  }
@@ -15537,7 +15832,7 @@ function stringToNode({ plugin, schema }) {
15537
15832
  $,
15538
15833
  chain: { current: $(z) },
15539
15834
  nodes: {
15540
- base: baseNode$3,
15835
+ base: baseNode$4,
15541
15836
  const: constNode$1,
15542
15837
  format: formatNode,
15543
15838
  length: lengthNode,
@@ -15554,7 +15849,7 @@ function stringToNode({ plugin, schema }) {
15554
15849
  }
15555
15850
  //#endregion
15556
15851
  //#region src/plugins/zod/v4/toAst/tuple.ts
15557
- function baseNode$2(ctx) {
15852
+ function baseNode$3(ctx) {
15558
15853
  const { applyModifiers, childResults, symbols } = ctx;
15559
15854
  const { z } = symbols;
15560
15855
  const tupleFn = $(z).attr(identifiers.tuple);
@@ -15592,7 +15887,7 @@ function tupleToAst({ applyModifiers, plugin, schema, walk, walkerCtx }) {
15592
15887
  chain: { current: $(z) },
15593
15888
  childResults,
15594
15889
  nodes: {
15595
- base: baseNode$2,
15890
+ base: baseNode$3,
15596
15891
  const: constNode
15597
15892
  },
15598
15893
  plugin,
@@ -15609,7 +15904,7 @@ function tupleToAst({ applyModifiers, plugin, schema, walk, walkerCtx }) {
15609
15904
  }
15610
15905
  //#endregion
15611
15906
  //#region src/plugins/zod/v4/toAst/undefined.ts
15612
- function baseNode$1(ctx) {
15907
+ function baseNode$2(ctx) {
15613
15908
  const { symbols } = ctx;
15614
15909
  const { z } = symbols;
15615
15910
  return $(z).attr(identifiers.undefined).call();
@@ -15624,7 +15919,7 @@ function undefinedToAst({ plugin, schema }) {
15624
15919
  const ctx = {
15625
15920
  $,
15626
15921
  chain: { current: $(z) },
15627
- nodes: { base: baseNode$1 },
15922
+ nodes: { base: baseNode$2 },
15628
15923
  plugin,
15629
15924
  schema,
15630
15925
  symbols: { z }
@@ -15633,6 +15928,58 @@ function undefinedToAst({ plugin, schema }) {
15633
15928
  return resolver?.(ctx) ?? undefinedResolver(ctx);
15634
15929
  }
15635
15930
  //#endregion
15931
+ //#region src/plugins/zod/v4/toAst/union.ts
15932
+ function baseNode$1(ctx) {
15933
+ const { childResults, parentSchema, plugin, schemas, symbols } = ctx;
15934
+ const { z } = symbols;
15935
+ if (!childResults.length) return $(z).attr(identifiers.null).call();
15936
+ const nonNullItems = [];
15937
+ childResults.forEach((result, index) => {
15938
+ const schema = schemas[index];
15939
+ if (schema.type !== "null" && schema.const !== null) nonNullItems.push(result);
15940
+ });
15941
+ let expression;
15942
+ if (!nonNullItems.length) expression = $(z).attr(identifiers.null).call();
15943
+ else if (nonNullItems.length === 1) expression = nonNullItems[0].expression;
15944
+ else {
15945
+ const discriminatedExpression = tryBuildDiscriminatedUnion({
15946
+ items: childResults,
15947
+ parentSchema,
15948
+ plugin,
15949
+ schemas
15950
+ });
15951
+ if (discriminatedExpression) {
15952
+ const unionMembers = discriminatedExpression.members.map((member) => member.refExpression.attr(identifiers.extend).call($.object().prop(discriminatedExpression.discriminatorKey, $(z).attr(identifiers.literal).call($.fromValue(member.discriminatedValue)))));
15953
+ expression = $(z).attr(identifiers.discriminatedUnion).call($.literal(discriminatedExpression.discriminatorKey), $.array().pretty().elements(...unionMembers));
15954
+ } else expression = $(z).attr(identifiers.union).call($.array().pretty().elements(...nonNullItems.map((item) => item.expression)));
15955
+ }
15956
+ return expression;
15957
+ }
15958
+ function unionResolver(ctx) {
15959
+ const baseResult = ctx.nodes.base(ctx);
15960
+ ctx.chain.current = baseResult;
15961
+ return ctx.chain.current;
15962
+ }
15963
+ function unionToAst({ childResults, parentSchema, plugin, schemas }) {
15964
+ const z = plugin.external("zod.z");
15965
+ const ctx = {
15966
+ $,
15967
+ chain: { current: $(z) },
15968
+ childResults,
15969
+ nodes: { base: baseNode$1 },
15970
+ parentSchema,
15971
+ plugin,
15972
+ schema: parentSchema,
15973
+ schemas,
15974
+ symbols: { z }
15975
+ };
15976
+ const resolver = plugin.config["~resolvers"]?.union;
15977
+ return {
15978
+ childResults,
15979
+ expression: resolver?.(ctx) ?? unionResolver(ctx)
15980
+ };
15981
+ }
15982
+ //#endregion
15636
15983
  //#region src/plugins/zod/v4/toAst/void.ts
15637
15984
  function baseNode(ctx) {
15638
15985
  const { symbols } = ctx;
@@ -15659,6 +16006,9 @@ function voidToAst({ plugin, schema }) {
15659
16006
  }
15660
16007
  //#endregion
15661
16008
  //#region src/plugins/zod/v4/walker.ts
16009
+ function getDefaultValue(meta) {
16010
+ return meta.format ? maybeBigInt(meta.default, meta.format) : $.fromValue(meta.default);
16011
+ }
15662
16012
  function createVisitor(config = {}) {
15663
16013
  const { schemaExtractor } = config;
15664
16014
  return {
@@ -15666,12 +16016,12 @@ function createVisitor(config = {}) {
15666
16016
  const { optional } = options;
15667
16017
  let expression = result.expression;
15668
16018
  if (result.meta.readonly) expression = expression.attr(identifiers.readonly).call();
15669
- const hasDefault = result.meta.default !== void 0;
16019
+ const needsDefault = result.meta.default !== void 0;
15670
16020
  const needsNullable = result.meta.nullable;
15671
16021
  if (optional && needsNullable) expression = expression.attr(identifiers.nullish).call();
15672
16022
  else if (optional) expression = expression.attr(identifiers.optional).call();
15673
16023
  else if (needsNullable) expression = expression.attr(identifiers.nullable).call();
15674
- if (hasDefault) expression = expression.attr(identifiers.default).call(result.meta.format ? maybeBigInt(result.meta.default, result.meta.format) : $.fromValue(result.meta.default));
16024
+ if (needsDefault) expression = expression.attr(identifiers.default).call(getDefaultValue(result.meta));
15675
16025
  return { expression };
15676
16026
  },
15677
16027
  array(schema, ctx, walk) {
@@ -15743,17 +16093,13 @@ function createVisitor(config = {}) {
15743
16093
  };
15744
16094
  },
15745
16095
  intersection(items, schemas, parentSchema, ctx) {
15746
- const z = ctx.plugin.external("zod.z");
15747
16096
  const hasAnyLazy = items.some((item) => item.meta.hasLazy);
15748
- const firstSchema = schemas[0];
15749
- let expression;
15750
- if (firstSchema?.logicalOperator === "or" || firstSchema?.type && firstSchema.type !== "object") expression = $(z).attr(identifiers.intersection).call(...items.map((item) => item.expression));
15751
- else {
15752
- expression = items[0].expression;
15753
- items.slice(1).forEach((item) => {
15754
- expression = expression.attr(identifiers.and).call(item.meta.hasLazy ? $(z).attr(identifiers.lazy).call($.func().do(item.expression.return())) : item.expression);
15755
- });
15756
- }
16097
+ const { expression } = intersectionToAst({
16098
+ childResults: items,
16099
+ parentSchema,
16100
+ plugin: ctx.plugin,
16101
+ schemas
16102
+ });
15757
16103
  return {
15758
16104
  expression,
15759
16105
  meta: {
@@ -15906,18 +16252,14 @@ function createVisitor(config = {}) {
15906
16252
  };
15907
16253
  },
15908
16254
  union(items, schemas, parentSchema, ctx) {
15909
- const z = ctx.plugin.external("zod.z");
15910
16255
  const hasAnyLazy = items.some((item) => item.meta.hasLazy);
15911
16256
  const hasNull = schemas.some((s) => s.type === "null") || items.some((i) => i.meta.nullable);
15912
- const nonNullItems = [];
15913
- items.forEach((item, index) => {
15914
- const schema = schemas[index];
15915
- if (schema.type !== "null" && schema.const !== null) nonNullItems.push(item);
16257
+ const { expression } = unionToAst({
16258
+ childResults: items,
16259
+ parentSchema,
16260
+ plugin: ctx.plugin,
16261
+ schemas
15916
16262
  });
15917
- let expression;
15918
- if (!nonNullItems.length) expression = $(z).attr(identifiers.null).call();
15919
- else if (nonNullItems.length === 1) expression = nonNullItems[0].expression;
15920
- else expression = $(z).attr(identifiers.union).call($.array().pretty().elements(...nonNullItems.map((item) => item.expression)));
15921
16263
  return {
15922
16264
  expression,
15923
16265
  meta: {
@@ -16125,10 +16467,20 @@ const defaultConfig = {
16125
16467
  value: plugin.config.dates
16126
16468
  });
16127
16469
  plugin.config.types = context.valueToObject({
16128
- defaultValue: { infer: {
16129
- case: "PascalCase",
16130
- enabled: false
16131
- } },
16470
+ defaultValue: {
16471
+ infer: {
16472
+ case: "PascalCase",
16473
+ enabled: false
16474
+ },
16475
+ input: {
16476
+ case: "PascalCase",
16477
+ enabled: false
16478
+ },
16479
+ output: {
16480
+ case: "PascalCase",
16481
+ enabled: false
16482
+ }
16483
+ },
16132
16484
  mappers: { object: (fields, defaultValue) => ({
16133
16485
  ...fields,
16134
16486
  infer: context.valueToObject({
@@ -16138,6 +16490,22 @@ const defaultConfig = {
16138
16490
  },
16139
16491
  mappers,
16140
16492
  value: fields.infer
16493
+ }),
16494
+ input: context.valueToObject({
16495
+ defaultValue: {
16496
+ ...defaultValue.input,
16497
+ enabled: fields.input !== void 0 ? Boolean(fields.input) : defaultValue.input.enabled
16498
+ },
16499
+ mappers,
16500
+ value: fields.input
16501
+ }),
16502
+ output: context.valueToObject({
16503
+ defaultValue: {
16504
+ ...defaultValue.output,
16505
+ enabled: fields.output !== void 0 ? Boolean(fields.output) : defaultValue.output.enabled
16506
+ },
16507
+ mappers,
16508
+ value: fields.output
16141
16509
  })
16142
16510
  }) },
16143
16511
  value: plugin.config.types
@@ -16152,6 +16520,14 @@ const defaultConfig = {
16152
16520
  infer: {
16153
16521
  ...plugin.config.types.infer,
16154
16522
  name: "{{name}}ZodType"
16523
+ },
16524
+ input: {
16525
+ ...plugin.config.types.input,
16526
+ name: "{{name}}ZodInput"
16527
+ },
16528
+ output: {
16529
+ ...plugin.config.types.output,
16530
+ name: "{{name}}ZodOutput"
16155
16531
  }
16156
16532
  }
16157
16533
  },
@@ -16170,6 +16546,22 @@ const defaultConfig = {
16170
16546
  },
16171
16547
  mappers,
16172
16548
  value: fields.infer
16549
+ }),
16550
+ input: context.valueToObject({
16551
+ defaultValue: {
16552
+ ...defaultValue.input,
16553
+ enabled: fields.input !== void 0 ? Boolean(fields.input) : defaultValue.input.enabled
16554
+ },
16555
+ mappers,
16556
+ value: fields.input
16557
+ }),
16558
+ output: context.valueToObject({
16559
+ defaultValue: {
16560
+ ...defaultValue.output,
16561
+ enabled: fields.output !== void 0 ? Boolean(fields.output) : defaultValue.output.enabled
16562
+ },
16563
+ mappers,
16564
+ value: fields.output
16173
16565
  })
16174
16566
  }) },
16175
16567
  value: fields.types
@@ -16189,6 +16581,14 @@ const defaultConfig = {
16189
16581
  infer: {
16190
16582
  ...plugin.config.types.infer,
16191
16583
  name: "{{name}}BodyZodType"
16584
+ },
16585
+ input: {
16586
+ ...plugin.config.types.input,
16587
+ name: "{{name}}BodyZodInput"
16588
+ },
16589
+ output: {
16590
+ ...plugin.config.types.output,
16591
+ name: "{{name}}BodyZodOutput"
16192
16592
  }
16193
16593
  }
16194
16594
  },
@@ -16203,6 +16603,14 @@ const defaultConfig = {
16203
16603
  infer: {
16204
16604
  ...plugin.config.types.infer,
16205
16605
  name: "{{name}}HeadersZodType"
16606
+ },
16607
+ input: {
16608
+ ...plugin.config.types.input,
16609
+ name: "{{name}}HeadersZodInput"
16610
+ },
16611
+ output: {
16612
+ ...plugin.config.types.output,
16613
+ name: "{{name}}HeadersZodOutput"
16206
16614
  }
16207
16615
  }
16208
16616
  },
@@ -16216,6 +16624,14 @@ const defaultConfig = {
16216
16624
  infer: {
16217
16625
  ...plugin.config.types.infer,
16218
16626
  name: "{{name}}PathZodType"
16627
+ },
16628
+ input: {
16629
+ ...plugin.config.types.input,
16630
+ name: "{{name}}PathZodInput"
16631
+ },
16632
+ output: {
16633
+ ...plugin.config.types.output,
16634
+ name: "{{name}}PathZodOutput"
16219
16635
  }
16220
16636
  }
16221
16637
  },
@@ -16228,6 +16644,14 @@ const defaultConfig = {
16228
16644
  infer: {
16229
16645
  ...plugin.config.types.infer,
16230
16646
  name: "{{name}}QueryZodType"
16647
+ },
16648
+ input: {
16649
+ ...plugin.config.types.input,
16650
+ name: "{{name}}QueryZodInput"
16651
+ },
16652
+ output: {
16653
+ ...plugin.config.types.output,
16654
+ name: "{{name}}QueryZodOutput"
16231
16655
  }
16232
16656
  }
16233
16657
  },
@@ -16237,6 +16661,14 @@ const defaultConfig = {
16237
16661
  infer: {
16238
16662
  ...plugin.config.types.infer,
16239
16663
  name: "{{name}}DataZodType"
16664
+ },
16665
+ input: {
16666
+ ...plugin.config.types.input,
16667
+ name: "{{name}}DataZodInput"
16668
+ },
16669
+ output: {
16670
+ ...plugin.config.types.output,
16671
+ name: "{{name}}DataZodOutput"
16240
16672
  }
16241
16673
  }
16242
16674
  },
@@ -16261,6 +16693,22 @@ const defaultConfig = {
16261
16693
  },
16262
16694
  mappers,
16263
16695
  value: fields.infer
16696
+ }),
16697
+ input: context.valueToObject({
16698
+ defaultValue: {
16699
+ ...defaultValue.input,
16700
+ enabled: fields.input !== void 0 ? Boolean(fields.input) : defaultValue.input.enabled
16701
+ },
16702
+ mappers,
16703
+ value: fields.input
16704
+ }),
16705
+ output: context.valueToObject({
16706
+ defaultValue: {
16707
+ ...defaultValue.output,
16708
+ enabled: fields.output !== void 0 ? Boolean(fields.output) : defaultValue.output.enabled
16709
+ },
16710
+ mappers,
16711
+ value: fields.output
16264
16712
  })
16265
16713
  }) },
16266
16714
  value: fields.types
@@ -16286,6 +16734,22 @@ const defaultConfig = {
16286
16734
  },
16287
16735
  mappers,
16288
16736
  value: fields.infer
16737
+ }),
16738
+ input: context.valueToObject({
16739
+ defaultValue: {
16740
+ ...defaultValue.input,
16741
+ enabled: fields.input !== void 0 ? Boolean(fields.input) : defaultValue.input.enabled
16742
+ },
16743
+ mappers,
16744
+ value: fields.input
16745
+ }),
16746
+ output: context.valueToObject({
16747
+ defaultValue: {
16748
+ ...defaultValue.output,
16749
+ enabled: fields.output !== void 0 ? Boolean(fields.output) : defaultValue.output.enabled
16750
+ },
16751
+ mappers,
16752
+ value: fields.output
16289
16753
  })
16290
16754
  }) },
16291
16755
  value: fields.types
@@ -16311,6 +16775,22 @@ const defaultConfig = {
16311
16775
  },
16312
16776
  mappers,
16313
16777
  value: fields.infer
16778
+ }),
16779
+ input: context.valueToObject({
16780
+ defaultValue: {
16781
+ ...defaultValue.input,
16782
+ enabled: fields.input !== void 0 ? Boolean(fields.input) : defaultValue.input.enabled
16783
+ },
16784
+ mappers,
16785
+ value: fields.input
16786
+ }),
16787
+ output: context.valueToObject({
16788
+ defaultValue: {
16789
+ ...defaultValue.output,
16790
+ enabled: fields.output !== void 0 ? Boolean(fields.output) : defaultValue.output.enabled
16791
+ },
16792
+ mappers,
16793
+ value: fields.output
16314
16794
  })
16315
16795
  }) },
16316
16796
  value: fields.types
@@ -16336,6 +16816,22 @@ const defaultConfig = {
16336
16816
  },
16337
16817
  mappers,
16338
16818
  value: fields.infer
16819
+ }),
16820
+ input: context.valueToObject({
16821
+ defaultValue: {
16822
+ ...defaultValue.input,
16823
+ enabled: fields.input !== void 0 ? Boolean(fields.input) : defaultValue.input.enabled
16824
+ },
16825
+ mappers,
16826
+ value: fields.input
16827
+ }),
16828
+ output: context.valueToObject({
16829
+ defaultValue: {
16830
+ ...defaultValue.output,
16831
+ enabled: fields.output !== void 0 ? Boolean(fields.output) : defaultValue.output.enabled
16832
+ },
16833
+ mappers,
16834
+ value: fields.output
16339
16835
  })
16340
16836
  }) },
16341
16837
  value: fields.types
@@ -16356,6 +16852,22 @@ const defaultConfig = {
16356
16852
  },
16357
16853
  mappers,
16358
16854
  value: fields.infer
16855
+ }),
16856
+ input: context.valueToObject({
16857
+ defaultValue: {
16858
+ ...defaultValue.input,
16859
+ enabled: fields.input !== void 0 ? Boolean(fields.input) : defaultValue.input.enabled
16860
+ },
16861
+ mappers,
16862
+ value: fields.input
16863
+ }),
16864
+ output: context.valueToObject({
16865
+ defaultValue: {
16866
+ ...defaultValue.output,
16867
+ enabled: fields.output !== void 0 ? Boolean(fields.output) : defaultValue.output.enabled
16868
+ },
16869
+ mappers,
16870
+ value: fields.output
16359
16871
  })
16360
16872
  }) },
16361
16873
  value: fields.types
@@ -16374,6 +16886,14 @@ const defaultConfig = {
16374
16886
  infer: {
16375
16887
  ...plugin.config.types.infer,
16376
16888
  name: "{{name}}ResponseZodType"
16889
+ },
16890
+ input: {
16891
+ ...plugin.config.types.input,
16892
+ name: "{{name}}ResponseZodInput"
16893
+ },
16894
+ output: {
16895
+ ...plugin.config.types.output,
16896
+ name: "{{name}}ResponseZodOutput"
16377
16897
  }
16378
16898
  }
16379
16899
  },
@@ -16392,6 +16912,22 @@ const defaultConfig = {
16392
16912
  },
16393
16913
  mappers,
16394
16914
  value: fields.infer
16915
+ }),
16916
+ input: context.valueToObject({
16917
+ defaultValue: {
16918
+ ...defaultValue.input,
16919
+ enabled: fields.input !== void 0 ? Boolean(fields.input) : defaultValue.input.enabled
16920
+ },
16921
+ mappers,
16922
+ value: fields.input
16923
+ }),
16924
+ output: context.valueToObject({
16925
+ defaultValue: {
16926
+ ...defaultValue.output,
16927
+ enabled: fields.output !== void 0 ? Boolean(fields.output) : defaultValue.output.enabled
16928
+ },
16929
+ mappers,
16930
+ value: fields.output
16395
16931
  })
16396
16932
  }) },
16397
16933
  value: fields.types
@@ -16410,6 +16946,14 @@ const defaultConfig = {
16410
16946
  infer: {
16411
16947
  ...plugin.config.types.infer,
16412
16948
  name: "{{name}}WebhookRequestZodType"
16949
+ },
16950
+ input: {
16951
+ ...plugin.config.types.input,
16952
+ name: "{{name}}WebhookRequestZodInput"
16953
+ },
16954
+ output: {
16955
+ ...plugin.config.types.output,
16956
+ name: "{{name}}WebhookRequestZodOutput"
16413
16957
  }
16414
16958
  }
16415
16959
  },
@@ -16428,6 +16972,22 @@ const defaultConfig = {
16428
16972
  },
16429
16973
  mappers,
16430
16974
  value: fields.infer
16975
+ }),
16976
+ input: context.valueToObject({
16977
+ defaultValue: {
16978
+ ...defaultValue.input,
16979
+ enabled: fields.input !== void 0 ? Boolean(fields.input) : defaultValue.input.enabled
16980
+ },
16981
+ mappers,
16982
+ value: fields.input
16983
+ }),
16984
+ output: context.valueToObject({
16985
+ defaultValue: {
16986
+ ...defaultValue.output,
16987
+ enabled: fields.output !== void 0 ? Boolean(fields.output) : defaultValue.output.enabled
16988
+ },
16989
+ mappers,
16990
+ value: fields.output
16431
16991
  })
16432
16992
  }) },
16433
16993
  value: fields.types
@@ -16539,6 +17099,7 @@ function getPlugins({ dependencies, userConfig }) {
16539
17099
  if (userConfig.plugins.length === 1 && isPluginClient(userConfig.plugins[0])) definedPlugins = [...defaultPlugins, ...userConfig.plugins];
16540
17100
  else definedPlugins = userConfig.plugins;
16541
17101
  }
17102
+ warnOnConflictingDuplicatePlugins(definedPlugins);
16542
17103
  return getPluginsConfig({
16543
17104
  dependencies,
16544
17105
  userPlugins: definedPlugins.map((plugin) => {
@@ -16647,4 +17208,4 @@ async function resolveJobs({ logger, userConfigs }) {
16647
17208
  //#endregion
16648
17209
  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 };
16649
17210
 
16650
- //# sourceMappingURL=init-CXAVfp7x.mjs.map
17211
+ //# sourceMappingURL=init-D4xuNKgu.mjs.map