@opengis/fastify-table 1.1.39 → 1.1.40
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/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/form.js +28 -28
- package/table/controllers/table.js +7 -6
- package/test/api/crud.xss.test.js +72 -72
- 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/util/controllers/next.id.js +4 -4
- package/util/controllers/properties.get.js +19 -19
- package/util/index.js +23 -23
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import getTemplate from './utils/getTemplate.js';
|
|
2
|
-
import getMeta from '../../pg/funcs/getMeta.js';
|
|
3
|
-
import metaFormat from '../funcs/metaFormat/index.js';
|
|
4
|
-
|
|
5
|
-
export default async function card(req) {
|
|
6
|
-
const time = Date.now();
|
|
7
|
-
const {
|
|
8
|
-
pg, params = {}, query = {}, opt = {},
|
|
9
|
-
} = req;
|
|
10
|
-
|
|
11
|
-
const loadTable = await getTemplate('table', params.table);
|
|
12
|
-
|
|
13
|
-
if (!loadTable) { return { message: 'template not found', status: 404 }; }
|
|
14
|
-
|
|
15
|
-
const {
|
|
16
|
-
table, columns, meta, sql, cardSql,
|
|
17
|
-
} = loadTable;
|
|
18
|
-
|
|
19
|
-
const { pk, columns: dbColumns = [] } = await getMeta(table);
|
|
20
|
-
|
|
21
|
-
if (!pk) return { message: `table not found: ${table}`, status: 404 };
|
|
22
|
-
|
|
23
|
-
const cols = columns.map((el) => el.name || el).join(',');
|
|
24
|
-
const columnList = dbColumns.map((el) => el.name || el).join(',');
|
|
25
|
-
const sqlTable = sql?.filter?.((el) => !el?.disabled && el?.sql?.replace).map((el, i) => ` left join lateral (${el.sql}) ${el.name || `t${i}`} on 1=1 `)?.join('') || '';
|
|
26
|
-
const cardSqlFiltered = opt.id || params.id ? cardSql?.filter?.((el) => !el?.disabled && el?.name && el?.sql?.replace) : [];
|
|
27
|
-
const cardSqlTable = cardSqlFiltered?.length ? cardSqlFiltered.map((el, i) => ` left join lateral (select json_agg(row_to_json(q)) as ${el.name} from (${el.sql})q) ct${i} on 1=1 `).join('') || '' : '';
|
|
28
|
-
|
|
29
|
-
const where = [`"${pk}" = $1`, loadTable.query].filter((el) => el);
|
|
30
|
-
const cardColumns = cardSqlFiltered?.length ? `,${cardSqlFiltered.map((el) => el.name)}` : '';
|
|
31
|
-
const q = `select ${pk ? `"${pk}" as id,` : ''} ${columnList.includes('geom') ? 'st_asgeojson(geom)::json as geom,' : ''} ${cols || '*'} ${cardColumns} from ${table} t ${sqlTable} ${cardSqlTable}
|
|
32
|
-
where ${where.join(' and ') || 'true'} limit 1`;
|
|
33
|
-
|
|
34
|
-
if (query.sql === '1') { return q; }
|
|
35
|
-
|
|
36
|
-
const { rows } = await pg.query(q, [opt.id || params.id]);
|
|
37
|
-
|
|
38
|
-
await metaFormat({ rows, table: params.table });
|
|
39
|
-
|
|
40
|
-
const data = meta.card?.length ? meta.card.reduce((acc, curr) => Object.assign(acc, { [columns.find((col) => col.name === curr)?.ua || '']: rows[0][curr] }), {}) : {};
|
|
41
|
-
return {
|
|
42
|
-
time: Date.now() - time, data,
|
|
43
|
-
};
|
|
44
|
-
}
|
|
1
|
+
import getTemplate from './utils/getTemplate.js';
|
|
2
|
+
import getMeta from '../../pg/funcs/getMeta.js';
|
|
3
|
+
import metaFormat from '../funcs/metaFormat/index.js';
|
|
4
|
+
|
|
5
|
+
export default async function card(req) {
|
|
6
|
+
const time = Date.now();
|
|
7
|
+
const {
|
|
8
|
+
pg, params = {}, query = {}, opt = {},
|
|
9
|
+
} = req;
|
|
10
|
+
|
|
11
|
+
const loadTable = await getTemplate('table', params.table);
|
|
12
|
+
|
|
13
|
+
if (!loadTable) { return { message: 'template not found', status: 404 }; }
|
|
14
|
+
|
|
15
|
+
const {
|
|
16
|
+
table, columns, meta, sql, cardSql,
|
|
17
|
+
} = loadTable;
|
|
18
|
+
|
|
19
|
+
const { pk, columns: dbColumns = [] } = await getMeta(table);
|
|
20
|
+
|
|
21
|
+
if (!pk) return { message: `table not found: ${table}`, status: 404 };
|
|
22
|
+
|
|
23
|
+
const cols = columns.map((el) => el.name || el).join(',');
|
|
24
|
+
const columnList = dbColumns.map((el) => el.name || el).join(',');
|
|
25
|
+
const sqlTable = sql?.filter?.((el) => !el?.disabled && el?.sql?.replace).map((el, i) => ` left join lateral (${el.sql}) ${el.name || `t${i}`} on 1=1 `)?.join('') || '';
|
|
26
|
+
const cardSqlFiltered = opt.id || params.id ? cardSql?.filter?.((el) => !el?.disabled && el?.name && el?.sql?.replace) : [];
|
|
27
|
+
const cardSqlTable = cardSqlFiltered?.length ? cardSqlFiltered.map((el, i) => ` left join lateral (select json_agg(row_to_json(q)) as ${el.name} from (${el.sql})q) ct${i} on 1=1 `).join('') || '' : '';
|
|
28
|
+
|
|
29
|
+
const where = [`"${pk}" = $1`, loadTable.query].filter((el) => el);
|
|
30
|
+
const cardColumns = cardSqlFiltered?.length ? `,${cardSqlFiltered.map((el) => el.name)}` : '';
|
|
31
|
+
const q = `select ${pk ? `"${pk}" as id,` : ''} ${columnList.includes('geom') ? 'st_asgeojson(geom)::json as geom,' : ''} ${cols || '*'} ${cardColumns} from ${table} t ${sqlTable} ${cardSqlTable}
|
|
32
|
+
where ${where.join(' and ') || 'true'} limit 1`;
|
|
33
|
+
|
|
34
|
+
if (query.sql === '1') { return q; }
|
|
35
|
+
|
|
36
|
+
const { rows } = await pg.query(q, [opt.id || params.id]);
|
|
37
|
+
|
|
38
|
+
await metaFormat({ rows, table: params.table });
|
|
39
|
+
|
|
40
|
+
const data = meta.card?.length ? meta.card.reduce((acc, curr) => Object.assign(acc, { [columns.find((col) => col.name === curr)?.ua || '']: rows[0][curr] }), {}) : {};
|
|
41
|
+
return {
|
|
42
|
+
time: Date.now() - time, data,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import getTemplate from './utils/getTemplate.js';
|
|
2
|
-
|
|
3
|
-
const sql = `select property_key as key, property_json as json, property_int as int,
|
|
4
|
-
property_text as text from admin.properties where 1=1`;
|
|
5
|
-
|
|
6
|
-
async function getSettings({ pg }) {
|
|
7
|
-
const { rows = [] } = await pg.query(sql);
|
|
8
|
-
const data = rows.reduce((acc, curr) => Object.assign(acc, { [curr.key]: curr.json || curr.int || curr.text }), {});
|
|
9
|
-
return data;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export default async function formFunction(req) {
|
|
13
|
-
const time = Date.now();
|
|
14
|
-
const { pg, params } = req;
|
|
15
|
-
const form = await getTemplate('form', params.form);
|
|
16
|
-
if (!form) { return { status: 404, message: 'not found' }; }
|
|
17
|
-
|
|
18
|
-
// replace settings
|
|
19
|
-
const arr = JSON.stringify(form).match(/{{settings.([^}]*)}}/g);
|
|
20
|
-
if (arr?.length) {
|
|
21
|
-
const string = JSON.stringify(form);
|
|
22
|
-
const settings = await getSettings({ pg });
|
|
23
|
-
const match = arr.reduce((acc, curr) => Object.assign(acc, { [curr]: settings[curr.replace(/^{{settings./g, '').replace(/}}$/, '')] }), {});
|
|
24
|
-
const res = Object.keys(match).reduce((s, m) => s.replace(m, match[m]), string);
|
|
25
|
-
return { time: Date.now() - time, form: JSON.parse(res) };
|
|
26
|
-
}
|
|
27
|
-
return { time: Date.now() - time, form };
|
|
28
|
-
}
|
|
1
|
+
import getTemplate from './utils/getTemplate.js';
|
|
2
|
+
|
|
3
|
+
const sql = `select property_key as key, property_json as json, property_int as int,
|
|
4
|
+
property_text as text from admin.properties where 1=1`;
|
|
5
|
+
|
|
6
|
+
async function getSettings({ pg }) {
|
|
7
|
+
const { rows = [] } = await pg.query(sql);
|
|
8
|
+
const data = rows.reduce((acc, curr) => Object.assign(acc, { [curr.key]: curr.json || curr.int || curr.text }), {});
|
|
9
|
+
return data;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default async function formFunction(req) {
|
|
13
|
+
const time = Date.now();
|
|
14
|
+
const { pg, params } = req;
|
|
15
|
+
const form = await getTemplate('form', params.form);
|
|
16
|
+
if (!form) { return { status: 404, message: 'not found' }; }
|
|
17
|
+
|
|
18
|
+
// replace settings
|
|
19
|
+
const arr = JSON.stringify(form).match(/{{settings.([^}]*)}}/g);
|
|
20
|
+
if (arr?.length) {
|
|
21
|
+
const string = JSON.stringify(form);
|
|
22
|
+
const settings = await getSettings({ pg });
|
|
23
|
+
const match = arr.reduce((acc, curr) => Object.assign(acc, { [curr]: settings[curr.replace(/^{{settings./g, '').replace(/}}$/, '')] }), {});
|
|
24
|
+
const res = Object.keys(match).reduce((s, m) => s.replace(m, match[m]), string);
|
|
25
|
+
return { time: Date.now() - time, form: JSON.parse(res) };
|
|
26
|
+
}
|
|
27
|
+
return { time: Date.now() - time, form };
|
|
28
|
+
}
|
|
@@ -5,19 +5,20 @@ import { applyHook } from '../../utils.js';
|
|
|
5
5
|
|
|
6
6
|
export default async function tableAPI(req) {
|
|
7
7
|
const {
|
|
8
|
-
pg, params = {}, query = {},
|
|
8
|
+
pg, params = {}, query = {},
|
|
9
9
|
} = req;
|
|
10
10
|
if (!params.id) return { message: 'not enough params', status: 400 };
|
|
11
11
|
|
|
12
|
-
const loadTable = await getTemplate('table', opt?.table || params.table) || {};
|
|
13
|
-
if (!loadTable) {
|
|
14
|
-
if (!pg.pk?.[opt?.table || params.table]) { return { message: 'not found', status: 404 }; }
|
|
15
|
-
}
|
|
16
|
-
|
|
17
12
|
const check = await applyHook('preTable', { req });
|
|
18
13
|
if (check?.message && check?.status) {
|
|
19
14
|
return { message: check?.message, status: check?.status };
|
|
20
15
|
}
|
|
16
|
+
const { opt = {} } = req;
|
|
17
|
+
|
|
18
|
+
const loadTable = await getTemplate('table', opt?.table || params.table) || {};
|
|
19
|
+
if (!loadTable) {
|
|
20
|
+
if (!pg.pk?.[opt?.table || params.table]) { return { message: 'not found', status: 404 }; }
|
|
21
|
+
}
|
|
21
22
|
|
|
22
23
|
const {
|
|
23
24
|
table, /* columns, */ form,
|
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
import { test } from 'node:test';
|
|
2
|
-
import assert from 'node:assert';
|
|
3
|
-
|
|
4
|
-
import build from '../../helper.js';
|
|
5
|
-
|
|
6
|
-
import setToken from '../../crud/funcs/setToken.js';
|
|
7
|
-
import config from '../config.js';
|
|
8
|
-
|
|
9
|
-
test('api crud xss', async (t) => {
|
|
10
|
-
const app = await build(t);
|
|
11
|
-
const session = { passport: { user: { uid: '1' } } };
|
|
12
|
-
app.addHook('onRequest', async (req) => {
|
|
13
|
-
req.session = session;
|
|
14
|
-
});
|
|
15
|
-
// app.decorateRequest('session', session);
|
|
16
|
-
|
|
17
|
-
const prefix = config.prefix || '/api';
|
|
18
|
-
|
|
19
|
-
let addTokens;
|
|
20
|
-
let editTokens;
|
|
21
|
-
|
|
22
|
-
// before
|
|
23
|
-
t.test('setToken', async () => {
|
|
24
|
-
addTokens = setToken({
|
|
25
|
-
ids: [JSON.stringify({ add: 'gis.dataset', form: 'test.dataset.form' })],
|
|
26
|
-
mode: 'a',
|
|
27
|
-
uid: 1,
|
|
28
|
-
array: 1,
|
|
29
|
-
});
|
|
30
|
-
editTokens = setToken({
|
|
31
|
-
ids: [JSON.stringify({ id: '5400000', table: 'gis.dataset', form: 'test.dataset.form' })],
|
|
32
|
-
mode: 'w',
|
|
33
|
-
uid: 1,
|
|
34
|
-
array: 1,
|
|
35
|
-
});
|
|
36
|
-
assert.ok(addTokens.length === 1 && editTokens.length === 1, 'invalid token');
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
await t.test('POST /insert', async () => {
|
|
40
|
-
const res = await app.inject({
|
|
41
|
-
method: 'POST',
|
|
42
|
-
url: `${prefix}/table/${addTokens[0]}`,
|
|
43
|
-
body: { dataset_name: '<a onClick="alert("XSS Injection")">xss injection</a>', dataset_id: '5400000' },
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
const rep = JSON.parse(res?.body);
|
|
47
|
-
console.log(rep)
|
|
48
|
-
assert.ok(rep.status, 409);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
await t.test('PUT /update', async () => {
|
|
52
|
-
const res = await app.inject({
|
|
53
|
-
method: 'PUT',
|
|
54
|
-
url: `${prefix}/table/${editTokens[0]}/${editTokens[0]}`,
|
|
55
|
-
body: { editor_id: '11', dataset_name: '<a onClick="alert("XSS Injection")">xss injection</a>' },
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
const rep = JSON.parse(res?.body);
|
|
59
|
-
console.log(rep)
|
|
60
|
-
assert.equal(rep.status, 409);
|
|
61
|
-
});
|
|
62
|
-
await t.test('DELETE /delete', async () => {
|
|
63
|
-
const res = await app.inject({
|
|
64
|
-
method: 'DELETE',
|
|
65
|
-
url: `${prefix}/table/gis.dataset/5400000`,
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
const rep = JSON.parse(res?.body);
|
|
69
|
-
console.log(rep)
|
|
70
|
-
assert.ok(rep);
|
|
71
|
-
});
|
|
72
|
-
});
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert';
|
|
3
|
+
|
|
4
|
+
import build from '../../helper.js';
|
|
5
|
+
|
|
6
|
+
import setToken from '../../crud/funcs/setToken.js';
|
|
7
|
+
import config from '../config.js';
|
|
8
|
+
|
|
9
|
+
test('api crud xss', async (t) => {
|
|
10
|
+
const app = await build(t);
|
|
11
|
+
const session = { passport: { user: { uid: '1' } } };
|
|
12
|
+
app.addHook('onRequest', async (req) => {
|
|
13
|
+
req.session = session;
|
|
14
|
+
});
|
|
15
|
+
// app.decorateRequest('session', session);
|
|
16
|
+
|
|
17
|
+
const prefix = config.prefix || '/api';
|
|
18
|
+
|
|
19
|
+
let addTokens;
|
|
20
|
+
let editTokens;
|
|
21
|
+
|
|
22
|
+
// before
|
|
23
|
+
t.test('setToken', async () => {
|
|
24
|
+
addTokens = setToken({
|
|
25
|
+
ids: [JSON.stringify({ add: 'gis.dataset', form: 'test.dataset.form' })],
|
|
26
|
+
mode: 'a',
|
|
27
|
+
uid: 1,
|
|
28
|
+
array: 1,
|
|
29
|
+
});
|
|
30
|
+
editTokens = setToken({
|
|
31
|
+
ids: [JSON.stringify({ id: '5400000', table: 'gis.dataset', form: 'test.dataset.form' })],
|
|
32
|
+
mode: 'w',
|
|
33
|
+
uid: 1,
|
|
34
|
+
array: 1,
|
|
35
|
+
});
|
|
36
|
+
assert.ok(addTokens.length === 1 && editTokens.length === 1, 'invalid token');
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
await t.test('POST /insert', async () => {
|
|
40
|
+
const res = await app.inject({
|
|
41
|
+
method: 'POST',
|
|
42
|
+
url: `${prefix}/table/${addTokens[0]}`,
|
|
43
|
+
body: { dataset_name: '<a onClick="alert("XSS Injection")">xss injection</a>', dataset_id: '5400000' },
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const rep = JSON.parse(res?.body);
|
|
47
|
+
console.log(rep)
|
|
48
|
+
assert.ok(rep.status, 409);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
await t.test('PUT /update', async () => {
|
|
52
|
+
const res = await app.inject({
|
|
53
|
+
method: 'PUT',
|
|
54
|
+
url: `${prefix}/table/${editTokens[0]}/${editTokens[0]}`,
|
|
55
|
+
body: { editor_id: '11', dataset_name: '<a onClick="alert("XSS Injection")">xss injection</a>' },
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const rep = JSON.parse(res?.body);
|
|
59
|
+
console.log(rep)
|
|
60
|
+
assert.equal(rep.status, 409);
|
|
61
|
+
});
|
|
62
|
+
await t.test('DELETE /delete', async () => {
|
|
63
|
+
const res = await app.inject({
|
|
64
|
+
method: 'DELETE',
|
|
65
|
+
url: `${prefix}/table/gis.dataset/5400000`,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const rep = JSON.parse(res?.body);
|
|
69
|
+
console.log(rep)
|
|
70
|
+
assert.ok(rep);
|
|
71
|
+
});
|
|
72
|
+
});
|
package/test/config.example
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import config from '../config.js';
|
|
2
|
-
|
|
3
|
-
Object.assign(config, {
|
|
4
|
-
folder: 'test/templates',
|
|
5
|
-
pg: {
|
|
6
|
-
host: '192.168.3.160',
|
|
7
|
-
port: 5434,
|
|
8
|
-
database: 'mbk_rivne_dma',
|
|
9
|
-
user: 'postgres',
|
|
10
|
-
password: 'postgres',
|
|
11
|
-
},
|
|
12
|
-
redis: {
|
|
13
|
-
host: '192.168.3.160',
|
|
14
|
-
port: 6379,
|
|
15
|
-
family: 4,
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
export default config;
|
|
1
|
+
import config from '../config.js';
|
|
2
|
+
|
|
3
|
+
Object.assign(config, {
|
|
4
|
+
folder: 'test/templates',
|
|
5
|
+
pg: {
|
|
6
|
+
host: '192.168.3.160',
|
|
7
|
+
port: 5434,
|
|
8
|
+
database: 'mbk_rivne_dma',
|
|
9
|
+
user: 'postgres',
|
|
10
|
+
password: 'postgres',
|
|
11
|
+
},
|
|
12
|
+
redis: {
|
|
13
|
+
host: '192.168.3.160',
|
|
14
|
+
port: 6379,
|
|
15
|
+
family: 4,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
export default config;
|
package/test/funcs/pg.test.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { test } from 'node:test';
|
|
2
|
-
import assert from 'node:assert';
|
|
3
|
-
|
|
4
|
-
import '../config.js';
|
|
5
|
-
|
|
6
|
-
import getMeta from '../../pg/funcs/getMeta.js';
|
|
7
|
-
import autoIndex from '../../pg/funcs/autoIndex.js';
|
|
8
|
-
import pgClients from '../../pg/pgClients.js';
|
|
9
|
-
import rclient from '../../redis/client.js';
|
|
10
|
-
// import pgClients from '../../pg/funcs/pgClients.js';
|
|
11
|
-
|
|
12
|
-
test('funcs pg', async (t) => {
|
|
13
|
-
await pgClients.client.init();
|
|
14
|
-
await t.test('getMeta', async () => {
|
|
15
|
-
const { columns } = await getMeta({ table: 'gis.dataset' });
|
|
16
|
-
// console.log(columns)
|
|
17
|
-
assert.ok(columns);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
/* await t.test('getPG', async (t) => {
|
|
21
|
-
const data = await getPG({});
|
|
22
|
-
assert.ok(data);
|
|
23
|
-
}); */
|
|
24
|
-
|
|
25
|
-
await t.test('autoIndex', async () => {
|
|
26
|
-
await autoIndex({ table: 'gis.dataset', columns: ['service_type'] });
|
|
27
|
-
assert.ok(1);
|
|
28
|
-
});
|
|
29
|
-
t.after(() => {
|
|
30
|
-
pgClients.client.end();
|
|
31
|
-
|
|
32
|
-
rclient.quit();
|
|
33
|
-
});
|
|
34
|
-
});
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert';
|
|
3
|
+
|
|
4
|
+
import '../config.js';
|
|
5
|
+
|
|
6
|
+
import getMeta from '../../pg/funcs/getMeta.js';
|
|
7
|
+
import autoIndex from '../../pg/funcs/autoIndex.js';
|
|
8
|
+
import pgClients from '../../pg/pgClients.js';
|
|
9
|
+
import rclient from '../../redis/client.js';
|
|
10
|
+
// import pgClients from '../../pg/funcs/pgClients.js';
|
|
11
|
+
|
|
12
|
+
test('funcs pg', async (t) => {
|
|
13
|
+
await pgClients.client.init();
|
|
14
|
+
await t.test('getMeta', async () => {
|
|
15
|
+
const { columns } = await getMeta({ table: 'gis.dataset' });
|
|
16
|
+
// console.log(columns)
|
|
17
|
+
assert.ok(columns);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
/* await t.test('getPG', async (t) => {
|
|
21
|
+
const data = await getPG({});
|
|
22
|
+
assert.ok(data);
|
|
23
|
+
}); */
|
|
24
|
+
|
|
25
|
+
await t.test('autoIndex', async () => {
|
|
26
|
+
await autoIndex({ table: 'gis.dataset', columns: ['service_type'] });
|
|
27
|
+
assert.ok(1);
|
|
28
|
+
});
|
|
29
|
+
t.after(() => {
|
|
30
|
+
pgClients.client.end();
|
|
31
|
+
|
|
32
|
+
rclient.quit();
|
|
33
|
+
});
|
|
34
|
+
});
|
package/test/funcs/redis.test.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { test } from 'node:test';
|
|
2
|
-
import assert from 'node:assert';
|
|
3
|
-
|
|
4
|
-
import '../config.js';
|
|
5
|
-
|
|
6
|
-
import rclient from '../../redis/client.js';
|
|
7
|
-
|
|
8
|
-
test('funcs redis', async (t) => {
|
|
9
|
-
await t.test('get/set', async () => {
|
|
10
|
-
await rclient.set('test', '1');
|
|
11
|
-
const d = await rclient.get('test');
|
|
12
|
-
// console.log(columns)
|
|
13
|
-
assert.equal(d, '1');
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
t.after(() => {
|
|
17
|
-
rclient.quit();
|
|
18
|
-
});
|
|
19
|
-
});
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert';
|
|
3
|
+
|
|
4
|
+
import '../config.js';
|
|
5
|
+
|
|
6
|
+
import rclient from '../../redis/client.js';
|
|
7
|
+
|
|
8
|
+
test('funcs redis', async (t) => {
|
|
9
|
+
await t.test('get/set', async () => {
|
|
10
|
+
await rclient.set('test', '1');
|
|
11
|
+
const d = await rclient.get('test');
|
|
12
|
+
// console.log(columns)
|
|
13
|
+
assert.equal(d, '1');
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
t.after(() => {
|
|
17
|
+
rclient.quit();
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"id": 1,
|
|
4
|
-
"text": "test"
|
|
5
|
-
},
|
|
6
|
-
{
|
|
7
|
-
"id": 2,
|
|
8
|
-
"text": "test2"
|
|
9
|
-
}
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": 1,
|
|
4
|
+
"text": "test"
|
|
5
|
+
},
|
|
6
|
+
{
|
|
7
|
+
"id": 2,
|
|
8
|
+
"text": "test2"
|
|
9
|
+
}
|
|
10
10
|
]
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
{
|
|
2
|
-
"schema": {
|
|
3
|
-
|
|
4
|
-
"cp_umuni_id": {
|
|
5
|
-
"type": "Text",
|
|
6
|
-
"ua": "ID UMUNI"
|
|
7
|
-
},
|
|
8
|
-
"cp_year": {
|
|
9
|
-
"type": "Text",
|
|
10
|
-
"ua": "Рік будівництва"
|
|
11
|
-
},
|
|
12
|
-
"cp_date_en_audit": {
|
|
13
|
-
"type": "DatePicker",
|
|
14
|
-
"ua": "Дата проведення останнього енергоаудиту"
|
|
15
|
-
},
|
|
16
|
-
"cp_certificate": {
|
|
17
|
-
"type": "Text",
|
|
18
|
-
"ua": "Сертифікат енергоефективності будівлі",
|
|
19
|
-
"help": "Вкажіть посилання"
|
|
20
|
-
},
|
|
21
|
-
"cp_pkd": {
|
|
22
|
-
"type": "Autocomplete",
|
|
23
|
-
"data": "customer_name",
|
|
24
|
-
"add": {
|
|
25
|
-
"model": "crm_acc.crm_account",
|
|
26
|
-
"ua": "Додати",
|
|
27
|
-
"form": "account_light.form"
|
|
28
|
-
},
|
|
29
|
-
"ua": "Замовник ПКД"
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
"label_style": "vertical"
|
|
1
|
+
{
|
|
2
|
+
"schema": {
|
|
3
|
+
|
|
4
|
+
"cp_umuni_id": {
|
|
5
|
+
"type": "Text",
|
|
6
|
+
"ua": "ID UMUNI"
|
|
7
|
+
},
|
|
8
|
+
"cp_year": {
|
|
9
|
+
"type": "Text",
|
|
10
|
+
"ua": "Рік будівництва"
|
|
11
|
+
},
|
|
12
|
+
"cp_date_en_audit": {
|
|
13
|
+
"type": "DatePicker",
|
|
14
|
+
"ua": "Дата проведення останнього енергоаудиту"
|
|
15
|
+
},
|
|
16
|
+
"cp_certificate": {
|
|
17
|
+
"type": "Text",
|
|
18
|
+
"ua": "Сертифікат енергоефективності будівлі",
|
|
19
|
+
"help": "Вкажіть посилання"
|
|
20
|
+
},
|
|
21
|
+
"cp_pkd": {
|
|
22
|
+
"type": "Autocomplete",
|
|
23
|
+
"data": "customer_name",
|
|
24
|
+
"add": {
|
|
25
|
+
"model": "crm_acc.crm_account",
|
|
26
|
+
"ua": "Додати",
|
|
27
|
+
"form": "account_light.form"
|
|
28
|
+
},
|
|
29
|
+
"ua": "Замовник ПКД"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"label_style": "vertical"
|
|
33
33
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
{
|
|
2
|
-
"db": "mbk_lviv_dma",
|
|
3
|
-
"searchColumn": "alternative_name"
|
|
1
|
+
{
|
|
2
|
+
"db": "mbk_lviv_dma",
|
|
3
|
+
"searchColumn": "alternative_name"
|
|
4
4
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
{
|
|
2
|
-
"key": "dataset_id"
|
|
1
|
+
{
|
|
2
|
+
"key": "dataset_id"
|
|
3
3
|
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
{
|
|
2
|
-
"columns": [
|
|
3
|
-
{
|
|
4
|
-
"name": "dataset_id",
|
|
5
|
-
"title": "22"
|
|
6
|
-
},
|
|
7
|
-
{
|
|
8
|
-
"name": "dataset_name",
|
|
9
|
-
"title": "dataset_name"
|
|
10
|
-
}
|
|
11
|
-
],
|
|
12
|
-
"table": "gis.dataset",
|
|
13
|
-
"order": "dataset_name",
|
|
14
|
-
"filters": [
|
|
15
|
-
{
|
|
16
|
-
"ua": "Назва набору",
|
|
17
|
-
"name": "dataset_name",
|
|
18
|
-
"type": "text"
|
|
19
|
-
}
|
|
20
|
-
]
|
|
1
|
+
{
|
|
2
|
+
"columns": [
|
|
3
|
+
{
|
|
4
|
+
"name": "dataset_id",
|
|
5
|
+
"title": "22"
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
"name": "dataset_name",
|
|
9
|
+
"title": "dataset_name"
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
"table": "gis.dataset",
|
|
13
|
+
"order": "dataset_name",
|
|
14
|
+
"filters": [
|
|
15
|
+
{
|
|
16
|
+
"ua": "Назва набору",
|
|
17
|
+
"name": "dataset_name",
|
|
18
|
+
"type": "text"
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
21
|
}
|
|
@@ -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
|
+
};
|