@crombolo/content 0.73.0 → 0.74.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crombolo/content",
3
- "version": "0.73.0",
3
+ "version": "0.74.0",
4
4
  "description": "Internal to crombolo, with no compatibility promise: use @crombolo/crombolo. The rules every page, media and Library 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.73.0",
33
- "@crombolo/data": "0.73.0"
32
+ "@crombolo/core": "0.74.0",
33
+ "@crombolo/data": "0.74.0"
34
34
  }
35
35
  }
package/src/events.ts CHANGED
@@ -41,6 +41,8 @@ export type DocumentEvent =
41
41
  export interface EventSink {
42
42
  record(tx: Db, event: DocumentEvent, actor: Actor): Promise<void>
43
43
  afterCommit?(event: DocumentEvent, actor: Actor): void
44
+ /** Story 397: a publish in a person's own workspace merged its page, recorded as `changeId`. */
45
+ ownPublished?(tx: Db, published: { changeId: string; key: string }, actor: Actor): Promise<void>
44
46
  }
45
47
 
46
48
  /** A sink that hears nothing: for tests and tools that announce nothing. */
@@ -51,6 +53,9 @@ export const both = (...sinks: EventSink[]): EventSink => ({
51
53
  async record(tx, event, actor) {
52
54
  for (const sink of sinks) await sink.record(tx, event, actor)
53
55
  },
56
+ async ownPublished(tx, published, actor) {
57
+ for (const sink of sinks) await sink.ownPublished?.(tx, published, actor)
58
+ },
54
59
  afterCommit(event, actor) {
55
60
  for (const sink of sinks) sink.afterCommit?.(event, actor)
56
61
  },
@@ -397,6 +397,20 @@ export async function runWorkspaceMerge(
397
397
  }
398
398
  // Story 381: the merge is a change, its files and pages each with before and after.
399
399
  const changeId = await recordChange(tx, list, options, items, pages, merged)
400
+ // Story 400: each workspace the merge closed, announced with the change it made.
401
+ if (options.only === undefined) {
402
+ const made = await new ChangeRepository(tx).byId(changeId)
403
+ if (made)
404
+ for (const workspace of list)
405
+ await workspaces.announceMerged(
406
+ workspace.id,
407
+ { key: made.key, name: made.name },
408
+ options.userKey ?? null,
409
+ )
410
+ }
411
+ const alone = options.only === undefined ? undefined : merged[0]
412
+ if (alone?.published)
413
+ await options.events.ownPublished?.(tx, { changeId, key: alone.key }, options.actor)
400
414
  outcome = {
401
415
  ok: true,
402
416
  merged,