@crombolo/api-management 0.19.0 → 0.20.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/api-management",
3
- "version": "0.19.0",
3
+ "version": "0.20.0",
4
4
  "description": "Umbraco-compatible Management API handlers for crombolo.",
5
5
  "license": "MIT",
6
6
  "author": "Crombolo",
@@ -28,7 +28,7 @@
28
28
  "access": "public"
29
29
  },
30
30
  "dependencies": {
31
- "@crombolo/core": "0.19.0",
32
- "@crombolo/contracts": "0.19.0"
31
+ "@crombolo/core": "0.20.0",
32
+ "@crombolo/contracts": "0.20.0"
33
33
  }
34
34
  }
@@ -375,6 +375,7 @@ export function registerDocumentHandlers(
375
375
  return problemResponse(notFound(result.reason))
376
376
  return failureResponse('Could not publish the document', result, input.values)
377
377
  }
378
+ await approvals?.afterDirectPublish?.(principalOf(ctx), key, 'published it')
378
379
  return new Response(null, { status: 200 })
379
380
  })
380
381
 
@@ -587,6 +588,7 @@ export function registerDocumentHandlers(
587
588
  )
588
589
  const immediate = schedules.filter((s) => !later(s))
589
590
  if (schedules.length > 0 && immediate.length === 0) {
591
+ await approvals?.afterDirectPublish?.(principalOf(ctx), key, 'rescheduled it')
590
592
  ctx.notifications.push({
591
593
  message: 'Publishing scheduled',
592
594
  category: 'Content',
@@ -608,6 +610,7 @@ export function registerDocumentHandlers(
608
610
  }),
609
611
  )
610
612
  }
613
+ await approvals?.afterDirectPublish?.(principalOf(ctx), key, 'published it')
611
614
  return new Response(null, { status: 200 })
612
615
  })
613
616
 
@@ -627,6 +630,7 @@ export function registerDocumentHandlers(
627
630
  }),
628
631
  )
629
632
  }
633
+ await approvals?.afterDirectPublish?.(principalOf(ctx), key, 'took it down')
630
634
  return new Response(null, { status: 200 })
631
635
  })
632
636
 
@@ -746,6 +750,8 @@ export function registerDocumentHandlers(
746
750
  body.includeUnpublishedDescendants === true,
747
751
  )
748
752
  if (!result.ok) return failed('Could not publish the branch', result)
753
+ for (const published of result.published)
754
+ await approvals?.afterDirectPublish?.(principalOf(ctx), published, 'published its branch')
749
755
  const taskId = crypto.randomUUID()
750
756
  branchTasks.set(taskId, { documentKey: key })
751
757
  ctx.notifications.push({
@@ -626,4 +626,6 @@ export interface ApprovalGatePort {
626
626
  ): Promise<string | undefined>
627
627
  beforeSave(principal: Principal, key: string): Promise<string | undefined>
628
628
  afterSave(principal: Principal, key: string): Promise<void>
629
+ /** A publish, schedule or unpublish that passed the gate: it supersedes a scheduled request. */
630
+ afterDirectPublish?(principal: Principal, key: string, what: string): Promise<void>
629
631
  }