@sdk-it/core 0.46.11 → 0.47.0

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.
Files changed (46) hide show
  1. package/README.md +22 -12
  2. package/dist/index.d.ts +2 -2
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +2 -2
  5. package/dist/index.js.map +1 -1
  6. package/dist/lib/derived-type.d.ts +3 -0
  7. package/dist/lib/derived-type.d.ts.map +1 -0
  8. package/dist/lib/derived-type.js +7 -0
  9. package/dist/lib/derived-type.js.map +7 -0
  10. package/dist/lib/deriver.d.ts +13 -9
  11. package/dist/lib/deriver.d.ts.map +1 -1
  12. package/dist/lib/deriver.js +193 -243
  13. package/dist/lib/deriver.js.map +3 -3
  14. package/dist/lib/file-system.d.ts +0 -8
  15. package/dist/lib/file-system.d.ts.map +1 -1
  16. package/dist/lib/file-system.js +8 -39
  17. package/dist/lib/file-system.js.map +2 -2
  18. package/dist/lib/json-pointer.d.ts +13 -0
  19. package/dist/lib/json-pointer.d.ts.map +1 -0
  20. package/dist/lib/json-pointer.js +20 -0
  21. package/dist/lib/json-pointer.js.map +7 -0
  22. package/dist/lib/paths.d.ts +27 -8
  23. package/dist/lib/paths.d.ts.map +1 -1
  24. package/dist/lib/paths.js +165 -96
  25. package/dist/lib/paths.js.map +3 -3
  26. package/dist/lib/program.d.ts +19 -6
  27. package/dist/lib/program.d.ts.map +1 -1
  28. package/dist/lib/program.js +61 -62
  29. package/dist/lib/program.js.map +2 -2
  30. package/dist/lib/ref.d.ts +5 -5
  31. package/dist/lib/ref.d.ts.map +1 -1
  32. package/dist/lib/ref.js +28 -8
  33. package/dist/lib/ref.js.map +2 -2
  34. package/dist/lib/security.d.ts.map +1 -1
  35. package/dist/lib/utils.d.ts +9 -6
  36. package/dist/lib/utils.d.ts.map +1 -1
  37. package/dist/lib/utils.js +1 -1
  38. package/dist/lib/utils.js.map +2 -2
  39. package/dist/lib/zod-jsonschema.d.ts.map +1 -1
  40. package/dist/lib/zod-jsonschema.js +111 -93
  41. package/dist/lib/zod-jsonschema.js.map +2 -2
  42. package/package.json +17 -12
  43. package/dist/lib/spec-json.d.ts +0 -23
  44. package/dist/lib/spec-json.d.ts.map +0 -1
  45. package/dist/lib/spec-json.js +0 -11
  46. package/dist/lib/spec-json.js.map +0 -7
@@ -8,7 +8,7 @@ async function evalZod(schema, imports = []) {
8
8
  `const require = createRequire(filename);`,
9
9
  `const z = require("zod");`,
10
10
  `if (typeof z.toJSONSchema !== 'function') {
11
- throw new Error('@sdk-it/core requires Zod 4. Install zod@^4.3.0 and migrate Zod 3 schemas before analysis.');
11
+ throw new Error('@sdk-it/core requires Zod 4. Install zod@^4.6.7 and migrate Zod 3 schemas before analysis.');
12
12
  }`,
13
13
  // zod 4 removed ZodString.ip/.cidr; restore them for analyzed user source
14
14
  // that still uses the v3 spellings.
@@ -373,16 +373,6 @@ async function evalZod(schema, imports = []) {
373
373
  delete schema.propertyNames;
374
374
  }
375
375
 
376
- if (
377
- typeof schema.$ref === 'string' &&
378
- !schema.$ref.startsWith('#/components/schemas')
379
- ) {
380
- schema.$ref =
381
- schema.$ref === '#'
382
- ? '#/components/schemas'
383
- : schema.$ref.replace(/^#\\//, '#/components/schemas/');
384
- }
385
-
386
376
  if (Array.isArray(schema.allOf)) {
387
377
  const merged = mergePrimitiveSchemas(schema.allOf);
388
378
  if (merged) {
@@ -396,96 +386,119 @@ async function evalZod(schema, imports = []) {
396
386
 
397
387
  return schema;
398
388
  }`,
399
- `function escapePointerSegment(segment) {
400
- return String(segment).replaceAll('~', '~0').replaceAll('/', '~1');
389
+ `const components = Object.create(null);`,
390
+ `function addComponent(name, schema) {
391
+ if (
392
+ name in components &&
393
+ JSON.stringify(components[name]) !== JSON.stringify(schema)
394
+ ) {
395
+ throw new Error(
396
+ 'Two different schemas share the id "' + name + '"; give each its own .meta({ id }).',
397
+ );
398
+ }
399
+ components[name] = schema;
401
400
  }`,
402
- `function componentPointer(path) {
403
- return ['#', 'components', 'schemas', ...path.map(escapePointerSegment)].join('/');
401
+ `function definitionName(ref) {
402
+ return typeof ref === 'string' && ref.startsWith('#/definitions/')
403
+ ? ref.slice('#/definitions/'.length)
404
+ : undefined;
404
405
  }`,
405
- // Nested toJsonSchema passes (set/map values, pipe outputs) return
406
- // self-contained draft-7 documents whose '#' and '#/definitions/*' refs
407
- // are relative to the embedded document root, not the outer schema.
408
- // Resolve them to outer-root structural pointers before the outer
409
- // definitions/normalize passes rewrite them into dangling refs.
410
- `function resolveEmbeddedDocs(root) {
411
- function process(node, path, docRoot) {
412
- if (!node || typeof node !== 'object') return;
413
- if (Array.isArray(node)) {
414
- node.forEach((item, index) => process(item, [...path, index], docRoot));
415
- return;
416
- }
417
- if (node['x-sdkit-embedded-root']) {
418
- delete node['x-sdkit-embedded-root'];
419
- const defs = node.definitions ?? Object.create(null);
420
- delete node.definitions;
421
- docRoot = { path, defs, firstSite: Object.create(null) };
422
- }
423
- if (docRoot && typeof node.$ref === 'string') {
424
- if (node.$ref === '#') {
425
- node.$ref = componentPointer(docRoot.path);
426
- return;
427
- }
428
- const match = node.$ref.match(/^#\\/definitions\\/(.+)$/);
429
- if (match) {
430
- const name = match[1];
431
- if (name in docRoot.firstSite) {
432
- node.$ref = docRoot.firstSite[name];
433
- return;
434
- }
435
- docRoot.firstSite[name] = componentPointer(path);
436
- delete node.$ref;
437
- Object.assign(node, docRoot.defs[name]);
438
- }
439
- }
440
- for (const [key, value] of Object.entries(node)) {
441
- process(value, [...path, key], docRoot);
442
- }
406
+ `function isAnonymous(name) {
407
+ return /^__schema[0-9]+$/.test(name);
408
+ }`,
409
+ // .meta({ id }) on a schema whose cycle zod already named (z.json() is
410
+ // one) writes the id as { allOf: [{ $ref: anonymous }] }: the id names
411
+ // that anonymous definition.
412
+ `function aliasedDefinition(schema) {
413
+ if (
414
+ Object.keys(schema).length !== 1 ||
415
+ !Array.isArray(schema.allOf) ||
416
+ schema.allOf.length !== 1
417
+ ) {
418
+ return undefined;
443
419
  }
444
- process(root, [], null);
445
- return root;
420
+ const name = definitionName(schema.allOf[0]?.$ref);
421
+ return name && isAnonymous(name) ? name : undefined;
446
422
  }`,
447
- // zod v4 breaks non-root cycles with a draft-7 definitions block plus
448
- // #/definitions/* refs, which OpenAPI consumers cannot resolve. Inline
449
- // each definition at its first use site and point the remaining
450
- // (recursive) refs structurally at that site, mirroring the v3
451
- // $refStrategy: 'root' output.
452
- `function inlineDefinitions(root) {
453
- const defs = root.definitions;
454
- if (!defs || typeof defs !== 'object') return root;
455
- delete root.definitions;
456
- const firstSite = Object.create(null);
457
- function walk(node, path) {
458
- if (!node || typeof node !== 'object') return;
459
- if (Array.isArray(node)) {
460
- node.forEach((item, index) => walk(item, [...path, index]));
461
- return;
423
+ `function refersTo(node, ref) {
424
+ if (!node || typeof node !== 'object') return false;
425
+ if (node.$ref === ref) return true;
426
+ return Object.values(node).some((child) => refersTo(child, ref));
427
+ }`,
428
+ // zod writes every schema that carries an id, and every cycle, as a draft-7
429
+ // definition; a root with an id becomes a $ref to its own definition, and
430
+ // an id-less root that cycles refers to itself as '#'. Each named
431
+ // definition becomes a component the refs point at; a cycle without a name
432
+ // cannot become one.
433
+ `function extractComponents(doc, rootId) {
434
+ const { definitions = {}, ...root } = doc;
435
+ const names = Object.create(null);
436
+ const aliases = new Set();
437
+ for (const name of Object.keys(definitions)) {
438
+ if (!isAnonymous(name)) names[name] = name;
439
+ }
440
+ for (const [name, definition] of Object.entries(definitions)) {
441
+ const anonymous = names[name] && aliasedDefinition(definition);
442
+ if (anonymous && !(anonymous in names)) {
443
+ names[anonymous] = name;
444
+ aliases.add(name);
462
445
  }
463
- const match =
464
- typeof node.$ref === 'string' &&
465
- node.$ref.match(/^#\\/definitions\\/(.+)$/);
466
- if (match) {
467
- const name = match[1];
468
- if (name in firstSite) {
469
- node.$ref = firstSite[name];
470
- return;
446
+ }
447
+ if (
448
+ Object.keys(definitions).some((name) => !(name in names)) ||
449
+ (!rootId && refersTo(root, '#'))
450
+ ) {
451
+ throw new Error(
452
+ 'A recursive schema has no name; give it .meta({ id }) so it becomes a named component.',
453
+ );
454
+ }
455
+ function rewrite(node) {
456
+ if (Array.isArray(node)) return node.map(rewrite);
457
+ if (!node || typeof node !== 'object') return node;
458
+ const rewritten = {};
459
+ for (const [key, value] of Object.entries(node)) {
460
+ const target = key === '$ref' ? definitionName(value) : undefined;
461
+ if (target) {
462
+ rewritten.$ref = '#/components/schemas/' + names[target];
463
+ } else {
464
+ rewritten[key] = rewrite(value);
471
465
  }
472
- firstSite[name] = componentPointer(path);
473
- delete node.$ref;
474
- Object.assign(node, defs[name]);
475
466
  }
476
- for (const [key, value] of Object.entries(node)) {
477
- walk(value, [...path, key]);
467
+ return rewritten;
468
+ }
469
+ for (const [name, definition] of Object.entries(definitions)) {
470
+ if (!aliases.has(name)) {
471
+ addComponent(names[name], normalizeSchema(rewrite(definition)));
478
472
  }
479
473
  }
480
- walk(root, []);
481
- return root;
474
+ return rewrite(root);
475
+ }`,
476
+ // Nested toJsonSchema passes (set/map values, pipe outputs) return
477
+ // self-contained documents whose '#' and '#/definitions/*' refs are
478
+ // relative to their own root; each is lifted on its own, innermost first.
479
+ `function liftEmbedded(node) {
480
+ if (Array.isArray(node)) return node.map(liftEmbedded);
481
+ if (!node || typeof node !== 'object') return node;
482
+ const lifted = {};
483
+ for (const [key, value] of Object.entries(node)) {
484
+ lifted[key] = liftEmbedded(value);
485
+ }
486
+ if (!lifted['x-sdkit-embedded-root']) return lifted;
487
+ const {
488
+ 'x-sdkit-embedded-root': _root,
489
+ 'x-sdkit-embedded-id': id,
490
+ ...doc
491
+ } = lifted;
492
+ return extractComponents(doc, id);
482
493
  }`,
483
- // Wraps nested conversions: when the embedded document carries refs or a
484
- // definitions block, tag its root so resolveEmbeddedDocs can rebase them.
494
+ // Wraps nested conversions: when the embedded document carries an id,
495
+ // refs or a definitions block, tag its root so liftEmbedded extracts it.
485
496
  `function convertEmbedded(schema) {
486
497
  const { $schema: _ignored, ...doc } = toJsonSchema(schema);
487
- if (doc.definitions || JSON.stringify(doc).includes('"$ref"')) {
498
+ const id = z.globalRegistry.get(schema)?.id;
499
+ if (id || doc.definitions || JSON.stringify(doc).includes('"$ref"')) {
488
500
  doc['x-sdkit-embedded-root'] = true;
501
+ if (id) doc['x-sdkit-embedded-id'] = id;
489
502
  }
490
503
  return doc;
491
504
  }`,
@@ -507,8 +520,8 @@ async function evalZod(schema, imports = []) {
507
520
  }
508
521
  if (def.type === 'bigint') {
509
522
  json.type = 'integer';
510
- // z.bigint() carries no format; treat it as int64.
511
- json.format = ctx.zodSchema._zod.bag.format ?? 'int64';
523
+ // z.bigint()'s format is null; treat it as int64.
524
+ json.format = ctx.zodSchema.format ?? 'int64';
512
525
  if (def.coerce) {
513
526
  json['x-zod-type'] = 'coerce-bigint';
514
527
  }
@@ -567,7 +580,9 @@ async function evalZod(schema, imports = []) {
567
580
  if (def.type === 'pipe') {
568
581
  const outJson = convertEmbedded(def.out);
569
582
  const outKeys = Object.keys(outJson).filter(
570
- (key) => key !== 'x-sdkit-embedded-root',
583
+ (key) =>
584
+ key !== 'x-sdkit-embedded-root' &&
585
+ key !== 'x-sdkit-embedded-id',
571
586
  );
572
587
  if (outKeys.length > 0) {
573
588
  const inJson = { ...json };
@@ -614,7 +629,10 @@ async function evalZod(schema, imports = []) {
614
629
  }
615
630
  unmaskBigIntDefaults(rawResult);
616
631
  const result = normalizeSchema(
617
- inlineDefinitions(resolveEmbeddedDocs(rawResult)),
632
+ extractComponents(
633
+ liftEmbedded(rawResult),
634
+ z.globalRegistry.get(zodSchema)?.id,
635
+ ),
618
636
  );`,
619
637
  `const innerDef = unwrapSchemaDef(zodSchema._zod.def);
620
638
  if (innerDef?.coerce && !result['x-zod-type']) {
@@ -623,7 +641,7 @@ async function evalZod(schema, imports = []) {
623
641
  result['x-zod-type'] = zodType;
624
642
  }
625
643
  }`,
626
- `export default {schema: result, optional}`
644
+ `export default {schema: result, optional, components}`
627
645
  ];
628
646
  const base64 = Buffer.from(lines.join("\n")).toString("base64");
629
647
  return import(
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/lib/zod-jsonschema.ts"],
4
- "sourcesContent": ["export type InjectImport = {\n import: string;\n from: string;\n property?: string;\n};\n\nfunction removeUnsupportedMethods(schema: string) {\n return schema\n .replaceAll('.instanceof(File)', '.string().base64()')\n .replaceAll('.instanceof(Blob)', '.string().base64()')\n .replaceAll('.custom<File>()', '.string().base64()')\n .replaceAll('.custom<Blob>()', '.string().base64()');\n}\n\nexport async function evalZod(schema: string, imports: InjectImport[] = []) {\n // https://github.com/nodejs/node/issues/51956\n const lines = [\n `import { createRequire } from \"node:module\";`,\n `const filename = \"${import.meta.url}\";`,\n `const require = createRequire(filename);`,\n `const z = require(\"zod\");`,\n `if (typeof z.toJSONSchema !== 'function') {\n throw new Error('@sdk-it/core requires Zod 4. Install zod@^4.3.0 and migrate Zod 3 schemas before analysis.');\n }`,\n // zod 4 removed ZodString.ip/.cidr; restore them for analyzed user source\n // that still uses the v3 spellings.\n `const stringProto = Object.getPrototypeOf(z.string());\n const installedShims = [];\n function withReceiverChecks(receiver, format) {\n return (receiver._zod.def.checks ?? []).length\n ? z.intersection(receiver, format)\n : format;\n }\n if (!stringProto.ip) {\n installedShims.push('ip');\n stringProto.ip = function (options) {\n if (options?.version === 'v4') return withReceiverChecks(this, z.ipv4());\n if (options?.version === 'v6') return withReceiverChecks(this, z.ipv6());\n return withReceiverChecks(this, z.union([z.ipv4(), z.ipv6()]));\n };\n }\n if (!stringProto.cidr) {\n installedShims.push('cidr');\n stringProto.cidr = function (options) {\n if (options?.version === 'v4') return withReceiverChecks(this, z.cidrv4());\n if (options?.version === 'v6') return withReceiverChecks(this, z.cidrv6());\n return withReceiverChecks(this, z.union([z.cidrv4(), z.cidrv6()]));\n };\n }`,\n ...imports.map(\n (imp) =>\n `const ${imp.import} = require(${JSON.stringify(imp.from)})${\n imp.property ? `[${JSON.stringify(imp.property)}]` : ''\n };`,\n ),\n `let optional = false;`,\n `const WRAPPER_TYPES = new Set([\n 'optional',\n 'nullable',\n 'default',\n 'prefault',\n 'catch',\n 'readonly',\n 'nonoptional',\n ]);`,\n `function unwrapSchemaDef(def) {\n while (def) {\n if (WRAPPER_TYPES.has(def.type)) {\n def = def.innerType?._zod?.def;\n continue;\n }\n if (def.type === 'pipe') {\n def = def.in?._zod?.def;\n continue;\n }\n return def;\n }\n return def;\n }`,\n `function matchesDefType(schema, defType) {\n if (!schema || typeof schema !== 'object') return false;\n if (defType === 'number') {\n return schema.type === 'number' || schema.type === 'integer';\n }\n if (defType === 'bigint') {\n return schema.type === 'integer';\n }\n if (defType === 'string') {\n return schema.type === 'string';\n }\n if (defType === 'boolean') {\n return schema.type === 'boolean';\n }\n if (defType === 'date') {\n return schema.type === 'string' && schema.format === 'date-time';\n }\n return typeof schema.type === 'string';\n }`,\n `function applyZodType(schema, zodType, defType) {\n if (!schema || typeof schema !== 'object') return false;\n if (schema['x-zod-type']) return true;\n if (matchesDefType(schema, defType)) {\n schema['x-zod-type'] = zodType;\n return true;\n }\n for (const key of ['anyOf', 'oneOf', 'allOf']) {\n if (!Array.isArray(schema[key])) continue;\n const candidates = schema[key].filter(\n (candidate) => candidate && candidate.type !== 'null',\n );\n if (candidates.length === 1 && applyZodType(candidates[0], zodType, defType)) {\n return true;\n }\n for (const candidate of candidates) {\n if (applyZodType(candidate, zodType, defType)) {\n return true;\n }\n }\n }\n return false;\n }`,\n `const BIGINT_SENTINEL = '__sdkit_bigint__';`,\n // zod v4 JSON-round-trips default values before the override callback\n // runs, which throws on bigint. Mask them as sentinel strings up front\n // and restore after conversion.\n `function maskBigIntDefaults(schema, seen = new Set()) {\n if (!schema?._zod || schema._zod.version?.major !== 4) {\n throw new Error('@sdk-it/core requires Zod 4 schemas; migrate imported Zod 3 schemas before analysis.');\n }\n if (seen.has(schema)) return;\n seen.add(schema);\n const def = schema._zod.def;\n if (\n (def.type === 'default' || def.type === 'prefault') &&\n typeof def.defaultValue === 'bigint'\n ) {\n Object.defineProperty(def, 'defaultValue', {\n value: BIGINT_SENTINEL + def.defaultValue.toString(),\n configurable: true,\n });\n }\n for (const key of ['innerType', 'in', 'out', 'element', 'valueType', 'keyType', 'left', 'right', 'catchall', 'rest']) {\n if (def[key]) maskBigIntDefaults(def[key], seen);\n }\n if (typeof def.getter === 'function') {\n const inner = def.getter();\n maskBigIntDefaults(inner, seen);\n Object.defineProperty(def, 'getter', {\n value: () => inner,\n configurable: true,\n });\n }\n if (def.shape) {\n for (const value of Object.values(def.shape)) maskBigIntDefaults(value, seen);\n }\n if (Array.isArray(def.options)) {\n for (const option of def.options) maskBigIntDefaults(option, seen);\n }\n if (Array.isArray(def.items)) {\n for (const item of def.items) maskBigIntDefaults(item, seen);\n }\n }`,\n // int64 is a plain number in sdk-it, so masked bigint defaults unmask to\n // JS numbers \u2014 the spec stays plain JSON with no bigint values to trip up\n // JSON.stringify.\n `function unmaskBigIntDefaults(schema) {\n if (!schema || typeof schema !== 'object') return;\n for (const [key, value] of Object.entries(schema)) {\n if (typeof value === 'string' && value.startsWith(BIGINT_SENTINEL)) {\n schema[key] = Number(value.slice(BIGINT_SENTINEL.length));\n } else if (Array.isArray(value)) {\n value.forEach(unmaskBigIntDefaults);\n } else if (value && typeof value === 'object') {\n unmaskBigIntDefaults(value);\n }\n }\n }`,\n `function hasExplicitRegexCheck(def) {\n return (def.checks ?? []).some(\n (check) => check._zod?.def?.format === 'regex',\n );\n }`,\n `const STANDARD_STRING_FORMATS = new Set([\n 'email',\n 'uri',\n 'url',\n 'uuid',\n 'guid',\n 'date-time',\n 'date',\n 'time',\n 'duration',\n 'ipv4',\n 'ipv6',\n 'hostname',\n 'binary',\n ]);`,\n // Nonstandard formats that sdk-it's own converters map to semantic zod\n // validators. Keep both keys: format for our converters, pattern for\n // third-party validators that do not recognize the format.\n `const MAPPED_NONSTANDARD_FORMATS = new Set(['cidrv4', 'cidrv6']);`,\n `function normalizeDefaultValue(value) {\n return value instanceof Date ? value.toISOString() : value;\n }`,\n `function mergeComparableValue(target, key, value) {\n if (value === undefined) return true;\n const normalized = normalizeDefaultValue(value);\n if (target[key] === undefined) {\n target[key] = normalized;\n return true;\n }\n return Object.is(target[key], normalized);\n }`,\n `function mergeLowerBound(target, key, value) {\n if (value === undefined) return true;\n if (typeof value !== 'number') return false;\n if (target[key] === undefined || value > target[key]) {\n target[key] = value;\n }\n return true;\n }`,\n `function mergeUpperBound(target, key, value) {\n if (value === undefined) return true;\n if (typeof value !== 'number') return false;\n if (target[key] === undefined || value < target[key]) {\n target[key] = value;\n }\n return true;\n }`,\n `function mergeEnumValues(target, values) {\n if (!Array.isArray(values)) return false;\n if (!Array.isArray(target.enum)) {\n target.enum = [...values];\n return true;\n }\n target.enum = target.enum.filter((candidate) =>\n values.some((value) => Object.is(candidate, value)),\n );\n return target.enum.length > 0;\n }`,\n `function isMergeablePrimitiveSchema(schema) {\n return (\n schema &&\n typeof schema === 'object' &&\n !schema.$ref &&\n !schema.anyOf &&\n !schema.oneOf &&\n !schema.allOf &&\n (schema.type === 'string' ||\n schema.type === 'boolean' ||\n schema.type === 'number' ||\n schema.type === 'integer')\n );\n }`,\n `function isNumericPair(left, right) {\n return (\n (left.type === 'number' && right.type === 'integer') ||\n (left.type === 'integer' && right.type === 'number')\n );\n }`,\n `function mergePrimitiveSchemas(schemas) {\n const merged = {};\n for (const schema of schemas) {\n if (\n schema &&\n typeof schema === 'object' &&\n Object.keys(schema).length === 0\n ) {\n continue;\n }\n if (!isMergeablePrimitiveSchema(schema)) {\n return null;\n }\n if (merged.type === undefined) {\n merged.type = schema.type;\n } else if (merged.type !== schema.type) {\n if (!isNumericPair(merged, schema)) {\n return null;\n }\n merged.type = 'integer';\n }\n\n for (const [key, value] of Object.entries(schema)) {\n if (key === 'type') {\n continue;\n }\n switch (key) {\n case 'minimum':\n case 'exclusiveMinimum':\n case 'minLength':\n case 'minItems':\n case 'minProperties':\n if (!mergeLowerBound(merged, key, value)) {\n return null;\n }\n break;\n case 'maximum':\n case 'exclusiveMaximum':\n case 'maxLength':\n case 'maxItems':\n case 'maxProperties':\n if (!mergeUpperBound(merged, key, value)) {\n return null;\n }\n break;\n case 'enum':\n if (!mergeEnumValues(merged, value)) {\n return null;\n }\n break;\n default:\n if (!mergeComparableValue(merged, key, value)) {\n return null;\n }\n }\n }\n }\n return merged;\n }`,\n `function normalizeSchema(schema, isIntersectionMember = false) {\n if (!schema || typeof schema !== 'object') {\n return schema;\n }\n\n if (schema.default !== undefined) {\n schema.default = normalizeDefaultValue(schema.default);\n }\n\n if (Array.isArray(schema.items)) {\n schema.items = schema.items.map((item) => normalizeSchema(item));\n } else if (schema.items && typeof schema.items === 'object') {\n schema.items = normalizeSchema(schema.items);\n }\n\n if (schema.properties && typeof schema.properties === 'object') {\n for (const [key, value] of Object.entries(schema.properties)) {\n schema.properties[key] = normalizeSchema(value);\n }\n }\n\n if (\n schema.additionalProperties &&\n typeof schema.additionalProperties === 'object'\n ) {\n schema.additionalProperties = normalizeSchema(schema.additionalProperties);\n }\n\n for (const key of ['anyOf', 'oneOf', 'allOf']) {\n if (!Array.isArray(schema[key])) continue;\n schema[key] = schema[key].map((candidate) =>\n normalizeSchema(candidate, key === 'allOf'),\n );\n }\n\n if (Array.isArray(schema.oneOf) && !schema.anyOf) {\n schema.anyOf = schema.oneOf;\n delete schema.oneOf;\n }\n\n if (\n Array.isArray(schema.anyOf) &&\n schema.anyOf.every(\n (member) =>\n member &&\n typeof member === 'object' &&\n Object.keys(member).length === 1 &&\n typeof member.type === 'string',\n )\n ) {\n const { anyOf, ...rest } = schema;\n schema = { ...rest, type: anyOf.map((member) => member.type) };\n }\n\n if (\n schema.type === 'object' &&\n schema.properties &&\n schema.additionalProperties === undefined &&\n !isIntersectionMember\n ) {\n schema.additionalProperties = false;\n }\n\n if (\n schema.type === 'object' &&\n schema.propertyNames &&\n JSON.stringify(schema.propertyNames) === '{\"type\":\"string\"}'\n ) {\n delete schema.propertyNames;\n }\n\n if (\n typeof schema.$ref === 'string' &&\n !schema.$ref.startsWith('#/components/schemas')\n ) {\n schema.$ref =\n schema.$ref === '#'\n ? '#/components/schemas'\n : schema.$ref.replace(/^#\\\\//, '#/components/schemas/');\n }\n\n if (Array.isArray(schema.allOf)) {\n const merged = mergePrimitiveSchemas(schema.allOf);\n if (merged) {\n const { allOf, ...rest } = schema;\n return { ...rest, ...merged };\n }\n if (schema.allOf.length === 1 && Object.keys(schema).length === 1) {\n return schema.allOf[0];\n }\n }\n\n return schema;\n }`,\n `function escapePointerSegment(segment) {\n return String(segment).replaceAll('~', '~0').replaceAll('/', '~1');\n }`,\n `function componentPointer(path) {\n return ['#', 'components', 'schemas', ...path.map(escapePointerSegment)].join('/');\n }`,\n // Nested toJsonSchema passes (set/map values, pipe outputs) return\n // self-contained draft-7 documents whose '#' and '#/definitions/*' refs\n // are relative to the embedded document root, not the outer schema.\n // Resolve them to outer-root structural pointers before the outer\n // definitions/normalize passes rewrite them into dangling refs.\n `function resolveEmbeddedDocs(root) {\n function process(node, path, docRoot) {\n if (!node || typeof node !== 'object') return;\n if (Array.isArray(node)) {\n node.forEach((item, index) => process(item, [...path, index], docRoot));\n return;\n }\n if (node['x-sdkit-embedded-root']) {\n delete node['x-sdkit-embedded-root'];\n const defs = node.definitions ?? Object.create(null);\n delete node.definitions;\n docRoot = { path, defs, firstSite: Object.create(null) };\n }\n if (docRoot && typeof node.$ref === 'string') {\n if (node.$ref === '#') {\n node.$ref = componentPointer(docRoot.path);\n return;\n }\n const match = node.$ref.match(/^#\\\\/definitions\\\\/(.+)$/);\n if (match) {\n const name = match[1];\n if (name in docRoot.firstSite) {\n node.$ref = docRoot.firstSite[name];\n return;\n }\n docRoot.firstSite[name] = componentPointer(path);\n delete node.$ref;\n Object.assign(node, docRoot.defs[name]);\n }\n }\n for (const [key, value] of Object.entries(node)) {\n process(value, [...path, key], docRoot);\n }\n }\n process(root, [], null);\n return root;\n }`,\n // zod v4 breaks non-root cycles with a draft-7 definitions block plus\n // #/definitions/* refs, which OpenAPI consumers cannot resolve. Inline\n // each definition at its first use site and point the remaining\n // (recursive) refs structurally at that site, mirroring the v3\n // $refStrategy: 'root' output.\n `function inlineDefinitions(root) {\n const defs = root.definitions;\n if (!defs || typeof defs !== 'object') return root;\n delete root.definitions;\n const firstSite = Object.create(null);\n function walk(node, path) {\n if (!node || typeof node !== 'object') return;\n if (Array.isArray(node)) {\n node.forEach((item, index) => walk(item, [...path, index]));\n return;\n }\n const match =\n typeof node.$ref === 'string' &&\n node.$ref.match(/^#\\\\/definitions\\\\/(.+)$/);\n if (match) {\n const name = match[1];\n if (name in firstSite) {\n node.$ref = firstSite[name];\n return;\n }\n firstSite[name] = componentPointer(path);\n delete node.$ref;\n Object.assign(node, defs[name]);\n }\n for (const [key, value] of Object.entries(node)) {\n walk(value, [...path, key]);\n }\n }\n walk(root, []);\n return root;\n }`,\n // Wraps nested conversions: when the embedded document carries refs or a\n // definitions block, tag its root so resolveEmbeddedDocs can rebase them.\n `function convertEmbedded(schema) {\n const { $schema: _ignored, ...doc } = toJsonSchema(schema);\n if (doc.definitions || JSON.stringify(doc).includes('\"$ref\"')) {\n doc['x-sdkit-embedded-root'] = true;\n }\n return doc;\n }`,\n `function toJsonSchema(schema) {\n return z.toJSONSchema(schema, {\n target: 'draft-7',\n io: 'input',\n unrepresentable: 'any',\n override(ctx) {\n const def = ctx.zodSchema._zod.def;\n const json = ctx.jsonSchema;\n if (def.type === 'catch') {\n delete json.default;\n }\n if (def.type === 'date') {\n json.type = 'string';\n json.format = 'date-time';\n json['x-zod-type'] = def.coerce ? 'coerce-date' : 'date';\n }\n if (def.type === 'bigint') {\n json.type = 'integer';\n // z.bigint() carries no format; treat it as int64.\n json.format = ctx.zodSchema._zod.bag.format ?? 'int64';\n if (def.coerce) {\n json['x-zod-type'] = 'coerce-bigint';\n }\n }\n if (def.type === 'set') {\n json.type = 'array';\n json.uniqueItems = true;\n json.items = convertEmbedded(def.valueType);\n }\n if (def.type === 'map') {\n json.type = 'array';\n json.items = {\n type: 'array',\n items: [convertEmbedded(def.keyType), convertEmbedded(def.valueType)],\n minItems: 2,\n maxItems: 2,\n };\n }\n if (def.type === 'string' && json.format === 'base64') {\n json.format = 'binary';\n delete json.pattern;\n delete json.contentEncoding;\n }\n if (\n def.type === 'string' &&\n json.format &&\n json.pattern &&\n !hasExplicitRegexCheck(def)\n ) {\n if (STANDARD_STRING_FORMATS.has(json.format)) {\n delete json.pattern;\n } else if (!MAPPED_NONSTANDARD_FORMATS.has(json.format)) {\n delete json.format;\n }\n }\n if (def.type === 'number') {\n const explicitBound = (kind, value) =>\n (def.checks ?? []).some(\n (check) =>\n check._zod?.def?.check === kind &&\n Number(check._zod.def.value) === value,\n );\n if (\n json.maximum === Number.MAX_SAFE_INTEGER &&\n !explicitBound('less_than', Number.MAX_SAFE_INTEGER)\n ) {\n delete json.maximum;\n }\n if (\n json.minimum === Number.MIN_SAFE_INTEGER &&\n !explicitBound('greater_than', Number.MIN_SAFE_INTEGER)\n ) {\n delete json.minimum;\n }\n }\n if (def.type === 'pipe') {\n const outJson = convertEmbedded(def.out);\n const outKeys = Object.keys(outJson).filter(\n (key) => key !== 'x-sdkit-embedded-root',\n );\n if (outKeys.length > 0) {\n const inJson = { ...json };\n const compatible =\n inJson.type === undefined ||\n outJson.type === undefined ||\n inJson.type === outJson.type ||\n isNumericPair(inJson, outJson);\n if (compatible) {\n for (const key of Object.keys(json)) delete json[key];\n json.allOf = [inJson, outJson];\n }\n }\n }\n if (def.type === 'tuple' && Array.isArray(json.items)) {\n if (json.minItems === undefined) {\n json.minItems = json.items.length;\n }\n if (\n json.additionalItems === undefined &&\n json.maxItems === undefined\n ) {\n json.maxItems = json.items.length;\n }\n }\n },\n });\n }`,\n `let zodSchema;\n let rawResult;\n try {\n zodSchema = ${removeUnsupportedMethods(schema)};\n maskBigIntDefaults(zodSchema);\n // zod's own input-side flag: 'optional' for optional/nullish/catch,\n // 'defaulted' for default/prefault, undefined once .nonoptional() applies.\n optional = ['optional', 'defaulted'].includes(zodSchema._zod.optin);\n const { $schema, ...converted } = toJsonSchema(zodSchema);\n rawResult = converted;\n } finally {\n // The v3 shims exist only while the analyzed source evaluates and\n // converts (lazy getters can call them mid-conversion); remove them so\n // the shared zod instance is not left with v3 API surface process-wide.\n for (const method of installedShims) delete stringProto[method];\n }\n unmaskBigIntDefaults(rawResult);\n const result = normalizeSchema(\n inlineDefinitions(resolveEmbeddedDocs(rawResult)),\n );`,\n `const innerDef = unwrapSchemaDef(zodSchema._zod.def);\n if (innerDef?.coerce && !result['x-zod-type']) {\n const zodType = 'coerce-' + innerDef.type;\n if (!applyZodType(result, zodType, innerDef.type)) {\n result['x-zod-type'] = zodType;\n }\n }`,\n `export default {schema: result, optional}`,\n ];\n\n const base64 = Buffer.from(lines.join('\\n')).toString('base64');\n return import(\n /* @vite-ignore */\n `data:text/javascript;base64,${base64}`\n ).then((mod) => mod.default);\n}\n"],
5
- "mappings": "AAMA,SAAS,yBAAyB,QAAgB;AAChD,SAAO,OACJ,WAAW,qBAAqB,oBAAoB,EACpD,WAAW,qBAAqB,oBAAoB,EACpD,WAAW,mBAAmB,oBAAoB,EAClD,WAAW,mBAAmB,oBAAoB;AACvD;AAEA,eAAsB,QAAQ,QAAgB,UAA0B,CAAC,GAAG;AAE1E,QAAM,QAAQ;AAAA,IACZ;AAAA,IACA,qBAAqB,YAAY,GAAG;AAAA,IACpC;AAAA,IACA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA,IAKA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAuBA,GAAG,QAAQ;AAAA,MACT,CAAC,QACC,SAAS,IAAI,MAAM,cAAc,KAAK,UAAU,IAAI,IAAI,CAAC,IACvD,IAAI,WAAW,IAAI,KAAK,UAAU,I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;AAAA;AAAA;AAAA;AAAA,IAiBhD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOA;AAAA,EACF;AAEA,QAAM,SAAS,OAAO,KAAK,MAAM,KAAK,IAAI,CAAC,EAAE,SAAS,QAAQ;AAC9D,SAAO;AAAA;AAAA,IAEL,+BAA+B,MAAM;AAAA,IACrC,KAAK,CAAC,QAAQ,IAAI,OAAO;AAC7B;",
4
+ "sourcesContent": ["export type InjectImport = {\n import: string;\n from: string;\n property?: string;\n};\n\nfunction removeUnsupportedMethods(schema: string) {\n return schema\n .replaceAll('.instanceof(File)', '.string().base64()')\n .replaceAll('.instanceof(Blob)', '.string().base64()')\n .replaceAll('.custom<File>()', '.string().base64()')\n .replaceAll('.custom<Blob>()', '.string().base64()');\n}\n\nexport async function evalZod(schema: string, imports: InjectImport[] = []) {\n // https://github.com/nodejs/node/issues/51956\n const lines = [\n `import { createRequire } from \"node:module\";`,\n `const filename = \"${import.meta.url}\";`,\n `const require = createRequire(filename);`,\n `const z = require(\"zod\");`,\n `if (typeof z.toJSONSchema !== 'function') {\n throw new Error('@sdk-it/core requires Zod 4. Install zod@^4.6.7 and migrate Zod 3 schemas before analysis.');\n }`,\n // zod 4 removed ZodString.ip/.cidr; restore them for analyzed user source\n // that still uses the v3 spellings.\n `const stringProto = Object.getPrototypeOf(z.string());\n const installedShims = [];\n function withReceiverChecks(receiver, format) {\n return (receiver._zod.def.checks ?? []).length\n ? z.intersection(receiver, format)\n : format;\n }\n if (!stringProto.ip) {\n installedShims.push('ip');\n stringProto.ip = function (options) {\n if (options?.version === 'v4') return withReceiverChecks(this, z.ipv4());\n if (options?.version === 'v6') return withReceiverChecks(this, z.ipv6());\n return withReceiverChecks(this, z.union([z.ipv4(), z.ipv6()]));\n };\n }\n if (!stringProto.cidr) {\n installedShims.push('cidr');\n stringProto.cidr = function (options) {\n if (options?.version === 'v4') return withReceiverChecks(this, z.cidrv4());\n if (options?.version === 'v6') return withReceiverChecks(this, z.cidrv6());\n return withReceiverChecks(this, z.union([z.cidrv4(), z.cidrv6()]));\n };\n }`,\n ...imports.map(\n (imp) =>\n `const ${imp.import} = require(${JSON.stringify(imp.from)})${\n imp.property ? `[${JSON.stringify(imp.property)}]` : ''\n };`,\n ),\n `let optional = false;`,\n `const WRAPPER_TYPES = new Set([\n 'optional',\n 'nullable',\n 'default',\n 'prefault',\n 'catch',\n 'readonly',\n 'nonoptional',\n ]);`,\n `function unwrapSchemaDef(def) {\n while (def) {\n if (WRAPPER_TYPES.has(def.type)) {\n def = def.innerType?._zod?.def;\n continue;\n }\n if (def.type === 'pipe') {\n def = def.in?._zod?.def;\n continue;\n }\n return def;\n }\n return def;\n }`,\n `function matchesDefType(schema, defType) {\n if (!schema || typeof schema !== 'object') return false;\n if (defType === 'number') {\n return schema.type === 'number' || schema.type === 'integer';\n }\n if (defType === 'bigint') {\n return schema.type === 'integer';\n }\n if (defType === 'string') {\n return schema.type === 'string';\n }\n if (defType === 'boolean') {\n return schema.type === 'boolean';\n }\n if (defType === 'date') {\n return schema.type === 'string' && schema.format === 'date-time';\n }\n return typeof schema.type === 'string';\n }`,\n `function applyZodType(schema, zodType, defType) {\n if (!schema || typeof schema !== 'object') return false;\n if (schema['x-zod-type']) return true;\n if (matchesDefType(schema, defType)) {\n schema['x-zod-type'] = zodType;\n return true;\n }\n for (const key of ['anyOf', 'oneOf', 'allOf']) {\n if (!Array.isArray(schema[key])) continue;\n const candidates = schema[key].filter(\n (candidate) => candidate && candidate.type !== 'null',\n );\n if (candidates.length === 1 && applyZodType(candidates[0], zodType, defType)) {\n return true;\n }\n for (const candidate of candidates) {\n if (applyZodType(candidate, zodType, defType)) {\n return true;\n }\n }\n }\n return false;\n }`,\n `const BIGINT_SENTINEL = '__sdkit_bigint__';`,\n // zod v4 JSON-round-trips default values before the override callback\n // runs, which throws on bigint. Mask them as sentinel strings up front\n // and restore after conversion.\n `function maskBigIntDefaults(schema, seen = new Set()) {\n if (!schema?._zod || schema._zod.version?.major !== 4) {\n throw new Error('@sdk-it/core requires Zod 4 schemas; migrate imported Zod 3 schemas before analysis.');\n }\n if (seen.has(schema)) return;\n seen.add(schema);\n const def = schema._zod.def;\n if (\n (def.type === 'default' || def.type === 'prefault') &&\n typeof def.defaultValue === 'bigint'\n ) {\n Object.defineProperty(def, 'defaultValue', {\n value: BIGINT_SENTINEL + def.defaultValue.toString(),\n configurable: true,\n });\n }\n for (const key of ['innerType', 'in', 'out', 'element', 'valueType', 'keyType', 'left', 'right', 'catchall', 'rest']) {\n if (def[key]) maskBigIntDefaults(def[key], seen);\n }\n if (typeof def.getter === 'function') {\n const inner = def.getter();\n maskBigIntDefaults(inner, seen);\n Object.defineProperty(def, 'getter', {\n value: () => inner,\n configurable: true,\n });\n }\n if (def.shape) {\n for (const value of Object.values(def.shape)) maskBigIntDefaults(value, seen);\n }\n if (Array.isArray(def.options)) {\n for (const option of def.options) maskBigIntDefaults(option, seen);\n }\n if (Array.isArray(def.items)) {\n for (const item of def.items) maskBigIntDefaults(item, seen);\n }\n }`,\n // int64 is a plain number in sdk-it, so masked bigint defaults unmask to\n // JS numbers \u2014 the spec stays plain JSON with no bigint values to trip up\n // JSON.stringify.\n `function unmaskBigIntDefaults(schema) {\n if (!schema || typeof schema !== 'object') return;\n for (const [key, value] of Object.entries(schema)) {\n if (typeof value === 'string' && value.startsWith(BIGINT_SENTINEL)) {\n schema[key] = Number(value.slice(BIGINT_SENTINEL.length));\n } else if (Array.isArray(value)) {\n value.forEach(unmaskBigIntDefaults);\n } else if (value && typeof value === 'object') {\n unmaskBigIntDefaults(value);\n }\n }\n }`,\n `function hasExplicitRegexCheck(def) {\n return (def.checks ?? []).some(\n (check) => check._zod?.def?.format === 'regex',\n );\n }`,\n `const STANDARD_STRING_FORMATS = new Set([\n 'email',\n 'uri',\n 'url',\n 'uuid',\n 'guid',\n 'date-time',\n 'date',\n 'time',\n 'duration',\n 'ipv4',\n 'ipv6',\n 'hostname',\n 'binary',\n ]);`,\n // Nonstandard formats that sdk-it's own converters map to semantic zod\n // validators. Keep both keys: format for our converters, pattern for\n // third-party validators that do not recognize the format.\n `const MAPPED_NONSTANDARD_FORMATS = new Set(['cidrv4', 'cidrv6']);`,\n `function normalizeDefaultValue(value) {\n return value instanceof Date ? value.toISOString() : value;\n }`,\n `function mergeComparableValue(target, key, value) {\n if (value === undefined) return true;\n const normalized = normalizeDefaultValue(value);\n if (target[key] === undefined) {\n target[key] = normalized;\n return true;\n }\n return Object.is(target[key], normalized);\n }`,\n `function mergeLowerBound(target, key, value) {\n if (value === undefined) return true;\n if (typeof value !== 'number') return false;\n if (target[key] === undefined || value > target[key]) {\n target[key] = value;\n }\n return true;\n }`,\n `function mergeUpperBound(target, key, value) {\n if (value === undefined) return true;\n if (typeof value !== 'number') return false;\n if (target[key] === undefined || value < target[key]) {\n target[key] = value;\n }\n return true;\n }`,\n `function mergeEnumValues(target, values) {\n if (!Array.isArray(values)) return false;\n if (!Array.isArray(target.enum)) {\n target.enum = [...values];\n return true;\n }\n target.enum = target.enum.filter((candidate) =>\n values.some((value) => Object.is(candidate, value)),\n );\n return target.enum.length > 0;\n }`,\n `function isMergeablePrimitiveSchema(schema) {\n return (\n schema &&\n typeof schema === 'object' &&\n !schema.$ref &&\n !schema.anyOf &&\n !schema.oneOf &&\n !schema.allOf &&\n (schema.type === 'string' ||\n schema.type === 'boolean' ||\n schema.type === 'number' ||\n schema.type === 'integer')\n );\n }`,\n `function isNumericPair(left, right) {\n return (\n (left.type === 'number' && right.type === 'integer') ||\n (left.type === 'integer' && right.type === 'number')\n );\n }`,\n `function mergePrimitiveSchemas(schemas) {\n const merged = {};\n for (const schema of schemas) {\n if (\n schema &&\n typeof schema === 'object' &&\n Object.keys(schema).length === 0\n ) {\n continue;\n }\n if (!isMergeablePrimitiveSchema(schema)) {\n return null;\n }\n if (merged.type === undefined) {\n merged.type = schema.type;\n } else if (merged.type !== schema.type) {\n if (!isNumericPair(merged, schema)) {\n return null;\n }\n merged.type = 'integer';\n }\n\n for (const [key, value] of Object.entries(schema)) {\n if (key === 'type') {\n continue;\n }\n switch (key) {\n case 'minimum':\n case 'exclusiveMinimum':\n case 'minLength':\n case 'minItems':\n case 'minProperties':\n if (!mergeLowerBound(merged, key, value)) {\n return null;\n }\n break;\n case 'maximum':\n case 'exclusiveMaximum':\n case 'maxLength':\n case 'maxItems':\n case 'maxProperties':\n if (!mergeUpperBound(merged, key, value)) {\n return null;\n }\n break;\n case 'enum':\n if (!mergeEnumValues(merged, value)) {\n return null;\n }\n break;\n default:\n if (!mergeComparableValue(merged, key, value)) {\n return null;\n }\n }\n }\n }\n return merged;\n }`,\n `function normalizeSchema(schema, isIntersectionMember = false) {\n if (!schema || typeof schema !== 'object') {\n return schema;\n }\n\n if (schema.default !== undefined) {\n schema.default = normalizeDefaultValue(schema.default);\n }\n\n if (Array.isArray(schema.items)) {\n schema.items = schema.items.map((item) => normalizeSchema(item));\n } else if (schema.items && typeof schema.items === 'object') {\n schema.items = normalizeSchema(schema.items);\n }\n\n if (schema.properties && typeof schema.properties === 'object') {\n for (const [key, value] of Object.entries(schema.properties)) {\n schema.properties[key] = normalizeSchema(value);\n }\n }\n\n if (\n schema.additionalProperties &&\n typeof schema.additionalProperties === 'object'\n ) {\n schema.additionalProperties = normalizeSchema(schema.additionalProperties);\n }\n\n for (const key of ['anyOf', 'oneOf', 'allOf']) {\n if (!Array.isArray(schema[key])) continue;\n schema[key] = schema[key].map((candidate) =>\n normalizeSchema(candidate, key === 'allOf'),\n );\n }\n\n if (Array.isArray(schema.oneOf) && !schema.anyOf) {\n schema.anyOf = schema.oneOf;\n delete schema.oneOf;\n }\n\n if (\n Array.isArray(schema.anyOf) &&\n schema.anyOf.every(\n (member) =>\n member &&\n typeof member === 'object' &&\n Object.keys(member).length === 1 &&\n typeof member.type === 'string',\n )\n ) {\n const { anyOf, ...rest } = schema;\n schema = { ...rest, type: anyOf.map((member) => member.type) };\n }\n\n if (\n schema.type === 'object' &&\n schema.properties &&\n schema.additionalProperties === undefined &&\n !isIntersectionMember\n ) {\n schema.additionalProperties = false;\n }\n\n if (\n schema.type === 'object' &&\n schema.propertyNames &&\n JSON.stringify(schema.propertyNames) === '{\"type\":\"string\"}'\n ) {\n delete schema.propertyNames;\n }\n\n if (Array.isArray(schema.allOf)) {\n const merged = mergePrimitiveSchemas(schema.allOf);\n if (merged) {\n const { allOf, ...rest } = schema;\n return { ...rest, ...merged };\n }\n if (schema.allOf.length === 1 && Object.keys(schema).length === 1) {\n return schema.allOf[0];\n }\n }\n\n return schema;\n }`,\n `const components = Object.create(null);`,\n `function addComponent(name, schema) {\n if (\n name in components &&\n JSON.stringify(components[name]) !== JSON.stringify(schema)\n ) {\n throw new Error(\n 'Two different schemas share the id \"' + name + '\"; give each its own .meta({ id }).',\n );\n }\n components[name] = schema;\n }`,\n `function definitionName(ref) {\n return typeof ref === 'string' && ref.startsWith('#/definitions/')\n ? ref.slice('#/definitions/'.length)\n : undefined;\n }`,\n `function isAnonymous(name) {\n return /^__schema[0-9]+$/.test(name);\n }`,\n // .meta({ id }) on a schema whose cycle zod already named (z.json() is\n // one) writes the id as { allOf: [{ $ref: anonymous }] }: the id names\n // that anonymous definition.\n `function aliasedDefinition(schema) {\n if (\n Object.keys(schema).length !== 1 ||\n !Array.isArray(schema.allOf) ||\n schema.allOf.length !== 1\n ) {\n return undefined;\n }\n const name = definitionName(schema.allOf[0]?.$ref);\n return name && isAnonymous(name) ? name : undefined;\n }`,\n `function refersTo(node, ref) {\n if (!node || typeof node !== 'object') return false;\n if (node.$ref === ref) return true;\n return Object.values(node).some((child) => refersTo(child, ref));\n }`,\n // zod writes every schema that carries an id, and every cycle, as a draft-7\n // definition; a root with an id becomes a $ref to its own definition, and\n // an id-less root that cycles refers to itself as '#'. Each named\n // definition becomes a component the refs point at; a cycle without a name\n // cannot become one.\n `function extractComponents(doc, rootId) {\n const { definitions = {}, ...root } = doc;\n const names = Object.create(null);\n const aliases = new Set();\n for (const name of Object.keys(definitions)) {\n if (!isAnonymous(name)) names[name] = name;\n }\n for (const [name, definition] of Object.entries(definitions)) {\n const anonymous = names[name] && aliasedDefinition(definition);\n if (anonymous && !(anonymous in names)) {\n names[anonymous] = name;\n aliases.add(name);\n }\n }\n if (\n Object.keys(definitions).some((name) => !(name in names)) ||\n (!rootId && refersTo(root, '#'))\n ) {\n throw new Error(\n 'A recursive schema has no name; give it .meta({ id }) so it becomes a named component.',\n );\n }\n function rewrite(node) {\n if (Array.isArray(node)) return node.map(rewrite);\n if (!node || typeof node !== 'object') return node;\n const rewritten = {};\n for (const [key, value] of Object.entries(node)) {\n const target = key === '$ref' ? definitionName(value) : undefined;\n if (target) {\n rewritten.$ref = '#/components/schemas/' + names[target];\n } else {\n rewritten[key] = rewrite(value);\n }\n }\n return rewritten;\n }\n for (const [name, definition] of Object.entries(definitions)) {\n if (!aliases.has(name)) {\n addComponent(names[name], normalizeSchema(rewrite(definition)));\n }\n }\n return rewrite(root);\n }`,\n // Nested toJsonSchema passes (set/map values, pipe outputs) return\n // self-contained documents whose '#' and '#/definitions/*' refs are\n // relative to their own root; each is lifted on its own, innermost first.\n `function liftEmbedded(node) {\n if (Array.isArray(node)) return node.map(liftEmbedded);\n if (!node || typeof node !== 'object') return node;\n const lifted = {};\n for (const [key, value] of Object.entries(node)) {\n lifted[key] = liftEmbedded(value);\n }\n if (!lifted['x-sdkit-embedded-root']) return lifted;\n const {\n 'x-sdkit-embedded-root': _root,\n 'x-sdkit-embedded-id': id,\n ...doc\n } = lifted;\n return extractComponents(doc, id);\n }`,\n // Wraps nested conversions: when the embedded document carries an id,\n // refs or a definitions block, tag its root so liftEmbedded extracts it.\n `function convertEmbedded(schema) {\n const { $schema: _ignored, ...doc } = toJsonSchema(schema);\n const id = z.globalRegistry.get(schema)?.id;\n if (id || doc.definitions || JSON.stringify(doc).includes('\"$ref\"')) {\n doc['x-sdkit-embedded-root'] = true;\n if (id) doc['x-sdkit-embedded-id'] = id;\n }\n return doc;\n }`,\n `function toJsonSchema(schema) {\n return z.toJSONSchema(schema, {\n target: 'draft-7',\n io: 'input',\n unrepresentable: 'any',\n override(ctx) {\n const def = ctx.zodSchema._zod.def;\n const json = ctx.jsonSchema;\n if (def.type === 'catch') {\n delete json.default;\n }\n if (def.type === 'date') {\n json.type = 'string';\n json.format = 'date-time';\n json['x-zod-type'] = def.coerce ? 'coerce-date' : 'date';\n }\n if (def.type === 'bigint') {\n json.type = 'integer';\n // z.bigint()'s format is null; treat it as int64.\n json.format = ctx.zodSchema.format ?? 'int64';\n if (def.coerce) {\n json['x-zod-type'] = 'coerce-bigint';\n }\n }\n if (def.type === 'set') {\n json.type = 'array';\n json.uniqueItems = true;\n json.items = convertEmbedded(def.valueType);\n }\n if (def.type === 'map') {\n json.type = 'array';\n json.items = {\n type: 'array',\n items: [convertEmbedded(def.keyType), convertEmbedded(def.valueType)],\n minItems: 2,\n maxItems: 2,\n };\n }\n if (def.type === 'string' && json.format === 'base64') {\n json.format = 'binary';\n delete json.pattern;\n delete json.contentEncoding;\n }\n if (\n def.type === 'string' &&\n json.format &&\n json.pattern &&\n !hasExplicitRegexCheck(def)\n ) {\n if (STANDARD_STRING_FORMATS.has(json.format)) {\n delete json.pattern;\n } else if (!MAPPED_NONSTANDARD_FORMATS.has(json.format)) {\n delete json.format;\n }\n }\n if (def.type === 'number') {\n const explicitBound = (kind, value) =>\n (def.checks ?? []).some(\n (check) =>\n check._zod?.def?.check === kind &&\n Number(check._zod.def.value) === value,\n );\n if (\n json.maximum === Number.MAX_SAFE_INTEGER &&\n !explicitBound('less_than', Number.MAX_SAFE_INTEGER)\n ) {\n delete json.maximum;\n }\n if (\n json.minimum === Number.MIN_SAFE_INTEGER &&\n !explicitBound('greater_than', Number.MIN_SAFE_INTEGER)\n ) {\n delete json.minimum;\n }\n }\n if (def.type === 'pipe') {\n const outJson = convertEmbedded(def.out);\n const outKeys = Object.keys(outJson).filter(\n (key) =>\n key !== 'x-sdkit-embedded-root' &&\n key !== 'x-sdkit-embedded-id',\n );\n if (outKeys.length > 0) {\n const inJson = { ...json };\n const compatible =\n inJson.type === undefined ||\n outJson.type === undefined ||\n inJson.type === outJson.type ||\n isNumericPair(inJson, outJson);\n if (compatible) {\n for (const key of Object.keys(json)) delete json[key];\n json.allOf = [inJson, outJson];\n }\n }\n }\n if (def.type === 'tuple' && Array.isArray(json.items)) {\n if (json.minItems === undefined) {\n json.minItems = json.items.length;\n }\n if (\n json.additionalItems === undefined &&\n json.maxItems === undefined\n ) {\n json.maxItems = json.items.length;\n }\n }\n },\n });\n }`,\n `let zodSchema;\n let rawResult;\n try {\n zodSchema = ${removeUnsupportedMethods(schema)};\n maskBigIntDefaults(zodSchema);\n // zod's own input-side flag: 'optional' for optional/nullish/catch,\n // 'defaulted' for default/prefault, undefined once .nonoptional() applies.\n optional = ['optional', 'defaulted'].includes(zodSchema._zod.optin);\n const { $schema, ...converted } = toJsonSchema(zodSchema);\n rawResult = converted;\n } finally {\n // The v3 shims exist only while the analyzed source evaluates and\n // converts (lazy getters can call them mid-conversion); remove them so\n // the shared zod instance is not left with v3 API surface process-wide.\n for (const method of installedShims) delete stringProto[method];\n }\n unmaskBigIntDefaults(rawResult);\n const result = normalizeSchema(\n extractComponents(\n liftEmbedded(rawResult),\n z.globalRegistry.get(zodSchema)?.id,\n ),\n );`,\n `const innerDef = unwrapSchemaDef(zodSchema._zod.def);\n if (innerDef?.coerce && !result['x-zod-type']) {\n const zodType = 'coerce-' + innerDef.type;\n if (!applyZodType(result, zodType, innerDef.type)) {\n result['x-zod-type'] = zodType;\n }\n }`,\n `export default {schema: result, optional, components}`,\n ];\n\n const base64 = Buffer.from(lines.join('\\n')).toString('base64');\n return import(\n /* @vite-ignore */\n `data:text/javascript;base64,${base64}`\n ).then((mod) => mod.default);\n}\n"],
5
+ "mappings": "AAMA,SAAS,yBAAyB,QAAgB;AAChD,SAAO,OACJ,WAAW,qBAAqB,oBAAoB,EACpD,WAAW,qBAAqB,oBAAoB,EACpD,WAAW,mBAAmB,oBAAoB,EACl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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IA6GA;AAAA;AAAA;AAAA,oBAGgB,yBAAyB,MAAM,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAoBhD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOA;AAAA,EACF;AAEA,QAAM,SAAS,OAAO,KAAK,MAAM,KAAK,IAAI,CAAC,EAAE,SAAS,QAAQ;AAC9D,SAAO;AAAA;AAAA,IAEL,+BAA+B,MAAM;AAAA,IACrC,KAAK,CAAC,QAAQ,IAAI,OAAO;AAC7B;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,15 @@
1
1
  {
2
2
  "name": "@sdk-it/core",
3
- "version": "0.46.11",
3
+ "version": "0.47.0",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "https://github.com/JanuaryLabs/sdk-it",
7
+ "directory": "packages/core"
8
+ },
9
+ "bugs": {
10
+ "url": "https://github.com/JanuaryLabs/sdk-it/issues"
11
+ },
12
+ "homepage": "https://github.com/JanuaryLabs/sdk-it/tree/main/packages/core#readme",
4
13
  "type": "module",
5
14
  "main": "./dist/index.js",
6
15
  "module": "./dist/index.js",
@@ -27,24 +36,20 @@
27
36
  "!**/*.test.*"
28
37
  ],
29
38
  "dependencies": {
30
- "debug": "^4.4.0",
31
- "stringcase": "^4.3.1",
32
- "lodash-es": "^4.17.21"
39
+ "@zukhruf/fs": "^0.8.22",
40
+ "stringcase": "^4.3.1"
33
41
  },
34
42
  "peerDependencies": {
35
- "zod": "^4.3.0",
36
- "typescript": "^6.0.3",
37
- "openapi3-ts": "^4.4.0"
43
+ "@typescript/native": "npm:typescript@7.1.0-beta",
44
+ "openapi3-ts": "^4.6.2",
45
+ "zod": "^4.6.7"
38
46
  },
39
47
  "peerDependenciesMeta": {
40
- "openapi3-ts": {
48
+ "@typescript/native": {
41
49
  "optional": true
42
50
  },
43
- "typescript": {
51
+ "openapi3-ts": {
44
52
  "optional": true
45
53
  }
46
- },
47
- "devDependencies": {
48
- "@types/debug": "^4.1.12"
49
54
  }
50
55
  }
@@ -1,23 +0,0 @@
1
- declare global {
2
- interface JSON {
3
- /**
4
- * TC39 "JSON.parse source access" proposal, shipped in Node 21+ and
5
- * evergreen browsers. TypeScript 6 does not ship lib types for it yet.
6
- */
7
- rawJSON(text: string): {
8
- rawJSON: string;
9
- };
10
- isRawJSON(value: unknown): value is {
11
- rawJSON: string;
12
- };
13
- }
14
- }
15
- /**
16
- * Spec objects produced by the analyzers carry real bigint values for int64
17
- * defaults and bounds. JSON.stringify throws on bigint; this replacer writes
18
- * them as bare JSON numbers instead — lossless on disk (JSON's grammar allows
19
- * arbitrary-precision numbers) and valid against `type: integer` schemas.
20
- */
21
- export declare function specJsonReplacer(_key: string, value: unknown): unknown;
22
- export declare function stringifySpec(spec: unknown, space?: string | number): string;
23
- //# sourceMappingURL=spec-json.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"spec-json.d.ts","sourceRoot":"","sources":["../../src/lib/spec-json.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,IAAI;QACZ;;;WAGG;QACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG;YAAE,OAAO,EAAE,MAAM,CAAA;SAAE,CAAC;QAC3C,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI;YAAE,OAAO,EAAE,MAAM,CAAA;SAAE,CAAC;KACzD;CACF;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAEtE;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAE5E"}
@@ -1,11 +0,0 @@
1
- function specJsonReplacer(_key, value) {
2
- return typeof value === "bigint" ? JSON.rawJSON(value.toString()) : value;
3
- }
4
- function stringifySpec(spec, space) {
5
- return JSON.stringify(spec, specJsonReplacer, space);
6
- }
7
- export {
8
- specJsonReplacer,
9
- stringifySpec
10
- };
11
- //# sourceMappingURL=spec-json.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/lib/spec-json.ts"],
4
- "sourcesContent": ["declare global {\n interface JSON {\n /**\n * TC39 \"JSON.parse source access\" proposal, shipped in Node 21+ and\n * evergreen browsers. TypeScript 6 does not ship lib types for it yet.\n */\n rawJSON(text: string): { rawJSON: string };\n isRawJSON(value: unknown): value is { rawJSON: string };\n }\n}\n\n/**\n * Spec objects produced by the analyzers carry real bigint values for int64\n * defaults and bounds. JSON.stringify throws on bigint; this replacer writes\n * them as bare JSON numbers instead \u2014 lossless on disk (JSON's grammar allows\n * arbitrary-precision numbers) and valid against `type: integer` schemas.\n */\nexport function specJsonReplacer(_key: string, value: unknown): unknown {\n return typeof value === 'bigint' ? JSON.rawJSON(value.toString()) : value;\n}\n\nexport function stringifySpec(spec: unknown, space?: string | number): string {\n return JSON.stringify(spec, specJsonReplacer, space);\n}\n"],
5
- "mappings": "AAiBO,SAAS,iBAAiB,MAAc,OAAyB;AACtE,SAAO,OAAO,UAAU,WAAW,KAAK,QAAQ,MAAM,SAAS,CAAC,IAAI;AACtE;AAEO,SAAS,cAAc,MAAe,OAAiC;AAC5E,SAAO,KAAK,UAAU,MAAM,kBAAkB,KAAK;AACrD;",
6
- "names": []
7
- }