@meistrari/vault-sdk 1.6.0 → 1.6.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/README.md CHANGED
@@ -19,8 +19,8 @@ To create a new file in the vault, use `VaultFile.fromContent`:
19
19
 
20
20
  ```ts
21
21
  const vaultFile = await VaultFile.fromContent({
22
- name: 'document.txt', // Original filename
23
22
  content: new File(['content'], 'document.txt'), // File content
23
+ name: 'document.txt', // Optional: original filename
24
24
  config: {
25
25
  vaultUrl,
26
26
  authStrategy: new DataTokenAuthStrategy(dataToken)
@@ -63,8 +63,8 @@ const vaultUrl = Bun.env.VAULT_URL ?? 'https://vault.tela.com'
63
63
  // Step 1: Create and upload a new file
64
64
  const fileContent = Bun.file('path/to/local/file.txt')
65
65
  const vaultFile = await VaultFile.fromContent({
66
- name: 'file.txt',
67
66
  content: fileContent,
67
+ name: 'file.txt', // Optional: original filename
68
68
  config: {
69
69
  vaultUrl,
70
70
  authStrategy: new DataTokenAuthStrategy(dataToken)
@@ -121,7 +121,7 @@ const fileFromReference = vault.createFromReference('vault://1234567890')
121
121
 
122
122
  The `useVault` helper provides two methods:
123
123
 
124
- - `createFromContent(name, content)`: Creates a new `VaultFile` instance from a name and content (Blob or File)
124
+ - `createFromContent(content, name?)`: Creates a new `VaultFile` instance from content (Blob or File) and an optional name
125
125
  - `createFromReference(reference)`: Creates a new `VaultFile` instance from a vault reference string
126
126
 
127
127
  This helper makes it more convenient to work with multiple vault files using the same configuration.
package/dist/index.cjs CHANGED
@@ -221,7 +221,7 @@ async function detectFileMimeType(blob) {
221
221
  }
222
222
 
223
223
  const name = "@meistrari/vault-sdk";
224
- const version = "1.6.0";
224
+ const version = "1.6.1";
225
225
  const license = "UNLICENSED";
226
226
  const repository = {
227
227
  type: "git",
@@ -986,12 +986,20 @@ function convertS3UrlToVaultReference(url) {
986
986
 
987
987
  function vaultClient(vaultConfig) {
988
988
  const config = resolveConfig(vaultConfig);
989
- function createFromContent(name, content, options) {
990
- return VaultFile.fromContent({
991
- name,
992
- content,
993
- config
994
- }, { signal: options?.signal });
989
+ function createFromContent(nameOrContent, contentOrNameOrOptions, options) {
990
+ const isOptionsObject = (value) => {
991
+ return typeof value === "object" && value !== null && !(value instanceof Blob) && !(value instanceof File);
992
+ };
993
+ if (typeof nameOrContent === "string") {
994
+ const name2 = nameOrContent;
995
+ const content2 = contentOrNameOrOptions;
996
+ const signal2 = options?.signal;
997
+ return VaultFile.fromContent({ content: content2, name: name2, config }, { signal: signal2 });
998
+ }
999
+ const content = nameOrContent;
1000
+ const name = typeof contentOrNameOrOptions === "string" ? contentOrNameOrOptions : void 0;
1001
+ const signal = isOptionsObject(contentOrNameOrOptions) ? contentOrNameOrOptions.signal : options?.signal;
1002
+ return VaultFile.fromContent({ content, name, config }, { signal });
995
1003
  }
996
1004
  function createFromReference(reference, options) {
997
1005
  return VaultFile.fromVaultReference({
package/dist/index.d.cts CHANGED
@@ -249,9 +249,9 @@ declare class VaultFile {
249
249
  * ```
250
250
  */
251
251
  static fromContent(params: {
252
- name: string;
253
252
  content: Blob | File;
254
253
  config: VaultConfig;
254
+ name?: string;
255
255
  upload?: boolean;
256
256
  }, options?: {
257
257
  signal?: AbortSignal;
@@ -536,9 +536,17 @@ declare function extractVaultFileIdFromS3Url(url: string): string | null;
536
536
  declare function convertS3UrlToVaultReference(url: string): string | null;
537
537
 
538
538
  declare function vaultClient(vaultConfig: VaultConfig): {
539
- createFromContent: (name: string, content: Blob | File, options?: {
540
- signal?: AbortSignal;
541
- }) => Promise<VaultFile>;
539
+ createFromContent: {
540
+ (name: string, content: Blob | File, options?: {
541
+ signal?: AbortSignal;
542
+ }): Promise<VaultFile>;
543
+ (content: Blob | File, name?: string, options?: {
544
+ signal?: AbortSignal;
545
+ }): Promise<VaultFile>;
546
+ (content: Blob | File, options: {
547
+ signal?: AbortSignal;
548
+ }): Promise<VaultFile>;
549
+ };
542
550
  createFromReference: (reference: string, options?: {
543
551
  signal?: AbortSignal;
544
552
  }) => Promise<VaultFile>;
package/dist/index.d.mts CHANGED
@@ -249,9 +249,9 @@ declare class VaultFile {
249
249
  * ```
250
250
  */
251
251
  static fromContent(params: {
252
- name: string;
253
252
  content: Blob | File;
254
253
  config: VaultConfig;
254
+ name?: string;
255
255
  upload?: boolean;
256
256
  }, options?: {
257
257
  signal?: AbortSignal;
@@ -536,9 +536,17 @@ declare function extractVaultFileIdFromS3Url(url: string): string | null;
536
536
  declare function convertS3UrlToVaultReference(url: string): string | null;
537
537
 
538
538
  declare function vaultClient(vaultConfig: VaultConfig): {
539
- createFromContent: (name: string, content: Blob | File, options?: {
540
- signal?: AbortSignal;
541
- }) => Promise<VaultFile>;
539
+ createFromContent: {
540
+ (name: string, content: Blob | File, options?: {
541
+ signal?: AbortSignal;
542
+ }): Promise<VaultFile>;
543
+ (content: Blob | File, name?: string, options?: {
544
+ signal?: AbortSignal;
545
+ }): Promise<VaultFile>;
546
+ (content: Blob | File, options: {
547
+ signal?: AbortSignal;
548
+ }): Promise<VaultFile>;
549
+ };
542
550
  createFromReference: (reference: string, options?: {
543
551
  signal?: AbortSignal;
544
552
  }) => Promise<VaultFile>;
package/dist/index.d.ts CHANGED
@@ -249,9 +249,9 @@ declare class VaultFile {
249
249
  * ```
250
250
  */
251
251
  static fromContent(params: {
252
- name: string;
253
252
  content: Blob | File;
254
253
  config: VaultConfig;
254
+ name?: string;
255
255
  upload?: boolean;
256
256
  }, options?: {
257
257
  signal?: AbortSignal;
@@ -536,9 +536,17 @@ declare function extractVaultFileIdFromS3Url(url: string): string | null;
536
536
  declare function convertS3UrlToVaultReference(url: string): string | null;
537
537
 
538
538
  declare function vaultClient(vaultConfig: VaultConfig): {
539
- createFromContent: (name: string, content: Blob | File, options?: {
540
- signal?: AbortSignal;
541
- }) => Promise<VaultFile>;
539
+ createFromContent: {
540
+ (name: string, content: Blob | File, options?: {
541
+ signal?: AbortSignal;
542
+ }): Promise<VaultFile>;
543
+ (content: Blob | File, name?: string, options?: {
544
+ signal?: AbortSignal;
545
+ }): Promise<VaultFile>;
546
+ (content: Blob | File, options: {
547
+ signal?: AbortSignal;
548
+ }): Promise<VaultFile>;
549
+ };
542
550
  createFromReference: (reference: string, options?: {
543
551
  signal?: AbortSignal;
544
552
  }) => Promise<VaultFile>;
package/dist/index.mjs CHANGED
@@ -219,7 +219,7 @@ async function detectFileMimeType(blob) {
219
219
  }
220
220
 
221
221
  const name = "@meistrari/vault-sdk";
222
- const version = "1.6.0";
222
+ const version = "1.6.1";
223
223
  const license = "UNLICENSED";
224
224
  const repository = {
225
225
  type: "git",
@@ -984,12 +984,20 @@ function convertS3UrlToVaultReference(url) {
984
984
 
985
985
  function vaultClient(vaultConfig) {
986
986
  const config = resolveConfig(vaultConfig);
987
- function createFromContent(name, content, options) {
988
- return VaultFile.fromContent({
989
- name,
990
- content,
991
- config
992
- }, { signal: options?.signal });
987
+ function createFromContent(nameOrContent, contentOrNameOrOptions, options) {
988
+ const isOptionsObject = (value) => {
989
+ return typeof value === "object" && value !== null && !(value instanceof Blob) && !(value instanceof File);
990
+ };
991
+ if (typeof nameOrContent === "string") {
992
+ const name2 = nameOrContent;
993
+ const content2 = contentOrNameOrOptions;
994
+ const signal2 = options?.signal;
995
+ return VaultFile.fromContent({ content: content2, name: name2, config }, { signal: signal2 });
996
+ }
997
+ const content = nameOrContent;
998
+ const name = typeof contentOrNameOrOptions === "string" ? contentOrNameOrOptions : void 0;
999
+ const signal = isOptionsObject(contentOrNameOrOptions) ? contentOrNameOrOptions.signal : options?.signal;
1000
+ return VaultFile.fromContent({ content, name, config }, { signal });
993
1001
  }
994
1002
  function createFromReference(reference, options) {
995
1003
  return VaultFile.fromVaultReference({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meistrari/vault-sdk",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "license": "UNLICENSED",
5
5
  "repository": {
6
6
  "type": "git",