2026-10-05 11:13:51 +00:00
|
|
|
import type { UniqueID } from "@repo/rdx-ddd";
|
|
|
|
|
import type { Result } from "@repo/rdx-utils";
|
|
|
|
|
|
2026-10-05 15:01:32 +00:00
|
|
|
import type { ResourceReferenceDTO } from "../../common/inventory";
|
2026-10-05 11:13:51 +00:00
|
|
|
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>;
|
2026-10-05 15:01:32 +00:00
|
|
|
references: readonly ResourceReferenceDTO[];
|
2026-10-05 11:13:51 +00:00
|
|
|
}>;
|
2026-10-10 10:01:58 +00:00
|
|
|
|
2026-10-05 11:13:51 +00:00
|
|
|
export interface IResourceRepository {
|
2026-10-17 11:58:29 +00:00
|
|
|
remove(companyId: UniqueID, id: UniqueID): Promise<Result<void, ResourceCatalogError>>;
|
2026-10-05 11:13:51 +00:00
|
|
|
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>
|
|
|
|
|
>;
|
|
|
|
|
}
|