@opengis/fastify-table 1.3.55 → 1.3.57

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.55",
3
+ "version": "1.3.57",
4
4
  "type": "module",
5
5
  "description": "core-plugins",
6
6
  "keywords": [
@@ -20,10 +20,10 @@ async function init(client) {
20
20
  from pg_class where relkind in ('r','v')`);
21
21
  const relkinds = rows.reduce((acc, curr) => Object.assign(acc, { [curr.tname]: curr.relkind }), {});
22
22
 
23
- async function query(q, args = [], isstream) {
23
+ async function query(q, args = [], disableTimeout) {
24
24
  try {
25
- if (isstream) {
26
- await client.query('set statement_timeout to 100000000');
25
+ if (disableTimeout) {
26
+ await client.query('set statement_timeout to 2147483647'); // max limit of integer value
27
27
  }
28
28
  const data = await client.query(q, args);
29
29
  await client.query('set statement_timeout to 0');
@@ -39,8 +39,7 @@ async function init(client) {
39
39
  }
40
40
 
41
41
  async function querySafe(q, param = {}) {
42
- const { args, isstream } = param;
43
- const data = await query(q, args, isstream);
42
+ const data = await query(q, Array.isArray(param) ? param : param?.args, 1);
44
43
  return data;
45
44
  }
46
45
 
@@ -1,3 +1,7 @@
1
+ import path from 'node:path';
2
+ import { fileURLToPath } from 'url';
3
+ import { existsSync, readFileSync } from 'node:fs';
4
+
1
5
  import {
2
6
  config, getPG, getTemplate, getSelectMeta, getMeta, applyHook, getSelectVal,
3
7
  } from '../../../../utils.js';
@@ -9,6 +13,8 @@ const headers = {
9
13
  'Cache-Control': 'no-cache',
10
14
  };
11
15
 
16
+ const dirname = path.dirname(fileURLToPath(import.meta.url));
17
+
12
18
  function getTableColumnMeta(table, column, filtered) {
13
19
  const original = {
14
20
  true: `with c(id,text) as (select ${column}, ${column} from ${table} group by ${column}) select id, text from c`,
@@ -30,6 +36,14 @@ export default async function suggest(req) {
30
36
  const time = Date.now();
31
37
  const parent = query.parent || '';
32
38
 
39
+ if (params?.data && params.data?.startsWith?.('hash-')) {
40
+ const filepath = path.join(process.cwd(), `/log/suggest/${params.data.replace('hash-', '')}.json`);
41
+ if (existsSync(filepath)) {
42
+ const { table, column } = JSON.parse(readFileSync(filepath, { encoding: 'utf8' }) || '{}');
43
+ params.data = `${table}:${column}`;
44
+ }
45
+ }
46
+
33
47
  const [table, column] = params.data?.includes(':') ? params.data.split(':') : [];
34
48
  const selectName = query.sel || query.name || params.data;
35
49