typia 6.6.0-dev.20240720 → 6.6.0-dev.20240727

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 (64) hide show
  1. package/lib/CamelCase.d.ts +3 -2
  2. package/lib/PascalCase.d.ts +2 -2
  3. package/lib/factories/internal/metadata/iterate_metadata_constant.js +26 -8
  4. package/lib/factories/internal/metadata/iterate_metadata_constant.js.map +1 -1
  5. package/lib/factories/internal/metadata/iterate_metadata_intersection.js +15 -10
  6. package/lib/factories/internal/metadata/iterate_metadata_intersection.js.map +1 -1
  7. package/lib/programmers/CheckerProgrammer.js +2 -1
  8. package/lib/programmers/CheckerProgrammer.js.map +1 -1
  9. package/lib/programmers/internal/application_description.d.ts +2 -2
  10. package/lib/programmers/internal/application_description.js +2 -3
  11. package/lib/programmers/internal/application_description.js.map +1 -1
  12. package/lib/programmers/internal/application_title.d.ts +5 -0
  13. package/lib/programmers/internal/application_title.js +17 -0
  14. package/lib/programmers/internal/application_title.js.map +1 -0
  15. package/lib/programmers/internal/application_v31_alias.js +2 -8
  16. package/lib/programmers/internal/application_v31_alias.js.map +1 -1
  17. package/lib/programmers/internal/application_v31_constant.js +4 -0
  18. package/lib/programmers/internal/application_v31_constant.js.map +1 -1
  19. package/lib/programmers/internal/application_v31_object.js +31 -47
  20. package/lib/programmers/internal/application_v31_object.js.map +1 -1
  21. package/lib/programmers/internal/postfix_of_tuple.d.ts +1 -0
  22. package/lib/programmers/internal/postfix_of_tuple.js +8 -0
  23. package/lib/programmers/internal/postfix_of_tuple.js.map +1 -0
  24. package/lib/programmers/json/JsonStringifyProgrammer.js +2 -1
  25. package/lib/programmers/json/JsonStringifyProgrammer.js.map +1 -1
  26. package/lib/programmers/misc/MiscCloneProgrammer.js +2 -1
  27. package/lib/programmers/misc/MiscCloneProgrammer.js.map +1 -1
  28. package/lib/programmers/misc/MiscPruneProgrammer.js +2 -1
  29. package/lib/programmers/misc/MiscPruneProgrammer.js.map +1 -1
  30. package/lib/programmers/notations/NotationGeneralProgrammer.js +2 -1
  31. package/lib/programmers/notations/NotationGeneralProgrammer.js.map +1 -1
  32. package/lib/schemas/metadata/IMetadataConstantValue.d.ts +3 -0
  33. package/lib/schemas/metadata/MetadataConstantValue.d.ts +3 -0
  34. package/lib/schemas/metadata/MetadataConstantValue.js +2 -0
  35. package/lib/schemas/metadata/MetadataConstantValue.js.map +1 -1
  36. package/lib/utils/NamingConvention/NamingConvention.d.ts +2 -2
  37. package/lib/utils/NamingConvention/NamingConvention.js +53 -72
  38. package/lib/utils/NamingConvention/NamingConvention.js.map +1 -1
  39. package/lib/utils/NamingConvention/NamingConvention.mjs +42 -56
  40. package/lib/utils/NamingConvention/NamingConvention.mjs.map +1 -1
  41. package/lib/utils/StringUtil/StringUtil.js +1 -1
  42. package/lib/utils/StringUtil/StringUtil.js.map +1 -1
  43. package/lib/utils/StringUtil/StringUtil.mjs +1 -1
  44. package/lib/utils/StringUtil/StringUtil.mjs.map +1 -1
  45. package/package.json +1 -1
  46. package/src/CamelCase.ts +14 -7
  47. package/src/PascalCase.ts +10 -7
  48. package/src/factories/internal/metadata/iterate_metadata_constant.ts +13 -0
  49. package/src/factories/internal/metadata/iterate_metadata_intersection.ts +14 -10
  50. package/src/programmers/CheckerProgrammer.ts +2 -1
  51. package/src/programmers/internal/application_description.ts +3 -3
  52. package/src/programmers/internal/application_title.ts +20 -0
  53. package/src/programmers/internal/application_v31_alias.ts +2 -11
  54. package/src/programmers/internal/application_v31_constant.ts +4 -0
  55. package/src/programmers/internal/application_v31_object.ts +2 -17
  56. package/src/programmers/internal/postfix_of_tuple.ts +2 -0
  57. package/src/programmers/json/JsonStringifyProgrammer.ts +2 -1
  58. package/src/programmers/misc/MiscCloneProgrammer.ts +2 -1
  59. package/src/programmers/misc/MiscPruneProgrammer.ts +2 -1
  60. package/src/programmers/notations/NotationGeneralProgrammer.ts +2 -1
  61. package/src/schemas/metadata/IMetadataConstantValue.ts +3 -0
  62. package/src/schemas/metadata/MetadataConstantValue.ts +5 -0
  63. package/src/utils/NamingConvention/NamingConvention.ts +46 -43
  64. package/src/utils/StringUtil/StringUtil.ts +1 -1
@@ -0,0 +1,2 @@
1
+ export const postfix_of_tuple = (str: string): string =>
2
+ str.endsWith('"') ? str.slice(0, -1) : `${str} + "`;
@@ -33,6 +33,7 @@ import { UnionExplorer } from "../helpers/UnionExplorer";
33
33
  import { check_native } from "../internal/check_native";
34
34
  import { decode_union_object } from "../internal/decode_union_object";
35
35
  import { feature_object_entries } from "../internal/feature_object_entries";
36
+ import { postfix_of_tuple } from "../internal/postfix_of_tuple";
36
37
  import { wrap_metadata_rest_tuple } from "../internal/wrap_metadata_rest_tuple";
37
38
 
38
39
  export namespace JsonStringifyProgrammer {
@@ -543,7 +544,7 @@ export namespace JsonStringifyProgrammer {
543
544
  ...explore,
544
545
  from: "array",
545
546
  postfix: explore.postfix.length
546
- ? `${explore.postfix.slice(0, -1)}[${index}]"`
547
+ ? `${postfix_of_tuple(explore.postfix)}[${index}]"`
547
548
  : `"[${index}]"`,
548
549
  },
549
550
  ),
@@ -21,6 +21,7 @@ import { CloneJoiner } from "../helpers/CloneJoiner";
21
21
  import { FunctionImporter } from "../helpers/FunctionImporter";
22
22
  import { UnionExplorer } from "../helpers/UnionExplorer";
23
23
  import { decode_union_object } from "../internal/decode_union_object";
24
+ import { postfix_of_tuple } from "../internal/postfix_of_tuple";
24
25
  import { wrap_metadata_rest_tuple } from "../internal/wrap_metadata_rest_tuple";
25
26
 
26
27
  export namespace MiscCloneProgrammer {
@@ -335,7 +336,7 @@ export namespace MiscCloneProgrammer {
335
336
  ...explore,
336
337
  from: "array",
337
338
  postfix: explore.postfix.length
338
- ? `${explore.postfix.slice(0, -1)}[${index}]"`
339
+ ? `${postfix_of_tuple(explore.postfix)}[${index}]"`
339
340
  : `"[${index}]"`,
340
341
  },
341
342
  ),
@@ -21,6 +21,7 @@ import { FunctionImporter } from "../helpers/FunctionImporter";
21
21
  import { PruneJoiner } from "../helpers/PruneJoiner";
22
22
  import { UnionExplorer } from "../helpers/UnionExplorer";
23
23
  import { decode_union_object } from "../internal/decode_union_object";
24
+ import { postfix_of_tuple } from "../internal/postfix_of_tuple";
24
25
  import { wrap_metadata_rest_tuple } from "../internal/wrap_metadata_rest_tuple";
25
26
 
26
27
  export namespace MiscPruneProgrammer {
@@ -302,7 +303,7 @@ export namespace MiscPruneProgrammer {
302
303
  ...explore,
303
304
  from: "array",
304
305
  postfix: explore.postfix.length
305
- ? `${explore.postfix.slice(0, -1)}[${index}]"`
306
+ ? `${postfix_of_tuple(explore.postfix)}[${index}]"`
306
307
  : `"[${index}]"`,
307
308
  },
308
309
  ),
@@ -23,6 +23,7 @@ import { FunctionImporter } from "../helpers/FunctionImporter";
23
23
  import { NotationJoiner } from "../helpers/NotationJoiner";
24
24
  import { UnionExplorer } from "../helpers/UnionExplorer";
25
25
  import { decode_union_object } from "../internal/decode_union_object";
26
+ import { postfix_of_tuple } from "../internal/postfix_of_tuple";
26
27
  import { wrap_metadata_rest_tuple } from "../internal/wrap_metadata_rest_tuple";
27
28
 
28
29
  export namespace NotationGeneralProgrammer {
@@ -345,7 +346,7 @@ export namespace NotationGeneralProgrammer {
345
346
  ...explore,
346
347
  from: "array",
347
348
  postfix: explore.postfix.length
348
- ? `${explore.postfix.slice(0, -1)}[${index}]"`
349
+ ? `${postfix_of_tuple(explore.postfix)}[${index}]"`
349
350
  : `"[${index}]"`,
350
351
  },
351
352
  ),
@@ -1,8 +1,11 @@
1
1
  import { Atomic } from "../../typings/Atomic";
2
2
 
3
+ import { IJsDocTagInfo } from "./IJsDocTagInfo";
3
4
  import { IMetadataTypeTag } from "./IMetadataTypeTag";
4
5
 
5
6
  export interface IMetadataConstantValue<T extends Atomic.Type> {
6
7
  value: T;
7
8
  tags: IMetadataTypeTag[][] | undefined;
9
+ description?: string | null;
10
+ jsDocTags?: IJsDocTagInfo[];
8
11
  }
@@ -1,16 +1,21 @@
1
1
  import { ClassProperties } from "../../typings/ClassProperties";
2
2
 
3
+ import { IJsDocTagInfo } from "./IJsDocTagInfo";
3
4
  import { IMetadataConstantValue } from "./IMetadataConstantValue";
4
5
  import { IMetadataTypeTag } from "./IMetadataTypeTag";
5
6
 
6
7
  export class MetadataConstantValue {
7
8
  public readonly value: boolean | bigint | number | string;
8
9
  public tags: IMetadataTypeTag[][] | undefined;
10
+ public readonly description?: string | null;
11
+ public readonly jsDocTags?: IJsDocTagInfo[];
9
12
  private name_?: string;
10
13
 
11
14
  private constructor(props: ClassProperties<MetadataConstantValue>) {
12
15
  this.value = props.value;
13
16
  this.tags = props.tags;
17
+ this.description = props.description;
18
+ this.jsDocTags = props.jsDocTags;
14
19
  }
15
20
 
16
21
  public static create(
@@ -1,6 +1,24 @@
1
1
  import { StringUtil } from "../StringUtil";
2
2
 
3
3
  export function snake(str: string): string {
4
+ if (str.length === 0) return str;
5
+
6
+ // PREFIX
7
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
8
+ let prefix: string = "";
9
+ for (let i: number = 0; i < str.length; i++) {
10
+ if (str[i] === "_") prefix += "_";
11
+ else break;
12
+ }
13
+ if (prefix.length !== 0) str = str.substring(prefix.length);
14
+
15
+ const out = (s: string) => `${prefix}${s}`;
16
+
17
+ // SNAKE CASE
18
+ const items: string[] = str.split("_");
19
+ if (items.length > 1) return out(items.map((s) => s.toLowerCase()).join("_"));
20
+
21
+ // CAMEL OR PASCAL CASE
4
22
  const indexes: number[] = [];
5
23
  for (let i: number = 0; i < str.length; i++) {
6
24
  const code: number = str.charCodeAt(i);
@@ -23,29 +41,33 @@ export function snake(str: string): string {
23
41
  ret += "_";
24
42
  }
25
43
  ret += str.substring(indexes[indexes.length - 1]!).toLowerCase();
26
- return ret;
44
+ return out(ret);
27
45
  }
28
46
 
29
- export function camel(str: string): string {
30
- return unsnake((str: string) => {
31
- if (str.length === 0) return str;
32
- else if (str[0] === str[0]!.toUpperCase())
33
- return str[0]!.toLowerCase() + str.substring(1);
34
- else return str;
47
+ export const camel = (str: string): string =>
48
+ unsnake({
49
+ plain: (str) =>
50
+ str.length
51
+ ? str === str.toUpperCase()
52
+ ? str.toLocaleLowerCase()
53
+ : `${str[0]!.toLowerCase()}${str.substring(1)}`
54
+ : str,
55
+ snake: (str, i) =>
56
+ i === 0 ? str.toLowerCase() : StringUtil.capitalize(str.toLowerCase()),
35
57
  })(str);
36
- }
37
58
 
38
- export function pascal(str: string): string {
39
- return unsnake((str: string) => {
40
- if (str.length === 0) return str;
41
- else if (str[0] === str[0]!.toLowerCase())
42
- return str[0]!.toUpperCase() + str.substring(1);
43
- else return str;
59
+ export const pascal = (str: string): string =>
60
+ unsnake({
61
+ plain: (str) =>
62
+ str.length ? `${str[0]!.toUpperCase()}${str.substring(1)}` : str,
63
+ snake: StringUtil.capitalize,
44
64
  })(str);
45
- }
46
65
 
47
66
  const unsnake =
48
- (escaper: (str: string) => string) =>
67
+ (props: {
68
+ plain: (str: string) => string;
69
+ snake: (str: string, index: number) => string;
70
+ }) =>
49
71
  (str: string): string => {
50
72
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
51
73
  let prefix: string = "";
@@ -55,32 +77,13 @@ const unsnake =
55
77
  }
56
78
  if (prefix.length !== 0) str = str.substring(prefix.length);
57
79
 
58
- const indexes: [number, number][] = [];
59
- for (let i: number = 0; i < str.length; i++) {
60
- const ch: string = str[i]!;
61
- if (ch !== "_") continue;
62
-
63
- const last = indexes[indexes.length - 1];
64
- if (last === undefined || last[0] + last[1] !== i) indexes.push([i, 1]);
65
- else ++last[1];
66
- }
67
- if (indexes.length === 0) return prefix + escaper(str);
80
+ const out = (s: string) => `${prefix}${s}`;
81
+ if (str.length === 0) return out("");
68
82
 
69
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
70
- let ret: string = "";
71
- for (let i: number = 0; i < indexes.length; i++) {
72
- const [first] = indexes[i]!;
73
- if (i === 0)
74
- if (first === 0) ret += "_";
75
- else ret += str.substring(0, first);
76
- else {
77
- const [prevFirst, prevLength] = indexes[i - 1]!;
78
- const piece: string = str.substring(prevFirst + prevLength, first);
79
- if (piece.length) ret += StringUtil.capitalize(piece);
80
- }
81
- }
82
- const last = indexes[indexes.length - 1]!;
83
- const piece: string = str.substring(last[0] + last[1]);
84
- if (last.length) ret += StringUtil.capitalize(piece);
85
- return prefix + escaper(ret);
83
+ const items: string[] = str.split("_").filter((s) => s.length !== 0);
84
+ return items.length === 0
85
+ ? out("")
86
+ : items.length === 1
87
+ ? out(props.plain(items[0]!))
88
+ : out(items.map(props.snake).join(""));
86
89
  };
@@ -1,5 +1,5 @@
1
1
  export const capitalize = (str: string) =>
2
- str.length ? str[0]!.toUpperCase() + str.slice(1) : str;
2
+ str.length ? str[0]!.toUpperCase() + str.slice(1).toLowerCase() : str;
3
3
 
4
4
  export const escapeDuplicate =
5
5
  (keep: string[]) =>