Skip to content
Open
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
bacb509
move prisma to package
bryan-robitaille Oct 10, 2025
433ecf7
wip
bryan-robitaille Oct 14, 2025
5bcb1f5
wip
bryan-robitaille Oct 16, 2025
2b6023f
add missing require package
bryan-robitaille Oct 16, 2025
41564df
update git action workflows
bryan-robitaille Oct 17, 2025
6e06b73
update readme
bryan-robitaille Oct 17, 2025
a00bef4
remove generated code
bryan-robitaille Oct 17, 2025
18d2b02
ignore prisma generated code
bryan-robitaille Oct 17, 2025
2c5c841
wip
bryan-robitaille Oct 20, 2025
812017e
fix jest tests
bryan-robitaille Oct 21, 2025
695c249
fix hoisting of packages
bryan-robitaille Oct 21, 2025
25d1149
Merge branch 'main' into chore/package_prisma
bryan-robitaille Oct 21, 2025
757717f
update github action steps
bryan-robitaille Oct 21, 2025
9bc106f
fix cypress
bryan-robitaille Oct 21, 2025
d39a88b
fix import
bryan-robitaille Oct 21, 2025
aa2633a
update labeler for prisma
bryan-robitaille Oct 21, 2025
671abde
fix import for cypress config
bryan-robitaille Oct 21, 2025
289ce5f
remove package pruning as the node modules don't get copied
bryan-robitaille Oct 21, 2025
383c57b
Merge branch 'main' into chore/package_prisma
bryan-robitaille Oct 21, 2025
4f58f7d
update package.json db scripts
bryan-robitaille Oct 21, 2025
9680970
Merge branch 'chore/package_prisma' of https://github.com/cds-snc/pla…
bryan-robitaille Oct 21, 2025
a505ecb
fix imports for cypress e2e only
bryan-robitaille Oct 21, 2025
52ea83e
try relative path
bryan-robitaille Oct 21, 2025
34a113c
remove manual invoke of db seed
bryan-robitaille Oct 22, 2025
06d0cea
fix cypress multi command github action
bryan-robitaille Oct 22, 2025
4f839fc
womp womp
bryan-robitaille Oct 22, 2025
14a8859
remove @gcforms path from cypress tsconfig
bryan-robitaille Oct 22, 2025
7c9a637
small import refactors
bryan-robitaille Oct 22, 2025
6607071
Merge branch 'main' into chore/package_prisma
bryan-robitaille Oct 22, 2025
5fa51d5
update prisma client
bryan-robitaille Oct 22, 2025
1d2d4ae
Merge branch 'chore/package_prisma' of https://github.com/cds-snc/pla…
bryan-robitaille Oct 22, 2025
c5e6d88
update changelog
bryan-robitaille Oct 22, 2025
7649300
Merge branch 'main' into chore/package_prisma
bryan-robitaille Nov 20, 2025
6394e1d
update prisma package
bryan-robitaille Nov 20, 2025
06b8dba
ensure app test env is set for playwright
bryan-robitaille Nov 21, 2025
922ffb0
Merge branch 'main' into chore/package_prisma
bryan-robitaille Nov 21, 2025
503601f
remove extra space
bryan-robitaille Nov 21, 2025
1796917
update to prisma 7
bryan-robitaille Nov 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@
"!! Database Migration !!":
- changed-files:
- any-glob-to-any-file:
- prisma/migrations/**
- prisma/schema.prisma
- prisma/seeds/**
- packages/database/prisma/**
- packages/database/src/fixtures/**
4 changes: 2 additions & 2 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
linux-yarn-

- name: "Install dependencies"
run: yarn workspaces focus gcforms
run: yarn workspaces focus gcforms @gcforms/database

- name: Cypress Tests
uses: cypress-io/github-action@b8ba51a856ba5f4c15cf39007636d4ab04f23e3c # v6.10.2
Expand All @@ -76,7 +76,7 @@ jobs:
browser: chrome
headed: false
build: yarn build:test
start: yarn start:test
start: yarn cypress:run
wait-on: "http://localhost:3000"
config: baseUrl=http://localhost:3000
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
linux-yarn-

- name: "Install dependencies"
run: yarn workspaces focus gcforms
run: yarn workspaces focus gcforms @gcforms/database

- name: Install Playwright Browsers
run: npx playwright install msedge --with-deps
Expand Down
17 changes: 0 additions & 17 deletions .github/workflows/prisma-migration/action.yml

This file was deleted.

8 changes: 0 additions & 8 deletions .github/workflows/prod-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,6 @@ jobs:
TASKDEF_ARN=`jq -r '.taskDefinitionArn' form_viewer.json | cut -f 1-6 -d "/"`
jq --argjson port "$CONTAINER_PORT" --arg cname "$CONTAINER_NAME" --arg taskdefarn "$TASKDEF_ARN" '.Resources[0].TargetService.Properties.TaskDefinition = $taskdefarn | .Resources[0].TargetService.Properties.LoadBalancerInfo.ContainerName = $cname | .Resources[0].TargetService.Properties.LoadBalancerInfo.ContainerPort = $port' config/infrastructure/aws/appspec-template.json > form-viewer-appspec.json

- name: Run Prisma Migrations
id: prisma-migration
uses: ./.github/workflows/prisma-migration
with:
aws-account-id: ${{ env.AWS_ACCOUNT_ID }}
aws-region: ${{ env.AWS_REGION }}
app-env: production

- name: Deploy image for Form Viewer
timeout-minutes: 10
# v1.4.11
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/staging-db-migrate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Staging DB Migration
on:
workflow_dispatch:
workflow_run:
workflows: ["Deploy to Staging"]
types:
- in_progress
jobs:
run-check:
runs-on: ubuntu-latest
outputs:
has-migrations: ${{ steps.filter.outputs.migrations }}
steps:
- name: path-filter
uses: cds-snc/paths-filter@b316143212d841aed668b7b29240c719d603a9b9 # tag=v2.10.4
id: filter
with:
filters: |
migrations:
- 'packages/database/prisma/migrations/**'
- 'packages/database/src/fixtures/**'
migrate-db:
needs: [run-check]
if: ${{ needs.run-check.outputs.has-migrations == 'true' }}
runs-on:
- codebuild-Staging-Github-Runner-${{ github.run_id }}-${{ github.run_attempt }}
steps:
- run: yarn workspaces focus @gcforms/database
- run: yarn db:generate
- run: yarn db:prod
20 changes: 0 additions & 20 deletions .github/workflows/staging-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,26 +84,6 @@ jobs:
TASKDEF_ARN=`jq -r '.taskDefinitionArn' form_viewer.json | cut -f 1-6 -d "/"`
jq --argjson port "$CONTAINER_PORT" --arg cname "$CONTAINER_NAME" --arg taskdefarn "$TASKDEF_ARN" '.Resources[0].TargetService.Properties.TaskDefinition = $taskdefarn | .Resources[0].TargetService.Properties.LoadBalancerInfo.ContainerName = $cname | .Resources[0].TargetService.Properties.LoadBalancerInfo.ContainerPort = $port' config/infrastructure/aws/appspec-template.json > form-viewer-appspec.json

- name: Prisma Filter
id: prisma-filter
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
with:
# We include the ./seeds/** directory to trigger the workflow when a seed file is added or modified
filters: |
prisma:
- 'prisma/migrations/**'
- 'prisma/schema.prisma'
- 'prisma/seeds/**'

- name: Run Prisma Migrations
if: steps.prisma-filter.outputs.prisma == 'true'
id: prisma-migration
uses: ./.github/workflows/prisma-migration
with:
aws-account-id: ${{ env.AWS_ACCOUNT_ID }}
aws-region: ${{ env.AWS_REGION }}
app-env: staging

- name: Deploy image for Form Viewer
timeout-minutes: 10
# v1.4.11
Expand Down
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ typings/
# dotenv environment variables file
.env*.local
.env

.env.yarn
# Ignore cypress screenshots and videos
cypress/screenshots
cypress/videos
Expand Down Expand Up @@ -113,4 +113,7 @@ certificates
dist

test-results/
playwright-report/
playwright-report/

# Ignore generated Prisma Code
packages/database/src/generated
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ ENV NEXT_PUBLIC_HCAPTCHA_SITE_KEY=$HCAPTCHA_SITE_KEY
RUN corepack enable && yarn set version stable
RUN yarn workspaces focus gcforms
RUN yarn build
RUN yarn workspaces focus gcforms --production

FROM node:22-alpine AS final
LABEL maintainer="-"

ENV PORT 3000
ENV PORT=3000
ENV NODE_ENV=production

ARG COGNITO_APP_CLIENT_ID
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ yarn install

### Set your environment variables

Create an `.env` file at the root of the project and use the `.env.example` as a template. If you want you can find a ready to use version of the `.env` file in 1Password > Local Development .ENV secure note
Create an `.env.yarn` file at the root of the project and use the `.env.example` as a template. If you want you can find a ready to use version of the `.env` file in 1Password > Local Development .ENV secure note

### Run the web application in development mode

Expand Down
3 changes: 1 addition & 2 deletions __utils__/dbTearDown.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { PrismaClient } from "@prisma/client";
import { prisma } from "@gcforms/database";
import { logMessage } from "@lib/logger";

export default async function teardown() {
const prisma = new PrismaClient();
try {
const tablenames = await prisma.$queryRaw<
Array<{ tablename: string }>
Expand Down
8 changes: 1 addition & 7 deletions __utils__/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
export {
prismaMock,
PrismaClientInitializationError,
PrismaClientKnownRequestError,
PrismaClientUnknownRequestError,
PrismaClientValidationError,
} from "./prismaConnector";
export { prismaMock } from "./prismaConnector";
19 changes: 6 additions & 13 deletions __utils__/prismaConnector.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
import { PrismaClient, Prisma } from "@prisma/client";
import { mockDeep, mockReset, DeepMockProxy } from "jest-mock-extended";
import { prisma } from "@lib/integration/prismaConnector";
import { mockReset, DeepMockProxy } from "jest-mock-extended";
import { prisma, PrismaClient } from "@gcforms/database";

export const {
PrismaClientInitializationError,
PrismaClientKnownRequestError,
PrismaClientUnknownRequestError,
PrismaClientValidationError,
} = Prisma;

jest.mock("@lib/integration/prismaConnector", () => {
jest.mock("@gcforms/database", () => {
// Only mock prisma when were running in the Node jest environment
if (typeof window === "undefined") {
const originalModule = jest.requireActual("@lib/integration/prismaConnector");
const originalModule = jest.requireActual("@gcforms/database");
const { mockDeep } = jest.requireActual("jest-mock-extended");
return {
__esModule: true,
...originalModule,
prisma: mockDeep<PrismaClient>(),
prisma: mockDeep() as DeepMockProxy<PrismaClient>,
};
} else {
return {};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { serverTranslation } from "@i18n";
import { AppUser } from "@lib/types/user-types";
import type { Privilege as PType } from "@prisma/client";
import type { Privilege as PType } from "@gcforms/database";
import { Privilege } from "../client/Privilege";

type PrivilegeList = Omit<PType, "permissions" | "priority">[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
BatchGetCommandOutput,
} from "@aws-sdk/lib-dynamodb";
import { logEvent } from "@lib/auditLogs";
import { prisma } from "@lib/integration/prismaConnector";
import { prisma } from "@gcforms/database";
import { authorization } from "@lib/privileges";
import { AccessControlError } from "@lib/auth/errors";
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use server";

import { AuthenticatedAction } from "@lib/actions";
import { prisma } from "@lib/integration/prismaConnector";
import { prisma } from "@gcforms/database";
import { TemplateUser } from "./types";
import { AccessControlError } from "@lib/auth/errors";
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { AuthenticatedAction } from "@lib/actions";
import { ServerActionError } from "@lib/types/form-builder-types";
import { logMessage } from "@root/lib/logger";
import { prisma, prismaErrors } from "@lib/integration/prismaConnector";
import { prisma, prismaErrors } from "@gcforms/database";
import { logEvent } from "@root/lib/auditLogs";
import { getNotificationsUsers } from "@root/lib/notifications";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";
import { StarIcon } from "@serverComponents/icons/StarIcon";
import { accept, decline } from "./actions";
import { Invitation } from "@prisma/client";
import { Invitation } from "@gcforms/database";
import { useRouter } from "next/navigation";
import { useTranslation } from "@i18n/client";
import { Trans } from "react-i18next";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { getAllTemplatesForUser, TemplateOptions } from "@lib/templates";
import { DeliveryOption } from "@lib/types";
import { getOverdueTemplateIds } from "@lib/overdue";
import { Invitations } from "./components/Invitations/Invitations";
import { prisma } from "@lib/integration/prismaConnector";
import { prisma } from "@gcforms/database";

export type FormsTemplate = {
id: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { requestNew2FAVerificationCode } from "@lib/auth";
import { signIn } from "@lib/auth";
import { handleErrorById, Missing2FASession } from "@lib/auth/cognito";
import { cookies } from "next/headers";
import { prisma } from "@lib/integration/prismaConnector";
import { prisma } from "@gcforms/database";
import { CredentialsSignin } from "next-auth";
import { getUnprocessedSubmissionsForUser } from "@lib/users";
import { logMessage } from "@lib/logger";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import * as v from "valibot";
import { serverTranslation } from "@i18n";
import { sendPasswordResetLink, validateSecurityAnswers } from "@lib/auth";
import { prisma, prismaErrors } from "@lib/integration/prismaConnector";
import { prisma, prismaErrors } from "@gcforms/database";
import { logEvent } from "@lib/auditLogs";
import { hasError } from "@lib/hasError";
import { logMessage } from "@lib/logger";
Expand Down
16 changes: 0 additions & 16 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,10 @@
import { defineConfig } from "cypress";
import { logMessage } from "@lib/logger";
import terminalReport from "cypress-terminal-report/src/installLogsPrinter";
import dbTearDown from "./__utils__/dbTearDown";
import dbSeed from "./prisma/seeds/seed";

export default defineConfig({
video: false,
defaultCommandTimeout: 10000,
e2e: {
baseUrl: "http://localhost:3000",
setupNodeEvents(on) {
on("before:run", async () => {
logMessage.info("Tearing down database");
await dbTearDown();
logMessage.info("Seeding database");
await dbSeed("test");
});
if (process.env.CYPRESS_DEBUG) {
logMessage.info("Enabling terminal report for Debugging");
terminalReport(on);
}
},
},
component: {
devServer: {
Expand Down
6 changes: 3 additions & 3 deletions cypress/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/**
* @type {Cypress.PluginConfig}
*/
module.exports = () => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config

module.exports = (on: Cypress.PluginEvents) => {
if (Cypress.env("DEBUG")) require("cypress-terminal-report/src/installLogsPrinter")(on);
};
3 changes: 1 addition & 2 deletions cypress/support/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ import "./commands";

// Import Axe-Core library
import "cypress-axe";
import terminalReport from "cypress-terminal-report/src/installLogsCollector";

// import flagsDefault from "../../flag_initialization/default_flag_settings.json";

if (Cypress.env("DEBUG")) terminalReport();
if (Cypress.env("DEBUG")) require("cypress-terminal-report/src/installLogsCollector")();
2 changes: 1 addition & 1 deletion lib/appSettings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { prisma, prismaErrors } from "@lib/integration/prismaConnector";
import { prisma, prismaErrors } from "@gcforms/database";
import { authorization } from "./privileges";
import { AccessControlError } from "@lib/auth/errors";
import { logEvent } from "./auditLogs";
Expand Down
2 changes: 1 addition & 1 deletion lib/auth/cognito.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
CognitoIdentityProviderServiceException,
} from "@aws-sdk/client-cognito-identity-provider";
import { logEvent } from "@lib/auditLogs";
import { prisma, prismaErrors } from "@lib/integration/prismaConnector";
import { prisma, prismaErrors } from "@gcforms/database";
import { generateVerificationCode, sendVerificationCode } from "./2fa";
import { registerFailed2FAAttempt, clear2FALockout } from "./2faLockout";
import { logMessage } from "@lib/logger";
Expand Down
2 changes: 1 addition & 1 deletion lib/auth/nextAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { validate2FAVerificationCode, userHasSecurityQuestions } from "@lib/auth
import { PrismaAdapter } from "@auth/prisma-adapter";
import { logMessage } from "@lib/logger";
import { getOrCreateUser } from "@lib/users";
import { prisma } from "@lib/integration/prismaConnector";
import { prisma } from "@gcforms/database";
import { getPrivilegeRulesForUser } from "@lib/privileges";
import { getUserFeatureFlags } from "@lib/userFeatureFlags";
import { logEvent } from "@lib/auditLogs";
Expand Down
2 changes: 1 addition & 1 deletion lib/auth/passwordReset.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { prisma } from "@lib/integration/prismaConnector";
import { prisma } from "@gcforms/database";
import { generateVerificationCode } from "./2fa";
import { logMessage } from "@lib/logger";
import { sendEmail } from "@lib/integration/notifyConnector";
Expand Down
2 changes: 1 addition & 1 deletion lib/auth/securityQuestions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { prisma, prismaErrors } from "@lib/integration/prismaConnector";
import { prisma, prismaErrors } from "@gcforms/database";
import { scrypt, randomBytes } from "crypto";
import { authorization } from "@lib/privileges";
import { AccessControlError } from "@lib/auth/errors";
Expand Down
Loading
Loading