@crombolo/api-management 0.60.0 → 0.61.0
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/package.json +4 -4
- package/src/authorization.ts +27 -38
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crombolo/api-management",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.61.0",
|
|
4
4
|
"description": "Internal to crombolo, with no compatibility promise: use @crombolo/crombolo. Umbraco-compatible Management API handlers for crombolo.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Crombolo",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@crombolo/content": "0.
|
|
33
|
-
"@crombolo/contracts": "0.
|
|
34
|
-
"@crombolo/core": "0.
|
|
32
|
+
"@crombolo/content": "0.61.0",
|
|
33
|
+
"@crombolo/contracts": "0.61.0",
|
|
34
|
+
"@crombolo/core": "0.61.0"
|
|
35
35
|
}
|
|
36
36
|
}
|
package/src/authorization.ts
CHANGED
|
@@ -76,9 +76,6 @@ const CONTENT: Sections = ['content']
|
|
|
76
76
|
const MEDIA: Sections = ['media']
|
|
77
77
|
const SETTINGS: Sections = ['settings']
|
|
78
78
|
const USERS: Sections = ['users']
|
|
79
|
-
/** The parts of Settings a group can hold alone (story 296). */
|
|
80
|
-
const STRUCTURE: Sections = ['settings', 'structure']
|
|
81
|
-
const COMPONENTS: Sections = ['settings', 'components']
|
|
82
79
|
const MEMBERS: Sections = ['members']
|
|
83
80
|
const TRANSLATION: Sections = ['translation']
|
|
84
81
|
const LIBRARY: Sections = ['library']
|
|
@@ -89,16 +86,16 @@ const TREES: Record<string, Sections> = {
|
|
|
89
86
|
document: ANY_TREE,
|
|
90
87
|
media: ANY_TREE,
|
|
91
88
|
element: ANY_TREE,
|
|
92
|
-
'document-type':
|
|
93
|
-
'document-blueprint':
|
|
94
|
-
'data-type':
|
|
95
|
-
'media-type':
|
|
96
|
-
'member-type': ['settings', 'members'
|
|
97
|
-
template: ['settings', 'content'
|
|
89
|
+
'document-type': SETTINGS,
|
|
90
|
+
'document-blueprint': SETTINGS,
|
|
91
|
+
'data-type': SETTINGS,
|
|
92
|
+
'media-type': SETTINGS,
|
|
93
|
+
'member-type': ['settings', 'members'],
|
|
94
|
+
template: ['settings', 'content'],
|
|
98
95
|
dictionary: ['translation', 'settings'],
|
|
99
|
-
'partial-view':
|
|
100
|
-
script:
|
|
101
|
-
stylesheet:
|
|
96
|
+
'partial-view': SETTINGS,
|
|
97
|
+
script: SETTINGS,
|
|
98
|
+
stylesheet: SETTINGS,
|
|
102
99
|
'relation-type': SETTINGS,
|
|
103
100
|
'static-file': ['settings', 'content', 'media', 'members'],
|
|
104
101
|
'member-group': MEMBERS,
|
|
@@ -116,11 +113,11 @@ const SETTINGS_AREAS = new Set([
|
|
|
116
113
|
'telemetry',
|
|
117
114
|
'webhook',
|
|
118
115
|
'relation-type',
|
|
116
|
+
'partial-view',
|
|
117
|
+
'script',
|
|
118
|
+
'stylesheet',
|
|
119
119
|
])
|
|
120
120
|
|
|
121
|
-
/** What a group given Components can write. */
|
|
122
|
-
const COMPONENT_AREAS = new Set(['partial-view', 'script', 'stylesheet'])
|
|
123
|
-
|
|
124
121
|
/** Type actions only the Settings section may take, beyond every write. */
|
|
125
122
|
const TYPE_ADMIN_ACTIONS = new Set([
|
|
126
123
|
'configuration',
|
|
@@ -147,7 +144,6 @@ export function sectionRequirements(operation: OperationInfo): Array<Sections |
|
|
|
147
144
|
const action = second.startsWith('{') ? third : second
|
|
148
145
|
const typeAdmin = write || TYPE_ADMIN_ACTIONS.has(action)
|
|
149
146
|
if (SETTINGS_AREAS.has(area)) return [SETTINGS]
|
|
150
|
-
if (COMPONENT_AREAS.has(area)) return [COMPONENTS]
|
|
151
147
|
switch (area) {
|
|
152
148
|
case 'tree':
|
|
153
149
|
return TREES[second] ? [TREES[second]] : []
|
|
@@ -170,42 +166,35 @@ export function sectionRequirements(operation: OperationInfo): Array<Sections |
|
|
|
170
166
|
case 'dynamic-root':
|
|
171
167
|
return [CONTENT]
|
|
172
168
|
case 'document-type':
|
|
173
|
-
if (second === 'folder') return [
|
|
174
|
-
if (third === 'blueprint') return [['content', 'library', 'settings'
|
|
169
|
+
if (second === 'folder') return [SETTINGS]
|
|
170
|
+
if (third === 'blueprint') return [['content', 'library', 'settings'], CONTENT]
|
|
175
171
|
return typeAdmin
|
|
176
|
-
? [['content', 'library', 'settings'
|
|
177
|
-
: [['content', 'library', 'settings'
|
|
172
|
+
? [['content', 'library', 'settings'], SETTINGS]
|
|
173
|
+
: [['content', 'library', 'settings']]
|
|
178
174
|
case 'document-blueprint':
|
|
179
175
|
if (second === 'from-document' || third === 'scaffold') return [CONTENT]
|
|
180
|
-
if (!write && second.startsWith('{') && third === '')
|
|
181
|
-
|
|
182
|
-
return [STRUCTURE]
|
|
176
|
+
if (!write && second.startsWith('{') && third === '') return [['content', 'settings']]
|
|
177
|
+
return [SETTINGS]
|
|
183
178
|
case 'data-type':
|
|
184
|
-
if (second === 'folder') return [
|
|
179
|
+
if (second === 'folder') return [SETTINGS]
|
|
185
180
|
return typeAdmin
|
|
186
|
-
? [['content', 'library', 'media', 'members', 'settings'
|
|
187
|
-
: [['content', 'library', 'media', 'members', 'settings'
|
|
181
|
+
? [['content', 'library', 'media', 'members', 'settings'], SETTINGS]
|
|
182
|
+
: [['content', 'library', 'media', 'members', 'settings']]
|
|
188
183
|
case 'media':
|
|
189
184
|
return [MEDIA]
|
|
190
185
|
case 'media-type':
|
|
191
|
-
if (second === 'folder') return [
|
|
192
|
-
return typeAdmin
|
|
193
|
-
? [['media', 'settings', 'structure'], STRUCTURE]
|
|
194
|
-
: [['media', 'settings', 'structure']]
|
|
186
|
+
if (second === 'folder') return [SETTINGS]
|
|
187
|
+
return typeAdmin ? [['media', 'settings'], SETTINGS] : [['media', 'settings']]
|
|
195
188
|
case 'member-type':
|
|
196
|
-
if (second === 'folder') return [
|
|
197
|
-
return typeAdmin
|
|
198
|
-
? [['settings', 'members', 'structure'], STRUCTURE]
|
|
199
|
-
: [['settings', 'members', 'structure']]
|
|
189
|
+
if (second === 'folder') return [SETTINGS]
|
|
190
|
+
return typeAdmin ? [['settings', 'members'], SETTINGS] : [['settings', 'members']]
|
|
200
191
|
case 'member':
|
|
201
192
|
case 'member-group':
|
|
202
193
|
return [MEMBERS]
|
|
203
194
|
case 'template':
|
|
204
|
-
return write
|
|
205
|
-
? [['settings', 'content', 'components'], COMPONENTS]
|
|
206
|
-
: [['settings', 'content', 'components']]
|
|
195
|
+
return write ? [['settings', 'content'], SETTINGS] : [['settings', 'content']]
|
|
207
196
|
case 'language':
|
|
208
|
-
return write ? [
|
|
197
|
+
return write ? [SETTINGS] : []
|
|
209
198
|
case 'dictionary':
|
|
210
199
|
return [TRANSLATION]
|
|
211
200
|
case 'user':
|