typia 5.2.2 → 5.2.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 (74) hide show
  1. package/lib/Primitive.d.ts +1 -1
  2. package/lib/executable/setup/CommandExecutor.js +2 -2
  3. package/lib/executable/setup/CommandExecutor.js.map +1 -1
  4. package/package.json +1 -2
  5. package/src/CamelCase.ts +116 -116
  6. package/src/PascalCase.ts +116 -116
  7. package/src/Primitive.ts +135 -135
  8. package/src/Resolved.ts +116 -116
  9. package/src/SnakeCase.ts +156 -156
  10. package/src/executable/TypiaSetupWizard.ts +142 -142
  11. package/src/executable/setup/CommandExecutor.ts +2 -2
  12. package/src/factories/JsonMetadataFactory.ts +50 -50
  13. package/src/factories/MetadataCollection.ts +282 -282
  14. package/src/functional/$convention.ts +40 -40
  15. package/src/functional/Namespace.ts +164 -164
  16. package/src/module.ts +662 -662
  17. package/src/notations.ts +855 -855
  18. package/src/programmers/helpers/AtomicPredicator.ts +31 -31
  19. package/src/programmers/helpers/NotationJoiner.ts +146 -146
  20. package/src/programmers/misc/MiscCloneProgrammer.ts +790 -790
  21. package/src/programmers/misc/MiscPruneProgrammer.ts +552 -552
  22. package/src/programmers/notations/NotationAssertGeneralProgrammer.ts +72 -72
  23. package/src/programmers/notations/NotationGeneralProgrammer.ts +720 -720
  24. package/src/programmers/notations/NotationIsGeneralProgrammer.ts +79 -79
  25. package/src/programmers/notations/NotationValidateGeneralProgrammer.ts +88 -88
  26. package/src/transformers/CallExpressionTransformer.ts +380 -380
  27. package/src/transformers/features/json/JsonAssertParseTransformer.ts +10 -10
  28. package/src/transformers/features/json/JsonAssertStringifyTransformer.ts +10 -10
  29. package/src/transformers/features/json/JsonCreateAssertParseTransformer.ts +12 -12
  30. package/src/transformers/features/json/JsonCreateAssertStringifyTransformer.ts +12 -12
  31. package/src/transformers/features/json/JsonCreateIsParseTransformer.ts +9 -9
  32. package/src/transformers/features/json/JsonCreateIsStringifyTransformer.ts +12 -12
  33. package/src/transformers/features/json/JsonCreateStringifyTransformer.ts +9 -9
  34. package/src/transformers/features/json/JsonCreateValidateParseTransformer.ts +12 -12
  35. package/src/transformers/features/json/JsonCreateValidateStringifyProgrammer.ts +12 -12
  36. package/src/transformers/features/json/JsonIsParseTransformer.ts +9 -9
  37. package/src/transformers/features/json/JsonIsStringifyTransformer.ts +10 -10
  38. package/src/transformers/features/json/JsonStringifyTransformer.ts +9 -9
  39. package/src/transformers/features/json/JsonValidateParseTransformer.ts +10 -10
  40. package/src/transformers/features/json/JsonValidateStringifyTransformer.ts +10 -10
  41. package/src/transformers/features/misc/MiscAssertCloneTransformer.ts +10 -10
  42. package/src/transformers/features/misc/MiscAssertPruneTransformer.ts +10 -10
  43. package/src/transformers/features/misc/MiscCloneTransformer.ts +9 -9
  44. package/src/transformers/features/misc/MiscCreateAssertCloneTransformer.ts +12 -12
  45. package/src/transformers/features/misc/MiscCreateAssertPruneTransformer.ts +12 -12
  46. package/src/transformers/features/misc/MiscCreateCloneTransformer.ts +9 -9
  47. package/src/transformers/features/misc/MiscCreateIsCloneTransformer.ts +9 -9
  48. package/src/transformers/features/misc/MiscCreateIsPruneTransformer.ts +9 -9
  49. package/src/transformers/features/misc/MiscCreatePruneTransformer.ts +9 -9
  50. package/src/transformers/features/misc/MiscCreateValidateCloneTransformer.ts +12 -12
  51. package/src/transformers/features/misc/MiscCreateValidatePruneTransformer.ts +12 -12
  52. package/src/transformers/features/misc/MiscIsCloneTransformer.ts +9 -9
  53. package/src/transformers/features/misc/MiscIsPruneTransformer.ts +9 -9
  54. package/src/transformers/features/misc/MiscPruneTransformer.ts +9 -9
  55. package/src/transformers/features/misc/MiscValidateCloneTransformer.ts +10 -10
  56. package/src/transformers/features/misc/MiscValidatePruneTransformer.ts +10 -10
  57. package/src/transformers/features/notations/NotationAssertGeneralTransformer.ts +15 -15
  58. package/src/transformers/features/notations/NotationCreateAssertGeneralTransformer.ts +15 -15
  59. package/src/transformers/features/notations/NotationCreateGeneralTransformer.ts +15 -15
  60. package/src/transformers/features/notations/NotationCreateIsGeneralTransformer.ts +15 -15
  61. package/src/transformers/features/notations/NotationCreateValidateGeneralTransformer.ts +17 -17
  62. package/src/transformers/features/notations/NotationGeneralTransformer.ts +11 -11
  63. package/src/transformers/features/notations/NotationIsGeneralTransformer.ts +15 -15
  64. package/src/transformers/features/notations/NotationValidateGeneralTransformer.ts +17 -17
  65. package/src/transformers/features/protobuf/ProtobufCreateAssertDecodeTransformer.ts +12 -12
  66. package/src/transformers/features/protobuf/ProtobufCreateAssertEncodeTransformer.ts +12 -12
  67. package/src/transformers/features/protobuf/ProtobufCreateDecodeTransformer.ts +9 -9
  68. package/src/transformers/features/protobuf/ProtobufCreateEncodeTransformer.ts +9 -9
  69. package/src/transformers/features/protobuf/ProtobufCreateIsDecodeTransformer.ts +12 -12
  70. package/src/transformers/features/protobuf/ProtobufCreateIsEncodeTransformer.ts +12 -12
  71. package/src/transformers/features/protobuf/ProtobufCreateValidateDecodeTransformer.ts +12 -12
  72. package/src/transformers/features/protobuf/ProtobufCreateValidateEncodeTransformer.ts +12 -12
  73. package/src/utils/NamingConvention.ts +91 -91
  74. package/src/utils/StringUtil.ts +4 -4
@@ -1,31 +1,31 @@
1
- import { Metadata } from "../../schemas/metadata/Metadata";
2
-
3
- import { Atomic } from "../../typings/Atomic";
4
-
5
- import { ArrayUtil } from "../../utils/ArrayUtil";
6
-
7
- export namespace AtomicPredicator {
8
- export const constant =
9
- (meta: Metadata) =>
10
- (name: Atomic.Literal): boolean =>
11
- !ArrayUtil.has(meta.atomics, (a) => a.type === name) &&
12
- !ArrayUtil.has(
13
- meta.natives,
14
- (native) => native.toLowerCase() === name,
15
- );
16
-
17
- export const atomic =
18
- (meta: Metadata) =>
19
- (name: Atomic.Literal): boolean =>
20
- !ArrayUtil.has(
21
- meta.natives,
22
- (native) => native.toLowerCase() === name,
23
- );
24
-
25
- export const native = (name: string) => LIKE.has(name.toLowerCase());
26
-
27
- export const template = (meta: Metadata): boolean =>
28
- !ArrayUtil.has(meta.atomics, (a) => a.type === "string");
29
- }
30
-
31
- const LIKE = new Set(["boolean", "bigint", "number", "string"]);
1
+ import { Metadata } from "../../schemas/metadata/Metadata";
2
+
3
+ import { Atomic } from "../../typings/Atomic";
4
+
5
+ import { ArrayUtil } from "../../utils/ArrayUtil";
6
+
7
+ export namespace AtomicPredicator {
8
+ export const constant =
9
+ (meta: Metadata) =>
10
+ (name: Atomic.Literal): boolean =>
11
+ !ArrayUtil.has(meta.atomics, (a) => a.type === name) &&
12
+ !ArrayUtil.has(
13
+ meta.natives,
14
+ (native) => native.toLowerCase() === name,
15
+ );
16
+
17
+ export const atomic =
18
+ (meta: Metadata) =>
19
+ (name: Atomic.Literal): boolean =>
20
+ !ArrayUtil.has(
21
+ meta.natives,
22
+ (native) => native.toLowerCase() === name,
23
+ );
24
+
25
+ export const native = (name: string) => LIKE.has(name.toLowerCase());
26
+
27
+ export const template = (meta: Metadata): boolean =>
28
+ !ArrayUtil.has(meta.atomics, (a) => a.type === "string");
29
+ }
30
+
31
+ const LIKE = new Set(["boolean", "bigint", "number", "string"]);
@@ -1,146 +1,146 @@
1
- import ts from "typescript";
2
-
3
- import { IdentifierFactory } from "../../factories/IdentifierFactory";
4
- import { StatementFactory } from "../../factories/StatementFactory";
5
- import { TypeFactory } from "../../factories/TypeFactory";
6
-
7
- import { Escaper } from "../../utils/Escaper";
8
-
9
- import { metadata_to_pattern } from "../internal/metadata_to_pattern";
10
- import { IExpressionEntry } from "./IExpressionEntry";
11
-
12
- export namespace NotationJoiner {
13
- export const object =
14
- (rename: (str: string) => string) =>
15
- (
16
- input: ts.Expression,
17
- entries: IExpressionEntry<ts.Expression>[],
18
- ): ts.ConciseBody => {
19
- if (entries.length === 0) return ts.factory.createIdentifier("{}");
20
-
21
- const regular = entries.filter((e) => e.key.isSoleLiteral());
22
- const dynamic = entries.filter((e) => !e.key.isSoleLiteral());
23
- const literal = ts.factory.createObjectLiteralExpression(
24
- regular.map((entry) => {
25
- const str: string = rename(entry.key.getSoleLiteral()!);
26
- return ts.factory.createPropertyAssignment(
27
- Escaper.variable(str)
28
- ? str
29
- : ts.factory.createStringLiteral(str),
30
- entry.expression,
31
- );
32
- }),
33
- true,
34
- );
35
- if (dynamic.length === 0) return literal;
36
-
37
- const key = ts.factory.createIdentifier("key");
38
- const output = ts.factory.createIdentifier("output");
39
-
40
- const statements: ts.Statement[] = [];
41
- if (regular.length !== 0)
42
- statements.push(
43
- ts.factory.createIfStatement(
44
- ts.factory.createCallExpression(
45
- IdentifierFactory.access(
46
- ts.factory.createArrayLiteralExpression(
47
- regular.map((r) =>
48
- ts.factory.createStringLiteral(
49
- r.key.getSoleLiteral()!,
50
- ),
51
- ),
52
- ),
53
- )("some"),
54
- undefined,
55
- [
56
- ts.factory.createArrowFunction(
57
- undefined,
58
- undefined,
59
- [IdentifierFactory.parameter("regular")],
60
- undefined,
61
- undefined,
62
- ts.factory.createStrictEquality(
63
- ts.factory.createIdentifier("regular"),
64
- ts.factory.createIdentifier("key"),
65
- ),
66
- ),
67
- ],
68
- ),
69
- ts.factory.createContinueStatement(),
70
- ),
71
- );
72
- statements.push(
73
- ...dynamic.map((entry) =>
74
- ts.factory.createIfStatement(
75
- ts.factory.createCallExpression(
76
- ts.factory.createIdentifier(
77
- `RegExp(/${metadata_to_pattern(true)(
78
- entry.key,
79
- )}/).test`,
80
- ),
81
- undefined,
82
- [key],
83
- ),
84
- ts.factory.createBlock([
85
- ts.factory.createExpressionStatement(
86
- ts.factory.createBinaryExpression(
87
- ts.factory.createElementAccessExpression(
88
- output,
89
- key,
90
- ),
91
- ts.factory.createToken(
92
- ts.SyntaxKind.EqualsToken,
93
- ),
94
- entry.expression,
95
- ),
96
- ),
97
- ts.factory.createContinueStatement(),
98
- ]),
99
- ),
100
- ),
101
- );
102
-
103
- return ts.factory.createBlock([
104
- StatementFactory.constant(
105
- "output",
106
- ts.factory.createAsExpression(
107
- literal,
108
- TypeFactory.keyword("any"),
109
- ),
110
- ),
111
- ts.factory.createForOfStatement(
112
- undefined,
113
- StatementFactory.entry("key")("value"),
114
- ts.factory.createCallExpression(
115
- ts.factory.createIdentifier("Object.entries"),
116
- undefined,
117
- [input],
118
- ),
119
- ts.factory.createBlock(statements),
120
- ),
121
- ts.factory.createReturnStatement(output),
122
- ]);
123
- };
124
-
125
- export const tuple = (
126
- children: ts.Expression[],
127
- rest: ts.Expression | null,
128
- ): ts.Expression => {
129
- return ts.factory.createAsExpression(
130
- ts.factory.createArrayLiteralExpression(
131
- rest === null
132
- ? children
133
- : [...children, ts.factory.createSpreadElement(rest)],
134
- true,
135
- ),
136
- TypeFactory.keyword("any"),
137
- );
138
- };
139
-
140
- export const array = (input: ts.Expression, arrow: ts.Expression) =>
141
- ts.factory.createCallExpression(
142
- ts.factory.createPropertyAccessExpression(input, "map"),
143
- undefined,
144
- [arrow],
145
- );
146
- }
1
+ import ts from "typescript";
2
+
3
+ import { IdentifierFactory } from "../../factories/IdentifierFactory";
4
+ import { StatementFactory } from "../../factories/StatementFactory";
5
+ import { TypeFactory } from "../../factories/TypeFactory";
6
+
7
+ import { Escaper } from "../../utils/Escaper";
8
+
9
+ import { metadata_to_pattern } from "../internal/metadata_to_pattern";
10
+ import { IExpressionEntry } from "./IExpressionEntry";
11
+
12
+ export namespace NotationJoiner {
13
+ export const object =
14
+ (rename: (str: string) => string) =>
15
+ (
16
+ input: ts.Expression,
17
+ entries: IExpressionEntry<ts.Expression>[],
18
+ ): ts.ConciseBody => {
19
+ if (entries.length === 0) return ts.factory.createIdentifier("{}");
20
+
21
+ const regular = entries.filter((e) => e.key.isSoleLiteral());
22
+ const dynamic = entries.filter((e) => !e.key.isSoleLiteral());
23
+ const literal = ts.factory.createObjectLiteralExpression(
24
+ regular.map((entry) => {
25
+ const str: string = rename(entry.key.getSoleLiteral()!);
26
+ return ts.factory.createPropertyAssignment(
27
+ Escaper.variable(str)
28
+ ? str
29
+ : ts.factory.createStringLiteral(str),
30
+ entry.expression,
31
+ );
32
+ }),
33
+ true,
34
+ );
35
+ if (dynamic.length === 0) return literal;
36
+
37
+ const key = ts.factory.createIdentifier("key");
38
+ const output = ts.factory.createIdentifier("output");
39
+
40
+ const statements: ts.Statement[] = [];
41
+ if (regular.length !== 0)
42
+ statements.push(
43
+ ts.factory.createIfStatement(
44
+ ts.factory.createCallExpression(
45
+ IdentifierFactory.access(
46
+ ts.factory.createArrayLiteralExpression(
47
+ regular.map((r) =>
48
+ ts.factory.createStringLiteral(
49
+ r.key.getSoleLiteral()!,
50
+ ),
51
+ ),
52
+ ),
53
+ )("some"),
54
+ undefined,
55
+ [
56
+ ts.factory.createArrowFunction(
57
+ undefined,
58
+ undefined,
59
+ [IdentifierFactory.parameter("regular")],
60
+ undefined,
61
+ undefined,
62
+ ts.factory.createStrictEquality(
63
+ ts.factory.createIdentifier("regular"),
64
+ ts.factory.createIdentifier("key"),
65
+ ),
66
+ ),
67
+ ],
68
+ ),
69
+ ts.factory.createContinueStatement(),
70
+ ),
71
+ );
72
+ statements.push(
73
+ ...dynamic.map((entry) =>
74
+ ts.factory.createIfStatement(
75
+ ts.factory.createCallExpression(
76
+ ts.factory.createIdentifier(
77
+ `RegExp(/${metadata_to_pattern(true)(
78
+ entry.key,
79
+ )}/).test`,
80
+ ),
81
+ undefined,
82
+ [key],
83
+ ),
84
+ ts.factory.createBlock([
85
+ ts.factory.createExpressionStatement(
86
+ ts.factory.createBinaryExpression(
87
+ ts.factory.createElementAccessExpression(
88
+ output,
89
+ key,
90
+ ),
91
+ ts.factory.createToken(
92
+ ts.SyntaxKind.EqualsToken,
93
+ ),
94
+ entry.expression,
95
+ ),
96
+ ),
97
+ ts.factory.createContinueStatement(),
98
+ ]),
99
+ ),
100
+ ),
101
+ );
102
+
103
+ return ts.factory.createBlock([
104
+ StatementFactory.constant(
105
+ "output",
106
+ ts.factory.createAsExpression(
107
+ literal,
108
+ TypeFactory.keyword("any"),
109
+ ),
110
+ ),
111
+ ts.factory.createForOfStatement(
112
+ undefined,
113
+ StatementFactory.entry("key")("value"),
114
+ ts.factory.createCallExpression(
115
+ ts.factory.createIdentifier("Object.entries"),
116
+ undefined,
117
+ [input],
118
+ ),
119
+ ts.factory.createBlock(statements),
120
+ ),
121
+ ts.factory.createReturnStatement(output),
122
+ ]);
123
+ };
124
+
125
+ export const tuple = (
126
+ children: ts.Expression[],
127
+ rest: ts.Expression | null,
128
+ ): ts.Expression => {
129
+ return ts.factory.createAsExpression(
130
+ ts.factory.createArrayLiteralExpression(
131
+ rest === null
132
+ ? children
133
+ : [...children, ts.factory.createSpreadElement(rest)],
134
+ true,
135
+ ),
136
+ TypeFactory.keyword("any"),
137
+ );
138
+ };
139
+
140
+ export const array = (input: ts.Expression, arrow: ts.Expression) =>
141
+ ts.factory.createCallExpression(
142
+ ts.factory.createPropertyAccessExpression(input, "map"),
143
+ undefined,
144
+ [arrow],
145
+ );
146
+ }