@relking-elements/vue-firebase 0.1.0
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/LICENSE +21 -0
- package/README.md +118 -0
- package/dist/index.cjs +1096 -0
- package/dist/index.d.cts +605 -0
- package/dist/index.d.mts +605 -0
- package/dist/index.d.ts +605 -0
- package/dist/index.mjs +1060 -0
- package/package.json +85 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,605 @@
|
|
|
1
|
+
import { FirebaseApp } from 'firebase/app';
|
|
2
|
+
import * as vue from 'vue';
|
|
3
|
+
import { Ref, ShallowRef, MaybeRefOrGetter, App } from 'vue';
|
|
4
|
+
import * as firebase_database from 'firebase/database';
|
|
5
|
+
import { DataSnapshot, DatabaseReference, Query } from 'firebase/database';
|
|
6
|
+
import * as firebase_firestore from 'firebase/firestore';
|
|
7
|
+
import { FirestoreDataConverter, SnapshotOptions, SnapshotListenOptions, DocumentData, FirestoreError, CollectionReference, Query as Query$1, DocumentReference } from 'firebase/firestore';
|
|
8
|
+
import * as firebase_auth from 'firebase/auth';
|
|
9
|
+
import { User, Dependencies, Auth } from 'firebase/auth';
|
|
10
|
+
import { AppCheckOptions, AppCheck } from 'firebase/app-check';
|
|
11
|
+
import * as firebase_storage from 'firebase/storage';
|
|
12
|
+
import { StorageReference, FullMetadata, SettableMetadata, UploadTaskSnapshot, UploadTask, StorageError, UploadMetadata } from 'firebase/storage';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Allow resetting a subscription vue ref when the source changes or is removed. `false` keeps the value as is while
|
|
16
|
+
* true resets it to `null` for objects and `[]` for arrays. A function allows to specify a custom reset value.
|
|
17
|
+
*/
|
|
18
|
+
type ResetOption = boolean | (() => unknown);
|
|
19
|
+
/**
|
|
20
|
+
* Flattens out a type.
|
|
21
|
+
*
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
type _Simplify<T> = {
|
|
25
|
+
[KeyType in keyof T]: T[KeyType];
|
|
26
|
+
} & {};
|
|
27
|
+
/**
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
30
|
+
type _Nullable<T> = T | null | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* @internal
|
|
33
|
+
*/
|
|
34
|
+
interface _RefWithState<T, E = Error> extends Ref<T> {
|
|
35
|
+
/**
|
|
36
|
+
* Realtime data wrapped in a Vue `ref`
|
|
37
|
+
*/
|
|
38
|
+
get data(): Ref<T>;
|
|
39
|
+
/**
|
|
40
|
+
* Reactive Error if the firebase operation fails
|
|
41
|
+
*/
|
|
42
|
+
get error(): Ref<E | undefined>;
|
|
43
|
+
/**
|
|
44
|
+
* Reactive loading state
|
|
45
|
+
*/
|
|
46
|
+
get pending(): Ref<boolean>;
|
|
47
|
+
/**
|
|
48
|
+
* Reactive promise that resolves when the data is loaded or rejects if there is an error
|
|
49
|
+
*/
|
|
50
|
+
get promise(): ShallowRef<Promise<T>>;
|
|
51
|
+
/**
|
|
52
|
+
* Stops listening to the data changes and stops the Vue watcher.
|
|
53
|
+
*/
|
|
54
|
+
stop: (reset?: ResetOption) => void;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Base options for the data source options in both Firestore and Realtime Database.
|
|
58
|
+
*
|
|
59
|
+
* @internal
|
|
60
|
+
*/
|
|
61
|
+
interface _DataSourceOptions<DataT = unknown> {
|
|
62
|
+
/**
|
|
63
|
+
* Use the `target` ref instead of creating one.
|
|
64
|
+
*/
|
|
65
|
+
target?: Ref<DataT>;
|
|
66
|
+
/**
|
|
67
|
+
* If true, the data will be reset when the data source is unbound. Pass a function to specify a custom reset value.
|
|
68
|
+
*/
|
|
69
|
+
reset?: ResetOption;
|
|
70
|
+
/**
|
|
71
|
+
* If true, wait until the data is loaded before setting the data for the first time. For Firestore, this includes
|
|
72
|
+
* nested refs. This is only useful for lists and collections. Objects and documents do not need this.
|
|
73
|
+
*/
|
|
74
|
+
wait?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Should the data be fetched once rather than subscribing to changes.
|
|
77
|
+
*/
|
|
78
|
+
once?: boolean;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Convert firebase Database snapshot of a ref **that exists** into a bindable data record.
|
|
83
|
+
*
|
|
84
|
+
* @param snapshot
|
|
85
|
+
* @return
|
|
86
|
+
*/
|
|
87
|
+
declare function createRecordFromDatabaseSnapshot(snapshot: DataSnapshot): VueDatabaseDocumentData<unknown>;
|
|
88
|
+
interface DatabaseSnapshotSerializer<T = unknown> {
|
|
89
|
+
(snapshot: DataSnapshot): VueDatabaseDocumentData<T>;
|
|
90
|
+
}
|
|
91
|
+
interface _RefDatabase<T> extends _RefWithState<T, Error> {
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Type used by default by the `serialize` option.
|
|
95
|
+
*/
|
|
96
|
+
type VueDatabaseDocumentData<T = unknown> = null | (T & {
|
|
97
|
+
/**
|
|
98
|
+
* id of the document
|
|
99
|
+
*/
|
|
100
|
+
readonly id: string;
|
|
101
|
+
});
|
|
102
|
+
/**
|
|
103
|
+
* Same as VueDatabaseDocumentData but for a query.
|
|
104
|
+
*/
|
|
105
|
+
type VueDatabaseQueryData<T = unknown> = Array<_Simplify<NonNullable<VueDatabaseDocumentData<T>>>>;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Global option type when binding one database reference
|
|
109
|
+
* @internal
|
|
110
|
+
*/
|
|
111
|
+
interface _DatabaseRefOptions<DataT = unknown> extends _DataSourceOptions<DataT> {
|
|
112
|
+
/**
|
|
113
|
+
* Function to transform snapshots into data. **Make sure to reuse the original serializer to add the object `id`**.
|
|
114
|
+
* See https://vuefire.vuejs.org/guide/global-options.html
|
|
115
|
+
*/
|
|
116
|
+
serialize?: DatabaseSnapshotSerializer;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Global defaults type override options for all database bindings. This type remove make some optional values required.
|
|
120
|
+
* @internal
|
|
121
|
+
*/
|
|
122
|
+
interface _DatabaseRefOptionsWithDefaults extends _DatabaseRefOptions<unknown> {
|
|
123
|
+
/**
|
|
124
|
+
* @defaultValue `false`
|
|
125
|
+
*/
|
|
126
|
+
reset: ResetOption;
|
|
127
|
+
/**
|
|
128
|
+
* @defaultValue `true`
|
|
129
|
+
*/
|
|
130
|
+
wait: boolean;
|
|
131
|
+
serialize: DatabaseSnapshotSerializer;
|
|
132
|
+
}
|
|
133
|
+
declare const DEFAULT_OPTIONS$1: _DatabaseRefOptionsWithDefaults;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Options when calling `useDatabaseList()` and `useDatabaseObject()`.
|
|
137
|
+
*/
|
|
138
|
+
interface UseDatabaseRefOptions<DataT = unknown> extends _DatabaseRefOptions<DataT> {
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
type UseListOptions<DataT = unknown> = UseDatabaseRefOptions<DataT>;
|
|
142
|
+
/**
|
|
143
|
+
* Creates a reactive variable connected to the database as an array. Each element in the array will contain an `id`
|
|
144
|
+
* property. Note that if you override the `serialize` option, it should **also set an `id` property** in order for this
|
|
145
|
+
* to work.
|
|
146
|
+
*
|
|
147
|
+
* @param reference - Reference or query to the database
|
|
148
|
+
* @param options - optional options
|
|
149
|
+
*/
|
|
150
|
+
declare function useDatabaseList<T = unknown>(reference: MaybeRefOrGetter<_Nullable<DatabaseReference | Query>>, options?: UseListOptions<T>): _RefDatabase<VueDatabaseQueryData<T>>;
|
|
151
|
+
/**
|
|
152
|
+
* @deprecated use `useDatabaseList()` instead
|
|
153
|
+
*/
|
|
154
|
+
declare const useList: typeof useDatabaseList;
|
|
155
|
+
type UseObjectOptions<DataT = unknown> = UseDatabaseRefOptions<DataT>;
|
|
156
|
+
/**
|
|
157
|
+
* Creates a reactive variable connected to the database as an object. If the reference is a primitive, it will be
|
|
158
|
+
* converted to an object containing a `$value` property with the primitive value and an `id` property with the
|
|
159
|
+
* reference's key.
|
|
160
|
+
*
|
|
161
|
+
* @param reference - Reference or query to the database
|
|
162
|
+
* @param options - optional options
|
|
163
|
+
*/
|
|
164
|
+
declare function useDatabaseObject<T = unknown>(reference: MaybeRefOrGetter<_Nullable<DatabaseReference>>, options?: UseObjectOptions<T>): _RefDatabase<VueDatabaseDocumentData<T> | undefined>;
|
|
165
|
+
/**
|
|
166
|
+
* @deprecated use `useDatabaseObject()` instead
|
|
167
|
+
*/
|
|
168
|
+
declare const useObject: typeof useDatabaseObject;
|
|
169
|
+
/**
|
|
170
|
+
* Retrieves the Database instance.
|
|
171
|
+
*
|
|
172
|
+
* @param name - name of the application
|
|
173
|
+
* @param databaseUrl - URL for a named Realtime Database instance
|
|
174
|
+
* @returns the Database instance
|
|
175
|
+
*/
|
|
176
|
+
declare function useDatabase(name?: string, databaseUrl?: string): firebase_database.Database;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Options when binding a Firestore document or collection.
|
|
180
|
+
*/
|
|
181
|
+
interface FirestoreRefOptions<TData = unknown> extends _DataSourceOptions<TData> {
|
|
182
|
+
/**
|
|
183
|
+
* The maximum depth to bind nested refs. A nested ref that isn't bound will stay as the ref path while a bound ref
|
|
184
|
+
* will contain the same data as if the ref was bound directly.
|
|
185
|
+
*/
|
|
186
|
+
maxRefDepth?: number;
|
|
187
|
+
/**
|
|
188
|
+
* @inheritDoc {SnapshotOptions}
|
|
189
|
+
*/
|
|
190
|
+
snapshotOptions?: SnapshotOptions;
|
|
191
|
+
/**
|
|
192
|
+
* @inheritDoc {SnapshotListenOptions}
|
|
193
|
+
*/
|
|
194
|
+
snapshotListenOptions?: SnapshotListenOptions;
|
|
195
|
+
/**
|
|
196
|
+
* Default Firestore converter to use with snapshots.
|
|
197
|
+
*/
|
|
198
|
+
converter?: FirestoreDataConverter<unknown>;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Type of the global options for firestore refs. Some values cannot be `undefined`.
|
|
202
|
+
* @internal
|
|
203
|
+
*/
|
|
204
|
+
interface _FirestoreRefOptionsWithDefaults extends FirestoreRefOptions {
|
|
205
|
+
/**
|
|
206
|
+
* @defaultValue `false`
|
|
207
|
+
*/
|
|
208
|
+
reset: ResetOption;
|
|
209
|
+
/**
|
|
210
|
+
* @defaultValue `true`
|
|
211
|
+
*/
|
|
212
|
+
wait: boolean;
|
|
213
|
+
/**
|
|
214
|
+
* @defaultValue `2`
|
|
215
|
+
*/
|
|
216
|
+
maxRefDepth: number;
|
|
217
|
+
/**
|
|
218
|
+
* Default Firestore converter to use with snapshots. Make sure to reuse the original serializer to add the object id.
|
|
219
|
+
* See https://vuefire.vuejs.org/guide/global-options.html
|
|
220
|
+
*/
|
|
221
|
+
converter: FirestoreDataConverter<unknown>;
|
|
222
|
+
/**
|
|
223
|
+
* @defaultValue `{ serverTimestamps: 'estimate' }` to avoid `null` values
|
|
224
|
+
*/
|
|
225
|
+
snapshotOptions: SnapshotOptions;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Global default options
|
|
229
|
+
*/
|
|
230
|
+
declare const DEFAULT_OPTIONS: _FirestoreRefOptionsWithDefaults;
|
|
231
|
+
|
|
232
|
+
interface _UseFirestoreRefOptions<TData = unknown> extends FirestoreRefOptions<TData> {
|
|
233
|
+
/**
|
|
234
|
+
* @deprecated: use `.withConverter()` instead
|
|
235
|
+
*/
|
|
236
|
+
converter?: FirestoreDataConverter<unknown>;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Infers the type from a firestore reference. If it is not a reference, it returns the type as is.
|
|
240
|
+
*
|
|
241
|
+
* @internal
|
|
242
|
+
*/
|
|
243
|
+
type _InferReferenceType<R> = R extends CollectionReference<infer T> | Query$1<infer T> | DocumentReference<infer T> ? T : R;
|
|
244
|
+
/**
|
|
245
|
+
* Type used by default by the `firestoreDefaultConverter`.
|
|
246
|
+
*/
|
|
247
|
+
type VueFirestoreDocumentData<T = DocumentData> = null | (T & {
|
|
248
|
+
/**
|
|
249
|
+
* id of the document
|
|
250
|
+
*/
|
|
251
|
+
readonly id: string;
|
|
252
|
+
});
|
|
253
|
+
type VueFirestoreQueryData<T = DocumentData> = Array<_Simplify<NonNullable<VueFirestoreDocumentData<T>>>>;
|
|
254
|
+
/**
|
|
255
|
+
* @internal
|
|
256
|
+
*/
|
|
257
|
+
interface _RefFirestore<T> extends _RefWithState<T, FirestoreError> {
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
interface UseCollectionOptions<TData = unknown> extends _UseFirestoreRefOptions<TData> {
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Creates a reactive collection (usually an array) of documents from a collection ref or a query from Firestore. Extracts the type of the
|
|
265
|
+
* query or converter.
|
|
266
|
+
*
|
|
267
|
+
* @param collectionRef - query or collection
|
|
268
|
+
* @param options - optional options
|
|
269
|
+
*/
|
|
270
|
+
declare function useCollection<R extends CollectionReference<unknown> | Query$1<unknown>>(collectionRef: MaybeRefOrGetter<_Nullable<R>>, options?: UseCollectionOptions<_InferReferenceType<R>[]>): _RefFirestore<_InferReferenceType<R>[]>;
|
|
271
|
+
/**
|
|
272
|
+
* Creates a reactive collection (usually an array) of documents from a collection ref or a query from Firestore.
|
|
273
|
+
* Accepts a generic to **enforce the type** of the returned Ref. Note you can (and probably should) use
|
|
274
|
+
* `.withConverter()` to have stricter type safe version of a collection reference.
|
|
275
|
+
*
|
|
276
|
+
* @param collectionRef - query or collection
|
|
277
|
+
* @param options - optional options
|
|
278
|
+
*/
|
|
279
|
+
declare function useCollection<T>(collectionRef: MaybeRefOrGetter<_Nullable<CollectionReference<unknown> | Query$1<unknown>>>, options?: UseCollectionOptions<T[]>): _RefFirestore<VueFirestoreQueryData<T>>;
|
|
280
|
+
interface UseDocumentOptions<TData = unknown> extends _UseFirestoreRefOptions<TData> {
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Creates a reactive document from a document ref from Firestore. Automatically extracts the type of the converter or
|
|
284
|
+
* the document.
|
|
285
|
+
*
|
|
286
|
+
* @param documentRef - document reference
|
|
287
|
+
* @param options - optional options
|
|
288
|
+
*/
|
|
289
|
+
declare function useDocument<R extends DocumentReference<unknown>>(documentRef: MaybeRefOrGetter<_Nullable<R>>, options?: UseDocumentOptions<_InferReferenceType<R>>): _RefFirestore<_InferReferenceType<R> | undefined>;
|
|
290
|
+
/**
|
|
291
|
+
* Creates a reactive collection (usually an array) of documents from a collection ref or a query from Firestore.
|
|
292
|
+
* Accepts a generic to **enforce the type** of the returned Ref. Note you can (and probably should) use
|
|
293
|
+
* `.withConverter()` to have stricter type safe version of a collection reference.
|
|
294
|
+
*
|
|
295
|
+
* @param documentRef - query or collection
|
|
296
|
+
* @param options - optional options
|
|
297
|
+
*/
|
|
298
|
+
declare function useDocument<T>(documentRef: MaybeRefOrGetter<_Nullable<DocumentReference>>, options?: UseDocumentOptions<T>): _RefFirestore<VueFirestoreDocumentData<T> | undefined>;
|
|
299
|
+
/**
|
|
300
|
+
* Retrieves the Firestore instance.
|
|
301
|
+
*
|
|
302
|
+
* @param name - name of the application
|
|
303
|
+
* @param databaseId - database ID for named Firestore databases
|
|
304
|
+
* @returns the Firestore instance
|
|
305
|
+
*/
|
|
306
|
+
declare function useFirestore(name?: string, databaseId?: string): firebase_firestore.Firestore;
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Default converter for Firestore data. Can be overridden globally by setting `globalFirestoreOptions.converter`.
|
|
310
|
+
*/
|
|
311
|
+
declare const firestoreDefaultConverter: FirestoreDataConverter<VueFirestoreDocumentData>;
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Gets the firebase app instance.
|
|
315
|
+
*
|
|
316
|
+
* @param name - optional firebase app name
|
|
317
|
+
* @returns the firebase app
|
|
318
|
+
*/
|
|
319
|
+
declare function useFirebaseApp(name?: string): FirebaseApp;
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Returns a reactive variable of the currently authenticated user in the firebase app. The ref is null if no user is
|
|
323
|
+
* authenticated or when the user logs out. The ref is undefined until the user is initially loaded.
|
|
324
|
+
* @param name - name of the application
|
|
325
|
+
*/
|
|
326
|
+
declare function useCurrentUser(name?: string): Ref<_Nullable<User>, _Nullable<User>>;
|
|
327
|
+
/**
|
|
328
|
+
* Helper that returns a computed boolean that becomes `true` as soon as the current user is no longer `undefined`. Note
|
|
329
|
+
* this doesn't ensure the user is logged in, only if the initial signing process has run.
|
|
330
|
+
*
|
|
331
|
+
* @param name - name of the application
|
|
332
|
+
*/
|
|
333
|
+
declare function useIsCurrentUserLoaded(name?: string): vue.ComputedRef<boolean>;
|
|
334
|
+
/**
|
|
335
|
+
* Updates the current user profile and updates the current user state. This function internally calls `updateProfile()`
|
|
336
|
+
* from 'firebase/auth' and then updates the current user state.
|
|
337
|
+
*
|
|
338
|
+
* @param profile - the new profile information
|
|
339
|
+
*/
|
|
340
|
+
declare function updateCurrentUserProfile(profile: {
|
|
341
|
+
displayName?: _Nullable<string>;
|
|
342
|
+
photoURL?: _Nullable<string>;
|
|
343
|
+
}): Promise<void>;
|
|
344
|
+
/**
|
|
345
|
+
* Returns a promise that resolves the current user once the user is loaded. Must be called after the firebase app is
|
|
346
|
+
* initialized.
|
|
347
|
+
* @param name - name of the firebase application
|
|
348
|
+
*/
|
|
349
|
+
declare function getCurrentUser(name?: string): Promise<_Nullable<User>>;
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Options for VueFire Auth module.
|
|
353
|
+
*/
|
|
354
|
+
interface VueFireAuthOptions {
|
|
355
|
+
/**
|
|
356
|
+
* Options to pass to `initializeAuth()`.
|
|
357
|
+
*/
|
|
358
|
+
dependencies: Dependencies;
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* VueFire Auth Module to be added to the `VueFire` Vue plugin options. This calls the `VueFireAuthWithDependencies()`
|
|
362
|
+
* with **all** the dependencies, increasing bundle size. Consider using `VueFireAuthWithDependencies()` instead to
|
|
363
|
+
* better control the bundle size.
|
|
364
|
+
*
|
|
365
|
+
* @see https://firebase.google.com/docs/auth/web/custom-dependencies
|
|
366
|
+
*
|
|
367
|
+
* @example
|
|
368
|
+
*
|
|
369
|
+
*```ts
|
|
370
|
+
*import { createApp } from 'vue'
|
|
371
|
+
*import { VueFire, VueFireAuth } from 'vuefire'
|
|
372
|
+
*
|
|
373
|
+
*const app = createApp(App)
|
|
374
|
+
*app.use(VueFire, {
|
|
375
|
+
* modules: [VueFireAuth()],
|
|
376
|
+
*})
|
|
377
|
+
*```
|
|
378
|
+
*
|
|
379
|
+
*/
|
|
380
|
+
declare function VueFireAuth(): VueFireModule;
|
|
381
|
+
/**
|
|
382
|
+
* Key to be used to inject the auth instance into components. It allows avoiding to call `getAuth()`, which isn't tree
|
|
383
|
+
* shakable.
|
|
384
|
+
* @internal
|
|
385
|
+
*/
|
|
386
|
+
declare const _VueFireAuthKey: unique symbol;
|
|
387
|
+
/**
|
|
388
|
+
* Options for VueFire Auth module when passing the auth instance directly.
|
|
389
|
+
*/
|
|
390
|
+
interface VueFireAuthOptionsFromAuth {
|
|
391
|
+
/**
|
|
392
|
+
* Auth instance to use.
|
|
393
|
+
*/
|
|
394
|
+
auth: Auth;
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* VueFire Auth Module to be added to the `VueFire` Vue plugin options. It accepts an auth instance rather than the
|
|
398
|
+
* dependencies. It allows manually calling emulators and other advanced use cases. Prefer using
|
|
399
|
+
* `VueFireAuthWithDependencies()` and `VueFireAuth()` for most use cases.
|
|
400
|
+
*
|
|
401
|
+
* @param options - auth instance and initial user
|
|
402
|
+
*/
|
|
403
|
+
declare function VueFireAuthOptionsFromAuth({ auth, }: VueFireAuthOptionsFromAuth): VueFireModule;
|
|
404
|
+
/**
|
|
405
|
+
* VueFire Auth Module to be added to the `VueFire` Vue plugin options. It accepts dependencies to pass to
|
|
406
|
+
* `initializeAuth()` to better control the bundle size.
|
|
407
|
+
*
|
|
408
|
+
* @param options - user and options to pass to `initializeAuth()`.
|
|
409
|
+
*/
|
|
410
|
+
declare function VueFireAuthWithDependencies({ dependencies, }: VueFireAuthOptions): VueFireModule;
|
|
411
|
+
/**
|
|
412
|
+
* Initializes auth.
|
|
413
|
+
* @internal
|
|
414
|
+
*/
|
|
415
|
+
declare function _VueFireAuthInit(firebaseApp: FirebaseApp, app: App, dependencies?: Dependencies, auth?: Auth): readonly [vue.Ref<{
|
|
416
|
+
readonly emailVerified: boolean;
|
|
417
|
+
readonly isAnonymous: boolean;
|
|
418
|
+
readonly metadata: {
|
|
419
|
+
readonly creationTime?: string | undefined;
|
|
420
|
+
readonly lastSignInTime?: string | undefined;
|
|
421
|
+
};
|
|
422
|
+
readonly providerData: {
|
|
423
|
+
readonly displayName: string | null;
|
|
424
|
+
readonly email: string | null;
|
|
425
|
+
readonly phoneNumber: string | null;
|
|
426
|
+
readonly photoURL: string | null;
|
|
427
|
+
readonly providerId: string;
|
|
428
|
+
readonly uid: string;
|
|
429
|
+
}[];
|
|
430
|
+
readonly refreshToken: string;
|
|
431
|
+
readonly tenantId: string | null;
|
|
432
|
+
delete: () => Promise<void>;
|
|
433
|
+
getIdToken: (forceRefresh?: boolean) => Promise<string>;
|
|
434
|
+
getIdTokenResult: (forceRefresh?: boolean) => Promise<firebase_auth.IdTokenResult>;
|
|
435
|
+
reload: () => Promise<void>;
|
|
436
|
+
toJSON: () => object;
|
|
437
|
+
readonly displayName: string | null;
|
|
438
|
+
readonly email: string | null;
|
|
439
|
+
readonly phoneNumber: string | null;
|
|
440
|
+
readonly photoURL: string | null;
|
|
441
|
+
readonly providerId: string;
|
|
442
|
+
readonly uid: string;
|
|
443
|
+
} | null | undefined, _Nullable<User> | {
|
|
444
|
+
readonly emailVerified: boolean;
|
|
445
|
+
readonly isAnonymous: boolean;
|
|
446
|
+
readonly metadata: {
|
|
447
|
+
readonly creationTime?: string | undefined;
|
|
448
|
+
readonly lastSignInTime?: string | undefined;
|
|
449
|
+
};
|
|
450
|
+
readonly providerData: {
|
|
451
|
+
readonly displayName: string | null;
|
|
452
|
+
readonly email: string | null;
|
|
453
|
+
readonly phoneNumber: string | null;
|
|
454
|
+
readonly photoURL: string | null;
|
|
455
|
+
readonly providerId: string;
|
|
456
|
+
readonly uid: string;
|
|
457
|
+
}[];
|
|
458
|
+
readonly refreshToken: string;
|
|
459
|
+
readonly tenantId: string | null;
|
|
460
|
+
delete: () => Promise<void>;
|
|
461
|
+
getIdToken: (forceRefresh?: boolean) => Promise<string>;
|
|
462
|
+
getIdTokenResult: (forceRefresh?: boolean) => Promise<firebase_auth.IdTokenResult>;
|
|
463
|
+
reload: () => Promise<void>;
|
|
464
|
+
toJSON: () => object;
|
|
465
|
+
readonly displayName: string | null;
|
|
466
|
+
readonly email: string | null;
|
|
467
|
+
readonly phoneNumber: string | null;
|
|
468
|
+
readonly photoURL: string | null;
|
|
469
|
+
readonly providerId: string;
|
|
470
|
+
readonly uid: string;
|
|
471
|
+
}>, Auth];
|
|
472
|
+
/**
|
|
473
|
+
* Retrieves the Firebase Auth instance. **Returns `null` on the server**. When using this function on the client in
|
|
474
|
+
* TypeScript, you can force the type with `useFirebaseAuth()!`.
|
|
475
|
+
*
|
|
476
|
+
* @returns the Auth instance
|
|
477
|
+
*/
|
|
478
|
+
declare function useFirebaseAuth(): Auth | null;
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* The current app-check token as a `Ref`. Note this ref is always undefined on the server.
|
|
482
|
+
*/
|
|
483
|
+
declare function useAppCheckToken(): Ref<string | undefined, string | undefined>;
|
|
484
|
+
interface VueFireAppCheckOptions extends AppCheckOptions {
|
|
485
|
+
/**
|
|
486
|
+
* Setups the debug token global. See https://firebase.google.com/docs/app-check/web/debug-provider. Note you should
|
|
487
|
+
* set to false in production (or not set it at all). It can be set to a string to force a specific debug token.
|
|
488
|
+
*/
|
|
489
|
+
debug?: boolean | string;
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* VueFire AppCheck Module to be added to the `VueFire` Vue plugin options. This module **is client only** and shouldn't be added on server.
|
|
493
|
+
*
|
|
494
|
+
* @example
|
|
495
|
+
*
|
|
496
|
+
* ```ts
|
|
497
|
+
* import { createApp } from 'vue'
|
|
498
|
+
* import { VueFire, VueFireAppCheck } from 'vuefire'
|
|
499
|
+
*
|
|
500
|
+
* const app = createApp(App)
|
|
501
|
+
* app.use(VueFire, {
|
|
502
|
+
* modules: [VueFireAppCheck()],
|
|
503
|
+
* })
|
|
504
|
+
* ```
|
|
505
|
+
*/
|
|
506
|
+
declare function VueFireAppCheck(options: VueFireAppCheckOptions): (firebaseApp: FirebaseApp, app: App) => void;
|
|
507
|
+
/**
|
|
508
|
+
* Retrieves the Firebase App Check instance.
|
|
509
|
+
*
|
|
510
|
+
* @param name - name of the application
|
|
511
|
+
*/
|
|
512
|
+
declare function useAppCheck(name?: string): AppCheck;
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* Retrieves the Storage instance.
|
|
516
|
+
*
|
|
517
|
+
* @param name - name of the application
|
|
518
|
+
* @returns the Database instance
|
|
519
|
+
*/
|
|
520
|
+
declare function useFirebaseStorage(name?: string): firebase_storage.FirebaseStorage;
|
|
521
|
+
/**
|
|
522
|
+
* Retrieves a reactive download URL of a `StorageReference`. Updates automatically if the `StorageReference` changes.
|
|
523
|
+
*
|
|
524
|
+
* @param storageRef - StorageReference
|
|
525
|
+
*/
|
|
526
|
+
declare function useStorageFileUrl(storageRef: MaybeRefOrGetter<_Nullable<StorageReference>>): {
|
|
527
|
+
url: vue.Ref<string | null | undefined, string | null | undefined>;
|
|
528
|
+
refresh: () => Promise<string | null>;
|
|
529
|
+
promise: vue.ShallowRef<Promise<string | null>, Promise<string | null>>;
|
|
530
|
+
};
|
|
531
|
+
/**
|
|
532
|
+
* Returns a reactive version of the metadata of a `StorageReference`. Updates automatically if the `StorageReference`
|
|
533
|
+
* changes.
|
|
534
|
+
*
|
|
535
|
+
* @param storageRef - StorageReference
|
|
536
|
+
*/
|
|
537
|
+
declare function useStorageFileMetadata(storageRef: MaybeRefOrGetter<_Nullable<StorageReference>>): {
|
|
538
|
+
metadata: vue.ShallowRef<FullMetadata | null | undefined, FullMetadata | null | undefined>;
|
|
539
|
+
update: (newMetadata: SettableMetadata) => Promise<FullMetadata | null>;
|
|
540
|
+
refresh: () => Promise<FullMetadata | null>;
|
|
541
|
+
promise: vue.ShallowRef<Promise<FullMetadata | null>, Promise<FullMetadata | null>>;
|
|
542
|
+
};
|
|
543
|
+
/**
|
|
544
|
+
* Reactive information (url, metadata) of a `StorageReference`. Allows updating and deleting the storage object.
|
|
545
|
+
*
|
|
546
|
+
* @param storageRef - StorageReference
|
|
547
|
+
*/
|
|
548
|
+
declare function useStorageFile(storageRef: MaybeRefOrGetter<_Nullable<StorageReference>>): {
|
|
549
|
+
url: vue.Ref<string | null | undefined, string | null | undefined>;
|
|
550
|
+
metadata: vue.ShallowRef<FullMetadata | null | undefined, FullMetadata | null | undefined>;
|
|
551
|
+
snapshot: vue.ShallowRef<UploadTaskSnapshot | null | undefined, UploadTaskSnapshot | null | undefined>;
|
|
552
|
+
uploadTask: vue.ShallowRef<UploadTask | null | undefined, UploadTask | null | undefined>;
|
|
553
|
+
uploadError: vue.ShallowRef<StorageError | null | undefined, StorageError | null | undefined>;
|
|
554
|
+
uploadProgress: vue.ComputedRef<number | null>;
|
|
555
|
+
upload: (newData: Blob | Uint8Array | ArrayBuffer, newMetadata?: UploadMetadata) => Promise<unknown> | undefined;
|
|
556
|
+
updateMetadata: (newMetadata: SettableMetadata) => Promise<FullMetadata | null>;
|
|
557
|
+
refresh: () => Promise<[string | null, FullMetadata | null]>;
|
|
558
|
+
};
|
|
559
|
+
/**
|
|
560
|
+
* @deprecated use `useFirebaseStorage()` instead
|
|
561
|
+
*/
|
|
562
|
+
declare const useStorage: typeof useFirebaseStorage;
|
|
563
|
+
/**
|
|
564
|
+
* @deprecated use `useStorageFileUrl()` instead
|
|
565
|
+
*/
|
|
566
|
+
declare const useStorageUrl: typeof useStorageFileUrl;
|
|
567
|
+
/**
|
|
568
|
+
* @deprecated use `useStorageFileMetadata()` instead
|
|
569
|
+
*/
|
|
570
|
+
declare const useStorageMetadata: typeof useStorageFileMetadata;
|
|
571
|
+
/**
|
|
572
|
+
* @deprecated use `useStorageFile()` instead
|
|
573
|
+
*/
|
|
574
|
+
declare const useStorageObject: typeof useStorageFile;
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* @module vuefire
|
|
578
|
+
*/
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* Options for VueFire Vue plugin.
|
|
582
|
+
*/
|
|
583
|
+
interface VueFireOptions {
|
|
584
|
+
/**
|
|
585
|
+
* The firebase app used by VueFire and associated with the different modules.
|
|
586
|
+
*/
|
|
587
|
+
firebaseApp: FirebaseApp;
|
|
588
|
+
/**
|
|
589
|
+
* Array of VueFire modules that should be added to the application. e.g. `[VueFireAuth, VueFireDatabase]`. Remember
|
|
590
|
+
* to import them from `vuefire`.
|
|
591
|
+
*/
|
|
592
|
+
modules?: VueFireModule[];
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* A VueFire module that can be passed to the VueFire Vue plugin in the `modules` option.
|
|
596
|
+
*/
|
|
597
|
+
interface VueFireModule {
|
|
598
|
+
(firebaseApp: FirebaseApp, app: App): void;
|
|
599
|
+
}
|
|
600
|
+
/**
|
|
601
|
+
* VueFire Vue plugin.
|
|
602
|
+
*/
|
|
603
|
+
declare function VueFire(app: App, { firebaseApp, modules }: VueFireOptions): void;
|
|
604
|
+
|
|
605
|
+
export { type DatabaseSnapshotSerializer, type UseCollectionOptions, type UseDatabaseRefOptions, type UseDocumentOptions, type UseListOptions, type UseObjectOptions, type VueDatabaseDocumentData, type VueDatabaseQueryData, VueFire, VueFireAppCheck, type VueFireAppCheckOptions, VueFireAuth, type VueFireAuthOptions, VueFireAuthOptionsFromAuth, VueFireAuthWithDependencies, type VueFireModule, type VueFireOptions, type VueFirestoreDocumentData, type VueFirestoreQueryData, type _RefDatabase, type _RefFirestore, _VueFireAuthInit, _VueFireAuthKey, createRecordFromDatabaseSnapshot as databaseDefaultSerializer, firestoreDefaultConverter, getCurrentUser, DEFAULT_OPTIONS$1 as globalDatabaseOptions, DEFAULT_OPTIONS as globalFirestoreOptions, updateCurrentUserProfile, useAppCheck, useAppCheckToken, useCollection, useCurrentUser, useDatabase, useDatabaseList, useDatabaseObject, useDocument, useFirebaseApp, useFirebaseAuth, useFirebaseStorage, useFirestore, useIsCurrentUserLoaded, useList, useObject, useStorage, useStorageFile, useStorageFileMetadata, useStorageFileUrl, useStorageMetadata, useStorageObject, useStorageUrl };
|