@opengis/cms 0.0.65 → 0.0.66

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/locales/en.json CHANGED
@@ -300,14 +300,24 @@
300
300
  "vertical_tabs": "Vertical Tabs",
301
301
  "documents": "Documents",
302
302
  "infoLine": "Information Line",
303
+ "interested": "You may be interested in",
304
+ "contact": "Contact",
303
305
  "iframe": "Iframe",
306
+ "imageSlider": "Image Slider",
307
+ "videoSlider": "Video Slider",
304
308
  "detailedBanner": "Detailed Banner",
305
309
  "cardsReverse": "Cards Reverse",
306
310
  "table": "Data Table",
311
+ "linkBlock": "Link Block",
312
+ "videoBlock": "Video Block",
313
+ "accordionBlock": "Accordion Block",
307
314
  "fileDownload": "File Download",
308
315
  "bodyContent": "Body Content",
309
316
  "columnList": "List of elements in two columns",
310
317
  "list": "List of elements",
318
+ "paste": "Paste",
319
+ "sectionCopied": "Section copied",
320
+ "sectionPasted": "Section pasted",
311
321
  "linkList": "List of links",
312
322
  "manageContentCollections": "Manage content collections",
313
323
  "searchCollections": "Search collections...",
@@ -680,7 +690,9 @@
680
690
  "addField": "Add Field",
681
691
  "success": "Success",
682
692
  "error": "Error",
683
- "back": "Back"
693
+ "back": "Back",
694
+ "copy": "Copy",
695
+ "warning": "Warning"
684
696
  },
685
697
  "status": {
686
698
  "published": "Published",
package/locales/uk.json CHANGED
@@ -300,14 +300,24 @@
300
300
  "vertical_tabs": "Вертикальні таби",
301
301
  "documents": "Документи",
302
302
  "infoLine": "Інформаційна лінія",
303
- "iframe": "Iframe",
303
+ "interested": "Вас може зацікавити",
304
+ "contact": "Контакти",
305
+ "iframe": "Вбудований вміст (iframe)",
306
+ "imageSlider": "Слайдер зображень",
307
+ "videoSlider": "Слайдер відео",
304
308
  "detailedBanner": "Детальний банер",
305
309
  "cardsReverse": "Картки зворотнього порядку",
306
310
  "table": "Таблиця даних",
311
+ "accordionBlock": "Блок випадаючих елементів",
312
+ "linkBlock": "Блок посилань",
313
+ "videoBlock": "Блок відео",
307
314
  "fileDownload": "Завантажити файл",
308
315
  "bodyContent": "Текстовий блок",
309
316
  "columnList": "Список елементів у двох колонках",
310
317
  "list": "Список елементів",
318
+ "paste": "Вставити",
319
+ "sectionCopied": "Секцію скопійовано",
320
+ "sectionPasted": "Секцію вставлено",
311
321
  "linkList": "Список посилань",
312
322
  "manageContentCollections": "Керування колекціями контенту",
313
323
  "searchCollections": "Пошук колекцій...",
@@ -679,7 +689,9 @@
679
689
  "addField": "Додати поле",
680
690
  "success": "Успіх",
681
691
  "error": "Помилка",
682
- "back": "Повернутися"
692
+ "back": "Повернутися",
693
+ "copy": "Копіювати",
694
+ "warning": "Увага"
683
695
  },
684
696
  "status": {
685
697
  "published": "Опубліковано",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/cms",
3
- "version": "0.0.65",
3
+ "version": "0.0.66",
4
4
  "description": "cms",
5
5
  "type": "module",
6
6
  "author": "Softpro",
@@ -43,7 +43,7 @@
43
43
  "devDependencies": {
44
44
  "@fastify/compress": "^8.1.0",
45
45
  "@opengis/core": "^0.0.30",
46
- "@opengis/fastify-table": "^2.0.147",
46
+ "@opengis/fastify-table": "^2.0.162",
47
47
  "@opengis/filter": "^0.1.33",
48
48
  "@opengis/form": "^0.0.121",
49
49
  "@tailwindcss/typography": "0.5.10",
@@ -66,4 +66,4 @@
66
66
  "vue-tsc": "^2.2.10",
67
67
  "vuedraggable": "4.1.0"
68
68
  }
69
- }
69
+ }
@@ -0,0 +1,61 @@
1
+ import path from 'node:path';
2
+
3
+ import { uploadMultiPart, dataInsert, pgClients } from "@opengis/fastify-table/utils.js";
4
+
5
+ // path.resolve() converts POSIX paths from getFolder to valid Windows paths (Bun/Node fs require this on Windows)
6
+ const dir = '/files';
7
+
8
+ export default async function preUploadMultiPart({ req }) {
9
+ if (!req || !req.headers || req.headers['content-type']?.split?.(';')?.shift?.() !== 'multipart/form-data') {
10
+ throw new Error('invalid params: req');
11
+ }
12
+
13
+ const { pg = pgClients.client } = req;
14
+
15
+ const subdir = ['uploads', new Date().toISOString().split("T")[0]].join('/');
16
+
17
+ const file = await uploadMultiPart(req, { subdir, originalFilename: true }).catch(err => {
18
+ if (err.message === 'Bad request: file with specified name already exists in directory') {
19
+ return { error: 'Файл з вказаною назвою вже існує', code: 400 };
20
+ }
21
+ throw err;
22
+ });
23
+
24
+ if (file.error) {
25
+ return file;
26
+ }
27
+
28
+ const { originalFilename: filename, filetype, mimetype } = file;
29
+ const relpath = path.join(dir, subdir || '', file.originalFilename).replace(/\\/g, '/');
30
+
31
+ const id = await dataInsert({
32
+ pg,
33
+ table: 'site.media',
34
+ data: {
35
+ filename,
36
+ filetype,
37
+ subdir: subdir || '',
38
+ url: relpath,
39
+ mime: mimetype,
40
+ filesize: file.size,
41
+ },
42
+ uid: req.user?.uid,
43
+ }).then(el => el?.media_id);
44
+
45
+ return {
46
+ res: 'ok',
47
+ name: filename,
48
+ type: 'file',
49
+ mimetype,
50
+ result: {
51
+ file_id: id,
52
+ format: file.extension,
53
+ size: file.size,
54
+ // entity_id: resultInsert?.entity_id,
55
+ file_path: relpath,
56
+ file_name: filename,
57
+ dir: path.dirname(relpath).replace(/\\/g, '/'),
58
+ native_file_name: filename,
59
+ },
60
+ };
61
+ }
@@ -1,9 +1,9 @@
1
1
  import fp from 'fastify-plugin';
2
- import { randomUUID, createHash } from 'node:crypto';
3
2
 
4
3
  import { addHook, addCron, config, pgClients } from '@opengis/fastify-table/utils.js';
5
4
 
6
5
  import getDraftKey from '../functions/getDraftKey.js';
6
+ import preUploadMultiPart from '../functions/preUploadMultiPart.js';
7
7
 
8
8
  const pg = pgClients.client;
9
9
 
@@ -41,6 +41,7 @@ async function updateDelayPublished() {
41
41
  return r;
42
42
  }
43
43
  function plugin(app) {
44
+ addHook('preUploadMultiPart', preUploadMultiPart);
44
45
  addHook('afterUser', async ({ payload = {} }) => {
45
46
  if (payload?.user) {
46
47
  // get from cache, refresh hourly