Skip to content

Commit

Permalink
chore: Linting
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Nov 3, 2023
1 parent 4177298 commit 60803c6
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 38 deletions.
6 changes: 4 additions & 2 deletions api.planx.uk/admin/session/summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -73,7 +73,9 @@ interface SessionSummary {
const getSessionSummaryById = async (
sessionId: Session["id"],
): Promise<SessionSummary | null> => {
const { session } = await $api.client.request<Record<"session", SessionSummary | null>>(
const { session } = await $api.client.request<
Record<"session", SessionSummary | null>
>(
gql`
query GetSessionSummary($sessionId: uuid!) {
session: lowcal_sessions_by_pk(id: $sessionId) {
Expand Down
12 changes: 7 additions & 5 deletions api.planx.uk/editor/findReplace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ interface UpdateFlow {
flow: {
id: string;
slug: string;
data: FlowGraph
data: FlowGraph;
updatedAt: string;
}
};
}

/**
Expand Down Expand Up @@ -150,7 +150,10 @@ const findAndReplaceInFlow = async (
const response = await $client.request<UpdateFlow>(
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
Expand All @@ -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 ${
Expand Down
4 changes: 2 additions & 2 deletions api.planx.uk/editor/moveFlow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const moveFlow = async (
};

interface GetTeam {
teams: Pick<Team, "id">[]
teams: Pick<Team, "id">[];
}

const getTeamIdBySlug = async (slug: Team["slug"]): Promise<Team["id"]> => {
Expand All @@ -58,7 +58,7 @@ const getTeamIdBySlug = async (slug: Team["slug"]): Promise<Team["id"]> => {
};

interface UpdateFlow {
flow: Pick<Flow, "id">
flow: Pick<Flow, "id">;
}

const updateFlow = async (
Expand Down
4 changes: 2 additions & 2 deletions api.planx.uk/editor/publish.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ beforeAll(() => {
jwt: getJWT({ role: "teamEditor" }),
},
});
})
});

beforeEach(() => {
queryMock.mockQuery({
Expand Down Expand Up @@ -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: [
Expand Down
7 changes: 3 additions & 4 deletions api.planx.uk/editor/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ interface PublishFlow {
flowId: string;
publisherId: string;
createdAt: string;
data: FlowGraph
}
data: FlowGraph;
};
}

const publishFlow = async (
Expand Down Expand Up @@ -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,
Expand Down
17 changes: 10 additions & 7 deletions api.planx.uk/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Flow> => {
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) {
Expand Down Expand Up @@ -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)
Expand All @@ -107,18 +107,21 @@ 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
}
}
}
`,
{ id },
);

const mostRecent = flow?.publishedFlows?.[0]?.data;
if (!mostRecent) throw Error(`Published flow not found for flow ${id}`);

return mostRecent;
};

Expand Down
17 changes: 9 additions & 8 deletions api.planx.uk/inviteToPay/paymentRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -16,11 +16,11 @@ interface GetPaymentRequestDetails {
flowId: string;
flow: {
team: {
slug: string
}
}
slug: string;
};
};
};
} | null
} | null;
}

// middleware used by routes:
Expand All @@ -47,9 +47,10 @@ export async function fetchPaymentRequestDetails(
}
}
`;
const { paymentRequest } = await $api.client.request<GetPaymentRequestDetails>(query, {
paymentRequestId: req.params.paymentRequest,
});
const { paymentRequest } =
await $api.client.request<GetPaymentRequestDetails>(query, {
paymentRequestId: req.params.paymentRequest,
});
if (!paymentRequest) {
return next(
new ServerError({
Expand Down
2 changes: 1 addition & 1 deletion api.planx.uk/modules/analytics/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ interface UpdateAnalyticsLogUserExit {
id: string;
userExit: boolean;
analyticsId: string;
}
};
}

export const trackAnalyticsLogExit = async ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,12 @@ export const getExpiredSessionIds = async (): Promise<string[]> => {
`;
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;
};
Expand Down
2 changes: 1 addition & 1 deletion api.planx.uk/send/helpers.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down

0 comments on commit 60803c6

Please sign in to comment.