@duplojs/http 0.1.0 → 0.4.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 +22 -0
- package/dist/client/getBody.d.ts +1 -0
- package/dist/client/getBody.mjs +20 -0
- package/dist/client/hooks.cjs +79 -0
- package/dist/client/hooks.d.ts +33 -0
- package/dist/client/hooks.mjs +70 -0
- package/dist/client/httpClient.cjs +153 -0
- package/dist/client/httpClient.d.ts +60 -0
- package/dist/client/httpClient.mjs +130 -0
- package/dist/client/index.cjs +33 -0
- package/dist/client/index.d.ts +9 -0
- package/dist/client/index.mjs +9 -0
- package/dist/client/insertParamsInPath.cjs +12 -0
- package/dist/client/insertParamsInPath.d.ts +2 -0
- package/dist/client/insertParamsInPath.mjs +10 -0
- package/dist/client/kind.cjs +9 -0
- package/dist/client/kind.d.ts +6 -0
- package/dist/client/kind.mjs +7 -0
- package/dist/client/promiseRequest.cjs +355 -0
- package/dist/client/promiseRequest.d.ts +98 -0
- package/dist/client/promiseRequest.mjs +332 -0
- package/dist/client/queryToString.cjs +25 -0
- package/dist/client/queryToString.d.ts +2 -0
- package/dist/client/queryToString.mjs +23 -0
- package/dist/client/types/ObjectCanBeEmpty.cjs +2 -0
- package/dist/client/types/ObjectCanBeEmpty.d.ts +4 -0
- package/dist/client/types/ObjectCanBeEmpty.mjs +1 -0
- package/dist/client/types/clientRequestParams.cjs +2 -0
- package/dist/client/types/clientRequestParams.d.ts +51 -0
- package/dist/client/types/clientRequestParams.mjs +1 -0
- package/dist/client/types/clientResponse.cjs +2 -0
- package/dist/client/types/clientResponse.d.ts +34 -0
- package/dist/client/types/clientResponse.mjs +1 -0
- package/dist/client/types/index.cjs +7 -0
- package/dist/client/types/index.d.ts +4 -0
- package/dist/client/types/index.mjs +4 -0
- package/dist/client/types/serverRoute.cjs +2 -0
- package/dist/client/types/serverRoute.d.ts +22 -0
- package/dist/client/types/serverRoute.mjs +1 -0
- package/dist/client/unexpectedResponseError.cjs +44 -0
- package/dist/client/unexpectedResponseError.d.ts +38 -0
- package/dist/client/unexpectedResponseError.mjs +39 -0
- package/dist/core/builders/index.cjs +11 -0
- package/dist/core/builders/index.mjs +4 -0
- package/dist/core/builders/preflight/index.cjs +10 -0
- package/dist/core/builders/preflight/index.mjs +3 -0
- package/dist/core/builders/preflight/process.cjs +2 -8
- package/dist/core/builders/preflight/process.mjs +2 -8
- package/dist/core/builders/preflight/route.cjs +2 -8
- package/dist/core/builders/preflight/route.mjs +2 -8
- package/dist/core/builders/process/checker.cjs +2 -8
- package/dist/core/builders/process/checker.mjs +2 -8
- package/dist/core/builders/process/cut.cjs +2 -8
- package/dist/core/builders/process/cut.mjs +2 -8
- package/dist/core/builders/process/extract.cjs +2 -8
- package/dist/core/builders/process/extract.mjs +2 -8
- package/dist/core/builders/process/index.cjs +14 -0
- package/dist/core/builders/process/index.mjs +7 -0
- package/dist/core/builders/process/presetChecker.cjs +2 -8
- package/dist/core/builders/process/presetChecker.mjs +2 -8
- package/dist/core/builders/process/process.cjs +2 -8
- package/dist/core/builders/process/process.mjs +2 -8
- package/dist/core/builders/route/checker.cjs +2 -8
- package/dist/core/builders/route/checker.mjs +2 -8
- package/dist/core/builders/route/cut.cjs +2 -8
- package/dist/core/builders/route/cut.mjs +2 -8
- package/dist/core/builders/route/extract.cjs +2 -8
- package/dist/core/builders/route/extract.mjs +2 -8
- package/dist/core/builders/route/handler.cjs +2 -8
- package/dist/core/builders/route/handler.mjs +2 -8
- package/dist/core/builders/route/index.cjs +16 -0
- package/dist/core/builders/route/index.mjs +8 -0
- package/dist/core/builders/route/presetChecker.cjs +2 -8
- package/dist/core/builders/route/presetChecker.mjs +2 -8
- package/dist/core/builders/route/process.cjs +2 -8
- package/dist/core/builders/route/process.mjs +2 -8
- package/dist/core/floor.cjs +2 -0
- package/dist/core/floor.mjs +1 -0
- package/dist/core/functionsBuilders/index.cjs +5 -0
- package/dist/core/functionsBuilders/index.mjs +2 -0
- package/dist/core/functionsBuilders/route/build.cjs +5 -14
- package/dist/core/functionsBuilders/route/build.d.ts +3 -1
- package/dist/core/functionsBuilders/route/build.mjs +6 -15
- package/dist/core/functionsBuilders/route/create.d.ts +2 -0
- package/dist/core/functionsBuilders/route/default.cjs +11 -21
- package/dist/core/functionsBuilders/route/default.mjs +5 -15
- package/dist/core/functionsBuilders/route/hook.cjs +22 -22
- package/dist/core/functionsBuilders/route/hook.d.ts +2 -2
- package/dist/core/functionsBuilders/route/hook.mjs +2 -2
- package/dist/core/functionsBuilders/route/index.cjs +18 -0
- package/dist/core/functionsBuilders/route/index.mjs +4 -0
- package/dist/core/functionsBuilders/steps/build.cjs +4 -0
- package/dist/core/functionsBuilders/steps/build.d.ts +2 -0
- package/dist/core/functionsBuilders/steps/build.mjs +5 -1
- package/dist/core/functionsBuilders/steps/create.d.ts +3 -2
- package/dist/core/functionsBuilders/steps/defaults/checkerStep.cjs +5 -9
- package/dist/core/functionsBuilders/steps/defaults/checkerStep.mjs +5 -9
- package/dist/core/functionsBuilders/steps/defaults/cutStep.cjs +6 -11
- package/dist/core/functionsBuilders/steps/defaults/cutStep.mjs +7 -12
- package/dist/core/functionsBuilders/steps/defaults/extractStep.cjs +10 -17
- package/dist/core/functionsBuilders/steps/defaults/extractStep.mjs +9 -16
- package/dist/core/functionsBuilders/steps/defaults/handlerStep.cjs +6 -11
- package/dist/core/functionsBuilders/steps/defaults/handlerStep.mjs +6 -11
- package/dist/core/functionsBuilders/steps/defaults/index.cjs +16 -0
- package/dist/core/functionsBuilders/steps/defaults/index.mjs +5 -0
- package/dist/core/functionsBuilders/steps/defaults/processStep.cjs +7 -12
- package/dist/core/functionsBuilders/steps/defaults/processStep.mjs +6 -11
- package/dist/core/functionsBuilders/steps/index.cjs +10 -0
- package/dist/core/functionsBuilders/steps/index.mjs +3 -0
- package/dist/core/hub/defaultNotfoundHandler.cjs +2 -8
- package/dist/core/hub/defaultNotfoundHandler.d.ts +1 -1
- package/dist/core/hub/defaultNotfoundHandler.mjs +2 -8
- package/dist/core/hub/hooks.d.ts +3 -3
- package/dist/core/hub/index.cjs +3 -9
- package/dist/core/hub/index.mjs +3 -9
- package/dist/core/index.cjs +64 -70
- package/dist/core/index.mjs +23 -30
- package/dist/core/process/index.cjs +1 -0
- package/dist/core/process/index.mjs +1 -0
- package/dist/core/process/types/index.cjs +2 -0
- package/dist/core/process/types/index.mjs +1 -0
- package/dist/core/response/base.cjs +40 -0
- package/dist/core/response/base.d.ts +21 -0
- package/dist/core/response/base.mjs +38 -0
- package/dist/core/response/contract.cjs +13 -13
- package/dist/core/response/contract.d.ts +121 -119
- package/dist/core/response/contract.mjs +14 -14
- package/dist/core/{route/hooks/response.cjs → response/hook.cjs} +5 -4
- package/dist/core/{route/hooks/response.d.ts → response/hook.d.ts} +3 -3
- package/dist/core/{route/hooks/response.mjs → response/hook.mjs} +4 -3
- package/dist/core/response/index.cjs +9 -38
- package/dist/core/response/index.d.ts +3 -20
- package/dist/core/response/index.mjs +3 -38
- package/dist/core/response/predicted.cjs +22 -0
- package/dist/core/response/predicted.d.ts +11 -0
- package/dist/core/response/predicted.mjs +20 -0
- package/dist/core/route/{hooks/index.cjs → hooks.cjs} +2 -3
- package/dist/core/route/{hooks/index.d.ts → hooks.d.ts} +4 -4
- package/dist/core/route/{hooks/index.mjs → hooks.mjs} +2 -2
- package/dist/core/route/index.cjs +5 -4
- package/dist/core/route/index.mjs +2 -1
- package/dist/core/route/types/buildedRoute.cjs +2 -0
- package/dist/core/route/types/buildedRoute.mjs +1 -0
- package/dist/core/route/types/index.cjs +4 -0
- package/dist/core/route/types/index.mjs +1 -0
- package/dist/core/router/buildError.cjs +3 -1
- package/dist/core/router/buildError.d.ts +4 -2
- package/dist/core/router/buildError.mjs +3 -1
- package/dist/core/router/index.cjs +13 -7
- package/dist/core/router/index.mjs +14 -8
- package/dist/core/router/types/buildedRouter.cjs +2 -0
- package/dist/core/router/types/buildedRouter.mjs +1 -0
- package/dist/core/router/types/index.cjs +4 -0
- package/dist/core/router/types/index.mjs +1 -0
- package/dist/core/steps/cut.d.ts +3 -3
- package/dist/core/steps/handler.d.ts +3 -3
- package/dist/core/steps/identifier.d.ts +2 -2
- package/dist/core/steps/index.cjs +29 -0
- package/dist/core/steps/index.mjs +9 -0
- package/dist/core/steps/types/buildedStep.cjs +2 -0
- package/dist/core/steps/types/buildedStep.mjs +1 -0
- package/dist/core/steps/types/index.cjs +6 -0
- package/dist/core/steps/types/index.mjs +3 -0
- package/dist/core/steps/types/stepFunctionParams.cjs +2 -0
- package/dist/core/steps/types/stepFunctionParams.d.ts +2 -2
- package/dist/core/steps/types/stepFunctionParams.mjs +1 -0
- package/dist/core/steps/types/steps.cjs +2 -0
- package/dist/core/steps/types/steps.mjs +1 -0
- package/dist/core/types/environment.cjs +2 -0
- package/dist/core/types/environment.d.ts +1 -1
- package/dist/core/types/environment.mjs +1 -0
- package/dist/core/types/forbiddenBigintDataParser.cjs +2 -0
- package/dist/core/types/forbiddenBigintDataParser.d.ts +6 -0
- package/dist/core/types/forbiddenBigintDataParser.mjs +1 -0
- package/dist/core/types/index.cjs +5 -0
- package/dist/core/types/index.d.ts +1 -0
- package/dist/core/types/index.mjs +2 -0
- package/dist/interfaces/bun/index.cjs +1 -9
- package/dist/interfaces/bun/index.mjs +1 -9
- package/dist/interfaces/bun/types/index.cjs +4 -0
- package/dist/interfaces/bun/types/index.mjs +1 -0
- package/dist/interfaces/bun/types/request.cjs +5 -0
- package/dist/interfaces/bun/types/request.mjs +2 -0
- package/dist/interfaces/deno/index.cjs +1 -0
- package/dist/interfaces/deno/index.mjs +1 -0
- package/dist/interfaces/deno/types/index.cjs +2 -0
- package/dist/interfaces/deno/types/index.mjs +1 -0
- package/dist/interfaces/node/createHttpServer.cjs +11 -3
- package/dist/interfaces/node/createHttpServer.d.ts +2 -1
- package/dist/interfaces/node/createHttpServer.mjs +11 -3
- package/dist/interfaces/node/error/index.cjs +11 -0
- package/dist/interfaces/node/error/index.mjs +3 -0
- package/dist/interfaces/node/hooks.cjs +17 -13
- package/dist/interfaces/node/hooks.mjs +16 -12
- package/dist/interfaces/node/index.cjs +6 -13
- package/dist/interfaces/node/index.mjs +4 -11
- package/dist/interfaces/node/types/host.cjs +2 -0
- package/dist/interfaces/node/types/host.mjs +1 -0
- package/dist/interfaces/node/types/index.cjs +5 -0
- package/dist/interfaces/node/types/index.mjs +2 -0
- package/dist/interfaces/node/types/request.cjs +5 -0
- package/dist/interfaces/node/types/request.mjs +2 -0
- package/dist/plugins/codeGenerator/index.cjs +13 -0
- package/dist/plugins/codeGenerator/index.d.ts +5 -0
- package/dist/plugins/codeGenerator/index.mjs +5 -0
- package/dist/plugins/codeGenerator/plugin.cjs +51 -0
- package/dist/plugins/codeGenerator/plugin.d.ts +5 -0
- package/dist/plugins/codeGenerator/plugin.mjs +30 -0
- package/dist/plugins/codeGenerator/routeToDataParser.cjs +28 -0
- package/dist/plugins/codeGenerator/routeToDataParser.d.ts +7 -0
- package/dist/plugins/codeGenerator/routeToDataParser.mjs +26 -0
- package/dist/plugins/codeGenerator/stepsToDataParser.cjs +66 -0
- package/dist/plugins/codeGenerator/stepsToDataParser.d.ts +14 -0
- package/dist/plugins/codeGenerator/stepsToDataParser.mjs +64 -0
- package/dist/plugins/codeGenerator/types/entrypointKey.cjs +2 -0
- package/dist/plugins/codeGenerator/types/entrypointKey.d.ts +1 -0
- package/dist/plugins/codeGenerator/types/entrypointKey.mjs +1 -0
- package/dist/plugins/codeGenerator/types/index.cjs +4 -0
- package/dist/plugins/codeGenerator/types/index.d.ts +1 -0
- package/dist/plugins/codeGenerator/types/index.mjs +1 -0
- package/dist/plugins/openApiGenerator/aggregateStepContract.cjs +62 -0
- package/dist/plugins/openApiGenerator/aggregateStepContract.d.ts +18 -0
- package/dist/plugins/openApiGenerator/aggregateStepContract.mjs +60 -0
- package/dist/plugins/openApiGenerator/index.cjs +17 -0
- package/dist/plugins/openApiGenerator/index.d.ts +7 -0
- package/dist/plugins/openApiGenerator/index.mjs +7 -0
- package/dist/plugins/openApiGenerator/makeOpenApiPage.cjs +30 -0
- package/dist/plugins/openApiGenerator/makeOpenApiPage.d.ts +7 -0
- package/dist/plugins/openApiGenerator/makeOpenApiPage.mjs +28 -0
- package/dist/plugins/openApiGenerator/makeOpenApiRoute.cjs +15 -0
- package/dist/plugins/openApiGenerator/makeOpenApiRoute.d.ts +18 -0
- package/dist/plugins/openApiGenerator/makeOpenApiRoute.mjs +13 -0
- package/dist/plugins/openApiGenerator/plugin.cjs +90 -0
- package/dist/plugins/openApiGenerator/plugin.d.ts +49 -0
- package/dist/plugins/openApiGenerator/plugin.mjs +88 -0
- package/dist/plugins/openApiGenerator/routeToOpenApi.cjs +163 -0
- package/dist/plugins/openApiGenerator/routeToOpenApi.d.ts +35 -0
- package/dist/plugins/openApiGenerator/routeToOpenApi.mjs +161 -0
- package/dist/plugins/openApiGenerator/types/endpointResponse.cjs +2 -0
- package/dist/plugins/openApiGenerator/types/endpointResponse.d.ts +19 -0
- package/dist/plugins/openApiGenerator/types/endpointResponse.mjs +1 -0
- package/dist/plugins/openApiGenerator/types/entrypoint.cjs +2 -0
- package/dist/plugins/openApiGenerator/types/entrypoint.d.ts +22 -0
- package/dist/plugins/openApiGenerator/types/entrypoint.mjs +1 -0
- package/dist/plugins/openApiGenerator/types/entrypointKey.cjs +2 -0
- package/dist/plugins/openApiGenerator/types/entrypointKey.d.ts +1 -0
- package/dist/plugins/openApiGenerator/types/entrypointKey.mjs +1 -0
- package/dist/plugins/openApiGenerator/types/index.cjs +11 -0
- package/dist/plugins/openApiGenerator/types/index.d.ts +8 -0
- package/dist/plugins/openApiGenerator/types/index.mjs +8 -0
- package/dist/plugins/openApiGenerator/types/openApiDocument.cjs +2 -0
- package/dist/plugins/openApiGenerator/types/openApiDocument.d.ts +31 -0
- package/dist/plugins/openApiGenerator/types/openApiDocument.mjs +1 -0
- package/dist/plugins/openApiGenerator/types/openApiMethod.cjs +2 -0
- package/dist/plugins/openApiGenerator/types/openApiMethod.d.ts +1 -0
- package/dist/plugins/openApiGenerator/types/openApiMethod.mjs +1 -0
- package/dist/plugins/openApiGenerator/types/openApiOperation.cjs +2 -0
- package/dist/plugins/openApiGenerator/types/openApiOperation.d.ts +8 -0
- package/dist/plugins/openApiGenerator/types/openApiOperation.mjs +1 -0
- package/dist/plugins/openApiGenerator/types/openApiPath.cjs +2 -0
- package/dist/plugins/openApiGenerator/types/openApiPath.d.ts +4 -0
- package/dist/plugins/openApiGenerator/types/openApiPath.mjs +1 -0
- package/dist/plugins/openApiGenerator/types/openApiSecuritySchema.cjs +2 -0
- package/dist/plugins/openApiGenerator/types/openApiSecuritySchema.d.ts +8 -0
- package/dist/plugins/openApiGenerator/types/openApiSecuritySchema.mjs +1 -0
- package/package.json +22 -3
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { type BuildStepFunctionParams } from "../steps";
|
|
2
2
|
import { type BuildRouteNotSupportEither, type createRouteFunctionBuilder } from "./create";
|
|
3
3
|
import { type HookRouteLifeCycle, type Route } from "../../route";
|
|
4
|
+
import { type ResponseContract } from "../../response";
|
|
4
5
|
export interface BuildRouteFunctionParams extends BuildStepFunctionParams {
|
|
5
6
|
readonly routeFunctionBuilders: readonly ReturnType<typeof createRouteFunctionBuilder>[];
|
|
6
7
|
readonly globalHooksRouteLifeCycle: readonly HookRouteLifeCycle[];
|
|
8
|
+
readonly defaultExtractContract: ResponseContract.Contract;
|
|
7
9
|
}
|
|
8
|
-
export declare function buildRouteFunction(route: Route, params: BuildRouteFunctionParams): Promise<BuildRouteNotSupportEither | import("./create").BuildRouteSuccessEither>;
|
|
10
|
+
export declare function buildRouteFunction(route: Route, params: BuildRouteFunctionParams): Promise<BuildRouteNotSupportEither | import("./create").BuildRouteSuccessEither | import("..").BuildStepNotSupportEither>;
|
|
@@ -1,18 +1,5 @@
|
|
|
1
|
-
import { G,
|
|
2
|
-
import '
|
|
3
|
-
import '../../steps/kind.mjs';
|
|
4
|
-
import '../../steps/identifier.mjs';
|
|
5
|
-
import '../../steps/checker.mjs';
|
|
6
|
-
import '../../steps/extract.mjs';
|
|
7
|
-
import '../../steps/cut.mjs';
|
|
8
|
-
import '../../steps/handler.mjs';
|
|
9
|
-
import '../../steps/process.mjs';
|
|
10
|
-
import '../../steps/presetChecker.mjs';
|
|
11
|
-
import '../../response/index.mjs';
|
|
12
|
-
import '../steps/defaults/cutStep.mjs';
|
|
13
|
-
import '../steps/defaults/handlerStep.mjs';
|
|
14
|
-
import '../steps/defaults/extractStep.mjs';
|
|
15
|
-
import '../steps/defaults/processStep.mjs';
|
|
1
|
+
import { E, G, unwrap } from '@duplojs/utils';
|
|
2
|
+
import '../steps/index.mjs';
|
|
16
3
|
import { buildStepFunction } from '../steps/build.mjs';
|
|
17
4
|
|
|
18
5
|
function buildRouteFunction(route, params) {
|
|
@@ -25,10 +12,14 @@ function buildRouteFunction(route, params) {
|
|
|
25
12
|
},
|
|
26
13
|
environment: params.environment,
|
|
27
14
|
globalHooksRouteLifeCycle: params.globalHooksRouteLifeCycle,
|
|
15
|
+
defaultExtractContract: params.defaultExtractContract,
|
|
28
16
|
};
|
|
29
17
|
return G.asyncReduce(params.routeFunctionBuilders, G.reduceFrom(E.left("routeNotSupport", route)), async ({ element: functionBuilder, lastValue, next, exit, }) => {
|
|
30
18
|
const result = await functionBuilder(route, functionParams);
|
|
31
19
|
if (E.isLeft(result)) {
|
|
20
|
+
if (unwrap(result) !== route) {
|
|
21
|
+
return exit(result);
|
|
22
|
+
}
|
|
32
23
|
return next(lastValue);
|
|
33
24
|
}
|
|
34
25
|
return exit(result);
|
|
@@ -4,6 +4,7 @@ import { type Request } from "../../request";
|
|
|
4
4
|
import { type Environment } from "../../types";
|
|
5
5
|
import { type BuildStepSuccessEither, type BuildStepNotSupportEither } from "../steps";
|
|
6
6
|
import { type Steps } from "../../steps";
|
|
7
|
+
import { type ResponseContract } from "../../response";
|
|
7
8
|
export type BuildedRouteFunction = (request: Request) => Promise<void>;
|
|
8
9
|
export type BuildRouteSuccessEither = E.EitherRight<"buildSuccess", BuildedRouteFunction>;
|
|
9
10
|
export type BuildRouteNotSupportEither = E.EitherLeft<"routeNotSupport", Route>;
|
|
@@ -12,5 +13,6 @@ export interface RouteFunctionBuilderParams {
|
|
|
12
13
|
readonly environment: Environment;
|
|
13
14
|
buildStep(element: Steps): Promise<BuildStepSuccessEither | BuildStepNotSupportEither>;
|
|
14
15
|
success(result: BuildedRouteFunction): BuildRouteSuccessEither;
|
|
16
|
+
readonly defaultExtractContract: ResponseContract.Contract;
|
|
15
17
|
}
|
|
16
18
|
export declare function createRouteFunctionBuilder(support: (route: Route) => boolean, builder: (route: Route, params: RouteFunctionBuilderParams) => MaybePromise<BuildRouteSuccessEither | BuildStepNotSupportEither>): (route: Route, params: RouteFunctionBuilderParams) => MaybePromise<BuildRouteNotSupportEither | BuildRouteSuccessEither | BuildStepNotSupportEither>;
|
|
@@ -2,23 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
var index = require('../../route/index.cjs');
|
|
4
4
|
var utils = require('@duplojs/utils');
|
|
5
|
-
|
|
5
|
+
require('../../response/index.cjs');
|
|
6
6
|
var hook = require('./hook.cjs');
|
|
7
7
|
var create = require('./create.cjs');
|
|
8
|
-
require('
|
|
9
|
-
require('../../steps/kind.cjs');
|
|
10
|
-
require('../../steps/identifier.cjs');
|
|
11
|
-
require('../../steps/checker.cjs');
|
|
12
|
-
require('../../steps/extract.cjs');
|
|
13
|
-
require('../../steps/cut.cjs');
|
|
14
|
-
require('../../steps/handler.cjs');
|
|
15
|
-
require('../../steps/process.cjs');
|
|
16
|
-
require('../../steps/presetChecker.cjs');
|
|
17
|
-
require('../steps/defaults/cutStep.cjs');
|
|
18
|
-
require('../steps/defaults/handlerStep.cjs');
|
|
19
|
-
require('../steps/defaults/extractStep.cjs');
|
|
8
|
+
require('../steps/index.cjs');
|
|
20
9
|
var processStep = require('../steps/defaults/processStep.cjs');
|
|
21
|
-
var
|
|
10
|
+
var base = require('../../response/base.cjs');
|
|
11
|
+
var hook$1 = require('../../response/hook.cjs');
|
|
22
12
|
|
|
23
13
|
/* eslint-disable @typescript-eslint/prefer-for-of */
|
|
24
14
|
const defaultRouteFunctionBuilder = create.createRouteFunctionBuilder(index.routeKind.has, async (route, { success, buildStep, globalHooksRouteLifeCycle, }) => {
|
|
@@ -74,13 +64,13 @@ const defaultRouteFunctionBuilder = create.createRouteFunctionBuilder(index.rout
|
|
|
74
64
|
next: hook.nextHookFunction,
|
|
75
65
|
response: hook.createHookResponse("beforeRouteExecution"),
|
|
76
66
|
});
|
|
77
|
-
if (beforeRouteExecutionResult instanceof
|
|
67
|
+
if (beforeRouteExecutionResult instanceof base.Response) {
|
|
78
68
|
return beforeRouteExecutionResult;
|
|
79
69
|
}
|
|
80
70
|
let floor = {};
|
|
81
71
|
for (let index = 0; index < buildedPreFlightSteps.length; index++) {
|
|
82
72
|
const result = await buildedPreFlightSteps[index].buildedFunction(request, floor);
|
|
83
|
-
if (result instanceof
|
|
73
|
+
if (result instanceof base.Response) {
|
|
84
74
|
return result;
|
|
85
75
|
}
|
|
86
76
|
floor = result;
|
|
@@ -91,17 +81,17 @@ const defaultRouteFunctionBuilder = create.createRouteFunctionBuilder(index.rout
|
|
|
91
81
|
next: hook.nextHookFunction,
|
|
92
82
|
response: hook.createHookResponse("parseBody"),
|
|
93
83
|
});
|
|
94
|
-
if (parseBodyResult instanceof
|
|
84
|
+
if (parseBodyResult instanceof base.Response) {
|
|
95
85
|
return parseBodyResult;
|
|
96
86
|
}
|
|
97
87
|
for (let index = 0; index < buildedSteps.length; index++) {
|
|
98
88
|
const result = await buildedSteps[index].buildedFunction(request, floor);
|
|
99
|
-
if (result instanceof
|
|
89
|
+
if (result instanceof base.Response) {
|
|
100
90
|
return result;
|
|
101
91
|
}
|
|
102
92
|
floor = result;
|
|
103
93
|
}
|
|
104
|
-
return new
|
|
94
|
+
return new base.Response("500", "missing-response", undefined);
|
|
105
95
|
}
|
|
106
96
|
catch (error) {
|
|
107
97
|
const errorResult = await hooks.error({
|
|
@@ -111,10 +101,10 @@ const defaultRouteFunctionBuilder = create.createRouteFunctionBuilder(index.rout
|
|
|
111
101
|
next: hook.nextHookFunction,
|
|
112
102
|
response: hook.createHookResponse("error"),
|
|
113
103
|
});
|
|
114
|
-
if (errorResult instanceof
|
|
104
|
+
if (errorResult instanceof hook$1.HookResponse) {
|
|
115
105
|
return errorResult;
|
|
116
106
|
}
|
|
117
|
-
return new
|
|
107
|
+
return new base.Response("500", "server-error", error);
|
|
118
108
|
}
|
|
119
109
|
}
|
|
120
110
|
return success(async (request) => {
|
|
@@ -1,22 +1,12 @@
|
|
|
1
1
|
import { routeKind } from '../../route/index.mjs';
|
|
2
2
|
import { E, A, pipe, isType, forward } from '@duplojs/utils';
|
|
3
|
-
import
|
|
4
|
-
import { buildHookAfter, buildHookErrorBefore, buildHookBefore, nextHookFunction, exitHookFunction
|
|
3
|
+
import '../../response/index.mjs';
|
|
4
|
+
import { buildHookAfter, buildHookErrorBefore, buildHookBefore, createHookResponse, nextHookFunction, exitHookFunction } from './hook.mjs';
|
|
5
5
|
import { createRouteFunctionBuilder } from './create.mjs';
|
|
6
|
-
import '
|
|
7
|
-
import '../../steps/kind.mjs';
|
|
8
|
-
import '../../steps/identifier.mjs';
|
|
9
|
-
import '../../steps/checker.mjs';
|
|
10
|
-
import '../../steps/extract.mjs';
|
|
11
|
-
import '../../steps/cut.mjs';
|
|
12
|
-
import '../../steps/handler.mjs';
|
|
13
|
-
import '../../steps/process.mjs';
|
|
14
|
-
import '../../steps/presetChecker.mjs';
|
|
15
|
-
import '../steps/defaults/cutStep.mjs';
|
|
16
|
-
import '../steps/defaults/handlerStep.mjs';
|
|
17
|
-
import '../steps/defaults/extractStep.mjs';
|
|
6
|
+
import '../steps/index.mjs';
|
|
18
7
|
import { buildStepsFunction } from '../steps/defaults/processStep.mjs';
|
|
19
|
-
import {
|
|
8
|
+
import { Response } from '../../response/base.mjs';
|
|
9
|
+
import { HookResponse } from '../../response/hook.mjs';
|
|
20
10
|
|
|
21
11
|
/* eslint-disable @typescript-eslint/prefer-for-of */
|
|
22
12
|
const defaultRouteFunctionBuilder = createRouteFunctionBuilder(routeKind.has, async (route, { success, buildStep, globalHooksRouteLifeCycle, }) => {
|
|
@@ -1,56 +1,56 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
require('../../route/index.cjs');
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var hooks = require('../../route/hooks.cjs');
|
|
5
|
+
var hook = require('../../response/hook.cjs');
|
|
6
6
|
|
|
7
7
|
/* eslint-disable @typescript-eslint/prefer-for-of */
|
|
8
|
-
const hookExit =
|
|
9
|
-
const hookNext =
|
|
8
|
+
const hookExit = hooks.hookRouteExitKind.setTo({});
|
|
9
|
+
const hookNext = hooks.hookRouteNextKind.setTo({});
|
|
10
10
|
function exitHookFunction() {
|
|
11
11
|
return hookExit;
|
|
12
12
|
}
|
|
13
13
|
function nextHookFunction() {
|
|
14
14
|
return hookNext;
|
|
15
15
|
}
|
|
16
|
-
function buildHookBefore(hooks) {
|
|
17
|
-
if (!hooks.length) {
|
|
16
|
+
function buildHookBefore(hooks$1) {
|
|
17
|
+
if (!hooks$1.length) {
|
|
18
18
|
return exitHookFunction;
|
|
19
19
|
}
|
|
20
20
|
return async (params) => {
|
|
21
|
-
for (let index
|
|
22
|
-
const result = await hooks[index
|
|
23
|
-
if (
|
|
24
|
-
|| result instanceof
|
|
21
|
+
for (let index = 0; index < hooks$1.length; index++) {
|
|
22
|
+
const result = await hooks$1[index](params);
|
|
23
|
+
if (hooks.hookRouteExitKind.has(result)
|
|
24
|
+
|| result instanceof hook.HookResponse) {
|
|
25
25
|
return result;
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
return hookNext;
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
-
function buildHookErrorBefore(hooks) {
|
|
32
|
-
if (!hooks.length) {
|
|
31
|
+
function buildHookErrorBefore(hooks$1) {
|
|
32
|
+
if (!hooks$1.length) {
|
|
33
33
|
return exitHookFunction;
|
|
34
34
|
}
|
|
35
35
|
return async (params) => {
|
|
36
|
-
for (let index
|
|
37
|
-
const result = await hooks[index
|
|
38
|
-
if (
|
|
39
|
-
|| result instanceof
|
|
36
|
+
for (let index = 0; index < hooks$1.length; index++) {
|
|
37
|
+
const result = await hooks$1[index](params);
|
|
38
|
+
if (hooks.hookRouteExitKind.has(result)
|
|
39
|
+
|| result instanceof hook.HookResponse) {
|
|
40
40
|
return result;
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
return hookNext;
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
|
-
function buildHookAfter(hooks) {
|
|
47
|
-
if (!hooks.length) {
|
|
46
|
+
function buildHookAfter(hooks$1) {
|
|
47
|
+
if (!hooks$1.length) {
|
|
48
48
|
return exitHookFunction;
|
|
49
49
|
}
|
|
50
50
|
return async (params) => {
|
|
51
|
-
for (let index
|
|
52
|
-
const result = await hooks[index
|
|
53
|
-
if (
|
|
51
|
+
for (let index = 0; index < hooks$1.length; index++) {
|
|
52
|
+
const result = await hooks$1[index](params);
|
|
53
|
+
if (hooks.hookRouteExitKind.has(result)) {
|
|
54
54
|
return result;
|
|
55
55
|
}
|
|
56
56
|
}
|
|
@@ -58,7 +58,7 @@ function buildHookAfter(hooks) {
|
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
60
|
function createHookResponse(from) {
|
|
61
|
-
return (code, information, body) => new
|
|
61
|
+
return (code, information, body) => new hook.HookResponse(from, code, information, body);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
exports.buildHookAfter = buildHookAfter;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type HookAfterSendResponse, type HookBeforeRouteExecution, type HookBeforeSendResponse, type HookError, type HookParseBody, HookResponse, type HookRouteLifeCycle, type HookSendResponse, type RouteHookErrorParams, type RouteHookParams, type RouteHookParamsAfter } from "../../route";
|
|
2
2
|
export declare function exitHookFunction(): import("@duplojs/utils").Kind<import("@duplojs/utils").KindDefinition<"@DuplojsHttpCore/route-hook-exit", unknown>, unknown>;
|
|
3
3
|
export declare function nextHookFunction(): import("@duplojs/utils").Kind<import("@duplojs/utils").KindDefinition<"@DuplojsHttpCore/route-hook-next", unknown>, unknown>;
|
|
4
|
-
export declare function buildHookBefore(hooks: (HookBeforeRouteExecution | HookParseBody)[]): typeof exitHookFunction | ((params: RouteHookParams) => Promise<import("../../route").RouteHookExit | import("@duplojs/utils").Kind<import("@duplojs/utils").KindDefinition<"@DuplojsHttpCore/route-hook-next", unknown>, unknown> | HookResponse<import("
|
|
5
|
-
export declare function buildHookErrorBefore(hooks: HookError[]): typeof exitHookFunction | ((params: RouteHookErrorParams) => Promise<import("../../route").RouteHookExit | import("@duplojs/utils").Kind<import("@duplojs/utils").KindDefinition<"@DuplojsHttpCore/route-hook-next", unknown>, unknown> | HookResponse<import("
|
|
4
|
+
export declare function buildHookBefore(hooks: (HookBeforeRouteExecution | HookParseBody)[]): typeof exitHookFunction | ((params: RouteHookParams) => Promise<import("../../route").RouteHookExit | import("@duplojs/utils").Kind<import("@duplojs/utils").KindDefinition<"@DuplojsHttpCore/route-hook-next", unknown>, unknown> | HookResponse<import("../../route").ResponseCode, string, unknown>>);
|
|
5
|
+
export declare function buildHookErrorBefore(hooks: HookError[]): typeof exitHookFunction | ((params: RouteHookErrorParams) => Promise<import("../../route").RouteHookExit | import("@duplojs/utils").Kind<import("@duplojs/utils").KindDefinition<"@DuplojsHttpCore/route-hook-next", unknown>, unknown> | HookResponse<import("../../route").ResponseCode, string, unknown>>);
|
|
6
6
|
export declare function buildHookAfter(hooks: (HookBeforeSendResponse | HookSendResponse | HookAfterSendResponse)[]): typeof exitHookFunction | ((params: RouteHookParamsAfter) => Promise<import("../../route").RouteHookExit | import("@duplojs/utils").Kind<import("@duplojs/utils").KindDefinition<"@DuplojsHttpCore/route-hook-next", unknown>, unknown>>);
|
|
7
7
|
export declare function createHookResponse(from: keyof HookRouteLifeCycle): RouteHookParams["response"];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import '../../route/index.mjs';
|
|
2
|
-
import { hookRouteExitKind, hookRouteNextKind } from '../../route/hooks
|
|
3
|
-
import { HookResponse } from '../../
|
|
2
|
+
import { hookRouteExitKind, hookRouteNextKind } from '../../route/hooks.mjs';
|
|
3
|
+
import { HookResponse } from '../../response/hook.mjs';
|
|
4
4
|
|
|
5
5
|
/* eslint-disable @typescript-eslint/prefer-for-of */
|
|
6
6
|
const hookExit = hookRouteExitKind.setTo({});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var build = require('./build.cjs');
|
|
4
|
+
var create = require('./create.cjs');
|
|
5
|
+
var _default = require('./default.cjs');
|
|
6
|
+
var hook = require('./hook.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
exports.buildRouteFunction = build.buildRouteFunction;
|
|
11
|
+
exports.createRouteFunctionBuilder = create.createRouteFunctionBuilder;
|
|
12
|
+
exports.defaultRouteFunctionBuilder = _default.defaultRouteFunctionBuilder;
|
|
13
|
+
exports.buildHookAfter = hook.buildHookAfter;
|
|
14
|
+
exports.buildHookBefore = hook.buildHookBefore;
|
|
15
|
+
exports.buildHookErrorBefore = hook.buildHookErrorBefore;
|
|
16
|
+
exports.createHookResponse = hook.createHookResponse;
|
|
17
|
+
exports.exitHookFunction = hook.exitHookFunction;
|
|
18
|
+
exports.nextHookFunction = hook.nextHookFunction;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { buildRouteFunction } from './build.mjs';
|
|
2
|
+
export { createRouteFunctionBuilder } from './create.mjs';
|
|
3
|
+
export { defaultRouteFunctionBuilder } from './default.mjs';
|
|
4
|
+
export { buildHookAfter, buildHookBefore, buildHookErrorBefore, createHookResponse, exitHookFunction, nextHookFunction } from './hook.mjs';
|
|
@@ -11,10 +11,14 @@ function buildStepFunction(step, params) {
|
|
|
11
11
|
return buildStepFunction(step, params);
|
|
12
12
|
},
|
|
13
13
|
environment: params.environment,
|
|
14
|
+
defaultExtractContract: params.defaultExtractContract,
|
|
14
15
|
};
|
|
15
16
|
return utils.G.asyncReduce(params.stepFunctionBuilders, utils.G.reduceFrom(utils.E.left("stepNotSupport", step)), async ({ element: functionBuilder, lastValue, next, exit, }) => {
|
|
16
17
|
const result = await functionBuilder(step, functionParams);
|
|
17
18
|
if (utils.E.isLeft(result)) {
|
|
19
|
+
if (utils.unwrap(result) !== step) {
|
|
20
|
+
return exit(result);
|
|
21
|
+
}
|
|
18
22
|
return next(lastValue);
|
|
19
23
|
}
|
|
20
24
|
return exit(result);
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { type Steps } from "../../steps/types";
|
|
2
2
|
import { type BuildStepNotSupportEither, type createStepFunctionBuilder } from "./create";
|
|
3
3
|
import { type Environment } from "../../types";
|
|
4
|
+
import { type ResponseContract } from "../../response";
|
|
4
5
|
export interface BuildStepFunctionParams {
|
|
5
6
|
readonly stepFunctionBuilders: readonly ReturnType<typeof createStepFunctionBuilder>[];
|
|
6
7
|
readonly environment: Environment;
|
|
8
|
+
readonly defaultExtractContract: ResponseContract.Contract;
|
|
7
9
|
}
|
|
8
10
|
export declare function buildStepFunction(step: Steps, params: BuildStepFunctionParams): Promise<BuildStepNotSupportEither | import("./create").BuildStepSuccessEither>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { G,
|
|
1
|
+
import { E, G, unwrap } from '@duplojs/utils';
|
|
2
2
|
|
|
3
3
|
function buildStepFunction(step, params) {
|
|
4
4
|
const functionParams = {
|
|
@@ -9,10 +9,14 @@ function buildStepFunction(step, params) {
|
|
|
9
9
|
return buildStepFunction(step, params);
|
|
10
10
|
},
|
|
11
11
|
environment: params.environment,
|
|
12
|
+
defaultExtractContract: params.defaultExtractContract,
|
|
12
13
|
};
|
|
13
14
|
return G.asyncReduce(params.stepFunctionBuilders, G.reduceFrom(E.left("stepNotSupport", step)), async ({ element: functionBuilder, lastValue, next, exit, }) => {
|
|
14
15
|
const result = await functionBuilder(step, functionParams);
|
|
15
16
|
if (E.isLeft(result)) {
|
|
17
|
+
if (unwrap(result) !== step) {
|
|
18
|
+
return exit(result);
|
|
19
|
+
}
|
|
16
20
|
return next(lastValue);
|
|
17
21
|
}
|
|
18
22
|
return exit(result);
|
|
@@ -3,9 +3,9 @@ import { type Steps } from "../../steps/types";
|
|
|
3
3
|
import { type Floor } from "../../floor";
|
|
4
4
|
import { type HookRouteLifeCycle } from "../../route";
|
|
5
5
|
import { type Request } from "../../request";
|
|
6
|
-
import { type
|
|
6
|
+
import { type ResponseContract, type PredictedResponse } from "../../response";
|
|
7
7
|
import { type Environment } from "../../types";
|
|
8
|
-
export type BuildedStepFunction = (request: Request, floor: Floor) => MaybePromise<Floor |
|
|
8
|
+
export type BuildedStepFunction = (request: Request, floor: Floor) => MaybePromise<Floor | PredictedResponse>;
|
|
9
9
|
export interface BuildStepResult {
|
|
10
10
|
readonly buildedFunction: BuildedStepFunction;
|
|
11
11
|
readonly hooksRouteLifeCycle: readonly HookRouteLifeCycle[];
|
|
@@ -16,5 +16,6 @@ export interface StepFunctionBuilderParams {
|
|
|
16
16
|
buildStep(element: Steps): Promise<BuildStepSuccessEither | BuildStepNotSupportEither>;
|
|
17
17
|
success(result: BuildStepResult): BuildStepSuccessEither;
|
|
18
18
|
readonly environment: Environment;
|
|
19
|
+
readonly defaultExtractContract: ResponseContract.Contract;
|
|
19
20
|
}
|
|
20
21
|
export declare function createStepFunctionBuilder<GenericSupportStep extends Steps>(support: (step: Steps) => step is GenericSupportStep, builder: (step: GenericSupportStep, params: StepFunctionBuilderParams) => MaybePromise<BuildStepSuccessEither | BuildStepNotSupportEither>): (step: Steps, params: StepFunctionBuilderParams) => MaybePromise<BuildStepSuccessEither | BuildStepNotSupportEither>;
|
|
@@ -2,16 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
var checker$1 = require('../../../checker.cjs');
|
|
4
4
|
var create = require('../create.cjs');
|
|
5
|
-
require('../../../steps/
|
|
6
|
-
require('
|
|
5
|
+
require('../../../steps/index.cjs');
|
|
6
|
+
var utils = require('@duplojs/utils');
|
|
7
|
+
require('../../../response/index.cjs');
|
|
7
8
|
var checker = require('../../../steps/checker.cjs');
|
|
8
|
-
require('../../../steps/extract.cjs');
|
|
9
|
-
require('../../../steps/cut.cjs');
|
|
10
|
-
require('../../../steps/handler.cjs');
|
|
11
|
-
require('../../../steps/process.cjs');
|
|
12
9
|
var presetChecker = require('../../../steps/presetChecker.cjs');
|
|
13
|
-
var
|
|
14
|
-
var index = require('../../../response/index.cjs');
|
|
10
|
+
var predicted = require('../../../response/predicted.cjs');
|
|
15
11
|
|
|
16
12
|
const defaultCheckerStepFunctionBuilder = create.createStepFunctionBuilder((element) => checker.checkerStepKind.has(element) || presetChecker.presetCheckerStepKind.has(element), (step, { success }) => {
|
|
17
13
|
const { checkerOptions, checkerFunction, input, responseContract, stepResult, indexing, stepOptions, } = utils.pipe(step, utils.P.when(checker.checkerStepKind.has, ({ definition }) => ({
|
|
@@ -41,7 +37,7 @@ const defaultCheckerStepFunctionBuilder = create.createStepFunctionBuilder((elem
|
|
|
41
37
|
});
|
|
42
38
|
const expectedResult = utils.pipe(stepResult, utils.P.when(utils.isType("string"), (expectedInformation) => ((information) => information === expectedInformation)), utils.P.otherwise((expectedInformation) => ((information) => expectedInformation.includes(information))));
|
|
43
39
|
function getResponse() {
|
|
44
|
-
return new
|
|
40
|
+
return new predicted.PredictedResponse(responseContract.code, responseContract.information, undefined);
|
|
45
41
|
}
|
|
46
42
|
function treatResult(output, floor) {
|
|
47
43
|
if (!expectedResult(output.information)) {
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import { checkerOutputKind } from '../../../checker.mjs';
|
|
2
2
|
import { createStepFunctionBuilder } from '../create.mjs';
|
|
3
|
-
import '../../../steps/
|
|
4
|
-
import '
|
|
3
|
+
import '../../../steps/index.mjs';
|
|
4
|
+
import { pipe, P, or, isType, forward } from '@duplojs/utils';
|
|
5
|
+
import '../../../response/index.mjs';
|
|
5
6
|
import { checkerStepKind } from '../../../steps/checker.mjs';
|
|
6
|
-
import '../../../steps/extract.mjs';
|
|
7
|
-
import '../../../steps/cut.mjs';
|
|
8
|
-
import '../../../steps/handler.mjs';
|
|
9
|
-
import '../../../steps/process.mjs';
|
|
10
7
|
import { presetCheckerStepKind } from '../../../steps/presetChecker.mjs';
|
|
11
|
-
import {
|
|
12
|
-
import { Response } from '../../../response/index.mjs';
|
|
8
|
+
import { PredictedResponse } from '../../../response/predicted.mjs';
|
|
13
9
|
|
|
14
10
|
const defaultCheckerStepFunctionBuilder = createStepFunctionBuilder((element) => checkerStepKind.has(element) || presetCheckerStepKind.has(element), (step, { success }) => {
|
|
15
11
|
const { checkerOptions, checkerFunction, input, responseContract, stepResult, indexing, stepOptions, } = pipe(step, P.when(checkerStepKind.has, ({ definition }) => ({
|
|
@@ -39,7 +35,7 @@ const defaultCheckerStepFunctionBuilder = createStepFunctionBuilder((element) =>
|
|
|
39
35
|
});
|
|
40
36
|
const expectedResult = pipe(stepResult, P.when(isType("string"), (expectedInformation) => ((information) => information === expectedInformation)), P.otherwise((expectedInformation) => ((information) => expectedInformation.includes(information))));
|
|
41
37
|
function getResponse() {
|
|
42
|
-
return new
|
|
38
|
+
return new PredictedResponse(responseContract.code, responseContract.information, undefined);
|
|
43
39
|
}
|
|
44
40
|
function treatResult(output, floor) {
|
|
45
41
|
if (!expectedResult(output.information)) {
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
require('../../../steps/
|
|
4
|
-
require('../../../steps/identifier.cjs');
|
|
5
|
-
require('../../../steps/checker.cjs');
|
|
6
|
-
require('../../../steps/extract.cjs');
|
|
7
|
-
var cut = require('../../../steps/cut.cjs');
|
|
8
|
-
require('../../../steps/handler.cjs');
|
|
9
|
-
require('../../../steps/process.cjs');
|
|
10
|
-
require('../../../steps/presetChecker.cjs');
|
|
3
|
+
require('../../../steps/index.cjs');
|
|
11
4
|
var create = require('../create.cjs');
|
|
12
5
|
var utils = require('@duplojs/utils');
|
|
13
|
-
|
|
6
|
+
require('../../../response/index.cjs');
|
|
7
|
+
var cut = require('../../../steps/cut.cjs');
|
|
14
8
|
var contract = require('../../../response/contract.cjs');
|
|
9
|
+
var predicted = require('../../../response/predicted.cjs');
|
|
15
10
|
|
|
16
11
|
const defaultCutStepFunctionBuilder = create.createStepFunctionBuilder(cut.cutStepKind.has, (step, { success }) => {
|
|
17
12
|
const { responseContract, theFunction: cutFunction, } = step.definition;
|
|
@@ -24,11 +19,11 @@ const defaultCutStepFunctionBuilder = create.createStepFunctionBuilder(cut.cutSt
|
|
|
24
19
|
if (!currentContract) {
|
|
25
20
|
throw new contract.ResponseContract.Error(information);
|
|
26
21
|
}
|
|
27
|
-
const result = currentContract.
|
|
22
|
+
const result = currentContract.body.parse(body);
|
|
28
23
|
if (utils.E.isLeft(result)) {
|
|
29
24
|
throw new contract.ResponseContract.Error(information, utils.unwrap(result));
|
|
30
25
|
}
|
|
31
|
-
return new
|
|
26
|
+
return new predicted.PredictedResponse(currentContract.code, currentContract.information, body);
|
|
32
27
|
};
|
|
33
28
|
function treatResult(result, floor) {
|
|
34
29
|
if (cut.cutStepOutputKind.has(result)) {
|
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
import '../../../steps/
|
|
2
|
-
import '../../../steps/identifier.mjs';
|
|
3
|
-
import '../../../steps/checker.mjs';
|
|
4
|
-
import '../../../steps/extract.mjs';
|
|
5
|
-
import { cutStepKind, cutStepOutputKind } from '../../../steps/cut.mjs';
|
|
6
|
-
import '../../../steps/handler.mjs';
|
|
7
|
-
import '../../../steps/process.mjs';
|
|
8
|
-
import '../../../steps/presetChecker.mjs';
|
|
1
|
+
import '../../../steps/index.mjs';
|
|
9
2
|
import { createStepFunctionBuilder } from '../create.mjs';
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
3
|
+
import { wrapValue, A, E, unwrap } from '@duplojs/utils';
|
|
4
|
+
import '../../../response/index.mjs';
|
|
5
|
+
import { cutStepKind, cutStepOutputKind } from '../../../steps/cut.mjs';
|
|
12
6
|
import { ResponseContract } from '../../../response/contract.mjs';
|
|
7
|
+
import { PredictedResponse } from '../../../response/predicted.mjs';
|
|
13
8
|
|
|
14
9
|
const defaultCutStepFunctionBuilder = createStepFunctionBuilder(cutStepKind.has, (step, { success }) => {
|
|
15
10
|
const { responseContract, theFunction: cutFunction, } = step.definition;
|
|
@@ -22,11 +17,11 @@ const defaultCutStepFunctionBuilder = createStepFunctionBuilder(cutStepKind.has,
|
|
|
22
17
|
if (!currentContract) {
|
|
23
18
|
throw new ResponseContract.Error(information);
|
|
24
19
|
}
|
|
25
|
-
const result = currentContract.
|
|
20
|
+
const result = currentContract.body.parse(body);
|
|
26
21
|
if (E.isLeft(result)) {
|
|
27
22
|
throw new ResponseContract.Error(information, unwrap(result));
|
|
28
23
|
}
|
|
29
|
-
return new
|
|
24
|
+
return new PredictedResponse(currentContract.code, currentContract.information, body);
|
|
30
25
|
};
|
|
31
26
|
function treatResult(result, floor) {
|
|
32
27
|
if (cutStepOutputKind.has(result)) {
|
|
@@ -1,24 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
require('../../../steps/
|
|
4
|
-
require('../../../steps/identifier.cjs');
|
|
5
|
-
require('../../../steps/checker.cjs');
|
|
6
|
-
var extract = require('../../../steps/extract.cjs');
|
|
7
|
-
require('../../../steps/cut.cjs');
|
|
8
|
-
require('../../../steps/handler.cjs');
|
|
9
|
-
require('../../../steps/process.cjs');
|
|
10
|
-
require('../../../steps/presetChecker.cjs');
|
|
3
|
+
require('../../../steps/index.cjs');
|
|
11
4
|
var utils = require('@duplojs/utils');
|
|
12
|
-
|
|
5
|
+
require('../../../response/index.cjs');
|
|
13
6
|
var create = require('../create.cjs');
|
|
14
|
-
var
|
|
7
|
+
var extract = require('../../../steps/extract.cjs');
|
|
8
|
+
var predicted = require('../../../response/predicted.cjs');
|
|
15
9
|
|
|
16
|
-
const defaultExtractStepFunctionBuilder = create.createStepFunctionBuilder(extract.extractStepKind.has, (step, { success, environment }) => {
|
|
10
|
+
const defaultExtractStepFunctionBuilder = create.createStepFunctionBuilder(extract.extractStepKind.has, (step, { success, environment, defaultExtractContract }) => {
|
|
17
11
|
const { shape, responseContract: stepResponseContract, } = step.definition;
|
|
18
|
-
const responseContract = stepResponseContract ??
|
|
19
|
-
.unprocessableContent("extract-error");
|
|
12
|
+
const responseContract = stepResponseContract ?? defaultExtractContract;
|
|
20
13
|
function getResponse(result, key, subKey) {
|
|
21
|
-
const response = new
|
|
14
|
+
const response = new predicted.PredictedResponse(responseContract.code, responseContract.information, environment === "DEV"
|
|
22
15
|
? utils.unwrap(result)
|
|
23
16
|
: undefined);
|
|
24
17
|
return subKey === undefined
|
|
@@ -41,9 +34,9 @@ const defaultExtractStepFunctionBuilder = create.createStepFunctionBuilder(extra
|
|
|
41
34
|
buildedFunction: (request, floor) => {
|
|
42
35
|
let newFloor = floor;
|
|
43
36
|
// eslint-disable-next-line @typescript-eslint/prefer-for-of
|
|
44
|
-
for (let index
|
|
45
|
-
const result = extractors[index
|
|
46
|
-
if (result instanceof
|
|
37
|
+
for (let index = 0; index < extractors.length; index++) {
|
|
38
|
+
const result = extractors[index](request, newFloor);
|
|
39
|
+
if (result instanceof predicted.PredictedResponse) {
|
|
47
40
|
return result;
|
|
48
41
|
}
|
|
49
42
|
newFloor = result;
|
|
@@ -1,22 +1,15 @@
|
|
|
1
|
-
import '../../../steps/
|
|
2
|
-
import '
|
|
3
|
-
import '../../../
|
|
4
|
-
import { extractStepKind } from '../../../steps/extract.mjs';
|
|
5
|
-
import '../../../steps/cut.mjs';
|
|
6
|
-
import '../../../steps/handler.mjs';
|
|
7
|
-
import '../../../steps/process.mjs';
|
|
8
|
-
import '../../../steps/presetChecker.mjs';
|
|
9
|
-
import { A, O, pipe, DP, P, isType, justReturn, innerPipe, E, unwrap } from '@duplojs/utils';
|
|
10
|
-
import { Response } from '../../../response/index.mjs';
|
|
1
|
+
import '../../../steps/index.mjs';
|
|
2
|
+
import { unwrap, E, A, O, DP, pipe, P, isType, justReturn, innerPipe } from '@duplojs/utils';
|
|
3
|
+
import '../../../response/index.mjs';
|
|
11
4
|
import { createStepFunctionBuilder } from '../create.mjs';
|
|
12
|
-
import {
|
|
5
|
+
import { extractStepKind } from '../../../steps/extract.mjs';
|
|
6
|
+
import { PredictedResponse } from '../../../response/predicted.mjs';
|
|
13
7
|
|
|
14
|
-
const defaultExtractStepFunctionBuilder = createStepFunctionBuilder(extractStepKind.has, (step, { success, environment }) => {
|
|
8
|
+
const defaultExtractStepFunctionBuilder = createStepFunctionBuilder(extractStepKind.has, (step, { success, environment, defaultExtractContract }) => {
|
|
15
9
|
const { shape, responseContract: stepResponseContract, } = step.definition;
|
|
16
|
-
const responseContract = stepResponseContract ??
|
|
17
|
-
.unprocessableContent("extract-error");
|
|
10
|
+
const responseContract = stepResponseContract ?? defaultExtractContract;
|
|
18
11
|
function getResponse(result, key, subKey) {
|
|
19
|
-
const response = new
|
|
12
|
+
const response = new PredictedResponse(responseContract.code, responseContract.information, environment === "DEV"
|
|
20
13
|
? unwrap(result)
|
|
21
14
|
: undefined);
|
|
22
15
|
return subKey === undefined
|
|
@@ -41,7 +34,7 @@ const defaultExtractStepFunctionBuilder = createStepFunctionBuilder(extractStepK
|
|
|
41
34
|
// eslint-disable-next-line @typescript-eslint/prefer-for-of
|
|
42
35
|
for (let index = 0; index < extractors.length; index++) {
|
|
43
36
|
const result = extractors[index](request, newFloor);
|
|
44
|
-
if (result instanceof
|
|
37
|
+
if (result instanceof PredictedResponse) {
|
|
45
38
|
return result;
|
|
46
39
|
}
|
|
47
40
|
newFloor = result;
|