@crombolo/content 0.77.0 → 0.79.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/actor.ts +4 -0
- package/src/events.ts +9 -2
- package/src/operations.ts +13 -1
- package/src/workspace-merge-run.ts +15 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crombolo/content",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.79.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.
|
|
33
|
-
"@crombolo/data": "0.
|
|
32
|
+
"@crombolo/core": "0.79.0",
|
|
33
|
+
"@crombolo/data": "0.79.0"
|
|
34
34
|
}
|
|
35
35
|
}
|
package/src/actor.ts
CHANGED
|
@@ -59,6 +59,8 @@ export type Actor =
|
|
|
59
59
|
note?: string
|
|
60
60
|
/** Story 414: the change whose schedule it carries out. */
|
|
61
61
|
change?: { key: string; name: string | null }
|
|
62
|
+
/** Story 413: the approval it carries out: the editor who asked, and the workflow. */
|
|
63
|
+
approval?: { editorKey: string; workflow: string }
|
|
62
64
|
}
|
|
63
65
|
|
|
64
66
|
/**
|
|
@@ -115,6 +117,7 @@ export const systemActor = (
|
|
|
115
117
|
user?: { id: string; name: string }
|
|
116
118
|
note?: string
|
|
117
119
|
change?: { key: string; name: string | null }
|
|
120
|
+
approval?: { editorKey: string; workflow: string }
|
|
118
121
|
} = {},
|
|
119
122
|
): Actor => ({
|
|
120
123
|
kind: 'system',
|
|
@@ -123,6 +126,7 @@ export const systemActor = (
|
|
|
123
126
|
user: options.user,
|
|
124
127
|
note: options.note,
|
|
125
128
|
...(options.change ? { change: options.change } : {}),
|
|
129
|
+
...(options.approval ? { approval: options.approval } : {}),
|
|
126
130
|
})
|
|
127
131
|
|
|
128
132
|
/** The name an audit entry or a notification gives the actor. */
|
package/src/events.ts
CHANGED
|
@@ -13,7 +13,8 @@ export type DocumentEvent =
|
|
|
13
13
|
| { type: 'saved'; key: string }
|
|
14
14
|
| { type: 'createdAndPublished'; key: string; cultures: readonly string[] | null }
|
|
15
15
|
| { type: 'savedAndPublished'; key: string; cultures: readonly string[] | null }
|
|
16
|
-
|
|
16
|
+
/** `scheduled`: it set or cleared a time as well (story 417). */
|
|
17
|
+
| { type: 'published'; key: string; cultures: readonly string[] | null; scheduled?: true }
|
|
17
18
|
/** Only scheduled: nothing is published until the schedule fires. */
|
|
18
19
|
| { type: 'scheduled'; key: string }
|
|
19
20
|
/** A page and the pages below it: `published` names each one that went live. */
|
|
@@ -52,8 +53,14 @@ export interface EventSink {
|
|
|
52
53
|
changeId: string
|
|
53
54
|
key: string
|
|
54
55
|
/** Story 411: what the page's merge did, other than a publish. */
|
|
55
|
-
kind?: 'unpublish' | 'move' | 'reorder' | 'delete'
|
|
56
|
+
kind?: 'unpublish' | 'move' | 'reorder' | 'delete' | 'schedule'
|
|
56
57
|
page?: { key: string; name: string | null }
|
|
58
|
+
/** Story 417: the times the merge set, per language, in UTC; empty when cleared. */
|
|
59
|
+
schedule?: ReadonlyArray<{
|
|
60
|
+
culture: string | null
|
|
61
|
+
publishTime: string | null
|
|
62
|
+
unpublishTime: string | null
|
|
63
|
+
}>
|
|
57
64
|
},
|
|
58
65
|
actor: Actor,
|
|
59
66
|
): Promise<void>
|
package/src/operations.ts
CHANGED
|
@@ -756,6 +756,10 @@ export function createDocumentOperations(options: DocumentOperationsOptions) {
|
|
|
756
756
|
? immediate.flatMap((s) => (s.culture === null ? [] : [s.culture]))
|
|
757
757
|
: request.cultures
|
|
758
758
|
const before = scheduledOnly ? undefined : await options.redirects?.capture(key)
|
|
759
|
+
// Story 417: a time given, or one there to clear; a plain publish sends neither.
|
|
760
|
+
const touchesSchedule =
|
|
761
|
+
schedules.some((s) => s.publishTime !== null || s.unpublishTime !== null) ||
|
|
762
|
+
(schedules.length > 0 && (await repo.schedules(key)).length > 0)
|
|
759
763
|
// The schedule and the publish are one change: neither lands without the other.
|
|
760
764
|
const published = await commit(
|
|
761
765
|
actor,
|
|
@@ -775,7 +779,15 @@ export function createDocumentOperations(options: DocumentOperationsOptions) {
|
|
|
775
779
|
done === 'scheduled'
|
|
776
780
|
? [{ type: 'scheduled', key }]
|
|
777
781
|
: done
|
|
778
|
-
? [
|
|
782
|
+
? [
|
|
783
|
+
{
|
|
784
|
+
type: 'published',
|
|
785
|
+
key,
|
|
786
|
+
cultures,
|
|
787
|
+
// Story 417: it set or cleared a time too, for its change to carry.
|
|
788
|
+
...(touchesSchedule ? { scheduled: true } : {}),
|
|
789
|
+
},
|
|
790
|
+
]
|
|
779
791
|
: [],
|
|
780
792
|
)
|
|
781
793
|
if (published === 'scheduled') {
|
|
@@ -533,9 +533,21 @@ export async function runWorkspaceMerge(
|
|
|
533
533
|
},
|
|
534
534
|
options.actor,
|
|
535
535
|
)
|
|
536
|
-
} else if (alone && (alone.published || scheduled.includes(alone.key)))
|
|
537
|
-
// Story 414: a page only scheduled is announced as one published is
|
|
538
|
-
|
|
536
|
+
} else if (alone && (alone.published || scheduled.includes(alone.key))) {
|
|
537
|
+
// Story 414: a page only scheduled is announced as one published is; story 417:
|
|
538
|
+
// saying so, with its times, and a publish that set a time carrying them.
|
|
539
|
+
const times = schedules.flat().find((p) => p.key === alone.key)?.entries
|
|
540
|
+
await options.events.ownPublished?.(
|
|
541
|
+
tx,
|
|
542
|
+
{
|
|
543
|
+
changeId,
|
|
544
|
+
key: alone.key,
|
|
545
|
+
...(alone.published ? {} : { kind: 'schedule' as const }),
|
|
546
|
+
...(times ? { schedule: times } : {}),
|
|
547
|
+
},
|
|
548
|
+
options.actor,
|
|
549
|
+
)
|
|
550
|
+
}
|
|
539
551
|
outcome = {
|
|
540
552
|
ok: true,
|
|
541
553
|
merged,
|