@edgedev/firebase 1.6.0 → 1.6.2
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 +13 -6
- package/edgeFirebase.ts +19 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -30,7 +30,9 @@ const config = {
|
|
|
30
30
|
projectId: "your-projectId",
|
|
31
31
|
storageBucket: "your-storageBucket",
|
|
32
32
|
messagingSenderId: "your-messagingSenderId",
|
|
33
|
-
appId: "your-appId"
|
|
33
|
+
appId: "your-appId",
|
|
34
|
+
emulatorAuth: "", // local emlulator port populated app will be started with auth emulator
|
|
35
|
+
emulatorFirestore: "", // local emlulator port populated app will be started with firestore emulator
|
|
34
36
|
};
|
|
35
37
|
const isPersistant = true // If "persistence" is true, login will be saved locally, they can close their browser and when they open they will be logged in automatically. If "persistence" is false login saved only for the session.
|
|
36
38
|
const edgeFirebase = new EdgeFirebase(config, isPersistant);
|
|
@@ -58,7 +60,9 @@ app.use(eFb, {
|
|
|
58
60
|
projectId: "your-projectId",
|
|
59
61
|
storageBucket: "your-storageBucket",
|
|
60
62
|
messagingSenderId: "your-messagingSenderId",
|
|
61
|
-
appId: "your-appId"
|
|
63
|
+
appId: "your-appId",
|
|
64
|
+
emulatorAuth: "", // local emlulator port populated app will be started with auth emulator
|
|
65
|
+
emulatorFirestore: "", // local emlulator port populated app will be started with firestore emulator
|
|
62
66
|
}, isPersistant)
|
|
63
67
|
//end edgeFirebase
|
|
64
68
|
|
|
@@ -79,7 +83,9 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|
|
79
83
|
projectId: "your-projectId",
|
|
80
84
|
storageBucket: "your-storageBucket",
|
|
81
85
|
messagingSenderId: "your-messagingSenderId",
|
|
82
|
-
appId: "your-appId"
|
|
86
|
+
appId: "your-appId",
|
|
87
|
+
emulatorAuth: "", // local emlulator port populated app will be started with auth emulator
|
|
88
|
+
emulatorFirestore: "", // local emlulator port populated app will be started with firestore emulator
|
|
83
89
|
}, isPersistant);
|
|
84
90
|
});
|
|
85
91
|
```
|
|
@@ -582,12 +588,12 @@ staticSearch.getData("myItems", query, sort, limit);
|
|
|
582
588
|
```
|
|
583
589
|
|
|
584
590
|
|
|
585
|
-
#
|
|
591
|
+
# Responses
|
|
586
592
|
|
|
587
|
-
|
|
593
|
+
Most functions will return a response that can be used.
|
|
588
594
|
|
|
589
595
|
```javascript
|
|
590
|
-
const response =
|
|
596
|
+
const response = edgeFirebase.startSnapshot("things");
|
|
591
597
|
```
|
|
592
598
|
|
|
593
599
|
reponse:
|
|
@@ -596,6 +602,7 @@ reponse:
|
|
|
596
602
|
interface actionResponse {
|
|
597
603
|
success: boolean;
|
|
598
604
|
message: string;
|
|
605
|
+
meta: {}
|
|
599
606
|
}
|
|
600
607
|
```
|
|
601
608
|
|
package/edgeFirebase.ts
CHANGED
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
deleteField,
|
|
25
25
|
arrayRemove,
|
|
26
26
|
arrayUnion,
|
|
27
|
+
connectFirestoreEmulator,
|
|
27
28
|
} from "firebase/firestore";
|
|
28
29
|
|
|
29
30
|
import {
|
|
@@ -39,7 +40,8 @@ import {
|
|
|
39
40
|
reauthenticateWithCredential,
|
|
40
41
|
EmailAuthProvider,
|
|
41
42
|
sendPasswordResetEmail,
|
|
42
|
-
confirmPasswordReset
|
|
43
|
+
confirmPasswordReset,
|
|
44
|
+
connectAuthEmulator,
|
|
43
45
|
} from "firebase/auth";
|
|
44
46
|
|
|
45
47
|
interface FirestoreQuery {
|
|
@@ -102,19 +104,7 @@ interface newUser {
|
|
|
102
104
|
meta: object;
|
|
103
105
|
}
|
|
104
106
|
|
|
105
|
-
interface user {
|
|
106
|
-
email: string;
|
|
107
|
-
roles: role[];
|
|
108
|
-
specialPermissions: specialPermission[];
|
|
109
|
-
userId: string;
|
|
110
|
-
docId: string;
|
|
111
|
-
uid: string;
|
|
112
|
-
last_updated: Date;
|
|
113
|
-
}
|
|
114
107
|
|
|
115
|
-
interface usersByEmail {
|
|
116
|
-
[email: string]: [user];
|
|
117
|
-
}
|
|
118
108
|
interface userMeta extends newUser {
|
|
119
109
|
docId: string;
|
|
120
110
|
userId: string;
|
|
@@ -143,6 +133,8 @@ interface firebaseConfig {
|
|
|
143
133
|
storageBucket: string;
|
|
144
134
|
messagingSenderId: string;
|
|
145
135
|
appId: string;
|
|
136
|
+
emulatorAuth?: string;
|
|
137
|
+
emulatorFirestore?: string;
|
|
146
138
|
}
|
|
147
139
|
|
|
148
140
|
interface actionResponse {
|
|
@@ -164,7 +156,9 @@ export const EdgeFirebase = class {
|
|
|
164
156
|
projectId: "",
|
|
165
157
|
storageBucket: "",
|
|
166
158
|
messagingSenderId: "",
|
|
167
|
-
appId: ""
|
|
159
|
+
appId: "",
|
|
160
|
+
emulatorAuth: "",
|
|
161
|
+
emulatorFirestore: ""
|
|
168
162
|
},
|
|
169
163
|
isPersistant: false
|
|
170
164
|
) {
|
|
@@ -174,8 +168,17 @@ export const EdgeFirebase = class {
|
|
|
174
168
|
if (isPersistant) {
|
|
175
169
|
persistence = browserLocalPersistence;
|
|
176
170
|
}
|
|
171
|
+
|
|
177
172
|
this.auth = initializeAuth(this.app, { persistence });
|
|
173
|
+
if (this.firebaseConfig.emulatorAuth) {
|
|
174
|
+
connectAuthEmulator(this.auth, `http://localhost:${this.firebaseConfig.emulatorAuth}`)
|
|
175
|
+
}
|
|
176
|
+
|
|
178
177
|
this.db = getFirestore(this.app);
|
|
178
|
+
if (this.firebaseConfig.emulatorFirestore) {
|
|
179
|
+
connectFirestoreEmulator(this.db, "localhost", this.firebaseConfig.emulatorFirestore)
|
|
180
|
+
}
|
|
181
|
+
|
|
179
182
|
this.setOnAuthStateChanged();
|
|
180
183
|
}
|
|
181
184
|
|
|
@@ -318,6 +321,8 @@ export const EdgeFirebase = class {
|
|
|
318
321
|
this.unsubscibe['collection-data'] = unsubscribe
|
|
319
322
|
}
|
|
320
323
|
|
|
324
|
+
|
|
325
|
+
|
|
321
326
|
private startUserMetaSync = async (): Promise<void> => {
|
|
322
327
|
await this.startCollectionPermissionsSync()
|
|
323
328
|
await this.initUserMetaPermissions();
|
|
@@ -1084,8 +1089,6 @@ export const EdgeFirebase = class {
|
|
|
1084
1089
|
|
|
1085
1090
|
public startUsersSnapshot = (collectionPath = ''): void => {
|
|
1086
1091
|
this.stopSnapshot('users')
|
|
1087
|
-
// TODO: need to build users object appropriately and only show roles
|
|
1088
|
-
// and special permmisions for collectionPaths the user has assign access for
|
|
1089
1092
|
this.state.users = {};
|
|
1090
1093
|
if (collectionPath) {
|
|
1091
1094
|
if (this.permissionCheck('assign', collectionPath)) {
|