@zuzjs/flare-admin 0.1.3 → 0.1.5

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.d.cts CHANGED
@@ -12,6 +12,10 @@ interface FlareAdminConfig {
12
12
  * Keep in an environment variable — NEVER expose to the browser.
13
13
  */
14
14
  adminKey: string;
15
+ /** Optional gRPC endpoint, e.g. "127.0.0.1:5051". */
16
+ grpcUrl?: string;
17
+ /** Transport preference for supported operations. */
18
+ transport?: "auto" | "http" | "grpc";
15
19
  /** Default token TTL, e.g. "24h" */
16
20
  defaultTtl?: string;
17
21
  /**
@@ -89,6 +93,322 @@ interface FlareAdminNotifications {
89
93
  tokens: AdminPushToken[];
90
94
  }>;
91
95
  }
96
+ interface AdminStorageServer {
97
+ id: string;
98
+ name: string;
99
+ kind: string;
100
+ endpoint: string;
101
+ bucket: string;
102
+ region: string;
103
+ prefix?: string;
104
+ dataDir?: string;
105
+ forcePathStyle?: boolean;
106
+ frozen?: boolean;
107
+ readOnly?: boolean;
108
+ createdAt?: unknown;
109
+ updatedAt?: unknown;
110
+ }
111
+ interface AdminStorageServerInput {
112
+ name: string;
113
+ kind?: string;
114
+ endpoint?: string;
115
+ bucket: string;
116
+ region?: string;
117
+ accessKey?: string;
118
+ secretKey?: string;
119
+ prefix?: string;
120
+ dataDir?: string;
121
+ forcePathStyle?: boolean;
122
+ frozen?: boolean;
123
+ readOnly?: boolean;
124
+ }
125
+ interface AdminStorageServerPatchInput {
126
+ name?: string;
127
+ endpoint?: string;
128
+ bucket?: string;
129
+ region?: string;
130
+ accessKey?: string;
131
+ secretKey?: string;
132
+ prefix?: string;
133
+ dataDir?: string;
134
+ forcePathStyle?: boolean;
135
+ frozen?: boolean;
136
+ readOnly?: boolean;
137
+ }
138
+ interface AdminStorageUploadInput {
139
+ serverId: string;
140
+ path: string;
141
+ contentBase64: string;
142
+ contentType?: string;
143
+ encrypt?: boolean;
144
+ }
145
+ interface AdminStorageDownloadInput {
146
+ serverId: string;
147
+ path: string;
148
+ decrypt?: boolean;
149
+ }
150
+ interface AdminStorageDeleteInput {
151
+ serverId: string;
152
+ path: string;
153
+ }
154
+ interface AdminStorageObjectResult {
155
+ ok: boolean;
156
+ path: string;
157
+ key: string;
158
+ encrypted?: boolean;
159
+ size?: number;
160
+ contentBase64?: string;
161
+ contentType?: string;
162
+ }
163
+ declare enum AdminStorageSignedAction {
164
+ Upload = "upload",
165
+ Download = "download",
166
+ Delete = "delete",
167
+ Edit = "edit"
168
+ }
169
+ interface AdminStorageSignedUrlInput {
170
+ bucket: string;
171
+ key: string;
172
+ action: AdminStorageSignedAction;
173
+ expiresInSeconds?: number;
174
+ sizeBytes?: number;
175
+ contentType?: string;
176
+ encrypt?: boolean;
177
+ decrypt?: boolean;
178
+ forceDownload?: boolean;
179
+ allowedOrigins?: string[];
180
+ embedOnly?: boolean;
181
+ }
182
+ interface AdminStorageSignedUrlResult {
183
+ ok: boolean;
184
+ action: AdminStorageSignedAction;
185
+ method: "PUT" | "PATCH" | "GET" | "DELETE";
186
+ token: string;
187
+ urlPath: string;
188
+ url: string;
189
+ expiresInSeconds?: number;
190
+ expiresAt: number;
191
+ forceDownload?: boolean;
192
+ allowedOrigins?: string[];
193
+ embedOnly?: boolean;
194
+ }
195
+ interface AdminGetObjectUrlInput {
196
+ bucket: string;
197
+ key: string;
198
+ decrypt?: boolean;
199
+ expiresInSeconds?: number;
200
+ forceDownload?: boolean;
201
+ allowedOrigins?: string[];
202
+ embedOnly?: boolean;
203
+ }
204
+ interface AdminDownloadObjectInput extends AdminGetObjectUrlInput {
205
+ filename?: string;
206
+ openInNewTab?: boolean;
207
+ }
208
+ interface AdminDownloadObjectResult {
209
+ ok: boolean;
210
+ url: string;
211
+ filename: string;
212
+ triggered: boolean;
213
+ }
214
+ interface AdminStorageAwsConfig {
215
+ kind: string;
216
+ endpoint: string;
217
+ region: string;
218
+ bucket: string;
219
+ prefix?: string;
220
+ dataDir?: string;
221
+ forcePathStyle?: boolean;
222
+ accessKeyId: string;
223
+ secretAccessKey: string;
224
+ }
225
+ interface AdminStorageRulesPolicy {
226
+ maxEntries?: number;
227
+ maxAgeDays?: number;
228
+ }
229
+ interface AdminStorageRulesHistoryResult {
230
+ history: unknown[];
231
+ policy: AdminStorageRulesPolicy;
232
+ restoreEvents: unknown[];
233
+ }
234
+ interface FlareAdminStorage {
235
+ servers(): Promise<AdminStorageServer[]>;
236
+ createServer(input: AdminStorageServerInput): Promise<{
237
+ ok: boolean;
238
+ serverId: string;
239
+ }>;
240
+ patchServer(serverId: string, input: AdminStorageServerPatchInput): Promise<{
241
+ ok: boolean;
242
+ serverId: string;
243
+ }>;
244
+ deleteServer(serverId: string): Promise<{
245
+ ok: boolean;
246
+ serverId: string;
247
+ removedObjects: number;
248
+ }>;
249
+ awsConfig(serverId: string): Promise<AdminStorageAwsConfig>;
250
+ uploadObject(input: AdminStorageUploadInput): Promise<AdminStorageObjectResult>;
251
+ downloadObject(input: AdminStorageDownloadInput): Promise<AdminStorageObjectResult>;
252
+ deleteObject(input: AdminStorageDeleteInput | AdminDeleteObjectsInput): Promise<AdminStorageObjectResult | {
253
+ ok: boolean;
254
+ deleted: string[];
255
+ errors: Record<string, string>;
256
+ }>;
257
+ createSignedUrl(input: AdminStorageSignedUrlInput): Promise<AdminStorageSignedUrlResult>;
258
+ setRules(input: {
259
+ rules?: Record<string, unknown>;
260
+ rulesDsl?: string;
261
+ rulesHistoryPolicy?: AdminStorageRulesPolicy;
262
+ }): Promise<{
263
+ id: string;
264
+ }>;
265
+ validateRules(rulesDsl: string): Promise<{
266
+ valid: boolean;
267
+ diagnostics: unknown[];
268
+ rulesCount: number;
269
+ }>;
270
+ rulesHistory(): Promise<AdminStorageRulesHistoryResult>;
271
+ restoreRules(historyId: string): Promise<{
272
+ id: string;
273
+ rulesText: string;
274
+ }>;
275
+ createBucket(name: string, options?: AdminStorageBucketInput): Promise<AdminStorageBucket>;
276
+ listBuckets(): Promise<AdminStorageBucket[]>;
277
+ deleteBucket(name: string): Promise<{
278
+ ok: boolean;
279
+ removedObjects: number;
280
+ }>;
281
+ deleteBuckets(names: string[]): Promise<{
282
+ ok: boolean;
283
+ deleted: string[];
284
+ errors: Record<string, string>;
285
+ }>;
286
+ getBucketLocation(name: string): Promise<{
287
+ bucket: string;
288
+ kind: string;
289
+ region?: string;
290
+ endpoint?: string;
291
+ }>;
292
+ putObject(input: AdminPutObjectInput): Promise<AdminPutObjectResult>;
293
+ getObject(input: AdminGetObjectInput): Promise<AdminGetObjectResult>;
294
+ getObjectUrl(input: AdminGetObjectUrlInput): Promise<string>;
295
+ downloadObject(input: AdminDownloadObjectInput): Promise<AdminDownloadObjectResult>;
296
+ headObject(input: AdminHeadObjectInput): Promise<AdminStorageObjectMeta>;
297
+ headObjects(input: AdminHeadObjectsInput): Promise<AdminStorageObjectMeta[]>;
298
+ listObjects(input: AdminListObjectsInput): Promise<AdminListObjectsResult>;
299
+ copyObject(input: AdminCopyObjectInput): Promise<{
300
+ ok: boolean;
301
+ }>;
302
+ copyObjects(inputs: AdminCopyObjectInput[]): Promise<{
303
+ ok: boolean;
304
+ errors: Record<string, string>;
305
+ }>;
306
+ deleteObjects(input: AdminDeleteObjectsInput): Promise<{
307
+ ok: boolean;
308
+ deleted: string[];
309
+ errors: Record<string, string>;
310
+ }>;
311
+ }
312
+ interface AdminStorageBucket {
313
+ id: string;
314
+ name: string;
315
+ bucket: string;
316
+ kind: string;
317
+ region?: string;
318
+ endpoint?: string;
319
+ prefix?: string;
320
+ frozen?: boolean;
321
+ readOnly?: boolean;
322
+ createdAt?: unknown;
323
+ updatedAt?: unknown;
324
+ }
325
+ interface AdminStorageBucketInput {
326
+ kind?: string;
327
+ prefix?: string;
328
+ region?: string;
329
+ endpoint?: string;
330
+ accessKey?: string;
331
+ secretKey?: string;
332
+ dataDir?: string;
333
+ forcePathStyle?: boolean;
334
+ }
335
+ interface AdminStorageObjectMeta {
336
+ key: string;
337
+ bucket: string;
338
+ size: number;
339
+ contentType: string;
340
+ encrypted: boolean;
341
+ createdAt?: unknown;
342
+ updatedAt?: unknown;
343
+ }
344
+ interface AdminPutObjectInput {
345
+ bucket: string;
346
+ key: string;
347
+ body?: string | Uint8Array | ArrayBuffer | Buffer;
348
+ /** Pre-encoded base64 body. Mutually exclusive with `body`. Always uses base64 path. */
349
+ contentBase64?: string;
350
+ contentType?: string;
351
+ /** Encrypt at rest with AES-256-GCM. Defaults to true. */
352
+ encrypt?: boolean;
353
+ /**
354
+ * Max payload bytes for the base64-over-JSON upload path.
355
+ * Payloads larger than this are uploaded via a signed URL (raw binary PUT).
356
+ * Default: 4 MiB.
357
+ */
358
+ base64MaxBytes?: number;
359
+ }
360
+ interface AdminPutObjectResult {
361
+ ok: boolean;
362
+ bucket: string;
363
+ key: string;
364
+ size: number;
365
+ encrypted: boolean;
366
+ }
367
+ interface AdminGetObjectInput {
368
+ bucket: string;
369
+ key: string;
370
+ decrypt?: boolean;
371
+ }
372
+ interface AdminGetObjectResult {
373
+ ok: boolean;
374
+ bucket: string;
375
+ key: string;
376
+ contentBase64: string;
377
+ contentType: string;
378
+ size: number;
379
+ encrypted: boolean;
380
+ }
381
+ interface AdminHeadObjectInput {
382
+ bucket: string;
383
+ key: string;
384
+ }
385
+ interface AdminHeadObjectsInput {
386
+ bucket: string;
387
+ keys: string[];
388
+ }
389
+ interface AdminListObjectsInput {
390
+ bucket: string;
391
+ prefix?: string;
392
+ limit?: number;
393
+ cursor?: string;
394
+ }
395
+ interface AdminListObjectsResult {
396
+ bucket: string;
397
+ objects: AdminStorageObjectMeta[];
398
+ count: number;
399
+ hasMore: boolean;
400
+ cursor?: string;
401
+ }
402
+ interface AdminCopyObjectInput {
403
+ sourceBucket: string;
404
+ sourceKey: string;
405
+ destBucket: string;
406
+ destKey: string;
407
+ }
408
+ interface AdminDeleteObjectsInput {
409
+ bucket: string;
410
+ keys: string[];
411
+ }
92
412
  type QueryOperator = "==" | "!=" | "<" | "<=" | ">" | ">=" | "in" | "not-in" | "array-contains" | "array-contains-any" | "elem-match" | "like" | "not-like" | "contains" | "exists" | "not-exists";
93
413
  interface WhereFilter {
94
414
  field: string;
@@ -454,6 +774,104 @@ declare class FlareAdminNotificationsService implements FlareAdminNotifications
454
774
  }>;
455
775
  }
456
776
 
777
+ declare class FlareAdminStorageService {
778
+ private readonly cfg;
779
+ constructor(cfg: Required<FlareAdminConfig>);
780
+ private base;
781
+ private get headers();
782
+ protected jsonRequest<T>(method: string, path: string, body?: unknown): Promise<T>;
783
+ request<T>(method: string, path: string, body?: unknown): Promise<T>;
784
+ servers(): Promise<AdminStorageServer[]>;
785
+ createServer(input: AdminStorageServerInput): Promise<{
786
+ ok: boolean;
787
+ serverId: string;
788
+ }>;
789
+ patchServer(serverId: string, input: AdminStorageServerPatchInput): Promise<{
790
+ ok: boolean;
791
+ serverId: string;
792
+ }>;
793
+ deleteServer(serverId: string): Promise<{
794
+ ok: boolean;
795
+ serverId: string;
796
+ removedObjects: number;
797
+ }>;
798
+ awsConfig(serverId: string): Promise<AdminStorageAwsConfig>;
799
+ uploadObject(input: AdminStorageUploadInput): Promise<AdminStorageObjectResult>;
800
+ downloadObject(input: AdminStorageDownloadInput): Promise<AdminStorageObjectResult>;
801
+ deleteObject(input: AdminStorageDeleteInput): Promise<AdminStorageObjectResult>;
802
+ createSignedUrl(input: AdminStorageSignedUrlInput): Promise<AdminStorageSignedUrlResult>;
803
+ setRules(input: {
804
+ rules?: Record<string, unknown>;
805
+ rulesDsl?: string;
806
+ rulesHistoryPolicy?: AdminStorageRulesPolicy;
807
+ }): Promise<{
808
+ id: string;
809
+ }>;
810
+ validateRules(rulesDsl: string): Promise<{
811
+ valid: boolean;
812
+ diagnostics: unknown[];
813
+ rulesCount: number;
814
+ }>;
815
+ rulesHistory(): Promise<AdminStorageRulesHistoryResult>;
816
+ restoreRules(historyId: string): Promise<{
817
+ id: string;
818
+ rulesText: string;
819
+ }>;
820
+ }
821
+ /**
822
+ * S3-compatible admin storage service.
823
+ * Works with bucket names; resolves server IDs internally.
824
+ */
825
+ declare class FlareAdminStorageS3 {
826
+ private readonly _svc;
827
+ private readonly _bucketCache;
828
+ private _bucketListLoaded;
829
+ private _bucketListPromise;
830
+ constructor(svc: FlareAdminStorageService);
831
+ private _ensureBuckets;
832
+ private _loadBuckets;
833
+ private _invalidateCache;
834
+ private _resolveBucketId;
835
+ createBucket(name: string, options?: AdminStorageBucketInput): Promise<AdminStorageBucket>;
836
+ listBuckets(): Promise<AdminStorageBucket[]>;
837
+ deleteBucket(name: string): Promise<{
838
+ ok: boolean;
839
+ removedObjects: number;
840
+ }>;
841
+ deleteBuckets(names: string[]): Promise<{
842
+ ok: boolean;
843
+ deleted: string[];
844
+ errors: Record<string, string>;
845
+ }>;
846
+ getBucketLocation(name: string): Promise<{
847
+ bucket: string;
848
+ kind: string;
849
+ region?: string;
850
+ endpoint?: string;
851
+ }>;
852
+ putObject(input: AdminPutObjectInput): Promise<AdminPutObjectResult>;
853
+ getObject(input: AdminGetObjectInput): Promise<AdminGetObjectResult>;
854
+ getObjectUrl(input: AdminGetObjectUrlInput): Promise<string>;
855
+ downloadObject(input: AdminDownloadObjectInput): Promise<AdminDownloadObjectResult>;
856
+ headObject(input: AdminHeadObjectInput): Promise<AdminStorageObjectMeta>;
857
+ headObjects(input: AdminHeadObjectsInput): Promise<AdminStorageObjectMeta[]>;
858
+ listObjects(input: AdminListObjectsInput): Promise<AdminListObjectsResult>;
859
+ copyObject(input: AdminCopyObjectInput): Promise<{
860
+ ok: boolean;
861
+ }>;
862
+ copyObjects(inputs: AdminCopyObjectInput[]): Promise<{
863
+ ok: boolean;
864
+ errors: Record<string, string>;
865
+ }>;
866
+ deleteObject(input: AdminStorageDeleteInput): Promise<AdminStorageObjectResult>;
867
+ deleteObjects(input: AdminDeleteObjectsInput): Promise<{
868
+ ok: boolean;
869
+ deleted: string[];
870
+ errors: Record<string, string>;
871
+ }>;
872
+ createSignedUrl(input: AdminStorageSignedUrlInput): Promise<AdminStorageSignedUrlResult>;
873
+ }
874
+
457
875
  type AdminRealtimeSubscriber$1 = {
458
876
  subscribe: (collection: string, docId: string | undefined, structuredQuery: StructuredQuery | undefined, callback: AdminSnapshotCallback, options?: AdminSubscribeOptions) => AdminSubscriptionHandle;
459
877
  };
@@ -652,6 +1070,20 @@ declare class FlareAdminWsConnection {
652
1070
  private _handle;
653
1071
  }
654
1072
 
1073
+ /**
1074
+ * Sentinel value that asks flare-node to write the current server timestamp.
1075
+ *
1076
+ * Usage:
1077
+ * await admin.db().collection("posts").doc(id).update({ updatedAt: ServerTimeStamp })
1078
+ */
1079
+ declare const ServerTimeStamp: "ServerTimeStamp";
1080
+ /**
1081
+ * Object form of the same sentinel for payloads that prefer structured values.
1082
+ */
1083
+ declare const ServerTimeStampField: {
1084
+ readonly $serverTimestamp: true;
1085
+ };
1086
+
655
1087
  /**
656
1088
  * @zuzjs/flare-admin
657
1089
  *
@@ -704,6 +1136,8 @@ declare class FlareAdminApp {
704
1136
  private _db?;
705
1137
  private _conn?;
706
1138
  private _notifications?;
1139
+ private _storage?;
1140
+ private _storageS3?;
707
1141
  /**
708
1142
  * Access the auth service.
709
1143
  *
@@ -761,6 +1195,54 @@ declare class FlareAdminApp {
761
1195
  * Access push notification management APIs.
762
1196
  */
763
1197
  notifications(): FlareAdminNotifications;
1198
+ private storageService;
1199
+ storage(): FlareAdminStorageS3;
1200
+ /**
1201
+ * S3-compatible storage service. Works with bucket names; no server IDs needed.
1202
+ * Bucket is auto-created on putObject() if it doesn't exist.
1203
+ *
1204
+ * @example
1205
+ * await admin.s3().putObject({ bucket: 'avatars', key: 'alice.png', body: buffer });
1206
+ * const { contentBase64 } = await admin.s3().getObject({ bucket: 'avatars', key: 'alice.png' });
1207
+ */
1208
+ s3(): FlareAdminStorageS3;
1209
+ createSignedUrl(input: AdminStorageSignedUrlInput): Promise<AdminStorageSignedUrlResult>;
1210
+ createBucket(name: string, options?: AdminStorageBucketInput): Promise<AdminStorageBucket>;
1211
+ listBuckets(): Promise<AdminStorageBucket[]>;
1212
+ deleteBucket(name: string): Promise<{
1213
+ ok: boolean;
1214
+ removedObjects: number;
1215
+ }>;
1216
+ deleteBuckets(names: string[]): Promise<{
1217
+ ok: boolean;
1218
+ deleted: string[];
1219
+ errors: Record<string, string>;
1220
+ }>;
1221
+ getBucketLocation(name: string): Promise<{
1222
+ bucket: string;
1223
+ kind: string;
1224
+ region?: string;
1225
+ endpoint?: string;
1226
+ }>;
1227
+ putObject(input: AdminPutObjectInput): Promise<AdminPutObjectResult>;
1228
+ getObject(input: AdminGetObjectInput): Promise<AdminGetObjectResult>;
1229
+ getObjectUrl(input: AdminGetObjectUrlInput): Promise<string>;
1230
+ downloadObject(input: AdminDownloadObjectInput): Promise<AdminDownloadObjectResult>;
1231
+ headObject(input: AdminHeadObjectInput): Promise<AdminStorageObjectMeta>;
1232
+ headObjects(input: AdminHeadObjectsInput): Promise<AdminStorageObjectMeta[]>;
1233
+ listObjects(input: AdminListObjectsInput): Promise<AdminListObjectsResult>;
1234
+ copyObject(input: AdminCopyObjectInput): Promise<{
1235
+ ok: boolean;
1236
+ }>;
1237
+ copyObjects(inputs: AdminCopyObjectInput[]): Promise<{
1238
+ ok: boolean;
1239
+ errors: Record<string, string>;
1240
+ }>;
1241
+ deleteObjects(input: AdminDeleteObjectsInput): Promise<{
1242
+ ok: boolean;
1243
+ deleted: string[];
1244
+ errors: Record<string, string>;
1245
+ }>;
764
1246
  }
765
1247
  /**
766
1248
  * Initialize a FlareAdmin app instance.
@@ -816,5 +1298,6 @@ declare function connection(name?: string): FlareAdminConnection;
816
1298
  * Equivalent to `getApp().notifications()`.
817
1299
  */
818
1300
  declare function notifications(name?: string): FlareAdminNotifications;
1301
+ declare function storage(name?: string): FlareAdminStorageS3;
819
1302
 
820
- export { AdminCollectionReference, type AdminDocAddedCallback, type AdminDocChangedCallback, type AdminDocDeletedCallback, type AdminDocUpdatedCallback, AdminDocumentReference, AdminLiveCollectionReference, AdminLiveDocumentReference, type AdminPushSendInput, type AdminPushSendResult, type AdminPushToken, type AdminSnapshotCallback, type AdminSnapshotData, 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, FlareAdminWsConnection, type GroupByClause, type HavingClause, type JoinClause, type OrFilter, type OrderByClause, type QueryOperator, type StructuredQuery, type VectorSearchClause, type WhereCondition, type WhereFilter, auth, connectApp, connection, db, getApp, notifications };
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, connection, db, getApp, notifications, storage };
package/dist/index.d.ts CHANGED
@@ -39,18 +39,21 @@
39
39
  * .orderBy("createdAt", "desc")
40
40
  * .onSnapshot((snap) => console.log(snap));
41
41
  */
42
- export type { AdminDocAddedCallback, AdminDocChangedCallback, AdminDocDeletedCallback, AdminDocUpdatedCallback, AdminPushSendInput, AdminPushSendResult, AdminPushToken, AdminSnapshotCallback, AdminSnapshotData, AdminSubscriptionError, AdminSubscriptionErrorCallback, AdminSubscriptionHandle, AggregateFunction, AggregateSpec, AnyFilter, CreateCustomTokenOptions, CursorValue, FlareAdminAuth, FlareAdminConfig, FlareAdminDb, FlareAdminNotifications, GroupByClause, HavingClause, JoinClause, OrderByClause, OrFilter, QueryOperator, StructuredQuery, VectorSearchClause, WhereCondition, WhereFilter } from "./types";
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
44
  export { AdminCollectionReference } from "./db/Collection";
44
45
  export { AdminDocumentReference } from "./db/Document";
45
46
  export { FlareAdminDbService } from "./db/index";
46
47
  export { FlareAdminAuthService } from "./lib/auth";
47
48
  export { FlareAdminNotificationsService } from "./lib/notifications";
49
+ export { FlareAdminStorageS3 } from "./lib/storage";
48
50
  export { FlareAdminConnection } from "./realtime/Connection";
49
51
  export { AdminLiveCollectionReference } from "./realtime/LiveCollection";
50
52
  export { AdminLiveDocumentReference } from "./realtime/LiveDocument";
51
53
  export { FlareAdminWsConnection } from "./realtime/WsConnection";
54
+ import { FlareAdminStorageS3 } from "./lib/storage";
52
55
  import { FlareAdminConnection } from "./realtime/Connection";
53
- import { FlareAdminAuth, FlareAdminConfig, FlareAdminDb, FlareAdminNotifications } from "./types";
56
+ import { AdminCopyObjectInput, AdminDeleteObjectsInput, AdminDownloadObjectInput, AdminDownloadObjectResult, AdminGetObjectInput, AdminGetObjectResult, AdminGetObjectUrlInput, AdminHeadObjectInput, AdminHeadObjectsInput, AdminListObjectsInput, AdminListObjectsResult, AdminPutObjectInput, AdminPutObjectResult, AdminStorageBucket, AdminStorageBucketInput, AdminStorageObjectMeta, AdminStorageSignedUrlInput, AdminStorageSignedUrlResult, FlareAdminAuth, FlareAdminConfig, FlareAdminDb, FlareAdminNotifications } from "./types";
54
57
  /**
55
58
  * A FlareAdmin application instance.
56
59
  * Create one with `connectApp()` and keep it as a module-level singleton.
@@ -61,6 +64,8 @@ export declare class FlareAdminApp {
61
64
  private _db?;
62
65
  private _conn?;
63
66
  private _notifications?;
67
+ private _storage?;
68
+ private _storageS3?;
64
69
  /**
65
70
  * Access the auth service.
66
71
  *
@@ -118,6 +123,54 @@ export declare class FlareAdminApp {
118
123
  * Access push notification management APIs.
119
124
  */
120
125
  notifications(): FlareAdminNotifications;
126
+ private storageService;
127
+ storage(): FlareAdminStorageS3;
128
+ /**
129
+ * S3-compatible storage service. Works with bucket names; no server IDs needed.
130
+ * Bucket is auto-created on putObject() if it doesn't exist.
131
+ *
132
+ * @example
133
+ * await admin.s3().putObject({ bucket: 'avatars', key: 'alice.png', body: buffer });
134
+ * const { contentBase64 } = await admin.s3().getObject({ bucket: 'avatars', key: 'alice.png' });
135
+ */
136
+ s3(): FlareAdminStorageS3;
137
+ createSignedUrl(input: AdminStorageSignedUrlInput): Promise<AdminStorageSignedUrlResult>;
138
+ createBucket(name: string, options?: AdminStorageBucketInput): Promise<AdminStorageBucket>;
139
+ listBuckets(): Promise<AdminStorageBucket[]>;
140
+ deleteBucket(name: string): Promise<{
141
+ ok: boolean;
142
+ removedObjects: number;
143
+ }>;
144
+ deleteBuckets(names: string[]): Promise<{
145
+ ok: boolean;
146
+ deleted: string[];
147
+ errors: Record<string, string>;
148
+ }>;
149
+ getBucketLocation(name: string): Promise<{
150
+ bucket: string;
151
+ kind: string;
152
+ region?: string;
153
+ endpoint?: string;
154
+ }>;
155
+ putObject(input: AdminPutObjectInput): Promise<AdminPutObjectResult>;
156
+ getObject(input: AdminGetObjectInput): Promise<AdminGetObjectResult>;
157
+ getObjectUrl(input: AdminGetObjectUrlInput): Promise<string>;
158
+ downloadObject(input: AdminDownloadObjectInput): Promise<AdminDownloadObjectResult>;
159
+ headObject(input: AdminHeadObjectInput): Promise<AdminStorageObjectMeta>;
160
+ headObjects(input: AdminHeadObjectsInput): Promise<AdminStorageObjectMeta[]>;
161
+ listObjects(input: AdminListObjectsInput): Promise<AdminListObjectsResult>;
162
+ copyObject(input: AdminCopyObjectInput): Promise<{
163
+ ok: boolean;
164
+ }>;
165
+ copyObjects(inputs: AdminCopyObjectInput[]): Promise<{
166
+ ok: boolean;
167
+ errors: Record<string, string>;
168
+ }>;
169
+ deleteObjects(input: AdminDeleteObjectsInput): Promise<{
170
+ ok: boolean;
171
+ deleted: string[];
172
+ errors: Record<string, string>;
173
+ }>;
121
174
  }
122
175
  /**
123
176
  * Initialize a FlareAdmin app instance.
@@ -173,3 +226,5 @@ export declare function connection(name?: string): FlareAdminConnection;
173
226
  * Equivalent to `getApp().notifications()`.
174
227
  */
175
228
  export declare function notifications(name?: string): FlareAdminNotifications;
229
+ export declare function storage(name?: string): FlareAdminStorageS3;
230
+ export * from "./serverTimestamp";