@opengis/fastify-table 1.0.70 → 1.0.72
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/.eslintrc.cjs +42 -42
- package/Changelog.md +229 -225
- package/README.md +26 -26
- 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/isFileExists.js +13 -13
- package/crud/funcs/setToken.js +53 -53
- package/index.js +97 -89
- package/migration/exec.migrations.js +75 -75
- package/notification/controllers/testEmail.js +49 -49
- package/notification/funcs/utils/sendEmail.js +39 -39
- package/notification/index.js +31 -31
- package/package.json +27 -25
- package/pg/funcs/getPG.js +29 -29
- package/redis/funcs/getRedis.js +23 -23
- package/server/migrations/crm.sql +150 -150
- package/server/migrations/log.sql +43 -43
- package/server.js +14 -14
- package/table/controllers/filter.js +37 -37
- package/table/controllers/form.js +19 -1
- package/table/controllers/search.js +72 -72
- package/table/controllers/suggest.js +1 -1
- package/table/controllers/utils/getTemplate.js +28 -28
- package/table/controllers/utils/getTemplates.js +18 -18
- package/table/funcs/getFilterSQL/util/getTableSql.js +34 -34
- package/test/api/notification.test.js +37 -37
- package/test/api/table.test.js +57 -57
- package/test/api/widget.test.js +114 -114
- package/test/config.example +18 -18
- package/test/funcs/crud.test.js +76 -76
- package/test/funcs/notification.test.js +31 -31
- 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/index.js +13 -13
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
import getTemplate from './utils/getTemplate.js';
|
|
2
|
-
import getMeta from '../../pg/funcs/getMeta.js';
|
|
3
|
-
import metaFormat from '../funcs/metaFormat/index.js';
|
|
4
|
-
import getTemplates from './utils/getTemplates.js';
|
|
5
|
-
|
|
6
|
-
function sequence(tables, data, fn) {
|
|
7
|
-
return tables.reduce((promise, table) => promise.then(() => fn({
|
|
8
|
-
...data, tableName: table.replace('.json', ''),
|
|
9
|
-
})), Promise.resolve());
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
async function getData({
|
|
13
|
-
pg, funcs, tableName, query = {}, maxLimit, res,
|
|
14
|
-
}) {
|
|
15
|
-
const loadTable = await getTemplate('table', tableName);
|
|
16
|
-
|
|
17
|
-
if (!loadTable) { return { message: 'not found', status: 404 }; }
|
|
18
|
-
|
|
19
|
-
const { table, columns, meta, ua } = loadTable;
|
|
20
|
-
|
|
21
|
-
const { pk } = await getMeta(table);
|
|
22
|
-
|
|
23
|
-
const cols = columns.map((el) => el.name || el).join(',');
|
|
24
|
-
const [orderColumn, orderDir] = (query.order || loadTable.order || '').split('-');
|
|
25
|
-
const order = cols.includes(orderColumn) && orderColumn?.length ? `order by ${orderColumn} ${query.desc || orderDir === 'desc' ? 'desc' : ''}` : '';
|
|
26
|
-
|
|
27
|
-
const limit = Math.max(maxLimit - res.rows.length, 0);
|
|
28
|
-
// Math.max(query.offset - res.rows.length,0)
|
|
29
|
-
const offset = query.page && query.page > 0 ? ` offset ${(query.page - 1) * limit}` : '';
|
|
30
|
-
|
|
31
|
-
const search = meta?.search && query.key ? `(${meta?.search.concat(meta?.title ? `,${meta?.title}` : '').split(',').map(el => `${el} ilike '%${query.key}%'`).join(' or ')})` : 'false';
|
|
32
|
-
|
|
33
|
-
const where = [!pk ? 'false' : 'true', loadTable.query, search].filter((el) => el);
|
|
34
|
-
const q = `select ${[`"${pk}" as id`, meta?.title ? `${meta.title} as title` : ''].filter((el) => el).join(',')} from ${table} t where ${where.join(' and ') || 'true'} ${order} ${offset} limit ${limit}`;
|
|
35
|
-
if (query.sql) {
|
|
36
|
-
res.sql.push(q);
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const { rows } = await pg.query(q);
|
|
41
|
-
|
|
42
|
-
const total = await pg.queryCache(`select count(*) from ${table} t where ${where.join(' and ') || 'true'}`).then((el) => el?.rows[0]?.count) || 0;
|
|
43
|
-
|
|
44
|
-
await metaFormat({ rows, table: tableName });
|
|
45
|
-
res.total += +total;
|
|
46
|
-
rows.forEach((row) => {
|
|
47
|
-
const href = meta?.href ? funcs.handlebars.compile(meta.href)({ ...row, [pk]: row.id }) : undefined;
|
|
48
|
-
res.rows.push({ ...row, register: tableName, register_title: loadTable.ua, href });
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export default async function search({
|
|
53
|
-
pg, funcs, query = {},
|
|
54
|
-
}) {
|
|
55
|
-
const time = Date.now();
|
|
56
|
-
|
|
57
|
-
try {
|
|
58
|
-
const tables = query.table ? [query.table] : await getTemplates('table');
|
|
59
|
-
const res = { rows: [], sql: [], total: 0 };
|
|
60
|
-
|
|
61
|
-
const maxLimit = Math.min(100, query.limit || '16');
|
|
62
|
-
await sequence(tables, { pg, funcs, query, maxLimit, res }, getData);
|
|
63
|
-
|
|
64
|
-
if (query.sql) return res.sql.join(';\n');
|
|
65
|
-
|
|
66
|
-
return {
|
|
67
|
-
time: Date.now() - time, total: res.total, count: res.rows.length, rows: res.rows,
|
|
68
|
-
};
|
|
69
|
-
} catch (err) {
|
|
70
|
-
return { error: err.toString(), status: 500 };
|
|
71
|
-
}
|
|
72
|
-
}
|
|
1
|
+
import getTemplate from './utils/getTemplate.js';
|
|
2
|
+
import getMeta from '../../pg/funcs/getMeta.js';
|
|
3
|
+
import metaFormat from '../funcs/metaFormat/index.js';
|
|
4
|
+
import getTemplates from './utils/getTemplates.js';
|
|
5
|
+
|
|
6
|
+
function sequence(tables, data, fn) {
|
|
7
|
+
return tables.reduce((promise, table) => promise.then(() => fn({
|
|
8
|
+
...data, tableName: table.replace('.json', ''),
|
|
9
|
+
})), Promise.resolve());
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async function getData({
|
|
13
|
+
pg, funcs, tableName, query = {}, maxLimit, res,
|
|
14
|
+
}) {
|
|
15
|
+
const loadTable = await getTemplate('table', tableName);
|
|
16
|
+
|
|
17
|
+
if (!loadTable) { return { message: 'not found', status: 404 }; }
|
|
18
|
+
|
|
19
|
+
const { table, columns, meta, ua } = loadTable;
|
|
20
|
+
|
|
21
|
+
const { pk } = await getMeta(table);
|
|
22
|
+
|
|
23
|
+
const cols = columns.map((el) => el.name || el).join(',');
|
|
24
|
+
const [orderColumn, orderDir] = (query.order || loadTable.order || '').split('-');
|
|
25
|
+
const order = cols.includes(orderColumn) && orderColumn?.length ? `order by ${orderColumn} ${query.desc || orderDir === 'desc' ? 'desc' : ''}` : '';
|
|
26
|
+
|
|
27
|
+
const limit = Math.max(maxLimit - res.rows.length, 0);
|
|
28
|
+
// Math.max(query.offset - res.rows.length,0)
|
|
29
|
+
const offset = query.page && query.page > 0 ? ` offset ${(query.page - 1) * limit}` : '';
|
|
30
|
+
|
|
31
|
+
const search = meta?.search && query.key ? `(${meta?.search.concat(meta?.title ? `,${meta?.title}` : '').split(',').map(el => `${el} ilike '%${query.key}%'`).join(' or ')})` : 'false';
|
|
32
|
+
|
|
33
|
+
const where = [!pk ? 'false' : 'true', loadTable.query, search].filter((el) => el);
|
|
34
|
+
const q = `select ${[`"${pk}" as id`, meta?.title ? `${meta.title} as title` : ''].filter((el) => el).join(',')} from ${table} t where ${where.join(' and ') || 'true'} ${order} ${offset} limit ${limit}`;
|
|
35
|
+
if (query.sql) {
|
|
36
|
+
res.sql.push(q);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const { rows } = await pg.query(q);
|
|
41
|
+
|
|
42
|
+
const total = await pg.queryCache(`select count(*) from ${table} t where ${where.join(' and ') || 'true'}`).then((el) => el?.rows[0]?.count) || 0;
|
|
43
|
+
|
|
44
|
+
await metaFormat({ rows, table: tableName });
|
|
45
|
+
res.total += +total;
|
|
46
|
+
rows.forEach((row) => {
|
|
47
|
+
const href = meta?.href ? funcs.handlebars.compile(meta.href)({ ...row, [pk]: row.id }) : undefined;
|
|
48
|
+
res.rows.push({ ...row, register: tableName, register_title: loadTable.ua, href });
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export default async function search({
|
|
53
|
+
pg, funcs, query = {},
|
|
54
|
+
}) {
|
|
55
|
+
const time = Date.now();
|
|
56
|
+
|
|
57
|
+
try {
|
|
58
|
+
const tables = query.table ? [query.table] : await getTemplates('table');
|
|
59
|
+
const res = { rows: [], sql: [], total: 0 };
|
|
60
|
+
|
|
61
|
+
const maxLimit = Math.min(100, query.limit || '16');
|
|
62
|
+
await sequence(tables, { pg, funcs, query, maxLimit, res }, getData);
|
|
63
|
+
|
|
64
|
+
if (query.sql) return res.sql.join(';\n');
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
time: Date.now() - time, total: res.total, count: res.rows.length, rows: res.rows,
|
|
68
|
+
};
|
|
69
|
+
} catch (err) {
|
|
70
|
+
return { error: err.toString(), status: 500 };
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -15,7 +15,7 @@ export default async function suggest(req) {
|
|
|
15
15
|
if (!selectName) return { headers, status: 400, message: 'name is required' };
|
|
16
16
|
|
|
17
17
|
const meta = await getSelectMeta({ name: selectName });
|
|
18
|
-
const pg = meta
|
|
18
|
+
const pg = meta?.db ? getPG(meta.db) : pg1;
|
|
19
19
|
if (!meta) return { headers, status: 404, message: 'Not found query select ' };
|
|
20
20
|
|
|
21
21
|
const { arr, searchQuery } = meta;
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { readFile } from 'fs/promises';
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import config from '../../../config.js';
|
|
5
|
-
|
|
6
|
-
const loadTemplate = {};
|
|
7
|
-
|
|
8
|
-
export default async function getTemplateDir(type, name) {
|
|
9
|
-
if (!type) return null;
|
|
10
|
-
if (!name) return null;
|
|
11
|
-
|
|
12
|
-
const cwd = process.cwd();
|
|
13
|
-
const typeDir = path.join(cwd, (config.templateDir || 'server/templates'), type);
|
|
14
|
-
|
|
15
|
-
if (!loadTemplate[type]) {
|
|
16
|
-
const typeList = fs.existsSync(typeDir) ? fs.readdirSync(typeDir) : [];
|
|
17
|
-
loadTemplate[type] = typeList;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const fullname = loadTemplate[type].find((el) => path.parse(el).name === name);
|
|
21
|
-
const ext = fullname ? path.extname(fullname)?.slice(1) : null;
|
|
22
|
-
if (!ext) return null;
|
|
23
|
-
|
|
24
|
-
const sql = loadTemplate[type].includes(`${name}.sql`) ? await readFile(path.join(typeDir, `${name}.sql`), 'utf-8') : null;
|
|
25
|
-
const data = loadTemplate[type].includes(`${name}.json`) ? JSON.parse(await readFile(path.join(typeDir, `${name}.json`), 'utf-8')) : await readFile(path.join(typeDir, `${name}.${ext}`), 'utf-8');
|
|
26
|
-
if (sql) return { ...data || {}, sql };
|
|
27
|
-
return data;
|
|
28
|
-
}
|
|
1
|
+
import { readFile } from 'fs/promises';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import config from '../../../config.js';
|
|
5
|
+
|
|
6
|
+
const loadTemplate = {};
|
|
7
|
+
|
|
8
|
+
export default async function getTemplateDir(type, name) {
|
|
9
|
+
if (!type) return null;
|
|
10
|
+
if (!name) return null;
|
|
11
|
+
|
|
12
|
+
const cwd = process.cwd();
|
|
13
|
+
const typeDir = path.join(cwd, (config.templateDir || 'server/templates'), type);
|
|
14
|
+
|
|
15
|
+
if (!loadTemplate[type]) {
|
|
16
|
+
const typeList = fs.existsSync(typeDir) ? fs.readdirSync(typeDir) : [];
|
|
17
|
+
loadTemplate[type] = typeList;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const fullname = loadTemplate[type].find((el) => path.parse(el).name === name);
|
|
21
|
+
const ext = fullname ? path.extname(fullname)?.slice(1) : null;
|
|
22
|
+
if (!ext) return null;
|
|
23
|
+
|
|
24
|
+
const sql = loadTemplate[type].includes(`${name}.sql`) ? await readFile(path.join(typeDir, `${name}.sql`), 'utf-8') : null;
|
|
25
|
+
const data = loadTemplate[type].includes(`${name}.json`) ? JSON.parse(await readFile(path.join(typeDir, `${name}.json`), 'utf-8')) : await readFile(path.join(typeDir, `${name}.${ext}`), 'utf-8');
|
|
26
|
+
if (sql) return { ...data || {}, sql };
|
|
27
|
+
return data;
|
|
28
|
+
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import config from '../../../config.js';
|
|
4
|
-
|
|
5
|
-
const loadTemplate = {};
|
|
6
|
-
|
|
7
|
-
export default async function getTemplateDir(type) {
|
|
8
|
-
if (!type) return null;
|
|
9
|
-
|
|
10
|
-
const cwd = process.cwd();
|
|
11
|
-
const typeDir = path.join(cwd, (config.templateDir || 'server/templates'), type);
|
|
12
|
-
|
|
13
|
-
if (!loadTemplate[type]) {
|
|
14
|
-
const typeList = fs.existsSync(typeDir) ? fs.readdirSync(typeDir) : [];
|
|
15
|
-
loadTemplate[type] = typeList;
|
|
16
|
-
}
|
|
17
|
-
return loadTemplate[type];
|
|
18
|
-
}
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import config from '../../../config.js';
|
|
4
|
+
|
|
5
|
+
const loadTemplate = {};
|
|
6
|
+
|
|
7
|
+
export default async function getTemplateDir(type) {
|
|
8
|
+
if (!type) return null;
|
|
9
|
+
|
|
10
|
+
const cwd = process.cwd();
|
|
11
|
+
const typeDir = path.join(cwd, (config.templateDir || 'server/templates'), type);
|
|
12
|
+
|
|
13
|
+
if (!loadTemplate[type]) {
|
|
14
|
+
const typeList = fs.existsSync(typeDir) ? fs.readdirSync(typeDir) : [];
|
|
15
|
+
loadTemplate[type] = typeList;
|
|
16
|
+
}
|
|
17
|
+
return loadTemplate[type];
|
|
18
|
+
}
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
function getTable(table) {
|
|
2
|
-
const result = table?.toLowerCase()?.replace(/[\n\r]+/g, ' ')?.split(' from ')?.filter((el) => /^[a-z0-9_]+\.[a-z0-9_]+/.test(el))
|
|
3
|
-
?.map((el) => el.split(/[ )]/)[0]);
|
|
4
|
-
return result;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @param {Number} opt.json - (1|0) 1 - Результат - Object, 0 - String
|
|
9
|
-
* @param {String} opt.query - запит до таблиці
|
|
10
|
-
* @param {String} opt.hash - інформація з хешу по запиту
|
|
11
|
-
*/
|
|
12
|
-
const tableSql = {};
|
|
13
|
-
async function getTableSql({
|
|
14
|
-
pg, body, table, fields,
|
|
15
|
-
}) {
|
|
16
|
-
if (tableSql[table]) return tableSql[table];
|
|
17
|
-
|
|
18
|
-
const fieldList = fields.map((el) => el.name);
|
|
19
|
-
|
|
20
|
-
const tableList = body?.sql?.map((el) => getTable(el.sql)).reduce((acc, el) => acc.concat(el), []).filter((el) => fieldList.includes(pg.pk[el]));
|
|
21
|
-
|
|
22
|
-
if (!tableList) { tableSql[table] = []; return []; }
|
|
23
|
-
|
|
24
|
-
const data = await Promise.all(tableList?.map(async (tableEl) => {
|
|
25
|
-
const { fields: fieldsEl } = await pg.query(`select * from ${tableEl} limit 0`);
|
|
26
|
-
return fieldsEl.map((el) => ({ name: el.name, table: tableEl, pk: pg.pk[tableEl] }));
|
|
27
|
-
}));
|
|
28
|
-
|
|
29
|
-
tableSql[table] = data.reduce((acc, el) => acc.concat(el), []);
|
|
30
|
-
|
|
31
|
-
return tableSql[table];
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export default getTableSql;
|
|
1
|
+
function getTable(table) {
|
|
2
|
+
const result = table?.toLowerCase()?.replace(/[\n\r]+/g, ' ')?.split(' from ')?.filter((el) => /^[a-z0-9_]+\.[a-z0-9_]+/.test(el))
|
|
3
|
+
?.map((el) => el.split(/[ )]/)[0]);
|
|
4
|
+
return result;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @param {Number} opt.json - (1|0) 1 - Результат - Object, 0 - String
|
|
9
|
+
* @param {String} opt.query - запит до таблиці
|
|
10
|
+
* @param {String} opt.hash - інформація з хешу по запиту
|
|
11
|
+
*/
|
|
12
|
+
const tableSql = {};
|
|
13
|
+
async function getTableSql({
|
|
14
|
+
pg, body, table, fields,
|
|
15
|
+
}) {
|
|
16
|
+
if (tableSql[table]) return tableSql[table];
|
|
17
|
+
|
|
18
|
+
const fieldList = fields.map((el) => el.name);
|
|
19
|
+
|
|
20
|
+
const tableList = body?.sql?.map((el) => getTable(el.sql)).reduce((acc, el) => acc.concat(el), []).filter((el) => fieldList.includes(pg.pk[el]));
|
|
21
|
+
|
|
22
|
+
if (!tableList) { tableSql[table] = []; return []; }
|
|
23
|
+
|
|
24
|
+
const data = await Promise.all(tableList?.map(async (tableEl) => {
|
|
25
|
+
const { fields: fieldsEl } = await pg.query(`select * from ${tableEl} limit 0`);
|
|
26
|
+
return fieldsEl.map((el) => ({ name: el.name, table: tableEl, pk: pg.pk[tableEl] }));
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
tableSql[table] = data.reduce((acc, el) => acc.concat(el), []);
|
|
30
|
+
|
|
31
|
+
return tableSql[table];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export default getTableSql;
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import { test } from 'node:test';
|
|
2
|
-
import assert from 'node:assert';
|
|
3
|
-
|
|
4
|
-
import build from '../../helper.js';
|
|
5
|
-
import config from '../config.js';
|
|
6
|
-
|
|
7
|
-
const session = { passport: { user: { uid: config.testUser?.uid || '1' } } };
|
|
8
|
-
|
|
9
|
-
import userNotifications from '../../notification/controllers/userNotifications.js';
|
|
10
|
-
|
|
11
|
-
import pgClients from '../../pg/pgClients.js';
|
|
12
|
-
|
|
13
|
-
test('api && funcs notification', async (t) => {
|
|
14
|
-
const app = await build(t);
|
|
15
|
-
const pg = pgClients.client;
|
|
16
|
-
/*
|
|
17
|
-
// require dependency
|
|
18
|
-
await t.test('GET /auth', async () => {
|
|
19
|
-
const res = await app.inject({
|
|
20
|
-
method: 'GET',
|
|
21
|
-
url: `/api/login?username=${config.testUser?.username}&password=${config.testUser?.password}`,
|
|
22
|
-
});
|
|
23
|
-
assert.ok(res.statusCode);
|
|
24
|
-
});
|
|
25
|
-
await t.test('GET /notification', async () => {
|
|
26
|
-
const res = await app.inject({
|
|
27
|
-
method: 'GET',
|
|
28
|
-
url: '/api/notification',
|
|
29
|
-
});
|
|
30
|
-
const rep = JSON.parse(res?.body);
|
|
31
|
-
assert.ok(rep.time);
|
|
32
|
-
}); */
|
|
33
|
-
/* await t.test('GET /notification', async () => {
|
|
34
|
-
const rep = await userNotifications({ pg, session });
|
|
35
|
-
assert.ok(rep.time);
|
|
36
|
-
}); */
|
|
37
|
-
});
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert';
|
|
3
|
+
|
|
4
|
+
import build from '../../helper.js';
|
|
5
|
+
import config from '../config.js';
|
|
6
|
+
|
|
7
|
+
const session = { passport: { user: { uid: config.testUser?.uid || '1' } } };
|
|
8
|
+
|
|
9
|
+
import userNotifications from '../../notification/controllers/userNotifications.js';
|
|
10
|
+
|
|
11
|
+
import pgClients from '../../pg/pgClients.js';
|
|
12
|
+
|
|
13
|
+
test('api && funcs notification', async (t) => {
|
|
14
|
+
const app = await build(t);
|
|
15
|
+
const pg = pgClients.client;
|
|
16
|
+
/*
|
|
17
|
+
// require dependency
|
|
18
|
+
await t.test('GET /auth', async () => {
|
|
19
|
+
const res = await app.inject({
|
|
20
|
+
method: 'GET',
|
|
21
|
+
url: `/api/login?username=${config.testUser?.username}&password=${config.testUser?.password}`,
|
|
22
|
+
});
|
|
23
|
+
assert.ok(res.statusCode);
|
|
24
|
+
});
|
|
25
|
+
await t.test('GET /notification', async () => {
|
|
26
|
+
const res = await app.inject({
|
|
27
|
+
method: 'GET',
|
|
28
|
+
url: '/api/notification',
|
|
29
|
+
});
|
|
30
|
+
const rep = JSON.parse(res?.body);
|
|
31
|
+
assert.ok(rep.time);
|
|
32
|
+
}); */
|
|
33
|
+
/* await t.test('GET /notification', async () => {
|
|
34
|
+
const rep = await userNotifications({ pg, session });
|
|
35
|
+
assert.ok(rep.time);
|
|
36
|
+
}); */
|
|
37
|
+
});
|
package/test/api/table.test.js
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
import { test } from 'node:test';
|
|
2
|
-
import assert from 'node:assert';
|
|
3
|
-
|
|
4
|
-
import build from '../../helper.js';
|
|
5
|
-
|
|
6
|
-
test('api table', async (t) => {
|
|
7
|
-
const app = await build(t);
|
|
8
|
-
// assert.ok(1);
|
|
9
|
-
/* await t.test('GET /suggest', async () => {
|
|
10
|
-
const res = await app.inject({
|
|
11
|
-
method: 'GET',
|
|
12
|
-
url: '/api/suggest/test.storage.data',
|
|
13
|
-
});
|
|
14
|
-
// console.log(res?.body);
|
|
15
|
-
const rep = JSON.parse(res?.body);
|
|
16
|
-
// console.log(rep.total);
|
|
17
|
-
assert.ok(rep.total);
|
|
18
|
-
}); */
|
|
19
|
-
/* await t.test('GET /data', async () => {
|
|
20
|
-
const res = await app.inject({
|
|
21
|
-
method: 'GET',
|
|
22
|
-
url: '/api/data/test.dataset.table',
|
|
23
|
-
});
|
|
24
|
-
// console.log(res);
|
|
25
|
-
const rep = JSON.parse(res?.body);
|
|
26
|
-
// console.log(rep.total);
|
|
27
|
-
assert.ok(rep.total);
|
|
28
|
-
}); */
|
|
29
|
-
/* await t.test('GET /search', async () => {
|
|
30
|
-
const res = await app.inject({
|
|
31
|
-
method: 'GET',
|
|
32
|
-
url: '/api/search?table=test.dataset.table&key=0',
|
|
33
|
-
});
|
|
34
|
-
const rep = JSON.parse(res?.body);
|
|
35
|
-
assert.ok(rep.total);
|
|
36
|
-
}); */
|
|
37
|
-
await t.test('GET /form', async () => {
|
|
38
|
-
const res = await app.inject({
|
|
39
|
-
method: 'GET',
|
|
40
|
-
url: '/api/form/test.dataset.form',
|
|
41
|
-
});
|
|
42
|
-
// console.log(res);
|
|
43
|
-
const rep = JSON.parse(res?.body);
|
|
44
|
-
// console.log(rep.total);
|
|
45
|
-
assert.ok(rep);
|
|
46
|
-
});
|
|
47
|
-
await t.test('GET /filter', async () => {
|
|
48
|
-
const res = await app.inject({
|
|
49
|
-
method: 'GET',
|
|
50
|
-
url: '/api/filter/test.dataset.table',
|
|
51
|
-
});
|
|
52
|
-
// console.log(res);
|
|
53
|
-
const rep = JSON.parse(res?.body);
|
|
54
|
-
// console.log(rep.total);
|
|
55
|
-
assert.ok(rep);
|
|
56
|
-
});
|
|
57
|
-
});
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert';
|
|
3
|
+
|
|
4
|
+
import build from '../../helper.js';
|
|
5
|
+
|
|
6
|
+
test('api table', async (t) => {
|
|
7
|
+
const app = await build(t);
|
|
8
|
+
// assert.ok(1);
|
|
9
|
+
/* await t.test('GET /suggest', async () => {
|
|
10
|
+
const res = await app.inject({
|
|
11
|
+
method: 'GET',
|
|
12
|
+
url: '/api/suggest/test.storage.data',
|
|
13
|
+
});
|
|
14
|
+
// console.log(res?.body);
|
|
15
|
+
const rep = JSON.parse(res?.body);
|
|
16
|
+
// console.log(rep.total);
|
|
17
|
+
assert.ok(rep.total);
|
|
18
|
+
}); */
|
|
19
|
+
/* await t.test('GET /data', async () => {
|
|
20
|
+
const res = await app.inject({
|
|
21
|
+
method: 'GET',
|
|
22
|
+
url: '/api/data/test.dataset.table',
|
|
23
|
+
});
|
|
24
|
+
// console.log(res);
|
|
25
|
+
const rep = JSON.parse(res?.body);
|
|
26
|
+
// console.log(rep.total);
|
|
27
|
+
assert.ok(rep.total);
|
|
28
|
+
}); */
|
|
29
|
+
/* await t.test('GET /search', async () => {
|
|
30
|
+
const res = await app.inject({
|
|
31
|
+
method: 'GET',
|
|
32
|
+
url: '/api/search?table=test.dataset.table&key=0',
|
|
33
|
+
});
|
|
34
|
+
const rep = JSON.parse(res?.body);
|
|
35
|
+
assert.ok(rep.total);
|
|
36
|
+
}); */
|
|
37
|
+
await t.test('GET /form', async () => {
|
|
38
|
+
const res = await app.inject({
|
|
39
|
+
method: 'GET',
|
|
40
|
+
url: '/api/form/test.dataset.form',
|
|
41
|
+
});
|
|
42
|
+
// console.log(res);
|
|
43
|
+
const rep = JSON.parse(res?.body);
|
|
44
|
+
// console.log(rep.total);
|
|
45
|
+
assert.ok(rep);
|
|
46
|
+
});
|
|
47
|
+
await t.test('GET /filter', async () => {
|
|
48
|
+
const res = await app.inject({
|
|
49
|
+
method: 'GET',
|
|
50
|
+
url: '/api/filter/test.dataset.table',
|
|
51
|
+
});
|
|
52
|
+
// console.log(res);
|
|
53
|
+
const rep = JSON.parse(res?.body);
|
|
54
|
+
// console.log(rep.total);
|
|
55
|
+
assert.ok(rep);
|
|
56
|
+
});
|
|
57
|
+
});
|