@opengis/fastify-table 1.1.104 → 1.1.106

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.1.104",
3
+ "version": "1.1.106",
4
4
  "type": "module",
5
5
  "description": "core-plugins",
6
6
  "main": "index.js",
@@ -24,8 +24,10 @@
24
24
  "fastify": "^4.26.1",
25
25
  "fastify-plugin": "^4.0.0",
26
26
  "ioredis": "^5.3.2",
27
+ "js-yaml": "^4.1.0",
27
28
  "nodemailer": "^6.5.0",
28
29
  "pg": "^8.11.3",
30
+ "pino": "^9.5.0",
29
31
  "pino-abstract-transport": "^2.0.0"
30
32
  },
31
33
  "devDependencies": {
@@ -43,4 +45,4 @@
43
45
  },
44
46
  "author": "Softpro",
45
47
  "license": "ISC"
46
- }
48
+ }
@@ -1,3 +1,4 @@
1
+ import { getPG } from '@opengis/fastify-table/utils.js';
1
2
  import logger from '../../logger/getLogger.js';
2
3
  import autoIndex from '../../pg/funcs/autoIndex.js';
3
4
  import pgClients from '../../pg/pgClients.js';
@@ -11,6 +12,8 @@ export default async function getSelectMeta({ name, pg = pgClients.client, nocac
11
12
  if (selectMeta[name] && !nocache) return selectMeta[name];
12
13
 
13
14
  const cls = await getSelect(name, pg);
15
+ const pg1 = cls?.db ? getPG(cls.db) : pg;
16
+ if (!pg1?.pk) await pg1.init();
14
17
 
15
18
  if (!cls) return null;
16
19
  if (cls.arr) return cls;
@@ -26,17 +29,17 @@ export default async function getSelectMeta({ name, pg = pgClients.client, nocac
26
29
  const tableNew = original.toLowerCase().replace(/\n/g, ' ').split(' from ').filter((el) => /^[a-z0-9_]+\.[a-z0-9_]+/.test(el))
27
30
  .map((el) => el.split(/[ )]/)[0].replace(/[\r\n]+/g, ''));
28
31
 
29
- const dataOrigin = await pg.query(sql?.replace(`limit ${limit}`, 'limit 0'));
32
+ const dataOrigin = await pg1.query(sql?.replace(`limit ${limit}`, 'limit 0'));
30
33
 
31
- const dataOrigin1 = await pg.query(`${original} limit 0`);
34
+ const dataOrigin1 = await pg1.query(`${original} limit 0`);
32
35
 
33
36
  // const table = getTable(original);
34
- const count = cls?.count ?? await pg.query(`select count(*) from (${original})q`).then((el) => el?.rows?.[0].count);
37
+ const count = cls?.count ?? await pg1.query(`select count(*) from (${original})q`).then((el) => el?.rows?.[0].count);
35
38
 
36
39
  // column name
37
40
  const cols = dataOrigin.fields.map((el) => el.name);
38
41
  const originalCols = dataOrigin1.fields.map((el) => el.name);
39
- const type = dataOrigin.fields.map((el) => pg.pgType?.[el.dataTypeID] || 'text');
42
+ const type = dataOrigin.fields.map((el) => pg1.pgType?.[el.dataTypeID] || 'text');
40
43
 
41
44
  autoIndex({ table: tableNew[0], columns: [originalCols[1]].concat(cls?.searchColumn?.split(',')), gin: 1 }).catch(err => logger.error(err));
42
45