@opengis/fastify-table 1.0.55 → 1.0.57
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/Changelog.md +8 -0
- package/crud/funcs/dataUpdate.js +3 -1
- package/crud/index.js +0 -10
- package/index.js +2 -0
- package/package.json +1 -1
- package/server/migrations/crm.sql +2 -0
- package/server/migrations/log.sql +2 -0
- package/table/funcs/metaFormat/index.js +2 -1
- package/{crud → util}/controllers/properties.add.js +1 -1
- package/util/index.js +13 -0
- /package/{crud → util}/controllers/next.id.js +0 -0
- /package/{crud → util}/controllers/properties.get.js +0 -0
package/Changelog.md
CHANGED
package/crud/funcs/dataUpdate.js
CHANGED
|
@@ -12,7 +12,9 @@ export default async function dataUpdate({
|
|
|
12
12
|
|
|
13
13
|
const names = columns?.map((el) => el.name);
|
|
14
14
|
const filterData = Object.keys(data)
|
|
15
|
-
.filter((el) =>
|
|
15
|
+
.filter((el) => {
|
|
16
|
+
return typeof data[el] === 'boolean' ? true : data[el] && names?.includes(el);
|
|
17
|
+
});
|
|
16
18
|
|
|
17
19
|
const filterValue = filterData.map((el) => [el, data[el]]).map((el) => (typeof el[1] === 'object' && (!Array.isArray(el[1]) || typeof el[1]?.[0] === 'object') ? JSON.stringify(el[1]) : el[1]));
|
|
18
20
|
|
package/crud/index.js
CHANGED
|
@@ -4,16 +4,10 @@ import isFileExists from './funcs/isFileExists.js';
|
|
|
4
4
|
import dataUpdate from './funcs/dataUpdate.js';
|
|
5
5
|
import dataInsert from './funcs/dataInsert.js';
|
|
6
6
|
|
|
7
|
-
import nextId from './controllers/next.id.js';
|
|
8
7
|
import update from './controllers/update.js';
|
|
9
8
|
import insert from './controllers/insert.js';
|
|
10
9
|
import deleteCrud from './controllers/deleteCrud.js';
|
|
11
10
|
|
|
12
|
-
import getExtraProperties from './controllers/properties.get.js';
|
|
13
|
-
import addExtraProperties from './controllers/properties.add.js';
|
|
14
|
-
|
|
15
|
-
// import config from '../config.js';
|
|
16
|
-
|
|
17
11
|
async function plugin(fastify, config = {}) {
|
|
18
12
|
const prefix = config.prefix || '/api';
|
|
19
13
|
// funcs
|
|
@@ -25,13 +19,9 @@ async function plugin(fastify, config = {}) {
|
|
|
25
19
|
fastify.decorate('isFileExists', isFileExists);
|
|
26
20
|
|
|
27
21
|
// api
|
|
28
|
-
fastify.get(`${prefix}/next-id`, {}, nextId);
|
|
29
22
|
fastify.put(`${prefix}/table/:table/:id`, {}, update);
|
|
30
23
|
fastify.delete(`${prefix}/table/:table/:id`, {}, deleteCrud);
|
|
31
24
|
fastify.post(`${prefix}/table/:table`, {}, insert);
|
|
32
|
-
|
|
33
|
-
fastify.get(`${prefix}/properties/:id`, {}, getExtraProperties);
|
|
34
|
-
fastify.post(`${prefix}/properties/:id`, {}, addExtraProperties);
|
|
35
25
|
}
|
|
36
26
|
|
|
37
27
|
export default plugin;
|
package/index.js
CHANGED
|
@@ -13,6 +13,7 @@ import notificationPlugin from './notification/index.js';
|
|
|
13
13
|
import widgetPlugin from './widget/index.js';
|
|
14
14
|
import crudPlugin from './crud/index.js';
|
|
15
15
|
import policyPlugin from './policy/index.js';
|
|
16
|
+
import utilPlugin from './util/index.js';
|
|
16
17
|
|
|
17
18
|
import pgClients from './pg/pgClients.js';
|
|
18
19
|
|
|
@@ -81,6 +82,7 @@ async function plugin(fastify, opt) {
|
|
|
81
82
|
crudPlugin(fastify, opt);
|
|
82
83
|
notificationPlugin(fastify, opt);
|
|
83
84
|
widgetPlugin(fastify, opt);
|
|
85
|
+
utilPlugin(fastify, opt);
|
|
84
86
|
}
|
|
85
87
|
export default fp(plugin);
|
|
86
88
|
// export { rclient };
|
package/package.json
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
create schema if not exists log;
|
|
2
|
+
|
|
1
3
|
CREATE TABLE IF NOT EXISTS log.table_changes();
|
|
2
4
|
ALTER TABLE log.table_changes DROP CONSTRAINT IF EXISTS log_table_changes_pkey;
|
|
3
5
|
ALTER TABLE log.table_changes ADD COLUMN IF NOT EXISTS table_change_id text NOT NULL DEFAULT next_id();
|
|
@@ -3,7 +3,8 @@ import getSelectVal from './getSelectVal.js';
|
|
|
3
3
|
|
|
4
4
|
export default async function metaFormat({ rows, table }) {
|
|
5
5
|
const loadTable = await getTemplate('table', table);
|
|
6
|
-
const selectCols = loadTable
|
|
6
|
+
const selectCols = loadTable?.columns?.filter((e) => e.data);
|
|
7
|
+
if (!selectCols?.length) return rows;
|
|
7
8
|
|
|
8
9
|
// cls & select format
|
|
9
10
|
|
package/util/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import getExtraProperties from './controllers/properties.get.js';
|
|
2
|
+
import addExtraProperties from './controllers/properties.add.js';
|
|
3
|
+
import nextId from './controllers/next.id.js';
|
|
4
|
+
|
|
5
|
+
async function plugin(fastify, config = {}) {
|
|
6
|
+
const prefix = config.prefix || '/api';
|
|
7
|
+
|
|
8
|
+
fastify.get(`${prefix}/next-id`, {}, nextId);
|
|
9
|
+
fastify.get(`${prefix}/properties/:id`, {}, getExtraProperties);
|
|
10
|
+
fastify.post(`${prefix}/properties/:id`, {}, addExtraProperties);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default plugin;
|
|
File without changes
|
|
File without changes
|