typia 5.1.3 → 5.1.4-dev.20230929

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 (66) hide show
  1. package/lib/executable/TypiaSetupWizard.js +1 -19
  2. package/lib/executable/TypiaSetupWizard.js.map +1 -1
  3. package/package.json +1 -1
  4. package/src/executable/TypiaSetupWizard.ts +1 -16
  5. package/src/factories/MetadataCollection.ts +277 -277
  6. package/src/factories/MetadataFactory.ts +238 -238
  7. package/src/factories/MetadataTypeTagFactory.ts +325 -325
  8. package/src/factories/internal/metadata/emend_metadata_atomics.ts +41 -41
  9. package/src/factories/internal/metadata/iterate_metadata_intersection.ts +259 -259
  10. package/src/functional/$HeadersReader.ts +28 -28
  11. package/src/functional/$ParameterReader.ts +31 -31
  12. package/src/functional/$QueryReader.ts +56 -56
  13. package/src/functional/Namespace.ts +142 -142
  14. package/src/http.ts +1149 -1149
  15. package/src/json.ts +648 -648
  16. package/src/misc.ts +651 -651
  17. package/src/module.ts +657 -657
  18. package/src/programmers/helpers/HttpMetadataUtil.ts +21 -21
  19. package/src/programmers/http/HttpAssertHeadersProgrammer.ts +77 -77
  20. package/src/programmers/http/HttpAssertQueryProgrammer.ts +77 -77
  21. package/src/programmers/http/HttpHeadersProgrammer.ts +339 -339
  22. package/src/programmers/http/HttpIsHeadersProgrammer.ts +87 -87
  23. package/src/programmers/http/HttpIsQueryProgrammer.ts +87 -87
  24. package/src/programmers/http/HttpParameterProgrammer.ts +104 -104
  25. package/src/programmers/http/HttpQueryProgrammer.ts +273 -273
  26. package/src/programmers/http/HttpValidateHeadersProgrammer.ts +77 -77
  27. package/src/programmers/http/HttpValidateQueryProgrammer.ts +77 -77
  28. package/src/programmers/internal/application_boolean.ts +30 -30
  29. package/src/programmers/internal/application_number.ts +90 -90
  30. package/src/programmers/internal/application_schema.ts +180 -180
  31. package/src/programmers/internal/application_string.ts +54 -54
  32. package/src/programmers/internal/check_array_length.ts +44 -44
  33. package/src/programmers/internal/check_bigint.ts +48 -48
  34. package/src/programmers/internal/check_number.ts +108 -108
  35. package/src/programmers/internal/check_string.ts +48 -48
  36. package/src/programmers/protobuf/ProtobufEncodeProgrammer.ts +882 -882
  37. package/src/protobuf.ts +887 -887
  38. package/src/schemas/json/IJsonComponents.ts +34 -34
  39. package/src/schemas/json/IJsonSchema.ts +112 -112
  40. package/src/schemas/metadata/IMetadataConstant.ts +25 -25
  41. package/src/schemas/metadata/IMetadataTypeTag.ts +8 -8
  42. package/src/schemas/metadata/Metadata.ts +686 -686
  43. package/src/tags/Default.ts +15 -15
  44. package/src/tags/Format.ts +30 -30
  45. package/src/tags/Pattern.ts +9 -9
  46. package/src/tags/TagBase.ts +68 -68
  47. package/src/tags/index.ts +14 -14
  48. package/src/transformers/CallExpressionTransformer.ts +289 -289
  49. package/src/transformers/features/http/CreateHttpAssertHeadersTransformer.ts +12 -12
  50. package/src/transformers/features/http/CreateHttpAssertQueryTransformer.ts +12 -12
  51. package/src/transformers/features/http/CreateHttpHeadersTransformer.ts +9 -9
  52. package/src/transformers/features/http/CreateHttpIsHeadersTransformer.ts +9 -9
  53. package/src/transformers/features/http/CreateHttpIsQueryTransformer.ts +9 -9
  54. package/src/transformers/features/http/CreateHttpParameterTransformer.ts +9 -9
  55. package/src/transformers/features/http/CreateHttpQueryTransformer.ts +9 -9
  56. package/src/transformers/features/http/CreateHttpValidateHeadersTransformer.ts +12 -12
  57. package/src/transformers/features/http/CreateHttpValidateQueryTransformer.ts +12 -12
  58. package/src/transformers/features/http/HttpAssertHeadersTransformer.ts +10 -10
  59. package/src/transformers/features/http/HttpAssertQueryTransformer.ts +10 -10
  60. package/src/transformers/features/http/HttpHeadersTransformer.ts +9 -9
  61. package/src/transformers/features/http/HttpIsHeadersTransformer.ts +9 -9
  62. package/src/transformers/features/http/HttpIsQueryTransformer.ts +9 -9
  63. package/src/transformers/features/http/HttpParameterTransformer.ts +9 -9
  64. package/src/transformers/features/http/HttpQueryTransformer.ts +9 -9
  65. package/src/transformers/features/http/HttpValidateHeadersTransformer.ts +10 -10
  66. package/src/transformers/features/http/HttpValidateQueryTransformer.ts +10 -10
@@ -1,31 +1,31 @@
1
- export namespace $ParameterReader {
2
- export const boolean = (value: string) =>
3
- value !== "null"
4
- ? value === "true" || value === "1"
5
- ? true
6
- : value === "false" || value === "0"
7
- ? false
8
- : value
9
- : null;
10
-
11
- export const bigint = (value: string) =>
12
- value !== "null" ? toBigint(value) : null;
13
-
14
- export const number = (value: string) =>
15
- value !== "null" ? toNumber(value) : null;
16
-
17
- export const string = (value: string) => (value !== "null" ? value : null);
18
- }
19
-
20
- const toNumber = (str: string): number | string => {
21
- const value: number = Number(str);
22
- return isNaN(value) ? str : value;
23
- };
24
-
25
- const toBigint = (str: string): bigint | string => {
26
- try {
27
- return BigInt(str);
28
- } catch {
29
- return str;
30
- }
31
- };
1
+ export namespace $ParameterReader {
2
+ export const boolean = (value: string) =>
3
+ value !== "null"
4
+ ? value === "true" || value === "1"
5
+ ? true
6
+ : value === "false" || value === "0"
7
+ ? false
8
+ : value
9
+ : null;
10
+
11
+ export const bigint = (value: string) =>
12
+ value !== "null" ? toBigint(value) : null;
13
+
14
+ export const number = (value: string) =>
15
+ value !== "null" ? toNumber(value) : null;
16
+
17
+ export const string = (value: string) => (value !== "null" ? value : null);
18
+ }
19
+
20
+ const toNumber = (str: string): number | string => {
21
+ const value: number = Number(str);
22
+ return isNaN(value) ? str : value;
23
+ };
24
+
25
+ const toBigint = (str: string): bigint | string => {
26
+ try {
27
+ return BigInt(str);
28
+ } catch {
29
+ return str;
30
+ }
31
+ };
@@ -1,56 +1,56 @@
1
- export namespace $QueryReader {
2
- export const boolean = (str: string | null): boolean | null | undefined =>
3
- str === null
4
- ? undefined
5
- : str === "null"
6
- ? null
7
- : str.length === 0
8
- ? true
9
- : str === "true" || str === "1"
10
- ? true
11
- : str === "false" || str === "0"
12
- ? false
13
- : (str as any); // wrong type
14
-
15
- export const number = (str: string | null): number | null | undefined =>
16
- !!str?.length
17
- ? str === "null"
18
- ? null
19
- : (toNumber(str) as any)
20
- : undefined;
21
-
22
- export const bigint = (str: string | null): bigint | null | undefined =>
23
- !!str?.length
24
- ? str === "null"
25
- ? null
26
- : (toBigint(str) as any)
27
- : undefined;
28
-
29
- export const string = (str: string | null): string | null | undefined =>
30
- str === null ? undefined : str === "null" ? null : str;
31
-
32
- export const params = (input: string | URLSearchParams) => {
33
- if (typeof input === "string") {
34
- const index: number = input.indexOf("?");
35
- input = index === -1 ? "" : input.substring(index + 1);
36
- return new URLSearchParams(input);
37
- }
38
- return input;
39
- };
40
-
41
- export const array = (input: any[], alternative: null | undefined) =>
42
- input.length ? input : alternative;
43
- }
44
-
45
- const toNumber = (str: string): number | string => {
46
- const value: number = Number(str);
47
- return isNaN(value) ? str : value;
48
- };
49
-
50
- const toBigint = (str: string): bigint | string => {
51
- try {
52
- return BigInt(str);
53
- } catch {
54
- return str;
55
- }
56
- };
1
+ export namespace $QueryReader {
2
+ export const boolean = (str: string | null): boolean | null | undefined =>
3
+ str === null
4
+ ? undefined
5
+ : str === "null"
6
+ ? null
7
+ : str.length === 0
8
+ ? true
9
+ : str === "true" || str === "1"
10
+ ? true
11
+ : str === "false" || str === "0"
12
+ ? false
13
+ : (str as any); // wrong type
14
+
15
+ export const number = (str: string | null): number | null | undefined =>
16
+ !!str?.length
17
+ ? str === "null"
18
+ ? null
19
+ : (toNumber(str) as any)
20
+ : undefined;
21
+
22
+ export const bigint = (str: string | null): bigint | null | undefined =>
23
+ !!str?.length
24
+ ? str === "null"
25
+ ? null
26
+ : (toBigint(str) as any)
27
+ : undefined;
28
+
29
+ export const string = (str: string | null): string | null | undefined =>
30
+ str === null ? undefined : str === "null" ? null : str;
31
+
32
+ export const params = (input: string | URLSearchParams) => {
33
+ if (typeof input === "string") {
34
+ const index: number = input.indexOf("?");
35
+ input = index === -1 ? "" : input.substring(index + 1);
36
+ return new URLSearchParams(input);
37
+ }
38
+ return input;
39
+ };
40
+
41
+ export const array = (input: any[], alternative: null | undefined) =>
42
+ input.length ? input : alternative;
43
+ }
44
+
45
+ const toNumber = (str: string): number | string => {
46
+ const value: number = Number(str);
47
+ return isNaN(value) ? str : value;
48
+ };
49
+
50
+ const toBigint = (str: string): bigint | string => {
51
+ try {
52
+ return BigInt(str);
53
+ } catch {
54
+ return str;
55
+ }
56
+ };
@@ -1,142 +1,142 @@
1
- import { RandomGenerator } from "../utils/RandomGenerator";
2
-
3
- import { IValidation } from "../IValidation";
4
- import { TypeGuardError } from "../TypeGuardError";
5
- import { $HeadersReader } from "./$HeadersReader";
6
- import { $ParameterReader } from "./$ParameterReader";
7
- import { $ProtobufReader } from "./$ProtobufReader";
8
- import { $ProtobufSizer } from "./$ProtobufSizer";
9
- import { $ProtobufWriter } from "./$ProtobufWriter";
10
- import { $QueryReader } from "./$QueryReader";
11
- import { $any } from "./$any";
12
- import { $every } from "./$every";
13
- import { $guard } from "./$guard";
14
- import { $is_between } from "./$is_between";
15
- import { $join } from "./$join";
16
- import { $number } from "./$number";
17
- import { $report } from "./$report";
18
- import { $rest } from "./$rest";
19
- import { $string } from "./$string";
20
- import { $strlen } from "./$strlen";
21
- import { $tail } from "./$tail";
22
-
23
- /**
24
- * @internal
25
- */
26
- export namespace Namespace {
27
- export const is = () => ({
28
- is_between: $is_between,
29
- });
30
-
31
- export const assert = (method: string) => ({
32
- ...is(),
33
- join: $join,
34
- every: $every,
35
- guard: $guard(`typia.${method}`),
36
- predicate: (
37
- matched: boolean,
38
- exceptionable: boolean,
39
- closure: () => Omit<TypeGuardError.IProps, "method">,
40
- ): boolean => {
41
- if (matched === false && exceptionable === true)
42
- throw new TypeGuardError({
43
- ...closure(),
44
- method: `typia.${method}`,
45
- });
46
- return matched;
47
- },
48
- });
49
-
50
- export const validate = () => ({
51
- ...is(),
52
- join: $join,
53
- report: $report,
54
- predicate:
55
- (res: IValidation) =>
56
- (
57
- matched: boolean,
58
- exceptionable: boolean,
59
- closure: () => IValidation.IError,
60
- ) => {
61
- // CHECK FAILURE
62
- if (matched === false && exceptionable === true)
63
- (() => {
64
- res.success &&= false;
65
- const errorList = (res as IValidation.IFailure).errors;
66
-
67
- // TRACE ERROR
68
- const error = closure();
69
- if (errorList.length) {
70
- const last = errorList[errorList.length - 1]!.path;
71
- if (
72
- last.length >= error.path.length &&
73
- last.substring(0, error.path.length) ===
74
- error.path
75
- )
76
- return;
77
- }
78
- errorList.push(error);
79
- return;
80
- })();
81
- return matched;
82
- },
83
- });
84
-
85
- export namespace json {
86
- export const stringify = (method: string) => ({
87
- ...is(),
88
- number: $number,
89
- string: $string,
90
- tail: $tail,
91
- rest: $rest,
92
- throws: $throws(`json.${method}`),
93
- });
94
- }
95
-
96
- export namespace protobuf {
97
- export const decode = (method: string) => ({
98
- Reader: $ProtobufReader,
99
- throws: $throws(`protobuf.${method}`),
100
- });
101
-
102
- export const encode = (method: string) => ({
103
- Sizer: $ProtobufSizer,
104
- Writer: $ProtobufWriter,
105
- strlen: $strlen,
106
- throws: $throws(method),
107
- });
108
- }
109
-
110
- export namespace http {
111
- export const query = () => $QueryReader;
112
- export const headers = () => $HeadersReader;
113
- export const parameter = () => $ParameterReader;
114
- }
115
-
116
- export namespace misc {
117
- export const clone = (method: string) => ({
118
- ...is(),
119
- throws: $throws(`misc.${method}`),
120
- any: $any,
121
- });
122
-
123
- export const prune = (method: string) => ({
124
- ...is(),
125
- throws: $throws(`misc.${method}`),
126
- });
127
- }
128
-
129
- export const random = () => ({
130
- generator: RandomGenerator,
131
- pick: RandomGenerator.pick,
132
- });
133
-
134
- const $throws =
135
- (method: string) =>
136
- (props: Pick<TypeGuardError.IProps, "expected" | "value">) => {
137
- throw new TypeGuardError({
138
- ...props,
139
- method: `typia.${method}`,
140
- });
141
- };
142
- }
1
+ import { RandomGenerator } from "../utils/RandomGenerator";
2
+
3
+ import { IValidation } from "../IValidation";
4
+ import { TypeGuardError } from "../TypeGuardError";
5
+ import { $HeadersReader } from "./$HeadersReader";
6
+ import { $ParameterReader } from "./$ParameterReader";
7
+ import { $ProtobufReader } from "./$ProtobufReader";
8
+ import { $ProtobufSizer } from "./$ProtobufSizer";
9
+ import { $ProtobufWriter } from "./$ProtobufWriter";
10
+ import { $QueryReader } from "./$QueryReader";
11
+ import { $any } from "./$any";
12
+ import { $every } from "./$every";
13
+ import { $guard } from "./$guard";
14
+ import { $is_between } from "./$is_between";
15
+ import { $join } from "./$join";
16
+ import { $number } from "./$number";
17
+ import { $report } from "./$report";
18
+ import { $rest } from "./$rest";
19
+ import { $string } from "./$string";
20
+ import { $strlen } from "./$strlen";
21
+ import { $tail } from "./$tail";
22
+
23
+ /**
24
+ * @internal
25
+ */
26
+ export namespace Namespace {
27
+ export const is = () => ({
28
+ is_between: $is_between,
29
+ });
30
+
31
+ export const assert = (method: string) => ({
32
+ ...is(),
33
+ join: $join,
34
+ every: $every,
35
+ guard: $guard(`typia.${method}`),
36
+ predicate: (
37
+ matched: boolean,
38
+ exceptionable: boolean,
39
+ closure: () => Omit<TypeGuardError.IProps, "method">,
40
+ ): boolean => {
41
+ if (matched === false && exceptionable === true)
42
+ throw new TypeGuardError({
43
+ ...closure(),
44
+ method: `typia.${method}`,
45
+ });
46
+ return matched;
47
+ },
48
+ });
49
+
50
+ export const validate = () => ({
51
+ ...is(),
52
+ join: $join,
53
+ report: $report,
54
+ predicate:
55
+ (res: IValidation) =>
56
+ (
57
+ matched: boolean,
58
+ exceptionable: boolean,
59
+ closure: () => IValidation.IError,
60
+ ) => {
61
+ // CHECK FAILURE
62
+ if (matched === false && exceptionable === true)
63
+ (() => {
64
+ res.success &&= false;
65
+ const errorList = (res as IValidation.IFailure).errors;
66
+
67
+ // TRACE ERROR
68
+ const error = closure();
69
+ if (errorList.length) {
70
+ const last = errorList[errorList.length - 1]!.path;
71
+ if (
72
+ last.length >= error.path.length &&
73
+ last.substring(0, error.path.length) ===
74
+ error.path
75
+ )
76
+ return;
77
+ }
78
+ errorList.push(error);
79
+ return;
80
+ })();
81
+ return matched;
82
+ },
83
+ });
84
+
85
+ export namespace json {
86
+ export const stringify = (method: string) => ({
87
+ ...is(),
88
+ number: $number,
89
+ string: $string,
90
+ tail: $tail,
91
+ rest: $rest,
92
+ throws: $throws(`json.${method}`),
93
+ });
94
+ }
95
+
96
+ export namespace protobuf {
97
+ export const decode = (method: string) => ({
98
+ Reader: $ProtobufReader,
99
+ throws: $throws(`protobuf.${method}`),
100
+ });
101
+
102
+ export const encode = (method: string) => ({
103
+ Sizer: $ProtobufSizer,
104
+ Writer: $ProtobufWriter,
105
+ strlen: $strlen,
106
+ throws: $throws(method),
107
+ });
108
+ }
109
+
110
+ export namespace http {
111
+ export const query = () => $QueryReader;
112
+ export const headers = () => $HeadersReader;
113
+ export const parameter = () => $ParameterReader;
114
+ }
115
+
116
+ export namespace misc {
117
+ export const clone = (method: string) => ({
118
+ ...is(),
119
+ throws: $throws(`misc.${method}`),
120
+ any: $any,
121
+ });
122
+
123
+ export const prune = (method: string) => ({
124
+ ...is(),
125
+ throws: $throws(`misc.${method}`),
126
+ });
127
+ }
128
+
129
+ export const random = () => ({
130
+ generator: RandomGenerator,
131
+ pick: RandomGenerator.pick,
132
+ });
133
+
134
+ const $throws =
135
+ (method: string) =>
136
+ (props: Pick<TypeGuardError.IProps, "expected" | "value">) => {
137
+ throw new TypeGuardError({
138
+ ...props,
139
+ method: `typia.${method}`,
140
+ });
141
+ };
142
+ }