@byline/admin 2.4.0 → 2.4.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.
Files changed (177) hide show
  1. package/dist/abilities.js +5 -24
  2. package/dist/index.js +8 -30
  3. package/dist/lib/assert-admin-actor.js +13 -74
  4. package/dist/lib/create-command.js +6 -16
  5. package/dist/modules/admin-account/commands.js +35 -24
  6. package/dist/modules/admin-account/components/change-password.d.ts +8 -0
  7. package/dist/modules/admin-account/components/change-password.js +192 -0
  8. package/dist/modules/admin-account/components/change-password.module.js +8 -0
  9. package/dist/modules/admin-account/components/change-password_module.css +27 -0
  10. package/dist/modules/admin-account/components/container.d.ts +29 -0
  11. package/dist/modules/admin-account/components/container.js +298 -0
  12. package/dist/modules/admin-account/components/container.module.js +28 -0
  13. package/dist/modules/admin-account/components/container_module.css +106 -0
  14. package/dist/modules/admin-account/components/update.d.ts +8 -0
  15. package/dist/modules/admin-account/components/update.js +207 -0
  16. package/dist/modules/admin-account/components/update.module.js +8 -0
  17. package/dist/modules/admin-account/components/update_module.css +27 -0
  18. package/dist/modules/admin-account/errors.js +14 -45
  19. package/dist/modules/admin-account/index.js +4 -34
  20. package/dist/modules/admin-account/schemas.js +25 -59
  21. package/dist/modules/admin-account/service.js +56 -61
  22. package/dist/modules/admin-permissions/abilities.js +6 -24
  23. package/dist/modules/admin-permissions/commands.js +42 -28
  24. package/dist/modules/admin-permissions/components/inspector.d.ts +4 -0
  25. package/dist/modules/admin-permissions/components/inspector.js +284 -0
  26. package/dist/modules/admin-permissions/components/inspector.module.js +56 -0
  27. package/dist/modules/admin-permissions/components/inspector_module.css +238 -0
  28. package/dist/modules/admin-permissions/dto.js +3 -16
  29. package/dist/modules/admin-permissions/errors.js +14 -27
  30. package/dist/modules/admin-permissions/index.js +6 -26
  31. package/dist/modules/admin-permissions/repository.js +1 -8
  32. package/dist/modules/admin-permissions/schemas.js +33 -70
  33. package/dist/modules/admin-permissions/service.js +88 -92
  34. package/dist/modules/admin-roles/abilities.js +8 -30
  35. package/dist/modules/admin-roles/commands.js +89 -55
  36. package/dist/modules/admin-roles/components/create.d.ts +7 -0
  37. package/dist/modules/admin-roles/components/create.js +177 -0
  38. package/dist/modules/admin-roles/components/create.module.js +8 -0
  39. package/dist/modules/admin-roles/components/create_module.css +27 -0
  40. package/dist/modules/admin-roles/components/permissions.d.ts +10 -0
  41. package/dist/modules/admin-roles/components/permissions.js +303 -0
  42. package/dist/modules/admin-roles/components/permissions.module.js +44 -0
  43. package/dist/modules/admin-roles/components/permissions_module.css +192 -0
  44. package/dist/modules/admin-roles/components/update.d.ts +8 -0
  45. package/dist/modules/admin-roles/components/update.js +166 -0
  46. package/dist/modules/admin-roles/components/update.module.js +8 -0
  47. package/dist/modules/admin-roles/components/update_module.css +27 -0
  48. package/dist/modules/admin-roles/dto.js +3 -16
  49. package/dist/modules/admin-roles/errors.js +16 -40
  50. package/dist/modules/admin-roles/index.js +6 -26
  51. package/dist/modules/admin-roles/repository.js +1 -8
  52. package/dist/modules/admin-roles/schemas.js +41 -71
  53. package/dist/modules/admin-roles/service.js +79 -82
  54. package/dist/modules/admin-users/abilities.js +9 -38
  55. package/dist/modules/admin-users/commands.js +92 -50
  56. package/dist/modules/admin-users/components/create.d.ts +8 -0
  57. package/dist/modules/admin-users/components/create.js +268 -0
  58. package/dist/modules/admin-users/components/create.module.js +10 -0
  59. package/dist/modules/admin-users/components/create_module.css +45 -0
  60. package/dist/modules/admin-users/components/roles.d.ts +11 -0
  61. package/dist/modules/admin-users/components/roles.js +148 -0
  62. package/dist/modules/admin-users/components/roles.module.js +18 -0
  63. package/dist/modules/admin-users/components/roles_module.css +75 -0
  64. package/dist/modules/admin-users/components/set-password.d.ts +8 -0
  65. package/dist/modules/admin-users/components/set-password.js +170 -0
  66. package/dist/modules/admin-users/components/set-password.module.js +9 -0
  67. package/dist/modules/admin-users/components/set-password_module.css +31 -0
  68. package/dist/modules/admin-users/components/update.d.ts +8 -0
  69. package/dist/modules/admin-users/components/update.js +254 -0
  70. package/dist/modules/admin-users/components/update.module.js +9 -0
  71. package/dist/modules/admin-users/components/update_module.css +34 -0
  72. package/dist/modules/admin-users/dto.js +3 -18
  73. package/dist/modules/admin-users/errors.js +17 -43
  74. package/dist/modules/admin-users/index.js +7 -27
  75. package/dist/modules/admin-users/repository.js +1 -8
  76. package/dist/modules/admin-users/schemas.js +44 -75
  77. package/dist/modules/admin-users/seed-super-admin.js +9 -34
  78. package/dist/modules/admin-users/service.js +76 -91
  79. package/dist/modules/auth/components/sign-in-form.d.ts +12 -0
  80. package/dist/modules/auth/components/sign-in-form.js +115 -0
  81. package/dist/modules/auth/components/sign-in-form.module.js +12 -0
  82. package/dist/modules/auth/components/sign-in-form_module.css +41 -0
  83. package/dist/modules/auth/index.js +3 -24
  84. package/dist/modules/auth/jwt-session-provider.js +179 -149
  85. package/dist/modules/auth/password.js +11 -53
  86. package/dist/modules/auth/phc.js +21 -54
  87. package/dist/modules/auth/refresh-tokens-repository.js +1 -8
  88. package/dist/modules/auth/resolve-actor.js +6 -28
  89. package/dist/services/admin-services-context.d.ts +16 -0
  90. package/dist/services/admin-services-context.js +13 -0
  91. package/dist/services/admin-services-types.d.ts +129 -0
  92. package/dist/services/admin-services-types.js +1 -0
  93. package/dist/store.js +1 -8
  94. package/dist/vendor/noble-argon2/_blake.js +277 -45
  95. package/dist/vendor/noble-argon2/_md.js +81 -136
  96. package/dist/vendor/noble-argon2/_u64.js +65 -67
  97. package/dist/vendor/noble-argon2/argon2.js +181 -342
  98. package/dist/vendor/noble-argon2/blake2.js +252 -327
  99. package/dist/vendor/noble-argon2/utils.js +110 -490
  100. package/dist/vendor/noble-argon2/utils.js.LICENSE.txt +1 -0
  101. package/package.json +89 -10
  102. package/src/abilities.ts +32 -0
  103. package/src/declarations.d.ts +4 -0
  104. package/src/index.ts +39 -0
  105. package/src/lib/assert-admin-actor.ts +90 -0
  106. package/src/lib/create-command.ts +109 -0
  107. package/src/modules/admin-account/commands.ts +76 -0
  108. package/src/modules/admin-account/components/change-password.module.css +40 -0
  109. package/src/modules/admin-account/components/change-password.tsx +232 -0
  110. package/src/modules/admin-account/components/container.module.css +158 -0
  111. package/src/modules/admin-account/components/container.tsx +229 -0
  112. package/src/modules/admin-account/components/update.module.css +40 -0
  113. package/src/modules/admin-account/components/update.tsx +263 -0
  114. package/src/modules/admin-account/errors.ts +75 -0
  115. package/src/modules/admin-account/index.ts +60 -0
  116. package/src/modules/admin-account/schemas.ts +84 -0
  117. package/src/modules/admin-account/service.ts +92 -0
  118. package/src/modules/admin-permissions/abilities.ts +46 -0
  119. package/src/modules/admin-permissions/commands.ts +103 -0
  120. package/src/modules/admin-permissions/components/inspector.module.css +326 -0
  121. package/src/modules/admin-permissions/components/inspector.tsx +298 -0
  122. package/src/modules/admin-permissions/dto.ts +28 -0
  123. package/src/modules/admin-permissions/errors.ts +57 -0
  124. package/src/modules/admin-permissions/index.ts +72 -0
  125. package/src/modules/admin-permissions/repository.ts +49 -0
  126. package/src/modules/admin-permissions/schemas.ts +128 -0
  127. package/src/modules/admin-permissions/service.ts +137 -0
  128. package/src/modules/admin-roles/abilities.ts +62 -0
  129. package/src/modules/admin-roles/commands.ts +161 -0
  130. package/src/modules/admin-roles/components/create.module.css +40 -0
  131. package/src/modules/admin-roles/components/create.tsx +218 -0
  132. package/src/modules/admin-roles/components/permissions.module.css +279 -0
  133. package/src/modules/admin-roles/components/permissions.tsx +396 -0
  134. package/src/modules/admin-roles/components/update.module.css +40 -0
  135. package/src/modules/admin-roles/components/update.tsx +218 -0
  136. package/src/modules/admin-roles/dto.ts +30 -0
  137. package/src/modules/admin-roles/errors.ts +76 -0
  138. package/src/modules/admin-roles/index.ts +81 -0
  139. package/src/modules/admin-roles/repository.ts +96 -0
  140. package/src/modules/admin-roles/schemas.ts +139 -0
  141. package/src/modules/admin-roles/service.ts +136 -0
  142. package/src/modules/admin-users/abilities.ts +76 -0
  143. package/src/modules/admin-users/commands.ts +157 -0
  144. package/src/modules/admin-users/components/create.module.css +63 -0
  145. package/src/modules/admin-users/components/create.tsx +323 -0
  146. package/src/modules/admin-users/components/roles.module.css +119 -0
  147. package/src/modules/admin-users/components/roles.tsx +172 -0
  148. package/src/modules/admin-users/components/set-password.module.css +46 -0
  149. package/src/modules/admin-users/components/set-password.tsx +199 -0
  150. package/src/modules/admin-users/components/update.module.css +49 -0
  151. package/src/modules/admin-users/components/update.tsx +328 -0
  152. package/src/modules/admin-users/dto.ts +39 -0
  153. package/src/modules/admin-users/errors.ts +84 -0
  154. package/src/modules/admin-users/index.ts +91 -0
  155. package/src/modules/admin-users/repository.ts +161 -0
  156. package/src/modules/admin-users/schemas.ts +168 -0
  157. package/src/modules/admin-users/seed-super-admin.ts +102 -0
  158. package/src/modules/admin-users/service.ts +166 -0
  159. package/src/modules/auth/components/sign-in-form.module.css +62 -0
  160. package/src/modules/auth/components/sign-in-form.tsx +132 -0
  161. package/src/modules/auth/index.ts +31 -0
  162. package/src/modules/auth/jwt-session-provider.ts +301 -0
  163. package/src/modules/auth/password.ts +94 -0
  164. package/src/modules/auth/phc.ts +121 -0
  165. package/src/modules/auth/refresh-tokens-repository.ts +74 -0
  166. package/src/modules/auth/resolve-actor.ts +42 -0
  167. package/src/services/admin-services-context.tsx +52 -0
  168. package/src/services/admin-services-types.ts +177 -0
  169. package/src/store.ts +32 -0
  170. package/src/vendor/noble-argon2/LICENSE +21 -0
  171. package/src/vendor/noble-argon2/README.md +87 -0
  172. package/src/vendor/noble-argon2/_blake.ts +58 -0
  173. package/src/vendor/noble-argon2/_md.ts +223 -0
  174. package/src/vendor/noble-argon2/_u64.ts +118 -0
  175. package/src/vendor/noble-argon2/argon2.ts +668 -0
  176. package/src/vendor/noble-argon2/blake2.ts +583 -0
  177. package/src/vendor/noble-argon2/utils.ts +849 -0
@@ -0,0 +1,192 @@
1
+ :is(.wrap-oHhxZn, .byline-role-permissions-wrap) {
2
+ gap: var(--spacing-12);
3
+ margin-bottom: var(--spacing-48);
4
+ flex-direction: column;
5
+ display: flex;
6
+ }
7
+
8
+ :is(.toolbar-xiFHRx, .byline-role-permissions-toolbar) {
9
+ align-items: center;
10
+ gap: var(--spacing-12);
11
+ padding: var(--spacing-12);
12
+ border: var(--border-width-thin) var(--border-style-solid) var(--gray-100);
13
+ background-color: var(--canvas-25);
14
+ border-radius: var(--border-radius-sm);
15
+ flex-wrap: wrap;
16
+ display: flex;
17
+ }
18
+
19
+ :is(.counter-pkbHZT, .byline-role-permissions-counter) {
20
+ font-size: var(--font-size-sm);
21
+ margin: 0;
22
+ }
23
+
24
+ :is(.counter-num-zDSQWA, .byline-role-permissions-counter-num) {
25
+ font-weight: var(--font-weight-medium);
26
+ }
27
+
28
+ :is(.actions-TSS9AS, .byline-role-permissions-actions) {
29
+ align-items: center;
30
+ gap: var(--spacing-8);
31
+ margin-left: auto;
32
+ display: flex;
33
+ }
34
+
35
+ :is(.action-jzyool, .byline-role-permissions-action) {
36
+ min-width: 4rem;
37
+ }
38
+
39
+ :is(.checkbox-auto-TFunEY, .byline-role-permissions-checkbox-auto) {
40
+ width: auto !important;
41
+ }
42
+
43
+ :is(.groups-agis2F, .byline-role-permissions-groups) {
44
+ gap: var(--spacing-8);
45
+ flex-direction: column;
46
+ display: flex;
47
+ }
48
+
49
+ :is(.group-Xf1YG0, .byline-role-permissions-group) {
50
+ border: var(--border-width-thin) var(--border-style-solid) var(--gray-100);
51
+ border-radius: var(--border-radius-sm);
52
+ }
53
+
54
+ :is(.group-head-IUhwe9, .byline-role-permissions-group-head) {
55
+ padding: var(--spacing-12);
56
+ border-bottom: var(--border-width-thin) var(--border-style-solid) var(--gray-100);
57
+ justify-content: space-between;
58
+ align-items: center;
59
+ display: flex;
60
+ }
61
+
62
+ :is(.group-name-jAKMI7, .byline-role-permissions-group-name) {
63
+ font-weight: var(--font-weight-medium);
64
+ }
65
+
66
+ :is(.group-count-BQDjxo, .byline-role-permissions-group-count) {
67
+ margin-left: var(--spacing-8);
68
+ font-size: var(--font-size-xs);
69
+ }
70
+
71
+ :is(.group-buttons-KZVdZK, .byline-role-permissions-group-buttons) {
72
+ align-items: center;
73
+ gap: var(--spacing-4);
74
+ display: flex;
75
+ }
76
+
77
+ :is(.grid-tLxHtG, .byline-role-permissions-grid) {
78
+ gap: var(--spacing-4);
79
+ padding: var(--spacing-12);
80
+ grid-template-columns: 1fr;
81
+ display: grid;
82
+ }
83
+
84
+ @media (min-width: 40rem) {
85
+ :is(.grid-tLxHtG, .byline-role-permissions-grid) {
86
+ grid-template-columns: 1fr 1fr;
87
+ }
88
+ }
89
+
90
+ :is(.row-Q7NujV, .byline-role-permissions-row) {
91
+ align-items: flex-start;
92
+ gap: var(--spacing-8);
93
+ padding: var(--spacing-4) 0;
94
+ display: flex;
95
+ }
96
+
97
+ :is(.label-wOoMvK, .byline-role-permissions-label) {
98
+ cursor: default;
99
+ flex: 1 1 0;
100
+ min-width: 0;
101
+ }
102
+
103
+ :is(.label-edit-oRTY7d, .byline-role-permissions-label-edit) {
104
+ cursor: pointer;
105
+ }
106
+
107
+ :is(.label-head-nm1MZV, .byline-role-permissions-label-head) {
108
+ align-items: center;
109
+ gap: var(--spacing-8);
110
+ display: flex;
111
+ }
112
+
113
+ :is(.label-name-c9gt0V, .byline-role-permissions-label-name) {
114
+ font-size: var(--font-size-sm);
115
+ font-weight: var(--font-weight-medium);
116
+ }
117
+
118
+ :is(.key-ZIoxQA, .byline-role-permissions-key) {
119
+ background-color: var(--gray-100);
120
+ font-size: var(--font-size-xs);
121
+ border-radius: var(--border-radius-sm);
122
+ padding: .125rem .375rem;
123
+ }
124
+
125
+ :is(.description-FHyeNa, .byline-role-permissions-description) {
126
+ font-size: var(--font-size-xs);
127
+ margin-bottom: 0;
128
+ }
129
+
130
+ :is(.mode-toggle-rfVYTa, .byline-role-permissions-mode-toggle) {
131
+ border: var(--border-width-thin) var(--border-style-solid) var(--gray-200);
132
+ border-radius: var(--border-radius-sm);
133
+ display: inline-flex;
134
+ overflow: hidden;
135
+ }
136
+
137
+ :is(.mode-button-y37cUe, .byline-role-permissions-mode-button) {
138
+ font-size: var(--font-size-xs);
139
+ cursor: pointer;
140
+ background-color: #0000;
141
+ border: 0;
142
+ padding: .125rem .625rem;
143
+ transition: background-color .15s;
144
+ }
145
+
146
+ :is(.mode-button-y37cUe:hover, .byline-role-permissions-mode-button:hover) {
147
+ background-color: var(--gray-50);
148
+ }
149
+
150
+ :is(.mode-button-active-O9hDFq, .byline-role-permissions-mode-button-active) {
151
+ background-color: var(--gray-100);
152
+ font-weight: var(--font-weight-medium);
153
+ }
154
+
155
+ :is(.mode-button-divider-i7CEW9, .byline-role-permissions-mode-button-divider) {
156
+ border-left: var(--border-width-thin) var(--border-style-solid) var(--gray-200);
157
+ }
158
+
159
+ :is(.mode-button-disabled-i9SxhV, .byline-role-permissions-mode-button-disabled) {
160
+ opacity: .5;
161
+ cursor: not-allowed;
162
+ }
163
+
164
+ :is(:is([data-theme="dark"], .dark) .toolbar-xiFHRx, :is([data-theme="dark"], .dark) .byline-role-permissions-toolbar) {
165
+ border-color: var(--gray-700);
166
+ background-color: var(--canvas-800);
167
+ }
168
+
169
+ :is(:is([data-theme="dark"], .dark) .group-Xf1YG0, :is([data-theme="dark"], .dark) .byline-role-permissions-group) {
170
+ border-color: var(--gray-700);
171
+ }
172
+
173
+ :is(:is([data-theme="dark"], .dark) .group-head-IUhwe9, :is([data-theme="dark"], .dark) .byline-role-permissions-group-head) {
174
+ border-bottom-color: var(--gray-700);
175
+ }
176
+
177
+ :is(:is([data-theme="dark"], .dark) .key-ZIoxQA, :is([data-theme="dark"], .dark) .byline-role-permissions-key) {
178
+ background-color: var(--canvas-800);
179
+ }
180
+
181
+ :is(:is([data-theme="dark"], .dark) .mode-toggle-rfVYTa, :is([data-theme="dark"], .dark) .byline-role-permissions-mode-toggle) {
182
+ border-color: var(--gray-700);
183
+ }
184
+
185
+ :is(:is([data-theme="dark"], .dark) .mode-button-y37cUe:hover, :is([data-theme="dark"], .dark) .byline-role-permissions-mode-button:hover), :is(:is([data-theme="dark"], .dark) .mode-button-active-O9hDFq, :is([data-theme="dark"], .dark) .byline-role-permissions-mode-button-active) {
186
+ background-color: var(--canvas-700);
187
+ }
188
+
189
+ :is(:is([data-theme="dark"], .dark) .mode-button-divider-i7CEW9, :is([data-theme="dark"], .dark) .byline-role-permissions-mode-button-divider) {
190
+ border-left-color: var(--gray-700);
191
+ }
192
+
@@ -0,0 +1,8 @@
1
+ import type { AdminRoleResponse } from '../index.js';
2
+ interface UpdateRoleProps {
3
+ role: AdminRoleResponse;
4
+ onClose?: () => void;
5
+ onSuccess?: (role: AdminRoleResponse) => void;
6
+ }
7
+ export declare function UpdateRole({ role, onClose, onSuccess }: UpdateRoleProps): import("react").JSX.Element;
8
+ export {};
@@ -0,0 +1,166 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useState } from "react";
4
+ import { revalidateLogic, useForm } from "@tanstack/react-form-start";
5
+ import { Alert, Button, Input, LoaderEllipsis, TextArea } from "@byline/ui/react";
6
+ import classnames from "classnames";
7
+ import { z } from "zod";
8
+ import { useBylineAdminServices } from "../../../services/admin-services-context.js";
9
+ import update_module from "./update.module.js";
10
+ const updateRoleSchema = z.object({
11
+ name: z.string().min(1, 'Name is required').max(128, 'Name must not exceed 128 characters'),
12
+ description: z.string().max(2000, "Description must not exceed 2000 characters")
13
+ });
14
+ function defaultsFrom(role) {
15
+ return {
16
+ name: role.name,
17
+ description: role.description ?? ''
18
+ };
19
+ }
20
+ function buildPatch(values, role) {
21
+ const patch = {};
22
+ const normaliseText = (value)=>value.trim().length > 0 ? value : null;
23
+ const nextDescription = normaliseText(values.description);
24
+ const nextName = values.name.trim();
25
+ if (nextName !== role.name) patch.name = nextName;
26
+ if (nextDescription !== role.description) patch.description = nextDescription;
27
+ return patch;
28
+ }
29
+ function UpdateRole({ role, onClose, onSuccess }) {
30
+ const { updateAdminRole } = useBylineAdminServices();
31
+ const [formError, setFormError] = useState(null);
32
+ const [successMessage, setSuccessMessage] = useState(null);
33
+ const form = useForm({
34
+ defaultValues: defaultsFrom(role),
35
+ validationLogic: revalidateLogic({
36
+ mode: 'blur',
37
+ modeAfterSubmission: 'change'
38
+ }),
39
+ validators: {
40
+ onDynamic: updateRoleSchema
41
+ },
42
+ onSubmit: async ({ value })=>{
43
+ setFormError(null);
44
+ setSuccessMessage(null);
45
+ const patch = buildPatch(value, role);
46
+ if (0 === Object.keys(patch).length) return void setSuccessMessage('No changes to save.');
47
+ try {
48
+ const updated = await updateAdminRole({
49
+ data: {
50
+ id: role.id,
51
+ vid: role.vid,
52
+ patch
53
+ }
54
+ });
55
+ setSuccessMessage('Saved.');
56
+ onSuccess?.(updated);
57
+ } catch (err) {
58
+ const code = getErrorCode(err);
59
+ if ('admin.roles.versionConflict' === code) return void setFormError('This role has been modified elsewhere since you opened this form. Reload to get the latest values and try again.');
60
+ if ('admin.roles.notFound' === code) return void setFormError('This role no longer exists.');
61
+ setFormError('Could not save changes. Please try again.');
62
+ }
63
+ }
64
+ });
65
+ return /*#__PURE__*/ jsx("div", {
66
+ className: classnames('byline-role-update-wrap', update_module.wrap),
67
+ children: /*#__PURE__*/ jsxs("form", {
68
+ noValidate: true,
69
+ onSubmit: (event)=>{
70
+ event.preventDefault();
71
+ event.stopPropagation();
72
+ form.handleSubmit();
73
+ },
74
+ className: classnames('byline-role-update-form', update_module.form),
75
+ children: [
76
+ formError ? /*#__PURE__*/ jsx(Alert, {
77
+ intent: "danger",
78
+ children: formError
79
+ }) : null,
80
+ successMessage ? /*#__PURE__*/ jsx(Alert, {
81
+ intent: "success",
82
+ children: successMessage
83
+ }) : null,
84
+ /*#__PURE__*/ jsx(form.Field, {
85
+ name: "name",
86
+ children: (field)=>/*#__PURE__*/ jsx(Input, {
87
+ label: "Name",
88
+ id: "role-name",
89
+ name: field.name,
90
+ value: field.state.value,
91
+ onBlur: field.handleBlur,
92
+ onChange: (e)=>field.handleChange(e.currentTarget.value),
93
+ error: field.state.meta.errors.length > 0,
94
+ errorText: firstError(field.state.meta.errors),
95
+ required: true
96
+ })
97
+ }),
98
+ /*#__PURE__*/ jsx(Input, {
99
+ label: "Machine name",
100
+ id: "role-machine-name",
101
+ name: "machine_name",
102
+ value: role.machine_name,
103
+ readOnly: true,
104
+ disabled: true,
105
+ helpText: "The stable code-side handle. Cannot be changed after creation."
106
+ }),
107
+ /*#__PURE__*/ jsx(form.Field, {
108
+ name: "description",
109
+ children: (field)=>/*#__PURE__*/ jsx(TextArea, {
110
+ label: "Description",
111
+ id: "role-description",
112
+ name: field.name,
113
+ value: field.state.value,
114
+ onBlur: field.handleBlur,
115
+ onChange: (e)=>field.handleChange(e.currentTarget.value),
116
+ error: field.state.meta.errors.length > 0,
117
+ errorText: firstError(field.state.meta.errors),
118
+ rows: 3
119
+ })
120
+ }),
121
+ /*#__PURE__*/ jsxs("div", {
122
+ className: classnames('byline-role-update-actions', update_module.actions),
123
+ children: [
124
+ /*#__PURE__*/ jsx(Button, {
125
+ type: "button",
126
+ intent: "secondary",
127
+ size: "sm",
128
+ onClick: onClose,
129
+ className: classnames('byline-role-update-action', update_module.action),
130
+ children: successMessage ? 'Close' : 'Cancel'
131
+ }),
132
+ /*#__PURE__*/ jsx(form.Subscribe, {
133
+ selector: (state)=>({
134
+ canSubmit: state.canSubmit,
135
+ isSubmitting: state.isSubmitting
136
+ }),
137
+ children: ({ canSubmit, isSubmitting })=>/*#__PURE__*/ jsx(Button, {
138
+ size: "sm",
139
+ intent: "primary",
140
+ type: "submit",
141
+ disabled: !canSubmit || isSubmitting,
142
+ className: classnames('byline-role-update-action', update_module.action),
143
+ children: true === isSubmitting ? /*#__PURE__*/ jsx(LoaderEllipsis, {
144
+ size: 42
145
+ }) : 'Save'
146
+ })
147
+ })
148
+ ]
149
+ })
150
+ ]
151
+ })
152
+ });
153
+ }
154
+ function firstError(errors) {
155
+ for (const err of errors){
156
+ if ('string' == typeof err) return err;
157
+ if (err && 'object' == typeof err && 'message' in err) {
158
+ const msg = err.message;
159
+ if ('string' == typeof msg) return msg;
160
+ }
161
+ }
162
+ }
163
+ function getErrorCode(err) {
164
+ return 'string' == typeof err?.code ? err.code : null;
165
+ }
166
+ export { UpdateRole };
@@ -0,0 +1,8 @@
1
+ import "./update_module.css";
2
+ const update_module = {
3
+ wrap: "wrap-eLLoXn",
4
+ form: "form-xu5exJ",
5
+ actions: "actions-seCJ1H",
6
+ action: "action-zmeHlJ"
7
+ };
8
+ export default update_module;
@@ -0,0 +1,27 @@
1
+ :is(.wrap-eLLoXn, .byline-role-update-wrap) {
2
+ gap: var(--spacing-8);
3
+ padding: var(--spacing-4);
4
+ margin-top: var(--spacing-4);
5
+ flex-direction: column;
6
+ display: flex;
7
+ }
8
+
9
+ :is(.form-xu5exJ, .byline-role-update-form) {
10
+ gap: var(--spacing-16);
11
+ padding-top: var(--spacing-8);
12
+ flex-direction: column;
13
+ display: flex;
14
+ }
15
+
16
+ :is(.actions-seCJ1H, .byline-role-update-actions) {
17
+ justify-content: flex-end;
18
+ align-items: center;
19
+ gap: var(--spacing-8);
20
+ margin-top: var(--spacing-16);
21
+ display: flex;
22
+ }
23
+
24
+ :is(.action-zmeHlJ, .byline-role-update-action) {
25
+ min-width: 4rem;
26
+ }
27
+
@@ -1,18 +1,4 @@
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 `AdminRoleRow` into its public `AdminRoleResponse` form.
10
- *
11
- * Effectively an identity map today — the indirection exists so future
12
- * row-only fields (tenant id, soft-delete) stay opted out of the public
13
- * shape by default.
14
- */
15
- export function toAdminRole(row) {
1
+ function toAdminRole(row) {
16
2
  return {
17
3
  id: row.id,
18
4
  vid: row.vid,
@@ -21,6 +7,7 @@ export function toAdminRole(row) {
21
7
  description: row.description,
22
8
  order: row.order,
23
9
  created_at: row.created_at,
24
- updated_at: row.updated_at,
10
+ updated_at: row.updated_at
25
11
  };
26
12
  }
13
+ export { toAdminRole };
@@ -1,48 +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
- * Module-local error codes for admin-roles.
10
- *
11
- * Mirrors the `code + factory` shape used by `AdminUsersError`. Codes
12
- * are dot-prefixed (`admin.roles.*`) so they sort alongside the matching
13
- * ability keys in logs and admin UI messages.
14
- */
15
- export const AdminRolesErrorCodes = {
1
+ const AdminRolesErrorCodes = {
16
2
  NOT_FOUND: 'admin.roles.notFound',
17
3
  MACHINE_NAME_IN_USE: 'admin.roles.machineNameInUse',
18
4
  VERSION_CONFLICT: 'admin.roles.versionConflict',
19
- USER_NOT_FOUND: 'admin.roles.userNotFound',
5
+ USER_NOT_FOUND: 'admin.roles.userNotFound'
20
6
  };
21
- export class AdminRolesError extends Error {
22
- code;
23
- constructor(code, options) {
24
- super(options.message, options.cause != null ? { cause: options.cause } : undefined);
7
+ class AdminRolesError extends Error {
8
+ constructor(code, options){
9
+ super(options.message, null != options.cause ? {
10
+ cause: options.cause
11
+ } : void 0);
25
12
  this.name = 'AdminRolesError';
26
13
  this.code = code;
27
14
  }
28
15
  }
29
- const make = (code, defaultMessage) => (options) => new AdminRolesError(code, {
30
- message: options?.message ?? defaultMessage,
31
- cause: options?.cause,
32
- });
33
- /** The referenced admin role id does not exist. */
34
- export const ERR_ADMIN_ROLE_NOT_FOUND = make(AdminRolesErrorCodes.NOT_FOUND, 'admin role not found');
35
- /** Creating a role conflicts with an existing `machine_name`. */
36
- export const ERR_ADMIN_ROLE_MACHINE_NAME_IN_USE = make(AdminRolesErrorCodes.MACHINE_NAME_IN_USE, 'machine name already in use');
37
- /**
38
- * The stored `vid` does not match the client-supplied `expectedVid` —
39
- * the caller is holding a stale version of the row. Typical admin-UI
40
- * response is to reload the edit form with the current values.
41
- */
42
- export const ERR_ADMIN_ROLE_VERSION_CONFLICT = make(AdminRolesErrorCodes.VERSION_CONFLICT, 'admin role has been modified elsewhere — please reload and try again');
43
- /**
44
- * The admin user targeted by a role-assignment operation does not exist.
45
- * Module-local rather than reaching into `@byline/admin/admin-users`'
46
- * error codes — keeps the modules decoupled.
47
- */
48
- export const ERR_ADMIN_ROLE_USER_NOT_FOUND = make(AdminRolesErrorCodes.USER_NOT_FOUND, 'admin user not found');
16
+ const make = (code, defaultMessage)=>(options)=>new AdminRolesError(code, {
17
+ message: options?.message ?? defaultMessage,
18
+ cause: options?.cause
19
+ });
20
+ const ERR_ADMIN_ROLE_NOT_FOUND = make(AdminRolesErrorCodes.NOT_FOUND, 'admin role not found');
21
+ const ERR_ADMIN_ROLE_MACHINE_NAME_IN_USE = make(AdminRolesErrorCodes.MACHINE_NAME_IN_USE, 'machine name already in use');
22
+ const ERR_ADMIN_ROLE_VERSION_CONFLICT = make(AdminRolesErrorCodes.VERSION_CONFLICT, 'admin role has been modified elsewhere please reload and try again');
23
+ const ERR_ADMIN_ROLE_USER_NOT_FOUND = make(AdminRolesErrorCodes.USER_NOT_FOUND, 'admin user not found');
24
+ export { AdminRolesError, AdminRolesErrorCodes, ERR_ADMIN_ROLE_MACHINE_NAME_IN_USE, ERR_ADMIN_ROLE_NOT_FOUND, ERR_ADMIN_ROLE_USER_NOT_FOUND, ERR_ADMIN_ROLE_VERSION_CONFLICT };
@@ -1,26 +1,6 @@
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-roles` — role CRUD, reorder, and role ↔ user
10
- * assignment.
11
- *
12
- * Exports the adapter-facing `AdminRolesRepository` contract, ability
13
- * keys, transport-agnostic commands, the `AdminRolesService`, and the
14
- * module's error types. Commands are the recommended entry point for
15
- * any caller; the service is exposed for internal uses (other services,
16
- * future seeds) that want to skip Zod/ability overhead.
17
- *
18
- * Per-role ability grants live on the sibling
19
- * `@byline/admin/admin-permissions` module, not here.
20
- */
21
- export { ADMIN_ROLES_ABILITIES, registerAdminRolesAbilities, } from './abilities.js';
22
- export { createAdminRoleCommand, deleteAdminRoleCommand, getAdminRoleCommand, getRolesForUserCommand, listAdminRolesCommand, reorderAdminRolesCommand, setRolesForUserCommand, updateAdminRoleCommand, } from './commands.js';
23
- export { toAdminRole } from './dto.js';
24
- export { AdminRolesError, AdminRolesErrorCodes, ERR_ADMIN_ROLE_MACHINE_NAME_IN_USE, ERR_ADMIN_ROLE_NOT_FOUND, ERR_ADMIN_ROLE_USER_NOT_FOUND, ERR_ADMIN_ROLE_VERSION_CONFLICT, } from './errors.js';
25
- export { adminRoleListResponseSchema, adminRoleResponseSchema, createAdminRoleRequestSchema, deleteAdminRoleRequestSchema, getAdminRoleRequestSchema, getRolesForUserRequestSchema, listAdminRolesRequestSchema, reorderAdminRolesRequestSchema, setRolesForUserRequestSchema, updateAdminRoleRequestSchema, userRolesResponseSchema, } from './schemas.js';
26
- export { AdminRolesService } from './service.js';
1
+ export { ADMIN_ROLES_ABILITIES, registerAdminRolesAbilities } from "./abilities.js";
2
+ export { createAdminRoleCommand, deleteAdminRoleCommand, getAdminRoleCommand, getRolesForUserCommand, listAdminRolesCommand, reorderAdminRolesCommand, setRolesForUserCommand, updateAdminRoleCommand } from "./commands.js";
3
+ export { toAdminRole } from "./dto.js";
4
+ export { AdminRolesError, AdminRolesErrorCodes, ERR_ADMIN_ROLE_MACHINE_NAME_IN_USE, ERR_ADMIN_ROLE_NOT_FOUND, ERR_ADMIN_ROLE_USER_NOT_FOUND, ERR_ADMIN_ROLE_VERSION_CONFLICT } from "./errors.js";
5
+ export { adminRoleListResponseSchema, adminRoleResponseSchema, createAdminRoleRequestSchema, deleteAdminRoleRequestSchema, getAdminRoleRequestSchema, getRolesForUserRequestSchema, listAdminRolesRequestSchema, reorderAdminRolesRequestSchema, setRolesForUserRequestSchema, updateAdminRoleRequestSchema, userRolesResponseSchema } from "./schemas.js";
6
+ export { AdminRolesService } from "./service.js";
@@ -1,8 +1 @@
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 {};
1
+ export { };