@opengis/fastify-table 1.1.55 → 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.
Files changed (260) hide show
  1. package/README.md +26 -26
  2. package/config.js +10 -10
  3. package/index.js +27 -14
  4. package/package.json +10 -6
  5. package/server/migrations/log.sql +80 -80
  6. package/{cron → server/plugins/cron}/funcs/addCron.js +15 -19
  7. package/server/plugins/cron/index.js +6 -0
  8. package/{crud → server/plugins/crud}/funcs/dataDelete.js +3 -1
  9. package/{crud → server/plugins/crud}/funcs/dataInsert.js +3 -0
  10. package/{crud → server/plugins/crud}/funcs/dataUpdate.js +3 -1
  11. package/{crud → server/plugins/crud}/funcs/getAccess.js +5 -3
  12. package/{crud → server/plugins/crud}/funcs/getOpt.js +2 -0
  13. package/{crud → server/plugins/crud}/funcs/getToken.js +30 -27
  14. package/{crud → server/plugins/crud}/funcs/isFileExists.js +13 -13
  15. package/{crud → server/plugins/crud}/funcs/setOpt.js +3 -0
  16. package/{crud → server/plugins/crud}/funcs/setToken.js +4 -1
  17. package/{crud → server/plugins/crud}/funcs/utils/getFolder.js +2 -1
  18. package/{crud → server/plugins/crud}/funcs/utils/logChanges.js +2 -2
  19. package/server/plugins/crud/index.js +23 -0
  20. package/{hook → server/plugins/hook}/funcs/addHook.js +1 -1
  21. package/{hook → server/plugins/hook}/funcs/applyHook.js +2 -2
  22. package/{cron/controllers/utils/cronList.js → server/plugins/hook/hookList.js} +1 -1
  23. package/server/plugins/hook/index.js +8 -0
  24. package/{logger → server/plugins/logger}/createFileStream.js +2 -2
  25. package/{logger → server/plugins/logger}/getLogger.js +1 -1
  26. package/{migration → server/plugins/migration/funcs}/exec.migrations.js +1 -1
  27. package/server/plugins/migration/index.js +7 -0
  28. package/{pg → server/plugins/pg}/funcs/getPG.js +3 -3
  29. package/{pg → server/plugins/pg}/funcs/getPGAsync.js +3 -3
  30. package/{pg → server/plugins/pg}/funcs/init.js +2 -4
  31. package/{pg → server/plugins/pg}/index.js +5 -14
  32. package/{pg → server/plugins/pg}/pgClients.js +2 -1
  33. package/{policy → server/plugins/policy}/funcs/checkPolicy.js +1 -1
  34. package/{crud/controllers/utils → server/plugins/policy/funcs}/checkXSS.js +1 -4
  35. package/{policy → server/plugins/policy}/index.js +0 -2
  36. package/{policy/funcs → server/plugins/policy}/sqlInjection.js +1 -1
  37. package/{crud/controllers/utils → server/plugins/policy}/xssInjection.js +72 -72
  38. package/{redis → server/plugins/redis}/funcs/getRedis.js +24 -23
  39. package/{redis → server/plugins/redis}/funcs/redisClients.js +1 -0
  40. package/{redis → server/plugins/redis}/index.js +2 -6
  41. package/{table → server/plugins/table}/funcs/getFilterSQL/index.js +3 -1
  42. package/{table/controllers/utils → server/plugins/table/funcs}/getSelectMeta.js +1 -10
  43. package/{table/controllers/utils → server/plugins/table/funcs}/getTemplate.js +2 -1
  44. package/{table/controllers/utils → server/plugins/table/funcs}/getTemplatePath.js +3 -3
  45. package/{table/controllers/utils → server/plugins/table/funcs}/getTemplates.js +2 -1
  46. package/{table/controllers/utils → server/plugins/table/funcs}/gisIRColumn.js +4 -7
  47. package/{table → server/plugins/table}/funcs/metaFormat/getSelectVal.js +4 -2
  48. package/{table → server/plugins/table}/funcs/metaFormat/index.js +3 -1
  49. package/server/plugins/table/index.js +13 -0
  50. package/{util → server/plugins/util/funcs}/eventStream.js +1 -0
  51. package/server/plugins/util/index.js +7 -0
  52. package/{cron → server/routes/cron}/controllers/cronApi.js +22 -22
  53. package/{cron → server/routes/cron}/index.js +5 -3
  54. package/{crud → server/routes/crud}/controllers/deleteCrud.js +2 -2
  55. package/{crud → server/routes/crud}/controllers/insert.js +5 -3
  56. package/{crud → server/routes/crud}/controllers/update.js +3 -3
  57. package/server/routes/crud/index.js +19 -0
  58. package/{util → server/routes/logger}/controllers/logger.file.js +5 -5
  59. package/{util → server/routes/logger}/controllers/utils/checkUserAccess.js +1 -1
  60. package/{util → server/routes/logger}/controllers/utils/getRootDir.js +4 -3
  61. package/server/routes/logger/index.js +15 -0
  62. package/{util → server/routes/properties}/controllers/properties.add.js +19 -20
  63. package/server/routes/properties/controllers/properties.get.js +17 -0
  64. package/{util → server/routes/properties}/index.js +5 -8
  65. package/{table → server/routes/table}/controllers/card.js +3 -5
  66. package/{table → server/routes/table}/controllers/data.js +4 -10
  67. package/{table → server/routes/table}/controllers/filter.js +3 -4
  68. package/{table → server/routes/table}/controllers/form.js +1 -1
  69. package/{table → server/routes/table}/controllers/search.js +15 -17
  70. package/{table → server/routes/table}/controllers/suggest.js +15 -10
  71. package/{table → server/routes/table}/controllers/table.js +5 -7
  72. package/{table → server/routes/table}/index.js +1 -10
  73. package/{table → server/routes/table}/schema.js +1 -1
  74. package/{util → server/routes/util}/controllers/next.id.js +4 -4
  75. package/server/routes/util/index.js +11 -0
  76. package/utils.js +58 -50
  77. package/.eslintrc.cjs +0 -44
  78. package/.gitlab-ci.yml +0 -18
  79. package/Changelog.md +0 -352
  80. package/cron/schema.js +0 -8
  81. package/crud/index.js +0 -31
  82. package/crud/schema.js +0 -11
  83. package/docs/.vitepress/abbr.mjs +0 -26
  84. package/docs/.vitepress/config.mjs +0 -127
  85. package/docs/.vitepress/navigation.mjs +0 -82
  86. package/docs/.vitepress/theme/Layout.vue +0 -17
  87. package/docs/.vitepress/theme/components/NavigationLinks.vue +0 -102
  88. package/docs/.vitepress/theme/components/Panzoom.vue +0 -169
  89. package/docs/.vitepress/theme/index.mjs +0 -15
  90. package/docs/.vitepress/theme/style.scss +0 -163
  91. package/docs/abbr.json +0 -4
  92. package/docs/api/cron/cronApi.md +0 -56
  93. package/docs/api/crud/deleteCrud.md +0 -58
  94. package/docs/api/crud/insert.md +0 -82
  95. package/docs/api/crud/update.md +0 -85
  96. package/docs/api/index.md +0 -47
  97. package/docs/api/notification/testEmail.md +0 -91
  98. package/docs/api/table/card.md +0 -73
  99. package/docs/api/table/data.md +0 -134
  100. package/docs/api/table/export.md +0 -60
  101. package/docs/api/table/filter.md +0 -104
  102. package/docs/api/table/form.md +0 -126
  103. package/docs/api/table/search.md +0 -123
  104. package/docs/api/table/suggest.md +0 -156
  105. package/docs/api/table/table.md +0 -107
  106. package/docs/api/user/user.cls.id.md +0 -77
  107. package/docs/api/user/user.cls.md +0 -49
  108. package/docs/api/user/user.cls.post.md +0 -62
  109. package/docs/api/user/user.info.md +0 -37
  110. package/docs/api/utils/logger.file.md +0 -61
  111. package/docs/api/utils/next.id.md +0 -34
  112. package/docs/api/utils/properties.add.md +0 -127
  113. package/docs/api/utils/properties.get.md +0 -73
  114. package/docs/api/utils/status.monitor.md +0 -36
  115. package/docs/api/widget/widget.del.md +0 -76
  116. package/docs/api/widget/widget.get.md +0 -233
  117. package/docs/api/widget/widget.set.md +0 -88
  118. package/docs/db/admin.md +0 -947
  119. package/docs/db/crm.md +0 -564
  120. package/docs/db/index.md +0 -9
  121. package/docs/db/log.md +0 -204
  122. package/docs/hook/card/afterCard.md +0 -20
  123. package/docs/hook/card/preCard.md +0 -25
  124. package/docs/hook/data/afterData.md +0 -26
  125. package/docs/hook/data/preData.md +0 -26
  126. package/docs/hook/deleteCrud/afterDelete.md +0 -21
  127. package/docs/hook/deleteCrud/preDelete.md +0 -26
  128. package/docs/hook/form/afterForm.md +0 -19
  129. package/docs/hook/form/preForm.md +0 -26
  130. package/docs/hook/getTemplate/afterTemplate.md +0 -24
  131. package/docs/hook/getTemplate/preTemplate.md +0 -29
  132. package/docs/hook/index.md +0 -45
  133. package/docs/hook/insert/afterInsert.md +0 -41
  134. package/docs/hook/insert/preInsert.md +0 -25
  135. package/docs/hook/table/afterTable.md +0 -20
  136. package/docs/hook/table/preTable.md +0 -25
  137. package/docs/hook/update/afterUpdate.md +0 -41
  138. package/docs/hook/update/preUpdate.md +0 -25
  139. package/docs/index.md +0 -42
  140. package/docs/public/fastify-dark.svg +0 -4
  141. package/docs/public/fastify.svg +0 -1
  142. package/docs/public/logo-short-dark.svg +0 -12
  143. package/docs/public/logo-short.svg +0 -11
  144. package/docs/public/logo.svg +0 -19
  145. package/docs/readme/index.md +0 -121
  146. package/docs/templates/card.md +0 -83
  147. package/docs/templates/cls.md +0 -29
  148. package/docs/templates/filters.md +0 -91
  149. package/docs/templates/forms.md +0 -139
  150. package/docs/templates/image.png +0 -0
  151. package/docs/templates/index.md +0 -28
  152. package/docs/templates/select.md +0 -90
  153. package/docs/templates/table.md +0 -162
  154. package/docs/utils/cron/addCron.md +0 -29
  155. package/docs/utils/crud/dataInsert.md +0 -52
  156. package/docs/utils/crud/dataUpdate.md +0 -53
  157. package/docs/utils/crud/getOpt.md +0 -34
  158. package/docs/utils/crud/isFileExists.md +0 -38
  159. package/docs/utils/crud/setOpt.md +0 -38
  160. package/docs/utils/hook/addHook.md +0 -74
  161. package/docs/utils/hook/applyHook.md +0 -64
  162. package/docs/utils/index.md +0 -48
  163. package/docs/utils/notification/addNotification.md +0 -28
  164. package/docs/utils/notification/notification.md +0 -41
  165. package/docs/utils/pg/autoIndex.md +0 -22
  166. package/docs/utils/pg/getMeta.md +0 -59
  167. package/docs/utils/pg/getPG.md +0 -34
  168. package/docs/utils/pg/init.md +0 -30
  169. package/docs/utils/pg/pg.md +0 -70
  170. package/docs/utils/redis/getRedis.md +0 -36
  171. package/docs/utils/redis/rclient.md +0 -74
  172. package/docs/utils/table/getForm.md +0 -69
  173. package/docs/utils/table/getMeta.md +0 -56
  174. package/docs/utils/table/getSelect.md +0 -39
  175. package/docs/utils/table/getSelectMeta.md +0 -47
  176. package/docs/utils/table/getTable.md +0 -78
  177. package/helper.js +0 -30
  178. package/module/core/select/core.user_mentioned.sql +0 -2
  179. package/module/test/cls/itree.composition.json +0 -26
  180. package/module/test/table/test.rest_zone.table.json +0 -266
  181. package/notification/controllers/readNotifications.js +0 -27
  182. package/notification/controllers/testEmail.js +0 -46
  183. package/notification/controllers/userNotifications.js +0 -61
  184. package/notification/controllers/utils/pin-m-ty-media-record-outline+303070.png +0 -0
  185. package/notification/funcs/addNotification.js +0 -21
  186. package/notification/funcs/sendNotification.js +0 -112
  187. package/notification/funcs/utils/sendEmail.js +0 -39
  188. package/notification/index.js +0 -18
  189. package/notification/schema.js +0 -10
  190. package/server.js +0 -26
  191. package/table/controllers/utils/getTemplate_old.js +0 -28
  192. package/test/api/applyHook.test.js +0 -95
  193. package/test/api/crud.test.js +0 -89
  194. package/test/api/crud.xss.test.js +0 -80
  195. package/test/api/notification.test.js +0 -48
  196. package/test/api/suggest.test.js +0 -66
  197. package/test/api/table.test.js +0 -134
  198. package/test/api/user.test.js +0 -85
  199. package/test/api/widget.test.js +0 -117
  200. package/test/config.example +0 -18
  201. package/test/funcs/pg.test.js +0 -34
  202. package/test/funcs/redis.test.js +0 -19
  203. package/test/helper/formatDate.test.js +0 -62
  204. package/test/templates/cls/itree.quality_condition.json +0 -20
  205. package/test/templates/cls/itree.recommend copy.json +0 -26
  206. package/test/templates/cls/itree.recommend.json +0 -26
  207. package/test/templates/cls/itree.type_plant.json +0 -65
  208. package/test/templates/cls/test.json +0 -10
  209. package/test/templates/form/cp_building.form.json +0 -33
  210. package/test/templates/select/account_id.json +0 -4
  211. package/test/templates/select/account_id.sql +0 -1
  212. package/test/templates/select/atu.nsdi.ato_level.json +0 -4
  213. package/test/templates/select/atu.nsdi.ato_level.sql +0 -11
  214. package/test/templates/select/contact_id.sql +0 -1
  215. package/test/templates/select/storage.data.json +0 -3
  216. package/test/templates/select/storage.data.sql +0 -1
  217. package/test/templates/select/test.storage.data.json +0 -4
  218. package/test/templates/select/test.storage.data.sql +0 -1
  219. package/test/templates/select/test.suggest.ato_new.json +0 -4
  220. package/test/templates/select/test.suggest.ato_new.sql +0 -26
  221. package/test/templates/select/test.suggest.data.json +0 -5
  222. package/test/templates/select/test.suggest.data.sql +0 -1
  223. package/test/templates/select/test.suggest.parent.sql +0 -2
  224. package/test/templates/table/gis.dataset.table.json +0 -21
  225. package/test/templates/table/green_space.table.json +0 -383
  226. package/test/templates/table/service.json +0 -18
  227. package/user/controllers/user.cls.id.js +0 -14
  228. package/user/controllers/user.cls.js +0 -71
  229. package/user/controllers/user.cls.post.js +0 -52
  230. package/user/controllers/user.info.js +0 -17
  231. package/user/index.js +0 -17
  232. package/user/schema.js +0 -17
  233. package/util/controllers/properties.get.js +0 -17
  234. package/util/schema.js +0 -19
  235. package/widget/controllers/utils/historyFormat.js +0 -76
  236. package/widget/controllers/utils/obj2db.js +0 -13
  237. package/widget/controllers/widget.del.js +0 -41
  238. package/widget/controllers/widget.get.js +0 -96
  239. package/widget/controllers/widget.set.js +0 -74
  240. package/widget/index.js +0 -40
  241. /package/{hook/funcs/hookList.js → server/plugins/cron/cronList.js} +0 -0
  242. /package/{logger → server/plugins/logger}/getHooks.js +0 -0
  243. /package/{logger → server/plugins/logger}/labels.js +0 -0
  244. /package/{logger → server/plugins/logger}/logger.test.api.js +0 -0
  245. /package/{logger → server/plugins/logger}/serializers.js +0 -0
  246. /package/{pg → server/plugins/pg}/funcs/autoIndex.js +0 -0
  247. /package/{pg → server/plugins/pg}/funcs/getMeta.js +0 -0
  248. /package/{pg → server/plugins/pg}/funcs/pgClients.js +0 -0
  249. /package/{redis → server/plugins/redis}/client.js +0 -0
  250. /package/{table/controllers/utils → server/plugins/table/funcs}/addTemplateDir.js +0 -0
  251. /package/{table → server/plugins/table}/funcs/getFilterSQL/util/formatValue.js +0 -0
  252. /package/{table → server/plugins/table}/funcs/getFilterSQL/util/getCustomQuery.js +0 -0
  253. /package/{table → server/plugins/table}/funcs/getFilterSQL/util/getFilterQuery.js +0 -0
  254. /package/{table → server/plugins/table}/funcs/getFilterSQL/util/getOptimizedQuery.js +0 -0
  255. /package/{table → server/plugins/table}/funcs/getFilterSQL/util/getTableSql.js +0 -0
  256. /package/{table/controllers/utils → server/plugins/table/funcs}/getSelect.js +0 -0
  257. /package/{table/controllers/utils → server/plugins/table/funcs}/loadTemplate.js +0 -0
  258. /package/{table/controllers/utils → server/plugins/table/funcs}/loadTemplatePath.js +0 -0
  259. /package/{table/controllers/utils → server/plugins/table/funcs}/userTemplateDir.js +0 -0
  260. /package/{util → server/routes/util}/controllers/status.monitor.js +0 -0
@@ -1,78 +0,0 @@
1
- # getTable
2
-
3
- ## Опис
4
-
5
- Завантажує таблицю
6
-
7
- ```js
8
- getTable(name)
9
- ```
10
-
11
- ## Параметри
12
-
13
- :::tabs
14
- == params
15
-
16
- | Параметр | Тип | Опис |
17
- | -------- | ------ | ------------- |
18
- | name | String | Назва таблиці |
19
-
20
- :::
21
- ## Приклад
22
-
23
- ```js
24
- getTable('gis.dataset.table')
25
- ```
26
-
27
- ## Відповідь
28
-
29
- ::: details Приклад відповіді
30
-
31
- ```json
32
- {
33
- "columns": [
34
- {
35
- "name": "dataset_id",
36
- "title": "22"
37
- },
38
- {
39
- "name": "dataset_name",
40
- "title": "dataset_name"
41
- }
42
- ],
43
- "table": "gis.dataset",
44
- "filters": [
45
- {
46
- "ua": "Будівля",
47
- "data": "cp_building",
48
- "name": "cp_build_id",
49
- "type": "Text"
50
- },
51
- {
52
- "ua": "Рік будівництва",
53
- "name": "cp_year",
54
- "type": "Text"
55
- },
56
- {
57
- "ua": "Замовник ПКД",
58
- "data": "customer_name",
59
- "name": "cp_pkd",
60
- "type": "Text"
61
- },
62
- {
63
- "ua": "Наявність енергоаудиту",
64
- "name": "cp_date_en_audit",
65
- "type": "Date"
66
- },
67
- {
68
- "ua": "Знак сертифікату",
69
- "data": "cp_certificate_mark",
70
- "name": "cp_certificate_mark",
71
- "type": "Check"
72
- }
73
- ]
74
- }
75
-
76
- ```
77
-
78
- :::
package/helper.js DELETED
@@ -1,30 +0,0 @@
1
- import path from 'node:path';
2
- import Fastify from 'fastify';
3
- import config from './test/config.js';
4
- import appService from './index.js';
5
-
6
- import rclient from './redis/client.js';
7
- import pgClients from './pg/pgClients.js';
8
- import { addTemplateDir } from './utils.js';
9
-
10
- // automatically build and tear down our instance
11
- async function build(t) {
12
- // you can set all the options supported by the fastify CLI command
13
- // const argv = [AppPath]
14
- process.env.NODE_ENV = 'production';
15
- const app = Fastify({ logger: false });
16
- app.register(appService, config);
17
- const cwd = process.cwd();
18
- addTemplateDir(path.join(cwd, 'module/test'));
19
- // close the app after we are done
20
- t.after(() => {
21
- // console.log('close app');
22
- pgClients.client.end();
23
- rclient.quit();
24
- app.close();
25
- });
26
-
27
- return app;
28
- }
29
-
30
- export default build;
@@ -1,2 +0,0 @@
1
- select uid, coalesce(sur_name,'')||coalesce(' '||user_name,'') as text, email from admin.users
2
- where enabled order by coalesce(sur_name,'')||coalesce(' '||user_name,'')
@@ -1,26 +0,0 @@
1
- [
2
- {
3
- "id": "2",
4
- "text": "Хвойні",
5
- "en": "Conifers",
6
- "color": "#006400"
7
- },
8
- {
9
- "id": "3",
10
- "text": "Чагарники",
11
- "en": "Shrubs",
12
- "color": "#6B8E23"
13
- },
14
- {
15
- "id": "4",
16
- "text": "Плодові",
17
- "en": "Fruit",
18
- "color": "#808000"
19
- },
20
- {
21
- "id": "1",
22
- "text": "Листяні",
23
- "en": "Deciduous",
24
- "color": "#228B22"
25
- }
26
- ]
@@ -1,266 +0,0 @@
1
- {
2
- "public": true,
3
- "key": "rz_id",
4
- "table": "itree.rest_zones",
5
- "query": "verif",
6
- "sql": [
7
- {
8
- "sql": "select json_agg(file_path) as img_list from admin.doc_file where object_id=t.rz_id and file_status=1",
9
- "name": "image_sql"
10
- }
11
- ],
12
- "form": "rest_zone.form",
13
- "meta": {
14
- "bbox": "geom",
15
- "search": "name",
16
- "title": "name"
17
- },
18
- "columns": [
19
- {
20
- "ua": "Назва об'єкта",
21
- "title": "Назва об'єкта",
22
- "name": "name",
23
- "meta": "title",
24
- "html": "<a href=\"/rest_zone/mode=card/view={{rz_id}}\">{{name}}</a>",
25
- "format": "html"
26
- },
27
- {
28
- "en": "Green zone category",
29
- "ua": "Категорія зеленої зони",
30
- "meta": "category",
31
- "name": "category",
32
- "data": "itree.recrzone_category",
33
- "format": "select"
34
- },
35
- {
36
- "ru": "Вид насаджень",
37
- "ua": "Вид насаджень",
38
- "name": "plant_type",
39
- "meta": "type",
40
- "data": "itree.plant_type",
41
- "format": "select"
42
- },
43
- {
44
- "name": "uid",
45
- "ua": "Хто додав",
46
- "width": "70",
47
- "data": "contact_id",
48
- "format": "select"
49
- },
50
- {
51
- "ru": "Балансоутримувач об'єкта",
52
- "ua": "Балансоутримувач об'єкта",
53
- "hidden": true,
54
- "meta": "other",
55
- "name": "balancer",
56
- "format": "text"
57
- },
58
- {
59
- "ua": "Відповідальний за утримання",
60
- "name": "maintain_respons_gp",
61
- "meta": "other",
62
- "hidden": true,
63
- "format": "text"
64
- },
65
- {
66
- "ua": "Площа, га",
67
- "name": "area",
68
- "meta": "other",
69
- "format": "text"
70
- },
71
- {
72
- "ru": "Форма власності",
73
- "ua": "Форма власності",
74
- "name": "ownership",
75
- "meta": "other",
76
- "data": "itree.ownership",
77
- "format": "select"
78
- },
79
- {
80
- "ru": "Категорія земель",
81
- "ua": "Категорія земель",
82
- "name": "landcategory",
83
- "meta": "other",
84
- "hidden": true,
85
- "data": "itree.landcategory",
86
- "format": "select"
87
- },
88
- {
89
- "ru": "Цільве призначення",
90
- "ua": "Цільве призначення",
91
- "name": "purpose",
92
- "meta": "other",
93
- "hidden": true,
94
- "data": "itree.purpose_type",
95
- "format": "select"
96
- },
97
- {
98
- "ru": "Обмеження щодо використання",
99
- "ua": "Обмеження щодо використання",
100
- "name": "restriction",
101
- "hidden": true,
102
- "meta": "other",
103
- "data": "itree.restriction",
104
- "format": "select"
105
- },
106
- {
107
- "ru": "Площа, зайнята зеленими насадженнями, кв.м",
108
- "ua": "Площа, зайнята зеленими насадженнями, кв.м",
109
- "name": "plants_square",
110
- "meta": "other",
111
- "hidden": true,
112
- "format": "text"
113
- },
114
- {
115
- "ru": "Загальний стан насаджень",
116
- "ua": "Загальний стан насаджень",
117
- "name": "plants_cond",
118
- "meta": "other",
119
- "data": "itree.plants_cond",
120
- "format": "badge"
121
- },
122
- {
123
- "en": "Photo",
124
- "ru": "Фото",
125
- "ua": "Фото",
126
- "html": "{{#each img_list}}<a class='btn btn-xs btn-default' href=\"{{this}}\" download><i class='fa fa-file-text'></i></a><a target=\"_blank\" class='btn btn-xs btn-default' href=\"{{this}}\"><i class='fa fa-eye'></i></a><br>{{/each}}",
127
- "name": "image",
128
- "format": "html"
129
- },
130
- {
131
- "ru": "Видовий склад рослин",
132
- "ua": "Видовий склад рослин",
133
- "name": "composition",
134
- "hidden": true,
135
- "meta": "other",
136
- "data": "itree.composition",
137
- "format": "badge"
138
- },
139
- {
140
- "ru": "Кількість особливо цінних порід та чагарників, шт",
141
- "ua": "Кількість особливо цінних порід та чагарників, шт",
142
- "name": "espec_valuable",
143
- "hidden": true,
144
- "meta": "other",
145
- "format": "text"
146
- },
147
- {
148
- "ru": "Повнота насаджень (кількість дерев на 1 гектар), шт/га",
149
- "ua": "Повнота насаджень (кількість дерев на 1 гектар), шт/га",
150
- "name": "planting_density",
151
- "hidden": true,
152
- "meta": "other",
153
- "format": "text"
154
- },
155
- {
156
- "ru": "Площа, зайнята деревами, кв.м",
157
- "ua": "Площа, зайнята деревами, кв.м",
158
- "name": "tree_square",
159
- "hidden": true,
160
- "meta": "other",
161
- "format": "text"
162
- },
163
- {
164
- "ru": "Балансова вартість",
165
- "ua": "Балансова вартість",
166
- "name": "book_value",
167
- "meta": "other",
168
- "hidden": true,
169
- "format": "text"
170
- },
171
- {
172
- "ru": "Кадастровий номер",
173
- "ua": "Кадастровий номер",
174
- "meta": "other",
175
- "name": "cadnum",
176
- "hidden": true,
177
- "format": "text"
178
- },
179
- {
180
- "ru": "Нормативна грошова оцінка",
181
- "ua": "Нормативна грошова оцінка",
182
- "name": "monetary_valuation",
183
- "meta": "other",
184
- "hidden": true,
185
- "format": "text"
186
- },
187
- {
188
- "ua": "Верифіковано",
189
- "html": " {{#ifCond verif '==' true}} \r\n <span class=\"label\" style=\"color:#fff;background:green\"> Так</span> \r\n {{else}} \r\n <span class=\"label\" style=\"color:#fff;background:red\"> Ні</span>\r\n {{/ifCond}}",
190
- "name": "verif",
191
- "format": "check"
192
- }
193
- ],
194
- "title": "Зони відпочинку",
195
- "filterList": [
196
- {
197
- "ua": "Назва",
198
- "name": "name",
199
- "type": "Text"
200
- },
201
- {
202
- "ua": "Категорія зеленої зони",
203
- "data": "itree.recrzone_category",
204
- "name": "category",
205
- "sort": "asc",
206
- "type": "Check"
207
- },
208
- {
209
- "ua": "Вид насаджень",
210
- "data": "itree.plant_type",
211
- "name": "plant_type",
212
- "sort": "asc",
213
- "type": "Check"
214
- },
215
- {
216
- "ua": "Загальний стан насаджень",
217
- "data": "itree.plants_cond",
218
- "name": "plants_cond",
219
- "sort": "asc",
220
- "type": "Check"
221
- },
222
- {
223
- "ua": "Видовий склад рослин",
224
- "data": "itree.composition",
225
- "name": "composition",
226
- "sort": "asc",
227
- "type": "Check"
228
- },
229
- {
230
- "ua": "Форма власності",
231
- "data": "itree.ownership",
232
- "name": "ownership",
233
- "type": "Check"
234
- },
235
- {
236
- "ua": "Категорія земель",
237
- "data": "itree.landcategory",
238
- "name": "landcategory",
239
- "type": "Check"
240
- },
241
- {
242
- "ua": "Цільове призначення",
243
- "data": "itree.purpose",
244
- "name": "purpose",
245
- "type": "Check"
246
- }
247
- ],
248
- "filterCustom": [
249
- {
250
- "name": "actual",
251
- "label": "Поточний рік",
252
- "sql": "cdate > '2020-01-01'::date"
253
- }
254
- ],
255
- "filterState": [
256
- {
257
- "name": "actual",
258
- "label": "Поточний рік 2",
259
- "sql": "cdate > '2022-09-12'::date"
260
- }
261
- ],
262
- "actions": [
263
- "edit",
264
- "del"
265
- ]
266
- }
@@ -1,27 +0,0 @@
1
- export default async function readNotifications({
2
- pg, params = {}, query = {}, session = {},
3
- }) {
4
- const { uid } = session.passport?.user || {};
5
-
6
- if (!uid) {
7
- return { message: 'access restricted', status: 403 };
8
- }
9
-
10
-
11
- const { userId } = await pg.query('select uid as "userId" from admin.users where $1 in (uid,login) limit 1', [uid])
12
- .then((res) => res.rows?.[0] || {});
13
-
14
- if (!userId) {
15
- return { message: 'access restricted: 2', status: 403 };
16
- }
17
-
18
- const q = `update crm.notifications set read=true where read is not true
19
- and ${params?.id ? 'notification_id=$2' : '1=1'} and addressee_id=$1`;
20
-
21
- if (query.sql) return q;
22
-
23
- const { rowCount = 0 } = await pg.query(q, [userId, params?.id].filter((el) => el));
24
-
25
- return { message: `${rowCount} unread notifications marked as read`, status: 200 };
26
-
27
- }
@@ -1,46 +0,0 @@
1
- import path from 'path';
2
- import { existsSync } from 'fs';
3
- import { fileURLToPath } from 'url';
4
-
5
- import config from '../../config.js';
6
-
7
- const fileName = fileURLToPath(import.meta.url);
8
- const dirName = path.dirname(fileName);
9
-
10
- import notification from '../funcs/sendNotification.js';
11
-
12
- export default async function testNotification({
13
- pg, funcs = {}, log, query = {}, session = {},
14
- }) {
15
- const { local } = config || {};
16
- if (!session?.passport?.user?.user_type?.includes('admin') && !local) {
17
- return { message: 'Forbidden', status: 403 };
18
- }
19
-
20
- const date = new Date().toISOString().split('T')[0];
21
- if (!query.to) {
22
- return { message: 'param to is required', status: 400 };
23
- }
24
-
25
- const {
26
- to, template, table, id, nocache,
27
- } = query;
28
- const file = [path.join(dirName, '../../', 'changelog.md'), path.join(dirName, 'utils', 'pin-m-ty-media-record-outline+303070.png')].filter((el) => existsSync(el));
29
- const data = await notification({
30
- pg,
31
- log,
32
- to,
33
- template,
34
- title: `Test Softpro ${date}`,
35
- table,
36
- nocache,
37
- file,
38
- id,
39
- message: `Test mail Softpro ${date} Lorem Ipsum Lorem Ipsum`,
40
- });
41
-
42
- return {
43
- message: data || 'ok',
44
- };
45
-
46
- }
@@ -1,61 +0,0 @@
1
- // for example only
2
- /*
3
- const res = await funcs.dataInsert({
4
- pg,
5
- table: 'crm.notifications',
6
- data: {
7
- subject: 'notif title',
8
- body: 'notif body',
9
- link: 'http://localhost:3000/api/notification',
10
- addressee_id: userId,
11
- author_id: userId,
12
- },
13
- });
14
- */
15
-
16
- import { getSelectVal } from '../../utils.js';
17
-
18
- const maxLimit = 100;
19
-
20
- export default async function userNotifications({
21
- pg, query = {}, session = {},
22
- }) {
23
- const time = Date.now();
24
-
25
- const { uid } = session.passport?.user || {};
26
-
27
- if (!uid) {
28
- return { message: 'access restricted', status: 403 };
29
- }
30
-
31
- const limit = Math.min(maxLimit, +(query.limit || 5));
32
- const offset = query.page && query.page > 0 ? (query.page - 1) * limit : 0;
33
-
34
-
35
- const { userId } = await pg.query('select uid as "userId" from admin.users where $1 in (uid,login) limit 1', [uid])
36
- .then((res) => res.rows?.[0] || {});
37
-
38
- if (!userId) {
39
- return { message: 'access restricted: 2', status: 403 };
40
- }
41
-
42
- const q = `select notification_id as id, subject, body, cdate,
43
- author_id, read, link, entity_id, (select avatar from admin.users where uid=a.author_id limit 1) as avatar from crm.notifications a where addressee_id=$1 order by cdate desc limit ${limit} offset ${offset}`;
44
-
45
- if (query.sql) return q;
46
-
47
- const { rows = [] } = await pg.query(q, [userId]);
48
-
49
- const values = rows.map((el) => el.author_id)
50
- ?.filter((el, idx, arr) => el && arr.indexOf(el) === idx);
51
-
52
- if (values?.length) {
53
- const vals = await getSelectVal({ name: 'core.user_mentioned', values });
54
- rows.forEach((row) => {
55
- Object.assign(row, { author: vals?.[row.author_id] });
56
- });
57
- }
58
-
59
- return { time: Date.now() - time, total: rows?.length, rows };
60
-
61
- }
@@ -1,21 +0,0 @@
1
- import dataInsert from '../../crud/funcs/dataInsert.js';
2
-
3
- export default async function addNotification({
4
- pg, session = {}, subject, body, link, uid, entity,
5
- }) {
6
- const { uid: author } = session.passport?.user || {};
7
- const res = await dataInsert({
8
- pg,
9
- table: 'crm.notifications',
10
- data: {
11
- subject,
12
- body,
13
- link,
14
- addressee_id: uid,
15
- author_id: author,
16
- entity_id: entity,
17
- uid: author,
18
- },
19
- });
20
- return res?.rows?.[0] || {};
21
- }
@@ -1,112 +0,0 @@
1
- // eslint-disable-next-line max-len, no-control-regex
2
- const emailReg = /(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/g;
3
-
4
- // eslint-disable-next-line import/no-relative-packages
5
- // import downloadFile from '../../../fastify-file/file/funcs/downloadFile.js'; // test only
6
- import { handlebars } from '@opengis/fastify-hb/utils.js';
7
- import pgClients from '../../pg/pgClients.js';
8
- import sendEmail from './utils/sendEmail.js';
9
- import getTemplate from '../../table/controllers/utils/getTemplate.js';
10
- import getRedis from '../../redis/funcs/getRedis.js';
11
-
12
- async function generateNotificationContent({
13
- pg, table, template, id, message, data: data1,
14
- }) {
15
- if (template) {
16
- const data = table && id ? await pg.one(`select * from ${table} where ${pg.pk[table]}=$1`, [id]) : data1;
17
- // console.log(data);
18
- const body = await getTemplate('pt', template);
19
- // console.log(body);
20
- const html = handlebars.compile(body || template || 'template not found')(data || {});
21
- // console.log(html);
22
- return html;
23
- }
24
- return message;
25
- }
26
-
27
- // to do: refactor fastify-file to remove funcs completely
28
- export default async function notification({
29
- pg: pg1,
30
- funcs,
31
- log,
32
- provider = ['email'],
33
- from,
34
- to,
35
- template,
36
- table,
37
- message,
38
- title,
39
- file,
40
- data,
41
- id,
42
- nocache,
43
- }) {
44
- const rclient = getRedis();
45
- const pg = pg1 || pgClients.client;
46
-
47
- if (!pg) throw new Error('need pg');
48
-
49
- if (pg?.readonly) {
50
- return null;
51
- }
52
-
53
- const keyTo = `${pg.options?.database}:mail:${provider[0]}:${to || ''}${id || ''}${table || ''}${title || ''}`;
54
- const uniqueTo = await rclient.setnx(keyTo, 1);
55
- log.info('notification/sent', { keyTo, send: uniqueTo, nocache });
56
-
57
- if (!uniqueTo && !nocache) {
58
- return `already sent: ${keyTo}`;
59
- }
60
- await rclient.expire(keyTo, 1000 * 600);
61
-
62
- if (!to.length) {
63
- return null;
64
- }
65
-
66
- if (!(Array.isArray(provider) && provider.length)) {
67
- return 'notification provider - must be array and not empty';
68
- }
69
-
70
- try {
71
- const html = await generateNotificationContent({
72
- pg, table, template, id, message, data,
73
- });
74
-
75
- // return html;
76
-
77
- if (provider.includes('email')) {
78
- const files = Array.isArray(file) ? file : [file];
79
- const attachments = files?.length ? await Promise.all(files?.filter((el) => el).map(async (el) => {
80
- const content = await funcs.downloadFile(el, { funcs, buffer: true }); // ?
81
- return {
82
- filename: el.split('/').pop(),
83
- encoding: 'base64',
84
- content,
85
- };
86
- })) : [];
87
-
88
- const toEmail = Array.isArray(to) ? to.map((emails) => emails.match(emailReg)?.join(',')) : to;
89
-
90
- const result = await sendEmail({
91
- attachments,
92
- html,
93
- subject: title,
94
- from,
95
- to: toEmail,
96
- });
97
-
98
- log.info('notification', {
99
- provider, title, to: toEmail, from, result, len: message?.length, files,
100
- });
101
-
102
- return result;
103
- }
104
- return null;
105
- }
106
- catch (err) {
107
- log.info('notification/error', {
108
- provider, from, to, err: err.toString(),
109
- });
110
- throw err;
111
- }
112
- }