@sparkvault/sdk 1.23.6 → 1.23.8
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/sparkvault.cjs.js +27 -8
- package/dist/sparkvault.cjs.js.map +1 -1
- package/dist/sparkvault.esm.js +27 -8
- package/dist/sparkvault.esm.js.map +1 -1
- package/dist/sparkvault.js +1 -1
- package/dist/sparkvault.js.map +1 -1
- package/dist/vaults/upload/index.d.ts +0 -1
- package/dist/vaults/upload/types.d.ts +1 -0
- package/package.json +1 -1
package/dist/sparkvault.cjs.js
CHANGED
|
@@ -936,6 +936,7 @@ class IdentityApiError extends Error {
|
|
|
936
936
|
this.name = 'IdentityApiError';
|
|
937
937
|
this.code = code;
|
|
938
938
|
this.statusCode = statusCode;
|
|
939
|
+
Object.setPrototypeOf(this, IdentityApiError.prototype);
|
|
939
940
|
}
|
|
940
941
|
}
|
|
941
942
|
|
|
@@ -6515,6 +6516,7 @@ class UploadApiError extends SparkVaultError {
|
|
|
6515
6516
|
super(message, code, httpStatus);
|
|
6516
6517
|
this.httpStatus = httpStatus;
|
|
6517
6518
|
this.name = 'UploadApiError';
|
|
6519
|
+
Object.setPrototypeOf(this, UploadApiError.prototype);
|
|
6518
6520
|
}
|
|
6519
6521
|
}
|
|
6520
6522
|
/**
|
|
@@ -9013,8 +9015,6 @@ class UploadRenderer {
|
|
|
9013
9015
|
renderError(state) {
|
|
9014
9016
|
const div = document.createElement('div');
|
|
9015
9017
|
div.className = 'svu-error-view';
|
|
9016
|
-
const statusCode = state.httpStatus || 404;
|
|
9017
|
-
const statusText = statusCode === 402 ? 'Service Unavailable' : 'Resource Not Found';
|
|
9018
9018
|
div.innerHTML = `
|
|
9019
9019
|
<div class="svu-error-icon">
|
|
9020
9020
|
<svg width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
|
|
@@ -9023,7 +9023,7 @@ class UploadRenderer {
|
|
|
9023
9023
|
</svg>
|
|
9024
9024
|
</div>
|
|
9025
9025
|
|
|
9026
|
-
<h2 class="svu-error-title">${
|
|
9026
|
+
<h2 class="svu-error-title">${this.escapeHtml(state.title)}</h2>
|
|
9027
9027
|
|
|
9028
9028
|
<p class="svu-error-message">${this.escapeHtml(state.message)}</p>
|
|
9029
9029
|
|
|
@@ -9283,11 +9283,23 @@ class UploadRenderer {
|
|
|
9283
9283
|
}
|
|
9284
9284
|
handleApiError(error) {
|
|
9285
9285
|
if (error instanceof UploadApiError) {
|
|
9286
|
-
|
|
9287
|
-
|
|
9286
|
+
if (error.code === 'UPLOAD_SOURCE_DISABLED') {
|
|
9287
|
+
// The vault exists but the embedded widget isn't enabled.
|
|
9288
|
+
// This is almost always a developer/admin oversight, so the message
|
|
9289
|
+
// points at the dashboard rather than the end user.
|
|
9288
9290
|
this.setState({
|
|
9289
9291
|
view: 'error',
|
|
9290
|
-
|
|
9292
|
+
title: 'Upload Widget Not Enabled',
|
|
9293
|
+
message: 'This vault has not enabled the embedded upload widget. Enable it on the vault\'s settings page in the SparkVault dashboard to start accepting uploads here.',
|
|
9294
|
+
code: 'UPLOAD_SOURCE_DISABLED',
|
|
9295
|
+
httpStatus: error.httpStatus,
|
|
9296
|
+
});
|
|
9297
|
+
}
|
|
9298
|
+
else if (error.httpStatus === 404) {
|
|
9299
|
+
this.setState({
|
|
9300
|
+
view: 'error',
|
|
9301
|
+
title: 'Upload Page Not Found',
|
|
9302
|
+
message: 'The requested upload endpoint could not be located. This may occur if the upload link has expired or was entered incorrectly.',
|
|
9291
9303
|
code: 'NOT_FOUND',
|
|
9292
9304
|
httpStatus: 404,
|
|
9293
9305
|
});
|
|
@@ -9295,6 +9307,7 @@ class UploadRenderer {
|
|
|
9295
9307
|
else if (error.httpStatus === 402) {
|
|
9296
9308
|
this.setState({
|
|
9297
9309
|
view: 'error',
|
|
9310
|
+
title: 'Service Unavailable',
|
|
9298
9311
|
message: 'This upload endpoint has been temporarily disabled due to an account billing issue. Please contact the organization\'s administrator.',
|
|
9299
9312
|
code: 'PAYMENT_REQUIRED',
|
|
9300
9313
|
httpStatus: 402,
|
|
@@ -9303,6 +9316,7 @@ class UploadRenderer {
|
|
|
9303
9316
|
else {
|
|
9304
9317
|
this.setState({
|
|
9305
9318
|
view: 'error',
|
|
9319
|
+
title: 'Upload Failed',
|
|
9306
9320
|
message: error.message,
|
|
9307
9321
|
code: error.code,
|
|
9308
9322
|
httpStatus: error.httpStatus,
|
|
@@ -9313,6 +9327,7 @@ class UploadRenderer {
|
|
|
9313
9327
|
else if (error instanceof Error) {
|
|
9314
9328
|
this.setState({
|
|
9315
9329
|
view: 'error',
|
|
9330
|
+
title: 'Upload Failed',
|
|
9316
9331
|
message: error.message,
|
|
9317
9332
|
code: 'UNKNOWN_ERROR',
|
|
9318
9333
|
});
|
|
@@ -9322,6 +9337,7 @@ class UploadRenderer {
|
|
|
9322
9337
|
const err = new Error('An unexpected error occurred');
|
|
9323
9338
|
this.setState({
|
|
9324
9339
|
view: 'error',
|
|
9340
|
+
title: 'Upload Failed',
|
|
9325
9341
|
message: err.message,
|
|
9326
9342
|
code: 'UNKNOWN_ERROR',
|
|
9327
9343
|
});
|
|
@@ -9358,7 +9374,6 @@ class VaultUploadModule {
|
|
|
9358
9374
|
this.renderer = null;
|
|
9359
9375
|
this.attachedElements = new Map();
|
|
9360
9376
|
this.config = config;
|
|
9361
|
-
this.api = new UploadApi(config);
|
|
9362
9377
|
}
|
|
9363
9378
|
/**
|
|
9364
9379
|
* Upload a file to a vault.
|
|
@@ -9393,8 +9408,12 @@ class VaultUploadModule {
|
|
|
9393
9408
|
...options,
|
|
9394
9409
|
backdropBlur: options.backdropBlur ?? this.config.backdropBlur,
|
|
9395
9410
|
};
|
|
9411
|
+
// Fresh API instance per upload session: the AbortController inside the
|
|
9412
|
+
// api is single-use, so reusing it across modal opens would make every
|
|
9413
|
+
// request after the first close throw "Request cancelled".
|
|
9414
|
+
const api = new UploadApi(this.config);
|
|
9396
9415
|
return new Promise((resolve, reject) => {
|
|
9397
|
-
this.renderer = new UploadRenderer(container,
|
|
9416
|
+
this.renderer = new UploadRenderer(container, api, mergedOptions, {
|
|
9398
9417
|
onSuccess: (result) => {
|
|
9399
9418
|
options.onSuccess?.(result);
|
|
9400
9419
|
resolve(result);
|