@zuzjs/flare 0.2.6 → 0.2.8
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 +259 -0
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +96 -24
- package/dist/index.d.ts +96 -24
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -332,6 +332,58 @@ type DocAddedCallback<T = any> = (data: T, docId: string) => void;
|
|
|
332
332
|
type DocUpdatedCallback<T = any> = (data: T, docId: string) => void;
|
|
333
333
|
type DocDeletedCallback<T = any> = (docId: string) => void;
|
|
334
334
|
type DocChangedCallback<T = any> = (data: T | null, docId: string, operation: ChangeOperation) => void;
|
|
335
|
+
type StreamFlushReason = 'snapshot' | 'change-batch';
|
|
336
|
+
interface CollectionStreamOptions<T = any> {
|
|
337
|
+
/** Delay before a queued burst is flushed to listeners. */
|
|
338
|
+
flushMs?: number;
|
|
339
|
+
/** Flush immediately when queued changes reach this count. */
|
|
340
|
+
maxBatchSize?: number;
|
|
341
|
+
/** Field used to identify docs inside snapshots when getId is not provided. */
|
|
342
|
+
idField?: keyof T & string;
|
|
343
|
+
/** Custom identifier extractor for snapshot rows. */
|
|
344
|
+
getId?: (doc: T) => string | undefined;
|
|
345
|
+
/** Where newly inserted docs should be placed when they were not in snapshot. */
|
|
346
|
+
insertAt?: 'start' | 'end';
|
|
347
|
+
/** Optional cap to keep only the newest N docs in local stream state. */
|
|
348
|
+
maxDocs?: number;
|
|
349
|
+
/** Optional local sort run after flush. */
|
|
350
|
+
sort?: (a: T, b: T) => number;
|
|
351
|
+
}
|
|
352
|
+
interface CollectionStreamMeta {
|
|
353
|
+
reason: StreamFlushReason;
|
|
354
|
+
batchSize: number;
|
|
355
|
+
version: number;
|
|
356
|
+
ready: boolean;
|
|
357
|
+
}
|
|
358
|
+
type CollectionStreamListener<T = any> = (rows: readonly T[], meta: CollectionStreamMeta) => void;
|
|
359
|
+
interface CollectionStream<T = any> {
|
|
360
|
+
/** Subscribe to stream updates (call unsubscribe to stop). */
|
|
361
|
+
subscribe: (listener: CollectionStreamListener<T>, emitCurrent?: boolean) => () => void;
|
|
362
|
+
/** Returns the latest immutable snapshot of rows. */
|
|
363
|
+
getSnapshot: () => readonly T[];
|
|
364
|
+
/** Returns true after the initial snapshot has been received. */
|
|
365
|
+
isReady: () => boolean;
|
|
366
|
+
/** Monotonic version incremented on each flush. */
|
|
367
|
+
getVersion: () => number;
|
|
368
|
+
/** Stop the underlying realtime subscription and cleanup timers/listeners. */
|
|
369
|
+
close: () => void;
|
|
370
|
+
/** Attach subscription-level error handler. */
|
|
371
|
+
onError: (callback: SubscriptionErrorCallback) => CollectionStream<T>;
|
|
372
|
+
/** Attach permission-denied handler. */
|
|
373
|
+
onPermissionDenied: (callback: SubscriptionErrorCallback) => CollectionStream<T>;
|
|
374
|
+
}
|
|
375
|
+
interface CollectionExternalStore<T = any> {
|
|
376
|
+
/** Standard external-store subscribe signature used by UI store hooks. */
|
|
377
|
+
subscribe: (onStoreChange: () => void) => () => void;
|
|
378
|
+
/** Returns current immutable rows snapshot. */
|
|
379
|
+
getSnapshot: () => readonly T[];
|
|
380
|
+
/** Server snapshot fallback for SSR-safe store hooks. */
|
|
381
|
+
getServerSnapshot: () => readonly T[];
|
|
382
|
+
/** Access to underlying realtime stream for advanced handlers. */
|
|
383
|
+
stream: CollectionStream<T>;
|
|
384
|
+
/** Stops realtime stream and detaches listeners. */
|
|
385
|
+
destroy: () => void;
|
|
386
|
+
}
|
|
335
387
|
interface DocumentSnapshot<T = any> {
|
|
336
388
|
id: string;
|
|
337
389
|
data: T | null;
|
|
@@ -431,13 +483,13 @@ declare function parseValue(val: string): any;
|
|
|
431
483
|
declare class DocumentQueryBuilder<T = any> implements PromiseLike<T | null | void> {
|
|
432
484
|
private client;
|
|
433
485
|
private collection;
|
|
434
|
-
private
|
|
486
|
+
private docIdFromRef?;
|
|
435
487
|
private whereCondition?;
|
|
436
488
|
private updateData?;
|
|
437
489
|
private setData?;
|
|
438
490
|
private deleteOp;
|
|
439
491
|
private promise?;
|
|
440
|
-
constructor(client: FlareClient<any>, collection: string,
|
|
492
|
+
constructor(client: FlareClient<any>, collection: string, docIdFromRef?: string | undefined);
|
|
441
493
|
/**
|
|
442
494
|
* Set where condition
|
|
443
495
|
*/
|
|
@@ -455,7 +507,7 @@ declare class DocumentQueryBuilder<T = any> implements PromiseLike<T | null | vo
|
|
|
455
507
|
*/
|
|
456
508
|
delete(): this;
|
|
457
509
|
/**
|
|
458
|
-
* Get the document ID from
|
|
510
|
+
* Get the document ID from doc() reference or where condition.
|
|
459
511
|
*/
|
|
460
512
|
private getDocId;
|
|
461
513
|
/**
|
|
@@ -481,9 +533,7 @@ declare class DocumentQueryBuilder<T = any> implements PromiseLike<T | null | vo
|
|
|
481
533
|
onSnapshot(callback: SubscriptionCallback<T>): () => void;
|
|
482
534
|
}
|
|
483
535
|
|
|
484
|
-
/**
|
|
485
|
-
* Legacy document reference (for backward compatibility)
|
|
486
|
-
*/
|
|
536
|
+
/** Document reference */
|
|
487
537
|
declare class DocumentReference<T = any> {
|
|
488
538
|
private client;
|
|
489
539
|
readonly collection: string;
|
|
@@ -496,13 +546,8 @@ declare class DocumentReference<T = any> {
|
|
|
496
546
|
onSnapshot(callback: SubscriptionCallback<T>): () => void;
|
|
497
547
|
/**
|
|
498
548
|
* Fires when this document is updated / replaced.
|
|
499
|
-
* Aliases: onDocModified, onDocChange
|
|
500
549
|
*/
|
|
501
550
|
onDocUpdated(callback: DocUpdatedCallback<T>): () => void;
|
|
502
|
-
/** Alias for onDocUpdated */
|
|
503
|
-
onDocModified(callback: DocUpdatedCallback<T>): () => void;
|
|
504
|
-
/** Alias for onDocUpdated */
|
|
505
|
-
onDocChange(callback: DocUpdatedCallback<T>): () => void;
|
|
506
551
|
/**
|
|
507
552
|
* Fires when this document is deleted.
|
|
508
553
|
*/
|
|
@@ -533,6 +578,9 @@ declare class CollectionReference<T = any, TPresetMap extends QueryPresetMap = {
|
|
|
533
578
|
private appendAndFilters;
|
|
534
579
|
private toOrNode;
|
|
535
580
|
private toAndNode;
|
|
581
|
+
private isLeafFilter;
|
|
582
|
+
private isIdentityGuard;
|
|
583
|
+
private splitIdentityGuards;
|
|
536
584
|
private appendOrFilters;
|
|
537
585
|
private appendFilters;
|
|
538
586
|
with<Name extends keyof TPresetMap & string>(name: Name, params: QueryPresetParams<TPresetMap[Name]>): CollectionQuery<QueryPresetRow<TPresetMap[Name]>, TPresetMap>;
|
|
@@ -570,6 +618,8 @@ declare class CollectionReference<T = any, TPresetMap extends QueryPresetMap = {
|
|
|
570
618
|
orNotExists(field: string): CollectionQuery<T, TPresetMap>;
|
|
571
619
|
/** Get items starting from the most recently created (descending sequence) */
|
|
572
620
|
latest(): CollectionQuery<T, TPresetMap>;
|
|
621
|
+
/** Get items starting from the most recently created (descending sequence) */
|
|
622
|
+
newest(): CollectionQuery<T, TPresetMap>;
|
|
573
623
|
/** Get items starting from the first ever created (ascending sequence) */
|
|
574
624
|
oldest(): CollectionQuery<T, TPresetMap>;
|
|
575
625
|
orderBy(field: string, dir?: "asc" | "desc"): CollectionQuery<T, TPresetMap>;
|
|
@@ -589,6 +639,9 @@ declare class CollectionReference<T = any, TPresetMap extends QueryPresetMap = {
|
|
|
589
639
|
groupBy(...fields: string[]): CollectionQuery<T, TPresetMap>;
|
|
590
640
|
having(field: string, op: HavingClause['op'], value: number): CollectionQuery<T, TPresetMap>;
|
|
591
641
|
private buildStructuredJoin;
|
|
642
|
+
private cloneStructuredJoin;
|
|
643
|
+
private appendNestedJoinByAlias;
|
|
644
|
+
private parseRelationRef;
|
|
592
645
|
/**
|
|
593
646
|
* Join another collection into this query.
|
|
594
647
|
*
|
|
@@ -596,19 +649,26 @@ declare class CollectionReference<T = any, TPresetMap extends QueryPresetMap = {
|
|
|
596
649
|
* @param j Join mapping clause.
|
|
597
650
|
* @example
|
|
598
651
|
* flare.collection("boards")
|
|
599
|
-
* .
|
|
652
|
+
* .join("tasks", { source: "id", target: "boardId", as: "tasks" })
|
|
600
653
|
* .get();
|
|
601
654
|
*/
|
|
655
|
+
join(collectionName: string, j: JoinClause): CollectionQuery<T, TPresetMap>;
|
|
656
|
+
/**
|
|
657
|
+
* Append a nested join under an existing join alias.
|
|
658
|
+
* Example:
|
|
659
|
+
* .join("lists", { source: "id", target: "boardId", as: "lists" })
|
|
660
|
+
* .joinNested("lists", "cards", { source: "id", target: "listId", as: "cards" })
|
|
661
|
+
*/
|
|
662
|
+
joinNested(parentAlias: string, collectionName: string, j: JoinClause): CollectionQuery<T, TPresetMap>;
|
|
602
663
|
Join(collectionName: string, j: JoinClause): CollectionQuery<T, TPresetMap>;
|
|
664
|
+
JoinNested(parentAlias: string, collectionName: string, j: JoinClause): CollectionQuery<T, TPresetMap>;
|
|
603
665
|
/**
|
|
604
|
-
*
|
|
605
|
-
*
|
|
666
|
+
* SQL-like relation shorthand.
|
|
667
|
+
* Example: .withRelation("team.uid->users.id", { as: "teamMembers" })
|
|
606
668
|
*/
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
collection?: string;
|
|
611
|
-
}): CollectionQuery<T, TPresetMap>;
|
|
669
|
+
withRelation(relation: string, options?: (Omit<JoinClause, 'source' | 'target' | 'as'> & {
|
|
670
|
+
as?: string;
|
|
671
|
+
})): CollectionQuery<T, TPresetMap>;
|
|
612
672
|
select(...fields: string[]): CollectionQuery<T, TPresetMap>;
|
|
613
673
|
/** Returns unique values for a single field */
|
|
614
674
|
distinctField(field: string): CollectionQuery<T, TPresetMap>;
|
|
@@ -618,6 +678,10 @@ declare class CollectionReference<T = any, TPresetMap extends QueryPresetMap = {
|
|
|
618
678
|
* col.vectorSearch({ field: "embedding", vector: [...1536 numbers...], k: 10 })
|
|
619
679
|
*/
|
|
620
680
|
vectorSearch(opts: VectorSearchClause): CollectionQuery<T, TPresetMap>;
|
|
681
|
+
getRawQuery(): {
|
|
682
|
+
collection: string;
|
|
683
|
+
query: StructuredQuery;
|
|
684
|
+
};
|
|
621
685
|
get(): Promise<T[]>;
|
|
622
686
|
private _isStructured;
|
|
623
687
|
private _execute;
|
|
@@ -632,10 +696,18 @@ declare class CollectionReference<T = any, TPresetMap extends QueryPresetMap = {
|
|
|
632
696
|
* the live result consistent.
|
|
633
697
|
*/
|
|
634
698
|
onSnapshot(callback: SubscriptionCallback<T[]>): SubscriptionHandle;
|
|
699
|
+
/**
|
|
700
|
+
* High-throughput stream wrapper for bursty collections (chat, feeds, logs).
|
|
701
|
+
* It keeps local state and flushes change bursts in batches to reduce UI churn.
|
|
702
|
+
*/
|
|
703
|
+
stream(options?: CollectionStreamOptions<T>): CollectionStream<T>;
|
|
704
|
+
/**
|
|
705
|
+
* Framework-agnostic external-store bridge.
|
|
706
|
+
* Compatible with UI hooks expecting subscribe/getSnapshot signatures.
|
|
707
|
+
*/
|
|
708
|
+
asStore(options?: CollectionStreamOptions<T>): CollectionExternalStore<T>;
|
|
635
709
|
onDocAdded(callback: DocAddedCallback<T>): () => void;
|
|
636
710
|
onDocUpdated(callback: DocUpdatedCallback<T>): () => void;
|
|
637
|
-
onDocModified(callback: DocUpdatedCallback<T>): () => void;
|
|
638
|
-
onDocChange(callback: DocUpdatedCallback<T>): () => void;
|
|
639
711
|
onDocDeleted(callback: DocDeletedCallback<T>): () => void;
|
|
640
712
|
onDocChanged(callback: DocChangedCallback<T>): () => void;
|
|
641
713
|
add(data: Partial<T>): Promise<DocumentReference<T>>;
|
|
@@ -737,7 +809,7 @@ type ActiveSubscription = {
|
|
|
737
809
|
liveId: string;
|
|
738
810
|
collection: string;
|
|
739
811
|
docId?: string;
|
|
740
|
-
query?:
|
|
812
|
+
query?: StructuredQuery;
|
|
741
813
|
callback: SubscriptionCallback;
|
|
742
814
|
options: SubscribeOptions;
|
|
743
815
|
};
|
|
@@ -872,7 +944,7 @@ declare class FlareBase<TPresetMap extends QueryPresetMap = {}> {
|
|
|
872
944
|
protected toSubscriptionError(err: unknown): SubscriptionError;
|
|
873
945
|
protected emitSubscriptionError(baseId: string, error: SubscriptionError): void;
|
|
874
946
|
protected replayActiveSubscriptions(): Promise<void>;
|
|
875
|
-
subscribe(subId: string, collection: string, docId: string | undefined, query:
|
|
947
|
+
subscribe(subId: string, collection: string, docId: string | undefined, query: StructuredQuery | undefined, callback: SubscriptionCallback, options?: SubscribeOptions): SubscriptionHandle;
|
|
876
948
|
send(type: FlareAction, payload: any): Promise<any>;
|
|
877
949
|
private handleTransportError;
|
|
878
950
|
protected onConnected(): void;
|
|
@@ -1420,4 +1492,4 @@ declare const getFlare: () => FlareClient | null;
|
|
|
1420
1492
|
*/
|
|
1421
1493
|
declare const disconnectFlare: () => void;
|
|
1422
1494
|
|
|
1423
|
-
export { type AggregateFunction, type AggregateSpec, type AndFilter, type AnyFilter, type AuthConfigListener, type AuthConfigResponse, type AuthResult, type AuthStateListener, type AuthWithPendingVerificationResult, type AuthWithTokenResult, type BaseMessage, type BrowserPushRegistrationOptions, type BrowserPushTokenOptions, type ChangeEvent, type ChangeOperation, type CollectionPresetMethods, type CollectionQuery, CollectionReference, type ConnectionState, type CsrfProxyConfig, type CursorValue, type DocAddedCallback, type DocChangedCallback, type DocDeletedCallback, type DocUpdatedCallback, DocumentQueryBuilder, DocumentReference, type DocumentSnapshot, type EmailLinkVerifyResult, type EmailSendResult, FlareAction, type FlareAuthConfig, type FlareAuthProviderId, type FlareAuthProviderPublicConfig, type FlareAuthSession, type FlareAuthUser, type FlareConfig, FlareError, FlareErrors, FlareEvent, FlareResponseCodes, type FlareRule, type GroupByClause, type HavingClause, type JoinClause, type JoinQueryPattern, type NestedJoinClause, type OfflineOperation, type OrFilter, type OrderByClause, type PresenceCallback, type PresenceJoinCallback, type PresenceLeaveCallback, type PresenceMember, type PushSendResult, type QueryConfig, type QueryOperator, type QueryPresetMap, type QueryPresetParams, type QueryPresetRow, type QueryPresetSpec, type QuerySnapshot, type RegisterPushTokenInput, type RulePermission, type SecurityRuleEntry, type SecurityRulesMap, type SendEmailInput, type SendPushNotificationInput, type SnapshotEvent, type StructuredJoinClause, type StructuredQuery, type SubscribeMessage, type SubscribeOptions, type SubscriptionCallback, type SubscriptionData, type SubscriptionError, type SubscriptionErrorCallback, type SubscriptionHandle, type VectorFieldConfig, type VectorSearchClause, type VerifyEmailLinkInput, type WhereCondition, buildFlareHeaders, connectApp, createCsrfProxy, createCsrfProxyHandler,
|
|
1495
|
+
export { type AggregateFunction, type AggregateSpec, type AndFilter, type AnyFilter, type AuthConfigListener, type AuthConfigResponse, type AuthResult, type AuthStateListener, type AuthWithPendingVerificationResult, type AuthWithTokenResult, type BaseMessage, type BrowserPushRegistrationOptions, type BrowserPushTokenOptions, type ChangeEvent, type ChangeOperation, type CollectionExternalStore, type CollectionPresetMethods, type CollectionQuery, CollectionReference, type CollectionStream, type CollectionStreamListener, type CollectionStreamMeta, type CollectionStreamOptions, type ConnectionState, type CsrfProxyConfig, type CursorValue, type DocAddedCallback, type DocChangedCallback, type DocDeletedCallback, type DocUpdatedCallback, DocumentQueryBuilder, DocumentReference, type DocumentSnapshot, type EmailLinkVerifyResult, type EmailSendResult, FlareAction, type FlareAuthConfig, type FlareAuthProviderId, type FlareAuthProviderPublicConfig, type FlareAuthSession, type FlareAuthUser, FlareClient, type FlareConfig, FlareError, FlareErrors, FlareEvent, FlareResponseCodes, type FlareRule, type GroupByClause, type HavingClause, type JoinClause, type JoinQueryPattern, type NestedJoinClause, type OfflineOperation, type OrFilter, type OrderByClause, type PresenceCallback, type PresenceJoinCallback, type PresenceLeaveCallback, type PresenceMember, type PushSendResult, type QueryConfig, type QueryOperator, type QueryPresetMap, type QueryPresetParams, type QueryPresetRow, type QueryPresetSpec, type QuerySnapshot, type RegisterPushTokenInput, type RulePermission, type SecurityRuleEntry, type SecurityRulesMap, type SendEmailInput, type SendPushNotificationInput, type SnapshotEvent, type StreamFlushReason, type StructuredJoinClause, type StructuredQuery, type SubscribeMessage, type SubscribeOptions, type SubscriptionCallback, type SubscriptionData, type SubscriptionError, type SubscriptionErrorCallback, type SubscriptionHandle, type VectorFieldConfig, type VectorSearchClause, type VerifyEmailLinkInput, type WhereCondition, buildFlareHeaders, connectApp, createCsrfProxy, createCsrfProxyHandler, disconnectFlare, extractCsrfFromRequest, flareRulesToSecurityMap, getFlare, parseValue, parseWhereCondition, securityMapToFlareRules };
|
package/dist/index.d.ts
CHANGED
|
@@ -332,6 +332,58 @@ type DocAddedCallback<T = any> = (data: T, docId: string) => void;
|
|
|
332
332
|
type DocUpdatedCallback<T = any> = (data: T, docId: string) => void;
|
|
333
333
|
type DocDeletedCallback<T = any> = (docId: string) => void;
|
|
334
334
|
type DocChangedCallback<T = any> = (data: T | null, docId: string, operation: ChangeOperation) => void;
|
|
335
|
+
type StreamFlushReason = 'snapshot' | 'change-batch';
|
|
336
|
+
interface CollectionStreamOptions<T = any> {
|
|
337
|
+
/** Delay before a queued burst is flushed to listeners. */
|
|
338
|
+
flushMs?: number;
|
|
339
|
+
/** Flush immediately when queued changes reach this count. */
|
|
340
|
+
maxBatchSize?: number;
|
|
341
|
+
/** Field used to identify docs inside snapshots when getId is not provided. */
|
|
342
|
+
idField?: keyof T & string;
|
|
343
|
+
/** Custom identifier extractor for snapshot rows. */
|
|
344
|
+
getId?: (doc: T) => string | undefined;
|
|
345
|
+
/** Where newly inserted docs should be placed when they were not in snapshot. */
|
|
346
|
+
insertAt?: 'start' | 'end';
|
|
347
|
+
/** Optional cap to keep only the newest N docs in local stream state. */
|
|
348
|
+
maxDocs?: number;
|
|
349
|
+
/** Optional local sort run after flush. */
|
|
350
|
+
sort?: (a: T, b: T) => number;
|
|
351
|
+
}
|
|
352
|
+
interface CollectionStreamMeta {
|
|
353
|
+
reason: StreamFlushReason;
|
|
354
|
+
batchSize: number;
|
|
355
|
+
version: number;
|
|
356
|
+
ready: boolean;
|
|
357
|
+
}
|
|
358
|
+
type CollectionStreamListener<T = any> = (rows: readonly T[], meta: CollectionStreamMeta) => void;
|
|
359
|
+
interface CollectionStream<T = any> {
|
|
360
|
+
/** Subscribe to stream updates (call unsubscribe to stop). */
|
|
361
|
+
subscribe: (listener: CollectionStreamListener<T>, emitCurrent?: boolean) => () => void;
|
|
362
|
+
/** Returns the latest immutable snapshot of rows. */
|
|
363
|
+
getSnapshot: () => readonly T[];
|
|
364
|
+
/** Returns true after the initial snapshot has been received. */
|
|
365
|
+
isReady: () => boolean;
|
|
366
|
+
/** Monotonic version incremented on each flush. */
|
|
367
|
+
getVersion: () => number;
|
|
368
|
+
/** Stop the underlying realtime subscription and cleanup timers/listeners. */
|
|
369
|
+
close: () => void;
|
|
370
|
+
/** Attach subscription-level error handler. */
|
|
371
|
+
onError: (callback: SubscriptionErrorCallback) => CollectionStream<T>;
|
|
372
|
+
/** Attach permission-denied handler. */
|
|
373
|
+
onPermissionDenied: (callback: SubscriptionErrorCallback) => CollectionStream<T>;
|
|
374
|
+
}
|
|
375
|
+
interface CollectionExternalStore<T = any> {
|
|
376
|
+
/** Standard external-store subscribe signature used by UI store hooks. */
|
|
377
|
+
subscribe: (onStoreChange: () => void) => () => void;
|
|
378
|
+
/** Returns current immutable rows snapshot. */
|
|
379
|
+
getSnapshot: () => readonly T[];
|
|
380
|
+
/** Server snapshot fallback for SSR-safe store hooks. */
|
|
381
|
+
getServerSnapshot: () => readonly T[];
|
|
382
|
+
/** Access to underlying realtime stream for advanced handlers. */
|
|
383
|
+
stream: CollectionStream<T>;
|
|
384
|
+
/** Stops realtime stream and detaches listeners. */
|
|
385
|
+
destroy: () => void;
|
|
386
|
+
}
|
|
335
387
|
interface DocumentSnapshot<T = any> {
|
|
336
388
|
id: string;
|
|
337
389
|
data: T | null;
|
|
@@ -431,13 +483,13 @@ declare function parseValue(val: string): any;
|
|
|
431
483
|
declare class DocumentQueryBuilder<T = any> implements PromiseLike<T | null | void> {
|
|
432
484
|
private client;
|
|
433
485
|
private collection;
|
|
434
|
-
private
|
|
486
|
+
private docIdFromRef?;
|
|
435
487
|
private whereCondition?;
|
|
436
488
|
private updateData?;
|
|
437
489
|
private setData?;
|
|
438
490
|
private deleteOp;
|
|
439
491
|
private promise?;
|
|
440
|
-
constructor(client: FlareClient<any>, collection: string,
|
|
492
|
+
constructor(client: FlareClient<any>, collection: string, docIdFromRef?: string | undefined);
|
|
441
493
|
/**
|
|
442
494
|
* Set where condition
|
|
443
495
|
*/
|
|
@@ -455,7 +507,7 @@ declare class DocumentQueryBuilder<T = any> implements PromiseLike<T | null | vo
|
|
|
455
507
|
*/
|
|
456
508
|
delete(): this;
|
|
457
509
|
/**
|
|
458
|
-
* Get the document ID from
|
|
510
|
+
* Get the document ID from doc() reference or where condition.
|
|
459
511
|
*/
|
|
460
512
|
private getDocId;
|
|
461
513
|
/**
|
|
@@ -481,9 +533,7 @@ declare class DocumentQueryBuilder<T = any> implements PromiseLike<T | null | vo
|
|
|
481
533
|
onSnapshot(callback: SubscriptionCallback<T>): () => void;
|
|
482
534
|
}
|
|
483
535
|
|
|
484
|
-
/**
|
|
485
|
-
* Legacy document reference (for backward compatibility)
|
|
486
|
-
*/
|
|
536
|
+
/** Document reference */
|
|
487
537
|
declare class DocumentReference<T = any> {
|
|
488
538
|
private client;
|
|
489
539
|
readonly collection: string;
|
|
@@ -496,13 +546,8 @@ declare class DocumentReference<T = any> {
|
|
|
496
546
|
onSnapshot(callback: SubscriptionCallback<T>): () => void;
|
|
497
547
|
/**
|
|
498
548
|
* Fires when this document is updated / replaced.
|
|
499
|
-
* Aliases: onDocModified, onDocChange
|
|
500
549
|
*/
|
|
501
550
|
onDocUpdated(callback: DocUpdatedCallback<T>): () => void;
|
|
502
|
-
/** Alias for onDocUpdated */
|
|
503
|
-
onDocModified(callback: DocUpdatedCallback<T>): () => void;
|
|
504
|
-
/** Alias for onDocUpdated */
|
|
505
|
-
onDocChange(callback: DocUpdatedCallback<T>): () => void;
|
|
506
551
|
/**
|
|
507
552
|
* Fires when this document is deleted.
|
|
508
553
|
*/
|
|
@@ -533,6 +578,9 @@ declare class CollectionReference<T = any, TPresetMap extends QueryPresetMap = {
|
|
|
533
578
|
private appendAndFilters;
|
|
534
579
|
private toOrNode;
|
|
535
580
|
private toAndNode;
|
|
581
|
+
private isLeafFilter;
|
|
582
|
+
private isIdentityGuard;
|
|
583
|
+
private splitIdentityGuards;
|
|
536
584
|
private appendOrFilters;
|
|
537
585
|
private appendFilters;
|
|
538
586
|
with<Name extends keyof TPresetMap & string>(name: Name, params: QueryPresetParams<TPresetMap[Name]>): CollectionQuery<QueryPresetRow<TPresetMap[Name]>, TPresetMap>;
|
|
@@ -570,6 +618,8 @@ declare class CollectionReference<T = any, TPresetMap extends QueryPresetMap = {
|
|
|
570
618
|
orNotExists(field: string): CollectionQuery<T, TPresetMap>;
|
|
571
619
|
/** Get items starting from the most recently created (descending sequence) */
|
|
572
620
|
latest(): CollectionQuery<T, TPresetMap>;
|
|
621
|
+
/** Get items starting from the most recently created (descending sequence) */
|
|
622
|
+
newest(): CollectionQuery<T, TPresetMap>;
|
|
573
623
|
/** Get items starting from the first ever created (ascending sequence) */
|
|
574
624
|
oldest(): CollectionQuery<T, TPresetMap>;
|
|
575
625
|
orderBy(field: string, dir?: "asc" | "desc"): CollectionQuery<T, TPresetMap>;
|
|
@@ -589,6 +639,9 @@ declare class CollectionReference<T = any, TPresetMap extends QueryPresetMap = {
|
|
|
589
639
|
groupBy(...fields: string[]): CollectionQuery<T, TPresetMap>;
|
|
590
640
|
having(field: string, op: HavingClause['op'], value: number): CollectionQuery<T, TPresetMap>;
|
|
591
641
|
private buildStructuredJoin;
|
|
642
|
+
private cloneStructuredJoin;
|
|
643
|
+
private appendNestedJoinByAlias;
|
|
644
|
+
private parseRelationRef;
|
|
592
645
|
/**
|
|
593
646
|
* Join another collection into this query.
|
|
594
647
|
*
|
|
@@ -596,19 +649,26 @@ declare class CollectionReference<T = any, TPresetMap extends QueryPresetMap = {
|
|
|
596
649
|
* @param j Join mapping clause.
|
|
597
650
|
* @example
|
|
598
651
|
* flare.collection("boards")
|
|
599
|
-
* .
|
|
652
|
+
* .join("tasks", { source: "id", target: "boardId", as: "tasks" })
|
|
600
653
|
* .get();
|
|
601
654
|
*/
|
|
655
|
+
join(collectionName: string, j: JoinClause): CollectionQuery<T, TPresetMap>;
|
|
656
|
+
/**
|
|
657
|
+
* Append a nested join under an existing join alias.
|
|
658
|
+
* Example:
|
|
659
|
+
* .join("lists", { source: "id", target: "boardId", as: "lists" })
|
|
660
|
+
* .joinNested("lists", "cards", { source: "id", target: "listId", as: "cards" })
|
|
661
|
+
*/
|
|
662
|
+
joinNested(parentAlias: string, collectionName: string, j: JoinClause): CollectionQuery<T, TPresetMap>;
|
|
602
663
|
Join(collectionName: string, j: JoinClause): CollectionQuery<T, TPresetMap>;
|
|
664
|
+
JoinNested(parentAlias: string, collectionName: string, j: JoinClause): CollectionQuery<T, TPresetMap>;
|
|
603
665
|
/**
|
|
604
|
-
*
|
|
605
|
-
*
|
|
666
|
+
* SQL-like relation shorthand.
|
|
667
|
+
* Example: .withRelation("team.uid->users.id", { as: "teamMembers" })
|
|
606
668
|
*/
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
collection?: string;
|
|
611
|
-
}): CollectionQuery<T, TPresetMap>;
|
|
669
|
+
withRelation(relation: string, options?: (Omit<JoinClause, 'source' | 'target' | 'as'> & {
|
|
670
|
+
as?: string;
|
|
671
|
+
})): CollectionQuery<T, TPresetMap>;
|
|
612
672
|
select(...fields: string[]): CollectionQuery<T, TPresetMap>;
|
|
613
673
|
/** Returns unique values for a single field */
|
|
614
674
|
distinctField(field: string): CollectionQuery<T, TPresetMap>;
|
|
@@ -618,6 +678,10 @@ declare class CollectionReference<T = any, TPresetMap extends QueryPresetMap = {
|
|
|
618
678
|
* col.vectorSearch({ field: "embedding", vector: [...1536 numbers...], k: 10 })
|
|
619
679
|
*/
|
|
620
680
|
vectorSearch(opts: VectorSearchClause): CollectionQuery<T, TPresetMap>;
|
|
681
|
+
getRawQuery(): {
|
|
682
|
+
collection: string;
|
|
683
|
+
query: StructuredQuery;
|
|
684
|
+
};
|
|
621
685
|
get(): Promise<T[]>;
|
|
622
686
|
private _isStructured;
|
|
623
687
|
private _execute;
|
|
@@ -632,10 +696,18 @@ declare class CollectionReference<T = any, TPresetMap extends QueryPresetMap = {
|
|
|
632
696
|
* the live result consistent.
|
|
633
697
|
*/
|
|
634
698
|
onSnapshot(callback: SubscriptionCallback<T[]>): SubscriptionHandle;
|
|
699
|
+
/**
|
|
700
|
+
* High-throughput stream wrapper for bursty collections (chat, feeds, logs).
|
|
701
|
+
* It keeps local state and flushes change bursts in batches to reduce UI churn.
|
|
702
|
+
*/
|
|
703
|
+
stream(options?: CollectionStreamOptions<T>): CollectionStream<T>;
|
|
704
|
+
/**
|
|
705
|
+
* Framework-agnostic external-store bridge.
|
|
706
|
+
* Compatible with UI hooks expecting subscribe/getSnapshot signatures.
|
|
707
|
+
*/
|
|
708
|
+
asStore(options?: CollectionStreamOptions<T>): CollectionExternalStore<T>;
|
|
635
709
|
onDocAdded(callback: DocAddedCallback<T>): () => void;
|
|
636
710
|
onDocUpdated(callback: DocUpdatedCallback<T>): () => void;
|
|
637
|
-
onDocModified(callback: DocUpdatedCallback<T>): () => void;
|
|
638
|
-
onDocChange(callback: DocUpdatedCallback<T>): () => void;
|
|
639
711
|
onDocDeleted(callback: DocDeletedCallback<T>): () => void;
|
|
640
712
|
onDocChanged(callback: DocChangedCallback<T>): () => void;
|
|
641
713
|
add(data: Partial<T>): Promise<DocumentReference<T>>;
|
|
@@ -737,7 +809,7 @@ type ActiveSubscription = {
|
|
|
737
809
|
liveId: string;
|
|
738
810
|
collection: string;
|
|
739
811
|
docId?: string;
|
|
740
|
-
query?:
|
|
812
|
+
query?: StructuredQuery;
|
|
741
813
|
callback: SubscriptionCallback;
|
|
742
814
|
options: SubscribeOptions;
|
|
743
815
|
};
|
|
@@ -872,7 +944,7 @@ declare class FlareBase<TPresetMap extends QueryPresetMap = {}> {
|
|
|
872
944
|
protected toSubscriptionError(err: unknown): SubscriptionError;
|
|
873
945
|
protected emitSubscriptionError(baseId: string, error: SubscriptionError): void;
|
|
874
946
|
protected replayActiveSubscriptions(): Promise<void>;
|
|
875
|
-
subscribe(subId: string, collection: string, docId: string | undefined, query:
|
|
947
|
+
subscribe(subId: string, collection: string, docId: string | undefined, query: StructuredQuery | undefined, callback: SubscriptionCallback, options?: SubscribeOptions): SubscriptionHandle;
|
|
876
948
|
send(type: FlareAction, payload: any): Promise<any>;
|
|
877
949
|
private handleTransportError;
|
|
878
950
|
protected onConnected(): void;
|
|
@@ -1420,4 +1492,4 @@ declare const getFlare: () => FlareClient | null;
|
|
|
1420
1492
|
*/
|
|
1421
1493
|
declare const disconnectFlare: () => void;
|
|
1422
1494
|
|
|
1423
|
-
export { type AggregateFunction, type AggregateSpec, type AndFilter, type AnyFilter, type AuthConfigListener, type AuthConfigResponse, type AuthResult, type AuthStateListener, type AuthWithPendingVerificationResult, type AuthWithTokenResult, type BaseMessage, type BrowserPushRegistrationOptions, type BrowserPushTokenOptions, type ChangeEvent, type ChangeOperation, type CollectionPresetMethods, type CollectionQuery, CollectionReference, type ConnectionState, type CsrfProxyConfig, type CursorValue, type DocAddedCallback, type DocChangedCallback, type DocDeletedCallback, type DocUpdatedCallback, DocumentQueryBuilder, DocumentReference, type DocumentSnapshot, type EmailLinkVerifyResult, type EmailSendResult, FlareAction, type FlareAuthConfig, type FlareAuthProviderId, type FlareAuthProviderPublicConfig, type FlareAuthSession, type FlareAuthUser, type FlareConfig, FlareError, FlareErrors, FlareEvent, FlareResponseCodes, type FlareRule, type GroupByClause, type HavingClause, type JoinClause, type JoinQueryPattern, type NestedJoinClause, type OfflineOperation, type OrFilter, type OrderByClause, type PresenceCallback, type PresenceJoinCallback, type PresenceLeaveCallback, type PresenceMember, type PushSendResult, type QueryConfig, type QueryOperator, type QueryPresetMap, type QueryPresetParams, type QueryPresetRow, type QueryPresetSpec, type QuerySnapshot, type RegisterPushTokenInput, type RulePermission, type SecurityRuleEntry, type SecurityRulesMap, type SendEmailInput, type SendPushNotificationInput, type SnapshotEvent, type StructuredJoinClause, type StructuredQuery, type SubscribeMessage, type SubscribeOptions, type SubscriptionCallback, type SubscriptionData, type SubscriptionError, type SubscriptionErrorCallback, type SubscriptionHandle, type VectorFieldConfig, type VectorSearchClause, type VerifyEmailLinkInput, type WhereCondition, buildFlareHeaders, connectApp, createCsrfProxy, createCsrfProxyHandler,
|
|
1495
|
+
export { type AggregateFunction, type AggregateSpec, type AndFilter, type AnyFilter, type AuthConfigListener, type AuthConfigResponse, type AuthResult, type AuthStateListener, type AuthWithPendingVerificationResult, type AuthWithTokenResult, type BaseMessage, type BrowserPushRegistrationOptions, type BrowserPushTokenOptions, type ChangeEvent, type ChangeOperation, type CollectionExternalStore, type CollectionPresetMethods, type CollectionQuery, CollectionReference, type CollectionStream, type CollectionStreamListener, type CollectionStreamMeta, type CollectionStreamOptions, type ConnectionState, type CsrfProxyConfig, type CursorValue, type DocAddedCallback, type DocChangedCallback, type DocDeletedCallback, type DocUpdatedCallback, DocumentQueryBuilder, DocumentReference, type DocumentSnapshot, type EmailLinkVerifyResult, type EmailSendResult, FlareAction, type FlareAuthConfig, type FlareAuthProviderId, type FlareAuthProviderPublicConfig, type FlareAuthSession, type FlareAuthUser, FlareClient, type FlareConfig, FlareError, FlareErrors, FlareEvent, FlareResponseCodes, type FlareRule, type GroupByClause, type HavingClause, type JoinClause, type JoinQueryPattern, type NestedJoinClause, type OfflineOperation, type OrFilter, type OrderByClause, type PresenceCallback, type PresenceJoinCallback, type PresenceLeaveCallback, type PresenceMember, type PushSendResult, type QueryConfig, type QueryOperator, type QueryPresetMap, type QueryPresetParams, type QueryPresetRow, type QueryPresetSpec, type QuerySnapshot, type RegisterPushTokenInput, type RulePermission, type SecurityRuleEntry, type SecurityRulesMap, type SendEmailInput, type SendPushNotificationInput, type SnapshotEvent, type StreamFlushReason, type StructuredJoinClause, type StructuredQuery, type SubscribeMessage, type SubscribeOptions, type SubscriptionCallback, type SubscriptionData, type SubscriptionError, type SubscriptionErrorCallback, type SubscriptionHandle, type VectorFieldConfig, type VectorSearchClause, type VerifyEmailLinkInput, type WhereCondition, buildFlareHeaders, connectApp, createCsrfProxy, createCsrfProxyHandler, disconnectFlare, extractCsrfFromRequest, flareRulesToSecurityMap, getFlare, parseValue, parseWhereCondition, securityMapToFlareRules };
|