diff --git a/packages/backend/src/resolvers.ts b/packages/backend/src/resolvers.ts index 5e40c74a..9ddfed0a 100644 --- a/packages/backend/src/resolvers.ts +++ b/packages/backend/src/resolvers.ts @@ -17,7 +17,7 @@ export const createResolvers = async (service: Service): Promise => { return context.user; }, - organizations: async (_:any, __: any, context: any) => { + organizations: async (_: any, __: any, context: any) => { return service.getOrganizationsByUserId(context.user); }, @@ -25,8 +25,15 @@ export const createResolvers = async (service: Service): Promise => { return service.getProjectById(projectId); }, - projectsInOrganization: async (_: any, { organizationSlug }: {organizationSlug: string }, context: any) => { - return service.getProjectsInOrganization(context.user, organizationSlug); + projectsInOrganization: async ( + _: any, + { organizationSlug }: { organizationSlug: string }, + context: any, + ) => { + return service.getProjectsInOrganization( + context.user, + organizationSlug, + ); }, deployments: async (_: any, { projectId }: { projectId: string }) => { @@ -35,7 +42,7 @@ export const createResolvers = async (service: Service): Promise => { environmentVariables: async ( _: any, - { projectId }: { projectId: string } + { projectId }: { projectId: string }, ) => { return service.getEnvironmentVariablesByProjectId(projectId); }, @@ -44,7 +51,11 @@ export const createResolvers = async (service: Service): Promise => { return service.getProjectMembersByProjectId(projectId); }, - searchProjects: async (_: any, { searchText }: { searchText: string }, context: any) => { + searchProjects: async ( + _: any, + { searchText }: { searchText: string }, + context: any, + ) => { return service.searchProjects(context.user, searchText); }, @@ -52,11 +63,11 @@ export const createResolvers = async (service: Service): Promise => { _: any, { projectId, - filter - }: { projectId: string; filter?: FindOptionsWhere } + filter, + }: { projectId: string; filter?: FindOptionsWhere }, ) => { return service.getDomainsByProjectId(projectId, filter); - } + }, }, // TODO: Return error in GQL response @@ -64,10 +75,13 @@ export const createResolvers = async (service: Service): Promise => { removeProjectMember: async ( _: any, { projectMemberId }: { projectMemberId: string }, - context: any + context: any, ) => { try { - return await service.removeProjectMember(context.user, projectMemberId); + return await service.removeProjectMember( + context.user, + projectMemberId, + ); } catch (err) { log(err); return false; @@ -78,13 +92,13 @@ export const createResolvers = async (service: Service): Promise => { _: any, { projectMemberId, - data + data, }: { projectMemberId: string; data: { permissions: Permission[]; }; - } + }, ) => { try { return await service.updateProjectMember(projectMemberId, data); @@ -98,14 +112,14 @@ export const createResolvers = async (service: Service): Promise => { _: any, { projectId, - data + data, }: { projectId: string; data: { email: string; permissions: Permission[]; }; - } + }, ) => { try { return Boolean(await service.addProjectMember(projectId, data)); @@ -119,15 +133,15 @@ export const createResolvers = async (service: Service): Promise => { _: any, { projectId, - data + data, }: { projectId: string; data: { environments: string[]; key: string; value: string }[]; - } + }, ) => { try { return Boolean( - await service.addEnvironmentVariables(projectId, data) + await service.addEnvironmentVariables(projectId, data), ); } catch (err) { log(err); @@ -139,16 +153,16 @@ export const createResolvers = async (service: Service): Promise => { _: any, { environmentVariableId, - data + data, }: { environmentVariableId: string; data: DeepPartial; - } + }, ) => { try { return await service.updateEnvironmentVariable( environmentVariableId, - data + data, ); } catch (err) { log(err); @@ -158,7 +172,7 @@ export const createResolvers = async (service: Service): Promise => { removeEnvironmentVariable: async ( _: any, - { environmentVariableId }: { environmentVariableId: string } + { environmentVariableId }: { environmentVariableId: string }, ) => { try { return await service.removeEnvironmentVariable(environmentVariableId); @@ -171,10 +185,12 @@ export const createResolvers = async (service: Service): Promise => { updateDeploymentToProd: async ( _: any, { deploymentId }: { deploymentId: string }, - context: any + context: any, ) => { try { - return Boolean(await service.updateDeploymentToProd(context.user, deploymentId)); + return Boolean( + await service.updateDeploymentToProd(context.user, deploymentId), + ); } catch (err) { log(err); return false; @@ -185,9 +201,9 @@ export const createResolvers = async (service: Service): Promise => { _: any, { organizationSlug, - data + data, }: { organizationSlug: string; data: DeepPartial }, - context: any + context: any, ) => { try { return await service.addProject(context.user, organizationSlug, data); @@ -199,7 +215,7 @@ export const createResolvers = async (service: Service): Promise => { updateProject: async ( _: any, - { projectId, data }: { projectId: string; data: DeepPartial } + { projectId, data }: { projectId: string; data: DeepPartial }, ) => { try { return await service.updateProject(projectId, data); @@ -212,10 +228,12 @@ export const createResolvers = async (service: Service): Promise => { redeployToProd: async ( _: any, { deploymentId }: { deploymentId: string }, - context: any + context: any, ) => { try { - return Boolean(await service.redeployToProd(context.user, deploymentId)); + return Boolean( + await service.redeployToProd(context.user, deploymentId), + ); } catch (err) { log(err); return false; @@ -244,8 +262,8 @@ export const createResolvers = async (service: Service): Promise => { _: any, { projectId, - deploymentId - }: { deploymentId: string; projectId: string } + deploymentId, + }: { deploymentId: string; projectId: string }, ) => { try { return await service.rollbackDeployment(projectId, deploymentId); @@ -257,9 +275,7 @@ export const createResolvers = async (service: Service): Promise => { deleteDeployment: async ( _: any, - { - deploymentId - }: { deploymentId: string; } + { deploymentId }: { deploymentId: string }, ) => { try { return await service.deleteDeployment(deploymentId); @@ -271,7 +287,7 @@ export const createResolvers = async (service: Service): Promise => { addDomain: async ( _: any, - { projectId, data }: { projectId: string; data: { name: string } } + { projectId, data }: { projectId: string; data: { name: string } }, ) => { try { return Boolean(await service.addDomain(projectId, data)); @@ -283,7 +299,7 @@ export const createResolvers = async (service: Service): Promise => { updateDomain: async ( _: any, - { domainId, data }: { domainId: string; data: DeepPartial } + { domainId, data }: { domainId: string; data: DeepPartial }, ) => { try { return await service.updateDomain(domainId, data); @@ -296,7 +312,7 @@ export const createResolvers = async (service: Service): Promise => { authenticateGitHub: async ( _: any, { code }: { code: string }, - context: any + context: any, ) => { try { return await service.authenticateGitHub(code, context.user); @@ -308,12 +324,14 @@ export const createResolvers = async (service: Service): Promise => { unauthenticateGitHub: async (_: any, __: object, context: any) => { try { - return service.unauthenticateGitHub(context.user, { gitHubToken: null }); + return service.unauthenticateGitHub(context.user, { + gitHubToken: null, + }); } catch (err) { log(err); return false; } - } - } + }, + }, }; }; diff --git a/packages/backend/src/routes/staging.ts b/packages/backend/src/routes/staging.ts new file mode 100644 index 00000000..83ab5341 --- /dev/null +++ b/packages/backend/src/routes/staging.ts @@ -0,0 +1,9 @@ +import { Router } from 'express'; + +const router = Router(); + +router.get('/version', async (req, res) => { + return res.send({ version: '0.0.2' }); +}); + +export default router; diff --git a/packages/backend/src/server.ts b/packages/backend/src/server.ts index 74f7e5ed..b1717ca3 100644 --- a/packages/backend/src/server.ts +++ b/packages/backend/src/server.ts @@ -17,6 +17,7 @@ import { ServerConfig } from './config'; import { DEFAULT_GQL_PATH } from './constants'; import githubRouter from './routes/github'; import authRouter from './routes/auth'; +import stagingRouter from './routes/staging'; import { Service } from './service'; const log = debug('snowball:server'); @@ -109,6 +110,7 @@ export const createAndStartServer = async ( app.set('service', service); app.use('/auth', authRouter); app.use('/api/github', githubRouter); + app.use('/staging', stagingRouter); httpServer.listen(port, host, () => { log(`Server is listening on ${host}:${port}${server.graphqlPath}`); diff --git a/packages/backend/src/service.ts b/packages/backend/src/service.ts index aa6b5988..692ee577 100644 --- a/packages/backend/src/service.ts +++ b/packages/backend/src/service.ts @@ -15,7 +15,12 @@ import { Permission, ProjectMember } from './entity/ProjectMember'; import { User } from './entity/User'; import { Registry } from './registry'; import { GitHubConfig, RegistryConfig } from './config'; -import { AppDeploymentRecord, AppDeploymentRemovalRecord, GitPushEventPayload, PackageJSON } from './types'; +import { + AppDeploymentRecord, + AppDeploymentRemovalRecord, + GitPushEventPayload, + PackageJSON, +} from './types'; import { Role } from './entity/UserOrganization'; const log = debug('snowball:service'); @@ -38,7 +43,7 @@ export class Service { private deployRecordCheckTimeout?: NodeJS.Timeout; - constructor (config: Config, db: Database, app: OAuthApp, registry: Registry) { + constructor(config: Config, db: Database, app: OAuthApp, registry: Registry) { this.db = db; this.oauthApp = app; this.registry = registry; @@ -49,7 +54,7 @@ export class Service { /** * Initialize services */ - init (): void { + init(): void { // Start check for ApplicationDeploymentRecords asynchronously this.checkDeployRecordsAndUpdate(); // Start check for ApplicationDeploymentRemovalRecords asynchronously @@ -59,7 +64,7 @@ export class Service { /** * Destroy services */ - destroy (): void { + destroy(): void { clearTimeout(this.deployRecordCheckTimeout); } @@ -67,37 +72,36 @@ export class Service { * Checks for ApplicationDeploymentRecord and update corresponding deployments * Continues check in loop after a delay of registryConfig.fetchDeploymentRecordDelay */ - async checkDeployRecordsAndUpdate (): Promise { + async checkDeployRecordsAndUpdate(): Promise { // Fetch deployments in building state const deployments = await this.db.getDeployments({ where: { - status: DeploymentStatus.Building - } + status: DeploymentStatus.Building, + }, }); if (deployments.length) { log( - `Found ${deployments.length} deployments in ${DeploymentStatus.Building} state` + `Found ${deployments.length} deployments in ${DeploymentStatus.Building} state`, ); // Calculate a timestamp for one hour ago const anHourAgo = Date.now() - HOUR; // Filter out deployments started more than an hour ago and mark them as Error - const oldDeploymentsToUpdate = deployments.filter( - deployment => (Number(deployment.updatedAt) < anHourAgo) - ) + const oldDeploymentsToUpdate = deployments + .filter((deployment) => Number(deployment.updatedAt) < anHourAgo) .map((deployment) => { return this.db.updateDeploymentById(deployment.id, { status: DeploymentStatus.Error, - isCurrent: false + isCurrent: false, }); }); // If there are old deployments to update, log and perform the updates if (oldDeploymentsToUpdate.length > 0) { log( - `Cleaning up ${oldDeploymentsToUpdate.length} deployments stuck in ${DeploymentStatus.Building} state for over an hour` + `Cleaning up ${oldDeploymentsToUpdate.length} deployments stuck in ${DeploymentStatus.Building} state for over an hour`, ); await Promise.all(oldDeploymentsToUpdate); } @@ -121,21 +125,22 @@ export class Service { * Checks for ApplicationDeploymentRemovalRecord and remove corresponding deployments * Continues check in loop after a delay of registryConfig.fetchDeploymentRecordDelay */ - async checkDeploymentRemovalRecordsAndUpdate (): Promise { + async checkDeploymentRemovalRecordsAndUpdate(): Promise { // Fetch deployments in deleting state const deployments = await this.db.getDeployments({ where: { - status: DeploymentStatus.Deleting - } + status: DeploymentStatus.Deleting, + }, }); if (deployments.length) { log( - `Found ${deployments.length} deployments in ${DeploymentStatus.Deleting} state` + `Found ${deployments.length} deployments in ${DeploymentStatus.Deleting} state`, ); // Fetch ApplicationDeploymentRemovalRecords for deployments - const records = await this.registry.getDeploymentRemovalRecords(deployments); + const records = + await this.registry.getDeploymentRemovalRecords(deployments); log(`Found ${records.length} ApplicationDeploymentRemovalRecords`); // Update deployments for which ApplicationDeploymentRemovalRecords were returned @@ -152,17 +157,17 @@ export class Service { /** * Update deployments with ApplicationDeploymentRecord data */ - async updateDeploymentsWithRecordData ( - records: AppDeploymentRecord[] + async updateDeploymentsWithRecordData( + records: AppDeploymentRecord[], ): Promise { // Get deployments for ApplicationDeploymentRecords const deployments = await this.db.getDeployments({ where: records.map((record) => ({ - applicationRecordId: record.attributes.application + applicationRecordId: record.attributes.application, })), order: { - createdAt: 'DESC' - } + createdAt: 'DESC', + }, }); // Get project IDs of deployments that are in production environment @@ -174,13 +179,13 @@ export class Service { return acc; }, - new Set() + new Set(), ); // Set old deployments isCurrent to false await this.db.updateDeploymentsByProjectIds( Array.from(productionDeploymentProjectIds), - { isCurrent: false } + { isCurrent: false }, ); const recordToDeploymentsMap = deployments.reduce( @@ -188,7 +193,7 @@ export class Service { acc[deployment.applicationRecordId] = deployment; return acc; }, - {} + {}, ); // Update deployment data for ApplicationDeploymentRecords @@ -200,11 +205,11 @@ export class Service { applicationDeploymentRecordData: record.attributes, url: record.attributes.url, status: DeploymentStatus.Ready, - isCurrent: deployment.environment === Environment.Production + isCurrent: deployment.environment === Environment.Production, }); log( - `Updated deployment ${deployment.id} with URL ${record.attributes.url}` + `Updated deployment ${deployment.id} with URL ${record.attributes.url}`, ); }); @@ -214,21 +219,27 @@ export class Service { /** * Delete deployments with ApplicationDeploymentRemovalRecord data */ - async deleteDeploymentsWithRecordData ( + async deleteDeploymentsWithRecordData( records: AppDeploymentRemovalRecord[], deployments: Deployment[], ): Promise { - const removedApplicationDeploymentRecordIds = records.map(record => record.attributes.deployment); - + const removedApplicationDeploymentRecordIds = records.map( + (record) => record.attributes.deployment, + ); + // Get removed deployments for ApplicationDeploymentRecords - const removedDeployments = deployments.filter(deployment => removedApplicationDeploymentRecordIds.includes(deployment.applicationDeploymentRecordId!)) + const removedDeployments = deployments.filter((deployment) => + removedApplicationDeploymentRecordIds.includes( + deployment.applicationDeploymentRecordId!, + ), + ); const recordToDeploymentsMap = removedDeployments.reduce( (acc: { [key: string]: Deployment }, deployment) => { acc[deployment.applicationDeploymentRecordId!] = deployment; return acc; }, - {} + {}, ); // Update deployment data for ApplicationDeploymentRecords and delete @@ -241,53 +252,53 @@ export class Service { }); log( - `Updated deployment ${deployment.id} with ApplicationDeploymentRemovalRecord ${record.id}` + `Updated deployment ${deployment.id} with ApplicationDeploymentRemovalRecord ${record.id}`, ); - await this.db.deleteDeploymentById(deployment.id) + await this.db.deleteDeploymentById(deployment.id); }); await Promise.all(deploymentUpdatePromises); } - async getUser (userId: string): Promise { + async getUser(userId: string): Promise { return this.db.getUser({ where: { - id: userId - } + id: userId, + }, }); } async getUserByEmail(email: string): Promise { return await this.db.getUser({ where: { - email - } + email, + }, }); } async getUserBySubOrgId(subOrgId: string): Promise { return await this.db.getUser({ where: { - subOrgId - } + subOrgId, + }, }); } - async getUserByEthAddress (ethAddress: string): Promise { + async getUserByEthAddress(ethAddress: string): Promise { return await this.db.getUser({ where: { - ethAddress - } + ethAddress, + }, }); } - async createUser (params: { - name: string - email: string - subOrgId: string - ethAddress: string - turnkeyWalletId: string + async createUser(params: { + name: string; + email: string; + subOrgId: string; + ethAddress: string; + turnkeyWalletId: string; }): Promise { const [org] = await this.db.getOrganizations({}); assert(org, 'No organizations exists in database'); @@ -305,113 +316,125 @@ export class Service { await this.db.addUserOrganization({ member: user, organization: org, - role: Role.Owner + role: Role.Owner, }); return user; } - async getOctokit (userId: string): Promise { + async getOctokit(userId: string): Promise { const user = await this.db.getUser({ where: { id: userId } }); assert( user && user.gitHubToken, - 'User needs to be authenticated with GitHub token' + 'User needs to be authenticated with GitHub token', ); return new Octokit({ auth: user.gitHubToken }); } - async getOrganizationsByUserId (user: User): Promise { + async getOrganizationsByUserId(user: User): Promise { const dbOrganizations = await this.db.getOrganizationsByUserId(user.id); return dbOrganizations; } - async getProjectById (projectId: string): Promise { + async getProjectById(projectId: string): Promise { const dbProject = await this.db.getProjectById(projectId); return dbProject; } - async getProjectsInOrganization (user: User, organizationSlug: string): Promise { - const dbProjects = await this.db.getProjectsInOrganization(user.id, organizationSlug); + async getProjectsInOrganization( + user: User, + organizationSlug: string, + ): Promise { + const dbProjects = await this.db.getProjectsInOrganization( + user.id, + organizationSlug, + ); return dbProjects; } - async getDeploymentsByProjectId (projectId: string): Promise { + async getDeploymentsByProjectId(projectId: string): Promise { const dbDeployments = await this.db.getDeploymentsByProjectId(projectId); return dbDeployments; } - async getEnvironmentVariablesByProjectId ( - projectId: string + async getEnvironmentVariablesByProjectId( + projectId: string, ): Promise { const dbEnvironmentVariables = await this.db.getEnvironmentVariablesByProjectId(projectId); return dbEnvironmentVariables; } - async getProjectMembersByProjectId ( - projectId: string + async getProjectMembersByProjectId( + projectId: string, ): Promise { const dbProjectMembers = await this.db.getProjectMembersByProjectId(projectId); return dbProjectMembers; } - async searchProjects (user: User, searchText: string): Promise { - const dbProjects = await this.db.getProjectsBySearchText(user.id, searchText); + async searchProjects(user: User, searchText: string): Promise { + const dbProjects = await this.db.getProjectsBySearchText( + user.id, + searchText, + ); return dbProjects; } - async getDomainsByProjectId ( + async getDomainsByProjectId( projectId: string, - filter?: FindOptionsWhere + filter?: FindOptionsWhere, ): Promise { const dbDomains = await this.db.getDomainsByProjectId(projectId, filter); return dbDomains; } - async updateProjectMember ( + async updateProjectMember( projectMemberId: string, - data: { permissions: Permission[] } + data: { permissions: Permission[] }, ): Promise { return this.db.updateProjectMemberById(projectMemberId, data); } - async addProjectMember ( + async addProjectMember( projectId: string, data: { email: string; permissions: Permission[]; - } + }, ): Promise { // TODO: Send invitation let user = await this.db.getUser({ where: { - email: data.email - } + email: data.email, + }, }); if (!user) { user = await this.db.addUser({ - email: data.email + email: data.email, }); } const newProjectMember = await this.db.addProjectMember({ project: { - id: projectId + id: projectId, }, permissions: data.permissions, isPending: true, member: { - id: user.id - } + id: user.id, + }, }); return newProjectMember; } - async removeProjectMember (user: User, projectMemberId: string): Promise { + async removeProjectMember( + user: User, + projectMemberId: string, + ): Promise { const member = await this.db.getProjectMemberById(projectMemberId); if (String(member.member.id) === user.id) { @@ -428,9 +451,9 @@ export class Service { } } - async addEnvironmentVariables ( + async addEnvironmentVariables( projectId: string, - data: { environments: string[]; key: string; value: string }[] + data: { environments: string[]; key: string; value: string }[], ): Promise { const formattedEnvironmentVariables = data .map((environmentVariable) => { @@ -440,38 +463,41 @@ export class Service { value: environmentVariable.value, environment: environment as Environment, project: Object.assign(new Project(), { - id: projectId - }) + id: projectId, + }), }; }); }) .flat(); const savedEnvironmentVariables = await this.db.addEnvironmentVariables( - formattedEnvironmentVariables + formattedEnvironmentVariables, ); return savedEnvironmentVariables; } - async updateEnvironmentVariable ( + async updateEnvironmentVariable( environmentVariableId: string, - data: DeepPartial + data: DeepPartial, ): Promise { return this.db.updateEnvironmentVariable(environmentVariableId, data); } - async removeEnvironmentVariable ( - environmentVariableId: string + async removeEnvironmentVariable( + environmentVariableId: string, ): Promise { return this.db.deleteEnvironmentVariable(environmentVariableId); } - async updateDeploymentToProd (user: User, deploymentId: string): Promise { + async updateDeploymentToProd( + user: User, + deploymentId: string, + ): Promise { const oldDeployment = await this.db.getDeployment({ where: { id: deploymentId }, relations: { - project: true - } + project: true, + }, }); if (!oldDeployment) { @@ -480,33 +506,31 @@ export class Service { const prodBranchDomains = await this.db.getDomainsByProjectId( oldDeployment.project.id, - { branch: oldDeployment.project.prodBranch } + { branch: oldDeployment.project.prodBranch }, ); const octokit = await this.getOctokit(user.id); - const newDeployment = await this.createDeployment(user.id, - octokit, - { - project: oldDeployment.project, - branch: oldDeployment.branch, - environment: Environment.Production, - domain: prodBranchDomains[0], - commitHash: oldDeployment.commitHash, - commitMessage: oldDeployment.commitMessage - }); + const newDeployment = await this.createDeployment(user.id, octokit, { + project: oldDeployment.project, + branch: oldDeployment.branch, + environment: Environment.Production, + domain: prodBranchDomains[0], + commitHash: oldDeployment.commitHash, + commitMessage: oldDeployment.commitMessage, + }); return newDeployment; } - async createDeployment ( + async createDeployment( userId: string, octokit: Octokit, - data: DeepPartial + data: DeepPartial, ): Promise { assert(data.project?.repository, 'Project repository not found'); log( - `Creating deployment in project ${data.project.name} from branch ${data.branch}` + `Creating deployment in project ${data.project.name} from branch ${data.branch}`, ); const [owner, repo] = data.project.repository.split('/'); @@ -514,7 +538,7 @@ export class Service { owner, repo, path: 'package.json', - ref: data.commitHash + ref: data.commitHash, }); if (!packageJSONData) { @@ -526,10 +550,12 @@ export class Service { assert(packageJSON.name, "name field doesn't exist in package.json"); - const repoUrl = (await octokit.rest.repos.get({ - owner, - repo - })).data.html_url; + const repoUrl = ( + await octokit.rest.repos.get({ + owner, + repo, + }) + ).data.html_url; // TODO: Set environment variables for each deployment (environment variables can`t be set in application record) const { applicationRecordId, applicationRecordData } = @@ -538,17 +564,20 @@ export class Service { packageJSON, appType: data.project!.template!, commitHash: data.commitHash!, - repoUrl + repoUrl, }); // Update previous deployment with prod branch domain // TODO: Fix unique constraint error for domain if (data.domain) { - await this.db.updateDeployment({ - domainId: data.domain.id - }, { - domain: null - }); + await this.db.updateDeployment( + { + domainId: data.domain.id, + }, + { + domain: null, + }, + ); } const newDeployment = await this.db.addDeployment({ @@ -562,53 +591,67 @@ export class Service { applicationRecordData, domain: data.domain, createdBy: Object.assign(new User(), { - id: userId - }) + id: userId, + }), }); - log(`Created deployment ${newDeployment.id} and published application record ${applicationRecordId}`); + log( + `Created deployment ${newDeployment.id} and published application record ${applicationRecordId}`, + ); - const environmentVariables = await this.db.getEnvironmentVariablesByProjectId(data.project.id!, { environment: Environment.Production }); + const environmentVariables = + await this.db.getEnvironmentVariablesByProjectId(data.project.id!, { + environment: Environment.Production, + }); - const environmentVariablesObj = environmentVariables.reduce((acc, env) => { - acc[env.key] = env.value; + const environmentVariablesObj = environmentVariables.reduce( + (acc, env) => { + acc[env.key] = env.value; - return acc; - }, {} as { [key: string]: string }); + return acc; + }, + {} as { [key: string]: string }, + ); // To set project DNS if (data.environment === Environment.Production) { // On deleting deployment later, project DNS deployment is also deleted // So publish project DNS deployment first so that ApplicationDeploymentRecord for the same is available when deleting deployment later - await this.registry.createApplicationDeploymentRequest( - { - deployment: newDeployment, - appName: repo, - repository: repoUrl, - environmentVariables: environmentVariablesObj, - dns: `${newDeployment.project.name}` - }); - } - - const { applicationDeploymentRequestId, applicationDeploymentRequestData } = await this.registry.createApplicationDeploymentRequest( - { + await this.registry.createApplicationDeploymentRequest({ deployment: newDeployment, appName: repo, repository: repoUrl, environmentVariables: environmentVariablesObj, - dns: `${newDeployment.project.name}-${newDeployment.id}` + dns: `${newDeployment.project.name}`, + }); + } + + const { applicationDeploymentRequestId, applicationDeploymentRequestData } = + await this.registry.createApplicationDeploymentRequest({ + deployment: newDeployment, + appName: repo, + repository: repoUrl, + environmentVariables: environmentVariablesObj, + dns: `${newDeployment.project.name}-${newDeployment.id}`, }); - await this.db.updateDeploymentById(newDeployment.id, { applicationDeploymentRequestId, applicationDeploymentRequestData }); + await this.db.updateDeploymentById(newDeployment.id, { + applicationDeploymentRequestId, + applicationDeploymentRequestData, + }); return newDeployment; } - async addProject (user: User, organizationSlug: string, data: DeepPartial): Promise { + async addProject( + user: User, + organizationSlug: string, + data: DeepPartial, + ): Promise { const organization = await this.db.getOrganization({ where: { - slug: organizationSlug - } + slug: organizationSlug, + }, }); if (!organization) { throw new Error('Organization does not exist'); @@ -620,33 +663,30 @@ export class Service { const [owner, repo] = project.repository.split('/'); const { - data: [latestCommit] + data: [latestCommit], } = await octokit.rest.repos.listCommits({ owner, repo, sha: project.prodBranch, - per_page: 1 + per_page: 1, }); // Create deployment with prod branch and latest commit - await this.createDeployment(user.id, - octokit, - { - project, - branch: project.prodBranch, - environment: Environment.Production, - domain: null, - commitHash: latestCommit.sha, - commitMessage: latestCommit.commit.message - } - ); + await this.createDeployment(user.id, octokit, { + project, + branch: project.prodBranch, + environment: Environment.Production, + domain: null, + commitHash: latestCommit.sha, + commitMessage: latestCommit.commit.message, + }); await this.createRepoHook(octokit, project); return project; } - async createRepoHook (octokit: Octokit, project: Project): Promise { + async createRepoHook(octokit: Octokit, project: Project): Promise { try { const [owner, repo] = project.repository.split('/'); await octokit.rest.repos.createWebhook({ @@ -655,11 +695,11 @@ export class Service { config: { url: new URL( 'api/github/webhook', - this.config.gitHubConfig.webhookUrl + this.config.gitHubConfig.webhookUrl, ).href, - content_type: 'json' + content_type: 'json', }, - events: ['push'] + events: ['push'], }); } catch (err) { // https://docs.github.com/en/rest/repos/webhooks?apiVersion=2022-11-28#create-a-repository-webhook--status-codes @@ -668,7 +708,7 @@ export class Service { err instanceof RequestError && err.status === 422 && (err.response?.data as any).errors.some( - (err: any) => err.message === GITHUB_UNIQUE_WEBHOOK_ERROR + (err: any) => err.message === GITHUB_UNIQUE_WEBHOOK_ERROR, ) ) ) { @@ -679,7 +719,7 @@ export class Service { } } - async handleGitHubPush (data: GitPushEventPayload): Promise { + async handleGitHubPush(data: GitPushEventPayload): Promise { const { repository, ref, head_commit: headCommit, deleted } = data; if (deleted) { @@ -687,9 +727,11 @@ export class Service { return; } - log(`Handling GitHub push event from repository: ${repository.full_name}, branch: ${ref}`); + log( + `Handling GitHub push event from repository: ${repository.full_name}, branch: ${ref}`, + ); const projects = await this.db.getProjects({ - where: { repository: repository.full_name } + where: { repository: repository.full_name }, }); if (!projects.length) { @@ -703,7 +745,7 @@ export class Service { for await (const project of projects) { const octokit = await this.getOctokit(project.ownerId); const [domain] = await this.db.getDomainsByProjectId(project.id, { - branch + branch, }); // Create deployment with branch and latest commit in GitHub data @@ -716,49 +758,49 @@ export class Service { : Environment.Preview, domain, commitHash: headCommit.id, - commitMessage: headCommit.message + commitMessage: headCommit.message, }); } } - async updateProject ( + async updateProject( projectId: string, - data: DeepPartial + data: DeepPartial, ): Promise { return this.db.updateProjectById(projectId, data); } - async deleteProject (projectId: string): Promise { + async deleteProject(projectId: string): Promise { // TODO: Remove GitHub repo hook return this.db.deleteProjectById(projectId); } - async deleteDomain (domainId: string): Promise { + async deleteDomain(domainId: string): Promise { const domainsRedirectedFrom = await this.db.getDomains({ where: { - redirectToId: domainId - } + redirectToId: domainId, + }, }); if (domainsRedirectedFrom.length > 0) { throw new Error( - 'Cannot delete domain since it has redirects from other domains' + 'Cannot delete domain since it has redirects from other domains', ); } return this.db.deleteDomainById(domainId); } - async redeployToProd (user: User, deploymentId: string): Promise { + async redeployToProd(user: User, deploymentId: string): Promise { const oldDeployment = await this.db.getDeployment({ relations: { project: true, domain: true, - createdBy: true + createdBy: true, }, where: { - id: deploymentId - } + id: deploymentId, + }, }); if (oldDeployment === null) { @@ -767,36 +809,34 @@ export class Service { const octokit = await this.getOctokit(user.id); - const newDeployment = await this.createDeployment(user.id, - octokit, - { - project: oldDeployment.project, - // TODO: Put isCurrent field in project - branch: oldDeployment.branch, - environment: Environment.Production, - domain: oldDeployment.domain, - commitHash: oldDeployment.commitHash, - commitMessage: oldDeployment.commitMessage - }); + const newDeployment = await this.createDeployment(user.id, octokit, { + project: oldDeployment.project, + // TODO: Put isCurrent field in project + branch: oldDeployment.branch, + environment: Environment.Production, + domain: oldDeployment.domain, + commitHash: oldDeployment.commitHash, + commitMessage: oldDeployment.commitMessage, + }); return newDeployment; } - async rollbackDeployment ( + async rollbackDeployment( projectId: string, - deploymentId: string + deploymentId: string, ): Promise { // TODO: Implement transactions const oldCurrentDeployment = await this.db.getDeployment({ relations: { - domain: true + domain: true, }, where: { project: { - id: projectId + id: projectId, }, - isCurrent: true - } + isCurrent: true, + }, }); if (!oldCurrentDeployment) { @@ -805,65 +845,73 @@ export class Service { const oldCurrentDeploymentUpdate = await this.db.updateDeploymentById( oldCurrentDeployment.id, - { isCurrent: false, domain: null } + { isCurrent: false, domain: null }, ); const newCurrentDeploymentUpdate = await this.db.updateDeploymentById( deploymentId, - { isCurrent: true, domain: oldCurrentDeployment?.domain } + { isCurrent: true, domain: oldCurrentDeployment?.domain }, ); return newCurrentDeploymentUpdate && oldCurrentDeploymentUpdate; } - async deleteDeployment (deploymentId: string): Promise { + async deleteDeployment(deploymentId: string): Promise { const deployment = await this.db.getDeployment({ where: { - id: deploymentId + id: deploymentId, }, relations: { - project: true - } + project: true, + }, }); if (deployment && deployment.applicationDeploymentRecordId) { // If deployment is current, remove deployment for project subdomain as well if (deployment.isCurrent) { const currentDeploymentURL = `https://${deployment.project.subDomain}`; - - const deploymentRecords = await this.registry.getDeploymentRecordsByFilter({ - application: deployment.applicationRecordId, - url: currentDeploymentURL - }) + + const deploymentRecords = + await this.registry.getDeploymentRecordsByFilter({ + application: deployment.applicationRecordId, + url: currentDeploymentURL, + }); if (!deploymentRecords.length) { - log(`No ApplicationDeploymentRecord found for URL ${currentDeploymentURL} and ApplicationDeploymentRecord id ${deployment.applicationDeploymentRecordId}`); + log( + `No ApplicationDeploymentRecord found for URL ${currentDeploymentURL} and ApplicationDeploymentRecord id ${deployment.applicationDeploymentRecordId}`, + ); + return false; } - await this.registry.createApplicationDeploymentRemovalRequest({ deploymentId: deploymentRecords[0].id }); + await this.registry.createApplicationDeploymentRemovalRequest({ + deploymentId: deploymentRecords[0].id, + }); } - const result = await this.registry.createApplicationDeploymentRemovalRequest({ deploymentId: deployment.applicationDeploymentRecordId }); + const result = + await this.registry.createApplicationDeploymentRemovalRequest({ + deploymentId: deployment.applicationDeploymentRecordId, + }); - await this.db.updateDeploymentById( - deployment.id, - { - status: DeploymentStatus.Deleting, - applicationDeploymentRemovalRequestId: result.applicationDeploymentRemovalRequestId, - applicationDeploymentRemovalRequestData: result.applicationDeploymentRemovalRequestData - } - ); + await this.db.updateDeploymentById(deployment.id, { + status: DeploymentStatus.Deleting, + applicationDeploymentRemovalRequestId: + result.applicationDeploymentRemovalRequestId, + applicationDeploymentRemovalRequestData: + result.applicationDeploymentRemovalRequestData, + }); - return (result !== undefined || result !== null); + return result !== undefined || result !== null; } return false; } - async addDomain ( + async addDomain( projectId: string, - data: { name: string } + data: { name: string }, ): Promise<{ primaryDomain: Domain; redirectedDomain: Domain; @@ -877,7 +925,7 @@ export class Service { const primaryDomainDetails = { ...data, branch: currentProject.prodBranch, - project: currentProject + project: currentProject, }; const savedPrimaryDomain = await this.db.addDomain(primaryDomainDetails); @@ -888,27 +936,27 @@ export class Service { name: domainArr.length > 1 ? domainArr[1] : `www.${domainArr[0]}`, branch: currentProject.prodBranch, project: currentProject, - redirectTo: savedPrimaryDomain + redirectTo: savedPrimaryDomain, }; const savedRedirectedDomain = await this.db.addDomain( - redirectedDomainDetails + redirectedDomainDetails, ); return { primaryDomain: savedPrimaryDomain, - redirectedDomain: savedRedirectedDomain + redirectedDomain: savedRedirectedDomain, }; } - async updateDomain ( + async updateDomain( domainId: string, - data: DeepPartial + data: DeepPartial, ): Promise { const domain = await this.db.getDomain({ where: { - id: domainId - } + id: domainId, + }, }); if (domain === null) { @@ -916,16 +964,16 @@ export class Service { } const newDomain = { - ...data + ...data, }; const domainsRedirectedFrom = await this.db.getDomains({ where: { project: { - id: domain.projectId + id: domain.projectId, }, - redirectToId: domain.id - } + redirectToId: domain.id, + }, }); // If there are domains redirecting to current domain, only branch of current domain can be updated @@ -936,8 +984,8 @@ export class Service { if (data.redirectToId) { const redirectedDomain = await this.db.getDomain({ where: { - id: data.redirectToId - } + id: data.redirectToId, + }, }); if (redirectedDomain === null) { @@ -946,7 +994,7 @@ export class Service { if (redirectedDomain.redirectToId) { throw new Error( - 'Unable to redirect to the domain because it is already redirecting elsewhere. Redirects cannot be chained.' + 'Unable to redirect to the domain because it is already redirecting elsewhere. Redirects cannot be chained.', ); } @@ -958,9 +1006,14 @@ export class Service { return updateResult; } - async authenticateGitHub (code:string, user: User): Promise<{token: string}> { - const { authentication: { token } } = await this.oauthApp.createToken({ - code + async authenticateGitHub( + code: string, + user: User, + ): Promise<{ token: string }> { + const { + authentication: { token }, + } = await this.oauthApp.createToken({ + code, }); await this.db.updateUser(user, { gitHubToken: token }); @@ -968,7 +1021,10 @@ export class Service { return { token }; } - async unauthenticateGitHub (user: User, data: DeepPartial): Promise { + async unauthenticateGitHub( + user: User, + data: DeepPartial, + ): Promise { return this.db.updateUser(user, data); } } diff --git a/packages/gql-client/dist/index.js.map b/packages/gql-client/dist/index.js.map index dd1cb566..36d83c02 100644 --- a/packages/gql-client/dist/index.js.map +++ b/packages/gql-client/dist/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/index.ts","../src/client.ts","../src/queries.ts","../src/mutations.ts","../src/types.ts"],"sourcesContent":["export * from \"./client\";\nexport * from \"./types\";\n","import { ApolloClient, DefaultOptions, InMemoryCache, NormalizedCacheObject } from '@apollo/client';\n\nimport * as queries from './queries';\nimport * as types from './types';\nimport * as mutations from './mutations';\n\nexport interface GraphQLConfig {\n gqlEndpoint: string;\n}\n\n// TODO: check options\nconst defaultOptions: DefaultOptions = {\n watchQuery: {\n fetchPolicy: 'no-cache',\n errorPolicy: 'ignore'\n },\n query: {\n fetchPolicy: 'no-cache',\n errorPolicy: 'all'\n }\n};\n\nexport class GQLClient {\n private client: ApolloClient;\n\n constructor (config: GraphQLConfig) {\n this.client = new ApolloClient({\n uri: config.gqlEndpoint,\n cache: new InMemoryCache(),\n defaultOptions,\n credentials: 'include'\n });\n }\n\n async getUser () : Promise {\n const { data } = await this.client.query({\n query: queries.getUser\n });\n\n return data;\n }\n\n async getProject (projectId: string) : Promise {\n const { data } = await this.client.query({\n query: queries.getProject,\n variables: {\n projectId\n }\n });\n\n return data;\n }\n\n async getProjectsInOrganization (organizationSlug: string) : Promise {\n const { data } = await this.client.query({\n query: queries.getProjectsInOrganization,\n variables: {\n organizationSlug\n }\n });\n\n return data;\n }\n\n async getOrganizations () : Promise {\n const { data } = await this.client.query({\n query: queries.getOrganizations\n });\n\n return data;\n }\n\n async getDeployments (projectId: string) : Promise {\n const { data } = await this.client.query({\n query: queries.getDeployments,\n variables: {\n projectId\n }\n });\n\n return data;\n }\n\n async getEnvironmentVariables (projectId: string) : Promise {\n const { data } = await this.client.query({\n query: queries.getEnvironmentVariables,\n variables: {\n projectId\n }\n });\n\n return data;\n }\n\n async getProjectMembers (projectId: string) : Promise {\n const result = await this.client.query({\n query: queries.getProjectMembers,\n variables: {\n projectId\n }\n });\n\n return result.data;\n }\n\n async addProjectMember (projectId: string, data: types.AddProjectMemberInput) : Promise {\n const result = await this.client.mutate({\n mutation: mutations.addProjectMember,\n variables: {\n projectId,\n data\n }\n });\n\n return result.data;\n }\n\n async updateProjectMember (projectMemberId: string, data: types.UpdateProjectMemberInput): Promise {\n const result = await this.client.mutate({\n mutation: mutations.updateProjectMember,\n variables: {\n projectMemberId,\n data\n }\n });\n\n return result.data;\n }\n\n async removeProjectMember (projectMemberId: string): Promise {\n const result = await this.client.mutate({\n mutation: mutations.removeProjectMember,\n variables: {\n projectMemberId\n }\n });\n\n return result.data;\n }\n\n async searchProjects (searchText: string) : Promise {\n const { data } = await this.client.query({\n query: queries.searchProjects,\n variables: {\n searchText\n }\n });\n\n return data;\n }\n\n async addEnvironmentVariables (projectId: string, data: types.AddEnvironmentVariableInput[]): Promise {\n const result = await this.client.mutate({\n mutation: mutations.addEnvironmentVariables,\n variables: {\n projectId,\n data\n }\n });\n\n return result.data;\n }\n\n async updateEnvironmentVariable (environmentVariableId: string, data: types.UpdateEnvironmentVariableInput): Promise {\n const result = await this.client.mutate({\n mutation: mutations.updateEnvironmentVariable,\n variables: {\n environmentVariableId,\n data\n }\n });\n\n return result.data;\n }\n\n async removeEnvironmentVariable (environmentVariableId: string): Promise {\n const { data } = await this.client.mutate({\n mutation: mutations.removeEnvironmentVariable,\n variables: {\n environmentVariableId\n }\n });\n\n return data;\n }\n\n async updateDeploymentToProd (deploymentId: string): Promise {\n const { data } = await this.client.mutate({\n mutation: mutations.updateDeploymentToProd,\n variables: {\n deploymentId\n }\n });\n\n return data;\n }\n\n async addProject (organizationSlug: string, data: types.AddProjectInput): Promise {\n const result = await this.client.mutate({\n mutation: mutations.addProject,\n variables: {\n organizationSlug,\n data\n }\n });\n\n return result.data;\n }\n\n async updateProject (projectId: string, data: types.UpdateProjectInput): Promise {\n const result = await this.client.mutate({\n mutation: mutations.updateProjectMutation,\n variables: {\n projectId,\n data\n }\n });\n\n return result.data;\n }\n\n async updateDomain (domainId: string, data: types.UpdateDomainInput): Promise {\n const result = await this.client.mutate({\n mutation: mutations.updateDomainMutation,\n variables: {\n domainId,\n data\n }\n });\n\n return result.data;\n }\n\n async redeployToProd (deploymentId: string): Promise {\n const { data } = await this.client.mutate({\n mutation: mutations.redeployToProd,\n variables: {\n deploymentId\n }\n });\n\n return data;\n }\n\n async deleteProject (projectId: string): Promise {\n const { data } = await this.client.mutate({\n mutation: mutations.deleteProject,\n variables: {\n projectId\n }\n });\n\n return data;\n }\n\n async deleteDomain (domainId: string): Promise {\n const { data } = await this.client.mutate({\n mutation: mutations.deleteDomain,\n variables: {\n domainId\n }\n });\n\n return data;\n }\n\n async rollbackDeployment (projectId: string, deploymentId: string): Promise {\n const { data } = await this.client.mutate({\n mutation: mutations.rollbackDeployment,\n variables: {\n projectId,\n deploymentId\n }\n });\n\n return data;\n }\n\n async deleteDeployment (deploymentId: string): Promise {\n const { data } = await this.client.mutate({\n mutation: mutations.deleteDeployment,\n variables: {\n deploymentId\n }\n });\n\n return data;\n }\n\n async addDomain (projectId: string, data: types.AddDomainInput): Promise {\n const result = await this.client.mutate({\n mutation: mutations.addDomain,\n variables: {\n projectId,\n data\n }\n });\n\n return result.data;\n }\n\n async getDomains (projectId: string, filter?: types.FilterDomainInput): Promise {\n const { data } = await this.client.query({\n query: queries.getDomains,\n variables: {\n projectId,\n filter\n }\n });\n\n return data;\n }\n\n async authenticateGitHub (code: string): Promise {\n const { data } = await this.client.mutate({\n mutation: mutations.authenticateGitHub,\n variables: {\n code\n }\n });\n\n return data;\n }\n\n async unauthenticateGithub (): Promise {\n const { data } = await this.client.mutate({\n mutation: mutations.unauthenticateGitHub\n });\n\n return data;\n }\n}\n","import { gql } from '@apollo/client';\n\nexport const getUser = gql`\nquery {\n user {\n id\n name\n email\n createdAt\n updatedAt\n gitHubToken\n }\n}\n`;\n\nexport const getProject = gql`\nquery ($projectId: String!) {\n project(projectId: $projectId) {\n createdAt\n description\n id\n name\n template\n updatedAt\n prodBranch\n framework\n repository\n webhooks\n icon\n subDomain\n organization {\n id\n name\n }\n owner {\n id\n name\n email\n }\n deployments {\n id\n branch\n isCurrent\n status\n updatedAt\n commitHash\n createdAt\n environment\n domain {\n status\n branch\n createdAt\n updatedAt\n id\n name\n }\n createdBy {\n id\n name\n }\n }\n }\n}\n`;\n\nexport const getProjectsInOrganization = gql`\nquery ($organizationSlug: String!) {\n projectsInOrganization(organizationSlug: $organizationSlug) {\n id\n name\n createdAt\n description\n framework\n prodBranch\n webhooks\n repository\n updatedAt\n icon\n subDomain\n deployments {\n id\n branch\n isCurrent\n status\n updatedAt\n commitHash\n commitMessage\n createdAt\n environment\n domain {\n status\n branch\n createdAt\n updatedAt\n id\n name\n }\n }\n }\n}\n`;\n\nexport const getOrganizations = gql`\nquery {\n organizations {\n id\n name\n slug\n createdAt\n updatedAt\n }\n}\n`;\n\nexport const getDeployments = gql`\nquery ($projectId: String!) {\n deployments(projectId: $projectId) {\n id\n domain{\n branch\n createdAt\n id\n name\n status\n updatedAt\n }\n branch\n commitHash\n commitMessage\n url\n environment\n isCurrent\n status\n createdAt\n updatedAt\n createdBy {\n id\n name\n email\n }\n }\n}\n`;\n\nexport const getEnvironmentVariables = gql`\nquery ($projectId: String!) {\n environmentVariables(projectId: $projectId) {\n createdAt\n environment\n id\n key\n updatedAt\n value\n }\n}\n`;\n\nexport const getProjectMembers = gql`\nquery ($projectId: String!) {\n projectMembers(projectId: $projectId) {\n id\n member {\n id\n name\n email\n isVerified\n }\n isPending\n createdAt\n updatedAt\n permissions\n }\n}\n`;\n\nexport const searchProjects = gql`\nquery ($searchText: String!) {\n searchProjects(searchText: $searchText) {\n id\n name\n prodBranch\n repository\n createdAt\n description\n framework\n prodBranch\n webhooks\n updatedAt\n template\n repository\n organization {\n id\n name\n slug\n createdAt\n updatedAt\n }\n }\n}\n`;\n\nexport const getDomains = gql`\nquery ($projectId: String!, $filter: FilterDomainsInput) {\n domains(projectId: $projectId, filter: $filter) {\n branch\n createdAt\n redirectTo {\n id\n name\n branch\n status\n }\n id\n name\n status\n updatedAt\n }\n}\n`;\n","import { gql } from '@apollo/client';\n\nexport const removeProjectMember = gql`\nmutation ($projectMemberId: String!) {\n removeProjectMember(projectMemberId: $projectMemberId)\n}\n`;\n\nexport const updateProjectMember = gql`\nmutation ($projectMemberId: String!, $data: UpdateProjectMemberInput) {\n updateProjectMember(projectMemberId: $projectMemberId, data: $data)\n}\n`;\n\nexport const addProjectMember = gql`\nmutation ($projectId: String!, $data: AddProjectMemberInput) {\n addProjectMember(projectId: $projectId, data: $data)\n}\n`;\n\nexport const addEnvironmentVariables = gql`\nmutation ($projectId: String!, $data: [AddEnvironmentVariableInput!]) {\n addEnvironmentVariables(projectId: $projectId, data: $data)\n}\n`;\n\nexport const updateEnvironmentVariable = gql`\nmutation ($environmentVariableId: String!, $data: UpdateEnvironmentVariableInput!) {\n updateEnvironmentVariable(environmentVariableId: $environmentVariableId, data: $data)\n}\n`;\n\nexport const removeEnvironmentVariable = gql`\nmutation ($environmentVariableId: String!) {\n removeEnvironmentVariable(environmentVariableId: $environmentVariableId)\n}\n`;\n\nexport const updateDeploymentToProd = gql`\nmutation ($deploymentId: String!) {\n updateDeploymentToProd(deploymentId: $deploymentId)\n}\n`;\n\nexport const addProject = gql`\nmutation ($organizationSlug: String!, $data: AddProjectInput) {\n addProject(organizationSlug: $organizationSlug, data: $data) {\n id\n }\n}`;\n\nexport const updateProjectMutation = gql`\nmutation ($projectId: String!, $data: UpdateProjectInput) {\n updateProject(projectId: $projectId, data: $data)\n}`;\n\nexport const updateDomainMutation = gql`\nmutation ($domainId: String!, $data: UpdateDomainInput!) {\n updateDomain(domainId: $domainId, data: $data)\n}`;\n\nexport const redeployToProd = gql`\nmutation ($deploymentId: String!) {\n redeployToProd(deploymentId: $deploymentId)\n}\n`;\n\nexport const deleteProject = gql`\nmutation ($projectId: String!) {\n deleteProject(projectId: $projectId)\n}\n`;\n\nexport const deleteDomain = gql`\nmutation ($domainId: String!) {\n deleteDomain(domainId: $domainId)\n}`;\n\nexport const rollbackDeployment = gql`\nmutation ($projectId: String! ,$deploymentId: String!) {\n rollbackDeployment(projectId: $projectId, deploymentId: $deploymentId)\n}\n`;\n\nexport const deleteDeployment = gql`\nmutation ($deploymentId: String!) {\n deleteDeployment(deploymentId: $deploymentId)\n}\n`;\n\nexport const addDomain = gql`\nmutation ($projectId: String!, $data: AddDomainInput!) {\n addDomain(projectId: $projectId, data: $data)\n}\n`;\n\nexport const authenticateGitHub = gql`\nmutation ($code: String!) {\n authenticateGitHub(code: $code) {\n token\n }\n}`;\n\nexport const unauthenticateGitHub = gql`\nmutation {\n unauthenticateGitHub\n}`;\n","// Note: equivalent to types present in GQL schema\n\nexport enum Role {\n Owner = 'Owner',\n Maintainer = 'Maintainer',\n Reader = 'Reader',\n}\n\nexport enum Permission {\n View = 'View',\n Edit = 'Edit',\n}\n\nexport enum Environment {\n Production = 'Production',\n Preview = 'Preview',\n Development = 'Development',\n}\n\nexport enum DeploymentStatus {\n Building = 'Building',\n Ready = 'Ready',\n Error = 'Error',\n Deleting = 'Deleting'\n}\n\nexport enum DomainStatus {\n Live = 'Live',\n Pending = 'Pending',\n}\n\nexport type EnvironmentVariable = {\n id: string\n environment: Environment\n key: string\n value: string\n createdAt: string\n updatedAt: string\n}\n\nexport type Domain = {\n id: string\n branch: string\n name: string\n status: DomainStatus\n redirectTo: Domain | null\n createdAt: string\n updatedAt: string\n}\n\nexport type User = {\n id: string\n name: string | null\n email: string\n isVerified: boolean\n createdAt: string\n updatedAt: string\n gitHubToken: string | null\n}\n\nexport type Deployment = {\n id: string\n domain: Domain\n branch: string\n commitHash: string\n commitMessage: string\n url?: string\n environment: Environment\n isCurrent: boolean\n status: DeploymentStatus\n createdBy: User\n createdAt: string\n updatedAt: string\n}\n\nexport type OrganizationMember = {\n id: string\n member: User\n role: Role\n createdAt: string\n updatedAt: string\n}\n\nexport type ProjectMember = {\n id: string\n member: User\n permissions: Permission[]\n isPending: boolean\n createdAt: string\n updatedAt: string\n}\n\nexport type OrganizationProject = {\n id: string\n owner: User\n deployments: Deployment[]\n name: string\n repository: string\n prodBranch: string\n description: string\n template: string\n framework: string\n webhooks: string[]\n members: ProjectMember[]\n environmentVariables: EnvironmentVariable[]\n createdAt: string\n updatedAt: string\n}\n\nexport type Organization = {\n id: string\n name: string\n slug: string\n projects: OrganizationProject[]\n createdAt: string\n updatedAt: string\n members: OrganizationMember[]\n}\n\nexport type Project = {\n id: string\n owner: User\n deployments: Deployment[]\n name: string\n repository: string\n prodBranch: string\n description: string\n template: string\n framework: string\n webhooks: string[]\n members: ProjectMember[]\n environmentVariables: EnvironmentVariable[]\n createdAt: string\n updatedAt: string\n organization: Organization\n icon: string\n subDomain: string\n}\n\nexport type GetProjectMembersResponse = {\n projectMembers: ProjectMember[]\n}\n\nexport type AddProjectMemberResponse = {\n addProjectMember: boolean\n}\n\nexport type RemoveProjectMemberResponse = {\n removeProjectMember: boolean;\n}\n\nexport type UpdateProjectMemberResponse = {\n updateProjectMember: boolean;\n}\n\nexport type GetDeploymentsResponse = {\n deployments: Deployment[]\n}\n\nexport type GetEnvironmentVariablesResponse = {\n environmentVariables: EnvironmentVariable[]\n}\n\nexport type GetOrganizationsResponse = {\n organizations: Organization[]\n}\n\nexport type GetUserResponse = {\n user: User\n}\n\nexport type GetProjectResponse = {\n project: Project | null\n}\n\nexport type GetProjectsInOrganizationResponse = {\n projectsInOrganization: Project[]\n}\n\nexport type GetDomainsResponse = {\n domains: Domain[]\n}\n\nexport type SearchProjectsResponse = {\n searchProjects: Project[]\n}\n\nexport type AddEnvironmentVariablesResponse = {\n addEnvironmentVariables: boolean;\n}\n\nexport type AddEnvironmentVariableInput = {\n environments: string[];\n key: string;\n value: string;\n}\n\nexport type UpdateEnvironmentVariableInput = {\n key: string;\n value: string;\n}\n\nexport type UpdateProjectMemberInput = {\n permissions: Permission[];\n}\n\nexport type AddProjectMemberInput = {\n email: string;\n permissions: Permission[]\n}\n\nexport type UpdateEnvironmentVariableResponse = {\n updateEnvironmentVariable: boolean;\n}\n\nexport type RemoveEnvironmentVariableResponse = {\n removeEnvironmentVariable: boolean;\n}\n\nexport type UpdateDeploymentToProdResponse = {\n updateDeploymentToProd: boolean;\n}\n\nexport type AddProjectResponse = {\n addProject: Project\n}\n\nexport type UpdateProjectResponse = {\n updateProject: boolean;\n}\n\nexport type UpdateDomainResponse = {\n updateDomain: boolean;\n}\n\nexport type DeleteProjectResponse = {\n deleteProject: boolean;\n}\n\nexport type DeleteDomainResponse = {\n deleteDomain: boolean;\n}\n\nexport type AddProjectInput = {\n name: string;\n repository: string;\n prodBranch: string;\n template?: string;\n}\n\nexport type UpdateProjectInput = {\n name?: string\n description?: string\n prodBranch?: string\n webhooks?: string[]\n organizationId?: string\n}\n\nexport type UpdateDomainInput = {\n name?: string;\n branch?: string;\n redirectToId?: string | null;\n}\n\nexport type RedeployToProdResponse = {\n redeployToProd: boolean\n}\n\nexport type RollbackDeploymentResponse = {\n rollbackDeployment: boolean\n}\n\nexport type DeleteDeploymentResponse = {\n deleteDeployment: boolean\n}\n\nexport type AddDomainInput = {\n name: string\n}\n\nexport type FilterDomainInput = {\n branch?: string\n status?: DomainStatus\n}\n\nexport type AddDomainResponse = {\n addDomain: true\n}\n\nexport type AuthenticateGitHubResponse = {\n authenticateGitHub: {\n token: string\n }\n}\n\nexport type UnauthenticateGitHubResponse = {\n unauthenticateGitHub: boolean\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,iBAAmF;;;ACAnF,oBAAoB;AAEb,IAAM,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAahB,IAAM,aAAa;AAAA;AAAA;AAAA;AAAA;AA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,MACF,CAAC;AAED,aAAO;AAAA,IACT;AAAA;AAAA,EAEM,uBAAqE;AAAA;AACzE,YAAM,EAAE,KAAK,IAAI,MAAM,KAAK,OAAO,OAAO;AAAA,QACxC,UAAoB;AAAA,MACtB,CAAC;AAED,aAAO;AAAA,IACT;AAAA;AACF;;;AGzUO,IAAK,OAAL,kBAAKC,UAAL;AACL,EAAAA,MAAA,WAAQ;AACR,EAAAA,MAAA,gBAAa;AACb,EAAAA,MAAA,YAAS;AAHC,SAAAA;AAAA,GAAA;AAML,IAAK,aAAL,kBAAKC,gBAAL;AACL,EAAAA,YAAA,UAAO;AACP,EAAAA,YAAA,UAAO;AAFG,SAAAA;AAAA,GAAA;AAKL,IAAK,cAAL,kBAAKC,iBAAL;AACL,EAAAA,aAAA,gBAAa;AACb,EAAAA,aAAA,aAAU;AACV,EAAAA,aAAA,iBAAc;AAHJ,SAAAA;AAAA,GAAA;AAML,IAAK,mBAAL,kBAAKC,sBAAL;AACL,EAAAA,kBAAA,cAAW;AACX,EAAAA,kBAAA,WAAQ;AACR,EAAAA,kBAAA,WAAQ;AACR,EAAAA,kBAAA,cAAW;AAJD,SAAAA;AAAA,GAAA;AAOL,IAAK,eAAL,kBAAKC,kBAAL;AACL,EAAAA,cAAA,UAAO;AACP,EAAAA,cAAA,aAAU;AAFA,SAAAA;AAAA,GAAA;","names":["import_client","import_client","Role","Permission","Environment","DeploymentStatus","DomainStatus"]} \ No newline at end of file +{"version":3,"sources":["../src/index.ts","../src/client.ts","../src/queries.ts","../src/mutations.ts","../src/types.ts"],"sourcesContent":["export * from \"./client\";\nexport * from \"./types\";\n","import {\n ApolloClient,\n DefaultOptions,\n InMemoryCache,\n NormalizedCacheObject,\n} from \"@apollo/client\";\n\nimport * as queries from \"./queries\";\nimport * as types from \"./types\";\nimport * as mutations from \"./mutations\";\n\nexport interface GraphQLConfig {\n gqlEndpoint: string;\n}\n\n// TODO: check options\nconst defaultOptions: DefaultOptions = {\n watchQuery: {\n fetchPolicy: \"no-cache\",\n errorPolicy: \"ignore\",\n },\n query: {\n fetchPolicy: \"no-cache\",\n errorPolicy: \"all\",\n },\n};\n\nexport class GQLClient {\n private client: ApolloClient;\n\n constructor(config: GraphQLConfig) {\n this.client = new ApolloClient({\n uri: config.gqlEndpoint,\n cache: new InMemoryCache(),\n defaultOptions,\n credentials: \"include\",\n });\n }\n\n async getUser(): Promise {\n const { data } = await this.client.query({\n query: queries.getUser,\n });\n\n return data;\n }\n\n async getProject(projectId: string): Promise {\n const { data } = await this.client.query({\n query: queries.getProject,\n variables: {\n projectId,\n },\n });\n\n return data;\n }\n\n async getProjectsInOrganization(\n organizationSlug: string\n ): Promise {\n const { data } = await this.client.query({\n query: queries.getProjectsInOrganization,\n variables: {\n organizationSlug,\n },\n });\n\n return data;\n }\n\n async getOrganizations(): Promise {\n const { data } = await this.client.query({\n query: queries.getOrganizations,\n });\n\n return data;\n }\n\n async getDeployments(\n projectId: string\n ): Promise {\n const { data } = await this.client.query({\n query: queries.getDeployments,\n variables: {\n projectId,\n },\n });\n\n return data;\n }\n\n async getEnvironmentVariables(\n projectId: string\n ): Promise {\n const { data } = await this.client.query({\n query: queries.getEnvironmentVariables,\n variables: {\n projectId,\n },\n });\n\n return data;\n }\n\n async getProjectMembers(\n projectId: string\n ): Promise {\n const result = await this.client.query({\n query: queries.getProjectMembers,\n variables: {\n projectId,\n },\n });\n\n return result.data;\n }\n\n async addProjectMember(\n projectId: string,\n data: types.AddProjectMemberInput\n ): Promise {\n const result = await this.client.mutate({\n mutation: mutations.addProjectMember,\n variables: {\n projectId,\n data,\n },\n });\n\n return result.data;\n }\n\n async updateProjectMember(\n projectMemberId: string,\n data: types.UpdateProjectMemberInput\n ): Promise {\n const result = await this.client.mutate({\n mutation: mutations.updateProjectMember,\n variables: {\n projectMemberId,\n data,\n },\n });\n\n return result.data;\n }\n\n async removeProjectMember(\n projectMemberId: string\n ): Promise {\n const result = await this.client.mutate({\n mutation: mutations.removeProjectMember,\n variables: {\n projectMemberId,\n },\n });\n\n return result.data;\n }\n\n async searchProjects(\n searchText: string\n ): Promise {\n const { data } = await this.client.query({\n query: queries.searchProjects,\n variables: {\n searchText,\n },\n });\n\n return data;\n }\n\n async addEnvironmentVariables(\n projectId: string,\n data: types.AddEnvironmentVariableInput[]\n ): Promise {\n const result = await this.client.mutate({\n mutation: mutations.addEnvironmentVariables,\n variables: {\n projectId,\n data,\n },\n });\n\n return result.data;\n }\n\n async updateEnvironmentVariable(\n environmentVariableId: string,\n data: types.UpdateEnvironmentVariableInput\n ): Promise {\n const result = await this.client.mutate({\n mutation: mutations.updateEnvironmentVariable,\n variables: {\n environmentVariableId,\n data,\n },\n });\n\n return result.data;\n }\n\n async removeEnvironmentVariable(\n environmentVariableId: string\n ): Promise {\n const { data } = await this.client.mutate({\n mutation: mutations.removeEnvironmentVariable,\n variables: {\n environmentVariableId,\n },\n });\n\n return data;\n }\n\n async updateDeploymentToProd(\n deploymentId: string\n ): Promise {\n const { data } = await this.client.mutate({\n mutation: mutations.updateDeploymentToProd,\n variables: {\n deploymentId,\n },\n });\n\n return data;\n }\n\n async addProject(\n organizationSlug: string,\n data: types.AddProjectInput\n ): Promise {\n const result = await this.client.mutate({\n mutation: mutations.addProject,\n variables: {\n organizationSlug,\n data,\n },\n });\n\n return result.data;\n }\n\n async updateProject(\n projectId: string,\n data: types.UpdateProjectInput\n ): Promise {\n const result = await this.client.mutate({\n mutation: mutations.updateProjectMutation,\n variables: {\n projectId,\n data,\n },\n });\n\n return result.data;\n }\n\n async updateDomain(\n domainId: string,\n data: types.UpdateDomainInput\n ): Promise {\n const result = await this.client.mutate({\n mutation: mutations.updateDomainMutation,\n variables: {\n domainId,\n data,\n },\n });\n\n return result.data;\n }\n\n async redeployToProd(\n deploymentId: string\n ): Promise {\n const { data } = await this.client.mutate({\n mutation: mutations.redeployToProd,\n variables: {\n deploymentId,\n },\n });\n\n return data;\n }\n\n async deleteProject(projectId: string): Promise {\n const { data } = await this.client.mutate({\n mutation: mutations.deleteProject,\n variables: {\n projectId,\n },\n });\n\n return data;\n }\n\n async deleteDomain(domainId: string): Promise {\n const { data } = await this.client.mutate({\n mutation: mutations.deleteDomain,\n variables: {\n domainId,\n },\n });\n\n return data;\n }\n\n async rollbackDeployment(\n projectId: string,\n deploymentId: string\n ): Promise {\n const { data } = await this.client.mutate({\n mutation: mutations.rollbackDeployment,\n variables: {\n projectId,\n deploymentId,\n },\n });\n\n return data;\n }\n\n async deleteDeployment(\n deploymentId: string\n ): Promise {\n const { data } = await this.client.mutate({\n mutation: mutations.deleteDeployment,\n variables: {\n deploymentId,\n },\n });\n\n return data;\n }\n\n async addDomain(\n projectId: string,\n data: types.AddDomainInput\n ): Promise {\n const result = await this.client.mutate({\n mutation: mutations.addDomain,\n variables: {\n projectId,\n data,\n },\n });\n\n return result.data;\n }\n\n async getDomains(\n projectId: string,\n filter?: types.FilterDomainInput\n ): Promise {\n const { data } = await this.client.query({\n query: queries.getDomains,\n variables: {\n projectId,\n filter,\n },\n });\n\n return data;\n }\n\n async authenticateGitHub(\n code: string\n ): Promise {\n const { data } = await this.client.mutate({\n mutation: mutations.authenticateGitHub,\n variables: {\n code,\n },\n });\n\n return data;\n }\n\n async unauthenticateGithub(): Promise {\n const { data } = await this.client.mutate({\n mutation: mutations.unauthenticateGitHub,\n });\n\n return data;\n }\n}\n","import { gql } from '@apollo/client';\n\nexport const getUser = gql`\nquery {\n user {\n id\n name\n email\n createdAt\n updatedAt\n gitHubToken\n }\n}\n`;\n\nexport const getProject = gql`\nquery ($projectId: String!) {\n project(projectId: $projectId) {\n createdAt\n description\n id\n name\n template\n updatedAt\n prodBranch\n framework\n repository\n webhooks\n icon\n subDomain\n organization {\n id\n name\n }\n owner {\n id\n name\n email\n }\n deployments {\n id\n branch\n isCurrent\n status\n updatedAt\n commitHash\n createdAt\n environment\n domain {\n status\n branch\n createdAt\n updatedAt\n id\n name\n }\n createdBy {\n id\n name\n }\n }\n }\n}\n`;\n\nexport const getProjectsInOrganization = gql`\nquery ($organizationSlug: String!) {\n projectsInOrganization(organizationSlug: $organizationSlug) {\n id\n name\n createdAt\n description\n framework\n prodBranch\n webhooks\n repository\n updatedAt\n icon\n subDomain\n deployments {\n id\n branch\n isCurrent\n status\n updatedAt\n commitHash\n commitMessage\n createdAt\n environment\n domain {\n status\n branch\n createdAt\n updatedAt\n id\n name\n }\n }\n }\n}\n`;\n\nexport const getOrganizations = gql`\nquery {\n organizations {\n id\n name\n slug\n createdAt\n updatedAt\n }\n}\n`;\n\nexport const getDeployments = gql`\nquery ($projectId: String!) {\n deployments(projectId: $projectId) {\n id\n domain{\n branch\n createdAt\n id\n name\n status\n updatedAt\n }\n branch\n commitHash\n commitMessage\n url\n environment\n isCurrent\n status\n createdAt\n updatedAt\n createdBy {\n id\n name\n email\n }\n }\n}\n`;\n\nexport const getEnvironmentVariables = gql`\nquery ($projectId: String!) {\n environmentVariables(projectId: $projectId) {\n createdAt\n environment\n id\n key\n updatedAt\n value\n }\n}\n`;\n\nexport const getProjectMembers = gql`\nquery ($projectId: String!) {\n projectMembers(projectId: $projectId) {\n id\n member {\n id\n name\n email\n isVerified\n }\n isPending\n createdAt\n updatedAt\n permissions\n }\n}\n`;\n\nexport const searchProjects = gql`\nquery ($searchText: String!) {\n searchProjects(searchText: $searchText) {\n id\n name\n prodBranch\n repository\n createdAt\n description\n framework\n prodBranch\n webhooks\n updatedAt\n template\n repository\n organization {\n id\n name\n slug\n createdAt\n updatedAt\n }\n }\n}\n`;\n\nexport const getDomains = gql`\nquery ($projectId: String!, $filter: FilterDomainsInput) {\n domains(projectId: $projectId, filter: $filter) {\n branch\n createdAt\n redirectTo {\n id\n name\n branch\n status\n }\n id\n name\n status\n updatedAt\n }\n}\n`;\n","import { gql } from '@apollo/client';\n\nexport const removeProjectMember = gql`\nmutation ($projectMemberId: String!) {\n removeProjectMember(projectMemberId: $projectMemberId)\n}\n`;\n\nexport const updateProjectMember = gql`\nmutation ($projectMemberId: String!, $data: UpdateProjectMemberInput) {\n updateProjectMember(projectMemberId: $projectMemberId, data: $data)\n}\n`;\n\nexport const addProjectMember = gql`\nmutation ($projectId: String!, $data: AddProjectMemberInput) {\n addProjectMember(projectId: $projectId, data: $data)\n}\n`;\n\nexport const addEnvironmentVariables = gql`\nmutation ($projectId: String!, $data: [AddEnvironmentVariableInput!]) {\n addEnvironmentVariables(projectId: $projectId, data: $data)\n}\n`;\n\nexport const updateEnvironmentVariable = gql`\nmutation ($environmentVariableId: String!, $data: UpdateEnvironmentVariableInput!) {\n updateEnvironmentVariable(environmentVariableId: $environmentVariableId, data: $data)\n}\n`;\n\nexport const removeEnvironmentVariable = gql`\nmutation ($environmentVariableId: String!) {\n removeEnvironmentVariable(environmentVariableId: $environmentVariableId)\n}\n`;\n\nexport const updateDeploymentToProd = gql`\nmutation ($deploymentId: String!) {\n updateDeploymentToProd(deploymentId: $deploymentId)\n}\n`;\n\nexport const addProject = gql`\nmutation ($organizationSlug: String!, $data: AddProjectInput) {\n addProject(organizationSlug: $organizationSlug, data: $data) {\n id\n }\n}`;\n\nexport const updateProjectMutation = gql`\nmutation ($projectId: String!, $data: UpdateProjectInput) {\n updateProject(projectId: $projectId, data: $data)\n}`;\n\nexport const updateDomainMutation = gql`\nmutation ($domainId: String!, $data: UpdateDomainInput!) {\n updateDomain(domainId: $domainId, data: $data)\n}`;\n\nexport const redeployToProd = gql`\nmutation ($deploymentId: String!) {\n redeployToProd(deploymentId: $deploymentId)\n}\n`;\n\nexport const deleteProject = gql`\nmutation ($projectId: String!) {\n deleteProject(projectId: $projectId)\n}\n`;\n\nexport const deleteDomain = gql`\nmutation ($domainId: String!) {\n deleteDomain(domainId: $domainId)\n}`;\n\nexport const rollbackDeployment = gql`\nmutation ($projectId: String! ,$deploymentId: String!) {\n rollbackDeployment(projectId: $projectId, deploymentId: $deploymentId)\n}\n`;\n\nexport const deleteDeployment = gql`\nmutation ($deploymentId: String!) {\n deleteDeployment(deploymentId: $deploymentId)\n}\n`;\n\nexport const addDomain = gql`\nmutation ($projectId: String!, $data: AddDomainInput!) {\n addDomain(projectId: $projectId, data: $data)\n}\n`;\n\nexport const authenticateGitHub = gql`\nmutation ($code: String!) {\n authenticateGitHub(code: $code) {\n token\n }\n}`;\n\nexport const unauthenticateGitHub = gql`\nmutation {\n unauthenticateGitHub\n}`;\n","// Note: equivalent to types present in GQL schema\n\nexport enum Role {\n Owner = 'Owner',\n Maintainer = 'Maintainer',\n Reader = 'Reader',\n}\n\nexport enum Permission {\n View = 'View',\n Edit = 'Edit',\n}\n\nexport enum Environment {\n Production = 'Production',\n Preview = 'Preview',\n Development = 'Development',\n}\n\nexport enum DeploymentStatus {\n Building = 'Building',\n Ready = 'Ready',\n Error = 'Error',\n Deleting = 'Deleting'\n}\n\nexport enum DomainStatus {\n Live = 'Live',\n Pending = 'Pending',\n}\n\nexport type EnvironmentVariable = {\n id: string\n environment: Environment\n key: string\n value: string\n createdAt: string\n updatedAt: string\n}\n\nexport type Domain = {\n id: string\n branch: string\n name: string\n status: DomainStatus\n redirectTo: Domain | null\n createdAt: string\n updatedAt: string\n}\n\nexport type User = {\n id: string\n name: string | null\n email: string\n isVerified: boolean\n createdAt: string\n updatedAt: string\n gitHubToken: string | null\n}\n\nexport type Deployment = {\n id: string\n domain: Domain\n branch: string\n commitHash: string\n commitMessage: string\n url?: string\n environment: Environment\n isCurrent: boolean\n status: DeploymentStatus\n createdBy: User\n createdAt: string\n updatedAt: string\n}\n\nexport type OrganizationMember = {\n id: string\n member: User\n role: Role\n createdAt: string\n updatedAt: string\n}\n\nexport type ProjectMember = {\n id: string\n member: User\n permissions: Permission[]\n isPending: boolean\n createdAt: string\n updatedAt: string\n}\n\nexport type OrganizationProject = {\n id: string\n owner: User\n deployments: Deployment[]\n name: string\n repository: string\n prodBranch: string\n description: string\n template: string\n framework: string\n webhooks: string[]\n members: ProjectMember[]\n environmentVariables: EnvironmentVariable[]\n createdAt: string\n updatedAt: string\n}\n\nexport type Organization = {\n id: string\n name: string\n slug: string\n projects: OrganizationProject[]\n createdAt: string\n updatedAt: string\n members: OrganizationMember[]\n}\n\nexport type Project = {\n id: string\n owner: User\n deployments: Deployment[]\n name: string\n repository: string\n prodBranch: string\n description: string\n template: string\n framework: string\n webhooks: string[]\n members: ProjectMember[]\n environmentVariables: EnvironmentVariable[]\n createdAt: string\n updatedAt: string\n organization: Organization\n icon: string\n subDomain: string\n}\n\nexport type GetProjectMembersResponse = {\n projectMembers: ProjectMember[]\n}\n\nexport type AddProjectMemberResponse = {\n addProjectMember: boolean\n}\n\nexport type RemoveProjectMemberResponse = {\n removeProjectMember: boolean;\n}\n\nexport type UpdateProjectMemberResponse = {\n updateProjectMember: boolean;\n}\n\nexport type GetDeploymentsResponse = {\n deployments: Deployment[]\n}\n\nexport type GetEnvironmentVariablesResponse = {\n environmentVariables: EnvironmentVariable[]\n}\n\nexport type GetOrganizationsResponse = {\n organizations: Organization[]\n}\n\nexport type GetUserResponse = {\n user: User\n}\n\nexport type GetProjectResponse = {\n project: Project | null\n}\n\nexport type GetProjectsInOrganizationResponse = {\n projectsInOrganization: Project[]\n}\n\nexport type GetDomainsResponse = {\n domains: Domain[]\n}\n\nexport type SearchProjectsResponse = {\n searchProjects: Project[]\n}\n\nexport type AddEnvironmentVariablesResponse = {\n addEnvironmentVariables: boolean;\n}\n\nexport type AddEnvironmentVariableInput = {\n environments: string[];\n key: string;\n value: string;\n}\n\nexport type UpdateEnvironmentVariableInput = {\n key: string;\n value: string;\n}\n\nexport type UpdateProjectMemberInput = {\n permissions: Permission[];\n}\n\nexport type AddProjectMemberInput = {\n email: string;\n permissions: Permission[]\n}\n\nexport type UpdateEnvironmentVariableResponse = {\n updateEnvironmentVariable: boolean;\n}\n\nexport type RemoveEnvironmentVariableResponse = {\n removeEnvironmentVariable: boolean;\n}\n\nexport type UpdateDeploymentToProdResponse = {\n updateDeploymentToProd: boolean;\n}\n\nexport type AddProjectResponse = {\n addProject: Project\n}\n\nexport type UpdateProjectResponse = {\n updateProject: boolean;\n}\n\nexport type UpdateDomainResponse = {\n updateDomain: boolean;\n}\n\nexport type DeleteProjectResponse = {\n deleteProject: boolean;\n}\n\nexport type DeleteDomainResponse = {\n deleteDomain: boolean;\n}\n\nexport type AddProjectInput = {\n name: string;\n repository: string;\n prodBranch: string;\n template?: string;\n}\n\nexport type UpdateProjectInput = {\n name?: string\n description?: string\n prodBranch?: string\n webhooks?: string[]\n organizationId?: string\n}\n\nexport type UpdateDomainInput = {\n name?: string;\n branch?: string;\n redirectToId?: string | null;\n}\n\nexport type RedeployToProdResponse = {\n redeployToProd: boolean\n}\n\nexport type RollbackDeploymentResponse = {\n rollbackDeployment: boolean\n}\n\nexport type DeleteDeploymentResponse = {\n deleteDeployment: boolean\n}\n\nexport type AddDomainInput = {\n name: string\n}\n\nexport type FilterDomainInput = {\n branch?: string\n status?: DomainStatus\n}\n\nexport type AddDomainResponse = {\n addDomain: true\n}\n\nexport type AuthenticateGitHubResponse = {\n authenticateGitHub: {\n token: string\n }\n}\n\nexport type UnauthenticateGitHubResponse = {\n unauthenticateGitHub: boolean\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,iBAKO;;;ACLP,oBAAoB;AAEb,IAAM,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAahB,IAAM,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkDnB,IAAM,4BAA4B;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KC,gBAAL;AACL,EAAAA,YAAA,UAAO;AACP,EAAAA,YAAA,UAAO;AAFG,SAAAA;AAAA,GAAA;AAKL,IAAK,cAAL,kBAAKC,iBAAL;AACL,EAAAA,aAAA,gBAAa;AACb,EAAAA,aAAA,aAAU;AACV,EAAAA,aAAA,iBAAc;AAHJ,SAAAA;AAAA,GAAA;AAML,IAAK,mBAAL,kBAAKC,sBAAL;AACL,EAAAA,kBAAA,cAAW;AACX,EAAAA,kBAAA,WAAQ;AACR,EAAAA,kBAAA,WAAQ;AACR,EAAAA,kBAAA,cAAW;AAJD,SAAAA;AAAA,GAAA;AAOL,IAAK,eAAL,kBAAKC,kBAAL;AACL,EAAAA,cAAA,UAAO;AACP,EAAAA,cAAA,aAAU;AAFA,SAAAA;AAAA,GAAA;","names":["import_client","import_client","Role","Permission","Environment","DeploymentStatus","DomainStatus"]} \ No newline at end of file diff --git a/packages/gql-client/dist/index.mjs b/packages/gql-client/dist/index.mjs index 766ad320..acae66b7 100644 --- a/packages/gql-client/dist/index.mjs +++ b/packages/gql-client/dist/index.mjs @@ -20,7 +20,10 @@ var __async = (__this, __arguments, generator) => { }; // src/client.ts -import { ApolloClient, InMemoryCache } from "@apollo/client"; +import { + ApolloClient, + InMemoryCache +} from "@apollo/client"; // src/queries.ts import { gql } from "@apollo/client"; diff --git a/packages/gql-client/dist/index.mjs.map b/packages/gql-client/dist/index.mjs.map index ae7b2e7d..edba632f 100644 --- a/packages/gql-client/dist/index.mjs.map +++ b/packages/gql-client/dist/index.mjs.map @@ -1 +1 @@ -{"version":3,"sources":["../src/client.ts","../src/queries.ts","../src/mutations.ts","../src/types.ts"],"sourcesContent":["import { ApolloClient, DefaultOptions, InMemoryCache, NormalizedCacheObject } from '@apollo/client';\n\nimport * as queries from './queries';\nimport * as types from './types';\nimport * as mutations from './mutations';\n\nexport interface GraphQLConfig {\n gqlEndpoint: string;\n}\n\n// TODO: check options\nconst defaultOptions: DefaultOptions = {\n watchQuery: {\n fetchPolicy: 'no-cache',\n errorPolicy: 'ignore'\n },\n query: {\n fetchPolicy: 'no-cache',\n errorPolicy: 'all'\n }\n};\n\nexport class GQLClient {\n private client: ApolloClient;\n\n constructor (config: GraphQLConfig) {\n this.client = new ApolloClient({\n uri: config.gqlEndpoint,\n cache: new InMemoryCache(),\n defaultOptions,\n credentials: 'include'\n });\n }\n\n async getUser () : Promise {\n const { data } = await this.client.query({\n query: queries.getUser\n });\n\n return data;\n }\n\n async getProject (projectId: string) : Promise {\n const { data } = await this.client.query({\n query: queries.getProject,\n variables: {\n projectId\n }\n });\n\n return data;\n }\n\n async getProjectsInOrganization (organizationSlug: string) : Promise {\n const { data } = await this.client.query({\n query: queries.getProjectsInOrganization,\n variables: {\n organizationSlug\n }\n });\n\n return data;\n }\n\n async getOrganizations () : Promise {\n const { data } = await this.client.query({\n query: queries.getOrganizations\n });\n\n return data;\n }\n\n async getDeployments (projectId: string) : Promise {\n const { data } = await this.client.query({\n query: queries.getDeployments,\n variables: {\n projectId\n }\n });\n\n return data;\n }\n\n async getEnvironmentVariables (projectId: string) : Promise {\n const { data } = await this.client.query({\n query: queries.getEnvironmentVariables,\n variables: {\n projectId\n }\n });\n\n return data;\n }\n\n async getProjectMembers (projectId: string) : Promise {\n const result = await this.client.query({\n query: queries.getProjectMembers,\n variables: {\n projectId\n }\n });\n\n return result.data;\n }\n\n async addProjectMember (projectId: string, data: types.AddProjectMemberInput) : Promise {\n const result = await this.client.mutate({\n mutation: mutations.addProjectMember,\n variables: {\n projectId,\n data\n }\n });\n\n return result.data;\n }\n\n async updateProjectMember (projectMemberId: string, data: types.UpdateProjectMemberInput): Promise {\n const result = await this.client.mutate({\n mutation: mutations.updateProjectMember,\n variables: {\n projectMemberId,\n data\n }\n });\n\n return result.data;\n }\n\n async removeProjectMember (projectMemberId: string): Promise {\n const result = await this.client.mutate({\n mutation: mutations.removeProjectMember,\n variables: {\n projectMemberId\n }\n });\n\n return result.data;\n }\n\n async searchProjects (searchText: string) : Promise {\n const { data } = await this.client.query({\n query: queries.searchProjects,\n variables: {\n searchText\n }\n });\n\n return data;\n }\n\n async addEnvironmentVariables (projectId: string, data: types.AddEnvironmentVariableInput[]): Promise {\n const result = await this.client.mutate({\n mutation: mutations.addEnvironmentVariables,\n variables: {\n projectId,\n data\n }\n });\n\n return result.data;\n }\n\n async updateEnvironmentVariable (environmentVariableId: string, data: types.UpdateEnvironmentVariableInput): Promise {\n const result = await this.client.mutate({\n mutation: mutations.updateEnvironmentVariable,\n variables: {\n environmentVariableId,\n data\n }\n });\n\n return result.data;\n }\n\n async removeEnvironmentVariable (environmentVariableId: string): Promise {\n const { data } = await this.client.mutate({\n mutation: mutations.removeEnvironmentVariable,\n variables: {\n environmentVariableId\n }\n });\n\n return data;\n }\n\n async updateDeploymentToProd (deploymentId: string): Promise {\n const { data } = await this.client.mutate({\n mutation: mutations.updateDeploymentToProd,\n variables: {\n deploymentId\n }\n });\n\n return data;\n }\n\n async addProject (organizationSlug: string, data: types.AddProjectInput): Promise {\n const result = await this.client.mutate({\n mutation: mutations.addProject,\n variables: {\n organizationSlug,\n data\n }\n });\n\n return result.data;\n }\n\n async updateProject (projectId: string, data: types.UpdateProjectInput): Promise {\n const result = await this.client.mutate({\n mutation: mutations.updateProjectMutation,\n variables: {\n projectId,\n data\n }\n });\n\n return result.data;\n }\n\n async updateDomain (domainId: string, data: types.UpdateDomainInput): Promise {\n const result = await this.client.mutate({\n mutation: mutations.updateDomainMutation,\n variables: {\n domainId,\n data\n }\n });\n\n return result.data;\n }\n\n async redeployToProd (deploymentId: string): Promise {\n const { data } = await this.client.mutate({\n mutation: mutations.redeployToProd,\n variables: {\n deploymentId\n }\n });\n\n return data;\n }\n\n async deleteProject (projectId: string): Promise {\n const { data } = await this.client.mutate({\n mutation: mutations.deleteProject,\n variables: {\n projectId\n }\n });\n\n return data;\n }\n\n async deleteDomain (domainId: string): Promise {\n const { data } = await this.client.mutate({\n mutation: mutations.deleteDomain,\n variables: {\n domainId\n }\n });\n\n return data;\n }\n\n async rollbackDeployment (projectId: string, deploymentId: string): Promise {\n const { data } = await this.client.mutate({\n mutation: mutations.rollbackDeployment,\n variables: {\n projectId,\n deploymentId\n }\n });\n\n return data;\n }\n\n async deleteDeployment (deploymentId: string): Promise {\n const { data } = await this.client.mutate({\n mutation: mutations.deleteDeployment,\n variables: {\n deploymentId\n }\n });\n\n return data;\n }\n\n async addDomain (projectId: string, data: types.AddDomainInput): Promise {\n const result = await this.client.mutate({\n mutation: mutations.addDomain,\n variables: {\n projectId,\n data\n }\n });\n\n return result.data;\n }\n\n async getDomains (projectId: string, filter?: types.FilterDomainInput): Promise {\n const { data } = await this.client.query({\n query: queries.getDomains,\n variables: {\n projectId,\n filter\n }\n });\n\n return data;\n }\n\n async authenticateGitHub (code: string): Promise {\n const { data } = await this.client.mutate({\n mutation: mutations.authenticateGitHub,\n variables: {\n code\n }\n });\n\n return data;\n }\n\n async unauthenticateGithub (): Promise {\n const { data } = await this.client.mutate({\n mutation: mutations.unauthenticateGitHub\n });\n\n return data;\n }\n}\n","import { gql } from '@apollo/client';\n\nexport const getUser = gql`\nquery {\n user {\n id\n name\n email\n createdAt\n updatedAt\n gitHubToken\n }\n}\n`;\n\nexport const getProject = gql`\nquery ($projectId: String!) {\n project(projectId: $projectId) {\n createdAt\n description\n id\n name\n template\n updatedAt\n prodBranch\n framework\n repository\n webhooks\n icon\n subDomain\n organization {\n id\n name\n }\n owner {\n id\n name\n email\n }\n deployments {\n id\n branch\n isCurrent\n status\n updatedAt\n commitHash\n createdAt\n environment\n domain {\n status\n branch\n createdAt\n updatedAt\n id\n name\n }\n createdBy {\n id\n name\n }\n }\n }\n}\n`;\n\nexport const getProjectsInOrganization = gql`\nquery ($organizationSlug: String!) {\n projectsInOrganization(organizationSlug: $organizationSlug) {\n id\n name\n createdAt\n description\n framework\n prodBranch\n webhooks\n repository\n updatedAt\n icon\n subDomain\n deployments {\n id\n branch\n isCurrent\n status\n updatedAt\n commitHash\n commitMessage\n createdAt\n environment\n domain {\n status\n branch\n createdAt\n updatedAt\n id\n name\n }\n }\n }\n}\n`;\n\nexport const getOrganizations = gql`\nquery {\n organizations {\n id\n name\n slug\n createdAt\n updatedAt\n }\n}\n`;\n\nexport const getDeployments = gql`\nquery ($projectId: String!) {\n deployments(projectId: $projectId) {\n id\n domain{\n branch\n createdAt\n id\n name\n status\n updatedAt\n }\n branch\n commitHash\n commitMessage\n url\n environment\n isCurrent\n status\n createdAt\n updatedAt\n createdBy {\n id\n name\n email\n }\n }\n}\n`;\n\nexport const getEnvironmentVariables = gql`\nquery ($projectId: String!) {\n environmentVariables(projectId: $projectId) {\n createdAt\n environment\n id\n key\n updatedAt\n value\n }\n}\n`;\n\nexport const getProjectMembers = gql`\nquery ($projectId: String!) {\n projectMembers(projectId: $projectId) {\n id\n member {\n id\n name\n email\n isVerified\n }\n isPending\n createdAt\n updatedAt\n permissions\n }\n}\n`;\n\nexport const searchProjects = gql`\nquery ($searchText: String!) {\n searchProjects(searchText: $searchText) {\n id\n name\n prodBranch\n repository\n createdAt\n description\n framework\n prodBranch\n webhooks\n updatedAt\n template\n repository\n organization {\n id\n name\n slug\n createdAt\n updatedAt\n }\n }\n}\n`;\n\nexport const getDomains = gql`\nquery ($projectId: String!, $filter: FilterDomainsInput) {\n domains(projectId: $projectId, filter: $filter) {\n branch\n createdAt\n redirectTo {\n id\n name\n branch\n status\n }\n id\n name\n status\n updatedAt\n }\n}\n`;\n","import { gql } from '@apollo/client';\n\nexport const removeProjectMember = gql`\nmutation ($projectMemberId: String!) {\n removeProjectMember(projectMemberId: $projectMemberId)\n}\n`;\n\nexport const updateProjectMember = gql`\nmutation ($projectMemberId: String!, $data: UpdateProjectMemberInput) {\n updateProjectMember(projectMemberId: $projectMemberId, data: $data)\n}\n`;\n\nexport const addProjectMember = gql`\nmutation ($projectId: String!, $data: AddProjectMemberInput) {\n addProjectMember(projectId: $projectId, data: $data)\n}\n`;\n\nexport const addEnvironmentVariables = gql`\nmutation ($projectId: String!, $data: [AddEnvironmentVariableInput!]) {\n addEnvironmentVariables(projectId: $projectId, data: $data)\n}\n`;\n\nexport const updateEnvironmentVariable = gql`\nmutation ($environmentVariableId: String!, $data: UpdateEnvironmentVariableInput!) {\n updateEnvironmentVariable(environmentVariableId: $environmentVariableId, data: $data)\n}\n`;\n\nexport const removeEnvironmentVariable = gql`\nmutation ($environmentVariableId: String!) {\n removeEnvironmentVariable(environmentVariableId: $environmentVariableId)\n}\n`;\n\nexport const updateDeploymentToProd = gql`\nmutation ($deploymentId: String!) {\n updateDeploymentToProd(deploymentId: $deploymentId)\n}\n`;\n\nexport const addProject = gql`\nmutation ($organizationSlug: String!, $data: AddProjectInput) {\n addProject(organizationSlug: $organizationSlug, data: $data) {\n id\n }\n}`;\n\nexport const updateProjectMutation = gql`\nmutation ($projectId: String!, $data: UpdateProjectInput) {\n updateProject(projectId: $projectId, data: $data)\n}`;\n\nexport const updateDomainMutation = gql`\nmutation ($domainId: String!, $data: UpdateDomainInput!) {\n updateDomain(domainId: $domainId, data: $data)\n}`;\n\nexport const redeployToProd = gql`\nmutation ($deploymentId: String!) {\n redeployToProd(deploymentId: $deploymentId)\n}\n`;\n\nexport const deleteProject = gql`\nmutation ($projectId: String!) {\n deleteProject(projectId: $projectId)\n}\n`;\n\nexport const deleteDomain = gql`\nmutation ($domainId: String!) {\n deleteDomain(domainId: $domainId)\n}`;\n\nexport const rollbackDeployment = gql`\nmutation ($projectId: String! ,$deploymentId: String!) {\n rollbackDeployment(projectId: $projectId, deploymentId: $deploymentId)\n}\n`;\n\nexport const deleteDeployment = gql`\nmutation ($deploymentId: String!) {\n deleteDeployment(deploymentId: $deploymentId)\n}\n`;\n\nexport const addDomain = gql`\nmutation ($projectId: String!, $data: AddDomainInput!) {\n addDomain(projectId: $projectId, data: $data)\n}\n`;\n\nexport const authenticateGitHub = gql`\nmutation ($code: String!) {\n authenticateGitHub(code: $code) {\n token\n }\n}`;\n\nexport const unauthenticateGitHub = gql`\nmutation {\n unauthenticateGitHub\n}`;\n","// Note: equivalent to types present in GQL schema\n\nexport enum Role {\n Owner = 'Owner',\n Maintainer = 'Maintainer',\n Reader = 'Reader',\n}\n\nexport enum Permission {\n View = 'View',\n Edit = 'Edit',\n}\n\nexport enum Environment {\n Production = 'Production',\n Preview = 'Preview',\n Development = 'Development',\n}\n\nexport enum DeploymentStatus {\n Building = 'Building',\n Ready = 'Ready',\n Error = 'Error',\n Deleting = 'Deleting'\n}\n\nexport enum DomainStatus {\n Live = 'Live',\n Pending = 'Pending',\n}\n\nexport type EnvironmentVariable = {\n id: string\n environment: Environment\n key: string\n value: string\n createdAt: string\n updatedAt: string\n}\n\nexport type Domain = {\n id: string\n branch: string\n name: string\n status: DomainStatus\n redirectTo: Domain | null\n createdAt: string\n updatedAt: string\n}\n\nexport type User = {\n id: string\n name: string | null\n email: string\n isVerified: boolean\n createdAt: string\n updatedAt: string\n gitHubToken: string | null\n}\n\nexport type Deployment = {\n id: string\n domain: Domain\n branch: string\n commitHash: string\n commitMessage: string\n url?: string\n environment: Environment\n isCurrent: boolean\n status: DeploymentStatus\n createdBy: User\n createdAt: string\n updatedAt: string\n}\n\nexport type OrganizationMember = {\n id: string\n member: User\n role: Role\n createdAt: string\n updatedAt: string\n}\n\nexport type ProjectMember = {\n id: string\n member: User\n permissions: Permission[]\n isPending: boolean\n createdAt: string\n updatedAt: string\n}\n\nexport type OrganizationProject = {\n id: string\n owner: User\n deployments: Deployment[]\n name: string\n repository: string\n prodBranch: string\n description: string\n template: string\n framework: string\n webhooks: string[]\n members: ProjectMember[]\n environmentVariables: EnvironmentVariable[]\n createdAt: string\n updatedAt: string\n}\n\nexport type Organization = {\n id: string\n name: string\n slug: string\n projects: OrganizationProject[]\n createdAt: string\n updatedAt: string\n members: OrganizationMember[]\n}\n\nexport type Project = {\n id: string\n owner: User\n deployments: Deployment[]\n name: string\n repository: string\n prodBranch: string\n description: string\n template: string\n framework: string\n webhooks: string[]\n members: ProjectMember[]\n environmentVariables: EnvironmentVariable[]\n createdAt: string\n updatedAt: string\n organization: Organization\n icon: string\n subDomain: string\n}\n\nexport type GetProjectMembersResponse = {\n projectMembers: ProjectMember[]\n}\n\nexport type AddProjectMemberResponse = {\n addProjectMember: boolean\n}\n\nexport type RemoveProjectMemberResponse = {\n removeProjectMember: boolean;\n}\n\nexport type UpdateProjectMemberResponse = {\n updateProjectMember: boolean;\n}\n\nexport type GetDeploymentsResponse = {\n deployments: Deployment[]\n}\n\nexport type GetEnvironmentVariablesResponse = {\n environmentVariables: EnvironmentVariable[]\n}\n\nexport type GetOrganizationsResponse = {\n organizations: Organization[]\n}\n\nexport type GetUserResponse = {\n user: User\n}\n\nexport type GetProjectResponse = {\n project: Project | null\n}\n\nexport type GetProjectsInOrganizationResponse = {\n projectsInOrganization: Project[]\n}\n\nexport type GetDomainsResponse = {\n domains: Domain[]\n}\n\nexport type SearchProjectsResponse = {\n searchProjects: Project[]\n}\n\nexport type AddEnvironmentVariablesResponse = {\n addEnvironmentVariables: boolean;\n}\n\nexport type AddEnvironmentVariableInput = {\n environments: string[];\n key: string;\n value: string;\n}\n\nexport type UpdateEnvironmentVariableInput = {\n key: string;\n value: string;\n}\n\nexport type UpdateProjectMemberInput = {\n permissions: Permission[];\n}\n\nexport type AddProjectMemberInput = {\n email: string;\n permissions: Permission[]\n}\n\nexport type UpdateEnvironmentVariableResponse = {\n updateEnvironmentVariable: boolean;\n}\n\nexport type RemoveEnvironmentVariableResponse = {\n removeEnvironmentVariable: boolean;\n}\n\nexport type UpdateDeploymentToProdResponse = {\n updateDeploymentToProd: boolean;\n}\n\nexport type AddProjectResponse = {\n addProject: Project\n}\n\nexport type UpdateProjectResponse = {\n updateProject: boolean;\n}\n\nexport type UpdateDomainResponse = {\n updateDomain: boolean;\n}\n\nexport type DeleteProjectResponse = {\n deleteProject: boolean;\n}\n\nexport type DeleteDomainResponse = {\n deleteDomain: boolean;\n}\n\nexport type AddProjectInput = {\n name: string;\n repository: string;\n prodBranch: string;\n template?: string;\n}\n\nexport type UpdateProjectInput = {\n name?: string\n description?: string\n prodBranch?: string\n webhooks?: string[]\n organizationId?: string\n}\n\nexport type UpdateDomainInput = {\n name?: string;\n branch?: string;\n redirectToId?: string | null;\n}\n\nexport type RedeployToProdResponse = {\n redeployToProd: boolean\n}\n\nexport type RollbackDeploymentResponse = {\n rollbackDeployment: boolean\n}\n\nexport type DeleteDeploymentResponse = {\n deleteDeployment: boolean\n}\n\nexport type AddDomainInput = {\n name: string\n}\n\nexport type FilterDomainInput = {\n branch?: string\n status?: DomainStatus\n}\n\nexport type AddDomainResponse = {\n addDomain: true\n}\n\nexport type AuthenticateGitHubResponse = {\n authenticateGitHub: {\n token: string\n }\n}\n\nexport type UnauthenticateGitHubResponse = {\n unauthenticateGitHub: boolean\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,cAA8B,qBAA4C;;;ACAnF,SAAS,WAAW;AAEb,IAAM,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAahB,IAAM,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkDnB,IAAM,4BAA4B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAqClC,IAAM,mBAAmB;AAAA;AAAA;AAAA;AAAA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V,EAAAA,aAAA,iBAAc;AAHJ,SAAAA;AAAA,GAAA;AAML,IAAK,mBAAL,kBAAKC,sBAAL;AACL,EAAAA,kBAAA,cAAW;AACX,EAAAA,kBAAA,WAAQ;AACR,EAAAA,kBAAA,WAAQ;AACR,EAAAA,kBAAA,cAAW;AAJD,SAAAA;AAAA,GAAA;AAOL,IAAK,eAAL,kBAAKC,kBAAL;AACL,EAAAA,cAAA,UAAO;AACP,EAAAA,cAAA,aAAU;AAFA,SAAAA;AAAA,GAAA;","names":["gql","Role","Permission","Environment","DeploymentStatus","DomainStatus"]} \ No newline at end of file +{"version":3,"sources":["../src/client.ts","../src/queries.ts","../src/mutations.ts","../src/types.ts"],"sourcesContent":["import {\n ApolloClient,\n DefaultOptions,\n InMemoryCache,\n NormalizedCacheObject,\n} from \"@apollo/client\";\n\nimport * as queries from \"./queries\";\nimport * as types from \"./types\";\nimport * as mutations from \"./mutations\";\n\nexport interface GraphQLConfig {\n gqlEndpoint: string;\n}\n\n// TODO: check options\nconst defaultOptions: DefaultOptions = {\n watchQuery: {\n fetchPolicy: \"no-cache\",\n errorPolicy: \"ignore\",\n },\n query: {\n fetchPolicy: \"no-cache\",\n errorPolicy: \"all\",\n },\n};\n\nexport class GQLClient {\n private client: ApolloClient;\n\n constructor(config: GraphQLConfig) {\n this.client = new ApolloClient({\n uri: config.gqlEndpoint,\n cache: new InMemoryCache(),\n defaultOptions,\n credentials: \"include\",\n });\n }\n\n async getUser(): Promise {\n const { data } = await this.client.query({\n query: queries.getUser,\n });\n\n return data;\n }\n\n async getProject(projectId: string): Promise {\n const { data } = await this.client.query({\n query: queries.getProject,\n variables: {\n projectId,\n },\n });\n\n return data;\n }\n\n async getProjectsInOrganization(\n organizationSlug: string\n ): Promise {\n const { data } = await this.client.query({\n query: queries.getProjectsInOrganization,\n variables: {\n organizationSlug,\n },\n });\n\n return data;\n }\n\n async getOrganizations(): Promise {\n const { data } = await this.client.query({\n query: queries.getOrganizations,\n });\n\n return data;\n }\n\n async getDeployments(\n projectId: string\n ): Promise {\n const { data } = await this.client.query({\n query: queries.getDeployments,\n variables: {\n projectId,\n },\n });\n\n return data;\n }\n\n async getEnvironmentVariables(\n projectId: string\n ): Promise {\n const { data } = await this.client.query({\n query: queries.getEnvironmentVariables,\n variables: {\n projectId,\n },\n });\n\n return data;\n }\n\n async getProjectMembers(\n projectId: string\n ): Promise {\n const result = await this.client.query({\n query: queries.getProjectMembers,\n variables: {\n projectId,\n },\n });\n\n return result.data;\n }\n\n async addProjectMember(\n projectId: string,\n data: types.AddProjectMemberInput\n ): Promise {\n const result = await this.client.mutate({\n mutation: mutations.addProjectMember,\n variables: {\n projectId,\n data,\n },\n });\n\n return result.data;\n }\n\n async updateProjectMember(\n projectMemberId: string,\n data: types.UpdateProjectMemberInput\n ): Promise {\n const result = await this.client.mutate({\n mutation: mutations.updateProjectMember,\n variables: {\n projectMemberId,\n data,\n },\n });\n\n return result.data;\n }\n\n async removeProjectMember(\n projectMemberId: string\n ): Promise {\n const result = await this.client.mutate({\n mutation: mutations.removeProjectMember,\n variables: {\n projectMemberId,\n },\n });\n\n return result.data;\n }\n\n async searchProjects(\n searchText: string\n ): Promise {\n const { data } = await this.client.query({\n query: queries.searchProjects,\n variables: {\n searchText,\n },\n });\n\n return data;\n }\n\n async addEnvironmentVariables(\n projectId: string,\n data: types.AddEnvironmentVariableInput[]\n ): Promise {\n const result = await this.client.mutate({\n mutation: mutations.addEnvironmentVariables,\n variables: {\n projectId,\n data,\n },\n });\n\n return result.data;\n }\n\n async updateEnvironmentVariable(\n environmentVariableId: string,\n data: types.UpdateEnvironmentVariableInput\n ): Promise {\n const result = await this.client.mutate({\n mutation: mutations.updateEnvironmentVariable,\n variables: {\n environmentVariableId,\n data,\n },\n });\n\n return result.data;\n }\n\n async removeEnvironmentVariable(\n environmentVariableId: string\n ): Promise {\n const { data } = await this.client.mutate({\n mutation: mutations.removeEnvironmentVariable,\n variables: {\n environmentVariableId,\n },\n });\n\n return data;\n }\n\n async updateDeploymentToProd(\n deploymentId: string\n ): Promise {\n const { data } = await this.client.mutate({\n mutation: mutations.updateDeploymentToProd,\n variables: {\n deploymentId,\n },\n });\n\n return data;\n }\n\n async addProject(\n organizationSlug: string,\n data: types.AddProjectInput\n ): Promise {\n const result = await this.client.mutate({\n mutation: mutations.addProject,\n variables: {\n organizationSlug,\n data,\n },\n });\n\n return result.data;\n }\n\n async updateProject(\n projectId: string,\n data: types.UpdateProjectInput\n ): Promise {\n const result = await this.client.mutate({\n mutation: mutations.updateProjectMutation,\n variables: {\n projectId,\n data,\n },\n });\n\n return result.data;\n }\n\n async updateDomain(\n domainId: string,\n data: types.UpdateDomainInput\n ): Promise {\n const result = await this.client.mutate({\n mutation: mutations.updateDomainMutation,\n variables: {\n domainId,\n data,\n },\n });\n\n return result.data;\n }\n\n async redeployToProd(\n deploymentId: string\n ): Promise {\n const { data } = await this.client.mutate({\n mutation: mutations.redeployToProd,\n variables: {\n deploymentId,\n },\n });\n\n return data;\n }\n\n async deleteProject(projectId: string): Promise {\n const { data } = await this.client.mutate({\n mutation: mutations.deleteProject,\n variables: {\n projectId,\n },\n });\n\n return data;\n }\n\n async deleteDomain(domainId: string): Promise {\n const { data } = await this.client.mutate({\n mutation: mutations.deleteDomain,\n variables: {\n domainId,\n },\n });\n\n return data;\n }\n\n async rollbackDeployment(\n projectId: string,\n deploymentId: string\n ): Promise {\n const { data } = await this.client.mutate({\n mutation: mutations.rollbackDeployment,\n variables: {\n projectId,\n deploymentId,\n },\n });\n\n return data;\n }\n\n async deleteDeployment(\n deploymentId: string\n ): Promise {\n const { data } = await this.client.mutate({\n mutation: mutations.deleteDeployment,\n variables: {\n deploymentId,\n },\n });\n\n return data;\n }\n\n async addDomain(\n projectId: string,\n data: types.AddDomainInput\n ): Promise {\n const result = await this.client.mutate({\n mutation: mutations.addDomain,\n variables: {\n projectId,\n data,\n },\n });\n\n return result.data;\n }\n\n async getDomains(\n projectId: string,\n filter?: types.FilterDomainInput\n ): Promise {\n const { data } = await this.client.query({\n query: queries.getDomains,\n variables: {\n projectId,\n filter,\n },\n });\n\n return data;\n }\n\n async authenticateGitHub(\n code: string\n ): Promise {\n const { data } = await this.client.mutate({\n mutation: mutations.authenticateGitHub,\n variables: {\n code,\n },\n });\n\n return data;\n }\n\n async unauthenticateGithub(): Promise {\n const { data } = await this.client.mutate({\n mutation: mutations.unauthenticateGitHub,\n });\n\n return data;\n }\n}\n","import { gql } from '@apollo/client';\n\nexport const getUser = gql`\nquery {\n user {\n id\n name\n email\n createdAt\n updatedAt\n gitHubToken\n }\n}\n`;\n\nexport const getProject = gql`\nquery ($projectId: String!) {\n project(projectId: $projectId) {\n createdAt\n description\n id\n name\n template\n updatedAt\n prodBranch\n framework\n repository\n webhooks\n icon\n subDomain\n organization {\n id\n name\n }\n owner {\n id\n name\n email\n }\n deployments {\n id\n branch\n isCurrent\n status\n updatedAt\n commitHash\n createdAt\n environment\n domain {\n status\n branch\n createdAt\n updatedAt\n id\n name\n }\n createdBy {\n id\n name\n }\n }\n }\n}\n`;\n\nexport const getProjectsInOrganization = gql`\nquery ($organizationSlug: String!) {\n projectsInOrganization(organizationSlug: $organizationSlug) {\n id\n name\n createdAt\n description\n framework\n prodBranch\n webhooks\n repository\n updatedAt\n icon\n subDomain\n deployments {\n id\n branch\n isCurrent\n status\n updatedAt\n commitHash\n commitMessage\n createdAt\n environment\n domain {\n status\n branch\n createdAt\n updatedAt\n id\n name\n }\n }\n }\n}\n`;\n\nexport const getOrganizations = gql`\nquery {\n organizations {\n id\n name\n slug\n createdAt\n updatedAt\n }\n}\n`;\n\nexport const getDeployments = gql`\nquery ($projectId: String!) {\n deployments(projectId: $projectId) {\n id\n domain{\n branch\n createdAt\n id\n name\n status\n updatedAt\n }\n branch\n commitHash\n commitMessage\n url\n environment\n isCurrent\n status\n createdAt\n updatedAt\n createdBy {\n id\n name\n email\n }\n }\n}\n`;\n\nexport const getEnvironmentVariables = gql`\nquery ($projectId: String!) {\n environmentVariables(projectId: $projectId) {\n createdAt\n environment\n id\n key\n updatedAt\n value\n }\n}\n`;\n\nexport const getProjectMembers = gql`\nquery ($projectId: String!) {\n projectMembers(projectId: $projectId) {\n id\n member {\n id\n name\n email\n isVerified\n }\n isPending\n createdAt\n updatedAt\n permissions\n }\n}\n`;\n\nexport const searchProjects = gql`\nquery ($searchText: String!) {\n searchProjects(searchText: $searchText) {\n id\n name\n prodBranch\n repository\n createdAt\n description\n framework\n prodBranch\n webhooks\n updatedAt\n template\n repository\n organization {\n id\n name\n slug\n createdAt\n updatedAt\n }\n }\n}\n`;\n\nexport const getDomains = gql`\nquery ($projectId: String!, $filter: FilterDomainsInput) {\n domains(projectId: $projectId, filter: $filter) {\n branch\n createdAt\n redirectTo {\n id\n name\n branch\n status\n }\n id\n name\n status\n updatedAt\n }\n}\n`;\n","import { gql } from '@apollo/client';\n\nexport const removeProjectMember = gql`\nmutation ($projectMemberId: String!) {\n removeProjectMember(projectMemberId: $projectMemberId)\n}\n`;\n\nexport const updateProjectMember = gql`\nmutation ($projectMemberId: String!, $data: UpdateProjectMemberInput) {\n updateProjectMember(projectMemberId: $projectMemberId, data: $data)\n}\n`;\n\nexport const addProjectMember = gql`\nmutation ($projectId: String!, $data: AddProjectMemberInput) {\n addProjectMember(projectId: $projectId, data: $data)\n}\n`;\n\nexport const addEnvironmentVariables = gql`\nmutation ($projectId: String!, $data: [AddEnvironmentVariableInput!]) {\n addEnvironmentVariables(projectId: $projectId, data: $data)\n}\n`;\n\nexport const updateEnvironmentVariable = gql`\nmutation ($environmentVariableId: String!, $data: UpdateEnvironmentVariableInput!) {\n updateEnvironmentVariable(environmentVariableId: $environmentVariableId, data: $data)\n}\n`;\n\nexport const removeEnvironmentVariable = gql`\nmutation ($environmentVariableId: String!) {\n removeEnvironmentVariable(environmentVariableId: $environmentVariableId)\n}\n`;\n\nexport const updateDeploymentToProd = gql`\nmutation ($deploymentId: String!) {\n updateDeploymentToProd(deploymentId: $deploymentId)\n}\n`;\n\nexport const addProject = gql`\nmutation ($organizationSlug: String!, $data: AddProjectInput) {\n addProject(organizationSlug: $organizationSlug, data: $data) {\n id\n }\n}`;\n\nexport const updateProjectMutation = gql`\nmutation ($projectId: String!, $data: UpdateProjectInput) {\n updateProject(projectId: $projectId, data: $data)\n}`;\n\nexport const updateDomainMutation = gql`\nmutation ($domainId: String!, $data: UpdateDomainInput!) {\n updateDomain(domainId: $domainId, data: $data)\n}`;\n\nexport const redeployToProd = gql`\nmutation ($deploymentId: String!) {\n redeployToProd(deploymentId: $deploymentId)\n}\n`;\n\nexport const deleteProject = gql`\nmutation ($projectId: String!) {\n deleteProject(projectId: $projectId)\n}\n`;\n\nexport const deleteDomain = gql`\nmutation ($domainId: String!) {\n deleteDomain(domainId: $domainId)\n}`;\n\nexport const rollbackDeployment = gql`\nmutation ($projectId: String! ,$deploymentId: String!) {\n rollbackDeployment(projectId: $projectId, deploymentId: $deploymentId)\n}\n`;\n\nexport const deleteDeployment = gql`\nmutation ($deploymentId: String!) {\n deleteDeployment(deploymentId: $deploymentId)\n}\n`;\n\nexport const addDomain = gql`\nmutation ($projectId: String!, $data: AddDomainInput!) {\n addDomain(projectId: $projectId, data: $data)\n}\n`;\n\nexport const authenticateGitHub = gql`\nmutation ($code: String!) {\n authenticateGitHub(code: $code) {\n token\n }\n}`;\n\nexport const unauthenticateGitHub = gql`\nmutation {\n unauthenticateGitHub\n}`;\n","// Note: equivalent to types present in GQL schema\n\nexport enum Role {\n Owner = 'Owner',\n Maintainer = 'Maintainer',\n Reader = 'Reader',\n}\n\nexport enum Permission {\n View = 'View',\n Edit = 'Edit',\n}\n\nexport enum Environment {\n Production = 'Production',\n Preview = 'Preview',\n Development = 'Development',\n}\n\nexport enum DeploymentStatus {\n Building = 'Building',\n Ready = 'Ready',\n Error = 'Error',\n Deleting = 'Deleting'\n}\n\nexport enum DomainStatus {\n Live = 'Live',\n Pending = 'Pending',\n}\n\nexport type EnvironmentVariable = {\n id: string\n environment: Environment\n key: string\n value: string\n createdAt: string\n updatedAt: string\n}\n\nexport type Domain = {\n id: string\n branch: string\n name: string\n status: DomainStatus\n redirectTo: Domain | null\n createdAt: string\n updatedAt: string\n}\n\nexport type User = {\n id: string\n name: string | null\n email: string\n isVerified: boolean\n createdAt: string\n updatedAt: string\n gitHubToken: string | null\n}\n\nexport type Deployment = {\n id: string\n domain: Domain\n branch: string\n commitHash: string\n commitMessage: string\n url?: string\n environment: Environment\n isCurrent: boolean\n status: DeploymentStatus\n createdBy: User\n createdAt: string\n updatedAt: string\n}\n\nexport type OrganizationMember = {\n id: string\n member: User\n role: Role\n createdAt: string\n updatedAt: string\n}\n\nexport type ProjectMember = {\n id: string\n member: User\n permissions: Permission[]\n isPending: boolean\n createdAt: string\n updatedAt: string\n}\n\nexport type OrganizationProject = {\n id: string\n owner: User\n deployments: Deployment[]\n name: string\n repository: string\n prodBranch: string\n description: string\n template: string\n framework: string\n webhooks: string[]\n members: ProjectMember[]\n environmentVariables: EnvironmentVariable[]\n createdAt: string\n updatedAt: string\n}\n\nexport type Organization = {\n id: string\n name: string\n slug: string\n projects: OrganizationProject[]\n createdAt: string\n updatedAt: string\n members: OrganizationMember[]\n}\n\nexport type Project = {\n id: string\n owner: User\n deployments: Deployment[]\n name: string\n repository: string\n prodBranch: string\n description: string\n template: string\n framework: string\n webhooks: string[]\n members: ProjectMember[]\n environmentVariables: EnvironmentVariable[]\n createdAt: string\n updatedAt: string\n organization: Organization\n icon: string\n subDomain: string\n}\n\nexport type GetProjectMembersResponse = {\n projectMembers: ProjectMember[]\n}\n\nexport type AddProjectMemberResponse = {\n addProjectMember: boolean\n}\n\nexport type RemoveProjectMemberResponse = {\n removeProjectMember: boolean;\n}\n\nexport type UpdateProjectMemberResponse = {\n updateProjectMember: boolean;\n}\n\nexport type GetDeploymentsResponse = {\n deployments: Deployment[]\n}\n\nexport type GetEnvironmentVariablesResponse = {\n environmentVariables: EnvironmentVariable[]\n}\n\nexport type GetOrganizationsResponse = {\n organizations: Organization[]\n}\n\nexport type GetUserResponse = {\n user: User\n}\n\nexport type GetProjectResponse = {\n project: Project | null\n}\n\nexport type GetProjectsInOrganizationResponse = {\n projectsInOrganization: Project[]\n}\n\nexport type GetDomainsResponse = {\n domains: Domain[]\n}\n\nexport type SearchProjectsResponse = {\n searchProjects: Project[]\n}\n\nexport type AddEnvironmentVariablesResponse = {\n addEnvironmentVariables: boolean;\n}\n\nexport type AddEnvironmentVariableInput = {\n environments: string[];\n key: string;\n value: string;\n}\n\nexport type UpdateEnvironmentVariableInput = {\n key: string;\n value: string;\n}\n\nexport type UpdateProjectMemberInput = {\n permissions: Permission[];\n}\n\nexport type AddProjectMemberInput = {\n email: string;\n permissions: Permission[]\n}\n\nexport type UpdateEnvironmentVariableResponse = {\n updateEnvironmentVariable: boolean;\n}\n\nexport type RemoveEnvironmentVariableResponse = {\n removeEnvironmentVariable: boolean;\n}\n\nexport type UpdateDeploymentToProdResponse = {\n updateDeploymentToProd: boolean;\n}\n\nexport type AddProjectResponse = {\n addProject: Project\n}\n\nexport type UpdateProjectResponse = {\n updateProject: boolean;\n}\n\nexport type UpdateDomainResponse = {\n updateDomain: boolean;\n}\n\nexport type DeleteProjectResponse = {\n deleteProject: boolean;\n}\n\nexport type DeleteDomainResponse = {\n deleteDomain: boolean;\n}\n\nexport type AddProjectInput = {\n name: string;\n repository: string;\n prodBranch: string;\n template?: string;\n}\n\nexport type UpdateProjectInput = {\n name?: string\n description?: string\n prodBranch?: string\n webhooks?: string[]\n organizationId?: string\n}\n\nexport type UpdateDomainInput = {\n name?: string;\n branch?: string;\n redirectToId?: string | null;\n}\n\nexport type RedeployToProdResponse = {\n redeployToProd: boolean\n}\n\nexport type RollbackDeploymentResponse = {\n rollbackDeployment: boolean\n}\n\nexport type DeleteDeploymentResponse = {\n deleteDeployment: boolean\n}\n\nexport type AddDomainInput = {\n name: string\n}\n\nexport type FilterDomainInput = {\n branch?: string\n status?: DomainStatus\n}\n\nexport type AddDomainResponse = {\n addDomain: true\n}\n\nexport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AM,KAAK,OAAO,MAAM;AAAA,QACvC,OAAe;AAAA,QACf,WAAW;AAAA,UACT;AAAA,UACA;AAAA,QACF;AAAA,MACF,CAAC;AAED,aAAO;AAAA,IACT;AAAA;AAAA,EAEM,mBACJ,MAC2C;AAAA;AAC3C,YAAM,EAAE,KAAK,IAAI,MAAM,KAAK,OAAO,OAAO;AAAA,QACxC,UAAoB;AAAA,QACpB,WAAW;AAAA,UACT;AAAA,QACF;AAAA,MACF,CAAC;AAED,aAAO;AAAA,IACT;AAAA;AAAA,EAEM,uBAAoE;AAAA;AACxE,YAAM,EAAE,KAAK,IAAI,MAAM,KAAK,OAAO,OAAO;AAAA,QACxC,UAAoB;AAAA,MACtB,CAAC;AAED,aAAO;AAAA,IACT;AAAA;AACF;;;AGlYO,IAAK,OAAL,kBAAKC,UAAL;AACL,EAAAA,MAAA,WAAQ;AACR,EAAAA,MAAA,gBAAa;AACb,EAAAA,MAAA,YAAS;AAHC,SAAAA;AAAA,GAAA;AAML,IAAK,aAAL,kBAAKC,gBAAL;AACL,EAAAA,YAAA,UAAO;AACP,EAAAA,YAAA,UAAO;AAFG,SAAAA;AAAA,GAAA;AAKL,IAAK,cAAL,kBAAKC,iBAAL;AACL,EAAAA,aAAA,gBAAa;AACb,EAAAA,aAAA,aAAU;AACV,EAAAA,aAAA,iBAAc;AAHJ,SAAAA;AAAA,GAAA;AAML,IAAK,mBAAL,kBAAKC,sBAAL;AACL,EAAAA,kBAAA,cAAW;AACX,EAAAA,kBAAA,WAAQ;AACR,EAAAA,kBAAA,WAAQ;AACR,EAAAA,kBAAA,cAAW;AAJD,SAAAA;AAAA,GAAA;AAOL,IAAK,eAAL,kBAAKC,kBAAL;AACL,EAAAA,cAAA,UAAO;AACP,EAAAA,cAAA,aAAU;AAFA,SAAAA;AAAA,GAAA;","names":["gql","Role","Permission","Environment","DeploymentStatus","DomainStatus"]} \ No newline at end of file diff --git a/packages/gql-client/src/client.ts b/packages/gql-client/src/client.ts index f238869e..00f3b2ba 100644 --- a/packages/gql-client/src/client.ts +++ b/packages/gql-client/src/client.ts @@ -1,8 +1,13 @@ -import { ApolloClient, DefaultOptions, InMemoryCache, NormalizedCacheObject } from '@apollo/client'; +import { + ApolloClient, + DefaultOptions, + InMemoryCache, + NormalizedCacheObject, +} from "@apollo/client"; -import * as queries from './queries'; -import * as types from './types'; -import * as mutations from './mutations'; +import * as queries from "./queries"; +import * as types from "./types"; +import * as mutations from "./mutations"; export interface GraphQLConfig { gqlEndpoint: string; @@ -11,320 +16,372 @@ export interface GraphQLConfig { // TODO: check options const defaultOptions: DefaultOptions = { watchQuery: { - fetchPolicy: 'no-cache', - errorPolicy: 'ignore' + fetchPolicy: "no-cache", + errorPolicy: "ignore", }, query: { - fetchPolicy: 'no-cache', - errorPolicy: 'all' - } + fetchPolicy: "no-cache", + errorPolicy: "all", + }, }; export class GQLClient { private client: ApolloClient; - constructor (config: GraphQLConfig) { + constructor(config: GraphQLConfig) { this.client = new ApolloClient({ uri: config.gqlEndpoint, cache: new InMemoryCache(), defaultOptions, - credentials: 'include' + credentials: "include", }); } - async getUser () : Promise { + async getUser(): Promise { const { data } = await this.client.query({ - query: queries.getUser + query: queries.getUser, }); return data; } - async getProject (projectId: string) : Promise { + async getProject(projectId: string): Promise { const { data } = await this.client.query({ query: queries.getProject, variables: { - projectId - } + projectId, + }, }); return data; } - async getProjectsInOrganization (organizationSlug: string) : Promise { + async getProjectsInOrganization( + organizationSlug: string + ): Promise { const { data } = await this.client.query({ query: queries.getProjectsInOrganization, variables: { - organizationSlug - } + organizationSlug, + }, }); return data; } - async getOrganizations () : Promise { + async getOrganizations(): Promise { const { data } = await this.client.query({ - query: queries.getOrganizations + query: queries.getOrganizations, }); return data; } - async getDeployments (projectId: string) : Promise { + async getDeployments( + projectId: string + ): Promise { const { data } = await this.client.query({ query: queries.getDeployments, variables: { - projectId - } + projectId, + }, }); return data; } - async getEnvironmentVariables (projectId: string) : Promise { + async getEnvironmentVariables( + projectId: string + ): Promise { const { data } = await this.client.query({ query: queries.getEnvironmentVariables, variables: { - projectId - } + projectId, + }, }); return data; } - async getProjectMembers (projectId: string) : Promise { + async getProjectMembers( + projectId: string + ): Promise { const result = await this.client.query({ query: queries.getProjectMembers, variables: { - projectId - } + projectId, + }, }); return result.data; } - async addProjectMember (projectId: string, data: types.AddProjectMemberInput) : Promise { + async addProjectMember( + projectId: string, + data: types.AddProjectMemberInput + ): Promise { const result = await this.client.mutate({ mutation: mutations.addProjectMember, variables: { projectId, - data - } + data, + }, }); return result.data; } - async updateProjectMember (projectMemberId: string, data: types.UpdateProjectMemberInput): Promise { + async updateProjectMember( + projectMemberId: string, + data: types.UpdateProjectMemberInput + ): Promise { const result = await this.client.mutate({ mutation: mutations.updateProjectMember, variables: { projectMemberId, - data - } + data, + }, }); return result.data; } - async removeProjectMember (projectMemberId: string): Promise { + async removeProjectMember( + projectMemberId: string + ): Promise { const result = await this.client.mutate({ mutation: mutations.removeProjectMember, variables: { - projectMemberId - } + projectMemberId, + }, }); return result.data; } - async searchProjects (searchText: string) : Promise { + async searchProjects( + searchText: string + ): Promise { const { data } = await this.client.query({ query: queries.searchProjects, variables: { - searchText - } + searchText, + }, }); return data; } - async addEnvironmentVariables (projectId: string, data: types.AddEnvironmentVariableInput[]): Promise { + async addEnvironmentVariables( + projectId: string, + data: types.AddEnvironmentVariableInput[] + ): Promise { const result = await this.client.mutate({ mutation: mutations.addEnvironmentVariables, variables: { projectId, - data - } + data, + }, }); return result.data; } - async updateEnvironmentVariable (environmentVariableId: string, data: types.UpdateEnvironmentVariableInput): Promise { + async updateEnvironmentVariable( + environmentVariableId: string, + data: types.UpdateEnvironmentVariableInput + ): Promise { const result = await this.client.mutate({ mutation: mutations.updateEnvironmentVariable, variables: { environmentVariableId, - data - } + data, + }, }); return result.data; } - async removeEnvironmentVariable (environmentVariableId: string): Promise { + async removeEnvironmentVariable( + environmentVariableId: string + ): Promise { const { data } = await this.client.mutate({ mutation: mutations.removeEnvironmentVariable, variables: { - environmentVariableId - } + environmentVariableId, + }, }); return data; } - async updateDeploymentToProd (deploymentId: string): Promise { + async updateDeploymentToProd( + deploymentId: string + ): Promise { const { data } = await this.client.mutate({ mutation: mutations.updateDeploymentToProd, variables: { - deploymentId - } + deploymentId, + }, }); return data; } - async addProject (organizationSlug: string, data: types.AddProjectInput): Promise { + async addProject( + organizationSlug: string, + data: types.AddProjectInput + ): Promise { const result = await this.client.mutate({ mutation: mutations.addProject, variables: { organizationSlug, - data - } + data, + }, }); return result.data; } - async updateProject (projectId: string, data: types.UpdateProjectInput): Promise { + async updateProject( + projectId: string, + data: types.UpdateProjectInput + ): Promise { const result = await this.client.mutate({ mutation: mutations.updateProjectMutation, variables: { projectId, - data - } + data, + }, }); return result.data; } - async updateDomain (domainId: string, data: types.UpdateDomainInput): Promise { + async updateDomain( + domainId: string, + data: types.UpdateDomainInput + ): Promise { const result = await this.client.mutate({ mutation: mutations.updateDomainMutation, variables: { domainId, - data - } + data, + }, }); return result.data; } - async redeployToProd (deploymentId: string): Promise { + async redeployToProd( + deploymentId: string + ): Promise { const { data } = await this.client.mutate({ mutation: mutations.redeployToProd, variables: { - deploymentId - } + deploymentId, + }, }); return data; } - async deleteProject (projectId: string): Promise { + async deleteProject(projectId: string): Promise { const { data } = await this.client.mutate({ mutation: mutations.deleteProject, variables: { - projectId - } + projectId, + }, }); return data; } - async deleteDomain (domainId: string): Promise { + async deleteDomain(domainId: string): Promise { const { data } = await this.client.mutate({ mutation: mutations.deleteDomain, variables: { - domainId - } + domainId, + }, }); return data; } - async rollbackDeployment (projectId: string, deploymentId: string): Promise { + async rollbackDeployment( + projectId: string, + deploymentId: string + ): Promise { const { data } = await this.client.mutate({ mutation: mutations.rollbackDeployment, variables: { projectId, - deploymentId - } + deploymentId, + }, }); return data; } - async deleteDeployment (deploymentId: string): Promise { + async deleteDeployment( + deploymentId: string + ): Promise { const { data } = await this.client.mutate({ mutation: mutations.deleteDeployment, variables: { - deploymentId - } + deploymentId, + }, }); return data; } - async addDomain (projectId: string, data: types.AddDomainInput): Promise { + async addDomain( + projectId: string, + data: types.AddDomainInput + ): Promise { const result = await this.client.mutate({ mutation: mutations.addDomain, variables: { projectId, - data - } + data, + }, }); return result.data; } - async getDomains (projectId: string, filter?: types.FilterDomainInput): Promise { + async getDomains( + projectId: string, + filter?: types.FilterDomainInput + ): Promise { const { data } = await this.client.query({ query: queries.getDomains, variables: { projectId, - filter - } + filter, + }, }); return data; } - async authenticateGitHub (code: string): Promise { + async authenticateGitHub( + code: string + ): Promise { const { data } = await this.client.mutate({ mutation: mutations.authenticateGitHub, variables: { - code - } + code, + }, }); return data; } - async unauthenticateGithub (): Promise { + async unauthenticateGithub(): Promise { const { data } = await this.client.mutate({ - mutation: mutations.unauthenticateGitHub + mutation: mutations.unauthenticateGitHub, }); return data;