From 60803c600cb714ae29e7848e1ce731c019c1ce8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dafydd=20Ll=C5=B7r=20Pearson?= Date: Thu, 2 Nov 2023 22:29:39 +0000 Subject: [PATCH] chore: Linting --- api.planx.uk/admin/session/summary.ts | 6 ++++-- api.planx.uk/editor/findReplace.ts | 12 +++++++----- api.planx.uk/editor/moveFlow.ts | 4 ++-- api.planx.uk/editor/publish.test.ts | 4 ++-- api.planx.uk/editor/publish.ts | 7 +++---- api.planx.uk/helpers.ts | 17 ++++++++++------- api.planx.uk/inviteToPay/paymentRequest.ts | 17 +++++++++-------- api.planx.uk/modules/analytics/service.ts | 2 +- .../sanitiseApplicationData/operations.test.ts | 10 +++++++--- .../sanitiseApplicationData/operations.ts | 8 +++++--- api.planx.uk/send/helpers.ts | 2 +- 11 files changed, 51 insertions(+), 38 deletions(-) diff --git a/api.planx.uk/admin/session/summary.ts b/api.planx.uk/admin/session/summary.ts index 97a1902985..e62ddd11b9 100644 --- a/api.planx.uk/admin/session/summary.ts +++ b/api.planx.uk/admin/session/summary.ts @@ -7,7 +7,7 @@ import { NextFunction, Request, Response } from "express"; import { gql } from "graphql-request"; import { Breadcrumb, Flow, LowCalSession, Passport, Team } from "../../types"; -import { $api } from '../../client'; +import { $api } from "../../client"; /** * @swagger @@ -73,7 +73,9 @@ interface SessionSummary { const getSessionSummaryById = async ( sessionId: Session["id"], ): Promise => { - const { session } = await $api.client.request>( + const { session } = await $api.client.request< + Record<"session", SessionSummary | null> + >( gql` query GetSessionSummary($sessionId: uuid!) { session: lowcal_sessions_by_pk(id: $sessionId) { diff --git a/api.planx.uk/editor/findReplace.ts b/api.planx.uk/editor/findReplace.ts index 81cbee2d9b..a0beaae8eb 100644 --- a/api.planx.uk/editor/findReplace.ts +++ b/api.planx.uk/editor/findReplace.ts @@ -54,9 +54,9 @@ interface UpdateFlow { flow: { id: string; slug: string; - data: FlowGraph + data: FlowGraph; updatedAt: string; - } + }; } /** @@ -150,7 +150,10 @@ const findAndReplaceInFlow = async ( const response = await $client.request( gql` mutation UpdateFlow($data: jsonb = {}, $id: uuid!) { - flow: update_flows_by_pk(pk_columns: { id: $id }, _set: { data: $data }) { + flow: update_flows_by_pk( + pk_columns: { id: $id } + _set: { data: $data } + ) { id slug data @@ -164,8 +167,7 @@ const findAndReplaceInFlow = async ( }, ); - const updatedFlow = - response.flow && response.flow.data; + const updatedFlow = response.flow && response.flow.data; res.json({ message: `Found ${ diff --git a/api.planx.uk/editor/moveFlow.ts b/api.planx.uk/editor/moveFlow.ts index 9c7a0c9bbd..0135f81f37 100644 --- a/api.planx.uk/editor/moveFlow.ts +++ b/api.planx.uk/editor/moveFlow.ts @@ -37,7 +37,7 @@ const moveFlow = async ( }; interface GetTeam { - teams: Pick[] + teams: Pick[]; } const getTeamIdBySlug = async (slug: Team["slug"]): Promise => { @@ -58,7 +58,7 @@ const getTeamIdBySlug = async (slug: Team["slug"]): Promise => { }; interface UpdateFlow { - flow: Pick + flow: Pick; } const updateFlow = async ( diff --git a/api.planx.uk/editor/publish.test.ts b/api.planx.uk/editor/publish.test.ts index 930155351f..41f6165887 100644 --- a/api.planx.uk/editor/publish.test.ts +++ b/api.planx.uk/editor/publish.test.ts @@ -15,7 +15,7 @@ beforeAll(() => { jwt: getJWT({ role: "teamEditor" }), }, }); -}) +}); beforeEach(() => { queryMock.mockQuery({ @@ -119,7 +119,7 @@ describe("publish", () => { await supertest(app) .post("/flows/1/publish") .set(auth) - // .expect(200) + .expect(200) .then((res) => { expect(res.body).toEqual({ alteredNodes: [ diff --git a/api.planx.uk/editor/publish.ts b/api.planx.uk/editor/publish.ts index 72004d50bf..ca4d8976f6 100644 --- a/api.planx.uk/editor/publish.ts +++ b/api.planx.uk/editor/publish.ts @@ -75,8 +75,8 @@ interface PublishFlow { flowId: string; publisherId: string; createdAt: string; - data: FlowGraph - } + data: FlowGraph; + }; } const publishFlow = async ( @@ -127,8 +127,7 @@ const publishFlow = async ( ); const publishedFlow = - response.publishedFlow && - response.publishedFlow.data; + response.publishedFlow && response.publishedFlow.data; const alteredNodes = Object.keys(delta).map((key) => ({ id: key, diff --git a/api.planx.uk/helpers.ts b/api.planx.uk/helpers.ts index b088aeab3d..47e38c9be2 100644 --- a/api.planx.uk/helpers.ts +++ b/api.planx.uk/helpers.ts @@ -7,7 +7,7 @@ import { $public, getClient } from "./client"; // Get a flow's data (unflattened, without external portal nodes) const getFlowData = async (id: string): Promise => { const { client: $client } = getClient(); - const { flow } = await $client.request<{ flow: Flow | null}>( + const { flow } = await $client.request<{ flow: Flow | null }>( gql` query GetFlowData($id: uuid!) { flow: flows_by_pk(id: $id) { @@ -94,9 +94,9 @@ interface PublishedFlows { flow: { publishedFlows: { // TODO: use FlowGraph from planx-core here - data: Flow["data"] - }[] - } | null + data: Flow["data"]; + }[]; + } | null; } // Get the most recent version of a published flow's data (flattened, with external portal nodes) @@ -107,7 +107,10 @@ const getMostRecentPublishedFlow = async ( gql` query GetMostRecentPublishedFlow($id: uuid!) { flow: flows_by_pk(id: $id) { - publishedFlows: published_flows(limit: 1, order_by: { created_at: desc }) { + publishedFlows: published_flows( + limit: 1 + order_by: { created_at: desc } + ) { data } } @@ -115,10 +118,10 @@ const getMostRecentPublishedFlow = async ( `, { id }, ); - + const mostRecent = flow?.publishedFlows?.[0]?.data; if (!mostRecent) throw Error(`Published flow not found for flow ${id}`); - + return mostRecent; }; diff --git a/api.planx.uk/inviteToPay/paymentRequest.ts b/api.planx.uk/inviteToPay/paymentRequest.ts index 7658e62cd7..39d6321afa 100644 --- a/api.planx.uk/inviteToPay/paymentRequest.ts +++ b/api.planx.uk/inviteToPay/paymentRequest.ts @@ -6,7 +6,7 @@ import { fetchPaymentViaProxyWithCallback, } from "../pay"; import { GovUKPayment } from "@opensystemslab/planx-core/types"; -import { $api } from '../client'; +import { $api } from "../client"; interface GetPaymentRequestDetails { paymentRequest: { @@ -16,11 +16,11 @@ interface GetPaymentRequestDetails { flowId: string; flow: { team: { - slug: string - } - } + slug: string; + }; + }; }; - } | null + } | null; } // middleware used by routes: @@ -47,9 +47,10 @@ export async function fetchPaymentRequestDetails( } } `; - const { paymentRequest } = await $api.client.request(query, { - paymentRequestId: req.params.paymentRequest, - }); + const { paymentRequest } = + await $api.client.request(query, { + paymentRequestId: req.params.paymentRequest, + }); if (!paymentRequest) { return next( new ServerError({ diff --git a/api.planx.uk/modules/analytics/service.ts b/api.planx.uk/modules/analytics/service.ts index f55feb546f..9defd29fc5 100644 --- a/api.planx.uk/modules/analytics/service.ts +++ b/api.planx.uk/modules/analytics/service.ts @@ -6,7 +6,7 @@ interface UpdateAnalyticsLogUserExit { id: string; userExit: boolean; analyticsId: string; - } + }; } export const trackAnalyticsLogExit = async ({ diff --git a/api.planx.uk/modules/webhooks/service/sanitiseApplicationData/operations.test.ts b/api.planx.uk/modules/webhooks/service/sanitiseApplicationData/operations.test.ts index 911565a22a..c6d77a547b 100644 --- a/api.planx.uk/modules/webhooks/service/sanitiseApplicationData/operations.test.ts +++ b/api.planx.uk/modules/webhooks/service/sanitiseApplicationData/operations.test.ts @@ -35,17 +35,21 @@ jest.mock("@opensystemslab/planx-core", () => { "@opensystemslab/planx-core", ).CoreDomainClient; - const actualPassport = jest.requireActual("@opensystemslab/planx-core").Passport; + const actualPassport = jest.requireActual( + "@opensystemslab/planx-core", + ).Passport; return { Passport: actualPassport, CoreDomainClient: class extends actualCoreDomainClient { constructor() { super(); - this.session.find = jest.fn().mockImplementation(() => mockFindSession()); + this.session.find = jest + .fn() + .mockImplementation(() => mockFindSession()); } }, - } + }; }); const s3Mock = () => { diff --git a/api.planx.uk/modules/webhooks/service/sanitiseApplicationData/operations.ts b/api.planx.uk/modules/webhooks/service/sanitiseApplicationData/operations.ts index 13befc5ad8..b3c19658fd 100644 --- a/api.planx.uk/modules/webhooks/service/sanitiseApplicationData/operations.ts +++ b/api.planx.uk/modules/webhooks/service/sanitiseApplicationData/operations.ts @@ -78,10 +78,12 @@ export const getExpiredSessionIds = async (): Promise => { `; const { lowcal_sessions: sessions, - }: { lowcal_sessions: Record<"id", string>[] } = - await $api.client.request(query, { + }: { lowcal_sessions: Record<"id", string>[] } = await $api.client.request( + query, + { retentionPeriod: getRetentionPeriod(), - }); + }, + ); const sessionIds = sessions.map((session) => session.id); return sessionIds; }; diff --git a/api.planx.uk/send/helpers.ts b/api.planx.uk/send/helpers.ts index 4edeeeb915..eca20463a5 100644 --- a/api.planx.uk/send/helpers.ts +++ b/api.planx.uk/send/helpers.ts @@ -1,6 +1,6 @@ import { gql } from "graphql-request"; import airbrake from "../airbrake"; -import { $api } from '../client'; +import { $api } from "../client"; export async function logPaymentStatus({ sessionId,