@opengis/admin 0.2.40 → 0.2.41
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
@@ -2,7 +2,6 @@ import {
|
|
2
2
|
getTemplate, getMeta, metaFormat, applyHook, handlebars, pgClients,
|
3
3
|
} from '@opengis/fastify-table/utils.js';
|
4
4
|
|
5
|
-
const maxLimit = 100;
|
6
5
|
export default async function tableInfo(req) {
|
7
6
|
const {
|
8
7
|
pg = pgClients.client, params = {}, query = {}, user = {},
|
@@ -57,12 +56,10 @@ export default async function tableInfo(req) {
|
|
57
56
|
const cardSqlFiltered = params.id ? (cardSql?.filter?.((el) => !el?.disabled && el?.name && el?.sql?.replace) || []) : [];
|
58
57
|
const cardSqlTable = cardSqlFiltered.length ? cardSqlFiltered.map((el, i) => ` left join lateral (${el.sql.replace('{{uid}}', uid)}) ct${i} on 1=1 `).join('\n') || '' : '';
|
59
58
|
|
60
|
-
const keyQuery = query.key && loadTable.key && !(params.id) ? `${loadTable.key}=$1` : null;
|
61
|
-
|
62
59
|
const interfaceQuery = params?.query ? await handlebars.compile(params?.query)({ user, uid }) : undefined;
|
63
|
-
const where = [params.id ? `"${pk}" = $1` : null,
|
60
|
+
const where = [params.id ? `"${pk}" = $1` : null, loadTable.query, interfaceQuery].filter((el) => el).filter((el) => (user?.user_type === 'superadmin' ? !el.includes('{{uid}}') : true));
|
64
61
|
|
65
|
-
const { fields = [] } = await pg.query(`select * from ${table} where ${sqlTable ? 'true' : (where.join(' and ') || 'true')} limit 0
|
62
|
+
const { fields = [] } = await pg.query(`select * from ${table} where ${sqlTable ? 'true' : (where.join(' and ') || 'true')} limit 0`, ([sqlTable ? null : params.id].filter(el => el)) );
|
66
63
|
const columnList = fields.map(el => el.name);
|
67
64
|
|
68
65
|
const metaInfoCols = meta.info.split(',').filter(el => columnList.includes(el)).map((el) => `"${el}"`);
|
@@ -84,7 +81,7 @@ export default async function tableInfo(req) {
|
|
84
81
|
|
85
82
|
if (query.sql === '1') { return q; }
|
86
83
|
|
87
|
-
const { rows } = await pg.query(q,
|
84
|
+
const { rows } = await pg.query(q, [params.id]);
|
88
85
|
|
89
86
|
const qCount = `select
|
90
87
|
count(*)::int as total,
|
@@ -93,7 +90,7 @@ export default async function tableInfo(req) {
|
|
93
90
|
where ${[loadTable.query].filter(el => el).join(' and ') || 'true'} `
|
94
91
|
.replace(/{{uid}}/g, uid);
|
95
92
|
|
96
|
-
const { total, filtered } =
|
93
|
+
const { total, filtered } = params.id ? rows.length
|
97
94
|
: await pg.queryCache(qCount, { table: loadTable.table, time: 5 }).then((el) => el?.rows[0]);
|
98
95
|
|
99
96
|
const cls = meta.info.split(',').filter(el => columnList.includes(el))
|