katanakit-js / DirectoryRepository
Interface: DirectoryRepository
Defined in: src/core/services/directory.service.ts:29
Where user records actually live.
Injected, never implemented here. A role ladder that cannot decide its own questions is fine; a role ladder that decides where the rows go is not — that is what would tie the kit to one database and make "the core does no I/O" a lie.
Everything here is Promise because nothing here should be: an in-memory adapter for tests returns already-resolved promises, and a caller is never tempted to write sync code that only works against the fake.
Methods
useCountByRole()
useCountByRole(role): Promise<number>;Defined in: src/core/services/directory.service.ts:48
How many active users hold each role.
Called before any demotion so the "last owner" check cannot be raced by a second concurrent demotion. A repository that cannot answer this cheaply should cache it — the count is the only thing standing between a routine role change and an unadministrable system.
Parameters
| Parameter | Type |
|---|---|
role | string |
Returns
Promise<number>
useCreate()
useCreate(user): Promise<DirectoryResult<{
displayName?: string;
email?: string;
id: string | number;
metadata?: Record<string, unknown>;
principalSubject?: string;
roles: string[];
scope?: string;
status: "pending" | "active" | "suspended" | "deactivated";
}>>;Defined in: src/core/services/directory.service.ts:33
Persists a new person. Fails with already_active on a duplicate.
Parameters
| Parameter | Type |
|---|---|
user | Omit<DirectoryUser, "id"> |
Returns
Promise<DirectoryResult<{ displayName?: string; email?: string; id: string | number; metadata?: Record<string, unknown>; principalSubject?: string; roles: string[]; scope?: string; status: "pending" | "active" | "suspended" | "deactivated"; }>>
useDelete()
useDelete(id): Promise<DirectoryResult<true>>;Defined in: src/core/services/directory.service.ts:39
Row removal. Soft-delete belongs in useUpdate, not here.
Parameters
| Parameter | Type |
|---|---|
id | string | number |
Returns
Promise<DirectoryResult<true>>
useGet()
useGet(id): Promise<DirectoryResult<{
displayName?: string;
email?: string;
id: string | number;
metadata?: Record<string, unknown>;
principalSubject?: string;
roles: string[];
scope?: string;
status: "pending" | "active" | "suspended" | "deactivated";
}>>;Defined in: src/core/services/directory.service.ts:31
Parameters
| Parameter | Type |
|---|---|
id | string | number |
Returns
Promise<DirectoryResult<{ displayName?: string; email?: string; id: string | number; metadata?: Record<string, unknown>; principalSubject?: string; roles: string[]; scope?: string; status: "pending" | "active" | "suspended" | "deactivated"; }>>
useList()
useList(query): Promise<DirectoryPageResult>;Defined in: src/core/services/directory.service.ts:30
Parameters
| Parameter | Type |
|---|---|
query | { cursor?: string; limit: number; role?: string; scope?: string; search?: string; status?: "pending" | "active" | "suspended" | "deactivated"; } |
query.cursor? | string |
query.limit | number |
query.role? | string |
query.scope? | string |
query.search? | string |
query.status? | "pending" | "active" | "suspended" | "deactivated" |
Returns
Promise<DirectoryPageResult>
useUpdate()
useUpdate(id, patch): Promise<DirectoryResult<{
displayName?: string;
email?: string;
id: string | number;
metadata?: Record<string, unknown>;
principalSubject?: string;
roles: string[];
scope?: string;
status: "pending" | "active" | "suspended" | "deactivated";
}>>;Defined in: src/core/services/directory.service.ts:34
Parameters
| Parameter | Type |
|---|---|
id | string | number |
patch | Partial<Omit<DirectoryUser, "id">> |
Returns
Promise<DirectoryResult<{ displayName?: string; email?: string; id: string | number; metadata?: Record<string, unknown>; principalSubject?: string; roles: string[]; scope?: string; status: "pending" | "active" | "suspended" | "deactivated"; }>>