@nestia/migrate 0.7.4 → 0.7.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 (116) hide show
  1. package/lib/MigrateApplication.d.ts +9 -2
  2. package/lib/MigrateApplication.js +14 -8
  3. package/lib/MigrateApplication.js.map +1 -1
  4. package/lib/analyzers/MigrateAnalyzer.js +2 -2
  5. package/lib/analyzers/MigrateAnalyzer.js.map +1 -1
  6. package/lib/analyzers/{ControllerAnalyzer.d.ts → MigrateControllerAnalyzer.d.ts} +1 -1
  7. package/lib/analyzers/{ControllerAnalyzer.js → MigrateControllerAnalyzer.js} +11 -9
  8. package/lib/analyzers/MigrateControllerAnalyzer.js.map +1 -0
  9. package/lib/analyzers/{MethodAnalyzer.d.ts → MigrateMethodAnalyzer.d.ts} +1 -1
  10. package/lib/analyzers/{MethodAnalyzer.js → MigrateMethodAnalyzer.js} +26 -25
  11. package/lib/analyzers/MigrateMethodAnalyzer.js.map +1 -0
  12. package/lib/archivers/{FileArchiver.d.ts → MigrateFileArchiver.d.ts} +1 -1
  13. package/lib/archivers/{FileArchiver.js → MigrateFileArchiver.js} +6 -6
  14. package/lib/archivers/MigrateFileArchiver.js.map +1 -0
  15. package/lib/bundles/NEST_TEMPLATE.js +3 -3
  16. package/lib/bundles/NEST_TEMPLATE.js.map +1 -1
  17. package/lib/bundles/SDK_TEMPLATE.js +1 -1
  18. package/lib/executable/bundle.js +1 -0
  19. package/lib/executable/bundle.js.map +1 -1
  20. package/lib/internal/MigrateCommander.js +3 -3
  21. package/lib/internal/MigrateCommander.js.map +1 -1
  22. package/lib/programmers/{ApiFileProgrammer.d.ts → MigrateApiFileProgrammer.d.ts} +1 -1
  23. package/lib/programmers/MigrateApiFileProgrammer.js +28 -0
  24. package/lib/programmers/MigrateApiFileProgrammer.js.map +1 -0
  25. package/lib/programmers/{ApiFunctionProgrammer.d.ts → MigrateApiFunctionProgrammer.d.ts} +4 -4
  26. package/lib/programmers/{ApiFunctionProgrammer.js → MigrateApiFunctionProgrammer.js} +10 -10
  27. package/lib/programmers/MigrateApiFunctionProgrammer.js.map +1 -0
  28. package/lib/programmers/{ApiNamespaceProgrammer.d.ts → MigrateApiNamespaceProgrammer.d.ts} +3 -3
  29. package/lib/programmers/{ApiNamespaceProgrammer.js → MigrateApiNamespaceProgrammer.js} +19 -19
  30. package/lib/programmers/MigrateApiNamespaceProgrammer.js.map +1 -0
  31. package/lib/programmers/{ApiProgrammer.d.ts → MigrateApiProgrammer.d.ts} +1 -1
  32. package/lib/programmers/{ApiProgrammer.js → MigrateApiProgrammer.js} +25 -20
  33. package/lib/programmers/MigrateApiProgrammer.js.map +1 -0
  34. package/lib/programmers/{ApiSimulatationProgrammer.d.ts → MigrateApiSimulatationProgrammer.d.ts} +4 -4
  35. package/lib/programmers/{ApiSimulatationProgrammer.js → MigrateApiSimulatationProgrammer.js} +16 -16
  36. package/lib/programmers/MigrateApiSimulatationProgrammer.js.map +1 -0
  37. package/lib/programmers/{DtoProgrammer.d.ts → MigrateDtoProgrammer.d.ts} +3 -3
  38. package/lib/programmers/{DtoProgrammer.js → MigrateDtoProgrammer.js} +8 -8
  39. package/lib/programmers/MigrateDtoProgrammer.js.map +1 -0
  40. package/lib/programmers/{ImportProgrammer.d.ts → MigrateImportProgrammer.d.ts} +3 -3
  41. package/lib/programmers/{ImportProgrammer.js → MigrateImportProgrammer.js} +7 -5
  42. package/lib/programmers/MigrateImportProgrammer.js.map +1 -0
  43. package/lib/programmers/{NestControllerProgrammer.d.ts → MigrateNestControllerProgrammer.d.ts} +1 -1
  44. package/lib/programmers/{NestControllerProgrammer.js → MigrateNestControllerProgrammer.js} +11 -11
  45. package/lib/programmers/MigrateNestControllerProgrammer.js.map +1 -0
  46. package/lib/programmers/{NestMethodProgrammer.d.ts → MigrateNestMethodProgrammer.d.ts} +3 -3
  47. package/lib/programmers/{NestMethodProgrammer.js → MigrateNestMethodProgrammer.js} +13 -11
  48. package/lib/programmers/MigrateNestMethodProgrammer.js.map +1 -0
  49. package/lib/programmers/{NestModuleProgrammer.d.ts → MigrateNestModuleProgrammer.d.ts} +1 -1
  50. package/lib/programmers/{NestModuleProgrammer.js → MigrateNestModuleProgrammer.js} +8 -8
  51. package/lib/programmers/MigrateNestModuleProgrammer.js.map +1 -0
  52. package/lib/programmers/{NestProgrammer.d.ts → MigrateNestProgrammer.d.ts} +1 -1
  53. package/lib/programmers/{NestProgrammer.js → MigrateNestProgrammer.js} +17 -15
  54. package/lib/programmers/MigrateNestProgrammer.js.map +1 -0
  55. package/lib/programmers/{SchemaProgrammer.d.ts → MigrateSchemaProgrammer.d.ts} +3 -3
  56. package/lib/programmers/{SchemaProgrammer.js → MigrateSchemaProgrammer.js} +23 -23
  57. package/lib/programmers/MigrateSchemaProgrammer.js.map +1 -0
  58. package/lib/structures/IMigrateRoute.d.ts +1 -0
  59. package/lib/utils/FilePrinter.d.ts +1 -1
  60. package/lib/utils/FilePrinter.js +1 -1
  61. package/lib/utils/FilePrinter.js.map +1 -1
  62. package/lib/utils/{JsonTypeChecker.d.ts → SwaggerTypeChecker.d.ts} +1 -1
  63. package/lib/utils/SwaggerTypeChecker.js +34 -0
  64. package/lib/utils/SwaggerTypeChecker.js.map +1 -0
  65. package/package.json +68 -68
  66. package/src/IMigrateConfig.ts +4 -4
  67. package/src/MigrateApplication.ts +48 -35
  68. package/src/analyzers/MigrateAnalyzer.ts +13 -13
  69. package/src/analyzers/{ControllerAnalyzer.ts → MigrateControllerAnalyzer.ts} +122 -123
  70. package/src/analyzers/{MethodAnalyzer.ts → MigrateMethodAnalyzer.ts} +348 -347
  71. package/src/archivers/{FileArchiver.ts → MigrateFileArchiver.ts} +38 -38
  72. package/src/bundles/NEST_TEMPLATE.ts +3 -3
  73. package/src/bundles/SDK_TEMPLATE.ts +1 -1
  74. package/src/executable/bundle.ts +109 -108
  75. package/src/executable/migrate.ts +7 -7
  76. package/src/internal/MigrateCommander.ts +51 -52
  77. package/src/internal/MigrateInquirer.ts +79 -79
  78. package/src/module.ts +4 -4
  79. package/src/programmers/{ApiFileProgrammer.ts → MigrateApiFileProgrammer.ts} +53 -53
  80. package/src/programmers/{ApiFunctionProgrammer.ts → MigrateApiFunctionProgrammer.ts} +203 -203
  81. package/src/programmers/{ApiNamespaceProgrammer.ts → MigrateApiNamespaceProgrammer.ts} +430 -418
  82. package/src/programmers/{ApiProgrammer.ts → MigrateApiProgrammer.ts} +132 -128
  83. package/src/programmers/{ApiSimulatationProgrammer.ts → MigrateApiSimulatationProgrammer.ts} +328 -328
  84. package/src/programmers/{DtoProgrammer.ts → MigrateDtoProgrammer.ts} +78 -74
  85. package/src/programmers/{ImportProgrammer.ts → MigrateImportProgrammer.ts} +116 -114
  86. package/src/programmers/{NestControllerProgrammer.ts → MigrateNestControllerProgrammer.ts} +50 -48
  87. package/src/programmers/{NestMethodProgrammer.ts → MigrateNestMethodProgrammer.ts} +249 -243
  88. package/src/programmers/{NestModuleProgrammer.ts → MigrateNestModuleProgrammer.ts} +62 -62
  89. package/src/programmers/{NestProgrammer.ts → MigrateNestProgrammer.ts} +74 -74
  90. package/src/programmers/{SchemaProgrammer.ts → MigrateSchemaProgrammer.ts} +257 -255
  91. package/src/structures/IMigrateProgram.ts +9 -9
  92. package/src/structures/IMigrateRoute.ts +46 -45
  93. package/src/structures/ISwaggeSchema.ts +90 -90
  94. package/src/structures/ISwaggerInfo.ts +80 -80
  95. package/src/utils/FilePrinter.ts +36 -36
  96. package/src/utils/SetupWizard.ts +12 -12
  97. package/src/utils/StringUtil.ts +60 -60
  98. package/src/utils/{JsonTypeChecker.ts → SwaggerTypeChecker.ts} +67 -67
  99. package/lib/analyzers/ControllerAnalyzer.js.map +0 -1
  100. package/lib/analyzers/MethodAnalyzer.js.map +0 -1
  101. package/lib/archivers/FileArchiver.js.map +0 -1
  102. package/lib/programmers/ApiFileProgrammer.js +0 -28
  103. package/lib/programmers/ApiFileProgrammer.js.map +0 -1
  104. package/lib/programmers/ApiFunctionProgrammer.js.map +0 -1
  105. package/lib/programmers/ApiNamespaceProgrammer.js.map +0 -1
  106. package/lib/programmers/ApiProgrammer.js.map +0 -1
  107. package/lib/programmers/ApiSimulatationProgrammer.js.map +0 -1
  108. package/lib/programmers/DtoProgrammer.js.map +0 -1
  109. package/lib/programmers/ImportProgrammer.js.map +0 -1
  110. package/lib/programmers/NestControllerProgrammer.js.map +0 -1
  111. package/lib/programmers/NestMethodProgrammer.js.map +0 -1
  112. package/lib/programmers/NestModuleProgrammer.js.map +0 -1
  113. package/lib/programmers/NestProgrammer.js.map +0 -1
  114. package/lib/programmers/SchemaProgrammer.js.map +0 -1
  115. package/lib/utils/JsonTypeChecker.js +0 -34
  116. package/lib/utils/JsonTypeChecker.js.map +0 -1
@@ -1,90 +1,90 @@
1
- export type ISwaggerSchema =
2
- | ISwaggerSchema.IUnknown
3
- | ISwaggerSchema.INullOnly
4
- | ISwaggerSchema.IAnyOf
5
- | ISwaggerSchema.IOneOf
6
- | ISwaggerSchema.IBoolean
7
- | ISwaggerSchema.IInteger
8
- | ISwaggerSchema.INumber
9
- | ISwaggerSchema.IString
10
- | ISwaggerSchema.IArray
11
- | ISwaggerSchema.IObject
12
- | ISwaggerSchema.IReference;
13
- export namespace ISwaggerSchema {
14
- export interface IUnknown extends IAttribute {
15
- type?: undefined;
16
- }
17
- export interface INullOnly extends IAttribute {
18
- type: "null";
19
- }
20
-
21
- export interface IAnyOf extends IAttribute {
22
- anyOf: ISwaggerSchema[];
23
- }
24
- export interface IOneOf extends IAttribute {
25
- oneOf: ISwaggerSchema[];
26
- }
27
-
28
- export interface IBoolean extends ISignificant<"boolean"> {
29
- default?: boolean;
30
- enum?: boolean[];
31
- }
32
- export interface IInteger extends ISignificant<"integer"> {
33
- /** @type int */ default?: number;
34
- /** @type int */ enum?: number[];
35
- /** @type int */ minimum?: number;
36
- /** @type int */ maximum?: number;
37
- /** @type int */ exclusiveMinimum?: boolean;
38
- /** @type int */ exclusiveMaximum?: boolean;
39
- /** @type uint */ multipleOf?: number;
40
- }
41
- export interface INumber extends ISignificant<"number"> {
42
- default?: number;
43
- enum?: number[];
44
- minimum?: number;
45
- maximum?: number;
46
- exclusiveMinimum?: boolean;
47
- exclusiveMaximum?: boolean;
48
- multipleOf?: number;
49
- }
50
- export interface IString extends ISignificant<"string"> {
51
- default?: string;
52
- enum?: string[];
53
- format?: string;
54
- pattern?: string;
55
- /** @type uint */ minLength?: number;
56
- /** @type uint */ maxLength?: number;
57
- }
58
-
59
- export interface IArray extends ISignificant<"array"> {
60
- items: ISwaggerSchema;
61
- /** @type uint */ minItems?: number;
62
- /** @type uint */ maxItems?: number;
63
- "x-typia-tuple"?: ITuple;
64
- }
65
- export interface ITuple extends ISignificant<"array"> {
66
- items: ISwaggerSchema[];
67
- }
68
- export interface IObject extends ISignificant<"object"> {
69
- properties?: Record<string, ISwaggerSchema>;
70
- required?: string[];
71
- additionalProperties?: ISwaggerSchema | boolean;
72
- "x-typia-patternProperties"?: Record<string, ISwaggerSchema>;
73
- }
74
-
75
- export interface IReference extends IAttribute {
76
- $ref: string;
77
- }
78
-
79
- interface ISignificant<Type extends string> extends IAttribute {
80
- type: Type;
81
- nullable?: boolean;
82
- }
83
- interface IAttribute {
84
- title?: string;
85
- description?: string;
86
- deprecated?: boolean;
87
- "x-typia-optional"?: boolean;
88
- "x-typia-rest"?: boolean;
89
- }
90
- }
1
+ export type ISwaggerSchema =
2
+ | ISwaggerSchema.IUnknown
3
+ | ISwaggerSchema.INullOnly
4
+ | ISwaggerSchema.IAnyOf
5
+ | ISwaggerSchema.IOneOf
6
+ | ISwaggerSchema.IBoolean
7
+ | ISwaggerSchema.IInteger
8
+ | ISwaggerSchema.INumber
9
+ | ISwaggerSchema.IString
10
+ | ISwaggerSchema.IArray
11
+ | ISwaggerSchema.IObject
12
+ | ISwaggerSchema.IReference;
13
+ export namespace ISwaggerSchema {
14
+ export interface IUnknown extends IAttribute {
15
+ type?: undefined;
16
+ }
17
+ export interface INullOnly extends IAttribute {
18
+ type: "null";
19
+ }
20
+
21
+ export interface IAnyOf extends IAttribute {
22
+ anyOf: ISwaggerSchema[];
23
+ }
24
+ export interface IOneOf extends IAttribute {
25
+ oneOf: ISwaggerSchema[];
26
+ }
27
+
28
+ export interface IBoolean extends ISignificant<"boolean"> {
29
+ default?: boolean;
30
+ enum?: boolean[];
31
+ }
32
+ export interface IInteger extends ISignificant<"integer"> {
33
+ /** @type int */ default?: number;
34
+ /** @type int */ enum?: number[];
35
+ /** @type int */ minimum?: number;
36
+ /** @type int */ maximum?: number;
37
+ /** @type int */ exclusiveMinimum?: boolean;
38
+ /** @type int */ exclusiveMaximum?: boolean;
39
+ /** @type uint */ multipleOf?: number;
40
+ }
41
+ export interface INumber extends ISignificant<"number"> {
42
+ default?: number;
43
+ enum?: number[];
44
+ minimum?: number;
45
+ maximum?: number;
46
+ exclusiveMinimum?: boolean;
47
+ exclusiveMaximum?: boolean;
48
+ multipleOf?: number;
49
+ }
50
+ export interface IString extends ISignificant<"string"> {
51
+ default?: string;
52
+ enum?: string[];
53
+ format?: string;
54
+ pattern?: string;
55
+ /** @type uint */ minLength?: number;
56
+ /** @type uint */ maxLength?: number;
57
+ }
58
+
59
+ export interface IArray extends ISignificant<"array"> {
60
+ items: ISwaggerSchema;
61
+ /** @type uint */ minItems?: number;
62
+ /** @type uint */ maxItems?: number;
63
+ "x-typia-tuple"?: ITuple;
64
+ }
65
+ export interface ITuple extends ISignificant<"array"> {
66
+ items: ISwaggerSchema[];
67
+ }
68
+ export interface IObject extends ISignificant<"object"> {
69
+ properties?: Record<string, ISwaggerSchema>;
70
+ required?: string[];
71
+ additionalProperties?: ISwaggerSchema | boolean;
72
+ "x-typia-patternProperties"?: Record<string, ISwaggerSchema>;
73
+ }
74
+
75
+ export interface IReference extends IAttribute {
76
+ $ref: string;
77
+ }
78
+
79
+ interface ISignificant<Type extends string> extends IAttribute {
80
+ type: Type;
81
+ nullable?: boolean;
82
+ }
83
+ interface IAttribute {
84
+ title?: string;
85
+ description?: string;
86
+ deprecated?: boolean;
87
+ "x-typia-optional"?: boolean;
88
+ "x-typia-rest"?: boolean;
89
+ }
90
+ }
@@ -1,80 +1,80 @@
1
- /**
2
- * Information about the API.
3
- *
4
- * @author Samchon
5
- */
6
- export interface ISwaggerInfo {
7
- /**
8
- * The title of the API.
9
- */
10
- title: string;
11
-
12
- /**
13
- * A short description of the API.
14
- */
15
- description?: string;
16
-
17
- /**
18
- * A URL to the Terms of Service for the API.
19
- *
20
- * @format uri
21
- */
22
- termsOfService?: string;
23
-
24
- /**
25
- * The contact information for the exposed API.
26
- */
27
- contact?: ISwaggerInfo.IContact;
28
-
29
- /**
30
- * The license information for the exposed API.
31
- */
32
- license?: ISwaggerInfo.ILicense;
33
-
34
- /**
35
- * Version of the API.
36
- */
37
- version: string;
38
- }
39
- export namespace ISwaggerInfo {
40
- /**
41
- * Contact information for the exposed API.
42
- */
43
- export interface IContact {
44
- /**
45
- * The identifying name of the contact person/organization.
46
- */
47
- name?: string;
48
-
49
- /**
50
- * The URL pointing to the contact information.
51
- *
52
- * @format uri
53
- */
54
- url?: string;
55
-
56
- /**
57
- * The email address of the contact person/organization.
58
- *
59
- * @format email
60
- */
61
- email?: string;
62
- }
63
-
64
- /**
65
- * License information for the exposed API.
66
- */
67
- export interface ILicense {
68
- /**
69
- * The license name used for the API.
70
- */
71
- name: string;
72
-
73
- /**
74
- * A URL to the license used for the API.
75
- *
76
- * @format uri
77
- */
78
- url?: string;
79
- }
80
- }
1
+ /**
2
+ * Information about the API.
3
+ *
4
+ * @author Samchon
5
+ */
6
+ export interface ISwaggerInfo {
7
+ /**
8
+ * The title of the API.
9
+ */
10
+ title: string;
11
+
12
+ /**
13
+ * A short description of the API.
14
+ */
15
+ description?: string;
16
+
17
+ /**
18
+ * A URL to the Terms of Service for the API.
19
+ *
20
+ * @format uri
21
+ */
22
+ termsOfService?: string;
23
+
24
+ /**
25
+ * The contact information for the exposed API.
26
+ */
27
+ contact?: ISwaggerInfo.IContact;
28
+
29
+ /**
30
+ * The license information for the exposed API.
31
+ */
32
+ license?: ISwaggerInfo.ILicense;
33
+
34
+ /**
35
+ * Version of the API.
36
+ */
37
+ version: string;
38
+ }
39
+ export namespace ISwaggerInfo {
40
+ /**
41
+ * Contact information for the exposed API.
42
+ */
43
+ export interface IContact {
44
+ /**
45
+ * The identifying name of the contact person/organization.
46
+ */
47
+ name?: string;
48
+
49
+ /**
50
+ * The URL pointing to the contact information.
51
+ *
52
+ * @format uri
53
+ */
54
+ url?: string;
55
+
56
+ /**
57
+ * The email address of the contact person/organization.
58
+ *
59
+ * @format email
60
+ */
61
+ email?: string;
62
+ }
63
+
64
+ /**
65
+ * License information for the exposed API.
66
+ */
67
+ export interface ILicense {
68
+ /**
69
+ * The license name used for the API.
70
+ */
71
+ name: string;
72
+
73
+ /**
74
+ * A URL to the license used for the API.
75
+ *
76
+ * @format uri
77
+ */
78
+ url?: string;
79
+ }
80
+ }
@@ -1,36 +1,36 @@
1
- import ts from "typescript";
2
-
3
- export namespace FilePrinter {
4
- export const description = <Node extends ts.Node>(
5
- node: Node,
6
- comment: string,
7
- ): Node => {
8
- if (comment.length === 0) return node;
9
- ts.addSyntheticLeadingComment(
10
- node,
11
- ts.SyntaxKind.MultiLineCommentTrivia,
12
- ["*", ...comment.split("\n").map((str) => ` * ${str}`), ""].join("\n"),
13
- true,
14
- );
15
- return node;
16
- };
17
-
18
- export const enter = () =>
19
- ts.factory.createExpressionStatement(ts.factory.createIdentifier("\n"));
20
-
21
- export const write = (props: {
22
- statements: ts.Statement[];
23
- top?: string;
24
- }): string => {
25
- const script: string = ts
26
- .createPrinter()
27
- .printFile(
28
- ts.factory.createSourceFile(
29
- props.statements,
30
- ts.factory.createToken(ts.SyntaxKind.EndOfFileToken),
31
- ts.NodeFlags.None,
32
- ),
33
- );
34
- return (props.top ?? "") + script;
35
- };
36
- }
1
+ import ts from "typescript";
2
+
3
+ export namespace FilePrinter {
4
+ export const description = <Node extends ts.Node>(
5
+ node: Node,
6
+ comment: string,
7
+ ): Node => {
8
+ if (comment.length === 0) return node;
9
+ ts.addSyntheticLeadingComment(
10
+ node,
11
+ ts.SyntaxKind.MultiLineCommentTrivia,
12
+ ["*", ...comment.split("\n").map((str) => ` * ${str}`), ""].join("\n"),
13
+ true,
14
+ );
15
+ return node;
16
+ };
17
+
18
+ export const newLine = () =>
19
+ ts.factory.createExpressionStatement(ts.factory.createIdentifier("\n"));
20
+
21
+ export const write = (props: {
22
+ statements: ts.Statement[];
23
+ top?: string;
24
+ }): string => {
25
+ const script: string = ts
26
+ .createPrinter()
27
+ .printFile(
28
+ ts.factory.createSourceFile(
29
+ props.statements,
30
+ ts.factory.createToken(ts.SyntaxKind.EndOfFileToken),
31
+ ts.NodeFlags.None,
32
+ ),
33
+ );
34
+ return (props.top ?? "") + script;
35
+ };
36
+ }
@@ -1,12 +1,12 @@
1
- import cp from "child_process";
2
-
3
- export namespace SetupWizard {
4
- export const setup = (output: string) => {
5
- execute(output)("npm install");
6
- };
7
-
8
- const execute = (cwd: string) => (command: string, fake?: string) => {
9
- console.log(fake ?? command);
10
- cp.execSync(command, { cwd, stdio: "inherit" });
11
- };
12
- }
1
+ import cp from "child_process";
2
+
3
+ export namespace SetupWizard {
4
+ export const setup = (output: string) => {
5
+ execute(output)("npm install");
6
+ };
7
+
8
+ const execute = (cwd: string) => (command: string, fake?: string) => {
9
+ console.log(fake ?? command);
10
+ cp.execSync(command, { cwd, stdio: "inherit" });
11
+ };
12
+ }
@@ -1,60 +1,60 @@
1
- import { NamingConvention } from "typia/lib/utils/NamingConvention";
2
-
3
- export namespace StringUtil {
4
- export const capitalize = (str: string) =>
5
- str[0].toUpperCase() + str.slice(1).toLowerCase();
6
-
7
- export const pascal = (path: string) =>
8
- splitWithNormalization(path)
9
- .filter((str) => str[0] !== "{")
10
- .map(NamingConvention.pascal)
11
- .join("");
12
-
13
- export const camel = (path: string) =>
14
- splitWithNormalization(path)
15
- .map((str, i) =>
16
- i === 0 ? NamingConvention.camel(str) : NamingConvention.pascal(str),
17
- )
18
- .join("");
19
-
20
- export const splitWithNormalization = (path: string) =>
21
- path
22
- .split("/")
23
- .map((str) => normalize(str.trim()))
24
- .filter((str) => !!str.length);
25
-
26
- export const reJoinWithDecimalParameters = (path: string) =>
27
- path
28
- .split("/")
29
- .filter((str) => !!str.length)
30
- .map((str) =>
31
- str[0] === "{" && str[str.length - 1] === "}"
32
- ? `:${str.substring(1, str.length - 1)}`
33
- : str,
34
- )
35
- .join("/");
36
-
37
- export const normalize = (str: string) =>
38
- str.split(".").join("_").split("-").join("_");
39
-
40
- export const commonPrefix = (strs: string[]): string => {
41
- if (strs.length === 0) return "";
42
-
43
- let prefix = strs[0];
44
- for (let i = 1; i < strs.length; i++) {
45
- while (strs[i].indexOf(prefix) !== 0) {
46
- prefix = prefix.substring(0, prefix.length - 1);
47
- if (prefix === "") return "";
48
- }
49
- }
50
- return prefix
51
- .split("/")
52
- .filter((str) => str[0] !== "{" || str[str.length - 1] === "}")
53
- .join("/");
54
- };
55
-
56
- export const escapeDuplicate =
57
- (keep: string[]) =>
58
- (change: string): string =>
59
- keep.includes(change) ? escapeDuplicate(keep)(`_${change}`) : change;
60
- }
1
+ import { NamingConvention } from "typia/lib/utils/NamingConvention";
2
+
3
+ export namespace StringUtil {
4
+ export const capitalize = (str: string) =>
5
+ str[0].toUpperCase() + str.slice(1).toLowerCase();
6
+
7
+ export const pascal = (path: string) =>
8
+ splitWithNormalization(path)
9
+ .filter((str) => str[0] !== "{")
10
+ .map(NamingConvention.pascal)
11
+ .join("");
12
+
13
+ export const camel = (path: string) =>
14
+ splitWithNormalization(path)
15
+ .map((str, i) =>
16
+ i === 0 ? NamingConvention.camel(str) : NamingConvention.pascal(str),
17
+ )
18
+ .join("");
19
+
20
+ export const splitWithNormalization = (path: string) =>
21
+ path
22
+ .split("/")
23
+ .map((str) => normalize(str.trim()))
24
+ .filter((str) => !!str.length);
25
+
26
+ export const reJoinWithDecimalParameters = (path: string) =>
27
+ path
28
+ .split("/")
29
+ .filter((str) => !!str.length)
30
+ .map((str) =>
31
+ str[0] === "{" && str[str.length - 1] === "}"
32
+ ? `:${str.substring(1, str.length - 1)}`
33
+ : str,
34
+ )
35
+ .join("/");
36
+
37
+ export const normalize = (str: string) =>
38
+ str.split(".").join("_").split("-").join("_");
39
+
40
+ export const commonPrefix = (strs: string[]): string => {
41
+ if (strs.length === 0) return "";
42
+
43
+ let prefix = strs[0];
44
+ for (let i = 1; i < strs.length; i++) {
45
+ while (strs[i].indexOf(prefix) !== 0) {
46
+ prefix = prefix.substring(0, prefix.length - 1);
47
+ if (prefix === "") return "";
48
+ }
49
+ }
50
+ return prefix
51
+ .split("/")
52
+ .filter((str) => str[0] !== "{" || str[str.length - 1] === "}")
53
+ .join("/");
54
+ };
55
+
56
+ export const escapeDuplicate =
57
+ (keep: string[]) =>
58
+ (change: string): string =>
59
+ keep.includes(change) ? escapeDuplicate(keep)(`_${change}`) : change;
60
+ }