forked from cerc-io/snowballtools-base
Update method for deleting deployment
This commit is contained in:
1 parent
bf75dc8acc
commit
55e238d0b9
18 files changed
+60
-46
No files matched your search
@@ -465,8 +465,6 @@ export class Database {
|
||||
id: organizationId
|
||||
});
|
||||
|
||||
newProject.subDomain = `${newProject.name}.${this.projectDomain}`;
|
||||
|
||||
return projectRepository.save(newProject);
|
||||
}
|
||||
|
||||
|
||||
@@ -138,6 +138,9 @@ export class Deployment {
|
||||
@Column('boolean', { default: false })
|
||||
isCurrent!: boolean;
|
||||
|
||||
@Column('varchar', { nullable: true })
|
||||
baseDomain!: string | null;
|
||||
|
||||
@Column({
|
||||
enum: DeploymentStatus
|
||||
})
|
||||
|
||||
@@ -67,8 +67,8 @@ export class Project {
|
||||
@Column('varchar')
|
||||
icon!: string;
|
||||
|
||||
@Column('varchar')
|
||||
subDomain!: string;
|
||||
@Column('varchar', { nullable: true })
|
||||
baseDomains!: string[] | null;
|
||||
|
||||
@CreateDateColumn()
|
||||
createdAt!: Date;
|
||||
|
||||
@@ -194,7 +194,6 @@ export class Registry {
|
||||
})
|
||||
).data.html_url;
|
||||
|
||||
// TODO: Set environment variables for each deployment (environment variables can't be set in application record)
|
||||
const { applicationRecordId } =
|
||||
await this.createApplicationRecord({
|
||||
appName: repo,
|
||||
@@ -421,6 +420,7 @@ export class Registry {
|
||||
|
||||
async createApplicationDeploymentRemovalRequest (data: {
|
||||
deploymentId: string;
|
||||
deployerLrn: string;
|
||||
}): Promise<{
|
||||
applicationDeploymentRemovalRequestId: string;
|
||||
applicationDeploymentRemovalRequestData: ApplicationDeploymentRemovalRequest;
|
||||
@@ -428,7 +428,8 @@ export class Registry {
|
||||
const applicationDeploymentRemovalRequest = {
|
||||
type: APP_DEPLOYMENT_REMOVAL_REQUEST_TYPE,
|
||||
version: '1.0.0',
|
||||
deployment: data.deploymentId
|
||||
deployment: data.deploymentId,
|
||||
deployer: data.deployerLrn
|
||||
};
|
||||
|
||||
const fee = parseGasAndFees(this.registryConfig.fee.gas, this.registryConfig.fee.fees);
|
||||
|
||||
@@ -83,7 +83,7 @@ type Project {
|
||||
updatedAt: String!
|
||||
organization: Organization!
|
||||
icon: String
|
||||
subDomain: String
|
||||
baseDomains: [String!]
|
||||
}
|
||||
|
||||
type ProjectMember {
|
||||
@@ -105,6 +105,7 @@ type Deployment {
|
||||
environment: Environment!
|
||||
deployerLrn: String
|
||||
isCurrent: Boolean!
|
||||
baseDomain: String
|
||||
status: DeploymentStatus!
|
||||
createdAt: String!
|
||||
updatedAt: String!
|
||||
|
||||
@@ -210,10 +210,21 @@ export class Service {
|
||||
applicationDeploymentRecordId: record.id,
|
||||
applicationDeploymentRecordData: record.attributes,
|
||||
url: record.attributes.url,
|
||||
baseDomain,
|
||||
status: DeploymentStatus.Ready,
|
||||
isCurrent: deployment.environment === Environment.Production,
|
||||
});
|
||||
|
||||
const baseDomains = project.baseDomains || [];
|
||||
|
||||
if (!baseDomains.includes(baseDomain)) {
|
||||
baseDomains.push(baseDomain);
|
||||
}
|
||||
|
||||
await this.db.updateProjectById(project.id, {
|
||||
baseDomains
|
||||
})
|
||||
|
||||
log(
|
||||
`Updated deployment ${deployment.id} with URL ${record.attributes.url}`,
|
||||
);
|
||||
@@ -1113,7 +1124,7 @@ export class Service {
|
||||
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 currentDeploymentURL = `https://${(deployment.project.name).toLowerCase()}.${deployment.baseDomain}`;
|
||||
|
||||
const deploymentRecords =
|
||||
await this.registry.getDeploymentRecordsByFilter({
|
||||
@@ -1131,12 +1142,14 @@ export class Service {
|
||||
|
||||
await this.registry.createApplicationDeploymentRemovalRequest({
|
||||
deploymentId: deploymentRecords[0].id,
|
||||
deployerLrn: deployment.deployerLrn
|
||||
});
|
||||
}
|
||||
|
||||
const result =
|
||||
await this.registry.createApplicationDeploymentRemovalRequest({
|
||||
deploymentId: deployment.applicationDeploymentRecordId,
|
||||
deployerLrn: deployment.deployerLrn
|
||||
});
|
||||
|
||||
await this.db.updateDeploymentById(deployment.id, {
|
||||
|
||||
@@ -73,7 +73,7 @@ async function main() {
|
||||
|
||||
// Remove deployment for project subdomain if deployment is for production environment
|
||||
if (deployment.environment === Environment.Production) {
|
||||
applicationDeploymentRecord.url = `https://${deployment.project.subDomain}`
|
||||
applicationDeploymentRecord.url = `https://${deployment.project.name}.${deployment.baseDomain}`;
|
||||
|
||||
await registry.setRecord(
|
||||
{
|
||||
|
||||
@@ -5,7 +5,6 @@ import { Badge } from 'components/shared/Badge';
|
||||
import { Button } from 'components/shared/Button';
|
||||
import {
|
||||
ArrowLeftCircleFilledIcon,
|
||||
LinkChainIcon,
|
||||
QuestionMarkRoundFilledIcon,
|
||||
} from 'components/shared/CustomIcon';
|
||||
import { Heading } from 'components/shared/Heading';
|
||||
@@ -55,22 +54,6 @@ const Id = () => {
|
||||
<Heading as="h3" className="font-medium text-xl">
|
||||
{isAuction? 'Project created successfully.' : 'Project deployed successfully.'}
|
||||
</Heading>
|
||||
{!isAuction && (
|
||||
<p className="flex flex-col items-center lg:flex-row font-sans gap-0.5 lg:gap-2 text-sm text-elements-high-em">
|
||||
Your project has been deployed at{' '}
|
||||
<Button
|
||||
className="no-underline text-elements-link"
|
||||
// TODO: use dynamic value
|
||||
href={project ? `https://${project.subDomain}` : ''}
|
||||
as="a"
|
||||
variant="link-emphasized"
|
||||
external
|
||||
leftIcon={<LinkChainIcon />}
|
||||
>
|
||||
{project.subDomain}
|
||||
</Button>
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Card */}
|
||||
|
||||
@@ -129,12 +129,15 @@ const OverviewTabPanel = () => {
|
||||
<Heading className="text-lg leading-6 font-medium truncate">
|
||||
{project.name}
|
||||
</Heading>
|
||||
<a
|
||||
href={`https://${project.subDomain}`}
|
||||
className="text-sm text-elements-low-em tracking-tight truncate"
|
||||
>
|
||||
{project.subDomain}
|
||||
</a>
|
||||
{project.baseDomains && project.baseDomains.length > 0 && project.baseDomains.map((baseDomain, index) => (
|
||||
<a
|
||||
key={index}
|
||||
href={`https://${project.name}.${baseDomain}`}
|
||||
className="text-sm text-elements-low-em tracking-tight truncate"
|
||||
>
|
||||
{baseDomain}
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<OverviewInfo label="Domain" icon={<GlobeIcon />}>
|
||||
|
||||
@@ -102,7 +102,7 @@ export const deployment0: Deployment = {
|
||||
domain: domain0,
|
||||
commitMessage: 'Commit Message',
|
||||
createdBy: user,
|
||||
deployerLrn: 'lrn://deepstack-test4/deployers/webapp-deployer-api.test4.wireitin.com',
|
||||
deployerLrn: 'lrn://deployer.apps.snowballtools.com ',
|
||||
};
|
||||
|
||||
export const project: Project = {
|
||||
@@ -121,8 +121,8 @@ export const project: Project = {
|
||||
template: 'Template',
|
||||
members: [member],
|
||||
auctionId: '7553538436710373822151221341b43f577e07b0525d083cc9b2de98890138a1',
|
||||
deployerLrns: ['lrn://deepstack-test4/deployers/webapp-deployer-api.test4.wireitin.com', 'lrn://wireitin/deployers/webapp-deployer-api.wireitin.com'],
|
||||
deployerLrns: ['lrn://deployer.apps.snowballtools.com '],
|
||||
webhooks: ['beepboop'],
|
||||
icon: 'Icon',
|
||||
subDomain: 'SubDomain',
|
||||
baseDomains: ['baseDomain'],
|
||||
};
|
||||
Vendored
+2
-1
@@ -94,6 +94,7 @@ type Deployment = {
|
||||
deployerLrn: string;
|
||||
environment: Environment;
|
||||
isCurrent: boolean;
|
||||
baseDomain?: string;
|
||||
status: DeploymentStatus;
|
||||
createdBy: User;
|
||||
createdAt: string;
|
||||
@@ -158,7 +159,7 @@ type Project = {
|
||||
updatedAt: string;
|
||||
organization: Organization;
|
||||
icon: string;
|
||||
subDomain: string;
|
||||
baseDomains?: string[] | null;
|
||||
};
|
||||
type GetProjectMembersResponse = {
|
||||
projectMembers: ProjectMember[];
|
||||
|
||||
Vendored
+2
-1
@@ -94,6 +94,7 @@ type Deployment = {
|
||||
deployerLrn: string;
|
||||
environment: Environment;
|
||||
isCurrent: boolean;
|
||||
baseDomain?: string;
|
||||
status: DeploymentStatus;
|
||||
createdBy: User;
|
||||
createdAt: string;
|
||||
@@ -158,7 +159,7 @@ type Project = {
|
||||
updatedAt: string;
|
||||
organization: Organization;
|
||||
icon: string;
|
||||
subDomain: string;
|
||||
baseDomains?: string[] | null;
|
||||
};
|
||||
type GetProjectMembersResponse = {
|
||||
projectMembers: ProjectMember[];
|
||||
|
||||
Vendored
+5
-2
@@ -83,7 +83,7 @@ query ($projectId: String!) {
|
||||
repository
|
||||
webhooks
|
||||
icon
|
||||
subDomain
|
||||
baseDomains
|
||||
organization {
|
||||
id
|
||||
name
|
||||
@@ -97,6 +97,7 @@ query ($projectId: String!) {
|
||||
id
|
||||
branch
|
||||
isCurrent
|
||||
baseDomain
|
||||
status
|
||||
updatedAt
|
||||
commitHash
|
||||
@@ -133,11 +134,12 @@ query ($organizationSlug: String!) {
|
||||
repository
|
||||
updatedAt
|
||||
icon
|
||||
subDomain
|
||||
baseDomains
|
||||
deployments {
|
||||
id
|
||||
branch
|
||||
isCurrent
|
||||
baseDomain
|
||||
status
|
||||
updatedAt
|
||||
commitHash
|
||||
@@ -186,6 +188,7 @@ query ($projectId: String!) {
|
||||
deployerLrn
|
||||
environment
|
||||
isCurrent
|
||||
baseDomain
|
||||
status
|
||||
createdAt
|
||||
updatedAt
|
||||
|
||||
+1
-1
@@ -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 {\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<NormalizedCacheObject>;\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<types.GetUserResponse> {\n const { data } = await this.client.query({\n query: queries.getUser,\n });\n\n return data;\n }\n\n async getProject(projectId: string): Promise<types.GetProjectResponse> {\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<types.GetProjectsInOrganizationResponse> {\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<types.GetOrganizationsResponse> {\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<types.GetDeploymentsResponse> {\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<types.GetEnvironmentVariablesResponse> {\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<types.GetProjectMembersResponse> {\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<types.AddProjectMemberResponse> {\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<types.UpdateProjectMemberResponse> {\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<types.RemoveProjectMemberResponse> {\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<types.SearchProjectsResponse> {\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<types.AddEnvironmentVariablesResponse> {\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<types.UpdateEnvironmentVariableResponse> {\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<types.RemoveEnvironmentVariableResponse> {\n const { data } = await thisLine truncated
|
||||
{"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<NormalizedCacheObject>;\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<types.GetUserResponse> {\n const { data } = await this.client.query({\n query: queries.getUser,\n });\n\n return data;\n }\n\n async getProject(projectId: string): Promise<types.GetProjectResponse> {\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<types.GetProjectsInOrganizationResponse> {\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<types.GetOrganizationsResponse> {\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<types.GetDeploymentsResponse> {\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<types.GetEnvironmentVariablesResponse> {\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<types.GetProjectMembersResponse> {\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<types.AddProjectMemberResponse> {\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<types.UpdateProjectMemberResponse> {\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<types.RemoveProjectMemberResponse> {\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<types.SearchProjectsResponse> {\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<types.AddEnvironmentVariablesResponse> {\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<types.UpdateEnvironmentVariableResponse> {\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<types.RemoveEnvironmentVariableResponse> {\n const { data } = await thisLine truncated
|
||||
Vendored
+5
-2
@@ -55,7 +55,7 @@ query ($projectId: String!) {
|
||||
repository
|
||||
webhooks
|
||||
icon
|
||||
subDomain
|
||||
baseDomains
|
||||
organization {
|
||||
id
|
||||
name
|
||||
@@ -69,6 +69,7 @@ query ($projectId: String!) {
|
||||
id
|
||||
branch
|
||||
isCurrent
|
||||
baseDomain
|
||||
status
|
||||
updatedAt
|
||||
commitHash
|
||||
@@ -105,11 +106,12 @@ query ($organizationSlug: String!) {
|
||||
repository
|
||||
updatedAt
|
||||
icon
|
||||
subDomain
|
||||
baseDomains
|
||||
deployments {
|
||||
id
|
||||
branch
|
||||
isCurrent
|
||||
baseDomain
|
||||
status
|
||||
updatedAt
|
||||
commitHash
|
||||
@@ -158,6 +160,7 @@ query ($projectId: String!) {
|
||||
deployerLrn
|
||||
environment
|
||||
isCurrent
|
||||
baseDomain
|
||||
status
|
||||
createdAt
|
||||
updatedAt
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"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<NormalizedCacheObject>;\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<types.GetUserResponse> {\n const { data } = await this.client.query({\n query: queries.getUser,\n });\n\n return data;\n }\n\n async getProject(projectId: string): Promise<types.GetProjectResponse> {\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<types.GetProjectsInOrganizationResponse> {\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<types.GetOrganizationsResponse> {\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<types.GetDeploymentsResponse> {\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<types.GetEnvironmentVariablesResponse> {\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<types.GetProjectMembersResponse> {\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<types.AddProjectMemberResponse> {\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<types.UpdateProjectMemberResponse> {\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<types.RemoveProjectMemberResponse> {\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<types.SearchProjectsResponse> {\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<types.AddEnvironmentVariablesResponse> {\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<types.UpdateEnvironmentVariableResponse> {\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<types.RemoveEnvironmentVariableResponse> {\n const { data } = await this.client.mutate({\n mutation: mutations.removeEnvironmentVariable,\n Line truncated
|
||||
{"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<NormalizedCacheObject>;\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<types.GetUserResponse> {\n const { data } = await this.client.query({\n query: queries.getUser,\n });\n\n return data;\n }\n\n async getProject(projectId: string): Promise<types.GetProjectResponse> {\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<types.GetProjectsInOrganizationResponse> {\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<types.GetOrganizationsResponse> {\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<types.GetDeploymentsResponse> {\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<types.GetEnvironmentVariablesResponse> {\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<types.GetProjectMembersResponse> {\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<types.AddProjectMemberResponse> {\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<types.UpdateProjectMemberResponse> {\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<types.RemoveProjectMemberResponse> {\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<types.SearchProjectsResponse> {\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<types.AddEnvironmentVariablesResponse> {\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<types.UpdateEnvironmentVariableResponse> {\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<types.RemoveEnvironmentVariableResponse> {\n const { data } = await this.client.mutate({\n mutation: mutations.removeEnvironmentVariable,\n Line truncated
|
||||
@@ -29,7 +29,7 @@ query ($projectId: String!) {
|
||||
repository
|
||||
webhooks
|
||||
icon
|
||||
subDomain
|
||||
baseDomains
|
||||
organization {
|
||||
id
|
||||
name
|
||||
@@ -43,6 +43,7 @@ query ($projectId: String!) {
|
||||
id
|
||||
branch
|
||||
isCurrent
|
||||
baseDomain
|
||||
status
|
||||
updatedAt
|
||||
commitHash
|
||||
@@ -80,11 +81,12 @@ query ($organizationSlug: String!) {
|
||||
repository
|
||||
updatedAt
|
||||
icon
|
||||
subDomain
|
||||
baseDomains
|
||||
deployments {
|
||||
id
|
||||
branch
|
||||
isCurrent
|
||||
baseDomain
|
||||
status
|
||||
updatedAt
|
||||
commitHash
|
||||
@@ -135,6 +137,7 @@ query ($projectId: String!) {
|
||||
deployerLrn
|
||||
environment
|
||||
isCurrent
|
||||
baseDomain
|
||||
status
|
||||
createdAt
|
||||
updatedAt
|
||||
|
||||
@@ -108,6 +108,7 @@ export type Deployment = {
|
||||
deployerLrn: string;
|
||||
environment: Environment;
|
||||
isCurrent: boolean;
|
||||
baseDomain?: string;
|
||||
status: DeploymentStatus;
|
||||
createdBy: User;
|
||||
createdAt: string;
|
||||
@@ -177,7 +178,7 @@ export type Project = {
|
||||
updatedAt: string;
|
||||
organization: Organization;
|
||||
icon: string;
|
||||
subDomain: string;
|
||||
baseDomains?: string[] | null;
|
||||
};
|
||||
|
||||
export type GetProjectMembersResponse = {
|
||||
|
||||
Reference in new issue
Block a user