@live-change/content-service 0.3.0 → 0.3.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  const app = require("@live-change/framework").app()
2
2
 
3
3
  const relationsPlugin = require('@live-change/relations-plugin')
4
- const accessControlService = require('@live-change/user-service')
4
+ const accessControlService = require('@live-change/access-control-service')
5
5
 
6
6
  const definition = app.createServiceDefinition({
7
7
  name: "content",
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,227 @@
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
+ softValidation: ['nonEmpty', { name: 'maxLength', params: { maxLength: 64 } }]
69
+ },
70
+ description: {
71
+ type: String,
72
+ softValidation: ['nonEmpty', { name: 'maxLength', params: { maxLength: 155 } }]
73
+ },
74
+ og: {
75
+ type: Object,
76
+ properties: {
77
+ title: {
78
+ type: String,
79
+ softValidation: ['nonEmpty', { name: 'maxLength', params: { maxLength: 60 } }]
80
+ },
81
+ description: {
82
+ type: String,
83
+ input: 'textarea',
84
+ softValidation: ['nonEmpty', { name: 'maxLength', params: { maxLength: 65 } }]
85
+ },
86
+ image: {
87
+ type: 'Image',
88
+ softValidation: ['nonEmpty'],
89
+ },
90
+ determiner: {
91
+ type: String
92
+ },
93
+ locale: {
94
+ type: String
95
+ },
96
+ localeAlternate: {
97
+ type: Array,
98
+ of: {
99
+ type: String
100
+ }
101
+ },
102
+
103
+ /* audio: { /// TODO: add audio
104
+ type: 'Audio',
105
+ },*/
106
+ /* video: { /// TODO: add video
107
+ type: 'Video',
108
+ },*/
109
+ type: {
110
+ type: String,
111
+ softValidation: ['nonEmpty'],
112
+ options: [
113
+ 'music.song', 'music.album', 'music.playlist', 'music.radio_station',
114
+ 'video.movie', 'video.episode', 'video.tv_show', 'video.other',
115
+ 'article',
116
+ 'book',
117
+ 'profile',
118
+ 'website'
119
+ ]
120
+ },
121
+ music: {
122
+ if: App.isomorphic(({ props }) => props.og.type.split('.')[0] === 'music'),
123
+ type: Object,
124
+ properties: {
125
+ duration: {
126
+ if: App.isomorphic(({ props }) => ['music.album', 'music.song'].includes(props.og.type)),
127
+ ...durationType
128
+ },
129
+ song: {
130
+ if: App.isomorphic(({ props }) => ['music.album', 'music.playlist'].includes(props.og.type)),
131
+ ...musicSongsType
132
+ },
133
+ album: {
134
+ if: App.isomorphic(({ props }) => props.og.type === 'music.song'),
135
+ ...musicSongsType /// music.song list is compatible with music.album list
136
+ },
137
+ musician: {
138
+ if: App.isomorphic(({ props }) => ['music.album', 'music.song'].includes(props.og.type)),
139
+ ...urlArrayType
140
+ },
141
+ releaseDate: {
142
+ if: App.isomorphic(({ props }) => props.og.type === 'music.album'),
143
+ type: Date,
144
+ },
145
+ creator: {
146
+ if: App.isomorphic(({ props }) => ['music.radio_station', 'music.playlist'].includes(props.og.type)),
147
+ ...urlArrayType
148
+ },
149
+ },
150
+ softValidation: ['nonEmpty']
151
+ },
152
+ video: {
153
+ if: App.isomorphic(({ props }) => props.og.type.split('.')[0] === 'video'),
154
+ type: Object,
155
+ properties: {
156
+ actor: {
157
+ type: Array,
158
+ of: {
159
+ type: Object,
160
+ properties: {
161
+ url: urlType,
162
+ role: {
163
+ type: Number,
164
+ softValidation: ['integer']
165
+ }
166
+ }
167
+ }
168
+ },
169
+ director: urlArrayType,
170
+ writer: urlArrayType,
171
+ durationType: durationType,
172
+ releaseDate: {
173
+ type: Date,
174
+ },
175
+ tag: tagsType,
176
+ series: {
177
+ if: App.isomorphic(({ props }) => props.og.type === 'video.tv_show'),
178
+ ...urlType
179
+ }
180
+ }
181
+ },
182
+ article: {
183
+ if: App.isomorphic(({ props }) => props.og.type === 'article'),
184
+ type: Object,
185
+ properties: {
186
+ publishedTime: {
187
+ type: Date,
188
+ },
189
+ modifiedTime: {
190
+ type: Date,
191
+ },
192
+ expirationTime: {
193
+ type: Date,
194
+ },
195
+ author: urlType,
196
+ section: {
197
+ type: String
198
+ },
199
+ tag: tagsType
200
+ }
201
+ },
202
+ profile: {
203
+ if: App.isomorphic(({ props }) => props.og.type === 'profile'),
204
+ type: Object,
205
+ properties: {
206
+ firstName: {
207
+ type: String
208
+ },
209
+ lastName: {
210
+ type: String
211
+ },
212
+ username: {
213
+ type: String
214
+ },
215
+ gender: {
216
+ type: String,
217
+ options: ['male', 'female']
218
+ }
219
+ }
220
+ }
221
+ }
222
+ },
223
+ lastUpdate: {
224
+ type: Date
225
+ }
226
+ }
227
+ })
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.0",
3
+ "version": "0.3.2",
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.2",
25
- "@live-change/relations-plugin": "0.7.2",
24
+ "@live-change/framework": "0.7.4",
25
+ "@live-change/relations-plugin": "0.7.4",
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": "9cb5f8b01ecbcf4d841274ae112872370ea9d927"
31
+ "gitHead": "bc5b4a025949ef0ee18730d69ac2edf204f40317"
32
32
  }