@typia/utils 12.0.0-dev.20260315 → 12.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +85 -85
- package/package.json +2 -2
- package/src/converters/LlmSchemaConverter.ts +617 -617
- package/src/converters/OpenApiConverter.ts +375 -375
- package/src/converters/internal/OpenApiV3Downgrader.ts +381 -381
- package/src/converters/internal/OpenApiV3Upgrader.ts +494 -494
- package/src/converters/internal/OpenApiV3_1Downgrader.ts +318 -318
- package/src/converters/internal/OpenApiV3_1Upgrader.ts +710 -710
- package/src/converters/internal/OpenApiV3_2Upgrader.ts +342 -342
- package/src/converters/internal/SwaggerV2Downgrader.ts +450 -450
- package/src/converters/internal/SwaggerV2Upgrader.ts +547 -547
- package/src/http/HttpError.ts +114 -114
- package/src/http/HttpLlm.ts +169 -169
- package/src/http/HttpMigration.ts +94 -94
- package/src/http/internal/HttpLlmApplicationComposer.ts +360 -360
- package/src/http/internal/HttpMigrateApplicationComposer.ts +56 -56
- package/src/http/internal/HttpMigrateRouteComposer.ts +505 -505
- package/src/utils/LlmJson.ts +173 -173
- package/src/utils/internal/parseLenientJson.ts +919 -919
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
import {
|
|
2
|
-
IHttpMigrateApplication,
|
|
3
|
-
IHttpMigrateRoute,
|
|
4
|
-
OpenApi,
|
|
5
|
-
} from "@typia/interface";
|
|
6
|
-
|
|
7
|
-
import { EndpointUtil } from "../../utils/internal/EndpointUtil";
|
|
8
|
-
import { HttpMigrateRouteAccessor } from "./HttpMigrateRouteAccessor";
|
|
9
|
-
import { HttpMigrateRouteComposer } from "./HttpMigrateRouteComposer";
|
|
10
|
-
|
|
11
|
-
export namespace HttpMigrateApplicationComposer {
|
|
12
|
-
export const compose = (
|
|
13
|
-
document: OpenApi.IDocument,
|
|
14
|
-
): IHttpMigrateApplication => {
|
|
15
|
-
const errors: IHttpMigrateApplication.IError[] = [];
|
|
16
|
-
const entire: Array<IHttpMigrateRoute | null> = Object.entries({
|
|
17
|
-
...(document.paths ?? {}),
|
|
18
|
-
...(document.webhooks ?? {}),
|
|
19
|
-
})
|
|
20
|
-
.map(([path, collection]) =>
|
|
21
|
-
(["head", "get", "post", "put", "patch", "delete", "query"] as const)
|
|
22
|
-
.filter((method) => collection[method] !== undefined)
|
|
23
|
-
.map((method) => {
|
|
24
|
-
const operation: OpenApi.IOperation = collection[method]!;
|
|
25
|
-
const migrated: IHttpMigrateRoute | string[] =
|
|
26
|
-
HttpMigrateRouteComposer.compose({
|
|
27
|
-
document,
|
|
28
|
-
method,
|
|
29
|
-
path,
|
|
30
|
-
emendedPath: EndpointUtil.reJoinWithDecimalParameters(path),
|
|
31
|
-
operation,
|
|
32
|
-
});
|
|
33
|
-
if (Array.isArray(migrated)) {
|
|
34
|
-
errors.push({
|
|
35
|
-
method,
|
|
36
|
-
path,
|
|
37
|
-
operation: () => operation,
|
|
38
|
-
messages: migrated,
|
|
39
|
-
});
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
return migrated;
|
|
43
|
-
}),
|
|
44
|
-
)
|
|
45
|
-
.flat();
|
|
46
|
-
const operations: IHttpMigrateRoute[] = entire.filter(
|
|
47
|
-
(o): o is IHttpMigrateRoute => !!o,
|
|
48
|
-
);
|
|
49
|
-
HttpMigrateRouteAccessor.overwrite(operations);
|
|
50
|
-
return {
|
|
51
|
-
document: () => document,
|
|
52
|
-
routes: operations,
|
|
53
|
-
errors,
|
|
54
|
-
} satisfies IHttpMigrateApplication as IHttpMigrateApplication;
|
|
55
|
-
};
|
|
56
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
IHttpMigrateApplication,
|
|
3
|
+
IHttpMigrateRoute,
|
|
4
|
+
OpenApi,
|
|
5
|
+
} from "@typia/interface";
|
|
6
|
+
|
|
7
|
+
import { EndpointUtil } from "../../utils/internal/EndpointUtil";
|
|
8
|
+
import { HttpMigrateRouteAccessor } from "./HttpMigrateRouteAccessor";
|
|
9
|
+
import { HttpMigrateRouteComposer } from "./HttpMigrateRouteComposer";
|
|
10
|
+
|
|
11
|
+
export namespace HttpMigrateApplicationComposer {
|
|
12
|
+
export const compose = (
|
|
13
|
+
document: OpenApi.IDocument,
|
|
14
|
+
): IHttpMigrateApplication => {
|
|
15
|
+
const errors: IHttpMigrateApplication.IError[] = [];
|
|
16
|
+
const entire: Array<IHttpMigrateRoute | null> = Object.entries({
|
|
17
|
+
...(document.paths ?? {}),
|
|
18
|
+
...(document.webhooks ?? {}),
|
|
19
|
+
})
|
|
20
|
+
.map(([path, collection]) =>
|
|
21
|
+
(["head", "get", "post", "put", "patch", "delete", "query"] as const)
|
|
22
|
+
.filter((method) => collection[method] !== undefined)
|
|
23
|
+
.map((method) => {
|
|
24
|
+
const operation: OpenApi.IOperation = collection[method]!;
|
|
25
|
+
const migrated: IHttpMigrateRoute | string[] =
|
|
26
|
+
HttpMigrateRouteComposer.compose({
|
|
27
|
+
document,
|
|
28
|
+
method,
|
|
29
|
+
path,
|
|
30
|
+
emendedPath: EndpointUtil.reJoinWithDecimalParameters(path),
|
|
31
|
+
operation,
|
|
32
|
+
});
|
|
33
|
+
if (Array.isArray(migrated)) {
|
|
34
|
+
errors.push({
|
|
35
|
+
method,
|
|
36
|
+
path,
|
|
37
|
+
operation: () => operation,
|
|
38
|
+
messages: migrated,
|
|
39
|
+
});
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
return migrated;
|
|
43
|
+
}),
|
|
44
|
+
)
|
|
45
|
+
.flat();
|
|
46
|
+
const operations: IHttpMigrateRoute[] = entire.filter(
|
|
47
|
+
(o): o is IHttpMigrateRoute => !!o,
|
|
48
|
+
);
|
|
49
|
+
HttpMigrateRouteAccessor.overwrite(operations);
|
|
50
|
+
return {
|
|
51
|
+
document: () => document,
|
|
52
|
+
routes: operations,
|
|
53
|
+
errors,
|
|
54
|
+
} satisfies IHttpMigrateApplication as IHttpMigrateApplication;
|
|
55
|
+
};
|
|
56
|
+
}
|