metis-desk/modules/resources/src/api/application/resource.repository.ts

22 lines
819 B
TypeScript
Raw Normal View History

2026-10-05 11:13:51 +00:00
import type { UniqueID } from "@repo/rdx-ddd";
import type { Result } from "@repo/rdx-utils";
import type { Resource } from "../domain/resource.aggregate";
import type { ResourceCatalog } from "../domain/resource-catalog.aggregate";
import type { ResourceCatalogError } from "../domain/resource-definition";
export type InventoryContext = Readonly<{
catalog: ResourceCatalog;
resources: readonly Resource[];
actorNames: ReadonlyMap<string, string>;
}>;
export interface IResourceRepository {
get(companyId: UniqueID): Promise<Result<InventoryContext, ResourceCatalogError>>;
save(
companyId: UniqueID,
action: (context: InventoryContext) => Result<Resource, ResourceCatalogError>
): Promise<
Result<{ resource: Resource; actorNames: ReadonlyMap<string, string> }, ResourceCatalogError>
>;
}