@live-change/blog-service 0.3.5

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/definition.js ADDED
@@ -0,0 +1,11 @@
1
+ const app = require("@live-change/framework").app()
2
+
3
+ const relationsPlugin = require('@live-change/relations-plugin')
4
+ const accessControlService = require('@live-change/access-control-service')
5
+
6
+ const definition = app.createServiceDefinition({
7
+ name: "blog",
8
+ use: [ relationsPlugin, accessControlService ]
9
+ })
10
+
11
+ module.exports = definition
package/index.js ADDED
@@ -0,0 +1,8 @@
1
+ const App = require("@live-change/framework")
2
+ const app = App.app()
3
+
4
+ const definition = require('./definition.js')
5
+
6
+ const { Post } = require("./model.js")
7
+
8
+ module.exports = definition
package/metadata.js ADDED
@@ -0,0 +1,248 @@
1
+ const App = require("@live-change/framework")
2
+ const app = App.app()
3
+ const definition = require('./definition.js')
4
+
5
+ const config = definition.config
6
+ const {
7
+ contentReaderRoles = ['reader', 'writer'],
8
+ contentWriterRoles = ['writer']
9
+ } = config
10
+
11
+ const urlType = {
12
+ type: String,
13
+ softValidation: ['nonEmpty', 'url']
14
+ }
15
+ const urlArrayType = {
16
+ type: Array,
17
+ of: urlType
18
+ }
19
+
20
+ const musicSongsType = {
21
+ type: Array,
22
+ of: {
23
+ type: Object,
24
+ properties: {
25
+ url: urlType,
26
+ disc: {
27
+ type: Number,
28
+ input: 'integer',
29
+ softValidation: ['integer']
30
+ },
31
+ track: {
32
+ type: Number,
33
+ input: 'integer',
34
+ softValidation: ['integer']
35
+ }
36
+ }
37
+ }
38
+ }
39
+
40
+ const durationType = {
41
+ type: Number,
42
+ input: 'duration',
43
+ unit: 'seconds',
44
+ softValidation: ['nonEmpty', 'integer']
45
+ }
46
+
47
+ const tagsType = {
48
+ type: Array,
49
+ of: {
50
+ type: String
51
+ }
52
+ }
53
+
54
+ const Metadata = definition.model({
55
+ name: 'Metadata',
56
+ propertyOfAny: {
57
+ to: 'object',
58
+ readAccessControl: {
59
+ roles: contentReaderRoles
60
+ },
61
+ writeAccessControl: {
62
+ roles: contentWriterRoles
63
+ }
64
+ },
65
+ properties: {
66
+ title: {
67
+ type: String,
68
+ validation: ['nonEmpty', { name: 'maxLength', params: { length: 64 } }]
69
+ },
70
+ description: {
71
+ type: String,
72
+ input: 'textarea',
73
+ softValidation: ['nonEmpty', { name: 'maxLength', params: { length: 155 } }]
74
+ },
75
+ og: {
76
+ type: Object,
77
+ properties: {
78
+ title: {
79
+ type: String,
80
+ softValidation: ['nonEmpty', { name: 'maxLength', params: { length: 60 } }]
81
+ },
82
+ description: {
83
+ type: String,
84
+ input: 'textarea',
85
+ softValidation: ['nonEmpty', { name: 'maxLength', params: { length: 65 } }]
86
+ },
87
+ image: {
88
+ type: 'Image',
89
+ softValidation: ['nonEmpty'],
90
+ },
91
+ determiner: {
92
+ type: String
93
+ },
94
+ locale: {
95
+ type: String
96
+ },
97
+ localeAlternate: {
98
+ type: Array,
99
+ of: {
100
+ type: String
101
+ }
102
+ },
103
+
104
+ /* audio: { /// TODO: add audio
105
+ type: 'Audio',
106
+ },*/
107
+ /* video: { /// TODO: add video
108
+ type: 'Video',
109
+ },*/
110
+ type: {
111
+ type: String,
112
+ input: 'select',
113
+ softValidation: ['nonEmpty'],
114
+ defaultValue: 'website',
115
+ options: [
116
+ 'website',
117
+ 'article',
118
+ 'book',
119
+ 'profile',
120
+ 'music.song', 'music.album', 'music.playlist', 'music.radio_station',
121
+ 'video.movie', 'video.episode', 'video.tv_show', 'video.other'
122
+ ]
123
+ },
124
+ music: {
125
+ if: App.isomorphic(({ props }) =>
126
+ ['music.radio_station', 'music.playlist', 'music.album', 'music.song'].includes(props?.og?.type)
127
+ ),
128
+ type: Object,
129
+ properties: {
130
+ duration: {
131
+ if: App.isomorphic(({ props }) => ['music.album', 'music.song'].includes(props?.og?.type)),
132
+ ...durationType
133
+ },
134
+ song: {
135
+ if: App.isomorphic(({ props }) => ['music.album', 'music.playlist'].includes(props?.og?.type)),
136
+ ...musicSongsType
137
+ },
138
+ album: {
139
+ if: App.isomorphic(({ props }) => props?.og?.type === 'music.song'),
140
+ ...musicSongsType /// music.song list is compatible with music.album list
141
+ },
142
+ musician: {
143
+ if: App.isomorphic(({ props }) => ['music.album', 'music.song'].includes(props?.og?.type)),
144
+ ...urlArrayType
145
+ },
146
+ releaseDate: {
147
+ if: App.isomorphic(({ props }) => props?.og?.type === 'music.album'),
148
+ type: Date,
149
+ },
150
+ creator: {
151
+ if: App.isomorphic(({ props }) => ['music.radio_station', 'music.playlist'].includes(props?.og?.type)),
152
+ ...urlArrayType
153
+ },
154
+ },
155
+ softValidation: ['nonEmpty']
156
+ },
157
+ video: {
158
+ if: App.isomorphic(({ props }) =>
159
+ ['video.movie', 'video.episode', 'video.tv_show', 'video.other'].includes(props?.og?.type)
160
+ ),
161
+ type: Object,
162
+ properties: {
163
+ actor: {
164
+ type: Array,
165
+ of: {
166
+ type: Object,
167
+ properties: {
168
+ url: urlType,
169
+ role: {
170
+ type: Number,
171
+ softValidation: ['integer']
172
+ }
173
+ }
174
+ }
175
+ },
176
+ director: urlArrayType,
177
+ writer: urlArrayType,
178
+ duration: durationType,
179
+ releaseDate: {
180
+ type: Date,
181
+ },
182
+ tag: tagsType,
183
+ series: {
184
+ if: App.isomorphic(({ props }) => props?.og?.type === 'video.tv_show'),
185
+ ...urlType
186
+ }
187
+ }
188
+ },
189
+ article: {
190
+ if: App.isomorphic(({ props }) => props?.og?.type === 'article'),
191
+ type: Object,
192
+ properties: {
193
+ publishedTime: {
194
+ type: Date,
195
+ },
196
+ modifiedTime: {
197
+ type: Date,
198
+ },
199
+ expirationTime: {
200
+ type: Date,
201
+ },
202
+ author: urlArrayType,
203
+ section: {
204
+ type: String
205
+ },
206
+ tag: tagsType
207
+ }
208
+ },
209
+ profile: {
210
+ if: App.isomorphic(({ props }) => props?.og?.type === 'profile'),
211
+ type: Object,
212
+ properties: {
213
+ firstName: {
214
+ type: String
215
+ },
216
+ lastName: {
217
+ type: String
218
+ },
219
+ username: {
220
+ type: String
221
+ },
222
+ gender: {
223
+ type: String,
224
+ options: ['male', 'female']
225
+ }
226
+ }
227
+ },
228
+ book: {
229
+ if: App.isomorphic(({ props }) => props?.og?.type === 'book'),
230
+ type: Object,
231
+ properties: {
232
+ author: urlArrayType,
233
+ isbn: {
234
+ type: String
235
+ },
236
+ releaseDate: {
237
+ type: Date
238
+ },
239
+ tag: tagsType
240
+ }
241
+ }
242
+ }
243
+ },
244
+ lastUpdate: {
245
+ type: Date
246
+ }
247
+ }
248
+ })
package/model.js ADDED
@@ -0,0 +1,41 @@
1
+ const App = require("@live-change/framework")
2
+ const app = App.app()
3
+ const definition = require('./definition.js')
4
+
5
+ const config = definition.config
6
+ const {
7
+ postReaderRoles = ['reader', 'writer'],
8
+ postWriterRoles = ['writer']
9
+ } = config
10
+
11
+ const contentProperties = {
12
+ snapshot: {
13
+ type: String
14
+ },
15
+ dependencies: { // automatically generated list of static dependencies(images, documents etc.)
16
+ type: Array,
17
+ of: {
18
+ type: Array // Path - generated with frontend
19
+ }
20
+ }
21
+ }
22
+
23
+ const Post = definition.model({
24
+ name: 'Post',
25
+ entity: {
26
+ readAccessControl: {
27
+ roles: postReaderRoles
28
+ },
29
+ writeAccessControl: {
30
+ roles: postWriterRoles
31
+ },
32
+ },
33
+ properties: {
34
+ publishedTime: {
35
+ type: Date,
36
+ validation: ['nonEmpty', 'date']
37
+ }
38
+ }
39
+ })
40
+
41
+ module.exports = { Post }
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@live-change/blog-service",
3
+ "version": "0.3.5",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "NODE_ENV=test tape tests/*"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/live-change/live-change-services.git"
12
+ },
13
+ "license": "MIT",
14
+ "bugs": {
15
+ "url": "https://github.com/live-change/live-change-services/issues"
16
+ },
17
+ "homepage": "https://github.com/live-change/live-change-services",
18
+ "author": {
19
+ "email": "michal@laszczewski.pl",
20
+ "name": "Michał Łaszczewski",
21
+ "url": "https://www.viamage.com/"
22
+ },
23
+ "dependencies": {
24
+ "@live-change/framework": "0.7.5",
25
+ "@live-change/relations-plugin": "0.7.5",
26
+ "lru-cache": "^7.12.0",
27
+ "pluralize": "8.0.0",
28
+ "progress-stream": "^2.0.0",
29
+ "prosemirror-model": "^1.18.1"
30
+ },
31
+ "gitHead": "8d09f0f01547edd2c1321a8d7341e33aff4c562d"
32
+ }