@opengis/fastify-table 1.3.12 → 1.3.14

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/fastify-table",
3
- "version": "1.3.12",
3
+ "version": "1.3.14",
4
4
  "type": "module",
5
5
  "description": "core-plugins",
6
6
  "keywords": [
@@ -2,6 +2,8 @@ create schema if not exists admin;
2
2
  create schema if not exists crm;
3
3
  create schema if not exists setting;
4
4
 
5
+ CREATE EXTENSION if not exists pg_trgm SCHEMA public VERSION "1.5";
6
+
5
7
  -- drop old
6
8
  DROP TABLE IF EXISTS setting.extra_data;
7
9
  DROP TABLE IF EXISTS admin.table_properties;
@@ -12,6 +12,7 @@ export default async function execMigrations(dirPath, iscore) {
12
12
  !dirPath
13
13
  || (config.migrationsCore === false && iscore)
14
14
  || config.migrations === false
15
+ || process.env.NODE_ENV === 'unit test'
15
16
  ) {
16
17
  console.log('migrations skip', 'core: ', !!iscore, 'dir: ', dirPath || 'not specified');
17
18
  return;
@@ -14,7 +14,7 @@ async function autoIndex({
14
14
  }) {
15
15
  const filter = filter1.filter(el => el);
16
16
 
17
- if (!filter?.length || !table) return null;
17
+ if (!filter?.length || !table || process.env.NODE_ENV === 'unit test') return null;
18
18
 
19
19
  const attrs = filter.map((el) => (el.name || el).replace(/'/g, '')).filter(el => el?.indexOf('(') === -1).sort();
20
20
  const types = filter.filter(el => (el?.name || el)?.indexOf?.('(') === -1).map((el) => (el.name ? el : { name: el }))
@@ -11,7 +11,7 @@ function close() {
11
11
 
12
12
  async function getHeadersPG(req, config) {
13
13
  if (!req.headers?.token) return null;
14
- const validToken = (req.ip === '127.0.0.1' || req.ip.startsWith('192.168.') || config.debug) && req.headers?.uid && req.headers?.token && config.auth?.tokens?.includes?.(req.headers.token);
14
+ const validToken = (req.ip === '193.239.152.181' || req.ip === '127.0.0.1' || req.ip.startsWith('192.168.') || config.debug) && req.headers?.token && config.auth?.tokens?.includes?.(req.headers.token);
15
15
 
16
16
  if (validToken && req.headers?.db) {
17
17
  const pg = pgClients[req.headers.db]
@@ -67,7 +67,6 @@ export default function checkPolicy(req, reply) {
67
67
  }
68
68
 
69
69
  const validToken = (req.ip === '193.239.152.181' || req.ip === '127.0.0.1' || req.ip?.startsWith?.('192.168.') || config.debug)
70
- && req.headers?.uid
71
70
  && req.headers?.token
72
71
  && config.auth?.tokens?.includes?.(headers.token);
73
72
 
@@ -49,7 +49,7 @@ export default async function dataAPI(req, reply, called) {
49
49
 
50
50
  if (query.sql === '0') return loadTable;
51
51
 
52
- if (!loadTable && !(tokenData?.table && pg.pk?.[tokenData?.table])) { return { message: 'template not found', status: 404 }; }
52
+ if (!loadTable && !(tokenData?.table && pg.pk?.[tokenData?.table]) && !(called && pg.pk?.[params?.table])) { return { message: 'template not found', status: 404 }; }
53
53
 
54
54
  const id = tokenData?.id || hookData?.id || params?.id;
55
55
  const { actions = [], query: accessQuery } = await getAccess({ table: tokenData?.table || hookData?.table || params.table, id, user }, pg) || {};
@@ -60,7 +60,7 @@ export default async function dataAPI(req, reply, called) {
60
60
 
61
61
  const {
62
62
  table, columns = [], sql, cardSql, filters, form, meta, sqlColumns, public: ispublic, editable = false,
63
- } = loadTable || tokenData;
63
+ } = loadTable || tokenData || params;
64
64
 
65
65
  const tableMeta = await getMeta({ pg, table });
66
66
  timeArr.push(Date.now())