@opengis/fastify-table 1.4.68 → 1.4.69

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/fastify-table",
3
- "version": "1.4.68",
3
+ "version": "1.4.69",
4
4
  "type": "module",
5
5
  "description": "core-plugins",
6
6
  "keywords": [
@@ -16,7 +16,8 @@ export default async function getForm({
16
16
  pg = pgClients.client, params = {}, user = {}, query = {},
17
17
  }, reply) {
18
18
  const time = Date.now();
19
- const { add, edit } = query;
19
+ const { add } = query;
20
+ const edit = query.edit || params.id;
20
21
 
21
22
  if (!user?.uid) {
22
23
  return reply.status(401).send('unauthorized');
@@ -52,9 +53,9 @@ export default async function getForm({
52
53
  }
53
54
  }));
54
55
 
55
- const res = { schema };
56
+ const res = { mode: 'form', time: 0, schema };
56
57
 
57
- if (add && user.uid) {
58
+ if (user.uid) {
58
59
  if (!actions.includes('add') && !config.local) {
59
60
  return reply.status(403).send('access restricted: actions');
60
61
  }
@@ -67,7 +68,7 @@ export default async function getForm({
67
68
  uid: user.uid,
68
69
  array: 1,
69
70
  });
70
- Object.assign(res, { token: addTokens[0] });
71
+ Object.assign(res, { token: addTokens[0], mode: 'add' });
71
72
  }
72
73
 
73
74
  if (edit && user.uid) {
@@ -82,7 +83,7 @@ export default async function getForm({
82
83
  const data = await getEditData({
83
84
  pg, params: { table: hookData?.table || params.name, id: edit }, user,
84
85
  }, reply, true);
85
- Object.assign(res, { token: editTokens[0], data });
86
+ Object.assign(res, { token: editTokens[0], data, mode: 'edit' });
86
87
  }
87
88
 
88
89
  // replace settings
@@ -41,15 +41,17 @@ async function plugin(app, config = {}) {
41
41
  app.get(`${prefix}/data/:table/:id?`, { config: { policy: ['public', 'no-sql'] }, schema: tableSchema }, data);
42
42
  app.get(`${prefix}/table-data/:table`, { config: { policy: ['user', 'no-sql'] }, schema: tableDataSchema }, data);
43
43
  app.get(`${prefix}/table-data/:table/:id`, { config: { policy }, schema: tableDataIdSchema }, cardData);
44
- app.get(`${prefix}/card-data/:token`, { config: { policy }, scheme: cardTabDataSchema }, cardTabData);
44
+
45
45
  app.get(`${prefix}/data-info/:id?`, { config: { policy: ['public', 'no-sql'] }, schema: tableSchema }, dataInfo);
46
46
 
47
+ app.get(`${prefix}/card-data/:token`, { config: { policy }, scheme: cardTabDataSchema }, cardTabData);
47
48
  app.get(`${prefix}/card/:table/:id`, { config: { policy }, schema: tableSchema }, card);
49
+
48
50
  app.get(`${prefix}/search`, { config: { policy }, schema: searchSchema }, search);
49
51
 
50
52
  app.get(`${prefix}/templates`, () => loadTemplatePath);
51
53
  app.get(`${prefix}/filter/:table`, { config: { policy }, schema: filterSchema }, filter);
52
- app.get(`${prefix}/form/:name`, { config: { policy: ['user', 'site'] }, schema: formSchema }, form);
54
+ app.get(`${prefix}/form/:name/:id?`, { config: { policy: ['user', 'site'] }, schema: formSchema }, form);
53
55
  }
54
56
 
55
57
  export default plugin;
@@ -86,6 +86,7 @@ const formSchema = {
86
86
  properties: {
87
87
  params: {
88
88
  name: { type: 'string', pattern: '^([\\d\\w_.-]+)$' },
89
+ id: { type: 'string', pattern: '^([\\d\\w_.-]+)$' },
89
90
  },
90
91
  },
91
92
  };