@aloma.io/integration-sdk 3.7.34 → 3.7.36
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.
@@ -10,6 +10,7 @@ declare class OAuthFetcher extends Fetcher {
|
|
10
10
|
onResponse: any;
|
11
11
|
customize: any;
|
12
12
|
});
|
13
|
+
__healthCheck(): Promise<void>;
|
13
14
|
getToken(force: any): Promise<any>;
|
14
15
|
onError(e: any, url: any, options: any, retries: any, args: any, rateLimit: any): Promise<unknown>;
|
15
16
|
periodicRefresh(): Promise<void>;
|
@@ -7,6 +7,10 @@ class OAuthFetcher extends Fetcher {
|
|
7
7
|
this.oauth = oauth;
|
8
8
|
this._getToken = getToken;
|
9
9
|
}
|
10
|
+
async __healthCheck() {
|
11
|
+
if (!this.oauth.accessToken())
|
12
|
+
throw new Error('no access token');
|
13
|
+
}
|
10
14
|
async getToken(force) {
|
11
15
|
var local = this, oauth = local.oauth;
|
12
16
|
if (local._getToken)
|
package/build/internal/index.mjs
CHANGED
@@ -306,6 +306,8 @@ ${text}
|
|
306
306
|
console.log("periodic refresh", e);
|
307
307
|
}
|
308
308
|
}, this._oauth.tokenRefreshPeriod || 4 * 60 * 60 * 15000);
|
309
|
+
// @ts-ignore
|
310
|
+
theOAuth.getToken();
|
309
311
|
}
|
310
312
|
}
|
311
313
|
const getBlob = (id) => {
|
@@ -336,6 +338,7 @@ ${text}
|
|
336
338
|
transport.send(packet);
|
337
339
|
});
|
338
340
|
};
|
341
|
+
let oauthClient;
|
339
342
|
start({
|
340
343
|
config: decrypted,
|
341
344
|
oauth: theOAuth,
|
@@ -345,6 +348,9 @@ ${text}
|
|
345
348
|
healthCheck: async (controller) => {
|
346
349
|
let result = { ok: true, error: null };
|
347
350
|
try {
|
351
|
+
if (oauthClient) {
|
352
|
+
await oauthClient.__healthCheck();
|
353
|
+
}
|
348
354
|
await controller.__healthCheck();
|
349
355
|
}
|
350
356
|
catch (e) {
|
@@ -356,7 +362,7 @@ ${text}
|
|
356
362
|
packet.args(result);
|
357
363
|
transport.send(packet);
|
358
364
|
},
|
359
|
-
getClient: (arg) => theOAuth ? theOAuth.getClient(arg) : new Fetcher(arg),
|
365
|
+
getClient: (arg) => theOAuth ? (oauthClient = theOAuth.getClient(arg)) : new Fetcher(arg),
|
360
366
|
newTask: (name, data) => {
|
361
367
|
return new Promise((resolve, reject) => {
|
362
368
|
const packet = transport.newPacket({}, (ret) => (ret?.error ? reject(ret.error) : resolve(ret)), `_req-${cuid()}`);
|
package/package.json
CHANGED
package/src/internal/index.mts
CHANGED
@@ -373,6 +373,9 @@ ${text}
|
|
373
373
|
},
|
374
374
|
this._oauth.tokenRefreshPeriod || 4 * 60 * 60 * 15000,
|
375
375
|
);
|
376
|
+
|
377
|
+
// @ts-ignore
|
378
|
+
theOAuth.getToken();
|
376
379
|
}
|
377
380
|
}
|
378
381
|
|
@@ -426,6 +429,8 @@ ${text}
|
|
426
429
|
});
|
427
430
|
};
|
428
431
|
|
432
|
+
let oauthClient;
|
433
|
+
|
429
434
|
start({
|
430
435
|
config: decrypted,
|
431
436
|
oauth: theOAuth,
|
@@ -436,6 +441,10 @@ ${text}
|
|
436
441
|
let result: any = { ok: true, error: null };
|
437
442
|
|
438
443
|
try {
|
444
|
+
if (oauthClient) {
|
445
|
+
await oauthClient.__healthCheck();
|
446
|
+
}
|
447
|
+
|
439
448
|
await controller.__healthCheck();
|
440
449
|
} catch (e: any) {
|
441
450
|
result.ok = false;
|
@@ -450,7 +459,7 @@ ${text}
|
|
450
459
|
transport.send(packet);
|
451
460
|
},
|
452
461
|
getClient: (arg) =>
|
453
|
-
theOAuth ? theOAuth.getClient(arg) : new Fetcher(arg),
|
462
|
+
theOAuth ? (oauthClient = theOAuth.getClient(arg)) : new Fetcher(arg),
|
454
463
|
newTask: (name, data) => {
|
455
464
|
return new Promise((resolve, reject) => {
|
456
465
|
const packet = transport.newPacket(
|