@opengis/fastify-table 2.6.1 → 2.6.2

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.
Files changed (91) hide show
  1. package/README.md +86 -86
  2. package/dist/functions.js +20 -20
  3. package/dist/helper.d.ts +1 -20
  4. package/dist/helper.d.ts.map +1 -1
  5. package/dist/module/core/cls/constraint_action.json +9 -9
  6. package/dist/module/core/cls/constraint_matchtype.json +5 -5
  7. package/dist/module/core/cls/constraint_type_full.json +17 -17
  8. package/dist/module/core/cls/core.user_type.json +13 -13
  9. package/dist/module/core/pt/schemaItem.pt.hbs +17 -17
  10. package/dist/module/core/select/core.user_mentioned.sql +1 -1
  11. package/dist/script/adduser +14 -14
  12. package/dist/script/dump.js +48 -48
  13. package/dist/script/dump.ts +216 -216
  14. package/dist/script/migrate.ts +23 -23
  15. package/dist/server/helpers/core/badge.js +1 -1
  16. package/dist/server/helpers/list/descriptionList.js +8 -8
  17. package/dist/server/helpers/list/tableList.js +4 -4
  18. package/dist/server/helpers/list/utils/button.js +1 -1
  19. package/dist/server/helpers/list/utils/buttonDel.js +3 -3
  20. package/dist/server/helpers/list/utils/buttonEdit.js +3 -3
  21. package/dist/server/helpers/utils/button.js +1 -1
  22. package/dist/server/helpers/utils/buttonAdd.js +15 -15
  23. package/dist/server/helpers/utils/buttonDel.js +11 -11
  24. package/dist/server/helpers/utils/buttonEdit.js +3 -3
  25. package/dist/server/migrations/0.sql +99 -99
  26. package/dist/server/migrations/1_users.sql +145 -145
  27. package/dist/server/migrations/cls.sql +105 -105
  28. package/dist/server/migrations/context.sql +136 -136
  29. package/dist/server/migrations/dictionaries.sql +78 -78
  30. package/dist/server/migrations/oauth.sql +79 -79
  31. package/dist/server/migrations/properties.sql +115 -115
  32. package/dist/server/migrations/roles.sql +201 -200
  33. package/dist/server/migrations/template.sql +43 -43
  34. package/dist/server/plugins/access/funcs/getUserPermissions.js +7 -7
  35. package/dist/server/plugins/auth/funcs/authorizeUser.js +4 -4
  36. package/dist/server/plugins/auth/funcs/getQuery.js +20 -20
  37. package/dist/server/plugins/crud/funcs/dataUpdate.js +7 -7
  38. package/dist/server/plugins/crud/funcs/getAccess.js +14 -14
  39. package/dist/server/plugins/crud/funcs/utils/getInsertQuery.js +6 -6
  40. package/dist/server/plugins/crud/funcs/utils/logChanges.js +18 -18
  41. package/dist/server/plugins/grpc/utils/convertp.proto +143 -143
  42. package/dist/server/plugins/grpc/utils/htmlTemplate.js +10 -10
  43. package/dist/server/plugins/grpc/utils/office2pdf.proto +13 -13
  44. package/dist/server/plugins/metric/loggerSystem.js +1 -1
  45. package/dist/server/plugins/pg/funcs/autoIndex.js +5 -5
  46. package/dist/server/plugins/pg/funcs/getMeta.js +15 -15
  47. package/dist/server/plugins/pg/funcs/init.js +36 -36
  48. package/dist/server/plugins/sqlite/funcs/init.js +22 -22
  49. package/dist/server/plugins/table/funcs/getData.js +13 -13
  50. package/dist/server/plugins/table/funcs/getFilterSQL/util/getCustomQuery.js +1 -1
  51. package/dist/server/plugins/table/funcs/getSelect.js +1 -1
  52. package/dist/server/plugins/table/funcs/gisIRColumn.js +3 -3
  53. package/dist/server/plugins/usercls/index.js +2 -2
  54. package/dist/server/routes/access/controllers/access.group.js +6 -6
  55. package/dist/server/routes/access/controllers/access.group.post.js +3 -3
  56. package/dist/server/routes/access/controllers/access.interface.js +14 -14
  57. package/dist/server/routes/access/controllers/access.user.js +6 -6
  58. package/dist/server/routes/auth/controllers/2factor/providers/totp.js +5 -5
  59. package/dist/server/routes/auth/controllers/2factor/qrcode.js +1 -1
  60. package/dist/server/routes/auth/controllers/2factor/recovery.js +1 -1
  61. package/dist/server/routes/auth/controllers/2factor/verify.js +1 -1
  62. package/dist/server/routes/auth/controllers/core/getUserInfo.js +33 -33
  63. package/dist/server/routes/auth/controllers/core/passwordRecovery.js +1 -1
  64. package/dist/server/routes/auth/controllers/core/registration.js +2 -2
  65. package/dist/server/routes/auth/controllers/page/login2faTemplate.js +1 -1
  66. package/dist/server/routes/crud/functions/deleteTableRelation.js +9 -9
  67. package/dist/server/routes/crud/functions/updateTableRelation.js +9 -9
  68. package/dist/server/routes/file/controllers/resizeAll.js +7 -7
  69. package/dist/server/routes/grpc/controllers/file2geojson.js +13 -13
  70. package/dist/server/routes/menu/controllers/getMenu.js +9 -9
  71. package/dist/server/routes/notifications/controllers/readNotifications.js +4 -4
  72. package/dist/server/routes/notifications/controllers/userNotifications.js +3 -3
  73. package/dist/server/routes/table/controllers/card.js +1 -1
  74. package/dist/server/routes/table/controllers/filter.js +6 -6
  75. package/dist/server/routes/table/controllers/form.js +1 -1
  76. package/dist/server/routes/table/controllers/getFormByTable.js +6 -6
  77. package/dist/server/routes/table/controllers/suggest.js +10 -10
  78. package/dist/server/routes/table/controllers/tableData.js +2 -2
  79. package/dist/server/routes/table/controllers/tableInfo.js +10 -10
  80. package/dist/server/routes/table/functions/getData.js +13 -13
  81. package/dist/server/routes/widget/controllers/widget.get.js +33 -33
  82. package/dist/server/routes/widget/controllers/widget.set.js +4 -4
  83. package/dist/server/routes/widget/services/widget.entity.get.js +33 -33
  84. package/dist/server/routes/widget/services/widget.entity.set.js +4 -4
  85. package/dist/server/templates/page/2factor-recovery.html +101 -101
  86. package/dist/server/templates/page/2factor.html +140 -140
  87. package/dist/server/templates/page/login.html +90 -90
  88. package/dist/server/templates/pt/recovery-codes-email-template.hbs +12 -12
  89. package/dist/server/templates/pt/recovery-password-email-template.html +20 -20
  90. package/package.json +99 -99
  91. package/dist/module/core/select/core.user_mentioned.json +0 -3
package/README.md CHANGED
@@ -1,87 +1,87 @@
1
- # fastify-table
2
-
3
- <!-- ![alt text](https://cdn.softpro.ua/data/npm/admin/opengis-admin.png) -->
4
-
5
- [![NPM version](https://img.shields.io/npm/v/@opengis/fastify-table?style=plain)](https://www.npmjs.com/package/@opengis/fastify-table)
6
- [![NPM last update](https://img.shields.io/npm/last-update/@opengis/fastify-table?style=plain)]()
7
- [![NPM downloads](https://img.shields.io/npm/dw/@opengis/fastify-table?style=plain)]()
8
- [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=plain)](http://standardjs.com/)
9
-
10
- This is a backend toolkit for database management and more.
11
-
12
- ### Why fastify-table?
13
-
14
- - **Logger** - Monitoring user activity and system status.
15
- - **Redis cache** - Optimizes web page rendering for lightning-fast performance.
16
- - **Secure** - Ensures protection against XSS attacks in queries.
17
- - **SQL Migration** - Automatically adds all necessary tables to your project's database.
18
-
19
-
20
- ### Features
21
-
22
- - CRUD
23
- - cron
24
- - Logger
25
- - Redis
26
- - pg
27
-
28
- ---
29
-
30
- ### Install
31
-
32
- ```bash
33
- npm i @opengis/fastify-table
34
- ```
35
-
36
- ### Usage
37
-
38
- ```js
39
- fastify.register(import('@opengis/fastify-table'), config);
40
- ```
41
-
42
- ---
43
-
44
- ### Documenation
45
-
46
- For a detailed understanding `fastify-table`, its features, and how to use them, refer to our [Documentation](https://apidocs.softpro.ua/fastify-table/).
47
-
48
- ---
49
-
50
- ### Technology stack
51
-
52
- <a href="https://fastify.dev/" target="_blank">
53
- <img src="https://img.shields.io/badge/Fastify-323330?style=for-the-badge&logo=fastify" /></a>
54
-
55
- <a href="https://www.postgresql.org/" target="_blank">
56
- <img src="https://img.shields.io/badge/PostgreSQL-323330?style=for-the-badge&logo=postgresql&logoColor=white" /></a>
57
-
58
- <a href="https://redis.io/" target="_blank">
59
- <img src="https://img.shields.io/badge/redis-323330.svg?&style=for-the-badge&logo=redis&logoColor=" /></a>
60
-
61
- <a href="https://www.npmjs.com/package/pino" target="_blank">
62
- <img src="https://img.shields.io/badge/pino-323330.svg?&style=for-the-badge&logo=pino&logoColor=" /></a>
63
-
64
- ---
65
-
66
- ### Contribute
67
-
68
- Feel free to contact us through our website [SOFTPRO.UA](https://softpro.ua) or email <info@softpro.ua>
69
-
70
- - Report bugs
71
- - Share your ideas
72
- - Ask questions
73
-
74
- ### Follow Us
75
-
76
- [Official site](https://softpro.ua)
77
-
78
- <p>
79
- <a href="https://www.instagram.com/gissoftpro/" target="_blank"><img src="https://cdn.softpro.ua/data/npm/instagram.png" alt="Softpro Instagram" title="oftpro Instagram"></a>&nbsp;&nbsp;
80
- <a href="https://www.facebook.com/gissoftpro" target="_blank"><img src="https://cdn.softpro.ua/data/npm/facebook.png" alt="Softpro Facebook" title="Softpro Facebook"></a>&nbsp;&nbsp;
81
- <a href="https://t.me/softprogis" target="_blank"><img src="https://cdn.softpro.ua/data/npm/telegram.png" alt="Softpro Telegram" title="Softpro Telegram"></a>&nbsp;&nbsp;
82
- <a href="https://www.linkedin.com/in/softpro-ukraine-a8876b282/recent-activity/all/" target="_blank"><img src="https://cdn.softpro.ua/data/npm/social/linkedin.png" alt="Softpro Linkedin" title="Softpro LinkedIn"></a>&nbsp;&nbsp;
83
- </p>
84
-
85
- ### License
86
-
1
+ # fastify-table
2
+
3
+ <!-- ![alt text](https://cdn.softpro.ua/data/npm/admin/opengis-admin.png) -->
4
+
5
+ [![NPM version](https://img.shields.io/npm/v/@opengis/fastify-table?style=plain)](https://www.npmjs.com/package/@opengis/fastify-table)
6
+ [![NPM last update](https://img.shields.io/npm/last-update/@opengis/fastify-table?style=plain)]()
7
+ [![NPM downloads](https://img.shields.io/npm/dw/@opengis/fastify-table?style=plain)]()
8
+ [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=plain)](http://standardjs.com/)
9
+
10
+ This is a backend toolkit for database management and more.
11
+
12
+ ### Why fastify-table?
13
+
14
+ - **Logger** - Monitoring user activity and system status.
15
+ - **Redis cache** - Optimizes web page rendering for lightning-fast performance.
16
+ - **Secure** - Ensures protection against XSS attacks in queries.
17
+ - **SQL Migration** - Automatically adds all necessary tables to your project's database.
18
+
19
+
20
+ ### Features
21
+
22
+ - CRUD
23
+ - cron
24
+ - Logger
25
+ - Redis
26
+ - pg
27
+
28
+ ---
29
+
30
+ ### Install
31
+
32
+ ```bash
33
+ npm i @opengis/fastify-table
34
+ ```
35
+
36
+ ### Usage
37
+
38
+ ```js
39
+ fastify.register(import('@opengis/fastify-table'), config);
40
+ ```
41
+
42
+ ---
43
+
44
+ ### Documenation
45
+
46
+ For a detailed understanding `fastify-table`, its features, and how to use them, refer to our [Documentation](https://apidocs.softpro.ua/fastify-table/).
47
+
48
+ ---
49
+
50
+ ### Technology stack
51
+
52
+ <a href="https://fastify.dev/" target="_blank">
53
+ <img src="https://img.shields.io/badge/Fastify-323330?style=for-the-badge&logo=fastify" /></a>
54
+
55
+ <a href="https://www.postgresql.org/" target="_blank">
56
+ <img src="https://img.shields.io/badge/PostgreSQL-323330?style=for-the-badge&logo=postgresql&logoColor=white" /></a>
57
+
58
+ <a href="https://redis.io/" target="_blank">
59
+ <img src="https://img.shields.io/badge/redis-323330.svg?&style=for-the-badge&logo=redis&logoColor=" /></a>
60
+
61
+ <a href="https://www.npmjs.com/package/pino" target="_blank">
62
+ <img src="https://img.shields.io/badge/pino-323330.svg?&style=for-the-badge&logo=pino&logoColor=" /></a>
63
+
64
+ ---
65
+
66
+ ### Contribute
67
+
68
+ Feel free to contact us through our website [SOFTPRO.UA](https://softpro.ua) or email <info@softpro.ua>
69
+
70
+ - Report bugs
71
+ - Share your ideas
72
+ - Ask questions
73
+
74
+ ### Follow Us
75
+
76
+ [Official site](https://softpro.ua)
77
+
78
+ <p>
79
+ <a href="https://www.instagram.com/gissoftpro/" target="_blank"><img src="https://cdn.softpro.ua/data/npm/instagram.png" alt="Softpro Instagram" title="oftpro Instagram"></a>&nbsp;&nbsp;
80
+ <a href="https://www.facebook.com/gissoftpro" target="_blank"><img src="https://cdn.softpro.ua/data/npm/facebook.png" alt="Softpro Facebook" title="Softpro Facebook"></a>&nbsp;&nbsp;
81
+ <a href="https://t.me/softprogis" target="_blank"><img src="https://cdn.softpro.ua/data/npm/telegram.png" alt="Softpro Telegram" title="Softpro Telegram"></a>&nbsp;&nbsp;
82
+ <a href="https://www.linkedin.com/in/softpro-ukraine-a8876b282/recent-activity/all/" target="_blank"><img src="https://cdn.softpro.ua/data/npm/social/linkedin.png" alt="Softpro Linkedin" title="Softpro LinkedIn"></a>&nbsp;&nbsp;
83
+ </p>
84
+
85
+ ### License
86
+
87
87
  Copyright © SOFTPRO. All rights reserved.
package/dist/functions.js CHANGED
@@ -34,7 +34,7 @@ export async function onListen1() {
34
34
  arr.map((item) => item?.ua).indexOf(el?.ua) === idx);
35
35
  const q = `insert into admin.menu(name, ord) values${uniqueList
36
36
  .map((el, i) => `('${el?.ua.replace(/'/g, "''")}', ${i}) `)
37
- .join(",")}
37
+ .join(",")}
38
38
  on conflict (name) do update set ord=excluded.ord, enabled=true returning name, menu_id`;
39
39
  const { rows = [] } = uniqueList.length ? await client.query(q) : {};
40
40
  const menus = rows.reduce((acc, curr) => Object.assign(acc, {
@@ -58,25 +58,25 @@ export async function onListen1() {
58
58
  });
59
59
  }));
60
60
  // console.log(values)
61
- const q1 = `insert into admin.routes(route_id, alias, title, menu_id, table_name, actions, access, query)
61
+ const q1 = `insert into admin.routes(route_id, alias, title, menu_id, table_name, actions, access, query)
62
62
  values ${values
63
63
  .filter((el) => el?.path)
64
- .map((el) => `('${el.path}', ${el.table ? `'${el.table}'` : null},
64
+ .map((el) => `('${el.path}', ${el.table ? `'${el.table}'` : null},
65
65
  ${el.title || el.ua
66
66
  ? `'${(el.title || el.ua).replace(/'/g, "''")}'`
67
- : null},
68
- ${el.menuId ? `'${el.menuId}'` : null}, ${el.table1 ? `'${el.table1}'` : null},
69
- ${el.actions?.length ? `'{ ${el.actions} }'::text[]` : null}, ${el.access ? `'${el.access}'` : null},
67
+ : null},
68
+ ${el.menuId ? `'${el.menuId}'` : null}, ${el.table1 ? `'${el.table1}'` : null},
69
+ ${el.actions?.length ? `'{ ${el.actions} }'::text[]` : null}, ${el.access ? `'${el.access}'` : null},
70
70
  ${el.query ? `'${el.query.replace(/'/g, "''")}'` : "'1=1'"})`)
71
- .join(",")}
72
- on conflict (route_id) do update set menu_id=excluded.menu_id, alias=excluded.alias, title=excluded.title, enabled=true, query=excluded.query,
71
+ .join(",")}
72
+ on conflict (route_id) do update set menu_id=excluded.menu_id, alias=excluded.alias, title=excluded.title, enabled=true, query=excluded.query,
73
73
  table_name=excluded.table_name, actions=excluded.actions, access=excluded.access returning route_id, table_name`;
74
74
  try {
75
75
  console.log("admin/hook routes sql start");
76
- const { rowCount: menuCount } = await client.query(`delete from admin.menu
76
+ const { rowCount: menuCount } = await client.query(`delete from admin.menu
77
77
  where not array[menu_id] <@ $1::text[] and menu_id not in (select menu_id from admin.routes)`, [rows.map((el) => el.menu_id)]);
78
78
  console.log("delete deprecated menus ok", menuCount);
79
- const { rowCount: interfaceCount } = await client.query(`delete from admin.routes
79
+ const { rowCount: interfaceCount } = await client.query(`delete from admin.routes
80
80
  where not array[route_id] <@ $1::text[] and route_id not in (select route_id from admin.role_access)`, [values.filter((el) => el?.path)]);
81
81
  console.log("delete deprecated interfaces ok", interfaceCount);
82
82
  const { rowCount } = values?.length ? await client.query(q1) : {};
@@ -140,9 +140,9 @@ export async function onListen2() {
140
140
  return el.hash;
141
141
  }
142
142
  else if (type === "cls" && loadTemplate?.length && el.update) {
143
- clsQuery.push(`insert into admin.cls(name,type, module,hash) values('${name}','json', '${module?.replace(/'/g, "''")}','${el.hash}');
144
- insert into admin.cls(code,name,parent,icon,color,data,en,ua)
145
- select value->>'id',value->>'text','${name}',value->>'icon',value->>'color',value->>'data',value->>'en',value->>'ua'
143
+ clsQuery.push(`insert into admin.cls(name,type, module,hash) values('${name}','json', '${module?.replace(/'/g, "''")}','${el.hash}');
144
+ insert into admin.cls(code,name,parent,icon,color,data,en,ua)
145
+ select value->>'id',value->>'text','${name}',value->>'icon',value->>'color',value->>'data',value->>'en',value->>'ua'
146
146
  from json_array_elements('${JSON.stringify(loadTemplate).replace(/'/g, "''")}'::json) on conflict (code,parent) do update set color=excluded.color, name=excluded.name, ua=excluded.ua, en=excluded.en;`);
147
147
  if (config.trace)
148
148
  console.log(name, type, "insert fresh cls");
@@ -348,7 +348,7 @@ export async function afterTable({ table, res = {}, payload: rows = [], user = {
348
348
  !client?.pk?.["admin.custom_column"])
349
349
  return;
350
350
  // admin.custom_column - user column data
351
- const { rows: properties = [] } = await client.query(`select column_id, name, title, format, data from admin.custom_column
351
+ const { rows: properties = [] } = await client.query(`select column_id, name, title, format, data from admin.custom_column
352
352
  where _table and entity=$1 and uid=$2`, [table, uid]);
353
353
  const extraColumnList = properties.map((row) => ({
354
354
  id: row.column_id,
@@ -362,7 +362,7 @@ export async function afterTable({ table, res = {}, payload: rows = [], user = {
362
362
  if (Array.isArray(res?.columns) && res?.columns?.length) {
363
363
  extraColumnList.forEach((col) => res.columns.push(col));
364
364
  }
365
- const { rows: extraData = [] } = await client.query(`select object_id, json_object_agg( property_id, coalesce(value_date::text,value_text) ) as extra from crm.extra_data
365
+ const { rows: extraData = [] } = await client.query(`select object_id, json_object_agg( property_id, coalesce(value_date::text,value_text) ) as extra from crm.extra_data
366
366
  where property_entity=$1 and property_id=any($2) and object_id=any($3) group by object_id`, [
367
367
  table,
368
368
  extraColumnList?.map((el) => el.id),
@@ -434,7 +434,7 @@ export async function afterTemplate({ name, type, payload: data = {}, user = {},
434
434
  json: 1,
435
435
  })) ||
436
436
  {}; // add?
437
- const { rows: properties = [] } = await client.query(`select name, title, format, data from admin.custom_column
437
+ const { rows: properties = [] } = await client.query(`select name, title, format, data from admin.custom_column
438
438
  where entity=$1 and uid=$2`, [table || name, uid]);
439
439
  await Promise.all(properties.map(async (el) => {
440
440
  const clsData = el.data
@@ -471,13 +471,13 @@ export async function afterUpdate({ table, body = {}, payload: res = {}, user =
471
471
  return null;
472
472
  const pk = client?.pk?.[loadTable?.table || table];
473
473
  const id = res[pk];
474
- const { rows: properties = [] } = await client.query(`select column_id, name, title, format, data from admin.custom_column
474
+ const { rows: properties = [] } = await client.query(`select column_id, name, title, format, data from admin.custom_column
475
475
  where entity=$1 and uid=$2`, [table, uid]);
476
476
  if (!id || !properties?.length || !client.pk?.["crm.extra_data"])
477
477
  return null;
478
478
  const q = `delete from crm.extra_data where property_entity='${table}' and object_id='${id}';${properties
479
479
  .filter((el) => Object.keys(body).includes(el.name))
480
- .map((el) => `insert into crm.extra_data(property_id,property_key,property_entity,object_id,${el.format?.toLowerCase() === "date" ? "value_date" : "value_text"})
480
+ .map((el) => `insert into crm.extra_data(property_id,property_key,property_entity,object_id,${el.format?.toLowerCase() === "date" ? "value_date" : "value_text"})
481
481
  select '${el.column_id}', '${el.name}', '${table}', '${id}', ${el.format?.toLowerCase() === "date"
482
482
  ? `'${body[el.name]}'::timestamp without time zone`
483
483
  : `'${body[el.name]}'::text`}`)
@@ -499,13 +499,13 @@ export async function afterInsert({ table, body, payload: res = {}, user = {}, }
499
499
  return null;
500
500
  const pk = client?.pk?.[loadTable?.table || table];
501
501
  const id = res.rows?.[0]?.[pk];
502
- const { rows: properties = [] } = await client.query(`select column_id, name, title, format, data from admin.custom_column
502
+ const { rows: properties = [] } = await client.query(`select column_id, name, title, format, data from admin.custom_column
503
503
  where entity=$1 and uid=$2`, [table, uid]);
504
504
  if (!id || !properties?.length)
505
505
  return null;
506
506
  const q = properties
507
507
  .filter((el) => Object.keys(body).includes(el.name))
508
- .map((el) => `insert into crm.extra_data(property_id,property_key,property_entity,object_id,${el.format?.toLowerCase() === "date" ? "value_date" : "value_text"})
508
+ .map((el) => `insert into crm.extra_data(property_id,property_key,property_entity,object_id,${el.format?.toLowerCase() === "date" ? "value_date" : "value_text"})
509
509
  select '${el.column_id}', '${el.name}', '${table}', '${id}', ${el.format?.toLowerCase() === "date"
510
510
  ? `'${body[el.name]}'::timestamp without time zone`
511
511
  : `'${body[el.name]}'::text`}`)
package/dist/helper.d.ts CHANGED
@@ -1,26 +1,7 @@
1
1
  import config from "./config.js";
2
2
  import { pgClients } from "./utils.js";
3
3
  declare const prefix: any;
4
- export declare function injectWithHeaders(opts: any): Promise<{
5
- json: () => unknown;
6
- body: unknown;
7
- headers: {
8
- [k: string]: string;
9
- };
10
- statusCode: number;
11
- ok: boolean;
12
- status: number;
13
- statusText: string;
14
- type: import("undici-types").ResponseType;
15
- url: string;
16
- redirected: boolean;
17
- bodyUsed: boolean;
18
- arrayBuffer: () => Promise<ArrayBuffer>;
19
- blob: () => Promise<import("node:buffer").Blob>;
20
- bytes: () => Promise<Uint8Array>;
21
- formData: () => Promise<import("undici-types").FormData>;
22
- text: () => Promise<string>;
23
- }>;
4
+ export declare function injectWithHeaders(opts: any): Promise<any>;
24
5
  export declare function setup(): Promise<void>;
25
6
  export declare function teardown(): Promise<void>;
26
7
  export declare function build(): Promise<any>;
@@ -1 +1 @@
1
- {"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../helper.ts"],"names":[],"mappings":"AAEA,OAAO,MAAM,MAAM,aAAa,CAAC;AAGjC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,QAAA,MAAQ,MAAM,KAAoB,CAAC;AAInC,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,GAAG;;;;;;;;;;;;;;;;;;;GAiChD;AAED,wBAAsB,KAAK,kBAI1B;AAGD,wBAAsB,QAAQ,kBAW7B;AAED,wBAAsB,KAAK,iBA+B1B;AAED,OAAO,EAEL,MAAM,EACN,MAAM,EACN,SAAS,GACV,CAAC"}
1
+ {"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../helper.ts"],"names":[],"mappings":"AAEA,OAAO,MAAM,MAAM,aAAa,CAAC;AAGjC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,QAAA,MAAQ,MAAM,KAAoB,CAAC;AAInC,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAiC/D;AAED,wBAAsB,KAAK,kBAI1B;AAGD,wBAAsB,QAAQ,kBAW7B;AAED,wBAAsB,KAAK,iBA+B1B;AAED,OAAO,EAEL,MAAM,EACN,MAAM,EACN,SAAS,GACV,CAAC"}
@@ -1,10 +1,10 @@
1
- [
2
- {
3
- "id": "a",
4
- "text": "NO ACTION"
5
- },
6
- {
7
- "id": "c",
8
- "text": "CASCADE"
9
- }
1
+ [
2
+ {
3
+ "id": "a",
4
+ "text": "NO ACTION"
5
+ },
6
+ {
7
+ "id": "c",
8
+ "text": "CASCADE"
9
+ }
10
10
  ]
@@ -1,6 +1,6 @@
1
- [
2
- {
3
- "id": "s",
4
- "text": "SIMPLE"
5
- }
1
+ [
2
+ {
3
+ "id": "s",
4
+ "text": "SIMPLE"
5
+ }
6
6
  ]
@@ -1,18 +1,18 @@
1
- [
2
- {
3
- "id": "u",
4
- "text": "UNIQUE"
5
- },
6
- {
7
- "id": "p",
8
- "text": "PRIMARY KEY"
9
- },
10
- {
11
- "id": "f",
12
- "text": "FOREIGN KEY"
13
- },
14
- {
15
- "id": "c",
16
- "text": "CHECK"
17
- }
1
+ [
2
+ {
3
+ "id": "u",
4
+ "text": "UNIQUE"
5
+ },
6
+ {
7
+ "id": "p",
8
+ "text": "PRIMARY KEY"
9
+ },
10
+ {
11
+ "id": "f",
12
+ "text": "FOREIGN KEY"
13
+ },
14
+ {
15
+ "id": "c",
16
+ "text": "CHECK"
17
+ }
18
18
  ]
@@ -1,14 +1,14 @@
1
- [
2
- {
3
- "id": "regular",
4
- "text": "Regular"
5
- },
6
- {
7
- "id": "viewer",
8
- "text": "Viewer"
9
- },
10
- {
11
- "id": "admin",
12
- "text": "Admin"
13
- }
1
+ [
2
+ {
3
+ "id": "regular",
4
+ "text": "Regular"
5
+ },
6
+ {
7
+ "id": "viewer",
8
+ "text": "Viewer"
9
+ },
10
+ {
11
+ "id": "admin",
12
+ "text": "Admin"
13
+ }
14
14
  ]
@@ -1,18 +1,18 @@
1
- -- schema: {{nspname}}
2
-
3
- CREATE schema if not exists {{nspname}};
4
-
5
- {{#each rows}}
6
- -- {{{description}}}
7
-
8
- CREATE TABLE if not exists {{nspname}}.{{relname}}
9
- (
10
- {{#each columns}}
11
- {{column_name}} {{data_type}} {{#unless is_nullable}}NOT NULL{{/unless}}{{#if column_default}}DEFAULT {{column_default}}{{/if}}{{#ifCond @index '!=' (_math ../columns.length '-' 1)}},{{/ifCond}} -- {{{coalesce description '-'}}}
12
- {{/each}}{{#if constraints.length}},{{/if}}
13
- {{#each constraints}}
14
- CONSTRAINT {{constraint_name}} {{#ifCond constraint_type '==' 'c'}} {{check_definition}} {{/ifCond}} {{#ifCond constraint_type '==' 'f'}}FOREIGN KEY ({{foreign_column}}) REFERENCES {{foreign_table}} ({{foreign_column}}) MATCH {{select confmatchtype data="constraint_matchtype"}} ON UPDATE {{select confupdtype data="constraint_action"}} ON DELETE {{select confdeltype data="constraint_action"}}{{^}}{{#ifCond constraint_type '!=' 'c'}}{{select constraint_type data="constraint_type_full"}} ({{column_name}}){{/ifCond}}{{/ifCond}}{{#ifCond @index '!=' (_math ../constraints.length '-' 1)}},{{/ifCond}}
15
- {{/each}}
16
- );
17
-
1
+ -- schema: {{nspname}}
2
+
3
+ CREATE schema if not exists {{nspname}};
4
+
5
+ {{#each rows}}
6
+ -- {{{description}}}
7
+
8
+ CREATE TABLE if not exists {{nspname}}.{{relname}}
9
+ (
10
+ {{#each columns}}
11
+ {{column_name}} {{data_type}} {{#unless is_nullable}}NOT NULL{{/unless}}{{#if column_default}}DEFAULT {{column_default}}{{/if}}{{#ifCond @index '!=' (_math ../columns.length '-' 1)}},{{/ifCond}} -- {{{coalesce description '-'}}}
12
+ {{/each}}{{#if constraints.length}},{{/if}}
13
+ {{#each constraints}}
14
+ CONSTRAINT {{constraint_name}} {{#ifCond constraint_type '==' 'c'}} {{check_definition}} {{/ifCond}} {{#ifCond constraint_type '==' 'f'}}FOREIGN KEY ({{foreign_column}}) REFERENCES {{foreign_table}} ({{foreign_column}}) MATCH {{select confmatchtype data="constraint_matchtype"}} ON UPDATE {{select confupdtype data="constraint_action"}} ON DELETE {{select confdeltype data="constraint_action"}}{{^}}{{#ifCond constraint_type '!=' 'c'}}{{select constraint_type data="constraint_type_full"}} ({{column_name}}){{/ifCond}}{{/ifCond}}{{#ifCond @index '!=' (_math ../constraints.length '-' 1)}},{{/ifCond}}
15
+ {{/each}}
16
+ );
17
+
18
18
  {{/each}}
@@ -1,2 +1,2 @@
1
- select uid, coalesce(sur_name,'')||coalesce(' '||user_name,'') as text, email from admin.users
1
+ select uid, coalesce(sur_name,'')||coalesce(' '||user_name,'') as text, email from admin.users
2
2
  where enabled order by coalesce(sur_name,'')||coalesce(' '||user_name,'')
@@ -1,15 +1,15 @@
1
- #!/bin/bash
2
- rootDir=`echo $(dirname "$0")`
3
- echo "$rootDir/passwd"
4
-
5
- if [ -e "$rootDir/../passwd" ]
6
- then
7
- password=`echo -n "$2" | sha1sum | awk '{print $1}'`
8
- echo "$1:$password"
9
- echo "$1:$password" >> "$rootDir/../passwd"
10
- else
11
- > passwd
12
- password=`echo -n "$2" | sha1sum | awk '{print $1}'`
13
- echo "$1:$password"
14
- echo "$1:$password" > "$rootDir/../passwd"
1
+ #!/bin/bash
2
+ rootDir=`echo $(dirname "$0")`
3
+ echo "$rootDir/passwd"
4
+
5
+ if [ -e "$rootDir/../passwd" ]
6
+ then
7
+ password=`echo -n "$2" | sha1sum | awk '{print $1}'`
8
+ echo "$1:$password"
9
+ echo "$1:$password" >> "$rootDir/../passwd"
10
+ else
11
+ > passwd
12
+ password=`echo -n "$2" | sha1sum | awk '{print $1}'`
13
+ echo "$1:$password"
14
+ echo "$1:$password" > "$rootDir/../passwd"
15
15
  fi
@@ -79,57 +79,57 @@ async function saveFile(data, filename) {
79
79
  async function schemaItem({ pg, table, schema, debug, }) {
80
80
  if (!schema && !table)
81
81
  return new Error("param schema is required");
82
- const { rows: schemaInfo } = await pg.query(`select c.oid,relname,nspname,obj_description(c.oid) as description,
83
- (
84
- select json_agg(row_to_json(q))
85
- from (
86
- select
87
- column_name,
88
- case
89
- when data_type='USER-DEFINED' AND udt_name='geometry' THEN 'geometry'
90
- when data_type='ARRAY' AND udt_name='_text' THEN 'text[]'
91
- when data_type='ARRAY' AND udt_name='_int4' THEN 'integer[]'
92
- else data_type
93
- end as data_type,
94
- ordinal_position,
95
- column_default,
96
- is_nullable,
97
- case
98
- when column_name='uid' then 'ідентифікатор автора запису в БД'
99
- when column_name='cdate' then 'Дата створення запису в БД'
100
- when column_name='editor_id' then 'Ідентифікатор автора, який останій вніс зміни в запис'
101
- when column_name='editor_date' then 'Час останії зміни в записі'
102
- when column_name='files' then 'Системна колонка'
103
- when column_name='doc_status' then 'Статус документа'
104
- when column_name='reg_status' then 'Статус реєстрації'
105
- when column_name='obj_version' then 'Версія запису'
106
- else col_description(a.attrelid,ordinal_position)
107
- end as description
108
- from information_schema.columns col
109
- LEFT JOIN pg_attribute a ON col.column_name=a.attname and c.oid = a.attrelid
110
- where col.table_schema=nspname and col.table_name=relname
111
- )q
112
- ) as columns
113
- from pg_class c
114
- LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
115
- where ${table ? `nspname||'.'||relname='${table}'` : `'${schema}'=nspname`} and relam=2
82
+ const { rows: schemaInfo } = await pg.query(`select c.oid,relname,nspname,obj_description(c.oid) as description,
83
+ (
84
+ select json_agg(row_to_json(q))
85
+ from (
86
+ select
87
+ column_name,
88
+ case
89
+ when data_type='USER-DEFINED' AND udt_name='geometry' THEN 'geometry'
90
+ when data_type='ARRAY' AND udt_name='_text' THEN 'text[]'
91
+ when data_type='ARRAY' AND udt_name='_int4' THEN 'integer[]'
92
+ else data_type
93
+ end as data_type,
94
+ ordinal_position,
95
+ column_default,
96
+ is_nullable,
97
+ case
98
+ when column_name='uid' then 'ідентифікатор автора запису в БД'
99
+ when column_name='cdate' then 'Дата створення запису в БД'
100
+ when column_name='editor_id' then 'Ідентифікатор автора, який останій вніс зміни в запис'
101
+ when column_name='editor_date' then 'Час останії зміни в записі'
102
+ when column_name='files' then 'Системна колонка'
103
+ when column_name='doc_status' then 'Статус документа'
104
+ when column_name='reg_status' then 'Статус реєстрації'
105
+ when column_name='obj_version' then 'Версія запису'
106
+ else col_description(a.attrelid,ordinal_position)
107
+ end as description
108
+ from information_schema.columns col
109
+ LEFT JOIN pg_attribute a ON col.column_name=a.attname and c.oid = a.attrelid
110
+ where col.table_schema=nspname and col.table_name=relname
111
+ )q
112
+ ) as columns
113
+ from pg_class c
114
+ LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
115
+ where ${table ? `nspname||'.'||relname='${table}'` : `'${schema}'=nspname`} and relam=2
116
116
  order by nspname,relname`);
117
117
  if (!schemaInfo?.length)
118
118
  throw new Error("invalid params");
119
- const { rows: constraints } = await pg.query(`select con.conrelid::regclass as constraint_table, a.column_name,
120
- con.conname as constraint_name,contype as constraint_type, con.confrelid::regclass as foreign_table,
121
- con.confupdtype, con.confdeltype, con.confmatchtype, u.column_name as foreign_column,
122
- case when contype='c' then pg_get_constraintdef(con.oid, true) else null end AS check_definition from pg_constraint con
123
- left join pg_class c ON c.oid = con.conrelid
124
- left join pg_namespace n ON n.oid = c.relnamespace
125
- left join lateral (
126
- select string_agg(a.attname,',') as column_name from pg_attribute a
127
- where con.conrelid = a.attrelid and a.attnum = any(con.conkey) limit 1
128
- )a on 1=1
129
- left join lateral (
130
- select column_name from information_schema.constraint_column_usage u
131
- where conname=u.constraint_name limit 1
132
- )u on 1=1
119
+ const { rows: constraints } = await pg.query(`select con.conrelid::regclass as constraint_table, a.column_name,
120
+ con.conname as constraint_name,contype as constraint_type, con.confrelid::regclass as foreign_table,
121
+ con.confupdtype, con.confdeltype, con.confmatchtype, u.column_name as foreign_column,
122
+ case when contype='c' then pg_get_constraintdef(con.oid, true) else null end AS check_definition from pg_constraint con
123
+ left join pg_class c ON c.oid = con.conrelid
124
+ left join pg_namespace n ON n.oid = c.relnamespace
125
+ left join lateral (
126
+ select string_agg(a.attname,',') as column_name from pg_attribute a
127
+ where con.conrelid = a.attrelid and a.attnum = any(con.conkey) limit 1
128
+ )a on 1=1
129
+ left join lateral (
130
+ select column_name from information_schema.constraint_column_usage u
131
+ where conname=u.constraint_name limit 1
132
+ )u on 1=1
133
133
  where ${table ? `conrelid::regclass::text = '${table}'` : `nspname = '${schema}'`}`);
134
134
  // add table constraints, mermaid
135
135
  schemaInfo?.forEach((row) => {