Skip to content

Commit

Permalink
xml from session not audit log, adjust platformAdmin select permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicamcinchak committed Oct 16, 2023
1 parent 7780848 commit 5f726e7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 32 deletions.
2 changes: 1 addition & 1 deletion api.planx.uk/admin/session/bops.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
35 changes: 4 additions & 31 deletions api.planx.uk/admin/session/oneAppXML.ts
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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) {
Expand All @@ -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);
}
};
15 changes: 15 additions & 0 deletions hasura.planx.uk/metadata/tables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 5f726e7

Please sign in to comment.