@opengis/fastify-table 1.4.49 → 1.4.51

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 (107) hide show
  1. package/package.json +1 -1
  2. package/server/helpers/core/buttonFilePreview.js +0 -1
  3. package/server/helpers/core/buttonHelper.js +6 -5
  4. package/server/helpers/format/formatAuto.js +2 -2
  5. package/server/helpers/format/formatDate.js +3 -3
  6. package/server/helpers/format/formatDigit.js +1 -1
  7. package/server/helpers/format/formatNum.js +9 -5
  8. package/server/helpers/format/formatNumber.js +6 -6
  9. package/server/helpers/format/formatRelative.js +2 -2
  10. package/server/helpers/format/formatUnit.js +1 -1
  11. package/server/helpers/format/num_format.js +1 -1
  12. package/server/helpers/format/set.js +3 -2
  13. package/server/helpers/funcs/_math.js +3 -3
  14. package/server/helpers/funcs/contentList.js +8 -5
  15. package/server/helpers/funcs/empty.js +1 -1
  16. package/server/helpers/funcs/ifCondAnd.js +2 -1
  17. package/server/helpers/funcs/ifCondOr.js +2 -2
  18. package/server/helpers/funcs/inc.js +1 -2
  19. package/server/helpers/funcs/json.js +2 -2
  20. package/server/helpers/funcs/qrcode.js +5 -3
  21. package/server/helpers/funcs/round.js +2 -2
  22. package/server/helpers/funcs/select.js +7 -11
  23. package/server/helpers/list/buttonHelper.js +6 -5
  24. package/server/helpers/list/utils/button.js +1 -3
  25. package/server/helpers/list/utils/buttonDel.js +2 -3
  26. package/server/helpers/list/utils/buttonEdit.js +2 -5
  27. package/server/helpers/string/concat.js +1 -1
  28. package/server/helpers/string/split.js +2 -2
  29. package/server/helpers/string/str_replace.js +11 -10
  30. package/server/helpers/string/substr.js +1 -1
  31. package/server/helpers/string/translit.js +1 -1
  32. package/server/helpers/string/utils/alphabet.js +1 -1
  33. package/server/helpers/utils/button.js +1 -3
  34. package/server/helpers/utils/buttonAdd.js +2 -4
  35. package/server/helpers/utils/buttonDel.js +4 -4
  36. package/server/helpers/utils/buttonDownload.js +1 -1
  37. package/server/helpers/utils/buttonEdit.js +2 -4
  38. package/server/helpers/utils/buttonPreview.js +1 -1
  39. package/server/helpers/utils/mdToHTML.js +2 -2
  40. package/server/helpers/utils/paddingNumber.js +2 -2
  41. package/server/plugins/cron/funcs/interval2ms.js +1 -1
  42. package/server/plugins/cron/index.js +2 -1
  43. package/server/plugins/crud/funcs/dataInsert.js +1 -0
  44. package/server/plugins/crud/funcs/utils/logChanges.js +1 -1
  45. package/server/plugins/crud/funcs/validateData.js +1 -0
  46. package/server/plugins/crud/index.js +1 -1
  47. package/server/plugins/file/uploadMultiPart.js +1 -0
  48. package/server/plugins/grpc/grpc.js +3 -0
  49. package/server/plugins/grpc/office2pdf.js +2 -0
  50. package/server/plugins/hook/funcs/applyHook.js +1 -0
  51. package/server/plugins/hook/index.js +5 -5
  52. package/server/plugins/logger/createFileStream.js +3 -1
  53. package/server/plugins/logger/getLogger.js +2 -0
  54. package/server/plugins/logger/serializers.js +5 -5
  55. package/server/plugins/logger/timestampWithTimeZone.js +1 -1
  56. package/server/plugins/md/funcs/formatMdoc.js +7 -7
  57. package/server/plugins/md/funcs/mdToHTML.js +2 -2
  58. package/server/plugins/metric/index.js +1 -1
  59. package/server/plugins/migration/exec.migrations.js +1 -1
  60. package/server/plugins/migration/exec.sql.js +1 -0
  61. package/server/plugins/migration/index.js +3 -3
  62. package/server/plugins/pg/funcs/autoIndex.js +1 -0
  63. package/server/plugins/pg/funcs/getDBParams.js +4 -2
  64. package/server/plugins/pg/funcs/init.js +1 -0
  65. package/server/plugins/policy/index.js +2 -3
  66. package/server/plugins/redis/funcs/getRedis.js +1 -0
  67. package/server/plugins/redis/index.js +1 -1
  68. package/server/plugins/sqlite/funcs/getSqlite.js +2 -0
  69. package/server/plugins/sqlite/funcs/init.js +2 -0
  70. package/server/plugins/sqlite/index.js +1 -1
  71. package/server/plugins/sqlite/sqliteClients.js +2 -0
  72. package/server/plugins/table/funcs/addTemplateDir.js +1 -0
  73. package/server/plugins/table/funcs/customTokens.js +1 -1
  74. package/server/plugins/table/funcs/getFilterSQL/index.js +2 -2
  75. package/server/plugins/table/funcs/getFilterSQL/util/formatValue.js +1 -1
  76. package/server/plugins/table/funcs/getFilterSQL/util/getOptimizedQuery.js +3 -1
  77. package/server/plugins/table/funcs/getFilterSQL/util/getRangeQuery.js +7 -7
  78. package/server/plugins/table/funcs/getSelect.js +3 -3
  79. package/server/plugins/table/funcs/getSelectMeta.js +4 -1
  80. package/server/plugins/table/funcs/getTemplate.js +4 -4
  81. package/server/plugins/table/funcs/getTemplatePath.js +4 -3
  82. package/server/plugins/table/funcs/getTemplateSync.js +1 -1
  83. package/server/plugins/table/funcs/metaFormat/getSelectVal.js +1 -1
  84. package/server/plugins/table/funcs/metaFormat/index.js +2 -4
  85. package/server/plugins/table/funcs/userTokens.js +1 -1
  86. package/server/plugins/table/index.js +1 -1
  87. package/server/plugins/util/funcs/eventStream.js +1 -0
  88. package/server/plugins/util/funcs/flattenObject.js +5 -4
  89. package/server/plugins/util/funcs/unflattenObject.js +13 -3
  90. package/server/plugins/util/index.js +3 -3
  91. package/server/plugins/yml/funcs/json2yml.js +2 -2
  92. package/server/plugins/yml/funcs/yml2json.js +5 -4
  93. package/server/routes/crud/controllers/update.js +1 -1
  94. package/server/routes/dblist/index.mjs +1 -1
  95. package/server/routes/file/controllers/export.js +1 -0
  96. package/server/routes/file/controllers/resize.js +1 -0
  97. package/server/routes/file/controllers/resizeAll.js +1 -0
  98. package/server/routes/logger/controllers/logger.test.api.js +1 -0
  99. package/server/routes/logger/controllers/utils/getRootDir.js +1 -0
  100. package/server/routes/table/controllers/dataInfo.js +11 -9
  101. package/server/routes/table/controllers/filter.js +4 -6
  102. package/server/routes/table/controllers/tableInfo.js +1 -1
  103. package/server/routes/table/controllers/utils/conditions.js +3 -3
  104. package/server/routes/table/controllers/utils/locales.js +1 -1
  105. package/server/routes/table/functions/getData.js +9 -6
  106. package/server/routes/util/controllers/status.monitor.js +1 -1
  107. package/server/plugins/migration/get.caller.dir.js +0 -26
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/fastify-table",
3
- "version": "1.4.49",
3
+ "version": "1.4.51",
4
4
  "type": "module",
5
5
  "description": "core-plugins",
6
6
  "keywords": [
@@ -1,4 +1,3 @@
1
-
2
1
  import buttonPreview from '../utils/buttonPreview.js';
3
2
  import buttonDownload from '../utils/buttonDownload.js';
4
3
 
@@ -1,13 +1,14 @@
1
- import buttonAdd from "../utils/buttonAdd.js";
2
- import buttonDel from "../utils/buttonDel.js";
3
- import buttonEdit from "../utils/buttonEdit.js";
4
- import button from "../utils/button.js";
1
+ import buttonAdd from '../utils/buttonAdd.js';
2
+ import buttonDel from '../utils/buttonDel.js';
3
+ import buttonEdit from '../utils/buttonEdit.js';
4
+ import button from '../utils/button.js';
5
+
5
6
  export default function buttonHelper(data, opt) {
6
7
  const { hash } = opt;
7
8
 
8
9
  // console.log(params)
9
10
 
10
- if (!hash.token) return "token empty";
11
+ if (!hash.token) return 'token empty';
11
12
  if (hash.add) {
12
13
  return buttonAdd(hash.token, hash.title);
13
14
  }
@@ -1,4 +1,4 @@
1
- import formatDate from './formatDate.js'
1
+ import formatDate from './formatDate.js';
2
2
 
3
3
  export default function formatAuto(data, options = {}) {
4
4
  const format = options.hash?.format || 'text';
@@ -10,4 +10,4 @@ export default function formatAuto(data, options = {}) {
10
10
 
11
11
  if (typeof data === 'object') { return null; }
12
12
  return data;
13
- };
13
+ }
@@ -147,7 +147,6 @@ const mth = {
147
147
  * @returns {String} Returns HTML
148
148
  */
149
149
  export default function formatDate(data, options = {}) {
150
-
151
150
  if (typeof data === 'object' && data === null) return '';
152
151
  if (typeof data === 'undefined') return '';
153
152
 
@@ -185,7 +184,8 @@ export default function formatDate(data, options = {}) {
185
184
 
186
185
  try {
187
186
  val = val === 0 || val === '0' ? new Date() : new Date(val);
188
- } catch (e) {
187
+ }
188
+ catch (e) {
189
189
  return val;
190
190
  }
191
191
  if (options.hash.trunc) {
@@ -255,4 +255,4 @@ export default function formatDate(data, options = {}) {
255
255
  wd_ua: weekDayUa[val.getDay()],
256
256
  };
257
257
  return Object.keys(opt1).reduce((prev, el) => prev.replace(el, opt1[el]), options.hash.format || 'dd.mm.yy');
258
- };
258
+ }
@@ -18,4 +18,4 @@ export default function formatDigit(data, options) {
18
18
  const { rank = 4 } = options.hash;
19
19
  if (!data || (dataType !== 'number' && dataType !== 'string')) return '';
20
20
  return String(data).padStart(+rank, '0');
21
- };
21
+ }
@@ -223,12 +223,14 @@ function from0To999(arrRet, fValue, oObjDesc, lang) {
223
223
  if (fValueNew === 0) {
224
224
  arrRet.push(value(fValueNew, oObjDesc._Gender, lang));
225
225
  nCurrState = mapNumbers[lang][fValueNew][0];
226
- } else if (fValueNew < 20) {
226
+ }
227
+ else if (fValueNew < 20) {
227
228
  if (Math.floor(fValueNew) > 0 || oObjDesc._bAddZeroWord) {
228
229
  arrRet.push(value(fValueNew, oObjDesc._Gender, lang));
229
230
  nCurrState = mapNumbers[lang][fValueNew][0];
230
231
  }
231
- } else {
232
+ }
233
+ else {
232
234
  const fCurr = Math.floor(fValueNew / 10) * 10;
233
235
  arrRet.push(value(fCurr, oObjDesc._Gender, lang));
234
236
  nCurrState = mapNumbers[lang][fCurr][0];
@@ -287,7 +289,8 @@ function floatToSamplesInWordsUkr(fAmount, resultStr, exp, lang, currency) {
287
289
  /%d/,
288
290
  Math.floor(parseInt(fAmount, 10) + 0.005),
289
291
  );
290
- if (currency !== 'num' && objCur._arrStates[currency]) { resultStrNew = resultStrNew.replace(/%curr/, objCur._arrStates[currency][0]); } else {
292
+ if (currency !== 'num' && objCur._arrStates[currency]) { resultStrNew = resultStrNew.replace(/%curr/, objCur._arrStates[currency][0]); }
293
+ else {
291
294
  resultStrNew = resultStrNew.replace(
292
295
  /%curr/,
293
296
  objCur._arrStates[lang === 'ru' ? 'rur' : lang][0],
@@ -306,7 +309,8 @@ function floatToSamplesInWordsUkr(fAmount, resultStr, exp, lang, currency) {
306
309
 
307
310
  resultStrNew = resultStrNew.replace(/%f/, fDec);
308
311
 
309
- if (currency !== 'num' && objCur._arrStates[currency]) { resultStrNew = resultStrNew.replace(/%coin/, objCoin._arrStates[currency]); } else {
312
+ if (currency !== 'num' && objCur._arrStates[currency]) { resultStrNew = resultStrNew.replace(/%coin/, objCoin._arrStates[currency]); }
313
+ else {
310
314
  resultStrNew = resultStrNew.replace(
311
315
  /%coin/,
312
316
  objCoin._arrStates[lang === 'ru' ? 'rur' : lang],
@@ -358,4 +362,4 @@ export default function formatNum(data, options = {}) {
358
362
  const resultStr = opt.format || '%d (%dt) %curr %f (%ft) %coin';
359
363
 
360
364
  return floatToSamplesInWordsUkr(name, resultStr, exp, lang, currency);
361
- };
365
+ }
@@ -42,12 +42,12 @@ export default function formatNumber(data, options) {
42
42
  const notation = options.hash?.notation ?? 'standard';
43
43
 
44
44
  const formatter = new Intl.NumberFormat(locale, {
45
- style: style,
46
- currency: currency,
47
- unit: unit,
48
- unitDisplay: unitDisplay,
49
- notation: notation,
50
- maximumFractionDigits: round
45
+ style,
46
+ currency,
47
+ unit,
48
+ unitDisplay,
49
+ notation,
50
+ maximumFractionDigits: round,
51
51
  });
52
52
 
53
53
  return formatter.format(data - 0);
@@ -1,4 +1,3 @@
1
-
2
1
  /* eslint-disable no-param-reassign */
3
2
  /**
4
3
  * Форматування часу скільки залишилося чи пройшло від заданого
@@ -61,7 +60,8 @@ export default function formatRelative(data, options) {
61
60
 
62
61
  if (dif > 0) {
63
62
  chLang = options.hash.short ? short[locale] : templDifPast[locale];
64
- } else if (dif < 0) {
63
+ }
64
+ else if (dif < 0) {
65
65
  chLang = options.hash.short ? short[locale] : templDifFeature[locale];
66
66
  }
67
67
  dif = Math.abs(dif);
@@ -35,4 +35,4 @@ export default function formatUnit(data, options) {
35
35
  }
36
36
 
37
37
  return data.toString();
38
- };
38
+ }
@@ -39,4 +39,4 @@ export default function numFormat(data, options) {
39
39
  }
40
40
 
41
41
  return num.join('.');
42
- }
42
+ }
@@ -18,9 +18,10 @@
18
18
  export default function set(variableName, value) {
19
19
  if (typeof variableName === 'string') {
20
20
  this[variableName] = value;
21
- } else {
21
+ }
22
+ else {
22
23
  console.error('Invalid variable name.');
23
24
  }
24
25
 
25
26
  return '';
26
- }
27
+ }
@@ -21,9 +21,9 @@
21
21
  * @returns {String} Returns HTML
22
22
  */
23
23
  export default function _math(...args) {
24
- const options = args.pop();
24
+ const options = args.pop();
25
25
  const opt = options.hash;
26
-
26
+
27
27
  const operator = opt.operator ? opt.operator : args[1];
28
28
  opt.arg1 = (opt.arg1 || args[0]) - 0;
29
29
  opt.arg2 = (opt.arg2 || args[2]) - 0;
@@ -47,4 +47,4 @@ export default function _math(...args) {
47
47
  default:
48
48
  return 'operator is not defined';
49
49
  }
50
- }
50
+ }
@@ -25,7 +25,9 @@ const maxLimit = 100;
25
25
  * @returns {String} Returns HTML
26
26
  */
27
27
  export default async function contentList(options) {
28
- const { table, limit, query, order, sql, debug } = options.hash;
28
+ const {
29
+ table, limit, query, order, sql, debug,
30
+ } = options.hash;
29
31
  if (!table) { return 'Table undefined'; }
30
32
 
31
33
  try {
@@ -33,11 +35,11 @@ export default async function contentList(options) {
33
35
 
34
36
  const hasBrackets = table.trim().startsWith('(') && table.trim().endsWith(')');
35
37
 
36
- const where = `where ${query ? query : '1=1'}`;
38
+ const where = `where ${query || '1=1'}`;
37
39
  const _limit = limit !== undefined && limit !== null ? Math.min(maxLimit, +limit) : 15;
38
40
  const _order = order ? `order by ${order}` : '';
39
41
 
40
- const SQL = `select *,${pg.pk[table] || '1'}::text from ${hasBrackets ? table + ' t' : table} ${where} ${_order} limit ${_limit}`;
42
+ const SQL = `select *,${pg.pk[table] || '1'}::text from ${hasBrackets ? `${table} t` : table} ${where} ${_order} limit ${_limit}`;
41
43
  const compiledSQL = Handlebars.compile(SQL)(options.data.root);
42
44
 
43
45
  if (sql) {
@@ -52,7 +54,8 @@ export default async function contentList(options) {
52
54
  }
53
55
 
54
56
  return options.fn(data);
55
- } catch (err) {
57
+ }
58
+ catch (err) {
56
59
  return `Сталася помилка, зверніться до відділу підтримки.<!-- err: ${err.toString()} -->`;
57
60
  }
58
- };
61
+ }
@@ -18,4 +18,4 @@
18
18
  */
19
19
  export default function empty() {
20
20
  return '';
21
- };
21
+ }
@@ -76,7 +76,8 @@ export default function ifCondAnd() {
76
76
  if (typeof v2 === 'string') v2 = v2.split(',').map(item => item.trim());
77
77
  if (Array.isArray(v1)) {
78
78
  conditions.push(v1.some((value) => v2.includes(value.toString())));
79
- } else {
79
+ }
80
+ else {
80
81
  conditions.push(v2.includes(v1.toString()));
81
82
  }
82
83
  break;
@@ -5,7 +5,6 @@ function intersect(a, b) {
5
5
  return aN.filter((e) => bN.includes(e));
6
6
  }
7
7
 
8
-
9
8
  /**
10
9
  * Створення шаблона або його частини внаслідок виконання одразу декількох перевірок, хоча б одна з яких повинна повернути true
11
10
  *
@@ -78,7 +77,8 @@ export default function ifCondOr() {
78
77
  if (typeof v2 === 'string') v2 = v2.split(',').map(item => item.trim());
79
78
  if (Array.isArray(v1)) {
80
79
  conditions.push(v1.some((value) => v2.includes(value.toString())));
81
- } else {
80
+ }
81
+ else {
82
82
  conditions.push(v2.includes(v1.toString()));
83
83
  }
84
84
  break;
@@ -15,7 +15,6 @@
15
15
  export default function inc(...args) {
16
16
  const firstValue = args[0] || 0;
17
17
  const secondValue = typeof args[1] === 'number' ? args[1] : 1;
18
-
18
+
19
19
  return firstValue + secondValue;
20
20
  }
21
-
@@ -1,3 +1,3 @@
1
1
  export default function (data) {
2
- return JSON.stringify(data, null, 2)
3
- }
2
+ return JSON.stringify(data, null, 2);
3
+ }
@@ -38,7 +38,8 @@ export default async function qrcodeGenerator({ hash }) {
38
38
 
39
39
  if (type === 'png') {
40
40
  size = Math.abs(hash?.size) || 5;
41
- } else if (type === 'svg') {
41
+ }
42
+ else if (type === 'svg') {
42
43
  size = Math.abs(hash?.size) || undefined;
43
44
  }
44
45
 
@@ -60,7 +61,8 @@ export default async function qrcodeGenerator({ hash }) {
60
61
  const qrString = await qr.toDataURL(text, options);
61
62
 
62
63
  return qrString;
63
- } catch (err) {
64
+ }
65
+ catch (err) {
64
66
  return err.toString();
65
67
  }
66
- };
68
+ }
@@ -23,6 +23,6 @@ export default function round(data, options) {
23
23
  if (options.hash.floor) {
24
24
  return Math.floor(_data).toFixed(dec);
25
25
  }
26
-
26
+
27
27
  return _data.toFixed(dec);
28
- };
28
+ }
@@ -1,5 +1,6 @@
1
1
  import getPG from '../../plugins/pg/funcs/getPG.js';
2
- import getSelect from '../../plugins/table/funcs/getSelect.js';
2
+ import getSelect from '../../plugins/table/funcs/getSelect.js';
3
+
3
4
  const pg = getPG();
4
5
 
5
6
  // todo: remove dupe from npm/admin?
@@ -15,15 +16,10 @@ export default async function select(ids, options) {
15
16
 
16
17
  const classifier = await getSelect(data);
17
18
 
18
-
19
-
20
19
  if (!classifier) return `Не знайдено класифікатор ${data}`;
21
20
 
22
- const arr = classifier.arr || []
23
- if (classifier.sql && typeof classifier.sql === 'string') {
24
-
25
-
26
-
21
+ const arr = classifier.arr || [];
22
+ if (classifier.sql && typeof classifier.sql === 'string') {
27
23
  const metaQuery = `SELECT * FROM (${classifier.sql})q LIMIT 0`;
28
24
  const meta = await pg.query(metaQuery);
29
25
  const idColumn = meta.fields[0].name;
@@ -33,8 +29,7 @@ export default async function select(ids, options) {
33
29
  const values = [idsArray.map(id => String(id))];
34
30
 
35
31
  const { rows } = await pg.query(q, values);
36
- Object.assign(arr, rows);
37
-
32
+ Object.assign(arr, rows);
38
33
  }
39
34
  if (!arr.length) return idsArray;
40
35
 
@@ -44,7 +39,8 @@ export default async function select(ids, options) {
44
39
  });
45
40
 
46
41
  return results.filter(Boolean).join(', ');
47
- } catch (err) {
42
+ }
43
+ catch (err) {
48
44
  return `Сталася помилка.<!-- err: ${err.toString()} -->`;
49
45
  }
50
46
  }
@@ -1,13 +1,14 @@
1
- import buttonAdd from "../utils/buttonAdd.js";
2
- import buttonDel from "../utils/buttonDel.js";
3
- import buttonEdit from "../utils/buttonEdit.js";
4
- import button from "../utils/button.js";
1
+ import buttonAdd from '../utils/buttonAdd.js';
2
+ import buttonDel from '../utils/buttonDel.js';
3
+ import buttonEdit from '../utils/buttonEdit.js';
4
+ import button from '../utils/button.js';
5
+
5
6
  export default function buttonHelper(data, opt) {
6
7
  const { hash } = opt;
7
8
 
8
9
  // console.log(params)
9
10
 
10
- if (!hash.token) return "token empty";
11
+ if (!hash.token) return 'token empty';
11
12
  if (hash.add) {
12
13
  return buttonAdd(hash.token, hash.title);
13
14
  }
@@ -1,6 +1,4 @@
1
-
2
-
3
1
  export default function button(token, title) {
4
2
  return `<button onclick="window.v3plugin.$form({ token: '${token}' })"
5
3
  class="inline-flex items-center px-2 py-1 text-sm font-medium text-white duration-300 bg-blue-600 border border-transparent rounded-lg gap-x-2 hover:bg-blue-700 hover:text-white">${title || 'Додати'}</button>`;
6
- }
4
+ }
@@ -3,11 +3,10 @@
3
3
  // class="inline-flex items-center px-2 py-1 text-sm font-medium text-white duration-300 bg-red-600 border border-transparent rounded-lg gap-x-2 hover:bg-red-700 hover:text-white">${title || 'Вилучити'}</button>`;
4
4
  // }
5
5
 
6
-
7
- const newColor = 'red'
6
+ const newColor = 'red';
8
7
  export default function button(token, title) {
9
8
  return `<button onclick="window.v3plugin.$api({ api: '/api/table/${token}', method:'delete',confirm: { title:'Підтвердити операцію', text: 'Ви впевнені що хочете вилучити запис?', cancel: 'Скасувати', confirm : 'Виконати'} })"
10
9
  class="group px-2 py-1 inline-flex border-solid justify-center items-center gap-2 rounded-md font-semibold focus:outline-none text-sm transition-all border border-transparent hover:text-white ring-offset-white bg-${newColor}-100 text-${newColor}-100 hover:bg-${newColor}-500 focus:ring-${newColor}-500">
11
10
  <svg class="group-hover:fill-white" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" width="13" height="13" fill="#ef4444"><path d="M135.2 17.7L128 32 32 32C14.3 32 0 46.3 0 64S14.3 96 32 96l384 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-96 0-7.2-14.3C307.4 6.8 296.3 0 284.2 0L163.8 0c-12.1 0-23.2 6.8-28.6 17.7zM416 128L32 128 53.2 467c1.6 25.3 22.6 45 47.9 45l245.8 0c25.3 0 46.3-19.7 47.9-45L416 128z"/></svg>
12
11
  </button>`;
13
- }
12
+ }
@@ -1,15 +1,12 @@
1
-
2
-
3
1
  // export default function button(token, title) {
4
2
  // return `<button onclick="window.v3plugin.$form({ token: '${token}' })"
5
3
  // class="inline-flex items-center px-2 py-1 text-sm font-medium text-white duration-300 bg-blue-600 border border-transparent rounded-lg gap-x-2 hover:bg-blue-700 hover:text-white">${title || 'Редагувати'}</button>`;
6
4
  // }
7
5
 
8
-
9
- const newColor = 'blue'
6
+ const newColor = 'blue';
10
7
  export default function button(token, title) {
11
8
  return `<button onclick="window.v3plugin.$form({ token: '${token}' })"
12
9
  class="group px-2 py-1 inline-flex border-solid justify-center items-center gap-2 rounded-md font-semibold focus:outline-none text-sm transition-all border border-transparent hover:text-white ring-offset-white bg-${newColor}-100 text-${newColor}-100 hover:bg-${newColor}-500 focus:ring-${newColor}-500">
13
10
  <svg class="group-hover:fill-white" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="13" height="13" fill="#3b82f6"><path d="M471.6 21.7c-21.9-21.9-57.3-21.9-79.2 0L362.3 51.7l97.9 97.9 30.1-30.1c21.9-21.9 21.9-57.3 0-79.2L471.6 21.7zm-299.2 220c-6.1 6.1-10.8 13.6-13.5 21.9l-29.6 88.8c-2.9 8.6-.6 18.1 5.8 24.6s15.9 8.7 24.6 5.8l88.8-29.6c8.2-2.7 15.7-7.4 21.9-13.5L437.7 172.3 339.7 74.3 172.4 241.7zM96 64C43 64 0 107 0 160L0 416c0 53 43 96 96 96l256 0c53 0 96-43 96-96l0-96c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 96c0 17.7-14.3 32-32 32L96 448c-17.7 0-32-14.3-32-32l0-256c0-17.7 14.3-32 32-32l96 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L96 64z"/></svg>
14
11
  </button>`;
15
- }
12
+ }
@@ -25,4 +25,4 @@ export default function concat(...args) {
25
25
  }
26
26
 
27
27
  return result;
28
- };
28
+ }
@@ -8,7 +8,7 @@
8
8
  * @type helper
9
9
  * @example
10
10
 
11
- * @param {String} separator Символ по якому ділиться объект String
11
+ * @param {String} separator Символ по якому ділиться объект String
12
12
  * @param {String} data Строка або число яке обрізається
13
13
  * @returns {Array} Returns HTML
14
14
  */
@@ -17,4 +17,4 @@ export default function split(data, options) {
17
17
  const separator = options || ',';
18
18
 
19
19
  return fullString.split(separator);
20
- };
20
+ }
@@ -1,3 +1,10 @@
1
+ function replaceLast(str, what, replacement) {
2
+ if (!str?.split) return str;
3
+ const pcs = str?.split?.(what) || [];
4
+ const lastPc = pcs.pop();
5
+ return pcs.join(what) + replacement + lastPc;
6
+ }
7
+
1
8
  /**
2
9
  * Виконує заміну символів у строці. Є можливість заміни регулярного виразу нової строки на тег <br>
3
10
  *
@@ -16,11 +23,12 @@
16
23
  * @param {Object} newline
17
24
  * @param {Object} html
18
25
  * @param {Object} last
19
- * @param {Array} args[0]]
20
- * @param {Array} args[1]]
21
- * @param {Array} args[2]]
26
+ * @param {Array} args[0]
27
+ * @param {Array} args[1]
28
+ * @param {Array} args[2]
22
29
  * @returns {String} Returns HTML
23
30
  */
31
+
24
32
  export default function strReplace(...args) {
25
33
  const options = args.pop();
26
34
  const [str, from, to] = args;
@@ -52,10 +60,3 @@ export default function strReplace(...args) {
52
60
 
53
61
  return str.replace(new RegExp(from, 'g'), to);
54
62
  }
55
-
56
- function replaceLast(str, what, replacement) {
57
- if (!str?.split) return str;
58
- const pcs = str?.split(what);
59
- const lastPc = pcs.pop();
60
- return pcs.join(what) + replacement + lastPc;
61
- }
@@ -29,4 +29,4 @@ export default function substr(data, { hash }) {
29
29
  }
30
30
 
31
31
  return result;
32
- };
32
+ }
@@ -20,4 +20,4 @@ export default function translit({ data }) {
20
20
  const reg = new RegExp(`[${rKey}]`, 'g');
21
21
 
22
22
  return (data || '').replace(reg, (a) => (a in L ? L[a] : ''));
23
- };
23
+ }
@@ -73,4 +73,4 @@ export default {
73
73
  є: 'ie',
74
74
  Ґ: 'G',
75
75
  ґ: 'g',
76
- };
76
+ };
@@ -1,6 +1,4 @@
1
-
2
-
3
1
  export default function button(token, title) {
4
2
  return `<button onclick="window.v3plugin.$form({ token: '${token}' })"
5
3
  class="inline-flex items-center px-2 py-1 text-sm font-medium text-white duration-300 bg-blue-600 border border-transparent rounded-lg gap-x-2 hover:bg-blue-700 hover:text-white">${title || 'Редагувати'}</button>`;
6
- }
4
+ }
@@ -1,7 +1,5 @@
1
-
2
-
3
- const newColor = 'blue'
1
+ const newColor = 'blue';
4
2
  export default function button(token, title) {
5
3
  return `<button onclick="window.v3plugin.$form({ token: '${token}' })"
6
4
  class="px-2 py-1 inline-flex border-solid justify-center items-center gap-2 rounded-md font-semibold focus:outline-none text-sm transition-all border border-transparent hover:text-white ring-offset-white bg-${newColor}-100 text-${newColor}-500 hover:bg-${newColor}-500 focus:ring-${newColor}-500">${title || 'Додати'}</button>`;
7
- }
5
+ }
@@ -11,16 +11,16 @@ export default function button(token, title, icon) {
11
11
  confirm: 'Виконати'
12
12
  }
13
13
  })`;
14
-
14
+
15
15
  const buttonClass = icon
16
16
  ? `size-8 inline-flex justify-center items-center gap-x-2 rounded-e-lg border border-stone-200 bg-${newColor}-100 text-stone-800 shadow-sm hover:bg-${newColor}-200 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:bg-stone-50 dark:bg-neutral-800 dark:border-neutral-700 dark:text-neutral-300 dark:hover:bg-neutral-700 dark:focus:bg-neutral-700`
17
17
  : `px-2 py-1 inline-flex border-solid justify-center items-center gap-2 rounded-md font-semibold focus:outline-none text-sm transition-all border border-transparent hover:text-white ring-offset-white bg-${newColor}-100 text-${newColor}-500 hover:bg-${newColor}-500 focus:ring-${newColor}-500`;
18
-
18
+
19
19
  const buttonContent = icon
20
20
  ? `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="${newColor}" class="size-3.5">
21
21
  <path stroke-linecap="round" stroke-linejoin="round" d="m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0"/>
22
22
  </svg>`
23
23
  : `${title || 'Вилучити'}`;
24
-
24
+
25
25
  return `<button onclick="${apiCall}" class="${buttonClass}">${buttonContent}</button>`;
26
- }
26
+ }
@@ -1,3 +1,3 @@
1
1
  export default function buttonDownload(filepath) {
2
2
  return `<a download=1 class="flex items-center gap-x-2 border py-2 px-3 shadow rounded-xl cursor-pointer w-[42px] y-[34px]" href="${filepath}" target="_blank"><img src="https://cdn.softpro.ua/assets/file-up.svg" alt="generate"></a>`;
3
- }
3
+ }
@@ -1,4 +1,3 @@
1
-
2
1
  const newColor = 'blue';
3
2
  export default function button(token, title, icon) {
4
3
  const formCall = `window.v3plugin.$form({ token: '${token}' })`;
@@ -14,6 +13,5 @@ export default function button(token, title, icon) {
14
13
  </svg>`
15
14
  : `${title || 'Редагувати'}`;
16
15
 
17
- return `<button onclick="${formCall}" class="${buttonClass}">${buttonContent}</button>`;
18
-
19
- }
16
+ return `<button onclick="${formCall}" class="${buttonClass}">${buttonContent}</button>`;
17
+ }
@@ -1,3 +1,3 @@
1
1
  export default function buttonPreview(filepath) {
2
2
  return `<a class="flex items-center gap-x-2 border py-2 px-3 shadow rounded-xl cursor-pointer w-[42px] y-[34px]" href="${filepath}" target="_blank"><img src="https://cdn.softpro.ua/assets/eye.svg" alt="eye"></a>`;
3
- }
3
+ }
@@ -8,10 +8,10 @@ const md1 = md({ html: true });
8
8
 
9
9
  * @returns {String} Returns HTML
10
10
  */
11
- export default function mdToHTML(data, options) {
11
+ export default function mdToHTML(data) {
12
12
  // auto detect HTML or MD
13
13
  // const result = md().render(data);
14
14
  if (!data) return 'empty data';
15
15
  const result = md1.render(data);
16
16
  return result;
17
- };
17
+ }
@@ -1,4 +1,4 @@
1
1
  export default function (num) {
2
2
  const padding = arguments.length === 3 ? arguments[1] : 6;
3
- return num.toLocaleString('en', { minimumIntegerDigits: padding, useGrouping: false })
4
- }
3
+ return num.toLocaleString('en', { minimumIntegerDigits: padding, useGrouping: false });
4
+ }
@@ -37,4 +37,4 @@ const interval2ms = {
37
37
  },
38
38
  };
39
39
 
40
- export default interval2ms;
40
+ export default interval2ms;
@@ -1,3 +1,4 @@
1
+ /* eslint-disable no-console */
1
2
  import { createHash } from 'node:crypto';
2
3
 
3
4
  import config from '../../../config.js';
@@ -45,7 +46,7 @@ async function runCron({
45
46
  }
46
47
  }
47
48
 
48
- async function plugin(fastify) {
49
+ async function plugin() {
49
50
  if (config.cronList?.length) {
50
51
  config.cronList?.filter?.(el => el.query && !el.disabled)?.forEach?.((el, idx) => {
51
52
  const { interval, db, query } = el;
@@ -1,3 +1,4 @@
1
+ /* eslint-disable no-console */
1
2
  import getPG from '../../pg/funcs/getPG.js';
2
3
  import getRedis from '../../redis/funcs/getRedis.js';
3
4
  import pgClients from '../../pg/pgClients.js';