@meistrari/vault-sdk 1.6.3 → 1.8.0
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 +747 -77
- package/dist/index.d.cts +677 -72
- package/dist/index.d.mts +677 -72
- package/dist/index.d.ts +677 -72
- package/dist/index.mjs +747 -77
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -151,6 +151,7 @@ declare class VaultFile {
|
|
|
151
151
|
* @param metadata - The metadata for creating a file
|
|
152
152
|
* @param metadata.size - The size of the file
|
|
153
153
|
* @param metadata.mimeType - The mime type of the file
|
|
154
|
+
* @param metadata.parentId - The ID of the parent file for hierarchical file relationships
|
|
154
155
|
* @param options - The options for the request
|
|
155
156
|
* @param options.signal - The signal to abort the request
|
|
156
157
|
*
|
|
@@ -212,7 +213,9 @@ declare class VaultFile {
|
|
|
212
213
|
* @param params.name - The name of the file
|
|
213
214
|
* @param params.content - The content of the file
|
|
214
215
|
* @param params.config - The configuration for the VaultFile
|
|
216
|
+
* @param params.mimeType - The MIME type of the file (optional)
|
|
215
217
|
* @param params.upload - Whether to upload the file (default: false)
|
|
218
|
+
* @param params.parentId - The ID of the parent file for hierarchical file relationships
|
|
216
219
|
* @param options - The options for the request
|
|
217
220
|
* @param options.signal - The signal to abort the request
|
|
218
221
|
*
|
|
@@ -247,12 +250,30 @@ declare class VaultFile {
|
|
|
247
250
|
* upload: true
|
|
248
251
|
* })
|
|
249
252
|
* ```
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* ```ts
|
|
256
|
+
* // Create a child file with a parent
|
|
257
|
+
* const file = new File(['content'], 'child.txt')
|
|
258
|
+
* const vaultFile = await VaultFile.fromContent({
|
|
259
|
+
* name: 'child.txt',
|
|
260
|
+
* content: file,
|
|
261
|
+
* parentId: 'parent-file-id',
|
|
262
|
+
* config: {
|
|
263
|
+
* vaultUrl,
|
|
264
|
+
* authStrategy,
|
|
265
|
+
* },
|
|
266
|
+
* upload: true
|
|
267
|
+
* })
|
|
268
|
+
* ```
|
|
250
269
|
*/
|
|
251
270
|
static fromContent(params: {
|
|
252
271
|
content: Blob | File;
|
|
253
272
|
config: VaultConfig;
|
|
254
273
|
name?: string;
|
|
274
|
+
mimeType?: string;
|
|
255
275
|
upload?: boolean;
|
|
276
|
+
parentId?: string;
|
|
256
277
|
}, options?: {
|
|
257
278
|
signal?: AbortSignal;
|
|
258
279
|
}): Promise<VaultFile>;
|
|
@@ -265,6 +286,7 @@ declare class VaultFile {
|
|
|
265
286
|
* @param params.contentLength - The size of the content in bytes
|
|
266
287
|
* @param params.config - The configuration for the VaultFile
|
|
267
288
|
* @param params.contentType - The MIME type of the content (optional)
|
|
289
|
+
* @param params.parentId - The ID of the parent file for hierarchical file relationships
|
|
268
290
|
* @param options - The options for the request
|
|
269
291
|
* @param options.signal - The signal to abort the request
|
|
270
292
|
*
|
|
@@ -287,117 +309,309 @@ declare class VaultFile {
|
|
|
287
309
|
* contentType: file.type
|
|
288
310
|
* })
|
|
289
311
|
* ```
|
|
312
|
+
*
|
|
313
|
+
* @example
|
|
314
|
+
* ```ts
|
|
315
|
+
* // Create a child file with streaming
|
|
316
|
+
* const vaultFile = await VaultFile.fromStream({
|
|
317
|
+
* name: 'child-video.mp4',
|
|
318
|
+
* contentLength: 50 * 1024 * 1024,
|
|
319
|
+
* contentType: 'video/mp4',
|
|
320
|
+
* parentId: 'parent-file-id',
|
|
321
|
+
* config: { vaultUrl, authStrategy }
|
|
322
|
+
* })
|
|
323
|
+
* ```
|
|
290
324
|
*/
|
|
291
325
|
static fromStream(params: {
|
|
292
326
|
name: string;
|
|
293
327
|
contentLength: number;
|
|
294
328
|
config: VaultConfig;
|
|
295
329
|
contentType?: string;
|
|
330
|
+
parentId?: string;
|
|
296
331
|
}, options?: {
|
|
297
332
|
signal?: AbortSignal;
|
|
298
333
|
}): Promise<VaultFile>;
|
|
299
334
|
/**
|
|
300
|
-
*
|
|
301
|
-
* @param options - The options for the request
|
|
302
|
-
* @param options.signal - The signal to abort the request
|
|
335
|
+
* Fetches and populates the metadata fields for this VaultFile instance.
|
|
303
336
|
*
|
|
304
|
-
*
|
|
337
|
+
* This method retrieves the file's metadata from the vault server and updates the instance's
|
|
338
|
+
* metadata, name, and id properties. Useful when you have a VaultFile instance that was created
|
|
339
|
+
* without full metadata or when you need to refresh the metadata.
|
|
340
|
+
*
|
|
341
|
+
* @param options - Additional options for the request
|
|
342
|
+
* @param options.signal - AbortSignal to cancel the request
|
|
343
|
+
*
|
|
344
|
+
* @returns The VaultFile instance with populated metadata (for method chaining)
|
|
305
345
|
* @throws {Error} If the file ID is not set
|
|
306
346
|
* @throws {FetchError} If the metadata fetch fails
|
|
347
|
+
*
|
|
348
|
+
* @example
|
|
349
|
+
* ```ts
|
|
350
|
+
* const vaultFile = await VaultFile.fromVaultReference({
|
|
351
|
+
* reference: 'vault://file-id',
|
|
352
|
+
* config: { vaultUrl, authStrategy }
|
|
353
|
+
* })
|
|
354
|
+
* await vaultFile.populateMetadata()
|
|
355
|
+
* console.log('File size:', vaultFile.metadata?.size)
|
|
356
|
+
* console.log('MIME type:', vaultFile.metadata?.mimeType)
|
|
357
|
+
* ```
|
|
358
|
+
*
|
|
359
|
+
* @example
|
|
360
|
+
* ```ts
|
|
361
|
+
* // Chain with other operations
|
|
362
|
+
* const file = await VaultFile.fromVaultReference({
|
|
363
|
+
* reference: 'vault://file-id',
|
|
364
|
+
* config: { vaultUrl, authStrategy }
|
|
365
|
+
* })
|
|
366
|
+
* await file.populateMetadata()
|
|
367
|
+
* const children = await file.getChildren()
|
|
368
|
+
* ```
|
|
307
369
|
*/
|
|
308
370
|
populateMetadata(options?: {
|
|
309
371
|
signal?: AbortSignal;
|
|
310
372
|
}): Promise<this | undefined>;
|
|
311
373
|
/**
|
|
312
|
-
*
|
|
374
|
+
* Returns the vault URI reference for this file.
|
|
313
375
|
*
|
|
314
|
-
*
|
|
376
|
+
* The vault reference is a URI in the format `vault://{fileId}` that can be used to
|
|
377
|
+
* uniquely identify and retrieve this file from the vault. This reference can be stored
|
|
378
|
+
* in databases, passed to other services, or used with {@link VaultFile.fromVaultReference}
|
|
379
|
+
* to reconstruct a VaultFile instance.
|
|
380
|
+
*
|
|
381
|
+
* @returns The vault reference string in the format `vault://{fileId}`
|
|
315
382
|
* @throws {Error} If the file ID is not set
|
|
383
|
+
*
|
|
384
|
+
* @example
|
|
385
|
+
* ```ts
|
|
386
|
+
* const file = await VaultFile.fromContent({
|
|
387
|
+
* name: 'document.txt',
|
|
388
|
+
* content: new Blob(['content']),
|
|
389
|
+
* config: { vaultUrl, authStrategy },
|
|
390
|
+
* upload: true
|
|
391
|
+
* })
|
|
392
|
+
* const reference = file.getVaultReference()
|
|
393
|
+
* // Returns: "vault://abc123..."
|
|
394
|
+
* // Store this reference in your database for later retrieval
|
|
395
|
+
* ```
|
|
396
|
+
*
|
|
397
|
+
* @example
|
|
398
|
+
* ```ts
|
|
399
|
+
* // Retrieve a file later using the reference
|
|
400
|
+
* const storedReference = database.get('file_reference')
|
|
401
|
+
* const file = await VaultFile.fromVaultReference({
|
|
402
|
+
* reference: storedReference,
|
|
403
|
+
* config: { vaultUrl, authStrategy }
|
|
404
|
+
* })
|
|
405
|
+
* ```
|
|
316
406
|
*/
|
|
317
407
|
getVaultReference(): string;
|
|
318
408
|
/**
|
|
319
|
-
* Fetches the metadata
|
|
320
|
-
* @param options - The options for the request
|
|
321
|
-
* @param options.signal - The signal to abort the request
|
|
409
|
+
* Fetches the complete metadata for this file from the vault server.
|
|
322
410
|
*
|
|
323
|
-
*
|
|
411
|
+
* Retrieves detailed information about the file including size, MIME type, creation date,
|
|
412
|
+
* workspace ID, and other metadata fields. Unlike {@link populateMetadata}, this method
|
|
413
|
+
* returns the metadata without modifying the VaultFile instance.
|
|
414
|
+
*
|
|
415
|
+
* @param options - Additional options for the request
|
|
416
|
+
* @param options.signal - AbortSignal to cancel the request
|
|
417
|
+
*
|
|
418
|
+
* @returns A Promise that resolves to the FileMetadata object
|
|
324
419
|
* @throws {Error} If the file ID is not set
|
|
325
420
|
* @throws {FetchError} If the metadata fetch fails
|
|
421
|
+
*
|
|
422
|
+
* @example
|
|
423
|
+
* ```ts
|
|
424
|
+
* const vaultFile = await VaultFile.fromVaultReference({
|
|
425
|
+
* reference: 'vault://file-id',
|
|
426
|
+
* config: { vaultUrl, authStrategy }
|
|
427
|
+
* })
|
|
428
|
+
* const metadata = await vaultFile.getFileMetadata()
|
|
429
|
+
* console.log('File size:', metadata.size)
|
|
430
|
+
* console.log('Created at:', metadata.createdAt)
|
|
431
|
+
* console.log('Workspace:', metadata.workspaceId)
|
|
432
|
+
* ```
|
|
433
|
+
*
|
|
434
|
+
* @example
|
|
435
|
+
* ```ts
|
|
436
|
+
* // Use with abort signal
|
|
437
|
+
* const controller = new AbortController()
|
|
438
|
+
* const metadata = await vaultFile.getFileMetadata({ signal: controller.signal })
|
|
439
|
+
* ```
|
|
326
440
|
*/
|
|
327
441
|
getFileMetadata(options?: {
|
|
328
442
|
signal?: AbortSignal;
|
|
329
443
|
}): Promise<FileMetadata>;
|
|
330
444
|
/**
|
|
331
|
-
*
|
|
332
|
-
*
|
|
333
|
-
*
|
|
334
|
-
*
|
|
445
|
+
* Retrieves a presigned upload URL for uploading file content to the vault.
|
|
446
|
+
*
|
|
447
|
+
* This method returns a temporary URL that can be used to upload the file content directly
|
|
448
|
+
* to cloud storage (e.g., S3). The URL is cached and reused if still valid. If the file
|
|
449
|
+
* doesn't exist yet, it will be created automatically.
|
|
335
450
|
*
|
|
336
|
-
* @
|
|
451
|
+
* @param options - Additional options for the request
|
|
452
|
+
* @param options.signal - AbortSignal to cancel the request
|
|
453
|
+
* @param options.expiresIn - Number of seconds the upload URL should be valid for (default: server-defined)
|
|
454
|
+
*
|
|
455
|
+
* @returns A Promise that resolves to a URL object for uploading the file
|
|
337
456
|
* @throws {Error} If the vault service returns an invalid response
|
|
338
457
|
* @throws {FetchError} If the upload URL fetch fails
|
|
458
|
+
*
|
|
459
|
+
* @example
|
|
460
|
+
* ```ts
|
|
461
|
+
* const vaultFile = await VaultFile.fromContent({
|
|
462
|
+
* name: 'document.txt',
|
|
463
|
+
* content: new Blob(['content']),
|
|
464
|
+
* config: { vaultUrl, authStrategy }
|
|
465
|
+
* })
|
|
466
|
+
* const uploadUrl = await vaultFile.getUploadUrl()
|
|
467
|
+
* // Use the URL for custom upload logic
|
|
468
|
+
* await fetch(uploadUrl, {
|
|
469
|
+
* method: 'PUT',
|
|
470
|
+
* body: file,
|
|
471
|
+
* headers: { 'Content-Type': 'text/plain' }
|
|
472
|
+
* })
|
|
473
|
+
* ```
|
|
474
|
+
*
|
|
475
|
+
* @example
|
|
476
|
+
* ```ts
|
|
477
|
+
* // Request a longer-lived upload URL
|
|
478
|
+
* const uploadUrl = await vaultFile.getUploadUrl({ expiresIn: 7200 }) // 2 hours
|
|
479
|
+
* ```
|
|
339
480
|
*/
|
|
340
481
|
getUploadUrl(options?: {
|
|
341
482
|
signal?: AbortSignal;
|
|
342
483
|
expiresIn?: number;
|
|
343
484
|
}): Promise<URL>;
|
|
344
485
|
/**
|
|
345
|
-
*
|
|
346
|
-
*
|
|
347
|
-
*
|
|
348
|
-
*
|
|
486
|
+
* Retrieves a presigned download URL for accessing the file content.
|
|
487
|
+
*
|
|
488
|
+
* This method returns a temporary URL that can be used to download the file content directly
|
|
489
|
+
* from cloud storage (e.g., S3). The URL is cached and reused if still valid. This is useful
|
|
490
|
+
* for generating shareable links or implementing custom download logic.
|
|
349
491
|
*
|
|
350
|
-
* @
|
|
492
|
+
* @param options - Additional options for the request
|
|
493
|
+
* @param options.signal - AbortSignal to cancel the request
|
|
494
|
+
* @param options.expiresIn - Number of seconds the download URL should be valid for (default: server-defined)
|
|
495
|
+
*
|
|
496
|
+
* @returns A Promise that resolves to a URL object for downloading the file
|
|
351
497
|
* @throws {Error} If the vault service returns an invalid response
|
|
352
|
-
* @throws {Error} If
|
|
498
|
+
* @throws {Error} If no file ID, name, or content is set
|
|
353
499
|
* @throws {FetchError} If the download URL fetch fails
|
|
500
|
+
*
|
|
501
|
+
* @example
|
|
502
|
+
* ```ts
|
|
503
|
+
* const vaultFile = await VaultFile.fromVaultReference({
|
|
504
|
+
* reference: 'vault://file-id',
|
|
505
|
+
* config: { vaultUrl, authStrategy }
|
|
506
|
+
* })
|
|
507
|
+
* const downloadUrl = await vaultFile.getDownloadUrl()
|
|
508
|
+
* // Use the URL to download the file
|
|
509
|
+
* window.location.href = downloadUrl.toString()
|
|
510
|
+
* ```
|
|
511
|
+
*
|
|
512
|
+
* @example
|
|
513
|
+
* ```ts
|
|
514
|
+
* // Request a longer-lived download URL
|
|
515
|
+
* const downloadUrl = await vaultFile.getDownloadUrl({ expiresIn: 3600 }) // 1 hour
|
|
516
|
+
* // Share this URL with others
|
|
517
|
+
* ```
|
|
354
518
|
*/
|
|
355
519
|
getDownloadUrl(options?: {
|
|
356
520
|
signal?: AbortSignal;
|
|
357
521
|
expiresIn?: number;
|
|
358
522
|
}): Promise<URL>;
|
|
359
523
|
/**
|
|
360
|
-
* Uploads
|
|
524
|
+
* Uploads file content to the vault using a presigned URL.
|
|
525
|
+
*
|
|
526
|
+
* This method handles the actual file upload to cloud storage. If no file is provided,
|
|
527
|
+
* it uses the content from the VaultFile instance. If no upload URL is provided, one
|
|
528
|
+
* will be fetched automatically. The MIME type is detected automatically if not already set.
|
|
529
|
+
*
|
|
530
|
+
* @param file - The Blob or File to upload. If not provided, uses the instance's content property
|
|
531
|
+
* @param url - A presigned upload URL. If not provided, will be fetched via {@link getUploadUrl}
|
|
532
|
+
* @param options - Additional options for the request
|
|
533
|
+
* @param options.signal - AbortSignal to cancel the upload
|
|
534
|
+
*
|
|
535
|
+
* @throws {Error} If no file content is available (neither provided nor in the instance)
|
|
536
|
+
* @throws {FetchError} If the upload request fails
|
|
537
|
+
* @returns A Promise that resolves when the upload completes successfully
|
|
361
538
|
*
|
|
362
539
|
* @example
|
|
363
540
|
* ```ts
|
|
541
|
+
* // Simple upload using instance content
|
|
364
542
|
* const file = new File(['content'], 'document.txt')
|
|
365
543
|
* const vaultFile = await VaultFile.fromContent({
|
|
366
544
|
* name: 'document.txt',
|
|
367
545
|
* content: file,
|
|
368
|
-
* config: {
|
|
369
|
-
* vaultUrl,
|
|
370
|
-
* authStrategy,
|
|
371
|
-
* },
|
|
546
|
+
* config: { vaultUrl, authStrategy }
|
|
372
547
|
* })
|
|
373
|
-
* await vaultFile.upload(
|
|
548
|
+
* await vaultFile.upload()
|
|
374
549
|
* ```
|
|
375
550
|
*
|
|
376
|
-
* @
|
|
377
|
-
*
|
|
378
|
-
*
|
|
379
|
-
*
|
|
551
|
+
* @example
|
|
552
|
+
* ```ts
|
|
553
|
+
* // Upload different content than what's in the instance
|
|
554
|
+
* const vaultFile = await VaultFile.fromContent({
|
|
555
|
+
* name: 'document.txt',
|
|
556
|
+
* content: new Blob(['original']),
|
|
557
|
+
* config: { vaultUrl, authStrategy }
|
|
558
|
+
* })
|
|
559
|
+
* const newContent = new Blob(['updated content'])
|
|
560
|
+
* await vaultFile.upload(newContent)
|
|
561
|
+
* ```
|
|
380
562
|
*
|
|
381
|
-
* @
|
|
382
|
-
*
|
|
383
|
-
*
|
|
563
|
+
* @example
|
|
564
|
+
* ```ts
|
|
565
|
+
* // Upload with custom URL (advanced usage)
|
|
566
|
+
* const uploadUrl = await vaultFile.getUploadUrl({ expiresIn: 3600 })
|
|
567
|
+
* await vaultFile.upload(file, uploadUrl.toString())
|
|
568
|
+
* ```
|
|
384
569
|
*/
|
|
385
570
|
upload(file?: Blob, url?: string, options?: {
|
|
386
571
|
signal?: AbortSignal;
|
|
387
572
|
}): Promise<void>;
|
|
388
573
|
/**
|
|
389
|
-
* Downloads
|
|
574
|
+
* Downloads the complete file content from the vault.
|
|
390
575
|
*
|
|
391
|
-
*
|
|
392
|
-
*
|
|
393
|
-
*
|
|
576
|
+
* This method fetches the entire file content and loads it into memory. For large files,
|
|
577
|
+
* consider using {@link downloadStream} instead for memory-efficient streaming. The method
|
|
578
|
+
* automatically handles fetching the download URL and retrieving the content.
|
|
394
579
|
*
|
|
395
|
-
* @
|
|
580
|
+
* @param responseType - The desired response format: 'blob' (default) or 'base64'
|
|
581
|
+
* @param options - Additional options for the request
|
|
582
|
+
* @param options.signal - AbortSignal to cancel the download
|
|
583
|
+
*
|
|
584
|
+
* @returns A Promise resolving to a Blob (default) or base64-encoded string
|
|
585
|
+
* @throws {FetchError} If the download fails
|
|
396
586
|
*
|
|
397
587
|
* @example
|
|
398
588
|
* ```ts
|
|
399
|
-
*
|
|
400
|
-
* const
|
|
589
|
+
* // Download as Blob (default)
|
|
590
|
+
* const vaultFile = await VaultFile.fromVaultReference({
|
|
591
|
+
* reference: 'vault://file-id',
|
|
592
|
+
* config: { vaultUrl, authStrategy }
|
|
593
|
+
* })
|
|
594
|
+
* const blob = await vaultFile.download()
|
|
595
|
+
* console.log('Downloaded:', blob.size, 'bytes')
|
|
596
|
+
* ```
|
|
597
|
+
*
|
|
598
|
+
* @example
|
|
599
|
+
* ```ts
|
|
600
|
+
* // Download as base64 string
|
|
601
|
+
* const vaultFile = await VaultFile.fromVaultReference({
|
|
602
|
+
* reference: 'vault://file-id',
|
|
603
|
+
* config: { vaultUrl, authStrategy }
|
|
604
|
+
* })
|
|
605
|
+
* const base64 = await vaultFile.download('base64')
|
|
606
|
+
* // Use in img src: `<img src="data:image/png;base64,${base64}" />`
|
|
607
|
+
* ```
|
|
608
|
+
*
|
|
609
|
+
* @example
|
|
610
|
+
* ```ts
|
|
611
|
+
* // Download with abort signal
|
|
612
|
+
* const controller = new AbortController()
|
|
613
|
+
* const blob = await vaultFile.download('blob', { signal: controller.signal })
|
|
614
|
+
* // Later: controller.abort()
|
|
401
615
|
* ```
|
|
402
616
|
*/
|
|
403
617
|
download(responseType?: 'blob', options?: {
|
|
@@ -407,62 +621,123 @@ declare class VaultFile {
|
|
|
407
621
|
signal?: AbortSignal;
|
|
408
622
|
}): Promise<string>;
|
|
409
623
|
/**
|
|
410
|
-
* Downloads
|
|
624
|
+
* Downloads the file as a ReadableStream for memory-efficient processing of large files.
|
|
411
625
|
*
|
|
412
|
-
*
|
|
413
|
-
*
|
|
626
|
+
* This method is ideal for handling large files without loading the entire content into memory.
|
|
627
|
+
* The stream can be processed chunk-by-chunk, piped to other streams, or saved incrementally.
|
|
628
|
+
* This is the recommended approach for files larger than a few megabytes.
|
|
414
629
|
*
|
|
415
|
-
* @
|
|
630
|
+
* @param options - Additional options for the request
|
|
631
|
+
* @param options.signal - AbortSignal to cancel the download
|
|
632
|
+
*
|
|
633
|
+
* @returns A Promise resolving to a ReadableStream that yields Uint8Array chunks
|
|
634
|
+
* @throws {Error} If the response body is not readable
|
|
635
|
+
* @throws {FetchError} If the download fails
|
|
416
636
|
*
|
|
417
637
|
* @example
|
|
418
638
|
* ```ts
|
|
419
|
-
*
|
|
639
|
+
* // Process large file chunk by chunk
|
|
640
|
+
* const vaultFile = await VaultFile.fromVaultReference({
|
|
641
|
+
* reference: 'vault://large-video-id',
|
|
642
|
+
* config: { vaultUrl, authStrategy }
|
|
643
|
+
* })
|
|
420
644
|
* const stream = await vaultFile.downloadStream()
|
|
421
645
|
*
|
|
422
|
-
* // Process the stream chunk by chunk
|
|
423
646
|
* const reader = stream.getReader()
|
|
647
|
+
* let bytesReceived = 0
|
|
424
648
|
* try {
|
|
425
649
|
* while (true) {
|
|
426
650
|
* const { done, value } = await reader.read()
|
|
427
651
|
* if (done) break
|
|
428
|
-
*
|
|
429
|
-
* console.log(
|
|
652
|
+
* bytesReceived += value.length
|
|
653
|
+
* console.log(`Downloaded ${bytesReceived} bytes...`)
|
|
654
|
+
* // Process chunk (value is Uint8Array)
|
|
430
655
|
* }
|
|
431
656
|
* } finally {
|
|
432
657
|
* reader.releaseLock()
|
|
433
658
|
* }
|
|
434
659
|
* ```
|
|
660
|
+
*
|
|
661
|
+
* @example
|
|
662
|
+
* ```ts
|
|
663
|
+
* // Pipe stream to a writable destination
|
|
664
|
+
* const stream = await vaultFile.downloadStream()
|
|
665
|
+
* const fileHandle = await navigator.storage.getDirectory()
|
|
666
|
+
* .then(dir => dir.getFileHandle('output.dat', { create: true }))
|
|
667
|
+
* const writable = await fileHandle.createWritable()
|
|
668
|
+
* await stream.pipeTo(writable)
|
|
669
|
+
* ```
|
|
670
|
+
*
|
|
671
|
+
* @example
|
|
672
|
+
* ```ts
|
|
673
|
+
* // Use with abort signal
|
|
674
|
+
* const controller = new AbortController()
|
|
675
|
+
* const stream = await vaultFile.downloadStream({ signal: controller.signal })
|
|
676
|
+
* // Later: controller.abort()
|
|
677
|
+
* ```
|
|
435
678
|
*/
|
|
436
679
|
downloadStream(options?: {
|
|
437
680
|
signal?: AbortSignal;
|
|
438
681
|
}): Promise<ReadableStream<Uint8Array>>;
|
|
439
682
|
/**
|
|
440
|
-
* Uploads
|
|
683
|
+
* Uploads file content using a ReadableStream for memory-efficient processing of large files.
|
|
441
684
|
*
|
|
442
|
-
*
|
|
443
|
-
*
|
|
444
|
-
*
|
|
445
|
-
* @param options.contentLength - The total size of the content (required for S3 uploads)
|
|
446
|
-
* @param options.contentType - The MIME type of the content (will be detected if not provided)
|
|
685
|
+
* This method is ideal for uploading large files without loading the entire content into memory.
|
|
686
|
+
* The stream is sent directly to cloud storage, making it perfect for files larger than a few
|
|
687
|
+
* megabytes. Note: When using Bun, the stream is buffered due to implementation limitations.
|
|
447
688
|
*
|
|
448
|
-
* @
|
|
689
|
+
* @param stream - A ReadableStream of Uint8Array chunks containing the file data
|
|
690
|
+
* @param options - Required options for the upload
|
|
691
|
+
* @param options.contentLength - The total size of the content in bytes (required for S3 uploads)
|
|
692
|
+
* @param options.contentType - The MIME type of the content (auto-detected from filename if not provided)
|
|
693
|
+
* @param options.signal - AbortSignal to cancel the upload
|
|
694
|
+
*
|
|
695
|
+
* @throws {Error} If contentLength is not provided or is negative
|
|
449
696
|
* @throws {FetchError} If the upload fails
|
|
450
|
-
* @returns Promise that resolves when upload
|
|
697
|
+
* @returns A Promise that resolves when the upload completes successfully
|
|
451
698
|
*
|
|
452
699
|
* @example
|
|
453
700
|
* ```ts
|
|
454
|
-
*
|
|
455
|
-
* const
|
|
701
|
+
* // Upload a large file using streaming
|
|
702
|
+
* const file = new File(['large content'], 'video.mp4')
|
|
703
|
+
* const vaultFile = await VaultFile.fromStream({
|
|
704
|
+
* name: 'video.mp4',
|
|
705
|
+
* contentLength: file.size,
|
|
456
706
|
* contentType: file.type,
|
|
457
707
|
* config: { vaultUrl, authStrategy }
|
|
458
708
|
* })
|
|
459
709
|
*
|
|
460
|
-
* // Upload using the stream directly
|
|
461
710
|
* const stream = file.stream()
|
|
462
711
|
* await vaultFile.uploadStream(stream, {
|
|
463
712
|
* contentLength: file.size,
|
|
464
713
|
* contentType: file.type
|
|
465
714
|
* })
|
|
715
|
+
* console.log('Upload complete!')
|
|
716
|
+
* ```
|
|
717
|
+
*
|
|
718
|
+
* @example
|
|
719
|
+
* ```ts
|
|
720
|
+
* // Upload with progress tracking
|
|
721
|
+
* const vaultFile = await VaultFile.fromStream({
|
|
722
|
+
* name: 'document.pdf',
|
|
723
|
+
* contentLength: fileSize,
|
|
724
|
+
* config: { vaultUrl, authStrategy }
|
|
725
|
+
* })
|
|
726
|
+
*
|
|
727
|
+
* // Create a transform stream to track progress
|
|
728
|
+
* let uploaded = 0
|
|
729
|
+
* const progressStream = new TransformStream({
|
|
730
|
+
* transform(chunk, controller) {
|
|
731
|
+
* uploaded += chunk.length
|
|
732
|
+
* console.log(`Uploaded ${uploaded}/${fileSize} bytes`)
|
|
733
|
+
* controller.enqueue(chunk)
|
|
734
|
+
* }
|
|
735
|
+
* })
|
|
736
|
+
*
|
|
737
|
+
* await vaultFile.uploadStream(
|
|
738
|
+
* originalStream.pipeThrough(progressStream),
|
|
739
|
+
* { contentLength: fileSize }
|
|
740
|
+
* )
|
|
466
741
|
* ```
|
|
467
742
|
*/
|
|
468
743
|
uploadStream(stream: ReadableStream<Uint8Array>, options: {
|
|
@@ -471,22 +746,98 @@ declare class VaultFile {
|
|
|
471
746
|
contentType?: string;
|
|
472
747
|
}): Promise<void>;
|
|
473
748
|
/**
|
|
474
|
-
*
|
|
475
|
-
*
|
|
476
|
-
*
|
|
749
|
+
* Permanently deletes this file from the vault.
|
|
750
|
+
*
|
|
751
|
+
* This operation removes the file metadata and content from the vault. This action cannot be
|
|
752
|
+
* undone. Any vault references or permalinks to this file will become invalid after deletion.
|
|
753
|
+
* Note: This does not automatically delete child files in hierarchical relationships.
|
|
754
|
+
*
|
|
755
|
+
* @param options - Additional options for the request
|
|
756
|
+
* @param options.signal - AbortSignal to cancel the request
|
|
757
|
+
*
|
|
758
|
+
* @throws {Error} If the file ID is not set
|
|
759
|
+
* @throws {FetchError} If the deletion request fails
|
|
760
|
+
* @returns A Promise that resolves when the deletion completes successfully
|
|
477
761
|
*
|
|
762
|
+
* @example
|
|
763
|
+
* ```ts
|
|
764
|
+
* // Delete a file
|
|
765
|
+
* const vaultFile = await VaultFile.fromVaultReference({
|
|
766
|
+
* reference: 'vault://file-id',
|
|
767
|
+
* config: { vaultUrl, authStrategy }
|
|
768
|
+
* })
|
|
769
|
+
* await vaultFile.delete()
|
|
770
|
+
* console.log('File deleted successfully')
|
|
771
|
+
* ```
|
|
772
|
+
*
|
|
773
|
+
* @example
|
|
774
|
+
* ```ts
|
|
775
|
+
* // Delete with confirmation
|
|
776
|
+
* const vaultFile = await VaultFile.fromVaultReference({
|
|
777
|
+
* reference: 'vault://file-id',
|
|
778
|
+
* config: { vaultUrl, authStrategy }
|
|
779
|
+
* })
|
|
780
|
+
* if (confirm('Are you sure you want to delete this file?')) {
|
|
781
|
+
* await vaultFile.delete()
|
|
782
|
+
* }
|
|
783
|
+
* ```
|
|
784
|
+
*
|
|
785
|
+
* @example
|
|
786
|
+
* ```ts
|
|
787
|
+
* // Delete with abort signal
|
|
788
|
+
* const controller = new AbortController()
|
|
789
|
+
* await vaultFile.delete({ signal: controller.signal })
|
|
790
|
+
* ```
|
|
478
791
|
*/
|
|
479
792
|
delete(options?: {
|
|
480
793
|
signal?: AbortSignal;
|
|
481
794
|
}): Promise<void>;
|
|
482
795
|
/**
|
|
483
|
-
* Creates a permalink for
|
|
484
|
-
*
|
|
485
|
-
*
|
|
486
|
-
*
|
|
487
|
-
*
|
|
796
|
+
* Creates a new shareable permalink for this file.
|
|
797
|
+
*
|
|
798
|
+
* A permalink is a public URL that allows anyone with the link to access the file without
|
|
799
|
+
* authentication. The permalink can optionally expire after a specified duration. This is
|
|
800
|
+
* useful for sharing files with external users or embedding files in public content.
|
|
488
801
|
*
|
|
489
|
-
* @
|
|
802
|
+
* @param params - Optional parameters for permalink creation
|
|
803
|
+
* @param params.expiresIn - Number of seconds until the permalink expires (optional, defaults to server setting)
|
|
804
|
+
* @param options - Additional options for the request
|
|
805
|
+
* @param options.signal - AbortSignal to cancel the request
|
|
806
|
+
*
|
|
807
|
+
* @throws {Error} If the file ID is not set
|
|
808
|
+
* @throws {Error} If the workspace ID is not available (call {@link populateMetadata} first)
|
|
809
|
+
* @throws {FetchError} If the permalink creation fails
|
|
810
|
+
* @returns A Promise that resolves to a Permalink instance
|
|
811
|
+
*
|
|
812
|
+
* @example
|
|
813
|
+
* ```ts
|
|
814
|
+
* // Create a permanent permalink
|
|
815
|
+
* const vaultFile = await VaultFile.fromVaultReference({
|
|
816
|
+
* reference: 'vault://file-id',
|
|
817
|
+
* config: { vaultUrl, authStrategy }
|
|
818
|
+
* })
|
|
819
|
+
* await vaultFile.populateMetadata() // Required to get workspace ID
|
|
820
|
+
* const permalink = await vaultFile.createPermalink()
|
|
821
|
+
* console.log('Share this link:', permalink.url)
|
|
822
|
+
* ```
|
|
823
|
+
*
|
|
824
|
+
* @example
|
|
825
|
+
* ```ts
|
|
826
|
+
* // Create a permalink that expires in 24 hours
|
|
827
|
+
* await vaultFile.populateMetadata()
|
|
828
|
+
* const permalink = await vaultFile.createPermalink({
|
|
829
|
+
* expiresIn: 24 * 60 * 60 // 24 hours in seconds
|
|
830
|
+
* })
|
|
831
|
+
* console.log('Link expires at:', permalink.expiresAt)
|
|
832
|
+
* ```
|
|
833
|
+
*
|
|
834
|
+
* @example
|
|
835
|
+
* ```ts
|
|
836
|
+
* // Create a short-lived sharing link (1 hour)
|
|
837
|
+
* await vaultFile.populateMetadata()
|
|
838
|
+
* const permalink = await vaultFile.createPermalink({ expiresIn: 3600 })
|
|
839
|
+
* // Send permalink.url to user
|
|
840
|
+
* ```
|
|
490
841
|
*/
|
|
491
842
|
createPermalink(params?: {
|
|
492
843
|
expiresIn?: number;
|
|
@@ -494,15 +845,259 @@ declare class VaultFile {
|
|
|
494
845
|
signal?: AbortSignal;
|
|
495
846
|
}): Promise<Permalink>;
|
|
496
847
|
/**
|
|
497
|
-
*
|
|
848
|
+
* Retrieves all active permalinks associated with this file.
|
|
849
|
+
*
|
|
850
|
+
* This method fetches all permalinks that have been created for this file and are still
|
|
851
|
+
* valid (not expired or deleted). Each permalink is returned as a Permalink instance
|
|
852
|
+
* with full details including URL, expiration date, and other metadata.
|
|
853
|
+
*
|
|
498
854
|
* @param options - Additional options for the request
|
|
499
|
-
* @param options.signal -
|
|
855
|
+
* @param options.signal - AbortSignal to cancel the request
|
|
856
|
+
*
|
|
857
|
+
* @throws {Error} If the file ID is not set
|
|
858
|
+
* @throws {FetchError} If the request to fetch permalinks fails
|
|
859
|
+
* @returns A Promise that resolves to an array of Permalink instances
|
|
860
|
+
*
|
|
861
|
+
* @example
|
|
862
|
+
* ```ts
|
|
863
|
+
* // List all permalinks for a file
|
|
864
|
+
* const vaultFile = await VaultFile.fromVaultReference({
|
|
865
|
+
* reference: 'vault://file-id',
|
|
866
|
+
* config: { vaultUrl, authStrategy }
|
|
867
|
+
* })
|
|
868
|
+
* const permalinks = await vaultFile.getPermalinks()
|
|
869
|
+
* permalinks.forEach(permalink => {
|
|
870
|
+
* console.log('URL:', permalink.url)
|
|
871
|
+
* console.log('Expires:', permalink.expiresAt || 'Never')
|
|
872
|
+
* })
|
|
873
|
+
* ```
|
|
500
874
|
*
|
|
501
|
-
* @
|
|
875
|
+
* @example
|
|
876
|
+
* ```ts
|
|
877
|
+
* // Check if any permalinks exist
|
|
878
|
+
* const permalinks = await vaultFile.getPermalinks()
|
|
879
|
+
* if (permalinks.length > 0) {
|
|
880
|
+
* console.log(`This file has ${permalinks.length} active permalink(s)`)
|
|
881
|
+
* } else {
|
|
882
|
+
* console.log('No active permalinks')
|
|
883
|
+
* }
|
|
884
|
+
* ```
|
|
885
|
+
*
|
|
886
|
+
* @example
|
|
887
|
+
* ```ts
|
|
888
|
+
* // Find non-expiring permalinks
|
|
889
|
+
* const permalinks = await vaultFile.getPermalinks()
|
|
890
|
+
* const permanent = permalinks.filter(p => !p.expiresAt)
|
|
891
|
+
* console.log(`Found ${permanent.length} permanent links`)
|
|
892
|
+
* ```
|
|
502
893
|
*/
|
|
503
894
|
getPermalinks(options?: {
|
|
504
895
|
signal?: AbortSignal;
|
|
505
896
|
}): Promise<Permalink[]>;
|
|
897
|
+
/**
|
|
898
|
+
* Retrieves all child files in the hierarchical file relationship.
|
|
899
|
+
*
|
|
900
|
+
* This method queries files that have this file set as their parent (via parentId).
|
|
901
|
+
* Returns an empty array if the file has no children or if the file doesn't exist.
|
|
902
|
+
* The returned children are VaultFile instances with populated metadata but no content.
|
|
903
|
+
*
|
|
904
|
+
* @param params - Optional parameters for filtering and request control
|
|
905
|
+
* @param params.mimeType - Filter children by MIME type (e.g., 'image/png', 'application/pdf')
|
|
906
|
+
* @param params.includeDeleted - Whether to include deleted child files (default: false)
|
|
907
|
+
* @param params.limit - Maximum number of children to return (default: 100)
|
|
908
|
+
* @param params.offset - Number of children to skip (default: 0)
|
|
909
|
+
* @param options - Additional options for the request
|
|
910
|
+
* @param options.signal - AbortSignal to cancel the request
|
|
911
|
+
*
|
|
912
|
+
* @returns An array of VaultFile instances representing the child files
|
|
913
|
+
* @throws {Error} If the file ID is not set
|
|
914
|
+
* @throws {FetchError} If the request to fetch children fails
|
|
915
|
+
*
|
|
916
|
+
* @example
|
|
917
|
+
* ```ts
|
|
918
|
+
* // Get all children of a file
|
|
919
|
+
* const parent = await VaultFile.fromVaultReference({
|
|
920
|
+
* reference: 'vault://parent-id',
|
|
921
|
+
* config: { vaultUrl, authStrategy }
|
|
922
|
+
* })
|
|
923
|
+
* const children = await parent.getChildren()
|
|
924
|
+
* console.log(`Found ${children.length} child files`)
|
|
925
|
+
* ```
|
|
926
|
+
*
|
|
927
|
+
* @example
|
|
928
|
+
* ```ts
|
|
929
|
+
* // Get only image children
|
|
930
|
+
* const parent = await VaultFile.fromVaultReference({
|
|
931
|
+
* reference: 'vault://parent-id',
|
|
932
|
+
* config: { vaultUrl, authStrategy }
|
|
933
|
+
* })
|
|
934
|
+
* const imageChildren = await parent.getChildren({ mimeType: 'image/png' })
|
|
935
|
+
* ```
|
|
936
|
+
*
|
|
937
|
+
* @example
|
|
938
|
+
* ```ts
|
|
939
|
+
* // Get children with pagination
|
|
940
|
+
* const parent = await VaultFile.fromVaultReference({
|
|
941
|
+
* reference: 'vault://parent-id',
|
|
942
|
+
* config: { vaultUrl, authStrategy }
|
|
943
|
+
* })
|
|
944
|
+
* const firstPage = await parent.getChildren({ limit: 10, offset: 0 })
|
|
945
|
+
* const secondPage = await parent.getChildren({ limit: 10, offset: 10 })
|
|
946
|
+
* ```
|
|
947
|
+
*
|
|
948
|
+
* @example
|
|
949
|
+
* ```ts
|
|
950
|
+
* // Use with abort signal for cancellable requests
|
|
951
|
+
* const controller = new AbortController()
|
|
952
|
+
* const children = await parent.getChildren({}, { signal: controller.signal })
|
|
953
|
+
* // Later: controller.abort()
|
|
954
|
+
* ```
|
|
955
|
+
*/
|
|
956
|
+
getChildren(params?: {
|
|
957
|
+
mimeType?: string;
|
|
958
|
+
includeDeleted?: boolean;
|
|
959
|
+
limit?: number;
|
|
960
|
+
offset?: number;
|
|
961
|
+
}, options?: {
|
|
962
|
+
signal?: AbortSignal;
|
|
963
|
+
}): Promise<VaultFile[]>;
|
|
964
|
+
/**
|
|
965
|
+
* Iterates through all child files with automatic pagination.
|
|
966
|
+
*
|
|
967
|
+
* This method returns an async iterator that automatically fetches pages of children
|
|
968
|
+
* as you iterate through them. This is useful when you have a large number of children
|
|
969
|
+
* and want to process them without loading all of them into memory at once.
|
|
970
|
+
*
|
|
971
|
+
* @param params - Optional parameters for filtering and pagination
|
|
972
|
+
* @param params.pageSize - Number of children to fetch per page (default: 100)
|
|
973
|
+
* @param params.mimeType - Filter children by MIME type (e.g., 'image/png', 'application/pdf')
|
|
974
|
+
* @param params.includeDeleted - Whether to include deleted child files (default: false)
|
|
975
|
+
* @param options - Additional options for the request
|
|
976
|
+
* @param options.signal - AbortSignal to cancel the iteration
|
|
977
|
+
*
|
|
978
|
+
* @returns An async iterator that yields VaultFile instances
|
|
979
|
+
* @throws {Error} If the file ID is not set
|
|
980
|
+
* @throws {FetchError} If the request to fetch children fails
|
|
981
|
+
*
|
|
982
|
+
* @example
|
|
983
|
+
* ```ts
|
|
984
|
+
* // Iterate through all children
|
|
985
|
+
* const parent = await VaultFile.fromVaultReference({
|
|
986
|
+
* reference: 'vault://parent-id',
|
|
987
|
+
* config: { vaultUrl, authStrategy }
|
|
988
|
+
* })
|
|
989
|
+
*
|
|
990
|
+
* for await (const child of parent.iterateChildren()) {
|
|
991
|
+
* console.log(`Processing child: ${child.name}`)
|
|
992
|
+
* }
|
|
993
|
+
* ```
|
|
994
|
+
*
|
|
995
|
+
* @example
|
|
996
|
+
* ```ts
|
|
997
|
+
* // Iterate with filters and custom page size
|
|
998
|
+
* for await (const child of parent.iterateChildren({
|
|
999
|
+
* pageSize: 50,
|
|
1000
|
+
* mimeType: 'image/png'
|
|
1001
|
+
* })) {
|
|
1002
|
+
* console.log(`Processing image: ${child.name}`)
|
|
1003
|
+
* }
|
|
1004
|
+
* ```
|
|
1005
|
+
*
|
|
1006
|
+
* @example
|
|
1007
|
+
* ```ts
|
|
1008
|
+
* // Use with abort signal
|
|
1009
|
+
* const controller = new AbortController()
|
|
1010
|
+
* try {
|
|
1011
|
+
* for await (const child of parent.iterateChildren({}, { signal: controller.signal })) {
|
|
1012
|
+
* console.log(child.name)
|
|
1013
|
+
* // Can abort iteration at any time
|
|
1014
|
+
* if (someCondition) {
|
|
1015
|
+
* controller.abort()
|
|
1016
|
+
* }
|
|
1017
|
+
* }
|
|
1018
|
+
* } catch (error) {
|
|
1019
|
+
* if (error.name === 'AbortError') {
|
|
1020
|
+
* console.log('Iteration cancelled')
|
|
1021
|
+
* }
|
|
1022
|
+
* }
|
|
1023
|
+
* ```
|
|
1024
|
+
*/
|
|
1025
|
+
iterateChildren(params?: {
|
|
1026
|
+
pageSize?: number;
|
|
1027
|
+
mimeType?: string;
|
|
1028
|
+
includeDeleted?: boolean;
|
|
1029
|
+
}, options?: {
|
|
1030
|
+
signal?: AbortSignal;
|
|
1031
|
+
}): AsyncIterableIterator<VaultFile>;
|
|
1032
|
+
/**
|
|
1033
|
+
* Creates a child file from content with this file as the parent.
|
|
1034
|
+
*
|
|
1035
|
+
* This is a convenience method that wraps {@link VaultFile.fromContent} and automatically
|
|
1036
|
+
* sets the current file as the parent. All parameters and behavior are identical to
|
|
1037
|
+
* {@link VaultFile.fromContent}, except parentId is automatically provided.
|
|
1038
|
+
*
|
|
1039
|
+
* @param params - Parameters for creating the child file (same as fromContent, minus parentId)
|
|
1040
|
+
* @param options - Additional options for the request
|
|
1041
|
+
*
|
|
1042
|
+
* @returns A new VaultFile instance representing the child file
|
|
1043
|
+
* @throws {Error} If the parent file ID is not set
|
|
1044
|
+
* @throws {FetchError} If the child file creation fails
|
|
1045
|
+
*
|
|
1046
|
+
* @example
|
|
1047
|
+
* ```ts
|
|
1048
|
+
* // Create a child file
|
|
1049
|
+
* const parent = await VaultFile.fromContent({
|
|
1050
|
+
* name: 'parent.txt',
|
|
1051
|
+
* content: new Blob(['parent content']),
|
|
1052
|
+
* config: { vaultUrl, authStrategy },
|
|
1053
|
+
* upload: true
|
|
1054
|
+
* })
|
|
1055
|
+
* const child = await parent.createChildFromContent({
|
|
1056
|
+
* name: 'child.txt',
|
|
1057
|
+
* content: new Blob(['child content']),
|
|
1058
|
+
* upload: true
|
|
1059
|
+
* })
|
|
1060
|
+
* console.log('Child created with parent:', child.metadata?.parentId)
|
|
1061
|
+
* ```
|
|
1062
|
+
*/
|
|
1063
|
+
createChildFromContent(params: Omit<Parameters<typeof VaultFile.fromContent>[0], 'config' | 'parentId'>, options?: Parameters<typeof VaultFile.fromContent>[1]): Promise<VaultFile>;
|
|
1064
|
+
/**
|
|
1065
|
+
* Creates a child file from a stream with this file as the parent.
|
|
1066
|
+
*
|
|
1067
|
+
* This is a convenience method that wraps {@link VaultFile.fromStream} and automatically
|
|
1068
|
+
* sets the current file as the parent. All parameters and behavior are identical to
|
|
1069
|
+
* {@link VaultFile.fromStream}, except parentId is automatically provided.
|
|
1070
|
+
*
|
|
1071
|
+
* @param params - Parameters for creating the child file (same as fromStream, minus parentId)
|
|
1072
|
+
* @param options - Additional options for the request
|
|
1073
|
+
*
|
|
1074
|
+
* @returns A new VaultFile instance ready for streaming upload as a child
|
|
1075
|
+
* @throws {Error} If the parent file ID is not set
|
|
1076
|
+
* @throws {FetchError} If the child file creation fails
|
|
1077
|
+
*
|
|
1078
|
+
* @example
|
|
1079
|
+
* ```ts
|
|
1080
|
+
* // Create a child file for streaming
|
|
1081
|
+
* const parent = await VaultFile.fromContent({
|
|
1082
|
+
* name: 'parent.txt',
|
|
1083
|
+
* content: new Blob(['parent']),
|
|
1084
|
+
* config: { vaultUrl, authStrategy },
|
|
1085
|
+
* upload: true
|
|
1086
|
+
* })
|
|
1087
|
+
* const child = await parent.createChildFromStream({
|
|
1088
|
+
* name: 'large-child.mp4',
|
|
1089
|
+
* contentLength: 100 * 1024 * 1024,
|
|
1090
|
+
* contentType: 'video/mp4'
|
|
1091
|
+
* })
|
|
1092
|
+
* // Upload the stream
|
|
1093
|
+
* const stream = file.stream()
|
|
1094
|
+
* await child.uploadStream(stream, {
|
|
1095
|
+
* contentLength: file.size,
|
|
1096
|
+
* contentType: file.type
|
|
1097
|
+
* })
|
|
1098
|
+
* ```
|
|
1099
|
+
*/
|
|
1100
|
+
createChildFromStream(params: Omit<Parameters<typeof VaultFile.fromStream>[0], 'config' | 'parentId'>, options?: Parameters<typeof VaultFile.fromStream>[1]): Promise<VaultFile>;
|
|
506
1101
|
}
|
|
507
1102
|
|
|
508
1103
|
/**
|
|
@@ -539,12 +1134,21 @@ declare function vaultClient(vaultConfig: VaultConfig): {
|
|
|
539
1134
|
createFromContent: {
|
|
540
1135
|
(name: string, content: Blob | File, options?: {
|
|
541
1136
|
signal?: AbortSignal;
|
|
1137
|
+
parentId?: string;
|
|
1138
|
+
mimeType?: string;
|
|
1139
|
+
upload?: boolean;
|
|
542
1140
|
}): Promise<VaultFile>;
|
|
543
1141
|
(content: Blob | File, name?: string, options?: {
|
|
544
1142
|
signal?: AbortSignal;
|
|
1143
|
+
parentId?: string;
|
|
1144
|
+
mimeType?: string;
|
|
1145
|
+
upload?: boolean;
|
|
545
1146
|
}): Promise<VaultFile>;
|
|
546
1147
|
(content: Blob | File, options: {
|
|
547
1148
|
signal?: AbortSignal;
|
|
1149
|
+
parentId?: string;
|
|
1150
|
+
mimeType?: string;
|
|
1151
|
+
upload?: boolean;
|
|
548
1152
|
}): Promise<VaultFile>;
|
|
549
1153
|
};
|
|
550
1154
|
createFromReference: (reference: string, options?: {
|
|
@@ -553,6 +1157,7 @@ declare function vaultClient(vaultConfig: VaultConfig): {
|
|
|
553
1157
|
createFromStream: (name: string, contentLength: number, options?: {
|
|
554
1158
|
contentType?: string;
|
|
555
1159
|
signal?: AbortSignal;
|
|
1160
|
+
parentId?: string;
|
|
556
1161
|
}) => Promise<VaultFile>;
|
|
557
1162
|
};
|
|
558
1163
|
|