@opengis/fastify-table 2.0.120 → 2.0.121
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 +12 -3
- 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","sourceRoot":"","sources":["../../../../server/plugins/usercls/index.ts"],"names":[],"mappings":"AAMA,wBAAsB,YAAY,CAChC,EACE,I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K,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,gBA8CtB;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,MAAmB;;;;;UAsBnE;;AAED,wBAAoB"}
|
|
@@ -136,12 +136,21 @@ export async function getUserClsList({ name, search, sql }, pg = pgClients.clien
|
|
|
136
136
|
.filter(Boolean)
|
|
137
137
|
.join(" and ");
|
|
138
138
|
}, "1=1");
|
|
139
|
-
const q = `select name, type, description, alias, (select count(*) filter(where ${search
|
|
139
|
+
const q = `select true as custom, name, type, description, alias, (select count(*) filter(where ${search
|
|
140
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}
|
|
141
|
+
: "true"}) from admin.user_cls where parent=t.name) as count from admin.user_cls t where parent is null and ${where}
|
|
142
|
+
|
|
143
|
+
union all
|
|
144
|
+
|
|
145
|
+
select false as custom, name, type, null as description, null as alias, (select count(*) filter(where ${search
|
|
146
|
+
? `name ilike '%'||$${where.match(/\$\d/g)?.length || 0}||'%'`
|
|
147
|
+
: "true"}) from admin.cls where parent=t.name) as count from admin.cls t where parent is null and ${where}`;
|
|
142
148
|
if (sql)
|
|
143
149
|
return q;
|
|
144
|
-
const
|
|
150
|
+
const rows1 = await pg.query(q, args).then((el) => el.rows || []);
|
|
151
|
+
const customRows = rows1.filter((row) => row.custom);
|
|
152
|
+
const customClsNames = customRows.map((row) => row.name);
|
|
153
|
+
const rows = customRows.concat(rows1.filter((row) => !customClsNames.includes(row.name)));
|
|
145
154
|
return rows;
|
|
146
155
|
}
|
|
147
156
|
export async function getUserCls(name, pg = pgClients.client) {
|
|
@@ -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();
|