@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.
- package/dist/base-IpYuh3ZP.d.cts +173 -0
- package/dist/base-IpYuh3ZP.d.ts +173 -0
- package/dist/constants-Ckeonm-D.js +141 -0
- package/dist/constants-Ckeonm-D.js.map +1 -0
- package/dist/constants-CquR083U.cjs +152 -0
- package/dist/constants-CquR083U.cjs.map +1 -0
- package/dist/factory.cjs +23 -0
- package/dist/factory.d.cts +4 -0
- package/dist/factory.d.ts +4 -0
- package/dist/factory.js +4 -0
- package/dist/file-BVqSiSvV.d.cts +624 -0
- package/dist/file-Cg0T6cgz.cjs +319 -0
- package/dist/file-Cg0T6cgz.cjs.map +1 -0
- package/dist/file-CnuL8oUj.js +283 -0
- package/dist/file-CnuL8oUj.js.map +1 -0
- package/dist/file-CvlMAp_d.js +131 -0
- package/dist/file-CvlMAp_d.js.map +1 -0
- package/dist/file-Dd50jPkH.cjs +142 -0
- package/dist/file-Dd50jPkH.cjs.map +1 -0
- package/dist/file-xJnBQPGq.d.ts +624 -0
- package/dist/file.cjs +3 -0
- package/dist/file.d.cts +2 -0
- package/dist/file.d.ts +2 -0
- package/dist/file.js +1 -0
- package/dist/graph-BcwFCvei.js +144 -0
- package/dist/graph-BcwFCvei.js.map +1 -0
- package/dist/graph-DcIY6tQb.cjs +173 -0
- package/dist/graph-DcIY6tQb.cjs.map +1 -0
- package/dist/graph.cjs +6 -0
- package/dist/graph.d.cts +2 -0
- package/dist/graph.d.ts +2 -0
- package/dist/graph.js +1 -0
- package/dist/guards-B8qDgSaT.d.cts +23 -0
- package/dist/guards-COVJE6TU.cjs +41 -0
- package/dist/guards-COVJE6TU.cjs.map +1 -0
- package/dist/guards-D-h9R_sV.d.ts +23 -0
- package/dist/guards-DlJkKsT1.js +30 -0
- package/dist/guards-DlJkKsT1.js.map +1 -0
- package/dist/http-Bm5lhVK4.cjs +12 -0
- package/dist/http-Bm5lhVK4.cjs.map +1 -0
- package/dist/http-DwboM6pK.js +7 -0
- package/dist/http-DwboM6pK.js.map +1 -0
- package/dist/http.cjs +4 -0
- package/dist/http.d.cts +3 -0
- package/dist/http.d.ts +3 -0
- package/dist/http.js +2 -0
- package/dist/index-BWd95onW.d.cts +5 -0
- package/dist/index-Bb1kqq8H.d.cts +20 -0
- package/dist/index-BngGJux5.d.cts +12 -0
- package/dist/index-BwnMIoLl.d.ts +24 -0
- package/dist/index-C-vhkzwR.d.cts +79 -0
- package/dist/index-CAGuKv6t.d.ts +74 -0
- package/dist/index-CFH4ZC7q.d.ts +44 -0
- package/dist/index-CIqwy4EE.d.cts +74 -0
- package/dist/index-Cc2K3OzU.d.cts +11 -0
- package/dist/index-Cc2K3OzU.d.ts +11 -0
- package/dist/index-Csf8xsCc.d.cts +46 -0
- package/dist/index-D3M2spDR.d.ts +12 -0
- package/dist/index-DNiIem0x.d.ts +79 -0
- package/dist/index-DSVef1pp.d.cts +24 -0
- package/dist/index-DU_jYpBt.d.cts +44 -0
- package/dist/index-DYDha-3I.d.cts +67 -0
- package/dist/index-DaHsMJ_S.d.ts +5 -0
- package/dist/index-Dp50LM3a.d.ts +67 -0
- package/dist/index-cpjUxIik.d.ts +46 -0
- package/dist/index-eGkM4FE9.d.ts +20 -0
- package/dist/index.cjs +87 -2131
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +25 -2745
- package/dist/index.d.ts +25 -2745
- package/dist/index.js +40 -2052
- package/dist/index.js.map +1 -1
- package/dist/json-DH7_lcWm.js +74 -0
- package/dist/json-DH7_lcWm.js.map +1 -0
- package/dist/json-DURdtz9A.cjs +91 -0
- package/dist/json-DURdtz9A.cjs.map +1 -0
- package/dist/json.cjs +4 -0
- package/dist/json.d.cts +2 -0
- package/dist/json.d.ts +2 -0
- package/dist/json.js +1 -0
- package/dist/macro-D0KfNtff.js +104 -0
- package/dist/macro-D0KfNtff.js.map +1 -0
- package/dist/macro-DrTBT7fh.cjs +127 -0
- package/dist/macro-DrTBT7fh.cjs.map +1 -0
- package/dist/macro.cjs +4 -0
- package/dist/macro.d.cts +2 -0
- package/dist/macro.d.ts +2 -0
- package/dist/macro.js +1 -0
- package/dist/mediaType-CRjggmoG.js +19 -0
- package/dist/mediaType-CRjggmoG.js.map +1 -0
- package/dist/mediaType-D8uIO8sG.cjs +35 -0
- package/dist/mediaType-D8uIO8sG.cjs.map +1 -0
- package/dist/mediaType.cjs +4 -0
- package/dist/mediaType.d.cts +2 -0
- package/dist/mediaType.d.ts +2 -0
- package/dist/mediaType.js +1 -0
- package/dist/node-DjcETnc8.cjs +19 -0
- package/dist/node-DjcETnc8.cjs.map +1 -0
- package/dist/node-Djh-mZB2.js +14 -0
- package/dist/node-Djh-mZB2.js.map +1 -0
- package/dist/node.cjs +9 -0
- package/dist/node.d.cts +4 -0
- package/dist/node.d.ts +4 -0
- package/dist/node.js +5 -0
- package/dist/nodeText-DRb_rVd1.cjs +58 -0
- package/dist/nodeText-DRb_rVd1.cjs.map +1 -0
- package/dist/nodeText-DVVDZQjF.js +47 -0
- package/dist/nodeText-DVVDZQjF.js.map +1 -0
- package/dist/nodes-BB60Bq2H.cjs +320 -0
- package/dist/nodes-BB60Bq2H.cjs.map +1 -0
- package/dist/nodes-CWMa9xhW.js +231 -0
- package/dist/nodes-CWMa9xhW.js.map +1 -0
- package/dist/operation-BgRyVS7z.d.ts +1272 -0
- package/dist/operation-X7chCdL2.d.cts +1272 -0
- package/dist/optionality-D-zqzVMH.cjs +22 -0
- package/dist/optionality-D-zqzVMH.cjs.map +1 -0
- package/dist/optionality-DISn8ytP.js +17 -0
- package/dist/optionality-DISn8ytP.js.map +1 -0
- package/dist/promise-BOdlgT0N.cjs +50 -0
- package/dist/promise-BOdlgT0N.cjs.map +1 -0
- package/dist/promise-RpnEev9D.js +45 -0
- package/dist/promise-RpnEev9D.js.map +1 -0
- package/dist/ref-Bu7PoHar.js +22 -0
- package/dist/ref-Bu7PoHar.js.map +1 -0
- package/dist/ref-P0ZLT1Bg.cjs +39 -0
- package/dist/ref-P0ZLT1Bg.cjs.map +1 -0
- package/dist/ref.cjs +7 -0
- package/dist/ref.d.cts +2 -0
- package/dist/ref.d.ts +2 -0
- package/dist/ref.js +3 -0
- package/dist/refs-CYHpRlQo.cjs +131 -0
- package/dist/refs-CYHpRlQo.cjs.map +1 -0
- package/dist/refs-YCV3CznS.js +102 -0
- package/dist/refs-YCV3CznS.js.map +1 -0
- package/dist/rolldown-runtime-BV8xUvPy.cjs +52 -0
- package/dist/rolldown-runtime-BYyVTPww.js +16 -0
- package/dist/schema-2ZAQk7qE.js +44 -0
- package/dist/schema-2ZAQk7qE.js.map +1 -0
- package/dist/schema-BIErWqgc.cjs +214 -0
- package/dist/schema-BIErWqgc.cjs.map +1 -0
- package/dist/schema-DloctnMm.js +179 -0
- package/dist/schema-DloctnMm.js.map +1 -0
- package/dist/schema-hxMlgCrV.cjs +49 -0
- package/dist/schema-hxMlgCrV.cjs.map +1 -0
- package/dist/schema.cjs +16 -0
- package/dist/schema.d.cts +5 -0
- package/dist/schema.d.ts +5 -0
- package/dist/schema.js +6 -0
- package/dist/visitor-BZozlXBF.d.ts +179 -0
- package/dist/visitor-Bw_opzjF.d.cts +179 -0
- package/dist/visitor-DTrzvA3R.cjs +382 -0
- package/dist/visitor-DTrzvA3R.cjs.map +1 -0
- package/dist/visitor-NoQSUQTu.js +347 -0
- package/dist/visitor-NoQSUQTu.js.map +1 -0
- package/package.json +101 -1
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
require("./rolldown-runtime-BV8xUvPy.cjs");
|
|
2
|
+
const require_constants = require("./constants-CquR083U.cjs");
|
|
3
|
+
const require_mediaType = require("./mediaType-D8uIO8sG.cjs");
|
|
4
|
+
// src/schema/embeddedJson.ts
|
|
5
|
+
/** The schema of the JSON document a string holds (`contentMediaType` with `contentSchema`), else `undefined`. */
|
|
6
|
+
function getEmbeddedJson({ content }) {
|
|
7
|
+
if (!content?.schema || content.encoding || !content.mediaType) return void 0;
|
|
8
|
+
return require_mediaType.isJson(content.mediaType) ? content.schema : void 0;
|
|
9
|
+
}
|
|
10
|
+
// src/visitor.ts
|
|
11
|
+
/**
|
|
12
|
+
* Child node fields per node kind, in traversal order (Babel's `VISITOR_KEYS`).
|
|
13
|
+
*/
|
|
14
|
+
const VISITOR_KEYS = {
|
|
15
|
+
Input: ["schemas", "operations"],
|
|
16
|
+
Operation: [
|
|
17
|
+
"parameters",
|
|
18
|
+
"requestBody",
|
|
19
|
+
"responses"
|
|
20
|
+
],
|
|
21
|
+
RequestBody: ["content"],
|
|
22
|
+
Content: ["schema", "stream"],
|
|
23
|
+
Response: ["content", "headers"],
|
|
24
|
+
Schema: [
|
|
25
|
+
"properties",
|
|
26
|
+
"items",
|
|
27
|
+
"members",
|
|
28
|
+
"additionalProperties",
|
|
29
|
+
"patternProperties",
|
|
30
|
+
"propertyNames",
|
|
31
|
+
"rest"
|
|
32
|
+
],
|
|
33
|
+
Property: ["schema"],
|
|
34
|
+
Parameter: ["schema"]
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Schema fields that hold checks rather than shape: the `conditionals` entries, `contains` and a string's `content`.
|
|
38
|
+
* `transform` and `collect` skip them, and `visitChildNodes` walks them with `checks: true`.
|
|
39
|
+
*/
|
|
40
|
+
const schemaCheckKeys = [
|
|
41
|
+
"conditionals",
|
|
42
|
+
"contains",
|
|
43
|
+
"content"
|
|
44
|
+
];
|
|
45
|
+
/** Visitor callback names in traversal order, the keys of {@link Visitor}. */
|
|
46
|
+
const visitorKeys = [
|
|
47
|
+
"input",
|
|
48
|
+
"operation",
|
|
49
|
+
"schema",
|
|
50
|
+
"property",
|
|
51
|
+
"parameter",
|
|
52
|
+
"response"
|
|
53
|
+
];
|
|
54
|
+
/**
|
|
55
|
+
* Maps a node kind to the matching visitor callback name.
|
|
56
|
+
*/
|
|
57
|
+
const VISITOR_KEY_BY_KIND = {
|
|
58
|
+
Input: "input",
|
|
59
|
+
Operation: "operation",
|
|
60
|
+
Schema: "schema",
|
|
61
|
+
Property: "property",
|
|
62
|
+
Parameter: "parameter",
|
|
63
|
+
Response: "response"
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Returns `true` when `value` is an AST node (an object carrying a `kind`).
|
|
67
|
+
*/
|
|
68
|
+
function isNode(value) {
|
|
69
|
+
return typeof value === "object" && value !== null && typeof value.kind === "string";
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Returns `true` for a plain object that maps names to nodes, such as `patternProperties`.
|
|
73
|
+
*/
|
|
74
|
+
function isNodeRecord(value) {
|
|
75
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
76
|
+
}
|
|
77
|
+
function isNeverPrinted({ node, key }) {
|
|
78
|
+
if (node.kind !== require_constants.nodeKinds.schema) return false;
|
|
79
|
+
if (key === "contains" && (node.type === "array" || node.type === "tuple")) return node.contains?.min === 0 && node.contains.max === void 0;
|
|
80
|
+
if (key === "content" && node.type === "string") return !getEmbeddedJson(node);
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Child keys of a schema walked with `checks: true`: the shape keys, then {@link schemaCheckKeys}.
|
|
85
|
+
*/
|
|
86
|
+
const SCHEMA_CHECK_VISITOR_KEYS = [...VISITOR_KEYS.Schema, ...schemaCheckKeys];
|
|
87
|
+
function visitOnce(child, seen, visit) {
|
|
88
|
+
if (seen.first === void 0) {
|
|
89
|
+
seen.first = child;
|
|
90
|
+
return visit(child);
|
|
91
|
+
}
|
|
92
|
+
if (seen.first === child || seen.rest?.has(child)) return false;
|
|
93
|
+
(seen.rest ??= /* @__PURE__ */ new Set()).add(child);
|
|
94
|
+
return visit(child);
|
|
95
|
+
}
|
|
96
|
+
function visitRecord(value, seen, visit) {
|
|
97
|
+
for (const name in value) {
|
|
98
|
+
if (!Object.hasOwn(value, name)) continue;
|
|
99
|
+
const item = value[name];
|
|
100
|
+
if (isNode(item) && visitOnce(item, seen, visit)) return true;
|
|
101
|
+
}
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Calls `visit` for each direct child node and stops at the first call that returns `true`.
|
|
106
|
+
* With `checks: true`, a schema's {@link schemaCheckKeys} fields are walked too, except checks that cannot fail.
|
|
107
|
+
*/
|
|
108
|
+
function visitChildNodes(node, visit, { checks = false } = {}) {
|
|
109
|
+
const withChecks = checks && node.kind === require_constants.nodeKinds.schema;
|
|
110
|
+
const keys = withChecks ? SCHEMA_CHECK_VISITOR_KEYS : VISITOR_KEYS[node.kind];
|
|
111
|
+
if (!keys) return false;
|
|
112
|
+
const record = node;
|
|
113
|
+
let seen;
|
|
114
|
+
for (const key of keys) {
|
|
115
|
+
const value = record[key];
|
|
116
|
+
if (value === void 0 || value === null) continue;
|
|
117
|
+
if (withChecks && isNeverPrinted({
|
|
118
|
+
node,
|
|
119
|
+
key
|
|
120
|
+
})) continue;
|
|
121
|
+
seen ??= {
|
|
122
|
+
first: void 0,
|
|
123
|
+
rest: void 0
|
|
124
|
+
};
|
|
125
|
+
if (Array.isArray(value)) {
|
|
126
|
+
for (const item of value) if (isNode(item) ? visitOnce(item, seen, visit) : isNodeRecord(item) && visitRecord(item, seen, visit)) return true;
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
if (isNode(value)) {
|
|
130
|
+
if (visitOnce(value, seen, visit)) return true;
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
if (isNodeRecord(value) && visitRecord(value, seen, visit)) return true;
|
|
134
|
+
}
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
const notFound = {
|
|
138
|
+
found: void 0,
|
|
139
|
+
low: Number.POSITIVE_INFINITY
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* Finds the first schema that matches `predicate` in depth-first order. Pass `follow: ['ref']` to include resolved ref targets.
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* ```ts
|
|
146
|
+
* const firstString = findSchema(operationNode, {
|
|
147
|
+
* predicate: (schema) => schema.type === 'string',
|
|
148
|
+
* })
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
function findSchema(node, { predicate, follow, followRefs = false, cache }) {
|
|
152
|
+
const state = followRefs || (follow?.includes("ref") ?? false) ? /* @__PURE__ */ new Map() : void 0;
|
|
153
|
+
const pending = [];
|
|
154
|
+
let order = 0;
|
|
155
|
+
const walkChildren = (current, initial) => {
|
|
156
|
+
let result = initial;
|
|
157
|
+
visitChildNodes(current, (child) => {
|
|
158
|
+
const next = walk(child);
|
|
159
|
+
result = next.found || next.low < result.low ? next : result;
|
|
160
|
+
return next.found !== void 0;
|
|
161
|
+
});
|
|
162
|
+
return result;
|
|
163
|
+
};
|
|
164
|
+
const walkSchema = (current) => {
|
|
165
|
+
const target = state && current.type === "ref" && current.schema ? walk(current.schema) : notFound;
|
|
166
|
+
if (target.found) return target;
|
|
167
|
+
return walkChildren(current, target);
|
|
168
|
+
};
|
|
169
|
+
const walk = (current) => {
|
|
170
|
+
if (current.kind !== require_constants.nodeKinds.schema) return walkChildren(current, notFound);
|
|
171
|
+
const cached = cache?.get(current);
|
|
172
|
+
if (cached === null) return notFound;
|
|
173
|
+
if (cached) return {
|
|
174
|
+
found: cached,
|
|
175
|
+
low: Number.POSITIVE_INFINITY
|
|
176
|
+
};
|
|
177
|
+
if (predicate(current)) {
|
|
178
|
+
cache?.set(current, current);
|
|
179
|
+
return {
|
|
180
|
+
found: current,
|
|
181
|
+
low: Number.POSITIVE_INFINITY
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
const known = state?.get(current);
|
|
185
|
+
if (known !== void 0) return {
|
|
186
|
+
found: void 0,
|
|
187
|
+
low: known
|
|
188
|
+
};
|
|
189
|
+
const index = order++;
|
|
190
|
+
const start = pending.length;
|
|
191
|
+
state?.set(current, index);
|
|
192
|
+
const result = walkSchema(current);
|
|
193
|
+
if (result.found) {
|
|
194
|
+
cache?.set(current, result.found);
|
|
195
|
+
return result;
|
|
196
|
+
}
|
|
197
|
+
if (!state) {
|
|
198
|
+
cache?.set(current, null);
|
|
199
|
+
return notFound;
|
|
200
|
+
}
|
|
201
|
+
if (result.low < index) {
|
|
202
|
+
state.set(current, result.low);
|
|
203
|
+
pending.push(current);
|
|
204
|
+
return result;
|
|
205
|
+
}
|
|
206
|
+
for (const done of [...pending.splice(start), current]) {
|
|
207
|
+
state.set(done, Number.POSITIVE_INFINITY);
|
|
208
|
+
cache?.set(done, null);
|
|
209
|
+
}
|
|
210
|
+
return notFound;
|
|
211
|
+
};
|
|
212
|
+
return walk(node).found;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Runs the visitor callback that matches `node.kind` with the traversal
|
|
216
|
+
* context. The result is a replacement node, a collected value, or `undefined`
|
|
217
|
+
* when no callback is registered for the kind.
|
|
218
|
+
*
|
|
219
|
+
* Shared by `transform` and `collect` so node-kind dispatch lives in one place.
|
|
220
|
+
* `TResult` is the caller's expected return: the same node type for `transform`,
|
|
221
|
+
* the collected value type for `collect`.
|
|
222
|
+
*/
|
|
223
|
+
function applyVisitor(node, visitor, parent) {
|
|
224
|
+
const key = VISITOR_KEY_BY_KIND[node.kind];
|
|
225
|
+
if (!key) return void 0;
|
|
226
|
+
const fn = visitor[key];
|
|
227
|
+
return fn?.(node, { parent });
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Synchronous depth-first transform. Each visitor callback can return a
|
|
231
|
+
* replacement node. Returning `undefined` keeps the original.
|
|
232
|
+
*
|
|
233
|
+
* The original tree is never mutated, a new tree is returned. Pass
|
|
234
|
+
* `depth: 'shallow'` to skip the children of every schema node; other nodes are still walked.
|
|
235
|
+
*
|
|
236
|
+
* @example Prefix every operationId
|
|
237
|
+
* ```ts
|
|
238
|
+
* const next = transform(root, {
|
|
239
|
+
* operation(node) {
|
|
240
|
+
* return { ...node, operationId: `prefixed_${node.operationId}` }
|
|
241
|
+
* },
|
|
242
|
+
* })
|
|
243
|
+
* ```
|
|
244
|
+
*
|
|
245
|
+
* @example Rewrite the root node without walking its schemas
|
|
246
|
+
* ```ts
|
|
247
|
+
* const next = transform(root, {
|
|
248
|
+
* depth: 'shallow',
|
|
249
|
+
* input: (node) => ({ ...node, meta: { ...node.meta, title: 'Rewritten' } }),
|
|
250
|
+
* })
|
|
251
|
+
* ```
|
|
252
|
+
*/
|
|
253
|
+
function transform(node, options) {
|
|
254
|
+
const { depth, parent, ...visitor } = options;
|
|
255
|
+
return transformNode(node, visitor, (depth ?? "deep") === "deep", parent);
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Visits a single node, then immutably rebuilds its children. Returns the original
|
|
259
|
+
* reference when neither the visitor nor the child rebuild changed anything, so callers
|
|
260
|
+
* can detect "nothing changed" by identity and ancestors avoid reallocating.
|
|
261
|
+
*/
|
|
262
|
+
function transformNode(node, visitor, recurse, parent) {
|
|
263
|
+
return transformChildren(applyVisitor(node, visitor, parent) ?? node, visitor, recurse);
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Immutably rebuilds a node's children, transforming each child node and leaving non-node values
|
|
267
|
+
* (e.g. `additionalProperties: true`) intact.
|
|
268
|
+
*/
|
|
269
|
+
function transformChildren(node, visitor, recurse) {
|
|
270
|
+
const keys = node.kind === require_constants.nodeKinds.schema && !recurse ? void 0 : VISITOR_KEYS[node.kind];
|
|
271
|
+
if (!keys) return node;
|
|
272
|
+
const record = node;
|
|
273
|
+
let updates;
|
|
274
|
+
let done;
|
|
275
|
+
const transformOnce = (child) => {
|
|
276
|
+
done ??= /* @__PURE__ */ new Map();
|
|
277
|
+
const next = done.get(child) ?? transformNode(child, visitor, recurse, node);
|
|
278
|
+
done.set(child, next);
|
|
279
|
+
return next;
|
|
280
|
+
};
|
|
281
|
+
for (const key of keys) {
|
|
282
|
+
const value = record[key];
|
|
283
|
+
if (value === void 0 || value === null) continue;
|
|
284
|
+
if (Array.isArray(value)) {
|
|
285
|
+
let mapped;
|
|
286
|
+
for (const [i, item] of value.entries()) {
|
|
287
|
+
const next = isNode(item) ? transformOnce(item) : item;
|
|
288
|
+
if (mapped) {
|
|
289
|
+
mapped.push(next);
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
292
|
+
if (next !== item) mapped = [...value.slice(0, i), next];
|
|
293
|
+
}
|
|
294
|
+
if (mapped) (updates ??= {})[key] = mapped;
|
|
295
|
+
continue;
|
|
296
|
+
}
|
|
297
|
+
if (isNode(value)) {
|
|
298
|
+
const next = transformOnce(value);
|
|
299
|
+
if (next !== value) (updates ??= {})[key] = next;
|
|
300
|
+
continue;
|
|
301
|
+
}
|
|
302
|
+
if (isNodeRecord(value)) {
|
|
303
|
+
let mapped;
|
|
304
|
+
for (const [name, item] of Object.entries(value)) {
|
|
305
|
+
const next = isNode(item) ? transformOnce(item) : item;
|
|
306
|
+
if (next !== item) (mapped ??= { ...value })[name] = next;
|
|
307
|
+
}
|
|
308
|
+
if (mapped) (updates ??= {})[key] = mapped;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
if (!updates) return node;
|
|
312
|
+
return {
|
|
313
|
+
...node,
|
|
314
|
+
...updates
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Depth-first collection pass. Gathers every non-null value the visitor
|
|
319
|
+
* callbacks return into an array.
|
|
320
|
+
*
|
|
321
|
+
* @example Collect every operationId
|
|
322
|
+
* ```ts
|
|
323
|
+
* const ids = collect<string>(root, {
|
|
324
|
+
* operation(node) {
|
|
325
|
+
* return node.operationId
|
|
326
|
+
* },
|
|
327
|
+
* })
|
|
328
|
+
* ```
|
|
329
|
+
*/
|
|
330
|
+
function collect(node, options) {
|
|
331
|
+
const { depth, parent, ...visitor } = options;
|
|
332
|
+
const result = [];
|
|
333
|
+
collectInto(node, visitor, (depth ?? "deep") === "deep", parent, result);
|
|
334
|
+
return result;
|
|
335
|
+
}
|
|
336
|
+
function collectInto(node, visitor, recurse, parent, result) {
|
|
337
|
+
const v = applyVisitor(node, visitor, parent);
|
|
338
|
+
if (v != null) result.push(v);
|
|
339
|
+
if (node.kind === require_constants.nodeKinds.schema && !recurse) return;
|
|
340
|
+
visitChildNodes(node, (child) => {
|
|
341
|
+
collectInto(child, visitor, recurse, node, result);
|
|
342
|
+
return false;
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
Object.defineProperty(exports, "collect", {
|
|
346
|
+
enumerable: true,
|
|
347
|
+
get: function() {
|
|
348
|
+
return collect;
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
Object.defineProperty(exports, "findSchema", {
|
|
352
|
+
enumerable: true,
|
|
353
|
+
get: function() {
|
|
354
|
+
return findSchema;
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
Object.defineProperty(exports, "getEmbeddedJson", {
|
|
358
|
+
enumerable: true,
|
|
359
|
+
get: function() {
|
|
360
|
+
return getEmbeddedJson;
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
Object.defineProperty(exports, "transform", {
|
|
364
|
+
enumerable: true,
|
|
365
|
+
get: function() {
|
|
366
|
+
return transform;
|
|
367
|
+
}
|
|
368
|
+
});
|
|
369
|
+
Object.defineProperty(exports, "visitChildNodes", {
|
|
370
|
+
enumerable: true,
|
|
371
|
+
get: function() {
|
|
372
|
+
return visitChildNodes;
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
Object.defineProperty(exports, "visitorKeys", {
|
|
376
|
+
enumerable: true,
|
|
377
|
+
get: function() {
|
|
378
|
+
return visitorKeys;
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
//# sourceMappingURL=visitor-DTrzvA3R.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visitor-DTrzvA3R.cjs","names":["isJson","nodeKinds"],"sources":["../src/schema/embeddedJson.ts","../src/visitor.ts"],"sourcesContent":["import { isJson } from '../mediaType/index.ts'\nimport type { SchemaNode, StringSchemaNode } from '../nodes/schema.ts'\n\n/** The schema of the JSON document a string holds (`contentMediaType` with `contentSchema`), else `undefined`. */\nexport function getEmbeddedJson({ content }: Pick<StringSchemaNode, 'content'>): SchemaNode | undefined {\n // shortcut: an encoded document (`contentEncoding`) is not decoded, so only its encoding is checked; decode it once a spec needs both.\n if (!content?.schema || content.encoding || !content.mediaType) return undefined\n return isJson(content.mediaType) ? content.schema : undefined\n}\n","import { nodeKinds } from './constants.ts'\nimport type { Node } from './nodes/index.ts'\nimport type { InputNode } from './nodes/input.ts'\nimport type { NodeKind } from './nodes/base.ts'\nimport type { OperationNode } from './nodes/operation.ts'\nimport type { ParameterNode } from './nodes/parameter.ts'\nimport type { PropertyNode } from './nodes/property.ts'\nimport type { ResponseNode } from './nodes/response.ts'\nimport type { SchemaNode } from './nodes/schema.ts'\nimport { getEmbeddedJson } from './schema/embeddedJson.ts'\n\n/**\n * Traversal depth for AST visitor utilities.\n *\n * - `'shallow'` recurses through every node except nested `Schema` subtrees, which it treats as\n * leaves: a schema node itself is visited, but its children are not.\n * - `'deep'` recursively visits all descendant nodes, including schema subtrees.\n */\nexport type VisitorDepth = 'shallow' | 'deep'\n\n/**\n * Child node fields per node kind, in traversal order (Babel's `VISITOR_KEYS`).\n */\nconst VISITOR_KEYS: Partial<Record<NodeKind, ReadonlyArray<string>>> = {\n Input: ['schemas', 'operations'],\n Operation: ['parameters', 'requestBody', 'responses'],\n RequestBody: ['content'],\n Content: ['schema', 'stream'],\n Response: ['content', 'headers'],\n Schema: ['properties', 'items', 'members', 'additionalProperties', 'patternProperties', 'propertyNames', 'rest'],\n Property: ['schema'],\n Parameter: ['schema'],\n}\n\n/**\n * Schema fields that hold checks rather than shape: the `conditionals` entries, `contains` and a string's `content`.\n * `transform` and `collect` skip them, and `visitChildNodes` walks them with `checks: true`.\n */\nexport const schemaCheckKeys = ['conditionals', 'contains', 'content'] as const\n\n/** Visitor callback names in traversal order, the keys of {@link Visitor}. */\nexport const visitorKeys = ['input', 'operation', 'schema', 'property', 'parameter', 'response'] as const\n\nexport type VisitorKey = (typeof visitorKeys)[number]\n\n/**\n * Maps a node kind to the matching visitor callback name.\n */\nconst VISITOR_KEY_BY_KIND: Partial<Record<NodeKind, VisitorKey>> = {\n Input: 'input',\n Operation: 'operation',\n Schema: 'schema',\n Property: 'property',\n Parameter: 'parameter',\n Response: 'response',\n}\n\n/**\n * Traversal context passed as the second argument to every visitor callback.\n *\n * @example\n * ```ts\n * const visitor: Visitor = {\n * schema(node, { parent }) {\n * // parent is the node that holds this schema, or undefined at the root\n * },\n * }\n * ```\n */\nexport type VisitorContext = {\n /**\n * Parent node of the currently visited node. For the root node, this is `undefined`.\n */\n parent?: Node\n}\n\n/**\n * Synchronous visitor consumed by `transform`. Each optional callback runs\n * for the matching node type. Return a new node to replace it, or `undefined`\n * to leave it untouched.\n *\n * Plugins typically expose `transformer` so users can supply a `Visitor` that\n * rewrites the AST before printing.\n *\n * @example Prefix every operationId\n * ```ts\n * const visitor: Visitor = {\n * operation(node) {\n * return { ...node, operationId: `api_${node.operationId}` }\n * },\n * }\n * ```\n *\n * @example Strip schema descriptions\n * ```ts\n * const visitor: Visitor = {\n * schema(node) {\n * return { ...node, description: undefined }\n * },\n * }\n * ```\n */\nexport type Visitor = {\n input?(node: InputNode, context: VisitorContext): undefined | null | InputNode\n operation?(node: OperationNode, context: VisitorContext): undefined | null | OperationNode\n schema?(node: SchemaNode, context: VisitorContext): undefined | null | SchemaNode\n property?(node: PropertyNode, context: VisitorContext): undefined | null | PropertyNode\n parameter?(node: ParameterNode, context: VisitorContext): undefined | null | ParameterNode\n response?(node: ResponseNode, context: VisitorContext): undefined | null | ResponseNode\n}\n\n/**\n * The callbacks of {@link Visitor} with every return type replaced by `TResult`. `collect` uses it\n * so a visitor can yield values instead of replacement nodes.\n *\n * @example\n * ```ts\n * const visitor: VisitorOf<string> = {\n * operation(node) {\n * return node.operationId\n * },\n * }\n * ```\n */\ntype VisitorOf<TResult> = {\n [K in keyof Visitor]?: (node: Parameters<NonNullable<Visitor[K]>>[0], context: Parameters<NonNullable<Visitor[K]>>[1]) => TResult | null | undefined\n}\n\ntype TraversalOptions = {\n /**\n * Traversal depth.\n * @default 'deep'\n */\n depth?: VisitorDepth\n /**\n * Internal parent override used during recursion.\n */\n parent?: Node\n}\n\n/**\n * Options for `transform`.\n *\n * @example\n * ```ts\n * const options: TransformOptions = { depth: 'deep', schema: (node) => node }\n * ```\n *\n * @example\n * ```ts\n * // Only transform the current node, not nested children\n * const options: TransformOptions = { depth: 'shallow', schema: (node) => node }\n * ```\n */\ntype TransformOptions = Visitor & TraversalOptions\n\n/**\n * Options for `collect`.\n *\n * @example\n * ```ts\n * const options: CollectOptions<string> = { depth: 'shallow', schema: () => undefined }\n * ```\n */\ntype CollectOptions<T> = VisitorOf<T> & TraversalOptions\n\n/**\n * Returns `true` when `value` is an AST node (an object carrying a `kind`).\n */\nfunction isNode(value: unknown): value is Node {\n return typeof value === 'object' && value !== null && typeof (value as { kind?: unknown }).kind === 'string'\n}\n\n/**\n * Returns `true` for a plain object that maps names to nodes, such as `patternProperties`.\n */\nfunction isNodeRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\n// A check no printer emits: a `contains` that any array meets (`min: 0`, no `max`), or `content` that is not JSON.\nfunction isNeverPrinted({ node, key }: { node: Node; key: string }): boolean {\n if (node.kind !== nodeKinds.schema) return false\n if (key === 'contains' && (node.type === 'array' || node.type === 'tuple')) return node.contains?.min === 0 && node.contains.max === undefined\n if (key === 'content' && node.type === 'string') return !getEmbeddedJson(node)\n return false\n}\n\n/**\n * Child keys of a schema walked with `checks: true`: the shape keys, then {@link schemaCheckKeys}.\n */\nconst SCHEMA_CHECK_VISITOR_KEYS: ReadonlyArray<string> = [...VISITOR_KEYS.Schema!, ...schemaCheckKeys]\n\n/**\n * Children a node already passed to `visit`. A node under two keys, such as a stream item under `schema` and\n * `stream`, is visited once. The `Set` is only created once a node has a second child.\n */\ntype SeenChildren = { first: Node | undefined; rest: Set<Node> | undefined }\n\nfunction visitOnce(child: Node, seen: SeenChildren, visit: (child: Node) => boolean): boolean {\n if (seen.first === undefined) {\n seen.first = child\n return visit(child)\n }\n if (seen.first === child || seen.rest?.has(child)) return false\n ;(seen.rest ??= new Set()).add(child)\n return visit(child)\n}\n\nfunction visitRecord(value: Record<string, unknown>, seen: SeenChildren, visit: (child: Node) => boolean): boolean {\n for (const name in value) {\n if (!Object.hasOwn(value, name)) continue\n const item = value[name]\n if (isNode(item) && visitOnce(item, seen, visit)) return true\n }\n return false\n}\n\n/**\n * Calls `visit` for each direct child node and stops at the first call that returns `true`.\n * With `checks: true`, a schema's {@link schemaCheckKeys} fields are walked too, except checks that cannot fail.\n */\nexport function visitChildNodes(node: Node, visit: (child: Node) => boolean, { checks = false }: { checks?: boolean } = {}): boolean {\n const withChecks = checks && node.kind === nodeKinds.schema\n const keys = withChecks ? SCHEMA_CHECK_VISITOR_KEYS : VISITOR_KEYS[node.kind]\n if (!keys) return false\n\n const record = node as unknown as Record<string, unknown>\n let seen: SeenChildren | undefined\n for (const key of keys) {\n const value = record[key]\n if (value === undefined || value === null) continue\n if (withChecks && isNeverPrinted({ node, key })) continue\n seen ??= { first: undefined, rest: undefined }\n if (Array.isArray(value)) {\n // Items can be plain objects that hold nodes, such as the `{ if, then, else }` entries of `conditionals`.\n for (const item of value) if (isNode(item) ? visitOnce(item, seen, visit) : isNodeRecord(item) && visitRecord(item, seen, visit)) return true\n continue\n }\n if (isNode(value)) {\n if (visitOnce(value, seen, visit)) return true\n continue\n }\n if (isNodeRecord(value) && visitRecord(value, seen, visit)) return true\n }\n return false\n}\n\ntype FindResult = { found: SchemaNode | undefined; low: number }\n\nconst notFound: FindResult = { found: undefined, low: Number.POSITIVE_INFINITY }\n\n/**\n * Finds the first schema that matches `predicate` in depth-first order. Pass `follow: ['ref']` to include resolved ref targets.\n *\n * @example\n * ```ts\n * const firstString = findSchema(operationNode, {\n * predicate: (schema) => schema.type === 'string',\n * })\n * ```\n */\nexport function findSchema(\n node: Node,\n {\n predicate,\n follow,\n followRefs = false,\n cache,\n }: {\n predicate: (schema: SchemaNode) => boolean\n /**\n * Links to follow on top of the walk over every child. `['ref']` also walks a resolved ref's target.\n * @default []\n */\n follow?: ReadonlyArray<'ref'>\n /**\n * @deprecated Use `follow: ['ref']`. Removed in Kubb v6.\n */\n followRefs?: boolean\n /**\n * Remembers the match below each schema (`null` for none), so later calls skip the parts of the graph they share.\n * Keep one cache per `predicate` and ref-following mode (`follow`, or the deprecated `followRefs`), for example one per build.\n * In a cyclic graph, a cached call can return a different match than the first one in depth-first order.\n */\n cache?: WeakMap<SchemaNode, SchemaNode | null>\n },\n): SchemaNode | undefined {\n const followsRefs = followRefs || (follow?.includes('ref') ?? false)\n // When following refs, as in Tarjan's algorithm: the visit order of a schema still being walked, or for a finished\n // schema without a match the lowest visit order of an unfinished schema its subtree reached. Only a schema whose\n // subtree reached nothing visited before it has a final no-match; until then it waits in `pending`.\n const state = followsRefs ? new Map<SchemaNode, number>() : undefined\n const pending: Array<SchemaNode> = []\n let order = 0\n\n const walkChildren = (current: Node, initial: FindResult): FindResult => {\n let result = initial\n visitChildNodes(current, (child) => {\n const next = walk(child)\n result = next.found || next.low < result.low ? next : result\n return next.found !== undefined\n })\n return result\n }\n\n const walkSchema = (current: SchemaNode): FindResult => {\n const target = state && current.type === 'ref' && current.schema ? walk(current.schema) : notFound\n if (target.found) return target\n return walkChildren(current, target)\n }\n\n const walk = (current: Node): FindResult => {\n if (current.kind !== nodeKinds.schema) return walkChildren(current, notFound)\n\n const cached = cache?.get(current)\n if (cached === null) return notFound\n if (cached) return { found: cached, low: Number.POSITIVE_INFINITY }\n if (predicate(current)) {\n cache?.set(current, current)\n return { found: current, low: Number.POSITIVE_INFINITY }\n }\n const known = state?.get(current)\n if (known !== undefined) return { found: undefined, low: known }\n\n const index = order++\n const start = pending.length\n state?.set(current, index)\n const result = walkSchema(current)\n if (result.found) {\n cache?.set(current, result.found)\n return result\n }\n if (!state) {\n cache?.set(current, null)\n return notFound\n }\n if (result.low < index) {\n state.set(current, result.low)\n pending.push(current)\n return result\n }\n for (const done of [...pending.splice(start), current]) {\n state.set(done, Number.POSITIVE_INFINITY)\n cache?.set(done, null)\n }\n return notFound\n }\n\n return walk(node).found\n}\n\n/**\n * Runs the visitor callback that matches `node.kind` with the traversal\n * context. The result is a replacement node, a collected value, or `undefined`\n * when no callback is registered for the kind.\n *\n * Shared by `transform` and `collect` so node-kind dispatch lives in one place.\n * `TResult` is the caller's expected return: the same node type for `transform`,\n * the collected value type for `collect`.\n */\nfunction applyVisitor<TResult>(node: Node, visitor: Visitor | VisitorOf<unknown>, parent: Node | undefined): TResult | null | undefined {\n const key = VISITOR_KEY_BY_KIND[node.kind]\n if (!key) return undefined\n\n const fn = visitor[key] as ((node: Node, context: VisitorContext) => TResult | null | undefined) | undefined\n\n return fn?.(node, { parent })\n}\n\n/**\n * Synchronous depth-first transform. Each visitor callback can return a\n * replacement node. Returning `undefined` keeps the original.\n *\n * The original tree is never mutated, a new tree is returned. Pass\n * `depth: 'shallow'` to skip the children of every schema node; other nodes are still walked.\n *\n * @example Prefix every operationId\n * ```ts\n * const next = transform(root, {\n * operation(node) {\n * return { ...node, operationId: `prefixed_${node.operationId}` }\n * },\n * })\n * ```\n *\n * @example Rewrite the root node without walking its schemas\n * ```ts\n * const next = transform(root, {\n * depth: 'shallow',\n * input: (node) => ({ ...node, meta: { ...node.meta, title: 'Rewritten' } }),\n * })\n * ```\n */\nexport function transform<T extends Node>(node: T, options: TransformOptions): T {\n const { depth, parent, ...visitor } = options\n const recurse = (depth ?? 'deep') === 'deep'\n\n // Split the visitor object out once here, then thread it plus `recurse`/`parent` as plain\n // arguments through the recursion. The previous code re-ran the `...visitor` rest-destructure on\n // every recursive `transform` call and rebuilt a `{ ...options, parent }` object per node, so the\n // options shape (which callbacks are present) varied call to call and the hot recursion churned.\n return transformNode(node, visitor, recurse, parent) as T\n}\n\n/**\n * Visits a single node, then immutably rebuilds its children. Returns the original\n * reference when neither the visitor nor the child rebuild changed anything, so callers\n * can detect \"nothing changed\" by identity and ancestors avoid reallocating.\n */\nfunction transformNode(node: Node, visitor: Visitor, recurse: boolean, parent: Node | undefined): Node {\n const visited = applyVisitor<Node>(node, visitor, parent) ?? node\n return transformChildren(visited, visitor, recurse)\n}\n\n/**\n * Immutably rebuilds a node's children, transforming each child node and leaving non-node values\n * (e.g. `additionalProperties: true`) intact.\n */\nfunction transformChildren(node: Node, visitor: Visitor, recurse: boolean): Node {\n const keys = node.kind === nodeKinds.schema && !recurse ? undefined : VISITOR_KEYS[node.kind]\n if (!keys) return node\n\n const record = node as unknown as Record<string, unknown>\n let updates: Record<string, unknown> | undefined\n // A node under two keys is transformed once, so both keys keep pointing at one node. Leaves never create the map.\n let done: Map<Node, Node> | undefined\n const transformOnce = (child: Node) => {\n done ??= new Map()\n const next = done.get(child) ?? transformNode(child, visitor, recurse, node)\n done.set(child, next)\n return next\n }\n\n for (const key of keys) {\n const value = record[key]\n if (value === undefined || value === null) continue\n if (Array.isArray(value)) {\n // Rebuild the array lazily: allocate a new array only once a child actually changes, copying\n // the unchanged prefix at that point. An unchanged array keeps its original reference and\n // allocates nothing. This also drops the per-array `.map` closure that ran on every node.\n let mapped: Array<unknown> | undefined\n for (const [i, item] of value.entries()) {\n const next = isNode(item) ? transformOnce(item) : item\n if (mapped) {\n mapped.push(next)\n continue\n }\n if (next !== item) mapped = [...value.slice(0, i), next]\n }\n if (mapped) (updates ??= {})[key] = mapped\n continue\n }\n if (isNode(value)) {\n const next = transformOnce(value)\n if (next !== value) (updates ??= {})[key] = next\n continue\n }\n if (isNodeRecord(value)) {\n let mapped: Record<string, unknown> | undefined\n for (const [name, item] of Object.entries(value)) {\n const next = isNode(item) ? transformOnce(item) : item\n if (next !== item) (mapped ??= { ...value })[name] = next\n }\n if (mapped) (updates ??= {})[key] = mapped\n }\n }\n\n if (!updates) return node\n const merged = { ...node, ...updates }\n return merged as Node\n}\n\n/**\n * Depth-first collection pass. Gathers every non-null value the visitor\n * callbacks return into an array.\n *\n * @example Collect every operationId\n * ```ts\n * const ids = collect<string>(root, {\n * operation(node) {\n * return node.operationId\n * },\n * })\n * ```\n */\nexport function collect<T>(node: Node, options: CollectOptions<T>): Array<T> {\n const { depth, parent, ...visitor } = options\n const result: Array<T> = []\n // Plain recursion: draining nested generators costs a `yield*` hop per level for every value.\n collectInto<T>(node, visitor, (depth ?? 'deep') === 'deep', parent, result)\n return result\n}\n\nfunction collectInto<T>(node: Node, visitor: VisitorOf<T>, recurse: boolean, parent: Node | undefined, result: Array<T>): void {\n const v = applyVisitor<T>(node, visitor, parent)\n if (v != null) result.push(v)\n\n if (node.kind === nodeKinds.schema && !recurse) return\n visitChildNodes(node, (child) => {\n collectInto<T>(child, visitor, recurse, node, result)\n return false\n })\n}\n"],"mappings":";;;;;AAIA,SAAgB,gBAAgB,EAAE,WAAsE;CAEtG,IAAI,CAAC,SAAS,UAAU,QAAQ,YAAY,CAAC,QAAQ,WAAW,OAAO,KAAA;CACvE,OAAOA,kBAAAA,OAAO,QAAQ,SAAS,IAAI,QAAQ,SAAS,KAAA;AACtD;;;;;ACeA,MAAM,eAAiE;CACrE,OAAO,CAAC,WAAW,YAAY;CAC/B,WAAW;EAAC;EAAc;EAAe;CAAW;CACpD,aAAa,CAAC,SAAS;CACvB,SAAS,CAAC,UAAU,QAAQ;CAC5B,UAAU,CAAC,WAAW,SAAS;CAC/B,QAAQ;EAAC;EAAc;EAAS;EAAW;EAAwB;EAAqB;EAAiB;CAAM;CAC/G,UAAU,CAAC,QAAQ;CACnB,WAAW,CAAC,QAAQ;AACtB;;;;;AAMA,MAAa,kBAAkB;CAAC;CAAgB;CAAY;AAAS;;AAGrE,MAAa,cAAc;CAAC;CAAS;CAAa;CAAU;CAAY;CAAa;AAAU;;;;AAO/F,MAAM,sBAA6D;CACjE,OAAO;CACP,WAAW;CACX,QAAQ;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