@duplojs/http 0.2.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.
Files changed (151) hide show
  1. package/dist/client/getBody.cjs +22 -0
  2. package/dist/client/getBody.d.ts +1 -0
  3. package/dist/client/getBody.mjs +20 -0
  4. package/dist/client/hooks.cjs +79 -0
  5. package/dist/client/hooks.d.ts +33 -0
  6. package/dist/client/hooks.mjs +70 -0
  7. package/dist/client/httpClient.cjs +153 -0
  8. package/dist/client/httpClient.d.ts +60 -0
  9. package/dist/client/httpClient.mjs +130 -0
  10. package/dist/client/index.cjs +33 -0
  11. package/dist/client/index.d.ts +9 -0
  12. package/dist/client/index.mjs +9 -0
  13. package/dist/client/insertParamsInPath.cjs +12 -0
  14. package/dist/client/insertParamsInPath.d.ts +2 -0
  15. package/dist/client/insertParamsInPath.mjs +10 -0
  16. package/dist/client/kind.cjs +9 -0
  17. package/dist/client/kind.d.ts +6 -0
  18. package/dist/client/kind.mjs +7 -0
  19. package/dist/client/promiseRequest.cjs +355 -0
  20. package/dist/client/promiseRequest.d.ts +98 -0
  21. package/dist/client/promiseRequest.mjs +332 -0
  22. package/dist/client/queryToString.cjs +25 -0
  23. package/dist/client/queryToString.d.ts +2 -0
  24. package/dist/client/queryToString.mjs +23 -0
  25. package/dist/client/types/ObjectCanBeEmpty.cjs +2 -0
  26. package/dist/client/types/ObjectCanBeEmpty.d.ts +4 -0
  27. package/dist/client/types/ObjectCanBeEmpty.mjs +1 -0
  28. package/dist/client/types/clientRequestParams.cjs +2 -0
  29. package/dist/client/types/clientRequestParams.d.ts +51 -0
  30. package/dist/client/types/clientRequestParams.mjs +1 -0
  31. package/dist/client/types/clientResponse.cjs +2 -0
  32. package/dist/client/types/clientResponse.d.ts +34 -0
  33. package/dist/client/types/clientResponse.mjs +1 -0
  34. package/dist/client/types/index.cjs +7 -0
  35. package/dist/client/types/index.d.ts +4 -0
  36. package/dist/client/types/index.mjs +4 -0
  37. package/dist/client/types/serverRoute.cjs +2 -0
  38. package/dist/client/types/serverRoute.d.ts +22 -0
  39. package/dist/client/types/serverRoute.mjs +1 -0
  40. package/dist/client/unexpectedResponseError.cjs +44 -0
  41. package/dist/client/unexpectedResponseError.d.ts +38 -0
  42. package/dist/client/unexpectedResponseError.mjs +39 -0
  43. package/dist/core/functionsBuilders/route/default.cjs +10 -9
  44. package/dist/core/functionsBuilders/route/default.mjs +3 -2
  45. package/dist/core/functionsBuilders/route/hook.cjs +22 -22
  46. package/dist/core/functionsBuilders/route/hook.d.ts +2 -2
  47. package/dist/core/functionsBuilders/route/hook.mjs +2 -2
  48. package/dist/core/functionsBuilders/steps/create.d.ts +2 -2
  49. package/dist/core/functionsBuilders/steps/defaults/checkerStep.cjs +3 -2
  50. package/dist/core/functionsBuilders/steps/defaults/checkerStep.mjs +3 -2
  51. package/dist/core/functionsBuilders/steps/defaults/cutStep.cjs +3 -2
  52. package/dist/core/functionsBuilders/steps/defaults/cutStep.mjs +3 -2
  53. package/dist/core/functionsBuilders/steps/defaults/extractStep.cjs +6 -5
  54. package/dist/core/functionsBuilders/steps/defaults/extractStep.mjs +4 -3
  55. package/dist/core/functionsBuilders/steps/defaults/handlerStep.cjs +3 -2
  56. package/dist/core/functionsBuilders/steps/defaults/handlerStep.mjs +3 -2
  57. package/dist/core/functionsBuilders/steps/defaults/processStep.cjs +5 -4
  58. package/dist/core/functionsBuilders/steps/defaults/processStep.mjs +3 -2
  59. package/dist/core/hub/defaultNotfoundHandler.d.ts +1 -1
  60. package/dist/core/hub/index.cjs +1 -1
  61. package/dist/core/hub/index.mjs +1 -1
  62. package/dist/core/index.cjs +37 -34
  63. package/dist/core/index.mjs +5 -3
  64. package/dist/core/response/base.cjs +40 -0
  65. package/dist/core/response/base.d.ts +21 -0
  66. package/dist/core/response/base.mjs +38 -0
  67. package/dist/core/response/contract.cjs +2 -2
  68. package/dist/core/response/contract.d.ts +120 -118
  69. package/dist/core/response/contract.mjs +2 -2
  70. package/dist/core/{route/hooks/response.cjs → response/hook.cjs} +4 -3
  71. package/dist/core/{route/hooks/response.d.ts → response/hook.d.ts} +2 -2
  72. package/dist/core/{route/hooks/response.mjs → response/hook.mjs} +3 -2
  73. package/dist/core/response/index.cjs +9 -38
  74. package/dist/core/response/index.d.ts +3 -20
  75. package/dist/core/response/index.mjs +3 -38
  76. package/dist/core/response/predicted.cjs +22 -0
  77. package/dist/core/response/predicted.d.ts +11 -0
  78. package/dist/core/response/predicted.mjs +20 -0
  79. package/dist/core/route/{hooks/index.cjs → hooks.cjs} +2 -3
  80. package/dist/core/route/{hooks/index.d.ts → hooks.d.ts} +4 -4
  81. package/dist/core/route/{hooks/index.mjs → hooks.mjs} +2 -2
  82. package/dist/core/route/index.cjs +4 -4
  83. package/dist/core/route/index.mjs +1 -1
  84. package/dist/core/steps/cut.d.ts +3 -3
  85. package/dist/core/steps/handler.d.ts +3 -3
  86. package/dist/core/steps/identifier.d.ts +2 -2
  87. package/dist/core/steps/types/stepFunctionParams.d.ts +2 -2
  88. package/dist/core/types/forbiddenBigintDataParser.cjs +2 -0
  89. package/dist/core/types/forbiddenBigintDataParser.d.ts +6 -0
  90. package/dist/core/types/forbiddenBigintDataParser.mjs +1 -0
  91. package/dist/core/types/index.cjs +1 -0
  92. package/dist/core/types/index.d.ts +1 -0
  93. package/dist/core/types/index.mjs +1 -0
  94. package/dist/interfaces/node/createHttpServer.cjs +1 -0
  95. package/dist/interfaces/node/createHttpServer.d.ts +2 -1
  96. package/dist/interfaces/node/createHttpServer.mjs +1 -0
  97. package/dist/interfaces/node/hooks.cjs +16 -13
  98. package/dist/interfaces/node/hooks.mjs +15 -12
  99. package/dist/plugins/codeGenerator/index.cjs +0 -3
  100. package/dist/plugins/codeGenerator/index.mjs +1 -1
  101. package/dist/plugins/codeGenerator/plugin.cjs +1 -1
  102. package/dist/plugins/codeGenerator/plugin.mjs +1 -1
  103. package/dist/plugins/codeGenerator/routeToDataParser.cjs +4 -55
  104. package/dist/plugins/codeGenerator/routeToDataParser.d.ts +2 -181
  105. package/dist/plugins/codeGenerator/routeToDataParser.mjs +6 -54
  106. package/dist/plugins/openApiGenerator/aggregateStepContract.cjs +62 -0
  107. package/dist/plugins/openApiGenerator/aggregateStepContract.d.ts +18 -0
  108. package/dist/plugins/openApiGenerator/aggregateStepContract.mjs +60 -0
  109. package/dist/plugins/openApiGenerator/index.cjs +17 -0
  110. package/dist/plugins/openApiGenerator/index.d.ts +7 -0
  111. package/dist/plugins/openApiGenerator/index.mjs +7 -0
  112. package/dist/plugins/openApiGenerator/makeOpenApiPage.cjs +30 -0
  113. package/dist/plugins/openApiGenerator/makeOpenApiPage.d.ts +7 -0
  114. package/dist/plugins/openApiGenerator/makeOpenApiPage.mjs +28 -0
  115. package/dist/plugins/openApiGenerator/makeOpenApiRoute.cjs +15 -0
  116. package/dist/plugins/openApiGenerator/makeOpenApiRoute.d.ts +18 -0
  117. package/dist/plugins/openApiGenerator/makeOpenApiRoute.mjs +13 -0
  118. package/dist/plugins/openApiGenerator/plugin.cjs +90 -0
  119. package/dist/plugins/openApiGenerator/plugin.d.ts +49 -0
  120. package/dist/plugins/openApiGenerator/plugin.mjs +88 -0
  121. package/dist/plugins/openApiGenerator/routeToOpenApi.cjs +163 -0
  122. package/dist/plugins/openApiGenerator/routeToOpenApi.d.ts +35 -0
  123. package/dist/plugins/openApiGenerator/routeToOpenApi.mjs +161 -0
  124. package/dist/plugins/openApiGenerator/types/endpointResponse.cjs +2 -0
  125. package/dist/plugins/openApiGenerator/types/endpointResponse.d.ts +19 -0
  126. package/dist/plugins/openApiGenerator/types/endpointResponse.mjs +1 -0
  127. package/dist/plugins/openApiGenerator/types/entrypoint.cjs +2 -0
  128. package/dist/plugins/openApiGenerator/types/entrypoint.d.ts +22 -0
  129. package/dist/plugins/openApiGenerator/types/entrypoint.mjs +1 -0
  130. package/dist/plugins/openApiGenerator/types/entrypointKey.cjs +2 -0
  131. package/dist/plugins/openApiGenerator/types/entrypointKey.d.ts +1 -0
  132. package/dist/plugins/openApiGenerator/types/entrypointKey.mjs +1 -0
  133. package/dist/plugins/openApiGenerator/types/index.cjs +11 -0
  134. package/dist/plugins/openApiGenerator/types/index.d.ts +8 -0
  135. package/dist/plugins/openApiGenerator/types/index.mjs +8 -0
  136. package/dist/plugins/openApiGenerator/types/openApiDocument.cjs +2 -0
  137. package/dist/plugins/openApiGenerator/types/openApiDocument.d.ts +31 -0
  138. package/dist/plugins/openApiGenerator/types/openApiDocument.mjs +1 -0
  139. package/dist/plugins/openApiGenerator/types/openApiMethod.cjs +2 -0
  140. package/dist/plugins/openApiGenerator/types/openApiMethod.d.ts +1 -0
  141. package/dist/plugins/openApiGenerator/types/openApiMethod.mjs +1 -0
  142. package/dist/plugins/openApiGenerator/types/openApiOperation.cjs +2 -0
  143. package/dist/plugins/openApiGenerator/types/openApiOperation.d.ts +8 -0
  144. package/dist/plugins/openApiGenerator/types/openApiOperation.mjs +1 -0
  145. package/dist/plugins/openApiGenerator/types/openApiPath.cjs +2 -0
  146. package/dist/plugins/openApiGenerator/types/openApiPath.d.ts +4 -0
  147. package/dist/plugins/openApiGenerator/types/openApiPath.mjs +1 -0
  148. package/dist/plugins/openApiGenerator/types/openApiSecuritySchema.cjs +2 -0
  149. package/dist/plugins/openApiGenerator/types/openApiSecuritySchema.d.ts +8 -0
  150. package/dist/plugins/openApiGenerator/types/openApiSecuritySchema.mjs +1 -0
  151. package/package.json +17 -4
@@ -0,0 +1,39 @@
1
+ import { kindHeritage } from '@duplojs/utils';
2
+ import { createClientKind } from './kind.mjs';
3
+
4
+ class UnexpectedInformationResponseError extends kindHeritage("unexpected-information-response-error", createClientKind("unexpected-information-response-error"), Error) {
5
+ information;
6
+ response;
7
+ constructor(information, response) {
8
+ super({}, ["Unexpected information response."]);
9
+ this.information = information;
10
+ this.response = response;
11
+ }
12
+ }
13
+ class UnexpectedCodeResponseError extends kindHeritage("unexpected-code-response-error", createClientKind("unexpected-code-response-error"), Error) {
14
+ code;
15
+ response;
16
+ constructor(code, response) {
17
+ super({}, ["Unexpected code response."]);
18
+ this.code = code;
19
+ this.response = response;
20
+ }
21
+ }
22
+ class UnexpectedResponseTypeError extends kindHeritage("unexpected-response-type-error", createClientKind("unexpected-response-type-error"), Error) {
23
+ expectType;
24
+ response;
25
+ constructor(expectType, response) {
26
+ super({}, ["Unexpected response type."]);
27
+ this.expectType = expectType;
28
+ this.response = response;
29
+ }
30
+ }
31
+ class UnexpectedResponseError extends kindHeritage("unexpected-response-error", createClientKind("unexpected-response-error"), Error) {
32
+ response;
33
+ constructor(response) {
34
+ super({}, ["Unexpected response."]);
35
+ this.response = response;
36
+ }
37
+ }
38
+
39
+ export { UnexpectedCodeResponseError, UnexpectedInformationResponseError, UnexpectedResponseError, UnexpectedResponseTypeError };
@@ -2,12 +2,13 @@
2
2
 
3
3
  var index = require('../../route/index.cjs');
4
4
  var utils = require('@duplojs/utils');
5
- var index$1 = require('../../response/index.cjs');
5
+ require('../../response/index.cjs');
6
6
  var hook = require('./hook.cjs');
7
7
  var create = require('./create.cjs');
8
8
  require('../steps/index.cjs');
9
9
  var processStep = require('../steps/defaults/processStep.cjs');
10
- var response = require('../../route/hooks/response.cjs');
10
+ var base = require('../../response/base.cjs');
11
+ var hook$1 = require('../../response/hook.cjs');
11
12
 
12
13
  /* eslint-disable @typescript-eslint/prefer-for-of */
13
14
  const defaultRouteFunctionBuilder = create.createRouteFunctionBuilder(index.routeKind.has, async (route, { success, buildStep, globalHooksRouteLifeCycle, }) => {
@@ -63,13 +64,13 @@ const defaultRouteFunctionBuilder = create.createRouteFunctionBuilder(index.rout
63
64
  next: hook.nextHookFunction,
64
65
  response: hook.createHookResponse("beforeRouteExecution"),
65
66
  });
66
- if (beforeRouteExecutionResult instanceof index$1.Response) {
67
+ if (beforeRouteExecutionResult instanceof base.Response) {
67
68
  return beforeRouteExecutionResult;
68
69
  }
69
70
  let floor = {};
70
71
  for (let index = 0; index < buildedPreFlightSteps.length; index++) {
71
72
  const result = await buildedPreFlightSteps[index].buildedFunction(request, floor);
72
- if (result instanceof index$1.Response) {
73
+ if (result instanceof base.Response) {
73
74
  return result;
74
75
  }
75
76
  floor = result;
@@ -80,17 +81,17 @@ const defaultRouteFunctionBuilder = create.createRouteFunctionBuilder(index.rout
80
81
  next: hook.nextHookFunction,
81
82
  response: hook.createHookResponse("parseBody"),
82
83
  });
83
- if (parseBodyResult instanceof index$1.Response) {
84
+ if (parseBodyResult instanceof base.Response) {
84
85
  return parseBodyResult;
85
86
  }
86
87
  for (let index = 0; index < buildedSteps.length; index++) {
87
88
  const result = await buildedSteps[index].buildedFunction(request, floor);
88
- if (result instanceof index$1.Response) {
89
+ if (result instanceof base.Response) {
89
90
  return result;
90
91
  }
91
92
  floor = result;
92
93
  }
93
- return new index$1.Response("500", "missing-response", undefined);
94
+ return new base.Response("500", "missing-response", undefined);
94
95
  }
95
96
  catch (error) {
96
97
  const errorResult = await hooks.error({
@@ -100,10 +101,10 @@ const defaultRouteFunctionBuilder = create.createRouteFunctionBuilder(index.rout
100
101
  next: hook.nextHookFunction,
101
102
  response: hook.createHookResponse("error"),
102
103
  });
103
- if (errorResult instanceof response.HookResponse) {
104
+ if (errorResult instanceof hook$1.HookResponse) {
104
105
  return errorResult;
105
106
  }
106
- return new index$1.Response("500", "server-error", error);
107
+ return new base.Response("500", "server-error", error);
107
108
  }
108
109
  }
109
110
  return success(async (request) => {
@@ -1,11 +1,12 @@
1
1
  import { routeKind } from '../../route/index.mjs';
2
2
  import { E, A, pipe, isType, forward } from '@duplojs/utils';
3
- import { Response } from '../../response/index.mjs';
3
+ import '../../response/index.mjs';
4
4
  import { buildHookAfter, buildHookErrorBefore, buildHookBefore, createHookResponse, nextHookFunction, exitHookFunction } from './hook.mjs';
5
5
  import { createRouteFunctionBuilder } from './create.mjs';
6
6
  import '../steps/index.mjs';
7
7
  import { buildStepsFunction } from '../steps/defaults/processStep.mjs';
8
- import { HookResponse } from '../../route/hooks/response.mjs';
8
+ import { Response } from '../../response/base.mjs';
9
+ import { HookResponse } from '../../response/hook.mjs';
9
10
 
10
11
  /* eslint-disable @typescript-eslint/prefer-for-of */
11
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 index = require('../../route/hooks/index.cjs');
5
- var response = require('../../route/hooks/response.cjs');
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 = index.hookRouteExitKind.setTo({});
9
- const hookNext = index.hookRouteNextKind.setTo({});
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$1 = 0; index$1 < hooks.length; index$1++) {
22
- const result = await hooks[index$1](params);
23
- if (index.hookRouteExitKind.has(result)
24
- || result instanceof response.HookResponse) {
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$1 = 0; index$1 < hooks.length; index$1++) {
37
- const result = await hooks[index$1](params);
38
- if (index.hookRouteExitKind.has(result)
39
- || result instanceof response.HookResponse) {
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$1 = 0; index$1 < hooks.length; index$1++) {
52
- const result = await hooks[index$1](params);
53
- if (index.hookRouteExitKind.has(result)) {
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 response.HookResponse(from, code, information, body);
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("../..").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("../..").ResponseCode, string, 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("../../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/index.mjs';
3
- import { HookResponse } from '../../route/hooks/response.mjs';
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({});
@@ -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 ResponseContract, type Response } from "../../response";
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 | Response>;
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[];
@@ -4,9 +4,10 @@ var checker$1 = require('../../../checker.cjs');
4
4
  var create = require('../create.cjs');
5
5
  require('../../../steps/index.cjs');
6
6
  var utils = require('@duplojs/utils');
7
- var index = require('../../../response/index.cjs');
7
+ require('../../../response/index.cjs');
8
8
  var checker = require('../../../steps/checker.cjs');
9
9
  var presetChecker = require('../../../steps/presetChecker.cjs');
10
+ var predicted = require('../../../response/predicted.cjs');
10
11
 
11
12
  const defaultCheckerStepFunctionBuilder = create.createStepFunctionBuilder((element) => checker.checkerStepKind.has(element) || presetChecker.presetCheckerStepKind.has(element), (step, { success }) => {
12
13
  const { checkerOptions, checkerFunction, input, responseContract, stepResult, indexing, stepOptions, } = utils.pipe(step, utils.P.when(checker.checkerStepKind.has, ({ definition }) => ({
@@ -36,7 +37,7 @@ const defaultCheckerStepFunctionBuilder = create.createStepFunctionBuilder((elem
36
37
  });
37
38
  const expectedResult = utils.pipe(stepResult, utils.P.when(utils.isType("string"), (expectedInformation) => ((information) => information === expectedInformation)), utils.P.otherwise((expectedInformation) => ((information) => expectedInformation.includes(information))));
38
39
  function getResponse() {
39
- return new index.Response(responseContract.code, responseContract.information, undefined);
40
+ return new predicted.PredictedResponse(responseContract.code, responseContract.information, undefined);
40
41
  }
41
42
  function treatResult(output, floor) {
42
43
  if (!expectedResult(output.information)) {
@@ -2,9 +2,10 @@ import { checkerOutputKind } from '../../../checker.mjs';
2
2
  import { createStepFunctionBuilder } from '../create.mjs';
3
3
  import '../../../steps/index.mjs';
4
4
  import { pipe, P, or, isType, forward } from '@duplojs/utils';
5
- import { Response } from '../../../response/index.mjs';
5
+ import '../../../response/index.mjs';
6
6
  import { checkerStepKind } from '../../../steps/checker.mjs';
7
7
  import { presetCheckerStepKind } from '../../../steps/presetChecker.mjs';
8
+ import { PredictedResponse } from '../../../response/predicted.mjs';
8
9
 
9
10
  const defaultCheckerStepFunctionBuilder = createStepFunctionBuilder((element) => checkerStepKind.has(element) || presetCheckerStepKind.has(element), (step, { success }) => {
10
11
  const { checkerOptions, checkerFunction, input, responseContract, stepResult, indexing, stepOptions, } = pipe(step, P.when(checkerStepKind.has, ({ definition }) => ({
@@ -34,7 +35,7 @@ const defaultCheckerStepFunctionBuilder = createStepFunctionBuilder((element) =>
34
35
  });
35
36
  const expectedResult = pipe(stepResult, P.when(isType("string"), (expectedInformation) => ((information) => information === expectedInformation)), P.otherwise((expectedInformation) => ((information) => expectedInformation.includes(information))));
36
37
  function getResponse() {
37
- return new Response(responseContract.code, responseContract.information, undefined);
38
+ return new PredictedResponse(responseContract.code, responseContract.information, undefined);
38
39
  }
39
40
  function treatResult(output, floor) {
40
41
  if (!expectedResult(output.information)) {
@@ -3,9 +3,10 @@
3
3
  require('../../../steps/index.cjs');
4
4
  var create = require('../create.cjs');
5
5
  var utils = require('@duplojs/utils');
6
- var index = require('../../../response/index.cjs');
6
+ require('../../../response/index.cjs');
7
7
  var cut = require('../../../steps/cut.cjs');
8
8
  var contract = require('../../../response/contract.cjs');
9
+ var predicted = require('../../../response/predicted.cjs');
9
10
 
10
11
  const defaultCutStepFunctionBuilder = create.createStepFunctionBuilder(cut.cutStepKind.has, (step, { success }) => {
11
12
  const { responseContract, theFunction: cutFunction, } = step.definition;
@@ -22,7 +23,7 @@ const defaultCutStepFunctionBuilder = create.createStepFunctionBuilder(cut.cutSt
22
23
  if (utils.E.isLeft(result)) {
23
24
  throw new contract.ResponseContract.Error(information, utils.unwrap(result));
24
25
  }
25
- return new index.Response(currentContract.code, currentContract.information, body);
26
+ return new predicted.PredictedResponse(currentContract.code, currentContract.information, body);
26
27
  };
27
28
  function treatResult(result, floor) {
28
29
  if (cut.cutStepOutputKind.has(result)) {
@@ -1,9 +1,10 @@
1
1
  import '../../../steps/index.mjs';
2
2
  import { createStepFunctionBuilder } from '../create.mjs';
3
3
  import { wrapValue, A, E, unwrap } from '@duplojs/utils';
4
- import { Response } from '../../../response/index.mjs';
4
+ import '../../../response/index.mjs';
5
5
  import { cutStepKind, cutStepOutputKind } from '../../../steps/cut.mjs';
6
6
  import { ResponseContract } from '../../../response/contract.mjs';
7
+ import { PredictedResponse } from '../../../response/predicted.mjs';
7
8
 
8
9
  const defaultCutStepFunctionBuilder = createStepFunctionBuilder(cutStepKind.has, (step, { success }) => {
9
10
  const { responseContract, theFunction: cutFunction, } = step.definition;
@@ -20,7 +21,7 @@ const defaultCutStepFunctionBuilder = createStepFunctionBuilder(cutStepKind.has,
20
21
  if (E.isLeft(result)) {
21
22
  throw new ResponseContract.Error(information, unwrap(result));
22
23
  }
23
- return new Response(currentContract.code, currentContract.information, body);
24
+ return new PredictedResponse(currentContract.code, currentContract.information, body);
24
25
  };
25
26
  function treatResult(result, floor) {
26
27
  if (cutStepOutputKind.has(result)) {
@@ -2,15 +2,16 @@
2
2
 
3
3
  require('../../../steps/index.cjs');
4
4
  var utils = require('@duplojs/utils');
5
- var index = require('../../../response/index.cjs');
5
+ require('../../../response/index.cjs');
6
6
  var create = require('../create.cjs');
7
7
  var extract = require('../../../steps/extract.cjs');
8
+ var predicted = require('../../../response/predicted.cjs');
8
9
 
9
10
  const defaultExtractStepFunctionBuilder = create.createStepFunctionBuilder(extract.extractStepKind.has, (step, { success, environment, defaultExtractContract }) => {
10
11
  const { shape, responseContract: stepResponseContract, } = step.definition;
11
12
  const responseContract = stepResponseContract ?? defaultExtractContract;
12
13
  function getResponse(result, key, subKey) {
13
- const response = new index.Response(responseContract.code, responseContract.information, environment === "DEV"
14
+ const response = new predicted.PredictedResponse(responseContract.code, responseContract.information, environment === "DEV"
14
15
  ? utils.unwrap(result)
15
16
  : undefined);
16
17
  return subKey === undefined
@@ -33,9 +34,9 @@ const defaultExtractStepFunctionBuilder = create.createStepFunctionBuilder(extra
33
34
  buildedFunction: (request, floor) => {
34
35
  let newFloor = floor;
35
36
  // eslint-disable-next-line @typescript-eslint/prefer-for-of
36
- for (let index$1 = 0; index$1 < extractors.length; index$1++) {
37
- const result = extractors[index$1](request, newFloor);
38
- if (result instanceof index.Response) {
37
+ for (let index = 0; index < extractors.length; index++) {
38
+ const result = extractors[index](request, newFloor);
39
+ if (result instanceof predicted.PredictedResponse) {
39
40
  return result;
40
41
  }
41
42
  newFloor = result;
@@ -1,14 +1,15 @@
1
1
  import '../../../steps/index.mjs';
2
2
  import { unwrap, E, A, O, DP, pipe, P, isType, justReturn, innerPipe } from '@duplojs/utils';
3
- import { Response } from '../../../response/index.mjs';
3
+ import '../../../response/index.mjs';
4
4
  import { createStepFunctionBuilder } from '../create.mjs';
5
5
  import { extractStepKind } from '../../../steps/extract.mjs';
6
+ import { PredictedResponse } from '../../../response/predicted.mjs';
6
7
 
7
8
  const defaultExtractStepFunctionBuilder = createStepFunctionBuilder(extractStepKind.has, (step, { success, environment, defaultExtractContract }) => {
8
9
  const { shape, responseContract: stepResponseContract, } = step.definition;
9
10
  const responseContract = stepResponseContract ?? defaultExtractContract;
10
11
  function getResponse(result, key, subKey) {
11
- const response = new Response(responseContract.code, responseContract.information, environment === "DEV"
12
+ const response = new PredictedResponse(responseContract.code, responseContract.information, environment === "DEV"
12
13
  ? unwrap(result)
13
14
  : undefined);
14
15
  return subKey === undefined
@@ -33,7 +34,7 @@ const defaultExtractStepFunctionBuilder = createStepFunctionBuilder(extractStepK
33
34
  // eslint-disable-next-line @typescript-eslint/prefer-for-of
34
35
  for (let index = 0; index < extractors.length; index++) {
35
36
  const result = extractors[index](request, newFloor);
36
- if (result instanceof Response) {
37
+ if (result instanceof PredictedResponse) {
37
38
  return result;
38
39
  }
39
40
  newFloor = result;
@@ -3,9 +3,10 @@
3
3
  require('../../../steps/index.cjs');
4
4
  var create = require('../create.cjs');
5
5
  var utils = require('@duplojs/utils');
6
- var index = require('../../../response/index.cjs');
6
+ require('../../../response/index.cjs');
7
7
  var handler = require('../../../steps/handler.cjs');
8
8
  var contract = require('../../../response/contract.cjs');
9
+ var predicted = require('../../../response/predicted.cjs');
9
10
 
10
11
  const defaultHandlerStepFunctionBuilder = create.createStepFunctionBuilder(handler.handlerStepKind.has, (step, { success }) => {
11
12
  const { responseContract, theFunction: handlerFunction, } = step.definition;
@@ -21,7 +22,7 @@ const defaultHandlerStepFunctionBuilder = create.createStepFunctionBuilder(handl
21
22
  if (utils.E.isLeft(result)) {
22
23
  throw new contract.ResponseContract.Error(information, utils.unwrap(result));
23
24
  }
24
- return new index.Response(currentContract.code, currentContract.information, body);
25
+ return new predicted.PredictedResponse(currentContract.code, currentContract.information, body);
25
26
  };
26
27
  return success({
27
28
  buildedFunction: (request, floor) => handlerFunction(floor, {
@@ -1,9 +1,10 @@
1
1
  import '../../../steps/index.mjs';
2
2
  import { createStepFunctionBuilder } from '../create.mjs';
3
3
  import { A, E, unwrap } from '@duplojs/utils';
4
- import { Response } from '../../../response/index.mjs';
4
+ import '../../../response/index.mjs';
5
5
  import { handlerStepKind } from '../../../steps/handler.mjs';
6
6
  import { ResponseContract } from '../../../response/contract.mjs';
7
+ import { PredictedResponse } from '../../../response/predicted.mjs';
7
8
 
8
9
  const defaultHandlerStepFunctionBuilder = createStepFunctionBuilder(handlerStepKind.has, (step, { success }) => {
9
10
  const { responseContract, theFunction: handlerFunction, } = step.definition;
@@ -19,7 +20,7 @@ const defaultHandlerStepFunctionBuilder = createStepFunctionBuilder(handlerStepK
19
20
  if (E.isLeft(result)) {
20
21
  throw new ResponseContract.Error(information, unwrap(result));
21
22
  }
22
- return new Response(currentContract.code, currentContract.information, body);
23
+ return new PredictedResponse(currentContract.code, currentContract.information, body);
23
24
  };
24
25
  return success({
25
26
  buildedFunction: (request, floor) => handlerFunction(floor, {
@@ -1,10 +1,11 @@
1
1
  'use strict';
2
2
 
3
3
  require('../../../steps/index.cjs');
4
- var index = require('../../../response/index.cjs');
4
+ require('../../../response/index.cjs');
5
5
  var create = require('../create.cjs');
6
6
  var utils = require('@duplojs/utils');
7
7
  var process = require('../../../steps/process.cjs');
8
+ var predicted = require('../../../response/predicted.cjs');
8
9
 
9
10
  function buildStepsFunction(steps, buildStep) {
10
11
  return utils.G.asyncReduce(steps, utils.G.reduceFrom([]), async ({ lastValue, element: step, next, exit }) => {
@@ -31,9 +32,9 @@ const defaultProcessStepFunctionBuilder = create.createStepFunctionBuilder(proce
31
32
  buildedFunction: async (request, floor) => {
32
33
  let processFloor = { options: getOptions(floor) };
33
34
  // eslint-disable-next-line @typescript-eslint/prefer-for-of
34
- for (let index$1 = 0; index$1 < buildedSteps.length; index$1++) {
35
- const result = await buildedSteps[index$1].buildedFunction(request, floor);
36
- if (result instanceof index.Response) {
35
+ for (let index = 0; index < buildedSteps.length; index++) {
36
+ const result = await buildedSteps[index].buildedFunction(request, floor);
37
+ if (result instanceof predicted.PredictedResponse) {
37
38
  return result;
38
39
  }
39
40
  processFloor = result;
@@ -1,8 +1,9 @@
1
1
  import '../../../steps/index.mjs';
2
- import { Response } from '../../../response/index.mjs';
2
+ import '../../../response/index.mjs';
3
3
  import { createStepFunctionBuilder } from '../create.mjs';
4
4
  import { G, E, A, unwrap, pipe, P, or, isType, forward } from '@duplojs/utils';
5
5
  import { processStepKind } from '../../../steps/process.mjs';
6
+ import { PredictedResponse } from '../../../response/predicted.mjs';
6
7
 
7
8
  function buildStepsFunction(steps, buildStep) {
8
9
  return G.asyncReduce(steps, G.reduceFrom([]), async ({ lastValue, element: step, next, exit }) => {
@@ -31,7 +32,7 @@ const defaultProcessStepFunctionBuilder = createStepFunctionBuilder(processStepK
31
32
  // eslint-disable-next-line @typescript-eslint/prefer-for-of
32
33
  for (let index = 0; index < buildedSteps.length; index++) {
33
34
  const result = await buildedSteps[index].buildedFunction(request, floor);
34
- if (result instanceof Response) {
35
+ if (result instanceof PredictedResponse) {
35
36
  return result;
36
37
  }
37
38
  processFloor = result;
@@ -6,5 +6,5 @@ export declare const defaultNotfoundHandler: import("../steps").HandlerStep<{
6
6
  readonly coerce: boolean;
7
7
  readonly checkers: readonly [];
8
8
  }>>>;
9
- theFunction: (floor: import("..").Floor, { request, response }: import("../steps").HandlerStepFunctionParams<import("..").Request, import("../response").Response<import("../response").ResponseCode, string, unknown>>) => never;
9
+ theFunction: (floor: import("..").Floor, { request, response }: import("../steps").HandlerStepFunctionParams<import("..").Request, import("../response").PredictedResponse<import("../response").ResponseCode, string, unknown>>) => never;
10
10
  }>;
@@ -59,7 +59,7 @@ function createHub(config) {
59
59
  register(route) {
60
60
  return {
61
61
  ...this,
62
- routes: utils.A.concat(this.routes, utils.pipe(route, utils.P.when(index.routeKind.has, utils.A.coalescing), utils.P.when(utils.isType("iterable"), utils.A.from), utils.P.otherwise(utils.O.values))),
62
+ routes: utils.A.concat(this.routes, utils.pipe(route, utils.P.when(index.routeKind.has, utils.A.coalescing), utils.P.when(utils.isType("iterable"), utils.A.from), utils.P.otherwise(utils.O.values), utils.A.filter((route) => !utils.A.includes(this.routes, route)))),
63
63
  };
64
64
  },
65
65
  setDefaultExtractContract(defaultExtractContract) {
@@ -57,7 +57,7 @@ function createHub(config) {
57
57
  register(route) {
58
58
  return {
59
59
  ...this,
60
- routes: A.concat(this.routes, pipe(route, P.when(routeKind.has, A.coalescing), P.when(isType("iterable"), A.from), P.otherwise(O.values))),
60
+ routes: A.concat(this.routes, pipe(route, P.when(routeKind.has, A.coalescing), P.when(isType("iterable"), A.from), P.otherwise(O.values), A.filter((route) => !A.includes(this.routes, route)))),
61
61
  };
62
62
  },
63
63
  setDefaultExtractContract(defaultExtractContract) {