@crombolo/api-management 0.43.1 → 0.44.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.43.1",
3
+ "version": "0.44.0",
4
4
  "description": "Internal to crombolo, with no compatibility promise: use @crombolo/crombolo. Umbraco-compatible Management API handlers for crombolo.",
5
5
  "license": "MIT",
6
6
  "author": "Crombolo",
@@ -29,8 +29,8 @@
29
29
  "access": "public"
30
30
  },
31
31
  "dependencies": {
32
- "@crombolo/content": "0.43.1",
33
- "@crombolo/contracts": "0.43.1",
34
- "@crombolo/core": "0.43.1"
32
+ "@crombolo/content": "0.44.0",
33
+ "@crombolo/contracts": "0.44.0",
34
+ "@crombolo/core": "0.44.0"
35
35
  }
36
36
  }
@@ -79,17 +79,8 @@ const USERS: Sections = ['users']
79
79
  const MEMBERS: Sections = ['members']
80
80
  const TRANSLATION: Sections = ['translation']
81
81
  const LIBRARY: Sections = ['library']
82
- const PACKAGES: Sections = ['packages']
83
82
  /** SectionAccessFor{Content,Media,Element}Tree: pickers open these trees from anywhere. */
84
- const ANY_TREE: Sections = [
85
- 'content',
86
- 'media',
87
- 'users',
88
- 'settings',
89
- 'packages',
90
- 'members',
91
- 'library',
92
- ]
83
+ const ANY_TREE: Sections = ['content', 'media', 'users', 'settings', 'members', 'library']
93
84
 
94
85
  const TREES: Record<string, Sections> = {
95
86
  document: ANY_TREE,
@@ -213,8 +204,9 @@ export function sectionRequirements(operation: OperationInfo): Array<Sections |
213
204
  case 'element':
214
205
  case 'element-version':
215
206
  return [LIBRARY]
207
+ // Bundles is a Settings tool (story 238).
216
208
  case 'package':
217
- return [PACKAGES]
209
+ return [SETTINGS]
218
210
  case 'upgrade':
219
211
  return ['admin']
220
212
  case 'server':
@@ -22,6 +22,15 @@ import type { ManagementApiRouter, RequestContext } from '../router.ts'
22
22
  type DocumentTypeResponse = ResponseOf<'GetDocumentTypeById'>
23
23
 
24
24
  /** Umbraco returns 201 with an empty body, `Location`, and the new id. */
25
+ /** A type made from a form (story 239) changes with the form, never on its own. */
26
+ const madeFromForm = (name: string) =>
27
+ problemDetails({
28
+ title: 'This content type is made from a form',
29
+ status: 400,
30
+ detail: `Change the ${name} form in Forms, and this type follows it.`,
31
+ operationStatus: 'NotAllowed',
32
+ })
33
+
25
34
  export function created(location: string, id: string): Response {
26
35
  return new Response(null, {
27
36
  status: 201,
@@ -458,6 +467,7 @@ export function registerContentTypeHandlers(
458
467
  if (!existing) {
459
468
  return problemResponse(notFound(`The ${noun} could not be found`))
460
469
  }
470
+ if (existing.formKey) return problemResponse(madeFromForm(existing.name))
461
471
  const body = (await ctx.request.json()) as Record<string, unknown>
462
472
  if (kind !== 'member' && isSystemContentType(kind, key) && body.alias !== existing.alias)
463
473
  return problemResponse(
@@ -502,6 +512,8 @@ export function registerContentTypeHandlers(
502
512
  })
503
513
 
504
514
  handle(`Delete${T}ById`, async (ctx) => {
515
+ const made = kind === 'document' ? await port.byKey(ctx.params.id as string) : undefined
516
+ if (made?.formKey) return problemResponse(madeFromForm(made.name))
505
517
  if (kind === 'document' && isSystemContentType('document', ctx.params.id as string))
506
518
  return problemResponse(
507
519
  problemDetails({
package/src/router.ts CHANGED
@@ -59,6 +59,12 @@ export interface Principal {
59
59
  startNodes: { document: StartNodes; media: StartNodes; element: StartNodes }
60
60
  /** Each group's verbs, for per-node permission checks. */
61
61
  groups: GroupGrant[]
62
+ /**
63
+ * Set when this is CI acting by a trust rule (story 160), not a person: the
64
+ * rule's key, and where the run was. Such a principal is only ever given to
65
+ * the remote protocol's routes.
66
+ */
67
+ ci?: { rule: string; claims: Record<string, string> }
62
68
  }
63
69
 
64
70
  export interface RequestContext {