@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.
- package/README.md +26 -26
- package/config.js +10 -10
- package/index.js +27 -14
- package/package.json +10 -6
- package/server/migrations/log.sql +80 -80
- package/{cron → server/plugins/cron}/funcs/addCron.js +15 -19
- 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 +30 -27
- package/{crud → server/plugins/crud}/funcs/isFileExists.js +13 -13
- 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/{cron/controllers/utils/cronList.js → server/plugins/hook/hookList.js} +1 -1
- package/server/plugins/hook/index.js +8 -0
- package/{logger → server/plugins/logger}/createFileStream.js +2 -2
- 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/{crud/controllers/utils → server/plugins/policy}/xssInjection.js +72 -72
- package/{redis → server/plugins/redis}/funcs/getRedis.js +24 -23
- 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 +22 -22
- 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 +15 -10
- 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 +4 -4
- 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 -112
- 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/{hook/funcs/hookList.js → server/plugins/cron/cronList.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/{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/README.md
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
# fastify-table
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/@opengis/fastify-table)
|
|
4
|
-
[](http://standardjs.com/)
|
|
5
|
-
|
|
6
|
-
It standardizes the entire form building process, while taking care of everything from rendering to validation and processing:
|
|
7
|
-
|
|
8
|
-
- pg
|
|
9
|
-
- redis
|
|
10
|
-
- crud
|
|
11
|
-
|
|
12
|
-
## Install
|
|
13
|
-
|
|
14
|
-
```bash
|
|
15
|
-
npm i @opengis/fastify-table
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
## Usage
|
|
19
|
-
|
|
20
|
-
```js
|
|
21
|
-
fastify.register(import('@opengis/fastify-table'), config);
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## Documenation
|
|
25
|
-
|
|
26
|
-
For a detailed understanding fastify-table, its features, and how to use them, refer to our [Documentation](https://apidocs.softpro.ua/gis.storage/).
|
|
1
|
+
# fastify-table
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@opengis/fastify-table)
|
|
4
|
+
[](http://standardjs.com/)
|
|
5
|
+
|
|
6
|
+
It standardizes the entire form building process, while taking care of everything from rendering to validation and processing:
|
|
7
|
+
|
|
8
|
+
- pg
|
|
9
|
+
- redis
|
|
10
|
+
- crud
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm i @opengis/fastify-table
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
fastify.register(import('@opengis/fastify-table'), config);
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Documenation
|
|
25
|
+
|
|
26
|
+
For a detailed understanding fastify-table, its features, and how to use them, refer to our [Documentation](https://apidocs.softpro.ua/gis.storage/).
|
package/config.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
|
|
3
|
-
const fileName = ['config.json', '/data/local/config.json'].find(el => (fs.existsSync(el) ? el : null));
|
|
4
|
-
const config = fileName ? JSON.parse(fs.readFileSync(fileName)) : {};
|
|
5
|
-
|
|
6
|
-
Object.assign(config, {
|
|
7
|
-
allTemplates: config?.allTemplates || {},
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
export default config;
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
|
|
3
|
+
const fileName = ['config.json', '/data/local/config.json'].find(el => (fs.existsSync(el) ? el : null));
|
|
4
|
+
const config = fileName ? JSON.parse(fs.readFileSync(fileName)) : {};
|
|
5
|
+
|
|
6
|
+
Object.assign(config, {
|
|
7
|
+
allTemplates: config?.allTemplates || {},
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export default config;
|
package/index.js
CHANGED
|
@@ -7,20 +7,27 @@ import fp from 'fastify-plugin';
|
|
|
7
7
|
import config from './config.js';
|
|
8
8
|
// import rclient from './redis/client.js';
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
|
|
10
|
+
// plugins
|
|
11
|
+
import cronPlugin from './server/plugins/cron/index.js';
|
|
12
|
+
import crudPlugin from './server/plugins/crud/index.js';
|
|
13
|
+
// hook, logger, migration - utils only
|
|
14
|
+
import pgPlugin from './server/plugins/pg/index.js';
|
|
15
|
+
import policyPlugin from './server/plugins/policy/index.js';
|
|
16
|
+
import redisPlugin from './server/plugins/redis/index.js';
|
|
17
|
+
import tablePlugin from './server/plugins/table/index.js';
|
|
18
|
+
import utilPlugin from './server/plugins/util/index.js';
|
|
19
|
+
|
|
20
|
+
// routes
|
|
21
|
+
import cronRoutes from './server/routes/cron/index.js';
|
|
22
|
+
import crudRoutes from './server/routes/crud/index.js';
|
|
23
|
+
import loggerRoutes from './server/routes/logger/index.js';
|
|
24
|
+
import propertiesRoutes from './server/routes/properties/index.js';
|
|
25
|
+
import tableRoutes from './server/routes/table/index.js';
|
|
26
|
+
import utilRoutes from './server/routes/util/index.js';
|
|
20
27
|
|
|
21
28
|
// import pgClients from './pg/pgClients.js';
|
|
22
29
|
|
|
23
|
-
import { addTemplateDir, execMigrations
|
|
30
|
+
import { addTemplateDir, execMigrations } from './utils.js';
|
|
24
31
|
|
|
25
32
|
async function plugin(fastify, opt) {
|
|
26
33
|
// console.log(opt);
|
|
@@ -85,16 +92,22 @@ async function plugin(fastify, opt) {
|
|
|
85
92
|
// fastify.decorateRequest('funcs', fastify);
|
|
86
93
|
}
|
|
87
94
|
|
|
95
|
+
// plugins / utils / funcs
|
|
88
96
|
policyPlugin(fastify);
|
|
89
97
|
redisPlugin(fastify);
|
|
90
98
|
await pgPlugin(fastify, opt);
|
|
91
99
|
tablePlugin(fastify, opt);
|
|
92
100
|
crudPlugin(fastify, opt);
|
|
93
|
-
notificationPlugin(fastify, opt);
|
|
94
|
-
widgetPlugin(fastify, opt);
|
|
95
101
|
utilPlugin(fastify, opt);
|
|
96
102
|
cronPlugin(fastify, opt);
|
|
97
|
-
|
|
103
|
+
|
|
104
|
+
// routes / api
|
|
105
|
+
cronRoutes(fastify, opt);
|
|
106
|
+
crudRoutes(fastify, opt);
|
|
107
|
+
loggerRoutes(fastify, opt);
|
|
108
|
+
propertiesRoutes(fastify, opt);
|
|
109
|
+
tableRoutes(fastify, opt);
|
|
110
|
+
utilRoutes(fastify, opt);
|
|
98
111
|
|
|
99
112
|
// core templates && cls
|
|
100
113
|
const filename = fileURLToPath(import.meta.url);
|
package/package.json
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengis/fastify-table",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.57",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "core-plugins",
|
|
6
6
|
"main": "index.js",
|
|
7
|
+
"files": [
|
|
8
|
+
"server/*",
|
|
9
|
+
"index.js",
|
|
10
|
+
"utils.js",
|
|
11
|
+
"config.js"
|
|
12
|
+
],
|
|
7
13
|
"scripts": {
|
|
8
14
|
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
|
|
9
15
|
"test": "node --test",
|
|
@@ -14,15 +20,13 @@
|
|
|
14
20
|
"dependencies": {
|
|
15
21
|
"@fastify/sensible": "^5.0.0",
|
|
16
22
|
"@fastify/url-data": "^5.4.0",
|
|
17
|
-
"@opengis/fastify-hb": "^1.4.
|
|
18
|
-
"@opengis/fastify-table": "^1.1.47",
|
|
23
|
+
"@opengis/fastify-hb": "^1.4.4",
|
|
19
24
|
"fastify": "^4.26.1",
|
|
20
25
|
"fastify-plugin": "^4.0.0",
|
|
21
26
|
"ioredis": "^5.3.2",
|
|
22
27
|
"nodemailer": "^6.5.0",
|
|
23
28
|
"pg": "^8.11.3",
|
|
24
|
-
"pino-abstract-transport": "^2.0.0"
|
|
25
|
-
"rotating-file-stream": "^3.2.3"
|
|
29
|
+
"pino-abstract-transport": "^2.0.0"
|
|
26
30
|
},
|
|
27
31
|
"devDependencies": {
|
|
28
32
|
"@panzoom/panzoom": "^4.5.1",
|
|
@@ -39,4 +43,4 @@
|
|
|
39
43
|
},
|
|
40
44
|
"author": "Softpro",
|
|
41
45
|
"license": "ISC"
|
|
42
|
-
}
|
|
46
|
+
}
|
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
create schema if not exists log;
|
|
2
|
-
|
|
3
|
-
-- DROP TABLE IF EXISTS log.table_changes cascade;
|
|
4
|
-
CREATE TABLE IF NOT EXISTS log.table_changes();
|
|
5
|
-
ALTER TABLE log.table_changes ADD COLUMN IF NOT EXISTS change_id text NOT NULL DEFAULT next_id();
|
|
6
|
-
ALTER TABLE log.table_changes ADD COLUMN IF NOT EXISTS change_type text;
|
|
7
|
-
ALTER TABLE log.table_changes ADD COLUMN IF NOT EXISTS change_date date;
|
|
8
|
-
ALTER TABLE log.table_changes ADD COLUMN IF NOT EXISTS change_user_id text;
|
|
9
|
-
ALTER TABLE log.table_changes ADD COLUMN IF NOT EXISTS entity_type text; -- table_name
|
|
10
|
-
ALTER TABLE log.table_changes ADD COLUMN IF NOT EXISTS entity_id text; -- object_id
|
|
11
|
-
ALTER TABLE log.table_changes ADD COLUMN IF NOT EXISTS uid text;
|
|
12
|
-
ALTER TABLE log.table_changes ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT (now())::timestamp without time zone;
|
|
13
|
-
ALTER TABLE log.table_changes ADD COLUMN IF NOT EXISTS editor_id text;
|
|
14
|
-
ALTER TABLE log.table_changes ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
|
|
15
|
-
|
|
16
|
-
-- DROP TABLE IF EXISTS log.table_changes_data;
|
|
17
|
-
CREATE TABLE IF NOT EXISTS log.table_changes_data();
|
|
18
|
-
ALTER TABLE log.table_changes_data ADD COLUMN IF NOT EXISTS change_data_id text NOT NULL DEFAULT next_id();
|
|
19
|
-
ALTER TABLE log.table_changes_data ADD COLUMN IF NOT EXISTS change_id text not null;
|
|
20
|
-
ALTER TABLE log.table_changes_data ADD COLUMN IF NOT EXISTS entity_key text; -- column_name
|
|
21
|
-
ALTER TABLE log.table_changes_data ADD COLUMN IF NOT EXISTS value_old text;
|
|
22
|
-
ALTER TABLE log.table_changes_data ADD COLUMN IF NOT EXISTS value_new text;
|
|
23
|
-
ALTER TABLE log.table_changes_data ADD COLUMN IF NOT EXISTS uid text;
|
|
24
|
-
ALTER TABLE log.table_changes_data ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT (now())::timestamp without time zone;
|
|
25
|
-
ALTER TABLE log.table_changes_data ADD COLUMN IF NOT EXISTS editor_id text;
|
|
26
|
-
ALTER TABLE log.table_changes_data ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
|
|
27
|
-
|
|
28
|
-
-- DROP TABLE IF EXISTS log.user_auth;
|
|
29
|
-
CREATE TABLE IF NOT EXISTS log.user_auth();
|
|
30
|
-
ALTER TABLE log.user_auth ADD COLUMN IF NOT EXISTS user_auth_id text NOT NULL DEFAULT next_id();
|
|
31
|
-
ALTER TABLE log.user_auth ADD COLUMN IF NOT EXISTS user_id text;
|
|
32
|
-
ALTER TABLE log.user_auth ADD COLUMN IF NOT EXISTS auth_date timestamp without time zone;
|
|
33
|
-
ALTER TABLE log.user_auth ADD COLUMN IF NOT EXISTS auth_type text;
|
|
34
|
-
ALTER TABLE log.user_auth ADD COLUMN IF NOT EXISTS uid text;
|
|
35
|
-
ALTER TABLE log.user_auth ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT (now())::timestamp without time zone;
|
|
36
|
-
ALTER TABLE log.user_auth ADD COLUMN IF NOT EXISTS editor_id text;
|
|
37
|
-
ALTER TABLE log.user_auth ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
|
|
38
|
-
|
|
39
|
-
COMMENT ON TABLE log.table_changes IS 'Логи подій змін в БД';
|
|
40
|
-
COMMENT ON COLUMN log.table_changes.change_type IS 'Тип події (insert / update / delete)';
|
|
41
|
-
COMMENT ON COLUMN log.table_changes.change_date IS 'Дата внесення змін до БД';
|
|
42
|
-
COMMENT ON COLUMN log.table_changes.entity_type IS 'Таблиця, до якої вносяться зміни';
|
|
43
|
-
COMMENT ON COLUMN log.table_changes.entity_id IS 'ID строки, до якої вносяться зміни';
|
|
44
|
-
COMMENT ON COLUMN log.table_changes.change_user_id IS 'Ініціатор внесення змін';
|
|
45
|
-
|
|
46
|
-
COMMENT ON TABLE log.table_changes_data IS 'Логи змін в таблицях БД';
|
|
47
|
-
COMMENT ON COLUMN log.table_changes_data.change_id IS 'ID події зміни в БД';
|
|
48
|
-
COMMENT ON COLUMN log.table_changes_data.entity_key IS 'Колонка таблиці, до якої вносяться зміни';
|
|
49
|
-
COMMENT ON COLUMN log.table_changes_data.value_old IS 'Старе значення';
|
|
50
|
-
COMMENT ON COLUMN log.table_changes_data.value_new IS 'Нове значення';
|
|
51
|
-
|
|
52
|
-
COMMENT ON TABLE log.user_auth IS 'Логи авторизації';
|
|
53
|
-
COMMENT ON COLUMN log.user_auth.user_id IS 'ID користувача';
|
|
54
|
-
COMMENT ON COLUMN log.user_auth.auth_date IS 'Дата авторизації';
|
|
55
|
-
COMMENT ON COLUMN log.user_auth.auth_type IS 'Тип авторизації';
|
|
56
|
-
|
|
57
|
-
ALTER TABLE log.table_changes DROP CONSTRAINT IF EXISTS log_table_changes_pkey cascade;
|
|
58
|
-
ALTER TABLE log.table_changes_data DROP CONSTRAINT IF EXISTS log_table_changes_data_pkey;
|
|
59
|
-
ALTER TABLE log.table_changes_data DROP CONSTRAINT IF EXISTS log_table_changes_data_change_id_fkey;
|
|
60
|
-
ALTER TABLE log.user_auth DROP CONSTRAINT IF EXISTS log_user_auth_pkey;
|
|
61
|
-
ALTER TABLE log.user_auth DROP CONSTRAINT IF EXISTS log_user_auth_user_id_fkey;
|
|
62
|
-
|
|
63
|
-
ALTER TABLE log.table_changes ADD CONSTRAINT log_table_changes_pkey PRIMARY KEY (change_id);
|
|
64
|
-
ALTER TABLE log.table_changes_data ADD CONSTRAINT log_table_changes_data_pkey PRIMARY KEY (change_data_id);
|
|
65
|
-
ALTER TABLE log.table_changes_data ADD CONSTRAINT log_table_changes_data_change_id_fkey FOREIGN KEY (change_id)
|
|
66
|
-
REFERENCES log.table_changes (change_id);
|
|
67
|
-
ALTER TABLE log.user_auth ADD CONSTRAINT log_user_auth_pkey PRIMARY KEY (user_auth_id);
|
|
68
|
-
-- ALTER TABLE log.user_auth ADD CONSTRAINT log_user_auth_user_id_fkey FOREIGN KEY (user_id) REFERENCES admin.users (uid) MATCH SIMPLE;
|
|
69
|
-
|
|
70
|
-
/* drop old columns */
|
|
71
|
-
alter table log.table_changes drop column if exists date_new;
|
|
72
|
-
alter table log.table_changes drop column if exists date_old;
|
|
73
|
-
alter table log.table_changes drop column if exists number_new;
|
|
74
|
-
alter table log.table_changes drop column if exists number_old;
|
|
75
|
-
alter table log.table_changes drop column if exists json_new;
|
|
76
|
-
alter table log.table_changes drop column if exists json_old;
|
|
77
|
-
alter table log.table_changes drop column if exists text_new;
|
|
78
|
-
alter table log.table_changes drop column if exists text_old;
|
|
79
|
-
alter table log.table_changes drop column if exists bool_new;
|
|
80
|
-
alter table log.table_changes drop column if exists bool_old;
|
|
1
|
+
create schema if not exists log;
|
|
2
|
+
|
|
3
|
+
-- DROP TABLE IF EXISTS log.table_changes cascade;
|
|
4
|
+
CREATE TABLE IF NOT EXISTS log.table_changes();
|
|
5
|
+
ALTER TABLE log.table_changes ADD COLUMN IF NOT EXISTS change_id text NOT NULL DEFAULT next_id();
|
|
6
|
+
ALTER TABLE log.table_changes ADD COLUMN IF NOT EXISTS change_type text;
|
|
7
|
+
ALTER TABLE log.table_changes ADD COLUMN IF NOT EXISTS change_date date;
|
|
8
|
+
ALTER TABLE log.table_changes ADD COLUMN IF NOT EXISTS change_user_id text;
|
|
9
|
+
ALTER TABLE log.table_changes ADD COLUMN IF NOT EXISTS entity_type text; -- table_name
|
|
10
|
+
ALTER TABLE log.table_changes ADD COLUMN IF NOT EXISTS entity_id text; -- object_id
|
|
11
|
+
ALTER TABLE log.table_changes ADD COLUMN IF NOT EXISTS uid text;
|
|
12
|
+
ALTER TABLE log.table_changes ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT (now())::timestamp without time zone;
|
|
13
|
+
ALTER TABLE log.table_changes ADD COLUMN IF NOT EXISTS editor_id text;
|
|
14
|
+
ALTER TABLE log.table_changes ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
|
|
15
|
+
|
|
16
|
+
-- DROP TABLE IF EXISTS log.table_changes_data;
|
|
17
|
+
CREATE TABLE IF NOT EXISTS log.table_changes_data();
|
|
18
|
+
ALTER TABLE log.table_changes_data ADD COLUMN IF NOT EXISTS change_data_id text NOT NULL DEFAULT next_id();
|
|
19
|
+
ALTER TABLE log.table_changes_data ADD COLUMN IF NOT EXISTS change_id text not null;
|
|
20
|
+
ALTER TABLE log.table_changes_data ADD COLUMN IF NOT EXISTS entity_key text; -- column_name
|
|
21
|
+
ALTER TABLE log.table_changes_data ADD COLUMN IF NOT EXISTS value_old text;
|
|
22
|
+
ALTER TABLE log.table_changes_data ADD COLUMN IF NOT EXISTS value_new text;
|
|
23
|
+
ALTER TABLE log.table_changes_data ADD COLUMN IF NOT EXISTS uid text;
|
|
24
|
+
ALTER TABLE log.table_changes_data ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT (now())::timestamp without time zone;
|
|
25
|
+
ALTER TABLE log.table_changes_data ADD COLUMN IF NOT EXISTS editor_id text;
|
|
26
|
+
ALTER TABLE log.table_changes_data ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
|
|
27
|
+
|
|
28
|
+
-- DROP TABLE IF EXISTS log.user_auth;
|
|
29
|
+
CREATE TABLE IF NOT EXISTS log.user_auth();
|
|
30
|
+
ALTER TABLE log.user_auth ADD COLUMN IF NOT EXISTS user_auth_id text NOT NULL DEFAULT next_id();
|
|
31
|
+
ALTER TABLE log.user_auth ADD COLUMN IF NOT EXISTS user_id text;
|
|
32
|
+
ALTER TABLE log.user_auth ADD COLUMN IF NOT EXISTS auth_date timestamp without time zone;
|
|
33
|
+
ALTER TABLE log.user_auth ADD COLUMN IF NOT EXISTS auth_type text;
|
|
34
|
+
ALTER TABLE log.user_auth ADD COLUMN IF NOT EXISTS uid text;
|
|
35
|
+
ALTER TABLE log.user_auth ADD COLUMN IF NOT EXISTS cdate timestamp without time zone DEFAULT (now())::timestamp without time zone;
|
|
36
|
+
ALTER TABLE log.user_auth ADD COLUMN IF NOT EXISTS editor_id text;
|
|
37
|
+
ALTER TABLE log.user_auth ADD COLUMN IF NOT EXISTS editor_date timestamp without time zone;
|
|
38
|
+
|
|
39
|
+
COMMENT ON TABLE log.table_changes IS 'Логи подій змін в БД';
|
|
40
|
+
COMMENT ON COLUMN log.table_changes.change_type IS 'Тип події (insert / update / delete)';
|
|
41
|
+
COMMENT ON COLUMN log.table_changes.change_date IS 'Дата внесення змін до БД';
|
|
42
|
+
COMMENT ON COLUMN log.table_changes.entity_type IS 'Таблиця, до якої вносяться зміни';
|
|
43
|
+
COMMENT ON COLUMN log.table_changes.entity_id IS 'ID строки, до якої вносяться зміни';
|
|
44
|
+
COMMENT ON COLUMN log.table_changes.change_user_id IS 'Ініціатор внесення змін';
|
|
45
|
+
|
|
46
|
+
COMMENT ON TABLE log.table_changes_data IS 'Логи змін в таблицях БД';
|
|
47
|
+
COMMENT ON COLUMN log.table_changes_data.change_id IS 'ID події зміни в БД';
|
|
48
|
+
COMMENT ON COLUMN log.table_changes_data.entity_key IS 'Колонка таблиці, до якої вносяться зміни';
|
|
49
|
+
COMMENT ON COLUMN log.table_changes_data.value_old IS 'Старе значення';
|
|
50
|
+
COMMENT ON COLUMN log.table_changes_data.value_new IS 'Нове значення';
|
|
51
|
+
|
|
52
|
+
COMMENT ON TABLE log.user_auth IS 'Логи авторизації';
|
|
53
|
+
COMMENT ON COLUMN log.user_auth.user_id IS 'ID користувача';
|
|
54
|
+
COMMENT ON COLUMN log.user_auth.auth_date IS 'Дата авторизації';
|
|
55
|
+
COMMENT ON COLUMN log.user_auth.auth_type IS 'Тип авторизації';
|
|
56
|
+
|
|
57
|
+
ALTER TABLE log.table_changes DROP CONSTRAINT IF EXISTS log_table_changes_pkey cascade;
|
|
58
|
+
ALTER TABLE log.table_changes_data DROP CONSTRAINT IF EXISTS log_table_changes_data_pkey;
|
|
59
|
+
ALTER TABLE log.table_changes_data DROP CONSTRAINT IF EXISTS log_table_changes_data_change_id_fkey;
|
|
60
|
+
ALTER TABLE log.user_auth DROP CONSTRAINT IF EXISTS log_user_auth_pkey;
|
|
61
|
+
ALTER TABLE log.user_auth DROP CONSTRAINT IF EXISTS log_user_auth_user_id_fkey;
|
|
62
|
+
|
|
63
|
+
ALTER TABLE log.table_changes ADD CONSTRAINT log_table_changes_pkey PRIMARY KEY (change_id);
|
|
64
|
+
ALTER TABLE log.table_changes_data ADD CONSTRAINT log_table_changes_data_pkey PRIMARY KEY (change_data_id);
|
|
65
|
+
ALTER TABLE log.table_changes_data ADD CONSTRAINT log_table_changes_data_change_id_fkey FOREIGN KEY (change_id)
|
|
66
|
+
REFERENCES log.table_changes (change_id);
|
|
67
|
+
ALTER TABLE log.user_auth ADD CONSTRAINT log_user_auth_pkey PRIMARY KEY (user_auth_id);
|
|
68
|
+
-- ALTER TABLE log.user_auth ADD CONSTRAINT log_user_auth_user_id_fkey FOREIGN KEY (user_id) REFERENCES admin.users (uid) MATCH SIMPLE;
|
|
69
|
+
|
|
70
|
+
/* drop old columns */
|
|
71
|
+
alter table log.table_changes drop column if exists date_new;
|
|
72
|
+
alter table log.table_changes drop column if exists date_old;
|
|
73
|
+
alter table log.table_changes drop column if exists number_new;
|
|
74
|
+
alter table log.table_changes drop column if exists number_old;
|
|
75
|
+
alter table log.table_changes drop column if exists json_new;
|
|
76
|
+
alter table log.table_changes drop column if exists json_old;
|
|
77
|
+
alter table log.table_changes drop column if exists text_new;
|
|
78
|
+
alter table log.table_changes drop column if exists text_old;
|
|
79
|
+
alter table log.table_changes drop column if exists bool_new;
|
|
80
|
+
alter table log.table_changes drop column if exists bool_old;
|
|
81
81
|
alter table log.table_changes drop column if exists table_change_id;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { createHash } from 'crypto';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import config from '../../../../config.js';
|
|
4
4
|
import getRedis from '../../redis/funcs/getRedis.js';
|
|
5
5
|
import getPG from '../../pg/funcs/getPG.js';
|
|
6
|
-
import
|
|
6
|
+
import logger from '../../logger/getLogger.js';
|
|
7
|
+
import cronList from '../cronList.js';
|
|
7
8
|
|
|
8
9
|
const md5 = (string) => createHash('md5').update(string).digest('hex');
|
|
9
10
|
|
|
@@ -58,21 +59,21 @@ const interval2ms = {
|
|
|
58
59
|
};
|
|
59
60
|
|
|
60
61
|
async function runCron({
|
|
61
|
-
pg,
|
|
62
|
+
pg, func, name, rclient,
|
|
62
63
|
}) {
|
|
63
64
|
const unique = await verifyUnique(name, rclient);
|
|
64
65
|
|
|
65
66
|
if (!unique) return;
|
|
66
67
|
const db = pg.options.database;
|
|
67
|
-
|
|
68
|
+
logger.debug(`cron.${name}`, 1, db);
|
|
68
69
|
try {
|
|
69
|
-
const data = await func({ pg
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
const data = await func({ pg });
|
|
71
|
+
logger.debug('cron', { db, name, result: data });
|
|
72
|
+
logger.info('cron', { db, name, result: data });
|
|
72
73
|
}
|
|
73
74
|
catch (err) {
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
logger.debug('cron', { db, name, error: err.toString() });
|
|
76
|
+
logger.error('cron', { db, name, error: err.toString() });
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
79
|
|
|
@@ -88,12 +89,7 @@ async function runCron({
|
|
|
88
89
|
* - 10 * 60 - every 10 minutes
|
|
89
90
|
*/
|
|
90
91
|
|
|
91
|
-
export default async function addCron(func, interval
|
|
92
|
-
if (!fastify) {
|
|
93
|
-
throw new Error('not enough params: fastify');
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const { log } = fastify;
|
|
92
|
+
export default async function addCron(func, interval) {
|
|
97
93
|
const { time = {}, disabled = [] } = config.cron || {};
|
|
98
94
|
const pg = getPG();
|
|
99
95
|
const rclient = getRedis();
|
|
@@ -103,7 +99,7 @@ export default async function addCron(func, interval, fastify) {
|
|
|
103
99
|
// if (!config.isServer) return;
|
|
104
100
|
|
|
105
101
|
if (disabled.includes(name)) {
|
|
106
|
-
|
|
102
|
+
logger.debug('cron', { name, message: 'cron disabled' });
|
|
107
103
|
return;
|
|
108
104
|
}
|
|
109
105
|
|
|
@@ -113,19 +109,19 @@ export default async function addCron(func, interval, fastify) {
|
|
|
113
109
|
const [waitMs, intervalMs] = interval2ms[typeof interval](userInterval);
|
|
114
110
|
|
|
115
111
|
if (intervalMs < 1000) {
|
|
116
|
-
|
|
112
|
+
logger.warn('cron', { name, error: `interval ${interval} to small` });
|
|
117
113
|
return;
|
|
118
114
|
}
|
|
119
115
|
|
|
120
116
|
// setTimeout to w8 for the time to start
|
|
121
117
|
setTimeout(() => {
|
|
122
118
|
runCron({
|
|
123
|
-
pg,
|
|
119
|
+
pg, func, name, rclient, logger,
|
|
124
120
|
});
|
|
125
121
|
// interval
|
|
126
122
|
setInterval(() => {
|
|
127
123
|
runCron({
|
|
128
|
-
pg,
|
|
124
|
+
pg, func, name, rclient, logger,
|
|
129
125
|
});
|
|
130
126
|
}, intervalMs);
|
|
131
127
|
}, waitMs);
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
import getTemplate from '../../table/controllers/utils/getTemplate.js';
|
|
3
|
-
import config from '../../config.js';
|
|
1
|
+
import config from '../../../../config.js';
|
|
4
2
|
import pgClients from '../../pg/pgClients.js';
|
|
3
|
+
|
|
4
|
+
import getTemplate from '../../table/funcs/getTemplate.js';
|
|
5
5
|
import applyHook from '../../hook/funcs/applyHook.js';
|
|
6
6
|
|
|
7
|
+
// import { config, pgClients, getTemplate, applyHook } from '../../../../utils.js';
|
|
8
|
+
|
|
7
9
|
const q = `select a.route_id as id, coalesce(b.actions,array['get']) as actions, b.scope
|
|
8
10
|
from admin.routes a
|
|
9
11
|
left join admin.access b on
|
|
@@ -1,27 +1,30 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
1
|
+
import config from '../../../../config.js';
|
|
2
|
+
|
|
3
|
+
import getRedis from '../../redis/funcs/getRedis.js';
|
|
4
|
+
|
|
5
|
+
// import { config, getRedis } from '../../../../utils.js';
|
|
6
|
+
|
|
7
|
+
function sprintf(str, ...args) {
|
|
8
|
+
return str.replace(/%s/g, () => args.shift());
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const keys = {
|
|
12
|
+
r: '%s:token:view:%s',
|
|
13
|
+
a: '%s:token:add:%s',
|
|
14
|
+
w: '%s:token:edit:%s',
|
|
15
|
+
e: '%s:token:exec:%s',
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
async function getToken({
|
|
19
|
+
uid, token, mode = 'r', json,
|
|
20
|
+
}) {
|
|
21
|
+
if (mode === 'r') return token;
|
|
22
|
+
|
|
23
|
+
const rclient = getRedis({ db: 0 });
|
|
24
|
+
|
|
25
|
+
const key = sprintf(keys[mode], config?.pg?.database, uid?.toString());
|
|
26
|
+
const id = await rclient.hget(key, token);
|
|
27
|
+
return json && id?.[0] === '{' ? JSON.parse(id) : id;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default getToken;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { access } from 'fs/promises';
|
|
2
|
-
|
|
3
|
-
const isFileExists = async (filepath) => {
|
|
4
|
-
try {
|
|
5
|
-
await access(filepath);
|
|
6
|
-
return true;
|
|
7
|
-
}
|
|
8
|
-
catch (err) {
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export default isFileExists;
|
|
1
|
+
import { access } from 'fs/promises';
|
|
2
|
+
|
|
3
|
+
const isFileExists = async (filepath) => {
|
|
4
|
+
try {
|
|
5
|
+
await access(filepath);
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
catch (err) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default isFileExists;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { createHash, randomUUID } from 'crypto';
|
|
2
2
|
|
|
3
|
-
import config from '
|
|
3
|
+
import config from '../../../../config.js';
|
|
4
|
+
|
|
4
5
|
import getRedis from '../../redis/funcs/getRedis.js';
|
|
5
6
|
|
|
7
|
+
// import { config, getRedis } from '../../../../utils.js';
|
|
8
|
+
|
|
6
9
|
const generateCodes = (ids, userToken) => {
|
|
7
10
|
const token = userToken || randomUUID();
|
|
8
11
|
const notNullIds = ids.filter((el) => el);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
import config from '../../../../../config.js';
|
|
3
4
|
|
|
4
5
|
export default function getFolder(req, type = 'server') {
|
|
5
6
|
if (!['server', 'local'].includes(type)) throw new Error('params type is invalid');
|
|
@@ -38,12 +38,12 @@ export default async function logChanges({
|
|
|
38
38
|
const filterData = Object.entries({
|
|
39
39
|
change_id: changeId, entity_key: el, value_old: old[el], value_new: data[el], uid,
|
|
40
40
|
})
|
|
41
|
-
.filter((
|
|
41
|
+
.filter((el1) => el1[1] && names.includes(el1[0]));
|
|
42
42
|
|
|
43
43
|
const insertQuery = `insert into log.table_changes_data (${filterData?.map((key) => `"${key[0]}"`).join(',')})
|
|
44
44
|
values (${filterData?.map((key, i) => `$${i + 1}`).join(',')}) returning *`;
|
|
45
45
|
|
|
46
|
-
const { rows = [] } = await pg.query(insertQuery, [...filterData.map((
|
|
46
|
+
const { rows = [] } = await pg.query(insertQuery, [...filterData.map((el1) => (el1[1] && typeof el1[1] === 'object' && (!Array.isArray(el1[1]) || typeof el1[1]?.[0] === 'object') ? JSON.stringify(el1[1]) : el1[1]))]) || {};
|
|
47
47
|
return rows[0];
|
|
48
48
|
}));
|
|
49
49
|
|