@echovisionlab/geul-telemetry 0.1.2 → 0.1.3
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/README.md +7 -0
- package/package.json +1 -1
- package/src/audit/content-shared.ts +184 -0
- package/src/audit/content.ts +43 -691
- package/src/audit/page.ts +137 -0
- package/src/audit/post.ts +263 -0
- package/src/audit/work.ts +183 -0
package/src/audit/content.ts
CHANGED
|
@@ -1,389 +1,47 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
AuditItemOperation,
|
|
4
|
-
AuditRecord,
|
|
5
|
-
AuditRelationship,
|
|
6
|
-
AuditState,
|
|
7
|
-
} from "../records.ts";
|
|
1
|
+
import type { AuditRecord } from "../records.ts";
|
|
2
|
+
import { requireCatalogTarget } from "./catalog.ts";
|
|
8
3
|
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
type
|
|
12
|
-
} from "./
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
"comments_enabled",
|
|
51
|
-
"document_layout",
|
|
52
|
-
"map_place_id",
|
|
53
|
-
"slug",
|
|
54
|
-
]);
|
|
55
|
-
const pageConfigurationFields = new Set<PageConfigurationField>([
|
|
56
|
-
"document_layout",
|
|
57
|
-
"show_title",
|
|
58
|
-
"slug",
|
|
59
|
-
]);
|
|
60
|
-
const workMetadataFields = new Set<WorkMetadataField>([
|
|
61
|
-
"clients",
|
|
62
|
-
"featured",
|
|
63
|
-
"is_present",
|
|
64
|
-
"map_place_id",
|
|
65
|
-
"metadata",
|
|
66
|
-
"month",
|
|
67
|
-
"slug",
|
|
68
|
-
"type",
|
|
69
|
-
"until_month",
|
|
70
|
-
"until_year",
|
|
71
|
-
"year",
|
|
72
|
-
]);
|
|
73
|
-
|
|
74
|
-
function buildContentAuditRecord(
|
|
75
|
-
metadata: AuditMetadata,
|
|
76
|
-
action: ContentAction,
|
|
77
|
-
targetId: string,
|
|
78
|
-
attributes: Parameters<typeof buildAuditRecord>[2] = {},
|
|
79
|
-
): AuditRecord {
|
|
80
|
-
return buildAuditRecord(
|
|
81
|
-
metadata,
|
|
82
|
-
{ action, target_type: AUDIT_CATALOG[action], target_id: targetId },
|
|
83
|
-
attributes,
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function requireFields(
|
|
88
|
-
record: AuditRecord,
|
|
89
|
-
allowed: ReadonlySet<string>,
|
|
90
|
-
): readonly string[] {
|
|
91
|
-
const fields = record.changed_fields;
|
|
92
|
-
if (
|
|
93
|
-
!fields?.length ||
|
|
94
|
-
fields.some(
|
|
95
|
-
(field, i) => !allowed.has(field) || (i > 0 && fields[i - 1] >= field),
|
|
96
|
-
)
|
|
97
|
-
) {
|
|
98
|
-
throw new TypeError("invalid or non-canonical changed_fields");
|
|
99
|
-
}
|
|
100
|
-
return fields;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function requireIdentifier(name: string, value: string | undefined): void {
|
|
104
|
-
if (!value || value.length > 255 || value.trim() !== value) {
|
|
105
|
-
throw new TypeError(`${name} requires an identifier`);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function requireOnly(
|
|
110
|
-
record: AuditRecord,
|
|
111
|
-
allowed: readonly AuditRecordAttributeName[],
|
|
112
|
-
): void {
|
|
113
|
-
assertOnlyAuditAttributes(record, allowed);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function requireVersion(record: AuditRecord): void {
|
|
117
|
-
if (!record.version_id || !record.contributor_member_ids?.length) {
|
|
118
|
-
throw new TypeError(
|
|
119
|
-
"version requires version_id and contributor_member_ids",
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
if (
|
|
123
|
-
record.contributor_member_ids.some(
|
|
124
|
-
(id, i) =>
|
|
125
|
-
!/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(
|
|
126
|
-
id,
|
|
127
|
-
) ||
|
|
128
|
-
(i > 0 && record.contributor_member_ids![i - 1] >= id),
|
|
129
|
-
)
|
|
130
|
-
) {
|
|
131
|
-
throw new TypeError("version requires sorted unique UUIDv4 contributors");
|
|
132
|
-
}
|
|
133
|
-
requireOnly(record, [
|
|
134
|
-
"changed_fields",
|
|
135
|
-
"version_id",
|
|
136
|
-
"contributor_member_ids",
|
|
137
|
-
]);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
function requireContentVersionActor(record: AuditRecord): void {
|
|
141
|
-
const version =
|
|
142
|
-
record.changed_fields?.length === 1 &&
|
|
143
|
-
record.changed_fields[0] === "version";
|
|
144
|
-
if (version) {
|
|
145
|
-
if (
|
|
146
|
-
record.actor_kind !== "system" ||
|
|
147
|
-
record.actor_service !== "geul-collab"
|
|
148
|
-
)
|
|
149
|
-
throw new TypeError("content version requires geul-collab system actor");
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
if (record.actor_kind === "system") {
|
|
153
|
-
throw new TypeError(
|
|
154
|
-
"content system actor is limited to geul-collab version checkpoints",
|
|
155
|
-
);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
function requireStateTransition(
|
|
160
|
-
record: AuditRecord,
|
|
161
|
-
allowed: readonly AuditState[],
|
|
162
|
-
): void {
|
|
163
|
-
if (
|
|
164
|
-
!record.previous_state ||
|
|
165
|
-
!record.new_state ||
|
|
166
|
-
record.previous_state === record.new_state ||
|
|
167
|
-
!allowed.includes(record.previous_state) ||
|
|
168
|
-
!allowed.includes(record.new_state)
|
|
169
|
-
) {
|
|
170
|
-
throw new TypeError("lifecycle requires an allowed state transition");
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
function requireShareLink(record: AuditRecord): void {
|
|
175
|
-
if (
|
|
176
|
-
record.item_operation !== "created" &&
|
|
177
|
-
record.item_operation !== "deleted"
|
|
178
|
-
) {
|
|
179
|
-
throw new TypeError(
|
|
180
|
-
"share link requires created or deleted item operation",
|
|
181
|
-
);
|
|
182
|
-
}
|
|
183
|
-
requireIdentifier("item_id", record.item_id);
|
|
184
|
-
requireOnly(record, ["changed_fields", "item_operation", "item_id"]);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
function requireFeaturedImage(
|
|
188
|
-
record: AuditRecord,
|
|
189
|
-
attribute: "asset_id" | "file_id",
|
|
190
|
-
): void {
|
|
191
|
-
if (
|
|
192
|
-
record.collection_operation !== "added" &&
|
|
193
|
-
record.collection_operation !== "removed"
|
|
194
|
-
) {
|
|
195
|
-
throw new TypeError("featured image requires a binding operation");
|
|
196
|
-
}
|
|
197
|
-
requireIdentifier(attribute, record[attribute]);
|
|
198
|
-
requireOnly(record, ["changed_fields", "collection_operation", attribute]);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
function requireVersionRestore(record: AuditRecord): void {
|
|
202
|
-
requireIdentifier("version_id", record.version_id);
|
|
203
|
-
requireOnly(record, ["changed_fields", "version_id"]);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
function postParticipantFields(
|
|
207
|
-
previous: AuditRelationship,
|
|
208
|
-
next: AuditRelationship,
|
|
209
|
-
): readonly ("authors" | "collaborators")[] {
|
|
210
|
-
const valid = new Set<AuditRelationship>(["none", "author", "collaborator"]);
|
|
211
|
-
if (!valid.has(previous) || !valid.has(next) || previous === next) {
|
|
212
|
-
throw new TypeError(
|
|
213
|
-
"post participant requires a distinct author/collaborator transition",
|
|
214
|
-
);
|
|
215
|
-
}
|
|
216
|
-
if (previous === "author" || next === "author") {
|
|
217
|
-
if (previous === "collaborator" || next === "collaborator") {
|
|
218
|
-
return ["authors", "collaborators"];
|
|
219
|
-
}
|
|
220
|
-
return ["authors"];
|
|
221
|
-
}
|
|
222
|
-
return ["collaborators"];
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
function requirePostParticipant(record: AuditRecord): void {
|
|
226
|
-
const previous = record.previous_relationship;
|
|
227
|
-
const next = record.new_relationship;
|
|
228
|
-
if (previous === undefined || next === undefined) {
|
|
229
|
-
throw new TypeError("post participant requires relationships");
|
|
230
|
-
}
|
|
231
|
-
const fields = postParticipantFields(previous, next);
|
|
232
|
-
if (
|
|
233
|
-
record.changed_fields?.length !== fields.length ||
|
|
234
|
-
record.changed_fields.some((field, i) => field !== fields[i])
|
|
235
|
-
) {
|
|
236
|
-
throw new TypeError(
|
|
237
|
-
"post participant changed_fields must match the relationship transition",
|
|
238
|
-
);
|
|
239
|
-
}
|
|
240
|
-
requireIdentifier("subject_member_id", record.subject_member_id);
|
|
241
|
-
requireOnly(record, [
|
|
242
|
-
"changed_fields",
|
|
243
|
-
"subject_member_id",
|
|
244
|
-
"previous_relationship",
|
|
245
|
-
"new_relationship",
|
|
246
|
-
]);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
function requirePostUpdate(record: AuditRecord): void {
|
|
250
|
-
if (isRelationDownloadPolicyAuditRecord(record))
|
|
251
|
-
return validateRelationDownloadPolicyAuditRecord(record);
|
|
252
|
-
if (record.changed_fields?.length === 1) {
|
|
253
|
-
switch (record.changed_fields[0]) {
|
|
254
|
-
case "version":
|
|
255
|
-
return requireVersion(record);
|
|
256
|
-
case "featured_image":
|
|
257
|
-
return requireFeaturedImage(record, "asset_id");
|
|
258
|
-
case "share_links":
|
|
259
|
-
return requireShareLink(record);
|
|
260
|
-
case "version_restore":
|
|
261
|
-
return requireVersionRestore(record);
|
|
262
|
-
case "comments": {
|
|
263
|
-
if (record.actor_kind !== "member") {
|
|
264
|
-
throw new TypeError("post comment requires a member actor");
|
|
265
|
-
}
|
|
266
|
-
if (
|
|
267
|
-
!record.item_operation ||
|
|
268
|
-
!["created", "updated", "deleted"].includes(record.item_operation)
|
|
269
|
-
) {
|
|
270
|
-
throw new TypeError("post comment requires an item operation");
|
|
271
|
-
}
|
|
272
|
-
requireIdentifier("item_id", record.item_id);
|
|
273
|
-
requireOnly(record, ["changed_fields", "item_operation", "item_id"]);
|
|
274
|
-
return;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
if (
|
|
279
|
-
record.changed_fields?.includes("authors") ||
|
|
280
|
-
record.changed_fields?.includes("collaborators")
|
|
281
|
-
) {
|
|
282
|
-
return requirePostParticipant(record);
|
|
283
|
-
}
|
|
284
|
-
const fields = requireFields(
|
|
285
|
-
record,
|
|
286
|
-
new Set([...postConfigurationFields, "schedule", "status"]),
|
|
287
|
-
);
|
|
288
|
-
const lifecycle = fields.includes("schedule") || fields.includes("status");
|
|
289
|
-
if (!lifecycle) return requireOnly(record, ["changed_fields"]);
|
|
290
|
-
requireStateTransition(record, [
|
|
291
|
-
"draft",
|
|
292
|
-
"scheduled",
|
|
293
|
-
"published",
|
|
294
|
-
"archived",
|
|
295
|
-
]);
|
|
296
|
-
if (fields.includes("schedule")) {
|
|
297
|
-
if (
|
|
298
|
-
!record.scheduled_at ||
|
|
299
|
-
Number.isNaN(Date.parse(record.scheduled_at)) ||
|
|
300
|
-
!record.scheduled_time_zone
|
|
301
|
-
) {
|
|
302
|
-
throw new TypeError(
|
|
303
|
-
"post schedule requires scheduled_at and scheduled_time_zone",
|
|
304
|
-
);
|
|
305
|
-
}
|
|
306
|
-
} else if (
|
|
307
|
-
record.scheduled_at !== undefined ||
|
|
308
|
-
record.scheduled_time_zone !== undefined
|
|
309
|
-
) {
|
|
310
|
-
throw new TypeError(
|
|
311
|
-
"post schedule attributes require changed_fields schedule",
|
|
312
|
-
);
|
|
313
|
-
}
|
|
314
|
-
requireOnly(record, [
|
|
315
|
-
"changed_fields",
|
|
316
|
-
"previous_state",
|
|
317
|
-
"new_state",
|
|
318
|
-
"scheduled_at",
|
|
319
|
-
"scheduled_time_zone",
|
|
320
|
-
]);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
function requirePageUpdate(record: AuditRecord): void {
|
|
324
|
-
if (isRelationDownloadPolicyAuditRecord(record))
|
|
325
|
-
return validateRelationDownloadPolicyAuditRecord(record);
|
|
326
|
-
if (record.changed_fields?.length === 1) {
|
|
327
|
-
switch (record.changed_fields[0]) {
|
|
328
|
-
case "version":
|
|
329
|
-
return requireVersion(record);
|
|
330
|
-
case "featured_image":
|
|
331
|
-
return requireFeaturedImage(record, "asset_id");
|
|
332
|
-
case "share_links":
|
|
333
|
-
return requireShareLink(record);
|
|
334
|
-
case "version_restore":
|
|
335
|
-
return requireVersionRestore(record);
|
|
336
|
-
case "status":
|
|
337
|
-
requireStateTransition(record, ["draft", "published"]);
|
|
338
|
-
return requireOnly(record, [
|
|
339
|
-
"changed_fields",
|
|
340
|
-
"previous_state",
|
|
341
|
-
"new_state",
|
|
342
|
-
]);
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
requireFields(record, pageConfigurationFields);
|
|
346
|
-
requireOnly(record, ["changed_fields"]);
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
function requireWorkUpdate(record: AuditRecord): void {
|
|
350
|
-
if (isRelationDownloadPolicyAuditRecord(record))
|
|
351
|
-
return validateRelationDownloadPolicyAuditRecord(record);
|
|
352
|
-
if (record.changed_fields?.length === 1) {
|
|
353
|
-
switch (record.changed_fields[0]) {
|
|
354
|
-
case "version":
|
|
355
|
-
return requireVersion(record);
|
|
356
|
-
case "featured_image":
|
|
357
|
-
return requireFeaturedImage(record, "asset_id");
|
|
358
|
-
case "share_links":
|
|
359
|
-
return requireShareLink(record);
|
|
360
|
-
case "version_restore":
|
|
361
|
-
return requireVersionRestore(record);
|
|
362
|
-
case "status":
|
|
363
|
-
requireStateTransition(record, ["draft", "published", "archived"]);
|
|
364
|
-
return requireOnly(record, [
|
|
365
|
-
"changed_fields",
|
|
366
|
-
"previous_state",
|
|
367
|
-
"new_state",
|
|
368
|
-
]);
|
|
369
|
-
case "credits":
|
|
370
|
-
if (
|
|
371
|
-
!record.item_operation ||
|
|
372
|
-
!["created", "updated", "deleted"].includes(record.item_operation)
|
|
373
|
-
) {
|
|
374
|
-
throw new TypeError("work credit requires an item operation");
|
|
375
|
-
}
|
|
376
|
-
requireIdentifier("item_id", record.item_id);
|
|
377
|
-
return requireOnly(record, [
|
|
378
|
-
"changed_fields",
|
|
379
|
-
"item_operation",
|
|
380
|
-
"item_id",
|
|
381
|
-
]);
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
requireFields(record, workMetadataFields);
|
|
385
|
-
requireOnly(record, ["changed_fields"]);
|
|
386
|
-
}
|
|
4
|
+
requireContentVersionActor,
|
|
5
|
+
requireOnly,
|
|
6
|
+
type ContentTarget,
|
|
7
|
+
} from "./content-shared.ts";
|
|
8
|
+
import { requirePostUpdate } from "./post.ts";
|
|
9
|
+
import { requirePageUpdate } from "./page.ts";
|
|
10
|
+
import { requireWorkUpdate } from "./work.ts";
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
buildPostCommentAuditRecord,
|
|
14
|
+
buildPostConfigurationAuditRecord,
|
|
15
|
+
buildPostCreatedAuditRecord,
|
|
16
|
+
buildPostDeletedAuditRecord,
|
|
17
|
+
buildPostFeaturedImageAuditRecord,
|
|
18
|
+
buildPostLifecycleAuditRecord,
|
|
19
|
+
buildPostParticipantAuditRecord,
|
|
20
|
+
buildPostShareLinkAuditRecord,
|
|
21
|
+
buildPostVersionCreatedAuditRecord,
|
|
22
|
+
buildPostVersionRestoreAuditRecord,
|
|
23
|
+
} from "./post.ts";
|
|
24
|
+
export {
|
|
25
|
+
buildPageConfigurationAuditRecord,
|
|
26
|
+
buildPageCreatedAuditRecord,
|
|
27
|
+
buildPageDeletedAuditRecord,
|
|
28
|
+
buildPageFeaturedImageAuditRecord,
|
|
29
|
+
buildPageLifecycleAuditRecord,
|
|
30
|
+
buildPageShareLinkAuditRecord,
|
|
31
|
+
buildPageVersionCreatedAuditRecord,
|
|
32
|
+
buildPageVersionRestoreAuditRecord,
|
|
33
|
+
} from "./page.ts";
|
|
34
|
+
export {
|
|
35
|
+
buildWorkCreatedAuditRecord,
|
|
36
|
+
buildWorkCreditAuditRecord,
|
|
37
|
+
buildWorkDeletedAuditRecord,
|
|
38
|
+
buildWorkFeaturedImageAuditRecord,
|
|
39
|
+
buildWorkLifecycleAuditRecord,
|
|
40
|
+
buildWorkMetadataAuditRecord,
|
|
41
|
+
buildWorkShareLinkAuditRecord,
|
|
42
|
+
buildWorkVersionCreatedAuditRecord,
|
|
43
|
+
buildWorkVersionRestoreAuditRecord,
|
|
44
|
+
} from "./work.ts";
|
|
387
45
|
|
|
388
46
|
/** Returns true only for Post, Page, and Work catalog actions. */
|
|
389
47
|
export function validateContentAuditRecord(record: AuditRecord): boolean {
|
|
@@ -415,309 +73,3 @@ export function validateContentAuditRecord(record: AuditRecord): boolean {
|
|
|
415
73
|
}
|
|
416
74
|
return true;
|
|
417
75
|
}
|
|
418
|
-
|
|
419
|
-
function buildVersionCreatedAuditRecord(
|
|
420
|
-
metadata: AuditMetadata,
|
|
421
|
-
action: Extract<
|
|
422
|
-
ContentAction,
|
|
423
|
-
"post.updated" | "page.updated" | "work.updated"
|
|
424
|
-
>,
|
|
425
|
-
targetId: string,
|
|
426
|
-
versionId: string,
|
|
427
|
-
contributorMemberIds: readonly string[],
|
|
428
|
-
): AuditRecord {
|
|
429
|
-
return buildContentAuditRecord(metadata, action, targetId, {
|
|
430
|
-
changed_fields: ["version"],
|
|
431
|
-
version_id: versionId,
|
|
432
|
-
contributor_member_ids: canonicalAuditValues(contributorMemberIds),
|
|
433
|
-
});
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
export function buildPostVersionCreatedAuditRecord(
|
|
437
|
-
m: AuditMetadata,
|
|
438
|
-
id: string,
|
|
439
|
-
version: string,
|
|
440
|
-
contributors: readonly string[],
|
|
441
|
-
): AuditRecord {
|
|
442
|
-
return buildVersionCreatedAuditRecord(
|
|
443
|
-
m,
|
|
444
|
-
"post.updated",
|
|
445
|
-
id,
|
|
446
|
-
version,
|
|
447
|
-
contributors,
|
|
448
|
-
);
|
|
449
|
-
}
|
|
450
|
-
export function buildPageVersionCreatedAuditRecord(
|
|
451
|
-
m: AuditMetadata,
|
|
452
|
-
id: string,
|
|
453
|
-
version: string,
|
|
454
|
-
contributors: readonly string[],
|
|
455
|
-
): AuditRecord {
|
|
456
|
-
return buildVersionCreatedAuditRecord(
|
|
457
|
-
m,
|
|
458
|
-
"page.updated",
|
|
459
|
-
id,
|
|
460
|
-
version,
|
|
461
|
-
contributors,
|
|
462
|
-
);
|
|
463
|
-
}
|
|
464
|
-
export function buildWorkVersionCreatedAuditRecord(
|
|
465
|
-
m: AuditMetadata,
|
|
466
|
-
id: string,
|
|
467
|
-
version: string,
|
|
468
|
-
contributors: readonly string[],
|
|
469
|
-
): AuditRecord {
|
|
470
|
-
return buildVersionCreatedAuditRecord(
|
|
471
|
-
m,
|
|
472
|
-
"work.updated",
|
|
473
|
-
id,
|
|
474
|
-
version,
|
|
475
|
-
contributors,
|
|
476
|
-
);
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
export function buildPostConfigurationAuditRecord(
|
|
480
|
-
m: AuditMetadata,
|
|
481
|
-
id: string,
|
|
482
|
-
fields: readonly PostConfigurationField[],
|
|
483
|
-
): AuditRecord {
|
|
484
|
-
return buildContentAuditRecord(m, "post.updated", id, {
|
|
485
|
-
changed_fields: canonicalAuditValues(fields),
|
|
486
|
-
});
|
|
487
|
-
}
|
|
488
|
-
export function buildPostLifecycleAuditRecord(
|
|
489
|
-
m: AuditMetadata,
|
|
490
|
-
id: string,
|
|
491
|
-
fields: readonly ("schedule" | "status")[],
|
|
492
|
-
previous: AuditState,
|
|
493
|
-
next: AuditState,
|
|
494
|
-
scheduledAt?: string,
|
|
495
|
-
scheduledTimeZone?: string,
|
|
496
|
-
): AuditRecord {
|
|
497
|
-
return buildContentAuditRecord(m, "post.updated", id, {
|
|
498
|
-
changed_fields: canonicalAuditValues(fields),
|
|
499
|
-
previous_state: previous,
|
|
500
|
-
new_state: next,
|
|
501
|
-
scheduled_at: scheduledAt,
|
|
502
|
-
scheduled_time_zone: scheduledTimeZone,
|
|
503
|
-
});
|
|
504
|
-
}
|
|
505
|
-
export function buildPostFeaturedImageAuditRecord(
|
|
506
|
-
m: AuditMetadata,
|
|
507
|
-
id: string,
|
|
508
|
-
assetId: string,
|
|
509
|
-
operation: AuditCollectionOperation,
|
|
510
|
-
): AuditRecord {
|
|
511
|
-
return buildContentAuditRecord(m, "post.updated", id, {
|
|
512
|
-
changed_fields: ["featured_image"],
|
|
513
|
-
asset_id: assetId,
|
|
514
|
-
collection_operation: operation,
|
|
515
|
-
});
|
|
516
|
-
}
|
|
517
|
-
export function buildPostParticipantAuditRecord(
|
|
518
|
-
m: AuditMetadata,
|
|
519
|
-
id: string,
|
|
520
|
-
memberId: string,
|
|
521
|
-
previous: AuditRelationship,
|
|
522
|
-
next: AuditRelationship,
|
|
523
|
-
): AuditRecord {
|
|
524
|
-
return buildContentAuditRecord(m, "post.updated", id, {
|
|
525
|
-
changed_fields: postParticipantFields(previous, next),
|
|
526
|
-
subject_member_id: memberId,
|
|
527
|
-
previous_relationship: previous,
|
|
528
|
-
new_relationship: next,
|
|
529
|
-
});
|
|
530
|
-
}
|
|
531
|
-
export function buildPostShareLinkAuditRecord(
|
|
532
|
-
m: AuditMetadata,
|
|
533
|
-
id: string,
|
|
534
|
-
itemId: string,
|
|
535
|
-
operation: Extract<AuditItemOperation, "created" | "deleted">,
|
|
536
|
-
): AuditRecord {
|
|
537
|
-
return buildContentAuditRecord(m, "post.updated", id, {
|
|
538
|
-
changed_fields: ["share_links"],
|
|
539
|
-
item_id: itemId,
|
|
540
|
-
item_operation: operation,
|
|
541
|
-
});
|
|
542
|
-
}
|
|
543
|
-
export function buildPostCommentAuditRecord(
|
|
544
|
-
m: AuditMetadata,
|
|
545
|
-
id: string,
|
|
546
|
-
itemId: string,
|
|
547
|
-
operation: AuditItemOperation,
|
|
548
|
-
): AuditRecord {
|
|
549
|
-
return buildContentAuditRecord(m, "post.updated", id, {
|
|
550
|
-
changed_fields: ["comments"],
|
|
551
|
-
item_id: itemId,
|
|
552
|
-
item_operation: operation,
|
|
553
|
-
});
|
|
554
|
-
}
|
|
555
|
-
export function buildPostVersionRestoreAuditRecord(
|
|
556
|
-
m: AuditMetadata,
|
|
557
|
-
id: string,
|
|
558
|
-
versionId: string,
|
|
559
|
-
): AuditRecord {
|
|
560
|
-
return buildContentAuditRecord(m, "post.updated", id, {
|
|
561
|
-
changed_fields: ["version_restore"],
|
|
562
|
-
version_id: versionId,
|
|
563
|
-
});
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
export function buildPageConfigurationAuditRecord(
|
|
567
|
-
m: AuditMetadata,
|
|
568
|
-
id: string,
|
|
569
|
-
fields: readonly PageConfigurationField[],
|
|
570
|
-
): AuditRecord {
|
|
571
|
-
return buildContentAuditRecord(m, "page.updated", id, {
|
|
572
|
-
changed_fields: canonicalAuditValues(fields),
|
|
573
|
-
});
|
|
574
|
-
}
|
|
575
|
-
export function buildPageLifecycleAuditRecord(
|
|
576
|
-
m: AuditMetadata,
|
|
577
|
-
id: string,
|
|
578
|
-
previous: Extract<AuditState, "draft" | "published">,
|
|
579
|
-
next: Extract<AuditState, "draft" | "published">,
|
|
580
|
-
): AuditRecord {
|
|
581
|
-
return buildContentAuditRecord(m, "page.updated", id, {
|
|
582
|
-
changed_fields: ["status"],
|
|
583
|
-
previous_state: previous,
|
|
584
|
-
new_state: next,
|
|
585
|
-
});
|
|
586
|
-
}
|
|
587
|
-
export function buildPageFeaturedImageAuditRecord(
|
|
588
|
-
m: AuditMetadata,
|
|
589
|
-
id: string,
|
|
590
|
-
assetId: string,
|
|
591
|
-
operation: AuditCollectionOperation,
|
|
592
|
-
): AuditRecord {
|
|
593
|
-
return buildContentAuditRecord(m, "page.updated", id, {
|
|
594
|
-
changed_fields: ["featured_image"],
|
|
595
|
-
asset_id: assetId,
|
|
596
|
-
collection_operation: operation,
|
|
597
|
-
});
|
|
598
|
-
}
|
|
599
|
-
export function buildPageShareLinkAuditRecord(
|
|
600
|
-
m: AuditMetadata,
|
|
601
|
-
id: string,
|
|
602
|
-
itemId: string,
|
|
603
|
-
operation: Extract<AuditItemOperation, "created" | "deleted">,
|
|
604
|
-
): AuditRecord {
|
|
605
|
-
return buildContentAuditRecord(m, "page.updated", id, {
|
|
606
|
-
changed_fields: ["share_links"],
|
|
607
|
-
item_id: itemId,
|
|
608
|
-
item_operation: operation,
|
|
609
|
-
});
|
|
610
|
-
}
|
|
611
|
-
export function buildPageVersionRestoreAuditRecord(
|
|
612
|
-
m: AuditMetadata,
|
|
613
|
-
id: string,
|
|
614
|
-
versionId: string,
|
|
615
|
-
): AuditRecord {
|
|
616
|
-
return buildContentAuditRecord(m, "page.updated", id, {
|
|
617
|
-
changed_fields: ["version_restore"],
|
|
618
|
-
version_id: versionId,
|
|
619
|
-
});
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
export function buildWorkMetadataAuditRecord(
|
|
623
|
-
m: AuditMetadata,
|
|
624
|
-
id: string,
|
|
625
|
-
fields: readonly WorkMetadataField[],
|
|
626
|
-
): AuditRecord {
|
|
627
|
-
return buildContentAuditRecord(m, "work.updated", id, {
|
|
628
|
-
changed_fields: canonicalAuditValues(fields),
|
|
629
|
-
});
|
|
630
|
-
}
|
|
631
|
-
export function buildWorkLifecycleAuditRecord(
|
|
632
|
-
m: AuditMetadata,
|
|
633
|
-
id: string,
|
|
634
|
-
previous: Extract<AuditState, "draft" | "published" | "archived">,
|
|
635
|
-
next: Extract<AuditState, "draft" | "published" | "archived">,
|
|
636
|
-
): AuditRecord {
|
|
637
|
-
return buildContentAuditRecord(m, "work.updated", id, {
|
|
638
|
-
changed_fields: ["status"],
|
|
639
|
-
previous_state: previous,
|
|
640
|
-
new_state: next,
|
|
641
|
-
});
|
|
642
|
-
}
|
|
643
|
-
export function buildWorkFeaturedImageAuditRecord(
|
|
644
|
-
m: AuditMetadata,
|
|
645
|
-
id: string,
|
|
646
|
-
assetId: string,
|
|
647
|
-
operation: AuditCollectionOperation,
|
|
648
|
-
): AuditRecord {
|
|
649
|
-
return buildContentAuditRecord(m, "work.updated", id, {
|
|
650
|
-
changed_fields: ["featured_image"],
|
|
651
|
-
asset_id: assetId,
|
|
652
|
-
collection_operation: operation,
|
|
653
|
-
});
|
|
654
|
-
}
|
|
655
|
-
export function buildWorkCreditAuditRecord(
|
|
656
|
-
m: AuditMetadata,
|
|
657
|
-
id: string,
|
|
658
|
-
itemId: string,
|
|
659
|
-
operation: AuditItemOperation,
|
|
660
|
-
): AuditRecord {
|
|
661
|
-
return buildContentAuditRecord(m, "work.updated", id, {
|
|
662
|
-
changed_fields: ["credits"],
|
|
663
|
-
item_id: itemId,
|
|
664
|
-
item_operation: operation,
|
|
665
|
-
});
|
|
666
|
-
}
|
|
667
|
-
export function buildWorkShareLinkAuditRecord(
|
|
668
|
-
m: AuditMetadata,
|
|
669
|
-
id: string,
|
|
670
|
-
itemId: string,
|
|
671
|
-
operation: Extract<AuditItemOperation, "created" | "deleted">,
|
|
672
|
-
): AuditRecord {
|
|
673
|
-
return buildContentAuditRecord(m, "work.updated", id, {
|
|
674
|
-
changed_fields: ["share_links"],
|
|
675
|
-
item_id: itemId,
|
|
676
|
-
item_operation: operation,
|
|
677
|
-
});
|
|
678
|
-
}
|
|
679
|
-
export function buildWorkVersionRestoreAuditRecord(
|
|
680
|
-
m: AuditMetadata,
|
|
681
|
-
id: string,
|
|
682
|
-
versionId: string,
|
|
683
|
-
): AuditRecord {
|
|
684
|
-
return buildContentAuditRecord(m, "work.updated", id, {
|
|
685
|
-
changed_fields: ["version_restore"],
|
|
686
|
-
version_id: versionId,
|
|
687
|
-
});
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
function buildRootAuditRecord(
|
|
691
|
-
m: AuditMetadata,
|
|
692
|
-
action: Extract<
|
|
693
|
-
ContentAction,
|
|
694
|
-
`${ContentTarget}.created` | `${ContentTarget}.deleted`
|
|
695
|
-
>,
|
|
696
|
-
id: string,
|
|
697
|
-
): AuditRecord {
|
|
698
|
-
return buildContentAuditRecord(m, action, id);
|
|
699
|
-
}
|
|
700
|
-
export const buildPostCreatedAuditRecord = (
|
|
701
|
-
m: AuditMetadata,
|
|
702
|
-
id: string,
|
|
703
|
-
): AuditRecord => buildRootAuditRecord(m, "post.created", id);
|
|
704
|
-
export const buildPostDeletedAuditRecord = (
|
|
705
|
-
m: AuditMetadata,
|
|
706
|
-
id: string,
|
|
707
|
-
): AuditRecord => buildRootAuditRecord(m, "post.deleted", id);
|
|
708
|
-
export const buildPageCreatedAuditRecord = (
|
|
709
|
-
m: AuditMetadata,
|
|
710
|
-
id: string,
|
|
711
|
-
): AuditRecord => buildRootAuditRecord(m, "page.created", id);
|
|
712
|
-
export const buildPageDeletedAuditRecord = (
|
|
713
|
-
m: AuditMetadata,
|
|
714
|
-
id: string,
|
|
715
|
-
): AuditRecord => buildRootAuditRecord(m, "page.deleted", id);
|
|
716
|
-
export const buildWorkCreatedAuditRecord = (
|
|
717
|
-
m: AuditMetadata,
|
|
718
|
-
id: string,
|
|
719
|
-
): AuditRecord => buildRootAuditRecord(m, "work.created", id);
|
|
720
|
-
export const buildWorkDeletedAuditRecord = (
|
|
721
|
-
m: AuditMetadata,
|
|
722
|
-
id: string,
|
|
723
|
-
): AuditRecord => buildRootAuditRecord(m, "work.deleted", id);
|