Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
6ba4d10
WIP - move form definitions package into lambdas/packages
stephenhand May 12, 2025
6fcaddb
WIP - package-lock.json for moved package
stephenhand May 12, 2025
9da0ba1
WIP - fixed hrm-form-definitions build
stephenhand May 12, 2025
b8ab5ad
WIP - fixed hrm-form-definitions tests
stephenhand May 12, 2025
3ba11b7
WIP - fixed e2e package lock
stephenhand May 12, 2025
f4351e5
Fix linting
stephenhand May 12, 2025
007287b
Lint all lambdas projects
stephenhand May 12, 2025
8f5c470
Lint all lambdas projects
stephenhand May 12, 2025
68839d1
Lint all lambdas projects
stephenhand May 12, 2025
ede090f
Fix lambda linting in CI
stephenhand May 12, 2025
a0e02c6
Merge branch 'CHI-3295-update_prepopulate_logic' into CHI-3295-formde…
stephenhand May 12, 2025
83f36da
Tests passing for populateMappings
stephenhand May 14, 2025
0e9dc8b
Add more tests and fix issues highlighted by tests
stephenhand May 14, 2025
511dfce
Flip dependencies so hrm-form-definitions depends on hrm-types
stephenhand May 14, 2025
f54a6ee
Fix package pathing in lambda dockerfile
stephenhand May 14, 2025
91bee68
Try changing nrm-form-definitions -> hrm-types dependency to a file d…
stephenhand May 14, 2025
0b3f52c
Break dependency between hrm-types and hrm-form-definitions
stephenhand May 14, 2025
8182028
Fix build
stephenhand May 14, 2025
05283cf
Fix build
stephenhand May 14, 2025
8bd0596
Fix a bunch of deps
stephenhand May 14, 2025
8cd8aea
Move hrm-form-definitions tests to lambda CI
stephenhand May 15, 2025
be1c87a
Linter
stephenhand May 15, 2025
f5acf27
Fix lambda service tests
stephenhand May 15, 2025
3b3fcf3
Fix lambda service tests
stephenhand May 15, 2025
d9994d0
Fix lambda service tests
stephenhand May 15, 2025
f3edffc
Upgrade @babel/runtime
stephenhand May 15, 2025
e31890c
Upgrade package-lock.json
stephenhand May 15, 2025
5f979a1
Build lambdas for plugin tests
stephenhand May 15, 2025
ef0f223
Build lambdas for plugin tests
stephenhand May 15, 2025
2064750
Install lambda packages outside workspace for unit tests
stephenhand May 15, 2025
a2d5a5a
Try copying packages to local node_modules :-/
stephenhand May 15, 2025
56b5e50
Try copying packages to local node_modules :-/
stephenhand May 15, 2025
05bc0c6
Try copying packages to local node_modules :-/
stephenhand May 15, 2025
9b804ff
Shotgun fixing
stephenhand May 15, 2025
266d335
Shotgun fixing
stephenhand May 15, 2025
cbdbd31
Shotgun fixing
stephenhand May 15, 2025
85ba443
Remove DefinitionVersionId enum
stephenhand May 15, 2025
c827677
Try reordering ci calls installing flex plugin deps
stephenhand May 16, 2025
77b0141
Try reordering ci calls installing flex plugin deps
stephenhand May 16, 2025
81df3fa
Remove reference to old DefinitionVersion enum
stephenhand May 16, 2025
dc68730
Remove unused export
stephenhand May 16, 2025
81df0f6
Fix form def deploy path
stephenhand May 16, 2025
f709739
Merge pull request #2970 from techmatters/CHI-3295-use_new_prepopulat…
stephenhand May 20, 2025
6702f23
Merge branch 'master' into CHI-3295-formdef_package_move
stephenhand May 22, 2025
9fceb23
Post merge fixes
stephenhand May 22, 2025
53102b8
Linter
stephenhand May 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 4 additions & 4 deletions .github/actions/install-flex-plugin/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ runs:
- name: Install the Twilio CLI and plugins
run: npm install -g twilio-cli && twilio plugins:install @twilio-labs/plugin-flex@7.0.0
shell: bash
- name: Install hrm-form-definitions Packages
run: npm ci
working-directory: ${{ inputs.path }}/hrm-form-definitions
shell: bash
- name: Install plugin-hrm-form Packages
run: npm ci
working-directory: ${{ inputs.path }}/plugin-hrm-form
shell: bash
- name: Install hrm-types packages
run: npm ci
working-directory: ${{ inputs.path }}/lambdas
shell: bash
4 changes: 2 additions & 2 deletions .github/scripts/setupDeployFormDefinitionsEnv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ fi
helpline="${helpline,,}"

path="form-definitions/${helpline}"
helpline_dir="./hrm-form-definitions/${path}"
helpline_dir="./lambdas/packages/hrm-form-definitions/${path}"

if [ ! -d "$helpline_dir" ]; then
echo "${helpline} is not a valid helpline. It must be one of: $(ls ./hrm-form-definitions/form-definitions)"
echo "${helpline} is not a valid helpline. It must be one of: $(ls ./lambdas/packages/hrm-form-definitions/form-definitions)"
fi

echo "environment=${environment}" >> $GITHUB_ENV
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/flex-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@ jobs:
working-directory: ./plugin-hrm-form
- name: Install Flex Plugin
uses: ./.github/actions/install-flex-plugin
- name: Run hrm-form-definitions Lint
run: npm run lint
working-directory: ./hrm-form-definitions
- name: Run plugin-hrm-form code Lint
run: npm run lint --if-present
working-directory: ./plugin-hrm-form
- name: Install Lambdas
run: npm ci
working-directory: ./lambdas
- name: Run Lambdas Lint
run: npm run lint
working-directory: ./lambdas
- name: Install e2e-test Packages
run: npm ci
working-directory: ./e2e-tests
Expand All @@ -59,9 +62,6 @@ jobs:
node-version: '20.x'
- name: Install Flex Plugin
uses: ./.github/actions/install-flex-plugin
- name: Run hrm-form-definitions Tests
run: npm run test
working-directory: ./hrm-form-definitions
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/twilio-lambda-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ jobs:
run: |
npm ci
working-directory: ./lambdas
- name: Build Lambda packages
run: |
npm run build
working-directory: ./lambdas

- name: Run Unit Tests
run: |
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@

**/__pycache__/

hrm-form-definitions/junit.xml
**/junit.xml
4 changes: 2 additions & 2 deletions e2e-tests/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash - && \
curl -Lo /usr/local/bin/aws-lambda-rie https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/${REI_FILE} && \
chmod +x /usr/local/bin/aws-lambda-rie

COPY hrm-form-definitions/package*.json /app/hrm-form-definitions/
COPY lambdas/packages/hrm-form-definitions/package*.json /app/hrm-form-definitions/
COPY e2e-tests/package*.json /app/e2e-tests/

RUN cd hrm-form-definitions && \
Expand Down Expand Up @@ -75,7 +75,7 @@ WORKDIR /app/e2e-tests

RUN npx playwright install-deps

COPY hrm-form-definitions /app/hrm-form-definitions
COPY lambdas/packages/hrm-form-definitions /app/hrm-form-definitions
COPY e2e-tests /app/e2e-tests
COPY --chmod=0755 e2e-tests/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
COPY e2e-tests/lambda/handler.js /app/e2e-tests/handler.js
Expand Down
49 changes: 43 additions & 6 deletions e2e-tests/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"eslint-import-resolver-typescript": "^2.7.1",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-prettier": "^4.0.0",
"hrm-form-definitions": "file:../hrm-form-definitions",
"hrm-form-definitions": "file:../lambdas/packages/hrm-form-definitions",
"mock-socket": "^9.1.5",
"npm-run-all": "^4.1.5",
"playwright-core": "^1.30.0",
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/ui-tests/aselo-service-mocks/form-definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const mockFormDefinitions = async (page: Page) => {
.url()
.substring(context.FORM_DEFINITIONS_BASE_URL.toString().length);
const definitionFilePath = path.join(
'../hrm-form-definitions/form-definitions',
'../lambdas/packages/hrm-form-definitions/form-definitions',
definitionFile,
);
console.log('Loading form def file:', definitionFilePath);
Expand Down
4 changes: 1 addition & 3 deletions e2e-tests/ui-tests/aselo-service-mocks/hrm/cases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
import flexContext from '../../flex-in-a-box/global-context';
import { addSeconds, subHours } from 'date-fns';
// eslint-disable-next-line import/no-extraneous-dependencies
import { DefinitionVersionId } from 'hrm-form-definitions';
// eslint-disable-next-line import/no-extraneous-dependencies
import { Page } from '@playwright/test';
import context from '../global-context';
import * as path from 'path';
Expand All @@ -39,7 +37,7 @@ const generateMockCases = (toGenerate: number): any[] => {
'case category 2': ['subcategory3'],
},
info: {
definitionVersion: DefinitionVersionId.demoV1,
definitionVersion: 'demo-v1',
},
createdAt: time.toISOString(),
updatedAt: time.toISOString(),
Expand Down
43 changes: 0 additions & 43 deletions hrm-form-definitions/.eslintrc.js

This file was deleted.

12 changes: 0 additions & 12 deletions hrm-form-definitions/form-definitions/as/v1/PostSurvey.json

This file was deleted.

4 changes: 3 additions & 1 deletion lambdas/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

module.exports = {
extends: ['airbnb-typescript/base', 'plugin:prettier/recommended'],
plugins: ['prettier', 'jest', 'import'],
plugins: ['jest', 'import'],
rules: {
'prettier/prettier': ['error'],
'no-console': 'off',
Expand Down Expand Up @@ -49,5 +49,7 @@ module.exports = {
'**/coverage/**',
'node_modules/**',
'**/node_modules/**',
'**/*.js',
'**/*.d.ts'
],
};
6 changes: 3 additions & 3 deletions lambdas/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,28 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see https://www.gnu.org/licenses/.

FROM public.ecr.aws/lambda/nodejs:22 as build

Check warning on line 15 in lambdas/Dockerfile

View workflow job for this annotation

GitHub Actions / twilio-lambda-ci / Build Lambda Image (account-scoped)

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

ARG lambda_dir
ENV lambda_dir ${lambda_dir}

Check warning on line 18 in lambdas/Dockerfile

View workflow job for this annotation

GitHub Actions / twilio-lambda-ci / Build Lambda Image (account-scoped)

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/
ARG lambda_name
ENV lambda_name ${lambda_name}

Check warning on line 20 in lambdas/Dockerfile

View workflow job for this annotation

GitHub Actions / twilio-lambda-ci / Build Lambda Image (account-scoped)

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/

# This is a bit complicated by the need for access to the packages.
# We must have the full repo context for our docker build so we can
# copy the hrm-lib package and labmdas folders so that the file: based
# dependency in package.json can be resolved
COPY ${lambda_dir}/${lambda_name} /tmp/build/${lambda_dir}/${lambda_name}
COPY ${lambda_dir}/../packages /tmp/build/${lambda_dir}/../packages
COPY ${lambda_dir}/../packages /tmp/build/packages
COPY package.json package-lock.json tsconfig.json tsconfig.base.json ${lambda_dir}/${lambda_name}/tsconfig.build.json /tmp/build/

RUN dnf install -y rsync \
&& cd /tmp/build \
&& npm ci -w ${lambda_dir}/${lambda_name} -w ${lambda_dir}/../packages/* --verbose \
&& npm ci -w ${lambda_dir}/${lambda_name} -w packages/* --verbose \
&& npx tsc -b tsconfig.build.json --verbose \
&& cp -r ${lambda_dir}/${lambda_name}/dist/. /var/task/ \
&& mkdir -p /var/task/${lambda_dir} \
&& cp -r ${lambda_dir}/../packages /var/task/${lambda_dir}/../packages/ \
&& cp -r packages /var/task/ \
&& cp -r node_modules /var/task/

# Ignore errors if node_modules is not present
Expand Down
2 changes: 2 additions & 0 deletions lambdas/account-scoped/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
"@aws-sdk/client-lex-runtime-service": "^3.787.0",
"@aws-sdk/client-lex-runtime-v2": "^3.787.0",
"@aws-sdk/client-ssm": "^3.716.0",
"@tech-matters/hrm-form-definitions": "^1.0.0",
"@tech-matters/hrm-types": "^1.0.0",
"@twilio-labs/serverless-runtime-types": "^4.0.1",
"date-fns": "^4.1.0",
"lodash": "^4.17.21",
Expand Down
40 changes: 40 additions & 0 deletions lambdas/account-scoped/src/hrm/availableContactFormSelector.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* Copyright (C) 2021-2023 Technology Matters
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*/

import { HrmContactRawJson } from '@tech-matters/hrm-types';
import { DefinitionVersion } from '@tech-matters/hrm-form-definitions';

export type ContactFormDefinitionName = keyof Pick<
DefinitionVersion['tabbedForms'],
'ChildInformationTab' | 'CallerInformationTab' | 'CaseInformationTab'
>;

export type ContactFormName = keyof Omit<
HrmContactRawJson,
'callType' | 'definitionVersion' | 'categories' | 'contactlessTask'
>;

export type AvailableContactFormSelector = (
parameter?: any,
) => (
source: keyof DefinitionVersion['prepopulateMappings'],
preEngagementSelections: any,
surveyAnswers: any,
) => ContactFormDefinitionName[];

export const staticAvailableContactTabSelector: AvailableContactFormSelector =
availableTabs => () =>
availableTabs;
Loading
Loading