@modern-js/bff-core 1.2.0 → 1.2.1-beta.2

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.
@@ -23,6 +23,7 @@ export function Api(...args) {
23
23
  }
24
24
 
25
25
  const validateHandlers = operators.filter(operator => operator.validate).map(operator => operator.validate);
26
+ const pipeHandlers = operators.filter(operator => operator.execute).map(operator => operator.execute);
26
27
 
27
28
  async function runner(inputs) {
28
29
  const executeHelper = {
@@ -30,10 +31,15 @@ export function Api(...args) {
30
31
 
31
32
  get inputs() {
32
33
  return inputs;
34
+ },
35
+
36
+ set inputs(val) {
37
+ // eslint-disable-next-line no-param-reassign
38
+ inputs = val;
33
39
  }
34
40
 
35
41
  };
36
- const stack = [...validateHandlers];
42
+ const stack = [...validateHandlers, ...pipeHandlers];
37
43
  stack.push(async (helper, next) => {
38
44
  const res = await handler(inputs);
39
45
  helper.result = res;
@@ -35,6 +35,7 @@ function Api(...args) {
35
35
  }
36
36
 
37
37
  const validateHandlers = operators.filter(operator => operator.validate).map(operator => operator.validate);
38
+ const pipeHandlers = operators.filter(operator => operator.execute).map(operator => operator.execute);
38
39
 
39
40
  async function runner(inputs) {
40
41
  const executeHelper = {
@@ -42,10 +43,15 @@ function Api(...args) {
42
43
 
43
44
  get inputs() {
44
45
  return inputs;
46
+ },
47
+
48
+ set inputs(val) {
49
+ // eslint-disable-next-line no-param-reassign
50
+ inputs = val;
45
51
  }
46
52
 
47
53
  };
48
- const stack = [...validateHandlers];
54
+ const stack = [...validateHandlers, ...pipeHandlers];
49
55
  stack.push(async (helper, next) => {
50
56
  const res = await handler(inputs);
51
57
  helper.result = res;
@@ -31,10 +31,10 @@ export declare enum HttpMethod {
31
31
  Head = "HEAD",
32
32
  }
33
33
  export declare type InputSchemaMeata = Extract<HttpMetadata, HttpMetadata.Data | HttpMetadata.Query | HttpMetadata.Headers | HttpMetadata.Params>;
34
- export declare type ValidateFunc = (helper: ExecuteHelper, next: () => Promise<any>) => Promise<any>;
34
+ export declare type ExecuteFunc = (helper: ExecuteHelper, next: () => Promise<any>) => Promise<any>;
35
35
  export declare type ExecuteHelper = {
36
36
  result?: any;
37
- readonly inputs: any;
37
+ inputs: any;
38
38
  };
39
39
  export declare type MetadataHelper = {
40
40
  setMetadata: <T = any>(key: any, value: T) => void;
@@ -44,7 +44,8 @@ export declare type Operator<Input> = {
44
44
  name: string;
45
45
  inputType?: Input;
46
46
  metadata?: (helper: MetadataHelper) => void;
47
- validate?: ValidateFunc;
47
+ validate?: ExecuteFunc;
48
+ execute?: ExecuteFunc;
48
49
  };
49
50
  export declare type MaybeAsync<T> = Promise<T> | T;
50
51
  export declare type ApiRunner<Input extends object | void | unknown, Output extends MaybeAsync<any>> = (...args: Input extends void ? never : [input: Input]) => Output;
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.2.0",
14
+ "version": "1.2.1-beta.2",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -58,7 +58,8 @@
58
58
  },
59
59
  "publishConfig": {
60
60
  "registry": "https://registry.npmjs.org/",
61
- "access": "public"
61
+ "access": "public",
62
+ "types": "./dist/types/index.d.ts"
62
63
  },
63
64
  "wireit": {
64
65
  "build": {