From 064a212ce15aabfc70183419557f8f9bfdf686bb Mon Sep 17 00:00:00 2001 From: Jessica McInchak Date: Tue, 19 Sep 2023 16:20:42 +0200 Subject: [PATCH] wip --- .../admin/session/digitalPlanningData.ts | 35 +++++++++++++++++++ api.planx.uk/package.json | 2 +- api.planx.uk/pnpm-lock.yaml | 2 +- api.planx.uk/server.ts | 5 +++ e2e/tests/api-driven/package.json | 2 +- e2e/tests/api-driven/pnpm-lock.yaml | 2 +- e2e/tests/ui-driven/package.json | 2 +- e2e/tests/ui-driven/pnpm-lock.yaml | 2 +- editor.planx.uk/package.json | 2 +- editor.planx.uk/pnpm-lock.yaml | 2 +- 10 files changed, 48 insertions(+), 8 deletions(-) create mode 100644 api.planx.uk/admin/session/digitalPlanningData.ts diff --git a/api.planx.uk/admin/session/digitalPlanningData.ts b/api.planx.uk/admin/session/digitalPlanningData.ts new file mode 100644 index 0000000000..5c250a4624 --- /dev/null +++ b/api.planx.uk/admin/session/digitalPlanningData.ts @@ -0,0 +1,35 @@ +import { Request, Response, NextFunction } from "express"; +import { $admin } from "../../client"; + +/** + * @swagger + * /admin/session/{sessionId}/digital-planning-data: + * get: + * summary: Generates a Digital Planning Data payload + * description: Generates a Digital Planning Data payload, based on the Digital Planning Data Open API schema + * tags: + * - admin + * parameters: + * - $ref: '#/components/parameters/sessionId' + * security: + * - userJWT: [] + */ +export const getDigitalPlanningDataPayload = async ( + req: Request, + res: Response, + next: NextFunction, +) => { + try { + const { exportData } = await $admin.export.digitalPlanningDataPayload( + req.params.sessionId, + ); + res.set("content-type", "application/json"); + return res.send(exportData); + } catch (error) { + return next({ + message: + "Failed to make Digital Planning Data payload: " + + (error as Error).message, + }); + } +}; diff --git a/api.planx.uk/package.json b/api.planx.uk/package.json index 66a7c8207b..cb86ae31cd 100644 --- a/api.planx.uk/package.json +++ b/api.planx.uk/package.json @@ -4,7 +4,7 @@ "private": true, "dependencies": { "@airbrake/node": "^2.1.8", - "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#4e3d09f", + "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#f5c3ef9", "@types/isomorphic-fetch": "^0.0.36", "adm-zip": "^0.5.10", "aws-sdk": "^2.1441.0", diff --git a/api.planx.uk/pnpm-lock.yaml b/api.planx.uk/pnpm-lock.yaml index 753ac87739..d16a832ba1 100644 --- a/api.planx.uk/pnpm-lock.yaml +++ b/api.planx.uk/pnpm-lock.yaml @@ -9,7 +9,7 @@ dependencies: specifier: ^2.1.8 version: 2.1.8 '@opensystemslab/planx-core': - specifier: git+https://github.com/theopensystemslab/planx-core#4e3d09f + specifier: git+https://github.com/theopensystemslab/planx-core#f5c3ef9 version: github.com/theopensystemslab/planx-core/4e3d09f '@types/isomorphic-fetch': specifier: ^0.0.36 diff --git a/api.planx.uk/server.ts b/api.planx.uk/server.ts index 0291b8c609..2729c2ed90 100644 --- a/api.planx.uk/server.ts +++ b/api.planx.uk/server.ts @@ -79,6 +79,7 @@ import { googleStrategy } from "./modules/auth/strategy/google"; import authRoutes from "./modules/auth/routes"; import teamRoutes from "./modules/team/routes"; import { useSwaggerDocs } from "./docs"; +import { getDigitalPlanningDataPayload } from "./admin/session/digitalPlanningData"; const router = express.Router(); @@ -325,6 +326,10 @@ app.get("/admin/session/:sessionId/html", getHTMLExport); app.get("/admin/session/:sessionId/html-redacted", getRedactedHTMLExport); app.get("/admin/session/:sessionId/zip", generateZip); app.get("/admin/session/:sessionId/summary", getSessionSummary); +app.get( + "/admin/session/:sessionId/digital-planning-data", + getDigitalPlanningDataPayload, +); // XXX: leaving this in temporarily as a testing endpoint to ensure it // works correctly in staging and production diff --git a/e2e/tests/api-driven/package.json b/e2e/tests/api-driven/package.json index de91478a3e..9167dee788 100644 --- a/e2e/tests/api-driven/package.json +++ b/e2e/tests/api-driven/package.json @@ -6,7 +6,7 @@ }, "dependencies": { "@cucumber/cucumber": "^9.3.0", - "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#4e3d09f", + "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#f5c3ef9", "axios": "^1.4.0", "dotenv": "^16.3.1", "dotenv-expand": "^10.0.0", diff --git a/e2e/tests/api-driven/pnpm-lock.yaml b/e2e/tests/api-driven/pnpm-lock.yaml index 199b1e8691..27846d5b44 100644 --- a/e2e/tests/api-driven/pnpm-lock.yaml +++ b/e2e/tests/api-driven/pnpm-lock.yaml @@ -9,7 +9,7 @@ dependencies: specifier: ^9.3.0 version: 9.3.0 '@opensystemslab/planx-core': - specifier: git+https://github.com/theopensystemslab/planx-core#4e3d09f + specifier: git+https://github.com/theopensystemslab/planx-core#f5c3ef9 version: github.com/theopensystemslab/planx-core/4e3d09f axios: specifier: ^1.4.0 diff --git a/e2e/tests/ui-driven/package.json b/e2e/tests/ui-driven/package.json index eead6768e2..fdeeb65842 100644 --- a/e2e/tests/ui-driven/package.json +++ b/e2e/tests/ui-driven/package.json @@ -8,7 +8,7 @@ "postinstall": "./install-dependencies.sh" }, "dependencies": { - "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#4e3d09f", + "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#f5c3ef9", "axios": "^1.4.0", "dotenv": "^16.3.1", "eslint": "^8.44.0", diff --git a/e2e/tests/ui-driven/pnpm-lock.yaml b/e2e/tests/ui-driven/pnpm-lock.yaml index 7a9edbc70f..686e276afd 100644 --- a/e2e/tests/ui-driven/pnpm-lock.yaml +++ b/e2e/tests/ui-driven/pnpm-lock.yaml @@ -6,7 +6,7 @@ settings: dependencies: '@opensystemslab/planx-core': - specifier: git+https://github.com/theopensystemslab/planx-core#4e3d09f + specifier: git+https://github.com/theopensystemslab/planx-core#f5c3ef9 version: github.com/theopensystemslab/planx-core/4e3d09f axios: specifier: ^1.4.0 diff --git a/editor.planx.uk/package.json b/editor.planx.uk/package.json index ffec422e0c..554450667d 100644 --- a/editor.planx.uk/package.json +++ b/editor.planx.uk/package.json @@ -14,7 +14,7 @@ "@mui/styles": "^5.14.5", "@mui/utils": "^5.14.5", "@opensystemslab/map": "^0.7.5", - "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#4e3d09f", + "@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#f5c3ef9", "@tiptap/core": "^2.0.3", "@tiptap/extension-bold": "^2.0.3", "@tiptap/extension-bubble-menu": "^2.1.6", diff --git a/editor.planx.uk/pnpm-lock.yaml b/editor.planx.uk/pnpm-lock.yaml index 4625024832..341378d755 100644 --- a/editor.planx.uk/pnpm-lock.yaml +++ b/editor.planx.uk/pnpm-lock.yaml @@ -46,7 +46,7 @@ dependencies: specifier: ^0.7.5 version: 0.7.5 '@opensystemslab/planx-core': - specifier: git+https://github.com/theopensystemslab/planx-core#4e3d09f + specifier: git+https://github.com/theopensystemslab/planx-core#f5c3ef9 version: github.com/theopensystemslab/planx-core/4e3d09f(@types/react@18.2.20) '@tiptap/core': specifier: ^2.0.3