@opengis/fastify-table 2.0.127 → 2.0.131
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/module/core/select/core.user_mentioned.sql +1 -1
- package/dist/server/plugins/crud/funcs/getAccess.d.ts +1 -1
- package/dist/server/plugins/crud/funcs/getAccess.d.ts.map +1 -1
- package/dist/server/plugins/crud/funcs/getAccess.js +1 -1
- package/dist/server/plugins/hook/index.js +39 -0
- package/dist/server/plugins/redis/funcs/getRedis.d.ts +1 -1
- package/dist/server/plugins/redis/funcs/getRedis.d.ts.map +1 -1
- package/dist/server/plugins/redis/funcs/getRedis.js +11 -7
- package/dist/server/routes/auth/controllers/2factor/generate.js +38 -0
- package/dist/server/routes/auth/controllers/2factor/toggle.js +39 -0
- package/dist/server/routes/crud/controllers/deleteCrud.d.ts.map +1 -1
- package/dist/server/routes/crud/controllers/deleteCrud.js +10 -3
- package/dist/server/routes/crud/controllers/insert.d.ts.map +1 -1
- package/dist/server/routes/crud/controllers/insert.js +14 -4
- package/dist/server/routes/crud/controllers/table.d.ts.map +1 -1
- package/dist/server/routes/crud/controllers/table.js +10 -2
- package/dist/server/routes/crud/controllers/update.d.ts.map +1 -1
- package/dist/server/routes/crud/controllers/update.js +14 -3
- package/dist/server/routes/logger/controllers/utils/checkUserAccess.js +22 -0
- package/dist/server/routes/logger/controllers/utils/getRootDir.js +25 -0
- package/dist/server/routes/table/controllers/card.d.ts.map +1 -1
- package/dist/server/routes/table/controllers/card.js +10 -2
- package/dist/server/routes/table/controllers/cardData.d.ts.map +1 -1
- package/dist/server/routes/table/controllers/cardData.js +10 -3
- package/dist/server/routes/table/controllers/getFormByTable.d.ts +2 -1
- package/dist/server/routes/table/controllers/getFormByTable.d.ts.map +1 -1
- package/dist/server/routes/table/controllers/getFormByTable.js +10 -3
- package/dist/server/routes/table/functions/getData.d.ts +2 -1
- package/dist/server/routes/table/functions/getData.d.ts.map +1 -1
- package/dist/server/routes/table/functions/getData.js +11 -7
- package/dist/server/routes/util/controllers/dependencies.d.ts +2 -0
- package/dist/server/routes/util/controllers/dependencies.d.ts.map +1 -0
- package/dist/server/routes/util/controllers/dependencies.js +13 -0
- package/dist/server/routes/util/index.d.ts.map +1 -1
- package/dist/server/routes/util/index.js +2 -0
- package/package.json +1 -1
- package/dist/module/core/cls/constraint_type.json +0 -14
- package/dist/module/core/cls/constraint_type_table.json +0 -18
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
select uid, coalesce(sur_name,'')||coalesce(' '||user_name,'') as text, email from admin.users
|
|
1
|
+
select uid, coalesce(sur_name,'')||coalesce(' '||user_name,'') as text, email from admin.users
|
|
2
2
|
where enabled order by coalesce(sur_name,'')||coalesce(' '||user_name,'')
|
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
* @param {String} user.user_type User type
|
|
9
9
|
* @returns { scope: String, roles: String[], actions: String[], query: String }
|
|
10
10
|
*/
|
|
11
|
-
export default function getAccess({ table, form, user }: any, pg?: any): Promise<{} | null>;
|
|
11
|
+
export default function getAccess({ table, form, user, method }: any, pg?: any): Promise<{} | null>;
|
|
12
12
|
//# sourceMappingURL=getAccess.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getAccess.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/crud/funcs/getAccess.ts"],"names":[],"mappings":"AAuBA;;;;;;;;;GASG;AAEH,wBAA8B,SAAS,CACrC,EAAE,KAAK,EAAE,IAAI,EAAE,IAAS,EAAE,EAAE,GAAG,EAC/
|
|
1
|
+
{"version":3,"file":"getAccess.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/crud/funcs/getAccess.ts"],"names":[],"mappings":"AAuBA;;;;;;;;;GASG;AAEH,wBAA8B,SAAS,CACrC,EAAE,KAAK,EAAE,IAAI,EAAE,IAAS,EAAE,MAAc,EAAE,EAAE,GAAG,EAC/C,EAAE,MAAmB,sBAwFtB"}
|
|
@@ -28,7 +28,7 @@ where $1 in (a.route_id, a.alias, a.table_name) and $2 in (b.user_uid, d.user_ui
|
|
|
28
28
|
* @param {String} user.user_type User type
|
|
29
29
|
* @returns { scope: String, roles: String[], actions: String[], query: String }
|
|
30
30
|
*/
|
|
31
|
-
export default async function getAccess({ table, form, user = {} }, pg = pgClients.client) {
|
|
31
|
+
export default async function getAccess({ table, form, user = {}, method = 'GET' }, pg = pgClients.client) {
|
|
32
32
|
if (!table)
|
|
33
33
|
return null;
|
|
34
34
|
const hookData = await applyHook("getAccess", { table, user, pg });
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import config from "../../../config.js";
|
|
2
|
+
export const hookList = {};
|
|
3
|
+
export async function applyHook(name, data) {
|
|
4
|
+
if (config.trace)
|
|
5
|
+
console.log("applyHook", name);
|
|
6
|
+
if (!hookList[name]?.length)
|
|
7
|
+
return null;
|
|
8
|
+
const result = {};
|
|
9
|
+
await Promise.all(hookList[name].map(async (hook) => {
|
|
10
|
+
const hookData = await hook({ ...data, config });
|
|
11
|
+
if (hookData) {
|
|
12
|
+
if (config.trace)
|
|
13
|
+
console.log("applyHook", name, hookData);
|
|
14
|
+
Object.assign(result, hookData);
|
|
15
|
+
}
|
|
16
|
+
})).catch((err) => {
|
|
17
|
+
console.error("applyHook", name, err.toString());
|
|
18
|
+
});
|
|
19
|
+
if (Object.keys(result).length) {
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
export function addHook(name, fn) {
|
|
25
|
+
if (!hookList[name]) {
|
|
26
|
+
hookList[name] = [];
|
|
27
|
+
}
|
|
28
|
+
if (config.trace)
|
|
29
|
+
console.log("addHook", name);
|
|
30
|
+
hookList[name].push(fn);
|
|
31
|
+
}
|
|
32
|
+
export function applyHookSync(name, data) {
|
|
33
|
+
if (!hookList[name]?.length)
|
|
34
|
+
return null;
|
|
35
|
+
if (config.trace)
|
|
36
|
+
console.log("applyHookSync", name);
|
|
37
|
+
const hookData = hookList[name].map((hook) => hook(data))[0];
|
|
38
|
+
return hookData;
|
|
39
|
+
}
|
|
@@ -3,7 +3,7 @@ declare function getRedis({ db, host, port, closeClient, retryStrategy, enableOf
|
|
|
3
3
|
host?: string;
|
|
4
4
|
port?: number;
|
|
5
5
|
closeClient?: boolean;
|
|
6
|
-
retryStrategy?: any;
|
|
6
|
+
retryStrategy?: Function | any;
|
|
7
7
|
enableOfflineQueue?: boolean;
|
|
8
8
|
lazyConnect?: boolean;
|
|
9
9
|
connectTimeout?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRedis.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/redis/funcs/getRedis.ts"],"names":[],"mappings":"AAQA,iBAAS,QAAQ,CACf,EACE,EAAE,EACF,IAAI,EACJ,IAAI,EACJ,
|
|
1
|
+
{"version":3,"file":"getRedis.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/redis/funcs/getRedis.ts"],"names":[],"mappings":"AAQA,iBAAS,QAAQ,CACf,EACE,EAAE,EACF,IAAI,EACJ,IAAI,EACJ,WAAW,EACX,aAAa,EACb,kBAAkB,EAClB,WAAW,EACX,cAAc,EACd,oBAAoB,GACrB,GAAE;IACD,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,aAAa,CAAC,EAAE,QAAQ,GAAG,GAAG,CAAC;IAC/B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,MAAM,CAAC;CACnB,OAoDd;AAED,eAAe,QAAQ,CAAC"}
|
|
@@ -3,7 +3,7 @@ import config from "../../../../config.js";
|
|
|
3
3
|
import logger from "../../logger/getLogger.js";
|
|
4
4
|
import redisClients from "./redisClients.js";
|
|
5
5
|
config.ready = config.ready || {};
|
|
6
|
-
function getRedis({ db, host, port, closeClient
|
|
6
|
+
function getRedis({ db, host, port, closeClient, retryStrategy, enableOfflineQueue, lazyConnect, connectTimeout, maxRetriesPerRequest, } = { db: 0 }) {
|
|
7
7
|
if (!config.redis && !host)
|
|
8
8
|
return null;
|
|
9
9
|
const key = host || port ? [host, port, db].join("-") : db;
|
|
@@ -21,12 +21,16 @@ function getRedis({ db, host, port, closeClient = false, retryStrategy = (times)
|
|
|
21
21
|
host: host || config.redis?.host || "127.0.0.1",
|
|
22
22
|
port: port || config.redis?.port || 6379, // Redis port
|
|
23
23
|
family: 4, // 4 (IPv4) or 6 (IPv6)
|
|
24
|
-
closeClient,
|
|
25
|
-
retryStrategy
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
closeClient: closeClient || config.redis?.closeClient || false,
|
|
25
|
+
retryStrategy: retryStrategy
|
|
26
|
+
? retryStrategy
|
|
27
|
+
: (times) => Math.min(times * 500, 5000),
|
|
28
|
+
enableOfflineQueue: enableOfflineQueue || config.redis?.enableOfflineQueue || true,
|
|
29
|
+
lazyConnect: lazyConnect || config.redis?.lazyConnect || true,
|
|
30
|
+
connectTimeout: +(connectTimeout || config.redis?.connectTimeout || 2000),
|
|
31
|
+
maxRetriesPerRequest: +(maxRetriesPerRequest ||
|
|
32
|
+
config.redis?.maxRetriesPerRequest ||
|
|
33
|
+
1),
|
|
30
34
|
};
|
|
31
35
|
redisClients[key] = new Redis(redisConfig);
|
|
32
36
|
redisClients[key].on("ready", () => {
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import config from "../../../../../config.js";
|
|
2
|
+
import pgClients from "../../../../plugins/pg/pgClients.js";
|
|
3
|
+
import { generate } from "./providers/totp.js";
|
|
4
|
+
/**
|
|
5
|
+
* Генерація secret для двохфакторної авторизації користувача
|
|
6
|
+
*
|
|
7
|
+
* @method GET
|
|
8
|
+
* @summary Генерація user secret для двохфакторної авторизації
|
|
9
|
+
* @priority 3
|
|
10
|
+
* @alias generate
|
|
11
|
+
* @type api
|
|
12
|
+
* @tag auth
|
|
13
|
+
* @requires 2fa
|
|
14
|
+
* @errors 500
|
|
15
|
+
* @returns {Number} status Номер помилки
|
|
16
|
+
* @returns {String|Object} error Опис помилки
|
|
17
|
+
* @returns {String|Object} message Повідомлення про успішне виконання або об'єкт з параметрами
|
|
18
|
+
*/
|
|
19
|
+
export default async function generateFunction({ pg = pgClients.client, user = {} }, reply) {
|
|
20
|
+
if (!user?.uid) {
|
|
21
|
+
return reply.status(401).send("unauthorized");
|
|
22
|
+
}
|
|
23
|
+
const { uid } = user;
|
|
24
|
+
if (!config?.auth?.["2factor"]) {
|
|
25
|
+
return reply.status(400).send("2fa not enabled");
|
|
26
|
+
}
|
|
27
|
+
if (!config.pg) {
|
|
28
|
+
return reply.status(400).send("empty pg");
|
|
29
|
+
}
|
|
30
|
+
if (!uid) {
|
|
31
|
+
return reply.status(401).send("access restricted: unauthorized");
|
|
32
|
+
}
|
|
33
|
+
const res = await generate({ pg, uid });
|
|
34
|
+
if (res?.enabled) {
|
|
35
|
+
return reply.status(400).send("already created 2fa");
|
|
36
|
+
}
|
|
37
|
+
return reply.status(200).send(res);
|
|
38
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import config from '../../../../../config.js';
|
|
2
|
+
import pgClients from '../../../../plugins/pg/pgClients.js';
|
|
3
|
+
import { toggle } from './providers/totp.js';
|
|
4
|
+
/**
|
|
5
|
+
* Включення/виключення двохфакторної авторизації для користувача
|
|
6
|
+
*
|
|
7
|
+
* @method GET
|
|
8
|
+
* @summary Включення/виключення двохфакторної авторизації
|
|
9
|
+
* @priority 2
|
|
10
|
+
* @alias toggle
|
|
11
|
+
* @type api
|
|
12
|
+
* @tag auth
|
|
13
|
+
* @requires 2fa
|
|
14
|
+
* @errors 500
|
|
15
|
+
* @returns {Number} status Номер помилки
|
|
16
|
+
* @returns {String|Object} error Опис помилки
|
|
17
|
+
* @returns {String|Object} message Повідомлення про успішне виконання або об'єкт з параметрами
|
|
18
|
+
*/
|
|
19
|
+
export default async function toggleFunction(req, reply) {
|
|
20
|
+
const { pg = pgClients.client, session = {}, query = {}, } = req;
|
|
21
|
+
const { uid } = session?.passport?.user || {};
|
|
22
|
+
const { code, enable } = query;
|
|
23
|
+
if (!config.pg) {
|
|
24
|
+
return reply.status(400).send('empty pg');
|
|
25
|
+
}
|
|
26
|
+
if (!uid) {
|
|
27
|
+
return reply.status(401).send('access restricted: unauthorized');
|
|
28
|
+
}
|
|
29
|
+
if (!code) {
|
|
30
|
+
return reply.status(400).send('param "code" is required');
|
|
31
|
+
}
|
|
32
|
+
if (!Object.hasOwn(query, 'enable')) {
|
|
33
|
+
return reply.status(400).send('param "enable" is required');
|
|
34
|
+
}
|
|
35
|
+
const data = await toggle({
|
|
36
|
+
pg, code, enable: enable === 'true', uid,
|
|
37
|
+
});
|
|
38
|
+
return reply.status(200).send(data);
|
|
39
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deleteCrud.d.ts","sourceRoot":"","sources":["../../../../../server/routes/crud/controllers/deleteCrud.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AAa5C,wBAA8B,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"deleteCrud.d.ts","sourceRoot":"","sources":["../../../../../server/routes/crud/controllers/deleteCrud.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AAa5C,wBAA8B,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,YAAY,kBA8HrE"}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import config from "../../../../config.js";
|
|
2
|
+
import pgClients from "../../../plugins/pg/pgClients.js";
|
|
3
|
+
import getAccess from "../../../plugins/crud/funcs/getAccess.js";
|
|
4
|
+
import getToken from "../../../plugins/crud/funcs/getToken.js";
|
|
5
|
+
import applyHook from "../../../plugins/hook/applyHook.js";
|
|
6
|
+
import getOpt from "../../../plugins/crud/funcs/getOpt.js";
|
|
7
|
+
import getTemplate from "../../../plugins/table/funcs/getTemplate.js";
|
|
8
|
+
import dataDelete from "../../../plugins/crud/funcs/dataDelete.js";
|
|
2
9
|
export default async function deleteCrud(req, reply) {
|
|
3
|
-
const { pg = pgClients.client, user = {}, params = {}, headers = {}, } = req || {};
|
|
10
|
+
const { pg = pgClients.client, user = {}, params = {}, headers = {}, method, } = req || {};
|
|
4
11
|
const hookData = (await applyHook("preDelete", {
|
|
5
12
|
pg,
|
|
6
13
|
table: params?.table,
|
|
@@ -29,7 +36,7 @@ export default async function deleteCrud(req, reply) {
|
|
|
29
36
|
code: 403,
|
|
30
37
|
});
|
|
31
38
|
}
|
|
32
|
-
const { actions = [] } = (await getAccess({ table: del, id, user }, pg)) || {};
|
|
39
|
+
const { actions = [] } = (await getAccess({ table: del, id, user, method }, pg)) || {};
|
|
33
40
|
if (!tokenData &&
|
|
34
41
|
!config?.local &&
|
|
35
42
|
!config.security?.disableToken &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insert.d.ts","sourceRoot":"","sources":["../../../../../server/routes/crud/controllers/insert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"insert.d.ts","sourceRoot":"","sources":["../../../../../server/routes/crud/controllers/insert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AAe5C,wBAA8B,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,YAAY,kBA6KjE"}
|
|
@@ -1,6 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import config from "../../../../config.js";
|
|
2
|
+
import applyHook from "../../../plugins/hook/applyHook.js";
|
|
3
|
+
import logger from "../../../plugins/logger/getLogger.js";
|
|
4
|
+
import pgClients from "../../../plugins/pg/pgClients.js";
|
|
5
|
+
import checkXSS from "../../../plugins/policy/funcs/checkXSS.js";
|
|
6
|
+
import checkSQL from "../../../plugins/policy/funcs/checkSQL.js";
|
|
7
|
+
import dataInsert from "../../../plugins/crud/funcs/dataInsert.js";
|
|
8
|
+
import validateData from "../../../plugins/crud/funcs/validateData.js";
|
|
9
|
+
import getAccess from "../../../plugins/crud/funcs/getAccess.js";
|
|
10
|
+
import getToken from "../../../plugins/crud/funcs/getToken.js";
|
|
11
|
+
import getTemplate from "../../../plugins/table/funcs/getTemplate.js";
|
|
2
12
|
export default async function insert(req, reply) {
|
|
3
|
-
const { pg = pgClients.client, user = {}, params = {}, body = {}, headers = {}, } = req || {};
|
|
13
|
+
const { pg = pgClients.client, user = {}, params = {}, body = {}, headers = {}, method, } = req || {};
|
|
4
14
|
if (!user) {
|
|
5
15
|
return reply.status(403).send({ error: "access restricted", code: 403 });
|
|
6
16
|
}
|
|
@@ -28,7 +38,7 @@ export default async function insert(req, reply) {
|
|
|
28
38
|
(config.security?.disableToken || config.local || config.auth?.disable
|
|
29
39
|
? req.params
|
|
30
40
|
: {});
|
|
31
|
-
const { actions = [] } = (await getAccess({ table: add, form, user }, pg)) || {};
|
|
41
|
+
const { actions = [] } = (await getAccess({ table: add, form, user, method }, pg)) || {};
|
|
32
42
|
if (!tokenData &&
|
|
33
43
|
!config.local &&
|
|
34
44
|
!config.security?.disableToken &&
|
|
@@ -126,5 +136,5 @@ export default async function insert(req, reply) {
|
|
|
126
136
|
const pk = pg.pk?.[loadTemplate?.table || table];
|
|
127
137
|
return reply
|
|
128
138
|
.status(200)
|
|
129
|
-
.send({ id: res?.rows?.[0]?.[pk], rows: res.rows, extra: res.extra });
|
|
139
|
+
.send({ id: res?.rows?.[0]?.[pk], rows: res.rows, extra: res.extra, ...(res.rows?.[0] || {}) });
|
|
130
140
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../../../server/routes/crud/controllers/table.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../../../server/routes/crud/controllers/table.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAc5C,wBAA8B,QAAQ,CACpC,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,GAAG,gBAmOZ"}
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import config from "../../../../config.js";
|
|
2
|
+
import applyHook from "../../../plugins/hook/applyHook.js";
|
|
3
|
+
import pgClients from "../../../plugins/pg/pgClients.js";
|
|
4
|
+
import getMeta from "../../../plugins/pg/funcs/getMeta.js";
|
|
5
|
+
import getAccess from "../../../plugins/crud/funcs/getAccess.js";
|
|
6
|
+
import getToken from "../../../plugins/crud/funcs/getToken.js";
|
|
7
|
+
import setToken from "../../../plugins/crud/funcs/setToken.js";
|
|
8
|
+
import getTemplate from "../../../plugins/table/funcs/getTemplate.js";
|
|
2
9
|
import extraDataGet from "../../../plugins/extra/extraDataGet.js";
|
|
3
10
|
export default async function tableAPI(req, reply, called) {
|
|
4
|
-
const { pg = pgClients.client, params, user = {}, query = {} } = req;
|
|
11
|
+
const { pg = pgClients.client, params, user = {}, query = {}, method } = req;
|
|
5
12
|
const tokenData = await getToken({
|
|
6
13
|
token: params?.table,
|
|
7
14
|
uid: user.uid,
|
|
@@ -39,6 +46,7 @@ export default async function tableAPI(req, reply, called) {
|
|
|
39
46
|
form,
|
|
40
47
|
id,
|
|
41
48
|
user,
|
|
49
|
+
method,
|
|
42
50
|
}, pg)) || {};
|
|
43
51
|
if (!tokenData &&
|
|
44
52
|
!config?.local &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../../server/routes/crud/controllers/update.ts"],"names":[],"mappings":"AAeA,wBAA8B,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../../server/routes/crud/controllers/update.ts"],"names":[],"mappings":"AAeA,wBAA8B,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,gBA8LxD"}
|
|
@@ -1,8 +1,19 @@
|
|
|
1
|
-
import { pgClients, applyHook, getAccess, getTemplate, checkXSS, checkSQL, dataUpdate, logger, getToken, validateData, } from "../../../../utils.js";
|
|
2
1
|
import config from "../../../../config.js";
|
|
2
|
+
import applyHook from "../../../plugins/hook/applyHook.js";
|
|
3
|
+
import logger from "../../../plugins/logger/getLogger.js";
|
|
4
|
+
import pgClients from "../../../plugins/pg/pgClients.js";
|
|
5
|
+
import checkXSS from "../../../plugins/policy/funcs/checkXSS.js";
|
|
6
|
+
import checkSQL from "../../../plugins/policy/funcs/checkSQL.js";
|
|
7
|
+
import dataUpdate from "../../../plugins/crud/funcs/dataUpdate.js";
|
|
8
|
+
import validateData from "../../../plugins/crud/funcs/validateData.js";
|
|
9
|
+
import getAccess from "../../../plugins/crud/funcs/getAccess.js";
|
|
10
|
+
import getToken from "../../../plugins/crud/funcs/getToken.js";
|
|
11
|
+
import getTemplate from "../../../plugins/table/funcs/getTemplate.js";
|
|
3
12
|
import insert from "./insert.js";
|
|
4
13
|
export default async function update(req, reply) {
|
|
5
|
-
const { pg = pgClients.client, user, params = {}, body = {}, headers = {},
|
|
14
|
+
const { pg = pgClients.client, user, params = {}, body = {}, headers = {}, method, } = req;
|
|
15
|
+
const { referer } = headers;
|
|
16
|
+
const unittest = process.env.NODE_ENV === 'test' || process.env.VITEST;
|
|
6
17
|
if (!user) {
|
|
7
18
|
return reply.status(403).send({ error: "access restricted", code: 403 });
|
|
8
19
|
}
|
|
@@ -18,7 +29,6 @@ export default async function update(req, reply) {
|
|
|
18
29
|
: hookData.message;
|
|
19
30
|
return reply.status(hookData.status).send(response);
|
|
20
31
|
}
|
|
21
|
-
const { referer } = headers;
|
|
22
32
|
const tokenData = await getToken({
|
|
23
33
|
uid: user.uid,
|
|
24
34
|
token: body.token || params.id || params.table,
|
|
@@ -35,6 +45,7 @@ export default async function update(req, reply) {
|
|
|
35
45
|
form,
|
|
36
46
|
id,
|
|
37
47
|
user,
|
|
48
|
+
method,
|
|
38
49
|
}, pg)) || {};
|
|
39
50
|
if (!tokenData &&
|
|
40
51
|
!config.local &&
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import config from "../../../../../config.js";
|
|
2
|
+
const { accessToken = "0NWcGQxKRP8AsRxD" } = config.auth || {};
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @summary check user access to logger interface - per admin user type or user group
|
|
6
|
+
* @returns {Object} message, status
|
|
7
|
+
*/
|
|
8
|
+
export default function checkUserAccess({ user = {}, token, }) {
|
|
9
|
+
if (token && token === accessToken) {
|
|
10
|
+
return { message: "access granted", status: 200 };
|
|
11
|
+
}
|
|
12
|
+
// console.log(user);
|
|
13
|
+
if (!user.user_type?.includes?.("admin") &&
|
|
14
|
+
!config?.local &&
|
|
15
|
+
!config.auth?.disable) {
|
|
16
|
+
return { message: "access restricted", status: 403 };
|
|
17
|
+
}
|
|
18
|
+
/* if (!['admin', 'superadmin']?.includes(user.user_type) && count === '0') {
|
|
19
|
+
return { message: 'access restricted', status: 403 };
|
|
20
|
+
} */
|
|
21
|
+
return { message: "access granted", status: 200 };
|
|
22
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import config from "../../../../../config.js";
|
|
5
|
+
// import { existsSync } from 'fs';
|
|
6
|
+
let logDir = null;
|
|
7
|
+
export default function getRootDir() {
|
|
8
|
+
// absolute / relative path
|
|
9
|
+
if (logDir)
|
|
10
|
+
return logDir;
|
|
11
|
+
const file = ["config.json", "/data/local/config.json"].find((el) => fs.existsSync(el) ? el : null);
|
|
12
|
+
const root = file === "config.json" ? process.cwd() : "/data/local";
|
|
13
|
+
logDir = config.logDir || path.join(root, config.log?.dir || "log");
|
|
14
|
+
console.log({ logDir });
|
|
15
|
+
return logDir;
|
|
16
|
+
// windows debug support
|
|
17
|
+
/* const customLogDir = process.cwd().includes(':') ? 'c:/data/local' : '/data/local';
|
|
18
|
+
// docker default path
|
|
19
|
+
if (existsSync(customLogDir)) {
|
|
20
|
+
return path.join(customLogDir, config.folder || '', 'log');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// non-docker default path
|
|
24
|
+
return path.join(config.root || '/data/local', config.folder || '', 'log'); */
|
|
25
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"card.d.ts","sourceRoot":"","sources":["../../../../../server/routes/table/controllers/card.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"card.d.ts","sourceRoot":"","sources":["../../../../../server/routes/table/controllers/card.ts"],"names":[],"mappings":"AAOA,wBAA8B,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,gBAmItD"}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import getAccess from "../../../plugins/crud/funcs/getAccess.js";
|
|
2
|
+
import applyHook from "../../../plugins/hook/applyHook.js";
|
|
3
|
+
import getTemplate from "../../../plugins/table/funcs/getTemplate.js";
|
|
4
|
+
import getMeta from "../../../plugins/pg/funcs/getMeta.js";
|
|
5
|
+
import pgClients from "../../../plugins/pg/pgClients.js";
|
|
6
|
+
import metaFormat from "../../../plugins/table/funcs/metaFormat/index.js";
|
|
2
7
|
export default async function card(req, reply) {
|
|
3
8
|
const time = Date.now();
|
|
4
|
-
const { pg = pgClients.client, user, params = {}, query = {} } = req;
|
|
9
|
+
const { pg = pgClients.client, user, params = {}, query = {}, method } = req;
|
|
5
10
|
const hookData = (await applyHook("preCard", {
|
|
6
11
|
table: params?.table,
|
|
7
12
|
id: params?.id,
|
|
@@ -17,6 +22,7 @@ export default async function card(req, reply) {
|
|
|
17
22
|
table: hookData?.table || params.table,
|
|
18
23
|
id: hookData?.id || params?.id,
|
|
19
24
|
user,
|
|
25
|
+
method,
|
|
20
26
|
})) || {};
|
|
21
27
|
if (!actions.includes("view") || (scope === "my" && !my)) {
|
|
22
28
|
return reply.status(403).send({ error: "access restricted", code: 403 });
|
|
@@ -74,12 +80,14 @@ export default async function card(req, reply) {
|
|
|
74
80
|
id: hookData?.id || params?.id,
|
|
75
81
|
user,
|
|
76
82
|
payload: {
|
|
83
|
+
id: hookData?.id || params?.id,
|
|
77
84
|
time: Date.now() - time,
|
|
78
85
|
data,
|
|
79
86
|
},
|
|
80
87
|
});
|
|
81
88
|
return (afterHookData || {
|
|
82
89
|
time: Date.now() - time,
|
|
90
|
+
id: hookData?.id || params?.id,
|
|
83
91
|
data,
|
|
84
92
|
});
|
|
85
93
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cardData.d.ts","sourceRoot":"","sources":["../../../../../server/routes/table/controllers/cardData.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cardData.d.ts","sourceRoot":"","sources":["../../../../../server/routes/table/controllers/cardData.ts"],"names":[],"mappings":"AAuBA,wBAA8B,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,gBAuO7D"}
|
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
/* eslint-disable no-param-reassign */
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import
|
|
3
|
+
import config from "../../../../config.js";
|
|
4
|
+
import { handlebars, handlebarsSync } from "../../../helpers/index.js";
|
|
5
|
+
import getAccess from "../../../plugins/crud/funcs/getAccess.js";
|
|
6
|
+
import setToken from "../../../plugins/crud/funcs/setToken.js";
|
|
7
|
+
import applyHook from "../../../plugins/hook/applyHook.js";
|
|
8
|
+
import setOpt from "../../../plugins/crud/funcs/setOpt.js";
|
|
9
|
+
import getTemplate from "../../../plugins/table/funcs/getTemplate.js";
|
|
10
|
+
import getData from "../functions/getData.js";
|
|
4
11
|
import conditions from "./utils/conditions.js";
|
|
5
12
|
const components = {
|
|
6
13
|
"vs-widget-file": "select 'vs-widget-file' as component, count(*) from crm.files where entity_id=$1 and file_status<>3",
|
|
7
14
|
"vs-widget-comments": "select 'vs-widget-comments' as component, count(*) from crm.communications where entity_id=$1",
|
|
8
15
|
};
|
|
9
16
|
export default async function getCardData(req, reply) {
|
|
10
|
-
const { pg, headers, params = {}, user = {} } = req;
|
|
17
|
+
const { pg, headers, params = {}, user = {}, method } = req;
|
|
11
18
|
const { table, id } = params;
|
|
12
19
|
const { uid } = user;
|
|
13
20
|
const res = await applyHook("cardData", { table, id, user });
|
|
@@ -15,7 +22,7 @@ export default async function getCardData(req, reply) {
|
|
|
15
22
|
return res;
|
|
16
23
|
const time = Date.now();
|
|
17
24
|
const template = await getTemplate("card", table);
|
|
18
|
-
const access = (await getAccess({ table, user }, pg));
|
|
25
|
+
const access = (await getAccess({ table, id, user, method }, pg));
|
|
19
26
|
if (!access?.actions?.length) {
|
|
20
27
|
return reply.status(403).send("access restricted");
|
|
21
28
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FastifyReply } from "fastify";
|
|
2
2
|
import type { ExtendedPG } from "../../../types/core.js";
|
|
3
|
-
export default function getForm({ pg, params, user, query, }: {
|
|
3
|
+
export default function getForm({ pg, params, user, query, method, }: {
|
|
4
4
|
pg: ExtendedPG;
|
|
5
5
|
params: {
|
|
6
6
|
name: string;
|
|
@@ -10,5 +10,6 @@ export default function getForm({ pg, params, user, query, }: {
|
|
|
10
10
|
query: {
|
|
11
11
|
edit?: any;
|
|
12
12
|
};
|
|
13
|
+
method: string;
|
|
13
14
|
}, reply: FastifyReply): Promise<any>;
|
|
14
15
|
//# sourceMappingURL=getFormByTable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFormByTable.d.ts","sourceRoot":"","sources":["../../../../../server/routes/table/controllers/getFormByTable.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"getFormByTable.d.ts","sourceRoot":"","sources":["../../../../../server/routes/table/controllers/getFormByTable.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAY5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAUzD,wBAA8B,OAAO,CACnC,EACE,EAAqB,EACrB,MAAM,EACN,IAAS,EACT,KAAU,EACV,MAAM,GACP,EAAE;IACD,EAAE,EAAE,UAAU,CAAC;IACf,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACtC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1B,KAAK,EAAE;QAAE,IAAI,CAAC,EAAE,GAAG,CAAA;KAAE,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;CAChB,EACD,KAAK,EAAE,YAAY,gBAsKpB"}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import getToken from "../../../plugins/crud/funcs/getToken.js";
|
|
2
|
+
import getSelectMeta from "../../../plugins/table/funcs/getSelectMeta.js";
|
|
3
|
+
import pgClients from "../../../plugins/pg/pgClients.js";
|
|
4
|
+
import config from "../../../../config.js";
|
|
5
|
+
import getAccess from "../../../plugins/crud/funcs/getAccess.js";
|
|
6
|
+
import setToken from "../../../plugins/crud/funcs/setToken.js";
|
|
7
|
+
import applyHook from "../../../plugins/hook/applyHook.js";
|
|
8
|
+
import getTemplate from "../../../plugins/table/funcs/getTemplate.js";
|
|
2
9
|
import getEditData from "../../crud/controllers/table.js";
|
|
3
10
|
import formatSchema from "./utils/formatSchema.js";
|
|
4
11
|
const q = `select
|
|
@@ -8,7 +15,7 @@ const q = `select
|
|
|
8
15
|
property_text as text
|
|
9
16
|
from admin.properties
|
|
10
17
|
where 1=1`;
|
|
11
|
-
export default async function getForm({ pg = pgClients.client, params, user = {}, query = {}, }, reply) {
|
|
18
|
+
export default async function getForm({ pg = pgClients.client, params, user = {}, query = {}, method, }, reply) {
|
|
12
19
|
const time = Date.now();
|
|
13
20
|
const edit = query.edit || params.id;
|
|
14
21
|
if (!user?.uid) {
|
|
@@ -29,7 +36,7 @@ export default async function getForm({ pg = pgClients.client, params, user = {}
|
|
|
29
36
|
if (!form) {
|
|
30
37
|
// return reply.status(404).send("form not found");
|
|
31
38
|
}
|
|
32
|
-
const { actions = [] } = (await getAccess({ table, form, user }, pg)) || {};
|
|
39
|
+
const { actions = [] } = (await getAccess({ table, id: edit, form, user, method }, pg)) || {};
|
|
33
40
|
const loadTemplate = await getTemplate("form", form || params.name);
|
|
34
41
|
if (!loadTemplate) {
|
|
35
42
|
return reply.status(404).send("form template not found");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FastifyReply } from "fastify";
|
|
2
2
|
import type { ExtendedPG } from "../../../types/core.js";
|
|
3
|
-
export default function dataAPI({ pg, params, table, id, headers, query, user, contextQuery, sufix, filterList, actions: actionsParam, columns: columnsParam, }: {
|
|
3
|
+
export default function dataAPI({ pg, params, table, id, headers, query, user, contextQuery, sufix, filterList, actions: actionsParam, accessQuery: accessQueryParam, columns: columnsParam, }: {
|
|
4
4
|
pg?: ExtendedPG;
|
|
5
5
|
params?: {
|
|
6
6
|
id?: string;
|
|
@@ -16,6 +16,7 @@ export default function dataAPI({ pg, params, table, id, headers, query, user, c
|
|
|
16
16
|
sufix?: boolean;
|
|
17
17
|
filterList?: any[];
|
|
18
18
|
actions?: string[];
|
|
19
|
+
accessQuery?: string;
|
|
19
20
|
columns?: string[];
|
|
20
21
|
}, reply1?: FastifyReply, called?: any): Promise<any>;
|
|
21
22
|
//# sourceMappingURL=getData.d.ts.map
|
|
@@ -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;AA4EzD,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,OAAO,EAAE,YAAY,GACtB,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,OAAO,CAAC,EAAE,MAAM,EAAE,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;AA4EzD,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,GACtB,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;CACpB,EACD,MAAM,CAAC,EAAE,YAAY,EACrB,MAAM,CAAC,EAAE,GAAG,gBAs0Bb"}
|
|
@@ -5,7 +5,7 @@ import getAccess from "../../../plugins/crud/funcs/getAccess.js";
|
|
|
5
5
|
import setToken from "../../../plugins/crud/funcs/setToken.js";
|
|
6
6
|
import getToken from "../../../plugins/crud/funcs/getToken.js";
|
|
7
7
|
import gisIRColumn from "../../../plugins/table/funcs/gisIRColumn.js";
|
|
8
|
-
import
|
|
8
|
+
import applyHook from "../../../plugins/hook/applyHook.js";
|
|
9
9
|
import getSelect from "../../../plugins/table/funcs/getSelect.js";
|
|
10
10
|
import setOpt from "../../../plugins/crud/funcs/setOpt.js";
|
|
11
11
|
import getOpt from "../../../plugins/crud/funcs/getOpt.js";
|
|
@@ -52,11 +52,12 @@ function getOrder(queryOrder, queryDesc, defaultOrder, columnList, iscalled = fa
|
|
|
52
52
|
const checkInline = {};
|
|
53
53
|
const maxLimit = 100;
|
|
54
54
|
const defaultLimit = 20;
|
|
55
|
-
export default async function dataAPI({ pg = pgClients.client, params, table, id, headers = {}, query = {}, user = {}, contextQuery, sufix = true, filterList, actions: actionsParam, columns: columnsParam, }, reply1, called) {
|
|
55
|
+
export default async function dataAPI({ pg = pgClients.client, params, table, id, headers = {}, query = {}, user = {}, contextQuery, sufix = true, filterList, actions: actionsParam, accessQuery: accessQueryParam, columns: columnsParam, }, reply1, called) {
|
|
56
56
|
const time = Date.now();
|
|
57
57
|
const timeArr = [Date.now()];
|
|
58
58
|
const { uid } = user;
|
|
59
59
|
const reply = reply1 || mockReply;
|
|
60
|
+
const method = 'GET';
|
|
60
61
|
const checkQuery = (item) => user?.user_type === "superadmin" ? !item.includes("{{uid}}") : true;
|
|
61
62
|
const paramsTable = params?.table || table;
|
|
62
63
|
if (!paramsTable) {
|
|
@@ -127,11 +128,14 @@ export default async function dataAPI({ pg = pgClients.client, params, table, id
|
|
|
127
128
|
return reply.status(404).send("template not found");
|
|
128
129
|
}
|
|
129
130
|
const objectId = tokenData?.id || hookData?.id || params?.id || id;
|
|
130
|
-
const { actions = [], query: accessQuery } =
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
131
|
+
const { actions = [], query: accessQuery } = actionsParam
|
|
132
|
+
? { actions: actionsParam, query: accessQueryParam || "1=1" }
|
|
133
|
+
: (await getAccess({
|
|
134
|
+
table: templateName,
|
|
135
|
+
id: objectId,
|
|
136
|
+
user,
|
|
137
|
+
method,
|
|
138
|
+
}, pg));
|
|
135
139
|
const body = loadTable || hookData || tokenData;
|
|
136
140
|
const { table: table1, columns = [], sql, cardSql, form, meta, sqlColumns, public: ispublic, editable = false, } = loadTable || hookData || tokenData || params || { table };
|
|
137
141
|
if (!ispublic && !user?.uid && !called) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependencies.d.ts","sourceRoot":"","sources":["../../../../../server/routes/util/controllers/dependencies.ts"],"names":[],"mappings":"AAQA,wBAA8B,iBAAiB,CAAC,GAAG,EAAE,GAAG,eAUvD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
const require = createRequire(import.meta.url);
|
|
5
|
+
const pkgPath = path.join(process.cwd(), "package.json");
|
|
6
|
+
const json = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
7
|
+
export default async function dumpInstalledDeps(app) {
|
|
8
|
+
return Object.keys({
|
|
9
|
+
...json.dependencies,
|
|
10
|
+
...(json.devDependencies || {}),
|
|
11
|
+
...(json.peerDependencies || {}),
|
|
12
|
+
}).reduce((acc, curr) => Object.assign(acc, { [curr]: require(`${curr}/package.json`).version }), {});
|
|
13
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/util/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/util/index.ts"],"names":[],"mappings":"AASA,iBAAS,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,GAAE,GAAQ,QA2BtC;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -3,6 +3,7 @@ import nextId from "./controllers/next.id.js";
|
|
|
3
3
|
import statusMonitor from "./controllers/status.monitor.js";
|
|
4
4
|
import userTokens from "./controllers/user.tokens.js";
|
|
5
5
|
import codeGenerator from "./controllers/code.generator.js";
|
|
6
|
+
import dependencies from "./controllers/dependencies.js";
|
|
6
7
|
function plugin(app, opt = {}) {
|
|
7
8
|
app.get("/next-id", { config: { policy: "L0" } }, nextId);
|
|
8
9
|
app.get("/status-monitor", { config: { role: "admin" } }, statusMonitor);
|
|
@@ -13,5 +14,6 @@ function plugin(app, opt = {}) {
|
|
|
13
14
|
sessionId: req.session?.sessionId,
|
|
14
15
|
}));
|
|
15
16
|
app.get("/config", { config: { policy: "L0" /*role: "admin"*/ } }, apiConfig);
|
|
17
|
+
app.get("/dependencies", { config: { policy: "L1", role: "admin" } }, dependencies);
|
|
16
18
|
}
|
|
17
19
|
export default plugin;
|
package/package.json
CHANGED