@opengis/fastify-table 2.0.11 → 2.0.12
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.
|
@@ -65,9 +65,7 @@ function plugin(fastify) {
|
|
|
65
65
|
};
|
|
66
66
|
req.user = req.session.passport.user;
|
|
67
67
|
}
|
|
68
|
-
req.user = req.user
|
|
69
|
-
// already done by @fastify/passport serializer / deserializer
|
|
70
|
-
// req.user = passport.user;
|
|
68
|
+
req.user = req.user || req.session?.passport?.user || undefined; // fix for user.uid errors, by default user is null, while with express passport it was {}, unauthorized user does not trigger serializer
|
|
71
69
|
if (config.trace && false) {
|
|
72
70
|
console.log("req.user?.uid", req.user?.uid, "req.session?.passport?.user?.uid", req.session?.passport?.user?.uid, "config.auth", config.auth);
|
|
73
71
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { handlebars } from "../../../../helpers/index.js";
|
|
2
2
|
import getTemplate from "../getTemplate.js";
|
|
3
3
|
import getSelectVal from "./getSelectVal.js";
|
|
4
4
|
import pgClients from "../../../pg/pgClients.js";
|
|
@@ -19,17 +19,17 @@ export default async function metaFormat({ rows: original, table, cls = {}, html
|
|
|
19
19
|
return original;
|
|
20
20
|
const rows = reassign ? original : JSON.parse(JSON.stringify(original));
|
|
21
21
|
// html && slot (vue component) format
|
|
22
|
-
htmlCols.
|
|
23
|
-
rows.filter(Boolean).
|
|
24
|
-
const html =
|
|
22
|
+
await Promise.all(htmlCols.map(async (attr) => {
|
|
23
|
+
await Promise.all(rows.filter(Boolean).map(async (row) => {
|
|
24
|
+
const html = await handlebars.compile(attr.html)(row);
|
|
25
25
|
Object.assign(row, {
|
|
26
26
|
[attr.name]: html
|
|
27
27
|
?.replaceAll?.(/<[^>]*>/g, "")
|
|
28
28
|
?.replace?.(/\n/g, "")
|
|
29
29
|
?.trim?.(),
|
|
30
30
|
});
|
|
31
|
-
});
|
|
32
|
-
});
|
|
31
|
+
}));
|
|
32
|
+
}));
|
|
33
33
|
// cls & select format
|
|
34
34
|
await Promise.all(selectCols.concat(metaCls)?.map(async (attr) => {
|
|
35
35
|
const values = [
|
package/package.json
CHANGED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import config from "../../../config.js";
|
|
2
|
-
export const hookList = {};
|
|
3
|
-
export async function applyHook(name, data) {
|
|
4
|
-
if (config.trace)
|
|
5
|
-
console.log("applyHook", name);
|
|
6
|
-
if (!hookList[name]?.length)
|
|
7
|
-
return null;
|
|
8
|
-
const result = {};
|
|
9
|
-
await Promise.all(hookList[name].map(async (hook) => {
|
|
10
|
-
const hookData = await hook({ ...data, config });
|
|
11
|
-
if (hookData) {
|
|
12
|
-
if (config.trace)
|
|
13
|
-
console.log("applyHook", name, hookData);
|
|
14
|
-
Object.assign(result, hookData);
|
|
15
|
-
}
|
|
16
|
-
})).catch((err) => {
|
|
17
|
-
console.error("applyHook", name, err.toString());
|
|
18
|
-
});
|
|
19
|
-
if (Object.keys(result).length) {
|
|
20
|
-
return result;
|
|
21
|
-
}
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
export function addHook(name, fn) {
|
|
25
|
-
if (!hookList[name]) {
|
|
26
|
-
hookList[name] = [];
|
|
27
|
-
}
|
|
28
|
-
if (config.trace)
|
|
29
|
-
console.log("addHook", name);
|
|
30
|
-
hookList[name].push(fn);
|
|
31
|
-
}
|
|
32
|
-
export function applyHookSync(name, data) {
|
|
33
|
-
if (!hookList[name]?.length)
|
|
34
|
-
return null;
|
|
35
|
-
if (config.trace)
|
|
36
|
-
console.log("applyHookSync", name);
|
|
37
|
-
const hookData = hookList[name].map((hook) => hook(data))[0];
|
|
38
|
-
return hookData;
|
|
39
|
-
}
|