From 66024266d6033ee10dcb9bbd96c313849ac6093d Mon Sep 17 00:00:00 2001 From: Tai Kamilla Date: Mon, 9 Oct 2023 09:38:44 +0200 Subject: [PATCH] =?UTF-8?q?Clean=20=F0=9F=A7=BC=20=F0=9F=A7=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/routes/proxy/index.ts | 1 - src/schema/query/index.ts | 2 - src/schema/query/people.query.ts | 45 ------------------- src/schema/types/people.type.ts | 24 ---------- src/utils/files/getRowsFromMeta.ts | 1 - src/utils/form/getFieldType.ts | 2 - src/utils/form/metadata.helper.ts | 1 - .../schema/introspection/getFieldType.ts | 3 -- .../resolvers/Meta/getMetaFieldResolver.ts | 4 -- .../resolvers/Meta/getMetaPeopleResolver.ts | 23 ---------- 10 files changed, 106 deletions(-) delete mode 100644 src/schema/query/people.query.ts delete mode 100644 src/schema/types/people.type.ts delete mode 100644 src/utils/schema/resolvers/Meta/getMetaPeopleResolver.ts diff --git a/src/routes/proxy/index.ts b/src/routes/proxy/index.ts index 68a7169dc..d29b105ab 100644 --- a/src/routes/proxy/index.ts +++ b/src/routes/proxy/index.ts @@ -181,7 +181,6 @@ router.all('/:name/**', async (req, res) => { $or: [{ name: req.params.name }, { id: req.params.name }], status: 'active', }).select('name authType endpoint settings id'); - if (!api) { return res.status(404).send(i18next.t('common.errors.dataNotFound')); } diff --git a/src/schema/query/index.ts b/src/schema/query/index.ts index 12d78d29b..6b0fc5925 100644 --- a/src/schema/query/index.ts +++ b/src/schema/query/index.ts @@ -10,7 +10,6 @@ import recordsAggregation from './recordsAggregation.query'; import dashboards from './dashboards.query'; import dashboard from './dashboard.query'; import users from './users.query'; -import people from './people.query'; import me from './me.query'; import role from './role.query'; import roles from './roles.query'; @@ -73,7 +72,6 @@ const Query = new GraphQLObjectType({ steps, user, users, - people, workflow, workflows, positionAttributes, diff --git a/src/schema/query/people.query.ts b/src/schema/query/people.query.ts deleted file mode 100644 index 61918bafb..000000000 --- a/src/schema/query/people.query.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { GraphQLList, GraphQLError, GraphQLID } from 'graphql'; -import { PeopleType } from '../types/people.type'; -import { logger } from '@services/logger.service'; - -/** Temporary test mocked people awaiting for real data */ -export const MockedPeople = [ - { - _id: '5f9a9b9b9b9b9b9b9b9b9b9b', - emailaddress: 'JohnDoe@test.com', - firstname: 'John', - lastname: 'Doe', - oid: '5f9a9b9b9b9b9b9b9b9b9b9b', - }, - { - _id: '6f9a9b9b9b9b9b9b9b9b9b9b', - emailaddress: 'JaneDoe@test.com', - firstname: 'Jane', - lastname: 'Doe', - oid: '6f9a9b9b9b9b9b9b9b9b9b9b', - }, -]; - -/** - * People mock query - */ -export default { - type: new GraphQLList(PeopleType), - args: { - applications: { type: new GraphQLList(GraphQLID) }, - }, - resolve(parent, args, context) { - try { - // return a test user - return MockedPeople; - } catch (err) { - logger.error(err.message, { stack: err.stack }); - if (err instanceof GraphQLError) { - throw new GraphQLError(err.message); - } - throw new GraphQLError( - context.i18next.t('common.errors.internalServerError') - ); - } - }, -}; diff --git a/src/schema/types/people.type.ts b/src/schema/types/people.type.ts deleted file mode 100644 index b45d4cf0c..000000000 --- a/src/schema/types/people.type.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { GraphQLObjectType, GraphQLID, GraphQLString } from 'graphql'; -import { Connection } from './pagination.type'; - -/** - * GraphQL User type. - */ -export const PeopleType = new GraphQLObjectType({ - name: 'People', - fields: () => ({ - id: { - type: GraphQLID, - resolve(parent) { - return parent._id; - }, - }, - emailaddress: { type: GraphQLString }, - firstname: { type: GraphQLString }, - lastname: { type: GraphQLString }, - oid: { type: GraphQLString }, - }), -}); - -/** User connection type */ -export const UserConnectionType = Connection(PeopleType); diff --git a/src/utils/files/getRowsFromMeta.ts b/src/utils/files/getRowsFromMeta.ts index 877df12b5..8000e0840 100644 --- a/src/utils/files/getRowsFromMeta.ts +++ b/src/utils/files/getRowsFromMeta.ts @@ -66,7 +66,6 @@ export const getRowsFromMeta = (columns: any[], records: any[]): any[] => { set(row, column.name, Array.isArray(value) ? value.join(',') : value); break; } - case 'people': case 'users': { let value: any = get(data, column.field); const choices = column.meta.field.choices || []; diff --git a/src/utils/form/getFieldType.ts b/src/utils/form/getFieldType.ts index 509a325d6..eadef92ea 100644 --- a/src/utils/form/getFieldType.ts +++ b/src/utils/form/getFieldType.ts @@ -79,8 +79,6 @@ export const getFieldType = async (question: { return 'tagbox'; case 'users': return 'users'; - case 'people': - return 'people'; case 'owner': return 'owner'; case 'geospatial': diff --git a/src/utils/form/metadata.helper.ts b/src/utils/form/metadata.helper.ts index 784d64625..d77b8caca 100644 --- a/src/utils/form/metadata.helper.ts +++ b/src/utils/form/metadata.helper.ts @@ -316,7 +316,6 @@ export const getMetaData = async ( }; break; } - case 'people': case 'users': { fieldMeta.editor = 'select'; fieldMeta.multiSelect = true; diff --git a/src/utils/schema/introspection/getFieldType.ts b/src/utils/schema/introspection/getFieldType.ts index b83d50ec0..ab48c05a2 100644 --- a/src/utils/schema/introspection/getFieldType.ts +++ b/src/utils/schema/introspection/getFieldType.ts @@ -119,9 +119,6 @@ const getFieldType = ( case 'users': { return GraphQLJSON; } - case 'people': { - return GraphQLJSON; - } case 'owner': { return GraphQLJSON; } diff --git a/src/utils/schema/resolvers/Meta/getMetaFieldResolver.ts b/src/utils/schema/resolvers/Meta/getMetaFieldResolver.ts index 7d94e5bcc..94e3b19c5 100644 --- a/src/utils/schema/resolvers/Meta/getMetaFieldResolver.ts +++ b/src/utils/schema/resolvers/Meta/getMetaFieldResolver.ts @@ -1,7 +1,6 @@ import getMetaCheckboxResolver from './getMetaCheckboxResolver'; import getMetaDropdownResolver from './getMetaDropdownResolver'; import getMetaOwnerResolver from './getMetaOwnerResolver'; -import getMetaPeopleResolver from './getMetaPeopleResolver'; import getMetaUsersResolver from './getMetaUsersResolver'; import getMetaRadioResolver from './getMetaRadiogroupResolver'; import getMetaTagboxResolver from './getMetaTagboxResolver'; @@ -26,9 +25,6 @@ const getMetaFieldResolver = (field: any) => { case 'tagbox': { return getMetaTagboxResolver(field); } - case 'people': { - return getMetaPeopleResolver(field); - } case 'users': { return getMetaUsersResolver(field); } diff --git a/src/utils/schema/resolvers/Meta/getMetaPeopleResolver.ts b/src/utils/schema/resolvers/Meta/getMetaPeopleResolver.ts deleted file mode 100644 index 219e085c9..000000000 --- a/src/utils/schema/resolvers/Meta/getMetaPeopleResolver.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { MockedPeople } from '@schema/query/people.query'; - -/** - * Return people meta resolver. - * - * @param field field definition. - * @returns people resolver. - */ -const getMetaUsersResolver = async (field: any) => { - const people = MockedPeople; - return Object.assign(field, { - choices: people - ? people.map((x) => { - return { - text: x.firstname + ', ' + x.lastname, - value: x._id, - }; - }) - : [], - }); -}; - -export default getMetaUsersResolver;