@opengis/fastify-table 1.0.38 → 1.0.40
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/.eslintrc.cjs +42 -42
- package/Changelog.md +117 -109
- package/README.md +26 -26
- package/config.js +12 -12
- package/crud/controllers/deleteCrud.js +14 -14
- package/crud/controllers/utils/checkXSS.js +45 -45
- package/crud/controllers/utils/xssInjection.js +72 -72
- package/crud/funcs/dataDelete.js +15 -15
- package/crud/funcs/dataInsert.js +24 -24
- package/crud/funcs/dataUpdate.js +24 -24
- package/crud/funcs/getToken.js +27 -27
- package/crud/funcs/isFileExists.js +13 -13
- package/crud/funcs/setToken.js +53 -53
- package/index.js +12 -1
- package/package.json +22 -22
- package/pg/funcs/getPG.js +29 -29
- package/redis/funcs/getRedis.js +23 -23
- package/server/migrations/crm.sql +95 -95
- package/server/migrations/log.sql +41 -41
- package/server.js +14 -14
- package/table/controllers/data.js +57 -57
- package/table/controllers/filter.js +37 -37
- package/table/controllers/search.js +41 -41
- package/table/funcs/getFilterSQL/util/getTableSql.js +34 -34
- package/test/api/notification.test.js +37 -37
- package/test/api/table.test.js +57 -57
- package/test/api/widget.test.js +114 -114
- package/test/config.example +18 -18
- package/test/funcs/crud.test.js +76 -76
- package/test/funcs/notification.test.js +31 -31
- package/test/funcs/pg.test.js +34 -34
- package/test/funcs/redis.test.js +19 -19
- package/test/templates/cls/test.json +9 -9
- package/test/templates/form/cp_building.form.json +32 -32
- package/test/templates/select/account_id.json +3 -3
- package/test/templates/select/storage.data.json +2 -2
- package/test/templates/table/gis.dataset.table.json +20 -20
- package/widget/controllers/widget.get.js +22 -12
package/test/funcs/crud.test.js
CHANGED
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
import { test } from 'node:test';
|
|
2
|
-
import assert from 'node:assert';
|
|
3
|
-
import config from '../config.js';
|
|
4
|
-
import pgClients from '../../pg/pgClients.js';
|
|
5
|
-
import rclient from '../../redis/client.js';
|
|
6
|
-
|
|
7
|
-
import dataInsert from '../../crud/funcs/dataInsert.js';
|
|
8
|
-
import dataUpdate from '../../crud/funcs/dataUpdate.js';
|
|
9
|
-
import dataDelete from '../../crud/funcs/dataDelete.js';
|
|
10
|
-
import isFileExists from '../../crud/funcs/isFileExists.js';
|
|
11
|
-
|
|
12
|
-
import getOpt from '../../crud/funcs/getOpt.js';
|
|
13
|
-
import setOpt from '../../crud/funcs/setOpt.js';
|
|
14
|
-
|
|
15
|
-
import getToken from '../../crud/funcs/getToken.js';
|
|
16
|
-
import setToken from '../../crud/funcs/setToken.js';
|
|
17
|
-
|
|
18
|
-
test('funcs crud', async (t) => {
|
|
19
|
-
await pgClients.client.init();
|
|
20
|
-
await t.test('getOpt/setOpt', async () => {
|
|
21
|
-
const opt = await setOpt({ table: 'gis.dataset' });
|
|
22
|
-
const data = await getOpt(opt);
|
|
23
|
-
// console.log(data);
|
|
24
|
-
assert.equal(data.table, 'gis.dataset');
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
const id = (Math.random() * 10000).toFixed();
|
|
28
|
-
/* await t.test('dataInsert', async () => {
|
|
29
|
-
const data = await dataInsert({ table: 'gis.dataset', data: { dataset_id: id, dataset_name: '222' } });
|
|
30
|
-
assert.equal(data.dataset_id, id);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
await t.test('dataUpdate', async () => {
|
|
34
|
-
const data = await dataUpdate({ table: 'gis.dataset', id, data: { dataset_name: '22211' } });
|
|
35
|
-
assert.equal(data.dataset_name, '22211');
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
await t.test('dataDelete', async () => {
|
|
39
|
-
const data = await dataDelete({ table: 'gis.dataset', id });
|
|
40
|
-
assert.ok(data);
|
|
41
|
-
}); */
|
|
42
|
-
|
|
43
|
-
await t.test('isFileExists', async () => {
|
|
44
|
-
const data = await isFileExists({ filepath: '../../crud/funcs/isFileExists.js' });
|
|
45
|
-
assert.equal(data, false);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
let tokens;
|
|
49
|
-
const session = { passport: { user: { uid: '1' } } };
|
|
50
|
-
const tokenData = JSON.stringify({ add: 'gis.dataset', form: 'test.dataset.form' });
|
|
51
|
-
|
|
52
|
-
await t.test('setToken', async () => {
|
|
53
|
-
tokens = setToken({
|
|
54
|
-
funcs: { config },
|
|
55
|
-
ids: [tokenData],
|
|
56
|
-
mode: 'a',
|
|
57
|
-
uid: 1,
|
|
58
|
-
array: 1,
|
|
59
|
-
});
|
|
60
|
-
assert.equal(tokens.length, 1);
|
|
61
|
-
});
|
|
62
|
-
await t.test('getToken', async () => {
|
|
63
|
-
const data = await getToken({
|
|
64
|
-
uid: 1,
|
|
65
|
-
token: tokens[0],
|
|
66
|
-
mode: 'a',
|
|
67
|
-
});
|
|
68
|
-
assert.equal(data, tokenData);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
// pgClients.client.query('delete from gis.dataset where dataset_id=$1', [id]);
|
|
72
|
-
t.after(() => {
|
|
73
|
-
pgClients.client?.end();
|
|
74
|
-
rclient.quit();
|
|
75
|
-
});
|
|
76
|
-
});
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert';
|
|
3
|
+
import config from '../config.js';
|
|
4
|
+
import pgClients from '../../pg/pgClients.js';
|
|
5
|
+
import rclient from '../../redis/client.js';
|
|
6
|
+
|
|
7
|
+
import dataInsert from '../../crud/funcs/dataInsert.js';
|
|
8
|
+
import dataUpdate from '../../crud/funcs/dataUpdate.js';
|
|
9
|
+
import dataDelete from '../../crud/funcs/dataDelete.js';
|
|
10
|
+
import isFileExists from '../../crud/funcs/isFileExists.js';
|
|
11
|
+
|
|
12
|
+
import getOpt from '../../crud/funcs/getOpt.js';
|
|
13
|
+
import setOpt from '../../crud/funcs/setOpt.js';
|
|
14
|
+
|
|
15
|
+
import getToken from '../../crud/funcs/getToken.js';
|
|
16
|
+
import setToken from '../../crud/funcs/setToken.js';
|
|
17
|
+
|
|
18
|
+
test('funcs crud', async (t) => {
|
|
19
|
+
await pgClients.client.init();
|
|
20
|
+
await t.test('getOpt/setOpt', async () => {
|
|
21
|
+
const opt = await setOpt({ table: 'gis.dataset' });
|
|
22
|
+
const data = await getOpt(opt);
|
|
23
|
+
// console.log(data);
|
|
24
|
+
assert.equal(data.table, 'gis.dataset');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const id = (Math.random() * 10000).toFixed();
|
|
28
|
+
/* await t.test('dataInsert', async () => {
|
|
29
|
+
const data = await dataInsert({ table: 'gis.dataset', data: { dataset_id: id, dataset_name: '222' } });
|
|
30
|
+
assert.equal(data.dataset_id, id);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
await t.test('dataUpdate', async () => {
|
|
34
|
+
const data = await dataUpdate({ table: 'gis.dataset', id, data: { dataset_name: '22211' } });
|
|
35
|
+
assert.equal(data.dataset_name, '22211');
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
await t.test('dataDelete', async () => {
|
|
39
|
+
const data = await dataDelete({ table: 'gis.dataset', id });
|
|
40
|
+
assert.ok(data);
|
|
41
|
+
}); */
|
|
42
|
+
|
|
43
|
+
await t.test('isFileExists', async () => {
|
|
44
|
+
const data = await isFileExists({ filepath: '../../crud/funcs/isFileExists.js' });
|
|
45
|
+
assert.equal(data, false);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
let tokens;
|
|
49
|
+
const session = { passport: { user: { uid: '1' } } };
|
|
50
|
+
const tokenData = JSON.stringify({ add: 'gis.dataset', form: 'test.dataset.form' });
|
|
51
|
+
|
|
52
|
+
await t.test('setToken', async () => {
|
|
53
|
+
tokens = setToken({
|
|
54
|
+
funcs: { config },
|
|
55
|
+
ids: [tokenData],
|
|
56
|
+
mode: 'a',
|
|
57
|
+
uid: 1,
|
|
58
|
+
array: 1,
|
|
59
|
+
});
|
|
60
|
+
assert.equal(tokens.length, 1);
|
|
61
|
+
});
|
|
62
|
+
await t.test('getToken', async () => {
|
|
63
|
+
const data = await getToken({
|
|
64
|
+
uid: 1,
|
|
65
|
+
token: tokens[0],
|
|
66
|
+
mode: 'a',
|
|
67
|
+
});
|
|
68
|
+
assert.equal(data, tokenData);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// pgClients.client.query('delete from gis.dataset where dataset_id=$1', [id]);
|
|
72
|
+
t.after(() => {
|
|
73
|
+
pgClients.client?.end();
|
|
74
|
+
rclient.quit();
|
|
75
|
+
});
|
|
76
|
+
});
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import { test } from 'node:test';
|
|
2
|
-
import assert from 'node:assert';
|
|
3
|
-
|
|
4
|
-
// import build from '../../helper.js';
|
|
5
|
-
// import config from '../config.js';
|
|
6
|
-
|
|
7
|
-
// import addNotification from '../../notification/funcs/addNotification.js';
|
|
8
|
-
|
|
9
|
-
// import pgClients from '../../pg/pgClients.js';
|
|
10
|
-
|
|
11
|
-
test('notification funcs', async (t) => {
|
|
12
|
-
// await build(t);
|
|
13
|
-
// const pg = pgClients.client;
|
|
14
|
-
// let resp;
|
|
15
|
-
/* await t.test('addNotification', async () => {
|
|
16
|
-
resp = await addNotification({
|
|
17
|
-
pg,
|
|
18
|
-
|
|
19
|
-
title: 'test title',
|
|
20
|
-
body: 'test body',
|
|
21
|
-
link: 'http://link',
|
|
22
|
-
notificationType: 'mention',
|
|
23
|
-
uid: config.testUser?.uid || '1',
|
|
24
|
-
});
|
|
25
|
-
assert.ok(resp.id);
|
|
26
|
-
});
|
|
27
|
-
await t.test('clean up after test, before pool is closed', async () => {
|
|
28
|
-
await pg.query('delete from crm.notification where notification_id=$1', [resp.id]);
|
|
29
|
-
console.log(resp.id, 'deleted');
|
|
30
|
-
}); */
|
|
31
|
-
});
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert';
|
|
3
|
+
|
|
4
|
+
// import build from '../../helper.js';
|
|
5
|
+
// import config from '../config.js';
|
|
6
|
+
|
|
7
|
+
// import addNotification from '../../notification/funcs/addNotification.js';
|
|
8
|
+
|
|
9
|
+
// import pgClients from '../../pg/pgClients.js';
|
|
10
|
+
|
|
11
|
+
test('notification funcs', async (t) => {
|
|
12
|
+
// await build(t);
|
|
13
|
+
// const pg = pgClients.client;
|
|
14
|
+
// let resp;
|
|
15
|
+
/* await t.test('addNotification', async () => {
|
|
16
|
+
resp = await addNotification({
|
|
17
|
+
pg,
|
|
18
|
+
|
|
19
|
+
title: 'test title',
|
|
20
|
+
body: 'test body',
|
|
21
|
+
link: 'http://link',
|
|
22
|
+
notificationType: 'mention',
|
|
23
|
+
uid: config.testUser?.uid || '1',
|
|
24
|
+
});
|
|
25
|
+
assert.ok(resp.id);
|
|
26
|
+
});
|
|
27
|
+
await t.test('clean up after test, before pool is closed', async () => {
|
|
28
|
+
await pg.query('delete from crm.notification where notification_id=$1', [resp.id]);
|
|
29
|
+
console.log(resp.id, 'deleted');
|
|
30
|
+
}); */
|
|
31
|
+
});
|
package/test/funcs/pg.test.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { test } from 'node:test';
|
|
2
|
-
import assert from 'node:assert';
|
|
3
|
-
|
|
4
|
-
import '../config.js';
|
|
5
|
-
|
|
6
|
-
import getMeta from '../../pg/funcs/getMeta.js';
|
|
7
|
-
import autoIndex from '../../pg/funcs/autoIndex.js';
|
|
8
|
-
import pgClients from '../../pg/pgClients.js';
|
|
9
|
-
import rclient from '../../redis/client.js';
|
|
10
|
-
// import pgClients from '../../pg/funcs/pgClients.js';
|
|
11
|
-
|
|
12
|
-
test('funcs pg', async (t) => {
|
|
13
|
-
await pgClients.client.init();
|
|
14
|
-
await t.test('getMeta', async () => {
|
|
15
|
-
const { columns } = await getMeta({ table: 'gis.dataset' });
|
|
16
|
-
// console.log(columns)
|
|
17
|
-
assert.ok(columns);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
/* await t.test('getPG', async (t) => {
|
|
21
|
-
const data = await getPG({});
|
|
22
|
-
assert.ok(data);
|
|
23
|
-
}); */
|
|
24
|
-
|
|
25
|
-
await t.test('autoIndex', async () => {
|
|
26
|
-
await autoIndex({ table: 'gis.dataset', columns: ['service_type'] });
|
|
27
|
-
assert.ok(1);
|
|
28
|
-
});
|
|
29
|
-
t.after(() => {
|
|
30
|
-
pgClients.client.end();
|
|
31
|
-
|
|
32
|
-
rclient.quit();
|
|
33
|
-
});
|
|
34
|
-
});
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert';
|
|
3
|
+
|
|
4
|
+
import '../config.js';
|
|
5
|
+
|
|
6
|
+
import getMeta from '../../pg/funcs/getMeta.js';
|
|
7
|
+
import autoIndex from '../../pg/funcs/autoIndex.js';
|
|
8
|
+
import pgClients from '../../pg/pgClients.js';
|
|
9
|
+
import rclient from '../../redis/client.js';
|
|
10
|
+
// import pgClients from '../../pg/funcs/pgClients.js';
|
|
11
|
+
|
|
12
|
+
test('funcs pg', async (t) => {
|
|
13
|
+
await pgClients.client.init();
|
|
14
|
+
await t.test('getMeta', async () => {
|
|
15
|
+
const { columns } = await getMeta({ table: 'gis.dataset' });
|
|
16
|
+
// console.log(columns)
|
|
17
|
+
assert.ok(columns);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
/* await t.test('getPG', async (t) => {
|
|
21
|
+
const data = await getPG({});
|
|
22
|
+
assert.ok(data);
|
|
23
|
+
}); */
|
|
24
|
+
|
|
25
|
+
await t.test('autoIndex', async () => {
|
|
26
|
+
await autoIndex({ table: 'gis.dataset', columns: ['service_type'] });
|
|
27
|
+
assert.ok(1);
|
|
28
|
+
});
|
|
29
|
+
t.after(() => {
|
|
30
|
+
pgClients.client.end();
|
|
31
|
+
|
|
32
|
+
rclient.quit();
|
|
33
|
+
});
|
|
34
|
+
});
|
package/test/funcs/redis.test.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { test } from 'node:test';
|
|
2
|
-
import assert from 'node:assert';
|
|
3
|
-
|
|
4
|
-
import '../config.js';
|
|
5
|
-
|
|
6
|
-
import rclient from '../../redis/client.js';
|
|
7
|
-
|
|
8
|
-
test('funcs redis', async (t) => {
|
|
9
|
-
await t.test('get/set', async () => {
|
|
10
|
-
await rclient.set('test', '1');
|
|
11
|
-
const d = await rclient.get('test');
|
|
12
|
-
// console.log(columns)
|
|
13
|
-
assert.equal(d, '1');
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
t.after(() => {
|
|
17
|
-
rclient.quit();
|
|
18
|
-
});
|
|
19
|
-
});
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert';
|
|
3
|
+
|
|
4
|
+
import '../config.js';
|
|
5
|
+
|
|
6
|
+
import rclient from '../../redis/client.js';
|
|
7
|
+
|
|
8
|
+
test('funcs redis', async (t) => {
|
|
9
|
+
await t.test('get/set', async () => {
|
|
10
|
+
await rclient.set('test', '1');
|
|
11
|
+
const d = await rclient.get('test');
|
|
12
|
+
// console.log(columns)
|
|
13
|
+
assert.equal(d, '1');
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
t.after(() => {
|
|
17
|
+
rclient.quit();
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"id": 1,
|
|
4
|
-
"text": "test"
|
|
5
|
-
},
|
|
6
|
-
{
|
|
7
|
-
"id": 2,
|
|
8
|
-
"text": "test2"
|
|
9
|
-
}
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": 1,
|
|
4
|
+
"text": "test"
|
|
5
|
+
},
|
|
6
|
+
{
|
|
7
|
+
"id": 2,
|
|
8
|
+
"text": "test2"
|
|
9
|
+
}
|
|
10
10
|
]
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
{
|
|
2
|
-
"schema": {
|
|
3
|
-
|
|
4
|
-
"cp_umuni_id": {
|
|
5
|
-
"type": "Text",
|
|
6
|
-
"ua": "ID UMUNI"
|
|
7
|
-
},
|
|
8
|
-
"cp_year": {
|
|
9
|
-
"type": "Text",
|
|
10
|
-
"ua": "Рік будівництва"
|
|
11
|
-
},
|
|
12
|
-
"cp_date_en_audit": {
|
|
13
|
-
"type": "DatePicker",
|
|
14
|
-
"ua": "Дата проведення останнього енергоаудиту"
|
|
15
|
-
},
|
|
16
|
-
"cp_certificate": {
|
|
17
|
-
"type": "Text",
|
|
18
|
-
"ua": "Сертифікат енергоефективності будівлі",
|
|
19
|
-
"help": "Вкажіть посилання"
|
|
20
|
-
},
|
|
21
|
-
"cp_pkd": {
|
|
22
|
-
"type": "Autocomplete",
|
|
23
|
-
"data": "customer_name",
|
|
24
|
-
"add": {
|
|
25
|
-
"model": "crm_acc.crm_account",
|
|
26
|
-
"ua": "Додати",
|
|
27
|
-
"form": "account_light.form"
|
|
28
|
-
},
|
|
29
|
-
"ua": "Замовник ПКД"
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
"label_style": "vertical"
|
|
1
|
+
{
|
|
2
|
+
"schema": {
|
|
3
|
+
|
|
4
|
+
"cp_umuni_id": {
|
|
5
|
+
"type": "Text",
|
|
6
|
+
"ua": "ID UMUNI"
|
|
7
|
+
},
|
|
8
|
+
"cp_year": {
|
|
9
|
+
"type": "Text",
|
|
10
|
+
"ua": "Рік будівництва"
|
|
11
|
+
},
|
|
12
|
+
"cp_date_en_audit": {
|
|
13
|
+
"type": "DatePicker",
|
|
14
|
+
"ua": "Дата проведення останнього енергоаудиту"
|
|
15
|
+
},
|
|
16
|
+
"cp_certificate": {
|
|
17
|
+
"type": "Text",
|
|
18
|
+
"ua": "Сертифікат енергоефективності будівлі",
|
|
19
|
+
"help": "Вкажіть посилання"
|
|
20
|
+
},
|
|
21
|
+
"cp_pkd": {
|
|
22
|
+
"type": "Autocomplete",
|
|
23
|
+
"data": "customer_name",
|
|
24
|
+
"add": {
|
|
25
|
+
"model": "crm_acc.crm_account",
|
|
26
|
+
"ua": "Додати",
|
|
27
|
+
"form": "account_light.form"
|
|
28
|
+
},
|
|
29
|
+
"ua": "Замовник ПКД"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"label_style": "vertical"
|
|
33
33
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
{
|
|
2
|
-
"db": "mbk_lviv_dma",
|
|
3
|
-
"searchColumn": "alternative_name"
|
|
1
|
+
{
|
|
2
|
+
"db": "mbk_lviv_dma",
|
|
3
|
+
"searchColumn": "alternative_name"
|
|
4
4
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
{
|
|
2
|
-
"key": "dataset_id"
|
|
1
|
+
{
|
|
2
|
+
"key": "dataset_id"
|
|
3
3
|
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
{
|
|
2
|
-
"columns": [
|
|
3
|
-
{
|
|
4
|
-
"name": "dataset_id",
|
|
5
|
-
"title": "22"
|
|
6
|
-
},
|
|
7
|
-
{
|
|
8
|
-
"name": "dataset_name",
|
|
9
|
-
"title": "dataset_name"
|
|
10
|
-
}
|
|
11
|
-
],
|
|
12
|
-
"table": "gis.dataset",
|
|
13
|
-
"order": "dataset_name",
|
|
14
|
-
"filters": [
|
|
15
|
-
{
|
|
16
|
-
"ua": "Назва набору",
|
|
17
|
-
"name": "dataset_name",
|
|
18
|
-
"type": "text"
|
|
19
|
-
}
|
|
20
|
-
]
|
|
1
|
+
{
|
|
2
|
+
"columns": [
|
|
3
|
+
{
|
|
4
|
+
"name": "dataset_id",
|
|
5
|
+
"title": "22"
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
"name": "dataset_name",
|
|
9
|
+
"title": "dataset_name"
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
"table": "gis.dataset",
|
|
13
|
+
"order": "dataset_name",
|
|
14
|
+
"filters": [
|
|
15
|
+
{
|
|
16
|
+
"ua": "Назва набору",
|
|
17
|
+
"name": "dataset_name",
|
|
18
|
+
"type": "text"
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
21
|
}
|
|
@@ -23,25 +23,35 @@ export default async function widgetGet({
|
|
|
23
23
|
if (!objectid) return { error: 'id required', status: 400 };
|
|
24
24
|
|
|
25
25
|
const sqls = {
|
|
26
|
-
comment:
|
|
26
|
+
comment: pg.pk['admin.users']
|
|
27
|
+
? `select communication_id, entity_id, body, subject, c.cdate, c.uid,
|
|
27
28
|
coalesce(user_name,' ')||' '||coalesce(sur_name,'') as username, avatar
|
|
28
|
-
from crm.communications c left join admin.users u on u.uid=c.uid where entity_id=$1 order by cdate desc
|
|
29
|
+
from crm.communications c left join admin.users u on u.uid=c.uid where entity_id=$1 order by cdate desc`
|
|
30
|
+
: 'select communication_id, entity_id, body, subject, cdate, uid from crm.communications where entity_id=$1 order by cdate desc',
|
|
29
31
|
|
|
30
32
|
history: `SELECT table_change_id, entity_id, entity_type, change_key, change_date, json_old, json_new, date_old,
|
|
31
33
|
date_new, number_old, number_new, bool_old, bool_new, text_old,
|
|
32
34
|
text_new, uid, cdate FROM log.table_changes where entity_id=$1 order by cdate desc, change_key limit 100`,
|
|
33
35
|
|
|
34
|
-
checklist:
|
|
35
|
-
|
|
36
|
+
checklist: pg.pk['admin.users']
|
|
37
|
+
? `SELECT checklist_id, entity_id, subject, is_done, done_date, c.uid, c.cdate, coalesce(user_name,' ')||' '||coalesce(sur_name,'') as username,
|
|
38
|
+
avatar FROM crm.checklists c left join admin.users u on u.uid=c.uid where entity_id=$1 order by cdate desc`
|
|
39
|
+
: 'SELECT checklist_id, entity_id, subject, is_done, done_date, uid, cdate FROM crm.checklists where entity_id=$1 order by cdate desc',
|
|
36
40
|
|
|
37
|
-
file:
|
|
41
|
+
file: pg.pk['admin.users']
|
|
42
|
+
? `SELECT file_id, entity_id, entity_type, file_path, uploaded_name, ext, size, c.uid, c.cdate, file_type, c.ismain,
|
|
38
43
|
coalesce(user_name,' ')||' '||coalesce(sur_name,'') as username, isverified,
|
|
39
44
|
avatar, c.uid as author, file_status FROM crm.files c left join admin.users u on u.uid=c.uid
|
|
40
|
-
where entity_id=$1 and file_status<>3 order by cdate desc
|
|
41
|
-
|
|
45
|
+
where entity_id=$1 and file_status<>3 order by cdate desc`
|
|
46
|
+
: `SELECT file_id, entity_id, entity_type, file_path, uploaded_name, ext, size, uid, cdate, file_type, ismain,
|
|
47
|
+
isverified, uid as author, file_status FROM crm.files c where entity_id=$1 and file_status<>3 order by cdate desc`,
|
|
48
|
+
gallery: pg.pk['admin.users']
|
|
49
|
+
? `SELECT file_id, entity_id, entity_type, file_path, uploaded_name, ext, size, c.uid, c.cdate, file_type, c.ismain,
|
|
42
50
|
coalesce(user_name,' ')||' '||coalesce(sur_name,'') as username, isverified,
|
|
43
51
|
avatar, c.uid as author, file_status FROM crm.files c left join admin.users u on u.uid=c.uid
|
|
44
|
-
where entity_id=$1 and file_status<>3 and ext = any($2) order by cdate desc
|
|
52
|
+
where entity_id=$1 and file_status<>3 and ext = any($2) order by cdate desc`
|
|
53
|
+
: `SELECT file_id, entity_id, entity_type, file_path, uploaded_name, ext, size, c.uid, c.cdate, file_type, ismain,
|
|
54
|
+
isverified, uid as author, file_status FROM crm.files c where entity_id=$1 and file_status<>3 and ext = any($2) order by cdate desc`,
|
|
45
55
|
|
|
46
56
|
};
|
|
47
57
|
const sql = sqls[params.type];
|
|
@@ -56,12 +66,12 @@ export default async function widgetGet({
|
|
|
56
66
|
time.push(Date.now());
|
|
57
67
|
|
|
58
68
|
/* Object info */
|
|
59
|
-
const { tableName } = await pg.one('select entity_type as "tableName" from log.table_changes where entity_id=$1 limit 1', [objectid]);
|
|
69
|
+
const { tableName } = pg.pk['log.table_changes'] ? await pg.one('select entity_type as "tableName" from log.table_changes where entity_id=$1 limit 1', [objectid]) : {};
|
|
60
70
|
const { pk } = await getMeta({ table: tableName });
|
|
61
71
|
|
|
62
|
-
const q = `select coalesce(b.user_name,'')||coalesce(' '||b.sur_name,'') as author, a.cdate, a.editor_date from ${tableName} a
|
|
63
|
-
left join admin.users b on a.uid=b.uid where a.${pk}=$1 limit 1
|
|
64
|
-
const data = pk ? await pg.one(q, [objectid]) : {};
|
|
72
|
+
const q = tableName && pg.pk['admin.users'] ? `select coalesce(b.user_name,'')||coalesce(' '||b.sur_name,'') as author, a.cdate, a.editor_date from ${tableName} a
|
|
73
|
+
left join admin.users b on a.uid=b.uid where a.${pk}=$1 limit 1` : undefined;
|
|
74
|
+
const data = pk && q ? await pg.one(q, [objectid]) : {};
|
|
65
75
|
|
|
66
76
|
if (query.debug && user?.user_type === 'admin') {
|
|
67
77
|
return {
|