2026-10-05 11:13:51 +00:00
|
|
|
import type { UniqueID } from "@repo/rdx-ddd";
|
|
|
|
|
import type { Result } from "@repo/rdx-utils";
|
|
|
|
|
|
2026-10-20 11:20:22 +00:00
|
|
|
import type { DirectoryDomainDTO } from "../../common/directory-domains";
|
2026-10-05 15:01:32 +00:00
|
|
|
import type { ResourceReferenceDTO } from "../../common/inventory";
|
2026-10-21 09:25:23 +00:00
|
|
|
import type { NetworkShareDTO } from "../../common/network-shares";
|
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<{
|
2026-10-21 09:25:23 +00:00
|
|
|
smbAccessTypeId?: string;
|
|
|
|
|
networkShares?: ReadonlyMap<string, NetworkShareDTO>;
|
2026-10-20 11:20:22 +00:00
|
|
|
directoryDomains?: ReadonlyMap<string, DirectoryDomainDTO>;
|
2026-10-05 11:13:51 +00:00
|
|
|
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,
|
2026-10-21 09:25:23 +00:00
|
|
|
action: (context: InventoryContext) => Result<Resource, ResourceCatalogError>,
|
|
|
|
|
creation?: { templateId: string; actorId: UniqueID }
|
2026-10-05 11:13:51 +00:00
|
|
|
): Promise<
|
2026-10-20 11:20:22 +00:00
|
|
|
Result<
|
|
|
|
|
{
|
|
|
|
|
resource: Resource;
|
|
|
|
|
actorNames: ReadonlyMap<string, string>;
|
|
|
|
|
directory?: DirectoryDomainDTO;
|
2026-10-21 09:25:23 +00:00
|
|
|
networkShare?: NetworkShareDTO;
|
2026-10-20 11:20:22 +00:00
|
|
|
},
|
|
|
|
|
ResourceCatalogError
|
|
|
|
|
>
|
2026-10-05 11:13:51 +00:00
|
|
|
>;
|
|
|
|
|
}
|