@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.esm.js
CHANGED
|
@@ -932,6 +932,7 @@ class IdentityApiError extends Error {
|
|
|
932
932
|
this.name = 'IdentityApiError';
|
|
933
933
|
this.code = code;
|
|
934
934
|
this.statusCode = statusCode;
|
|
935
|
+
Object.setPrototypeOf(this, IdentityApiError.prototype);
|
|
935
936
|
}
|
|
936
937
|
}
|
|
937
938
|
|
|
@@ -6511,6 +6512,7 @@ class UploadApiError extends SparkVaultError {
|
|
|
6511
6512
|
super(message, code, httpStatus);
|
|
6512
6513
|
this.httpStatus = httpStatus;
|
|
6513
6514
|
this.name = 'UploadApiError';
|
|
6515
|
+
Object.setPrototypeOf(this, UploadApiError.prototype);
|
|
6514
6516
|
}
|
|
6515
6517
|
}
|
|
6516
6518
|
/**
|
|
@@ -9009,8 +9011,6 @@ class UploadRenderer {
|
|
|
9009
9011
|
renderError(state) {
|
|
9010
9012
|
const div = document.createElement('div');
|
|
9011
9013
|
div.className = 'svu-error-view';
|
|
9012
|
-
const statusCode = state.httpStatus || 404;
|
|
9013
|
-
const statusText = statusCode === 402 ? 'Service Unavailable' : 'Resource Not Found';
|
|
9014
9014
|
div.innerHTML = `
|
|
9015
9015
|
<div class="svu-error-icon">
|
|
9016
9016
|
<svg width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
|
|
@@ -9019,7 +9019,7 @@ class UploadRenderer {
|
|
|
9019
9019
|
</svg>
|
|
9020
9020
|
</div>
|
|
9021
9021
|
|
|
9022
|
-
<h2 class="svu-error-title">${
|
|
9022
|
+
<h2 class="svu-error-title">${this.escapeHtml(state.title)}</h2>
|
|
9023
9023
|
|
|
9024
9024
|
<p class="svu-error-message">${this.escapeHtml(state.message)}</p>
|
|
9025
9025
|
|
|
@@ -9279,11 +9279,23 @@ class UploadRenderer {
|
|
|
9279
9279
|
}
|
|
9280
9280
|
handleApiError(error) {
|
|
9281
9281
|
if (error instanceof UploadApiError) {
|
|
9282
|
-
|
|
9283
|
-
|
|
9282
|
+
if (error.code === 'UPLOAD_SOURCE_DISABLED') {
|
|
9283
|
+
// The vault exists but the embedded widget isn't enabled.
|
|
9284
|
+
// This is almost always a developer/admin oversight, so the message
|
|
9285
|
+
// points at the dashboard rather than the end user.
|
|
9284
9286
|
this.setState({
|
|
9285
9287
|
view: 'error',
|
|
9286
|
-
|
|
9288
|
+
title: 'Upload Widget Not Enabled',
|
|
9289
|
+
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.',
|
|
9290
|
+
code: 'UPLOAD_SOURCE_DISABLED',
|
|
9291
|
+
httpStatus: error.httpStatus,
|
|
9292
|
+
});
|
|
9293
|
+
}
|
|
9294
|
+
else if (error.httpStatus === 404) {
|
|
9295
|
+
this.setState({
|
|
9296
|
+
view: 'error',
|
|
9297
|
+
title: 'Upload Page Not Found',
|
|
9298
|
+
message: 'The requested upload endpoint could not be located. This may occur if the upload link has expired or was entered incorrectly.',
|
|
9287
9299
|
code: 'NOT_FOUND',
|
|
9288
9300
|
httpStatus: 404,
|
|
9289
9301
|
});
|
|
@@ -9291,6 +9303,7 @@ class UploadRenderer {
|
|
|
9291
9303
|
else if (error.httpStatus === 402) {
|
|
9292
9304
|
this.setState({
|
|
9293
9305
|
view: 'error',
|
|
9306
|
+
title: 'Service Unavailable',
|
|
9294
9307
|
message: 'This upload endpoint has been temporarily disabled due to an account billing issue. Please contact the organization\'s administrator.',
|
|
9295
9308
|
code: 'PAYMENT_REQUIRED',
|
|
9296
9309
|
httpStatus: 402,
|
|
@@ -9299,6 +9312,7 @@ class UploadRenderer {
|
|
|
9299
9312
|
else {
|
|
9300
9313
|
this.setState({
|
|
9301
9314
|
view: 'error',
|
|
9315
|
+
title: 'Upload Failed',
|
|
9302
9316
|
message: error.message,
|
|
9303
9317
|
code: error.code,
|
|
9304
9318
|
httpStatus: error.httpStatus,
|
|
@@ -9309,6 +9323,7 @@ class UploadRenderer {
|
|
|
9309
9323
|
else if (error instanceof Error) {
|
|
9310
9324
|
this.setState({
|
|
9311
9325
|
view: 'error',
|
|
9326
|
+
title: 'Upload Failed',
|
|
9312
9327
|
message: error.message,
|
|
9313
9328
|
code: 'UNKNOWN_ERROR',
|
|
9314
9329
|
});
|
|
@@ -9318,6 +9333,7 @@ class UploadRenderer {
|
|
|
9318
9333
|
const err = new Error('An unexpected error occurred');
|
|
9319
9334
|
this.setState({
|
|
9320
9335
|
view: 'error',
|
|
9336
|
+
title: 'Upload Failed',
|
|
9321
9337
|
message: err.message,
|
|
9322
9338
|
code: 'UNKNOWN_ERROR',
|
|
9323
9339
|
});
|
|
@@ -9354,7 +9370,6 @@ class VaultUploadModule {
|
|
|
9354
9370
|
this.renderer = null;
|
|
9355
9371
|
this.attachedElements = new Map();
|
|
9356
9372
|
this.config = config;
|
|
9357
|
-
this.api = new UploadApi(config);
|
|
9358
9373
|
}
|
|
9359
9374
|
/**
|
|
9360
9375
|
* Upload a file to a vault.
|
|
@@ -9389,8 +9404,12 @@ class VaultUploadModule {
|
|
|
9389
9404
|
...options,
|
|
9390
9405
|
backdropBlur: options.backdropBlur ?? this.config.backdropBlur,
|
|
9391
9406
|
};
|
|
9407
|
+
// Fresh API instance per upload session: the AbortController inside the
|
|
9408
|
+
// api is single-use, so reusing it across modal opens would make every
|
|
9409
|
+
// request after the first close throw "Request cancelled".
|
|
9410
|
+
const api = new UploadApi(this.config);
|
|
9392
9411
|
return new Promise((resolve, reject) => {
|
|
9393
|
-
this.renderer = new UploadRenderer(container,
|
|
9412
|
+
this.renderer = new UploadRenderer(container, api, mergedOptions, {
|
|
9394
9413
|
onSuccess: (result) => {
|
|
9395
9414
|
options.onSuccess?.(result);
|
|
9396
9415
|
resolve(result);
|