@opengis/admin 0.2.69 → 0.2.71

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/admin",
3
- "version": "0.2.69",
3
+ "version": "0.2.71",
4
4
  "description": "This project Softpro Admin",
5
5
  "main": "dist/admin.js",
6
6
  "type": "module",
@@ -43,7 +43,7 @@
43
43
  "@opengis/admin": "^0.1.69",
44
44
  "@opengis/fastify-auth": "^1.0.60",
45
45
  "@opengis/fastify-file": "^1.0.39",
46
- "@opengis/fastify-table": "^1.1.142",
46
+ "@opengis/fastify-table": "^1.1.143",
47
47
  "@opengis/v3-core": "^0.3.29",
48
48
  "@opengis/v3-filter": "^0.0.41",
49
49
  "@tabler/icons-vue": "^3.28.1",
@@ -0,0 +1,34 @@
1
+ import { pgClients, metaFormat } from '@opengis/fastify-table/utils.js';
2
+ import { getAdminAccess } from '../../../../utils.js';
3
+
4
+ const q = `select a.route_id as id, coalesce(b.user_uid, d.user_uid) as user_uid, coalesce(d.actions, b.actions, array['view']) as actions, b.scope, c.role_id
5
+ from admin.routes a
6
+ left join admin.role_access b on
7
+ a.route_id=b.route_id
8
+ left join admin.roles c on
9
+ b.role_id=c.role_id
10
+ and c.enabled
11
+ left join admin.user_roles d on
12
+ c.role_id=d.role_id
13
+ and ( case when
14
+ d.expiration is not null
15
+ then d.expiration > CURRENT_DATE
16
+ else 1=1
17
+ end )
18
+ where $1 in (a.route_id, a.alias, a.table_name) and coalesce(b.user_uid, d.user_uid) is not null`;
19
+
20
+ export default async function accessInterface(req) {
21
+ const { pg = pgClients.client, params = {}, user = {} } = req;
22
+
23
+ // restrict access - admin only
24
+ const check = await getAdminAccess({
25
+ id: params.name, user,
26
+ });
27
+ if (check) return check;
28
+
29
+ const { rows = [] } = await pg.query(q, [params.name]);
30
+
31
+ const cls = { user_uid: 'core.user_uid', actions: 'core.actions', role_id: 'core.roles' };
32
+ await metaFormat({ rows, cls, sufix: false });
33
+ return { rows };
34
+ }
@@ -1,8 +1,11 @@
1
1
  import accessGroup from "./controllers/access.group.js";
2
2
  import accessGroupPost from "./controllers/access.group.post.js";
3
- import { accessGroupPostSchema, accessGroupSchema } from "./schema.mjs";
3
+ import accessInterface from "./controllers/access.interface.js";
4
+
5
+ import { accessGroupPostSchema, accessGroupSchema, accessInterfaceSchema } from "./schema.mjs";
4
6
 
5
7
  export default async function route(fastify) {
6
8
  fastify.get('/access-group/:id', { schema: accessGroupSchema }, accessGroup);
7
9
  fastify.post('/access-group/:id', { schema: accessGroupPostSchema }, accessGroupPost);
10
+ fastify.get('/access-interface/:name', { schema: accessInterfaceSchema }, accessInterface);
8
11
  }
@@ -1,5 +1,5 @@
1
1
  export default null;
2
- export { accessGroupSchema, accessGroupPostSchema }
2
+ export { accessGroupSchema, accessGroupPostSchema, accessInterfaceSchema }
3
3
 
4
4
  const accessGroupSchema = {
5
5
  params: {
@@ -11,6 +11,16 @@ const accessGroupSchema = {
11
11
  },
12
12
  };
13
13
 
14
+ const accessInterfaceSchema = {
15
+ params: {
16
+ type: 'object',
17
+ properties: {
18
+ name: { type: 'string', pattern: '^([\\d\\w._-]+)$' },
19
+ },
20
+ required: ['name'],
21
+ },
22
+ };
23
+
14
24
  const accessGroupPostSchema = {
15
25
  params: {
16
26
  type: 'object',
@@ -61,6 +61,7 @@ export default async function tableFilter(req) {
61
61
  Object.assign(el, { options });
62
62
  }));
63
63
 
64
+ // percentile_cont - alternative
64
65
  await Promise.all(filters.filter((el) => el.name && el.type === 'Range').map(async (el) => {
65
66
  const data = await pg.queryCache(`select array[
66
67
  min(${el.name}),