Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…dct-seds into jon-cdk
  • Loading branch information
JonHolman committed Jan 31, 2025
2 parents f634b78 + 3c1174b commit 059364d
Show file tree
Hide file tree
Showing 133 changed files with 3,422 additions and 5,182 deletions.
2 changes: 2 additions & 0 deletions .env.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ COGNITO_USER_POOL_CLIENT_ID=op://mdct_devs/seds_secrets/COGNITO_USER_POOL_CLIENT
COGNITO_USER_POOL_CLIENT_DOMAIN=placeholder
COGNITO_REDIRECT_SIGNIN=http://localhost:3000/
COGNITO_REDIRECT_SIGNOUT=http://localhost:3000/

SERVERLESS_LICENSE_KEY=op://mdct_devs/seds_secrets/SERVERLESS_LICENSE_KEY
5 changes: 3 additions & 2 deletions .github/branchNameValidation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
set -e

local_branch=${1}
[ -z "${1}" ] && local_branch=$(git rev-parse --abbrev-ref HEAD)

valid_branch='^[a-z][a-z0-9-]*$'

Expand All @@ -15,7 +16,7 @@ join_by() { local IFS='|'; echo "$*"; }
#creates glob match to check for reserved words used in branch names which would trigger failures
glob=$(join_by $(for i in ${reserved_words[@]}; do echo "^$i-|-$i$|-$i-|^$i$"; done;))

if [[ ! $local_branch =~ $valid_branch ]] || [[ $local_branch =~ $glob ]] || [[ ${#local_branch} -gt 64 ]]; then
if [[ ! $local_branch =~ $valid_branch ]] || [[ $local_branch =~ $glob ]] || [[ ${#local_branch} -gt 20 ]]; then
echo """
------------------------------------------------------------------------------------------------------------------------------
ERROR: Please read below
Expand All @@ -28,7 +29,7 @@ if [[ ! $local_branch =~ $valid_branch ]] || [[ $local_branch =~ $glob ]] || [[
Therefore, the branch name must be a valid service name. Branch name must be all lower case with no spaces and no underscores.
From Serverless:
A service name should only contain alphanumeric (case sensitive) and hyphens. It should start with an alphabetic character and shouldnt exceed 128 characters.
A service name should only contain alphanumeric (case sensitive) and hyphens. It should start with an alphabetic character and shouldnt exceed 20 characters.
For Github Actions support, please push your code to a new branch with a name that meets Serverless' service name requirements.
So, make a new branch with a name that begins with a letter and is made up of only letters, numbers, and hyphens... then delete this branch.
------------------------------------------------------------------------------------------------------------------------------
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ permissions:
id-token: write
contents: read
actions: read

env:
SERVERLESS_LICENSE_KEY: ${{ secrets.SERVERLESS_LICENSE_KEY }}

jobs:
deploy:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -199,6 +203,7 @@ jobs:
working-directory: tests/cypress
spec: integration/**/*
browser: chrome
headed: true
- name: Upload screenshots
uses: actions/upload-artifact@v4
if: failure()
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ name: Pull Request
on: [pull_request]

jobs:
prchecks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Configure pre-commit to skip branch name validation
run: |
echo "SKIP=branch-name-validation" >> $GITHUB_ENV
assignAuthor:
runs-on: ubuntu-latest
steps:
Expand Down
9 changes: 8 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,11 @@ repos:
- repo: https://github.com/zricethezav/gitleaks
rev: v8.12.0
hooks:
- id: gitleaks
- id: gitleaks
- repo: local
hooks:
- id: branch-name-validation
name: branch-name-validation
entry: .github/branchNameValidation.sh
language: script
pass_filenames: false
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
"test": "tests"
},
"scripts": {
"build": "tsc",
"watch": "tsc -w",
"cdk": "cdk",
"build": "tsc",
"watch": "tsc -w",
"cdk": "cdk",
Expand All @@ -37,19 +40,16 @@
"@types/node": "^20.12.7",
"@types/readline-sync": "^1.4.8",
"@types/yargs": "^15.0.10",
"aws-cdk": "2.161.1",
"chromedriver": ">=88.0.0",
"dotenv": "^8.2.0",
"nightwatch": "3.1.2",
"prettier": "2.2.1",
"serverless": "^3.39.0",
"serverless-bundle": "^6.0.0",
"serverless": "^4.4.18",
"serverless-dotenv-plugin": "^4.0.0",
"serverless-iam-helper": "github:Enterprise-CMCS/serverless-iam-helper",
"serverless-offline": "^13.5.0",
"serverless-offline": "^14.4.0",
"serverless-online": "Enterprise-CMCS/macpro-serverless-online",
"serverless-plugin-scripts": "^1.0.2",
"serverless-s3-bucket-helper": "github:Enterprise-CMCS/serverless-s3-bucket-helper#0.1.1",
"serverless-stack-termination-protection": "^2.0.2",
"typescript": "^4.0.5",
"yargs": "^16.1.1"
Expand Down
10 changes: 5 additions & 5 deletions run
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ if ! which yarn > /dev/null ; then
fi

# check serverless is installed globally.
if ! which serverless > /dev/null ; then
echo "installing serverless globally"
yarn global add serverless@3.38.0
export PATH="$PATH:$(yarn global bin)"
if ! which serverless > /dev/null || ! serverless --version 2>&1 | grep -q "Framework 4."; then
echo "installing serverless v4 globally"
yarn global add serverless@4.4.18
export PATH="$PATH:$(yarn global bin)"
fi

# have to ensure that yarn install is up to date.
Expand Down Expand Up @@ -76,4 +76,4 @@ fi

# build and run run.ts
# tsc is configured to build what we expect in tsconfig.json
./node_modules/.bin/tsc && node ./build_dev/src/run.js "${ARGS[@]-}"
./node_modules/.bin/tsc && node ./build_dev/run.js "${ARGS[@]-}"
2 changes: 1 addition & 1 deletion services/app-api/auth/authConditions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getCurrentUserInfo } from "../auth/cognito-auth";
import { getCurrentUserInfo } from "../auth/cognito-auth.js";

/** Throws an exception unless the current user is authenticated. */
export const authorizeAnyUser = async (event) => {
Expand Down
4 changes: 2 additions & 2 deletions services/app-api/auth/cognito-auth.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getUserDetailsFromEvent } from "../libs/authorization";
import { obtainUserByEmail } from "../handlers/users/post/obtainUserByEmail";
import { getUserDetailsFromEvent } from "../libs/authorization.js";
import { obtainUserByEmail } from "../handlers/users/post/obtainUserByEmail.js";

export const getCurrentUserInfo = async (event) => {
const user = await getUserDetailsFromEvent(event);
Expand Down
157 changes: 0 additions & 157 deletions services/app-api/export/exportToExcel.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import handler from "../../../libs/handler-lib";
import dynamoDb from "../../../libs/dynamodb-lib";
import { authorizeAdmin } from "../../../auth/authConditions";
import handler from "../../../libs/handler-lib.js";
import dynamoDb from "../../../libs/dynamodb-lib.js";
import { authorizeAdmin } from "../../../auth/authConditions.js";

/**
* Returns a single form template
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import handler from "../../../libs/handler-lib";
import dynamoDb from "../../../libs/dynamodb-lib";
import { authorizeAdmin } from "../../../auth/authConditions";
import handler from "../../../libs/handler-lib.js";
import dynamoDb from "../../../libs/dynamodb-lib.js";
import { authorizeAdmin } from "../../../auth/authConditions.js";

export const main = handler(async (event, context) => {
await authorizeAdmin(event);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import handler from "../../../libs/handler-lib";
import dynamoDb from "../../../libs/dynamodb-lib";
import { authorizeAdmin } from "../../../auth/authConditions";
import handler from "../../../libs/handler-lib.js";
import dynamoDb from "../../../libs/dynamodb-lib.js";
import { authorizeAdmin } from "../../../auth/authConditions.js";

export const main = handler(async (event, context) => {
await authorizeAdmin(event);
Expand Down
6 changes: 3 additions & 3 deletions services/app-api/handlers/forms/get.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import handler from "./../../libs/handler-lib";
import dynamoDb from "./../../libs/dynamodb-lib";
import { authorizeAdminOrUserForState } from "../../auth/authConditions";
import handler from "./../../libs/handler-lib.js";
import dynamoDb from "./../../libs/dynamodb-lib.js";
import { authorizeAdminOrUserForState } from "../../auth/authConditions.js";

export const main = handler(async (event, context) => {
// Deconstruct variables from URL string
Expand Down
6 changes: 3 additions & 3 deletions services/app-api/handlers/forms/get/getFormTypes.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import handler from "../../../libs/handler-lib";
import dynamoDb from "../../../libs/dynamodb-lib";
import { authorizeAnyUser } from "../../../auth/authConditions";
import handler from "../../../libs/handler-lib.js";
import dynamoDb from "../../../libs/dynamodb-lib.js";
import { authorizeAnyUser } from "../../../auth/authConditions.js";

export const main = handler(async (event, context) => {
await authorizeAnyUser(event);
Expand Down
8 changes: 4 additions & 4 deletions services/app-api/handlers/forms/post/generateQuarterForms.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import handler from "../../../libs/handler-lib";
import dynamoDb from "../../../libs/dynamodb-lib";
import handler from "../../../libs/handler-lib.js";
import dynamoDb from "../../../libs/dynamodb-lib.js";
import {
getFormDescriptions,
getQuestionsByYear,
getStatesList,
findExistingStateForms,
fetchOrCreateQuestions,
getAnswersSet,
} from "../../shared/sharedFunctions";
import { authorizeAdmin } from "../../../auth/authConditions";
} from "../../shared/sharedFunctions.js";
import { authorizeAdmin } from "../../../auth/authConditions.js";

/** Called from the API; admin access required */
export const main = handler(async (event, context) => {
Expand Down
6 changes: 3 additions & 3 deletions services/app-api/handlers/forms/post/obtainAvailableForms.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { authorizeAdminOrUserForState } from "../../../auth/authConditions";
import dynamodbLib from "../../../libs/dynamodb-lib";
import handler from "../../../libs/handler-lib";
import { authorizeAdminOrUserForState } from "../../../auth/authConditions.js";
import dynamodbLib from "../../../libs/dynamodb-lib.js";
import handler from "../../../libs/handler-lib.js";

/**
* Returns list of all forms based on state
Expand Down
6 changes: 3 additions & 3 deletions services/app-api/handlers/forms/post/obtainFormsList.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import handler from "../../../libs/handler-lib";
import dynamoDb from "../../../libs/dynamodb-lib";
import { authorizeAdminOrUserForState } from "../../../auth/authConditions";
import handler from "../../../libs/handler-lib.js";
import dynamoDb from "../../../libs/dynamodb-lib.js";
import { authorizeAdminOrUserForState } from "../../../auth/authConditions.js";

export const main = handler(async (event, context) => {
const data = JSON.parse(event.body);
Expand Down
Loading

0 comments on commit 059364d

Please sign in to comment.