Skip to content

Commit

Permalink
update swagger, tidy types
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicamcinchak committed Jul 8, 2024
1 parent 29e1704 commit a64b9fd
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 14 deletions.
32 changes: 26 additions & 6 deletions api.planx.uk/modules/flows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,25 @@ components:
type: array
items:
type: string
ValidationCheck:
type: object
properties:
title:
type: string
example: File types
required: true
status:
type: string
enum:
- Pass
- Fail
- Warn
- Not applicable
example: Pass
message:
type: string
example: Your flow has valid file types
required: true
responses:
CopyFlow:
content:
Expand Down Expand Up @@ -124,19 +143,20 @@ components:
properties:
message:
type: string
required: false
description:
type: string
required: false
required: true
alteredNodes:
oneOf:
- type: array
items:
$ref: "#/components/schemas/Node"
- type: "null"
updatedFlow:
$ref: "#/components/schemas/FlowData"
validationChecks:
required: false
oneOf:
- type: array
items:
$ref: "#/components/schemas/ValidationCheck"
- type: "null"
FlattenData:
content:
application/json:
Expand Down
14 changes: 6 additions & 8 deletions api.planx.uk/modules/flows/validate/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,8 @@ const validateInviteToPay = (flowGraph: FlowGraph): ValidationResponse => {
};

const inviteToPayEnabled = (flowGraph: FlowGraph): boolean => {
const payNodes = Object.entries(flowGraph).filter(
(entry): entry is [string, Node] =>
isComponentType(entry, ComponentType.Pay),
const payNodes = Object.entries(flowGraph).filter((entry) =>
isComponentType(entry, ComponentType.Pay),
);
const payNodeStatuses = payNodes.map(
([_nodeId, node]) => node?.data?.allowInviteToPay,
Expand Down Expand Up @@ -257,22 +256,21 @@ const validateFileTypes = (flowGraph: FlowGraph): ValidationResponse => {
};

const getFileUploadNodeFns = (flowGraph: FlowGraph): string[] => {
const fileUploadNodes = Object.entries(flowGraph).filter(
(entry): entry is [string, Node] =>
isComponentType(entry, ComponentType.FileUpload),
const fileUploadNodes = Object.entries(flowGraph).filter((entry) =>
isComponentType(entry, ComponentType.FileUpload),
);
return fileUploadNodes.map(([_nodeId, node]) => node.data?.fn as string);
};

const getFileUploadAndLabelNodeFns = (flowGraph: FlowGraph): string[] => {
// Exclude Upload & Label nodes used in "info-only" mode with a hidden dropzone
const uploadAndLabelNodes = Object.entries(flowGraph).filter(
(entry): entry is [string, Node] =>
(entry) =>
isComponentType(entry, ComponentType.FileUploadAndLabel) &&
entry[1].data?.hideDropZone !== true,
);
const uploadAndLabelFileTypes = uploadAndLabelNodes
.map(([_nodeId, node]) => node.data?.fileTypes)
.map(([_nodeId, node]: [string, Node]) => node.data?.fileTypes)
.flat();
return uploadAndLabelFileTypes?.map((file: any) => file?.fn as string);

Check warning on line 275 in api.planx.uk/modules/flows/validate/service.ts

View workflow job for this annotation

GitHub Actions / Run API Tests

Unexpected any. Specify a different type
};
Expand Down

0 comments on commit a64b9fd

Please sign in to comment.