@sparkvault/sdk-js 11.2.0 → 11.2.2
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.cjs +19 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +18 -4
- package/dist/index.mjs +19 -8
- package/dist/index.mjs.map +1 -1
- package/dist/ingots/types.d.ts +18 -4
- package/dist/sparkvault.js +1 -1
- package/dist/sparkvault.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -31,8 +31,9 @@ function isTransientHttpStatus(status) {
|
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* The upload publication contract between Forge and Core's activation, and
|
|
34
|
-
* the facts of a transfer token both services spell: its shape,
|
|
35
|
-
*
|
|
34
|
+
* the facts of a transfer token both services spell: its shape, the
|
|
35
|
+
* publication it is bound to (a content version, and the one an ingot row
|
|
36
|
+
* names), and Core's revocation of an upload's token.
|
|
36
37
|
*
|
|
37
38
|
* Forge stamps UPLOAD_PUBLICATION_PROTOCOL on every upload session it creates
|
|
38
39
|
* and on the final state it hands Core's activation (POST
|
|
@@ -16318,10 +16319,9 @@ class IngotsModule {
|
|
|
16318
16319
|
throw new ValidationError('Provide folder or folderId, not both');
|
|
16319
16320
|
}
|
|
16320
16321
|
const name = options.name ?? getBlobName(options.file);
|
|
16321
|
-
const contentType = options.contentType ?? options.file.type ?? 'application/octet-stream';
|
|
16322
16322
|
const created = await this.requestUploadSession(vault, {
|
|
16323
16323
|
name,
|
|
16324
|
-
content_type:
|
|
16324
|
+
content_type: sentContentType(options),
|
|
16325
16325
|
size_bytes: options.file.size,
|
|
16326
16326
|
contentHmac: options.contentHmac,
|
|
16327
16327
|
folder: options.folder,
|
|
@@ -16343,10 +16343,11 @@ class IngotsModule {
|
|
|
16343
16343
|
const vaultId = requireVaultId(vault);
|
|
16344
16344
|
const id = requireResourceId(ingotId, 'ingotId');
|
|
16345
16345
|
const name = options.name ?? getBlobName(options.file);
|
|
16346
|
-
const contentType = options
|
|
16346
|
+
const contentType = sentContentType(options);
|
|
16347
16347
|
const response = await this.http.put(apiPath `/v1/vaults/${vaultId}/ingots/${id}`, {
|
|
16348
16348
|
name,
|
|
16349
|
-
|
|
16349
|
+
// Omitted, Core keeps the ingot's stored type (ReplaceIngotOptions.contentType).
|
|
16350
|
+
...(contentType !== undefined && { content_type: contentType }),
|
|
16350
16351
|
size_bytes: options.file.size,
|
|
16351
16352
|
...(options.contentHmac && { content_hmac: options.contentHmac }),
|
|
16352
16353
|
}, { vat: vault.vatToken }).catch((error) => {
|
|
@@ -16626,7 +16627,8 @@ class IngotsModule {
|
|
|
16626
16627
|
async requestUploadSession(vault, body) {
|
|
16627
16628
|
const payload = {
|
|
16628
16629
|
name: body.name,
|
|
16629
|
-
|
|
16630
|
+
// Omitted, Core types the file by its name's extension.
|
|
16631
|
+
...(body.content_type !== undefined && { content_type: body.content_type }),
|
|
16630
16632
|
size_bytes: body.size_bytes,
|
|
16631
16633
|
};
|
|
16632
16634
|
// folder_path (find-or-create) and folder_id (existing folder) are
|
|
@@ -16684,6 +16686,15 @@ function getBlobName(file) {
|
|
|
16684
16686
|
}
|
|
16685
16687
|
return 'unnamed';
|
|
16686
16688
|
}
|
|
16689
|
+
/**
|
|
16690
|
+
* The type an upload or replacement sends: the caller's, else the file's own.
|
|
16691
|
+
* A Blob of no type reports '', so such a file is sent with none, which Core
|
|
16692
|
+
* reads as a create typed by its name and a replacement that keeps the
|
|
16693
|
+
* ingot's stored type.
|
|
16694
|
+
*/
|
|
16695
|
+
function sentContentType(options) {
|
|
16696
|
+
return options.contentType ?? (options.file.type || undefined);
|
|
16697
|
+
}
|
|
16687
16698
|
function mapIngot(wire) {
|
|
16688
16699
|
return {
|
|
16689
16700
|
id: wire.ingot_id,
|
|
@@ -17420,7 +17431,7 @@ class SparkVault {
|
|
|
17420
17431
|
}
|
|
17421
17432
|
/** Get the SDK version */
|
|
17422
17433
|
static get version() {
|
|
17423
|
-
return '11.2.
|
|
17434
|
+
return '11.2.2';
|
|
17424
17435
|
}
|
|
17425
17436
|
}
|
|
17426
17437
|
if (typeof window !== 'undefined') {
|