Skip to content

Commit

Permalink
try this
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicamcinchak committed Sep 27, 2023
1 parent 62bd968 commit b743d20
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 13 deletions.
32 changes: 22 additions & 10 deletions src/export/digitalPlanning/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { DigitalPlanningDataSchema as DigitalPlanningPayload } from "./schema/ty
export async function generateDigitalPlanningPayload(
client: GraphQLClient,
sessionId: string,
validate?: boolean,
): Promise<DigitalPlanningPayload> {
const session = await getSessionById(client, sessionId);
if (!session) throw Error(`No session found matching ID ${sessionId}`);
Expand All @@ -18,13 +17,26 @@ export async function generateDigitalPlanningPayload(

const passport = new Passport(session.data.passport);

return validate
? new DigitalPlanning({
sessionId,
passport,
}).getPayload()
: new DigitalPlanning({
sessionId,
passport,
}).getPayloadWithoutValidation();
return new DigitalPlanning({
sessionId,
passport,
}).getPayload();
}

export async function generateDigitalPlanningPayloadWithoutValidation(
client: GraphQLClient,
sessionId: string,
): Promise<DigitalPlanningPayload> {
const session = await getSessionById(client, sessionId);
if (!session) throw Error(`No session found matching ID ${sessionId}`);

if (!session.data.passport?.data)
throw Error(`Data missing from passport for session ${sessionId}`);

const passport = new Passport(session.data.passport);

return new DigitalPlanning({
sessionId,
passport,
}).getPayloadWithoutValidation();
}
18 changes: 15 additions & 3 deletions src/requests/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import { GraphQLClient } from "graphql-request";

import { computeBOPSParams } from "../export/bops";
import { computeCSVData } from "../export/csv";
import { generateDigitalPlanningPayload } from "../export/digitalPlanning";
import {
generateDigitalPlanningPayload,
generateDigitalPlanningPayloadWithoutValidation,
} from "../export/digitalPlanning";
import { DigitalPlanningDataSchema } from "../export/digitalPlanning/schema/types";
import type { BOPSExportData, ExportData } from "../types";
import { findPublishedFlowBySessionId, getFlowName } from "./flow";
Expand All @@ -25,9 +28,18 @@ export class ExportClient {

digitalPlanningDataPayload(
sessionId: string,
validate?: boolean,
): Promise<DigitalPlanningDataSchema> {
return generateDigitalPlanningPayload(this.client, sessionId, validate);
return generateDigitalPlanningPayload(this.client, sessionId);
}

/** Temp export for testing */
digitalPlanningDataPayloadWithoutValidation(
sessionId: string,
): Promise<DigitalPlanningDataSchema> {
return generateDigitalPlanningPayloadWithoutValidation(
this.client,
sessionId,
);
}
}

Expand Down

0 comments on commit b743d20

Please sign in to comment.