@meistrari/vault-sdk 1.8.3 → 1.9.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 +18 -5
- package/dist/index.d.cts +6 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.mjs +18 -5
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -237,7 +237,7 @@ function getFileName(content) {
|
|
|
237
237
|
}
|
|
238
238
|
|
|
239
239
|
const name = "@meistrari/vault-sdk";
|
|
240
|
-
const version = "1.
|
|
240
|
+
const version = "1.9.0";
|
|
241
241
|
const license = "UNLICENSED";
|
|
242
242
|
const repository = {
|
|
243
243
|
type: "git",
|
|
@@ -417,6 +417,7 @@ class VaultFile {
|
|
|
417
417
|
* @param metadata.mimeType - The mime type of the file
|
|
418
418
|
* @param metadata.parentId - The ID of the parent file for hierarchical file relationships
|
|
419
419
|
* @param metadata.onMissingParent - What to do if the parent file does not exist or has been deleted
|
|
420
|
+
* @param metadata.onParentConflict - What to do if the file already exists as an active child of another file
|
|
420
421
|
* @param options - The options for the request
|
|
421
422
|
* @param options.signal - The signal to abort the request
|
|
422
423
|
*
|
|
@@ -433,6 +434,7 @@ class VaultFile {
|
|
|
433
434
|
mimeType: metadata.mimeType,
|
|
434
435
|
parentId: metadata.parentId,
|
|
435
436
|
onMissingParent: metadata.onMissingParent,
|
|
437
|
+
onParentConflict: metadata.onParentConflict,
|
|
436
438
|
fileName: this.name,
|
|
437
439
|
sha256sum: this.id ?? this.metadata?.id ?? (this.content ? await getFileHash(this.content) : void 0)
|
|
438
440
|
}),
|
|
@@ -524,6 +526,7 @@ class VaultFile {
|
|
|
524
526
|
* @param params.upload - Whether to upload the file (default: false)
|
|
525
527
|
* @param params.parentId - The ID of the parent file for hierarchical file relationships
|
|
526
528
|
* @param params.onMissingParent - What to do if the parent file does not exist or has been deleted
|
|
529
|
+
* @param params.onParentConflict - What to do if the file already exists as an active child of another file
|
|
527
530
|
* @param options - The options for the request
|
|
528
531
|
* @param options.signal - The signal to abort the request
|
|
529
532
|
*
|
|
@@ -576,7 +579,7 @@ class VaultFile {
|
|
|
576
579
|
* ```
|
|
577
580
|
*/
|
|
578
581
|
static async fromContent(params, options) {
|
|
579
|
-
const { content, config: vaultConfig, upload = false, parentId, onMissingParent } = params;
|
|
582
|
+
const { content, config: vaultConfig, upload = false, parentId, onMissingParent, onParentConflict } = params;
|
|
580
583
|
const name = basename(params.name) ?? getFileName(content);
|
|
581
584
|
const config = resolveConfig(vaultConfig);
|
|
582
585
|
const { vaultUrl, authStrategy } = config;
|
|
@@ -596,7 +599,8 @@ class VaultFile {
|
|
|
596
599
|
size,
|
|
597
600
|
mimeType,
|
|
598
601
|
parentId,
|
|
599
|
-
onMissingParent
|
|
602
|
+
onMissingParent,
|
|
603
|
+
onParentConflict
|
|
600
604
|
}, { signal: options?.signal });
|
|
601
605
|
if (upload) {
|
|
602
606
|
await file.upload(file.content, createdFile.uploadUrl, { signal: options?.signal });
|
|
@@ -614,6 +618,7 @@ class VaultFile {
|
|
|
614
618
|
* @param params.contentType - The MIME type of the content (optional)
|
|
615
619
|
* @param params.parentId - The ID of the parent file for hierarchical file relationships
|
|
616
620
|
* @param params.onMissingParent - What to do if the parent file does not exist or has been deleted
|
|
621
|
+
* @param params.onParentConflict - What to do if the file already exists as an active child of another file
|
|
617
622
|
* @param options - The options for the request
|
|
618
623
|
* @param options.signal - The signal to abort the request
|
|
619
624
|
*
|
|
@@ -650,7 +655,14 @@ class VaultFile {
|
|
|
650
655
|
* ```
|
|
651
656
|
*/
|
|
652
657
|
static async fromStream(params, options) {
|
|
653
|
-
const {
|
|
658
|
+
const {
|
|
659
|
+
contentLength,
|
|
660
|
+
config: vaultConfig,
|
|
661
|
+
contentType,
|
|
662
|
+
parentId,
|
|
663
|
+
onMissingParent,
|
|
664
|
+
onParentConflict
|
|
665
|
+
} = params;
|
|
654
666
|
const name = basename(params.name);
|
|
655
667
|
const config = resolveConfig(vaultConfig);
|
|
656
668
|
const file = new VaultFile({ config, name });
|
|
@@ -658,7 +670,8 @@ class VaultFile {
|
|
|
658
670
|
size: contentLength,
|
|
659
671
|
mimeType: contentType || "application/octet-stream",
|
|
660
672
|
parentId,
|
|
661
|
-
onMissingParent
|
|
673
|
+
onMissingParent,
|
|
674
|
+
onParentConflict
|
|
662
675
|
}, { signal: options?.signal });
|
|
663
676
|
return file;
|
|
664
677
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -88,6 +88,7 @@ type VaultFileParams = {
|
|
|
88
88
|
config: VaultConfig;
|
|
89
89
|
};
|
|
90
90
|
type OnMissingParent = 'error' | 'create-as-root';
|
|
91
|
+
type OnParentConflict = 'error' | 'update-parent-id' | 'ignore';
|
|
91
92
|
/**
|
|
92
93
|
* Represents a file in the vault and allows interacting with it.
|
|
93
94
|
*
|
|
@@ -154,6 +155,7 @@ declare class VaultFile {
|
|
|
154
155
|
* @param metadata.mimeType - The mime type of the file
|
|
155
156
|
* @param metadata.parentId - The ID of the parent file for hierarchical file relationships
|
|
156
157
|
* @param metadata.onMissingParent - What to do if the parent file does not exist or has been deleted
|
|
158
|
+
* @param metadata.onParentConflict - What to do if the file already exists as an active child of another file
|
|
157
159
|
* @param options - The options for the request
|
|
158
160
|
* @param options.signal - The signal to abort the request
|
|
159
161
|
*
|
|
@@ -219,6 +221,7 @@ declare class VaultFile {
|
|
|
219
221
|
* @param params.upload - Whether to upload the file (default: false)
|
|
220
222
|
* @param params.parentId - The ID of the parent file for hierarchical file relationships
|
|
221
223
|
* @param params.onMissingParent - What to do if the parent file does not exist or has been deleted
|
|
224
|
+
* @param params.onParentConflict - What to do if the file already exists as an active child of another file
|
|
222
225
|
* @param options - The options for the request
|
|
223
226
|
* @param options.signal - The signal to abort the request
|
|
224
227
|
*
|
|
@@ -278,6 +281,7 @@ declare class VaultFile {
|
|
|
278
281
|
upload?: boolean;
|
|
279
282
|
parentId?: string;
|
|
280
283
|
onMissingParent?: OnMissingParent;
|
|
284
|
+
onParentConflict?: OnParentConflict;
|
|
281
285
|
}, options?: {
|
|
282
286
|
signal?: AbortSignal;
|
|
283
287
|
}): Promise<VaultFile>;
|
|
@@ -292,6 +296,7 @@ declare class VaultFile {
|
|
|
292
296
|
* @param params.contentType - The MIME type of the content (optional)
|
|
293
297
|
* @param params.parentId - The ID of the parent file for hierarchical file relationships
|
|
294
298
|
* @param params.onMissingParent - What to do if the parent file does not exist or has been deleted
|
|
299
|
+
* @param params.onParentConflict - What to do if the file already exists as an active child of another file
|
|
295
300
|
* @param options - The options for the request
|
|
296
301
|
* @param options.signal - The signal to abort the request
|
|
297
302
|
*
|
|
@@ -334,6 +339,7 @@ declare class VaultFile {
|
|
|
334
339
|
contentType?: string;
|
|
335
340
|
parentId?: string;
|
|
336
341
|
onMissingParent?: OnMissingParent;
|
|
342
|
+
onParentConflict?: OnParentConflict;
|
|
337
343
|
}, options?: {
|
|
338
344
|
signal?: AbortSignal;
|
|
339
345
|
}): Promise<VaultFile>;
|
package/dist/index.d.mts
CHANGED
|
@@ -88,6 +88,7 @@ type VaultFileParams = {
|
|
|
88
88
|
config: VaultConfig;
|
|
89
89
|
};
|
|
90
90
|
type OnMissingParent = 'error' | 'create-as-root';
|
|
91
|
+
type OnParentConflict = 'error' | 'update-parent-id' | 'ignore';
|
|
91
92
|
/**
|
|
92
93
|
* Represents a file in the vault and allows interacting with it.
|
|
93
94
|
*
|
|
@@ -154,6 +155,7 @@ declare class VaultFile {
|
|
|
154
155
|
* @param metadata.mimeType - The mime type of the file
|
|
155
156
|
* @param metadata.parentId - The ID of the parent file for hierarchical file relationships
|
|
156
157
|
* @param metadata.onMissingParent - What to do if the parent file does not exist or has been deleted
|
|
158
|
+
* @param metadata.onParentConflict - What to do if the file already exists as an active child of another file
|
|
157
159
|
* @param options - The options for the request
|
|
158
160
|
* @param options.signal - The signal to abort the request
|
|
159
161
|
*
|
|
@@ -219,6 +221,7 @@ declare class VaultFile {
|
|
|
219
221
|
* @param params.upload - Whether to upload the file (default: false)
|
|
220
222
|
* @param params.parentId - The ID of the parent file for hierarchical file relationships
|
|
221
223
|
* @param params.onMissingParent - What to do if the parent file does not exist or has been deleted
|
|
224
|
+
* @param params.onParentConflict - What to do if the file already exists as an active child of another file
|
|
222
225
|
* @param options - The options for the request
|
|
223
226
|
* @param options.signal - The signal to abort the request
|
|
224
227
|
*
|
|
@@ -278,6 +281,7 @@ declare class VaultFile {
|
|
|
278
281
|
upload?: boolean;
|
|
279
282
|
parentId?: string;
|
|
280
283
|
onMissingParent?: OnMissingParent;
|
|
284
|
+
onParentConflict?: OnParentConflict;
|
|
281
285
|
}, options?: {
|
|
282
286
|
signal?: AbortSignal;
|
|
283
287
|
}): Promise<VaultFile>;
|
|
@@ -292,6 +296,7 @@ declare class VaultFile {
|
|
|
292
296
|
* @param params.contentType - The MIME type of the content (optional)
|
|
293
297
|
* @param params.parentId - The ID of the parent file for hierarchical file relationships
|
|
294
298
|
* @param params.onMissingParent - What to do if the parent file does not exist or has been deleted
|
|
299
|
+
* @param params.onParentConflict - What to do if the file already exists as an active child of another file
|
|
295
300
|
* @param options - The options for the request
|
|
296
301
|
* @param options.signal - The signal to abort the request
|
|
297
302
|
*
|
|
@@ -334,6 +339,7 @@ declare class VaultFile {
|
|
|
334
339
|
contentType?: string;
|
|
335
340
|
parentId?: string;
|
|
336
341
|
onMissingParent?: OnMissingParent;
|
|
342
|
+
onParentConflict?: OnParentConflict;
|
|
337
343
|
}, options?: {
|
|
338
344
|
signal?: AbortSignal;
|
|
339
345
|
}): Promise<VaultFile>;
|
package/dist/index.d.ts
CHANGED
|
@@ -88,6 +88,7 @@ type VaultFileParams = {
|
|
|
88
88
|
config: VaultConfig;
|
|
89
89
|
};
|
|
90
90
|
type OnMissingParent = 'error' | 'create-as-root';
|
|
91
|
+
type OnParentConflict = 'error' | 'update-parent-id' | 'ignore';
|
|
91
92
|
/**
|
|
92
93
|
* Represents a file in the vault and allows interacting with it.
|
|
93
94
|
*
|
|
@@ -154,6 +155,7 @@ declare class VaultFile {
|
|
|
154
155
|
* @param metadata.mimeType - The mime type of the file
|
|
155
156
|
* @param metadata.parentId - The ID of the parent file for hierarchical file relationships
|
|
156
157
|
* @param metadata.onMissingParent - What to do if the parent file does not exist or has been deleted
|
|
158
|
+
* @param metadata.onParentConflict - What to do if the file already exists as an active child of another file
|
|
157
159
|
* @param options - The options for the request
|
|
158
160
|
* @param options.signal - The signal to abort the request
|
|
159
161
|
*
|
|
@@ -219,6 +221,7 @@ declare class VaultFile {
|
|
|
219
221
|
* @param params.upload - Whether to upload the file (default: false)
|
|
220
222
|
* @param params.parentId - The ID of the parent file for hierarchical file relationships
|
|
221
223
|
* @param params.onMissingParent - What to do if the parent file does not exist or has been deleted
|
|
224
|
+
* @param params.onParentConflict - What to do if the file already exists as an active child of another file
|
|
222
225
|
* @param options - The options for the request
|
|
223
226
|
* @param options.signal - The signal to abort the request
|
|
224
227
|
*
|
|
@@ -278,6 +281,7 @@ declare class VaultFile {
|
|
|
278
281
|
upload?: boolean;
|
|
279
282
|
parentId?: string;
|
|
280
283
|
onMissingParent?: OnMissingParent;
|
|
284
|
+
onParentConflict?: OnParentConflict;
|
|
281
285
|
}, options?: {
|
|
282
286
|
signal?: AbortSignal;
|
|
283
287
|
}): Promise<VaultFile>;
|
|
@@ -292,6 +296,7 @@ declare class VaultFile {
|
|
|
292
296
|
* @param params.contentType - The MIME type of the content (optional)
|
|
293
297
|
* @param params.parentId - The ID of the parent file for hierarchical file relationships
|
|
294
298
|
* @param params.onMissingParent - What to do if the parent file does not exist or has been deleted
|
|
299
|
+
* @param params.onParentConflict - What to do if the file already exists as an active child of another file
|
|
295
300
|
* @param options - The options for the request
|
|
296
301
|
* @param options.signal - The signal to abort the request
|
|
297
302
|
*
|
|
@@ -334,6 +339,7 @@ declare class VaultFile {
|
|
|
334
339
|
contentType?: string;
|
|
335
340
|
parentId?: string;
|
|
336
341
|
onMissingParent?: OnMissingParent;
|
|
342
|
+
onParentConflict?: OnParentConflict;
|
|
337
343
|
}, options?: {
|
|
338
344
|
signal?: AbortSignal;
|
|
339
345
|
}): Promise<VaultFile>;
|
package/dist/index.mjs
CHANGED
|
@@ -231,7 +231,7 @@ function getFileName(content) {
|
|
|
231
231
|
}
|
|
232
232
|
|
|
233
233
|
const name = "@meistrari/vault-sdk";
|
|
234
|
-
const version = "1.
|
|
234
|
+
const version = "1.9.0";
|
|
235
235
|
const license = "UNLICENSED";
|
|
236
236
|
const repository = {
|
|
237
237
|
type: "git",
|
|
@@ -411,6 +411,7 @@ class VaultFile {
|
|
|
411
411
|
* @param metadata.mimeType - The mime type of the file
|
|
412
412
|
* @param metadata.parentId - The ID of the parent file for hierarchical file relationships
|
|
413
413
|
* @param metadata.onMissingParent - What to do if the parent file does not exist or has been deleted
|
|
414
|
+
* @param metadata.onParentConflict - What to do if the file already exists as an active child of another file
|
|
414
415
|
* @param options - The options for the request
|
|
415
416
|
* @param options.signal - The signal to abort the request
|
|
416
417
|
*
|
|
@@ -427,6 +428,7 @@ class VaultFile {
|
|
|
427
428
|
mimeType: metadata.mimeType,
|
|
428
429
|
parentId: metadata.parentId,
|
|
429
430
|
onMissingParent: metadata.onMissingParent,
|
|
431
|
+
onParentConflict: metadata.onParentConflict,
|
|
430
432
|
fileName: this.name,
|
|
431
433
|
sha256sum: this.id ?? this.metadata?.id ?? (this.content ? await getFileHash(this.content) : void 0)
|
|
432
434
|
}),
|
|
@@ -518,6 +520,7 @@ class VaultFile {
|
|
|
518
520
|
* @param params.upload - Whether to upload the file (default: false)
|
|
519
521
|
* @param params.parentId - The ID of the parent file for hierarchical file relationships
|
|
520
522
|
* @param params.onMissingParent - What to do if the parent file does not exist or has been deleted
|
|
523
|
+
* @param params.onParentConflict - What to do if the file already exists as an active child of another file
|
|
521
524
|
* @param options - The options for the request
|
|
522
525
|
* @param options.signal - The signal to abort the request
|
|
523
526
|
*
|
|
@@ -570,7 +573,7 @@ class VaultFile {
|
|
|
570
573
|
* ```
|
|
571
574
|
*/
|
|
572
575
|
static async fromContent(params, options) {
|
|
573
|
-
const { content, config: vaultConfig, upload = false, parentId, onMissingParent } = params;
|
|
576
|
+
const { content, config: vaultConfig, upload = false, parentId, onMissingParent, onParentConflict } = params;
|
|
574
577
|
const name = basename(params.name) ?? getFileName(content);
|
|
575
578
|
const config = resolveConfig(vaultConfig);
|
|
576
579
|
const { vaultUrl, authStrategy } = config;
|
|
@@ -590,7 +593,8 @@ class VaultFile {
|
|
|
590
593
|
size,
|
|
591
594
|
mimeType,
|
|
592
595
|
parentId,
|
|
593
|
-
onMissingParent
|
|
596
|
+
onMissingParent,
|
|
597
|
+
onParentConflict
|
|
594
598
|
}, { signal: options?.signal });
|
|
595
599
|
if (upload) {
|
|
596
600
|
await file.upload(file.content, createdFile.uploadUrl, { signal: options?.signal });
|
|
@@ -608,6 +612,7 @@ class VaultFile {
|
|
|
608
612
|
* @param params.contentType - The MIME type of the content (optional)
|
|
609
613
|
* @param params.parentId - The ID of the parent file for hierarchical file relationships
|
|
610
614
|
* @param params.onMissingParent - What to do if the parent file does not exist or has been deleted
|
|
615
|
+
* @param params.onParentConflict - What to do if the file already exists as an active child of another file
|
|
611
616
|
* @param options - The options for the request
|
|
612
617
|
* @param options.signal - The signal to abort the request
|
|
613
618
|
*
|
|
@@ -644,7 +649,14 @@ class VaultFile {
|
|
|
644
649
|
* ```
|
|
645
650
|
*/
|
|
646
651
|
static async fromStream(params, options) {
|
|
647
|
-
const {
|
|
652
|
+
const {
|
|
653
|
+
contentLength,
|
|
654
|
+
config: vaultConfig,
|
|
655
|
+
contentType,
|
|
656
|
+
parentId,
|
|
657
|
+
onMissingParent,
|
|
658
|
+
onParentConflict
|
|
659
|
+
} = params;
|
|
648
660
|
const name = basename(params.name);
|
|
649
661
|
const config = resolveConfig(vaultConfig);
|
|
650
662
|
const file = new VaultFile({ config, name });
|
|
@@ -652,7 +664,8 @@ class VaultFile {
|
|
|
652
664
|
size: contentLength,
|
|
653
665
|
mimeType: contentType || "application/octet-stream",
|
|
654
666
|
parentId,
|
|
655
|
-
onMissingParent
|
|
667
|
+
onMissingParent,
|
|
668
|
+
onParentConflict
|
|
656
669
|
}, { signal: options?.signal });
|
|
657
670
|
return file;
|
|
658
671
|
}
|