@zuzjs/flare 0.2.14 → 0.2.16
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 +32 -0
- package/dist/chunk-DGCKTOF5.cjs +2 -0
- package/dist/grpc.cjs +2 -0
- package/dist/grpc.d.cts +16 -0
- package/dist/grpc.d.ts +16 -0
- package/dist/grpc.js +1 -0
- package/dist/{index-DQHYN410.d.cts → index-5uGluFZz.d.ts} +3 -505
- package/dist/index-BAvE1URE.d.cts +511 -0
- package/dist/index-BAvE1URE.d.ts +511 -0
- package/dist/{index-DQHYN410.d.ts → index-D-lTsYDe.d.cts} +3 -505
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +2 -2
- package/dist/react.cjs +1 -1
- package/dist/react.d.cts +2 -1
- package/dist/react.d.ts +2 -1
- package/package.json +5 -2
- package/proto/admin.proto +129 -0
- package/proto/app.proto +69 -0
- package/proto/auth.proto +70 -0
- package/proto/flare.proto +11 -0
- package/proto/query.proto +109 -0
|
@@ -0,0 +1,511 @@
|
|
|
1
|
+
import { AuthToken } from '@zuzjs/auth';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Client Configuration
|
|
5
|
+
*/
|
|
6
|
+
interface FlareConfig {
|
|
7
|
+
/** Base URL for the Flare API. */
|
|
8
|
+
endpoint: string;
|
|
9
|
+
/** Optional gRPC endpoint, e.g. "127.0.0.1:5051" for Node runtimes. */
|
|
10
|
+
grpcUrl?: string;
|
|
11
|
+
/** Transport preference for supported operations. */
|
|
12
|
+
transport?: "auto" | "ws" | "http" | "grpc";
|
|
13
|
+
/**
|
|
14
|
+
* Optional HTTP base URL for auth API calls.
|
|
15
|
+
* When set, all auth HTTP calls go through this base instead of calling
|
|
16
|
+
* Flare directly. Use this to route calls through a Next.js proxy so CSRF
|
|
17
|
+
* is handled entirely server-side.
|
|
18
|
+
* Example: '/api/flare' (relative, browser resolves against current origin)
|
|
19
|
+
*/
|
|
20
|
+
httpBase?: string;
|
|
21
|
+
/**
|
|
22
|
+
* WebSocket path used for realtime transport.
|
|
23
|
+
* Defaults to '/' for backward compatibility.
|
|
24
|
+
*/
|
|
25
|
+
wsPath?: string;
|
|
26
|
+
/** Unique identifier for the application. */
|
|
27
|
+
appId: string;
|
|
28
|
+
/** API key for the application. */
|
|
29
|
+
apiKey?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Request content type for credential auth endpoints (/auth/token, /auth/register).
|
|
32
|
+
* Defaults to OAuth-compatible form encoding.
|
|
33
|
+
*/
|
|
34
|
+
authRequestContentType?: "application/x-www-form-urlencoded" | "application/json";
|
|
35
|
+
/**
|
|
36
|
+
* Controls how onAuthStateChanged initializes auth in browser runtime.
|
|
37
|
+
* - `refresh` (default): attempt /auth/refresh once in httpBase mode.
|
|
38
|
+
* - `none`: skip automatic refresh bootstrap; listeners receive current in-memory state only.
|
|
39
|
+
*/
|
|
40
|
+
authBootstrapMode?: "refresh" | "none";
|
|
41
|
+
/** Public key for the application. */
|
|
42
|
+
publicKey?: string;
|
|
43
|
+
/** Whether to automatically reconnect on connection loss. */
|
|
44
|
+
autoReconnect?: boolean;
|
|
45
|
+
/** Delay between reconnection attempts in milliseconds. */
|
|
46
|
+
reconnectDelay?: number;
|
|
47
|
+
/** Maximum delay between reconnection attempts in milliseconds. */
|
|
48
|
+
maxReconnectDelay?: number;
|
|
49
|
+
/** Enable or disable debug mode. */
|
|
50
|
+
debug?: boolean;
|
|
51
|
+
/** Enable or disable request timing. */
|
|
52
|
+
requestTiming?: boolean;
|
|
53
|
+
/** Connection timeout in milliseconds. */
|
|
54
|
+
connectionTimeout?: number;
|
|
55
|
+
/** Enable automatic push notification registration on supported platforms. */
|
|
56
|
+
pushNotifications?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Optional per-collection mapper registry for shaping inbound data.
|
|
59
|
+
*
|
|
60
|
+
* Keys can be:
|
|
61
|
+
* - base collection names (e.g. "boards")
|
|
62
|
+
* - join aliases (`join(..., { as: "team" })` => "team")
|
|
63
|
+
*/
|
|
64
|
+
dataMapper?: DataMapperRegistry;
|
|
65
|
+
}
|
|
66
|
+
type DataMapperFn<TRow = any, TMapped = any> = (row: TRow) => TMapped;
|
|
67
|
+
type DataMapperRegistry = Record<string, DataMapperFn<any, any>>;
|
|
68
|
+
type FlareAuthProviderId = "credentials" | "anonymous" | "google" | "facebook" | "github" | "dropbox" | "apple" | "twitter";
|
|
69
|
+
interface FlareAuthProviderPublicConfig {
|
|
70
|
+
enabled: boolean;
|
|
71
|
+
clientId?: string;
|
|
72
|
+
scopes?: string[];
|
|
73
|
+
}
|
|
74
|
+
interface FlareAuthConfig {
|
|
75
|
+
appId: string;
|
|
76
|
+
enabled: boolean;
|
|
77
|
+
needsEmailVerification?: boolean;
|
|
78
|
+
autoSendVerificationEmail?: boolean;
|
|
79
|
+
redirectUri?: string;
|
|
80
|
+
csrfToken?: string;
|
|
81
|
+
cookie?: {
|
|
82
|
+
accessTokenName?: string;
|
|
83
|
+
refreshTokenName?: string;
|
|
84
|
+
csrfTokenName?: string;
|
|
85
|
+
domain?: string;
|
|
86
|
+
path?: string;
|
|
87
|
+
secure?: boolean;
|
|
88
|
+
sameSite?: "Lax" | "Strict" | "None";
|
|
89
|
+
accessTokenMaxAge?: number;
|
|
90
|
+
refreshTokenMaxAge?: number;
|
|
91
|
+
csrfTokenMaxAge?: number;
|
|
92
|
+
};
|
|
93
|
+
providers: Record<FlareAuthProviderId, FlareAuthProviderPublicConfig>;
|
|
94
|
+
}
|
|
95
|
+
interface FlareAuthSession {
|
|
96
|
+
uid: string;
|
|
97
|
+
accessToken: string;
|
|
98
|
+
refreshToken: string | null;
|
|
99
|
+
provider?: string;
|
|
100
|
+
email?: string | null;
|
|
101
|
+
emailVerified?: boolean;
|
|
102
|
+
}
|
|
103
|
+
interface FlareAuthUser {
|
|
104
|
+
uid: string;
|
|
105
|
+
email: string;
|
|
106
|
+
email_verified: string;
|
|
107
|
+
[x: string]: any;
|
|
108
|
+
}
|
|
109
|
+
interface FlareAuthHydrationInput {
|
|
110
|
+
uid?: string | null;
|
|
111
|
+
id?: string | null;
|
|
112
|
+
accessToken?: string | null;
|
|
113
|
+
refreshToken?: string | null;
|
|
114
|
+
ticket?: string | null;
|
|
115
|
+
provider?: string;
|
|
116
|
+
email?: string | null;
|
|
117
|
+
emailVerified?: boolean;
|
|
118
|
+
email_verified?: boolean;
|
|
119
|
+
profile?: Partial<FlareAuthUser> | null;
|
|
120
|
+
}
|
|
121
|
+
interface FlareAuthHydrationOptions {
|
|
122
|
+
source?: string;
|
|
123
|
+
markBootstrapAttempted?: boolean;
|
|
124
|
+
syncSocket?: boolean;
|
|
125
|
+
}
|
|
126
|
+
interface RegisterPushTokenInput {
|
|
127
|
+
token: string;
|
|
128
|
+
platform?: string;
|
|
129
|
+
deviceId?: string;
|
|
130
|
+
topics?: string[];
|
|
131
|
+
authAppId?: string;
|
|
132
|
+
}
|
|
133
|
+
interface BrowserPushTokenOptions {
|
|
134
|
+
/** Service worker registration used for PushManager subscription. */
|
|
135
|
+
serviceWorkerRegistration?: ServiceWorkerRegistration;
|
|
136
|
+
/** Existing PushSubscription to reuse instead of subscribing again. */
|
|
137
|
+
subscription?: PushSubscription;
|
|
138
|
+
/** Public VAPID key used when creating a new PushSubscription. */
|
|
139
|
+
applicationServerKey?: string;
|
|
140
|
+
/** When true, unsubscribe old subscriptions before creating a new one. */
|
|
141
|
+
forceResubscribe?: boolean;
|
|
142
|
+
}
|
|
143
|
+
interface BrowserPushRegistrationOptions extends BrowserPushTokenOptions {
|
|
144
|
+
/** Optional explicit platform label. Defaults to "web". */
|
|
145
|
+
platform?: string;
|
|
146
|
+
deviceId?: string;
|
|
147
|
+
topics?: string[];
|
|
148
|
+
authAppId?: string;
|
|
149
|
+
}
|
|
150
|
+
interface SendPushNotificationInput {
|
|
151
|
+
title?: string;
|
|
152
|
+
body?: string;
|
|
153
|
+
image?: string;
|
|
154
|
+
data?: Record<string, unknown>;
|
|
155
|
+
tokens?: string[];
|
|
156
|
+
uid?: string;
|
|
157
|
+
topic?: string;
|
|
158
|
+
priority?: "normal" | "high";
|
|
159
|
+
ttlSeconds?: number;
|
|
160
|
+
dryRun?: boolean;
|
|
161
|
+
authAppId?: string;
|
|
162
|
+
}
|
|
163
|
+
interface PushSendResult {
|
|
164
|
+
sent: boolean;
|
|
165
|
+
appId: string;
|
|
166
|
+
targetCount: number;
|
|
167
|
+
successCount: number;
|
|
168
|
+
failureCount: number;
|
|
169
|
+
invalidatedTokenCount: number;
|
|
170
|
+
dryRun: boolean;
|
|
171
|
+
}
|
|
172
|
+
interface SendEmailInput {
|
|
173
|
+
to: string | string[];
|
|
174
|
+
tag: string;
|
|
175
|
+
values?: Record<string, unknown>;
|
|
176
|
+
authAppId?: string;
|
|
177
|
+
}
|
|
178
|
+
interface EmailSendResult {
|
|
179
|
+
sent: boolean;
|
|
180
|
+
appId: string;
|
|
181
|
+
tag: string;
|
|
182
|
+
recipientCount: number;
|
|
183
|
+
acceptedCount: number;
|
|
184
|
+
rejectedCount: number;
|
|
185
|
+
includeVerificationLink?: boolean;
|
|
186
|
+
linkId?: string;
|
|
187
|
+
verifyUrl?: string;
|
|
188
|
+
messageId?: string;
|
|
189
|
+
}
|
|
190
|
+
interface VerifyEmailLinkInput {
|
|
191
|
+
token: string;
|
|
192
|
+
tag?: string;
|
|
193
|
+
email?: string;
|
|
194
|
+
authAppId?: string;
|
|
195
|
+
}
|
|
196
|
+
interface EmailLinkVerifyResult {
|
|
197
|
+
verified: boolean;
|
|
198
|
+
alreadyVerified: boolean;
|
|
199
|
+
appId: string;
|
|
200
|
+
linkId: string;
|
|
201
|
+
email: string;
|
|
202
|
+
tag: string;
|
|
203
|
+
verifiedAt?: string;
|
|
204
|
+
acceptedByUid?: string;
|
|
205
|
+
}
|
|
206
|
+
type AuthStateListener = (session: FlareAuthSession & FlareAuthUser | null) => void;
|
|
207
|
+
type AuthConfigListener = (conf: FlareAuthConfig) => void;
|
|
208
|
+
interface SubscribeOptions {
|
|
209
|
+
skipSnapshot?: boolean;
|
|
210
|
+
}
|
|
211
|
+
type QueryOperator = "==" | "!=" | "<" | "<=" | ">" | ">=" | "in" | "not-in" | "array-contains" | "array-contains-any" | "elem-match" | "like" | "not-like" | "contains" | "exists" | "not-exists";
|
|
212
|
+
interface QueryConfig {
|
|
213
|
+
field: string;
|
|
214
|
+
op: QueryOperator;
|
|
215
|
+
value: unknown;
|
|
216
|
+
}
|
|
217
|
+
/** OR group */
|
|
218
|
+
interface OrFilter {
|
|
219
|
+
or: AnyFilter[];
|
|
220
|
+
}
|
|
221
|
+
/** AND group */
|
|
222
|
+
interface AndFilter {
|
|
223
|
+
and: AnyFilter[];
|
|
224
|
+
}
|
|
225
|
+
type AnyFilter = QueryConfig | OrFilter | AndFilter;
|
|
226
|
+
type WhereCondition = Record<string, string | number | boolean | any[]>;
|
|
227
|
+
interface OrderByClause {
|
|
228
|
+
field: string;
|
|
229
|
+
dir?: "asc" | "desc";
|
|
230
|
+
}
|
|
231
|
+
interface GroupByClause {
|
|
232
|
+
fields: string[];
|
|
233
|
+
}
|
|
234
|
+
interface HavingClause {
|
|
235
|
+
field: string;
|
|
236
|
+
op: "==" | "!=" | "<" | "<=" | ">" | ">=";
|
|
237
|
+
value: number;
|
|
238
|
+
}
|
|
239
|
+
interface CursorValue {
|
|
240
|
+
values: unknown[];
|
|
241
|
+
}
|
|
242
|
+
type AggregateFunction = "count" | "sum" | "avg" | "min" | "max" | "distinct";
|
|
243
|
+
interface AggregateSpec {
|
|
244
|
+
fn: AggregateFunction;
|
|
245
|
+
field?: string;
|
|
246
|
+
alias?: string;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Join definition used by CollectionReference.Join().
|
|
250
|
+
*
|
|
251
|
+
* Example:
|
|
252
|
+
* Join("tasks", { source: "id", target: "boardId", as: "tasks" })
|
|
253
|
+
*/
|
|
254
|
+
interface JoinQueryPattern {
|
|
255
|
+
where?: AnyFilter[];
|
|
256
|
+
orderBy?: OrderByClause[];
|
|
257
|
+
limit?: number;
|
|
258
|
+
offset?: number;
|
|
259
|
+
startAt?: CursorValue;
|
|
260
|
+
startAfter?: CursorValue;
|
|
261
|
+
endAt?: CursorValue;
|
|
262
|
+
endBefore?: CursorValue;
|
|
263
|
+
aggregate?: AggregateSpec[];
|
|
264
|
+
groupBy?: GroupByClause;
|
|
265
|
+
having?: HavingClause[];
|
|
266
|
+
vectorSearch?: VectorSearchClause;
|
|
267
|
+
select?: string[];
|
|
268
|
+
distinctField?: string;
|
|
269
|
+
}
|
|
270
|
+
interface NestedJoinClause extends JoinQueryPattern {
|
|
271
|
+
/** Joined collection name for this nested join. */
|
|
272
|
+
collection: string;
|
|
273
|
+
/** Field from the parent join result. */
|
|
274
|
+
source: string;
|
|
275
|
+
/** Field from this nested collection to match source. */
|
|
276
|
+
target: string;
|
|
277
|
+
/** Alias where nested rows are attached in each parent join row. */
|
|
278
|
+
as: string;
|
|
279
|
+
/** If true, expect at most one joined row. */
|
|
280
|
+
single?: boolean;
|
|
281
|
+
/** Recursive nested joins. */
|
|
282
|
+
joins?: NestedJoinClause[];
|
|
283
|
+
}
|
|
284
|
+
interface JoinClause extends JoinQueryPattern {
|
|
285
|
+
/** Field from the base collection (the collection you started the query on). */
|
|
286
|
+
source: string;
|
|
287
|
+
/** Field from the joined collection that should match source. */
|
|
288
|
+
target: string;
|
|
289
|
+
/** Alias where joined rows will be attached in each result object. */
|
|
290
|
+
as: string;
|
|
291
|
+
/** If true, expect at most one joined row (object instead of array on server side). */
|
|
292
|
+
single?: boolean;
|
|
293
|
+
/** Optional nested joins under this join. */
|
|
294
|
+
joins?: NestedJoinClause[];
|
|
295
|
+
}
|
|
296
|
+
/** Internal wire-ready join shape sent to server query engine. */
|
|
297
|
+
interface StructuredJoinClause extends JoinQueryPattern {
|
|
298
|
+
from: string;
|
|
299
|
+
localField: string;
|
|
300
|
+
foreignField: string;
|
|
301
|
+
as: string;
|
|
302
|
+
single?: boolean;
|
|
303
|
+
joins?: StructuredJoinClause[];
|
|
304
|
+
}
|
|
305
|
+
interface VectorSearchClause {
|
|
306
|
+
field: string;
|
|
307
|
+
vector: number[];
|
|
308
|
+
k: number;
|
|
309
|
+
metric?: "cosine" | "euclidean" | "dotProduct";
|
|
310
|
+
minScore?: number;
|
|
311
|
+
}
|
|
312
|
+
/** Full structured query (document query + SQL-style feature set) */
|
|
313
|
+
interface StructuredQuery {
|
|
314
|
+
where?: AnyFilter[];
|
|
315
|
+
orderBy?: OrderByClause[];
|
|
316
|
+
limit?: number;
|
|
317
|
+
offset?: number;
|
|
318
|
+
startAt?: CursorValue;
|
|
319
|
+
startAfter?: CursorValue;
|
|
320
|
+
endAt?: CursorValue;
|
|
321
|
+
endBefore?: CursorValue;
|
|
322
|
+
aggregate?: AggregateSpec[];
|
|
323
|
+
groupBy?: GroupByClause;
|
|
324
|
+
having?: HavingClause[];
|
|
325
|
+
joins?: StructuredJoinClause[];
|
|
326
|
+
vectorSearch?: VectorSearchClause;
|
|
327
|
+
select?: string[];
|
|
328
|
+
distinctField?: string;
|
|
329
|
+
}
|
|
330
|
+
type QueryPresetSpec<Params extends Record<string, unknown> = Record<string, unknown>, Row = any> = {
|
|
331
|
+
params: Params;
|
|
332
|
+
row: Row;
|
|
333
|
+
};
|
|
334
|
+
type QueryPresetMap = Record<string, QueryPresetSpec<any, any>>;
|
|
335
|
+
type QueryPresetParams<TSpec> = TSpec extends QueryPresetSpec<infer Params, any> ? Params : Record<string, unknown>;
|
|
336
|
+
type QueryPresetRow<TSpec> = TSpec extends QueryPresetSpec<any, infer Row> ? Row : any;
|
|
337
|
+
type ChangeOperation = 'insert' | 'update' | 'replace' | 'delete';
|
|
338
|
+
/**
|
|
339
|
+
* Fired once when the subscription is first established.
|
|
340
|
+
* `data` is always an array — the full matching collection snapshot.
|
|
341
|
+
*/
|
|
342
|
+
interface SnapshotEvent<T = any> {
|
|
343
|
+
type: 'snapshot';
|
|
344
|
+
subscriptionId: string;
|
|
345
|
+
collection: string;
|
|
346
|
+
data: T[];
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Fired on every subsequent document mutation that matches the subscription query.
|
|
350
|
+
* `data` is the single affected document (null on delete).
|
|
351
|
+
*/
|
|
352
|
+
interface ChangeEvent<T = any> {
|
|
353
|
+
type: 'change';
|
|
354
|
+
subscriptionId: string;
|
|
355
|
+
collection: string;
|
|
356
|
+
docId: string;
|
|
357
|
+
operation: ChangeOperation;
|
|
358
|
+
data: T | null;
|
|
359
|
+
}
|
|
360
|
+
/** Discriminated union — narrow on `event.type` to get the right shape. */
|
|
361
|
+
type SubscriptionData<T = any> = SnapshotEvent<T> | ChangeEvent<T>;
|
|
362
|
+
type SubscriptionCallback<T = any> = (data: SubscriptionData<T>) => void;
|
|
363
|
+
interface SubscriptionError {
|
|
364
|
+
code?: string;
|
|
365
|
+
message: string;
|
|
366
|
+
permissionDenied: boolean;
|
|
367
|
+
raw?: unknown;
|
|
368
|
+
}
|
|
369
|
+
type SubscriptionErrorCallback = (error: SubscriptionError) => void;
|
|
370
|
+
interface SubscriptionHandle {
|
|
371
|
+
(): void;
|
|
372
|
+
unsubscribe: () => void;
|
|
373
|
+
onError: (callback: SubscriptionErrorCallback) => SubscriptionHandle;
|
|
374
|
+
onPermissionDenied: (callback: SubscriptionErrorCallback) => SubscriptionHandle;
|
|
375
|
+
catch: (callback: SubscriptionErrorCallback) => SubscriptionHandle;
|
|
376
|
+
}
|
|
377
|
+
type DocAddedCallback<T = any> = (data: T, docId: string) => void;
|
|
378
|
+
type DocUpdatedCallback<T = any> = (data: T, docId: string) => void;
|
|
379
|
+
type DocDeletedCallback<T = any> = (docId: string) => void;
|
|
380
|
+
type DocChangedCallback<T = any> = (data: T | null, docId: string, operation: ChangeOperation) => void;
|
|
381
|
+
type StreamFlushReason = 'snapshot' | 'change-batch';
|
|
382
|
+
interface CollectionStreamOptions<T = any> {
|
|
383
|
+
/** Delay before a queued burst is flushed to listeners. */
|
|
384
|
+
flushMs?: number;
|
|
385
|
+
/** Flush immediately when queued changes reach this count. */
|
|
386
|
+
maxBatchSize?: number;
|
|
387
|
+
/** Field used to identify docs inside snapshots when getId is not provided. */
|
|
388
|
+
idField?: keyof T & string;
|
|
389
|
+
/** Custom identifier extractor for snapshot rows. */
|
|
390
|
+
getId?: (doc: T) => string | undefined;
|
|
391
|
+
/** Where newly inserted docs should be placed when they were not in snapshot. */
|
|
392
|
+
insertAt?: 'start' | 'end';
|
|
393
|
+
/** Optional cap to keep only the newest N docs in local stream state. */
|
|
394
|
+
maxDocs?: number;
|
|
395
|
+
/** Optional local sort run after flush. */
|
|
396
|
+
sort?: (a: T, b: T) => number;
|
|
397
|
+
}
|
|
398
|
+
interface CollectionStreamMeta {
|
|
399
|
+
reason: StreamFlushReason;
|
|
400
|
+
batchSize: number;
|
|
401
|
+
version: number;
|
|
402
|
+
ready: boolean;
|
|
403
|
+
}
|
|
404
|
+
type CollectionStreamListener<T = any> = (rows: readonly T[], meta: CollectionStreamMeta) => void;
|
|
405
|
+
interface CollectionStream<T = any> {
|
|
406
|
+
/** Subscribe to stream updates (call unsubscribe to stop). */
|
|
407
|
+
subscribe: (listener: CollectionStreamListener<T>, emitCurrent?: boolean) => () => void;
|
|
408
|
+
/** Returns the latest immutable snapshot of rows. */
|
|
409
|
+
getSnapshot: () => readonly T[];
|
|
410
|
+
/** Returns true after the initial snapshot has been received. */
|
|
411
|
+
isReady: () => boolean;
|
|
412
|
+
/** Monotonic version incremented on each flush. */
|
|
413
|
+
getVersion: () => number;
|
|
414
|
+
/** Stop the underlying realtime subscription and cleanup timers/listeners. */
|
|
415
|
+
close: () => void;
|
|
416
|
+
/** Attach subscription-level error handler. */
|
|
417
|
+
onError: (callback: SubscriptionErrorCallback) => CollectionStream<T>;
|
|
418
|
+
/** Attach permission-denied handler. */
|
|
419
|
+
onPermissionDenied: (callback: SubscriptionErrorCallback) => CollectionStream<T>;
|
|
420
|
+
}
|
|
421
|
+
interface CollectionExternalStore<T = any> {
|
|
422
|
+
/** Standard external-store subscribe signature used by UI store hooks. */
|
|
423
|
+
subscribe: (onStoreChange: () => void) => () => void;
|
|
424
|
+
/** Returns current immutable rows snapshot. */
|
|
425
|
+
getSnapshot: () => readonly T[];
|
|
426
|
+
/** Server snapshot fallback for SSR-safe store hooks. */
|
|
427
|
+
getServerSnapshot: () => readonly T[];
|
|
428
|
+
/** Access to underlying realtime stream for advanced handlers. */
|
|
429
|
+
stream: CollectionStream<T>;
|
|
430
|
+
/** Stops realtime stream and detaches listeners. */
|
|
431
|
+
destroy: () => void;
|
|
432
|
+
}
|
|
433
|
+
interface DocumentSnapshot<T = any> {
|
|
434
|
+
id: string;
|
|
435
|
+
data: T | null;
|
|
436
|
+
exists: boolean;
|
|
437
|
+
}
|
|
438
|
+
interface QuerySnapshot<T = any> {
|
|
439
|
+
docs: DocumentSnapshot<T>[];
|
|
440
|
+
size: number;
|
|
441
|
+
empty: boolean;
|
|
442
|
+
}
|
|
443
|
+
interface OfflineOperation {
|
|
444
|
+
id: string;
|
|
445
|
+
type: 'write' | 'delete';
|
|
446
|
+
collection: string;
|
|
447
|
+
docId: string;
|
|
448
|
+
data?: Record<string, unknown>;
|
|
449
|
+
merge?: boolean;
|
|
450
|
+
clientTs: number;
|
|
451
|
+
}
|
|
452
|
+
interface AuthResult {
|
|
453
|
+
uid: string;
|
|
454
|
+
token?: string;
|
|
455
|
+
}
|
|
456
|
+
type ConnectionState = 'connecting' | 'connected' | 'disconnected' | 'reconnecting' | 'error';
|
|
457
|
+
interface AuthWithPendingVerificationResult {
|
|
458
|
+
verificationRequired: true;
|
|
459
|
+
created: true;
|
|
460
|
+
emailSent: boolean;
|
|
461
|
+
preview?: {
|
|
462
|
+
code: string;
|
|
463
|
+
link: string;
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
interface AuthWithTokenResult extends AuthResult {
|
|
467
|
+
accessToken: string;
|
|
468
|
+
refreshToken: string | null;
|
|
469
|
+
authToken: AuthToken;
|
|
470
|
+
created: boolean;
|
|
471
|
+
}
|
|
472
|
+
interface PresenceMember {
|
|
473
|
+
uid: string;
|
|
474
|
+
socketId: string;
|
|
475
|
+
room: string;
|
|
476
|
+
meta?: Record<string, unknown>;
|
|
477
|
+
joinedAt: number;
|
|
478
|
+
lastSeen: number;
|
|
479
|
+
}
|
|
480
|
+
type PresenceCallback = (members: PresenceMember[]) => void;
|
|
481
|
+
type PresenceJoinCallback = (member: PresenceMember) => void;
|
|
482
|
+
type PresenceLeaveCallback = (uid: string) => void;
|
|
483
|
+
/** Fields marked as vector will be auto-embedded before write */
|
|
484
|
+
type VectorFieldConfig = {
|
|
485
|
+
/** Dimensions of the vector (e.g. 1536 for OpenAI ada-002) */
|
|
486
|
+
dimensions: number;
|
|
487
|
+
/** Optional custom embedding function; defaults to client-configured embedder */
|
|
488
|
+
embed?: (text: string) => Promise<number[]>;
|
|
489
|
+
};
|
|
490
|
+
type RulePermission = "create" | "read" | "update" | "delete";
|
|
491
|
+
interface FlareRule {
|
|
492
|
+
id: string;
|
|
493
|
+
name: string;
|
|
494
|
+
auth: "any" | "guest" | "auth";
|
|
495
|
+
collection: string;
|
|
496
|
+
document?: string;
|
|
497
|
+
condition?: string;
|
|
498
|
+
permissions: RulePermission[];
|
|
499
|
+
}
|
|
500
|
+
interface SecurityRuleEntry {
|
|
501
|
+
".read"?: string;
|
|
502
|
+
".write"?: string;
|
|
503
|
+
".create"?: string;
|
|
504
|
+
".update"?: string;
|
|
505
|
+
".delete"?: string;
|
|
506
|
+
}
|
|
507
|
+
type SecurityRulesMap = Record<string, SecurityRuleEntry>;
|
|
508
|
+
declare const flareRulesToSecurityMap: (rules: FlareRule[]) => SecurityRulesMap;
|
|
509
|
+
declare const securityMapToFlareRules: (rules: SecurityRulesMap) => FlareRule[];
|
|
510
|
+
|
|
511
|
+
export { type QueryPresetMap as $, type AggregateFunction as A, type BrowserPushRegistrationOptions as B, type ChangeEvent as C, type DataMapperFn as D, type EmailLinkVerifyResult as E, type FlareConfig as F, type FlareAuthHydrationOptions as G, type FlareAuthProviderId as H, type FlareAuthProviderPublicConfig as I, type FlareAuthSession as J, type FlareAuthUser as K, type FlareRule as L, type GroupByClause as M, type HavingClause as N, type JoinClause as O, type JoinQueryPattern as P, type NestedJoinClause as Q, type OfflineOperation as R, type OrFilter as S, type OrderByClause as T, type PresenceCallback as U, type PresenceJoinCallback as V, type PresenceLeaveCallback as W, type PresenceMember as X, type PushSendResult as Y, type QueryConfig as Z, type QueryOperator as _, type AggregateSpec as a, type QueryPresetParams as a0, type QueryPresetRow as a1, type QueryPresetSpec as a2, type QuerySnapshot as a3, type RegisterPushTokenInput as a4, type RulePermission as a5, type SecurityRuleEntry as a6, type SecurityRulesMap as a7, type SendEmailInput as a8, type SendPushNotificationInput as a9, type SnapshotEvent as aa, type StreamFlushReason as ab, type StructuredJoinClause as ac, type StructuredQuery as ad, type SubscribeOptions as ae, type SubscriptionCallback as af, type SubscriptionData as ag, type SubscriptionError as ah, type SubscriptionErrorCallback as ai, type SubscriptionHandle as aj, type VectorFieldConfig as ak, type VectorSearchClause as al, type VerifyEmailLinkInput as am, type WhereCondition as an, flareRulesToSecurityMap as ao, securityMapToFlareRules as ap, 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 ChangeOperation as j, type CollectionExternalStore as k, type CollectionStream as l, type CollectionStreamListener as m, type CollectionStreamMeta as n, type CollectionStreamOptions as o, type ConnectionState as p, type CursorValue as q, type DataMapperRegistry as r, type DocAddedCallback as s, type DocChangedCallback as t, type DocDeletedCallback as u, type DocUpdatedCallback as v, type DocumentSnapshot as w, type EmailSendResult as x, type FlareAuthConfig as y, type FlareAuthHydrationInput as z };
|