@kubb/parser-ts 4.1.4 → 5.0.0-alpha.31

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,496 +0,0 @@
1
- //#region rolldown:runtime
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (all) => {
9
- let target = {};
10
- for (var name in all) __defProp(target, name, {
11
- get: all[name],
12
- enumerable: true
13
- });
14
- return target;
15
- };
16
- var __copyProps = (to, from, except, desc) => {
17
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
18
- key = keys[i];
19
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
20
- get: ((k) => from[k]).bind(null, key),
21
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
22
- });
23
- }
24
- return to;
25
- };
26
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
27
- value: mod,
28
- enumerable: true
29
- }) : target, mod));
30
-
31
- //#endregion
32
- let remeda = require("remeda");
33
- remeda = __toESM(remeda);
34
- let typescript = require("typescript");
35
- typescript = __toESM(typescript);
36
-
37
- //#region src/factory.ts
38
- var factory_exports = /* @__PURE__ */ __export({
39
- appendJSDocToNode: () => appendJSDocToNode,
40
- createArrayDeclaration: () => createArrayDeclaration,
41
- createArrayTypeNode: () => createArrayTypeNode,
42
- createEnumDeclaration: () => createEnumDeclaration,
43
- createExportDeclaration: () => createExportDeclaration,
44
- createFalse: () => createFalse,
45
- createIdentifier: () => createIdentifier,
46
- createImportDeclaration: () => createImportDeclaration,
47
- createIndexSignature: () => createIndexSignature,
48
- createInterfaceDeclaration: () => createInterfaceDeclaration,
49
- createIntersectionDeclaration: () => createIntersectionDeclaration,
50
- createJSDoc: () => createJSDoc,
51
- createLiteralTypeNode: () => createLiteralTypeNode,
52
- createNamespaceDeclaration: () => createNamespaceDeclaration,
53
- createNull: () => createNull,
54
- createNumericLiteral: () => createNumericLiteral,
55
- createOmitDeclaration: () => createOmitDeclaration,
56
- createOptionalTypeNode: () => createOptionalTypeNode,
57
- createParameterSignature: () => createParameterSignature,
58
- createPropertySignature: () => createPropertySignature,
59
- createQuestionToken: () => createQuestionToken,
60
- createRestTypeNode: () => createRestTypeNode,
61
- createStringLiteral: () => createStringLiteral,
62
- createTrue: () => createTrue,
63
- createTupleDeclaration: () => createTupleDeclaration,
64
- createTupleTypeNode: () => createTupleTypeNode,
65
- createTypeAliasDeclaration: () => createTypeAliasDeclaration,
66
- createTypeDeclaration: () => createTypeDeclaration,
67
- createTypeLiteralNode: () => createTypeLiteralNode,
68
- createTypeReferenceNode: () => createTypeReferenceNode,
69
- createUnionDeclaration: () => createUnionDeclaration,
70
- keywordTypeNodes: () => keywordTypeNodes,
71
- modifiers: () => modifiers,
72
- syntaxKind: () => syntaxKind
73
- });
74
- const { SyntaxKind, factory } = typescript.default;
75
- const modifiers = {
76
- async: factory.createModifier(typescript.default.SyntaxKind.AsyncKeyword),
77
- export: factory.createModifier(typescript.default.SyntaxKind.ExportKeyword),
78
- const: factory.createModifier(typescript.default.SyntaxKind.ConstKeyword),
79
- static: factory.createModifier(typescript.default.SyntaxKind.StaticKeyword)
80
- };
81
- const syntaxKind = { union: SyntaxKind.UnionType };
82
- function isValidIdentifier(str) {
83
- if (!str.length || str.trim() !== str) return false;
84
- const node = typescript.default.parseIsolatedEntityName(str, typescript.default.ScriptTarget.Latest);
85
- return !!node && node.kind === typescript.default.SyntaxKind.Identifier && typescript.default.identifierToKeywordKind(node.kind) === void 0;
86
- }
87
- function propertyName(name) {
88
- if (typeof name === "string") return isValidIdentifier(name) ? factory.createIdentifier(name) : factory.createStringLiteral(name);
89
- return name;
90
- }
91
- const questionToken = factory.createToken(typescript.default.SyntaxKind.QuestionToken);
92
- function createQuestionToken(token) {
93
- if (!token) return;
94
- if (token === true) return questionToken;
95
- return token;
96
- }
97
- function createIntersectionDeclaration({ nodes, withParentheses }) {
98
- if (!nodes.length) return null;
99
- if (nodes.length === 1) return nodes[0] || null;
100
- const node = factory.createIntersectionTypeNode(nodes);
101
- if (withParentheses) return factory.createParenthesizedType(node);
102
- return node;
103
- }
104
- /**
105
- * Minimum nodes length of 2
106
- * @example `string & number`
107
- */
108
- function createTupleDeclaration({ nodes, withParentheses }) {
109
- if (!nodes.length) return null;
110
- if (nodes.length === 1) return nodes[0] || null;
111
- const node = factory.createTupleTypeNode(nodes);
112
- if (withParentheses) return factory.createParenthesizedType(node);
113
- return node;
114
- }
115
- function createArrayDeclaration({ nodes }) {
116
- if (!nodes.length) return factory.createTupleTypeNode([]);
117
- if (nodes.length === 1) return factory.createArrayTypeNode(nodes.at(0));
118
- return factory.createExpressionWithTypeArguments(factory.createIdentifier("Array"), [factory.createUnionTypeNode(nodes)]);
119
- }
120
- /**
121
- * Minimum nodes length of 2
122
- * @example `string | number`
123
- */
124
- function createUnionDeclaration({ nodes, withParentheses }) {
125
- if (!nodes.length) return keywordTypeNodes.any;
126
- if (nodes.length === 1) return nodes[0];
127
- const node = factory.createUnionTypeNode(nodes);
128
- if (withParentheses) return factory.createParenthesizedType(node);
129
- return node;
130
- }
131
- function createPropertySignature({ readOnly, modifiers: modifiers$1 = [], name, questionToken: questionToken$1, type }) {
132
- return factory.createPropertySignature([...modifiers$1, readOnly ? factory.createToken(typescript.default.SyntaxKind.ReadonlyKeyword) : void 0].filter(Boolean), propertyName(name), createQuestionToken(questionToken$1), type);
133
- }
134
- function createParameterSignature(name, { modifiers: modifiers$1, dotDotDotToken, questionToken: questionToken$1, type, initializer }) {
135
- return factory.createParameterDeclaration(modifiers$1, dotDotDotToken, name, createQuestionToken(questionToken$1), type, initializer);
136
- }
137
- function createJSDoc({ comments }) {
138
- if (!comments.length) return null;
139
- return factory.createJSDocComment(factory.createNodeArray(comments.map((comment, i) => {
140
- if (i === comments.length - 1) return factory.createJSDocText(comment);
141
- return factory.createJSDocText(`${comment}\n`);
142
- })));
143
- }
144
- /**
145
- * @link https://github.com/microsoft/TypeScript/issues/44151
146
- */
147
- function appendJSDocToNode({ node, comments }) {
148
- const filteredComments = comments.filter(Boolean);
149
- if (!filteredComments.length) return node;
150
- const text = filteredComments.reduce((acc = "", comment = "") => {
151
- return `${acc}\n * ${comment.replaceAll("*/", "*\\/")}`;
152
- }, "*");
153
- return typescript.default.addSyntheticLeadingComment({ ...node }, typescript.default.SyntaxKind.MultiLineCommentTrivia, `${text || "*"}\n`, true);
154
- }
155
- function createIndexSignature(type, { modifiers: modifiers$1, indexName = "key", indexType = factory.createKeywordTypeNode(typescript.default.SyntaxKind.StringKeyword) } = {}) {
156
- return factory.createIndexSignature(modifiers$1, [createParameterSignature(indexName, { type: indexType })], type);
157
- }
158
- function createTypeAliasDeclaration({ modifiers: modifiers$1, name, typeParameters, type }) {
159
- return factory.createTypeAliasDeclaration(modifiers$1, name, typeParameters, type);
160
- }
161
- function createInterfaceDeclaration({ modifiers: modifiers$1, name, typeParameters, members }) {
162
- return factory.createInterfaceDeclaration(modifiers$1, name, typeParameters, void 0, members);
163
- }
164
- function createTypeDeclaration({ syntax, isExportable, comments, name, type }) {
165
- if (syntax === "interface" && "members" in type) {
166
- const node$1 = createInterfaceDeclaration({
167
- members: type.members,
168
- modifiers: isExportable ? [modifiers.export] : [],
169
- name,
170
- typeParameters: void 0
171
- });
172
- return appendJSDocToNode({
173
- node: node$1,
174
- comments
175
- });
176
- }
177
- const node = createTypeAliasDeclaration({
178
- type,
179
- modifiers: isExportable ? [modifiers.export] : [],
180
- name,
181
- typeParameters: void 0
182
- });
183
- return appendJSDocToNode({
184
- node,
185
- comments
186
- });
187
- }
188
- function createNamespaceDeclaration({ statements, name }) {
189
- return factory.createModuleDeclaration([factory.createToken(typescript.default.SyntaxKind.ExportKeyword)], factory.createIdentifier(name), factory.createModuleBlock(statements), typescript.default.NodeFlags.Namespace);
190
- }
191
- /**
192
- * In { propertyName: string; name?: string } is `name` being used to make the type more unique when multiple same names are used.
193
- * @example `import { Pet as Cat } from './Pet'`
194
- */
195
- function createImportDeclaration({ name, path, isTypeOnly = false, isNameSpace = false }) {
196
- if (!Array.isArray(name)) {
197
- let importPropertyName = factory.createIdentifier(name);
198
- let importName;
199
- if (isNameSpace) {
200
- importPropertyName = void 0;
201
- importName = factory.createNamespaceImport(factory.createIdentifier(name));
202
- }
203
- return factory.createImportDeclaration(void 0, factory.createImportClause(isTypeOnly, importPropertyName, importName), factory.createStringLiteral(path), void 0);
204
- }
205
- return factory.createImportDeclaration(void 0, factory.createImportClause(isTypeOnly, void 0, factory.createNamedImports(name.map((item) => {
206
- if (typeof item === "object") {
207
- const obj = item;
208
- if (obj.name) return factory.createImportSpecifier(false, factory.createIdentifier(obj.propertyName), factory.createIdentifier(obj.name));
209
- return factory.createImportSpecifier(false, void 0, factory.createIdentifier(obj.propertyName));
210
- }
211
- return factory.createImportSpecifier(false, void 0, factory.createIdentifier(item));
212
- }))), factory.createStringLiteral(path), void 0);
213
- }
214
- function createExportDeclaration({ path, asAlias, isTypeOnly = false, name }) {
215
- if (name && !Array.isArray(name) && !asAlias) console.warn(`When using name as string, asAlias should be true ${name}`);
216
- if (!Array.isArray(name)) {
217
- const parsedName = name?.match(/^\d/) ? `_${name?.slice(1)}` : name;
218
- return factory.createExportDeclaration(void 0, isTypeOnly, asAlias && parsedName ? factory.createNamespaceExport(factory.createIdentifier(parsedName)) : void 0, factory.createStringLiteral(path), void 0);
219
- }
220
- return factory.createExportDeclaration(void 0, isTypeOnly, factory.createNamedExports(name.map((propertyName$1) => {
221
- return factory.createExportSpecifier(false, void 0, typeof propertyName$1 === "string" ? factory.createIdentifier(propertyName$1) : propertyName$1);
222
- })), factory.createStringLiteral(path), void 0);
223
- }
224
- function createEnumDeclaration({ type = "enum", name, typeName, enums }) {
225
- if (type === "literal") return [void 0, factory.createTypeAliasDeclaration([factory.createToken(typescript.default.SyntaxKind.ExportKeyword)], factory.createIdentifier(typeName), void 0, factory.createUnionTypeNode(enums.map(([_key, value]) => {
226
- if ((0, remeda.isNumber)(value)) return factory.createLiteralTypeNode(factory.createNumericLiteral(value?.toString()));
227
- if (typeof value === "boolean") return factory.createLiteralTypeNode(value ? factory.createTrue() : factory.createFalse());
228
- if (value) return factory.createLiteralTypeNode(factory.createStringLiteral(value.toString()));
229
- }).filter(Boolean)))];
230
- if (type === "enum" || type === "constEnum") return [void 0, factory.createEnumDeclaration([factory.createToken(typescript.default.SyntaxKind.ExportKeyword), type === "constEnum" ? factory.createToken(typescript.default.SyntaxKind.ConstKeyword) : void 0].filter(Boolean), factory.createIdentifier(typeName), enums.map(([key, value]) => {
231
- let initializer = factory.createStringLiteral(value?.toString());
232
- if (Number.parseInt(value.toString(), 10) === value && (0, remeda.isNumber)(Number.parseInt(value.toString(), 10))) initializer = factory.createNumericLiteral(value);
233
- if (typeof value === "boolean") initializer = value ? factory.createTrue() : factory.createFalse();
234
- if ((0, remeda.isNumber)(Number.parseInt(key.toString(), 10))) return factory.createEnumMember(factory.createStringLiteral(`${typeName}_${key}`), initializer);
235
- if (key) return factory.createEnumMember(factory.createStringLiteral(`${key}`), initializer);
236
- }).filter(Boolean))];
237
- const identifierName = type === "asPascalConst" ? typeName : name;
238
- return [factory.createVariableStatement([factory.createToken(typescript.default.SyntaxKind.ExportKeyword)], factory.createVariableDeclarationList([factory.createVariableDeclaration(factory.createIdentifier(identifierName), void 0, void 0, factory.createAsExpression(factory.createObjectLiteralExpression(enums.map(([key, value]) => {
239
- let initializer = factory.createStringLiteral(value?.toString());
240
- if ((0, remeda.isNumber)(value)) if (value < 0) initializer = factory.createPrefixUnaryExpression(typescript.default.SyntaxKind.MinusToken, factory.createNumericLiteral(Math.abs(value)));
241
- else initializer = factory.createNumericLiteral(value);
242
- if (typeof value === "boolean") initializer = value ? factory.createTrue() : factory.createFalse();
243
- if (key) return factory.createPropertyAssignment(factory.createStringLiteral(`${key}`), initializer);
244
- }).filter(Boolean), true), factory.createTypeReferenceNode(factory.createIdentifier("const"), void 0)))], typescript.default.NodeFlags.Const)), factory.createTypeAliasDeclaration(type === "asPascalConst" ? [] : [factory.createToken(typescript.default.SyntaxKind.ExportKeyword)], factory.createIdentifier(typeName), void 0, factory.createIndexedAccessTypeNode(factory.createParenthesizedType(factory.createTypeQueryNode(factory.createIdentifier(identifierName), void 0)), factory.createTypeOperatorNode(typescript.default.SyntaxKind.KeyOfKeyword, factory.createTypeQueryNode(factory.createIdentifier(identifierName), void 0))))];
245
- }
246
- function createOmitDeclaration({ keys, type, nonNullable }) {
247
- const node = nonNullable ? factory.createTypeReferenceNode(factory.createIdentifier("NonNullable"), [type]) : type;
248
- if (Array.isArray(keys)) return factory.createTypeReferenceNode(factory.createIdentifier("Omit"), [node, factory.createUnionTypeNode(keys.map((key) => {
249
- return factory.createLiteralTypeNode(factory.createStringLiteral(key));
250
- }))]);
251
- return factory.createTypeReferenceNode(factory.createIdentifier("Omit"), [node, factory.createLiteralTypeNode(factory.createStringLiteral(keys))]);
252
- }
253
- const keywordTypeNodes = {
254
- any: factory.createKeywordTypeNode(typescript.default.SyntaxKind.AnyKeyword),
255
- unknown: factory.createKeywordTypeNode(typescript.default.SyntaxKind.UnknownKeyword),
256
- void: factory.createKeywordTypeNode(typescript.default.SyntaxKind.VoidKeyword),
257
- number: factory.createKeywordTypeNode(typescript.default.SyntaxKind.NumberKeyword),
258
- integer: factory.createKeywordTypeNode(typescript.default.SyntaxKind.NumberKeyword),
259
- object: factory.createKeywordTypeNode(typescript.default.SyntaxKind.ObjectKeyword),
260
- string: factory.createKeywordTypeNode(typescript.default.SyntaxKind.StringKeyword),
261
- boolean: factory.createKeywordTypeNode(typescript.default.SyntaxKind.BooleanKeyword),
262
- undefined: factory.createKeywordTypeNode(typescript.default.SyntaxKind.UndefinedKeyword),
263
- null: factory.createLiteralTypeNode(factory.createToken(typescript.default.SyntaxKind.NullKeyword))
264
- };
265
- const createTypeLiteralNode = factory.createTypeLiteralNode;
266
- const createTypeReferenceNode = factory.createTypeReferenceNode;
267
- const createNumericLiteral = factory.createNumericLiteral;
268
- const createStringLiteral = factory.createStringLiteral;
269
- const createArrayTypeNode = factory.createArrayTypeNode;
270
- const createLiteralTypeNode = factory.createLiteralTypeNode;
271
- const createNull = factory.createNull;
272
- const createIdentifier = factory.createIdentifier;
273
- const createOptionalTypeNode = factory.createOptionalTypeNode;
274
- const createTupleTypeNode = factory.createTupleTypeNode;
275
- const createRestTypeNode = factory.createRestTypeNode;
276
- const createTrue = factory.createTrue;
277
- const createFalse = factory.createFalse;
278
-
279
- //#endregion
280
- Object.defineProperty(exports, '__toESM', {
281
- enumerable: true,
282
- get: function () {
283
- return __toESM;
284
- }
285
- });
286
- Object.defineProperty(exports, 'appendJSDocToNode', {
287
- enumerable: true,
288
- get: function () {
289
- return appendJSDocToNode;
290
- }
291
- });
292
- Object.defineProperty(exports, 'createArrayDeclaration', {
293
- enumerable: true,
294
- get: function () {
295
- return createArrayDeclaration;
296
- }
297
- });
298
- Object.defineProperty(exports, 'createArrayTypeNode', {
299
- enumerable: true,
300
- get: function () {
301
- return createArrayTypeNode;
302
- }
303
- });
304
- Object.defineProperty(exports, 'createEnumDeclaration', {
305
- enumerable: true,
306
- get: function () {
307
- return createEnumDeclaration;
308
- }
309
- });
310
- Object.defineProperty(exports, 'createExportDeclaration', {
311
- enumerable: true,
312
- get: function () {
313
- return createExportDeclaration;
314
- }
315
- });
316
- Object.defineProperty(exports, 'createFalse', {
317
- enumerable: true,
318
- get: function () {
319
- return createFalse;
320
- }
321
- });
322
- Object.defineProperty(exports, 'createIdentifier', {
323
- enumerable: true,
324
- get: function () {
325
- return createIdentifier;
326
- }
327
- });
328
- Object.defineProperty(exports, 'createImportDeclaration', {
329
- enumerable: true,
330
- get: function () {
331
- return createImportDeclaration;
332
- }
333
- });
334
- Object.defineProperty(exports, 'createIndexSignature', {
335
- enumerable: true,
336
- get: function () {
337
- return createIndexSignature;
338
- }
339
- });
340
- Object.defineProperty(exports, 'createInterfaceDeclaration', {
341
- enumerable: true,
342
- get: function () {
343
- return createInterfaceDeclaration;
344
- }
345
- });
346
- Object.defineProperty(exports, 'createIntersectionDeclaration', {
347
- enumerable: true,
348
- get: function () {
349
- return createIntersectionDeclaration;
350
- }
351
- });
352
- Object.defineProperty(exports, 'createJSDoc', {
353
- enumerable: true,
354
- get: function () {
355
- return createJSDoc;
356
- }
357
- });
358
- Object.defineProperty(exports, 'createLiteralTypeNode', {
359
- enumerable: true,
360
- get: function () {
361
- return createLiteralTypeNode;
362
- }
363
- });
364
- Object.defineProperty(exports, 'createNamespaceDeclaration', {
365
- enumerable: true,
366
- get: function () {
367
- return createNamespaceDeclaration;
368
- }
369
- });
370
- Object.defineProperty(exports, 'createNull', {
371
- enumerable: true,
372
- get: function () {
373
- return createNull;
374
- }
375
- });
376
- Object.defineProperty(exports, 'createNumericLiteral', {
377
- enumerable: true,
378
- get: function () {
379
- return createNumericLiteral;
380
- }
381
- });
382
- Object.defineProperty(exports, 'createOmitDeclaration', {
383
- enumerable: true,
384
- get: function () {
385
- return createOmitDeclaration;
386
- }
387
- });
388
- Object.defineProperty(exports, 'createOptionalTypeNode', {
389
- enumerable: true,
390
- get: function () {
391
- return createOptionalTypeNode;
392
- }
393
- });
394
- Object.defineProperty(exports, 'createParameterSignature', {
395
- enumerable: true,
396
- get: function () {
397
- return createParameterSignature;
398
- }
399
- });
400
- Object.defineProperty(exports, 'createPropertySignature', {
401
- enumerable: true,
402
- get: function () {
403
- return createPropertySignature;
404
- }
405
- });
406
- Object.defineProperty(exports, 'createQuestionToken', {
407
- enumerable: true,
408
- get: function () {
409
- return createQuestionToken;
410
- }
411
- });
412
- Object.defineProperty(exports, 'createRestTypeNode', {
413
- enumerable: true,
414
- get: function () {
415
- return createRestTypeNode;
416
- }
417
- });
418
- Object.defineProperty(exports, 'createStringLiteral', {
419
- enumerable: true,
420
- get: function () {
421
- return createStringLiteral;
422
- }
423
- });
424
- Object.defineProperty(exports, 'createTrue', {
425
- enumerable: true,
426
- get: function () {
427
- return createTrue;
428
- }
429
- });
430
- Object.defineProperty(exports, 'createTupleDeclaration', {
431
- enumerable: true,
432
- get: function () {
433
- return createTupleDeclaration;
434
- }
435
- });
436
- Object.defineProperty(exports, 'createTupleTypeNode', {
437
- enumerable: true,
438
- get: function () {
439
- return createTupleTypeNode;
440
- }
441
- });
442
- Object.defineProperty(exports, 'createTypeAliasDeclaration', {
443
- enumerable: true,
444
- get: function () {
445
- return createTypeAliasDeclaration;
446
- }
447
- });
448
- Object.defineProperty(exports, 'createTypeDeclaration', {
449
- enumerable: true,
450
- get: function () {
451
- return createTypeDeclaration;
452
- }
453
- });
454
- Object.defineProperty(exports, 'createTypeLiteralNode', {
455
- enumerable: true,
456
- get: function () {
457
- return createTypeLiteralNode;
458
- }
459
- });
460
- Object.defineProperty(exports, 'createTypeReferenceNode', {
461
- enumerable: true,
462
- get: function () {
463
- return createTypeReferenceNode;
464
- }
465
- });
466
- Object.defineProperty(exports, 'createUnionDeclaration', {
467
- enumerable: true,
468
- get: function () {
469
- return createUnionDeclaration;
470
- }
471
- });
472
- Object.defineProperty(exports, 'factory_exports', {
473
- enumerable: true,
474
- get: function () {
475
- return factory_exports;
476
- }
477
- });
478
- Object.defineProperty(exports, 'keywordTypeNodes', {
479
- enumerable: true,
480
- get: function () {
481
- return keywordTypeNodes;
482
- }
483
- });
484
- Object.defineProperty(exports, 'modifiers', {
485
- enumerable: true,
486
- get: function () {
487
- return modifiers;
488
- }
489
- });
490
- Object.defineProperty(exports, 'syntaxKind', {
491
- enumerable: true,
492
- get: function () {
493
- return syntaxKind;
494
- }
495
- });
496
- //# sourceMappingURL=factory-BNDICAoK.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"factory-BNDICAoK.cjs","names":["ts","modifiers","questionToken","node","importPropertyName: ts.Identifier | undefined","importName: ts.NamedImportBindings | undefined","propertyName","initializer: ts.Expression"],"sources":["../src/factory.ts"],"sourcesContent":["import { isNumber } from 'remeda'\nimport ts from 'typescript'\n\nconst { SyntaxKind, factory } = ts\n\n// https://ts-ast-viewer.com/\n\nexport const modifiers = {\n async: factory.createModifier(ts.SyntaxKind.AsyncKeyword),\n export: factory.createModifier(ts.SyntaxKind.ExportKeyword),\n const: factory.createModifier(ts.SyntaxKind.ConstKeyword),\n static: factory.createModifier(ts.SyntaxKind.StaticKeyword),\n} as const\n\nexport const syntaxKind = {\n union: SyntaxKind.UnionType as 192,\n} as const\n\nfunction isValidIdentifier(str: string): boolean {\n if (!str.length || str.trim() !== str) {\n return false\n }\n const node = ts.parseIsolatedEntityName(str, ts.ScriptTarget.Latest)\n\n return !!node && node.kind === ts.SyntaxKind.Identifier && ts.identifierToKeywordKind(node.kind as unknown as ts.Identifier) === undefined\n}\n\nfunction propertyName(name: string | ts.PropertyName): ts.PropertyName {\n if (typeof name === 'string') {\n return isValidIdentifier(name) ? factory.createIdentifier(name) : factory.createStringLiteral(name)\n }\n return name\n}\n\nconst questionToken = factory.createToken(ts.SyntaxKind.QuestionToken)\n\nexport function createQuestionToken(token?: boolean | ts.QuestionToken) {\n if (!token) {\n return undefined\n }\n if (token === true) {\n return questionToken\n }\n return token\n}\n\nexport function createIntersectionDeclaration({ nodes, withParentheses }: { nodes: Array<ts.TypeNode>; withParentheses?: boolean }): ts.TypeNode | null {\n if (!nodes.length) {\n return null\n }\n\n if (nodes.length === 1) {\n return nodes[0] || null\n }\n\n const node = factory.createIntersectionTypeNode(nodes)\n\n if (withParentheses) {\n return factory.createParenthesizedType(node)\n }\n\n return node\n}\n\n/**\n * Minimum nodes length of 2\n * @example `string & number`\n */\nexport function createTupleDeclaration({ nodes, withParentheses }: { nodes: Array<ts.TypeNode>; withParentheses?: boolean }): ts.TypeNode | null {\n if (!nodes.length) {\n return null\n }\n\n if (nodes.length === 1) {\n return nodes[0] || null\n }\n\n const node = factory.createTupleTypeNode(nodes)\n\n if (withParentheses) {\n return factory.createParenthesizedType(node)\n }\n\n return node\n}\n\nexport function createArrayDeclaration({ nodes }: { nodes: Array<ts.TypeNode> }): ts.TypeNode | null {\n if (!nodes.length) {\n return factory.createTupleTypeNode([])\n }\n\n if (nodes.length === 1) {\n return factory.createArrayTypeNode(nodes.at(0)!)\n }\n\n return factory.createExpressionWithTypeArguments(factory.createIdentifier('Array'), [factory.createUnionTypeNode(nodes)])\n}\n\n/**\n * Minimum nodes length of 2\n * @example `string | number`\n */\nexport function createUnionDeclaration({ nodes, withParentheses }: { nodes: Array<ts.TypeNode>; withParentheses?: boolean }): ts.TypeNode {\n if (!nodes.length) {\n return keywordTypeNodes.any\n }\n\n if (nodes.length === 1) {\n return nodes[0] as ts.TypeNode\n }\n\n const node = factory.createUnionTypeNode(nodes)\n\n if (withParentheses) {\n return factory.createParenthesizedType(node)\n }\n\n return node\n}\n\nexport function createPropertySignature({\n readOnly,\n modifiers = [],\n name,\n questionToken,\n type,\n}: {\n readOnly?: boolean\n modifiers?: Array<ts.Modifier>\n name: ts.PropertyName | string\n questionToken?: ts.QuestionToken | boolean\n type?: ts.TypeNode\n}) {\n return factory.createPropertySignature(\n [...modifiers, readOnly ? factory.createToken(ts.SyntaxKind.ReadonlyKeyword) : undefined].filter(Boolean),\n propertyName(name),\n createQuestionToken(questionToken),\n type,\n )\n}\n\nexport function createParameterSignature(\n name: string | ts.BindingName,\n {\n modifiers,\n dotDotDotToken,\n questionToken,\n type,\n initializer,\n }: {\n decorators?: Array<ts.Decorator>\n modifiers?: Array<ts.Modifier>\n dotDotDotToken?: ts.DotDotDotToken\n questionToken?: ts.QuestionToken | boolean\n type?: ts.TypeNode\n initializer?: ts.Expression\n },\n): ts.ParameterDeclaration {\n return factory.createParameterDeclaration(modifiers, dotDotDotToken, name, createQuestionToken(questionToken), type, initializer)\n}\n\nexport function createJSDoc({ comments }: { comments: string[] }) {\n if (!comments.length) {\n return null\n }\n return factory.createJSDocComment(\n factory.createNodeArray(\n comments.map((comment, i) => {\n if (i === comments.length - 1) {\n return factory.createJSDocText(comment)\n }\n\n return factory.createJSDocText(`${comment}\\n`)\n }),\n ),\n )\n}\n\n/**\n * @link https://github.com/microsoft/TypeScript/issues/44151\n */\nexport function appendJSDocToNode<TNode extends ts.Node>({ node, comments }: { node: TNode; comments: Array<string | undefined> }) {\n const filteredComments = comments.filter(Boolean)\n\n if (!filteredComments.length) {\n return node\n }\n\n const text = filteredComments.reduce((acc = '', comment = '') => {\n return `${acc}\\n * ${comment.replaceAll('*/', '*\\\\/')}`\n }, '*')\n\n // node: {...node}, with that ts.addSyntheticLeadingComment is appending\n return ts.addSyntheticLeadingComment({ ...node }, ts.SyntaxKind.MultiLineCommentTrivia, `${text || '*'}\\n`, true)\n}\n\nexport function createIndexSignature(\n type: ts.TypeNode,\n {\n modifiers,\n indexName = 'key',\n indexType = factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword),\n }: {\n indexName?: string\n indexType?: ts.TypeNode\n decorators?: Array<ts.Decorator>\n modifiers?: Array<ts.Modifier>\n } = {},\n) {\n return factory.createIndexSignature(modifiers, [createParameterSignature(indexName, { type: indexType })], type)\n}\n\nexport function createTypeAliasDeclaration({\n modifiers,\n name,\n typeParameters,\n type,\n}: {\n modifiers?: Array<ts.Modifier>\n name: string | ts.Identifier\n typeParameters?: Array<ts.TypeParameterDeclaration>\n type: ts.TypeNode\n}) {\n return factory.createTypeAliasDeclaration(modifiers, name, typeParameters, type)\n}\n\nexport function createInterfaceDeclaration({\n modifiers,\n name,\n typeParameters,\n members,\n}: {\n modifiers?: Array<ts.Modifier>\n name: string | ts.Identifier\n typeParameters?: Array<ts.TypeParameterDeclaration>\n members: Array<ts.TypeElement>\n}) {\n return factory.createInterfaceDeclaration(modifiers, name, typeParameters, undefined, members)\n}\n\nexport function createTypeDeclaration({\n syntax,\n isExportable,\n comments,\n name,\n type,\n}: {\n syntax: 'type' | 'interface'\n comments: Array<string | undefined>\n isExportable?: boolean\n name: string | ts.Identifier\n type: ts.TypeNode\n}) {\n if (syntax === 'interface' && 'members' in type) {\n const node = createInterfaceDeclaration({\n members: type.members as Array<ts.TypeElement>,\n modifiers: isExportable ? [modifiers.export] : [],\n name,\n typeParameters: undefined,\n })\n\n return appendJSDocToNode({\n node,\n comments,\n })\n }\n\n const node = createTypeAliasDeclaration({\n type,\n modifiers: isExportable ? [modifiers.export] : [],\n name,\n typeParameters: undefined,\n })\n\n return appendJSDocToNode({\n node,\n comments,\n })\n}\n\nexport function createNamespaceDeclaration({ statements, name }: { name: string; statements: ts.Statement[] }) {\n return factory.createModuleDeclaration(\n [factory.createToken(ts.SyntaxKind.ExportKeyword)],\n factory.createIdentifier(name),\n factory.createModuleBlock(statements),\n ts.NodeFlags.Namespace,\n )\n}\n\n/**\n * In { propertyName: string; name?: string } is `name` being used to make the type more unique when multiple same names are used.\n * @example `import { Pet as Cat } from './Pet'`\n */\nexport function createImportDeclaration({\n name,\n path,\n isTypeOnly = false,\n isNameSpace = false,\n}: {\n name: string | Array<string | { propertyName: string; name?: string }>\n path: string\n isTypeOnly?: boolean\n isNameSpace?: boolean\n}) {\n if (!Array.isArray(name)) {\n let importPropertyName: ts.Identifier | undefined = factory.createIdentifier(name)\n let importName: ts.NamedImportBindings | undefined\n\n if (isNameSpace) {\n importPropertyName = undefined\n importName = factory.createNamespaceImport(factory.createIdentifier(name))\n }\n\n return factory.createImportDeclaration(\n undefined,\n factory.createImportClause(isTypeOnly, importPropertyName, importName),\n factory.createStringLiteral(path),\n undefined,\n )\n }\n\n return factory.createImportDeclaration(\n undefined,\n factory.createImportClause(\n isTypeOnly,\n undefined,\n factory.createNamedImports(\n name.map((item) => {\n if (typeof item === 'object') {\n const obj = item as { propertyName: string; name?: string }\n if (obj.name) {\n return factory.createImportSpecifier(false, factory.createIdentifier(obj.propertyName), factory.createIdentifier(obj.name))\n }\n\n return factory.createImportSpecifier(false, undefined, factory.createIdentifier(obj.propertyName))\n }\n\n return factory.createImportSpecifier(false, undefined, factory.createIdentifier(item))\n }),\n ),\n ),\n factory.createStringLiteral(path),\n undefined,\n )\n}\n\nexport function createExportDeclaration({\n path,\n asAlias,\n isTypeOnly = false,\n name,\n}: {\n path: string\n asAlias?: boolean\n isTypeOnly?: boolean\n name?: string | Array<ts.Identifier | string>\n}) {\n if (name && !Array.isArray(name) && !asAlias) {\n console.warn(`When using name as string, asAlias should be true ${name}`)\n }\n\n if (!Array.isArray(name)) {\n const parsedName = name?.match(/^\\d/) ? `_${name?.slice(1)}` : name\n\n return factory.createExportDeclaration(\n undefined,\n isTypeOnly,\n asAlias && parsedName ? factory.createNamespaceExport(factory.createIdentifier(parsedName)) : undefined,\n factory.createStringLiteral(path),\n undefined,\n )\n }\n\n return factory.createExportDeclaration(\n undefined,\n isTypeOnly,\n factory.createNamedExports(\n name.map((propertyName) => {\n return factory.createExportSpecifier(false, undefined, typeof propertyName === 'string' ? factory.createIdentifier(propertyName) : propertyName)\n }),\n ),\n factory.createStringLiteral(path),\n undefined,\n )\n}\n\nexport function createEnumDeclaration({\n type = 'enum',\n name,\n typeName,\n enums,\n}: {\n /**\n * @default `'enum'`\n */\n type?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal'\n /**\n * Enum name in camelCase.\n */\n name: string\n /**\n * Enum name in PascalCase.\n */\n typeName: string\n enums: [key: string | number, value: string | number | boolean][]\n}): [name: ts.Node | undefined, type: ts.Node] {\n if (type === 'literal') {\n return [\n undefined,\n factory.createTypeAliasDeclaration(\n [factory.createToken(ts.SyntaxKind.ExportKeyword)],\n factory.createIdentifier(typeName),\n undefined,\n factory.createUnionTypeNode(\n enums\n .map(([_key, value]) => {\n if (isNumber(value)) {\n return factory.createLiteralTypeNode(factory.createNumericLiteral(value?.toString()))\n }\n\n if (typeof value === 'boolean') {\n return factory.createLiteralTypeNode(value ? factory.createTrue() : factory.createFalse())\n }\n if (value) {\n return factory.createLiteralTypeNode(factory.createStringLiteral(value.toString()))\n }\n\n return undefined\n })\n .filter(Boolean),\n ),\n ),\n ]\n }\n\n if (type === 'enum' || type === 'constEnum') {\n return [\n undefined,\n factory.createEnumDeclaration(\n [factory.createToken(ts.SyntaxKind.ExportKeyword), type === 'constEnum' ? factory.createToken(ts.SyntaxKind.ConstKeyword) : undefined].filter(Boolean),\n factory.createIdentifier(typeName),\n enums\n .map(([key, value]) => {\n let initializer: ts.Expression = factory.createStringLiteral(value?.toString())\n const isExactNumber = Number.parseInt(value.toString(), 10) === value\n\n if (isExactNumber && isNumber(Number.parseInt(value.toString(), 10))) {\n initializer = factory.createNumericLiteral(value as number)\n }\n\n if (typeof value === 'boolean') {\n initializer = value ? factory.createTrue() : factory.createFalse()\n }\n\n if (isNumber(Number.parseInt(key.toString(), 10))) {\n return factory.createEnumMember(factory.createStringLiteral(`${typeName}_${key}`), initializer)\n }\n\n if (key) {\n return factory.createEnumMember(factory.createStringLiteral(`${key}`), initializer)\n }\n\n return undefined\n })\n .filter(Boolean),\n ),\n ]\n }\n\n // used when using `as const` instead of an TypeScript enum.\n const identifierName = type === 'asPascalConst' ? typeName : name\n\n return [\n factory.createVariableStatement(\n [factory.createToken(ts.SyntaxKind.ExportKeyword)],\n factory.createVariableDeclarationList(\n [\n factory.createVariableDeclaration(\n factory.createIdentifier(identifierName),\n undefined,\n undefined,\n factory.createAsExpression(\n factory.createObjectLiteralExpression(\n enums\n .map(([key, value]) => {\n let initializer: ts.Expression = factory.createStringLiteral(value?.toString())\n\n if (isNumber(value)) {\n // Error: Negative numbers should be created in combination with createPrefixUnaryExpression factory.\n // The method createNumericLiteral only accepts positive numbers\n // or those combined with createPrefixUnaryExpression.\n // Therefore, we need to ensure that the number is not negative.\n if (value < 0) {\n initializer = factory.createPrefixUnaryExpression(ts.SyntaxKind.MinusToken, factory.createNumericLiteral(Math.abs(value)))\n } else {\n initializer = factory.createNumericLiteral(value)\n }\n }\n\n if (typeof value === 'boolean') {\n initializer = value ? factory.createTrue() : factory.createFalse()\n }\n\n if (key) {\n return factory.createPropertyAssignment(factory.createStringLiteral(`${key}`), initializer)\n }\n\n return undefined\n })\n .filter(Boolean),\n true,\n ),\n factory.createTypeReferenceNode(factory.createIdentifier('const'), undefined),\n ),\n ),\n ],\n ts.NodeFlags.Const,\n ),\n ),\n factory.createTypeAliasDeclaration(\n type === 'asPascalConst' ? [] : [factory.createToken(ts.SyntaxKind.ExportKeyword)],\n factory.createIdentifier(typeName),\n undefined,\n factory.createIndexedAccessTypeNode(\n factory.createParenthesizedType(factory.createTypeQueryNode(factory.createIdentifier(identifierName), undefined)),\n factory.createTypeOperatorNode(ts.SyntaxKind.KeyOfKeyword, factory.createTypeQueryNode(factory.createIdentifier(identifierName), undefined)),\n ),\n ),\n ]\n}\n\nexport function createOmitDeclaration({ keys, type, nonNullable }: { keys: Array<string> | string; type: ts.TypeNode; nonNullable?: boolean }) {\n const node = nonNullable ? factory.createTypeReferenceNode(factory.createIdentifier('NonNullable'), [type]) : type\n\n if (Array.isArray(keys)) {\n return factory.createTypeReferenceNode(factory.createIdentifier('Omit'), [\n node,\n factory.createUnionTypeNode(\n keys.map((key) => {\n return factory.createLiteralTypeNode(factory.createStringLiteral(key))\n }),\n ),\n ])\n }\n\n return factory.createTypeReferenceNode(factory.createIdentifier('Omit'), [node, factory.createLiteralTypeNode(factory.createStringLiteral(keys))])\n}\n\nexport const keywordTypeNodes = {\n any: factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword),\n unknown: factory.createKeywordTypeNode(ts.SyntaxKind.UnknownKeyword),\n void: factory.createKeywordTypeNode(ts.SyntaxKind.VoidKeyword),\n number: factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword),\n integer: factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword),\n object: factory.createKeywordTypeNode(ts.SyntaxKind.ObjectKeyword),\n string: factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword),\n boolean: factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword),\n undefined: factory.createKeywordTypeNode(ts.SyntaxKind.UndefinedKeyword),\n null: factory.createLiteralTypeNode(factory.createToken(ts.SyntaxKind.NullKeyword)),\n} as const\n\nexport const createTypeLiteralNode = factory.createTypeLiteralNode\n\nexport const createTypeReferenceNode = factory.createTypeReferenceNode\nexport const createNumericLiteral = factory.createNumericLiteral\nexport const createStringLiteral = factory.createStringLiteral\n\nexport const createArrayTypeNode = factory.createArrayTypeNode\n\nexport const createLiteralTypeNode = factory.createLiteralTypeNode\nexport const createNull = factory.createNull\nexport const createIdentifier = factory.createIdentifier\n\nexport const createOptionalTypeNode = factory.createOptionalTypeNode\nexport const createTupleTypeNode = factory.createTupleTypeNode\nexport const createRestTypeNode = factory.createRestTypeNode\nexport const createTrue = factory.createTrue\nexport const createFalse = factory.createFalse\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,MAAM,EAAE,YAAY,YAAYA;AAIhC,MAAa,YAAY;CACvB,OAAO,QAAQ,eAAeA,mBAAG,WAAW,aAAa;CACzD,QAAQ,QAAQ,eAAeA,mBAAG,WAAW,cAAc;CAC3D,OAAO,QAAQ,eAAeA,mBAAG,WAAW,aAAa;CACzD,QAAQ,QAAQ,eAAeA,mBAAG,WAAW,cAAc;CAC5D;AAED,MAAa,aAAa,EACxB,OAAO,WAAW,WACnB;AAED,SAAS,kBAAkB,KAAsB;AAC/C,KAAI,CAAC,IAAI,UAAU,IAAI,MAAM,KAAK,IAChC,QAAO;CAET,MAAM,OAAOA,mBAAG,wBAAwB,KAAKA,mBAAG,aAAa,OAAO;AAEpE,QAAO,CAAC,CAAC,QAAQ,KAAK,SAASA,mBAAG,WAAW,cAAcA,mBAAG,wBAAwB,KAAK,KAAiC,KAAK;;AAGnI,SAAS,aAAa,MAAiD;AACrE,KAAI,OAAO,SAAS,SAClB,QAAO,kBA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