@opengis/fastify-table 1.4.86 → 1.4.87

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,64 +1,64 @@
1
- {
2
- "name": "@opengis/fastify-table",
3
- "version": "1.4.86",
4
- "type": "module",
5
- "description": "core-plugins",
6
- "keywords": [
7
- "fastify",
8
- "table",
9
- "crud",
10
- "pg",
11
- "backend"
12
- ],
13
- "main": "index.js",
14
- "files": [
15
- "server/*",
16
- "index.js",
17
- "utils.js",
18
- "config.js",
19
- "dblist.js",
20
- "redactionList.js"
21
- ],
22
- "scripts": {
23
- "patch": "npm version patch && git push && npm publish",
24
- "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
25
- "test": "node --test",
26
- "test:helpers": "node --test .\\test\\helpers",
27
- "test:routes": "node --test .\\test\\routes",
28
- "test:functions": "node --test .\\test\\functions",
29
- "compress": "node compress.js",
30
- "dev1": "set NODE_ENV=dev&& node server.js",
31
- "dev": "node --env-file=.env.dev --env-file=.env server",
32
- "start": "node --env-file=.env server"
33
- },
34
- "dependencies": {
35
- "@aws-sdk/client-s3": "3.879.0",
36
- "@aws-sdk/lib-storage": "3.879.0",
37
- "@fastify/http-proxy": "11.1.2",
38
- "@fastify/multipart": "9.0.3",
39
- "@fastify/rate-limit": "10.3.0",
40
- "@grpc/grpc-js": "1.10.6",
41
- "@grpc/proto-loader": "0.7.12",
42
- "better-sqlite3": "12.2.0",
43
- "dotenv": "16.5.0",
44
- "fastify": "5.3.3",
45
- "fastify-plugin": "5.0.1",
46
- "handlebars": "4.7.8",
47
- "image-size": "1.2.0",
48
- "ioredis": "5.3.2",
49
- "js-yaml": "4.1.0",
50
- "markdown-it": "14.1.0",
51
- "pg": "8.11.3",
52
- "pino": "9.5.0",
53
- "pino-abstract-transport": "2.0.0",
54
- "promised-handlebars": "2.0.1",
55
- "qrcode": "1.5.4",
56
- "uglify-js": "3.19.3"
57
- },
58
- "devDependencies": {
59
- "eslint": "^8.49.0",
60
- "eslint-config-airbnb": "^19.0.4"
61
- },
62
- "author": "Softpro",
63
- "license": "ISC"
64
- }
1
+ {
2
+ "name": "@opengis/fastify-table",
3
+ "version": "1.4.87",
4
+ "type": "module",
5
+ "description": "core-plugins",
6
+ "keywords": [
7
+ "fastify",
8
+ "table",
9
+ "crud",
10
+ "pg",
11
+ "backend"
12
+ ],
13
+ "main": "index.js",
14
+ "files": [
15
+ "server/*",
16
+ "index.js",
17
+ "utils.js",
18
+ "config.js",
19
+ "dblist.js",
20
+ "redactionList.js"
21
+ ],
22
+ "scripts": {
23
+ "patch": "npm version patch && git push && npm publish",
24
+ "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
25
+ "test": "node --test",
26
+ "test:helpers": "node --test .\\test\\helpers",
27
+ "test:routes": "node --test .\\test\\routes",
28
+ "test:functions": "node --test .\\test\\functions",
29
+ "compress": "node compress.js",
30
+ "dev1": "set NODE_ENV=dev&& node server.js",
31
+ "dev": "node --env-file=.env.dev --env-file=.env server",
32
+ "start": "node --env-file=.env server"
33
+ },
34
+ "dependencies": {
35
+ "@aws-sdk/client-s3": "3.879.0",
36
+ "@aws-sdk/lib-storage": "3.879.0",
37
+ "@fastify/http-proxy": "11.1.2",
38
+ "@fastify/multipart": "9.0.3",
39
+ "@fastify/rate-limit": "10.3.0",
40
+ "@grpc/grpc-js": "1.10.6",
41
+ "@grpc/proto-loader": "0.7.12",
42
+ "better-sqlite3": "12.2.0",
43
+ "dotenv": "16.5.0",
44
+ "fastify": "5.3.3",
45
+ "fastify-plugin": "5.0.1",
46
+ "handlebars": "4.7.8",
47
+ "image-size": "1.2.0",
48
+ "ioredis": "5.3.2",
49
+ "js-yaml": "4.1.0",
50
+ "markdown-it": "14.1.0",
51
+ "pg": "8.11.3",
52
+ "pino": "9.5.0",
53
+ "pino-abstract-transport": "2.0.0",
54
+ "promised-handlebars": "2.0.1",
55
+ "qrcode": "1.5.4",
56
+ "uglify-js": "3.19.3"
57
+ },
58
+ "devDependencies": {
59
+ "eslint": "^8.49.0",
60
+ "eslint-config-airbnb": "^19.0.4"
61
+ },
62
+ "author": "Softpro",
63
+ "license": "ISC"
64
+ }
@@ -1,18 +1,18 @@
1
- import setToken from '../../plugins/crud/funcs/setToken.js';
2
-
3
- export default function tokenFunc(params) {
4
- const { data, hash } = params;
5
-
6
- if (!data?.root?.user?.uid && !hash.uid) return '-';
7
- if (!hash || typeof hash !== 'object') return '-';
8
-
9
- // const id = hash?.edit ? hash?.id : data?.root?.id;
10
- // console.log(hash)
11
- const [token] = setToken({
12
- ids: [JSON.stringify(hash)],
13
-
14
- uid: data?.root?.user?.uid || hash.uid,
15
- array: 1,
16
- });
17
- return token;
18
- }
1
+ import setToken from '../../plugins/crud/funcs/setToken.js';
2
+
3
+ export default function tokenFunc(params) {
4
+ const { data, hash } = params;
5
+
6
+ if (!data?.root?.user?.uid && !hash.uid) return '-';
7
+ if (!hash || typeof hash !== 'object') return '-';
8
+
9
+ // const id = hash?.edit ? hash?.id : data?.root?.id;
10
+ // console.log(hash)
11
+ const [token] = setToken({
12
+ ids: [JSON.stringify(hash)],
13
+
14
+ uid: data?.root?.user?.uid || hash.uid,
15
+ array: 1,
16
+ });
17
+ return token;
18
+ }
@@ -151,5 +151,5 @@ CREATE TABLE if not exists crm.reactions (
151
151
  entity_id text NOT NULL,
152
152
  reaction_type text NOT NULL check (reaction_type in ('like', 'love', 'hate', 'wow', 'sad', 'angry')),
153
153
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
154
- FOREIGN KEY (user_id) REFERENCES admin.users(uid)
154
+ FOREIGN KEY (created_by) REFERENCES admin.users(uid)
155
155
  );
@@ -1,52 +1,52 @@
1
- import config from '../../../../config.js';
2
-
3
- import logger from '../../logger/getLogger.js';
4
- import pgClients from '../../pg/pgClients.js';
5
-
6
- import cronList from '../cronList.js';
7
- import runCron from './runCron.js';
8
- import interval2ms from './interval2ms.js';
9
-
10
- /**
11
- * interval:
12
- * - 02:54 - every day
13
- * - 2:03 - every day
14
- * - *1:43 - 2 times a day
15
- * - *12:03 - 2 times a day
16
- * - **:54 - every hour
17
- * - **:*3 - every 10 minutes
18
- * - 60 - every minute
19
- * - 10 * 60 - every 10 minutes
20
- */
21
-
22
- export default async function addCron(func, interval, pg = pgClients.client) {
23
- const { time = {}, disabled = [] } = config.cron || {};
24
-
25
- const name = func.name || func.toString().split('/').at(-1).split('\'')[0];
26
-
27
- // if (!config.isServer) return;
28
-
29
- if (disabled.includes(name)) {
30
- logger.file('cron', { name, message: 'cron disabled' });
31
- return;
32
- }
33
-
34
- cronList[name] = func;
35
-
36
- const userInterval = time[name] || interval;
37
- const [waitMs, intervalMs] = interval2ms[typeof interval](userInterval);
38
-
39
- if (intervalMs < 1000) {
40
- logger.file('cron', { name, error: `interval ${interval} too small` });
41
- return;
42
- }
43
-
44
- // setTimeout to w8 for the time to start
45
- setTimeout(() => {
46
- runCron({ pg, func, name });
47
- // interval
48
- setInterval(() => {
49
- runCron({ pg, func, name });
50
- }, intervalMs);
51
- }, waitMs);
52
- }
1
+ import config from '../../../../config.js';
2
+
3
+ import logger from '../../logger/getLogger.js';
4
+ import pgClients from '../../pg/pgClients.js';
5
+
6
+ import cronList from '../cronList.js';
7
+ import runCron from './runCron.js';
8
+ import interval2ms from './interval2ms.js';
9
+
10
+ /**
11
+ * interval:
12
+ * - 02:54 - every day
13
+ * - 2:03 - every day
14
+ * - *1:43 - 2 times a day
15
+ * - *12:03 - 2 times a day
16
+ * - **:54 - every hour
17
+ * - **:*3 - every 10 minutes
18
+ * - 60 - every minute
19
+ * - 10 * 60 - every 10 minutes
20
+ */
21
+
22
+ export default async function addCron(func, interval, pg = pgClients.client) {
23
+ const { time = {}, disabled = [] } = config.cron || {};
24
+
25
+ const name = func.name || func.toString().split('/').at(-1).split('\'')[0];
26
+
27
+ // if (!config.isServer) return;
28
+
29
+ if (disabled.includes(name)) {
30
+ logger.file('cron', { name, message: 'cron disabled' });
31
+ return;
32
+ }
33
+
34
+ cronList[name] = func;
35
+
36
+ const userInterval = time[name] || interval;
37
+ const [waitMs, intervalMs] = interval2ms[typeof interval](userInterval);
38
+
39
+ if (intervalMs < 1000) {
40
+ logger.file('cron', { name, error: `interval ${interval} too small` });
41
+ return;
42
+ }
43
+
44
+ // setTimeout to w8 for the time to start
45
+ setTimeout(() => {
46
+ runCron({ pg, func, name });
47
+ // interval
48
+ setInterval(() => {
49
+ runCron({ pg, func, name });
50
+ }, intervalMs);
51
+ }, waitMs);
52
+ }
@@ -1,14 +1,14 @@
1
- import config from '../../../../config.js';
2
- import getRedis from '../../redis/funcs/getRedis.js';
3
-
4
- const rclient = getRedis({ db: 0 });
5
-
6
- export default async function getOpt(token, uid = 0) {
7
- if (!config.redis) return null;
8
-
9
- const key = `opt:${uid}:${token}`;
10
- // console.log(key);
11
- const data = await rclient.get(key);
12
- if (!data) return null;
13
- return JSON.parse(data);
14
- }
1
+ import config from '../../../../config.js';
2
+ import getRedis from '../../redis/funcs/getRedis.js';
3
+
4
+ const rclient = getRedis({ db: 0 });
5
+
6
+ export default async function getOpt(token, uid = 0) {
7
+ if (!config.redis) return null;
8
+
9
+ const key = `opt:${uid}:${token}`;
10
+ // console.log(key);
11
+ const data = await rclient.get(key);
12
+ if (!data) return null;
13
+ return JSON.parse(data);
14
+ }
@@ -1,11 +1,11 @@
1
- import path from 'node:path';
2
-
3
- import config from '../../../../../config.js';
4
-
5
- export default function getFolder(req, type = 'server') {
6
- if (!['server', 'local'].includes(type)) throw new Error('params type is invalid');
7
- const types = { local: req.root || config.root, server: req.mapServerRoot || config.mapServerRoot };
8
- const dbname = req.pg?.options?.database || req.pg?.database || config.pg?.database; // request / config params / default config params
9
- const filepath = path.posix.join(types[type] || `/data/local/${dbname || ''}`, req.folder || config.folder || '');
10
- return filepath;
11
- }
1
+ import path from 'node:path';
2
+
3
+ import config from '../../../../../config.js';
4
+
5
+ export default function getFolder(req, type = 'server') {
6
+ if (!['server', 'local'].includes(type)) throw new Error('params type is invalid');
7
+ const types = { local: req.root || config.root, server: req.mapServerRoot || config.mapServerRoot };
8
+ const dbname = req.pg?.options?.database || req.pg?.database || config.pg?.database; // request / config params / default config params
9
+ const filepath = path.posix.join(types[type] || `/data/local/${dbname || ''}`, req.folder || config.folder || '');
10
+ return filepath;
11
+ }
@@ -1,19 +1,19 @@
1
- import applyHookSync from '../hook/funcs/applyHookSync.js';
2
-
3
- function errorStatus(error) {
4
- const hook = applyHookSync('errorStatus', error);
5
- if (hook) return hook;
6
-
7
- if (error.routine === 'exec_stmt_raise' && error.file === 'pl_exec.c') {
8
- return 601;
9
- }
10
- if (error.routine === 'ExecConstraints') {
11
- return 602;
12
- }
13
- if (error.type === 'DatabaseError') {
14
- return 600;
15
- }
16
-
17
- return 500;
18
- }
19
- export default errorStatus;
1
+ import applyHookSync from '../hook/funcs/applyHookSync.js';
2
+
3
+ function errorStatus(error) {
4
+ const hook = applyHookSync('errorStatus', error);
5
+ if (hook) return hook;
6
+
7
+ if (error.routine === 'exec_stmt_raise' && error.file === 'pl_exec.c') {
8
+ return 601;
9
+ }
10
+ if (error.routine === 'ExecConstraints') {
11
+ return 602;
12
+ }
13
+ if (error.type === 'DatabaseError') {
14
+ return 600;
15
+ }
16
+
17
+ return 500;
18
+ }
19
+ export default errorStatus;
@@ -1,8 +1,8 @@
1
- import redisClients from './funcs/redisClients.js';
2
- import getRedis from './funcs/getRedis.js';
3
-
4
- if (!redisClients[0]) {
5
- getRedis({ db: 0 });
6
- }
7
-
8
- export default redisClients[0];
1
+ import redisClients from './funcs/redisClients.js';
2
+ import getRedis from './funcs/getRedis.js';
3
+
4
+ if (!redisClients[0]) {
5
+ getRedis({ db: 0 });
6
+ }
7
+
8
+ export default redisClients[0];
@@ -1,3 +1,3 @@
1
- const redisClients = {};
2
-
3
- export default redisClients;
1
+ const redisClients = {};
2
+
3
+ export default redisClients;
@@ -1,13 +1,13 @@
1
- async function getCustomQuery({
2
- pg, table, customFilter,
3
- }) {
4
- if (!customFilter) return null;
5
- const customFilterList = customFilter?.split(',')?.map((el) => el?.split('_').pop());
6
- const { property_json: customFilterSQL } = await pg.one(`select json_agg(json_build_object('id',property_id,'name',property_key,'query',property_text)
7
- ) as property_json from admin.properties where property_key is not null and property_entity='customQuery' and object_id=$1`, [table]);
8
- const data = customFilterSQL?.length ? customFilterSQL.filter((el) => customFilterList.includes(el.id)) || [] : [];
9
- const customQuery = data?.map((el) => el.query).join(' and ');
10
- return `${customQuery}`;
11
- }
12
-
13
- export default getCustomQuery;
1
+ async function getCustomQuery({
2
+ pg, table, customFilter,
3
+ }) {
4
+ if (!customFilter) return null;
5
+ const customFilterList = customFilter?.split(',')?.map((el) => el?.split('_').pop());
6
+ const { property_json: customFilterSQL } = await pg.one(`select json_agg(json_build_object('id',property_id,'name',property_key,'query',property_text)
7
+ ) as property_json from admin.properties where property_key is not null and property_entity='customQuery' and object_id=$1`, [table]);
8
+ const data = customFilterSQL?.length ? customFilterSQL.filter((el) => customFilterList.includes(el.id)) || [] : [];
9
+ const customQuery = data?.map((el) => el.query).join(' and ');
10
+ return `${customQuery}`;
11
+ }
12
+
13
+ export default getCustomQuery;
@@ -1,34 +1,34 @@
1
- function getTable(table) {
2
- const result = table?.toLowerCase()?.replace(/[\n\r]+/g, ' ')?.split(' from ')?.filter((el) => /^[a-z0-9_]+\.[a-z0-9_]+/.test(el))
3
- ?.map((el) => el.split(/[ )]/)[0]);
4
- return result;
5
- }
6
-
7
- /**
8
- * @param {Number} opt.json - (1|0) 1 - Результат - Object, 0 - String
9
- * @param {String} opt.query - запит до таблиці
10
- * @param {String} opt.hash - інформація з хешу по запиту
11
- */
12
- const tableSql = {};
13
- async function getTableSql({
14
- pg, body, table, fields,
15
- }) {
16
- if (tableSql[table]) return tableSql[table];
17
-
18
- const fieldList = fields.map((el) => el.name);
19
-
20
- const tableList = body?.sql?.map((el) => getTable(el.sql)).reduce((acc, el) => acc.concat(el), []).filter((el) => fieldList.includes(pg.pk[el]));
21
-
22
- if (!tableList) { tableSql[table] = []; return []; }
23
-
24
- const data = await Promise.all(tableList?.map(async (tableEl) => {
25
- const { fields: fieldsEl } = await pg.query(`select * from ${tableEl} limit 0`);
26
- return fieldsEl.map((el) => ({ name: el.name, table: tableEl, pk: pg.pk[tableEl] }));
27
- }));
28
-
29
- tableSql[table] = data.reduce((acc, el) => acc.concat(el), []);
30
-
31
- return tableSql[table];
32
- }
33
-
34
- export default getTableSql;
1
+ function getTable(table) {
2
+ const result = table?.toLowerCase()?.replace(/[\n\r]+/g, ' ')?.split(' from ')?.filter((el) => /^[a-z0-9_]+\.[a-z0-9_]+/.test(el))
3
+ ?.map((el) => el.split(/[ )]/)[0]);
4
+ return result;
5
+ }
6
+
7
+ /**
8
+ * @param {Number} opt.json - (1|0) 1 - Результат - Object, 0 - String
9
+ * @param {String} opt.query - запит до таблиці
10
+ * @param {String} opt.hash - інформація з хешу по запиту
11
+ */
12
+ const tableSql = {};
13
+ async function getTableSql({
14
+ pg, body, table, fields,
15
+ }) {
16
+ if (tableSql[table]) return tableSql[table];
17
+
18
+ const fieldList = fields.map((el) => el.name);
19
+
20
+ const tableList = body?.sql?.map((el) => getTable(el.sql)).reduce((acc, el) => acc.concat(el), []).filter((el) => fieldList.includes(pg.pk[el]));
21
+
22
+ if (!tableList) { tableSql[table] = []; return []; }
23
+
24
+ const data = await Promise.all(tableList?.map(async (tableEl) => {
25
+ const { fields: fieldsEl } = await pg.query(`select * from ${tableEl} limit 0`);
26
+ return fieldsEl.map((el) => ({ name: el.name, table: tableEl, pk: pg.pk[tableEl] }));
27
+ }));
28
+
29
+ tableSql[table] = data.reduce((acc, el) => acc.concat(el), []);
30
+
31
+ return tableSql[table];
32
+ }
33
+
34
+ export default getTableSql;
@@ -1,19 +1,19 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
-
4
- import config from '../../../../config.js';
5
-
6
- const loadTemplate = {};
7
-
8
- export default async function getTemplateDir(type) {
9
- if (!type) return null;
10
-
11
- const cwd = process.cwd();
12
- const typeDir = path.join(cwd, (config.templateDir || 'server/templates'), type);
13
-
14
- if (!loadTemplate[type]) {
15
- const typeList = fs.existsSync(typeDir) ? fs.readdirSync(typeDir) : [];
16
- loadTemplate[type] = typeList;
17
- }
18
- return loadTemplate[type];
19
- }
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+
4
+ import config from '../../../../config.js';
5
+
6
+ const loadTemplate = {};
7
+
8
+ export default async function getTemplateDir(type) {
9
+ if (!type) return null;
10
+
11
+ const cwd = process.cwd();
12
+ const typeDir = path.join(cwd, (config.templateDir || 'server/templates'), type);
13
+
14
+ if (!loadTemplate[type]) {
15
+ const typeList = fs.existsSync(typeDir) ? fs.readdirSync(typeDir) : [];
16
+ loadTemplate[type] = typeList;
17
+ }
18
+ return loadTemplate[type];
19
+ }
@@ -1,82 +1,82 @@
1
- import getSelect from './getSelect.js';
2
-
3
- import getFilterSQL from './getFilterSQL/index.js';
4
- import getTemplate from './getTemplate.js';
5
- import pgClients from '../../pg/pgClients.js';
6
- import config from '../../../../config.js';
7
- import getSelectVal from './metaFormat/getSelectVal.js';
8
-
9
- export default async function gisIRColumn({
10
- pg = pgClients.client, layer, column, sql, query = '1=1', filter, state, search, custom,
11
- }) {
12
- const time = Date.now();
13
-
14
- const sel = await getSelect(query.cls || column, pg);
15
-
16
- const body = await getTemplate('table', layer);
17
- const fData = await getFilterSQL({
18
- table: layer,
19
- filter,
20
- state,
21
- search,
22
- custom,
23
- });
24
-
25
- const { tlist } = await pg.one(`select array_agg((select nspname from pg_namespace where oid=relnamespace)||'.'||relname) tlist from pg_class
26
- where relkind in ('r','v','m')`);
27
-
28
- const tableName = body?.table || layer;
29
- if (!tlist.includes(tableName)) return { error: `table not found: ${tableName}`, status: 400 };
30
-
31
- // eslint-disable-next-line max-len
32
- const { fields } = await pg.query(`select * from (${fData?.optimizedSQL || `select * from ${tableName}`})q limit 0`);
33
-
34
- const col = fields.find((el) => el.name === column);
35
-
36
- if (!col) return { status: 404, message: 'not found' };
37
- const colField = pg.pgType[col.dataTypeID]?.includes('[]') ? `unnest(${column})` : column;
38
-
39
- const q = `select ${colField} as id, count(*)::int from (
40
- ${fData?.optimizedSQL || `select * from ${tableName} where ${body?.query || 'true'}`}
41
- )t group by ${colField} order by count desc limit 15`;
42
-
43
- if (sql) return q;
44
-
45
- if (!body?.columns?.length) {
46
- const { rows } = await pg.query(q);
47
- if (sel?.arr?.length) {
48
- rows.forEach((el) => {
49
- const data = sel?.find((item) => item.id?.toString() === el.id?.toString());
50
- Object.assign(el, data || {});
51
- });
52
- }
53
- return {
54
- count: rows?.reduce((acc, el) => acc + el.count, 0),
55
- sql: config.local ? q : undefined,
56
- rows,
57
- };
58
- }
59
-
60
- const { rows } = await pg.query(q);
61
- const cls = query.cls || body?.columns?.find((el) => el.name === column)?.data || col.data || col.option;
62
- const select = await getSelectVal({
63
- pg, name: cls, values: rows.map((el) => el.id), ar: 1,
64
- });
65
- rows.forEach((el) => {
66
- if (Array.isArray(select)) {
67
- Object.assign(el, select.find((item) => item.id?.toString() === el.id?.toString()) || {});
68
- }
69
- else if (typeof select?.[el.id] === 'string') {
70
- Object.assign(el, { text: select?.[el.id] });
71
- }
72
- else {
73
- Object.assign(el, select?.[el.id] || {});
74
- }
75
- });
76
- return {
77
- time: Date.now() - time,
78
- count: rows.reduce((acc, el) => acc + el.count, 0),
79
- sql: config.local ? q : undefined,
80
- rows,
81
- };
82
- }
1
+ import getSelect from './getSelect.js';
2
+
3
+ import getFilterSQL from './getFilterSQL/index.js';
4
+ import getTemplate from './getTemplate.js';
5
+ import pgClients from '../../pg/pgClients.js';
6
+ import config from '../../../../config.js';
7
+ import getSelectVal from './metaFormat/getSelectVal.js';
8
+
9
+ export default async function gisIRColumn({
10
+ pg = pgClients.client, layer, column, sql, query = '1=1', filter, state, search, custom,
11
+ }) {
12
+ const time = Date.now();
13
+
14
+ const sel = await getSelect(query.cls || column, pg);
15
+
16
+ const body = await getTemplate('table', layer);
17
+ const fData = await getFilterSQL({
18
+ table: layer,
19
+ filter,
20
+ state,
21
+ search,
22
+ custom,
23
+ });
24
+
25
+ const { tlist } = await pg.one(`select array_agg((select nspname from pg_namespace where oid=relnamespace)||'.'||relname) tlist from pg_class
26
+ where relkind in ('r','v','m')`);
27
+
28
+ const tableName = body?.table || layer;
29
+ if (!tlist.includes(tableName)) return { error: `table not found: ${tableName}`, status: 400 };
30
+
31
+ // eslint-disable-next-line max-len
32
+ const { fields } = await pg.query(`select * from (${fData?.optimizedSQL || `select * from ${tableName}`})q limit 0`);
33
+
34
+ const col = fields.find((el) => el.name === column);
35
+
36
+ if (!col) return { status: 404, message: 'not found' };
37
+ const colField = pg.pgType[col.dataTypeID]?.includes('[]') ? `unnest(${column})` : column;
38
+
39
+ const q = `select ${colField} as id, count(*)::int from (
40
+ ${fData?.optimizedSQL || `select * from ${tableName} where ${body?.query || 'true'}`}
41
+ )t group by ${colField} order by count desc limit 15`;
42
+
43
+ if (sql) return q;
44
+
45
+ if (!body?.columns?.length) {
46
+ const { rows } = await pg.query(q);
47
+ if (sel?.arr?.length) {
48
+ rows.forEach((el) => {
49
+ const data = sel?.find((item) => item.id?.toString() === el.id?.toString());
50
+ Object.assign(el, data || {});
51
+ });
52
+ }
53
+ return {
54
+ count: rows?.reduce((acc, el) => acc + el.count, 0),
55
+ sql: config.local ? q : undefined,
56
+ rows,
57
+ };
58
+ }
59
+
60
+ const { rows } = await pg.query(q);
61
+ const cls = query.cls || body?.columns?.find((el) => el.name === column)?.data || col.data || col.option;
62
+ const select = await getSelectVal({
63
+ pg, name: cls, values: rows.map((el) => el.id), ar: 1,
64
+ });
65
+ rows.forEach((el) => {
66
+ if (Array.isArray(select)) {
67
+ Object.assign(el, select.find((item) => item.id?.toString() === el.id?.toString()) || {});
68
+ }
69
+ else if (typeof select?.[el.id] === 'string') {
70
+ Object.assign(el, { text: select?.[el.id] });
71
+ }
72
+ else {
73
+ Object.assign(el, select?.[el.id] || {});
74
+ }
75
+ });
76
+ return {
77
+ time: Date.now() - time,
78
+ count: rows.reduce((acc, el) => acc + el.count, 0),
79
+ sql: config.local ? q : undefined,
80
+ rows,
81
+ };
82
+ }
@@ -1 +1 @@
1
- export default {};
1
+ export default {};
@@ -1 +1 @@
1
- export default {};
1
+ export default {};
@@ -1 +1 @@
1
- export default [];
1
+ export default [];
@@ -1,74 +1,74 @@
1
- import {
2
- getMeta, metaFormat, getTemplates, getTemplate, handlebars,
3
- } from '../../../../utils.js';
4
-
5
- function sequence(tables, data, fn) {
6
- return tables.reduce((promise, table) => promise.then(() => fn({
7
- ...data, tableName: table.replace('.json', ''),
8
- })), Promise.resolve());
9
- }
10
-
11
- async function getData({
12
- pg, tableName, query = {}, maxLimit, res,
13
- }) {
14
- const loadTable = await getTemplate('table', tableName);
15
-
16
- if (!loadTable) { return { message: 'not found', status: 404 }; }
17
-
18
- const {
19
- table, columns, meta,
20
- } = loadTable;
21
-
22
- const { pk } = await getMeta(table);
23
-
24
- const cols = columns.map((el) => el.name || el).join(',');
25
- const [orderColumn, orderDir] = (query.order || loadTable.order || '').split('-');
26
- const order = cols.includes(orderColumn) && orderColumn?.length ? `order by ${orderColumn} ${query.desc || orderDir === 'desc' ? 'desc' : ''}` : '';
27
-
28
- const limit = Math.max(maxLimit - res.rows.length, 0);
29
- // Math.max(query.offset - res.rows.length,0)
30
- const offset = query.page && query.page > 0 ? ` offset ${(query.page - 1) * limit}` : '';
31
-
32
- const search1 = meta?.search && query.key ? `(${meta?.search.concat(meta?.title ? `,${meta?.title}` : '').split(',').map(el => `${el} ilike '%${query.key}%'`).join(' or ')})` : 'false';
33
-
34
- const where = [!pk ? 'false' : 'true', loadTable.query, search1].filter((el) => el);
35
- const q = `select ${[`"${pk}" as id`, meta?.title ? `${meta.title} as title` : ''].filter((el) => el).join(',')} from ${table} t where ${where.join(' and ') || 'true'} ${order} ${offset} limit ${limit}`;
36
- if (query.sql) {
37
- res.sql.push(q);
38
- return null;
39
- }
40
-
41
- const { rows } = await pg.query(q);
42
-
43
- const total = await pg.queryCache(`select count(*) from ${table} t where ${where.join(' and ') || 'true'}`).then((el) => el?.rows[0]?.count) || 0;
44
-
45
- await metaFormat({ rows, table: tableName });
46
- res.total += +total;
47
- rows.forEach((row) => {
48
- const href = meta?.href ? handlebars.compile(meta.href)({ ...row, [pk]: row.id }) : undefined;
49
- res.rows.push({
50
- ...row, register: tableName, register_title: loadTable.ua, href,
51
- });
52
- });
53
- return null;
54
- }
55
-
56
- export default async function search({
57
- pg, funcs, query = {},
58
- }) {
59
- const time = Date.now();
60
-
61
- const tables = query.table ? [query.table] : await getTemplates('table');
62
- const res = { rows: [], sql: [], total: 0 };
63
-
64
- const maxLimit = Math.min(100, query.limit || '16');
65
- await sequence(tables, {
66
- pg, funcs, query, maxLimit, res,
67
- }, getData);
68
-
69
- if (query.sql) return res.sql.join(';\n');
70
-
71
- return {
72
- time: Date.now() - time, total: res.total, count: res.rows.length, rows: res.rows,
73
- };
74
- }
1
+ import {
2
+ getMeta, metaFormat, getTemplates, getTemplate, handlebars,
3
+ } from '../../../../utils.js';
4
+
5
+ function sequence(tables, data, fn) {
6
+ return tables.reduce((promise, table) => promise.then(() => fn({
7
+ ...data, tableName: table.replace('.json', ''),
8
+ })), Promise.resolve());
9
+ }
10
+
11
+ async function getData({
12
+ pg, tableName, query = {}, maxLimit, res,
13
+ }) {
14
+ const loadTable = await getTemplate('table', tableName);
15
+
16
+ if (!loadTable) { return { message: 'not found', status: 404 }; }
17
+
18
+ const {
19
+ table, columns, meta,
20
+ } = loadTable;
21
+
22
+ const { pk } = await getMeta(table);
23
+
24
+ const cols = columns.map((el) => el.name || el).join(',');
25
+ const [orderColumn, orderDir] = (query.order || loadTable.order || '').split('-');
26
+ const order = cols.includes(orderColumn) && orderColumn?.length ? `order by ${orderColumn} ${query.desc || orderDir === 'desc' ? 'desc' : ''}` : '';
27
+
28
+ const limit = Math.max(maxLimit - res.rows.length, 0);
29
+ // Math.max(query.offset - res.rows.length,0)
30
+ const offset = query.page && query.page > 0 ? ` offset ${(query.page - 1) * limit}` : '';
31
+
32
+ const search1 = meta?.search && query.key ? `(${meta?.search.concat(meta?.title ? `,${meta?.title}` : '').split(',').map(el => `${el} ilike '%${query.key}%'`).join(' or ')})` : 'false';
33
+
34
+ const where = [!pk ? 'false' : 'true', loadTable.query, search1].filter((el) => el);
35
+ const q = `select ${[`"${pk}" as id`, meta?.title ? `${meta.title} as title` : ''].filter((el) => el).join(',')} from ${table} t where ${where.join(' and ') || 'true'} ${order} ${offset} limit ${limit}`;
36
+ if (query.sql) {
37
+ res.sql.push(q);
38
+ return null;
39
+ }
40
+
41
+ const { rows } = await pg.query(q);
42
+
43
+ const total = await pg.queryCache(`select count(*) from ${table} t where ${where.join(' and ') || 'true'}`).then((el) => el?.rows[0]?.count) || 0;
44
+
45
+ await metaFormat({ rows, table: tableName });
46
+ res.total += +total;
47
+ rows.forEach((row) => {
48
+ const href = meta?.href ? handlebars.compile(meta.href)({ ...row, [pk]: row.id }) : undefined;
49
+ res.rows.push({
50
+ ...row, register: tableName, register_title: loadTable.ua, href,
51
+ });
52
+ });
53
+ return null;
54
+ }
55
+
56
+ export default async function search({
57
+ pg, funcs, query = {},
58
+ }) {
59
+ const time = Date.now();
60
+
61
+ const tables = query.table ? [query.table] : await getTemplates('table');
62
+ const res = { rows: [], sql: [], total: 0 };
63
+
64
+ const maxLimit = Math.min(100, query.limit || '16');
65
+ await sequence(tables, {
66
+ pg, funcs, query, maxLimit, res,
67
+ }, getData);
68
+
69
+ if (query.sql) return res.sql.join(';\n');
70
+
71
+ return {
72
+ time: Date.now() - time, total: res.total, count: res.rows.length, rows: res.rows,
73
+ };
74
+ }
@@ -32,6 +32,15 @@ const checkInline = {};
32
32
  const maxLimit = 100;
33
33
  const defaultLimit = 20;
34
34
 
35
+ function getOrder(queryOrder, queryDesc, defaultOrder, columnList = [], iscalled = false) {
36
+ if (iscalled && queryOrder) { return `order by ${queryOrder}`; }
37
+ if (!queryOrder) { return `order by ${(defaultOrder || 'true::boolean')} nulls last`; }
38
+
39
+ const orderArr = queryOrder.split(/[|]/g).map(el => el.split(/[-]/));
40
+ const validOrder = orderArr.filter(el => el[0] && columnList.includes(el[0])).map(el => `${el[0]} ${queryDesc || (el[1] === 'desc') ? 'desc' : ''}`).join(',');
41
+ return `order by ${validOrder || 'true::boolean'} nulls last`;
42
+ }
43
+
35
44
  export default async function dataAPI(req, reply, called) {
36
45
  const {
37
46
  pg = pgClients.client, params, headers = {}, query = {}, user = {}, contextQuery, sufix = true, filterList, actions: actionsParam,
@@ -183,11 +192,9 @@ export default async function dataAPI(req, reply, called) {
183
192
 
184
193
  const offset = query.page && query.page > 0 && !objectId ? ` offset ${(query.page - 1) * limit}` : '';
185
194
  // id, query, filter
186
- const [orderColumn, orderDir] = called && query.order ? [query.order] : (query.order || loadTable?.order || '').split(/[- ]/);
187
195
 
188
- const order = query.order && ((columnList.includes(orderColumn) && orderColumn?.length) || called)
189
- ? `order by ${orderColumn} ${query.desc || orderDir === 'desc' ? 'desc' : ''} ${!called ? 'nulls last' : ''}`
190
- : `order by ${(loadTable?.order || 'true::boolean')} nulls last`;
196
+ const order = getOrder(query.order, query.desc, loadTable?.order, columnList, !!called);
197
+ if (config.trace) console.log(order);
191
198
 
192
199
  const search = loadTable?.meta?.search && query.search
193
200
  ? `(${loadTable?.meta?.search?.split(',')?.map(el => `${el} ilike '%${query.search.replace(/%/g, '\\%').replace(/'/g, "''")}%'`).join(' or ')})`
@@ -1,99 +1,99 @@
1
- import config from '../../../../config.js';
2
- import isFileExists from '../../../plugins/file/isFileExists.js';
3
- import logChanges from '../../../plugins/crud/funcs/utils/logChanges.js';
4
- import pgClients from '../../../plugins/pg/pgClients.js';
5
-
6
- const isAdmin = (req) => process.env.NODE_ENV === 'admin'
7
- || config.admin
8
- || req?.hostname?.split?.(':')?.shift?.() === config.adminDomain
9
- || req?.hostname?.startsWith?.('admin');
10
-
11
- async function checkAccess(pg, objectid, id) {
12
- const { uid, filepath } = await pg.query('select uid, file_path as filepath from crm.files where entity_id=$1 and file_id=$2', [objectid, id])
13
- .then(el => el.rows?.[0] || {});
14
- return { uid, exists: filepath ? await isFileExists(filepath) : null };
15
- }
16
-
17
- /**
18
- * Дістає CRM дані для vue хешує ідентифікатори, підтягує селекти
19
- *
20
- * @method DELETE
21
- * @summary CRM дані для обраного віджета.
22
- * @priority 2
23
- * @tag table
24
- * @type api
25
- * @requires setTokenById
26
- * @requires getSelect
27
- * @param {String} id Ідентифікатор для хешування
28
- * @param {Any} sql Використовується для повернення sql запиту
29
- * @param {String} type Тип для хешування даних
30
- * @errors 400, 500
31
- * @returns {Number} status Номер помилки
32
- * @returns {String|Object} error Опис помилки
33
- * @returns {String|Object} message Повідомлення про успішне виконання або об'єкт з параметрами
34
- */
35
-
36
- export default async function widgetDel(req, reply) {
37
- const {
38
- pg = pgClients.client, params = {}, user = {},
39
- } = req;
40
-
41
- if (!user?.uid) {
42
- return reply.status(401).send('access restricted: user not authorized');
43
- }
44
-
45
- const { type, objectid, id } = params;
46
-
47
- if (!objectid) {
48
- return reply.status(400).send('not enough params: object id');
49
- }
50
-
51
- if (!id && type !== 'reaction') {
52
- return reply.status(400).send('not enough params: id');
53
- }
54
-
55
- // force delete db entry if file not exists
56
- const { exists, uid } = ['file', 'gallery'].includes(type) ? await checkAccess(pg, objectid, id) : {};
57
-
58
- if (exists && !isAdmin(req) && uid && user?.uid !== uid) {
59
- return reply.status(403).send('access restricted: file exists, not an author');
60
- }
61
-
62
- const sqls = {
63
- comment: `delete from crm.communications where entity_id=$1 and ${isAdmin(req) ? '$2=$2' : 'uid=$2'} and communication_id=$3`,
64
- checklist: `delete from crm.checklists where entity_id=$1 and ${isAdmin(req) ? '$2=$2' : 'uid=$2'} and checklist_id=$3`,
65
- file: `update crm.files set file_status=3 where entity_id=$1 and ${!exists || isAdmin(req) ? '$2=$2' : 'uid=$2'} and file_id=$3 returning uploaded_name`,
66
- gallery: `update crm.files set file_status=3 where entity_id=$1 and ${!exists || isAdmin(req) ? '$2=$2' : 'uid=$2'} and file_id=$3 returning uploaded_name`,
67
- reaction: `delete from crm.reactions where entity_id=$1 and ${isAdmin(req) ? '$2=$2' : 'created_by=$2'} and $3=$3 returning reaction_type`,
68
- };
69
-
70
- const sql = sqls[type];
71
- const table = {
72
- comment: 'crm.communications',
73
- checklist: 'crm.checklists',
74
- file: 'crm.files',
75
- gallery: 'crm.files',
76
- reaction: 'crm.reactions',
77
- }[type];
78
-
79
- if (!sql) {
80
- return reply.status(400).send('invalid widget type');
81
- }
82
-
83
- const { rows = [] } = await pg.query(sql, [objectid, user.uid, id || '']);
84
-
85
- if (type === 'reaction') {
86
- console.log('231131');
87
- }
88
-
89
- await logChanges({
90
- pg,
91
- table,
92
- id: type === 'reaction' ? objectid : id,
93
- data: rows[0],
94
- uid: user?.uid,
95
- type: 'DELETE',
96
- });
97
-
98
- return reply.status(200).send({ data: { id }, user: { uid: user.uid, name: user.user_name } });
99
- }
1
+ import config from '../../../../config.js';
2
+ import isFileExists from '../../../plugins/file/isFileExists.js';
3
+ import logChanges from '../../../plugins/crud/funcs/utils/logChanges.js';
4
+ import pgClients from '../../../plugins/pg/pgClients.js';
5
+
6
+ const isAdmin = (req) => process.env.NODE_ENV === 'admin'
7
+ || config.admin
8
+ || req?.hostname?.split?.(':')?.shift?.() === config.adminDomain
9
+ || req?.hostname?.startsWith?.('admin');
10
+
11
+ async function checkAccess(pg, objectid, id) {
12
+ const { uid, filepath } = await pg.query('select uid, file_path as filepath from crm.files where entity_id=$1 and file_id=$2', [objectid, id])
13
+ .then(el => el.rows?.[0] || {});
14
+ return { uid, exists: filepath ? await isFileExists(filepath) : null };
15
+ }
16
+
17
+ /**
18
+ * Дістає CRM дані для vue хешує ідентифікатори, підтягує селекти
19
+ *
20
+ * @method DELETE
21
+ * @summary CRM дані для обраного віджета.
22
+ * @priority 2
23
+ * @tag table
24
+ * @type api
25
+ * @requires setTokenById
26
+ * @requires getSelect
27
+ * @param {String} id Ідентифікатор для хешування
28
+ * @param {Any} sql Використовується для повернення sql запиту
29
+ * @param {String} type Тип для хешування даних
30
+ * @errors 400, 500
31
+ * @returns {Number} status Номер помилки
32
+ * @returns {String|Object} error Опис помилки
33
+ * @returns {String|Object} message Повідомлення про успішне виконання або об'єкт з параметрами
34
+ */
35
+
36
+ export default async function widgetDel(req, reply) {
37
+ const {
38
+ pg = pgClients.client, params = {}, user = {},
39
+ } = req;
40
+
41
+ if (!user?.uid) {
42
+ return reply.status(401).send('access restricted: user not authorized');
43
+ }
44
+
45
+ const { type, objectid, id } = params;
46
+
47
+ if (!objectid) {
48
+ return reply.status(400).send('not enough params: object id');
49
+ }
50
+
51
+ if (!id && type !== 'reaction') {
52
+ return reply.status(400).send('not enough params: id');
53
+ }
54
+
55
+ // force delete db entry if file not exists
56
+ const { exists, uid } = ['file', 'gallery'].includes(type) ? await checkAccess(pg, objectid, id) : {};
57
+
58
+ if (exists && !isAdmin(req) && uid && user?.uid !== uid) {
59
+ return reply.status(403).send('access restricted: file exists, not an author');
60
+ }
61
+
62
+ const sqls = {
63
+ comment: `delete from crm.communications where entity_id=$1 and ${isAdmin(req) ? '$2=$2' : 'uid=$2'} and communication_id=$3`,
64
+ checklist: `delete from crm.checklists where entity_id=$1 and ${isAdmin(req) ? '$2=$2' : 'uid=$2'} and checklist_id=$3`,
65
+ file: `update crm.files set file_status=3 where entity_id=$1 and ${!exists || isAdmin(req) ? '$2=$2' : 'uid=$2'} and file_id=$3 returning uploaded_name`,
66
+ gallery: `update crm.files set file_status=3 where entity_id=$1 and ${!exists || isAdmin(req) ? '$2=$2' : 'uid=$2'} and file_id=$3 returning uploaded_name`,
67
+ reaction: `delete from crm.reactions where entity_id=$1 and ${isAdmin(req) ? '$2=$2' : 'created_by=$2'} and $3=$3 returning reaction_type`,
68
+ };
69
+
70
+ const sql = sqls[type];
71
+ const table = {
72
+ comment: 'crm.communications',
73
+ checklist: 'crm.checklists',
74
+ file: 'crm.files',
75
+ gallery: 'crm.files',
76
+ reaction: 'crm.reactions',
77
+ }[type];
78
+
79
+ if (!sql) {
80
+ return reply.status(400).send('invalid widget type');
81
+ }
82
+
83
+ const { rows = [] } = await pg.query(sql, [objectid, user.uid, id || '']);
84
+
85
+ if (type === 'reaction') {
86
+ console.log('231131');
87
+ }
88
+
89
+ await logChanges({
90
+ pg,
91
+ table,
92
+ id: type === 'reaction' ? objectid : id,
93
+ data: rows[0],
94
+ uid: user?.uid,
95
+ type: 'DELETE',
96
+ });
97
+
98
+ return reply.status(200).send({ data: { id }, user: { uid: user.uid, name: user.user_name } });
99
+ }
@@ -1,13 +1,13 @@
1
- import pgClients from '../../../plugins/pg/pgClients.js';
2
-
3
- export default async function onWidgetSet({
4
- pg = pgClients.client, id, objectid, type, payload = {},
5
- }) {
6
- if (!id || !objectid || type !== 'gallery') {
7
- return null;
8
- }
9
- if (payload?.ismain) {
10
- await pg.query('update crm.files set ismain=false where entity_id=$1 and file_id<>$2', [objectid, id]);
11
- }
12
- return null;
13
- }
1
+ import pgClients from '../../../plugins/pg/pgClients.js';
2
+
3
+ export default async function onWidgetSet({
4
+ pg = pgClients.client, id, objectid, type, payload = {},
5
+ }) {
6
+ if (!id || !objectid || type !== 'gallery') {
7
+ return null;
8
+ }
9
+ if (payload?.ismain) {
10
+ await pg.query('update crm.files set ismain=false where entity_id=$1 and file_id<>$2', [objectid, id]);
11
+ }
12
+ return null;
13
+ }
@@ -1,38 +1,38 @@
1
- import addHook from '../../plugins/hook/funcs/addHook.js';
2
-
3
- import widgetDel from './controllers/widget.del.js';
4
- import widgetSet from './controllers/widget.set.js';
5
- import widgetGet from './controllers/widget.get.js';
6
- import fileEdit from './controllers/file.edit.js';
7
-
8
- import onWidgetSet from './hook/onWidgetSet.js';
9
-
10
- const tableSchema = {
11
- params: {
12
- type: 'object',
13
- properties: {
14
- type: { type: 'string', enum: ['gallery', 'file', 'checklist', 'history', 'comment', 'reaction'] },
15
- objectid: { type: 'string', pattern: '^([\\d\\w]+)$' },
16
- id: { type: 'string', pattern: '^([\\d\\w]+)$' },
17
- },
18
- },
19
- querystring: {
20
- type: 'object',
21
- properties: {
22
- debug: { type: 'string', pattern: '^(\\d+)$' },
23
- },
24
- },
25
- };
26
-
27
- addHook('onWidgetSet', onWidgetSet);
28
-
29
- const policy = ['site'];
30
- const params = { config: { policy }, schema: tableSchema };
31
-
32
- export default async function route(app, config = {}) {
33
- const { prefix = '/api' } = config;
34
- app.delete(`${prefix}/widget/:type/:objectid/:id`, params, widgetDel);
35
- app.post(`${prefix}/widget/:type/:objectid/:id?`, params, widgetSet);
36
- app.put(`${prefix}/file-edit/:id`, params, fileEdit);
37
- app.get(`${prefix}/widget/:type/:objectid`, { config: { policy: ['public'] }, schema: tableSchema }, widgetGet);
38
- }
1
+ import addHook from '../../plugins/hook/funcs/addHook.js';
2
+
3
+ import widgetDel from './controllers/widget.del.js';
4
+ import widgetSet from './controllers/widget.set.js';
5
+ import widgetGet from './controllers/widget.get.js';
6
+ import fileEdit from './controllers/file.edit.js';
7
+
8
+ import onWidgetSet from './hook/onWidgetSet.js';
9
+
10
+ const tableSchema = {
11
+ params: {
12
+ type: 'object',
13
+ properties: {
14
+ type: { type: 'string', enum: ['gallery', 'file', 'checklist', 'history', 'comment', 'reaction'] },
15
+ objectid: { type: 'string', pattern: '^([\\d\\w]+)$' },
16
+ id: { type: 'string', pattern: '^([\\d\\w]+)$' },
17
+ },
18
+ },
19
+ querystring: {
20
+ type: 'object',
21
+ properties: {
22
+ debug: { type: 'string', pattern: '^(\\d+)$' },
23
+ },
24
+ },
25
+ };
26
+
27
+ addHook('onWidgetSet', onWidgetSet);
28
+
29
+ const policy = ['site'];
30
+ const params = { config: { policy }, schema: tableSchema };
31
+
32
+ export default async function route(app, config = {}) {
33
+ const { prefix = '/api' } = config;
34
+ app.delete(`${prefix}/widget/:type/:objectid/:id`, params, widgetDel);
35
+ app.post(`${prefix}/widget/:type/:objectid/:id?`, params, widgetSet);
36
+ app.put(`${prefix}/file-edit/:id`, params, fileEdit);
37
+ app.get(`${prefix}/widget/:type/:objectid`, { config: { policy: ['public'] }, schema: tableSchema }, widgetGet);
38
+ }