@opengis/cms 0.0.48 → 0.0.50

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 (35) hide show
  1. package/dist/ArticlesPage-Cuit_90w.js +286 -0
  2. package/dist/BuilderPage-B79YHrmr.js +386 -0
  3. package/dist/CollectionsBreadcrumb.vue_vue_type_script_setup_true_lang-B6irHMzL.js +45 -0
  4. package/dist/CollectionsPage-JfmrHNR_.js +110 -0
  5. package/dist/CreateForm-BMOBeP4G.js +125 -0
  6. package/dist/EditCollectionPage-B4p_iA6h.js +803 -0
  7. package/dist/EmptyData-DaZt_nAm.js +72 -0
  8. package/dist/MenuAddPage-CmU4kAUM.js +115 -0
  9. package/dist/MenuItemPage-UV8JlJvT.js +1365 -0
  10. package/dist/MenuPage-c4TPJgIN.js +106 -0
  11. package/dist/MonacoEditor.vue_vue_type_script_setup_true_lang-C8cip9Ci.js +84 -0
  12. package/dist/UniversalTable.vue_vue_type_script_setup_true_lang-DR4PQwqR.js +210 -0
  13. package/dist/UniversalTablePagination.vue_vue_type_script_setup_true_lang-C8P9DCeX.js +89 -0
  14. package/dist/_plugin-vue_export-helper-CHgC5LLL.js +9 -0
  15. package/dist/contentForm-S5mXr5B7.js +553 -0
  16. package/dist/getField-C7EZs-YQ.js +2920 -0
  17. package/dist/index.js +80 -12921
  18. package/dist/vuedraggable-CoAPPFYd.js +1742 -0
  19. package/locales/en.json +809 -0
  20. package/locales/uk.json +809 -0
  21. package/package.json +68 -67
  22. package/server/functions/getContent.js +1 -1
  23. package/server/functions/getSearchData.js +2 -2
  24. package/server/routes/cms/controllers/getPermissions.js +15 -15
  25. package/server/routes/cms/controllers/listMedia.js +18 -2
  26. package/server/routes/cms/controllers/searchContent.js +2 -0
  27. package/server/routes/cms/controllers/setPermissions.js +49 -49
  28. package/server/templates/select/core.user_mentioned.sql +1 -1
  29. package/utils.d.ts +3 -1
  30. package/dist/MenuAddPage-DJPQEn2D.js +0 -4
  31. package/dist/MenuItemPage-EH8svyv5.js +0 -4
  32. package/dist/MenuPage-BgE0yNpY.js +0 -4
  33. package/dist/en-CGMXhoFl.js +0 -813
  34. package/dist/index.umd.cjs +0 -52
  35. package/dist/uk-D2uNloeQ.js +0 -813
package/package.json CHANGED
@@ -1,67 +1,68 @@
1
- {
2
- "name": "@opengis/cms",
3
- "version": "0.0.48",
4
- "description": "cms",
5
- "type": "module",
6
- "author": "Softpro",
7
- "main": "./dist/index.js",
8
- "license": "EULA",
9
- "files": [
10
- "module",
11
- "dist",
12
- "server",
13
- "plugin.js",
14
- "utils.js",
15
- "utils.d.ts",
16
- "input-types.json"
17
- ],
18
- "scripts": {
19
- "patch": "npm version patch && git push && npm publish",
20
- "test": "node --test test/**/*.test.js",
21
- "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
22
- "dev": "NODE_ENV=dev bun --env-file=.env.ip server ",
23
- "admin": "vite admin",
24
- "build": "vite build && vite build admin",
25
- "build:lib": "vite build",
26
- "proxy": "vite dev admin",
27
- "start": "bun --env-file=.env.ip server",
28
- "prod": "NODE_ENV=production bun --env-file=.env.ip server ",
29
- "ip": "bun --env-file=.env.ip server",
30
- "demo": "node --env-file=.env.demo --env-file=.env server",
31
- "i18n:sync": "node i18n-sync.cjs",
32
- "prepublishOnly": "bun build:lib",
33
- "softpro": "bun --env-file=.env.softpro server",
34
- "softpro1": "NODE_ENV=production bun --env-file=.env.prod-softpro.local server"
35
- },
36
- "dependencies": {},
37
- "resolutions": {
38
- "rollup": "4.30.0"
39
- },
40
- "devDependencies": {
41
- "@fastify/compress": "^8.1.0",
42
- "@opengis/core": "^0.0.30",
43
- "@opengis/fastify-table": "^2.0.136",
44
- "@opengis/filter": "^0.1.31",
45
- "@opengis/form": "^0.0.109",
46
- "@opengis/richtext": "0.0.38",
47
- "@vueuse/head": "2.0.0",
48
- "js-yaml": "^4.1.0",
49
- "lucide-vue-next": "0.344.0",
50
- "vite": "5.1.4",
51
- "vue": "^3.5.17",
52
- "vue-i18n": "11.1.5",
53
- "vue-router": "4.4.3",
54
- "vuedraggable": "4.1.0",
55
- "@tailwindcss/typography": "0.5.10",
56
- "@tsconfig/node22": "^22.0.2",
57
- "@vitejs/plugin-vue": "5.0.4",
58
- "autoprefixer": "10.4.18",
59
- "eslint": "8.49.0",
60
- "postcss": "8.4.35",
61
- "sass": "^1.92.1",
62
- "tailwindcss": "3.4.1",
63
- "typescript": "~5.8.0",
64
- "vitest": "3.2.4",
65
- "vue-tsc": "^2.2.10"
66
- }
67
- }
1
+ {
2
+ "name": "@opengis/cms",
3
+ "version": "0.0.50",
4
+ "description": "cms",
5
+ "type": "module",
6
+ "author": "Softpro",
7
+ "main": "./dist/index.js",
8
+ "license": "EULA",
9
+ "files": [
10
+ "module",
11
+ "locales",
12
+ "dist",
13
+ "server",
14
+ "plugin.js",
15
+ "utils.js",
16
+ "utils.d.ts",
17
+ "input-types.json"
18
+ ],
19
+ "scripts": {
20
+ "patch": "npm version patch && git push && npm publish",
21
+ "test": "node --test test/**/*.test.js",
22
+ "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
23
+ "dev": "NODE_ENV=dev bun --env-file=.env.ip server ",
24
+ "admin": "vite admin",
25
+ "build": "vite build && vite build admin",
26
+ "build:lib": "vite build",
27
+ "proxy": "vite dev admin",
28
+ "start": "bun --env-file=.env.ip server",
29
+ "prod": "NODE_ENV=production bun --env-file=.env.ip server ",
30
+ "ip": "bun --env-file=.env.ip server",
31
+ "demo": "node --env-file=.env.demo --env-file=.env server",
32
+ "i18n:sync": "node i18n-sync.cjs",
33
+ "prepublishOnly": "bun build:lib",
34
+ "softpro": "bun --env-file=.env.softpro server",
35
+ "softpro1": "NODE_ENV=production bun --env-file=.env.prod-softpro.local server"
36
+ },
37
+ "dependencies": {},
38
+ "resolutions": {
39
+ "rollup": "4.30.0"
40
+ },
41
+ "devDependencies": {
42
+ "@fastify/compress": "^8.1.0",
43
+ "@opengis/core": "^0.0.30",
44
+ "@opengis/fastify-table": "^2.0.137",
45
+ "@opengis/filter": "^0.1.31",
46
+ "@opengis/form": "^0.0.109",
47
+ "@opengis/richtext": "0.0.38",
48
+ "@vueuse/head": "2.0.0",
49
+ "js-yaml": "^4.1.0",
50
+ "lucide-vue-next": "0.344.0",
51
+ "vite": "5.1.4",
52
+ "vue": "^3.5.17",
53
+ "vue-i18n": "11.1.5",
54
+ "vue-router": "4.4.3",
55
+ "vuedraggable": "4.1.0",
56
+ "@tailwindcss/typography": "0.5.10",
57
+ "@tsconfig/node22": "^22.0.2",
58
+ "@vitejs/plugin-vue": "5.0.4",
59
+ "autoprefixer": "10.4.18",
60
+ "eslint": "8.49.0",
61
+ "postcss": "8.4.35",
62
+ "sass": "^1.92.1",
63
+ "tailwindcss": "3.4.1",
64
+ "typescript": "~5.8.0",
65
+ "vitest": "3.2.4",
66
+ "vue-tsc": "^2.2.10"
67
+ }
68
+ }
@@ -19,7 +19,7 @@ const mockReply = {
19
19
  },
20
20
  };
21
21
 
22
- export default async function getContentBySlug(slug, { filter, tags, state, locale, contextQuery, collection = 'pages', ttl = 3600, fields, limit = 12, page = 1 } = {}) {
22
+ export default async function getContentBySlug({ slug, filter, tags, state, locale, contextQuery, collection = 'pages', ttl = 3600, fields, limit = 12, page = 1 } = {}) {
23
23
  if (!slug) {
24
24
  // return { error: 'not enough params: slug', code: 400 };
25
25
  }
@@ -19,7 +19,7 @@ const mockReply = {
19
19
  },
20
20
  };
21
21
 
22
- export default async function getSearchData({ page = 1, limit = 12, ttl = 3600, locale, tags, filter, contentType, asc } = {}) {
22
+ export default async function getSearchData({ page = 1, limit = 12, ttl = 3600, search, locale, tags, filter, contentType, asc } = {}) {
23
23
  // check if any crud operations performed, if not - return cached response
24
24
  const crudInc = await rclient.get(`pg:site.contents:crud`) || 0;
25
25
 
@@ -31,7 +31,7 @@ export default async function getSearchData({ page = 1, limit = 12, ttl = 3600,
31
31
  return { cache: true, ...cacheData };
32
32
  }
33
33
 
34
- const result = await searchContent({ pg, query: { locale, page, limit, tags, filter, contentType } }, mockReply);
34
+ const result = await searchContent({ pg, query: { search, locale, page, limit, tags, filter, contentType } }, mockReply);
35
35
 
36
36
  if (ttl) {
37
37
  await rclient.set(cacheKey, JSON.stringify(result), 'EX', ttl);
@@ -1,16 +1,16 @@
1
- import { pgClients } from '@opengis/fastify-table/utils.js';
2
-
3
- export default async function getPermissions(req, reply) {
4
- const { pg = pgClients.client, params = {}, user = {} } = req;
5
-
6
- if (!user?.uid) {
7
- return reply.status(401).send('unauthorized');
8
- }
9
-
10
- const { rows = [] } = await pg.query(
11
- `select * from site.permissions where ${params.id ? 'user_id=$1' : 'true'}`,
12
- [params.id].filter(Boolean),
13
- );
14
-
15
- return { permissions: rows };
1
+ import { pgClients } from '@opengis/fastify-table/utils.js';
2
+
3
+ export default async function getPermissions(req, reply) {
4
+ const { pg = pgClients.client, params = {}, user = {} } = req;
5
+
6
+ if (!user?.uid) {
7
+ return reply.status(401).send('unauthorized');
8
+ }
9
+
10
+ const { rows = [] } = await pg.query(
11
+ `select * from site.permissions where ${params.id ? 'user_id=$1' : 'true'}`,
12
+ [params.id].filter(Boolean),
13
+ );
14
+
15
+ return { permissions: rows };
16
16
  }
@@ -2,9 +2,22 @@ import path from 'node:path';
2
2
  import { existsSync, mkdirSync } from 'node:fs';
3
3
  import { readdir, stat } from 'node:fs/promises';
4
4
 
5
- import { config, getFolder, pgClients, getMimeType } from '@opengis/fastify-table/utils.js';
5
+ import { config, getFolder, pgClients, getMimeType, getFilterSQL } from '@opengis/fastify-table/utils.js';
6
6
  import { createHash } from 'node:crypto';
7
7
 
8
+ const filterList = [
9
+ {
10
+ name: "created_at",
11
+ type: "Date",
12
+ ua: "Дата створення"
13
+ },
14
+ {
15
+ name: "updated_at",
16
+ type: "Date",
17
+ ua: "Дата редагування"
18
+ }
19
+ ]
20
+
8
21
  // path.resolve() converts POSIX paths from getFolder to valid Windows paths (Bun/Node fs require this on Windows)
9
22
  const rootDir = path.resolve(getFolder(config, 'local'));
10
23
  const dir = '/files';
@@ -39,12 +52,15 @@ export default async function listMedia(req, reply) {
39
52
  const allItems = isDirectory ? await readdir(dirpath, { withFileTypes: true, recursive: true }) : [];
40
53
  const items = isDirectory ? await readdir(dirpath, { withFileTypes: true }) : [];
41
54
 
55
+ const { q = '' } = await getFilterSQL({ table: 'site.media', filter: query?.filter, filterList, pg });
56
+
42
57
  const rows = await pg.query(
43
58
  `select
44
59
  media_id as id, filename, filetype, filesize, url, description, alt,
45
60
  mime, preview_url, created_at, updated_at, created_by, updated_by
46
61
  from site.media
47
- where ${subdir ? 'subdir = $1' : (search ? '1=1' : 'subdir is null')} ${search ? `and filename ilike '%${search.replace(/'/g, "''")}%'` : ''}`,
62
+ where ${subdir ? 'subdir = $1' : (search ? '1=1' : 'subdir is null')} ${search ? `and filename ilike '%${search.replace(/'/g, "''")}%'` : ''}
63
+ ${q ? ` and (${q})` : ''}`,
48
64
  [subdir].filter(Boolean),
49
65
  ).then(el => el.rows || []); // ?.filter(row => items.map(el => el.name).includes(row.filename))
50
66
 
@@ -35,6 +35,7 @@ export default async function searchContent({
35
35
 
36
36
  const {
37
37
  locale, // to do?
38
+ search,
38
39
  filter,
39
40
  contentType,
40
41
  asc,
@@ -58,6 +59,7 @@ export default async function searchContent({
58
59
  pg,
59
60
  table: 'site.contents',
60
61
  filter,
62
+ search,
61
63
  query: `status='published'`,
62
64
  filterList,
63
65
  }) : { q: `status='published'` };
@@ -1,50 +1,50 @@
1
- import { logger, pgClients, dataInsert } from '@opengis/fastify-table/utils.js';
2
-
3
- export default async function setPermissions(req, reply) {
4
- const { pg = pgClients.client, params = {}, user = {}, body = {} } = req;
5
-
6
- if (!user?.uid) {
7
- return reply.status(401).send('unauthorized');
8
- }
9
-
10
- if (!params.id) {
11
- return reply.status(400).send('not enough params: id');
12
- }
13
-
14
- const client = await pg.connect()
15
- const result = {};
16
- try {
17
- await client.query('BEGIN');
18
-
19
- const { rowCount = 0 } = await client.query(
20
- `delete from site.permissions where user_id=$1`,
21
- [params.id].filter(Boolean),
22
- );
23
-
24
- Object.assign(result, { deleted: rowCount });
25
-
26
- if (Array.isArray(body.permissions) && body.permissions?.length) {
27
- body.permissions.forEach((el) => {
28
- Object.assign(el, { user_id: el.user_id || params.id });
29
- });
30
-
31
- await Promise.all(body.permissions.map(async (el) => dataInsert({
32
- pg: client,
33
- table: 'site.permissions',
34
- data: el,
35
- uid: user.uid,
36
- })));
37
-
38
- Object.assign(result, { inserted: body.permissions.length });
39
- }
40
-
41
- await client.query('COMMIT');
42
- return reply.status(200).send(result);
43
- } catch (err) {
44
- await client.query('ROLLBACK');
45
- logger.file('cms/permissions', { error: err.toString(), stack: err.stack });
46
- return reply.status(500).send('set permissions error');
47
- } finally {
48
- client.release();
49
- }
1
+ import { logger, pgClients, dataInsert } from '@opengis/fastify-table/utils.js';
2
+
3
+ export default async function setPermissions(req, reply) {
4
+ const { pg = pgClients.client, params = {}, user = {}, body = {} } = req;
5
+
6
+ if (!user?.uid) {
7
+ return reply.status(401).send('unauthorized');
8
+ }
9
+
10
+ if (!params.id) {
11
+ return reply.status(400).send('not enough params: id');
12
+ }
13
+
14
+ const client = await pg.connect()
15
+ const result = {};
16
+ try {
17
+ await client.query('BEGIN');
18
+
19
+ const { rowCount = 0 } = await client.query(
20
+ `delete from site.permissions where user_id=$1`,
21
+ [params.id].filter(Boolean),
22
+ );
23
+
24
+ Object.assign(result, { deleted: rowCount });
25
+
26
+ if (Array.isArray(body.permissions) && body.permissions?.length) {
27
+ body.permissions.forEach((el) => {
28
+ Object.assign(el, { user_id: el.user_id || params.id });
29
+ });
30
+
31
+ await Promise.all(body.permissions.map(async (el) => dataInsert({
32
+ pg: client,
33
+ table: 'site.permissions',
34
+ data: el,
35
+ uid: user.uid,
36
+ })));
37
+
38
+ Object.assign(result, { inserted: body.permissions.length });
39
+ }
40
+
41
+ await client.query('COMMIT');
42
+ return reply.status(200).send(result);
43
+ } catch (err) {
44
+ await client.query('ROLLBACK');
45
+ logger.file('cms/permissions', { error: err.toString(), stack: err.stack });
46
+ return reply.status(500).send('set permissions error');
47
+ } finally {
48
+ client.release();
49
+ }
50
50
  }
@@ -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,'')
package/utils.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  interface ContentParam {
2
+ slug?: string;
2
3
  locale?: string;
3
4
  ttl?: number;
4
5
  page?: number;
@@ -35,6 +36,7 @@ interface Setting {
35
36
  interface SearchParam {
36
37
  contentType?: string;
37
38
  filter?: string;
39
+ search?: string;
38
40
  locale?: string;
39
41
  tags?: string;
40
42
  page?: number;
@@ -43,7 +45,7 @@ interface SearchParam {
43
45
  ttl?: number;
44
46
  }
45
47
 
46
- export function getContent(slug?: string, param?: ContentParam): any;
48
+ export function getContent(param?: ContentParam): any;
47
49
  export function getMenu(slug: string, param?: MenuParam): any;
48
50
  export function getSettings(param?: SettingParam): any;
49
51
  export function getUser(cookies: string | Record<string, any>): any;
@@ -1,4 +0,0 @@
1
- import { MenuAddPage as e } from "./index.js";
2
- export {
3
- e as default
4
- };
@@ -1,4 +0,0 @@
1
- import { MenuItemPage as e } from "./index.js";
2
- export {
3
- e as default
4
- };
@@ -1,4 +0,0 @@
1
- import { MenuPage as e } from "./index.js";
2
- export {
3
- e as default
4
- };