@opengis/fastify-table 1.2.2 → 1.2.3
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
package/server/migrations/0.sql
CHANGED
|
@@ -35,8 +35,8 @@ if (_returnType != 'text') then
|
|
|
35
35
|
|
|
36
36
|
DROP FUNCTION IF EXISTS next_id();
|
|
37
37
|
|
|
38
|
-
CREATE EXTENSION if not exists "uuid-ossp";
|
|
39
|
-
ALTER EXTENSION "uuid-ossp" SET SCHEMA public;
|
|
38
|
+
/* CREATE EXTENSION if not exists "uuid-ossp";
|
|
39
|
+
ALTER EXTENSION "uuid-ossp" SET SCHEMA public; */
|
|
40
40
|
|
|
41
41
|
CREATE OR REPLACE FUNCTION next_id()
|
|
42
42
|
RETURNS text AS
|
|
@@ -44,7 +44,9 @@ if (_returnType != 'text') then
|
|
|
44
44
|
DECLARE
|
|
45
45
|
|
|
46
46
|
BEGIN
|
|
47
|
-
return replace(public.uuid_generate_v4()::text, '-', '');
|
|
47
|
+
-- return replace(public.uuid_generate_v4()::text, '-', '');
|
|
48
|
+
-- return replace(gen_random_uuid()::text, '-', ''); -- native from postgres 13 onward
|
|
49
|
+
return encode(public.gen_random_bytes(6), 'hex');
|
|
48
50
|
END;
|
|
49
51
|
$BODY$
|
|
50
52
|
LANGUAGE plpgsql VOLATILE
|
|
@@ -61,8 +63,8 @@ if (_returnType != 'text') then
|
|
|
61
63
|
else
|
|
62
64
|
raise notice 'skip default reassign';
|
|
63
65
|
|
|
64
|
-
CREATE EXTENSION if not exists "uuid-ossp";
|
|
65
|
-
ALTER EXTENSION "uuid-ossp" SET SCHEMA public;
|
|
66
|
+
/* CREATE EXTENSION if not exists "uuid-ossp";
|
|
67
|
+
ALTER EXTENSION "uuid-ossp" SET SCHEMA public; */
|
|
66
68
|
|
|
67
69
|
CREATE OR REPLACE FUNCTION next_id()
|
|
68
70
|
RETURNS text AS
|
|
@@ -70,7 +72,9 @@ else
|
|
|
70
72
|
DECLARE
|
|
71
73
|
|
|
72
74
|
BEGIN
|
|
73
|
-
return replace(public.uuid_generate_v4()::text, '-', '');
|
|
75
|
+
-- return replace(public.uuid_generate_v4()::text, '-', '');
|
|
76
|
+
-- return replace(gen_random_uuid()::text, '-', ''); -- native from postgres 13 onward
|
|
77
|
+
return encode(public.gen_random_bytes(6), 'hex');
|
|
74
78
|
END;
|
|
75
79
|
$BODY$
|
|
76
80
|
LANGUAGE plpgsql VOLATILE
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import getTemplate from '../../..//table/funcs/getTemplate.js';
|
|
2
2
|
import { metaFormat } from '@opengis/fastify-table/utils.js';
|
|
3
3
|
|
|
4
|
+
const defaultTitles = {
|
|
5
|
+
// editor_date: 'Дата оновлення',
|
|
6
|
+
// editor_id: 'Редактор',
|
|
7
|
+
// сdate: 'Дата створення',
|
|
8
|
+
// uid: 'Автор',
|
|
9
|
+
body: 'Зміст',
|
|
10
|
+
// entity_id: 'ID Сутності',
|
|
11
|
+
// entity_type: 'Таблиця сутності',
|
|
12
|
+
file_path: 'Шлях до файлу',
|
|
13
|
+
uploaded_name: 'Назва файлу',
|
|
14
|
+
};
|
|
15
|
+
|
|
4
16
|
function getValue(val) {
|
|
5
17
|
if (!val) return null;
|
|
6
18
|
return typeof val === 'object'
|
|
@@ -67,10 +79,10 @@ export default async function logChanges({
|
|
|
67
79
|
await metaFormat({ rows: [data], cls, sufix: false });
|
|
68
80
|
}
|
|
69
81
|
|
|
70
|
-
const newObj = Object.fromEntries(Object.entries(data || {}).map(el => ([[titles[el[0]] || el[0]], el[1]])));
|
|
82
|
+
const newObj = Object.fromEntries(Object.entries(data || {}).map(el => ([[titles[el[0]] || defaultTitles[el[0]] || el[0]], el[1]])));
|
|
71
83
|
const changesData = Object.keys(newObj || {}).map(el => ({
|
|
72
84
|
change_id: changeId,
|
|
73
|
-
entity_key:
|
|
85
|
+
entity_key: el,
|
|
74
86
|
value_old: getValue(old?.[el]),
|
|
75
87
|
value_new: type === 'DELETE' ? null : getValue(newObj?.[el]),
|
|
76
88
|
uid,
|