@opengis/fastify-table 1.4.72 → 1.4.73
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/config.js +7 -1
- package/package.json +3 -2
- package/server/plugins/access/index.mjs +6 -6
- package/server/routes/access/controllers/access.group.js +28 -28
- package/server/routes/access/controllers/access.group.post.js +57 -57
- package/server/routes/access/index.mjs +12 -12
- package/server/routes/access/schema.mjs +67 -67
- package/server/routes/crud/controllers/table.js +1 -1
- package/server/routes/table/controllers/getFormByTable.js +29 -23
- package/server/routes/table/controllers/tableData.js +3 -2
- package/server/routes/table/controllers/utils/formatSchema.js +23 -0
- package/server/routes/util/controllers/code.generator.js +94 -94
- package/utils.js +76 -177
package/config.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
|
-
|
|
2
|
+
import dotenv from 'dotenv';
|
|
3
|
+
|
|
4
|
+
dotenv.config(); // load .env for node, not required for bun
|
|
3
5
|
|
|
4
6
|
import { existsSync, readFileSync } from 'node:fs';
|
|
5
7
|
|
|
@@ -19,6 +21,10 @@ Object.assign(config, {
|
|
|
19
21
|
env: process.env?.NODE_ENV,
|
|
20
22
|
});
|
|
21
23
|
|
|
24
|
+
if (process.env?.NODE_ENV && existsSync(`.env.${process.env.NODE_ENV}`)) {
|
|
25
|
+
dotenv.config({ path: `.env.${process.env.NODE_ENV}` }); // load .env.{{production}} etc. for node, not required for bun
|
|
26
|
+
}
|
|
27
|
+
|
|
22
28
|
function loadEnvConfig() {
|
|
23
29
|
// node --env-file-if-exists=.env.dev --env-file-if-exists=.env server
|
|
24
30
|
if (config.trace) { console.log(Object.keys(process.env)); }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengis/fastify-table",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.73",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "core-plugins",
|
|
6
6
|
"keywords": [
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"redactionList.js"
|
|
21
21
|
],
|
|
22
22
|
"scripts": {
|
|
23
|
+
"patch": "npm version patch && git push && npm publish",
|
|
23
24
|
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
|
|
24
25
|
"test": "node --test",
|
|
25
26
|
"test:helpers": "node --test .\\test\\helpers",
|
|
@@ -59,4 +60,4 @@
|
|
|
59
60
|
},
|
|
60
61
|
"author": "Softpro",
|
|
61
62
|
"license": "ISC"
|
|
62
|
-
}
|
|
63
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import getAdminAccess from './funcs/getAdminAccess.js';
|
|
2
|
-
|
|
3
|
-
async function plugin(fastify) {
|
|
4
|
-
// fastify.decorate('getAdminAccess', getAdminAccess);
|
|
5
|
-
}
|
|
6
|
-
export default plugin;
|
|
1
|
+
import getAdminAccess from './funcs/getAdminAccess.js';
|
|
2
|
+
|
|
3
|
+
async function plugin(fastify) {
|
|
4
|
+
// fastify.decorate('getAdminAccess', getAdminAccess);
|
|
5
|
+
}
|
|
6
|
+
export default plugin;
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { pgClients, getAdminAccess } from '../../../../utils.js';
|
|
2
|
-
|
|
3
|
-
export default async function accessGroup({
|
|
4
|
-
pg = pgClients.client, params = {}, user = {}, unittest,
|
|
5
|
-
}, reply) {
|
|
6
|
-
if (!params?.id) {
|
|
7
|
-
return reply.status(400).send('not enough params: id');
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
// restrict access - admin only
|
|
11
|
-
const check = await getAdminAccess({
|
|
12
|
-
id: params.id, user,
|
|
13
|
-
});
|
|
14
|
-
if (check?.message && check?.status && !unittest) {
|
|
15
|
-
return reply.status(check?.status).send(check?.message);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const { rows: routes = [] } = await pg.query(`select a.route_id as path, b.actions from admin.routes a
|
|
19
|
-
left join admin.role_access b on a.route_id=b.route_id
|
|
20
|
-
where b.role_id=$1`, [params.id]);
|
|
21
|
-
|
|
22
|
-
const { rows: users = [] } = await pg.query(`select user_uid as id, user_name as name, access_granted,
|
|
23
|
-
b.cdate as user_created, b.last_activity_date as last_activity from admin.user_roles a
|
|
24
|
-
left join admin.users b on a.user_uid=b.uid
|
|
25
|
-
where a.role_id=$1`, [params.id]);
|
|
26
|
-
|
|
27
|
-
return { routes, users };
|
|
28
|
-
}
|
|
1
|
+
import { pgClients, getAdminAccess } from '../../../../utils.js';
|
|
2
|
+
|
|
3
|
+
export default async function accessGroup({
|
|
4
|
+
pg = pgClients.client, params = {}, user = {}, unittest,
|
|
5
|
+
}, reply) {
|
|
6
|
+
if (!params?.id) {
|
|
7
|
+
return reply.status(400).send('not enough params: id');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// restrict access - admin only
|
|
11
|
+
const check = await getAdminAccess({
|
|
12
|
+
id: params.id, user,
|
|
13
|
+
});
|
|
14
|
+
if (check?.message && check?.status && !unittest) {
|
|
15
|
+
return reply.status(check?.status).send(check?.message);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const { rows: routes = [] } = await pg.query(`select a.route_id as path, b.actions from admin.routes a
|
|
19
|
+
left join admin.role_access b on a.route_id=b.route_id
|
|
20
|
+
where b.role_id=$1`, [params.id]);
|
|
21
|
+
|
|
22
|
+
const { rows: users = [] } = await pg.query(`select user_uid as id, user_name as name, access_granted,
|
|
23
|
+
b.cdate as user_created, b.last_activity_date as last_activity from admin.user_roles a
|
|
24
|
+
left join admin.users b on a.user_uid=b.uid
|
|
25
|
+
where a.role_id=$1`, [params.id]);
|
|
26
|
+
|
|
27
|
+
return { routes, users };
|
|
28
|
+
}
|
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
import { pgClients, getAdminAccess } from '../../../../utils.js';
|
|
2
|
-
import accessGroup from './access.group.js';
|
|
3
|
-
|
|
4
|
-
export default async function accessGroupPost({
|
|
5
|
-
pg = pgClients.client, params = {}, user = {}, body = {}, unittest,
|
|
6
|
-
}, reply) {
|
|
7
|
-
const { id } = params;
|
|
8
|
-
if (!user?.uid) {
|
|
9
|
-
return reply.status(401).send('unauthorized');
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
// restrict access - admin only
|
|
13
|
-
const check = await getAdminAccess({ id, user });
|
|
14
|
-
if (check?.message && check?.status && !unittest) {
|
|
15
|
-
return reply.status(check?.status).send(check?.message);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const { users = [], routes = [] } = body;
|
|
19
|
-
|
|
20
|
-
if (!routes?.length) {
|
|
21
|
-
// return { message: 'not enough params: users / routes', status: 400 };
|
|
22
|
-
await pg.query('delete from admin.role_access where role_id=$1', [id]);
|
|
23
|
-
|
|
24
|
-
if (!users?.length) {
|
|
25
|
-
return reply.status(200).send({ id, routes });
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (routes?.length) {
|
|
30
|
-
const { routesDB = [] } = await pg.query('select array_agg(route_id) as "routesDB" from admin.routes where enabled')
|
|
31
|
-
.then((res1) => res1.rows?.[0] || {});
|
|
32
|
-
await pg.query('delete from admin.role_access where role_id=$1;', [id]);
|
|
33
|
-
|
|
34
|
-
const q = 'insert into admin.role_access(role_id,route_id,actions) values ($1,$2,$3)';
|
|
35
|
-
await Promise.all(routes.filter(el => routesDB.includes(el.path) && el.actions).map(el => pg.query(q, [id, el.path, el.actions])));
|
|
36
|
-
|
|
37
|
-
const { rows } = await pg.query(`select a.route_id as path, b.actions as actions from admin.routes a
|
|
38
|
-
left join admin.role_access b on a.route_id=b.route_id
|
|
39
|
-
where b.role_id=$1`, [id]);
|
|
40
|
-
|
|
41
|
-
if (!users?.length) {
|
|
42
|
-
return reply.status(200).send({ id, routes: rows });
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const q = `delete from admin.user_roles where role_id='${id.replace(/'/g, "''")}';
|
|
47
|
-
insert into admin.user_roles(role_id,user_uid,access_granted)
|
|
48
|
-
values ${users.filter((el) => el?.id).map((el) => `('${id.replace(/'/g, "''")}','${el.id.replace(/'/g, "''")}','${user?.uid?.replace(/'/g, "''")}')`)}`;
|
|
49
|
-
|
|
50
|
-
await pg.query(q);
|
|
51
|
-
|
|
52
|
-
const res = await accessGroup({
|
|
53
|
-
pg, params, user, unittest,
|
|
54
|
-
}, reply);
|
|
55
|
-
|
|
56
|
-
return res;
|
|
57
|
-
}
|
|
1
|
+
import { pgClients, getAdminAccess } from '../../../../utils.js';
|
|
2
|
+
import accessGroup from './access.group.js';
|
|
3
|
+
|
|
4
|
+
export default async function accessGroupPost({
|
|
5
|
+
pg = pgClients.client, params = {}, user = {}, body = {}, unittest,
|
|
6
|
+
}, reply) {
|
|
7
|
+
const { id } = params;
|
|
8
|
+
if (!user?.uid) {
|
|
9
|
+
return reply.status(401).send('unauthorized');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// restrict access - admin only
|
|
13
|
+
const check = await getAdminAccess({ id, user });
|
|
14
|
+
if (check?.message && check?.status && !unittest) {
|
|
15
|
+
return reply.status(check?.status).send(check?.message);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const { users = [], routes = [] } = body;
|
|
19
|
+
|
|
20
|
+
if (!routes?.length) {
|
|
21
|
+
// return { message: 'not enough params: users / routes', status: 400 };
|
|
22
|
+
await pg.query('delete from admin.role_access where role_id=$1', [id]);
|
|
23
|
+
|
|
24
|
+
if (!users?.length) {
|
|
25
|
+
return reply.status(200).send({ id, routes });
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (routes?.length) {
|
|
30
|
+
const { routesDB = [] } = await pg.query('select array_agg(route_id) as "routesDB" from admin.routes where enabled')
|
|
31
|
+
.then((res1) => res1.rows?.[0] || {});
|
|
32
|
+
await pg.query('delete from admin.role_access where role_id=$1;', [id]);
|
|
33
|
+
|
|
34
|
+
const q = 'insert into admin.role_access(role_id,route_id,actions) values ($1,$2,$3)';
|
|
35
|
+
await Promise.all(routes.filter(el => routesDB.includes(el.path) && el.actions).map(el => pg.query(q, [id, el.path, el.actions])));
|
|
36
|
+
|
|
37
|
+
const { rows } = await pg.query(`select a.route_id as path, b.actions as actions from admin.routes a
|
|
38
|
+
left join admin.role_access b on a.route_id=b.route_id
|
|
39
|
+
where b.role_id=$1`, [id]);
|
|
40
|
+
|
|
41
|
+
if (!users?.length) {
|
|
42
|
+
return reply.status(200).send({ id, routes: rows });
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const q = `delete from admin.user_roles where role_id='${id.replace(/'/g, "''")}';
|
|
47
|
+
insert into admin.user_roles(role_id,user_uid,access_granted)
|
|
48
|
+
values ${users.filter((el) => el?.id).map((el) => `('${id.replace(/'/g, "''")}','${el.id.replace(/'/g, "''")}','${user?.uid?.replace(/'/g, "''")}')`)}`;
|
|
49
|
+
|
|
50
|
+
await pg.query(q);
|
|
51
|
+
|
|
52
|
+
const res = await accessGroup({
|
|
53
|
+
pg, params, user, unittest,
|
|
54
|
+
}, reply);
|
|
55
|
+
|
|
56
|
+
return res;
|
|
57
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import accessGroup from './controllers/access.group.js';
|
|
2
|
-
import accessGroupPost from './controllers/access.group.post.js';
|
|
3
|
-
import accessInterface from './controllers/access.interface.js';
|
|
4
|
-
|
|
5
|
-
import { accessGroupPostSchema, accessGroupSchema, accessInterfaceSchema } from './schema.mjs';
|
|
6
|
-
|
|
7
|
-
export default async function route(fastify, config) {
|
|
8
|
-
const { prefix = '/api' } = config;
|
|
9
|
-
fastify.get(`${prefix}/access-group/:id`, { schema: accessGroupSchema }, accessGroup);
|
|
10
|
-
fastify.post(`${prefix}/access-group/:id`, { schema: accessGroupPostSchema }, accessGroupPost);
|
|
11
|
-
fastify.get(`${prefix}/access-interface/:name`, { schema: accessInterfaceSchema }, accessInterface);
|
|
12
|
-
}
|
|
1
|
+
import accessGroup from './controllers/access.group.js';
|
|
2
|
+
import accessGroupPost from './controllers/access.group.post.js';
|
|
3
|
+
import accessInterface from './controllers/access.interface.js';
|
|
4
|
+
|
|
5
|
+
import { accessGroupPostSchema, accessGroupSchema, accessInterfaceSchema } from './schema.mjs';
|
|
6
|
+
|
|
7
|
+
export default async function route(fastify, config) {
|
|
8
|
+
const { prefix = '/api' } = config;
|
|
9
|
+
fastify.get(`${prefix}/access-group/:id`, { schema: accessGroupSchema }, accessGroup);
|
|
10
|
+
fastify.post(`${prefix}/access-group/:id`, { schema: accessGroupPostSchema }, accessGroupPost);
|
|
11
|
+
fastify.get(`${prefix}/access-interface/:name`, { schema: accessInterfaceSchema }, accessInterface);
|
|
12
|
+
}
|
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
export default null;
|
|
2
|
-
export { accessGroupSchema, accessGroupPostSchema, accessInterfaceSchema }
|
|
3
|
-
|
|
4
|
-
const accessGroupSchema = {
|
|
5
|
-
params: {
|
|
6
|
-
type: 'object',
|
|
7
|
-
properties: {
|
|
8
|
-
id: { type: 'string', pattern: '^([\\d\\w._-]+)$' },
|
|
9
|
-
},
|
|
10
|
-
required: ['id'],
|
|
11
|
-
},
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const accessInterfaceSchema = {
|
|
15
|
-
params: {
|
|
16
|
-
type: 'object',
|
|
17
|
-
properties: {
|
|
18
|
-
name: { type: 'string', pattern: '^([\\d\\w._-]+)$' },
|
|
19
|
-
},
|
|
20
|
-
required: ['name'],
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const accessGroupPostSchema = {
|
|
25
|
-
params: {
|
|
26
|
-
type: 'object',
|
|
27
|
-
properties: {
|
|
28
|
-
id: { type: 'string', pattern: '^([\\d\\w._-]+)$' },
|
|
29
|
-
},
|
|
30
|
-
required: ['id'],
|
|
31
|
-
},
|
|
32
|
-
body: {
|
|
33
|
-
type: 'object',
|
|
34
|
-
properties: {
|
|
35
|
-
users: {
|
|
36
|
-
type: 'array',
|
|
37
|
-
items: {
|
|
38
|
-
type: 'object',
|
|
39
|
-
properties: {
|
|
40
|
-
id: {
|
|
41
|
-
type: 'string',
|
|
42
|
-
pattern: '^([\\d\\w._-]+)$',
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
routes: {
|
|
48
|
-
type: 'array',
|
|
49
|
-
/*items: {
|
|
50
|
-
type: 'object',
|
|
51
|
-
properties: {
|
|
52
|
-
path: {
|
|
53
|
-
type: 'string',
|
|
54
|
-
pattern: '^([\\d\\w._-]+)$',
|
|
55
|
-
},
|
|
56
|
-
actions: {
|
|
57
|
-
type: 'array',
|
|
58
|
-
items: {
|
|
59
|
-
type: 'string',
|
|
60
|
-
enum: ['get', 'add', 'edit', 'del'],
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
},*/
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
},
|
|
1
|
+
export default null;
|
|
2
|
+
export { accessGroupSchema, accessGroupPostSchema, accessInterfaceSchema }
|
|
3
|
+
|
|
4
|
+
const accessGroupSchema = {
|
|
5
|
+
params: {
|
|
6
|
+
type: 'object',
|
|
7
|
+
properties: {
|
|
8
|
+
id: { type: 'string', pattern: '^([\\d\\w._-]+)$' },
|
|
9
|
+
},
|
|
10
|
+
required: ['id'],
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const accessInterfaceSchema = {
|
|
15
|
+
params: {
|
|
16
|
+
type: 'object',
|
|
17
|
+
properties: {
|
|
18
|
+
name: { type: 'string', pattern: '^([\\d\\w._-]+)$' },
|
|
19
|
+
},
|
|
20
|
+
required: ['name'],
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const accessGroupPostSchema = {
|
|
25
|
+
params: {
|
|
26
|
+
type: 'object',
|
|
27
|
+
properties: {
|
|
28
|
+
id: { type: 'string', pattern: '^([\\d\\w._-]+)$' },
|
|
29
|
+
},
|
|
30
|
+
required: ['id'],
|
|
31
|
+
},
|
|
32
|
+
body: {
|
|
33
|
+
type: 'object',
|
|
34
|
+
properties: {
|
|
35
|
+
users: {
|
|
36
|
+
type: 'array',
|
|
37
|
+
items: {
|
|
38
|
+
type: 'object',
|
|
39
|
+
properties: {
|
|
40
|
+
id: {
|
|
41
|
+
type: 'string',
|
|
42
|
+
pattern: '^([\\d\\w._-]+)$',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
routes: {
|
|
48
|
+
type: 'array',
|
|
49
|
+
/*items: {
|
|
50
|
+
type: 'object',
|
|
51
|
+
properties: {
|
|
52
|
+
path: {
|
|
53
|
+
type: 'string',
|
|
54
|
+
pattern: '^([\\d\\w._-]+)$',
|
|
55
|
+
},
|
|
56
|
+
actions: {
|
|
57
|
+
type: 'array',
|
|
58
|
+
items: {
|
|
59
|
+
type: 'string',
|
|
60
|
+
enum: ['get', 'add', 'edit', 'del'],
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},*/
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
68
|
};
|
|
@@ -21,7 +21,7 @@ export default async function tableAPI(req, reply, called) {
|
|
|
21
21
|
|
|
22
22
|
const loadTable = await getTemplate('table', templateName);
|
|
23
23
|
|
|
24
|
-
if (!loadTable && !pg.pk?.[tokenData.table]) {
|
|
24
|
+
if (!loadTable && !pg.pk?.[tokenData.table] && !(pg.pk?.[templateName] && called)) {
|
|
25
25
|
return reply.status(404).send('not found');
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
/* eslint-disable no-param-reassign */
|
|
1
2
|
import {
|
|
2
3
|
config, applyHook, getTemplate, pgClients, getAccess, setToken, getSelectMeta, getToken,
|
|
3
4
|
} from '../../../../utils.js';
|
|
4
5
|
|
|
5
6
|
import getEditData from '../../crud/controllers/table.js';
|
|
7
|
+
import formatSchema from './utils/formatSchema.js';
|
|
6
8
|
|
|
7
9
|
const q = `select
|
|
8
10
|
property_key as key,
|
|
@@ -33,7 +35,9 @@ export default async function getForm({
|
|
|
33
35
|
|
|
34
36
|
const table = tokenData?.table || hookData?.table || params.name;
|
|
35
37
|
|
|
36
|
-
const
|
|
38
|
+
const form = tokenData?.form
|
|
39
|
+
|| hookData?.form
|
|
40
|
+
|| await getTemplate('table', table).then(el => el.form) || {};
|
|
37
41
|
|
|
38
42
|
if (!form) {
|
|
39
43
|
return reply.status(404).send('form not found');
|
|
@@ -60,34 +64,36 @@ export default async function getForm({
|
|
|
60
64
|
const res = { mode: 'form', time: 0, schema };
|
|
61
65
|
|
|
62
66
|
if (user.uid) {
|
|
63
|
-
|
|
67
|
+
// form in form addToken
|
|
68
|
+
formatSchema(schema, user, loadTemplate?.obj);
|
|
69
|
+
|
|
70
|
+
const id = edit && tokenData?.id;
|
|
71
|
+
const isAllowedByTemplate = id ? actions.includes('edit') : actions.includes('add');
|
|
72
|
+
|
|
73
|
+
if (
|
|
74
|
+
!isAllowedByTemplate
|
|
75
|
+
&& !config.local
|
|
76
|
+
&& process.env.NODE_ENV !== 'test'
|
|
77
|
+
&& !(tokenData?.form || hookData?.form)
|
|
78
|
+
) {
|
|
64
79
|
return reply.status(403).send('access restricted: actions');
|
|
65
80
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
table,
|
|
70
|
-
form,
|
|
71
|
-
})],
|
|
81
|
+
|
|
82
|
+
const token = setToken({
|
|
83
|
+
ids: [JSON.stringify({ id, table, form })],
|
|
72
84
|
uid: user.uid,
|
|
73
85
|
array: 1,
|
|
74
|
-
});
|
|
75
|
-
Object.assign(res, { token: addTokens[0], mode: 'add' });
|
|
76
|
-
}
|
|
86
|
+
})?.[0];
|
|
77
87
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
88
|
+
if (!id) {
|
|
89
|
+
Object.assign(res, { token, mode: 'add' });
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
const data = await getEditData({
|
|
93
|
+
pg, params: { table, id }, user,
|
|
94
|
+
}, reply, true);
|
|
95
|
+
Object.assign(res, { token, data, mode: 'edit' });
|
|
81
96
|
}
|
|
82
|
-
const editTokens = setToken({
|
|
83
|
-
ids: [JSON.stringify({ id: edit || tokenData?.id, table, form })],
|
|
84
|
-
uid: user.uid,
|
|
85
|
-
array: 1,
|
|
86
|
-
});
|
|
87
|
-
const data = await getEditData({
|
|
88
|
-
pg, params: { table, id: edit || tokenData?.id }, user,
|
|
89
|
-
}, reply, true);
|
|
90
|
-
Object.assign(res, { token: editTokens[0], data, mode: 'edit' });
|
|
91
97
|
}
|
|
92
98
|
|
|
93
99
|
// replace settings
|
|
@@ -56,6 +56,7 @@ export default async function getTableData(req, reply, called) {
|
|
|
56
56
|
}, reply, called);
|
|
57
57
|
const route = pg.tlist?.includes('admin.routes') ? await pg.query('select route_id as path, title from admin.routes where enabled and alias=$1 limit 1', [params.table])
|
|
58
58
|
.then(el => el.rows?.[0] || {}) : {};
|
|
59
|
-
|
|
60
|
-
return res;
|
|
59
|
+
|
|
60
|
+
if (typeof res === 'string') return res;
|
|
61
|
+
return { route, ...res };
|
|
61
62
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/* eslint-disable no-param-reassign */
|
|
2
|
+
import config from '../../../../../config.js';
|
|
3
|
+
import setToken from '../../../../plugins/crud/funcs/setToken.js';
|
|
4
|
+
import { handlebarsSync } from '../../../../helpers/index.js';
|
|
5
|
+
|
|
6
|
+
export default function formatSchema(schema, user, opt) {
|
|
7
|
+
function parseDataTables(obj) {
|
|
8
|
+
if (obj?.add) {
|
|
9
|
+
const obj1 = obj.add?.obj?.includes('{{') && opt ? handlebarsSync.compile(obj.add.obj)(opt) : obj.add?.obj;
|
|
10
|
+
if (obj.add?.obj) obj.add.obj = obj1;
|
|
11
|
+
const [token] = setToken({
|
|
12
|
+
ids: [JSON.stringify({ ...obj.add, table: obj.add?.table || obj.add?.model })],
|
|
13
|
+
uid: user.uid,
|
|
14
|
+
array: 1,
|
|
15
|
+
});
|
|
16
|
+
Object.assign(obj.add, { token, api: `${config.prefix || '/api'}/table/${token}` });
|
|
17
|
+
}
|
|
18
|
+
else if (obj?.type === 'DataTable' && obj.colModel?.length) {
|
|
19
|
+
obj.colModel.forEach(parseDataTables);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
Object.keys(schema || {}).map(key => ({ key, ...schema[key] })).forEach(parseDataTables);
|
|
23
|
+
}
|
|
@@ -1,94 +1,94 @@
|
|
|
1
|
-
import getTemplate from '../../../plugins/table/funcs/getTemplate.js';
|
|
2
|
-
import pgClients from '../../../plugins/pg/pgClients.js';
|
|
3
|
-
import getToken from '../../../plugins/crud/funcs/getToken.js';
|
|
4
|
-
import { handlebarsSync } from '../../../../utils.js';
|
|
5
|
-
|
|
6
|
-
function dayOfTheYear(date) {
|
|
7
|
-
const start = new Date(date.getFullYear(), 0, 0);
|
|
8
|
-
const diff = (date - start) + ((start.getTimezoneOffset() - date.getTimezoneOffset()) * 60 * 1000);
|
|
9
|
-
const oneDay = 1000 * 60 * 60 * 24;
|
|
10
|
-
const day = Math.floor(diff / oneDay);
|
|
11
|
-
return day;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export default async function codeGenerator({
|
|
15
|
-
pg = pgClients.client, params = {}, user = {}, query = {},
|
|
16
|
-
}, reply) {
|
|
17
|
-
const { token, column } = params;
|
|
18
|
-
const data = query.data?.split?.(';') || [];
|
|
19
|
-
|
|
20
|
-
if (!token || !column) {
|
|
21
|
-
return reply.status(400).send('not enough params: token / column');
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (!user?.uid) {
|
|
25
|
-
return reply.status(401).send('unauthorized');
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const tokenData = await getToken({ token, uid: user?.uid, json: 1 }) || {};
|
|
29
|
-
|
|
30
|
-
if (!tokenData?.form || !tokenData?.table) {
|
|
31
|
-
return reply.status(401).send('token not allow');
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const loadTemplate = await getTemplate('form', tokenData.form);
|
|
35
|
-
const schema = loadTemplate?.schema || loadTemplate;
|
|
36
|
-
|
|
37
|
-
if (!schema) {
|
|
38
|
-
return reply.status(404).send('form not found');
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (!schema?.[column]?.template) {
|
|
42
|
-
return reply.status(400).send('template not specified');
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const columnValue = data.find(el => el.startsWith(column))?.split('=')?.pop();
|
|
46
|
-
|
|
47
|
-
const loadTable = await getTemplate('table', tokenData.table);
|
|
48
|
-
const table = loadTable?.table || tokenData.table;
|
|
49
|
-
|
|
50
|
-
if (!pg.pk?.[table]) {
|
|
51
|
-
return reply.status(404).send('table pk not found');
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const { count = 0 } = await pg.query(
|
|
55
|
-
`select count(*) from ${table} where ${columnValue ? `${column}::text = '${columnValue}'` : 'true'} limit 1`,
|
|
56
|
-
).then(el => el.rows?.[0] || {});
|
|
57
|
-
|
|
58
|
-
const { NUMY = 0 } = await pg.query(
|
|
59
|
-
`select ${column} as "NUMY" from ${table} where ${column} is not null and date_part('year', cdate) = $1 order by cdate desc limit 1`,
|
|
60
|
-
[(new Date()).getFullYear()],
|
|
61
|
-
).then(el => el.rows?.[0] || {});
|
|
62
|
-
|
|
63
|
-
const date = new Date();
|
|
64
|
-
|
|
65
|
-
const template = schema[column].template.match(/NUM[M|Y] \d/g)
|
|
66
|
-
.reduce(
|
|
67
|
-
(acc, curr) => acc.replace(
|
|
68
|
-
curr.startsWith('{{{') ? `{{{${curr}}}}` : `{{${curr}}}`,
|
|
69
|
-
handlebarsSync.compile('{{paddingNumber value padding}}')({ padding: curr.substring(4, curr.length)?.trim?.(), value: curr.startsWith('NUMY') ? NUMY : +count + 1 }),
|
|
70
|
-
),
|
|
71
|
-
schema[column].template,
|
|
72
|
-
);
|
|
73
|
-
const result = handlebarsSync.compile(template)({
|
|
74
|
-
HH: date.getHours(), // hours 24h: 14:00 = 14
|
|
75
|
-
HH12: (date.getHours() + 24) % 12 || 12, // hours 12h: 14:00 = 2
|
|
76
|
-
HH24: date.getHours(), // hours 24h: 14:00 = 14
|
|
77
|
-
MI: date.getMinutes(), // minutes
|
|
78
|
-
SS: date.getSeconds(), // seconds
|
|
79
|
-
|
|
80
|
-
YYYY: date.getFullYear(), // full year: 2025
|
|
81
|
-
YY: date.getFullYear().toString().substring(2, 4), // last 2 digits of year: 25
|
|
82
|
-
|
|
83
|
-
MONTH: date.toLocaleString('en', { month: 'long' }).toUpperCase(), // month name: MARCH
|
|
84
|
-
MON: date.toLocaleString('en', { month: 'long' }).substring(0, 3).toUpperCase(), // month name abbrev: MAR
|
|
85
|
-
MM: date.getMonth() + 1, // month number: 1 - january, 12 - december
|
|
86
|
-
|
|
87
|
-
D: date.getDay(), // day of the week: 1 - monday, 7 - sunday
|
|
88
|
-
DD: date.getDate(), // day of the month: january 4 = 4
|
|
89
|
-
DDD: dayOfTheYear(date), // day of the year: march 4 = 63
|
|
90
|
-
...data,
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
return reply.status(200).send(result);
|
|
94
|
-
}
|
|
1
|
+
import getTemplate from '../../../plugins/table/funcs/getTemplate.js';
|
|
2
|
+
import pgClients from '../../../plugins/pg/pgClients.js';
|
|
3
|
+
import getToken from '../../../plugins/crud/funcs/getToken.js';
|
|
4
|
+
import { handlebarsSync } from '../../../../utils.js';
|
|
5
|
+
|
|
6
|
+
function dayOfTheYear(date) {
|
|
7
|
+
const start = new Date(date.getFullYear(), 0, 0);
|
|
8
|
+
const diff = (date - start) + ((start.getTimezoneOffset() - date.getTimezoneOffset()) * 60 * 1000);
|
|
9
|
+
const oneDay = 1000 * 60 * 60 * 24;
|
|
10
|
+
const day = Math.floor(diff / oneDay);
|
|
11
|
+
return day;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default async function codeGenerator({
|
|
15
|
+
pg = pgClients.client, params = {}, user = {}, query = {},
|
|
16
|
+
}, reply) {
|
|
17
|
+
const { token, column } = params;
|
|
18
|
+
const data = query.data?.split?.(';') || [];
|
|
19
|
+
|
|
20
|
+
if (!token || !column) {
|
|
21
|
+
return reply.status(400).send('not enough params: token / column');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (!user?.uid) {
|
|
25
|
+
return reply.status(401).send('unauthorized');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const tokenData = await getToken({ token, uid: user?.uid, json: 1 }) || {};
|
|
29
|
+
|
|
30
|
+
if (!tokenData?.form || !tokenData?.table) {
|
|
31
|
+
return reply.status(401).send('token not allow');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const loadTemplate = await getTemplate('form', tokenData.form);
|
|
35
|
+
const schema = loadTemplate?.schema || loadTemplate;
|
|
36
|
+
|
|
37
|
+
if (!schema) {
|
|
38
|
+
return reply.status(404).send('form not found');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (!schema?.[column]?.template) {
|
|
42
|
+
return reply.status(400).send('template not specified');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const columnValue = data.find(el => el.startsWith(column))?.split('=')?.pop();
|
|
46
|
+
|
|
47
|
+
const loadTable = await getTemplate('table', tokenData.table);
|
|
48
|
+
const table = loadTable?.table || tokenData.table;
|
|
49
|
+
|
|
50
|
+
if (!pg.pk?.[table]) {
|
|
51
|
+
return reply.status(404).send('table pk not found');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const { count = 0 } = await pg.query(
|
|
55
|
+
`select count(*) from ${table} where ${columnValue ? `${column}::text = '${columnValue}'` : 'true'} limit 1`,
|
|
56
|
+
).then(el => el.rows?.[0] || {});
|
|
57
|
+
|
|
58
|
+
const { NUMY = 0 } = await pg.query(
|
|
59
|
+
`select ${column} as "NUMY" from ${table} where ${column} is not null and date_part('year', cdate) = $1 order by cdate desc limit 1`,
|
|
60
|
+
[(new Date()).getFullYear()],
|
|
61
|
+
).then(el => el.rows?.[0] || {});
|
|
62
|
+
|
|
63
|
+
const date = new Date();
|
|
64
|
+
|
|
65
|
+
const template = schema[column].template.match(/NUM[M|Y] \d/g)
|
|
66
|
+
.reduce(
|
|
67
|
+
(acc, curr) => acc.replace(
|
|
68
|
+
curr.startsWith('{{{') ? `{{{${curr}}}}` : `{{${curr}}}`,
|
|
69
|
+
handlebarsSync.compile('{{paddingNumber value padding}}')({ padding: curr.substring(4, curr.length)?.trim?.(), value: curr.startsWith('NUMY') ? NUMY : +count + 1 }),
|
|
70
|
+
),
|
|
71
|
+
schema[column].template,
|
|
72
|
+
);
|
|
73
|
+
const result = handlebarsSync.compile(template)({
|
|
74
|
+
HH: date.getHours(), // hours 24h: 14:00 = 14
|
|
75
|
+
HH12: (date.getHours() + 24) % 12 || 12, // hours 12h: 14:00 = 2
|
|
76
|
+
HH24: date.getHours(), // hours 24h: 14:00 = 14
|
|
77
|
+
MI: date.getMinutes(), // minutes
|
|
78
|
+
SS: date.getSeconds(), // seconds
|
|
79
|
+
|
|
80
|
+
YYYY: date.getFullYear(), // full year: 2025
|
|
81
|
+
YY: date.getFullYear().toString().substring(2, 4), // last 2 digits of year: 25
|
|
82
|
+
|
|
83
|
+
MONTH: date.toLocaleString('en', { month: 'long' }).toUpperCase(), // month name: MARCH
|
|
84
|
+
MON: date.toLocaleString('en', { month: 'long' }).substring(0, 3).toUpperCase(), // month name abbrev: MAR
|
|
85
|
+
MM: date.getMonth() + 1, // month number: 1 - january, 12 - december
|
|
86
|
+
|
|
87
|
+
D: date.getDay(), // day of the week: 1 - monday, 7 - sunday
|
|
88
|
+
DD: date.getDate(), // day of the month: january 4 = 4
|
|
89
|
+
DDD: dayOfTheYear(date), // day of the year: march 4 = 63
|
|
90
|
+
...data,
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
return reply.status(200).send(result);
|
|
94
|
+
}
|
package/utils.js
CHANGED
|
@@ -2,212 +2,111 @@
|
|
|
2
2
|
// between our tests.
|
|
3
3
|
|
|
4
4
|
// hb
|
|
5
|
-
|
|
5
|
+
export { handlebars, handlebarsSync } from './server/helpers/index.js';
|
|
6
6
|
|
|
7
7
|
// pg
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
export { default as getPG } from './server/plugins/pg/funcs/getPG.js';
|
|
9
|
+
export { default as getPGAsync } from './server/plugins/pg/funcs/getPGAsync.js';
|
|
10
|
+
export { default as getSqlite } from './server/plugins/sqlite/funcs/getSqlite.js';
|
|
11
|
+
export { default as initSqlite } from './server/plugins/sqlite/funcs/init.js';
|
|
12
|
+
export { default as sqliteClients } from './server/plugins/sqlite/sqliteClients.js';
|
|
13
|
+
export { default as getDBParams } from './server/plugins/pg/funcs/getDBParams.js';
|
|
14
|
+
export { default as initPG } from './server/plugins/pg/funcs/init.js';
|
|
15
|
+
export { default as pgClients } from './server/plugins/pg/pgClients.js';
|
|
16
|
+
export { default as getMeta } from './server/plugins/pg/funcs/getMeta.js';
|
|
17
|
+
export { default as getAccess } from './server/plugins/crud/funcs/getAccess.js';
|
|
18
18
|
|
|
19
19
|
// redis
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
export { default as getRedis } from './server/plugins/redis/funcs/getRedis.js';
|
|
21
|
+
export { default as redisClients } from './server/plugins/redis/funcs/redisClients.js';
|
|
22
22
|
|
|
23
23
|
// template
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
export { default as getTemplate } from './server/plugins/table/funcs/getTemplate.js';
|
|
25
|
+
export { default as getTemplateSync } from './server/plugins/table/funcs/getTemplateSync.js';
|
|
26
|
+
export { default as getTemplates } from './server/plugins/table/funcs/getTemplates.js';
|
|
27
|
+
export { default as getTemplatePath } from './server/plugins/table/funcs/getTemplatePath.js';
|
|
28
|
+
export { default as addTemplateDir } from './server/plugins/table/funcs/addTemplateDir.js';
|
|
29
|
+
export { default as addMenu } from './server/plugins/table/funcs/addMenu.js';
|
|
30
|
+
export { default as menuDirs } from './server/plugins/table/funcs/menuDirs.js';
|
|
31
|
+
export { default as userTemplateDir } from './server/plugins/table/funcs/userTemplateDir.js';
|
|
32
|
+
export { default as customTokens } from './server/plugins/table/funcs/customTokens.js';
|
|
33
|
+
export { default as userTokens } from './server/plugins/table/funcs/userTokens.js';
|
|
34
34
|
|
|
35
35
|
// table
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
36
|
+
export { default as metaFormat } from './server/plugins/table/funcs/metaFormat/index.js';
|
|
37
|
+
export { default as autoIndex } from './server/plugins/pg/funcs/autoIndex.js';
|
|
38
|
+
export { default as getSelectVal } from './server/plugins/table/funcs/metaFormat/getSelectVal.js';
|
|
39
|
+
export { default as getFilterSQL } from './server/plugins/table/funcs/getFilterSQL/index.js';
|
|
40
|
+
export { default as getSelect } from './server/plugins/table/funcs/getSelect.js';
|
|
41
|
+
export { default as getSelectMeta } from './server/plugins/table/funcs/getSelectMeta.js';
|
|
42
|
+
export { default as gisIRColumn } from './server/plugins/table/funcs/gisIRColumn.js';
|
|
43
|
+
export { default as getData } from './server/plugins/table/funcs/getData.js';
|
|
44
|
+
export { default as getMenu } from './server/routes/menu/controllers/getMenu.js';
|
|
45
|
+
export { default as getFilter } from './server/plugins/table/funcs/getFilter.js';
|
|
46
46
|
|
|
47
47
|
// crud
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
48
|
+
export { default as dataInsert } from './server/plugins/crud/funcs/dataInsert.js';
|
|
49
|
+
export { default as dataUpdate } from './server/plugins/crud/funcs/dataUpdate.js';
|
|
50
|
+
export { default as dataDelete } from './server/plugins/crud/funcs/dataDelete.js';
|
|
51
|
+
export { default as getInsertQuery } from './server/plugins/crud/funcs/utils/getInsertQuery.js';
|
|
52
|
+
export { default as getToken } from './server/plugins/crud/funcs/getToken.js';
|
|
53
|
+
export { default as setToken } from './server/plugins/crud/funcs/setToken.js';
|
|
54
|
+
export { default as getOpt } from './server/plugins/crud/funcs/getOpt.js';
|
|
55
|
+
export { default as setOpt } from './server/plugins/crud/funcs/setOpt.js';
|
|
56
|
+
export { default as validateData } from './server/plugins/crud/funcs/validateData.js';
|
|
57
57
|
|
|
58
58
|
// policy
|
|
59
|
-
|
|
59
|
+
export { default as checkXSS } from './server/plugins/policy/funcs/checkXSS.js';
|
|
60
60
|
|
|
61
61
|
// hook
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
export { default as applyHook } from './server/plugins/hook/funcs/applyHook.js';
|
|
63
|
+
export { default as applyHookSync } from './server/plugins/hook/funcs/applyHookSync.js';
|
|
64
|
+
export { default as addHook } from './server/plugins/hook/funcs/addHook.js';
|
|
65
|
+
export { default as execMigrations } from './server/plugins/migration/exec.migrations.js';
|
|
66
|
+
export { default as execSql } from './server/plugins/migration/exec.sql.js';
|
|
67
67
|
|
|
68
68
|
// cron
|
|
69
|
-
|
|
69
|
+
export { default as addCron } from './server/plugins/cron/funcs/addCron.js';
|
|
70
70
|
|
|
71
71
|
// logger
|
|
72
|
-
|
|
72
|
+
export { default as logger } from './server/plugins/logger/getLogger.js';
|
|
73
73
|
|
|
74
74
|
// utils
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
//
|
|
80
|
-
|
|
75
|
+
export { default as config } from './config.js';
|
|
76
|
+
export { default as dblist } from './dblist.js';
|
|
77
|
+
export { default as redactionList } from './redactionList.js';
|
|
78
|
+
export { default as eventStream } from './server/plugins/util/funcs/eventStream.js';
|
|
79
|
+
// export { default as isFileExists } from './server/plugins/crud/funcs/isFileExists.js';
|
|
80
|
+
export { default as getFolder } from './server/plugins/crud/funcs/utils/getFolder.js';
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
export { default as logChanges } from './server/plugins/crud/funcs/utils/logChanges.js';
|
|
83
83
|
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
export { default as yml2json } from './server/plugins/yml/funcs/yml2json.js';
|
|
85
|
+
export { default as json2yml } from './server/plugins/yml/funcs/json2yml.js';
|
|
86
86
|
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
export { default as formatMdoc } from './server/plugins/md/funcs/formatMdoc.js';
|
|
88
|
+
export { default as mdToHTML } from './server/plugins/md/funcs/mdToHTML.js';
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
export { default as flattenObject } from './server/plugins/util/funcs/flattenObject.js';
|
|
91
|
+
export { default as unflattenObject } from './server/plugins/util/funcs/unflattenObject.js';
|
|
92
92
|
|
|
93
93
|
// file
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
94
|
+
export { default as isFileExists } from './server/plugins/file/isFileExists.js';
|
|
95
|
+
export { default as downloadFile } from './server/plugins/file/downloadFile.js';
|
|
96
|
+
export { default as uploadFile } from './server/plugins/file/uploadFile.js';
|
|
97
|
+
export { default as uploadMultiPart } from './server/plugins/file/uploadMultiPart.js';
|
|
98
|
+
export { default as getMimeType } from './server/plugins/file/providers/mime/index.js';
|
|
99
|
+
export { default as getFileType } from './server/plugins/file/utils/getFileType.js';
|
|
100
|
+
export { default as allowedExtensions } from './server/plugins/file/utils/allowedExtensions.js';
|
|
101
101
|
|
|
102
102
|
// grpc
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
103
|
+
export { default as grpc } from './server/plugins/grpc/grpc.js';
|
|
104
|
+
export { default as file2json } from './server/plugins/grpc/file2json.js';
|
|
105
|
+
export { default as officeConverter } from './server/plugins/grpc/office2pdf.js';
|
|
106
|
+
export { default as getExport } from './server/plugins/file/getExport.js';
|
|
107
|
+
export { default as jsonToCsv } from './server/routes/file/controllers/utils/jsonToCsv.js';
|
|
108
|
+
export { default as jsonToXls } from './server/routes/file/controllers/utils/jsonToXls.js';
|
|
109
109
|
|
|
110
110
|
export { default as getAdminAccess } from './server/plugins/access/funcs/getAdminAccess.js';
|
|
111
111
|
|
|
112
112
|
export default null;
|
|
113
|
-
export {
|
|
114
|
-
config,
|
|
115
|
-
dblist,
|
|
116
|
-
redactionList,
|
|
117
|
-
getFolder,
|
|
118
|
-
handlebars,
|
|
119
|
-
handlebarsSync,
|
|
120
|
-
getFilterSQL,
|
|
121
|
-
addCron,
|
|
122
|
-
execMigrations,
|
|
123
|
-
execSql,
|
|
124
|
-
getRedis,
|
|
125
|
-
redisClients,
|
|
126
|
-
logger,
|
|
127
|
-
// isFileExists,
|
|
128
|
-
eventStream,
|
|
129
|
-
|
|
130
|
-
// hook
|
|
131
|
-
addHook,
|
|
132
|
-
applyHook,
|
|
133
|
-
applyHookSync,
|
|
134
|
-
|
|
135
|
-
// template
|
|
136
|
-
getTemplate,
|
|
137
|
-
getTemplateSync,
|
|
138
|
-
getTemplates,
|
|
139
|
-
getTemplatePath,
|
|
140
|
-
addTemplateDir,
|
|
141
|
-
menuDirs,
|
|
142
|
-
addMenu,
|
|
143
|
-
userTemplateDir,
|
|
144
|
-
customTokens,
|
|
145
|
-
userTokens,
|
|
146
|
-
|
|
147
|
-
// security
|
|
148
|
-
checkXSS,
|
|
149
|
-
getAccess,
|
|
150
|
-
getToken,
|
|
151
|
-
getOpt,
|
|
152
|
-
setOpt,
|
|
153
|
-
setToken,
|
|
154
|
-
validateData,
|
|
155
|
-
|
|
156
|
-
// crud
|
|
157
|
-
dataInsert,
|
|
158
|
-
dataUpdate,
|
|
159
|
-
dataDelete,
|
|
160
|
-
getInsertQuery,
|
|
161
|
-
|
|
162
|
-
// table
|
|
163
|
-
autoIndex,
|
|
164
|
-
metaFormat,
|
|
165
|
-
getMeta,
|
|
166
|
-
gisIRColumn,
|
|
167
|
-
getData,
|
|
168
|
-
getFilter,
|
|
169
|
-
getMenu,
|
|
170
|
-
|
|
171
|
-
// pg
|
|
172
|
-
initPG,
|
|
173
|
-
getPG,
|
|
174
|
-
getPGAsync,
|
|
175
|
-
pgClients,
|
|
176
|
-
getDBParams,
|
|
177
|
-
|
|
178
|
-
// sqlite
|
|
179
|
-
getSqlite,
|
|
180
|
-
initSqlite,
|
|
181
|
-
sqliteClients,
|
|
182
|
-
|
|
183
|
-
// select
|
|
184
|
-
getSelectVal,
|
|
185
|
-
getSelectMeta,
|
|
186
|
-
getSelect,
|
|
187
|
-
|
|
188
|
-
logChanges,
|
|
189
|
-
|
|
190
|
-
yml2json,
|
|
191
|
-
json2yml,
|
|
192
|
-
|
|
193
|
-
formatMdoc,
|
|
194
|
-
mdToHTML,
|
|
195
|
-
|
|
196
|
-
flattenObject,
|
|
197
|
-
unflattenObject,
|
|
198
|
-
|
|
199
|
-
// file
|
|
200
|
-
isFileExists,
|
|
201
|
-
downloadFile,
|
|
202
|
-
uploadFile,
|
|
203
|
-
uploadMultiPart,
|
|
204
|
-
file2json,
|
|
205
|
-
grpc,
|
|
206
|
-
getMimeType,
|
|
207
|
-
getFileType,
|
|
208
|
-
getExport,
|
|
209
|
-
officeConverter,
|
|
210
|
-
allowedExtensions,
|
|
211
|
-
jsonToCsv,
|
|
212
|
-
jsonToXls,
|
|
213
|
-
};
|