@axisparkjs/engine 1.0.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 (204) hide show
  1. package/PACKAGE.md +3 -0
  2. package/lib/decorators/index.d.ts +6 -0
  3. package/lib/decorators/index.js +23 -0
  4. package/lib/decorators/index.js.map +1 -0
  5. package/lib/decorators/parameter.d.ts +1 -0
  6. package/lib/decorators/parameter.js +20 -0
  7. package/lib/decorators/parameter.js.map +1 -0
  8. package/lib/decorators/pipe.d.ts +6 -0
  9. package/lib/decorators/pipe.js +42 -0
  10. package/lib/decorators/pipe.js.map +1 -0
  11. package/lib/decorators/step-method.d.ts +6 -0
  12. package/lib/decorators/step-method.js +24 -0
  13. package/lib/decorators/step-method.js.map +1 -0
  14. package/lib/decorators/step-target.d.ts +7 -0
  15. package/lib/decorators/step-target.js +31 -0
  16. package/lib/decorators/step-target.js.map +1 -0
  17. package/lib/decorators/timeout.d.ts +2 -0
  18. package/lib/decorators/timeout.js +23 -0
  19. package/lib/decorators/timeout.js.map +1 -0
  20. package/lib/decorators/use.d.ts +2 -0
  21. package/lib/decorators/use.js +20 -0
  22. package/lib/decorators/use.js.map +1 -0
  23. package/lib/execution/execution-context.d.ts +8 -0
  24. package/lib/execution/execution-context.js +3 -0
  25. package/lib/execution/execution-context.js.map +1 -0
  26. package/lib/execution/execution-engine.d.ts +14 -0
  27. package/lib/execution/execution-engine.js +101 -0
  28. package/lib/execution/execution-engine.js.map +1 -0
  29. package/lib/execution/execution-handler.d.ts +5 -0
  30. package/lib/execution/execution-handler.js +3 -0
  31. package/lib/execution/execution-handler.js.map +1 -0
  32. package/lib/execution/execution-plan.d.ts +10 -0
  33. package/lib/execution/execution-plan.js +3 -0
  34. package/lib/execution/execution-plan.js.map +1 -0
  35. package/lib/execution/execution-planner.d.ts +16 -0
  36. package/lib/execution/execution-planner.js +98 -0
  37. package/lib/execution/execution-planner.js.map +1 -0
  38. package/lib/execution/execution-transport.d.ts +5 -0
  39. package/lib/execution/execution-transport.js +10 -0
  40. package/lib/execution/execution-transport.js.map +1 -0
  41. package/lib/execution/handler-invoker.d.ts +13 -0
  42. package/lib/execution/handler-invoker.js +50 -0
  43. package/lib/execution/handler-invoker.js.map +1 -0
  44. package/lib/execution/index.d.ts +7 -0
  45. package/lib/execution/index.js +24 -0
  46. package/lib/execution/index.js.map +1 -0
  47. package/lib/implementations/index.d.ts +3 -0
  48. package/lib/implementations/index.js +20 -0
  49. package/lib/implementations/index.js.map +1 -0
  50. package/lib/implementations/parameters/context.d.ts +7 -0
  51. package/lib/implementations/parameters/context.js +16 -0
  52. package/lib/implementations/parameters/context.js.map +1 -0
  53. package/lib/implementations/parameters/filtered-error.d.ts +7 -0
  54. package/lib/implementations/parameters/filtered-error.js +16 -0
  55. package/lib/implementations/parameters/filtered-error.js.map +1 -0
  56. package/lib/implementations/parameters/index.d.ts +2 -0
  57. package/lib/implementations/parameters/index.js +19 -0
  58. package/lib/implementations/parameters/index.js.map +1 -0
  59. package/lib/implementations/pipe-steps/index.d.ts +13 -0
  60. package/lib/implementations/pipe-steps/index.js +30 -0
  61. package/lib/implementations/pipe-steps/index.js.map +1 -0
  62. package/lib/implementations/pipe-steps/lower-case.d.ts +6 -0
  63. package/lib/implementations/pipe-steps/lower-case.js +23 -0
  64. package/lib/implementations/pipe-steps/lower-case.js.map +1 -0
  65. package/lib/implementations/pipe-steps/max-length.d.ts +12 -0
  66. package/lib/implementations/pipe-steps/max-length.js +32 -0
  67. package/lib/implementations/pipe-steps/max-length.js.map +1 -0
  68. package/lib/implementations/pipe-steps/max.d.ts +12 -0
  69. package/lib/implementations/pipe-steps/max.js +32 -0
  70. package/lib/implementations/pipe-steps/max.js.map +1 -0
  71. package/lib/implementations/pipe-steps/min-length.d.ts +12 -0
  72. package/lib/implementations/pipe-steps/min-length.js +32 -0
  73. package/lib/implementations/pipe-steps/min-length.js.map +1 -0
  74. package/lib/implementations/pipe-steps/min.d.ts +12 -0
  75. package/lib/implementations/pipe-steps/min.js +32 -0
  76. package/lib/implementations/pipe-steps/min.js.map +1 -0
  77. package/lib/implementations/pipe-steps/not-empty.d.ts +6 -0
  78. package/lib/implementations/pipe-steps/not-empty.js +27 -0
  79. package/lib/implementations/pipe-steps/not-empty.js.map +1 -0
  80. package/lib/implementations/pipe-steps/parse-boolean.d.ts +6 -0
  81. package/lib/implementations/pipe-steps/parse-boolean.js +41 -0
  82. package/lib/implementations/pipe-steps/parse-boolean.js.map +1 -0
  83. package/lib/implementations/pipe-steps/parse-float.d.ts +6 -0
  84. package/lib/implementations/pipe-steps/parse-float.js +28 -0
  85. package/lib/implementations/pipe-steps/parse-float.js.map +1 -0
  86. package/lib/implementations/pipe-steps/parse-int.d.ts +12 -0
  87. package/lib/implementations/pipe-steps/parse-int.js +35 -0
  88. package/lib/implementations/pipe-steps/parse-int.js.map +1 -0
  89. package/lib/implementations/pipe-steps/range.d.ts +13 -0
  90. package/lib/implementations/pipe-steps/range.js +32 -0
  91. package/lib/implementations/pipe-steps/range.js.map +1 -0
  92. package/lib/implementations/pipe-steps/regex.d.ts +12 -0
  93. package/lib/implementations/pipe-steps/regex.js +32 -0
  94. package/lib/implementations/pipe-steps/regex.js.map +1 -0
  95. package/lib/implementations/pipe-steps/trim.d.ts +6 -0
  96. package/lib/implementations/pipe-steps/trim.js +23 -0
  97. package/lib/implementations/pipe-steps/trim.js.map +1 -0
  98. package/lib/implementations/pipe-steps/upper-case.d.ts +6 -0
  99. package/lib/implementations/pipe-steps/upper-case.js +23 -0
  100. package/lib/implementations/pipe-steps/upper-case.js.map +1 -0
  101. package/lib/implementations/result/handled-result.d.ts +5 -0
  102. package/lib/implementations/result/handled-result.js +24 -0
  103. package/lib/implementations/result/handled-result.js.map +1 -0
  104. package/lib/implementations/result/index.d.ts +1 -0
  105. package/lib/implementations/result/index.js +18 -0
  106. package/lib/implementations/result/index.js.map +1 -0
  107. package/lib/index.d.ts +7 -0
  108. package/lib/index.js +24 -0
  109. package/lib/index.js.map +1 -0
  110. package/lib/metadata/index.d.ts +6 -0
  111. package/lib/metadata/index.js +23 -0
  112. package/lib/metadata/index.js.map +1 -0
  113. package/lib/metadata/parameter-metadata.d.ts +5 -0
  114. package/lib/metadata/parameter-metadata.js +3 -0
  115. package/lib/metadata/parameter-metadata.js.map +1 -0
  116. package/lib/metadata/pipe-metadata.d.ts +10 -0
  117. package/lib/metadata/pipe-metadata.js +3 -0
  118. package/lib/metadata/pipe-metadata.js.map +1 -0
  119. package/lib/metadata/step-method-metadata.d.ts +24 -0
  120. package/lib/metadata/step-method-metadata.js +3 -0
  121. package/lib/metadata/step-method-metadata.js.map +1 -0
  122. package/lib/metadata/step-target-metadata.d.ts +9 -0
  123. package/lib/metadata/step-target-metadata.js +3 -0
  124. package/lib/metadata/step-target-metadata.js.map +1 -0
  125. package/lib/metadata/timeout-metadata.d.ts +4 -0
  126. package/lib/metadata/timeout-metadata.js +3 -0
  127. package/lib/metadata/timeout-metadata.js.map +1 -0
  128. package/lib/metadata/use-metadata.d.ts +4 -0
  129. package/lib/metadata/use-metadata.js +3 -0
  130. package/lib/metadata/use-metadata.js.map +1 -0
  131. package/lib/parameter/index.d.ts +3 -0
  132. package/lib/parameter/index.js +20 -0
  133. package/lib/parameter/index.js.map +1 -0
  134. package/lib/parameter/parameter-definition.d.ts +15 -0
  135. package/lib/parameter/parameter-definition.js +26 -0
  136. package/lib/parameter/parameter-definition.js.map +1 -0
  137. package/lib/parameter/parameter-generator.d.ts +9 -0
  138. package/lib/parameter/parameter-generator.js +41 -0
  139. package/lib/parameter/parameter-generator.js.map +1 -0
  140. package/lib/parameter/parameter-resolver.d.ts +6 -0
  141. package/lib/parameter/parameter-resolver.js +3 -0
  142. package/lib/parameter/parameter-resolver.js.map +1 -0
  143. package/lib/pipe/index.d.ts +6 -0
  144. package/lib/pipe/index.js +23 -0
  145. package/lib/pipe/index.js.map +1 -0
  146. package/lib/pipe/pipe-definition.d.ts +14 -0
  147. package/lib/pipe/pipe-definition.js +11 -0
  148. package/lib/pipe/pipe-definition.js.map +1 -0
  149. package/lib/pipe/pipe-generator.d.ts +7 -0
  150. package/lib/pipe/pipe-generator.js +53 -0
  151. package/lib/pipe/pipe-generator.js.map +1 -0
  152. package/lib/pipe/pipe-processor.d.ts +9 -0
  153. package/lib/pipe/pipe-processor.js +48 -0
  154. package/lib/pipe/pipe-processor.js.map +1 -0
  155. package/lib/pipe/pipe-scope.d.ts +5 -0
  156. package/lib/pipe/pipe-scope.js +10 -0
  157. package/lib/pipe/pipe-scope.js.map +1 -0
  158. package/lib/pipe/pipe-step-errors.d.ts +11 -0
  159. package/lib/pipe/pipe-step-errors.js +26 -0
  160. package/lib/pipe/pipe-step-errors.js.map +1 -0
  161. package/lib/pipe/pipe-step.d.ts +6 -0
  162. package/lib/pipe/pipe-step.js +3 -0
  163. package/lib/pipe/pipe-step.js.map +1 -0
  164. package/lib/result/index.d.ts +3 -0
  165. package/lib/result/index.js +20 -0
  166. package/lib/result/index.js.map +1 -0
  167. package/lib/result/result-definition.d.ts +7 -0
  168. package/lib/result/result-definition.js +11 -0
  169. package/lib/result/result-definition.js.map +1 -0
  170. package/lib/result/result-processor.d.ts +9 -0
  171. package/lib/result/result-processor.js +46 -0
  172. package/lib/result/result-processor.js.map +1 -0
  173. package/lib/result/result-resolver.d.ts +6 -0
  174. package/lib/result/result-resolver.js +7 -0
  175. package/lib/result/result-resolver.js.map +1 -0
  176. package/lib/step/index.d.ts +3 -0
  177. package/lib/step/index.js +20 -0
  178. package/lib/step/index.js.map +1 -0
  179. package/lib/step/step-definition.d.ts +44 -0
  180. package/lib/step/step-definition.js +71 -0
  181. package/lib/step/step-definition.js.map +1 -0
  182. package/lib/step/step-generator.d.ts +10 -0
  183. package/lib/step/step-generator.js +57 -0
  184. package/lib/step/step-generator.js.map +1 -0
  185. package/lib/step/step-priority.d.ts +7 -0
  186. package/lib/step/step-priority.js +12 -0
  187. package/lib/step/step-priority.js.map +1 -0
  188. package/lib/timeout/index.d.ts +4 -0
  189. package/lib/timeout/index.js +21 -0
  190. package/lib/timeout/index.js.map +1 -0
  191. package/lib/timeout/timeout-definition.d.ts +4 -0
  192. package/lib/timeout/timeout-definition.js +10 -0
  193. package/lib/timeout/timeout-definition.js.map +1 -0
  194. package/lib/timeout/timeout-generator.d.ts +9 -0
  195. package/lib/timeout/timeout-generator.js +32 -0
  196. package/lib/timeout/timeout-generator.js.map +1 -0
  197. package/lib/timeout/timeout-processor.d.ts +9 -0
  198. package/lib/timeout/timeout-processor.js +40 -0
  199. package/lib/timeout/timeout-processor.js.map +1 -0
  200. package/lib/timeout/timeout-resolver.d.ts +5 -0
  201. package/lib/timeout/timeout-resolver.js +3 -0
  202. package/lib/timeout/timeout-resolver.js.map +1 -0
  203. package/package.json +30 -0
  204. package/tsconfig.build.json +9 -0
package/PACKAGE.md ADDED
@@ -0,0 +1,3 @@
1
+ # @axisparkjs/engine
2
+
3
+ Execution engine for AxiSpark framework.
@@ -0,0 +1,6 @@
1
+ export * from './step-method';
2
+ export * from './step-target';
3
+ export * from './use';
4
+ export * from './timeout';
5
+ export * from './parameter';
6
+ export * from './pipe';
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./step-method"), exports);
18
+ __exportStar(require("./step-target"), exports);
19
+ __exportStar(require("./use"), exports);
20
+ __exportStar(require("./timeout"), exports);
21
+ __exportStar(require("./parameter"), exports);
22
+ __exportStar(require("./pipe"), exports);
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,gDAA8B;AAC9B,wCAAsB;AACtB,4CAA0B;AAC1B,8CAA4B;AAC5B,yCAAuB"}
@@ -0,0 +1 @@
1
+ export declare function Parameter(parameter: string, field?: string): ParameterDecorator;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Parameter = Parameter;
4
+ const common_1 = require("@axisparkjs/common");
5
+ function Parameter(parameter, field) {
6
+ return (target, propertyKey, parameterIndex) => {
7
+ var _a;
8
+ propertyKey = propertyKey;
9
+ const parameters = (_a = common_1.Metadata.get(common_1.MetadataKeys.PARAMETER, target, propertyKey)) !== null && _a !== void 0 ? _a : [];
10
+ parameters.push({
11
+ target: common_1.Metadata.normalizeTarget(target),
12
+ parameter,
13
+ parameterIndex,
14
+ field,
15
+ propertyKey
16
+ });
17
+ common_1.Metadata.define(common_1.MetadataKeys.PARAMETER, parameters, target, propertyKey);
18
+ };
19
+ }
20
+ //# sourceMappingURL=parameter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parameter.js","sourceRoot":"","sources":["../../src/decorators/parameter.ts"],"names":[],"mappings":";;AASA,8BAeC;AAxBD,+CAA4D;AAS5D,SAAgB,SAAS,CAAC,SAAiB,EAAE,KAAc;IACvD,OAAO,CAAC,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,EAAE;;QAC3C,WAAW,GAAG,WAA8B,CAAC;QAC7C,MAAM,UAAU,GAAG,MAAA,iBAAQ,CAAC,GAAG,CAAsB,qBAAY,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,CAAC,mCAAI,EAAE,CAAC;QAExG,UAAU,CAAC,IAAI,CAAC;YACZ,MAAM,EAAE,iBAAQ,CAAC,eAAe,CAAC,MAAM,CAAC;YACxC,SAAS;YACT,cAAc;YACd,KAAK;YACL,WAAW;SACd,CAAC,CAAC;QAEH,iBAAQ,CAAC,MAAM,CAAC,qBAAY,CAAC,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;IAC7E,CAAC,CAAC;AACN,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { PipeStepConfig, PipeStep } from '../pipe';
2
+ import { ClassType } from '@axisparkjs/common';
3
+ export declare function Pipe(...steps: (ClassType<PipeStep> | {
4
+ pipeStep: ClassType<PipeStep>;
5
+ PipeStepConfig: PipeStepConfig;
6
+ })[]): ClassDecorator & MethodDecorator & ParameterDecorator;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Pipe = Pipe;
4
+ const common_1 = require("@axisparkjs/common");
5
+ const pipe_1 = require("../pipe");
6
+ function Pipe(...steps) {
7
+ return (...args) => {
8
+ var _a, _b;
9
+ if (args.length === 1) {
10
+ const [target] = args;
11
+ const pipes = (_a = common_1.Metadata.get(common_1.MetadataKeys.PIPE, target)) !== null && _a !== void 0 ? _a : [];
12
+ pipes.push({
13
+ target: common_1.Metadata.normalizeTarget(target),
14
+ pipeScope: pipe_1.PipeScope.Class,
15
+ steps
16
+ });
17
+ common_1.Metadata.define(common_1.MetadataKeys.PIPE, pipes, target);
18
+ return;
19
+ }
20
+ const [target, propertyKey, third] = args;
21
+ const pipes = (_b = common_1.Metadata.get(common_1.MetadataKeys.PIPE, target, propertyKey)) !== null && _b !== void 0 ? _b : [];
22
+ if (typeof third === 'number') {
23
+ pipes.push({
24
+ target: common_1.Metadata.normalizeTarget(target),
25
+ propertyKey,
26
+ parameterIndex: third,
27
+ pipeScope: pipe_1.PipeScope.Parameter,
28
+ steps
29
+ });
30
+ common_1.Metadata.define(common_1.MetadataKeys.PIPE, pipes, target, propertyKey);
31
+ return;
32
+ }
33
+ pipes.push({
34
+ target: common_1.Metadata.normalizeTarget(target),
35
+ propertyKey,
36
+ pipeScope: pipe_1.PipeScope.Method,
37
+ steps
38
+ });
39
+ common_1.Metadata.define(common_1.MetadataKeys.PIPE, pipes, target, propertyKey);
40
+ };
41
+ }
42
+ //# sourceMappingURL=pipe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipe.js","sourceRoot":"","sources":["../../src/decorators/pipe.ts"],"names":[],"mappings":";;AAUA,oBAgDC;AA1DD,+CAA4D;AAE5D,kCAA8D;AAQ9D,SAAgB,IAAI,CAChB,GAAG,KAAkG;IAErG,OAAO,CAAC,GAAG,IAAW,EAAE,EAAE;;QAEtB,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACpB,MAAM,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;YAEtB,MAAM,KAAK,GAAG,MAAA,iBAAQ,CAAC,GAAG,CAAiB,qBAAY,CAAC,IAAI,EAAE,MAAM,CAAC,mCAAI,EAAE,CAAC;YAE5E,KAAK,CAAC,IAAI,CAAC;gBACP,MAAM,EAAE,iBAAQ,CAAC,eAAe,CAAC,MAAM,CAAC;gBACxC,SAAS,EAAE,gBAAS,CAAC,KAAK;gBAC1B,KAAK;aACR,CAAC,CAAC;YAEH,iBAAQ,CAAC,MAAM,CAAC,qBAAY,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;YAClD,OAAO;QACX,CAAC;QAED,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC;QAC1C,MAAM,KAAK,GAAG,MAAA,iBAAQ,CAAC,GAAG,CAAiB,qBAAY,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,mCAAI,EAAE,CAAC;QAGzF,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC5B,KAAK,CAAC,IAAI,CAAC;gBACP,MAAM,EAAE,iBAAQ,CAAC,eAAe,CAAC,MAAM,CAAC;gBACxC,WAAW;gBACX,cAAc,EAAE,KAAK;gBACrB,SAAS,EAAE,gBAAS,CAAC,SAAS;gBAC9B,KAAK;aACR,CAAC,CAAC;YAEH,iBAAQ,CAAC,MAAM,CAAC,qBAAY,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;YAE/D,OAAO;QACX,CAAC;QAGD,KAAK,CAAC,IAAI,CAAC;YACP,MAAM,EAAE,iBAAQ,CAAC,eAAe,CAAC,MAAM,CAAC;YACxC,WAAW;YACX,SAAS,EAAE,gBAAS,CAAC,MAAM;YAC3B,KAAK;SACR,CAAC,CAAC;QAEH,iBAAQ,CAAC,MAAM,CAAC,qBAAY,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;IACnE,CAAC,CAAC;AACN,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { ClassType } from '@axisparkjs/common';
2
+ export declare const Handle: () => MethodDecorator;
3
+ export declare const Check: () => MethodDecorator;
4
+ export declare const Before: () => MethodDecorator;
5
+ export declare const After: () => MethodDecorator;
6
+ export declare const Catch: (...acceptedErrors: ClassType<Error>[]) => MethodDecorator;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Catch = exports.After = exports.Before = exports.Check = exports.Handle = void 0;
4
+ const common_1 = require("@axisparkjs/common");
5
+ const step_1 = require("../step");
6
+ function StepMethod(metadata) {
7
+ return (target, propertyKey) => {
8
+ var _a;
9
+ const stepMethods = (_a = common_1.Metadata.get(common_1.MetadataKeys.STEP_METHOD, target)) !== null && _a !== void 0 ? _a : [];
10
+ stepMethods.push(Object.assign({ target: common_1.Metadata.normalizeTarget(target), propertyKey }, metadata));
11
+ common_1.Metadata.define(common_1.MetadataKeys.STEP_METHOD, stepMethods, target);
12
+ };
13
+ }
14
+ const Handle = () => StepMethod({ type: step_1.StepType.Middleware });
15
+ exports.Handle = Handle;
16
+ const Check = () => StepMethod({ type: step_1.StepType.Guard });
17
+ exports.Check = Check;
18
+ const Before = () => StepMethod({ type: step_1.StepType.Interceptor, scope: step_1.StepScope.Before });
19
+ exports.Before = Before;
20
+ const After = () => StepMethod({ type: step_1.StepType.Interceptor, scope: step_1.StepScope.After });
21
+ exports.After = After;
22
+ const Catch = (...acceptedErrors) => StepMethod({ type: step_1.StepType.Filter, acceptedErrors });
23
+ exports.Catch = Catch;
24
+ //# sourceMappingURL=step-method.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"step-method.js","sourceRoot":"","sources":["../../src/decorators/step-method.ts"],"names":[],"mappings":";;;AAAA,+CAAuE;AAEvE,kCAA8C;AAO9C,SAAS,UAAU,CAAC,QAAqC;IACrD,OAAO,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE;;QAC3B,MAAM,WAAW,GAAG,MAAA,iBAAQ,CAAC,GAAG,CAAuB,qBAAY,CAAC,WAAW,EAAE,MAAM,CAAC,mCAAI,EAAE,CAAC;QAC/F,WAAW,CAAC,IAAI,CAAC,gBACb,MAAM,EAAE,iBAAQ,CAAC,eAAe,CAAC,MAAM,CAAC,EACxC,WAAW,IACR,QAAQ,CACQ,CAAC,CAAC;QAEzB,iBAAQ,CAAC,MAAM,CAAC,qBAAY,CAAC,WAAW,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;IACnE,CAAC,CAAC;AACN,CAAC;AAMM,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,eAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;AAAzD,QAAA,MAAM,UAAmD;AAK/D,MAAM,KAAK,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,eAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;AAAnD,QAAA,KAAK,SAA8C;AAKzD,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,eAAQ,CAAC,WAAW,EAAE,KAAK,EAAE,gBAAS,CAAC,MAAM,EAAE,CAAC,CAAC;AAAnF,QAAA,MAAM,UAA6E;AAKzF,MAAM,KAAK,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,eAAQ,CAAC,WAAW,EAAE,KAAK,EAAE,gBAAS,CAAC,KAAK,EAAE,CAAC,CAAC;AAAjF,QAAA,KAAK,SAA4E;AAMvF,MAAM,KAAK,GAAG,CAAC,GAAG,cAAkC,EAAE,EAAE,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,eAAQ,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC,CAAC;AAAzG,QAAA,KAAK,SAAoG"}
@@ -0,0 +1,7 @@
1
+ import { StepTargetMetadata } from '../metadata';
2
+ type StepTargetConfig = Partial<Omit<StepTargetMetadata, 'type'>>;
3
+ export declare const Middleware: (config?: StepTargetConfig) => ClassDecorator;
4
+ export declare const Guard: (config?: StepTargetConfig) => ClassDecorator;
5
+ export declare const Interceptor: (config?: StepTargetConfig) => ClassDecorator;
6
+ export declare const Filter: (config?: StepTargetConfig) => ClassDecorator;
7
+ export {};
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Filter = exports.Interceptor = exports.Guard = exports.Middleware = void 0;
4
+ const common_1 = require("@axisparkjs/common");
5
+ const di_1 = require("@axisparkjs/di");
6
+ const step_1 = require("../step");
7
+ const execution_1 = require("../execution");
8
+ function StepTarget(config) {
9
+ return (target) => {
10
+ var _a, _b, _c, _d;
11
+ const stepTargets = (_a = common_1.Metadata.get(common_1.MetadataKeys.STEP_TARGET, target)) !== null && _a !== void 0 ? _a : [];
12
+ stepTargets.push({
13
+ target: common_1.Metadata.normalizeTarget(target),
14
+ type: config.type,
15
+ transport: (_b = config.transport) !== null && _b !== void 0 ? _b : execution_1.ExecutionTransport.All,
16
+ global: (_c = config.global) !== null && _c !== void 0 ? _c : true,
17
+ priority: (_d = config.priority) !== null && _d !== void 0 ? _d : step_1.StepPriority.Normal
18
+ });
19
+ (0, di_1.Constructable)(common_1.MetadataKeys.INJECTABLE)(target);
20
+ common_1.Metadata.define(common_1.MetadataKeys.STEP_TARGET, stepTargets, target);
21
+ };
22
+ }
23
+ const Middleware = (config) => StepTarget(Object.assign(Object.assign({}, config), { type: step_1.StepType.Middleware }));
24
+ exports.Middleware = Middleware;
25
+ const Guard = (config) => StepTarget(Object.assign(Object.assign({}, config), { type: step_1.StepType.Guard }));
26
+ exports.Guard = Guard;
27
+ const Interceptor = (config) => StepTarget(Object.assign(Object.assign({}, config), { type: step_1.StepType.Interceptor }));
28
+ exports.Interceptor = Interceptor;
29
+ const Filter = (config) => StepTarget(Object.assign(Object.assign({}, config), { type: step_1.StepType.Filter }));
30
+ exports.Filter = Filter;
31
+ //# sourceMappingURL=step-target.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"step-target.js","sourceRoot":"","sources":["../../src/decorators/step-target.ts"],"names":[],"mappings":";;;AAAA,+CAA4D;AAC5D,uCAA+C;AAE/C,kCAAiD;AACjD,4CAAkD;AAOlD,SAAS,UAAU,CAAC,MAAmC;IACnD,OAAO,CAAC,MAAM,EAAE,EAAE;;QACd,MAAM,WAAW,GAAG,MAAA,iBAAQ,CAAC,GAAG,CAAuB,qBAAY,CAAC,WAAW,EAAE,MAAM,CAAC,mCAAI,EAAE,CAAC;QAC/F,WAAW,CAAC,IAAI,CAAC;YACb,MAAM,EAAE,iBAAQ,CAAC,eAAe,CAAC,MAAM,CAAC;YACxC,IAAI,EAAE,MAAM,CAAC,IAAgB;YAC7B,SAAS,EAAE,MAAA,MAAM,CAAC,SAAS,mCAAI,8BAAkB,CAAC,GAAG;YACrD,MAAM,EAAE,MAAA,MAAM,CAAC,MAAM,mCAAI,IAAI;YAC7B,QAAQ,EAAE,MAAA,MAAM,CAAC,QAAQ,mCAAI,mBAAY,CAAC,MAAM;SACnD,CAAC,CAAC;QAEH,IAAA,kBAAa,EAAC,qBAAY,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;QAC/C,iBAAQ,CAAC,MAAM,CAAC,qBAAY,CAAC,WAAW,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;IACnE,CAAC,CAAC;AACN,CAAC;AASM,MAAM,UAAU,GAAG,CAAC,MAAyB,EAAE,EAAE,CAAC,UAAU,iCAAM,MAAM,KAAE,IAAI,EAAE,eAAQ,CAAC,UAAU,IAAG,CAAC;AAAjG,QAAA,UAAU,cAAuF;AAMvG,MAAM,KAAK,GAAG,CAAC,MAAyB,EAAE,EAAE,CAAC,UAAU,iCAAM,MAAM,KAAE,IAAI,EAAE,eAAQ,CAAC,KAAK,IAAG,CAAC;AAAvF,QAAA,KAAK,SAAkF;AAM7F,MAAM,WAAW,GAAG,CAAC,MAAyB,EAAE,EAAE,CAAC,UAAU,iCAAM,MAAM,KAAE,IAAI,EAAE,eAAQ,CAAC,WAAW,IAAG,CAAC;AAAnG,QAAA,WAAW,eAAwF;AAMzG,MAAM,MAAM,GAAG,CAAC,MAAyB,EAAE,EAAE,CAAC,UAAU,iCAAM,MAAM,KAAE,IAAI,EAAE,eAAQ,CAAC,MAAM,IAAG,CAAC;AAAzF,QAAA,MAAM,UAAmF"}
@@ -0,0 +1,2 @@
1
+ export declare function Timeout(time: number): MethodDecorator & ClassDecorator;
2
+ export declare const NoTimeout: () => MethodDecorator & ClassDecorator;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NoTimeout = void 0;
4
+ exports.Timeout = Timeout;
5
+ const common_1 = require("@axisparkjs/common");
6
+ function Timeout(time) {
7
+ return function (target, propertyKey) {
8
+ const metadata = {
9
+ target: common_1.Metadata.normalizeTarget(target),
10
+ propertyKey,
11
+ time
12
+ };
13
+ if (propertyKey) {
14
+ common_1.Metadata.define(common_1.MetadataKeys.TIMEOUT, metadata, target, propertyKey);
15
+ }
16
+ else {
17
+ common_1.Metadata.define(common_1.MetadataKeys.TIMEOUT, metadata, target);
18
+ }
19
+ };
20
+ }
21
+ const NoTimeout = () => Timeout(-1);
22
+ exports.NoTimeout = NoTimeout;
23
+ //# sourceMappingURL=timeout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timeout.js","sourceRoot":"","sources":["../../src/decorators/timeout.ts"],"names":[],"mappings":";;;AAQA,0BAeC;AAvBD,+CAA4D;AAQ5D,SAAgB,OAAO,CAAC,IAAY;IAChC,OAAO,UAAU,MAAW,EAAE,WAA6B;QACvD,MAAM,QAAQ,GAAoB;YAC9B,MAAM,EAAE,iBAAQ,CAAC,eAAe,CAAC,MAAM,CAAC;YACxC,WAAW;YACX,IAAI;SACP,CAAC;QACF,IAAI,WAAW,EAAE,CAAC;YAEd,iBAAQ,CAAC,MAAM,CAAC,qBAAY,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;QACzE,CAAC;aAAM,CAAC;YAEJ,iBAAQ,CAAC,MAAM,CAAC,qBAAY,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC5D,CAAC;IACL,CAAC,CAAC;AACN,CAAC;AAMM,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;AAA9B,QAAA,SAAS,aAAqB"}
@@ -0,0 +1,2 @@
1
+ import { ClassType } from '@axisparkjs/common';
2
+ export declare function Use(...targets: ClassType[]): ClassDecorator & MethodDecorator;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Use = Use;
4
+ const common_1 = require("@axisparkjs/common");
5
+ function Use(...targets) {
6
+ return (target, propertyKey, descriptor) => {
7
+ const metadata = {
8
+ target: common_1.Metadata.normalizeTarget(target),
9
+ propertyKey,
10
+ targets
11
+ };
12
+ if (descriptor) {
13
+ common_1.Metadata.define(common_1.MetadataKeys.USE, metadata, target, propertyKey);
14
+ }
15
+ else {
16
+ common_1.Metadata.define(common_1.MetadataKeys.USE, metadata, target);
17
+ }
18
+ };
19
+ }
20
+ //# sourceMappingURL=use.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use.js","sourceRoot":"","sources":["../../src/decorators/use.ts"],"names":[],"mappings":";;AAQA,kBAiBC;AAzBD,+CAAuE;AAQvE,SAAgB,GAAG,CAAC,GAAG,OAAoB;IACvC,OAAO,CAAC,MAAyB,EAAE,WAA6B,EAAE,UAA+B,EAAE,EAAE;QACjG,MAAM,QAAQ,GAAgB;YAC1B,MAAM,EAAE,iBAAQ,CAAC,eAAe,CAAC,MAAM,CAAC;YACxC,WAAW;YACX,OAAO;SACV,CAAC;QAGF,IAAI,UAAU,EAAE,CAAC;YACb,iBAAQ,CAAC,MAAM,CAAC,qBAAY,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,WAA8B,CAAC,CAAC;QACxF,CAAC;aAEI,CAAC;YACF,iBAAQ,CAAC,MAAM,CAAC,qBAAY,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;QACxD,CAAC;IACL,CAAC,CAAC;AACN,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { ScopedContainer } from '@axisparkjs/di';
2
+ import { ExecutionTransport } from './execution-transport';
3
+ import { ExecutionHandler } from './execution-handler';
4
+ export interface ExecutionContext extends ExecutionHandler {
5
+ error?: Error;
6
+ transport: ExecutionTransport;
7
+ scopedContainer: ScopedContainer;
8
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=execution-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-context.js","sourceRoot":"","sources":["../../src/execution/execution-context.ts"],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ import { Executable } from '@axisparkjs/common';
2
+ import { ExecutionContext } from './execution-context';
3
+ import { HandlerInvoker } from './handler-invoker';
4
+ import { ResultProcessor } from '../result';
5
+ import { ExecutionPlanner } from './execution-planner';
6
+ import { TimeoutProcessor } from '../timeout';
7
+ export declare class ExecutionEngine implements Executable {
8
+ private readonly planGenerator;
9
+ private readonly handlerInvoker;
10
+ private readonly timeoutProcessor;
11
+ private readonly resultProcessor;
12
+ constructor(planGenerator: ExecutionPlanner, handlerInvoker: HandlerInvoker, timeoutProcessor: TimeoutProcessor, resultProcessor: ResultProcessor);
13
+ execute(context: ExecutionContext): Promise<void>;
14
+ }
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
13
+ return new (P || (P = Promise))(function (resolve, reject) {
14
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
15
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
16
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
17
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
18
+ });
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.ExecutionEngine = void 0;
22
+ const handler_invoker_1 = require("./handler-invoker");
23
+ const di_1 = require("@axisparkjs/di");
24
+ const result_1 = require("../result");
25
+ const execution_planner_1 = require("./execution-planner");
26
+ const timeout_1 = require("../timeout");
27
+ let ExecutionEngine = class ExecutionEngine {
28
+ constructor(planGenerator, handlerInvoker, timeoutProcessor, resultProcessor) {
29
+ this.planGenerator = planGenerator;
30
+ this.handlerInvoker = handlerInvoker;
31
+ this.timeoutProcessor = timeoutProcessor;
32
+ this.resultProcessor = resultProcessor;
33
+ }
34
+ execute(context) {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ const plan = yield this.planGenerator.plan(context);
37
+ let result;
38
+ try {
39
+ const execution = () => __awaiter(this, void 0, void 0, function* () {
40
+ for (const step of plan.before)
41
+ yield this.handlerInvoker.invoke(step, context);
42
+ return yield this.handlerInvoker.invoke(plan.context, context);
43
+ });
44
+ if (plan.timeout) {
45
+ let finished = false;
46
+ const timeout = () => __awaiter(this, void 0, void 0, function* () {
47
+ yield new Promise((resolve, reject) => {
48
+ setTimeout(() => __awaiter(this, void 0, void 0, function* () {
49
+ if (finished) {
50
+ resolve();
51
+ return;
52
+ }
53
+ try {
54
+ yield this.timeoutProcessor.process(plan.timeout, context);
55
+ resolve();
56
+ }
57
+ catch (error) {
58
+ reject(error);
59
+ }
60
+ }), plan.timeout.time);
61
+ });
62
+ });
63
+ try {
64
+ result = yield Promise.race([execution(), timeout()]);
65
+ }
66
+ finally {
67
+ finished = true;
68
+ }
69
+ }
70
+ else {
71
+ result = yield execution();
72
+ }
73
+ }
74
+ catch (error) {
75
+ context.error = error;
76
+ for (const step of plan.catch) {
77
+ const accepts = step.acceptedErrors.some((accepted) => error instanceof accepted);
78
+ if (!accepts)
79
+ continue;
80
+ result = yield this.handlerInvoker.invoke(step, context);
81
+ if (result !== undefined)
82
+ break;
83
+ }
84
+ }
85
+ finally {
86
+ for (const step of plan.after)
87
+ yield this.handlerInvoker.invoke(step, context);
88
+ }
89
+ yield this.resultProcessor.process(result, context);
90
+ });
91
+ }
92
+ };
93
+ exports.ExecutionEngine = ExecutionEngine;
94
+ exports.ExecutionEngine = ExecutionEngine = __decorate([
95
+ (0, di_1.Injectable)(),
96
+ __metadata("design:paramtypes", [execution_planner_1.ExecutionPlanner,
97
+ handler_invoker_1.HandlerInvoker,
98
+ timeout_1.TimeoutProcessor,
99
+ result_1.ResultProcessor])
100
+ ], ExecutionEngine);
101
+ //# sourceMappingURL=execution-engine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-engine.js","sourceRoot":"","sources":["../../src/execution/execution-engine.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAEA,uDAAmD;AACnD,uCAA4C;AAC5C,sCAA8D;AAC9D,2DAAuD;AACvD,wCAAiE;AAM1D,IAAM,eAAe,GAArB,MAAM,eAAe;IACxB,YACqB,aAA+B,EAC/B,cAA8B,EAC9B,gBAAkC,EAClC,eAAgC;QAHhC,kBAAa,GAAb,aAAa,CAAkB;QAC/B,mBAAc,GAAd,cAAc,CAAgB;QAC9B,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,oBAAe,GAAf,eAAe,CAAiB;IAClD,CAAC;IAOS,OAAO,CAAC,OAAyB;;YAC1C,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACpD,IAAI,MAAkC,CAAC;YACvC,IAAI,CAAC;gBACD,MAAM,SAAS,GAAG,GAAS,EAAE;oBACzB,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,MAAM;wBAAE,MAAM,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;oBAChF,OAAO,MAAM,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;gBACnE,CAAC,CAAA,CAAC;gBAEF,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;oBACf,IA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AAC,IAAI,EAAE,OAAO,CAAC,CAAC;oBACzD,IAAI,MAAM,KAAK,SAAS;wBAAE,MAAM;gBACpC,CAAC;YACL,CAAC;oBAAS,CAAC;gBACP,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK;oBAAE,MAAM,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YACnF,CAAC;YAED,MAAM,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACxD,CAAC;KAAA;CACJ,CAAA;AApEY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,eAAU,GAAE;qCAG2B,oCAAgB;QACf,gCAAc;QACZ,0BAAgB;QACjB,wBAAe;GAL5C,eAAe,CAoE3B"}
@@ -0,0 +1,5 @@
1
+ import { ClassType } from '@axisparkjs/common';
2
+ export interface ExecutionHandler {
3
+ target: ClassType;
4
+ propertyKey: string | symbol;
5
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=execution-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-handler.js","sourceRoot":"","sources":["../../src/execution/execution-handler.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ import { ExecutionContext } from './execution-context';
2
+ import { CatchStepDefinition, AfterStepDefinition, BeforeStepDefinition, CheckStepDefinition, HandleStepDefinition } from '../step';
3
+ import { TimeoutDefinition } from '../timeout';
4
+ export interface ExecutionPlan {
5
+ before: (HandleStepDefinition | CheckStepDefinition | BeforeStepDefinition)[];
6
+ context: ExecutionContext;
7
+ after: AfterStepDefinition[];
8
+ catch: CatchStepDefinition[];
9
+ timeout: TimeoutDefinition | undefined;
10
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=execution-plan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-plan.js","sourceRoot":"","sources":["../../src/execution/execution-plan.ts"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ import { ExecutionContext } from './execution-context';
2
+ import { StepGenerator } from '../step';
3
+ import { ExecutionPlan } from './execution-plan';
4
+ import { TimeoutGenerator } from '../timeout';
5
+ export declare class ExecutionPlanner {
6
+ private readonly timeoutGenerator;
7
+ private readonly stepGenerator;
8
+ private readonly registeredPlans;
9
+ constructor(timeoutGenerator: TimeoutGenerator, stepGenerator: StepGenerator);
10
+ plan(context: ExecutionContext): Promise<ExecutionPlan>;
11
+ private generatePlan;
12
+ private getSteps;
13
+ private generateBeforeSteps;
14
+ private generateAfterSteps;
15
+ private generateCatchSteps;
16
+ }
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
13
+ return new (P || (P = Promise))(function (resolve, reject) {
14
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
15
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
16
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
17
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
18
+ });
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.ExecutionPlanner = void 0;
22
+ const step_1 = require("../step");
23
+ const execution_transport_1 = require("./execution-transport");
24
+ const di_1 = require("@axisparkjs/di");
25
+ const timeout_1 = require("../timeout");
26
+ let ExecutionPlanner = class ExecutionPlanner {
27
+ constructor(timeoutGenerator, stepGenerator) {
28
+ this.timeoutGenerator = timeoutGenerator;
29
+ this.stepGenerator = stepGenerator;
30
+ this.registeredPlans = new Map();
31
+ }
32
+ plan(context) {
33
+ return __awaiter(this, void 0, void 0, function* () {
34
+ const key = `${context.target.name}.${String(context.propertyKey)}`;
35
+ let plan = this.registeredPlans.get(key);
36
+ if (!plan) {
37
+ const steps = yield this.stepGenerator.generate(context);
38
+ plan = this.generatePlan(context, steps);
39
+ this.registeredPlans.set(key, plan);
40
+ }
41
+ return plan;
42
+ });
43
+ }
44
+ generatePlan(context, steps) {
45
+ const validSteps = steps.filter((step) => step.transport === execution_transport_1.ExecutionTransport.All || step.transport === context.transport);
46
+ const beforeSteps = this.generateBeforeSteps(validSteps);
47
+ const afterSteps = this.generateAfterSteps(validSteps);
48
+ const catchSteps = this.generateCatchSteps(validSteps);
49
+ const timeoutStep = this.timeoutGenerator.generate(context);
50
+ return { before: beforeSteps, after: afterSteps, context, catch: catchSteps, timeout: timeoutStep };
51
+ }
52
+ getSteps(steps, type, global) {
53
+ let finalSteps = steps.filter((step) => step.type === type && step.global === global);
54
+ if (global)
55
+ finalSteps = finalSteps.sort((a, b) => b.priority - a.priority);
56
+ return finalSteps;
57
+ }
58
+ generateBeforeSteps(steps) {
59
+ const before = [];
60
+ const globalMiddlewares = this.getSteps(steps, step_1.StepType.Middleware, true);
61
+ const usingMiddlewares = this.getSteps(steps, step_1.StepType.Middleware, false);
62
+ before.push(...globalMiddlewares);
63
+ before.push(...usingMiddlewares);
64
+ const globalGuards = this.getSteps(steps, step_1.StepType.Guard, true);
65
+ const usingGuards = this.getSteps(steps, step_1.StepType.Guard, false);
66
+ before.push(...globalGuards);
67
+ before.push(...usingGuards);
68
+ const globalInterceptors = this.getSteps(steps, step_1.StepType.Interceptor, true);
69
+ const usingInterceptors = this.getSteps(steps, step_1.StepType.Interceptor, false);
70
+ const interceptors = [...globalInterceptors, ...usingInterceptors].filter((step) => step.scope === step_1.StepScope.Before);
71
+ before.push(...interceptors);
72
+ return before;
73
+ }
74
+ generateAfterSteps(steps) {
75
+ const after = [];
76
+ const globalInterceptors = this.getSteps(steps, step_1.StepType.Interceptor, true);
77
+ const usingInterceptors = this.getSteps(steps, step_1.StepType.Interceptor, false);
78
+ const interceptors = [...globalInterceptors, ...usingInterceptors].filter((step) => step.scope === step_1.StepScope.After);
79
+ const interceptorsReverse = interceptors.toReversed();
80
+ after.push(...interceptorsReverse);
81
+ return after;
82
+ }
83
+ generateCatchSteps(steps) {
84
+ const catchs = [];
85
+ const globalFilters = this.getSteps(steps, step_1.StepType.Filter, true);
86
+ const usingFilters = this.getSteps(steps, step_1.StepType.Filter, false);
87
+ const allFilters = [...usingFilters.toReversed(), ...globalFilters];
88
+ catchs.push(...allFilters);
89
+ return catchs;
90
+ }
91
+ };
92
+ exports.ExecutionPlanner = ExecutionPlanner;
93
+ exports.ExecutionPlanner = ExecutionPlanner = __decorate([
94
+ (0, di_1.Injectable)(),
95
+ __metadata("design:paramtypes", [timeout_1.TimeoutGenerator,
96
+ step_1.StepGenerator])
97
+ ], ExecutionPlanner);
98
+ //# sourceMappingURL=execution-planner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-planner.js","sourceRoot":"","sources":["../../src/execution/execution-planner.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA,kCAUiB;AAEjB,+DAA2D;AAC3D,uCAA4C;AAC5C,wCAA8C;AAMvC,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAGzB,YACqB,gBAAkC,EAClC,aAA4B;QAD5B,qBAAgB,GAAhB,gBAAgB,CAAk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AY,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,eAAQ,CAAC,MAAM,EAAE,KAAK,CAA0B,CAAC;QAC3F,MAAM,UAAU,GAAG,CAAC,GAAG,YAAY,CAAC,UAAU,EAAE,EAAE,GAAG,aAAa,CAAC,CAAC;QACpE,MAAM,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,CAAC;QAE3B,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ,CAAA;AApFY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,eAAU,GAAE;qCAK8B,0BAAgB;QACnB,oBAAa;GALxC,gBAAgB,CAoF5B"}
@@ -0,0 +1,5 @@
1
+ export declare enum ExecutionTransport {
2
+ All = "all",
3
+ Http = "http",
4
+ Other = "other"
5
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExecutionTransport = void 0;
4
+ var ExecutionTransport;
5
+ (function (ExecutionTransport) {
6
+ ExecutionTransport["All"] = "all";
7
+ ExecutionTransport["Http"] = "http";
8
+ ExecutionTransport["Other"] = "other";
9
+ })(ExecutionTransport || (exports.ExecutionTransport = ExecutionTransport = {}));
10
+ //# sourceMappingURL=execution-transport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-transport.js","sourceRoot":"","sources":["../../src/execution/execution-transport.ts"],"names":[],"mappings":";;;AAGA,IAAY,kBAIX;AAJD,WAAY,kBAAkB;IAC1B,iCAAW,CAAA;IACX,mCAAa,CAAA;IACb,qCAAe,CAAA;AACnB,CAAC,EAJW,kBAAkB,kCAAlB,kBAAkB,QAI7B"}
@@ -0,0 +1,13 @@
1
+ import { Injector } from '@axisparkjs/di';
2
+ import { ExecutionContext } from './execution-context';
3
+ import { ExecutionHandler } from './execution-handler';
4
+ import { ParameterGenerator } from '../parameter';
5
+ import { PipeGenerator, PipeProcessor } from '../pipe';
6
+ export declare class HandlerInvoker {
7
+ private readonly parameterGenerator;
8
+ private readonly pipeGenerator;
9
+ private readonly pipeProcessor;
10
+ private readonly injector;
11
+ constructor(parameterGenerator: ParameterGenerator, pipeGenerator: PipeGenerator, pipeProcessor: PipeProcessor, injector: Injector);
12
+ invoke(handler: ExecutionHandler, context: ExecutionContext): Promise<unknown>;
13
+ }