@crombolo/content 0.55.0 → 0.57.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.55.0",
3
+ "version": "0.57.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.55.0",
33
- "@crombolo/data": "0.55.0"
32
+ "@crombolo/core": "0.57.0",
33
+ "@crombolo/data": "0.57.0"
34
34
  }
35
35
  }
package/src/actor.ts CHANGED
@@ -24,6 +24,11 @@ export interface ActorOrigin {
24
24
  source: 'request' | 'cli' | 'job'
25
25
  ipAddress?: string | null
26
26
  forwardedFor?: string | null
27
+ /**
28
+ * The site's own code that made the change (story 298): `route POST /api/listings`,
29
+ * `action contact.send`, `job imports.nightly`, `event Umbraco.ContentPublish <key>`.
30
+ */
31
+ via?: string
27
32
  }
28
33
 
29
34
  export type Actor =
@@ -129,4 +134,11 @@ export const actorMemberKey = (actor: MediaActor): string | null =>
129
134
 
130
135
  /** What the actor says alongside the change, if anything. */
131
136
  export const actorNote = (actor: MediaActor): string | undefined =>
132
- actor.kind === 'system' ? actor.note : undefined
137
+ actor.kind === 'system'
138
+ ? actor.note
139
+ : actor.origin.via
140
+ ? `through ${viaWords(actor.origin.via)}`
141
+ : undefined
142
+
143
+ /** `event <alias> <key>` as the audit log says it: without the key it is already about. */
144
+ const viaWords = (via: string): string => via.replace(/^(event \S+) [0-9a-f-]{36}$/i, '$1')
package/src/operations.ts CHANGED
@@ -188,7 +188,11 @@ const refuse = (kind: Refusal['kind'], status: number, reason: string): Refusal
188
188
  function refusalFrom(error: unknown, extra?: (error: unknown) => string | undefined): Refusal {
189
189
  if (error instanceof WriteRejectedError) return refuse('conflict', 409, error.message)
190
190
  if (error instanceof InvalidParentError) return refuse('invalid', 400, error.message)
191
- if (error instanceof PublishBlockedError) return refuse('blocked', 400, error.message)
191
+ if (error instanceof PublishBlockedError)
192
+ return {
193
+ ...refuse('blocked', 400, error.message),
194
+ ...(error.errors.length > 0 ? { errors: error.errors } : {}),
195
+ }
192
196
  if (error instanceof StaleRevisionError) return refuse('stale', 412, STALE)
193
197
  const reason = extra?.(error)
194
198
  if (reason) return refuse('invalid', 400, reason)