typia 7.0.0-dev.20241009-2 → 7.0.0-dev.20241010

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 (151) hide show
  1. package/lib/factories/JsonMetadataFactory.d.ts +5 -1
  2. package/lib/factories/JsonMetadataFactory.js +4 -1
  3. package/lib/factories/JsonMetadataFactory.js.map +1 -1
  4. package/lib/internal/{$httpFormDataReadArray.js → $httpFormdataReadArray.js} +1 -1
  5. package/lib/internal/$httpFormdataReadArray.js.map +1 -0
  6. package/lib/programmers/CheckerProgrammer.js +4 -1
  7. package/lib/programmers/CheckerProgrammer.js.map +1 -1
  8. package/lib/programmers/FeatureProgrammer.d.ts +4 -1
  9. package/lib/programmers/FeatureProgrammer.js +2 -2
  10. package/lib/programmers/FeatureProgrammer.js.map +1 -1
  11. package/lib/programmers/RandomProgrammer.js +12 -9
  12. package/lib/programmers/RandomProgrammer.js.map +1 -1
  13. package/lib/programmers/TypiaProgrammer.js +4 -1
  14. package/lib/programmers/TypiaProgrammer.js.map +1 -1
  15. package/lib/programmers/internal/prune_object_properties.js +3 -2
  16. package/lib/programmers/internal/prune_object_properties.js.map +1 -1
  17. package/lib/programmers/json/JsonAssertParseProgrammer.js +2 -2
  18. package/lib/programmers/json/JsonAssertParseProgrammer.js.map +1 -1
  19. package/lib/programmers/misc/MiscCloneProgrammer.js +4 -1
  20. package/lib/programmers/misc/MiscCloneProgrammer.js.map +1 -1
  21. package/lib/programmers/misc/MiscPruneProgrammer.js +4 -1
  22. package/lib/programmers/misc/MiscPruneProgrammer.js.map +1 -1
  23. package/lib/programmers/notations/NotationGeneralProgrammer.js +4 -1
  24. package/lib/programmers/notations/NotationGeneralProgrammer.js.map +1 -1
  25. package/lib/programmers/protobuf/ProtobufDecodeProgrammer.js +1 -1
  26. package/lib/programmers/protobuf/ProtobufDecodeProgrammer.js.map +1 -1
  27. package/lib/transformers/FileTransformer.js +0 -6
  28. package/lib/transformers/FileTransformer.js.map +1 -1
  29. package/lib/transformers/ImportTransformer.d.ts +4 -1
  30. package/lib/transformers/ImportTransformer.js +34 -30
  31. package/lib/transformers/ImportTransformer.js.map +1 -1
  32. package/package.json +1 -1
  33. package/src/IRandomGenerator.ts +49 -49
  34. package/src/factories/ExpressionFactory.ts +164 -164
  35. package/src/factories/JsonMetadataFactory.ts +25 -15
  36. package/src/factories/LiteralFactory.ts +50 -50
  37. package/src/factories/MetadataCommentTagFactory.ts +650 -650
  38. package/src/functional.ts +750 -750
  39. package/src/http.ts +1042 -1042
  40. package/src/internal/$IProtobufWriter.ts +18 -18
  41. package/src/internal/$ProtobufReader.ts +194 -194
  42. package/src/internal/$ProtobufSizer.ts +151 -151
  43. package/src/internal/$ProtobufWriter.ts +145 -145
  44. package/src/internal/$accessExpressionAsString.ts +46 -46
  45. package/src/internal/$assertGuard.ts +13 -13
  46. package/src/internal/$functionalTypeGuardErrorFactory.ts +4 -4
  47. package/src/internal/$httpFormDataReadBigint.ts +18 -18
  48. package/src/internal/$httpFormDataReadBlob.ts +10 -10
  49. package/src/internal/$httpFormDataReadBoolean.ts +16 -16
  50. package/src/internal/$httpFormDataReadFile.ts +10 -10
  51. package/src/internal/$httpFormDataReadNumber.ts +15 -15
  52. package/src/internal/$httpFormDataReadString.ts +10 -10
  53. package/src/internal/{$httpFormDataReadArray.ts → $httpFormdataReadArray.ts} +4 -4
  54. package/src/internal/$httpHeaderReadBigint.ts +10 -10
  55. package/src/internal/$httpHeaderReadBoolean.ts +8 -8
  56. package/src/internal/$httpHeaderReadNumber.ts +7 -7
  57. package/src/internal/$httpParameterBigint.ts +10 -10
  58. package/src/internal/$httpParameterBoolean.ts +8 -8
  59. package/src/internal/$httpParameterNumber.ts +7 -7
  60. package/src/internal/$httpParameterString.ts +2 -2
  61. package/src/internal/$httpQueryParseURLSearchParams.ts +10 -10
  62. package/src/internal/$httpQueryReadArray.ts +4 -4
  63. package/src/internal/$httpQueryReadBigint.ts +12 -12
  64. package/src/internal/$httpQueryReadBoolean.ts +14 -14
  65. package/src/internal/$httpQueryReadNumber.ts +9 -9
  66. package/src/internal/$httpQueryReadString.ts +4 -4
  67. package/src/internal/$isBetween.ts +2 -2
  68. package/src/internal/$isBigintString.ts +8 -8
  69. package/src/internal/$jsonStringifyNumber.ts +12 -12
  70. package/src/internal/$jsonStringifyRest.ts +3 -3
  71. package/src/internal/$jsonStringifyString.ts +42 -42
  72. package/src/internal/$jsonStringifyTail.ts +2 -2
  73. package/src/internal/$llmApplicationFinalize.ts +18 -18
  74. package/src/internal/$miscCloneAny.ts +48 -48
  75. package/src/internal/$notationAny.ts +37 -37
  76. package/src/internal/$notationCamel.ts +13 -13
  77. package/src/internal/$notationPascal.ts +8 -8
  78. package/src/internal/$notationSnake.ts +43 -43
  79. package/src/internal/$randomArray.ts +21 -21
  80. package/src/internal/$randomBigint.ts +6 -6
  81. package/src/internal/$randomBoolean.ts +1 -1
  82. package/src/internal/$randomFormatByte.ts +3 -3
  83. package/src/internal/$randomFormatDate.ts +18 -18
  84. package/src/internal/$randomFormatDatetime.ts +16 -16
  85. package/src/internal/$randomFormatDuration.ts +27 -27
  86. package/src/internal/$randomFormatEmail.ts +11 -11
  87. package/src/internal/$randomFormatHostname.ts +6 -6
  88. package/src/internal/$randomFormatIdnEmail.ts +3 -3
  89. package/src/internal/$randomFormatIdnHostname.ts +3 -3
  90. package/src/internal/$randomFormatIpv4.ts +11 -11
  91. package/src/internal/$randomFormatIpv6.ts +11 -11
  92. package/src/internal/$randomFormatIri.ts +3 -3
  93. package/src/internal/$randomFormatIriReference.ts +3 -3
  94. package/src/internal/$randomFormatJsonPointer.ts +7 -7
  95. package/src/internal/$randomFormatPassword.ts +8 -8
  96. package/src/internal/$randomFormatRegex.ts +4 -4
  97. package/src/internal/$randomFormatRelativeJsonPointer.ts +8 -8
  98. package/src/internal/$randomFormatTime.ts +14 -14
  99. package/src/internal/$randomFormatUri.ts +3 -3
  100. package/src/internal/$randomFormatUriReference.ts +3 -3
  101. package/src/internal/$randomFormatUriTemplate.ts +3 -3
  102. package/src/internal/$randomFormatUrl.ts +11 -11
  103. package/src/internal/$randomFormatUuid.ts +6 -6
  104. package/src/internal/$randomInteger.ts +47 -47
  105. package/src/internal/$randomNumber.ts +74 -74
  106. package/src/internal/$randomPattern.ts +10 -10
  107. package/src/internal/$randomPick.ts +9 -9
  108. package/src/internal/$randomString.ts +24 -24
  109. package/src/internal/$throwTypeGuardError.ts +5 -5
  110. package/src/internal/$validateReport.ts +13 -13
  111. package/src/internal/private/$__notationCapitalize.ts +2 -2
  112. package/src/internal/private/$__notationUnsnake.ts +24 -24
  113. package/src/json.ts +651 -651
  114. package/src/llm.ts +178 -178
  115. package/src/misc.ts +658 -658
  116. package/src/module.ts +933 -933
  117. package/src/notations.ts +827 -827
  118. package/src/programmers/CheckerProgrammer.ts +4 -1
  119. package/src/programmers/FeatureProgrammer.ts +619 -616
  120. package/src/programmers/RandomProgrammer.ts +24 -16
  121. package/src/programmers/TypiaProgrammer.ts +4 -1
  122. package/src/programmers/functional/FunctionalAssertFunctionProgrammer.ts +153 -153
  123. package/src/programmers/functional/FunctionalAssertParametersProgrammer.ts +125 -125
  124. package/src/programmers/functional/FunctionalAssertReturnProgrammer.ts +115 -115
  125. package/src/programmers/functional/FunctionalValidateFunctionProgrammer.ts +119 -119
  126. package/src/programmers/functional/FunctionalValidateParametersProgrammer.ts +274 -274
  127. package/src/programmers/functional/FunctionalValidateReturnProgrammer.ts +135 -135
  128. package/src/programmers/helpers/FunctionProgrammer.ts +67 -67
  129. package/src/programmers/helpers/RandomJoiner.ts +168 -168
  130. package/src/programmers/helpers/StringifyJoinder.ts +115 -115
  131. package/src/programmers/helpers/disable_function_programmer_declare.ts +32 -32
  132. package/src/programmers/internal/check_dynamic_key.ts +201 -201
  133. package/src/programmers/internal/check_dynamic_properties.ts +208 -208
  134. package/src/programmers/internal/check_object.ts +75 -75
  135. package/src/programmers/internal/feature_object_entries.ts +61 -61
  136. package/src/programmers/internal/prune_object_properties.ts +71 -63
  137. package/src/programmers/json/JsonAssertParseProgrammer.ts +14 -11
  138. package/src/programmers/llm/LlmApplicationProgrammer.ts +235 -235
  139. package/src/programmers/llm/LlmSchemaProgrammer.ts +51 -51
  140. package/src/programmers/misc/MiscCloneProgrammer.ts +4 -1
  141. package/src/programmers/misc/MiscPruneProgrammer.ts +4 -1
  142. package/src/programmers/notations/NotationGeneralProgrammer.ts +4 -1
  143. package/src/programmers/protobuf/ProtobufDecodeProgrammer.ts +1 -1
  144. package/src/protobuf.ts +868 -868
  145. package/src/reflect.ts +57 -57
  146. package/src/transformers/FileTransformer.ts +0 -6
  147. package/src/transformers/ImportTransformer.ts +59 -44
  148. package/src/utils/NamingConvention.ts +94 -94
  149. package/src/utils/StringUtil.ts +16 -16
  150. package/lib/internal/$httpFormDataReadArray.js.map +0 -1
  151. /package/lib/internal/{$httpFormDataReadArray.d.ts → $httpFormdataReadArray.d.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"ImportTransformer.js","sourceRoot":"","sources":["../../src/transformers/ImportTransformer.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAwB;AACxB,0DAA4B;AAE5B,IAAiB,iBAAiB,CAwDjC;AAxDD,WAAiB,iBAAiB;IACnB,2BAAS,GACpB,UAAC,IAAY;QACb,OAAA,UAAC,EAAU;YACX,OAAA,UAAC,OAAiC;gBAClC,OAAA,UAAC,IAAmB;oBAClB,OAAA,cAAc,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC;gBAAvC,CAAuC;YADzC,CACyC;QAFzC,CAEyC;IAHzC,CAGyC,CAAC;IAE5C,IAAM,cAAc,GAClB,UAAC,GAAW;QACZ,OAAA,UAAC,EAAU;YACX,OAAA,UAAC,OAAiC;gBAClC,OAAA,UAAC,IAAmB;oBAClB,IAAI,IAAI,CAAC,iBAAiB;wBAAE,OAAO,IAAI,CAAC;oBAExC,IAAM,IAAI,GAAW,kBAAkB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,CAAC,GAAG,CAAC,CAAC;YACb,OAAO,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,YAAK,MAAM,CAAE,CAAC;QACpD,CAAC,CAAC,EAAE,CAAC;QAEL,OAAO,oBAAE,CAAC,OAAO,CAAC,uBAAuB,CACvC,SAAS,EACT,KAAK,CAAC,IAAI,CAAC,YAAY,EACvB,oBAAE,CAAC,OAAO,CAAC,mBAAmB,CAAC,QAAQ,CAAC,EACxC,KAAK,CAAC,IAAI,CAAC,YAAY,CACxB,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,EAvEgB,iBAAiB,iCAAjB,iBAAiB,QAuEjC;AAED,IAAM,kBAAkB,GAAG,UAAC,IAAY;IACtC,IAAM,QAAQ,GAAa,cAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,cAAI,CAAC,GAAG,CAAC,CAAC;IAC9D,QAAQ,CAAC,GAAG,EAAE,CAAC;IACf,OAAO,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,cAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC/C,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typia",
3
- "version": "7.0.0-dev.20241009-2",
3
+ "version": "7.0.0-dev.20241010",
4
4
  "description": "Superfast runtime validators with only one line",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -1,49 +1,49 @@
1
- import { OpenApi } from "@samchon/openapi";
2
-
3
- export interface IRandomGenerator {
4
- // REGULAR
5
- boolean(): boolean | undefined;
6
- number(schema: OpenApi.IJsonSchema.INumber): number;
7
- integer(schema: OpenApi.IJsonSchema.IInteger): number;
8
- bigint(schema: OpenApi.IJsonSchema.IInteger): bigint;
9
- string(schema: OpenApi.IJsonSchema.IString): string;
10
- array<T>(
11
- schema: Omit<OpenApi.IJsonSchema.IArray, "items"> & {
12
- element: (index: number, count: number) => T;
13
- },
14
- ): T[];
15
- pattern(regex: RegExp): string;
16
-
17
- //----
18
- // FORMAT
19
- //----
20
- // SPECIAL CHARACTERS
21
- byte(): string;
22
- password(): string;
23
- regex(): string;
24
- uuid(): string;
25
-
26
- // ADDRESSES
27
- email(): string;
28
- hostname(): string;
29
- idnEmail(): string;
30
- idnHostname(): string;
31
- iri(): string;
32
- iriReference(): string;
33
- ipv4(): string;
34
- ipv6(): string;
35
- uri(): string;
36
- uriReference(): string;
37
- uriTemplate(): string;
38
- url(): string;
39
-
40
- // TIMESTAMPS
41
- datetime(props?: { minimum?: number; maximum?: number }): string;
42
- date(props?: { minimum?: number; maximum?: number }): string;
43
- time(): string;
44
- duration(): string;
45
-
46
- // POINTERS
47
- jsonPointer(): string;
48
- relativeJsonPointer(): string;
49
- }
1
+ import { OpenApi } from "@samchon/openapi";
2
+
3
+ export interface IRandomGenerator {
4
+ // REGULAR
5
+ boolean(): boolean | undefined;
6
+ number(schema: OpenApi.IJsonSchema.INumber): number;
7
+ integer(schema: OpenApi.IJsonSchema.IInteger): number;
8
+ bigint(schema: OpenApi.IJsonSchema.IInteger): bigint;
9
+ string(schema: OpenApi.IJsonSchema.IString): string;
10
+ array<T>(
11
+ schema: Omit<OpenApi.IJsonSchema.IArray, "items"> & {
12
+ element: (index: number, count: number) => T;
13
+ },
14
+ ): T[];
15
+ pattern(regex: RegExp): string;
16
+
17
+ //----
18
+ // FORMAT
19
+ //----
20
+ // SPECIAL CHARACTERS
21
+ byte(): string;
22
+ password(): string;
23
+ regex(): string;
24
+ uuid(): string;
25
+
26
+ // ADDRESSES
27
+ email(): string;
28
+ hostname(): string;
29
+ idnEmail(): string;
30
+ idnHostname(): string;
31
+ iri(): string;
32
+ iriReference(): string;
33
+ ipv4(): string;
34
+ ipv6(): string;
35
+ uri(): string;
36
+ uriReference(): string;
37
+ uriTemplate(): string;
38
+ url(): string;
39
+
40
+ // TIMESTAMPS
41
+ datetime(props?: { minimum?: number; maximum?: number }): string;
42
+ date(props?: { minimum?: number; maximum?: number }): string;
43
+ time(): string;
44
+ duration(): string;
45
+
46
+ // POINTERS
47
+ jsonPointer(): string;
48
+ relativeJsonPointer(): string;
49
+ }
@@ -1,164 +1,164 @@
1
- import ts from "typescript";
2
-
3
- import { $randomFormatUuid } from "../internal/$randomFormatUuid";
4
-
5
- export namespace ExpressionFactory {
6
- export const number = (value: number) =>
7
- value < 0
8
- ? ts.factory.createPrefixUnaryExpression(
9
- ts.SyntaxKind.MinusToken,
10
- ts.factory.createNumericLiteral(Math.abs(value)),
11
- )
12
- : ts.factory.createNumericLiteral(value);
13
-
14
- export const bigint = (value: number | bigint) =>
15
- ts.factory.createCallExpression(
16
- ts.factory.createIdentifier("BigInt"),
17
- undefined,
18
- [ts.factory.createIdentifier(value.toString())],
19
- );
20
-
21
- export const isRequired = (input: ts.Expression): ts.Expression =>
22
- ts.factory.createStrictInequality(
23
- ts.factory.createIdentifier("undefined"),
24
- input,
25
- );
26
-
27
- export const isArray = (input: ts.Expression): ts.Expression =>
28
- ts.factory.createCallExpression(
29
- ts.factory.createIdentifier("Array.isArray"),
30
- undefined,
31
- [input],
32
- );
33
-
34
- export const isObject = (props: {
35
- checkNull: boolean;
36
- checkArray: boolean;
37
- input: ts.Expression;
38
- }): ts.Expression => {
39
- const conditions: ts.Expression[] = [
40
- ts.factory.createStrictEquality(
41
- ts.factory.createStringLiteral("object"),
42
- ts.factory.createTypeOfExpression(props.input),
43
- ),
44
- ];
45
- if (props.checkNull === true)
46
- conditions.push(
47
- ts.factory.createStrictInequality(ts.factory.createNull(), props.input),
48
- );
49
- if (props.checkArray === true)
50
- conditions.push(
51
- ts.factory.createStrictEquality(
52
- ts.factory.createFalse(),
53
- ts.factory.createCallExpression(
54
- ts.factory.createIdentifier("Array.isArray"),
55
- undefined,
56
- [props.input],
57
- ),
58
- ),
59
- );
60
-
61
- return conditions.length === 1
62
- ? conditions[0]!
63
- : conditions.reduce((x, y) => ts.factory.createLogicalAnd(x, y));
64
- };
65
-
66
- export const isInstanceOf = (
67
- type: string,
68
- input: ts.Expression,
69
- ): ts.Expression => {
70
- return ts.factory.createBinaryExpression(
71
- input,
72
- ts.factory.createToken(ts.SyntaxKind.InstanceOfKeyword),
73
- ts.factory.createIdentifier(type),
74
- );
75
- };
76
-
77
- export const coalesce = (x: ts.Expression, y: ts.Expression): ts.Expression =>
78
- ts.factory.createBinaryExpression(
79
- x,
80
- ts.factory.createToken(ts.SyntaxKind.QuestionQuestionToken),
81
- y,
82
- );
83
-
84
- export const currying = (props: {
85
- function: ts.Expression;
86
- arguments: ts.Expression[];
87
- }): ts.CallExpression => {
88
- if (props.arguments.length === 0)
89
- return ts.factory.createCallExpression(
90
- props.function,
91
- undefined,
92
- undefined,
93
- );
94
- let prev: ts.CallExpression = ts.factory.createCallExpression(
95
- props.function,
96
- undefined,
97
- [props.arguments[0]!],
98
- );
99
- for (const param of props.arguments.slice(1))
100
- prev = ts.factory.createCallExpression(prev, undefined, [param]);
101
- return prev;
102
- };
103
-
104
- export const selfCall = (body: ts.ConciseBody) =>
105
- ts.isCallExpression(body)
106
- ? body
107
- : ts.factory.createCallExpression(
108
- ts.factory.createParenthesizedExpression(
109
- ts.factory.createArrowFunction(
110
- undefined,
111
- undefined,
112
- [],
113
- undefined,
114
- undefined,
115
- body,
116
- ),
117
- ),
118
- undefined,
119
- undefined,
120
- );
121
-
122
- export const getEscapedText = (props: {
123
- printer: ts.Printer;
124
- input: ts.Expression;
125
- }): string =>
126
- props.printer.printNode(
127
- ts.EmitHint.Expression,
128
- props.input,
129
- props.input.getSourceFile(),
130
- );
131
-
132
- export const transpile = (
133
- transformer: ts.TransformationContext,
134
- script: string,
135
- ) => {
136
- const file: ts.SourceFile = ts.createSourceFile(
137
- `${$randomFormatUuid()}.ts`,
138
- script,
139
- ts.ScriptTarget.ESNext,
140
- true,
141
- ts.ScriptKind.TS,
142
- );
143
- const statement: ts.Statement | undefined = file.statements[0];
144
- if (statement === undefined)
145
- throw new ReferenceError(
146
- "Error on ExpressionFactory.transpile(): no statement exists.",
147
- );
148
- else if (!ts.isExpressionStatement(statement))
149
- throw new TypeError(
150
- "Error on ExpressionFactory.transpile(): statement is not an expression statement.",
151
- );
152
- return (input: ts.Expression): ts.Expression => {
153
- const visitor = (node: ts.Node): ts.Node => {
154
- if (ts.isIdentifier(node) && node.text === "$input") return input;
155
- return ts.visitEachChild(
156
- (ts.factory as any).cloneNode(node),
157
- visitor,
158
- transformer,
159
- );
160
- };
161
- return visitor(statement.expression) as ts.Expression;
162
- };
163
- };
164
- }
1
+ import ts from "typescript";
2
+
3
+ import { $randomFormatUuid } from "../internal/$randomFormatUuid";
4
+
5
+ export namespace ExpressionFactory {
6
+ export const number = (value: number) =>
7
+ value < 0
8
+ ? ts.factory.createPrefixUnaryExpression(
9
+ ts.SyntaxKind.MinusToken,
10
+ ts.factory.createNumericLiteral(Math.abs(value)),
11
+ )
12
+ : ts.factory.createNumericLiteral(value);
13
+
14
+ export const bigint = (value: number | bigint) =>
15
+ ts.factory.createCallExpression(
16
+ ts.factory.createIdentifier("BigInt"),
17
+ undefined,
18
+ [ts.factory.createIdentifier(value.toString())],
19
+ );
20
+
21
+ export const isRequired = (input: ts.Expression): ts.Expression =>
22
+ ts.factory.createStrictInequality(
23
+ ts.factory.createIdentifier("undefined"),
24
+ input,
25
+ );
26
+
27
+ export const isArray = (input: ts.Expression): ts.Expression =>
28
+ ts.factory.createCallExpression(
29
+ ts.factory.createIdentifier("Array.isArray"),
30
+ undefined,
31
+ [input],
32
+ );
33
+
34
+ export const isObject = (props: {
35
+ checkNull: boolean;
36
+ checkArray: boolean;
37
+ input: ts.Expression;
38
+ }): ts.Expression => {
39
+ const conditions: ts.Expression[] = [
40
+ ts.factory.createStrictEquality(
41
+ ts.factory.createStringLiteral("object"),
42
+ ts.factory.createTypeOfExpression(props.input),
43
+ ),
44
+ ];
45
+ if (props.checkNull === true)
46
+ conditions.push(
47
+ ts.factory.createStrictInequality(ts.factory.createNull(), props.input),
48
+ );
49
+ if (props.checkArray === true)
50
+ conditions.push(
51
+ ts.factory.createStrictEquality(
52
+ ts.factory.createFalse(),
53
+ ts.factory.createCallExpression(
54
+ ts.factory.createIdentifier("Array.isArray"),
55
+ undefined,
56
+ [props.input],
57
+ ),
58
+ ),
59
+ );
60
+
61
+ return conditions.length === 1
62
+ ? conditions[0]!
63
+ : conditions.reduce((x, y) => ts.factory.createLogicalAnd(x, y));
64
+ };
65
+
66
+ export const isInstanceOf = (
67
+ type: string,
68
+ input: ts.Expression,
69
+ ): ts.Expression => {
70
+ return ts.factory.createBinaryExpression(
71
+ input,
72
+ ts.factory.createToken(ts.SyntaxKind.InstanceOfKeyword),
73
+ ts.factory.createIdentifier(type),
74
+ );
75
+ };
76
+
77
+ export const coalesce = (x: ts.Expression, y: ts.Expression): ts.Expression =>
78
+ ts.factory.createBinaryExpression(
79
+ x,
80
+ ts.factory.createToken(ts.SyntaxKind.QuestionQuestionToken),
81
+ y,
82
+ );
83
+
84
+ export const currying = (props: {
85
+ function: ts.Expression;
86
+ arguments: ts.Expression[];
87
+ }): ts.CallExpression => {
88
+ if (props.arguments.length === 0)
89
+ return ts.factory.createCallExpression(
90
+ props.function,
91
+ undefined,
92
+ undefined,
93
+ );
94
+ let prev: ts.CallExpression = ts.factory.createCallExpression(
95
+ props.function,
96
+ undefined,
97
+ [props.arguments[0]!],
98
+ );
99
+ for (const param of props.arguments.slice(1))
100
+ prev = ts.factory.createCallExpression(prev, undefined, [param]);
101
+ return prev;
102
+ };
103
+
104
+ export const selfCall = (body: ts.ConciseBody) =>
105
+ ts.isCallExpression(body)
106
+ ? body
107
+ : ts.factory.createCallExpression(
108
+ ts.factory.createParenthesizedExpression(
109
+ ts.factory.createArrowFunction(
110
+ undefined,
111
+ undefined,
112
+ [],
113
+ undefined,
114
+ undefined,
115
+ body,
116
+ ),
117
+ ),
118
+ undefined,
119
+ undefined,
120
+ );
121
+
122
+ export const getEscapedText = (props: {
123
+ printer: ts.Printer;
124
+ input: ts.Expression;
125
+ }): string =>
126
+ props.printer.printNode(
127
+ ts.EmitHint.Expression,
128
+ props.input,
129
+ props.input.getSourceFile(),
130
+ );
131
+
132
+ export const transpile = (
133
+ transformer: ts.TransformationContext,
134
+ script: string,
135
+ ) => {
136
+ const file: ts.SourceFile = ts.createSourceFile(
137
+ `${$randomFormatUuid()}.ts`,
138
+ script,
139
+ ts.ScriptTarget.ESNext,
140
+ true,
141
+ ts.ScriptKind.TS,
142
+ );
143
+ const statement: ts.Statement | undefined = file.statements[0];
144
+ if (statement === undefined)
145
+ throw new ReferenceError(
146
+ "Error on ExpressionFactory.transpile(): no statement exists.",
147
+ );
148
+ else if (!ts.isExpressionStatement(statement))
149
+ throw new TypeError(
150
+ "Error on ExpressionFactory.transpile(): statement is not an expression statement.",
151
+ );
152
+ return (input: ts.Expression): ts.Expression => {
153
+ const visitor = (node: ts.Node): ts.Node => {
154
+ if (ts.isIdentifier(node) && node.text === "$input") return input;
155
+ return ts.visitEachChild(
156
+ (ts.factory as any).cloneNode(node),
157
+ visitor,
158
+ transformer,
159
+ );
160
+ };
161
+ return visitor(statement.expression) as ts.Expression;
162
+ };
163
+ };
164
+ }
@@ -6,6 +6,8 @@ import { AtomicPredicator } from "../programmers/helpers/AtomicPredicator";
6
6
 
7
7
  import { TransformerError } from "../transformers/TransformerError";
8
8
 
9
+ import { ValidationPipe } from "../typings/ValidationPipe";
10
+
9
11
  import { MetadataCollection } from "./MetadataCollection";
10
12
  import { MetadataFactory } from "./MetadataFactory";
11
13
 
@@ -16,27 +18,35 @@ export namespace JsonMetadataFactory {
16
18
  transformer?: ts.TransformationContext;
17
19
  type: ts.Type;
18
20
  }
21
+ export interface IOutput {
22
+ collection: MetadataCollection;
23
+ metadata: Metadata;
24
+ }
19
25
 
20
- export const analyze = (props: IProps): [MetadataCollection, Metadata] => {
21
- const collection = new MetadataCollection();
22
- const result = MetadataFactory.analyze({
23
- checker: props.checker,
24
- transformer: props.transformer,
25
- options: {
26
- escape: true,
27
- constant: true,
28
- absorb: true,
29
- validate,
30
- },
31
- collection,
32
- type: props.type,
33
- });
26
+ export const analyze = (props: IProps): IOutput => {
27
+ const collection: MetadataCollection = new MetadataCollection();
28
+ const result: ValidationPipe<Metadata, MetadataFactory.IError> =
29
+ MetadataFactory.analyze({
30
+ checker: props.checker,
31
+ transformer: props.transformer,
32
+ options: {
33
+ escape: true,
34
+ constant: true,
35
+ absorb: true,
36
+ validate,
37
+ },
38
+ collection,
39
+ type: props.type,
40
+ });
34
41
  if (result.success === false)
35
42
  throw TransformerError.from({
36
43
  code: props.method,
37
44
  errors: result.errors,
38
45
  });
39
- return [collection, result.data];
46
+ return {
47
+ collection,
48
+ metadata: result.data,
49
+ };
40
50
  };
41
51
 
42
52
  export const validate = (meta: Metadata) => {
@@ -1,50 +1,50 @@
1
- import ts from "typescript";
2
-
3
- import { ExpressionFactory } from "./ExpressionFactory";
4
- import { IdentifierFactory } from "./IdentifierFactory";
5
-
6
- export namespace LiteralFactory {
7
- export const write = (input: any): ts.Expression => {
8
- if (input === null) return ts.factory.createNull();
9
- else if (ts.isIdentifier(input)) return input;
10
- else if (input instanceof Array) return writeArray(input);
11
- else if (typeof input === "object") return writeObject(input);
12
- else if (typeof input === "boolean") return writeBoolean(input);
13
- else if (typeof input === "bigint") return writeBigint(input);
14
- else if (typeof input === "number") return writeNumber(input);
15
- else if (typeof input === "string") return writeStrinng(input);
16
- // unreachable code
17
- else if (typeof input === "function")
18
- return ts.factory.createIdentifier("undefined");
19
- else
20
- throw new TypeError("Error on LiteralFactory.generate(): unknown type.");
21
- };
22
-
23
- const writeObject = (obj: object): ts.ObjectLiteralExpression =>
24
- ts.factory.createObjectLiteralExpression(
25
- Object.entries(obj)
26
- .filter((tuple) => tuple[1] !== undefined)
27
- .map(([key, value]) =>
28
- ts.factory.createPropertyAssignment(
29
- IdentifierFactory.identifier(key),
30
- write(value),
31
- ),
32
- ),
33
- true,
34
- );
35
-
36
- const writeArray = (array: any[]): ts.ArrayLiteralExpression =>
37
- ts.factory.createArrayLiteralExpression(array.map(write), true);
38
-
39
- const writeBoolean = (value: boolean): ts.Expression =>
40
- value ? ts.factory.createTrue() : ts.factory.createFalse();
41
-
42
- const writeNumber = (value: number): ts.Expression =>
43
- ExpressionFactory.number(value);
44
-
45
- const writeBigint = (value: bigint): ts.Expression =>
46
- ExpressionFactory.bigint(value);
47
-
48
- const writeStrinng = (value: string): ts.StringLiteral =>
49
- ts.factory.createStringLiteral(value);
50
- }
1
+ import ts from "typescript";
2
+
3
+ import { ExpressionFactory } from "./ExpressionFactory";
4
+ import { IdentifierFactory } from "./IdentifierFactory";
5
+
6
+ export namespace LiteralFactory {
7
+ export const write = (input: any): ts.Expression => {
8
+ if (input === null) return ts.factory.createNull();
9
+ else if (ts.isIdentifier(input)) return input;
10
+ else if (input instanceof Array) return writeArray(input);
11
+ else if (typeof input === "object") return writeObject(input);
12
+ else if (typeof input === "boolean") return writeBoolean(input);
13
+ else if (typeof input === "bigint") return writeBigint(input);
14
+ else if (typeof input === "number") return writeNumber(input);
15
+ else if (typeof input === "string") return writeStrinng(input);
16
+ // unreachable code
17
+ else if (typeof input === "function")
18
+ return ts.factory.createIdentifier("undefined");
19
+ else
20
+ throw new TypeError("Error on LiteralFactory.generate(): unknown type.");
21
+ };
22
+
23
+ const writeObject = (obj: object): ts.ObjectLiteralExpression =>
24
+ ts.factory.createObjectLiteralExpression(
25
+ Object.entries(obj)
26
+ .filter((tuple) => tuple[1] !== undefined)
27
+ .map(([key, value]) =>
28
+ ts.factory.createPropertyAssignment(
29
+ IdentifierFactory.identifier(key),
30
+ write(value),
31
+ ),
32
+ ),
33
+ true,
34
+ );
35
+
36
+ const writeArray = (array: any[]): ts.ArrayLiteralExpression =>
37
+ ts.factory.createArrayLiteralExpression(array.map(write), true);
38
+
39
+ const writeBoolean = (value: boolean): ts.Expression =>
40
+ value ? ts.factory.createTrue() : ts.factory.createFalse();
41
+
42
+ const writeNumber = (value: number): ts.Expression =>
43
+ ExpressionFactory.number(value);
44
+
45
+ const writeBigint = (value: bigint): ts.Expression =>
46
+ ExpressionFactory.bigint(value);
47
+
48
+ const writeStrinng = (value: string): ts.StringLiteral =>
49
+ ts.factory.createStringLiteral(value);
50
+ }