@crombolo/api-management 0.13.1 → 0.13.2

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.13.1",
3
+ "version": "0.13.2",
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.13.1",
32
- "@crombolo/contracts": "0.13.1"
31
+ "@crombolo/core": "0.13.2",
32
+ "@crombolo/contracts": "0.13.2"
33
33
  }
34
34
  }
@@ -62,6 +62,12 @@ export function registerMemberGroupHandlers(
62
62
  name,
63
63
  })
64
64
  if (result.status !== 'ok' || !result.key) return statusResponse(result.status)
65
+ // The toast the backoffice shows, as for every other type it saves.
66
+ ctx.notifications.push({
67
+ message: 'Member group created',
68
+ category: 'Member Group',
69
+ type: 'Success',
70
+ })
65
71
  return created(`${ctx.url.origin}${V1}/member-group/${result.key}`, result.key)
66
72
  })
67
73
 
@@ -69,7 +75,14 @@ export function registerMemberGroupHandlers(
69
75
  const body = ((await ctx.request.json().catch(() => ({}))) ?? {}) as Record<string, unknown>
70
76
  const name = typeof body.name === 'string' ? body.name.trim() : ''
71
77
  if (!name) return problemResponse(problemDetails({ title: 'A name is required', status: 400 }))
72
- return statusResponse(await groups.rename(ctx.params.id as string, name))
78
+ const status = await groups.rename(ctx.params.id as string, name)
79
+ if (status === 'ok')
80
+ ctx.notifications.push({
81
+ message: 'Member group saved',
82
+ category: 'Member Group',
83
+ type: 'Success',
84
+ })
85
+ return statusResponse(status)
73
86
  })
74
87
 
75
88
  router.handle('DeleteMemberGroupById', async (ctx) =>
@@ -527,11 +527,24 @@ function registerGroups(router: ManagementApiRouter, groups: UserGroupPort): voi
527
527
  router.handle('PostUserGroup', async (ctx) => {
528
528
  const result = await groups.create(me(ctx), readGroup(await body(ctx)))
529
529
  if (result.status !== 'Success' || !result.key) return status(result.status)
530
+ // The toast the backoffice shows, as for every other type it saves.
531
+ ctx.notifications.push({
532
+ message: 'User group created',
533
+ category: 'User Group',
534
+ type: 'Success',
535
+ })
530
536
  return created(`${ctx.url.origin}${V1}/user-group/${result.key}`, result.key)
531
537
  })
532
- router.handle('PutUserGroupById', async (ctx) =>
533
- status(await groups.update(me(ctx), ctx.params.id as string, readGroup(await body(ctx)))),
534
- )
538
+ router.handle('PutUserGroupById', async (ctx) => {
539
+ const result = await groups.update(me(ctx), ctx.params.id as string, readGroup(await body(ctx)))
540
+ if (result === 'Success')
541
+ ctx.notifications.push({
542
+ message: 'User group saved',
543
+ category: 'User Group',
544
+ type: 'Success',
545
+ })
546
+ return status(result)
547
+ })
535
548
  router.handle('DeleteUserGroupById', async (ctx) =>
536
549
  status(await groups.delete(me(ctx), [ctx.params.id as string])),
537
550
  )