@edgedev/firebase 1.5.13 → 1.6.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 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
- Each collection (including sub collections) will automatically have permissions keyed by role. By default each collection and sub collection will receive the following permissions by role when created:
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
- - **user:** assign: false, write:false, read: false, delete: false
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 user or admin
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
  | ![root-collection-roles](./images/root-collection-roles.png) | ![root-user](./images/root-user.jpg) |
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 and subcollections passed to the snapshot that the user running the function has assign access for, it will be a listed index by email/user id. Passing no collection will get all users that the user running has assign access for.
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
- //users is a ref and needs to be accessed via "value"
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.value" :key="item">
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 {
@@ -582,12 +582,12 @@ staticSearch.getData("myItems", query, sort, limit);
582
582
  ```
583
583
 
584
584
 
585
- # Await and responses
585
+ # Responses
586
586
 
587
- All functions can be used in conjunction with "await" and will return a response that can be used.
587
+ Most functions will return a response that can be used.
588
588
 
589
589
  ```javascript
590
- const response = await edgeFirebase.startSnapshot("things");
590
+ const response = edgeFirebase.startSnapshot("things");
591
591
  ```
592
592
 
593
593
  reponse:
@@ -596,6 +596,7 @@ reponse:
596
596
  interface actionResponse {
597
597
  success: boolean;
598
598
  message: string;
599
+ meta: {}
599
600
  }
600
601
  ```
601
602