25 lines
971 B
TypeScript
25 lines
971 B
TypeScript
import type { UniqueID } from "@repo/rdx-ddd";
|
|
import type { Result } from "@repo/rdx-utils";
|
|
|
|
import type { AccessDefinition } from "../domain/access/access-definition";
|
|
import type { Mailbox } from "../domain/mailbox.aggregate";
|
|
import type { MailboxUse } from "../domain/mailbox-use.aggregate";
|
|
import type { MailboxError } from "../domain/mailbox-values";
|
|
|
|
export type MailboxContext = Readonly<{
|
|
mailboxes: readonly Mailbox[];
|
|
uses: readonly MailboxUse[];
|
|
people: readonly { id: UniqueID; active: boolean }[];
|
|
items: readonly { id: UniqueID; values: AccessDefinition }[];
|
|
actors: ReadonlyMap<string, string>;
|
|
today: string;
|
|
}>;
|
|
|
|
export interface IMailboxRepository {
|
|
get(companyId: UniqueID): Promise<Result<MailboxContext, MailboxError>>;
|
|
save(
|
|
companyId: UniqueID,
|
|
action: (context: MailboxContext) => Result<Mailbox | MailboxUse, MailboxError>
|
|
): Promise<Result<{ item: Mailbox | MailboxUse; context: MailboxContext }, MailboxError>>;
|
|
}
|