@mongoosejs/studio 0.0.70 → 0.0.72

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.
@@ -1,34 +1,72 @@
1
1
  'use strict';
2
2
 
3
- module.exports = [
4
- {
5
- path: '/',
6
- name: 'root',
7
- component: 'models'
8
- },
9
- {
10
- path: '/model/:model',
11
- name: 'model',
12
- component: 'models'
13
- },
14
- {
15
- path: '/model/:model/document/:documentId',
16
- name: 'document',
17
- component: 'document'
18
- },
19
- {
20
- path: '/dashboards',
21
- name: 'dashboards',
22
- component: 'dashboards'
23
- },
24
- {
25
- path: '/dashboard/:dashboardId',
26
- name: 'dashboard',
27
- component: 'dashboard'
28
- },
29
- {
30
- path: '/team',
31
- name: 'team',
32
- component: 'team'
33
- }
34
- ];
3
+ // Role-based access control configuration
4
+ const roleAccess = {
5
+ owner: ['root', 'model', 'document', 'dashboards', 'dashboard', 'team'],
6
+ admin: ['root', 'model', 'document', 'dashboards', 'dashboard', 'team'],
7
+ member: ['root', 'model', 'document', 'dashboards', 'dashboard'],
8
+ readonly: ['root', 'model', 'document'],
9
+ dashboards: ['dashboards', 'dashboard']
10
+ };
11
+
12
+ // Helper function to check if a role has access to a route
13
+ function hasAccess(roles, routeName) {
14
+ // change to true for local development
15
+ if (!roles) return false;
16
+ return roles.some(role => roleAccess[role]?.includes(routeName));
17
+ }
18
+
19
+ module.exports = {
20
+ routes: [
21
+ {
22
+ path: '/',
23
+ name: 'root',
24
+ component: 'models',
25
+ meta: {
26
+ authorized: true
27
+ }
28
+ },
29
+ {
30
+ path: '/model/:model',
31
+ name: 'model',
32
+ component: 'models',
33
+ meta: {
34
+ authorized: true
35
+ }
36
+ },
37
+ {
38
+ path: '/model/:model/document/:documentId',
39
+ name: 'document',
40
+ component: 'document',
41
+ meta: {
42
+ authorized: true
43
+ }
44
+ },
45
+ {
46
+ path: '/dashboards',
47
+ name: 'dashboards',
48
+ component: 'dashboards',
49
+ meta: {
50
+ authorized: true
51
+ }
52
+ },
53
+ {
54
+ path: '/dashboard/:dashboardId',
55
+ name: 'dashboard',
56
+ component: 'dashboard',
57
+ meta: {
58
+ authorized: true
59
+ }
60
+ },
61
+ {
62
+ path: '/team',
63
+ name: 'team',
64
+ component: 'team',
65
+ meta: {
66
+ authorized: true
67
+ }
68
+ }
69
+ ],
70
+ roleAccess,
71
+ hasAccess
72
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mongoosejs/studio",
3
- "version": "0.0.70",
3
+ "version": "0.0.72",
4
4
  "dependencies": {
5
5
  "archetype": "0.13.1",
6
6
  "csv-stringify": "6.3.0",