@opengis/fastify-table 2.0.45 → 2.0.47

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":"getSelect.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/table/funcs/getSelect.ts"],"names":[],"mappings":"AAYA,wBAA8B,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,MAAmB,gBAkCvE"}
1
+ {"version":3,"file":"getSelect.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/table/funcs/getSelect.ts"],"names":[],"mappings":"AAYA,wBAA8B,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,MAAmB,gBA6BvE"}
@@ -11,20 +11,17 @@ export default async function getSelect(name, pg = pgClients.client) {
11
11
  if (loadCls[name] && !config.local)
12
12
  return loadCls[name];
13
13
  const clsDataGIT = await getTemplate(["cls", "select"], name);
14
- const { type } = !clsDataGIT && pg.pk?.["admin.user_cls"]
14
+ const { type } = pg.pk?.["admin.user_cls"]
15
15
  ? await pg
16
16
  .query("select type from admin.user_cls where parent is null and name=$1 union all select type from admin.cls where parent is null and name=$1 limit 1", [name])
17
17
  .then((el) => el.rows?.[0] || {})
18
18
  : {};
19
- const q = !clsDataGIT && type && ["sql", "json"].includes(type)
20
- ? sqls[type]
21
- : undefined;
22
- const clsDataDB = q
19
+ const clsDataDB = sqls[type || ""]
23
20
  ? await pg
24
- .query(q, [name])
21
+ .query(sqls[type || ""], [name])
25
22
  .then((el) => el.rows?.find((item) => item?.data)?.data)
26
23
  : undefined;
27
- const clsData = clsDataGIT || clsDataDB;
24
+ const clsData = clsDataDB ?? clsDataGIT;
28
25
  if (!clsData)
29
26
  return null;
30
27
  // console.log(clsData);
@@ -1 +1 @@
1
- {"version":3,"file":"suggest.d.ts","sourceRoot":"","sources":["../../../../../server/routes/table/controllers/suggest.ts"],"names":[],"mappings":"AAsDA,wBAA8B,OAAO,CAAC,GAAG,EAAE,GAAG,gBA8U7C"}
1
+ {"version":3,"file":"suggest.d.ts","sourceRoot":"","sources":["../../../../../server/routes/table/controllers/suggest.ts"],"names":[],"mappings":"AAsDA,wBAA8B,OAAO,CAAC,GAAG,EAAE,GAAG,gBAgV7C"}
@@ -199,7 +199,7 @@ export default async function suggest(req) {
199
199
  ? `unnest(${filterColumn})`
200
200
  : filterColumn} from ${(loadTable?.table || query.token).replace(/'/g, "''")})`
201
201
  : "true";
202
- const sqlSuggest = `with c(id,text) as ( ${meta.original.replace(/{{parent}}/gi, parent)} where ${where} order by 2) select * from c where ${filter} limit ${Math.min(query.limit || meta.limit || limit, limit)}`.replace(/{{uid}}/g, user?.uid || "0");
202
+ 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");
203
203
  if (query.sql && (config.local || user?.user_type?.includes?.("admin"))) {
204
204
  return sqlSuggest;
205
205
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/fastify-table",
3
- "version": "2.0.45",
3
+ "version": "2.0.47",
4
4
  "type": "module",
5
5
  "description": "core-plugins",
6
6
  "keywords": [