@opengis/fastify-table 2.0.121 → 2.0.123
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":["../../../../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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E,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,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,GAAG,CAAA;CAAE,EACpE,EAAE,MAAmB,gBA8BtB;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,MAAmB;;;;;UAsBnE;;AAED,wBAAoB"}
|
|
@@ -121,37 +121,25 @@ 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 }, pg = pgClients.client) {
|
|
124
|
-
const args = [];
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
name: `name=any($${idx + 1}::text[])`,
|
|
133
|
-
search: `name in (select parent from admin.user_cls where name ilike '%'||$${idx + 1}||'%')`,
|
|
134
|
-
}[curr[0]],
|
|
135
|
-
]
|
|
136
|
-
.filter(Boolean)
|
|
137
|
-
.join(" and ");
|
|
138
|
-
}, "1=1");
|
|
139
|
-
const q = `select true as custom, name, type, description, alias, (select count(*) filter(where ${search
|
|
140
|
-
? `name ilike '%'||$${where.match(/\$\d/g)?.length || 0}||'%'`
|
|
141
|
-
: "true"}) from admin.user_cls where parent=t.name) as count from admin.user_cls t where parent is null and ${where}
|
|
142
|
-
|
|
124
|
+
const args = name ? [name.split(",")] : [search].filter(Boolean);
|
|
125
|
+
const subQuery = search ? `name ilike '%'||$1||'%'` : "true";
|
|
126
|
+
const where = (name ? "name=any($1::text[])" : null) ||
|
|
127
|
+
(search
|
|
128
|
+
? `( ${subQuery} or name in (select parent from admin.user_cls where ${subQuery}) )`
|
|
129
|
+
: "1=1");
|
|
130
|
+
const q = `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
|
|
131
|
+
from admin.user_cls t where parent is null and ${where}
|
|
143
132
|
union all
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
: "true"}) from admin.cls where parent=t.name) as count from admin.cls t where parent is null and ${where}`;
|
|
133
|
+
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
|
|
134
|
+
from admin.cls t where parent is null and ${where}
|
|
135
|
+
order by name`;
|
|
148
136
|
if (sql)
|
|
149
137
|
return q;
|
|
150
|
-
const
|
|
151
|
-
const customRows =
|
|
138
|
+
const rows = await pg.query(q, args).then((el) => el.rows || []);
|
|
139
|
+
const customRows = rows.filter((row) => row.custom);
|
|
152
140
|
const customClsNames = customRows.map((row) => row.name);
|
|
153
|
-
const
|
|
154
|
-
return
|
|
141
|
+
const filteredRows = rows.filter((row) => !customClsNames.includes(row.name));
|
|
142
|
+
return customRows.concat(filteredRows);
|
|
155
143
|
}
|
|
156
144
|
export async function getUserCls(name, pg = pgClients.client) {
|
|
157
145
|
const { type, data, description, alias } = await pg
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editUserCls.d.ts","sourceRoot":"","sources":["../../../../../server/routes/usercls/controllers/editUserCls.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"editUserCls.d.ts","sourceRoot":"","sources":["../../../../../server/routes/usercls/controllers/editUserCls.ts"],"names":[],"mappings":"AAUA,wBAA8B,cAAc,CAC1C,EAAE,EAAqB,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,GAAG,EAClD,KAAK,EAAE,GAAG,gBAsCX"}
|
|
@@ -3,23 +3,23 @@ import getSelectMeta from "../../../plugins/table/funcs/getSelectMeta.js";
|
|
|
3
3
|
import { addUserCls, addCustomCls, editUserCls, getUserCls, } from "../../../plugins/usercls/index.js";
|
|
4
4
|
export default async function editUserClsApi({ pg = pgClients.client, body, params, user }, reply) {
|
|
5
5
|
const { name } = params;
|
|
6
|
-
const { data, table } = body;
|
|
6
|
+
const { data, table, description, alias } = body;
|
|
7
7
|
const t1 = Date.now();
|
|
8
8
|
if (!user?.uid) {
|
|
9
9
|
return reply.status(401).send({ error: "unauthorized", code: 401 });
|
|
10
10
|
}
|
|
11
11
|
if (table) {
|
|
12
|
-
await addCustomCls({ name, data, table, uid: user.uid }, pg);
|
|
12
|
+
await addCustomCls({ name, data, description, alias, table, uid: user.uid }, pg);
|
|
13
13
|
return reply
|
|
14
14
|
.status(200)
|
|
15
15
|
.send({ time: Date.now() - t1, name, type: "custom" });
|
|
16
16
|
}
|
|
17
17
|
const exists = await getUserCls(name, pg);
|
|
18
18
|
if (exists) {
|
|
19
|
-
await editUserCls({ name, data }, pg);
|
|
19
|
+
await editUserCls({ name, data, description, alias }, pg);
|
|
20
20
|
}
|
|
21
21
|
else {
|
|
22
|
-
await addUserCls({ name, data }, pg);
|
|
22
|
+
await addUserCls({ name, data, description, alias }, pg);
|
|
23
23
|
}
|
|
24
24
|
// refresh metadata to avoid suggest API cache
|
|
25
25
|
const test = await getSelectMeta({
|