@kubb/plugin-ts 5.0.0-alpha.20 → 5.0.0-alpha.22
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/Type-Bf8raoQX.cjs +124 -0
- package/dist/Type-Bf8raoQX.cjs.map +1 -0
- package/dist/Type-BpXxT4l_.js +113 -0
- package/dist/Type-BpXxT4l_.js.map +1 -0
- package/dist/builderTs-COUg3xtQ.cjs +135 -0
- package/dist/builderTs-COUg3xtQ.cjs.map +1 -0
- package/dist/builderTs-DPpkJKd1.js +131 -0
- package/dist/builderTs-DPpkJKd1.js.map +1 -0
- package/dist/builders.cjs +3 -0
- package/dist/builders.d.ts +23 -0
- package/dist/builders.js +2 -0
- package/dist/{casing-Cp-jbC_k.js → casing-BJHFg-zZ.js} +1 -1
- package/dist/{casing-Cp-jbC_k.js.map → casing-BJHFg-zZ.js.map} +1 -1
- package/dist/{casing-D2uQKLWS.cjs → casing-DHfdqpLi.cjs} +2 -39
- package/dist/{casing-D2uQKLWS.cjs.map → casing-DHfdqpLi.cjs.map} +1 -1
- package/dist/chunk-ByKO4r7w.cjs +38 -0
- package/dist/components.cjs +1 -1
- package/dist/components.d.ts +5 -2
- package/dist/components.js +1 -1
- package/dist/generators-DFDut8o-.js +555 -0
- package/dist/generators-DFDut8o-.js.map +1 -0
- package/dist/{generators-xHWQCNd9.cjs → generators-DKd7MYbx.cjs} +300 -293
- package/dist/generators-DKd7MYbx.cjs.map +1 -0
- package/dist/generators.cjs +2 -1
- package/dist/generators.d.ts +5 -2
- package/dist/generators.js +2 -2
- package/dist/index.cjs +75 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +21 -2
- package/dist/index.js +73 -35
- package/dist/index.js.map +1 -1
- package/dist/{Type-B70QnSzH.cjs → printerTs-BcHudagv.cjs} +41 -135
- package/dist/printerTs-BcHudagv.cjs.map +1 -0
- package/dist/{Type-CMC7L-38.js → printerTs-CMBCOuqd.js} +19 -132
- package/dist/printerTs-CMBCOuqd.js.map +1 -0
- package/dist/printers.cjs +3 -0
- package/dist/printers.d.ts +81 -0
- package/dist/printers.js +2 -0
- package/dist/{resolvers-DsKabI0F.js → resolverTsLegacy-CPiqqsO6.js} +10 -9
- package/dist/resolverTsLegacy-CPiqqsO6.js.map +1 -0
- package/dist/{resolvers-YIpeP5YD.cjs → resolverTsLegacy-CuR9XbKk.cjs} +11 -9
- package/dist/resolverTsLegacy-CuR9XbKk.cjs.map +1 -0
- package/dist/resolvers.cjs +3 -3
- package/dist/resolvers.d.ts +1 -1
- package/dist/resolvers.js +1 -1
- package/dist/{types-zqLMbIqZ.d.ts → types-CRtcZOCz.d.ts} +59 -25
- package/package.json +17 -5
- package/src/builders/builderTs.ts +107 -0
- package/src/builders/index.ts +1 -0
- package/src/components/Enum.tsx +15 -11
- package/src/components/Type.tsx +20 -9
- package/src/factory.ts +0 -32
- package/src/generators/index.ts +1 -0
- package/src/generators/typeGenerator.tsx +53 -141
- package/src/generators/typeGeneratorLegacy.tsx +348 -0
- package/src/index.ts +1 -1
- package/src/plugin.ts +36 -44
- package/src/presets.ts +27 -7
- package/src/printers/index.ts +1 -0
- package/src/{printer.ts → printers/printerTs.ts} +31 -19
- package/src/resolvers/resolverTs.ts +9 -6
- package/src/resolvers/resolverTsLegacy.ts +1 -1
- package/src/types.ts +72 -24
- package/dist/Type-B70QnSzH.cjs.map +0 -1
- package/dist/Type-CMC7L-38.js.map +0 -1
- package/dist/generators-BFkr7ecU.js +0 -556
- package/dist/generators-BFkr7ecU.js.map +0 -1
- package/dist/generators-xHWQCNd9.cjs.map +0 -1
- package/dist/resolvers-DsKabI0F.js.map +0 -1
- package/dist/resolvers-YIpeP5YD.cjs.map +0 -1
- package/src/generators/utils.ts +0 -308
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_chunk = require("./chunk-ByKO4r7w.cjs");
|
|
2
|
+
const require_casing = require("./casing-DHfdqpLi.cjs");
|
|
2
3
|
let _kubb_ast = require("@kubb/ast");
|
|
3
4
|
let _kubb_core = require("@kubb/core");
|
|
4
|
-
let _kubb_react_fabric = require("@kubb/react-fabric");
|
|
5
5
|
let _kubb_fabric_core_parsers_typescript = require("@kubb/fabric-core/parsers/typescript");
|
|
6
6
|
let remeda = require("remeda");
|
|
7
7
|
let typescript = require("typescript");
|
|
8
|
-
typescript =
|
|
9
|
-
let _kubb_react_fabric_jsx_runtime = require("@kubb/react-fabric/jsx-runtime");
|
|
8
|
+
typescript = require_chunk.__toESM(typescript);
|
|
10
9
|
//#region ../../internals/utils/src/string.ts
|
|
11
10
|
/**
|
|
12
11
|
* Strips a single matching pair of `"..."`, `'...'`, or `` `...` `` from both ends of `text`.
|
|
@@ -318,7 +317,7 @@ factory.createIndexedAccessTypeNode;
|
|
|
318
317
|
factory.createTypeOperatorNode;
|
|
319
318
|
const createPrefixUnaryExpression = factory.createPrefixUnaryExpression;
|
|
320
319
|
//#endregion
|
|
321
|
-
//#region src/
|
|
320
|
+
//#region src/printers/printerTs.ts
|
|
322
321
|
/**
|
|
323
322
|
* Converts a primitive const value to a TypeScript literal type node.
|
|
324
323
|
* Handles negative numbers via a prefix unary expression.
|
|
@@ -464,8 +463,7 @@ const printerTs = (0, _kubb_core.definePrinter)((options) => {
|
|
|
464
463
|
withParentheses: true,
|
|
465
464
|
nodes: values.filter((v) => v !== null).map((value) => constToTypeNode(value, typeof value)).filter(Boolean)
|
|
466
465
|
}) ?? void 0;
|
|
467
|
-
|
|
468
|
-
return createTypeReferenceNode(ENUM_TYPES_WITH_KEY_SUFFIX.has(this.options.enumType) ? `${resolvedName}Key` : resolvedName, void 0);
|
|
466
|
+
return createTypeReferenceNode(ENUM_TYPES_WITH_KEY_SUFFIX.has(this.options.enumType) && this.options.enumTypeSuffix ? this.options.resolver.resolveEnumKeyTypedName(node, this.options.enumTypeSuffix) : this.options.resolver.default(node.name, "type"), void 0);
|
|
469
467
|
},
|
|
470
468
|
union(node) {
|
|
471
469
|
const members = node.members ?? [];
|
|
@@ -480,34 +478,34 @@ const printerTs = (0, _kubb_core.definePrinter)((options) => {
|
|
|
480
478
|
nodes: [keywordTypeNodes.string, createTypeLiteralNode([])],
|
|
481
479
|
withParentheses: true
|
|
482
480
|
});
|
|
483
|
-
return this.
|
|
481
|
+
return this.transform(m);
|
|
484
482
|
}).filter(Boolean)
|
|
485
483
|
}) ?? void 0;
|
|
486
484
|
return createUnionDeclaration({
|
|
487
485
|
withParentheses: true,
|
|
488
|
-
nodes: buildMemberNodes(members, this.
|
|
486
|
+
nodes: buildMemberNodes(members, this.transform)
|
|
489
487
|
}) ?? void 0;
|
|
490
488
|
},
|
|
491
489
|
intersection(node) {
|
|
492
490
|
return createIntersectionDeclaration({
|
|
493
491
|
withParentheses: true,
|
|
494
|
-
nodes: buildMemberNodes(node.members, this.
|
|
492
|
+
nodes: buildMemberNodes(node.members, this.transform)
|
|
495
493
|
}) ?? void 0;
|
|
496
494
|
},
|
|
497
495
|
array(node) {
|
|
498
496
|
return createArrayDeclaration({
|
|
499
|
-
nodes: (node.items ?? []).map((item) => this.
|
|
497
|
+
nodes: (node.items ?? []).map((item) => this.transform(item)).filter(Boolean),
|
|
500
498
|
arrayType: this.options.arrayType
|
|
501
499
|
}) ?? void 0;
|
|
502
500
|
},
|
|
503
501
|
tuple(node) {
|
|
504
|
-
return buildTupleNode(node, this.
|
|
502
|
+
return buildTupleNode(node, this.transform);
|
|
505
503
|
},
|
|
506
504
|
object(node) {
|
|
507
|
-
const {
|
|
505
|
+
const { transform, options } = this;
|
|
508
506
|
const addsQuestionToken = OPTIONAL_ADDS_QUESTION_TOKEN.has(options.optionalType);
|
|
509
507
|
const propertyNodes = node.properties.map((prop) => {
|
|
510
|
-
const baseType =
|
|
508
|
+
const baseType = transform(prop.schema) ?? keywordTypeNodes.unknown;
|
|
511
509
|
const type = buildPropertyType(prop.schema, baseType, options.optionalType);
|
|
512
510
|
return appendJSDocToNode({
|
|
513
511
|
node: createPropertySignature({
|
|
@@ -519,20 +517,20 @@ const printerTs = (0, _kubb_core.definePrinter)((options) => {
|
|
|
519
517
|
comments: buildPropertyJSDocComments(prop.schema)
|
|
520
518
|
});
|
|
521
519
|
});
|
|
522
|
-
const allElements = [...propertyNodes, ...buildIndexSignatures(node, propertyNodes.length,
|
|
520
|
+
const allElements = [...propertyNodes, ...buildIndexSignatures(node, propertyNodes.length, transform)];
|
|
523
521
|
if (!allElements.length) return keywordTypeNodes.object;
|
|
524
522
|
return createTypeLiteralNode(allElements);
|
|
525
523
|
}
|
|
526
524
|
},
|
|
527
525
|
print(node) {
|
|
528
|
-
let type = this.
|
|
529
|
-
if (!type) return;
|
|
526
|
+
let type = this.transform(node);
|
|
527
|
+
if (!type) return null;
|
|
530
528
|
if (node.nullable) type = createUnionDeclaration({ nodes: [type, keywordTypeNodes.null] });
|
|
531
529
|
if ((node.nullish || node.optional) && addsUndefined) type = createUnionDeclaration({ nodes: [type, keywordTypeNodes.undefined] });
|
|
532
530
|
const { typeName, syntaxType = "type", description, keysToOmit } = this.options;
|
|
533
|
-
if (!typeName) return type;
|
|
531
|
+
if (!typeName) return (0, _kubb_fabric_core_parsers_typescript.safePrint)(type);
|
|
534
532
|
const useTypeGeneration = syntaxType === "type" || type.kind === syntaxKind.union || !!keysToOmit?.length;
|
|
535
|
-
return createTypeDeclaration({
|
|
533
|
+
return (0, _kubb_fabric_core_parsers_typescript.safePrint)(createTypeDeclaration({
|
|
536
534
|
name: typeName,
|
|
537
535
|
isExportable: true,
|
|
538
536
|
type: keysToOmit?.length ? createOmitDeclaration({
|
|
@@ -551,138 +549,46 @@ const printerTs = (0, _kubb_core.definePrinter)((options) => {
|
|
|
551
549
|
node?.default ? `@default ${node.default}` : void 0,
|
|
552
550
|
node?.example ? `@example ${node.example}` : void 0
|
|
553
551
|
]
|
|
554
|
-
});
|
|
552
|
+
}));
|
|
555
553
|
}
|
|
556
554
|
};
|
|
557
555
|
});
|
|
558
556
|
//#endregion
|
|
559
|
-
//#region src/components/Enum.tsx
|
|
560
|
-
/**
|
|
561
|
-
* Resolves the runtime identifier name and the TypeScript type name for an enum schema node.
|
|
562
|
-
*
|
|
563
|
-
* The raw `node.name` may be a YAML key such as `"enumNames.Type"` which is not a
|
|
564
|
-
* valid TypeScript identifier. The resolver normalizes it; for inline enum
|
|
565
|
-
* properties the adapter already emits a PascalCase+suffix name so resolution is typically a no-op.
|
|
566
|
-
*/
|
|
567
|
-
function getEnumNames({ node, enumType, resolver }) {
|
|
568
|
-
const resolved = resolver.default(node.name, "type");
|
|
569
|
-
return {
|
|
570
|
-
enumName: enumType === "asPascalConst" ? resolved : require_casing.camelCase(node.name),
|
|
571
|
-
typeName: ENUM_TYPES_WITH_KEY_SUFFIX.has(enumType) ? `${resolved}Key` : resolved,
|
|
572
|
-
refName: resolved
|
|
573
|
-
};
|
|
574
|
-
}
|
|
575
|
-
/**
|
|
576
|
-
* Renders the enum declaration(s) for a single named `EnumSchemaNode`.
|
|
577
|
-
*
|
|
578
|
-
* Depending on `enumType` this may emit:
|
|
579
|
-
* - A runtime object (`asConst` / `asPascalConst`) plus a `typeof` type alias
|
|
580
|
-
* - A `const enum` or plain `enum` declaration (`constEnum` / `enum`)
|
|
581
|
-
* - A union literal type alias (`literal`)
|
|
582
|
-
*
|
|
583
|
-
* The emitted `File.Source` nodes carry the resolved names so that the barrel
|
|
584
|
-
* index picks up the correct export identifiers.
|
|
585
|
-
*/
|
|
586
|
-
function Enum({ node, enumType, enumKeyCasing, resolver }) {
|
|
587
|
-
const { enumName, typeName, refName } = getEnumNames({
|
|
588
|
-
node,
|
|
589
|
-
enumType,
|
|
590
|
-
resolver
|
|
591
|
-
});
|
|
592
|
-
const [nameNode, typeNode] = createEnumDeclaration({
|
|
593
|
-
name: enumName,
|
|
594
|
-
typeName,
|
|
595
|
-
enums: node.namedEnumValues?.map((v) => [trimQuotes(v.name.toString()), v.value]) ?? node.enumValues?.filter((v) => v !== null && v !== void 0).map((v) => [trimQuotes(v.toString()), v]) ?? [],
|
|
596
|
-
type: enumType,
|
|
597
|
-
enumKeyCasing
|
|
598
|
-
});
|
|
599
|
-
const needsRefAlias = ENUM_TYPES_WITH_KEY_SUFFIX.has(enumType) && refName !== typeName;
|
|
600
|
-
return /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric_jsx_runtime.Fragment, { children: [
|
|
601
|
-
nameNode && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Source, {
|
|
602
|
-
name: enumName,
|
|
603
|
-
isExportable: true,
|
|
604
|
-
isIndexable: true,
|
|
605
|
-
isTypeOnly: false,
|
|
606
|
-
children: (0, _kubb_fabric_core_parsers_typescript.safePrint)(nameNode)
|
|
607
|
-
}),
|
|
608
|
-
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Source, {
|
|
609
|
-
name: typeName,
|
|
610
|
-
isIndexable: true,
|
|
611
|
-
isExportable: ENUM_TYPES_WITH_RUNTIME_VALUE.has(enumType),
|
|
612
|
-
isTypeOnly: ENUM_TYPES_WITH_TYPE_ONLY.has(enumType),
|
|
613
|
-
children: (0, _kubb_fabric_core_parsers_typescript.safePrint)(typeNode)
|
|
614
|
-
}),
|
|
615
|
-
needsRefAlias && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Source, {
|
|
616
|
-
name: refName,
|
|
617
|
-
isExportable: true,
|
|
618
|
-
isIndexable: true,
|
|
619
|
-
isTypeOnly: true,
|
|
620
|
-
children: `export type ${refName} = ${typeName}`
|
|
621
|
-
})
|
|
622
|
-
] });
|
|
623
|
-
}
|
|
624
|
-
//#endregion
|
|
625
|
-
//#region src/components/Type.tsx
|
|
626
|
-
function Type({ name, typedName, node, keysToOmit, optionalType, arrayType, syntaxType, enumType, enumKeyCasing, description, resolver }) {
|
|
627
|
-
const resolvedDescription = description || node?.description;
|
|
628
|
-
const enumSchemaNodes = (0, _kubb_ast.collect)(node, { schema(n) {
|
|
629
|
-
const enumNode = (0, _kubb_ast.narrowSchema)(n, _kubb_ast.schemaTypes.enum);
|
|
630
|
-
if (enumNode?.name) return enumNode;
|
|
631
|
-
} });
|
|
632
|
-
const typeNode = printerTs({
|
|
633
|
-
optionalType,
|
|
634
|
-
arrayType,
|
|
635
|
-
enumType,
|
|
636
|
-
typeName: name,
|
|
637
|
-
syntaxType,
|
|
638
|
-
description: resolvedDescription,
|
|
639
|
-
keysToOmit,
|
|
640
|
-
resolver
|
|
641
|
-
}).print(node);
|
|
642
|
-
if (!typeNode) return;
|
|
643
|
-
const enums = [...new Map(enumSchemaNodes.map((n) => [n.name, n])).values()].map((node) => {
|
|
644
|
-
return {
|
|
645
|
-
node,
|
|
646
|
-
...getEnumNames({
|
|
647
|
-
node,
|
|
648
|
-
enumType,
|
|
649
|
-
resolver
|
|
650
|
-
})
|
|
651
|
-
};
|
|
652
|
-
});
|
|
653
|
-
const shouldExportEnums = enumType !== "inlineLiteral";
|
|
654
|
-
const shouldExportType = enumType === "inlineLiteral" || enums.every((item) => item.typeName !== name);
|
|
655
|
-
return /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric_jsx_runtime.Fragment, { children: [shouldExportEnums && enums.map(({ node }) => /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(Enum, {
|
|
656
|
-
node,
|
|
657
|
-
enumType,
|
|
658
|
-
enumKeyCasing,
|
|
659
|
-
resolver
|
|
660
|
-
})), shouldExportType && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Source, {
|
|
661
|
-
name: typedName,
|
|
662
|
-
isTypeOnly: true,
|
|
663
|
-
isExportable: true,
|
|
664
|
-
isIndexable: true,
|
|
665
|
-
children: (0, _kubb_fabric_core_parsers_typescript.safePrint)(typeNode)
|
|
666
|
-
})] });
|
|
667
|
-
}
|
|
668
|
-
//#endregion
|
|
669
557
|
Object.defineProperty(exports, "ENUM_TYPES_WITH_KEY_SUFFIX", {
|
|
670
558
|
enumerable: true,
|
|
671
559
|
get: function() {
|
|
672
560
|
return ENUM_TYPES_WITH_KEY_SUFFIX;
|
|
673
561
|
}
|
|
674
562
|
});
|
|
675
|
-
Object.defineProperty(exports, "
|
|
563
|
+
Object.defineProperty(exports, "ENUM_TYPES_WITH_RUNTIME_VALUE", {
|
|
564
|
+
enumerable: true,
|
|
565
|
+
get: function() {
|
|
566
|
+
return ENUM_TYPES_WITH_RUNTIME_VALUE;
|
|
567
|
+
}
|
|
568
|
+
});
|
|
569
|
+
Object.defineProperty(exports, "ENUM_TYPES_WITH_TYPE_ONLY", {
|
|
570
|
+
enumerable: true,
|
|
571
|
+
get: function() {
|
|
572
|
+
return ENUM_TYPES_WITH_TYPE_ONLY;
|
|
573
|
+
}
|
|
574
|
+
});
|
|
575
|
+
Object.defineProperty(exports, "createEnumDeclaration", {
|
|
576
|
+
enumerable: true,
|
|
577
|
+
get: function() {
|
|
578
|
+
return createEnumDeclaration;
|
|
579
|
+
}
|
|
580
|
+
});
|
|
581
|
+
Object.defineProperty(exports, "printerTs", {
|
|
676
582
|
enumerable: true,
|
|
677
583
|
get: function() {
|
|
678
|
-
return
|
|
584
|
+
return printerTs;
|
|
679
585
|
}
|
|
680
586
|
});
|
|
681
|
-
Object.defineProperty(exports, "
|
|
587
|
+
Object.defineProperty(exports, "trimQuotes", {
|
|
682
588
|
enumerable: true,
|
|
683
589
|
get: function() {
|
|
684
|
-
return
|
|
590
|
+
return trimQuotes;
|
|
685
591
|
}
|
|
686
592
|
});
|
|
687
593
|
|
|
688
|
-
//# sourceMappingURL=
|
|
594
|
+
//# sourceMappingURL=printerTs-BcHudagv.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"printerTs-BcHudagv.cjs","names":["ts","screamingSnakeCase","snakeCase","pascalCase","camelCase","factory.createLiteralTypeNode","factory.createTrue","factory.createFalse","factory.createPrefixUnaryExpression","factory.createNumericLiteral","factory.createStringLiteral","factory.createTypeReferenceNode","factory.createIdentifier","factory.createOptionalTypeNode","factory.createRestTypeNode","factory.createArrayTypeNode","factory.createTupleTypeNode","factory.createUnionDeclaration","factory.createIndexSignature","factory.createUrlTemplateType","schemaTypes","factory.createIntersectionDeclaration","factory.createTypeLiteralNode","factory.createArrayDeclaration","factory.createPropertySignature","factory.appendJSDocToNode","factory.createTypeDeclaration","factory.createOmitDeclaration"],"sources":["../../../internals/utils/src/string.ts","../../../internals/utils/src/object.ts","../src/constants.ts","../src/factory.ts","../src/printers/printerTs.ts"],"sourcesContent":["/**\n * Strips a single matching pair of `\"...\"`, `'...'`, or `` `...` `` from both ends of `text`.\n * Returns the string unchanged when no balanced quote pair is found.\n *\n * @example\n * trimQuotes('\"hello\"') // 'hello'\n * trimQuotes('hello') // 'hello'\n */\nexport function trimQuotes(text: string): string {\n if (text.length >= 2) {\n const first = text[0]\n const last = text[text.length - 1]\n if ((first === '\"' && last === '\"') || (first === \"'\" && last === \"'\") || (first === '`' && last === '`')) {\n return text.slice(1, -1)\n }\n }\n return text\n}\n\n/**\n * Escapes characters that are not allowed inside JS string literals.\n * Handles quotes, backslashes, and Unicode line terminators (U+2028 / U+2029).\n *\n * @see http://www.ecma-international.org/ecma-262/5.1/#sec-7.8.4\n *\n * @example\n * ```ts\n * jsStringEscape('say \"hi\"\\nbye') // 'say \\\\\"hi\\\\\"\\\\nbye'\n * ```\n */\nexport function jsStringEscape(input: unknown): string {\n return `${input}`.replace(/[\"'\\\\\\n\\r\\u2028\\u2029]/g, (character) => {\n switch (character) {\n case '\"':\n case \"'\":\n case '\\\\':\n return `\\\\${character}`\n case '\\n':\n return '\\\\n'\n case '\\r':\n return '\\\\r'\n case '\\u2028':\n return '\\\\u2028'\n case '\\u2029':\n return '\\\\u2029'\n default:\n return ''\n }\n })\n}\n\n/**\n * Returns a masked version of a string, showing only the first and last few characters.\n * Useful for logging sensitive values (tokens, keys) without exposing the full value.\n *\n * @example\n * maskString('KUBB_STUDIO-abc123-xyz789') // 'KUBB_STUDIO-…789'\n */\nexport function maskString(value: string, start = 8, end = 4): string {\n if (value.length <= start + end) return value\n return `${value.slice(0, start)}…${value.slice(-end)}`\n}\n","import { trimQuotes } from './string.ts'\n\n/**\n * Serializes a primitive value to a JSON string literal, stripping any surrounding quote characters first.\n *\n * @example\n * stringify('hello') // '\"hello\"'\n * stringify('\"hello\"') // '\"hello\"'\n */\nexport function stringify(value: string | number | boolean | undefined): string {\n if (value === undefined || value === null) return '\"\"'\n return JSON.stringify(trimQuotes(value.toString()))\n}\n\n/**\n * Converts a plain object into a multiline key-value string suitable for embedding in generated code.\n * Nested objects are recursively stringified with indentation.\n *\n * @example\n * stringifyObject({ foo: 'bar', nested: { a: 1 } })\n * // 'foo: bar,\\nnested: {\\n a: 1\\n }'\n */\nexport function stringifyObject(value: Record<string, unknown>): string {\n const items = Object.entries(value)\n .map(([key, val]) => {\n if (val !== null && typeof val === 'object') {\n return `${key}: {\\n ${stringifyObject(val as Record<string, unknown>)}\\n }`\n }\n return `${key}: ${val}`\n })\n .filter(Boolean)\n return items.join(',\\n')\n}\n\n/**\n * Strips functions, symbols, and `undefined` values from plugin options for safe JSON transport.\n *\n * @example\n * ```ts\n * serializePluginOptions({ output: './src', onWrite: () => {} })\n * // { output: './src' } (function stripped)\n * ```\n */\nexport function serializePluginOptions<TOptions extends object>(options: TOptions): TOptions {\n if (options === null || options === undefined) return {} as TOptions\n if (typeof options !== 'object') return options\n if (Array.isArray(options)) return options.map(serializePluginOptions) as unknown as TOptions\n\n const serialized: Record<string, unknown> = {}\n for (const [key, value] of Object.entries(options)) {\n if (typeof value === 'function' || typeof value === 'symbol' || value === undefined) continue\n serialized[key] = value !== null && typeof value === 'object' ? serializePluginOptions(value as object) : value\n }\n return serialized as TOptions\n}\n\n/**\n * Strips all `undefined` values from an object recursively by round-tripping through JSON.\n * Useful for clean inline snapshot assertions that only show fields with actual values.\n *\n * @example\n * toSnapshot({ kind: 'Schema', name: undefined, type: 'string' })\n * // { kind: 'Schema', type: 'string' }\n */\nexport function toSnapshot<T>(value: T): T {\n return JSON.parse(JSON.stringify(value))\n}\n\n/**\n * Converts a dot-notation path or string array into an optional-chaining accessor expression.\n *\n * @example\n * getNestedAccessor('pagination.next.id', 'lastPage')\n * // → \"lastPage?.['pagination']?.['next']?.['id']\"\n */\nexport function getNestedAccessor(param: string | string[], accessor: string): string | null {\n const parts = Array.isArray(param) ? param : param.split('.')\n if (parts.length === 0 || (parts.length === 1 && parts[0] === '')) return null\n return `${accessor}?.['${`${parts.join(\"']?.['\")}']`}`\n}\n","import type { PluginTs } from './types.ts'\n\ntype OptionalType = PluginTs['resolvedOptions']['optionalType']\ntype EnumType = PluginTs['resolvedOptions']['enumType']\n\n/**\n * `optionalType` values that cause a property's type to include `| undefined`.\n */\nexport const OPTIONAL_ADDS_UNDEFINED = new Set<OptionalType>(['undefined', 'questionTokenAndUndefined'] as const)\n\n/**\n * `optionalType` values that render the property key with a `?` token.\n */\nexport const OPTIONAL_ADDS_QUESTION_TOKEN = new Set<OptionalType>(['questionToken', 'questionTokenAndUndefined'] as const)\n\n/**\n * `enumType` values that append a `Key` suffix to the generated enum type alias.\n */\nexport const ENUM_TYPES_WITH_KEY_SUFFIX = new Set<EnumType>(['asConst', 'asPascalConst'] as const)\n\n/**\n * `enumType` values that require a runtime value declaration (object, enum, or literal).\n */\nexport const ENUM_TYPES_WITH_RUNTIME_VALUE = new Set<EnumType | undefined>(['enum', 'asConst', 'asPascalConst', 'constEnum', 'literal', undefined] as const)\n\n/**\n * `enumType` values whose type declaration is type-only (no runtime value emitted for the type alias).\n */\nexport const ENUM_TYPES_WITH_TYPE_ONLY = new Set<EnumType | undefined>(['asConst', 'asPascalConst', 'literal', undefined] as const)\n","import { camelCase, pascalCase, screamingSnakeCase, snakeCase } from '@internals/utils'\nimport { isNumber, sortBy } from 'remeda'\nimport ts from 'typescript'\n\nconst { SyntaxKind, factory } = ts\n\n// https://ts-ast-viewer.com/\n\nexport const modifiers = {\n async: factory.createModifier(ts.SyntaxKind.AsyncKeyword),\n export: factory.createModifier(ts.SyntaxKind.ExportKeyword),\n const: factory.createModifier(ts.SyntaxKind.ConstKeyword),\n static: factory.createModifier(ts.SyntaxKind.StaticKeyword),\n} as const\n\nexport const syntaxKind = {\n union: SyntaxKind.UnionType as 192,\n literalType: SyntaxKind.LiteralType,\n stringLiteral: SyntaxKind.StringLiteral,\n} as const\n\nfunction isValidIdentifier(str: string): boolean {\n if (!str.length || str.trim() !== str) {\n return false\n }\n const node = ts.parseIsolatedEntityName(str, ts.ScriptTarget.Latest)\n\n return !!node && node.kind === ts.SyntaxKind.Identifier && ts.identifierToKeywordKind(node.kind as unknown as ts.Identifier) === undefined\n}\n\nfunction propertyName(name: string | ts.PropertyName): ts.PropertyName {\n if (typeof name === 'string') {\n const isValid = isValidIdentifier(name)\n return isValid ? factory.createIdentifier(name) : factory.createStringLiteral(name)\n }\n return name\n}\n\nconst questionToken = factory.createToken(ts.SyntaxKind.QuestionToken)\n\nexport function createQuestionToken(token?: boolean | ts.QuestionToken) {\n if (!token) {\n return undefined\n }\n if (token === true) {\n return questionToken\n }\n return token\n}\n\nexport function createIntersectionDeclaration({ nodes, withParentheses }: { nodes: Array<ts.TypeNode>; withParentheses?: boolean }): ts.TypeNode | null {\n if (!nodes.length) {\n return null\n }\n\n if (nodes.length === 1) {\n return nodes[0] || null\n }\n\n const node = factory.createIntersectionTypeNode(nodes)\n\n if (withParentheses) {\n return factory.createParenthesizedType(node)\n }\n\n return node\n}\n\nexport function createArrayDeclaration({ nodes, arrayType = 'array' }: { nodes: Array<ts.TypeNode>; arrayType?: 'array' | 'generic' }): ts.TypeNode | null {\n if (!nodes.length) {\n return factory.createTupleTypeNode([])\n }\n\n if (nodes.length === 1) {\n const node = nodes[0]\n if (!node) {\n return null\n }\n if (arrayType === 'generic') {\n return factory.createTypeReferenceNode(factory.createIdentifier('Array'), [node])\n }\n return factory.createArrayTypeNode(node)\n }\n\n // For union types (multiple nodes), respect arrayType preference\n const unionType = factory.createUnionTypeNode(nodes)\n if (arrayType === 'generic') {\n return factory.createTypeReferenceNode(factory.createIdentifier('Array'), [unionType])\n }\n // For array syntax with unions, we need parentheses: (string | number)[]\n return factory.createArrayTypeNode(factory.createParenthesizedType(unionType))\n}\n\n/**\n * Minimum nodes length of 2\n * @example `string | number`\n */\nexport function createUnionDeclaration({ nodes, withParentheses }: { nodes: Array<ts.TypeNode>; withParentheses?: boolean }): ts.TypeNode {\n if (!nodes.length) {\n return keywordTypeNodes.any\n }\n\n if (nodes.length === 1) {\n return nodes[0] as ts.TypeNode\n }\n\n const node = factory.createUnionTypeNode(nodes)\n\n if (withParentheses) {\n return factory.createParenthesizedType(node)\n }\n\n return node\n}\n\nexport function createPropertySignature({\n readOnly,\n modifiers = [],\n name,\n questionToken,\n type,\n}: {\n readOnly?: boolean\n modifiers?: Array<ts.Modifier>\n name: ts.PropertyName | string\n questionToken?: ts.QuestionToken | boolean\n type?: ts.TypeNode\n}) {\n return factory.createPropertySignature(\n [...modifiers, readOnly ? factory.createToken(ts.SyntaxKind.ReadonlyKeyword) : undefined].filter(Boolean),\n propertyName(name),\n createQuestionToken(questionToken),\n type,\n )\n}\n\nexport function createParameterSignature(\n name: string | ts.BindingName,\n {\n modifiers,\n dotDotDotToken,\n questionToken,\n type,\n initializer,\n }: {\n decorators?: Array<ts.Decorator>\n modifiers?: Array<ts.Modifier>\n dotDotDotToken?: ts.DotDotDotToken\n questionToken?: ts.QuestionToken | boolean\n type?: ts.TypeNode\n initializer?: ts.Expression\n },\n): ts.ParameterDeclaration {\n return factory.createParameterDeclaration(modifiers, dotDotDotToken, name, createQuestionToken(questionToken), type, initializer)\n}\n\nexport function createJSDoc({ comments }: { comments: string[] }) {\n if (!comments.length) {\n return null\n }\n return factory.createJSDocComment(\n factory.createNodeArray(\n comments.map((comment, i) => {\n if (i === comments.length - 1) {\n return factory.createJSDocText(comment)\n }\n\n return factory.createJSDocText(`${comment}\\n`)\n }),\n ),\n )\n}\n\n/**\n * @link https://github.com/microsoft/TypeScript/issues/44151\n */\nexport function appendJSDocToNode<TNode extends ts.Node>({ node, comments }: { node: TNode; comments: Array<string | undefined> }) {\n const filteredComments = comments.filter(Boolean)\n\n if (!filteredComments.length) {\n return node\n }\n\n const text = filteredComments.reduce((acc = '', comment = '') => {\n return `${acc}\\n * ${comment.replaceAll('*/', '*\\\\/')}`\n }, '*')\n\n // Use the node directly instead of spreading to avoid creating Unknown nodes\n // TypeScript's addSyntheticLeadingComment accepts the node as-is\n return ts.addSyntheticLeadingComment(node, ts.SyntaxKind.MultiLineCommentTrivia, `${text || '*'}\\n`, true)\n}\n\nexport function createIndexSignature(\n type: ts.TypeNode,\n {\n modifiers,\n indexName = 'key',\n indexType = factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword),\n }: {\n indexName?: string\n indexType?: ts.TypeNode\n decorators?: Array<ts.Decorator>\n modifiers?: Array<ts.Modifier>\n } = {},\n) {\n return factory.createIndexSignature(modifiers, [createParameterSignature(indexName, { type: indexType })], type)\n}\n\nexport function createTypeAliasDeclaration({\n modifiers,\n name,\n typeParameters,\n type,\n}: {\n modifiers?: Array<ts.Modifier>\n name: string | ts.Identifier\n typeParameters?: Array<ts.TypeParameterDeclaration>\n type: ts.TypeNode\n}) {\n return factory.createTypeAliasDeclaration(modifiers, name, typeParameters, type)\n}\n\nexport function createInterfaceDeclaration({\n modifiers,\n name,\n typeParameters,\n members,\n}: {\n modifiers?: Array<ts.Modifier>\n name: string | ts.Identifier\n typeParameters?: Array<ts.TypeParameterDeclaration>\n members: Array<ts.TypeElement>\n}) {\n return factory.createInterfaceDeclaration(modifiers, name, typeParameters, undefined, members)\n}\n\nexport function createTypeDeclaration({\n syntax,\n isExportable,\n comments,\n name,\n type,\n}: {\n syntax: 'type' | 'interface'\n comments: Array<string | undefined>\n isExportable?: boolean\n name: string | ts.Identifier\n type: ts.TypeNode\n}) {\n if (syntax === 'interface' && 'members' in type) {\n const node = createInterfaceDeclaration({\n members: type.members as Array<ts.TypeElement>,\n modifiers: isExportable ? [modifiers.export] : [],\n name,\n typeParameters: undefined,\n })\n\n return appendJSDocToNode({\n node,\n comments,\n })\n }\n\n const node = createTypeAliasDeclaration({\n type,\n modifiers: isExportable ? [modifiers.export] : [],\n name,\n typeParameters: undefined,\n })\n\n return appendJSDocToNode({\n node,\n comments,\n })\n}\n\nexport function createNamespaceDeclaration({ statements, name }: { name: string; statements: ts.Statement[] }) {\n return factory.createModuleDeclaration(\n [factory.createToken(ts.SyntaxKind.ExportKeyword)],\n factory.createIdentifier(name),\n factory.createModuleBlock(statements),\n ts.NodeFlags.Namespace,\n )\n}\n\n/**\n * In { propertyName: string; name?: string } is `name` being used to make the type more unique when multiple same names are used.\n * @example `import { Pet as Cat } from './Pet'`\n */\nexport function createImportDeclaration({\n name,\n path,\n isTypeOnly = false,\n isNameSpace = false,\n}: {\n name: string | Array<string | { propertyName: string; name?: string }>\n path: string\n isTypeOnly?: boolean\n isNameSpace?: boolean\n}) {\n if (!Array.isArray(name)) {\n let importPropertyName: ts.Identifier | undefined = factory.createIdentifier(name)\n let importName: ts.NamedImportBindings | undefined\n\n if (isNameSpace) {\n importPropertyName = undefined\n importName = factory.createNamespaceImport(factory.createIdentifier(name))\n }\n\n return factory.createImportDeclaration(\n undefined,\n factory.createImportClause(isTypeOnly, importPropertyName, importName),\n factory.createStringLiteral(path),\n undefined,\n )\n }\n\n // Sort the imports alphabetically for consistent output across platforms\n const sortedName = sortBy(name, [(item) => (typeof item === 'object' ? item.propertyName : item), 'asc'])\n\n return factory.createImportDeclaration(\n undefined,\n factory.createImportClause(\n isTypeOnly,\n undefined,\n factory.createNamedImports(\n sortedName.map((item) => {\n if (typeof item === 'object') {\n const obj = item as { propertyName: string; name?: string }\n if (obj.name) {\n return factory.createImportSpecifier(false, factory.createIdentifier(obj.propertyName), factory.createIdentifier(obj.name))\n }\n\n return factory.createImportSpecifier(false, undefined, factory.createIdentifier(obj.propertyName))\n }\n\n return factory.createImportSpecifier(false, undefined, factory.createIdentifier(item))\n }),\n ),\n ),\n factory.createStringLiteral(path),\n undefined,\n )\n}\n\nexport function createExportDeclaration({\n path,\n asAlias,\n isTypeOnly = false,\n name,\n}: {\n path: string\n asAlias?: boolean\n isTypeOnly?: boolean\n name?: string | Array<ts.Identifier | string>\n}) {\n if (name && !Array.isArray(name) && !asAlias) {\n console.warn(`When using name as string, asAlias should be true ${name}`)\n }\n\n if (!Array.isArray(name)) {\n const parsedName = name?.match(/^\\d/) ? `_${name?.slice(1)}` : name\n\n return factory.createExportDeclaration(\n undefined,\n isTypeOnly,\n asAlias && parsedName ? factory.createNamespaceExport(factory.createIdentifier(parsedName)) : undefined,\n factory.createStringLiteral(path),\n undefined,\n )\n }\n\n // Sort the exports alphabetically for consistent output across platforms\n const sortedName = sortBy(name, [(propertyName) => (typeof propertyName === 'string' ? propertyName : propertyName.text), 'asc'])\n\n return factory.createExportDeclaration(\n undefined,\n isTypeOnly,\n factory.createNamedExports(\n sortedName.map((propertyName) => {\n return factory.createExportSpecifier(false, undefined, typeof propertyName === 'string' ? factory.createIdentifier(propertyName) : propertyName)\n }),\n ),\n factory.createStringLiteral(path),\n undefined,\n )\n}\n\n/**\n * Apply casing transformation to enum keys\n */\nfunction applyEnumKeyCasing(key: string, casing: 'screamingSnakeCase' | 'snakeCase' | 'pascalCase' | 'camelCase' | 'none' = 'none'): string {\n if (casing === 'none') {\n return key\n }\n if (casing === 'screamingSnakeCase') {\n return screamingSnakeCase(key)\n }\n if (casing === 'snakeCase') {\n return snakeCase(key)\n }\n if (casing === 'pascalCase') {\n return pascalCase(key)\n }\n if (casing === 'camelCase') {\n return camelCase(key)\n }\n return key\n}\n\nexport function createEnumDeclaration({\n type = 'enum',\n name,\n typeName,\n enums,\n enumKeyCasing = 'none',\n}: {\n /**\n * Choose to use `enum`, `asConst`, `asPascalConst`, `constEnum`, or `literal` for enums.\n * - `enum`: TypeScript enum\n * - `asConst`: const with camelCase name (e.g., `petType`)\n * - `asPascalConst`: const with PascalCase name (e.g., `PetType`)\n * - `constEnum`: const enum\n * - `literal`: literal union type\n * @default `'enum'`\n */\n type?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal' | 'inlineLiteral'\n /**\n * Enum name in camelCase.\n */\n name: string\n /**\n * Enum name in PascalCase.\n */\n typeName: string\n enums: [key: string | number, value: string | number | boolean][]\n /**\n * Choose the casing for enum key names.\n * @default 'none'\n */\n enumKeyCasing?: 'screamingSnakeCase' | 'snakeCase' | 'pascalCase' | 'camelCase' | 'none'\n}): [name: ts.Node | undefined, type: ts.Node] {\n if (type === 'literal' || type === 'inlineLiteral') {\n return [\n undefined,\n factory.createTypeAliasDeclaration(\n [factory.createToken(ts.SyntaxKind.ExportKeyword)],\n factory.createIdentifier(typeName),\n undefined,\n factory.createUnionTypeNode(\n enums\n .map(([_key, value]) => {\n if (isNumber(value)) {\n if (value < 0) {\n return factory.createLiteralTypeNode(\n factory.createPrefixUnaryExpression(ts.SyntaxKind.MinusToken, factory.createNumericLiteral(Math.abs(value))),\n )\n }\n return factory.createLiteralTypeNode(factory.createNumericLiteral(value?.toString()))\n }\n\n if (typeof value === 'boolean') {\n return factory.createLiteralTypeNode(value ? factory.createTrue() : factory.createFalse())\n }\n if (value) {\n return factory.createLiteralTypeNode(factory.createStringLiteral(value.toString()))\n }\n\n return undefined\n })\n .filter(Boolean),\n ),\n ),\n ]\n }\n\n if (type === 'enum' || type === 'constEnum') {\n return [\n undefined,\n factory.createEnumDeclaration(\n [factory.createToken(ts.SyntaxKind.ExportKeyword), type === 'constEnum' ? factory.createToken(ts.SyntaxKind.ConstKeyword) : undefined].filter(Boolean),\n factory.createIdentifier(typeName),\n enums\n .map(([key, value]) => {\n let initializer: ts.Expression = factory.createStringLiteral(value?.toString())\n const isExactNumber = Number.parseInt(value.toString(), 10) === value\n\n if (isExactNumber && isNumber(Number.parseInt(value.toString(), 10))) {\n if ((value as number) < 0) {\n initializer = factory.createPrefixUnaryExpression(ts.SyntaxKind.MinusToken, factory.createNumericLiteral(Math.abs(value as number)))\n } else {\n initializer = factory.createNumericLiteral(value as number)\n }\n }\n\n if (typeof value === 'boolean') {\n initializer = value ? factory.createTrue() : factory.createFalse()\n }\n\n if (isNumber(Number.parseInt(key.toString(), 10))) {\n const casingKey = applyEnumKeyCasing(`${typeName}_${key}`, enumKeyCasing)\n return factory.createEnumMember(propertyName(casingKey), initializer)\n }\n\n if (key) {\n const casingKey = applyEnumKeyCasing(key.toString(), enumKeyCasing)\n return factory.createEnumMember(propertyName(casingKey), initializer)\n }\n\n return undefined\n })\n .filter(Boolean),\n ),\n ]\n }\n\n // used when using `as const` instead of an TypeScript enum.\n // name is already PascalCase for asPascalConst and camelCase for asConst (set in Type.tsx)\n // typeName has the Key suffix for type alias, so we use name for the const identifier\n const identifierName = name\n\n // When there are no enum items (empty or all-null enum), don't generate a runtime const.\n // Return undefined for nameNode so the barrel won't try to export a non-existent symbol.\n // Use `never` as the type alias to keep references valid without creating a broken const.\n if (enums.length === 0) {\n return [\n undefined,\n factory.createTypeAliasDeclaration(\n [factory.createToken(ts.SyntaxKind.ExportKeyword)],\n factory.createIdentifier(typeName),\n undefined,\n factory.createKeywordTypeNode(ts.SyntaxKind.NeverKeyword),\n ),\n ]\n }\n\n return [\n factory.createVariableStatement(\n [factory.createToken(ts.SyntaxKind.ExportKeyword)],\n factory.createVariableDeclarationList(\n [\n factory.createVariableDeclaration(\n factory.createIdentifier(identifierName),\n undefined,\n undefined,\n factory.createAsExpression(\n factory.createObjectLiteralExpression(\n enums\n .map(([key, value]) => {\n let initializer: ts.Expression = factory.createStringLiteral(value?.toString())\n\n if (isNumber(value)) {\n // Error: Negative numbers should be created in combination with createPrefixUnaryExpression factory.\n // The method createNumericLiteral only accepts positive numbers\n // or those combined with createPrefixUnaryExpression.\n // Therefore, we need to ensure that the number is not negative.\n if (value < 0) {\n initializer = factory.createPrefixUnaryExpression(ts.SyntaxKind.MinusToken, factory.createNumericLiteral(Math.abs(value)))\n } else {\n initializer = factory.createNumericLiteral(value)\n }\n }\n\n if (typeof value === 'boolean') {\n initializer = value ? factory.createTrue() : factory.createFalse()\n }\n\n if (key) {\n const casingKey = applyEnumKeyCasing(key.toString(), enumKeyCasing)\n return factory.createPropertyAssignment(propertyName(casingKey), initializer)\n }\n\n return undefined\n })\n .filter(Boolean),\n true,\n ),\n factory.createTypeReferenceNode(factory.createIdentifier('const'), undefined),\n ),\n ),\n ],\n ts.NodeFlags.Const,\n ),\n ),\n factory.createTypeAliasDeclaration(\n [factory.createToken(ts.SyntaxKind.ExportKeyword)],\n factory.createIdentifier(typeName),\n undefined,\n factory.createIndexedAccessTypeNode(\n factory.createParenthesizedType(factory.createTypeQueryNode(factory.createIdentifier(identifierName), undefined)),\n factory.createTypeOperatorNode(ts.SyntaxKind.KeyOfKeyword, factory.createTypeQueryNode(factory.createIdentifier(identifierName), undefined)),\n ),\n ),\n ]\n}\n\nexport function createOmitDeclaration({ keys, type, nonNullable }: { keys: Array<string> | string; type: ts.TypeNode; nonNullable?: boolean }) {\n const node = nonNullable ? factory.createTypeReferenceNode(factory.createIdentifier('NonNullable'), [type]) : type\n\n if (Array.isArray(keys)) {\n return factory.createTypeReferenceNode(factory.createIdentifier('Omit'), [\n node,\n factory.createUnionTypeNode(\n keys.map((key) => {\n return factory.createLiteralTypeNode(factory.createStringLiteral(key))\n }),\n ),\n ])\n }\n\n return factory.createTypeReferenceNode(factory.createIdentifier('Omit'), [node, factory.createLiteralTypeNode(factory.createStringLiteral(keys))])\n}\n\nexport const keywordTypeNodes = {\n any: factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword),\n unknown: factory.createKeywordTypeNode(ts.SyntaxKind.UnknownKeyword),\n void: factory.createKeywordTypeNode(ts.SyntaxKind.VoidKeyword),\n number: factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword),\n integer: factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword),\n bigint: factory.createKeywordTypeNode(ts.SyntaxKind.BigIntKeyword),\n object: factory.createKeywordTypeNode(ts.SyntaxKind.ObjectKeyword),\n string: factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword),\n boolean: factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword),\n undefined: factory.createKeywordTypeNode(ts.SyntaxKind.UndefinedKeyword),\n null: factory.createLiteralTypeNode(factory.createToken(ts.SyntaxKind.NullKeyword)),\n never: factory.createKeywordTypeNode(ts.SyntaxKind.NeverKeyword),\n} as const\n\n/**\n * Converts a path like '/pet/{petId}/uploadImage' to a template literal type\n * like `/pet/${string}/uploadImage`\n */\n/**\n * Converts an OAS-style path (e.g. `/pets/{petId}`) or an Express-style path\n * (e.g. `/pets/:petId`) to a TypeScript template literal type\n * like `` `/pets/${string}` ``.\n */\nexport function createUrlTemplateType(path: string): ts.TypeNode {\n // normalized Express `:param` → OAS `{param}` so a single regex handles both.\n const normalized = path.replace(/:([^/]+)/g, '{$1}')\n\n if (!normalized.includes('{')) {\n return factory.createLiteralTypeNode(factory.createStringLiteral(normalized))\n }\n\n const segments = normalized.split(/(\\{[^}]+\\})/)\n const parts: string[] = []\n const parameterIndices: number[] = []\n\n segments.forEach((segment) => {\n if (segment.startsWith('{') && segment.endsWith('}')) {\n parameterIndices.push(parts.length)\n parts.push(segment)\n } else if (segment) {\n parts.push(segment)\n }\n })\n\n const head = ts.factory.createTemplateHead(parts[0] || '')\n const templateSpans: ts.TemplateLiteralTypeSpan[] = []\n\n parameterIndices.forEach((paramIndex, i) => {\n const isLast = i === parameterIndices.length - 1\n const nextPart = parts[paramIndex + 1] || ''\n const literal = isLast ? ts.factory.createTemplateTail(nextPart) : ts.factory.createTemplateMiddle(nextPart)\n templateSpans.push(ts.factory.createTemplateLiteralTypeSpan(keywordTypeNodes.string, literal))\n })\n\n return ts.factory.createTemplateLiteralType(head, templateSpans)\n}\n\nexport const createTypeLiteralNode = factory.createTypeLiteralNode\n\nexport const createTypeReferenceNode = factory.createTypeReferenceNode\nexport const createNumericLiteral = factory.createNumericLiteral\nexport const createStringLiteral = factory.createStringLiteral\n\nexport const createArrayTypeNode = factory.createArrayTypeNode\nexport const createParenthesizedType = factory.createParenthesizedType\n\nexport const createLiteralTypeNode = factory.createLiteralTypeNode\nexport const createNull = factory.createNull\nexport const createIdentifier = factory.createIdentifier\n\nexport const createOptionalTypeNode = factory.createOptionalTypeNode\nexport const createTupleTypeNode = factory.createTupleTypeNode\nexport const createRestTypeNode = factory.createRestTypeNode\nexport const createTrue = factory.createTrue\nexport const createFalse = factory.createFalse\nexport const createIndexedAccessTypeNode = factory.createIndexedAccessTypeNode\nexport const createTypeOperatorNode = factory.createTypeOperatorNode\nexport const createPrefixUnaryExpression = factory.createPrefixUnaryExpression\n\nexport { SyntaxKind }\n","import { jsStringEscape, stringify } from '@internals/utils'\nimport { isStringType, narrowSchema, schemaTypes } from '@kubb/ast'\nimport type { ArraySchemaNode, SchemaNode } from '@kubb/ast/types'\nimport type { PrinterFactoryOptions } from '@kubb/core'\nimport { definePrinter } from '@kubb/core'\nimport { safePrint } from '@kubb/fabric-core/parsers/typescript'\nimport type ts from 'typescript'\nimport { ENUM_TYPES_WITH_KEY_SUFFIX, OPTIONAL_ADDS_QUESTION_TOKEN, OPTIONAL_ADDS_UNDEFINED } from '../constants.ts'\nimport * as factory from '../factory.ts'\nimport type { PluginTs, ResolverTs } from '../types.ts'\n\ntype TsOptions = {\n /**\n * @default `'questionToken'`\n */\n optionalType: PluginTs['resolvedOptions']['optionalType']\n /**\n * @default `'array'`\n */\n arrayType: PluginTs['resolvedOptions']['arrayType']\n /**\n * @default `'inlineLiteral'`\n */\n enumType: PluginTs['resolvedOptions']['enumType']\n /**\n * Suffix appended to the generated type alias name when `enumType` is `asConst` or `asPascalConst`.\n *\n * @default `'Key'`\n */\n enumTypeSuffix?: PluginTs['resolvedOptions']['enumTypeSuffix']\n /**\n * Controls whether a `type` alias or `interface` declaration is emitted.\n * @default `'type'`\n */\n syntaxType?: PluginTs['resolvedOptions']['syntaxType']\n /**\n * When set, `printer.print(node)` produces a full `type Name = …` declaration.\n * When omitted, `printer.print(node)` returns the raw type node.\n */\n typeName?: string\n\n /**\n * JSDoc `@description` comment added to the generated type or interface declaration.\n */\n description?: string\n /**\n * Property keys to exclude from the generated type via `Omit<Type, Keys>`.\n * Forces type-alias syntax even when `syntaxType` is `'interface'`.\n */\n keysToOmit?: Array<string>\n /**\n * Resolver used to transform raw schema names into valid TypeScript identifiers.\n */\n resolver: ResolverTs\n}\n\n/**\n * TypeScript printer factory options: maps `SchemaNode` → `ts.TypeNode` (raw) or `ts.Node` (full declaration).\n */\ntype TsPrinter = PrinterFactoryOptions<'typescript', TsOptions, ts.TypeNode, string>\n\n/**\n * Converts a primitive const value to a TypeScript literal type node.\n * Handles negative numbers via a prefix unary expression.\n */\nfunction constToTypeNode(value: string | number | boolean, format: 'string' | 'number' | 'boolean'): ts.TypeNode | undefined {\n if (format === 'boolean') {\n return factory.createLiteralTypeNode(value === true ? factory.createTrue() : factory.createFalse())\n }\n if (format === 'number' && typeof value === 'number') {\n if (value < 0) {\n return factory.createLiteralTypeNode(factory.createPrefixUnaryExpression(factory.SyntaxKind.MinusToken, factory.createNumericLiteral(Math.abs(value))))\n }\n return factory.createLiteralTypeNode(factory.createNumericLiteral(value))\n }\n return factory.createLiteralTypeNode(factory.createStringLiteral(String(value)))\n}\n\n/**\n * Returns a `Date` reference type node when `representation` is `'date'`, otherwise falls back to `string`.\n */\nfunction dateOrStringNode(node: { representation?: string }): ts.TypeNode {\n return node.representation === 'date' ? factory.createTypeReferenceNode(factory.createIdentifier('Date')) : factory.keywordTypeNodes.string\n}\n\n/**\n * Maps an array of `SchemaNode`s through the printer, filtering out `null` and `undefined` results.\n */\nfunction buildMemberNodes(members: Array<SchemaNode> | undefined, print: (node: SchemaNode) => ts.TypeNode | null | undefined): Array<ts.TypeNode> {\n return (members ?? []).map(print).filter(Boolean)\n}\n\n/**\n * Builds a TypeScript tuple type node from an array schema's `items`,\n * applying min/max slice and optional/rest element rules.\n */\nfunction buildTupleNode(node: ArraySchemaNode, print: (node: SchemaNode) => ts.TypeNode | null | undefined): ts.TypeNode | undefined {\n let items = (node.items ?? []).map(print).filter(Boolean)\n\n const restNode = node.rest ? (print(node.rest) ?? undefined) : undefined\n const { min, max } = node\n\n if (max !== undefined) {\n items = items.slice(0, max)\n if (items.length < max && restNode) {\n items = [...items, ...Array(max - items.length).fill(restNode)]\n }\n }\n\n if (min !== undefined) {\n items = items.map((item, i) => (i >= min ? factory.createOptionalTypeNode(item) : item))\n }\n\n if (max === undefined && restNode) {\n items.push(factory.createRestTypeNode(factory.createArrayTypeNode(restNode)))\n }\n\n return factory.createTupleTypeNode(items)\n}\n\n/**\n * Applies `nullable` and optional/nullish `| undefined` union modifiers to a property's resolved base type.\n */\nfunction buildPropertyType(schema: SchemaNode, baseType: ts.TypeNode, optionalType: TsOptions['optionalType']): ts.TypeNode {\n const addsUndefined = OPTIONAL_ADDS_UNDEFINED.has(optionalType)\n\n let type = baseType\n\n if (schema.nullable) {\n type = factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.null] })\n }\n\n if ((schema.nullish || schema.optional) && addsUndefined) {\n type = factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.undefined] })\n }\n\n return type\n}\n\n/**\n * Collects JSDoc annotation strings (description, deprecated, min/max, pattern, default, example, type) for a schema node.\n */\nfunction buildPropertyJSDocComments(schema: SchemaNode): Array<string | undefined> {\n const isArray = schema.type === 'array'\n\n return [\n 'description' in schema && schema.description ? `@description ${jsStringEscape(schema.description)}` : undefined,\n 'deprecated' in schema && schema.deprecated ? '@deprecated' : undefined,\n // minItems/maxItems on arrays should not be emitted as @minLength/@maxLength\n !isArray && 'min' in schema && schema.min !== undefined ? `@minLength ${schema.min}` : undefined,\n !isArray && 'max' in schema && schema.max !== undefined ? `@maxLength ${schema.max}` : undefined,\n 'pattern' in schema && schema.pattern ? `@pattern ${schema.pattern}` : undefined,\n 'default' in schema && schema.default !== undefined\n ? `@default ${'primitive' in schema && schema.primitive === 'string' ? stringify(schema.default as string) : schema.default}`\n : undefined,\n 'example' in schema && schema.example !== undefined ? `@example ${schema.example}` : undefined,\n 'primitive' in schema && schema.primitive\n ? [`@type ${schema.primitive || 'unknown'}`, 'optional' in schema && schema.optional ? ' | undefined' : undefined].filter(Boolean).join('')\n : undefined,\n ]\n}\n\n/**\n * Creates TypeScript index signatures for `additionalProperties` and `patternProperties` on an object schema node.\n */\nfunction buildIndexSignatures(\n node: { additionalProperties?: SchemaNode | boolean; patternProperties?: Record<string, SchemaNode> },\n propertyCount: number,\n print: (node: SchemaNode) => ts.TypeNode | null | undefined,\n): Array<ts.TypeElement> {\n const elements: Array<ts.TypeElement> = []\n\n if (node.additionalProperties && node.additionalProperties !== true) {\n const additionalType = print(node.additionalProperties) ?? factory.keywordTypeNodes.unknown\n\n elements.push(factory.createIndexSignature(propertyCount > 0 ? factory.keywordTypeNodes.unknown : additionalType))\n } else if (node.additionalProperties === true) {\n elements.push(factory.createIndexSignature(factory.keywordTypeNodes.unknown))\n }\n\n if (node.patternProperties) {\n const first = Object.values(node.patternProperties)[0]\n if (first) {\n let patternType = print(first) ?? factory.keywordTypeNodes.unknown\n\n if (first.nullable) {\n patternType = factory.createUnionDeclaration({ nodes: [patternType, factory.keywordTypeNodes.null] })\n }\n elements.push(factory.createIndexSignature(patternType))\n }\n }\n\n return elements\n}\n\n/**\n * TypeScript type printer built with `definePrinter`.\n *\n * Converts a `SchemaNode` AST node into a TypeScript AST node:\n * - **`printer.print(node)`** — when `options.typeName` is set, returns a full\n * `type Name = …` or `interface Name { … }` declaration (`ts.Node`).\n * Without `typeName`, returns the raw `ts.TypeNode` for the schema.\n *\n * Dispatches on `node.type` to the appropriate handler in `nodes`. Options are closed\n * over per printer instance, so each call to `printerTs(options)` produces an independent printer.\n *\n * @example Raw type node (no `typeName`)\n * ```ts\n * const printer = printerTs({ optionalType: 'questionToken', arrayType: 'array', enumType: 'inlineLiteral' })\n * const typeNode = printer.print(schemaNode) // ts.TypeNode\n * ```\n *\n * @example Full declaration (with `typeName`)\n * ```ts\n * const printer = printerTs({ optionalType: 'questionToken', arrayType: 'array', enumType: 'inlineLiteral', typeName: 'MyType' })\n * const declaration = printer.print(schemaNode) // ts.TypeAliasDeclaration | ts.InterfaceDeclaration\n * ```\n */\nexport const printerTs = definePrinter<TsPrinter>((options) => {\n const addsUndefined = OPTIONAL_ADDS_UNDEFINED.has(options.optionalType)\n\n return {\n name: 'typescript',\n options,\n nodes: {\n any: () => factory.keywordTypeNodes.any,\n unknown: () => factory.keywordTypeNodes.unknown,\n void: () => factory.keywordTypeNodes.void,\n never: () => factory.keywordTypeNodes.never,\n boolean: () => factory.keywordTypeNodes.boolean,\n null: () => factory.keywordTypeNodes.null,\n blob: () => factory.createTypeReferenceNode('Blob', []),\n string: () => factory.keywordTypeNodes.string,\n uuid: () => factory.keywordTypeNodes.string,\n email: () => factory.keywordTypeNodes.string,\n url: (node) => {\n if (node.path) {\n return factory.createUrlTemplateType(node.path)\n }\n return factory.keywordTypeNodes.string\n },\n datetime: () => factory.keywordTypeNodes.string,\n number: () => factory.keywordTypeNodes.number,\n integer: () => factory.keywordTypeNodes.number,\n bigint: () => factory.keywordTypeNodes.bigint,\n date: dateOrStringNode,\n time: dateOrStringNode,\n ref(node) {\n if (!node.name) {\n return undefined\n }\n // Parser-generated refs (with $ref) carry raw schema names that need resolving.\n // Use the canonical name from the $ref path — node.name may have been overridden\n // (e.g. by single-member allOf flatten using the property-derived child name).\n // Inline refs (without $ref) from utils already carry resolved type names.\n const refName = node.ref ? (node.ref.split('/').at(-1) ?? node.name) : node.name\n const name = node.ref ? this.options.resolver.default(refName, 'type') : refName\n\n return factory.createTypeReferenceNode(name, undefined)\n },\n enum(node) {\n const values = node.namedEnumValues?.map((v) => v.value) ?? node.enumValues ?? []\n\n if (this.options.enumType === 'inlineLiteral' || !node.name) {\n const literalNodes = values\n .filter((v): v is string | number | boolean => v !== null)\n .map((value) => constToTypeNode(value, typeof value as 'string' | 'number' | 'boolean'))\n .filter(Boolean)\n\n return factory.createUnionDeclaration({ withParentheses: true, nodes: literalNodes }) ?? undefined\n }\n\n const resolvedName =\n ENUM_TYPES_WITH_KEY_SUFFIX.has(this.options.enumType) && this.options.enumTypeSuffix\n ? this.options.resolver.resolveEnumKeyTypedName(node as unknown as SchemaNode, this.options.enumTypeSuffix)\n : this.options.resolver.default(node.name, 'type')\n\n return factory.createTypeReferenceNode(resolvedName, undefined)\n },\n union(node) {\n const members = node.members ?? []\n\n const hasStringLiteral = members.some((m) => {\n const enumNode = narrowSchema(m, schemaTypes.enum)\n return enumNode?.primitive === 'string'\n })\n const hasPlainString = members.some((m) => isStringType(m))\n\n if (hasStringLiteral && hasPlainString) {\n const memberNodes = members\n .map((m) => {\n if (isStringType(m)) {\n return factory.createIntersectionDeclaration({\n nodes: [factory.keywordTypeNodes.string, factory.createTypeLiteralNode([])],\n withParentheses: true,\n })\n }\n\n return this.transform(m)\n })\n .filter(Boolean)\n\n return factory.createUnionDeclaration({ withParentheses: true, nodes: memberNodes }) ?? undefined\n }\n\n return factory.createUnionDeclaration({ withParentheses: true, nodes: buildMemberNodes(members, this.transform) }) ?? undefined\n },\n intersection(node) {\n return factory.createIntersectionDeclaration({ withParentheses: true, nodes: buildMemberNodes(node.members, this.transform) }) ?? undefined\n },\n array(node) {\n const itemNodes = (node.items ?? []).map((item) => this.transform(item)).filter(Boolean)\n\n return factory.createArrayDeclaration({ nodes: itemNodes, arrayType: this.options.arrayType }) ?? undefined\n },\n tuple(node) {\n return buildTupleNode(node, this.transform)\n },\n object(node) {\n const { transform, options } = this\n\n const addsQuestionToken = OPTIONAL_ADDS_QUESTION_TOKEN.has(options.optionalType)\n\n const propertyNodes: Array<ts.TypeElement> = node.properties.map((prop) => {\n const baseType = transform(prop.schema) ?? factory.keywordTypeNodes.unknown\n const type = buildPropertyType(prop.schema, baseType, options.optionalType)\n\n const propertyNode = factory.createPropertySignature({\n questionToken: prop.schema.optional || prop.schema.nullish ? addsQuestionToken : false,\n name: prop.name,\n type,\n readOnly: prop.schema.readOnly,\n })\n\n return factory.appendJSDocToNode({ node: propertyNode, comments: buildPropertyJSDocComments(prop.schema) })\n })\n\n const allElements = [...propertyNodes, ...buildIndexSignatures(node, propertyNodes.length, transform)]\n\n if (!allElements.length) {\n return factory.keywordTypeNodes.object\n }\n\n return factory.createTypeLiteralNode(allElements)\n },\n },\n print(node) {\n let type = this.transform(node)\n\n if (!type) {\n return null\n }\n\n // Apply top-level nullable / optional union modifiers.\n if (node.nullable) {\n type = factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.null] })\n }\n\n if ((node.nullish || node.optional) && addsUndefined) {\n type = factory.createUnionDeclaration({ nodes: [type, factory.keywordTypeNodes.undefined] })\n }\n\n // Without typeName, return the type node as-is (no declaration wrapping).\n const { typeName, syntaxType = 'type', description, keysToOmit } = this.options\n if (!typeName) {\n return safePrint(type)\n }\n\n const useTypeGeneration = syntaxType === 'type' || type.kind === factory.syntaxKind.union || !!keysToOmit?.length\n\n const typeNode = factory.createTypeDeclaration({\n name: typeName,\n isExportable: true,\n type: keysToOmit?.length\n ? factory.createOmitDeclaration({\n keys: keysToOmit,\n type,\n nonNullable: true,\n })\n : type,\n syntax: useTypeGeneration ? 'type' : 'interface',\n comments: [\n node?.title ? jsStringEscape(node.title) : undefined,\n description ? `@description ${jsStringEscape(description)}` : undefined,\n node?.deprecated ? '@deprecated' : undefined,\n node && 'min' in node && node.min !== undefined ? `@minLength ${node.min}` : undefined,\n node && 'max' in node && node.max !== undefined ? `@maxLength ${node.max}` : undefined,\n node && 'pattern' in node && node.pattern ? `@pattern ${node.pattern}` : undefined,\n node?.default ? `@default ${node.default}` : undefined,\n node?.example ? `@example ${node.example}` : undefined,\n ],\n })\n\n return safePrint(typeNode)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;;;;AAQA,SAAgB,WAA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AK,QAAQ,KAAA,IAAY,cAAc,KAAK,QAAQ,KAAA;KAC7E,QAAQ,aAAa,QAAQ,KAAK,UAAU,YAAY,KAAK,YAAY,KAAA;KACzE,MAAM,UAAU,YAAY,KAAK,YAAY,KAAA;KAC7C,MAAM,UAAU,YAAY,KAAK,YAAY,KAAA;KAC9C;IACF,CAAC,CAEwB;;EAE7B;EACD"}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import "./chunk--u3MIqq1.js";
|
|
2
|
-
import { i as snakeCase, n as pascalCase, r as screamingSnakeCase, t as camelCase } from "./casing-
|
|
3
|
-
import {
|
|
2
|
+
import { i as snakeCase, n as pascalCase, r as screamingSnakeCase, t as camelCase } from "./casing-BJHFg-zZ.js";
|
|
3
|
+
import { isStringType, narrowSchema, schemaTypes } from "@kubb/ast";
|
|
4
4
|
import { definePrinter } from "@kubb/core";
|
|
5
|
-
import { File } from "@kubb/react-fabric";
|
|
6
5
|
import { safePrint } from "@kubb/fabric-core/parsers/typescript";
|
|
7
6
|
import { isNumber } from "remeda";
|
|
8
7
|
import ts from "typescript";
|
|
9
|
-
import { Fragment, jsx, jsxs } from "@kubb/react-fabric/jsx-runtime";
|
|
10
8
|
//#region ../../internals/utils/src/string.ts
|
|
11
9
|
/**
|
|
12
10
|
* Strips a single matching pair of `"..."`, `'...'`, or `` `...` `` from both ends of `text`.
|
|
@@ -318,7 +316,7 @@ factory.createIndexedAccessTypeNode;
|
|
|
318
316
|
factory.createTypeOperatorNode;
|
|
319
317
|
const createPrefixUnaryExpression = factory.createPrefixUnaryExpression;
|
|
320
318
|
//#endregion
|
|
321
|
-
//#region src/
|
|
319
|
+
//#region src/printers/printerTs.ts
|
|
322
320
|
/**
|
|
323
321
|
* Converts a primitive const value to a TypeScript literal type node.
|
|
324
322
|
* Handles negative numbers via a prefix unary expression.
|
|
@@ -464,8 +462,7 @@ const printerTs = definePrinter((options) => {
|
|
|
464
462
|
withParentheses: true,
|
|
465
463
|
nodes: values.filter((v) => v !== null).map((value) => constToTypeNode(value, typeof value)).filter(Boolean)
|
|
466
464
|
}) ?? void 0;
|
|
467
|
-
|
|
468
|
-
return createTypeReferenceNode(ENUM_TYPES_WITH_KEY_SUFFIX.has(this.options.enumType) ? `${resolvedName}Key` : resolvedName, void 0);
|
|
465
|
+
return createTypeReferenceNode(ENUM_TYPES_WITH_KEY_SUFFIX.has(this.options.enumType) && this.options.enumTypeSuffix ? this.options.resolver.resolveEnumKeyTypedName(node, this.options.enumTypeSuffix) : this.options.resolver.default(node.name, "type"), void 0);
|
|
469
466
|
},
|
|
470
467
|
union(node) {
|
|
471
468
|
const members = node.members ?? [];
|
|
@@ -480,34 +477,34 @@ const printerTs = definePrinter((options) => {
|
|
|
480
477
|
nodes: [keywordTypeNodes.string, createTypeLiteralNode([])],
|
|
481
478
|
withParentheses: true
|
|
482
479
|
});
|
|
483
|
-
return this.
|
|
480
|
+
return this.transform(m);
|
|
484
481
|
}).filter(Boolean)
|
|
485
482
|
}) ?? void 0;
|
|
486
483
|
return createUnionDeclaration({
|
|
487
484
|
withParentheses: true,
|
|
488
|
-
nodes: buildMemberNodes(members, this.
|
|
485
|
+
nodes: buildMemberNodes(members, this.transform)
|
|
489
486
|
}) ?? void 0;
|
|
490
487
|
},
|
|
491
488
|
intersection(node) {
|
|
492
489
|
return createIntersectionDeclaration({
|
|
493
490
|
withParentheses: true,
|
|
494
|
-
nodes: buildMemberNodes(node.members, this.
|
|
491
|
+
nodes: buildMemberNodes(node.members, this.transform)
|
|
495
492
|
}) ?? void 0;
|
|
496
493
|
},
|
|
497
494
|
array(node) {
|
|
498
495
|
return createArrayDeclaration({
|
|
499
|
-
nodes: (node.items ?? []).map((item) => this.
|
|
496
|
+
nodes: (node.items ?? []).map((item) => this.transform(item)).filter(Boolean),
|
|
500
497
|
arrayType: this.options.arrayType
|
|
501
498
|
}) ?? void 0;
|
|
502
499
|
},
|
|
503
500
|
tuple(node) {
|
|
504
|
-
return buildTupleNode(node, this.
|
|
501
|
+
return buildTupleNode(node, this.transform);
|
|
505
502
|
},
|
|
506
503
|
object(node) {
|
|
507
|
-
const {
|
|
504
|
+
const { transform, options } = this;
|
|
508
505
|
const addsQuestionToken = OPTIONAL_ADDS_QUESTION_TOKEN.has(options.optionalType);
|
|
509
506
|
const propertyNodes = node.properties.map((prop) => {
|
|
510
|
-
const baseType =
|
|
507
|
+
const baseType = transform(prop.schema) ?? keywordTypeNodes.unknown;
|
|
511
508
|
const type = buildPropertyType(prop.schema, baseType, options.optionalType);
|
|
512
509
|
return appendJSDocToNode({
|
|
513
510
|
node: createPropertySignature({
|
|
@@ -519,20 +516,20 @@ const printerTs = definePrinter((options) => {
|
|
|
519
516
|
comments: buildPropertyJSDocComments(prop.schema)
|
|
520
517
|
});
|
|
521
518
|
});
|
|
522
|
-
const allElements = [...propertyNodes, ...buildIndexSignatures(node, propertyNodes.length,
|
|
519
|
+
const allElements = [...propertyNodes, ...buildIndexSignatures(node, propertyNodes.length, transform)];
|
|
523
520
|
if (!allElements.length) return keywordTypeNodes.object;
|
|
524
521
|
return createTypeLiteralNode(allElements);
|
|
525
522
|
}
|
|
526
523
|
},
|
|
527
524
|
print(node) {
|
|
528
|
-
let type = this.
|
|
529
|
-
if (!type) return;
|
|
525
|
+
let type = this.transform(node);
|
|
526
|
+
if (!type) return null;
|
|
530
527
|
if (node.nullable) type = createUnionDeclaration({ nodes: [type, keywordTypeNodes.null] });
|
|
531
528
|
if ((node.nullish || node.optional) && addsUndefined) type = createUnionDeclaration({ nodes: [type, keywordTypeNodes.undefined] });
|
|
532
529
|
const { typeName, syntaxType = "type", description, keysToOmit } = this.options;
|
|
533
|
-
if (!typeName) return type;
|
|
530
|
+
if (!typeName) return safePrint(type);
|
|
534
531
|
const useTypeGeneration = syntaxType === "type" || type.kind === syntaxKind.union || !!keysToOmit?.length;
|
|
535
|
-
return createTypeDeclaration({
|
|
532
|
+
return safePrint(createTypeDeclaration({
|
|
536
533
|
name: typeName,
|
|
537
534
|
isExportable: true,
|
|
538
535
|
type: keysToOmit?.length ? createOmitDeclaration({
|
|
@@ -551,121 +548,11 @@ const printerTs = definePrinter((options) => {
|
|
|
551
548
|
node?.default ? `@default ${node.default}` : void 0,
|
|
552
549
|
node?.example ? `@example ${node.example}` : void 0
|
|
553
550
|
]
|
|
554
|
-
});
|
|
551
|
+
}));
|
|
555
552
|
}
|
|
556
553
|
};
|
|
557
554
|
});
|
|
558
555
|
//#endregion
|
|
559
|
-
|
|
560
|
-
/**
|
|
561
|
-
* Resolves the runtime identifier name and the TypeScript type name for an enum schema node.
|
|
562
|
-
*
|
|
563
|
-
* The raw `node.name` may be a YAML key such as `"enumNames.Type"` which is not a
|
|
564
|
-
* valid TypeScript identifier. The resolver normalizes it; for inline enum
|
|
565
|
-
* properties the adapter already emits a PascalCase+suffix name so resolution is typically a no-op.
|
|
566
|
-
*/
|
|
567
|
-
function getEnumNames({ node, enumType, resolver }) {
|
|
568
|
-
const resolved = resolver.default(node.name, "type");
|
|
569
|
-
return {
|
|
570
|
-
enumName: enumType === "asPascalConst" ? resolved : camelCase(node.name),
|
|
571
|
-
typeName: ENUM_TYPES_WITH_KEY_SUFFIX.has(enumType) ? `${resolved}Key` : resolved,
|
|
572
|
-
refName: resolved
|
|
573
|
-
};
|
|
574
|
-
}
|
|
575
|
-
/**
|
|
576
|
-
* Renders the enum declaration(s) for a single named `EnumSchemaNode`.
|
|
577
|
-
*
|
|
578
|
-
* Depending on `enumType` this may emit:
|
|
579
|
-
* - A runtime object (`asConst` / `asPascalConst`) plus a `typeof` type alias
|
|
580
|
-
* - A `const enum` or plain `enum` declaration (`constEnum` / `enum`)
|
|
581
|
-
* - A union literal type alias (`literal`)
|
|
582
|
-
*
|
|
583
|
-
* The emitted `File.Source` nodes carry the resolved names so that the barrel
|
|
584
|
-
* index picks up the correct export identifiers.
|
|
585
|
-
*/
|
|
586
|
-
function Enum({ node, enumType, enumKeyCasing, resolver }) {
|
|
587
|
-
const { enumName, typeName, refName } = getEnumNames({
|
|
588
|
-
node,
|
|
589
|
-
enumType,
|
|
590
|
-
resolver
|
|
591
|
-
});
|
|
592
|
-
const [nameNode, typeNode] = createEnumDeclaration({
|
|
593
|
-
name: enumName,
|
|
594
|
-
typeName,
|
|
595
|
-
enums: node.namedEnumValues?.map((v) => [trimQuotes(v.name.toString()), v.value]) ?? node.enumValues?.filter((v) => v !== null && v !== void 0).map((v) => [trimQuotes(v.toString()), v]) ?? [],
|
|
596
|
-
type: enumType,
|
|
597
|
-
enumKeyCasing
|
|
598
|
-
});
|
|
599
|
-
const needsRefAlias = ENUM_TYPES_WITH_KEY_SUFFIX.has(enumType) && refName !== typeName;
|
|
600
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
601
|
-
nameNode && /* @__PURE__ */ jsx(File.Source, {
|
|
602
|
-
name: enumName,
|
|
603
|
-
isExportable: true,
|
|
604
|
-
isIndexable: true,
|
|
605
|
-
isTypeOnly: false,
|
|
606
|
-
children: safePrint(nameNode)
|
|
607
|
-
}),
|
|
608
|
-
/* @__PURE__ */ jsx(File.Source, {
|
|
609
|
-
name: typeName,
|
|
610
|
-
isIndexable: true,
|
|
611
|
-
isExportable: ENUM_TYPES_WITH_RUNTIME_VALUE.has(enumType),
|
|
612
|
-
isTypeOnly: ENUM_TYPES_WITH_TYPE_ONLY.has(enumType),
|
|
613
|
-
children: safePrint(typeNode)
|
|
614
|
-
}),
|
|
615
|
-
needsRefAlias && /* @__PURE__ */ jsx(File.Source, {
|
|
616
|
-
name: refName,
|
|
617
|
-
isExportable: true,
|
|
618
|
-
isIndexable: true,
|
|
619
|
-
isTypeOnly: true,
|
|
620
|
-
children: `export type ${refName} = ${typeName}`
|
|
621
|
-
})
|
|
622
|
-
] });
|
|
623
|
-
}
|
|
624
|
-
//#endregion
|
|
625
|
-
//#region src/components/Type.tsx
|
|
626
|
-
function Type({ name, typedName, node, keysToOmit, optionalType, arrayType, syntaxType, enumType, enumKeyCasing, description, resolver }) {
|
|
627
|
-
const resolvedDescription = description || node?.description;
|
|
628
|
-
const enumSchemaNodes = collect(node, { schema(n) {
|
|
629
|
-
const enumNode = narrowSchema(n, schemaTypes.enum);
|
|
630
|
-
if (enumNode?.name) return enumNode;
|
|
631
|
-
} });
|
|
632
|
-
const typeNode = printerTs({
|
|
633
|
-
optionalType,
|
|
634
|
-
arrayType,
|
|
635
|
-
enumType,
|
|
636
|
-
typeName: name,
|
|
637
|
-
syntaxType,
|
|
638
|
-
description: resolvedDescription,
|
|
639
|
-
keysToOmit,
|
|
640
|
-
resolver
|
|
641
|
-
}).print(node);
|
|
642
|
-
if (!typeNode) return;
|
|
643
|
-
const enums = [...new Map(enumSchemaNodes.map((n) => [n.name, n])).values()].map((node) => {
|
|
644
|
-
return {
|
|
645
|
-
node,
|
|
646
|
-
...getEnumNames({
|
|
647
|
-
node,
|
|
648
|
-
enumType,
|
|
649
|
-
resolver
|
|
650
|
-
})
|
|
651
|
-
};
|
|
652
|
-
});
|
|
653
|
-
const shouldExportEnums = enumType !== "inlineLiteral";
|
|
654
|
-
const shouldExportType = enumType === "inlineLiteral" || enums.every((item) => item.typeName !== name);
|
|
655
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [shouldExportEnums && enums.map(({ node }) => /* @__PURE__ */ jsx(Enum, {
|
|
656
|
-
node,
|
|
657
|
-
enumType,
|
|
658
|
-
enumKeyCasing,
|
|
659
|
-
resolver
|
|
660
|
-
})), shouldExportType && /* @__PURE__ */ jsx(File.Source, {
|
|
661
|
-
name: typedName,
|
|
662
|
-
isTypeOnly: true,
|
|
663
|
-
isExportable: true,
|
|
664
|
-
isIndexable: true,
|
|
665
|
-
children: safePrint(typeNode)
|
|
666
|
-
})] });
|
|
667
|
-
}
|
|
668
|
-
//#endregion
|
|
669
|
-
export { Enum as n, ENUM_TYPES_WITH_KEY_SUFFIX as r, Type as t };
|
|
556
|
+
export { ENUM_TYPES_WITH_TYPE_ONLY as a, ENUM_TYPES_WITH_RUNTIME_VALUE as i, createEnumDeclaration as n, trimQuotes as o, ENUM_TYPES_WITH_KEY_SUFFIX as r, printerTs as t };
|
|
670
557
|
|
|
671
|
-
//# sourceMappingURL=
|
|
558
|
+
//# sourceMappingURL=printerTs-CMBCOuqd.js.map
|