@duplojs/http 0.8.4 → 0.9.5
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/core/builders/preflight/builder.d.ts +5 -6
- package/dist/core/builders/preflight/process.d.ts +3 -4
- package/dist/core/builders/preflight/route.d.ts +4 -5
- package/dist/core/builders/process/builder.d.ts +4 -5
- package/dist/core/builders/process/checker.d.ts +2 -3
- package/dist/core/builders/process/cut.d.ts +4 -5
- package/dist/core/builders/process/exports.d.ts +3 -4
- package/dist/core/builders/process/extract.d.ts +2 -3
- package/dist/core/builders/process/presetChecker.d.ts +2 -3
- package/dist/core/builders/process/process.d.ts +3 -4
- package/dist/core/builders/route/builder.d.ts +6 -6
- package/dist/core/builders/route/checker.d.ts +2 -3
- package/dist/core/builders/route/cut.d.ts +4 -5
- package/dist/core/builders/route/extract.d.ts +3 -3
- package/dist/core/builders/route/handler.d.ts +3 -4
- package/dist/core/builders/route/presetChecker.d.ts +2 -3
- package/dist/core/builders/route/process.d.ts +3 -4
- package/dist/core/defaultHooks/index.d.ts +1 -1
- package/dist/core/functionsBuilders/index.cjs +1 -0
- package/dist/core/functionsBuilders/index.d.ts +1 -0
- package/dist/core/functionsBuilders/index.mjs +1 -0
- package/dist/core/functionsBuilders/route/build.d.ts +5 -2
- package/dist/core/functionsBuilders/route/create.d.ts +3 -5
- package/dist/core/functionsBuilders/route/{hook.cjs → default/hook.cjs} +16 -7
- package/dist/core/functionsBuilders/route/{hook.d.ts → default/hook.d.ts} +5 -5
- package/dist/core/functionsBuilders/route/{hook.mjs → default/hook.mjs} +16 -7
- package/dist/core/functionsBuilders/route/{default.cjs → default/index.cjs} +22 -34
- package/dist/core/functionsBuilders/route/default/index.d.ts +2 -0
- package/dist/core/functionsBuilders/route/{default.mjs → default/index.mjs} +11 -29
- package/dist/core/functionsBuilders/route/index.cjs +2 -9
- package/dist/core/functionsBuilders/route/index.d.ts +0 -1
- package/dist/core/functionsBuilders/route/index.mjs +1 -2
- package/dist/core/functionsBuilders/router/build.cjs +7 -0
- package/dist/core/functionsBuilders/router/build.d.ts +14 -0
- package/dist/core/functionsBuilders/router/build.mjs +5 -0
- package/dist/core/functionsBuilders/router/create.cjs +7 -0
- package/dist/core/functionsBuilders/router/create.d.ts +15 -0
- package/dist/core/functionsBuilders/router/create.mjs +5 -0
- package/dist/core/functionsBuilders/router/default/index.cjs +52 -0
- package/dist/core/functionsBuilders/router/default/index.d.ts +1 -0
- package/dist/core/functionsBuilders/router/default/index.mjs +50 -0
- package/dist/core/functionsBuilders/router/index.cjs +11 -0
- package/dist/core/functionsBuilders/router/index.d.ts +3 -0
- package/dist/core/functionsBuilders/router/index.mjs +3 -0
- package/dist/core/functionsBuilders/steps/create.d.ts +3 -6
- package/dist/core/hub/defaultMalformedUrlHandler.d.ts +1 -1
- package/dist/core/hub/defaultNotfoundHandler.d.ts +1 -1
- package/dist/core/hub/hooks.d.ts +2 -2
- package/dist/core/hub/index.cjs +5 -0
- package/dist/core/hub/index.d.ts +6 -3
- package/dist/core/hub/index.mjs +5 -0
- package/dist/core/implementHttpServer.cjs +1 -1
- package/dist/core/implementHttpServer.d.ts +2 -2
- package/dist/core/implementHttpServer.mjs +2 -2
- package/dist/core/index.cjs +15 -14
- package/dist/core/index.mjs +8 -6
- package/dist/core/process/index.d.ts +0 -7
- package/dist/core/request/bodyController/formData.cjs +1 -0
- package/dist/core/request/bodyController/formData.d.ts +2 -0
- package/dist/core/request/bodyController/formData.mjs +1 -0
- package/dist/core/route/hooks.cjs +2 -17
- package/dist/core/route/hooks.d.ts +15 -32
- package/dist/core/route/hooks.mjs +3 -17
- package/dist/core/route/index.cjs +0 -1
- package/dist/core/route/index.mjs +1 -1
- package/dist/core/router/{buildSystemRoute.cjs → createRouterElementSystem.cjs} +4 -3
- package/dist/core/router/createRouterElementSystem.d.ts +9 -0
- package/dist/core/router/{buildSystemRoute.mjs → createRouterElementSystem.mjs} +4 -3
- package/dist/core/router/index.cjs +19 -60
- package/dist/core/router/index.d.ts +3 -4
- package/dist/core/router/index.mjs +17 -56
- package/dist/core/router/types/buildedRouter.d.ts +2 -12
- package/dist/core/router/types/index.cjs +4 -0
- package/dist/core/router/types/index.d.ts +4 -0
- package/dist/core/router/types/index.mjs +4 -0
- package/dist/core/router/types/router.cjs +2 -0
- package/dist/core/router/types/router.d.ts +12 -0
- package/dist/core/router/types/router.mjs +1 -0
- package/dist/core/router/types/routerElement.cjs +2 -0
- package/dist/core/router/types/routerElement.d.ts +8 -0
- package/dist/core/router/types/routerElement.mjs +1 -0
- package/dist/core/router/types/routerElementSystem.cjs +2 -0
- package/dist/core/router/types/routerElementSystem.d.ts +6 -0
- package/dist/core/router/types/routerElementSystem.mjs +1 -0
- package/dist/core/router/types/routerElementWrapper.cjs +2 -0
- package/dist/core/router/types/routerElementWrapper.d.ts +2 -0
- package/dist/core/router/types/routerElementWrapper.mjs +1 -0
- package/dist/core/steps/cut.d.ts +1 -2
- package/dist/core/steps/handler.d.ts +1 -2
- package/dist/core/steps/types/stepFunctionParams.d.ts +2 -2
- package/dist/interfaces/node/bodyReaders/formData/index.cjs +1 -0
- package/dist/interfaces/node/bodyReaders/formData/index.mjs +1 -0
- package/dist/interfaces/node/bodyReaders/formData/readRequestFormData.cjs +10 -1
- package/dist/interfaces/node/bodyReaders/formData/readRequestFormData.d.ts +2 -1
- package/dist/interfaces/node/bodyReaders/formData/readRequestFormData.mjs +10 -1
- package/dist/interfaces/node/createHttpServer.cjs +2 -2
- package/dist/interfaces/node/createHttpServer.mjs +2 -2
- package/dist/interfaces/node/hooks/index.d.ts +3 -3
- package/dist/plugins/cacheController/hooks.cjs +2 -1
- package/dist/plugins/cacheController/hooks.d.ts +1 -1
- package/dist/plugins/cacheController/hooks.mjs +2 -1
- package/dist/plugins/cors/headerFunctions/allowHeaders.cjs +11 -0
- package/dist/plugins/cors/headerFunctions/allowHeaders.d.ts +5 -0
- package/dist/plugins/cors/headerFunctions/allowHeaders.mjs +9 -0
- package/dist/plugins/cors/headerFunctions/allowMethods.cjs +16 -0
- package/dist/plugins/cors/headerFunctions/allowMethods.d.ts +6 -0
- package/dist/plugins/cors/headerFunctions/allowMethods.mjs +14 -0
- package/dist/plugins/cors/headerFunctions/allowOrigin.cjs +24 -0
- package/dist/plugins/cors/headerFunctions/allowOrigin.d.ts +7 -0
- package/dist/plugins/cors/headerFunctions/allowOrigin.mjs +22 -0
- package/dist/plugins/cors/headerFunctions/credentials.cjs +11 -0
- package/dist/plugins/cors/headerFunctions/credentials.d.ts +5 -0
- package/dist/plugins/cors/headerFunctions/credentials.mjs +9 -0
- package/dist/plugins/cors/headerFunctions/exposeHeaders.cjs +11 -0
- package/dist/plugins/cors/headerFunctions/exposeHeaders.d.ts +5 -0
- package/dist/plugins/cors/headerFunctions/exposeHeaders.mjs +9 -0
- package/dist/plugins/cors/headerFunctions/index.cjs +19 -0
- package/dist/plugins/cors/headerFunctions/index.d.ts +7 -0
- package/dist/plugins/cors/headerFunctions/index.mjs +7 -0
- package/dist/plugins/cors/headerFunctions/maxAge.cjs +11 -0
- package/dist/plugins/cors/headerFunctions/maxAge.d.ts +5 -0
- package/dist/plugins/cors/headerFunctions/maxAge.mjs +9 -0
- package/dist/plugins/cors/headerFunctions/vary.cjs +35 -0
- package/dist/plugins/cors/headerFunctions/vary.d.ts +5 -0
- package/dist/plugins/cors/headerFunctions/vary.mjs +33 -0
- package/dist/plugins/cors/index.cjs +9 -0
- package/dist/plugins/cors/index.d.ts +2 -0
- package/dist/plugins/cors/index.mjs +2 -0
- package/dist/plugins/cors/metadata.cjs +8 -0
- package/dist/plugins/cors/metadata.d.ts +1 -0
- package/dist/plugins/cors/metadata.mjs +6 -0
- package/dist/plugins/cors/plugin.cjs +108 -0
- package/dist/plugins/cors/plugin.d.ts +12 -0
- package/dist/plugins/cors/plugin.mjs +106 -0
- package/dist/plugins/openApiGenerator/makeOpenApiRoute.d.ts +1 -1
- package/dist/plugins/static/makeRouteFile.d.ts +2 -2
- package/dist/plugins/static/makeRouteFolder.cjs +1 -1
- package/dist/plugins/static/makeRouteFolder.d.ts +2 -2
- package/dist/plugins/static/makeRouteFolder.mjs +1 -1
- package/dist/plugins/static/plugin.d.ts +1 -1
- package/package.json +30 -5
- package/dist/core/functionsBuilders/route/default.d.ts +0 -1
- package/dist/core/router/buildSystemRoute.d.ts +0 -11
- /package/dist/core/{router/decodeUrl.cjs → decodeUrl.cjs} +0 -0
- /package/dist/core/{router/decodeUrl.d.ts → decodeUrl.d.ts} +0 -0
- /package/dist/core/{router/decodeUrl.mjs → decodeUrl.mjs} +0 -0
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { type Floor } from "../../floor";
|
|
2
|
-
import { type
|
|
3
|
-
import { type Builder
|
|
4
|
-
import { type Request } from "../../request";
|
|
2
|
+
import { type HookRouteLifeCycle, type RoutePreFlightSteps } from "../../route";
|
|
3
|
+
import { type Builder } from "@duplojs/utils";
|
|
5
4
|
import { type Metadata } from "../../metadata";
|
|
6
5
|
export interface PreflightBuilderDefinition {
|
|
7
6
|
readonly preflightSteps: readonly RoutePreFlightSteps[];
|
|
8
7
|
readonly hooks: readonly HookRouteLifeCycle[];
|
|
9
8
|
readonly metadata: readonly Metadata[];
|
|
10
9
|
}
|
|
11
|
-
export interface PreflightBuilder<GenericDefinition extends PreflightBuilderDefinition = PreflightBuilderDefinition, GenericFloor extends Floor = {}
|
|
10
|
+
export interface PreflightBuilder<GenericDefinition extends PreflightBuilderDefinition = PreflightBuilderDefinition, GenericFloor extends Floor = {}> extends Builder<PreflightBuilderDefinition> {
|
|
12
11
|
}
|
|
13
|
-
export declare const preflightBuilder: import("@duplojs/utils").BuilderHandler<PreflightBuilder<PreflightBuilderDefinition, {}
|
|
12
|
+
export declare const preflightBuilder: import("@duplojs/utils").BuilderHandler<PreflightBuilder<PreflightBuilderDefinition, {}>>;
|
|
14
13
|
export declare function usePreflightBuilder<const GenericHooks extends readonly HookRouteLifeCycle[] = readonly [], const GenericMetadata extends readonly Metadata[] = readonly []>(options?: {
|
|
15
14
|
hooks?: GenericHooks | readonly HookRouteLifeCycle[];
|
|
16
15
|
metadata?: GenericMetadata;
|
|
@@ -18,4 +17,4 @@ export declare function usePreflightBuilder<const GenericHooks extends readonly
|
|
|
18
17
|
readonly preflightSteps: readonly [];
|
|
19
18
|
readonly hooks: GenericHooks;
|
|
20
19
|
readonly metadata: GenericMetadata;
|
|
21
|
-
}, {}
|
|
20
|
+
}, {}>;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { type Floor } from "../../floor";
|
|
2
2
|
import { type ProcessStep } from "../../steps";
|
|
3
3
|
import { type O, type NeverCoalescing, type FixDeepFunctionInfer, type Adaptor, type AnyFunction } from "@duplojs/utils";
|
|
4
|
-
import { type
|
|
5
|
-
import { type Request } from "../../request";
|
|
4
|
+
import { type GetProcessExportValue, type Process } from "../../process";
|
|
6
5
|
import { type Metadata } from "../../metadata";
|
|
7
6
|
declare module "./builder" {
|
|
8
|
-
interface PreflightBuilder<GenericDefinition extends PreflightBuilderDefinition = PreflightBuilderDefinition, GenericFloor extends Floor = {}
|
|
7
|
+
interface PreflightBuilder<GenericDefinition extends PreflightBuilderDefinition = PreflightBuilderDefinition, GenericFloor extends Floor = {}> {
|
|
9
8
|
exec<GenericProcess extends Process, GenericProcessExportValue extends GetProcessExportValue<GenericProcess>, const GenericImportation extends readonly Extract<keyof GenericProcessExportValue, string>[] = never, GenericOptions extends (GenericProcess["definition"]["options"] | ((floor: GenericFloor) => Exclude<GenericProcess["definition"]["options"], undefined>)) = never, const GenericMetadata extends readonly Metadata[] = readonly []>(process: GenericProcess, params?: {
|
|
10
9
|
readonly imports?: GenericImportation;
|
|
11
10
|
readonly options?: FixDeepFunctionInfer<GenericProcess["definition"]["options"] | ((floor: GenericFloor) => GenericProcess["definition"]["options"]), GenericOptions>;
|
|
@@ -19,6 +18,6 @@ declare module "./builder" {
|
|
|
19
18
|
readonly metadata: GenericMetadata;
|
|
20
19
|
}>
|
|
21
20
|
];
|
|
22
|
-
}>, O.AssignObjects<GenericFloor, Pick<GenericProcessExportValue, GenericImportation[number]
|
|
21
|
+
}>, O.AssignObjects<GenericFloor, Pick<GenericProcessExportValue, GenericImportation[number]>>>;
|
|
23
22
|
}
|
|
24
23
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { type Floor } from "../../floor";
|
|
2
|
-
import { type RequestMethods, type
|
|
3
|
-
import { type
|
|
2
|
+
import { type RequestMethods, type BodyController } from "../../request";
|
|
3
|
+
import { type HookRouteLifeCycle, type RoutePath } from "../../route";
|
|
4
4
|
import { type RouteBuilder } from "../route";
|
|
5
|
-
import { type NeverCoalescing } from "@duplojs/utils";
|
|
6
5
|
import { type Metadata } from "../../metadata";
|
|
7
6
|
declare module "./builder" {
|
|
8
|
-
interface PreflightBuilder<GenericDefinition extends PreflightBuilderDefinition = PreflightBuilderDefinition, GenericFloor extends Floor = {}
|
|
7
|
+
interface PreflightBuilder<GenericDefinition extends PreflightBuilderDefinition = PreflightBuilderDefinition, GenericFloor extends Floor = {}> {
|
|
9
8
|
useRouteBuilder<GenericMethod extends RequestMethods, const GenericPaths extends RoutePath | readonly [RoutePath, ...RoutePath[]], const GenericHooks extends readonly HookRouteLifeCycle[] = readonly [], const GenericMetadata extends readonly Metadata[] = readonly [], const GenericBodyController extends BodyController | null = null>(method: GenericMethod, path: GenericPaths, options?: {
|
|
10
9
|
hooks?: GenericHooks | readonly HookRouteLifeCycle[];
|
|
11
10
|
metadata?: GenericMetadata;
|
|
@@ -24,6 +23,6 @@ declare module "./builder" {
|
|
|
24
23
|
...GenericDefinition["metadata"]
|
|
25
24
|
];
|
|
26
25
|
readonly bodyController: GenericBodyController;
|
|
27
|
-
}, GenericFloor
|
|
26
|
+
}, GenericFloor>;
|
|
28
27
|
}
|
|
29
28
|
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { type ProcessDefinition } from "../../process";
|
|
2
2
|
import { type Floor } from "../../floor";
|
|
3
3
|
import { type Builder, type IsEqual, type NeverCoalescing } from "@duplojs/utils";
|
|
4
|
-
import { type
|
|
5
|
-
import { type Request } from "../../request";
|
|
4
|
+
import { type HookRouteLifeCycle } from "../../route";
|
|
6
5
|
import { type Metadata } from "../../metadata";
|
|
7
|
-
export interface ProcessBuilder<GenericDefinition extends ProcessDefinition = ProcessDefinition, GenericFloor extends Floor = {}
|
|
6
|
+
export interface ProcessBuilder<GenericDefinition extends ProcessDefinition = ProcessDefinition, GenericFloor extends Floor = {}> extends Builder<ProcessDefinition> {
|
|
8
7
|
}
|
|
9
|
-
export declare const processBuilder: import("@duplojs/utils").BuilderHandler<ProcessBuilder<ProcessDefinition, {}
|
|
8
|
+
export declare const processBuilder: import("@duplojs/utils").BuilderHandler<ProcessBuilder<ProcessDefinition, {}>>;
|
|
10
9
|
export declare function useProcessBuilder<GenericOptions extends ProcessDefinition["options"] = never, const GenericHooks extends readonly HookRouteLifeCycle[] = readonly [], const GenericMetadata extends readonly Metadata[] = readonly []>(params?: {
|
|
11
10
|
options?: GenericOptions;
|
|
12
11
|
hooks?: GenericHooks | readonly HookRouteLifeCycle[];
|
|
@@ -18,4 +17,4 @@ export declare function useProcessBuilder<GenericOptions extends ProcessDefiniti
|
|
|
18
17
|
readonly metadata: GenericMetadata;
|
|
19
18
|
}, IsEqual<GenericOptions, never> extends true ? {} : {
|
|
20
19
|
options: GenericOptions;
|
|
21
|
-
}
|
|
20
|
+
}>;
|
|
@@ -4,10 +4,9 @@ import { type O, type MaybeArray, type NeverCoalescing, type FixDeepFunctionInfe
|
|
|
4
4
|
import { type GetCheckerResult, type Checker, type GetCheckerInput, type GetCheckerOptions } from "../../checker";
|
|
5
5
|
import { type ClientErrorResponseCode, type ResponseContract } from "../../response";
|
|
6
6
|
import { type ProcessDefinition } from "../../process";
|
|
7
|
-
import { type Request } from "../../request";
|
|
8
7
|
import { type Metadata } from "../../metadata";
|
|
9
8
|
declare module "./builder" {
|
|
10
|
-
interface ProcessBuilder<GenericDefinition extends ProcessDefinition = ProcessDefinition, GenericFloor extends Floor = {}
|
|
9
|
+
interface ProcessBuilder<GenericDefinition extends ProcessDefinition = ProcessDefinition, GenericFloor extends Floor = {}> {
|
|
11
10
|
check<GenericChecker extends Checker, GenericResultInformation extends MaybeArray<Awaited<GetCheckerResult<GenericChecker>>["information"]>, GenericInput extends GetCheckerInput<GenericChecker>, GenericResponseContract extends ResponseContract.Contract<ClientErrorResponseCode, string, DP.DataParserEmpty>, GenericIndex extends string = never, GenericOptions extends (GetCheckerOptions<GenericChecker> | ((floor: GenericFloor) => Exclude<GetCheckerOptions<GenericChecker>, undefined>)) = never, const GenericMetadata extends readonly Metadata[] = readonly []>(checker: GenericChecker, params: {
|
|
12
11
|
input(floor: GenericFloor): GenericInput;
|
|
13
12
|
readonly result: GenericResultInformation;
|
|
@@ -31,6 +30,6 @@ declare module "./builder" {
|
|
|
31
30
|
[Prop in GenericIndex]: Extract<Awaited<GetCheckerResult<GenericChecker>>, {
|
|
32
31
|
information: A.ArrayCoalescing<GenericResultInformation>[number];
|
|
33
32
|
}>["value"];
|
|
34
|
-
}
|
|
33
|
+
}>>;
|
|
35
34
|
}
|
|
36
35
|
}
|
|
@@ -3,19 +3,18 @@ import { type ResponseContract } from "../../response";
|
|
|
3
3
|
import { type CutStepFunctionOutput, type CutStep, type CutStepFunctionParams } from "../../steps";
|
|
4
4
|
import { type Unwrap, type O, type MaybePromise, type IsEqual, type A } from "@duplojs/utils";
|
|
5
5
|
import { type ProcessDefinition } from "../../process";
|
|
6
|
-
import { type Request } from "../../request";
|
|
7
6
|
import { type Metadata } from "../../metadata";
|
|
8
7
|
declare module "./builder" {
|
|
9
|
-
interface ProcessBuilder<GenericDefinition extends ProcessDefinition = ProcessDefinition, GenericFloor extends Floor = {}
|
|
10
|
-
cut<const GenericResponseContract extends (ResponseContract.Contract | readonly ResponseContract.Contract[]), GenericResponse extends ResponseContract.Convert<A.ArrayCoalescing<GenericResponseContract>[number]>, GenericOutput extends CutStepFunctionOutput | GenericResponse, const GenericMetadata extends readonly Metadata[] = readonly []>(responseContract: GenericResponseContract, theFunction: (floor: GenericFloor, param: CutStepFunctionParams<
|
|
8
|
+
interface ProcessBuilder<GenericDefinition extends ProcessDefinition = ProcessDefinition, GenericFloor extends Floor = {}> {
|
|
9
|
+
cut<const GenericResponseContract extends (ResponseContract.Contract | readonly ResponseContract.Contract[]), GenericResponse extends ResponseContract.Convert<A.ArrayCoalescing<GenericResponseContract>[number]>, GenericOutput extends CutStepFunctionOutput | GenericResponse, const GenericMetadata extends readonly Metadata[] = readonly []>(responseContract: GenericResponseContract, theFunction: (floor: GenericFloor, param: CutStepFunctionParams<GenericResponse>) => MaybePromise<GenericOutput>, ...metadata: GenericMetadata): ProcessBuilder<O.AssignObjects<GenericDefinition, {
|
|
11
10
|
readonly steps: readonly [
|
|
12
11
|
...GenericDefinition["steps"],
|
|
13
12
|
CutStep<{
|
|
14
13
|
readonly responseContract: GenericResponseContract;
|
|
15
|
-
theFunction(floor: GenericFloor, param: CutStepFunctionParams<
|
|
14
|
+
theFunction(floor: GenericFloor, param: CutStepFunctionParams<GenericResponse>): MaybePromise<GenericOutput>;
|
|
16
15
|
readonly metadata: GenericMetadata;
|
|
17
16
|
}>
|
|
18
17
|
];
|
|
19
|
-
}>, IsEqual<Extract<GenericOutput, CutStepFunctionOutput>, never> extends true ? GenericFloor : (GenericOutput extends infer InferredOutputData extends CutStepFunctionOutput ? O.AssignObjects<GenericFloor, Unwrap<InferredOutputData>> : never)
|
|
18
|
+
}>, IsEqual<Extract<GenericOutput, CutStepFunctionOutput>, never> extends true ? GenericFloor : (GenericOutput extends infer InferredOutputData extends CutStepFunctionOutput ? O.AssignObjects<GenericFloor, Unwrap<InferredOutputData>> : never)>;
|
|
20
19
|
}
|
|
21
20
|
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { type Floor } from "../../floor";
|
|
2
2
|
import { type SimplifyTopLevel, type IsEqual, type Or } from "@duplojs/utils";
|
|
3
|
-
import { type Process, type ProcessExportValue, type ProcessDefinition
|
|
4
|
-
import { type Request } from "../../request";
|
|
3
|
+
import { type Process, type ProcessExportValue, type ProcessDefinition } from "../../process";
|
|
5
4
|
declare module "./builder" {
|
|
6
|
-
interface ProcessBuilder<GenericDefinition extends ProcessDefinition = ProcessDefinition, GenericFloor extends Floor = {}
|
|
5
|
+
interface ProcessBuilder<GenericDefinition extends ProcessDefinition = ProcessDefinition, GenericFloor extends Floor = {}> {
|
|
7
6
|
exports<GenericExportation extends (keyof GenericFloor)[] = never>(exportedKey?: GenericExportation): Process<SimplifyTopLevel<GenericDefinition & (Or<[
|
|
8
7
|
IsEqual<GenericExportation, never>,
|
|
9
8
|
IsEqual<GenericExportation, never[]>
|
|
10
|
-
]> extends true ? {} : ProcessExportValue<SimplifyTopLevel<Pick<GenericFloor, GenericExportation[number]>>>)
|
|
9
|
+
]> extends true ? {} : ProcessExportValue<SimplifyTopLevel<Pick<GenericFloor, GenericExportation[number]>>>)>>;
|
|
11
10
|
}
|
|
12
11
|
}
|
|
@@ -3,10 +3,9 @@ import { type ExtractShape, type ExtractStep } from "../../steps";
|
|
|
3
3
|
import { type DP, type ObjectEntry, type O, type SimplifyTopLevel, type NeverCoalescing } from "@duplojs/utils";
|
|
4
4
|
import { type ClientErrorResponseCode, type ResponseContract } from "../../response";
|
|
5
5
|
import { type ProcessDefinition } from "../../process";
|
|
6
|
-
import { type Request } from "../../request";
|
|
7
6
|
import { type Metadata } from "../../metadata";
|
|
8
7
|
declare module "./builder" {
|
|
9
|
-
interface ProcessBuilder<GenericDefinition extends ProcessDefinition = ProcessDefinition, GenericFloor extends Floor = {}
|
|
8
|
+
interface ProcessBuilder<GenericDefinition extends ProcessDefinition = ProcessDefinition, GenericFloor extends Floor = {}> {
|
|
10
9
|
extract<GenericShape extends ExtractShape, GenericResponseContract extends (ResponseContract.Contract<ClientErrorResponseCode, string, DP.DataParserEmpty> | undefined) = never, const GenericMetadata extends readonly Metadata[] = readonly []>(shape: GenericShape, responseContract?: GenericResponseContract, ...metadata: GenericMetadata): ProcessBuilder<O.AssignObjects<GenericDefinition, {
|
|
11
10
|
readonly steps: readonly [
|
|
12
11
|
...GenericDefinition["steps"],
|
|
@@ -22,6 +21,6 @@ declare module "./builder" {
|
|
|
22
21
|
}[keyof InferredSubShape] : never;
|
|
23
22
|
}[keyof GenericShape] extends infer InferredEntry extends ObjectEntry ? SimplifyTopLevel<{
|
|
24
23
|
[Entry in InferredEntry as Entry[0]]: Entry[1];
|
|
25
|
-
}> : never
|
|
24
|
+
}> : never>>;
|
|
26
25
|
}
|
|
27
26
|
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { type Floor } from "../../floor";
|
|
2
2
|
import { type PresetCheckerStep } from "../../steps";
|
|
3
3
|
import { type O, type A } from "@duplojs/utils";
|
|
4
|
-
import { type Request } from "../../request";
|
|
5
4
|
import { type GetPresetCheckerIndex, type GetPresetCheckerInformation, type GetPresetCheckerResult, type GetPresetCheckerInput, type PresetChecker } from "../../presetChecker";
|
|
6
5
|
import { type ProcessDefinition } from "../../process";
|
|
7
6
|
import { type Metadata } from "../../metadata";
|
|
8
7
|
declare module "./builder" {
|
|
9
|
-
interface ProcessBuilder<GenericDefinition extends ProcessDefinition = ProcessDefinition, GenericFloor extends Floor = {}
|
|
8
|
+
interface ProcessBuilder<GenericDefinition extends ProcessDefinition = ProcessDefinition, GenericFloor extends Floor = {}> {
|
|
10
9
|
presetCheck<GenericPresetChecker extends PresetChecker, GenericInput extends GetPresetCheckerInput<GenericPresetChecker>, const GenericMetadata extends readonly Metadata[] = readonly []>(presetChecker: GenericPresetChecker, input: (floor: GenericFloor) => GenericInput, ...metadata: GenericMetadata): ProcessBuilder<O.AssignObjects<GenericDefinition, {
|
|
11
10
|
readonly steps: readonly [
|
|
12
11
|
...GenericDefinition["steps"],
|
|
@@ -20,6 +19,6 @@ declare module "./builder" {
|
|
|
20
19
|
[Prop in GetPresetCheckerIndex<GenericPresetChecker>]: Extract<Awaited<GetPresetCheckerResult<GenericPresetChecker>>, {
|
|
21
20
|
information: A.ArrayCoalescing<GetPresetCheckerInformation<GenericPresetChecker>>[number];
|
|
22
21
|
}>["value"];
|
|
23
|
-
}
|
|
22
|
+
}>>;
|
|
24
23
|
}
|
|
25
24
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { type Floor } from "../../floor";
|
|
2
2
|
import { type ProcessStep } from "../../steps";
|
|
3
3
|
import { type O, type NeverCoalescing, type FixDeepFunctionInfer, type Adaptor, type AnyFunction } from "@duplojs/utils";
|
|
4
|
-
import { type ProcessDefinition, type GetProcessExportValue, type Process
|
|
5
|
-
import { type Request } from "../../request";
|
|
4
|
+
import { type ProcessDefinition, type GetProcessExportValue, type Process } from "../../process";
|
|
6
5
|
import { type Metadata } from "../../metadata";
|
|
7
6
|
declare module "./builder" {
|
|
8
|
-
interface ProcessBuilder<GenericDefinition extends ProcessDefinition = ProcessDefinition, GenericFloor extends Floor = {}
|
|
7
|
+
interface ProcessBuilder<GenericDefinition extends ProcessDefinition = ProcessDefinition, GenericFloor extends Floor = {}> {
|
|
9
8
|
exec<GenericProcess extends Process, GenericProcessExportValue extends GetProcessExportValue<GenericProcess>, const GenericImportation extends readonly Extract<keyof GenericProcessExportValue, string>[] = never, GenericOptions extends (GenericProcess["definition"]["options"] | ((floor: GenericFloor) => Exclude<GenericProcess["definition"]["options"], undefined>)) = never, const GenericMetadata extends readonly Metadata[] = readonly []>(process: GenericProcess, params?: {
|
|
10
9
|
readonly imports?: GenericImportation;
|
|
11
10
|
readonly options?: FixDeepFunctionInfer<GenericProcess["definition"]["options"] | ((floor: GenericFloor) => GenericProcess["definition"]["options"]), GenericOptions>;
|
|
@@ -19,6 +18,6 @@ declare module "./builder" {
|
|
|
19
18
|
readonly metadata: GenericMetadata;
|
|
20
19
|
}>
|
|
21
20
|
];
|
|
22
|
-
}>, O.AssignObjects<GenericFloor, Pick<GenericProcessExportValue, GenericImportation[number]
|
|
21
|
+
}>, O.AssignObjects<GenericFloor, Pick<GenericProcessExportValue, GenericImportation[number]>>>;
|
|
23
22
|
}
|
|
24
23
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type HookRouteLifeCycle, type RouteDefinition, type RoutePath } from "../../route";
|
|
2
2
|
import { type Floor } from "../../floor";
|
|
3
|
-
import { type RequestMethods, type
|
|
4
|
-
import { type Builder
|
|
3
|
+
import { type RequestMethods, type BodyController } from "../../request";
|
|
4
|
+
import { type Builder } from "@duplojs/utils";
|
|
5
5
|
import { type Metadata } from "../../metadata";
|
|
6
|
-
export interface RouteBuilder<GenericDefinition extends RouteDefinition = RouteDefinition, GenericFloor extends Floor = {}
|
|
6
|
+
export interface RouteBuilder<GenericDefinition extends RouteDefinition = RouteDefinition, GenericFloor extends Floor = {}> extends Builder<RouteDefinition> {
|
|
7
7
|
}
|
|
8
|
-
export declare const routeBuilderHandler: import("@duplojs/utils").BuilderHandler<RouteBuilder<RouteDefinition, {}
|
|
8
|
+
export declare const routeBuilderHandler: import("@duplojs/utils").BuilderHandler<RouteBuilder<RouteDefinition, {}>>;
|
|
9
9
|
export declare function useRouteBuilder<GenericMethod extends RequestMethods, const GenericPaths extends RoutePath | readonly [RoutePath, ...RoutePath[]], const GenericHooks extends readonly HookRouteLifeCycle[] = readonly [], const GenericMetadata extends readonly Metadata[] = readonly [], const GenericBodyController extends BodyController | null = null>(method: GenericMethod, path: GenericPaths, options?: {
|
|
10
10
|
hooks?: GenericHooks | readonly HookRouteLifeCycle[];
|
|
11
11
|
metadata?: GenericMetadata;
|
|
@@ -18,4 +18,4 @@ export declare function useRouteBuilder<GenericMethod extends RequestMethods, co
|
|
|
18
18
|
readonly hooks: GenericHooks;
|
|
19
19
|
readonly metadata: GenericMetadata;
|
|
20
20
|
readonly bodyController: GenericBodyController;
|
|
21
|
-
}, {}
|
|
21
|
+
}, {}>;
|
|
@@ -4,10 +4,9 @@ import { type CheckerStep } from "../../steps";
|
|
|
4
4
|
import { type O, type MaybeArray, type NeverCoalescing, type FixDeepFunctionInfer, type Adaptor, type AnyFunction, type DP, type A } from "@duplojs/utils";
|
|
5
5
|
import { type GetCheckerInput, type Checker, type GetCheckerResult, type GetCheckerOptions } from "../../checker";
|
|
6
6
|
import { type ClientErrorResponseCode, type ResponseContract } from "../../response";
|
|
7
|
-
import { type Request } from "../../request";
|
|
8
7
|
import { type Metadata } from "../../metadata";
|
|
9
8
|
declare module "./builder" {
|
|
10
|
-
interface RouteBuilder<GenericDefinition extends RouteDefinition = RouteDefinition, GenericFloor extends Floor = {}
|
|
9
|
+
interface RouteBuilder<GenericDefinition extends RouteDefinition = RouteDefinition, GenericFloor extends Floor = {}> {
|
|
11
10
|
check<GenericChecker extends Checker, GenericResultInformation extends MaybeArray<Awaited<GetCheckerResult<GenericChecker>>["information"]>, GenericInput extends GetCheckerInput<GenericChecker>, GenericResponseContract extends ResponseContract.Contract<ClientErrorResponseCode, string, DP.DataParserEmpty>, GenericIndex extends string = never, GenericOptions extends (GetCheckerOptions<GenericChecker> | ((floor: GenericFloor) => Exclude<GetCheckerOptions<GenericChecker>, undefined>)) = never, const GenericMetadata extends readonly Metadata[] = readonly []>(checker: GenericChecker, params: {
|
|
12
11
|
input(floor: GenericFloor): GenericInput;
|
|
13
12
|
readonly result: GenericResultInformation;
|
|
@@ -31,6 +30,6 @@ declare module "./builder" {
|
|
|
31
30
|
[Prop in GenericIndex]: Extract<Awaited<GetCheckerResult<GenericChecker>>, {
|
|
32
31
|
information: A.ArrayCoalescing<GenericResultInformation>[number];
|
|
33
32
|
}>["value"];
|
|
34
|
-
}
|
|
33
|
+
}>>;
|
|
35
34
|
}
|
|
36
35
|
}
|
|
@@ -3,19 +3,18 @@ import { type ResponseContract } from "../../response";
|
|
|
3
3
|
import { type RouteDefinition } from "../../route";
|
|
4
4
|
import { type CutStepFunctionOutput, type CutStep, type CutStepFunctionParams } from "../../steps";
|
|
5
5
|
import { type Unwrap, type O, type MaybePromise, type IsEqual, type A } from "@duplojs/utils";
|
|
6
|
-
import { type Request } from "../../request";
|
|
7
6
|
import { type Metadata } from "../../metadata";
|
|
8
7
|
declare module "./builder" {
|
|
9
|
-
interface RouteBuilder<GenericDefinition extends RouteDefinition = RouteDefinition, GenericFloor extends Floor = {}
|
|
10
|
-
cut<const GenericResponseContract extends (ResponseContract.Contract | readonly ResponseContract.Contract[]), GenericResponse extends ResponseContract.Convert<A.ArrayCoalescing<GenericResponseContract>[number]>, GenericOutput extends CutStepFunctionOutput | GenericResponse, const GenericMetadata extends readonly Metadata[] = readonly []>(responseContract: GenericResponseContract, theFunction: (floor: GenericFloor, params: CutStepFunctionParams<
|
|
8
|
+
interface RouteBuilder<GenericDefinition extends RouteDefinition = RouteDefinition, GenericFloor extends Floor = {}> {
|
|
9
|
+
cut<const GenericResponseContract extends (ResponseContract.Contract | readonly ResponseContract.Contract[]), GenericResponse extends ResponseContract.Convert<A.ArrayCoalescing<GenericResponseContract>[number]>, GenericOutput extends CutStepFunctionOutput | GenericResponse, const GenericMetadata extends readonly Metadata[] = readonly []>(responseContract: GenericResponseContract, theFunction: (floor: GenericFloor, params: CutStepFunctionParams<GenericResponse>) => MaybePromise<GenericOutput>, ...metadata: GenericMetadata): RouteBuilder<O.AssignObjects<GenericDefinition, {
|
|
11
10
|
readonly steps: readonly [
|
|
12
11
|
...GenericDefinition["steps"],
|
|
13
12
|
CutStep<{
|
|
14
13
|
readonly responseContract: GenericResponseContract;
|
|
15
|
-
theFunction(floor: GenericFloor, param: CutStepFunctionParams<
|
|
14
|
+
theFunction(floor: GenericFloor, param: CutStepFunctionParams<GenericResponse>): MaybePromise<GenericOutput>;
|
|
16
15
|
readonly metadata: GenericMetadata;
|
|
17
16
|
}>
|
|
18
17
|
];
|
|
19
|
-
}>, IsEqual<Extract<GenericOutput, CutStepFunctionOutput>, never> extends true ? GenericFloor : (GenericOutput extends infer InferredOutputData extends CutStepFunctionOutput ? O.AssignObjects<GenericFloor, Unwrap<InferredOutputData>> : never)
|
|
18
|
+
}>, IsEqual<Extract<GenericOutput, CutStepFunctionOutput>, never> extends true ? GenericFloor : (GenericOutput extends infer InferredOutputData extends CutStepFunctionOutput ? O.AssignObjects<GenericFloor, Unwrap<InferredOutputData>> : never)>;
|
|
20
19
|
}
|
|
21
20
|
}
|
|
@@ -6,8 +6,8 @@ import { type ClientErrorResponseCode, type ResponseContract } from "../../respo
|
|
|
6
6
|
import { type Request } from "../../request";
|
|
7
7
|
import { type Metadata } from "../../metadata";
|
|
8
8
|
declare module "./builder" {
|
|
9
|
-
interface RouteBuilder<GenericDefinition extends RouteDefinition = RouteDefinition, GenericFloor extends Floor = {}
|
|
10
|
-
extract<GenericShape extends ExtractShape<
|
|
9
|
+
interface RouteBuilder<GenericDefinition extends RouteDefinition = RouteDefinition, GenericFloor extends Floor = {}> {
|
|
10
|
+
extract<GenericShape extends ExtractShape<Request>, GenericResponseContract extends (ResponseContract.Contract<ClientErrorResponseCode, string, DP.DataParserEmpty> | undefined) = never, const GenericMetadata extends readonly Metadata[] = readonly []>(shape: GenericShape, responseContract?: GenericResponseContract, ...metadata: GenericMetadata): RouteBuilder<O.AssignObjects<GenericDefinition, {
|
|
11
11
|
readonly steps: readonly [
|
|
12
12
|
...GenericDefinition["steps"],
|
|
13
13
|
ExtractStep<{
|
|
@@ -22,6 +22,6 @@ declare module "./builder" {
|
|
|
22
22
|
}[keyof InferredSubShape] : never;
|
|
23
23
|
}[keyof GenericShape] extends infer InferredEntry extends ObjectEntry ? SimplifyTopLevel<{
|
|
24
24
|
[Entry in InferredEntry as Entry[0]]: Entry[1];
|
|
25
|
-
}> : never
|
|
25
|
+
}> : never>>;
|
|
26
26
|
}
|
|
27
27
|
}
|
|
@@ -3,19 +3,18 @@ import { type ResponseContract } from "../../response";
|
|
|
3
3
|
import { type Route, type RouteDefinition } from "../../route";
|
|
4
4
|
import { type HandlerStep, type HandlerStepFunctionParams } from "../../steps";
|
|
5
5
|
import { type MaybePromise, type O } from "@duplojs/utils";
|
|
6
|
-
import { type Request } from "../../request";
|
|
7
6
|
import { type Metadata } from "../../metadata";
|
|
8
7
|
declare module "./builder" {
|
|
9
|
-
interface RouteBuilder<GenericDefinition extends RouteDefinition = RouteDefinition, GenericFloor extends Floor = {}
|
|
8
|
+
interface RouteBuilder<GenericDefinition extends RouteDefinition = RouteDefinition, GenericFloor extends Floor = {}> {
|
|
10
9
|
handler<GenericResponseContract extends (ResponseContract.Contract | ResponseContract.ServerSentEventsContract | readonly [
|
|
11
10
|
(ResponseContract.Contract | ResponseContract.ServerSentEventsContract),
|
|
12
11
|
...(ResponseContract.Contract | ResponseContract.ServerSentEventsContract)[]
|
|
13
|
-
]), GenericResponse extends ResponseContract.Convert<GenericResponseContract extends readonly any[] ? GenericResponseContract[number] : GenericResponseContract>, const GenericMetadata extends readonly Metadata[] = readonly []>(responseContract: GenericResponseContract, theFunction: (floor: GenericFloor, param: HandlerStepFunctionParams<
|
|
12
|
+
]), GenericResponse extends ResponseContract.Convert<GenericResponseContract extends readonly any[] ? GenericResponseContract[number] : GenericResponseContract>, const GenericMetadata extends readonly Metadata[] = readonly []>(responseContract: GenericResponseContract, theFunction: (floor: GenericFloor, param: HandlerStepFunctionParams<GenericResponse>) => MaybePromise<GenericResponse>, ...metadata: GenericMetadata): Route<O.AssignObjects<GenericDefinition, {
|
|
14
13
|
readonly steps: readonly [
|
|
15
14
|
...GenericDefinition["steps"],
|
|
16
15
|
HandlerStep<{
|
|
17
16
|
readonly responseContract: GenericResponseContract;
|
|
18
|
-
theFunction(floor: GenericFloor, param: HandlerStepFunctionParams<
|
|
17
|
+
theFunction(floor: GenericFloor, param: HandlerStepFunctionParams<GenericResponse>): MaybePromise<GenericResponse>;
|
|
19
18
|
readonly metadata: GenericMetadata;
|
|
20
19
|
}>
|
|
21
20
|
];
|
|
@@ -2,11 +2,10 @@ import { type Floor } from "../../floor";
|
|
|
2
2
|
import { type RouteDefinition } from "../../route";
|
|
3
3
|
import { type PresetCheckerStep } from "../../steps";
|
|
4
4
|
import { type O, type A } from "@duplojs/utils";
|
|
5
|
-
import { type Request } from "../../request";
|
|
6
5
|
import { type GetPresetCheckerIndex, type GetPresetCheckerInformation, type GetPresetCheckerResult, type GetPresetCheckerInput, type PresetChecker } from "../../presetChecker";
|
|
7
6
|
import { type Metadata } from "../../metadata";
|
|
8
7
|
declare module "./builder" {
|
|
9
|
-
interface RouteBuilder<GenericDefinition extends RouteDefinition = RouteDefinition, GenericFloor extends Floor = {}
|
|
8
|
+
interface RouteBuilder<GenericDefinition extends RouteDefinition = RouteDefinition, GenericFloor extends Floor = {}> {
|
|
10
9
|
presetCheck<GenericPresetChecker extends PresetChecker, GenericInput extends GetPresetCheckerInput<GenericPresetChecker>, const GenericMetadata extends readonly Metadata[] = readonly []>(presetChecker: GenericPresetChecker, input: (floor: GenericFloor) => GenericInput, ...metadata: GenericMetadata): RouteBuilder<O.AssignObjects<GenericDefinition, {
|
|
11
10
|
readonly steps: readonly [
|
|
12
11
|
...GenericDefinition["steps"],
|
|
@@ -20,6 +19,6 @@ declare module "./builder" {
|
|
|
20
19
|
[Prop in GetPresetCheckerIndex<GenericPresetChecker>]: Extract<Awaited<GetPresetCheckerResult<GenericPresetChecker>>, {
|
|
21
20
|
information: A.ArrayCoalescing<GetPresetCheckerInformation<GenericPresetChecker>>[number];
|
|
22
21
|
}>["value"];
|
|
23
|
-
}
|
|
22
|
+
}>>;
|
|
24
23
|
}
|
|
25
24
|
}
|
|
@@ -2,11 +2,10 @@ import { type Floor } from "../../floor";
|
|
|
2
2
|
import { type RouteDefinition } from "../../route";
|
|
3
3
|
import { type ProcessStep } from "../../steps";
|
|
4
4
|
import { type O, type NeverCoalescing, type FixDeepFunctionInfer, type Adaptor, type AnyFunction } from "@duplojs/utils";
|
|
5
|
-
import { type
|
|
6
|
-
import { type Request } from "../../request";
|
|
5
|
+
import { type GetProcessExportValue, type Process } from "../../process";
|
|
7
6
|
import { type Metadata } from "../../metadata";
|
|
8
7
|
declare module "./builder" {
|
|
9
|
-
interface RouteBuilder<GenericDefinition extends RouteDefinition = RouteDefinition, GenericFloor extends Floor = {}
|
|
8
|
+
interface RouteBuilder<GenericDefinition extends RouteDefinition = RouteDefinition, GenericFloor extends Floor = {}> {
|
|
10
9
|
exec<GenericProcess extends Process, GenericProcessExportValue extends GetProcessExportValue<GenericProcess>, const GenericImportation extends readonly Extract<keyof GenericProcessExportValue, string>[] = never, GenericOptions extends (GenericProcess["definition"]["options"] | ((floor: GenericFloor) => Exclude<GenericProcess["definition"]["options"], undefined>)) = never, const GenericMetadata extends readonly Metadata[] = readonly []>(process: GenericProcess, params?: {
|
|
11
10
|
readonly imports?: GenericImportation;
|
|
12
11
|
readonly options?: FixDeepFunctionInfer<GenericProcess["definition"]["options"] | ((floor: GenericFloor) => GenericProcess["definition"]["options"]), GenericOptions>;
|
|
@@ -20,6 +19,6 @@ declare module "./builder" {
|
|
|
20
19
|
readonly metadata: GenericMetadata;
|
|
21
20
|
}>
|
|
22
21
|
];
|
|
23
|
-
}>, O.AssignObjects<GenericFloor, Pick<GenericProcessExportValue, GenericImportation[number]
|
|
22
|
+
}>, O.AssignObjects<GenericFloor, Pick<GenericProcessExportValue, GenericImportation[number]>>>;
|
|
24
23
|
}
|
|
25
24
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Hub } from "../hub";
|
|
2
2
|
import { type HttpServerParams } from "../types";
|
|
3
3
|
export declare function initDefaultHook(hub: Hub, serverParams: HttpServerParams): {
|
|
4
|
-
readonly beforeSendResponse: ({ currentResponse, next }: import("../route").RouteHookParamsAfter
|
|
4
|
+
readonly beforeSendResponse: ({ currentResponse, next }: import("../route").RouteHookParamsAfter) => import("../route").RouteHookNext;
|
|
5
5
|
};
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type createStepFunctionBuilder } from "../steps";
|
|
2
2
|
import { type BuildRouteNotSupportEither, type createRouteFunctionBuilder } from "./create";
|
|
3
3
|
import { type HookRouteLifeCycle, type Route } from "../../route";
|
|
4
4
|
import { type ResponseContract } from "../../response";
|
|
5
|
-
|
|
5
|
+
import { type Environment } from "../../types";
|
|
6
|
+
export interface BuildRouteFunctionParams {
|
|
6
7
|
readonly routeFunctionBuilders: readonly ReturnType<typeof createRouteFunctionBuilder>[];
|
|
7
8
|
readonly globalHooksRouteLifeCycle: readonly HookRouteLifeCycle[];
|
|
9
|
+
readonly stepFunctionBuilders: readonly ReturnType<typeof createStepFunctionBuilder>[];
|
|
10
|
+
readonly environment: Environment;
|
|
8
11
|
readonly defaultExtractContract: ResponseContract.Contract;
|
|
9
12
|
}
|
|
10
13
|
export declare function buildRouteFunction(route: Route, params: BuildRouteFunctionParams): Promise<import("..").BuildStepNotSupportEither | import("./create").BuildRouteSuccessEither | BuildRouteNotSupportEither>;
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import { E, type MaybePromise } from "@duplojs/utils";
|
|
2
|
-
import { type HookRouteLifeCycle, type Route } from "../../route";
|
|
3
|
-
import { type Request } from "../../request";
|
|
2
|
+
import { type BuildedRoute, type HookRouteLifeCycle, type Route } from "../../route";
|
|
4
3
|
import { type Environment } from "../../types";
|
|
5
4
|
import { type BuildStepSuccessEither, type BuildStepNotSupportEither } from "../steps";
|
|
6
5
|
import { type Steps } from "../../steps";
|
|
7
6
|
import { type ResponseContract } from "../../response";
|
|
8
|
-
export type
|
|
9
|
-
export type BuildRouteSuccessEither = E.Right<"buildSuccess", BuildedRouteFunction>;
|
|
7
|
+
export type BuildRouteSuccessEither = E.Right<"buildSuccess", BuildedRoute>;
|
|
10
8
|
export type BuildRouteNotSupportEither = E.Left<"routeNotSupport", Route>;
|
|
11
9
|
export interface RouteFunctionBuilderParams {
|
|
12
10
|
readonly globalHooksRouteLifeCycle: readonly HookRouteLifeCycle[];
|
|
13
11
|
readonly environment: Environment;
|
|
14
12
|
buildStep(element: Steps): Promise<BuildStepSuccessEither | BuildStepNotSupportEither>;
|
|
15
|
-
success(result:
|
|
13
|
+
success(result: BuildedRoute): BuildRouteSuccessEither;
|
|
16
14
|
readonly defaultExtractContract: ResponseContract.Contract;
|
|
17
15
|
}
|
|
18
16
|
export declare function createRouteFunctionBuilder(support: (route: Route) => boolean, builder: (route: Route, params: RouteFunctionBuilderParams) => MaybePromise<BuildRouteSuccessEither | BuildStepNotSupportEither>): (route: Route, params: RouteFunctionBuilderParams) => MaybePromise<BuildRouteNotSupportEither | BuildRouteSuccessEither | BuildStepNotSupportEither>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
require('
|
|
4
|
-
require('
|
|
5
|
-
var hooks = require('
|
|
6
|
-
var hook = require('
|
|
3
|
+
require('../../../response/index.cjs');
|
|
4
|
+
require('../../../route/index.cjs');
|
|
5
|
+
var hooks = require('../../../route/hooks.cjs');
|
|
6
|
+
var hook = require('../../../response/hook.cjs');
|
|
7
7
|
|
|
8
8
|
/* eslint-disable @typescript-eslint/prefer-for-of */
|
|
9
9
|
const hookExit = hooks.hookRouteExitKind.setTo({});
|
|
@@ -20,7 +20,10 @@ function buildHookBefore(hooks$1) {
|
|
|
20
20
|
}
|
|
21
21
|
return async (params) => {
|
|
22
22
|
for (let index = 0; index < hooks$1.length; index++) {
|
|
23
|
-
|
|
23
|
+
let result = hooks$1[index](params);
|
|
24
|
+
if (result instanceof Promise) {
|
|
25
|
+
result = await result;
|
|
26
|
+
}
|
|
24
27
|
if (hooks.hookRouteExitKind.has(result)
|
|
25
28
|
|| result instanceof hook.HookResponse) {
|
|
26
29
|
return result;
|
|
@@ -35,7 +38,10 @@ function buildHookErrorBefore(hooks$1) {
|
|
|
35
38
|
}
|
|
36
39
|
return async (params) => {
|
|
37
40
|
for (let index = 0; index < hooks$1.length; index++) {
|
|
38
|
-
|
|
41
|
+
let result = hooks$1[index](params);
|
|
42
|
+
if (result instanceof Promise) {
|
|
43
|
+
result = await result;
|
|
44
|
+
}
|
|
39
45
|
if (hooks.hookRouteExitKind.has(result)
|
|
40
46
|
|| result instanceof hook.HookResponse) {
|
|
41
47
|
return result;
|
|
@@ -50,7 +56,10 @@ function buildHookAfter(hooks$1) {
|
|
|
50
56
|
}
|
|
51
57
|
return async (params) => {
|
|
52
58
|
for (let index = 0; index < hooks$1.length; index++) {
|
|
53
|
-
|
|
59
|
+
let result = hooks$1[index](params);
|
|
60
|
+
if (result instanceof Promise) {
|
|
61
|
+
result = await result;
|
|
62
|
+
}
|
|
54
63
|
if (hooks.hookRouteExitKind.has(result)) {
|
|
55
64
|
return result;
|
|
56
65
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { HookResponse } from "
|
|
2
|
-
import { type HookAfterSendResponse, type HookBeforeRouteExecution, type HookBeforeSendResponse, type HookError, type HookRouteLifeCycle, type HookSendResponse, type RouteHookErrorParams, type RouteHookParams, type RouteHookParamsAfter } from "
|
|
1
|
+
import { HookResponse } from "../../../response";
|
|
2
|
+
import { type HookAfterSendResponse, type HookBeforeRouteExecution, type HookBeforeSendResponse, type HookError, type HookRouteLifeCycle, type HookSendResponse, type RouteHookErrorParams, type RouteHookParams, type RouteHookParamsAfter } from "../../../route";
|
|
3
3
|
export declare function exitHookFunction(): import("@duplojs/utils").Kind<import("@duplojs/utils").KindDefinition<"@DuplojsHttpCore/route-hook-exit", unknown>, unknown>;
|
|
4
4
|
export declare function nextHookFunction(): import("@duplojs/utils").Kind<import("@duplojs/utils").KindDefinition<"@DuplojsHttpCore/route-hook-next", unknown>, unknown>;
|
|
5
|
-
export declare function buildHookBefore(hooks: (HookBeforeRouteExecution)[]): typeof exitHookFunction | ((params: RouteHookParams) => Promise<import("
|
|
6
|
-
export declare function buildHookErrorBefore(hooks: HookError[]): typeof exitHookFunction | ((params: RouteHookErrorParams) => Promise<import("
|
|
7
|
-
export declare function buildHookAfter(hooks: (HookBeforeSendResponse | HookSendResponse | HookAfterSendResponse)[]): typeof exitHookFunction | ((params: RouteHookParamsAfter) => Promise<import("
|
|
5
|
+
export declare function buildHookBefore(hooks: (HookBeforeRouteExecution)[]): typeof exitHookFunction | ((params: RouteHookParams) => Promise<import("../../../route").RouteHookExit | import("@duplojs/utils").Kind<import("@duplojs/utils").KindDefinition<"@DuplojsHttpCore/route-hook-next", unknown>, unknown> | HookResponse<import("../../../response").ResponseCode, string, unknown>>);
|
|
6
|
+
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("../../../response").ResponseCode, string, unknown>>);
|
|
7
|
+
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>>);
|
|
8
8
|
export declare function createHookResponse(from: keyof HookRouteLifeCycle): RouteHookParams["response"];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import '
|
|
2
|
-
import '
|
|
3
|
-
import { hookRouteExitKind, hookRouteNextKind } from '
|
|
4
|
-
import { HookResponse } from '
|
|
1
|
+
import '../../../response/index.mjs';
|
|
2
|
+
import '../../../route/index.mjs';
|
|
3
|
+
import { hookRouteExitKind, hookRouteNextKind } from '../../../route/hooks.mjs';
|
|
4
|
+
import { HookResponse } from '../../../response/hook.mjs';
|
|
5
5
|
|
|
6
6
|
/* eslint-disable @typescript-eslint/prefer-for-of */
|
|
7
7
|
const hookExit = hookRouteExitKind.setTo({});
|
|
@@ -18,7 +18,10 @@ function buildHookBefore(hooks) {
|
|
|
18
18
|
}
|
|
19
19
|
return async (params) => {
|
|
20
20
|
for (let index = 0; index < hooks.length; index++) {
|
|
21
|
-
|
|
21
|
+
let result = hooks[index](params);
|
|
22
|
+
if (result instanceof Promise) {
|
|
23
|
+
result = await result;
|
|
24
|
+
}
|
|
22
25
|
if (hookRouteExitKind.has(result)
|
|
23
26
|
|| result instanceof HookResponse) {
|
|
24
27
|
return result;
|
|
@@ -33,7 +36,10 @@ function buildHookErrorBefore(hooks) {
|
|
|
33
36
|
}
|
|
34
37
|
return async (params) => {
|
|
35
38
|
for (let index = 0; index < hooks.length; index++) {
|
|
36
|
-
|
|
39
|
+
let result = hooks[index](params);
|
|
40
|
+
if (result instanceof Promise) {
|
|
41
|
+
result = await result;
|
|
42
|
+
}
|
|
37
43
|
if (hookRouteExitKind.has(result)
|
|
38
44
|
|| result instanceof HookResponse) {
|
|
39
45
|
return result;
|
|
@@ -48,7 +54,10 @@ function buildHookAfter(hooks) {
|
|
|
48
54
|
}
|
|
49
55
|
return async (params) => {
|
|
50
56
|
for (let index = 0; index < hooks.length; index++) {
|
|
51
|
-
|
|
57
|
+
let result = hooks[index](params);
|
|
58
|
+
if (result instanceof Promise) {
|
|
59
|
+
result = await result;
|
|
60
|
+
}
|
|
52
61
|
if (hookRouteExitKind.has(result)) {
|
|
53
62
|
return result;
|
|
54
63
|
}
|