@opengis/fastify-table 2.0.35 → 2.0.37
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/plugins/table/funcs/getFilterSQL/util/getCustomQuery.d.ts.map +1 -1
- package/dist/server/plugins/table/funcs/getFilterSQL/util/getCustomQuery.js +14 -5
- package/dist/server/plugins/table/funcs/metaFormat/getSelectVal.d.ts.map +1 -1
- package/dist/server/plugins/table/funcs/metaFormat/getSelectVal.js +5 -2
- package/dist/server/routes/auth/controllers/page/loginTemplate.d.ts.map +1 -1
- package/dist/server/routes/auth/controllers/page/loginTemplate.js +1 -1
- package/dist/server/routes/menu/controllers/getMenu.d.ts.map +1 -1
- package/dist/server/routes/menu/controllers/getMenu.js +5 -1
- package/dist/server/routes/table/controllers/filter.d.ts.map +1 -1
- package/dist/server/routes/table/controllers/filter.js +5 -1
- package/dist/server/routes/table/controllers/form.d.ts.map +1 -1
- package/dist/server/routes/table/controllers/form.js +4 -2
- package/dist/server/routes/table/controllers/getFormByTable.d.ts.map +1 -1
- package/dist/server/routes/table/controllers/getFormByTable.js +3 -1
- package/package.json +1 -1
- package/dist/server/routes/logger/controllers/utils/checkUserAccess.js +0 -22
- package/dist/server/routes/logger/controllers/utils/getRootDir.js +0 -25
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCustomQuery.d.ts","sourceRoot":"","sources":["../../../../../../../server/plugins/table/funcs/getFilterSQL/util/getCustomQuery.ts"],"names":[],"mappings":"AAAA,iBAAe,cAAc,CAAC,
|
|
1
|
+
{"version":3,"file":"getCustomQuery.d.ts","sourceRoot":"","sources":["../../../../../../../server/plugins/table/funcs/getFilterSQL/util/getCustomQuery.ts"],"names":[],"mappings":"AAAA,iBAAe,cAAc,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,GAAG,0BAoB7D;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
async function getCustomQuery({ pg, table, customFilter }) {
|
|
2
2
|
if (!customFilter)
|
|
3
3
|
return null;
|
|
4
|
-
const customFilterList = customFilter
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
4
|
+
const customFilterList = customFilter
|
|
5
|
+
?.split(",")
|
|
6
|
+
?.map((el) => el?.split("_").pop());
|
|
7
|
+
const customFilterSQL = pg?.pk?.["admin.properties"]
|
|
8
|
+
? await pg
|
|
9
|
+
.query(`select json_agg(json_build_object('id',property_id,'name',property_key,'query',property_text)
|
|
10
|
+
) as property_json from admin.properties where property_key is not null and property_entity='customQuery' and object_id=$1`, [table])
|
|
11
|
+
.then((el) => el.rows?.[0]?.property_json || [])
|
|
12
|
+
: [];
|
|
13
|
+
const data = customFilterSQL?.length
|
|
14
|
+
? customFilterSQL.filter((el) => customFilterList.includes(el.id)) ||
|
|
15
|
+
[]
|
|
16
|
+
: [];
|
|
17
|
+
const customQuery = data?.map((el) => el.query).join(" and ");
|
|
9
18
|
return `${customQuery}`;
|
|
10
19
|
}
|
|
11
20
|
export default getCustomQuery;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSelectVal.d.ts","sourceRoot":"","sources":["../../../../../../server/plugins/table/funcs/metaFormat/getSelectVal.ts"],"names":[],"mappings":"AAaA,wBAA8B,YAAY,CAAC,EACzC,EAAqB,EACrB,IAAI,EACJ,MAAM,EAAE,YAAY,EACpB,EAAU,GACX,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"getSelectVal.d.ts","sourceRoot":"","sources":["../../../../../../server/plugins/table/funcs/metaFormat/getSelectVal.ts"],"names":[],"mappings":"AAaA,wBAA8B,YAAY,CAAC,EACzC,EAAqB,EACrB,IAAI,EACJ,MAAM,EAAE,YAAY,EACpB,EAAU,GACX,EAAE,GAAG,gBAmGL"}
|
|
@@ -33,7 +33,7 @@ export default async function getSelectVal({ pg = pgClients.client, name, values
|
|
|
33
33
|
const id = selectIds[name];
|
|
34
34
|
// cache
|
|
35
35
|
const key = `select:${name}`;
|
|
36
|
-
const cache = values?.length && config.redis
|
|
36
|
+
const cache = values?.length && config.redis && !config.disableCache
|
|
37
37
|
? (await rclient.hmget(key, values)).reduce((p, el, i) => ({
|
|
38
38
|
...p,
|
|
39
39
|
[values[i]]: el,
|
|
@@ -58,7 +58,10 @@ export default async function getSelectVal({ pg = pgClients.client, name, values
|
|
|
58
58
|
[el.id.toString()]: el.color ? el : el.text,
|
|
59
59
|
}), {}),
|
|
60
60
|
};
|
|
61
|
-
|
|
61
|
+
const cacheableValues = Object.entries(clsObj).find(([key, val]) => typeof val !== "object")
|
|
62
|
+
? Object.fromEntries(Object.entries(clsObj).filter(([key, val]) => typeof val !== "object"))
|
|
63
|
+
: null;
|
|
64
|
+
if (data?.length && config.redis && cacheableValues) {
|
|
62
65
|
rclient.hmset(key, clsObj);
|
|
63
66
|
}
|
|
64
67
|
if (ar) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loginTemplate.d.ts","sourceRoot":"","sources":["../../../../../../server/routes/auth/controllers/page/loginTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAkB,MAAM,SAAS,CAAC;AAUvD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAY5D,wBAA8B,aAAa,CACzC,GAAG,EAAE,eAAe,EACpB,KAAK,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"loginTemplate.d.ts","sourceRoot":"","sources":["../../../../../../server/routes/auth/controllers/page/loginTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAkB,MAAM,SAAS,CAAC;AAUvD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAY5D,wBAA8B,aAAa,CACzC,GAAG,EAAE,eAAe,EACpB,KAAK,EAAE,YAAY,kBAwCpB"}
|
|
@@ -16,7 +16,7 @@ const headers = {
|
|
|
16
16
|
export default async function loginTemplate(req, reply) {
|
|
17
17
|
const { pg = pgClients.client } = req;
|
|
18
18
|
const body = await getTemplate("page", "login");
|
|
19
|
-
const { rows = [] } = config.pg
|
|
19
|
+
const { rows = [] } = config.pg && pg?.pk?.["admin.properties"]
|
|
20
20
|
? await pg.query("select property_key as key, property_text as val from admin.properties where property_key is not null")
|
|
21
21
|
: {};
|
|
22
22
|
const settings = rows.reduce((p, { key, val }) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getMenu.d.ts","sourceRoot":"","sources":["../../../../../server/routes/menu/controllers/getMenu.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AA4CzD,wBAA8B,SAAS,CACrC,EACE,IAAS,EACT,OAAO,EACP,EAAqB,GACtB,EAAE;IACD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC9B,EAAE,EAAE,UAAU,CAAC;CAChB,EACD,KAAK,EAAE,YAAY,GAAG,IAAI;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"getMenu.d.ts","sourceRoot":"","sources":["../../../../../server/routes/menu/controllers/getMenu.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AA4CzD,wBAA8B,SAAS,CACrC,EACE,IAAS,EACT,OAAO,EACP,EAAqB,GACtB,EAAE;IACD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC9B,EAAE,EAAE,UAAU,CAAC;CAChB,EACD,KAAK,EAAE,YAAY,GAAG,IAAI;;;;;;;;;;;;GAuG3B"}
|
|
@@ -35,7 +35,11 @@ export default async function adminMenu({ user = {}, session, pg = pgClients.cli
|
|
|
35
35
|
return reply.status(403).send("access restricted");
|
|
36
36
|
}
|
|
37
37
|
const menus = isProduction && menuCache.length ? menuCache : await readMenu();
|
|
38
|
-
const
|
|
38
|
+
const rows = pgClients.client?.pk?.["admin.properties"]
|
|
39
|
+
? await pgClients.client
|
|
40
|
+
.query(`select property_key as key,property_text as val from admin.properties where property_key~'^(${config.settingKeys || "site|map|admin"})'`)
|
|
41
|
+
.then((el) => el.rows || [])
|
|
42
|
+
: [];
|
|
39
43
|
const settings = rows.reduce((p, { key, val }) => {
|
|
40
44
|
const [k1, k2] = key.split(".");
|
|
41
45
|
p[k1] = p[k1] || {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../../../../server/routes/table/controllers/filter.ts"],"names":[],"mappings":"AAUA,UAAU,OAAO;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC;IAC3B,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC;IAC3B,KAAK,CAAC,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC;CAC3B;AAED,wBAA8B,SAAS,CACrC,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,GAAG,EACV,QAAQ,EAAE,GAAG,GACZ,OAAO,CAAC,OAAO,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,GAAG,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../../../../server/routes/table/controllers/filter.ts"],"names":[],"mappings":"AAUA,UAAU,OAAO;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC;IAC3B,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC;IAC3B,KAAK,CAAC,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC;CAC3B;AAED,wBAA8B,SAAS,CACrC,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,GAAG,EACV,QAAQ,EAAE,GAAG,GACZ,OAAO,CAAC,OAAO,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,GAAG,GAAG,CAAC,CAyRvE"}
|
|
@@ -37,7 +37,11 @@ export default async function filterAPI(req, reply, iscalled) {
|
|
|
37
37
|
loadTable?.filterList ||
|
|
38
38
|
[]).concat(loadTable?.filterSql || []);
|
|
39
39
|
// admin.custom_column - user filter NA-165
|
|
40
|
-
const
|
|
40
|
+
const properties = pg.pk?.["admin.custom_column"]
|
|
41
|
+
? await pg
|
|
42
|
+
.query("select column_id, name, title, format, data from admin.custom_column where entity=$1 and uid=$2 and filter", [params.table, user?.uid])
|
|
43
|
+
.then((el) => el.rows || [])
|
|
44
|
+
: [];
|
|
41
45
|
properties.forEach((row) => filters.push({
|
|
42
46
|
id: row.name,
|
|
43
47
|
name: row.name,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../../../../../server/routes/table/controllers/form.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../../../../../server/routes/table/controllers/form.ts"],"names":[],"mappings":"AAiBA,wBAA8B,YAAY,CAAC,GAAG,EAAE,GAAG,eA6ClD"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { applyHook, getTemplate } from "../../../../utils.js";
|
|
2
|
-
const
|
|
2
|
+
const q = `select property_key as key, property_json as json, property_int as int,
|
|
3
3
|
property_text as text from admin.properties where 1=1`;
|
|
4
4
|
async function getSettings({ pg }) {
|
|
5
|
-
const
|
|
5
|
+
const rows = pg?.pk?.["admin.properties"]
|
|
6
|
+
? await pg.query(q).then((el) => el.rows || [])
|
|
7
|
+
: [];
|
|
6
8
|
const data = rows.reduce((acc, curr) => Object.assign(acc, { [curr.key]: curr.json || curr.int || curr.text }), {});
|
|
7
9
|
return data;
|
|
8
10
|
}
|
|
@@ -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;AAc5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAUzD,wBAA8B,OAAO,CACnC,EACE,EAAqB,EACrB,MAAM,EACN,IAAS,EACT,KAAU,GACX,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;CACvB,EACD,KAAK,EAAE,YAAY,
|
|
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;AAc5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAUzD,wBAA8B,OAAO,CACnC,EACE,EAAqB,EACrB,MAAM,EACN,IAAS,EACT,KAAU,GACX,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;CACvB,EACD,KAAK,EAAE,YAAY,gBAuJpB"}
|
|
@@ -93,7 +93,9 @@ export default async function getForm({ pg = pgClients.client, params, user = {}
|
|
|
93
93
|
const arr = JSON.stringify(loadTemplate).match(/{{settings.([^}]*)}}/g);
|
|
94
94
|
if (arr?.length) {
|
|
95
95
|
const string = JSON.stringify(loadTemplate);
|
|
96
|
-
const
|
|
96
|
+
const rows = pg?.pk?.["admin.properties"]
|
|
97
|
+
? await pg.query(q).then((el) => el.rows || [])
|
|
98
|
+
: [];
|
|
97
99
|
const settings = rows.reduce((acc, curr) => Object.assign(acc, { [curr.key]: curr.json || curr.int || curr.text }), {});
|
|
98
100
|
const match = arr.reduce((acc, curr) => Object.assign(acc, {
|
|
99
101
|
[curr]: settings[curr.replace(/^{{settings./g, "").replace(/}}$/, "")],
|
package/package.json
CHANGED
|
@@ -1,22 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
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
|
-
}
|