@typia/utils 12.0.0-dev.20260309 → 12.0.0-dev.20260310

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/lib/http/internal/HttpLlmApplicationComposer.mjs +5 -1
  2. package/lib/http/internal/HttpLlmApplicationComposer.mjs.map +1 -1
  3. package/lib/index.mjs +9 -9
  4. package/lib/utils/LlmJson.mjs +9 -2
  5. package/lib/utils/LlmJson.mjs.map +1 -1
  6. package/lib/utils/internal/stringifyValidationFailure.js +17 -15
  7. package/lib/utils/internal/stringifyValidationFailure.js.map +1 -1
  8. package/lib/utils/internal/stringifyValidationFailure.mjs +17 -15
  9. package/lib/utils/internal/stringifyValidationFailure.mjs.map +1 -1
  10. package/lib/validators/internal/OpenApiOneOfValidator.mjs +5 -1
  11. package/lib/validators/internal/OpenApiOneOfValidator.mjs.map +1 -1
  12. package/package.json +2 -2
  13. package/src/converters/LlmSchemaConverter.ts +647 -647
  14. package/src/converters/OpenApiConverter.ts +285 -285
  15. package/src/converters/index.ts +5 -5
  16. package/src/converters/internal/LlmDescriptionInverter.ts +178 -178
  17. package/src/converters/internal/LlmParametersComposer.ts +52 -52
  18. package/src/converters/internal/OpenApiConstraintShifter.ts +154 -154
  19. package/src/converters/internal/OpenApiExclusiveEmender.ts +46 -46
  20. package/src/converters/internal/OpenApiV3Downgrader.ts +355 -355
  21. package/src/converters/internal/OpenApiV3Upgrader.ts +470 -470
  22. package/src/converters/internal/OpenApiV3_1Upgrader.ts +685 -685
  23. package/src/converters/internal/SwaggerV2Downgrader.ts +424 -424
  24. package/src/converters/internal/SwaggerV2Upgrader.ts +523 -523
  25. package/src/http/HttpError.ts +107 -107
  26. package/src/http/HttpLlm.ts +167 -167
  27. package/src/http/HttpMigration.ts +92 -92
  28. package/src/http/index.ts +3 -3
  29. package/src/http/internal/HttpLlmApplicationComposer.ts +361 -361
  30. package/src/http/internal/HttpLlmFunctionFetcher.ts +37 -37
  31. package/src/http/internal/HttpMigrateApplicationComposer.ts +56 -56
  32. package/src/http/internal/HttpMigrateRouteAccessor.ts +135 -135
  33. package/src/http/internal/HttpMigrateRouteComposer.ts +505 -505
  34. package/src/http/internal/HttpMigrateRouteFetcher.ts +203 -203
  35. package/src/index.ts +4 -4
  36. package/src/utils/ArrayUtil.ts +42 -42
  37. package/src/utils/LlmJson.ts +141 -141
  38. package/src/utils/MapUtil.ts +15 -15
  39. package/src/utils/NamingConvention.ts +205 -205
  40. package/src/utils/Singleton.ts +17 -17
  41. package/src/utils/StringUtil.ts +14 -14
  42. package/src/utils/dedent.ts +57 -57
  43. package/src/utils/index.ts +8 -8
  44. package/src/utils/internal/EndpointUtil.ts +44 -44
  45. package/src/utils/internal/JsonDescriptor.ts +70 -70
  46. package/src/utils/internal/OpenApiTypeCheckerBase.ts +822 -822
  47. package/src/utils/internal/coerceLlmArguments.ts +314 -314
  48. package/src/utils/internal/parseLenientJson.ts +894 -894
  49. package/src/utils/internal/stringifyValidationFailure.ts +415 -411
  50. package/src/validators/LlmTypeChecker.ts +402 -402
  51. package/src/validators/OpenApiTypeChecker.ts +297 -297
  52. package/src/validators/OpenApiV3TypeChecker.ts +70 -70
  53. package/src/validators/OpenApiV3_1TypeChecker.ts +86 -86
  54. package/src/validators/OpenApiValidator.ts +94 -94
  55. package/src/validators/SwaggerV2TypeChecker.ts +71 -71
  56. package/src/validators/functional/_isBigintString.ts +8 -8
  57. package/src/validators/functional/_isFormatByte.ts +7 -7
  58. package/src/validators/functional/_isFormatDate.ts +3 -3
  59. package/src/validators/functional/_isFormatDateTime.ts +4 -4
  60. package/src/validators/functional/_isFormatDuration.ts +4 -4
  61. package/src/validators/functional/_isFormatEmail.ts +4 -4
  62. package/src/validators/functional/_isFormatHostname.ts +4 -4
  63. package/src/validators/functional/_isFormatIdnEmail.ts +4 -4
  64. package/src/validators/functional/_isFormatIdnHostname.ts +4 -4
  65. package/src/validators/functional/_isFormatIpv4.ts +4 -4
  66. package/src/validators/functional/_isFormatIpv6.ts +4 -4
  67. package/src/validators/functional/_isFormatIri.ts +3 -3
  68. package/src/validators/functional/_isFormatIriReference.ts +4 -4
  69. package/src/validators/functional/_isFormatJsonPointer.ts +3 -3
  70. package/src/validators/functional/_isFormatPassword.ts +1 -1
  71. package/src/validators/functional/_isFormatRegex.ts +8 -8
  72. package/src/validators/functional/_isFormatRelativeJsonPointer.ts +4 -4
  73. package/src/validators/functional/_isFormatTime.ts +4 -4
  74. package/src/validators/functional/_isFormatUri.ts +6 -6
  75. package/src/validators/functional/_isFormatUriReference.ts +5 -5
  76. package/src/validators/functional/_isFormatUriTemplate.ts +4 -4
  77. package/src/validators/functional/_isFormatUrl.ts +4 -4
  78. package/src/validators/functional/_isFormatUuid.ts +3 -3
  79. package/src/validators/functional/_isUniqueItems.ts +159 -159
  80. package/src/validators/index.ts +14 -14
  81. package/src/validators/internal/IOpenApiValidatorContext.ts +17 -17
  82. package/src/validators/internal/OpenApiArrayValidator.ts +49 -49
  83. package/src/validators/internal/OpenApiBooleanValidator.ts +11 -11
  84. package/src/validators/internal/OpenApiConstantValidator.ts +11 -11
  85. package/src/validators/internal/OpenApiIntegerValidator.ts +49 -49
  86. package/src/validators/internal/OpenApiNumberValidator.ts +48 -48
  87. package/src/validators/internal/OpenApiObjectValidator.ts +83 -83
  88. package/src/validators/internal/OpenApiOneOfValidator.ts +309 -309
  89. package/src/validators/internal/OpenApiSchemaNamingRule.ts +124 -124
  90. package/src/validators/internal/OpenApiStationValidator.ts +115 -115
  91. package/src/validators/internal/OpenApiStringValidator.ts +88 -88
  92. package/src/validators/internal/OpenApiTupleValidator.ts +55 -55
@@ -1,44 +1,44 @@
1
- import { NamingConvention } from "../NamingConvention";
2
-
3
- export namespace EndpointUtil {
4
- export const capitalize = (str: string): string =>
5
- str.length !== 0 ? str[0]!.toUpperCase() + str.slice(1).toLowerCase() : str;
6
-
7
- export const pascal = (path: string): string =>
8
- splitWithNormalization(path)
9
- .filter((str) => str[0] !== "{")
10
- .map(NamingConvention.pascal)
11
- .join("");
12
-
13
- export const splitWithNormalization = (path: string): string[] =>
14
- path
15
- .split("/")
16
- .map((str) => normalize(str.trim()))
17
- .filter((str) => !!str.length);
18
-
19
- export const reJoinWithDecimalParameters = (path: string) => {
20
- path = path
21
- .split("/")
22
- .map((str) =>
23
- str[0] === "{" && str[str.length - 1] === "}"
24
- ? `:${str.substring(1, str.length - 1)}`
25
- : str,
26
- )
27
- .join("/");
28
- return `${path.startsWith("/") ? "" : "/"}${path}`;
29
- };
30
-
31
- export const normalize = (str: string): string => {
32
- str = str.split(".").join("_").split("-").join("_").trim();
33
- if (str.length === 0) return str;
34
- else if (NamingConvention.reserved(str)) return `_${str}`;
35
- else if (str.length !== 0 && "0" <= str[0]! && str[0]! <= "9")
36
- str = `_${str}`;
37
- return str;
38
- };
39
-
40
- export const escapeDuplicate =
41
- (keep: string[]) =>
42
- (change: string): string =>
43
- keep.includes(change) ? escapeDuplicate(keep)(`_${change}`) : change;
44
- }
1
+ import { NamingConvention } from "../NamingConvention";
2
+
3
+ export namespace EndpointUtil {
4
+ export const capitalize = (str: string): string =>
5
+ str.length !== 0 ? str[0]!.toUpperCase() + str.slice(1).toLowerCase() : str;
6
+
7
+ export const pascal = (path: string): string =>
8
+ splitWithNormalization(path)
9
+ .filter((str) => str[0] !== "{")
10
+ .map(NamingConvention.pascal)
11
+ .join("");
12
+
13
+ export const splitWithNormalization = (path: string): string[] =>
14
+ path
15
+ .split("/")
16
+ .map((str) => normalize(str.trim()))
17
+ .filter((str) => !!str.length);
18
+
19
+ export const reJoinWithDecimalParameters = (path: string) => {
20
+ path = path
21
+ .split("/")
22
+ .map((str) =>
23
+ str[0] === "{" && str[str.length - 1] === "}"
24
+ ? `:${str.substring(1, str.length - 1)}`
25
+ : str,
26
+ )
27
+ .join("/");
28
+ return `${path.startsWith("/") ? "" : "/"}${path}`;
29
+ };
30
+
31
+ export const normalize = (str: string): string => {
32
+ str = str.split(".").join("_").split("-").join("_").trim();
33
+ if (str.length === 0) return str;
34
+ else if (NamingConvention.reserved(str)) return `_${str}`;
35
+ else if (str.length !== 0 && "0" <= str[0]! && str[0]! <= "9")
36
+ str = `_${str}`;
37
+ return str;
38
+ };
39
+
40
+ export const escapeDuplicate =
41
+ (keep: string[]) =>
42
+ (change: string): string =>
43
+ keep.includes(change) ? escapeDuplicate(keep)(`_${change}`) : change;
44
+ }
@@ -1,70 +1,70 @@
1
- import { OpenApi } from "@typia/interface";
2
-
3
- import { OpenApiTypeChecker } from "../../validators/OpenApiTypeChecker";
4
- import { NamingConvention } from "../NamingConvention";
5
-
6
- export namespace JsonDescriptor {
7
- export const cascade = (props: {
8
- prefix: string;
9
- components: OpenApi.IComponents;
10
- schema: OpenApi.IJsonSchema.IReference;
11
- escape: boolean;
12
- }): string | undefined => {
13
- const accessors: string[] = (
14
- props.schema.$ref.split(props.prefix)[1] ??
15
- props.schema.$ref.split("/").at(-1)!
16
- ).split(".");
17
- const pReferences: IParentReference[] = accessors
18
- .slice(0, props.escape ? accessors.length : accessors.length - 1)
19
- .map((_, i, array) => array.slice(0, i + 1).join("."))
20
- .map((key) => ({
21
- key,
22
- description: props.components.schemas?.[key]?.description,
23
- }))
24
- .reverse()
25
- .filter(
26
- (schema, i): schema is IParentReference =>
27
- i === 0 || !!schema?.description,
28
- );
29
- if (!props.schema.description?.length && pReferences.length === 0)
30
- return undefined;
31
- return [
32
- ...(!!props.schema.description?.length ? [props.schema.description] : []),
33
- ...pReferences.map((pRef, i) =>
34
- pRef.description === undefined
35
- ? `Current Type: {@link ${pRef.key}}`
36
- : `Description of the ${i === 0 && props.escape ? "current" : "parent"} {@link ${pRef.key}} type:\n\n` +
37
- pRef.description
38
- .split("\n")
39
- .map((str) => `> ${str}`)
40
- .join("\n"),
41
- ),
42
- ].join("\n\n------------------------------\n\n");
43
- };
44
-
45
- export const take = (o: OpenApi.IJsonSchema.IObject): string | undefined => {
46
- const result: string = [
47
- ...(!!o.description?.length ? [o.description] : []),
48
- ...Object.entries(o.properties ?? {})
49
- .filter(
50
- ([_key, value]) =>
51
- OpenApiTypeChecker.isReference(value) &&
52
- !!value.description?.length,
53
- )
54
- .map(
55
- ([key, value]) =>
56
- `### Description of {@link ${NamingConvention.variable(key) ? key : JSON.stringify(key)}} property:\n\n` +
57
- (value.description ?? "")
58
- .split("\n")
59
- .map((str) => `> ${str}`)
60
- .join("\n"),
61
- ),
62
- ].join("\n\n");
63
- return !!result.length ? result : undefined;
64
- };
65
- }
66
-
67
- interface IParentReference {
68
- key: string;
69
- description: string | undefined;
70
- }
1
+ import { OpenApi } from "@typia/interface";
2
+
3
+ import { OpenApiTypeChecker } from "../../validators/OpenApiTypeChecker";
4
+ import { NamingConvention } from "../NamingConvention";
5
+
6
+ export namespace JsonDescriptor {
7
+ export const cascade = (props: {
8
+ prefix: string;
9
+ components: OpenApi.IComponents;
10
+ schema: OpenApi.IJsonSchema.IReference;
11
+ escape: boolean;
12
+ }): string | undefined => {
13
+ const accessors: string[] = (
14
+ props.schema.$ref.split(props.prefix)[1] ??
15
+ props.schema.$ref.split("/").at(-1)!
16
+ ).split(".");
17
+ const pReferences: IParentReference[] = accessors
18
+ .slice(0, props.escape ? accessors.length : accessors.length - 1)
19
+ .map((_, i, array) => array.slice(0, i + 1).join("."))
20
+ .map((key) => ({
21
+ key,
22
+ description: props.components.schemas?.[key]?.description,
23
+ }))
24
+ .reverse()
25
+ .filter(
26
+ (schema, i): schema is IParentReference =>
27
+ i === 0 || !!schema?.description,
28
+ );
29
+ if (!props.schema.description?.length && pReferences.length === 0)
30
+ return undefined;
31
+ return [
32
+ ...(!!props.schema.description?.length ? [props.schema.description] : []),
33
+ ...pReferences.map((pRef, i) =>
34
+ pRef.description === undefined
35
+ ? `Current Type: {@link ${pRef.key}}`
36
+ : `Description of the ${i === 0 && props.escape ? "current" : "parent"} {@link ${pRef.key}} type:\n\n` +
37
+ pRef.description
38
+ .split("\n")
39
+ .map((str) => `> ${str}`)
40
+ .join("\n"),
41
+ ),
42
+ ].join("\n\n------------------------------\n\n");
43
+ };
44
+
45
+ export const take = (o: OpenApi.IJsonSchema.IObject): string | undefined => {
46
+ const result: string = [
47
+ ...(!!o.description?.length ? [o.description] : []),
48
+ ...Object.entries(o.properties ?? {})
49
+ .filter(
50
+ ([_key, value]) =>
51
+ OpenApiTypeChecker.isReference(value) &&
52
+ !!value.description?.length,
53
+ )
54
+ .map(
55
+ ([key, value]) =>
56
+ `### Description of {@link ${NamingConvention.variable(key) ? key : JSON.stringify(key)}} property:\n\n` +
57
+ (value.description ?? "")
58
+ .split("\n")
59
+ .map((str) => `> ${str}`)
60
+ .join("\n"),
61
+ ),
62
+ ].join("\n\n");
63
+ return !!result.length ? result : undefined;
64
+ };
65
+ }
66
+
67
+ interface IParentReference {
68
+ key: string;
69
+ description: string | undefined;
70
+ }