@opengis/fastify-table 2.0.146 → 2.0.148

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AA4FA,iBAAS,MAAM,CAAC,OAAO,EAAE,GAAG,QA6K3B;;AACD,wBAA0B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AA4FA,iBAAS,MAAM,CAAC,OAAO,EAAE,GAAG,QA8K3B;;AACD,wBAA0B"}
package/dist/index.js CHANGED
@@ -125,7 +125,7 @@ function plugin(fastify) {
125
125
  timeWindow: config.rateLimit?.timeWindow || 60000,
126
126
  hook: "preHandler",
127
127
  global: true,
128
- keyGenerator: (req) => `${req.ip}-${req.raw.url.split("?")[0]}`,
128
+ keyGenerator: (req) => `${req.user?.uid || req.ip}-${req.raw.url.split("?")[0]}`,
129
129
  });
130
130
  }
131
131
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"suggest.d.ts","sourceRoot":"","sources":["../../../../../server/routes/table/controllers/suggest.ts"],"names":[],"mappings":"AAiHA,wBAA8B,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,gBA6WzD"}
1
+ {"version":3,"file":"suggest.d.ts","sourceRoot":"","sources":["../../../../../server/routes/table/controllers/suggest.ts"],"names":[],"mappings":"AAuHA,wBAA8B,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,gBA6WzD"}
@@ -25,6 +25,14 @@ async function getTableColumnMeta({ table, template, column, selectName, filtere
25
25
  .filter((el) => !el.disabled && el.sql && el.sql.includes(column) && false)
26
26
  .map((el, i) => ` left join lateral (${el.sql}) ${el.name || `t${i}`} on 1=1 `)
27
27
  ?.join("") || "";
28
+ // w/out select
29
+ const searchQueryDefault = startsWith && key
30
+ ? `(left(lower("text"::text),${key.length}) = $1 )`
31
+ : '(lower("text"::text) ~ $1 )';
32
+ // w/ select
33
+ const searchQuerySelect = startsWith && key
34
+ ? `id in ( with cc(id, text) as (${select}) select id from cc where (left(lower("text"),${key.length})=$1) )`
35
+ : `id in ( with cc(id, text) as (${select}) select id from cc where (lower("text") ~ $1) )`;
28
36
  if (pg.pgType?.[dataTypeID]?.includes("[]")) {
29
37
  const original = filtered
30
38
  ? `with c(id,text) as (select id, id as text from (select unnest(${column}) as id from ${tableName} t ${sqlTable})q group by id) select id, text from c`
@@ -32,9 +40,7 @@ async function getTableColumnMeta({ table, template, column, selectName, filtere
32
40
  return {
33
41
  arr,
34
42
  original,
35
- searchQuery: startsWith && key
36
- ? `(left(lower("text"::text),${key.length}) = $1 )`
37
- : '(lower("text"::text) ~ $1 )',
43
+ searchQuery: select ? searchQuerySelect : searchQueryDefault,
38
44
  pk: "id",
39
45
  };
40
46
  }
@@ -44,9 +50,7 @@ async function getTableColumnMeta({ table, template, column, selectName, filtere
44
50
  return {
45
51
  arr,
46
52
  original,
47
- searchQuery: startsWith && key
48
- ? `(left(lower("text"),${key.length}) = $1 )`
49
- : '(lower("text") ~ $1 )',
53
+ searchQuery: select ? searchQuerySelect : searchQueryDefault,
50
54
  pk: "id",
51
55
  };
52
56
  }
@@ -252,7 +256,7 @@ export default async function suggest(req, reply) {
252
256
  const where = [search, val, filter, meta.pk ? `${meta.pk} is not null` : null]
253
257
  .filter(Boolean)
254
258
  .join(" and ") || "true";
255
- const sqlSuggest = `with c(id,text) as ( ${meta.original.replace(/{{parent}}/gi, parent)} where ${where} ${meta.original.includes("order by") ? "" : "order by 2"}) select * from c where ${filter} limit ${Math.min(query.limit || meta.limit || limit, limit)}`.replace(/{{uid}}/g, user?.uid || "0");
259
+ const sqlSuggest = `with c(id,text) as ( ${meta.original.replace(/{{parent}}/gi, parent)} where ${where} ${meta.original.toLowerCase().includes("order by") ? "" : "order by 2"}) select * from c where ${filter} limit ${Math.min(query.limit || meta.limit || limit, limit)}`.replace(/{{uid}}/g, user?.uid || "0");
256
260
  if (query.sql && debugMode) {
257
261
  return sqlSuggest;
258
262
  }
@@ -1 +1 @@
1
- {"version":3,"file":"dependencies.d.ts","sourceRoot":"","sources":["../../../../../server/routes/util/controllers/dependencies.ts"],"names":[],"mappings":"AAQA,wBAA8B,iBAAiB,CAAC,GAAG,EAAE,GAAG,eAUvD"}
1
+ {"version":3,"file":"dependencies.d.ts","sourceRoot":"","sources":["../../../../../server/routes/util/controllers/dependencies.ts"],"names":[],"mappings":"AAQA,wBAA8B,iBAAiB,CAAC,GAAG,EAAE,GAAG,eAcvD"}
@@ -9,5 +9,14 @@ export default async function dumpInstalledDeps(app) {
9
9
  ...json.dependencies,
10
10
  ...(json.devDependencies || {}),
11
11
  ...(json.peerDependencies || {}),
12
- }).reduce((acc, curr) => Object.assign(acc, { [curr]: require(`${curr}/package.json`).version }), {});
12
+ }).reduce((acc, curr) => {
13
+ try {
14
+ Object.assign(acc, { [curr]: require(`${curr}/package.json`).version });
15
+ }
16
+ catch (err) {
17
+ Object.assign(acc, { [curr]: err.toString() });
18
+ // skip packages that does not explicidly provide access to package.json
19
+ }
20
+ return acc;
21
+ }, {});
13
22
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/fastify-table",
3
- "version": "2.0.146",
3
+ "version": "2.0.148",
4
4
  "type": "module",
5
5
  "description": "core-plugins",
6
6
  "keywords": [
@@ -15,7 +15,8 @@
15
15
  "exports": {
16
16
  ".": "./dist/index.js",
17
17
  "./index.js": "./dist/index.js",
18
- "./utils.js": "./dist/utils.js"
18
+ "./utils.js": "./dist/utils.js",
19
+ "./package.json": "./package.json"
19
20
  },
20
21
  "files": [
21
22
  "dist/*"