@sparkvault/sdk-js 11.2.0 → 11.2.1
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 +16 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +18 -4
- package/dist/index.mjs +16 -6
- 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.d.ts
CHANGED
|
@@ -2370,7 +2370,11 @@ interface UploadIngotOptions {
|
|
|
2370
2370
|
file: File | Blob;
|
|
2371
2371
|
/** Optional name (defaults to file name) */
|
|
2372
2372
|
name?: string;
|
|
2373
|
-
/**
|
|
2373
|
+
/**
|
|
2374
|
+
* Content type (the file's own `type` if not provided). A file of no type is
|
|
2375
|
+
* sent with none, and Core stores the type the registry lists for the name's
|
|
2376
|
+
* extension, else `application/octet-stream`.
|
|
2377
|
+
*/
|
|
2374
2378
|
contentType?: string;
|
|
2375
2379
|
/** Slash-delimited folder path (find-or-created from root). */
|
|
2376
2380
|
folder?: string;
|
|
@@ -2418,7 +2422,11 @@ interface ReplaceIngotOptions {
|
|
|
2418
2422
|
name?: string;
|
|
2419
2423
|
/** Vault-keyed plaintext HMAC (43-char base64url) for the NEW content. */
|
|
2420
2424
|
contentHmac?: string;
|
|
2421
|
-
/**
|
|
2425
|
+
/**
|
|
2426
|
+
* Content type (the file's own `type` if not provided). A file of no type
|
|
2427
|
+
* keeps the type the ingot stores, which Core reads from the name by its
|
|
2428
|
+
* extension only when it is `application/octet-stream` or unparsable.
|
|
2429
|
+
*/
|
|
2422
2430
|
contentType?: string;
|
|
2423
2431
|
/** Progress callback for the Forge/TUS transfer */
|
|
2424
2432
|
onProgress?: (bytesUploaded: number, bytesTotal: number) => void;
|
|
@@ -2464,9 +2472,15 @@ interface FolderContents {
|
|
|
2464
2472
|
}
|
|
2465
2473
|
/** Options for search. */
|
|
2466
2474
|
interface SearchIngotsOptions {
|
|
2467
|
-
/**
|
|
2475
|
+
/** The beginning of the ingot's name, in any case: a prefix, never a substring or a fuzzy match. */
|
|
2468
2476
|
q?: string;
|
|
2469
|
-
/**
|
|
2477
|
+
/**
|
|
2478
|
+
* The MIME type to match, in lowercase: a family (`image`, `video`,
|
|
2479
|
+
* `audio`, `text`, `application`, ...), which every type under it matches,
|
|
2480
|
+
* or an exact type (`application/pdf`), which matches that type whatever
|
|
2481
|
+
* its parameters. A well-formed value no ingot carries matches none; the
|
|
2482
|
+
* server refuses a value that is neither.
|
|
2483
|
+
*/
|
|
2470
2484
|
fileType?: string;
|
|
2471
2485
|
/** Scope the search to one folder (whole vault when omitted) */
|
|
2472
2486
|
folderId?: string;
|
package/dist/index.mjs
CHANGED
|
@@ -16314,10 +16314,9 @@ class IngotsModule {
|
|
|
16314
16314
|
throw new ValidationError('Provide folder or folderId, not both');
|
|
16315
16315
|
}
|
|
16316
16316
|
const name = options.name ?? getBlobName(options.file);
|
|
16317
|
-
const contentType = options.contentType ?? options.file.type ?? 'application/octet-stream';
|
|
16318
16317
|
const created = await this.requestUploadSession(vault, {
|
|
16319
16318
|
name,
|
|
16320
|
-
content_type:
|
|
16319
|
+
content_type: sentContentType(options),
|
|
16321
16320
|
size_bytes: options.file.size,
|
|
16322
16321
|
contentHmac: options.contentHmac,
|
|
16323
16322
|
folder: options.folder,
|
|
@@ -16339,10 +16338,11 @@ class IngotsModule {
|
|
|
16339
16338
|
const vaultId = requireVaultId(vault);
|
|
16340
16339
|
const id = requireResourceId(ingotId, 'ingotId');
|
|
16341
16340
|
const name = options.name ?? getBlobName(options.file);
|
|
16342
|
-
const contentType = options
|
|
16341
|
+
const contentType = sentContentType(options);
|
|
16343
16342
|
const response = await this.http.put(apiPath `/v1/vaults/${vaultId}/ingots/${id}`, {
|
|
16344
16343
|
name,
|
|
16345
|
-
|
|
16344
|
+
// Omitted, Core keeps the ingot's stored type (ReplaceIngotOptions.contentType).
|
|
16345
|
+
...(contentType !== undefined && { content_type: contentType }),
|
|
16346
16346
|
size_bytes: options.file.size,
|
|
16347
16347
|
...(options.contentHmac && { content_hmac: options.contentHmac }),
|
|
16348
16348
|
}, { vat: vault.vatToken }).catch((error) => {
|
|
@@ -16622,7 +16622,8 @@ class IngotsModule {
|
|
|
16622
16622
|
async requestUploadSession(vault, body) {
|
|
16623
16623
|
const payload = {
|
|
16624
16624
|
name: body.name,
|
|
16625
|
-
|
|
16625
|
+
// Omitted, Core types the file by its name's extension.
|
|
16626
|
+
...(body.content_type !== undefined && { content_type: body.content_type }),
|
|
16626
16627
|
size_bytes: body.size_bytes,
|
|
16627
16628
|
};
|
|
16628
16629
|
// folder_path (find-or-create) and folder_id (existing folder) are
|
|
@@ -16680,6 +16681,15 @@ function getBlobName(file) {
|
|
|
16680
16681
|
}
|
|
16681
16682
|
return 'unnamed';
|
|
16682
16683
|
}
|
|
16684
|
+
/**
|
|
16685
|
+
* The type an upload or replacement sends: the caller's, else the file's own.
|
|
16686
|
+
* A Blob of no type reports '', so such a file is sent with none, which Core
|
|
16687
|
+
* reads as a create typed by its name and a replacement that keeps the
|
|
16688
|
+
* ingot's stored type.
|
|
16689
|
+
*/
|
|
16690
|
+
function sentContentType(options) {
|
|
16691
|
+
return options.contentType ?? (options.file.type || undefined);
|
|
16692
|
+
}
|
|
16683
16693
|
function mapIngot(wire) {
|
|
16684
16694
|
return {
|
|
16685
16695
|
id: wire.ingot_id,
|
|
@@ -17416,7 +17426,7 @@ class SparkVault {
|
|
|
17416
17426
|
}
|
|
17417
17427
|
/** Get the SDK version */
|
|
17418
17428
|
static get version() {
|
|
17419
|
-
return '11.2.
|
|
17429
|
+
return '11.2.1';
|
|
17420
17430
|
}
|
|
17421
17431
|
}
|
|
17422
17432
|
if (typeof window !== 'undefined') {
|