@duplojs/http 0.7.0 → 0.7.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/dist/client/queryToString.cjs +2 -2
- package/dist/client/queryToString.mjs +2 -2
- package/dist/client/types/clientRequestParams.d.ts +9 -3
- package/dist/client/types/serverRoute.d.ts +9 -3
- package/dist/plugins/codeGenerator/plugin.cjs +3 -0
- package/dist/plugins/codeGenerator/plugin.mjs +4 -1
- package/dist/plugins/codeGenerator/typescriptTransfomer.cjs +19 -0
- package/dist/plugins/codeGenerator/typescriptTransfomer.d.ts +4 -1
- package/dist/plugins/codeGenerator/typescriptTransfomer.mjs +18 -1
- package/dist/plugins/openApiGenerator/routeToOpenApi.cjs +1 -6
- package/dist/plugins/openApiGenerator/routeToOpenApi.mjs +1 -6
- package/package.json +3 -3
|
@@ -11,11 +11,11 @@ function queryToString(query) {
|
|
|
11
11
|
}
|
|
12
12
|
if (value instanceof Array) {
|
|
13
13
|
value.forEach((subValue) => {
|
|
14
|
-
pv.push(`${key}=${subValue}`);
|
|
14
|
+
pv.push(`${key}=${subValue.toString()}`);
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
17
|
else {
|
|
18
|
-
pv.push(`${key}=${value}`);
|
|
18
|
+
pv.push(`${key}=${value.toString()}`);
|
|
19
19
|
}
|
|
20
20
|
return pv;
|
|
21
21
|
}, [])
|
|
@@ -9,11 +9,11 @@ function queryToString(query) {
|
|
|
9
9
|
}
|
|
10
10
|
if (value instanceof Array) {
|
|
11
11
|
value.forEach((subValue) => {
|
|
12
|
-
pv.push(`${key}=${subValue}`);
|
|
12
|
+
pv.push(`${key}=${subValue.toString()}`);
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
else {
|
|
16
|
-
pv.push(`${key}=${value}`);
|
|
16
|
+
pv.push(`${key}=${value.toString()}`);
|
|
17
17
|
}
|
|
18
18
|
return pv;
|
|
19
19
|
}, [])
|
|
@@ -4,9 +4,15 @@ import { type ObjectCanBeEmpty } from "./ObjectCanBeEmpty";
|
|
|
4
4
|
import type * as OO from "@duplojs/utils/object";
|
|
5
5
|
export interface ClientRequestInitParams extends Pick<RequestInit, "cache" | "credentials" | "integrity" | "keepalive" | "mode" | "redirect" | "referrer" | "referrerPolicy" | "signal"> {
|
|
6
6
|
}
|
|
7
|
-
export type ClientRequestParamsHeaders = Record<string, string | undefined
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
export type ClientRequestParamsHeaders = Record<string, string | undefined | {
|
|
8
|
+
toString(): string;
|
|
9
|
+
}>;
|
|
10
|
+
export type ClientRequestParamsParams = Record<string, string | undefined | {
|
|
11
|
+
toString(): string;
|
|
12
|
+
}>;
|
|
13
|
+
export type ClientRequestParamsQuery = Record<string, MaybeArray<string | {
|
|
14
|
+
toString(): string;
|
|
15
|
+
}> | undefined>;
|
|
10
16
|
export type ClientRequestParamsBody = unknown;
|
|
11
17
|
export interface ClientRequestParams<GenericHookParams extends Record<string, unknown> = Record<string, unknown>> {
|
|
12
18
|
method: string;
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { type SimplifyTopLevel, type MaybeArray, type IsEqual } from "@duplojs/utils";
|
|
2
2
|
import type * as SS from "@duplojs/utils/string";
|
|
3
3
|
export type ServerPrimitiveData = string | undefined | number | null | boolean;
|
|
4
|
-
export type ServerRouteHeaders = Record<string, ServerPrimitiveData
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
export type ServerRouteHeaders = Record<string, ServerPrimitiveData | {
|
|
5
|
+
toString(): string;
|
|
6
|
+
}>;
|
|
7
|
+
export type ServerRouteParams = Record<string, ServerPrimitiveData | {
|
|
8
|
+
toString(): string;
|
|
9
|
+
}>;
|
|
10
|
+
export type ServerRouteQuery = Record<string, MaybeArray<ServerPrimitiveData | {
|
|
11
|
+
toString(): string;
|
|
12
|
+
}>>;
|
|
7
13
|
export type ServerRouteBody = unknown;
|
|
8
14
|
export type ServerRouteResponseBody = unknown;
|
|
9
15
|
export interface ServerRouteResponse {
|
|
@@ -43,8 +43,11 @@ function codeGeneratorPlugin(pluginParams) {
|
|
|
43
43
|
}
|
|
44
44
|
const output = DataParserToTypescript__namespace.render(utils.DP.union(dataParserRoutes), {
|
|
45
45
|
identifier: "Routes",
|
|
46
|
+
mode: "in",
|
|
46
47
|
transformers: [
|
|
47
48
|
typescriptTransfomer.fileTransformer,
|
|
49
|
+
typescriptTransfomer.dateTransformer,
|
|
50
|
+
typescriptTransfomer.timeTransformer,
|
|
48
51
|
...DataParserToTypescript__namespace.defaultTransformers,
|
|
49
52
|
],
|
|
50
53
|
});
|
|
@@ -2,7 +2,7 @@ import * as DataParserToTypescript from '@duplojs/data-parser-tools/toTypescript
|
|
|
2
2
|
import { equal, A, DP, asserts, E } from '@duplojs/utils';
|
|
3
3
|
import { routeToDataParser } from './routeToDataParser.mjs';
|
|
4
4
|
import { SF } from '@duplojs/server-utils';
|
|
5
|
-
import { fileTransformer } from './typescriptTransfomer.mjs';
|
|
5
|
+
import { fileTransformer, dateTransformer, timeTransformer } from './typescriptTransfomer.mjs';
|
|
6
6
|
|
|
7
7
|
function codeGeneratorPlugin(pluginParams) {
|
|
8
8
|
return () => ({
|
|
@@ -22,8 +22,11 @@ function codeGeneratorPlugin(pluginParams) {
|
|
|
22
22
|
}
|
|
23
23
|
const output = DataParserToTypescript.render(DP.union(dataParserRoutes), {
|
|
24
24
|
identifier: "Routes",
|
|
25
|
+
mode: "in",
|
|
25
26
|
transformers: [
|
|
26
27
|
fileTransformer,
|
|
28
|
+
dateTransformer,
|
|
29
|
+
timeTransformer,
|
|
27
30
|
...DataParserToTypescript.defaultTransformers,
|
|
28
31
|
],
|
|
29
32
|
});
|
|
@@ -2,8 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
var DataParserToTypescript = require('@duplojs/data-parser-tools/toTypescript');
|
|
4
4
|
var serverUtils = require('@duplojs/server-utils');
|
|
5
|
+
var utils = require('@duplojs/utils');
|
|
5
6
|
var typescript = require('typescript');
|
|
6
7
|
|
|
7
8
|
const fileTransformer = DataParserToTypescript.createTransformer(serverUtils.SDP.fileKind.has, (__, { success }) => success(typescript.factory.createTypeReferenceNode("File")));
|
|
9
|
+
const dateTransformer = DataParserToTypescript.createTransformer(utils.DP.dateKind.has, (__, { success, addImport }) => {
|
|
10
|
+
addImport("@duplojs/utils/date", "TheDate");
|
|
11
|
+
addImport("@duplojs/utils/date", "SerializedTheDate");
|
|
12
|
+
return success(typescript.factory.createUnionTypeNode([
|
|
13
|
+
typescript.factory.createTypeReferenceNode(typescript.factory.createIdentifier("SerializedTheDate")),
|
|
14
|
+
typescript.factory.createTypeReferenceNode(typescript.factory.createIdentifier("TheDate")),
|
|
15
|
+
]));
|
|
16
|
+
});
|
|
17
|
+
const timeTransformer = DataParserToTypescript.createTransformer(utils.DP.timeKind.has, (__, { success, addImport }) => {
|
|
18
|
+
addImport("@duplojs/utils/date", "TheTime");
|
|
19
|
+
addImport("@duplojs/utils/date", "SerializedTheTime");
|
|
20
|
+
return success(typescript.factory.createUnionTypeNode([
|
|
21
|
+
typescript.factory.createTypeReferenceNode(typescript.factory.createIdentifier("SerializedTheTime")),
|
|
22
|
+
typescript.factory.createTypeReferenceNode(typescript.factory.createIdentifier("TheTime")),
|
|
23
|
+
]));
|
|
24
|
+
});
|
|
8
25
|
|
|
26
|
+
exports.dateTransformer = dateTransformer;
|
|
9
27
|
exports.fileTransformer = fileTransformer;
|
|
28
|
+
exports.timeTransformer = timeTransformer;
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { DP } from "@duplojs/utils";
|
|
2
|
+
export declare const fileTransformer: (schema: DP.DataParsers, params: import("@duplojs/data-parser-tools/toTypescript").TransformerParams) => import("@duplojs/data-parser-tools/toTypescript").MaybeTransformerEither;
|
|
3
|
+
export declare const dateTransformer: (schema: DP.DataParsers, params: import("@duplojs/data-parser-tools/toTypescript").TransformerParams) => import("@duplojs/data-parser-tools/toTypescript").MaybeTransformerEither;
|
|
4
|
+
export declare const timeTransformer: (schema: DP.DataParsers, params: import("@duplojs/data-parser-tools/toTypescript").TransformerParams) => import("@duplojs/data-parser-tools/toTypescript").MaybeTransformerEither;
|
|
@@ -1,7 +1,24 @@
|
|
|
1
1
|
import { createTransformer } from '@duplojs/data-parser-tools/toTypescript';
|
|
2
2
|
import { SDP } from '@duplojs/server-utils';
|
|
3
|
+
import { DP } from '@duplojs/utils';
|
|
3
4
|
import { factory } from 'typescript';
|
|
4
5
|
|
|
5
6
|
const fileTransformer = createTransformer(SDP.fileKind.has, (__, { success }) => success(factory.createTypeReferenceNode("File")));
|
|
7
|
+
const dateTransformer = createTransformer(DP.dateKind.has, (__, { success, addImport }) => {
|
|
8
|
+
addImport("@duplojs/utils/date", "TheDate");
|
|
9
|
+
addImport("@duplojs/utils/date", "SerializedTheDate");
|
|
10
|
+
return success(factory.createUnionTypeNode([
|
|
11
|
+
factory.createTypeReferenceNode(factory.createIdentifier("SerializedTheDate")),
|
|
12
|
+
factory.createTypeReferenceNode(factory.createIdentifier("TheDate")),
|
|
13
|
+
]));
|
|
14
|
+
});
|
|
15
|
+
const timeTransformer = createTransformer(DP.timeKind.has, (__, { success, addImport }) => {
|
|
16
|
+
addImport("@duplojs/utils/date", "TheTime");
|
|
17
|
+
addImport("@duplojs/utils/date", "SerializedTheTime");
|
|
18
|
+
return success(factory.createUnionTypeNode([
|
|
19
|
+
factory.createTypeReferenceNode(factory.createIdentifier("SerializedTheTime")),
|
|
20
|
+
factory.createTypeReferenceNode(factory.createIdentifier("TheTime")),
|
|
21
|
+
]));
|
|
22
|
+
});
|
|
6
23
|
|
|
7
|
-
export { fileTransformer };
|
|
24
|
+
export { dateTransformer, fileTransformer, timeTransformer };
|
|
@@ -12,7 +12,7 @@ function factoryJsonSchema(params) {
|
|
|
12
12
|
?? `NotIdentified${params.resultSchemaContext.size}`;
|
|
13
13
|
const renderResult = toJsonSchema.render(params.schema, {
|
|
14
14
|
identifier,
|
|
15
|
-
mode:
|
|
15
|
+
mode: "in",
|
|
16
16
|
context: params.context,
|
|
17
17
|
version: "openApi31",
|
|
18
18
|
transformers: toJsonSchema.defaultTransformers,
|
|
@@ -57,7 +57,6 @@ function routeToOpenApi(route, params) {
|
|
|
57
57
|
schema: factoryJsonSchema({
|
|
58
58
|
context: params.contextToJsonSchemaFactory,
|
|
59
59
|
resultSchemaContext: params.resultSchemaContext,
|
|
60
|
-
mode: "in",
|
|
61
60
|
schema,
|
|
62
61
|
}),
|
|
63
62
|
}))));
|
|
@@ -68,7 +67,6 @@ function routeToOpenApi(route, params) {
|
|
|
68
67
|
schema: factoryJsonSchema({
|
|
69
68
|
context: params.contextToJsonSchemaFactory,
|
|
70
69
|
resultSchemaContext: params.resultSchemaContext,
|
|
71
|
-
mode: "in",
|
|
72
70
|
schema: objectSchema,
|
|
73
71
|
}),
|
|
74
72
|
},
|
|
@@ -80,7 +78,6 @@ function routeToOpenApi(route, params) {
|
|
|
80
78
|
schema: factoryJsonSchema({
|
|
81
79
|
context: params.contextToJsonSchemaFactory,
|
|
82
80
|
resultSchemaContext: params.resultSchemaContext,
|
|
83
|
-
mode: "in",
|
|
84
81
|
schema: objectSchema,
|
|
85
82
|
}),
|
|
86
83
|
},
|
|
@@ -92,7 +89,6 @@ function routeToOpenApi(route, params) {
|
|
|
92
89
|
schema: factoryJsonSchema({
|
|
93
90
|
context: params.contextToJsonSchemaFactory,
|
|
94
91
|
resultSchemaContext: params.resultSchemaContext,
|
|
95
|
-
mode: "in",
|
|
96
92
|
schema: primitiveSchema,
|
|
97
93
|
}),
|
|
98
94
|
},
|
|
@@ -103,7 +99,6 @@ function routeToOpenApi(route, params) {
|
|
|
103
99
|
? factoryJsonSchema({
|
|
104
100
|
context: params.contextToJsonSchemaFactory,
|
|
105
101
|
resultSchemaContext: params.resultSchemaContext,
|
|
106
|
-
mode: "in",
|
|
107
102
|
schema: body,
|
|
108
103
|
})
|
|
109
104
|
: undefined;
|
|
@@ -10,7 +10,7 @@ function factoryJsonSchema(params) {
|
|
|
10
10
|
?? `NotIdentified${params.resultSchemaContext.size}`;
|
|
11
11
|
const renderResult = render(params.schema, {
|
|
12
12
|
identifier,
|
|
13
|
-
mode:
|
|
13
|
+
mode: "in",
|
|
14
14
|
context: params.context,
|
|
15
15
|
version: "openApi31",
|
|
16
16
|
transformers: defaultTransformers,
|
|
@@ -55,7 +55,6 @@ function routeToOpenApi(route, params) {
|
|
|
55
55
|
schema: factoryJsonSchema({
|
|
56
56
|
context: params.contextToJsonSchemaFactory,
|
|
57
57
|
resultSchemaContext: params.resultSchemaContext,
|
|
58
|
-
mode: "in",
|
|
59
58
|
schema,
|
|
60
59
|
}),
|
|
61
60
|
}))));
|
|
@@ -66,7 +65,6 @@ function routeToOpenApi(route, params) {
|
|
|
66
65
|
schema: factoryJsonSchema({
|
|
67
66
|
context: params.contextToJsonSchemaFactory,
|
|
68
67
|
resultSchemaContext: params.resultSchemaContext,
|
|
69
|
-
mode: "in",
|
|
70
68
|
schema: objectSchema,
|
|
71
69
|
}),
|
|
72
70
|
},
|
|
@@ -78,7 +76,6 @@ function routeToOpenApi(route, params) {
|
|
|
78
76
|
schema: factoryJsonSchema({
|
|
79
77
|
context: params.contextToJsonSchemaFactory,
|
|
80
78
|
resultSchemaContext: params.resultSchemaContext,
|
|
81
|
-
mode: "in",
|
|
82
79
|
schema: objectSchema,
|
|
83
80
|
}),
|
|
84
81
|
},
|
|
@@ -90,7 +87,6 @@ function routeToOpenApi(route, params) {
|
|
|
90
87
|
schema: factoryJsonSchema({
|
|
91
88
|
context: params.contextToJsonSchemaFactory,
|
|
92
89
|
resultSchemaContext: params.resultSchemaContext,
|
|
93
|
-
mode: "in",
|
|
94
90
|
schema: primitiveSchema,
|
|
95
91
|
}),
|
|
96
92
|
},
|
|
@@ -101,7 +97,6 @@ function routeToOpenApi(route, params) {
|
|
|
101
97
|
? factoryJsonSchema({
|
|
102
98
|
context: params.contextToJsonSchemaFactory,
|
|
103
99
|
resultSchemaContext: params.resultSchemaContext,
|
|
104
|
-
mode: "in",
|
|
105
100
|
schema: body,
|
|
106
101
|
})
|
|
107
102
|
: undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@duplojs/http",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"author": "mathcovax",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -65,9 +65,9 @@
|
|
|
65
65
|
"README.md"
|
|
66
66
|
],
|
|
67
67
|
"peerDependencies": {
|
|
68
|
-
"@duplojs/data-parser-tools": ">=0.2.
|
|
68
|
+
"@duplojs/data-parser-tools": ">=0.2.8 <1.0.0",
|
|
69
69
|
"@duplojs/server-utils": ">=0.2.0 <1.0.0",
|
|
70
|
-
"@duplojs/utils": ">=1.5.
|
|
70
|
+
"@duplojs/utils": ">=1.5.6 <2.0.0"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"@commitlint/cli": "19.8.1",
|