|
| 1 | +import { Address, ChainId } from "@grants-stack-indexer/shared"; |
| 2 | + |
| 3 | +import { |
| 4 | + NewPendingProjectRole, |
| 5 | + NewProject, |
| 6 | + NewProjectRole, |
| 7 | + PartialProject, |
| 8 | + PendingProjectRole, |
| 9 | + Project, |
| 10 | + ProjectRoleNames, |
| 11 | +} from "../types/project.types.js"; |
| 12 | + |
| 13 | +export interface IProjectReadRepository { |
| 14 | + /** |
| 15 | + * Retrieves all projects for a given chain ID. |
| 16 | + * @param chainId The chain ID to filter projects by. |
| 17 | + * @returns A promise that resolves to an array of Project objects. |
| 18 | + */ |
| 19 | + getProjects(chainId: ChainId): Promise<Project[]>; |
| 20 | + |
| 21 | + /** |
| 22 | + * Retrieves a specific project by its ID and chain ID. |
| 23 | + * @param chainId The chain ID of the project. |
| 24 | + * @param projectId The unique identifier of the project. |
| 25 | + * @returns A promise that resolves to a Project object if found, or undefined if not found. |
| 26 | + */ |
| 27 | + getProjectById(chainId: ChainId, projectId: string): Promise<Project | undefined>; |
| 28 | + |
| 29 | + /** |
| 30 | + * Retrieves all pending project roles. |
| 31 | + * @returns A promise that resolves to an array of PendingProjectRole objects. |
| 32 | + */ |
| 33 | + getPendingProjectRoles(): Promise<PendingProjectRole[]>; |
| 34 | + |
| 35 | + /** |
| 36 | + * Retrieves pending project roles for a specific chain ID and role. |
| 37 | + * @param chainId The chain ID to filter pending roles by. |
| 38 | + * @param role The role to filter pending roles by. |
| 39 | + * @returns A promise that resolves to an array of PendingProjectRole objects. |
| 40 | + */ |
| 41 | + getPendingProjectRolesByRole(chainId: ChainId, role: string): Promise<PendingProjectRole[]>; |
| 42 | + |
| 43 | + /** |
| 44 | + * Retrieves a project by its anchor address and chain ID. |
| 45 | + * @param chainId The chain ID of the project. |
| 46 | + * @param anchorAddress The anchor address of the project. |
| 47 | + * @returns A promise that resolves to a Project object if found, or undefined if not found. |
| 48 | + */ |
| 49 | + getProjectByAnchor(chainId: ChainId, anchorAddress: Address): Promise<Project | undefined>; |
| 50 | +} |
| 51 | + |
| 52 | +export interface IProjectRepository extends IProjectReadRepository { |
| 53 | + /** |
| 54 | + * Inserts a new project into the repository. |
| 55 | + * @param project The new project to be inserted. |
| 56 | + * @returns A promise that resolves when the insertion is complete. |
| 57 | + */ |
| 58 | + insertProject(project: NewProject): Promise<void>; |
| 59 | + |
| 60 | + /** |
| 61 | + * Updates an existing project in the repository. |
| 62 | + * @param where An object containing the id and chainId to identify the project to update. |
| 63 | + * @param project The partial project data to update. |
| 64 | + * @returns A promise that resolves when the update is complete. |
| 65 | + */ |
| 66 | + updateProject(where: { id: string; chainId: ChainId }, project: PartialProject): Promise<void>; |
| 67 | + |
| 68 | + /** |
| 69 | + * Inserts a new project role into the repository. |
| 70 | + * @param projectRole The new project role to be inserted. |
| 71 | + * @returns A promise that resolves when the insertion is complete. |
| 72 | + */ |
| 73 | + insertProjectRole(projectRole: NewProjectRole): Promise<void>; |
| 74 | + |
| 75 | + /** |
| 76 | + * Deletes multiple project roles based on the provided criteria. |
| 77 | + * @param chainId The chain ID of the project roles to delete. |
| 78 | + * @param projectId The project ID of the roles to delete. |
| 79 | + * @param role The role type to delete. |
| 80 | + * @param address Optional address to further filter the roles to delete. |
| 81 | + * @returns A promise that resolves when the deletion is complete. |
| 82 | + */ |
| 83 | + deleteManyProjectRoles( |
| 84 | + chainId: ChainId, |
| 85 | + projectId: string, |
| 86 | + role: ProjectRoleNames, |
| 87 | + address?: Address, |
| 88 | + ): Promise<void>; |
| 89 | + |
| 90 | + /** |
| 91 | + * Inserts a new pending project role into the repository. |
| 92 | + * @param pendingProjectRole The new pending project role to be inserted. |
| 93 | + * @returns A promise that resolves when the insertion is complete. |
| 94 | + */ |
| 95 | + insertPendingProjectRole(pendingProjectRole: NewPendingProjectRole): Promise<void>; |
| 96 | + |
| 97 | + /** |
| 98 | + * Deletes multiple pending project roles based on their IDs. |
| 99 | + * @param ids An array of IDs of the pending project roles to delete. |
| 100 | + * @returns A promise that resolves when the deletion is complete. |
| 101 | + */ |
| 102 | + deleteManyPendingProjectRoles(ids: number[]): Promise<void>; |
| 103 | +} |
0 commit comments