@opengis/fastify-table 1.1.15 → 1.1.17
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/package.json +1 -1
- package/pg/funcs/getMeta.js +3 -1
- package/pg/funcs/init.js +7 -2
- package/server/migrations/properties.sql +28 -1
- package/server/migrations/users.sql +45 -0
- package/table/controllers/data.js +6 -1
package/Changelog.md
CHANGED
package/package.json
CHANGED
package/pg/funcs/getMeta.js
CHANGED
|
@@ -21,7 +21,9 @@ export default async function getMeta(opt) {
|
|
|
21
21
|
|
|
22
22
|
const geomAttr = fields.find((el) => pg.pgType[el.dataTypeID] === 'geometry')?.name; // change geometry text to geometry code
|
|
23
23
|
|
|
24
|
-
const res = {
|
|
24
|
+
const res = {
|
|
25
|
+
pk, columns: fields, geom: geomAttr, view: pg.relkinds?.[table] === 'v',
|
|
26
|
+
};
|
|
25
27
|
data[table] = res;
|
|
26
28
|
return res;
|
|
27
29
|
}
|
package/pg/funcs/init.js
CHANGED
|
@@ -14,6 +14,10 @@ async function init(client) {
|
|
|
14
14
|
const tlist = await client.query(`select array_agg((select nspname from pg_namespace where oid=relnamespace)||'.'||relname) tlist
|
|
15
15
|
from pg_class where relkind in ('r','v')`).then((d) => d.rows[0].tlist);
|
|
16
16
|
|
|
17
|
+
const { rows = [] } = await client.query(`select (select nspname from pg_namespace where oid=relnamespace)||'.'||relname as tname, relkind
|
|
18
|
+
from pg_class where relkind in ('r','v')`);
|
|
19
|
+
const relkinds = rows.reduce((acc, curr) => Object.assign(acc, { [curr.tname]: curr.relkind }), {});
|
|
20
|
+
|
|
17
21
|
async function one(query, param = {}) {
|
|
18
22
|
const data = await client.query(query, Array.isArray(param) ? param : param.args || []);
|
|
19
23
|
const result = ((Array.isArray(data) ? data.pop() : data)?.rows || [])[0] || {};
|
|
@@ -29,7 +33,8 @@ async function init(client) {
|
|
|
29
33
|
try {
|
|
30
34
|
result = await clientCb.query(query, args);
|
|
31
35
|
clientCb.end();
|
|
32
|
-
}
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
33
38
|
clientCb.end();
|
|
34
39
|
cb(err.toString(), 1);
|
|
35
40
|
throw err;
|
|
@@ -51,7 +56,7 @@ async function init(client) {
|
|
|
51
56
|
}
|
|
52
57
|
|
|
53
58
|
Object.assign(client, {
|
|
54
|
-
one, pgType, pk, tlist, queryCache, queryNotice,
|
|
59
|
+
one, pgType, pk, tlist, relkinds, queryCache, queryNotice,
|
|
55
60
|
});
|
|
56
61
|
}
|
|
57
62
|
|
|
@@ -28,4 +28,31 @@ ALTER TABLE admin.properties ADD COLUMN IF NOT EXISTS files json;
|
|
|
28
28
|
|
|
29
29
|
ALTER TABLE admin.properties ADD CONSTRAINT admin_properties_property_id_pkey PRIMARY KEY(property_id);
|
|
30
30
|
|
|
31
|
-
COMMENT ON TABLE admin.properties IS 'Налаштування';
|
|
31
|
+
COMMENT ON TABLE admin.properties IS 'Налаштування';
|
|
32
|
+
|
|
33
|
+
-- DROP TABLE admin.user_properties;
|
|
34
|
+
CREATE TABLE IF NOT EXISTS admin.user_properties();
|
|
35
|
+
ALTER TABLE admin.user_properties DROP CONSTRAINT IF EXISTS admin_user_properties_property_id_pkey;
|
|
36
|
+
alter table admin.user_properties drop constraint if exists user_properties_key_uid_unique;
|
|
37
|
+
ALTER TABLE admin.user_properties ADD COLUMN IF NOT EXISTS property_id text NOT NULL DEFAULT next_id();
|
|
38
|
+
|
|
39
|
+
ALTER TABLE admin.user_properties ADD COLUMN IF NOT EXISTS property_key text;
|
|
40
|
+
COMMENT ON COLUMN admin.user_properties.property_key IS 'Ключ';
|
|
41
|
+
ALTER TABLE admin.user_properties ADD COLUMN IF NOT EXISTS property_json json;
|
|
42
|
+
COMMENT ON COLUMN admin.user_properties.property_json IS 'Значення налаштування';
|
|
43
|
+
|
|
44
|
+
ALTER TABLE admin.properties ADD COLUMN IF NOT EXISTS property_entity text;
|
|
45
|
+
COMMENT ON COLUMN admin.properties.property_entity IS 'Сутність';
|
|
46
|
+
ALTER TABLE admin.properties ADD COLUMN IF NOT EXISTS property_title text;
|
|
47
|
+
COMMENT ON COLUMN admin.properties.property_title IS 'Назва';
|
|
48
|
+
|
|
49
|
+
ALTER TABLE admin.user_properties ADD COLUMN IF NOT EXISTS uid text NOT NULL DEFAULT '1'::text;
|
|
50
|
+
ALTER TABLE admin.user_properties ADD COLUMN IF NOT EXISTS editor_id text;
|
|
51
|
+
ALTER TABLE admin.user_properties ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
|
|
52
|
+
ALTER TABLE admin.user_properties ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT now();
|
|
53
|
+
ALTER TABLE admin.user_properties ADD COLUMN IF NOT EXISTS files json;
|
|
54
|
+
|
|
55
|
+
ALTER TABLE admin.user_properties ADD CONSTRAINT admin_user_properties_property_id_pkey PRIMARY KEY(property_id);
|
|
56
|
+
alter table admin.user_properties add constraint user_properties_key_uid_unique UNIQUE (property_key,uid);
|
|
57
|
+
|
|
58
|
+
COMMENT ON TABLE admin.user_properties IS 'Налаштування користувача';
|
|
@@ -87,3 +87,48 @@ LANGUAGE plpgsql VOLATILE COST 100;
|
|
|
87
87
|
DROP TRIGGER if exists insert_update_user_before on admin.users;
|
|
88
88
|
CREATE TRIGGER insert_update_user_before BEFORE INSERT OR UPDATE ON admin.users FOR EACH ROW
|
|
89
89
|
EXECUTE PROCEDURE admin.insert_update_user_before();
|
|
90
|
+
|
|
91
|
+
-- DROP TABLE is exists admin.users_social_auth;
|
|
92
|
+
CREATE TABLE if not exists admin.users_social_auth();
|
|
93
|
+
ALTER TABLE admin.users_social_auth add column if not exists users_social_auth_id text NOT NULL DEFAULT next_id();
|
|
94
|
+
ALTER TABLE admin.users_social_auth alter column users_social_auth_id set DEFAULT next_id();
|
|
95
|
+
ALTER TABLE admin.users_social_auth DROP CONSTRAINT if exists users_social_auth_pk cascade;
|
|
96
|
+
ALTER TABLE admin.users_social_auth DROP CONSTRAINT if exists users_social_auth_users_fk cascade;
|
|
97
|
+
|
|
98
|
+
ALTER TABLE admin.users_social_auth add column if not exists uid text not null;
|
|
99
|
+
ALTER TABLE admin.users_social_auth add column if not exists user_name text;
|
|
100
|
+
ALTER TABLE admin.users_social_auth add column if not exists sur_name text;
|
|
101
|
+
ALTER TABLE admin.users_social_auth add column if not exists email text;
|
|
102
|
+
ALTER TABLE admin.users_social_auth add column if not exists city text;
|
|
103
|
+
ALTER TABLE admin.users_social_auth add column if not exists phone text;
|
|
104
|
+
ALTER TABLE admin.users_social_auth add column if not exists social_auth_id text;
|
|
105
|
+
ALTER TABLE admin.users_social_auth add column if not exists social_auth_type text;
|
|
106
|
+
ALTER TABLE admin.users_social_auth add column if not exists social_auth_code text;
|
|
107
|
+
ALTER TABLE admin.users_social_auth add column if not exists social_auth_obj json;
|
|
108
|
+
ALTER TABLE admin.users_social_auth add column if not exists social_auth_date timestamp without time zone;
|
|
109
|
+
ALTER TABLE admin.users_social_auth add column if not exists social_auth_softpro_code text;
|
|
110
|
+
ALTER TABLE admin.users_social_auth add column if not exists enabled boolean;
|
|
111
|
+
ALTER TABLE admin.users_social_auth add column if not exists cdate timestamp without time zone;
|
|
112
|
+
ALTER TABLE admin.users_social_auth alter column cdate SET DEFAULT date_trunc('seconds'::text, now());
|
|
113
|
+
|
|
114
|
+
ALTER TABLE admin.users_social_auth add column if not exists editor_id text;
|
|
115
|
+
ALTER TABLE admin.users_social_auth add column if not exists lang text;
|
|
116
|
+
ALTER TABLE admin.users_social_auth add column if not exists editor_date timestamp without time zone;
|
|
117
|
+
ALTER TABLE admin.users_social_auth add column if not exists social_auth_url text;
|
|
118
|
+
ALTER TABLE admin.users_social_auth add CONSTRAINT users_social_auth_pk PRIMARY KEY (users_social_auth_id);
|
|
119
|
+
ALTER TABLE admin.users_social_auth add CONSTRAINT users_social_auth_users_fk FOREIGN KEY (uid) REFERENCES admin.users (uid) MATCH SIMPLE;
|
|
120
|
+
|
|
121
|
+
COMMENT ON COLUMN admin.users_social_auth.uid IS 'id пользователя';
|
|
122
|
+
COMMENT ON COLUMN admin.users_social_auth.user_name IS 'Имя пользователя';
|
|
123
|
+
COMMENT ON COLUMN admin.users_social_auth.sur_name IS 'Фамилия';
|
|
124
|
+
COMMENT ON COLUMN admin.users_social_auth.email IS 'email пользователя';
|
|
125
|
+
COMMENT ON COLUMN admin.users_social_auth.city IS 'Місто';
|
|
126
|
+
COMMENT ON COLUMN admin.users_social_auth.phone IS 'Телефон';
|
|
127
|
+
COMMENT ON COLUMN admin.users_social_auth.social_auth_id IS 'ID в соцсети';
|
|
128
|
+
COMMENT ON COLUMN admin.users_social_auth.social_auth_type IS 'тип соцсети';
|
|
129
|
+
COMMENT ON COLUMN admin.users_social_auth.social_auth_code IS 'код обьекта соцсети, используеться соцсетью';
|
|
130
|
+
COMMENT ON COLUMN admin.users_social_auth.social_auth_obj IS 'обьект соцсети';
|
|
131
|
+
COMMENT ON COLUMN admin.users_social_auth.social_auth_date IS 'время получение последнего обьекта соцсети';
|
|
132
|
+
COMMENT ON COLUMN admin.users_social_auth.social_auth_softpro_code IS 'код обьекта соцсети, создаваемый и используемый сервером авторизации';
|
|
133
|
+
COMMENT ON COLUMN admin.users_social_auth.enabled IS 'Выключатель';
|
|
134
|
+
COMMENT ON COLUMN admin.users_social_auth.social_auth_url IS 'URL для QR code';
|
|
@@ -21,7 +21,12 @@ export default async function dataAPI({
|
|
|
21
21
|
const {
|
|
22
22
|
table, columns, sql, cardSql, filters, form, meta, sqlColumns, ispublic,
|
|
23
23
|
} = loadTable;
|
|
24
|
-
const
|
|
24
|
+
const tableMeta = await getMeta(table);
|
|
25
|
+
if (tableMeta?.view) {
|
|
26
|
+
if (!loadTable?.key) return { message: `key not found: ${table}`, status: 404 };
|
|
27
|
+
Object.assign(tableMeta, { pk: loadTable?.key });
|
|
28
|
+
}
|
|
29
|
+
const { pk, columns: dbColumns = [] } = tableMeta || {};
|
|
25
30
|
|
|
26
31
|
if (!pk) return { message: `table not found: ${table}`, status: 404 };
|
|
27
32
|
|