@duplojs/http 0.6.1 → 0.7.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/getBody.cjs +1 -1
- package/dist/client/getBody.mjs +1 -1
- package/dist/client/hooks.d.ts +1 -25
- package/dist/client/httpClient.d.ts +29 -25
- package/dist/client/promiseRequest.cjs +3 -0
- package/dist/client/promiseRequest.d.ts +31 -39
- package/dist/client/promiseRequest.mjs +4 -1
- package/dist/client/types/clientResponse.d.ts +6 -6
- package/dist/client/types/hooks.d.ts +25 -0
- package/dist/client/types/index.cjs +2 -0
- package/dist/client/types/index.d.ts +2 -0
- package/dist/client/types/index.mjs +2 -0
- package/dist/client/types/promiseRequestParams.cjs +2 -0
- package/dist/client/types/promiseRequestParams.d.ts +9 -0
- package/dist/client/types/promiseRequestParams.mjs +1 -0
- package/dist/client/types/serverRoute.d.ts +19 -1
- package/dist/client/unexpectedResponseError.d.ts +1 -2
- package/dist/core/builders/preflight/route.cjs +1 -0
- package/dist/core/builders/preflight/route.d.ts +4 -2
- package/dist/core/builders/preflight/route.mjs +1 -0
- package/dist/core/builders/route/builder.cjs +1 -0
- package/dist/core/builders/route/builder.d.ts +4 -2
- package/dist/core/builders/route/builder.mjs +1 -0
- package/dist/core/clean/constraint.cjs +24 -0
- package/dist/core/clean/constraint.d.ts +8 -0
- package/dist/core/clean/constraint.mjs +22 -0
- package/dist/core/clean/constraintsSet.cjs +27 -0
- package/dist/core/clean/constraintsSet.d.ts +8 -0
- package/dist/core/clean/constraintsSet.mjs +25 -0
- package/dist/core/clean/entity.cjs +33 -0
- package/dist/core/clean/entity.d.ts +20 -0
- package/dist/core/clean/entity.mjs +31 -0
- package/dist/core/clean/index.cjs +8 -0
- package/dist/core/clean/index.d.ts +5 -0
- package/dist/core/clean/index.mjs +5 -0
- package/dist/core/clean/newType.cjs +15 -0
- package/dist/core/clean/newType.d.ts +8 -0
- package/dist/core/clean/newType.mjs +13 -0
- package/dist/core/clean/primitive.cjs +12 -0
- package/dist/core/clean/primitive.d.ts +8 -0
- package/dist/core/clean/primitive.mjs +10 -0
- package/dist/core/defaultHooks/index.cjs +50 -0
- package/dist/core/defaultHooks/index.d.ts +5 -0
- package/dist/core/defaultHooks/index.mjs +48 -0
- package/dist/{interfaces/node/error → core/errors}/bodyParseWrongChunkReceived.cjs +6 -4
- package/dist/core/errors/bodyParseWrongChunkReceived.d.ts +9 -0
- package/dist/core/errors/bodyParseWrongChunkReceived.mjs +14 -0
- package/dist/{interfaces/node/error → core/errors}/bodySizeExceedsLimitError.cjs +2 -2
- package/dist/{interfaces/node/error → core/errors}/bodySizeExceedsLimitError.d.ts +2 -2
- package/dist/{interfaces/node/error → core/errors}/bodySizeExceedsLimitError.mjs +2 -2
- package/dist/{interfaces/node/error → core/errors}/index.cjs +6 -4
- package/dist/{interfaces/node/error → core/errors}/index.d.ts +3 -2
- package/dist/{interfaces/node/error → core/errors}/index.mjs +3 -2
- package/dist/core/errors/parseJsonError.cjs +16 -0
- package/dist/core/errors/parseJsonError.d.ts +9 -0
- package/dist/core/errors/parseJsonError.mjs +14 -0
- package/dist/core/errors/wrongContentTypeError.cjs +16 -0
- package/dist/core/errors/wrongContentTypeError.d.ts +9 -0
- package/dist/core/errors/wrongContentTypeError.mjs +14 -0
- package/dist/core/functionsBuilders/route/create.d.ts +2 -2
- package/dist/core/functionsBuilders/route/default.cjs +0 -11
- package/dist/core/functionsBuilders/route/default.mjs +0 -11
- package/dist/core/functionsBuilders/route/hook.d.ts +2 -2
- package/dist/core/functionsBuilders/steps/create.d.ts +2 -2
- package/dist/core/functionsBuilders/steps/defaults/cutStep.cjs +15 -18
- package/dist/core/functionsBuilders/steps/defaults/cutStep.mjs +15 -18
- package/dist/core/functionsBuilders/steps/defaults/extractStep.cjs +43 -19
- package/dist/core/functionsBuilders/steps/defaults/extractStep.d.ts +2 -1
- package/dist/core/functionsBuilders/steps/defaults/extractStep.mjs +44 -20
- package/dist/core/functionsBuilders/steps/defaults/handlerStep.cjs +14 -8
- package/dist/core/functionsBuilders/steps/defaults/handlerStep.mjs +14 -8
- package/dist/core/hub/defaultBodyController.cjs +8 -0
- package/dist/core/hub/defaultBodyController.d.ts +1 -0
- package/dist/core/hub/defaultBodyController.mjs +6 -0
- package/dist/core/hub/hooks.cjs +3 -1
- package/dist/core/hub/hooks.d.ts +2 -3
- package/dist/core/hub/hooks.mjs +3 -1
- package/dist/core/hub/index.cjs +101 -127
- package/dist/core/hub/index.d.ts +33 -34
- package/dist/core/hub/index.mjs +100 -128
- package/dist/core/implementHttpServer.cjs +5 -5
- package/dist/core/implementHttpServer.d.ts +2 -1
- package/dist/core/implementHttpServer.mjs +5 -5
- package/dist/core/index.cjs +35 -10
- package/dist/core/index.d.ts +3 -0
- package/dist/core/index.mjs +14 -2
- package/dist/core/request/bodyController/base.cjs +36 -0
- package/dist/core/request/bodyController/base.d.ts +28 -0
- package/dist/core/request/bodyController/base.mjs +34 -0
- package/dist/core/request/bodyController/formData.cjs +28 -0
- package/dist/core/request/bodyController/formData.d.ts +22 -0
- package/dist/core/request/bodyController/formData.mjs +25 -0
- package/dist/core/request/bodyController/index.cjs +13 -0
- package/dist/core/request/bodyController/index.d.ts +3 -0
- package/dist/core/request/bodyController/index.mjs +3 -0
- package/dist/core/request/bodyController/text.cjs +14 -0
- package/dist/core/request/bodyController/text.d.ts +10 -0
- package/dist/core/request/bodyController/text.mjs +11 -0
- package/dist/core/{request.cjs → request/index.cjs} +21 -3
- package/dist/core/{request.d.ts → request/index.d.ts} +10 -3
- package/dist/core/request/index.mjs +50 -0
- package/dist/core/response/contract.d.ts +1 -1
- package/dist/core/route/hooks.d.ts +0 -2
- package/dist/core/route/index.d.ts +2 -1
- package/dist/core/router/index.cjs +27 -8
- package/dist/core/router/index.d.ts +2 -1
- package/dist/core/router/index.mjs +28 -10
- package/dist/core/router/notFoundBodyReaderImplementationError.cjs +16 -0
- package/dist/core/router/notFoundBodyReaderImplementationError.d.ts +11 -0
- package/dist/core/router/notFoundBodyReaderImplementationError.mjs +14 -0
- package/dist/core/router/types/buildedRouter.d.ts +3 -3
- package/dist/core/steps/extract.d.ts +3 -1
- package/dist/core/steps/types/steps.d.ts +1 -3
- package/dist/core/types/hosts.cjs +2 -0
- package/dist/core/types/hosts.d.ts +4 -0
- package/dist/core/types/hosts.mjs +1 -0
- package/dist/core/types/httpServerParams.cjs +2 -0
- package/dist/core/types/httpServerParams.d.ts +11 -0
- package/dist/core/types/httpServerParams.mjs +1 -0
- package/dist/core/types/index.cjs +2 -0
- package/dist/core/types/index.d.ts +2 -0
- package/dist/core/types/index.mjs +2 -0
- package/dist/interfaces/bun/types/request.cjs +1 -1
- package/dist/interfaces/bun/types/request.mjs +1 -1
- package/dist/interfaces/node/bodyReaders/formData/error.cjs +14 -0
- package/dist/interfaces/node/bodyReaders/formData/error.d.ts +8 -0
- package/dist/interfaces/node/bodyReaders/formData/error.mjs +12 -0
- package/dist/interfaces/node/bodyReaders/formData/index.cjs +94 -0
- package/dist/interfaces/node/bodyReaders/formData/index.d.ts +4 -0
- package/dist/interfaces/node/bodyReaders/formData/index.mjs +90 -0
- package/dist/interfaces/node/bodyReaders/formData/readRequestFormData.cjs +175 -0
- package/dist/interfaces/node/bodyReaders/formData/readRequestFormData.d.ts +21 -0
- package/dist/interfaces/node/bodyReaders/formData/readRequestFormData.mjs +173 -0
- package/dist/interfaces/node/bodyReaders/index.cjs +9 -0
- package/dist/interfaces/node/bodyReaders/index.d.ts +2 -0
- package/dist/interfaces/node/bodyReaders/index.mjs +2 -0
- package/dist/interfaces/node/bodyReaders/text/index.cjs +41 -0
- package/dist/interfaces/node/bodyReaders/text/index.d.ts +3 -0
- package/dist/interfaces/node/bodyReaders/text/index.mjs +38 -0
- package/dist/interfaces/node/bodyReaders/text/readRequestText.cjs +37 -0
- package/dist/interfaces/node/bodyReaders/text/readRequestText.d.ts +6 -0
- package/dist/interfaces/node/bodyReaders/text/readRequestText.mjs +35 -0
- package/dist/interfaces/node/createHttpServer.cjs +13 -5
- package/dist/interfaces/node/createHttpServer.d.ts +13 -12
- package/dist/interfaces/node/createHttpServer.mjs +13 -5
- package/dist/interfaces/node/hooks/index.cjs +47 -0
- package/dist/interfaces/node/hooks/index.d.ts +5 -0
- package/dist/interfaces/node/hooks/index.mjs +45 -0
- package/dist/interfaces/node/index.cjs +13 -9
- package/dist/interfaces/node/index.d.ts +1 -1
- package/dist/interfaces/node/index.mjs +7 -5
- package/dist/interfaces/node/types/index.cjs +0 -1
- package/dist/interfaces/node/types/index.d.ts +0 -1
- package/dist/interfaces/node/types/index.mjs +0 -1
- package/dist/interfaces/node/types/request.cjs +1 -1
- package/dist/interfaces/node/types/request.mjs +1 -1
- package/dist/plugins/codeGenerator/index.cjs +2 -0
- package/dist/plugins/codeGenerator/index.mjs +1 -1
- package/dist/plugins/codeGenerator/plugin.cjs +8 -4
- package/dist/plugins/codeGenerator/plugin.mjs +9 -5
- package/dist/plugins/codeGenerator/routeToDataParser.cjs +24 -1
- package/dist/plugins/codeGenerator/routeToDataParser.d.ts +34 -0
- package/dist/plugins/codeGenerator/routeToDataParser.mjs +24 -3
- package/dist/plugins/codeGenerator/typescriptTransfomer.cjs +9 -0
- package/dist/plugins/codeGenerator/typescriptTransfomer.d.ts +1 -0
- package/dist/plugins/codeGenerator/typescriptTransfomer.mjs +7 -0
- package/dist/plugins/openApiGenerator/makeOpenApiRoute.d.ts +3 -0
- package/dist/plugins/openApiGenerator/plugin.cjs +3 -3
- package/dist/plugins/openApiGenerator/plugin.mjs +4 -4
- package/dist/plugins/openApiGenerator/routeToOpenApi.cjs +16 -1
- package/dist/plugins/openApiGenerator/routeToOpenApi.d.ts +10 -1
- package/dist/plugins/openApiGenerator/routeToOpenApi.mjs +16 -1
- package/dist/plugins/openApiGenerator/types/entrypoint.d.ts +6 -1
- package/dist/plugins/openApiGenerator/types/openApiMethod.d.ts +1 -1
- package/package.json +5 -6
- package/dist/core/request.mjs +0 -32
- package/dist/interfaces/node/error/bodyParseUnknownError.cjs +0 -16
- package/dist/interfaces/node/error/bodyParseUnknownError.d.ts +0 -9
- package/dist/interfaces/node/error/bodyParseUnknownError.mjs +0 -14
- package/dist/interfaces/node/error/bodyParseWrongChunkReceived.d.ts +0 -8
- package/dist/interfaces/node/error/bodyParseWrongChunkReceived.mjs +0 -12
- package/dist/interfaces/node/hooks.cjs +0 -126
- package/dist/interfaces/node/hooks.d.ts +0 -8
- package/dist/interfaces/node/hooks.mjs +0 -124
- package/dist/interfaces/node/types/host.d.ts +0 -4
- /package/dist/{interfaces/node/types/host.cjs → client/types/hooks.cjs} +0 -0
- /package/dist/{interfaces/node/types/host.mjs → client/types/hooks.mjs} +0 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('../../../core/route/index.cjs');
|
|
4
|
+
var serverUtils = require('@duplojs/server-utils');
|
|
5
|
+
var utils = require('@duplojs/utils');
|
|
6
|
+
var node_fs = require('node:fs');
|
|
7
|
+
var hooks = require('../../../core/route/hooks.cjs');
|
|
8
|
+
|
|
9
|
+
const nodeHook = hooks.createHookRouteLifeCycle({
|
|
10
|
+
beforeSendResponse({ request, currentResponse, exit }) {
|
|
11
|
+
request.raw.response.writeHead(Number(currentResponse.code), currentResponse.headers);
|
|
12
|
+
return exit();
|
|
13
|
+
},
|
|
14
|
+
async sendResponse({ request, currentResponse, exit }) {
|
|
15
|
+
const { response: rawResponse } = request.raw;
|
|
16
|
+
const body = currentResponse.body;
|
|
17
|
+
if (body instanceof Error) {
|
|
18
|
+
rawResponse.write(body.toString());
|
|
19
|
+
}
|
|
20
|
+
else if (serverUtils.SF.isFileInterface(body)) {
|
|
21
|
+
await new Promise((resolve, reject) => {
|
|
22
|
+
node_fs.createReadStream(body.path)
|
|
23
|
+
.pipe(request.raw.response
|
|
24
|
+
.once("error", reject)
|
|
25
|
+
.once("close", resolve));
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
else if (typeof body === "object"
|
|
29
|
+
|| typeof body === "number"
|
|
30
|
+
|| typeof body === "boolean") {
|
|
31
|
+
rawResponse.write(JSON.stringify(body));
|
|
32
|
+
}
|
|
33
|
+
else if (typeof body === "string") {
|
|
34
|
+
rawResponse.write(body);
|
|
35
|
+
}
|
|
36
|
+
rawResponse.end();
|
|
37
|
+
return exit();
|
|
38
|
+
},
|
|
39
|
+
async afterSendResponse({ request, next }) {
|
|
40
|
+
if (request.filesAttache) {
|
|
41
|
+
await Promise.all(utils.A.map(request.filesAttache, (path) => serverUtils.SF.remove(path)));
|
|
42
|
+
}
|
|
43
|
+
return next();
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
exports.nodeHook = nodeHook;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const nodeHook: {
|
|
2
|
+
beforeSendResponse({ request, currentResponse, exit }: import("../../../core/route").RouteHookParamsAfter<import("../../../core/request").Request>): import("../../../core/route").RouteHookExit;
|
|
3
|
+
sendResponse({ request, currentResponse, exit }: import("../../../core/route").RouteHookParamsAfter<import("../../../core/request").Request>): Promise<import("../../../core/route").RouteHookExit>;
|
|
4
|
+
afterSendResponse({ request, next }: import("../../../core/route").RouteHookParamsAfter<import("../../../core/request").Request>): Promise<import("../../../core/route").RouteHookNext>;
|
|
5
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import '../../../core/route/index.mjs';
|
|
2
|
+
import { SF } from '@duplojs/server-utils';
|
|
3
|
+
import { A } from '@duplojs/utils';
|
|
4
|
+
import { createReadStream } from 'node:fs';
|
|
5
|
+
import { createHookRouteLifeCycle } from '../../../core/route/hooks.mjs';
|
|
6
|
+
|
|
7
|
+
const nodeHook = createHookRouteLifeCycle({
|
|
8
|
+
beforeSendResponse({ request, currentResponse, exit }) {
|
|
9
|
+
request.raw.response.writeHead(Number(currentResponse.code), currentResponse.headers);
|
|
10
|
+
return exit();
|
|
11
|
+
},
|
|
12
|
+
async sendResponse({ request, currentResponse, exit }) {
|
|
13
|
+
const { response: rawResponse } = request.raw;
|
|
14
|
+
const body = currentResponse.body;
|
|
15
|
+
if (body instanceof Error) {
|
|
16
|
+
rawResponse.write(body.toString());
|
|
17
|
+
}
|
|
18
|
+
else if (SF.isFileInterface(body)) {
|
|
19
|
+
await new Promise((resolve, reject) => {
|
|
20
|
+
createReadStream(body.path)
|
|
21
|
+
.pipe(request.raw.response
|
|
22
|
+
.once("error", reject)
|
|
23
|
+
.once("close", resolve));
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
else if (typeof body === "object"
|
|
27
|
+
|| typeof body === "number"
|
|
28
|
+
|| typeof body === "boolean") {
|
|
29
|
+
rawResponse.write(JSON.stringify(body));
|
|
30
|
+
}
|
|
31
|
+
else if (typeof body === "string") {
|
|
32
|
+
rawResponse.write(body);
|
|
33
|
+
}
|
|
34
|
+
rawResponse.end();
|
|
35
|
+
return exit();
|
|
36
|
+
},
|
|
37
|
+
async afterSendResponse({ request, next }) {
|
|
38
|
+
if (request.filesAttache) {
|
|
39
|
+
await Promise.all(A.map(request.filesAttache, (path) => SF.remove(path)));
|
|
40
|
+
}
|
|
41
|
+
return next();
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export { nodeHook };
|
|
@@ -2,18 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
require('./types/index.cjs');
|
|
4
4
|
var kind = require('./kind.cjs');
|
|
5
|
-
require('./error/index.cjs');
|
|
6
5
|
var createHttpServer = require('./createHttpServer.cjs');
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
var
|
|
10
|
-
var
|
|
6
|
+
var index = require('./hooks/index.cjs');
|
|
7
|
+
require('./bodyReaders/index.cjs');
|
|
8
|
+
var error = require('./bodyReaders/formData/error.cjs');
|
|
9
|
+
var readRequestFormData = require('./bodyReaders/formData/readRequestFormData.cjs');
|
|
10
|
+
var index$1 = require('./bodyReaders/formData/index.cjs');
|
|
11
|
+
var readRequestText = require('./bodyReaders/text/readRequestText.cjs');
|
|
12
|
+
var index$2 = require('./bodyReaders/text/index.cjs');
|
|
11
13
|
|
|
12
14
|
|
|
13
15
|
|
|
14
16
|
exports.createInterfacesNodeLibKind = kind.createInterfacesNodeLibKind;
|
|
15
17
|
exports.createHttpServer = createHttpServer.createHttpServer;
|
|
16
|
-
exports.
|
|
17
|
-
exports.
|
|
18
|
-
exports.
|
|
19
|
-
exports.
|
|
18
|
+
exports.nodeHook = index.nodeHook;
|
|
19
|
+
exports.BodyParseFormDataError = error.BodyParseFormDataError;
|
|
20
|
+
exports.readRequestFormData = readRequestFormData.readRequestFormData;
|
|
21
|
+
exports.createFormDataBodyReaderImplementation = index$1.createFormDataBodyReaderImplementation;
|
|
22
|
+
exports.readRequestText = readRequestText.readRequestText;
|
|
23
|
+
exports.createTextBodyReaderImplementation = index$2.createTextBodyReaderImplementation;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import './types/index.mjs';
|
|
2
2
|
export { createInterfacesNodeLibKind } from './kind.mjs';
|
|
3
|
-
import './error/index.mjs';
|
|
4
3
|
export { createHttpServer } from './createHttpServer.mjs';
|
|
5
|
-
export {
|
|
6
|
-
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
4
|
+
export { nodeHook } from './hooks/index.mjs';
|
|
5
|
+
import './bodyReaders/index.mjs';
|
|
6
|
+
export { BodyParseFormDataError } from './bodyReaders/formData/error.mjs';
|
|
7
|
+
export { readRequestFormData } from './bodyReaders/formData/readRequestFormData.mjs';
|
|
8
|
+
export { createFormDataBodyReaderImplementation } from './bodyReaders/formData/index.mjs';
|
|
9
|
+
export { readRequestText } from './bodyReaders/text/readRequestText.mjs';
|
|
10
|
+
export { createTextBodyReaderImplementation } from './bodyReaders/text/index.mjs';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import '../../../core/request.mjs';
|
|
1
|
+
import '../../../core/request/index.mjs';
|
|
2
2
|
import '../../../core/steps/index.mjs';
|
|
@@ -10,6 +10,8 @@ var metadata = require('./metadata.cjs');
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
exports.codeGeneratorPlugin = plugin.codeGeneratorPlugin;
|
|
13
|
+
exports.bodyAsFormData = routeToDataParser.bodyAsFormData;
|
|
14
|
+
exports.convertRoutePath = routeToDataParser.convertRoutePath;
|
|
13
15
|
exports.routeToDataParser = routeToDataParser.routeToDataParser;
|
|
14
16
|
exports.aggregateStepContract = aggregateStepContract.aggregateStepContract;
|
|
15
17
|
exports.IgnoreByCodeGeneratorMetadata = metadata.IgnoreByCodeGeneratorMetadata;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import '@duplojs/data-parser-tools/toTypescript';
|
|
2
2
|
import './types/index.mjs';
|
|
3
3
|
export { codeGeneratorPlugin } from './plugin.mjs';
|
|
4
|
-
export { routeToDataParser } from './routeToDataParser.mjs';
|
|
4
|
+
export { bodyAsFormData, convertRoutePath, routeToDataParser } from './routeToDataParser.mjs';
|
|
5
5
|
export { aggregateStepContract } from './aggregateStepContract.mjs';
|
|
6
6
|
export { IgnoreByCodeGeneratorMetadata } from './metadata.mjs';
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
var DataParserToTypescript = require('@duplojs/data-parser-tools/toTypescript');
|
|
4
4
|
var utils = require('@duplojs/utils');
|
|
5
5
|
var routeToDataParser = require('./routeToDataParser.cjs');
|
|
6
|
-
var
|
|
6
|
+
var serverUtils = require('@duplojs/server-utils');
|
|
7
|
+
var typescriptTransfomer = require('./typescriptTransfomer.cjs');
|
|
7
8
|
|
|
8
9
|
function _interopNamespaceDefault(e) {
|
|
9
10
|
var n = Object.create(null);
|
|
@@ -33,7 +34,7 @@ function codeGeneratorPlugin(pluginParams) {
|
|
|
33
34
|
if (!utils.equal(hub.config.environment, ["DEV", "BUILD"])) {
|
|
34
35
|
return;
|
|
35
36
|
}
|
|
36
|
-
const routes = hub.
|
|
37
|
+
const routes = utils.A.from(hub.routes);
|
|
37
38
|
const dataParserRoutes = utils.A.flatMap(routes, (route) => routeToDataParser.routeToDataParser(route, {
|
|
38
39
|
defaultExtractContract: hub.defaultExtractContract,
|
|
39
40
|
}));
|
|
@@ -42,9 +43,12 @@ function codeGeneratorPlugin(pluginParams) {
|
|
|
42
43
|
}
|
|
43
44
|
const output = DataParserToTypescript__namespace.render(utils.DP.union(dataParserRoutes), {
|
|
44
45
|
identifier: "Routes",
|
|
45
|
-
transformers:
|
|
46
|
+
transformers: [
|
|
47
|
+
typescriptTransfomer.fileTransformer,
|
|
48
|
+
...DataParserToTypescript__namespace.defaultTransformers,
|
|
49
|
+
],
|
|
46
50
|
});
|
|
47
|
-
await
|
|
51
|
+
utils.asserts(await serverUtils.SF.writeTextFile(pluginParams.outputFile, output), utils.E.isRight);
|
|
48
52
|
},
|
|
49
53
|
},
|
|
50
54
|
],
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as DataParserToTypescript from '@duplojs/data-parser-tools/toTypescript';
|
|
2
|
-
import { equal, A, DP } from '@duplojs/utils';
|
|
2
|
+
import { equal, A, DP, asserts, E } from '@duplojs/utils';
|
|
3
3
|
import { routeToDataParser } from './routeToDataParser.mjs';
|
|
4
|
-
import {
|
|
4
|
+
import { SF } from '@duplojs/server-utils';
|
|
5
|
+
import { fileTransformer } from './typescriptTransfomer.mjs';
|
|
5
6
|
|
|
6
7
|
function codeGeneratorPlugin(pluginParams) {
|
|
7
8
|
return () => ({
|
|
@@ -12,7 +13,7 @@ function codeGeneratorPlugin(pluginParams) {
|
|
|
12
13
|
if (!equal(hub.config.environment, ["DEV", "BUILD"])) {
|
|
13
14
|
return;
|
|
14
15
|
}
|
|
15
|
-
const routes = hub.
|
|
16
|
+
const routes = A.from(hub.routes);
|
|
16
17
|
const dataParserRoutes = A.flatMap(routes, (route) => routeToDataParser(route, {
|
|
17
18
|
defaultExtractContract: hub.defaultExtractContract,
|
|
18
19
|
}));
|
|
@@ -21,9 +22,12 @@ function codeGeneratorPlugin(pluginParams) {
|
|
|
21
22
|
}
|
|
22
23
|
const output = DataParserToTypescript.render(DP.union(dataParserRoutes), {
|
|
23
24
|
identifier: "Routes",
|
|
24
|
-
transformers:
|
|
25
|
+
transformers: [
|
|
26
|
+
fileTransformer,
|
|
27
|
+
...DataParserToTypescript.defaultTransformers,
|
|
28
|
+
],
|
|
25
29
|
});
|
|
26
|
-
await
|
|
30
|
+
asserts(await SF.writeTextFile(pluginParams.outputFile, output), E.isRight);
|
|
27
31
|
},
|
|
28
32
|
},
|
|
29
33
|
],
|
|
@@ -3,7 +3,21 @@
|
|
|
3
3
|
var aggregateStepContract = require('./aggregateStepContract.cjs');
|
|
4
4
|
var utils = require('@duplojs/utils');
|
|
5
5
|
var metadata = require('./metadata.cjs');
|
|
6
|
+
require('../../core/request/index.cjs');
|
|
7
|
+
var typescript = require('typescript');
|
|
8
|
+
var formData = require('../../core/request/bodyController/formData.cjs');
|
|
6
9
|
|
|
10
|
+
const bodyAsFormData = (dataParser, { transformer, success, addImport }) => {
|
|
11
|
+
const result = transformer(dataParser);
|
|
12
|
+
if (utils.E.isLeft(result)) {
|
|
13
|
+
return result;
|
|
14
|
+
}
|
|
15
|
+
addImport("@duplojs/utils", "TheFormData");
|
|
16
|
+
return success(typescript.factory.createTypeReferenceNode("TheFormData", [utils.unwrap(result)]));
|
|
17
|
+
};
|
|
18
|
+
const convertRoutePath = (path) => utils.pipe(path, utils.S.split("*"), utils.A.flatMap((element, { index, self }) => utils.A.isLastIndex(self, index)
|
|
19
|
+
? element
|
|
20
|
+
: [element, utils.DP.string()]), utils.P.when(utils.A.minElements(2), (template) => utils.DP.templateLiteral(template)), utils.P.otherwise(() => utils.DP.literal(path)));
|
|
7
21
|
function routeToDataParser(route, params) {
|
|
8
22
|
const isIgnore = utils.A.find(route.definition.metadata, metadata.IgnoreByCodeGeneratorMetadata.is);
|
|
9
23
|
if (isIgnore) {
|
|
@@ -24,10 +38,19 @@ function routeToDataParser(route, params) {
|
|
|
24
38
|
return skip();
|
|
25
39
|
}), utils.O.fromEntries)), ({ endpointContract, entrypointContract }) => utils.A.map(route.definition.paths, (path) => utils.DP.object({
|
|
26
40
|
method: utils.DP.literal(route.definition.method),
|
|
27
|
-
path:
|
|
41
|
+
path: convertRoutePath(path),
|
|
28
42
|
...entrypointContract,
|
|
43
|
+
...(entrypointContract.body && formData.FormDataBodyController.is(route.definition.bodyController)
|
|
44
|
+
? {
|
|
45
|
+
body: entrypointContract
|
|
46
|
+
.body
|
|
47
|
+
.addOverrideTypescriptTransformer(bodyAsFormData),
|
|
48
|
+
}
|
|
49
|
+
: {}),
|
|
29
50
|
responses: utils.DP.union(endpointContract),
|
|
30
51
|
})));
|
|
31
52
|
}
|
|
32
53
|
|
|
54
|
+
exports.bodyAsFormData = bodyAsFormData;
|
|
55
|
+
exports.convertRoutePath = convertRoutePath;
|
|
33
56
|
exports.routeToDataParser = routeToDataParser;
|
|
@@ -1,7 +1,41 @@
|
|
|
1
1
|
import { type Route } from "../../core/route";
|
|
2
2
|
import { DP } from "@duplojs/utils";
|
|
3
3
|
import { type ResponseContract } from "../../core/response";
|
|
4
|
+
import { type TransformerBuildFunction } from "@duplojs/data-parser-tools/toTypescript";
|
|
4
5
|
export interface RouteToDataParserParams {
|
|
5
6
|
readonly defaultExtractContract: ResponseContract.Contract;
|
|
6
7
|
}
|
|
8
|
+
export declare const bodyAsFormData: TransformerBuildFunction;
|
|
9
|
+
export declare const convertRoutePath: (path: string) => DP.DataParserLiteral<{
|
|
10
|
+
readonly value: readonly string[];
|
|
11
|
+
readonly errorMessage?: string | undefined;
|
|
12
|
+
readonly identifier?: string | undefined;
|
|
13
|
+
readonly overrideTypescriptTransformer?: TransformerBuildFunction | undefined;
|
|
14
|
+
readonly checkers: readonly [];
|
|
15
|
+
}> | DP.DataParserTemplateLiteral<{
|
|
16
|
+
readonly template: [string | DP.DataParserString<{
|
|
17
|
+
readonly errorMessage?: string | undefined;
|
|
18
|
+
readonly identifier?: string | undefined;
|
|
19
|
+
readonly overrideTypescriptTransformer?: TransformerBuildFunction | undefined;
|
|
20
|
+
readonly coerce: boolean;
|
|
21
|
+
readonly checkers: readonly [];
|
|
22
|
+
}>, string | DP.DataParserString<{
|
|
23
|
+
readonly errorMessage?: string | undefined;
|
|
24
|
+
readonly identifier?: string | undefined;
|
|
25
|
+
readonly overrideTypescriptTransformer?: TransformerBuildFunction | undefined;
|
|
26
|
+
readonly coerce: boolean;
|
|
27
|
+
readonly checkers: readonly [];
|
|
28
|
+
}>, ...(string | DP.DataParserString<{
|
|
29
|
+
readonly errorMessage?: string | undefined;
|
|
30
|
+
readonly identifier?: string | undefined;
|
|
31
|
+
readonly overrideTypescriptTransformer?: TransformerBuildFunction | undefined;
|
|
32
|
+
readonly coerce: boolean;
|
|
33
|
+
readonly checkers: readonly [];
|
|
34
|
+
}>)[]];
|
|
35
|
+
readonly errorMessage?: string | undefined;
|
|
36
|
+
readonly identifier?: string | undefined;
|
|
37
|
+
readonly overrideTypescriptTransformer?: TransformerBuildFunction | undefined;
|
|
38
|
+
readonly pattern: RegExp;
|
|
39
|
+
readonly checkers: readonly [];
|
|
40
|
+
}>;
|
|
7
41
|
export declare function routeToDataParser(route: Route, params: RouteToDataParserParams): DP.DataParser[];
|
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
import { aggregateStepContract } from './aggregateStepContract.mjs';
|
|
2
|
-
import {
|
|
2
|
+
import { E, unwrap, pipe, S, A, DP, P, O, innerPipe } from '@duplojs/utils';
|
|
3
3
|
import { IgnoreByCodeGeneratorMetadata } from './metadata.mjs';
|
|
4
|
+
import '../../core/request/index.mjs';
|
|
5
|
+
import { factory } from 'typescript';
|
|
6
|
+
import { FormDataBodyController } from '../../core/request/bodyController/formData.mjs';
|
|
4
7
|
|
|
8
|
+
const bodyAsFormData = (dataParser, { transformer, success, addImport }) => {
|
|
9
|
+
const result = transformer(dataParser);
|
|
10
|
+
if (E.isLeft(result)) {
|
|
11
|
+
return result;
|
|
12
|
+
}
|
|
13
|
+
addImport("@duplojs/utils", "TheFormData");
|
|
14
|
+
return success(factory.createTypeReferenceNode("TheFormData", [unwrap(result)]));
|
|
15
|
+
};
|
|
16
|
+
const convertRoutePath = (path) => pipe(path, S.split("*"), A.flatMap((element, { index, self }) => A.isLastIndex(self, index)
|
|
17
|
+
? element
|
|
18
|
+
: [element, DP.string()]), P.when(A.minElements(2), (template) => DP.templateLiteral(template)), P.otherwise(() => DP.literal(path)));
|
|
5
19
|
function routeToDataParser(route, params) {
|
|
6
20
|
const isIgnore = A.find(route.definition.metadata, IgnoreByCodeGeneratorMetadata.is);
|
|
7
21
|
if (isIgnore) {
|
|
@@ -22,10 +36,17 @@ function routeToDataParser(route, params) {
|
|
|
22
36
|
return skip();
|
|
23
37
|
}), O.fromEntries)), ({ endpointContract, entrypointContract }) => A.map(route.definition.paths, (path) => DP.object({
|
|
24
38
|
method: DP.literal(route.definition.method),
|
|
25
|
-
path:
|
|
39
|
+
path: convertRoutePath(path),
|
|
26
40
|
...entrypointContract,
|
|
41
|
+
...(entrypointContract.body && FormDataBodyController.is(route.definition.bodyController)
|
|
42
|
+
? {
|
|
43
|
+
body: entrypointContract
|
|
44
|
+
.body
|
|
45
|
+
.addOverrideTypescriptTransformer(bodyAsFormData),
|
|
46
|
+
}
|
|
47
|
+
: {}),
|
|
27
48
|
responses: DP.union(endpointContract),
|
|
28
49
|
})));
|
|
29
50
|
}
|
|
30
51
|
|
|
31
|
-
export { routeToDataParser };
|
|
52
|
+
export { bodyAsFormData, convertRoutePath, routeToDataParser };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var DataParserToTypescript = require('@duplojs/data-parser-tools/toTypescript');
|
|
4
|
+
var serverUtils = require('@duplojs/server-utils');
|
|
5
|
+
var typescript = require('typescript');
|
|
6
|
+
|
|
7
|
+
const fileTransformer = DataParserToTypescript.createTransformer(serverUtils.SDP.fileKind.has, (__, { success }) => success(typescript.factory.createTypeReferenceNode("File")));
|
|
8
|
+
|
|
9
|
+
exports.fileTransformer = fileTransformer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const fileTransformer: (schema: import("@duplojs/utils/dataParser").DataParsers, params: import("@duplojs/data-parser-tools/toTypescript").TransformerParams) => import("@duplojs/data-parser-tools/toTypescript").MaybeTransformerEither;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createTransformer } from '@duplojs/data-parser-tools/toTypescript';
|
|
2
|
+
import { SDP } from '@duplojs/server-utils';
|
|
3
|
+
import { factory } from 'typescript';
|
|
4
|
+
|
|
5
|
+
const fileTransformer = createTransformer(SDP.fileKind.has, (__, { success }) => success(factory.createTypeReferenceNode("File")));
|
|
6
|
+
|
|
7
|
+
export { fileTransformer };
|
|
@@ -7,10 +7,13 @@ export declare function makeOpenApiRoute(routePath: RoutePath, openApiPage: stri
|
|
|
7
7
|
readonly hooks: readonly [];
|
|
8
8
|
readonly preflightSteps: readonly [];
|
|
9
9
|
readonly paths: readonly [`/${string}`];
|
|
10
|
+
readonly bodyController: null;
|
|
10
11
|
readonly steps: readonly [import("../../core/steps").HandlerStep<{
|
|
11
12
|
readonly responseContract: NoInfer<ResponseContract.Contract<"200", "swaggerUi", DP.DataParserString<{
|
|
12
13
|
readonly errorMessage?: string | undefined;
|
|
13
14
|
readonly identifier?: string | undefined;
|
|
15
|
+
readonly overrideJsonSchemaTransformer?: import("@duplojs/data-parser-tools/toJsonSchema").TransformerBuildFunction | undefined;
|
|
16
|
+
readonly overrideTypescriptTransformer?: import("@duplojs/data-parser-tools/toTypescript").TransformerBuildFunction | undefined;
|
|
14
17
|
readonly coerce: boolean;
|
|
15
18
|
readonly checkers: readonly [];
|
|
16
19
|
}>>>;
|
|
@@ -4,7 +4,7 @@ var routeToOpenApi = require('./routeToOpenApi.cjs');
|
|
|
4
4
|
var utils = require('@duplojs/utils');
|
|
5
5
|
var makeOpenApiPage = require('./makeOpenApiPage.cjs');
|
|
6
6
|
var makeOpenApiRoute = require('./makeOpenApiRoute.cjs');
|
|
7
|
-
var
|
|
7
|
+
var serverUtils = require('@duplojs/server-utils');
|
|
8
8
|
|
|
9
9
|
function openApiGeneratorPlugin(pluginParams) {
|
|
10
10
|
return () => ({
|
|
@@ -19,7 +19,7 @@ function openApiGeneratorPlugin(pluginParams) {
|
|
|
19
19
|
}
|
|
20
20
|
const contextToJsonSchemaFactory = new Map();
|
|
21
21
|
const resultSchemaContext = new Map();
|
|
22
|
-
const routes = hub.
|
|
22
|
+
const routes = utils.A.from(hub.routes);
|
|
23
23
|
const openApiRoutes = utils.pipe(routes, utils.A.filter((route) => route.definition.method !== "OPTIONS"), utils.A.flatMap((route) => routeToOpenApi.routeToOpenApi(route, {
|
|
24
24
|
defaultExtractContract: hub.defaultExtractContract,
|
|
25
25
|
resultSchemaContext,
|
|
@@ -77,7 +77,7 @@ function openApiGeneratorPlugin(pluginParams) {
|
|
|
77
77
|
};
|
|
78
78
|
const openApiDocumentString = JSON.stringify(openApiDocument, null, 2);
|
|
79
79
|
if (pluginParams.outputFile) {
|
|
80
|
-
await
|
|
80
|
+
utils.asserts(await serverUtils.SF.writeTextFile(pluginParams.outputFile, openApiDocumentString), utils.E.isRight);
|
|
81
81
|
}
|
|
82
82
|
if (pluginParams.routePath) {
|
|
83
83
|
const openApiPage = makeOpenApiPage.makeOpenApiPage({
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { routeToOpenApi } from './routeToOpenApi.mjs';
|
|
2
|
-
import { equal,
|
|
2
|
+
import { equal, A, pipe, O, G, P, justReturn, asserts, E } from '@duplojs/utils';
|
|
3
3
|
import { makeOpenApiPage } from './makeOpenApiPage.mjs';
|
|
4
4
|
import { makeOpenApiRoute } from './makeOpenApiRoute.mjs';
|
|
5
|
-
import {
|
|
5
|
+
import { SF } from '@duplojs/server-utils';
|
|
6
6
|
|
|
7
7
|
function openApiGeneratorPlugin(pluginParams) {
|
|
8
8
|
return () => ({
|
|
@@ -17,7 +17,7 @@ function openApiGeneratorPlugin(pluginParams) {
|
|
|
17
17
|
}
|
|
18
18
|
const contextToJsonSchemaFactory = new Map();
|
|
19
19
|
const resultSchemaContext = new Map();
|
|
20
|
-
const routes = hub.
|
|
20
|
+
const routes = A.from(hub.routes);
|
|
21
21
|
const openApiRoutes = pipe(routes, A.filter((route) => route.definition.method !== "OPTIONS"), A.flatMap((route) => routeToOpenApi(route, {
|
|
22
22
|
defaultExtractContract: hub.defaultExtractContract,
|
|
23
23
|
resultSchemaContext,
|
|
@@ -75,7 +75,7 @@ function openApiGeneratorPlugin(pluginParams) {
|
|
|
75
75
|
};
|
|
76
76
|
const openApiDocumentString = JSON.stringify(openApiDocument, null, 2);
|
|
77
77
|
if (pluginParams.outputFile) {
|
|
78
|
-
await
|
|
78
|
+
asserts(await SF.writeTextFile(pluginParams.outputFile, openApiDocumentString), E.isRight);
|
|
79
79
|
}
|
|
80
80
|
if (pluginParams.routePath) {
|
|
81
81
|
const openApiPage = makeOpenApiPage({
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
var aggregateStepContract = require('./aggregateStepContract.cjs');
|
|
4
4
|
var utils = require('@duplojs/utils');
|
|
5
5
|
var toJsonSchema = require('@duplojs/data-parser-tools/toJsonSchema');
|
|
6
|
+
require('../../core/request/index.cjs');
|
|
6
7
|
var metadata = require('./metadata.cjs');
|
|
8
|
+
var formData = require('../../core/request/bodyController/formData.cjs');
|
|
7
9
|
|
|
8
10
|
function factoryJsonSchema(params) {
|
|
9
11
|
const identifier = params.schema.definition.identifier
|
|
@@ -32,6 +34,7 @@ const methodMapper = {
|
|
|
32
34
|
TRACE: "trace",
|
|
33
35
|
CONNECT: "connect",
|
|
34
36
|
OPTIONS: "options",
|
|
37
|
+
PATCH: "patch",
|
|
35
38
|
};
|
|
36
39
|
function routeToOpenApi(route, params) {
|
|
37
40
|
const isIgnore = utils.A.find(route.definition.metadata, metadata.IgnoreByOpenApiGeneratorMetadata.is);
|
|
@@ -58,7 +61,19 @@ function routeToOpenApi(route, params) {
|
|
|
58
61
|
schema,
|
|
59
62
|
}),
|
|
60
63
|
}))));
|
|
61
|
-
const requestBody = utils.pipe(body, utils.when((value) => utils.O.countKeys(value) === 0, utils.justReturn(utils.DP.empty())), utils.whenNot(utils.DP.dataParserKind.has, utils.DP.object), utils.P.when(utils.DP.identifier(utils.DP.emptyKind), utils.justReturn(undefined)), utils.P.when(
|
|
64
|
+
const requestBody = utils.pipe(body, utils.when((value) => utils.O.countKeys(value) === 0, utils.justReturn(utils.DP.empty())), utils.whenNot(utils.DP.dataParserKind.has, utils.DP.object), utils.P.when(utils.DP.identifier(utils.DP.emptyKind), utils.justReturn(undefined)), utils.P.when(() => formData.FormDataBodyController.is(route.definition.bodyController), (objectSchema) => ({
|
|
65
|
+
required: true,
|
|
66
|
+
content: {
|
|
67
|
+
"multipart/form-data": {
|
|
68
|
+
schema: factoryJsonSchema({
|
|
69
|
+
context: params.contextToJsonSchemaFactory,
|
|
70
|
+
resultSchemaContext: params.resultSchemaContext,
|
|
71
|
+
mode: "in",
|
|
72
|
+
schema: objectSchema,
|
|
73
|
+
}),
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
})), utils.P.when(utils.DP.identifier(utils.DP.objectKind), (objectSchema) => ({
|
|
62
77
|
required: true,
|
|
63
78
|
content: {
|
|
64
79
|
"application/json": {
|
|
@@ -10,9 +10,18 @@ export interface RouteToOpenApiParams {
|
|
|
10
10
|
}
|
|
11
11
|
export declare function routeToOpenApi(route: Route, params: RouteToOpenApiParams): {
|
|
12
12
|
path: `/${string}`;
|
|
13
|
-
method: "options" | "get" | "post" | "put" | "delete" | "head" | "trace" | "connect";
|
|
13
|
+
method: "options" | "get" | "post" | "put" | "patch" | "delete" | "head" | "trace" | "connect";
|
|
14
14
|
parameters: EntrypointParameter[];
|
|
15
15
|
requestBody: {
|
|
16
|
+
required: true;
|
|
17
|
+
content: {
|
|
18
|
+
"multipart/form-data": {
|
|
19
|
+
schema: {
|
|
20
|
+
$ref: `#/components/schemas/${string}`;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
} | {
|
|
16
25
|
required: true;
|
|
17
26
|
content: {
|
|
18
27
|
"application/json": {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { aggregateStepContract } from './aggregateStepContract.mjs';
|
|
2
2
|
import { O, A, pipe, DP, when, justReturn, whenNot, P, isType, S } from '@duplojs/utils';
|
|
3
3
|
import { render, defaultTransformers } from '@duplojs/data-parser-tools/toJsonSchema';
|
|
4
|
+
import '../../core/request/index.mjs';
|
|
4
5
|
import { IgnoreByOpenApiGeneratorMetadata } from './metadata.mjs';
|
|
6
|
+
import { FormDataBodyController } from '../../core/request/bodyController/formData.mjs';
|
|
5
7
|
|
|
6
8
|
function factoryJsonSchema(params) {
|
|
7
9
|
const identifier = params.schema.definition.identifier
|
|
@@ -30,6 +32,7 @@ const methodMapper = {
|
|
|
30
32
|
TRACE: "trace",
|
|
31
33
|
CONNECT: "connect",
|
|
32
34
|
OPTIONS: "options",
|
|
35
|
+
PATCH: "patch",
|
|
33
36
|
};
|
|
34
37
|
function routeToOpenApi(route, params) {
|
|
35
38
|
const isIgnore = A.find(route.definition.metadata, IgnoreByOpenApiGeneratorMetadata.is);
|
|
@@ -56,7 +59,19 @@ function routeToOpenApi(route, params) {
|
|
|
56
59
|
schema,
|
|
57
60
|
}),
|
|
58
61
|
}))));
|
|
59
|
-
const requestBody = pipe(body, when((value) => O.countKeys(value) === 0, justReturn(DP.empty())), whenNot(DP.dataParserKind.has, DP.object), P.when(DP.identifier(DP.emptyKind), justReturn(undefined)), P.when(
|
|
62
|
+
const requestBody = pipe(body, when((value) => O.countKeys(value) === 0, justReturn(DP.empty())), whenNot(DP.dataParserKind.has, DP.object), P.when(DP.identifier(DP.emptyKind), justReturn(undefined)), P.when(() => FormDataBodyController.is(route.definition.bodyController), (objectSchema) => ({
|
|
63
|
+
required: true,
|
|
64
|
+
content: {
|
|
65
|
+
"multipart/form-data": {
|
|
66
|
+
schema: factoryJsonSchema({
|
|
67
|
+
context: params.contextToJsonSchemaFactory,
|
|
68
|
+
resultSchemaContext: params.resultSchemaContext,
|
|
69
|
+
mode: "in",
|
|
70
|
+
schema: objectSchema,
|
|
71
|
+
}),
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
})), P.when(DP.identifier(DP.objectKind), (objectSchema) => ({
|
|
60
75
|
required: true,
|
|
61
76
|
content: {
|
|
62
77
|
"application/json": {
|
|
@@ -10,12 +10,17 @@ export interface EntrypointContentBodyApplicationJson {
|
|
|
10
10
|
schema: JsonSchema;
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
|
+
export interface EntrypointContentBodyFormData {
|
|
14
|
+
"multipart/form-data": {
|
|
15
|
+
schema: JsonSchema;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
13
18
|
export interface EntrypointContentBodyTextPlain {
|
|
14
19
|
"text/plain": {
|
|
15
20
|
schema: JsonSchema;
|
|
16
21
|
};
|
|
17
22
|
}
|
|
18
|
-
export type EntrypointContentBody = EntrypointContentBodyApplicationJson | EntrypointContentBodyTextPlain;
|
|
23
|
+
export type EntrypointContentBody = (EntrypointContentBodyApplicationJson | EntrypointContentBodyTextPlain | EntrypointContentBodyFormData);
|
|
19
24
|
export interface EntrypointRequestBody {
|
|
20
25
|
required: true;
|
|
21
26
|
content: EntrypointContentBody;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export type OpenApiMethod = "get" | "post" | "put" | "delete" | "head" | "trace" | "connect" | "options";
|
|
1
|
+
export type OpenApiMethod = "get" | "post" | "put" | "patch" | "delete" | "head" | "trace" | "connect" | "options";
|