snowballtools-base/packages/gql-client/dist/index.js.map

1 line
26 KiB
Plaintext
Raw Normal View History

{"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<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 (organizationSlug: string) : 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 (projectId: string) : 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 (projectId: string) : 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 (projectId: string) : 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 (projectId: string, data: types.AddProjectMemberInput) : 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 (projectMemberId: string, data: types.UpdateProjectMemberInput): 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 (projectMemberId: string): 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 (searchText: string) : 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 (projectId: string, data: types.AddEnvironmentVariableInput[]): Promise<types.AddEnvironmentVariablesResponse> {\