Skip to content
0

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() ​

ts
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 ​

ParameterType
rolestring

Returns ​

Promise<number>


useCreate() ​

ts
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 ​

ParameterType
userOmit<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() ​

ts
useDelete(id): Promise<DirectoryResult<true>>;

Defined in: src/core/services/directory.service.ts:39

Row removal. Soft-delete belongs in useUpdate, not here.

Parameters ​

ParameterType
idstring | number

Returns ​

Promise<DirectoryResult<true>>


useGet() ​

ts
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 ​

ParameterType
idstring | 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() ​

ts
useList(query): Promise<DirectoryPageResult>;

Defined in: src/core/services/directory.service.ts:30

Parameters ​

ParameterType
query{ cursor?: string; limit: number; role?: string; scope?: string; search?: string; status?: "pending" | "active" | "suspended" | "deactivated"; }
query.cursor?string
query.limitnumber
query.role?string
query.scope?string
query.search?string
query.status?"pending" | "active" | "suspended" | "deactivated"

Returns ​

Promise<DirectoryPageResult>


useUpdate() ​

ts
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 ​

ParameterType
idstring | number
patchPartial<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"; }>>

Released under the MIT License.