@zuzjs/flare 0.2.2 → 0.2.4
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/dist/index.cjs +2 -2
- package/dist/index.d.cts +221 -40
- package/dist/index.d.ts +221 -40
- package/dist/index.js +2 -2
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -59,7 +59,13 @@ interface FlareAuthSession {
|
|
|
59
59
|
email?: string | null;
|
|
60
60
|
emailVerified?: boolean;
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
interface FlareAuthUser {
|
|
63
|
+
uid: string;
|
|
64
|
+
email: string;
|
|
65
|
+
email_verified: string;
|
|
66
|
+
[x: string]: any;
|
|
67
|
+
}
|
|
68
|
+
type AuthStateListener = (session: FlareAuthSession & FlareAuthUser | null) => void;
|
|
63
69
|
type AuthConfigListener = (conf: FlareAuthConfig) => void;
|
|
64
70
|
interface SubscribeOptions {
|
|
65
71
|
skipSnapshot?: boolean;
|
|
@@ -97,12 +103,62 @@ interface AggregateSpec {
|
|
|
97
103
|
field?: string;
|
|
98
104
|
alias?: string;
|
|
99
105
|
}
|
|
100
|
-
|
|
106
|
+
/**
|
|
107
|
+
* Join definition used by CollectionReference.Join().
|
|
108
|
+
*
|
|
109
|
+
* Example:
|
|
110
|
+
* Join("tasks", { source: "id", target: "boardId", as: "tasks" })
|
|
111
|
+
*/
|
|
112
|
+
interface JoinQueryPattern {
|
|
113
|
+
where?: AnyFilter[];
|
|
114
|
+
orderBy?: OrderByClause[];
|
|
115
|
+
limit?: number;
|
|
116
|
+
offset?: number;
|
|
117
|
+
startAt?: CursorValue;
|
|
118
|
+
startAfter?: CursorValue;
|
|
119
|
+
endAt?: CursorValue;
|
|
120
|
+
endBefore?: CursorValue;
|
|
121
|
+
aggregate?: AggregateSpec[];
|
|
122
|
+
groupBy?: GroupByClause;
|
|
123
|
+
having?: HavingClause[];
|
|
124
|
+
vectorSearch?: VectorSearchClause;
|
|
125
|
+
select?: string[];
|
|
126
|
+
distinctField?: string;
|
|
127
|
+
}
|
|
128
|
+
interface NestedJoinClause extends JoinQueryPattern {
|
|
129
|
+
/** Joined collection name for this nested join. */
|
|
130
|
+
collection: string;
|
|
131
|
+
/** Field from the parent join result. */
|
|
132
|
+
source: string;
|
|
133
|
+
/** Field from this nested collection to match source. */
|
|
134
|
+
target: string;
|
|
135
|
+
/** Alias where nested rows are attached in each parent join row. */
|
|
136
|
+
as: string;
|
|
137
|
+
/** If true, expect at most one joined row. */
|
|
138
|
+
single?: boolean;
|
|
139
|
+
/** Recursive nested joins. */
|
|
140
|
+
joins?: NestedJoinClause[];
|
|
141
|
+
}
|
|
142
|
+
interface JoinClause extends JoinQueryPattern {
|
|
143
|
+
/** Field from the base collection (the collection you started the query on). */
|
|
144
|
+
source: string;
|
|
145
|
+
/** Field from the joined collection that should match source. */
|
|
146
|
+
target: string;
|
|
147
|
+
/** Alias where joined rows will be attached in each result object. */
|
|
148
|
+
as: string;
|
|
149
|
+
/** If true, expect at most one joined row (object instead of array on server side). */
|
|
150
|
+
single?: boolean;
|
|
151
|
+
/** Optional nested joins under this join. */
|
|
152
|
+
joins?: NestedJoinClause[];
|
|
153
|
+
}
|
|
154
|
+
/** Internal wire-ready join shape sent to server query engine. */
|
|
155
|
+
interface StructuredJoinClause extends JoinQueryPattern {
|
|
101
156
|
from: string;
|
|
102
157
|
localField: string;
|
|
103
158
|
foreignField: string;
|
|
104
159
|
as: string;
|
|
105
160
|
single?: boolean;
|
|
161
|
+
joins?: StructuredJoinClause[];
|
|
106
162
|
}
|
|
107
163
|
interface VectorSearchClause {
|
|
108
164
|
field: string;
|
|
@@ -124,11 +180,18 @@ interface StructuredQuery {
|
|
|
124
180
|
aggregate?: AggregateSpec[];
|
|
125
181
|
groupBy?: GroupByClause;
|
|
126
182
|
having?: HavingClause[];
|
|
127
|
-
joins?:
|
|
183
|
+
joins?: StructuredJoinClause[];
|
|
128
184
|
vectorSearch?: VectorSearchClause;
|
|
129
185
|
select?: string[];
|
|
130
186
|
distinctField?: string;
|
|
131
187
|
}
|
|
188
|
+
type QueryPresetSpec<Params extends Record<string, unknown> = Record<string, unknown>, Row = any> = {
|
|
189
|
+
params: Params;
|
|
190
|
+
row: Row;
|
|
191
|
+
};
|
|
192
|
+
type QueryPresetMap = Record<string, QueryPresetSpec<any, any>>;
|
|
193
|
+
type QueryPresetParams<TSpec> = TSpec extends QueryPresetSpec<infer Params, any> ? Params : Record<string, unknown>;
|
|
194
|
+
type QueryPresetRow<TSpec> = TSpec extends QueryPresetSpec<any, infer Row> ? Row : any;
|
|
132
195
|
type ChangeOperation = 'insert' | 'update' | 'replace' | 'delete';
|
|
133
196
|
/**
|
|
134
197
|
* Fired once when the subscription is first established.
|
|
@@ -155,6 +218,20 @@ interface ChangeEvent<T = any> {
|
|
|
155
218
|
/** Discriminated union — narrow on `event.type` to get the right shape. */
|
|
156
219
|
type SubscriptionData<T = any> = SnapshotEvent<T> | ChangeEvent<T>;
|
|
157
220
|
type SubscriptionCallback<T = any> = (data: SubscriptionData<T>) => void;
|
|
221
|
+
interface SubscriptionError {
|
|
222
|
+
code?: string;
|
|
223
|
+
message: string;
|
|
224
|
+
permissionDenied: boolean;
|
|
225
|
+
raw?: unknown;
|
|
226
|
+
}
|
|
227
|
+
type SubscriptionErrorCallback = (error: SubscriptionError) => void;
|
|
228
|
+
interface SubscriptionHandle {
|
|
229
|
+
(): void;
|
|
230
|
+
unsubscribe: () => void;
|
|
231
|
+
onError: (callback: SubscriptionErrorCallback) => SubscriptionHandle;
|
|
232
|
+
onPermissionDenied: (callback: SubscriptionErrorCallback) => SubscriptionHandle;
|
|
233
|
+
catch: (callback: SubscriptionErrorCallback) => SubscriptionHandle;
|
|
234
|
+
}
|
|
158
235
|
type DocAddedCallback<T = any> = (data: T, docId: string) => void;
|
|
159
236
|
type DocUpdatedCallback<T = any> = (data: T, docId: string) => void;
|
|
160
237
|
type DocDeletedCallback<T = any> = (docId: string) => void;
|
|
@@ -216,6 +293,26 @@ type VectorFieldConfig = {
|
|
|
216
293
|
/** Optional custom embedding function; defaults to client-configured embedder */
|
|
217
294
|
embed?: (text: string) => Promise<number[]>;
|
|
218
295
|
};
|
|
296
|
+
type RulePermission = "create" | "read" | "update" | "delete";
|
|
297
|
+
interface FlareRule {
|
|
298
|
+
id: string;
|
|
299
|
+
name: string;
|
|
300
|
+
auth: "any" | "guest" | "auth";
|
|
301
|
+
collection: string;
|
|
302
|
+
document?: string;
|
|
303
|
+
condition?: string;
|
|
304
|
+
permissions: RulePermission[];
|
|
305
|
+
}
|
|
306
|
+
interface SecurityRuleEntry {
|
|
307
|
+
".read"?: string;
|
|
308
|
+
".write"?: string;
|
|
309
|
+
".create"?: string;
|
|
310
|
+
".update"?: string;
|
|
311
|
+
".delete"?: string;
|
|
312
|
+
}
|
|
313
|
+
type SecurityRulesMap = Record<string, SecurityRuleEntry>;
|
|
314
|
+
declare const flareRulesToSecurityMap: (rules: FlareRule[]) => SecurityRulesMap;
|
|
315
|
+
declare const securityMapToFlareRules: (rules: SecurityRulesMap) => FlareRule[];
|
|
219
316
|
|
|
220
317
|
/**
|
|
221
318
|
* Parse ORM-style where condition: { age: ">= 25", role: "admin" }
|
|
@@ -244,7 +341,7 @@ declare class DocumentQueryBuilder<T = any> implements PromiseLike<T | null | vo
|
|
|
244
341
|
private setData?;
|
|
245
342
|
private deleteOp;
|
|
246
343
|
private promise?;
|
|
247
|
-
constructor(client: FlareClient
|
|
344
|
+
constructor(client: FlareClient<any>, collection: string, legacyId?: string | undefined);
|
|
248
345
|
/**
|
|
249
346
|
* Set where condition
|
|
250
347
|
*/
|
|
@@ -295,7 +392,7 @@ declare class DocumentReference<T = any> {
|
|
|
295
392
|
private client;
|
|
296
393
|
readonly collection: string;
|
|
297
394
|
readonly id: string;
|
|
298
|
-
constructor(client: FlareClient
|
|
395
|
+
constructor(client: FlareClient<any>, collection: string, id: string);
|
|
299
396
|
get(): Promise<T | null>;
|
|
300
397
|
set(data: Partial<T>): Promise<void>;
|
|
301
398
|
update(data: Partial<T>): Promise<void>;
|
|
@@ -321,46 +418,76 @@ declare class DocumentReference<T = any> {
|
|
|
321
418
|
onDocChanged(callback: DocChangedCallback<T>): () => void;
|
|
322
419
|
}
|
|
323
420
|
|
|
324
|
-
|
|
421
|
+
type CollectionPresetMethods<TPresetMap extends QueryPresetMap> = {
|
|
422
|
+
[K in keyof TPresetMap & string]: (params: QueryPresetParams<TPresetMap[K]>) => CollectionQuery<QueryPresetRow<TPresetMap[K]>, TPresetMap>;
|
|
423
|
+
};
|
|
424
|
+
type CollectionQuery<T = any, TPresetMap extends QueryPresetMap = {}> = CollectionReference<T, TPresetMap> & CollectionPresetMethods<TPresetMap>;
|
|
425
|
+
declare class CollectionReference<T = any, TPresetMap extends QueryPresetMap = {}> implements PromiseLike<T[]> {
|
|
325
426
|
private client;
|
|
326
427
|
readonly collection: string;
|
|
327
428
|
private sq;
|
|
328
429
|
private promise?;
|
|
329
|
-
constructor(client: FlareClient
|
|
430
|
+
constructor(client: FlareClient<TPresetMap>, collection: string);
|
|
330
431
|
doc(id: string): DocumentReference<T>;
|
|
331
432
|
private clone;
|
|
433
|
+
with<Name extends keyof TPresetMap & string>(name: Name, params: QueryPresetParams<TPresetMap[Name]>): CollectionQuery<QueryPresetRow<TPresetMap[Name]>, TPresetMap>;
|
|
434
|
+
with(name: string, params?: Record<string, unknown>): CollectionQuery<T, TPresetMap>;
|
|
332
435
|
/** ORM shorthand: .where({ age: ">= 25", role: "admin" }) */
|
|
333
|
-
where(condition: WhereCondition):
|
|
436
|
+
where(condition: WhereCondition): CollectionQuery<T, TPresetMap>;
|
|
334
437
|
/** Explicit field/op/value */
|
|
335
|
-
where(field: string, op: QueryConfig['op'], value: unknown):
|
|
438
|
+
where(field: string, op: QueryConfig['op'], value: unknown): CollectionQuery<T, TPresetMap>;
|
|
336
439
|
/** OR group: .orWhere([{ field:"status", op:"==", value:"active" }, ...]) */
|
|
337
|
-
orWhere(filters: QueryConfig[]):
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
440
|
+
orWhere(filters: QueryConfig[]): CollectionQuery<T, TPresetMap>;
|
|
441
|
+
/** Get items starting from the most recently created (descending sequence) */
|
|
442
|
+
latest(): CollectionQuery<T, TPresetMap>;
|
|
443
|
+
/** Get items starting from the first ever created (ascending sequence) */
|
|
444
|
+
oldest(): CollectionQuery<T, TPresetMap>;
|
|
445
|
+
orderBy(field: string, dir?: "asc" | "desc"): CollectionQuery<T, TPresetMap>;
|
|
446
|
+
limit(n: number): CollectionQuery<T, TPresetMap>;
|
|
447
|
+
offset(n: number): CollectionQuery<T, TPresetMap>;
|
|
448
|
+
startAt(...values: unknown[]): CollectionQuery<T, TPresetMap>;
|
|
449
|
+
startAfter(...values: unknown[]): CollectionQuery<T, TPresetMap>;
|
|
450
|
+
endAt(...values: unknown[]): CollectionQuery<T, TPresetMap>;
|
|
451
|
+
endBefore(...values: unknown[]): CollectionQuery<T, TPresetMap>;
|
|
452
|
+
aggregate(...specs: AggregateSpec[]): CollectionQuery<T, TPresetMap>;
|
|
453
|
+
count(alias?: string): CollectionQuery<T, TPresetMap>;
|
|
454
|
+
sum(field: string, alias?: string): CollectionQuery<T, TPresetMap>;
|
|
455
|
+
avg(field: string, alias?: string): CollectionQuery<T, TPresetMap>;
|
|
456
|
+
min(field: string, alias?: string): CollectionQuery<T, TPresetMap>;
|
|
457
|
+
max(field: string, alias?: string): CollectionQuery<T, TPresetMap>;
|
|
458
|
+
distinct(field: string, alias?: string): CollectionQuery<T, TPresetMap>;
|
|
459
|
+
groupBy(...fields: string[]): CollectionQuery<T, TPresetMap>;
|
|
460
|
+
having(field: string, op: HavingClause['op'], value: number): CollectionQuery<T, TPresetMap>;
|
|
461
|
+
private buildStructuredJoin;
|
|
462
|
+
/**
|
|
463
|
+
* Join another collection into this query.
|
|
464
|
+
*
|
|
465
|
+
* @param collectionName Joined collection name.
|
|
466
|
+
* @param j Join mapping clause.
|
|
467
|
+
* @example
|
|
468
|
+
* flare.collection("boards")
|
|
469
|
+
* .Join("tasks", { source: "id", target: "boardId", as: "tasks" })
|
|
470
|
+
* .get();
|
|
471
|
+
*/
|
|
472
|
+
Join(collectionName: string, j: JoinClause): CollectionQuery<T, TPresetMap>;
|
|
473
|
+
/**
|
|
474
|
+
* Legacy join signature.
|
|
475
|
+
* Prefer Join(collectionName, clause) for better readability.
|
|
476
|
+
*/
|
|
477
|
+
join(collectionName: string, j: JoinClause): CollectionQuery<T, TPresetMap>;
|
|
478
|
+
join(j: JoinClause & {
|
|
479
|
+
from?: string;
|
|
480
|
+
collection?: string;
|
|
481
|
+
}): CollectionQuery<T, TPresetMap>;
|
|
482
|
+
select(...fields: string[]): CollectionQuery<T, TPresetMap>;
|
|
356
483
|
/** Returns unique values for a single field */
|
|
357
|
-
distinctField(field: string):
|
|
484
|
+
distinctField(field: string): CollectionQuery<T, TPresetMap>;
|
|
358
485
|
/**
|
|
359
486
|
* KNN nearest-neighbour search (requires Atlas vector index).
|
|
360
487
|
* @example
|
|
361
488
|
* col.vectorSearch({ field: "embedding", vector: [...1536 numbers...], k: 10 })
|
|
362
489
|
*/
|
|
363
|
-
vectorSearch(opts: VectorSearchClause):
|
|
490
|
+
vectorSearch(opts: VectorSearchClause): CollectionQuery<T, TPresetMap>;
|
|
364
491
|
get(): Promise<T[]>;
|
|
365
492
|
private _isStructured;
|
|
366
493
|
private _execute;
|
|
@@ -374,7 +501,7 @@ declare class CollectionReference<T = any> implements PromiseLike<T[]> {
|
|
|
374
501
|
* Individual change events are then sorted / filtered client-side to keep
|
|
375
502
|
* the live result consistent.
|
|
376
503
|
*/
|
|
377
|
-
onSnapshot(callback: SubscriptionCallback<T[]>):
|
|
504
|
+
onSnapshot(callback: SubscriptionCallback<T[]>): SubscriptionHandle;
|
|
378
505
|
onDocAdded(callback: DocAddedCallback<T>): () => void;
|
|
379
506
|
onDocUpdated(callback: DocUpdatedCallback<T>): () => void;
|
|
380
507
|
onDocModified(callback: DocUpdatedCallback<T>): () => void;
|
|
@@ -470,6 +597,11 @@ declare class FlareTransport {
|
|
|
470
597
|
|
|
471
598
|
type ConnectionListener = (state: ConnectionState) => void;
|
|
472
599
|
type ErrorListener = (error: Error) => void;
|
|
600
|
+
type HttpResponseSnapshot = {
|
|
601
|
+
status: number;
|
|
602
|
+
headers: Record<string, string>;
|
|
603
|
+
data: any;
|
|
604
|
+
};
|
|
473
605
|
type ActiveSubscription = {
|
|
474
606
|
baseId: string;
|
|
475
607
|
liveId: string;
|
|
@@ -479,14 +611,19 @@ type ActiveSubscription = {
|
|
|
479
611
|
callback: SubscriptionCallback;
|
|
480
612
|
options: SubscribeOptions;
|
|
481
613
|
};
|
|
614
|
+
type QueryPresetHandler<Params extends Record<string, unknown> = Record<string, unknown>, Row = any> = (ref: CollectionQuery<any, any>, params: Params) => CollectionQuery<Row, any>;
|
|
482
615
|
/** Embedder function registered by the user */
|
|
483
616
|
type EmbedFn = (text: string) => Promise<number[]>;
|
|
484
|
-
declare class FlareBase {
|
|
617
|
+
declare class FlareBase<TPresetMap extends QueryPresetMap = {}> {
|
|
485
618
|
protected transport: FlareTransport;
|
|
486
619
|
protected readonly config: FlareConfig;
|
|
487
620
|
protected readonly pendingAcks: Map<string, (value: any) => void>;
|
|
488
621
|
protected readonly subscriptions: Map<string, SubscriptionCallback>;
|
|
489
622
|
protected readonly activeSubscriptions: Map<string, ActiveSubscription>;
|
|
623
|
+
protected readonly queryPresets: Map<string, QueryPresetHandler<any, any>>;
|
|
624
|
+
protected readonly subscriptionErrorHandlers: Map<string, Set<SubscriptionErrorCallback>>;
|
|
625
|
+
protected readonly subscriptionPermissionHandlers: Map<string, Set<SubscriptionErrorCallback>>;
|
|
626
|
+
protected readonly subscriptionLastErrors: Map<string, SubscriptionError>;
|
|
490
627
|
protected readonly offlineQueue: any[];
|
|
491
628
|
protected currentState: ConnectionState;
|
|
492
629
|
protected connectionListeners: ConnectionListener[];
|
|
@@ -497,6 +634,9 @@ declare class FlareBase {
|
|
|
497
634
|
protected subscriptionReplayPromise: Promise<void>;
|
|
498
635
|
protected requestTraceSeq: number;
|
|
499
636
|
protected requestTimingEnabled: boolean;
|
|
637
|
+
protected httpInFlight: Map<string, Promise<HttpResponseSnapshot>>;
|
|
638
|
+
protected httpResponseCache: Map<string, HttpResponseSnapshot>;
|
|
639
|
+
protected readonly maxHttpCacheEntries = 200;
|
|
500
640
|
protected presenceCallbacks: Map<string, PresenceCallback[]>;
|
|
501
641
|
protected presenceJoinCbs: Map<string, PresenceJoinCallback[]>;
|
|
502
642
|
protected presenceLeaveCbs: Map<string, PresenceLeaveCallback[]>;
|
|
@@ -507,8 +647,33 @@ declare class FlareBase {
|
|
|
507
647
|
protected nowMs(): number;
|
|
508
648
|
protected normalizeHeaders(headers?: HeadersInit): Record<string, string>;
|
|
509
649
|
protected redactHeaders(headers: Record<string, string>): Record<string, string>;
|
|
650
|
+
protected stableStringify(value: unknown): string;
|
|
651
|
+
protected buildHttpCacheKey(method: string, url: string, headers: Record<string, string>, body: unknown, credentials?: RequestCredentials): string;
|
|
652
|
+
protected shouldCacheResponse(method: string, url: string): boolean;
|
|
653
|
+
protected rememberHttpResponse(key: string, value: HttpResponseSnapshot): void;
|
|
654
|
+
protected createTimedFetchTrace(snapshot: HttpResponseSnapshot, requestId: number, startedAtMs: number, method: string, url: string, networkMs: number): {
|
|
655
|
+
response: {
|
|
656
|
+
status: number;
|
|
657
|
+
ok: boolean;
|
|
658
|
+
headers: {
|
|
659
|
+
get: (name: string) => string | null;
|
|
660
|
+
};
|
|
661
|
+
json: () => Promise<any>;
|
|
662
|
+
};
|
|
663
|
+
requestId: number;
|
|
664
|
+
startedAtMs: number;
|
|
665
|
+
networkMs: number;
|
|
666
|
+
method: string;
|
|
667
|
+
url: string;
|
|
668
|
+
};
|
|
510
669
|
protected logHttpTiming(...args: any[]): void;
|
|
511
670
|
protected mergeHeaders(base: HeadersInit | undefined, extra: Record<string, string>): HeadersInit;
|
|
671
|
+
protected toWireField(field: string): string;
|
|
672
|
+
protected fromWireField(field: string): string;
|
|
673
|
+
protected normalizeOutboundData(value: unknown): unknown;
|
|
674
|
+
protected normalizeInboundData(value: unknown): unknown;
|
|
675
|
+
protected normalizeOutboundAnyFilter(filter: Record<string, unknown>): Record<string, unknown>;
|
|
676
|
+
protected normalizeOutboundQuery(query: unknown): unknown;
|
|
512
677
|
protected timedFetch(label: string, input: string, init?: RequestInit): Promise<{
|
|
513
678
|
response: {
|
|
514
679
|
status: number;
|
|
@@ -548,7 +713,14 @@ declare class FlareBase {
|
|
|
548
713
|
get isConnected(): boolean;
|
|
549
714
|
onConnectionStateChange(listener: ConnectionListener): () => void;
|
|
550
715
|
onError(callback: ErrorListener): () => void;
|
|
551
|
-
collection<T = any>(name: string):
|
|
716
|
+
collection<T = any>(name: string): CollectionQuery<T, TPresetMap>;
|
|
717
|
+
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>>>;
|
|
718
|
+
registerQueryPresets<TRegistry extends Record<string, QueryPresetHandler<any, any>>>(presets: TRegistry): this & FlareBase<TPresetMap & {
|
|
719
|
+
[K in keyof TRegistry]: TRegistry[K] extends QueryPresetHandler<infer Params, infer Row> ? QueryPresetSpec<Params, Row> : QueryPresetSpec<Record<string, unknown>, any>;
|
|
720
|
+
}>;
|
|
721
|
+
hasQueryPreset(name: string): boolean;
|
|
722
|
+
applyQueryPreset<Name extends keyof TPresetMap & string>(ref: CollectionReference<any, TPresetMap>, name: Name, params: QueryPresetParams<TPresetMap[Name]>): CollectionQuery<QueryPresetRow<TPresetMap[Name]>, TPresetMap>;
|
|
723
|
+
applyQueryPreset<T = any>(ref: CollectionQuery<T, TPresetMap>, name: string, params?: Record<string, unknown>): CollectionQuery<T, TPresetMap>;
|
|
552
724
|
doc<T = any>(collection: string): DocumentQueryBuilder<T>;
|
|
553
725
|
doc<T = any>(collection: string, id: string): DocumentReference<T>;
|
|
554
726
|
ping(): Promise<number>;
|
|
@@ -565,9 +737,12 @@ declare class FlareBase {
|
|
|
565
737
|
private _startPresenceHeartbeat;
|
|
566
738
|
private _stopPresenceHeartbeat;
|
|
567
739
|
syncOffline(): Promise<void>;
|
|
740
|
+
protected beforeActivateSubscription(_entry: ActiveSubscription): Promise<void>;
|
|
568
741
|
protected activateSubscription(entry: ActiveSubscription): Promise<void>;
|
|
742
|
+
protected toSubscriptionError(err: unknown): SubscriptionError;
|
|
743
|
+
protected emitSubscriptionError(baseId: string, error: SubscriptionError): void;
|
|
569
744
|
protected replayActiveSubscriptions(): Promise<void>;
|
|
570
|
-
subscribe(subId: string, collection: string, docId: string | undefined, query: QueryConfig | StructuredQuery | undefined, callback: SubscriptionCallback, options?: SubscribeOptions):
|
|
745
|
+
subscribe(subId: string, collection: string, docId: string | undefined, query: QueryConfig | StructuredQuery | undefined, callback: SubscriptionCallback, options?: SubscribeOptions): SubscriptionHandle;
|
|
571
746
|
send(type: FlareAction, payload: any): Promise<any>;
|
|
572
747
|
private handleTransportError;
|
|
573
748
|
protected onConnected(): void;
|
|
@@ -596,7 +771,7 @@ declare class FlareBase {
|
|
|
596
771
|
* the browser owns two HttpOnly cookies: one from the Flare
|
|
597
772
|
* domain and one from the Next.js domain.
|
|
598
773
|
*/
|
|
599
|
-
declare class FlareAuth extends FlareBase {
|
|
774
|
+
declare class FlareAuth<TPresetMap extends QueryPresetMap = {}> extends FlareBase<TPresetMap> {
|
|
600
775
|
protected authToken?: string;
|
|
601
776
|
protected userId?: string;
|
|
602
777
|
protected authGuard?: AuthGuard;
|
|
@@ -605,9 +780,11 @@ declare class FlareAuth extends FlareBase {
|
|
|
605
780
|
protected csrfToken?: string;
|
|
606
781
|
protected csrfInitPromise?: Promise<void>;
|
|
607
782
|
protected csrfBootstrapAttempted: boolean;
|
|
783
|
+
protected socketAuthSyncPromise?: Promise<void>;
|
|
608
784
|
protected authSession: FlareAuthSession | null;
|
|
609
785
|
protected authStateListeners: AuthStateListener[];
|
|
610
786
|
protected authConfigListeners: AuthConfigListener[];
|
|
787
|
+
protected currentProfile: FlareAuthUser | undefined;
|
|
611
788
|
private getDefaultCsrfCookieName;
|
|
612
789
|
getCsrfCookieName(): string;
|
|
613
790
|
/**
|
|
@@ -650,13 +827,15 @@ declare class FlareAuth extends FlareBase {
|
|
|
650
827
|
loadAuthConfig(): Promise<FlareAuthConfig>;
|
|
651
828
|
protected fetchAuthConfig(): Promise<FlareAuthConfig>;
|
|
652
829
|
onAuthConfigLoaded(listener: AuthConfigListener): () => void;
|
|
830
|
+
protected setProfile(profile: FlareAuthUser): void;
|
|
653
831
|
protected setAuthSession(session: FlareAuthSession | null): void;
|
|
654
832
|
onAuthStateChanged(listener: AuthStateListener): () => void;
|
|
655
833
|
onAuthStateChange(listener: AuthStateListener): () => void;
|
|
656
|
-
get currentUser():
|
|
657
|
-
getCurrentUser():
|
|
834
|
+
get currentUser(): FlareAuthUser | undefined;
|
|
835
|
+
getCurrentUser(): FlareAuthUser | undefined;
|
|
658
836
|
protected syncSocketAuth(accessToken?: string | null): Promise<void>;
|
|
659
837
|
protected updateSocketIdentity(uid?: string, forceReplay?: boolean): Promise<void>;
|
|
838
|
+
protected beforeActivateSubscription(_entry: any): Promise<void>;
|
|
660
839
|
protected onConnected(): void;
|
|
661
840
|
protected handleIncoming(msg: any): void;
|
|
662
841
|
auth(token: string): Promise<AuthResult>;
|
|
@@ -847,7 +1026,9 @@ declare class FlareAuth extends FlareBase {
|
|
|
847
1026
|
additionalParams?: Record<string, string>;
|
|
848
1027
|
signInIfAllowed?: boolean;
|
|
849
1028
|
}): Promise<Record<string, any>>;
|
|
850
|
-
protected requestEmailPasswordToken(email: string, password: string, scope?: string[]): Promise<AuthToken
|
|
1029
|
+
protected requestEmailPasswordToken(email: string, password: string, scope?: string[]): Promise<AuthToken & {
|
|
1030
|
+
kind: string;
|
|
1031
|
+
}>;
|
|
851
1032
|
protected fetchAuthMe(token: string): Promise<{
|
|
852
1033
|
id?: string;
|
|
853
1034
|
email?: string | null;
|
|
@@ -880,7 +1061,7 @@ declare class FlareAuth extends FlareBase {
|
|
|
880
1061
|
* This file wires FlareAuth together and leaves CSRF bootstrapping to the user.
|
|
881
1062
|
*/
|
|
882
1063
|
|
|
883
|
-
declare class FlareClient extends FlareAuth {
|
|
1064
|
+
declare class FlareClient<TPresetMap extends QueryPresetMap = {}> extends FlareAuth<TPresetMap> {
|
|
884
1065
|
constructor(config: FlareConfig);
|
|
885
1066
|
}
|
|
886
1067
|
|
|
@@ -1072,4 +1253,4 @@ declare const getFlare: () => FlareClient | null;
|
|
|
1072
1253
|
*/
|
|
1073
1254
|
declare const disconnectFlare: () => void;
|
|
1074
1255
|
|
|
1075
|
-
export { type AggregateFunction, type AggregateSpec, type AnyFilter, type AuthConfigListener, type AuthConfigResponse, type AuthResult, type AuthStateListener, type AuthWithPendingVerificationResult, type AuthWithTokenResult, type BaseMessage, type ChangeEvent, type ChangeOperation, CollectionReference, type ConnectionState, type CsrfProxyConfig, type CursorValue, type DocAddedCallback, type DocChangedCallback, type DocDeletedCallback, type DocUpdatedCallback, DocumentQueryBuilder, DocumentReference, type DocumentSnapshot, FlareAction, type FlareAuthConfig, type FlareAuthProviderId, type FlareAuthProviderPublicConfig, type FlareAuthSession, type FlareConfig, FlareError, FlareErrors, FlareEvent, FlareResponseCodes, type GroupByClause, type HavingClause, type JoinClause, type OfflineOperation, type OrFilter, type OrderByClause, type PresenceCallback, type PresenceJoinCallback, type PresenceLeaveCallback, type PresenceMember, type QueryConfig, type QueryOperator, type QuerySnapshot, type SnapshotEvent, type StructuredQuery, type SubscribeMessage, type SubscribeOptions, type SubscriptionCallback, type SubscriptionData, type VectorFieldConfig, type VectorSearchClause, type WhereCondition, buildFlareHeaders, connectApp, createCsrfProxy, createCsrfProxyHandler, FlareClient as default, disconnectFlare, extractCsrfFromRequest, getFlare, parseValue, parseWhereCondition };
|
|
1256
|
+
export { type AggregateFunction, type AggregateSpec, type AnyFilter, type AuthConfigListener, type AuthConfigResponse, type AuthResult, type AuthStateListener, type AuthWithPendingVerificationResult, type AuthWithTokenResult, type BaseMessage, 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, 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 QueryConfig, type QueryOperator, type QueryPresetMap, type QueryPresetParams, type QueryPresetRow, type QueryPresetSpec, type QuerySnapshot, type RulePermission, type SecurityRuleEntry, type SecurityRulesMap, 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 WhereCondition, buildFlareHeaders, connectApp, createCsrfProxy, createCsrfProxyHandler, FlareClient as default, disconnectFlare, extractCsrfFromRequest, flareRulesToSecurityMap, getFlare, parseValue, parseWhereCondition, securityMapToFlareRules };
|