@aloma.io/integration-sdk 3.3.3 → 3.3.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.
@@ -7,8 +7,9 @@ export declare abstract class AbstractController {
7
7
  protected fallback(arg: any): Promise<any>;
8
8
  protected endpoint(arg: any): Promise<any>;
9
9
  protected newTask(name: string, data: any): Promise<string>;
10
- protected getClient({ baseUrl }: {
10
+ protected getClient({ baseUrl, onResponse }: {
11
11
  baseUrl: string;
12
+ onResponse?: (response: any) => void;
12
13
  }): Promise<any>;
13
14
  protected updateTask(name: string, data: any): Promise<string>;
14
15
  __endpoint(arg: any): Promise<any | null>;
@@ -15,7 +15,7 @@ export class AbstractController {
15
15
  async newTask(name, data) {
16
16
  throw new Error("not implemented");
17
17
  }
18
- getClient({ baseUrl }) {
18
+ getClient({ baseUrl, onResponse }) {
19
19
  throw new Error("not implemented");
20
20
  }
21
21
  async updateTask(name, data) {
@@ -36,9 +36,10 @@ const unwrap = async (ret, options) => {
36
36
  return await ret.json();
37
37
  };
38
38
  class Fetcher {
39
- constructor({ retry = 5, baseUrl }) {
39
+ constructor({ retry = 5, baseUrl, onResponse }) {
40
40
  this.retry = retry;
41
41
  this.baseUrl = baseUrl;
42
+ this.onResponse = onResponse;
42
43
  }
43
44
  async customize(options, args = {}) { }
44
45
  async onError(e, url, options, retries, args) {
@@ -87,6 +88,9 @@ class Fetcher {
87
88
  e.status = status;
88
89
  throw e;
89
90
  }
91
+ if (local.onResponse) {
92
+ await local.onResponse(ret);
93
+ }
90
94
  return unwrap(ret, options);
91
95
  }
92
96
  catch (e) {
@@ -99,8 +103,8 @@ class Fetcher {
99
103
  }
100
104
  }
101
105
  class OAuthFetcher extends Fetcher {
102
- constructor({ oauth, retry = 5, getToken, baseUrl }) {
103
- super({ retry, baseUrl });
106
+ constructor({ oauth, retry = 5, getToken, baseUrl, onResponse }) {
107
+ super({ retry, baseUrl, onResponse });
104
108
  this.oauth = oauth;
105
109
  this._getToken = getToken;
106
110
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aloma.io/integration-sdk",
3
- "version": "3.3.3",
3
+ "version": "3.3.5",
4
4
  "description": "",
5
5
  "author": "aloma.io",
6
6
  "license": "Apache-2.0",
@@ -22,7 +22,7 @@ export abstract class AbstractController {
22
22
  throw new Error("not implemented");
23
23
  }
24
24
 
25
- protected getClient({ baseUrl }: { baseUrl: string }): Promise<any> {
25
+ protected getClient({ baseUrl, onResponse }: { baseUrl: string, onResponse?: (response: any) => void }): Promise<any> {
26
26
  throw new Error("not implemented");
27
27
  }
28
28
 
@@ -45,9 +45,10 @@ const unwrap = async (ret, options) => {
45
45
  };
46
46
 
47
47
  class Fetcher {
48
- constructor({ retry = 5, baseUrl }) {
48
+ constructor({ retry = 5, baseUrl, onResponse }) {
49
49
  this.retry = retry;
50
50
  this.baseUrl = baseUrl;
51
+ this.onResponse = onResponse;
51
52
  }
52
53
 
53
54
  async customize(options, args = {}) {}
@@ -112,6 +113,11 @@ class Fetcher {
112
113
  e.status = status;
113
114
  throw e;
114
115
  }
116
+
117
+ if (local.onResponse)
118
+ {
119
+ await local.onResponse(ret);
120
+ }
115
121
 
116
122
  return unwrap(ret, options);
117
123
  } catch (e) {
@@ -127,8 +133,8 @@ class Fetcher {
127
133
  }
128
134
 
129
135
  class OAuthFetcher extends Fetcher {
130
- constructor({ oauth, retry = 5, getToken, baseUrl }) {
131
- super({ retry, baseUrl });
136
+ constructor({ oauth, retry = 5, getToken, baseUrl, onResponse }) {
137
+ super({ retry, baseUrl, onResponse });
132
138
 
133
139
  this.oauth = oauth;
134
140
  this._getToken = getToken;