@opengis/fastify-table 1.3.51 → 1.3.53
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengis/fastify-table",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.53",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "core-plugins",
|
|
6
6
|
"keywords": [
|
|
@@ -32,32 +32,32 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@fastify/http-proxy": "9.5.0",
|
|
35
|
-
"@fastify/sensible": "
|
|
35
|
+
"@fastify/sensible": "5.0.0",
|
|
36
36
|
"@fastify/url-data": "5.4.0",
|
|
37
|
-
"fastify": "
|
|
38
|
-
"fastify-plugin": "
|
|
37
|
+
"fastify": "4.26.1",
|
|
38
|
+
"fastify-plugin": "4.0.0",
|
|
39
|
+
"handlebars": "4.7.8",
|
|
39
40
|
"ioredis": "5.3.2",
|
|
40
41
|
"js-yaml": "4.1.0",
|
|
41
42
|
"pg": "8.11.3",
|
|
42
43
|
"pino": "9.5.0",
|
|
43
44
|
"pino-abstract-transport": "2.0.0",
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"qrcode": "^1.5.4"
|
|
45
|
+
"promised-handlebars": "2.0.1",
|
|
46
|
+
"qrcode": "1.5.4",
|
|
47
|
+
"uglify-js": "3.19.3"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@panzoom/panzoom": "
|
|
51
|
-
"eslint": "
|
|
52
|
-
"eslint-config-airbnb": "
|
|
53
|
-
"markdown-it-abbr": "
|
|
54
|
-
"mermaid": "
|
|
50
|
+
"@panzoom/panzoom": "4.5.1",
|
|
51
|
+
"eslint": "8.49.0",
|
|
52
|
+
"eslint-config-airbnb": "19.0.4",
|
|
53
|
+
"markdown-it-abbr": "2.0.0",
|
|
54
|
+
"mermaid": "10.9.3",
|
|
55
55
|
"sass": "1.72.0",
|
|
56
|
-
"vitepress": "
|
|
57
|
-
"vitepress-plugin-mermaid": "
|
|
58
|
-
"vitepress-plugin-tabs": "
|
|
59
|
-
"vitepress-sidebar": "
|
|
60
|
-
"vue": "
|
|
56
|
+
"vitepress": "1.3.4",
|
|
57
|
+
"vitepress-plugin-mermaid": "2.0.16",
|
|
58
|
+
"vitepress-plugin-tabs": "0.5.0",
|
|
59
|
+
"vitepress-sidebar": "1.25.0",
|
|
60
|
+
"vue": "3.4.27"
|
|
61
61
|
},
|
|
62
62
|
"author": "Softpro",
|
|
63
63
|
"license": "ISC"
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
function handleData(data, curr, acc, titles = {}, plain, splittype = 1) {
|
|
2
|
+
|
|
3
|
+
const titleStr = {
|
|
4
|
+
1: `${(titles?.[curr] || curr)}\n`, // for lists
|
|
5
|
+
2: `${(titles?.[curr] || curr)}: `, // one-liner
|
|
6
|
+
3: '' // for nested lists w/ one property
|
|
7
|
+
}[splittype];
|
|
8
|
+
|
|
9
|
+
if (Array.isArray(data[curr])) {
|
|
10
|
+
const str = `${plain ? '' : '\n\n### '}${titleStr}${data[curr].map(el => {
|
|
11
|
+
if (typeof el === 'object' && !Array.isArray(el)) {
|
|
12
|
+
const str = Object.keys(el).filter(el => el !== 'id').reduce((acc1, curr1) => handleData(el, curr1, acc1, {}, 1, 3), '');
|
|
13
|
+
return `\n - ${str}`;
|
|
14
|
+
}
|
|
15
|
+
return `\n - ${el}`;
|
|
16
|
+
})}`;
|
|
17
|
+
acc += `${str}`;
|
|
18
|
+
return acc;
|
|
19
|
+
} else if (typeof data[curr] === 'object') {
|
|
20
|
+
const str = `${plain ? '' : '\n\n### '} ${titleStr}${JSON.stringify(data[curr])}`;
|
|
21
|
+
acc += str;
|
|
22
|
+
return acc;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
acc += `${plain ? '' : '\n\n### '}${titleStr}${data[curr] || ''}`;
|
|
26
|
+
return acc;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default function formatMdoc(data, titles = {}, headerColumns = [], descriptionColumns = []) {
|
|
30
|
+
if (!data) return 'empty data';
|
|
31
|
+
if (typeof data !== 'object' || Array.isArray(data)) return 'invalid data';
|
|
32
|
+
if (headerColumns && !Array.isArray(headerColumns)) return 'invalid headerColumns';
|
|
33
|
+
if (descriptionColumns && !Array.isArray(descriptionColumns)) return 'invalid descriptionColumns';
|
|
34
|
+
|
|
35
|
+
const header = Object.keys(data).filter(key => headerColumns.includes(key) && data[key]).reduce((acc, curr) => handleData(data, curr, acc, titles, 1, 2), '');
|
|
36
|
+
|
|
37
|
+
const description = Object.keys(data).filter(key => descriptionColumns.includes(key) && data[key]).reduce((acc, curr) => handleData(data, curr, acc, titles), '');
|
|
38
|
+
|
|
39
|
+
return `---\n${header}\n---${description}`.replace(/,,/g, ',');
|
|
40
|
+
};
|
|
@@ -155,7 +155,7 @@ export default async function dataAPI(req, reply, called) {
|
|
|
155
155
|
${params.id || query.key ? '*' : sqlColumns || cols || '*'}
|
|
156
156
|
${metaCols}
|
|
157
157
|
|
|
158
|
-
${dbColumns.
|
|
158
|
+
${dbColumns.filter((el) => pg.pgType?.[el.dataTypeID] === 'geometry').length ? `,${dbColumns.filter((el) => pg.pgType?.[el.dataTypeID] === 'geometry').map(el => `st_asgeojson("${el.name.replace(/'/g, "''")}")::json as "${el.name.replace(/'/g, "''")}"`).join(',')}` : ''}
|
|
159
159
|
from (select * ${sql?.filter(el => el.inline).map(el => `,(${el.sql})`).join('') || ''} from ${table} t ${sqlTable} ) t
|
|
160
160
|
|
|
161
161
|
${params.id ? cardSqlTable : ''}
|
|
@@ -167,7 +167,10 @@ export default async function dataAPI(req, reply, called) {
|
|
|
167
167
|
if (config.trace) console.log(q);
|
|
168
168
|
if (query.sql === '1') { return q; }
|
|
169
169
|
|
|
170
|
-
const { rows = [] } = await pg.query(q, (tokenData?.id || hookData?.id || params.id ? [tokenData?.id || hookData?.id || params.id] : null) || (query.key && loadTable.key ? [query.key] : []))
|
|
170
|
+
const { rows = [] } = await pg.query(q, (tokenData?.id || hookData?.id || params.id ? [tokenData?.id || hookData?.id || params.id] : null) || (query.key && loadTable.key ? [query.key] : [])).catch(err => {
|
|
171
|
+
console.error(err.toString());
|
|
172
|
+
throw new Error(err.toString());
|
|
173
|
+
});
|
|
171
174
|
|
|
172
175
|
timeArr.push(Date.now())
|
|
173
176
|
|
|
@@ -16,7 +16,7 @@ export default async function filterAPI(req) {
|
|
|
16
16
|
|
|
17
17
|
const optimizedSQL = `select * from ${loadTable.table} t ${sqlTable} where ${loadTable.query || '1=1'}`.replace(/{{uid}}/g, user?.uid);
|
|
18
18
|
|
|
19
|
-
if (query?.sql && user?.user_type === 'admin') return
|
|
19
|
+
if (query?.sql && user?.user_type === 'admin') return optimizedSQL;
|
|
20
20
|
|
|
21
21
|
const filters = (loadTable?.filter_list || loadTable?.filters || loadTable?.filterList || []).concat(loadTable?.filterSql || []);
|
|
22
22
|
|
|
@@ -36,7 +36,7 @@ export default async function filterAPI(req) {
|
|
|
36
36
|
|
|
37
37
|
filters?.forEach?.(el => Object.assign(el, { id: el.id || el.name, title: el.title || el.ua, extra: extraColumns.includes(el.id || el.name) }));
|
|
38
38
|
|
|
39
|
-
await Promise.all(filters.filter((el) => el.data && el.id && el.type !== 'Autocomplete').map(async (el) => {
|
|
39
|
+
await Promise.all(filters.filter((el) => el.data && el.id && el.type !== 'Autocomplete' && !el.sql).map(async (el) => {
|
|
40
40
|
const cls = await getSelect(el.data, pg);
|
|
41
41
|
|
|
42
42
|
if (!cls || !loadTable.table) return;
|
package/utils.js
CHANGED
|
@@ -76,6 +76,8 @@ import logChanges from './server/plugins/crud/funcs/utils/logChanges.js';
|
|
|
76
76
|
import yml2json from './server/plugins/yml/funcs/yml2json.js';
|
|
77
77
|
import json2yml from './server/plugins/yml/funcs/json2yml.js';
|
|
78
78
|
|
|
79
|
+
import formatMdoc from './server/plugins/md/funcs/formatMdoc.js';
|
|
80
|
+
|
|
79
81
|
export default null;
|
|
80
82
|
export {
|
|
81
83
|
config,
|
|
@@ -146,4 +148,6 @@ export {
|
|
|
146
148
|
|
|
147
149
|
yml2json,
|
|
148
150
|
json2yml,
|
|
151
|
+
|
|
152
|
+
formatMdoc,
|
|
149
153
|
};
|