diff --git a/api.planx.uk/admin/session/bops.ts b/api.planx.uk/admin/session/bops.ts index 74aa8feb0a..566d4a7683 100644 --- a/api.planx.uk/admin/session/bops.ts +++ b/api.planx.uk/admin/session/bops.ts @@ -6,7 +6,7 @@ import { getClient } from "../../client"; * /admin/session/{sessionId}/bops: * get: * summary: Generates a Back Office Planning System (BOPS) payload - * description: Generates a BOPS payload, relies on a submission record in `bops_applications` + * description: Generates a BOPS payload * tags: * - admin * parameters: diff --git a/api.planx.uk/admin/session/oneAppXML.ts b/api.planx.uk/admin/session/oneAppXML.ts index 2f95b144cc..10c2f6f7d4 100644 --- a/api.planx.uk/admin/session/oneAppXML.ts +++ b/api.planx.uk/admin/session/oneAppXML.ts @@ -1,13 +1,12 @@ -import { gql } from "graphql-request"; import { Request, Response, NextFunction } from "express"; -import { adminGraphQLClient as client } from "../../hasura"; +import { getClient } from "../../client"; /** * @swagger * /admin/session/{sessionId}/xml: * get: * summary: Generates a OneApp XML - * description: Generates a OneApp XML, relies on a submission record in `uniform_applications` + * description: Generates a OneApp XML * tags: * - admin * parameters: @@ -21,7 +20,8 @@ export const getOneAppXML = async ( next: NextFunction, ) => { try { - const xml = await fetchSessionXML(req.params.sessionId); + const $client = getClient(); + const xml = await $client.generateOneAppXML(req.params.sessionId); res.set("content-type", "text/xml"); return res.send(xml); } catch (error) { @@ -30,30 +30,3 @@ export const getOneAppXML = async ( }); } }; - -const fetchSessionXML = async (sessionId: string) => { - try { - const query = gql` - query GetMostRecentUniformApplicationBySessionID( - $submission_reference: String - ) { - uniform_applications( - where: { submission_reference: { _eq: $submission_reference } } - order_by: { created_at: desc } - limit: 1 - ) { - xml - } - } - `; - const { uniform_applications } = await client.request(query, { - submission_reference: sessionId, - }); - - if (!uniform_applications?.length) throw Error("Invalid sessionID"); - - return uniform_applications[0].xml; - } catch (error) { - throw Error("Unable to fetch session XML: " + (error as Error).message); - } -}; diff --git a/hasura.planx.uk/metadata/tables.yaml b/hasura.planx.uk/metadata/tables.yaml index 5b5f621381..34ce237f2c 100644 --- a/hasura.planx.uk/metadata/tables.yaml +++ b/hasura.planx.uk/metadata/tables.yaml @@ -528,6 +528,21 @@ - has_user_saved - sanitised_at filter: {} + - role: platformAdmin + permission: + columns: + - data + - email + - created_at + - deleted_at + - locked_at + - submitted_at + - updated_at + - flow_id + - id + - has_user_saved + - sanitised_at + filter: {} - role: public permission: columns: