@hey-api/openapi-ts 0.97.2 → 0.97.3

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.
@@ -6399,6 +6399,13 @@ const dateExpressions = ({ dataExpression, schema }) => {
6399
6399
  if (typeof dataExpression === "string") return [$.return($.new("Date").arg(dataExpression))];
6400
6400
  if (dataExpression) return [$(dataExpression).assign($.new("Date").arg(dataExpression))];
6401
6401
  };
6402
+ const temporalExpressions = ({ dataExpression, plugin, schema }) => {
6403
+ if (schema.type !== "string" || !(schema.format === "date" || schema.format === "date-time")) return;
6404
+ const temporal = plugin.symbolOnce("Temporal", { external: "temporal-polyfill" });
6405
+ const memberName = schema.format === "date" ? "PlainDate" : "Instant";
6406
+ if (typeof dataExpression === "string") return [$.return($(temporal).attr(memberName).attr("from").call(dataExpression))];
6407
+ if (dataExpression) return [$(dataExpression).assign($(temporal).attr(memberName).attr("from").call(dataExpression))];
6408
+ };
6402
6409
  //#endregion
6403
6410
  //#region src/plugins/@hey-api/transformers/plugin.ts
6404
6411
  const dataVariableName = "data";
@@ -6602,7 +6609,10 @@ const defaultConfig$15 = {
6602
6609
  name: "@hey-api/transformers",
6603
6610
  resolveConfig: (plugin) => {
6604
6611
  if (!plugin.config.transformers) plugin.config.transformers = [];
6605
- if (plugin.config.dates) plugin.config.transformers = [...plugin.config.transformers, dateExpressions];
6612
+ if (plugin.config.dates) {
6613
+ const dateTransformer = plugin.config.dates === "temporal" ? temporalExpressions : dateExpressions;
6614
+ plugin.config.transformers = [...plugin.config.transformers, dateTransformer];
6615
+ }
6606
6616
  if (plugin.config.bigInt) plugin.config.transformers = [...plugin.config.transformers, bigIntExpressions];
6607
6617
  },
6608
6618
  tags: ["transformer"]
@@ -6805,14 +6815,14 @@ function baseNode$69(ctx) {
6805
6815
  function arrayResolver$4(ctx) {
6806
6816
  return ctx.nodes.base(ctx);
6807
6817
  }
6808
- function arrayToAst$3({ plugin, schema, walk, walkerCtx }) {
6818
+ function arrayToAst$3({ path, plugin, schema, walk }) {
6809
6819
  const ctx = {
6810
6820
  $,
6811
6821
  nodes: { base: baseNode$69 },
6822
+ path,
6812
6823
  plugin,
6813
6824
  schema,
6814
- walk,
6815
- walkerCtx
6825
+ walk
6816
6826
  };
6817
6827
  const resolver = plugin.config["~resolvers"]?.array;
6818
6828
  return resolver?.(ctx) ?? arrayResolver$4(ctx);
@@ -6831,13 +6841,14 @@ function booleanResolver$4(ctx) {
6831
6841
  if (constResult) return constResult;
6832
6842
  return ctx.nodes.base(ctx);
6833
6843
  }
6834
- function booleanToAst$3({ plugin, schema }) {
6844
+ function booleanToAst$3({ path, plugin, schema }) {
6835
6845
  const ctx = {
6836
6846
  $,
6837
6847
  nodes: {
6838
6848
  base: baseNode$68,
6839
6849
  const: constNode$19
6840
6850
  },
6851
+ path,
6841
6852
  plugin,
6842
6853
  schema
6843
6854
  };
@@ -6890,7 +6901,7 @@ function baseNode$67(ctx) {
6890
6901
  function enumResolver$4(ctx) {
6891
6902
  return ctx.nodes.base(ctx);
6892
6903
  }
6893
- function enumToAst$3({ plugin, schema }) {
6904
+ function enumToAst$3({ path, plugin, schema }) {
6894
6905
  const enumData = buildEnumData(plugin, schema);
6895
6906
  const ctx = {
6896
6907
  $,
@@ -6898,6 +6909,7 @@ function enumToAst$3({ plugin, schema }) {
6898
6909
  base: baseNode$67,
6899
6910
  items: itemsNode$4
6900
6911
  },
6912
+ path,
6901
6913
  plugin,
6902
6914
  schema
6903
6915
  };
@@ -6917,12 +6929,13 @@ function baseNode$66(ctx) {
6917
6929
  function intersectionResolver$4(ctx) {
6918
6930
  return ctx.nodes.base(ctx);
6919
6931
  }
6920
- function intersectionToAst$3({ childResults, parentSchema, plugin, schemas }) {
6932
+ function intersectionToAst$3({ childResults, parentSchema, path, plugin, schemas }) {
6921
6933
  const ctx = {
6922
6934
  $,
6923
6935
  childResults,
6924
6936
  nodes: { base: baseNode$66 },
6925
6937
  parentSchema,
6938
+ path,
6926
6939
  plugin,
6927
6940
  schemas
6928
6941
  };
@@ -6937,10 +6950,11 @@ function baseNode$65() {
6937
6950
  function neverResolver$4(ctx) {
6938
6951
  return ctx.nodes.base(ctx);
6939
6952
  }
6940
- function neverToAst$3({ plugin, schema }) {
6953
+ function neverToAst$3({ path, plugin, schema }) {
6941
6954
  const ctx = {
6942
6955
  $,
6943
6956
  nodes: { base: baseNode$65 },
6957
+ path,
6944
6958
  plugin,
6945
6959
  schema
6946
6960
  };
@@ -6955,10 +6969,11 @@ function baseNode$64() {
6955
6969
  function nullResolver$4(ctx) {
6956
6970
  return ctx.nodes.base(ctx);
6957
6971
  }
6958
- function nullToAst$4({ plugin, schema }) {
6972
+ function nullToAst$4({ path, plugin, schema }) {
6959
6973
  const ctx = {
6960
6974
  $,
6961
6975
  nodes: { base: baseNode$64 },
6976
+ path,
6962
6977
  plugin,
6963
6978
  schema
6964
6979
  };
@@ -6983,13 +6998,14 @@ function numberResolver$4(ctx) {
6983
6998
  if (constResult) return constResult;
6984
6999
  return ctx.nodes.base(ctx);
6985
7000
  }
6986
- function numberToAst({ plugin, schema }) {
7001
+ function numberToAst({ path, plugin, schema }) {
6987
7002
  const ctx = {
6988
7003
  $,
6989
7004
  nodes: {
6990
7005
  base: baseNode$63,
6991
7006
  const: constNode$18
6992
7007
  },
7008
+ path,
6993
7009
  plugin,
6994
7010
  schema
6995
7011
  };
@@ -6999,22 +7015,22 @@ function numberToAst({ plugin, schema }) {
6999
7015
  //#endregion
7000
7016
  //#region src/plugins/@hey-api/typescript/v1/toAst/object.ts
7001
7017
  function shapeNode$4(ctx) {
7002
- const { schema, walk, walkerCtx } = ctx;
7018
+ const { plugin, schema, walk } = ctx;
7003
7019
  const shape = $.type.object();
7004
7020
  const required = schema.required ?? [];
7005
7021
  for (const name in schema.properties) {
7006
7022
  const property = schema.properties[name];
7007
7023
  const propertyResult = walk(property, {
7008
7024
  path: ref([]),
7009
- plugin: walkerCtx.plugin
7025
+ plugin
7010
7026
  });
7011
7027
  const isRequired = required.includes(name);
7012
- shape.prop(name, (p) => p.$if(walkerCtx.plugin.config.comments && createSchemaComment(property), (p, v) => p.doc(v)).readonly(property.accessScope === "read").required(isRequired).type(propertyResult.type));
7028
+ shape.prop(name, (p) => p.$if(plugin.config.comments && createSchemaComment(property), (p, v) => p.doc(v)).readonly(property.accessScope === "read").required(isRequired).type(propertyResult.type));
7013
7029
  }
7014
7030
  return shape;
7015
7031
  }
7016
7032
  function baseNode$62(ctx) {
7017
- const { schema, walk, walkerCtx } = ctx;
7033
+ const { plugin, schema, walk } = ctx;
7018
7034
  const shape = shapeNode$4(ctx);
7019
7035
  const required = schema.required ?? [];
7020
7036
  let indexSchemas = [];
@@ -7044,12 +7060,12 @@ function baseNode$62(ctx) {
7044
7060
  logicalOperator: "or"
7045
7061
  } }), {
7046
7062
  path: ref([]),
7047
- plugin: walkerCtx.plugin
7063
+ plugin
7048
7064
  }).type;
7049
7065
  if (schema.propertyNames?.$ref) {
7050
7066
  const propertyNamesResult = walk({ $ref: schema.propertyNames.$ref }, {
7051
7067
  path: ref([]),
7052
- plugin: walkerCtx.plugin
7068
+ plugin
7053
7069
  });
7054
7070
  return $.type.mapped("key").key(propertyNamesResult.type).optional().type(indexType);
7055
7071
  }
@@ -7061,17 +7077,17 @@ function baseNode$62(ctx) {
7061
7077
  function objectResolver$4(ctx) {
7062
7078
  return ctx.nodes.base(ctx);
7063
7079
  }
7064
- function objectToAst$4({ plugin, schema, walk, walkerCtx }) {
7080
+ function objectToAst$4({ path, plugin, schema, walk }) {
7065
7081
  const ctx = {
7066
7082
  $,
7067
7083
  nodes: {
7068
7084
  base: baseNode$62,
7069
7085
  shape: shapeNode$4
7070
7086
  },
7087
+ path,
7071
7088
  plugin,
7072
7089
  schema,
7073
- walk,
7074
- walkerCtx
7090
+ walk
7075
7091
  };
7076
7092
  const resolver = plugin.config["~resolvers"]?.object;
7077
7093
  return resolver?.(ctx) ?? objectResolver$4(ctx);
@@ -7088,7 +7104,14 @@ function formatNode$4(ctx) {
7088
7104
  if (!format) return;
7089
7105
  if (format === "binary") return $.type.or($.type("Blob"), $.type("File"));
7090
7106
  if (format === "date-time" || format === "date") {
7091
- if (plugin.getPlugin("@hey-api/transformers")?.config.dates) return $.type("Date");
7107
+ const dates = plugin.getPlugin("@hey-api/transformers")?.config.dates;
7108
+ if (dates) {
7109
+ if (dates === "temporal") {
7110
+ const temporal = plugin.symbolOnce("Temporal", { external: "temporal-polyfill" });
7111
+ return $.type(temporal).attr(format === "date" ? "PlainDate" : "Instant");
7112
+ }
7113
+ return $.type("Date");
7114
+ }
7092
7115
  }
7093
7116
  if (format === "typeid" && typeof schema.example === "string") {
7094
7117
  const parts = String(schema.example).split("_");
@@ -7132,7 +7155,7 @@ function stringResolver$4(ctx) {
7132
7155
  if (formatResult) return formatResult;
7133
7156
  return ctx.nodes.base(ctx);
7134
7157
  }
7135
- function stringToAst$1({ plugin, schema }) {
7158
+ function stringToAst$1({ path, plugin, schema }) {
7136
7159
  const ctx = {
7137
7160
  $,
7138
7161
  nodes: {
@@ -7140,6 +7163,7 @@ function stringToAst$1({ plugin, schema }) {
7140
7163
  const: constNode$17,
7141
7164
  format: formatNode$4
7142
7165
  },
7166
+ path,
7143
7167
  plugin,
7144
7168
  schema
7145
7169
  };
@@ -7171,17 +7195,17 @@ function tupleResolver$4(ctx) {
7171
7195
  if (constResult) return constResult;
7172
7196
  return ctx.nodes.base(ctx);
7173
7197
  }
7174
- function tupleToAst$3({ plugin, schema, walk, walkerCtx }) {
7198
+ function tupleToAst$3({ path, plugin, schema, walk }) {
7175
7199
  const ctx = {
7176
7200
  $,
7177
7201
  nodes: {
7178
7202
  base: baseNode$60,
7179
7203
  const: constNode$16
7180
7204
  },
7205
+ path,
7181
7206
  plugin,
7182
7207
  schema,
7183
- walk,
7184
- walkerCtx
7208
+ walk
7185
7209
  };
7186
7210
  const resolver = plugin.config["~resolvers"]?.tuple;
7187
7211
  return resolver?.(ctx) ?? tupleResolver$4(ctx);
@@ -7194,10 +7218,11 @@ function baseNode$59() {
7194
7218
  function undefinedResolver$4(ctx) {
7195
7219
  return ctx.nodes.base(ctx);
7196
7220
  }
7197
- function undefinedToAst$3({ plugin, schema }) {
7221
+ function undefinedToAst$3({ path, plugin, schema }) {
7198
7222
  const ctx = {
7199
7223
  $,
7200
7224
  nodes: { base: baseNode$59 },
7225
+ path,
7201
7226
  plugin,
7202
7227
  schema
7203
7228
  };
@@ -7214,12 +7239,13 @@ function baseNode$58(ctx) {
7214
7239
  function unionResolver$4(ctx) {
7215
7240
  return ctx.nodes.base(ctx);
7216
7241
  }
7217
- function unionToAst$3({ childResults, parentSchema, plugin, schemas }) {
7242
+ function unionToAst$3({ childResults, parentSchema, path, plugin, schemas }) {
7218
7243
  const ctx = {
7219
7244
  $,
7220
7245
  childResults,
7221
7246
  nodes: { base: baseNode$58 },
7222
7247
  parentSchema,
7248
+ path,
7223
7249
  plugin,
7224
7250
  schemas
7225
7251
  };
@@ -7234,10 +7260,11 @@ function baseNode$57(ctx) {
7234
7260
  function unknownResolver$4(ctx) {
7235
7261
  return ctx.nodes.base(ctx);
7236
7262
  }
7237
- function unknownToAst$3({ plugin, schema }) {
7263
+ function unknownToAst$3({ path, plugin, schema }) {
7238
7264
  const ctx = {
7239
7265
  $,
7240
7266
  nodes: { base: baseNode$57 },
7267
+ path,
7241
7268
  plugin,
7242
7269
  schema
7243
7270
  };
@@ -7252,10 +7279,11 @@ function baseNode$56() {
7252
7279
  function voidResolver$4(ctx) {
7253
7280
  return ctx.nodes.base(ctx);
7254
7281
  }
7255
- function voidToAst$3({ plugin, schema }) {
7282
+ function voidToAst$3({ path, plugin, schema }) {
7256
7283
  const ctx = {
7257
7284
  $,
7258
7285
  nodes: { base: baseNode$56 },
7286
+ path,
7259
7287
  plugin,
7260
7288
  schema
7261
7289
  };
@@ -7264,8 +7292,8 @@ function voidToAst$3({ plugin, schema }) {
7264
7292
  }
7265
7293
  //#endregion
7266
7294
  //#region src/plugins/@hey-api/typescript/v1/visitor.ts
7267
- function createVisitor$4(config = {}) {
7268
- const { schemaExtractor } = config;
7295
+ function createVisitor$4(config) {
7296
+ const { plugin, schemaExtractor } = config;
7269
7297
  return {
7270
7298
  applyModifiers(result) {
7271
7299
  return {
@@ -7275,10 +7303,10 @@ function createVisitor$4(config = {}) {
7275
7303
  },
7276
7304
  array(schema, ctx, walk) {
7277
7305
  const type = arrayToAst$3({
7278
- plugin: ctx.plugin,
7306
+ path: ctx.path,
7307
+ plugin,
7279
7308
  schema,
7280
- walk,
7281
- walkerCtx: ctx
7309
+ walk
7282
7310
  });
7283
7311
  return {
7284
7312
  meta: defaultMeta$2(schema),
@@ -7287,7 +7315,8 @@ function createVisitor$4(config = {}) {
7287
7315
  },
7288
7316
  boolean(schema, ctx) {
7289
7317
  const type = booleanToAst$3({
7290
- plugin: ctx.plugin,
7318
+ path: ctx.path,
7319
+ plugin,
7291
7320
  schema
7292
7321
  });
7293
7322
  return {
@@ -7297,7 +7326,8 @@ function createVisitor$4(config = {}) {
7297
7326
  },
7298
7327
  enum(schema, ctx) {
7299
7328
  const { enumData, type } = enumToAst$3({
7300
- plugin: ctx.plugin,
7329
+ path: ctx.path,
7330
+ plugin,
7301
7331
  schema
7302
7332
  });
7303
7333
  return {
@@ -7308,7 +7338,8 @@ function createVisitor$4(config = {}) {
7308
7338
  },
7309
7339
  integer(schema, ctx) {
7310
7340
  const type = numberToAst({
7311
- plugin: ctx.plugin,
7341
+ path: ctx.path,
7342
+ plugin,
7312
7343
  schema
7313
7344
  });
7314
7345
  return {
@@ -7323,14 +7354,14 @@ function createVisitor$4(config = {}) {
7323
7354
  resource: "definition",
7324
7355
  resourceId: pathToJsonPointer(fromRef(ctx.path))
7325
7356
  },
7326
- naming: ctx.plugin.config.definitions,
7357
+ naming: plugin.config.definitions,
7327
7358
  path: fromRef(ctx.path),
7328
- plugin: ctx.plugin,
7359
+ plugin,
7329
7360
  schema
7330
7361
  });
7331
7362
  if (extracted !== schema) return walk(extracted, ctx);
7332
7363
  }
7333
- const transformersPlugin = ctx.plugin.getPlugin("@hey-api/transformers");
7364
+ const transformersPlugin = plugin.getPlugin("@hey-api/transformers");
7334
7365
  if (transformersPlugin?.config.typeTransformers) for (const typeTransformer of transformersPlugin.config.typeTransformers) {
7335
7366
  const typeNode = typeTransformer({
7336
7367
  $,
@@ -7347,7 +7378,8 @@ function createVisitor$4(config = {}) {
7347
7378
  const type = intersectionToAst$3({
7348
7379
  childResults: items,
7349
7380
  parentSchema,
7350
- plugin: ctx.plugin,
7381
+ path: ctx.path,
7382
+ plugin,
7351
7383
  schemas
7352
7384
  });
7353
7385
  return {
@@ -7357,7 +7389,8 @@ function createVisitor$4(config = {}) {
7357
7389
  },
7358
7390
  never(schema, ctx) {
7359
7391
  const type = neverToAst$3({
7360
- plugin: ctx.plugin,
7392
+ path: ctx.path,
7393
+ plugin,
7361
7394
  schema
7362
7395
  });
7363
7396
  return {
@@ -7367,7 +7400,8 @@ function createVisitor$4(config = {}) {
7367
7400
  },
7368
7401
  null(schema, ctx) {
7369
7402
  const type = nullToAst$4({
7370
- plugin: ctx.plugin,
7403
+ path: ctx.path,
7404
+ plugin,
7371
7405
  schema
7372
7406
  });
7373
7407
  return {
@@ -7377,7 +7411,8 @@ function createVisitor$4(config = {}) {
7377
7411
  },
7378
7412
  number(schema, ctx) {
7379
7413
  const type = numberToAst({
7380
- plugin: ctx.plugin,
7414
+ path: ctx.path,
7415
+ plugin,
7381
7416
  schema
7382
7417
  });
7383
7418
  return {
@@ -7387,10 +7422,10 @@ function createVisitor$4(config = {}) {
7387
7422
  },
7388
7423
  object(schema, ctx, walk) {
7389
7424
  const type = objectToAst$4({
7390
- plugin: ctx.plugin,
7425
+ path: ctx.path,
7426
+ plugin,
7391
7427
  schema,
7392
- walk,
7393
- walkerCtx: ctx
7428
+ walk
7394
7429
  });
7395
7430
  return {
7396
7431
  meta: defaultMeta$2(schema),
@@ -7400,8 +7435,8 @@ function createVisitor$4(config = {}) {
7400
7435
  postProcess(result) {
7401
7436
  return result;
7402
7437
  },
7403
- reference($ref, schema, ctx) {
7404
- const symbol = ctx.plugin.referenceSymbol({
7438
+ reference($ref, schema) {
7439
+ const symbol = plugin.referenceSymbol({
7405
7440
  category: "type",
7406
7441
  resource: "definition",
7407
7442
  resourceId: $ref
@@ -7420,7 +7455,8 @@ function createVisitor$4(config = {}) {
7420
7455
  },
7421
7456
  string(schema, ctx) {
7422
7457
  const type = stringToAst$1({
7423
- plugin: ctx.plugin,
7458
+ path: ctx.path,
7459
+ plugin,
7424
7460
  schema
7425
7461
  });
7426
7462
  return {
@@ -7430,10 +7466,10 @@ function createVisitor$4(config = {}) {
7430
7466
  },
7431
7467
  tuple(schema, ctx, walk) {
7432
7468
  const type = tupleToAst$3({
7433
- plugin: ctx.plugin,
7469
+ path: ctx.path,
7470
+ plugin,
7434
7471
  schema,
7435
- walk,
7436
- walkerCtx: ctx
7472
+ walk
7437
7473
  });
7438
7474
  return {
7439
7475
  meta: defaultMeta$2(schema),
@@ -7442,7 +7478,8 @@ function createVisitor$4(config = {}) {
7442
7478
  },
7443
7479
  undefined(schema, ctx) {
7444
7480
  const type = undefinedToAst$3({
7445
- plugin: ctx.plugin,
7481
+ path: ctx.path,
7482
+ plugin,
7446
7483
  schema
7447
7484
  });
7448
7485
  return {
@@ -7454,7 +7491,8 @@ function createVisitor$4(config = {}) {
7454
7491
  const type = unionToAst$3({
7455
7492
  childResults: items,
7456
7493
  parentSchema,
7457
- plugin: ctx.plugin,
7494
+ path: ctx.path,
7495
+ plugin,
7458
7496
  schemas
7459
7497
  });
7460
7498
  return {
@@ -7464,7 +7502,8 @@ function createVisitor$4(config = {}) {
7464
7502
  },
7465
7503
  unknown(schema, ctx) {
7466
7504
  const type = unknownToAst$3({
7467
- plugin: ctx.plugin,
7505
+ path: ctx.path,
7506
+ plugin,
7468
7507
  schema
7469
7508
  });
7470
7509
  return {
@@ -7474,7 +7513,8 @@ function createVisitor$4(config = {}) {
7474
7513
  },
7475
7514
  void(schema, ctx) {
7476
7515
  const type = voidToAst$3({
7477
- plugin: ctx.plugin,
7516
+ path: ctx.path,
7517
+ plugin,
7478
7518
  schema
7479
7519
  });
7480
7520
  return {
@@ -7488,10 +7528,10 @@ function createVisitor$4(config = {}) {
7488
7528
  //#region src/plugins/@hey-api/typescript/v1/processor.ts
7489
7529
  function createProcessor$4(plugin) {
7490
7530
  const processor = createSchemaProcessor();
7491
- const extractorHooks = [plugin.config["~hooks"]?.schemas?.shouldExtract, plugin.context.config.parser.hooks.schemas?.shouldExtract];
7492
- function extractor(ctx) {
7531
+ const extractorHooks = plugin.getHooks((hooks) => hooks.schemas?.shouldExtract);
7532
+ const schemaExtractor = (ctx) => {
7493
7533
  if (processor.hasEmitted(ctx.path)) return ctx.schema;
7494
- for (const hook of extractorHooks) if (typeof hook === "boolean" ? hook : hook?.(ctx) ?? false) {
7534
+ for (const hook of extractorHooks) if (typeof hook === "boolean" ? hook : hook(ctx)) {
7495
7535
  process({
7496
7536
  namingAnchor: processor.context.anchor,
7497
7537
  tags: processor.context.tags,
@@ -7500,7 +7540,7 @@ function createProcessor$4(plugin) {
7500
7540
  return { $ref: pathToJsonPointer(ctx.path) };
7501
7541
  }
7502
7542
  return ctx.schema;
7503
- }
7543
+ };
7504
7544
  function process(ctx) {
7505
7545
  if (!processor.markEmitted(ctx.path)) return;
7506
7546
  const shouldExport = ctx.export !== false;
@@ -7508,7 +7548,10 @@ function createProcessor$4(plugin) {
7508
7548
  anchor: ctx.namingAnchor,
7509
7549
  tags: ctx.tags
7510
7550
  }, () => {
7511
- const visitor = createVisitor$4({ schemaExtractor: extractor });
7551
+ const visitor = createVisitor$4({
7552
+ plugin,
7553
+ schemaExtractor
7554
+ });
7512
7555
  const result = createSchemaWalker(visitor)(ctx.schema, {
7513
7556
  path: ref(ctx.path),
7514
7557
  plugin
@@ -8333,6 +8376,43 @@ const useTypeResponse = ({ operation, plugin }) => {
8333
8376
  return $.type(symbolResponseType ?? "unknown");
8334
8377
  };
8335
8378
  //#endregion
8379
+ //#region src/plugins/@tanstack/query-core/v5/getQueryData.ts
8380
+ function createGetQueryData({ operation, plugin }) {
8381
+ if (hasOperationSse({ operation })) return;
8382
+ const isRequiredOptions = isOperationOptionsRequired({
8383
+ context: plugin.context,
8384
+ operation
8385
+ });
8386
+ const symbolQueryOptionsFn = plugin.referenceSymbol({
8387
+ category: "hook",
8388
+ resource: "operation",
8389
+ resourceId: operation.id,
8390
+ role: "queryOptions",
8391
+ tool: plugin.name
8392
+ });
8393
+ const symbolQueryClient = plugin.referenceSymbol({ resource: `${plugin.name}.QueryClient` });
8394
+ const typeData = useTypeData({
8395
+ operation,
8396
+ plugin
8397
+ });
8398
+ const typeResponse = useTypeResponse({
8399
+ operation,
8400
+ plugin
8401
+ });
8402
+ const symbolGetQueryData = plugin.symbol(applyNaming(operation.id, plugin.config.getQueryData), { meta: {
8403
+ category: "hook",
8404
+ resource: "operation",
8405
+ resourceId: operation.id,
8406
+ role: "getQueryData",
8407
+ tool: plugin.name
8408
+ } });
8409
+ const queryClientParam = "queryClient";
8410
+ const optionsParam = "options";
8411
+ const optionsType = isRequiredOptions ? typeData : $.type.or(typeData, $.type("undefined"));
8412
+ const statement = $.const(symbolGetQueryData).export().$if(plugin.config.comments && createOperationComment(operation), (c, v) => c.doc(v)).assign($.func().param(queryClientParam, (p) => p.type($.type(symbolQueryClient))).param(optionsParam, (p) => p.type(optionsType)).do($(queryClientParam).attr("getQueryData").call($(symbolQueryOptionsFn).call(optionsParam).attr("queryKey")).generic(typeResponse).return()));
8413
+ plugin.node(statement);
8414
+ }
8415
+ //#endregion
8336
8416
  //#region src/plugins/@tanstack/query-core/queryKey.ts
8337
8417
  const TOptionsType$1 = "TOptions";
8338
8418
  function createQueryKeyFunction({ plugin }) {
@@ -8694,6 +8774,44 @@ function createSetQueryData({ operation, plugin }) {
8694
8774
  plugin.node(statement);
8695
8775
  }
8696
8776
  //#endregion
8777
+ //#region src/plugins/@tanstack/query-core/v5/useGetQueryData.ts
8778
+ function createUseGetQueryData({ operation, plugin }) {
8779
+ if (hasOperationSse({ operation })) return;
8780
+ if (!("useGetQueryData" in plugin.config)) return;
8781
+ const isRequiredOptions = isOperationOptionsRequired({
8782
+ context: plugin.context,
8783
+ operation
8784
+ });
8785
+ const symbolUseQueryClient = plugin.external(`${plugin.name}.useQueryClient`);
8786
+ const symbolQueryOptionsFn = plugin.referenceSymbol({
8787
+ category: "hook",
8788
+ resource: "operation",
8789
+ resourceId: operation.id,
8790
+ role: "queryOptions",
8791
+ tool: plugin.name
8792
+ });
8793
+ const typeData = useTypeData({
8794
+ operation,
8795
+ plugin
8796
+ });
8797
+ const typeResponse = useTypeResponse({
8798
+ operation,
8799
+ plugin
8800
+ });
8801
+ const symbolUseGetQueryData = plugin.symbol(applyNaming(operation.id, plugin.config.useGetQueryData), { meta: {
8802
+ category: "hook",
8803
+ resource: "operation",
8804
+ resourceId: operation.id,
8805
+ role: "useGetQueryData",
8806
+ tool: plugin.name
8807
+ } });
8808
+ const queryClientVar = "queryClient";
8809
+ const optionsParam = "options";
8810
+ const optionsType = isRequiredOptions ? typeData : $.type.or(typeData, $.type("undefined"));
8811
+ const statement = $.const(symbolUseGetQueryData).export().$if(plugin.config.comments && createOperationComment(operation), (c, v) => c.doc(v)).assign($.func().do($.const(queryClientVar).assign($(symbolUseQueryClient).call()), $.return($.func().param(optionsParam, (p) => p.type(optionsType)).do($(queryClientVar).attr("getQueryData").call($(symbolQueryOptionsFn).call(optionsParam).attr("queryKey")).generic(typeResponse).return()))));
8812
+ plugin.node(statement);
8813
+ }
8814
+ //#endregion
8697
8815
  //#region src/plugins/@tanstack/query-core/v5/useMutation.ts
8698
8816
  const mutationOptionsParamName = "mutationOptions";
8699
8817
  function createUseMutation({ operation, plugin }) {
@@ -8832,10 +8950,18 @@ const handlerV5 = ({ plugin }) => {
8832
8950
  operation,
8833
8951
  plugin
8834
8952
  });
8953
+ if (plugin.config.getQueryData.enabled) createGetQueryData({
8954
+ operation,
8955
+ plugin
8956
+ });
8835
8957
  if (plugin.config.setQueryData.enabled) createSetQueryData({
8836
8958
  operation,
8837
8959
  plugin
8838
8960
  });
8961
+ if ("useGetQueryData" in plugin.config && plugin.config.useGetQueryData.enabled) createUseGetQueryData({
8962
+ operation,
8963
+ plugin
8964
+ });
8839
8965
  if ("useQuery" in plugin.config && plugin.config.useQuery.enabled) createUseQuery({
8840
8966
  operation,
8841
8967
  plugin
@@ -8872,6 +8998,15 @@ const defaultConfig$12 = {
8872
8998
  handler: handler$7,
8873
8999
  name: "@tanstack/angular-query-experimental",
8874
9000
  resolveConfig: (plugin, context) => {
9001
+ plugin.config.getQueryData = context.valueToObject({
9002
+ defaultValue: {
9003
+ case: plugin.config.case ?? "camelCase",
9004
+ enabled: false,
9005
+ name: "{{name}}GetQueryData"
9006
+ },
9007
+ mappers,
9008
+ value: plugin.config.getQueryData
9009
+ });
8875
9010
  plugin.config.infiniteQueryKeys = context.valueToObject({
8876
9011
  defaultValue: {
8877
9012
  case: plugin.config.case ?? "camelCase",
@@ -8937,21 +9072,7 @@ const defaultConfig$12 = {
8937
9072
  enabled: false,
8938
9073
  name: "{{name}}SetQueryData"
8939
9074
  },
8940
- mappers: {
8941
- boolean: (enabled) => ({ enabled }),
8942
- function: (name) => ({
8943
- enabled: true,
8944
- name
8945
- }),
8946
- object: (fields) => ({
8947
- enabled: true,
8948
- ...fields
8949
- }),
8950
- string: (name) => ({
8951
- enabled: true,
8952
- name
8953
- })
8954
- },
9075
+ mappers,
8955
9076
  value: plugin.config.setQueryData
8956
9077
  });
8957
9078
  }
@@ -8969,6 +9090,15 @@ const defaultConfig$11 = {
8969
9090
  handler: handler$7,
8970
9091
  name: "@tanstack/preact-query",
8971
9092
  resolveConfig: (plugin, context) => {
9093
+ plugin.config.getQueryData = context.valueToObject({
9094
+ defaultValue: {
9095
+ case: plugin.config.case ?? "camelCase",
9096
+ enabled: false,
9097
+ name: "{{name}}GetQueryData"
9098
+ },
9099
+ mappers,
9100
+ value: plugin.config.getQueryData
9101
+ });
8972
9102
  plugin.config.infiniteQueryKeys = context.valueToObject({
8973
9103
  defaultValue: {
8974
9104
  case: plugin.config.case ?? "camelCase",
@@ -9034,44 +9164,25 @@ const defaultConfig$11 = {
9034
9164
  enabled: false,
9035
9165
  name: "{{name}}SetQueryData"
9036
9166
  },
9037
- mappers: {
9038
- boolean: (enabled) => ({ enabled }),
9039
- function: (name) => ({
9040
- enabled: true,
9041
- name
9042
- }),
9043
- object: (fields) => ({
9044
- enabled: true,
9045
- ...fields
9046
- }),
9047
- string: (name) => ({
9048
- enabled: true,
9049
- name
9050
- })
9051
- },
9167
+ mappers,
9052
9168
  value: plugin.config.setQueryData
9053
9169
  });
9170
+ plugin.config.useGetQueryData = context.valueToObject({
9171
+ defaultValue: {
9172
+ case: plugin.config.case ?? "camelCase",
9173
+ enabled: false,
9174
+ name: "use{{name}}GetQueryData"
9175
+ },
9176
+ mappers,
9177
+ value: plugin.config.useGetQueryData
9178
+ });
9054
9179
  plugin.config.useMutation = context.valueToObject({
9055
9180
  defaultValue: {
9056
9181
  case: plugin.config.case ?? "camelCase",
9057
9182
  enabled: false,
9058
9183
  name: "use{{name}}Mutation"
9059
9184
  },
9060
- mappers: {
9061
- boolean: (enabled) => ({ enabled }),
9062
- function: (name) => ({
9063
- enabled: true,
9064
- name
9065
- }),
9066
- object: (fields) => ({
9067
- enabled: true,
9068
- ...fields
9069
- }),
9070
- string: (name) => ({
9071
- enabled: true,
9072
- name
9073
- })
9074
- },
9185
+ mappers,
9075
9186
  value: plugin.config.useMutation
9076
9187
  });
9077
9188
  plugin.config.useQuery = context.valueToObject({
@@ -9080,21 +9191,7 @@ const defaultConfig$11 = {
9080
9191
  enabled: false,
9081
9192
  name: "use{{name}}Query"
9082
9193
  },
9083
- mappers: {
9084
- boolean: (enabled) => ({ enabled }),
9085
- function: (name) => ({
9086
- enabled: true,
9087
- name
9088
- }),
9089
- object: (fields) => ({
9090
- enabled: true,
9091
- ...fields
9092
- }),
9093
- string: (name) => ({
9094
- enabled: true,
9095
- name
9096
- })
9097
- },
9194
+ mappers,
9098
9195
  value: plugin.config.useQuery
9099
9196
  });
9100
9197
  plugin.config.useSetQueryData = context.valueToObject({
@@ -9103,21 +9200,7 @@ const defaultConfig$11 = {
9103
9200
  enabled: false,
9104
9201
  name: "use{{name}}SetQueryData"
9105
9202
  },
9106
- mappers: {
9107
- boolean: (enabled) => ({ enabled }),
9108
- function: (name) => ({
9109
- enabled: true,
9110
- name
9111
- }),
9112
- object: (fields) => ({
9113
- enabled: true,
9114
- ...fields
9115
- }),
9116
- string: (name) => ({
9117
- enabled: true,
9118
- name
9119
- })
9120
- },
9203
+ mappers,
9121
9204
  value: plugin.config.useSetQueryData
9122
9205
  });
9123
9206
  if (plugin.config.useMutation.enabled) {
@@ -9147,6 +9230,15 @@ const defaultConfig$10 = {
9147
9230
  handler: handler$7,
9148
9231
  name: "@tanstack/react-query",
9149
9232
  resolveConfig: (plugin, context) => {
9233
+ plugin.config.getQueryData = context.valueToObject({
9234
+ defaultValue: {
9235
+ case: plugin.config.case ?? "camelCase",
9236
+ enabled: false,
9237
+ name: "{{name}}GetQueryData"
9238
+ },
9239
+ mappers,
9240
+ value: plugin.config.getQueryData
9241
+ });
9150
9242
  plugin.config.infiniteQueryKeys = context.valueToObject({
9151
9243
  defaultValue: {
9152
9244
  case: plugin.config.case ?? "camelCase",
@@ -9212,44 +9304,25 @@ const defaultConfig$10 = {
9212
9304
  enabled: false,
9213
9305
  name: "{{name}}SetQueryData"
9214
9306
  },
9215
- mappers: {
9216
- boolean: (enabled) => ({ enabled }),
9217
- function: (name) => ({
9218
- enabled: true,
9219
- name
9220
- }),
9221
- object: (fields) => ({
9222
- enabled: true,
9223
- ...fields
9224
- }),
9225
- string: (name) => ({
9226
- enabled: true,
9227
- name
9228
- })
9229
- },
9307
+ mappers,
9230
9308
  value: plugin.config.setQueryData
9231
9309
  });
9310
+ plugin.config.useGetQueryData = context.valueToObject({
9311
+ defaultValue: {
9312
+ case: plugin.config.case ?? "camelCase",
9313
+ enabled: false,
9314
+ name: "use{{name}}GetQueryData"
9315
+ },
9316
+ mappers,
9317
+ value: plugin.config.useGetQueryData
9318
+ });
9232
9319
  plugin.config.useMutation = context.valueToObject({
9233
9320
  defaultValue: {
9234
9321
  case: plugin.config.case ?? "camelCase",
9235
9322
  enabled: false,
9236
9323
  name: "use{{name}}Mutation"
9237
9324
  },
9238
- mappers: {
9239
- boolean: (enabled) => ({ enabled }),
9240
- function: (name) => ({
9241
- enabled: true,
9242
- name
9243
- }),
9244
- object: (fields) => ({
9245
- enabled: true,
9246
- ...fields
9247
- }),
9248
- string: (name) => ({
9249
- enabled: true,
9250
- name
9251
- })
9252
- },
9325
+ mappers,
9253
9326
  value: plugin.config.useMutation
9254
9327
  });
9255
9328
  plugin.config.useQuery = context.valueToObject({
@@ -9258,21 +9331,7 @@ const defaultConfig$10 = {
9258
9331
  enabled: false,
9259
9332
  name: "use{{name}}Query"
9260
9333
  },
9261
- mappers: {
9262
- boolean: (enabled) => ({ enabled }),
9263
- function: (name) => ({
9264
- enabled: true,
9265
- name
9266
- }),
9267
- object: (fields) => ({
9268
- enabled: true,
9269
- ...fields
9270
- }),
9271
- string: (name) => ({
9272
- enabled: true,
9273
- name
9274
- })
9275
- },
9334
+ mappers,
9276
9335
  value: plugin.config.useQuery
9277
9336
  });
9278
9337
  plugin.config.useSetQueryData = context.valueToObject({
@@ -9281,21 +9340,7 @@ const defaultConfig$10 = {
9281
9340
  enabled: false,
9282
9341
  name: "use{{name}}SetQueryData"
9283
9342
  },
9284
- mappers: {
9285
- boolean: (enabled) => ({ enabled }),
9286
- function: (name) => ({
9287
- enabled: true,
9288
- name
9289
- }),
9290
- object: (fields) => ({
9291
- enabled: true,
9292
- ...fields
9293
- }),
9294
- string: (name) => ({
9295
- enabled: true,
9296
- name
9297
- })
9298
- },
9343
+ mappers,
9299
9344
  value: plugin.config.useSetQueryData
9300
9345
  });
9301
9346
  if (plugin.config.useMutation.enabled) {
@@ -9325,6 +9370,15 @@ const defaultConfig$9 = {
9325
9370
  handler: handler$7,
9326
9371
  name: "@tanstack/solid-query",
9327
9372
  resolveConfig: (plugin, context) => {
9373
+ plugin.config.getQueryData = context.valueToObject({
9374
+ defaultValue: {
9375
+ case: plugin.config.case ?? "camelCase",
9376
+ enabled: false,
9377
+ name: "{{name}}GetQueryData"
9378
+ },
9379
+ mappers,
9380
+ value: plugin.config.getQueryData
9381
+ });
9328
9382
  plugin.config.infiniteQueryKeys = context.valueToObject({
9329
9383
  defaultValue: {
9330
9384
  case: plugin.config.case ?? "camelCase",
@@ -9390,21 +9444,7 @@ const defaultConfig$9 = {
9390
9444
  enabled: false,
9391
9445
  name: "{{name}}SetQueryData"
9392
9446
  },
9393
- mappers: {
9394
- boolean: (enabled) => ({ enabled }),
9395
- function: (name) => ({
9396
- enabled: true,
9397
- name
9398
- }),
9399
- object: (fields) => ({
9400
- enabled: true,
9401
- ...fields
9402
- }),
9403
- string: (name) => ({
9404
- enabled: true,
9405
- name
9406
- })
9407
- },
9447
+ mappers,
9408
9448
  value: plugin.config.setQueryData
9409
9449
  });
9410
9450
  }
@@ -9422,6 +9462,15 @@ const defaultConfig$8 = {
9422
9462
  handler: handler$7,
9423
9463
  name: "@tanstack/svelte-query",
9424
9464
  resolveConfig: (plugin, context) => {
9465
+ plugin.config.getQueryData = context.valueToObject({
9466
+ defaultValue: {
9467
+ case: plugin.config.case ?? "camelCase",
9468
+ enabled: false,
9469
+ name: "{{name}}GetQueryData"
9470
+ },
9471
+ mappers,
9472
+ value: plugin.config.getQueryData
9473
+ });
9425
9474
  plugin.config.infiniteQueryKeys = context.valueToObject({
9426
9475
  defaultValue: {
9427
9476
  case: plugin.config.case ?? "camelCase",
@@ -9487,21 +9536,7 @@ const defaultConfig$8 = {
9487
9536
  enabled: false,
9488
9537
  name: "{{name}}SetQueryData"
9489
9538
  },
9490
- mappers: {
9491
- boolean: (enabled) => ({ enabled }),
9492
- function: (name) => ({
9493
- enabled: true,
9494
- name
9495
- }),
9496
- object: (fields) => ({
9497
- enabled: true,
9498
- ...fields
9499
- }),
9500
- string: (name) => ({
9501
- enabled: true,
9502
- name
9503
- })
9504
- },
9539
+ mappers,
9505
9540
  value: plugin.config.setQueryData
9506
9541
  });
9507
9542
  }
@@ -9519,6 +9554,15 @@ const defaultConfig$7 = {
9519
9554
  handler: handler$7,
9520
9555
  name: "@tanstack/vue-query",
9521
9556
  resolveConfig: (plugin, context) => {
9557
+ plugin.config.getQueryData = context.valueToObject({
9558
+ defaultValue: {
9559
+ case: plugin.config.case ?? "camelCase",
9560
+ enabled: false,
9561
+ name: "{{name}}GetQueryData"
9562
+ },
9563
+ mappers,
9564
+ value: plugin.config.getQueryData
9565
+ });
9522
9566
  plugin.config.infiniteQueryKeys = context.valueToObject({
9523
9567
  defaultValue: {
9524
9568
  case: plugin.config.case ?? "camelCase",
@@ -9584,21 +9628,7 @@ const defaultConfig$7 = {
9584
9628
  enabled: false,
9585
9629
  name: "{{name}}SetQueryData"
9586
9630
  },
9587
- mappers: {
9588
- boolean: (enabled) => ({ enabled }),
9589
- function: (name) => ({
9590
- enabled: true,
9591
- name
9592
- }),
9593
- object: (fields) => ({
9594
- enabled: true,
9595
- ...fields
9596
- }),
9597
- string: (name) => ({
9598
- enabled: true,
9599
- name
9600
- })
9601
- },
9631
+ mappers,
9602
9632
  value: plugin.config.setQueryData
9603
9633
  });
9604
9634
  }
@@ -10749,21 +10779,7 @@ const defaultConfig$2 = {
10749
10779
  enabled: true,
10750
10780
  name: "use{{name}}"
10751
10781
  },
10752
- mappers: {
10753
- boolean: (enabled) => ({ enabled }),
10754
- function: (name) => ({
10755
- enabled: true,
10756
- name
10757
- }),
10758
- object: (fields) => ({
10759
- enabled: true,
10760
- ...fields
10761
- }),
10762
- string: (name) => ({
10763
- enabled: true,
10764
- name
10765
- })
10766
- },
10782
+ mappers,
10767
10783
  value: plugin.config.useSwr
10768
10784
  });
10769
10785
  if (plugin.config.useSwr.enabled) {
@@ -11487,7 +11503,7 @@ function unknownResolver$3(ctx) {
11487
11503
  return ctx.pipes.current;
11488
11504
  }
11489
11505
  function unknownToPipes({ path, plugin, schema }) {
11490
- const ctx = {
11506
+ const resolverCtx = {
11491
11507
  $,
11492
11508
  nodes: { base: baseNode$55 },
11493
11509
  path,
@@ -11500,8 +11516,8 @@ function unknownToPipes({ path, plugin, schema }) {
11500
11516
  symbols: { v: plugin.external("valibot.v") }
11501
11517
  };
11502
11518
  const resolver = plugin.config["~resolvers"]?.unknown;
11503
- const node = resolver?.(ctx) ?? unknownResolver$3(ctx);
11504
- return ctx.pipes.toNode(node, plugin);
11519
+ const node = resolver?.(resolverCtx) ?? unknownResolver$3(resolverCtx);
11520
+ return resolverCtx.pipes.toNode(node, plugin);
11505
11521
  }
11506
11522
  //#endregion
11507
11523
  //#region src/plugins/valibot/v1/toAst/array.ts
@@ -11518,10 +11534,14 @@ function baseNode$54(ctx) {
11518
11534
  const childResults = [];
11519
11535
  for (let i = 0; i < normalizedSchema.items.length; i++) {
11520
11536
  const item = normalizedSchema.items[i];
11521
- const result = walk(item, childContext({
11522
- path,
11523
- plugin
11524
- }, "items", i));
11537
+ const result = walk(item, {
11538
+ path: ref([
11539
+ ...fromRef(ctx.path),
11540
+ "items",
11541
+ i
11542
+ ]),
11543
+ plugin: ctx.plugin
11544
+ });
11525
11545
  childResults.push(result);
11526
11546
  }
11527
11547
  if (childResults.length === 1) {
@@ -11570,10 +11590,14 @@ function arrayToPipes(ctx) {
11570
11590
  const normalizedSchema = deduplicateSchema({ schema });
11571
11591
  for (let i = 0; i < normalizedSchema.items.length; i++) {
11572
11592
  const item = normalizedSchema.items[i];
11573
- const result = walk(item, childContext({
11574
- path,
11575
- plugin
11576
- }, "items", i));
11593
+ const result = walk(item, {
11594
+ path: ref([
11595
+ ...fromRef(ctx.path),
11596
+ "items",
11597
+ i
11598
+ ]),
11599
+ plugin: ctx.plugin
11600
+ });
11577
11601
  childResults.push(result);
11578
11602
  }
11579
11603
  }
@@ -11624,7 +11648,7 @@ function booleanResolver$3(ctx) {
11624
11648
  return ctx.pipes.current;
11625
11649
  }
11626
11650
  function booleanToPipes({ path, plugin, schema }) {
11627
- const ctx = {
11651
+ const resolverCtx = {
11628
11652
  $,
11629
11653
  nodes: {
11630
11654
  base: baseNode$53,
@@ -11640,8 +11664,8 @@ function booleanToPipes({ path, plugin, schema }) {
11640
11664
  symbols: { v: plugin.external("valibot.v") }
11641
11665
  };
11642
11666
  const resolver = plugin.config["~resolvers"]?.boolean;
11643
- const node = resolver?.(ctx) ?? booleanResolver$3(ctx);
11644
- return ctx.pipes.toNode(node, plugin);
11667
+ const node = resolver?.(resolverCtx) ?? booleanResolver$3(resolverCtx);
11668
+ return resolverCtx.pipes.toNode(node, plugin);
11645
11669
  }
11646
11670
  //#endregion
11647
11671
  //#region src/plugins/valibot/v1/toAst/enum.ts
@@ -11683,7 +11707,7 @@ function enumResolver$3(ctx) {
11683
11707
  }
11684
11708
  function enumToPipes({ path, plugin, schema }) {
11685
11709
  const v = plugin.external("valibot.v");
11686
- const ctx = {
11710
+ const resolverCtx = {
11687
11711
  $,
11688
11712
  nodes: {
11689
11713
  base: baseNode$52,
@@ -11699,8 +11723,8 @@ function enumToPipes({ path, plugin, schema }) {
11699
11723
  symbols: { v }
11700
11724
  };
11701
11725
  const resolver = plugin.config["~resolvers"]?.enum;
11702
- const node = resolver?.(ctx) ?? enumResolver$3(ctx);
11703
- return ctx.pipes.toNode(node, plugin);
11726
+ const node = resolver?.(resolverCtx) ?? enumResolver$3(resolverCtx);
11727
+ return resolverCtx.pipes.toNode(node, plugin);
11704
11728
  }
11705
11729
  //#endregion
11706
11730
  //#region src/plugins/valibot/v1/toAst/intersection.ts
@@ -11753,7 +11777,7 @@ function neverResolver$3(ctx) {
11753
11777
  return ctx.pipes.current;
11754
11778
  }
11755
11779
  function neverToPipes({ path, plugin, schema }) {
11756
- const ctx = {
11780
+ const resolverCtx = {
11757
11781
  $,
11758
11782
  nodes: { base: baseNode$50 },
11759
11783
  path,
@@ -11766,8 +11790,8 @@ function neverToPipes({ path, plugin, schema }) {
11766
11790
  symbols: { v: plugin.external("valibot.v") }
11767
11791
  };
11768
11792
  const resolver = plugin.config["~resolvers"]?.never;
11769
- const node = resolver?.(ctx) ?? neverResolver$3(ctx);
11770
- return ctx.pipes.toNode(node, plugin);
11793
+ const node = resolver?.(resolverCtx) ?? neverResolver$3(resolverCtx);
11794
+ return resolverCtx.pipes.toNode(node, plugin);
11771
11795
  }
11772
11796
  //#endregion
11773
11797
  //#region src/plugins/valibot/v1/toAst/null.ts
@@ -11782,7 +11806,7 @@ function nullResolver$3(ctx) {
11782
11806
  return ctx.pipes.current;
11783
11807
  }
11784
11808
  function nullToPipes({ path, plugin, schema }) {
11785
- const ctx = {
11809
+ const resolverCtx = {
11786
11810
  $,
11787
11811
  nodes: { base: baseNode$49 },
11788
11812
  path,
@@ -11795,8 +11819,8 @@ function nullToPipes({ path, plugin, schema }) {
11795
11819
  symbols: { v: plugin.external("valibot.v") }
11796
11820
  };
11797
11821
  const resolver = plugin.config["~resolvers"]?.null;
11798
- const node = resolver?.(ctx) ?? nullResolver$3(ctx);
11799
- return ctx.pipes.toNode(node, plugin);
11822
+ const node = resolver?.(resolverCtx) ?? nullResolver$3(resolverCtx);
11823
+ return resolverCtx.pipes.toNode(node, plugin);
11800
11824
  }
11801
11825
  //#endregion
11802
11826
  //#region src/plugins/shared/utils/formats.ts
@@ -11870,7 +11894,7 @@ function numberResolver$3(ctx) {
11870
11894
  return ctx.pipes.current;
11871
11895
  }
11872
11896
  function numberToPipes({ path, plugin, schema }) {
11873
- const ctx = {
11897
+ const resolverCtx = {
11874
11898
  $,
11875
11899
  nodes: {
11876
11900
  base: baseNode$48,
@@ -11893,19 +11917,19 @@ function numberToPipes({ path, plugin, schema }) {
11893
11917
  }
11894
11918
  };
11895
11919
  const resolver = plugin.config["~resolvers"]?.number;
11896
- const node = resolver?.(ctx) ?? numberResolver$3(ctx);
11897
- return ctx.pipes.toNode(node, plugin);
11920
+ const node = resolver?.(resolverCtx) ?? numberResolver$3(resolverCtx);
11921
+ return resolverCtx.pipes.toNode(node, plugin);
11898
11922
  }
11899
11923
  //#endregion
11900
11924
  //#region src/plugins/valibot/v1/toAst/object.ts
11901
11925
  function additionalPropertiesNode$3(ctx) {
11902
- const { path, pipes, plugin, schema } = ctx;
11926
+ const { pipes, schema } = ctx;
11903
11927
  if (!schema.additionalProperties || !schema.additionalProperties.type) return;
11904
11928
  if (schema.additionalProperties.type === "never") return null;
11905
- const additionalResult = ctx.walk(schema.additionalProperties, childContext({
11906
- path,
11907
- plugin
11908
- }, "additionalProperties"));
11929
+ const additionalResult = ctx.walk(schema.additionalProperties, {
11930
+ path: ref([...fromRef(ctx.path), "additionalProperties"]),
11931
+ plugin: ctx.plugin
11932
+ });
11909
11933
  ctx._childResults.push(additionalResult);
11910
11934
  return pipes.toNode(additionalResult.pipes, ctx.plugin);
11911
11935
  }
@@ -11924,15 +11948,19 @@ function objectResolver$3(ctx) {
11924
11948
  return ctx.nodes.base(ctx);
11925
11949
  }
11926
11950
  function shapeNode$3(ctx) {
11927
- const { path, pipes, plugin, schema } = ctx;
11951
+ const { pipes, schema } = ctx;
11928
11952
  const shape = $.object().pretty();
11929
11953
  for (const name in schema.properties) {
11930
11954
  const property = schema.properties[name];
11931
11955
  const isOptional = !schema.required?.includes(name);
11932
- const propertyResult = ctx.walk(property, childContext({
11933
- path,
11934
- plugin
11935
- }, "properties", name));
11956
+ const propertyResult = ctx.walk(property, {
11957
+ path: ref([
11958
+ ...fromRef(ctx.path),
11959
+ "properties",
11960
+ name
11961
+ ]),
11962
+ plugin: ctx.plugin
11963
+ });
11936
11964
  ctx._childResults.push(propertyResult);
11937
11965
  const finalExpr = ctx.applyModifiers(propertyResult, { optional: isOptional });
11938
11966
  shape.prop(name, pipes.toNode(finalExpr.pipes, ctx.plugin));
@@ -12047,7 +12075,7 @@ function stringToPipes({ path, plugin, schema }) {
12047
12075
  type: "number"
12048
12076
  }
12049
12077
  });
12050
- const ctx = {
12078
+ const resolverCtx = {
12051
12079
  $,
12052
12080
  nodes: {
12053
12081
  base: baseNode$46,
@@ -12068,8 +12096,8 @@ function stringToPipes({ path, plugin, schema }) {
12068
12096
  symbols: { v: plugin.external("valibot.v") }
12069
12097
  };
12070
12098
  const resolver = plugin.config["~resolvers"]?.string;
12071
- const node = resolver?.(ctx) ?? stringResolver$3(ctx);
12072
- return ctx.pipes.toNode(node, plugin);
12099
+ const node = resolver?.(resolverCtx) ?? stringResolver$3(resolverCtx);
12100
+ return resolverCtx.pipes.toNode(node, plugin);
12073
12101
  }
12074
12102
  //#endregion
12075
12103
  //#region src/plugins/valibot/v1/toAst/tuple.ts
@@ -12083,10 +12111,14 @@ function baseNode$45(ctx) {
12083
12111
  const childResults = [];
12084
12112
  for (let i = 0; i < schema.items.length; i++) {
12085
12113
  const item = schema.items[i];
12086
- const result = walk(item, childContext({
12087
- path,
12088
- plugin
12089
- }, "items", i));
12114
+ const result = walk(item, {
12115
+ path: ref([
12116
+ ...fromRef(ctx.path),
12117
+ "items",
12118
+ i
12119
+ ]),
12120
+ plugin: ctx.plugin
12121
+ });
12090
12122
  childResults.push(result);
12091
12123
  }
12092
12124
  const tupleElements = childResults.map((r) => pipes.toNode(applyModifiers(r).pipes, plugin));
@@ -12111,10 +12143,14 @@ function tupleToPipes(ctx) {
12111
12143
  const childResults = [];
12112
12144
  if (schema.items) for (let i = 0; i < schema.items.length; i++) {
12113
12145
  const item = schema.items[i];
12114
- const result = walk(item, childContext({
12115
- path,
12116
- plugin
12117
- }, "items", i));
12146
+ const result = walk(item, {
12147
+ path: ref([
12148
+ ...fromRef(ctx.path),
12149
+ "items",
12150
+ i
12151
+ ]),
12152
+ plugin: ctx.plugin
12153
+ });
12118
12154
  childResults.push(result);
12119
12155
  }
12120
12156
  const resolverCtx = {
@@ -12154,7 +12190,7 @@ function undefinedResolver$3(ctx) {
12154
12190
  return ctx.pipes.current;
12155
12191
  }
12156
12192
  function undefinedToPipes({ path, plugin, schema }) {
12157
- const ctx = {
12193
+ const resolverCtx = {
12158
12194
  $,
12159
12195
  nodes: { base: baseNode$44 },
12160
12196
  path,
@@ -12167,8 +12203,8 @@ function undefinedToPipes({ path, plugin, schema }) {
12167
12203
  symbols: { v: plugin.external("valibot.v") }
12168
12204
  };
12169
12205
  const resolver = plugin.config["~resolvers"]?.undefined;
12170
- const node = resolver?.(ctx) ?? undefinedResolver$3(ctx);
12171
- return ctx.pipes.toNode(node, plugin);
12206
+ const node = resolver?.(resolverCtx) ?? undefinedResolver$3(resolverCtx);
12207
+ return resolverCtx.pipes.toNode(node, plugin);
12172
12208
  }
12173
12209
  //#endregion
12174
12210
  //#region src/plugins/valibot/shared/discriminated-union.ts
@@ -12249,7 +12285,7 @@ function voidResolver$3(ctx) {
12249
12285
  return ctx.pipes.current;
12250
12286
  }
12251
12287
  function voidToPipes({ path, plugin, schema }) {
12252
- const ctx = {
12288
+ const resolverCtx = {
12253
12289
  $,
12254
12290
  nodes: { base: baseNode$42 },
12255
12291
  path,
@@ -12262,44 +12298,67 @@ function voidToPipes({ path, plugin, schema }) {
12262
12298
  symbols: { v: plugin.external("valibot.v") }
12263
12299
  };
12264
12300
  const resolver = plugin.config["~resolvers"]?.void;
12265
- const node = resolver?.(ctx) ?? voidResolver$3(ctx);
12266
- return ctx.pipes.toNode(node, plugin);
12301
+ const node = resolver?.(resolverCtx) ?? voidResolver$3(resolverCtx);
12302
+ return resolverCtx.pipes.toNode(node, plugin);
12267
12303
  }
12268
12304
  //#endregion
12269
12305
  //#region src/plugins/valibot/v1/visitor.ts
12270
12306
  function getDefaultValue$3(meta) {
12271
12307
  return meta.format ? maybeBigInt(meta.default, meta.format) : $.fromValue(meta.default);
12272
12308
  }
12273
- function createVisitor$3(config = {}) {
12274
- const { schemaExtractor } = config;
12275
- return {
12276
- applyModifiers(result, ctx, options = {}) {
12277
- const { optional } = options;
12278
- const v = ctx.plugin.external("valibot.v");
12279
- const pipes = [...result.pipes];
12280
- if (result.meta.readonly) pipes.push($(v).attr(identifiers$1.actions.readonly).call());
12281
- const needsDefault = result.meta.default !== void 0;
12282
- const needsOptional = optional || needsDefault;
12283
- const needsNullable = result.meta.nullable;
12284
- const innerNode = pipesToNode(pipes, ctx.plugin);
12285
- let finalPipes;
12286
- if (needsOptional && needsNullable) if (needsDefault) finalPipes = [$(v).attr(identifiers$1.schemas.nullish).call(innerNode, getDefaultValue$3(result.meta))];
12287
- else finalPipes = [$(v).attr(identifiers$1.schemas.nullish).call(innerNode)];
12288
- else if (needsOptional) if (needsDefault) finalPipes = [$(v).attr(identifiers$1.schemas.optional).call(innerNode, getDefaultValue$3(result.meta))];
12289
- else finalPipes = [$(v).attr(identifiers$1.schemas.optional).call(innerNode)];
12290
- else if (needsNullable) finalPipes = [$(v).attr(identifiers$1.schemas.nullable).call(innerNode)];
12291
- else finalPipes = pipes;
12309
+ function createVisitor$3(config) {
12310
+ const { plugin, schemaExtractor } = config;
12311
+ const v = plugin.external("valibot.v");
12312
+ function applyModifiers(result, options = {}) {
12313
+ const pipes = [...result.pipes];
12314
+ if (result.meta.readonly) pipes.push($(v).attr(identifiers$1.actions.readonly).call());
12315
+ const typeName = result.meta.hasLazy ? identifiers$1.types.GenericSchema : void 0;
12316
+ const needsDefault = result.meta.default !== void 0;
12317
+ const needsOptional = options.optional || needsDefault;
12318
+ const needsNullable = result.meta.nullable;
12319
+ if (needsOptional && needsNullable) {
12320
+ const innerNode = pipesToNode(pipes, plugin);
12321
+ if (needsDefault) return {
12322
+ pipes: [$(v).attr(identifiers$1.schemas.nullish).call(innerNode, getDefaultValue$3(result.meta))],
12323
+ typeName
12324
+ };
12325
+ return {
12326
+ pipes: [$(v).attr(identifiers$1.schemas.nullish).call(innerNode)],
12327
+ typeName
12328
+ };
12329
+ }
12330
+ if (needsOptional) {
12331
+ const innerNode = pipesToNode(pipes, plugin);
12332
+ if (needsDefault) return {
12333
+ pipes: [$(v).attr(identifiers$1.schemas.optional).call(innerNode, getDefaultValue$3(result.meta))],
12334
+ typeName
12335
+ };
12336
+ return {
12337
+ pipes: [$(v).attr(identifiers$1.schemas.optional).call(innerNode)],
12338
+ typeName
12339
+ };
12340
+ }
12341
+ if (needsNullable) {
12342
+ const innerNode = pipesToNode(pipes, plugin);
12292
12343
  return {
12293
- pipes: finalPipes,
12294
- typeName: result.meta.hasLazy ? identifiers$1.types.GenericSchema : void 0
12344
+ pipes: [$(v).attr(identifiers$1.schemas.nullable).call(innerNode)],
12345
+ typeName
12295
12346
  };
12347
+ }
12348
+ return {
12349
+ pipes,
12350
+ typeName
12351
+ };
12352
+ }
12353
+ return {
12354
+ applyModifiers(result, ctx, opts) {
12355
+ return applyModifiers(result, opts);
12296
12356
  },
12297
12357
  array(schema, ctx, walk) {
12298
- const applyModifiers = (result, opts) => this.applyModifiers(result, ctx, opts);
12299
12358
  const { childResults, pipes } = arrayToPipes({
12300
12359
  applyModifiers,
12301
12360
  path: ctx.path,
12302
- plugin: ctx.plugin,
12361
+ plugin,
12303
12362
  schema,
12304
12363
  walk
12305
12364
  });
@@ -12311,7 +12370,7 @@ function createVisitor$3(config = {}) {
12311
12370
  boolean(schema, ctx) {
12312
12371
  const pipe = booleanToPipes({
12313
12372
  path: ctx.path,
12314
- plugin: ctx.plugin,
12373
+ plugin,
12315
12374
  schema
12316
12375
  });
12317
12376
  return {
@@ -12322,7 +12381,7 @@ function createVisitor$3(config = {}) {
12322
12381
  enum(schema, ctx) {
12323
12382
  const pipe = enumToPipes({
12324
12383
  path: ctx.path,
12325
- plugin: ctx.plugin,
12384
+ plugin,
12326
12385
  schema
12327
12386
  });
12328
12387
  const isNullable = schema.items?.some((item) => item.type === "null" || item.const === null) ?? false;
@@ -12337,7 +12396,7 @@ function createVisitor$3(config = {}) {
12337
12396
  integer(schema, ctx) {
12338
12397
  const pipe = numberToPipes({
12339
12398
  path: ctx.path,
12340
- plugin: ctx.plugin,
12399
+ plugin,
12341
12400
  schema
12342
12401
  });
12343
12402
  return {
@@ -12352,9 +12411,9 @@ function createVisitor$3(config = {}) {
12352
12411
  resource: "definition",
12353
12412
  resourceId: pathToJsonPointer(fromRef(ctx.path))
12354
12413
  },
12355
- naming: ctx.plugin.config.definitions,
12414
+ naming: plugin.config.definitions,
12356
12415
  path: fromRef(ctx.path),
12357
- plugin: ctx.plugin,
12416
+ plugin,
12358
12417
  schema
12359
12418
  });
12360
12419
  if (extracted !== schema) return walk(extracted, ctx);
@@ -12365,13 +12424,12 @@ function createVisitor$3(config = {}) {
12365
12424
  };
12366
12425
  },
12367
12426
  intersection(items, schemas, parentSchema, ctx) {
12368
- const applyModifiers = (result, opts) => this.applyModifiers(result, ctx, opts);
12369
12427
  const { pipes } = intersectionToPipes({
12370
12428
  applyModifiers,
12371
12429
  childResults: items,
12372
12430
  parentSchema,
12373
12431
  path: ctx.path,
12374
- plugin: ctx.plugin
12432
+ plugin
12375
12433
  });
12376
12434
  return {
12377
12435
  meta: composeMeta$1(items, { default: parentSchema.default }),
@@ -12381,7 +12439,7 @@ function createVisitor$3(config = {}) {
12381
12439
  never(schema, ctx) {
12382
12440
  const pipe = neverToPipes({
12383
12441
  path: ctx.path,
12384
- plugin: ctx.plugin,
12442
+ plugin,
12385
12443
  schema
12386
12444
  });
12387
12445
  return {
@@ -12396,7 +12454,7 @@ function createVisitor$3(config = {}) {
12396
12454
  null(schema, ctx) {
12397
12455
  const pipe = nullToPipes({
12398
12456
  path: ctx.path,
12399
- plugin: ctx.plugin,
12457
+ plugin,
12400
12458
  schema
12401
12459
  });
12402
12460
  return {
@@ -12411,7 +12469,7 @@ function createVisitor$3(config = {}) {
12411
12469
  number(schema, ctx) {
12412
12470
  const pipe = numberToPipes({
12413
12471
  path: ctx.path,
12414
- plugin: ctx.plugin,
12472
+ plugin,
12415
12473
  schema
12416
12474
  });
12417
12475
  return {
@@ -12420,11 +12478,10 @@ function createVisitor$3(config = {}) {
12420
12478
  };
12421
12479
  },
12422
12480
  object(schema, ctx, walk) {
12423
- const applyModifiers = (result, opts) => this.applyModifiers(result, ctx, opts);
12424
12481
  const { childResults, pipes } = objectToPipes({
12425
12482
  applyModifiers,
12426
12483
  path: ctx.path,
12427
- plugin: ctx.plugin,
12484
+ plugin,
12428
12485
  schema,
12429
12486
  walk
12430
12487
  });
@@ -12433,8 +12490,8 @@ function createVisitor$3(config = {}) {
12433
12490
  pipes
12434
12491
  };
12435
12492
  },
12436
- postProcess(result, schema, ctx) {
12437
- const metadata = ctx.plugin.config.metadata;
12493
+ postProcess(result, schema) {
12494
+ const metadata = plugin.config.metadata;
12438
12495
  if (!metadata) return result;
12439
12496
  const node = $.object();
12440
12497
  if (typeof metadata === "function") metadata({
@@ -12444,22 +12501,21 @@ function createVisitor$3(config = {}) {
12444
12501
  });
12445
12502
  else if (schema.description) node.prop("description", $.literal(schema.description));
12446
12503
  if (node.isEmpty) return result;
12447
- const metadataExpr = $(ctx.plugin.external("valibot.v")).attr(identifiers$1.actions.metadata).call(node);
12504
+ const metadataExpr = $(v).attr(identifiers$1.actions.metadata).call(node);
12448
12505
  return {
12449
12506
  meta: result.meta,
12450
12507
  pipes: [...result.pipes, metadataExpr]
12451
12508
  };
12452
12509
  },
12453
- reference($ref, schema, ctx) {
12454
- const v = ctx.plugin.external("valibot.v");
12510
+ reference($ref, schema) {
12455
12511
  const query = {
12456
12512
  category: "schema",
12457
12513
  resource: "definition",
12458
12514
  resourceId: $ref,
12459
12515
  tool: "valibot"
12460
12516
  };
12461
- const refSymbol = ctx.plugin.referenceSymbol(query);
12462
- if (ctx.plugin.isSymbolRegistered(query)) return {
12517
+ const refSymbol = plugin.referenceSymbol(query);
12518
+ if (plugin.isSymbolRegistered(query)) return {
12463
12519
  meta: defaultMeta$1(schema),
12464
12520
  pipes: [$(refSymbol)]
12465
12521
  };
@@ -12474,7 +12530,7 @@ function createVisitor$3(config = {}) {
12474
12530
  string(schema, ctx) {
12475
12531
  const pipe = stringToPipes({
12476
12532
  path: ctx.path,
12477
- plugin: ctx.plugin,
12533
+ plugin,
12478
12534
  schema
12479
12535
  });
12480
12536
  return {
@@ -12483,11 +12539,10 @@ function createVisitor$3(config = {}) {
12483
12539
  };
12484
12540
  },
12485
12541
  tuple(schema, ctx, walk) {
12486
- const applyModifiers = (result, opts) => this.applyModifiers(result, ctx, opts);
12487
12542
  const { childResults, pipes } = tupleToPipes({
12488
12543
  applyModifiers,
12489
12544
  path: ctx.path,
12490
- plugin: ctx.plugin,
12545
+ plugin,
12491
12546
  schema,
12492
12547
  walk
12493
12548
  });
@@ -12499,7 +12554,7 @@ function createVisitor$3(config = {}) {
12499
12554
  undefined(schema, ctx) {
12500
12555
  const pipe = undefinedToPipes({
12501
12556
  path: ctx.path,
12502
- plugin: ctx.plugin,
12557
+ plugin,
12503
12558
  schema
12504
12559
  });
12505
12560
  return {
@@ -12512,14 +12567,13 @@ function createVisitor$3(config = {}) {
12512
12567
  };
12513
12568
  },
12514
12569
  union(items, schemas, parentSchema, ctx) {
12515
- const applyModifiers = (result, opts) => this.applyModifiers(result, ctx, opts);
12516
12570
  const hasNull = schemas.some((s) => s.type === "null") || items.some((i) => i.meta.nullable);
12517
12571
  const { pipes } = unionToPipes({
12518
12572
  applyModifiers,
12519
12573
  childResults: items,
12520
12574
  parentSchema,
12521
12575
  path: ctx.path,
12522
- plugin: ctx.plugin,
12576
+ plugin,
12523
12577
  schemas
12524
12578
  });
12525
12579
  return {
@@ -12533,7 +12587,7 @@ function createVisitor$3(config = {}) {
12533
12587
  unknown(schema, ctx) {
12534
12588
  const pipe = unknownToPipes({
12535
12589
  path: ctx.path,
12536
- plugin: ctx.plugin
12590
+ plugin
12537
12591
  });
12538
12592
  return {
12539
12593
  meta: {
@@ -12547,7 +12601,7 @@ function createVisitor$3(config = {}) {
12547
12601
  void(schema, ctx) {
12548
12602
  const pipe = voidToPipes({
12549
12603
  path: ctx.path,
12550
- plugin: ctx.plugin,
12604
+ plugin,
12551
12605
  schema
12552
12606
  });
12553
12607
  return {
@@ -12565,10 +12619,10 @@ function createVisitor$3(config = {}) {
12565
12619
  //#region src/plugins/valibot/v1/processor.ts
12566
12620
  function createProcessor$3(plugin) {
12567
12621
  const processor = createSchemaProcessor();
12568
- const extractorHooks = [plugin.config["~hooks"]?.schemas?.shouldExtract, plugin.context.config.parser.hooks.schemas?.shouldExtract];
12569
- function extractor(ctx) {
12622
+ const extractorHooks = plugin.getHooks((hooks) => hooks.schemas?.shouldExtract);
12623
+ const schemaExtractor = (ctx) => {
12570
12624
  if (processor.hasEmitted(ctx.path)) return ctx.schema;
12571
- for (const hook of extractorHooks) if (typeof hook === "boolean" ? hook : hook?.(ctx) ?? false) {
12625
+ for (const hook of extractorHooks) if (typeof hook === "boolean" ? hook : hook(ctx)) {
12572
12626
  process({
12573
12627
  namingAnchor: processor.context.anchor,
12574
12628
  tags: processor.context.tags,
@@ -12577,7 +12631,7 @@ function createProcessor$3(plugin) {
12577
12631
  return { $ref: pathToJsonPointer(ctx.path) };
12578
12632
  }
12579
12633
  return ctx.schema;
12580
- }
12634
+ };
12581
12635
  function process(ctx) {
12582
12636
  if (!processor.markEmitted(ctx.path)) return;
12583
12637
  const shouldExport = ctx.export !== false;
@@ -12585,7 +12639,10 @@ function createProcessor$3(plugin) {
12585
12639
  anchor: ctx.namingAnchor,
12586
12640
  tags: ctx.tags
12587
12641
  }, () => {
12588
- const visitor = createVisitor$3({ schemaExtractor: extractor });
12642
+ const visitor = createVisitor$3({
12643
+ plugin,
12644
+ schemaExtractor
12645
+ });
12589
12646
  const result = createSchemaWalker(visitor)(ctx.schema, {
12590
12647
  path: ref(ctx.path),
12591
12648
  plugin
@@ -12867,7 +12924,7 @@ function exportAst({ final, meta, naming, namingAnchor, path, plugin, schema, ta
12867
12924
  plugin,
12868
12925
  schema
12869
12926
  }));
12870
- 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);
12927
+ 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.chain);
12871
12928
  plugin.node(statement);
12872
12929
  const typeInferSymbol = naming.types.infer.enabled ? plugin.registerSymbol(buildSymbolIn({
12873
12930
  meta: {
@@ -13098,7 +13155,7 @@ function createRequestSchemaMini(ctx) {
13098
13155
  if (!schema) return;
13099
13156
  if (!plugin.config.requests.shouldExtract({ operation })) return schema;
13100
13157
  return exportAst({
13101
- final: { expression: schema },
13158
+ final: { chain: schema },
13102
13159
  meta: {
13103
13160
  resource: "operation",
13104
13161
  resourceId: operation.id,
@@ -13253,7 +13310,7 @@ function createRequestSchemaV3(ctx) {
13253
13310
  if (!schema) return;
13254
13311
  if (!plugin.config.requests.shouldExtract({ operation })) return schema;
13255
13312
  return exportAst({
13256
- final: { expression: schema },
13313
+ final: { chain: schema },
13257
13314
  meta: {
13258
13315
  resource: "operation",
13259
13316
  resourceId: operation.id,
@@ -13408,7 +13465,7 @@ function createRequestSchemaV4(ctx) {
13408
13465
  if (!schema) return;
13409
13466
  if (!plugin.config.requests.shouldExtract({ operation })) return schema;
13410
13467
  return exportAst({
13411
- final: { expression: schema },
13468
+ final: { chain: schema },
13412
13469
  meta: {
13413
13470
  resource: "operation",
13414
13471
  resourceId: operation.id,
@@ -13715,11 +13772,11 @@ function baseNode$40(ctx) {
13715
13772
  schema: { type: "unknown" }
13716
13773
  }));
13717
13774
  if (childResults.length === 1) {
13718
- const itemNode = applyModifiers(childResults[0], { optional: false }).expression;
13775
+ const itemNode = applyModifiers(childResults[0], { optional: false }).chain;
13719
13776
  return arrayFn.call(itemNode);
13720
13777
  }
13721
13778
  if (childResults.length > 1) {
13722
- const itemExpressions = childResults.map((result) => applyModifiers(result, { optional: false }).expression);
13779
+ const itemExpressions = childResults.map((result) => applyModifiers(result, { optional: false }).chain);
13723
13780
  if (normalizedSchema.logicalOperator === "and") return arrayFn.call($(z).attr(identifiers.intersection).call(...itemExpressions));
13724
13781
  else return arrayFn.call($(z).attr(identifiers.union).call($.array(...itemExpressions)));
13725
13782
  }
@@ -13792,8 +13849,8 @@ function arrayToAst$2({ applyModifiers, path, plugin, schema, walk }) {
13792
13849
  };
13793
13850
  const resolver = plugin.config["~resolvers"]?.array;
13794
13851
  return {
13795
- childResults,
13796
- expression: resolver?.(ctx) ?? arrayResolver$2(ctx)
13852
+ chain: resolver?.(ctx) ?? arrayResolver$2(ctx),
13853
+ childResults
13797
13854
  };
13798
13855
  }
13799
13856
  //#endregion
@@ -13906,11 +13963,11 @@ function baseNode$37(ctx) {
13906
13963
  const { childResults, symbols } = ctx;
13907
13964
  const { z } = symbols;
13908
13965
  if (!childResults.length) return $(z).attr(identifiers.never).call();
13909
- let expression = childResults[0].expression;
13966
+ let chain = childResults[0].chain;
13910
13967
  childResults.slice(1).forEach((item) => {
13911
- expression = $(z).attr(identifiers.intersection).call(expression, item.meta.hasLazy ? $(z).attr(identifiers.lazy).call($.func().do(item.expression.return())) : item.expression);
13968
+ chain = $(z).attr(identifiers.intersection).call(chain, item.meta.hasLazy ? $(z).attr(identifiers.lazy).call($.func().do(item.chain.return())) : item.chain);
13912
13969
  });
13913
- return expression;
13970
+ return chain;
13914
13971
  }
13915
13972
  function intersectionResolver$2(ctx) {
13916
13973
  const baseResult = ctx.nodes.base(ctx);
@@ -13933,8 +13990,8 @@ function intersectionToAst$2({ childResults, parentSchema, path, plugin, schemas
13933
13990
  };
13934
13991
  const resolver = plugin.config["~resolvers"]?.intersection;
13935
13992
  return {
13936
- childResults,
13937
- expression: resolver?.(ctx) ?? intersectionResolver$2(ctx)
13993
+ chain: resolver?.(ctx) ?? intersectionResolver$2(ctx),
13994
+ childResults
13938
13995
  };
13939
13996
  }
13940
13997
  //#endregion
@@ -14071,7 +14128,7 @@ function additionalPropertiesNode$2(ctx) {
14071
14128
  plugin
14072
14129
  }, "additionalProperties"));
14073
14130
  _childResults.push(additionalResult);
14074
- return applyModifiers(additionalResult, {}).expression;
14131
+ return applyModifiers(additionalResult, {}).chain;
14075
14132
  }
14076
14133
  function baseNode$33(ctx) {
14077
14134
  const { nodes, symbols } = ctx;
@@ -14096,7 +14153,7 @@ function shapeNode$2(ctx) {
14096
14153
  }, "properties", name));
14097
14154
  _childResults.push(propertyResult);
14098
14155
  const finalExpr = applyModifiers(propertyResult, { optional: isOptional });
14099
- shape.prop(name, finalExpr.expression);
14156
+ shape.prop(name, finalExpr.chain);
14100
14157
  }
14101
14158
  return shape;
14102
14159
  }
@@ -14122,8 +14179,8 @@ function objectToAst$2(options) {
14122
14179
  };
14123
14180
  const resolver = plugin.config["~resolvers"]?.object;
14124
14181
  return {
14125
- childResults,
14126
- expression: resolver?.(ctx) ?? objectResolver$2(ctx)
14182
+ chain: resolver?.(ctx) ?? objectResolver$2(ctx),
14183
+ childResults
14127
14184
  };
14128
14185
  }
14129
14186
  //#endregion
@@ -14234,7 +14291,7 @@ function baseNode$31(ctx) {
14234
14291
  const { z } = symbols;
14235
14292
  const tupleFn = $(z).attr(identifiers.tuple);
14236
14293
  if (!childResults.length) return tupleFn.call($.array());
14237
- const tupleElements = childResults.map((result) => applyModifiers(result, { optional: false }).expression);
14294
+ const tupleElements = childResults.map((result) => applyModifiers(result, { optional: false }).chain);
14238
14295
  return tupleFn.call($.array(...tupleElements));
14239
14296
  }
14240
14297
  function constNode$8(ctx) {
@@ -14281,8 +14338,8 @@ function tupleToAst$2({ applyModifiers, path, plugin, schema, walk }) {
14281
14338
  };
14282
14339
  const resolver = plugin.config["~resolvers"]?.tuple;
14283
14340
  return {
14284
- childResults,
14285
- expression: resolver?.(ctx) ?? tupleResolver$2(ctx)
14341
+ chain: resolver?.(ctx) ?? tupleResolver$2(ctx),
14342
+ childResults
14286
14343
  };
14287
14344
  }
14288
14345
  //#endregion
@@ -14313,6 +14370,10 @@ function undefinedToAst$2({ path, plugin, schema }) {
14313
14370
  }
14314
14371
  //#endregion
14315
14372
  //#region src/plugins/zod/shared/discriminated-union.ts
14373
+ function isRecordShaped(schema) {
14374
+ if (!schema || schema.type !== "object") return false;
14375
+ return !(schema.properties && Object.keys(schema.properties).length > 0) && Boolean(schema.additionalProperties);
14376
+ }
14316
14377
  function tryBuildDiscriminatedUnion({ items, parentSchema, plugin, schemas }) {
14317
14378
  const discriminatorKey = parentSchema.discriminator?.propertyName;
14318
14379
  if (!discriminatorKey) return null;
@@ -14336,6 +14397,11 @@ function tryBuildDiscriminatedUnion({ items, parentSchema, plugin, schemas }) {
14336
14397
  tool: "zod"
14337
14398
  };
14338
14399
  if ((plugin.querySymbol(query)?.meta)?.isIntersection) return null;
14400
+ let resolved;
14401
+ try {
14402
+ resolved = plugin.context.resolveIrRef(refPart.$ref);
14403
+ } catch {}
14404
+ if (isRecordShaped(resolved)) return null;
14339
14405
  refExpression = $(plugin.referenceSymbol(query));
14340
14406
  } else return null;
14341
14407
  members.push({
@@ -14361,7 +14427,7 @@ function baseNode$29(ctx) {
14361
14427
  if (schema.type !== "null" && schema.const !== null) nonNullItems.push(result);
14362
14428
  });
14363
14429
  if (!nonNullItems.length) return $(z).attr(identifiers.null).call();
14364
- if (nonNullItems.length === 1) return nonNullItems[0].expression;
14430
+ if (nonNullItems.length === 1) return nonNullItems[0].chain;
14365
14431
  const discriminatedExpression = tryBuildDiscriminatedUnion({
14366
14432
  items: childResults,
14367
14433
  parentSchema,
@@ -14372,7 +14438,7 @@ function baseNode$29(ctx) {
14372
14438
  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)))));
14373
14439
  return $(z).attr(identifiers.discriminatedUnion).call($.literal(discriminatedExpression.discriminatorKey), $.array().pretty().elements(...unionMembers));
14374
14440
  }
14375
- return $(z).attr(identifiers.union).call($.array().pretty().elements(...nonNullItems.map((item) => item.expression)));
14441
+ return $(z).attr(identifiers.union).call($.array().pretty().elements(...nonNullItems.map((item) => item.chain)));
14376
14442
  }
14377
14443
  function unionResolver$2(ctx) {
14378
14444
  const baseResult = ctx.nodes.base(ctx);
@@ -14395,8 +14461,8 @@ function unionToAst$2({ childResults, parentSchema, path, plugin, schemas }) {
14395
14461
  };
14396
14462
  const resolver = plugin.config["~resolvers"]?.union;
14397
14463
  return {
14398
- childResults,
14399
- expression: resolver?.(ctx) ?? unionResolver$2(ctx)
14464
+ chain: resolver?.(ctx) ?? unionResolver$2(ctx),
14465
+ childResults
14400
14466
  };
14401
14467
  }
14402
14468
  //#endregion
@@ -14430,55 +14496,54 @@ function voidToAst$2({ path, plugin, schema }) {
14430
14496
  function getDefaultValue$2(meta) {
14431
14497
  return meta.format ? maybeBigInt(meta.default, meta.format) : $.fromValue(meta.default);
14432
14498
  }
14433
- function createVisitor$2(config = {}) {
14434
- const { schemaExtractor } = config;
14499
+ function createVisitor$2(config) {
14500
+ const { plugin, schemaExtractor } = config;
14501
+ const z = plugin.external("zod.z");
14435
14502
  return {
14436
14503
  applyModifiers(result, ctx, options = {}) {
14437
14504
  const { optional } = options;
14438
- const z = ctx.plugin.external("zod.z");
14439
- let expression = result.expression;
14440
- if (result.meta.readonly) expression = $(z).attr(identifiers.readonly).call(expression);
14505
+ let chain = result.chain;
14506
+ if (result.meta.readonly) chain = $(z).attr(identifiers.readonly).call(chain);
14441
14507
  const needsDefault = result.meta.default !== void 0;
14442
14508
  const needsNullable = result.meta.nullable;
14443
- if (optional && needsNullable) expression = $(z).attr(identifiers.nullish).call(expression);
14444
- else if (optional) expression = $(z).attr(identifiers.optional).call(expression);
14445
- else if (needsNullable) expression = $(z).attr(identifiers.nullable).call(expression);
14446
- if (needsDefault) expression = $(z).attr(identifiers._default).call(expression, getDefaultValue$2(result.meta));
14447
- return { expression };
14509
+ if (optional && needsNullable) chain = $(z).attr(identifiers.nullish).call(chain);
14510
+ else if (optional) chain = $(z).attr(identifiers.optional).call(chain);
14511
+ else if (needsNullable) chain = $(z).attr(identifiers.nullable).call(chain);
14512
+ if (needsDefault) chain = $(z).attr(identifiers._default).call(chain, getDefaultValue$2(result.meta));
14513
+ return { chain };
14448
14514
  },
14449
14515
  array(schema, ctx, walk) {
14450
- const applyModifiers = (result, opts) => this.applyModifiers(result, ctx, opts);
14451
- const { childResults, expression } = arrayToAst$2({
14452
- applyModifiers,
14516
+ const { chain, childResults } = arrayToAst$2({
14517
+ applyModifiers: (result, opts) => this.applyModifiers(result, ctx, opts),
14453
14518
  path: ctx.path,
14454
- plugin: ctx.plugin,
14519
+ plugin,
14455
14520
  schema,
14456
14521
  walk
14457
14522
  });
14458
14523
  return {
14459
- expression,
14524
+ chain,
14460
14525
  meta: inheritMeta(schema, childResults)
14461
14526
  };
14462
14527
  },
14463
14528
  boolean(schema, ctx) {
14464
14529
  return {
14465
- expression: booleanToAst$2({
14530
+ chain: booleanToAst$2({
14466
14531
  path: ctx.path,
14467
- plugin: ctx.plugin,
14532
+ plugin,
14468
14533
  schema
14469
14534
  }),
14470
14535
  meta: defaultMeta(schema)
14471
14536
  };
14472
14537
  },
14473
14538
  enum(schema, ctx) {
14474
- const expression = enumToAst$2({
14539
+ const chain = enumToAst$2({
14475
14540
  path: ctx.path,
14476
- plugin: ctx.plugin,
14541
+ plugin,
14477
14542
  schema
14478
14543
  });
14479
14544
  const hasNull = schema.items?.some((item) => item.type === "null" || item.const === null) ?? false;
14480
14545
  return {
14481
- expression,
14546
+ chain,
14482
14547
  meta: {
14483
14548
  ...defaultMeta(schema),
14484
14549
  nullable: hasNull
@@ -14487,9 +14552,9 @@ function createVisitor$2(config = {}) {
14487
14552
  },
14488
14553
  integer(schema, ctx) {
14489
14554
  return {
14490
- expression: numberToNode$2({
14555
+ chain: numberToNode$2({
14491
14556
  path: ctx.path,
14492
- plugin: ctx.plugin,
14557
+ plugin,
14493
14558
  schema
14494
14559
  }),
14495
14560
  meta: {
@@ -14505,29 +14570,29 @@ function createVisitor$2(config = {}) {
14505
14570
  resource: "definition",
14506
14571
  resourceId: pathToJsonPointer(fromRef(ctx.path))
14507
14572
  },
14508
- naming: ctx.plugin.config.definitions,
14573
+ naming: plugin.config.definitions,
14509
14574
  path: fromRef(ctx.path),
14510
- plugin: ctx.plugin,
14575
+ plugin,
14511
14576
  schema
14512
14577
  });
14513
14578
  if (extracted !== schema) return walk(extracted, ctx);
14514
14579
  }
14515
14580
  if (schema.symbolRef) return {
14516
- expression: $(schema.symbolRef),
14581
+ chain: $(schema.symbolRef),
14517
14582
  meta: defaultMeta(schema)
14518
14583
  };
14519
14584
  },
14520
14585
  intersection(items, schemas, parentSchema, ctx) {
14521
14586
  const hasAnyLazy = items.some((item) => item.meta.hasLazy);
14522
- const { expression } = intersectionToAst$2({
14587
+ const { chain } = intersectionToAst$2({
14523
14588
  childResults: items,
14524
14589
  parentSchema,
14525
14590
  path: ctx.path,
14526
- plugin: ctx.plugin,
14591
+ plugin,
14527
14592
  schemas
14528
14593
  });
14529
14594
  return {
14530
- expression,
14595
+ chain,
14531
14596
  meta: {
14532
14597
  default: parentSchema.default,
14533
14598
  format: parentSchema.format,
@@ -14541,9 +14606,9 @@ function createVisitor$2(config = {}) {
14541
14606
  },
14542
14607
  never(schema, ctx) {
14543
14608
  return {
14544
- expression: neverToAst$2({
14609
+ chain: neverToAst$2({
14545
14610
  path: ctx.path,
14546
- plugin: ctx.plugin,
14611
+ plugin,
14547
14612
  schema
14548
14613
  }),
14549
14614
  meta: {
@@ -14555,9 +14620,9 @@ function createVisitor$2(config = {}) {
14555
14620
  },
14556
14621
  null(schema, ctx) {
14557
14622
  return {
14558
- expression: nullToAst$2({
14623
+ chain: nullToAst$2({
14559
14624
  path: ctx.path,
14560
- plugin: ctx.plugin,
14625
+ plugin,
14561
14626
  schema
14562
14627
  }),
14563
14628
  meta: {
@@ -14569,9 +14634,9 @@ function createVisitor$2(config = {}) {
14569
14634
  },
14570
14635
  number(schema, ctx) {
14571
14636
  return {
14572
- expression: numberToNode$2({
14637
+ chain: numberToNode$2({
14573
14638
  path: ctx.path,
14574
- plugin: ctx.plugin,
14639
+ plugin,
14575
14640
  schema
14576
14641
  }),
14577
14642
  meta: {
@@ -14581,21 +14646,20 @@ function createVisitor$2(config = {}) {
14581
14646
  };
14582
14647
  },
14583
14648
  object(schema, ctx, walk) {
14584
- const applyModifiers = (result, opts) => this.applyModifiers(result, ctx, opts);
14585
- const { childResults, expression } = objectToAst$2({
14586
- applyModifiers,
14649
+ const { chain, childResults } = objectToAst$2({
14650
+ applyModifiers: (result, opts) => this.applyModifiers(result, ctx, opts),
14587
14651
  path: ctx.path,
14588
- plugin: ctx.plugin,
14652
+ plugin,
14589
14653
  schema,
14590
14654
  walk
14591
14655
  });
14592
14656
  return {
14593
- expression,
14657
+ chain,
14594
14658
  meta: inheritMeta(schema, childResults)
14595
14659
  };
14596
14660
  },
14597
- postProcess(result, schema, ctx) {
14598
- const { metadata } = ctx.plugin.config;
14661
+ postProcess(result, schema) {
14662
+ const { metadata } = plugin.config;
14599
14663
  if (!metadata) return result;
14600
14664
  const node = $.object();
14601
14665
  if (metadata === true) {
@@ -14607,27 +14671,25 @@ function createVisitor$2(config = {}) {
14607
14671
  schema
14608
14672
  });
14609
14673
  if (node.isEmpty) return result;
14610
- const z = ctx.plugin.external("zod.z");
14611
14674
  return {
14612
14675
  ...result,
14613
- expression: result.expression.attr(identifiers.register).call($(z).attr(identifiers.globalRegistry), node)
14676
+ chain: result.chain.attr(identifiers.register).call($(z).attr(identifiers.globalRegistry), node)
14614
14677
  };
14615
14678
  },
14616
- reference($ref, schema, ctx) {
14617
- const z = ctx.plugin.external("zod.z");
14679
+ reference($ref, schema) {
14618
14680
  const query = {
14619
14681
  category: "schema",
14620
14682
  resource: "definition",
14621
14683
  resourceId: $ref,
14622
14684
  tool: "zod"
14623
14685
  };
14624
- const refSymbol = ctx.plugin.referenceSymbol(query);
14625
- if (ctx.plugin.isSymbolRegistered(query)) return {
14626
- expression: $(refSymbol),
14686
+ const refSymbol = plugin.referenceSymbol(query);
14687
+ if (plugin.isSymbolRegistered(query)) return {
14688
+ chain: $(refSymbol),
14627
14689
  meta: defaultMeta(schema)
14628
14690
  };
14629
14691
  return {
14630
- expression: $(z).attr(identifiers.lazy).call($.func().returns("any").do($(refSymbol).return())),
14692
+ chain: $(z).attr(identifiers.lazy).call($.func().returns("any").do($(refSymbol).return())),
14631
14693
  meta: {
14632
14694
  ...defaultMeta(schema),
14633
14695
  hasLazy: true,
@@ -14637,9 +14699,9 @@ function createVisitor$2(config = {}) {
14637
14699
  },
14638
14700
  string(schema, ctx) {
14639
14701
  if (shouldCoerceToBigInt(schema.format)) return {
14640
- expression: numberToNode$2({
14702
+ chain: numberToNode$2({
14641
14703
  path: ctx.path,
14642
- plugin: ctx.plugin,
14704
+ plugin,
14643
14705
  schema: {
14644
14706
  ...schema,
14645
14707
  type: "number"
@@ -14648,33 +14710,32 @@ function createVisitor$2(config = {}) {
14648
14710
  meta: defaultMeta(schema)
14649
14711
  };
14650
14712
  return {
14651
- expression: stringToNode$2({
14713
+ chain: stringToNode$2({
14652
14714
  path: ctx.path,
14653
- plugin: ctx.plugin,
14715
+ plugin,
14654
14716
  schema
14655
14717
  }),
14656
14718
  meta: defaultMeta(schema)
14657
14719
  };
14658
14720
  },
14659
14721
  tuple(schema, ctx, walk) {
14660
- const applyModifiers = (result, opts) => this.applyModifiers(result, ctx, opts);
14661
- const { childResults, expression } = tupleToAst$2({
14662
- applyModifiers,
14722
+ const { chain, childResults } = tupleToAst$2({
14723
+ applyModifiers: (result, opts) => this.applyModifiers(result, ctx, opts),
14663
14724
  path: ctx.path,
14664
- plugin: ctx.plugin,
14725
+ plugin,
14665
14726
  schema,
14666
14727
  walk
14667
14728
  });
14668
14729
  return {
14669
- expression,
14730
+ chain,
14670
14731
  meta: inheritMeta(schema, childResults)
14671
14732
  };
14672
14733
  },
14673
14734
  undefined(schema, ctx) {
14674
14735
  return {
14675
- expression: undefinedToAst$2({
14736
+ chain: undefinedToAst$2({
14676
14737
  path: ctx.path,
14677
- plugin: ctx.plugin,
14738
+ plugin,
14678
14739
  schema
14679
14740
  }),
14680
14741
  meta: {
@@ -14687,15 +14748,15 @@ function createVisitor$2(config = {}) {
14687
14748
  union(items, schemas, parentSchema, ctx) {
14688
14749
  const hasAnyLazy = items.some((item) => item.meta.hasLazy);
14689
14750
  const hasNull = schemas.some((s) => s.type === "null") || items.some((i) => i.meta.nullable);
14690
- const { expression } = unionToAst$2({
14751
+ const { chain } = unionToAst$2({
14691
14752
  childResults: items,
14692
14753
  parentSchema,
14693
14754
  path: ctx.path,
14694
- plugin: ctx.plugin,
14755
+ plugin,
14695
14756
  schemas
14696
14757
  });
14697
14758
  return {
14698
- expression,
14759
+ chain,
14699
14760
  meta: {
14700
14761
  default: parentSchema.default,
14701
14762
  format: parentSchema.format,
@@ -14709,9 +14770,9 @@ function createVisitor$2(config = {}) {
14709
14770
  },
14710
14771
  unknown(schema, ctx) {
14711
14772
  return {
14712
- expression: unknownToAst$2({
14773
+ chain: unknownToAst$2({
14713
14774
  path: ctx.path,
14714
- plugin: ctx.plugin,
14775
+ plugin,
14715
14776
  schema
14716
14777
  }),
14717
14778
  meta: {
@@ -14723,9 +14784,9 @@ function createVisitor$2(config = {}) {
14723
14784
  },
14724
14785
  void(schema, ctx) {
14725
14786
  return {
14726
- expression: voidToAst$2({
14787
+ chain: voidToAst$2({
14727
14788
  path: ctx.path,
14728
- plugin: ctx.plugin,
14789
+ plugin,
14729
14790
  schema
14730
14791
  }),
14731
14792
  meta: {
@@ -14741,10 +14802,10 @@ function createVisitor$2(config = {}) {
14741
14802
  //#region src/plugins/zod/mini/processor.ts
14742
14803
  function createProcessor$2(plugin) {
14743
14804
  const processor = createSchemaProcessor();
14744
- const extractorHooks = [plugin.config["~hooks"]?.schemas?.shouldExtract, plugin.context.config.parser.hooks.schemas?.shouldExtract];
14745
- function extractor(ctx) {
14805
+ const extractorHooks = plugin.getHooks((hooks) => hooks.schemas?.shouldExtract);
14806
+ const schemaExtractor = (ctx) => {
14746
14807
  if (processor.hasEmitted(ctx.path)) return ctx.schema;
14747
- for (const hook of extractorHooks) if (typeof hook === "boolean" ? hook : hook?.(ctx) ?? false) {
14808
+ for (const hook of extractorHooks) if (typeof hook === "boolean" ? hook : hook(ctx)) {
14748
14809
  process({
14749
14810
  namingAnchor: processor.context.anchor,
14750
14811
  tags: processor.context.tags,
@@ -14753,7 +14814,7 @@ function createProcessor$2(plugin) {
14753
14814
  return { $ref: pathToJsonPointer(ctx.path) };
14754
14815
  }
14755
14816
  return ctx.schema;
14756
- }
14817
+ };
14757
14818
  function process(ctx) {
14758
14819
  if (!processor.markEmitted(ctx.path)) return;
14759
14820
  const shouldExport = ctx.export !== false;
@@ -14761,7 +14822,10 @@ function createProcessor$2(plugin) {
14761
14822
  anchor: ctx.namingAnchor,
14762
14823
  tags: ctx.tags
14763
14824
  }, () => {
14764
- const visitor = createVisitor$2({ schemaExtractor: extractor });
14825
+ const visitor = createVisitor$2({
14826
+ plugin,
14827
+ schemaExtractor
14828
+ });
14765
14829
  const result = createSchemaWalker(visitor)(ctx.schema, {
14766
14830
  path: ref(ctx.path),
14767
14831
  plugin
@@ -14898,11 +14962,11 @@ function baseNode$26(ctx) {
14898
14962
  schema: { type: "unknown" }
14899
14963
  }));
14900
14964
  if (childResults.length === 1) {
14901
- const itemNode = applyModifiers(childResults[0], { optional: false }).expression;
14965
+ const itemNode = applyModifiers(childResults[0], { optional: false }).chain;
14902
14966
  return arrayFn.call(itemNode);
14903
14967
  }
14904
14968
  if (childResults.length > 1) {
14905
- const itemExpressions = childResults.map((result) => applyModifiers(result, { optional: false }).expression);
14969
+ const itemExpressions = childResults.map((result) => applyModifiers(result, { optional: false }).chain);
14906
14970
  const firstSchema = normalizedSchema.items[0];
14907
14971
  if (normalizedSchema.logicalOperator === "and") {
14908
14972
  let intersectionExpression;
@@ -14980,8 +15044,8 @@ function arrayToAst$1({ applyModifiers, path, plugin, schema, walk }) {
14980
15044
  };
14981
15045
  const resolver = plugin.config["~resolvers"]?.array;
14982
15046
  return {
14983
- childResults,
14984
- expression: resolver?.(ctx) ?? arrayResolver$1(ctx)
15047
+ chain: resolver?.(ctx) ?? arrayResolver$1(ctx),
15048
+ childResults
14985
15049
  };
14986
15050
  }
14987
15051
  //#endregion
@@ -15095,12 +15159,12 @@ function baseNode$23(ctx) {
15095
15159
  const { z } = symbols;
15096
15160
  if (!childResults.length) return $(z).attr(identifiers.never).call();
15097
15161
  const firstSchema = schemas[0];
15098
- if (firstSchema?.logicalOperator === "or" || firstSchema?.type && firstSchema.type !== "object") return $(z).attr(identifiers.intersection).call(...childResults.map((result) => result.expression));
15099
- let expression = childResults[0].expression;
15162
+ if (firstSchema?.logicalOperator === "or" || firstSchema?.type && firstSchema.type !== "object") return $(z).attr(identifiers.intersection).call(...childResults.map((result) => result.chain));
15163
+ let chain = childResults[0].chain;
15100
15164
  childResults.slice(1).forEach((item) => {
15101
- expression = expression.attr(identifiers.and).call(item.meta.hasLazy && !item.meta.isLazy ? $(z).attr(identifiers.lazy).call($.func().do(item.expression.return())) : item.expression);
15165
+ chain = chain.attr(identifiers.and).call(item.meta.hasLazy && !item.meta.isLazy ? $(z).attr(identifiers.lazy).call($.func().do(item.chain.return())) : item.chain);
15102
15166
  });
15103
- return expression;
15167
+ return chain;
15104
15168
  }
15105
15169
  function intersectionResolver$1(ctx) {
15106
15170
  const baseResult = ctx.nodes.base(ctx);
@@ -15123,8 +15187,8 @@ function intersectionToAst$1({ childResults, parentSchema, path, plugin, schemas
15123
15187
  };
15124
15188
  const resolver = plugin.config["~resolvers"]?.intersection;
15125
15189
  return {
15126
- childResults,
15127
- expression: resolver?.(ctx) ?? intersectionResolver$1(ctx)
15190
+ chain: resolver?.(ctx) ?? intersectionResolver$1(ctx),
15191
+ childResults
15128
15192
  };
15129
15193
  }
15130
15194
  //#endregion
@@ -15257,7 +15321,7 @@ function additionalPropertiesNode$1(ctx) {
15257
15321
  plugin
15258
15322
  }, "additionalProperties"));
15259
15323
  ctx._childResults.push(additionalResult);
15260
- return applyModifiers(additionalResult, {}).expression;
15324
+ return applyModifiers(additionalResult, {}).chain;
15261
15325
  }
15262
15326
  function baseNode$19(ctx) {
15263
15327
  const { nodes, symbols } = ctx;
@@ -15282,7 +15346,7 @@ function shapeNode$1(ctx) {
15282
15346
  }, "properties", name));
15283
15347
  ctx._childResults.push(propertyResult);
15284
15348
  const finalExpr = applyModifiers(propertyResult, { optional: isOptional });
15285
- shape.prop(name, finalExpr.expression);
15349
+ shape.prop(name, finalExpr.chain);
15286
15350
  }
15287
15351
  return shape;
15288
15352
  }
@@ -15308,8 +15372,8 @@ function objectToAst$1(options) {
15308
15372
  };
15309
15373
  const resolver = plugin.config["~resolvers"]?.object;
15310
15374
  return {
15311
- childResults,
15312
- expression: resolver?.(ctx) ?? objectResolver$1(ctx)
15375
+ chain: resolver?.(ctx) ?? objectResolver$1(ctx),
15376
+ childResults
15313
15377
  };
15314
15378
  }
15315
15379
  //#endregion
@@ -15412,7 +15476,7 @@ function baseNode$17(ctx) {
15412
15476
  const { z } = symbols;
15413
15477
  const tupleFn = $(z).attr(identifiers.tuple);
15414
15478
  if (!childResults.length) return tupleFn.call($.array());
15415
- const tupleElements = childResults.map((result) => applyModifiers(result, { optional: false }).expression);
15479
+ const tupleElements = childResults.map((result) => applyModifiers(result, { optional: false }).chain);
15416
15480
  return tupleFn.call($.array(...tupleElements));
15417
15481
  }
15418
15482
  function constNode$4(ctx) {
@@ -15459,8 +15523,8 @@ function tupleToAst$1({ applyModifiers, path, plugin, schema, walk }) {
15459
15523
  };
15460
15524
  const resolver = plugin.config["~resolvers"]?.tuple;
15461
15525
  return {
15462
- childResults,
15463
- expression: resolver?.(ctx) ?? tupleResolver$1(ctx)
15526
+ chain: resolver?.(ctx) ?? tupleResolver$1(ctx),
15527
+ childResults
15464
15528
  };
15465
15529
  }
15466
15530
  //#endregion
@@ -15501,7 +15565,7 @@ function baseNode$15(ctx) {
15501
15565
  if (schema.type !== "null" && schema.const !== null) nonNullItems.push(result);
15502
15566
  });
15503
15567
  if (!nonNullItems.length) return $(z).attr(identifiers.null).call();
15504
- if (nonNullItems.length === 1) return nonNullItems[0].expression;
15568
+ if (nonNullItems.length === 1) return nonNullItems[0].chain;
15505
15569
  const discriminatedExpression = tryBuildDiscriminatedUnion({
15506
15570
  items: childResults,
15507
15571
  parentSchema,
@@ -15512,7 +15576,7 @@ function baseNode$15(ctx) {
15512
15576
  const unionMembers = discriminatedExpression.members.map((member) => member.refExpression.attr(identifiers.extend).call($.object().prop(discriminatedExpression.discriminatorKey, $(z).attr(identifiers.literal).call($.fromValue(member.discriminatedValue)))));
15513
15577
  return $(z).attr(identifiers.discriminatedUnion).call($.literal(discriminatedExpression.discriminatorKey), $.array().pretty().elements(...unionMembers));
15514
15578
  }
15515
- return $(z).attr(identifiers.union).call($.array().pretty().elements(...nonNullItems.map((item) => item.expression)));
15579
+ return $(z).attr(identifiers.union).call($.array().pretty().elements(...nonNullItems.map((item) => item.chain)));
15516
15580
  }
15517
15581
  function unionResolver$1(ctx) {
15518
15582
  const baseResult = ctx.nodes.base(ctx);
@@ -15535,8 +15599,8 @@ function unionToAst$1({ childResults, parentSchema, path, plugin, schemas }) {
15535
15599
  };
15536
15600
  const resolver = plugin.config["~resolvers"]?.union;
15537
15601
  return {
15538
- childResults,
15539
- expression: resolver?.(ctx) ?? unionResolver$1(ctx)
15602
+ chain: resolver?.(ctx) ?? unionResolver$1(ctx),
15603
+ childResults
15540
15604
  };
15541
15605
  }
15542
15606
  //#endregion
@@ -15570,57 +15634,56 @@ function voidToAst$1({ path, plugin, schema }) {
15570
15634
  function getDefaultValue$1(meta) {
15571
15635
  return meta.format ? maybeBigInt(meta.default, meta.format) : $.fromValue(meta.default);
15572
15636
  }
15573
- function createVisitor$1(config = {}) {
15574
- const { schemaExtractor } = config;
15637
+ function createVisitor$1(config) {
15638
+ const { plugin, schemaExtractor } = config;
15575
15639
  return {
15576
15640
  applyModifiers(result, ctx, options = {}) {
15577
15641
  const { optional } = options;
15578
- let expression = result.expression;
15579
- if (result.meta.readonly) expression = expression.attr(identifiers.readonly).call();
15642
+ let chain = result.chain;
15643
+ if (result.meta.readonly) chain = chain.attr(identifiers.readonly).call();
15580
15644
  const needsDefault = result.meta.default !== void 0;
15581
15645
  const needsNullable = result.meta.nullable;
15582
- if (optional && needsNullable) expression = expression.attr(identifiers.nullish).call();
15583
- else if (optional) expression = expression.attr(identifiers.optional).call();
15584
- else if (needsNullable) expression = expression.attr(identifiers.nullable).call();
15585
- if (needsDefault) expression = expression.attr(identifiers.default).call(getDefaultValue$1(result.meta));
15646
+ if (optional && needsNullable) chain = chain.attr(identifiers.nullish).call();
15647
+ else if (optional) chain = chain.attr(identifiers.optional).call();
15648
+ else if (needsNullable) chain = chain.attr(identifiers.nullable).call();
15649
+ if (needsDefault) chain = chain.attr(identifiers.default).call(getDefaultValue$1(result.meta));
15586
15650
  return {
15587
- expression,
15651
+ chain,
15588
15652
  typeName: result.meta.hasLazy ? result.meta.isObject ? identifiers.AnyZodObject : identifiers.ZodTypeAny : void 0
15589
15653
  };
15590
15654
  },
15591
15655
  array(schema, ctx, walk) {
15592
- const applyModifiers = (result, opts) => this.applyModifiers(result, ctx, opts);
15593
- const { childResults, expression } = arrayToAst$1({
15594
- applyModifiers,
15656
+ const { chain, childResults } = arrayToAst$1({
15657
+ applyModifiers: (result, opts) => this.applyModifiers(result, ctx, opts),
15595
15658
  path: ctx.path,
15596
- plugin: ctx.plugin,
15659
+ plugin,
15597
15660
  schema,
15598
15661
  walk
15599
15662
  });
15600
15663
  return {
15601
- expression,
15664
+ chain,
15602
15665
  meta: inheritMeta(schema, childResults)
15603
15666
  };
15604
15667
  },
15605
15668
  boolean(schema, ctx) {
15606
15669
  return {
15607
- expression: booleanToAst$1({
15670
+ chain: booleanToAst$1({
15608
15671
  path: ctx.path,
15609
- plugin: ctx.plugin,
15672
+ plugin,
15610
15673
  schema
15611
15674
  }),
15612
15675
  meta: defaultMeta(schema)
15613
15676
  };
15614
15677
  },
15615
15678
  enum(schema, ctx) {
15616
- const expression = enumToAst$1({
15679
+ const chain = enumToAst$1({
15617
15680
  path: ctx.path,
15618
- plugin: ctx.plugin,
15681
+ plugin,
15619
15682
  schema
15620
15683
  });
15621
15684
  const hasNull = schema.items?.some((item) => item.type === "null" || item.const === null) ?? false;
15622
15685
  return {
15623
- expression,
15686
+ chain,
15624
15687
  meta: {
15625
15688
  ...defaultMeta(schema),
15626
15689
  nullable: hasNull
@@ -15629,9 +15692,9 @@ function createVisitor$1(config = {}) {
15629
15692
  },
15630
15693
  integer(schema, ctx) {
15631
15694
  return {
15632
- expression: numberToNode$1({
15695
+ chain: numberToNode$1({
15633
15696
  path: ctx.path,
15634
- plugin: ctx.plugin,
15697
+ plugin,
15635
15698
  schema
15636
15699
  }),
15637
15700
  meta: {
@@ -15647,29 +15710,29 @@ function createVisitor$1(config = {}) {
15647
15710
  resource: "definition",
15648
15711
  resourceId: pathToJsonPointer(fromRef(ctx.path))
15649
15712
  },
15650
- naming: ctx.plugin.config.definitions,
15713
+ naming: plugin.config.definitions,
15651
15714
  path: fromRef(ctx.path),
15652
- plugin: ctx.plugin,
15715
+ plugin,
15653
15716
  schema
15654
15717
  });
15655
15718
  if (extracted !== schema) return walk(extracted, ctx);
15656
15719
  }
15657
15720
  if (schema.symbolRef) return {
15658
- expression: $(schema.symbolRef),
15721
+ chain: $(schema.symbolRef),
15659
15722
  meta: defaultMeta(schema)
15660
15723
  };
15661
15724
  },
15662
15725
  intersection(items, schemas, parentSchema, ctx) {
15663
15726
  const hasAnyLazy = items.some((item) => item.meta.hasLazy);
15664
- const { expression } = intersectionToAst$1({
15727
+ const { chain } = intersectionToAst$1({
15665
15728
  childResults: items,
15666
15729
  parentSchema,
15667
15730
  path: ctx.path,
15668
- plugin: ctx.plugin,
15731
+ plugin,
15669
15732
  schemas
15670
15733
  });
15671
15734
  return {
15672
- expression,
15735
+ chain,
15673
15736
  meta: {
15674
15737
  default: parentSchema.default,
15675
15738
  format: parentSchema.format,
@@ -15683,9 +15746,9 @@ function createVisitor$1(config = {}) {
15683
15746
  },
15684
15747
  never(schema, ctx) {
15685
15748
  return {
15686
- expression: neverToAst$1({
15749
+ chain: neverToAst$1({
15687
15750
  path: ctx.path,
15688
- plugin: ctx.plugin,
15751
+ plugin,
15689
15752
  schema
15690
15753
  }),
15691
15754
  meta: {
@@ -15697,9 +15760,9 @@ function createVisitor$1(config = {}) {
15697
15760
  },
15698
15761
  null(schema, ctx) {
15699
15762
  return {
15700
- expression: nullToAst$1({
15763
+ chain: nullToAst$1({
15701
15764
  path: ctx.path,
15702
- plugin: ctx.plugin,
15765
+ plugin,
15703
15766
  schema
15704
15767
  }),
15705
15768
  meta: {
@@ -15711,9 +15774,9 @@ function createVisitor$1(config = {}) {
15711
15774
  },
15712
15775
  number(schema, ctx) {
15713
15776
  return {
15714
- expression: numberToNode$1({
15777
+ chain: numberToNode$1({
15715
15778
  path: ctx.path,
15716
- plugin: ctx.plugin,
15779
+ plugin,
15717
15780
  schema
15718
15781
  }),
15719
15782
  meta: {
@@ -15723,44 +15786,43 @@ function createVisitor$1(config = {}) {
15723
15786
  };
15724
15787
  },
15725
15788
  object(schema, ctx, walk) {
15726
- const applyModifiers = (result, opts) => this.applyModifiers(result, ctx, opts);
15727
- const { childResults, expression } = objectToAst$1({
15728
- applyModifiers,
15789
+ const { chain, childResults } = objectToAst$1({
15790
+ applyModifiers: (result, opts) => this.applyModifiers(result, ctx, opts),
15729
15791
  path: ctx.path,
15730
- plugin: ctx.plugin,
15792
+ plugin,
15731
15793
  schema,
15732
15794
  walk
15733
15795
  });
15734
15796
  return {
15735
- expression,
15797
+ chain,
15736
15798
  meta: {
15737
15799
  ...inheritMeta(schema, childResults),
15738
15800
  isObject: true
15739
15801
  }
15740
15802
  };
15741
15803
  },
15742
- postProcess(result, schema, ctx) {
15743
- if (ctx.plugin.config.metadata && schema.description) return {
15804
+ postProcess(result, schema) {
15805
+ if (plugin.config.metadata && schema.description) return {
15744
15806
  ...result,
15745
- expression: result.expression.attr(identifiers.describe).call($.literal(schema.description))
15807
+ chain: result.chain.attr(identifiers.describe).call($.literal(schema.description))
15746
15808
  };
15747
15809
  return result;
15748
15810
  },
15749
- reference($ref, schema, ctx) {
15750
- const z = ctx.plugin.external("zod.z");
15811
+ reference($ref, schema) {
15812
+ const z = plugin.external("zod.z");
15751
15813
  const query = {
15752
15814
  category: "schema",
15753
15815
  resource: "definition",
15754
15816
  resourceId: $ref,
15755
15817
  tool: "zod"
15756
15818
  };
15757
- const refSymbol = ctx.plugin.referenceSymbol(query);
15758
- if (ctx.plugin.isSymbolRegistered(query)) return {
15759
- expression: $(refSymbol),
15819
+ const refSymbol = plugin.referenceSymbol(query);
15820
+ if (plugin.isSymbolRegistered(query)) return {
15821
+ chain: $(refSymbol),
15760
15822
  meta: defaultMeta(schema)
15761
15823
  };
15762
15824
  return {
15763
- expression: $(z).attr(identifiers.lazy).call($.func().do($(refSymbol).return())),
15825
+ chain: $(z).attr(identifiers.lazy).call($.func().do($(refSymbol).return())),
15764
15826
  meta: {
15765
15827
  ...defaultMeta(schema),
15766
15828
  hasLazy: true,
@@ -15770,9 +15832,9 @@ function createVisitor$1(config = {}) {
15770
15832
  },
15771
15833
  string(schema, ctx) {
15772
15834
  if (shouldCoerceToBigInt(schema.format)) return {
15773
- expression: numberToNode$1({
15835
+ chain: numberToNode$1({
15774
15836
  path: ctx.path,
15775
- plugin: ctx.plugin,
15837
+ plugin,
15776
15838
  schema: {
15777
15839
  ...schema,
15778
15840
  type: "number"
@@ -15781,33 +15843,32 @@ function createVisitor$1(config = {}) {
15781
15843
  meta: defaultMeta(schema)
15782
15844
  };
15783
15845
  return {
15784
- expression: stringToNode$1({
15846
+ chain: stringToNode$1({
15785
15847
  path: ctx.path,
15786
- plugin: ctx.plugin,
15848
+ plugin,
15787
15849
  schema
15788
15850
  }),
15789
15851
  meta: defaultMeta(schema)
15790
15852
  };
15791
15853
  },
15792
15854
  tuple(schema, ctx, walk) {
15793
- const applyModifiers = (result, opts) => this.applyModifiers(result, ctx, opts);
15794
- const { childResults, expression } = tupleToAst$1({
15795
- applyModifiers,
15855
+ const { chain, childResults } = tupleToAst$1({
15856
+ applyModifiers: (result, opts) => this.applyModifiers(result, ctx, opts),
15796
15857
  path: ctx.path,
15797
- plugin: ctx.plugin,
15858
+ plugin,
15798
15859
  schema,
15799
15860
  walk
15800
15861
  });
15801
15862
  return {
15802
- expression,
15863
+ chain,
15803
15864
  meta: inheritMeta(schema, childResults)
15804
15865
  };
15805
15866
  },
15806
15867
  undefined(schema, ctx) {
15807
15868
  return {
15808
- expression: undefinedToAst$1({
15869
+ chain: undefinedToAst$1({
15809
15870
  path: ctx.path,
15810
- plugin: ctx.plugin,
15871
+ plugin,
15811
15872
  schema
15812
15873
  }),
15813
15874
  meta: {
@@ -15820,15 +15881,15 @@ function createVisitor$1(config = {}) {
15820
15881
  union(items, schemas, parentSchema, ctx) {
15821
15882
  const hasAnyLazy = items.some((item) => item.meta.hasLazy);
15822
15883
  const hasNull = schemas.some((s) => s.type === "null") || items.some((i) => i.meta.nullable);
15823
- const { expression } = unionToAst$1({
15884
+ const { chain } = unionToAst$1({
15824
15885
  childResults: items,
15825
15886
  parentSchema,
15826
15887
  path: ctx.path,
15827
- plugin: ctx.plugin,
15888
+ plugin,
15828
15889
  schemas
15829
15890
  });
15830
15891
  return {
15831
- expression,
15892
+ chain,
15832
15893
  meta: {
15833
15894
  default: parentSchema.default,
15834
15895
  format: parentSchema.format,
@@ -15842,9 +15903,9 @@ function createVisitor$1(config = {}) {
15842
15903
  },
15843
15904
  unknown(schema, ctx) {
15844
15905
  return {
15845
- expression: unknownToAst$1({
15906
+ chain: unknownToAst$1({
15846
15907
  path: ctx.path,
15847
- plugin: ctx.plugin,
15908
+ plugin,
15848
15909
  schema
15849
15910
  }),
15850
15911
  meta: {
@@ -15856,9 +15917,9 @@ function createVisitor$1(config = {}) {
15856
15917
  },
15857
15918
  void(schema, ctx) {
15858
15919
  return {
15859
- expression: voidToAst$1({
15920
+ chain: voidToAst$1({
15860
15921
  path: ctx.path,
15861
- plugin: ctx.plugin,
15922
+ plugin,
15862
15923
  schema
15863
15924
  }),
15864
15925
  meta: {
@@ -15874,10 +15935,10 @@ function createVisitor$1(config = {}) {
15874
15935
  //#region src/plugins/zod/v3/processor.ts
15875
15936
  function createProcessor$1(plugin) {
15876
15937
  const processor = createSchemaProcessor();
15877
- const extractorHooks = [plugin.config["~hooks"]?.schemas?.shouldExtract, plugin.context.config.parser.hooks.schemas?.shouldExtract];
15878
- function extractor(ctx) {
15938
+ const extractorHooks = plugin.getHooks((hooks) => hooks.schemas?.shouldExtract);
15939
+ const schemaExtractor = (ctx) => {
15879
15940
  if (processor.hasEmitted(ctx.path)) return ctx.schema;
15880
- for (const hook of extractorHooks) if (typeof hook === "boolean" ? hook : hook?.(ctx) ?? false) {
15941
+ for (const hook of extractorHooks) if (typeof hook === "boolean" ? hook : hook(ctx)) {
15881
15942
  process({
15882
15943
  namingAnchor: processor.context.anchor,
15883
15944
  tags: processor.context.tags,
@@ -15886,7 +15947,7 @@ function createProcessor$1(plugin) {
15886
15947
  return { $ref: pathToJsonPointer(ctx.path) };
15887
15948
  }
15888
15949
  return ctx.schema;
15889
- }
15950
+ };
15890
15951
  function process(ctx) {
15891
15952
  if (!processor.markEmitted(ctx.path)) return;
15892
15953
  const shouldExport = ctx.export !== false;
@@ -15894,7 +15955,10 @@ function createProcessor$1(plugin) {
15894
15955
  anchor: ctx.namingAnchor,
15895
15956
  tags: ctx.tags
15896
15957
  }, () => {
15897
- const visitor = createVisitor$1({ schemaExtractor: extractor });
15958
+ const visitor = createVisitor$1({
15959
+ plugin,
15960
+ schemaExtractor
15961
+ });
15898
15962
  const result = createSchemaWalker(visitor)(ctx.schema, {
15899
15963
  path: ref(ctx.path),
15900
15964
  plugin
@@ -16030,11 +16094,11 @@ function baseNode$12(ctx) {
16030
16094
  schema: { type: "unknown" }
16031
16095
  }));
16032
16096
  if (childResults.length === 1) {
16033
- const itemNode = applyModifiers(childResults[0], { optional: false }).expression;
16097
+ const itemNode = applyModifiers(childResults[0], { optional: false }).chain;
16034
16098
  return arrayFn.call(itemNode);
16035
16099
  }
16036
16100
  if (childResults.length > 1) {
16037
- const itemExpressions = childResults.map((result) => applyModifiers(result, { optional: false }).expression);
16101
+ const itemExpressions = childResults.map((result) => applyModifiers(result, { optional: false }).chain);
16038
16102
  const firstSchema = normalizedSchema.items[0];
16039
16103
  if (normalizedSchema.logicalOperator === "and") {
16040
16104
  let intersectionExpression;
@@ -16112,8 +16176,8 @@ function arrayToAst({ applyModifiers, path, plugin, schema, walk }) {
16112
16176
  };
16113
16177
  const resolver = plugin.config["~resolvers"]?.array;
16114
16178
  return {
16115
- childResults,
16116
- expression: resolver?.(ctx) ?? arrayResolver(ctx)
16179
+ chain: resolver?.(ctx) ?? arrayResolver(ctx),
16180
+ childResults
16117
16181
  };
16118
16182
  }
16119
16183
  //#endregion
@@ -16227,12 +16291,12 @@ function baseNode$9(ctx) {
16227
16291
  const { z } = symbols;
16228
16292
  if (!childResults.length) return $(z).attr(identifiers.never).call();
16229
16293
  const firstSchema = schemas[0];
16230
- if (firstSchema?.logicalOperator === "or" || firstSchema?.type && firstSchema.type !== "object") return $(z).attr(identifiers.intersection).call(...childResults.map((result) => result.expression));
16231
- let expression = childResults[0].expression;
16294
+ if (firstSchema?.logicalOperator === "or" || firstSchema?.type && firstSchema.type !== "object") return $(z).attr(identifiers.intersection).call(...childResults.map((result) => result.chain));
16295
+ let chain = childResults[0].chain;
16232
16296
  childResults.slice(1).forEach((item) => {
16233
- expression = expression.attr(identifiers.and).call(item.meta.hasLazy ? $(z).attr(identifiers.lazy).call($.func().do(item.expression.return())) : item.expression);
16297
+ chain = chain.attr(identifiers.and).call(item.meta.hasLazy ? $(z).attr(identifiers.lazy).call($.func().do(item.chain.return())) : item.chain);
16234
16298
  });
16235
- return expression;
16299
+ return chain;
16236
16300
  }
16237
16301
  function intersectionResolver(ctx) {
16238
16302
  const baseResult = ctx.nodes.base(ctx);
@@ -16255,8 +16319,8 @@ function intersectionToAst({ childResults, parentSchema, path, plugin, schemas }
16255
16319
  };
16256
16320
  const resolver = plugin.config["~resolvers"]?.intersection;
16257
16321
  return {
16258
- childResults,
16259
- expression: resolver?.(ctx) ?? intersectionResolver(ctx)
16322
+ chain: resolver?.(ctx) ?? intersectionResolver(ctx),
16323
+ childResults
16260
16324
  };
16261
16325
  }
16262
16326
  //#endregion
@@ -16389,7 +16453,7 @@ function additionalPropertiesNode(ctx) {
16389
16453
  plugin
16390
16454
  }, "additionalProperties"));
16391
16455
  _childResults.push(additionalResult);
16392
- return applyModifiers(additionalResult, {}).expression;
16456
+ return applyModifiers(additionalResult, {}).chain;
16393
16457
  }
16394
16458
  function baseNode$5(ctx) {
16395
16459
  const { nodes, symbols } = ctx;
@@ -16414,7 +16478,7 @@ function shapeNode(ctx) {
16414
16478
  }, "properties", name));
16415
16479
  _childResults.push(propertyResult);
16416
16480
  const finalExpr = applyModifiers(propertyResult, { optional: isOptional });
16417
- shape.prop(name, finalExpr.expression);
16481
+ shape.prop(name, finalExpr.chain);
16418
16482
  }
16419
16483
  return shape;
16420
16484
  }
@@ -16439,8 +16503,8 @@ function objectToAst({ applyModifiers, path, plugin, schema, walk }) {
16439
16503
  };
16440
16504
  const resolver = plugin.config["~resolvers"]?.object;
16441
16505
  return {
16442
- childResults,
16443
- expression: resolver?.(ctx) ?? objectResolver(ctx)
16506
+ chain: resolver?.(ctx) ?? objectResolver(ctx),
16507
+ childResults
16444
16508
  };
16445
16509
  }
16446
16510
  //#endregion
@@ -16545,7 +16609,7 @@ function baseNode$3(ctx) {
16545
16609
  const { z } = symbols;
16546
16610
  const tupleFn = $(z).attr(identifiers.tuple);
16547
16611
  if (!childResults.length) return tupleFn.call($.array());
16548
- const tupleElements = childResults.map((result) => applyModifiers(result, { optional: false }).expression);
16612
+ const tupleElements = childResults.map((result) => applyModifiers(result, { optional: false }).chain);
16549
16613
  return tupleFn.call($.array(...tupleElements));
16550
16614
  }
16551
16615
  function constNode(ctx) {
@@ -16592,8 +16656,8 @@ function tupleToAst({ applyModifiers, path, plugin, schema, walk }) {
16592
16656
  };
16593
16657
  const resolver = plugin.config["~resolvers"]?.tuple;
16594
16658
  return {
16595
- childResults,
16596
- expression: resolver?.(ctx) ?? tupleResolver(ctx)
16659
+ chain: resolver?.(ctx) ?? tupleResolver(ctx),
16660
+ childResults
16597
16661
  };
16598
16662
  }
16599
16663
  //#endregion
@@ -16633,9 +16697,9 @@ function baseNode$1(ctx) {
16633
16697
  const schema = schemas[index];
16634
16698
  if (schema.type !== "null" && schema.const !== null) nonNullItems.push(result);
16635
16699
  });
16636
- let expression;
16637
- if (!nonNullItems.length) expression = $(z).attr(identifiers.null).call();
16638
- else if (nonNullItems.length === 1) expression = nonNullItems[0].expression;
16700
+ let chain;
16701
+ if (!nonNullItems.length) chain = $(z).attr(identifiers.null).call();
16702
+ else if (nonNullItems.length === 1) chain = nonNullItems[0].chain;
16639
16703
  else {
16640
16704
  const discriminatedExpression = tryBuildDiscriminatedUnion({
16641
16705
  items: childResults,
@@ -16645,10 +16709,10 @@ function baseNode$1(ctx) {
16645
16709
  });
16646
16710
  if (discriminatedExpression) {
16647
16711
  const unionMembers = discriminatedExpression.members.map((member) => member.refExpression.attr(identifiers.extend).call($.object().prop(discriminatedExpression.discriminatorKey, $(z).attr(identifiers.literal).call($.fromValue(member.discriminatedValue)))));
16648
- expression = $(z).attr(identifiers.discriminatedUnion).call($.literal(discriminatedExpression.discriminatorKey), $.array().pretty().elements(...unionMembers));
16649
- } else expression = $(z).attr(identifiers.union).call($.array().pretty().elements(...nonNullItems.map((item) => item.expression)));
16712
+ chain = $(z).attr(identifiers.discriminatedUnion).call($.literal(discriminatedExpression.discriminatorKey), $.array().pretty().elements(...unionMembers));
16713
+ } else chain = $(z).attr(identifiers.union).call($.array().pretty().elements(...nonNullItems.map((item) => item.chain)));
16650
16714
  }
16651
- return expression;
16715
+ return chain;
16652
16716
  }
16653
16717
  function unionResolver(ctx) {
16654
16718
  const baseResult = ctx.nodes.base(ctx);
@@ -16671,8 +16735,8 @@ function unionToAst({ childResults, parentSchema, path, plugin, schemas }) {
16671
16735
  };
16672
16736
  const resolver = plugin.config["~resolvers"]?.union;
16673
16737
  return {
16674
- childResults,
16675
- expression: resolver?.(ctx) ?? unionResolver(ctx)
16738
+ chain: resolver?.(ctx) ?? unionResolver(ctx),
16739
+ childResults
16676
16740
  };
16677
16741
  }
16678
16742
  //#endregion
@@ -16706,54 +16770,54 @@ function voidToAst({ path, plugin, schema }) {
16706
16770
  function getDefaultValue(meta) {
16707
16771
  return meta.format ? maybeBigInt(meta.default, meta.format) : $.fromValue(meta.default);
16708
16772
  }
16709
- function createVisitor(config = {}) {
16710
- const { schemaExtractor } = config;
16773
+ function createVisitor(config) {
16774
+ const { plugin, schemaExtractor } = config;
16775
+ const z = plugin.external("zod.z");
16711
16776
  return {
16712
16777
  applyModifiers(result, ctx, options = {}) {
16713
16778
  const { optional } = options;
16714
- let expression = result.expression;
16715
- if (result.meta.readonly) expression = expression.attr(identifiers.readonly).call();
16779
+ let chain = result.chain;
16780
+ if (result.meta.readonly) chain = chain.attr(identifiers.readonly).call();
16716
16781
  const needsDefault = result.meta.default !== void 0;
16717
16782
  const needsNullable = result.meta.nullable;
16718
- if (optional && needsNullable) expression = expression.attr(identifiers.nullish).call();
16719
- else if (optional) expression = expression.attr(identifiers.optional).call();
16720
- else if (needsNullable) expression = expression.attr(identifiers.nullable).call();
16721
- if (needsDefault) expression = expression.attr(identifiers.default).call(getDefaultValue(result.meta));
16722
- return { expression };
16783
+ if (optional && needsNullable) chain = chain.attr(identifiers.nullish).call();
16784
+ else if (optional) chain = chain.attr(identifiers.optional).call();
16785
+ else if (needsNullable) chain = chain.attr(identifiers.nullable).call();
16786
+ if (needsDefault) chain = chain.attr(identifiers.default).call(getDefaultValue(result.meta));
16787
+ return { chain };
16723
16788
  },
16724
16789
  array(schema, ctx, walk) {
16725
- const applyModifiers = (result, opts) => this.applyModifiers(result, ctx, opts);
16726
- const { childResults, expression } = arrayToAst({
16727
- applyModifiers,
16790
+ const { chain, childResults } = arrayToAst({
16791
+ applyModifiers: (result, opts) => this.applyModifiers(result, ctx, opts),
16728
16792
  path: ctx.path,
16729
- plugin: ctx.plugin,
16793
+ plugin,
16730
16794
  schema,
16731
16795
  walk
16732
16796
  });
16733
16797
  return {
16734
- expression,
16798
+ chain,
16735
16799
  meta: inheritMeta(schema, childResults)
16736
16800
  };
16737
16801
  },
16738
16802
  boolean(schema, ctx) {
16739
16803
  return {
16740
- expression: booleanToAst({
16804
+ chain: booleanToAst({
16741
16805
  path: ctx.path,
16742
- plugin: ctx.plugin,
16806
+ plugin,
16743
16807
  schema
16744
16808
  }),
16745
16809
  meta: defaultMeta(schema)
16746
16810
  };
16747
16811
  },
16748
16812
  enum(schema, ctx) {
16749
- const expression = enumToAst({
16813
+ const chain = enumToAst({
16750
16814
  path: ctx.path,
16751
- plugin: ctx.plugin,
16815
+ plugin,
16752
16816
  schema
16753
16817
  });
16754
16818
  const hasNull = schema.items?.some((item) => item.type === "null" || item.const === null) ?? false;
16755
16819
  return {
16756
- expression,
16820
+ chain,
16757
16821
  meta: {
16758
16822
  ...defaultMeta(schema),
16759
16823
  nullable: hasNull
@@ -16762,9 +16826,9 @@ function createVisitor(config = {}) {
16762
16826
  },
16763
16827
  integer(schema, ctx) {
16764
16828
  return {
16765
- expression: numberToNode({
16829
+ chain: numberToNode({
16766
16830
  path: ctx.path,
16767
- plugin: ctx.plugin,
16831
+ plugin,
16768
16832
  schema
16769
16833
  }),
16770
16834
  meta: {
@@ -16780,29 +16844,29 @@ function createVisitor(config = {}) {
16780
16844
  resource: "definition",
16781
16845
  resourceId: pathToJsonPointer(fromRef(ctx.path))
16782
16846
  },
16783
- naming: ctx.plugin.config.definitions,
16847
+ naming: plugin.config.definitions,
16784
16848
  path: fromRef(ctx.path),
16785
- plugin: ctx.plugin,
16849
+ plugin,
16786
16850
  schema
16787
16851
  });
16788
16852
  if (extracted !== schema) return walk(extracted, ctx);
16789
16853
  }
16790
16854
  if (schema.symbolRef) return {
16791
- expression: $(schema.symbolRef),
16855
+ chain: $(schema.symbolRef),
16792
16856
  meta: defaultMeta(schema)
16793
16857
  };
16794
16858
  },
16795
16859
  intersection(items, schemas, parentSchema, ctx) {
16796
16860
  const hasAnyLazy = items.some((item) => item.meta.hasLazy);
16797
- const { expression } = intersectionToAst({
16861
+ const { chain } = intersectionToAst({
16798
16862
  childResults: items,
16799
16863
  parentSchema,
16800
16864
  path: ctx.path,
16801
- plugin: ctx.plugin,
16865
+ plugin,
16802
16866
  schemas
16803
16867
  });
16804
16868
  return {
16805
- expression,
16869
+ chain,
16806
16870
  meta: {
16807
16871
  default: parentSchema.default,
16808
16872
  format: parentSchema.format,
@@ -16816,9 +16880,9 @@ function createVisitor(config = {}) {
16816
16880
  },
16817
16881
  never(schema, ctx) {
16818
16882
  return {
16819
- expression: neverToAst({
16883
+ chain: neverToAst({
16820
16884
  path: ctx.path,
16821
- plugin: ctx.plugin,
16885
+ plugin,
16822
16886
  schema
16823
16887
  }),
16824
16888
  meta: {
@@ -16830,9 +16894,9 @@ function createVisitor(config = {}) {
16830
16894
  },
16831
16895
  null(schema, ctx) {
16832
16896
  return {
16833
- expression: nullToAst({
16897
+ chain: nullToAst({
16834
16898
  path: ctx.path,
16835
- plugin: ctx.plugin,
16899
+ plugin,
16836
16900
  schema
16837
16901
  }),
16838
16902
  meta: {
@@ -16844,9 +16908,9 @@ function createVisitor(config = {}) {
16844
16908
  },
16845
16909
  number(schema, ctx) {
16846
16910
  return {
16847
- expression: numberToNode({
16911
+ chain: numberToNode({
16848
16912
  path: ctx.path,
16849
- plugin: ctx.plugin,
16913
+ plugin,
16850
16914
  schema
16851
16915
  }),
16852
16916
  meta: {
@@ -16856,21 +16920,20 @@ function createVisitor(config = {}) {
16856
16920
  };
16857
16921
  },
16858
16922
  object(schema, ctx, walk) {
16859
- const applyModifiers = (result, opts) => this.applyModifiers(result, ctx, opts);
16860
- const { childResults, expression } = objectToAst({
16861
- applyModifiers,
16923
+ const { chain, childResults } = objectToAst({
16924
+ applyModifiers: (result, opts) => this.applyModifiers(result, ctx, opts),
16862
16925
  path: ctx.path,
16863
- plugin: ctx.plugin,
16926
+ plugin,
16864
16927
  schema,
16865
16928
  walk
16866
16929
  });
16867
16930
  return {
16868
- expression,
16931
+ chain,
16869
16932
  meta: inheritMeta(schema, childResults)
16870
16933
  };
16871
16934
  },
16872
- postProcess(result, schema, ctx) {
16873
- const { metadata } = ctx.plugin.config;
16935
+ postProcess(result, schema) {
16936
+ const { metadata } = plugin.config;
16874
16937
  if (!metadata) return result;
16875
16938
  const node = $.object();
16876
16939
  if (metadata === true) {
@@ -16882,27 +16945,25 @@ function createVisitor(config = {}) {
16882
16945
  schema
16883
16946
  });
16884
16947
  if (node.isEmpty) return result;
16885
- const z = ctx.plugin.external("zod.z");
16886
16948
  return {
16887
16949
  ...result,
16888
- expression: result.expression.attr(identifiers.register).call($(z).attr(identifiers.globalRegistry), node)
16950
+ chain: result.chain.attr(identifiers.register).call($(z).attr(identifiers.globalRegistry), node)
16889
16951
  };
16890
16952
  },
16891
- reference($ref, schema, ctx) {
16892
- const z = ctx.plugin.external("zod.z");
16953
+ reference($ref, schema) {
16893
16954
  const query = {
16894
16955
  category: "schema",
16895
16956
  resource: "definition",
16896
16957
  resourceId: $ref,
16897
16958
  tool: "zod"
16898
16959
  };
16899
- const refSymbol = ctx.plugin.referenceSymbol(query);
16900
- if (ctx.plugin.isSymbolRegistered(query)) return {
16901
- expression: $(refSymbol),
16960
+ const refSymbol = plugin.referenceSymbol(query);
16961
+ if (plugin.isSymbolRegistered(query)) return {
16962
+ chain: $(refSymbol),
16902
16963
  meta: defaultMeta(schema)
16903
16964
  };
16904
16965
  return {
16905
- expression: $(z).attr(identifiers.lazy).call($.func().returns("any").do($(refSymbol).return())),
16966
+ chain: $(z).attr(identifiers.lazy).call($.func().returns("any").do($(refSymbol).return())),
16906
16967
  meta: {
16907
16968
  ...defaultMeta(schema),
16908
16969
  hasLazy: true,
@@ -16912,9 +16973,9 @@ function createVisitor(config = {}) {
16912
16973
  },
16913
16974
  string(schema, ctx) {
16914
16975
  if (shouldCoerceToBigInt(schema.format)) return {
16915
- expression: numberToNode({
16976
+ chain: numberToNode({
16916
16977
  path: ctx.path,
16917
- plugin: ctx.plugin,
16978
+ plugin,
16918
16979
  schema: {
16919
16980
  ...schema,
16920
16981
  type: "number"
@@ -16923,33 +16984,32 @@ function createVisitor(config = {}) {
16923
16984
  meta: defaultMeta(schema)
16924
16985
  };
16925
16986
  return {
16926
- expression: stringToNode({
16987
+ chain: stringToNode({
16927
16988
  path: ctx.path,
16928
- plugin: ctx.plugin,
16989
+ plugin,
16929
16990
  schema
16930
16991
  }),
16931
16992
  meta: defaultMeta(schema)
16932
16993
  };
16933
16994
  },
16934
16995
  tuple(schema, ctx, walk) {
16935
- const applyModifiers = (result, opts) => this.applyModifiers(result, ctx, opts);
16936
- const { childResults, expression } = tupleToAst({
16937
- applyModifiers,
16996
+ const { chain, childResults } = tupleToAst({
16997
+ applyModifiers: (result, opts) => this.applyModifiers(result, ctx, opts),
16938
16998
  path: ctx.path,
16939
- plugin: ctx.plugin,
16999
+ plugin,
16940
17000
  schema,
16941
17001
  walk
16942
17002
  });
16943
17003
  return {
16944
- expression,
17004
+ chain,
16945
17005
  meta: inheritMeta(schema, childResults)
16946
17006
  };
16947
17007
  },
16948
17008
  undefined(schema, ctx) {
16949
17009
  return {
16950
- expression: undefinedToAst({
17010
+ chain: undefinedToAst({
16951
17011
  path: ctx.path,
16952
- plugin: ctx.plugin,
17012
+ plugin,
16953
17013
  schema
16954
17014
  }),
16955
17015
  meta: {
@@ -16962,15 +17022,15 @@ function createVisitor(config = {}) {
16962
17022
  union(items, schemas, parentSchema, ctx) {
16963
17023
  const hasAnyLazy = items.some((item) => item.meta.hasLazy);
16964
17024
  const hasNull = schemas.some((s) => s.type === "null") || items.some((i) => i.meta.nullable);
16965
- const { expression } = unionToAst({
17025
+ const { chain } = unionToAst({
16966
17026
  childResults: items,
16967
17027
  parentSchema,
16968
17028
  path: ctx.path,
16969
- plugin: ctx.plugin,
17029
+ plugin,
16970
17030
  schemas
16971
17031
  });
16972
17032
  return {
16973
- expression,
17033
+ chain,
16974
17034
  meta: {
16975
17035
  default: parentSchema.default,
16976
17036
  format: parentSchema.format,
@@ -16984,9 +17044,9 @@ function createVisitor(config = {}) {
16984
17044
  },
16985
17045
  unknown(schema, ctx) {
16986
17046
  return {
16987
- expression: unknownToAst({
17047
+ chain: unknownToAst({
16988
17048
  path: ctx.path,
16989
- plugin: ctx.plugin,
17049
+ plugin,
16990
17050
  schema
16991
17051
  }),
16992
17052
  meta: {
@@ -16998,9 +17058,9 @@ function createVisitor(config = {}) {
16998
17058
  },
16999
17059
  void(schema, ctx) {
17000
17060
  return {
17001
- expression: voidToAst({
17061
+ chain: voidToAst({
17002
17062
  path: ctx.path,
17003
- plugin: ctx.plugin,
17063
+ plugin,
17004
17064
  schema
17005
17065
  }),
17006
17066
  meta: {
@@ -17016,10 +17076,10 @@ function createVisitor(config = {}) {
17016
17076
  //#region src/plugins/zod/v4/processor.ts
17017
17077
  function createProcessor(plugin) {
17018
17078
  const processor = createSchemaProcessor();
17019
- const extractorHooks = [plugin.config["~hooks"]?.schemas?.shouldExtract, plugin.context.config.parser.hooks.schemas?.shouldExtract];
17020
- function extractor(ctx) {
17079
+ const extractorHooks = plugin.getHooks((hooks) => hooks.schemas?.shouldExtract);
17080
+ const schemaExtractor = (ctx) => {
17021
17081
  if (processor.hasEmitted(ctx.path)) return ctx.schema;
17022
- for (const hook of extractorHooks) if (typeof hook === "boolean" ? hook : hook?.(ctx) ?? false) {
17082
+ for (const hook of extractorHooks) if (typeof hook === "boolean" ? hook : hook(ctx)) {
17023
17083
  process({
17024
17084
  namingAnchor: processor.context.anchor,
17025
17085
  tags: processor.context.tags,
@@ -17028,7 +17088,7 @@ function createProcessor(plugin) {
17028
17088
  return { $ref: pathToJsonPointer(ctx.path) };
17029
17089
  }
17030
17090
  return ctx.schema;
17031
- }
17091
+ };
17032
17092
  function process(ctx) {
17033
17093
  if (!processor.markEmitted(ctx.path)) return;
17034
17094
  const shouldExport = ctx.export !== false;
@@ -17036,7 +17096,10 @@ function createProcessor(plugin) {
17036
17096
  anchor: ctx.namingAnchor,
17037
17097
  tags: ctx.tags
17038
17098
  }, () => {
17039
- const visitor = createVisitor({ schemaExtractor: extractor });
17099
+ const visitor = createVisitor({
17100
+ plugin,
17101
+ schemaExtractor
17102
+ });
17040
17103
  const result = createSchemaWalker(visitor)(ctx.schema, {
17041
17104
  path: ref(ctx.path),
17042
17105
  plugin
@@ -17924,4 +17987,4 @@ async function resolveJobs({ logger, userConfigs }) {
17924
17987
  //#endregion
17925
17988
  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 };
17926
17989
 
17927
- //# sourceMappingURL=init-CitwzRmB.mjs.map
17990
+ //# sourceMappingURL=init-D3VuY80Z.mjs.map