@opengis/fastify-table 1.1.56 → 1.1.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/index.js +27 -14
- package/package.json +9 -4
- package/{cron → server/plugins/cron}/funcs/addCron.js +12 -12
- package/server/plugins/cron/index.js +6 -0
- package/{crud → server/plugins/crud}/funcs/dataDelete.js +3 -1
- package/{crud → server/plugins/crud}/funcs/dataInsert.js +3 -0
- package/{crud → server/plugins/crud}/funcs/dataUpdate.js +3 -1
- package/{crud → server/plugins/crud}/funcs/getAccess.js +5 -3
- package/{crud → server/plugins/crud}/funcs/getOpt.js +2 -0
- package/{crud → server/plugins/crud}/funcs/getToken.js +4 -1
- package/{crud → server/plugins/crud}/funcs/setOpt.js +3 -0
- package/{crud → server/plugins/crud}/funcs/setToken.js +4 -1
- package/{crud → server/plugins/crud}/funcs/utils/getFolder.js +2 -1
- package/{crud → server/plugins/crud}/funcs/utils/logChanges.js +2 -2
- package/server/plugins/crud/index.js +23 -0
- package/{hook → server/plugins/hook}/funcs/addHook.js +1 -1
- package/{hook → server/plugins/hook}/funcs/applyHook.js +2 -2
- package/server/plugins/hook/index.js +8 -0
- package/{logger → server/plugins/logger}/createFileStream.js +1 -1
- package/{logger → server/plugins/logger}/getLogger.js +1 -1
- package/{migration → server/plugins/migration/funcs}/exec.migrations.js +1 -1
- package/server/plugins/migration/index.js +7 -0
- package/{pg → server/plugins/pg}/funcs/getPG.js +3 -3
- package/{pg → server/plugins/pg}/funcs/getPGAsync.js +3 -3
- package/{pg → server/plugins/pg}/funcs/init.js +2 -4
- package/{pg → server/plugins/pg}/index.js +5 -14
- package/{pg → server/plugins/pg}/pgClients.js +2 -1
- package/{policy → server/plugins/policy}/funcs/checkPolicy.js +1 -1
- package/{crud/controllers/utils → server/plugins/policy/funcs}/checkXSS.js +1 -4
- package/{policy → server/plugins/policy}/index.js +0 -2
- package/{policy/funcs → server/plugins/policy}/sqlInjection.js +1 -1
- package/{redis → server/plugins/redis}/funcs/getRedis.js +2 -1
- package/{redis → server/plugins/redis}/funcs/redisClients.js +1 -0
- package/{redis → server/plugins/redis}/index.js +2 -6
- package/{table → server/plugins/table}/funcs/getFilterSQL/index.js +3 -1
- package/{table/controllers/utils → server/plugins/table/funcs}/getSelectMeta.js +1 -10
- package/{table/controllers/utils → server/plugins/table/funcs}/getTemplate.js +2 -1
- package/{table/controllers/utils → server/plugins/table/funcs}/getTemplatePath.js +3 -3
- package/{table/controllers/utils → server/plugins/table/funcs}/getTemplates.js +2 -1
- package/{table/controllers/utils → server/plugins/table/funcs}/gisIRColumn.js +4 -7
- package/{table → server/plugins/table}/funcs/metaFormat/getSelectVal.js +4 -2
- package/{table → server/plugins/table}/funcs/metaFormat/index.js +3 -1
- package/server/plugins/table/index.js +13 -0
- package/{util → server/plugins/util/funcs}/eventStream.js +1 -0
- package/server/plugins/util/index.js +7 -0
- package/{cron → server/routes/cron}/controllers/cronApi.js +1 -1
- package/{cron → server/routes/cron}/index.js +5 -3
- package/{crud → server/routes/crud}/controllers/deleteCrud.js +2 -2
- package/{crud → server/routes/crud}/controllers/insert.js +5 -3
- package/{crud → server/routes/crud}/controllers/update.js +3 -3
- package/server/routes/crud/index.js +19 -0
- package/{util → server/routes/logger}/controllers/logger.file.js +5 -5
- package/{util → server/routes/logger}/controllers/utils/checkUserAccess.js +1 -1
- package/{util → server/routes/logger}/controllers/utils/getRootDir.js +4 -3
- package/server/routes/logger/index.js +15 -0
- package/{util → server/routes/properties}/controllers/properties.add.js +19 -20
- package/server/routes/properties/controllers/properties.get.js +17 -0
- package/{util → server/routes/properties}/index.js +5 -8
- package/{table → server/routes/table}/controllers/card.js +3 -5
- package/{table → server/routes/table}/controllers/data.js +4 -10
- package/{table → server/routes/table}/controllers/filter.js +3 -4
- package/{table → server/routes/table}/controllers/form.js +1 -1
- package/{table → server/routes/table}/controllers/search.js +15 -17
- package/{table → server/routes/table}/controllers/suggest.js +8 -7
- package/{table → server/routes/table}/controllers/table.js +5 -7
- package/{table → server/routes/table}/index.js +1 -10
- package/{table → server/routes/table}/schema.js +1 -1
- package/{util → server/routes/util}/controllers/next.id.js +1 -1
- package/server/routes/util/index.js +11 -0
- package/utils.js +58 -50
- package/.eslintrc.cjs +0 -44
- package/.gitlab-ci.yml +0 -18
- package/Changelog.md +0 -352
- package/cron/schema.js +0 -8
- package/crud/index.js +0 -31
- package/crud/schema.js +0 -11
- package/docs/.vitepress/abbr.mjs +0 -26
- package/docs/.vitepress/config.mjs +0 -127
- package/docs/.vitepress/navigation.mjs +0 -82
- package/docs/.vitepress/theme/Layout.vue +0 -17
- package/docs/.vitepress/theme/components/NavigationLinks.vue +0 -102
- package/docs/.vitepress/theme/components/Panzoom.vue +0 -169
- package/docs/.vitepress/theme/index.mjs +0 -15
- package/docs/.vitepress/theme/style.scss +0 -163
- package/docs/abbr.json +0 -4
- package/docs/api/cron/cronApi.md +0 -56
- package/docs/api/crud/deleteCrud.md +0 -58
- package/docs/api/crud/insert.md +0 -82
- package/docs/api/crud/update.md +0 -85
- package/docs/api/index.md +0 -47
- package/docs/api/notification/testEmail.md +0 -91
- package/docs/api/table/card.md +0 -73
- package/docs/api/table/data.md +0 -134
- package/docs/api/table/export.md +0 -60
- package/docs/api/table/filter.md +0 -104
- package/docs/api/table/form.md +0 -126
- package/docs/api/table/search.md +0 -123
- package/docs/api/table/suggest.md +0 -156
- package/docs/api/table/table.md +0 -107
- package/docs/api/user/user.cls.id.md +0 -77
- package/docs/api/user/user.cls.md +0 -49
- package/docs/api/user/user.cls.post.md +0 -62
- package/docs/api/user/user.info.md +0 -37
- package/docs/api/utils/logger.file.md +0 -61
- package/docs/api/utils/next.id.md +0 -34
- package/docs/api/utils/properties.add.md +0 -127
- package/docs/api/utils/properties.get.md +0 -73
- package/docs/api/utils/status.monitor.md +0 -36
- package/docs/api/widget/widget.del.md +0 -76
- package/docs/api/widget/widget.get.md +0 -233
- package/docs/api/widget/widget.set.md +0 -88
- package/docs/db/admin.md +0 -947
- package/docs/db/crm.md +0 -564
- package/docs/db/index.md +0 -9
- package/docs/db/log.md +0 -204
- package/docs/hook/card/afterCard.md +0 -20
- package/docs/hook/card/preCard.md +0 -25
- package/docs/hook/data/afterData.md +0 -26
- package/docs/hook/data/preData.md +0 -26
- package/docs/hook/deleteCrud/afterDelete.md +0 -21
- package/docs/hook/deleteCrud/preDelete.md +0 -26
- package/docs/hook/form/afterForm.md +0 -19
- package/docs/hook/form/preForm.md +0 -26
- package/docs/hook/getTemplate/afterTemplate.md +0 -24
- package/docs/hook/getTemplate/preTemplate.md +0 -29
- package/docs/hook/index.md +0 -45
- package/docs/hook/insert/afterInsert.md +0 -41
- package/docs/hook/insert/preInsert.md +0 -25
- package/docs/hook/table/afterTable.md +0 -20
- package/docs/hook/table/preTable.md +0 -25
- package/docs/hook/update/afterUpdate.md +0 -41
- package/docs/hook/update/preUpdate.md +0 -25
- package/docs/index.md +0 -42
- package/docs/public/fastify-dark.svg +0 -4
- package/docs/public/fastify.svg +0 -1
- package/docs/public/logo-short-dark.svg +0 -12
- package/docs/public/logo-short.svg +0 -11
- package/docs/public/logo.svg +0 -19
- package/docs/readme/index.md +0 -121
- package/docs/templates/card.md +0 -83
- package/docs/templates/cls.md +0 -29
- package/docs/templates/filters.md +0 -91
- package/docs/templates/forms.md +0 -139
- package/docs/templates/image.png +0 -0
- package/docs/templates/index.md +0 -28
- package/docs/templates/select.md +0 -90
- package/docs/templates/table.md +0 -162
- package/docs/utils/cron/addCron.md +0 -29
- package/docs/utils/crud/dataInsert.md +0 -52
- package/docs/utils/crud/dataUpdate.md +0 -53
- package/docs/utils/crud/getOpt.md +0 -34
- package/docs/utils/crud/isFileExists.md +0 -38
- package/docs/utils/crud/setOpt.md +0 -38
- package/docs/utils/hook/addHook.md +0 -74
- package/docs/utils/hook/applyHook.md +0 -64
- package/docs/utils/index.md +0 -48
- package/docs/utils/notification/addNotification.md +0 -28
- package/docs/utils/notification/notification.md +0 -41
- package/docs/utils/pg/autoIndex.md +0 -22
- package/docs/utils/pg/getMeta.md +0 -59
- package/docs/utils/pg/getPG.md +0 -34
- package/docs/utils/pg/init.md +0 -30
- package/docs/utils/pg/pg.md +0 -70
- package/docs/utils/redis/getRedis.md +0 -36
- package/docs/utils/redis/rclient.md +0 -74
- package/docs/utils/table/getForm.md +0 -69
- package/docs/utils/table/getMeta.md +0 -56
- package/docs/utils/table/getSelect.md +0 -39
- package/docs/utils/table/getSelectMeta.md +0 -47
- package/docs/utils/table/getTable.md +0 -78
- package/helper.js +0 -30
- package/module/core/select/core.user_mentioned.sql +0 -2
- package/module/test/cls/itree.composition.json +0 -26
- package/module/test/table/test.rest_zone.table.json +0 -266
- package/notification/controllers/readNotifications.js +0 -27
- package/notification/controllers/testEmail.js +0 -46
- package/notification/controllers/userNotifications.js +0 -61
- package/notification/controllers/utils/pin-m-ty-media-record-outline+303070.png +0 -0
- package/notification/funcs/addNotification.js +0 -21
- package/notification/funcs/sendNotification.js +0 -111
- package/notification/funcs/utils/sendEmail.js +0 -39
- package/notification/index.js +0 -18
- package/notification/schema.js +0 -10
- package/server.js +0 -26
- package/table/controllers/utils/getTemplate_old.js +0 -28
- package/test/api/applyHook.test.js +0 -95
- package/test/api/crud.test.js +0 -89
- package/test/api/crud.xss.test.js +0 -80
- package/test/api/notification.test.js +0 -48
- package/test/api/suggest.test.js +0 -66
- package/test/api/table.test.js +0 -134
- package/test/api/user.test.js +0 -85
- package/test/api/widget.test.js +0 -117
- package/test/config.example +0 -18
- package/test/funcs/pg.test.js +0 -34
- package/test/funcs/redis.test.js +0 -19
- package/test/helper/formatDate.test.js +0 -62
- package/test/templates/cls/itree.quality_condition.json +0 -20
- package/test/templates/cls/itree.recommend copy.json +0 -26
- package/test/templates/cls/itree.recommend.json +0 -26
- package/test/templates/cls/itree.type_plant.json +0 -65
- package/test/templates/cls/test.json +0 -10
- package/test/templates/form/cp_building.form.json +0 -33
- package/test/templates/select/account_id.json +0 -4
- package/test/templates/select/account_id.sql +0 -1
- package/test/templates/select/atu.nsdi.ato_level.json +0 -4
- package/test/templates/select/atu.nsdi.ato_level.sql +0 -11
- package/test/templates/select/contact_id.sql +0 -1
- package/test/templates/select/storage.data.json +0 -3
- package/test/templates/select/storage.data.sql +0 -1
- package/test/templates/select/test.storage.data.json +0 -4
- package/test/templates/select/test.storage.data.sql +0 -1
- package/test/templates/select/test.suggest.ato_new.json +0 -4
- package/test/templates/select/test.suggest.ato_new.sql +0 -26
- package/test/templates/select/test.suggest.data.json +0 -5
- package/test/templates/select/test.suggest.data.sql +0 -1
- package/test/templates/select/test.suggest.parent.sql +0 -2
- package/test/templates/table/gis.dataset.table.json +0 -21
- package/test/templates/table/green_space.table.json +0 -383
- package/test/templates/table/service.json +0 -18
- package/user/controllers/user.cls.id.js +0 -14
- package/user/controllers/user.cls.js +0 -71
- package/user/controllers/user.cls.post.js +0 -52
- package/user/controllers/user.info.js +0 -17
- package/user/index.js +0 -17
- package/user/schema.js +0 -17
- package/util/controllers/properties.get.js +0 -17
- package/util/schema.js +0 -19
- package/widget/controllers/utils/historyFormat.js +0 -76
- package/widget/controllers/utils/obj2db.js +0 -13
- package/widget/controllers/widget.del.js +0 -41
- package/widget/controllers/widget.get.js +0 -96
- package/widget/controllers/widget.set.js +0 -74
- package/widget/index.js +0 -40
- /package/{cron/controllers/utils → server/plugins/cron}/cronList.js +0 -0
- /package/{crud → server/plugins/crud}/funcs/isFileExists.js +0 -0
- /package/{hook/funcs → server/plugins/hook}/hookList.js +0 -0
- /package/{logger → server/plugins/logger}/getHooks.js +0 -0
- /package/{logger → server/plugins/logger}/labels.js +0 -0
- /package/{logger → server/plugins/logger}/logger.test.api.js +0 -0
- /package/{logger → server/plugins/logger}/serializers.js +0 -0
- /package/{pg → server/plugins/pg}/funcs/autoIndex.js +0 -0
- /package/{pg → server/plugins/pg}/funcs/getMeta.js +0 -0
- /package/{pg → server/plugins/pg}/funcs/pgClients.js +0 -0
- /package/{crud/controllers/utils → server/plugins/policy}/xssInjection.js +0 -0
- /package/{redis → server/plugins/redis}/client.js +0 -0
- /package/{table/controllers/utils → server/plugins/table/funcs}/addTemplateDir.js +0 -0
- /package/{table → server/plugins/table}/funcs/getFilterSQL/util/formatValue.js +0 -0
- /package/{table → server/plugins/table}/funcs/getFilterSQL/util/getCustomQuery.js +0 -0
- /package/{table → server/plugins/table}/funcs/getFilterSQL/util/getFilterQuery.js +0 -0
- /package/{table → server/plugins/table}/funcs/getFilterSQL/util/getOptimizedQuery.js +0 -0
- /package/{table → server/plugins/table}/funcs/getFilterSQL/util/getTableSql.js +0 -0
- /package/{table/controllers/utils → server/plugins/table/funcs}/getSelect.js +0 -0
- /package/{table/controllers/utils → server/plugins/table/funcs}/loadTemplate.js +0 -0
- /package/{table/controllers/utils → server/plugins/table/funcs}/loadTemplatePath.js +0 -0
- /package/{table/controllers/utils → server/plugins/table/funcs}/userTemplateDir.js +0 -0
- /package/{util → server/routes/util}/controllers/status.monitor.js +0 -0
package/test/api/user.test.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { test } from 'node:test';
|
|
2
|
-
import assert from 'node:assert';
|
|
3
|
-
|
|
4
|
-
import pgClients from '../../pg/pgClients.js';
|
|
5
|
-
import init from '../../pg/funcs/init.js';
|
|
6
|
-
|
|
7
|
-
import build from '../../helper.js';
|
|
8
|
-
import config from '../config.js';
|
|
9
|
-
|
|
10
|
-
const prefix = config.prefix || '/api';
|
|
11
|
-
|
|
12
|
-
const body = {
|
|
13
|
-
name: 'test.user.cls',
|
|
14
|
-
type: 'json',
|
|
15
|
-
children: [
|
|
16
|
-
{
|
|
17
|
-
id: 'get',
|
|
18
|
-
text: 'Отримання',
|
|
19
|
-
},
|
|
20
|
-
],
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
test('applyHook to API data/table', async (t) => {
|
|
24
|
-
const app = await build(t);
|
|
25
|
-
await init(pgClients.client);
|
|
26
|
-
|
|
27
|
-
app.addHook('onRequest', async (req) => {
|
|
28
|
-
req.session = { passport: { user: { uid: '1' } } };
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
await t.test('GET /user-info', async () => {
|
|
32
|
-
const res = await app.inject({
|
|
33
|
-
method: 'GET',
|
|
34
|
-
url: `${prefix}/user-info`,
|
|
35
|
-
});
|
|
36
|
-
assert.equal(res.statusCode, 200);
|
|
37
|
-
assert.equal(res.json().uid, '1');
|
|
38
|
-
assert.ok(res.json().user_name, 'not enough info: user_name');
|
|
39
|
-
assert.ok(res.json().notifications || res.json().notifications === 0, 'not enough info: notifications');
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
await t.test('GET /user-cls', async () => {
|
|
43
|
-
const res = await app.inject({
|
|
44
|
-
method: 'GET',
|
|
45
|
-
url: `${prefix}/user-cls`,
|
|
46
|
-
});
|
|
47
|
-
const { message = {} } = res.json() || {};
|
|
48
|
-
assert.ok(message.rows?.length, 'empty cls list');
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
await t.test('POST /user-cls', async () => {
|
|
52
|
-
const res = await app.inject({
|
|
53
|
-
method: 'POST',
|
|
54
|
-
url: `${prefix}/user-cls`,
|
|
55
|
-
body,
|
|
56
|
-
});
|
|
57
|
-
assert.equal(res.statusCode, 200);
|
|
58
|
-
assert.ok(res.json().children?.length, 'insert user cls error');
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
await t.test('GET /user-cls/:name', async () => {
|
|
62
|
-
const res = await app.inject({
|
|
63
|
-
method: 'GET',
|
|
64
|
-
url: `${prefix}/user-cls/${body.name}`,
|
|
65
|
-
body,
|
|
66
|
-
});
|
|
67
|
-
const resp = res.json();
|
|
68
|
-
assert.equal(res.statusCode, 200);
|
|
69
|
-
assert.equal(resp.status || 200, 200);
|
|
70
|
-
assert.equal(resp.message?.children?.length, 1);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
await t.test('clean up', async () => {
|
|
74
|
-
const { rowCount = 0 } = await pgClients.client.query(`with recursive rows as (
|
|
75
|
-
select user_clsid, name, code, icon, color, parent
|
|
76
|
-
from admin.user_cls a
|
|
77
|
-
where name=$1
|
|
78
|
-
union all
|
|
79
|
-
select a.user_clsid, a.name, a.code, a.icon, a.color, a.parent
|
|
80
|
-
from admin.user_cls a
|
|
81
|
-
join rows b on a.parent=b.name
|
|
82
|
-
) delete from admin.user_cls where user_clsid in (select user_clsid from rows )`, [body.name]);
|
|
83
|
-
console.log('clean up', rowCount);
|
|
84
|
-
});
|
|
85
|
-
});
|
package/test/api/widget.test.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
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
|
-
const session = { passport: { user: { uid: config.testUser?.uid || '1' } } };
|
|
8
|
-
|
|
9
|
-
import widgetGet from '../../widget/controllers/widget.get.js';
|
|
10
|
-
import widgetSet from '../../widget/controllers/widget.set.js';
|
|
11
|
-
import widgetDel from '../../widget/controllers/widget.del.js';
|
|
12
|
-
|
|
13
|
-
import pgClients from '../../pg/pgClients.js';
|
|
14
|
-
|
|
15
|
-
test('widget api', async (t) => {
|
|
16
|
-
await build(t);
|
|
17
|
-
const pg = pgClients.client;
|
|
18
|
-
|
|
19
|
-
// comment
|
|
20
|
-
let commentId;
|
|
21
|
-
await t.test('POST /widget/comment/:objectid', async () => {
|
|
22
|
-
const body = {};
|
|
23
|
-
const resp = await widgetSet({
|
|
24
|
-
pg, params: { type: 'comment', objectid: '1' }, session, body,
|
|
25
|
-
});
|
|
26
|
-
commentId = resp.id;
|
|
27
|
-
assert.ok(commentId, 'comment widget insert fail');
|
|
28
|
-
});
|
|
29
|
-
await t.test('GET /widget/comment/:objectid', async () => {
|
|
30
|
-
const resp = await widgetGet({
|
|
31
|
-
pg, session, params: { type: 'comment', objectid: '1' },
|
|
32
|
-
});
|
|
33
|
-
assert.ok(resp.rows?.length, 'comment widget get fail');
|
|
34
|
-
});
|
|
35
|
-
await t.test('DELETE /widget/comment/:objectid', async () => {
|
|
36
|
-
const resp = await widgetDel({
|
|
37
|
-
pg, session, params: { type: 'comment', objectid: '1', id: commentId },
|
|
38
|
-
});
|
|
39
|
-
assert.ok(resp?.data?.id === commentId, 'comment widget delete fail');
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
// checklist
|
|
43
|
-
let checklistId;
|
|
44
|
-
await t.test('POST /widget/checklist/:objectid', async () => {
|
|
45
|
-
const body = {};
|
|
46
|
-
const resp = await widgetSet({
|
|
47
|
-
pg, params: { type: 'checklist', objectid: '1' }, session, body,
|
|
48
|
-
});
|
|
49
|
-
checklistId = resp.id;
|
|
50
|
-
assert.ok(checklistId, 'checklist widget insert fail');
|
|
51
|
-
});
|
|
52
|
-
await t.test('GET /widget/checklist/:objectid', async () => {
|
|
53
|
-
const resp = await widgetGet({
|
|
54
|
-
pg, session, params: { type: 'checklist', objectid: '1' },
|
|
55
|
-
});
|
|
56
|
-
assert.ok(resp.rows?.length, 'checklist widget data get fail');
|
|
57
|
-
});
|
|
58
|
-
await t.test('DELETE /widget/checklist/:objectid', async () => {
|
|
59
|
-
const resp = await widgetDel({
|
|
60
|
-
pg, session, params: { type: 'checklist', objectid: '1', id: checklistId },
|
|
61
|
-
});
|
|
62
|
-
assert.ok(resp?.data?.id === checklistId, 'checklist widget delete fail');
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
// before GET log request
|
|
66
|
-
await t.test('FAKE POST /widget/history/:objectid', async () => {
|
|
67
|
-
const { changeId } = await pg.query(`insert into log.table_changes(uid, entity_id, entity_type)
|
|
68
|
-
select $1, '1', 'admin.users' returning change_id as "changeId"`, [config.testUser?.uid || '1']).then((res) => res.rows?.[0] || {});
|
|
69
|
-
const res1 = await pg.query(`insert into log.table_changes_data(change_id, entity_key, value_new)
|
|
70
|
-
select $1, 'uid', $2`, [changeId, config.testUser?.uid || '1']);
|
|
71
|
-
// console.log(res.rowCount);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
// history
|
|
75
|
-
await t.test('GET /widget/history/:objectid', async () => {
|
|
76
|
-
const resp = await widgetGet({
|
|
77
|
-
pg, session, params: { type: 'history', objectid: '1' },
|
|
78
|
-
});
|
|
79
|
-
assert.ok(resp.rows?.length > 0, 'history widget data get fail');
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
// file
|
|
83
|
-
let fileId;
|
|
84
|
-
/* @opengis/fastify-file dependency - funcs */
|
|
85
|
-
/* await t.test('POST /widget/file/:objectid', async () => {
|
|
86
|
-
const body = {};
|
|
87
|
-
const resp = await widgetSet({
|
|
88
|
-
pg, params: { type: 'file', objectid: '1' }, session, body,
|
|
89
|
-
});
|
|
90
|
-
fileId = resp.id;
|
|
91
|
-
assert.ok(fileId, 'file widget insert fail');
|
|
92
|
-
}); */
|
|
93
|
-
await t.test('GET /widget/file/:objectid', async () => {
|
|
94
|
-
const { rows } = await pg.query(`insert into crm.files(entity_id, entity_type, uid, file_status)
|
|
95
|
-
select '1', 'admin.users', $1, 1 returning *`, [config.testUser?.uid || '1']);
|
|
96
|
-
fileId = rows?.[0]?.file_id; // substitude for POST request
|
|
97
|
-
const resp = await widgetGet({
|
|
98
|
-
pg, session, params: { type: 'file', objectid: '1' },
|
|
99
|
-
});
|
|
100
|
-
assert.ok(resp.rows?.length, 'file widget data get fail');
|
|
101
|
-
});
|
|
102
|
-
await t.test('DELETE /widget/file/:objectid', async () => {
|
|
103
|
-
const resp = await widgetDel({
|
|
104
|
-
pg, session, params: { type: 'file', objectid: '1', id: fileId },
|
|
105
|
-
});
|
|
106
|
-
assert.ok(resp?.data?.id === fileId, 'file widget delete fail');
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
await t.test('clean after test', async () => {
|
|
110
|
-
const res1 = await pg.query('delete from crm.communications where entity_id=$1', ['1']);
|
|
111
|
-
const res2 = await pg.query('delete from crm.checklists where entity_id=$1', ['1']);
|
|
112
|
-
const res3 = await pg.query('delete from crm.files where entity_id=$1', ['1']);
|
|
113
|
-
const res4 = await pg.query('delete from log.table_changes_data where change_id in (select change_id from log.table_changes where entity_id=$1)', ['1']);
|
|
114
|
-
const res5 = await pg.query('delete from log.table_changes where entity_id=$1', ['1']);
|
|
115
|
-
pg.end();
|
|
116
|
-
});
|
|
117
|
-
});
|
package/test/config.example
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import config from '../config.js';
|
|
2
|
-
|
|
3
|
-
Object.assign(config, {
|
|
4
|
-
folder: 'test/templates',
|
|
5
|
-
pg: {
|
|
6
|
-
host: '192.168.3.160',
|
|
7
|
-
port: 5434,
|
|
8
|
-
database: 'mbk_rivne_dma',
|
|
9
|
-
user: 'postgres',
|
|
10
|
-
password: 'postgres',
|
|
11
|
-
},
|
|
12
|
-
redis: {
|
|
13
|
-
host: '192.168.3.160',
|
|
14
|
-
port: 6379,
|
|
15
|
-
family: 4,
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
export default config;
|
package/test/funcs/pg.test.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
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,62 +0,0 @@
|
|
|
1
|
-
import { test } from 'node:test';
|
|
2
|
-
import assert from 'node:assert';
|
|
3
|
-
|
|
4
|
-
import { handlebars } from '../../utils.js';
|
|
5
|
-
|
|
6
|
-
await test('formatDate helper', async () => {
|
|
7
|
-
await test('should format the date as "dd.mm.yy hh:mi" by default', async () => {
|
|
8
|
-
const template = handlebars.compile('{{formatDate "2021-09-08T12:22:27.983" format="dd.mm.yy hh:mi"}}');
|
|
9
|
-
const result = await template({});
|
|
10
|
-
assert.equal(result, '08.09.2021 12:22');
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
await test('should shift the date by 5 days', async () => {
|
|
14
|
-
const template = handlebars.compile('{{formatDate "2021-09-08T12:22:27.983" shift=5 format="dd.mm.yy"}}');
|
|
15
|
-
const result = await template({});
|
|
16
|
-
assert.equal(result, '13.09.2021');
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
await test('should format the date with Ukrainian month name', async () => {
|
|
20
|
-
const template = handlebars.compile('{{formatDate "2021-09-08T12:22:27.983" format="dd month yy" lang="ua"}}');
|
|
21
|
-
const result = await template({});
|
|
22
|
-
assert.equal(result, '08 Вересень 2021');
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
await test('should format the date with English month name', async () => {
|
|
26
|
-
const template = handlebars.compile('{{formatDate "2021-09-08T12:22:27.983" format="dd mw_en yy" lang="en"}}');
|
|
27
|
-
const result = await template({});
|
|
28
|
-
assert.equal(result, '08 september 2021');
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
await test('should format the current date if input is 0', async () => {
|
|
32
|
-
const template = handlebars.compile('{{formatDate 0 format="dd.mm.yy"}}');
|
|
33
|
-
const currentDate = new Date();
|
|
34
|
-
const expected = `${(`0${currentDate.getDate()}`).slice(-2)}.${(`0${currentDate.getMonth() + 1}`).slice(-2)}.${currentDate.getFullYear()}`;
|
|
35
|
-
const result = await template({});
|
|
36
|
-
assert.equal(result, expected);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
await test('should format the date with time (hh:mi:sec)', async () => {
|
|
40
|
-
const template = handlebars.compile('{{formatDate "2021-09-08T12:22:27.983" format="dd.mm.yy hh:mi:sec"}}');
|
|
41
|
-
const result = await template({});
|
|
42
|
-
assert.equal(result, '08.09.2021 12:22:27');
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
await test('should shift the year by 1', async () => {
|
|
46
|
-
const template = handlebars.compile('{{formatDate "2021-09-08T12:22:27.983" shift_year=1 format="dd.mm.yy"}}');
|
|
47
|
-
const result = await template({});
|
|
48
|
-
assert.equal(result, '08.09.2022');
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
await test('should truncate the date to the first day of the year', async () => {
|
|
52
|
-
const template = handlebars.compile('{{formatDate "2021-09-08T12:22:27.983" trunc="year" format="dd.mm.yy"}}');
|
|
53
|
-
const result = await template({});
|
|
54
|
-
assert.equal(result, '01.01.2021');
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
await test('should truncate the date to the first day of the quarter', async () => {
|
|
58
|
-
const template = handlebars.compile('{{formatDate "2021-09-08T12:22:27.983" trunc="quarter" format="dd.mm.yy"}}');
|
|
59
|
-
const result = await template({});
|
|
60
|
-
assert.equal(result, '01.07.2021');
|
|
61
|
-
});
|
|
62
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"id": "1",
|
|
4
|
-
"text": "Добрий",
|
|
5
|
-
"en": "Good",
|
|
6
|
-
"color": "#006400"
|
|
7
|
-
},
|
|
8
|
-
{
|
|
9
|
-
"id": "2",
|
|
10
|
-
"text": "Задовільний",
|
|
11
|
-
"en": "Satisfying",
|
|
12
|
-
"color": "#ffd700"
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
"id": "3",
|
|
16
|
-
"text": "Незадовільний",
|
|
17
|
-
"en": "Dissatisfying",
|
|
18
|
-
"color": "#b22222"
|
|
19
|
-
}
|
|
20
|
-
]
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"id": "3",
|
|
4
|
-
"text": "Заміна",
|
|
5
|
-
"en": "Replacement",
|
|
6
|
-
"color": "#B8860B"
|
|
7
|
-
},
|
|
8
|
-
{
|
|
9
|
-
"id": "2",
|
|
10
|
-
"text": "Видалення",
|
|
11
|
-
"en": "Removal",
|
|
12
|
-
"color": "#8B0000"
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
"id": "1",
|
|
16
|
-
"text": "Обрізка",
|
|
17
|
-
"en": "Cutting",
|
|
18
|
-
"color": "#DEB887"
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
"id": "4",
|
|
22
|
-
"text": "Відсутні",
|
|
23
|
-
"en": "None",
|
|
24
|
-
"color": "#2E8B57"
|
|
25
|
-
}
|
|
26
|
-
]
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"id": "3",
|
|
4
|
-
"text": "Заміна",
|
|
5
|
-
"en": "Replacement",
|
|
6
|
-
"color": "#B8860B"
|
|
7
|
-
},
|
|
8
|
-
{
|
|
9
|
-
"id": "2",
|
|
10
|
-
"text": "Видалення",
|
|
11
|
-
"en": "Removal",
|
|
12
|
-
"color": "#8B0000"
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
"id": "1",
|
|
16
|
-
"text": "Обрізка",
|
|
17
|
-
"en": "Cutting",
|
|
18
|
-
"color": "#DEB887"
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
"id": "4",
|
|
22
|
-
"text": "Відсутні",
|
|
23
|
-
"en": "None",
|
|
24
|
-
"color": "#2E8B57"
|
|
25
|
-
}
|
|
26
|
-
]
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"id": "4",
|
|
4
|
-
"text": "Газони",
|
|
5
|
-
"en": "Lawns",
|
|
6
|
-
"icon": "/assets/image/icon/60936458728884429/3f714a00-6dec-11ea-b853-074b5683525e.svg",
|
|
7
|
-
"color": "#87a96b",
|
|
8
|
-
"data": "lawns"
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
"id": "8",
|
|
12
|
-
"text": "Пам’ятка природи",
|
|
13
|
-
"en": "Landmark",
|
|
14
|
-
"color": "blue",
|
|
15
|
-
"data": "landmark"
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
"id": "7",
|
|
19
|
-
"text": "Пеньок",
|
|
20
|
-
"en": "Stump",
|
|
21
|
-
"icon": "/assets/image/icon/2322523888191276250/52ec1310-0d2b-11eb-ab6a-23ffd484ced7.svg",
|
|
22
|
-
"color": "#63594C",
|
|
23
|
-
"data": "stump"
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
"id": "2",
|
|
27
|
-
"text": "Дерева",
|
|
28
|
-
"en": "Tree",
|
|
29
|
-
"icon": "/assets/image/icon/2202400955901674510/ba471bb0-5b13-11ea-9003-07912ed5d347.svg",
|
|
30
|
-
"color": "#66cd00",
|
|
31
|
-
"data": "tree"
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
"id": "6",
|
|
35
|
-
"text": "Лунка",
|
|
36
|
-
"en": "Digger",
|
|
37
|
-
"icon": "/assets/image/icon/2322523536775709909/50634550-0d2b-11eb-ab6a-23ffd484ced7.svg",
|
|
38
|
-
"color": "#cdb79e",
|
|
39
|
-
"data": "digger"
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
"id": "1",
|
|
43
|
-
"text": "Кущі",
|
|
44
|
-
"en": "Bush",
|
|
45
|
-
"icon": "/assets/image/icon/2202401113020302354/c62b1580-5b13-11ea-9003-07912ed5d347.svg",
|
|
46
|
-
"color": "#556b2f",
|
|
47
|
-
"data": "bush"
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
"id": "3",
|
|
51
|
-
"text": "Живопліт",
|
|
52
|
-
"en": "Hedge",
|
|
53
|
-
"icon": "/assets/image/icon/59524404264212563/dd365ec0-6e6d-11ea-bc2a-d3dca36653f0.svg",
|
|
54
|
-
"color": "#9fa91f",
|
|
55
|
-
"data": "hedge"
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
"id": "5",
|
|
59
|
-
"text": "Квітники",
|
|
60
|
-
"en": "Flowers",
|
|
61
|
-
"icon": "/assets/image/icon/2254649206885057992/e961fa00-5b13-11ea-9003-07912ed5d347.svg",
|
|
62
|
-
"color": "#ff7f24",
|
|
63
|
-
"data": "flowers"
|
|
64
|
-
}
|
|
65
|
-
]
|
|
@@ -1,33 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
SELECT account_id, account_name FROM crm_acc.crm_account
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/*db:geo_atu*/
|
|
2
|
-
SELECT a.codifier, a.name_ua ||' '||case when b.ato_type_old in (1,2, 4) then '' else b.prefix_ua end ||' '|| coalesce(a.codifier, '')||
|
|
3
|
-
case when b.ato_type_old in (5,6) then coalesce(' (' || a3.name_ua ||' область'||')' ,'')
|
|
4
|
-
else coalesce(' (' || a3.name_ua ||' область, ' || a2.name_ua ||' '||b2.prefix_ua ||' )','') end as name, b.ato_level + 1 as ato_level, st_asgeojson(a.geom::box2d::geometry)::json as geom,
|
|
5
|
-
case when a.object_type in ('O','A','K') then 'regional' when a.object_type in ('B','X','C','T','M','P','H') then 'local' end as resource_level, a.name_ua
|
|
6
|
-
FROM ato_new.ato_new_all a
|
|
7
|
-
left join ato_new.ato_settings_city_and_terrytory b on b.ato_type=a.object_type
|
|
8
|
-
left join ato_new.ato_new_all a2 on a2.region_id=a.parent_level2
|
|
9
|
-
left join ato_new.ato_new_all a3 on a3.region_id=a.parent_level1
|
|
10
|
-
left join ato_new.ato_settings_city_and_terrytory b2 on b2.ato_type=a2.object_type
|
|
11
|
-
where a.object_status <> '3' and a.codifier is not null
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
select contact_id, coalesce(last_name,'')||' '||coalesce(first_name,'') from crm_acc.crm_contact order by last_name
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
select dataset_id,dataset_name from gis.dataset
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
select dataset_id, dataset_name, table_name from gis.dataset
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
select
|
|
2
|
-
codifier,
|
|
3
|
-
case
|
|
4
|
-
when object_type = 'A' then name_ua
|
|
5
|
-
else case
|
|
6
|
-
when object_type in ('P', 'H', 'O', 'B') then name_ua || ' ' || prefix_ua
|
|
7
|
-
else prefix_ua || ' ' || name_ua
|
|
8
|
-
end
|
|
9
|
-
end as title
|
|
10
|
-
from
|
|
11
|
-
ato_new.ato_new_all
|
|
12
|
-
left join ato_new.ato_settings_city_and_terrytory on ato_type = object_type
|
|
13
|
-
where
|
|
14
|
-
codifier is not null
|
|
15
|
-
union
|
|
16
|
-
all
|
|
17
|
-
select
|
|
18
|
-
country_id,
|
|
19
|
-
name_ua as title
|
|
20
|
-
from
|
|
21
|
-
ato_new.country
|
|
22
|
-
where
|
|
23
|
-
country_id = '2845832997045798794'
|
|
24
|
-
union
|
|
25
|
-
all
|
|
26
|
-
select 'UA00000000000000000', 'Україна'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
select dataset_id, dataset_name, table_name from gis.dataset
|
|
@@ -1,21 +0,0 @@
|
|
|
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
|
-
}
|