@zuzjs/flare 0.2.17 → 0.2.19
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 +235 -0
- package/dist/grpc.d.cts +1 -1
- package/dist/grpc.d.ts +1 -1
- package/dist/{index-B8jyF1xs.d.ts → index-EwoU5mWk.d.cts} +236 -2
- package/dist/{index-B2YceCms.d.cts → index-GvnP1-Os.d.ts} +236 -2
- package/dist/{index-BAvE1URE.d.cts → index-Y0Mq_6P9.d.cts} +355 -1
- package/dist/{index-BAvE1URE.d.ts → index-Y0Mq_6P9.d.ts} +355 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/dist/react.d.cts +2 -2
- package/dist/react.d.ts +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -509,6 +509,241 @@ const boards = await app
|
|
|
509
509
|
|
|
510
510
|
Tip: If your join alias is `team`, define `dataMapper.team` (not `dataMapper.users`) for that join payload.
|
|
511
511
|
|
|
512
|
+
### Storage API (S3-like)
|
|
513
|
+
|
|
514
|
+
```ts
|
|
515
|
+
import { connectApp, FlareStorageSignedAction } from '@zuzjs/flare';
|
|
516
|
+
|
|
517
|
+
const app = connectApp({
|
|
518
|
+
endpoint: 'https://flare.zuzcdn.net',
|
|
519
|
+
appId: 'my-app',
|
|
520
|
+
apiKey: 'ak',
|
|
521
|
+
storage: {
|
|
522
|
+
/**
|
|
523
|
+
* Built-in transfer manager — serialises uploads/downloads so calling
|
|
524
|
+
* putObject / getObject without `await` is always safe.
|
|
525
|
+
*/
|
|
526
|
+
transferManager: {
|
|
527
|
+
enabled: true,
|
|
528
|
+
uploadConcurrency: 1, // one upload at a time (default)
|
|
529
|
+
downloadConcurrency: 2, // allow two parallel downloads
|
|
530
|
+
},
|
|
531
|
+
},
|
|
532
|
+
});
|
|
533
|
+
|
|
534
|
+
const storage = app.storage();
|
|
535
|
+
|
|
536
|
+
await storage.createBucket('avatars');
|
|
537
|
+
|
|
538
|
+
// ── Raw binary upload (default) ──────────────────────────────────────────────
|
|
539
|
+
// By default putObject uploads files via a signed URL as raw binary.
|
|
540
|
+
// This is efficient for any file size and provides upload progress in browsers.
|
|
541
|
+
const uploaded = await storage.putObject({
|
|
542
|
+
bucket: 'avatars',
|
|
543
|
+
key: 'users/alice.png',
|
|
544
|
+
body: fileOrBlobOrBytes,
|
|
545
|
+
contentType: 'image/png',
|
|
546
|
+
onProgress: (p) => {
|
|
547
|
+
console.log(`uploaded ${p.loaded}/${p.total} (${p.percent}%)`);
|
|
548
|
+
},
|
|
549
|
+
});
|
|
550
|
+
|
|
551
|
+
// ── Base64 upload (opt-in, small files only) ─────────────────────────────────
|
|
552
|
+
// Pass `base64: true` to use the legacy base64-over-JSON path.
|
|
553
|
+
// If the payload exceeds `base64MaxBytes` (default 4 MiB), the SDK
|
|
554
|
+
// automatically falls back to raw signed-URL upload.
|
|
555
|
+
const uploaded2 = await storage.putObject({
|
|
556
|
+
bucket: 'avatars',
|
|
557
|
+
key: 'users/thumb.png',
|
|
558
|
+
body: smallFileBytes,
|
|
559
|
+
contentType: 'image/png',
|
|
560
|
+
base64: true, // prefer base64 path
|
|
561
|
+
base64MaxBytes: 2 * 1024 * 1024, // cap at 2 MiB; larger → raw upload
|
|
562
|
+
});
|
|
563
|
+
|
|
564
|
+
// ── Pre-encoded base64 (always uses base64 path) ─────────────────────────────
|
|
565
|
+
const uploaded3 = await storage.putObject({
|
|
566
|
+
bucket: 'avatars',
|
|
567
|
+
key: 'users/icon.png',
|
|
568
|
+
contentBase64: alreadyEncodedString,
|
|
569
|
+
contentType: 'image/png',
|
|
570
|
+
});
|
|
571
|
+
|
|
572
|
+
const head = await storage.headObject({ bucket: 'avatars', key: uploaded.key });
|
|
573
|
+
const file = await storage.getObject({ bucket: 'avatars', key: uploaded.key });
|
|
574
|
+
|
|
575
|
+
const page1 = await storage.listObjects({ bucket: 'avatars', prefix: 'users/', limit: 100 });
|
|
576
|
+
const page2 = page1.cursor
|
|
577
|
+
? await storage.listObjects({ bucket: 'avatars', prefix: 'users/', limit: 100, cursor: page1.cursor })
|
|
578
|
+
: { objects: [] };
|
|
579
|
+
|
|
580
|
+
await storage.copyObject({
|
|
581
|
+
sourceBucket: 'avatars',
|
|
582
|
+
sourceKey: 'users/alice.png',
|
|
583
|
+
destBucket: 'avatars-backup',
|
|
584
|
+
destKey: 'users/alice.png',
|
|
585
|
+
});
|
|
586
|
+
|
|
587
|
+
await storage.deleteObjects({
|
|
588
|
+
bucket: 'avatars',
|
|
589
|
+
keys: ['users/alice.png', 'users/bob.png'],
|
|
590
|
+
});
|
|
591
|
+
|
|
592
|
+
const signedUpload = await storage.createSignedUrl({
|
|
593
|
+
bucket: 'media',
|
|
594
|
+
key: 'uploads/clip.mp4',
|
|
595
|
+
action: FlareStorageSignedAction.Upload,
|
|
596
|
+
expiresInSeconds: 300,
|
|
597
|
+
contentType: 'video/mp4',
|
|
598
|
+
encrypt: true,
|
|
599
|
+
});
|
|
600
|
+
|
|
601
|
+
await fetch(signedUpload.url, {
|
|
602
|
+
method: signedUpload.method,
|
|
603
|
+
headers: { 'Content-Type': 'video/mp4' },
|
|
604
|
+
body: videoBlob,
|
|
605
|
+
});
|
|
606
|
+
```
|
|
607
|
+
|
|
608
|
+
Direct helpers are also available on the app instance:
|
|
609
|
+
|
|
610
|
+
```ts
|
|
611
|
+
await app.createBucket('files');
|
|
612
|
+
await app.putObject({ bucket: 'files', key: 'docs/readme.txt', body: 'hello' });
|
|
613
|
+
const doc = await app.getObject({ bucket: 'files', key: 'docs/readme.txt' });
|
|
614
|
+
await app.deleteObject({ bucket: 'files', key: 'docs/readme.txt' });
|
|
615
|
+
|
|
616
|
+
const signedDownload = await app.createSignedUrl({
|
|
617
|
+
bucket: 'files',
|
|
618
|
+
key: 'docs/readme.txt',
|
|
619
|
+
action: FlareStorageSignedAction.Download,
|
|
620
|
+
expiresInSeconds: 120,
|
|
621
|
+
});
|
|
622
|
+
|
|
623
|
+
console.log('signed url expires at unix seconds', signedDownload.expiresAt);
|
|
624
|
+
console.log('signed url ttl seconds', signedDownload.expiresInSeconds);
|
|
625
|
+
```
|
|
626
|
+
|
|
627
|
+
### Signed URL Download Policies
|
|
628
|
+
|
|
629
|
+
`token` (for example `st_...`) is only a ticket identifier. Expiry is enforced server-side and returned via `expiresAt` / `expiresInSeconds`.
|
|
630
|
+
|
|
631
|
+
```ts
|
|
632
|
+
import { connectApp, FlareStorageSignedAction } from '@zuzjs/flare';
|
|
633
|
+
|
|
634
|
+
const app = connectApp({ endpoint: 'https://flare.zuzcdn.net', appId: 'my-app', apiKey: 'ak' });
|
|
635
|
+
const storage = app.storage();
|
|
636
|
+
|
|
637
|
+
const signed = await storage.createSignedUrl({
|
|
638
|
+
bucket: 'media',
|
|
639
|
+
key: 'videos/intro.mp4',
|
|
640
|
+
action: FlareStorageSignedAction.Download,
|
|
641
|
+
expiresInSeconds: 180,
|
|
642
|
+
forceDownload: true,
|
|
643
|
+
allowedOrigins: ['https://app.example.com'],
|
|
644
|
+
embedOnly: false,
|
|
645
|
+
});
|
|
646
|
+
|
|
647
|
+
console.log(signed.url, signed.expiresAt, signed.expiresInSeconds);
|
|
648
|
+
```
|
|
649
|
+
|
|
650
|
+
Helper APIs:
|
|
651
|
+
|
|
652
|
+
```ts
|
|
653
|
+
// 1) Get a direct signed download URL.
|
|
654
|
+
const url = await storage.getObjectUrl({
|
|
655
|
+
bucket: 'media',
|
|
656
|
+
key: 'images/hero.png',
|
|
657
|
+
expiresInSeconds: 90,
|
|
658
|
+
allowedOrigins: ['*'],
|
|
659
|
+
});
|
|
660
|
+
|
|
661
|
+
// 2) Trigger browser download (defaults to forceDownload: true).
|
|
662
|
+
await storage.downloadObject({
|
|
663
|
+
bucket: 'media',
|
|
664
|
+
key: 'images/hero.png',
|
|
665
|
+
filename: 'hero.png',
|
|
666
|
+
expiresInSeconds: 90,
|
|
667
|
+
allowedOrigins: ['https://app.example.com'],
|
|
668
|
+
forceDownload: true,
|
|
669
|
+
});
|
|
670
|
+
|
|
671
|
+
// 3) Embed-only URL for media tags (<img>, <video>, <audio>).
|
|
672
|
+
const embedUrl = await storage.getObjectUrl({
|
|
673
|
+
bucket: 'media',
|
|
674
|
+
key: 'videos/trailer.mp4',
|
|
675
|
+
embedOnly: true,
|
|
676
|
+
allowedOrigins: ['https://app.example.com'],
|
|
677
|
+
});
|
|
678
|
+
```
|
|
679
|
+
|
|
680
|
+
Notes:
|
|
681
|
+
- `forceDownload` and `embedOnly` are mutually exclusive.
|
|
682
|
+
- `allowedOrigins` defaults to `['*']` when omitted.
|
|
683
|
+
- `embedOnly` is valid only for download signed URLs.
|
|
684
|
+
|
|
685
|
+
### Transfer Manager
|
|
686
|
+
|
|
687
|
+
The built-in transfer manager queues uploads and downloads so fire-and-forget calls
|
|
688
|
+
remain safe without needing a manual `await` at the call site.
|
|
689
|
+
|
|
690
|
+
```ts
|
|
691
|
+
const app = connectApp({
|
|
692
|
+
endpoint: 'https://flare.zuzcdn.net',
|
|
693
|
+
appId: 'my-app',
|
|
694
|
+
apiKey: 'ak',
|
|
695
|
+
storage: {
|
|
696
|
+
transferManager: {
|
|
697
|
+
enabled: true,
|
|
698
|
+
uploadConcurrency: 1, // default — uploads are serialised
|
|
699
|
+
downloadConcurrency: 2, // allow two downloads in parallel
|
|
700
|
+
},
|
|
701
|
+
},
|
|
702
|
+
});
|
|
703
|
+
|
|
704
|
+
const storage = app.storage();
|
|
705
|
+
|
|
706
|
+
// All three uploads are queued and executed one at a time — no race conditions.
|
|
707
|
+
storage.putObject({ bucket: 'files', key: 'a.png', body: blobA });
|
|
708
|
+
storage.putObject({ bucket: 'files', key: 'b.png', body: blobB });
|
|
709
|
+
storage.putObject({ bucket: 'files', key: 'c.png', body: blobC });
|
|
710
|
+
|
|
711
|
+
// Or await them individually for ordered results.
|
|
712
|
+
const [resA, resB] = await Promise.all([
|
|
713
|
+
storage.putObject({ bucket: 'files', key: 'a.png', body: blobA }),
|
|
714
|
+
storage.putObject({ bucket: 'files', key: 'b.png', body: blobB }),
|
|
715
|
+
]);
|
|
716
|
+
console.log(resA.key, resB.key);
|
|
717
|
+
```
|
|
718
|
+
|
|
719
|
+
### External AWS SDK Init From Flare `/aws` Config
|
|
720
|
+
|
|
721
|
+
bucket: 'media',
|
|
722
|
+
key: 'uploads/clip.mp4',
|
|
723
|
+
import { connectApp } from '@zuzjs/flare';
|
|
724
|
+
|
|
725
|
+
const app = connectApp({ endpoint: 'https://flare.zuzcdn.net', appId: 'my-app', apiKey: 'ak' });
|
|
726
|
+
|
|
727
|
+
const aws = await app.getStorageServerAwsConfig('storage-server-id');
|
|
728
|
+
|
|
729
|
+
const s3 = new S3Client({
|
|
730
|
+
endpoint: aws.endpoint,
|
|
731
|
+
region: aws.region,
|
|
732
|
+
forcePathStyle: Boolean(aws.forcePathStyle),
|
|
733
|
+
credentials: {
|
|
734
|
+
accessKeyId: aws.accessKeyId,
|
|
735
|
+
secretAccessKey: aws.secretAccessKey,
|
|
736
|
+
},
|
|
737
|
+
});
|
|
738
|
+
|
|
739
|
+
await s3.send(new PutObjectCommand({
|
|
740
|
+
Bucket: aws.bucket,
|
|
741
|
+
Key: `${aws.prefix ?? ''}manual/test.txt`,
|
|
742
|
+
Body: 'hello from external sdk',
|
|
743
|
+
ContentType: 'text/plain',
|
|
744
|
+
}));
|
|
745
|
+
```
|
|
746
|
+
|
|
512
747
|
### Template-Based Email APIs
|
|
513
748
|
|
|
514
749
|
### Security Rules Example (Boards Owner Or Team Member)
|
package/dist/grpc.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as FlareConfig,
|
|
1
|
+
import { F as FlareConfig, aN as StructuredQuery } from './index-Y0Mq_6P9.cjs';
|
|
2
2
|
import '@zuzjs/auth';
|
|
3
3
|
|
|
4
4
|
declare function runGrpcQuery<T = Record<string, unknown>>(config: FlareConfig, collection: string, query: StructuredQuery): Promise<T[] | null>;
|
package/dist/grpc.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as FlareConfig,
|
|
1
|
+
import { F as FlareConfig, aN as StructuredQuery } from './index-Y0Mq_6P9.js';
|
|
2
2
|
import '@zuzjs/auth';
|
|
3
3
|
|
|
4
4
|
declare function runGrpcQuery<T = Record<string, unknown>>(config: FlareConfig, collection: string, query: StructuredQuery): Promise<T[] | null>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { aX as WhereCondition, aP as SubscriptionCallback, as as QueryConfig, E as DocUpdatedCallback, z as DocDeletedCallback, y as DocChangedCallback, au as QueryPresetMap, av as QueryPresetParams, aw as QueryPresetRow, a as AggregateSpec, aa as HavingClause, ad as JoinClause, aV as VectorSearchClause, aN as StructuredQuery, aT as SubscriptionHandle, q as CollectionStreamOptions, n as CollectionStream, m as CollectionExternalStore, x as DocAddedCallback, F as FlareConfig, aO as SubscribeOptions, aS as SubscriptionErrorCallback, aR as SubscriptionError, r as ConnectionState, al as PresenceCallback, am as PresenceJoinCallback, an as PresenceLeaveCallback, aU as VectorFieldConfig, ax as QueryPresetSpec, a4 as FlareStorageTransferManagerConfig, aJ as StorageProgress, aH as StorageBucketInput, aG as StorageBucket, k as BucketPolicyInput, Z as FlareStorageRulesPolicy, j as BucketCorsRule, Y as FlareStorageRulesHistoryResult, aq as PutObjectInput, ar as PutObjectResult, a6 as GetObjectInput, a7 as GetObjectResult, a8 as GetObjectUrlInput, H as DownloadObjectInput, I as DownloadObjectResult, ab as HeadObjectInput, aI as StorageObjectMeta, ac as HeadObjectsInput, af as ListObjectsInput, ag as ListObjectsResult, s as CopyObjectInput, v as DeleteObjectInput, w as DeleteObjectsInput, aK as StorageSignedUrlInput, a3 as FlareStorageSignedUrlResult, L as FlareAuthConfig, f as AuthStateListener, d as AuthConfigListener, Q as FlareAuthSession, R as FlareAuthUser, M as FlareAuthHydrationInput, N as FlareAuthHydrationOptions, i as BrowserPushTokenOptions, B as BrowserPushRegistrationOptions, az as RegisterPushTokenInput, aE as SendPushNotificationInput, ap as PushSendResult, e as AuthResult } from './index-Y0Mq_6P9.cjs';
|
|
2
2
|
import { AuthToken } from '@zuzjs/auth';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -508,6 +508,168 @@ declare class FlareBase<TPresetMap extends QueryPresetMap = {}> {
|
|
|
508
508
|
protected handleIncoming(msg: any): void;
|
|
509
509
|
}
|
|
510
510
|
|
|
511
|
+
interface FlareStorageTransport {
|
|
512
|
+
readonly appId: string;
|
|
513
|
+
readonly transferManager?: FlareStorageTransferManagerConfig;
|
|
514
|
+
call(topic: string, payload?: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
515
|
+
subscribe(subId: string, collection: string, docId: string | undefined, query: unknown, callback: (event: any) => void, options?: {
|
|
516
|
+
skipSnapshot?: boolean;
|
|
517
|
+
}): () => void;
|
|
518
|
+
doPost(label: string, path: string, body: unknown): Promise<Record<string, unknown>>;
|
|
519
|
+
doGet(label: string, path: string): Promise<Record<string, unknown>>;
|
|
520
|
+
doPostWithProgress(label: string, path: string, body: unknown, onProgress: (p: StorageProgress) => void): Promise<Record<string, unknown>>;
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* S3-compatible storage service returned by `app.storage()`.
|
|
524
|
+
*
|
|
525
|
+
* Works with bucket **names** (not internal server IDs). Server IDs are
|
|
526
|
+
* resolved lazily and cached. `putObject()` automatically creates the bucket
|
|
527
|
+
* if it does not yet exist.
|
|
528
|
+
*/
|
|
529
|
+
declare class FlareStorage {
|
|
530
|
+
private readonly _t;
|
|
531
|
+
private readonly _transferEnabled;
|
|
532
|
+
private readonly _uploadLimiter;
|
|
533
|
+
private readonly _downloadLimiter;
|
|
534
|
+
/** bucket-name → serverId cache */
|
|
535
|
+
private readonly _bucketCache;
|
|
536
|
+
private _bucketListLoaded;
|
|
537
|
+
private _bucketListPromise;
|
|
538
|
+
constructor(transport: FlareStorageTransport);
|
|
539
|
+
private _scheduleUpload;
|
|
540
|
+
private _scheduleDownload;
|
|
541
|
+
private _ensureBuckets;
|
|
542
|
+
private _loadBuckets;
|
|
543
|
+
private _invalidateBucketCache;
|
|
544
|
+
/**
|
|
545
|
+
* Resolves a bucket name to its internal serverId.
|
|
546
|
+
* When `autoCreate` is true, creates the bucket if it does not exist.
|
|
547
|
+
*/
|
|
548
|
+
private _resolveBucketId;
|
|
549
|
+
private _appPath;
|
|
550
|
+
private _bucketStreamCollection;
|
|
551
|
+
private _objectStreamCollection;
|
|
552
|
+
private _subscribeStorage;
|
|
553
|
+
/**
|
|
554
|
+
* Creates a new bucket (storage server) for the app.
|
|
555
|
+
*
|
|
556
|
+
* Idempotent: if a bucket with this name already exists the existing one
|
|
557
|
+
* is returned unchanged (same behaviour as AWS S3 for same-owner buckets).
|
|
558
|
+
*/
|
|
559
|
+
createBucket(name: string, options?: StorageBucketInput): Promise<StorageBucket>;
|
|
560
|
+
private _listBucketsRaw;
|
|
561
|
+
/** Returns all buckets for the app. */
|
|
562
|
+
listBuckets(): Promise<StorageBucket[]>;
|
|
563
|
+
/** Deletes a bucket and all its objects. */
|
|
564
|
+
deleteBucket(name: string): Promise<{
|
|
565
|
+
ok: boolean;
|
|
566
|
+
removedObjects: number;
|
|
567
|
+
}>;
|
|
568
|
+
/** Deletes multiple buckets. */
|
|
569
|
+
deleteBuckets(names: string[]): Promise<{
|
|
570
|
+
ok: boolean;
|
|
571
|
+
deleted: string[];
|
|
572
|
+
errors: Record<string, string>;
|
|
573
|
+
}>;
|
|
574
|
+
/** Returns location info for a bucket (kind, region, endpoint). */
|
|
575
|
+
getBucketLocation(name: string): Promise<{
|
|
576
|
+
bucket: string;
|
|
577
|
+
kind: string;
|
|
578
|
+
region?: string;
|
|
579
|
+
endpoint?: string;
|
|
580
|
+
}>;
|
|
581
|
+
onBucketAdded(callback: (bucket: StorageBucket, bucketId: string) => void): () => void;
|
|
582
|
+
onBucketUpdated(callback: (bucket: StorageBucket, bucketId: string) => void): () => void;
|
|
583
|
+
onBucketDeleted(callback: (bucketId: string) => void): () => void;
|
|
584
|
+
/**
|
|
585
|
+
* Sets security rules for storage.
|
|
586
|
+
* Rules apply app-wide (all buckets share the same rules DSL).
|
|
587
|
+
*/
|
|
588
|
+
putBucketPolicy(input: BucketPolicyInput): Promise<{
|
|
589
|
+
id: string;
|
|
590
|
+
}>;
|
|
591
|
+
/** Gets the current storage rules policy. */
|
|
592
|
+
getBucketPolicy(): Promise<{
|
|
593
|
+
rulesDsl?: string;
|
|
594
|
+
rules?: unknown;
|
|
595
|
+
policy: FlareStorageRulesPolicy;
|
|
596
|
+
}>;
|
|
597
|
+
/**
|
|
598
|
+
* Sets CORS rules for a bucket.
|
|
599
|
+
* Note: CORS is configured at the flare-node server level; this method
|
|
600
|
+
* stores the rules in app settings for reference.
|
|
601
|
+
*/
|
|
602
|
+
putBucketCors(_bucket: string, _rules: BucketCorsRule[]): Promise<{
|
|
603
|
+
ok: boolean;
|
|
604
|
+
}>;
|
|
605
|
+
/** Alias for putBucketCors. */
|
|
606
|
+
setBucketCors: (_bucket: string, _rules: BucketCorsRule[]) => Promise<{
|
|
607
|
+
ok: boolean;
|
|
608
|
+
}>;
|
|
609
|
+
/** Returns the full storage rules/policy history. */
|
|
610
|
+
rulesHistory(): Promise<FlareStorageRulesHistoryResult>;
|
|
611
|
+
/**
|
|
612
|
+
* Uploads an object to a bucket.
|
|
613
|
+
*
|
|
614
|
+
* The bucket is created automatically if it does not exist.
|
|
615
|
+
* Default path is direct raw upload via signed URL (no base64 encoding).
|
|
616
|
+
* Set `base64: true` to prefer legacy base64 upload for small payloads.
|
|
617
|
+
* Provide `onProgress` for upload progress updates (browser only).
|
|
618
|
+
*/
|
|
619
|
+
putObject(input: PutObjectInput): Promise<PutObjectResult>;
|
|
620
|
+
/**
|
|
621
|
+
* Downloads an object from a bucket.
|
|
622
|
+
* Returns base64-encoded content.
|
|
623
|
+
*/
|
|
624
|
+
getObject(input: GetObjectInput): Promise<GetObjectResult>;
|
|
625
|
+
/** Returns a short-lived signed URL for direct browser/object download. */
|
|
626
|
+
getObjectUrl(input: GetObjectUrlInput): Promise<string>;
|
|
627
|
+
/**
|
|
628
|
+
* Triggers browser download using a signed URL and returns the resolved URL.
|
|
629
|
+
* In non-browser runtimes, this only returns the URL without dispatching a click.
|
|
630
|
+
*/
|
|
631
|
+
downloadObject(input: DownloadObjectInput): Promise<DownloadObjectResult>;
|
|
632
|
+
/** Returns object metadata without downloading the content. */
|
|
633
|
+
headObject(input: HeadObjectInput): Promise<StorageObjectMeta>;
|
|
634
|
+
/** Returns metadata for multiple objects in parallel. */
|
|
635
|
+
headObjects(input: HeadObjectsInput): Promise<StorageObjectMeta[]>;
|
|
636
|
+
/**
|
|
637
|
+
* Lists objects in a bucket with optional prefix filter and pagination.
|
|
638
|
+
*
|
|
639
|
+
* Pass the returned `cursor` to the next call to page through results.
|
|
640
|
+
*/
|
|
641
|
+
listObjects(input: ListObjectsInput): Promise<ListObjectsResult>;
|
|
642
|
+
/**
|
|
643
|
+
* Copies an object from one bucket/key to another.
|
|
644
|
+
* Source and destination can be different buckets in the same app.
|
|
645
|
+
*/
|
|
646
|
+
copyObject(input: CopyObjectInput): Promise<{
|
|
647
|
+
ok: boolean;
|
|
648
|
+
}>;
|
|
649
|
+
/** Copies multiple objects. Runs concurrently. */
|
|
650
|
+
copyObjects(inputs: CopyObjectInput[]): Promise<{
|
|
651
|
+
ok: boolean;
|
|
652
|
+
errors: Record<string, string>;
|
|
653
|
+
}>;
|
|
654
|
+
/** Deletes a single object. */
|
|
655
|
+
deleteObject(input: DeleteObjectInput): Promise<{
|
|
656
|
+
ok: boolean;
|
|
657
|
+
}>;
|
|
658
|
+
/**
|
|
659
|
+
* Deletes multiple objects in a single server request.
|
|
660
|
+
*/
|
|
661
|
+
deleteObjects(input: DeleteObjectsInput): Promise<{
|
|
662
|
+
ok: boolean;
|
|
663
|
+
deleted: string[];
|
|
664
|
+
errors: Record<string, string>;
|
|
665
|
+
}>;
|
|
666
|
+
onObjectAdded(bucket: string, callback: (object: StorageObjectMeta, key: string) => void): () => void;
|
|
667
|
+
onObjectUpdated(bucket: string, callback: (object: StorageObjectMeta, key: string) => void): () => void;
|
|
668
|
+
onObjectDeleted(bucket: string, callback: (key: string) => void): () => void;
|
|
669
|
+
/** Issues a short-lived signed URL for direct client-to-flare uploads or downloads. */
|
|
670
|
+
createSignedUrl(input: StorageSignedUrlInput): Promise<FlareStorageSignedUrlResult>;
|
|
671
|
+
}
|
|
672
|
+
|
|
511
673
|
declare class FlareAuth<TPresetMap extends QueryPresetMap = {}> extends FlareBase<TPresetMap> {
|
|
512
674
|
static AUTH_TRACE_STORAGE_KEY: string;
|
|
513
675
|
protected pushServiceWorkerInitPromise?: Promise<ServiceWorkerRegistration | null>;
|
|
@@ -527,6 +689,8 @@ declare class FlareAuth<TPresetMap extends QueryPresetMap = {}> extends FlareBas
|
|
|
527
689
|
protected csrfToken?: string;
|
|
528
690
|
protected csrfBootstrapAttempted: boolean;
|
|
529
691
|
protected csrfInitPromise?: Promise<void>;
|
|
692
|
+
/** Lazy singleton FlareStorage service. */
|
|
693
|
+
private _storageService;
|
|
530
694
|
protected isAuthTraceEnabled(): boolean;
|
|
531
695
|
protected traceAuth(event: string, details?: Record<string, unknown>): void;
|
|
532
696
|
setAuthTrace(enabled: boolean, persist?: boolean): void;
|
|
@@ -615,6 +779,76 @@ declare class FlareAuth<TPresetMap extends QueryPresetMap = {}> extends FlareBas
|
|
|
615
779
|
removed: boolean;
|
|
616
780
|
}>;
|
|
617
781
|
sendPushNotification(input: SendPushNotificationInput): Promise<PushSendResult>;
|
|
782
|
+
/**
|
|
783
|
+
* Returns the S3-compatible storage service for this app.
|
|
784
|
+
*
|
|
785
|
+
* Works with bucket **names** — no serverId needed.
|
|
786
|
+
* Buckets are created automatically on `putObject()` if they don't exist yet.
|
|
787
|
+
*
|
|
788
|
+
* @example
|
|
789
|
+
* const s = app.storage();
|
|
790
|
+
* await s.putObject({ bucket: 'avatars', key: 'alice.png', body: file });
|
|
791
|
+
* const { contentBase64 } = await s.getObject({ bucket: 'avatars', key: 'alice.png' });
|
|
792
|
+
*/
|
|
793
|
+
storage(): FlareStorage;
|
|
794
|
+
private _buildStorageTransport;
|
|
795
|
+
/** @see FlareStorage.putObject */
|
|
796
|
+
putObject(input: PutObjectInput): Promise<PutObjectResult>;
|
|
797
|
+
/** @see FlareStorage.getObject */
|
|
798
|
+
getObject(input: GetObjectInput): Promise<GetObjectResult>;
|
|
799
|
+
/** @see FlareStorage.getObjectUrl */
|
|
800
|
+
getObjectUrl(input: GetObjectUrlInput): Promise<string>;
|
|
801
|
+
/** @see FlareStorage.downloadObject */
|
|
802
|
+
downloadObject(input: DownloadObjectInput): Promise<DownloadObjectResult>;
|
|
803
|
+
/** @see FlareStorage.headObject */
|
|
804
|
+
headObject(input: HeadObjectInput): Promise<StorageObjectMeta>;
|
|
805
|
+
/** @see FlareStorage.headObjects */
|
|
806
|
+
headObjects(input: HeadObjectsInput): Promise<StorageObjectMeta[]>;
|
|
807
|
+
/** @see FlareStorage.listObjects */
|
|
808
|
+
listObjects(input: ListObjectsInput): Promise<ListObjectsResult>;
|
|
809
|
+
/** @see FlareStorage.copyObject */
|
|
810
|
+
copyObject(input: CopyObjectInput): Promise<{
|
|
811
|
+
ok: boolean;
|
|
812
|
+
}>;
|
|
813
|
+
/** @see FlareStorage.copyObjects */
|
|
814
|
+
copyObjects(inputs: CopyObjectInput[]): Promise<{
|
|
815
|
+
ok: boolean;
|
|
816
|
+
errors: Record<string, string>;
|
|
817
|
+
}>;
|
|
818
|
+
/** @see FlareStorage.deleteObject */
|
|
819
|
+
deleteObject(input: DeleteObjectInput): Promise<{
|
|
820
|
+
ok: boolean;
|
|
821
|
+
}>;
|
|
822
|
+
/** @see FlareStorage.deleteObjects */
|
|
823
|
+
deleteObjects(input: DeleteObjectsInput): Promise<{
|
|
824
|
+
ok: boolean;
|
|
825
|
+
deleted: string[];
|
|
826
|
+
errors: Record<string, string>;
|
|
827
|
+
}>;
|
|
828
|
+
/** @see FlareStorage.createBucket */
|
|
829
|
+
createBucket(name: string, options?: StorageBucketInput): Promise<StorageBucket>;
|
|
830
|
+
/** @see FlareStorage.listBuckets */
|
|
831
|
+
listBuckets(): Promise<StorageBucket[]>;
|
|
832
|
+
/** @see FlareStorage.deleteBucket */
|
|
833
|
+
deleteBucket(name: string): Promise<{
|
|
834
|
+
ok: boolean;
|
|
835
|
+
removedObjects: number;
|
|
836
|
+
}>;
|
|
837
|
+
/** @see FlareStorage.deleteBuckets */
|
|
838
|
+
deleteBuckets(names: string[]): Promise<{
|
|
839
|
+
ok: boolean;
|
|
840
|
+
deleted: string[];
|
|
841
|
+
errors: Record<string, string>;
|
|
842
|
+
}>;
|
|
843
|
+
/** @see FlareStorage.getBucketLocation */
|
|
844
|
+
getBucketLocation(name: string): Promise<{
|
|
845
|
+
bucket: string;
|
|
846
|
+
kind: string;
|
|
847
|
+
region?: string;
|
|
848
|
+
endpoint?: string;
|
|
849
|
+
}>;
|
|
850
|
+
/** @see FlareStorage.createSignedUrl */
|
|
851
|
+
createSignedUrl(input: StorageSignedUrlInput): Promise<FlareStorageSignedUrlResult>;
|
|
618
852
|
auth(token: string): Promise<AuthResult>;
|
|
619
853
|
private getAuthRequestContentType;
|
|
620
854
|
private buildAuthRequestBody;
|
|
@@ -826,4 +1060,4 @@ declare class FlareClient<TPresetMap extends QueryPresetMap = {}> extends FlareA
|
|
|
826
1060
|
autoEnablePushNotifications(): Promise<void>;
|
|
827
1061
|
}
|
|
828
1062
|
|
|
829
|
-
export { type BaseMessage as B, type CollectionPresetMethods as C, DocumentQueryBuilder as D, FlareClient as F, type SubscribeMessage as S, type CollectionQuery as a, CollectionReference as b, DocumentReference as c, FlareAction as d, FlareEvent as e,
|
|
1063
|
+
export { type BaseMessage as B, type CollectionPresetMethods as C, DocumentQueryBuilder as D, FlareClient as F, type SubscribeMessage as S, type CollectionQuery as a, CollectionReference as b, DocumentReference as c, FlareAction as d, FlareEvent as e, FlareStorage as f, parseWhereCondition as g, parseValue as p };
|