@opengis/fastify-table 2.0.120 → 2.0.122
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/dist/config.js +1 -1
- package/dist/server/plugins/logger/createFileStream.d.ts.map +1 -1
- package/dist/server/plugins/table/funcs/getSelectMeta.d.ts.map +1 -1
- package/dist/server/plugins/table/funcs/getSelectMeta.js +3 -1
- package/dist/server/plugins/usercls/index.d.ts.map +1 -1
- package/dist/server/plugins/usercls/index.js +15 -19
- package/dist/server/routes/usercls/controllers/editUserCls.d.ts.map +1 -1
- package/dist/server/routes/usercls/controllers/editUserCls.js +4 -4
- package/dist/server/routes/usercls/controllers/getUserCls.js +2 -1
- package/package.json +1 -1
package/dist/config.js
CHANGED
|
@@ -10,7 +10,7 @@ Object.assign(config, {
|
|
|
10
10
|
storageList: {},
|
|
11
11
|
allTemplates: config?.allTemplates || {},
|
|
12
12
|
env: process.env.NODE_ENV,
|
|
13
|
-
port: process.env.PORT,
|
|
13
|
+
port: config.port || process.env.PORT,
|
|
14
14
|
});
|
|
15
15
|
if (existsSync(`.env.local`)) {
|
|
16
16
|
dotenv.config({ path: `.env.local` }); // ! load .env.local
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createFileStream.d.ts","sourceRoot":"","sources":["../../../../server/plugins/logger/createFileStream.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"createFileStream.d.ts","sourceRoot":"","sources":["../../../../server/plugins/logger/createFileStream.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,yBAAyB,CAAC;AAmC5C,MAAM,CAAC,OAAO,UAAU,eAAe,iDAoDtC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSelectMeta.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/table/funcs/getSelectMeta.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAWzD,wBAA8B,aAAa,CAAC,EAC1C,IAAI,EACJ,UAAU,EACV,GAAG,EACH,OAAO,EACP,MAAM,EACN,EAAqB,GACtB,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,EAAE,CAAC,EAAE,UAAU,CAAC;CACjB,
|
|
1
|
+
{"version":3,"file":"getSelectMeta.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/table/funcs/getSelectMeta.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAWzD,wBAA8B,aAAa,CAAC,EAC1C,IAAI,EACJ,UAAU,EACV,GAAG,EACH,OAAO,EACP,MAAM,EACN,EAAqB,GACtB,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,EAAE,CAAC,EAAE,UAAU,CAAC;CACjB,gBA8GA"}
|
|
@@ -17,7 +17,9 @@ export default async function getSelectMeta({ name, startsWith, key, nocache, pa
|
|
|
17
17
|
}
|
|
18
18
|
const cls = await getSelect(name, pg, nocache);
|
|
19
19
|
const db = typeof cls?.db === "string" ? { database: cls.db } : cls?.db;
|
|
20
|
-
const pg1 = cls?.db
|
|
20
|
+
const pg1 = cls?.db
|
|
21
|
+
? await getPGAsync({ database: db, port: cls?.port })
|
|
22
|
+
: pg;
|
|
21
23
|
if (!cls)
|
|
22
24
|
return null;
|
|
23
25
|
if (cls.arr)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sour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C;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,27 +121,23 @@ 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 where =
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
]
|
|
136
|
-
.filter(Boolean)
|
|
137
|
-
.join(" and ");
|
|
138
|
-
}, "1=1");
|
|
139
|
-
const q = `select 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}`;
|
|
124
|
+
const args = name ? [name.split(",")] : [search];
|
|
125
|
+
const where = name
|
|
126
|
+
? "name=any($1::text[])"
|
|
127
|
+
: `( name ilike '%'||$1||'%' or name in (select parent from admin.user_cls where name ilike '%'||$1||'%') )`;
|
|
128
|
+
const q = `select true as custom, name, type, description, alias, (select count(*) filter(where ${search ? `name ilike '%'||$1||'%'` : "true"}) from admin.user_cls where parent=t.name limit 1) as count from admin.user_cls t where parent is null and ${where}
|
|
129
|
+
|
|
130
|
+
union all
|
|
131
|
+
|
|
132
|
+
select false as custom, name, type, null as description, null as alias, (select count(*) filter(where ${search ? `name ilike '%'||$1||'%'` : "true"}) from admin.cls where parent=t.name limit 1) as count from admin.cls t where parent is null and ${where}
|
|
133
|
+
|
|
134
|
+
order by name`;
|
|
142
135
|
if (sql)
|
|
143
136
|
return q;
|
|
144
|
-
const
|
|
137
|
+
const rows1 = await pg.query(q, args).then((el) => el.rows || []);
|
|
138
|
+
const customRows = rows1.filter((row) => row.custom);
|
|
139
|
+
const customClsNames = customRows.map((row) => row.name);
|
|
140
|
+
const rows = customRows.concat(rows1.filter((row) => !customClsNames.includes(row.name)));
|
|
145
141
|
return rows;
|
|
146
142
|
}
|
|
147
143
|
export async function getUserCls(name, pg = pgClients.client) {
|
|
@@ -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({
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import config from "../../../../config.js";
|
|
1
2
|
import pgClients from "../../../plugins/pg/pgClients.js";
|
|
2
3
|
import { getUserClsList } from "../../../plugins/usercls/index.js";
|
|
3
4
|
export default async function getUserClsListApi({ query, user, pg = pgClients.client }, reply) {
|
|
4
|
-
if (!user?.uid) {
|
|
5
|
+
if (!user?.uid && !config.local) {
|
|
5
6
|
return reply.status(401).send({ error: "unauthorized", code: 401 });
|
|
6
7
|
}
|
|
7
8
|
const t1 = Date.now();
|