typia 3.4.21 → 3.4.23

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 (127) hide show
  1. package/README.md +57 -23
  2. package/lib/programmers/AssertProgrammer.js +79 -70
  3. package/lib/programmers/AssertProgrammer.js.map +1 -1
  4. package/lib/programmers/IsProgrammer.d.ts +1 -0
  5. package/lib/programmers/IsProgrammer.js +4 -0
  6. package/lib/programmers/IsProgrammer.js.map +1 -1
  7. package/lib/programmers/ValidateProgrammer.js +68 -59
  8. package/lib/programmers/ValidateProgrammer.js.map +1 -1
  9. package/lib/programmers/helpers/OptionPredicator.d.ts +1 -0
  10. package/lib/programmers/helpers/OptionPredicator.js +4 -0
  11. package/lib/programmers/helpers/OptionPredicator.js.map +1 -1
  12. package/lib/programmers/internal/application_schema.js +23 -21
  13. package/lib/programmers/internal/application_schema.js.map +1 -1
  14. package/lib/programmers/internal/check_dynamic_properties.js +5 -0
  15. package/lib/programmers/internal/check_dynamic_properties.js.map +1 -1
  16. package/lib/programmers/internal/check_object.d.ts +1 -0
  17. package/lib/programmers/internal/check_object.js.map +1 -1
  18. package/lib/transformers/ITransformOptions.d.ts +10 -0
  19. package/package.json +2 -2
  20. package/src/IValidation.ts +21 -21
  21. package/src/Primitive.ts +82 -82
  22. package/src/TypeGuardError.ts +36 -36
  23. package/src/executable/internal/CommandParser.ts +15 -15
  24. package/src/factories/CommentFactory.ts +10 -10
  25. package/src/factories/ExpressionFactory.ts +66 -66
  26. package/src/factories/IdentifierFactory.ts +72 -72
  27. package/src/factories/LiteralFactory.ts +44 -44
  28. package/src/factories/StatementFactory.ts +60 -60
  29. package/src/factories/TemplateFactory.ts +56 -56
  30. package/src/factories/TypeFactory.ts +101 -101
  31. package/src/factories/ValueFactory.ts +12 -12
  32. package/src/functional/$every.ts +11 -11
  33. package/src/functional/$is_email.ts +5 -5
  34. package/src/functional/$is_ipv4.ts +5 -5
  35. package/src/functional/$is_ipv6.ts +5 -5
  36. package/src/functional/$is_url.ts +5 -5
  37. package/src/functional/$is_uuid.ts +5 -5
  38. package/src/functional/$join.ts +50 -50
  39. package/src/functional/$report.ts +15 -15
  40. package/src/functional/$rest.ts +3 -3
  41. package/src/functional/$string.ts +37 -37
  42. package/src/functional/$tail.ts +6 -6
  43. package/src/index.ts +4 -4
  44. package/src/metadata/IJsDocTagInfo.ts +10 -10
  45. package/src/metadata/IMetadata.ts +25 -25
  46. package/src/metadata/IMetadataApplication.ts +7 -7
  47. package/src/metadata/IMetadataConstant.ts +16 -16
  48. package/src/metadata/IMetadataEntry.ts +6 -6
  49. package/src/metadata/IMetadataObject.ts +29 -29
  50. package/src/metadata/IMetadataProperty.ts +11 -11
  51. package/src/metadata/MetadataConstant.ts +3 -3
  52. package/src/metadata/MetadataObject.ts +131 -131
  53. package/src/metadata/MetadataProperty.ts +64 -64
  54. package/src/programmers/ApplicationProgrammer.ts +55 -55
  55. package/src/programmers/AssertProgrammer.ts +36 -29
  56. package/src/programmers/IsProgrammer.ts +5 -0
  57. package/src/programmers/ValidateProgrammer.ts +36 -29
  58. package/src/programmers/helpers/AtomicPredicator.ts +15 -15
  59. package/src/programmers/helpers/FunctionImporeter.ts +31 -31
  60. package/src/programmers/helpers/IExpressionEntry.ts +10 -10
  61. package/src/programmers/helpers/OptionPredicator.ts +4 -0
  62. package/src/programmers/helpers/StringifyJoinder.ts +111 -111
  63. package/src/programmers/helpers/StringifyPredicator.ts +18 -18
  64. package/src/programmers/helpers/UnionPredicator.ts +81 -81
  65. package/src/programmers/internal/application_array.ts +47 -47
  66. package/src/programmers/internal/application_boolean.ts +17 -17
  67. package/src/programmers/internal/application_constant.ts +29 -29
  68. package/src/programmers/internal/application_default_string.ts +32 -32
  69. package/src/programmers/internal/application_native.ts +29 -29
  70. package/src/programmers/internal/application_number.ts +76 -76
  71. package/src/programmers/internal/application_schema.ts +9 -6
  72. package/src/programmers/internal/application_string.ts +49 -49
  73. package/src/programmers/internal/application_templates.ts +27 -27
  74. package/src/programmers/internal/application_tuple.ts +29 -29
  75. package/src/programmers/internal/check_dynamic_properties.ts +164 -146
  76. package/src/programmers/internal/check_everything.ts +25 -25
  77. package/src/programmers/internal/check_length.ts +46 -46
  78. package/src/programmers/internal/check_native.ts +9 -9
  79. package/src/programmers/internal/check_object.ts +43 -42
  80. package/src/programmers/internal/check_string.ts +24 -24
  81. package/src/programmers/internal/check_string_tags.ts +63 -63
  82. package/src/programmers/internal/check_template.ts +50 -50
  83. package/src/programmers/internal/decode_union_object.ts +73 -73
  84. package/src/programmers/internal/feature_object_entries.ts +49 -49
  85. package/src/programmers/internal/metadata_to_pattern.ts +31 -31
  86. package/src/programmers/internal/stringify_dynamic_properties.ts +164 -164
  87. package/src/programmers/internal/stringify_native.ts +8 -8
  88. package/src/programmers/internal/stringify_regular_properties.ts +81 -81
  89. package/src/programmers/internal/template_to_pattern.ts +15 -15
  90. package/src/schemas/IJsonApplication.ts +9 -9
  91. package/src/schemas/IJsonComponents.ts +26 -26
  92. package/src/transform.ts +20 -20
  93. package/src/transformers/ExpressionWithArgumentTransformer.ts +66 -66
  94. package/src/transformers/FileTransformer.ts +49 -49
  95. package/src/transformers/IProject.ts +11 -11
  96. package/src/transformers/ITransformOptions.ts +11 -0
  97. package/src/transformers/NodeTransformer.ts +19 -19
  98. package/src/transformers/features/miscellaneous/MetadataTransformer.ts +55 -55
  99. package/src/transformers/features/parsers/AssertParseTransformer.ts +36 -36
  100. package/src/transformers/features/parsers/CreateAssertParseTransformer.ts +32 -32
  101. package/src/transformers/features/parsers/CreateIsParseTransformer.ts +32 -32
  102. package/src/transformers/features/parsers/CreateValidateParseTransformer.ts +32 -32
  103. package/src/transformers/features/parsers/IsParseTransformer.ts +36 -36
  104. package/src/transformers/features/parsers/ValidateParseTransformer.ts +36 -36
  105. package/src/transformers/features/stringifiers/AssertStringifyTransformer.ts +38 -38
  106. package/src/transformers/features/stringifiers/CreateAssertStringifyTransformer.ts +32 -32
  107. package/src/transformers/features/stringifiers/CreateIsStringifyTransformer.ts +32 -32
  108. package/src/transformers/features/stringifiers/CreateStringifyTransformer.ts +31 -31
  109. package/src/transformers/features/stringifiers/CreateValidateStringifyProgrammer.ts +32 -32
  110. package/src/transformers/features/stringifiers/IsStringifyTransformer.ts +38 -38
  111. package/src/transformers/features/stringifiers/ValidateStringifyTransformer.ts +38 -38
  112. package/src/transformers/features/validators/AssertTransformer.ts +43 -43
  113. package/src/transformers/features/validators/CreateAssertTransformer.ts +35 -35
  114. package/src/transformers/features/validators/CreateIsTransformer.ts +35 -35
  115. package/src/transformers/features/validators/CreateValidateTransformer.ts +35 -35
  116. package/src/transformers/features/validators/IsTransformer.ts +43 -43
  117. package/src/transformers/features/validators/ValidateTransformer.ts +43 -43
  118. package/src/typings/Atomic.ts +17 -17
  119. package/src/typings/ClassProperties.ts +5 -5
  120. package/src/typings/OmitNever.ts +3 -3
  121. package/src/typings/SpecialFields.ts +3 -3
  122. package/src/typings/Writable.ts +11 -11
  123. package/src/utils/ArrayUtil.ts +49 -49
  124. package/src/utils/Escaper.ts +50 -50
  125. package/src/utils/MapUtil.ts +14 -14
  126. package/src/utils/PatternUtil.ts +30 -30
  127. package/src/utils/Singleton.ts +17 -17
@@ -1,49 +1,49 @@
1
- import { Metadata } from "../../metadata/Metadata";
2
- import { IJsonSchema } from "../../schemas/IJsonSchema";
3
-
4
- import { application_default_string } from "./application_default_string";
5
-
6
- /**
7
- * @internal
8
- */
9
- export const application_string = (
10
- meta: Metadata,
11
- attribute: IJsonSchema.IAttribute,
12
- ): IJsonSchema.IString => {
13
- const output: IJsonSchema.IString = {
14
- type: "string",
15
- nullable: meta.nullable,
16
- ...attribute,
17
- };
18
-
19
- // FORMAT TAG OF METADATA
20
- const formatJsdocTag = attribute["x-typia-jsDocTags"]?.find(
21
- (tag) => tag.name === "format",
22
- );
23
- if (formatJsdocTag?.text?.length)
24
- output.format = formatJsdocTag?.text.map((t) => t.text).join(" ");
25
-
26
- // REGULAR TAGS COMPATIBLE WITH JSON-SCHEMA
27
- for (const tag of attribute["x-typia-metaTags"] || []) {
28
- // RANGE
29
- if (tag.kind === "minLength") output.minLength = tag.value;
30
- else if (tag.kind === "maxLength") output.maxLength = tag.value;
31
- else if (tag.kind === "length") {
32
- if (tag.minimum !== undefined)
33
- output.minLength =
34
- tag.minimum.value + (tag.minimum.include ? 0 : 1);
35
- if (tag.maximum !== undefined)
36
- output.maxLength =
37
- tag.maximum.value - (tag.maximum.include ? 0 : 1);
38
- }
39
- // FORMAT AND PATTERN
40
- else if (tag.kind === "format") output.format = tag.value;
41
- else if (tag.kind === "pattern") output.pattern = tag.value;
42
- }
43
-
44
- // DEFAULT CONFIGURATION
45
- output.default = application_default_string(meta, attribute)(output);
46
-
47
- // RETURNS
48
- return output;
49
- };
1
+ import { Metadata } from "../../metadata/Metadata";
2
+ import { IJsonSchema } from "../../schemas/IJsonSchema";
3
+
4
+ import { application_default_string } from "./application_default_string";
5
+
6
+ /**
7
+ * @internal
8
+ */
9
+ export const application_string = (
10
+ meta: Metadata,
11
+ attribute: IJsonSchema.IAttribute,
12
+ ): IJsonSchema.IString => {
13
+ const output: IJsonSchema.IString = {
14
+ type: "string",
15
+ nullable: meta.nullable,
16
+ ...attribute,
17
+ };
18
+
19
+ // FORMAT TAG OF METADATA
20
+ const formatJsdocTag = attribute["x-typia-jsDocTags"]?.find(
21
+ (tag) => tag.name === "format",
22
+ );
23
+ if (formatJsdocTag?.text?.length)
24
+ output.format = formatJsdocTag?.text.map((t) => t.text).join(" ");
25
+
26
+ // REGULAR TAGS COMPATIBLE WITH JSON-SCHEMA
27
+ for (const tag of attribute["x-typia-metaTags"] || []) {
28
+ // RANGE
29
+ if (tag.kind === "minLength") output.minLength = tag.value;
30
+ else if (tag.kind === "maxLength") output.maxLength = tag.value;
31
+ else if (tag.kind === "length") {
32
+ if (tag.minimum !== undefined)
33
+ output.minLength =
34
+ tag.minimum.value + (tag.minimum.include ? 0 : 1);
35
+ if (tag.maximum !== undefined)
36
+ output.maxLength =
37
+ tag.maximum.value - (tag.maximum.include ? 0 : 1);
38
+ }
39
+ // FORMAT AND PATTERN
40
+ else if (tag.kind === "format") output.format = tag.value;
41
+ else if (tag.kind === "pattern") output.pattern = tag.value;
42
+ }
43
+
44
+ // DEFAULT CONFIGURATION
45
+ output.default = application_default_string(meta, attribute)(output);
46
+
47
+ // RETURNS
48
+ return output;
49
+ };
@@ -1,27 +1,27 @@
1
- import { Metadata } from "../../metadata/Metadata";
2
- import { IJsonSchema } from "../../schemas/IJsonSchema";
3
-
4
- import { application_default_string } from "./application_default_string";
5
- import { metadata_to_pattern } from "./metadata_to_pattern";
6
-
7
- /**
8
- * @internal
9
- */
10
- export const application_templates = (
11
- meta: Metadata,
12
- attribute: IJsonSchema.IAttribute,
13
- ): IJsonSchema.IString => {
14
- // CONSTRUCT PATTERN
15
- const output: IJsonSchema.IString = {
16
- type: "string",
17
- nullable: meta.nullable,
18
- ...attribute,
19
- };
20
- output.pattern = metadata_to_pattern(true)(meta);
21
-
22
- // DEFAULT VALUE
23
- output.default = application_default_string(meta, attribute)(output);
24
-
25
- // RETURNS
26
- return output;
27
- };
1
+ import { Metadata } from "../../metadata/Metadata";
2
+ import { IJsonSchema } from "../../schemas/IJsonSchema";
3
+
4
+ import { application_default_string } from "./application_default_string";
5
+ import { metadata_to_pattern } from "./metadata_to_pattern";
6
+
7
+ /**
8
+ * @internal
9
+ */
10
+ export const application_templates = (
11
+ meta: Metadata,
12
+ attribute: IJsonSchema.IAttribute,
13
+ ): IJsonSchema.IString => {
14
+ // CONSTRUCT PATTERN
15
+ const output: IJsonSchema.IString = {
16
+ type: "string",
17
+ nullable: meta.nullable,
18
+ ...attribute,
19
+ };
20
+ output.pattern = metadata_to_pattern(true)(meta);
21
+
22
+ // DEFAULT VALUE
23
+ output.default = application_default_string(meta, attribute)(output);
24
+
25
+ // RETURNS
26
+ return output;
27
+ };
@@ -1,29 +1,29 @@
1
- import { Metadata } from "../../metadata/Metadata";
2
- import { IJsonComponents } from "../../schemas/IJsonComponents";
3
- import { IJsonSchema } from "../../schemas/IJsonSchema";
4
-
5
- import { ApplicationProgrammer } from "../ApplicationProgrammer";
6
- import { application_schema } from "./application_schema";
7
-
8
- /**
9
- * @internal
10
- */
11
- export const application_tuple =
12
- (options: ApplicationProgrammer.IOptions) =>
13
- (components: IJsonComponents) =>
14
- (
15
- items: Array<Metadata>,
16
- nullable: boolean,
17
- attribute: IJsonSchema.IAttribute,
18
- ): IJsonSchema.ITuple => ({
19
- type: "array",
20
- items: items.map((meta, i) =>
21
- application_schema(options)(components)(false)(meta.rest ?? meta, {
22
- ...attribute,
23
- "x-typia-rest":
24
- i === items.length - 1 ? meta.rest !== null : undefined,
25
- }),
26
- ),
27
- nullable,
28
- ...attribute,
29
- });
1
+ import { Metadata } from "../../metadata/Metadata";
2
+ import { IJsonComponents } from "../../schemas/IJsonComponents";
3
+ import { IJsonSchema } from "../../schemas/IJsonSchema";
4
+
5
+ import { ApplicationProgrammer } from "../ApplicationProgrammer";
6
+ import { application_schema } from "./application_schema";
7
+
8
+ /**
9
+ * @internal
10
+ */
11
+ export const application_tuple =
12
+ (options: ApplicationProgrammer.IOptions) =>
13
+ (components: IJsonComponents) =>
14
+ (
15
+ items: Array<Metadata>,
16
+ nullable: boolean,
17
+ attribute: IJsonSchema.IAttribute,
18
+ ): IJsonSchema.ITuple => ({
19
+ type: "array",
20
+ items: items.map((meta, i) =>
21
+ application_schema(options)(components)(false)(meta.rest ?? meta, {
22
+ ...attribute,
23
+ "x-typia-rest":
24
+ i === items.length - 1 ? meta.rest !== null : undefined,
25
+ }),
26
+ ),
27
+ nullable,
28
+ ...attribute,
29
+ });
@@ -1,146 +1,164 @@
1
- import ts from "typescript";
2
-
3
- import { IdentifierFactory } from "../../factories/IdentifierFactory";
4
- import { StatementFactory } from "../../factories/StatementFactory";
5
-
6
- import { IExpressionEntry } from "../helpers/IExpressionEntry";
7
- import { check_everything } from "./check_everything";
8
- import { check_object } from "./check_object";
9
- import { metadata_to_pattern } from "./metadata_to_pattern";
10
-
11
- /**
12
- * @internal
13
- */
14
- export const check_dynamic_properties =
15
- (props: check_object.IProps) =>
16
- (
17
- regular: IExpressionEntry[],
18
- dynamic: IExpressionEntry[],
19
- ): ts.Expression => {
20
- const criteria = props.entries
21
- ? ts.factory.createCallExpression(props.entries, undefined, [
22
- ts.factory.createCallExpression(
23
- ts.factory.createIdentifier("Object.keys"),
24
- undefined,
25
- [ts.factory.createIdentifier("input")],
26
- ),
27
- check_dynamic_property(props)(regular, dynamic),
28
- ])
29
- : ts.factory.createCallExpression(
30
- IdentifierFactory.join(
31
- ts.factory.createCallExpression(
32
- ts.factory.createIdentifier("Object.keys"),
33
- undefined,
34
- [ts.factory.createIdentifier("input")],
35
- ),
36
- props.assert ? "every" : "map",
37
- ),
38
- undefined,
39
- [check_dynamic_property(props)(regular, dynamic)],
40
- );
41
- return (props.halt || ((elem) => elem))(
42
- props.assert ? criteria : check_everything(criteria),
43
- );
44
- };
45
-
46
- const check_dynamic_property =
47
- (props: check_object.IProps) =>
48
- (regular: IExpressionEntry[], dynamic: IExpressionEntry[]) => {
49
- //----
50
- // IF CONDITIONS
51
- //----
52
- // PREPARE ASSETS
53
- const key = ts.factory.createIdentifier("key");
54
- const value = ts.factory.createIdentifier("value");
55
-
56
- const statements: ts.Statement[] = [];
57
- const add = (exp: ts.Expression, output: ts.Expression) =>
58
- statements.push(
59
- ts.factory.createIfStatement(
60
- exp,
61
- ts.factory.createReturnStatement(output),
62
- ),
63
- );
64
-
65
- // GATHER CONDITIONS
66
- if (props.equals === true && regular.length)
67
- add(is_regular_property(regular), props.positive);
68
- statements.push(
69
- StatementFactory.constant(
70
- "value",
71
- ts.factory.createIdentifier("input[key]"),
72
- ),
73
- );
74
- add(
75
- ts.factory.createStrictEquality(
76
- ts.factory.createIdentifier("undefined"),
77
- value,
78
- ),
79
- props.positive,
80
- );
81
- for (const entry of dynamic)
82
- add(
83
- ts.factory.createCallExpression(
84
- ts.factory.createIdentifier(
85
- `RegExp(/${metadata_to_pattern(true)(
86
- entry.key,
87
- )}/).test`,
88
- ),
89
- undefined,
90
- [key],
91
- ),
92
- entry.expression,
93
- );
94
-
95
- //----
96
- // FUNCTION BODY
97
- //----
98
- // CLOSURE BLOCK
99
- const block: ts.Block = ts.factory.createBlock(
100
- [
101
- ...statements,
102
- ts.factory.createReturnStatement(
103
- props.equals === true
104
- ? props.superfluous(value)
105
- : props.positive,
106
- ),
107
- ],
108
- true,
109
- );
110
-
111
- // RETURNS
112
- return ts.factory.createArrowFunction(
113
- undefined,
114
- undefined,
115
- [IdentifierFactory.parameter("key")],
116
- undefined,
117
- undefined,
118
- block,
119
- );
120
- };
121
-
122
- const is_regular_property = (regular: IExpressionEntry[]) =>
123
- ts.factory.createCallExpression(
124
- IdentifierFactory.join(
125
- ts.factory.createArrayLiteralExpression(
126
- regular.map((entry) =>
127
- ts.factory.createStringLiteral(entry.key.getSoleLiteral()!),
128
- ),
129
- ),
130
- "some",
131
- ),
132
- undefined,
133
- [
134
- ts.factory.createArrowFunction(
135
- undefined,
136
- undefined,
137
- [IdentifierFactory.parameter("prop")],
138
- undefined,
139
- undefined,
140
- ts.factory.createStrictEquality(
141
- ts.factory.createIdentifier("key"),
142
- ts.factory.createIdentifier("prop"),
143
- ),
144
- ),
145
- ],
146
- );
1
+ import ts from "typescript";
2
+
3
+ import { IdentifierFactory } from "../../factories/IdentifierFactory";
4
+ import { StatementFactory } from "../../factories/StatementFactory";
5
+
6
+ import { IExpressionEntry } from "../helpers/IExpressionEntry";
7
+ import { check_everything } from "./check_everything";
8
+ import { check_object } from "./check_object";
9
+ import { metadata_to_pattern } from "./metadata_to_pattern";
10
+
11
+ /**
12
+ * @internal
13
+ */
14
+ export const check_dynamic_properties =
15
+ (props: check_object.IProps) =>
16
+ (
17
+ regular: IExpressionEntry[],
18
+ dynamic: IExpressionEntry[],
19
+ ): ts.Expression => {
20
+ if (
21
+ props.equals === true &&
22
+ props.undefined === false &&
23
+ regular.every((r) => r.meta.required) &&
24
+ dynamic.length === 0
25
+ )
26
+ return ts.factory.createStrictEquality(
27
+ ts.factory.createNumericLiteral(regular.length),
28
+ IdentifierFactory.join(
29
+ ts.factory.createCallExpression(
30
+ ts.factory.createIdentifier("Object.keys"),
31
+ undefined,
32
+ [ts.factory.createIdentifier("input")],
33
+ ),
34
+ "length",
35
+ ),
36
+ );
37
+
38
+ const criteria = props.entries
39
+ ? ts.factory.createCallExpression(props.entries, undefined, [
40
+ ts.factory.createCallExpression(
41
+ ts.factory.createIdentifier("Object.keys"),
42
+ undefined,
43
+ [ts.factory.createIdentifier("input")],
44
+ ),
45
+ check_dynamic_property(props)(regular, dynamic),
46
+ ])
47
+ : ts.factory.createCallExpression(
48
+ IdentifierFactory.join(
49
+ ts.factory.createCallExpression(
50
+ ts.factory.createIdentifier("Object.keys"),
51
+ undefined,
52
+ [ts.factory.createIdentifier("input")],
53
+ ),
54
+ props.assert ? "every" : "map",
55
+ ),
56
+ undefined,
57
+ [check_dynamic_property(props)(regular, dynamic)],
58
+ );
59
+ return (props.halt || ((elem) => elem))(
60
+ props.assert ? criteria : check_everything(criteria),
61
+ );
62
+ };
63
+
64
+ const check_dynamic_property =
65
+ (props: check_object.IProps) =>
66
+ (regular: IExpressionEntry[], dynamic: IExpressionEntry[]) => {
67
+ //----
68
+ // IF CONDITIONS
69
+ //----
70
+ // PREPARE ASSETS
71
+ const key = ts.factory.createIdentifier("key");
72
+ const value = ts.factory.createIdentifier("value");
73
+
74
+ const statements: ts.Statement[] = [];
75
+ const add = (exp: ts.Expression, output: ts.Expression) =>
76
+ statements.push(
77
+ ts.factory.createIfStatement(
78
+ exp,
79
+ ts.factory.createReturnStatement(output),
80
+ ),
81
+ );
82
+
83
+ // GATHER CONDITIONS
84
+ if (props.equals === true && regular.length)
85
+ add(is_regular_property(regular), props.positive);
86
+ statements.push(
87
+ StatementFactory.constant(
88
+ "value",
89
+ ts.factory.createIdentifier("input[key]"),
90
+ ),
91
+ );
92
+ add(
93
+ ts.factory.createStrictEquality(
94
+ ts.factory.createIdentifier("undefined"),
95
+ value,
96
+ ),
97
+ props.positive,
98
+ );
99
+ for (const entry of dynamic)
100
+ add(
101
+ ts.factory.createCallExpression(
102
+ ts.factory.createIdentifier(
103
+ `RegExp(/${metadata_to_pattern(true)(
104
+ entry.key,
105
+ )}/).test`,
106
+ ),
107
+ undefined,
108
+ [key],
109
+ ),
110
+ entry.expression,
111
+ );
112
+
113
+ //----
114
+ // FUNCTION BODY
115
+ //----
116
+ // CLOSURE BLOCK
117
+ const block: ts.Block = ts.factory.createBlock(
118
+ [
119
+ ...statements,
120
+ ts.factory.createReturnStatement(
121
+ props.equals === true
122
+ ? props.superfluous(value)
123
+ : props.positive,
124
+ ),
125
+ ],
126
+ true,
127
+ );
128
+
129
+ // RETURNS
130
+ return ts.factory.createArrowFunction(
131
+ undefined,
132
+ undefined,
133
+ [IdentifierFactory.parameter("key")],
134
+ undefined,
135
+ undefined,
136
+ block,
137
+ );
138
+ };
139
+
140
+ const is_regular_property = (regular: IExpressionEntry[]) =>
141
+ ts.factory.createCallExpression(
142
+ IdentifierFactory.join(
143
+ ts.factory.createArrayLiteralExpression(
144
+ regular.map((entry) =>
145
+ ts.factory.createStringLiteral(entry.key.getSoleLiteral()!),
146
+ ),
147
+ ),
148
+ "some",
149
+ ),
150
+ undefined,
151
+ [
152
+ ts.factory.createArrowFunction(
153
+ undefined,
154
+ undefined,
155
+ [IdentifierFactory.parameter("prop")],
156
+ undefined,
157
+ undefined,
158
+ ts.factory.createStrictEquality(
159
+ ts.factory.createIdentifier("key"),
160
+ ts.factory.createIdentifier("prop"),
161
+ ),
162
+ ),
163
+ ],
164
+ );
@@ -1,25 +1,25 @@
1
- import ts from "typescript";
2
-
3
- import { IdentifierFactory } from "../../factories/IdentifierFactory";
4
-
5
- /**
6
- * @internal
7
- */
8
- export const check_everything = (array: ts.Expression) =>
9
- ts.factory.createCallExpression(
10
- IdentifierFactory.join(array, "every"),
11
- undefined,
12
- [
13
- ts.factory.createArrowFunction(
14
- undefined,
15
- undefined,
16
- [IdentifierFactory.parameter("flag")],
17
- undefined,
18
- undefined,
19
- ts.factory.createStrictEquality(
20
- ts.factory.createTrue(),
21
- ts.factory.createIdentifier("flag"),
22
- ),
23
- ),
24
- ],
25
- );
1
+ import ts from "typescript";
2
+
3
+ import { IdentifierFactory } from "../../factories/IdentifierFactory";
4
+
5
+ /**
6
+ * @internal
7
+ */
8
+ export const check_everything = (array: ts.Expression) =>
9
+ ts.factory.createCallExpression(
10
+ IdentifierFactory.join(array, "every"),
11
+ undefined,
12
+ [
13
+ ts.factory.createArrowFunction(
14
+ undefined,
15
+ undefined,
16
+ [IdentifierFactory.parameter("flag")],
17
+ undefined,
18
+ undefined,
19
+ ts.factory.createStrictEquality(
20
+ ts.factory.createTrue(),
21
+ ts.factory.createIdentifier("flag"),
22
+ ),
23
+ ),
24
+ ],
25
+ );