@opengis/fastify-table 2.0.150 → 2.0.152

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":"logChanges.d.ts","sourceRoot":"","sources":["../../../../../../server/plugins/crud/funcs/utils/logChanges.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,2BAA2B,CAAC;AA8C5D,wBAA8B,UAAU,CAAC,EACvC,EAAE,EACF,KAAK,EAAE,MAAM,EACb,SAAS,EACT,OAAO,EACP,EAAE,EACF,IAAI,EACJ,GAAO,EACP,IAAI,GACL,EAAE;IACD,EAAE,EAAE,UAAU,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAClC,IAAI,EAAE,MAAM,CAAC;CACd;;;;;;;;;;;;;;;;;;;;UA8MA"}
1
+ {"version":3,"file":"logChanges.d.ts","sourceRoot":"","sources":["../../../../../../server/plugins/crud/funcs/utils/logChanges.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,2BAA2B,CAAC;AA8C5D,wBAA8B,UAAU,CAAC,EACvC,EAAE,EACF,KAAK,EAAE,MAAM,EACb,SAAS,EACT,OAAO,EACP,EAAE,EACF,IAAI,EACJ,GAAO,EACP,IAAI,GACL,EAAE;IACD,EAAE,EAAE,UAAU,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAClC,IAAI,EAAE,MAAM,CAAC;CACd;;;;;;;;;;;;;;;;;;;;UAiNA"}
@@ -123,20 +123,24 @@ export default async function logChanges({ pg, table: table1, tokenData, referer
123
123
  return acc;
124
124
  });
125
125
  }
126
- const newGeoms = await Promise.all(Object.keys(newObj1)
126
+ await Promise.all(Object.keys(row)
127
127
  .filter((key) => row[key] && columnTypes[key] === "geometry")
128
128
  .map(async (key) => pg
129
129
  .query(typeof row[key] === "string" // binary geometry as string via update?
130
130
  ? "select st_asgeojson(st_pointonsurface($1))::json"
131
131
  : "select st_asgeojson(st_pointonsurface(st_geomfromgeojson($1)))::json", [row[key]])
132
- .then((el) => ({ key, geometry: el.rows[0].st_asgeojson })))).then((r) => r.reduce((acc, curr) => {
132
+ .then((el) => ({ key, geometry: el.rows[0].st_asgeojson })))).then((r) => r.forEach((curr) => {
133
133
  const value = curr.geometry.coordinates.join(",");
134
134
  const hash = createHash("md5")
135
135
  .update(JSON.stringify(value))
136
136
  .digest("hex");
137
- newObj1[curr.key] = { value, hash };
138
- return { ...acc, [curr.key]: { value, hash } };
139
- }, {}));
137
+ if (titles[curr.key]) {
138
+ newObj1[titles[curr.key]] = { value, hash };
139
+ }
140
+ else {
141
+ newObj1[curr.key] = { value, hash };
142
+ }
143
+ }));
140
144
  const changesData = Object.keys(newObj1 || {})
141
145
  .filter((key) => typeof newObj1?.[key] === "boolean" || newObj1?.[key])
142
146
  .filter((key) => old[key] ? old[key].hash !== newObj1[key]?.hash : newObj1[key]?.hash)
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/plugins/usercls/index.ts"],"names":[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tB;AAED,wBAAsB,cAAc,CAClC,EACE,IAAI,EACJ,MAAM,EACN,GAAG,EACH,MAAM,EACN,IAAI,GACL,EAAE;IACD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,EACD,EAAE,MAAmB,gBA6CtB;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,MAAmB;;;;;UAsBnE;;AAED,wBAAoB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/plugins/usercls/index.ts"],"names":[],"mappings":"AAMA,wBAAsB,YAAY,CAChC,EACE,IAAI,EACJ,WAAW,EACX,KAAK,EACL,KAAK,EACL,GAAG,EACH,IAAS,GACV,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE;QACJ,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,OAAO,CAAC;KAClB,EAAE,CAAC;CACL,EACD,EAAE,MAAmB,mBA8EtB;AAED,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,MAAmB,mBAUtE;AAED,wBAAsB,UAAU,CAC9B,EACE,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,WAAW,GACZ,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;CACtC,EACD,EAAE,MAAmB,mBAkDtB;AAED,wBAAsB,WAAW,CAC/B,EACE,IAAI,EACJ,KAAK,EACL,WAAW,EACX,IAAI,GACL,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;CACtC,EACD,EAAE,MAAmB,mBAKtB;AAED,wBAAsB,cAAc,CAClC,EACE,IAAI,EACJ,MAAM,EACN,GAAG,EACH,MAAM,EACN,IAAI,GACL,EAAE;IACD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,EACD,EAAE,MAAmB,gBAgDtB;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,MAAmB;;;;;UAsBnE;;AAED,wBAAoB"}
@@ -121,18 +121,21 @@ export async function editUserCls({ name, alias, description, data, }, pg = pgCl
121
121
  return "ok";
122
122
  }
123
123
  export async function getUserClsList({ name, search, sql, custom, type, }, pg = pgClients.client) {
124
- const args = name ? [name.split(",")] : [search].filter(Boolean);
125
- const subQuery = search
126
- ? `case when parent<>$1 then name ilike '%'||$1||'%' else true end`
127
- : "true";
124
+ const args = [name ? name.split(",") : null, search].filter(Boolean);
128
125
  const typeStr = type ? { cls: "json", select: "sql" }[type] : null;
129
- const where = (name ? "name=any($1::text[])" : null) ||
130
- (search
131
- ? `( name ilike '%'||$1||'%' or name in (select parent from admin.user_cls where name ilike '%'||$1||'%') )`
132
- : "1=1");
133
- const customQuery = `select true as custom, name, type, description, alias, (select count(*) filter(where ${subQuery}) from admin.user_cls where parent=t.name limit 1) as count
126
+ const idx = search && name ? 2 : 1;
127
+ const where = [
128
+ name ? "name=any($1::text[])" : null,
129
+ search
130
+ ? `( name ilike '%'||$${idx}||'%' or name in (select parent from admin.user_cls where name ilike '%'||$${idx}||'%') )`
131
+ : null,
132
+ ]
133
+ .filter(Boolean)
134
+ .join(" and ") || "1=1";
135
+ console.log(name, search, where);
136
+ const customQuery = `select true as custom, name, type, description, alias, case when type = 'sql' then 1 else (select count(*) from admin.user_cls where parent=t.name limit 1) end as count
134
137
  from admin.user_cls t where parent is null and ${where} and ${typeStr ? `type='${typeStr}'` : "true"}`;
135
- const gitQuery = `select false as custom, name, type, null as description, null as alias, (select count(*) filter(where ${subQuery}) from admin.cls where parent=t.name limit 1) as count
138
+ const gitQuery = `select false as custom, name, type, null as description, null as alias, case when type = 'sql' then 1 else (select count(*) from admin.cls where parent=t.name limit 1) end as count
136
139
  from admin.cls t where parent is null and ${where.replace(/admin.user_cls/g, "admin.cls")} and ${typeStr ? `type='${typeStr}'` : "true"}`;
137
140
  const q = [
138
141
  custom !== "0" ? customQuery : null,
@@ -1 +1 @@
1
- {"version":3,"file":"getUserCls.d.ts","sourceRoot":"","sources":["../../../../../server/routes/usercls/controllers/getUserCls.ts"],"names":[],"mappings":"AAKA,wBAA8B,iBAAiB,CAC7C,EAAE,KAAK,EAAE,IAAI,EAAE,EAAqB,EAAE,EAAE,GAAG,EAC3C,KAAK,EAAE,GAAG,gBAsBX"}
1
+ {"version":3,"file":"getUserCls.d.ts","sourceRoot":"","sources":["../../../../../server/routes/usercls/controllers/getUserCls.ts"],"names":[],"mappings":"AAQA,wBAA8B,iBAAiB,CAC7C,EAAE,KAAK,EAAE,IAAI,EAAE,EAAqB,EAAE,EAAE,GAAG,EAC3C,KAAK,EAAE,GAAG,gBA0BX"}
@@ -1,10 +1,16 @@
1
1
  import config from "../../../../config.js";
2
2
  import pgClients from "../../../plugins/pg/pgClients.js";
3
3
  import { getUserClsList } from "../../../plugins/usercls/index.js";
4
+ // query.name = cls1,cls2,cls3
5
+ // query.search = substring of cls name
6
+ // data[idx].count - should not depend on either query.name or query.search
4
7
  export default async function getUserClsListApi({ query, user, pg = pgClients.client }, reply) {
5
8
  if (!user?.uid && !config.local) {
6
9
  return reply.status(401).send({ error: "unauthorized", code: 401 });
7
10
  }
11
+ if (!pg) {
12
+ return reply.status(400).send({ error: "empty pg", code: 400 });
13
+ }
8
14
  const t1 = Date.now();
9
15
  const result = await getUserClsList({
10
16
  name: query.name,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/fastify-table",
3
- "version": "2.0.150",
3
+ "version": "2.0.152",
4
4
  "type": "module",
5
5
  "description": "core-plugins",
6
6
  "keywords": [