@opengis/fastify-table 1.2.43 → 1.2.45

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.2.43",
3
+ "version": "1.2.45",
4
4
  "type": "module",
5
5
  "description": "core-plugins",
6
6
  "keywords": [
@@ -69,6 +69,7 @@ export default async function extraData({
69
69
  const rows = Object.keys(data || {})
70
70
  .filter(key => Object.keys(loadTemplate?.schema || {}).includes(key))
71
71
  .filter(key => !mainColumns.map(el => el.name).concat('id', 'token').includes(key))
72
+ .filter(key => Array.isArray(data[key]) ? data[key].length : true)
72
73
  .map(key => ({
73
74
  object_id: id,
74
75
  property_key: key,
@@ -31,7 +31,7 @@ export default async function getFilterSQL({
31
31
 
32
32
  const extraDataTable = extra
33
33
  ? config.extraData?.[body.table]
34
- || config.extraData?.[mainTable.split('.').shift()]
34
+ || config.extraData?.[body.table.split('.').shift()]
35
35
  || config.extraData?.['default']
36
36
  || config.extraData
37
37
  || defaultTable
@@ -41,7 +41,7 @@ export default async function dataAPI(req, reply, called) {
41
41
  }
42
42
 
43
43
  const {
44
- table, columns = [], sql, cardSql, filters, form, meta, sqlColumns, public: ispublic,
44
+ table, columns = [], sql, cardSql, filters, form, meta, sqlColumns, public: ispublic, editable = false,
45
45
  } = loadTable || tokenData;
46
46
 
47
47
  const tableMeta = await getMeta({ pg, table });
@@ -129,7 +129,17 @@ export default async function dataAPI(req, reply, called) {
129
129
 
130
130
  if (query.sql === '1') { return q; }
131
131
 
132
- 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] : []));
132
+ 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] : []));
133
+
134
+ if (uid && rows.length && editable) {
135
+ rows.forEach(row => {
136
+ row.token = setToken({
137
+ ids: [JSON.stringify({ id: row.id, table: tokenData?.table || hookData?.table || params.table, form: loadTable?.form })],
138
+ uid,
139
+ array: 1,
140
+ })[0];
141
+ });
142
+ }
133
143
 
134
144
  const filterWhere = [fData.q, search, bbox, queryPolyline, interfaceQuery, loadTable?.query, tokenData?.query].filter((el) => el);
135
145