@crombolo/content 0.46.1 → 0.47.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 +3 -3
- package/src/operations.ts +23 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crombolo/content",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.47.0",
|
|
4
4
|
"description": "Internal to crombolo, with no compatibility promise: use @crombolo/crombolo. The rules every page and media write follows, whoever starts it: who may, where it may go, approvals, and what it announces. No transport.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Crombolo",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@crombolo/core": "0.
|
|
33
|
-
"@crombolo/data": "0.
|
|
32
|
+
"@crombolo/core": "0.47.0",
|
|
33
|
+
"@crombolo/data": "0.47.0"
|
|
34
34
|
}
|
|
35
35
|
}
|
package/src/operations.ts
CHANGED
|
@@ -1197,14 +1197,17 @@ export function createDocumentOperations(options: DocumentOperationsOptions) {
|
|
|
1197
1197
|
if (!(await isDocument(input.errorDocumentKey))) return 'error-node-not-found'
|
|
1198
1198
|
const saved = await commit(
|
|
1199
1199
|
actor,
|
|
1200
|
-
(_tx, txDb) =>
|
|
1201
|
-
new PublicAccessRepository(txDb).save({
|
|
1200
|
+
async (_tx, txDb) => {
|
|
1201
|
+
const done = await new PublicAccessRepository(txDb).save({
|
|
1202
1202
|
nodeKey: key,
|
|
1203
1203
|
loginNodeKey: input.loginDocumentKey,
|
|
1204
1204
|
errorNodeKey: input.errorDocumentKey,
|
|
1205
1205
|
memberGroupNames: input.memberGroupNames,
|
|
1206
1206
|
memberUserNames: input.memberUserNames,
|
|
1207
|
-
})
|
|
1207
|
+
})
|
|
1208
|
+
if (done) await accessInstruction(txDb)
|
|
1209
|
+
return done
|
|
1210
|
+
},
|
|
1208
1211
|
(done) => (done ? [{ type: 'publicAccessChanged', key, change }] : []),
|
|
1209
1212
|
)
|
|
1210
1213
|
if (!saved) return 'content-not-found'
|
|
@@ -1217,7 +1220,11 @@ export function createDocumentOperations(options: DocumentOperationsOptions) {
|
|
|
1217
1220
|
if (!(await permits(actor, 'publicAccess', key))) return 'forbidden'
|
|
1218
1221
|
const removed = await commit(
|
|
1219
1222
|
actor,
|
|
1220
|
-
(_tx, txDb) =>
|
|
1223
|
+
async (_tx, txDb) => {
|
|
1224
|
+
const done = await new PublicAccessRepository(txDb).remove(key)
|
|
1225
|
+
if (done) await accessInstruction(txDb)
|
|
1226
|
+
return done
|
|
1227
|
+
},
|
|
1221
1228
|
(done) => (done ? [{ type: 'publicAccessChanged', key, change: 'removed' }] : []),
|
|
1222
1229
|
)
|
|
1223
1230
|
if (!removed) return 'entry-not-found'
|
|
@@ -1234,6 +1241,18 @@ export function createDocumentOperations(options: DocumentOperationsOptions) {
|
|
|
1234
1241
|
return node?.objectType === repo.objectType
|
|
1235
1242
|
}
|
|
1236
1243
|
|
|
1244
|
+
/**
|
|
1245
|
+
* A page that leaves out what a visitor may not open changes with who may,
|
|
1246
|
+
* so a change to it moves the checkpoint, and every page's ETag (story 258).
|
|
1247
|
+
*/
|
|
1248
|
+
async function accessInstruction(on: Db): Promise<void> {
|
|
1249
|
+
await appendCacheInstruction(on, {
|
|
1250
|
+
kind: 'content',
|
|
1251
|
+
payload: { publicAccess: true },
|
|
1252
|
+
by: options.repository?.nodeId,
|
|
1253
|
+
})
|
|
1254
|
+
}
|
|
1255
|
+
|
|
1237
1256
|
/** The content cache instruction other nodes rebuild on. */
|
|
1238
1257
|
async function repoInstruction(key: string, on: Db = db): Promise<void> {
|
|
1239
1258
|
await appendCacheInstruction(on, {
|