@edgedev/firebase 1.5.13 → 1.6.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/README.md +11 -11
- package/edgeFirebase.ts +183 -228
- package/package.json +1 -1
- package/pnpm-lock.yaml +2317 -0
package/README.md
CHANGED
|
@@ -153,17 +153,19 @@ After someoene has been added as a user they will need to "self register" to beg
|
|
|
153
153
|
|
|
154
154
|
### Collection permissions by role
|
|
155
155
|
|
|
156
|
-
|
|
156
|
+
Roles define what permissions the user willl have. The system will use collection-data/-default- to lookup the permissions for an assigned role. The default permissions can be changed or you can define role permissions based on specific collection paths. If a specific collection path is not found when looking up a user's role permissions
|
|
157
157
|
|
|
158
158
|
- **admin:** assign: true, write: true, read: true, delete: true
|
|
159
|
-
- **
|
|
159
|
+
- **editor**: assign: false, write: true, read: true, delete: true
|
|
160
|
+
- **writer**: assign: false, write: true, read: true, delete: false
|
|
161
|
+
- **user:** assign: false, write:false, read: true, delete: false
|
|
160
162
|
|
|
161
163
|
How to change role permissions for a specific collection:
|
|
162
164
|
|
|
163
165
|
```javascript
|
|
164
166
|
edgeFirebase.storeCollectionPermissions(
|
|
165
167
|
"myItems/subitems/things", // Collection path
|
|
166
|
-
"user", // must be
|
|
168
|
+
"user", // must be admin, editor, writer, user
|
|
167
169
|
{
|
|
168
170
|
assign: false,
|
|
169
171
|
write: false,
|
|
@@ -207,7 +209,7 @@ Remove a role from a user for a collection:
|
|
|
207
209
|
|
|
208
210
|
### Root permissions and first user
|
|
209
211
|
|
|
210
|
-
You can assign a user access to all collections in the entire project by giving them a role on "-", which is used to define the root collection path. This would be for someone who is acting like a super admin. If this is your first user, you will need to manually set them up in the Firstore console. Once a root user is added manually you can use this user to add other "root users" or setup other collections and assign roles to them.
|
|
212
|
+
You can assign a user access to all collections in the entire project by giving them a role on "-", which is used to define the root collection path. This would be for someone who is acting like a super admin. If this is your first user, you will need to manually set them up in the Firstore console. Once a root user is added manually you can use this user to add other "root users" or setup other collections and assign roles to them. The first time you login with your root user the collection-data/-default- role permissions document (mentioned above) will be automatically created.
|
|
211
213
|
|
|
212
214
|
|  |  |
|
|
213
215
|
| ------------------------------------------------------------ | ------------------------------------ |
|
|
@@ -254,7 +256,7 @@ edgeFirebase.removeUser("user@edgemarketingdesign.com");
|
|
|
254
256
|
|
|
255
257
|
### Users Snapshot Data
|
|
256
258
|
|
|
257
|
-
This will create a reactive object (users) that contains the members of the collection
|
|
259
|
+
This will create a reactive object (state.users) that contains the members of the collection passed to the snapshot if the user running the function has assign access for, it will be a listed index by email/user id.
|
|
258
260
|
|
|
259
261
|
```javascript
|
|
260
262
|
edgeFirebase.startUsersSnapshot("myItems");
|
|
@@ -264,12 +266,11 @@ edgeFirebase.stopUsersSnapshot();
|
|
|
264
266
|
|
|
265
267
|
```vue
|
|
266
268
|
<script setup>
|
|
267
|
-
|
|
268
|
-
console.log(edgeFirebase.users.value);
|
|
269
|
+
console.log(edgeFirebase.state.users);
|
|
269
270
|
</script>
|
|
270
271
|
<template>
|
|
271
272
|
<div>
|
|
272
|
-
<div v-for="user in edgeFirebase.users
|
|
273
|
+
<div v-for="user in edgeFirebase.state.users" :key="item">
|
|
273
274
|
{{ user.email }}
|
|
274
275
|
</div>
|
|
275
276
|
</div>
|
|
@@ -297,7 +298,7 @@ interface user {
|
|
|
297
298
|
```typescript
|
|
298
299
|
interface role {
|
|
299
300
|
collectionPath: "-" | string; // - is root
|
|
300
|
-
role: "admin" | "user";
|
|
301
|
+
role: "admin" | "editor" | "writer" | "user";
|
|
301
302
|
}
|
|
302
303
|
```
|
|
303
304
|
|
|
@@ -342,13 +343,12 @@ interface UserDataObject {
|
|
|
342
343
|
meta: object;
|
|
343
344
|
roles: role[]; //see role below
|
|
344
345
|
specialPermissions: specialPermission[]; //see specialPermission below
|
|
345
|
-
canAssignCollectionPaths: string[]; //an array of collectionPaths that the user has "assign" access to
|
|
346
346
|
}
|
|
347
347
|
|
|
348
348
|
// sub types of UserDataObject:
|
|
349
349
|
interface role {
|
|
350
350
|
collectionPath: "-" | string; // - is root
|
|
351
|
-
role: "admin" | "user";
|
|
351
|
+
role: "admin" | "editor" | "writer" | "user";
|
|
352
352
|
}
|
|
353
353
|
|
|
354
354
|
interface specialPermission {
|