@kubb/parser-ts 3.2.0 → 3.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import { isNumber } from 'remeda';
2
- import ts from 'typescript';
2
+ import ts, { SyntaxKind } from 'typescript';
3
3
 
4
4
  var __defProp = Object.defineProperty;
5
5
  var __export = (target, all) => {
@@ -19,6 +19,7 @@ __export(factory_exports, {
19
19
  createIdentifier: () => createIdentifier,
20
20
  createImportDeclaration: () => createImportDeclaration,
21
21
  createIndexSignature: () => createIndexSignature,
22
+ createInterfaceDeclaration: () => createInterfaceDeclaration,
22
23
  createIntersectionDeclaration: () => createIntersectionDeclaration,
23
24
  createJSDoc: () => createJSDoc,
24
25
  createLiteralTypeNode: () => createLiteralTypeNode,
@@ -34,11 +35,13 @@ __export(factory_exports, {
34
35
  createTupleDeclaration: () => createTupleDeclaration,
35
36
  createTupleTypeNode: () => createTupleTypeNode,
36
37
  createTypeAliasDeclaration: () => createTypeAliasDeclaration,
38
+ createTypeDeclaration: () => createTypeDeclaration,
37
39
  createTypeLiteralNode: () => createTypeLiteralNode,
38
40
  createTypeReferenceNode: () => createTypeReferenceNode,
39
41
  createUnionDeclaration: () => createUnionDeclaration,
40
42
  keywordTypeNodes: () => keywordTypeNodes,
41
- modifiers: () => modifiers
43
+ modifiers: () => modifiers,
44
+ syntaxKind: () => syntaxKind
42
45
  });
43
46
  var { factory } = ts;
44
47
  var modifiers = {
@@ -47,6 +50,9 @@ var modifiers = {
47
50
  const: factory.createModifier(ts.SyntaxKind.ConstKeyword),
48
51
  static: factory.createModifier(ts.SyntaxKind.StaticKeyword)
49
52
  };
53
+ var syntaxKind = {
54
+ union: SyntaxKind.UnionType
55
+ };
50
56
  function isValidIdentifier(str) {
51
57
  if (!str.length || str.trim() !== str) {
52
58
  return false;
@@ -198,6 +204,44 @@ function createTypeAliasDeclaration({
198
204
  }) {
199
205
  return factory.createTypeAliasDeclaration(modifiers2, name, typeParameters, type);
200
206
  }
207
+ function createInterfaceDeclaration({
208
+ modifiers: modifiers2,
209
+ name,
210
+ typeParameters,
211
+ members
212
+ }) {
213
+ return factory.createInterfaceDeclaration(modifiers2, name, typeParameters, void 0, members);
214
+ }
215
+ function createTypeDeclaration({
216
+ syntax,
217
+ isExportable,
218
+ description,
219
+ name,
220
+ type
221
+ }) {
222
+ if (syntax === "interface" && "members" in type) {
223
+ const node2 = createInterfaceDeclaration({
224
+ members: type.members,
225
+ modifiers: isExportable ? [modifiers.export] : [],
226
+ name,
227
+ typeParameters: void 0
228
+ });
229
+ return appendJSDocToNode({
230
+ node: node2,
231
+ comments: [description ? `@description ${description}` : void 0].filter(Boolean)
232
+ });
233
+ }
234
+ const node = createTypeAliasDeclaration({
235
+ type,
236
+ modifiers: isExportable ? [modifiers.export] : [],
237
+ name,
238
+ typeParameters: void 0
239
+ });
240
+ return appendJSDocToNode({
241
+ node,
242
+ comments: [description ? `@description ${description}` : void 0].filter(Boolean)
243
+ });
244
+ }
201
245
  function createNamespaceDeclaration({
202
246
  statements,
203
247
  name
@@ -427,6 +471,6 @@ var createTupleTypeNode = factory.createTupleTypeNode;
427
471
  var createTrue = factory.createTrue;
428
472
  var createFalse = factory.createFalse;
429
473
 
430
- export { appendJSDocToNode, createArrayDeclaration, createArrayTypeNode, createEnumDeclaration, createExportDeclaration, createFalse, createIdentifier, createImportDeclaration, createIndexSignature, createIntersectionDeclaration, createJSDoc, createLiteralTypeNode, createNamespaceDeclaration, createNull, createNumericLiteral, createOmitDeclaration, createParameterSignature, createPropertySignature, createQuestionToken, createStringLiteral, createTrue, createTupleDeclaration, createTupleTypeNode, createTypeAliasDeclaration, createTypeLiteralNode, createTypeReferenceNode, createUnionDeclaration, factory_exports, keywordTypeNodes, modifiers };
431
- //# sourceMappingURL=chunk-RWXGFVS2.js.map
432
- //# sourceMappingURL=chunk-RWXGFVS2.js.map
474
+ export { appendJSDocToNode, createArrayDeclaration, createArrayTypeNode, createEnumDeclaration, createExportDeclaration, createFalse, createIdentifier, createImportDeclaration, createIndexSignature, createInterfaceDeclaration, createIntersectionDeclaration, createJSDoc, createLiteralTypeNode, createNamespaceDeclaration, createNull, createNumericLiteral, createOmitDeclaration, createParameterSignature, createPropertySignature, createQuestionToken, createStringLiteral, createTrue, createTupleDeclaration, createTupleTypeNode, createTypeAliasDeclaration, createTypeDeclaration, createTypeLiteralNode, createTypeReferenceNode, createUnionDeclaration, factory_exports, keywordTypeNodes, modifiers, syntaxKind };
475
+ //# sourceMappingURL=chunk-3AITTBIG.js.map
476
+ //# sourceMappingURL=chunk-3AITTBIG.js.map
@@ -0,0 +1 @@
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,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,wBAAA,EAAA,MAAA,wBAAA;AAA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AAsB,CAAA,EAAA,CAAG,WAAW,aAAa,CAAA;AAAA,EAClE,MAAQ,EAAA,OAAA,CAAQ,qBAAsB,CAAA,EAAA,CAAG,WAAW,aAAa,CAAA;AAAA,EACjE,MAAQ,EAAA,OAAA,CAAQ,qBAAsB,CAAA,EAAA,CAAG,WAAW,aAAa,CAAA;AAAA,EACjE,OAAS,EAAA,OAAA,CAAQ,qBAAsB,CAAA,EAAA,CAAG,WAAW,cAAc,CAAA;AAAA,EACnE,SAAW,EAAA,OAAA,CAAQ,qBAAsB,CAAA,EAAA,CAAG,WAAW,gBAAgB,CAAA;AAAA,EACvE,IAAA,EAAM,QAAQ,qBAAsB,CAAA,OAAA,CAAQ,YAAY,EAAG,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,sBAAsB,OAAQ,CAAA;AACpC,IAAM,aAAa,OAAQ,CAAA;AAC3B,IAAM,cAAc,OAAQ,CAAA","file":"chunk-3AITTBIG.js","sourcesContent":["import { isNumber } from 'remeda'\nimport ts, { SyntaxKind } from 'typescript'\n\nconst { 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({\n nodes,\n withParentheses,\n}: {\n nodes: Array<ts.TypeNode>\n withParentheses?: boolean\n}): 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({\n nodes,\n withParentheses,\n}: {\n nodes: Array<ts.TypeNode>\n withParentheses?: boolean\n}): 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({\n nodes,\n}: {\n nodes: Array<ts.TypeNode>\n}): 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({\n nodes,\n withParentheses,\n}: {\n nodes: Array<ts.TypeNode>\n withParentheses?: boolean\n}): 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>({\n node,\n comments,\n}: {\n node: TNode\n comments: Array<string | undefined>\n}) {\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 description,\n name,\n type,\n}: {\n syntax: 'type' | 'interface'\n description?: string\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: [description ? `@description ${description}` : undefined].filter(Boolean),\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: [description ? `@description ${description}` : undefined].filter(Boolean),\n })\n}\n\nexport function createNamespaceDeclaration({\n statements,\n name,\n}: {\n name: string\n statements: ts.Statement[]\n}) {\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 = 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\n if (isNumber(Number.parseInt(value.toString()))) {\n initializer = factory.createNumericLiteral(value as number)\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({\n keys,\n type,\n nonNullable,\n}: {\n keys: Array<string> | string\n type: ts.TypeNode\n nonNullable?: boolean\n}) {\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 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 createTupleTypeNode = factory.createTupleTypeNode\nexport const createTrue = factory.createTrue\nexport const createFalse = factory.createFalse\n"]}
@@ -25,6 +25,7 @@ __export(factory_exports, {
25
25
  createIdentifier: () => createIdentifier,
26
26
  createImportDeclaration: () => createImportDeclaration,
27
27
  createIndexSignature: () => createIndexSignature,
28
+ createInterfaceDeclaration: () => createInterfaceDeclaration,
28
29
  createIntersectionDeclaration: () => createIntersectionDeclaration,
29
30
  createJSDoc: () => createJSDoc,
30
31
  createLiteralTypeNode: () => createLiteralTypeNode,
@@ -40,11 +41,13 @@ __export(factory_exports, {
40
41
  createTupleDeclaration: () => createTupleDeclaration,
41
42
  createTupleTypeNode: () => createTupleTypeNode,
42
43
  createTypeAliasDeclaration: () => createTypeAliasDeclaration,
44
+ createTypeDeclaration: () => createTypeDeclaration,
43
45
  createTypeLiteralNode: () => createTypeLiteralNode,
44
46
  createTypeReferenceNode: () => createTypeReferenceNode,
45
47
  createUnionDeclaration: () => createUnionDeclaration,
46
48
  keywordTypeNodes: () => keywordTypeNodes,
47
- modifiers: () => modifiers
49
+ modifiers: () => modifiers,
50
+ syntaxKind: () => syntaxKind
48
51
  });
49
52
  var { factory } = ts__default.default;
50
53
  var modifiers = {
@@ -53,6 +56,9 @@ var modifiers = {
53
56
  const: factory.createModifier(ts__default.default.SyntaxKind.ConstKeyword),
54
57
  static: factory.createModifier(ts__default.default.SyntaxKind.StaticKeyword)
55
58
  };
59
+ var syntaxKind = {
60
+ union: ts.SyntaxKind.UnionType
61
+ };
56
62
  function isValidIdentifier(str) {
57
63
  if (!str.length || str.trim() !== str) {
58
64
  return false;
@@ -204,6 +210,44 @@ function createTypeAliasDeclaration({
204
210
  }) {
205
211
  return factory.createTypeAliasDeclaration(modifiers2, name, typeParameters, type);
206
212
  }
213
+ function createInterfaceDeclaration({
214
+ modifiers: modifiers2,
215
+ name,
216
+ typeParameters,
217
+ members
218
+ }) {
219
+ return factory.createInterfaceDeclaration(modifiers2, name, typeParameters, void 0, members);
220
+ }
221
+ function createTypeDeclaration({
222
+ syntax,
223
+ isExportable,
224
+ description,
225
+ name,
226
+ type
227
+ }) {
228
+ if (syntax === "interface" && "members" in type) {
229
+ const node2 = createInterfaceDeclaration({
230
+ members: type.members,
231
+ modifiers: isExportable ? [modifiers.export] : [],
232
+ name,
233
+ typeParameters: void 0
234
+ });
235
+ return appendJSDocToNode({
236
+ node: node2,
237
+ comments: [description ? `@description ${description}` : void 0].filter(Boolean)
238
+ });
239
+ }
240
+ const node = createTypeAliasDeclaration({
241
+ type,
242
+ modifiers: isExportable ? [modifiers.export] : [],
243
+ name,
244
+ typeParameters: void 0
245
+ });
246
+ return appendJSDocToNode({
247
+ node,
248
+ comments: [description ? `@description ${description}` : void 0].filter(Boolean)
249
+ });
250
+ }
207
251
  function createNamespaceDeclaration({
208
252
  statements,
209
253
  name
@@ -442,6 +486,7 @@ exports.createFalse = createFalse;
442
486
  exports.createIdentifier = createIdentifier;
443
487
  exports.createImportDeclaration = createImportDeclaration;
444
488
  exports.createIndexSignature = createIndexSignature;
489
+ exports.createInterfaceDeclaration = createInterfaceDeclaration;
445
490
  exports.createIntersectionDeclaration = createIntersectionDeclaration;
446
491
  exports.createJSDoc = createJSDoc;
447
492
  exports.createLiteralTypeNode = createLiteralTypeNode;
@@ -457,11 +502,13 @@ exports.createTrue = createTrue;
457
502
  exports.createTupleDeclaration = createTupleDeclaration;
458
503
  exports.createTupleTypeNode = createTupleTypeNode;
459
504
  exports.createTypeAliasDeclaration = createTypeAliasDeclaration;
505
+ exports.createTypeDeclaration = createTypeDeclaration;
460
506
  exports.createTypeLiteralNode = createTypeLiteralNode;
461
507
  exports.createTypeReferenceNode = createTypeReferenceNode;
462
508
  exports.createUnionDeclaration = createUnionDeclaration;
463
509
  exports.factory_exports = factory_exports;
464
510
  exports.keywordTypeNodes = keywordTypeNodes;
465
511
  exports.modifiers = modifiers;
466
- //# sourceMappingURL=chunk-DVADLCYY.cjs.map
467
- //# sourceMappingURL=chunk-DVADLCYY.cjs.map
512
+ exports.syntaxKind = syntaxKind;
513
+ //# sourceMappingURL=chunk-7KMTK5VM.cjs.map
514
+ //# sourceMappingURL=chunk-7KMTK5VM.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/factory.ts"],"names":["ts","SyntaxKind","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,wBAAA,EAAA,MAAA,wBAAA;AAAA,EAAA,uBAAA,EAAA,MAAA,uBAAA;AAAA,EAAA,mBAAA,EAAA,MAAA,mBAAA;AAAA,EAAA,mBAAA,EAAA,MAAA,mBAAA;AAAA,EAAA,UAAA,EAAA,MAAA,UAAA;AAAA,EAAA,sBAAA,EAAA,MAAA,sBAAA;AAAA,EAAA,mBAAA,EAAA,MAAA,mBAAA;AAAA,EAAA,0BAAA,EAAA,MAAA,0BAAA;AAAA,EA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WAAW,aAAa,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,sBAAsB,OAAQ,CAAA;AACpC,IAAM,aAAa,OAAQ,CAAA;AAC3B,IAAM,cAAc,OAAQ,CAAA","file":"chunk-7KMTK5VM.cjs","sourcesContent":["import { isNumber } from 'remeda'\nimport ts, { SyntaxKind } from 'typescript'\n\nconst { 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({\n nodes,\n withParentheses,\n}: {\n nodes: Array<ts.TypeNode>\n withParentheses?: boolean\n}): 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({\n nodes,\n withParentheses,\n}: {\n nodes: Array<ts.TypeNode>\n withParentheses?: boolean\n}): 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({\n nodes,\n}: {\n nodes: Array<ts.TypeNode>\n}): 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({\n nodes,\n withParentheses,\n}: {\n nodes: Array<ts.TypeNode>\n withParentheses?: boolean\n}): 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>({\n node,\n comments,\n}: {\n node: TNode\n comments: Array<string | undefined>\n}) {\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 description,\n name,\n type,\n}: {\n syntax: 'type' | 'interface'\n description?: string\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: [description ? `@description ${description}` : undefined].filter(Boolean),\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: [description ? `@description ${description}` : undefined].filter(Boolean),\n })\n}\n\nexport function createNamespaceDeclaration({\n statements,\n name,\n}: {\n name: string\n statements: ts.Statement[]\n}) {\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 = 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\n if (isNumber(Number.parseInt(value.toString()))) {\n initializer = factory.createNumericLiteral(value as number)\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({\n keys,\n type,\n nonNullable,\n}: {\n keys: Array<string> | string\n type: ts.TypeNode\n nonNullable?: boolean\n}) {\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 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 createTupleTypeNode = factory.createTupleTypeNode\nexport const createTrue = factory.createTrue\nexport const createFalse = factory.createFalse\n"]}
@@ -6,6 +6,9 @@ declare const modifiers: {
6
6
  readonly const: ts.ModifierToken<ts.SyntaxKind.ConstKeyword>;
7
7
  readonly static: ts.ModifierToken<ts.SyntaxKind.StaticKeyword>;
8
8
  };
9
+ declare const syntaxKind: {
10
+ readonly union: 192;
11
+ };
9
12
  declare function createQuestionToken(token?: boolean | ts.QuestionToken): ts.PunctuationToken<ts.SyntaxKind.QuestionToken> | undefined;
10
13
  declare function createIntersectionDeclaration({ nodes, withParentheses, }: {
11
14
  nodes: Array<ts.TypeNode>;
@@ -67,6 +70,19 @@ declare function createTypeAliasDeclaration({ modifiers, name, typeParameters, t
67
70
  typeParameters?: Array<ts.TypeParameterDeclaration>;
68
71
  type: ts.TypeNode;
69
72
  }): ts.TypeAliasDeclaration;
73
+ declare function createInterfaceDeclaration({ modifiers, name, typeParameters, members, }: {
74
+ modifiers?: Array<ts.Modifier>;
75
+ name: string | ts.Identifier;
76
+ typeParameters?: Array<ts.TypeParameterDeclaration>;
77
+ members: Array<ts.TypeElement>;
78
+ }): ts.InterfaceDeclaration;
79
+ declare function createTypeDeclaration({ syntax, isExportable, description, name, type, }: {
80
+ syntax: 'type' | 'interface';
81
+ description?: string;
82
+ isExportable?: boolean;
83
+ name: string | ts.Identifier;
84
+ type: ts.TypeNode;
85
+ }): ts.TypeAliasDeclaration | ts.InterfaceDeclaration;
70
86
  declare function createNamespaceDeclaration({ statements, name, }: {
71
87
  name: string;
72
88
  statements: ts.Statement[];
@@ -142,6 +158,7 @@ declare const factory_createFalse: typeof createFalse;
142
158
  declare const factory_createIdentifier: typeof createIdentifier;
143
159
  declare const factory_createImportDeclaration: typeof createImportDeclaration;
144
160
  declare const factory_createIndexSignature: typeof createIndexSignature;
161
+ declare const factory_createInterfaceDeclaration: typeof createInterfaceDeclaration;
145
162
  declare const factory_createIntersectionDeclaration: typeof createIntersectionDeclaration;
146
163
  declare const factory_createJSDoc: typeof createJSDoc;
147
164
  declare const factory_createLiteralTypeNode: typeof createLiteralTypeNode;
@@ -157,13 +174,15 @@ declare const factory_createTrue: typeof createTrue;
157
174
  declare const factory_createTupleDeclaration: typeof createTupleDeclaration;
158
175
  declare const factory_createTupleTypeNode: typeof createTupleTypeNode;
159
176
  declare const factory_createTypeAliasDeclaration: typeof createTypeAliasDeclaration;
177
+ declare const factory_createTypeDeclaration: typeof createTypeDeclaration;
160
178
  declare const factory_createTypeLiteralNode: typeof createTypeLiteralNode;
161
179
  declare const factory_createTypeReferenceNode: typeof createTypeReferenceNode;
162
180
  declare const factory_createUnionDeclaration: typeof createUnionDeclaration;
163
181
  declare const factory_keywordTypeNodes: typeof keywordTypeNodes;
164
182
  declare const factory_modifiers: typeof modifiers;
183
+ declare const factory_syntaxKind: typeof syntaxKind;
165
184
  declare namespace factory {
166
- export { factory_appendJSDocToNode as appendJSDocToNode, factory_createArrayDeclaration as createArrayDeclaration, factory_createArrayTypeNode as createArrayTypeNode, factory_createEnumDeclaration as createEnumDeclaration, factory_createExportDeclaration as createExportDeclaration, factory_createFalse as createFalse, factory_createIdentifier as createIdentifier, factory_createImportDeclaration as createImportDeclaration, factory_createIndexSignature as createIndexSignature, factory_createIntersectionDeclaration as createIntersectionDeclaration, factory_createJSDoc as createJSDoc, factory_createLiteralTypeNode as createLiteralTypeNode, factory_createNamespaceDeclaration as createNamespaceDeclaration, factory_createNull as createNull, factory_createNumericLiteral as createNumericLiteral, factory_createOmitDeclaration as createOmitDeclaration, factory_createParameterSignature as createParameterSignature, factory_createPropertySignature as createPropertySignature, factory_createQuestionToken as createQuestionToken, factory_createStringLiteral as createStringLiteral, factory_createTrue as createTrue, factory_createTupleDeclaration as createTupleDeclaration, factory_createTupleTypeNode as createTupleTypeNode, factory_createTypeAliasDeclaration as createTypeAliasDeclaration, factory_createTypeLiteralNode as createTypeLiteralNode, factory_createTypeReferenceNode as createTypeReferenceNode, factory_createUnionDeclaration as createUnionDeclaration, factory_keywordTypeNodes as keywordTypeNodes, factory_modifiers as modifiers };
185
+ export { factory_appendJSDocToNode as appendJSDocToNode, factory_createArrayDeclaration as createArrayDeclaration, factory_createArrayTypeNode as createArrayTypeNode, factory_createEnumDeclaration as createEnumDeclaration, factory_createExportDeclaration as createExportDeclaration, factory_createFalse as createFalse, factory_createIdentifier as createIdentifier, factory_createImportDeclaration as createImportDeclaration, factory_createIndexSignature as createIndexSignature, factory_createInterfaceDeclaration as createInterfaceDeclaration, factory_createIntersectionDeclaration as createIntersectionDeclaration, factory_createJSDoc as createJSDoc, factory_createLiteralTypeNode as createLiteralTypeNode, factory_createNamespaceDeclaration as createNamespaceDeclaration, factory_createNull as createNull, factory_createNumericLiteral as createNumericLiteral, factory_createOmitDeclaration as createOmitDeclaration, factory_createParameterSignature as createParameterSignature, factory_createPropertySignature as createPropertySignature, factory_createQuestionToken as createQuestionToken, factory_createStringLiteral as createStringLiteral, factory_createTrue as createTrue, factory_createTupleDeclaration as createTupleDeclaration, factory_createTupleTypeNode as createTupleTypeNode, factory_createTypeAliasDeclaration as createTypeAliasDeclaration, factory_createTypeDeclaration as createTypeDeclaration, factory_createTypeLiteralNode as createTypeLiteralNode, factory_createTypeReferenceNode as createTypeReferenceNode, factory_createUnionDeclaration as createUnionDeclaration, factory_keywordTypeNodes as keywordTypeNodes, factory_modifiers as modifiers, factory_syntaxKind as syntaxKind };
167
186
  }
168
187
 
169
- export { createIdentifier as A, createTupleTypeNode as B, createTrue as C, createFalse as D, createIntersectionDeclaration as a, createTupleDeclaration as b, createQuestionToken as c, createArrayDeclaration as d, createUnionDeclaration as e, factory as f, createPropertySignature as g, createParameterSignature as h, createJSDoc as i, appendJSDocToNode as j, createIndexSignature as k, createTypeAliasDeclaration as l, modifiers as m, createNamespaceDeclaration as n, createImportDeclaration as o, createExportDeclaration as p, createEnumDeclaration as q, createOmitDeclaration as r, keywordTypeNodes as s, createTypeLiteralNode as t, createTypeReferenceNode as u, createNumericLiteral as v, createStringLiteral as w, createArrayTypeNode as x, createLiteralTypeNode as y, createNull as z };
188
+ export { createArrayTypeNode as A, createLiteralTypeNode as B, createNull as C, createIdentifier as D, createTupleTypeNode as E, createTrue as F, createFalse as G, createIntersectionDeclaration as a, createTupleDeclaration as b, createQuestionToken as c, createArrayDeclaration as d, createUnionDeclaration as e, factory as f, createPropertySignature as g, createParameterSignature as h, createJSDoc as i, appendJSDocToNode as j, createIndexSignature as k, createTypeAliasDeclaration as l, modifiers as m, createInterfaceDeclaration as n, createTypeDeclaration as o, createNamespaceDeclaration as p, createImportDeclaration as q, createExportDeclaration as r, syntaxKind as s, createEnumDeclaration as t, createOmitDeclaration as u, keywordTypeNodes as v, createTypeLiteralNode as w, createTypeReferenceNode as x, createNumericLiteral as y, createStringLiteral as z };
@@ -6,6 +6,9 @@ declare const modifiers: {
6
6
  readonly const: ts.ModifierToken<ts.SyntaxKind.ConstKeyword>;
7
7
  readonly static: ts.ModifierToken<ts.SyntaxKind.StaticKeyword>;
8
8
  };
9
+ declare const syntaxKind: {
10
+ readonly union: 192;
11
+ };
9
12
  declare function createQuestionToken(token?: boolean | ts.QuestionToken): ts.PunctuationToken<ts.SyntaxKind.QuestionToken> | undefined;
10
13
  declare function createIntersectionDeclaration({ nodes, withParentheses, }: {
11
14
  nodes: Array<ts.TypeNode>;
@@ -67,6 +70,19 @@ declare function createTypeAliasDeclaration({ modifiers, name, typeParameters, t
67
70
  typeParameters?: Array<ts.TypeParameterDeclaration>;
68
71
  type: ts.TypeNode;
69
72
  }): ts.TypeAliasDeclaration;
73
+ declare function createInterfaceDeclaration({ modifiers, name, typeParameters, members, }: {
74
+ modifiers?: Array<ts.Modifier>;
75
+ name: string | ts.Identifier;
76
+ typeParameters?: Array<ts.TypeParameterDeclaration>;
77
+ members: Array<ts.TypeElement>;
78
+ }): ts.InterfaceDeclaration;
79
+ declare function createTypeDeclaration({ syntax, isExportable, description, name, type, }: {
80
+ syntax: 'type' | 'interface';
81
+ description?: string;
82
+ isExportable?: boolean;
83
+ name: string | ts.Identifier;
84
+ type: ts.TypeNode;
85
+ }): ts.TypeAliasDeclaration | ts.InterfaceDeclaration;
70
86
  declare function createNamespaceDeclaration({ statements, name, }: {
71
87
  name: string;
72
88
  statements: ts.Statement[];
@@ -142,6 +158,7 @@ declare const factory_createFalse: typeof createFalse;
142
158
  declare const factory_createIdentifier: typeof createIdentifier;
143
159
  declare const factory_createImportDeclaration: typeof createImportDeclaration;
144
160
  declare const factory_createIndexSignature: typeof createIndexSignature;
161
+ declare const factory_createInterfaceDeclaration: typeof createInterfaceDeclaration;
145
162
  declare const factory_createIntersectionDeclaration: typeof createIntersectionDeclaration;
146
163
  declare const factory_createJSDoc: typeof createJSDoc;
147
164
  declare const factory_createLiteralTypeNode: typeof createLiteralTypeNode;
@@ -157,13 +174,15 @@ declare const factory_createTrue: typeof createTrue;
157
174
  declare const factory_createTupleDeclaration: typeof createTupleDeclaration;
158
175
  declare const factory_createTupleTypeNode: typeof createTupleTypeNode;
159
176
  declare const factory_createTypeAliasDeclaration: typeof createTypeAliasDeclaration;
177
+ declare const factory_createTypeDeclaration: typeof createTypeDeclaration;
160
178
  declare const factory_createTypeLiteralNode: typeof createTypeLiteralNode;
161
179
  declare const factory_createTypeReferenceNode: typeof createTypeReferenceNode;
162
180
  declare const factory_createUnionDeclaration: typeof createUnionDeclaration;
163
181
  declare const factory_keywordTypeNodes: typeof keywordTypeNodes;
164
182
  declare const factory_modifiers: typeof modifiers;
183
+ declare const factory_syntaxKind: typeof syntaxKind;
165
184
  declare namespace factory {
166
- export { factory_appendJSDocToNode as appendJSDocToNode, factory_createArrayDeclaration as createArrayDeclaration, factory_createArrayTypeNode as createArrayTypeNode, factory_createEnumDeclaration as createEnumDeclaration, factory_createExportDeclaration as createExportDeclaration, factory_createFalse as createFalse, factory_createIdentifier as createIdentifier, factory_createImportDeclaration as createImportDeclaration, factory_createIndexSignature as createIndexSignature, factory_createIntersectionDeclaration as createIntersectionDeclaration, factory_createJSDoc as createJSDoc, factory_createLiteralTypeNode as createLiteralTypeNode, factory_createNamespaceDeclaration as createNamespaceDeclaration, factory_createNull as createNull, factory_createNumericLiteral as createNumericLiteral, factory_createOmitDeclaration as createOmitDeclaration, factory_createParameterSignature as createParameterSignature, factory_createPropertySignature as createPropertySignature, factory_createQuestionToken as createQuestionToken, factory_createStringLiteral as createStringLiteral, factory_createTrue as createTrue, factory_createTupleDeclaration as createTupleDeclaration, factory_createTupleTypeNode as createTupleTypeNode, factory_createTypeAliasDeclaration as createTypeAliasDeclaration, factory_createTypeLiteralNode as createTypeLiteralNode, factory_createTypeReferenceNode as createTypeReferenceNode, factory_createUnionDeclaration as createUnionDeclaration, factory_keywordTypeNodes as keywordTypeNodes, factory_modifiers as modifiers };
185
+ export { factory_appendJSDocToNode as appendJSDocToNode, factory_createArrayDeclaration as createArrayDeclaration, factory_createArrayTypeNode as createArrayTypeNode, factory_createEnumDeclaration as createEnumDeclaration, factory_createExportDeclaration as createExportDeclaration, factory_createFalse as createFalse, factory_createIdentifier as createIdentifier, factory_createImportDeclaration as createImportDeclaration, factory_createIndexSignature as createIndexSignature, factory_createInterfaceDeclaration as createInterfaceDeclaration, factory_createIntersectionDeclaration as createIntersectionDeclaration, factory_createJSDoc as createJSDoc, factory_createLiteralTypeNode as createLiteralTypeNode, factory_createNamespaceDeclaration as createNamespaceDeclaration, factory_createNull as createNull, factory_createNumericLiteral as createNumericLiteral, factory_createOmitDeclaration as createOmitDeclaration, factory_createParameterSignature as createParameterSignature, factory_createPropertySignature as createPropertySignature, factory_createQuestionToken as createQuestionToken, factory_createStringLiteral as createStringLiteral, factory_createTrue as createTrue, factory_createTupleDeclaration as createTupleDeclaration, factory_createTupleTypeNode as createTupleTypeNode, factory_createTypeAliasDeclaration as createTypeAliasDeclaration, factory_createTypeDeclaration as createTypeDeclaration, factory_createTypeLiteralNode as createTypeLiteralNode, factory_createTypeReferenceNode as createTypeReferenceNode, factory_createUnionDeclaration as createUnionDeclaration, factory_keywordTypeNodes as keywordTypeNodes, factory_modifiers as modifiers, factory_syntaxKind as syntaxKind };
167
186
  }
168
187
 
169
- export { createIdentifier as A, createTupleTypeNode as B, createTrue as C, createFalse as D, createIntersectionDeclaration as a, createTupleDeclaration as b, createQuestionToken as c, createArrayDeclaration as d, createUnionDeclaration as e, factory as f, createPropertySignature as g, createParameterSignature as h, createJSDoc as i, appendJSDocToNode as j, createIndexSignature as k, createTypeAliasDeclaration as l, modifiers as m, createNamespaceDeclaration as n, createImportDeclaration as o, createExportDeclaration as p, createEnumDeclaration as q, createOmitDeclaration as r, keywordTypeNodes as s, createTypeLiteralNode as t, createTypeReferenceNode as u, createNumericLiteral as v, createStringLiteral as w, createArrayTypeNode as x, createLiteralTypeNode as y, createNull as z };
188
+ export { createArrayTypeNode as A, createLiteralTypeNode as B, createNull as C, createIdentifier as D, createTupleTypeNode as E, createTrue as F, createFalse as G, createIntersectionDeclaration as a, createTupleDeclaration as b, createQuestionToken as c, createArrayDeclaration as d, createUnionDeclaration as e, factory as f, createPropertySignature as g, createParameterSignature as h, createJSDoc as i, appendJSDocToNode as j, createIndexSignature as k, createTypeAliasDeclaration as l, modifiers as m, createInterfaceDeclaration as n, createTypeDeclaration as o, createNamespaceDeclaration as p, createImportDeclaration as q, createExportDeclaration as r, syntaxKind as s, createEnumDeclaration as t, createOmitDeclaration as u, keywordTypeNodes as v, createTypeLiteralNode as w, createTypeReferenceNode as x, createNumericLiteral as y, createStringLiteral as z };
package/dist/factory.cjs CHANGED
@@ -1,124 +1,136 @@
1
1
  'use strict';
2
2
 
3
- var chunkDVADLCYY_cjs = require('./chunk-DVADLCYY.cjs');
3
+ var chunk7KMTK5VM_cjs = require('./chunk-7KMTK5VM.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "appendJSDocToNode", {
8
8
  enumerable: true,
9
- get: function () { return chunkDVADLCYY_cjs.appendJSDocToNode; }
9
+ get: function () { return chunk7KMTK5VM_cjs.appendJSDocToNode; }
10
10
  });
11
11
  Object.defineProperty(exports, "createArrayDeclaration", {
12
12
  enumerable: true,
13
- get: function () { return chunkDVADLCYY_cjs.createArrayDeclaration; }
13
+ get: function () { return chunk7KMTK5VM_cjs.createArrayDeclaration; }
14
14
  });
15
15
  Object.defineProperty(exports, "createArrayTypeNode", {
16
16
  enumerable: true,
17
- get: function () { return chunkDVADLCYY_cjs.createArrayTypeNode; }
17
+ get: function () { return chunk7KMTK5VM_cjs.createArrayTypeNode; }
18
18
  });
19
19
  Object.defineProperty(exports, "createEnumDeclaration", {
20
20
  enumerable: true,
21
- get: function () { return chunkDVADLCYY_cjs.createEnumDeclaration; }
21
+ get: function () { return chunk7KMTK5VM_cjs.createEnumDeclaration; }
22
22
  });
23
23
  Object.defineProperty(exports, "createExportDeclaration", {
24
24
  enumerable: true,
25
- get: function () { return chunkDVADLCYY_cjs.createExportDeclaration; }
25
+ get: function () { return chunk7KMTK5VM_cjs.createExportDeclaration; }
26
26
  });
27
27
  Object.defineProperty(exports, "createFalse", {
28
28
  enumerable: true,
29
- get: function () { return chunkDVADLCYY_cjs.createFalse; }
29
+ get: function () { return chunk7KMTK5VM_cjs.createFalse; }
30
30
  });
31
31
  Object.defineProperty(exports, "createIdentifier", {
32
32
  enumerable: true,
33
- get: function () { return chunkDVADLCYY_cjs.createIdentifier; }
33
+ get: function () { return chunk7KMTK5VM_cjs.createIdentifier; }
34
34
  });
35
35
  Object.defineProperty(exports, "createImportDeclaration", {
36
36
  enumerable: true,
37
- get: function () { return chunkDVADLCYY_cjs.createImportDeclaration; }
37
+ get: function () { return chunk7KMTK5VM_cjs.createImportDeclaration; }
38
38
  });
39
39
  Object.defineProperty(exports, "createIndexSignature", {
40
40
  enumerable: true,
41
- get: function () { return chunkDVADLCYY_cjs.createIndexSignature; }
41
+ get: function () { return chunk7KMTK5VM_cjs.createIndexSignature; }
42
+ });
43
+ Object.defineProperty(exports, "createInterfaceDeclaration", {
44
+ enumerable: true,
45
+ get: function () { return chunk7KMTK5VM_cjs.createInterfaceDeclaration; }
42
46
  });
43
47
  Object.defineProperty(exports, "createIntersectionDeclaration", {
44
48
  enumerable: true,
45
- get: function () { return chunkDVADLCYY_cjs.createIntersectionDeclaration; }
49
+ get: function () { return chunk7KMTK5VM_cjs.createIntersectionDeclaration; }
46
50
  });
47
51
  Object.defineProperty(exports, "createJSDoc", {
48
52
  enumerable: true,
49
- get: function () { return chunkDVADLCYY_cjs.createJSDoc; }
53
+ get: function () { return chunk7KMTK5VM_cjs.createJSDoc; }
50
54
  });
51
55
  Object.defineProperty(exports, "createLiteralTypeNode", {
52
56
  enumerable: true,
53
- get: function () { return chunkDVADLCYY_cjs.createLiteralTypeNode; }
57
+ get: function () { return chunk7KMTK5VM_cjs.createLiteralTypeNode; }
54
58
  });
55
59
  Object.defineProperty(exports, "createNamespaceDeclaration", {
56
60
  enumerable: true,
57
- get: function () { return chunkDVADLCYY_cjs.createNamespaceDeclaration; }
61
+ get: function () { return chunk7KMTK5VM_cjs.createNamespaceDeclaration; }
58
62
  });
59
63
  Object.defineProperty(exports, "createNull", {
60
64
  enumerable: true,
61
- get: function () { return chunkDVADLCYY_cjs.createNull; }
65
+ get: function () { return chunk7KMTK5VM_cjs.createNull; }
62
66
  });
63
67
  Object.defineProperty(exports, "createNumericLiteral", {
64
68
  enumerable: true,
65
- get: function () { return chunkDVADLCYY_cjs.createNumericLiteral; }
69
+ get: function () { return chunk7KMTK5VM_cjs.createNumericLiteral; }
66
70
  });
67
71
  Object.defineProperty(exports, "createOmitDeclaration", {
68
72
  enumerable: true,
69
- get: function () { return chunkDVADLCYY_cjs.createOmitDeclaration; }
73
+ get: function () { return chunk7KMTK5VM_cjs.createOmitDeclaration; }
70
74
  });
71
75
  Object.defineProperty(exports, "createParameterSignature", {
72
76
  enumerable: true,
73
- get: function () { return chunkDVADLCYY_cjs.createParameterSignature; }
77
+ get: function () { return chunk7KMTK5VM_cjs.createParameterSignature; }
74
78
  });
75
79
  Object.defineProperty(exports, "createPropertySignature", {
76
80
  enumerable: true,
77
- get: function () { return chunkDVADLCYY_cjs.createPropertySignature; }
81
+ get: function () { return chunk7KMTK5VM_cjs.createPropertySignature; }
78
82
  });
79
83
  Object.defineProperty(exports, "createQuestionToken", {
80
84
  enumerable: true,
81
- get: function () { return chunkDVADLCYY_cjs.createQuestionToken; }
85
+ get: function () { return chunk7KMTK5VM_cjs.createQuestionToken; }
82
86
  });
83
87
  Object.defineProperty(exports, "createStringLiteral", {
84
88
  enumerable: true,
85
- get: function () { return chunkDVADLCYY_cjs.createStringLiteral; }
89
+ get: function () { return chunk7KMTK5VM_cjs.createStringLiteral; }
86
90
  });
87
91
  Object.defineProperty(exports, "createTrue", {
88
92
  enumerable: true,
89
- get: function () { return chunkDVADLCYY_cjs.createTrue; }
93
+ get: function () { return chunk7KMTK5VM_cjs.createTrue; }
90
94
  });
91
95
  Object.defineProperty(exports, "createTupleDeclaration", {
92
96
  enumerable: true,
93
- get: function () { return chunkDVADLCYY_cjs.createTupleDeclaration; }
97
+ get: function () { return chunk7KMTK5VM_cjs.createTupleDeclaration; }
94
98
  });
95
99
  Object.defineProperty(exports, "createTupleTypeNode", {
96
100
  enumerable: true,
97
- get: function () { return chunkDVADLCYY_cjs.createTupleTypeNode; }
101
+ get: function () { return chunk7KMTK5VM_cjs.createTupleTypeNode; }
98
102
  });
99
103
  Object.defineProperty(exports, "createTypeAliasDeclaration", {
100
104
  enumerable: true,
101
- get: function () { return chunkDVADLCYY_cjs.createTypeAliasDeclaration; }
105
+ get: function () { return chunk7KMTK5VM_cjs.createTypeAliasDeclaration; }
106
+ });
107
+ Object.defineProperty(exports, "createTypeDeclaration", {
108
+ enumerable: true,
109
+ get: function () { return chunk7KMTK5VM_cjs.createTypeDeclaration; }
102
110
  });
103
111
  Object.defineProperty(exports, "createTypeLiteralNode", {
104
112
  enumerable: true,
105
- get: function () { return chunkDVADLCYY_cjs.createTypeLiteralNode; }
113
+ get: function () { return chunk7KMTK5VM_cjs.createTypeLiteralNode; }
106
114
  });
107
115
  Object.defineProperty(exports, "createTypeReferenceNode", {
108
116
  enumerable: true,
109
- get: function () { return chunkDVADLCYY_cjs.createTypeReferenceNode; }
117
+ get: function () { return chunk7KMTK5VM_cjs.createTypeReferenceNode; }
110
118
  });
111
119
  Object.defineProperty(exports, "createUnionDeclaration", {
112
120
  enumerable: true,
113
- get: function () { return chunkDVADLCYY_cjs.createUnionDeclaration; }
121
+ get: function () { return chunk7KMTK5VM_cjs.createUnionDeclaration; }
114
122
  });
115
123
  Object.defineProperty(exports, "keywordTypeNodes", {
116
124
  enumerable: true,
117
- get: function () { return chunkDVADLCYY_cjs.keywordTypeNodes; }
125
+ get: function () { return chunk7KMTK5VM_cjs.keywordTypeNodes; }
118
126
  });
119
127
  Object.defineProperty(exports, "modifiers", {
120
128
  enumerable: true,
121
- get: function () { return chunkDVADLCYY_cjs.modifiers; }
129
+ get: function () { return chunk7KMTK5VM_cjs.modifiers; }
130
+ });
131
+ Object.defineProperty(exports, "syntaxKind", {
132
+ enumerable: true,
133
+ get: function () { return chunk7KMTK5VM_cjs.syntaxKind; }
122
134
  });
123
135
  //# sourceMappingURL=factory.cjs.map
124
136
  //# sourceMappingURL=factory.cjs.map
@@ -1,2 +1,2 @@
1
1
  import 'typescript';
2
- export { j as appendJSDocToNode, d as createArrayDeclaration, x as createArrayTypeNode, q as createEnumDeclaration, p as createExportDeclaration, D as createFalse, A as createIdentifier, o as createImportDeclaration, k as createIndexSignature, a as createIntersectionDeclaration, i as createJSDoc, y as createLiteralTypeNode, n as createNamespaceDeclaration, z as createNull, v as createNumericLiteral, r as createOmitDeclaration, h as createParameterSignature, g as createPropertySignature, c as createQuestionToken, w as createStringLiteral, C as createTrue, b as createTupleDeclaration, B as createTupleTypeNode, l as createTypeAliasDeclaration, t as createTypeLiteralNode, u as createTypeReferenceNode, e as createUnionDeclaration, s as keywordTypeNodes, m as modifiers } from './factory-1NIBrzkm.cjs';
2
+ export { j as appendJSDocToNode, d as createArrayDeclaration, A as createArrayTypeNode, t as createEnumDeclaration, r as createExportDeclaration, G as createFalse, D as createIdentifier, q as createImportDeclaration, k as createIndexSignature, n as createInterfaceDeclaration, a as createIntersectionDeclaration, i as createJSDoc, B as createLiteralTypeNode, p as createNamespaceDeclaration, C as createNull, y as createNumericLiteral, u as createOmitDeclaration, h as createParameterSignature, g as createPropertySignature, c as createQuestionToken, z as createStringLiteral, F as createTrue, b as createTupleDeclaration, E as createTupleTypeNode, l as createTypeAliasDeclaration, o as createTypeDeclaration, w as createTypeLiteralNode, x as createTypeReferenceNode, e as createUnionDeclaration, v as keywordTypeNodes, m as modifiers, s as syntaxKind } from './factory-BbbhTZjP.cjs';
package/dist/factory.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  import 'typescript';
2
- export { j as appendJSDocToNode, d as createArrayDeclaration, x as createArrayTypeNode, q as createEnumDeclaration, p as createExportDeclaration, D as createFalse, A as createIdentifier, o as createImportDeclaration, k as createIndexSignature, a as createIntersectionDeclaration, i as createJSDoc, y as createLiteralTypeNode, n as createNamespaceDeclaration, z as createNull, v as createNumericLiteral, r as createOmitDeclaration, h as createParameterSignature, g as createPropertySignature, c as createQuestionToken, w as createStringLiteral, C as createTrue, b as createTupleDeclaration, B as createTupleTypeNode, l as createTypeAliasDeclaration, t as createTypeLiteralNode, u as createTypeReferenceNode, e as createUnionDeclaration, s as keywordTypeNodes, m as modifiers } from './factory-1NIBrzkm.js';
2
+ export { j as appendJSDocToNode, d as createArrayDeclaration, A as createArrayTypeNode, t as createEnumDeclaration, r as createExportDeclaration, G as createFalse, D as createIdentifier, q as createImportDeclaration, k as createIndexSignature, n as createInterfaceDeclaration, a as createIntersectionDeclaration, i as createJSDoc, B as createLiteralTypeNode, p as createNamespaceDeclaration, C as createNull, y as createNumericLiteral, u as createOmitDeclaration, h as createParameterSignature, g as createPropertySignature, c as createQuestionToken, z as createStringLiteral, F as createTrue, b as createTupleDeclaration, E as createTupleTypeNode, l as createTypeAliasDeclaration, o as createTypeDeclaration, w as createTypeLiteralNode, x as createTypeReferenceNode, e as createUnionDeclaration, v as keywordTypeNodes, m as modifiers, s as syntaxKind } from './factory-BbbhTZjP.js';
package/dist/factory.js CHANGED
@@ -1,3 +1,3 @@
1
- export { appendJSDocToNode, createArrayDeclaration, createArrayTypeNode, createEnumDeclaration, createExportDeclaration, createFalse, createIdentifier, createImportDeclaration, createIndexSignature, createIntersectionDeclaration, createJSDoc, createLiteralTypeNode, createNamespaceDeclaration, createNull, createNumericLiteral, createOmitDeclaration, createParameterSignature, createPropertySignature, createQuestionToken, createStringLiteral, createTrue, createTupleDeclaration, createTupleTypeNode, createTypeAliasDeclaration, createTypeLiteralNode, createTypeReferenceNode, createUnionDeclaration, keywordTypeNodes, modifiers } from './chunk-RWXGFVS2.js';
1
+ export { appendJSDocToNode, createArrayDeclaration, createArrayTypeNode, createEnumDeclaration, createExportDeclaration, createFalse, createIdentifier, createImportDeclaration, createIndexSignature, createInterfaceDeclaration, createIntersectionDeclaration, createJSDoc, createLiteralTypeNode, createNamespaceDeclaration, createNull, createNumericLiteral, createOmitDeclaration, createParameterSignature, createPropertySignature, createQuestionToken, createStringLiteral, createTrue, createTupleDeclaration, createTupleTypeNode, createTypeAliasDeclaration, createTypeDeclaration, createTypeLiteralNode, createTypeReferenceNode, createUnionDeclaration, keywordTypeNodes, modifiers, syntaxKind } from './chunk-3AITTBIG.js';
2
2
  //# sourceMappingURL=factory.js.map
3
3
  //# sourceMappingURL=factory.js.map
package/dist/index.cjs CHANGED
@@ -1,11 +1,14 @@
1
1
  'use strict';
2
2
 
3
- var chunkDVADLCYY_cjs = require('./chunk-DVADLCYY.cjs');
3
+ var chunk7KMTK5VM_cjs = require('./chunk-7KMTK5VM.cjs');
4
4
  var ts = require('typescript');
5
+ var prettier = require('prettier');
6
+ var pluginTypescript = require('prettier/plugins/typescript');
5
7
 
6
8
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
9
 
8
10
  var ts__default = /*#__PURE__*/_interopDefault(ts);
11
+ var pluginTypescript__default = /*#__PURE__*/_interopDefault(pluginTypescript);
9
12
 
10
13
  var { factory } = ts__default.default;
11
14
  var escapeNewLines = (code) => code.replace(/\n\n/g, "\n/* :newline: */");
@@ -31,15 +34,26 @@ function print(elements, { source = "", baseName = "print.ts", removeComments, n
31
34
  const outputSource = printer.printFile(sourceFile);
32
35
  return [outputFile, restoreNewLines(outputSource)].filter(Boolean).join("\n");
33
36
  }
34
-
35
- // src/format.ts
36
- function format(source, options = {}) {
37
- return print([], { source, noEmitHelpers: false, ...options });
37
+ var formatOptions = {
38
+ tabWidth: 2,
39
+ printWidth: 160,
40
+ parser: "typescript",
41
+ singleQuote: true,
42
+ semi: false,
43
+ bracketSameLine: false,
44
+ endOfLine: "auto",
45
+ plugins: [pluginTypescript__default.default]
46
+ };
47
+ async function format(source) {
48
+ if (!source) {
49
+ return "";
50
+ }
51
+ return prettier.format(source, formatOptions);
38
52
  }
39
53
 
40
54
  Object.defineProperty(exports, "factory", {
41
55
  enumerable: true,
42
- get: function () { return chunkDVADLCYY_cjs.factory_exports; }
56
+ get: function () { return chunk7KMTK5VM_cjs.factory_exports; }
43
57
  });
44
58
  exports.format = format;
45
59
  exports.print = print;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/print.ts","../src/format.ts"],"names":["ts"],"mappings":";;;;;;;;;AAIA,IAAM,EAAE,SAAY,GAAAA,mBAAA;AAapB,IAAM,iBAAiB,CAAC,IAAA,KAAiB,IAAK,CAAA,OAAA,CAAQ,SAAS,mBAAmB,CAAA;AAOlF,IAAM,kBAAkB,CAAC,IAAA,KAAiB,IAAK,CAAA,OAAA,CAAQ,wBAAwB,IAAI,CAAA;AAK5E,SAAS,MACd,QACA,EAAA,EAAE,SAAS,EAAI,EAAA,QAAA,GAAW,YAAY,cAAgB,EAAA,aAAA,EAAe,UAAUA,mBAAG,CAAA,WAAA,CAAY,UAAU,UAAa,GAAAA,mBAAA,CAAG,WAAW,EAAG,EAAA,GAAkB,EAChJ,EAAA;AACR,EAAM,MAAA,UAAA,GAAaA,mBAAG,CAAA,gBAAA,CAAiB,QAAU,EAAA,cAAA,CAAe,MAAM,CAAA,EAAGA,mBAAG,CAAA,YAAA,CAAa,MAAQ,EAAA,KAAA,EAAO,UAAU,CAAA;AAClH,EAAM,MAAA,OAAA,GAAUA,oBAAG,aAAc,CAAA;AAAA,IAC/B,qBAAuB,EAAA,IAAA;AAAA,IACvB,OAAA;AAAA,IACA,cAAA;AAAA,IACA;AAAA,GACD,CAAA;AAED,EAAA,IAAI,QAAwB,EAAC;AAE7B,EAAA,IAAI,CAAC,QAAU,EAAA;AACb,IAAO,OAAA,EAAA;AAAA;AAGT,EAAI,IAAA,KAAA,CAAM,OAAQ,CAAA,QAAQ,CAAG,EAAA;AAC3B,IAAQ,KAAA,GAAA,QAAA,CAAS,OAAO,OAAO,CAAA;AAAA,GAC1B,MAAA;AACL,IAAA,KAAA,GAAQ,CAAC,QAAQ,CAAE,CAAA,MAAA,CAAO,OAAO,CAAA;AAAA;AAGnC,EAAM,MAAA,UAAA,GAAa,OAAQ,CAAA,SAAA,CAAUA,mBAAG,CAAA,UAAA,CAAW,WAAW,OAAQ,CAAA,eAAA,CAAgB,KAAK,CAAA,EAAG,UAAU,CAAA;AACxG,EAAM,MAAA,YAAA,GAAe,OAAQ,CAAA,SAAA,CAAU,UAAU,CAAA;AAEjD,EAAO,OAAA,CAAC,UAAY,EAAA,eAAA,CAAgB,YAAY,CAAC,EAAE,MAAO,CAAA,OAAO,CAAE,CAAA,IAAA,CAAK,IAAI,CAAA;AAC9E;;;ACpDO,SAAS,MAAO,CAAA,MAAA,EAAgB,OAAwC,GAAA,EAAI,EAAA;AAEjF,EAAO,OAAA,KAAA,CAAM,EAAI,EAAA,EAAE,QAAQ,aAAe,EAAA,KAAA,EAAO,GAAG,OAAA,EAAS,CAAA;AAC/D","file":"index.cjs","sourcesContent":["import ts, { LanguageVariant } from 'typescript'\n\nimport type { PrinterOptions } from 'typescript'\n\nconst { factory } = ts\n\nexport type PrintOptions = {\n source?: string\n baseName?: string\n scriptKind?: ts.ScriptKind\n} & PrinterOptions\n\n/**\n * Escaped new lines in code with block comments so they can be restored by {@link restoreNewLines}\n * @param {string} code The code to escape new lines in\n * @returns The same code but with new lines escaped using block comments\n */\nconst escapeNewLines = (code: string) => code.replace(/\\n\\n/g, '\\n/* :newline: */')\n\n/**\n * Reverses {@link escapeNewLines} and restores new lines\n * @param {string} code The code with escaped new lines\n * @returns The same code with new lines restored\n */\nconst restoreNewLines = (code: string) => code.replace(/\\/\\* :newline: \\*\\//g, '\\n')\n\n/**\n * Convert AST TypeScript nodes to a string based on the TypeScript printer.\n */\nexport function print(\n elements: Array<ts.Node>,\n { source = '', baseName = 'print.ts', removeComments, noEmitHelpers, newLine = ts.NewLineKind.LineFeed, scriptKind = ts.ScriptKind.TS }: PrintOptions = {},\n): string {\n const sourceFile = ts.createSourceFile(baseName, escapeNewLines(source), ts.ScriptTarget.ES2022, false, scriptKind)\n const printer = ts.createPrinter({\n omitTrailingSemicolon: true,\n newLine,\n removeComments,\n noEmitHelpers,\n })\n\n let nodes: Array<ts.Node> = []\n\n if (!elements) {\n return ''\n }\n\n if (Array.isArray(elements)) {\n nodes = elements.filter(Boolean)\n } else {\n nodes = [elements].filter(Boolean)\n }\n\n const outputFile = printer.printList(ts.ListFormat.MultiLine, factory.createNodeArray(nodes), sourceFile)\n const outputSource = printer.printFile(sourceFile)\n\n return [outputFile, restoreNewLines(outputSource)].filter(Boolean).join('\\n')\n}\n","import { type PrintOptions, print } from './print.ts'\n\n/**\n * Format the generated code based on the TypeScript printer.\n */\nexport function format(source: string, options: Omit<PrintOptions, 'source'> = {}) {\n // do some basic linting with the ts compiler\n return print([], { source, noEmitHelpers: false, ...options })\n}\n"]}
1
+ {"version":3,"sources":["../src/print.ts","../src/format.ts"],"names":["ts","pluginTypescript","prettierFormat"],"mappings":";;;;;;;;;;;;AAIA,IAAM,EAAE,SAAY,GAAAA,mBAAA;AAapB,IAAM,iBAAiB,CAAC,IAAA,KAAiB,IAAK,CAAA,OAAA,CAAQ,SAAS,mBAAmB,CAAA;AAOlF,IAAM,kBAAkB,CAAC,IAAA,KAAiB,IAAK,CAAA,OAAA,CAAQ,wBAAwB,IAAI,CAAA;AAK5E,SAAS,MACd,QACA,EAAA,EAAE,S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AQ,EAAA,YAAA;AAAA,EACR,WAAa,EAAA,IAAA;AAAA,EACb,IAAM,EAAA,KAAA;AAAA,EACN,eAAiB,EAAA,KAAA;AAAA,EACjB,SAAW,EAAA,MAAA;AAAA,EACX,OAAA,EAAS,CAACC,iCAAgB;AAC5B,CAAA;AAKA,eAAsB,OAAO,MAAgB,EAAA;AAE3C,EAAA,IAAI,CAAC,MAAQ,EAAA;AACX,IAAO,OAAA,EAAA;AAAA;AAGT,EAAO,OAAAC,eAAA,CAAe,QAAQ,aAAa,CAAA;AAC7C","file":"index.cjs","sourcesContent":["import ts from 'typescript'\n\nimport type { PrinterOptions } from 'typescript'\n\nconst { factory } = ts\n\nexport type PrintOptions = {\n source?: string\n baseName?: string\n scriptKind?: ts.ScriptKind\n} & PrinterOptions\n\n/**\n * Escaped new lines in code with block comments so they can be restored by {@link restoreNewLines}\n * @param {string} code The code to escape new lines in\n * @returns The same code but with new lines escaped using block comments\n */\nconst escapeNewLines = (code: string) => code.replace(/\\n\\n/g, '\\n/* :newline: */')\n\n/**\n * Reverses {@link escapeNewLines} and restores new lines\n * @param {string} code The code with escaped new lines\n * @returns The same code with new lines restored\n */\nconst restoreNewLines = (code: string) => code.replace(/\\/\\* :newline: \\*\\//g, '\\n')\n\n/**\n * Convert AST TypeScript nodes to a string based on the TypeScript printer.\n */\nexport function print(\n elements: Array<ts.Node>,\n { source = '', baseName = 'print.ts', removeComments, noEmitHelpers, newLine = ts.NewLineKind.LineFeed, scriptKind = ts.ScriptKind.TS }: PrintOptions = {},\n): string {\n const sourceFile = ts.createSourceFile(baseName, escapeNewLines(source), ts.ScriptTarget.ES2022, false, scriptKind)\n const printer = ts.createPrinter({\n omitTrailingSemicolon: true,\n newLine,\n removeComments,\n noEmitHelpers,\n })\n\n let nodes: Array<ts.Node> = []\n\n if (!elements) {\n return ''\n }\n\n if (Array.isArray(elements)) {\n nodes = elements.filter(Boolean)\n } else {\n nodes = [elements].filter(Boolean)\n }\n\n const outputFile = printer.printList(ts.ListFormat.MultiLine, factory.createNodeArray(nodes), sourceFile)\n const outputSource = printer.printFile(sourceFile)\n\n return [outputFile, restoreNewLines(outputSource)].filter(Boolean).join('\\n')\n}\n","import { format as prettierFormat } from 'prettier'\nimport pluginTypescript from 'prettier/plugins/typescript'\n\nimport type { Options } from 'prettier'\n\nconst formatOptions: Options = {\n tabWidth: 2,\n printWidth: 160,\n parser: 'typescript',\n singleQuote: true,\n semi: false,\n bracketSameLine: false,\n endOfLine: 'auto',\n plugins: [pluginTypescript],\n}\n\n/**\n * Format the generated code based on Prettier\n */\nexport async function format(source: string) {\n // do some basic linting with the ts compiler\n if (!source) {\n return ''\n }\n\n return prettierFormat(source, formatOptions)\n}\n"]}
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import ts, { PrinterOptions } from 'typescript';
2
- export { f as factory } from './factory-1NIBrzkm.cjs';
2
+ export { f as factory } from './factory-BbbhTZjP.cjs';
3
3
 
4
4
  type PrintOptions = {
5
5
  source?: string;
@@ -12,8 +12,8 @@ type PrintOptions = {
12
12
  declare function print(elements: Array<ts.Node>, { source, baseName, removeComments, noEmitHelpers, newLine, scriptKind }?: PrintOptions): string;
13
13
 
14
14
  /**
15
- * Format the generated code based on the TypeScript printer.
15
+ * Format the generated code based on Prettier
16
16
  */
17
- declare function format(source: string, options?: Omit<PrintOptions, 'source'>): string;
17
+ declare function format(source: string): Promise<string>;
18
18
 
19
19
  export { format, print };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import ts, { PrinterOptions } from 'typescript';
2
- export { f as factory } from './factory-1NIBrzkm.js';
2
+ export { f as factory } from './factory-BbbhTZjP.js';
3
3
 
4
4
  type PrintOptions = {
5
5
  source?: string;
@@ -12,8 +12,8 @@ type PrintOptions = {
12
12
  declare function print(elements: Array<ts.Node>, { source, baseName, removeComments, noEmitHelpers, newLine, scriptKind }?: PrintOptions): string;
13
13
 
14
14
  /**
15
- * Format the generated code based on the TypeScript printer.
15
+ * Format the generated code based on Prettier
16
16
  */
17
- declare function format(source: string, options?: Omit<PrintOptions, 'source'>): string;
17
+ declare function format(source: string): Promise<string>;
18
18
 
19
19
  export { format, print };
package/dist/index.js CHANGED
@@ -1,5 +1,7 @@
1
- export { factory_exports as factory } from './chunk-RWXGFVS2.js';
1
+ export { factory_exports as factory } from './chunk-3AITTBIG.js';
2
2
  import ts from 'typescript';
3
+ import { format as format$1 } from 'prettier';
4
+ import pluginTypescript from 'prettier/plugins/typescript';
3
5
 
4
6
  var { factory } = ts;
5
7
  var escapeNewLines = (code) => code.replace(/\n\n/g, "\n/* :newline: */");
@@ -25,10 +27,21 @@ function print(elements, { source = "", baseName = "print.ts", removeComments, n
25
27
  const outputSource = printer.printFile(sourceFile);
26
28
  return [outputFile, restoreNewLines(outputSource)].filter(Boolean).join("\n");
27
29
  }
28
-
29
- // src/format.ts
30
- function format(source, options = {}) {
31
- return print([], { source, noEmitHelpers: false, ...options });
30
+ var formatOptions = {
31
+ tabWidth: 2,
32
+ printWidth: 160,
33
+ parser: "typescript",
34
+ singleQuote: true,
35
+ semi: false,
36
+ bracketSameLine: false,
37
+ endOfLine: "auto",
38
+ plugins: [pluginTypescript]
39
+ };
40
+ async function format(source) {
41
+ if (!source) {
42
+ return "";
43
+ }
44
+ return format$1(source, formatOptions);
32
45
  }
33
46
 
34
47
  export { format, print };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/print.ts","../src/format.ts"],"names":[],"mappings":";;;AAIA,IAAM,EAAE,SAAY,GAAA,EAAA;AAapB,IAAM,iBAAiB,CAAC,IAAA,KAAiB,IAAK,CAAA,OAAA,CAAQ,SAAS,mBAAmB,CAAA;AAOlF,IAAM,kBAAkB,CAAC,IAAA,KAAiB,IAAK,CAAA,OAAA,CAAQ,wBAAwB,IAAI,CAAA;AAK5E,SAAS,MACd,QACA,EAAA,EAAE,SAAS,EAAI,EAAA,QAAA,GAAW,YAAY,cAAgB,EAAA,aAAA,EAAe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/D","file":"index.js","sourcesContent":["import ts, { LanguageVariant } from 'typescript'\n\nimport type { PrinterOptions } from 'typescript'\n\nconst { factory } = ts\n\nexport type PrintOptions = {\n source?: string\n baseName?: string\n scriptKind?: ts.ScriptKind\n} & PrinterOptions\n\n/**\n * Escaped new lines in code with block comments so they can be restored by {@link restoreNewLines}\n * @param {string} code The code to escape new lines in\n * @returns The same code but with new lines escaped using block comments\n */\nconst escapeNewLines = (code: string) => code.replace(/\\n\\n/g, '\\n/* :newline: */')\n\n/**\n * Reverses {@link escapeNewLines} and restores new lines\n * @param {string} code The code with escaped new lines\n * @returns The same code with new lines restored\n */\nconst restoreNewLines = (code: string) => code.replace(/\\/\\* :newline: \\*\\//g, '\\n')\n\n/**\n * Convert AST TypeScript nodes to a string based on the TypeScript printer.\n */\nexport function print(\n elements: Array<ts.Node>,\n { source = '', baseName = 'print.ts', removeComments, noEmitHelpers, newLine = ts.NewLineKind.LineFeed, scriptKind = ts.ScriptKind.TS }: PrintOptions = {},\n): string {\n const sourceFile = ts.createSourceFile(baseName, escapeNewLines(source), ts.ScriptTarget.ES2022, false, scriptKind)\n const printer = ts.createPrinter({\n omitTrailingSemicolon: true,\n newLine,\n removeComments,\n noEmitHelpers,\n })\n\n let nodes: Array<ts.Node> = []\n\n if (!elements) {\n return ''\n }\n\n if (Array.isArray(elements)) {\n nodes = elements.filter(Boolean)\n } else {\n nodes = [elements].filter(Boolean)\n }\n\n const outputFile = printer.printList(ts.ListFormat.MultiLine, factory.createNodeArray(nodes), sourceFile)\n const outputSource = printer.printFile(sourceFile)\n\n return [outputFile, restoreNewLines(outputSource)].filter(Boolean).join('\\n')\n}\n","import { type PrintOptions, print } from './print.ts'\n\n/**\n * Format the generated code based on the TypeScript printer.\n */\nexport function format(source: string, options: Omit<PrintOptions, 'source'> = {}) {\n // do some basic linting with the ts compiler\n return print([], { source, noEmitHelpers: false, ...options })\n}\n"]}
1
+ {"version":3,"sources":["../src/print.ts","../src/format.ts"],"names":["prettierFormat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,UAAU,CAAA;AAEjD,EAAO,OAAA,CAAC,UAAY,EAAA,eAAA,CAAgB,YAAY,CAAC,EAAE,MAAO,CAAA,OAAO,CAAE,CAAA,IAAA,CAAK,IAAI,CAAA;AAC9E;ACpDA,IAAM,aAAyB,GAAA;AAAA,EAC7B,QAAU,EAAA,CAAA;AAAA,EACV,UAAY,EAAA,GAAA;AAAA,EACZ,MAAQ,EAAA,YAAA;AAAA,EACR,WAAa,EAAA,IAAA;AAAA,EACb,IAAM,EAAA,KAAA;AAAA,EACN,eAAiB,EAAA,KAAA;AAAA,EACjB,SAAW,EAAA,MAAA;AAAA,EACX,OAAA,EAAS,CAAC,gBAAgB;AAC5B,CAAA;AAKA,eAAsB,OAAO,MAAgB,EAAA;AAE3C,EAAA,IAAI,CAAC,MAAQ,EAAA;AACX,IAAO,OAAA,EAAA;AAAA;AAGT,EAAO,OAAAA,QAAA,CAAe,QAAQ,aAAa,CAAA;AAC7C","file":"index.js","sourcesContent":["import ts from 'typescript'\n\nimport type { PrinterOptions } from 'typescript'\n\nconst { factory } = ts\n\nexport type PrintOptions = {\n source?: string\n baseName?: string\n scriptKind?: ts.ScriptKind\n} & PrinterOptions\n\n/**\n * Escaped new lines in code with block comments so they can be restored by {@link restoreNewLines}\n * @param {string} code The code to escape new lines in\n * @returns The same code but with new lines escaped using block comments\n */\nconst escapeNewLines = (code: string) => code.replace(/\\n\\n/g, '\\n/* :newline: */')\n\n/**\n * Reverses {@link escapeNewLines} and restores new lines\n * @param {string} code The code with escaped new lines\n * @returns The same code with new lines restored\n */\nconst restoreNewLines = (code: string) => code.replace(/\\/\\* :newline: \\*\\//g, '\\n')\n\n/**\n * Convert AST TypeScript nodes to a string based on the TypeScript printer.\n */\nexport function print(\n elements: Array<ts.Node>,\n { source = '', baseName = 'print.ts', removeComments, noEmitHelpers, newLine = ts.NewLineKind.LineFeed, scriptKind = ts.ScriptKind.TS }: PrintOptions = {},\n): string {\n const sourceFile = ts.createSourceFile(baseName, escapeNewLines(source), ts.ScriptTarget.ES2022, false, scriptKind)\n const printer = ts.createPrinter({\n omitTrailingSemicolon: true,\n newLine,\n removeComments,\n noEmitHelpers,\n })\n\n let nodes: Array<ts.Node> = []\n\n if (!elements) {\n return ''\n }\n\n if (Array.isArray(elements)) {\n nodes = elements.filter(Boolean)\n } else {\n nodes = [elements].filter(Boolean)\n }\n\n const outputFile = printer.printList(ts.ListFormat.MultiLine, factory.createNodeArray(nodes), sourceFile)\n const outputSource = printer.printFile(sourceFile)\n\n return [outputFile, restoreNewLines(outputSource)].filter(Boolean).join('\\n')\n}\n","import { format as prettierFormat } from 'prettier'\nimport pluginTypescript from 'prettier/plugins/typescript'\n\nimport type { Options } from 'prettier'\n\nconst formatOptions: Options = {\n tabWidth: 2,\n printWidth: 160,\n parser: 'typescript',\n singleQuote: true,\n semi: false,\n bracketSameLine: false,\n endOfLine: 'auto',\n plugins: [pluginTypescript],\n}\n\n/**\n * Format the generated code based on Prettier\n */\nexport async function format(source: string) {\n // do some basic linting with the ts compiler\n if (!source) {\n return ''\n }\n\n return prettierFormat(source, formatOptions)\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/parser-ts",
3
- "version": "3.2.0",
3
+ "version": "3.3.1",
4
4
  "description": "TypeScript parser",
5
5
  "keywords": [
6
6
  "typescript",
@@ -48,13 +48,14 @@
48
48
  "!/**/__tests__/**"
49
49
  ],
50
50
  "dependencies": {
51
+ "prettier": "^3.4.2",
51
52
  "remeda": "^2.17.4",
52
53
  "typescript": "^5.7.2"
53
54
  },
54
55
  "devDependencies": {
55
56
  "tsup": "^8.3.5",
56
- "@kubb/config-ts": "3.2.0",
57
- "@kubb/config-tsup": "3.2.0"
57
+ "@kubb/config-ts": "3.3.1",
58
+ "@kubb/config-tsup": "3.3.1"
58
59
  },
59
60
  "engines": {
60
61
  "node": ">=20"
package/src/factory.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { isNumber } from 'remeda'
2
- import ts from 'typescript'
2
+ import ts, { SyntaxKind } from 'typescript'
3
3
 
4
4
  const { factory } = ts
5
5
 
@@ -12,6 +12,10 @@ export const modifiers = {
12
12
  static: factory.createModifier(ts.SyntaxKind.StaticKeyword),
13
13
  } as const
14
14
 
15
+ export const syntaxKind = {
16
+ union: SyntaxKind.UnionType as 192,
17
+ } as const
18
+
15
19
  function isValidIdentifier(str: string): boolean {
16
20
  if (!str.length || str.trim() !== str) {
17
21
  return false
@@ -248,6 +252,60 @@ export function createTypeAliasDeclaration({
248
252
  return factory.createTypeAliasDeclaration(modifiers, name, typeParameters, type)
249
253
  }
250
254
 
255
+ export function createInterfaceDeclaration({
256
+ modifiers,
257
+ name,
258
+ typeParameters,
259
+ members,
260
+ }: {
261
+ modifiers?: Array<ts.Modifier>
262
+ name: string | ts.Identifier
263
+ typeParameters?: Array<ts.TypeParameterDeclaration>
264
+ members: Array<ts.TypeElement>
265
+ }) {
266
+ return factory.createInterfaceDeclaration(modifiers, name, typeParameters, undefined, members)
267
+ }
268
+
269
+ export function createTypeDeclaration({
270
+ syntax,
271
+ isExportable,
272
+ description,
273
+ name,
274
+ type,
275
+ }: {
276
+ syntax: 'type' | 'interface'
277
+ description?: string
278
+ isExportable?: boolean
279
+ name: string | ts.Identifier
280
+ type: ts.TypeNode
281
+ }) {
282
+ if (syntax === 'interface' && 'members' in type) {
283
+ const node = createInterfaceDeclaration({
284
+ members: type.members as Array<ts.TypeElement>,
285
+ modifiers: isExportable ? [modifiers.export] : [],
286
+ name,
287
+ typeParameters: undefined,
288
+ })
289
+
290
+ return appendJSDocToNode({
291
+ node,
292
+ comments: [description ? `@description ${description}` : undefined].filter(Boolean),
293
+ })
294
+ }
295
+
296
+ const node = createTypeAliasDeclaration({
297
+ type,
298
+ modifiers: isExportable ? [modifiers.export] : [],
299
+ name,
300
+ typeParameters: undefined,
301
+ })
302
+
303
+ return appendJSDocToNode({
304
+ node,
305
+ comments: [description ? `@description ${description}` : undefined].filter(Boolean),
306
+ })
307
+ }
308
+
251
309
  export function createNamespaceDeclaration({
252
310
  statements,
253
311
  name,
package/src/format.ts CHANGED
@@ -1,9 +1,27 @@
1
- import { type PrintOptions, print } from './print.ts'
1
+ import { format as prettierFormat } from 'prettier'
2
+ import pluginTypescript from 'prettier/plugins/typescript'
3
+
4
+ import type { Options } from 'prettier'
5
+
6
+ const formatOptions: Options = {
7
+ tabWidth: 2,
8
+ printWidth: 160,
9
+ parser: 'typescript',
10
+ singleQuote: true,
11
+ semi: false,
12
+ bracketSameLine: false,
13
+ endOfLine: 'auto',
14
+ plugins: [pluginTypescript],
15
+ }
2
16
 
3
17
  /**
4
- * Format the generated code based on the TypeScript printer.
18
+ * Format the generated code based on Prettier
5
19
  */
6
- export function format(source: string, options: Omit<PrintOptions, 'source'> = {}) {
20
+ export async function format(source: string) {
7
21
  // do some basic linting with the ts compiler
8
- return print([], { source, noEmitHelpers: false, ...options })
22
+ if (!source) {
23
+ return ''
24
+ }
25
+
26
+ return prettierFormat(source, formatOptions)
9
27
  }
package/src/print.ts CHANGED
@@ -1,4 +1,4 @@
1
- import ts, { LanguageVariant } from 'typescript'
1
+ import ts from 'typescript'
2
2
 
3
3
  import type { PrinterOptions } from 'typescript'
4
4
 
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/factory.ts"],"names":["ts","modifiers","questionToken","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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} = 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\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({\n nodes,\n withParentheses,\n}: {\n nodes: Array<ts.TypeNode>\n withParentheses?: boolean\n}): 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({\n nodes,\n withParentheses,\n}: {\n nodes: Array<ts.TypeNode>\n withParentheses?: boolean\n}): 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({\n nodes,\n}: {\n nodes: Array<ts.TypeNode>\n}): 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({\n nodes,\n withParentheses,\n}: {\n nodes: Array<ts.TypeNode>\n withParentheses?: boolean\n}): 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>({\n node,\n comments,\n}: {\n node: TNode\n comments: Array<string | undefined>\n}) {\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 createNamespaceDeclaration({\n statements,\n name,\n}: {\n name: string\n statements: ts.Statement[]\n}) {\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 = 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\n if (isNumber(Number.parseInt(value.toString()))) {\n initializer = factory.createNumericLiteral(value as number)\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({\n keys,\n type,\n nonNullable,\n}: {\n keys: Array<string> | string\n type: ts.TypeNode\n nonNullable?: boolean\n}) {\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 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 createTupleTypeNode = factory.createTupleTypeNode\nexport const createTrue = factory.createTrue\nexport const createFalse = factory.createFalse\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/factory.ts"],"names":["modifiers","questionToken","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,WAA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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\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({\n nodes,\n withParentheses,\n}: {\n nodes: Array<ts.TypeNode>\n withParentheses?: boolean\n}): 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({\n nodes,\n withParentheses,\n}: {\n nodes: Array<ts.TypeNode>\n withParentheses?: boolean\n}): 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({\n nodes,\n}: {\n nodes: Array<ts.TypeNode>\n}): 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({\n nodes,\n withParentheses,\n}: {\n nodes: Array<ts.TypeNode>\n withParentheses?: boolean\n}): 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>({\n node,\n comments,\n}: {\n node: TNode\n comments: Array<string | undefined>\n}) {\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 createNamespaceDeclaration({\n statements,\n name,\n}: {\n name: string\n statements: ts.Statement[]\n}) {\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 = 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\n if (isNumber(Number.parseInt(value.toString()))) {\n initializer = factory.createNumericLiteral(value as number)\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({\n keys,\n type,\n nonNullable,\n}: {\n keys: Array<string> | string\n type: ts.TypeNode\n nonNullable?: boolean\n}) {\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 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 createTupleTypeNode = factory.createTupleTypeNode\nexport const createTrue = factory.createTrue\nexport const createFalse = factory.createFalse\n"]}