@opengis/fastify-table 1.1.51 → 1.1.52
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/.gitlab-ci.yml +18 -18
- package/Changelog.md +352 -352
- package/README.md +26 -26
- package/config.js +10 -10
- package/cron/controllers/cronApi.js +22 -22
- package/cron/controllers/utils/cronList.js +1 -1
- package/cron/funcs/addCron.js +132 -132
- package/cron/index.js +12 -10
- package/cron/schema.js +8 -0
- package/crud/controllers/deleteCrud.js +36 -36
- package/crud/controllers/insert.js +71 -71
- package/crud/controllers/update.js +76 -76
- package/crud/controllers/utils/xssInjection.js +72 -72
- package/crud/funcs/dataDelete.js +19 -19
- package/crud/funcs/dataInsert.js +30 -30
- package/crud/funcs/dataUpdate.js +48 -48
- package/crud/funcs/getAccess.js +46 -46
- package/crud/funcs/getOpt.js +10 -10
- package/crud/funcs/getToken.js +27 -27
- package/crud/funcs/isFileExists.js +13 -13
- package/crud/funcs/setOpt.js +16 -16
- package/crud/funcs/setToken.js +53 -53
- package/crud/funcs/utils/getFolder.js +9 -9
- package/crud/funcs/utils/logChanges.js +62 -62
- package/crud/index.js +31 -36
- package/crud/schema.js +11 -0
- package/docs/.vitepress/abbr.mjs +26 -26
- package/docs/.vitepress/config.mjs +127 -127
- package/docs/.vitepress/navigation.mjs +82 -82
- package/docs/.vitepress/theme/Layout.vue +17 -17
- package/docs/.vitepress/theme/components/NavigationLinks.vue +102 -102
- package/docs/.vitepress/theme/components/Panzoom.vue +169 -169
- package/docs/.vitepress/theme/index.mjs +15 -15
- package/docs/.vitepress/theme/style.scss +163 -163
- package/docs/abbr.json +4 -4
- package/docs/api/cron/cronApi.md +56 -56
- package/docs/api/crud/deleteCrud.md +58 -58
- package/docs/api/crud/insert.md +82 -82
- package/docs/api/crud/update.md +85 -85
- package/docs/api/index.md +47 -47
- package/docs/api/notification/testEmail.md +91 -91
- package/docs/api/table/card.md +73 -73
- package/docs/api/table/data.md +134 -134
- package/docs/api/table/export.md +60 -60
- package/docs/api/table/filter.md +104 -104
- package/docs/api/table/form.md +126 -126
- package/docs/api/table/search.md +123 -123
- package/docs/api/table/suggest.md +156 -156
- package/docs/api/table/table.md +107 -107
- package/docs/api/user/user.cls.id.md +77 -77
- package/docs/api/user/user.cls.md +49 -49
- package/docs/api/user/user.cls.post.md +62 -62
- package/docs/api/user/user.info.md +37 -37
- package/docs/api/utils/logger.file.md +60 -60
- package/docs/api/utils/next.id.md +34 -34
- package/docs/api/utils/properties.add.md +127 -127
- package/docs/api/utils/properties.get.md +73 -73
- package/docs/api/utils/status.monitor.md +36 -36
- package/docs/api/widget/widget.del.md +76 -76
- package/docs/api/widget/widget.get.md +233 -233
- package/docs/api/widget/widget.set.md +88 -88
- package/docs/db/admin.md +947 -947
- package/docs/db/crm.md +564 -564
- package/docs/db/index.md +9 -9
- package/docs/db/log.md +204 -204
- package/docs/hook/card/afterCard.md +20 -20
- package/docs/hook/card/preCard.md +25 -25
- package/docs/hook/data/afterData.md +26 -26
- package/docs/hook/data/preData.md +26 -26
- package/docs/hook/deleteCrud/afterDelete.md +21 -21
- package/docs/hook/deleteCrud/preDelete.md +26 -26
- package/docs/hook/form/afterForm.md +19 -19
- package/docs/hook/form/preForm.md +26 -26
- package/docs/hook/getTemplate/afterTemplate.md +24 -24
- package/docs/hook/getTemplate/preTemplate.md +29 -29
- package/docs/hook/index.md +45 -45
- package/docs/hook/insert/afterInsert.md +41 -41
- package/docs/hook/insert/preInsert.md +25 -25
- package/docs/hook/table/afterTable.md +20 -20
- package/docs/hook/table/preTable.md +25 -25
- package/docs/hook/update/afterUpdate.md +41 -41
- package/docs/hook/update/preUpdate.md +25 -25
- package/docs/index.md +42 -42
- package/docs/public/fastify-dark.svg +3 -3
- package/docs/public/logo-short-dark.svg +11 -11
- package/docs/public/logo-short.svg +10 -10
- package/docs/public/logo.svg +19 -19
- package/docs/readme/index.md +121 -121
- package/docs/templates/card.md +83 -83
- package/docs/templates/cls.md +29 -29
- package/docs/templates/filters.md +91 -91
- package/docs/templates/forms.md +139 -139
- package/docs/templates/index.md +28 -28
- package/docs/templates/select.md +90 -90
- package/docs/templates/table.md +162 -162
- package/docs/utils/cron/addCron.md +29 -29
- package/docs/utils/crud/dataInsert.md +51 -51
- package/docs/utils/crud/dataUpdate.md +52 -52
- package/docs/utils/crud/getOpt.md +33 -33
- package/docs/utils/crud/isFileExists.md +37 -37
- package/docs/utils/crud/setOpt.md +37 -37
- package/docs/utils/hook/addHook.md +74 -74
- package/docs/utils/hook/applyHook.md +64 -64
- package/docs/utils/index.md +47 -47
- package/docs/utils/notification/addNotification.md +28 -28
- package/docs/utils/notification/notification.md +41 -41
- package/docs/utils/pg/autoIndex.md +22 -22
- package/docs/utils/pg/getMeta.md +58 -58
- package/docs/utils/pg/getPG.md +34 -34
- package/docs/utils/pg/init.md +29 -29
- package/docs/utils/pg/pg.md +70 -70
- package/docs/utils/redis/getRedis.md +36 -36
- package/docs/utils/redis/rclient.md +74 -74
- package/docs/utils/table/getForm.md +68 -68
- package/docs/utils/table/getMeta.md +55 -55
- package/docs/utils/table/getSelect.md +38 -38
- package/docs/utils/table/getSelectMeta.md +46 -46
- package/docs/utils/table/getTable.md +77 -77
- package/helper.js +30 -30
- package/index.js +105 -105
- package/migration/exec.migrations.js +79 -79
- package/module/core/select/core.user_mentioned.sql +1 -1
- package/module/test/cls/itree.composition.json +25 -25
- package/module/test/table/test.rest_zone.table.json +265 -265
- package/notification/controllers/readNotifications.js +27 -30
- package/notification/controllers/testEmail.js +46 -50
- package/notification/controllers/userNotifications.js +61 -64
- package/notification/funcs/addNotification.js +21 -21
- package/notification/funcs/sendNotification.js +112 -112
- package/notification/index.js +3 -8
- package/notification/schema.js +10 -0
- package/package.json +41 -41
- package/pg/funcs/getMeta.js +29 -29
- package/pg/funcs/getPG.js +30 -30
- package/pg/pgClients.js +20 -20
- package/policy/funcs/checkPolicy.js +92 -92
- package/policy/funcs/sqlInjection.js +33 -33
- package/policy/index.js +14 -14
- package/redis/client.js +8 -8
- package/redis/funcs/getRedis.js +23 -23
- package/redis/funcs/redisClients.js +2 -2
- package/redis/index.js +19 -19
- package/server/migrations/0.sql +78 -78
- package/server/migrations/cls.sql +39 -39
- package/server/migrations/log.sql +80 -80
- package/server/migrations/properties.sql +144 -144
- package/server/migrations/roles.sql +172 -172
- package/server/migrations/users.sql +168 -168
- package/server.js +26 -26
- package/table/controllers/data.js +157 -150
- package/table/controllers/filter.js +61 -50
- package/table/controllers/form.js +42 -42
- package/table/controllers/search.js +76 -80
- package/table/controllers/suggest.js +79 -79
- package/table/controllers/table.js +83 -83
- package/table/controllers/utils/addTemplateDir.js +8 -8
- package/table/controllers/utils/getSelect.js +19 -19
- package/table/controllers/utils/getSelectMeta.js +66 -66
- package/table/controllers/utils/getTemplate_old.js +28 -28
- package/table/controllers/utils/getTemplates.js +18 -18
- package/table/controllers/utils/gisIRColumn.js +72 -67
- package/table/controllers/utils/loadTemplate.js +1 -1
- package/table/controllers/utils/loadTemplatePath.js +1 -1
- package/table/controllers/utils/userTemplateDir.js +1 -1
- package/table/funcs/getFilterSQL/index.js +94 -94
- package/table/funcs/getFilterSQL/util/formatValue.js +170 -170
- package/table/funcs/getFilterSQL/util/getCustomQuery.js +13 -13
- package/table/funcs/getFilterSQL/util/getFilterQuery.js +66 -66
- package/table/funcs/getFilterSQL/util/getOptimizedQuery.js +12 -12
- package/table/funcs/getFilterSQL/util/getTableSql.js +34 -34
- package/table/funcs/metaFormat/getSelectVal.js +21 -21
- package/table/funcs/metaFormat/index.js +28 -28
- package/table/index.js +37 -37
- package/table/schema.js +64 -54
- package/test/api/applyHook.test.js +95 -95
- package/test/api/crud.test.js +89 -89
- package/test/api/crud.xss.test.js +80 -80
- package/test/api/suggest.test.js +66 -66
- package/test/api/table.test.js +134 -134
- package/test/api/user.test.js +85 -85
- package/test/api/widget.test.js +117 -117
- package/test/config.example +18 -18
- package/test/funcs/pg.test.js +34 -34
- package/test/funcs/redis.test.js +19 -19
- package/test/helper/formatDate.test.js +62 -62
- 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/select/test.storage.data.json +3 -3
- package/test/templates/select/test.suggest.ato_new.json +3 -3
- package/test/templates/select/test.suggest.ato_new.sql +25 -25
- package/test/templates/select/test.suggest.data.json +4 -4
- package/test/templates/select/test.suggest.parent.sql +1 -1
- package/test/templates/table/gis.dataset.table.json +20 -20
- package/user/controllers/user.cls.id.js +14 -14
- package/user/controllers/user.cls.js +71 -75
- package/user/controllers/user.cls.post.js +52 -55
- package/user/controllers/user.info.js +17 -21
- package/user/index.js +7 -36
- package/user/schema.js +17 -0
- package/util/controllers/logger.file.js +91 -91
- package/util/controllers/next.id.js +4 -4
- package/util/controllers/properties.add.js +56 -60
- package/util/controllers/properties.get.js +16 -19
- package/util/controllers/status.monitor.js +8 -8
- package/util/controllers/utils/checkUserAccess.js +20 -17
- package/util/controllers/utils/getRootDir.js +25 -25
- package/util/index.js +19 -23
- package/util/schema.js +19 -0
- package/utils.js +106 -104
- package/widget/controllers/utils/historyFormat.js +76 -76
- package/widget/controllers/utils/obj2db.js +13 -13
- package/widget/controllers/widget.del.js +41 -44
- package/widget/controllers/widget.get.js +96 -102
- package/widget/controllers/widget.set.js +74 -79
- package/widget/index.js +40 -40
|
@@ -1,62 +1,62 @@
|
|
|
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
|
+
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,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,4 +1,4 @@
|
|
|
1
|
-
{
|
|
2
|
-
"key": "dataset_id",
|
|
3
|
-
"searchColumn": "table_name"
|
|
1
|
+
{
|
|
2
|
+
"key": "dataset_id",
|
|
3
|
+
"searchColumn": "table_name"
|
|
4
4
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
{
|
|
2
|
-
"db": "mbk_state_old",
|
|
3
|
-
"port": 5437
|
|
1
|
+
{
|
|
2
|
+
"db": "mbk_state_old",
|
|
3
|
+
"port": 5437
|
|
4
4
|
}
|
|
@@ -1,26 +1,26 @@
|
|
|
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
|
|
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
26
|
select 'UA00000000000000000', 'Україна'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
{
|
|
2
|
-
"db": "mbk_poltava",
|
|
3
|
-
"key": "dataset_id",
|
|
4
|
-
"searchColumn": "table_name"
|
|
1
|
+
{
|
|
2
|
+
"db": "mbk_poltava",
|
|
3
|
+
"key": "dataset_id",
|
|
4
|
+
"searchColumn": "table_name"
|
|
5
5
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
select dataset_id, dataset_name, table_name from gis.dataset
|
|
1
|
+
select dataset_id, dataset_name, table_name from gis.dataset
|
|
2
2
|
where dataset_id = '{{parent}}'
|
|
@@ -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
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import userCls from './user.cls.js';
|
|
2
|
-
|
|
3
|
-
export default async function userClsId(req) {
|
|
4
|
-
const { id } = req.params || {};
|
|
5
|
-
const res = await userCls(req);
|
|
6
|
-
if (req.query?.sql || res?.error) {
|
|
7
|
-
return res;
|
|
8
|
-
}
|
|
9
|
-
const { rows = [] } = res?.message || {};
|
|
10
|
-
if (!rows?.length) {
|
|
11
|
-
return { message: `cls not found: ${id}`, status: 404 };
|
|
12
|
-
}
|
|
13
|
-
return { message: rows?.[0], status: 200 };
|
|
14
|
-
}
|
|
1
|
+
import userCls from './user.cls.js';
|
|
2
|
+
|
|
3
|
+
export default async function userClsId(req) {
|
|
4
|
+
const { id } = req.params || {};
|
|
5
|
+
const res = await userCls(req);
|
|
6
|
+
if (req.query?.sql || res?.error) {
|
|
7
|
+
return res;
|
|
8
|
+
}
|
|
9
|
+
const { rows = [] } = res?.message || {};
|
|
10
|
+
if (!rows?.length) {
|
|
11
|
+
return { message: `cls not found: ${id}`, status: 404 };
|
|
12
|
+
}
|
|
13
|
+
return { message: rows?.[0], status: 200 };
|
|
14
|
+
}
|
|
@@ -1,75 +1,71 @@
|
|
|
1
|
-
import { readFile } from 'fs/promises';
|
|
2
|
-
import { getSelect, getTemplatePath } from '../../utils.js';
|
|
3
|
-
|
|
4
|
-
export default async function userCls(req) {
|
|
5
|
-
const {
|
|
6
|
-
pg, params = {}, query = {}, session = {},
|
|
7
|
-
} = req;
|
|
8
|
-
const { uid } = session.passport?.user || {};
|
|
9
|
-
|
|
10
|
-
if (!uid) {
|
|
11
|
-
return { message: 'access restricted', status: 403 };
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
if (query.type && !['json', 'sql'].includes(query.type)) {
|
|
15
|
-
return { message: 'param type is invalid', status: 400 };
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const q = `select user_clsid as id, name, type,
|
|
19
|
-
case when type='json' then (
|
|
20
|
-
${params?.id
|
|
21
|
-
? `(with recursive rows as (
|
|
22
|
-
select user_clsid, code as id, name as text, icon, color, parent
|
|
23
|
-
from admin.user_cls a
|
|
24
|
-
where name=u.name
|
|
25
|
-
union all
|
|
26
|
-
select a.user_clsid, a.code, a.name, a.icon, a.color, a.parent
|
|
27
|
-
from admin.user_cls a
|
|
28
|
-
join rows b on a.parent=b.text
|
|
29
|
-
) select json_agg(row_to_json(q)) from rows q where text<>u.name
|
|
30
|
-
)`
|
|
31
|
-
: 'select count(*)::int from admin.user_cls where parent=u.name'} ) else null end as children,
|
|
32
|
-
case when type='sql' then data else null end as sql from admin.user_cls u
|
|
33
|
-
where (case when type='json' then parent is null else true end)
|
|
34
|
-
and uid=(select uid from admin.users where $1 in (login,uid) limit 1)
|
|
35
|
-
and parent is null and ${query.type ? `type='${query.type}'` : '1=1'} and ${params?.id ? 'u.name=$2' : '1=1'}`;
|
|
36
|
-
|
|
37
|
-
if (query?.sql) return q;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const { rows = [] } = await pg.query(q, [uid, params.id].filter((el) => el));
|
|
41
|
-
|
|
42
|
-
rows.forEach((row) => {
|
|
43
|
-
if (row.type === 'sql') delete row.children;
|
|
44
|
-
if (row.type === 'json') { delete row.sql; Object.assign(row, { children: row.children || (params?.id ? [] : 0) }); }
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
const clsList = query.type === 'sql' ? [] : getTemplatePath('cls'); // skip cls if type sql
|
|
48
|
-
const selectList = query.type === 'json' ? [] : getTemplatePath('select'); // skip sql if type json
|
|
49
|
-
|
|
50
|
-
const userClsNames = rows.map((el) => el.name);
|
|
51
|
-
const selectNames = selectList.map((el) => el[0]);
|
|
52
|
-
|
|
53
|
-
const arr = (clsList || []).concat(selectList || []).map((el) => ({ name: el[0], path: el[1], type: el[2] }))
|
|
54
|
-
?.filter((el) => (params?.id ? el.name === params?.id : true))
|
|
55
|
-
?.filter((el) => ['sql', 'json'].includes(el?.type) && !userClsNames.includes(el.name))
|
|
56
|
-
?.filter((el) => (el?.type === 'json' ? !selectNames?.includes(el?.name) : true));
|
|
57
|
-
|
|
58
|
-
const res = await Promise.all(arr?.map(async (el) => {
|
|
59
|
-
const type = { json: 'cls', sql: 'select' }[el.type] || el.type;
|
|
60
|
-
// const clsData = await getSelect(type, el.name);
|
|
61
|
-
const str = await readFile(el.path, 'utf-8');
|
|
62
|
-
const clsData = type === 'cls' ? JSON.parse(str) : str;
|
|
63
|
-
if (type === 'cls') {
|
|
64
|
-
const children = params?.id ? clsData : clsData?.length || 0;
|
|
65
|
-
return { name: el.name, type: el.type, children };
|
|
66
|
-
}
|
|
67
|
-
return { name: el.name, type: el.type, sql: clsData?.sql || clsData };
|
|
68
|
-
}));
|
|
69
|
-
|
|
70
|
-
return { message: { rows: rows.concat(res) }, status: 200 };
|
|
71
|
-
|
|
72
|
-
catch (err) {
|
|
73
|
-
return { error: err.toString(), status: 200 };
|
|
74
|
-
}
|
|
75
|
-
}
|
|
1
|
+
import { readFile } from 'fs/promises';
|
|
2
|
+
import { getSelect, getTemplatePath } from '../../utils.js';
|
|
3
|
+
|
|
4
|
+
export default async function userCls(req) {
|
|
5
|
+
const {
|
|
6
|
+
pg, params = {}, query = {}, session = {},
|
|
7
|
+
} = req;
|
|
8
|
+
const { uid } = session.passport?.user || {};
|
|
9
|
+
|
|
10
|
+
if (!uid) {
|
|
11
|
+
return { message: 'access restricted', status: 403 };
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (query.type && !['json', 'sql'].includes(query.type)) {
|
|
15
|
+
return { message: 'param type is invalid', status: 400 };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const q = `select user_clsid as id, name, type,
|
|
19
|
+
case when type='json' then (
|
|
20
|
+
${params?.id
|
|
21
|
+
? `(with recursive rows as (
|
|
22
|
+
select user_clsid, code as id, name as text, icon, color, parent
|
|
23
|
+
from admin.user_cls a
|
|
24
|
+
where name=u.name
|
|
25
|
+
union all
|
|
26
|
+
select a.user_clsid, a.code, a.name, a.icon, a.color, a.parent
|
|
27
|
+
from admin.user_cls a
|
|
28
|
+
join rows b on a.parent=b.text
|
|
29
|
+
) select json_agg(row_to_json(q)) from rows q where text<>u.name
|
|
30
|
+
)`
|
|
31
|
+
: 'select count(*)::int from admin.user_cls where parent=u.name'} ) else null end as children,
|
|
32
|
+
case when type='sql' then data else null end as sql from admin.user_cls u
|
|
33
|
+
where (case when type='json' then parent is null else true end)
|
|
34
|
+
and uid=(select uid from admin.users where $1 in (login,uid) limit 1)
|
|
35
|
+
and parent is null and ${query.type ? `type='${query.type}'` : '1=1'} and ${params?.id ? 'u.name=$2' : '1=1'}`;
|
|
36
|
+
|
|
37
|
+
if (query?.sql) return q;
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
const { rows = [] } = await pg.query(q, [uid, params.id].filter((el) => el));
|
|
41
|
+
|
|
42
|
+
rows.forEach((row) => {
|
|
43
|
+
if (row.type === 'sql') delete row.children;
|
|
44
|
+
if (row.type === 'json') { delete row.sql; Object.assign(row, { children: row.children || (params?.id ? [] : 0) }); }
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const clsList = query.type === 'sql' ? [] : getTemplatePath('cls'); // skip cls if type sql
|
|
48
|
+
const selectList = query.type === 'json' ? [] : getTemplatePath('select'); // skip sql if type json
|
|
49
|
+
|
|
50
|
+
const userClsNames = rows.map((el) => el.name);
|
|
51
|
+
const selectNames = selectList.map((el) => el[0]);
|
|
52
|
+
|
|
53
|
+
const arr = (clsList || []).concat(selectList || []).map((el) => ({ name: el[0], path: el[1], type: el[2] }))
|
|
54
|
+
?.filter((el) => (params?.id ? el.name === params?.id : true))
|
|
55
|
+
?.filter((el) => ['sql', 'json'].includes(el?.type) && !userClsNames.includes(el.name))
|
|
56
|
+
?.filter((el) => (el?.type === 'json' ? !selectNames?.includes(el?.name) : true));
|
|
57
|
+
|
|
58
|
+
const res = await Promise.all(arr?.map(async (el) => {
|
|
59
|
+
const type = { json: 'cls', sql: 'select' }[el.type] || el.type;
|
|
60
|
+
// const clsData = await getSelect(type, el.name);
|
|
61
|
+
const str = await readFile(el.path, 'utf-8');
|
|
62
|
+
const clsData = type === 'cls' ? JSON.parse(str) : str;
|
|
63
|
+
if (type === 'cls') {
|
|
64
|
+
const children = params?.id ? clsData : clsData?.length || 0;
|
|
65
|
+
return { name: el.name, type: el.type, children };
|
|
66
|
+
}
|
|
67
|
+
return { name: el.name, type: el.type, sql: clsData?.sql || clsData };
|
|
68
|
+
}));
|
|
69
|
+
|
|
70
|
+
return { message: { rows: rows.concat(res) }, status: 200 };
|
|
71
|
+
}
|
|
@@ -1,55 +1,52 @@
|
|
|
1
|
-
export default async function userClsPost({
|
|
2
|
-
pg, body = {}, session = {},
|
|
3
|
-
}) {
|
|
4
|
-
const { uid } = session.passport?.user || {};
|
|
5
|
-
const {
|
|
6
|
-
name, type = 'json', children = [], sql,
|
|
7
|
-
} = body;
|
|
8
|
-
|
|
9
|
-
if (!uid) {
|
|
10
|
-
return { message: 'access restricted', status: 403 };
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
if (!name) {
|
|
14
|
-
return { message: 'not enough params: name', status: 400 };
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (type === 'json' && (!Array.isArray(children) || !children.length || !children?.[0]?.id)) {
|
|
18
|
-
return { message: 'invalid params: children (array of objects)', status: 400 };
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (type === 'sql' && (!sql || typeof sql !== 'string')) {
|
|
22
|
-
return { message: 'invalid params: sql (string)', status: 400 };
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const { rowCount = 0 } = await pg.query(`with recursive rows as (
|
|
27
|
-
select user_clsid, name, code, icon, color, parent
|
|
28
|
-
from admin.user_cls a
|
|
29
|
-
where name=$1
|
|
30
|
-
union all
|
|
31
|
-
select a.user_clsid, a.name, a.code, a.icon, a.color, a.parent
|
|
32
|
-
from admin.user_cls a
|
|
33
|
-
join rows b on a.parent=b.name
|
|
34
|
-
) delete from admin.user_cls where user_clsid in (select user_clsid from rows )`, [name]);
|
|
35
|
-
console.log('delete old user cls', name, rowCount);
|
|
36
|
-
|
|
37
|
-
const { id, data } = await pg.query('insert into admin.user_cls(name,type,data,uid) values($1,$2,$3,$4) returning user_clsid as id, data', [name, type, sql, uid])
|
|
38
|
-
.then((res) => res.rows?.[0] || {});
|
|
39
|
-
if (type === 'json') {
|
|
40
|
-
if (!id) { return { error: 'insert user cls error', status: 500 }; }
|
|
41
|
-
const q1 = `insert into admin.user_cls(code,name,color,icon,parent,uid)
|
|
42
|
-
|
|
43
|
-
select value->>'id',value->>'text',value->>'color',value->>'icon', '${name.replace(/'/g, "''")}', '${uid}'
|
|
44
|
-
from json_array_elements('${JSON.stringify(children).replace(/'/g, "''")}'::json)
|
|
45
|
-
|
|
46
|
-
returning user_clsid as id, code, name, parent`;
|
|
47
|
-
const { rows = [] } = await pg.query(q1);
|
|
48
|
-
return { id, children: rows };
|
|
49
|
-
}
|
|
50
|
-
return { id, data };
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return { error: err.toString(), status: 500 };
|
|
54
|
-
}
|
|
55
|
-
}
|
|
1
|
+
export default async function userClsPost({
|
|
2
|
+
pg, body = {}, session = {},
|
|
3
|
+
}) {
|
|
4
|
+
const { uid } = session.passport?.user || {};
|
|
5
|
+
const {
|
|
6
|
+
name, type = 'json', children = [], sql,
|
|
7
|
+
} = body;
|
|
8
|
+
|
|
9
|
+
if (!uid) {
|
|
10
|
+
return { message: 'access restricted', status: 403 };
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (!name) {
|
|
14
|
+
return { message: 'not enough params: name', status: 400 };
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (type === 'json' && (!Array.isArray(children) || !children.length || !children?.[0]?.id)) {
|
|
18
|
+
return { message: 'invalid params: children (array of objects)', status: 400 };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (type === 'sql' && (!sql || typeof sql !== 'string')) {
|
|
22
|
+
return { message: 'invalid params: sql (string)', status: 400 };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
const { rowCount = 0 } = await pg.query(`with recursive rows as (
|
|
27
|
+
select user_clsid, name, code, icon, color, parent
|
|
28
|
+
from admin.user_cls a
|
|
29
|
+
where name=$1
|
|
30
|
+
union all
|
|
31
|
+
select a.user_clsid, a.name, a.code, a.icon, a.color, a.parent
|
|
32
|
+
from admin.user_cls a
|
|
33
|
+
join rows b on a.parent=b.name
|
|
34
|
+
) delete from admin.user_cls where user_clsid in (select user_clsid from rows )`, [name]);
|
|
35
|
+
console.log('delete old user cls', name, rowCount);
|
|
36
|
+
|
|
37
|
+
const { id, data } = await pg.query('insert into admin.user_cls(name,type,data,uid) values($1,$2,$3,$4) returning user_clsid as id, data', [name, type, sql, uid])
|
|
38
|
+
.then((res) => res.rows?.[0] || {});
|
|
39
|
+
if (type === 'json') {
|
|
40
|
+
if (!id) { return { error: 'insert user cls error', status: 500 }; }
|
|
41
|
+
const q1 = `insert into admin.user_cls(code,name,color,icon,parent,uid)
|
|
42
|
+
|
|
43
|
+
select value->>'id',value->>'text',value->>'color',value->>'icon', '${name.replace(/'/g, "''")}', '${uid}'
|
|
44
|
+
from json_array_elements('${JSON.stringify(children).replace(/'/g, "''")}'::json)
|
|
45
|
+
|
|
46
|
+
returning user_clsid as id, code, name, parent`;
|
|
47
|
+
const { rows = [] } = await pg.query(q1);
|
|
48
|
+
return { id, children: rows };
|
|
49
|
+
}
|
|
50
|
+
return { id, data };
|
|
51
|
+
|
|
52
|
+
}
|