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

40 lines
1.5 KiB
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";
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";
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<{
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 {
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>,
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;
networkShare?: NetworkShareDTO;
2026-10-20 11:20:22 +00:00
},
ResourceCatalogError
>
2026-10-05 11:13:51 +00:00
>;
}