zodvex 0.7.1-beta.4 → 0.7.1-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/index.js CHANGED
@@ -470,32 +470,46 @@ function transformImports(file) {
470
470
  }
471
471
  function transformClassRefs(file) {
472
472
  let count = 0;
473
- const runtimeImports = /* @__PURE__ */ new Set();
474
- const typeOnlyImports = /* @__PURE__ */ new Set();
473
+ const runtimeCoreImports = /* @__PURE__ */ new Set();
474
+ const typeOnlyCoreImports = /* @__PURE__ */ new Set();
475
475
  const propAccesses = file.getDescendantsOfKind(SyntaxKind.PropertyAccessExpression);
476
476
  for (const pa of propAccesses) {
477
477
  if (pa.wasForgotten()) continue;
478
478
  const text = pa.getText();
479
- const replacement = CLASS_RENAMES[text];
480
- if (!replacement) continue;
481
- pa.replaceWithText(replacement);
482
- runtimeImports.add(replacement);
483
- count++;
479
+ const miniReplacement = MINI_CLASS_RENAMES[text];
480
+ if (miniReplacement) {
481
+ pa.replaceWithText(miniReplacement);
482
+ count++;
483
+ continue;
484
+ }
485
+ const coreReplacement = CORE_CLASS_RENAMES[text];
486
+ if (coreReplacement) {
487
+ pa.replaceWithText(coreReplacement);
488
+ runtimeCoreImports.add(coreReplacement);
489
+ count++;
490
+ }
484
491
  }
485
492
  const qualNames = file.getDescendantsOfKind(SyntaxKind.QualifiedName);
486
493
  for (const qn of qualNames) {
487
494
  if (qn.wasForgotten()) continue;
488
495
  const text = qn.getText();
489
- const replacement = CLASS_RENAMES[text];
490
- if (!replacement) continue;
491
- qn.replaceWithText(replacement);
492
- if (!runtimeImports.has(replacement)) {
493
- typeOnlyImports.add(replacement);
496
+ const miniReplacement = MINI_CLASS_RENAMES[text];
497
+ if (miniReplacement) {
498
+ qn.replaceWithText(miniReplacement);
499
+ count++;
500
+ continue;
501
+ }
502
+ const coreReplacement = CORE_CLASS_RENAMES[text];
503
+ if (coreReplacement) {
504
+ qn.replaceWithText(coreReplacement);
505
+ if (!runtimeCoreImports.has(coreReplacement)) {
506
+ typeOnlyCoreImports.add(coreReplacement);
507
+ }
508
+ count++;
494
509
  }
495
- count++;
496
510
  }
497
- for (const name of runtimeImports) {
498
- typeOnlyImports.delete(name);
511
+ for (const name of runtimeCoreImports) {
512
+ typeOnlyCoreImports.delete(name);
499
513
  }
500
514
  const addToExistingImport = (imp, names) => {
501
515
  if (!imp) return;
@@ -505,42 +519,42 @@ function transformClassRefs(file) {
505
519
  }
506
520
  }
507
521
  };
508
- if (runtimeImports.size > 0) {
522
+ if (runtimeCoreImports.size > 0) {
509
523
  const existingCoreImport = file.getImportDeclaration(
510
524
  (d) => d.getModuleSpecifierValue() === "zod/v4/core" && !d.isTypeOnly()
511
525
  );
512
526
  if (existingCoreImport) {
513
- addToExistingImport(existingCoreImport, runtimeImports);
527
+ addToExistingImport(existingCoreImport, runtimeCoreImports);
514
528
  } else {
515
529
  const internalImport = file.getImportDeclaration(
516
530
  (d) => d.getModuleSpecifierValue().endsWith("/zod-core") && !d.isTypeOnly()
517
531
  );
518
532
  if (internalImport) {
519
- addToExistingImport(internalImport, runtimeImports);
533
+ addToExistingImport(internalImport, runtimeCoreImports);
520
534
  } else {
521
535
  file.addImportDeclaration({
522
536
  moduleSpecifier: "zod/v4/core",
523
- namedImports: [...runtimeImports].sort()
537
+ namedImports: [...runtimeCoreImports].sort()
524
538
  });
525
539
  }
526
540
  }
527
541
  }
528
- if (typeOnlyImports.size > 0) {
542
+ if (typeOnlyCoreImports.size > 0) {
529
543
  const existingTypeImport = file.getImportDeclaration(
530
544
  (d) => d.getModuleSpecifierValue() === "zod/v4/core" && d.isTypeOnly()
531
545
  );
532
546
  if (existingTypeImport) {
533
- addToExistingImport(existingTypeImport, typeOnlyImports);
547
+ addToExistingImport(existingTypeImport, typeOnlyCoreImports);
534
548
  } else {
535
549
  const internalTypeImport = file.getImportDeclaration(
536
550
  (d) => d.getModuleSpecifierValue().endsWith("/zod-core") && d.isTypeOnly()
537
551
  );
538
552
  if (internalTypeImport) {
539
- addToExistingImport(internalTypeImport, typeOnlyImports);
553
+ addToExistingImport(internalTypeImport, typeOnlyCoreImports);
540
554
  } else {
541
555
  file.addImportDeclaration({
542
556
  moduleSpecifier: "zod/v4/core",
543
- namedImports: [...typeOnlyImports].sort(),
557
+ namedImports: [...typeOnlyCoreImports].sort(),
544
558
  isTypeOnly: true
545
559
  });
546
560
  }
@@ -611,7 +625,7 @@ function transformCode(code, options) {
611
625
  return { code, changed: false };
612
626
  }
613
627
  }
614
- var WRAPPER_METHODS, NAMESPACE_IDENTIFIERS, ZOD_ONLY_CHECK_METHODS, AMBIGUOUS_CHECK_METHODS, STRING_RENAME, NUMBER_RENAME, UNCONDITIONAL_TOP_LEVEL, AMBIGUOUS_TOP_LEVEL, RENAMED_METHODS, TRANSFORM_METHOD, CHECK_WRAP_METHODS, CONSTRUCTOR_REPLACEMENTS, INTERNAL_PROPERTY_ACCESSORS, WARN_METHODS, CLASS_RENAMES;
628
+ var WRAPPER_METHODS, NAMESPACE_IDENTIFIERS, ZOD_ONLY_CHECK_METHODS, AMBIGUOUS_CHECK_METHODS, STRING_RENAME, NUMBER_RENAME, UNCONDITIONAL_TOP_LEVEL, AMBIGUOUS_TOP_LEVEL, RENAMED_METHODS, TRANSFORM_METHOD, CHECK_WRAP_METHODS, CONSTRUCTOR_REPLACEMENTS, INTERNAL_PROPERTY_ACCESSORS, WARN_METHODS, MINI_CLASS_RENAMES, CORE_CLASS_RENAMES;
615
629
  var init_transforms = __esm({
616
630
  "../zod-to-mini/src/transforms.ts"() {
617
631
  WRAPPER_METHODS = ["optional", "nullable"];
@@ -677,31 +691,33 @@ var init_transforms = __esm({
677
691
  "merge"
678
692
  // use z.extend() or spread
679
693
  ];
680
- CLASS_RENAMES = {
694
+ MINI_CLASS_RENAMES = {
695
+ "z.ZodType": "z.ZodMiniType",
696
+ "z.ZodTypeAny": "z.ZodMiniType",
697
+ "z.ZodObject": "z.ZodMiniObject",
698
+ "z.ZodArray": "z.ZodMiniArray",
699
+ "z.ZodString": "z.ZodMiniString",
700
+ "z.ZodNumber": "z.ZodMiniNumber",
701
+ "z.ZodBoolean": "z.ZodMiniBoolean",
702
+ "z.ZodOptional": "z.ZodMiniOptional",
703
+ "z.ZodNullable": "z.ZodMiniNullable",
704
+ "z.ZodUnion": "z.ZodMiniUnion",
705
+ "z.ZodEnum": "z.ZodMiniEnum",
706
+ "z.ZodLiteral": "z.ZodMiniLiteral",
707
+ "z.ZodCodec": "z.ZodMiniCodec",
708
+ "z.ZodCustom": "z.ZodMiniCustom",
709
+ "z.ZodDefault": "z.ZodMiniDefault",
710
+ "z.ZodRecord": "z.ZodMiniRecord",
711
+ "z.ZodTuple": "z.ZodMiniTuple",
712
+ "z.ZodDiscriminatedUnion": "z.ZodMiniDiscriminatedUnion",
713
+ "z.ZodLazy": "z.ZodMiniLazy",
714
+ "z.ZodPipe": "z.ZodMiniPipe",
715
+ "z.ZodTransform": "z.ZodMiniTransform",
716
+ "z.ZodReadonly": "z.ZodMiniReadonly"
717
+ };
718
+ CORE_CLASS_RENAMES = {
681
719
  "z.ZodError": "$ZodError",
682
- "z.ZodType": "$ZodType",
683
- "z.ZodTypeAny": "$ZodType",
684
- "z.ZodRawShape": "$ZodShape",
685
- "z.ZodObject": "$ZodObject",
686
- "z.ZodArray": "$ZodArray",
687
- "z.ZodString": "$ZodString",
688
- "z.ZodNumber": "$ZodNumber",
689
- "z.ZodBoolean": "$ZodBoolean",
690
- "z.ZodOptional": "$ZodOptional",
691
- "z.ZodNullable": "$ZodNullable",
692
- "z.ZodUnion": "$ZodUnion",
693
- "z.ZodEnum": "$ZodEnum",
694
- "z.ZodLiteral": "$ZodLiteral",
695
- "z.ZodCodec": "$ZodCodec",
696
- "z.ZodCustom": "$ZodCustom",
697
- "z.ZodDefault": "$ZodDefault",
698
- "z.ZodRecord": "$ZodRecord",
699
- "z.ZodTuple": "$ZodTuple",
700
- "z.ZodDiscriminatedUnion": "$ZodDiscriminatedUnion",
701
- "z.ZodLazy": "$ZodLazy",
702
- "z.ZodPipe": "$ZodPipe",
703
- "z.ZodTransform": "$ZodTransform",
704
- "z.ZodReadonly": "$ZodReadonly"
720
+ "z.ZodRawShape": "$ZodShape"
705
721
  };
706
722
  }
707
723
  });