typia 14.0.0 → 14.0.1
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/internal/_createStandardSchema.d.ts +1 -2
- package/lib/internal/_createStandardSchema.js.map +1 -1
- package/lib/internal/_createStandardSchema.mjs.map +1 -1
- package/lib/module.d.ts +1 -2
- package/lib/module.js.map +1 -1
- package/lib/module.mjs.map +1 -1
- package/lib/re-exports.d.ts +1 -1
- package/lib/re-exports.js.map +1 -1
- package/native/cmd/ttsc-typia/create_assert_error_factory_arity_test.go +5 -2
- package/native/cmd/ttsc-typia/dependency_collector_virtual_scheme_test.go +52 -0
- package/native/cmd/ttsc-typia/project_dependencies_callee_argument_transform_test.go +177 -0
- package/native/cmd/ttsc-typia/project_dependencies_callee_barrel_transform_test.go +115 -0
- package/native/cmd/ttsc-typia/project_dependencies_callee_inference_transform_test.go +285 -0
- package/native/cmd/ttsc-typia/project_dependencies_callee_shape_transform_test.go +117 -0
- package/native/cmd/ttsc-typia/project_dependencies_callee_untransformed_barrel_transform_test.go +121 -0
- package/native/cmd/ttsc-typia/project_dependencies_complete_diagnostic_transform_test.go +116 -0
- package/native/cmd/ttsc-typia/project_dependencies_complete_envelope_transform_test.go +115 -0
- package/native/cmd/ttsc-typia/project_dependencies_complete_inferred_type_transform_test.go +127 -0
- package/native/cmd/ttsc-typia/project_dependencies_complete_replaced_library_transform_test.go +153 -0
- package/native/cmd/ttsc-typia/project_dependencies_complete_untouched_reprint_transform_test.go +155 -0
- package/native/cmd/ttsc-typia/project_dependencies_computed_key_transform_test.go +218 -0
- package/native/cmd/ttsc-typia/project_dependencies_custom_lib_name_transform_test.go +6 -5
- package/native/cmd/ttsc-typia/project_dependencies_enum_member_value_transform_test.go +131 -0
- package/native/cmd/ttsc-typia/project_dependencies_inferred_declaration_transform_test.go +159 -0
- package/native/cmd/ttsc-typia/project_dependencies_jsdoc_typedef_transform_test.go +134 -0
- package/native/cmd/ttsc-typia/project_dependencies_named_tuple_member_transform_test.go +123 -0
- package/native/cmd/ttsc-typia/project_dependencies_qualified_barrel_transform_test.go +141 -0
- package/native/cmd/ttsc-typia/project_dependencies_type_parameter_default_transform_test.go +127 -0
- package/native/cmd/ttsc-typia/transform.go +193 -19
- package/native/core/schemas/metadata/MetadataDependency.go +613 -30
- package/native/transform/CallExpressionTransformer.go +16 -1
- package/package.json +4 -5
- package/src/internal/_createStandardSchema.ts +1 -2
- package/src/module.ts +6 -2
- package/src/re-exports.ts +13 -0
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { StandardSchemaV1 } from "@
|
|
2
|
-
import { IValidation } from "@typia/interface";
|
|
1
|
+
import { IValidation, StandardSchemaV1 } from "@typia/interface";
|
|
3
2
|
export declare const _createStandardSchema: <T>(fn: (input: unknown) => IValidation<T>) => ((input: unknown) => IValidation<T>) & StandardSchemaV1<T, T>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_createStandardSchema.js","sourceRoot":"","sources":["../../src/internal/_createStandardSchema.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"_createStandardSchema.js","sourceRoot":"","sources":["../../src/internal/_createStandardSchema.ts"],"names":[],"mappings":";;;AAEO,MAAM,qBAAqB,GAAG,CACnC,EAAsC,EACyB,EAAE,CACjE,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE;IAChB,WAAW,EAAE;QACX,OAAO,EAAE,CAAC;QACV,MAAM,EAAE,OAAO;QACf,QAAQ,EAAE,CAAC,KAAc,EAA8B,EAAE;YACvD,MAAM,MAAM,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;YACzB,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACnB,OAAO;oBACL,KAAK,EAAE,MAAM,CAAC,IAAI;iBACyB,CAAC;YAChD,CAAC;iBAAM,CAAC;gBACN,OAAO;oBACL,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;wBACpC,OAAO,EAAE,YAAY,KAAK,CAAC,QAAQ,SAAS,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;wBACtE,IAAI,EAAE,6BAA6B,CAAC,KAAK,CAAC,IAAI,CAAC;qBAChD,CAAC,CAAC;iBACqC,CAAC;YAC7C,CAAC;QACH,CAAC;KACF;CAC+B,CAAC,CAAC;AAvBzB,QAAA,qBAAqB,GAArB,qBAAqB,CAuBI;AAEtC,MAAM,WAAW,GAAG,CAAC,KAAc,EAAU,EAAE;IAC7C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO,MAAM,CAAC;QAClC,IAAI,CAAC;YACH,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;gBAAE,OAAO,gBAAgB,CAAC;QACpD,CAAC;mBAAO,CAAC;YACP,sDAAsD;QACxD,CAAC;QACD,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,UAAU;QAAE,OAAO,YAAY,CAAC;IACrD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC,CAAC;AAEF,IAAK,eAWJ;AAXD,WAAK,eAAe;IAClB,yBAAyB;IACzB,oCAAoC;IACpC,mEAAmE;IACnE,uDAAK,CAAA;IACL,mCAAmC;IACnC,6DAAQ,CAAA;IACR,oCAAoC;IACpC,+DAAS,CAAA;IACT,gCAAgC;IAChC,+DAAS,CAAA;AACX,CAAC,EAXI,eAAe,KAAf,eAAe,QAWnB;AAED,MAAM,6BAA6B,GAAG,CACpC,IAAY,EACiC,EAAE;IAC/C,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,iBAAiB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED,MAAM,QAAQ,GAAmC,EAAE,CAAC;IACpD,IAAI,cAAc,GAAG,EAAE,CAAC;IACxB,IAAI,KAAK,GAAoB,eAAe,CAAC,KAAK,CAAC;IACnD,IAAI,KAAK,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;IAChC,OAAO,KAAK,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/B,KAAK,EAAE,CAAC;QACR,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;QAEzB,IAAI,KAAK,KAAK,eAAe,CAAC,QAAQ,EAAE,CAAC;YACvC,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;gBACjC,kBAAkB;gBAClB,QAAQ,CAAC,IAAI,CAAC;oBACZ,GAAG,EAAE,cAAc;iBACpB,CAAC,CAAC;gBACH,KAAK,GAAG,eAAe,CAAC,KAAK,CAAC;YAChC,CAAC;iBAAM,IAAI,KAAK,KAAK,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACrC,cAAc;gBACd,cAAc,IAAI,IAAI,CAAC;gBACvB,QAAQ,CAAC,IAAI,CAAC;oBACZ,GAAG,EAAE,cAAc;iBACpB,CAAC,CAAC;gBACH,KAAK,EAAE,CAAC;gBACR,KAAK,GAAG,eAAe,CAAC,KAAK,CAAC;YAChC,CAAC;iBAAM,CAAC;gBACN,cAAc,IAAI,IAAI,CAAC;YACzB,CAAC;QACH,CAAC;aAAM,IAAI,KAAK,KAAK,eAAe,CAAC,SAAS,EAAE,CAAC;YAC/C,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;gBACjB,oBAAoB;gBACpB,QAAQ,CAAC,IAAI,CAAC;oBACZ,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,cAAc,GAAG,IAAI,CAAC;iBACvC,CAAC,CAAC;gBACH,mBAAmB;gBACnB,KAAK,IAAI,CAAC,CAAC;gBACX,KAAK,GAAG,eAAe,CAAC,KAAK,CAAC;YAChC,CAAC;iBAAM,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;gBACzB,uCAAuC;gBACvC,cAAc,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;gBAC9B,KAAK,EAAE,CAAC;gBACR,cAAc,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;YAChC,CAAC;iBAAM,CAAC;gBACN,cAAc,IAAI,IAAI,CAAC;YACzB,CAAC;QACH,CAAC;aAAM,IAAI,KAAK,KAAK,eAAe,CAAC,SAAS,EAAE,CAAC;YAC/C,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;gBACjB,oBAAoB;gBACpB,QAAQ,CAAC,IAAI,CAAC;oBACZ,GAAG,EAAE,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC;iBACrC,CAAC,CAAC;gBACH,KAAK,EAAE,CAAC;gBACR,KAAK,GAAG,eAAe,CAAC,KAAK,CAAC;YAChC,CAAC;iBAAM,CAAC;gBACN,cAAc,IAAI,IAAI,CAAC;YACzB,CAAC;QACH,CAAC;QAED,IAAI,KAAK,KAAK,eAAe,CAAC,KAAK,IAAI,KAAK,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC/D,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;YAC5B,cAAc,GAAG,EAAE,CAAC;YACpB,IAAI,OAAO,KAAK,GAAG,EAAE,CAAC;gBACpB,IAAI,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;oBAC5B,sBAAsB;oBACtB,oGAAoG;oBACpG,KAAK,GAAG,eAAe,CAAC,SAAS,CAAC;oBAClC,KAAK,EAAE,CAAC;oBACR,cAAc,GAAG,GAAG,CAAC;gBACvB,CAAC;qBAAM,CAAC;oBACN,sBAAsB;oBACtB,KAAK,GAAG,eAAe,CAAC,SAAS,CAAC;gBACpC,CAAC;YACH,CAAC;iBAAM,IAAI,OAAO,KAAK,GAAG,EAAE,CAAC;gBAC3B,oBAAoB;gBACpB,KAAK,GAAG,eAAe,CAAC,QAAQ,CAAC;YACnC,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;YACnE,CAAC;QACH,CAAC;IACH,CAAC;IAED,IAAI,KAAK,KAAK,eAAe,CAAC,KAAK,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,yBAAyB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACnE,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_createStandardSchema.mjs","names":[],"sources":["../../src/internal/_createStandardSchema.ts"],"sourcesContent":["import { StandardSchemaV1 } from \"@
|
|
1
|
+
{"version":3,"file":"_createStandardSchema.mjs","names":[],"sources":["../../src/internal/_createStandardSchema.ts"],"sourcesContent":["import { IValidation, StandardSchemaV1 } from \"@typia/interface\";\n\nexport const _createStandardSchema = <T>(\n fn: (input: unknown) => IValidation<T>,\n): ((input: unknown) => IValidation<T>) & StandardSchemaV1<T, T> =>\n Object.assign(fn, {\n \"~standard\": {\n version: 1,\n vendor: \"typia\",\n validate: (input: unknown): StandardSchemaV1.Result<T> => {\n const result = fn(input);\n if (result.success) {\n return {\n value: result.data,\n } satisfies StandardSchemaV1.SuccessResult<T>;\n } else {\n return {\n issues: result.errors.map((error) => ({\n message: `expected ${error.expected}, got ${formatValue(error.value)}`,\n path: typiaPathToStandardSchemaPath(error.path),\n })),\n } satisfies StandardSchemaV1.FailureResult;\n }\n },\n },\n } satisfies StandardSchemaV1<T, T>);\n\nconst formatValue = (value: unknown): string => {\n if (typeof value === \"object\") {\n if (value === null) return \"null\";\n try {\n if (Array.isArray(value)) return \"[object Array]\";\n } catch {\n // A revoked proxy can throw even for Array.isArray().\n }\n return \"[object Object]\";\n }\n if (typeof value === \"function\") return \"[function]\";\n return String(value);\n};\n\nenum PathParserState {\n // Start of a new segment\n // When the parser is in this state,\n // the pointer must point `.` or `[` or equal to length of the path\n Start,\n // Parsing a property key (`.hoge`)\n Property,\n // Parsing a string key (`[\"fuga\"]`)\n StringKey,\n // Parsing a number key (`[42]`)\n NumberKey,\n}\n\nconst typiaPathToStandardSchemaPath = (\n path: string,\n): ReadonlyArray<StandardSchemaV1.PathSegment> => {\n if (!path.startsWith(\"$input\")) {\n throw new Error(`Invalid path: ${JSON.stringify(path)}`);\n }\n\n const segments: StandardSchemaV1.PathSegment[] = [];\n let currentSegment = \"\";\n let state: PathParserState = PathParserState.Start;\n let index = \"$input\".length - 1;\n while (index < path.length - 1) {\n index++;\n const char = path[index];\n\n if (state === PathParserState.Property) {\n if (char === \".\" || char === \"[\") {\n // End of property\n segments.push({\n key: currentSegment,\n });\n state = PathParserState.Start;\n } else if (index === path.length - 1) {\n // End of path\n currentSegment += char;\n segments.push({\n key: currentSegment,\n });\n index++;\n state = PathParserState.Start;\n } else {\n currentSegment += char;\n }\n } else if (state === PathParserState.StringKey) {\n if (char === '\"') {\n // End of string key\n segments.push({\n key: JSON.parse(currentSegment + char),\n });\n // Skip `\"` and `]`\n index += 2;\n state = PathParserState.Start;\n } else if (char === \"\\\\\") {\n // Skip the next character from parsing\n currentSegment += path[index];\n index++;\n currentSegment += path[index];\n } else {\n currentSegment += char;\n }\n } else if (state === PathParserState.NumberKey) {\n if (char === \"]\") {\n // End of number key\n segments.push({\n key: Number.parseInt(currentSegment),\n });\n index++;\n state = PathParserState.Start;\n } else {\n currentSegment += char;\n }\n }\n\n if (state === PathParserState.Start && index < path.length - 1) {\n const newChar = path[index];\n currentSegment = \"\";\n if (newChar === \"[\") {\n if (path[index + 1] === '\"') {\n // Start of string key\n // NOTE: Typia uses JSON.stringify for this kind of keys, so `'` will not used as a string delimiter\n state = PathParserState.StringKey;\n index++;\n currentSegment = '\"';\n } else {\n // Start of number key\n state = PathParserState.NumberKey;\n }\n } else if (newChar === \".\") {\n // Start of property\n state = PathParserState.Property;\n } else {\n throw new Error(\"Unreachable: pointer points invalid character\");\n }\n }\n }\n\n if (state !== PathParserState.Start) {\n throw new Error(`Failed to parse path: ${JSON.stringify(path)}`);\n }\n\n return segments;\n};\n"],"mappings":";AAEA,MAAa,yBACX,OAEA,OAAO,OAAO,IAAI,EAChB,aAAa;CACX,SAAS;CACT,QAAQ;CACR,WAAW,UAA+C;EACxD,MAAM,SAAS,GAAG,KAAK;EACvB,IAAI,OAAO,SACT,OAAO,EACL,OAAO,OAAO,KAChB;OAEA,OAAO,EACL,QAAQ,OAAO,OAAO,KAAK,WAAW;GACpC,SAAS,YAAY,MAAM,SAAS,QAAQ,YAAY,MAAM,KAAK;GACnE,MAAM,8BAA8B,MAAM,IAAI;EAChD,EAAE,EACJ;CAEJ;AACF,EACF,CAAkC;AAEpC,MAAM,eAAe,UAA2B;CAC9C,IAAI,OAAO,UAAU,UAAU;EAC7B,IAAI,UAAU,MAAM,OAAO;EAC3B,IAAI;GACF,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO;EACnC,QAAQ,CAER;EACA,OAAO;CACT;CACA,IAAI,OAAO,UAAU,YAAY,OAAO;CACxC,OAAO,OAAO,KAAK;AACrB;AAeA,MAAM,iCACJ,SACgD;CAChD,IAAI,CAAC,KAAK,WAAW,QAAQ,GAC3B,MAAM,IAAI,MAAM,iBAAiB,KAAK,UAAU,IAAI,GAAG;CAGzD,MAAM,WAA2C,CAAC;CAClD,IAAI,iBAAiB;CACrB,IAAI,QAAA;CACJ,IAAI,QAAQ;CACZ,OAAO,QAAQ,KAAK,SAAS,GAAG;EAC9B;EACA,MAAM,OAAO,KAAK;EAElB,IAAI,UAAA,GACF,IAAI,SAAS,OAAO,SAAS,KAAK;GAEhC,SAAS,KAAK,EACZ,KAAK,eACP,CAAC;GACD,QAAA;EACF,OAAO,IAAI,UAAU,KAAK,SAAS,GAAG;GAEpC,kBAAkB;GAClB,SAAS,KAAK,EACZ,KAAK,eACP,CAAC;GACD;GACA,QAAA;EACF,OACE,kBAAkB;OAEf,IAAI,UAAA,GACT,IAAI,SAAS,MAAK;GAEhB,SAAS,KAAK,EACZ,KAAK,KAAK,MAAM,iBAAiB,IAAI,EACvC,CAAC;GAED,SAAS;GACT,QAAA;EACF,OAAO,IAAI,SAAS,MAAM;GAExB,kBAAkB,KAAK;GACvB;GACA,kBAAkB,KAAK;EACzB,OACE,kBAAkB;OAEf,IAAI,UAAA,GACT,IAAI,SAAS,KAAK;GAEhB,SAAS,KAAK,EACZ,KAAK,OAAO,SAAS,cAAc,EACrC,CAAC;GACD;GACA,QAAA;EACF,OACE,kBAAkB;EAItB,IAAI,UAAA,KAAmC,QAAQ,KAAK,SAAS,GAAG;GAC9D,MAAM,UAAU,KAAK;GACrB,iBAAiB;GACjB,IAAI,YAAY,KACd,IAAI,KAAK,QAAQ,OAAO,MAAK;IAG3B,QAAA;IACA;IACA,iBAAiB;GACnB,OAEE,QAAA;QAEG,IAAI,YAAY,KAErB,QAAA;QAEA,MAAM,IAAI,MAAM,+CAA+C;EAEnE;CACF;CAEA,IAAI,UAAA,GACF,MAAM,IAAI,MAAM,yBAAyB,KAAK,UAAU,IAAI,GAAG;CAGjE,OAAO;AACT"}
|
package/lib/module.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { StandardSchemaV1 } from "@
|
|
2
|
-
import { IRandomGenerator, IValidation, Resolved } from "@typia/interface";
|
|
1
|
+
import { IRandomGenerator, IValidation, Resolved, StandardSchemaV1 } from "@typia/interface";
|
|
3
2
|
import { TypeGuardError } from "./TypeGuardError";
|
|
4
3
|
export * as compare from "./compare";
|
|
5
4
|
export * as functional from "./functional";
|
package/lib/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.js","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,gGAA6F;AAE7F,QAAY,OAAO,sCAAkB;AACrC,QAAY,UAAU,yCAAqB;AAC3C,QAAY,IAAI,mCAAe;AAC/B,QAAY,GAAG,kCAAc;AAC7B,QAAY,IAAI,mCAAe;AAC/B,QAAY,KAAK,oCAAgB;AACjC,QAAY,SAAS,wCAAoB;AACzC,QAAY,QAAQ,uCAAmB;AACvC,QAAY,OAAO,sCAAkB;AAErC,mDAAiC;AAEjC,+CAA6B;AA+D7B,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,QAAQ,CAAC,CAAC;AAC1C,CAAC;AA4DD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,aAAa,CAAC,CAAC;AAC/C,CAAC;AA0CD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,IAAI,CAAC,CAAC;AACtC,CAAC;AAgED,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,SAAS,CAAC,CAAC;AAC3C,CAAC;AAoDD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,UAAU,CAAC,CAAC;AAC5C,CAAC;AAyDD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,cAAc,CAAC,CAAC;AAChD,CAAC;AAoDD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,mBAAmB,CAAC,CAAC;AACrD,CAAC;AAwCD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,QAAQ,CAAC,CAAC;AAC1C,CAAC;AAkDD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,gBAAgB,CAAC,CAAC;AAClD,CAAC;AAgCD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,QAAQ,CAAC,CAAC;AAC1C,CAAC;AAwCD,gBAAgB;AAChB;IAIE,IAAA,6DAA6B,EAAC,cAAc,CAAC,CAAC;AAChD,CAAC;AA+CD,gBAAgB;AAChB;IAIE,IAAA,6DAA6B,EAAC,mBAAmB,CAAC,CAAC;AACrD,CAAC;AAyBD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,UAAU,CAAC,CAAC;AAC5C,CAAC;AA+BD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,eAAe,CAAC,CAAC;AACjD,CAAC;AA4BD,gBAAgB;AAChB;IAEE,IAAA,6DAA6B,EAAC,gBAAgB,CAAC,CAAC;AAClD,CAAC;AAsCD,gBAAgB;AAChB;IAIE,IAAA,6DAA6B,EAAC,oBAAoB,CAAC,CAAC;AACtD,CAAC;AA+CD,gBAAgB;AAChB;IAIE,IAAA,6DAA6B,EAAC,yBAAyB,CAAC,CAAC;AAC3D,CAAC;AAyBD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,cAAc,CAAC,CAAC;AAChD,CAAC;AA8BD,gBAAgB;AAChB;IAEE,IAAA,6DAA6B,EAAC,sBAAsB,CAAC,CAAC;AACxD,CAAC;AA6BD,gBAAgB;AAChB;IACE,IAAA,6DAA6B,EAAC,cAAc,CAAC,CAAC;AAChD,CAAC"}
|
package/lib/module.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.mjs","names":[],"sources":["../src/module.ts"],"sourcesContent":["import { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport { IRandomGenerator, IValidation, Resolved } from \"@typia/interface\";\n\nimport { TypeGuardError } from \"./TypeGuardError\";\nimport { NoTransformConfigurationError } from \"./transformers/NoTransformConfigurationError\";\n\nexport * as compare from \"./compare\";\nexport * as functional from \"./functional\";\nexport * as http from \"./http\";\nexport * as llm from \"./llm\";\nexport * as json from \"./json\";\nexport * as plain from \"./plain\";\nexport * as notations from \"./notations\";\nexport * as protobuf from \"./protobuf\";\nexport * as reflect from \"./reflect\";\n\nexport * from \"./TypeGuardError\";\n\nexport * from \"./re-exports\";\n\n/* -----------------------------------------------------------\n BASIC VALIDATORS\n----------------------------------------------------------- */\n/**\n * Asserts type `T`.\n *\n * Performs runtime type checking against compile-time type `T`. Stops at first\n * mismatch and throws {@link TypeGuardError} containing:\n *\n * - `path`: Property path where error occurred (e.g., `\"input.user.age\"`)\n * - `expected`: Expected type string (e.g., `\"number & ExclusiveMinimum<19>\"`)\n * - `value`: Actual value that failed validation\n *\n * Related functions:\n *\n * - {@link is} — Returns `boolean` instead of throwing\n * - {@link validate} — Collects all errors instead of stopping at first\n * - {@link assertGuard} — Type guard with no return value (narrows type only)\n * - {@link assertEquals} — Also rejects properties not defined in `T`\n *\n * @template T Target type to validate against\n * @param input Value to assert\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns The input value typed as `T`\n * @throws {TypeGuardError} When input doesn't conform to type `T`\n */\nexport function assert<T>(\n input: T,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): T;\n\n/**\n * Asserts type `T`.\n *\n * Performs runtime type checking against compile-time type `T`. Stops at first\n * mismatch and throws {@link TypeGuardError} containing:\n *\n * - `path`: Property path where error occurred (e.g., `\"input.user.age\"`)\n * - `expected`: Expected type string (e.g., `\"number & ExclusiveMinimum<19>\"`)\n * - `value`: Actual value that failed validation\n *\n * Related functions:\n *\n * - {@link is} — Returns `boolean` instead of throwing\n * - {@link validate} — Collects all errors instead of stopping at first\n * - {@link assertGuard} — Type guard with no return value (narrows type only)\n * - {@link assertEquals} — Also rejects properties not defined in `T`\n *\n * @template T Target type to validate against\n * @param input Value to assert\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns The input value typed as `T`\n * @throws {TypeGuardError} When input doesn't conform to type `T`\n */\nexport function assert<T>(\n input: unknown,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): T;\n\n/** @internal */\nexport function assert(): never {\n NoTransformConfigurationError(\"assert\");\n}\n\n/**\n * Asserts type `T` as assertion guard.\n *\n * Unlike {@link assert}, returns nothing (`asserts input is T`). After this\n * call, TypeScript narrows `input` to type `T` in subsequent code. Useful when\n * you need type narrowing with runtime validation but don't need the return\n * value.\n *\n * Throws {@link TypeGuardError} on first mismatch with `path`, `expected`, and\n * `value`.\n *\n * Related functions:\n *\n * - {@link assert} — Same validation but returns the input value\n * - {@link is} — Returns `boolean` instead of throwing\n * - {@link validate} — Collects all errors instead of throwing\n * - {@link assertGuardEquals} — Also rejects properties not defined in `T`\n *\n * @template T Target type to validate against\n * @param input Value to assert (narrowed to `T` after call)\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @throws {TypeGuardError} When input doesn't conform to type `T`\n */\nexport function assertGuard<T>(\n input: T,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): asserts input is T;\n\n/**\n * Asserts type `T` as assertion guard.\n *\n * Unlike {@link assert}, returns nothing (`asserts input is T`). After this\n * call, TypeScript narrows `input` to type `T` in subsequent code. Useful when\n * you need type narrowing with runtime validation but don't need the return\n * value.\n *\n * Throws {@link TypeGuardError} on first mismatch with `path`, `expected`, and\n * `value`.\n *\n * Related functions:\n *\n * - {@link assert} — Same validation but returns the input value\n * - {@link is} — Returns `boolean` instead of throwing\n * - {@link validate} — Collects all errors instead of throwing\n * - {@link assertGuardEquals} — Also rejects properties not defined in `T`\n *\n * @template T Target type to validate against\n * @param input Value to assert (narrowed to `T` after call)\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @throws {TypeGuardError} When input doesn't conform to type `T`\n */\nexport function assertGuard<T>(\n input: unknown,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): asserts input is T;\n\n/** @internal */\nexport function assertGuard(): never {\n NoTransformConfigurationError(\"assertGuard\");\n}\n\n/**\n * Tests type `T`.\n *\n * Performs runtime type checking without throwing exceptions. Acts as\n * TypeScript type guard, narrowing the input type in conditional branches when\n * result is `true`.\n *\n * Related functions:\n *\n * - {@link assert} — Throws {@link TypeGuardError} with detailed error info on\n * mismatch\n * - {@link validate} — Returns all errors without throwing\n * - {@link equals} — Also rejects properties not defined in `T`\n *\n * @template T Target type to check\n * @param input Value to test\n * @returns `true` if valid, `false` otherwise (type predicate `input is T`)\n */\nexport function is<T>(input: T): input is T;\n\n/**\n * Tests type `T`.\n *\n * Performs runtime type checking without throwing exceptions. Acts as\n * TypeScript type guard, narrowing the input type in conditional branches when\n * result is `true`.\n *\n * Related functions:\n *\n * - {@link assert} — Throws {@link TypeGuardError} with detailed error info on\n * mismatch\n * - {@link validate} — Returns all errors without throwing\n * - {@link equals} — Also rejects properties not defined in `T`\n *\n * @template T Target type to check\n * @param input Value to test\n * @returns `true` if valid, `false` otherwise (type predicate `input is T`)\n */\nexport function is<T>(input: unknown): input is T;\n\n/** @internal */\nexport function is(): never {\n NoTransformConfigurationError(\"is\");\n}\n\n/**\n * Tests type `T` up to a limited depth.\n *\n * Like {@link is}, but only descends into nested objects, arrays, and tuples\n * until the depth budget `N` is exhausted; beyond that point a value is\n * accepted as long as it is an `object` (or `null` where the type permits).\n * Useful for **discrimination** rather than full validation — when you only\n * need to know which branch of a union an input belongs to, paying for a deep\n * structural check of every leaf is wasteful.\n *\n * Because the check is shallow past depth `N`, a `true` result is **not** a\n * guarantee that the whole value conforms to `T`. The name `shallow` reflects\n * this: only the discriminating, near-surface part of the type is verified. For\n * a full guarantee, use {@link is}.\n *\n * Related functions:\n *\n * - {@link is} — Full-depth check, returns a sound type guard\n * - {@link assert} — Throws {@link TypeGuardError} with detailed error info on\n * mismatch\n * - {@link validate} — Returns all errors without throwing\n *\n * @template T Target type to check\n * @template N Maximum depth to descend before accepting a value structurally.\n * Must be a non-negative integer literal. Defaults to `2`.\n * @param input Value to test\n * @returns `true` if valid up to depth `N`, `false` otherwise (type predicate\n * `input is T`)\n */\nexport function shallow<T, N extends number = 2>(input: T): input is T;\n\n/**\n * Tests type `T` up to a limited depth.\n *\n * Like {@link is}, but only descends into nested objects, arrays, and tuples\n * until the depth budget `N` is exhausted; beyond that point a value is\n * accepted as long as it is an `object` (or `null` where the type permits).\n * Useful for **discrimination** rather than full validation — when you only\n * need to know which branch of a union an input belongs to, paying for a deep\n * structural check of every leaf is wasteful.\n *\n * Because the check is shallow past depth `N`, a `true` result is **not** a\n * guarantee that the whole value conforms to `T`. The name `shallow` reflects\n * this: only the discriminating, near-surface part of the type is verified. For\n * a full guarantee, use {@link is}.\n *\n * Related functions:\n *\n * - {@link is} — Full-depth check, returns a sound type guard\n * - {@link assert} — Throws {@link TypeGuardError} with detailed error info on\n * mismatch\n * - {@link validate} — Returns all errors without throwing\n *\n * @template T Target type to check\n * @template N Maximum depth to descend before accepting a value structurally.\n * Must be a non-negative integer literal. Defaults to `2`.\n * @param input Value to test\n * @returns `true` if valid up to depth `N`, `false` otherwise (type predicate\n * `input is T`)\n */\nexport function shallow<T, N extends number = 2>(input: unknown): input is T;\n\n/** @internal */\nexport function shallow(): never {\n NoTransformConfigurationError(\"shallow\");\n}\n\n/**\n * Validates type `T`.\n *\n * Unlike {@link assert} which throws on first error, this function continues\n * checking and collects all type mismatches into {@link IValidation.errors}\n * array. Never throws.\n *\n * Return structure:\n *\n * - `success: true` → `data` contains validated input as `T`\n * - `success: false` → `errors` array of {@link IValidation.IError} with `path`,\n * `expected`, `value`\n *\n * Related functions:\n *\n * - {@link assert} — Throws on first error instead of collecting all\n * - {@link is} — Simple boolean check\n * - {@link validateEquals} — Also rejects properties not defined in `T`\n *\n * @template T Target type to validate against\n * @param input Value to validate\n * @returns {@link IValidation} <T> containing either `data` or `errors`\n */\nexport function validate<T>(input: T): IValidation<T>;\n\n/**\n * Validates type `T`.\n *\n * Unlike {@link assert} which throws on first error, this function continues\n * checking and collects all type mismatches into {@link IValidation.errors}\n * array. Never throws.\n *\n * Return structure:\n *\n * - `success: true` → `data` contains validated input as `T`\n * - `success: false` → `errors` array of {@link IValidation.IError} with `path`,\n * `expected`, `value`\n *\n * Related functions:\n *\n * - {@link assert} — Throws on first error instead of collecting all\n * - {@link is} — Simple boolean check\n * - {@link validateEquals} — Also rejects properties not defined in `T`\n *\n * @template T Target type to validate against\n * @param input Value to validate\n * @returns {@link IValidation} <T> containing either `data` or `errors`\n */\nexport function validate<T>(input: unknown): IValidation<T>;\n\n/** @internal */\nexport function validate(): never {\n NoTransformConfigurationError(\"validate\");\n}\n\n/* -----------------------------------------------------------\n STRICT VALIDATORS\n----------------------------------------------------------- */\n/**\n * Asserts type `T` with strict equality.\n *\n * Stricter than {@link assert}: also fails when input contains any property not\n * defined in type `T`. For extra property errors, `expected` will be\n * `\"undefined\"`.\n *\n * Related functions:\n *\n * - {@link assert} — Allows extra properties\n * - {@link equals} — Boolean result without throwing\n * - {@link validateEquals} — Collects all errors without throwing\n * - {@link assertGuardEquals} — Type guard version with no return value\n *\n * @template T Target type for exact match\n * @param input Value to validate\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns The input value typed as `T`\n * @throws {TypeGuardError} When type mismatch or extra property detected\n */\nexport function assertEquals<T>(\n input: T,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): T;\n\n/**\n * Asserts type `T` with strict equality.\n *\n * Stricter than {@link assert}: also fails when input contains any property not\n * defined in type `T`. For extra property errors, `expected` will be\n * `\"undefined\"`.\n *\n * Related functions:\n *\n * - {@link assert} — Allows extra properties\n * - {@link equals} — Boolean result without throwing\n * - {@link validateEquals} — Collects all errors without throwing\n * - {@link assertGuardEquals} — Type guard version with no return value\n *\n * @template T Target type for exact match\n * @param input Value to validate\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns The input value typed as `T`\n * @throws {TypeGuardError} When type mismatch or extra property detected\n */\nexport function assertEquals<T>(\n input: unknown,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): T;\n\n/** @internal */\nexport function assertEquals(): never {\n NoTransformConfigurationError(\"assertEquals\");\n}\n\n/**\n * Asserts type `T` with strict equality as assertion guard.\n *\n * Combines {@link assertGuard} with strict equality checking. Returns nothing\n * but narrows input to type `T`. Also fails when input contains properties not\n * in `T`.\n *\n * Related functions:\n *\n * - {@link assertGuard} — Allows extra properties\n * - {@link assertEquals} — Returns value instead of type guard\n * - {@link equals} — Boolean result without throwing\n * - {@link validateEquals} — Collects all errors without throwing\n *\n * @template T Target type for exact match\n * @param input Value to assert (narrowed to `T` after call)\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @throws {TypeGuardError} When type mismatch or extra property detected\n */\nexport function assertGuardEquals<T>(\n input: T,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): asserts input is T;\n\n/**\n * Asserts type `T` with strict equality as assertion guard.\n *\n * Combines {@link assertGuard} with strict equality checking. Returns nothing\n * but narrows input to type `T`. Also fails when input contains properties not\n * in `T`.\n *\n * Related functions:\n *\n * - {@link assertGuard} — Allows extra properties\n * - {@link assertEquals} — Returns value instead of type guard\n * - {@link equals} — Boolean result without throwing\n * - {@link validateEquals} — Collects all errors without throwing\n *\n * @template T Target type for exact match\n * @param input Value to assert (narrowed to `T` after call)\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @throws {TypeGuardError} When type mismatch or extra property detected\n */\nexport function assertGuardEquals<T>(\n input: unknown,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): asserts input is T;\n\n/** @internal */\nexport function assertGuardEquals(): never {\n NoTransformConfigurationError(\"assertGuardEquals\");\n}\n\n/**\n * Tests type `T` with strict equality.\n *\n * Stricter than {@link is}: also returns `false` when input contains any\n * property not defined in type `T`. Useful for detecting unexpected data or\n * typos.\n *\n * Related functions:\n *\n * - {@link is} — Allows extra properties\n * - {@link assertEquals} — Throws with detailed error info on mismatch\n * - {@link validateEquals} — Returns all errors without throwing\n *\n * @template T Target type for exact match\n * @param input Value to test\n * @returns `true` if valid, `false` otherwise (type predicate `input is T`)\n */\nexport function equals<T>(input: T): input is T;\n\n/**\n * Tests type `T` with strict equality.\n *\n * Stricter than {@link is}: also returns `false` when input contains any\n * property not defined in type `T`. Useful for detecting unexpected data or\n * typos.\n *\n * Related functions:\n *\n * - {@link is} — Allows extra properties\n * - {@link assertEquals} — Throws with detailed error info on mismatch\n * - {@link validateEquals} — Returns all errors without throwing\n *\n * @template T Target type for exact match\n * @param input Value to test\n * @returns `true` if valid, `false` otherwise (type predicate `input is T`)\n */\nexport function equals<T>(input: unknown): input is T;\n\n/** @internal */\nexport function equals(): never {\n NoTransformConfigurationError(\"equals\");\n}\n\n/**\n * Validates type `T` with strict equality.\n *\n * Combines {@link validate} with strict equality checking. Collects all errors\n * including extra property violations into {@link IValidation.errors} array.\n *\n * Return structure:\n *\n * - `success: true` → `data` contains validated input as `T`\n * - `success: false` → `errors` array with `path`, `expected`, `value` for each\n * mismatch\n *\n * Related functions:\n *\n * - {@link validate} — Allows extra properties\n * - {@link assertEquals} — Throws on first error\n * - {@link equals} — Simple boolean check\n *\n * @template T Target type for exact match\n * @param input Value to validate\n * @returns {@link IValidation} <T> containing either `data` or `errors`\n */\nexport function validateEquals<T>(input: T): IValidation<T>;\n\n/**\n * Validates type `T` with strict equality.\n *\n * Combines {@link validate} with strict equality checking. Collects all errors\n * including extra property violations into {@link IValidation.errors} array.\n *\n * Return structure:\n *\n * - `success: true` → `data` contains validated input as `T`\n * - `success: false` → `errors` array with `path`, `expected`, `value` for each\n * mismatch\n *\n * Related functions:\n *\n * - {@link validate} — Allows extra properties\n * - {@link assertEquals} — Throws on first error\n * - {@link equals} — Simple boolean check\n *\n * @template T Target type for exact match\n * @param input Value to validate\n * @returns {@link IValidation} <T> containing either `data` or `errors`\n */\nexport function validateEquals<T>(input: unknown): IValidation<T>;\n\n/** @internal */\nexport function validateEquals(): never {\n NoTransformConfigurationError(\"validateEquals\");\n}\n\n/* -----------------------------------------------------------\n RANDOM\n----------------------------------------------------------- */\n/**\n * Generates random data of type `T`.\n *\n * Creates random instance conforming to compile-time type `T`. Generates only\n * primitive data; methods in `T` are ignored. If `T` has `toJSON()` method,\n * generates its return type instead.\n *\n * @template T Type of data to generate\n * @param generator Custom random generator implementing {@link IRandomGenerator}\n * @returns Randomly generated data as `Resolved<T>`\n * @danger You must configure the generic argument `T`\n */\nexport function random(generator?: Partial<IRandomGenerator>): never;\n\n/**\n * Generates random data of type `T`.\n *\n * Creates random instance conforming to compile-time type `T`. Generates only\n * primitive data; methods in `T` are ignored. If `T` has `toJSON()` method,\n * generates its return type instead.\n *\n * @template T Type of data to generate\n * @param generator Custom random generator implementing {@link IRandomGenerator}\n * @returns Randomly generated data as `Resolved<T>`\n */\nexport function random<T>(generator?: Partial<IRandomGenerator>): Resolved<T>;\n\n/** @internal */\nexport function random(): never {\n NoTransformConfigurationError(\"random\");\n}\n\n/* -----------------------------------------------------------\n FACTORY FUNCTIONS\n----------------------------------------------------------- */\n/**\n * Creates reusable {@link assert} function.\n *\n * Returns a function that can be called multiple times without recompilation.\n * Useful when the same type validation is needed repeatedly.\n *\n * @template T Target type to validate against\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns Reusable assert function `(input: unknown, errorFactory?) => T`\n * @danger You must configure the generic argument `T`\n */\nexport function createAssert(\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): never;\n\n/**\n * Creates reusable {@link assert} function.\n *\n * Returns a function that can be called multiple times without recompilation.\n * Useful when the same type validation is needed repeatedly.\n *\n * @template T Target type to validate against\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns Reusable assert function `(input: unknown, errorFactory?) => T`,\n * whose own `errorFactory` overrides this one for that single call\n */\nexport function createAssert<T>(\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): (\n input: unknown,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n) => T;\n\n/** @internal */\nexport function createAssert<T>(): (\n input: unknown,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n) => T {\n NoTransformConfigurationError(\"createAssert\");\n}\n\n/**\n * Creates reusable {@link assertGuard} function.\n *\n * Returns a reusable type guard assertion function.\n *\n * TypeScript requirement: You must declare the variable type explicitly. `const\n * fn: AssertionGuard<T> = createAssertGuard<T>()` — otherwise compile error.\n * That annotation is one parameter wide, so it also hides the call-time\n * `errorFactory`; annotate with `(input: unknown, errorFactory?: (props:\n * TypeGuardError.IProps) => Error) => asserts input is T` when you need it.\n *\n * @template T Target type to validate against\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns Reusable assertion guard function\n * @danger You must configure the generic argument `T`\n */\nexport function createAssertGuard(\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): never;\n\n/**\n * Creates reusable {@link assertGuard} function.\n *\n * Returns a reusable type guard assertion function.\n *\n * TypeScript requirement: You must declare the variable type explicitly. `const\n * fn: AssertionGuard<T> = createAssertGuard<T>()` — otherwise compile error.\n * That annotation is one parameter wide, so it also hides the call-time\n * `errorFactory`; annotate with `(input: unknown, errorFactory?: (props:\n * TypeGuardError.IProps) => Error) => asserts input is T` when you need it.\n *\n * @template T Target type to validate against\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns Reusable assertion guard function, whose own `errorFactory`\n * overrides this one for that single call\n */\nexport function createAssertGuard<T>(\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): (\n input: unknown,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n) => asserts input is T;\n\n/** @internal */\nexport function createAssertGuard<T>(): (\n input: unknown,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n) => asserts input is T {\n NoTransformConfigurationError(\"createAssertGuard\");\n}\n\n/**\n * Creates reusable {@link is} function.\n *\n * Returns a type guard function that can be called multiple times without\n * recompilation.\n *\n * @template T Target type to check\n * @returns Reusable type guard function `(input: unknown) => input is T`\n * @danger You must configure the generic argument `T`\n */\nexport function createIs(): never;\n\n/**\n * Creates reusable {@link is} function.\n *\n * Returns a type guard function that can be called multiple times without\n * recompilation.\n *\n * @template T Target type to check\n * @returns Reusable type guard function `(input: unknown) => input is T`\n */\nexport function createIs<T>(): (input: unknown) => input is T;\n\n/** @internal */\nexport function createIs<T>(): (input: unknown) => input is T {\n NoTransformConfigurationError(\"createIs\");\n}\n\n/**\n * Creates reusable {@link shallow} function.\n *\n * Returns a depth-limited type guard function that can be called multiple times\n * without recompilation.\n *\n * @template T Target type to check\n * @template N Maximum depth to descend before accepting a value structurally.\n * Must be a non-negative integer literal. Defaults to `2`.\n * @returns Reusable type guard function `(input: unknown) => input is T`\n * @danger You must configure the generic argument `T`\n */\nexport function createShallow(): never;\n\n/**\n * Creates reusable {@link shallow} function.\n *\n * Returns a depth-limited type guard function that can be called multiple times\n * without recompilation.\n *\n * @template T Target type to check\n * @template N Maximum depth to descend before accepting a value structurally.\n * Must be a non-negative integer literal. Defaults to `2`.\n * @returns Reusable type guard function `(input: unknown) => input is T`\n */\nexport function createShallow<T, N extends number = 2>(): (\n input: unknown,\n) => input is T;\n\n/** @internal */\nexport function createShallow<T>(): (input: unknown) => input is T {\n NoTransformConfigurationError(\"createShallow\");\n}\n\n/**\n * Creates reusable {@link validate} function.\n *\n * Returns a validation function that can be called multiple times without\n * recompilation. Also implements {@link StandardSchemaV1} interface for\n * interoperability.\n *\n * @template T Target type to validate against\n * @returns Reusable validate function `(input: unknown) => IValidation<T>`\n * @danger You must configure the generic argument `T`\n */\nexport function createValidate(): never;\n\n/**\n * Creates reusable {@link validate} function.\n *\n * Returns a validation function that can be called multiple times without\n * recompilation. Also implements {@link StandardSchemaV1} interface for\n * interoperability.\n *\n * @template T Target type to validate against\n * @returns Reusable validate function `(input: unknown) => IValidation<T>`\n */\nexport function createValidate<T>(): ((input: unknown) => IValidation<T>) &\n StandardSchemaV1<T, T>;\n\n/** @internal */\nexport function createValidate(): ((input: unknown) => IValidation) &\n StandardSchemaV1<unknown, unknown> {\n NoTransformConfigurationError(\"createValidate\");\n}\n\n/**\n * Creates reusable {@link assertEquals} function.\n *\n * Returns a strict assertion function that rejects superfluous properties. Can\n * be called multiple times without recompilation.\n *\n * @template T Target type for exact match\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns Reusable assertEquals function `(input: unknown, errorFactory?) =>\n * T`\n * @danger You must configure the generic argument `T`\n */\nexport function createAssertEquals(\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): never;\n\n/**\n * Creates reusable {@link assertEquals} function.\n *\n * Returns a strict assertion function that rejects superfluous properties. Can\n * be called multiple times without recompilation.\n *\n * @template T Target type for exact match\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns Reusable assertEquals function `(input: unknown, errorFactory?) =>\n * T`, whose own `errorFactory` overrides this one for that single call\n */\nexport function createAssertEquals<T>(\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): (\n input: unknown,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n) => T;\n\n/** @internal */\nexport function createAssertEquals<T>(): (\n input: unknown,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n) => T {\n NoTransformConfigurationError(\"createAssertEquals\");\n}\n\n/**\n * Creates reusable {@link assertGuardEquals} function.\n *\n * Returns a strict assertion guard that rejects superfluous properties.\n *\n * TypeScript requirement: You must declare the variable type explicitly. `const\n * fn: AssertionGuard<T> = createAssertGuardEquals<T>()` — otherwise compile\n * error. That annotation is one parameter wide, so it also hides the call-time\n * `errorFactory`; annotate with `(input: unknown, errorFactory?: (props:\n * TypeGuardError.IProps) => Error) => asserts input is T` when you need it.\n *\n * @template T Target type for exact match\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns Reusable assertion guard function\n * @danger You must configure the generic argument `T`\n */\nexport function createAssertGuardEquals(\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): never;\n\n/**\n * Creates reusable {@link assertGuardEquals} function.\n *\n * Returns a strict assertion guard that rejects superfluous properties.\n *\n * TypeScript requirement: You must declare the variable type explicitly. `const\n * fn: AssertionGuard<T> = createAssertGuardEquals<T>()` — otherwise compile\n * error. That annotation is one parameter wide, so it also hides the call-time\n * `errorFactory`; annotate with `(input: unknown, errorFactory?: (props:\n * TypeGuardError.IProps) => Error) => asserts input is T` when you need it.\n *\n * @template T Target type for exact match\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns Reusable assertion guard function, whose own `errorFactory`\n * overrides this one for that single call\n */\nexport function createAssertGuardEquals<T>(\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): (\n input: unknown,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n) => asserts input is T;\n\n/** @internal */\nexport function createAssertGuardEquals<T>(): (\n input: unknown,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n) => asserts input is T {\n NoTransformConfigurationError(\"createAssertGuardEquals\");\n}\n\n/**\n * Creates reusable {@link equals} function.\n *\n * Returns a strict type guard that rejects superfluous properties. Can be\n * called multiple times without recompilation.\n *\n * @template T Target type for exact match\n * @returns Reusable type guard function `(input: unknown) => input is T`\n * @danger You must configure the generic argument `T`\n */\nexport function createEquals(): never;\n\n/**\n * Creates reusable {@link equals} function.\n *\n * Returns a strict type guard that rejects superfluous properties. Can be\n * called multiple times without recompilation.\n *\n * @template T Target type for exact match\n * @returns Reusable type guard function `(input: unknown) => input is T`\n */\nexport function createEquals<T>(): (input: unknown) => input is T;\n\n/** @internal */\nexport function createEquals<T>(): (input: unknown) => input is T {\n NoTransformConfigurationError(\"createEquals\");\n}\n\n/**\n * Creates reusable {@link validateEquals} function.\n *\n * Returns a strict validation function that rejects superfluous properties.\n * Also implements {@link StandardSchemaV1} interface for interoperability.\n *\n * @template T Target type for exact match\n * @returns Reusable validateEquals function `(input: unknown) =>\n * IValidation<T>`\n * @danger You must configure the generic argument `T`\n */\nexport function createValidateEquals(): never;\n\n/**\n * Creates reusable {@link validateEquals} function.\n *\n * Returns a strict validation function that rejects superfluous properties.\n * Also implements {@link StandardSchemaV1} interface for interoperability.\n *\n * @template T Target type for exact match\n * @returns Reusable validateEquals function `(input: unknown) =>\n * IValidation<T>`\n */\nexport function createValidateEquals<T>(): ((\n input: unknown,\n) => IValidation<T>) &\n StandardSchemaV1<T, T>;\n\n/** @internal */\nexport function createValidateEquals(): ((input: unknown) => IValidation) &\n StandardSchemaV1<unknown, unknown> {\n NoTransformConfigurationError(\"createValidateEquals\");\n}\n\n/**\n * Creates reusable {@link random} function.\n *\n * Returns a random data generator that can be called multiple times without\n * recompilation.\n *\n * @template T Type of data to generate\n * @param generator Custom random generator implementing {@link IRandomGenerator}\n * @returns Reusable random function `() => Resolved<T>`\n * @danger You must configure the generic argument `T`\n */\nexport function createRandom(generator?: Partial<IRandomGenerator>): never;\n\n/**\n * Creates reusable {@link random} function.\n *\n * Returns a random data generator that can be called multiple times without\n * recompilation.\n *\n * @template T Type of data to generate\n * @param generator Custom random generator implementing {@link IRandomGenerator}\n * @returns Reusable random function `() => Resolved<T>`\n */\nexport function createRandom<T>(\n generator?: Partial<IRandomGenerator>,\n): () => Resolved<T>;\n\n/** @internal */\nexport function createRandom(): never {\n NoTransformConfigurationError(\"createRandom\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkFA,SAAgB,SAAgB;CAC9B,8BAA8B,QAAQ;AACxC;;AA6DA,SAAgB,cAAqB;CACnC,8BAA8B,aAAa;AAC7C;;AA2CA,SAAgB,KAAY;CAC1B,8BAA8B,IAAI;AACpC;;AAiEA,SAAgB,UAAiB;CAC/B,8BAA8B,SAAS;AACzC;;AAqDA,SAAgB,WAAkB;CAChC,8BAA8B,UAAU;AAC1C;;AA0DA,SAAgB,eAAsB;CACpC,8BAA8B,cAAc;AAC9C;;AAqDA,SAAgB,oBAA2B;CACzC,8BAA8B,mBAAmB;AACnD;;AAyCA,SAAgB,SAAgB;CAC9B,8BAA8B,QAAQ;AACxC;;AAmDA,SAAgB,iBAAwB;CACtC,8BAA8B,gBAAgB;AAChD;;AAiCA,SAAgB,SAAgB;CAC9B,8BAA8B,QAAQ;AACxC;;AAyCA,SAAgB,eAGT;CACL,8BAA8B,cAAc;AAC9C;;AAgDA,SAAgB,oBAGQ;CACtB,8BAA8B,mBAAmB;AACnD;;AA0BA,SAAgB,WAA8C;CAC5D,8BAA8B,UAAU;AAC1C;;AAgCA,SAAgB,gBAAmD;CACjE,8BAA8B,eAAe;AAC/C;;AA6BA,SAAgB,iBACqB;CACnC,8BAA8B,gBAAgB;AAChD;;AAuCA,SAAgB,qBAGT;CACL,8BAA8B,oBAAoB;AACpD;;AAgDA,SAAgB,0BAGQ;CACtB,8BAA8B,yBAAyB;AACzD;;AA0BA,SAAgB,eAAkD;CAChE,8BAA8B,cAAc;AAC9C;;AA+BA,SAAgB,uBACqB;CACnC,8BAA8B,sBAAsB;AACtD;;AA8BA,SAAgB,eAAsB;CACpC,8BAA8B,cAAc;AAC9C"}
|
|
1
|
+
{"version":3,"file":"module.mjs","names":[],"sources":["../src/module.ts"],"sourcesContent":["import {\n IRandomGenerator,\n IValidation,\n Resolved,\n StandardSchemaV1,\n} from \"@typia/interface\";\n\nimport { TypeGuardError } from \"./TypeGuardError\";\nimport { NoTransformConfigurationError } from \"./transformers/NoTransformConfigurationError\";\n\nexport * as compare from \"./compare\";\nexport * as functional from \"./functional\";\nexport * as http from \"./http\";\nexport * as llm from \"./llm\";\nexport * as json from \"./json\";\nexport * as plain from \"./plain\";\nexport * as notations from \"./notations\";\nexport * as protobuf from \"./protobuf\";\nexport * as reflect from \"./reflect\";\n\nexport * from \"./TypeGuardError\";\n\nexport * from \"./re-exports\";\n\n/* -----------------------------------------------------------\n BASIC VALIDATORS\n----------------------------------------------------------- */\n/**\n * Asserts type `T`.\n *\n * Performs runtime type checking against compile-time type `T`. Stops at first\n * mismatch and throws {@link TypeGuardError} containing:\n *\n * - `path`: Property path where error occurred (e.g., `\"input.user.age\"`)\n * - `expected`: Expected type string (e.g., `\"number & ExclusiveMinimum<19>\"`)\n * - `value`: Actual value that failed validation\n *\n * Related functions:\n *\n * - {@link is} — Returns `boolean` instead of throwing\n * - {@link validate} — Collects all errors instead of stopping at first\n * - {@link assertGuard} — Type guard with no return value (narrows type only)\n * - {@link assertEquals} — Also rejects properties not defined in `T`\n *\n * @template T Target type to validate against\n * @param input Value to assert\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns The input value typed as `T`\n * @throws {TypeGuardError} When input doesn't conform to type `T`\n */\nexport function assert<T>(\n input: T,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): T;\n\n/**\n * Asserts type `T`.\n *\n * Performs runtime type checking against compile-time type `T`. Stops at first\n * mismatch and throws {@link TypeGuardError} containing:\n *\n * - `path`: Property path where error occurred (e.g., `\"input.user.age\"`)\n * - `expected`: Expected type string (e.g., `\"number & ExclusiveMinimum<19>\"`)\n * - `value`: Actual value that failed validation\n *\n * Related functions:\n *\n * - {@link is} — Returns `boolean` instead of throwing\n * - {@link validate} — Collects all errors instead of stopping at first\n * - {@link assertGuard} — Type guard with no return value (narrows type only)\n * - {@link assertEquals} — Also rejects properties not defined in `T`\n *\n * @template T Target type to validate against\n * @param input Value to assert\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns The input value typed as `T`\n * @throws {TypeGuardError} When input doesn't conform to type `T`\n */\nexport function assert<T>(\n input: unknown,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): T;\n\n/** @internal */\nexport function assert(): never {\n NoTransformConfigurationError(\"assert\");\n}\n\n/**\n * Asserts type `T` as assertion guard.\n *\n * Unlike {@link assert}, returns nothing (`asserts input is T`). After this\n * call, TypeScript narrows `input` to type `T` in subsequent code. Useful when\n * you need type narrowing with runtime validation but don't need the return\n * value.\n *\n * Throws {@link TypeGuardError} on first mismatch with `path`, `expected`, and\n * `value`.\n *\n * Related functions:\n *\n * - {@link assert} — Same validation but returns the input value\n * - {@link is} — Returns `boolean` instead of throwing\n * - {@link validate} — Collects all errors instead of throwing\n * - {@link assertGuardEquals} — Also rejects properties not defined in `T`\n *\n * @template T Target type to validate against\n * @param input Value to assert (narrowed to `T` after call)\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @throws {TypeGuardError} When input doesn't conform to type `T`\n */\nexport function assertGuard<T>(\n input: T,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): asserts input is T;\n\n/**\n * Asserts type `T` as assertion guard.\n *\n * Unlike {@link assert}, returns nothing (`asserts input is T`). After this\n * call, TypeScript narrows `input` to type `T` in subsequent code. Useful when\n * you need type narrowing with runtime validation but don't need the return\n * value.\n *\n * Throws {@link TypeGuardError} on first mismatch with `path`, `expected`, and\n * `value`.\n *\n * Related functions:\n *\n * - {@link assert} — Same validation but returns the input value\n * - {@link is} — Returns `boolean` instead of throwing\n * - {@link validate} — Collects all errors instead of throwing\n * - {@link assertGuardEquals} — Also rejects properties not defined in `T`\n *\n * @template T Target type to validate against\n * @param input Value to assert (narrowed to `T` after call)\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @throws {TypeGuardError} When input doesn't conform to type `T`\n */\nexport function assertGuard<T>(\n input: unknown,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): asserts input is T;\n\n/** @internal */\nexport function assertGuard(): never {\n NoTransformConfigurationError(\"assertGuard\");\n}\n\n/**\n * Tests type `T`.\n *\n * Performs runtime type checking without throwing exceptions. Acts as\n * TypeScript type guard, narrowing the input type in conditional branches when\n * result is `true`.\n *\n * Related functions:\n *\n * - {@link assert} — Throws {@link TypeGuardError} with detailed error info on\n * mismatch\n * - {@link validate} — Returns all errors without throwing\n * - {@link equals} — Also rejects properties not defined in `T`\n *\n * @template T Target type to check\n * @param input Value to test\n * @returns `true` if valid, `false` otherwise (type predicate `input is T`)\n */\nexport function is<T>(input: T): input is T;\n\n/**\n * Tests type `T`.\n *\n * Performs runtime type checking without throwing exceptions. Acts as\n * TypeScript type guard, narrowing the input type in conditional branches when\n * result is `true`.\n *\n * Related functions:\n *\n * - {@link assert} — Throws {@link TypeGuardError} with detailed error info on\n * mismatch\n * - {@link validate} — Returns all errors without throwing\n * - {@link equals} — Also rejects properties not defined in `T`\n *\n * @template T Target type to check\n * @param input Value to test\n * @returns `true` if valid, `false` otherwise (type predicate `input is T`)\n */\nexport function is<T>(input: unknown): input is T;\n\n/** @internal */\nexport function is(): never {\n NoTransformConfigurationError(\"is\");\n}\n\n/**\n * Tests type `T` up to a limited depth.\n *\n * Like {@link is}, but only descends into nested objects, arrays, and tuples\n * until the depth budget `N` is exhausted; beyond that point a value is\n * accepted as long as it is an `object` (or `null` where the type permits).\n * Useful for **discrimination** rather than full validation — when you only\n * need to know which branch of a union an input belongs to, paying for a deep\n * structural check of every leaf is wasteful.\n *\n * Because the check is shallow past depth `N`, a `true` result is **not** a\n * guarantee that the whole value conforms to `T`. The name `shallow` reflects\n * this: only the discriminating, near-surface part of the type is verified. For\n * a full guarantee, use {@link is}.\n *\n * Related functions:\n *\n * - {@link is} — Full-depth check, returns a sound type guard\n * - {@link assert} — Throws {@link TypeGuardError} with detailed error info on\n * mismatch\n * - {@link validate} — Returns all errors without throwing\n *\n * @template T Target type to check\n * @template N Maximum depth to descend before accepting a value structurally.\n * Must be a non-negative integer literal. Defaults to `2`.\n * @param input Value to test\n * @returns `true` if valid up to depth `N`, `false` otherwise (type predicate\n * `input is T`)\n */\nexport function shallow<T, N extends number = 2>(input: T): input is T;\n\n/**\n * Tests type `T` up to a limited depth.\n *\n * Like {@link is}, but only descends into nested objects, arrays, and tuples\n * until the depth budget `N` is exhausted; beyond that point a value is\n * accepted as long as it is an `object` (or `null` where the type permits).\n * Useful for **discrimination** rather than full validation — when you only\n * need to know which branch of a union an input belongs to, paying for a deep\n * structural check of every leaf is wasteful.\n *\n * Because the check is shallow past depth `N`, a `true` result is **not** a\n * guarantee that the whole value conforms to `T`. The name `shallow` reflects\n * this: only the discriminating, near-surface part of the type is verified. For\n * a full guarantee, use {@link is}.\n *\n * Related functions:\n *\n * - {@link is} — Full-depth check, returns a sound type guard\n * - {@link assert} — Throws {@link TypeGuardError} with detailed error info on\n * mismatch\n * - {@link validate} — Returns all errors without throwing\n *\n * @template T Target type to check\n * @template N Maximum depth to descend before accepting a value structurally.\n * Must be a non-negative integer literal. Defaults to `2`.\n * @param input Value to test\n * @returns `true` if valid up to depth `N`, `false` otherwise (type predicate\n * `input is T`)\n */\nexport function shallow<T, N extends number = 2>(input: unknown): input is T;\n\n/** @internal */\nexport function shallow(): never {\n NoTransformConfigurationError(\"shallow\");\n}\n\n/**\n * Validates type `T`.\n *\n * Unlike {@link assert} which throws on first error, this function continues\n * checking and collects all type mismatches into {@link IValidation.errors}\n * array. Never throws.\n *\n * Return structure:\n *\n * - `success: true` → `data` contains validated input as `T`\n * - `success: false` → `errors` array of {@link IValidation.IError} with `path`,\n * `expected`, `value`\n *\n * Related functions:\n *\n * - {@link assert} — Throws on first error instead of collecting all\n * - {@link is} — Simple boolean check\n * - {@link validateEquals} — Also rejects properties not defined in `T`\n *\n * @template T Target type to validate against\n * @param input Value to validate\n * @returns {@link IValidation} <T> containing either `data` or `errors`\n */\nexport function validate<T>(input: T): IValidation<T>;\n\n/**\n * Validates type `T`.\n *\n * Unlike {@link assert} which throws on first error, this function continues\n * checking and collects all type mismatches into {@link IValidation.errors}\n * array. Never throws.\n *\n * Return structure:\n *\n * - `success: true` → `data` contains validated input as `T`\n * - `success: false` → `errors` array of {@link IValidation.IError} with `path`,\n * `expected`, `value`\n *\n * Related functions:\n *\n * - {@link assert} — Throws on first error instead of collecting all\n * - {@link is} — Simple boolean check\n * - {@link validateEquals} — Also rejects properties not defined in `T`\n *\n * @template T Target type to validate against\n * @param input Value to validate\n * @returns {@link IValidation} <T> containing either `data` or `errors`\n */\nexport function validate<T>(input: unknown): IValidation<T>;\n\n/** @internal */\nexport function validate(): never {\n NoTransformConfigurationError(\"validate\");\n}\n\n/* -----------------------------------------------------------\n STRICT VALIDATORS\n----------------------------------------------------------- */\n/**\n * Asserts type `T` with strict equality.\n *\n * Stricter than {@link assert}: also fails when input contains any property not\n * defined in type `T`. For extra property errors, `expected` will be\n * `\"undefined\"`.\n *\n * Related functions:\n *\n * - {@link assert} — Allows extra properties\n * - {@link equals} — Boolean result without throwing\n * - {@link validateEquals} — Collects all errors without throwing\n * - {@link assertGuardEquals} — Type guard version with no return value\n *\n * @template T Target type for exact match\n * @param input Value to validate\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns The input value typed as `T`\n * @throws {TypeGuardError} When type mismatch or extra property detected\n */\nexport function assertEquals<T>(\n input: T,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): T;\n\n/**\n * Asserts type `T` with strict equality.\n *\n * Stricter than {@link assert}: also fails when input contains any property not\n * defined in type `T`. For extra property errors, `expected` will be\n * `\"undefined\"`.\n *\n * Related functions:\n *\n * - {@link assert} — Allows extra properties\n * - {@link equals} — Boolean result without throwing\n * - {@link validateEquals} — Collects all errors without throwing\n * - {@link assertGuardEquals} — Type guard version with no return value\n *\n * @template T Target type for exact match\n * @param input Value to validate\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns The input value typed as `T`\n * @throws {TypeGuardError} When type mismatch or extra property detected\n */\nexport function assertEquals<T>(\n input: unknown,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): T;\n\n/** @internal */\nexport function assertEquals(): never {\n NoTransformConfigurationError(\"assertEquals\");\n}\n\n/**\n * Asserts type `T` with strict equality as assertion guard.\n *\n * Combines {@link assertGuard} with strict equality checking. Returns nothing\n * but narrows input to type `T`. Also fails when input contains properties not\n * in `T`.\n *\n * Related functions:\n *\n * - {@link assertGuard} — Allows extra properties\n * - {@link assertEquals} — Returns value instead of type guard\n * - {@link equals} — Boolean result without throwing\n * - {@link validateEquals} — Collects all errors without throwing\n *\n * @template T Target type for exact match\n * @param input Value to assert (narrowed to `T` after call)\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @throws {TypeGuardError} When type mismatch or extra property detected\n */\nexport function assertGuardEquals<T>(\n input: T,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): asserts input is T;\n\n/**\n * Asserts type `T` with strict equality as assertion guard.\n *\n * Combines {@link assertGuard} with strict equality checking. Returns nothing\n * but narrows input to type `T`. Also fails when input contains properties not\n * in `T`.\n *\n * Related functions:\n *\n * - {@link assertGuard} — Allows extra properties\n * - {@link assertEquals} — Returns value instead of type guard\n * - {@link equals} — Boolean result without throwing\n * - {@link validateEquals} — Collects all errors without throwing\n *\n * @template T Target type for exact match\n * @param input Value to assert (narrowed to `T` after call)\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @throws {TypeGuardError} When type mismatch or extra property detected\n */\nexport function assertGuardEquals<T>(\n input: unknown,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): asserts input is T;\n\n/** @internal */\nexport function assertGuardEquals(): never {\n NoTransformConfigurationError(\"assertGuardEquals\");\n}\n\n/**\n * Tests type `T` with strict equality.\n *\n * Stricter than {@link is}: also returns `false` when input contains any\n * property not defined in type `T`. Useful for detecting unexpected data or\n * typos.\n *\n * Related functions:\n *\n * - {@link is} — Allows extra properties\n * - {@link assertEquals} — Throws with detailed error info on mismatch\n * - {@link validateEquals} — Returns all errors without throwing\n *\n * @template T Target type for exact match\n * @param input Value to test\n * @returns `true` if valid, `false` otherwise (type predicate `input is T`)\n */\nexport function equals<T>(input: T): input is T;\n\n/**\n * Tests type `T` with strict equality.\n *\n * Stricter than {@link is}: also returns `false` when input contains any\n * property not defined in type `T`. Useful for detecting unexpected data or\n * typos.\n *\n * Related functions:\n *\n * - {@link is} — Allows extra properties\n * - {@link assertEquals} — Throws with detailed error info on mismatch\n * - {@link validateEquals} — Returns all errors without throwing\n *\n * @template T Target type for exact match\n * @param input Value to test\n * @returns `true` if valid, `false` otherwise (type predicate `input is T`)\n */\nexport function equals<T>(input: unknown): input is T;\n\n/** @internal */\nexport function equals(): never {\n NoTransformConfigurationError(\"equals\");\n}\n\n/**\n * Validates type `T` with strict equality.\n *\n * Combines {@link validate} with strict equality checking. Collects all errors\n * including extra property violations into {@link IValidation.errors} array.\n *\n * Return structure:\n *\n * - `success: true` → `data` contains validated input as `T`\n * - `success: false` → `errors` array with `path`, `expected`, `value` for each\n * mismatch\n *\n * Related functions:\n *\n * - {@link validate} — Allows extra properties\n * - {@link assertEquals} — Throws on first error\n * - {@link equals} — Simple boolean check\n *\n * @template T Target type for exact match\n * @param input Value to validate\n * @returns {@link IValidation} <T> containing either `data` or `errors`\n */\nexport function validateEquals<T>(input: T): IValidation<T>;\n\n/**\n * Validates type `T` with strict equality.\n *\n * Combines {@link validate} with strict equality checking. Collects all errors\n * including extra property violations into {@link IValidation.errors} array.\n *\n * Return structure:\n *\n * - `success: true` → `data` contains validated input as `T`\n * - `success: false` → `errors` array with `path`, `expected`, `value` for each\n * mismatch\n *\n * Related functions:\n *\n * - {@link validate} — Allows extra properties\n * - {@link assertEquals} — Throws on first error\n * - {@link equals} — Simple boolean check\n *\n * @template T Target type for exact match\n * @param input Value to validate\n * @returns {@link IValidation} <T> containing either `data` or `errors`\n */\nexport function validateEquals<T>(input: unknown): IValidation<T>;\n\n/** @internal */\nexport function validateEquals(): never {\n NoTransformConfigurationError(\"validateEquals\");\n}\n\n/* -----------------------------------------------------------\n RANDOM\n----------------------------------------------------------- */\n/**\n * Generates random data of type `T`.\n *\n * Creates random instance conforming to compile-time type `T`. Generates only\n * primitive data; methods in `T` are ignored. If `T` has `toJSON()` method,\n * generates its return type instead.\n *\n * @template T Type of data to generate\n * @param generator Custom random generator implementing {@link IRandomGenerator}\n * @returns Randomly generated data as `Resolved<T>`\n * @danger You must configure the generic argument `T`\n */\nexport function random(generator?: Partial<IRandomGenerator>): never;\n\n/**\n * Generates random data of type `T`.\n *\n * Creates random instance conforming to compile-time type `T`. Generates only\n * primitive data; methods in `T` are ignored. If `T` has `toJSON()` method,\n * generates its return type instead.\n *\n * @template T Type of data to generate\n * @param generator Custom random generator implementing {@link IRandomGenerator}\n * @returns Randomly generated data as `Resolved<T>`\n */\nexport function random<T>(generator?: Partial<IRandomGenerator>): Resolved<T>;\n\n/** @internal */\nexport function random(): never {\n NoTransformConfigurationError(\"random\");\n}\n\n/* -----------------------------------------------------------\n FACTORY FUNCTIONS\n----------------------------------------------------------- */\n/**\n * Creates reusable {@link assert} function.\n *\n * Returns a function that can be called multiple times without recompilation.\n * Useful when the same type validation is needed repeatedly.\n *\n * @template T Target type to validate against\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns Reusable assert function `(input: unknown, errorFactory?) => T`\n * @danger You must configure the generic argument `T`\n */\nexport function createAssert(\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): never;\n\n/**\n * Creates reusable {@link assert} function.\n *\n * Returns a function that can be called multiple times without recompilation.\n * Useful when the same type validation is needed repeatedly.\n *\n * @template T Target type to validate against\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns Reusable assert function `(input: unknown, errorFactory?) => T`,\n * whose own `errorFactory` overrides this one for that single call\n */\nexport function createAssert<T>(\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): (\n input: unknown,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n) => T;\n\n/** @internal */\nexport function createAssert<T>(): (\n input: unknown,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n) => T {\n NoTransformConfigurationError(\"createAssert\");\n}\n\n/**\n * Creates reusable {@link assertGuard} function.\n *\n * Returns a reusable type guard assertion function.\n *\n * TypeScript requirement: You must declare the variable type explicitly. `const\n * fn: AssertionGuard<T> = createAssertGuard<T>()` — otherwise compile error.\n * That annotation is one parameter wide, so it also hides the call-time\n * `errorFactory`; annotate with `(input: unknown, errorFactory?: (props:\n * TypeGuardError.IProps) => Error) => asserts input is T` when you need it.\n *\n * @template T Target type to validate against\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns Reusable assertion guard function\n * @danger You must configure the generic argument `T`\n */\nexport function createAssertGuard(\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): never;\n\n/**\n * Creates reusable {@link assertGuard} function.\n *\n * Returns a reusable type guard assertion function.\n *\n * TypeScript requirement: You must declare the variable type explicitly. `const\n * fn: AssertionGuard<T> = createAssertGuard<T>()` — otherwise compile error.\n * That annotation is one parameter wide, so it also hides the call-time\n * `errorFactory`; annotate with `(input: unknown, errorFactory?: (props:\n * TypeGuardError.IProps) => Error) => asserts input is T` when you need it.\n *\n * @template T Target type to validate against\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns Reusable assertion guard function, whose own `errorFactory`\n * overrides this one for that single call\n */\nexport function createAssertGuard<T>(\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): (\n input: unknown,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n) => asserts input is T;\n\n/** @internal */\nexport function createAssertGuard<T>(): (\n input: unknown,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n) => asserts input is T {\n NoTransformConfigurationError(\"createAssertGuard\");\n}\n\n/**\n * Creates reusable {@link is} function.\n *\n * Returns a type guard function that can be called multiple times without\n * recompilation.\n *\n * @template T Target type to check\n * @returns Reusable type guard function `(input: unknown) => input is T`\n * @danger You must configure the generic argument `T`\n */\nexport function createIs(): never;\n\n/**\n * Creates reusable {@link is} function.\n *\n * Returns a type guard function that can be called multiple times without\n * recompilation.\n *\n * @template T Target type to check\n * @returns Reusable type guard function `(input: unknown) => input is T`\n */\nexport function createIs<T>(): (input: unknown) => input is T;\n\n/** @internal */\nexport function createIs<T>(): (input: unknown) => input is T {\n NoTransformConfigurationError(\"createIs\");\n}\n\n/**\n * Creates reusable {@link shallow} function.\n *\n * Returns a depth-limited type guard function that can be called multiple times\n * without recompilation.\n *\n * @template T Target type to check\n * @template N Maximum depth to descend before accepting a value structurally.\n * Must be a non-negative integer literal. Defaults to `2`.\n * @returns Reusable type guard function `(input: unknown) => input is T`\n * @danger You must configure the generic argument `T`\n */\nexport function createShallow(): never;\n\n/**\n * Creates reusable {@link shallow} function.\n *\n * Returns a depth-limited type guard function that can be called multiple times\n * without recompilation.\n *\n * @template T Target type to check\n * @template N Maximum depth to descend before accepting a value structurally.\n * Must be a non-negative integer literal. Defaults to `2`.\n * @returns Reusable type guard function `(input: unknown) => input is T`\n */\nexport function createShallow<T, N extends number = 2>(): (\n input: unknown,\n) => input is T;\n\n/** @internal */\nexport function createShallow<T>(): (input: unknown) => input is T {\n NoTransformConfigurationError(\"createShallow\");\n}\n\n/**\n * Creates reusable {@link validate} function.\n *\n * Returns a validation function that can be called multiple times without\n * recompilation. Also implements {@link StandardSchemaV1} interface for\n * interoperability.\n *\n * @template T Target type to validate against\n * @returns Reusable validate function `(input: unknown) => IValidation<T>`\n * @danger You must configure the generic argument `T`\n */\nexport function createValidate(): never;\n\n/**\n * Creates reusable {@link validate} function.\n *\n * Returns a validation function that can be called multiple times without\n * recompilation. Also implements {@link StandardSchemaV1} interface for\n * interoperability.\n *\n * @template T Target type to validate against\n * @returns Reusable validate function `(input: unknown) => IValidation<T>`\n */\nexport function createValidate<T>(): ((input: unknown) => IValidation<T>) &\n StandardSchemaV1<T, T>;\n\n/** @internal */\nexport function createValidate(): ((input: unknown) => IValidation) &\n StandardSchemaV1<unknown, unknown> {\n NoTransformConfigurationError(\"createValidate\");\n}\n\n/**\n * Creates reusable {@link assertEquals} function.\n *\n * Returns a strict assertion function that rejects superfluous properties. Can\n * be called multiple times without recompilation.\n *\n * @template T Target type for exact match\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns Reusable assertEquals function `(input: unknown, errorFactory?) =>\n * T`\n * @danger You must configure the generic argument `T`\n */\nexport function createAssertEquals(\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): never;\n\n/**\n * Creates reusable {@link assertEquals} function.\n *\n * Returns a strict assertion function that rejects superfluous properties. Can\n * be called multiple times without recompilation.\n *\n * @template T Target type for exact match\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns Reusable assertEquals function `(input: unknown, errorFactory?) =>\n * T`, whose own `errorFactory` overrides this one for that single call\n */\nexport function createAssertEquals<T>(\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): (\n input: unknown,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n) => T;\n\n/** @internal */\nexport function createAssertEquals<T>(): (\n input: unknown,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n) => T {\n NoTransformConfigurationError(\"createAssertEquals\");\n}\n\n/**\n * Creates reusable {@link assertGuardEquals} function.\n *\n * Returns a strict assertion guard that rejects superfluous properties.\n *\n * TypeScript requirement: You must declare the variable type explicitly. `const\n * fn: AssertionGuard<T> = createAssertGuardEquals<T>()` — otherwise compile\n * error. That annotation is one parameter wide, so it also hides the call-time\n * `errorFactory`; annotate with `(input: unknown, errorFactory?: (props:\n * TypeGuardError.IProps) => Error) => asserts input is T` when you need it.\n *\n * @template T Target type for exact match\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns Reusable assertion guard function\n * @danger You must configure the generic argument `T`\n */\nexport function createAssertGuardEquals(\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): never;\n\n/**\n * Creates reusable {@link assertGuardEquals} function.\n *\n * Returns a strict assertion guard that rejects superfluous properties.\n *\n * TypeScript requirement: You must declare the variable type explicitly. `const\n * fn: AssertionGuard<T> = createAssertGuardEquals<T>()` — otherwise compile\n * error. That annotation is one parameter wide, so it also hides the call-time\n * `errorFactory`; annotate with `(input: unknown, errorFactory?: (props:\n * TypeGuardError.IProps) => Error) => asserts input is T` when you need it.\n *\n * @template T Target type for exact match\n * @param errorFactory Custom error factory receiving\n * {@link TypeGuardError.IProps}\n * @returns Reusable assertion guard function, whose own `errorFactory`\n * overrides this one for that single call\n */\nexport function createAssertGuardEquals<T>(\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n): (\n input: unknown,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n) => asserts input is T;\n\n/** @internal */\nexport function createAssertGuardEquals<T>(): (\n input: unknown,\n errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),\n) => asserts input is T {\n NoTransformConfigurationError(\"createAssertGuardEquals\");\n}\n\n/**\n * Creates reusable {@link equals} function.\n *\n * Returns a strict type guard that rejects superfluous properties. Can be\n * called multiple times without recompilation.\n *\n * @template T Target type for exact match\n * @returns Reusable type guard function `(input: unknown) => input is T`\n * @danger You must configure the generic argument `T`\n */\nexport function createEquals(): never;\n\n/**\n * Creates reusable {@link equals} function.\n *\n * Returns a strict type guard that rejects superfluous properties. Can be\n * called multiple times without recompilation.\n *\n * @template T Target type for exact match\n * @returns Reusable type guard function `(input: unknown) => input is T`\n */\nexport function createEquals<T>(): (input: unknown) => input is T;\n\n/** @internal */\nexport function createEquals<T>(): (input: unknown) => input is T {\n NoTransformConfigurationError(\"createEquals\");\n}\n\n/**\n * Creates reusable {@link validateEquals} function.\n *\n * Returns a strict validation function that rejects superfluous properties.\n * Also implements {@link StandardSchemaV1} interface for interoperability.\n *\n * @template T Target type for exact match\n * @returns Reusable validateEquals function `(input: unknown) =>\n * IValidation<T>`\n * @danger You must configure the generic argument `T`\n */\nexport function createValidateEquals(): never;\n\n/**\n * Creates reusable {@link validateEquals} function.\n *\n * Returns a strict validation function that rejects superfluous properties.\n * Also implements {@link StandardSchemaV1} interface for interoperability.\n *\n * @template T Target type for exact match\n * @returns Reusable validateEquals function `(input: unknown) =>\n * IValidation<T>`\n */\nexport function createValidateEquals<T>(): ((\n input: unknown,\n) => IValidation<T>) &\n StandardSchemaV1<T, T>;\n\n/** @internal */\nexport function createValidateEquals(): ((input: unknown) => IValidation) &\n StandardSchemaV1<unknown, unknown> {\n NoTransformConfigurationError(\"createValidateEquals\");\n}\n\n/**\n * Creates reusable {@link random} function.\n *\n * Returns a random data generator that can be called multiple times without\n * recompilation.\n *\n * @template T Type of data to generate\n * @param generator Custom random generator implementing {@link IRandomGenerator}\n * @returns Reusable random function `() => Resolved<T>`\n * @danger You must configure the generic argument `T`\n */\nexport function createRandom(generator?: Partial<IRandomGenerator>): never;\n\n/**\n * Creates reusable {@link random} function.\n *\n * Returns a random data generator that can be called multiple times without\n * recompilation.\n *\n * @template T Type of data to generate\n * @param generator Custom random generator implementing {@link IRandomGenerator}\n * @returns Reusable random function `() => Resolved<T>`\n */\nexport function createRandom<T>(\n generator?: Partial<IRandomGenerator>,\n): () => Resolved<T>;\n\n/** @internal */\nexport function createRandom(): never {\n NoTransformConfigurationError(\"createRandom\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsFA,SAAgB,SAAgB;CAC9B,8BAA8B,QAAQ;AACxC;;AA6DA,SAAgB,cAAqB;CACnC,8BAA8B,aAAa;AAC7C;;AA2CA,SAAgB,KAAY;CAC1B,8BAA8B,IAAI;AACpC;;AAiEA,SAAgB,UAAiB;CAC/B,8BAA8B,SAAS;AACzC;;AAqDA,SAAgB,WAAkB;CAChC,8BAA8B,UAAU;AAC1C;;AA0DA,SAAgB,eAAsB;CACpC,8BAA8B,cAAc;AAC9C;;AAqDA,SAAgB,oBAA2B;CACzC,8BAA8B,mBAAmB;AACnD;;AAyCA,SAAgB,SAAgB;CAC9B,8BAA8B,QAAQ;AACxC;;AAmDA,SAAgB,iBAAwB;CACtC,8BAA8B,gBAAgB;AAChD;;AAiCA,SAAgB,SAAgB;CAC9B,8BAA8B,QAAQ;AACxC;;AAyCA,SAAgB,eAGT;CACL,8BAA8B,cAAc;AAC9C;;AAgDA,SAAgB,oBAGQ;CACtB,8BAA8B,mBAAmB;AACnD;;AA0BA,SAAgB,WAA8C;CAC5D,8BAA8B,UAAU;AAC1C;;AAgCA,SAAgB,gBAAmD;CACjE,8BAA8B,eAAe;AAC/C;;AA6BA,SAAgB,iBACqB;CACnC,8BAA8B,gBAAgB;AAChD;;AAuCA,SAAgB,qBAGT;CACL,8BAA8B,oBAAoB;AACpD;;AAgDA,SAAgB,0BAGQ;CACtB,8BAA8B,yBAAyB;AACzD;;AA0BA,SAAgB,eAAkD;CAChE,8BAA8B,cAAc;AAC9C;;AA+BA,SAAgB,uBACqB;CACnC,8BAA8B,sBAAsB;AACtD;;AA8BA,SAAgB,eAAsB;CACpC,8BAA8B,cAAc;AAC9C"}
|
package/lib/re-exports.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type { AssertionGuard, IJsonParseResult, IValidation, IRandomGenerator, OpenApi, IJsonSchemaCollection, IJsonSchemaUnit, ILlmController, ILlmApplication, ILlmFunction, ILlmStructuredOutput, ILlmSchema, IMetadataSchema, IMetadataSchemaCollection, IMetadataSchemaUnit, IMetadataComponents, IMetadataTypeTag, IJsDocTagInfo, Classifiable, ClassifyResult, Primitive, Resolved, CamelCase, KebabCase, PascalCase, SnakeCase, IReadableURLSearchParams, } from "@typia/interface";
|
|
1
|
+
export type { AssertionGuard, IJsonParseResult, IValidation, IRandomGenerator, StandardSchemaV1, OpenApi, IJsonSchemaApplication, IJsonSchemaCollection, IJsonSchemaUnit, ILlmController, ILlmApplication, ILlmFunction, ILlmStructuredOutput, ILlmSchema, IMetadataSchema, IMetadataSchemaCollection, IMetadataSchemaUnit, IMetadataComponents, IMetadataTypeTag, IJsDocTagInfo, Atomic, Classifiable, ClassifyResult, Primitive, Resolved, CamelCase, KebabCase, PascalCase, SnakeCase, IReadableURLSearchParams, } from "@typia/interface";
|
|
2
2
|
export { tags } from "@typia/interface";
|
package/lib/re-exports.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"re-exports.js","sourceRoot":"","sources":["../src/re-exports.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"re-exports.js","sourceRoot":"","sources":["../src/re-exports.ts"],"names":[],"mappings":";;;AAiDA,0EAA0E;AAC1E,sEAAsE;AACtE,0EAA0E;AAC1E,mEAAmE;AACnE,sBAAsB;AACtB,8CAAwC;AAA/B,iGAAA,IAAI,OAAA"}
|
|
@@ -120,8 +120,11 @@ const createAssertErrorFactorySentinel = "zzz"
|
|
|
120
120
|
// never executed: the http, protobuf and notation members pull runtime helpers
|
|
121
121
|
// this package stubs only for the emit it runs, so the executed fixture stays
|
|
122
122
|
// on the module family.
|
|
123
|
-
const createAssertErrorFactorySurfaceSource = `import {
|
|
124
|
-
|
|
123
|
+
const createAssertErrorFactorySurfaceSource = `import typia, {
|
|
124
|
+
AssertionGuard,
|
|
125
|
+
StandardSchemaV1,
|
|
126
|
+
TypeGuardError,
|
|
127
|
+
} from "typia";
|
|
125
128
|
|
|
126
129
|
interface User {
|
|
127
130
|
id: number;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
package main
|
|
2
|
+
|
|
3
|
+
import "testing"
|
|
4
|
+
|
|
5
|
+
// TestDependencyCollectorVirtualScheme verifies which dropped file still costs
|
|
6
|
+
// the current key its completeness declaration.
|
|
7
|
+
//
|
|
8
|
+
// The envelope reports no virtual URI source, because nothing can watch one. Two
|
|
9
|
+
// of them are not the same, though: `driver.NewTransformGraph` skips exactly
|
|
10
|
+
// `bundled:///`, so a bundled library is absent from the host-owned bound too
|
|
11
|
+
// and dropping it changes nothing, while a file under any other scheme is still
|
|
12
|
+
// a member of that bound. Narrowing to a list that cannot name it would stop
|
|
13
|
+
// watching an input the default bound watches, so the file that consulted it
|
|
14
|
+
// stays undeclared (samchon/typia#2357).
|
|
15
|
+
//
|
|
16
|
+
// The case is a collector probe rather than a fixture because no tsconfig this
|
|
17
|
+
// repository can write makes the compiler serve a non-bundled virtual source;
|
|
18
|
+
// the branch is reachable only from the listener side.
|
|
19
|
+
//
|
|
20
|
+
// 1. Report a `bundled:///` library against one key and a foreign-scheme source
|
|
21
|
+
// against another.
|
|
22
|
+
// 2. Render both sections.
|
|
23
|
+
// 3. Assert neither file reached `dependencies`.
|
|
24
|
+
// 4. Assert only the foreign-scheme key lost its completeness declaration.
|
|
25
|
+
func TestDependencyCollectorVirtualScheme(t *testing.T) {
|
|
26
|
+
collector := newTransformDependencyCollector("D:/project", func(string) bool { return false })
|
|
27
|
+
|
|
28
|
+
collector.Begin("src/bundled.ts")
|
|
29
|
+
collector.Touch("bundled:///lib.es5.d.ts")
|
|
30
|
+
collector.End()
|
|
31
|
+
|
|
32
|
+
collector.Begin("src/foreign.ts")
|
|
33
|
+
collector.Touch("vfs://memory/generated.d.ts")
|
|
34
|
+
collector.End()
|
|
35
|
+
|
|
36
|
+
if reported := collector.ToJSON(); reported != nil {
|
|
37
|
+
t.Fatalf("a virtual URI source is unwatchable and must never reach dependencies: %v", reported)
|
|
38
|
+
}
|
|
39
|
+
declared := map[string]bool{}
|
|
40
|
+
for _, key := range collector.ToCompleteJSON(map[string]string{
|
|
41
|
+
"src/bundled.ts": "",
|
|
42
|
+
"src/foreign.ts": "",
|
|
43
|
+
}) {
|
|
44
|
+
declared[key] = true
|
|
45
|
+
}
|
|
46
|
+
if !declared["src/bundled.ts"] {
|
|
47
|
+
t.Fatalf("the host graph drops bundled libraries too, so dropping one costs no declaration: %v", declared)
|
|
48
|
+
}
|
|
49
|
+
if declared["src/foreign.ts"] {
|
|
50
|
+
t.Fatalf("the host graph keeps a foreign scheme, so a file that consulted one must be withheld: %v", declared)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
package main
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"encoding/json"
|
|
5
|
+
"os"
|
|
6
|
+
"path/filepath"
|
|
7
|
+
"strings"
|
|
8
|
+
"testing"
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
// TestProjectDependenciesCalleeArgumentTransform verifies a nested call's
|
|
12
|
+
// arguments report the names they write, and that their shape never withholds
|
|
13
|
+
// the caller.
|
|
14
|
+
//
|
|
15
|
+
// The callee chain names every indirection a caller writes -- a factory, a
|
|
16
|
+
// barrel, a namespace alias -- but a generic pass-through carries identity
|
|
17
|
+
// through what the call is APPLIED to instead: `pick(ns).is<Foo>(x)` is rewritten
|
|
18
|
+
// because `ns` holds the typia namespace, so `ns.ts` decides whether this file
|
|
19
|
+
// becomes a validator at all. Reproduced: the envelope declared the caller
|
|
20
|
+
// complete while reporting only `foo.ts` and `pick.ts`, so re-pointing `ns.ts`
|
|
21
|
+
// would have turned the validator back into a plain call with nothing to
|
|
22
|
+
// invalidate it (samchon/typia#2357).
|
|
23
|
+
//
|
|
24
|
+
// The twin is why the walk's answer is dropped rather than combined: a callback
|
|
25
|
+
// handed to a chained array method decides nothing about which `join` the outer
|
|
26
|
+
// call names, and withholding on it would cost every file that chains one.
|
|
27
|
+
//
|
|
28
|
+
// 1. Build a project where `main.ts` calls `pick(ns).is<Foo>(input)` for a
|
|
29
|
+
// `pick` that returns its argument, and `chain.ts` writes
|
|
30
|
+
// `["a"].map((x) => x + HIDDEN).join(",")` for a `HIDDEN` from another file.
|
|
31
|
+
// 2. Run project transform mode and decode the JSON envelope.
|
|
32
|
+
// 3. Assert `main.ts` really was rewritten into a validator, so the pass-through
|
|
33
|
+
// is the shape the test intends.
|
|
34
|
+
// 4. Assert `dependencies["src/main.ts"]` carries `src/ns.ts` and `src/pick.ts`,
|
|
35
|
+
// and that the file is declared complete.
|
|
36
|
+
// 5. Assert `chain.ts` is declared complete and never reports `src/hidden.ts`,
|
|
37
|
+
// the name only its callback body writes.
|
|
38
|
+
// 6. Assert the tagged-template spelling of the same pass-through --
|
|
39
|
+
// “tag`x${ns}`.is<Foo>(input)“ -- reports `src/ns.ts` as well, because a
|
|
40
|
+
// template is what its tag is applied to.
|
|
41
|
+
func TestProjectDependenciesCalleeArgumentTransform(t *testing.T) {
|
|
42
|
+
project := projectDependenciesCalleeArgumentProject(t)
|
|
43
|
+
out, errText, code := ttscTypiaTestCapture(func() int {
|
|
44
|
+
return runTransform([]string{
|
|
45
|
+
"--cwd", project,
|
|
46
|
+
"--tsconfig", "tsconfig.json",
|
|
47
|
+
"--output", "ts",
|
|
48
|
+
})
|
|
49
|
+
})
|
|
50
|
+
if code != 0 {
|
|
51
|
+
t.Fatalf("project transform failed: code=%d stderr=\n%s", code, errText)
|
|
52
|
+
}
|
|
53
|
+
var envelope struct {
|
|
54
|
+
TypeScript map[string]string `json:"typescript"`
|
|
55
|
+
Dependencies map[string][]string `json:"dependencies"`
|
|
56
|
+
DependenciesComplete []string `json:"dependenciesComplete"`
|
|
57
|
+
}
|
|
58
|
+
if err := json.Unmarshal([]byte(out), &envelope); err != nil {
|
|
59
|
+
t.Fatalf("decode envelope: %v\n%s", err, out)
|
|
60
|
+
}
|
|
61
|
+
if text := envelope.TypeScript["src/main.ts"]; !strings.Contains(text, "input is Foo") {
|
|
62
|
+
t.Fatalf("the pass-through call must have been rewritten into a validator, got:\n%s", text)
|
|
63
|
+
}
|
|
64
|
+
entries := envelope.Dependencies["src/main.ts"]
|
|
65
|
+
found := map[string]bool{}
|
|
66
|
+
for _, entry := range entries {
|
|
67
|
+
found[entry] = true
|
|
68
|
+
}
|
|
69
|
+
if !found["src/ns.ts"] {
|
|
70
|
+
t.Fatalf("dependencies of src/main.ts must contain src/ns.ts, the argument that makes this call typia's: %v", entries)
|
|
71
|
+
}
|
|
72
|
+
if !found["src/pick.ts"] {
|
|
73
|
+
t.Fatalf("dependencies of src/main.ts must contain src/pick.ts, the pass-through on the callee chain: %v", entries)
|
|
74
|
+
}
|
|
75
|
+
declared := map[string]bool{}
|
|
76
|
+
for _, key := range envelope.DependenciesComplete {
|
|
77
|
+
declared[key] = true
|
|
78
|
+
}
|
|
79
|
+
if !declared["src/main.ts"] {
|
|
80
|
+
t.Fatalf("src/main.ts must be declared complete, so the reported entry is the whole bound: %v", envelope.DependenciesComplete)
|
|
81
|
+
}
|
|
82
|
+
if !declared["src/chain.ts"] {
|
|
83
|
+
t.Fatalf("a callback handed to a chained array method decides no callee identity and must not withhold its file: %v", envelope.DependenciesComplete)
|
|
84
|
+
}
|
|
85
|
+
for _, entry := range envelope.Dependencies["src/chain.ts"] {
|
|
86
|
+
if entry == "src/hidden.ts" {
|
|
87
|
+
t.Fatalf("the walk must stop at a function literal, so src/hidden.ts must not be charged to src/chain.ts: %v", envelope.Dependencies["src/chain.ts"])
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if text := envelope.TypeScript["src/tagged.ts"]; !strings.Contains(text, "input is Foo") {
|
|
91
|
+
t.Fatalf("the tagged-template pass-through must have been rewritten into a validator, got:\n%s", text)
|
|
92
|
+
}
|
|
93
|
+
tagged := map[string]bool{}
|
|
94
|
+
for _, entry := range envelope.Dependencies["src/tagged.ts"] {
|
|
95
|
+
tagged[entry] = true
|
|
96
|
+
}
|
|
97
|
+
if !tagged["src/ns.ts"] {
|
|
98
|
+
t.Fatalf("dependencies of src/tagged.ts must contain src/ns.ts, the substitution that makes this call typia's: %v", envelope.Dependencies["src/tagged.ts"])
|
|
99
|
+
}
|
|
100
|
+
if !declared["src/tagged.ts"] {
|
|
101
|
+
t.Fatalf("src/tagged.ts must be declared complete, so the reported entry is the whole bound: %v", envelope.DependenciesComplete)
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
func projectDependenciesCalleeArgumentProject(t *testing.T) string {
|
|
106
|
+
t.Helper()
|
|
107
|
+
root := ttscTypiaTestRepoRoot(t)
|
|
108
|
+
base := filepath.Join(root, "packages", "typia", "native", ".tmp-ttsc-typia-tests")
|
|
109
|
+
if err := os.MkdirAll(base, 0o755); err != nil {
|
|
110
|
+
t.Fatalf("mkdir temp base: %v", err)
|
|
111
|
+
}
|
|
112
|
+
dir, err := os.MkdirTemp(base, "project-dependencies-callee-argument-")
|
|
113
|
+
if err != nil {
|
|
114
|
+
t.Fatalf("create temp fixture: %v", err)
|
|
115
|
+
}
|
|
116
|
+
t.Cleanup(func() { _ = os.RemoveAll(dir) })
|
|
117
|
+
src := filepath.Join(dir, "src")
|
|
118
|
+
if err := os.MkdirAll(src, 0o755); err != nil {
|
|
119
|
+
t.Fatalf("mkdir fixture src: %v", err)
|
|
120
|
+
}
|
|
121
|
+
if err := os.WriteFile(filepath.Join(dir, "tsconfig.json"), []byte(projectDependenciesEnvelopeTSConfig), 0o644); err != nil {
|
|
122
|
+
t.Fatalf("write tsconfig: %v", err)
|
|
123
|
+
}
|
|
124
|
+
for name, body := range map[string]string{
|
|
125
|
+
"main.ts": projectDependenciesCalleeArgumentSourceMain,
|
|
126
|
+
"ns.ts": projectDependenciesCalleeArgumentSourceNs,
|
|
127
|
+
"pick.ts": projectDependenciesCalleeArgumentSourcePick,
|
|
128
|
+
"foo.ts": projectDependenciesCalleeArgumentSourceFoo,
|
|
129
|
+
"chain.ts": projectDependenciesCalleeArgumentSourceChain,
|
|
130
|
+
"hidden.ts": projectDependenciesCalleeArgumentSourceHidden,
|
|
131
|
+
"tagged.ts": projectDependenciesCalleeArgumentSourceTagged,
|
|
132
|
+
"tag.ts": projectDependenciesCalleeArgumentSourceTag,
|
|
133
|
+
} {
|
|
134
|
+
if err := os.WriteFile(filepath.Join(src, name), []byte(body), 0o644); err != nil {
|
|
135
|
+
t.Fatalf("write %s: %v", name, err)
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return dir
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const projectDependenciesCalleeArgumentSourceMain = `import { Foo } from "./foo";
|
|
142
|
+
import { ns } from "./ns";
|
|
143
|
+
import { pick } from "./pick";
|
|
144
|
+
|
|
145
|
+
export const check = (input: unknown) => pick(ns).is<Foo>(input);
|
|
146
|
+
`
|
|
147
|
+
|
|
148
|
+
const projectDependenciesCalleeArgumentSourceNs = `import typia from "typia";
|
|
149
|
+
|
|
150
|
+
export const ns = typia;
|
|
151
|
+
`
|
|
152
|
+
|
|
153
|
+
const projectDependenciesCalleeArgumentSourcePick = `export const pick = <T>(value: T): T => value;
|
|
154
|
+
`
|
|
155
|
+
|
|
156
|
+
const projectDependenciesCalleeArgumentSourceFoo = `export interface Foo {
|
|
157
|
+
id: string;
|
|
158
|
+
}
|
|
159
|
+
`
|
|
160
|
+
|
|
161
|
+
const projectDependenciesCalleeArgumentSourceChain = `import { HIDDEN } from "./hidden";
|
|
162
|
+
|
|
163
|
+
export const joined = ["a"].map((x) => x + HIDDEN).join(",");
|
|
164
|
+
`
|
|
165
|
+
|
|
166
|
+
const projectDependenciesCalleeArgumentSourceHidden = `export const HIDDEN = "hidden";
|
|
167
|
+
`
|
|
168
|
+
|
|
169
|
+
const projectDependenciesCalleeArgumentSourceTagged = `import { Foo } from "./foo";
|
|
170
|
+
import { ns } from "./ns";
|
|
171
|
+
import { tag } from "./tag";
|
|
172
|
+
|
|
173
|
+
export const check = (input: unknown) => tag` + "`" + `x${ns}` + "`" + `.is<Foo>(input);
|
|
174
|
+
`
|
|
175
|
+
|
|
176
|
+
const projectDependenciesCalleeArgumentSourceTag = `export const tag = <T>(_strings: TemplateStringsArray, value: T): T => value;
|
|
177
|
+
`
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
package main
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"encoding/json"
|
|
5
|
+
"os"
|
|
6
|
+
"path/filepath"
|
|
7
|
+
"strings"
|
|
8
|
+
"testing"
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
// TestProjectDependenciesCalleeBarrelTransform verifies the modules an import
|
|
12
|
+
// chain traverses to reach a typia callee are reported for the file that calls
|
|
13
|
+
// it.
|
|
14
|
+
//
|
|
15
|
+
// typia decides its own call sites by the file that declares the resolved
|
|
16
|
+
// signature, so a barrel between the caller and typia chooses whether the call
|
|
17
|
+
// is rewritten at all: re-pointing `export { is } from "typia"` at a local
|
|
18
|
+
// helper turns a generated validator back into a plain call. The consulted-type
|
|
19
|
+
// touches cannot see that -- they report what the validated type is, never what
|
|
20
|
+
// selected the callee -- so without this the barrel is nowhere in the reported
|
|
21
|
+
// list, and a consumer that narrows to that list serves the stale validator
|
|
22
|
+
// (samchon/typia#2357).
|
|
23
|
+
//
|
|
24
|
+
// 1. Build a project where `consumer.ts` calls `is<Alpha>` imported from
|
|
25
|
+
// `barrel.ts`, which re-exports it from `typia`.
|
|
26
|
+
// 2. Run project transform mode and decode the JSON envelope.
|
|
27
|
+
// 3. Assert the call was rewritten, so the barrel really did select typia.
|
|
28
|
+
// 4. Assert `dependencies["src/consumer.ts"]` contains `src/barrel.ts`, and
|
|
29
|
+
// not `src/unused.ts`, which the barrel also re-exports but this reference
|
|
30
|
+
// never traverses.
|
|
31
|
+
func TestProjectDependenciesCalleeBarrelTransform(t *testing.T) {
|
|
32
|
+
project := projectDependenciesCalleeBarrelProject(t)
|
|
33
|
+
out, errText, code := ttscTypiaTestCapture(func() int {
|
|
34
|
+
return runTransform([]string{
|
|
35
|
+
"--cwd", project,
|
|
36
|
+
"--tsconfig", "tsconfig.json",
|
|
37
|
+
"--output", "ts",
|
|
38
|
+
})
|
|
39
|
+
})
|
|
40
|
+
if code != 0 {
|
|
41
|
+
t.Fatalf("project transform failed: code=%d stderr=\n%s", code, errText)
|
|
42
|
+
}
|
|
43
|
+
var envelope struct {
|
|
44
|
+
TypeScript map[string]string `json:"typescript"`
|
|
45
|
+
Dependencies map[string][]string `json:"dependencies"`
|
|
46
|
+
}
|
|
47
|
+
if err := json.Unmarshal([]byte(out), &envelope); err != nil {
|
|
48
|
+
t.Fatalf("decode envelope: %v\n%s", err, out)
|
|
49
|
+
}
|
|
50
|
+
if text := envelope.TypeScript["src/consumer.ts"]; !strings.Contains(text, "input is") {
|
|
51
|
+
t.Fatalf("the re-exported callee must still be recognized as typia's, got:\n%s", text)
|
|
52
|
+
}
|
|
53
|
+
entries := envelope.Dependencies["src/consumer.ts"]
|
|
54
|
+
found := map[string]bool{}
|
|
55
|
+
for _, entry := range entries {
|
|
56
|
+
found[entry] = true
|
|
57
|
+
}
|
|
58
|
+
if !found["src/barrel.ts"] {
|
|
59
|
+
t.Fatalf("dependencies of src/consumer.ts must contain the barrel src/barrel.ts that selects the typia callee: %v", entries)
|
|
60
|
+
}
|
|
61
|
+
if found["src/unused.ts"] {
|
|
62
|
+
t.Fatalf("dependencies of src/consumer.ts must not contain src/unused.ts, which the barrel re-exports but this reference never traverses: %v", entries)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
func projectDependenciesCalleeBarrelProject(t *testing.T) string {
|
|
67
|
+
t.Helper()
|
|
68
|
+
root := ttscTypiaTestRepoRoot(t)
|
|
69
|
+
base := filepath.Join(root, "packages", "typia", "native", ".tmp-ttsc-typia-tests")
|
|
70
|
+
if err := os.MkdirAll(base, 0o755); err != nil {
|
|
71
|
+
t.Fatalf("mkdir temp base: %v", err)
|
|
72
|
+
}
|
|
73
|
+
dir, err := os.MkdirTemp(base, "project-dependencies-callee-barrel-")
|
|
74
|
+
if err != nil {
|
|
75
|
+
t.Fatalf("create temp fixture: %v", err)
|
|
76
|
+
}
|
|
77
|
+
t.Cleanup(func() { _ = os.RemoveAll(dir) })
|
|
78
|
+
src := filepath.Join(dir, "src")
|
|
79
|
+
if err := os.MkdirAll(src, 0o755); err != nil {
|
|
80
|
+
t.Fatalf("mkdir fixture src: %v", err)
|
|
81
|
+
}
|
|
82
|
+
if err := os.WriteFile(filepath.Join(dir, "tsconfig.json"), []byte(projectDependenciesEnvelopeTSConfig), 0o644); err != nil {
|
|
83
|
+
t.Fatalf("write tsconfig: %v", err)
|
|
84
|
+
}
|
|
85
|
+
for name, body := range map[string]string{
|
|
86
|
+
"consumer.ts": projectDependenciesCalleeBarrelSourceConsumer,
|
|
87
|
+
"barrel.ts": projectDependenciesCalleeBarrelSourceBarrel,
|
|
88
|
+
"alpha.ts": projectDependenciesCalleeBarrelSourceAlpha,
|
|
89
|
+
"unused.ts": projectDependenciesCalleeBarrelSourceUnused,
|
|
90
|
+
} {
|
|
91
|
+
if err := os.WriteFile(filepath.Join(src, name), []byte(body), 0o644); err != nil {
|
|
92
|
+
t.Fatalf("write %s: %v", name, err)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return dir
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const projectDependenciesCalleeBarrelSourceConsumer = `import { is } from "./barrel";
|
|
99
|
+
|
|
100
|
+
import { Alpha } from "./alpha";
|
|
101
|
+
|
|
102
|
+
export const checkAlpha = (input: unknown) => is<Alpha>(input);
|
|
103
|
+
`
|
|
104
|
+
|
|
105
|
+
const projectDependenciesCalleeBarrelSourceBarrel = `export { is } from "typia";
|
|
106
|
+
export { unused } from "./unused";
|
|
107
|
+
`
|
|
108
|
+
|
|
109
|
+
const projectDependenciesCalleeBarrelSourceAlpha = `export interface Alpha {
|
|
110
|
+
id: string;
|
|
111
|
+
}
|
|
112
|
+
`
|
|
113
|
+
|
|
114
|
+
const projectDependenciesCalleeBarrelSourceUnused = `export const unused = (): number => 1;
|
|
115
|
+
`
|