@kubb/parser-ts 3.16.2 → 3.16.3
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/chunk-Cl8Af3a2.js +11 -0
- package/dist/factory-CTKjALU5.js +254 -0
- package/dist/factory-CTKjALU5.js.map +1 -0
- package/dist/factory-CUjjpSgy.d.ts +230 -0
- package/dist/factory-DeJMlphM.cjs +497 -0
- package/dist/factory-DeJMlphM.cjs.map +1 -0
- package/dist/factory-_F-JTqnG.d.cts +230 -0
- package/dist/factory.cjs +35 -143
- package/dist/factory.d.cts +2 -2
- package/dist/factory.d.ts +2 -2
- package/dist/factory.js +3 -3
- package/dist/index.cjs +55 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -9
- package/dist/index.d.ts +19 -9
- package/dist/index.js +51 -32
- package/dist/index.js.map +1 -1
- package/package.json +11 -15
- package/src/factory.ts +3 -3
- package/dist/chunk-BEHWCDCH.js +0 -461
- package/dist/chunk-BEHWCDCH.js.map +0 -1
- package/dist/chunk-FIHRQE7D.cjs +0 -501
- package/dist/chunk-FIHRQE7D.cjs.map +0 -1
- package/dist/factory-Cn6Avpxk.d.cts +0 -193
- package/dist/factory-Cn6Avpxk.d.ts +0 -193
- package/dist/factory.cjs.map +0 -1
- package/dist/factory.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/factory.ts"],"names":["modifiers","questionToken","node","propertyName"],"mappings":";;;;;;;;;;AAAA,IAAA,eAAA,GAAA;AAAA,QAAA,CAAA,eAAA,EAAA;AAAA,EAAA,iBAAA,EAAA,MAAA,iBAAA;AAAA,EAAA,sBAAA,EAAA,MAAA,sBAAA;AAAA,EAAA,mBAAA,EAAA,MAAA,mBAAA;AAAA,EAAA,qBAAA,EAAA,MAAA,qBAAA;AAAA,EAAA,uBAAA,EAAA,MAAA,uBAAA;AAAA,EAAA,WAAA,EAAA,MAAA,WAAA;AAAA,EAAA,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://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} 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 return isValidIdentifier(name) ? 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\n/**\n * Minimum nodes length of 2\n * @example `string & number`\n */\nexport function createTupleDeclaration({ 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.createTupleTypeNode(nodes)\n\n if (withParentheses) {\n return factory.createParenthesizedType(node)\n }\n\n return node\n}\n\nexport function createArrayDeclaration({ nodes }: { nodes: Array<ts.TypeNode> }): ts.TypeNode | null {\n if (!nodes.length) {\n return factory.createTupleTypeNode([])\n }\n\n if (nodes.length === 1) {\n return factory.createArrayTypeNode(nodes.at(0)!)\n }\n\n return factory.createExpressionWithTypeArguments(factory.createIdentifier('Array'), [factory.createUnionTypeNode(nodes)])\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 // node: {...node}, with that ts.addSyntheticLeadingComment is appending\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 return factory.createImportDeclaration(\n undefined,\n factory.createImportClause(\n isTypeOnly,\n undefined,\n factory.createNamedImports(\n name.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 return factory.createExportDeclaration(\n undefined,\n isTypeOnly,\n factory.createNamedExports(\n name.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\nexport function createEnumDeclaration({\n type = 'enum',\n name,\n typeName,\n enums,\n}: {\n /**\n * @default `'enum'`\n */\n type?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal'\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}): [name: ts.Node | undefined, type: ts.Node] {\n if (type === 'literal') {\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 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()) === value\n\n if (isExactNumber && isNumber(Number.parseInt(value.toString()))) {\n initializer = factory.createNumericLiteral(value as number)\n }\n\n if (typeof value === 'boolean') {\n initializer = value ? factory.createTrue() : factory.createFalse()\n }\n\n if (isNumber(Number.parseInt(key.toString()))) {\n return factory.createEnumMember(factory.createStringLiteral(`${typeName}_${key}`), initializer)\n }\n\n if (key) {\n return factory.createEnumMember(factory.createStringLiteral(`${key}`), 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 const identifierName = type === 'asPascalConst' ? typeName : name\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 return factory.createPropertyAssignment(factory.createStringLiteral(`${key}`), 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 type === 'asPascalConst' ? [] : [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 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} as const\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\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\n"]}
|
package/dist/chunk-FIHRQE7D.cjs
DELETED
|
@@ -1,501 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var remeda = require('remeda');
|
|
4
|
-
var ts = require('typescript');
|
|
5
|
-
|
|
6
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
|
-
|
|
8
|
-
var ts__default = /*#__PURE__*/_interopDefault(ts);
|
|
9
|
-
|
|
10
|
-
var __defProp = Object.defineProperty;
|
|
11
|
-
var __export = (target, all) => {
|
|
12
|
-
for (var name in all)
|
|
13
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
// src/factory.ts
|
|
17
|
-
var factory_exports = {};
|
|
18
|
-
__export(factory_exports, {
|
|
19
|
-
appendJSDocToNode: () => appendJSDocToNode,
|
|
20
|
-
createArrayDeclaration: () => createArrayDeclaration,
|
|
21
|
-
createArrayTypeNode: () => createArrayTypeNode,
|
|
22
|
-
createEnumDeclaration: () => createEnumDeclaration,
|
|
23
|
-
createExportDeclaration: () => createExportDeclaration,
|
|
24
|
-
createFalse: () => createFalse,
|
|
25
|
-
createIdentifier: () => createIdentifier,
|
|
26
|
-
createImportDeclaration: () => createImportDeclaration,
|
|
27
|
-
createIndexSignature: () => createIndexSignature,
|
|
28
|
-
createInterfaceDeclaration: () => createInterfaceDeclaration,
|
|
29
|
-
createIntersectionDeclaration: () => createIntersectionDeclaration,
|
|
30
|
-
createJSDoc: () => createJSDoc,
|
|
31
|
-
createLiteralTypeNode: () => createLiteralTypeNode,
|
|
32
|
-
createNamespaceDeclaration: () => createNamespaceDeclaration,
|
|
33
|
-
createNull: () => createNull,
|
|
34
|
-
createNumericLiteral: () => createNumericLiteral,
|
|
35
|
-
createOmitDeclaration: () => createOmitDeclaration,
|
|
36
|
-
createOptionalTypeNode: () => createOptionalTypeNode,
|
|
37
|
-
createParameterSignature: () => createParameterSignature,
|
|
38
|
-
createPropertySignature: () => createPropertySignature,
|
|
39
|
-
createQuestionToken: () => createQuestionToken,
|
|
40
|
-
createRestTypeNode: () => createRestTypeNode,
|
|
41
|
-
createStringLiteral: () => createStringLiteral,
|
|
42
|
-
createTrue: () => createTrue,
|
|
43
|
-
createTupleDeclaration: () => createTupleDeclaration,
|
|
44
|
-
createTupleTypeNode: () => createTupleTypeNode,
|
|
45
|
-
createTypeAliasDeclaration: () => createTypeAliasDeclaration,
|
|
46
|
-
createTypeDeclaration: () => createTypeDeclaration,
|
|
47
|
-
createTypeLiteralNode: () => createTypeLiteralNode,
|
|
48
|
-
createTypeReferenceNode: () => createTypeReferenceNode,
|
|
49
|
-
createUnionDeclaration: () => createUnionDeclaration,
|
|
50
|
-
keywordTypeNodes: () => keywordTypeNodes,
|
|
51
|
-
modifiers: () => modifiers,
|
|
52
|
-
syntaxKind: () => syntaxKind
|
|
53
|
-
});
|
|
54
|
-
var { SyntaxKind, factory } = ts__default.default;
|
|
55
|
-
var modifiers = {
|
|
56
|
-
async: factory.createModifier(ts__default.default.SyntaxKind.AsyncKeyword),
|
|
57
|
-
export: factory.createModifier(ts__default.default.SyntaxKind.ExportKeyword),
|
|
58
|
-
const: factory.createModifier(ts__default.default.SyntaxKind.ConstKeyword),
|
|
59
|
-
static: factory.createModifier(ts__default.default.SyntaxKind.StaticKeyword)
|
|
60
|
-
};
|
|
61
|
-
var syntaxKind = {
|
|
62
|
-
union: SyntaxKind.UnionType
|
|
63
|
-
};
|
|
64
|
-
function isValidIdentifier(str) {
|
|
65
|
-
if (!str.length || str.trim() !== str) {
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
const node = ts__default.default.parseIsolatedEntityName(str, ts__default.default.ScriptTarget.Latest);
|
|
69
|
-
return !!node && node.kind === ts__default.default.SyntaxKind.Identifier && ts__default.default.identifierToKeywordKind(node.kind) === void 0;
|
|
70
|
-
}
|
|
71
|
-
function propertyName(name) {
|
|
72
|
-
if (typeof name === "string") {
|
|
73
|
-
return isValidIdentifier(name) ? factory.createIdentifier(name) : factory.createStringLiteral(name);
|
|
74
|
-
}
|
|
75
|
-
return name;
|
|
76
|
-
}
|
|
77
|
-
var questionToken = factory.createToken(ts__default.default.SyntaxKind.QuestionToken);
|
|
78
|
-
function createQuestionToken(token) {
|
|
79
|
-
if (!token) {
|
|
80
|
-
return void 0;
|
|
81
|
-
}
|
|
82
|
-
if (token === true) {
|
|
83
|
-
return questionToken;
|
|
84
|
-
}
|
|
85
|
-
return token;
|
|
86
|
-
}
|
|
87
|
-
function createIntersectionDeclaration({ nodes, withParentheses }) {
|
|
88
|
-
if (!nodes.length) {
|
|
89
|
-
return null;
|
|
90
|
-
}
|
|
91
|
-
if (nodes.length === 1) {
|
|
92
|
-
return nodes[0] || null;
|
|
93
|
-
}
|
|
94
|
-
const node = factory.createIntersectionTypeNode(nodes);
|
|
95
|
-
if (withParentheses) {
|
|
96
|
-
return factory.createParenthesizedType(node);
|
|
97
|
-
}
|
|
98
|
-
return node;
|
|
99
|
-
}
|
|
100
|
-
function createTupleDeclaration({ nodes, withParentheses }) {
|
|
101
|
-
if (!nodes.length) {
|
|
102
|
-
return null;
|
|
103
|
-
}
|
|
104
|
-
if (nodes.length === 1) {
|
|
105
|
-
return nodes[0] || null;
|
|
106
|
-
}
|
|
107
|
-
const node = factory.createTupleTypeNode(nodes);
|
|
108
|
-
if (withParentheses) {
|
|
109
|
-
return factory.createParenthesizedType(node);
|
|
110
|
-
}
|
|
111
|
-
return node;
|
|
112
|
-
}
|
|
113
|
-
function createArrayDeclaration({ nodes }) {
|
|
114
|
-
if (!nodes.length) {
|
|
115
|
-
return factory.createTupleTypeNode([]);
|
|
116
|
-
}
|
|
117
|
-
if (nodes.length === 1) {
|
|
118
|
-
return factory.createArrayTypeNode(nodes.at(0));
|
|
119
|
-
}
|
|
120
|
-
return factory.createExpressionWithTypeArguments(factory.createIdentifier("Array"), [factory.createUnionTypeNode(nodes)]);
|
|
121
|
-
}
|
|
122
|
-
function createUnionDeclaration({ nodes, withParentheses }) {
|
|
123
|
-
if (!nodes.length) {
|
|
124
|
-
return keywordTypeNodes.any;
|
|
125
|
-
}
|
|
126
|
-
if (nodes.length === 1) {
|
|
127
|
-
return nodes[0];
|
|
128
|
-
}
|
|
129
|
-
const node = factory.createUnionTypeNode(nodes);
|
|
130
|
-
if (withParentheses) {
|
|
131
|
-
return factory.createParenthesizedType(node);
|
|
132
|
-
}
|
|
133
|
-
return node;
|
|
134
|
-
}
|
|
135
|
-
function createPropertySignature({
|
|
136
|
-
readOnly,
|
|
137
|
-
modifiers: modifiers2 = [],
|
|
138
|
-
name,
|
|
139
|
-
questionToken: questionToken2,
|
|
140
|
-
type
|
|
141
|
-
}) {
|
|
142
|
-
return factory.createPropertySignature(
|
|
143
|
-
[...modifiers2, readOnly ? factory.createToken(ts__default.default.SyntaxKind.ReadonlyKeyword) : void 0].filter(Boolean),
|
|
144
|
-
propertyName(name),
|
|
145
|
-
createQuestionToken(questionToken2),
|
|
146
|
-
type
|
|
147
|
-
);
|
|
148
|
-
}
|
|
149
|
-
function createParameterSignature(name, {
|
|
150
|
-
modifiers: modifiers2,
|
|
151
|
-
dotDotDotToken,
|
|
152
|
-
questionToken: questionToken2,
|
|
153
|
-
type,
|
|
154
|
-
initializer
|
|
155
|
-
}) {
|
|
156
|
-
return factory.createParameterDeclaration(modifiers2, dotDotDotToken, name, createQuestionToken(questionToken2), type, initializer);
|
|
157
|
-
}
|
|
158
|
-
function createJSDoc({ comments }) {
|
|
159
|
-
if (!comments.length) {
|
|
160
|
-
return null;
|
|
161
|
-
}
|
|
162
|
-
return factory.createJSDocComment(
|
|
163
|
-
factory.createNodeArray(
|
|
164
|
-
comments.map((comment, i) => {
|
|
165
|
-
if (i === comments.length - 1) {
|
|
166
|
-
return factory.createJSDocText(comment);
|
|
167
|
-
}
|
|
168
|
-
return factory.createJSDocText(`${comment}
|
|
169
|
-
`);
|
|
170
|
-
})
|
|
171
|
-
)
|
|
172
|
-
);
|
|
173
|
-
}
|
|
174
|
-
function appendJSDocToNode({ node, comments }) {
|
|
175
|
-
const filteredComments = comments.filter(Boolean);
|
|
176
|
-
if (!filteredComments.length) {
|
|
177
|
-
return node;
|
|
178
|
-
}
|
|
179
|
-
const text = filteredComments.reduce((acc = "", comment = "") => {
|
|
180
|
-
return `${acc}
|
|
181
|
-
* ${comment.replaceAll("*/", "*\\/")}`;
|
|
182
|
-
}, "*");
|
|
183
|
-
return ts__default.default.addSyntheticLeadingComment({ ...node }, ts__default.default.SyntaxKind.MultiLineCommentTrivia, `${text || "*"}
|
|
184
|
-
`, true);
|
|
185
|
-
}
|
|
186
|
-
function createIndexSignature(type, {
|
|
187
|
-
modifiers: modifiers2,
|
|
188
|
-
indexName = "key",
|
|
189
|
-
indexType = factory.createKeywordTypeNode(ts__default.default.SyntaxKind.StringKeyword)
|
|
190
|
-
} = {}) {
|
|
191
|
-
return factory.createIndexSignature(modifiers2, [createParameterSignature(indexName, { type: indexType })], type);
|
|
192
|
-
}
|
|
193
|
-
function createTypeAliasDeclaration({
|
|
194
|
-
modifiers: modifiers2,
|
|
195
|
-
name,
|
|
196
|
-
typeParameters,
|
|
197
|
-
type
|
|
198
|
-
}) {
|
|
199
|
-
return factory.createTypeAliasDeclaration(modifiers2, name, typeParameters, type);
|
|
200
|
-
}
|
|
201
|
-
function createInterfaceDeclaration({
|
|
202
|
-
modifiers: modifiers2,
|
|
203
|
-
name,
|
|
204
|
-
typeParameters,
|
|
205
|
-
members
|
|
206
|
-
}) {
|
|
207
|
-
return factory.createInterfaceDeclaration(modifiers2, name, typeParameters, void 0, members);
|
|
208
|
-
}
|
|
209
|
-
function createTypeDeclaration({
|
|
210
|
-
syntax,
|
|
211
|
-
isExportable,
|
|
212
|
-
comments,
|
|
213
|
-
name,
|
|
214
|
-
type
|
|
215
|
-
}) {
|
|
216
|
-
if (syntax === "interface" && "members" in type) {
|
|
217
|
-
const node2 = createInterfaceDeclaration({
|
|
218
|
-
members: type.members,
|
|
219
|
-
modifiers: isExportable ? [modifiers.export] : [],
|
|
220
|
-
name,
|
|
221
|
-
typeParameters: void 0
|
|
222
|
-
});
|
|
223
|
-
return appendJSDocToNode({
|
|
224
|
-
node: node2,
|
|
225
|
-
comments
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
const node = createTypeAliasDeclaration({
|
|
229
|
-
type,
|
|
230
|
-
modifiers: isExportable ? [modifiers.export] : [],
|
|
231
|
-
name,
|
|
232
|
-
typeParameters: void 0
|
|
233
|
-
});
|
|
234
|
-
return appendJSDocToNode({
|
|
235
|
-
node,
|
|
236
|
-
comments
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
function createNamespaceDeclaration({ statements, name }) {
|
|
240
|
-
return factory.createModuleDeclaration(
|
|
241
|
-
[factory.createToken(ts__default.default.SyntaxKind.ExportKeyword)],
|
|
242
|
-
factory.createIdentifier(name),
|
|
243
|
-
factory.createModuleBlock(statements),
|
|
244
|
-
ts__default.default.NodeFlags.Namespace
|
|
245
|
-
);
|
|
246
|
-
}
|
|
247
|
-
function createImportDeclaration({
|
|
248
|
-
name,
|
|
249
|
-
path,
|
|
250
|
-
isTypeOnly = false,
|
|
251
|
-
isNameSpace = false
|
|
252
|
-
}) {
|
|
253
|
-
if (!Array.isArray(name)) {
|
|
254
|
-
let importPropertyName = factory.createIdentifier(name);
|
|
255
|
-
let importName;
|
|
256
|
-
if (isNameSpace) {
|
|
257
|
-
importPropertyName = void 0;
|
|
258
|
-
importName = factory.createNamespaceImport(factory.createIdentifier(name));
|
|
259
|
-
}
|
|
260
|
-
return factory.createImportDeclaration(
|
|
261
|
-
void 0,
|
|
262
|
-
factory.createImportClause(isTypeOnly, importPropertyName, importName),
|
|
263
|
-
factory.createStringLiteral(path),
|
|
264
|
-
void 0
|
|
265
|
-
);
|
|
266
|
-
}
|
|
267
|
-
return factory.createImportDeclaration(
|
|
268
|
-
void 0,
|
|
269
|
-
factory.createImportClause(
|
|
270
|
-
isTypeOnly,
|
|
271
|
-
void 0,
|
|
272
|
-
factory.createNamedImports(
|
|
273
|
-
name.map((item) => {
|
|
274
|
-
if (typeof item === "object") {
|
|
275
|
-
const obj = item;
|
|
276
|
-
if (obj.name) {
|
|
277
|
-
return factory.createImportSpecifier(false, factory.createIdentifier(obj.propertyName), factory.createIdentifier(obj.name));
|
|
278
|
-
}
|
|
279
|
-
return factory.createImportSpecifier(false, void 0, factory.createIdentifier(obj.propertyName));
|
|
280
|
-
}
|
|
281
|
-
return factory.createImportSpecifier(false, void 0, factory.createIdentifier(item));
|
|
282
|
-
})
|
|
283
|
-
)
|
|
284
|
-
),
|
|
285
|
-
factory.createStringLiteral(path),
|
|
286
|
-
void 0
|
|
287
|
-
);
|
|
288
|
-
}
|
|
289
|
-
function createExportDeclaration({
|
|
290
|
-
path,
|
|
291
|
-
asAlias,
|
|
292
|
-
isTypeOnly = false,
|
|
293
|
-
name
|
|
294
|
-
}) {
|
|
295
|
-
if (name && !Array.isArray(name) && !asAlias) {
|
|
296
|
-
console.warn(`When using name as string, asAlias should be true ${name}`);
|
|
297
|
-
}
|
|
298
|
-
if (!Array.isArray(name)) {
|
|
299
|
-
const parsedName = name?.match(/^\d/) ? `_${name?.slice(1)}` : name;
|
|
300
|
-
return factory.createExportDeclaration(
|
|
301
|
-
void 0,
|
|
302
|
-
isTypeOnly,
|
|
303
|
-
asAlias && parsedName ? factory.createNamespaceExport(factory.createIdentifier(parsedName)) : void 0,
|
|
304
|
-
factory.createStringLiteral(path),
|
|
305
|
-
void 0
|
|
306
|
-
);
|
|
307
|
-
}
|
|
308
|
-
return factory.createExportDeclaration(
|
|
309
|
-
void 0,
|
|
310
|
-
isTypeOnly,
|
|
311
|
-
factory.createNamedExports(
|
|
312
|
-
name.map((propertyName2) => {
|
|
313
|
-
return factory.createExportSpecifier(false, void 0, typeof propertyName2 === "string" ? factory.createIdentifier(propertyName2) : propertyName2);
|
|
314
|
-
})
|
|
315
|
-
),
|
|
316
|
-
factory.createStringLiteral(path),
|
|
317
|
-
void 0
|
|
318
|
-
);
|
|
319
|
-
}
|
|
320
|
-
function createEnumDeclaration({
|
|
321
|
-
type = "enum",
|
|
322
|
-
name,
|
|
323
|
-
typeName,
|
|
324
|
-
enums
|
|
325
|
-
}) {
|
|
326
|
-
if (type === "literal") {
|
|
327
|
-
return [
|
|
328
|
-
void 0,
|
|
329
|
-
factory.createTypeAliasDeclaration(
|
|
330
|
-
[factory.createToken(ts__default.default.SyntaxKind.ExportKeyword)],
|
|
331
|
-
factory.createIdentifier(typeName),
|
|
332
|
-
void 0,
|
|
333
|
-
factory.createUnionTypeNode(
|
|
334
|
-
enums.map(([_key, value]) => {
|
|
335
|
-
if (remeda.isNumber(value)) {
|
|
336
|
-
return factory.createLiteralTypeNode(factory.createNumericLiteral(value?.toString()));
|
|
337
|
-
}
|
|
338
|
-
if (typeof value === "boolean") {
|
|
339
|
-
return factory.createLiteralTypeNode(value ? factory.createTrue() : factory.createFalse());
|
|
340
|
-
}
|
|
341
|
-
if (value) {
|
|
342
|
-
return factory.createLiteralTypeNode(factory.createStringLiteral(value.toString()));
|
|
343
|
-
}
|
|
344
|
-
return void 0;
|
|
345
|
-
}).filter(Boolean)
|
|
346
|
-
)
|
|
347
|
-
)
|
|
348
|
-
];
|
|
349
|
-
}
|
|
350
|
-
if (type === "enum" || type === "constEnum") {
|
|
351
|
-
return [
|
|
352
|
-
void 0,
|
|
353
|
-
factory.createEnumDeclaration(
|
|
354
|
-
[factory.createToken(ts__default.default.SyntaxKind.ExportKeyword), type === "constEnum" ? factory.createToken(ts__default.default.SyntaxKind.ConstKeyword) : void 0].filter(Boolean),
|
|
355
|
-
factory.createIdentifier(typeName),
|
|
356
|
-
enums.map(([key, value]) => {
|
|
357
|
-
let initializer = factory.createStringLiteral(value?.toString());
|
|
358
|
-
const isExactNumber = Number.parseInt(value.toString()) === value;
|
|
359
|
-
if (isExactNumber && remeda.isNumber(Number.parseInt(value.toString()))) {
|
|
360
|
-
initializer = factory.createNumericLiteral(value);
|
|
361
|
-
}
|
|
362
|
-
if (typeof value === "boolean") {
|
|
363
|
-
initializer = value ? factory.createTrue() : factory.createFalse();
|
|
364
|
-
}
|
|
365
|
-
if (remeda.isNumber(Number.parseInt(key.toString()))) {
|
|
366
|
-
return factory.createEnumMember(factory.createStringLiteral(`${typeName}_${key}`), initializer);
|
|
367
|
-
}
|
|
368
|
-
if (key) {
|
|
369
|
-
return factory.createEnumMember(factory.createStringLiteral(`${key}`), initializer);
|
|
370
|
-
}
|
|
371
|
-
return void 0;
|
|
372
|
-
}).filter(Boolean)
|
|
373
|
-
)
|
|
374
|
-
];
|
|
375
|
-
}
|
|
376
|
-
const identifierName = type === "asPascalConst" ? typeName : name;
|
|
377
|
-
return [
|
|
378
|
-
factory.createVariableStatement(
|
|
379
|
-
[factory.createToken(ts__default.default.SyntaxKind.ExportKeyword)],
|
|
380
|
-
factory.createVariableDeclarationList(
|
|
381
|
-
[
|
|
382
|
-
factory.createVariableDeclaration(
|
|
383
|
-
factory.createIdentifier(identifierName),
|
|
384
|
-
void 0,
|
|
385
|
-
void 0,
|
|
386
|
-
factory.createAsExpression(
|
|
387
|
-
factory.createObjectLiteralExpression(
|
|
388
|
-
enums.map(([key, value]) => {
|
|
389
|
-
let initializer = factory.createStringLiteral(value?.toString());
|
|
390
|
-
if (remeda.isNumber(value)) {
|
|
391
|
-
if (value < 0) {
|
|
392
|
-
initializer = factory.createPrefixUnaryExpression(ts__default.default.SyntaxKind.MinusToken, factory.createNumericLiteral(Math.abs(value)));
|
|
393
|
-
} else {
|
|
394
|
-
initializer = factory.createNumericLiteral(value);
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
if (typeof value === "boolean") {
|
|
398
|
-
initializer = value ? factory.createTrue() : factory.createFalse();
|
|
399
|
-
}
|
|
400
|
-
if (key) {
|
|
401
|
-
return factory.createPropertyAssignment(factory.createStringLiteral(`${key}`), initializer);
|
|
402
|
-
}
|
|
403
|
-
return void 0;
|
|
404
|
-
}).filter(Boolean),
|
|
405
|
-
true
|
|
406
|
-
),
|
|
407
|
-
factory.createTypeReferenceNode(factory.createIdentifier("const"), void 0)
|
|
408
|
-
)
|
|
409
|
-
)
|
|
410
|
-
],
|
|
411
|
-
ts__default.default.NodeFlags.Const
|
|
412
|
-
)
|
|
413
|
-
),
|
|
414
|
-
factory.createTypeAliasDeclaration(
|
|
415
|
-
type === "asPascalConst" ? [] : [factory.createToken(ts__default.default.SyntaxKind.ExportKeyword)],
|
|
416
|
-
factory.createIdentifier(typeName),
|
|
417
|
-
void 0,
|
|
418
|
-
factory.createIndexedAccessTypeNode(
|
|
419
|
-
factory.createParenthesizedType(factory.createTypeQueryNode(factory.createIdentifier(identifierName), void 0)),
|
|
420
|
-
factory.createTypeOperatorNode(ts__default.default.SyntaxKind.KeyOfKeyword, factory.createTypeQueryNode(factory.createIdentifier(identifierName), void 0))
|
|
421
|
-
)
|
|
422
|
-
)
|
|
423
|
-
];
|
|
424
|
-
}
|
|
425
|
-
function createOmitDeclaration({ keys, type, nonNullable }) {
|
|
426
|
-
const node = nonNullable ? factory.createTypeReferenceNode(factory.createIdentifier("NonNullable"), [type]) : type;
|
|
427
|
-
if (Array.isArray(keys)) {
|
|
428
|
-
return factory.createTypeReferenceNode(factory.createIdentifier("Omit"), [
|
|
429
|
-
node,
|
|
430
|
-
factory.createUnionTypeNode(
|
|
431
|
-
keys.map((key) => {
|
|
432
|
-
return factory.createLiteralTypeNode(factory.createStringLiteral(key));
|
|
433
|
-
})
|
|
434
|
-
)
|
|
435
|
-
]);
|
|
436
|
-
}
|
|
437
|
-
return factory.createTypeReferenceNode(factory.createIdentifier("Omit"), [node, factory.createLiteralTypeNode(factory.createStringLiteral(keys))]);
|
|
438
|
-
}
|
|
439
|
-
var keywordTypeNodes = {
|
|
440
|
-
any: factory.createKeywordTypeNode(ts__default.default.SyntaxKind.AnyKeyword),
|
|
441
|
-
unknown: factory.createKeywordTypeNode(ts__default.default.SyntaxKind.UnknownKeyword),
|
|
442
|
-
void: factory.createKeywordTypeNode(ts__default.default.SyntaxKind.VoidKeyword),
|
|
443
|
-
number: factory.createKeywordTypeNode(ts__default.default.SyntaxKind.NumberKeyword),
|
|
444
|
-
integer: factory.createKeywordTypeNode(ts__default.default.SyntaxKind.NumberKeyword),
|
|
445
|
-
object: factory.createKeywordTypeNode(ts__default.default.SyntaxKind.ObjectKeyword),
|
|
446
|
-
string: factory.createKeywordTypeNode(ts__default.default.SyntaxKind.StringKeyword),
|
|
447
|
-
boolean: factory.createKeywordTypeNode(ts__default.default.SyntaxKind.BooleanKeyword),
|
|
448
|
-
undefined: factory.createKeywordTypeNode(ts__default.default.SyntaxKind.UndefinedKeyword),
|
|
449
|
-
null: factory.createLiteralTypeNode(factory.createToken(ts__default.default.SyntaxKind.NullKeyword))
|
|
450
|
-
};
|
|
451
|
-
var createTypeLiteralNode = factory.createTypeLiteralNode;
|
|
452
|
-
var createTypeReferenceNode = factory.createTypeReferenceNode;
|
|
453
|
-
var createNumericLiteral = factory.createNumericLiteral;
|
|
454
|
-
var createStringLiteral = factory.createStringLiteral;
|
|
455
|
-
var createArrayTypeNode = factory.createArrayTypeNode;
|
|
456
|
-
var createLiteralTypeNode = factory.createLiteralTypeNode;
|
|
457
|
-
var createNull = factory.createNull;
|
|
458
|
-
var createIdentifier = factory.createIdentifier;
|
|
459
|
-
var createOptionalTypeNode = factory.createOptionalTypeNode;
|
|
460
|
-
var createTupleTypeNode = factory.createTupleTypeNode;
|
|
461
|
-
var createRestTypeNode = factory.createRestTypeNode;
|
|
462
|
-
var createTrue = factory.createTrue;
|
|
463
|
-
var createFalse = factory.createFalse;
|
|
464
|
-
|
|
465
|
-
exports.appendJSDocToNode = appendJSDocToNode;
|
|
466
|
-
exports.createArrayDeclaration = createArrayDeclaration;
|
|
467
|
-
exports.createArrayTypeNode = createArrayTypeNode;
|
|
468
|
-
exports.createEnumDeclaration = createEnumDeclaration;
|
|
469
|
-
exports.createExportDeclaration = createExportDeclaration;
|
|
470
|
-
exports.createFalse = createFalse;
|
|
471
|
-
exports.createIdentifier = createIdentifier;
|
|
472
|
-
exports.createImportDeclaration = createImportDeclaration;
|
|
473
|
-
exports.createIndexSignature = createIndexSignature;
|
|
474
|
-
exports.createInterfaceDeclaration = createInterfaceDeclaration;
|
|
475
|
-
exports.createIntersectionDeclaration = createIntersectionDeclaration;
|
|
476
|
-
exports.createJSDoc = createJSDoc;
|
|
477
|
-
exports.createLiteralTypeNode = createLiteralTypeNode;
|
|
478
|
-
exports.createNamespaceDeclaration = createNamespaceDeclaration;
|
|
479
|
-
exports.createNull = createNull;
|
|
480
|
-
exports.createNumericLiteral = createNumericLiteral;
|
|
481
|
-
exports.createOmitDeclaration = createOmitDeclaration;
|
|
482
|
-
exports.createOptionalTypeNode = createOptionalTypeNode;
|
|
483
|
-
exports.createParameterSignature = createParameterSignature;
|
|
484
|
-
exports.createPropertySignature = createPropertySignature;
|
|
485
|
-
exports.createQuestionToken = createQuestionToken;
|
|
486
|
-
exports.createRestTypeNode = createRestTypeNode;
|
|
487
|
-
exports.createStringLiteral = createStringLiteral;
|
|
488
|
-
exports.createTrue = createTrue;
|
|
489
|
-
exports.createTupleDeclaration = createTupleDeclaration;
|
|
490
|
-
exports.createTupleTypeNode = createTupleTypeNode;
|
|
491
|
-
exports.createTypeAliasDeclaration = createTypeAliasDeclaration;
|
|
492
|
-
exports.createTypeDeclaration = createTypeDeclaration;
|
|
493
|
-
exports.createTypeLiteralNode = createTypeLiteralNode;
|
|
494
|
-
exports.createTypeReferenceNode = createTypeReferenceNode;
|
|
495
|
-
exports.createUnionDeclaration = createUnionDeclaration;
|
|
496
|
-
exports.factory_exports = factory_exports;
|
|
497
|
-
exports.keywordTypeNodes = keywordTypeNodes;
|
|
498
|
-
exports.modifiers = modifiers;
|
|
499
|
-
exports.syntaxKind = syntaxKind;
|
|
500
|
-
//# sourceMappingURL=chunk-FIHRQE7D.cjs.map
|
|
501
|
-
//# sourceMappingURL=chunk-FIHRQE7D.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/factory.ts"],"names":["ts","modifiers","questionToken","node","propertyName","isNumber"],"mappings":";;;;;;;;;;;;;;;;AAAA,IAAA,eAAA,GAAA;AAAA,QAAA,CAAA,eAAA,EAAA;AAAA,EAAA,iBAAA,EAAA,MAAA,iBAAA;AAAA,EAAA,sBAAA,EAAA,MAAA,sBAAA;AAAA,EAAA,mBAAA,EAAA,MAAA,mBAAA;AAAA,EAAA,qBAAA,EAAA,MAAA,qBAAA;AAAA,EAAA,uBAAA,EAAA,MAAA,uBAAA;AAAA,EAAA,WAAA,EAAA,MAAA,WAAA;AAAA,EAAA,gBAAA,EAAA,MAAA,gBAAA;AAAA,EAAA,uBAAA,EAAA,MAAA,uBAAA;AAAA,EAAA,oBAAA,EAAA,MAAA,oBAAA;AAAA,EAAA,0BAAA,EAAA,MAAA,0BAAA;AAAA,EAAA,6BAAA,EAAA,MAAA,6BAAA;AAAA,EAAA,WAAA,EAAA,MAAA,WAAA;AAAA,EAAA,qBAAA,EAAA,MAAA,qBAAA;AAAA,EAAA,0BAAA,EAAA,MAAA,0BAAA;AAAA,EAAA,UAAA,EAAA,MAAA,UAAA;AAAA,EAAA,oBAAA,EAAA,MAAA,oBAAA;AAAA,EAAA,qBAAA,EAAA,MAAA,qBAAA;AAAA,EAAA,sBAAA,EAAA,MAAA,sBAAA;AAAA,EAAA,wBAAA,EAAA,MAAA,wBAAA;AAAA,EAAA,u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AAa,CAAA;AAAA,EACjE,OAAS,EAAA,OAAA,CAAQ,qBAAsB,CAAAA,mBAAA,CAAG,WAAW,cAAc,CAAA;AAAA,EACnE,SAAW,EAAA,OAAA,CAAQ,qBAAsB,CAAAA,mBAAA,CAAG,WAAW,gBAAgB,CAAA;AAAA,EACvE,IAAA,EAAM,QAAQ,qBAAsB,CAAA,OAAA,CAAQ,YAAYA,mBAAG,CAAA,UAAA,CAAW,WAAW,CAAC;AACpF;AAEO,IAAM,wBAAwB,OAAQ,CAAA;AAEtC,IAAM,0BAA0B,OAAQ,CAAA;AACxC,IAAM,uBAAuB,OAAQ,CAAA;AACrC,IAAM,sBAAsB,OAAQ,CAAA;AAEpC,IAAM,sBAAsB,OAAQ,CAAA;AAEpC,IAAM,wBAAwB,OAAQ,CAAA;AACtC,IAAM,aAAa,OAAQ,CAAA;AAC3B,IAAM,mBAAmB,OAAQ,CAAA;AAEjC,IAAM,yBAAyB,OAAQ,CAAA;AACvC,IAAM,sBAAsB,OAAQ,CAAA;AACpC,IAAM,qBAAqB,OAAQ,CAAA;AACnC,IAAM,aAAa,OAAQ,CAAA;AAC3B,IAAM,cAAc,OAAQ,CAAA","file":"chunk-FIHRQE7D.cjs","sourcesContent":["import { isNumber } 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} 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 return isValidIdentifier(name) ? 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\n/**\n * Minimum nodes length of 2\n * @example `string & number`\n */\nexport function createTupleDeclaration({ 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.createTupleTypeNode(nodes)\n\n if (withParentheses) {\n return factory.createParenthesizedType(node)\n }\n\n return node\n}\n\nexport function createArrayDeclaration({ nodes }: { nodes: Array<ts.TypeNode> }): ts.TypeNode | null {\n if (!nodes.length) {\n return factory.createTupleTypeNode([])\n }\n\n if (nodes.length === 1) {\n return factory.createArrayTypeNode(nodes.at(0)!)\n }\n\n return factory.createExpressionWithTypeArguments(factory.createIdentifier('Array'), [factory.createUnionTypeNode(nodes)])\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 // node: {...node}, with that ts.addSyntheticLeadingComment is appending\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 return factory.createImportDeclaration(\n undefined,\n factory.createImportClause(\n isTypeOnly,\n undefined,\n factory.createNamedImports(\n name.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 return factory.createExportDeclaration(\n undefined,\n isTypeOnly,\n factory.createNamedExports(\n name.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\nexport function createEnumDeclaration({\n type = 'enum',\n name,\n typeName,\n enums,\n}: {\n /**\n * @default `'enum'`\n */\n type?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal'\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}): [name: ts.Node | undefined, type: ts.Node] {\n if (type === 'literal') {\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 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()) === value\n\n if (isExactNumber && isNumber(Number.parseInt(value.toString()))) {\n initializer = factory.createNumericLiteral(value as number)\n }\n\n if (typeof value === 'boolean') {\n initializer = value ? factory.createTrue() : factory.createFalse()\n }\n\n if (isNumber(Number.parseInt(key.toString()))) {\n return factory.createEnumMember(factory.createStringLiteral(`${typeName}_${key}`), initializer)\n }\n\n if (key) {\n return factory.createEnumMember(factory.createStringLiteral(`${key}`), 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 const identifierName = type === 'asPascalConst' ? typeName : name\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 return factory.createPropertyAssignment(factory.createStringLiteral(`${key}`), 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 type === 'asPascalConst' ? [] : [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 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} as const\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\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\n"]}
|