@zuzjs/flare 0.2.19 → 0.2.21

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
@@ -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
package/dist/grpc.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { F as FlareConfig, aN as StructuredQuery } from './index-Y0Mq_6P9.cjs';
1
+ import { F as FlareConfig, aR as StructuredQuery } from './index-DlQgWDy-.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, aN as StructuredQuery } from './index-Y0Mq_6P9.js';
1
+ import { F as FlareConfig, aR as StructuredQuery } from './index-DlQgWDy-.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>;
@@ -732,6 +732,40 @@ type DocAddedCallback<T = any> = (data: T, docId: string) => void;
732
732
  type DocUpdatedCallback<T = any> = (data: T, docId: string) => void;
733
733
  type DocDeletedCallback<T = any> = (docId: string) => void;
734
734
  type DocChangedCallback<T = any> = (data: T | null, docId: string, operation: ChangeOperation) => void;
735
+ type BulkWriteOperation = 'addMany' | 'updateMany' | 'deleteMany';
736
+ interface BulkWriteProgress {
737
+ operation: BulkWriteOperation;
738
+ processed: number;
739
+ succeeded: number;
740
+ failed: number;
741
+ total?: number;
742
+ percent?: number;
743
+ lastDocId?: string;
744
+ lastError?: unknown;
745
+ }
746
+ interface BulkWriteResult {
747
+ operation: BulkWriteOperation;
748
+ processed: number;
749
+ succeeded: number;
750
+ failed: number;
751
+ total?: number;
752
+ }
753
+ interface BulkWriteOptions {
754
+ /** How many operations to execute per chunk; defaults to 250. */
755
+ batchSize?: number;
756
+ /** Number of in-flight writes within each chunk; defaults to 1. */
757
+ concurrency?: number;
758
+ /** Continue processing remaining items after individual failures. */
759
+ continueOnError?: boolean;
760
+ /** Optional cancellation signal for long-running bulk writes. */
761
+ signal?: AbortSignal;
762
+ /** Progress callback invoked after each processed item. */
763
+ onProgress?: (progress: BulkWriteProgress) => void;
764
+ }
765
+ interface UpdateManyItem<T = any> {
766
+ id: string;
767
+ data: Partial<T>;
768
+ }
735
769
  type StreamFlushReason = 'snapshot' | 'change-batch';
736
770
  interface CollectionStreamOptions<T = any> {
737
771
  /** Delay before a queued burst is flushed to listeners. */
@@ -862,4 +896,4 @@ type SecurityRulesMap = Record<string, SecurityRuleEntry>;
862
896
  declare const flareRulesToSecurityMap: (rules: FlareRule[]) => SecurityRulesMap;
863
897
  declare const securityMapToFlareRules: (rules: SecurityRulesMap) => FlareRule[];
864
898
 
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 };
899
+ 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 };
@@ -732,6 +732,40 @@ type DocAddedCallback<T = any> = (data: T, docId: string) => void;
732
732
  type DocUpdatedCallback<T = any> = (data: T, docId: string) => void;
733
733
  type DocDeletedCallback<T = any> = (docId: string) => void;
734
734
  type DocChangedCallback<T = any> = (data: T | null, docId: string, operation: ChangeOperation) => void;
735
+ type BulkWriteOperation = 'addMany' | 'updateMany' | 'deleteMany';
736
+ interface BulkWriteProgress {
737
+ operation: BulkWriteOperation;
738
+ processed: number;
739
+ succeeded: number;
740
+ failed: number;
741
+ total?: number;
742
+ percent?: number;
743
+ lastDocId?: string;
744
+ lastError?: unknown;
745
+ }
746
+ interface BulkWriteResult {
747
+ operation: BulkWriteOperation;
748
+ processed: number;
749
+ succeeded: number;
750
+ failed: number;
751
+ total?: number;
752
+ }
753
+ interface BulkWriteOptions {
754
+ /** How many operations to execute per chunk; defaults to 250. */
755
+ batchSize?: number;
756
+ /** Number of in-flight writes within each chunk; defaults to 1. */
757
+ concurrency?: number;
758
+ /** Continue processing remaining items after individual failures. */
759
+ continueOnError?: boolean;
760
+ /** Optional cancellation signal for long-running bulk writes. */
761
+ signal?: AbortSignal;
762
+ /** Progress callback invoked after each processed item. */
763
+ onProgress?: (progress: BulkWriteProgress) => void;
764
+ }
765
+ interface UpdateManyItem<T = any> {
766
+ id: string;
767
+ data: Partial<T>;
768
+ }
735
769
  type StreamFlushReason = 'snapshot' | 'change-batch';
736
770
  interface CollectionStreamOptions<T = any> {
737
771
  /** Delay before a queued burst is flushed to listeners. */
@@ -862,4 +896,4 @@ type SecurityRulesMap = Record<string, SecurityRuleEntry>;
862
896
  declare const flareRulesToSecurityMap: (rules: FlareRule[]) => SecurityRulesMap;
863
897
  declare const securityMapToFlareRules: (rules: SecurityRulesMap) => FlareRule[];
864
898
 
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 };
899
+ 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 { 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';
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-DlQgWDy-.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
- doc<T = any>(collection: string): DocumentQueryBuilder<T>;
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>;
@@ -1055,6 +1099,7 @@ declare class FlareAuth<TPresetMap extends QueryPresetMap = {}> extends FlareBas
1055
1099
 
1056
1100
  declare class FlareClient<TPresetMap extends QueryPresetMap = {}> extends FlareAuth<TPresetMap> {
1057
1101
  private autoPushRegisteredIdentity?;
1102
+ private autoPushInProgress;
1058
1103
  constructor(config: FlareConfig);
1059
1104
  private enableAutoPushNotificationsAfterAuth;
1060
1105
  autoEnablePushNotifications(): Promise<void>;
@@ -1,4 +1,4 @@
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.js';
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-DlQgWDy-.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
- doc<T = any>(collection: string): DocumentQueryBuilder<T>;
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>;
@@ -1055,6 +1099,7 @@ declare class FlareAuth<TPresetMap extends QueryPresetMap = {}> extends FlareBas
1055
1099
 
1056
1100
  declare class FlareClient<TPresetMap extends QueryPresetMap = {}> extends FlareAuth<TPresetMap> {
1057
1101
  private autoPushRegisteredIdentity?;
1102
+ private autoPushInProgress;
1058
1103
  constructor(config: FlareConfig);
1059
1104
  private enableAutoPushNotificationsAfterAuth;
1060
1105
  autoEnablePushNotifications(): Promise<void>;