@crombolo/server 0.35.2 → 0.36.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/package.json +12 -12
- package/src/config.ts +1 -1
- package/src/media-access.ts +21 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crombolo/server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.36.2",
|
|
4
4
|
"description": "Internal to crombolo, with no compatibility promise: use @crombolo/crombolo. The crombolo HTTP server: routing, configuration, media stores and background jobs.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Crombolo",
|
|
@@ -30,17 +30,17 @@
|
|
|
30
30
|
"access": "public"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@crombolo/api-delivery": "0.
|
|
34
|
-
"@crombolo/api-management": "0.
|
|
35
|
-
"@crombolo/auth": "0.
|
|
36
|
-
"@crombolo/backoffice-host": "0.
|
|
37
|
-
"@crombolo/content": "0.
|
|
38
|
-
"@crombolo/contracts": "0.
|
|
39
|
-
"@crombolo/core": "0.
|
|
40
|
-
"@crombolo/data": "0.
|
|
41
|
-
"@crombolo/render": "0.
|
|
42
|
-
"@crombolo/schema": "0.
|
|
43
|
-
"@crombolo/transfer": "0.
|
|
33
|
+
"@crombolo/api-delivery": "0.36.2",
|
|
34
|
+
"@crombolo/api-management": "0.36.2",
|
|
35
|
+
"@crombolo/auth": "0.36.2",
|
|
36
|
+
"@crombolo/backoffice-host": "0.36.2",
|
|
37
|
+
"@crombolo/content": "0.36.2",
|
|
38
|
+
"@crombolo/contracts": "0.36.2",
|
|
39
|
+
"@crombolo/core": "0.36.2",
|
|
40
|
+
"@crombolo/data": "0.36.2",
|
|
41
|
+
"@crombolo/render": "0.36.2",
|
|
42
|
+
"@crombolo/schema": "0.36.2",
|
|
43
|
+
"@crombolo/transfer": "0.36.2",
|
|
44
44
|
"@logtape/logtape": "^2.3.8",
|
|
45
45
|
"jose": "^6.2.12"
|
|
46
46
|
}
|
package/src/config.ts
CHANGED
|
@@ -839,7 +839,7 @@ export function describeDatabase(
|
|
|
839
839
|
}
|
|
840
840
|
}
|
|
841
841
|
|
|
842
|
-
export const VERSION = '0.
|
|
842
|
+
export const VERSION = '0.36.2'
|
|
843
843
|
|
|
844
844
|
/** A whole number of seconds from the environment; undefined when unset or not one. */
|
|
845
845
|
/** A positive number from a setting, else the default. */
|
package/src/media-access.ts
CHANGED
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
type Db,
|
|
32
32
|
type MediaAccessEntry,
|
|
33
33
|
type MediaAccessGroup,
|
|
34
|
+
type MediaAccessMember,
|
|
34
35
|
MediaAccessRepository,
|
|
35
36
|
type MediaByUrl,
|
|
36
37
|
MemberRepository,
|
|
@@ -66,6 +67,7 @@ const isUuid = (value: string) =>
|
|
|
66
67
|
interface RuleBody {
|
|
67
68
|
publicRead: boolean
|
|
68
69
|
groups: MediaAccessGroup[]
|
|
70
|
+
members?: MediaAccessMember[]
|
|
69
71
|
newRead: NewMediaRead | null
|
|
70
72
|
newWrite: NewMediaWrite | null
|
|
71
73
|
/** File types members may upload below (story 198); empty is none. */
|
|
@@ -77,6 +79,7 @@ interface RuleBody {
|
|
|
77
79
|
const ruleBody = (entry: MediaAccessEntry): RuleBody => ({
|
|
78
80
|
publicRead: entry.publicRead,
|
|
79
81
|
groups: entry.groups,
|
|
82
|
+
...(entry.members?.length ? { members: [...entry.members] } : {}),
|
|
80
83
|
newRead: entry.newRead,
|
|
81
84
|
newWrite: entry.newWrite,
|
|
82
85
|
memberTypes: entry.memberTypes,
|
|
@@ -95,11 +98,20 @@ export function parseRuleBody(raw: unknown): RuleBody | string {
|
|
|
95
98
|
parsed.push({ name: g.name.trim(), read: g.read === true, write: g.write === true })
|
|
96
99
|
}
|
|
97
100
|
const newRead = body.newRead ?? null
|
|
101
|
+
if (body.members !== undefined && !Array.isArray(body.members))
|
|
102
|
+
return 'Choose members from the member picker.'
|
|
103
|
+
const members: MediaAccessMember[] = []
|
|
104
|
+
for (const rawMember of (body.members ?? []) as unknown[]) {
|
|
105
|
+
const m = rawMember as Record<string, unknown> | null
|
|
106
|
+
if (!m || typeof m.key !== 'string' || !isUuid(m.key))
|
|
107
|
+
return 'Choose members from the member picker.'
|
|
108
|
+
members.push({ key: normaliseUuid(m.key), read: m.read === true, write: m.write === true })
|
|
109
|
+
}
|
|
98
110
|
if (newRead !== null && !NEW_MEDIA_READ.includes(newRead as NewMediaRead))
|
|
99
|
-
return 'Choose who may see new files
|
|
111
|
+
return 'Choose who may see new files.'
|
|
100
112
|
const newWrite = body.newWrite ?? null
|
|
101
113
|
if (newWrite !== null && !NEW_MEDIA_WRITE.includes(newWrite as NewMediaWrite))
|
|
102
|
-
return 'Choose who may change new files
|
|
114
|
+
return 'Choose who may change new files.'
|
|
103
115
|
const known = MEMBER_FILE_TYPES.map((type) => type.id)
|
|
104
116
|
const memberTypes = body.memberTypes ?? []
|
|
105
117
|
if (!Array.isArray(memberTypes) || memberTypes.some((t) => !known.includes(t as string)))
|
|
@@ -113,6 +125,7 @@ export function parseRuleBody(raw: unknown): RuleBody | string {
|
|
|
113
125
|
return {
|
|
114
126
|
publicRead: body.publicRead === true,
|
|
115
127
|
groups: parsed,
|
|
128
|
+
...(members.length ? { members } : {}),
|
|
116
129
|
newRead: newRead as NewMediaRead | null,
|
|
117
130
|
newWrite: newWrite as NewMediaWrite | null,
|
|
118
131
|
memberTypes: [...new Set(memberTypes as string[])],
|
|
@@ -221,6 +234,7 @@ export function createMediaAccess(deps: MediaAccessDeps) {
|
|
|
221
234
|
return {
|
|
222
235
|
key: node.key,
|
|
223
236
|
name: node.text ?? '',
|
|
237
|
+
hasParent: node.parentId > 0,
|
|
224
238
|
hasFile: Boolean(fileRows[0]?.file_url),
|
|
225
239
|
own: own ? ruleBody(own) : null,
|
|
226
240
|
inherited:
|
|
@@ -284,7 +298,11 @@ export function createMediaAccess(deps: MediaAccessDeps) {
|
|
|
284
298
|
const write = raw.writePolicy ?? 'inherit'
|
|
285
299
|
if (!MEDIA_POLICIES.includes(read as MediaPolicy))
|
|
286
300
|
return Response.json({ reason: 'Choose who may see this file.' }, { status: 400 })
|
|
287
|
-
if (
|
|
301
|
+
if (
|
|
302
|
+
!MEDIA_POLICIES.includes(write as MediaPolicy) ||
|
|
303
|
+
write === 'public' ||
|
|
304
|
+
write === 'members'
|
|
305
|
+
)
|
|
288
306
|
return Response.json({ reason: 'Choose who may change this file.' }, { status: 400 })
|
|
289
307
|
item = { readPolicy: read as MediaPolicy, writePolicy: write as MediaPolicy }
|
|
290
308
|
}
|