@spacelr/sdk 0.19.1 → 0.19.3
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/dist/index.js +26 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2711,6 +2711,19 @@ var AuthModule = class _AuthModule {
|
|
|
2711
2711
|
};
|
|
2712
2712
|
|
|
2713
2713
|
// libs/sdk/src/modules/storage.module.ts
|
|
2714
|
+
var THROTTLE_RETRY_MS = 6e4;
|
|
2715
|
+
var THROTTLE_MAX_RETRIES = 2;
|
|
2716
|
+
async function retryThrottled(call) {
|
|
2717
|
+
for (let attempt = 0; ; attempt++) {
|
|
2718
|
+
try {
|
|
2719
|
+
return await call();
|
|
2720
|
+
} catch (error) {
|
|
2721
|
+
const throttled = error instanceof SpacelrError && error.statusCode === 429;
|
|
2722
|
+
if (!throttled || attempt >= THROTTLE_MAX_RETRIES) throw error;
|
|
2723
|
+
await new Promise((resolve) => setTimeout(resolve, THROTTLE_RETRY_MS));
|
|
2724
|
+
}
|
|
2725
|
+
}
|
|
2726
|
+
}
|
|
2714
2727
|
var StorageModule = class {
|
|
2715
2728
|
constructor(http, tokenManager, config) {
|
|
2716
2729
|
this.http = http;
|
|
@@ -2780,10 +2793,12 @@ var StorageModule = class {
|
|
|
2780
2793
|
percentage: fileSize > 0 ? Math.min(100, Math.round(totalLoaded / fileSize * 100)) : 0
|
|
2781
2794
|
});
|
|
2782
2795
|
} : void 0;
|
|
2783
|
-
const result = await
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2796
|
+
const result = await retryThrottled(
|
|
2797
|
+
() => this.http.uploadForm(
|
|
2798
|
+
`/storage/files/${fileId}/multipart/upload-part`,
|
|
2799
|
+
formData,
|
|
2800
|
+
partProgress
|
|
2801
|
+
)
|
|
2787
2802
|
);
|
|
2788
2803
|
partProgressMap.delete(partNumber);
|
|
2789
2804
|
completedBytes += chunkSize;
|
|
@@ -2803,11 +2818,10 @@ var StorageModule = class {
|
|
|
2803
2818
|
partProgressMap.clear();
|
|
2804
2819
|
}
|
|
2805
2820
|
completedParts.sort((a, b) => a.partNumber - b.partNumber);
|
|
2806
|
-
await this.completeMultipartUpload(fileId, completedParts);
|
|
2807
|
-
return this.getFileInfo(fileId);
|
|
2821
|
+
return await retryThrottled(() => this.completeMultipartUpload(fileId, completedParts));
|
|
2808
2822
|
} catch (error) {
|
|
2809
2823
|
try {
|
|
2810
|
-
await this.abortMultipartUpload(fileId);
|
|
2824
|
+
await retryThrottled(() => this.abortMultipartUpload(fileId));
|
|
2811
2825
|
} catch {
|
|
2812
2826
|
}
|
|
2813
2827
|
throw error;
|
|
@@ -4357,7 +4371,8 @@ var NotificationsModule = class _NotificationsModule {
|
|
|
4357
4371
|
if (!stored) return;
|
|
4358
4372
|
await this.deleteSubscription(
|
|
4359
4373
|
stored.subscription.platform,
|
|
4360
|
-
_NotificationsModule.identifierOf(stored.subscription)
|
|
4374
|
+
_NotificationsModule.identifierOf(stored.subscription),
|
|
4375
|
+
true
|
|
4361
4376
|
).catch(() => void 0);
|
|
4362
4377
|
});
|
|
4363
4378
|
let timer;
|
|
@@ -4374,7 +4389,7 @@ var NotificationsModule = class _NotificationsModule {
|
|
|
4374
4389
|
this.pushQueue = run.catch(() => void 0);
|
|
4375
4390
|
return run;
|
|
4376
4391
|
}
|
|
4377
|
-
deleteSubscription(platform, identifier) {
|
|
4392
|
+
deleteSubscription(platform, identifier, skipAuthRefresh = false) {
|
|
4378
4393
|
const body = { platform };
|
|
4379
4394
|
if (platform === "web") {
|
|
4380
4395
|
body["endpoint"] = identifier;
|
|
@@ -4385,7 +4400,8 @@ var NotificationsModule = class _NotificationsModule {
|
|
|
4385
4400
|
method: "DELETE",
|
|
4386
4401
|
path: "/notifications/subscribe",
|
|
4387
4402
|
body,
|
|
4388
|
-
authenticated: true
|
|
4403
|
+
authenticated: true,
|
|
4404
|
+
skipAuthRefresh
|
|
4389
4405
|
});
|
|
4390
4406
|
}
|
|
4391
4407
|
/** The value `unsubscribe()` identifies a subscription by: endpoint for web, token otherwise. */
|