@opengis/fastify-table 1.1.56 → 1.1.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +27 -14
- package/package.json +9 -4
- package/{cron → server/plugins/cron}/funcs/addCron.js +12 -12
- package/server/plugins/cron/index.js +6 -0
- package/{crud → server/plugins/crud}/funcs/dataDelete.js +3 -1
- package/{crud → server/plugins/crud}/funcs/dataInsert.js +3 -0
- package/{crud → server/plugins/crud}/funcs/dataUpdate.js +3 -1
- package/{crud → server/plugins/crud}/funcs/getAccess.js +5 -3
- package/{crud → server/plugins/crud}/funcs/getOpt.js +2 -0
- package/{crud → server/plugins/crud}/funcs/getToken.js +4 -1
- package/{crud → server/plugins/crud}/funcs/setOpt.js +3 -0
- package/{crud → server/plugins/crud}/funcs/setToken.js +4 -1
- package/{crud → server/plugins/crud}/funcs/utils/getFolder.js +2 -1
- package/{crud → server/plugins/crud}/funcs/utils/logChanges.js +2 -2
- package/server/plugins/crud/index.js +23 -0
- package/{hook → server/plugins/hook}/funcs/addHook.js +1 -1
- package/{hook → server/plugins/hook}/funcs/applyHook.js +2 -2
- package/server/plugins/hook/index.js +8 -0
- package/{logger → server/plugins/logger}/createFileStream.js +1 -1
- package/{logger → server/plugins/logger}/getLogger.js +1 -1
- package/{migration → server/plugins/migration/funcs}/exec.migrations.js +1 -1
- package/server/plugins/migration/index.js +7 -0
- package/{pg → server/plugins/pg}/funcs/getPG.js +3 -3
- package/{pg → server/plugins/pg}/funcs/getPGAsync.js +3 -3
- package/{pg → server/plugins/pg}/funcs/init.js +2 -4
- package/{pg → server/plugins/pg}/index.js +5 -14
- package/{pg → server/plugins/pg}/pgClients.js +2 -1
- package/{policy → server/plugins/policy}/funcs/checkPolicy.js +1 -1
- package/{crud/controllers/utils → server/plugins/policy/funcs}/checkXSS.js +1 -4
- package/{policy → server/plugins/policy}/index.js +0 -2
- package/{policy/funcs → server/plugins/policy}/sqlInjection.js +1 -1
- package/{redis → server/plugins/redis}/funcs/getRedis.js +2 -1
- package/{redis → server/plugins/redis}/funcs/redisClients.js +1 -0
- package/{redis → server/plugins/redis}/index.js +2 -6
- package/{table → server/plugins/table}/funcs/getFilterSQL/index.js +3 -1
- package/{table/controllers/utils → server/plugins/table/funcs}/getSelectMeta.js +1 -10
- package/{table/controllers/utils → server/plugins/table/funcs}/getTemplate.js +2 -1
- package/{table/controllers/utils → server/plugins/table/funcs}/getTemplatePath.js +3 -3
- package/{table/controllers/utils → server/plugins/table/funcs}/getTemplates.js +2 -1
- package/{table/controllers/utils → server/plugins/table/funcs}/gisIRColumn.js +4 -7
- package/{table → server/plugins/table}/funcs/metaFormat/getSelectVal.js +4 -2
- package/{table → server/plugins/table}/funcs/metaFormat/index.js +3 -1
- package/server/plugins/table/index.js +13 -0
- package/{util → server/plugins/util/funcs}/eventStream.js +1 -0
- package/server/plugins/util/index.js +7 -0
- package/{cron → server/routes/cron}/controllers/cronApi.js +1 -1
- package/{cron → server/routes/cron}/index.js +5 -3
- package/{crud → server/routes/crud}/controllers/deleteCrud.js +2 -2
- package/{crud → server/routes/crud}/controllers/insert.js +5 -3
- package/{crud → server/routes/crud}/controllers/update.js +3 -3
- package/server/routes/crud/index.js +19 -0
- package/{util → server/routes/logger}/controllers/logger.file.js +5 -5
- package/{util → server/routes/logger}/controllers/utils/checkUserAccess.js +1 -1
- package/{util → server/routes/logger}/controllers/utils/getRootDir.js +4 -3
- package/server/routes/logger/index.js +15 -0
- package/{util → server/routes/properties}/controllers/properties.add.js +19 -20
- package/server/routes/properties/controllers/properties.get.js +17 -0
- package/{util → server/routes/properties}/index.js +5 -8
- package/{table → server/routes/table}/controllers/card.js +3 -5
- package/{table → server/routes/table}/controllers/data.js +4 -10
- package/{table → server/routes/table}/controllers/filter.js +3 -4
- package/{table → server/routes/table}/controllers/form.js +1 -1
- package/{table → server/routes/table}/controllers/search.js +15 -17
- package/{table → server/routes/table}/controllers/suggest.js +8 -7
- package/{table → server/routes/table}/controllers/table.js +5 -7
- package/{table → server/routes/table}/index.js +1 -10
- package/{table → server/routes/table}/schema.js +1 -1
- package/{util → server/routes/util}/controllers/next.id.js +1 -1
- package/server/routes/util/index.js +11 -0
- package/utils.js +58 -50
- package/.eslintrc.cjs +0 -44
- package/.gitlab-ci.yml +0 -18
- package/Changelog.md +0 -352
- package/cron/schema.js +0 -8
- package/crud/index.js +0 -31
- package/crud/schema.js +0 -11
- package/docs/.vitepress/abbr.mjs +0 -26
- package/docs/.vitepress/config.mjs +0 -127
- package/docs/.vitepress/navigation.mjs +0 -82
- package/docs/.vitepress/theme/Layout.vue +0 -17
- package/docs/.vitepress/theme/components/NavigationLinks.vue +0 -102
- package/docs/.vitepress/theme/components/Panzoom.vue +0 -169
- package/docs/.vitepress/theme/index.mjs +0 -15
- package/docs/.vitepress/theme/style.scss +0 -163
- package/docs/abbr.json +0 -4
- package/docs/api/cron/cronApi.md +0 -56
- package/docs/api/crud/deleteCrud.md +0 -58
- package/docs/api/crud/insert.md +0 -82
- package/docs/api/crud/update.md +0 -85
- package/docs/api/index.md +0 -47
- package/docs/api/notification/testEmail.md +0 -91
- package/docs/api/table/card.md +0 -73
- package/docs/api/table/data.md +0 -134
- package/docs/api/table/export.md +0 -60
- package/docs/api/table/filter.md +0 -104
- package/docs/api/table/form.md +0 -126
- package/docs/api/table/search.md +0 -123
- package/docs/api/table/suggest.md +0 -156
- package/docs/api/table/table.md +0 -107
- package/docs/api/user/user.cls.id.md +0 -77
- package/docs/api/user/user.cls.md +0 -49
- package/docs/api/user/user.cls.post.md +0 -62
- package/docs/api/user/user.info.md +0 -37
- package/docs/api/utils/logger.file.md +0 -61
- package/docs/api/utils/next.id.md +0 -34
- package/docs/api/utils/properties.add.md +0 -127
- package/docs/api/utils/properties.get.md +0 -73
- package/docs/api/utils/status.monitor.md +0 -36
- package/docs/api/widget/widget.del.md +0 -76
- package/docs/api/widget/widget.get.md +0 -233
- package/docs/api/widget/widget.set.md +0 -88
- package/docs/db/admin.md +0 -947
- package/docs/db/crm.md +0 -564
- package/docs/db/index.md +0 -9
- package/docs/db/log.md +0 -204
- package/docs/hook/card/afterCard.md +0 -20
- package/docs/hook/card/preCard.md +0 -25
- package/docs/hook/data/afterData.md +0 -26
- package/docs/hook/data/preData.md +0 -26
- package/docs/hook/deleteCrud/afterDelete.md +0 -21
- package/docs/hook/deleteCrud/preDelete.md +0 -26
- package/docs/hook/form/afterForm.md +0 -19
- package/docs/hook/form/preForm.md +0 -26
- package/docs/hook/getTemplate/afterTemplate.md +0 -24
- package/docs/hook/getTemplate/preTemplate.md +0 -29
- package/docs/hook/index.md +0 -45
- package/docs/hook/insert/afterInsert.md +0 -41
- package/docs/hook/insert/preInsert.md +0 -25
- package/docs/hook/table/afterTable.md +0 -20
- package/docs/hook/table/preTable.md +0 -25
- package/docs/hook/update/afterUpdate.md +0 -41
- package/docs/hook/update/preUpdate.md +0 -25
- package/docs/index.md +0 -42
- package/docs/public/fastify-dark.svg +0 -4
- package/docs/public/fastify.svg +0 -1
- package/docs/public/logo-short-dark.svg +0 -12
- package/docs/public/logo-short.svg +0 -11
- package/docs/public/logo.svg +0 -19
- package/docs/readme/index.md +0 -121
- package/docs/templates/card.md +0 -83
- package/docs/templates/cls.md +0 -29
- package/docs/templates/filters.md +0 -91
- package/docs/templates/forms.md +0 -139
- package/docs/templates/image.png +0 -0
- package/docs/templates/index.md +0 -28
- package/docs/templates/select.md +0 -90
- package/docs/templates/table.md +0 -162
- package/docs/utils/cron/addCron.md +0 -29
- package/docs/utils/crud/dataInsert.md +0 -52
- package/docs/utils/crud/dataUpdate.md +0 -53
- package/docs/utils/crud/getOpt.md +0 -34
- package/docs/utils/crud/isFileExists.md +0 -38
- package/docs/utils/crud/setOpt.md +0 -38
- package/docs/utils/hook/addHook.md +0 -74
- package/docs/utils/hook/applyHook.md +0 -64
- package/docs/utils/index.md +0 -48
- package/docs/utils/notification/addNotification.md +0 -28
- package/docs/utils/notification/notification.md +0 -41
- package/docs/utils/pg/autoIndex.md +0 -22
- package/docs/utils/pg/getMeta.md +0 -59
- package/docs/utils/pg/getPG.md +0 -34
- package/docs/utils/pg/init.md +0 -30
- package/docs/utils/pg/pg.md +0 -70
- package/docs/utils/redis/getRedis.md +0 -36
- package/docs/utils/redis/rclient.md +0 -74
- package/docs/utils/table/getForm.md +0 -69
- package/docs/utils/table/getMeta.md +0 -56
- package/docs/utils/table/getSelect.md +0 -39
- package/docs/utils/table/getSelectMeta.md +0 -47
- package/docs/utils/table/getTable.md +0 -78
- package/helper.js +0 -30
- package/module/core/select/core.user_mentioned.sql +0 -2
- package/module/test/cls/itree.composition.json +0 -26
- package/module/test/table/test.rest_zone.table.json +0 -266
- package/notification/controllers/readNotifications.js +0 -27
- package/notification/controllers/testEmail.js +0 -46
- package/notification/controllers/userNotifications.js +0 -61
- package/notification/controllers/utils/pin-m-ty-media-record-outline+303070.png +0 -0
- package/notification/funcs/addNotification.js +0 -21
- package/notification/funcs/sendNotification.js +0 -111
- package/notification/funcs/utils/sendEmail.js +0 -39
- package/notification/index.js +0 -18
- package/notification/schema.js +0 -10
- package/server.js +0 -26
- package/table/controllers/utils/getTemplate_old.js +0 -28
- package/test/api/applyHook.test.js +0 -95
- package/test/api/crud.test.js +0 -89
- package/test/api/crud.xss.test.js +0 -80
- package/test/api/notification.test.js +0 -48
- package/test/api/suggest.test.js +0 -66
- package/test/api/table.test.js +0 -134
- package/test/api/user.test.js +0 -85
- package/test/api/widget.test.js +0 -117
- package/test/config.example +0 -18
- package/test/funcs/pg.test.js +0 -34
- package/test/funcs/redis.test.js +0 -19
- package/test/helper/formatDate.test.js +0 -62
- package/test/templates/cls/itree.quality_condition.json +0 -20
- package/test/templates/cls/itree.recommend copy.json +0 -26
- package/test/templates/cls/itree.recommend.json +0 -26
- package/test/templates/cls/itree.type_plant.json +0 -65
- package/test/templates/cls/test.json +0 -10
- package/test/templates/form/cp_building.form.json +0 -33
- package/test/templates/select/account_id.json +0 -4
- package/test/templates/select/account_id.sql +0 -1
- package/test/templates/select/atu.nsdi.ato_level.json +0 -4
- package/test/templates/select/atu.nsdi.ato_level.sql +0 -11
- package/test/templates/select/contact_id.sql +0 -1
- package/test/templates/select/storage.data.json +0 -3
- package/test/templates/select/storage.data.sql +0 -1
- package/test/templates/select/test.storage.data.json +0 -4
- package/test/templates/select/test.storage.data.sql +0 -1
- package/test/templates/select/test.suggest.ato_new.json +0 -4
- package/test/templates/select/test.suggest.ato_new.sql +0 -26
- package/test/templates/select/test.suggest.data.json +0 -5
- package/test/templates/select/test.suggest.data.sql +0 -1
- package/test/templates/select/test.suggest.parent.sql +0 -2
- package/test/templates/table/gis.dataset.table.json +0 -21
- package/test/templates/table/green_space.table.json +0 -383
- package/test/templates/table/service.json +0 -18
- package/user/controllers/user.cls.id.js +0 -14
- package/user/controllers/user.cls.js +0 -71
- package/user/controllers/user.cls.post.js +0 -52
- package/user/controllers/user.info.js +0 -17
- package/user/index.js +0 -17
- package/user/schema.js +0 -17
- package/util/controllers/properties.get.js +0 -17
- package/util/schema.js +0 -19
- package/widget/controllers/utils/historyFormat.js +0 -76
- package/widget/controllers/utils/obj2db.js +0 -13
- package/widget/controllers/widget.del.js +0 -41
- package/widget/controllers/widget.get.js +0 -96
- package/widget/controllers/widget.set.js +0 -74
- package/widget/index.js +0 -40
- /package/{cron/controllers/utils → server/plugins/cron}/cronList.js +0 -0
- /package/{crud → server/plugins/crud}/funcs/isFileExists.js +0 -0
- /package/{hook/funcs → server/plugins/hook}/hookList.js +0 -0
- /package/{logger → server/plugins/logger}/getHooks.js +0 -0
- /package/{logger → server/plugins/logger}/labels.js +0 -0
- /package/{logger → server/plugins/logger}/logger.test.api.js +0 -0
- /package/{logger → server/plugins/logger}/serializers.js +0 -0
- /package/{pg → server/plugins/pg}/funcs/autoIndex.js +0 -0
- /package/{pg → server/plugins/pg}/funcs/getMeta.js +0 -0
- /package/{pg → server/plugins/pg}/funcs/pgClients.js +0 -0
- /package/{crud/controllers/utils → server/plugins/policy}/xssInjection.js +0 -0
- /package/{redis → server/plugins/redis}/client.js +0 -0
- /package/{table/controllers/utils → server/plugins/table/funcs}/addTemplateDir.js +0 -0
- /package/{table → server/plugins/table}/funcs/getFilterSQL/util/formatValue.js +0 -0
- /package/{table → server/plugins/table}/funcs/getFilterSQL/util/getCustomQuery.js +0 -0
- /package/{table → server/plugins/table}/funcs/getFilterSQL/util/getFilterQuery.js +0 -0
- /package/{table → server/plugins/table}/funcs/getFilterSQL/util/getOptimizedQuery.js +0 -0
- /package/{table → server/plugins/table}/funcs/getFilterSQL/util/getTableSql.js +0 -0
- /package/{table/controllers/utils → server/plugins/table/funcs}/getSelect.js +0 -0
- /package/{table/controllers/utils → server/plugins/table/funcs}/loadTemplate.js +0 -0
- /package/{table/controllers/utils → server/plugins/table/funcs}/loadTemplatePath.js +0 -0
- /package/{table/controllers/utils → server/plugins/table/funcs}/userTemplateDir.js +0 -0
- /package/{util → server/routes/util}/controllers/status.monitor.js +0 -0
package/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,8 +20,7 @@
|
|
|
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",
|
|
@@ -38,4 +43,4 @@
|
|
|
38
43
|
},
|
|
39
44
|
"author": "Softpro",
|
|
40
45
|
"license": "ISC"
|
|
41
|
-
}
|
|
46
|
+
}
|
|
@@ -1,10 +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 config from '../../config.js';
|
|
7
6
|
import logger from '../../logger/getLogger.js';
|
|
7
|
+
import cronList from '../cronList.js';
|
|
8
8
|
|
|
9
9
|
const md5 = (string) => createHash('md5').update(string).digest('hex');
|
|
10
10
|
|
|
@@ -59,21 +59,21 @@ const interval2ms = {
|
|
|
59
59
|
};
|
|
60
60
|
|
|
61
61
|
async function runCron({
|
|
62
|
-
pg,
|
|
62
|
+
pg, func, name, rclient,
|
|
63
63
|
}) {
|
|
64
64
|
const unique = await verifyUnique(name, rclient);
|
|
65
65
|
|
|
66
66
|
if (!unique) return;
|
|
67
67
|
const db = pg.options.database;
|
|
68
|
-
|
|
68
|
+
logger.debug(`cron.${name}`, 1, db);
|
|
69
69
|
try {
|
|
70
|
-
const data = await func({ pg
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
const data = await func({ pg });
|
|
71
|
+
logger.debug('cron', { db, name, result: data });
|
|
72
|
+
logger.info('cron', { db, name, result: data });
|
|
73
73
|
}
|
|
74
74
|
catch (err) {
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
logger.debug('cron', { db, name, error: err.toString() });
|
|
76
|
+
logger.error('cron', { db, name, error: err.toString() });
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
@@ -89,7 +89,7 @@ async function runCron({
|
|
|
89
89
|
* - 10 * 60 - every 10 minutes
|
|
90
90
|
*/
|
|
91
91
|
|
|
92
|
-
export default async function addCron(func, interval
|
|
92
|
+
export default async function addCron(func, interval) {
|
|
93
93
|
const { time = {}, disabled = [] } = config.cron || {};
|
|
94
94
|
const pg = getPG();
|
|
95
95
|
const rclient = getRedis();
|
|
@@ -116,12 +116,12 @@ export default async function addCron(func, interval, fastify = {}) {
|
|
|
116
116
|
// setTimeout to w8 for the time to start
|
|
117
117
|
setTimeout(() => {
|
|
118
118
|
runCron({
|
|
119
|
-
pg,
|
|
119
|
+
pg, func, name, rclient, logger,
|
|
120
120
|
});
|
|
121
121
|
// interval
|
|
122
122
|
setInterval(() => {
|
|
123
123
|
runCron({
|
|
124
|
-
pg,
|
|
124
|
+
pg, func, name, rclient, logger,
|
|
125
125
|
});
|
|
126
126
|
}, intervalMs);
|
|
127
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,5 +1,8 @@
|
|
|
1
|
+
import config from '../../../../config.js';
|
|
2
|
+
|
|
1
3
|
import getRedis from '../../redis/funcs/getRedis.js';
|
|
2
|
-
|
|
4
|
+
|
|
5
|
+
// import { config, getRedis } from '../../../../utils.js';
|
|
3
6
|
|
|
4
7
|
function sprintf(str, ...args) {
|
|
5
8
|
return str.replace(/%s/g, () => args.shift());
|
|
@@ -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
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// import getOpt from './funcs/getOpt.js';
|
|
2
|
+
// import setOpt from './funcs/setOpt.js';
|
|
3
|
+
|
|
4
|
+
// import isFileExists from './funcs/isFileExists.js';
|
|
5
|
+
|
|
6
|
+
// import dataUpdate from './funcs/dataUpdate.js';
|
|
7
|
+
// import dataInsert from './funcs/dataInsert.js';
|
|
8
|
+
|
|
9
|
+
// import getAccessFunc from './funcs/getAccess.js';
|
|
10
|
+
|
|
11
|
+
async function plugin(fastify) {
|
|
12
|
+
// fastify.decorate('setOpt', setOpt);
|
|
13
|
+
// fastify.decorate('getOpt', getOpt);
|
|
14
|
+
|
|
15
|
+
// fastify.decorate('dataUpdate', dataUpdate);
|
|
16
|
+
// fastify.decorate('dataInsert', dataInsert);
|
|
17
|
+
|
|
18
|
+
// fastify.decorate('getAccess', getAccessFunc);
|
|
19
|
+
|
|
20
|
+
// fastify.decorate('isFileExists', isFileExists);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default plugin;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import pg from 'pg';
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
import config from '../../../../config.js';
|
|
3
4
|
import pgClients from '../pgClients.js';
|
|
4
5
|
import init from './init.js';
|
|
5
6
|
|
|
6
7
|
function getPG(param) {
|
|
7
8
|
const {
|
|
8
|
-
user, password, host, port, db, database, name: origin,
|
|
9
|
+
user, password, host, port, db, database, name: origin,
|
|
9
10
|
} = param || {};
|
|
10
|
-
// if (funcs?.config) Object.assign(config, { ...funcs.config }); // unit test
|
|
11
11
|
const name = origin || db || database || param || 'client';
|
|
12
12
|
if (pgClients[name]) return pgClients[name];
|
|
13
13
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import pg from 'pg';
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
import config from '../../../../config.js';
|
|
3
4
|
import pgClients from '../pgClients.js';
|
|
4
5
|
import init from './init.js';
|
|
5
6
|
|
|
6
7
|
async function getPGAsync(param) {
|
|
7
8
|
const {
|
|
8
|
-
user, password, host, port, db, database, name: origin,
|
|
9
|
+
user, password, host, port, db, database, name: origin,
|
|
9
10
|
} = typeof param === 'string' ? { db: param } : param || {};
|
|
10
|
-
if (funcs?.config) Object.assign(config, { ...funcs.config }); // unit test
|
|
11
11
|
const name = origin || db || database || param || 'client';
|
|
12
12
|
|
|
13
13
|
if (pgClients[name]?.tlist) return pgClients[name];
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { createHash } from 'crypto';
|
|
2
2
|
|
|
3
|
-
// import pg from 'pg';
|
|
4
3
|
import getRedis from '../../redis/funcs/getRedis.js';
|
|
5
|
-
// import config from '../config.js';
|
|
6
4
|
|
|
7
5
|
async function init(client) {
|
|
8
6
|
const textQuery = `select
|
|
@@ -44,7 +42,7 @@ async function init(client) {
|
|
|
44
42
|
|
|
45
43
|
async function queryCache(query) {
|
|
46
44
|
const rclient = getRedis({ db: 0 });
|
|
47
|
-
const hash =
|
|
45
|
+
const hash = createHash('sha1').update(query).digest('base64');
|
|
48
46
|
const keyCache = `pg:${hash}`;
|
|
49
47
|
const cache = await rclient.get(keyCache);
|
|
50
48
|
if (cache) {
|
|
@@ -1,34 +1,25 @@
|
|
|
1
|
-
// import fp from 'fastify-plugin';
|
|
2
|
-
//import pg from 'pg';
|
|
3
1
|
import pgClients from './funcs/pgClients.js';
|
|
4
2
|
import init from './funcs/init.js';
|
|
3
|
+
import getPG from './funcs/getPG.js';
|
|
5
4
|
import autoIndex from './funcs/autoIndex.js';
|
|
6
5
|
import getMeta from './funcs/getMeta.js';
|
|
7
|
-
import getPG from './funcs/getPG.js';
|
|
8
6
|
|
|
9
7
|
function close() {
|
|
10
|
-
// console.log('pg close');
|
|
11
8
|
Object.keys(pgClients).forEach((el) => {
|
|
12
|
-
// console.log(el);
|
|
13
9
|
pgClients[el].end();
|
|
14
10
|
});
|
|
15
|
-
|
|
16
|
-
// return pgClients.client.end();
|
|
17
11
|
}
|
|
18
12
|
|
|
19
13
|
async function plugin(fastify, config) {
|
|
20
|
-
const client = getPG({ ...config.pg || {}, name: 'client' })
|
|
14
|
+
const client = getPG({ ...config.pg || {}, name: 'client' });
|
|
21
15
|
await init(client);
|
|
22
16
|
fastify.addHook('onRequest', async (req) => {
|
|
23
|
-
// req.funcs = fastify;
|
|
24
17
|
req.pg = req.pg || client;
|
|
25
18
|
});
|
|
26
|
-
//pgClients.client = client;
|
|
27
19
|
|
|
28
|
-
// fastify.decorate('
|
|
29
|
-
fastify.decorate('
|
|
30
|
-
fastify.decorate('
|
|
31
|
-
fastify.decorate('getPG', getPG);
|
|
20
|
+
// fastify.decorate('autoIndex', autoIndex);
|
|
21
|
+
// fastify.decorate('getMeta', getMeta);
|
|
22
|
+
// fastify.decorate('getPG', getPG);
|
|
32
23
|
fastify.addHook('onClose', close);
|
|
33
24
|
}
|
|
34
25
|
|
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
// import client from './client.js';
|
|
2
1
|
import getRedis from './funcs/getRedis.js';
|
|
3
|
-
// import client from './funcs/redisClients.js';
|
|
4
2
|
|
|
5
3
|
function close(fastify) {
|
|
6
4
|
fastify.rclient.quit();
|
|
7
|
-
// fastify.rclient2.quit();
|
|
8
5
|
}
|
|
9
6
|
|
|
10
7
|
async function plugin(fastify) {
|
|
11
8
|
const client = getRedis({ db: 0, funcs: fastify });
|
|
12
9
|
client.getJSON = client.get;
|
|
13
|
-
fastify.decorate('rclient', client);
|
|
14
|
-
fastify.decorate('getRedis', getRedis);
|
|
15
|
-
// fastify.decorate('rclient2', client2);
|
|
10
|
+
// fastify.decorate('rclient', client);
|
|
11
|
+
// fastify.decorate('getRedis', getRedis);
|
|
16
12
|
fastify.addHook('onClose', close);
|
|
17
13
|
}
|
|
18
14
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import getTemplate from '
|
|
1
|
+
import getTemplate from '../getTemplate.js';
|
|
2
2
|
import pgClients from '../../../pg/pgClients.js';
|
|
3
3
|
|
|
4
|
+
// import { getTemplate, pgClients } from '../../../../../utils.js';
|
|
5
|
+
|
|
4
6
|
// filter util
|
|
5
7
|
import getTableSql from './util/getTableSql.js';
|
|
6
8
|
import getFilterQuery from './util/getFilterQuery.js';
|
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import getPG from '../../../pg/funcs/getPG.js';
|
|
1
|
+
import getPG from '../../pg/funcs/getPG.js';
|
|
3
2
|
|
|
4
3
|
import getSelect from './getSelect.js';
|
|
5
4
|
|
|
6
|
-
/*
|
|
7
|
-
function getTable(table) {
|
|
8
|
-
// eslint-disable-next-line class-methods-use-this
|
|
9
|
-
const result = table.toLowerCase().replace(/[\n\r]+/g, ' ').split(' from ').filter((el) => /^[a-z0-9_]+\.[a-z0-9_]+/.test(el))
|
|
10
|
-
.map((el) => el.split(/[ )]/)[0]);
|
|
11
|
-
return result?.pop();
|
|
12
|
-
} */
|
|
13
|
-
|
|
14
5
|
const selectMeta = {};
|
|
15
6
|
|
|
16
7
|
export default async function getSelectMeta({ name, pg: pg1, nocache }) {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { readdir, readFile } from 'fs/promises';
|
|
2
1
|
import path from 'path';
|
|
3
2
|
import yaml from 'js-yaml';
|
|
4
3
|
|
|
4
|
+
import { readdir, readFile } from 'fs/promises';
|
|
5
|
+
|
|
5
6
|
import getTemplatePath from './getTemplatePath.js';
|
|
6
7
|
import loadTemplate from './loadTemplate.js';
|
|
7
8
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
// import { readFile } from 'fs/promises';
|
|
2
|
-
import fs, { existsSync, readdirSync } from 'fs';
|
|
3
1
|
import path from 'path';
|
|
4
|
-
import
|
|
2
|
+
import fs, { existsSync, readdirSync } from 'fs';
|
|
3
|
+
|
|
4
|
+
import config from '../../../../config.js';
|
|
5
5
|
|
|
6
6
|
import loadTemplatePath from './loadTemplatePath.js';
|
|
7
7
|
import userTemplateDir from './userTemplateDir.js';
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import getTemplate from './getTemplate.js';
|
|
5
|
-
import getSelect from './getSelect.js';
|
|
6
|
-
import getFilterSQL from '../../funcs/getFilterSQL/index.js';
|
|
1
|
+
import {
|
|
2
|
+
config, pgClients, getTemplate, getSelect, getFilterSQL,
|
|
3
|
+
} from '../../../../utils.js';
|
|
7
4
|
|
|
8
5
|
export default async function gisIRColumn({
|
|
9
6
|
pg = pgClients.client, layer, column, sql, query = '1=1', filter, state, search, custom,
|
|
@@ -14,7 +11,7 @@ export default async function gisIRColumn({
|
|
|
14
11
|
|
|
15
12
|
const body = await getTemplate('table', layer);
|
|
16
13
|
const fData = await getFilterSQL({
|
|
17
|
-
table: layer,
|
|
14
|
+
table: layer,
|
|
18
15
|
filter,
|
|
19
16
|
state,
|
|
20
17
|
search,
|