snowballtools-base-mirror/packages/gql-client/dist/index.d.ts
Vivian Phung a684743bd6
feat(template projects): generate git repo on backend (#218)
### TL;DR

- Still cretaes app if user migrates from page

The PR introduces a new `AddProjectFromTemplate` mutation to facilitate project creation using a repository template. This change centralizes the template project creation logic within the backend, improving code maintainability by removing redundant client-side code.

### What changed?
- Added `AddProjectFromTemplate` input type in `schema.gql` and corresponding TypeScript interfaces.
- Implemented `addProjectFromTemplate` resolver with error handling and Octokit integration for repository creation.
- Updated `service.ts` to include the new `addProjectFromTemplate` method.
- Created new GraphQL `Mutation` for `addProjectFromTemplate` in the GraphQL schema.
- Adjusted the client-side GQLClient to support the new mutation.
- Modified frontend to utilize the new backend mutation for project creation from a template.

### How to test?
1. Ensure your backend server is running.
2. Use a GraphQL client like Postman to call the `addProjectFromTemplate` mutation with appropriate input.
3. Verify that the new project is created using the specified template, and appropriate error messages are returned for failures.
4. Check the frontend flow for creating a project from a template to ensure it is working correctly.

### Why make this change?
This change enhances code maintainability by centralizing template project creation logic within the backend, thereby reducing redundancy and potential inconsistencies in client-side implementations.

---
2024-06-24 18:38:01 -04:00

296 lines
9.4 KiB
TypeScript

declare enum Role {
Owner = "Owner",
Maintainer = "Maintainer",
Reader = "Reader"
}
declare enum Permission {
View = "View",
Edit = "Edit"
}
declare enum Environment {
Production = "Production",
Preview = "Preview",
Development = "Development"
}
declare enum DeploymentStatus {
Building = "Building",
Ready = "Ready",
Error = "Error",
Deleting = "Deleting"
}
declare enum DomainStatus {
Live = "Live",
Pending = "Pending"
}
type EnvironmentVariable = {
id: string;
environment: Environment;
key: string;
value: string;
createdAt: string;
updatedAt: string;
};
type Domain = {
id: string;
branch: string;
name: string;
status: DomainStatus;
redirectTo: Domain | null;
createdAt: string;
updatedAt: string;
};
type User = {
id: string;
name: string | null;
email: string;
isVerified: boolean;
createdAt: string;
updatedAt: string;
gitHubToken: string | null;
};
type Deployment = {
id: string;
domain: Domain;
branch: string;
commitHash: string;
commitMessage: string;
url?: string;
environment: Environment;
isCurrent: boolean;
status: DeploymentStatus;
createdBy: User;
createdAt: string;
updatedAt: string;
};
type OrganizationMember = {
id: string;
member: User;
role: Role;
createdAt: string;
updatedAt: string;
};
type ProjectMember = {
id: string;
member: User;
permissions: Permission[];
isPending: boolean;
createdAt: string;
updatedAt: string;
};
type OrganizationProject = {
id: string;
owner: User;
deployments: Deployment[];
name: string;
repository: string;
prodBranch: string;
description: string;
template: string;
framework: string;
webhooks: string[];
members: ProjectMember[];
environmentVariables: EnvironmentVariable[];
createdAt: string;
updatedAt: string;
};
type Organization = {
id: string;
name: string;
slug: string;
projects: OrganizationProject[];
createdAt: string;
updatedAt: string;
members: OrganizationMember[];
};
type Project = {
id: string;
owner: User;
deployments: Deployment[];
name: string;
repository: string;
prodBranch: string;
description: string;
template: string;
framework: string;
webhooks: string[];
members: ProjectMember[];
environmentVariables: EnvironmentVariable[];
createdAt: string;
updatedAt: string;
organization: Organization;
icon: string;
subDomain: string;
};
type GetProjectMembersResponse = {
projectMembers: ProjectMember[];
};
type AddProjectMemberResponse = {
addProjectMember: boolean;
};
type RemoveProjectMemberResponse = {
removeProjectMember: boolean;
};
type UpdateProjectMemberResponse = {
updateProjectMember: boolean;
};
type GetDeploymentsResponse = {
deployments: Deployment[];
};
type GetEnvironmentVariablesResponse = {
environmentVariables: EnvironmentVariable[];
};
type GetOrganizationsResponse = {
organizations: Organization[];
};
type GetUserResponse = {
user: User;
};
type GetProjectResponse = {
project: Project | null;
};
type GetProjectsInOrganizationResponse = {
projectsInOrganization: Project[];
};
type GetDomainsResponse = {
domains: Domain[];
};
type SearchProjectsResponse = {
searchProjects: Project[];
};
type AddEnvironmentVariablesResponse = {
addEnvironmentVariables: boolean;
};
type AddEnvironmentVariableInput = {
environments: string[];
key: string;
value: string;
};
type UpdateEnvironmentVariableInput = {
key: string;
value: string;
};
type UpdateProjectMemberInput = {
permissions: Permission[];
};
type AddProjectMemberInput = {
email: string;
permissions: Permission[];
};
type UpdateEnvironmentVariableResponse = {
updateEnvironmentVariable: boolean;
};
type RemoveEnvironmentVariableResponse = {
removeEnvironmentVariable: boolean;
};
type UpdateDeploymentToProdResponse = {
updateDeploymentToProd: boolean;
};
type AddProjectFromTemplateResponse = {
addProjectFromTemplate: Project;
};
type AddProjectResponse = {
addProject: Project;
};
type UpdateProjectResponse = {
updateProject: boolean;
};
type UpdateDomainResponse = {
updateDomain: boolean;
};
type DeleteProjectResponse = {
deleteProject: boolean;
};
type DeleteDomainResponse = {
deleteDomain: boolean;
};
type AddProjectFromTemplateInput = {
templateOwner: string;
templateRepo: string;
owner: string;
name: string;
isPrivate: boolean;
};
type AddProjectInput = {
name: string;
repository: string;
prodBranch: string;
template?: string;
};
type UpdateProjectInput = {
name?: string;
description?: string;
prodBranch?: string;
webhooks?: string[];
organizationId?: string;
};
type UpdateDomainInput = {
name?: string;
branch?: string;
redirectToId?: string | null;
};
type RedeployToProdResponse = {
redeployToProd: boolean;
};
type RollbackDeploymentResponse = {
rollbackDeployment: boolean;
};
type DeleteDeploymentResponse = {
deleteDeployment: boolean;
};
type AddDomainInput = {
name: string;
};
type FilterDomainInput = {
branch?: string;
status?: DomainStatus;
};
type AddDomainResponse = {
addDomain: true;
};
type AuthenticateGitHubResponse = {
authenticateGitHub: {
token: string;
};
};
type UnauthenticateGitHubResponse = {
unauthenticateGitHub: boolean;
};
interface GraphQLConfig {
gqlEndpoint: string;
}
declare class GQLClient {
private client;
constructor(config: GraphQLConfig);
getUser(): Promise<GetUserResponse>;
getProject(projectId: string): Promise<GetProjectResponse>;
getProjectsInOrganization(organizationSlug: string): Promise<GetProjectsInOrganizationResponse>;
getOrganizations(): Promise<GetOrganizationsResponse>;
getDeployments(projectId: string): Promise<GetDeploymentsResponse>;
getEnvironmentVariables(projectId: string): Promise<GetEnvironmentVariablesResponse>;
getProjectMembers(projectId: string): Promise<GetProjectMembersResponse>;
addProjectMember(projectId: string, data: AddProjectMemberInput): Promise<AddProjectMemberResponse>;
updateProjectMember(projectMemberId: string, data: UpdateProjectMemberInput): Promise<UpdateProjectMemberResponse>;
removeProjectMember(projectMemberId: string): Promise<RemoveProjectMemberResponse>;
searchProjects(searchText: string): Promise<SearchProjectsResponse>;
addEnvironmentVariables(projectId: string, data: AddEnvironmentVariableInput[]): Promise<AddEnvironmentVariablesResponse>;
updateEnvironmentVariable(environmentVariableId: string, data: UpdateEnvironmentVariableInput): Promise<UpdateEnvironmentVariableResponse>;
removeEnvironmentVariable(environmentVariableId: string): Promise<RemoveEnvironmentVariableResponse>;
updateDeploymentToProd(deploymentId: string): Promise<UpdateDeploymentToProdResponse>;
addProjectFromTemplate(organizationSlug: string, data: AddProjectFromTemplateInput): Promise<AddProjectFromTemplateResponse>;
addProject(organizationSlug: string, data: AddProjectInput): Promise<AddProjectResponse>;
updateProject(projectId: string, data: UpdateProjectInput): Promise<UpdateProjectResponse>;
updateDomain(domainId: string, data: UpdateDomainInput): Promise<UpdateDomainResponse>;
redeployToProd(deploymentId: string): Promise<RedeployToProdResponse>;
deleteProject(projectId: string): Promise<DeleteProjectResponse>;
deleteDomain(domainId: string): Promise<DeleteDomainResponse>;
rollbackDeployment(projectId: string, deploymentId: string): Promise<RollbackDeploymentResponse>;
deleteDeployment(deploymentId: string): Promise<DeleteDeploymentResponse>;
addDomain(projectId: string, data: AddDomainInput): Promise<AddDomainResponse>;
getDomains(projectId: string, filter?: FilterDomainInput): Promise<GetDomainsResponse>;
authenticateGitHub(code: string): Promise<AuthenticateGitHubResponse>;
unauthenticateGithub(): Promise<UnauthenticateGitHubResponse>;
}
export { type AddDomainInput, type AddDomainResponse, type AddEnvironmentVariableInput, type AddEnvironmentVariablesResponse, type AddProjectFromTemplateInput, type AddProjectFromTemplateResponse, type AddProjectInput, type AddProjectMemberInput, type AddProjectMemberResponse, type AddProjectResponse, type AuthenticateGitHubResponse, type DeleteDeploymentResponse, type DeleteDomainResponse, type DeleteProjectResponse, type Deployment, DeploymentStatus, type Domain, DomainStatus, Environment, type EnvironmentVariable, type FilterDomainInput, GQLClient, type GetDeploymentsResponse, type GetDomainsResponse, type GetEnvironmentVariablesResponse, type GetOrganizationsResponse, type GetProjectMembersResponse, type GetProjectResponse, type GetProjectsInOrganizationResponse, type GetUserResponse, type GraphQLConfig, type Organization, type OrganizationMember, type OrganizationProject, Permission, type Project, type ProjectMember, type RedeployToProdResponse, type RemoveEnvironmentVariableResponse, type RemoveProjectMemberResponse, Role, type RollbackDeploymentResponse, type SearchProjectsResponse, type UnauthenticateGitHubResponse, type UpdateDeploymentToProdResponse, type UpdateDomainInput, type UpdateDomainResponse, type UpdateEnvironmentVariableInput, type UpdateEnvironmentVariableResponse, type UpdateProjectInput, type UpdateProjectMemberInput, type UpdateProjectMemberResponse, type UpdateProjectResponse, type User };