@edgedev/firebase 1.5.12 → 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 CHANGED
@@ -71,6 +71,7 @@ Add a file (whatever.client.ts) to your "plugins" folder with the following code
71
71
  ***-Note the ".client" in the file name. If the file doesn't have that in the name you must disabled SSR in the nuxt config.***
72
72
  ```javascript
73
73
  import eFb from "@edgedev/firebase";
74
+ 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.
74
75
  export default defineNuxtPlugin((nuxtApp) => {
75
76
  nuxtApp.vueApp.use(eFb, {
76
77
  apiKey: "your-apiKey",
@@ -79,7 +80,7 @@ export default defineNuxtPlugin((nuxtApp) => {
79
80
  storageBucket: "your-storageBucket",
80
81
  messagingSenderId: "your-messagingSenderId",
81
82
  appId: "your-appId"
82
- });
83
+ }, isPersistant);
83
84
  });
84
85
  ```
85
86
  ***-Alternatively you can disable SSR for your entire Nuxt project instead of naming the plugin with ".client", update the nuxt.config.ts file:***
@@ -152,17 +153,19 @@ After someoene has been added as a user they will need to "self register" to beg
152
153
 
153
154
  ### Collection permissions by role
154
155
 
155
- 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
156
157
 
157
158
  - **admin:** assign: true, write: true, read: true, delete: true
158
- - **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
159
162
 
160
163
  How to change role permissions for a specific collection:
161
164
 
162
165
  ```javascript
163
166
  edgeFirebase.storeCollectionPermissions(
164
167
  "myItems/subitems/things", // Collection path
165
- "user", // must be user or admin
168
+ "user", // must be admin, editor, writer, user
166
169
  {
167
170
  assign: false,
168
171
  write: false,
@@ -206,7 +209,7 @@ Remove a role from a user for a collection:
206
209
 
207
210
  ### Root permissions and first user
208
211
 
209
- 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.
210
213
 
211
214
  | ![root-collection-roles](./images/root-collection-roles.png) | ![root-user](./images/root-user.jpg) |
212
215
  | ------------------------------------------------------------ | ------------------------------------ |
@@ -253,7 +256,7 @@ edgeFirebase.removeUser("user@edgemarketingdesign.com");
253
256
 
254
257
  ### Users Snapshot Data
255
258
 
256
- 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.
257
260
 
258
261
  ```javascript
259
262
  edgeFirebase.startUsersSnapshot("myItems");
@@ -263,12 +266,11 @@ edgeFirebase.stopUsersSnapshot();
263
266
 
264
267
  ```vue
265
268
  <script setup>
266
- //users is a ref and needs to be accessed via "value"
267
- console.log(edgeFirebase.users.value);
269
+ console.log(edgeFirebase.state.users);
268
270
  </script>
269
271
  <template>
270
272
  <div>
271
- <div v-for="user in edgeFirebase.users.value" :key="item">
273
+ <div v-for="user in edgeFirebase.state.users" :key="item">
272
274
  {{ user.email }}
273
275
  </div>
274
276
  </div>
@@ -296,7 +298,7 @@ interface user {
296
298
  ```typescript
297
299
  interface role {
298
300
  collectionPath: "-" | string; // - is root
299
- role: "admin" | "user";
301
+ role: "admin" | "editor" | "writer" | "user";
300
302
  }
301
303
  ```
302
304
 
@@ -341,13 +343,12 @@ interface UserDataObject {
341
343
  meta: object;
342
344
  roles: role[]; //see role below
343
345
  specialPermissions: specialPermission[]; //see specialPermission below
344
- canAssignCollectionPaths: string[]; //an array of collectionPaths that the user has "assign" access to
345
346
  }
346
347
 
347
348
  // sub types of UserDataObject:
348
349
  interface role {
349
350
  collectionPath: "-" | string; // - is root
350
- role: "admin" | "user";
351
+ role: "admin" | "editor" | "writer" | "user";
351
352
  }
352
353
 
353
354
  interface specialPermission {