@nestia/migrate 12.0.0-rc.2 → 12.0.0-rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/LICENSE +21 -21
  2. package/lib/_virtual/_tstl.mjs +2 -2
  3. package/lib/_virtual/index.mjs +2 -2
  4. package/lib/_virtual/index2.mjs +2 -2
  5. package/lib/_virtual/index3.mjs +2 -2
  6. package/lib/archivers/NestiaMigrateFileArchiver2.mjs +2 -2
  7. package/lib/archivers/NestiaMigrateFileArchiver2.mjs.map +1 -1
  8. package/lib/bundles/NEST_TEMPLATE.js +47 -47
  9. package/lib/bundles/NEST_TEMPLATE.js.map +1 -1
  10. package/lib/bundles/NEST_TEMPLATE2.mjs +47 -47
  11. package/lib/bundles/NEST_TEMPLATE2.mjs.map +1 -1
  12. package/lib/bundles/SDK_TEMPLATE.js +20 -20
  13. package/lib/bundles/SDK_TEMPLATE.js.map +1 -1
  14. package/lib/bundles/SDK_TEMPLATE2.mjs +20 -20
  15. package/lib/bundles/SDK_TEMPLATE2.mjs.map +1 -1
  16. package/lib/index2.mjs +1 -1
  17. package/lib/module2.mjs +2 -2
  18. package/lib/programmers/NestiaMigrateApiProgrammer2.mjs +4 -4
  19. package/lib/programmers/NestiaMigrateApiProgrammer2.mjs.map +1 -1
  20. package/lib/programmers/index2.mjs +1 -1
  21. package/lib/structures/index2.mjs +1 -1
  22. package/package.json +6 -6
  23. package/src/NestiaMigrateApplication.ts +196 -196
  24. package/src/analyzers/NestiaMigrateControllerAnalyzer.ts +51 -51
  25. package/src/archivers/NestiaMigrateFileArchiver.ts +28 -28
  26. package/src/bundles/NEST_TEMPLATE.ts +47 -47
  27. package/src/bundles/SDK_TEMPLATE.ts +20 -20
  28. package/src/executable/NestiaMigrateCommander.ts +115 -115
  29. package/src/executable/NestiaMigrateInquirer.ts +106 -106
  30. package/src/executable/bundle.js +323 -349
  31. package/src/executable/migrate.ts +7 -7
  32. package/src/factories/ExpressionFactory.ts +23 -23
  33. package/src/factories/FormatCheatSheet.ts +71 -71
  34. package/src/factories/IdentifierFactory.ts +84 -84
  35. package/src/factories/LiteralFactory.ts +54 -54
  36. package/src/factories/StatementFactory.ts +56 -56
  37. package/src/factories/TypeFactory.ts +27 -27
  38. package/src/factories/TypeLiteralFactory.ts +62 -62
  39. package/src/index.ts +4 -4
  40. package/src/internal/ts.ts +75 -75
  41. package/src/module.ts +6 -6
  42. package/src/programmers/NestiaMigrateApiFileProgrammer.ts +55 -55
  43. package/src/programmers/NestiaMigrateApiFunctionProgrammer.ts +358 -358
  44. package/src/programmers/NestiaMigrateApiNamespaceProgrammer.ts +511 -511
  45. package/src/programmers/NestiaMigrateApiProgrammer.ts +108 -108
  46. package/src/programmers/NestiaMigrateApiSimulationProgrammer.ts +309 -309
  47. package/src/programmers/NestiaMigrateApiStartProgrammer.ts +198 -198
  48. package/src/programmers/NestiaMigrateDtoProgrammer.ts +117 -117
  49. package/src/programmers/NestiaMigrateE2eFileProgrammer.ts +155 -155
  50. package/src/programmers/NestiaMigrateE2eProgrammer.ts +48 -48
  51. package/src/programmers/NestiaMigrateImportProgrammer.ts +119 -119
  52. package/src/programmers/NestiaMigrateNestControllerProgrammer.ts +70 -70
  53. package/src/programmers/NestiaMigrateNestMethodProgrammer.ts +402 -402
  54. package/src/programmers/NestiaMigrateNestModuleProgrammer.ts +64 -64
  55. package/src/programmers/NestiaMigrateNestProgrammer.ts +89 -89
  56. package/src/programmers/NestiaMigrateSchemaProgrammer.ts +475 -475
  57. package/src/programmers/index.ts +15 -15
  58. package/src/structures/INestiaMigrateConfig.ts +19 -19
  59. package/src/structures/INestiaMigrateContext.ts +9 -9
  60. package/src/structures/INestiaMigrateController.ts +8 -8
  61. package/src/structures/INestiaMigrateFile.ts +5 -5
  62. package/src/structures/index.ts +4 -4
  63. package/src/utils/FilePrinter.ts +44 -44
  64. package/src/utils/MapUtil.ts +13 -13
  65. package/src/utils/StringUtil.ts +109 -109
  66. package/README.md +0 -93
@@ -1,7 +1,7 @@
1
- #!/usr/bin/env node
2
- import { NestiaMigrateCommander } from "./NestiaMigrateCommander";
3
-
4
- NestiaMigrateCommander.main().catch((exp) => {
5
- console.error(exp);
6
- process.exit(-1);
7
- });
1
+ #!/usr/bin/env node
2
+ import { NestiaMigrateCommander } from "./NestiaMigrateCommander";
3
+
4
+ NestiaMigrateCommander.main().catch((exp) => {
5
+ console.error(exp);
6
+ process.exit(-1);
7
+ });
@@ -1,23 +1,23 @@
1
- import {
2
- type NumericLiteral,
3
- type PrefixUnaryExpression,
4
- SyntaxKind,
5
- factory,
6
- } from "@ttsc/factory";
7
-
8
- /**
9
- * Numeric-literal helper that handles negative values via a leading
10
- * `MinusToken` prefix unary, matching how the TypeScript factory itself emits
11
- * negative numeric literals.
12
- */
13
- export namespace ExpressionFactory {
14
- export const number = (
15
- value: number,
16
- ): NumericLiteral | PrefixUnaryExpression =>
17
- value < 0
18
- ? factory.createPrefixUnaryExpression(
19
- SyntaxKind.MinusToken,
20
- factory.createNumericLiteral(Math.abs(value)),
21
- )
22
- : factory.createNumericLiteral(value);
23
- }
1
+ import {
2
+ type NumericLiteral,
3
+ type PrefixUnaryExpression,
4
+ SyntaxKind,
5
+ factory,
6
+ } from "@ttsc/factory";
7
+
8
+ /**
9
+ * Numeric-literal helper that handles negative values via a leading
10
+ * `MinusToken` prefix unary, matching how the TypeScript factory itself emits
11
+ * negative numeric literals.
12
+ */
13
+ export namespace ExpressionFactory {
14
+ export const number = (
15
+ value: number,
16
+ ): NumericLiteral | PrefixUnaryExpression =>
17
+ value < 0
18
+ ? factory.createPrefixUnaryExpression(
19
+ SyntaxKind.MinusToken,
20
+ factory.createNumericLiteral(Math.abs(value)),
21
+ )
22
+ : factory.createNumericLiteral(value);
23
+ }
@@ -1,71 +1,71 @@
1
- const RegexCall = <Text extends string>(text: Text) =>
2
- `${text}.test($input)` as const;
3
-
4
- /** @reference https://github.dev/ajv-validator/ajv-formats/blob/master/src/formats.ts */
5
- export const FormatCheatSheet = {
6
- // SPECIAL CHARACTERS
7
- byte: RegexCall(
8
- `/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm`,
9
- ),
10
- password: `true`,
11
- regex: `(() => { try { new RegExp($input); return true; } catch { return false; } })()`,
12
- uuid: RegexCall(
13
- `/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i`,
14
- ),
15
-
16
- // ADDRESSES
17
- email: RegexCall(
18
- `/^[a-z0-9!#$%&'*+/=?^_\`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_\`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i`,
19
- ),
20
- hostname: RegexCall(
21
- `/^(?=.{1,253}\\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\\.?$/i`,
22
- ),
23
- "idn-email": RegexCall(
24
- `/^(([^<>()[\\]\\.,;:\\s@\\"]+(\\.[^<>()[\\]\\.,;:\\s@\\"]+)*)|(\\".+\\"))@(([^<>()[\\]\\.,;:\\s@\\"]+\\.)+[^<>()[\\]\\.,;:\\s@\\"]{2,})$/i`,
25
- ),
26
- "idn-hostname": RegexCall(
27
- `/^([a-z0-9\\u00a1-\\uffff0-9]+(-[a-z0-9\\u00a1-\\uffff0-9]+)*\\.)+[a-z\\u00a1-\\uffff]{2,}$/i`,
28
- ),
29
- iri: RegexCall(
30
- `/^[A-Za-z][\\d+-.A-Za-z]*:[^\\u0000-\\u0020"<>\\\\^\`{|}]*$/u`,
31
- ),
32
- "iri-reference": RegexCall(
33
- `/^[A-Za-z][\\d+-.A-Za-z]*:[^\\u0000-\\u0020"<>\\\\^\`{|}]*$/u`,
34
- ),
35
- ipv4: RegexCall(
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:[a-z0-9\\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\\/(?:[a-z0-9\\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\\/(?:[a-z0-9\\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\\?(?:[a-z0-9\\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i`,
46
- ),
47
- "uri-template": RegexCall(
48
- `/^(?:(?:[^\\x00-\\x20"'<>%\\\\^\`{|}]|%[0-9a-f]{2})|\\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\\*)?)*\\})*$/i`,
49
- ),
50
- url: RegexCall(
51
- `/^(?:https?|ftp):\\/\\/(?:\\S+(?::\\S*)?@)?(?:(?!(?:10|127)(?:\\.\\d{1,3}){3})(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z0-9\\u{00a1}-\\u{ffff}]+-)*[a-z0-9\\u{00a1}-\\u{ffff}]+)(?:\\.(?:[a-z0-9\\u{00a1}-\\u{ffff}]+-)*[a-z0-9\\u{00a1}-\\u{ffff}]+)*(?:\\.(?:[a-z\\u{00a1}-\\u{ffff}]{2,})))(?::\\d{2,5})?(?:\\/[^\\s]*)?$/iu`,
52
- ),
53
-
54
- // TIMESTAMPS
55
- "date-time": RegexCall(
56
- `/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])(T|\\s)([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]{1,9})?(Z|[+-]([01][0-9]|2[0-3]):[0-5][0-9])$/i`,
57
- ),
58
- date: RegexCall(`/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/`),
59
- time: RegexCall(
60
- `/^([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]{1,9})?(Z|[+-]([01][0-9]|2[0-3]):[0-5][0-9])$/i`,
61
- ),
62
- duration: RegexCall(
63
- `/^P(?!$)((\\d+Y)?(\\d+M)?(\\d+D)?(T(?=\\d)(\\d+H)?(\\d+M)?(\\d+S)?)?|(\\d+W)?)$/`,
64
- ),
65
-
66
- // POINTERS
67
- "json-pointer": RegexCall(`/^(?:\\/(?:[^~/]|~0|~1)*)*$/`),
68
- "relative-json-pointer": RegexCall(
69
- `/^(?:0|[1-9][0-9]*)(?:#|(?:\\/(?:[^~/]|~0|~1)*)*)$/`,
70
- ),
71
- } as const;
1
+ const RegexCall = <Text extends string>(text: Text) =>
2
+ `${text}.test($input)` as const;
3
+
4
+ /** @reference https://github.dev/ajv-validator/ajv-formats/blob/master/src/formats.ts */
5
+ export const FormatCheatSheet = {
6
+ // SPECIAL CHARACTERS
7
+ byte: RegexCall(
8
+ `/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm`,
9
+ ),
10
+ password: `true`,
11
+ regex: `(() => { try { new RegExp($input); return true; } catch { return false; } })()`,
12
+ uuid: RegexCall(
13
+ `/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i`,
14
+ ),
15
+
16
+ // ADDRESSES
17
+ email: RegexCall(
18
+ `/^[a-z0-9!#$%&'*+/=?^_\`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_\`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i`,
19
+ ),
20
+ hostname: RegexCall(
21
+ `/^(?=.{1,253}\\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\\.?$/i`,
22
+ ),
23
+ "idn-email": RegexCall(
24
+ `/^(([^<>()[\\]\\.,;:\\s@\\"]+(\\.[^<>()[\\]\\.,;:\\s@\\"]+)*)|(\\".+\\"))@(([^<>()[\\]\\.,;:\\s@\\"]+\\.)+[^<>()[\\]\\.,;:\\s@\\"]{2,})$/i`,
25
+ ),
26
+ "idn-hostname": RegexCall(
27
+ `/^([a-z0-9\\u00a1-\\uffff0-9]+(-[a-z0-9\\u00a1-\\uffff0-9]+)*\\.)+[a-z\\u00a1-\\uffff]{2,}$/i`,
28
+ ),
29
+ iri: RegexCall(
30
+ `/^[A-Za-z][\\d+-.A-Za-z]*:[^\\u0000-\\u0020"<>\\\\^\`{|}]*$/u`,
31
+ ),
32
+ "iri-reference": RegexCall(
33
+ `/^[A-Za-z][\\d+-.A-Za-z]*:[^\\u0000-\\u0020"<>\\\\^\`{|}]*$/u`,
34
+ ),
35
+ ipv4: RegexCall(
36
+ `/^(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)$/`,
37
+ ),
38
+ ipv6: RegexCall(
39
+ `/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[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 ),
47
+ "uri-template": RegexCall(
48
+ `/^(?:(?:[^\\x00-\\x20"'<>%\\\\^\`{|}]|%[0-9a-f]{2})|\\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\\*)?)*\\})*$/i`,
49
+ ),
50
+ url: RegexCall(
51
+ `/^(?:https?|ftp):\\/\\/(?:\\S+(?::\\S*)?@)?(?:(?!(?:10|127)(?:\\.\\d{1,3}){3})(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z0-9\\u{00a1}-\\u{ffff}]+-)*[a-z0-9\\u{00a1}-\\u{ffff}]+)(?:\\.(?:[a-z0-9\\u{00a1}-\\u{ffff}]+-)*[a-z0-9\\u{00a1}-\\u{ffff}]+)*(?:\\.(?:[a-z\\u{00a1}-\\u{ffff}]{2,})))(?::\\d{2,5})?(?:\\/[^\\s]*)?$/iu`,
52
+ ),
53
+
54
+ // TIMESTAMPS
55
+ "date-time": RegexCall(
56
+ `/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])(T|\\s)([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]{1,9})?(Z|[+-]([01][0-9]|2[0-3]):[0-5][0-9])$/i`,
57
+ ),
58
+ date: RegexCall(`/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/`),
59
+ time: RegexCall(
60
+ `/^([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]{1,9})?(Z|[+-]([01][0-9]|2[0-3]):[0-5][0-9])$/i`,
61
+ ),
62
+ duration: RegexCall(
63
+ `/^P(?!$)((\\d+Y)?(\\d+M)?(\\d+D)?(T(?=\\d)(\\d+H)?(\\d+M)?(\\d+S)?)?|(\\d+W)?)$/`,
64
+ ),
65
+
66
+ // POINTERS
67
+ "json-pointer": RegexCall(`/^(?:\\/(?:[^~/]|~0|~1)*)*$/`),
68
+ "relative-json-pointer": RegexCall(
69
+ `/^(?:0|[1-9][0-9]*)(?:#|(?:\\/(?:[^~/]|~0|~1)*)*)$/`,
70
+ ),
71
+ } as const;
@@ -1,84 +1,84 @@
1
- import {
2
- type Expression,
3
- type Identifier,
4
- type ParameterDeclaration,
5
- type StringLiteral,
6
- SyntaxKind,
7
- type Token,
8
- type TypeNode,
9
- factory,
10
- } from "@ttsc/factory";
11
-
12
- import { TypeFactory } from "./TypeFactory";
13
-
14
- // Conservative "is this string a syntactically valid JavaScript variable
15
- // name?" test, inlined to avoid pulling in @typia/utils' full namespace.
16
- const VARIABLE_REGEX = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
17
- const isVariableName = (str: string): boolean => VARIABLE_REGEX.test(str);
18
-
19
- /**
20
- * Identifier and member-access helpers. The surface kept here is the subset
21
- * nestia generators actually call (`identifier`, `access`, `parameter`).
22
- */
23
- export namespace IdentifierFactory {
24
- /**
25
- * Build an identifier or string literal depending on whether `name` is a
26
- * valid JavaScript identifier.
27
- */
28
- export const identifier = (name: string): Identifier | StringLiteral =>
29
- isVariableName(name)
30
- ? factory.createIdentifier(name)
31
- : factory.createStringLiteral(name);
32
-
33
- /**
34
- * Member access on `input` by `key`. Falls back to element access when the
35
- * key is not a valid identifier.
36
- */
37
- export const access = (
38
- input: Expression,
39
- key: string,
40
- chain?: boolean,
41
- ): Expression => {
42
- const postfix = identifier(key);
43
- if (postfix.kind === "StringLiteral")
44
- return chain === true
45
- ? factory.createElementAccessChain(
46
- input,
47
- factory.createToken(SyntaxKind.QuestionDotToken),
48
- postfix,
49
- )
50
- : factory.createElementAccessExpression(input, postfix);
51
- return chain === true
52
- ? factory.createPropertyAccessChain(
53
- input,
54
- factory.createToken(SyntaxKind.QuestionDotToken),
55
- postfix,
56
- )
57
- : factory.createPropertyAccessExpression(input, postfix);
58
- };
59
-
60
- /**
61
- * Parameter declaration with default `any` type when the caller omits one.
62
- * Passing a `QuestionToken` as `init` marks the parameter optional.
63
- */
64
- export const parameter = (
65
- name: string | Identifier,
66
- type?: TypeNode,
67
- init?: Expression | Token,
68
- ): ParameterDeclaration => {
69
- const isQuestionToken =
70
- !!init &&
71
- init.kind === "Token" &&
72
- (init as Token).token === SyntaxKind.QuestionToken;
73
- return factory.createParameterDeclaration(
74
- undefined,
75
- undefined,
76
- name,
77
- isQuestionToken
78
- ? factory.createToken(SyntaxKind.QuestionToken)
79
- : undefined,
80
- type ?? TypeFactory.keyword("any"),
81
- isQuestionToken ? undefined : (init as Expression | undefined),
82
- );
83
- };
84
- }
1
+ import {
2
+ type Expression,
3
+ type Identifier,
4
+ type ParameterDeclaration,
5
+ type StringLiteral,
6
+ SyntaxKind,
7
+ type Token,
8
+ type TypeNode,
9
+ factory,
10
+ } from "@ttsc/factory";
11
+
12
+ import { TypeFactory } from "./TypeFactory";
13
+
14
+ // Conservative "is this string a syntactically valid JavaScript variable
15
+ // name?" test, inlined to avoid pulling in @typia/utils' full namespace.
16
+ const VARIABLE_REGEX = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
17
+ const isVariableName = (str: string): boolean => VARIABLE_REGEX.test(str);
18
+
19
+ /**
20
+ * Identifier and member-access helpers. The surface kept here is the subset
21
+ * nestia generators actually call (`identifier`, `access`, `parameter`).
22
+ */
23
+ export namespace IdentifierFactory {
24
+ /**
25
+ * Build an identifier or string literal depending on whether `name` is a
26
+ * valid JavaScript identifier.
27
+ */
28
+ export const identifier = (name: string): Identifier | StringLiteral =>
29
+ isVariableName(name)
30
+ ? factory.createIdentifier(name)
31
+ : factory.createStringLiteral(name);
32
+
33
+ /**
34
+ * Member access on `input` by `key`. Falls back to element access when the
35
+ * key is not a valid identifier.
36
+ */
37
+ export const access = (
38
+ input: Expression,
39
+ key: string,
40
+ chain?: boolean,
41
+ ): Expression => {
42
+ const postfix = identifier(key);
43
+ if (postfix.kind === "StringLiteral")
44
+ return chain === true
45
+ ? factory.createElementAccessChain(
46
+ input,
47
+ factory.createToken(SyntaxKind.QuestionDotToken),
48
+ postfix,
49
+ )
50
+ : factory.createElementAccessExpression(input, postfix);
51
+ return chain === true
52
+ ? factory.createPropertyAccessChain(
53
+ input,
54
+ factory.createToken(SyntaxKind.QuestionDotToken),
55
+ postfix,
56
+ )
57
+ : factory.createPropertyAccessExpression(input, postfix);
58
+ };
59
+
60
+ /**
61
+ * Parameter declaration with default `any` type when the caller omits one.
62
+ * Passing a `QuestionToken` as `init` marks the parameter optional.
63
+ */
64
+ export const parameter = (
65
+ name: string | Identifier,
66
+ type?: TypeNode,
67
+ init?: Expression | Token,
68
+ ): ParameterDeclaration => {
69
+ const isQuestionToken =
70
+ !!init &&
71
+ init.kind === "Token" &&
72
+ (init as Token).token === SyntaxKind.QuestionToken;
73
+ return factory.createParameterDeclaration(
74
+ undefined,
75
+ undefined,
76
+ name,
77
+ isQuestionToken
78
+ ? factory.createToken(SyntaxKind.QuestionToken)
79
+ : undefined,
80
+ type ?? TypeFactory.keyword("any"),
81
+ isQuestionToken ? undefined : (init as Expression | undefined),
82
+ );
83
+ };
84
+ }
@@ -1,54 +1,54 @@
1
- import { type Expression, factory } from "@ttsc/factory";
2
-
3
- import { ExpressionFactory } from "./ExpressionFactory";
4
- import { IdentifierFactory } from "./IdentifierFactory";
5
-
6
- const PASSTHROUGH_KINDS = new Set<string>([
7
- "ArrowFunction",
8
- "CallExpression",
9
- "Identifier",
10
- ]);
11
-
12
- const isNode = (value: unknown): value is Expression =>
13
- typeof value === "object" &&
14
- value !== null &&
15
- typeof (value as { kind?: unknown }).kind === "string";
16
-
17
- /**
18
- * Recursive value-to-AST-literal builder. Hands back already-AST inputs
19
- * unchanged (so callers can mix factory output with raw JS values inside the
20
- * same object/array), and emits the appropriate literal node otherwise.
21
- */
22
- export namespace LiteralFactory {
23
- export const write = (input: any): Expression => {
24
- if (input === null) return factory.createNull();
25
- if (isNode(input) && PASSTHROUGH_KINDS.has(input.kind)) return input;
26
- if (Array.isArray(input)) return writeArray(input);
27
- if (typeof input === "object") return writeObject(input as object);
28
- if (typeof input === "boolean")
29
- return input ? factory.createTrue() : factory.createFalse();
30
- if (typeof input === "number") return ExpressionFactory.number(input);
31
- if (typeof input === "string") return factory.createStringLiteral(input);
32
- if (typeof input === "bigint")
33
- return factory.createStringLiteral(input.toString());
34
- if (typeof input === "function")
35
- return factory.createIdentifier("undefined");
36
- throw new TypeError("LiteralFactory.write: unsupported input type.");
37
- };
38
-
39
- const writeObject = (obj: object): Expression =>
40
- factory.createObjectLiteralExpression(
41
- Object.entries(obj)
42
- .filter(([, value]) => value !== undefined)
43
- .map(([key, value]) =>
44
- factory.createPropertyAssignment(
45
- IdentifierFactory.identifier(key),
46
- write(value),
47
- ),
48
- ),
49
- true,
50
- );
51
-
52
- const writeArray = (array: readonly any[]): Expression =>
53
- factory.createArrayLiteralExpression(array.map(write), true);
54
- }
1
+ import { type Expression, factory } from "@ttsc/factory";
2
+
3
+ import { ExpressionFactory } from "./ExpressionFactory";
4
+ import { IdentifierFactory } from "./IdentifierFactory";
5
+
6
+ const PASSTHROUGH_KINDS = new Set<string>([
7
+ "ArrowFunction",
8
+ "CallExpression",
9
+ "Identifier",
10
+ ]);
11
+
12
+ const isNode = (value: unknown): value is Expression =>
13
+ typeof value === "object" &&
14
+ value !== null &&
15
+ typeof (value as { kind?: unknown }).kind === "string";
16
+
17
+ /**
18
+ * Recursive value-to-AST-literal builder. Hands back already-AST inputs
19
+ * unchanged (so callers can mix factory output with raw JS values inside the
20
+ * same object/array), and emits the appropriate literal node otherwise.
21
+ */
22
+ export namespace LiteralFactory {
23
+ export const write = (input: any): Expression => {
24
+ if (input === null) return factory.createNull();
25
+ if (isNode(input) && PASSTHROUGH_KINDS.has(input.kind)) return input;
26
+ if (Array.isArray(input)) return writeArray(input);
27
+ if (typeof input === "object") return writeObject(input as object);
28
+ if (typeof input === "boolean")
29
+ return input ? factory.createTrue() : factory.createFalse();
30
+ if (typeof input === "number") return ExpressionFactory.number(input);
31
+ if (typeof input === "string") return factory.createStringLiteral(input);
32
+ if (typeof input === "bigint")
33
+ return factory.createStringLiteral(input.toString());
34
+ if (typeof input === "function")
35
+ return factory.createIdentifier("undefined");
36
+ throw new TypeError("LiteralFactory.write: unsupported input type.");
37
+ };
38
+
39
+ const writeObject = (obj: object): Expression =>
40
+ factory.createObjectLiteralExpression(
41
+ Object.entries(obj)
42
+ .filter(([, value]) => value !== undefined)
43
+ .map(([key, value]) =>
44
+ factory.createPropertyAssignment(
45
+ IdentifierFactory.identifier(key),
46
+ write(value),
47
+ ),
48
+ ),
49
+ true,
50
+ );
51
+
52
+ const writeArray = (array: readonly any[]): Expression =>
53
+ factory.createArrayLiteralExpression(array.map(write), true);
54
+ }
@@ -1,56 +1,56 @@
1
- import {
2
- type Expression,
3
- NodeFlags,
4
- type TypeNode,
5
- type VariableStatement,
6
- factory,
7
- } from "@ttsc/factory";
8
-
9
- import { TypeFactory } from "./TypeFactory";
10
-
11
- /** Variable-statement helpers. `constant` emits `const`, `mut` emits `let`. */
12
- export namespace StatementFactory {
13
- export const mut = (props: {
14
- name: string;
15
- type?: TypeNode | undefined;
16
- initializer?: Expression | undefined;
17
- }): VariableStatement =>
18
- factory.createVariableStatement(
19
- undefined,
20
- factory.createVariableDeclarationList(
21
- [
22
- factory.createVariableDeclaration(
23
- props.name,
24
- undefined,
25
- props.type !== undefined
26
- ? props.type
27
- : props.initializer === undefined
28
- ? TypeFactory.keyword("any")
29
- : undefined,
30
- props.initializer,
31
- ),
32
- ],
33
- NodeFlags.Let,
34
- ),
35
- );
36
-
37
- export const constant = (props: {
38
- name: string;
39
- type?: TypeNode | undefined;
40
- value?: Expression | undefined;
41
- }): VariableStatement =>
42
- factory.createVariableStatement(
43
- undefined,
44
- factory.createVariableDeclarationList(
45
- [
46
- factory.createVariableDeclaration(
47
- props.name,
48
- undefined,
49
- props.type,
50
- props.value,
51
- ),
52
- ],
53
- NodeFlags.Const,
54
- ),
55
- );
56
- }
1
+ import {
2
+ type Expression,
3
+ NodeFlags,
4
+ type TypeNode,
5
+ type VariableStatement,
6
+ factory,
7
+ } from "@ttsc/factory";
8
+
9
+ import { TypeFactory } from "./TypeFactory";
10
+
11
+ /** Variable-statement helpers. `constant` emits `const`, `mut` emits `let`. */
12
+ export namespace StatementFactory {
13
+ export const mut = (props: {
14
+ name: string;
15
+ type?: TypeNode | undefined;
16
+ initializer?: Expression | undefined;
17
+ }): VariableStatement =>
18
+ factory.createVariableStatement(
19
+ undefined,
20
+ factory.createVariableDeclarationList(
21
+ [
22
+ factory.createVariableDeclaration(
23
+ props.name,
24
+ undefined,
25
+ props.type !== undefined
26
+ ? props.type
27
+ : props.initializer === undefined
28
+ ? TypeFactory.keyword("any")
29
+ : undefined,
30
+ props.initializer,
31
+ ),
32
+ ],
33
+ NodeFlags.Let,
34
+ ),
35
+ );
36
+
37
+ export const constant = (props: {
38
+ name: string;
39
+ type?: TypeNode | undefined;
40
+ value?: Expression | undefined;
41
+ }): VariableStatement =>
42
+ factory.createVariableStatement(
43
+ undefined,
44
+ factory.createVariableDeclarationList(
45
+ [
46
+ factory.createVariableDeclaration(
47
+ props.name,
48
+ undefined,
49
+ props.type,
50
+ props.value,
51
+ ),
52
+ ],
53
+ NodeFlags.Const,
54
+ ),
55
+ );
56
+ }