22 lines
819 B
TypeScript
22 lines
819 B
TypeScript
|
|
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>
|
||
|
|
>;
|
||
|
|
}
|