@opengis/fastify-table 1.3.53 → 1.3.54

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.3.53",
3
+ "version": "1.3.54",
4
4
  "type": "module",
5
5
  "description": "core-plugins",
6
6
  "keywords": [
@@ -39,6 +39,7 @@
39
39
  "handlebars": "4.7.8",
40
40
  "ioredis": "5.3.2",
41
41
  "js-yaml": "4.1.0",
42
+ "markdown-it": "14.1.0",
42
43
  "pg": "8.11.3",
43
44
  "pino": "9.5.0",
44
45
  "pino-abstract-transport": "2.0.0",
@@ -9,16 +9,21 @@ ALTER TABLE admin.templates DROP CONSTRAINT if exists admin_templates_name_type_
9
9
  ALTER TABLE admin.templates add column if not exists name text;
10
10
  ALTER TABLE admin.templates add column if not exists title text;
11
11
  ALTER TABLE admin.templates add column if not exists type text;
12
+ ALTER TABLE admin.templates add column if not exists category text;
12
13
  ALTER TABLE admin.templates add column if not exists route_id text;
13
- ALTER TABLE admin.templates add column if not exists enabled boolean;
14
- ALTER TABLE admin.templates alter column enabled set default true;
14
+ ALTER TABLE admin.templates add column if not exists is_active boolean;
15
+ ALTER TABLE admin.templates alter column is_active set default true;
15
16
  ALTER TABLE admin.templates add column if not exists body text;
17
+ ALTER TABLE admin.templates add column if not exists description text;
18
+ ALTER TABLE admin.templates add column if not exists placeholders json;
19
+ ALTER TABLE admin.templates add column if not exists version numeric;
16
20
 
17
- ALTER TABLE admin.templates add column if not exists uid text;
18
- ALTER TABLE admin.templates add column if not exists cdate timestamp without time zone DEFAULT date_trunc('seconds'::text, now());
19
- ALTER TABLE admin.templates alter column cdate set DEFAULT date_trunc('seconds'::text, now());
20
- ALTER TABLE admin.templates add column if not exists editor_id text;
21
- ALTER TABLE admin.templates add column if not exists editor_date timestamp without time zone;
21
+ ALTER TABLE admin.templates add column if not exists created_by text;
22
+ ALTER TABLE admin.templates add column if not exists created_at timestamp without time zone;
23
+ ALTER TABLE admin.templates alter column created_at set DEFAULT date_trunc('seconds'::text, now());
24
+ ALTER TABLE admin.templates add column if not exists updated_by text;
25
+ ALTER TABLE admin.templates add column if not exists updated_at timestamp without time zone;
26
+ ALTER TABLE admin.templates alter column updated_at set DEFAULT date_trunc('seconds'::text, now());
22
27
 
23
28
  ALTER TABLE admin.templates add CONSTRAINT admin_templates_template_id_pkey PRIMARY KEY (template_id);
24
29
  ALTER TABLE admin.templates add CONSTRAINT admin_templates_name_type_unique UNIQUE (name, type);
@@ -30,6 +35,10 @@ COMMENT ON COLUMN admin.templates.uid IS 'ID користувача';
30
35
  COMMENT ON COLUMN admin.templates.name IS 'Систамна назва шаблону';
31
36
  COMMENT ON COLUMN admin.templates.title IS 'Назва шаблону українською';
32
37
  COMMENT ON COLUMN admin.templates.type IS 'Тип вихідних даних шаблону (demo/user)';
38
+ COMMENT ON COLUMN admin.templates.category IS 'Категорія або тип документа';
33
39
  COMMENT ON COLUMN admin.templates.route_id IS 'ID інтерфейсу';
34
- COMMENT ON COLUMN admin.templates.enabled IS 'On / Off';
35
- COMMENT ON COLUMN admin.templates.body IS 'Body HTML';
40
+ COMMENT ON COLUMN admin.templates.is_active IS 'Чи доступний шаблон для використання';
41
+ COMMENT ON COLUMN admin.templates.body IS 'Body HTML';
42
+ COMMENT ON COLUMN admin.templates.description IS 'Короткий опис шаблону';
43
+ COMMENT ON COLUMN admin.templates.placeholders IS 'Список змінних, які можна вставляти';
44
+ COMMENT ON COLUMN admin.templates.version IS 'Версія шаблону';
@@ -0,0 +1,17 @@
1
+ import md from 'markdown-it';
2
+
3
+ const md1 = md({ html: true });
4
+
5
+ /**
6
+ * Перетворення з файла readme.md до формату HTML.
7
+ * Потрабно вставити в хелпер шлях до файла або текст readme.md і за допомогою бібліотеки markdown-it перетвориться в HTML.
8
+
9
+ * @returns {String} Returns HTML
10
+ */
11
+ export default function mdToHTML(data, options) {
12
+ // auto detect HTML or MD
13
+ // const result = md().render(data);
14
+ if (!data) return 'empty data';
15
+ const result = md1.render(data);
16
+ return result;
17
+ };
@@ -1,10 +1,11 @@
1
- import path from 'path';
1
+ import path from 'node:path';
2
2
  import yaml from 'js-yaml';
3
3
 
4
- import { readdir, readFile } from 'fs/promises';
4
+ import { readdir, readFile } from 'node:fs/promises';
5
5
 
6
6
  import getTemplatePath from './getTemplatePath.js';
7
7
  import loadTemplate from './loadTemplate.js';
8
+ import mdToHTML from '../../md/funcs/mdToHTML.js';
8
9
 
9
10
  async function readFileData(file) {
10
11
  const data = await readFile(file, 'utf-8');
@@ -16,6 +17,21 @@ async function readFileData(file) {
16
17
  if (ext === 'json') {
17
18
  return JSON.parse(data);
18
19
  }
20
+ if (ext === 'md') {
21
+ const match = data.match(/^---\r?\n([\s\S]*?)---\r?\n([\s\S]*)$/);
22
+
23
+ const parseLinesRecursively = (lines, index = 0, result = {}) => index >= lines.length
24
+ ? result
25
+ : (([key, ...rest]) => key && rest.length
26
+ ? parseLinesRecursively(lines, index + 1, { ...result, [key.trim()]: rest.join(':').trim() })
27
+ : parseLinesRecursively(lines, index + 1, result))((lines[index] || '').split(':'));
28
+
29
+ const header = parseLinesRecursively(match[1]?.split?.(/\r?\n/) || []);
30
+ const body = match[2]?.replace(/\r\n/g, '')?.startsWith('```html') ? match[2]?.match?.(/```html\r?\n([\s\S]*?)```/)?.[1] : match[2];
31
+
32
+ return { ...header, html: mdToHTML(body) };
33
+
34
+ }
19
35
  return data;
20
36
  }
21
37
 
package/utils.js CHANGED
@@ -77,6 +77,7 @@ import yml2json from './server/plugins/yml/funcs/yml2json.js';
77
77
  import json2yml from './server/plugins/yml/funcs/json2yml.js';
78
78
 
79
79
  import formatMdoc from './server/plugins/md/funcs/formatMdoc.js';
80
+ import mdToHTML from './server/plugins/md/funcs/mdToHTML.js';
80
81
 
81
82
  export default null;
82
83
  export {
@@ -150,4 +151,5 @@ export {
150
151
  json2yml,
151
152
 
152
153
  formatMdoc,
154
+ mdToHTML,
153
155
  };