@kubb/kit 5.0.0-beta.100

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs ADDED
@@ -0,0 +1,627 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#endregion
3
+ let _kubb_ast = require("@kubb/ast");
4
+ let _kubb_core = require("@kubb/core");
5
+ //#region ../../internals/utils/src/casing.ts
6
+ /**
7
+ * Shared implementation for camelCase and PascalCase conversion.
8
+ * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)
9
+ * and capitalizes each word according to `pascal`.
10
+ *
11
+ * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
12
+ */
13
+ function toCamelOrPascal(text, pascal) {
14
+ return text.trim().replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/(\d)([a-z])/g, "$1 $2").split(/[\s\-_./\\:]+/).filter(Boolean).map((word, i) => {
15
+ if (word.length > 1 && word === word.toUpperCase()) return word;
16
+ return (i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1);
17
+ }).join("").replace(/[^a-zA-Z0-9]/g, "");
18
+ }
19
+ /**
20
+ * Converts `text` to camelCase.
21
+ *
22
+ * @example Word boundaries
23
+ * `camelCase('hello-world') // 'helloWorld'`
24
+ *
25
+ * @example With a prefix
26
+ * `camelCase('tag', { prefix: 'create' }) // 'createTag'`
27
+ */
28
+ function camelCase(text, { prefix = "", suffix = "" } = {}) {
29
+ return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
30
+ }
31
+ /**
32
+ * Converts `text` to PascalCase.
33
+ *
34
+ * @example Word boundaries
35
+ * `pascalCase('hello-world') // 'HelloWorld'`
36
+ *
37
+ * @example With a suffix
38
+ * `pascalCase('tag', { suffix: 'schema' }) // 'TagSchema'`
39
+ */
40
+ function pascalCase(text, { prefix = "", suffix = "" } = {}) {
41
+ return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true);
42
+ }
43
+ //#endregion
44
+ //#region ../../internals/utils/src/reserved.ts
45
+ /**
46
+ * JavaScript and Java reserved words.
47
+ * @link https://github.com/jonschlinkert/reserved/blob/master/index.js
48
+ */
49
+ const reservedWords = /* @__PURE__ */ new Set([
50
+ "abstract",
51
+ "arguments",
52
+ "boolean",
53
+ "break",
54
+ "byte",
55
+ "case",
56
+ "catch",
57
+ "char",
58
+ "class",
59
+ "const",
60
+ "continue",
61
+ "debugger",
62
+ "default",
63
+ "delete",
64
+ "do",
65
+ "double",
66
+ "else",
67
+ "enum",
68
+ "eval",
69
+ "export",
70
+ "extends",
71
+ "false",
72
+ "final",
73
+ "finally",
74
+ "float",
75
+ "for",
76
+ "function",
77
+ "goto",
78
+ "if",
79
+ "implements",
80
+ "import",
81
+ "in",
82
+ "instanceof",
83
+ "int",
84
+ "interface",
85
+ "let",
86
+ "long",
87
+ "native",
88
+ "new",
89
+ "null",
90
+ "package",
91
+ "private",
92
+ "protected",
93
+ "public",
94
+ "return",
95
+ "short",
96
+ "static",
97
+ "super",
98
+ "switch",
99
+ "synchronized",
100
+ "this",
101
+ "throw",
102
+ "throws",
103
+ "transient",
104
+ "true",
105
+ "try",
106
+ "typeof",
107
+ "var",
108
+ "void",
109
+ "volatile",
110
+ "while",
111
+ "with",
112
+ "yield",
113
+ "Array",
114
+ "Date",
115
+ "hasOwnProperty",
116
+ "Infinity",
117
+ "isFinite",
118
+ "isNaN",
119
+ "isPrototypeOf",
120
+ "length",
121
+ "Math",
122
+ "name",
123
+ "NaN",
124
+ "Number",
125
+ "Object",
126
+ "prototype",
127
+ "String",
128
+ "toString",
129
+ "undefined",
130
+ "valueOf"
131
+ ]);
132
+ /**
133
+ * Returns `true` when `name` is a syntactically valid JavaScript variable name.
134
+ *
135
+ * @example
136
+ * ```ts
137
+ * isValidVarName('status') // true
138
+ * isValidVarName('class') // false (reserved word)
139
+ * isValidVarName('42foo') // false (starts with digit)
140
+ * ```
141
+ */
142
+ function isValidVarName(name) {
143
+ if (!name || reservedWords.has(name)) return false;
144
+ return isIdentifier(name);
145
+ }
146
+ /**
147
+ * Returns `true` when `name` is syntactically a valid identifier, ignoring reserved words.
148
+ *
149
+ * Reserved words and globals (`class`, `name`, `Date`, …) are valid as bare object-literal keys
150
+ * even though they are not valid variable names, so use this (not {@link isValidVarName}) when
151
+ * deciding whether an object key needs quoting.
152
+ *
153
+ * @example
154
+ * ```ts
155
+ * isIdentifier('name') // true
156
+ * isIdentifier('x-total')// false
157
+ * ```
158
+ */
159
+ function isIdentifier(name) {
160
+ return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name);
161
+ }
162
+ //#endregion
163
+ //#region ../../internals/utils/src/Url.ts
164
+ function transformParam(raw) {
165
+ return isValidVarName(raw) ? raw : camelCase(raw);
166
+ }
167
+ /**
168
+ * Renders how a grouped `path` object's member is accessed: dot access for a valid
169
+ * identifier, bracket access with the raw name otherwise.
170
+ */
171
+ function groupedAccessor(name) {
172
+ return isValidVarName(name) ? `.${name}` : `[${JSON.stringify(name)}]`;
173
+ }
174
+ function toParamsObject(path, { replacer } = {}) {
175
+ const params = {};
176
+ for (const match of path.matchAll(/\{([^}]+)\}/g)) {
177
+ const param = transformParam(match[1]);
178
+ const key = replacer ? replacer(param) : param;
179
+ params[key] = key;
180
+ }
181
+ return Object.keys(params).length > 0 ? params : null;
182
+ }
183
+ /**
184
+ * Helpers for OpenAPI/Swagger paths, plus a thin wrapper over the native `URL`.
185
+ */
186
+ var Url = class Url {
187
+ /**
188
+ * Converts an OpenAPI/Swagger path to Express-style colon syntax.
189
+ *
190
+ * @example
191
+ * Url.toPath('/pet/{petId}') // '/pet/:petId'
192
+ */
193
+ static toPath(path) {
194
+ return path.replace(/\{([^}]+)\}/g, ":$1");
195
+ }
196
+ /**
197
+ * Converts an OpenAPI/Swagger path to a TypeScript template literal string.
198
+ * `prefix` is prepended inside the literal, and `replacer` transforms each parameter name.
199
+ *
200
+ * @example
201
+ * Url.toTemplateString('/pet/{petId}') // '`/pet/${petId}`'
202
+ *
203
+ * @example
204
+ * Url.toTemplateString('/pet/{petId}', { prefix: 'https://api' }) // '`https://api/pet/${petId}`'
205
+ */
206
+ static toTemplateString(path, { prefix, replacer } = {}) {
207
+ const result = path.split(/\{([^}]+)\}/).map((part, i) => {
208
+ if (i % 2 === 0) return part;
209
+ const param = transformParam(part);
210
+ return `\${${replacer ? replacer(param) : param}}`;
211
+ }).join("");
212
+ return `\`${prefix ?? ""}${result}\``;
213
+ }
214
+ /**
215
+ * Converts an OpenAPI/Swagger path to a template literal that reads each parameter off a
216
+ * grouped `path` request option, e.g. `/pet/{petId}` becomes `` `/pet/${path.petId}` ``.
217
+ * Parameter names are kept exactly as they appear in the OpenAPI path; a name falls back to
218
+ * bracket access (`` path['pet-id'] ``) only when it isn't a valid JS identifier.
219
+ * `prefix` is prepended inside the literal. Shared by generators that pass a grouped `path` object.
220
+ *
221
+ * @example
222
+ * Url.toGroupedTemplateString('/pet/{petId}') // '`/pet/${path.petId}`'
223
+ *
224
+ * @example
225
+ * Url.toGroupedTemplateString('/user/{monetary-account-id}') // '`/user/${path["monetary-account-id"]}`'
226
+ */
227
+ static toGroupedTemplateString(path, { prefix } = {}) {
228
+ const result = path.split(/\{([^}]+)\}/).map((part, i) => i % 2 === 0 ? part : `\${path${groupedAccessor(part)}}`).join("");
229
+ return `\`${prefix ?? ""}${result}\``;
230
+ }
231
+ /**
232
+ * Returns the path and its extracted params as a structured `URLObject`, or as a stringified
233
+ * expression when `stringify` is set.
234
+ *
235
+ * @example
236
+ * Url.toObject('/pet/{petId}')
237
+ * // { url: '/pet/:petId', params: { petId: 'petId' } }
238
+ */
239
+ static toObject(path, { type = "path", replacer, stringify } = {}) {
240
+ const object = {
241
+ url: type === "path" ? Url.toPath(path) : Url.toTemplateString(path, { replacer }),
242
+ params: toParamsObject(path, { replacer })
243
+ };
244
+ if (stringify) {
245
+ if (type === "template") return JSON.stringify(object).replaceAll("'", "").replaceAll(`"`, "");
246
+ if (object.params) return `{ url: '${object.url}', params: ${JSON.stringify(object.params).replaceAll("'", "").replaceAll(`"`, "")} }`;
247
+ return `{ url: '${object.url}' }`;
248
+ }
249
+ return object;
250
+ }
251
+ };
252
+ //#endregion
253
+ //#region src/macros/macroDiscriminatorEnum.ts
254
+ /**
255
+ * Builds a macro that replaces a discriminator property's schema with a string enum of the given
256
+ * values. Object schemas that lack the property are returned unchanged.
257
+ *
258
+ * @example
259
+ * ```ts
260
+ * const macro = macroDiscriminatorEnum({ propertyName: 'type', values: ['dog', 'cat'] })
261
+ * const next = applyMacros(objectSchema, [macro], { depth: 'shallow' })
262
+ * ```
263
+ */
264
+ function macroDiscriminatorEnum({ propertyName, values, enumName }) {
265
+ return _kubb_ast.ast.defineMacro({
266
+ name: "discriminator-enum",
267
+ schema(node) {
268
+ const objectNode = _kubb_ast.ast.narrowSchema(node, "object");
269
+ if (!objectNode?.properties?.length) return void 0;
270
+ if (!objectNode.properties.some((prop) => prop.name === propertyName)) return void 0;
271
+ return _kubb_ast.ast.factory.createSchema({
272
+ ...objectNode,
273
+ properties: objectNode.properties.map((prop) => {
274
+ if (prop.name !== propertyName) return prop;
275
+ return _kubb_ast.ast.factory.createProperty({
276
+ ...prop,
277
+ schema: _kubb_ast.ast.factory.createSchema({
278
+ type: "enum",
279
+ primitive: "string",
280
+ enumValues: values,
281
+ name: enumName,
282
+ readOnly: prop.schema.readOnly,
283
+ writeOnly: prop.schema.writeOnly
284
+ })
285
+ });
286
+ })
287
+ });
288
+ }
289
+ });
290
+ }
291
+ //#endregion
292
+ //#region src/utils/refs.ts
293
+ const plainStringTypes = /* @__PURE__ */ new Set([
294
+ "string",
295
+ "uuid",
296
+ "email",
297
+ "url",
298
+ "datetime"
299
+ ]);
300
+ /**
301
+ * Returns the last path segment of a reference string.
302
+ *
303
+ * @example
304
+ * `extractRefName('#/components/schemas/Pet') // 'Pet'`
305
+ */
306
+ function extractRefName(ref) {
307
+ return ref.split("/").at(-1) ?? ref;
308
+ }
309
+ /**
310
+ * Builds a PascalCase child schema name by joining a parent name and property name.
311
+ * Returns `null` when there is no parent to nest under.
312
+ *
313
+ * @example Nested under a parent
314
+ * `childName('Order', 'shipping_address') // 'OrderShippingAddress'`
315
+ *
316
+ * @example No parent
317
+ * `childName(undefined, 'params') // null`
318
+ */
319
+ function childName(parentName, propName) {
320
+ return parentName ? pascalCase([parentName, propName].join(" ")) : null;
321
+ }
322
+ /**
323
+ * Builds a PascalCase enum name from the parent name, property name, and a suffix, skipping any
324
+ * empty parts.
325
+ *
326
+ * @example
327
+ * `enumPropName('Order', 'status', 'enum') // 'OrderStatusEnum'`
328
+ */
329
+ function enumPropName(parentName, propName, enumSuffix) {
330
+ return pascalCase([
331
+ parentName,
332
+ propName,
333
+ enumSuffix
334
+ ].filter(Boolean).join(" "));
335
+ }
336
+ /**
337
+ * Merges a ref node with its resolved schema, giving usage-site fields precedence.
338
+ *
339
+ * Every field set on the ref node except `kind`, `type`, `name`, `ref`, and `schema` overrides the
340
+ * same field in the resolved `node.schema` (for example `description`, `nullable`, `readOnly`,
341
+ * `deprecated`). Fields left `undefined` on the ref do not shadow the resolved schema. Non-ref
342
+ * nodes and refs without a resolved `schema` are returned unchanged.
343
+ *
344
+ * @example
345
+ * ```ts
346
+ * const ref = ast.factory.createSchema({ type: 'ref', ref: '#/components/schemas/Pet', description: 'A cute pet' })
347
+ * const merged = syncSchemaRef(ref) // merges with resolved Pet schema
348
+ * ```
349
+ */
350
+ function syncSchemaRef(node) {
351
+ const ref = _kubb_ast.ast.narrowSchema(node, "ref");
352
+ if (!ref) return node;
353
+ if (!ref.schema) return node;
354
+ const { kind: _kind, type: _type, name: _name, ref: _ref, schema: _schema, ...overrides } = ref;
355
+ const definedOverrides = Object.fromEntries(Object.entries(overrides).filter(([, v]) => v !== void 0));
356
+ return _kubb_ast.ast.factory.createSchema({
357
+ ...ref.schema,
358
+ ...definedOverrides
359
+ });
360
+ }
361
+ /**
362
+ * Returns `true` when a schema emits as a plain `string` type.
363
+ *
364
+ * Covers `string`, `uuid`, `email`, `url`, and `datetime` types. For `date` and `time`
365
+ * types, returns `true` only when `representation` is `'string'` rather than `'date'`.
366
+ */
367
+ function isStringType(node) {
368
+ if (plainStringTypes.has(node.type)) return true;
369
+ const temporal = _kubb_ast.ast.narrowSchema(node, "date") ?? _kubb_ast.ast.narrowSchema(node, "time");
370
+ if (temporal) return temporal.representation !== "date";
371
+ return false;
372
+ }
373
+ //#endregion
374
+ //#region src/macros/macroEnumName.ts
375
+ /**
376
+ * Builds a macro that names an inline enum schema from its parent and property name. Boolean enums
377
+ * are left anonymous. Non-enum nodes are returned unchanged.
378
+ *
379
+ * @example
380
+ * ```ts
381
+ * const macro = macroEnumName({ parentName: 'Pet', propName: 'status', enumSuffix: 'enum' })
382
+ * const named = applyMacros(propSchema, [macro], { depth: 'shallow' })
383
+ * ```
384
+ */
385
+ function macroEnumName({ parentName, propName, enumSuffix }) {
386
+ return _kubb_ast.ast.defineMacro({
387
+ name: "enum-name",
388
+ schema(node) {
389
+ const enumNode = _kubb_ast.ast.narrowSchema(node, "enum");
390
+ if (enumNode?.primitive === "boolean") return {
391
+ ...node,
392
+ name: null
393
+ };
394
+ if (enumNode) return {
395
+ ...node,
396
+ name: enumPropName(parentName, propName, enumSuffix)
397
+ };
398
+ }
399
+ });
400
+ }
401
+ //#endregion
402
+ //#region src/macros/macroRenameSchema.ts
403
+ /**
404
+ * Builds a macro that renames a schema consistently: the declaration (`name`) and every ref
405
+ * pointing at it (`targetName`) change together, so imports and printed references stay in
406
+ * sync. Renaming only one side by hand produces imports for files that are never generated.
407
+ *
408
+ * @example
409
+ * `const macro = macroRenameSchema({ from: 'Order', to: 'StoreOrder' })`
410
+ */
411
+ function macroRenameSchema({ from, to }) {
412
+ return _kubb_ast.ast.defineMacro({
413
+ name: "rename-schema",
414
+ schema(node) {
415
+ const refNode = _kubb_ast.ast.narrowSchema(node, "ref");
416
+ if (!refNode) return node.name === from ? {
417
+ ...node,
418
+ name: to
419
+ } : void 0;
420
+ const renamesDeclaration = refNode.name === from;
421
+ const renamesTarget = _kubb_ast.ast.resolveRefName(refNode) === from;
422
+ if (!renamesDeclaration && !renamesTarget) return void 0;
423
+ return {
424
+ ...refNode,
425
+ ...renamesDeclaration ? { name: to } : {},
426
+ ...renamesTarget ? { targetName: to } : {}
427
+ };
428
+ }
429
+ });
430
+ }
431
+ //#endregion
432
+ //#region src/macros/macroSimplifyUnion.ts
433
+ /**
434
+ * Scalar primitive schema types used for union simplification and type narrowing.
435
+ */
436
+ const SCALAR_PRIMITIVE_TYPES = /* @__PURE__ */ new Set([
437
+ "string",
438
+ "number",
439
+ "integer",
440
+ "bigint",
441
+ "boolean"
442
+ ]);
443
+ function isScalarPrimitive(type) {
444
+ return SCALAR_PRIMITIVE_TYPES.has(type);
445
+ }
446
+ /**
447
+ * Filters union members, dropping enum members that a broader scalar primitive already covers.
448
+ */
449
+ function simplifyUnionMembers(members) {
450
+ const scalarPrimitives = new Set(members.filter((member) => isScalarPrimitive(member.type)).map((m) => m.type));
451
+ if (!scalarPrimitives.size) return members;
452
+ return members.filter((member) => {
453
+ const enumNode = _kubb_ast.ast.narrowSchema(member, "enum");
454
+ if (!enumNode) return true;
455
+ const primitive = enumNode.primitive;
456
+ if (!primitive) return true;
457
+ if ((enumNode.namedEnumValues?.length ?? enumNode.enumValues?.length ?? 0) <= 1) return true;
458
+ if (scalarPrimitives.has(primitive)) return false;
459
+ if ((primitive === "integer" || primitive === "number") && (scalarPrimitives.has("integer") || scalarPrimitives.has("number"))) return false;
460
+ return true;
461
+ });
462
+ }
463
+ /**
464
+ * Removes union members a broader scalar primitive already covers, such as a multi-value string enum
465
+ * sitting next to a plain `string`. Single-value enums are kept.
466
+ *
467
+ * @example
468
+ * ```ts
469
+ * const next = applyMacros(unionSchema, [macroSimplifyUnion], { depth: 'shallow' })
470
+ * ```
471
+ */
472
+ const macroSimplifyUnion = _kubb_ast.ast.defineMacro({
473
+ name: "simplify-union",
474
+ schema(node) {
475
+ const unionNode = _kubb_ast.ast.narrowSchema(node, "union");
476
+ if (!unionNode?.members?.length) return void 0;
477
+ const simplified = simplifyUnionMembers(unionNode.members);
478
+ if (simplified.length === unionNode.members.length) return void 0;
479
+ return {
480
+ ...unionNode,
481
+ members: simplified
482
+ };
483
+ }
484
+ });
485
+ //#endregion
486
+ //#region src/utils/mergeAdjacentSchemas.ts
487
+ /**
488
+ * Merges a run of adjacent anonymous object members into one. Named or non-object members break the
489
+ * run and pass through unchanged. The merge follows member order, so callers control which members
490
+ * combine by where they place them in the sequence.
491
+ *
492
+ * @example
493
+ * ```ts
494
+ * const merged = [...mergeAdjacentObjectsLazy([objectA, objectB])]
495
+ * ```
496
+ */
497
+ function* mergeAdjacentObjectsLazy(members) {
498
+ let acc;
499
+ for (const member of members) {
500
+ const objectMember = _kubb_ast.ast.narrowSchema(member, "object");
501
+ if (objectMember && !objectMember.name && acc !== void 0) {
502
+ const accObject = _kubb_ast.ast.narrowSchema(acc, "object");
503
+ if (accObject && !accObject.name) {
504
+ acc = _kubb_ast.ast.factory.createSchema({
505
+ ...accObject,
506
+ properties: [...accObject.properties ?? [], ...objectMember.properties ?? []]
507
+ });
508
+ continue;
509
+ }
510
+ }
511
+ if (acc !== void 0) yield acc;
512
+ acc = member;
513
+ }
514
+ if (acc !== void 0) yield acc;
515
+ }
516
+ //#endregion
517
+ //#region src/utils/schemaGraph.ts
518
+ /**
519
+ * Returns `true` when a schema, or anything nested inside it, references a circular schema.
520
+ *
521
+ * Pass `excludeName` to skip refs to a specific schema, which helps when self-references are handled
522
+ * on their own. Pair it with `ast.findCircularSchemas()` to decide where lazy wrappers go.
523
+ *
524
+ * @note Stops at the first matching circular ref.
525
+ */
526
+ function containsCircularRef(node, { circularSchemas, excludeName }) {
527
+ if (!node || circularSchemas.size === 0) return false;
528
+ for (const _ of _kubb_ast.ast.collect(node, { schema(child) {
529
+ if (child.type !== "ref") return null;
530
+ const name = _kubb_ast.ast.resolveRefName(child);
531
+ return name && name !== excludeName && circularSchemas.has(name) ? true : null;
532
+ } })) return true;
533
+ return false;
534
+ }
535
+ //#endregion
536
+ Object.defineProperty(exports, "Diagnostics", {
537
+ enumerable: true,
538
+ get: function() {
539
+ return _kubb_core.Diagnostics;
540
+ }
541
+ });
542
+ Object.defineProperty(exports, "Hookable", {
543
+ enumerable: true,
544
+ get: function() {
545
+ return _kubb_core.Hookable;
546
+ }
547
+ });
548
+ Object.defineProperty(exports, "Resolver", {
549
+ enumerable: true,
550
+ get: function() {
551
+ return _kubb_core.Resolver;
552
+ }
553
+ });
554
+ exports.Url = Url;
555
+ Object.defineProperty(exports, "ast", {
556
+ enumerable: true,
557
+ get: function() {
558
+ return _kubb_ast.ast;
559
+ }
560
+ });
561
+ exports.childName = childName;
562
+ exports.containsCircularRef = containsCircularRef;
563
+ Object.defineProperty(exports, "createAdapter", {
564
+ enumerable: true,
565
+ get: function() {
566
+ return _kubb_core.createAdapter;
567
+ }
568
+ });
569
+ Object.defineProperty(exports, "createRenderer", {
570
+ enumerable: true,
571
+ get: function() {
572
+ return _kubb_core.createRenderer;
573
+ }
574
+ });
575
+ Object.defineProperty(exports, "createResolver", {
576
+ enumerable: true,
577
+ get: function() {
578
+ return _kubb_core.createResolver;
579
+ }
580
+ });
581
+ Object.defineProperty(exports, "createStorage", {
582
+ enumerable: true,
583
+ get: function() {
584
+ return _kubb_core.createStorage;
585
+ }
586
+ });
587
+ Object.defineProperty(exports, "defineGenerator", {
588
+ enumerable: true,
589
+ get: function() {
590
+ return _kubb_core.defineGenerator;
591
+ }
592
+ });
593
+ Object.defineProperty(exports, "defineParser", {
594
+ enumerable: true,
595
+ get: function() {
596
+ return _kubb_core.defineParser;
597
+ }
598
+ });
599
+ Object.defineProperty(exports, "definePlugin", {
600
+ enumerable: true,
601
+ get: function() {
602
+ return _kubb_core.definePlugin;
603
+ }
604
+ });
605
+ exports.enumPropName = enumPropName;
606
+ exports.extractRefName = extractRefName;
607
+ Object.defineProperty(exports, "fsStorage", {
608
+ enumerable: true,
609
+ get: function() {
610
+ return _kubb_core.fsStorage;
611
+ }
612
+ });
613
+ exports.isStringType = isStringType;
614
+ exports.macroDiscriminatorEnum = macroDiscriminatorEnum;
615
+ exports.macroEnumName = macroEnumName;
616
+ exports.macroRenameSchema = macroRenameSchema;
617
+ exports.macroSimplifyUnion = macroSimplifyUnion;
618
+ Object.defineProperty(exports, "memoryStorage", {
619
+ enumerable: true,
620
+ get: function() {
621
+ return _kubb_core.memoryStorage;
622
+ }
623
+ });
624
+ exports.mergeAdjacentObjectsLazy = mergeAdjacentObjectsLazy;
625
+ exports.syncSchemaRef = syncSchemaRef;
626
+
627
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["ast","ast","ast","ast","ast","ast","ast"],"sources":["../../../internals/utils/src/casing.ts","../../../internals/utils/src/reserved.ts","../../../internals/utils/src/Url.ts","../src/macros/macroDiscriminatorEnum.ts","../src/utils/refs.ts","../src/macros/macroEnumName.ts","../src/macros/macroRenameSchema.ts","../src/macros/macroSimplifyUnion.ts","../src/utils/mergeAdjacentSchemas.ts","../src/utils/schemaGraph.ts"],"sourcesContent":["type Options = {\n /**\n * Text prepended before casing is applied.\n */\n prefix?: string\n /**\n * Text appended before casing is applied.\n */\n suffix?: string\n}\n\n/**\n * Shared implementation for camelCase and PascalCase conversion.\n * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)\n * and capitalizes each word according to `pascal`.\n *\n * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.\n */\nfunction toCamelOrPascal(text: string, pascal: boolean): string {\n return text\n .trim()\n .replace(/([a-z\\d])([A-Z])/g, '$1 $2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')\n .replace(/(\\d)([a-z])/g, '$1 $2')\n .split(/[\\s\\-_./\\\\:]+/)\n .filter(Boolean)\n .map((word, i) => {\n if (word.length > 1 && word === word.toUpperCase()) return word\n const head = i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()\n return head + word.slice(1)\n })\n .join('')\n .replace(/[^a-zA-Z0-9]/g, '')\n}\n\n/**\n * Converts `text` to camelCase.\n *\n * @example Word boundaries\n * `camelCase('hello-world') // 'helloWorld'`\n *\n * @example With a prefix\n * `camelCase('tag', { prefix: 'create' }) // 'createTag'`\n */\nexport function camelCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false)\n}\n\n/**\n * Converts `text` to PascalCase.\n *\n * @example Word boundaries\n * `pascalCase('hello-world') // 'HelloWorld'`\n *\n * @example With a suffix\n * `pascalCase('tag', { suffix: 'schema' }) // 'TagSchema'`\n */\nexport function pascalCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true)\n}\n","/**\n * JavaScript and Java reserved words.\n * @link https://github.com/jonschlinkert/reserved/blob/master/index.js\n */\nconst reservedWords = new Set([\n 'abstract',\n 'arguments',\n 'boolean',\n 'break',\n 'byte',\n 'case',\n 'catch',\n 'char',\n 'class',\n 'const',\n 'continue',\n 'debugger',\n 'default',\n 'delete',\n 'do',\n 'double',\n 'else',\n 'enum',\n 'eval',\n 'export',\n 'extends',\n 'false',\n 'final',\n 'finally',\n 'float',\n 'for',\n 'function',\n 'goto',\n 'if',\n 'implements',\n 'import',\n 'in',\n 'instanceof',\n 'int',\n 'interface',\n 'let',\n 'long',\n 'native',\n 'new',\n 'null',\n 'package',\n 'private',\n 'protected',\n 'public',\n 'return',\n 'short',\n 'static',\n 'super',\n 'switch',\n 'synchronized',\n 'this',\n 'throw',\n 'throws',\n 'transient',\n 'true',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'volatile',\n 'while',\n 'with',\n 'yield',\n 'Array',\n 'Date',\n 'hasOwnProperty',\n 'Infinity',\n 'isFinite',\n 'isNaN',\n 'isPrototypeOf',\n 'length',\n 'Math',\n 'name',\n 'NaN',\n 'Number',\n 'Object',\n 'prototype',\n 'String',\n 'toString',\n 'undefined',\n 'valueOf',\n] as const)\n\n/**\n * Returns `true` when `name` is a syntactically valid JavaScript variable name.\n *\n * @example\n * ```ts\n * isValidVarName('status') // true\n * isValidVarName('class') // false (reserved word)\n * isValidVarName('42foo') // false (starts with digit)\n * ```\n */\nexport function isValidVarName(name: string): boolean {\n if (!name || reservedWords.has(name as 'valueOf')) {\n return false\n }\n return isIdentifier(name)\n}\n\n/**\n * Returns `true` when `name` is syntactically a valid identifier, ignoring reserved words.\n *\n * Reserved words and globals (`class`, `name`, `Date`, …) are valid as bare object-literal keys\n * even though they are not valid variable names, so use this (not {@link isValidVarName}) when\n * deciding whether an object key needs quoting.\n *\n * @example\n * ```ts\n * isIdentifier('name') // true\n * isIdentifier('x-total')// false\n * ```\n */\nexport function isIdentifier(name: string): boolean {\n return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name)\n}\n","import { camelCase } from './casing.ts'\nimport { isValidVarName } from './reserved.ts'\n\ntype URLObject = {\n /**\n * The resolved URL string (Express-style or template literal, depending on context).\n */\n url: string\n /**\n * Extracted path parameters as a key-value map, or `null` when the path has none.\n */\n params: Record<string, string> | null\n}\n\ntype TemplateOptions = {\n /**\n * Literal text prepended inside the template literal, e.g. a base URL.\n */\n prefix?: string | null\n /**\n * Transform applied to each extracted parameter name before interpolation.\n */\n replacer?: (pathParam: string) => string\n}\n\ntype ObjectOptions = {\n /**\n * Controls whether the `url` is rendered as an Express path or a template literal.\n * @default 'path'\n */\n type?: 'path' | 'template'\n /**\n * Transform applied to each extracted parameter name.\n */\n replacer?: (pathParam: string) => string\n /**\n * When `true`, the result is serialized to a string expression instead of a plain object.\n */\n stringify?: boolean\n}\n\nfunction transformParam(raw: string): string {\n return isValidVarName(raw) ? raw : camelCase(raw)\n}\n\n/**\n * Renders how a grouped `path` object's member is accessed: dot access for a valid\n * identifier, bracket access with the raw name otherwise.\n */\nfunction groupedAccessor(name: string): string {\n return isValidVarName(name) ? `.${name}` : `[${JSON.stringify(name)}]`\n}\n\nfunction toParamsObject(path: string, { replacer }: { replacer?: (pathParam: string) => string } = {}): Record<string, string> | null {\n const params: Record<string, string> = {}\n\n for (const match of path.matchAll(/\\{([^}]+)\\}/g)) {\n const param = transformParam(match[1]!)\n const key = replacer ? replacer(param) : param\n params[key] = key\n }\n\n return Object.keys(params).length > 0 ? params : null\n}\n\n/**\n * Helpers for OpenAPI/Swagger paths, plus a thin wrapper over the native `URL`.\n */\nexport class Url {\n /**\n * Converts an OpenAPI/Swagger path to Express-style colon syntax.\n *\n * @example\n * Url.toPath('/pet/{petId}') // '/pet/:petId'\n */\n static toPath(path: string): string {\n return path.replace(/\\{([^}]+)\\}/g, ':$1')\n }\n\n /**\n * Converts an OpenAPI/Swagger path to a TypeScript template literal string.\n * `prefix` is prepended inside the literal, and `replacer` transforms each parameter name.\n *\n * @example\n * Url.toTemplateString('/pet/{petId}') // '`/pet/${petId}`'\n *\n * @example\n * Url.toTemplateString('/pet/{petId}', { prefix: 'https://api' }) // '`https://api/pet/${petId}`'\n */\n static toTemplateString(path: string, { prefix, replacer }: TemplateOptions = {}): string {\n const parts = path.split(/\\{([^}]+)\\}/)\n const result = parts\n .map((part, i) => {\n if (i % 2 === 0) return part\n const param = transformParam(part)\n return `\\${${replacer ? replacer(param) : param}}`\n })\n .join('')\n\n return `\\`${prefix ?? ''}${result}\\``\n }\n\n /**\n * Converts an OpenAPI/Swagger path to a template literal that reads each parameter off a\n * grouped `path` request option, e.g. `/pet/{petId}` becomes `` `/pet/${path.petId}` ``.\n * Parameter names are kept exactly as they appear in the OpenAPI path; a name falls back to\n * bracket access (`` path['pet-id'] ``) only when it isn't a valid JS identifier.\n * `prefix` is prepended inside the literal. Shared by generators that pass a grouped `path` object.\n *\n * @example\n * Url.toGroupedTemplateString('/pet/{petId}') // '`/pet/${path.petId}`'\n *\n * @example\n * Url.toGroupedTemplateString('/user/{monetary-account-id}') // '`/user/${path[\"monetary-account-id\"]}`'\n */\n static toGroupedTemplateString(path: string, { prefix }: { prefix?: string | null } = {}): string {\n const parts = path.split(/\\{([^}]+)\\}/)\n const result = parts.map((part, i) => (i % 2 === 0 ? part : `\\${path${groupedAccessor(part)}}`)).join('')\n\n return `\\`${prefix ?? ''}${result}\\``\n }\n\n /**\n * Returns the path and its extracted params as a structured `URLObject`, or as a stringified\n * expression when `stringify` is set.\n *\n * @example\n * Url.toObject('/pet/{petId}')\n * // { url: '/pet/:petId', params: { petId: 'petId' } }\n */\n static toObject(path: string, { type = 'path', replacer, stringify }: ObjectOptions = {}): URLObject | string {\n const object: URLObject = {\n url: type === 'path' ? Url.toPath(path) : Url.toTemplateString(path, { replacer }),\n params: toParamsObject(path, { replacer }),\n }\n\n if (stringify) {\n if (type === 'template') {\n return JSON.stringify(object).replaceAll(\"'\", '').replaceAll(`\"`, '')\n }\n\n if (object.params) {\n return `{ url: '${object.url}', params: ${JSON.stringify(object.params).replaceAll(\"'\", '').replaceAll(`\"`, '')} }`\n }\n\n return `{ url: '${object.url}' }`\n }\n\n return object\n }\n}\n","import { ast } from '@kubb/ast'\n\ntype Props = {\n propertyName: string\n values: Array<string>\n enumName?: string\n}\n\n/**\n * Builds a macro that replaces a discriminator property's schema with a string enum of the given\n * values. Object schemas that lack the property are returned unchanged.\n *\n * @example\n * ```ts\n * const macro = macroDiscriminatorEnum({ propertyName: 'type', values: ['dog', 'cat'] })\n * const next = applyMacros(objectSchema, [macro], { depth: 'shallow' })\n * ```\n */\nexport function macroDiscriminatorEnum({ propertyName, values, enumName }: Props) {\n return ast.defineMacro({\n name: 'discriminator-enum',\n schema(node) {\n const objectNode = ast.narrowSchema(node, 'object')\n if (!objectNode?.properties?.length) return undefined\n if (!objectNode.properties.some((prop) => prop.name === propertyName)) return undefined\n\n return ast.factory.createSchema({\n ...objectNode,\n properties: objectNode.properties.map((prop) => {\n if (prop.name !== propertyName) return prop\n\n return ast.factory.createProperty({\n ...prop,\n schema: ast.factory.createSchema({\n type: 'enum',\n primitive: 'string',\n enumValues: values,\n name: enumName,\n readOnly: prop.schema.readOnly,\n writeOnly: prop.schema.writeOnly,\n }),\n })\n }),\n })\n },\n })\n}\n","import { ast } from '@kubb/ast'\nimport type { SchemaNode, SchemaType } from '@kubb/ast'\nimport { pascalCase } from '@internals/utils'\n\nconst plainStringTypes = new Set<SchemaType>(['string', 'uuid', 'email', 'url', 'datetime'] as const)\n\n/**\n * Returns the last path segment of a reference string.\n *\n * @example\n * `extractRefName('#/components/schemas/Pet') // 'Pet'`\n */\nexport function extractRefName(ref: string): string {\n return ref.split('/').at(-1) ?? ref\n}\n\n/**\n * Builds a PascalCase child schema name by joining a parent name and property name.\n * Returns `null` when there is no parent to nest under.\n *\n * @example Nested under a parent\n * `childName('Order', 'shipping_address') // 'OrderShippingAddress'`\n *\n * @example No parent\n * `childName(undefined, 'params') // null`\n */\nexport function childName(parentName: string | null | undefined, propName: string): string | null {\n return parentName ? pascalCase([parentName, propName].join(' ')) : null\n}\n\n/**\n * Builds a PascalCase enum name from the parent name, property name, and a suffix, skipping any\n * empty parts.\n *\n * @example\n * `enumPropName('Order', 'status', 'enum') // 'OrderStatusEnum'`\n */\nexport function enumPropName(parentName: string | null | undefined, propName: string, enumSuffix: string): string {\n return pascalCase([parentName, propName, enumSuffix].filter(Boolean).join(' '))\n}\n\n/**\n * Merges a ref node with its resolved schema, giving usage-site fields precedence.\n *\n * Every field set on the ref node except `kind`, `type`, `name`, `ref`, and `schema` overrides the\n * same field in the resolved `node.schema` (for example `description`, `nullable`, `readOnly`,\n * `deprecated`). Fields left `undefined` on the ref do not shadow the resolved schema. Non-ref\n * nodes and refs without a resolved `schema` are returned unchanged.\n *\n * @example\n * ```ts\n * const ref = ast.factory.createSchema({ type: 'ref', ref: '#/components/schemas/Pet', description: 'A cute pet' })\n * const merged = syncSchemaRef(ref) // merges with resolved Pet schema\n * ```\n */\nexport function syncSchemaRef(node: SchemaNode): SchemaNode {\n const ref = ast.narrowSchema(node, 'ref')\n\n if (!ref) return node\n if (!ref.schema) return node\n\n const { kind: _kind, type: _type, name: _name, ref: _ref, schema: _schema, ...overrides } = ref\n\n // Filter out undefined override values so they don't shadow the resolved schema's fields.\n const definedOverrides = Object.fromEntries(Object.entries(overrides).filter(([, v]) => v !== undefined))\n\n return ast.factory.createSchema({ ...ref.schema, ...definedOverrides })\n}\n\n/**\n * Returns `true` when a schema emits as a plain `string` type.\n *\n * Covers `string`, `uuid`, `email`, `url`, and `datetime` types. For `date` and `time`\n * types, returns `true` only when `representation` is `'string'` rather than `'date'`.\n */\nexport function isStringType(node: SchemaNode): boolean {\n if (plainStringTypes.has(node.type)) {\n return true\n }\n\n const temporal = ast.narrowSchema(node, 'date') ?? ast.narrowSchema(node, 'time')\n if (temporal) {\n return temporal.representation !== 'date'\n }\n\n return false\n}\n","import { ast } from '@kubb/ast'\nimport { enumPropName } from '../utils/refs.ts'\n\ntype Props = {\n parentName: string | null | undefined\n propName: string\n enumSuffix: string\n}\n\n/**\n * Builds a macro that names an inline enum schema from its parent and property name. Boolean enums\n * are left anonymous. Non-enum nodes are returned unchanged.\n *\n * @example\n * ```ts\n * const macro = macroEnumName({ parentName: 'Pet', propName: 'status', enumSuffix: 'enum' })\n * const named = applyMacros(propSchema, [macro], { depth: 'shallow' })\n * ```\n */\nexport function macroEnumName({ parentName, propName, enumSuffix }: Props) {\n return ast.defineMacro({\n name: 'enum-name',\n schema(node) {\n const enumNode = ast.narrowSchema(node, 'enum')\n\n if (enumNode?.primitive === 'boolean') return { ...node, name: null }\n if (enumNode) return { ...node, name: enumPropName(parentName, propName, enumSuffix) }\n\n return undefined\n },\n })\n}\n","import { ast } from '@kubb/ast'\n\ntype Props = {\n from: string\n to: string\n}\n\n/**\n * Builds a macro that renames a schema consistently: the declaration (`name`) and every ref\n * pointing at it (`targetName`) change together, so imports and printed references stay in\n * sync. Renaming only one side by hand produces imports for files that are never generated.\n *\n * @example\n * `const macro = macroRenameSchema({ from: 'Order', to: 'StoreOrder' })`\n */\nexport function macroRenameSchema({ from, to }: Props) {\n return ast.defineMacro({\n name: 'rename-schema',\n schema(node) {\n const refNode = ast.narrowSchema(node, 'ref')\n\n if (!refNode) {\n return node.name === from ? { ...node, name: to } : undefined\n }\n\n const renamesDeclaration = refNode.name === from\n const renamesTarget = ast.resolveRefName(refNode) === from\n if (!renamesDeclaration && !renamesTarget) return undefined\n\n return {\n ...refNode,\n ...(renamesDeclaration ? { name: to } : {}),\n ...(renamesTarget ? { targetName: to } : {}),\n }\n },\n })\n}\n","import { ast } from '@kubb/ast'\nimport type { SchemaNode } from '@kubb/ast'\n\ntype ScalarPrimitive = 'string' | 'number' | 'integer' | 'bigint' | 'boolean'\n\n/**\n * Scalar primitive schema types used for union simplification and type narrowing.\n */\nconst SCALAR_PRIMITIVE_TYPES = new Set<ScalarPrimitive>(['string', 'number', 'integer', 'bigint', 'boolean'])\n\nfunction isScalarPrimitive(type: string): type is ScalarPrimitive {\n return SCALAR_PRIMITIVE_TYPES.has(type as ScalarPrimitive)\n}\n\n/**\n * Filters union members, dropping enum members that a broader scalar primitive already covers.\n */\nfunction simplifyUnionMembers(members: Array<SchemaNode>): Array<SchemaNode> {\n const scalarPrimitives = new Set(members.filter((member) => isScalarPrimitive(member.type)).map((m) => m.type))\n if (!scalarPrimitives.size) return members\n\n return members.filter((member) => {\n const enumNode = ast.narrowSchema(member, 'enum')\n if (!enumNode) return true\n\n const primitive = enumNode.primitive\n if (!primitive) return true\n\n const enumValueCount = enumNode.namedEnumValues?.length ?? enumNode.enumValues?.length ?? 0\n if (enumValueCount <= 1) return true\n\n if (scalarPrimitives.has(primitive)) return false\n if ((primitive === 'integer' || primitive === 'number') && (scalarPrimitives.has('integer') || scalarPrimitives.has('number'))) return false\n\n return true\n })\n}\n\n/**\n * Removes union members a broader scalar primitive already covers, such as a multi-value string enum\n * sitting next to a plain `string`. Single-value enums are kept.\n *\n * @example\n * ```ts\n * const next = applyMacros(unionSchema, [macroSimplifyUnion], { depth: 'shallow' })\n * ```\n */\nexport const macroSimplifyUnion = ast.defineMacro({\n name: 'simplify-union',\n schema(node) {\n const unionNode = ast.narrowSchema(node, 'union')\n if (!unionNode?.members?.length) return undefined\n\n const simplified = simplifyUnionMembers(unionNode.members)\n if (simplified.length === unionNode.members.length) return undefined\n\n return { ...unionNode, members: simplified }\n },\n})\n","import { ast } from '@kubb/ast'\nimport type { SchemaNode } from '@kubb/ast'\n\n/**\n * Merges a run of adjacent anonymous object members into one. Named or non-object members break the\n * run and pass through unchanged. The merge follows member order, so callers control which members\n * combine by where they place them in the sequence.\n *\n * @example\n * ```ts\n * const merged = [...mergeAdjacentObjectsLazy([objectA, objectB])]\n * ```\n */\nexport function* mergeAdjacentObjectsLazy(members: Iterable<SchemaNode>): Generator<SchemaNode, void, undefined> {\n let acc: SchemaNode | undefined\n\n for (const member of members) {\n const objectMember = ast.narrowSchema(member, 'object')\n if (objectMember && !objectMember.name && acc !== undefined) {\n const accObject = ast.narrowSchema(acc, 'object')\n if (accObject && !accObject.name) {\n acc = ast.factory.createSchema({\n ...accObject,\n properties: [...(accObject.properties ?? []), ...(objectMember.properties ?? [])],\n })\n continue\n }\n }\n if (acc !== undefined) yield acc\n acc = member\n }\n\n if (acc !== undefined) yield acc\n}\n","import { ast } from '@kubb/ast'\nimport type { SchemaNode } from '@kubb/ast'\n\n/**\n * Returns `true` when a schema, or anything nested inside it, references a circular schema.\n *\n * Pass `excludeName` to skip refs to a specific schema, which helps when self-references are handled\n * on their own. Pair it with `ast.findCircularSchemas()` to decide where lazy wrappers go.\n *\n * @note Stops at the first matching circular ref.\n */\nexport function containsCircularRef(\n node: SchemaNode | undefined,\n { circularSchemas, excludeName }: { circularSchemas: ReadonlySet<string>; excludeName?: string },\n): boolean {\n if (!node || circularSchemas.size === 0) return false\n\n for (const _ of ast.collect<true>(node, {\n schema(child) {\n if (child.type !== 'ref') return null\n const name = ast.resolveRefName(child)\n return name && name !== excludeName && circularSchemas.has(name) ? true : null\n },\n })) {\n return true\n }\n\n return false\n}\n"],"mappings":";;;;;;;;;;;;AAkBA,SAAS,gBAAgB,MAAc,QAAyB;CAC9D,OAAO,KACJ,KAAK,CAAC,CACN,QAAQ,qBAAqB,OAAO,CAAC,CACrC,QAAQ,yBAAyB,OAAO,CAAC,CACzC,QAAQ,gBAAgB,OAAO,CAAC,CAChC,MAAM,eAAe,CAAC,CACtB,OAAO,OAAO,CAAC,CACf,KAAK,MAAM,MAAM;EAChB,IAAI,KAAK,SAAS,KAAK,SAAS,KAAK,YAAY,GAAG,OAAO;EAE3D,QADa,MAAM,KAAK,CAAC,SAAS,KAAK,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,YAAY,KAC9E,KAAK,MAAM,CAAC;CAC5B,CAAC,CAAC,CACD,KAAK,EAAE,CAAC,CACR,QAAQ,iBAAiB,EAAE;AAChC;;;;;;;;;;AAWA,SAAgB,UAAU,MAAc,EAAE,SAAS,IAAI,SAAS,OAAgB,CAAC,GAAW;CAC1F,OAAO,gBAAgB,GAAG,OAAO,GAAG,KAAK,GAAG,UAAU,KAAK;AAC7D;;;;;;;;;;AAWA,SAAgB,WAAW,MAAc,EAAE,SAAS,IAAI,SAAS,OAAgB,CAAC,GAAW;CAC3F,OAAO,gBAAgB,GAAG,OAAO,GAAG,KAAK,GAAG,UAAU,IAAI;AAC5D;;;;;;;ACvDA,MAAM,gCAAgB,IAAI,IAAI;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;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