typia 3.6.4 → 3.6.6

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 (72) hide show
  1. package/lib/functional/$is_uuid.js +1 -1
  2. package/lib/functional/$is_uuid.js.map +1 -1
  3. package/lib/module.d.ts +1 -1
  4. package/lib/programmers/internal/application_number.js +1 -1
  5. package/package.json +1 -1
  6. package/src/executable/setup/ArgumentParser.ts +91 -91
  7. package/src/executable/setup/FileRetriever.ts +33 -33
  8. package/src/executable/setup/PackageManager.ts +92 -92
  9. package/src/executable/setup/PluginConfigurator.ts +99 -99
  10. package/src/factories/internal/metadata/emplace_metadata_object.ts +142 -142
  11. package/src/functional/$is_uuid.ts +2 -1
  12. package/src/module.ts +1946 -1946
  13. package/src/programmers/AssertCloneProgrammer.ts +70 -70
  14. package/src/programmers/AssertParseProgrammer.ts +65 -65
  15. package/src/programmers/AssertProgrammer.ts +232 -232
  16. package/src/programmers/AssertPruneProgrammer.ts +67 -67
  17. package/src/programmers/AssertStringifyProgrammer.ts +71 -71
  18. package/src/programmers/CheckerProgrammer.ts +893 -893
  19. package/src/programmers/CloneProgrammer.ts +386 -386
  20. package/src/programmers/FeatureProgrammer.ts +505 -505
  21. package/src/programmers/IsCloneProgrammer.ts +80 -80
  22. package/src/programmers/IsParseProgrammer.ts +74 -74
  23. package/src/programmers/IsPruneProgrammer.ts +75 -75
  24. package/src/programmers/IsStringifyProgrammer.ts +81 -81
  25. package/src/programmers/PruneProgrammer.ts +341 -341
  26. package/src/programmers/RandomProgrammer.ts +391 -391
  27. package/src/programmers/StringifyProgrammer.ts +795 -795
  28. package/src/programmers/ValidateCloneProgrammer.ts +90 -90
  29. package/src/programmers/ValidateParseProgrammer.ts +69 -69
  30. package/src/programmers/ValidateProgrammer.ts +266 -266
  31. package/src/programmers/ValidatePruneProgrammer.ts +83 -83
  32. package/src/programmers/ValidateStringifyProgrammer.ts +89 -89
  33. package/src/programmers/internal/application_number.ts +1 -1
  34. package/src/transformers/features/miscellaneous/AssertCloneTransformer.ts +9 -9
  35. package/src/transformers/features/miscellaneous/AssertPruneTransformer.ts +9 -9
  36. package/src/transformers/features/miscellaneous/CloneTransformer.ts +9 -9
  37. package/src/transformers/features/miscellaneous/CreateAssertCloneTransformer.ts +9 -9
  38. package/src/transformers/features/miscellaneous/CreateAssertPruneTransformer.ts +9 -9
  39. package/src/transformers/features/miscellaneous/CreateCloneTransformer.ts +9 -9
  40. package/src/transformers/features/miscellaneous/CreateIsCloneTransformer.ts +9 -9
  41. package/src/transformers/features/miscellaneous/CreateIsPruneTransformer.ts +9 -9
  42. package/src/transformers/features/miscellaneous/CreatePruneTransformer.ts +9 -9
  43. package/src/transformers/features/miscellaneous/CreateRandomGenerator.ts +42 -42
  44. package/src/transformers/features/miscellaneous/CreateValidateCloneTransformer.ts +9 -9
  45. package/src/transformers/features/miscellaneous/CreateValidatePruneTransformer.ts +9 -9
  46. package/src/transformers/features/miscellaneous/IsCloneTransformer.ts +9 -9
  47. package/src/transformers/features/miscellaneous/IsPruneTransformer.ts +9 -9
  48. package/src/transformers/features/miscellaneous/PruneTransformer.ts +9 -9
  49. package/src/transformers/features/miscellaneous/RandomTransformer.ts +48 -48
  50. package/src/transformers/features/miscellaneous/ValidateCloneTransformer.ts +9 -9
  51. package/src/transformers/features/miscellaneous/ValidatePruneTransformer.ts +9 -9
  52. package/src/transformers/features/parsers/AssertParseTransformer.ts +9 -9
  53. package/src/transformers/features/parsers/CreateAssertParseTransformer.ts +9 -9
  54. package/src/transformers/features/parsers/CreateIsParseTransformer.ts +9 -9
  55. package/src/transformers/features/parsers/CreateValidateParseTransformer.ts +9 -9
  56. package/src/transformers/features/parsers/IsParseTransformer.ts +9 -9
  57. package/src/transformers/features/parsers/ValidateParseTransformer.ts +9 -9
  58. package/src/transformers/features/stringifiers/AssertStringifyTransformer.ts +10 -10
  59. package/src/transformers/features/stringifiers/CreateAssertStringifyTransformer.ts +9 -9
  60. package/src/transformers/features/stringifiers/CreateIsStringifyTransformer.ts +9 -9
  61. package/src/transformers/features/stringifiers/CreateStringifyTransformer.ts +9 -9
  62. package/src/transformers/features/stringifiers/CreateValidateStringifyProgrammer.ts +11 -11
  63. package/src/transformers/features/stringifiers/IsStringifyTransformer.ts +9 -9
  64. package/src/transformers/features/stringifiers/StringifyTransformer.ts +9 -9
  65. package/src/transformers/features/stringifiers/ValidateStringifyTransformer.ts +10 -10
  66. package/src/transformers/features/validators/AssertTransformer.ts +11 -11
  67. package/src/transformers/features/validators/CreateAssertTransformer.ts +12 -12
  68. package/src/transformers/features/validators/CreateIsTransformer.ts +10 -10
  69. package/src/transformers/features/validators/CreateValidateTransformer.ts +12 -12
  70. package/src/transformers/features/validators/IsTransformer.ts +10 -10
  71. package/src/transformers/features/validators/ValidateTransformer.ts +11 -11
  72. package/src/transformers/internal/GenericTransformer.ts +99 -99
@@ -1,99 +1,99 @@
1
- import type Comment from "comment-json";
2
- import fs from "fs";
3
- import path from "path";
4
-
5
- import { TypiaSetupWizard } from "../TypiaSetupWizard";
6
- import { FileRetriever } from "./FileRetriever";
7
- import { PackageManager } from "./PackageManager";
8
-
9
- export namespace PluginConfigurator {
10
- export async function configure(
11
- pack: PackageManager,
12
- args: TypiaSetupWizard.IArguments,
13
- ): Promise<void> {
14
- // INSTALL COMMENT-JSON
15
- const installed: boolean = pack.install({
16
- dev: true,
17
- modulo: "comment-json",
18
- version: "4.2.3",
19
- silent: true,
20
- });
21
-
22
- // DO CONFIGURE
23
- const error: Error | null = await (async () => {
24
- try {
25
- await _Configure(pack, args);
26
- return null;
27
- } catch (exp) {
28
- return exp as Error;
29
- }
30
- })();
31
-
32
- // REMOVE IT
33
- if (installed)
34
- pack.erase({
35
- modulo: "comment-json",
36
- silent: true,
37
- });
38
- if (error !== null) throw error;
39
- }
40
-
41
- async function _Configure(
42
- pack: PackageManager,
43
- args: TypiaSetupWizard.IArguments,
44
- ): Promise<void> {
45
- // GET COMPILER-OPTIONS
46
- const Comment: typeof import("comment-json") =
47
- await FileRetriever.require(
48
- path.join("node_modules", "comment-json"),
49
- )(pack.directory);
50
-
51
- const config: Comment.CommentObject = Comment.parse(
52
- await fs.promises.readFile(args.project!, "utf8"),
53
- ) as Comment.CommentObject;
54
- const compilerOptions = config.compilerOptions as
55
- | Comment.CommentObject
56
- | undefined;
57
- if (compilerOptions === undefined)
58
- throw new Error(
59
- `${args.project} file does not have "compilerOptions" property.`,
60
- );
61
-
62
- // PREPARE PLUGINS
63
- const plugins: Comment.CommentArray<Comment.CommentObject> = (() => {
64
- const plugins = compilerOptions.plugins as
65
- | Comment.CommentArray<Comment.CommentObject>
66
- | undefined;
67
- if (plugins === undefined)
68
- return (compilerOptions.plugins = [] as any);
69
- else if (!Array.isArray(plugins))
70
- throw new Error(
71
- `"plugins" property of ${args.project} must be array type.`,
72
- );
73
- return plugins;
74
- })();
75
-
76
- const strict: boolean = compilerOptions.strict === true;
77
- const oldbie: Comment.CommentObject | undefined = plugins.find(
78
- (p) =>
79
- typeof p === "object" &&
80
- p !== null &&
81
- p.transform === "typia/lib/transform",
82
- );
83
- if (strict === true && oldbie !== undefined) return;
84
-
85
- // DO CONFIGURE
86
- compilerOptions.strict = true;
87
- if (oldbie === undefined)
88
- plugins.push(
89
- Comment.parse(`
90
- {
91
- "transform": "typia/lib/transform"
92
- }`) as Comment.CommentObject,
93
- );
94
- await fs.promises.writeFile(
95
- args.project!,
96
- Comment.stringify(config, null, 2),
97
- );
98
- }
99
- }
1
+ import type Comment from "comment-json";
2
+ import fs from "fs";
3
+ import path from "path";
4
+
5
+ import { TypiaSetupWizard } from "../TypiaSetupWizard";
6
+ import { FileRetriever } from "./FileRetriever";
7
+ import { PackageManager } from "./PackageManager";
8
+
9
+ export namespace PluginConfigurator {
10
+ export async function configure(
11
+ pack: PackageManager,
12
+ args: TypiaSetupWizard.IArguments,
13
+ ): Promise<void> {
14
+ // INSTALL COMMENT-JSON
15
+ const installed: boolean = pack.install({
16
+ dev: true,
17
+ modulo: "comment-json",
18
+ version: "4.2.3",
19
+ silent: true,
20
+ });
21
+
22
+ // DO CONFIGURE
23
+ const error: Error | null = await (async () => {
24
+ try {
25
+ await _Configure(pack, args);
26
+ return null;
27
+ } catch (exp) {
28
+ return exp as Error;
29
+ }
30
+ })();
31
+
32
+ // REMOVE IT
33
+ if (installed)
34
+ pack.erase({
35
+ modulo: "comment-json",
36
+ silent: true,
37
+ });
38
+ if (error !== null) throw error;
39
+ }
40
+
41
+ async function _Configure(
42
+ pack: PackageManager,
43
+ args: TypiaSetupWizard.IArguments,
44
+ ): Promise<void> {
45
+ // GET COMPILER-OPTIONS
46
+ const Comment: typeof import("comment-json") =
47
+ await FileRetriever.require(
48
+ path.join("node_modules", "comment-json"),
49
+ )(pack.directory);
50
+
51
+ const config: Comment.CommentObject = Comment.parse(
52
+ await fs.promises.readFile(args.project!, "utf8"),
53
+ ) as Comment.CommentObject;
54
+ const compilerOptions = config.compilerOptions as
55
+ | Comment.CommentObject
56
+ | undefined;
57
+ if (compilerOptions === undefined)
58
+ throw new Error(
59
+ `${args.project} file does not have "compilerOptions" property.`,
60
+ );
61
+
62
+ // PREPARE PLUGINS
63
+ const plugins: Comment.CommentArray<Comment.CommentObject> = (() => {
64
+ const plugins = compilerOptions.plugins as
65
+ | Comment.CommentArray<Comment.CommentObject>
66
+ | undefined;
67
+ if (plugins === undefined)
68
+ return (compilerOptions.plugins = [] as any);
69
+ else if (!Array.isArray(plugins))
70
+ throw new Error(
71
+ `"plugins" property of ${args.project} must be array type.`,
72
+ );
73
+ return plugins;
74
+ })();
75
+
76
+ const strict: boolean = compilerOptions.strict === true;
77
+ const oldbie: Comment.CommentObject | undefined = plugins.find(
78
+ (p) =>
79
+ typeof p === "object" &&
80
+ p !== null &&
81
+ p.transform === "typia/lib/transform",
82
+ );
83
+ if (strict === true && oldbie !== undefined) return;
84
+
85
+ // DO CONFIGURE
86
+ compilerOptions.strict = true;
87
+ if (oldbie === undefined)
88
+ plugins.push(
89
+ Comment.parse(`
90
+ {
91
+ "transform": "typia/lib/transform"
92
+ }`) as Comment.CommentObject,
93
+ );
94
+ await fs.promises.writeFile(
95
+ args.project!,
96
+ Comment.stringify(config, null, 2),
97
+ );
98
+ }
99
+ }
@@ -1,142 +1,142 @@
1
- import ts from "typescript";
2
-
3
- import { Metadata } from "../../../metadata/Metadata";
4
- import { MetadataObject } from "../../../metadata/MetadataObject";
5
- import { MetadataProperty } from "../../../metadata/MetadataProperty";
6
-
7
- import { Writable } from "../../../typings/Writable";
8
-
9
- import { ArrayUtil } from "../../../utils/ArrayUtil";
10
-
11
- import { CommentFactory } from "../../CommentFactory";
12
- import { MetadataCollection } from "../../MetadataCollection";
13
- import { MetadataFactory } from "../../MetadataFactory";
14
- import { MetadataTagFactory } from "../../MetadataTagFactory";
15
- import { MetadataHelper } from "./MetadataHelper";
16
- import { explore_metadata } from "./explore_metadata";
17
-
18
- export const emplace_metadata_object =
19
- (checker: ts.TypeChecker) =>
20
- (options: MetadataFactory.IOptions) =>
21
- (collection: MetadataCollection) =>
22
- (parent: ts.Type, nullable: boolean): MetadataObject => {
23
- // EMPLACE OBJECT
24
- const [obj, newbie] = collection.emplace(checker, parent);
25
- ArrayUtil.add(obj.nullables, nullable, (elem) => elem === nullable);
26
- if (newbie === false) return obj;
27
-
28
- // PREPARE ASSETS
29
- const isClass: boolean = parent.isClass();
30
- const pred: (node: ts.Declaration) => boolean = isClass
31
- ? (node) => {
32
- const kind: ts.SyntaxKind | undefined = node
33
- .getChildren()[0]
34
- ?.getChildren()[0]?.kind;
35
- return (
36
- kind !== ts.SyntaxKind.PrivateKeyword &&
37
- kind !== ts.SyntaxKind.ProtectedKeyword &&
38
- (ts.isParameter(node) || isProperty(node))
39
- );
40
- }
41
- : (node) => isProperty(node);
42
-
43
- const insert =
44
- (key: Metadata) =>
45
- (value: Metadata) =>
46
- (identifier: () => string) =>
47
- (
48
- symbol: ts.Symbol | undefined,
49
- filter?: (doc: ts.JSDocTagInfo) => boolean,
50
- ): MetadataProperty => {
51
- // COMMENTS AND TAGS
52
- const description: string | undefined =
53
- CommentFactory.generate(
54
- symbol?.getDocumentationComment(checker) || [],
55
- ) || undefined;
56
- const jsDocTags: ts.JSDocTagInfo[] = (
57
- symbol?.getJsDocTags() || []
58
- ).filter(filter || (() => true));
59
-
60
- // THE PROPERTY
61
- const property = MetadataProperty.create({
62
- key,
63
- value,
64
- description,
65
- jsDocTags,
66
- tags: MetadataTagFactory.generate(
67
- () => identifier(),
68
- value,
69
- jsDocTags,
70
- ),
71
- });
72
- obj.properties.push(property);
73
- return property;
74
- };
75
-
76
- //----
77
- // REGULAR PROPERTIES
78
- //----
79
- for (const prop of parent.getApparentProperties()) {
80
- // CHECK INTERNAL TAG
81
- if (
82
- (prop.getJsDocTags(checker) || []).find(
83
- (tag) => tag.name === "internal",
84
- ) !== undefined
85
- )
86
- continue;
87
-
88
- // CHECK NODE IS A FORMAL PROPERTY
89
- const [node, type] = (() => {
90
- const node = (prop.getDeclarations() || [])[0] as
91
- | ts.PropertyDeclaration
92
- | undefined;
93
- const type: ts.Type | undefined = node
94
- ? checker.getTypeOfSymbolAtLocation(prop, node)
95
- : "getTypeOfPropertyOfType" in checker
96
- ? (checker as any).getTypeOfPropertyOfType(
97
- parent,
98
- prop.name,
99
- )
100
- : undefined;
101
- return [node, type];
102
- })();
103
- if ((node && pred(node) === false) || type === undefined) continue;
104
-
105
- // GET EXACT TYPE
106
- const key: Metadata = MetadataHelper.literal_to_metadata(prop.name);
107
- const value: Metadata = explore_metadata(checker)(options)(
108
- collection,
109
- )(type, false);
110
-
111
- // INSERT WITH REQUIRED CONFIGURATION
112
- if (node?.questionToken) Writable(value).required = false;
113
- insert(key)(value)(() => `${obj.name}.${prop.name}`)(prop);
114
- }
115
-
116
- //----
117
- // DYNAMIC PROPERTIES
118
- //----
119
- for (const index of checker.getIndexInfosOfType(parent)) {
120
- // GET EXACT TYPE
121
- const analyzer = (type: ts.Type) =>
122
- explore_metadata(checker)(options)(collection)(type, false);
123
- const key: Metadata = analyzer(index.keyType);
124
- const value: Metadata = analyzer(index.type);
125
-
126
- // INSERT WITH REQUIRED CONFIGURATION
127
- insert(key)(value)(() => `${obj.name}[${key.getName()}]`)(
128
- index.declaration?.parent
129
- ? checker.getSymbolAtLocation(index.declaration.parent)
130
- : undefined,
131
- (doc) => doc.name !== "default",
132
- );
133
- }
134
-
135
- return obj;
136
- };
137
-
138
- const isProperty = (node: ts.Declaration) =>
139
- ts.isPropertyDeclaration(node) ||
140
- ts.isPropertyAssignment(node) ||
141
- ts.isPropertySignature(node) ||
142
- ts.isTypeLiteralNode(node);
1
+ import ts from "typescript";
2
+
3
+ import { Metadata } from "../../../metadata/Metadata";
4
+ import { MetadataObject } from "../../../metadata/MetadataObject";
5
+ import { MetadataProperty } from "../../../metadata/MetadataProperty";
6
+
7
+ import { Writable } from "../../../typings/Writable";
8
+
9
+ import { ArrayUtil } from "../../../utils/ArrayUtil";
10
+
11
+ import { CommentFactory } from "../../CommentFactory";
12
+ import { MetadataCollection } from "../../MetadataCollection";
13
+ import { MetadataFactory } from "../../MetadataFactory";
14
+ import { MetadataTagFactory } from "../../MetadataTagFactory";
15
+ import { MetadataHelper } from "./MetadataHelper";
16
+ import { explore_metadata } from "./explore_metadata";
17
+
18
+ export const emplace_metadata_object =
19
+ (checker: ts.TypeChecker) =>
20
+ (options: MetadataFactory.IOptions) =>
21
+ (collection: MetadataCollection) =>
22
+ (parent: ts.Type, nullable: boolean): MetadataObject => {
23
+ // EMPLACE OBJECT
24
+ const [obj, newbie] = collection.emplace(checker, parent);
25
+ ArrayUtil.add(obj.nullables, nullable, (elem) => elem === nullable);
26
+ if (newbie === false) return obj;
27
+
28
+ // PREPARE ASSETS
29
+ const isClass: boolean = parent.isClass();
30
+ const pred: (node: ts.Declaration) => boolean = isClass
31
+ ? (node) => {
32
+ const kind: ts.SyntaxKind | undefined = node
33
+ .getChildren()[0]
34
+ ?.getChildren()[0]?.kind;
35
+ return (
36
+ kind !== ts.SyntaxKind.PrivateKeyword &&
37
+ kind !== ts.SyntaxKind.ProtectedKeyword &&
38
+ (ts.isParameter(node) || isProperty(node))
39
+ );
40
+ }
41
+ : (node) => isProperty(node);
42
+
43
+ const insert =
44
+ (key: Metadata) =>
45
+ (value: Metadata) =>
46
+ (identifier: () => string) =>
47
+ (
48
+ symbol: ts.Symbol | undefined,
49
+ filter?: (doc: ts.JSDocTagInfo) => boolean,
50
+ ): MetadataProperty => {
51
+ // COMMENTS AND TAGS
52
+ const description: string | undefined =
53
+ CommentFactory.generate(
54
+ symbol?.getDocumentationComment(checker) || [],
55
+ ) || undefined;
56
+ const jsDocTags: ts.JSDocTagInfo[] = (
57
+ symbol?.getJsDocTags() || []
58
+ ).filter(filter || (() => true));
59
+
60
+ // THE PROPERTY
61
+ const property = MetadataProperty.create({
62
+ key,
63
+ value,
64
+ description,
65
+ jsDocTags,
66
+ tags: MetadataTagFactory.generate(
67
+ () => identifier(),
68
+ value,
69
+ jsDocTags,
70
+ ),
71
+ });
72
+ obj.properties.push(property);
73
+ return property;
74
+ };
75
+
76
+ //----
77
+ // REGULAR PROPERTIES
78
+ //----
79
+ for (const prop of parent.getApparentProperties()) {
80
+ // CHECK INTERNAL TAG
81
+ if (
82
+ (prop.getJsDocTags(checker) || []).find(
83
+ (tag) => tag.name === "internal",
84
+ ) !== undefined
85
+ )
86
+ continue;
87
+
88
+ // CHECK NODE IS A FORMAL PROPERTY
89
+ const [node, type] = (() => {
90
+ const node = (prop.getDeclarations() || [])[0] as
91
+ | ts.PropertyDeclaration
92
+ | undefined;
93
+ const type: ts.Type | undefined = node
94
+ ? checker.getTypeOfSymbolAtLocation(prop, node)
95
+ : "getTypeOfPropertyOfType" in checker
96
+ ? (checker as any).getTypeOfPropertyOfType(
97
+ parent,
98
+ prop.name,
99
+ )
100
+ : undefined;
101
+ return [node, type];
102
+ })();
103
+ if ((node && pred(node) === false) || type === undefined) continue;
104
+
105
+ // GET EXACT TYPE
106
+ const key: Metadata = MetadataHelper.literal_to_metadata(prop.name);
107
+ const value: Metadata = explore_metadata(checker)(options)(
108
+ collection,
109
+ )(type, false);
110
+
111
+ // INSERT WITH REQUIRED CONFIGURATION
112
+ if (node?.questionToken) Writable(value).required = false;
113
+ insert(key)(value)(() => `${obj.name}.${prop.name}`)(prop);
114
+ }
115
+
116
+ //----
117
+ // DYNAMIC PROPERTIES
118
+ //----
119
+ for (const index of checker.getIndexInfosOfType(parent)) {
120
+ // GET EXACT TYPE
121
+ const analyzer = (type: ts.Type) =>
122
+ explore_metadata(checker)(options)(collection)(type, false);
123
+ const key: Metadata = analyzer(index.keyType);
124
+ const value: Metadata = analyzer(index.type);
125
+
126
+ // INSERT WITH REQUIRED CONFIGURATION
127
+ insert(key)(value)(() => `${obj.name}[${key.getName()}]`)(
128
+ index.declaration?.parent
129
+ ? checker.getSymbolAtLocation(index.declaration.parent)
130
+ : undefined,
131
+ (doc) => doc.name !== "default",
132
+ );
133
+ }
134
+
135
+ return obj;
136
+ };
137
+
138
+ const isProperty = (node: ts.Declaration) =>
139
+ ts.isPropertyDeclaration(node) ||
140
+ ts.isPropertyAssignment(node) ||
141
+ ts.isPropertySignature(node) ||
142
+ ts.isTypeLiteralNode(node);
@@ -1,4 +1,5 @@
1
1
  export function $is_uuid(str: string): boolean {
2
2
  return REGEX.test(str);
3
3
  }
4
- const REGEX = /^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i;
4
+ const REGEX =
5
+ /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;