@kubb/ast 5.22.0 → 5.23.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.
Files changed (155) hide show
  1. package/dist/base-IpYuh3ZP.d.cts +173 -0
  2. package/dist/base-IpYuh3ZP.d.ts +173 -0
  3. package/dist/constants-Ckeonm-D.js +141 -0
  4. package/dist/constants-Ckeonm-D.js.map +1 -0
  5. package/dist/constants-CquR083U.cjs +152 -0
  6. package/dist/constants-CquR083U.cjs.map +1 -0
  7. package/dist/factory.cjs +23 -0
  8. package/dist/factory.d.cts +4 -0
  9. package/dist/factory.d.ts +4 -0
  10. package/dist/factory.js +4 -0
  11. package/dist/file-BVqSiSvV.d.cts +624 -0
  12. package/dist/file-Cg0T6cgz.cjs +319 -0
  13. package/dist/file-Cg0T6cgz.cjs.map +1 -0
  14. package/dist/file-CnuL8oUj.js +283 -0
  15. package/dist/file-CnuL8oUj.js.map +1 -0
  16. package/dist/file-CvlMAp_d.js +131 -0
  17. package/dist/file-CvlMAp_d.js.map +1 -0
  18. package/dist/file-Dd50jPkH.cjs +142 -0
  19. package/dist/file-Dd50jPkH.cjs.map +1 -0
  20. package/dist/file-xJnBQPGq.d.ts +624 -0
  21. package/dist/file.cjs +3 -0
  22. package/dist/file.d.cts +2 -0
  23. package/dist/file.d.ts +2 -0
  24. package/dist/file.js +1 -0
  25. package/dist/graph-BcwFCvei.js +144 -0
  26. package/dist/graph-BcwFCvei.js.map +1 -0
  27. package/dist/graph-DcIY6tQb.cjs +173 -0
  28. package/dist/graph-DcIY6tQb.cjs.map +1 -0
  29. package/dist/graph.cjs +6 -0
  30. package/dist/graph.d.cts +2 -0
  31. package/dist/graph.d.ts +2 -0
  32. package/dist/graph.js +1 -0
  33. package/dist/guards-B8qDgSaT.d.cts +23 -0
  34. package/dist/guards-COVJE6TU.cjs +41 -0
  35. package/dist/guards-COVJE6TU.cjs.map +1 -0
  36. package/dist/guards-D-h9R_sV.d.ts +23 -0
  37. package/dist/guards-DlJkKsT1.js +30 -0
  38. package/dist/guards-DlJkKsT1.js.map +1 -0
  39. package/dist/http-Bm5lhVK4.cjs +12 -0
  40. package/dist/http-Bm5lhVK4.cjs.map +1 -0
  41. package/dist/http-DwboM6pK.js +7 -0
  42. package/dist/http-DwboM6pK.js.map +1 -0
  43. package/dist/http.cjs +4 -0
  44. package/dist/http.d.cts +3 -0
  45. package/dist/http.d.ts +3 -0
  46. package/dist/http.js +2 -0
  47. package/dist/index-BWd95onW.d.cts +5 -0
  48. package/dist/index-Bb1kqq8H.d.cts +20 -0
  49. package/dist/index-BngGJux5.d.cts +12 -0
  50. package/dist/index-BwnMIoLl.d.ts +24 -0
  51. package/dist/index-C-vhkzwR.d.cts +79 -0
  52. package/dist/index-CAGuKv6t.d.ts +74 -0
  53. package/dist/index-CFH4ZC7q.d.ts +44 -0
  54. package/dist/index-CIqwy4EE.d.cts +74 -0
  55. package/dist/index-Cc2K3OzU.d.cts +11 -0
  56. package/dist/index-Cc2K3OzU.d.ts +11 -0
  57. package/dist/index-Csf8xsCc.d.cts +46 -0
  58. package/dist/index-D3M2spDR.d.ts +12 -0
  59. package/dist/index-DNiIem0x.d.ts +79 -0
  60. package/dist/index-DSVef1pp.d.cts +24 -0
  61. package/dist/index-DU_jYpBt.d.cts +44 -0
  62. package/dist/index-DYDha-3I.d.cts +67 -0
  63. package/dist/index-DaHsMJ_S.d.ts +5 -0
  64. package/dist/index-Dp50LM3a.d.ts +67 -0
  65. package/dist/index-cpjUxIik.d.ts +46 -0
  66. package/dist/index-eGkM4FE9.d.ts +20 -0
  67. package/dist/index.cjs +87 -2131
  68. package/dist/index.cjs.map +1 -1
  69. package/dist/index.d.cts +25 -2745
  70. package/dist/index.d.ts +25 -2745
  71. package/dist/index.js +40 -2052
  72. package/dist/index.js.map +1 -1
  73. package/dist/json-DH7_lcWm.js +74 -0
  74. package/dist/json-DH7_lcWm.js.map +1 -0
  75. package/dist/json-DURdtz9A.cjs +91 -0
  76. package/dist/json-DURdtz9A.cjs.map +1 -0
  77. package/dist/json.cjs +4 -0
  78. package/dist/json.d.cts +2 -0
  79. package/dist/json.d.ts +2 -0
  80. package/dist/json.js +1 -0
  81. package/dist/macro-D0KfNtff.js +104 -0
  82. package/dist/macro-D0KfNtff.js.map +1 -0
  83. package/dist/macro-DrTBT7fh.cjs +127 -0
  84. package/dist/macro-DrTBT7fh.cjs.map +1 -0
  85. package/dist/macro.cjs +4 -0
  86. package/dist/macro.d.cts +2 -0
  87. package/dist/macro.d.ts +2 -0
  88. package/dist/macro.js +1 -0
  89. package/dist/mediaType-CRjggmoG.js +19 -0
  90. package/dist/mediaType-CRjggmoG.js.map +1 -0
  91. package/dist/mediaType-D8uIO8sG.cjs +35 -0
  92. package/dist/mediaType-D8uIO8sG.cjs.map +1 -0
  93. package/dist/mediaType.cjs +4 -0
  94. package/dist/mediaType.d.cts +2 -0
  95. package/dist/mediaType.d.ts +2 -0
  96. package/dist/mediaType.js +1 -0
  97. package/dist/node-DjcETnc8.cjs +19 -0
  98. package/dist/node-DjcETnc8.cjs.map +1 -0
  99. package/dist/node-Djh-mZB2.js +14 -0
  100. package/dist/node-Djh-mZB2.js.map +1 -0
  101. package/dist/node.cjs +9 -0
  102. package/dist/node.d.cts +4 -0
  103. package/dist/node.d.ts +4 -0
  104. package/dist/node.js +5 -0
  105. package/dist/nodeText-DRb_rVd1.cjs +58 -0
  106. package/dist/nodeText-DRb_rVd1.cjs.map +1 -0
  107. package/dist/nodeText-DVVDZQjF.js +47 -0
  108. package/dist/nodeText-DVVDZQjF.js.map +1 -0
  109. package/dist/nodes-BB60Bq2H.cjs +320 -0
  110. package/dist/nodes-BB60Bq2H.cjs.map +1 -0
  111. package/dist/nodes-CWMa9xhW.js +231 -0
  112. package/dist/nodes-CWMa9xhW.js.map +1 -0
  113. package/dist/operation-BgRyVS7z.d.ts +1272 -0
  114. package/dist/operation-X7chCdL2.d.cts +1272 -0
  115. package/dist/optionality-D-zqzVMH.cjs +22 -0
  116. package/dist/optionality-D-zqzVMH.cjs.map +1 -0
  117. package/dist/optionality-DISn8ytP.js +17 -0
  118. package/dist/optionality-DISn8ytP.js.map +1 -0
  119. package/dist/promise-BOdlgT0N.cjs +50 -0
  120. package/dist/promise-BOdlgT0N.cjs.map +1 -0
  121. package/dist/promise-RpnEev9D.js +45 -0
  122. package/dist/promise-RpnEev9D.js.map +1 -0
  123. package/dist/ref-Bu7PoHar.js +22 -0
  124. package/dist/ref-Bu7PoHar.js.map +1 -0
  125. package/dist/ref-P0ZLT1Bg.cjs +39 -0
  126. package/dist/ref-P0ZLT1Bg.cjs.map +1 -0
  127. package/dist/ref.cjs +7 -0
  128. package/dist/ref.d.cts +2 -0
  129. package/dist/ref.d.ts +2 -0
  130. package/dist/ref.js +3 -0
  131. package/dist/refs-CYHpRlQo.cjs +131 -0
  132. package/dist/refs-CYHpRlQo.cjs.map +1 -0
  133. package/dist/refs-YCV3CznS.js +102 -0
  134. package/dist/refs-YCV3CznS.js.map +1 -0
  135. package/dist/rolldown-runtime-BV8xUvPy.cjs +52 -0
  136. package/dist/rolldown-runtime-BYyVTPww.js +16 -0
  137. package/dist/schema-2ZAQk7qE.js +44 -0
  138. package/dist/schema-2ZAQk7qE.js.map +1 -0
  139. package/dist/schema-BIErWqgc.cjs +214 -0
  140. package/dist/schema-BIErWqgc.cjs.map +1 -0
  141. package/dist/schema-DloctnMm.js +179 -0
  142. package/dist/schema-DloctnMm.js.map +1 -0
  143. package/dist/schema-hxMlgCrV.cjs +49 -0
  144. package/dist/schema-hxMlgCrV.cjs.map +1 -0
  145. package/dist/schema.cjs +16 -0
  146. package/dist/schema.d.cts +5 -0
  147. package/dist/schema.d.ts +5 -0
  148. package/dist/schema.js +6 -0
  149. package/dist/visitor-BZozlXBF.d.ts +179 -0
  150. package/dist/visitor-Bw_opzjF.d.cts +179 -0
  151. package/dist/visitor-DTrzvA3R.cjs +382 -0
  152. package/dist/visitor-DTrzvA3R.cjs.map +1 -0
  153. package/dist/visitor-NoQSUQTu.js +347 -0
  154. package/dist/visitor-NoQSUQTu.js.map +1 -0
  155. package/package.json +101 -1
@@ -0,0 +1,22 @@
1
+ require("./rolldown-runtime-BV8xUvPy.cjs");
2
+ // src/optionality.ts
3
+ /**
4
+ * Generic JSON Schema optionality: a non-required field is optional, and a
5
+ * non-required nullable field is nullish.
6
+ */
7
+ function applyOptionality(schema, required) {
8
+ const nullable = schema.nullable ?? false;
9
+ return {
10
+ ...schema,
11
+ optional: !required && !nullable ? true : void 0,
12
+ nullish: !required && nullable ? true : void 0
13
+ };
14
+ }
15
+ Object.defineProperty(exports, "applyOptionality", {
16
+ enumerable: true,
17
+ get: function() {
18
+ return applyOptionality;
19
+ }
20
+ });
21
+
22
+ //# sourceMappingURL=optionality-D-zqzVMH.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"optionality-D-zqzVMH.cjs","names":[],"sources":["../src/optionality.ts"],"sourcesContent":["import type { SchemaNode } from './nodes/schema.ts'\n\n/**\n * Generic JSON Schema optionality: a non-required field is optional, and a\n * non-required nullable field is nullish.\n */\nexport function applyOptionality(schema: SchemaNode, required: boolean): SchemaNode {\n const nullable = schema.nullable ?? false\n\n return {\n ...schema,\n optional: !required && !nullable ? true : undefined,\n nullish: !required && nullable ? true : undefined,\n }\n}\n"],"mappings":";;;;;;AAMA,SAAgB,iBAAiB,QAAoB,UAA+B;CAClF,MAAM,WAAW,OAAO,YAAY;CAEpC,OAAO;EACL,GAAG;EACH,UAAU,CAAC,YAAY,CAAC,WAAW,OAAO,KAAA;EAC1C,SAAS,CAAC,YAAY,WAAW,OAAO,KAAA;CAC1C;AACF"}
@@ -0,0 +1,17 @@
1
+ import "./rolldown-runtime-BYyVTPww.js";
2
+ // src/optionality.ts
3
+ /**
4
+ * Generic JSON Schema optionality: a non-required field is optional, and a
5
+ * non-required nullable field is nullish.
6
+ */
7
+ function applyOptionality(schema, required) {
8
+ const nullable = schema.nullable ?? false;
9
+ return {
10
+ ...schema,
11
+ optional: !required && !nullable ? true : void 0,
12
+ nullish: !required && nullable ? true : void 0
13
+ };
14
+ }
15
+ export { applyOptionality as t };
16
+
17
+ //# sourceMappingURL=optionality-DISn8ytP.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"optionality-DISn8ytP.js","names":[],"sources":["../src/optionality.ts"],"sourcesContent":["import type { SchemaNode } from './nodes/schema.ts'\n\n/**\n * Generic JSON Schema optionality: a non-required field is optional, and a\n * non-required nullable field is nullish.\n */\nexport function applyOptionality(schema: SchemaNode, required: boolean): SchemaNode {\n const nullable = schema.nullable ?? false\n\n return {\n ...schema,\n optional: !required && !nullable ? true : undefined,\n nullish: !required && nullable ? true : undefined,\n }\n}\n"],"mappings":";;;;;;AAMA,SAAgB,iBAAiB,QAAoB,UAA+B;CAClF,MAAM,WAAW,OAAO,YAAY;CAEpC,OAAO;EACL,GAAG;EACH,UAAU,CAAC,YAAY,CAAC,WAAW,OAAO,KAAA;EAC1C,SAAS,CAAC,YAAY,WAAW,OAAO,KAAA;CAC1C;AACF"}
@@ -0,0 +1,50 @@
1
+ require("./rolldown-runtime-BV8xUvPy.cjs");
2
+ // ../../internals/utils/src/promise.ts
3
+ /**
4
+ * Returns the value cached under `key` in `store`, computing and storing it on the first call.
5
+ * Pass a `WeakMap` for object keys, so an entry goes away with its key, or a `Map` for primitive
6
+ * keys. A cached `null` or `undefined` counts as a hit, so `compute` runs once per key.
7
+ *
8
+ * @example
9
+ * `const refs = memo(refCache, node, () => collectRefs(node))`
10
+ */
11
+ function memo(store, key, compute) {
12
+ const cached = store.get(key);
13
+ if (cached !== void 0 || store.has(key)) return cached;
14
+ const value = compute();
15
+ store.set(key, value);
16
+ return value;
17
+ }
18
+ function createStore({ weak, max } = {}) {
19
+ if (weak) return /* @__PURE__ */ new WeakMap();
20
+ const entry = /* @__PURE__ */ new Map();
21
+ if (max === void 0) return entry;
22
+ const set = (key, value) => {
23
+ if (entry.size >= max) entry.clear();
24
+ entry.set(key, value);
25
+ };
26
+ if (max !== 1) return {
27
+ has: (key) => entry.has(key),
28
+ get: (key) => entry.get(key),
29
+ set
30
+ };
31
+ const touch = (key) => {
32
+ if (!entry.has(key)) return false;
33
+ set(key, entry.get(key));
34
+ return true;
35
+ };
36
+ return {
37
+ has: touch,
38
+ get: (key) => touch(key) ? entry.get(key) : void 0,
39
+ set
40
+ };
41
+ }
42
+ memo.create = createStore;
43
+ Object.defineProperty(exports, "memo", {
44
+ enumerable: true,
45
+ get: function() {
46
+ return memo;
47
+ }
48
+ });
49
+
50
+ //# sourceMappingURL=promise-BOdlgT0N.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promise-BOdlgT0N.cjs","names":[],"sources":["../../../internals/utils/src/promise.ts"],"sourcesContent":["/** A value that may already be resolved or still pending.\n *\n * @example\n * ```ts\n * function load(id: string): PossiblePromise<string> {\n * return cache.get(id) ?? fetchRemote(id)\n * }\n * ```\n */\nexport type PossiblePromise<T> = Promise<T> | T\n\ntype Store<TKey, TValue> = {\n has(key: TKey): boolean\n get(key: TKey): TValue | undefined\n set(key: TKey, value: TValue): unknown\n}\n\n/**\n * Returns the value cached under `key` in `store`, computing and storing it on the first call.\n * Pass a `WeakMap` for object keys, so an entry goes away with its key, or a `Map` for primitive\n * keys. A cached `null` or `undefined` counts as a hit, so `compute` runs once per key.\n *\n * @example\n * `const refs = memo(refCache, node, () => collectRefs(node))`\n */\nexport function memo<TKey, TValue>(store: Store<TKey, TValue>, key: TKey, compute: () => TValue): TValue {\n const cached = store.get(key)\n if (cached !== undefined || store.has(key)) return cached as TValue\n const value = compute()\n store.set(key, value)\n return value\n}\n\n/**\n * Creates a store for `memo`. With no options it is a `Map`. Each option changes one thing:\n *\n * - `weak` holds the keys weakly, in a `WeakMap`, so an entry goes away with its key.\n * - `max` bounds the store: it empties itself before the entry that would pass `max`, which keeps a\n * cache in a long-running process from growing without end. `max: 1` keeps only the last entry.\n *\n * @example\n * `const patterns = memo.create<string, RegExp>()`\n *\n * @example Freed with its key\n * `const refs = memo.create<SchemaNode, Array<string>>({ weak: true })`\n *\n * @example Bounded\n * `const names = memo.create<string, string>({ max: 100_000 })`\n *\n * @example Many values per key\n * ```ts\n * const filesByPlugin = memo.create<string, Array<string>>()\n * memo(filesByPlugin, 'plugin-ts', () => []).push('models.ts')\n * ```\n */\nfunction createStore<TKey, TValue>(options?: { weak?: false; max?: undefined }): Map<TKey, TValue>\nfunction createStore<TKey extends WeakKey, TValue>(options: { weak: true; max?: undefined }): WeakMap<TKey, TValue>\nfunction createStore<TKey, TValue>(options: { max: number; weak?: false }): Store<TKey, TValue>\nfunction createStore<TKey, TValue>({ weak, max }: { weak?: boolean; max?: number } = {}): Store<TKey, TValue> {\n if (weak) return new WeakMap<WeakKey, TValue>() as Store<TKey, TValue>\n const entry = new Map<TKey, TValue>()\n if (max === undefined) return entry\n const set = (key: TKey, value: TValue) => {\n if (entry.size >= max) entry.clear()\n entry.set(key, value)\n }\n if (max !== 1) return { has: (key) => entry.has(key), get: (key) => entry.get(key), set }\n // A key equal to the stored one but a different object, such as a copy of a string, replaces the\n // stored key, so the next lookup is an identity hit instead of a full comparison.\n const touch = (key: TKey) => {\n if (!entry.has(key)) return false\n set(key, entry.get(key) as TValue)\n return true\n }\n return { has: touch, get: (key) => (touch(key) ? entry.get(key) : undefined), set }\n}\n\nmemo.create = createStore\n\ntype ParallelOptions<TItem> = {\n /**\n * Items to work through, handed out in order.\n */\n items: ReadonlyArray<TItem>\n /**\n * How many items may be in flight at once.\n */\n limit: number\n /**\n * Runs once per item, with the item's position so a caller can report progress.\n */\n run(item: TItem, index: number): Promise<void>\n}\n\n/**\n * Runs `run` over every item with at most `limit` in flight. Workers share one iterator, so each\n * takes the next item the moment it frees up instead of waiting for a batch to drain.\n *\n * @example\n * ```ts\n * await inParallel({ items: files, limit: 50, run: (file) => storage.writeItem(file.path, file.source) })\n * ```\n */\nexport async function inParallel<TItem>({ items, limit, run }: ParallelOptions<TItem>): Promise<void> {\n const queue = items.entries()\n\n const worker = async (): Promise<void> => {\n for (const [index, item] of queue) await run(item, index)\n }\n\n await Promise.all(Array.from({ length: Math.min(limit, items.length) }, () => worker()))\n}\n"],"mappings":";;;;;;;;;;AAyBA,SAAgB,KAAmB,OAA4B,KAAW,SAA+B;CACvG,MAAM,SAAS,MAAM,IAAI,GAAG;CAC5B,IAAI,WAAW,KAAA,KAAa,MAAM,IAAI,GAAG,GAAG,OAAO;CACnD,MAAM,QAAQ,QAAQ;CACtB,MAAM,IAAI,KAAK,KAAK;CACpB,OAAO;AACT;AA2BA,SAAS,YAA0B,EAAE,MAAM,QAA0C,CAAC,GAAwB;CAC5G,IAAI,MAAM,uBAAO,IAAI,QAAyB;CAC9C,MAAM,wBAAQ,IAAI,IAAkB;CACpC,IAAI,QAAQ,KAAA,GAAW,OAAO;CAC9B,MAAM,OAAO,KAAW,UAAkB;EACxC,IAAI,MAAM,QAAQ,KAAK,MAAM,MAAM;EACnC,MAAM,IAAI,KAAK,KAAK;CACtB;CACA,IAAI,QAAQ,GAAG,OAAO;EAAE,MAAM,QAAQ,MAAM,IAAI,GAAG;EAAG,MAAM,QAAQ,MAAM,IAAI,GAAG;EAAG;CAAI;CAGxF,MAAM,SAAS,QAAc;EAC3B,IAAI,CAAC,MAAM,IAAI,GAAG,GAAG,OAAO;EAC5B,IAAI,KAAK,MAAM,IAAI,GAAG,CAAW;EACjC,OAAO;CACT;CACA,OAAO;EAAE,KAAK;EAAO,MAAM,QAAS,MAAM,GAAG,IAAI,MAAM,IAAI,GAAG,IAAI,KAAA;EAAY;CAAI;AACpF;AAEA,KAAK,SAAS"}
@@ -0,0 +1,45 @@
1
+ import "./rolldown-runtime-BYyVTPww.js";
2
+ // ../../internals/utils/src/promise.ts
3
+ /**
4
+ * Returns the value cached under `key` in `store`, computing and storing it on the first call.
5
+ * Pass a `WeakMap` for object keys, so an entry goes away with its key, or a `Map` for primitive
6
+ * keys. A cached `null` or `undefined` counts as a hit, so `compute` runs once per key.
7
+ *
8
+ * @example
9
+ * `const refs = memo(refCache, node, () => collectRefs(node))`
10
+ */
11
+ function memo(store, key, compute) {
12
+ const cached = store.get(key);
13
+ if (cached !== void 0 || store.has(key)) return cached;
14
+ const value = compute();
15
+ store.set(key, value);
16
+ return value;
17
+ }
18
+ function createStore({ weak, max } = {}) {
19
+ if (weak) return /* @__PURE__ */ new WeakMap();
20
+ const entry = /* @__PURE__ */ new Map();
21
+ if (max === void 0) return entry;
22
+ const set = (key, value) => {
23
+ if (entry.size >= max) entry.clear();
24
+ entry.set(key, value);
25
+ };
26
+ if (max !== 1) return {
27
+ has: (key) => entry.has(key),
28
+ get: (key) => entry.get(key),
29
+ set
30
+ };
31
+ const touch = (key) => {
32
+ if (!entry.has(key)) return false;
33
+ set(key, entry.get(key));
34
+ return true;
35
+ };
36
+ return {
37
+ has: touch,
38
+ get: (key) => touch(key) ? entry.get(key) : void 0,
39
+ set
40
+ };
41
+ }
42
+ memo.create = createStore;
43
+ export { memo as t };
44
+
45
+ //# sourceMappingURL=promise-RpnEev9D.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promise-RpnEev9D.js","names":[],"sources":["../../../internals/utils/src/promise.ts"],"sourcesContent":["/** A value that may already be resolved or still pending.\n *\n * @example\n * ```ts\n * function load(id: string): PossiblePromise<string> {\n * return cache.get(id) ?? fetchRemote(id)\n * }\n * ```\n */\nexport type PossiblePromise<T> = Promise<T> | T\n\ntype Store<TKey, TValue> = {\n has(key: TKey): boolean\n get(key: TKey): TValue | undefined\n set(key: TKey, value: TValue): unknown\n}\n\n/**\n * Returns the value cached under `key` in `store`, computing and storing it on the first call.\n * Pass a `WeakMap` for object keys, so an entry goes away with its key, or a `Map` for primitive\n * keys. A cached `null` or `undefined` counts as a hit, so `compute` runs once per key.\n *\n * @example\n * `const refs = memo(refCache, node, () => collectRefs(node))`\n */\nexport function memo<TKey, TValue>(store: Store<TKey, TValue>, key: TKey, compute: () => TValue): TValue {\n const cached = store.get(key)\n if (cached !== undefined || store.has(key)) return cached as TValue\n const value = compute()\n store.set(key, value)\n return value\n}\n\n/**\n * Creates a store for `memo`. With no options it is a `Map`. Each option changes one thing:\n *\n * - `weak` holds the keys weakly, in a `WeakMap`, so an entry goes away with its key.\n * - `max` bounds the store: it empties itself before the entry that would pass `max`, which keeps a\n * cache in a long-running process from growing without end. `max: 1` keeps only the last entry.\n *\n * @example\n * `const patterns = memo.create<string, RegExp>()`\n *\n * @example Freed with its key\n * `const refs = memo.create<SchemaNode, Array<string>>({ weak: true })`\n *\n * @example Bounded\n * `const names = memo.create<string, string>({ max: 100_000 })`\n *\n * @example Many values per key\n * ```ts\n * const filesByPlugin = memo.create<string, Array<string>>()\n * memo(filesByPlugin, 'plugin-ts', () => []).push('models.ts')\n * ```\n */\nfunction createStore<TKey, TValue>(options?: { weak?: false; max?: undefined }): Map<TKey, TValue>\nfunction createStore<TKey extends WeakKey, TValue>(options: { weak: true; max?: undefined }): WeakMap<TKey, TValue>\nfunction createStore<TKey, TValue>(options: { max: number; weak?: false }): Store<TKey, TValue>\nfunction createStore<TKey, TValue>({ weak, max }: { weak?: boolean; max?: number } = {}): Store<TKey, TValue> {\n if (weak) return new WeakMap<WeakKey, TValue>() as Store<TKey, TValue>\n const entry = new Map<TKey, TValue>()\n if (max === undefined) return entry\n const set = (key: TKey, value: TValue) => {\n if (entry.size >= max) entry.clear()\n entry.set(key, value)\n }\n if (max !== 1) return { has: (key) => entry.has(key), get: (key) => entry.get(key), set }\n // A key equal to the stored one but a different object, such as a copy of a string, replaces the\n // stored key, so the next lookup is an identity hit instead of a full comparison.\n const touch = (key: TKey) => {\n if (!entry.has(key)) return false\n set(key, entry.get(key) as TValue)\n return true\n }\n return { has: touch, get: (key) => (touch(key) ? entry.get(key) : undefined), set }\n}\n\nmemo.create = createStore\n\ntype ParallelOptions<TItem> = {\n /**\n * Items to work through, handed out in order.\n */\n items: ReadonlyArray<TItem>\n /**\n * How many items may be in flight at once.\n */\n limit: number\n /**\n * Runs once per item, with the item's position so a caller can report progress.\n */\n run(item: TItem, index: number): Promise<void>\n}\n\n/**\n * Runs `run` over every item with at most `limit` in flight. Workers share one iterator, so each\n * takes the next item the moment it frees up instead of waiting for a batch to drain.\n *\n * @example\n * ```ts\n * await inParallel({ items: files, limit: 50, run: (file) => storage.writeItem(file.path, file.source) })\n * ```\n */\nexport async function inParallel<TItem>({ items, limit, run }: ParallelOptions<TItem>): Promise<void> {\n const queue = items.entries()\n\n const worker = async (): Promise<void> => {\n for (const [index, item] of queue) await run(item, index)\n }\n\n await Promise.all(Array.from({ length: Math.min(limit, items.length) }, () => worker()))\n}\n"],"mappings":";;;;;;;;;;AAyBA,SAAgB,KAAmB,OAA4B,KAAW,SAA+B;CACvG,MAAM,SAAS,MAAM,IAAI,GAAG;CAC5B,IAAI,WAAW,KAAA,KAAa,MAAM,IAAI,GAAG,GAAG,OAAO;CACnD,MAAM,QAAQ,QAAQ;CACtB,MAAM,IAAI,KAAK,KAAK;CACpB,OAAO;AACT;AA2BA,SAAS,YAA0B,EAAE,MAAM,QAA0C,CAAC,GAAwB;CAC5G,IAAI,MAAM,uBAAO,IAAI,QAAyB;CAC9C,MAAM,wBAAQ,IAAI,IAAkB;CACpC,IAAI,QAAQ,KAAA,GAAW,OAAO;CAC9B,MAAM,OAAO,KAAW,UAAkB;EACxC,IAAI,MAAM,QAAQ,KAAK,MAAM,MAAM;EACnC,MAAM,IAAI,KAAK,KAAK;CACtB;CACA,IAAI,QAAQ,GAAG,OAAO;EAAE,MAAM,QAAQ,MAAM,IAAI,GAAG;EAAG,MAAM,QAAQ,MAAM,IAAI,GAAG;EAAG;CAAI;CAGxF,MAAM,SAAS,QAAc;EAC3B,IAAI,CAAC,MAAM,IAAI,GAAG,GAAG,OAAO;EAC5B,IAAI,KAAK,MAAM,IAAI,GAAG,CAAW;EACjC,OAAO;CACT;CACA,OAAO;EAAE,KAAK;EAAO,MAAM,QAAS,MAAM,GAAG,IAAI,MAAM,IAAI,GAAG,IAAI,KAAA;EAAY;CAAI;AACpF;AAEA,KAAK,SAAS"}
@@ -0,0 +1,22 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-BYyVTPww.js";
2
+ import { a as resolveRefName, i as resolveRef, n as mergeRefWithSchema, r as refName, t as isBareRef } from "./refs-YCV3CznS.js";
3
+ import { n as narrowSchema } from "./guards-DlJkKsT1.js";
4
+ import { t as createSchema } from "./schema-2ZAQk7qE.js";
5
+ // src/ref/index.ts
6
+ var ref_exports = /* @__PURE__ */ __exportAll({
7
+ getName: () => getName,
8
+ getSchema: () => resolveRef,
9
+ isAlias: () => isBareRef,
10
+ mergeSchema: () => mergeSchema
11
+ });
12
+ /** A resolved ref merged with its target schema, so usage-site fields such as `description` win. Other nodes come back unchanged. */
13
+ function mergeSchema(node) {
14
+ const ref = narrowSchema(node, "ref");
15
+ return ref?.schema ? createSchema(mergeRefWithSchema(ref)) : node;
16
+ }
17
+ function getName(input) {
18
+ return typeof input === "string" ? refName(input) : resolveRefName(input);
19
+ }
20
+ export { mergeSchema as n, ref_exports as r, getName as t };
21
+
22
+ //# sourceMappingURL=ref-Bu7PoHar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ref-Bu7PoHar.js","names":[],"sources":["../src/ref/index.ts"],"sourcesContent":["export { isBareRef as isAlias, resolveRef as getSchema } from '../utils/refs.ts'\nimport { narrowSchema } from '../guards.ts'\nimport { createSchema, type SchemaNode } from '../nodes/schema.ts'\nimport { mergeRefWithSchema, refName, resolveRefName } from '../utils/refs.ts'\n\n/** A resolved ref merged with its target schema, so usage-site fields such as `description` win. Other nodes come back unchanged. */\nexport function mergeSchema(node: SchemaNode): SchemaNode {\n const ref = narrowSchema(node, 'ref')\n return ref?.schema ? createSchema(mergeRefWithSchema(ref)) : node\n}\n\n/**\n * The name a ref points at. A `$ref` string gives its last segment: `'#/components/schemas/Pet'` gives `'Pet'`.\n * A ref node gives its `targetName` first, so pass the node, not `node.ref`, to respect a renamed target. Other nodes give `null`.\n */\nexport function getName(ref: string): string\nexport function getName(node: SchemaNode | null | undefined): string | null\nexport function getName(input: string | SchemaNode | null | undefined): string | null {\n return typeof input === 'string' ? refName(input) : resolveRefName(input)\n}\n"],"mappings":";;;;;;;;;;;;AAMA,SAAgB,YAAY,MAA8B;CACxD,MAAM,MAAM,aAAa,MAAM,KAAK;CACpC,OAAO,KAAK,SAAS,aAAa,mBAAmB,GAAG,CAAC,IAAI;AAC/D;AAQA,SAAgB,QAAQ,OAA8D;CACpF,OAAO,OAAO,UAAU,WAAW,QAAQ,KAAK,IAAI,eAAe,KAAK;AAC1E"}
@@ -0,0 +1,39 @@
1
+ const require_rolldown_runtime = require("./rolldown-runtime-BV8xUvPy.cjs");
2
+ const require_refs = require("./refs-CYHpRlQo.cjs");
3
+ const require_guards = require("./guards-COVJE6TU.cjs");
4
+ const require_schema = require("./schema-hxMlgCrV.cjs");
5
+ // src/ref/index.ts
6
+ var ref_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
7
+ getName: () => getName,
8
+ getSchema: () => require_refs.resolveRef,
9
+ isAlias: () => require_refs.isBareRef,
10
+ mergeSchema: () => mergeSchema
11
+ });
12
+ /** A resolved ref merged with its target schema, so usage-site fields such as `description` win. Other nodes come back unchanged. */
13
+ function mergeSchema(node) {
14
+ const ref = require_guards.narrowSchema(node, "ref");
15
+ return ref?.schema ? require_schema.createSchema(require_refs.mergeRefWithSchema(ref)) : node;
16
+ }
17
+ function getName(input) {
18
+ return typeof input === "string" ? require_refs.refName(input) : require_refs.resolveRefName(input);
19
+ }
20
+ Object.defineProperty(exports, "getName", {
21
+ enumerable: true,
22
+ get: function() {
23
+ return getName;
24
+ }
25
+ });
26
+ Object.defineProperty(exports, "mergeSchema", {
27
+ enumerable: true,
28
+ get: function() {
29
+ return mergeSchema;
30
+ }
31
+ });
32
+ Object.defineProperty(exports, "ref_exports", {
33
+ enumerable: true,
34
+ get: function() {
35
+ return ref_exports;
36
+ }
37
+ });
38
+
39
+ //# sourceMappingURL=ref-P0ZLT1Bg.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ref-P0ZLT1Bg.cjs","names":["narrowSchema","createSchema","mergeRefWithSchema","refName","resolveRefName"],"sources":["../src/ref/index.ts"],"sourcesContent":["export { isBareRef as isAlias, resolveRef as getSchema } from '../utils/refs.ts'\nimport { narrowSchema } from '../guards.ts'\nimport { createSchema, type SchemaNode } from '../nodes/schema.ts'\nimport { mergeRefWithSchema, refName, resolveRefName } from '../utils/refs.ts'\n\n/** A resolved ref merged with its target schema, so usage-site fields such as `description` win. Other nodes come back unchanged. */\nexport function mergeSchema(node: SchemaNode): SchemaNode {\n const ref = narrowSchema(node, 'ref')\n return ref?.schema ? createSchema(mergeRefWithSchema(ref)) : node\n}\n\n/**\n * The name a ref points at. A `$ref` string gives its last segment: `'#/components/schemas/Pet'` gives `'Pet'`.\n * A ref node gives its `targetName` first, so pass the node, not `node.ref`, to respect a renamed target. Other nodes give `null`.\n */\nexport function getName(ref: string): string\nexport function getName(node: SchemaNode | null | undefined): string | null\nexport function getName(input: string | SchemaNode | null | undefined): string | null {\n return typeof input === 'string' ? refName(input) : resolveRefName(input)\n}\n"],"mappings":";;;;;;;;;;;;AAMA,SAAgB,YAAY,MAA8B;CACxD,MAAM,MAAMA,eAAAA,aAAa,MAAM,KAAK;CACpC,OAAO,KAAK,SAASC,eAAAA,aAAaC,aAAAA,mBAAmB,GAAG,CAAC,IAAI;AAC/D;AAQA,SAAgB,QAAQ,OAA8D;CACpF,OAAO,OAAO,UAAU,WAAWC,aAAAA,QAAQ,KAAK,IAAIC,aAAAA,eAAe,KAAK;AAC1E"}
package/dist/ref.cjs ADDED
@@ -0,0 +1,7 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_refs = require("./refs-CYHpRlQo.cjs");
3
+ const require_ref = require("./ref-P0ZLT1Bg.cjs");
4
+ exports.getName = require_ref.getName;
5
+ exports.getSchema = require_refs.resolveRef;
6
+ exports.isAlias = require_refs.isBareRef;
7
+ exports.mergeSchema = require_ref.mergeSchema;
package/dist/ref.d.cts ADDED
@@ -0,0 +1,2 @@
1
+ import { i as isBareRef, o as resolveRef, r as mergeSchema, t as getName } from "./index-DU_jYpBt.cjs";
2
+ export { getName, resolveRef as getSchema, isBareRef as isAlias, mergeSchema };
package/dist/ref.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import { i as isBareRef, o as resolveRef, r as mergeSchema, t as getName } from "./index-CFH4ZC7q.js";
2
+ export { getName, resolveRef as getSchema, isBareRef as isAlias, mergeSchema };
package/dist/ref.js ADDED
@@ -0,0 +1,3 @@
1
+ import { i as resolveRef, t as isBareRef } from "./refs-YCV3CznS.js";
2
+ import { n as mergeSchema, t as getName } from "./ref-Bu7PoHar.js";
3
+ export { getName, resolveRef as getSchema, isBareRef as isAlias, mergeSchema };
@@ -0,0 +1,131 @@
1
+ require("./rolldown-runtime-BV8xUvPy.cjs");
2
+ const require_promise = require("./promise-BOdlgT0N.cjs");
3
+ // src/utils/refs.ts
4
+ /**
5
+ * Returns the last segment of a `$ref` pointer, for example `'Pet'` for `#/components/schemas/Pet`.
6
+ * The segment is decoded like the pointer resolver does: percent-escapes first, then `~1` and `~0`
7
+ * (RFC 6901), so `a~1b~0c` names the component `a/b~c`.
8
+ */
9
+ function refName(ref) {
10
+ return require_promise.memo(refNames, ref, () => {
11
+ const segment = ref.split("/").at(-1) ?? ref;
12
+ let decoded = segment;
13
+ try {
14
+ decoded = decodeURIComponent(segment);
15
+ } catch {}
16
+ return decoded.replaceAll("~1", "/").replaceAll("~0", "~");
17
+ });
18
+ }
19
+ const refNames = require_promise.memo.create({ max: 1e5 });
20
+ /**
21
+ * Resolves the emitted name of the schema a ref node points at. Prefers `targetName` (set when
22
+ * the referenced schema was renamed, e.g. to break a collision), then the last segment of `ref`,
23
+ * then `name`, then the nested `schema.name`.
24
+ *
25
+ * Returns `null` for non-ref nodes or when no name resolves.
26
+ *
27
+ * @example
28
+ * `resolveRefName({ kind: 'Schema', type: 'ref', ref: '#/components/schemas/Pet' }) // 'Pet'`
29
+ *
30
+ * @example Collision-renamed target
31
+ * `resolveRefName({ kind: 'Schema', type: 'ref', ref: '#/components/schemas/Order', targetName: 'OrderSchema' }) // 'OrderSchema'`
32
+ */
33
+ function resolveRefName(node) {
34
+ if (!node || node.type !== "ref") return null;
35
+ if (node.targetName) return node.targetName;
36
+ if (node.ref) return refName(node.ref);
37
+ return node.name ?? node.schema?.name ?? null;
38
+ }
39
+ /**
40
+ * Follows a resolved ref chain to its target schema. Returns an unresolved or cyclic ref as is.
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * const target = resolveRef(refSchema)
45
+ * ```
46
+ */
47
+ function resolveRef(node) {
48
+ if (node.type !== "ref" || !node.schema) return node;
49
+ const seen = /* @__PURE__ */ new WeakSet();
50
+ let current = node;
51
+ while (current.type === "ref" && current.schema) {
52
+ if (seen.has(current)) return current;
53
+ seen.add(current);
54
+ current = current.schema;
55
+ }
56
+ return current;
57
+ }
58
+ /** Fields of a ref node that describe the ref itself, so they never override the resolved schema. */
59
+ const REF_OWN_KEYS = /* @__PURE__ */ new Set([
60
+ "kind",
61
+ "type",
62
+ "name",
63
+ "ref",
64
+ "schema"
65
+ ]);
66
+ /**
67
+ * Merges a ref node with its resolved schema, giving the fields set at the usage site precedence.
68
+ *
69
+ * Every field on the ref except `kind`, `type`, `name`, `ref`, and `schema` overrides the same field
70
+ * of the resolved `schema` (for example `description`, `nullable`, `readOnly`, `deprecated`). Fields
71
+ * left `undefined` on the ref do not shadow the resolved schema. A ref without a resolved `schema`
72
+ * is returned as is.
73
+ *
74
+ * @example
75
+ * ```ts
76
+ * const ref = createSchema({ type: 'ref', ref: '#/components/schemas/Pet', description: 'A pet', schema: petSchema })
77
+ * mergeRefWithSchema(ref) // petSchema's fields with description 'A pet'
78
+ * ```
79
+ */
80
+ function mergeRefWithSchema(node) {
81
+ if (!node.schema) return node;
82
+ const merged = { ...node.schema };
83
+ for (const key of Object.keys(node)) {
84
+ const value = node[key];
85
+ if (value !== void 0 && !REF_OWN_KEYS.has(key)) merged[key] = value;
86
+ }
87
+ return merged;
88
+ }
89
+ /**
90
+ * Returns `true` when a schema is a bare ref without modifiers, metadata, or omit keys.
91
+ *
92
+ * Modifiers inherited from the resolved schema are included in the check because a ref emits the
93
+ * referenced schema variable with those modifiers already applied.
94
+ */
95
+ function isBareRef(node, keysToOmit) {
96
+ if (!node || node.type !== "ref") return false;
97
+ const meta = mergeRefWithSchema(node);
98
+ return !meta.nullable && !meta.optional && !meta.nullish && meta.default === void 0 && !meta.description && !meta.examples?.length && !keysToOmit?.length;
99
+ }
100
+ Object.defineProperty(exports, "isBareRef", {
101
+ enumerable: true,
102
+ get: function() {
103
+ return isBareRef;
104
+ }
105
+ });
106
+ Object.defineProperty(exports, "mergeRefWithSchema", {
107
+ enumerable: true,
108
+ get: function() {
109
+ return mergeRefWithSchema;
110
+ }
111
+ });
112
+ Object.defineProperty(exports, "refName", {
113
+ enumerable: true,
114
+ get: function() {
115
+ return refName;
116
+ }
117
+ });
118
+ Object.defineProperty(exports, "resolveRef", {
119
+ enumerable: true,
120
+ get: function() {
121
+ return resolveRef;
122
+ }
123
+ });
124
+ Object.defineProperty(exports, "resolveRefName", {
125
+ enumerable: true,
126
+ get: function() {
127
+ return resolveRefName;
128
+ }
129
+ });
130
+
131
+ //# sourceMappingURL=refs-CYHpRlQo.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refs-CYHpRlQo.cjs","names":["memo"],"sources":["../src/utils/refs.ts"],"sourcesContent":["import { memo } from '@internals/utils'\nimport type { RefSchemaNode, SchemaNode } from '../nodes/schema.ts'\n\n/**\n * Returns the last segment of a `$ref` pointer, for example `'Pet'` for `#/components/schemas/Pet`.\n * The segment is decoded like the pointer resolver does: percent-escapes first, then `~1` and `~0`\n * (RFC 6901), so `a~1b~0c` names the component `a/b~c`.\n */\nexport function refName(ref: string): string {\n return memo(refNames, ref, () => {\n const segment = ref.split('/').at(-1) ?? ref\n let decoded = segment\n\n try {\n decoded = decodeURIComponent(segment)\n } catch {\n // A stray `%` is not a valid escape, so the segment is already the literal name.\n }\n\n return decoded.replaceAll('~1', '/').replaceAll('~0', '~')\n })\n}\n\n// Every plugin resolves the same refs on every visit; the limit only bounds a long-running host.\nconst refNames = memo.create<string, string>({ max: 100_000 })\n\n/**\n * Resolves the emitted name of the schema a ref node points at. Prefers `targetName` (set when\n * the referenced schema was renamed, e.g. to break a collision), then the last segment of `ref`,\n * then `name`, then the nested `schema.name`.\n *\n * Returns `null` for non-ref nodes or when no name resolves.\n *\n * @example\n * `resolveRefName({ kind: 'Schema', type: 'ref', ref: '#/components/schemas/Pet' }) // 'Pet'`\n *\n * @example Collision-renamed target\n * `resolveRefName({ kind: 'Schema', type: 'ref', ref: '#/components/schemas/Order', targetName: 'OrderSchema' }) // 'OrderSchema'`\n */\nexport function resolveRefName(node: SchemaNode | null | undefined): string | null {\n if (!node || node.type !== 'ref') return null\n if (node.targetName) return node.targetName\n if (node.ref) return refName(node.ref)\n\n return node.name ?? node.schema?.name ?? null\n}\n\n/**\n * Follows a resolved ref chain to its target schema. Returns an unresolved or cyclic ref as is.\n *\n * @example\n * ```ts\n * const target = resolveRef(refSchema)\n * ```\n */\nexport function resolveRef(node: SchemaNode): SchemaNode {\n if (node.type !== 'ref' || !node.schema) return node\n\n const seen = new WeakSet<SchemaNode>()\n let current: SchemaNode = node\n while (current.type === 'ref' && current.schema) {\n if (seen.has(current)) return current\n seen.add(current)\n current = current.schema\n }\n return current\n}\n\n/** Fields of a ref node that describe the ref itself, so they never override the resolved schema. */\nconst REF_OWN_KEYS: ReadonlySet<string> = new Set(['kind', 'type', 'name', 'ref', 'schema'])\n\n/**\n * Merges a ref node with its resolved schema, giving the fields set at the usage site precedence.\n *\n * Every field on the ref except `kind`, `type`, `name`, `ref`, and `schema` overrides the same field\n * of the resolved `schema` (for example `description`, `nullable`, `readOnly`, `deprecated`). Fields\n * left `undefined` on the ref do not shadow the resolved schema. A ref without a resolved `schema`\n * is returned as is.\n *\n * @example\n * ```ts\n * const ref = createSchema({ type: 'ref', ref: '#/components/schemas/Pet', description: 'A pet', schema: petSchema })\n * mergeRefWithSchema(ref) // petSchema's fields with description 'A pet'\n * ```\n */\nexport function mergeRefWithSchema(node: RefSchemaNode): SchemaNode {\n if (!node.schema) return node\n\n const merged: Record<string, unknown> = { ...node.schema }\n for (const key of Object.keys(node)) {\n const value = (node as Record<string, unknown>)[key]\n if (value !== undefined && !REF_OWN_KEYS.has(key)) merged[key] = value\n }\n\n return merged as SchemaNode\n}\n\n/**\n * Returns `true` when a schema is a bare ref without modifiers, metadata, or omit keys.\n *\n * Modifiers inherited from the resolved schema are included in the check because a ref emits the\n * referenced schema variable with those modifiers already applied.\n */\nexport function isBareRef(node: SchemaNode | null | undefined, keysToOmit?: Array<string> | null): boolean {\n if (!node || node.type !== 'ref') return false\n\n const meta = mergeRefWithSchema(node)\n\n return !meta.nullable && !meta.optional && !meta.nullish && meta.default === undefined && !meta.description && !meta.examples?.length && !keysToOmit?.length\n}\n"],"mappings":";;;;;;;;AAQA,SAAgB,QAAQ,KAAqB;CAC3C,OAAOA,gBAAAA,KAAK,UAAU,WAAW;EAC/B,MAAM,UAAU,IAAI,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK;EACzC,IAAI,UAAU;EAEd,IAAI;GACF,UAAU,mBAAmB,OAAO;EACtC,QAAQ,CAER;EAEA,OAAO,QAAQ,WAAW,MAAM,GAAG,CAAC,CAAC,WAAW,MAAM,GAAG;CAC3D,CAAC;AACH;AAGA,MAAM,WAAWA,gBAAAA,KAAK,OAAuB,EAAE,KAAK,IAAQ,CAAC;;;;;;;;;;;;;;AAe7D,SAAgB,eAAe,MAAoD;CACjF,IAAI,CAAC,QAAQ,KAAK,SAAS,OAAO,OAAO;CACzC,IAAI,KAAK,YAAY,OAAO,KAAK;CACjC,IAAI,KAAK,KAAK,OAAO,QAAQ,KAAK,GAAG;CAErC,OAAO,KAAK,QAAQ,KAAK,QAAQ,QAAQ;AAC3C;;;;;;;;;AAUA,SAAgB,WAAW,MAA8B;CACvD,IAAI,KAAK,SAAS,SAAS,CAAC,KAAK,QAAQ,OAAO;CAEhD,MAAM,uBAAO,IAAI,QAAoB;CACrC,IAAI,UAAsB;CAC1B,OAAO,QAAQ,SAAS,SAAS,QAAQ,QAAQ;EAC/C,IAAI,KAAK,IAAI,OAAO,GAAG,OAAO;EAC9B,KAAK,IAAI,OAAO;EAChB,UAAU,QAAQ;CACpB;CACA,OAAO;AACT;;AAGA,MAAM,+BAAoC,IAAI,IAAI;CAAC;CAAQ;CAAQ;CAAQ;CAAO;AAAQ,CAAC;;;;;;;;;;;;;;;AAgB3F,SAAgB,mBAAmB,MAAiC;CAClE,IAAI,CAAC,KAAK,QAAQ,OAAO;CAEzB,MAAM,SAAkC,EAAE,GAAG,KAAK,OAAO;CACzD,KAAK,MAAM,OAAO,OAAO,KAAK,IAAI,GAAG;EACnC,MAAM,QAAS,KAAiC;EAChD,IAAI,UAAU,KAAA,KAAa,CAAC,aAAa,IAAI,GAAG,GAAG,OAAO,OAAO;CACnE;CAEA,OAAO;AACT;;;;;;;AAQA,SAAgB,UAAU,MAAqC,YAA4C;CACzG,IAAI,CAAC,QAAQ,KAAK,SAAS,OAAO,OAAO;CAEzC,MAAM,OAAO,mBAAmB,IAAI;CAEpC,OAAO,CAAC,KAAK,YAAY,CAAC,KAAK,YAAY,CAAC,KAAK,WAAW,KAAK,YAAY,KAAA,KAAa,CAAC,KAAK,eAAe,CAAC,KAAK,UAAU,UAAU,CAAC,YAAY;AACxJ"}
@@ -0,0 +1,102 @@
1
+ import "./rolldown-runtime-BYyVTPww.js";
2
+ import { t as memo } from "./promise-RpnEev9D.js";
3
+ // src/utils/refs.ts
4
+ /**
5
+ * Returns the last segment of a `$ref` pointer, for example `'Pet'` for `#/components/schemas/Pet`.
6
+ * The segment is decoded like the pointer resolver does: percent-escapes first, then `~1` and `~0`
7
+ * (RFC 6901), so `a~1b~0c` names the component `a/b~c`.
8
+ */
9
+ function refName(ref) {
10
+ return memo(refNames, ref, () => {
11
+ const segment = ref.split("/").at(-1) ?? ref;
12
+ let decoded = segment;
13
+ try {
14
+ decoded = decodeURIComponent(segment);
15
+ } catch {}
16
+ return decoded.replaceAll("~1", "/").replaceAll("~0", "~");
17
+ });
18
+ }
19
+ const refNames = memo.create({ max: 1e5 });
20
+ /**
21
+ * Resolves the emitted name of the schema a ref node points at. Prefers `targetName` (set when
22
+ * the referenced schema was renamed, e.g. to break a collision), then the last segment of `ref`,
23
+ * then `name`, then the nested `schema.name`.
24
+ *
25
+ * Returns `null` for non-ref nodes or when no name resolves.
26
+ *
27
+ * @example
28
+ * `resolveRefName({ kind: 'Schema', type: 'ref', ref: '#/components/schemas/Pet' }) // 'Pet'`
29
+ *
30
+ * @example Collision-renamed target
31
+ * `resolveRefName({ kind: 'Schema', type: 'ref', ref: '#/components/schemas/Order', targetName: 'OrderSchema' }) // 'OrderSchema'`
32
+ */
33
+ function resolveRefName(node) {
34
+ if (!node || node.type !== "ref") return null;
35
+ if (node.targetName) return node.targetName;
36
+ if (node.ref) return refName(node.ref);
37
+ return node.name ?? node.schema?.name ?? null;
38
+ }
39
+ /**
40
+ * Follows a resolved ref chain to its target schema. Returns an unresolved or cyclic ref as is.
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * const target = resolveRef(refSchema)
45
+ * ```
46
+ */
47
+ function resolveRef(node) {
48
+ if (node.type !== "ref" || !node.schema) return node;
49
+ const seen = /* @__PURE__ */ new WeakSet();
50
+ let current = node;
51
+ while (current.type === "ref" && current.schema) {
52
+ if (seen.has(current)) return current;
53
+ seen.add(current);
54
+ current = current.schema;
55
+ }
56
+ return current;
57
+ }
58
+ /** Fields of a ref node that describe the ref itself, so they never override the resolved schema. */
59
+ const REF_OWN_KEYS = /* @__PURE__ */ new Set([
60
+ "kind",
61
+ "type",
62
+ "name",
63
+ "ref",
64
+ "schema"
65
+ ]);
66
+ /**
67
+ * Merges a ref node with its resolved schema, giving the fields set at the usage site precedence.
68
+ *
69
+ * Every field on the ref except `kind`, `type`, `name`, `ref`, and `schema` overrides the same field
70
+ * of the resolved `schema` (for example `description`, `nullable`, `readOnly`, `deprecated`). Fields
71
+ * left `undefined` on the ref do not shadow the resolved schema. A ref without a resolved `schema`
72
+ * is returned as is.
73
+ *
74
+ * @example
75
+ * ```ts
76
+ * const ref = createSchema({ type: 'ref', ref: '#/components/schemas/Pet', description: 'A pet', schema: petSchema })
77
+ * mergeRefWithSchema(ref) // petSchema's fields with description 'A pet'
78
+ * ```
79
+ */
80
+ function mergeRefWithSchema(node) {
81
+ if (!node.schema) return node;
82
+ const merged = { ...node.schema };
83
+ for (const key of Object.keys(node)) {
84
+ const value = node[key];
85
+ if (value !== void 0 && !REF_OWN_KEYS.has(key)) merged[key] = value;
86
+ }
87
+ return merged;
88
+ }
89
+ /**
90
+ * Returns `true` when a schema is a bare ref without modifiers, metadata, or omit keys.
91
+ *
92
+ * Modifiers inherited from the resolved schema are included in the check because a ref emits the
93
+ * referenced schema variable with those modifiers already applied.
94
+ */
95
+ function isBareRef(node, keysToOmit) {
96
+ if (!node || node.type !== "ref") return false;
97
+ const meta = mergeRefWithSchema(node);
98
+ return !meta.nullable && !meta.optional && !meta.nullish && meta.default === void 0 && !meta.description && !meta.examples?.length && !keysToOmit?.length;
99
+ }
100
+ export { resolveRefName as a, resolveRef as i, mergeRefWithSchema as n, refName as r, isBareRef as t };
101
+
102
+ //# sourceMappingURL=refs-YCV3CznS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refs-YCV3CznS.js","names":[],"sources":["../src/utils/refs.ts"],"sourcesContent":["import { memo } from '@internals/utils'\nimport type { RefSchemaNode, SchemaNode } from '../nodes/schema.ts'\n\n/**\n * Returns the last segment of a `$ref` pointer, for example `'Pet'` for `#/components/schemas/Pet`.\n * The segment is decoded like the pointer resolver does: percent-escapes first, then `~1` and `~0`\n * (RFC 6901), so `a~1b~0c` names the component `a/b~c`.\n */\nexport function refName(ref: string): string {\n return memo(refNames, ref, () => {\n const segment = ref.split('/').at(-1) ?? ref\n let decoded = segment\n\n try {\n decoded = decodeURIComponent(segment)\n } catch {\n // A stray `%` is not a valid escape, so the segment is already the literal name.\n }\n\n return decoded.replaceAll('~1', '/').replaceAll('~0', '~')\n })\n}\n\n// Every plugin resolves the same refs on every visit; the limit only bounds a long-running host.\nconst refNames = memo.create<string, string>({ max: 100_000 })\n\n/**\n * Resolves the emitted name of the schema a ref node points at. Prefers `targetName` (set when\n * the referenced schema was renamed, e.g. to break a collision), then the last segment of `ref`,\n * then `name`, then the nested `schema.name`.\n *\n * Returns `null` for non-ref nodes or when no name resolves.\n *\n * @example\n * `resolveRefName({ kind: 'Schema', type: 'ref', ref: '#/components/schemas/Pet' }) // 'Pet'`\n *\n * @example Collision-renamed target\n * `resolveRefName({ kind: 'Schema', type: 'ref', ref: '#/components/schemas/Order', targetName: 'OrderSchema' }) // 'OrderSchema'`\n */\nexport function resolveRefName(node: SchemaNode | null | undefined): string | null {\n if (!node || node.type !== 'ref') return null\n if (node.targetName) return node.targetName\n if (node.ref) return refName(node.ref)\n\n return node.name ?? node.schema?.name ?? null\n}\n\n/**\n * Follows a resolved ref chain to its target schema. Returns an unresolved or cyclic ref as is.\n *\n * @example\n * ```ts\n * const target = resolveRef(refSchema)\n * ```\n */\nexport function resolveRef(node: SchemaNode): SchemaNode {\n if (node.type !== 'ref' || !node.schema) return node\n\n const seen = new WeakSet<SchemaNode>()\n let current: SchemaNode = node\n while (current.type === 'ref' && current.schema) {\n if (seen.has(current)) return current\n seen.add(current)\n current = current.schema\n }\n return current\n}\n\n/** Fields of a ref node that describe the ref itself, so they never override the resolved schema. */\nconst REF_OWN_KEYS: ReadonlySet<string> = new Set(['kind', 'type', 'name', 'ref', 'schema'])\n\n/**\n * Merges a ref node with its resolved schema, giving the fields set at the usage site precedence.\n *\n * Every field on the ref except `kind`, `type`, `name`, `ref`, and `schema` overrides the same field\n * of the resolved `schema` (for example `description`, `nullable`, `readOnly`, `deprecated`). Fields\n * left `undefined` on the ref do not shadow the resolved schema. A ref without a resolved `schema`\n * is returned as is.\n *\n * @example\n * ```ts\n * const ref = createSchema({ type: 'ref', ref: '#/components/schemas/Pet', description: 'A pet', schema: petSchema })\n * mergeRefWithSchema(ref) // petSchema's fields with description 'A pet'\n * ```\n */\nexport function mergeRefWithSchema(node: RefSchemaNode): SchemaNode {\n if (!node.schema) return node\n\n const merged: Record<string, unknown> = { ...node.schema }\n for (const key of Object.keys(node)) {\n const value = (node as Record<string, unknown>)[key]\n if (value !== undefined && !REF_OWN_KEYS.has(key)) merged[key] = value\n }\n\n return merged as SchemaNode\n}\n\n/**\n * Returns `true` when a schema is a bare ref without modifiers, metadata, or omit keys.\n *\n * Modifiers inherited from the resolved schema are included in the check because a ref emits the\n * referenced schema variable with those modifiers already applied.\n */\nexport function isBareRef(node: SchemaNode | null | undefined, keysToOmit?: Array<string> | null): boolean {\n if (!node || node.type !== 'ref') return false\n\n const meta = mergeRefWithSchema(node)\n\n return !meta.nullable && !meta.optional && !meta.nullish && meta.default === undefined && !meta.description && !meta.examples?.length && !keysToOmit?.length\n}\n"],"mappings":";;;;;;;;AAQA,SAAgB,QAAQ,KAAqB;CAC3C,OAAO,KAAK,UAAU,WAAW;EAC/B,MAAM,UAAU,IAAI,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK;EACzC,IAAI,UAAU;EAEd,IAAI;GACF,UAAU,mBAAmB,OAAO;EACtC,QAAQ,CAER;EAEA,OAAO,QAAQ,WAAW,MAAM,GAAG,CAAC,CAAC,WAAW,MAAM,GAAG;CAC3D,CAAC;AACH;AAGA,MAAM,WAAW,KAAK,OAAuB,EAAE,KAAK,IAAQ,CAAC;;;;;;;;;;;;;;AAe7D,SAAgB,eAAe,MAAoD;CACjF,IAAI,CAAC,QAAQ,KAAK,SAAS,OAAO,OAAO;CACzC,IAAI,KAAK,YAAY,OAAO,KAAK;CACjC,IAAI,KAAK,KAAK,OAAO,QAAQ,KAAK,GAAG;CAErC,OAAO,KAAK,QAAQ,KAAK,QAAQ,QAAQ;AAC3C;;;;;;;;;AAUA,SAAgB,WAAW,MAA8B;CACvD,IAAI,KAAK,SAAS,SAAS,CAAC,KAAK,QAAQ,OAAO;CAEhD,MAAM,uBAAO,IAAI,QAAoB;CACrC,IAAI,UAAsB;CAC1B,OAAO,QAAQ,SAAS,SAAS,QAAQ,QAAQ;EAC/C,IAAI,KAAK,IAAI,OAAO,GAAG,OAAO;EAC9B,KAAK,IAAI,OAAO;EAChB,UAAU,QAAQ;CACpB;CACA,OAAO;AACT;;AAGA,MAAM,+BAAoC,IAAI,IAAI;CAAC;CAAQ;CAAQ;CAAQ;CAAO;AAAQ,CAAC;;;;;;;;;;;;;;;AAgB3F,SAAgB,mBAAmB,MAAiC;CAClE,IAAI,CAAC,KAAK,QAAQ,OAAO;CAEzB,MAAM,SAAkC,EAAE,GAAG,KAAK,OAAO;CACzD,KAAK,MAAM,OAAO,OAAO,KAAK,IAAI,GAAG;EACnC,MAAM,QAAS,KAAiC;EAChD,IAAI,UAAU,KAAA,KAAa,CAAC,aAAa,IAAI,GAAG,GAAG,OAAO,OAAO;CACnE;CAEA,OAAO;AACT;;;;;;;AAQA,SAAgB,UAAU,MAAqC,YAA4C;CACzG,IAAI,CAAC,QAAQ,KAAK,SAAS,OAAO,OAAO;CAEzC,MAAM,OAAO,mBAAmB,IAAI;CAEpC,OAAO,CAAC,KAAK,YAAY,CAAC,KAAK,YAAY,CAAC,KAAK,WAAW,KAAK,YAAY,KAAA,KAAa,CAAC,KAAK,eAAe,CAAC,KAAK,UAAU,UAAU,CAAC,YAAY;AACxJ"}
@@ -0,0 +1,52 @@
1
+ // \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", {
5
+ value,
6
+ configurable: true
7
+ });
8
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
9
+ var __getOwnPropNames = Object.getOwnPropertyNames;
10
+ var __getProtoOf = Object.getPrototypeOf;
11
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
12
+ var __exportAll = (all, flags) => {
13
+ let target = Object.setPrototypeOf({}, null);
14
+ for (var name in all) __defProp(target, name, {
15
+ get: all[name],
16
+ enumerable: true
17
+ });
18
+ if (!(flags & 1)) __defProp(target, Symbol.toStringTag, { value: "Module" });
19
+ return flags & 2 ? target : Object.preventExtensions(target);
20
+ };
21
+ var __copyProps = (to, from, except, desc) => {
22
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
23
+ key = keys[i];
24
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
25
+ get: ((k) => from[k]).bind(null, key),
26
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
27
+ });
28
+ }
29
+ return to;
30
+ };
31
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
32
+ value: mod,
33
+ enumerable: true
34
+ }) : target, mod));
35
+ Object.defineProperty(exports, "__exportAll", {
36
+ enumerable: true,
37
+ get: function() {
38
+ return __exportAll;
39
+ }
40
+ });
41
+ Object.defineProperty(exports, "__name", {
42
+ enumerable: true,
43
+ get: function() {
44
+ return __name;
45
+ }
46
+ });
47
+ Object.defineProperty(exports, "__toESM", {
48
+ enumerable: true,
49
+ get: function() {
50
+ return __toESM;
51
+ }
52
+ });
@@ -0,0 +1,16 @@
1
+ // \0rolldown/runtime.js
2
+ var __defProp = Object.defineProperty;
3
+ var __name = (target, value) => __defProp(target, "name", {
4
+ value,
5
+ configurable: true
6
+ });
7
+ var __exportAll = (all, flags) => {
8
+ let target = Object.setPrototypeOf({}, null);
9
+ for (var name in all) __defProp(target, name, {
10
+ get: all[name],
11
+ enumerable: true
12
+ });
13
+ if (!(flags & 1)) __defProp(target, Symbol.toStringTag, { value: "Module" });
14
+ return flags & 2 ? target : Object.preventExtensions(target);
15
+ };
16
+ export { __name as n, __exportAll as t };
@@ -0,0 +1,44 @@
1
+ import "./rolldown-runtime-BYyVTPww.js";
2
+ import { t as nodeKinds } from "./constants-Ckeonm-D.js";
3
+ // src/nodes/schema.ts
4
+ /**
5
+ * Maps schema `type` to its underlying `primitive`.
6
+ * Primitive types map to themselves and special string formats map to `'string'`.
7
+ * Any type not listed here (such as `ref`, `enum`, `union`, `intersection`, `not`, `tuple`, `ipv4`, `ipv6`, `blob`) has no `primitive`.
8
+ */
9
+ const TYPE_TO_PRIMITIVE = {
10
+ string: "string",
11
+ number: "number",
12
+ integer: "integer",
13
+ bigint: "bigint",
14
+ boolean: "boolean",
15
+ null: "null",
16
+ any: "any",
17
+ unknown: "unknown",
18
+ void: "void",
19
+ never: "never",
20
+ object: "object",
21
+ array: "array",
22
+ date: "date",
23
+ uuid: "string",
24
+ email: "string",
25
+ url: "string",
26
+ datetime: "string",
27
+ time: "string"
28
+ };
29
+ function createSchema(props) {
30
+ if (props.type === "object") return {
31
+ properties: [],
32
+ primitive: "object",
33
+ ...props,
34
+ kind: nodeKinds.schema
35
+ };
36
+ return {
37
+ primitive: TYPE_TO_PRIMITIVE[props.type],
38
+ ...props,
39
+ kind: nodeKinds.schema
40
+ };
41
+ }
42
+ export { createSchema as t };
43
+
44
+ //# sourceMappingURL=schema-2ZAQk7qE.js.map