@opengis/fastify-table 1.1.40 → 1.1.41
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/Changelog.md +1 -1
- package/README.md +26 -26
- package/config.js +10 -10
- package/cron/controllers/cronApi.js +22 -22
- package/cron/controllers/utils/cronList.js +1 -1
- package/cron/funcs/addCron.js +131 -131
- package/cron/index.js +10 -10
- package/crud/controllers/utils/checkXSS.js +45 -45
- package/crud/controllers/utils/xssInjection.js +72 -72
- package/crud/funcs/getToken.js +27 -27
- package/crud/funcs/isFileExists.js +13 -13
- package/crud/funcs/setToken.js +53 -53
- package/notification/controllers/testEmail.js +49 -49
- package/notification/funcs/utils/sendEmail.js +39 -39
- package/package.json +1 -1
- package/pg/funcs/getPG.js +30 -30
- package/redis/funcs/getRedis.js +23 -23
- package/server/migrations/log.sql +80 -80
- package/table/controllers/card.js +44 -44
- package/table/controllers/filter.js +12 -2
- package/table/controllers/form.js +28 -28
- package/test/api/crud.xss.test.js +72 -72
- package/test/api/user.test.js +3 -2
- package/test/config.example +18 -18
- package/test/funcs/pg.test.js +34 -34
- package/test/funcs/redis.test.js +19 -19
- package/test/templates/cls/test.json +9 -9
- package/test/templates/form/cp_building.form.json +32 -32
- package/test/templates/select/account_id.json +3 -3
- package/test/templates/select/storage.data.json +2 -2
- package/test/templates/table/gis.dataset.table.json +20 -20
- package/user/controllers/user.cls.js +7 -3
- package/util/controllers/next.id.js +4 -4
- package/util/controllers/properties.get.js +19 -19
- package/util/index.js +23 -23
- package/utils.js +50 -19
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export default async function nextId({ pg }) {
|
|
2
|
-
const { id } = await pg.one('select next_id() as id');
|
|
3
|
-
return { id: id.toString() };
|
|
4
|
-
};
|
|
1
|
+
export default async function nextId({ pg }) {
|
|
2
|
+
const { id } = await pg.one('select next_id() as id');
|
|
3
|
+
return { id: id.toString() };
|
|
4
|
+
};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
export default async function getExtraProperties({
|
|
2
|
-
pg, params = {},
|
|
3
|
-
}) {
|
|
4
|
-
const { id } = params;
|
|
5
|
-
if (!id) {
|
|
6
|
-
return { message: 'not enougn params', status: 400 };
|
|
7
|
-
}
|
|
8
|
-
try {
|
|
9
|
-
const { rows = [] } = pg.pk?.['crm.properties']
|
|
10
|
-
? await pg.query(`select property_key, property_type, property_text, property_int,
|
|
11
|
-
property_json, property_date from crm.properties where property_key is not null and object_id=$1`, [id])
|
|
12
|
-
: {};
|
|
13
|
-
if (!rows.length) return {};
|
|
14
|
-
|
|
15
|
-
const data = rows.reduce((acc, curr) => Object.assign(acc, { [curr.property_key]: curr[`property_${curr.property_type}`] }), {});
|
|
16
|
-
return { message: data, status: 200 };
|
|
17
|
-
} catch (err) {
|
|
18
|
-
return { error: err.toString(), status: 500 };
|
|
19
|
-
}
|
|
1
|
+
export default async function getExtraProperties({
|
|
2
|
+
pg, params = {},
|
|
3
|
+
}) {
|
|
4
|
+
const { id } = params;
|
|
5
|
+
if (!id) {
|
|
6
|
+
return { message: 'not enougn params', status: 400 };
|
|
7
|
+
}
|
|
8
|
+
try {
|
|
9
|
+
const { rows = [] } = pg.pk?.['crm.properties']
|
|
10
|
+
? await pg.query(`select property_key, property_type, property_text, property_int,
|
|
11
|
+
property_json, property_date from crm.properties where property_key is not null and object_id=$1`, [id])
|
|
12
|
+
: {};
|
|
13
|
+
if (!rows.length) return {};
|
|
14
|
+
|
|
15
|
+
const data = rows.reduce((acc, curr) => Object.assign(acc, { [curr.property_key]: curr[`property_${curr.property_type}`] }), {});
|
|
16
|
+
return { message: data, status: 200 };
|
|
17
|
+
} catch (err) {
|
|
18
|
+
return { error: err.toString(), status: 500 };
|
|
19
|
+
}
|
|
20
20
|
}
|
package/util/index.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import getExtraProperties from './controllers/properties.get.js';
|
|
2
|
-
import addExtraProperties from './controllers/properties.add.js';
|
|
3
|
-
import nextId from './controllers/next.id.js';
|
|
4
|
-
import statusMonitor from './controllers/status.monitor.js';
|
|
5
|
-
import loggerFile from './controllers/logger.file.js';
|
|
6
|
-
|
|
7
|
-
const propertiesSchema = {
|
|
8
|
-
params: {
|
|
9
|
-
id: { type: 'string', pattern: '^([\\d\\w]+)$' },
|
|
10
|
-
},
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
async function plugin(fastify, config = {}) {
|
|
14
|
-
const prefix = config.prefix || '/api';
|
|
15
|
-
|
|
16
|
-
fastify.get(`${prefix}/next-id`, {}, nextId);
|
|
17
|
-
fastify.get(`${prefix}/status-monitor`, {}, statusMonitor);
|
|
18
|
-
fastify.get(`${prefix}/properties/:id`, { schema: propertiesSchema }, getExtraProperties);
|
|
19
|
-
fastify.post(`${prefix}/properties/:id`, { schema: propertiesSchema }, addExtraProperties);
|
|
20
|
-
fastify.get('/logger-file/*', { config: { policy: ['log'] } }, loggerFile);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export default plugin;
|
|
1
|
+
import getExtraProperties from './controllers/properties.get.js';
|
|
2
|
+
import addExtraProperties from './controllers/properties.add.js';
|
|
3
|
+
import nextId from './controllers/next.id.js';
|
|
4
|
+
import statusMonitor from './controllers/status.monitor.js';
|
|
5
|
+
import loggerFile from './controllers/logger.file.js';
|
|
6
|
+
|
|
7
|
+
const propertiesSchema = {
|
|
8
|
+
params: {
|
|
9
|
+
id: { type: 'string', pattern: '^([\\d\\w]+)$' },
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
async function plugin(fastify, config = {}) {
|
|
14
|
+
const prefix = config.prefix || '/api';
|
|
15
|
+
|
|
16
|
+
fastify.get(`${prefix}/next-id`, {}, nextId);
|
|
17
|
+
fastify.get(`${prefix}/status-monitor`, {}, statusMonitor);
|
|
18
|
+
fastify.get(`${prefix}/properties/:id`, { schema: propertiesSchema }, getExtraProperties);
|
|
19
|
+
fastify.post(`${prefix}/properties/:id`, { schema: propertiesSchema }, addExtraProperties);
|
|
20
|
+
fastify.get('/logger-file/*', { config: { policy: ['log'] } }, loggerFile);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default plugin;
|
package/utils.js
CHANGED
|
@@ -21,7 +21,7 @@ import dataDelete from './crud/funcs/dataDelete.js';
|
|
|
21
21
|
import getToken from './crud/funcs/getToken.js';
|
|
22
22
|
import setToken from './crud/funcs/setToken.js';
|
|
23
23
|
import checkXSS from './crud/controllers/utils/checkXSS.js';
|
|
24
|
-
import
|
|
24
|
+
import getTableColumn from './table/controllers/utils/gisIRColumn.js';
|
|
25
25
|
import getMeta from './pg/funcs/getMeta.js';
|
|
26
26
|
import getAccess from './crud/funcs/getAccess.js';
|
|
27
27
|
import getSelectVal from './table/funcs/metaFormat/getSelectVal.js';
|
|
@@ -32,38 +32,69 @@ import addHook from './hook/funcs/addHook.js';
|
|
|
32
32
|
import execMigrations from './migration/exec.migrations.js';
|
|
33
33
|
import addNotification from './notification/funcs/addNotification.js';
|
|
34
34
|
import sendNotification from './notification/funcs/sendNotification.js';
|
|
35
|
+
import getFilterSQL from './table/funcs/getFilterSQL/index.js';
|
|
36
|
+
|
|
37
|
+
import addCron from './cron/funcs/addCron.js';
|
|
38
|
+
import getOpt from './crud/funcs/getOpt.js';
|
|
39
|
+
import setOpt from './crud/funcs/setOpt.js';
|
|
40
|
+
|
|
41
|
+
import isFileExists from './crud/funcs/isFileExists.js';
|
|
42
|
+
|
|
35
43
|
import logger from './logger/getLogger.js';
|
|
36
44
|
// const logger = false; // test!
|
|
37
45
|
|
|
38
46
|
export default null;
|
|
39
47
|
export {
|
|
48
|
+
|
|
49
|
+
addCron,
|
|
50
|
+
execMigrations,
|
|
51
|
+
getRedis,
|
|
40
52
|
logger,
|
|
53
|
+
isFileExists,
|
|
54
|
+
|
|
55
|
+
// hook
|
|
56
|
+
addHook,
|
|
57
|
+
applyHook,
|
|
58
|
+
|
|
59
|
+
// template
|
|
41
60
|
getTemplate,
|
|
42
61
|
getTemplatePath,
|
|
43
|
-
userTemplateDir,
|
|
44
|
-
metaFormat,
|
|
45
|
-
autoIndex,
|
|
46
62
|
addTemplateDir,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
63
|
+
userTemplateDir,
|
|
64
|
+
|
|
65
|
+
// notification
|
|
66
|
+
addNotification,
|
|
67
|
+
sendNotification,
|
|
68
|
+
|
|
69
|
+
// security
|
|
70
|
+
checkXSS,
|
|
71
|
+
getAccess,
|
|
72
|
+
getToken,
|
|
73
|
+
getOpt,
|
|
74
|
+
setOpt,
|
|
75
|
+
setToken,
|
|
76
|
+
|
|
77
|
+
// crud
|
|
51
78
|
dataInsert,
|
|
52
79
|
dataUpdate,
|
|
53
80
|
dataDelete,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
81
|
+
|
|
82
|
+
// table
|
|
83
|
+
autoIndex,
|
|
84
|
+
metaFormat,
|
|
85
|
+
getFilterSQL,
|
|
59
86
|
getMeta,
|
|
60
|
-
|
|
87
|
+
getTableColumn,
|
|
88
|
+
|
|
89
|
+
// pg
|
|
90
|
+
initPG,
|
|
91
|
+
getPG,
|
|
92
|
+
getPGAsync,
|
|
93
|
+
pgClients,
|
|
94
|
+
|
|
95
|
+
// select
|
|
61
96
|
getSelectVal,
|
|
62
97
|
getSelectMeta,
|
|
63
98
|
getSelect,
|
|
64
|
-
|
|
65
|
-
addHook,
|
|
66
|
-
execMigrations,
|
|
67
|
-
addNotification,
|
|
68
|
-
sendNotification,
|
|
99
|
+
|
|
69
100
|
};
|