Skip to content

Commit

Permalink
rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicamcinchak committed Jul 16, 2024
2 parents 9923999 + 81fd176 commit a8128e6
Show file tree
Hide file tree
Showing 319 changed files with 15,200 additions and 7,981 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,8 @@ UNIFORM_CLIENT_AYLESBURY_VALE=👻
UNIFORM_CLIENT_CHILTERN=👻
UNIFORM_CLIENT_WYCOMBE=👻

## Forthcoming Idox Nexus integration
IDOX_NEXUS_CLIENT=👻

## End-to-end test team (borrows Lambeth's details)
GOV_UK_PAY_SECRET_E2E=👻
12 changes: 6 additions & 6 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ updates:
- "theopensystemslab/planx"
ignore:
- dependency-name: "*"
update-types: ["version-update:semver-patch"]
update-types: ["version-update:semver-patch", "version-update:semver-minor"]

# Hasura
- package-ecosystem: "npm"
Expand All @@ -38,7 +38,7 @@ updates:
- "theopensystemslab/planx"
ignore:
- dependency-name: "*"
update-types: ["version-update:semver-patch"]
update-types: ["version-update:semver-patch", "version-update:semver-minor"]

- package-ecosystem: "docker"
directory: "/hasura.planx.uk"
Expand Down Expand Up @@ -76,7 +76,7 @@ updates:
- "theopensystemslab/planx"
ignore:
- dependency-name: "*"
update-types: ["version-update:semver-patch"]
update-types: ["version-update:semver-patch", "version-update:semver-minor"]

# ShareDB
- package-ecosystem: "npm"
Expand All @@ -90,7 +90,7 @@ updates:
- "theopensystemslab/planx"
ignore:
- dependency-name: "*"
update-types: ["version-update:semver-patch"]
update-types: ["version-update:semver-patch", "version-update:semver-minor"]

- package-ecosystem: "docker"
directory: "/sharedb.planx.uk"
Expand All @@ -115,7 +115,7 @@ updates:
- "theopensystemslab/planx"
ignore:
- dependency-name: "*"
update-types: ["version-update:semver-patch"]
update-types: ["version-update:semver-patch", "version-update:semver-minor"]

- package-ecosystem: "docker"
directory: "/api.planx.uk"
Expand All @@ -142,7 +142,7 @@ updates:
- "theopensystemslab/planx"
ignore:
- dependency-name: "*"
update-types: ["version-update:semver-patch"]
update-types: ["version-update:semver-patch", "version-update:semver-minor"]

# Infrastructure
# - package-ecosystem: "npm"
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/pizza-teardown-manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
inputs:
pull_request_id:
required: true
type: integer
type: number
description: Pull Request number which should have its pizza destroyed

env:
Expand All @@ -20,4 +20,8 @@ jobs:
action: destroy
api_key: ${{ secrets.VULTR_API_KEY }}
domain: ${{ env.DOMAIN }}
pullrequest_id: ${{ github.event.inputs.pull_request_id }}
os_type: alpine
plan: vc2-1c-1gb
pull_request_id: ${{ github.event.inputs.pull_request_id }}
region: lhr
tag: manual-teardown
2 changes: 1 addition & 1 deletion .github/workflows/pizza-teardown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
action: destroy
api_key: ${{ secrets.VULTR_API_KEY }}
domain: ${{ env.DOMAIN }}
os_type: ubuntu
os_type: alpine
plan: vc2-1c-1gb
pull_request_id: ${{ env.PULLREQUEST_ID }}
region: lhr
Expand Down
24 changes: 18 additions & 6 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ jobs:
action: create
api_key: ${{ secrets.VULTR_API_KEY }}
domain: ${{ env.DOMAIN }}
os_type: ubuntu
os_type: alpine
plan: vc2-1c-1gb
pull_request_id: ${{ env.PULLREQUEST_ID }}
region: lhr
Expand All @@ -324,13 +324,19 @@ jobs:
password: ${{ steps.create.outputs.default_password }}
command_timeout: 20m
script: |
apt-get update -y
apk update
apk add docker
addgroup root docker
rc-update add docker default
service docker start
apk add docker-cli-compose
apk add git
git clone "${{ secrets.AUTHENTICATED_REPO_URL }}"
cd planx-new
git fetch origin "pull/${{ env.PULLREQUEST_ID }}/head" && git checkout FETCH_HEAD
apt-get install awscli -y
apk add aws-cli
export AWS_ACCESS_KEY_ID=${{ secrets.PIZZA_AWS_ACCESS_KEY_ID }}
export AWS_SECRET_ACCESS_KEY=${{ secrets.PIZZA_AWS_SECRET_ACCESS_KEY }}
export AWS_REGION=eu-west-2
Expand All @@ -352,15 +358,21 @@ jobs:
username: root
password: ${{ secrets.SSH_PASSWORD }}
command_timeout: 10m
# TODO: some of below script might be superfluous for server update (rather than create)
script: |
apt-get update -y
apk update
apk add docker
addgroup root docker
rc-update add docker default
service docker start
apk add docker-cli-compose
git clone "${{ secrets.AUTHENTICATED_REPO_URL }}"
cd planx-new
git add . && git stash
git fetch origin "pull/${{ env.PULLREQUEST_ID }}/head" && git checkout FETCH_HEAD
apt-get install awscli -y
apk add aws-cli
export AWS_ACCESS_KEY_ID=${{ secrets.PIZZA_AWS_ACCESS_KEY_ID }}
export AWS_SECRET_ACCESS_KEY=${{ secrets.PIZZA_AWS_SECRET_ACCESS_KEY }}
export AWS_REGION=eu-west-2
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ api.planx.uk/tmp/
# Ignore certificate files
**/*.chain
**/*.cert
**/*.crt
**/*.key
**/*.pfx
**/*.pkcs12
Expand Down
6 changes: 6 additions & 0 deletions api.planx.uk/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { $public, getClient } from "./client";

export interface FlowData {
slug: string;
name: string;
data: Flow["data"];
team_id: number;
team: { slug: string };
Expand All @@ -28,6 +29,7 @@ const getFlowData = async (id: string): Promise<FlowData> => {
flow: flows_by_pk(id: $id) {
slug
data
name
team_id
team {
slug
Expand Down Expand Up @@ -62,6 +64,7 @@ interface InsertFlow {
const insertFlow = async (
teamId: number,
slug: string,
name: string,
flowData: Flow["data"],
creatorId?: number,
copiedFrom?: Flow["id"],
Expand All @@ -75,6 +78,7 @@ const insertFlow = async (
mutation InsertFlow(
$team_id: Int!
$slug: String!
$name: String!
$data: jsonb = {}
$creator_id: Int
$copied_from: uuid
Expand All @@ -83,6 +87,7 @@ const insertFlow = async (
object: {
team_id: $team_id
slug: $slug
name: $name
data: $data
version: 1
creator_id: $creator_id
Expand All @@ -96,6 +101,7 @@ const insertFlow = async (
{
team_id: teamId,
slug: slug,
name: name,
data: flowData,
creator_id: creatorId,
copied_from: copiedFrom,
Expand Down
1 change: 1 addition & 0 deletions api.planx.uk/lib/hasura/metadata/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface ScheduledEvent {
export interface CombinedResponse {
bops?: ScheduledEventResponse;
uniform?: ScheduledEventResponse;
idox?: ScheduledEventResponse;
email?: ScheduledEventResponse;
s3?: ScheduledEventResponse;
}
Expand Down
4 changes: 1 addition & 3 deletions api.planx.uk/modules/admin/session/digitalPlanningData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ export const getDigitalPlanningApplicationPayload = async (
return res.send(data);
} catch (error) {
return next({
message:
"Failed to make Digital Planning Application payload: " +
(error as Error).message,
message: `Failed to make Digital Planning Application payload: ${error}. Stack: ${(error as Error).stack}`,
});
}
};
9 changes: 2 additions & 7 deletions api.planx.uk/modules/admin/session/summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,12 @@ import {
GovUKPayment,
PaymentRequest,
Session,
Team,
} from "@opensystemslab/planx-core/types";
import { NextFunction, Request, Response } from "express";
import { gql } from "graphql-request";

import {
Breadcrumb,
Flow,
LowCalSession,
Passport,
Team,
} from "../../../types";
import { Breadcrumb, Flow, LowCalSession, Passport } from "../../../types";
import { $api } from "../../../client";

/**
Expand Down
2 changes: 2 additions & 0 deletions api.planx.uk/modules/flows/copyFlow/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ const copyFlow = async (
// Check if copied flow data should be inserted into `flows` table, or just returned for reference
if (insert) {
const newSlug = flow.slug + "-copy";
const newName = flow.name + " (copy)";
const creatorId = userContext.getStore()?.user?.sub;
if (!creatorId) throw Error("User details missing from request");

// Insert the flow and an associated operation
await insertFlow(
flow.team_id,
newSlug,
newName,
uniqueFlowData,
parseInt(creatorId),
flowId,
Expand Down
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
3 changes: 2 additions & 1 deletion api.planx.uk/modules/flows/moveFlow/service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { gql } from "graphql-request";
import { Flow, Team } from "../../../types";
import { Flow } from "../../../types";
import { $public, getClient } from "../../../client";
import { Team } from "@opensystemslab/planx-core/types";

export const moveFlow = async (flowId: string, teamSlug: string) => {
const team = await $public.team.getBySlug(teamSlug);
Expand Down
2 changes: 1 addition & 1 deletion api.planx.uk/modules/flows/validate/controller.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Node } from "@opensystemslab/planx-core/types";
import { ValidatedRequestHandler } from "../../../shared/middleware/validate";
import { z } from "zod";
import { validateAndDiffFlow } from "./service";
import { validateAndDiffFlow } from "./service/index";
import { ServerError } from "../../../errors";

interface ValidateAndDiffResponse {
Expand Down
51 changes: 51 additions & 0 deletions api.planx.uk/modules/flows/validate/helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import {
ComponentType,
FlowGraph,
Node,
} from "@opensystemslab/planx-core/types";
import { Entry } from "type-fest";

export const isComponentType = (
entry: Entry<FlowGraph>,
type: ComponentType,
): entry is [string, Node] => {
const [nodeId, node] = entry;
if (nodeId === "_root") return false;
return Boolean(node?.type === type);
};

export const hasComponentType = (
flowGraph: FlowGraph,
type: ComponentType,
fn?: string,
): boolean => {
const nodeIds = Object.entries(flowGraph).filter(
(entry): entry is [string, Node] => isComponentType(entry, type),
);
if (fn) {
nodeIds
?.filter(([_nodeId, nodeData]) => nodeData?.data?.fn === fn)
?.map(([nodeId, _nodeData]) => nodeId);
} else {
nodeIds?.map(([nodeId, _nodeData]) => nodeId);
}
return Boolean(nodeIds?.length);
};

export const numberOfComponentType = (
flowGraph: FlowGraph,
type: ComponentType,
fn?: string,
): number => {
const nodeIds = Object.entries(flowGraph).filter(
(entry): entry is [string, Node] => isComponentType(entry, type),
);
if (fn) {
nodeIds
?.filter(([_nodeId, nodeData]) => nodeData?.data?.fn === fn)
?.map(([nodeId, _nodeData]) => nodeId);
} else {
nodeIds?.map(([nodeId, _nodeData]) => nodeId);
}
return nodeIds?.length;
};
Loading

0 comments on commit a8128e6

Please sign in to comment.