typia 13.2.0 → 13.3.0
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.
- package/lib/http.d.ts +3 -3
- package/lib/http.js.map +1 -1
- package/lib/http.mjs.map +1 -1
- package/lib/internal/_assertGuard.js +13 -3
- package/lib/internal/_assertGuard.js.map +1 -1
- package/lib/internal/_assertGuard.mjs +4 -2
- package/lib/internal/_assertGuard.mjs.map +1 -1
- package/lib/internal/_isFormatIdnHostname.js +5 -1
- package/lib/internal/_isFormatIdnHostname.js.map +1 -1
- package/lib/internal/_isFormatIdnHostname.mjs +1 -1
- package/lib/internal/_isFormatIdnHostname.mjs.map +1 -1
- package/lib/internal/_isFormatTime.js +19 -2
- package/lib/internal/_isFormatTime.js.map +1 -1
- package/lib/internal/_isFormatTime.mjs +9 -2
- package/lib/internal/_isFormatTime.mjs.map +1 -1
- package/lib/internal/_randomArray.js +37 -4
- package/lib/internal/_randomArray.js.map +1 -1
- package/lib/internal/_randomArray.mjs +16 -3
- package/lib/internal/_randomArray.mjs.map +1 -1
- package/lib/internal/_randomFormatByte.js +15 -12
- package/lib/internal/_randomFormatByte.js.map +1 -1
- package/lib/internal/_randomFormatByte.mjs +11 -10
- package/lib/internal/_randomFormatByte.mjs.map +1 -1
- package/lib/internal/_randomFormatDatetime.mjs +1 -1
- package/lib/internal/_randomFormatHostname.d.ts +2 -2
- package/lib/internal/_randomFormatHostname.js +2 -2
- package/lib/internal/_randomFormatHostname.mjs +2 -2
- package/lib/internal/_randomFormatHostname.mjs.map +1 -1
- package/lib/internal/_randomFormatIdnHostname.js +9 -10
- package/lib/internal/_randomFormatIdnHostname.js.map +1 -1
- package/lib/internal/_randomFormatIdnHostname.mjs +3 -4
- package/lib/internal/_randomFormatIdnHostname.mjs.map +1 -1
- package/lib/internal/_randomFormatRegex.js +4 -4
- package/lib/internal/_randomFormatRegex.js.map +1 -1
- package/lib/internal/_randomFormatRegex.mjs +1 -2
- package/lib/internal/_randomFormatRegex.mjs.map +1 -1
- package/lib/internal/_randomFormatTime.js +15 -10
- package/lib/internal/_randomFormatTime.js.map +1 -1
- package/lib/internal/_randomFormatTime.mjs +6 -3
- package/lib/internal/_randomFormatTime.mjs.map +1 -1
- package/lib/internal/private/__randomComposition.d.ts +8 -0
- package/lib/internal/private/__randomComposition.js +21 -1
- package/lib/internal/private/__randomComposition.js.map +1 -1
- package/lib/internal/private/__randomComposition.mjs +18 -1
- package/lib/internal/private/__randomComposition.mjs.map +1 -1
- package/lib/json.d.ts +2 -2
- package/lib/json.js.map +1 -1
- package/lib/json.mjs.map +1 -1
- package/lib/module.d.ts +28 -13
- package/lib/module.js.map +1 -1
- package/lib/module.mjs.map +1 -1
- package/lib/notations.d.ts +4 -4
- package/lib/notations.js.map +1 -1
- package/lib/notations.mjs.map +1 -1
- package/lib/plain.d.ts +3 -3
- package/lib/plain.js.map +1 -1
- package/lib/plain.mjs.map +1 -1
- package/lib/protobuf.d.ts +2 -2
- package/lib/protobuf.js.map +1 -1
- package/lib/protobuf.mjs.map +1 -1
- package/native/cmd/ttsc-typia/assert_guard_factory_contract_test.go +17 -4
- package/native/cmd/ttsc-typia/create_assert_error_factory_arity_test.go +309 -0
- package/native/cmd/ttsc-typia/local_function_named_like_typia_operation_transform_test.go +185 -0
- package/native/cmd/ttsc-typia/recursive_conditional_alias_name_transform_test.go +307 -0
- package/native/cmd/ttsc-typia/shadowed_typia_module_declaration_diagnostic_test.go +152 -0
- package/native/cmd/ttsc-typia/template_literal_type_tags_transform_test.go +1 -3
- package/native/cmd/ttsc-typia/transform_helpers_test.go +92 -26
- package/native/core/factories/FormatCheatSheet.go +2 -2
- package/native/core/factories/MetadataCommentTagFactory.go +26 -11
- package/native/core/factories/factory_utility_coverage_test.go +896 -907
- package/native/core/factories/internal/metadata/MetadataHelper.go +5 -28
- package/native/core/factories/metadata_comment_tag_factory_coverage_test.go +2 -2
- package/native/core/programmers/RandomProgrammer.go +5 -2
- package/native/core/schemas/metadata/MetadataCollection.go +47 -5
- package/native/transform/CallExpressionTransformer.go +167 -0
- package/package.json +3 -3
- package/src/http.ts +18 -4
- package/src/internal/_assertGuard.ts +13 -2
- package/src/internal/_isFormatIdnHostname.ts +5 -1
- package/src/internal/_isFormatTime.ts +19 -2
- package/src/internal/_randomArray.ts +42 -6
- package/src/internal/_randomFormatByte.ts +17 -12
- package/src/internal/_randomFormatHostname.ts +2 -2
- package/src/internal/_randomFormatIdnHostname.ts +8 -9
- package/src/internal/_randomFormatRegex.ts +4 -6
- package/src/internal/_randomFormatTime.ts +15 -10
- package/src/internal/private/__randomComposition.ts +24 -0
- package/src/json.ts +16 -4
- package/src/module.ts +56 -22
- package/src/notations.ts +16 -4
- package/src/plain.ts +12 -3
- package/src/protobuf.ts +16 -4
|
@@ -20,8 +20,8 @@ const pickLength = (props) => {
|
|
|
20
20
|
};
|
|
21
21
|
/**
|
|
22
22
|
* Builds dot-joined hostname labels totaling exactly `length` characters, each
|
|
23
|
-
* label within 63 chars. Shared with the idn-hostname generator, which
|
|
24
|
-
*
|
|
23
|
+
* label within 63 chars. Shared with the idn-hostname generator, which realizes
|
|
24
|
+
* its length the same way since #2317 gave the two formats one structure.
|
|
25
25
|
*/
|
|
26
26
|
const _randomHostnameLabels = (length) => {
|
|
27
27
|
const parts = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_randomFormatHostname.mjs","names":[],"sources":["../../src/internal/_randomFormatHostname.ts"],"sourcesContent":["import { _randomInteger } from \"./_randomInteger\";\nimport { _randomString } from \"./_randomString\";\nimport { _ILengthProps } from \"./_randomStringLength\";\n\nexport const _randomFormatHostname = (props?: _ILengthProps): string => {\n if (props?.minLength === undefined && props?.maxLength === undefined)\n return `${random(10)}.${random(3)}`;\n // A hostname is dot-joined labels of 1..63 chars whose total is capped at 253,\n // so the requested length is realized by splitting it across enough labels.\n return _randomHostnameLabels(pickLength(props));\n};\n\nconst MAX_TOTAL = 253;\nconst MAX_LABEL = 63;\n\nconst pickLength = (props: _ILengthProps): number => {\n let low: number = props.minLength === undefined ? 1 : props.minLength;\n if (low < 1) low = 1;\n const high: number =\n props.maxLength === undefined\n ? Math.min(MAX_TOTAL, low + 14)\n : Math.min(MAX_TOTAL, props.maxLength);\n if (high < low)\n throw new Error(\n \"unable to generate a random hostname satisfying both the format and the length constraints.\",\n );\n return _randomInteger({ type: \"integer\", minimum: low, maximum: high });\n};\n\n/**\n * Builds dot-joined hostname labels totaling exactly `length` characters, each\n * label within 63 chars. Shared with the idn-hostname generator, which
|
|
1
|
+
{"version":3,"file":"_randomFormatHostname.mjs","names":[],"sources":["../../src/internal/_randomFormatHostname.ts"],"sourcesContent":["import { _randomInteger } from \"./_randomInteger\";\nimport { _randomString } from \"./_randomString\";\nimport { _ILengthProps } from \"./_randomStringLength\";\n\nexport const _randomFormatHostname = (props?: _ILengthProps): string => {\n if (props?.minLength === undefined && props?.maxLength === undefined)\n return `${random(10)}.${random(3)}`;\n // A hostname is dot-joined labels of 1..63 chars whose total is capped at 253,\n // so the requested length is realized by splitting it across enough labels.\n return _randomHostnameLabels(pickLength(props));\n};\n\nconst MAX_TOTAL = 253;\nconst MAX_LABEL = 63;\n\nconst pickLength = (props: _ILengthProps): number => {\n let low: number = props.minLength === undefined ? 1 : props.minLength;\n if (low < 1) low = 1;\n const high: number =\n props.maxLength === undefined\n ? Math.min(MAX_TOTAL, low + 14)\n : Math.min(MAX_TOTAL, props.maxLength);\n if (high < low)\n throw new Error(\n \"unable to generate a random hostname satisfying both the format and the length constraints.\",\n );\n return _randomInteger({ type: \"integer\", minimum: low, maximum: high });\n};\n\n/**\n * Builds dot-joined hostname labels totaling exactly `length` characters, each\n * label within 63 chars. Shared with the idn-hostname generator, which realizes\n * its length the same way since #2317 gave the two formats one structure.\n */\nexport const _randomHostnameLabels = (length: number): string => {\n const parts: string[] = [];\n let remaining: number = length;\n while (remaining > MAX_LABEL + 1) {\n // one full label plus its joining dot\n parts.push(random(MAX_LABEL));\n remaining -= MAX_LABEL + 1;\n }\n if (remaining <= MAX_LABEL) parts.push(random(remaining));\n else {\n // remaining === MAX_LABEL + 1: two labels keep every label within 63 chars\n parts.push(random(MAX_LABEL - 1));\n parts.push(random(1));\n }\n return parts.join(\".\");\n};\n\nconst random = (length: number) =>\n _randomString({ type: \"string\", minLength: length, maxLength: length });\n"],"mappings":";;;AAIA,MAAa,yBAAyB,UAAkC;CACtE,IAAI,OAAO,cAAc,KAAA,KAAa,OAAO,cAAc,KAAA,GACzD,OAAO,GAAG,OAAO,EAAE,EAAE,GAAG,OAAO,CAAC;CAGlC,OAAO,sBAAsB,WAAW,KAAK,CAAC;AAChD;AAEA,MAAM,YAAY;AAClB,MAAM,YAAY;AAElB,MAAM,cAAc,UAAiC;CACnD,IAAI,MAAc,MAAM,cAAc,KAAA,IAAY,IAAI,MAAM;CAC5D,IAAI,MAAM,GAAG,MAAM;CACnB,MAAM,OACJ,MAAM,cAAc,KAAA,IAChB,KAAK,IAAI,WAAW,MAAM,EAAE,IAC5B,KAAK,IAAI,WAAW,MAAM,SAAS;CACzC,IAAI,OAAO,KACT,MAAM,IAAI,MACR,6FACF;CACF,OAAO,eAAe;EAAE,MAAM;EAAW,SAAS;EAAK,SAAS;CAAK,CAAC;AACxE;;;;;;AAOA,MAAa,yBAAyB,WAA2B;CAC/D,MAAM,QAAkB,CAAC;CACzB,IAAI,YAAoB;CACxB,OAAO,YAAY,IAAe;EAEhC,MAAM,KAAK,OAAO,SAAS,CAAC;EAC5B,aAAa;CACf;CACA,IAAI,aAAa,WAAW,MAAM,KAAK,OAAO,SAAS,CAAC;MACnD;EAEH,MAAM,KAAK,OAAO,YAAY,CAAC,CAAC;EAChC,MAAM,KAAK,OAAO,CAAC,CAAC;CACtB;CACA,OAAO,MAAM,KAAK,GAAG;AACvB;AAEA,MAAM,UAAU,WACd,cAAc;CAAE,MAAM;CAAU,WAAW;CAAQ,WAAW;AAAO,CAAC"}
|
|
@@ -7,20 +7,19 @@ const _randomString_1 = require("./_randomString");
|
|
|
7
7
|
const _randomFormatIdnHostname = (props) => {
|
|
8
8
|
if ((props === null || props === void 0 ? void 0 : props.minLength) === undefined && (props === null || props === void 0 ? void 0 : props.maxLength) === undefined)
|
|
9
9
|
return `${random(10)}.${random(3)}`;
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
|
|
15
|
-
return
|
|
10
|
+
// idn-hostname shares hostname's structure (a single label of 1..63 chars is
|
|
11
|
+
// valid, no dot or trailing label required), so the requested length is
|
|
12
|
+
// realized the same way: split it across dot-joined labels. #2317 dropped the
|
|
13
|
+
// mandatory dot and two-character trailing label this generator used to
|
|
14
|
+
// reserve, which is why it now realizes a length below four.
|
|
15
|
+
return (0, _randomFormatHostname_1._randomHostnameLabels)(pickLength(props));
|
|
16
16
|
};
|
|
17
17
|
exports._randomFormatIdnHostname = _randomFormatIdnHostname;
|
|
18
18
|
const MAX_TOTAL = 253;
|
|
19
|
-
const MIN_TOTAL = 4; // the shortest idn hostname, `x.yy`: label(1) + `.` + tld(2)
|
|
20
19
|
const pickLength = (props) => {
|
|
21
|
-
let low = props.minLength === undefined ?
|
|
22
|
-
if (low <
|
|
23
|
-
low =
|
|
20
|
+
let low = props.minLength === undefined ? 1 : props.minLength;
|
|
21
|
+
if (low < 1)
|
|
22
|
+
low = 1;
|
|
24
23
|
const high = props.maxLength === undefined
|
|
25
24
|
? Math.min(MAX_TOTAL, low + 14)
|
|
26
25
|
: Math.min(MAX_TOTAL, props.maxLength);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_randomFormatIdnHostname.js","sourceRoot":"","sources":["../../src/internal/_randomFormatIdnHostname.ts"],"names":[],"mappings":";;;AAAA,mEAAgE;AAChE,qDAAkD;AAClD,mDAAgD;AAGzC,MAAM,wBAAwB,GAAG,CAAC,KAAqB,EAAU,EAAE;IACxE,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,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G,CAAC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAC3C,IAAI,IAAI,GAAG,GAAG;QACZ,MAAM,IAAI,KAAK,CACb,iGAAiG,CAClG,CAAC;IACJ,OAAO,IAAA,+BAAc,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;AAC1E,CAAC,CAAC;AAEF,MAAM,MAAM,GAAG,CAAC,MAAc,EAAE,EAAE,CAChC,IAAA,6BAAa,EAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC"}
|
|
@@ -4,13 +4,12 @@ import { _randomHostnameLabels } from "./_randomFormatHostname.mjs";
|
|
|
4
4
|
//#region src/internal/_randomFormatIdnHostname.ts
|
|
5
5
|
const _randomFormatIdnHostname = (props) => {
|
|
6
6
|
if (props?.minLength === void 0 && props?.maxLength === void 0) return `${random(10)}.${random(3)}`;
|
|
7
|
-
return
|
|
7
|
+
return _randomHostnameLabels(pickLength(props));
|
|
8
8
|
};
|
|
9
9
|
const MAX_TOTAL = 253;
|
|
10
|
-
const MIN_TOTAL = 4;
|
|
11
10
|
const pickLength = (props) => {
|
|
12
|
-
let low = props.minLength === void 0 ?
|
|
13
|
-
if (low <
|
|
11
|
+
let low = props.minLength === void 0 ? 1 : props.minLength;
|
|
12
|
+
if (low < 1) low = 1;
|
|
14
13
|
const high = props.maxLength === void 0 ? Math.min(MAX_TOTAL, low + 14) : Math.min(MAX_TOTAL, props.maxLength);
|
|
15
14
|
if (high < low) throw new Error("unable to generate a random idn hostname satisfying both the format and the length constraints.");
|
|
16
15
|
return _randomInteger({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_randomFormatIdnHostname.mjs","names":[],"sources":["../../src/internal/_randomFormatIdnHostname.ts"],"sourcesContent":["import { _randomHostnameLabels } from \"./_randomFormatHostname\";\nimport { _randomInteger } from \"./_randomInteger\";\nimport { _randomString } from \"./_randomString\";\nimport { _ILengthProps } from \"./_randomStringLength\";\n\nexport const _randomFormatIdnHostname = (props?: _ILengthProps): string => {\n if (props?.minLength === undefined && props?.maxLength === undefined)\n return `${random(10)}.${random(3)}`;\n //
|
|
1
|
+
{"version":3,"file":"_randomFormatIdnHostname.mjs","names":[],"sources":["../../src/internal/_randomFormatIdnHostname.ts"],"sourcesContent":["import { _randomHostnameLabels } from \"./_randomFormatHostname\";\nimport { _randomInteger } from \"./_randomInteger\";\nimport { _randomString } from \"./_randomString\";\nimport { _ILengthProps } from \"./_randomStringLength\";\n\nexport const _randomFormatIdnHostname = (props?: _ILengthProps): string => {\n if (props?.minLength === undefined && props?.maxLength === undefined)\n return `${random(10)}.${random(3)}`;\n // idn-hostname shares hostname's structure (a single label of 1..63 chars is\n // valid, no dot or trailing label required), so the requested length is\n // realized the same way: split it across dot-joined labels. #2317 dropped the\n // mandatory dot and two-character trailing label this generator used to\n // reserve, which is why it now realizes a length below four.\n return _randomHostnameLabels(pickLength(props));\n};\n\nconst MAX_TOTAL = 253;\n\nconst pickLength = (props: _ILengthProps): number => {\n let low: number = props.minLength === undefined ? 1 : props.minLength;\n if (low < 1) low = 1;\n const high: number =\n props.maxLength === undefined\n ? Math.min(MAX_TOTAL, low + 14)\n : Math.min(MAX_TOTAL, props.maxLength);\n if (high < low)\n throw new Error(\n \"unable to generate a random idn hostname satisfying both the format and the length constraints.\",\n );\n return _randomInteger({ type: \"integer\", minimum: low, maximum: high });\n};\n\nconst random = (length: number) =>\n _randomString({ type: \"string\", minLength: length, maxLength: length });\n"],"mappings":";;;;AAKA,MAAa,4BAA4B,UAAkC;CACzE,IAAI,OAAO,cAAc,KAAA,KAAa,OAAO,cAAc,KAAA,GACzD,OAAO,GAAG,OAAO,EAAE,EAAE,GAAG,OAAO,CAAC;CAMlC,OAAO,sBAAsB,WAAW,KAAK,CAAC;AAChD;AAEA,MAAM,YAAY;AAElB,MAAM,cAAc,UAAiC;CACnD,IAAI,MAAc,MAAM,cAAc,KAAA,IAAY,IAAI,MAAM;CAC5D,IAAI,MAAM,GAAG,MAAM;CACnB,MAAM,OACJ,MAAM,cAAc,KAAA,IAChB,KAAK,IAAI,WAAW,MAAM,EAAE,IAC5B,KAAK,IAAI,WAAW,MAAM,SAAS;CACzC,IAAI,OAAO,KACT,MAAM,IAAI,MACR,iGACF;CACF,OAAO,eAAe;EAAE,MAAM;EAAW,SAAS;EAAK,SAAS;CAAK,CAAC;AACxE;AAEA,MAAM,UAAU,WACd,cAAc;CAAE,MAAM;CAAU,WAAW;CAAQ,WAAW;AAAO,CAAC"}
|
|
@@ -4,11 +4,12 @@ exports._randomFormatRegex = void 0;
|
|
|
4
4
|
const _randomString_1 = require("./_randomString");
|
|
5
5
|
const _randomStringLength_1 = require("./_randomStringLength");
|
|
6
6
|
const _randomFormatRegex = (props) => {
|
|
7
|
-
if ((props === null || props === void 0 ? void 0 : props.minLength) === undefined && (props === null || props === void 0 ? void 0 : props.maxLength) === undefined)
|
|
8
|
-
return FIXED;
|
|
9
7
|
// Every character `_randomString` emits is a literal in regular expression
|
|
10
8
|
// syntax, so a source of any length — including the empty source `new
|
|
11
|
-
// RegExp("")` accepts — compiles.
|
|
9
|
+
// RegExp("")` accepts — compiles. An unconstrained draw is therefore an
|
|
10
|
+
// unconstrained string, and a constrained one fixes the length first.
|
|
11
|
+
if ((props === null || props === void 0 ? void 0 : props.minLength) === undefined && (props === null || props === void 0 ? void 0 : props.maxLength) === undefined)
|
|
12
|
+
return (0, _randomString_1._randomString)({ type: "string" });
|
|
12
13
|
const length = (0, _randomStringLength_1._randomLengthPick)((0, _randomStringLength_1._randomLengthWindow)(props, { minimum: 0, spread: 16 }));
|
|
13
14
|
return (0, _randomString_1._randomString)({
|
|
14
15
|
type: "string",
|
|
@@ -17,5 +18,4 @@ const _randomFormatRegex = (props) => {
|
|
|
17
18
|
});
|
|
18
19
|
};
|
|
19
20
|
exports._randomFormatRegex = _randomFormatRegex;
|
|
20
|
-
const FIXED = "/^(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)$/";
|
|
21
21
|
//# sourceMappingURL=_randomFormatRegex.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_randomFormatRegex.js","sourceRoot":"","sources":["../../src/internal/_randomFormatRegex.ts"],"names":[],"mappings":";;;AAAA,mDAAgD;AAChD,+DAI+B;AAExB,MAAM,kBAAkB,GAAG,CAAC,KAAqB,EAAU,EAAE;IAClE,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,MAAK,SAAS,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,MAAK,SAAS;QAClE,OAAO,
|
|
1
|
+
{"version":3,"file":"_randomFormatRegex.js","sourceRoot":"","sources":["../../src/internal/_randomFormatRegex.ts"],"names":[],"mappings":";;;AAAA,mDAAgD;AAChD,+DAI+B;AAExB,MAAM,kBAAkB,GAAG,CAAC,KAAqB,EAAU,EAAE;IAClE,2EAA2E;IAC3E,sEAAsE;IACtE,wEAAwE;IACxE,sEAAsE;IACtE,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,MAAK,SAAS,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,MAAK,SAAS;QAClE,OAAO,IAAA,6BAAa,EAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC3C,MAAM,MAAM,GAAW,IAAA,uCAAiB,EACtC,IAAA,yCAAmB,EAAC,KAAK,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CACvD,CAAC;IACF,OAAO,IAAA,6BAAa,EAAC;QACnB,IAAI,EAAE,QAAQ;QACd,SAAS,EAAE,MAAM;QACjB,SAAS,EAAE,MAAM;KAClB,CAAC,CAAC;AACL,CAAC,CAAC;AAfW,QAAA,kBAAkB,GAAlB,kBAAkB,CAe7B"}
|
|
@@ -2,7 +2,7 @@ import { _randomString } from "./_randomString.mjs";
|
|
|
2
2
|
import { _randomLengthPick, _randomLengthWindow } from "./_randomStringLength.mjs";
|
|
3
3
|
//#region src/internal/_randomFormatRegex.ts
|
|
4
4
|
const _randomFormatRegex = (props) => {
|
|
5
|
-
if (props?.minLength === void 0 && props?.maxLength === void 0) return
|
|
5
|
+
if (props?.minLength === void 0 && props?.maxLength === void 0) return _randomString({ type: "string" });
|
|
6
6
|
const length = _randomLengthPick(_randomLengthWindow(props, {
|
|
7
7
|
minimum: 0,
|
|
8
8
|
spread: 16
|
|
@@ -13,7 +13,6 @@ const _randomFormatRegex = (props) => {
|
|
|
13
13
|
maxLength: length
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
|
-
const FIXED = "/^(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)$/";
|
|
17
16
|
//#endregion
|
|
18
17
|
export { _randomFormatRegex };
|
|
19
18
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_randomFormatRegex.mjs","names":[],"sources":["../../src/internal/_randomFormatRegex.ts"],"sourcesContent":["import { _randomString } from \"./_randomString\";\nimport {\n _ILengthProps,\n _randomLengthPick,\n _randomLengthWindow,\n} from \"./_randomStringLength\";\n\nexport const _randomFormatRegex = (props?: _ILengthProps): string => {\n
|
|
1
|
+
{"version":3,"file":"_randomFormatRegex.mjs","names":[],"sources":["../../src/internal/_randomFormatRegex.ts"],"sourcesContent":["import { _randomString } from \"./_randomString\";\nimport {\n _ILengthProps,\n _randomLengthPick,\n _randomLengthWindow,\n} from \"./_randomStringLength\";\n\nexport const _randomFormatRegex = (props?: _ILengthProps): string => {\n // Every character `_randomString` emits is a literal in regular expression\n // syntax, so a source of any length — including the empty source `new\n // RegExp(\"\")` accepts — compiles. An unconstrained draw is therefore an\n // unconstrained string, and a constrained one fixes the length first.\n if (props?.minLength === undefined && props?.maxLength === undefined)\n return _randomString({ type: \"string\" });\n const length: number = _randomLengthPick(\n _randomLengthWindow(props, { minimum: 0, spread: 16 }),\n );\n return _randomString({\n type: \"string\",\n minLength: length,\n maxLength: length,\n });\n};\n"],"mappings":";;;AAOA,MAAa,sBAAsB,UAAkC;CAKnE,IAAI,OAAO,cAAc,KAAA,KAAa,OAAO,cAAc,KAAA,GACzD,OAAO,cAAc,EAAE,MAAM,SAAS,CAAC;CACzC,MAAM,SAAiB,kBACrB,oBAAoB,OAAO;EAAE,SAAS;EAAG,QAAQ;CAAG,CAAC,CACvD;CACA,OAAO,cAAc;EACnB,MAAM;EACN,WAAW;EACX,WAAW;CACb,CAAC;AACH"}
|
|
@@ -9,12 +9,11 @@ const _randomFormatTime = (props) => {
|
|
|
9
9
|
if ((props === null || props === void 0 ? void 0 : props.minLength) === undefined && (props === null || props === void 0 ? void 0 : props.maxLength) === undefined)
|
|
10
10
|
return clock().substring(11);
|
|
11
11
|
// `HH:MM:SS` carries a mandatory offset — one character as `Z`, six as
|
|
12
|
-
// `+HH:MM` — and an optional fraction
|
|
13
|
-
// Together they express 9 and every length from 11
|
|
14
|
-
// gap, because a fraction needs both a dot and a digit.
|
|
12
|
+
// `+HH:MM` — and an optional fraction between them that RFC 3339 leaves
|
|
13
|
+
// open above. Together they express 9 and every length from 11 upward; 10 is
|
|
14
|
+
// the one gap, because a fraction needs both a dot and a digit.
|
|
15
15
|
const window = (0, _randomStringLength_1._randomLengthWindow)(props, {
|
|
16
16
|
minimum: CLOCK + 1,
|
|
17
|
-
maximum: CLOCK + 1 + FRACTION_MAX + OFFSET,
|
|
18
17
|
spread: 6,
|
|
19
18
|
});
|
|
20
19
|
let length = (0, _randomStringLength_1._randomLengthPick)(window);
|
|
@@ -25,17 +24,23 @@ const _randomFormatTime = (props) => {
|
|
|
25
24
|
const base = clock().substring(11, 11 + CLOCK);
|
|
26
25
|
if (length === CLOCK + 1)
|
|
27
26
|
return `${base}Z`;
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
// The `Z` form reaches every remaining length by itself, so the numeric
|
|
28
|
+
// offset is a choice rather than a fallback: it spends six characters, which
|
|
29
|
+
// leaves either nothing (14, `HH:MM:SS+HH:MM`) or a whole fraction (16 and
|
|
30
|
+
// up). At 15 only the `Z` form fits, since the offset would demand a dot
|
|
31
|
+
// with no digit after it.
|
|
32
|
+
const fraction = length - CLOCK - OFFSET - 1;
|
|
33
|
+
return (fraction === -1 || fraction >= 1) &&
|
|
34
|
+
(0, _randomInteger_1._randomInteger)({ type: "integer", minimum: 0, maximum: 1 }) === 1
|
|
35
|
+
? fraction === -1
|
|
36
|
+
? `${base}${offset()}`
|
|
37
|
+
: `${base}.${(0, __randomComposition_1.__randomDigits)(fraction)}${offset()}`
|
|
38
|
+
: `${base}.${(0, __randomComposition_1.__randomDigits)(length - CLOCK - 2)}Z`;
|
|
33
39
|
};
|
|
34
40
|
exports._randomFormatTime = _randomFormatTime;
|
|
35
41
|
const DAY = 86400000;
|
|
36
42
|
const CLOCK = "00:00:00".length;
|
|
37
43
|
const OFFSET = "+00:00".length;
|
|
38
|
-
const FRACTION_MAX = 9;
|
|
39
44
|
const offset = () => `${(0, _randomInteger_1._randomInteger)({ type: "integer", minimum: 0, maximum: 1 }) === 0 ? "+" : "-"}${pad((0, _randomInteger_1._randomInteger)({ type: "integer", minimum: 0, maximum: 23 }))}:${pad((0, _randomInteger_1._randomInteger)({ type: "integer", minimum: 0, maximum: 59 }))}`;
|
|
40
45
|
const pad = (value) => String(value).padStart(2, "0");
|
|
41
46
|
//# sourceMappingURL=_randomFormatTime.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_randomFormatTime.js","sourceRoot":"","sources":["../../src/internal/_randomFormatTime.ts"],"names":[],"mappings":";;;AAAA,qDAAkD;AAClD,+DAK+B;AAC/B,uEAA+D;AAExD,MAAM,iBAAiB,GAAG,CAAC,KAAqB,EAAU,EAAE;IACjE,MAAM,KAAK,GAAG,GAAW,EAAE,CACzB,IAAI,IAAI,CACN,IAAA,+BAAc,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAC9D,CAAC,WAAW,EAAE,CAAC;IAClB,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,MAAK,SAAS,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,MAAK,SAAS;QAClE,OAAO,KAAK,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IAC/B,uEAAuE;IACvE,
|
|
1
|
+
{"version":3,"file":"_randomFormatTime.js","sourceRoot":"","sources":["../../src/internal/_randomFormatTime.ts"],"names":[],"mappings":";;;AAAA,qDAAkD;AAClD,+DAK+B;AAC/B,uEAA+D;AAExD,MAAM,iBAAiB,GAAG,CAAC,KAAqB,EAAU,EAAE;IACjE,MAAM,KAAK,GAAG,GAAW,EAAE,CACzB,IAAI,IAAI,CACN,IAAA,+BAAc,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAC9D,CAAC,WAAW,EAAE,CAAC;IAClB,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,MAAK,SAAS,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,MAAK,SAAS;QAClE,OAAO,KAAK,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IAC/B,uEAAuE;IACvE,wEAAwE;IACxE,6EAA6E;IAC7E,gEAAgE;IAChE,MAAM,MAAM,GAAG,IAAA,yCAAmB,EAAC,KAAK,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G,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC;AACvD,CAAC,CAAC;AAlCW,QAAA,iBAAiB,GAAjB,iBAAiB,CAkC5B;AAEF,MAAM,GAAG,GAAG,QAAU,CAAC;AACvB,MAAM,KAAK,GAAG,UAAU,CAAC,MAAM,CAAC;AAChC,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;AAE/B,MAAM,MAAM,GAAG,GAAW,EAAE,CAC1B,GAAG,IAAA,+BAAc,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CACpF,IAAA,+BAAc,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAC7D,IAAI,GAAG,CAAC,IAAA,+BAAc,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC;AAE3E,MAAM,GAAG,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC"}
|
|
@@ -11,7 +11,6 @@ const _randomFormatTime = (props) => {
|
|
|
11
11
|
if (props?.minLength === void 0 && props?.maxLength === void 0) return clock().substring(11);
|
|
12
12
|
const window = _randomLengthWindow(props, {
|
|
13
13
|
minimum: CLOCK + 1,
|
|
14
|
-
maximum: CLOCK + 1 + FRACTION_MAX + OFFSET,
|
|
15
14
|
spread: 6
|
|
16
15
|
});
|
|
17
16
|
let length = _randomLengthPick(window);
|
|
@@ -19,12 +18,16 @@ const _randomFormatTime = (props) => {
|
|
|
19
18
|
if (length < window.low || length > window.high) throw new Error(_RANDOM_LENGTH_ERROR);
|
|
20
19
|
const base = clock().substring(11, 11 + CLOCK);
|
|
21
20
|
if (length === CLOCK + 1) return `${base}Z`;
|
|
22
|
-
|
|
21
|
+
const fraction = length - CLOCK - OFFSET - 1;
|
|
22
|
+
return (fraction === -1 || fraction >= 1) && _randomInteger({
|
|
23
|
+
type: "integer",
|
|
24
|
+
minimum: 0,
|
|
25
|
+
maximum: 1
|
|
26
|
+
}) === 1 ? fraction === -1 ? `${base}${offset()}` : `${base}.${__randomDigits(fraction)}${offset()}` : `${base}.${__randomDigits(length - CLOCK - 2)}Z`;
|
|
23
27
|
};
|
|
24
28
|
const DAY = 864e5;
|
|
25
29
|
const CLOCK = 8;
|
|
26
30
|
const OFFSET = 6;
|
|
27
|
-
const FRACTION_MAX = 9;
|
|
28
31
|
const offset = () => `${_randomInteger({
|
|
29
32
|
type: "integer",
|
|
30
33
|
minimum: 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_randomFormatTime.mjs","names":[],"sources":["../../src/internal/_randomFormatTime.ts"],"sourcesContent":["import { _randomInteger } from \"./_randomInteger\";\nimport {\n _ILengthProps,\n _RANDOM_LENGTH_ERROR,\n _randomLengthPick,\n _randomLengthWindow,\n} from \"./_randomStringLength\";\nimport { __randomDigits } from \"./private/__randomComposition\";\n\nexport const _randomFormatTime = (props?: _ILengthProps): string => {\n const clock = (): string =>\n new Date(\n _randomInteger({ type: \"integer\", minimum: 0, maximum: DAY }),\n ).toISOString();\n if (props?.minLength === undefined && props?.maxLength === undefined)\n return clock().substring(11);\n // `HH:MM:SS` carries a mandatory offset — one character as `Z`, six as\n // `+HH:MM` — and an optional fraction
|
|
1
|
+
{"version":3,"file":"_randomFormatTime.mjs","names":[],"sources":["../../src/internal/_randomFormatTime.ts"],"sourcesContent":["import { _randomInteger } from \"./_randomInteger\";\nimport {\n _ILengthProps,\n _RANDOM_LENGTH_ERROR,\n _randomLengthPick,\n _randomLengthWindow,\n} from \"./_randomStringLength\";\nimport { __randomDigits } from \"./private/__randomComposition\";\n\nexport const _randomFormatTime = (props?: _ILengthProps): string => {\n const clock = (): string =>\n new Date(\n _randomInteger({ type: \"integer\", minimum: 0, maximum: DAY }),\n ).toISOString();\n if (props?.minLength === undefined && props?.maxLength === undefined)\n return clock().substring(11);\n // `HH:MM:SS` carries a mandatory offset — one character as `Z`, six as\n // `+HH:MM` — and an optional fraction between them that RFC 3339 leaves\n // open above. Together they express 9 and every length from 11 upward; 10 is\n // the one gap, because a fraction needs both a dot and a digit.\n const window = _randomLengthWindow(props, {\n minimum: CLOCK + 1,\n spread: 6,\n });\n let length: number = _randomLengthPick(window);\n if (length === CLOCK + 2)\n length = window.high >= CLOCK + 3 ? CLOCK + 3 : CLOCK + 1;\n if (length < window.low || length > window.high)\n throw new Error(_RANDOM_LENGTH_ERROR);\n const base: string = clock().substring(11, 11 + CLOCK);\n if (length === CLOCK + 1) return `${base}Z`;\n // The `Z` form reaches every remaining length by itself, so the numeric\n // offset is a choice rather than a fallback: it spends six characters, which\n // leaves either nothing (14, `HH:MM:SS+HH:MM`) or a whole fraction (16 and\n // up). At 15 only the `Z` form fits, since the offset would demand a dot\n // with no digit after it.\n const fraction: number = length - CLOCK - OFFSET - 1;\n return (fraction === -1 || fraction >= 1) &&\n _randomInteger({ type: \"integer\", minimum: 0, maximum: 1 }) === 1\n ? fraction === -1\n ? `${base}${offset()}`\n : `${base}.${__randomDigits(fraction)}${offset()}`\n : `${base}.${__randomDigits(length - CLOCK - 2)}Z`;\n};\n\nconst DAY = 86_400_000;\nconst CLOCK = \"00:00:00\".length;\nconst OFFSET = \"+00:00\".length;\n\nconst offset = (): string =>\n `${_randomInteger({ type: \"integer\", minimum: 0, maximum: 1 }) === 0 ? \"+\" : \"-\"}${pad(\n _randomInteger({ type: \"integer\", minimum: 0, maximum: 23 }),\n )}:${pad(_randomInteger({ type: \"integer\", minimum: 0, maximum: 59 }))}`;\n\nconst pad = (value: number): string => String(value).padStart(2, \"0\");\n"],"mappings":";;;;AASA,MAAa,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CAAC,SAAS,GAAG,GAAG"}
|
|
@@ -17,6 +17,14 @@ export declare const __randomComposition: (props: {
|
|
|
17
17
|
minimum: number;
|
|
18
18
|
maximum: number;
|
|
19
19
|
}) => number[];
|
|
20
|
+
/**
|
|
21
|
+
* Draws `length` characters of the base64 alphabet.
|
|
22
|
+
*
|
|
23
|
+
* The caller passes a multiple of four, which `format: "byte"` accepts without
|
|
24
|
+
* padding; every character below is in the alphabet its validator spells out,
|
|
25
|
+
* so the result needs no encoding step.
|
|
26
|
+
*/
|
|
27
|
+
export declare const __randomBase64: (length: number) => string;
|
|
20
28
|
/** Draws `length` decimal digits, leading zeros included. */
|
|
21
29
|
export declare const __randomDigits: (length: number) => string;
|
|
22
30
|
/** Draws a decimal number of exactly `length` digits without a leading zero. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.__randomNumeric = exports.__randomDigits = exports.__randomComposition = void 0;
|
|
3
|
+
exports.__randomNumeric = exports.__randomDigits = exports.__randomBase64 = exports.__randomComposition = void 0;
|
|
4
4
|
const _randomInteger_1 = require("../_randomInteger");
|
|
5
5
|
/**
|
|
6
6
|
* Splits `total` into `count` parts, each inside `[minimum, maximum]`.
|
|
@@ -31,6 +31,26 @@ const __randomComposition = (props) => {
|
|
|
31
31
|
return parts;
|
|
32
32
|
};
|
|
33
33
|
exports.__randomComposition = __randomComposition;
|
|
34
|
+
/**
|
|
35
|
+
* Draws `length` characters of the base64 alphabet.
|
|
36
|
+
*
|
|
37
|
+
* The caller passes a multiple of four, which `format: "byte"` accepts without
|
|
38
|
+
* padding; every character below is in the alphabet its validator spells out,
|
|
39
|
+
* so the result needs no encoding step.
|
|
40
|
+
*/
|
|
41
|
+
const __randomBase64 = (length) => {
|
|
42
|
+
let text = "";
|
|
43
|
+
for (let i = 0; i < length; ++i)
|
|
44
|
+
text +=
|
|
45
|
+
BASE64[(0, _randomInteger_1._randomInteger)({
|
|
46
|
+
type: "integer",
|
|
47
|
+
minimum: 0,
|
|
48
|
+
maximum: BASE64.length - 1,
|
|
49
|
+
})];
|
|
50
|
+
return text;
|
|
51
|
+
};
|
|
52
|
+
exports.__randomBase64 = __randomBase64;
|
|
53
|
+
const BASE64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
34
54
|
/** Draws `length` decimal digits, leading zeros included. */
|
|
35
55
|
const __randomDigits = (length) => {
|
|
36
56
|
let text = "";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"__randomComposition.js","sourceRoot":"","sources":["../../../src/internal/private/__randomComposition.ts"],"names":[],"mappings":";;;AAAA,sDAAmD;AAEnD;;;;;;;;;;;;GAYG;AACI,MAAM,mBAAmB,GAAG,CAAC,KAKnC,EAAY,EAAE;IACb,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,SAAS,GAAW,KAAK,CAAC,KAAK,CAAC;IACpC,KAAK,IAAI,CAAC,GAAW,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC;QAC7C,MAAM,IAAI,GAAW,KAAK,CAAC,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC;QACzC,MAAM,KAAK,GAAW,IAAA,+BAAc,EAAC;YACnC,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE,SAAS,GAAG,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC;YAClE,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE,SAAS,GAAG,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC;SACnE,CAAC,CAAC;QACH,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAClB,SAAS,IAAI,KAAK,CAAC;IACrB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAA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MAAM,EAAE,EAAE,CAAC;QACrC,IAAI,IAAI,MAAM,CAAC,IAAA,+BAAc,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC9E,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AALW,QAAA,cAAc,GAAd,cAAc,CAKzB;AAEF,gFAAgF;AACzE,MAAM,eAAe,GAAG,CAAC,MAAc,EAAU,EAAE,CACxD,MAAM,IAAI,CAAC;IACT,CAAC,CAAC,MAAM,CAAC,IAAA,+BAAc,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;IACrE,CAAC,CAAC,MAAM,CAAC,IAAA,+BAAc,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;QACnE,IAAA,QAAA,cAAc,EAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAJpB,QAAA,eAAe,GAAf,eAAe,CAIK"}
|
|
@@ -28,6 +28,23 @@ const __randomComposition = (props) => {
|
|
|
28
28
|
}
|
|
29
29
|
return parts;
|
|
30
30
|
};
|
|
31
|
+
/**
|
|
32
|
+
* Draws `length` characters of the base64 alphabet.
|
|
33
|
+
*
|
|
34
|
+
* The caller passes a multiple of four, which `format: "byte"` accepts without
|
|
35
|
+
* padding; every character below is in the alphabet its validator spells out,
|
|
36
|
+
* so the result needs no encoding step.
|
|
37
|
+
*/
|
|
38
|
+
const __randomBase64 = (length) => {
|
|
39
|
+
let text = "";
|
|
40
|
+
for (let i = 0; i < length; ++i) text += BASE64[_randomInteger({
|
|
41
|
+
type: "integer",
|
|
42
|
+
minimum: 0,
|
|
43
|
+
maximum: BASE64.length - 1
|
|
44
|
+
})];
|
|
45
|
+
return text;
|
|
46
|
+
};
|
|
47
|
+
const BASE64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
31
48
|
/** Draws `length` decimal digits, leading zeros included. */
|
|
32
49
|
const __randomDigits = (length) => {
|
|
33
50
|
let text = "";
|
|
@@ -49,6 +66,6 @@ const __randomNumeric = (length) => length <= 1 ? String(_randomInteger({
|
|
|
49
66
|
maximum: 9
|
|
50
67
|
})) + __randomDigits(length - 1);
|
|
51
68
|
//#endregion
|
|
52
|
-
export { __randomComposition, __randomDigits, __randomNumeric };
|
|
69
|
+
export { __randomBase64, __randomComposition, __randomDigits, __randomNumeric };
|
|
53
70
|
|
|
54
71
|
//# sourceMappingURL=__randomComposition.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"__randomComposition.mjs","names":[],"sources":["../../../src/internal/private/__randomComposition.ts"],"sourcesContent":["import { _randomInteger } from \"../_randomInteger\";\n\n/**\n * Splits `total` into `count` parts, each inside `[minimum, maximum]`.\n *\n * Used where a format's length is the sum of its segments — an IPv4 octet spans\n * one to three digits, an IPv6 group one to four — so a requested total length\n * is realized by choosing how many characters each segment contributes instead\n * of redrawing whole addresses and hoping one lands in the window (issue\n * #2284).\n *\n * The caller guarantees `count * minimum <= total <= count * maximum`; each\n * part is drawn from the range that still leaves the remaining parts\n * satisfiable.\n */\nexport const __randomComposition = (props: {\n total: number;\n count: number;\n minimum: number;\n maximum: number;\n}): number[] => {\n const parts: number[] = [];\n let remaining: number = props.total;\n for (let i: number = 0; i < props.count; ++i) {\n const rest: number = props.count - i - 1;\n const value: number = _randomInteger({\n type: \"integer\",\n minimum: Math.max(props.minimum, remaining - rest * props.maximum),\n maximum: Math.min(props.maximum, remaining - rest * props.minimum),\n });\n parts.push(value);\n remaining -= value;\n }\n return parts;\n};\n\n/** Draws `length` decimal digits, leading zeros included. */\nexport const __randomDigits = (length: number): string => {\n let text: string = \"\";\n for (let i: number = 0; i < length; ++i)\n text += String(_randomInteger({ type: \"integer\", minimum: 0, maximum: 9 }));\n return text;\n};\n\n/** Draws a decimal number of exactly `length` digits without a leading zero. */\nexport const __randomNumeric = (length: number): string =>\n length <= 1\n ? String(_randomInteger({ type: \"integer\", minimum: 0, maximum: 9 }))\n : String(_randomInteger({ type: \"integer\", minimum: 1, maximum: 9 })) +\n __randomDigits(length - 1);\n"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAa,uBAAuB,UAKpB;CACd,MAAM,QAAkB,CAAC;CACzB,IAAI,YAAoB,MAAM;CAC9B,KAAK,IAAI,IAAY,GAAG,IAAI,MAAM,OAAO,EAAE,GAAG;EAC5C,MAAM,OAAe,MAAM,QAAQ,IAAI;EACvC,MAAM,QAAgB,eAAe;GACnC,MAAM;GACN,SAAS,KAAK,IAAI,MAAM,SAAS,YAAY,OAAO,MAAM,OAAO;GACjE,SAAS,KAAK,IAAI,MAAM,SAAS,YAAY,OAAO,MAAM,OAAO;EACnE,CAAC;EACD,MAAM,KAAK,KAAK;EAChB,aAAa;CACf;CACA,OAAO;AACT;;
|
|
1
|
+
{"version":3,"file":"__randomComposition.mjs","names":[],"sources":["../../../src/internal/private/__randomComposition.ts"],"sourcesContent":["import { _randomInteger } from \"../_randomInteger\";\n\n/**\n * Splits `total` into `count` parts, each inside `[minimum, maximum]`.\n *\n * Used where a format's length is the sum of its segments — an IPv4 octet spans\n * one to three digits, an IPv6 group one to four — so a requested total length\n * is realized by choosing how many characters each segment contributes instead\n * of redrawing whole addresses and hoping one lands in the window (issue\n * #2284).\n *\n * The caller guarantees `count * minimum <= total <= count * maximum`; each\n * part is drawn from the range that still leaves the remaining parts\n * satisfiable.\n */\nexport const __randomComposition = (props: {\n total: number;\n count: number;\n minimum: number;\n maximum: number;\n}): number[] => {\n const parts: number[] = [];\n let remaining: number = props.total;\n for (let i: number = 0; i < props.count; ++i) {\n const rest: number = props.count - i - 1;\n const value: number = _randomInteger({\n type: \"integer\",\n minimum: Math.max(props.minimum, remaining - rest * props.maximum),\n maximum: Math.min(props.maximum, remaining - rest * props.minimum),\n });\n parts.push(value);\n remaining -= value;\n }\n return parts;\n};\n\n/**\n * Draws `length` characters of the base64 alphabet.\n *\n * The caller passes a multiple of four, which `format: \"byte\"` accepts without\n * padding; every character below is in the alphabet its validator spells out,\n * so the result needs no encoding step.\n */\nexport const __randomBase64 = (length: number): string => {\n let text: string = \"\";\n for (let i: number = 0; i < length; ++i)\n text +=\n BASE64[\n _randomInteger({\n type: \"integer\",\n minimum: 0,\n maximum: BASE64.length - 1,\n })\n ];\n return text;\n};\n\nconst BASE64 =\n \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n\n/** Draws `length` decimal digits, leading zeros included. */\nexport const __randomDigits = (length: number): string => {\n let text: string = \"\";\n for (let i: number = 0; i < length; ++i)\n text += String(_randomInteger({ type: \"integer\", minimum: 0, maximum: 9 }));\n return text;\n};\n\n/** Draws a decimal number of exactly `length` digits without a leading zero. */\nexport const __randomNumeric = (length: number): string =>\n length <= 1\n ? String(_randomInteger({ type: \"integer\", minimum: 0, maximum: 9 }))\n : String(_randomInteger({ type: \"integer\", minimum: 1, maximum: 9 })) +\n __randomDigits(length - 1);\n"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAa,uBAAuB,UAKpB;CACd,MAAM,QAAkB,CAAC;CACzB,IAAI,YAAoB,MAAM;CAC9B,KAAK,IAAI,IAAY,GAAG,IAAI,MAAM,OAAO,EAAE,GAAG;EAC5C,MAAM,OAAe,MAAM,QAAQ,IAAI;EACvC,MAAM,QAAgB,eAAe;GACnC,MAAM;GACN,SAAS,KAAK,IAAI,MAAM,SAAS,YAAY,OAAO,MAAM,OAAO;GACjE,SAAS,KAAK,IAAI,MAAM,SAAS,YAAY,OAAO,MAAM,OAAO;EACnE,CAAC;EACD,MAAM,KAAK,KAAK;EAChB,aAAa;CACf;CACA,OAAO;AACT;;;;;;;;AASA,MAAa,kBAAkB,WAA2B;CACxD,IAAI,OAAe;CACnB,KAAK,IAAI,IAAY,GAAG,IAAI,QAAQ,EAAE,GACpC,QACE,OACE,eAAe;EACb,MAAM;EACN,SAAS;EACT,SAAS,OAAO,SAAS;CAC3B,CAAC;CAEP,OAAO;AACT;AAEA,MAAM,SACJ;;AAGF,MAAa,kBAAkB,WAA2B;CACxD,IAAI,OAAe;CACnB,KAAK,IAAI,IAAY,GAAG,IAAI,QAAQ,EAAE,GACpC,QAAQ,OAAO,eAAe;EAAE,MAAM;EAAW,SAAS;EAAG,SAAS;CAAE,CAAC,CAAC;CAC5E,OAAO;AACT;;AAGA,MAAa,mBAAmB,WAC9B,UAAU,IACN,OAAO,eAAe;CAAE,MAAM;CAAW,SAAS;CAAG,SAAS;AAAE,CAAC,CAAC,IAClE,OAAO,eAAe;CAAE,MAAM;CAAW,SAAS;CAAG,SAAS;AAAE,CAAC,CAAC,IAClE,eAAe,SAAS,CAAC"}
|
package/lib/json.d.ts
CHANGED
|
@@ -302,7 +302,7 @@ export declare function createAssertParse(errorFactory?: undefined | ((props: Ty
|
|
|
302
302
|
* {@link TypeGuardError.IProps}
|
|
303
303
|
* @returns Reusable parser function
|
|
304
304
|
*/
|
|
305
|
-
export declare function createAssertParse<T>(errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error)): (input: string) => Primitive<T>;
|
|
305
|
+
export declare function createAssertParse<T>(errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error)): (input: string, errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error)) => Primitive<T>;
|
|
306
306
|
/**
|
|
307
307
|
* Creates reusable {@link validateParse} function.
|
|
308
308
|
*
|
|
@@ -343,7 +343,7 @@ export declare function createAssertStringify(errorFactory?: undefined | ((props
|
|
|
343
343
|
* {@link TypeGuardError.IProps}
|
|
344
344
|
* @returns Reusable stringify function
|
|
345
345
|
*/
|
|
346
|
-
export declare function createAssertStringify<T>(errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error)): (input: unknown) => string;
|
|
346
|
+
export declare function createAssertStringify<T>(errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error)): (input: unknown, errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error)) => string;
|
|
347
347
|
/**
|
|
348
348
|
* Creates reusable {@link isStringify} function.
|
|
349
349
|
*
|
package/lib/json.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.js","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AASA,gGAA6F;AAoC7F,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,aAAa,CAAC,CAAC;AAC/C,CAAC;AA2BD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,cAAc,CAAC,CAAC;AAChD,CAAC;AAuCD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,kBAAkB,CAAC,CAAC;AACpD,CAAC;AAsCD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,kBAAkB,CAAC,CAAC;AACpD,CAAC;AA0BD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,cAAc,CAAC,CAAC;AAChD,CAAC;AA2BD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,oBAAoB,CAAC,CAAC;AACtD,CAAC;AAuBD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,gBAAgB,CAAC,CAAC;AAClD,CAAC;AAoDD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,sBAAsB,CAAC,CAAC;AACxD,CAAC;AAwCD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,kBAAkB,CAAC,CAAC;AACpD,CAAC;AA0CD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,wBAAwB,CAAC,CAAC;AAC1D,CAAC;AAoBD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,oBAAoB,CAAC,CAAC;AACtD,CAAC;
|
|
1
|
+
{"version":3,"file":"json.js","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":";;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BD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,wBAAwB,CAAC,CAAC;AAC1D,CAAC;AAmBD,gBAAgB;AAChB;IAGE,IAAA,6DAA6B,EAAC,8BAA8B,CAAC,CAAC;AAChE,CAAC"}
|
package/lib/json.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.mjs","names":[],"sources":["../src/json.ts"],"sourcesContent":["import {\n IJsonSchemaApplication,\n IJsonSchemaCollection,\n IJsonSchemaUnit,\n IValidation,\n Primitive,\n} from \"@typia/interface\";\n\nimport { TypeGuardError } from \"./TypeGuardError\";\nimport { NoTransformConfigurationError } from \"./transformers/NoTransformConfigurationError\";\n\n/* ===========================================================\n JSON\n - METADATA\n - PARSE\n - STRINGIFY\n - FACTORY FUNCTIONS\n==============================================================\n METADATA\n----------------------------------------------------------- */\n/**\n * Generates JSON schema for type `T`.\n *\n * @danger You must configure the generic argument `Type`\n */\nexport function schema(): never;\n\n/**\n * Generates JSON schema for type `T`.\n *\n * Creates {@link IJsonSchemaUnit} containing a main schema and shared\n * components. Named types are stored in `components` for `$ref` referencing.\n *\n * Specify OpenAPI version via `Version` generic (`\"3.0\"` or `\"3.1\"`). Default\n * is `\"3.1\"`. Key difference: `\"3.1\"` supports tuple types.\n *\n * @template Type Target type\n * @template Version OpenAPI version (`\"3.0\"` | `\"3.1\"`). Default `\"3.1\"`\n * @returns JSON schema unit\n */\nexport function schema<\n Type extends unknown,\n Version extends \"3.0\" | \"3.1\" = \"3.1\",\n>(): IJsonSchemaUnit<Version, Type>;\n\n/** @internal */\nexport function schema(): never {\n NoTransformConfigurationError(\"json.schema\");\n}\n\n/**\n * Generates JSON schemas for multiple types.\n *\n * @danger You must configure the generic argument `Types`\n */\nexport function schemas(): never;\n\n/**\n * Generates JSON schemas for multiple types.\n *\n * Creates {@link IJsonSchemaCollection} containing schemas for all types in the\n * tuple. Named types are stored in `components` for `$ref` referencing.\n *\n * Specify OpenAPI version via `Version` generic (`\"3.0\"` or `\"3.1\"`). Default\n * is `\"3.1\"`. Key difference: `\"3.1\"` supports tuple types.\n *\n * @template Types Tuple of target types\n * @template Version OpenAPI version (`\"3.0\"` | `\"3.1\"`). Default `\"3.1\"`\n * @returns JSON schema collection\n */\nexport function schemas<\n Types extends unknown[],\n Version extends \"3.0\" | \"3.1\" = \"3.1\",\n>(): IJsonSchemaCollection<Version, Types>;\n\n/** @internal */\nexport function schemas(): never {\n NoTransformConfigurationError(\"json.schemas\");\n}\n\n/**\n * Generates JSON function schema application.\n *\n * @danger You must configure the generic argument `Class`\n */\nexport function application(): never;\n\n/**\n * Generates JSON function schema application from class/interface.\n *\n * Creates {@link IJsonSchemaApplication} from a TypeScript class or interface,\n * generating JSON schemas for all methods, parameters, and return types.\n * Designed for building custom LLM function calling schemas.\n *\n * The returned object contains:\n *\n * - `functions`: Array of function metadata with parameter/return schemas\n * - `components`: Shared schema components for `$ref` referencing\n *\n * Use cases:\n *\n * - Custom LLM function calling schema formats\n * - API documentation or code generation tools\n * - Alternative LLM integrations that need full JSON Schema\n *\n * For standard LLM function calling, use {@link llm.application} instead, which\n * builds the LLM-optimized function schema directly.\n *\n * @template Class Target class or interface type\n * @template Version OpenAPI version (`\"3.0\"` | `\"3.1\"`). Default `\"3.1\"`\n * @returns JSON function schema application\n */\nexport function application<\n Class extends object,\n Version extends \"3.0\" | \"3.1\" = \"3.1\",\n>(): IJsonSchemaApplication<Version, Class>;\n\n/** @internal */\nexport function application(): never {\n NoTransformConfigurationError(\"json.application\");\n}\n\n/* -----------------------------------------------------------\n PARSE\n----------------------------------------------------------- */\n/**\n * Parses JSON string with assertion.\n *\n * @danger You must configure the generic argument `T`\n */\nexport function assertParse(\n input: string,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): never;\n\n/**\n * Parses JSON string with assertion.\n *\n * Combines `JSON.parse()` with {@link assert}. Throws {@link TypeGuardError} when\n * parsed value doesn't match type `T`.\n *\n * Related functions:\n *\n * - {@link isParse} — Returns `null` instead of throwing\n * - {@link validateParse} — Returns detailed validation errors\n *\n * @template T Target type for parsed value\n * @param input JSON string to parse\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns Parsed value of type `T`\n * @throws {TypeGuardError} When parsed value doesn't conform to type `T`\n */\nexport function assertParse<T>(\n input: string,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): Primitive<T>;\n\n/** @internal */\nexport function assertParse<T>(): Primitive<T> {\n NoTransformConfigurationError(\"json.assertParse\");\n}\n\n/**\n * Parses JSON string with type checking.\n *\n * @danger You must configure the generic argument `T`\n */\nexport function isParse(input: string): never;\n\n/**\n * Parses JSON string with type checking.\n *\n * Combines `JSON.parse()` with {@link is}. Returns `null` when parsed value\n * doesn't match type `T`.\n *\n * Related functions:\n *\n * - {@link assertParse} — Throws instead of returning `null`\n * - {@link validateParse} — Returns detailed validation errors\n *\n * @template T Target type for parsed value\n * @param input JSON string to parse\n * @returns Parsed value of type `T`, or `null` if invalid\n */\nexport function isParse<T>(input: string): Primitive<T> | null;\n\n/** @internal */\nexport function isParse<T>(): Primitive<T> | null {\n NoTransformConfigurationError(\"json.isParse\");\n}\n\n/**\n * Parses JSON string with validation.\n *\n * @danger You must configure the generic argument `T`\n */\nexport function validateParse(input: string): never;\n\n/**\n * Parses JSON string with validation.\n *\n * Combines `JSON.parse()` with {@link validate}. Returns\n * {@link IValidation.IFailure} with all errors on mismatch, or\n * {@link IValidation.ISuccess} with parsed value.\n *\n * Related functions:\n *\n * - {@link assertParse} — Throws on first error\n * - {@link isParse} — Returns `null` instead of error details\n *\n * @template T Target type for parsed value\n * @param input JSON string to parse\n * @returns Validation result containing parsed value or errors\n */\nexport function validateParse<T>(input: string): IValidation<Primitive<T>>;\n\n/** @internal */\nexport function validateParse<T>(): IValidation<Primitive<T>> {\n NoTransformConfigurationError(\"json.validateParse\");\n}\n\n/* -----------------------------------------------------------\n STRINGIFY\n----------------------------------------------------------- */\n/**\n * Converts value to JSON string (8x faster).\n *\n * Generates optimized JSON conversion code specific to type `T`, achieving ~8x\n * faster performance than native `JSON.stringify()`.\n *\n * Does not validate the input. For validation, use:\n *\n * - {@link assertStringify} — Throws on type mismatch\n * - {@link isStringify} — Returns `null` on type mismatch\n * - {@link validateStringify} — Returns detailed validation errors\n *\n * @template T Type of input value\n * @param input Value to stringify\n * @returns JSON string\n */\nexport function stringify<T>(input: T): string;\n\n/** @internal */\nexport function stringify(): never {\n NoTransformConfigurationError(\"json.stringify\");\n}\n\n/**\n * Converts value to JSON string with assertion (5x faster).\n *\n * Combines {@link assert} with {@link stringify}. Throws {@link TypeGuardError}\n * when input doesn't match type `T`. Achieves ~5x faster performance than\n * native `JSON.stringify()`.\n *\n * Related functions:\n *\n * - {@link stringify} — No validation\n * - {@link isStringify} — Returns `null` instead of throwing\n * - {@link validateStringify} — Returns detailed validation errors\n *\n * @template T Type of input value\n * @param input Value to assert and stringify\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns JSON string\n * @throws {TypeGuardError} When input doesn't conform to type `T`\n */\nexport function assertStringify<T>(\n input: T,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): string;\n\n/**\n * Converts value to JSON string with assertion (5x faster).\n *\n * Combines {@link assert} with {@link stringify}. Throws {@link TypeGuardError}\n * when input doesn't match type `T`. Achieves ~5x faster performance than\n * native `JSON.stringify()`.\n *\n * Related functions:\n *\n * - {@link stringify} — No validation\n * - {@link isStringify} — Returns `null` instead of throwing\n * - {@link validateStringify} — Returns detailed validation errors\n *\n * @template T Type of input value\n * @param input Value to assert and stringify\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns JSON string\n * @throws {TypeGuardError} When input doesn't conform to type `T`\n */\nexport function assertStringify<T>(\n input: T,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): unknown;\n\n/** @internal */\nexport function assertStringify(): string {\n NoTransformConfigurationError(\"json.assertStringify\");\n}\n\n/**\n * Converts value to JSON string with type checking (7x faster).\n *\n * Combines {@link is} with {@link stringify}. Returns `null` when input doesn't\n * match type `T`. Achieves ~7x faster performance than native\n * `JSON.stringify()`.\n *\n * Related functions:\n *\n * - {@link stringify} — No validation\n * - {@link assertStringify} — Throws instead of returning `null`\n * - {@link validateStringify} — Returns detailed validation errors\n *\n * @template T Type of input value\n * @param input Value to check and stringify\n * @returns JSON string, or `null` if type check fails\n */\nexport function isStringify<T>(input: T): string | null;\n\n/**\n * Converts value to JSON string with type checking (7x faster).\n *\n * Combines {@link is} with {@link stringify}. Returns `null` when input doesn't\n * match type `T`. Achieves ~7x faster performance than native\n * `JSON.stringify()`.\n *\n * Related functions:\n *\n * - {@link stringify} — No validation\n * - {@link assertStringify} — Throws instead of returning `null`\n * - {@link validateStringify} — Returns detailed validation errors\n *\n * @template T Type of input value\n * @param input Value to check and stringify\n * @returns JSON string, or `null` if type check fails\n */\nexport function isStringify<T>(input: unknown): string | null;\n\n/** @internal */\nexport function isStringify(): string | null {\n NoTransformConfigurationError(\"json.isStringify\");\n}\n\n/**\n * Converts value to JSON string with validation (5x faster).\n *\n * Combines {@link validate} with {@link stringify}. Returns\n * {@link IValidation.IFailure} with all errors on mismatch, or\n * {@link IValidation.ISuccess} with JSON string. Achieves ~5x faster performance\n * than native `JSON.stringify()`.\n *\n * Related functions:\n *\n * - {@link stringify} — No validation\n * - {@link assertStringify} — Throws on first error\n * - {@link isStringify} — Returns `null` instead of error details\n *\n * @template T Type of input value\n * @param input Value to validate and stringify\n * @returns Validation result containing JSON string or errors\n */\nexport function validateStringify<T>(input: T): IValidation<string>;\n\n/**\n * Converts value to JSON string with validation (5x faster).\n *\n * Combines {@link validate} with {@link stringify}. Returns\n * {@link IValidation.IFailure} with all errors on mismatch, or\n * {@link IValidation.ISuccess} with JSON string. Achieves ~5x faster performance\n * than native `JSON.stringify()`.\n *\n * Related functions:\n *\n * - {@link stringify} — No validation\n * - {@link assertStringify} — Throws on first error\n * - {@link isStringify} — Returns `null` instead of error details\n *\n * @template T Type of input value\n * @param input Value to validate and stringify\n * @returns Validation result containing JSON string or errors\n */\nexport function validateStringify<T>(input: unknown): IValidation<string>;\n\n/** @internal */\nexport function validateStringify(): IValidation<string> {\n NoTransformConfigurationError(\"json.validateStringify\");\n}\n\n/* -----------------------------------------------------------\n FACTORY FUNCTIONS\n----------------------------------------------------------- */\n/**\n * Creates reusable {@link isParse} function.\n *\n * @danger You must configure the generic argument `T`\n */\nexport function createIsParse(): never;\n\n/**\n * Creates reusable {@link isParse} function.\n *\n * @template T Target type for parsed value\n * @returns Reusable parser function\n */\nexport function createIsParse<T>(): (input: string) => Primitive<T> | null;\n\n/** @internal */\nexport function createIsParse<T>(): (input: string) => Primitive<T> | null {\n NoTransformConfigurationError(\"json.createIsParse\");\n}\n\n/**\n * Creates reusable {@link assertParse} function.\n *\n * @danger You must configure the generic argument `T`\n */\nexport function createAssertParse(\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): never;\n\n/**\n * Creates reusable {@link assertParse} function.\n *\n * @template T Target type for parsed value\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns Reusable parser function\n */\nexport function createAssertParse<T>(\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): (input: string) => Primitive<T>;\n\n/** @internal */\nexport function createAssertParse<T>(): (input: string) => Primitive<T> {\n NoTransformConfigurationError(\"json.createAssertParse\");\n}\n\n/**\n * Creates reusable {@link validateParse} function.\n *\n * @danger You must configure the generic argument `T`\n */\nexport function createValidateParse(): never;\n\n/**\n * Creates reusable {@link validateParse} function.\n *\n * @template T Target type for parsed value\n * @returns Reusable parser function\n */\nexport function createValidateParse<T>(): (\n input: string,\n) => IValidation<Primitive<T>>;\n\n/** @internal */\nexport function createValidateParse<T>(): (\n input: string,\n) => IValidation<Primitive<T>> {\n NoTransformConfigurationError(\"json.createValidateParse\");\n}\n\n/**\n * Creates reusable {@link stringify} function.\n *\n * @danger You must configure the generic argument `T`\n */\nexport function createStringify(): never;\n\n/**\n * Creates reusable {@link stringify} function.\n *\n * @template T Type of input value\n * @returns Reusable stringify function\n */\nexport function createStringify<T>(): (input: T) => string;\n\n/** @internal */\nexport function createStringify<T>(): (input: T) => string {\n NoTransformConfigurationError(\"json.createStringify\");\n}\n\n/**\n * Creates reusable {@link assertStringify} function.\n *\n * @danger You must configure the generic argument `T`\n */\nexport function createAssertStringify(\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): never;\n\n/**\n * Creates reusable {@link assertStringify} function.\n *\n * @template T Type of input value\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns Reusable stringify function\n */\nexport function createAssertStringify<T>(\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): (input: unknown) => string;\n\n/** @internal */\nexport function createAssertStringify(): (input: unknown) => string {\n NoTransformConfigurationError(\"json.createAssertStringify\");\n}\n\n/**\n * Creates reusable {@link isStringify} function.\n *\n * @danger You must configure the generic argument `T`\n */\nexport function createIsStringify(): never;\n\n/**\n * Creates reusable {@link isStringify} function.\n *\n * @template T Type of input value\n * @returns Reusable stringify function\n */\nexport function createIsStringify<T>(): (input: unknown) => string | null;\n\n/** @internal */\nexport function createIsStringify(): (input: unknown) => string | null {\n NoTransformConfigurationError(\"json.createIsStringify\");\n}\n\n/**\n * Creates reusable {@link validateStringify} function.\n *\n * @danger You must configure the generic argument `T`\n */\nexport function createValidateStringify(): never;\n\n/**\n * Creates reusable {@link validateStringify} function.\n *\n * @template T Type of input value\n * @returns Reusable stringify function\n */\nexport function createValidateStringify<T>(): (\n input: unknown,\n) => IValidation<string>;\n\n/** @internal */\nexport function createValidateStringify(): (\n input: unknown,\n) => IValidation<string> {\n NoTransformConfigurationError(\"json.createValidateStringify\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA8CA,SAAgB,SAAgB;CAC9B,8BAA8B,aAAa;AAC7C;;AA4BA,SAAgB,UAAiB;CAC/B,8BAA8B,cAAc;AAC9C;;AAwCA,SAAgB,cAAqB;CACnC,8BAA8B,kBAAkB;AAClD;;AAuCA,SAAgB,cAA+B;CAC7C,8BAA8B,kBAAkB;AAClD;;AA2BA,SAAgB,UAAkC;CAChD,8BAA8B,cAAc;AAC9C;;AA4BA,SAAgB,gBAA8C;CAC5D,8BAA8B,oBAAoB;AACpD;;AAwBA,SAAgB,YAAmB;CACjC,8BAA8B,gBAAgB;AAChD;;AAqDA,SAAgB,kBAA0B;CACxC,8BAA8B,sBAAsB;AACtD;;AAyCA,SAAgB,cAA6B;CAC3C,8BAA8B,kBAAkB;AAClD;;AA2CA,SAAgB,oBAAyC;CACvD,8BAA8B,wBAAwB;AACxD;;AAqBA,SAAgB,gBAA2D;CACzE,8BAA8B,oBAAoB;AACpD;;AAwBA,SAAgB,oBAAwD;CACtE,8BAA8B,wBAAwB;AACxD;;AAoBA,SAAgB,sBAEe;CAC7B,8BAA8B,0BAA0B;AAC1D;;AAkBA,SAAgB,kBAA2C;CACzD,8BAA8B,sBAAsB;AACtD;;AAwBA,SAAgB,wBAAoD;CAClE,8BAA8B,4BAA4B;AAC5D;;AAkBA,SAAgB,oBAAuD;CACrE,8BAA8B,wBAAwB;AACxD;;AAoBA,SAAgB,0BAES;CACvB,8BAA8B,8BAA8B;AAC9D"}
|
|
1
|
+
{"version":3,"file":"json.mjs","names":[],"sources":["../src/json.ts"],"sourcesContent":["import {\n IJsonSchemaApplication,\n IJsonSchemaCollection,\n IJsonSchemaUnit,\n IValidation,\n Primitive,\n} from \"@typia/interface\";\n\nimport { TypeGuardError } from \"./TypeGuardError\";\nimport { NoTransformConfigurationError } from \"./transformers/NoTransformConfigurationError\";\n\n/* ===========================================================\n JSON\n - METADATA\n - PARSE\n - STRINGIFY\n - FACTORY FUNCTIONS\n==============================================================\n METADATA\n----------------------------------------------------------- */\n/**\n * Generates JSON schema for type `T`.\n *\n * @danger You must configure the generic argument `Type`\n */\nexport function schema(): never;\n\n/**\n * Generates JSON schema for type `T`.\n *\n * Creates {@link IJsonSchemaUnit} containing a main schema and shared\n * components. Named types are stored in `components` for `$ref` referencing.\n *\n * Specify OpenAPI version via `Version` generic (`\"3.0\"` or `\"3.1\"`). Default\n * is `\"3.1\"`. Key difference: `\"3.1\"` supports tuple types.\n *\n * @template Type Target type\n * @template Version OpenAPI version (`\"3.0\"` | `\"3.1\"`). Default `\"3.1\"`\n * @returns JSON schema unit\n */\nexport function schema<\n Type extends unknown,\n Version extends \"3.0\" | \"3.1\" = \"3.1\",\n>(): IJsonSchemaUnit<Version, Type>;\n\n/** @internal */\nexport function schema(): never {\n NoTransformConfigurationError(\"json.schema\");\n}\n\n/**\n * Generates JSON schemas for multiple types.\n *\n * @danger You must configure the generic argument `Types`\n */\nexport function schemas(): never;\n\n/**\n * Generates JSON schemas for multiple types.\n *\n * Creates {@link IJsonSchemaCollection} containing schemas for all types in the\n * tuple. Named types are stored in `components` for `$ref` referencing.\n *\n * Specify OpenAPI version via `Version` generic (`\"3.0\"` or `\"3.1\"`). Default\n * is `\"3.1\"`. Key difference: `\"3.1\"` supports tuple types.\n *\n * @template Types Tuple of target types\n * @template Version OpenAPI version (`\"3.0\"` | `\"3.1\"`). Default `\"3.1\"`\n * @returns JSON schema collection\n */\nexport function schemas<\n Types extends unknown[],\n Version extends \"3.0\" | \"3.1\" = \"3.1\",\n>(): IJsonSchemaCollection<Version, Types>;\n\n/** @internal */\nexport function schemas(): never {\n NoTransformConfigurationError(\"json.schemas\");\n}\n\n/**\n * Generates JSON function schema application.\n *\n * @danger You must configure the generic argument `Class`\n */\nexport function application(): never;\n\n/**\n * Generates JSON function schema application from class/interface.\n *\n * Creates {@link IJsonSchemaApplication} from a TypeScript class or interface,\n * generating JSON schemas for all methods, parameters, and return types.\n * Designed for building custom LLM function calling schemas.\n *\n * The returned object contains:\n *\n * - `functions`: Array of function metadata with parameter/return schemas\n * - `components`: Shared schema components for `$ref` referencing\n *\n * Use cases:\n *\n * - Custom LLM function calling schema formats\n * - API documentation or code generation tools\n * - Alternative LLM integrations that need full JSON Schema\n *\n * For standard LLM function calling, use {@link llm.application} instead, which\n * builds the LLM-optimized function schema directly.\n *\n * @template Class Target class or interface type\n * @template Version OpenAPI version (`\"3.0\"` | `\"3.1\"`). Default `\"3.1\"`\n * @returns JSON function schema application\n */\nexport function application<\n Class extends object,\n Version extends \"3.0\" | \"3.1\" = \"3.1\",\n>(): IJsonSchemaApplication<Version, Class>;\n\n/** @internal */\nexport function application(): never {\n NoTransformConfigurationError(\"json.application\");\n}\n\n/* -----------------------------------------------------------\n PARSE\n----------------------------------------------------------- */\n/**\n * Parses JSON string with assertion.\n *\n * @danger You must configure the generic argument `T`\n */\nexport function assertParse(\n input: string,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): never;\n\n/**\n * Parses JSON string with assertion.\n *\n * Combines `JSON.parse()` with {@link assert}. Throws {@link TypeGuardError} when\n * parsed value doesn't match type `T`.\n *\n * Related functions:\n *\n * - {@link isParse} — Returns `null` instead of throwing\n * - {@link validateParse} — Returns detailed validation errors\n *\n * @template T Target type for parsed value\n * @param input JSON string to parse\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns Parsed value of type `T`\n * @throws {TypeGuardError} When parsed value doesn't conform to type `T`\n */\nexport function assertParse<T>(\n input: string,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): Primitive<T>;\n\n/** @internal */\nexport function assertParse<T>(): Primitive<T> {\n NoTransformConfigurationError(\"json.assertParse\");\n}\n\n/**\n * Parses JSON string with type checking.\n *\n * @danger You must configure the generic argument `T`\n */\nexport function isParse(input: string): never;\n\n/**\n * Parses JSON string with type checking.\n *\n * Combines `JSON.parse()` with {@link is}. Returns `null` when parsed value\n * doesn't match type `T`.\n *\n * Related functions:\n *\n * - {@link assertParse} — Throws instead of returning `null`\n * - {@link validateParse} — Returns detailed validation errors\n *\n * @template T Target type for parsed value\n * @param input JSON string to parse\n * @returns Parsed value of type `T`, or `null` if invalid\n */\nexport function isParse<T>(input: string): Primitive<T> | null;\n\n/** @internal */\nexport function isParse<T>(): Primitive<T> | null {\n NoTransformConfigurationError(\"json.isParse\");\n}\n\n/**\n * Parses JSON string with validation.\n *\n * @danger You must configure the generic argument `T`\n */\nexport function validateParse(input: string): never;\n\n/**\n * Parses JSON string with validation.\n *\n * Combines `JSON.parse()` with {@link validate}. Returns\n * {@link IValidation.IFailure} with all errors on mismatch, or\n * {@link IValidation.ISuccess} with parsed value.\n *\n * Related functions:\n *\n * - {@link assertParse} — Throws on first error\n * - {@link isParse} — Returns `null` instead of error details\n *\n * @template T Target type for parsed value\n * @param input JSON string to parse\n * @returns Validation result containing parsed value or errors\n */\nexport function validateParse<T>(input: string): IValidation<Primitive<T>>;\n\n/** @internal */\nexport function validateParse<T>(): IValidation<Primitive<T>> {\n NoTransformConfigurationError(\"json.validateParse\");\n}\n\n/* -----------------------------------------------------------\n STRINGIFY\n----------------------------------------------------------- */\n/**\n * Converts value to JSON string (8x faster).\n *\n * Generates optimized JSON conversion code specific to type `T`, achieving ~8x\n * faster performance than native `JSON.stringify()`.\n *\n * Does not validate the input. For validation, use:\n *\n * - {@link assertStringify} — Throws on type mismatch\n * - {@link isStringify} — Returns `null` on type mismatch\n * - {@link validateStringify} — Returns detailed validation errors\n *\n * @template T Type of input value\n * @param input Value to stringify\n * @returns JSON string\n */\nexport function stringify<T>(input: T): string;\n\n/** @internal */\nexport function stringify(): never {\n NoTransformConfigurationError(\"json.stringify\");\n}\n\n/**\n * Converts value to JSON string with assertion (5x faster).\n *\n * Combines {@link assert} with {@link stringify}. Throws {@link TypeGuardError}\n * when input doesn't match type `T`. Achieves ~5x faster performance than\n * native `JSON.stringify()`.\n *\n * Related functions:\n *\n * - {@link stringify} — No validation\n * - {@link isStringify} — Returns `null` instead of throwing\n * - {@link validateStringify} — Returns detailed validation errors\n *\n * @template T Type of input value\n * @param input Value to assert and stringify\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns JSON string\n * @throws {TypeGuardError} When input doesn't conform to type `T`\n */\nexport function assertStringify<T>(\n input: T,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): string;\n\n/**\n * Converts value to JSON string with assertion (5x faster).\n *\n * Combines {@link assert} with {@link stringify}. Throws {@link TypeGuardError}\n * when input doesn't match type `T`. Achieves ~5x faster performance than\n * native `JSON.stringify()`.\n *\n * Related functions:\n *\n * - {@link stringify} — No validation\n * - {@link isStringify} — Returns `null` instead of throwing\n * - {@link validateStringify} — Returns detailed validation errors\n *\n * @template T Type of input value\n * @param input Value to assert and stringify\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns JSON string\n * @throws {TypeGuardError} When input doesn't conform to type `T`\n */\nexport function assertStringify<T>(\n input: T,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): unknown;\n\n/** @internal */\nexport function assertStringify(): string {\n NoTransformConfigurationError(\"json.assertStringify\");\n}\n\n/**\n * Converts value to JSON string with type checking (7x faster).\n *\n * Combines {@link is} with {@link stringify}. Returns `null` when input doesn't\n * match type `T`. Achieves ~7x faster performance than native\n * `JSON.stringify()`.\n *\n * Related functions:\n *\n * - {@link stringify} — No validation\n * - {@link assertStringify} — Throws instead of returning `null`\n * - {@link validateStringify} — Returns detailed validation errors\n *\n * @template T Type of input value\n * @param input Value to check and stringify\n * @returns JSON string, or `null` if type check fails\n */\nexport function isStringify<T>(input: T): string | null;\n\n/**\n * Converts value to JSON string with type checking (7x faster).\n *\n * Combines {@link is} with {@link stringify}. Returns `null` when input doesn't\n * match type `T`. Achieves ~7x faster performance than native\n * `JSON.stringify()`.\n *\n * Related functions:\n *\n * - {@link stringify} — No validation\n * - {@link assertStringify} — Throws instead of returning `null`\n * - {@link validateStringify} — Returns detailed validation errors\n *\n * @template T Type of input value\n * @param input Value to check and stringify\n * @returns JSON string, or `null` if type check fails\n */\nexport function isStringify<T>(input: unknown): string | null;\n\n/** @internal */\nexport function isStringify(): string | null {\n NoTransformConfigurationError(\"json.isStringify\");\n}\n\n/**\n * Converts value to JSON string with validation (5x faster).\n *\n * Combines {@link validate} with {@link stringify}. Returns\n * {@link IValidation.IFailure} with all errors on mismatch, or\n * {@link IValidation.ISuccess} with JSON string. Achieves ~5x faster performance\n * than native `JSON.stringify()`.\n *\n * Related functions:\n *\n * - {@link stringify} — No validation\n * - {@link assertStringify} — Throws on first error\n * - {@link isStringify} — Returns `null` instead of error details\n *\n * @template T Type of input value\n * @param input Value to validate and stringify\n * @returns Validation result containing JSON string or errors\n */\nexport function validateStringify<T>(input: T): IValidation<string>;\n\n/**\n * Converts value to JSON string with validation (5x faster).\n *\n * Combines {@link validate} with {@link stringify}. Returns\n * {@link IValidation.IFailure} with all errors on mismatch, or\n * {@link IValidation.ISuccess} with JSON string. Achieves ~5x faster performance\n * than native `JSON.stringify()`.\n *\n * Related functions:\n *\n * - {@link stringify} — No validation\n * - {@link assertStringify} — Throws on first error\n * - {@link isStringify} — Returns `null` instead of error details\n *\n * @template T Type of input value\n * @param input Value to validate and stringify\n * @returns Validation result containing JSON string or errors\n */\nexport function validateStringify<T>(input: unknown): IValidation<string>;\n\n/** @internal */\nexport function validateStringify(): IValidation<string> {\n NoTransformConfigurationError(\"json.validateStringify\");\n}\n\n/* -----------------------------------------------------------\n FACTORY FUNCTIONS\n----------------------------------------------------------- */\n/**\n * Creates reusable {@link isParse} function.\n *\n * @danger You must configure the generic argument `T`\n */\nexport function createIsParse(): never;\n\n/**\n * Creates reusable {@link isParse} function.\n *\n * @template T Target type for parsed value\n * @returns Reusable parser function\n */\nexport function createIsParse<T>(): (input: string) => Primitive<T> | null;\n\n/** @internal */\nexport function createIsParse<T>(): (input: string) => Primitive<T> | null {\n NoTransformConfigurationError(\"json.createIsParse\");\n}\n\n/**\n * Creates reusable {@link assertParse} function.\n *\n * @danger You must configure the generic argument `T`\n */\nexport function createAssertParse(\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): never;\n\n/**\n * Creates reusable {@link assertParse} function.\n *\n * @template T Target type for parsed value\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns Reusable parser function\n */\nexport function createAssertParse<T>(\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): (\n input: string,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n) => Primitive<T>;\n\n/** @internal */\nexport function createAssertParse<T>(): (\n input: string,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n) => Primitive<T> {\n NoTransformConfigurationError(\"json.createAssertParse\");\n}\n\n/**\n * Creates reusable {@link validateParse} function.\n *\n * @danger You must configure the generic argument `T`\n */\nexport function createValidateParse(): never;\n\n/**\n * Creates reusable {@link validateParse} function.\n *\n * @template T Target type for parsed value\n * @returns Reusable parser function\n */\nexport function createValidateParse<T>(): (\n input: string,\n) => IValidation<Primitive<T>>;\n\n/** @internal */\nexport function createValidateParse<T>(): (\n input: string,\n) => IValidation<Primitive<T>> {\n NoTransformConfigurationError(\"json.createValidateParse\");\n}\n\n/**\n * Creates reusable {@link stringify} function.\n *\n * @danger You must configure the generic argument `T`\n */\nexport function createStringify(): never;\n\n/**\n * Creates reusable {@link stringify} function.\n *\n * @template T Type of input value\n * @returns Reusable stringify function\n */\nexport function createStringify<T>(): (input: T) => string;\n\n/** @internal */\nexport function createStringify<T>(): (input: T) => string {\n NoTransformConfigurationError(\"json.createStringify\");\n}\n\n/**\n * Creates reusable {@link assertStringify} function.\n *\n * @danger You must configure the generic argument `T`\n */\nexport function createAssertStringify(\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): never;\n\n/**\n * Creates reusable {@link assertStringify} function.\n *\n * @template T Type of input value\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns Reusable stringify function\n */\nexport function createAssertStringify<T>(\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): (\n input: unknown,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n) => string;\n\n/** @internal */\nexport function createAssertStringify(): (\n input: unknown,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n) => string {\n NoTransformConfigurationError(\"json.createAssertStringify\");\n}\n\n/**\n * Creates reusable {@link isStringify} function.\n *\n * @danger You must configure the generic argument `T`\n */\nexport function createIsStringify(): never;\n\n/**\n * Creates reusable {@link isStringify} function.\n *\n * @template T Type of input value\n * @returns Reusable stringify function\n */\nexport function createIsStringify<T>(): (input: unknown) => string | null;\n\n/** @internal */\nexport function createIsStringify(): (input: unknown) => string | null {\n NoTransformConfigurationError(\"json.createIsStringify\");\n}\n\n/**\n * Creates reusable {@link validateStringify} function.\n *\n * @danger You must configure the generic argument `T`\n */\nexport function createValidateStringify(): never;\n\n/**\n * Creates reusable {@link validateStringify} function.\n *\n * @template T Type of input value\n * @returns Reusable stringify function\n */\nexport function createValidateStringify<T>(): (\n input: unknown,\n) => IValidation<string>;\n\n/** @internal */\nexport function createValidateStringify(): (\n input: unknown,\n) => IValidation<string> {\n NoTransformConfigurationError(\"json.createValidateStringify\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA8CA,SAAgB,SAAgB;CAC9B,8BAA8B,aAAa;AAC7C;;AA4BA,SAAgB,UAAiB;CAC/B,8BAA8B,cAAc;AAC9C;;AAwCA,SAAgB,cAAqB;CACnC,8BAA8B,kBAAkB;AAClD;;AAuCA,SAAgB,cAA+B;CAC7C,8BAA8B,kBAAkB;AAClD;;AA2BA,SAAgB,UAAkC;CAChD,8BAA8B,cAAc;AAC9C;;AA4BA,SAAgB,gBAA8C;CAC5D,8BAA8B,oBAAoB;AACpD;;AAwBA,SAAgB,YAAmB;CACjC,8BAA8B,gBAAgB;AAChD;;AAqDA,SAAgB,kBAA0B;CACxC,8BAA8B,sBAAsB;AACtD;;AAyCA,SAAgB,cAA6B;CAC3C,8BAA8B,kBAAkB;AAClD;;AA2CA,SAAgB,oBAAyC;CACvD,8BAA8B,wBAAwB;AACxD;;AAqBA,SAAgB,gBAA2D;CACzE,8BAA8B,oBAAoB;AACpD;;AA2BA,SAAgB,oBAGE;CAChB,8BAA8B,wBAAwB;AACxD;;AAoBA,SAAgB,sBAEe;CAC7B,8BAA8B,0BAA0B;AAC1D;;AAkBA,SAAgB,kBAA2C;CACzD,8BAA8B,sBAAsB;AACtD;;AA2BA,SAAgB,wBAGJ;CACV,8BAA8B,4BAA4B;AAC5D;;AAkBA,SAAgB,oBAAuD;CACrE,8BAA8B,wBAAwB;AACxD;;AAoBA,SAAgB,0BAES;CACvB,8BAA8B,8BAA8B;AAC9D"}
|