@meistrari/vault-sdk 3.3.0 → 3.4.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/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Vault SDK
2
2
 
3
- TypeScript SDK for interacting with the Vault file storage service. It supports file upload, download, streaming uploads, file hierarchies, public assets, permalinks, and vault reference utilities.
3
+ TypeScript SDK for interacting with the Vault file storage service. It supports file upload, download, streaming uploads, file hierarchies, assets, permalinks, and vault reference utilities.
4
4
 
5
- Use the SDK when an application needs to store private files in Vault, publish stable public asset URLs such as avatars or logos, or keep durable `vault://` references instead of temporary presigned URLs.
5
+ Use the SDK when an application needs to store private files in Vault, publish stable asset URLs such as avatars or logos, or keep durable `vault://` references instead of temporary presigned URLs.
6
6
 
7
7
  ## Installation
8
8
 
package/dist/index.cjs CHANGED
@@ -1,9 +1,8 @@
1
1
  'use strict';
2
2
 
3
- const zod = require('zod');
3
+ const schemas = require('@meistrari/vault-shared/schemas');
4
4
  const fileType = require('@meistrari/file-type');
5
5
  const mimeTypes = require('mime-types');
6
- const schemas = require('@meistrari/vault-shared/schemas');
7
6
  const vaultUtils = require('@meistrari/vault-shared/utils');
8
7
 
9
8
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
@@ -78,7 +77,7 @@ async function getFileHash(blob) {
78
77
  }
79
78
  async function detectFileMimeType(blob) {
80
79
  if (blob instanceof Blob && blob.type) {
81
- return blob.type.split(";")[0].trim();
80
+ return blob.type.split(";")[0]?.trim();
82
81
  }
83
82
  if ("name" in blob && typeof blob.name === "string") {
84
83
  const extension = blob.name.split(".").pop()?.toLowerCase();
@@ -106,7 +105,7 @@ async function detectFileMimeType(blob) {
106
105
  if (lines.length > 1) {
107
106
  const commaCounts = lines.map((line) => (line.match(/,/g) || []).length);
108
107
  const allSame = commaCounts.every((count) => count === commaCounts[0]);
109
- if (allSame && commaCounts[0] > 0) {
108
+ if (allSame && (commaCounts[0] ?? 0) > 0) {
110
109
  return "text/csv";
111
110
  }
112
111
  }
@@ -138,7 +137,7 @@ function getFileName(content) {
138
137
  }
139
138
 
140
139
  const name = "@meistrari/vault-sdk";
141
- const version = "3.3.0";
140
+ const version = "3.4.0";
142
141
  const license = "UNLICENSED";
143
142
  const repository = {
144
143
  type: "git",
@@ -166,7 +165,7 @@ const scripts = {
166
165
  };
167
166
  const dependencies = {
168
167
  "@meistrari/file-type": "22.0.0",
169
- "@meistrari/vault-shared": "0.1.2",
168
+ "@meistrari/vault-shared": "0.2.0",
170
169
  "mime-types": "3.0.1",
171
170
  ofetch: "1.4.1",
172
171
  zod: "4.3.6"
@@ -210,13 +209,6 @@ var __publicField$2 = (obj, key, value) => {
210
209
  return value;
211
210
  };
212
211
  const compatibilityDate$1 = "2025-05-19";
213
- const PublicAssetUploadResponse = zod.z.object({
214
- assetId: zod.z.string(),
215
- assetUrl: zod.z.string().url(),
216
- uploadUrl: zod.z.string().url(),
217
- expiresAt: zod.z.string().datetime(),
218
- uploadHeaders: zod.z.record(zod.z.string(), zod.z.string())
219
- });
220
212
  async function wrappedFetch$1(url, requestInit) {
221
213
  const request = new Request(url, requestInit);
222
214
  request.headers.set("User-Agent", userAgent);
@@ -228,18 +220,58 @@ async function wrappedFetch$1(url, requestInit) {
228
220
  return response;
229
221
  }
230
222
  class VaultAsset {
231
- constructor({ assetId, assetUrl, uploadUrl, expiresAt, uploadHeaders }) {
223
+ /**
224
+ * Constructs a VaultAsset instance from Vault response data.
225
+ *
226
+ * Direct usage of the constructor is not usually needed. Prefer
227
+ * {@link VaultAsset.create} or {@link VaultAsset.fromContent}.
228
+ *
229
+ * @param params - Values returned by Vault when creating an asset upload.
230
+ * @param params.assetId - Vault-assigned asset ID.
231
+ * @param params.assetUrl - Stable URL used to resolve or download the asset.
232
+ * @param params.uploadUrl - Presigned URL used to upload the asset content.
233
+ * @param params.expiresAt - Expiration time for the presigned upload URL.
234
+ * @param params.uploadHeaders - Headers required by the presigned upload URL.
235
+ * @param params.asset - Stored asset metadata returned by Vault.
236
+ */
237
+ constructor({ assetId, assetUrl, uploadUrl, expiresAt, uploadHeaders, asset }) {
238
+ /** Vault-assigned asset ID. */
232
239
  __publicField$2(this, "assetId");
240
+ /** Stable URL used to resolve or download the asset. */
233
241
  __publicField$2(this, "assetUrl");
242
+ /** Presigned URL used to upload asset content. */
234
243
  __publicField$2(this, "uploadUrl");
244
+ /** Expiration time for the presigned upload URL. */
235
245
  __publicField$2(this, "expiresAt");
246
+ /** Headers that must be sent when uploading to {@link VaultAsset.uploadUrl}. */
236
247
  __publicField$2(this, "uploadHeaders");
248
+ /** Stored asset metadata returned by Vault. */
249
+ __publicField$2(this, "asset");
237
250
  this.assetId = assetId;
238
251
  this.assetUrl = new URL(assetUrl);
239
252
  this.uploadUrl = new URL(uploadUrl);
240
253
  this.expiresAt = new Date(expiresAt);
241
254
  this.uploadHeaders = uploadHeaders;
255
+ this.asset = asset;
242
256
  }
257
+ /**
258
+ * Creates an asset upload URL without uploading content.
259
+ *
260
+ * Use {@link VaultAsset.upload} to upload content later, or use
261
+ * {@link VaultAsset.fromContent} with `upload: true` to create and upload in one call.
262
+ *
263
+ * @param vaultConfig - Vault client configuration.
264
+ * @param params - Parameters for the asset upload.
265
+ * @param params.assetClass - Application-defined class for grouping assets.
266
+ * @param params.subject - Opaque application-owned entity reference for lookup and cleanup. Use a stable namespaced value such as `user:user_123`; Vault does not interpret it or include it in the asset URL.
267
+ * @param params.mimeType - MIME type of the content that will be uploaded.
268
+ * @param params.size - Size of the content in bytes, when known.
269
+ * @param options - Additional options for the request.
270
+ * @param options.signal - Signal used to abort the request.
271
+ * @returns A VaultAsset containing the asset URL and presigned upload URL.
272
+ * @throws {FetchError} If Vault rejects the create request.
273
+ * @throws {Error} If Vault returns a response that does not match the SDK schema.
274
+ */
243
275
  static async create(vaultConfig, params, options) {
244
276
  const config = resolveConfig(vaultConfig);
245
277
  const headers = config.authStrategy.getHeaders();
@@ -250,19 +282,40 @@ class VaultAsset {
250
282
  headers,
251
283
  body: JSON.stringify({
252
284
  assetClass: params.assetClass,
285
+ subject: params.subject,
253
286
  mimeType: params.mimeType,
254
287
  size: params.size
255
288
  })
256
- }).then(async (response2) => await response2.json()).then((data) => PublicAssetUploadResponse.safeParse(data));
289
+ }).then(async (response2) => await response2.json()).then((data) => schemas.CreateAssetUploadResponse.safeParse(data));
257
290
  if (!response.success) {
258
291
  throw new Error(`Invalid response from vault service. ${JSON.stringify(response.error)}`);
259
292
  }
260
293
  return new VaultAsset(response.data);
261
294
  }
295
+ /**
296
+ * Creates an asset from Blob or File content.
297
+ *
298
+ * The SDK detects the MIME type when `params.mimeType` is omitted. Set
299
+ * `params.upload` to `true` to upload the content immediately.
300
+ *
301
+ * @param vaultConfig - Vault client configuration.
302
+ * @param content - Content to associate with the asset.
303
+ * @param params - Parameters for the asset.
304
+ * @param params.assetClass - Application-defined class for grouping assets.
305
+ * @param params.subject - Opaque application-owned entity reference for lookup and cleanup. Use a stable namespaced value such as `user:user_123`; Vault does not interpret it or include it in the asset URL.
306
+ * @param params.mimeType - MIME type override for the content.
307
+ * @param params.upload - Whether to upload the content immediately after creating the asset.
308
+ * @param options - Additional options for the create and upload requests.
309
+ * @param options.signal - Signal used to abort either request.
310
+ * @returns A VaultAsset containing the asset URL and presigned upload URL.
311
+ * @throws {FetchError} If Vault rejects the create request or the upload request fails.
312
+ * @throws {Error} If Vault returns a response that does not match the SDK schema.
313
+ */
262
314
  static async fromContent(vaultConfig, content, params, options) {
263
315
  const mimeType = params.mimeType ?? await detectFileMimeType(content) ?? "application/octet-stream";
264
316
  const asset = await VaultAsset.create(vaultConfig, {
265
317
  assetClass: params.assetClass,
318
+ subject: params.subject,
266
319
  mimeType,
267
320
  size: content.size
268
321
  }, options);
@@ -271,6 +324,16 @@ class VaultAsset {
271
324
  }
272
325
  return asset;
273
326
  }
327
+ /**
328
+ * Uploads content to this asset's presigned upload URL.
329
+ *
330
+ * The upload request sends the headers returned by Vault when the asset was created.
331
+ *
332
+ * @param content - Content to upload.
333
+ * @param options - Additional options for the upload request.
334
+ * @param options.signal - Signal used to abort the upload.
335
+ * @throws {FetchError} If the upload endpoint returns an error response.
336
+ */
274
337
  async upload(content, options) {
275
338
  await wrappedFetch$1(this.uploadUrl, {
276
339
  method: "PUT",
@@ -2104,9 +2167,32 @@ function vaultClient(vaultConfig) {
2104
2167
  }, { signal: options?.signal });
2105
2168
  }
2106
2169
  const assets = {
2170
+ /**
2171
+ * Creates an asset upload URL without uploading content.
2172
+ *
2173
+ * `params.subject` should be a stable application-owned entity reference such as
2174
+ * `user:user_123` or `organization:org_123`. Vault stores it for lookup and cleanup,
2175
+ * but does not interpret it, enforce authorization from it, or include it in the asset URL.
2176
+ *
2177
+ * @param params - Parameters for the asset upload.
2178
+ * @param options - Additional options for the request.
2179
+ * @returns A VaultAsset with the stable asset URL and presigned upload URL.
2180
+ */
2107
2181
  async create(params, options) {
2108
2182
  return await VaultAsset.create(config, params, { signal: options?.signal });
2109
2183
  },
2184
+ /**
2185
+ * Creates an asset from File or Blob content and optionally uploads it immediately.
2186
+ *
2187
+ * `params.subject` should be a stable application-owned entity reference such as
2188
+ * `user:user_123` or `organization:org_123`. Vault stores it for lookup and cleanup,
2189
+ * but does not interpret it, enforce authorization from it, or include it in the asset URL.
2190
+ *
2191
+ * @param content - File or Blob content to associate with the asset.
2192
+ * @param params - Parameters for the asset.
2193
+ * @param options - Additional options for the create and upload requests.
2194
+ * @returns A VaultAsset with the stable asset URL and presigned upload URL.
2195
+ */
2110
2196
  async createFromContent(content, params, options) {
2111
2197
  return await VaultAsset.fromContent(config, content, params, { signal: options?.signal });
2112
2198
  }
package/dist/index.d.cts CHANGED
@@ -1,4 +1,5 @@
1
- import { SerializedPermalink, FileMetadata } from '@meistrari/vault-shared/schemas';
1
+ import { AssetMetadata, SerializedPermalink, FileMetadata } from '@meistrari/vault-shared/schemas';
2
+ export { AssetMetadata } from '@meistrari/vault-shared/schemas';
2
3
 
3
4
  interface AuthStrategy {
4
5
  getHeaders: () => Headers;
@@ -28,36 +29,145 @@ type VaultConfig = {
28
29
  authStrategy: AuthStrategy;
29
30
  };
30
31
 
32
+ /**
33
+ * Parameters for creating an asset upload URL.
34
+ */
31
35
  type CreateAssetUploadParams = {
36
+ /** Application-defined class for grouping assets, such as `avatar` or `cover-image`. */
32
37
  assetClass: string;
38
+ /**
39
+ * Opaque application-owned entity reference for this asset.
40
+ *
41
+ * Use a stable, namespaced value that points to the domain object the asset represents
42
+ * or belongs to, such as `user:user_123`, `organization:org_123`, or `app:app_123`.
43
+ * Vault stores this value for lookup and cleanup workflows but does not interpret it,
44
+ * enforce authorization from it, or include it in the stable asset URL.
45
+ */
46
+ subject: string;
47
+ /** MIME type of the content that will be uploaded. */
33
48
  mimeType: string;
49
+ /** Size of the content in bytes, when known. */
34
50
  size?: number;
35
51
  };
52
+ /**
53
+ * Parameters for creating an asset from in-memory content.
54
+ */
36
55
  type CreateAssetFromContentParams = {
56
+ /** Application-defined class for grouping assets, such as `avatar` or `cover-image`. */
37
57
  assetClass: string;
58
+ /**
59
+ * Opaque application-owned entity reference for this asset.
60
+ *
61
+ * Use a stable, namespaced value that points to the domain object the asset represents
62
+ * or belongs to, such as `user:user_123`, `organization:org_123`, or `app:app_123`.
63
+ * Vault stores this value for lookup and cleanup workflows but does not interpret it,
64
+ * enforce authorization from it, or include it in the stable asset URL.
65
+ */
66
+ subject: string;
67
+ /** MIME type override. When omitted, the SDK attempts to detect the content type. */
38
68
  mimeType?: string;
69
+ /** Whether to upload the content immediately after creating the asset. */
39
70
  upload?: boolean;
40
71
  };
72
+ /** Values required to construct a VaultAsset instance. */
41
73
  type VaultAssetParams = {
74
+ /** Vault-assigned asset ID. */
42
75
  assetId: string;
76
+ /** Stable URL used to resolve or download the asset. */
43
77
  assetUrl: string | URL;
78
+ /** Presigned URL used to upload the asset content. */
44
79
  uploadUrl: string | URL;
80
+ /** Expiration time for the presigned upload URL. */
45
81
  expiresAt: string | Date;
82
+ /** Headers that must be sent with the presigned upload request. */
46
83
  uploadHeaders: Record<string, string>;
84
+ /** Stored asset metadata returned by Vault. */
85
+ asset: AssetMetadata;
47
86
  };
87
+ /**
88
+ * Represents a Vault asset with a stable asset URL and a presigned upload URL.
89
+ */
48
90
  declare class VaultAsset {
91
+ /** Vault-assigned asset ID. */
49
92
  readonly assetId: string;
93
+ /** Stable URL used to resolve or download the asset. */
50
94
  readonly assetUrl: URL;
95
+ /** Presigned URL used to upload asset content. */
51
96
  readonly uploadUrl: URL;
97
+ /** Expiration time for the presigned upload URL. */
52
98
  readonly expiresAt: Date;
99
+ /** Headers that must be sent when uploading to {@link VaultAsset.uploadUrl}. */
53
100
  readonly uploadHeaders: Record<string, string>;
54
- constructor({ assetId, assetUrl, uploadUrl, expiresAt, uploadHeaders }: VaultAssetParams);
101
+ /** Stored asset metadata returned by Vault. */
102
+ readonly asset: AssetMetadata;
103
+ /**
104
+ * Constructs a VaultAsset instance from Vault response data.
105
+ *
106
+ * Direct usage of the constructor is not usually needed. Prefer
107
+ * {@link VaultAsset.create} or {@link VaultAsset.fromContent}.
108
+ *
109
+ * @param params - Values returned by Vault when creating an asset upload.
110
+ * @param params.assetId - Vault-assigned asset ID.
111
+ * @param params.assetUrl - Stable URL used to resolve or download the asset.
112
+ * @param params.uploadUrl - Presigned URL used to upload the asset content.
113
+ * @param params.expiresAt - Expiration time for the presigned upload URL.
114
+ * @param params.uploadHeaders - Headers required by the presigned upload URL.
115
+ * @param params.asset - Stored asset metadata returned by Vault.
116
+ */
117
+ constructor({ assetId, assetUrl, uploadUrl, expiresAt, uploadHeaders, asset }: VaultAssetParams);
118
+ /**
119
+ * Creates an asset upload URL without uploading content.
120
+ *
121
+ * Use {@link VaultAsset.upload} to upload content later, or use
122
+ * {@link VaultAsset.fromContent} with `upload: true` to create and upload in one call.
123
+ *
124
+ * @param vaultConfig - Vault client configuration.
125
+ * @param params - Parameters for the asset upload.
126
+ * @param params.assetClass - Application-defined class for grouping assets.
127
+ * @param params.subject - Opaque application-owned entity reference for lookup and cleanup. Use a stable namespaced value such as `user:user_123`; Vault does not interpret it or include it in the asset URL.
128
+ * @param params.mimeType - MIME type of the content that will be uploaded.
129
+ * @param params.size - Size of the content in bytes, when known.
130
+ * @param options - Additional options for the request.
131
+ * @param options.signal - Signal used to abort the request.
132
+ * @returns A VaultAsset containing the asset URL and presigned upload URL.
133
+ * @throws {FetchError} If Vault rejects the create request.
134
+ * @throws {Error} If Vault returns a response that does not match the SDK schema.
135
+ */
55
136
  static create(vaultConfig: VaultConfig, params: CreateAssetUploadParams, options?: {
56
137
  signal?: AbortSignal;
57
138
  }): Promise<VaultAsset>;
139
+ /**
140
+ * Creates an asset from Blob or File content.
141
+ *
142
+ * The SDK detects the MIME type when `params.mimeType` is omitted. Set
143
+ * `params.upload` to `true` to upload the content immediately.
144
+ *
145
+ * @param vaultConfig - Vault client configuration.
146
+ * @param content - Content to associate with the asset.
147
+ * @param params - Parameters for the asset.
148
+ * @param params.assetClass - Application-defined class for grouping assets.
149
+ * @param params.subject - Opaque application-owned entity reference for lookup and cleanup. Use a stable namespaced value such as `user:user_123`; Vault does not interpret it or include it in the asset URL.
150
+ * @param params.mimeType - MIME type override for the content.
151
+ * @param params.upload - Whether to upload the content immediately after creating the asset.
152
+ * @param options - Additional options for the create and upload requests.
153
+ * @param options.signal - Signal used to abort either request.
154
+ * @returns A VaultAsset containing the asset URL and presigned upload URL.
155
+ * @throws {FetchError} If Vault rejects the create request or the upload request fails.
156
+ * @throws {Error} If Vault returns a response that does not match the SDK schema.
157
+ */
58
158
  static fromContent(vaultConfig: VaultConfig, content: Blob | File, params: CreateAssetFromContentParams, options?: {
59
159
  signal?: AbortSignal;
60
160
  }): Promise<VaultAsset>;
161
+ /**
162
+ * Uploads content to this asset's presigned upload URL.
163
+ *
164
+ * The upload request sends the headers returned by Vault when the asset was created.
165
+ *
166
+ * @param content - Content to upload.
167
+ * @param options - Additional options for the upload request.
168
+ * @param options.signal - Signal used to abort the upload.
169
+ * @throws {FetchError} If the upload endpoint returns an error response.
170
+ */
61
171
  upload(content: Blob | File, options?: {
62
172
  signal?: AbortSignal;
63
173
  }): Promise<void>;
@@ -1384,63 +1494,122 @@ declare function getVaultParamsFromS3Url(url: string): {
1384
1494
  parentId: string | null;
1385
1495
  } | null;
1386
1496
 
1497
+ /** Options shared by content-based file creation overloads. */
1498
+ type CreateFromContentOptions = {
1499
+ /** Signal used to abort the request. */
1500
+ signal?: AbortSignal;
1501
+ /** Parent file ID for hierarchical file relationships. */
1502
+ parentId?: string;
1503
+ /** MIME type override for the uploaded content. */
1504
+ mimeType?: string;
1505
+ /** Whether to upload the content immediately after creating the file metadata. */
1506
+ upload?: boolean;
1507
+ };
1508
+ /** Options for fetching an existing Vault file by reference. */
1509
+ type CreateFromReferenceOptions = {
1510
+ /** Signal used to abort the request. */
1511
+ signal?: AbortSignal;
1512
+ };
1513
+ /** Options for stream-based file creation. */
1514
+ type CreateFromStreamOptions = {
1515
+ /** MIME type of the stream content. */
1516
+ contentType?: string;
1517
+ /** Signal used to abort the request. */
1518
+ signal?: AbortSignal;
1519
+ /** Parent file ID for hierarchical file relationships. */
1520
+ parentId?: string;
1521
+ };
1522
+ /** File input used by bulk content creation. */
1523
+ type CreateFromContentBulkFile = {
1524
+ /** File or Blob content to register and optionally upload. */
1525
+ content: Blob | File;
1526
+ /** File name override. */
1527
+ name?: string;
1528
+ /** MIME type override for the content. */
1529
+ mimeType?: string;
1530
+ /** Parent file ID for hierarchical file relationships. */
1531
+ parentId?: string;
1532
+ /** Behavior when the requested parent cannot be found. */
1533
+ onMissingParent?: 'error' | 'create-as-root';
1534
+ /** Behavior when the file already exists under a different parent. */
1535
+ onParentConflict?: 'error' | 'update-parent-id' | 'ignore';
1536
+ };
1537
+ /** Options for bulk content creation. */
1538
+ type CreateFromContentBulkOptions = {
1539
+ /** Whether to upload all created files immediately. */
1540
+ upload?: boolean;
1541
+ /** Signal used to abort the request. */
1542
+ signal?: AbortSignal;
1543
+ };
1544
+ /** File input used by bulk stream creation. */
1545
+ type CreateFromStreamBulkFile = {
1546
+ /** Name of the file represented by the stream. */
1547
+ name: string;
1548
+ /** Size of the stream content in bytes. */
1549
+ contentLength: number;
1550
+ /** MIME type of the stream content. */
1551
+ contentType?: string;
1552
+ /** Parent file ID for hierarchical file relationships. */
1553
+ parentId?: string;
1554
+ /** Behavior when the requested parent cannot be found. */
1555
+ onMissingParent?: 'error' | 'create-as-root';
1556
+ /** Behavior when the file already exists under a different parent. */
1557
+ onParentConflict?: 'error' | 'update-parent-id' | 'ignore';
1558
+ };
1559
+ /** Options for bulk stream creation. */
1560
+ type CreateFromStreamBulkOptions = {
1561
+ /** Signal used to abort the request. */
1562
+ signal?: AbortSignal;
1563
+ };
1564
+ /** Options shared by asset creation helpers. */
1565
+ type AssetRequestOptions = {
1566
+ /** Signal used to abort the request. */
1567
+ signal?: AbortSignal;
1568
+ };
1569
+ /**
1570
+ * Creates a Vault SDK client bound to a Vault URL and auth strategy.
1571
+ *
1572
+ * @param vaultConfig - Vault client configuration.
1573
+ * @param vaultConfig.vaultUrl - Base URL for the Vault API.
1574
+ * @param vaultConfig.authStrategy - Auth strategy used to sign Vault requests.
1575
+ * @returns Client helpers for files, streams, bulk creation, references, and assets.
1576
+ */
1387
1577
  declare function vaultClient(vaultConfig: VaultConfig): {
1388
1578
  createFromContent: {
1389
- (name: string, content: Blob | File, options?: {
1390
- signal?: AbortSignal;
1391
- parentId?: string;
1392
- mimeType?: string;
1393
- upload?: boolean;
1394
- }): Promise<VaultFile>;
1395
- (content: Blob | File, name?: string, options?: {
1396
- signal?: AbortSignal;
1397
- parentId?: string;
1398
- mimeType?: string;
1399
- upload?: boolean;
1400
- }): Promise<VaultFile>;
1401
- (content: Blob | File, options: {
1402
- signal?: AbortSignal;
1403
- parentId?: string;
1404
- mimeType?: string;
1405
- upload?: boolean;
1406
- }): Promise<VaultFile>;
1579
+ (name: string, content: Blob | File, options?: CreateFromContentOptions): Promise<VaultFile>;
1580
+ (content: Blob | File, name?: string, options?: CreateFromContentOptions): Promise<VaultFile>;
1581
+ (content: Blob | File, options: CreateFromContentOptions): Promise<VaultFile>;
1407
1582
  };
1408
- createFromReference: (reference: string, options?: {
1409
- signal?: AbortSignal;
1410
- }) => Promise<VaultFile>;
1411
- createFromStream: (name: string, contentLength: number, options?: {
1412
- contentType?: string;
1413
- signal?: AbortSignal;
1414
- parentId?: string;
1415
- }) => Promise<VaultFile>;
1416
- createFromContentBulk: (files: Array<{
1417
- content: Blob | File;
1418
- name?: string;
1419
- mimeType?: string;
1420
- parentId?: string;
1421
- onMissingParent?: "error" | "create-as-root";
1422
- onParentConflict?: "error" | "update-parent-id" | "ignore";
1423
- }>, options?: {
1424
- upload?: boolean;
1425
- signal?: AbortSignal;
1426
- }) => Promise<VaultFile[]>;
1427
- createFromStreamBulk: (files: Array<{
1428
- name: string;
1429
- contentLength: number;
1430
- contentType?: string;
1431
- parentId?: string;
1432
- onMissingParent?: "error" | "create-as-root";
1433
- onParentConflict?: "error" | "update-parent-id" | "ignore";
1434
- }>, options?: {
1435
- signal?: AbortSignal;
1436
- }) => Promise<VaultFile[]>;
1583
+ createFromReference: (reference: string, options?: CreateFromReferenceOptions) => Promise<VaultFile>;
1584
+ createFromStream: (name: string, contentLength: number, options?: CreateFromStreamOptions) => Promise<VaultFile>;
1585
+ createFromContentBulk: (files: CreateFromContentBulkFile[], options?: CreateFromContentBulkOptions) => Promise<VaultFile[]>;
1586
+ createFromStreamBulk: (files: CreateFromStreamBulkFile[], options?: CreateFromStreamBulkOptions) => Promise<VaultFile[]>;
1437
1587
  assets: {
1438
- create(params: CreateAssetUploadParams, options?: {
1439
- signal?: AbortSignal;
1440
- }): Promise<VaultAsset>;
1441
- createFromContent(content: Blob | File, params: CreateAssetFromContentParams, options?: {
1442
- signal?: AbortSignal;
1443
- }): Promise<VaultAsset>;
1588
+ /**
1589
+ * Creates an asset upload URL without uploading content.
1590
+ *
1591
+ * `params.subject` should be a stable application-owned entity reference such as
1592
+ * `user:user_123` or `organization:org_123`. Vault stores it for lookup and cleanup,
1593
+ * but does not interpret it, enforce authorization from it, or include it in the asset URL.
1594
+ *
1595
+ * @param params - Parameters for the asset upload.
1596
+ * @param options - Additional options for the request.
1597
+ * @returns A VaultAsset with the stable asset URL and presigned upload URL.
1598
+ */
1599
+ create(params: CreateAssetUploadParams, options?: AssetRequestOptions): Promise<VaultAsset>;
1600
+ /**
1601
+ * Creates an asset from File or Blob content and optionally uploads it immediately.
1602
+ *
1603
+ * `params.subject` should be a stable application-owned entity reference such as
1604
+ * `user:user_123` or `organization:org_123`. Vault stores it for lookup and cleanup,
1605
+ * but does not interpret it, enforce authorization from it, or include it in the asset URL.
1606
+ *
1607
+ * @param content - File or Blob content to associate with the asset.
1608
+ * @param params - Parameters for the asset.
1609
+ * @param options - Additional options for the create and upload requests.
1610
+ * @returns A VaultAsset with the stable asset URL and presigned upload URL.
1611
+ */
1612
+ createFromContent(content: Blob | File, params: CreateAssetFromContentParams, options?: AssetRequestOptions): Promise<VaultAsset>;
1444
1613
  };
1445
1614
  };
1446
1615