@byline/admin 0.9.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.
Files changed (159) hide show
  1. package/LICENSE +373 -0
  2. package/README.md +19 -0
  3. package/dist/abilities.d.ts +22 -0
  4. package/dist/abilities.d.ts.map +1 -0
  5. package/dist/abilities.js +29 -0
  6. package/dist/abilities.js.map +1 -0
  7. package/dist/index.d.ts +31 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/index.js +30 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/lib/assert-admin-actor.d.ts +58 -0
  12. package/dist/lib/assert-admin-actor.d.ts.map +1 -0
  13. package/dist/lib/assert-admin-actor.js +82 -0
  14. package/dist/lib/assert-admin-actor.js.map +1 -0
  15. package/dist/modules/admin-account/commands.d.ts +30 -0
  16. package/dist/modules/admin-account/commands.d.ts.map +1 -0
  17. package/dist/modules/admin-account/commands.js +36 -0
  18. package/dist/modules/admin-account/commands.js.map +1 -0
  19. package/dist/modules/admin-account/errors.d.ts +52 -0
  20. package/dist/modules/admin-account/errors.d.ts.map +1 -0
  21. package/dist/modules/admin-account/errors.js +52 -0
  22. package/dist/modules/admin-account/errors.js.map +1 -0
  23. package/dist/modules/admin-account/index.d.ts +37 -0
  24. package/dist/modules/admin-account/index.d.ts.map +1 -0
  25. package/dist/modules/admin-account/index.js +35 -0
  26. package/dist/modules/admin-account/index.js.map +1 -0
  27. package/dist/modules/admin-account/schemas.d.ts +31 -0
  28. package/dist/modules/admin-account/schemas.d.ts.map +1 -0
  29. package/dist/modules/admin-account/schemas.js +69 -0
  30. package/dist/modules/admin-account/schemas.js.map +1 -0
  31. package/dist/modules/admin-account/service.d.ts +44 -0
  32. package/dist/modules/admin-account/service.d.ts.map +1 -0
  33. package/dist/modules/admin-account/service.js +76 -0
  34. package/dist/modules/admin-account/service.js.map +1 -0
  35. package/dist/modules/admin-permissions/abilities.d.ts +27 -0
  36. package/dist/modules/admin-permissions/abilities.d.ts.map +1 -0
  37. package/dist/modules/admin-permissions/abilities.js +40 -0
  38. package/dist/modules/admin-permissions/abilities.js.map +1 -0
  39. package/dist/modules/admin-permissions/commands.d.ts +30 -0
  40. package/dist/modules/admin-permissions/commands.d.ts.map +1 -0
  41. package/dist/modules/admin-permissions/commands.js +39 -0
  42. package/dist/modules/admin-permissions/commands.js.map +1 -0
  43. package/dist/modules/admin-permissions/dto.d.ts +18 -0
  44. package/dist/modules/admin-permissions/dto.d.ts.map +1 -0
  45. package/dist/modules/admin-permissions/dto.js +24 -0
  46. package/dist/modules/admin-permissions/dto.js.map +1 -0
  47. package/dist/modules/admin-permissions/errors.d.ts +34 -0
  48. package/dist/modules/admin-permissions/errors.d.ts.map +1 -0
  49. package/dist/modules/admin-permissions/errors.js +34 -0
  50. package/dist/modules/admin-permissions/errors.js.map +1 -0
  51. package/dist/modules/admin-permissions/index.d.ts +30 -0
  52. package/dist/modules/admin-permissions/index.d.ts.map +1 -0
  53. package/dist/modules/admin-permissions/index.js +27 -0
  54. package/dist/modules/admin-permissions/index.js.map +1 -0
  55. package/dist/modules/admin-permissions/repository.d.ts +48 -0
  56. package/dist/modules/admin-permissions/repository.d.ts.map +1 -0
  57. package/dist/modules/admin-permissions/repository.js +9 -0
  58. package/dist/modules/admin-permissions/repository.js.map +1 -0
  59. package/dist/modules/admin-permissions/schemas.d.ts +137 -0
  60. package/dist/modules/admin-permissions/schemas.d.ts.map +1 -0
  61. package/dist/modules/admin-permissions/schemas.js +99 -0
  62. package/dist/modules/admin-permissions/schemas.js.map +1 -0
  63. package/dist/modules/admin-permissions/service.d.ts +42 -0
  64. package/dist/modules/admin-permissions/service.d.ts.map +1 -0
  65. package/dist/modules/admin-permissions/service.js +114 -0
  66. package/dist/modules/admin-permissions/service.js.map +1 -0
  67. package/dist/modules/admin-roles/abilities.d.ts +33 -0
  68. package/dist/modules/admin-roles/abilities.d.ts.map +1 -0
  69. package/dist/modules/admin-roles/abilities.js +56 -0
  70. package/dist/modules/admin-roles/abilities.js.map +1 -0
  71. package/dist/modules/admin-roles/commands.d.ts +37 -0
  72. package/dist/modules/admin-roles/commands.d.ts.map +1 -0
  73. package/dist/modules/admin-roles/commands.js +70 -0
  74. package/dist/modules/admin-roles/commands.js.map +1 -0
  75. package/dist/modules/admin-roles/dto.d.ts +18 -0
  76. package/dist/modules/admin-roles/dto.d.ts.map +1 -0
  77. package/dist/modules/admin-roles/dto.js +27 -0
  78. package/dist/modules/admin-roles/dto.js.map +1 -0
  79. package/dist/modules/admin-roles/errors.d.ts +49 -0
  80. package/dist/modules/admin-roles/errors.d.ts.map +1 -0
  81. package/dist/modules/admin-roles/errors.js +49 -0
  82. package/dist/modules/admin-roles/errors.js.map +1 -0
  83. package/dist/modules/admin-roles/index.d.ts +30 -0
  84. package/dist/modules/admin-roles/index.d.ts.map +1 -0
  85. package/dist/modules/admin-roles/index.js +27 -0
  86. package/dist/modules/admin-roles/index.js.map +1 -0
  87. package/dist/modules/admin-roles/repository.d.ts +91 -0
  88. package/dist/modules/admin-roles/repository.d.ts.map +1 -0
  89. package/dist/modules/admin-roles/repository.js +9 -0
  90. package/dist/modules/admin-roles/repository.js.map +1 -0
  91. package/dist/modules/admin-roles/schemas.d.ts +99 -0
  92. package/dist/modules/admin-roles/schemas.d.ts.map +1 -0
  93. package/dist/modules/admin-roles/schemas.js +105 -0
  94. package/dist/modules/admin-roles/schemas.js.map +1 -0
  95. package/dist/modules/admin-roles/service.d.ts +49 -0
  96. package/dist/modules/admin-roles/service.d.ts.map +1 -0
  97. package/dist/modules/admin-roles/service.js +110 -0
  98. package/dist/modules/admin-roles/service.js.map +1 -0
  99. package/dist/modules/admin-users/abilities.d.ts +41 -0
  100. package/dist/modules/admin-users/abilities.d.ts.map +1 -0
  101. package/dist/modules/admin-users/abilities.js +70 -0
  102. package/dist/modules/admin-users/abilities.js.map +1 -0
  103. package/dist/modules/admin-users/commands.d.ts +45 -0
  104. package/dist/modules/admin-users/commands.d.ts.map +1 -0
  105. package/dist/modules/admin-users/commands.js +63 -0
  106. package/dist/modules/admin-users/commands.js.map +1 -0
  107. package/dist/modules/admin-users/dto.d.ts +20 -0
  108. package/dist/modules/admin-users/dto.d.ts.map +1 -0
  109. package/dist/modules/admin-users/dto.js +36 -0
  110. package/dist/modules/admin-users/dto.js.map +1 -0
  111. package/dist/modules/admin-users/errors.d.ts +53 -0
  112. package/dist/modules/admin-users/errors.d.ts.map +1 -0
  113. package/dist/modules/admin-users/errors.js +53 -0
  114. package/dist/modules/admin-users/errors.js.map +1 -0
  115. package/dist/modules/admin-users/index.d.ts +31 -0
  116. package/dist/modules/admin-users/index.d.ts.map +1 -0
  117. package/dist/modules/admin-users/index.js +28 -0
  118. package/dist/modules/admin-users/index.js.map +1 -0
  119. package/dist/modules/admin-users/repository.d.ts +147 -0
  120. package/dist/modules/admin-users/repository.d.ts.map +1 -0
  121. package/dist/modules/admin-users/repository.js +9 -0
  122. package/dist/modules/admin-users/repository.js.map +1 -0
  123. package/dist/modules/admin-users/schemas.d.ts +136 -0
  124. package/dist/modules/admin-users/schemas.d.ts.map +1 -0
  125. package/dist/modules/admin-users/schemas.js +137 -0
  126. package/dist/modules/admin-users/schemas.js.map +1 -0
  127. package/dist/modules/admin-users/seed-super-admin.d.ts +44 -0
  128. package/dist/modules/admin-users/seed-super-admin.d.ts.map +1 -0
  129. package/dist/modules/admin-users/seed-super-admin.js +70 -0
  130. package/dist/modules/admin-users/seed-super-admin.js.map +1 -0
  131. package/dist/modules/admin-users/service.d.ts +53 -0
  132. package/dist/modules/admin-users/service.d.ts.map +1 -0
  133. package/dist/modules/admin-users/service.js +143 -0
  134. package/dist/modules/admin-users/service.js.map +1 -0
  135. package/dist/modules/auth/index.d.ts +26 -0
  136. package/dist/modules/auth/index.d.ts.map +1 -0
  137. package/dist/modules/auth/index.js +25 -0
  138. package/dist/modules/auth/index.js.map +1 -0
  139. package/dist/modules/auth/jwt-session-provider.d.ts +47 -0
  140. package/dist/modules/auth/jwt-session-provider.d.ts.map +1 -0
  141. package/dist/modules/auth/jwt-session-provider.js +215 -0
  142. package/dist/modules/auth/jwt-session-provider.js.map +1 -0
  143. package/dist/modules/auth/password.d.ts +16 -0
  144. package/dist/modules/auth/password.d.ts.map +1 -0
  145. package/dist/modules/auth/password.js +48 -0
  146. package/dist/modules/auth/password.js.map +1 -0
  147. package/dist/modules/auth/refresh-tokens-repository.d.ts +71 -0
  148. package/dist/modules/auth/refresh-tokens-repository.d.ts.map +1 -0
  149. package/dist/modules/auth/refresh-tokens-repository.js +9 -0
  150. package/dist/modules/auth/refresh-tokens-repository.js.map +1 -0
  151. package/dist/modules/auth/resolve-actor.d.ts +25 -0
  152. package/dist/modules/auth/resolve-actor.d.ts.map +1 -0
  153. package/dist/modules/auth/resolve-actor.js +36 -0
  154. package/dist/modules/auth/resolve-actor.js.map +1 -0
  155. package/dist/store.d.ts +31 -0
  156. package/dist/store.d.ts.map +1 -0
  157. package/dist/store.js +9 -0
  158. package/dist/store.js.map +1 -0
  159. package/package.json +101 -0
@@ -0,0 +1,39 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+ import { assertAdminActor } from '../../lib/assert-admin-actor.js';
9
+ import { ADMIN_PERMISSIONS_ABILITIES } from './abilities.js';
10
+ import { getRoleAbilitiesRequestSchema, getRoleAbilitiesResponseSchema, listRegisteredAbilitiesRequestSchema, listRegisteredAbilitiesResponseSchema, setRoleAbilitiesRequestSchema, setRoleAbilitiesResponseSchema, whoHasAbilityRequestSchema, whoHasAbilityResponseSchema, } from './schemas.js';
11
+ import { AdminPermissionsService } from './service.js';
12
+ function serviceOf(deps) {
13
+ return new AdminPermissionsService({ store: deps.store, abilities: deps.abilities });
14
+ }
15
+ export async function listRegisteredAbilitiesCommand(context, input, deps) {
16
+ listRegisteredAbilitiesRequestSchema.parse(input ?? {});
17
+ assertAdminActor(context, ADMIN_PERMISSIONS_ABILITIES.read);
18
+ const result = serviceOf(deps).listRegisteredAbilities();
19
+ return listRegisteredAbilitiesResponseSchema.parse(result);
20
+ }
21
+ export async function whoHasAbilityCommand(context, input, deps) {
22
+ const parsed = whoHasAbilityRequestSchema.parse(input);
23
+ assertAdminActor(context, ADMIN_PERMISSIONS_ABILITIES.read);
24
+ const result = await serviceOf(deps).whoHasAbility(parsed);
25
+ return whoHasAbilityResponseSchema.parse(result);
26
+ }
27
+ export async function getRoleAbilitiesCommand(context, input, deps) {
28
+ const parsed = getRoleAbilitiesRequestSchema.parse(input);
29
+ assertAdminActor(context, ADMIN_PERMISSIONS_ABILITIES.read);
30
+ const result = await serviceOf(deps).getRoleAbilities(parsed);
31
+ return getRoleAbilitiesResponseSchema.parse(result);
32
+ }
33
+ export async function setRoleAbilitiesCommand(context, input, deps) {
34
+ const parsed = setRoleAbilitiesRequestSchema.parse(input);
35
+ assertAdminActor(context, ADMIN_PERMISSIONS_ABILITIES.update);
36
+ const result = await serviceOf(deps).setRoleAbilities(parsed);
37
+ return setRoleAbilitiesResponseSchema.parse(result);
38
+ }
39
+ //# sourceMappingURL=commands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.js","sourceRoot":"","sources":["../../../src/modules/admin-permissions/commands.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAA;AAClE,OAAO,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAA;AAC5D,OAAO,EACL,6BAA6B,EAC7B,8BAA8B,EAC9B,oCAAoC,EACpC,qCAAqC,EACrC,6BAA6B,EAC7B,8BAA8B,EAC9B,0BAA0B,EAC1B,2BAA2B,GAC5B,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AA0BtD,SAAS,SAAS,CAAC,IAAiC;IAClD,OAAO,IAAI,uBAAuB,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAA;AACtF,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAClD,OAAmC,EACnC,KAAc,EACd,IAAiC;IAEjC,oCAAoC,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,CAAA;IACvD,gBAAgB,CAAC,OAAO,EAAE,2BAA2B,CAAC,IAAI,CAAC,CAAA;IAC3D,MAAM,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,uBAAuB,EAAE,CAAA;IACxD,OAAO,qCAAqC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;AAC5D,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,OAAmC,EACnC,KAAc,EACd,IAAiC;IAEjC,MAAM,MAAM,GAAG,0BAA0B,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IACtD,gBAAgB,CAAC,OAAO,EAAE,2BAA2B,CAAC,IAAI,CAAC,CAAA;IAC3D,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAA;IAC1D,OAAO,2BAA2B,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;AAClD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,OAAmC,EACnC,KAAc,EACd,IAAiC;IAEjC,MAAM,MAAM,GAAG,6BAA6B,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IACzD,gBAAgB,CAAC,OAAO,EAAE,2BAA2B,CAAC,IAAI,CAAC,CAAA;IAC3D,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAA;IAC7D,OAAO,8BAA8B,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;AACrD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,OAAmC,EACnC,KAAc,EACd,IAAiC;IAEjC,MAAM,MAAM,GAAG,6BAA6B,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IACzD,gBAAgB,CAAC,OAAO,EAAE,2BAA2B,CAAC,MAAM,CAAC,CAAA;IAC7D,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAA;IAC7D,OAAO,8BAA8B,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;AACrD,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+ import type { AbilityDescriptor } from '@byline/auth';
9
+ import type { AbilityDescriptorResponse } from './schemas.js';
10
+ /**
11
+ * Shape an `AbilityDescriptor` from the registry into its public
12
+ * response form. Identity-shaped today — the indirection exists so
13
+ * that future internal-only fields on `AbilityDescriptor` (e.g. a
14
+ * registration timestamp) stay opted out of the public shape by
15
+ * default.
16
+ */
17
+ export declare function toAbilityDescriptor(descriptor: AbilityDescriptor): AbilityDescriptorResponse;
18
+ //# sourceMappingURL=dto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dto.d.ts","sourceRoot":"","sources":["../../../src/modules/admin-permissions/dto.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAErD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AAE7D;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,iBAAiB,GAAG,yBAAyB,CAQ5F"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+ /**
9
+ * Shape an `AbilityDescriptor` from the registry into its public
10
+ * response form. Identity-shaped today — the indirection exists so
11
+ * that future internal-only fields on `AbilityDescriptor` (e.g. a
12
+ * registration timestamp) stay opted out of the public shape by
13
+ * default.
14
+ */
15
+ export function toAbilityDescriptor(descriptor) {
16
+ return {
17
+ key: descriptor.key,
18
+ label: descriptor.label,
19
+ description: descriptor.description ?? null,
20
+ group: descriptor.group,
21
+ source: descriptor.source ?? null,
22
+ };
23
+ }
24
+ //# sourceMappingURL=dto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dto.js","sourceRoot":"","sources":["../../../src/modules/admin-permissions/dto.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,UAA6B;IAC/D,OAAO;QACL,GAAG,EAAE,UAAU,CAAC,GAAG;QACnB,KAAK,EAAE,UAAU,CAAC,KAAK;QACvB,WAAW,EAAE,UAAU,CAAC,WAAW,IAAI,IAAI;QAC3C,KAAK,EAAE,UAAU,CAAC,KAAK;QACvB,MAAM,EAAE,UAAU,CAAC,MAAM,IAAI,IAAI;KAClC,CAAA;AACH,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+ /**
9
+ * Module-local error codes for admin-permissions.
10
+ *
11
+ * `ROLE_NOT_FOUND` covers the editor (and future grant/revoke) paths;
12
+ * `ABILITY_UNREGISTERED` is reserved for the editor too — when a client
13
+ * tries to grant an ability key that no subsystem has registered. The
14
+ * inspector is read-only and never throws either of these.
15
+ */
16
+ export declare const AdminPermissionsErrorCodes: {
17
+ readonly ROLE_NOT_FOUND: "admin.permissions.roleNotFound";
18
+ readonly ABILITY_UNREGISTERED: "admin.permissions.abilityUnregistered";
19
+ };
20
+ export type AdminPermissionsErrorCode = (typeof AdminPermissionsErrorCodes)[keyof typeof AdminPermissionsErrorCodes];
21
+ export interface AdminPermissionsErrorOptions {
22
+ message?: string;
23
+ cause?: unknown;
24
+ }
25
+ export declare class AdminPermissionsError extends Error {
26
+ readonly code: AdminPermissionsErrorCode;
27
+ constructor(code: AdminPermissionsErrorCode, options: {
28
+ message: string;
29
+ cause?: unknown;
30
+ });
31
+ }
32
+ export declare const ERR_ADMIN_PERMISSIONS_ROLE_NOT_FOUND: (options?: AdminPermissionsErrorOptions) => AdminPermissionsError;
33
+ export declare const ERR_ADMIN_PERMISSIONS_ABILITY_UNREGISTERED: (options?: AdminPermissionsErrorOptions) => AdminPermissionsError;
34
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/modules/admin-permissions/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;GAOG;AAEH,eAAO,MAAM,0BAA0B;;;CAG7B,CAAA;AAEV,MAAM,MAAM,yBAAyB,GACnC,CAAC,OAAO,0BAA0B,CAAC,CAAC,MAAM,OAAO,0BAA0B,CAAC,CAAA;AAE9E,MAAM,WAAW,4BAA4B;IAC3C,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,SAAgB,IAAI,EAAE,yBAAyB,CAAA;gBAEnC,IAAI,EAAE,yBAAyB,EAAE,OAAO,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAK3F;AAUD,eAAO,MAAM,oCAAoC,aANpC,4BAA4B,KAAG,qBAS3C,CAAA;AAED,eAAO,MAAM,0CAA0C,aAX1C,4BAA4B,KAAG,qBAc3C,CAAA"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+ /**
9
+ * Module-local error codes for admin-permissions.
10
+ *
11
+ * `ROLE_NOT_FOUND` covers the editor (and future grant/revoke) paths;
12
+ * `ABILITY_UNREGISTERED` is reserved for the editor too — when a client
13
+ * tries to grant an ability key that no subsystem has registered. The
14
+ * inspector is read-only and never throws either of these.
15
+ */
16
+ export const AdminPermissionsErrorCodes = {
17
+ ROLE_NOT_FOUND: 'admin.permissions.roleNotFound',
18
+ ABILITY_UNREGISTERED: 'admin.permissions.abilityUnregistered',
19
+ };
20
+ export class AdminPermissionsError extends Error {
21
+ code;
22
+ constructor(code, options) {
23
+ super(options.message, options.cause != null ? { cause: options.cause } : undefined);
24
+ this.name = 'AdminPermissionsError';
25
+ this.code = code;
26
+ }
27
+ }
28
+ const make = (code, defaultMessage) => (options) => new AdminPermissionsError(code, {
29
+ message: options?.message ?? defaultMessage,
30
+ cause: options?.cause,
31
+ });
32
+ export const ERR_ADMIN_PERMISSIONS_ROLE_NOT_FOUND = make(AdminPermissionsErrorCodes.ROLE_NOT_FOUND, 'admin role not found');
33
+ export const ERR_ADMIN_PERMISSIONS_ABILITY_UNREGISTERED = make(AdminPermissionsErrorCodes.ABILITY_UNREGISTERED, 'one or more abilities are not registered');
34
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/modules/admin-permissions/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;GAOG;AAEH,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,cAAc,EAAE,gCAAgC;IAChD,oBAAoB,EAAE,uCAAuC;CACrD,CAAA;AAUV,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC9B,IAAI,CAA2B;IAE/C,YAAY,IAA+B,EAAE,OAA6C;QACxF,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;QACpF,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAA;QACnC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;CACF;AAED,MAAM,IAAI,GACR,CAAC,IAA+B,EAAE,cAAsB,EAAE,EAAE,CAC5D,CAAC,OAAsC,EAAyB,EAAE,CAChE,IAAI,qBAAqB,CAAC,IAAI,EAAE;IAC9B,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,cAAc;IAC3C,KAAK,EAAE,OAAO,EAAE,KAAK;CACtB,CAAC,CAAA;AAEN,MAAM,CAAC,MAAM,oCAAoC,GAAG,IAAI,CACtD,0BAA0B,CAAC,cAAc,EACzC,sBAAsB,CACvB,CAAA;AAED,MAAM,CAAC,MAAM,0CAA0C,GAAG,IAAI,CAC5D,0BAA0B,CAAC,oBAAoB,EAC/C,0CAA0C,CAC3C,CAAA"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+ /**
9
+ * `@byline/admin/admin-permissions` — ability grants against roles plus
10
+ * the read-only inspector view.
11
+ *
12
+ * Backs the `byline_admin_permissions` table. Ability keys are
13
+ * registered at `initBylineCore()` time through the `AbilityRegistry`
14
+ * from `@byline/auth`; this module owns the per-role grant data and the
15
+ * inspector that surfaces it.
16
+ *
17
+ * The editor surface (`getRoleAbilities` / `setRoleAbilities`) is
18
+ * deliberately out of scope on this first ship — it lands with Phase B
19
+ * and mounts on the admin-roles role detail page.
20
+ */
21
+ export { ADMIN_PERMISSIONS_ABILITIES, type AdminPermissionsAbilityKey, registerAdminPermissionsAbilities, } from './abilities.js';
22
+ export { getRoleAbilitiesCommand, listRegisteredAbilitiesCommand, setRoleAbilitiesCommand, whoHasAbilityCommand, } from './commands.js';
23
+ export { toAbilityDescriptor } from './dto.js';
24
+ export { AdminPermissionsError, type AdminPermissionsErrorCode, AdminPermissionsErrorCodes, ERR_ADMIN_PERMISSIONS_ABILITY_UNREGISTERED, ERR_ADMIN_PERMISSIONS_ROLE_NOT_FOUND, } from './errors.js';
25
+ export { abilityDescriptorResponseSchema, abilityGroupResponseSchema, abilityHolderRoleSchema, abilityHolderUserSchema, getRoleAbilitiesRequestSchema, getRoleAbilitiesResponseSchema, listRegisteredAbilitiesRequestSchema, listRegisteredAbilitiesResponseSchema, setRoleAbilitiesRequestSchema, setRoleAbilitiesResponseSchema, whoHasAbilityRequestSchema, whoHasAbilityResponseSchema, } from './schemas.js';
26
+ export { AdminPermissionsService } from './service.js';
27
+ export type { AdminPermissionsCommandDeps } from './commands.js';
28
+ export type { AdminPermissionsRepository } from './repository.js';
29
+ export type { AbilityDescriptorResponse, AbilityGroupResponse, AbilityHolderRole, AbilityHolderUser, GetRoleAbilitiesRequest, GetRoleAbilitiesResponse, ListRegisteredAbilitiesRequest, ListRegisteredAbilitiesResponse, SetRoleAbilitiesRequest, SetRoleAbilitiesResponse, WhoHasAbilityRequest, WhoHasAbilityResponse, } from './schemas.js';
30
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/admin-permissions/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,2BAA2B,EAC3B,KAAK,0BAA0B,EAC/B,iCAAiC,GAClC,MAAM,gBAAgB,CAAA;AACvB,OAAO,EACL,uBAAuB,EACvB,8BAA8B,EAC9B,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,EACL,qBAAqB,EACrB,KAAK,yBAAyB,EAC9B,0BAA0B,EAC1B,0CAA0C,EAC1C,oCAAoC,GACrC,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,+BAA+B,EAC/B,0BAA0B,EAC1B,uBAAuB,EACvB,uBAAuB,EACvB,6BAA6B,EAC7B,8BAA8B,EAC9B,oCAAoC,EACpC,qCAAqC,EACrC,6BAA6B,EAC7B,8BAA8B,EAC9B,0BAA0B,EAC1B,2BAA2B,GAC5B,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AACtD,YAAY,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAA;AAChE,YAAY,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAA;AACjE,YAAY,EACV,yBAAyB,EACzB,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,EACvB,wBAAwB,EACxB,8BAA8B,EAC9B,+BAA+B,EAC/B,uBAAuB,EACvB,wBAAwB,EACxB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,cAAc,CAAA"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+ /**
9
+ * `@byline/admin/admin-permissions` — ability grants against roles plus
10
+ * the read-only inspector view.
11
+ *
12
+ * Backs the `byline_admin_permissions` table. Ability keys are
13
+ * registered at `initBylineCore()` time through the `AbilityRegistry`
14
+ * from `@byline/auth`; this module owns the per-role grant data and the
15
+ * inspector that surfaces it.
16
+ *
17
+ * The editor surface (`getRoleAbilities` / `setRoleAbilities`) is
18
+ * deliberately out of scope on this first ship — it lands with Phase B
19
+ * and mounts on the admin-roles role detail page.
20
+ */
21
+ export { ADMIN_PERMISSIONS_ABILITIES, registerAdminPermissionsAbilities, } from './abilities.js';
22
+ export { getRoleAbilitiesCommand, listRegisteredAbilitiesCommand, setRoleAbilitiesCommand, whoHasAbilityCommand, } from './commands.js';
23
+ export { toAbilityDescriptor } from './dto.js';
24
+ export { AdminPermissionsError, AdminPermissionsErrorCodes, ERR_ADMIN_PERMISSIONS_ABILITY_UNREGISTERED, ERR_ADMIN_PERMISSIONS_ROLE_NOT_FOUND, } from './errors.js';
25
+ export { abilityDescriptorResponseSchema, abilityGroupResponseSchema, abilityHolderRoleSchema, abilityHolderUserSchema, getRoleAbilitiesRequestSchema, getRoleAbilitiesResponseSchema, listRegisteredAbilitiesRequestSchema, listRegisteredAbilitiesResponseSchema, setRoleAbilitiesRequestSchema, setRoleAbilitiesResponseSchema, whoHasAbilityRequestSchema, whoHasAbilityResponseSchema, } from './schemas.js';
26
+ export { AdminPermissionsService } from './service.js';
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/admin-permissions/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,2BAA2B,EAE3B,iCAAiC,GAClC,MAAM,gBAAgB,CAAA;AACvB,OAAO,EACL,uBAAuB,EACvB,8BAA8B,EAC9B,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,EACL,qBAAqB,EAErB,0BAA0B,EAC1B,0CAA0C,EAC1C,oCAAoC,GACrC,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,+BAA+B,EAC/B,0BAA0B,EAC1B,uBAAuB,EACvB,uBAAuB,EACvB,6BAA6B,EAC7B,8BAA8B,EAC9B,oCAAoC,EACpC,qCAAqC,EACrC,6BAA6B,EAC7B,8BAA8B,EAC9B,0BAA0B,EAC1B,2BAA2B,GAC5B,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+ /**
9
+ * `AdminPermissionsRepository` — ability grants against roles.
10
+ *
11
+ * Backs the `byline_admin_permissions` table — one row per (role, ability)
12
+ * grant. `setAbilities` is the wholesale-replace operation the role-ability
13
+ * editor in the admin UI will drive; `grantAbility` / `revokeAbility` are
14
+ * the incremental operations for programmatic callers.
15
+ *
16
+ * `listAbilitiesForUser` is the join used by `resolveActor` to build an
17
+ * `AdminAuth` — distinct abilities across every role the user holds.
18
+ *
19
+ * `listRolesForAbility` and `listUsersForAbility` are the inverse joins
20
+ * driving the admin-permissions inspector view (which roles grant a given
21
+ * ability, and which admin users hold those roles transitively).
22
+ */
23
+ export interface AdminPermissionsRepository {
24
+ /** Grant an ability to a role. Idempotent via the unique constraint. */
25
+ grantAbility(roleId: string, ability: string): Promise<void>;
26
+ revokeAbility(roleId: string, ability: string): Promise<void>;
27
+ listAbilities(roleId: string): Promise<string[]>;
28
+ /** Replace the ability set for a role wholesale. Runs inside a transaction. */
29
+ setAbilities(roleId: string, abilities: readonly string[]): Promise<void>;
30
+ /**
31
+ * Distinct abilities granted to a user via every role they hold. Used by
32
+ * `resolveActor()` to build the ability set on an `AdminAuth`.
33
+ */
34
+ listAbilitiesForUser(userId: string): Promise<string[]>;
35
+ /**
36
+ * Role ids that grant the given ability. Used by the inspector to render
37
+ * the per-ability "granted by these roles" list.
38
+ */
39
+ listRolesForAbility(ability: string): Promise<string[]>;
40
+ /**
41
+ * Distinct admin user ids that hold a role granting the given ability.
42
+ * Single-query join through `byline_admin_role_admin_user` — preferred
43
+ * over chaining `listRolesForAbility` + `listUsersForRole` so the
44
+ * inspector stays O(1) queries per ability.
45
+ */
46
+ listUsersForAbility(ability: string): Promise<string[]>;
47
+ }
48
+ //# sourceMappingURL=repository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../../src/modules/admin-permissions/repository.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;;;GAcG;AAEH,MAAM,WAAW,0BAA0B;IACzC,wEAAwE;IACxE,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC5D,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC7D,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;IAChD,+EAA+E;IAC/E,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACzE;;;OAGG;IACH,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;IACvD;;;OAGG;IACH,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;IACvD;;;;;OAKG;IACH,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;CACxD"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=repository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repository.js","sourceRoot":"","sources":["../../../src/modules/admin-permissions/repository.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
@@ -0,0 +1,137 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+ import { z } from 'zod';
9
+ export declare const listRegisteredAbilitiesRequestSchema: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
10
+ export type ListRegisteredAbilitiesRequest = z.infer<typeof listRegisteredAbilitiesRequestSchema>;
11
+ export declare const whoHasAbilityRequestSchema: z.ZodObject<{
12
+ ability: z.ZodString;
13
+ }, z.core.$strip>;
14
+ export type WhoHasAbilityRequest = z.infer<typeof whoHasAbilityRequestSchema>;
15
+ export declare const getRoleAbilitiesRequestSchema: z.ZodObject<{
16
+ id: z.ZodUUID;
17
+ }, z.core.$strip>;
18
+ export type GetRoleAbilitiesRequest = z.infer<typeof getRoleAbilitiesRequestSchema>;
19
+ export declare const setRoleAbilitiesRequestSchema: z.ZodObject<{
20
+ id: z.ZodUUID;
21
+ abilities: z.ZodArray<z.ZodString>;
22
+ }, z.core.$strip>;
23
+ export type SetRoleAbilitiesRequest = z.infer<typeof setRoleAbilitiesRequestSchema>;
24
+ export declare const abilityDescriptorResponseSchema: z.ZodObject<{
25
+ key: z.ZodString;
26
+ label: z.ZodString;
27
+ description: z.ZodNullable<z.ZodString>;
28
+ group: z.ZodString;
29
+ source: z.ZodNullable<z.ZodEnum<{
30
+ admin: "admin";
31
+ collection: "collection";
32
+ plugin: "plugin";
33
+ core: "core";
34
+ }>>;
35
+ }, z.core.$strip>;
36
+ export type AbilityDescriptorResponse = z.infer<typeof abilityDescriptorResponseSchema>;
37
+ export declare const abilityGroupResponseSchema: z.ZodObject<{
38
+ group: z.ZodString;
39
+ abilities: z.ZodArray<z.ZodObject<{
40
+ key: z.ZodString;
41
+ label: z.ZodString;
42
+ description: z.ZodNullable<z.ZodString>;
43
+ group: z.ZodString;
44
+ source: z.ZodNullable<z.ZodEnum<{
45
+ admin: "admin";
46
+ collection: "collection";
47
+ plugin: "plugin";
48
+ core: "core";
49
+ }>>;
50
+ }, z.core.$strip>>;
51
+ }, z.core.$strip>;
52
+ export type AbilityGroupResponse = z.infer<typeof abilityGroupResponseSchema>;
53
+ /**
54
+ * Inspector list payload. Returns both the flat list and the grouped
55
+ * buckets so the UI can render either shape without re-bucketing.
56
+ */
57
+ export declare const listRegisteredAbilitiesResponseSchema: z.ZodObject<{
58
+ abilities: z.ZodArray<z.ZodObject<{
59
+ key: z.ZodString;
60
+ label: z.ZodString;
61
+ description: z.ZodNullable<z.ZodString>;
62
+ group: z.ZodString;
63
+ source: z.ZodNullable<z.ZodEnum<{
64
+ admin: "admin";
65
+ collection: "collection";
66
+ plugin: "plugin";
67
+ core: "core";
68
+ }>>;
69
+ }, z.core.$strip>>;
70
+ groups: z.ZodArray<z.ZodObject<{
71
+ group: z.ZodString;
72
+ abilities: z.ZodArray<z.ZodObject<{
73
+ key: z.ZodString;
74
+ label: z.ZodString;
75
+ description: z.ZodNullable<z.ZodString>;
76
+ group: z.ZodString;
77
+ source: z.ZodNullable<z.ZodEnum<{
78
+ admin: "admin";
79
+ collection: "collection";
80
+ plugin: "plugin";
81
+ core: "core";
82
+ }>>;
83
+ }, z.core.$strip>>;
84
+ }, z.core.$strip>>;
85
+ total: z.ZodNumber;
86
+ }, z.core.$strip>;
87
+ export type ListRegisteredAbilitiesResponse = z.infer<typeof listRegisteredAbilitiesResponseSchema>;
88
+ /**
89
+ * Who-has-ability matrix entry. Roles and users are surfaced in the
90
+ * same response so the inline-expand row in the inspector renders in
91
+ * one round-trip.
92
+ */
93
+ export declare const abilityHolderRoleSchema: z.ZodObject<{
94
+ id: z.ZodString;
95
+ name: z.ZodString;
96
+ machine_name: z.ZodString;
97
+ }, z.core.$strip>;
98
+ export type AbilityHolderRole = z.infer<typeof abilityHolderRoleSchema>;
99
+ export declare const abilityHolderUserSchema: z.ZodObject<{
100
+ id: z.ZodString;
101
+ email: z.ZodString;
102
+ given_name: z.ZodNullable<z.ZodString>;
103
+ family_name: z.ZodNullable<z.ZodString>;
104
+ }, z.core.$strip>;
105
+ export type AbilityHolderUser = z.infer<typeof abilityHolderUserSchema>;
106
+ export declare const whoHasAbilityResponseSchema: z.ZodObject<{
107
+ ability: z.ZodString;
108
+ roles: z.ZodArray<z.ZodObject<{
109
+ id: z.ZodString;
110
+ name: z.ZodString;
111
+ machine_name: z.ZodString;
112
+ }, z.core.$strip>>;
113
+ users: z.ZodArray<z.ZodObject<{
114
+ id: z.ZodString;
115
+ email: z.ZodString;
116
+ given_name: z.ZodNullable<z.ZodString>;
117
+ family_name: z.ZodNullable<z.ZodString>;
118
+ }, z.core.$strip>>;
119
+ }, z.core.$strip>;
120
+ export type WhoHasAbilityResponse = z.infer<typeof whoHasAbilityResponseSchema>;
121
+ /**
122
+ * Editor payloads. `roleId` is echoed back on both responses so the
123
+ * caller can match async writes against the role they were editing
124
+ * without holding the id separately. `abilities` is the authoritative
125
+ * stored set after the write.
126
+ */
127
+ export declare const getRoleAbilitiesResponseSchema: z.ZodObject<{
128
+ roleId: z.ZodString;
129
+ abilities: z.ZodArray<z.ZodString>;
130
+ }, z.core.$strip>;
131
+ export type GetRoleAbilitiesResponse = z.infer<typeof getRoleAbilitiesResponseSchema>;
132
+ export declare const setRoleAbilitiesResponseSchema: z.ZodObject<{
133
+ roleId: z.ZodString;
134
+ abilities: z.ZodArray<z.ZodString>;
135
+ }, z.core.$strip>;
136
+ export type SetRoleAbilitiesResponse = z.infer<typeof setRoleAbilitiesResponseSchema>;
137
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/modules/admin-permissions/schemas.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAwBvB,eAAO,MAAM,oCAAoC,+CAA0B,CAAA;AAC3E,MAAM,MAAM,8BAA8B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oCAAoC,CAAC,CAAA;AAEjG,eAAO,MAAM,0BAA0B;;iBAErC,CAAA;AACF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAA;AAE7E,eAAO,MAAM,6BAA6B;;iBAExC,CAAA;AACF,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAA;AAEnF,eAAO,MAAM,6BAA6B;;;iBAGxC,CAAA;AACF,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAA;AAQnF,eAAO,MAAM,+BAA+B;;;;;;;;;;;iBAM1C,CAAA;AACF,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAA;AAEvF,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;iBAGrC,CAAA;AACF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAA;AAE7E;;;GAGG;AACH,eAAO,MAAM,qCAAqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAIhD,CAAA;AACF,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qCAAqC,CAAC,CAAA;AAEnG;;;;GAIG;AACH,eAAO,MAAM,uBAAuB;;;;iBAIlC,CAAA;AACF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAA;AAEvE,eAAO,MAAM,uBAAuB;;;;;iBAKlC,CAAA;AACF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAA;AAEvE,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;iBAItC,CAAA;AACF,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAA;AAE/E;;;;;GAKG;AACH,eAAO,MAAM,8BAA8B;;;iBAGzC,CAAA;AACF,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAA;AAErF,eAAO,MAAM,8BAA8B;;;iBAGzC,CAAA;AACF,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAA"}
@@ -0,0 +1,99 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+ import { uuidSchema } from '@byline/core/validation';
9
+ import { z } from 'zod';
10
+ /**
11
+ * Zod request/response schemas for the admin-permissions inspector.
12
+ *
13
+ * The inspector ships two endpoints:
14
+ *
15
+ * - `listRegisteredAbilities` — flat list + grouped buckets straight
16
+ * out of the `AbilityRegistry`. No DB read.
17
+ * - `whoHasAbility` — for a given ability key, the list of roles that
18
+ * grant it and the distinct list of admin users transitively
19
+ * holding it. Two DB joins.
20
+ *
21
+ * Phase B will add `getRoleAbilities` / `setRoleAbilities` for the
22
+ * per-role editor on the admin-roles detail page; both are deliberately
23
+ * out of scope here.
24
+ */
25
+ const abilityKeySchema = z.string().min(1).max(128);
26
+ // ---------------------------------------------------------------------------
27
+ // Requests
28
+ // ---------------------------------------------------------------------------
29
+ export const listRegisteredAbilitiesRequestSchema = z.object({}).optional();
30
+ export const whoHasAbilityRequestSchema = z.object({
31
+ ability: abilityKeySchema,
32
+ });
33
+ export const getRoleAbilitiesRequestSchema = z.object({
34
+ id: uuidSchema,
35
+ });
36
+ export const setRoleAbilitiesRequestSchema = z.object({
37
+ id: uuidSchema,
38
+ abilities: z.array(abilityKeySchema),
39
+ });
40
+ // ---------------------------------------------------------------------------
41
+ // Responses
42
+ // ---------------------------------------------------------------------------
43
+ const abilitySourceSchema = z.enum(['collection', 'plugin', 'core', 'admin']).nullable();
44
+ export const abilityDescriptorResponseSchema = z.object({
45
+ key: z.string(),
46
+ label: z.string(),
47
+ description: z.string().nullable(),
48
+ group: z.string(),
49
+ source: abilitySourceSchema,
50
+ });
51
+ export const abilityGroupResponseSchema = z.object({
52
+ group: z.string(),
53
+ abilities: z.array(abilityDescriptorResponseSchema),
54
+ });
55
+ /**
56
+ * Inspector list payload. Returns both the flat list and the grouped
57
+ * buckets so the UI can render either shape without re-bucketing.
58
+ */
59
+ export const listRegisteredAbilitiesResponseSchema = z.object({
60
+ abilities: z.array(abilityDescriptorResponseSchema),
61
+ groups: z.array(abilityGroupResponseSchema),
62
+ total: z.number().int().min(0),
63
+ });
64
+ /**
65
+ * Who-has-ability matrix entry. Roles and users are surfaced in the
66
+ * same response so the inline-expand row in the inspector renders in
67
+ * one round-trip.
68
+ */
69
+ export const abilityHolderRoleSchema = z.object({
70
+ id: z.string(),
71
+ name: z.string(),
72
+ machine_name: z.string(),
73
+ });
74
+ export const abilityHolderUserSchema = z.object({
75
+ id: z.string(),
76
+ email: z.string(),
77
+ given_name: z.string().nullable(),
78
+ family_name: z.string().nullable(),
79
+ });
80
+ export const whoHasAbilityResponseSchema = z.object({
81
+ ability: z.string(),
82
+ roles: z.array(abilityHolderRoleSchema),
83
+ users: z.array(abilityHolderUserSchema),
84
+ });
85
+ /**
86
+ * Editor payloads. `roleId` is echoed back on both responses so the
87
+ * caller can match async writes against the role they were editing
88
+ * without holding the id separately. `abilities` is the authoritative
89
+ * stored set after the write.
90
+ */
91
+ export const getRoleAbilitiesResponseSchema = z.object({
92
+ roleId: z.string(),
93
+ abilities: z.array(z.string()),
94
+ });
95
+ export const setRoleAbilitiesResponseSchema = z.object({
96
+ roleId: z.string(),
97
+ abilities: z.array(z.string()),
98
+ });
99
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../../src/modules/admin-permissions/schemas.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+ import type { AbilityRegistry } from '@byline/auth';
9
+ import type { AdminStore } from '../../store.js';
10
+ import type { GetRoleAbilitiesRequest, GetRoleAbilitiesResponse, ListRegisteredAbilitiesResponse, SetRoleAbilitiesRequest, SetRoleAbilitiesResponse, WhoHasAbilityRequest, WhoHasAbilityResponse } from './schemas.js';
11
+ /**
12
+ * Read-only inspector service for admin-permissions.
13
+ *
14
+ * Two responsibilities:
15
+ *
16
+ * 1. **Enumerate registered abilities.** Pure registry read — no DB
17
+ * access. The registry is populated at `initBylineCore()` time
18
+ * by collection auto-registration plus subsystem registrars
19
+ * (`registerAdminAbilities`).
20
+ * 2. **Resolve the who-has matrix.** For a given ability key, list
21
+ * the roles that grant it and the distinct admin users
22
+ * transitively holding it. Backed by two single-query joins on
23
+ * the permissions repository, then resolved against the roles
24
+ * and users repositories so the inspector can render names
25
+ * without further round-trips.
26
+ *
27
+ * The editor surface (`getRoleAbilities` / `setRoleAbilities`) is
28
+ * deliberately not on this service yet — it lands with Phase B and
29
+ * will live alongside these methods.
30
+ */
31
+ export declare class AdminPermissionsService {
32
+ #private;
33
+ constructor(deps: {
34
+ store: AdminStore;
35
+ abilities: AbilityRegistry;
36
+ });
37
+ listRegisteredAbilities(): ListRegisteredAbilitiesResponse;
38
+ getRoleAbilities(request: GetRoleAbilitiesRequest): Promise<GetRoleAbilitiesResponse>;
39
+ setRoleAbilities(request: SetRoleAbilitiesRequest): Promise<SetRoleAbilitiesResponse>;
40
+ whoHasAbility(request: WhoHasAbilityRequest): Promise<WhoHasAbilityResponse>;
41
+ }
42
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/modules/admin-permissions/service.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAOnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,KAAK,EACV,uBAAuB,EACvB,wBAAwB,EACxB,+BAA+B,EAC/B,uBAAuB,EACvB,wBAAwB,EACxB,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,cAAc,CAAA;AAErB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,uBAAuB;;gBAItB,IAAI,EAAE;QAAE,KAAK,EAAE,UAAU,CAAC;QAAC,SAAS,EAAE,eAAe,CAAA;KAAE;IAKnE,uBAAuB,IAAI,+BAA+B;IAkBpD,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAOrF,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAwBrF,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAgCnF"}