@opengis/cms 0.0.34 → 0.0.35

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.
@@ -0,0 +1,18 @@
1
+ [
2
+ {
3
+ "id": "draft",
4
+ "text": "Чернетка"
5
+ },
6
+ {
7
+ "id": "published",
8
+ "text": "Опубліковано"
9
+ },
10
+ {
11
+ "id": "archived",
12
+ "text": "Архівовано"
13
+ },
14
+ {
15
+ "id": "delayPublished",
16
+ "text": "Затримка публікації"
17
+ }
18
+ ]
@@ -0,0 +1,10 @@
1
+ [
2
+ {
3
+ "id": "regular",
4
+ "text": "Звичайний"
5
+ },
6
+ {
7
+ "id": "admin",
8
+ "text": "Admin"
9
+ }
10
+ ]
@@ -0,0 +1,78 @@
1
+ {
2
+ "schema": {
3
+ "user_name": {
4
+ "type": "Text",
5
+ "rules": [
6
+ "required"
7
+ ],
8
+ "ua": "Ім'я",
9
+ "i": "Вноситься ім'я користувача, що буде відображатися у системі"
10
+ },
11
+ "sur_name": {
12
+ "type": "Text",
13
+ "rules": [
14
+ "required"
15
+ ],
16
+ "ua": "Прізвище",
17
+ "i": "Вноситься прізвище користувача, що буде відображатися у системі"
18
+ },
19
+ "father_name": {
20
+ "ua": "По-батькові",
21
+ "type": "Text"
22
+ },
23
+ "phone": {
24
+ "type": "Text",
25
+ "mask": "+389999999999",
26
+ "ua": "Телефон",
27
+ "i": "Вноситься телефон користувача"
28
+ },
29
+ "email": {
30
+ "type": "Text",
31
+ "ua": "E-mail",
32
+ "i": "Вноситься електронна адреса користувача",
33
+ "rules": [
34
+ "email"
35
+ ]
36
+ },
37
+ "login": {
38
+ "type": "Text",
39
+ "ua": "Логін",
40
+ "i": "Вноситься довільний логін користувача латинськими літерами, що буде використовуватися для входу в систему",
41
+ "rules": [
42
+ "required"
43
+ ]
44
+ },
45
+ "password": {
46
+ "type": "Text",
47
+ "ua": "Пароль",
48
+ "rules": [
49
+ "required",
50
+ {
51
+ "type": "regexp",
52
+ "pattern": "^.{8,}$",
53
+ "message": "Пароль повинен бути більше 8 символів"
54
+ }
55
+ ],
56
+ "i": "Вноситься пароль, що буде використовуватися для входу в систему (рекомендоване використання складних паролів)"
57
+ },
58
+ "avatar": {
59
+ "type": "File",
60
+ "ua": "Аватар",
61
+ "i": "Додається зображення, що буде відображено в системі у якості аватара цього користувача"
62
+ },
63
+ "user_type": {
64
+ "type": "Select",
65
+ "ua": "Тип користувача",
66
+ "i": "Вноситься тип користувача",
67
+ "data": "user_type"
68
+ },
69
+ "enabled": {
70
+ "type": "Switcher",
71
+ "label": "Доступ"
72
+ },
73
+ "twofa": {
74
+ "type": "Switcher",
75
+ "label": "Двофакторна авторизація"
76
+ }
77
+ }
78
+ }
@@ -0,0 +1,2 @@
1
+ select content_type_id, name || ' (' || title || ')' from site.content_types
2
+ WHERE type = 'single'
@@ -0,0 +1 @@
1
+ SELECT content_type_id, name FROM site.content_types where type='collection'
@@ -0,0 +1,12 @@
1
+ select a.id, a.title, tags from data.news a
2
+ left join lateral(select array_agg(tag_id) as tags from site.tag_data b where a.id=b.data_id)b on 1=1
3
+
4
+ where
5
+ case when '{{parent}}'<> ''
6
+ then '{{parent}}'=any(b.tags)
7
+ else true
8
+ end
9
+
10
+ and status='published'
11
+
12
+ order by a.updated_at
@@ -0,0 +1 @@
1
+ select tag_id, value from site.tags order by value
@@ -0,0 +1,54 @@
1
+ {
2
+ "ua": "Користувачі",
3
+ "key": "uid",
4
+ "order": "cdate desc",
5
+ "access": "admin",
6
+ "sqlColumns": "*",
7
+ "form": "admin.users.form",
8
+ "table": "admin.users",
9
+ "sql": [
10
+ {
11
+ "name": "social_auth_sql",
12
+ "sql": "select social_auth_obj,social_auth_date from admin.users_social_auth where uid=t.uid limit 1"
13
+ },
14
+ {
15
+ "sql": "SELECT coalesce(sur_name, '') || ' ' || coalesce(user_name, '') || ' ' || coalesce(father_name, '') as full_name FROM admin.users WHERE uid = t.uid",
16
+ "name": "full_name_sql"
17
+ }
18
+ ],
19
+ "columns": [
20
+ {
21
+ "ua": "ПІБ",
22
+ "name": "full_name",
23
+ "format": "select",
24
+ "data": "full_name_sql"
25
+ },
26
+ {
27
+ "ua": "Тип користувача",
28
+ "name": "user_type_text",
29
+ "format": "select",
30
+ "data": "user_type_text"
31
+ },
32
+ {
33
+ "ua": "Статус доступу",
34
+ "name": "enabled"
35
+ }
36
+ ],
37
+ "filters": [
38
+ {
39
+ "label": "Тип користувача",
40
+ "type": "Check",
41
+ "name": "user_type",
42
+ "data": "user_type"
43
+ }
44
+ ],
45
+ "meta": {
46
+ "title": "full_name",
47
+ "search": "user_name,user_rnokpp"
48
+ },
49
+ "actions": [
50
+ "edit",
51
+ "del",
52
+ "add"
53
+ ]
54
+ }
@@ -0,0 +1,96 @@
1
+ {
2
+ "table": "site.contents",
3
+ "columns": [
4
+ {
5
+ "label": "Slug",
6
+ "name": "slug",
7
+ "parent": "title",
8
+ "required": true,
9
+ "type": "slug"
10
+ },
11
+ {
12
+ "label": "Title",
13
+ "name": "title",
14
+ "required": true,
15
+ "type": "text",
16
+ "localization": true
17
+ },
18
+ {
19
+ "label": "Status",
20
+ "name": "status",
21
+ "type": "select",
22
+ "data": "content.status",
23
+ "options": [
24
+ {
25
+ "id": "draft",
26
+ "text": "Draft"
27
+ },
28
+ {
29
+ "id": "published",
30
+ "text": "Published"
31
+ },
32
+ {
33
+ "id": "archived",
34
+ "text": "Archived"
35
+ },
36
+ {
37
+ "id": "delayPublished",
38
+ "text": "Delay Published"
39
+ }
40
+ ],
41
+ "required": true
42
+ },
43
+ {
44
+ "label": "Publish at",
45
+ "name": "published_at",
46
+ "required": true,
47
+ "type": "datetime"
48
+ },
49
+ {
50
+ "label": "Зображення",
51
+ "name": "main_image",
52
+ "type": "mediaselect"
53
+ }
54
+ ],
55
+ "filters": [
56
+ {
57
+ "extra": false,
58
+ "id": "status",
59
+ "name": "status",
60
+ "title": "Статус",
61
+ "type": "Check",
62
+ "data": "content.status",
63
+ "ua": "Статус"
64
+ },
65
+ {
66
+ "extra": false,
67
+ "label": "Publish at",
68
+ "name": "published_at",
69
+ "type": "Date"
70
+ },
71
+ {
72
+ "extra": false,
73
+ "name": "tag_list",
74
+ "type": "Tags",
75
+ "sql": "id in (select b.data_id from site.tags a left join site.tag_data b on a.tag_id=b.tag_id where a.tag_id=any($1))",
76
+ "label": "Теги"
77
+ },
78
+ {
79
+ "extra": false,
80
+ "columns": "slug,title",
81
+ "id": "search",
82
+ "name": "search",
83
+ "placeholder": "Пошук по тексту",
84
+ "title": "Пошук по тексту",
85
+ "type": "Text"
86
+ },
87
+ {
88
+ "extra": false,
89
+ "id": "created_at",
90
+ "name": "created_at",
91
+ "title": "Дата створення",
92
+ "type": "Date",
93
+ "ua": "Дата створення"
94
+ }
95
+ ]
96
+ }
@@ -0,0 +1,114 @@
1
+ {
2
+ "table": "site.contents",
3
+ "columns": [
4
+ {
5
+ "label": "Slug",
6
+ "name": "slug",
7
+ "parent": "title",
8
+ "required": true,
9
+ "type": "slug"
10
+ },
11
+ {
12
+ "label": "Title",
13
+ "name": "title",
14
+ "required": true,
15
+ "type": "text",
16
+ "localization": true
17
+ },
18
+ {
19
+ "label": "Status",
20
+ "name": "status",
21
+ "type": "select",
22
+ "data": "content.status",
23
+ "options": [
24
+ {
25
+ "id": "draft",
26
+ "text": "Draft"
27
+ },
28
+ {
29
+ "id": "published",
30
+ "text": "Published"
31
+ },
32
+ {
33
+ "id": "archived",
34
+ "text": "Archived"
35
+ },
36
+ {
37
+ "id": "delayPublished",
38
+ "text": "Delay Published"
39
+ }
40
+ ],
41
+ "required": true
42
+ },
43
+ {
44
+ "label": "Publish at",
45
+ "name": "published_at",
46
+ "required": true,
47
+ "type": "datetime"
48
+ },
49
+ {
50
+ "label": "Контент",
51
+ "name": "single_body",
52
+ "type": "richtext",
53
+ "localization": true
54
+ },
55
+ {
56
+ "name": "single_sections",
57
+ "label": "Секції",
58
+ "type": "reference",
59
+ "localization": true
60
+ },
61
+ {
62
+ "label": "Зображення",
63
+ "name": "main_image",
64
+ "type": "mediaselect"
65
+ }
66
+ ],
67
+ "filters": [
68
+ {
69
+ "extra": false,
70
+ "id": "status",
71
+ "name": "status",
72
+ "title": "Статус",
73
+ "type": "Check",
74
+ "data": "content.status",
75
+ "ua": "Статус"
76
+ },
77
+ {
78
+ "extra": false,
79
+ "label": "Publish at",
80
+ "name": "published_at",
81
+ "type": "Date"
82
+ },
83
+ {
84
+ "extra": false,
85
+ "label": "Контент",
86
+ "name": "single_body",
87
+ "type": "Text"
88
+ },
89
+ {
90
+ "extra": false,
91
+ "name": "tag_list",
92
+ "type": "Tags",
93
+ "sql": "id in (select b.data_id from site.tags a left join site.tag_data b on a.tag_id=b.tag_id where a.tag_id=any($1))",
94
+ "label": "Теги"
95
+ },
96
+ {
97
+ "extra": false,
98
+ "columns": "slug,title",
99
+ "id": "search",
100
+ "name": "search",
101
+ "placeholder": "Пошук по тексту",
102
+ "title": "Пошук по тексту",
103
+ "type": "Text"
104
+ },
105
+ {
106
+ "extra": false,
107
+ "id": "created_at",
108
+ "name": "created_at",
109
+ "title": "Дата створення",
110
+ "type": "Date",
111
+ "ua": "Дата створення"
112
+ }
113
+ ]
114
+ }
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@opengis/cms",
3
- "version": "0.0.34",
3
+ "version": "0.0.35",
4
4
  "description": "cms",
5
5
  "type": "module",
6
6
  "author": "Softpro",
7
7
  "main": "./dist/index.js",
8
8
  "license": "EULA",
9
9
  "files": [
10
+ "module",
10
11
  "dist",
11
12
  "server",
12
13
  "plugin.js"
package/plugin.js CHANGED
@@ -39,7 +39,7 @@ export default async function (app) {
39
39
  const pg = await getPGAsync(config.pg);
40
40
  execMigrations(path.join(dirname, 'server/migrations'), pg).catch(err => console.log(err));
41
41
  if (pg?.pk?.['site.content_types']) {
42
- const customTables = await pg.query('select array_agg(table_name) from site.content_types where table_name is not null').then(el => el.rows?.[0]?.array_agg || []).catch(err => console.log(err));
42
+ const customTables = await pg.query('select array_agg(table_name) from site.content_types where table_name is not null').catch(err => console.log(err)).then(el => el?.rows?.[0]?.array_agg || []);
43
43
 
44
44
  await Promise.all(customTables.filter(table => pg.pk?.[`data.${table}`])?.map(async (table) => {
45
45
  await pg.query(`alter table data.${table} add column if not exists meta json`).catch(err => console.log(err));
@@ -42,12 +42,12 @@ left join lateral (select content_type_id from site.content_types b where a.type
42
42
  -- seamless migration finish
43
43
 
44
44
  --- insert default content types start
45
- insert into site.content_types(content_type_id,name,title,type,columns)
45
+ insert into site.content_types(content_type_id,name,title,type,columns,template,uid)
46
46
  values('pages','pages','Сторінки','collection',
47
47
  '[{"name":"slug","label":"Slug","type":"slug","parent":"title","required":true},{"name":"title","label":"Title","type":"text","required":true},{"name":"status","label":"Status","type":"select","options":[{"id":"draft","text":"Draft"},{"id":"published","text":"Published"},{"id":"archived","text":"Archived"},{"id":"delayPublished","text":"Delay Published"}],"required":true},{"name":"published_at","label":"Publish at","type":"datetime","required":true}]'::json
48
- ) on conflict(content_type_id) do update set columns=excluded.columns, type = excluded.type;
49
- insert into site.contents(content_id,content_type_id,space_id)
50
- values('pages','pages','default') on conflict(content_id) do nothing;
48
+ ,'','1') on conflict(content_type_id) do update set columns=excluded.columns, type = excluded.type;
49
+ insert into site.contents(content_id,content_type_id,space_id,template,uid)
50
+ values('pages','pages','default','','1') on conflict(content_id) do nothing;
51
51
  --- insert default content types finish
52
52
 
53
53
  alter table site.contents add column if not exists meta json;
@@ -83,7 +83,8 @@ update site.content_types
83
83
  set columns=replace(columns::text,'publish_at', 'published_at')::json
84
84
  where columns::text like '%publish_at%';
85
85
 
86
- ALTER TABLE site.contents DROP CONSTRAINT contents_status_check;
86
+ ALTER TABLE site.contents DROP CONSTRAINT if exists contents_status_check;
87
+ -- select * from site.contents where not status = ANY (ARRAY['draft'::text, 'published'::text, 'archived'::text, 'delayPublished'::text])
87
88
  ALTER TABLE site.contents ADD CONSTRAINT contents_status_check CHECK (status = ANY (ARRAY['draft'::text, 'published'::text, 'archived'::text, 'delayPublished'::text]));
88
89
 
89
90
  UPDATE site.content_types
@@ -64,7 +64,7 @@ CREATE TABLE if not exists site.content_types (
64
64
  table_name VARCHAR(50),
65
65
  columns json,
66
66
  status VARCHAR (20) DEFAULT 'draft' CHECK (status::text = ANY (ARRAY['draft', 'published', 'archived']::text[])),
67
- visible BOOLEAN DEFAULT TRUE,
67
+ visible BOOLEAN DEFAULT TRUE,
68
68
  localized BOOLEAN DEFAULT FALSE,
69
69
  type VARCHAR(20) NOT NULL DEFAULT 'collection' CHECK (type::text = ANY (ARRAY['collection', 'single']::text[])),
70
70
  schema JSONB,
@@ -78,6 +78,20 @@ CREATE TABLE if not exists site.content_types (
78
78
  updated_by text REFERENCES admin.users(uid)
79
79
  );
80
80
 
81
+ ALTER TABLE site.content_types add COLUMN if not exists table_name text;
82
+ ALTER TABLE site.content_types add COLUMN if not exists title text;
83
+ ALTER TABLE site.content_types add COLUMN if not exists status text;
84
+ ALTER TABLE site.content_types add COLUMN if not exists visible boolean default true;
85
+ ALTER TABLE site.content_types add COLUMN if not exists localized boolean default false;
86
+ ALTER TABLE site.content_types add COLUMN if not exists schema jsonb;
87
+ ALTER TABLE site.content_types add COLUMN if not exists icon text;
88
+ ALTER TABLE site.content_types add COLUMN if not exists color text;
89
+ ALTER TABLE site.content_types add COLUMN if not exists created_at TIMESTAMP DEFAULT NOW();
90
+ ALTER TABLE site.content_types add COLUMN if not exists updated_at TIMESTAMP DEFAULT NOW();
91
+ ALTER TABLE site.content_types add COLUMN if not exists created_by text REFERENCES admin.users(uid);
92
+ ALTER TABLE site.content_types add COLUMN if not exists updated_by text REFERENCES admin.users(uid);
93
+ ALTER TABLE site.content_types add COLUMN if not exists preview_path text;
94
+
81
95
  ALTER TABLE if exists site.content_types ALTER COLUMN table_name DROP NOT NULL;
82
96
  ALTER TABLE if exists site.content_types ADD COLUMN if not exists columns json;
83
97
 
@@ -145,6 +159,14 @@ CREATE TABLE if not exists site.menus (
145
159
  );
146
160
 
147
161
  alter table site.menus add column if not exists locale VARCHAR(20) not null default 'uk';
162
+ alter table site.menus add column if not exists content text;
163
+ alter table site.menus add column if not exists items json;
164
+ alter table site.menus add column if not exists description text;
165
+ ALTER TABLE site.menus add COLUMN if not exists created_at TIMESTAMP DEFAULT NOW();
166
+ ALTER TABLE site.menus add COLUMN if not exists updated_at TIMESTAMP DEFAULT NOW();
167
+ ALTER TABLE site.menus add COLUMN if not exists created_by text REFERENCES admin.users(uid);
168
+ ALTER TABLE site.menus add COLUMN if not exists updated_by text REFERENCES admin.users(uid);
169
+
148
170
  ALTER TABLE site.menus DROP CONSTRAINT if exists menus_name_key;
149
171
  ALTER TABLE site.menus DROP CONSTRAINT if exists menus_name_locale_unique;
150
172
  alter table site.menus drop column if exists lang;
@@ -189,8 +211,8 @@ CREATE INDEX if not exists idx_roles_name ON site.roles(name);
189
211
  -- drop table if exists site.permissions cascade;
190
212
  CREATE TABLE if not exists site.permissions (
191
213
  permission_id text PRIMARY KEY default next_id(),
192
- role_id text references site.roles(role_id),
193
- user_id text references admin.users(uid),
214
+ role_id text references site.roles(role_id),
215
+ user_id text references admin.users(uid),
194
216
  content_type_id text references site.content_types(content_type_id),
195
217
  subject VARCHAR(100) NOT NULL,
196
218
  actions TEXT[] NOT NULL check (actions && (ARRAY['read', 'create', 'delete', 'edit']::text[])),
@@ -229,7 +251,7 @@ CREATE TABLE if not exists site.tokens (
229
251
  last_used TIMESTAMP NULL, -- When the token was last used (nullable)
230
252
  created_at TIMESTAMP NOT NULL default now(), -- When the token was created
231
253
  updated_at TIMESTAMP NOT NULL default now(), -- When the token was updated
232
- created_by TEXT, -- Who created the token
254
+ created_by TEXT, -- Who created the token
233
255
  updated_by TEXT, -- When updated the token
234
256
  expiration_date TIMESTAMP, -- (nullable) Expiration date of the token
235
257
  token_type TEXT CHECK (token_type IN ('CMA', 'PAT')), -- Type of token
@@ -348,6 +370,19 @@ CREATE TABLE if not exists site.contents (
348
370
  FOREIGN KEY (updated_by) REFERENCES admin.users(uid)
349
371
  );
350
372
 
373
+ alter table site.contents add column if not exists space_id text;
374
+ alter table site.contents add column if not exists content_type_id text;
375
+ ALTER TABLE site.contents add COLUMN if not exists created_at TIMESTAMP DEFAULT NOW();
376
+ ALTER TABLE site.contents add COLUMN if not exists updated_at TIMESTAMP DEFAULT NOW();
377
+ ALTER TABLE site.contents add COLUMN if not exists created_by text REFERENCES admin.users(uid);
378
+ ALTER TABLE site.contents add COLUMN if not exists updated_by text REFERENCES admin.users(uid);
379
+ ALTER TABLE site.contents add COLUMN if not exists published_at TIMESTAMP DEFAULT NOW();
380
+ ALTER TABLE site.contents add COLUMN if not exists revision INTEGER NOT NULL DEFAULT 1;
381
+ ALTER TABLE site.contents add COLUMN if not exists locale TEXT NOT NULL DEFAULT 'uk'::text;
382
+ ALTER TABLE site.contents add COLUMN if not exists published_by text;
383
+ ALTER TABLE site.contents add COLUMN if not exists slug text;
384
+ ALTER TABLE site.contents add COLUMN if not exists meta json;
385
+
351
386
  COMMENT ON COLUMN site.contents.content_id IS 'Unique identifier for the content item (entry)';
352
387
  COMMENT ON COLUMN site.contents.space_id IS 'FK to the space this content belongs to';
353
388
  COMMENT ON COLUMN site.contents.content_type_id IS 'FK to the content type definition';
@@ -380,6 +415,21 @@ CREATE TABLE if not exists site.content_data (
380
415
  constraint content_data_content_id_fkey FOREIGN KEY (content_id) REFERENCES site.contents(content_id) on delete cascade
381
416
  );
382
417
 
418
+
419
+ alter table site.content_data add column if not exists field_key text not null;
420
+ alter table site.content_data add column if not exists field_type text;
421
+ alter table site.content_data add column if not exists field_value text;
422
+ alter table site.content_data add column if not exists field_value_object json;
423
+ alter table site.content_data add column if not exists locale text;
424
+ alter table site.content_data add column if not exists field_id text;
425
+ alter table site.content_data add column if not exists object_id text;
426
+ ALTER TABLE site.content_data add COLUMN if not exists created_at TIMESTAMP DEFAULT NOW();
427
+ ALTER TABLE site.content_data add COLUMN if not exists updated_at TIMESTAMP DEFAULT NOW();
428
+ ALTER TABLE site.content_data add COLUMN if not exists created_by text REFERENCES admin.users(uid);
429
+ ALTER TABLE site.content_data add COLUMN if not exists updated_by text REFERENCES admin.users(uid);
430
+
431
+
432
+
383
433
  -- create unique index for slug
384
434
  CREATE UNIQUE INDEX if not exists content_data_slug_unique ON site.content_data (field_value) WHERE field_key = 'slug';
385
435