@thepassle/app-tools 0.8.1 → 0.8.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.
package/api/index.js CHANGED
@@ -111,7 +111,10 @@ export class Api {
111
111
  .then(async res => {
112
112
  for(const plugin of plugins) {
113
113
  try {
114
- res = await plugin?.afterFetch?.(res) ?? res;
114
+ const afterFetchResult = await plugin?.afterFetch?.(res) ?? res;
115
+ if(afterFetchResult) {
116
+ res = afterFetchResult;
117
+ }
115
118
  } catch(e) {
116
119
  log(`Plugin "${plugin.name}" error on afterFetch hook`)
117
120
  throw e;
@@ -4,7 +4,7 @@
4
4
  */
5
5
  export const delayPlugin = (ms) => ({
6
6
  name: 'delay',
7
- afterFetch: () => new Promise(r => setTimeout(r,ms))
7
+ afterFetch: () => {new Promise(r => setTimeout(r,ms))}
8
8
  });
9
9
 
10
10
  export const delay = delayPlugin(1000);
package/api/types.d.ts CHANGED
@@ -13,7 +13,7 @@ export type Method = 'GET'|'DELETE'|'HEAD'|'OPTIONS'|'POST'|'PUT'|'PATCH';
13
13
 
14
14
  export interface Plugin {
15
15
  beforeFetch?: (meta: MetaParams) => MetaParams | Promise<MetaParams> | void;
16
- afterFetch?: (res: Response) => Response | Promise<Response>;
16
+ afterFetch?: (res: Response) => void | Promise<void> | Response | Promise<Response>;
17
17
  transform?: (data: any) => any;
18
18
  name: string;
19
19
  handleError?: (e: Error) => boolean;
package/dialog/types.d.ts CHANGED
@@ -15,7 +15,7 @@ export interface OpenDialogOptions {
15
15
  }
16
16
 
17
17
  export interface Context {
18
- dialog: DialogNode,
18
+ dialog: DialogNode | undefined,
19
19
  id: string,
20
20
  parameters: Record<string, any>
21
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thepassle/app-tools",
3
- "version": "0.8.1",
3
+ "version": "0.8.2",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",