@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,45 @@
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 { RequestContext } from '@byline/auth';
9
+ import type { AdminStore } from '../../store.js';
10
+ import type { AdminUserListResponse, AdminUserResponse, OkResponse } from './schemas.js';
11
+ /**
12
+ * Transport-agnostic commands for the admin-users module.
13
+ *
14
+ * Each command is a plain exported function — not a class method — to
15
+ * match Byline's existing `document-lifecycle` shape. Every command
16
+ * follows the same four steps in the same order:
17
+ *
18
+ * 1. `schema.parse(input)` — Zod-validate and normalise the raw input.
19
+ * Throws `ZodError` on invalid shape; transport adapters translate
20
+ * that into a 400-ish response.
21
+ * 2. `assertAdminActor(context, ability)` — require an `AdminAuth`
22
+ * actor holding the specific ability. Throws `ERR_UNAUTHENTICATED`
23
+ * or `ERR_FORBIDDEN`.
24
+ * 3. Call the `AdminUsersService` method with the validated input
25
+ * (plus the actor where an invariant needs it).
26
+ * 4. Parse the response through its output schema. In production the
27
+ * check is redundant with the DTO's type; in tests it catches
28
+ * drift between schema and DTO early.
29
+ *
30
+ * The `deps` argument holds the `AdminStore`. The webapp wraps these in
31
+ * server fns that supply `deps` from the application's singleton store;
32
+ * scripts and tests construct their own store and pass it in directly.
33
+ */
34
+ export interface AdminUsersCommandDeps {
35
+ store: AdminStore;
36
+ }
37
+ export declare function listAdminUsersCommand(context: RequestContext | undefined, input: unknown, deps: AdminUsersCommandDeps): Promise<AdminUserListResponse>;
38
+ export declare function getAdminUserCommand(context: RequestContext | undefined, input: unknown, deps: AdminUsersCommandDeps): Promise<AdminUserResponse>;
39
+ export declare function createAdminUserCommand(context: RequestContext | undefined, input: unknown, deps: AdminUsersCommandDeps): Promise<AdminUserResponse>;
40
+ export declare function updateAdminUserCommand(context: RequestContext | undefined, input: unknown, deps: AdminUsersCommandDeps): Promise<AdminUserResponse>;
41
+ export declare function setAdminUserPasswordCommand(context: RequestContext | undefined, input: unknown, deps: AdminUsersCommandDeps): Promise<AdminUserResponse>;
42
+ export declare function enableAdminUserCommand(context: RequestContext | undefined, input: unknown, deps: AdminUsersCommandDeps): Promise<OkResponse>;
43
+ export declare function disableAdminUserCommand(context: RequestContext | undefined, input: unknown, deps: AdminUsersCommandDeps): Promise<OkResponse>;
44
+ export declare function deleteAdminUserCommand(context: RequestContext | undefined, input: unknown, deps: AdminUsersCommandDeps): Promise<OkResponse>;
45
+ //# sourceMappingURL=commands.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../../src/modules/admin-users/commands.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAkBlD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;A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B,sBAAsB,CAC1C,OAAO,EAAE,cAAc,GAAG,SAAS,EACnC,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,qBAAqB,GAC1B,OAAO,CAAC,UAAU,CAAC,CAKrB"}
@@ -0,0 +1,63 @@
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_USERS_ABILITIES } from './abilities.js';
10
+ import { adminUserListResponseSchema, adminUserResponseSchema, createAdminUserRequestSchema, deleteAdminUserRequestSchema, disableAdminUserRequestSchema, enableAdminUserRequestSchema, getAdminUserRequestSchema, listAdminUsersRequestSchema, okResponseSchema, setAdminUserPasswordRequestSchema, updateAdminUserRequestSchema, } from './schemas.js';
11
+ import { AdminUsersService } from './service.js';
12
+ function serviceOf(deps) {
13
+ return new AdminUsersService({ repo: deps.store.adminUsers });
14
+ }
15
+ export async function listAdminUsersCommand(context, input, deps) {
16
+ const parsed = listAdminUsersRequestSchema.parse(input ?? {});
17
+ assertAdminActor(context, ADMIN_USERS_ABILITIES.read);
18
+ const result = await serviceOf(deps).listUsers(parsed);
19
+ return adminUserListResponseSchema.parse(result);
20
+ }
21
+ export async function getAdminUserCommand(context, input, deps) {
22
+ const parsed = getAdminUserRequestSchema.parse(input);
23
+ assertAdminActor(context, ADMIN_USERS_ABILITIES.read);
24
+ const result = await serviceOf(deps).getUser(parsed);
25
+ return adminUserResponseSchema.parse(result);
26
+ }
27
+ export async function createAdminUserCommand(context, input, deps) {
28
+ const parsed = createAdminUserRequestSchema.parse(input);
29
+ assertAdminActor(context, ADMIN_USERS_ABILITIES.create);
30
+ const result = await serviceOf(deps).createUser(parsed);
31
+ return adminUserResponseSchema.parse(result);
32
+ }
33
+ export async function updateAdminUserCommand(context, input, deps) {
34
+ const parsed = updateAdminUserRequestSchema.parse(input);
35
+ assertAdminActor(context, ADMIN_USERS_ABILITIES.update);
36
+ const result = await serviceOf(deps).updateUser(parsed);
37
+ return adminUserResponseSchema.parse(result);
38
+ }
39
+ export async function setAdminUserPasswordCommand(context, input, deps) {
40
+ const parsed = setAdminUserPasswordRequestSchema.parse(input);
41
+ assertAdminActor(context, ADMIN_USERS_ABILITIES.changePassword);
42
+ const result = await serviceOf(deps).setPassword(parsed);
43
+ return adminUserResponseSchema.parse(result);
44
+ }
45
+ export async function enableAdminUserCommand(context, input, deps) {
46
+ const parsed = enableAdminUserRequestSchema.parse(input);
47
+ assertAdminActor(context, ADMIN_USERS_ABILITIES.update);
48
+ await serviceOf(deps).enableUser(parsed);
49
+ return okResponseSchema.parse({ ok: true });
50
+ }
51
+ export async function disableAdminUserCommand(context, input, deps) {
52
+ const parsed = disableAdminUserRequestSchema.parse(input);
53
+ const actor = assertAdminActor(context, ADMIN_USERS_ABILITIES.update);
54
+ await serviceOf(deps).disableUser(actor, parsed);
55
+ return okResponseSchema.parse({ ok: true });
56
+ }
57
+ export async function deleteAdminUserCommand(context, input, deps) {
58
+ const parsed = deleteAdminUserRequestSchema.parse(input);
59
+ const actor = assertAdminActor(context, ADMIN_USERS_ABILITIES.delete);
60
+ await serviceOf(deps).deleteUser(actor, parsed);
61
+ return okResponseSchema.parse({ ok: true });
62
+ }
63
+ //# sourceMappingURL=commands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.js","sourceRoot":"","sources":["../../../src/modules/admin-users/commands.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAA;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAA;AACtD,OAAO,EACL,2BAA2B,EAC3B,uBAAuB,EACvB,4BAA4B,EAC5B,4BAA4B,EAC5B,6BAA6B,EAC7B,4BAA4B,EAC5B,yBAAyB,EACzB,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E,EAAE,EAAE,IAAI,EAAE,CAAC,CAAA;AAC7C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,OAAmC,EACnC,KAAc,EACd,IAA2B;IAE3B,MAAM,MAAM,GAAG,6BAA6B,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IACzD,MAAM,KAAK,GAAG,gBAAgB,CAAC,OAAO,EAAE,qBAAqB,CAAC,MAAM,CAAC,CAAA;IACrE,MAAM,SAAS,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;IAChD,OAAO,gBAAgB,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAA;AAC7C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,OAAmC,EACnC,KAAc,EACd,IAA2B;IAE3B,MAAM,MAAM,GAAG,4BAA4B,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IACxD,MAAM,KAAK,GAAG,gBAAgB,CAAC,OAAO,EAAE,qBAAqB,CAAC,MAAM,CAAC,CAAA;IACrE,MAAM,SAAS,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;IAC/C,OAAO,gBAAgB,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAA;AAC7C,CAAC"}
@@ -0,0 +1,20 @@
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 { AdminUserRow } from './repository.js';
9
+ import type { AdminUserResponse } from './schemas.js';
10
+ /**
11
+ * Shape an `AdminUserRow` into its public `AdminUserResponse` form.
12
+ *
13
+ * The row type from the repository already omits `password_hash`, so
14
+ * this is effectively an identity map — the indirection exists so that
15
+ * if internal fields ever get added to the row (e.g. tenant id,
16
+ * soft-delete timestamp), they are explicitly opted out of the public
17
+ * shape here rather than leaking by default.
18
+ */
19
+ export declare function toAdminUser(row: AdminUserRow): AdminUserResponse;
20
+ //# sourceMappingURL=dto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dto.d.ts","sourceRoot":"","sources":["../../../src/modules/admin-users/dto.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAErD;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,YAAY,GAAG,iBAAiB,CAkBhE"}
@@ -0,0 +1,36 @@
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 `AdminUserRow` into its public `AdminUserResponse` form.
10
+ *
11
+ * The row type from the repository already omits `password_hash`, so
12
+ * this is effectively an identity map — the indirection exists so that
13
+ * if internal fields ever get added to the row (e.g. tenant id,
14
+ * soft-delete timestamp), they are explicitly opted out of the public
15
+ * shape here rather than leaking by default.
16
+ */
17
+ export function toAdminUser(row) {
18
+ return {
19
+ id: row.id,
20
+ vid: row.vid,
21
+ email: row.email,
22
+ given_name: row.given_name,
23
+ family_name: row.family_name,
24
+ username: row.username,
25
+ remember_me: row.remember_me,
26
+ last_login: row.last_login,
27
+ last_login_ip: row.last_login_ip,
28
+ failed_login_attempts: row.failed_login_attempts,
29
+ is_super_admin: row.is_super_admin,
30
+ is_enabled: row.is_enabled,
31
+ is_email_verified: row.is_email_verified,
32
+ created_at: row.created_at,
33
+ updated_at: row.updated_at,
34
+ };
35
+ }
36
+ //# sourceMappingURL=dto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dto.js","sourceRoot":"","sources":["../../../src/modules/admin-users/dto.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH;;;;;;;;GAQG;AACH,MAAM,UAAU,WAAW,CAAC,GAAiB;IAC3C,OAAO;QACL,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,GAAG,EAAE,GAAG,CAAC,GAAG;QACZ,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,UAAU,EAAE,GAAG,CAAC,UAAU;QAC1B,WAAW,EAAE,GAAG,CAAC,WAAW;QAC5B,QAAQ,EAAE,GAAG,CAAC,QAAQ;QACtB,WAAW,EAAE,GAAG,CAAC,WAAW;QAC5B,UAAU,EAAE,GAAG,CAAC,UAAU;QAC1B,aAAa,EAAE,GAAG,CAAC,aAAa;QAChC,qBAAqB,EAAE,GAAG,CAAC,qBAAqB;QAChD,cAAc,EAAE,GAAG,CAAC,cAAc;QAClC,UAAU,EAAE,GAAG,CAAC,UAAU;QAC1B,iBAAiB,EAAE,GAAG,CAAC,iBAAiB;QACxC,UAAU,EAAE,GAAG,CAAC,UAAU;QAC1B,UAAU,EAAE,GAAG,CAAC,UAAU;KAC3B,CAAA;AACH,CAAC"}
@@ -0,0 +1,53 @@
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-users.
10
+ *
11
+ * Follows the same `code + factory` shape used by `AuthError` in
12
+ * `@byline/auth`, but with its own class so consumers can distinguish
13
+ * admin-users-specific failures from generic auth failures (e.g. to
14
+ * translate `EMAIL_IN_USE` into a 409 at a transport boundary while
15
+ * `FORBIDDEN` maps to 403).
16
+ *
17
+ * The codes are intentionally prefixed — `admin.users.*` — so they sort
18
+ * alongside the matching ability keys in logs and admin UI messages.
19
+ */
20
+ export declare const AdminUsersErrorCodes: {
21
+ readonly NOT_FOUND: "admin.users.notFound";
22
+ readonly EMAIL_IN_USE: "admin.users.emailInUse";
23
+ readonly SELF_DELETE_FORBIDDEN: "admin.users.selfDeleteForbidden";
24
+ readonly SELF_DISABLE_FORBIDDEN: "admin.users.selfDisableForbidden";
25
+ readonly VERSION_CONFLICT: "admin.users.versionConflict";
26
+ };
27
+ export type AdminUsersErrorCode = (typeof AdminUsersErrorCodes)[keyof typeof AdminUsersErrorCodes];
28
+ export interface AdminUsersErrorOptions {
29
+ message?: string;
30
+ cause?: unknown;
31
+ }
32
+ export declare class AdminUsersError extends Error {
33
+ readonly code: AdminUsersErrorCode;
34
+ constructor(code: AdminUsersErrorCode, options: {
35
+ message: string;
36
+ cause?: unknown;
37
+ });
38
+ }
39
+ /** The referenced admin user id does not exist. */
40
+ export declare const ERR_ADMIN_USER_NOT_FOUND: (options?: AdminUsersErrorOptions) => AdminUsersError;
41
+ /** Creating or updating an admin user conflicts with an existing email. */
42
+ export declare const ERR_ADMIN_USER_EMAIL_IN_USE: (options?: AdminUsersErrorOptions) => AdminUsersError;
43
+ /** The actor attempted to delete their own admin-user row. */
44
+ export declare const ERR_ADMIN_USER_SELF_DELETE: (options?: AdminUsersErrorOptions) => AdminUsersError;
45
+ /** The actor attempted to disable their own admin-user row. */
46
+ export declare const ERR_ADMIN_USER_SELF_DISABLE: (options?: AdminUsersErrorOptions) => AdminUsersError;
47
+ /**
48
+ * The stored `vid` does not match the client-supplied `expectedVid` —
49
+ * the caller is holding a stale version of the row. Typical admin-UI
50
+ * response is to reload the edit form with the current values.
51
+ */
52
+ export declare const ERR_ADMIN_USER_VERSION_CONFLICT: (options?: AdminUsersErrorOptions) => AdminUsersError;
53
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/modules/admin-users/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;GAWG;AAEH,eAAO,MAAM,oBAAoB;;;;;;CAMvB,CAAA;AAEV,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,OAAO,oBAAoB,CAAC,CAAA;AAElG,MAAM,WAAW,sBAAsB;IACrC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED,qBAAa,eAAgB,SAAQ,KAAK;IACxC,SAAgB,IAAI,EAAE,mBAAmB,CAAA;gBAE7B,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAKrF;AAUD,mDAAmD;AACnD,eAAO,MAAM,wBAAwB,aAPxB,sBAAsB,KAAG,eAO8D,CAAA;AAEpG,2EAA2E;AAC3E,eAAO,MAAM,2BAA2B,aAV3B,sBAAsB,KAAG,eAarC,CAAA;AAED,8DAA8D;AAC9D,eAAO,MAAM,0BAA0B,aAhB1B,sBAAsB,KAAG,eAmBrC,CAAA;AAED,+DAA+D;AAC/D,eAAO,MAAM,2BAA2B,aAtB3B,sBAAsB,KAAG,eAyBrC,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,+BAA+B,aAhC/B,sBAAsB,KAAG,eAmCrC,CAAA"}
@@ -0,0 +1,53 @@
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-users.
10
+ *
11
+ * Follows the same `code + factory` shape used by `AuthError` in
12
+ * `@byline/auth`, but with its own class so consumers can distinguish
13
+ * admin-users-specific failures from generic auth failures (e.g. to
14
+ * translate `EMAIL_IN_USE` into a 409 at a transport boundary while
15
+ * `FORBIDDEN` maps to 403).
16
+ *
17
+ * The codes are intentionally prefixed — `admin.users.*` — so they sort
18
+ * alongside the matching ability keys in logs and admin UI messages.
19
+ */
20
+ export const AdminUsersErrorCodes = {
21
+ NOT_FOUND: 'admin.users.notFound',
22
+ EMAIL_IN_USE: 'admin.users.emailInUse',
23
+ SELF_DELETE_FORBIDDEN: 'admin.users.selfDeleteForbidden',
24
+ SELF_DISABLE_FORBIDDEN: 'admin.users.selfDisableForbidden',
25
+ VERSION_CONFLICT: 'admin.users.versionConflict',
26
+ };
27
+ export class AdminUsersError extends Error {
28
+ code;
29
+ constructor(code, options) {
30
+ super(options.message, options.cause != null ? { cause: options.cause } : undefined);
31
+ this.name = 'AdminUsersError';
32
+ this.code = code;
33
+ }
34
+ }
35
+ const make = (code, defaultMessage) => (options) => new AdminUsersError(code, {
36
+ message: options?.message ?? defaultMessage,
37
+ cause: options?.cause,
38
+ });
39
+ /** The referenced admin user id does not exist. */
40
+ export const ERR_ADMIN_USER_NOT_FOUND = make(AdminUsersErrorCodes.NOT_FOUND, 'admin user not found');
41
+ /** Creating or updating an admin user conflicts with an existing email. */
42
+ export const ERR_ADMIN_USER_EMAIL_IN_USE = make(AdminUsersErrorCodes.EMAIL_IN_USE, 'email already in use');
43
+ /** The actor attempted to delete their own admin-user row. */
44
+ export const ERR_ADMIN_USER_SELF_DELETE = make(AdminUsersErrorCodes.SELF_DELETE_FORBIDDEN, 'cannot delete your own admin account');
45
+ /** The actor attempted to disable their own admin-user row. */
46
+ export const ERR_ADMIN_USER_SELF_DISABLE = make(AdminUsersErrorCodes.SELF_DISABLE_FORBIDDEN, 'cannot disable your own admin account');
47
+ /**
48
+ * The stored `vid` does not match the client-supplied `expectedVid` —
49
+ * the caller is holding a stale version of the row. Typical admin-UI
50
+ * response is to reload the edit form with the current values.
51
+ */
52
+ export const ERR_ADMIN_USER_VERSION_CONFLICT = make(AdminUsersErrorCodes.VERSION_CONFLICT, 'admin user has been modified elsewhere — please reload and try again');
53
+ //# sourceM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AAoB,CAAC,qBAAqB,EAC1C,sCAAsC,CACvC,CAAA;AAED,+DAA+D;AAC/D,MAAM,CAAC,MAAM,2BAA2B,GAAG,IAAI,CAC7C,oBAAoB,CAAC,sBAAsB,EAC3C,uCAAuC,CACxC,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,IAAI,CACjD,oBAAoB,CAAC,gBAAgB,EACrC,sEAAsE,CACvE,CAAA"}
@@ -0,0 +1,31 @@
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-users` — admin user CRUD.
10
+ *
11
+ * Exports the adapter-facing `AdminUsersRepository` contract, ability
12
+ * keys, transport-agnostic commands, the `AdminUsersService`, the seed
13
+ * helper, and the module's error types. Commands are the recommended
14
+ * entry point for any caller; the service is exposed for internal uses
15
+ * (seeds, other services) that want to skip Zod/ability overhead.
16
+ *
17
+ * Password hashing is owned by `@byline/admin/auth`; this module takes
18
+ * pre-hashed `password_hash` strings on the repository boundary so the
19
+ * adapter never sees plaintext.
20
+ */
21
+ export { ADMIN_USERS_ABILITIES, type AdminUsersAbilityKey, registerAdminUsersAbilities, } from './abilities.js';
22
+ export { createAdminUserCommand, deleteAdminUserCommand, disableAdminUserCommand, enableAdminUserCommand, getAdminUserCommand, listAdminUsersCommand, setAdminUserPasswordCommand, updateAdminUserCommand, } from './commands.js';
23
+ export { toAdminUser } from './dto.js';
24
+ export { AdminUsersError, type AdminUsersErrorCode, AdminUsersErrorCodes, ERR_ADMIN_USER_EMAIL_IN_USE, ERR_ADMIN_USER_NOT_FOUND, ERR_ADMIN_USER_SELF_DELETE, ERR_ADMIN_USER_SELF_DISABLE, ERR_ADMIN_USER_VERSION_CONFLICT, } from './errors.js';
25
+ export { adminUserListResponseSchema, adminUserResponseSchema, createAdminUserRequestSchema, deleteAdminUserRequestSchema, disableAdminUserRequestSchema, enableAdminUserRequestSchema, getAdminUserRequestSchema, listAdminUsersRequestSchema, okResponseSchema, setAdminUserPasswordRequestSchema, updateAdminUserRequestSchema, } from './schemas.js';
26
+ export { type SeedSuperAdminInput, type SeedSuperAdminResult, seedSuperAdmin, } from './seed-super-admin.js';
27
+ export { AdminUsersService } from './service.js';
28
+ export type { AdminUsersCommandDeps } from './commands.js';
29
+ export type { AdminUserListOrder, AdminUserRow, AdminUsersRepository, AdminUserWithPasswordRow, CountAdminUsersOptions, CreateAdminUserInput, ListAdminUsersOptions, UpdateAdminUserInput, } from './repository.js';
30
+ export type { AdminUserListResponse, AdminUserResponse, CreateAdminUserRequest, DeleteAdminUserRequest, DisableAdminUserRequest, EnableAdminUserRequest, GetAdminUserRequest, ListAdminUsersRequest, OkResponse, SetAdminUserPasswordRequest, UpdateAdminUserRequest, } from './schemas.js';
31
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/admin-users/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,qBAAqB,EACrB,KAAK,oBAAoB,EACzB,2BAA2B,GAC5B,MAAM,gBAAgB,CAAA;AACvB,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,EACnB,qBAAqB,EACrB,2BAA2B,EAC3B,sBAAsB,GACvB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,EACL,eAAe,EACf,KAAK,mBAAmB,EACxB,oBAAoB,EACpB,2BAA2B,EAC3B,wBAAwB,EACxB,0BAA0B,EAC1B,2BAA2B,EAC3B,+BAA+B,GAChC,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,2BAA2B,EAC3B,uBAAuB,EACvB,4BAA4B,EAC5B,4BAA4B,EAC5B,6BAA6B,EAC7B,4BAA4B,EAC5B,yBAAyB,EACzB,2BAA2B,EAC3B,gBAAgB,EAChB,iCAAiC,EACjC,4BAA4B,GAC7B,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,cAAc,GACf,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAChD,YAAY,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAC1D,YAAY,EACV,kBAAkB,EAClB,YAAY,EACZ,oBAAoB,EACpB,wBAAwB,EACxB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,iBAAiB,CAAA;AACxB,YAAY,EACV,qBAAqB,EACrB,iBAAiB,EACjB,sBAAsB,EACtB,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,EACnB,qBAAqB,EACrB,UAAU,EACV,2BAA2B,EAC3B,sBAAsB,GACvB,MAAM,cAAc,CAAA"}
@@ -0,0 +1,28 @@
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-users` — admin user CRUD.
10
+ *
11
+ * Exports the adapter-facing `AdminUsersRepository` contract, ability
12
+ * keys, transport-agnostic commands, the `AdminUsersService`, the seed
13
+ * helper, and the module's error types. Commands are the recommended
14
+ * entry point for any caller; the service is exposed for internal uses
15
+ * (seeds, other services) that want to skip Zod/ability overhead.
16
+ *
17
+ * Password hashing is owned by `@byline/admin/auth`; this module takes
18
+ * pre-hashed `password_hash` strings on the repository boundary so the
19
+ * adapter never sees plaintext.
20
+ */
21
+ export { ADMIN_USERS_ABILITIES, registerAdminUsersAbilities, } from './abilities.js';
22
+ export { createAdminUserCommand, deleteAdminUserCommand, disableAdminUserCommand, enableAdminUserCommand, getAdminUserCommand, listAdminUsersCommand, setAdminUserPasswordCommand, updateAdminUserCommand, } from './commands.js';
23
+ export { toAdminUser } from './dto.js';
24
+ export { AdminUsersError, AdminUsersErrorCodes, ERR_ADMIN_USER_EMAIL_IN_USE, ERR_ADMIN_USER_NOT_FOUND, ERR_ADMIN_USER_SELF_DELETE, ERR_ADMIN_USER_SELF_DISABLE, ERR_ADMIN_USER_VERSION_CONFLICT, } from './errors.js';
25
+ export { adminUserListResponseSchema, adminUserResponseSchema, createAdminUserRequestSchema, deleteAdminUserRequestSchema, disableAdminUserRequestSchema, enableAdminUserRequestSchema, getAdminUserRequestSchema, listAdminUsersRequestSchema, okResponseSchema, setAdminUserPasswordRequestSchema, updateAdminUserRequestSchema, } from './schemas.js';
26
+ export { seedSuperAdmin, } from './seed-super-admin.js';
27
+ export { AdminUsersService } from './service.js';
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/admin-users/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,qBAAqB,EAErB,2BAA2B,GAC5B,MAAM,gBAAgB,CAAA;AACvB,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,EACnB,qBAAqB,EACrB,2BAA2B,EAC3B,sBAAsB,GACvB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,EACL,eAAe,EAEf,oBAAoB,EACpB,2BAA2B,EAC3B,wBAAwB,EACxB,0BAA0B,EAC1B,2BAA2B,EAC3B,+BAA+B,GAChC,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,2BAA2B,EAC3B,uBAAuB,EACvB,4BAA4B,EAC5B,4BAA4B,EAC5B,6BAA6B,EAC7B,4BAA4B,EAC5B,yBAAyB,EACzB,2BAA2B,EAC3B,gBAAgB,EAChB,iCAAiC,EACjC,4BAA4B,GAC7B,MAAM,cAAc,CAAA;AACrB,OAAO,EAGL,cAAc,GACf,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA"}
@@ -0,0 +1,147 @@
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
+ * `AdminUsersRepository` — the DB-adapter-facing contract for the
10
+ * `byline_admin_users` table.
11
+ *
12
+ * The interface deliberately takes **pre-hashed** password strings
13
+ * (`password_hash`) rather than plaintext. Argon2 / bcrypt hashing is a
14
+ * service-layer concern that depends on `@byline/admin/auth` primitives;
15
+ * keeping it out of the repository means the adapter stays unaware of
16
+ * password policy and the hashing library of the day.
17
+ *
18
+ * **Optimistic concurrency.** Content-shaped writes (`update`,
19
+ * `setPasswordHash`, `delete`) take an `expectedVid` and bump the stored
20
+ * `vid` on success. If the stored `vid` does not match `expectedVid` the
21
+ * adapter throws `AdminUsersError(VERSION_CONFLICT)`, signalling a stale
22
+ * client. Admin-intent writes that do not depend on current state
23
+ * (`setEnabled`, login counters) are vid-less — last-writer-wins is the
24
+ * right semantic for those.
25
+ *
26
+ * Adapters (e.g. `@byline/db-postgres`) implement this interface; admin
27
+ * services (`seed-super-admin`, admin-user commands) consume it. No
28
+ * caller should ever construct `AdminUsersRepository` instances directly
29
+ * outside the adapter — use the `AdminStore` bundle passed at
30
+ * `initBylineCore()` time.
31
+ */
32
+ /**
33
+ * Public-facing admin-user row — the `password_hash` column is
34
+ * deliberately omitted. Only `getByEmailForSignIn` returns the hash, and
35
+ * only so the session provider can verify it.
36
+ */
37
+ export interface AdminUserRow {
38
+ id: string;
39
+ vid: number;
40
+ given_name: string | null;
41
+ family_name: string | null;
42
+ username: string | null;
43
+ email: string;
44
+ remember_me: boolean;
45
+ last_login: Date | null;
46
+ last_login_ip: string | null;
47
+ failed_login_attempts: number;
48
+ is_super_admin: boolean;
49
+ is_enabled: boolean;
50
+ is_email_verified: boolean;
51
+ created_at: Date;
52
+ updated_at: Date;
53
+ }
54
+ /**
55
+ * Admin-user row including the PHC password hash. Returned only by
56
+ * `getByEmailForSignIn` — callers must treat it with care (never log,
57
+ * never return to clients).
58
+ */
59
+ export interface AdminUserWithPasswordRow extends AdminUserRow {
60
+ password_hash: string;
61
+ }
62
+ export interface CreateAdminUserInput {
63
+ email: string;
64
+ /** Pre-hashed PHC string. Service layer hashes plaintext before calling. */
65
+ password_hash: string;
66
+ given_name?: string | null;
67
+ family_name?: string | null;
68
+ username?: string | null;
69
+ is_super_admin?: boolean;
70
+ is_enabled?: boolean;
71
+ is_email_verified?: boolean;
72
+ }
73
+ export interface UpdateAdminUserInput {
74
+ given_name?: string | null;
75
+ family_name?: string | null;
76
+ username?: string | null;
77
+ email?: string;
78
+ is_super_admin?: boolean;
79
+ is_enabled?: boolean;
80
+ is_email_verified?: boolean;
81
+ remember_me?: boolean;
82
+ }
83
+ export type AdminUserListOrder = 'given_name' | 'family_name' | 'email' | 'username' | 'created_at' | 'updated_at';
84
+ export interface ListAdminUsersOptions {
85
+ /** 1-based page number. */
86
+ page: number;
87
+ /** Page size. Reasonable ceiling applied at the command layer. */
88
+ pageSize: number;
89
+ /** Free-text search across email, given_name, family_name, username. */
90
+ query?: string;
91
+ /** Column to sort by. */
92
+ order: AdminUserListOrder;
93
+ /** True for DESC, false for ASC. */
94
+ desc: boolean;
95
+ }
96
+ export interface CountAdminUsersOptions {
97
+ /** Free-text search — same semantics as `list`. */
98
+ query?: string;
99
+ }
100
+ export interface AdminUsersRepository {
101
+ create(input: CreateAdminUserInput): Promise<AdminUserRow>;
102
+ getById(id: string): Promise<AdminUserRow | null>;
103
+ getByEmail(email: string): Promise<AdminUserRow | null>;
104
+ getByUsername(username: string): Promise<AdminUserRow | null>;
105
+ /**
106
+ * Sign-in-only lookup. Returns the PHC hash alongside the public row so
107
+ * the session provider can verify. Callers **must not** persist or echo
108
+ * the `password_hash` field.
109
+ */
110
+ getByEmailForSignIn(email: string): Promise<AdminUserWithPasswordRow | null>;
111
+ /**
112
+ * Authenticated-verification lookup. Same shape as
113
+ * `getByEmailForSignIn` but keyed by id — used by the self-service
114
+ * change-password flow, where the actor is already authenticated and
115
+ * we need to verify the *current* password before swapping in a new
116
+ * one. Same handling rules apply: callers **must not** persist or
117
+ * echo the `password_hash` field.
118
+ */
119
+ getByIdForSignIn(id: string): Promise<AdminUserWithPasswordRow | null>;
120
+ /** Paginated, filtered, sorted list. */
121
+ list(options: ListAdminUsersOptions): Promise<AdminUserRow[]>;
122
+ /** Total row count matching the same filter (for pager `total_pages`). */
123
+ count(options?: CountAdminUsersOptions): Promise<number>;
124
+ /**
125
+ * Content update with optimistic concurrency. Throws
126
+ * `AdminUsersError(VERSION_CONFLICT)` if the stored `vid` differs from
127
+ * `expectedVid`. Bumps `vid` on success and returns the fresh row.
128
+ */
129
+ update(id: string, expectedVid: number, patch: UpdateAdminUserInput): Promise<AdminUserRow>;
130
+ /**
131
+ * Replace the stored password hash with optimistic concurrency.
132
+ * Version-gated on `expectedVid`. Caller supplies a pre-hashed PHC string.
133
+ * Returns the updated row so callers holding the edit form can refresh
134
+ * their cached `vid` without a second round-trip.
135
+ */
136
+ setPasswordHash(id: string, expectedVid: number, passwordHash: string): Promise<AdminUserRow>;
137
+ /** Toggle enabled state. Vid-less — admin intent is independent of other edits. */
138
+ setEnabled(id: string, enabled: boolean): Promise<void>;
139
+ recordLoginSuccess(id: string, ip: string | null): Promise<void>;
140
+ recordLoginFailure(id: string): Promise<void>;
141
+ /**
142
+ * Delete with optimistic concurrency. Version-gated on `expectedVid` to
143
+ * prevent races against a concurrent update.
144
+ */
145
+ delete(id: string, expectedVid: number): Promise<void>;
146
+ }
147
+ //# sourceMappingURL=repository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../../src/modules/admin-users/repository.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAA;IACV,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,OAAO,CAAA;IACpB,UAAU,EAAE,IAAI,GAAG,IAAI,CAAA;IACvB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,qBAAqB,EAAE,MAAM,CAAA;IAC7B,cAAc,EAAE,OAAO,CAAA;IACvB,UAAU,EAAE,OAAO,CAAA;IACnB,iBAAiB,EAAE,OAAO,CAAA;IAC1B,UAAU,EAAE,IAAI,CAAA;IAChB,UAAU,EAAE,IAAI,CAAA;CACjB;AAED;;;;GAIG;AACH,MAAM,WAAW,wBAAyB,SAAQ,YAAY;IAC5D,aAAa,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAA;IACb,4EAA4E;IAC5E,aAAa,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,iBAAiB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KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,wBAAwB,GAAG,IAAI,CAAC,CAAA;IAC5E;;;;;;;OAOG;IACH,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,wBAAwB,GAAG,IAAI,CAAC,CAAA;IACtE,wCAAwC;IACxC,IAAI,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAAA;IAC7D,0EAA0E;IAC1E,KAAK,CAAC,OAAO,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IACxD;;;;OAIG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAA;IAC3F;;;;;OAKG;IACH,eAAe,CAAC,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAAA;IAC7F,mFAAmF;IACnF,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACvD,kBAAkB,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAChE,kBAAkB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC7C;;;OAGG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACvD"}
@@ -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-users/repository.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}