@zuzjs/flare 0.2.16 → 0.2.18

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.
@@ -62,6 +62,39 @@ interface FlareConfig {
62
62
  * - join aliases (`join(..., { as: "team" })` => "team")
63
63
  */
64
64
  dataMapper?: DataMapperRegistry;
65
+ /**
66
+ * Optional storage auto-provisioning config for bucket/server defaults.
67
+ */
68
+ storage?: boolean | FlareStorageAutoConfig;
69
+ }
70
+ /**
71
+ * Options for storage auto-provisioning via `storage` in `FlareConfig`.
72
+ */
73
+ interface FlareStorageAutoConfig {
74
+ /** Human-readable label for the auto-provisioned server. Defaults to `"default"`. */
75
+ name?: string;
76
+ /**
77
+ * Bucket name. Defaults to `"<appId>-storage"`.
78
+ * Must be unique per app per backend kind (embedded vs S3).
79
+ */
80
+ bucket?: string;
81
+ /** Optional key prefix applied to all objects inside the bucket. */
82
+ prefix?: string;
83
+ /**
84
+ * Built-in transfer manager settings.
85
+ *
86
+ * By default uploads/downloads are queued with concurrency 1 each so
87
+ * calling putObject/getObject without await remains safe.
88
+ */
89
+ transferManager?: FlareStorageTransferManagerConfig;
90
+ }
91
+ interface FlareStorageTransferManagerConfig {
92
+ /** Enable built-in storage transfer queue. Defaults to true. */
93
+ enabled?: boolean;
94
+ /** Max concurrent uploads (putObject). Defaults to 1. */
95
+ uploadConcurrency?: number;
96
+ /** Max concurrent downloads (getObject). Defaults to 1. */
97
+ downloadConcurrency?: number;
65
98
  }
66
99
  type DataMapperFn<TRow = any, TMapped = any> = (row: TRow) => TMapped;
67
100
  type DataMapperRegistry = Record<string, DataMapperFn<any, any>>;
@@ -169,6 +202,327 @@ interface PushSendResult {
169
202
  invalidatedTokenCount: number;
170
203
  dryRun: boolean;
171
204
  }
205
+ interface FlareStorageServer {
206
+ id: string;
207
+ name: string;
208
+ kind: string;
209
+ endpoint: string;
210
+ bucket: string;
211
+ region: string;
212
+ prefix?: string;
213
+ dataDir?: string;
214
+ forcePathStyle?: boolean;
215
+ frozen?: boolean;
216
+ readOnly?: boolean;
217
+ createdAt?: unknown;
218
+ updatedAt?: unknown;
219
+ }
220
+ interface FlareStorageServerInput {
221
+ name: string;
222
+ kind?: string;
223
+ endpoint?: string;
224
+ bucket: string;
225
+ region?: string;
226
+ accessKey?: string;
227
+ secretKey?: string;
228
+ prefix?: string;
229
+ dataDir?: string;
230
+ forcePathStyle?: boolean;
231
+ frozen?: boolean;
232
+ readOnly?: boolean;
233
+ }
234
+ interface FlareStorageServerPatchInput {
235
+ name?: string;
236
+ endpoint?: string;
237
+ bucket?: string;
238
+ region?: string;
239
+ accessKey?: string;
240
+ secretKey?: string;
241
+ prefix?: string;
242
+ dataDir?: string;
243
+ forcePathStyle?: boolean;
244
+ frozen?: boolean;
245
+ readOnly?: boolean;
246
+ }
247
+ interface FlareStorageUploadInput {
248
+ serverId: string;
249
+ path: string;
250
+ contentBase64: string;
251
+ contentType?: string;
252
+ encrypt?: boolean;
253
+ }
254
+ interface FlareStorageDownloadInput {
255
+ serverId: string;
256
+ path: string;
257
+ decrypt?: boolean;
258
+ }
259
+ interface FlareStorageDeleteInput {
260
+ serverId: string;
261
+ path: string;
262
+ }
263
+ interface FlareStorageObjectResult {
264
+ ok: boolean;
265
+ path: string;
266
+ key: string;
267
+ encrypted?: boolean;
268
+ size?: number;
269
+ contentBase64?: string;
270
+ contentType?: string;
271
+ }
272
+ declare enum FlareStorageSignedAction {
273
+ Upload = "upload",
274
+ Download = "download",
275
+ Delete = "delete",
276
+ Edit = "edit"
277
+ }
278
+ interface FlareStorageSignedUrlInput {
279
+ serverId: string;
280
+ path: string;
281
+ action: FlareStorageSignedAction;
282
+ expiresInSeconds?: number;
283
+ sizeBytes?: number;
284
+ contentType?: string;
285
+ encrypt?: boolean;
286
+ decrypt?: boolean;
287
+ forceDownload?: boolean;
288
+ allowedOrigins?: string[];
289
+ embedOnly?: boolean;
290
+ }
291
+ interface FlareStorageSignedUrlResult {
292
+ ok: boolean;
293
+ action: FlareStorageSignedAction;
294
+ method: "PUT" | "PATCH" | "GET" | "DELETE";
295
+ token: string;
296
+ urlPath: string;
297
+ url: string;
298
+ expiresInSeconds?: number;
299
+ expiresAt: number;
300
+ forceDownload?: boolean;
301
+ allowedOrigins?: string[];
302
+ embedOnly?: boolean;
303
+ }
304
+ interface FlareStorageAwsConfig {
305
+ kind: string;
306
+ endpoint: string;
307
+ region: string;
308
+ bucket: string;
309
+ prefix?: string;
310
+ dataDir?: string;
311
+ forcePathStyle?: boolean;
312
+ accessKeyId: string;
313
+ secretAccessKey: string;
314
+ }
315
+ interface FlareStorageRulesPolicy {
316
+ maxEntries?: number;
317
+ maxAgeDays?: number;
318
+ }
319
+ interface FlareStorageRulesHistoryResult {
320
+ history: unknown[];
321
+ policy: FlareStorageRulesPolicy;
322
+ restoreEvents: unknown[];
323
+ }
324
+ /** Upload progress snapshot. */
325
+ interface StorageProgress {
326
+ /** Bytes sent so far. */
327
+ loaded: number;
328
+ /** Total bytes to send. */
329
+ total: number;
330
+ /** 0–100. */
331
+ percent: number;
332
+ }
333
+ /** A bucket (backed by a flare storage server). */
334
+ interface StorageBucket {
335
+ /** Internal flare server ID. */
336
+ id: string;
337
+ /** Human-readable label. */
338
+ name: string;
339
+ /** Bucket name used on the backend (s3 bucket / embedded dir name). */
340
+ bucket: string;
341
+ /** Backend kind: "embedded" | "s3" | "managed". */
342
+ kind: string;
343
+ region?: string;
344
+ endpoint?: string;
345
+ prefix?: string;
346
+ frozen?: boolean;
347
+ readOnly?: boolean;
348
+ createdAt?: unknown;
349
+ updatedAt?: unknown;
350
+ }
351
+ /** Options for createBucket(). */
352
+ interface StorageBucketInput {
353
+ /**
354
+ * Backend kind. Defaults to "managed".
355
+ * "managed" lets flare-node choose embedded or s3-proxy based on server config.
356
+ */
357
+ kind?: string;
358
+ prefix?: string;
359
+ region?: string;
360
+ /** Advanced: explicit s3 endpoint (only needed for kind="s3"). */
361
+ endpoint?: string;
362
+ accessKey?: string;
363
+ secretKey?: string;
364
+ dataDir?: string;
365
+ forcePathStyle?: boolean;
366
+ }
367
+ /** Object metadata without content. */
368
+ interface StorageObjectMeta {
369
+ key: string;
370
+ bucket: string;
371
+ size: number;
372
+ contentType: string;
373
+ encrypted: boolean;
374
+ createdAt?: unknown;
375
+ updatedAt?: unknown;
376
+ }
377
+ /** Upload an object to a bucket. */
378
+ interface PutObjectInput {
379
+ bucket: string;
380
+ /** Object key (path inside the bucket). */
381
+ key: string;
382
+ /**
383
+ * Object body. Accepted forms:
384
+ * - `string` — UTF-8 text
385
+ * - `Uint8Array` / `ArrayBuffer` — raw bytes
386
+ * - `Blob` — browser File / Blob
387
+ * - `contentBase64` field on the object — pre-encoded base64 string
388
+ */
389
+ body?: string | Uint8Array | ArrayBuffer | Blob;
390
+ /** Pre-encoded base64 body. Mutually exclusive with `body`. */
391
+ contentBase64?: string;
392
+ /**
393
+ * Prefer legacy base64 upload path.
394
+ *
395
+ * Default is `false` (raw signed URL upload).
396
+ * If true and payload size exceeds `base64MaxBytes`, SDK auto-falls back to raw upload.
397
+ */
398
+ base64?: boolean;
399
+ /**
400
+ * Max payload bytes allowed for base64 path before auto-fallback to raw upload.
401
+ * Default: 4 MiB.
402
+ */
403
+ base64MaxBytes?: number;
404
+ contentType?: string;
405
+ /** Encrypt at rest with AES-256-GCM. Defaults to true. */
406
+ encrypt?: boolean;
407
+ /** Upload progress callback. Only fires in browser environments. */
408
+ onProgress?: (progress: StorageProgress) => void;
409
+ }
410
+ interface PutObjectResult {
411
+ ok: boolean;
412
+ bucket: string;
413
+ key: string;
414
+ size: number;
415
+ encrypted: boolean;
416
+ }
417
+ interface GetObjectInput {
418
+ bucket: string;
419
+ key: string;
420
+ /** Decrypt on download. Defaults to true. */
421
+ decrypt?: boolean;
422
+ }
423
+ interface GetObjectResult {
424
+ ok: boolean;
425
+ bucket: string;
426
+ key: string;
427
+ /** Base64-encoded content. */
428
+ contentBase64: string;
429
+ contentType: string;
430
+ size: number;
431
+ encrypted: boolean;
432
+ }
433
+ interface GetObjectUrlInput {
434
+ bucket: string;
435
+ key: string;
436
+ /** Decrypt on download. Defaults to true. */
437
+ decrypt?: boolean;
438
+ /** Signed URL ttl in seconds. Defaults to server policy. */
439
+ expiresInSeconds?: number;
440
+ /** Force attachment response for browser-displayable media. */
441
+ forceDownload?: boolean;
442
+ /** Allowed request origins for accessing the signed file. Defaults to ["*"]. */
443
+ allowedOrigins?: string[];
444
+ /** Restrict access to embedded media contexts (<img>, <video>, <audio>). */
445
+ embedOnly?: boolean;
446
+ }
447
+ interface DownloadObjectInput extends GetObjectUrlInput {
448
+ /** Suggested filename for browser downloads. Defaults to key basename. */
449
+ filename?: string;
450
+ /** Open in a new tab instead of forcing attachment download. */
451
+ openInNewTab?: boolean;
452
+ }
453
+ interface DownloadObjectResult {
454
+ ok: boolean;
455
+ url: string;
456
+ filename: string;
457
+ /** True when browser click dispatch occurred. */
458
+ triggered: boolean;
459
+ }
460
+ interface HeadObjectInput {
461
+ bucket: string;
462
+ key: string;
463
+ }
464
+ interface HeadObjectsInput {
465
+ bucket: string;
466
+ keys: string[];
467
+ }
468
+ interface ListObjectsInput {
469
+ bucket: string;
470
+ /** Key prefix filter. */
471
+ prefix?: string;
472
+ limit?: number;
473
+ /** Continuation token from a previous ListObjectsResult. */
474
+ cursor?: string;
475
+ }
476
+ interface ListObjectsResult {
477
+ bucket: string;
478
+ objects: StorageObjectMeta[];
479
+ count: number;
480
+ hasMore: boolean;
481
+ /** Pass to the next listObjects() call to get the next page. */
482
+ cursor?: string;
483
+ }
484
+ interface CopyObjectInput {
485
+ sourceBucket: string;
486
+ sourceKey: string;
487
+ destBucket: string;
488
+ destKey: string;
489
+ }
490
+ interface DeleteObjectInput {
491
+ bucket: string;
492
+ key: string;
493
+ }
494
+ interface DeleteObjectsInput {
495
+ bucket: string;
496
+ keys: string[];
497
+ }
498
+ /** Signed URL input using bucket/key names instead of serverId. */
499
+ interface StorageSignedUrlInput {
500
+ bucket: string;
501
+ key: string;
502
+ action: FlareStorageSignedAction;
503
+ expiresInSeconds?: number;
504
+ sizeBytes?: number;
505
+ contentType?: string;
506
+ encrypt?: boolean;
507
+ decrypt?: boolean;
508
+ forceDownload?: boolean;
509
+ allowedOrigins?: string[];
510
+ embedOnly?: boolean;
511
+ }
512
+ /** Bucket-level security rules. Maps to flare storage rules DSL. */
513
+ interface BucketPolicyInput {
514
+ rulesDsl?: string;
515
+ rules?: Record<string, unknown>;
516
+ rulesHistoryPolicy?: FlareStorageRulesPolicy;
517
+ }
518
+ /** CORS rule for a bucket. */
519
+ interface BucketCorsRule {
520
+ allowedOrigins: string[];
521
+ allowedMethods: ("GET" | "PUT" | "POST" | "DELETE" | "HEAD")[];
522
+ allowedHeaders?: string[];
523
+ exposeHeaders?: string[];
524
+ maxAgeSeconds?: number;
525
+ }
172
526
  interface SendEmailInput {
173
527
  to: string | string[];
174
528
  tag: string;
@@ -508,4 +862,4 @@ type SecurityRulesMap = Record<string, SecurityRuleEntry>;
508
862
  declare const flareRulesToSecurityMap: (rules: FlareRule[]) => SecurityRulesMap;
509
863
  declare const securityMapToFlareRules: (rules: SecurityRulesMap) => FlareRule[];
510
864
 
511
- export { type QueryPresetMap as $, type AggregateFunction as A, type BrowserPushRegistrationOptions as B, type ChangeEvent as C, type DataMapperFn as D, type EmailLinkVerifyResult as E, type FlareConfig as F, type FlareAuthHydrationOptions as G, type FlareAuthProviderId as H, type FlareAuthProviderPublicConfig as I, type FlareAuthSession as J, type FlareAuthUser as K, type FlareRule as L, type GroupByClause as M, type HavingClause as N, type JoinClause as O, type JoinQueryPattern as P, type NestedJoinClause as Q, type OfflineOperation as R, type OrFilter as S, type OrderByClause as T, type PresenceCallback as U, type PresenceJoinCallback as V, type PresenceLeaveCallback as W, type PresenceMember as X, type PushSendResult as Y, type QueryConfig as Z, type QueryOperator as _, type AggregateSpec as a, type QueryPresetParams as a0, type QueryPresetRow as a1, type QueryPresetSpec as a2, type QuerySnapshot as a3, type RegisterPushTokenInput as a4, type RulePermission as a5, type SecurityRuleEntry as a6, type SecurityRulesMap as a7, type SendEmailInput as a8, type SendPushNotificationInput as a9, type SnapshotEvent as aa, type StreamFlushReason as ab, type StructuredJoinClause as ac, type StructuredQuery as ad, type SubscribeOptions as ae, type SubscriptionCallback as af, type SubscriptionData as ag, type SubscriptionError as ah, type SubscriptionErrorCallback as ai, type SubscriptionHandle as aj, type VectorFieldConfig as ak, type VectorSearchClause as al, type VerifyEmailLinkInput as am, type WhereCondition as an, flareRulesToSecurityMap as ao, securityMapToFlareRules as ap, type AndFilter as b, type AnyFilter as c, type AuthConfigListener as d, type AuthResult as e, type AuthStateListener as f, type AuthWithPendingVerificationResult as g, type AuthWithTokenResult as h, type BrowserPushTokenOptions as i, type ChangeOperation as j, type CollectionExternalStore as k, type CollectionStream as l, type CollectionStreamListener as m, type CollectionStreamMeta as n, type CollectionStreamOptions as o, type ConnectionState as p, type CursorValue as q, type DataMapperRegistry as r, type DocAddedCallback as s, type DocChangedCallback as t, type DocDeletedCallback as u, type DocUpdatedCallback as v, type DocumentSnapshot as w, type EmailSendResult as x, type FlareAuthConfig as y, type FlareAuthHydrationInput as z };
865
+ export { type FlareStorageServerInput as $, type AggregateFunction as A, type BrowserPushRegistrationOptions as B, type ChangeEvent as C, type DataMapperFn as D, type DocUpdatedCallback as E, type FlareConfig as F, type DocumentSnapshot as G, type DownloadObjectInput as H, type DownloadObjectResult as I, type EmailLinkVerifyResult as J, type EmailSendResult as K, type FlareAuthConfig as L, type FlareAuthHydrationInput as M, type FlareAuthHydrationOptions as N, type FlareAuthProviderId as O, type FlareAuthProviderPublicConfig as P, type FlareAuthSession as Q, type FlareAuthUser as R, type FlareRule as S, type FlareStorageAutoConfig as T, type FlareStorageAwsConfig as U, type FlareStorageDeleteInput as V, type FlareStorageDownloadInput as W, type FlareStorageObjectResult as X, type FlareStorageRulesHistoryResult as Y, type FlareStorageRulesPolicy as Z, type FlareStorageServer as _, type AggregateSpec as a, type FlareStorageServerPatchInput as a0, FlareStorageSignedAction as a1, type FlareStorageSignedUrlInput as a2, type FlareStorageSignedUrlResult as a3, type FlareStorageTransferManagerConfig as a4, type FlareStorageUploadInput as a5, type GetObjectInput as a6, type GetObjectResult as a7, type GetObjectUrlInput as a8, type GroupByClause as a9, type RulePermission as aA, type SecurityRuleEntry as aB, type SecurityRulesMap as aC, type SendEmailInput as aD, type SendPushNotificationInput as aE, type SnapshotEvent as aF, type StorageBucket as aG, type StorageBucketInput as aH, type StorageObjectMeta as aI, type StorageProgress as aJ, type StorageSignedUrlInput as aK, type StreamFlushReason as aL, type StructuredJoinClause as aM, type StructuredQuery as aN, type SubscribeOptions as aO, type SubscriptionCallback as aP, type SubscriptionData as aQ, type SubscriptionError as aR, type SubscriptionErrorCallback as aS, type SubscriptionHandle as aT, type VectorFieldConfig as aU, type VectorSearchClause as aV, type VerifyEmailLinkInput as aW, type WhereCondition as aX, flareRulesToSecurityMap as aY, securityMapToFlareRules as aZ, type HavingClause as aa, type HeadObjectInput as ab, type HeadObjectsInput as ac, type JoinClause as ad, type JoinQueryPattern as ae, type ListObjectsInput as af, type ListObjectsResult as ag, type NestedJoinClause as ah, type OfflineOperation as ai, type OrFilter as aj, type OrderByClause as ak, type PresenceCallback as al, type PresenceJoinCallback as am, type PresenceLeaveCallback as an, type PresenceMember as ao, type PushSendResult as ap, type PutObjectInput as aq, type PutObjectResult as ar, type QueryConfig as as, type QueryOperator as at, type QueryPresetMap as au, type QueryPresetParams as av, type QueryPresetRow as aw, type QueryPresetSpec as ax, type QuerySnapshot as ay, type RegisterPushTokenInput as az, type AndFilter as b, type AnyFilter as c, type AuthConfigListener as d, type AuthResult as e, type AuthStateListener as f, type AuthWithPendingVerificationResult as g, type AuthWithTokenResult as h, type BrowserPushTokenOptions as i, type BucketCorsRule as j, type BucketPolicyInput as k, type ChangeOperation as l, type CollectionExternalStore as m, type CollectionStream as n, type CollectionStreamListener as o, type CollectionStreamMeta as p, type CollectionStreamOptions as q, type ConnectionState as r, type CopyObjectInput as s, type CursorValue as t, type DataMapperRegistry as u, type DeleteObjectInput as v, type DeleteObjectsInput as w, type DocAddedCallback as x, type DocChangedCallback as y, type DocDeletedCallback as z };