zod-nest 1.8.0 → 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1552,6 +1552,31 @@ var forEachOperation = /* @__PURE__ */ __name((doc, fn) => {
1552
1552
  }
1553
1553
  }, "forEachOperation");
1554
1554
 
1555
+ // src/document/walk-refs.ts
1556
+ var walkRefs = /* @__PURE__ */ __name((node, visit) => {
1557
+ if (node === null || typeof node !== "object") {
1558
+ return;
1559
+ }
1560
+ if (Array.isArray(node)) {
1561
+ for (const item of node) {
1562
+ walkRefs(item, visit);
1563
+ }
1564
+ return;
1565
+ }
1566
+ const obj = node;
1567
+ for (const key of Object.keys(obj)) {
1568
+ const value = obj[key];
1569
+ if (key === "$ref" && typeof value === "string") {
1570
+ const next = visit(value);
1571
+ if (next !== void 0) {
1572
+ obj[key] = next;
1573
+ }
1574
+ continue;
1575
+ }
1576
+ walkRefs(value, visit);
1577
+ }
1578
+ }, "walkRefs");
1579
+
1555
1580
  // src/document/collect-usage.ts
1556
1581
  var isPlainRecord2 = /* @__PURE__ */ __name((value) => value !== null && typeof value === "object" && !Array.isArray(value), "isPlainRecord");
1557
1582
  var collectUsage = /* @__PURE__ */ __name((doc, app, registry) => {
@@ -1655,19 +1680,19 @@ var collectRefFromSchema = /* @__PURE__ */ __name((schema, classToDtoId, knownId
1655
1680
  if (!isPlainRecord2(schema)) {
1656
1681
  return;
1657
1682
  }
1658
- const ref = schema.$ref;
1659
- if (typeof ref !== "string" || !ref.startsWith(COMPONENTS_SCHEMAS_PREFIX)) {
1660
- return;
1661
- }
1662
- const className = ref.slice(COMPONENTS_SCHEMAS_PREFIX.length);
1663
- const renamed = classToDtoId.get(className);
1664
- if (renamed !== void 0) {
1665
- ids.add(renamed);
1666
- return;
1667
- }
1668
- if (knownIds.has(className)) {
1669
- ids.add(className);
1670
- }
1683
+ walkRefs(schema, (ref) => {
1684
+ if (!ref.startsWith(COMPONENTS_SCHEMAS_PREFIX)) {
1685
+ return void 0;
1686
+ }
1687
+ const className = ref.slice(COMPONENTS_SCHEMAS_PREFIX.length);
1688
+ const renamed = classToDtoId.get(className);
1689
+ if (renamed !== void 0) {
1690
+ ids.add(renamed);
1691
+ } else if (knownIds.has(className)) {
1692
+ ids.add(className);
1693
+ }
1694
+ return void 0;
1695
+ });
1671
1696
  }, "collectRefFromSchema");
1672
1697
  var collectOutputExposedIds = /* @__PURE__ */ __name((app) => {
1673
1698
  const ids = /* @__PURE__ */ new Set();
@@ -1729,31 +1754,6 @@ var ZodNestDocumentError = class extends ZodNestError {
1729
1754
  }
1730
1755
  };
1731
1756
 
1732
- // src/document/walk-refs.ts
1733
- var walkRefs = /* @__PURE__ */ __name((node, visit) => {
1734
- if (node === null || typeof node !== "object") {
1735
- return;
1736
- }
1737
- if (Array.isArray(node)) {
1738
- for (const item of node) {
1739
- walkRefs(item, visit);
1740
- }
1741
- return;
1742
- }
1743
- const obj = node;
1744
- for (const key of Object.keys(obj)) {
1745
- const value = obj[key];
1746
- if (key === "$ref" && typeof value === "string") {
1747
- const next = visit(value);
1748
- if (next !== void 0) {
1749
- obj[key] = next;
1750
- }
1751
- continue;
1752
- }
1753
- walkRefs(value, visit);
1754
- }
1755
- }, "walkRefs");
1756
-
1757
1757
  // src/document/dangling-refs.ts
1758
1758
  var assertNoDanglingRefs = /* @__PURE__ */ __name((params) => {
1759
1759
  const { doc, collected } = params;