@opengis/fastify-table 2.0.36 → 2.0.38

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 +1 @@
1
- {"version":3,"file":"validateData.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/crud/funcs/validateData.ts"],"names":[],"mappings":"AA0GA,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EACnC,IAAS,EACT,MAAW,GACZ,EAAE;IACD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC7B,OAMA"}
1
+ {"version":3,"file":"validateData.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/crud/funcs/validateData.ts"],"names":[],"mappings":"AA8GA,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EACnC,IAAS,EACT,MAAW,GACZ,EAAE;IACD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC7B,OAMA"}
@@ -28,7 +28,10 @@ function checkField(key, val, options, idx, body) {
28
28
  }
29
29
  else if (isrequired && !val) {
30
30
  if (options?.conditions) {
31
- const allowed = JSON.parse(options?.conditions?.[2] || null);
31
+ const allowed = typeof options?.conditions?.[2] === "string" &&
32
+ options?.conditions?.[2]?.startsWith("[")
33
+ ? JSON.parse(options?.conditions?.[2])
34
+ : options?.conditions?.[2];
32
35
  const check = options?.conditions?.[1] === "in" && Array.isArray(allowed)
33
36
  ? allowed.includes(body[options?.conditions?.[0] || ""])
34
37
  : body[options?.conditions?.[0] || ""] === allowed;
@@ -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,EAC5B,EAAE,EACF,KAAK,EACL,YAAY,EACb,EAAE,GAAG,0BAQL;AAED,eAAe,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?.split(',')?.map((el) => el?.split('_').pop());
5
- const { property_json: customFilterSQL } = await pg.one(`select json_agg(json_build_object('id',property_id,'name',property_key,'query',property_text)
6
- ) as property_json from admin.properties where property_key is not null and property_entity='customQuery' and object_id=$1`, [table]);
7
- const data = customFilterSQL?.length ? customFilterSQL.filter((el) => customFilterList.includes(el.id)) || [] : [];
8
- const customQuery = data?.map((el) => el.query).join(' and ');
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":"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,kBAuCpB"}
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;;;;;;;;;;;;GAkG3B"}
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 { rows } = await pgClients.client.query(`select property_key as key,property_text as val from admin.properties where property_key~'^(${config.settingKeys || "site|map|admin"})'`);
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,CAqRvE"}
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 { rows: properties = [] } = await pg.query("select column_id, name, title, format, data from admin.custom_column where entity=$1 and uid=$2 and filter", [params.table, user?.uid]);
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":"AAeA,wBAA8B,YAAY,CAAC,GAAG,EAAE,GAAG,eA6ClD"}
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 sql = `select property_key as key, property_json as json, property_int as int,
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 { rows = [] } = await pg.query(sql);
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,gBAqJpB"}
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 { rows = [] } = await pg.query(q);
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/fastify-table",
3
- "version": "2.0.36",
3
+ "version": "2.0.38",
4
4
  "type": "module",
5
5
  "description": "core-plugins",
6
6
  "keywords": [
@@ -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
- }