-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathcontent.js
120 lines (111 loc) · 4.24 KB
/
content.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
module.exports = (function() {
'use strict';
var coordinator = require('./coordinator'),
middleware = require('../middleware'),
security = require('../security'),
Kontx = require('../utils/kontx'),
logger = require('../utils/logger');
coordinator.use('content.update', [
middleware.identity,
middleware.nodes.setNodeIdFromArgument,
middleware.nodes.requireNodePermissions(security.roles.AUTHOR),
middleware.content.convertType,
middleware.content.prepareEvent,
middleware.event('parse'),
middleware.event('validate'),
middleware.content.validate,
middleware.content.setComputedProperties,
middleware.content.update,
middleware.event('out'),
middleware.event('save')
]);
coordinator.use('content.insert', [
middleware.identity,
middleware.nodes.setNodeIdFromArgument,
middleware.nodes.requireNodePermissions(security.roles.AUTHOR),
middleware.content.convertType,
middleware.content.prepareEvent,
middleware.event('parse'),
middleware.event('validate'),
middleware.content.validate,
middleware.content.setComputedProperties,
middleware.content.insert,
middleware.event('out'),
middleware.event('save')
]);
coordinator.use('content.query', [
middleware.identity,
middleware.role(security.roles.READER),
middleware.content.query,
middleware.content.setContentPayload,
middleware.event('out')
]);
coordinator.use('content.queryFull', [
middleware.identity,
middleware.role(security.roles.READER),
middleware.content.query,
middleware.content.populateAll,
middleware.content.setContentPayload,
middleware.event('out')
]);
coordinator.use('content.deleteById', [
middleware.identity,
middleware.content.setTempContent,
middleware.nodes.requireNodePermissions(security.roles.AUTHOR),
middleware.content.setEventFiltersFromTempContent,
middleware.event('parse'),
middleware.event('validate'),
middleware.content.deleteById,
middleware.event('out'),
middleware.event('delete')
]);
coordinator.use('content.getById', [
middleware.identity,
middleware.content.setTempContent,
middleware.nodes.requireNodePermissions(security.roles.READER),
middleware.content.setEventFiltersFromTempContent,
middleware.event('parse'),
middleware.event('validate'),
middleware.content.setContentPayload,
middleware.event('out')
]);
coordinator.use('content.getFullById', [
middleware.identity,
middleware.content.setTempContent,
middleware.content.populateAll,
middleware.nodes.requireNodePermissions(security.roles.READER),
middleware.content.setEventFiltersFromTempContent,
middleware.event('parse'),
middleware.event('validate'),
middleware.content.setContentPayload,
middleware.event('out')
]);
return function(token){
return {
insert: function(content){
return coordinator.handle('content.insert', content, Kontx(token));
},
deleteById: function(id){
return coordinator.handle('content.deleteById', [id], Kontx(token));
},
getById: function(id){
return coordinator.handle('content.getById', {id:id}, Kontx(token));
},
getFullById: function(id){
return coordinator.handle('content.getFullById', {id:id}, Kontx(token));
},
query: function(criteria){
return coordinator.handle('content.query', criteria, Kontx(token));
},
queryFull: function(criteria){
return coordinator.handle('content.queryFull', criteria, Kontx(token));
},
update: function(content){
return coordinator.handle('content.update', content, Kontx(token));
},
list: function(options){
return coordinator.handle('content.list', [options], Kontx(token));
}
};
};
})();