@opengis/fastify-table 1.4.66 → 1.4.67
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/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
config, applyHook, getTemplate, pgClients, getAccess, setToken,
|
|
2
|
+
config, applyHook, getTemplate, pgClients, getAccess, setToken, getSelectMeta,
|
|
3
3
|
} from '../../../../utils.js';
|
|
4
4
|
|
|
5
5
|
import getEditData from '../../crud/controllers/table.js';
|
|
@@ -18,6 +18,10 @@ export default async function getForm({
|
|
|
18
18
|
const time = Date.now();
|
|
19
19
|
const { add, edit } = query;
|
|
20
20
|
|
|
21
|
+
if (!user?.uid) {
|
|
22
|
+
return reply.status(401).send('unauthorized');
|
|
23
|
+
}
|
|
24
|
+
|
|
21
25
|
const hookData = await applyHook('preForm', { table: params.name, user });
|
|
22
26
|
|
|
23
27
|
if (hookData?.message && hookData?.status) {
|
|
@@ -38,7 +42,17 @@ export default async function getForm({
|
|
|
38
42
|
return reply.status(404).send('form template not found');
|
|
39
43
|
}
|
|
40
44
|
|
|
41
|
-
const
|
|
45
|
+
const { schema = loadTemplate } = loadTemplate;
|
|
46
|
+
|
|
47
|
+
await Promise.all(Object.keys(schema || {}).filter(key => schema[key]?.data).map(async key => {
|
|
48
|
+
const { arr } = await getSelectMeta({ name: schema[key].data, pg }) || {};
|
|
49
|
+
if (arr) {
|
|
50
|
+
schema[key].data = undefined;
|
|
51
|
+
schema[key].options = arr;
|
|
52
|
+
}
|
|
53
|
+
}));
|
|
54
|
+
|
|
55
|
+
const res = { schema };
|
|
42
56
|
|
|
43
57
|
if (add && user.uid) {
|
|
44
58
|
if (!actions.includes('add') && !config.local) {
|
|
@@ -49,7 +49,7 @@ async function plugin(app, config = {}) {
|
|
|
49
49
|
|
|
50
50
|
app.get(`${prefix}/templates`, () => loadTemplatePath);
|
|
51
51
|
app.get(`${prefix}/filter/:table`, { config: { policy }, schema: filterSchema }, filter);
|
|
52
|
-
app.get(`${prefix}/form/:name`, { config: { policy }, schema: formSchema }, form);
|
|
52
|
+
app.get(`${prefix}/form/:name`, { config: { policy: ['user', 'site'] }, schema: formSchema }, form);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
export default plugin;
|