@aloma.io/integration-sdk 3.5.1 → 3.6.0
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/build/builder/transform/index.mjs +2 -4
- package/build/internal/index.mjs +14 -7
- package/build/internal/websocket/connection/index.mjs +2 -2
- package/build/internal/websocket/connection/registration.mjs +1 -1
- package/package.json +1 -1
- package/src/builder/transform/index.mts +6 -4
- package/src/internal/index.mjs +16 -6
- package/src/internal/websocket/connection/index.mjs +2 -4
- package/src/internal/websocket/connection/registration.mjs +1 -1
@@ -22,10 +22,8 @@ const transform = (meta) => {
|
|
22
22
|
.getSignatures()
|
23
23
|
.map((sig) => {
|
24
24
|
const docs = sig.getJSDoc().serialize() || [];
|
25
|
-
const desc = docs.find((what) => what.kind === "description")
|
26
|
-
|
27
|
-
const example = docs.find((what) => what.kind === "example")
|
28
|
-
?.value;
|
25
|
+
const desc = docs.find((what) => what.kind === "description")?.value;
|
26
|
+
const example = docs.find((what) => what.kind === "example")?.value;
|
29
27
|
let eg;
|
30
28
|
if (example) {
|
31
29
|
const parts = example.split(/```/);
|
package/build/internal/index.mjs
CHANGED
@@ -31,8 +31,10 @@ const unwrap0 = (ret, body, options) => {
|
|
31
31
|
const unwrap = async (ret, options) => {
|
32
32
|
if (options?.text)
|
33
33
|
return unwrap0(ret, await ret.text(), options);
|
34
|
-
if (options?.base64)
|
35
|
-
|
34
|
+
if (options?.base64) {
|
35
|
+
const base64 = Buffer.from(await ret.arrayBuffer()).toString('base64');
|
36
|
+
return unwrap0(ret, base64, options);
|
37
|
+
}
|
36
38
|
const text = await ret.text();
|
37
39
|
try {
|
38
40
|
return unwrap0(ret, JSON.parse(text), options);
|
@@ -95,7 +97,10 @@ class Fetcher {
|
|
95
97
|
options?.headers?.["Content-type"] === "application/json") {
|
96
98
|
options.body = JSON.stringify(options.body);
|
97
99
|
}
|
98
|
-
const ret = await fetch(theURL, {
|
100
|
+
const ret = await fetch(theURL, {
|
101
|
+
...options,
|
102
|
+
signal: AbortSignal.timeout(30 * 60 * 1000),
|
103
|
+
});
|
99
104
|
const status = await ret.status;
|
100
105
|
if (status > 399) {
|
101
106
|
const text = await ret.text();
|
@@ -173,9 +178,11 @@ class OAuthFetcher extends Fetcher {
|
|
173
178
|
}
|
174
179
|
async periodicRefresh() {
|
175
180
|
const local = this, oauth = local.oauth;
|
181
|
+
console.log("refreshing oauth token, have token", !!oauth.refreshToken());
|
176
182
|
if (!oauth.refreshToken())
|
177
183
|
return;
|
178
184
|
await local.getToken(true);
|
185
|
+
console.log("refreshed oauth token");
|
179
186
|
}
|
180
187
|
async customize(options, args = {}) {
|
181
188
|
const local = this;
|
@@ -405,7 +412,7 @@ ${text}
|
|
405
412
|
method: "POST",
|
406
413
|
body: new URLSearchParams(body),
|
407
414
|
headers,
|
408
|
-
signal: AbortSignal.timeout(60 * 1000)
|
415
|
+
signal: AbortSignal.timeout(60 * 1000),
|
409
416
|
});
|
410
417
|
const status = await response.status;
|
411
418
|
const text = await response.text();
|
@@ -481,7 +488,7 @@ ${text}
|
|
481
488
|
Accept: "application/json",
|
482
489
|
...headers,
|
483
490
|
},
|
484
|
-
signal: AbortSignal.timeout(60 * 1000)
|
491
|
+
signal: AbortSignal.timeout(60 * 1000),
|
485
492
|
});
|
486
493
|
const status = await response.status;
|
487
494
|
const text = await response.text();
|
@@ -500,13 +507,13 @@ ${text}
|
|
500
507
|
if (!(this._oauth.noPeriodicTokenRefresh === false)) {
|
501
508
|
this._refreshOAuthToken = setInterval(async () => {
|
502
509
|
try {
|
503
|
-
console.log(
|
510
|
+
console.log("refreshing oauth token");
|
504
511
|
await theOAuth.periodicRefresh();
|
505
512
|
}
|
506
513
|
catch (e) {
|
507
514
|
console.log("periodic refresh", e);
|
508
515
|
}
|
509
|
-
}, this._oauth.tokenRefreshPeriod ||
|
516
|
+
}, this._oauth.tokenRefreshPeriod || 4 * 60 * 60 * 15000);
|
510
517
|
}
|
511
518
|
}
|
512
519
|
const getBlob = (id) => {
|
@@ -12,7 +12,7 @@ class Connection {
|
|
12
12
|
method: "POST",
|
13
13
|
body: JSON.stringify({}),
|
14
14
|
headers: { "Content-Type": "application/json" },
|
15
|
-
signal: AbortSignal.timeout(60 * 1000)
|
15
|
+
signal: AbortSignal.timeout(60 * 1000),
|
16
16
|
}, config));
|
17
17
|
if (response.status === 401) {
|
18
18
|
config.setToken(await new Registration(local.config).run());
|
@@ -41,7 +41,7 @@ class Connection {
|
|
41
41
|
method: "POST",
|
42
42
|
body: JSON.stringify({}),
|
43
43
|
headers: { "Content-Type": "application/json" },
|
44
|
-
signal: AbortSignal.timeout(60 * 1000)
|
44
|
+
signal: AbortSignal.timeout(60 * 1000),
|
45
45
|
}, this.config));
|
46
46
|
}
|
47
47
|
catch (e) {
|
@@ -21,7 +21,7 @@ class Registration {
|
|
21
21
|
icon,
|
22
22
|
}),
|
23
23
|
headers: { "Content-Type": "application/json" },
|
24
|
-
signal: AbortSignal.timeout(60 * 1000)
|
24
|
+
signal: AbortSignal.timeout(60 * 1000),
|
25
25
|
}, config));
|
26
26
|
if (response.status === 200)
|
27
27
|
return (await response.json()).key;
|
package/package.json
CHANGED
@@ -29,11 +29,13 @@ const transform = (meta: any) => {
|
|
29
29
|
.getSignatures()
|
30
30
|
.map((sig: any) => {
|
31
31
|
const docs = sig.getJSDoc().serialize() || [];
|
32
|
-
const desc = docs.find(
|
33
|
-
|
32
|
+
const desc = docs.find(
|
33
|
+
(what: any) => what.kind === "description",
|
34
|
+
)?.value;
|
34
35
|
|
35
|
-
const example = docs.find(
|
36
|
-
|
36
|
+
const example = docs.find(
|
37
|
+
(what: any) => what.kind === "example",
|
38
|
+
)?.value;
|
37
39
|
|
38
40
|
let eg;
|
39
41
|
if (example) {
|
package/src/internal/index.mjs
CHANGED
@@ -39,7 +39,11 @@ const unwrap0 = (ret, body, options) => {
|
|
39
39
|
const unwrap = async (ret, options) => {
|
40
40
|
if (options?.text) return unwrap0(ret, await ret.text(), options);
|
41
41
|
if (options?.base64)
|
42
|
-
|
42
|
+
{
|
43
|
+
const base64 = Buffer.from(await ret.arrayBuffer()).toString('base64');
|
44
|
+
|
45
|
+
return unwrap0(ret, base64, options);
|
46
|
+
}
|
43
47
|
|
44
48
|
const text = await ret.text();
|
45
49
|
|
@@ -123,7 +127,10 @@ class Fetcher {
|
|
123
127
|
options.body = JSON.stringify(options.body);
|
124
128
|
}
|
125
129
|
|
126
|
-
const ret = await fetch(theURL, {
|
130
|
+
const ret = await fetch(theURL, {
|
131
|
+
...options,
|
132
|
+
signal: AbortSignal.timeout(30 * 60 * 1000),
|
133
|
+
});
|
127
134
|
const status = await ret.status;
|
128
135
|
|
129
136
|
if (status > 399) {
|
@@ -225,9 +232,12 @@ class OAuthFetcher extends Fetcher {
|
|
225
232
|
const local = this,
|
226
233
|
oauth = local.oauth;
|
227
234
|
|
235
|
+
console.log("refreshing oauth token, have token", !!oauth.refreshToken());
|
228
236
|
if (!oauth.refreshToken()) return;
|
229
237
|
|
230
238
|
await local.getToken(true);
|
239
|
+
|
240
|
+
console.log("refreshed oauth token");
|
231
241
|
}
|
232
242
|
|
233
243
|
async customize(options, args = {}) {
|
@@ -507,7 +517,7 @@ ${text}
|
|
507
517
|
method: "POST",
|
508
518
|
body: new URLSearchParams(body),
|
509
519
|
headers,
|
510
|
-
signal: AbortSignal.timeout(60 * 1000)
|
520
|
+
signal: AbortSignal.timeout(60 * 1000),
|
511
521
|
});
|
512
522
|
|
513
523
|
const status = await response.status;
|
@@ -600,7 +610,7 @@ ${text}
|
|
600
610
|
Accept: "application/json",
|
601
611
|
...headers,
|
602
612
|
},
|
603
|
-
signal: AbortSignal.timeout(60 * 1000)
|
613
|
+
signal: AbortSignal.timeout(60 * 1000),
|
604
614
|
});
|
605
615
|
|
606
616
|
const status = await response.status;
|
@@ -626,13 +636,13 @@ ${text}
|
|
626
636
|
this._refreshOAuthToken = setInterval(
|
627
637
|
async () => {
|
628
638
|
try {
|
629
|
-
console.log(
|
639
|
+
console.log("refreshing oauth token");
|
630
640
|
await theOAuth.periodicRefresh();
|
631
641
|
} catch (e) {
|
632
642
|
console.log("periodic refresh", e);
|
633
643
|
}
|
634
644
|
},
|
635
|
-
this._oauth.tokenRefreshPeriod ||
|
645
|
+
this._oauth.tokenRefreshPeriod || 4 * 60 * 60 * 15000,
|
636
646
|
);
|
637
647
|
}
|
638
648
|
}
|
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
import { Registration } from "./registration.mjs";
|
3
2
|
import C from "./constants.mjs";
|
4
3
|
|
@@ -20,10 +19,9 @@ class Connection {
|
|
20
19
|
method: "POST",
|
21
20
|
body: JSON.stringify({}),
|
22
21
|
headers: { "Content-Type": "application/json" },
|
23
|
-
signal: AbortSignal.timeout(60 * 1000)
|
22
|
+
signal: AbortSignal.timeout(60 * 1000),
|
24
23
|
},
|
25
24
|
config,
|
26
|
-
|
27
25
|
),
|
28
26
|
);
|
29
27
|
|
@@ -59,7 +57,7 @@ class Connection {
|
|
59
57
|
method: "POST",
|
60
58
|
body: JSON.stringify({}),
|
61
59
|
headers: { "Content-Type": "application/json" },
|
62
|
-
signal: AbortSignal.timeout(60 * 1000)
|
60
|
+
signal: AbortSignal.timeout(60 * 1000),
|
63
61
|
},
|
64
62
|
this.config,
|
65
63
|
),
|