typia 7.0.0-dev.20241009-2 → 7.0.0-dev.20241010

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 (151) hide show
  1. package/lib/factories/JsonMetadataFactory.d.ts +5 -1
  2. package/lib/factories/JsonMetadataFactory.js +4 -1
  3. package/lib/factories/JsonMetadataFactory.js.map +1 -1
  4. package/lib/internal/{$httpFormDataReadArray.js → $httpFormdataReadArray.js} +1 -1
  5. package/lib/internal/$httpFormdataReadArray.js.map +1 -0
  6. package/lib/programmers/CheckerProgrammer.js +4 -1
  7. package/lib/programmers/CheckerProgrammer.js.map +1 -1
  8. package/lib/programmers/FeatureProgrammer.d.ts +4 -1
  9. package/lib/programmers/FeatureProgrammer.js +2 -2
  10. package/lib/programmers/FeatureProgrammer.js.map +1 -1
  11. package/lib/programmers/RandomProgrammer.js +12 -9
  12. package/lib/programmers/RandomProgrammer.js.map +1 -1
  13. package/lib/programmers/TypiaProgrammer.js +4 -1
  14. package/lib/programmers/TypiaProgrammer.js.map +1 -1
  15. package/lib/programmers/internal/prune_object_properties.js +3 -2
  16. package/lib/programmers/internal/prune_object_properties.js.map +1 -1
  17. package/lib/programmers/json/JsonAssertParseProgrammer.js +2 -2
  18. package/lib/programmers/json/JsonAssertParseProgrammer.js.map +1 -1
  19. package/lib/programmers/misc/MiscCloneProgrammer.js +4 -1
  20. package/lib/programmers/misc/MiscCloneProgrammer.js.map +1 -1
  21. package/lib/programmers/misc/MiscPruneProgrammer.js +4 -1
  22. package/lib/programmers/misc/MiscPruneProgrammer.js.map +1 -1
  23. package/lib/programmers/notations/NotationGeneralProgrammer.js +4 -1
  24. package/lib/programmers/notations/NotationGeneralProgrammer.js.map +1 -1
  25. package/lib/programmers/protobuf/ProtobufDecodeProgrammer.js +1 -1
  26. package/lib/programmers/protobuf/ProtobufDecodeProgrammer.js.map +1 -1
  27. package/lib/transformers/FileTransformer.js +0 -6
  28. package/lib/transformers/FileTransformer.js.map +1 -1
  29. package/lib/transformers/ImportTransformer.d.ts +4 -1
  30. package/lib/transformers/ImportTransformer.js +34 -30
  31. package/lib/transformers/ImportTransformer.js.map +1 -1
  32. package/package.json +1 -1
  33. package/src/IRandomGenerator.ts +49 -49
  34. package/src/factories/ExpressionFactory.ts +164 -164
  35. package/src/factories/JsonMetadataFactory.ts +25 -15
  36. package/src/factories/LiteralFactory.ts +50 -50
  37. package/src/factories/MetadataCommentTagFactory.ts +650 -650
  38. package/src/functional.ts +750 -750
  39. package/src/http.ts +1042 -1042
  40. package/src/internal/$IProtobufWriter.ts +18 -18
  41. package/src/internal/$ProtobufReader.ts +194 -194
  42. package/src/internal/$ProtobufSizer.ts +151 -151
  43. package/src/internal/$ProtobufWriter.ts +145 -145
  44. package/src/internal/$accessExpressionAsString.ts +46 -46
  45. package/src/internal/$assertGuard.ts +13 -13
  46. package/src/internal/$functionalTypeGuardErrorFactory.ts +4 -4
  47. package/src/internal/$httpFormDataReadBigint.ts +18 -18
  48. package/src/internal/$httpFormDataReadBlob.ts +10 -10
  49. package/src/internal/$httpFormDataReadBoolean.ts +16 -16
  50. package/src/internal/$httpFormDataReadFile.ts +10 -10
  51. package/src/internal/$httpFormDataReadNumber.ts +15 -15
  52. package/src/internal/$httpFormDataReadString.ts +10 -10
  53. package/src/internal/{$httpFormDataReadArray.ts → $httpFormdataReadArray.ts} +4 -4
  54. package/src/internal/$httpHeaderReadBigint.ts +10 -10
  55. package/src/internal/$httpHeaderReadBoolean.ts +8 -8
  56. package/src/internal/$httpHeaderReadNumber.ts +7 -7
  57. package/src/internal/$httpParameterBigint.ts +10 -10
  58. package/src/internal/$httpParameterBoolean.ts +8 -8
  59. package/src/internal/$httpParameterNumber.ts +7 -7
  60. package/src/internal/$httpParameterString.ts +2 -2
  61. package/src/internal/$httpQueryParseURLSearchParams.ts +10 -10
  62. package/src/internal/$httpQueryReadArray.ts +4 -4
  63. package/src/internal/$httpQueryReadBigint.ts +12 -12
  64. package/src/internal/$httpQueryReadBoolean.ts +14 -14
  65. package/src/internal/$httpQueryReadNumber.ts +9 -9
  66. package/src/internal/$httpQueryReadString.ts +4 -4
  67. package/src/internal/$isBetween.ts +2 -2
  68. package/src/internal/$isBigintString.ts +8 -8
  69. package/src/internal/$jsonStringifyNumber.ts +12 -12
  70. package/src/internal/$jsonStringifyRest.ts +3 -3
  71. package/src/internal/$jsonStringifyString.ts +42 -42
  72. package/src/internal/$jsonStringifyTail.ts +2 -2
  73. package/src/internal/$llmApplicationFinalize.ts +18 -18
  74. package/src/internal/$miscCloneAny.ts +48 -48
  75. package/src/internal/$notationAny.ts +37 -37
  76. package/src/internal/$notationCamel.ts +13 -13
  77. package/src/internal/$notationPascal.ts +8 -8
  78. package/src/internal/$notationSnake.ts +43 -43
  79. package/src/internal/$randomArray.ts +21 -21
  80. package/src/internal/$randomBigint.ts +6 -6
  81. package/src/internal/$randomBoolean.ts +1 -1
  82. package/src/internal/$randomFormatByte.ts +3 -3
  83. package/src/internal/$randomFormatDate.ts +18 -18
  84. package/src/internal/$randomFormatDatetime.ts +16 -16
  85. package/src/internal/$randomFormatDuration.ts +27 -27
  86. package/src/internal/$randomFormatEmail.ts +11 -11
  87. package/src/internal/$randomFormatHostname.ts +6 -6
  88. package/src/internal/$randomFormatIdnEmail.ts +3 -3
  89. package/src/internal/$randomFormatIdnHostname.ts +3 -3
  90. package/src/internal/$randomFormatIpv4.ts +11 -11
  91. package/src/internal/$randomFormatIpv6.ts +11 -11
  92. package/src/internal/$randomFormatIri.ts +3 -3
  93. package/src/internal/$randomFormatIriReference.ts +3 -3
  94. package/src/internal/$randomFormatJsonPointer.ts +7 -7
  95. package/src/internal/$randomFormatPassword.ts +8 -8
  96. package/src/internal/$randomFormatRegex.ts +4 -4
  97. package/src/internal/$randomFormatRelativeJsonPointer.ts +8 -8
  98. package/src/internal/$randomFormatTime.ts +14 -14
  99. package/src/internal/$randomFormatUri.ts +3 -3
  100. package/src/internal/$randomFormatUriReference.ts +3 -3
  101. package/src/internal/$randomFormatUriTemplate.ts +3 -3
  102. package/src/internal/$randomFormatUrl.ts +11 -11
  103. package/src/internal/$randomFormatUuid.ts +6 -6
  104. package/src/internal/$randomInteger.ts +47 -47
  105. package/src/internal/$randomNumber.ts +74 -74
  106. package/src/internal/$randomPattern.ts +10 -10
  107. package/src/internal/$randomPick.ts +9 -9
  108. package/src/internal/$randomString.ts +24 -24
  109. package/src/internal/$throwTypeGuardError.ts +5 -5
  110. package/src/internal/$validateReport.ts +13 -13
  111. package/src/internal/private/$__notationCapitalize.ts +2 -2
  112. package/src/internal/private/$__notationUnsnake.ts +24 -24
  113. package/src/json.ts +651 -651
  114. package/src/llm.ts +178 -178
  115. package/src/misc.ts +658 -658
  116. package/src/module.ts +933 -933
  117. package/src/notations.ts +827 -827
  118. package/src/programmers/CheckerProgrammer.ts +4 -1
  119. package/src/programmers/FeatureProgrammer.ts +619 -616
  120. package/src/programmers/RandomProgrammer.ts +24 -16
  121. package/src/programmers/TypiaProgrammer.ts +4 -1
  122. package/src/programmers/functional/FunctionalAssertFunctionProgrammer.ts +153 -153
  123. package/src/programmers/functional/FunctionalAssertParametersProgrammer.ts +125 -125
  124. package/src/programmers/functional/FunctionalAssertReturnProgrammer.ts +115 -115
  125. package/src/programmers/functional/FunctionalValidateFunctionProgrammer.ts +119 -119
  126. package/src/programmers/functional/FunctionalValidateParametersProgrammer.ts +274 -274
  127. package/src/programmers/functional/FunctionalValidateReturnProgrammer.ts +135 -135
  128. package/src/programmers/helpers/FunctionProgrammer.ts +67 -67
  129. package/src/programmers/helpers/RandomJoiner.ts +168 -168
  130. package/src/programmers/helpers/StringifyJoinder.ts +115 -115
  131. package/src/programmers/helpers/disable_function_programmer_declare.ts +32 -32
  132. package/src/programmers/internal/check_dynamic_key.ts +201 -201
  133. package/src/programmers/internal/check_dynamic_properties.ts +208 -208
  134. package/src/programmers/internal/check_object.ts +75 -75
  135. package/src/programmers/internal/feature_object_entries.ts +61 -61
  136. package/src/programmers/internal/prune_object_properties.ts +71 -63
  137. package/src/programmers/json/JsonAssertParseProgrammer.ts +14 -11
  138. package/src/programmers/llm/LlmApplicationProgrammer.ts +235 -235
  139. package/src/programmers/llm/LlmSchemaProgrammer.ts +51 -51
  140. package/src/programmers/misc/MiscCloneProgrammer.ts +4 -1
  141. package/src/programmers/misc/MiscPruneProgrammer.ts +4 -1
  142. package/src/programmers/notations/NotationGeneralProgrammer.ts +4 -1
  143. package/src/programmers/protobuf/ProtobufDecodeProgrammer.ts +1 -1
  144. package/src/protobuf.ts +868 -868
  145. package/src/reflect.ts +57 -57
  146. package/src/transformers/FileTransformer.ts +0 -6
  147. package/src/transformers/ImportTransformer.ts +59 -44
  148. package/src/utils/NamingConvention.ts +94 -94
  149. package/src/utils/StringUtil.ts +16 -16
  150. package/lib/internal/$httpFormDataReadArray.js.map +0 -1
  151. /package/lib/internal/{$httpFormDataReadArray.d.ts → $httpFormdataReadArray.d.ts} +0 -0
@@ -1,48 +1,48 @@
1
- import { Resolved } from "../Resolved";
2
-
3
- export const $miscCloneAny = <T>(value: T): Resolved<T> =>
4
- $cloneMain(value) as Resolved<T>;
5
-
6
- const $cloneMain = (value: any): any => {
7
- if (value === undefined) return undefined;
8
- else if (typeof value === "object")
9
- if (value === null) return null;
10
- else if (Array.isArray(value)) return value.map($cloneMain);
11
- else if (value instanceof Date) return new Date(value);
12
- else if (value instanceof Uint8Array) return new Uint8Array(value);
13
- else if (value instanceof Uint8ClampedArray)
14
- return new Uint8ClampedArray(value);
15
- else if (value instanceof Uint16Array) return new Uint16Array(value);
16
- else if (value instanceof Uint32Array) return new Uint32Array(value);
17
- else if (value instanceof BigUint64Array) return new BigUint64Array(value);
18
- else if (value instanceof Int8Array) return new Int8Array(value);
19
- else if (value instanceof Int16Array) return new Int16Array(value);
20
- else if (value instanceof Int32Array) return new Int32Array(value);
21
- else if (value instanceof BigInt64Array) return new BigInt64Array(value);
22
- else if (value instanceof Float32Array) return new Float32Array(value);
23
- else if (value instanceof Float64Array) return new Float64Array(value);
24
- else if (value instanceof ArrayBuffer) return value.slice(0);
25
- else if (value instanceof SharedArrayBuffer) return value.slice(0);
26
- else if (value instanceof DataView)
27
- return new DataView(value.buffer.slice(0));
28
- else if (typeof File !== "undefined" && value instanceof File)
29
- return new File([value], value.name, { type: value.type });
30
- else if (typeof Blob !== "undefined" && value instanceof Blob)
31
- return new Blob([value], { type: value.type });
32
- else if (value instanceof Set) return new Set([...value].map($cloneMain));
33
- else if (value instanceof Map)
34
- return new Map(
35
- [...value].map(([k, v]) => [$cloneMain(k), $cloneMain(v)]),
36
- );
37
- else if (value instanceof WeakSet || value instanceof WeakMap)
38
- throw new Error("WeakSet and WeakMap are not supported");
39
- else if (value.valueOf() !== value) return $cloneMain(value.valueOf());
40
- else
41
- return Object.fromEntries(
42
- Object.entries(value)
43
- .map(([k, v]) => [k, $cloneMain(v)])
44
- .filter(([, v]) => v !== undefined),
45
- );
46
- else if (typeof value === "function") return undefined;
47
- return value;
48
- };
1
+ import { Resolved } from "../Resolved";
2
+
3
+ export const $miscCloneAny = <T>(value: T): Resolved<T> =>
4
+ $cloneMain(value) as Resolved<T>;
5
+
6
+ const $cloneMain = (value: any): any => {
7
+ if (value === undefined) return undefined;
8
+ else if (typeof value === "object")
9
+ if (value === null) return null;
10
+ else if (Array.isArray(value)) return value.map($cloneMain);
11
+ else if (value instanceof Date) return new Date(value);
12
+ else if (value instanceof Uint8Array) return new Uint8Array(value);
13
+ else if (value instanceof Uint8ClampedArray)
14
+ return new Uint8ClampedArray(value);
15
+ else if (value instanceof Uint16Array) return new Uint16Array(value);
16
+ else if (value instanceof Uint32Array) return new Uint32Array(value);
17
+ else if (value instanceof BigUint64Array) return new BigUint64Array(value);
18
+ else if (value instanceof Int8Array) return new Int8Array(value);
19
+ else if (value instanceof Int16Array) return new Int16Array(value);
20
+ else if (value instanceof Int32Array) return new Int32Array(value);
21
+ else if (value instanceof BigInt64Array) return new BigInt64Array(value);
22
+ else if (value instanceof Float32Array) return new Float32Array(value);
23
+ else if (value instanceof Float64Array) return new Float64Array(value);
24
+ else if (value instanceof ArrayBuffer) return value.slice(0);
25
+ else if (value instanceof SharedArrayBuffer) return value.slice(0);
26
+ else if (value instanceof DataView)
27
+ return new DataView(value.buffer.slice(0));
28
+ else if (typeof File !== "undefined" && value instanceof File)
29
+ return new File([value], value.name, { type: value.type });
30
+ else if (typeof Blob !== "undefined" && value instanceof Blob)
31
+ return new Blob([value], { type: value.type });
32
+ else if (value instanceof Set) return new Set([...value].map($cloneMain));
33
+ else if (value instanceof Map)
34
+ return new Map(
35
+ [...value].map(([k, v]) => [$cloneMain(k), $cloneMain(v)]),
36
+ );
37
+ else if (value instanceof WeakSet || value instanceof WeakMap)
38
+ throw new Error("WeakSet and WeakMap are not supported");
39
+ else if (value.valueOf() !== value) return $cloneMain(value.valueOf());
40
+ else
41
+ return Object.fromEntries(
42
+ Object.entries(value)
43
+ .map(([k, v]) => [k, $cloneMain(v)])
44
+ .filter(([, v]) => v !== undefined),
45
+ );
46
+ else if (typeof value === "function") return undefined;
47
+ return value;
48
+ };
@@ -1,37 +1,37 @@
1
- export const $notationAny = (rename: (str: string) => string) => {
2
- const main = (input: any): any => {
3
- if (typeof input === "object")
4
- if (input === null) return null;
5
- else if (Array.isArray(input)) return input.map(main);
6
- else if (
7
- input instanceof Boolean ||
8
- input instanceof BigInt ||
9
- input instanceof Number ||
10
- input instanceof String
11
- )
12
- return input.valueOf();
13
- else if (input instanceof Date) return new Date(input);
14
- else if (
15
- input instanceof Uint8Array ||
16
- input instanceof Uint8ClampedArray ||
17
- input instanceof Uint16Array ||
18
- input instanceof Uint32Array ||
19
- input instanceof BigUint64Array ||
20
- input instanceof Int8Array ||
21
- input instanceof Int16Array ||
22
- input instanceof Int32Array ||
23
- input instanceof BigInt64Array ||
24
- input instanceof Float32Array ||
25
- input instanceof Float64Array ||
26
- input instanceof DataView
27
- )
28
- return input;
29
- else return object(input);
30
- return input;
31
- };
32
- const object = (input: Record<string, any>) =>
33
- Object.fromEntries(
34
- Object.entries(input).map(([key, value]) => [rename(key), main(value)]),
35
- );
36
- return main;
37
- };
1
+ export const $notationAny = (rename: (str: string) => string) => {
2
+ const main = (input: any): any => {
3
+ if (typeof input === "object")
4
+ if (input === null) return null;
5
+ else if (Array.isArray(input)) return input.map(main);
6
+ else if (
7
+ input instanceof Boolean ||
8
+ input instanceof BigInt ||
9
+ input instanceof Number ||
10
+ input instanceof String
11
+ )
12
+ return input.valueOf();
13
+ else if (input instanceof Date) return new Date(input);
14
+ else if (
15
+ input instanceof Uint8Array ||
16
+ input instanceof Uint8ClampedArray ||
17
+ input instanceof Uint16Array ||
18
+ input instanceof Uint32Array ||
19
+ input instanceof BigUint64Array ||
20
+ input instanceof Int8Array ||
21
+ input instanceof Int16Array ||
22
+ input instanceof Int32Array ||
23
+ input instanceof BigInt64Array ||
24
+ input instanceof Float32Array ||
25
+ input instanceof Float64Array ||
26
+ input instanceof DataView
27
+ )
28
+ return input;
29
+ else return object(input);
30
+ return input;
31
+ };
32
+ const object = (input: Record<string, any>) =>
33
+ Object.fromEntries(
34
+ Object.entries(input).map(([key, value]) => [rename(key), main(value)]),
35
+ );
36
+ return main;
37
+ };
@@ -1,13 +1,13 @@
1
- import { $__notationCapitalize } from "./private/$__notationCapitalize";
2
- import { $__notationUnsnake } from "./private/$__notationUnsnake";
3
-
4
- export const $notationCamel = $__notationUnsnake({
5
- plain: (str) =>
6
- str.length
7
- ? str === str.toUpperCase()
8
- ? str.toLocaleLowerCase()
9
- : `${str[0]!.toLowerCase()}${str.substring(1)}`
10
- : str,
11
- snake: (str, i) =>
12
- i === 0 ? str.toLowerCase() : $__notationCapitalize(str.toLowerCase()),
13
- });
1
+ import { $__notationCapitalize } from "./private/$__notationCapitalize";
2
+ import { $__notationUnsnake } from "./private/$__notationUnsnake";
3
+
4
+ export const $notationCamel = $__notationUnsnake({
5
+ plain: (str) =>
6
+ str.length
7
+ ? str === str.toUpperCase()
8
+ ? str.toLocaleLowerCase()
9
+ : `${str[0]!.toLowerCase()}${str.substring(1)}`
10
+ : str,
11
+ snake: (str, i) =>
12
+ i === 0 ? str.toLowerCase() : $__notationCapitalize(str.toLowerCase()),
13
+ });
@@ -1,8 +1,8 @@
1
- import { $__notationCapitalize } from "./private/$__notationCapitalize";
2
- import { $__notationUnsnake } from "./private/$__notationUnsnake";
3
-
4
- export const $notationPascal = $__notationUnsnake({
5
- plain: (str) =>
6
- str.length ? `${str[0]!.toUpperCase()}${str.substring(1)}` : str,
7
- snake: $__notationCapitalize,
8
- });
1
+ import { $__notationCapitalize } from "./private/$__notationCapitalize";
2
+ import { $__notationUnsnake } from "./private/$__notationUnsnake";
3
+
4
+ export const $notationPascal = $__notationUnsnake({
5
+ plain: (str) =>
6
+ str.length ? `${str[0]!.toUpperCase()}${str.substring(1)}` : str,
7
+ snake: $__notationCapitalize,
8
+ });
@@ -1,43 +1,43 @@
1
- export const $notationSnake = (str: string): string => {
2
- if (str.length === 0) return str;
3
-
4
- // PREFIX
5
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
6
- let prefix: string = "";
7
- for (let i: number = 0; i < str.length; i++) {
8
- if (str[i] === "_") prefix += "_";
9
- else break;
10
- }
11
- if (prefix.length !== 0) str = str.substring(prefix.length);
12
-
13
- const out = (s: string) => `${prefix}${s}`;
14
-
15
- // SNAKE CASE
16
- const items: string[] = str.split("_");
17
- if (items.length > 1) return out(items.map((s) => s.toLowerCase()).join("_"));
18
-
19
- // CAMEL OR PASCAL CASE
20
- const indexes: number[] = [];
21
- for (let i: number = 0; i < str.length; i++) {
22
- const code: number = str.charCodeAt(i);
23
- if (65 <= code && code <= 90) indexes.push(i);
24
- }
25
- for (let i: number = indexes.length - 1; i > 0; --i) {
26
- const now: number = indexes[i]!;
27
- const prev: number = indexes[i - 1]!;
28
- if (now - prev === 1) indexes.splice(i, 1);
29
- }
30
- if (indexes.length !== 0 && indexes[0] === 0) indexes.splice(0, 1);
31
- if (indexes.length === 0) return str.toLowerCase();
32
-
33
- let ret: string = "";
34
- for (let i: number = 0; i < indexes.length; i++) {
35
- const first: number = i === 0 ? 0 : indexes[i - 1]!;
36
- const last: number = indexes[i]!;
37
-
38
- ret += str.substring(first, last).toLowerCase();
39
- ret += "_";
40
- }
41
- ret += str.substring(indexes[indexes.length - 1]!).toLowerCase();
42
- return out(ret);
43
- };
1
+ export const $notationSnake = (str: string): string => {
2
+ if (str.length === 0) return str;
3
+
4
+ // PREFIX
5
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
6
+ let prefix: string = "";
7
+ for (let i: number = 0; i < str.length; i++) {
8
+ if (str[i] === "_") prefix += "_";
9
+ else break;
10
+ }
11
+ if (prefix.length !== 0) str = str.substring(prefix.length);
12
+
13
+ const out = (s: string) => `${prefix}${s}`;
14
+
15
+ // SNAKE CASE
16
+ const items: string[] = str.split("_");
17
+ if (items.length > 1) return out(items.map((s) => s.toLowerCase()).join("_"));
18
+
19
+ // CAMEL OR PASCAL CASE
20
+ const indexes: number[] = [];
21
+ for (let i: number = 0; i < str.length; i++) {
22
+ const code: number = str.charCodeAt(i);
23
+ if (65 <= code && code <= 90) indexes.push(i);
24
+ }
25
+ for (let i: number = indexes.length - 1; i > 0; --i) {
26
+ const now: number = indexes[i]!;
27
+ const prev: number = indexes[i - 1]!;
28
+ if (now - prev === 1) indexes.splice(i, 1);
29
+ }
30
+ if (indexes.length !== 0 && indexes[0] === 0) indexes.splice(0, 1);
31
+ if (indexes.length === 0) return str.toLowerCase();
32
+
33
+ let ret: string = "";
34
+ for (let i: number = 0; i < indexes.length; i++) {
35
+ const first: number = i === 0 ? 0 : indexes[i - 1]!;
36
+ const last: number = indexes[i]!;
37
+
38
+ ret += str.substring(first, last).toLowerCase();
39
+ ret += "_";
40
+ }
41
+ ret += str.substring(indexes[indexes.length - 1]!).toLowerCase();
42
+ return out(ret);
43
+ };
@@ -1,21 +1,21 @@
1
- import { OpenApi } from "@samchon/openapi";
2
-
3
- import { $randomInteger } from "./$randomInteger";
4
-
5
- export const $randomArray = <T>(
6
- props: Omit<OpenApi.IJsonSchema.IArray, "items"> & {
7
- element: (index: number, count: number) => T;
8
- },
9
- ) => {
10
- const count: number = $randomInteger({
11
- type: "integer",
12
- minimum: props.minItems ?? 0,
13
- maximum: props.maxItems ?? (props.minItems ?? 0) + 5,
14
- });
15
- if (props.uniqueItems !== true)
16
- return new Array(count).fill(null).map((_, i) => props.element(i, count));
17
- const elements: Set<any> = new Set();
18
- while (elements.size !== count)
19
- elements.add(props.element(elements.size, count));
20
- return Array.from(elements);
21
- };
1
+ import { OpenApi } from "@samchon/openapi";
2
+
3
+ import { $randomInteger } from "./$randomInteger";
4
+
5
+ export const $randomArray = <T>(
6
+ props: Omit<OpenApi.IJsonSchema.IArray, "items"> & {
7
+ element: (index: number, count: number) => T;
8
+ },
9
+ ) => {
10
+ const count: number = $randomInteger({
11
+ type: "integer",
12
+ minimum: props.minItems ?? 0,
13
+ maximum: props.maxItems ?? (props.minItems ?? 0) + 5,
14
+ });
15
+ if (props.uniqueItems !== true)
16
+ return new Array(count).fill(null).map((_, i) => props.element(i, count));
17
+ const elements: Set<any> = new Set();
18
+ while (elements.size !== count)
19
+ elements.add(props.element(elements.size, count));
20
+ return Array.from(elements);
21
+ };
@@ -1,6 +1,6 @@
1
- import { OpenApi } from "@samchon/openapi";
2
-
3
- import { $randomInteger } from "./$randomInteger";
4
-
5
- export const $randomBigint = (props: OpenApi.IJsonSchema.IInteger): bigint =>
6
- BigInt($randomInteger(props));
1
+ import { OpenApi } from "@samchon/openapi";
2
+
3
+ import { $randomInteger } from "./$randomInteger";
4
+
5
+ export const $randomBigint = (props: OpenApi.IJsonSchema.IInteger): bigint =>
6
+ BigInt($randomInteger(props));
@@ -1 +1 @@
1
- export const $randomBoolean = (): boolean => Math.random() < 0.5;
1
+ export const $randomBoolean = (): boolean => Math.random() < 0.5;
@@ -1,3 +1,3 @@
1
- export const $randomFormatByte = (): string => FIXED;
2
-
3
- const FIXED = "vt7ekz4lIoNTTS9sDQYdWKharxIFAR54+z/umIxSgUM=";
1
+ export const $randomFormatByte = (): string => FIXED;
2
+
3
+ const FIXED = "vt7ekz4lIoNTTS9sDQYdWKharxIFAR54+z/umIxSgUM=";
@@ -1,18 +1,18 @@
1
- import { $randomInteger } from "./$randomInteger";
2
-
3
- export const $randomFormatDate = (props?: {
4
- minimum?: number;
5
- maximum?: number;
6
- }) =>
7
- new Date(
8
- $randomInteger({
9
- type: "integer",
10
- minimum: props?.minimum ?? 0,
11
- maximum:
12
- (props?.maximum ?? props?.minimum === undefined)
13
- ? Date.now()
14
- : props.minimum + 365 * 24 * 60 * 60 * 1_000,
15
- }),
16
- )
17
- .toISOString()
18
- .substring(0, 10);
1
+ import { $randomInteger } from "./$randomInteger";
2
+
3
+ export const $randomFormatDate = (props?: {
4
+ minimum?: number;
5
+ maximum?: number;
6
+ }) =>
7
+ new Date(
8
+ $randomInteger({
9
+ type: "integer",
10
+ minimum: props?.minimum ?? 0,
11
+ maximum:
12
+ (props?.maximum ?? props?.minimum === undefined)
13
+ ? Date.now()
14
+ : props.minimum + 365 * 24 * 60 * 60 * 1_000,
15
+ }),
16
+ )
17
+ .toISOString()
18
+ .substring(0, 10);
@@ -1,16 +1,16 @@
1
- import { $randomInteger } from "./$randomInteger";
2
-
3
- export const $randomFormatDatetime = (props?: {
4
- minimum?: number;
5
- maximum?: number;
6
- }) =>
7
- new Date(
8
- $randomInteger({
9
- type: "integer",
10
- minimum: props?.minimum ?? 0,
11
- maximum:
12
- (props?.maximum ?? props?.minimum === undefined)
13
- ? Date.now()
14
- : props.minimum + 365 * 24 * 60 * 60 * 1_000,
15
- }),
16
- ).toISOString();
1
+ import { $randomInteger } from "./$randomInteger";
2
+
3
+ export const $randomFormatDatetime = (props?: {
4
+ minimum?: number;
5
+ maximum?: number;
6
+ }) =>
7
+ new Date(
8
+ $randomInteger({
9
+ type: "integer",
10
+ minimum: props?.minimum ?? 0,
11
+ maximum:
12
+ (props?.maximum ?? props?.minimum === undefined)
13
+ ? Date.now()
14
+ : props.minimum + 365 * 24 * 60 * 60 * 1_000,
15
+ }),
16
+ ).toISOString();
@@ -1,27 +1,27 @@
1
- import { $randomInteger } from "./$randomInteger";
2
-
3
- export const $randomFormatDuration = (): string => {
4
- const period: string = durate([
5
- ["Y", random(0, 100)],
6
- ["M", random(0, 12)],
7
- ["D", random(0, 31)],
8
- ]);
9
- const time: string = durate([
10
- ["H", random(0, 24)],
11
- ["M", random(0, 60)],
12
- ["S", random(0, 60)],
13
- ]);
14
- if (period.length + time.length === 0) return "PT0S";
15
- return `P${period}${time.length ? "T" : ""}${time}`;
16
- };
17
- const durate = (elements: [string, number][]) =>
18
- elements
19
- .filter(([_unit, value]) => value !== 0)
20
- .map(([unit, value]) => `${value}${unit}`)
21
- .join("");
22
- const random = (minimum: number, maximum: number) =>
23
- $randomInteger({
24
- type: "integer",
25
- minimum,
26
- maximum,
27
- });
1
+ import { $randomInteger } from "./$randomInteger";
2
+
3
+ export const $randomFormatDuration = (): string => {
4
+ const period: string = durate([
5
+ ["Y", random(0, 100)],
6
+ ["M", random(0, 12)],
7
+ ["D", random(0, 31)],
8
+ ]);
9
+ const time: string = durate([
10
+ ["H", random(0, 24)],
11
+ ["M", random(0, 60)],
12
+ ["S", random(0, 60)],
13
+ ]);
14
+ if (period.length + time.length === 0) return "PT0S";
15
+ return `P${period}${time.length ? "T" : ""}${time}`;
16
+ };
17
+ const durate = (elements: [string, number][]) =>
18
+ elements
19
+ .filter(([_unit, value]) => value !== 0)
20
+ .map(([unit, value]) => `${value}${unit}`)
21
+ .join("");
22
+ const random = (minimum: number, maximum: number) =>
23
+ $randomInteger({
24
+ type: "integer",
25
+ minimum,
26
+ maximum,
27
+ });
@@ -1,11 +1,11 @@
1
- import { $randomString } from "./$randomString";
2
-
3
- export const $randomFormatEmail = (): string =>
4
- `${random(10)}@${random(10)}.${random(3)}`;
5
-
6
- const random = (length: number) =>
7
- $randomString({
8
- type: "string",
9
- minLength: length,
10
- maxLength: length,
11
- });
1
+ import { $randomString } from "./$randomString";
2
+
3
+ export const $randomFormatEmail = (): string =>
4
+ `${random(10)}@${random(10)}.${random(3)}`;
5
+
6
+ const random = (length: number) =>
7
+ $randomString({
8
+ type: "string",
9
+ minLength: length,
10
+ maxLength: length,
11
+ });
@@ -1,6 +1,6 @@
1
- import { $randomString } from "./$randomString";
2
-
3
- export const $randomFormatHostname = (): string => `${random(10)}.${random(3)}`;
4
-
5
- const random = (length: number) =>
6
- $randomString({ type: "string", minLength: length, maxLength: length });
1
+ import { $randomString } from "./$randomString";
2
+
3
+ export const $randomFormatHostname = (): string => `${random(10)}.${random(3)}`;
4
+
5
+ const random = (length: number) =>
6
+ $randomString({ type: "string", minLength: length, maxLength: length });
@@ -1,3 +1,3 @@
1
- import { $randomFormatEmail } from "./$randomFormatEmail";
2
-
3
- export const $randomFormatIdnEmail = (): string => $randomFormatEmail();
1
+ import { $randomFormatEmail } from "./$randomFormatEmail";
2
+
3
+ export const $randomFormatIdnEmail = (): string => $randomFormatEmail();
@@ -1,3 +1,3 @@
1
- import { $randomFormatHostname } from "./$randomFormatHostname";
2
-
3
- export const $randomFormatIdnHostname = (): string => $randomFormatHostname();
1
+ import { $randomFormatHostname } from "./$randomFormatHostname";
2
+
3
+ export const $randomFormatIdnHostname = (): string => $randomFormatHostname();
@@ -1,11 +1,11 @@
1
- import { $randomInteger } from "./$randomInteger";
2
-
3
- export const $randomFormatIpv4 = (): string =>
4
- new Array(4).fill(0).map(random).join(".");
5
-
6
- const random = () =>
7
- $randomInteger({
8
- type: "integer",
9
- minimum: 0,
10
- maximum: 255,
11
- });
1
+ import { $randomInteger } from "./$randomInteger";
2
+
3
+ export const $randomFormatIpv4 = (): string =>
4
+ new Array(4).fill(0).map(random).join(".");
5
+
6
+ const random = () =>
7
+ $randomInteger({
8
+ type: "integer",
9
+ minimum: 0,
10
+ maximum: 255,
11
+ });
@@ -1,11 +1,11 @@
1
- import { $randomInteger } from "./$randomInteger";
2
-
3
- export const $randomFormatIpv6 = (): string =>
4
- new Array(8).fill(0).map(random).join(":");
5
-
6
- const random = () =>
7
- $randomInteger({
8
- type: "integer",
9
- minimum: 0,
10
- maximum: 65_535,
11
- }).toString(16);
1
+ import { $randomInteger } from "./$randomInteger";
2
+
3
+ export const $randomFormatIpv6 = (): string =>
4
+ new Array(8).fill(0).map(random).join(":");
5
+
6
+ const random = () =>
7
+ $randomInteger({
8
+ type: "integer",
9
+ minimum: 0,
10
+ maximum: 65_535,
11
+ }).toString(16);
@@ -1,3 +1,3 @@
1
- import { $randomFormatUrl } from "./$randomFormatUrl";
2
-
3
- export const $randomFormatIri = (): string => $randomFormatUrl();
1
+ import { $randomFormatUrl } from "./$randomFormatUrl";
2
+
3
+ export const $randomFormatIri = (): string => $randomFormatUrl();
@@ -1,3 +1,3 @@
1
- import { $randomFormatUrl } from "./$randomFormatUrl";
2
-
3
- export const $randomFormatIriReference = (): string => $randomFormatUrl();
1
+ import { $randomFormatUrl } from "./$randomFormatUrl";
2
+
3
+ export const $randomFormatIriReference = (): string => $randomFormatUrl();
@@ -1,7 +1,7 @@
1
- import { $randomString } from "./$randomString";
2
-
3
- export const $randomFormatJsonPointer = (): string =>
4
- `/components/schemas/${random()}`;
5
-
6
- const random = () =>
7
- $randomString({ type: "string", minLength: 10, maxLength: 10 });
1
+ import { $randomString } from "./$randomString";
2
+
3
+ export const $randomFormatJsonPointer = (): string =>
4
+ `/components/schemas/${random()}`;
5
+
6
+ const random = () =>
7
+ $randomString({ type: "string", minLength: 10, maxLength: 10 });