@zuzjs/flare 0.2.20 → 0.2.22
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 +59 -0
- package/dist/grpc.d.cts +1 -1
- package/dist/grpc.d.ts +1 -1
- package/dist/{index-Y0Mq_6P9.d.cts → index-18tMqAtM.d.cts} +46 -2
- package/dist/{index-Y0Mq_6P9.d.ts → index-18tMqAtM.d.ts} +46 -2
- package/dist/{index-CVwSnXPP.d.cts → index-CRByt4Qw.d.ts} +46 -2
- package/dist/{index-OUj3iEUt.d.ts → index-DOaU2Hxo.d.cts} +46 -2
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +30 -30
- package/dist/index.d.ts +30 -30
- package/dist/index.js +2 -2
- package/dist/react.cjs +1 -1
- package/dist/react.d.cts +41 -3
- package/dist/react.d.ts +41 -3
- package/dist/react.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -48,6 +48,51 @@ const same = getFlare();
|
|
|
48
48
|
disconnectFlare();
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
+
### Bulk Writes (Memory Efficient)
|
|
52
|
+
|
|
53
|
+
`addMany`, `updateMany`, and `deleteMany` process data in bounded chunks so very large input streams can run without loading everything into memory at once.
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
const users = app.collection<{ name: string; plan?: string }>('users');
|
|
57
|
+
|
|
58
|
+
// Add many from an array
|
|
59
|
+
const addResult = await users.addMany(
|
|
60
|
+
[{ name: 'Alice' }, { name: 'Bob' }],
|
|
61
|
+
{
|
|
62
|
+
batchSize: 500,
|
|
63
|
+
concurrency: 8,
|
|
64
|
+
onProgress: (p) => {
|
|
65
|
+
console.log('addMany', p.processed, p.total, p.percent);
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
// Update many by id
|
|
71
|
+
const updateResult = await users.updateMany(
|
|
72
|
+
[
|
|
73
|
+
{ id: 'user_1', data: { plan: 'pro' } },
|
|
74
|
+
{ id: 'user_2', data: { plan: 'team' } },
|
|
75
|
+
],
|
|
76
|
+
{ continueOnError: true },
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
// Delete many by id
|
|
80
|
+
const deleteResult = await users.deleteMany(['user_3', 'user_4']);
|
|
81
|
+
|
|
82
|
+
console.log({ addResult, updateResult, deleteResult });
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
// Stream input from an async source (best for huge datasets)
|
|
87
|
+
async function* rows() {
|
|
88
|
+
for (let i = 0; i < 1_000_000; i += 1) {
|
|
89
|
+
yield { name: `user-${i}` };
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
await app.collection('users').addMany(rows(), { batchSize: 1000, concurrency: 4 });
|
|
94
|
+
```
|
|
95
|
+
|
|
51
96
|
### Auth Config And State
|
|
52
97
|
|
|
53
98
|
```ts
|
|
@@ -548,6 +593,10 @@ const uploaded = await storage.putObject({
|
|
|
548
593
|
},
|
|
549
594
|
});
|
|
550
595
|
|
|
596
|
+
console.log(uploaded.key); // users/alice.png
|
|
597
|
+
console.log(uploaded.access); // public (default)
|
|
598
|
+
console.log(uploaded.url); // https://.../storage/public/<appId>/avatars/users%2Falice.png
|
|
599
|
+
|
|
551
600
|
// ── Base64 upload (opt-in, small files only) ─────────────────────────────────
|
|
552
601
|
// Pass `base64: true` to use the legacy base64-over-JSON path.
|
|
553
602
|
// If the payload exceeds `base64MaxBytes` (default 4 MiB), the SDK
|
|
@@ -557,6 +606,7 @@ const uploaded2 = await storage.putObject({
|
|
|
557
606
|
key: 'users/thumb.png',
|
|
558
607
|
body: smallFileBytes,
|
|
559
608
|
contentType: 'image/png',
|
|
609
|
+
access: 'private', // override the default public access
|
|
560
610
|
base64: true, // prefer base64 path
|
|
561
611
|
base64MaxBytes: 2 * 1024 * 1024, // cap at 2 MiB; larger → raw upload
|
|
562
612
|
});
|
|
@@ -567,12 +617,17 @@ const uploaded3 = await storage.putObject({
|
|
|
567
617
|
key: 'users/icon.png',
|
|
568
618
|
contentBase64: alreadyEncodedString,
|
|
569
619
|
contentType: 'image/png',
|
|
620
|
+
// encrypt defaults to false when omitted
|
|
570
621
|
});
|
|
571
622
|
|
|
572
623
|
const head = await storage.headObject({ bucket: 'avatars', key: uploaded.key });
|
|
624
|
+
console.log(head.access, head.url);
|
|
625
|
+
|
|
573
626
|
const file = await storage.getObject({ bucket: 'avatars', key: uploaded.key });
|
|
574
627
|
|
|
575
628
|
const page1 = await storage.listObjects({ bucket: 'avatars', prefix: 'users/', limit: 100 });
|
|
629
|
+
console.log(page1.objects[0]?.access, page1.objects[0]?.url);
|
|
630
|
+
|
|
576
631
|
const page2 = page1.cursor
|
|
577
632
|
? await storage.listObjects({ bucket: 'avatars', prefix: 'users/', limit: 100, cursor: page1.cursor })
|
|
578
633
|
: { objects: [] };
|
|
@@ -595,6 +650,7 @@ const signedUpload = await storage.createSignedUrl({
|
|
|
595
650
|
action: FlareStorageSignedAction.Upload,
|
|
596
651
|
expiresInSeconds: 300,
|
|
597
652
|
contentType: 'video/mp4',
|
|
653
|
+
access: 'private',
|
|
598
654
|
encrypt: true,
|
|
599
655
|
});
|
|
600
656
|
|
|
@@ -678,6 +734,9 @@ const embedUrl = await storage.getObjectUrl({
|
|
|
678
734
|
```
|
|
679
735
|
|
|
680
736
|
Notes:
|
|
737
|
+
- `putObject()` defaults to `encrypt: false` and `access: 'public'`.
|
|
738
|
+
- `uploaded.url` is the stable public object URL shape. Anonymous reads still depend on stored `access` and any storage rules configured on the app.
|
|
739
|
+
- `headObject()` and `listObjects()` also return `access` and `url` metadata.
|
|
681
740
|
- `forceDownload` and `embedOnly` are mutually exclusive.
|
|
682
741
|
- `allowedOrigins` defaults to `['*']` when omitted.
|
|
683
742
|
- `embedOnly` is valid only for download signed URLs.
|
package/dist/grpc.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as FlareConfig,
|
|
1
|
+
import { F as FlareConfig, aR as StructuredQuery } from './index-18tMqAtM.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, aR as StructuredQuery } from './index-18tMqAtM.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>;
|
|
@@ -264,6 +264,8 @@ interface FlareStorageObjectResult {
|
|
|
264
264
|
ok: boolean;
|
|
265
265
|
path: string;
|
|
266
266
|
key: string;
|
|
267
|
+
access?: "public" | "private";
|
|
268
|
+
url?: string;
|
|
267
269
|
encrypted?: boolean;
|
|
268
270
|
size?: number;
|
|
269
271
|
contentBase64?: string;
|
|
@@ -282,6 +284,7 @@ interface FlareStorageSignedUrlInput {
|
|
|
282
284
|
expiresInSeconds?: number;
|
|
283
285
|
sizeBytes?: number;
|
|
284
286
|
contentType?: string;
|
|
287
|
+
access?: "public" | "private";
|
|
285
288
|
encrypt?: boolean;
|
|
286
289
|
decrypt?: boolean;
|
|
287
290
|
forceDownload?: boolean;
|
|
@@ -370,6 +373,8 @@ interface StorageObjectMeta {
|
|
|
370
373
|
bucket: string;
|
|
371
374
|
size: number;
|
|
372
375
|
contentType: string;
|
|
376
|
+
access?: "public" | "private";
|
|
377
|
+
url?: string;
|
|
373
378
|
encrypted: boolean;
|
|
374
379
|
createdAt?: unknown;
|
|
375
380
|
updatedAt?: unknown;
|
|
@@ -402,7 +407,9 @@ interface PutObjectInput {
|
|
|
402
407
|
*/
|
|
403
408
|
base64MaxBytes?: number;
|
|
404
409
|
contentType?: string;
|
|
405
|
-
/**
|
|
410
|
+
/** Public/private object access. Defaults to public. */
|
|
411
|
+
access?: "public" | "private";
|
|
412
|
+
/** Encrypt at rest with AES-256-GCM. Defaults to false. */
|
|
406
413
|
encrypt?: boolean;
|
|
407
414
|
/** Upload progress callback. Only fires in browser environments. */
|
|
408
415
|
onProgress?: (progress: StorageProgress) => void;
|
|
@@ -411,6 +418,8 @@ interface PutObjectResult {
|
|
|
411
418
|
ok: boolean;
|
|
412
419
|
bucket: string;
|
|
413
420
|
key: string;
|
|
421
|
+
access: "public" | "private";
|
|
422
|
+
url?: string;
|
|
414
423
|
size: number;
|
|
415
424
|
encrypted: boolean;
|
|
416
425
|
}
|
|
@@ -503,6 +512,7 @@ interface StorageSignedUrlInput {
|
|
|
503
512
|
expiresInSeconds?: number;
|
|
504
513
|
sizeBytes?: number;
|
|
505
514
|
contentType?: string;
|
|
515
|
+
access?: "public" | "private";
|
|
506
516
|
encrypt?: boolean;
|
|
507
517
|
decrypt?: boolean;
|
|
508
518
|
forceDownload?: boolean;
|
|
@@ -732,6 +742,40 @@ type DocAddedCallback<T = any> = (data: T, docId: string) => void;
|
|
|
732
742
|
type DocUpdatedCallback<T = any> = (data: T, docId: string) => void;
|
|
733
743
|
type DocDeletedCallback<T = any> = (docId: string) => void;
|
|
734
744
|
type DocChangedCallback<T = any> = (data: T | null, docId: string, operation: ChangeOperation) => void;
|
|
745
|
+
type BulkWriteOperation = 'addMany' | 'updateMany' | 'deleteMany';
|
|
746
|
+
interface BulkWriteProgress {
|
|
747
|
+
operation: BulkWriteOperation;
|
|
748
|
+
processed: number;
|
|
749
|
+
succeeded: number;
|
|
750
|
+
failed: number;
|
|
751
|
+
total?: number;
|
|
752
|
+
percent?: number;
|
|
753
|
+
lastDocId?: string;
|
|
754
|
+
lastError?: unknown;
|
|
755
|
+
}
|
|
756
|
+
interface BulkWriteResult {
|
|
757
|
+
operation: BulkWriteOperation;
|
|
758
|
+
processed: number;
|
|
759
|
+
succeeded: number;
|
|
760
|
+
failed: number;
|
|
761
|
+
total?: number;
|
|
762
|
+
}
|
|
763
|
+
interface BulkWriteOptions {
|
|
764
|
+
/** How many operations to execute per chunk; defaults to 250. */
|
|
765
|
+
batchSize?: number;
|
|
766
|
+
/** Number of in-flight writes within each chunk; defaults to 1. */
|
|
767
|
+
concurrency?: number;
|
|
768
|
+
/** Continue processing remaining items after individual failures. */
|
|
769
|
+
continueOnError?: boolean;
|
|
770
|
+
/** Optional cancellation signal for long-running bulk writes. */
|
|
771
|
+
signal?: AbortSignal;
|
|
772
|
+
/** Progress callback invoked after each processed item. */
|
|
773
|
+
onProgress?: (progress: BulkWriteProgress) => void;
|
|
774
|
+
}
|
|
775
|
+
interface UpdateManyItem<T = any> {
|
|
776
|
+
id: string;
|
|
777
|
+
data: Partial<T>;
|
|
778
|
+
}
|
|
735
779
|
type StreamFlushReason = 'snapshot' | 'change-batch';
|
|
736
780
|
interface CollectionStreamOptions<T = any> {
|
|
737
781
|
/** Delay before a queued burst is flushed to listeners. */
|
|
@@ -862,4 +906,4 @@ type SecurityRulesMap = Record<string, SecurityRuleEntry>;
|
|
|
862
906
|
declare const flareRulesToSecurityMap: (rules: FlareRule[]) => SecurityRulesMap;
|
|
863
907
|
declare const securityMapToFlareRules: (rules: SecurityRulesMap) => FlareRule[];
|
|
864
908
|
|
|
865
|
-
export { type
|
|
909
|
+
export { type FlareStorageObjectResult as $, type AggregateFunction as A, type BrowserPushRegistrationOptions as B, type ChangeEvent as C, type DataMapperFn as D, type DeleteObjectsInput as E, type FlareConfig as F, type DocAddedCallback as G, type DocChangedCallback as H, type DocDeletedCallback as I, type DocUpdatedCallback as J, type DocumentSnapshot as K, type DownloadObjectInput as L, type DownloadObjectResult as M, type EmailLinkVerifyResult as N, type EmailSendResult as O, type FlareAuthConfig as P, type FlareAuthHydrationInput as Q, type FlareAuthHydrationOptions as R, type FlareAuthProviderId as S, type FlareAuthProviderPublicConfig as T, type FlareAuthSession as U, type FlareAuthUser as V, type FlareRule as W, type FlareStorageAutoConfig as X, type FlareStorageAwsConfig as Y, type FlareStorageDeleteInput as Z, type FlareStorageDownloadInput as _, type AggregateSpec as a, type VerifyEmailLinkInput as a$, type FlareStorageRulesHistoryResult as a0, type FlareStorageRulesPolicy as a1, type FlareStorageServer as a2, type FlareStorageServerInput as a3, type FlareStorageServerPatchInput as a4, FlareStorageSignedAction as a5, type FlareStorageSignedUrlInput as a6, type FlareStorageSignedUrlResult as a7, type FlareStorageTransferManagerConfig as a8, type FlareStorageUploadInput as a9, type QueryPresetRow as aA, type QueryPresetSpec as aB, type QuerySnapshot as aC, type RegisterPushTokenInput as aD, type RulePermission as aE, type SecurityRuleEntry as aF, type SecurityRulesMap as aG, type SendEmailInput as aH, type SendPushNotificationInput as aI, type SnapshotEvent as aJ, type StorageBucket as aK, type StorageBucketInput as aL, type StorageObjectMeta as aM, type StorageProgress as aN, type StorageSignedUrlInput as aO, type StreamFlushReason as aP, type StructuredJoinClause as aQ, type StructuredQuery as aR, type SubscribeOptions as aS, type SubscriptionCallback as aT, type SubscriptionData as aU, type SubscriptionError as aV, type SubscriptionErrorCallback as aW, type SubscriptionHandle as aX, type UpdateManyItem as aY, type VectorFieldConfig as aZ, type VectorSearchClause as a_, type GetObjectInput as aa, type GetObjectResult as ab, type GetObjectUrlInput as ac, type GroupByClause as ad, type HavingClause as ae, type HeadObjectInput as af, type HeadObjectsInput as ag, type JoinClause as ah, type JoinQueryPattern as ai, type ListObjectsInput as aj, type ListObjectsResult as ak, type NestedJoinClause as al, type OfflineOperation as am, type OrFilter as an, type OrderByClause as ao, type PresenceCallback as ap, type PresenceJoinCallback as aq, type PresenceLeaveCallback as ar, type PresenceMember as as, type PushSendResult as at, type PutObjectInput as au, type PutObjectResult as av, type QueryConfig as aw, type QueryOperator as ax, type QueryPresetMap as ay, type QueryPresetParams as az, type AndFilter as b, type WhereCondition as b0, flareRulesToSecurityMap as b1, securityMapToFlareRules as b2, 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 BulkWriteOperation as l, type BulkWriteOptions as m, type BulkWriteProgress as n, type BulkWriteResult as o, type ChangeOperation as p, type CollectionExternalStore as q, type CollectionStream as r, type CollectionStreamListener as s, type CollectionStreamMeta as t, type CollectionStreamOptions as u, type ConnectionState as v, type CopyObjectInput as w, type CursorValue as x, type DataMapperRegistry as y, type DeleteObjectInput as z };
|
|
@@ -264,6 +264,8 @@ interface FlareStorageObjectResult {
|
|
|
264
264
|
ok: boolean;
|
|
265
265
|
path: string;
|
|
266
266
|
key: string;
|
|
267
|
+
access?: "public" | "private";
|
|
268
|
+
url?: string;
|
|
267
269
|
encrypted?: boolean;
|
|
268
270
|
size?: number;
|
|
269
271
|
contentBase64?: string;
|
|
@@ -282,6 +284,7 @@ interface FlareStorageSignedUrlInput {
|
|
|
282
284
|
expiresInSeconds?: number;
|
|
283
285
|
sizeBytes?: number;
|
|
284
286
|
contentType?: string;
|
|
287
|
+
access?: "public" | "private";
|
|
285
288
|
encrypt?: boolean;
|
|
286
289
|
decrypt?: boolean;
|
|
287
290
|
forceDownload?: boolean;
|
|
@@ -370,6 +373,8 @@ interface StorageObjectMeta {
|
|
|
370
373
|
bucket: string;
|
|
371
374
|
size: number;
|
|
372
375
|
contentType: string;
|
|
376
|
+
access?: "public" | "private";
|
|
377
|
+
url?: string;
|
|
373
378
|
encrypted: boolean;
|
|
374
379
|
createdAt?: unknown;
|
|
375
380
|
updatedAt?: unknown;
|
|
@@ -402,7 +407,9 @@ interface PutObjectInput {
|
|
|
402
407
|
*/
|
|
403
408
|
base64MaxBytes?: number;
|
|
404
409
|
contentType?: string;
|
|
405
|
-
/**
|
|
410
|
+
/** Public/private object access. Defaults to public. */
|
|
411
|
+
access?: "public" | "private";
|
|
412
|
+
/** Encrypt at rest with AES-256-GCM. Defaults to false. */
|
|
406
413
|
encrypt?: boolean;
|
|
407
414
|
/** Upload progress callback. Only fires in browser environments. */
|
|
408
415
|
onProgress?: (progress: StorageProgress) => void;
|
|
@@ -411,6 +418,8 @@ interface PutObjectResult {
|
|
|
411
418
|
ok: boolean;
|
|
412
419
|
bucket: string;
|
|
413
420
|
key: string;
|
|
421
|
+
access: "public" | "private";
|
|
422
|
+
url?: string;
|
|
414
423
|
size: number;
|
|
415
424
|
encrypted: boolean;
|
|
416
425
|
}
|
|
@@ -503,6 +512,7 @@ interface StorageSignedUrlInput {
|
|
|
503
512
|
expiresInSeconds?: number;
|
|
504
513
|
sizeBytes?: number;
|
|
505
514
|
contentType?: string;
|
|
515
|
+
access?: "public" | "private";
|
|
506
516
|
encrypt?: boolean;
|
|
507
517
|
decrypt?: boolean;
|
|
508
518
|
forceDownload?: boolean;
|
|
@@ -732,6 +742,40 @@ type DocAddedCallback<T = any> = (data: T, docId: string) => void;
|
|
|
732
742
|
type DocUpdatedCallback<T = any> = (data: T, docId: string) => void;
|
|
733
743
|
type DocDeletedCallback<T = any> = (docId: string) => void;
|
|
734
744
|
type DocChangedCallback<T = any> = (data: T | null, docId: string, operation: ChangeOperation) => void;
|
|
745
|
+
type BulkWriteOperation = 'addMany' | 'updateMany' | 'deleteMany';
|
|
746
|
+
interface BulkWriteProgress {
|
|
747
|
+
operation: BulkWriteOperation;
|
|
748
|
+
processed: number;
|
|
749
|
+
succeeded: number;
|
|
750
|
+
failed: number;
|
|
751
|
+
total?: number;
|
|
752
|
+
percent?: number;
|
|
753
|
+
lastDocId?: string;
|
|
754
|
+
lastError?: unknown;
|
|
755
|
+
}
|
|
756
|
+
interface BulkWriteResult {
|
|
757
|
+
operation: BulkWriteOperation;
|
|
758
|
+
processed: number;
|
|
759
|
+
succeeded: number;
|
|
760
|
+
failed: number;
|
|
761
|
+
total?: number;
|
|
762
|
+
}
|
|
763
|
+
interface BulkWriteOptions {
|
|
764
|
+
/** How many operations to execute per chunk; defaults to 250. */
|
|
765
|
+
batchSize?: number;
|
|
766
|
+
/** Number of in-flight writes within each chunk; defaults to 1. */
|
|
767
|
+
concurrency?: number;
|
|
768
|
+
/** Continue processing remaining items after individual failures. */
|
|
769
|
+
continueOnError?: boolean;
|
|
770
|
+
/** Optional cancellation signal for long-running bulk writes. */
|
|
771
|
+
signal?: AbortSignal;
|
|
772
|
+
/** Progress callback invoked after each processed item. */
|
|
773
|
+
onProgress?: (progress: BulkWriteProgress) => void;
|
|
774
|
+
}
|
|
775
|
+
interface UpdateManyItem<T = any> {
|
|
776
|
+
id: string;
|
|
777
|
+
data: Partial<T>;
|
|
778
|
+
}
|
|
735
779
|
type StreamFlushReason = 'snapshot' | 'change-batch';
|
|
736
780
|
interface CollectionStreamOptions<T = any> {
|
|
737
781
|
/** Delay before a queued burst is flushed to listeners. */
|
|
@@ -862,4 +906,4 @@ type SecurityRulesMap = Record<string, SecurityRuleEntry>;
|
|
|
862
906
|
declare const flareRulesToSecurityMap: (rules: FlareRule[]) => SecurityRulesMap;
|
|
863
907
|
declare const securityMapToFlareRules: (rules: SecurityRulesMap) => FlareRule[];
|
|
864
908
|
|
|
865
|
-
export { type
|
|
909
|
+
export { type FlareStorageObjectResult as $, type AggregateFunction as A, type BrowserPushRegistrationOptions as B, type ChangeEvent as C, type DataMapperFn as D, type DeleteObjectsInput as E, type FlareConfig as F, type DocAddedCallback as G, type DocChangedCallback as H, type DocDeletedCallback as I, type DocUpdatedCallback as J, type DocumentSnapshot as K, type DownloadObjectInput as L, type DownloadObjectResult as M, type EmailLinkVerifyResult as N, type EmailSendResult as O, type FlareAuthConfig as P, type FlareAuthHydrationInput as Q, type FlareAuthHydrationOptions as R, type FlareAuthProviderId as S, type FlareAuthProviderPublicConfig as T, type FlareAuthSession as U, type FlareAuthUser as V, type FlareRule as W, type FlareStorageAutoConfig as X, type FlareStorageAwsConfig as Y, type FlareStorageDeleteInput as Z, type FlareStorageDownloadInput as _, type AggregateSpec as a, type VerifyEmailLinkInput as a$, type FlareStorageRulesHistoryResult as a0, type FlareStorageRulesPolicy as a1, type FlareStorageServer as a2, type FlareStorageServerInput as a3, type FlareStorageServerPatchInput as a4, FlareStorageSignedAction as a5, type FlareStorageSignedUrlInput as a6, type FlareStorageSignedUrlResult as a7, type FlareStorageTransferManagerConfig as a8, type FlareStorageUploadInput as a9, type QueryPresetRow as aA, type QueryPresetSpec as aB, type QuerySnapshot as aC, type RegisterPushTokenInput as aD, type RulePermission as aE, type SecurityRuleEntry as aF, type SecurityRulesMap as aG, type SendEmailInput as aH, type SendPushNotificationInput as aI, type SnapshotEvent as aJ, type StorageBucket as aK, type StorageBucketInput as aL, type StorageObjectMeta as aM, type StorageProgress as aN, type StorageSignedUrlInput as aO, type StreamFlushReason as aP, type StructuredJoinClause as aQ, type StructuredQuery as aR, type SubscribeOptions as aS, type SubscriptionCallback as aT, type SubscriptionData as aU, type SubscriptionError as aV, type SubscriptionErrorCallback as aW, type SubscriptionHandle as aX, type UpdateManyItem as aY, type VectorFieldConfig as aZ, type VectorSearchClause as a_, type GetObjectInput as aa, type GetObjectResult as ab, type GetObjectUrlInput as ac, type GroupByClause as ad, type HavingClause as ae, type HeadObjectInput as af, type HeadObjectsInput as ag, type JoinClause as ah, type JoinQueryPattern as ai, type ListObjectsInput as aj, type ListObjectsResult as ak, type NestedJoinClause as al, type OfflineOperation as am, type OrFilter as an, type OrderByClause as ao, type PresenceCallback as ap, type PresenceJoinCallback as aq, type PresenceLeaveCallback as ar, type PresenceMember as as, type PushSendResult as at, type PutObjectInput as au, type PutObjectResult as av, type QueryConfig as aw, type QueryOperator as ax, type QueryPresetMap as ay, type QueryPresetParams as az, type AndFilter as b, type WhereCondition as b0, flareRulesToSecurityMap as b1, securityMapToFlareRules as b2, 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 BulkWriteOperation as l, type BulkWriteOptions as m, type BulkWriteProgress as n, type BulkWriteResult as o, type ChangeOperation as p, type CollectionExternalStore as q, type CollectionStream as r, type CollectionStreamListener as s, type CollectionStreamMeta as t, type CollectionStreamOptions as u, type ConnectionState as v, type CopyObjectInput as w, type CursorValue as x, type DataMapperRegistry as y, type DeleteObjectInput as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { b0 as WhereCondition, aT as SubscriptionCallback, aw as QueryConfig, J as DocUpdatedCallback, I as DocDeletedCallback, H as DocChangedCallback, ay as QueryPresetMap, az as QueryPresetParams, aA as QueryPresetRow, a as AggregateSpec, ae as HavingClause, ah as JoinClause, a_ as VectorSearchClause, aR as StructuredQuery, aX as SubscriptionHandle, u as CollectionStreamOptions, r as CollectionStream, q as CollectionExternalStore, G as DocAddedCallback, m as BulkWriteOptions, o as BulkWriteResult, aY as UpdateManyItem, F as FlareConfig, aS as SubscribeOptions, aW as SubscriptionErrorCallback, aV as SubscriptionError, v as ConnectionState, ap as PresenceCallback, aq as PresenceJoinCallback, ar as PresenceLeaveCallback, aZ as VectorFieldConfig, aB as QueryPresetSpec, a8 as FlareStorageTransferManagerConfig, aN as StorageProgress, aL as StorageBucketInput, aK as StorageBucket, k as BucketPolicyInput, a1 as FlareStorageRulesPolicy, j as BucketCorsRule, a0 as FlareStorageRulesHistoryResult, au as PutObjectInput, av as PutObjectResult, aa as GetObjectInput, ab as GetObjectResult, ac as GetObjectUrlInput, L as DownloadObjectInput, M as DownloadObjectResult, af as HeadObjectInput, aM as StorageObjectMeta, ag as HeadObjectsInput, aj as ListObjectsInput, ak as ListObjectsResult, w as CopyObjectInput, z as DeleteObjectInput, E as DeleteObjectsInput, aO as StorageSignedUrlInput, a7 as FlareStorageSignedUrlResult, P as FlareAuthConfig, f as AuthStateListener, d as AuthConfigListener, U as FlareAuthSession, V as FlareAuthUser, Q as FlareAuthHydrationInput, R as FlareAuthHydrationOptions, i as BrowserPushTokenOptions, B as BrowserPushRegistrationOptions, aD as RegisterPushTokenInput, aI as SendPushNotificationInput, at as PushSendResult, e as AuthResult } from './index-18tMqAtM.js';
|
|
2
2
|
import { AuthToken } from '@zuzjs/auth';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -260,7 +260,26 @@ declare class CollectionReference<T = any, TPresetMap extends QueryPresetMap = {
|
|
|
260
260
|
onDocUpdated(callback: DocUpdatedCallback<T>): () => void;
|
|
261
261
|
onDocDeleted(callback: DocDeletedCallback<T>): () => void;
|
|
262
262
|
onDocChanged(callback: DocChangedCallback<T>): () => void;
|
|
263
|
+
private ensureBulkOptions;
|
|
264
|
+
private toPercent;
|
|
265
|
+
private emitBulkProgress;
|
|
266
|
+
private chunkIterable;
|
|
267
|
+
private assertBulkSignal;
|
|
268
|
+
private runChunkWorkers;
|
|
269
|
+
private runBulkWrite;
|
|
263
270
|
add(data: Partial<T>): Promise<DocumentReference<T>>;
|
|
271
|
+
/**
|
|
272
|
+
* Create many documents with bounded memory and optional progress reporting.
|
|
273
|
+
*/
|
|
274
|
+
addMany(items: Iterable<Partial<T>> | AsyncIterable<Partial<T>>, options?: BulkWriteOptions): Promise<BulkWriteResult>;
|
|
275
|
+
/**
|
|
276
|
+
* Update many documents by id with bounded memory and optional progress reporting.
|
|
277
|
+
*/
|
|
278
|
+
updateMany(items: Iterable<UpdateManyItem<T>> | AsyncIterable<UpdateManyItem<T>>, options?: BulkWriteOptions): Promise<BulkWriteResult>;
|
|
279
|
+
/**
|
|
280
|
+
* Delete many documents by id with bounded memory and optional progress reporting.
|
|
281
|
+
*/
|
|
282
|
+
deleteMany(docIds: Iterable<string> | AsyncIterable<string>, options?: BulkWriteOptions): Promise<BulkWriteResult>;
|
|
264
283
|
update(data: Partial<T>): DocumentQueryBuilder<T>;
|
|
265
284
|
delete(): DocumentQueryBuilder<T>;
|
|
266
285
|
}
|
|
@@ -470,6 +489,16 @@ declare class FlareBase<TPresetMap extends QueryPresetMap = {}> {
|
|
|
470
489
|
onConnectionStateChange(listener: ConnectionListener): () => void;
|
|
471
490
|
onError(callback: ErrorListener): () => void;
|
|
472
491
|
collection<T = any>(name: string): CollectionQuery<T, TPresetMap>;
|
|
492
|
+
/**
|
|
493
|
+
* Generates a standard 20-character Flare document ID.
|
|
494
|
+
* UUID v4 without dashes, first 20 chars — matches the Rust server-side format.
|
|
495
|
+
*
|
|
496
|
+
* ```ts
|
|
497
|
+
* const id = db.generateFlareId();
|
|
498
|
+
* await db.collection('orders').doc(id).set({ total: 99 });
|
|
499
|
+
* ```
|
|
500
|
+
*/
|
|
501
|
+
generateFlareId(): string;
|
|
473
502
|
registerQueryPreset<Name extends string, Params extends Record<string, unknown>, Row = any>(name: Name, handler: QueryPresetHandler<Params, Row>): this & FlareBase<TPresetMap & Record<Name, QueryPresetSpec<Params, Row>>>;
|
|
474
503
|
registerQueryPresets<TRegistry extends Record<string, QueryPresetHandler<any, any>>>(presets: TRegistry): this & FlareBase<TPresetMap & {
|
|
475
504
|
[K in keyof TRegistry]: TRegistry[K] extends QueryPresetHandler<infer Params, infer Row> ? QueryPresetSpec<Params, Row> : QueryPresetSpec<Record<string, unknown>, any>;
|
|
@@ -477,7 +506,22 @@ declare class FlareBase<TPresetMap extends QueryPresetMap = {}> {
|
|
|
477
506
|
hasQueryPreset(name: string): boolean;
|
|
478
507
|
applyQueryPreset<Name extends keyof TPresetMap & string>(ref: CollectionReference<any, TPresetMap>, name: Name, params: QueryPresetParams<TPresetMap[Name]>): CollectionQuery<QueryPresetRow<TPresetMap[Name]>, TPresetMap>;
|
|
479
508
|
applyQueryPreset<T = any>(ref: CollectionQuery<T, TPresetMap>, name: string, params?: Record<string, unknown>): CollectionQuery<T, TPresetMap>;
|
|
480
|
-
|
|
509
|
+
/**
|
|
510
|
+
* Returns a DocumentReference for the given collection.
|
|
511
|
+
* When called with no ID, a 20-character Flare ID is auto-generated —
|
|
512
|
+
* read `.id` from the returned ref before any network call.
|
|
513
|
+
*
|
|
514
|
+
* ```ts
|
|
515
|
+
* const ref = db.doc('orders'); // auto-ID
|
|
516
|
+
* const id = ref.id;
|
|
517
|
+
* await ref.set({ total: 99, id });
|
|
518
|
+
*
|
|
519
|
+
* const existing = db.doc('orders', knownId); // known ID
|
|
520
|
+
* ```
|
|
521
|
+
*/
|
|
522
|
+
doc<T = any>(collection: string): DocumentReference<T> & {
|
|
523
|
+
id: string;
|
|
524
|
+
};
|
|
481
525
|
doc<T = any>(collection: string, id: string): DocumentReference<T>;
|
|
482
526
|
ping(): Promise<number>;
|
|
483
527
|
call<T = Record<string, unknown>>(topic: string, payload?: Record<string, unknown>): Promise<T>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { b0 as WhereCondition, aT as SubscriptionCallback, aw as QueryConfig, J as DocUpdatedCallback, I as DocDeletedCallback, H as DocChangedCallback, ay as QueryPresetMap, az as QueryPresetParams, aA as QueryPresetRow, a as AggregateSpec, ae as HavingClause, ah as JoinClause, a_ as VectorSearchClause, aR as StructuredQuery, aX as SubscriptionHandle, u as CollectionStreamOptions, r as CollectionStream, q as CollectionExternalStore, G as DocAddedCallback, m as BulkWriteOptions, o as BulkWriteResult, aY as UpdateManyItem, F as FlareConfig, aS as SubscribeOptions, aW as SubscriptionErrorCallback, aV as SubscriptionError, v as ConnectionState, ap as PresenceCallback, aq as PresenceJoinCallback, ar as PresenceLeaveCallback, aZ as VectorFieldConfig, aB as QueryPresetSpec, a8 as FlareStorageTransferManagerConfig, aN as StorageProgress, aL as StorageBucketInput, aK as StorageBucket, k as BucketPolicyInput, a1 as FlareStorageRulesPolicy, j as BucketCorsRule, a0 as FlareStorageRulesHistoryResult, au as PutObjectInput, av as PutObjectResult, aa as GetObjectInput, ab as GetObjectResult, ac as GetObjectUrlInput, L as DownloadObjectInput, M as DownloadObjectResult, af as HeadObjectInput, aM as StorageObjectMeta, ag as HeadObjectsInput, aj as ListObjectsInput, ak as ListObjectsResult, w as CopyObjectInput, z as DeleteObjectInput, E as DeleteObjectsInput, aO as StorageSignedUrlInput, a7 as FlareStorageSignedUrlResult, P as FlareAuthConfig, f as AuthStateListener, d as AuthConfigListener, U as FlareAuthSession, V as FlareAuthUser, Q as FlareAuthHydrationInput, R as FlareAuthHydrationOptions, i as BrowserPushTokenOptions, B as BrowserPushRegistrationOptions, aD as RegisterPushTokenInput, aI as SendPushNotificationInput, at as PushSendResult, e as AuthResult } from './index-18tMqAtM.cjs';
|
|
2
2
|
import { AuthToken } from '@zuzjs/auth';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -260,7 +260,26 @@ declare class CollectionReference<T = any, TPresetMap extends QueryPresetMap = {
|
|
|
260
260
|
onDocUpdated(callback: DocUpdatedCallback<T>): () => void;
|
|
261
261
|
onDocDeleted(callback: DocDeletedCallback<T>): () => void;
|
|
262
262
|
onDocChanged(callback: DocChangedCallback<T>): () => void;
|
|
263
|
+
private ensureBulkOptions;
|
|
264
|
+
private toPercent;
|
|
265
|
+
private emitBulkProgress;
|
|
266
|
+
private chunkIterable;
|
|
267
|
+
private assertBulkSignal;
|
|
268
|
+
private runChunkWorkers;
|
|
269
|
+
private runBulkWrite;
|
|
263
270
|
add(data: Partial<T>): Promise<DocumentReference<T>>;
|
|
271
|
+
/**
|
|
272
|
+
* Create many documents with bounded memory and optional progress reporting.
|
|
273
|
+
*/
|
|
274
|
+
addMany(items: Iterable<Partial<T>> | AsyncIterable<Partial<T>>, options?: BulkWriteOptions): Promise<BulkWriteResult>;
|
|
275
|
+
/**
|
|
276
|
+
* Update many documents by id with bounded memory and optional progress reporting.
|
|
277
|
+
*/
|
|
278
|
+
updateMany(items: Iterable<UpdateManyItem<T>> | AsyncIterable<UpdateManyItem<T>>, options?: BulkWriteOptions): Promise<BulkWriteResult>;
|
|
279
|
+
/**
|
|
280
|
+
* Delete many documents by id with bounded memory and optional progress reporting.
|
|
281
|
+
*/
|
|
282
|
+
deleteMany(docIds: Iterable<string> | AsyncIterable<string>, options?: BulkWriteOptions): Promise<BulkWriteResult>;
|
|
264
283
|
update(data: Partial<T>): DocumentQueryBuilder<T>;
|
|
265
284
|
delete(): DocumentQueryBuilder<T>;
|
|
266
285
|
}
|
|
@@ -470,6 +489,16 @@ declare class FlareBase<TPresetMap extends QueryPresetMap = {}> {
|
|
|
470
489
|
onConnectionStateChange(listener: ConnectionListener): () => void;
|
|
471
490
|
onError(callback: ErrorListener): () => void;
|
|
472
491
|
collection<T = any>(name: string): CollectionQuery<T, TPresetMap>;
|
|
492
|
+
/**
|
|
493
|
+
* Generates a standard 20-character Flare document ID.
|
|
494
|
+
* UUID v4 without dashes, first 20 chars — matches the Rust server-side format.
|
|
495
|
+
*
|
|
496
|
+
* ```ts
|
|
497
|
+
* const id = db.generateFlareId();
|
|
498
|
+
* await db.collection('orders').doc(id).set({ total: 99 });
|
|
499
|
+
* ```
|
|
500
|
+
*/
|
|
501
|
+
generateFlareId(): string;
|
|
473
502
|
registerQueryPreset<Name extends string, Params extends Record<string, unknown>, Row = any>(name: Name, handler: QueryPresetHandler<Params, Row>): this & FlareBase<TPresetMap & Record<Name, QueryPresetSpec<Params, Row>>>;
|
|
474
503
|
registerQueryPresets<TRegistry extends Record<string, QueryPresetHandler<any, any>>>(presets: TRegistry): this & FlareBase<TPresetMap & {
|
|
475
504
|
[K in keyof TRegistry]: TRegistry[K] extends QueryPresetHandler<infer Params, infer Row> ? QueryPresetSpec<Params, Row> : QueryPresetSpec<Record<string, unknown>, any>;
|
|
@@ -477,7 +506,22 @@ declare class FlareBase<TPresetMap extends QueryPresetMap = {}> {
|
|
|
477
506
|
hasQueryPreset(name: string): boolean;
|
|
478
507
|
applyQueryPreset<Name extends keyof TPresetMap & string>(ref: CollectionReference<any, TPresetMap>, name: Name, params: QueryPresetParams<TPresetMap[Name]>): CollectionQuery<QueryPresetRow<TPresetMap[Name]>, TPresetMap>;
|
|
479
508
|
applyQueryPreset<T = any>(ref: CollectionQuery<T, TPresetMap>, name: string, params?: Record<string, unknown>): CollectionQuery<T, TPresetMap>;
|
|
480
|
-
|
|
509
|
+
/**
|
|
510
|
+
* Returns a DocumentReference for the given collection.
|
|
511
|
+
* When called with no ID, a 20-character Flare ID is auto-generated —
|
|
512
|
+
* read `.id` from the returned ref before any network call.
|
|
513
|
+
*
|
|
514
|
+
* ```ts
|
|
515
|
+
* const ref = db.doc('orders'); // auto-ID
|
|
516
|
+
* const id = ref.id;
|
|
517
|
+
* await ref.set({ total: 99, id });
|
|
518
|
+
*
|
|
519
|
+
* const existing = db.doc('orders', knownId); // known ID
|
|
520
|
+
* ```
|
|
521
|
+
*/
|
|
522
|
+
doc<T = any>(collection: string): DocumentReference<T> & {
|
|
523
|
+
id: string;
|
|
524
|
+
};
|
|
481
525
|
doc<T = any>(collection: string, id: string): DocumentReference<T>;
|
|
482
526
|
ping(): Promise<number>;
|
|
483
527
|
call<T = Record<string, unknown>>(topic: string, payload?: Record<string, unknown>): Promise<T>;
|