@duplojs/http 0.9.5 → 0.11.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/dist/client/clientCache.cjs +84 -0
- package/dist/client/clientCache.d.ts +4 -0
- package/dist/client/clientCache.mjs +80 -0
- package/dist/client/getBody.cjs +0 -3
- package/dist/client/getBody.mjs +0 -3
- package/dist/client/hooks.cjs +36 -0
- package/dist/client/hooks.d.ts +5 -1
- package/dist/client/hooks.mjs +33 -1
- package/dist/client/httpClient.cjs +26 -1
- package/dist/client/httpClient.d.ts +8 -1
- package/dist/client/httpClient.mjs +26 -1
- package/dist/client/index.cjs +12 -0
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.mjs +4 -2
- package/dist/client/promiseRequest.cjs +33 -8
- package/dist/client/promiseRequest.d.ts +2 -1
- package/dist/client/promiseRequest.mjs +34 -9
- package/dist/client/serverSentEvents.cjs +18 -12
- package/dist/client/serverSentEvents.d.ts +2 -1
- package/dist/client/serverSentEvents.mjs +18 -13
- package/dist/client/stream.cjs +117 -0
- package/dist/client/stream.d.ts +3 -0
- package/dist/client/stream.mjs +95 -0
- package/dist/client/types/clientCache.cjs +2 -0
- package/dist/client/types/clientCache.d.ts +27 -0
- package/dist/client/types/clientCache.mjs +1 -0
- package/dist/client/types/clientRequestParams.d.ts +8 -1
- package/dist/client/types/clientResponse.d.ts +24 -6
- package/dist/client/types/hooks.d.ts +10 -1
- package/dist/client/types/index.cjs +1 -0
- package/dist/client/types/index.d.ts +1 -0
- package/dist/client/types/index.mjs +1 -0
- package/dist/client/types/promiseRequestParams.d.ts +3 -0
- package/dist/client/types/serverRoute.d.ts +2 -0
- package/dist/core/builders/route/handler.d.ts +5 -5
- package/dist/core/defaultHooks/index.cjs +14 -0
- package/dist/core/defaultHooks/index.mjs +14 -0
- package/dist/core/functionsBuilders/steps/defaults/extractStep.mjs +1 -1
- package/dist/core/functionsBuilders/steps/defaults/handlerStep.cjs +33 -0
- package/dist/core/functionsBuilders/steps/defaults/handlerStep.mjs +33 -0
- package/dist/core/hub/defaultMalformedUrlHandler.d.ts +1 -1
- package/dist/core/hub/defaultNotfoundHandler.d.ts +1 -1
- package/dist/core/index.cjs +143 -134
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.mjs +42 -39
- package/dist/core/response/contract.cjs +21 -0
- package/dist/core/response/contract.d.ts +33 -5
- package/dist/core/response/contract.mjs +21 -0
- package/dist/core/response/index.cjs +4 -0
- package/dist/core/response/index.d.ts +7 -0
- package/dist/core/response/index.mjs +2 -0
- package/dist/core/response/streamPredicted.cjs +23 -0
- package/dist/core/response/streamPredicted.d.ts +14 -0
- package/dist/core/response/streamPredicted.mjs +21 -0
- package/dist/core/response/streamTextPredicted.cjs +23 -0
- package/dist/core/response/streamTextPredicted.d.ts +14 -0
- package/dist/core/response/streamTextPredicted.mjs +21 -0
- package/dist/core/serverSentEvents.cjs +25 -77
- package/dist/core/serverSentEvents.d.ts +4 -16
- package/dist/core/serverSentEvents.mjs +25 -77
- package/dist/core/steps/handler.d.ts +15 -5
- package/dist/core/stream.cjs +73 -0
- package/dist/core/stream.d.ts +19 -0
- package/dist/core/stream.mjs +73 -0
- package/dist/interfaces/node/bodyReaders/formData/index.cjs +1 -1
- package/dist/interfaces/node/bodyReaders/formData/index.mjs +1 -1
- package/dist/interfaces/node/hooks/index.cjs +21 -1
- package/dist/interfaces/node/hooks/index.mjs +21 -1
- package/dist/interfaces/node/index.cjs +6 -6
- package/dist/interfaces/node/index.mjs +2 -2
- package/dist/plugins/codeGenerator/aggregateStepContract.cjs +12 -0
- package/dist/plugins/codeGenerator/aggregateStepContract.mjs +13 -1
- package/dist/plugins/cookie/hooks/cookieHooks.cjs +15 -0
- package/dist/plugins/cookie/hooks/cookieHooks.d.ts +11 -0
- package/dist/plugins/cookie/hooks/cookieHooks.mjs +13 -0
- package/dist/plugins/cookie/hooks/index.cjs +11 -0
- package/dist/plugins/cookie/hooks/index.d.ts +3 -0
- package/dist/plugins/cookie/hooks/index.mjs +3 -0
- package/dist/plugins/cookie/hooks/parseRequestCookie.cjs +20 -0
- package/dist/plugins/cookie/hooks/parseRequestCookie.d.ts +8 -0
- package/dist/plugins/cookie/hooks/parseRequestCookie.mjs +18 -0
- package/dist/plugins/cookie/hooks/serializeResponseCookie.cjs +17 -0
- package/dist/plugins/cookie/hooks/serializeResponseCookie.d.ts +7 -0
- package/dist/plugins/cookie/hooks/serializeResponseCookie.mjs +15 -0
- package/dist/plugins/cookie/index.cjs +25 -0
- package/dist/plugins/cookie/index.d.ts +6 -0
- package/dist/plugins/cookie/index.mjs +9 -0
- package/dist/plugins/cookie/kind.cjs +9 -0
- package/dist/plugins/cookie/kind.d.ts +6 -0
- package/dist/plugins/cookie/kind.mjs +7 -0
- package/dist/plugins/cookie/metadata.cjs +8 -0
- package/dist/plugins/cookie/metadata.d.ts +1 -0
- package/dist/plugins/cookie/metadata.mjs +6 -0
- package/dist/plugins/cookie/override.cjs +30 -0
- package/dist/plugins/cookie/override.d.ts +16 -0
- package/dist/plugins/cookie/override.mjs +28 -0
- package/dist/plugins/cookie/parser.cjs +84 -0
- package/dist/plugins/cookie/parser.d.ts +2 -0
- package/dist/plugins/cookie/parser.mjs +79 -0
- package/dist/plugins/cookie/plugin.cjs +30 -0
- package/dist/plugins/cookie/plugin.d.ts +8 -0
- package/dist/plugins/cookie/plugin.mjs +28 -0
- package/dist/plugins/cookie/serialize.cjs +84 -0
- package/dist/plugins/cookie/serialize.d.ts +29 -0
- package/dist/plugins/cookie/serialize.mjs +81 -0
- package/dist/plugins/openApiGenerator/aggregateStepContract.d.ts +1 -1
- package/dist/plugins/openApiGenerator/makeOpenApiRoute.d.ts +1 -1
- package/dist/plugins/openApiGenerator/routeToOpenApi.cjs +55 -2
- package/dist/plugins/openApiGenerator/routeToOpenApi.mjs +55 -2
- package/dist/plugins/openApiGenerator/types/endpointResponse.d.ts +4 -1
- package/dist/plugins/static/makeRouteFile.d.ts +1 -1
- package/dist/plugins/static/makeRouteFolder.d.ts +1 -1
- package/package.json +10 -5
|
@@ -5,7 +5,7 @@ import type { EntrypointKey } from "./types";
|
|
|
5
5
|
export type EntrypointReduceResult = Record<EntrypointKey, DP.DataParser | Record<string, DP.DataParser>>;
|
|
6
6
|
export interface AggregateStepsResult {
|
|
7
7
|
entrypointContract: EntrypointReduceResult;
|
|
8
|
-
endpointContract:
|
|
8
|
+
endpointContract: ResponseContract.Contracts[];
|
|
9
9
|
}
|
|
10
10
|
export interface AggregateStepsParams {
|
|
11
11
|
readonly defaultExtractContract: ResponseContract.Contract;
|
|
@@ -17,7 +17,7 @@ export declare function makeOpenApiRoute(routePath: RoutePath, openApiPage: stri
|
|
|
17
17
|
readonly coerce: boolean;
|
|
18
18
|
readonly checkers: readonly [];
|
|
19
19
|
}>>>;
|
|
20
|
-
theFunction(floor: {},
|
|
20
|
+
theFunction(floor: {}, params: import("../../core/steps").HandlerStepFunctionParams<import("../../core/response").PredictedResponse<"200", "swaggerUi", string>>): import("@duplojs/utils").MaybePromise<import("../../core/response").PredictedResponse<"200", "swaggerUi", string>>;
|
|
21
21
|
readonly metadata: readonly [];
|
|
22
22
|
}>];
|
|
23
23
|
}>;
|
|
@@ -161,19 +161,72 @@ function routeToOpenApi(route, params) {
|
|
|
161
161
|
},
|
|
162
162
|
});
|
|
163
163
|
}
|
|
164
|
+
if (contract.ResponseContract.streamContractKind.has(contract$1)) {
|
|
165
|
+
const lastContent = lastValue[code]?.content;
|
|
166
|
+
const schema = {
|
|
167
|
+
type: "string",
|
|
168
|
+
format: "binary",
|
|
169
|
+
};
|
|
170
|
+
const content = {
|
|
171
|
+
...lastContent,
|
|
172
|
+
"application/octet-stream": {
|
|
173
|
+
schema: lastContent?.["application/octet-stream"]
|
|
174
|
+
? {
|
|
175
|
+
anyOf: [
|
|
176
|
+
lastContent["application/octet-stream"].schema,
|
|
177
|
+
schema,
|
|
178
|
+
],
|
|
179
|
+
}
|
|
180
|
+
: schema,
|
|
181
|
+
},
|
|
182
|
+
};
|
|
183
|
+
return nextWithObject(lastValue, {
|
|
184
|
+
[code]: {
|
|
185
|
+
headers,
|
|
186
|
+
content,
|
|
187
|
+
},
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
if (contract.ResponseContract.streamTextContractKind.has(contract$1)) {
|
|
191
|
+
const lastContent = lastValue[code]?.content;
|
|
192
|
+
const schema = factoryJsonSchema({
|
|
193
|
+
context: params.contextToJsonSchemaFactory,
|
|
194
|
+
resultSchemaContext: params.resultSchemaContext,
|
|
195
|
+
schema: contract$1.flux,
|
|
196
|
+
});
|
|
197
|
+
const content = {
|
|
198
|
+
...lastContent,
|
|
199
|
+
"text/plain": {
|
|
200
|
+
schema: lastContent?.["text/plain"]
|
|
201
|
+
? {
|
|
202
|
+
anyOf: [
|
|
203
|
+
lastContent["text/plain"].schema,
|
|
204
|
+
schema,
|
|
205
|
+
],
|
|
206
|
+
}
|
|
207
|
+
: schema,
|
|
208
|
+
},
|
|
209
|
+
};
|
|
210
|
+
return nextWithObject(lastValue, {
|
|
211
|
+
[code]: {
|
|
212
|
+
headers,
|
|
213
|
+
content,
|
|
214
|
+
},
|
|
215
|
+
});
|
|
216
|
+
}
|
|
164
217
|
const schemaResponse = factoryJsonSchema({
|
|
165
218
|
context: params.contextToJsonSchemaFactory,
|
|
166
219
|
resultSchemaContext: params.resultSchemaContext,
|
|
167
220
|
schema: body,
|
|
168
221
|
});
|
|
169
222
|
const content = utils.pipe(body, utils.P.when(utils.DP.identifier(utils.DP.emptyKind), utils.justReturn(lastValue[code]?.content)), utils.P.otherwise((value) => {
|
|
170
|
-
if (utils.DP.identifier(value, utils.DP.stringKind) && lastValue[code]?.content?.["plain
|
|
223
|
+
if (utils.DP.identifier(value, utils.DP.stringKind) && lastValue[code]?.content?.["text/plain"]) {
|
|
171
224
|
return lastValue[code].content;
|
|
172
225
|
}
|
|
173
226
|
if (utils.DP.identifier(value, utils.DP.stringKind)) {
|
|
174
227
|
return {
|
|
175
228
|
...lastValue[code]?.content,
|
|
176
|
-
"plain
|
|
229
|
+
"text/plain": {
|
|
177
230
|
schema: schemaResponse,
|
|
178
231
|
},
|
|
179
232
|
};
|
|
@@ -159,19 +159,72 @@ function routeToOpenApi(route, params) {
|
|
|
159
159
|
},
|
|
160
160
|
});
|
|
161
161
|
}
|
|
162
|
+
if (ResponseContract.streamContractKind.has(contract)) {
|
|
163
|
+
const lastContent = lastValue[code]?.content;
|
|
164
|
+
const schema = {
|
|
165
|
+
type: "string",
|
|
166
|
+
format: "binary",
|
|
167
|
+
};
|
|
168
|
+
const content = {
|
|
169
|
+
...lastContent,
|
|
170
|
+
"application/octet-stream": {
|
|
171
|
+
schema: lastContent?.["application/octet-stream"]
|
|
172
|
+
? {
|
|
173
|
+
anyOf: [
|
|
174
|
+
lastContent["application/octet-stream"].schema,
|
|
175
|
+
schema,
|
|
176
|
+
],
|
|
177
|
+
}
|
|
178
|
+
: schema,
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
return nextWithObject(lastValue, {
|
|
182
|
+
[code]: {
|
|
183
|
+
headers,
|
|
184
|
+
content,
|
|
185
|
+
},
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
if (ResponseContract.streamTextContractKind.has(contract)) {
|
|
189
|
+
const lastContent = lastValue[code]?.content;
|
|
190
|
+
const schema = factoryJsonSchema({
|
|
191
|
+
context: params.contextToJsonSchemaFactory,
|
|
192
|
+
resultSchemaContext: params.resultSchemaContext,
|
|
193
|
+
schema: contract.flux,
|
|
194
|
+
});
|
|
195
|
+
const content = {
|
|
196
|
+
...lastContent,
|
|
197
|
+
"text/plain": {
|
|
198
|
+
schema: lastContent?.["text/plain"]
|
|
199
|
+
? {
|
|
200
|
+
anyOf: [
|
|
201
|
+
lastContent["text/plain"].schema,
|
|
202
|
+
schema,
|
|
203
|
+
],
|
|
204
|
+
}
|
|
205
|
+
: schema,
|
|
206
|
+
},
|
|
207
|
+
};
|
|
208
|
+
return nextWithObject(lastValue, {
|
|
209
|
+
[code]: {
|
|
210
|
+
headers,
|
|
211
|
+
content,
|
|
212
|
+
},
|
|
213
|
+
});
|
|
214
|
+
}
|
|
162
215
|
const schemaResponse = factoryJsonSchema({
|
|
163
216
|
context: params.contextToJsonSchemaFactory,
|
|
164
217
|
resultSchemaContext: params.resultSchemaContext,
|
|
165
218
|
schema: body,
|
|
166
219
|
});
|
|
167
220
|
const content = pipe(body, P.when(DP.identifier(DP.emptyKind), justReturn(lastValue[code]?.content)), P.otherwise((value) => {
|
|
168
|
-
if (DP.identifier(value, DP.stringKind) && lastValue[code]?.content?.["plain
|
|
221
|
+
if (DP.identifier(value, DP.stringKind) && lastValue[code]?.content?.["text/plain"]) {
|
|
169
222
|
return lastValue[code].content;
|
|
170
223
|
}
|
|
171
224
|
if (DP.identifier(value, DP.stringKind)) {
|
|
172
225
|
return {
|
|
173
226
|
...lastValue[code]?.content,
|
|
174
|
-
"plain
|
|
227
|
+
"text/plain": {
|
|
175
228
|
schema: schemaResponse,
|
|
176
229
|
},
|
|
177
230
|
};
|
|
@@ -41,7 +41,7 @@ export declare function makeRouteFile(params: MakeRouteFileParams): import("../.
|
|
|
41
41
|
readonly checkExist: boolean;
|
|
42
42
|
readonly checkers: readonly [];
|
|
43
43
|
}>>>, NoInfer<ResponseContract.Contract<"304", "resource.notModified", import("@duplojs/utils/dataParser").DataParserEmpty<import("@duplojs/utils/dataParser").DataParserDefinitionEmpty>>>];
|
|
44
|
-
theFunction(floor: {},
|
|
44
|
+
theFunction(floor: {}, params: import("../../core/steps").HandlerStepFunctionParams<import("../../core/response").PredictedResponse<"200", "resource.found", SF.FileInterface> | import("../../core/response").PredictedResponse<"304", "resource.notModified", undefined>>): import("@duplojs/utils").MaybePromise<import("../../core/response").PredictedResponse<"200", "resource.found", SF.FileInterface> | import("../../core/response").PredictedResponse<"304", "resource.notModified", undefined>>;
|
|
45
45
|
readonly metadata: readonly [];
|
|
46
46
|
}>];
|
|
47
47
|
}>;
|
|
@@ -32,7 +32,7 @@ export declare function makeRouteFolder(params: MakeRouteFolderParams): import("
|
|
|
32
32
|
readonly coerce: boolean;
|
|
33
33
|
readonly checkers: readonly [];
|
|
34
34
|
}>>>, NoInfer<ResponseContract.Contract<"304", "resource.notModified", import("@duplojs/utils/dataParser").DataParserEmpty<import("@duplojs/utils/dataParser").DataParserDefinitionEmpty>>>];
|
|
35
|
-
theFunction(floor: {},
|
|
35
|
+
theFunction(floor: {}, params: import("../../core/steps").HandlerStepFunctionParams<import("../../core/response").PredictedResponse<"200", "resource.found", SF.FileInterface> | import("../../core/response").PredictedResponse<"404", "resource.notfound", undefined> | import("../../core/response").PredictedResponse<"304", "resource.notModified", undefined>>): import("@duplojs/utils").MaybePromise<import("../../core/response").PredictedResponse<"200", "resource.found", SF.FileInterface> | import("../../core/response").PredictedResponse<"404", "resource.notfound", undefined> | import("../../core/response").PredictedResponse<"304", "resource.notModified", undefined>>;
|
|
36
36
|
readonly metadata: readonly [];
|
|
37
37
|
}>];
|
|
38
38
|
}>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@duplojs/http",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "mathcovax",
|
|
6
6
|
"url": "https://github.com/mathcovax"
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"test:tu:watch": "vitest --coverage --watch",
|
|
22
22
|
"test:tu:update": "vitest --coverage --update",
|
|
23
23
|
"test:types": "./.commands/test-types.sh",
|
|
24
|
-
"test:lint": "./.commands/test-
|
|
25
|
-
"test:lint:fix": "./.commands/test-
|
|
24
|
+
"test:lint": "./.commands/test-lint.sh",
|
|
25
|
+
"test:lint:fix": "./.commands/test-lint.sh --fix",
|
|
26
26
|
"prepare": "husky"
|
|
27
27
|
},
|
|
28
28
|
"types": "./dist/core/index.d.ts",
|
|
@@ -63,10 +63,15 @@
|
|
|
63
63
|
"types": "./dist/plugins/openApiGenerator/index.d.ts"
|
|
64
64
|
},
|
|
65
65
|
"./cacheController": {
|
|
66
|
-
|
|
66
|
+
"import": "./dist/plugins/cacheController/index.mjs",
|
|
67
67
|
"require": "./dist/plugins/cacheController/index.cjs",
|
|
68
68
|
"types": "./dist/plugins/cacheController/index.d.ts"
|
|
69
69
|
},
|
|
70
|
+
"./cookie": {
|
|
71
|
+
"import": "./dist/plugins/cookie/index.mjs",
|
|
72
|
+
"require": "./dist/plugins/cookie/index.cjs",
|
|
73
|
+
"types": "./dist/plugins/cookie/index.d.ts"
|
|
74
|
+
},
|
|
70
75
|
"./static": {
|
|
71
76
|
"import": "./dist/plugins/static/index.mjs",
|
|
72
77
|
"require": "./dist/plugins/static/index.cjs",
|
|
@@ -102,7 +107,7 @@
|
|
|
102
107
|
"form-data": "^4.0.5",
|
|
103
108
|
"husky": "9.1.7",
|
|
104
109
|
"node-mocks-http": "^1.17.2",
|
|
105
|
-
"rollup": "4.
|
|
110
|
+
"rollup": "^4.60.1",
|
|
106
111
|
"rollup-plugin-delete": "3.0.1",
|
|
107
112
|
"rollup-plugin-esbuild": "6.2.1",
|
|
108
113
|
"rollup-plugin-tsc-alias": "1.1.4",
|