DirectoryRepository
katanakit-js / DirectoryRepository
Interface: DirectoryRepository
Section titled “Interface: DirectoryRepository”Defined in: 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
Section titled “Methods”useCountByRole()
Section titled “useCountByRole()”useCountByRole(role): Promise<number>;Defined in: 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
Section titled “Parameters”| Parameter | Type |
|---|---|
role |
string |
Returns
Section titled “Returns”Promise<number>
useCreate()
Section titled “useCreate()”useCreate(user): Promise<DirectoryResult<{ displayName?: string; email?: string; id: string | number; metadata?: Record<string, unknown>; principalSubject?: string; roles: string[]; scope?: string; status: "active" | "pending" | "suspended" | "deactivated";}>>;Defined in: core/services/directory.service.ts:33
Persists a new person. Fails with already_active on a duplicate.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
user |
Omit<DirectoryUser, "id"> |
Returns
Section titled “Returns”Promise<DirectoryResult<{
displayName?: string;
email?: string;
id: string | number;
metadata?: Record<string, unknown>;
principalSubject?: string;
roles: string[];
scope?: string;
status: "active" | "pending" | "suspended" | "deactivated";
}>>
useDelete()
Section titled “useDelete()”useDelete(id): Promise<DirectoryResult<true>>;Defined in: core/services/directory.service.ts:39
Row removal. Soft-delete belongs in useUpdate, not here.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
id |
string | number |
Returns
Section titled “Returns”Promise<DirectoryResult<true>>
useGet()
Section titled “useGet()”useGet(id): Promise<DirectoryResult<{ displayName?: string; email?: string; id: string | number; metadata?: Record<string, unknown>; principalSubject?: string; roles: string[]; scope?: string; status: "active" | "pending" | "suspended" | "deactivated";}>>;Defined in: core/services/directory.service.ts:31
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
id |
string | number |
Returns
Section titled “Returns”Promise<DirectoryResult<{
displayName?: string;
email?: string;
id: string | number;
metadata?: Record<string, unknown>;
principalSubject?: string;
roles: string[];
scope?: string;
status: "active" | "pending" | "suspended" | "deactivated";
}>>
useList()
Section titled “useList()”useList(query): Promise<DirectoryPageResult>;Defined in: core/services/directory.service.ts:30
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
query |
{ cursor?: string; limit: number; role?: string; scope?: string; search?: string; status?: "active" | "pending" | "suspended" | "deactivated"; } |
query.cursor? |
string |
query.limit? |
number |
query.role? |
string |
query.scope? |
string |
query.search? |
string |
query.status? |
"active" | "pending" | "suspended" | "deactivated" |
Returns
Section titled “Returns”Promise<DirectoryPageResult>
useUpdate()
Section titled “useUpdate()”useUpdate(id, patch): Promise<DirectoryResult<{ displayName?: string; email?: string; id: string | number; metadata?: Record<string, unknown>; principalSubject?: string; roles: string[]; scope?: string; status: "active" | "pending" | "suspended" | "deactivated";}>>;Defined in: core/services/directory.service.ts:34
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
id |
string | number |
patch |
Partial<Omit<DirectoryUser, "id">> |
Returns
Section titled “Returns”Promise<DirectoryResult<{
displayName?: string;
email?: string;
id: string | number;
metadata?: Record<string, unknown>;
principalSubject?: string;
roles: string[];
scope?: string;
status: "active" | "pending" | "suspended" | "deactivated";
}>>