@opengis/fastify-table 2.0.155 → 2.0.157
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/dist/server/migrations/roles.sql +4 -0
- package/dist/server/routes/access/controllers/access.group.d.ts +2 -2
- package/dist/server/routes/access/controllers/access.group.d.ts.map +1 -1
- package/dist/server/routes/access/controllers/access.group.js +15 -7
- package/dist/server/routes/access/controllers/access.group.post.d.ts +2 -2
- package/dist/server/routes/access/controllers/access.group.post.d.ts.map +1 -1
- package/dist/server/routes/access/controllers/access.group.post.js +17 -9
- package/dist/server/routes/access/controllers/access.user.d.ts +2 -0
- package/dist/server/routes/access/controllers/access.user.d.ts.map +1 -0
- package/dist/server/routes/access/controllers/access.user.js +25 -0
- package/dist/server/routes/access/controllers/access.user.post.d.ts +2 -0
- package/dist/server/routes/access/controllers/access.user.post.d.ts.map +1 -0
- package/dist/server/routes/access/controllers/access.user.post.js +37 -0
- package/dist/server/routes/access/index.d.ts.map +1 -1
- package/dist/server/routes/access/index.js +5 -1
- package/dist/server/routes/access/schema.d.ts +45 -1
- package/dist/server/routes/access/schema.d.ts.map +1 -1
- package/dist/server/routes/access/schema.js +82 -28
- package/dist/server/routes/table/functions/getData.d.ts.map +1 -1
- package/dist/server/routes/table/functions/getData.js +3 -2
- package/package.json +1 -1
|
@@ -188,4 +188,8 @@ COMMENT ON COLUMN admin.role_access.access_granted_time IS 'Час коли на
|
|
|
188
188
|
CREATE INDEX if not exists admin_access_route_id_idx ON admin.role_access USING btree (route_id COLLATE pg_catalog."default");
|
|
189
189
|
CREATE INDEX if not exists admin_access_role_id_idx ON admin.role_access USING btree (role_id COLLATE pg_catalog."default");
|
|
190
190
|
|
|
191
|
+
alter table admin.role_access add column if not exists resource_id text;
|
|
192
|
+
COMMENT ON COLUMN admin.role_access.resource_id IS 'ID ресурсу';
|
|
193
|
+
alter table admin.role_access alter column route_id drop not null;
|
|
194
|
+
|
|
191
195
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { type FastifyReply } from "fastify";
|
|
2
2
|
import { type ExtendedPG } from "../../../types/core.js";
|
|
3
|
-
export default function accessGroup({ pg, params, user,
|
|
3
|
+
export default function accessGroup({ pg, params, user, }: {
|
|
4
4
|
pg: ExtendedPG;
|
|
5
5
|
params: {
|
|
6
6
|
id: string;
|
|
7
7
|
};
|
|
8
8
|
user: Record<string, any>;
|
|
9
|
-
unittest?: any;
|
|
10
9
|
}, reply: FastifyReply): Promise<{
|
|
11
10
|
routes: any;
|
|
11
|
+
resources: any;
|
|
12
12
|
users: any;
|
|
13
13
|
}>;
|
|
14
14
|
//# sourceMappingURL=access.group.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"access.group.d.ts","sourceRoot":"","sources":["../../../../../server/routes/access/controllers/access.group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAIzD,wBAA8B,WAAW,CACvC,EACE,EAAqB,EACrB,MAAM,EACN,IAAS,
|
|
1
|
+
{"version":3,"file":"access.group.d.ts","sourceRoot":"","sources":["../../../../../server/routes/access/controllers/access.group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAIzD,wBAA8B,WAAW,CACvC,EACE,EAAqB,EACrB,MAAM,EACN,IAAS,GACV,EAAE;IACD,EAAE,EAAE,UAAU,CAAC;IACf,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC3B,EAED,KAAK,EAAE,YAAY;;;;GA4CpB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { pgClients, getAdminAccess } from "../../../../utils.js";
|
|
2
|
-
export default async function accessGroup({ pg = pgClients.client, params, user = {},
|
|
2
|
+
export default async function accessGroup({ pg = pgClients.client, params, user = {}, }, reply) {
|
|
3
3
|
if (!params?.id) {
|
|
4
4
|
return reply.status(400).send("not enough params: id");
|
|
5
5
|
}
|
|
@@ -8,15 +8,23 @@ export default async function accessGroup({ pg = pgClients.client, params, user
|
|
|
8
8
|
id: params.id,
|
|
9
9
|
user,
|
|
10
10
|
});
|
|
11
|
-
if (check?.message && check?.status &&
|
|
11
|
+
if (check?.message && check?.status && process.env.NODE_ENV !== "test") {
|
|
12
12
|
return reply.status(check?.status).send(check?.message);
|
|
13
13
|
}
|
|
14
|
-
const
|
|
14
|
+
const routes = await pg
|
|
15
|
+
.query(`select a.route_id as path, b.actions from admin.routes a
|
|
15
16
|
left join admin.role_access b on a.route_id=b.route_id
|
|
16
|
-
where b.role_id=$1`, [params.id])
|
|
17
|
-
|
|
17
|
+
where b.role_id=$1`, [params.id])
|
|
18
|
+
.then((el) => el.rows || []);
|
|
19
|
+
const resources = await pg
|
|
20
|
+
.query(`select resource_id, actions from admin.role_access
|
|
21
|
+
where resource_id is not null and role_id=$1`, [params.id])
|
|
22
|
+
.then((el) => el.rows || []);
|
|
23
|
+
const users = await pg
|
|
24
|
+
.query(`select user_uid as id, user_name as name, access_granted,
|
|
18
25
|
b.cdate as user_created, b.last_activity_date as last_activity from admin.user_roles a
|
|
19
26
|
left join admin.users b on a.user_uid=b.uid
|
|
20
|
-
where a.role_id=$1`, [params.id])
|
|
21
|
-
|
|
27
|
+
where a.role_id=$1`, [params.id])
|
|
28
|
+
.then((el) => el.rows || []);
|
|
29
|
+
return { routes, resources, users };
|
|
22
30
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { type FastifyReply } from "fastify";
|
|
2
2
|
import { type ExtendedPG } from "../../../types/core.js";
|
|
3
|
-
export default function accessGroupPost({ pg, params, user, body,
|
|
3
|
+
export default function accessGroupPost({ pg, params, user, body, }: {
|
|
4
4
|
pg: ExtendedPG;
|
|
5
5
|
params: {
|
|
6
6
|
id: string;
|
|
7
7
|
};
|
|
8
8
|
user: Record<string, any>;
|
|
9
9
|
body: Record<string, any>;
|
|
10
|
-
unittest?: any;
|
|
11
10
|
}, reply: FastifyReply): Promise<{
|
|
12
11
|
routes: any;
|
|
12
|
+
resources: any;
|
|
13
13
|
users: any;
|
|
14
14
|
}>;
|
|
15
15
|
//# sourceMappingURL=access.group.post.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"access.group.post.d.ts","sourceRoot":"","sources":["../../../../../server/routes/access/controllers/access.group.post.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAKzD,wBAA8B,eAAe,CAC3C,EACE,EAAqB,EACrB,MAAM,EACN,IAAS,EACT,IAAS,
|
|
1
|
+
{"version":3,"file":"access.group.post.d.ts","sourceRoot":"","sources":["../../../../../server/routes/access/controllers/access.group.post.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAKzD,wBAA8B,eAAe,CAC3C,EACE,EAAqB,EACrB,MAAM,EACN,IAAS,EACT,IAAS,GACV,EAAE;IACD,EAAE,EAAE,UAAU,CAAC;IACf,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC3B,EACD,KAAK,EAAE,YAAY;;;;GA+GpB"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { pgClients, getAdminAccess } from "../../../../utils.js";
|
|
2
2
|
import accessGroup from "./access.group.js";
|
|
3
|
-
export default async function accessGroupPost({ pg = pgClients.client, params, user = {}, body = {},
|
|
3
|
+
export default async function accessGroupPost({ pg = pgClients.client, params, user = {}, body = {}, }, reply) {
|
|
4
4
|
const { id } = params;
|
|
5
5
|
if (!user?.uid) {
|
|
6
6
|
return reply.status(401).send("unauthorized");
|
|
7
7
|
}
|
|
8
8
|
// restrict access - admin only
|
|
9
9
|
const check = await getAdminAccess({ id, user });
|
|
10
|
-
if (check?.message && check?.status &&
|
|
10
|
+
if (check?.message && check?.status && process.env.NODE_ENV !== "test") {
|
|
11
11
|
return reply.status(check?.status).send(check?.message);
|
|
12
12
|
}
|
|
13
13
|
const { users = [], routes = [] } = body;
|
|
@@ -21,18 +21,27 @@ export default async function accessGroupPost({ pg = pgClients.client, params, u
|
|
|
21
21
|
const routesDB = await pg
|
|
22
22
|
.query('select array_agg(route_id) as "routesDB" from admin.routes where enabled')
|
|
23
23
|
.then((el) => el.rows?.[0]?.routesDB || []);
|
|
24
|
-
await pg.query("delete from admin.role_access where role_id=$1
|
|
24
|
+
await pg.query("delete from admin.role_access where role_id=$1", [id]);
|
|
25
25
|
await Promise.all(routes
|
|
26
|
-
.filter((el) => !routesDB?.includes(el.path))
|
|
26
|
+
.filter((el) => el.path && !routesDB?.includes(el.path))
|
|
27
27
|
.map((el) => pg.query("insert into admin.routes(route_id) values($1)", [el.path])));
|
|
28
28
|
await Promise.all(routes
|
|
29
|
-
.filter((el) =>
|
|
29
|
+
.filter((el) => el.path && el.actions)
|
|
30
30
|
.map((el) => pg.query("insert into admin.role_access(role_id,route_id,actions) values ($1,$2,$3)", [id, el.path, el.actions])));
|
|
31
|
-
|
|
31
|
+
await Promise.all(routes
|
|
32
|
+
.filter((el) => el.resource && el.actions)
|
|
33
|
+
.map((el) => pg.query("insert into admin.role_access(resource_id,route_id,actions) values ($1,$2,$3)", [id, el.path, el.actions])));
|
|
34
|
+
const rows = await pg
|
|
35
|
+
.query(`select a.route_id as path, b.actions as actions from admin.routes a
|
|
32
36
|
left join admin.role_access b on a.route_id=b.route_id
|
|
33
|
-
where b.role_id=$1`, [id])
|
|
37
|
+
where b.role_id=$1`, [id])
|
|
38
|
+
.then((el) => el.rows || []);
|
|
39
|
+
const resources = await pg
|
|
40
|
+
.query(`select resource_id, actions from admin.role_access
|
|
41
|
+
where resource_id is not null and role_id=$1`, [id])
|
|
42
|
+
.then((el) => el.rows || []);
|
|
34
43
|
if (!users?.length) {
|
|
35
|
-
return reply.status(200).send({ id, routes: rows });
|
|
44
|
+
return reply.status(200).send({ id, routes: rows, resources });
|
|
36
45
|
}
|
|
37
46
|
}
|
|
38
47
|
const q = `delete from admin.user_roles where role_id='${id.replace(/'/g, "''")}';
|
|
@@ -45,7 +54,6 @@ export default async function accessGroupPost({ pg = pgClients.client, params, u
|
|
|
45
54
|
pg,
|
|
46
55
|
params,
|
|
47
56
|
user,
|
|
48
|
-
unittest,
|
|
49
57
|
}, reply);
|
|
50
58
|
return res;
|
|
51
59
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"access.user.d.ts","sourceRoot":"","sources":["../../../../../server/routes/access/controllers/access.user.ts"],"names":[],"mappings":"AAEA,wBAA8B,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,gBAkC5D"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { config, pgClients } from "../../../../utils.js";
|
|
2
|
+
export default async function accessUser(req, reply) {
|
|
3
|
+
if (!req.params?.id) {
|
|
4
|
+
return reply
|
|
5
|
+
.status(400)
|
|
6
|
+
.send({ error: "not enough params: id", code: 400 });
|
|
7
|
+
}
|
|
8
|
+
// restrict access - admin only
|
|
9
|
+
if (!config.local && !req.user?.user_type?.includes?.("admin")) {
|
|
10
|
+
return reply.status(403).send({ error: "access restricted", code: 403 });
|
|
11
|
+
}
|
|
12
|
+
const { pg = pgClients.client } = req;
|
|
13
|
+
const routes = await pg
|
|
14
|
+
.query(`select a.route_id as path, b.actions from admin.routes a
|
|
15
|
+
left join admin.role_access b on a.route_id=b.route_id
|
|
16
|
+
where b.user_uid=$1`, [req.params.id])
|
|
17
|
+
.then((el) => el.rows || []);
|
|
18
|
+
const user = await pg
|
|
19
|
+
.query(`select user_uid as id, user_name as name, access_granted,
|
|
20
|
+
b.cdate as user_created, b.last_activity_date as last_activity from admin.user_roles a
|
|
21
|
+
left join admin.users b on a.user_uid=b.uid
|
|
22
|
+
where a.user_uid=$1`, [req.params.id])
|
|
23
|
+
.then((el) => el.rows?.[0]);
|
|
24
|
+
return reply.status(200).send({ routes, user });
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"access.user.post.d.ts","sourceRoot":"","sources":["../../../../../server/routes/access/controllers/access.user.post.ts"],"names":[],"mappings":"AAIA,wBAA8B,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,gBA8DhE"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { config, pgClients } from "../../../../utils.js";
|
|
2
|
+
import accessUser from "./access.user.js";
|
|
3
|
+
export default async function accessUserPost(req, reply) {
|
|
4
|
+
const { pg = pgClients.client, params, body, user } = req;
|
|
5
|
+
if (!params?.id) {
|
|
6
|
+
return reply
|
|
7
|
+
.status(400)
|
|
8
|
+
.send({ error: "not enough params: id", code: 400 });
|
|
9
|
+
}
|
|
10
|
+
if (!user?.uid) {
|
|
11
|
+
return reply.status(401).send({ error: "unauthorized", code: 401 });
|
|
12
|
+
}
|
|
13
|
+
// restrict access - admin only
|
|
14
|
+
if (!config.local && !user?.user_type?.includes?.("admin")) {
|
|
15
|
+
return reply.status(403).send({ error: "access restricted", code: 403 });
|
|
16
|
+
}
|
|
17
|
+
await pg.query("delete from admin.role_access where user_uid=$1", [
|
|
18
|
+
params.id,
|
|
19
|
+
]);
|
|
20
|
+
if (!body?.routes?.length) {
|
|
21
|
+
return reply.status(200).send({ id: params.id, routes: [] });
|
|
22
|
+
}
|
|
23
|
+
const routesDB = await pg
|
|
24
|
+
.query("select array_agg(route_id) from admin.routes where enabled")
|
|
25
|
+
.then((el) => el.rows?.[0]?.array_agg || []);
|
|
26
|
+
await Promise.all(body.routes
|
|
27
|
+
.filter((el) => el.path && !routesDB?.includes(el.path))
|
|
28
|
+
.map((el) => pg.query("insert into admin.routes(route_id) values($1)", [el.path])));
|
|
29
|
+
await Promise.all(body.routes
|
|
30
|
+
.filter((el) => el.path && el.actions)
|
|
31
|
+
.map((el) => pg.query("insert into admin.role_access(user_uid,route_id,actions) values ($1,$2,$3)", [params.id, el.path, el.actions])));
|
|
32
|
+
await Promise.all(body.routes
|
|
33
|
+
.filter((el) => el.resource && el.actions)
|
|
34
|
+
.map((el) => pg.query("insert into admin.role_access(user_uid,resource_id,actions) values ($1,$2,$3)", [params.id, el.resource, el.actions])));
|
|
35
|
+
const result = await accessUser({ pg, params }, reply);
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/access/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/access/index.ts"],"names":[],"mappings":"AAeA,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,GAAE,GAAQ,QAkBxD"}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import accessGroup from "./controllers/access.group.js";
|
|
2
2
|
import accessGroupPost from "./controllers/access.group.post.js";
|
|
3
|
+
import accessUser from "./controllers/access.user.js";
|
|
4
|
+
import accessUserPost from "./controllers/access.user.post.js";
|
|
3
5
|
import accessInterface from "./controllers/access.interface.js";
|
|
4
|
-
import { accessGroupPostSchema, accessGroupSchema, accessInterfaceSchema, } from "./schema.js";
|
|
6
|
+
import { accessGroupPostSchema, accessGroupSchema, accessInterfaceSchema, accessUserPostSchema, accessUserSchema, } from "./schema.js";
|
|
5
7
|
export default function route(fastify, opt = {}) {
|
|
6
8
|
fastify.get("/access-group/:id", { schema: accessGroupSchema }, accessGroup);
|
|
7
9
|
fastify.post("/access-group/:id", { schema: accessGroupPostSchema }, accessGroupPost);
|
|
10
|
+
fastify.get("/access-user/:id", { schema: accessUserSchema }, accessUser);
|
|
11
|
+
fastify.post("/access-user/:id", { schema: accessUserPostSchema }, accessUserPost);
|
|
8
12
|
fastify.get("/access-interface/:name", { schema: accessInterfaceSchema }, accessInterface);
|
|
9
13
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
declare const _default: null;
|
|
2
2
|
export default _default;
|
|
3
|
-
export { accessGroupSchema, accessGroupPostSchema, accessInterfaceSchema };
|
|
3
|
+
export { accessGroupSchema, accessUserSchema, accessGroupPostSchema, accessInterfaceSchema, accessUserPostSchema, };
|
|
4
4
|
declare const accessGroupSchema: {
|
|
5
5
|
params: {
|
|
6
6
|
type: string;
|
|
@@ -13,6 +13,18 @@ declare const accessGroupSchema: {
|
|
|
13
13
|
required: string[];
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
|
+
declare const accessUserSchema: {
|
|
17
|
+
params: {
|
|
18
|
+
type: string;
|
|
19
|
+
properties: {
|
|
20
|
+
id: {
|
|
21
|
+
type: string;
|
|
22
|
+
pattern: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
required: string[];
|
|
26
|
+
};
|
|
27
|
+
};
|
|
16
28
|
declare const accessInterfaceSchema: {
|
|
17
29
|
params: {
|
|
18
30
|
type: string;
|
|
@@ -57,4 +69,36 @@ declare const accessGroupPostSchema: {
|
|
|
57
69
|
};
|
|
58
70
|
};
|
|
59
71
|
};
|
|
72
|
+
declare const accessUserPostSchema: {
|
|
73
|
+
params: {
|
|
74
|
+
type: string;
|
|
75
|
+
properties: {
|
|
76
|
+
id: {
|
|
77
|
+
type: string;
|
|
78
|
+
pattern: string;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
required: string[];
|
|
82
|
+
};
|
|
83
|
+
body: {
|
|
84
|
+
type: string;
|
|
85
|
+
properties: {
|
|
86
|
+
users: {
|
|
87
|
+
type: string;
|
|
88
|
+
items: {
|
|
89
|
+
type: string;
|
|
90
|
+
properties: {
|
|
91
|
+
id: {
|
|
92
|
+
type: string;
|
|
93
|
+
pattern: string;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
routes: {
|
|
99
|
+
type: string;
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
};
|
|
60
104
|
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../server/routes/access/schema.ts"],"names":[],"mappings":";AAAA,wBAAoB;AACpB,OAAO,
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../server/routes/access/schema.ts"],"names":[],"mappings":";AAAA,wBAAoB;AACpB,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,GACrB,CAAC;AAEF,QAAA,MAAM,iBAAiB;;;;;;;;;;;CAQtB,CAAC;AAEF,QAAA,MAAM,gBAAgB;;;;;;;;;;;CAQrB,CAAC;AAEF,QAAA,MAAM,qBAAqB;;;;;;;;;;;CAQ1B,CAAC;AAEF,QAAA,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4C1B,CAAC;AAEF,QAAA,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4CzB,CAAC"}
|
|
@@ -1,64 +1,118 @@
|
|
|
1
1
|
export default null;
|
|
2
|
-
export { accessGroupSchema, accessGroupPostSchema, accessInterfaceSchema };
|
|
2
|
+
export { accessGroupSchema, accessUserSchema, accessGroupPostSchema, accessInterfaceSchema, accessUserPostSchema, };
|
|
3
3
|
const accessGroupSchema = {
|
|
4
4
|
params: {
|
|
5
|
-
type:
|
|
5
|
+
type: "object",
|
|
6
6
|
properties: {
|
|
7
|
-
id: { type:
|
|
7
|
+
id: { type: "string", pattern: "^([\\d\\w._-]+)$" },
|
|
8
8
|
},
|
|
9
|
-
required: [
|
|
9
|
+
required: ["id"],
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
const accessUserSchema = {
|
|
13
|
+
params: {
|
|
14
|
+
type: "object",
|
|
15
|
+
properties: {
|
|
16
|
+
id: { type: "string", pattern: "^([\\d\\w._-]+)$" },
|
|
17
|
+
},
|
|
18
|
+
required: ["id"],
|
|
10
19
|
},
|
|
11
20
|
};
|
|
12
21
|
const accessInterfaceSchema = {
|
|
13
22
|
params: {
|
|
14
|
-
type:
|
|
23
|
+
type: "object",
|
|
15
24
|
properties: {
|
|
16
|
-
name: { type:
|
|
25
|
+
name: { type: "string", pattern: "^([\\d\\w._-]+)$" },
|
|
17
26
|
},
|
|
18
|
-
required: [
|
|
27
|
+
required: ["name"],
|
|
19
28
|
},
|
|
20
29
|
};
|
|
21
30
|
const accessGroupPostSchema = {
|
|
22
31
|
params: {
|
|
23
|
-
type:
|
|
32
|
+
type: "object",
|
|
24
33
|
properties: {
|
|
25
|
-
id: { type:
|
|
34
|
+
id: { type: "string", pattern: "^([\\d\\w._-]+)$" },
|
|
26
35
|
},
|
|
27
|
-
required: [
|
|
36
|
+
required: ["id"],
|
|
28
37
|
},
|
|
29
38
|
body: {
|
|
30
|
-
type:
|
|
39
|
+
type: "object",
|
|
31
40
|
properties: {
|
|
32
41
|
users: {
|
|
33
|
-
type:
|
|
42
|
+
type: "array",
|
|
34
43
|
items: {
|
|
35
|
-
type:
|
|
44
|
+
type: "object",
|
|
36
45
|
properties: {
|
|
37
46
|
id: {
|
|
38
|
-
type:
|
|
39
|
-
pattern:
|
|
47
|
+
type: "string",
|
|
48
|
+
pattern: "^([\\d\\w._-]+)$",
|
|
40
49
|
},
|
|
41
50
|
},
|
|
42
51
|
},
|
|
43
52
|
},
|
|
44
53
|
routes: {
|
|
45
|
-
type:
|
|
54
|
+
type: "array",
|
|
46
55
|
/*items: {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
type: 'object',
|
|
57
|
+
properties: {
|
|
58
|
+
path: {
|
|
59
|
+
type: 'string',
|
|
60
|
+
pattern: '^([\\d\\w._-]+)$',
|
|
61
|
+
},
|
|
62
|
+
actions: {
|
|
63
|
+
type: 'array',
|
|
64
|
+
items: {
|
|
65
|
+
type: 'string',
|
|
66
|
+
enum: ['get', 'add', 'edit', 'del'],
|
|
67
|
+
},
|
|
68
|
+
},
|
|
58
69
|
},
|
|
70
|
+
},*/
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
const accessUserPostSchema = {
|
|
76
|
+
params: {
|
|
77
|
+
type: "object",
|
|
78
|
+
properties: {
|
|
79
|
+
id: { type: "string", pattern: "^([\\d\\w._-]+)$" },
|
|
80
|
+
},
|
|
81
|
+
required: ["id"],
|
|
82
|
+
},
|
|
83
|
+
body: {
|
|
84
|
+
type: "object",
|
|
85
|
+
properties: {
|
|
86
|
+
users: {
|
|
87
|
+
type: "array",
|
|
88
|
+
items: {
|
|
89
|
+
type: "object",
|
|
90
|
+
properties: {
|
|
91
|
+
id: {
|
|
92
|
+
type: "string",
|
|
93
|
+
pattern: "^([\\d\\w._-]+)$",
|
|
59
94
|
},
|
|
60
95
|
},
|
|
61
|
-
}
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
routes: {
|
|
99
|
+
type: "array",
|
|
100
|
+
/*items: {
|
|
101
|
+
type: 'object',
|
|
102
|
+
properties: {
|
|
103
|
+
path: {
|
|
104
|
+
type: 'string',
|
|
105
|
+
pattern: '^([\\d\\w._-]+)$',
|
|
106
|
+
},
|
|
107
|
+
actions: {
|
|
108
|
+
type: 'array',
|
|
109
|
+
items: {
|
|
110
|
+
type: 'string',
|
|
111
|
+
enum: ['get', 'add', 'edit', 'del'],
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
},*/
|
|
62
116
|
},
|
|
63
117
|
},
|
|
64
118
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getData.d.ts","sourceRoot":"","sources":["../../../../../server/routes/table/functions/getData.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAgFzD,wBAA8B,OAAO,CACnC,EACE,EAAqB,EACrB,MAAM,EACN,KAAK,EACL,EAAE,EACF,OAAY,EACZ,KAAU,EACV,IAAS,EACT,YAAY,EACZ,KAAY,EACZ,UAAU,EACV,OAAO,EAAE,YAAY,EACrB,WAAW,EAAE,gBAAgB,EAC7B,OAAO,EAAE,YAAY,EACrB,QAAgB,GACjB,EAAE;IACD,EAAE,CAAC,EAAE,UAAU,CAAC;IAChB,MAAM,CAAC,EAAE;QAAE,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IACxD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,GAAG,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,EACD,MAAM,CAAC,EAAE,YAAY,EACrB,MAAM,CAAC,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"getData.d.ts","sourceRoot":"","sources":["../../../../../server/routes/table/functions/getData.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAgFzD,wBAA8B,OAAO,CACnC,EACE,EAAqB,EACrB,MAAM,EACN,KAAK,EACL,EAAE,EACF,OAAY,EACZ,KAAU,EACV,IAAS,EACT,YAAY,EACZ,KAAY,EACZ,UAAU,EACV,OAAO,EAAE,YAAY,EACrB,WAAW,EAAE,gBAAgB,EAC7B,OAAO,EAAE,YAAY,EACrB,QAAgB,GACjB,EAAE;IACD,EAAE,CAAC,EAAE,UAAU,CAAC;IAChB,MAAM,CAAC,EAAE;QAAE,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IACxD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,GAAG,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,EACD,MAAM,CAAC,EAAE,YAAY,EACrB,MAAM,CAAC,EAAE,GAAG,gBA61Bb"}
|
|
@@ -149,11 +149,12 @@ export default async function dataAPI({ pg = pgClients.client, params, table, id
|
|
|
149
149
|
});
|
|
150
150
|
}
|
|
151
151
|
// const body = loadTable || hookData || tokenData;
|
|
152
|
-
const { table: table1, columns = [], sql, cardSql, form, meta, sqlColumns,
|
|
152
|
+
const { table: table1, columns = [], sql, cardSql, form, meta, sqlColumns, editable = false, } = loadTable || hookData || tokenData || params || { table };
|
|
153
|
+
const ispublic = loadTable?.public || hookData?.public || tokenData?.public || params?.public || false;
|
|
153
154
|
if (!ispublic && !user?.uid && !called) {
|
|
154
155
|
return reply.status(401).send({ error: "unauthorized", code: 401 });
|
|
155
156
|
}
|
|
156
|
-
if (!actions.includes("view") && !config?.local && !called) {
|
|
157
|
+
if (!ispublic && !actions.includes("view") && !config?.local && !called) {
|
|
157
158
|
return reply.status(403).send({ error: "access restricted", code: 403 });
|
|
158
159
|
}
|
|
159
160
|
const { list: filters = [] } = objectId
|