metis-desk/modules/companies/src/api/application/work-profile.repository.ts

28 lines
1.1 KiB
TypeScript
Raw Normal View History

2026-10-05 07:53:29 +00:00
import type { UniqueID } from "@repo/rdx-ddd";
import type { Result } from "@repo/rdx-utils";
import type { AccessDefinition } from "../domain/access/access-definition";
import type { WorkProfile } from "../domain/work-profile.aggregate";
import type { WorkProfileError } from "../domain/work-profile-values";
2026-10-10 10:01:58 +00:00
2026-10-05 07:53:29 +00:00
export interface IWorkProfileInventoryService {
list(companyId: UniqueID): Promise<readonly { id: UniqueID; available: boolean }[]>;
}
2026-10-10 10:01:58 +00:00
2026-10-05 07:53:29 +00:00
export type WorkProfileContext = Readonly<{
profiles: readonly WorkProfile[];
people: readonly { id: UniqueID; active: boolean }[];
assets: readonly { id: UniqueID; available: boolean }[];
items: readonly { id: UniqueID; values: AccessDefinition }[];
actors: ReadonlyMap<string, string>;
today: string;
}>;
2026-10-10 10:01:58 +00:00
2026-10-05 07:53:29 +00:00
export interface IWorkProfileRepository {
get(companyId: UniqueID): Promise<Result<WorkProfileContext, WorkProfileError>>;
save(
companyId: UniqueID,
action: (context: WorkProfileContext) => Result<WorkProfile, WorkProfileError>
): Promise<Result<{ profile: WorkProfile; context: WorkProfileContext }, WorkProfileError>>;
}