@live-change/content-service 0.3.1 → 0.3.3

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/index.js CHANGED
@@ -12,6 +12,7 @@ const {
12
12
 
13
13
 
14
14
  const { Content, Session, schemas, getDocument } = require("./model.js")
15
+ const { Metadata } = require("./metadata.js")
15
16
  const Snapshot = definition.foreignModel("prosemirror", "Snapshot")
16
17
 
17
18
  definition.view({
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'],
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 CHANGED
@@ -55,10 +55,10 @@ const Page = definition.model({
55
55
  name: 'Page',
56
56
  entity: {
57
57
  readAccessControl: {
58
- roles: ['reader']
58
+ roles: contentReaderRoles
59
59
  },
60
60
  writeAccessControl: {
61
- roles: ['writer']
61
+ roles: contentWriterRoles
62
62
  },
63
63
  },
64
64
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/content-service",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -21,12 +21,12 @@
21
21
  "url": "https://www.viamage.com/"
22
22
  },
23
23
  "dependencies": {
24
- "@live-change/framework": "0.7.3",
25
- "@live-change/relations-plugin": "0.7.3",
24
+ "@live-change/framework": "0.7.5",
25
+ "@live-change/relations-plugin": "0.7.5",
26
26
  "lru-cache": "^7.12.0",
27
27
  "pluralize": "8.0.0",
28
28
  "progress-stream": "^2.0.0",
29
29
  "prosemirror-model": "^1.18.1"
30
30
  },
31
- "gitHead": "0217e49963ae913ab28c1e07dcbea72ceb588bc1"
31
+ "gitHead": "046ebbe0c5be36b156f5e814b627b926dd968a95"
32
32
  }