@zuzjs/flare-admin 0.1.1
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 +267 -0
- package/dist/db/Collection.d.ts +92 -0
- package/dist/db/Document.d.ts +27 -0
- package/dist/db/index.d.ts +22 -0
- package/dist/index.cjs +3 -0
- package/dist/index.d.cts +793 -0
- package/dist/index.d.ts +175 -0
- package/dist/index.js +2 -0
- package/dist/lib/auth.d.ts +6 -0
- package/dist/lib/notifications.d.ts +14 -0
- package/dist/lib/utils.d.ts +5 -0
- package/dist/realtime/Connection.d.ts +33 -0
- package/dist/realtime/LiveCollection.d.ts +93 -0
- package/dist/realtime/LiveDocument.d.ts +32 -0
- package/dist/realtime/WsConnection.d.ts +43 -0
- package/dist/types/index.d.ts +275 -0
- package/package.json +38 -0
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
export interface FlareAdminConfig {
|
|
2
|
+
/**
|
|
3
|
+
* Base URL of your FlareServer instance.
|
|
4
|
+
* Self-hosted: "http://localhost:5050"
|
|
5
|
+
* SaaS: "https://www.zedgon.io"
|
|
6
|
+
*/
|
|
7
|
+
serverUrl: string;
|
|
8
|
+
/** The app ID created with `flare app create` */
|
|
9
|
+
appId: string;
|
|
10
|
+
/**
|
|
11
|
+
* Admin key printed when you run `flare app create`.
|
|
12
|
+
* Keep in an environment variable — NEVER expose to the browser.
|
|
13
|
+
*/
|
|
14
|
+
adminKey: string;
|
|
15
|
+
/** Default token TTL, e.g. "24h" */
|
|
16
|
+
defaultTtl?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface CreateCustomTokenOptions {
|
|
19
|
+
role?: "user" | "admin" | "anon";
|
|
20
|
+
claims?: Record<string, unknown>;
|
|
21
|
+
ttl?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface FlareAdminAuth {
|
|
24
|
+
createCustomToken(uid: string | number, opts?: CreateCustomTokenOptions): Promise<string>;
|
|
25
|
+
}
|
|
26
|
+
export interface AdminPushSendInput {
|
|
27
|
+
title?: string;
|
|
28
|
+
body?: string;
|
|
29
|
+
image?: string;
|
|
30
|
+
data?: Record<string, unknown>;
|
|
31
|
+
tokens?: string[];
|
|
32
|
+
uid?: string;
|
|
33
|
+
topic?: string;
|
|
34
|
+
priority?: "normal" | "high";
|
|
35
|
+
ttlSeconds?: number;
|
|
36
|
+
dryRun?: boolean;
|
|
37
|
+
}
|
|
38
|
+
export interface AdminPushSendResult {
|
|
39
|
+
sent: boolean;
|
|
40
|
+
appId: string;
|
|
41
|
+
targetCount: number;
|
|
42
|
+
successCount: number;
|
|
43
|
+
failureCount: number;
|
|
44
|
+
invalidatedTokenCount: number;
|
|
45
|
+
dryRun: boolean;
|
|
46
|
+
}
|
|
47
|
+
export interface AdminPushToken {
|
|
48
|
+
token: string;
|
|
49
|
+
uid: string;
|
|
50
|
+
platform?: string;
|
|
51
|
+
deviceId?: string;
|
|
52
|
+
topics?: string[];
|
|
53
|
+
createdAt?: string;
|
|
54
|
+
updatedAt?: string;
|
|
55
|
+
lastSeenAt?: string;
|
|
56
|
+
}
|
|
57
|
+
export interface FlareAdminNotifications {
|
|
58
|
+
send(input: AdminPushSendInput): Promise<AdminPushSendResult>;
|
|
59
|
+
tokens(): Promise<{
|
|
60
|
+
appId: string;
|
|
61
|
+
hasPushGateway: boolean;
|
|
62
|
+
total: number;
|
|
63
|
+
tokens: AdminPushToken[];
|
|
64
|
+
}>;
|
|
65
|
+
}
|
|
66
|
+
export type QueryOperator = "==" | "!=" | "<" | "<=" | ">" | ">=" | "in" | "not-in" | "array-contains" | "array-contains-any" | "elem-match" | "like" | "not-like" | "contains" | "exists" | "not-exists";
|
|
67
|
+
export interface WhereFilter {
|
|
68
|
+
field: string;
|
|
69
|
+
op: QueryOperator;
|
|
70
|
+
value: unknown;
|
|
71
|
+
}
|
|
72
|
+
/** OR group — matches if ANY inner filter matches */
|
|
73
|
+
export interface OrFilter {
|
|
74
|
+
or: AnyFilter[];
|
|
75
|
+
}
|
|
76
|
+
/** AND group — matches only if ALL inner filters match */
|
|
77
|
+
export interface AndFilter {
|
|
78
|
+
and: AnyFilter[];
|
|
79
|
+
}
|
|
80
|
+
export type AnyFilter = WhereFilter | OrFilter | AndFilter;
|
|
81
|
+
/**
|
|
82
|
+
* ORM-style shorthand: `{ age: ">= 25", role: "admin" }`
|
|
83
|
+
*/
|
|
84
|
+
export type WhereCondition = Record<string, string | number | boolean | unknown[]>;
|
|
85
|
+
export interface OrderByClause {
|
|
86
|
+
field: string;
|
|
87
|
+
dir?: "asc" | "desc";
|
|
88
|
+
}
|
|
89
|
+
export interface GroupByClause {
|
|
90
|
+
fields: string[];
|
|
91
|
+
}
|
|
92
|
+
export interface HavingClause {
|
|
93
|
+
field: string;
|
|
94
|
+
op: "==" | "!=" | "<" | "<=" | ">" | ">=";
|
|
95
|
+
value: number;
|
|
96
|
+
}
|
|
97
|
+
export interface CursorValue {
|
|
98
|
+
values: unknown[];
|
|
99
|
+
}
|
|
100
|
+
export type AggregateFunction = "count" | "sum" | "avg" | "min" | "max" | "distinct";
|
|
101
|
+
export interface AggregateSpec {
|
|
102
|
+
fn: AggregateFunction;
|
|
103
|
+
field?: string;
|
|
104
|
+
alias?: string;
|
|
105
|
+
}
|
|
106
|
+
export interface JoinClause {
|
|
107
|
+
source: string;
|
|
108
|
+
target: string;
|
|
109
|
+
as: string;
|
|
110
|
+
single?: boolean;
|
|
111
|
+
where?: AnyFilter[];
|
|
112
|
+
orderBy?: OrderByClause[];
|
|
113
|
+
limit?: number;
|
|
114
|
+
offset?: number;
|
|
115
|
+
select?: string[];
|
|
116
|
+
joins?: NestedJoinClause[];
|
|
117
|
+
}
|
|
118
|
+
export interface NestedJoinClause extends JoinClause {
|
|
119
|
+
collection: string;
|
|
120
|
+
}
|
|
121
|
+
export interface StructuredJoinClause {
|
|
122
|
+
from: string;
|
|
123
|
+
localField: string;
|
|
124
|
+
foreignField: string;
|
|
125
|
+
as: string;
|
|
126
|
+
single?: boolean;
|
|
127
|
+
where?: AnyFilter[];
|
|
128
|
+
orderBy?: OrderByClause[];
|
|
129
|
+
limit?: number;
|
|
130
|
+
offset?: number;
|
|
131
|
+
select?: string[];
|
|
132
|
+
joins?: StructuredJoinClause[];
|
|
133
|
+
}
|
|
134
|
+
export interface VectorSearchClause {
|
|
135
|
+
field: string;
|
|
136
|
+
vector: number[];
|
|
137
|
+
k: number;
|
|
138
|
+
metric?: "cosine" | "euclidean" | "dotProduct";
|
|
139
|
+
minScore?: number;
|
|
140
|
+
}
|
|
141
|
+
/** Full structured query (mirrors client StructuredQuery / server StructuredQuery) */
|
|
142
|
+
export interface StructuredQuery {
|
|
143
|
+
where?: AnyFilter[];
|
|
144
|
+
orderBy?: OrderByClause[];
|
|
145
|
+
limit?: number;
|
|
146
|
+
offset?: number;
|
|
147
|
+
startAt?: CursorValue;
|
|
148
|
+
startAfter?: CursorValue;
|
|
149
|
+
endAt?: CursorValue;
|
|
150
|
+
endBefore?: CursorValue;
|
|
151
|
+
aggregate?: AggregateSpec[];
|
|
152
|
+
groupBy?: GroupByClause;
|
|
153
|
+
having?: HavingClause[];
|
|
154
|
+
joins?: StructuredJoinClause[];
|
|
155
|
+
vectorSearch?: VectorSearchClause;
|
|
156
|
+
select?: string[];
|
|
157
|
+
distinctField?: string;
|
|
158
|
+
}
|
|
159
|
+
export interface AdminListOptions {
|
|
160
|
+
limit?: number;
|
|
161
|
+
skip?: number;
|
|
162
|
+
where?: WhereFilter[];
|
|
163
|
+
}
|
|
164
|
+
/** Minimal structural interface satisfied by AdminCollectionReference<T>. */
|
|
165
|
+
export interface FlareAdminDb {
|
|
166
|
+
collection<T = Record<string, unknown>>(name: string): AdminCollectionShape<T>;
|
|
167
|
+
}
|
|
168
|
+
export interface AdminDocumentShape<T> {
|
|
169
|
+
get(): Promise<T | null>;
|
|
170
|
+
set(data: Partial<T>): Promise<void>;
|
|
171
|
+
update(data: Partial<T>): Promise<void>;
|
|
172
|
+
delete(): Promise<void>;
|
|
173
|
+
}
|
|
174
|
+
export interface AdminCollectionShape<T> {
|
|
175
|
+
allowSensitiveAuthUserFields(enabled?: boolean): AdminCollectionShape<T>;
|
|
176
|
+
where(condition: WhereCondition): AdminCollectionShape<T>;
|
|
177
|
+
and(condition: WhereCondition): AdminCollectionShape<T>;
|
|
178
|
+
or(condition: WhereCondition): AdminCollectionShape<T>;
|
|
179
|
+
in(field: string, values: unknown[] | unknown): AdminCollectionShape<T>;
|
|
180
|
+
andIn(field: string, values: unknown[] | unknown): AdminCollectionShape<T>;
|
|
181
|
+
orIn(field: string, values: unknown[] | unknown): AdminCollectionShape<T>;
|
|
182
|
+
notIn(field: string, values: unknown[] | unknown): AdminCollectionShape<T>;
|
|
183
|
+
andNotIn(field: string, values: unknown[] | unknown): AdminCollectionShape<T>;
|
|
184
|
+
orNotIn(field: string, values: unknown[] | unknown): AdminCollectionShape<T>;
|
|
185
|
+
arrayContains(field: string, value: unknown): AdminCollectionShape<T>;
|
|
186
|
+
andArrayContains(field: string, value: unknown): AdminCollectionShape<T>;
|
|
187
|
+
orArrayContains(field: string, value: unknown): AdminCollectionShape<T>;
|
|
188
|
+
arrayContainsAny(field: string, values: unknown[] | unknown): AdminCollectionShape<T>;
|
|
189
|
+
andArrayContainsAny(field: string, values: unknown[] | unknown): AdminCollectionShape<T>;
|
|
190
|
+
orArrayContainsAny(field: string, values: unknown[] | unknown): AdminCollectionShape<T>;
|
|
191
|
+
some(field: string, condition: Record<string, unknown>): AdminCollectionShape<T>;
|
|
192
|
+
andSome(field: string, condition: Record<string, unknown>): AdminCollectionShape<T>;
|
|
193
|
+
orSome(field: string, condition: Record<string, unknown>): AdminCollectionShape<T>;
|
|
194
|
+
like(field: string, value: string): AdminCollectionShape<T>;
|
|
195
|
+
andLike(field: string, value: string): AdminCollectionShape<T>;
|
|
196
|
+
orLike(field: string, value: string): AdminCollectionShape<T>;
|
|
197
|
+
notLike(field: string, value: string): AdminCollectionShape<T>;
|
|
198
|
+
andNotLike(field: string, value: string): AdminCollectionShape<T>;
|
|
199
|
+
orNotLike(field: string, value: string): AdminCollectionShape<T>;
|
|
200
|
+
exists(field: string): AdminCollectionShape<T>;
|
|
201
|
+
andExists(field: string): AdminCollectionShape<T>;
|
|
202
|
+
orExists(field: string): AdminCollectionShape<T>;
|
|
203
|
+
notExists(field: string): AdminCollectionShape<T>;
|
|
204
|
+
andNotExists(field: string): AdminCollectionShape<T>;
|
|
205
|
+
orNotExists(field: string): AdminCollectionShape<T>;
|
|
206
|
+
latest(): AdminCollectionShape<T>;
|
|
207
|
+
newest(): AdminCollectionShape<T>;
|
|
208
|
+
oldest(): AdminCollectionShape<T>;
|
|
209
|
+
orderBy(field: string, dir?: "asc" | "desc"): AdminCollectionShape<T>;
|
|
210
|
+
limit(n: number): AdminCollectionShape<T>;
|
|
211
|
+
offset(n: number): AdminCollectionShape<T>;
|
|
212
|
+
startAt(...values: unknown[]): AdminCollectionShape<T>;
|
|
213
|
+
startAfter(...values: unknown[]): AdminCollectionShape<T>;
|
|
214
|
+
endAt(...values: unknown[]): AdminCollectionShape<T>;
|
|
215
|
+
endBefore(...values: unknown[]): AdminCollectionShape<T>;
|
|
216
|
+
aggregate(...specs: AggregateSpec[]): AdminCollectionShape<T>;
|
|
217
|
+
count(alias?: string): AdminCollectionShape<T>;
|
|
218
|
+
sum(field: string, alias?: string): AdminCollectionShape<T>;
|
|
219
|
+
avg(field: string, alias?: string): AdminCollectionShape<T>;
|
|
220
|
+
min(field: string, alias?: string): AdminCollectionShape<T>;
|
|
221
|
+
max(field: string, alias?: string): AdminCollectionShape<T>;
|
|
222
|
+
distinct(field: string, alias?: string): AdminCollectionShape<T>;
|
|
223
|
+
groupBy(...fields: string[]): AdminCollectionShape<T>;
|
|
224
|
+
having(field: string, op: HavingClause["op"], value: number): AdminCollectionShape<T>;
|
|
225
|
+
join(collection: string, j: JoinClause): AdminCollectionShape<T>;
|
|
226
|
+
joinNested(parentAlias: string, collection: string, j: JoinClause): AdminCollectionShape<T>;
|
|
227
|
+
Join(collection: string, j: JoinClause): AdminCollectionShape<T>;
|
|
228
|
+
JoinNested(parentAlias: string, collection: string, j: JoinClause): AdminCollectionShape<T>;
|
|
229
|
+
withRelation(relation: string, options?: Omit<JoinClause, "source" | "target" | "as"> & {
|
|
230
|
+
as?: string;
|
|
231
|
+
}): AdminCollectionShape<T>;
|
|
232
|
+
select(...fields: string[]): AdminCollectionShape<T>;
|
|
233
|
+
distinctField(field: string): AdminCollectionShape<T>;
|
|
234
|
+
vectorSearch(opts: VectorSearchClause): AdminCollectionShape<T>;
|
|
235
|
+
getRawQuery(): {
|
|
236
|
+
collection: string;
|
|
237
|
+
query: StructuredQuery;
|
|
238
|
+
};
|
|
239
|
+
get(): Promise<T[]>;
|
|
240
|
+
first(): Promise<T | null>;
|
|
241
|
+
last(): Promise<T | null>;
|
|
242
|
+
add(data: Partial<T>): Promise<AdminDocumentShape<T>>;
|
|
243
|
+
deleteMany(): Promise<number>;
|
|
244
|
+
doc(id: string): AdminDocumentShape<T>;
|
|
245
|
+
}
|
|
246
|
+
export interface AdminSnapshotData<T = unknown> {
|
|
247
|
+
subscriptionId: string;
|
|
248
|
+
collection: string;
|
|
249
|
+
docId?: string;
|
|
250
|
+
data: T;
|
|
251
|
+
type: "snapshot" | "change";
|
|
252
|
+
operation?: "insert" | "update" | "delete" | "replace";
|
|
253
|
+
}
|
|
254
|
+
export type AdminSnapshotCallback<T = unknown> = (data: AdminSnapshotData<T>) => void;
|
|
255
|
+
export type AdminDocAddedCallback<T = unknown> = (data: T, docId: string) => void;
|
|
256
|
+
export type AdminDocUpdatedCallback<T = unknown> = (data: T, docId: string) => void;
|
|
257
|
+
export type AdminDocDeletedCallback = (docId: string) => void;
|
|
258
|
+
export type AdminDocChangedCallback<T = unknown> = (data: T | null, docId: string, operation: "insert" | "update" | "delete" | "replace") => void;
|
|
259
|
+
export interface AdminSubscribeOptions {
|
|
260
|
+
skipSnapshot?: boolean;
|
|
261
|
+
}
|
|
262
|
+
export interface AdminSubscriptionError {
|
|
263
|
+
code?: string;
|
|
264
|
+
message: string;
|
|
265
|
+
permissionDenied: boolean;
|
|
266
|
+
raw?: unknown;
|
|
267
|
+
}
|
|
268
|
+
export type AdminSubscriptionErrorCallback = (error: AdminSubscriptionError) => void;
|
|
269
|
+
export interface AdminSubscriptionHandle {
|
|
270
|
+
(): void;
|
|
271
|
+
unsubscribe: () => void;
|
|
272
|
+
onError: (callback: AdminSubscriptionErrorCallback) => AdminSubscriptionHandle;
|
|
273
|
+
onPermissionDenied: (callback: AdminSubscriptionErrorCallback) => AdminSubscriptionHandle;
|
|
274
|
+
catch: (callback: AdminSubscriptionErrorCallback) => AdminSubscriptionHandle;
|
|
275
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zuzjs/flare-admin",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Server-side admin SDK for FlareServer — mint custom auth tokens from your backend (like firebase-admin)",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"flare",
|
|
7
|
+
"flare-admin",
|
|
8
|
+
"zuzjs",
|
|
9
|
+
"auth",
|
|
10
|
+
"realtime",
|
|
11
|
+
"websocket"
|
|
12
|
+
],
|
|
13
|
+
"author": "Zuz.js Team <support@zuz.com.pk>",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"type": "module",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "https://github.com/zuzjs/flare-admin.git"
|
|
19
|
+
},
|
|
20
|
+
"homepage": "https://www.zedgon.io",
|
|
21
|
+
"main": "./dist/index.cjs",
|
|
22
|
+
"module": "./dist/index.js",
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"import": "./dist/index.js",
|
|
28
|
+
"require": "./dist/index.cjs"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist",
|
|
33
|
+
"README.md"
|
|
34
|
+
],
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"ws": "^8.19.0"
|
|
37
|
+
}
|
|
38
|
+
}
|