@aloma.io/integration-sdk 3.3.79 → 3.3.81

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,9 +7,10 @@ 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, onResponse, }: {
10
+ protected getClient({ baseUrl, onResponse, customize }: {
11
11
  baseUrl: string;
12
12
  onResponse?: (response: any) => void;
13
+ customize?: (request: any) => void;
13
14
  }): Promise<any>;
14
15
  protected updateTask(name: string, data: any): Promise<string>;
15
16
  __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, onResponse, }) {
18
+ getClient({ baseUrl, onResponse, customize }) {
19
19
  throw new Error("not implemented");
20
20
  }
21
21
  async updateTask(name, data) {
@@ -42,12 +42,17 @@ const unwrap = async (ret, options) => {
42
42
  }
43
43
  };
44
44
  class Fetcher {
45
- constructor({ retry = 5, baseUrl, onResponse }) {
45
+ constructor({ retry = 5, baseUrl, onResponse, customize }) {
46
46
  this.retry = retry;
47
47
  this.baseUrl = baseUrl;
48
48
  this.onResponse = onResponse;
49
+ if (customize)
50
+ this.customize0 = customize;
51
+ }
52
+ async customize(options, args = {}) {
53
+ if (this.customize0)
54
+ await this.customize0(options, args);
49
55
  }
50
- async customize(options, args = {}) { }
51
56
  async onError(e, url, options, retries, args, rateLimit) {
52
57
  var local = this;
53
58
  return new Promise((resolve, reject) => {
@@ -113,8 +118,8 @@ class Fetcher {
113
118
  }
114
119
  }
115
120
  class OAuthFetcher extends Fetcher {
116
- constructor({ oauth, retry = 5, getToken, baseUrl, onResponse }) {
117
- super({ retry, baseUrl, onResponse });
121
+ constructor({ oauth, retry = 5, getToken, baseUrl, onResponse, customize }) {
122
+ super({ retry, baseUrl, onResponse, customize });
118
123
  this.oauth = oauth;
119
124
  this._getToken = getToken;
120
125
  }
@@ -166,6 +171,8 @@ class OAuthFetcher extends Fetcher {
166
171
  }
167
172
  async customize(options, args = {}) {
168
173
  const local = this;
174
+ if (this.customize0)
175
+ await this.customize0(options, args);
169
176
  const token = await local.getToken(args.forceTokenRefresh);
170
177
  options.headers = {
171
178
  ...options.headers,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aloma.io/integration-sdk",
3
- "version": "3.3.79",
3
+ "version": "3.3.81",
4
4
  "description": "",
5
5
  "author": "aloma.io",
6
6
  "license": "Apache-2.0",
@@ -25,9 +25,11 @@ export abstract class AbstractController {
25
25
  protected getClient({
26
26
  baseUrl,
27
27
  onResponse,
28
+ customize
28
29
  }: {
29
30
  baseUrl: string;
30
31
  onResponse?: (response: any) => void;
32
+ customize?: (request: any) => void;
31
33
  }): Promise<any> {
32
34
  throw new Error("not implemented");
33
35
  }
@@ -51,13 +51,16 @@ const unwrap = async (ret, options) => {
51
51
  };
52
52
 
53
53
  class Fetcher {
54
- constructor({ retry = 5, baseUrl, onResponse }) {
54
+ constructor({ retry = 5, baseUrl, onResponse, customize }) {
55
55
  this.retry = retry;
56
56
  this.baseUrl = baseUrl;
57
57
  this.onResponse = onResponse;
58
+ if (customize) this.customize0 = customize;
58
59
  }
59
60
 
60
- async customize(options, args = {}) {}
61
+ async customize(options, args = {}) {
62
+ if (this.customize0) await this.customize0(options, args);
63
+ }
61
64
 
62
65
  async onError(e, url, options, retries, args, rateLimit) {
63
66
  var local = this;
@@ -146,8 +149,8 @@ class Fetcher {
146
149
  }
147
150
 
148
151
  class OAuthFetcher extends Fetcher {
149
- constructor({ oauth, retry = 5, getToken, baseUrl, onResponse }) {
150
- super({ retry, baseUrl, onResponse });
152
+ constructor({ oauth, retry = 5, getToken, baseUrl, onResponse, customize}) {
153
+ super({ retry, baseUrl, onResponse, customize });
151
154
 
152
155
  this.oauth = oauth;
153
156
  this._getToken = getToken;
@@ -216,6 +219,8 @@ class OAuthFetcher extends Fetcher {
216
219
 
217
220
  async customize(options, args = {}) {
218
221
  const local = this;
222
+ if (this.customize0) await this.customize0(options, args);
223
+
219
224
  const token = await local.getToken(args.forceTokenRefresh);
220
225
 
221
226
  options.headers = {