@zuzjs/flare-admin 0.1.5 → 0.1.7
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 +316 -301
- package/dist/db/Collection.d.ts +27 -1
- package/dist/index.cjs +4 -4
- package/dist/index.d.cts +163 -51
- package/dist/index.d.ts +38 -10
- package/dist/index.js +3 -3
- package/dist/lib/grpc.d.ts +1 -1
- package/dist/lib/http.d.ts +3 -0
- package/dist/lib/notifications.d.ts +1 -1
- package/dist/realtime/Connection.d.ts +14 -0
- package/dist/realtime/LiveCollection.d.ts +3 -1
- package/dist/realtime/WsConnection.d.ts +11 -1
- package/dist/types/index.d.ts +75 -0
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
type AdminConnectionState = 'connecting' | 'connected' | 'disconnected' | 'reconnecting' | 'error';
|
|
2
|
+
type AdminConnectionStateListener = (state: AdminConnectionState) => void;
|
|
1
3
|
interface FlareAdminConfig {
|
|
2
4
|
/**
|
|
3
5
|
* Base URL of your FlareServer instance.
|
|
@@ -16,6 +18,8 @@ interface FlareAdminConfig {
|
|
|
16
18
|
grpcUrl?: string;
|
|
17
19
|
/** Transport preference for supported operations. */
|
|
18
20
|
transport?: "auto" | "http" | "grpc";
|
|
21
|
+
/** Optional HTTP base URL override for admin HTTP APIs. */
|
|
22
|
+
httpBase?: string;
|
|
19
23
|
/** Default token TTL, e.g. "24h" */
|
|
20
24
|
defaultTtl?: string;
|
|
21
25
|
/**
|
|
@@ -502,11 +506,46 @@ interface StructuredQuery {
|
|
|
502
506
|
select?: string[];
|
|
503
507
|
distinctField?: string;
|
|
504
508
|
}
|
|
509
|
+
type AdminBulkWriteOperation = "addMany" | "updateMany" | "deleteMany";
|
|
510
|
+
interface AdminBulkWriteProgress {
|
|
511
|
+
operation: AdminBulkWriteOperation;
|
|
512
|
+
processed: number;
|
|
513
|
+
succeeded: number;
|
|
514
|
+
failed: number;
|
|
515
|
+
total?: number;
|
|
516
|
+
percent?: number;
|
|
517
|
+
lastDocId?: string;
|
|
518
|
+
lastError?: unknown;
|
|
519
|
+
}
|
|
520
|
+
interface AdminBulkWriteResult {
|
|
521
|
+
operation: AdminBulkWriteOperation;
|
|
522
|
+
processed: number;
|
|
523
|
+
succeeded: number;
|
|
524
|
+
failed: number;
|
|
525
|
+
total?: number;
|
|
526
|
+
}
|
|
527
|
+
interface AdminBulkWriteOptions {
|
|
528
|
+
/** How many operations to execute per chunk; defaults to 250. */
|
|
529
|
+
batchSize?: number;
|
|
530
|
+
/** Number of in-flight writes within each chunk; defaults to 1. */
|
|
531
|
+
concurrency?: number;
|
|
532
|
+
/** Continue processing remaining items after individual failures. */
|
|
533
|
+
continueOnError?: boolean;
|
|
534
|
+
/** Optional cancellation signal for long-running bulk writes. */
|
|
535
|
+
signal?: AbortSignal;
|
|
536
|
+
/** Progress callback invoked after each processed item. */
|
|
537
|
+
onProgress?: (progress: AdminBulkWriteProgress) => void;
|
|
538
|
+
}
|
|
539
|
+
interface AdminUpdateManyItem<T = Record<string, unknown>> {
|
|
540
|
+
id: string;
|
|
541
|
+
data: Partial<T>;
|
|
542
|
+
}
|
|
505
543
|
/** Minimal structural interface satisfied by AdminCollectionReference<T>. */
|
|
506
544
|
interface FlareAdminDb {
|
|
507
545
|
collection<T = Record<string, unknown>>(name: string): AdminCollectionShape<T>;
|
|
508
546
|
}
|
|
509
547
|
interface AdminDocumentShape<T> {
|
|
548
|
+
readonly id: string;
|
|
510
549
|
get(): Promise<T | null>;
|
|
511
550
|
set(data: Partial<T>): Promise<void>;
|
|
512
551
|
update(data: Partial<T>): Promise<void>;
|
|
@@ -581,6 +620,9 @@ interface AdminCollectionShape<T> {
|
|
|
581
620
|
first(): Promise<T | null>;
|
|
582
621
|
last(): Promise<T | null>;
|
|
583
622
|
add(data: Partial<T>): Promise<AdminDocumentShape<T>>;
|
|
623
|
+
addMany(items: Iterable<Partial<T>> | AsyncIterable<Partial<T>>, options?: AdminBulkWriteOptions): Promise<AdminBulkWriteResult>;
|
|
624
|
+
updateMany(items: Iterable<AdminUpdateManyItem<T>> | AsyncIterable<AdminUpdateManyItem<T>>, options?: AdminBulkWriteOptions): Promise<AdminBulkWriteResult>;
|
|
625
|
+
deleteMany(docIds: Iterable<string> | AsyncIterable<string>, options?: AdminBulkWriteOptions): Promise<AdminBulkWriteResult>;
|
|
584
626
|
deleteMany(): Promise<number>;
|
|
585
627
|
doc(id: string): AdminDocumentShape<T>;
|
|
586
628
|
}
|
|
@@ -597,6 +639,39 @@ type AdminDocAddedCallback<T = unknown> = (data: T, docId: string) => void;
|
|
|
597
639
|
type AdminDocUpdatedCallback<T = unknown> = (data: T, docId: string) => void;
|
|
598
640
|
type AdminDocDeletedCallback = (docId: string) => void;
|
|
599
641
|
type AdminDocChangedCallback<T = unknown> = (data: T | null, docId: string, operation: "insert" | "update" | "delete" | "replace") => void;
|
|
642
|
+
type AdminStreamFlushReason = "snapshot" | "change-batch";
|
|
643
|
+
interface AdminCollectionStreamOptions<T = unknown> {
|
|
644
|
+
flushMs?: number;
|
|
645
|
+
maxBatchSize?: number;
|
|
646
|
+
idField?: keyof T & string;
|
|
647
|
+
getId?: (doc: T) => string | undefined;
|
|
648
|
+
insertAt?: "start" | "end";
|
|
649
|
+
maxDocs?: number;
|
|
650
|
+
sort?: (a: T, b: T) => number;
|
|
651
|
+
}
|
|
652
|
+
interface AdminCollectionStreamMeta {
|
|
653
|
+
reason: AdminStreamFlushReason;
|
|
654
|
+
batchSize: number;
|
|
655
|
+
version: number;
|
|
656
|
+
ready: boolean;
|
|
657
|
+
}
|
|
658
|
+
type AdminCollectionStreamListener<T = unknown> = (rows: readonly T[], meta: AdminCollectionStreamMeta) => void;
|
|
659
|
+
interface AdminCollectionStream<T = unknown> {
|
|
660
|
+
subscribe: (listener: AdminCollectionStreamListener<T>, emitCurrent?: boolean) => () => void;
|
|
661
|
+
getSnapshot: () => readonly T[];
|
|
662
|
+
isReady: () => boolean;
|
|
663
|
+
getVersion: () => number;
|
|
664
|
+
close: () => void;
|
|
665
|
+
onError: (callback: AdminSubscriptionErrorCallback) => AdminCollectionStream<T>;
|
|
666
|
+
onPermissionDenied: (callback: AdminSubscriptionErrorCallback) => AdminCollectionStream<T>;
|
|
667
|
+
}
|
|
668
|
+
interface AdminCollectionExternalStore<T = unknown> {
|
|
669
|
+
subscribe: (onStoreChange: () => void) => () => void;
|
|
670
|
+
getSnapshot: () => readonly T[];
|
|
671
|
+
getServerSnapshot: () => readonly T[];
|
|
672
|
+
stream: AdminCollectionStream<T>;
|
|
673
|
+
destroy: () => void;
|
|
674
|
+
}
|
|
600
675
|
interface AdminSubscribeOptions {
|
|
601
676
|
skipSnapshot?: boolean;
|
|
602
677
|
}
|
|
@@ -727,8 +802,34 @@ declare class AdminCollectionReference<T = Record<string, unknown>> {
|
|
|
727
802
|
get(): Promise<T[]>;
|
|
728
803
|
first(): Promise<T | null>;
|
|
729
804
|
last(): Promise<T | null>;
|
|
805
|
+
/**
|
|
806
|
+
* Create a single document and return its reference.
|
|
807
|
+
*/
|
|
730
808
|
add(data: Partial<T>): Promise<AdminDocumentReference<T>>;
|
|
809
|
+
private ensureBulkOptions;
|
|
810
|
+
private toPercent;
|
|
811
|
+
private emitBulkProgress;
|
|
812
|
+
private chunkIterable;
|
|
813
|
+
private assertBulkSignal;
|
|
814
|
+
private runChunkWorkers;
|
|
815
|
+
private runBulkWrite;
|
|
816
|
+
/**
|
|
817
|
+
* Create many documents with bounded memory and optional progress reporting.
|
|
818
|
+
*/
|
|
819
|
+
addMany(items: Iterable<Partial<T>> | AsyncIterable<Partial<T>>, options?: AdminBulkWriteOptions): Promise<AdminBulkWriteResult>;
|
|
820
|
+
/**
|
|
821
|
+
* Update many documents by id with bounded memory and optional progress reporting.
|
|
822
|
+
*/
|
|
823
|
+
updateMany(items: Iterable<AdminUpdateManyItem<T>> | AsyncIterable<AdminUpdateManyItem<T>>, options?: AdminBulkWriteOptions): Promise<AdminBulkWriteResult>;
|
|
824
|
+
/**
|
|
825
|
+
* Delete many specific document ids with bounded memory and optional progress reporting.
|
|
826
|
+
*/
|
|
731
827
|
deleteMany(): Promise<number>;
|
|
828
|
+
deleteMany(docIds: Iterable<string> | AsyncIterable<string>, options?: AdminBulkWriteOptions): Promise<AdminBulkWriteResult>;
|
|
829
|
+
private deleteManyByQuery;
|
|
830
|
+
/**
|
|
831
|
+
* Return a document reference by id.
|
|
832
|
+
*/
|
|
732
833
|
doc(id: string): AdminDocumentReference<T>;
|
|
733
834
|
}
|
|
734
835
|
|
|
@@ -987,6 +1088,8 @@ declare class AdminLiveCollectionReference<T = Record<string, unknown>> {
|
|
|
987
1088
|
query: StructuredQuery;
|
|
988
1089
|
};
|
|
989
1090
|
onSnapshot(callback: AdminSnapshotCallback<T[]>): () => void;
|
|
1091
|
+
stream(options?: AdminCollectionStreamOptions<T>): AdminCollectionStream<T>;
|
|
1092
|
+
asStore(options?: AdminCollectionStreamOptions<T>): AdminCollectionExternalStore<T>;
|
|
990
1093
|
onDocAdded(callback: AdminDocAddedCallback<T>): () => void;
|
|
991
1094
|
onDocUpdated(callback: AdminDocUpdatedCallback<T>): () => void;
|
|
992
1095
|
onDocDeleted(callback: AdminDocDeletedCallback): () => void;
|
|
@@ -1023,6 +1126,19 @@ declare class FlareAdminConnection {
|
|
|
1023
1126
|
collection<T = Record<string, unknown>>(name: string): AdminLiveCollectionReference<T>;
|
|
1024
1127
|
/** Wait until the WebSocket is open and authenticated. */
|
|
1025
1128
|
ready(): Promise<void>;
|
|
1129
|
+
/** Current connection state. */
|
|
1130
|
+
get connectionState(): AdminConnectionState;
|
|
1131
|
+
/**
|
|
1132
|
+
* Subscribe to connection state changes.
|
|
1133
|
+
* Returns an unsubscribe function.
|
|
1134
|
+
*
|
|
1135
|
+
* @example
|
|
1136
|
+
* const unsub = admin.live().onConnectionStateChange((state) => {
|
|
1137
|
+
* console.log("connection:", state);
|
|
1138
|
+
* });
|
|
1139
|
+
* // state: 'connecting' | 'connected' | 'disconnected' | 'reconnecting' | 'error'
|
|
1140
|
+
*/
|
|
1141
|
+
onConnectionStateChange(listener: AdminConnectionStateListener): () => void;
|
|
1026
1142
|
/** Close the WebSocket connection permanently (no reconnect). */
|
|
1027
1143
|
disconnect(): void;
|
|
1028
1144
|
}
|
|
@@ -1044,12 +1160,21 @@ declare class FlareAdminWsConnection {
|
|
|
1044
1160
|
private connected;
|
|
1045
1161
|
private shouldReconnect;
|
|
1046
1162
|
private reconnectDelay;
|
|
1163
|
+
private _state;
|
|
1164
|
+
private _stateListeners;
|
|
1047
1165
|
private readonly wsUrl;
|
|
1048
1166
|
private _readyResolve;
|
|
1049
1167
|
private _readyPromise;
|
|
1050
1168
|
constructor(cfg: Required<FlareAdminConfig>);
|
|
1051
1169
|
/** Resolves once the WS is open and AUTH_OK is received from the server. */
|
|
1052
1170
|
ready(): Promise<void>;
|
|
1171
|
+
/** Current connection state. */
|
|
1172
|
+
get connectionState(): AdminConnectionState;
|
|
1173
|
+
/**
|
|
1174
|
+
* Subscribe to connection state changes.
|
|
1175
|
+
* Returns an unsubscribe function.
|
|
1176
|
+
*/
|
|
1177
|
+
onConnectionStateChange(listener: AdminConnectionStateListener): () => void;
|
|
1053
1178
|
/** Close the connection permanently (no reconnect). */
|
|
1054
1179
|
disconnect(): void;
|
|
1055
1180
|
/**
|
|
@@ -1066,6 +1191,7 @@ declare class FlareAdminWsConnection {
|
|
|
1066
1191
|
private replayActiveSubscriptions;
|
|
1067
1192
|
private toSubscriptionError;
|
|
1068
1193
|
private emitSubscriptionError;
|
|
1194
|
+
private _setState;
|
|
1069
1195
|
private _connect;
|
|
1070
1196
|
private _handle;
|
|
1071
1197
|
}
|
|
@@ -1084,48 +1210,6 @@ declare const ServerTimeStampField: {
|
|
|
1084
1210
|
readonly $serverTimestamp: true;
|
|
1085
1211
|
};
|
|
1086
1212
|
|
|
1087
|
-
/**
|
|
1088
|
-
* @zuzjs/flare-admin
|
|
1089
|
-
*
|
|
1090
|
-
* Server-side admin SDK for FlareServer.
|
|
1091
|
-
* Runs only on your backend, never in a browser.
|
|
1092
|
-
*
|
|
1093
|
-
* ─── Quick start ──────────────────────────────────────────────────────────────
|
|
1094
|
-
*
|
|
1095
|
-
* import { connectApp } from "@zuzjs/flare-admin";
|
|
1096
|
-
*
|
|
1097
|
-
* const admin = connectApp({
|
|
1098
|
-
* serverUrl: process.env.FLARE_URL!,
|
|
1099
|
-
* appId: process.env.FLARE_APP_ID!,
|
|
1100
|
-
* adminKey: process.env.FLARE_ADMIN_KEY!,
|
|
1101
|
-
* });
|
|
1102
|
-
*
|
|
1103
|
-
* // Mint a custom auth token (for use by the browser client)
|
|
1104
|
-
* const token = await admin.auth().createCustomToken(String(user.id), {
|
|
1105
|
-
* role: user.isAdmin ? "admin" : "user",
|
|
1106
|
-
* claims: { email: user.email, plan: user.plan },
|
|
1107
|
-
* });
|
|
1108
|
-
*
|
|
1109
|
-
* // One-shot DB queries (bypasses security rules)
|
|
1110
|
-
* const users = await admin.db().collection("users").get();
|
|
1111
|
-
* await admin.db().collection("users").doc("alice").set({ name: "Alice" });
|
|
1112
|
-
*
|
|
1113
|
-
* // Rich queries
|
|
1114
|
-
* const seniors = await admin.db()
|
|
1115
|
-
* .collection("users")
|
|
1116
|
-
* .where({ age: ">= 60" })
|
|
1117
|
-
* .orderBy("name")
|
|
1118
|
-
* .limit(10)
|
|
1119
|
-
* .get();
|
|
1120
|
-
*
|
|
1121
|
-
* // Real-time subscriptions over WebSocket
|
|
1122
|
-
* const unsub = admin.connection()
|
|
1123
|
-
* .collection("orders")
|
|
1124
|
-
* .where({ status: "pending" })
|
|
1125
|
-
* .orderBy("createdAt", "desc")
|
|
1126
|
-
* .onSnapshot((snap) => console.log(snap));
|
|
1127
|
-
*/
|
|
1128
|
-
|
|
1129
1213
|
/**
|
|
1130
1214
|
* A FlareAdmin application instance.
|
|
1131
1215
|
* Create one with `connectApp()` and keep it as a module-level singleton.
|
|
@@ -1172,7 +1256,7 @@ declare class FlareAdminApp {
|
|
|
1172
1256
|
* `groupBy`, `having`, `Join`, `select`, `distinctField`, `vectorSearch`.
|
|
1173
1257
|
*
|
|
1174
1258
|
* @example
|
|
1175
|
-
* const unsub = admin.
|
|
1259
|
+
* const unsub = admin.live()
|
|
1176
1260
|
* .collection("orders")
|
|
1177
1261
|
* .where({ status: "pending" })
|
|
1178
1262
|
* .orderBy("createdAt", "desc")
|
|
@@ -1182,15 +1266,15 @@ declare class FlareAdminApp {
|
|
|
1182
1266
|
* else console.log(snap.operation, snap.data);
|
|
1183
1267
|
* });
|
|
1184
1268
|
*
|
|
1185
|
-
* const unsub2 = admin.
|
|
1269
|
+
* const unsub2 = admin.live()
|
|
1186
1270
|
* .collection("users").doc("alice")
|
|
1187
1271
|
* .onSnapshot((snap) => console.log(snap.data));
|
|
1188
1272
|
*
|
|
1189
1273
|
* unsub();
|
|
1190
1274
|
* unsub2();
|
|
1191
|
-
* admin.
|
|
1275
|
+
* admin.live().disconnect();
|
|
1192
1276
|
*/
|
|
1193
|
-
|
|
1277
|
+
live(): FlareAdminConnection;
|
|
1194
1278
|
/**
|
|
1195
1279
|
* Access push notification management APIs.
|
|
1196
1280
|
*/
|
|
@@ -1243,6 +1327,25 @@ declare class FlareAdminApp {
|
|
|
1243
1327
|
deleted: string[];
|
|
1244
1328
|
errors: Record<string, string>;
|
|
1245
1329
|
}>;
|
|
1330
|
+
/**
|
|
1331
|
+
* Subscribe to WebSocket connection state changes.
|
|
1332
|
+
* Initializes the live connection if not already open.
|
|
1333
|
+
* Returns an unsubscribe function.
|
|
1334
|
+
*
|
|
1335
|
+
* @example
|
|
1336
|
+
* const unsub = admin.onConnectionStateChange((state) => {
|
|
1337
|
+
* console.log("connection:", state);
|
|
1338
|
+
* // state: 'connecting' | 'connected' | 'disconnected' | 'reconnecting' | 'error'
|
|
1339
|
+
* });
|
|
1340
|
+
* // Later:
|
|
1341
|
+
* unsub();
|
|
1342
|
+
*/
|
|
1343
|
+
onConnectionStateChange(listener: (state: AdminConnectionState) => void): () => void;
|
|
1344
|
+
/**
|
|
1345
|
+
* Disconnect realtime resources tied to this app instance.
|
|
1346
|
+
* Safe to call multiple times.
|
|
1347
|
+
*/
|
|
1348
|
+
disconnect(): void;
|
|
1246
1349
|
}
|
|
1247
1350
|
/**
|
|
1248
1351
|
* Initialize a FlareAdmin app instance.
|
|
@@ -1264,6 +1367,15 @@ declare function connectApp(config: FlareAdminConfig, name?: string): FlareAdmin
|
|
|
1264
1367
|
* @throws If the app has not been initialized yet.
|
|
1265
1368
|
*/
|
|
1266
1369
|
declare function getApp(name?: string): FlareAdminApp;
|
|
1370
|
+
/**
|
|
1371
|
+
* Disconnect and remove an initialized app by name.
|
|
1372
|
+
* Returns true when an app existed and was removed.
|
|
1373
|
+
*/
|
|
1374
|
+
declare function disconnectApp(name?: string): boolean;
|
|
1375
|
+
/**
|
|
1376
|
+
* Disconnect and clear all initialized apps.
|
|
1377
|
+
*/
|
|
1378
|
+
declare function disconnectAllApps(): void;
|
|
1267
1379
|
/**
|
|
1268
1380
|
* Get the auth service from the default app.
|
|
1269
1381
|
* Equivalent to `getApp().auth()`.
|
|
@@ -1284,15 +1396,15 @@ declare function auth(name?: string): FlareAdminAuth;
|
|
|
1284
1396
|
declare function db(name?: string): FlareAdminDb;
|
|
1285
1397
|
/**
|
|
1286
1398
|
* Get the real-time WebSocket connection from the default app.
|
|
1287
|
-
* Equivalent to `getApp().
|
|
1399
|
+
* Equivalent to `getApp().live()`.
|
|
1288
1400
|
*
|
|
1289
1401
|
* @example
|
|
1290
|
-
* import {
|
|
1291
|
-
* const unsub =
|
|
1402
|
+
* import { live } from "@zuzjs/flare-admin";
|
|
1403
|
+
* const unsub = live().collection("users")
|
|
1292
1404
|
* .where({ role: "admin" })
|
|
1293
1405
|
* .onSnapshot((snap) => console.log(snap));
|
|
1294
1406
|
*/
|
|
1295
|
-
declare function
|
|
1407
|
+
declare function live(name?: string): FlareAdminConnection;
|
|
1296
1408
|
/**
|
|
1297
1409
|
* Get the notifications service from the default app.
|
|
1298
1410
|
* Equivalent to `getApp().notifications()`.
|
|
@@ -1300,4 +1412,4 @@ declare function connection(name?: string): FlareAdminConnection;
|
|
|
1300
1412
|
declare function notifications(name?: string): FlareAdminNotifications;
|
|
1301
1413
|
declare function storage(name?: string): FlareAdminStorageS3;
|
|
1302
1414
|
|
|
1303
|
-
export { AdminCollectionReference, type AdminCopyObjectInput, type AdminDeleteObjectsInput, type AdminDocAddedCallback, type AdminDocChangedCallback, type AdminDocDeletedCallback, type AdminDocUpdatedCallback, AdminDocumentReference, type AdminDownloadObjectInput, type AdminDownloadObjectResult, type AdminGetObjectInput, type AdminGetObjectResult, type AdminGetObjectUrlInput, type AdminHeadObjectInput, type AdminHeadObjectsInput, type AdminListObjectsInput, type AdminListObjectsResult, AdminLiveCollectionReference, AdminLiveDocumentReference, type AdminPushSendInput, type AdminPushSendResult, type AdminPushToken, type AdminPutObjectInput, type AdminPutObjectResult, type AdminSnapshotCallback, type AdminSnapshotData, type AdminStorageAwsConfig, type AdminStorageBucket, type AdminStorageBucketInput, type AdminStorageDeleteInput, type AdminStorageDownloadInput, type AdminStorageObjectMeta, type AdminStorageObjectResult, type AdminStorageRulesHistoryResult, type AdminStorageRulesPolicy, type AdminStorageServer, type AdminStorageServerInput, type AdminStorageServerPatchInput, AdminStorageSignedAction, type AdminStorageSignedUrlInput, type AdminStorageSignedUrlResult, type AdminStorageUploadInput, type AdminSubscriptionError, type AdminSubscriptionErrorCallback, type AdminSubscriptionHandle, type AggregateFunction, type AggregateSpec, type AnyFilter, type CreateCustomTokenOptions, type CursorValue, FlareAdminApp, type FlareAdminAuth, FlareAdminAuthService, type FlareAdminConfig, FlareAdminConnection, type FlareAdminDb, FlareAdminDbService, type FlareAdminNotifications, FlareAdminNotificationsService, type FlareAdminStorage, FlareAdminStorageS3, FlareAdminWsConnection, type GroupByClause, type HavingClause, type JoinClause, type OrFilter, type OrderByClause, type QueryOperator, ServerTimeStamp, ServerTimeStampField, type StructuredQuery, type VectorSearchClause, type WhereCondition, type WhereFilter, auth, connectApp,
|
|
1415
|
+
export { type AdminBulkWriteOperation, type AdminBulkWriteOptions, type AdminBulkWriteProgress, type AdminBulkWriteResult, AdminCollectionReference, type AdminConnectionState, type AdminConnectionStateListener, type AdminCopyObjectInput, type AdminDeleteObjectsInput, type AdminDocAddedCallback, type AdminDocChangedCallback, type AdminDocDeletedCallback, type AdminDocUpdatedCallback, AdminDocumentReference, type AdminDownloadObjectInput, type AdminDownloadObjectResult, type AdminGetObjectInput, type AdminGetObjectResult, type AdminGetObjectUrlInput, type AdminHeadObjectInput, type AdminHeadObjectsInput, type AdminListObjectsInput, type AdminListObjectsResult, AdminLiveCollectionReference, AdminLiveDocumentReference, type AdminPushSendInput, type AdminPushSendResult, type AdminPushToken, type AdminPutObjectInput, type AdminPutObjectResult, type AdminSnapshotCallback, type AdminSnapshotData, type AdminStorageAwsConfig, type AdminStorageBucket, type AdminStorageBucketInput, type AdminStorageDeleteInput, type AdminStorageDownloadInput, type AdminStorageObjectMeta, type AdminStorageObjectResult, type AdminStorageRulesHistoryResult, type AdminStorageRulesPolicy, type AdminStorageServer, type AdminStorageServerInput, type AdminStorageServerPatchInput, AdminStorageSignedAction, type AdminStorageSignedUrlInput, type AdminStorageSignedUrlResult, type AdminStorageUploadInput, type AdminSubscriptionError, type AdminSubscriptionErrorCallback, type AdminSubscriptionHandle, type AdminUpdateManyItem, type AggregateFunction, type AggregateSpec, type AnyFilter, type CreateCustomTokenOptions, type CursorValue, FlareAdminApp, type FlareAdminAuth, FlareAdminAuthService, type FlareAdminConfig, FlareAdminConnection, type FlareAdminDb, FlareAdminDbService, type FlareAdminNotifications, FlareAdminNotificationsService, type FlareAdminStorage, FlareAdminStorageS3, FlareAdminWsConnection, type GroupByClause, type HavingClause, type JoinClause, type OrFilter, type OrderByClause, type QueryOperator, ServerTimeStamp, ServerTimeStampField, type StructuredQuery, type VectorSearchClause, type WhereCondition, type WhereFilter, auth, connectApp, db, disconnectAllApps, disconnectApp, getApp, live, notifications, storage };
|
package/dist/index.d.ts
CHANGED
|
@@ -33,14 +33,14 @@
|
|
|
33
33
|
* .get();
|
|
34
34
|
*
|
|
35
35
|
* // Real-time subscriptions over WebSocket
|
|
36
|
-
* const unsub = admin.
|
|
36
|
+
* const unsub = admin.live()
|
|
37
37
|
* .collection("orders")
|
|
38
38
|
* .where({ status: "pending" })
|
|
39
39
|
* .orderBy("createdAt", "desc")
|
|
40
40
|
* .onSnapshot((snap) => console.log(snap));
|
|
41
41
|
*/
|
|
42
42
|
export { AdminStorageSignedAction } from "./types";
|
|
43
|
-
export type { AdminCopyObjectInput, AdminDeleteObjectsInput, AdminDocAddedCallback, AdminDocChangedCallback, AdminDocDeletedCallback, AdminDocUpdatedCallback, AdminDownloadObjectInput, AdminDownloadObjectResult, AdminGetObjectInput, AdminGetObjectResult, AdminGetObjectUrlInput, AdminHeadObjectInput, AdminHeadObjectsInput, AdminListObjectsInput, AdminListObjectsResult, AdminPushSendInput, AdminPushSendResult, AdminPushToken, AdminPutObjectInput, AdminPutObjectResult, AdminSnapshotCallback, AdminSnapshotData, AdminStorageAwsConfig, AdminStorageBucket, AdminStorageBucketInput, AdminStorageDeleteInput, AdminStorageDownloadInput, AdminStorageObjectMeta, AdminStorageObjectResult, AdminStorageRulesHistoryResult, AdminStorageRulesPolicy, AdminStorageServer, AdminStorageServerInput, AdminStorageServerPatchInput, AdminStorageSignedUrlInput, AdminStorageSignedUrlResult, AdminStorageUploadInput, AdminSubscriptionError, AdminSubscriptionErrorCallback, AdminSubscriptionHandle, AggregateFunction, AggregateSpec, AnyFilter, CreateCustomTokenOptions, CursorValue, FlareAdminAuth, FlareAdminConfig, FlareAdminDb, FlareAdminNotifications, FlareAdminStorage, GroupByClause, HavingClause, JoinClause, OrderByClause, OrFilter, QueryOperator, StructuredQuery, VectorSearchClause, WhereCondition, WhereFilter } from "./types";
|
|
43
|
+
export type { AdminBulkWriteOperation, AdminBulkWriteOptions, AdminBulkWriteProgress, AdminBulkWriteResult, AdminConnectionState, AdminConnectionStateListener, AdminCopyObjectInput, AdminDeleteObjectsInput, AdminDocAddedCallback, AdminDocChangedCallback, AdminDocDeletedCallback, AdminDocUpdatedCallback, AdminDownloadObjectInput, AdminDownloadObjectResult, AdminGetObjectInput, AdminGetObjectResult, AdminGetObjectUrlInput, AdminHeadObjectInput, AdminHeadObjectsInput, AdminListObjectsInput, AdminListObjectsResult, AdminPushSendInput, AdminPushSendResult, AdminPushToken, AdminPutObjectInput, AdminPutObjectResult, AdminSnapshotCallback, AdminSnapshotData, AdminStorageAwsConfig, AdminStorageBucket, AdminStorageBucketInput, AdminStorageDeleteInput, AdminStorageDownloadInput, AdminStorageObjectMeta, AdminStorageObjectResult, AdminStorageRulesHistoryResult, AdminStorageRulesPolicy, AdminStorageServer, AdminStorageServerInput, AdminStorageServerPatchInput, AdminStorageSignedUrlInput, AdminStorageSignedUrlResult, AdminStorageUploadInput, AdminSubscriptionError, AdminSubscriptionErrorCallback, AdminSubscriptionHandle, AdminUpdateManyItem, AggregateFunction, AggregateSpec, AnyFilter, CreateCustomTokenOptions, CursorValue, FlareAdminAuth, FlareAdminConfig, FlareAdminDb, FlareAdminNotifications, FlareAdminStorage, GroupByClause, HavingClause, JoinClause, OrderByClause, OrFilter, QueryOperator, StructuredQuery, VectorSearchClause, WhereCondition, WhereFilter } from "./types";
|
|
44
44
|
export { AdminCollectionReference } from "./db/Collection";
|
|
45
45
|
export { AdminDocumentReference } from "./db/Document";
|
|
46
46
|
export { FlareAdminDbService } from "./db/index";
|
|
@@ -100,7 +100,7 @@ export declare class FlareAdminApp {
|
|
|
100
100
|
* `groupBy`, `having`, `Join`, `select`, `distinctField`, `vectorSearch`.
|
|
101
101
|
*
|
|
102
102
|
* @example
|
|
103
|
-
* const unsub = admin.
|
|
103
|
+
* const unsub = admin.live()
|
|
104
104
|
* .collection("orders")
|
|
105
105
|
* .where({ status: "pending" })
|
|
106
106
|
* .orderBy("createdAt", "desc")
|
|
@@ -110,15 +110,15 @@ export declare class FlareAdminApp {
|
|
|
110
110
|
* else console.log(snap.operation, snap.data);
|
|
111
111
|
* });
|
|
112
112
|
*
|
|
113
|
-
* const unsub2 = admin.
|
|
113
|
+
* const unsub2 = admin.live()
|
|
114
114
|
* .collection("users").doc("alice")
|
|
115
115
|
* .onSnapshot((snap) => console.log(snap.data));
|
|
116
116
|
*
|
|
117
117
|
* unsub();
|
|
118
118
|
* unsub2();
|
|
119
|
-
* admin.
|
|
119
|
+
* admin.live().disconnect();
|
|
120
120
|
*/
|
|
121
|
-
|
|
121
|
+
live(): FlareAdminConnection;
|
|
122
122
|
/**
|
|
123
123
|
* Access push notification management APIs.
|
|
124
124
|
*/
|
|
@@ -171,6 +171,25 @@ export declare class FlareAdminApp {
|
|
|
171
171
|
deleted: string[];
|
|
172
172
|
errors: Record<string, string>;
|
|
173
173
|
}>;
|
|
174
|
+
/**
|
|
175
|
+
* Subscribe to WebSocket connection state changes.
|
|
176
|
+
* Initializes the live connection if not already open.
|
|
177
|
+
* Returns an unsubscribe function.
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* const unsub = admin.onConnectionStateChange((state) => {
|
|
181
|
+
* console.log("connection:", state);
|
|
182
|
+
* // state: 'connecting' | 'connected' | 'disconnected' | 'reconnecting' | 'error'
|
|
183
|
+
* });
|
|
184
|
+
* // Later:
|
|
185
|
+
* unsub();
|
|
186
|
+
*/
|
|
187
|
+
onConnectionStateChange(listener: (state: import("./types").AdminConnectionState) => void): () => void;
|
|
188
|
+
/**
|
|
189
|
+
* Disconnect realtime resources tied to this app instance.
|
|
190
|
+
* Safe to call multiple times.
|
|
191
|
+
*/
|
|
192
|
+
disconnect(): void;
|
|
174
193
|
}
|
|
175
194
|
/**
|
|
176
195
|
* Initialize a FlareAdmin app instance.
|
|
@@ -192,6 +211,15 @@ export declare function connectApp(config: FlareAdminConfig, name?: string): Fla
|
|
|
192
211
|
* @throws If the app has not been initialized yet.
|
|
193
212
|
*/
|
|
194
213
|
export declare function getApp(name?: string): FlareAdminApp;
|
|
214
|
+
/**
|
|
215
|
+
* Disconnect and remove an initialized app by name.
|
|
216
|
+
* Returns true when an app existed and was removed.
|
|
217
|
+
*/
|
|
218
|
+
export declare function disconnectApp(name?: string): boolean;
|
|
219
|
+
/**
|
|
220
|
+
* Disconnect and clear all initialized apps.
|
|
221
|
+
*/
|
|
222
|
+
export declare function disconnectAllApps(): void;
|
|
195
223
|
/**
|
|
196
224
|
* Get the auth service from the default app.
|
|
197
225
|
* Equivalent to `getApp().auth()`.
|
|
@@ -212,15 +240,15 @@ export declare function auth(name?: string): FlareAdminAuth;
|
|
|
212
240
|
export declare function db(name?: string): FlareAdminDb;
|
|
213
241
|
/**
|
|
214
242
|
* Get the real-time WebSocket connection from the default app.
|
|
215
|
-
* Equivalent to `getApp().
|
|
243
|
+
* Equivalent to `getApp().live()`.
|
|
216
244
|
*
|
|
217
245
|
* @example
|
|
218
|
-
* import {
|
|
219
|
-
* const unsub =
|
|
246
|
+
* import { live } from "@zuzjs/flare-admin";
|
|
247
|
+
* const unsub = live().collection("users")
|
|
220
248
|
* .where({ role: "admin" })
|
|
221
249
|
* .onSnapshot((snap) => console.log(snap));
|
|
222
250
|
*/
|
|
223
|
-
export declare function
|
|
251
|
+
export declare function live(name?: string): FlareAdminConnection;
|
|
224
252
|
/**
|
|
225
253
|
* Get the notifications service from the default app.
|
|
226
254
|
* Equivalent to `getApp().notifications()`.
|