diff --git a/.github/workflows/continuous-deployment.yml b/.github/workflows/continuous-deployment.yml index 6bd1aee47..0673aa766 100644 --- a/.github/workflows/continuous-deployment.yml +++ b/.github/workflows/continuous-deployment.yml @@ -29,7 +29,9 @@ on: - "false" - "true" enableBicepDeployment: - description: "enableBicepDeployment: Execute main.bicep deployment for application component Azure resources" + description: + "enableBicepDeployment: Execute main.bicep deployment for application component Azure + resources" required: true default: "false" type: choice @@ -88,7 +90,7 @@ jobs: unit-test-backend: uses: ./.github/workflows/reusable-unit-test.yml with: - path: backend/functions + path: backend node-version: ${{ vars.NODE_VERSION }} unit-test-common: @@ -109,12 +111,13 @@ jobs: secrets: inherit # pragma: allowlist secret with: nodeVersion: ${{ vars.NODE_VERSION }} - apiName: ${{ needs.setup.outputs.apiName }} - camsServerHostname: ${{ needs.setup.outputs.apiName }}.azurewebsites${{ vars.AZ_HOSTNAME_SUFFIX }} + camsServerHostname: ${{ needs.setup.outputs.apiFunctionName }}.azurewebsites${{ vars.AZ_HOSTNAME_SUFFIX }} camsServerPort: ${{ vars.CAMS_SERVER_PORT }} camsServerProtocol: ${{ vars.CAMS_SERVER_PROTOCOL }} camsBasePath: ${{ vars.CAMS_BASE_PATH }} webappName: ${{ needs.setup.outputs.webappName }} + apiFunctionName: ${{ needs.setup.outputs.apiFunctionName }} + migrationFunctionName: ${{ needs.setup.outputs.migrationFunctionName }} environment: ${{ needs.setup.outputs.ghaEnvironment }} launchDarklyEnvironment: ${{ vars.CAMS_LAUNCH_DARKLY_ENV }} @@ -131,13 +134,16 @@ jobs: unit-test-backend, unit-test-common, ] - if: ((github.ref == 'refs/heads/main') || (github.ref == 'refs/heads/dependency-updates-auto') || (inputs.deployBranch == 'true')) + if: + ((github.ref == 'refs/heads/main') || (github.ref == 'refs/heads/dependency-updates-auto') || + (inputs.deployBranch == 'true')) with: ghaEnvironment: ${{ needs.setup.outputs.ghaEnvironment }} azResourceGrpAppEncrypted: ${{ needs.setup.outputs.azResourceGrpAppEncrypted }} azResourceGrpNetworkEncrypted: ${{ needs.setup.outputs.azResourceGrpNetworkEncrypted }} stackName: ${{ needs.setup.outputs.stackName }} - apiName: ${{ needs.setup.outputs.apiName }} + apiFunctionName: ${{ needs.setup.outputs.apiFunctionName }} + migrationFunctionName: ${{ needs.setup.outputs.migrationFunctionName }} webAppName: ${{ needs.setup.outputs.webappName }} environmentHash: ${{ needs.setup.outputs.environmentHash }} execVnetDeploy: ${{ needs.setup.outputs.execVnetDeploy }} @@ -154,7 +160,8 @@ jobs: ghaEnvironment: ${{ needs.setup.outputs.ghaEnvironment }} azResourceGrpAppEncrypted: ${{ needs.setup.outputs.azResourceGrpAppEncrypted }} stackName: ${{ needs.setup.outputs.stackName }} - apiName: ${{ needs.setup.outputs.apiName }} + apiFunctionName: ${{ needs.setup.outputs.apiFunctionName }} + migrationFunctionName: ${{ needs.setup.outputs.migrationFunctionName }} webAppName: ${{ needs.setup.outputs.webappName }} environmentHash: ${{ needs.setup.outputs.environmentHash }} slotName: ${{ needs.setup.outputs.slotName }} diff --git a/.github/workflows/reusable-backend-slot.yml b/.github/workflows/reusable-backend-slot.yml index c4c8cdd12..696a58a99 100644 --- a/.github/workflows/reusable-backend-slot.yml +++ b/.github/workflows/reusable-backend-slot.yml @@ -6,7 +6,10 @@ on: webAppName: required: true type: string - apiName: + apiFunctionName: + required: true + type: string + migrationFunctionName: required: true type: string ghaEnvironment: @@ -51,16 +54,19 @@ jobs: - name: Create API Slot Resource run: | - slotStorageAccountName=ustpslot${{ inputs.environmentHash }} + migrationSlotStorageAccountName=ustpslot${{ inputs.environmentHash }} + apiSlotStorageAccountName=migrationslot${{ inputs.environmentHash }} ./ops/scripts/pipeline/slots/az-slot-api-resource-deploy.sh \ --resourceGroup ${{ steps.rgApp.outputs.out }} \ --idResourceGroup ${{ secrets.AZURE_RG }} \ - --apiName ${{ inputs.apiName }} \ + --apiFunctionName ${{ inputs.apiFunctionName }} \ + --migrationFunctionName ${{ inputs.migrationFunctionName }} \ --webappName ${{ inputs.webappName }} \ --slotName ${{ inputs.slotName }} \ --kvIdName ${{ secrets.AZ_KV_APP_CONFIG_MANAGED_ID }} \ --sqlIdName ${{ secrets.AZ_SQL_IDENTITY_NAME }} \ - --storageAccName ${slotStorageAccountName:0:24} \ + --apiStorageAccName ${migrationSlotStorageAccountName:0:24} \ + --migrationStorageAccName ${apiSlotStorageAccountName:0:24} \ --databaseName ${{ secrets.AZ_COSMOS_DATABASE_NAME }} \ --infoSha ${{ inputs.environmentHash || 'DOES_NOT_EXIST' }} diff --git a/.github/workflows/reusable-build-info.yml b/.github/workflows/reusable-build-info.yml index 33fbb92e9..fcf14c140 100644 --- a/.github/workflows/reusable-build-info.yml +++ b/.github/workflows/reusable-build-info.yml @@ -19,9 +19,9 @@ on: webappName: description: "Expected Web Application name [used for Azure Resource]" value: ${{ jobs.build-info.outputs.webappName }} - apiName: + apiFunctionName: description: "" - value: ${{ jobs.build-info.outputs.apiName }} + value: ${{ jobs.build-info.outputs.apiFunctionName }} azResourceGrpAppEncrypted: description: "" value: ${{ jobs.build-info.outputs.azResourceGrpAppEncrypted }} @@ -31,6 +31,9 @@ on: environmentHash: description: "" value: ${{ jobs.build-info.outputs.environmentHash }} + migrationFunctionName: + description: "" + value: ${{ jobs.build-info.outputs.migrationFunctionName }} slotName: description: "" value: ${{ jobs.build-info.outputs.slotName }} @@ -56,12 +59,13 @@ jobs: outputs: stackName: ${{ steps.build-info.outputs.stackName }} webappName: ${{ steps.build-info.outputs.webappName }} - apiName: ${{ steps.build-info.outputs.apiName }} + apiFunctionName: ${{ steps.build-info.outputs.apiFunctionName }} azResourceGrpAppEncrypted: ${{ steps.rgApp.outputs.out }} azResourceGrpNetworkEncrypted: ${{ steps.rgNetwork.outputs.out }} environmentHash: ${{ steps.check-env.outputs.environmentHash }} execVnetDeploy: ${{ steps.build-info.outputs.execVnetDeploy }} slotName: ${{ steps.build-info.outputs.slotName }} + migrationFunctionName: ${{ steps.build-info.outputs.migrationFunctionName }} deployBicep: ${{ steps.check-bicep.outputs.deployBicep }} initialDeployment: ${{ steps.check-initial-deployment.outputs.initialDeployment }} steps: @@ -101,9 +105,11 @@ jobs: stackName=$(ops/scripts/pipeline/generate-stackname.sh ${{ inputs.environment }} ${{ vars.APP_NAME }} ${{ vars.DEV_SUFFIX }} ${{ github.ref_name }}) echo "Stack Name: $stackName" webappName="${stackName}-webapp" - echo "Webapp Artifact: $webappName" - apiName="${stackName}-node-api" - echo "Api Artifact: $apiName" + echo "Webapp Name: $webappName" + apiFunctionName="${stackName}-node-api" + echo "Api Function Name: $apiFunctionName" + migrationFunctionName="${stackName}-migration" + echo "Migration Function Name: $migrationFunctionName" # Deployment flags echo "Bicep Deployment Flag: ${{ inputs.enableBicepDeployment == 'true' }}" @@ -115,7 +121,8 @@ jobs: echo "azResourceGrpNetwork=${{ secrets.AZ_NETWORK_RG }}${resourceGroupSuffix}" >> $GITHUB_OUTPUT echo "stackName=${stackName}" >> $GITHUB_OUTPUT echo "webappName=${webappName}" >> $GITHUB_OUTPUT - echo "apiName=${apiName}" >> $GITHUB_OUTPUT + echo "apiFunctionName=${apiFunctionName}" >> $GITHUB_OUTPUT + echo "migrationFunctionName=${migrationFunctionName}" >> $GITHUB_OUTPUT echo "execVnetDeploy=${execVnetDeploy}" >> $GITHUB_OUTPUT echo "slotName=${{ vars.SLOT_NAME }}" >> $GITHUB_OUTPUT @@ -143,7 +150,7 @@ jobs: - name: Check Initial Deployment id: check-initial-deployment run: | - initialDeployment=$(./ops/scripts/pipeline/check-for-environment.sh --resource-group ${{ steps.rgAppDecode.outputs.out }} --webappName ${{ steps.build-info.outputs.webappName }} --apiName ${{ steps.build-info.outputs.apiName }}) + initialDeployment=$(./ops/scripts/pipeline/check-for-environment.sh --resource-group ${{ steps.rgAppDecode.outputs.out }} --webappName ${{ steps.build-info.outputs.webappName }} --apiName ${{ steps.build-info.outputs.apiFunctionName }}) echo "initialDeployment=${initialDeployment}" >> $GITHUB_OUTPUT echo "Initial Deployment: ${initialDeployment}" diff --git a/.github/workflows/reusable-database-deploy.yml b/.github/workflows/reusable-database-deploy.yml index 97484d6c0..d90cedc64 100644 --- a/.github/workflows/reusable-database-deploy.yml +++ b/.github/workflows/reusable-database-deploy.yml @@ -9,7 +9,10 @@ on: azResourceGrpNetworkEncrypted: required: true type: string - apiName: + apiFunctionName: + required: true + type: string + migrationFunctionName: required: true type: string environmentHash: @@ -57,7 +60,7 @@ jobs: - name: Deploy Cosmos MongoDB id: azure-mongodb-deploy run: | - allowedNetworks=$(az network vnet subnet list -g ${{ steps.rgNetwork.outputs.out }} --vnet-name ${{ vars.AZ_NETWORK_VNET_NAME }} --query "[?name=='snet-${{ inputs.apiName }}'].id" -o json) + allowedNetworks=$(az network vnet subnet list -g ${{ steps.rgNetwork.outputs.out }} --vnet-name ${{ vars.AZ_NETWORK_VNET_NAME }} --query "[?name=='snet-${{ inputs.apiFunctionName }}' || name=='snet-${{inputs.migrationFunctionName}}'].id" -o json) ./ops/scripts/pipeline/az-cosmos-deploy.sh \ -g ${{ secrets.AZURE_RG }} \ diff --git a/.github/workflows/reusable-e2e.yml b/.github/workflows/reusable-e2e.yml index b8cf09533..4477c8ce9 100644 --- a/.github/workflows/reusable-e2e.yml +++ b/.github/workflows/reusable-e2e.yml @@ -3,7 +3,7 @@ name: End-to-end Tests on: workflow_call: inputs: - apiName: + apiFunctionName: required: true type: string slotName: @@ -75,13 +75,13 @@ jobs: fi echo "Seeding E2E CosmosDB..." - curl -v -d '{"txIdOverride": '0'}' -H "Content-Type: application/json" https://${{ inputs.apiName }}.azurewebsites${{ vars.AZ_HOSTNAME_SUFFIX }}/api/orders-sync?x-ms-routing-name=${{ inputs.slotName }} + curl -v -d '{"txIdOverride": '0'}' -H "Content-Type: application/json" https://${{ inputs.apiFunctionName }}.azurewebsites${{ vars.AZ_HOSTNAME_SUFFIX }}/api/orders-sync?x-ms-routing-name=${{ inputs.slotName }} - name: Restart API and Install Node dependencies working-directory: test/e2e run: | - az functionapp restart --name ${{ inputs.apiName }} --resource-group ${{ steps.rgApp.outputs.out }} & az webapp restart --name ${{ inputs.webappName }} --resource-group ${{ steps.rgApp.outputs.out }} - az functionapp restart --name ${{ inputs.apiName }} --resource-group ${{ steps.rgApp.outputs.out }} --slot staging & az webapp restart --name ${{ inputs.webappName }} --resource-group ${{ steps.rgApp.outputs.out }} --slot staging + az functionapp restart --name ${{ inputs.apiFunctionName }} --resource-group ${{ steps.rgApp.outputs.out }} & az webapp restart --name ${{ inputs.webappName }} --resource-group ${{ steps.rgApp.outputs.out }} + az functionapp restart --name ${{ inputs.apiFunctionName }} --resource-group ${{ steps.rgApp.outputs.out }} --slot staging & az webapp restart --name ${{ inputs.webappName }} --resource-group ${{ steps.rgApp.outputs.out }} --slot staging sleep 10 npm ci npx playwright install chromium msedge diff --git a/.github/workflows/reusable-endpoint-test.yml b/.github/workflows/reusable-endpoint-test.yml index 502f13d01..3eebf6842 100644 --- a/.github/workflows/reusable-endpoint-test.yml +++ b/.github/workflows/reusable-endpoint-test.yml @@ -3,7 +3,7 @@ name: Endpoint Tests on: workflow_call: inputs: - apiName: + apiFunctionName: required: true type: string slotName: @@ -33,7 +33,7 @@ jobs: env: stackName: ${{ inputs.stackName }} webappName: ${{ inputs.webappName }} - apiName: ${{ inputs.apiName }} + apiFunctionName: ${{ inputs.apiFunctionName }} branchHashId: ${{ inputs.branchHashId }} priority: 200 steps: @@ -62,7 +62,7 @@ jobs: - name: Health check App Resources run: | ./ops/scripts/pipeline/endpoint-test.sh \ - --apiName ${{ inputs.apiName }} \ + --apiFunctionName ${{ inputs.apiFunctionName }} \ --webappName ${{ inputs.webappName }} \ --hostSuffix ${{ vars.AZ_HOSTNAME_SUFFIX }} \ --gitSha ${{ github.sha }} \ diff --git a/.github/workflows/reusable-frontend-slot.yml b/.github/workflows/reusable-frontend-slot.yml index a857b533c..e9d84dcdb 100644 --- a/.github/workflows/reusable-frontend-slot.yml +++ b/.github/workflows/reusable-frontend-slot.yml @@ -6,7 +6,7 @@ on: webAppName: required: true type: string - apiName: + apiFunctionName: required: true type: string ghaEnvironment: @@ -51,7 +51,7 @@ jobs: ./ops/scripts/pipeline/slots/az-slot-web-resource-deploy.sh \ --resourceGroup ${{ steps.rgApp.outputs.out }} \ --webappName ${{ inputs.webappName }} \ - --apiName ${{ inputs.apiName }} \ + --apiFunctionName ${{ inputs.apiFunctionName }} \ --slotName ${{ inputs.slotName }} \ --subscription ${{ secrets.AZURE_SUBSCRIPTION }} \ --network-rg ${{ steps.rgNetwork.outputs.out }} \ diff --git a/.github/workflows/sub-build.yml b/.github/workflows/sub-build.yml index 1e9f704d1..358a1d1b5 100644 --- a/.github/workflows/sub-build.yml +++ b/.github/workflows/sub-build.yml @@ -6,7 +6,10 @@ on: nodeVersion: required: true type: string - apiName: + apiFunctionName: + required: true + type: string + migrationFunctionName: required: true type: string camsServerHostname: @@ -84,28 +87,42 @@ jobs: backend: defaults: run: - working-directory: backend/functions + working-directory: backend runs-on: ubuntu-latest environment: ${{ inputs.environment }} steps: - uses: actions/checkout@v3 + - name: Execute Build run: | - pushd ../../common - npm ci - popd + npm run use-bash + + npm run build-common npm ci - npm run build - - name: Package Application - run: OUT=${{ inputs.apiName }} npm run pack + npm run build:api + + npm run build:migration + + - name: Package API + run: OUT=${{ inputs.apiFunctionName }} npm run pack + + - name: Package Migration + run: OUT=${{ inputs.migrationFunctionName }} npm run pack:migration + + - name: Upload API Azure Functions Artifact + uses: actions/upload-artifact@v4.4.0 + with: + name: ${{ inputs.apiFunctionName }}-build + path: backend/function-apps/api/${{ inputs.apiFunctionName }}.zip + if-no-files-found: error - - name: Upload Node Azure Functions Artifact + - name: Upload Migration Azure Functions Artifact uses: actions/upload-artifact@v4.4.0 with: - name: ${{ inputs.apiName }}-build - path: backend/functions/${{ inputs.apiName }}.zip + name: ${{ inputs.migrationFunctionName }}-build + path: backend/function-apps/migration/${{ inputs.migrationFunctionName }}.zip if-no-files-found: error diff --git a/.github/workflows/sub-deploy-code-slot.yml b/.github/workflows/sub-deploy-code-slot.yml index 1041d44f6..1276aad9b 100644 --- a/.github/workflows/sub-deploy-code-slot.yml +++ b/.github/workflows/sub-deploy-code-slot.yml @@ -15,7 +15,10 @@ on: webappName: required: true type: string - apiName: + apiFunctionName: + required: true + type: string + migrationFunctionName: required: true type: string azResourceGrpAppEncrypted: @@ -40,8 +43,9 @@ jobs: ghaEnvironment: ${{ inputs.ghaEnvironment }} environmentHash: ${{ inputs.environmentHash }} stackName: ${{ inputs.stackName }} - webAppName: ${{ inputs.webappName }} - apiName: ${{ inputs.apiName }} + webappName: ${{ inputs.webappName }} + apiFunctionName: ${{ inputs.apiFunctionName }} + migrationFunctionName: ${{ inputs.migrationFunctionName }} azResourceGrpAppEncrypted: ${{ inputs.azResourceGrpAppEncrypted }} secrets: inherit # pragma: allowlist secret @@ -77,7 +81,7 @@ jobs: -n ${{ inputs.webappName }} \ --slotName ${{ inputs.slotName }} - deploy-service-slot: + deploy-api-slot: runs-on: ubuntu-latest environment: ${{ inputs.ghaEnvironment }} steps: @@ -86,7 +90,7 @@ jobs: - name: Download artifact from build job uses: actions/download-artifact@v4.1.7 with: - name: ${{ inputs.apiName }}-build + name: ${{ inputs.apiFunctionName }}-build - uses: azure/login@v1 with: @@ -100,22 +104,54 @@ jobs: op: decode in: ${{ inputs.azResourceGrpAppEncrypted }} - - name: Deploy Azure Functions slot backend - id: deploy-backend-slot-step + - name: Deploy Azure Function API slot + id: deploy-api-slot-step run: | ./ops/scripts/pipeline/slots/az-func-slot-deploy.sh \ -g ${{ steps.rgApp.outputs.out }} \ - -n ${{ inputs.apiName }} \ - --src ./${{ inputs.apiName }}.zip \ + -n ${{ inputs.apiFunctionName }} \ + --src ./${{ inputs.apiFunctionName }}.zip \ + --slotName ${{ inputs.slotName }} + + deploy-migration-slot: + runs-on: ubuntu-latest + environment: ${{ inputs.ghaEnvironment }} + steps: + - uses: actions/checkout@main + + - name: Download artifact from build job + uses: actions/download-artifact@v4.1.7 + with: + name: ${{ inputs.migrationFunctionName }}-build + + - uses: azure/login@v1 + with: + creds: ${{ secrets.AZURE_CREDENTIALS }} + environment: ${{ vars.AZURE_ENVIRONMENT }} + + - uses: cloudposse/github-action-secret-outputs@main + id: rgApp + with: + secret: ${{ secrets.PGP_SIGNING_PASSPHRASE }} + op: decode + in: ${{ inputs.azResourceGrpAppEncrypted }} + + - name: Deploy Azure Function Migration slot + id: deploy-migration-slot-step + run: | + ./ops/scripts/pipeline/slots/az-func-slot-deploy.sh \ + -g ${{ steps.rgApp.outputs.out }} \ + -n ${{ inputs.migrationFunctionName }} \ + --src ./${{ inputs.migrationFunctionName }}.zip \ --slotName ${{ inputs.slotName }} endpoint-test-application-slot: - needs: [deploy-webapp-slot, deploy-service-slot] + needs: [deploy-webapp-slot, deploy-api-slot, deploy-migration-slot] uses: ./.github/workflows/reusable-endpoint-test.yml with: stackName: ${{ inputs.stackName }} webappName: ${{ inputs.webappName }} - apiName: ${{ inputs.apiName }} + apiFunctionName: ${{ inputs.apiFunctionName }} branchHashId: ${{ inputs.environmentHash }} ghaEnvironment: ${{ inputs.ghaEnvironment }} azResourceGrpAppEncrypted: ${{ inputs.azResourceGrpAppEncrypted }} @@ -124,10 +160,15 @@ jobs: execute-e2e-test: needs: - [deploy-webapp-slot, deploy-service-slot, endpoint-test-application-slot] + [ + deploy-webapp-slot, + deploy-api-slot, + deploy-migration-slot, + endpoint-test-application-slot, + ] uses: ./.github/workflows/reusable-e2e.yml with: - apiName: ${{ inputs.apiName }} + apiFunctionName: ${{ inputs.apiFunctionName }} slotName: ${{ inputs.slotName }} webappName: ${{ inputs.webappName }} stackName: ${{ inputs.stackName }} @@ -140,7 +181,13 @@ jobs: swap-webapp-deployment-slot: if: ${{ inputs.initialDeployment != 'true' }} runs-on: ubuntu-latest - needs: [deploy-webapp-slot, deploy-service-slot, execute-e2e-test] + needs: + [ + deploy-webapp-slot, + deploy-api-slot, + deploy-migration-slot, + execute-e2e-test, + ] environment: ${{ inputs.ghaEnvironment }} env: webappName: ${{ inputs.webappName }} @@ -164,10 +211,45 @@ jobs: swap-nodeapi-deployment-slot: if: ${{ inputs.initialDeployment != 'true' }} runs-on: ubuntu-latest - needs: [deploy-webapp-slot, deploy-service-slot, execute-e2e-test] + needs: + [ + deploy-webapp-slot, + deploy-api-slot, + deploy-migration-slot, + execute-e2e-test, + ] + environment: ${{ inputs.ghaEnvironment }} + env: + apiFunctionName: ${{ inputs.apiFunctionName }} + slotName: ${{ inputs.slotName }} + steps: + - uses: azure/login@v1 + with: + creds: ${{ secrets.AZURE_CREDENTIALS }} + environment: ${{ vars.AZURE_ENVIRONMENT }} + - uses: cloudposse/github-action-secret-outputs@main + id: rgApp + with: + secret: ${{ secrets.PGP_SIGNING_PASSPHRASE }} + op: decode + in: ${{ inputs.azResourceGrpAppEncrypted }} + - name: Swap Deployment Slot + run: | + az functionapp deployment slot swap --slot ${{ env.slotName }} --name ${{ env.apiFunctionName }} -g ${{ steps.rgApp.outputs.out }} + az webapp traffic-routing clear --name ${{ env.apiFunctionName }} -g ${{ steps.rgApp.outputs.out }} + + swap-migration-app-deployment-slot: + if: ${{ inputs.initialDeployment != 'true' }} + runs-on: ubuntu-latest + needs: + [ + deploy-webapp-slot, + deploy-api-slot, + deploy-migration-slot, + execute-e2e-test, + ] environment: ${{ inputs.ghaEnvironment }} env: - apiName: ${{ inputs.apiName }} slotName: ${{ inputs.slotName }} steps: - uses: azure/login@v1 @@ -182,8 +264,9 @@ jobs: in: ${{ inputs.azResourceGrpAppEncrypted }} - name: Swap Deployment Slot run: | - az functionapp deployment slot swap --slot ${{ env.slotName }} --name ${{ env.apiName }} -g ${{ steps.rgApp.outputs.out }} - az webapp traffic-routing clear --name ${{ env.apiName }} -g ${{ steps.rgApp.outputs.out }} + az functionapp deployment slot swap --slot ${{ env.slotName }} --name ${{ inputs.migrationFunctionName }} -g ${{ steps.rgApp.outputs.out }} + az webapp traffic-routing clear --name ${{ inputs.migrationFunctionName }} -g ${{ steps.rgApp.outputs.out }} + az functionapp stop -g ${{ steps.rgApp.outputs.out }} --name ${{ inputs.migrationFunctionName }} --slot ${{ inputs.slotName }} endpoint-test-application-post-swap: needs: [swap-nodeapi-deployment-slot, swap-webapp-deployment-slot] @@ -191,7 +274,7 @@ jobs: with: stackName: ${{ inputs.stackName }} webappName: ${{ inputs.webappName }} - apiName: ${{ inputs.apiName }} + apiFunctionName: ${{ inputs.apiFunctionName }} branchHashId: ${{ inputs.environmentHash }} ghaEnvironment: ${{ inputs.ghaEnvironment }} azResourceGrpAppEncrypted: ${{ inputs.azResourceGrpAppEncrypted }} @@ -204,7 +287,7 @@ jobs: environment: ${{ inputs.ghaEnvironment }} env: webappName: ${{ inputs.webappName }} - apiName: ${{ inputs.apiName }} + apiFunctionName: ${{ inputs.apiFunctionName }} steps: - uses: azure/login@v1 with: @@ -221,4 +304,5 @@ jobs: - name: Enable production slot access run: | az webapp config access-restriction add --resource-group ${{ steps.rgApp.outputs.out }} --name ${{ env.webappName }} --rule-name AllowAll --action Allow --ip-address 0.0.0.0/0 --priority 100 1>/dev/null || true - az functionapp config access-restriction add --resource-group ${{ steps.rgApp.outputs.out }} --name ${{ env.apiName }} --rule-name AllowAll --action Allow --ip-address 0.0.0.0/0 --priority 100 1>/dev/null || true + az functionapp config access-restriction add --resource-group ${{ steps.rgApp.outputs.out }} --name ${{ env.apiFunctionName }} --rule-name AllowAll --action Allow --ip-address 0.0.0.0/0 --priority 100 1>/dev/null || true + az functionapp config access-restriction add --resource-group ${{ steps.rgApp.outputs.out }} --name ${{ inputs.migrationFunctionName }} --rule-name AllowAll --action Allow --ip-address 0.0.0.0/0 --priority 100 1>/dev/null || true diff --git a/.github/workflows/sub-deploy-code.yml b/.github/workflows/sub-deploy-code.yml index 7befe872a..d0dbc8071 100644 --- a/.github/workflows/sub-deploy-code.yml +++ b/.github/workflows/sub-deploy-code.yml @@ -15,7 +15,10 @@ on: webappName: required: true type: string - apiName: + apiFunctionName: + required: true + type: string + migrationFunctionName: required: true type: string azResourceGrpAppEncrypted: @@ -54,7 +57,39 @@ jobs: -g ${{ steps.rgApp.outputs.out }} \ -n ${{ inputs.webappName }} - deploy-service: + deploy-api: + runs-on: ubuntu-latest + environment: ${{ inputs.ghaEnvironment }} + steps: + - uses: actions/checkout@main + + - name: Download artifact from build job + uses: actions/download-artifact@v4.1.7 + with: + name: ${{ inputs.apiFunctionName }}-build + + - uses: azure/login@v1 + with: + creds: ${{ secrets.AZURE_CREDENTIALS }} + environment: ${{ vars.AZURE_ENVIRONMENT }} + + - uses: cloudposse/github-action-secret-outputs@main + id: rgApp + with: + secret: ${{ secrets.PGP_SIGNING_PASSPHRASE }} + op: decode + in: ${{ inputs.azResourceGrpAppEncrypted }} + + - name: Deploy Azure Functions API + id: deploy-backend-api-step + run: | + sleep 30 && + ./ops/scripts/pipeline/az-func-deploy.sh \ + -g ${{ steps.rgApp.outputs.out }} \ + -n ${{ inputs.apiFunctionName }} \ + --src ./${{ inputs.apiFunctionName }}.zip + + deploy-migration-app: runs-on: ubuntu-latest environment: ${{ inputs.ghaEnvironment }} steps: @@ -63,7 +98,7 @@ jobs: - name: Download artifact from build job uses: actions/download-artifact@v4.1.7 with: - name: ${{ inputs.apiName }}-build + name: ${{ inputs.migrationFunctionName }}-build - uses: azure/login@v1 with: @@ -77,22 +112,22 @@ jobs: op: decode in: ${{ inputs.azResourceGrpAppEncrypted }} - - name: Deploy Azure Functions backend - id: deploy-backend-step + - name: Deploy Azure Function Migration App + id: deploy-migration-app-step run: | sleep 30 && ./ops/scripts/pipeline/az-func-deploy.sh \ -g ${{ steps.rgApp.outputs.out }} \ - -n ${{ inputs.apiName }} \ - --src ./${{ inputs.apiName }}.zip + -n ${{ inputs.migrationFunctionName }} \ + --src ./${{ inputs.migrationFunctionName }}.zip - endpoint-test-application: - needs: [deploy-webapp, deploy-service] + endpoint-test-application: # TODO: healthcheck/endpoint test on new migration function app? + needs: [deploy-webapp, deploy-api] uses: ./.github/workflows/reusable-endpoint-test.yml with: stackName: ${{ inputs.stackName }} webappName: ${{ inputs.webappName }} - apiName: ${{ inputs.apiName }} + apiFunctionName: ${{ inputs.apiFunctionName }} branchHashId: ${{ inputs.environmentHash }} ghaEnvironment: ${{ inputs.ghaEnvironment }} azResourceGrpAppEncrypted: ${{ inputs.azResourceGrpAppEncrypted }} @@ -105,7 +140,7 @@ jobs: environment: ${{ inputs.ghaEnvironment }} env: webappName: ${{ inputs.webappName }} - apiName: ${{ inputs.apiName }} + apiFunctionName: ${{ inputs.apiFunctionName }} steps: - uses: azure/login@v1 with: @@ -122,4 +157,4 @@ jobs: - name: Enable production slot access run: | az webapp config access-restriction add --resource-group ${{ steps.rgApp.outputs.out }} --name ${{ env.webappName }} --rule-name AllowAll --action Allow --ip-address 0.0.0.0/0 --priority 100 1>/dev/null || true - az functionapp config access-restriction add --resource-group ${{ steps.rgApp.outputs.out }} --name ${{ env.apiName }} --rule-name AllowAll --action Allow --ip-address 0.0.0.0/0 --priority 100 1>/dev/null || true + az functionapp config access-restriction add --resource-group ${{ steps.rgApp.outputs.out }} --name ${{ env.apiFunctionName }} --rule-name AllowAll --action Allow --ip-address 0.0.0.0/0 --priority 100 1>/dev/null || true diff --git a/.github/workflows/sub-deploy-slot-resources.yml b/.github/workflows/sub-deploy-slot-resources.yml index fe4272ec4..026fcaeea 100644 --- a/.github/workflows/sub-deploy-slot-resources.yml +++ b/.github/workflows/sub-deploy-slot-resources.yml @@ -6,7 +6,10 @@ on: webAppName: required: true type: string - apiName: + apiFunctionName: + required: true + type: string + migrationFunctionName: required: true type: string ghaEnvironment: @@ -29,7 +32,7 @@ jobs: uses: ./.github/workflows/reusable-frontend-slot.yml with: webAppName: ${{ inputs.webAppName }} - apiName: ${{ inputs.apiName }} + apiFunctionName: ${{ inputs.apiFunctionName }} ghaEnvironment: ${{ inputs.ghaEnvironment }} azResourceGrpAppEncrypted: ${{ inputs.azResourceGrpAppEncrypted }} azResourceGrpNetworkEncrypted: ${{ inputs.azResourceGrpNetworkEncrypted }} @@ -40,7 +43,8 @@ jobs: uses: ./.github/workflows/reusable-backend-slot.yml with: webAppName: ${{ inputs.webAppName }} - apiName: ${{ inputs.apiName }} + apiFunctionName: ${{ inputs.apiFunctionName }} + migrationFunctionName: ${{ inputs.migrationFunctionName }} ghaEnvironment: ${{ inputs.ghaEnvironment }} azResourceGrpAppEncrypted: ${{ inputs.azResourceGrpAppEncrypted }} azResourceGrpNetworkEncrypted: ${{ inputs.azResourceGrpNetworkEncrypted }} diff --git a/.github/workflows/sub-deploy.yml b/.github/workflows/sub-deploy.yml index fbe55bcf2..c566d2a33 100644 --- a/.github/workflows/sub-deploy.yml +++ b/.github/workflows/sub-deploy.yml @@ -15,7 +15,10 @@ on: stackName: required: true type: string - apiName: + apiFunctionName: + required: true + type: string + migrationFunctionName: required: true type: string webAppName: @@ -45,7 +48,9 @@ jobs: deploy-infra: name: Azure Infrastructure uses: ./.github/workflows/reusable-deploy.yml - if: ((github.ref == 'refs/heads/main') || (inputs.deployBranch == 'true')) && ${{ inputs.deployBicep == 'true' }} + if: + ((github.ref == 'refs/heads/main') || (inputs.deployBranch == 'true')) && ${{ + inputs.deployBicep == 'true' }} with: ghaEnvironment: ${{ inputs.ghaEnvironment }} azResourceGrpAppEncrypted: ${{ inputs.azResourceGrpAppEncrypted }} @@ -66,7 +71,8 @@ jobs: ghaEnvironment: ${{ inputs.ghaEnvironment }} azResourceGrpNetworkEncrypted: ${{ inputs.azResourceGrpNetworkEncrypted }} environmentHash: ${{ inputs.environmentHash }} - apiName: ${{ inputs.apiName }} + apiFunctionName: ${{ inputs.apiFunctionName }} + migrationFunctionName: ${{ inputs.migrationFunctionName }} secrets: inherit # pragma: allowlist secret deploy-slot-resources: @@ -76,7 +82,8 @@ jobs: if: ((github.ref == 'refs/heads/main') || (inputs.deployBranch == 'true')) with: webAppName: ${{ inputs.webappName }} - apiName: ${{ inputs.apiName }} + apiFunctionName: ${{ inputs.apiFunctionName }} + migrationFunctionName: ${{ inputs.migrationFunctionName }} ghaEnvironment: ${{ inputs.ghaEnvironment }} azResourceGrpAppEncrypted: ${{ inputs.azResourceGrpAppEncrypted }} azResourceGrpNetworkEncrypted: ${{ inputs.azResourceGrpNetworkEncrypted }} diff --git a/.github/workflows/sub-security-scan.yml b/.github/workflows/sub-security-scan.yml index 45d33114e..dd6f78a53 100644 --- a/.github/workflows/sub-security-scan.yml +++ b/.github/workflows/sub-security-scan.yml @@ -12,7 +12,7 @@ jobs: sca-scan-backend: uses: ./.github/workflows/reusable-sca-scan.yml with: - path: backend/functions + path: backend secrets: inherit # pragma: allowlist secret sca-scan-common: diff --git a/.gitignore b/.gitignore index 98d9ac132..bebb0bbf8 100644 --- a/.gitignore +++ b/.gitignore @@ -75,6 +75,9 @@ cams1.code-workspace # Node **/node_modules/ +# Dist +**/dist/ + # Veracode **/pipeline-scan* diff --git a/architecture/export-architecture-diagrams.sh b/architecture/export-architecture-diagrams.sh index 8324da346..0fc80478f 100755 --- a/architecture/export-architecture-diagrams.sh +++ b/architecture/export-architecture-diagrams.sh @@ -41,7 +41,7 @@ mermaid_file="./structurizr-FunctionsAPIwithWebapp.mmd" cat "$mermaid_file" printf "\n\`\`\`\n" } > temp_file.md -mv temp_file.md ../docs/architecture/diagrams/cams-webapp-with-functions-api.md +mv temp_file.md ../docs/architecture/diagrams/cams-webapp-with-function-apps-api.md ## CAMS Webapp Components mermaid_file="./structurizr-CAMSWebapp.mmd" @@ -59,6 +59,6 @@ mermaid_file="./structurizr-FunctionsAPI.mmd" cat "$mermaid_file" printf "\n\`\`\`\n" } > temp_file.md -mv temp_file.md ../docs/architecture/diagrams/cams-functions-api-components.md +mv temp_file.md ../docs/architecture/diagrams/cams-function-apps-api-components.md popd || exit diff --git a/backend/functions/.dependency-cruiser.js b/backend/.dependency-cruiser.js similarity index 100% rename from backend/functions/.dependency-cruiser.js rename to backend/.dependency-cruiser.js diff --git a/backend/functions/.eslintignore b/backend/.eslintignore similarity index 100% rename from backend/functions/.eslintignore rename to backend/.eslintignore diff --git a/backend/functions/.eslintrc.json b/backend/.eslintrc.json similarity index 100% rename from backend/functions/.eslintrc.json rename to backend/.eslintrc.json diff --git a/backend/functions/.gitignore b/backend/.gitignore similarity index 100% rename from backend/functions/.gitignore rename to backend/.gitignore diff --git a/backend/functions/.prettierrc b/backend/.prettierrc similarity index 100% rename from backend/functions/.prettierrc rename to backend/.prettierrc diff --git a/backend/functions/.funcignore b/backend/function-apps/api/.funcignore similarity index 100% rename from backend/functions/.funcignore rename to backend/function-apps/api/.funcignore diff --git a/backend/function-apps/api/.gitignore b/backend/function-apps/api/.gitignore new file mode 100644 index 000000000..ee0da9b3f --- /dev/null +++ b/backend/function-apps/api/.gitignore @@ -0,0 +1,2 @@ +# Ignore package-lock.json as this project should not have its own dependencies +package-lock.json diff --git a/backend/functions/attorneys/attorneys.function.test.ts b/backend/function-apps/api/attorneys/attorneys.function.test.ts similarity index 78% rename from backend/functions/attorneys/attorneys.function.test.ts rename to backend/function-apps/api/attorneys/attorneys.function.test.ts index f0375b9c8..897502717 100644 --- a/backend/functions/attorneys/attorneys.function.test.ts +++ b/backend/function-apps/api/attorneys/attorneys.function.test.ts @@ -1,17 +1,17 @@ -import { AttorneysController } from '../lib/controllers/attorneys/attorneys.controller'; -import { CamsError } from '../lib/common-errors/cams-error'; -import { MockData } from '../../../common/src/cams/test-utilities/mock-data'; +import { AttorneysController } from '../../../lib/controllers/attorneys/attorneys.controller'; +import { CamsError } from '../../../lib/common-errors/cams-error'; +import { MockData } from '../../../../common/src/cams/test-utilities/mock-data'; import { buildTestResponseError, buildTestResponseSuccess, createMockAzureFunctionRequest, -} from '../azure/testing-helpers'; -import AttorneyList from '../lib/use-cases/attorneys'; +} from '../../azure/testing-helpers'; +import AttorneyList from '../../../lib/use-cases/attorneys'; import handler from './attorneys.function'; import { InvocationContext } from '@azure/functions'; -import { ResponseBody } from '../../../common/src/api/response'; -import { AttorneyUser } from '../../../common/src/cams/users'; -import ContextCreator from '../azure/application-context-creator'; +import { ResponseBody } from '../../../../common/src/api/response'; +import { AttorneyUser } from '../../../../common/src/cams/users'; +import ContextCreator from '../../azure/application-context-creator'; describe('Attorneys Azure Function tests', () => { const request = createMockAzureFunctionRequest(); diff --git a/backend/functions/attorneys/attorneys.function.ts b/backend/function-apps/api/attorneys/attorneys.function.ts similarity index 75% rename from backend/functions/attorneys/attorneys.function.ts rename to backend/function-apps/api/attorneys/attorneys.function.ts index 802e1aac4..c69188491 100644 --- a/backend/functions/attorneys/attorneys.function.ts +++ b/backend/function-apps/api/attorneys/attorneys.function.ts @@ -1,9 +1,9 @@ import * as dotenv from 'dotenv'; import { app, HttpRequest, HttpResponseInit, InvocationContext } from '@azure/functions'; -import { AttorneysController } from '../lib/controllers/attorneys/attorneys.controller'; -import { initializeApplicationInsights } from '../azure/app-insights'; -import { toAzureError, toAzureSuccess } from '../azure/functions'; -import ContextCreator from '../azure/application-context-creator'; +import { AttorneysController } from '../../../lib/controllers/attorneys/attorneys.controller'; +import { initializeApplicationInsights } from '../../azure/app-insights'; +import { toAzureError, toAzureSuccess } from '../../azure/functions'; +import ContextCreator from '../../azure/application-context-creator'; dotenv.config(); diff --git a/backend/functions/case-assignments/case.assignment.function.test.ts b/backend/function-apps/api/case-assignments/case.assignment.function.test.ts similarity index 85% rename from backend/functions/case-assignments/case.assignment.function.test.ts rename to backend/function-apps/api/case-assignments/case.assignment.function.test.ts index 0b08f5710..c51997169 100644 --- a/backend/functions/case-assignments/case.assignment.function.test.ts +++ b/backend/function-apps/api/case-assignments/case.assignment.function.test.ts @@ -1,19 +1,19 @@ import handler from './case.assignment.function'; -import { CaseAssignmentController } from '../lib/controllers/case-assignment/case.assignment.controller'; -import ContextCreator from '../azure/application-context-creator'; -import { CaseAssignment } from '../../../common/src/cams/assignments'; -import { MockData } from '../../../common/src/cams/test-utilities/mock-data'; -import { CamsHttpRequest } from '../lib/adapters/types/http'; +import { CaseAssignmentController } from '../../../lib/controllers/case-assignment/case.assignment.controller'; +import ContextCreator from '../../azure/application-context-creator'; +import { CaseAssignment } from '../../../../common/src/cams/assignments'; +import { MockData } from '../../../../common/src/cams/test-utilities/mock-data'; +import { CamsHttpRequest } from '../../../lib/adapters/types/http'; import { InvocationContext } from '@azure/functions'; -import { createMockApplicationContext } from '../lib/testing/testing-utilities'; +import { createMockApplicationContext } from '../../../lib/testing/testing-utilities'; import { buildTestResponseError, buildTestResponseSuccess, createMockAzureFunctionRequest, -} from '../azure/testing-helpers'; -import { CamsError } from '../lib/common-errors/cams-error'; -import { UnknownError } from '../lib/common-errors/unknown-error'; -import HttpStatusCodes from '../../../common/src/api/http-status-codes'; +} from '../../azure/testing-helpers'; +import { CamsError } from '../../../lib/common-errors/cams-error'; +import { UnknownError } from '../../../lib/common-errors/unknown-error'; +import HttpStatusCodes from '../../../../common/src/api/http-status-codes'; describe('Case Assignment Function Tests', () => { const defaultRequestProps: Partial = { diff --git a/backend/functions/case-assignments/case.assignment.function.ts b/backend/function-apps/api/case-assignments/case.assignment.function.ts similarity index 75% rename from backend/functions/case-assignments/case.assignment.function.ts rename to backend/function-apps/api/case-assignments/case.assignment.function.ts index 62f75fce0..7977d3a43 100644 --- a/backend/functions/case-assignments/case.assignment.function.ts +++ b/backend/function-apps/api/case-assignments/case.assignment.function.ts @@ -1,8 +1,8 @@ import { app, InvocationContext, HttpRequest, HttpResponseInit } from '@azure/functions'; -import { CaseAssignmentController } from '../lib/controllers/case-assignment/case.assignment.controller'; -import ContextCreator from '../azure/application-context-creator'; -import { initializeApplicationInsights } from '../azure/app-insights'; -import { toAzureError, toAzureSuccess } from '../azure/functions'; +import { CaseAssignmentController } from '../../../lib/controllers/case-assignment/case.assignment.controller'; +import ContextCreator from '../../azure/application-context-creator'; +import { initializeApplicationInsights } from '../../azure/app-insights'; +import { toAzureError, toAzureSuccess } from '../../azure/functions'; const MODULE_NAME = 'CASE-ASSIGNMENT-FUNCTION'; diff --git a/backend/functions/case-associated/case-associated.function.test.ts b/backend/function-apps/api/case-associated/case-associated.function.test.ts similarity index 77% rename from backend/functions/case-associated/case-associated.function.test.ts rename to backend/function-apps/api/case-associated/case-associated.function.test.ts index fa585f15b..29d4a02df 100644 --- a/backend/functions/case-associated/case-associated.function.test.ts +++ b/backend/function-apps/api/case-associated/case-associated.function.test.ts @@ -1,15 +1,15 @@ -import { NotFoundError } from '../lib/common-errors/not-found-error'; -import { CaseAssociatedController } from '../lib/controllers/case-associated/case-associated.controller'; +import { NotFoundError } from '../../../lib/common-errors/not-found-error'; +import { CaseAssociatedController } from '../../../lib/controllers/case-associated/case-associated.controller'; import handler from './case-associated.function'; -import ContextCreator from '../azure/application-context-creator'; -import MockData from '../../../common/src/cams/test-utilities/mock-data'; +import ContextCreator from '../../azure/application-context-creator'; +import MockData from '../../../../common/src/cams/test-utilities/mock-data'; import { InvocationContext } from '@azure/functions'; import { buildTestResponseError, buildTestResponseSuccess, createMockAzureFunctionRequest, -} from '../azure/testing-helpers'; -import { EventCaseReference } from '../../../common/src/cams/events'; +} from '../../azure/testing-helpers'; +import { EventCaseReference } from '../../../../common/src/cams/events'; describe('Case summary function', () => { jest diff --git a/backend/functions/case-associated/case-associated.function.ts b/backend/function-apps/api/case-associated/case-associated.function.ts similarity index 74% rename from backend/functions/case-associated/case-associated.function.ts rename to backend/function-apps/api/case-associated/case-associated.function.ts index ded7a8332..5994d86b2 100644 --- a/backend/functions/case-associated/case-associated.function.ts +++ b/backend/function-apps/api/case-associated/case-associated.function.ts @@ -1,9 +1,9 @@ import * as dotenv from 'dotenv'; import { app, HttpRequest, HttpResponseInit, InvocationContext } from '@azure/functions'; -import ContextCreator from '../azure/application-context-creator'; -import { initializeApplicationInsights } from '../azure/app-insights'; -import { CaseAssociatedController } from '../lib/controllers/case-associated/case-associated.controller'; -import { toAzureError, toAzureSuccess } from '../azure/functions'; +import ContextCreator from '../../azure/application-context-creator'; +import { initializeApplicationInsights } from '../../azure/app-insights'; +import { CaseAssociatedController } from '../../../lib/controllers/case-associated/case-associated.controller'; +import { toAzureError, toAzureSuccess } from '../../azure/functions'; dotenv.config(); diff --git a/backend/functions/case-docket/case-docket.function.test.ts b/backend/function-apps/api/case-docket/case-docket.function.test.ts similarity index 73% rename from backend/functions/case-docket/case-docket.function.test.ts rename to backend/function-apps/api/case-docket/case-docket.function.test.ts index 17d8efc66..9bd996781 100644 --- a/backend/functions/case-docket/case-docket.function.test.ts +++ b/backend/function-apps/api/case-docket/case-docket.function.test.ts @@ -1,16 +1,16 @@ import handler from './case-docket.function'; -import { DXTR_CASE_DOCKET_ENTRIES } from '../lib/testing/mock-data/case-docket-entries.mock'; -import { NORMAL_CASE_ID, NOT_FOUND_ERROR_CASE_ID } from '../lib/testing/testing-constants'; +import { DXTR_CASE_DOCKET_ENTRIES } from '../../../lib/testing/mock-data/case-docket-entries.mock'; +import { NORMAL_CASE_ID, NOT_FOUND_ERROR_CASE_ID } from '../../../lib/testing/testing-constants'; import { InvocationContext } from '@azure/functions'; -import { CamsHttpRequest } from '../lib/adapters/types/http'; +import { CamsHttpRequest } from '../../../lib/adapters/types/http'; import { buildTestResponseError, buildTestResponseSuccess, createMockAzureFunctionRequest, -} from '../azure/testing-helpers'; -import { CaseDocketController } from '../lib/controllers/case-docket/case-docket.controller'; -import { NotFoundError } from '../lib/common-errors/not-found-error'; -import { CaseDocket } from '../../../common/src/cams/cases'; +} from '../../azure/testing-helpers'; +import { CaseDocketController } from '../../../lib/controllers/case-docket/case-docket.controller'; +import { NotFoundError } from '../../../lib/common-errors/not-found-error'; +import { CaseDocket } from '../../../../common/src/cams/cases'; describe('Case docket function', () => { const context = new InvocationContext({ diff --git a/backend/functions/case-docket/case-docket.function.ts b/backend/function-apps/api/case-docket/case-docket.function.ts similarity index 77% rename from backend/functions/case-docket/case-docket.function.ts rename to backend/function-apps/api/case-docket/case-docket.function.ts index 1aad04740..478e5fe0f 100644 --- a/backend/functions/case-docket/case-docket.function.ts +++ b/backend/function-apps/api/case-docket/case-docket.function.ts @@ -1,9 +1,9 @@ import * as dotenv from 'dotenv'; import { app, HttpRequest, HttpResponseInit, InvocationContext } from '@azure/functions'; -import ContextCreator from '../azure/application-context-creator'; -import { CaseDocketController } from '../lib/controllers/case-docket/case-docket.controller'; -import { initializeApplicationInsights } from '../azure/app-insights'; -import { toAzureError, toAzureSuccess } from '../azure/functions'; +import ContextCreator from '../../azure/application-context-creator'; +import { CaseDocketController } from '../../../lib/controllers/case-docket/case-docket.controller'; +import { initializeApplicationInsights } from '../../azure/app-insights'; +import { toAzureError, toAzureSuccess } from '../../azure/functions'; dotenv.config(); diff --git a/backend/functions/case-history/case-history.function.test.ts b/backend/function-apps/api/case-history/case-history.function.test.ts similarity index 74% rename from backend/functions/case-history/case-history.function.test.ts rename to backend/function-apps/api/case-history/case-history.function.test.ts index 5f4198cdc..f9d1a9a93 100644 --- a/backend/functions/case-history/case-history.function.test.ts +++ b/backend/function-apps/api/case-history/case-history.function.test.ts @@ -1,18 +1,18 @@ -import { CASE_HISTORY } from '../lib/testing/mock-data/case-history.mock'; -import { NORMAL_CASE_ID, NOT_FOUND_ERROR_CASE_ID } from '../lib/testing/testing-constants'; -import { NotFoundError } from '../lib/common-errors/not-found-error'; -import { CamsHttpRequest } from '../lib/adapters/types/http'; +import { CASE_HISTORY } from '../../../lib/testing/mock-data/case-history.mock'; +import { NORMAL_CASE_ID, NOT_FOUND_ERROR_CASE_ID } from '../../../lib/testing/testing-constants'; +import { NotFoundError } from '../../../lib/common-errors/not-found-error'; +import { CamsHttpRequest } from '../../../lib/adapters/types/http'; import { InvocationContext } from '@azure/functions'; import handler from './case-history.function'; -import ContextCreator from '../azure/application-context-creator'; -import MockData from '../../../common/src/cams/test-utilities/mock-data'; -import { CaseHistoryController } from '../lib/controllers/case-history/case-history.controller'; +import ContextCreator from '../../azure/application-context-creator'; +import MockData from '../../../../common/src/cams/test-utilities/mock-data'; +import { CaseHistoryController } from '../../../lib/controllers/case-history/case-history.controller'; import { buildTestResponseError, buildTestResponseSuccess, createMockAzureFunctionRequest, -} from '../azure/testing-helpers'; -import { CaseHistory } from '../../../common/src/cams/history'; +} from '../../azure/testing-helpers'; +import { CaseHistory } from '../../../../common/src/cams/history'; describe('Case History Function Tests', () => { const defaultRequestProps: Partial = { diff --git a/backend/functions/case-history/case-history.function.ts b/backend/function-apps/api/case-history/case-history.function.ts similarity index 75% rename from backend/functions/case-history/case-history.function.ts rename to backend/function-apps/api/case-history/case-history.function.ts index 69ffec218..c33b2a237 100644 --- a/backend/functions/case-history/case-history.function.ts +++ b/backend/function-apps/api/case-history/case-history.function.ts @@ -1,9 +1,9 @@ import * as dotenv from 'dotenv'; import { app, InvocationContext, HttpRequest, HttpResponseInit } from '@azure/functions'; -import ContextCreator from '../azure/application-context-creator'; -import { CaseHistoryController } from '../lib/controllers/case-history/case-history.controller'; -import { initializeApplicationInsights } from '../azure/app-insights'; -import { toAzureError, toAzureSuccess } from '../azure/functions'; +import ContextCreator from '../../azure/application-context-creator'; +import { CaseHistoryController } from '../../../lib/controllers/case-history/case-history.controller'; +import { initializeApplicationInsights } from '../../azure/app-insights'; +import { toAzureError, toAzureSuccess } from '../../azure/functions'; const MODULE_NAME = 'CASE-HISTORY-FUNCTION'; diff --git a/backend/functions/case-summary/case-summary.function.test.ts b/backend/function-apps/api/case-summary/case-summary.function.test.ts similarity index 79% rename from backend/functions/case-summary/case-summary.function.test.ts rename to backend/function-apps/api/case-summary/case-summary.function.test.ts index 40ee2fda9..b497fac70 100644 --- a/backend/functions/case-summary/case-summary.function.test.ts +++ b/backend/function-apps/api/case-summary/case-summary.function.test.ts @@ -1,16 +1,16 @@ import { InvocationContext } from '@azure/functions'; -import { CaseDetail } from '../../../common/src/cams/cases'; -import { MockData } from '../../../common/src/cams/test-utilities/mock-data'; -import { NotFoundError } from '../lib/common-errors/not-found-error'; +import { CaseDetail } from '../../../../common/src/cams/cases'; +import { MockData } from '../../../../common/src/cams/test-utilities/mock-data'; +import { NotFoundError } from '../../../lib/common-errors/not-found-error'; import handler from './case-summary.function'; -import ContextCreator from '../azure/application-context-creator'; +import ContextCreator from '../../azure/application-context-creator'; import { buildTestResponseError, buildTestResponseSuccess, createMockAzureFunctionRequest, -} from '../azure/testing-helpers'; -import { CamsHttpRequest } from '../lib/adapters/types/http'; -import { CaseSummaryController } from '../lib/controllers/case-summary/case-summary.controller'; +} from '../../azure/testing-helpers'; +import { CamsHttpRequest } from '../../../lib/adapters/types/http'; +import { CaseSummaryController } from '../../../lib/controllers/case-summary/case-summary.controller'; describe('Case summary function', () => { jest diff --git a/backend/functions/case-summary/case-summary.function.ts b/backend/function-apps/api/case-summary/case-summary.function.ts similarity index 75% rename from backend/functions/case-summary/case-summary.function.ts rename to backend/function-apps/api/case-summary/case-summary.function.ts index 81204a5f7..7a34a9ba6 100644 --- a/backend/functions/case-summary/case-summary.function.ts +++ b/backend/function-apps/api/case-summary/case-summary.function.ts @@ -1,9 +1,9 @@ import * as dotenv from 'dotenv'; import { app, HttpRequest, HttpResponseInit, InvocationContext } from '@azure/functions'; -import ContextCreator from '../azure/application-context-creator'; -import { initializeApplicationInsights } from '../azure/app-insights'; -import { toAzureError, toAzureSuccess } from '../azure/functions'; -import { CaseSummaryController } from '../lib/controllers/case-summary/case-summary.controller'; +import ContextCreator from '../../azure/application-context-creator'; +import { initializeApplicationInsights } from '../../azure/app-insights'; +import { toAzureError, toAzureSuccess } from '../../azure/functions'; +import { CaseSummaryController } from '../../../lib/controllers/case-summary/case-summary.controller'; dotenv.config(); diff --git a/backend/functions/cases/cases.function.test.ts b/backend/function-apps/api/cases/cases.function.test.ts similarity index 72% rename from backend/functions/cases/cases.function.test.ts rename to backend/function-apps/api/cases/cases.function.test.ts index c3cc1db1b..4730c1a25 100644 --- a/backend/functions/cases/cases.function.test.ts +++ b/backend/function-apps/api/cases/cases.function.test.ts @@ -1,13 +1,16 @@ import handler from './cases.function'; -import { buildTestResponseSuccess, createMockAzureFunctionRequest } from '../azure/testing-helpers'; -import { CasesController } from '../lib/controllers/cases/cases.controller'; -import ContextCreator from '../azure/application-context-creator'; -import MockData from '../../../common/src/cams/test-utilities/mock-data'; +import { + buildTestResponseSuccess, + createMockAzureFunctionRequest, +} from '../../azure/testing-helpers'; +import { CasesController } from '../../../lib/controllers/cases/cases.controller'; +import ContextCreator from '../../azure/application-context-creator'; +import MockData from '../../../../common/src/cams/test-utilities/mock-data'; import { InvocationContext } from '@azure/functions'; -import { ResourceActions } from '../../../common/src/cams/actions'; -import { CaseDetail } from '../../../common/src/cams/cases'; -import { commonHeaders } from '../lib/adapters/utils/http-response'; -import { CamsError } from '../lib/common-errors/cams-error'; +import { ResourceActions } from '../../../../common/src/cams/actions'; +import { CaseDetail } from '../../../../common/src/cams/cases'; +import { commonHeaders } from '../../../lib/adapters/utils/http-response'; +import { CamsError } from '../../../lib/common-errors/cams-error'; describe('Cases function', () => { jest diff --git a/backend/functions/cases/cases.function.ts b/backend/function-apps/api/cases/cases.function.ts similarity index 76% rename from backend/functions/cases/cases.function.ts rename to backend/function-apps/api/cases/cases.function.ts index aaebe6a91..60251be68 100644 --- a/backend/functions/cases/cases.function.ts +++ b/backend/function-apps/api/cases/cases.function.ts @@ -1,9 +1,9 @@ import * as dotenv from 'dotenv'; import { app, HttpRequest, HttpResponseInit, InvocationContext } from '@azure/functions'; -import { CasesController } from '../lib/controllers/cases/cases.controller'; -import ContextCreator from '../azure/application-context-creator'; -import { initializeApplicationInsights } from '../azure/app-insights'; -import { toAzureError, toAzureSuccess } from '../azure/functions'; +import { CasesController } from '../../../lib/controllers/cases/cases.controller'; +import ContextCreator from '../../azure/application-context-creator'; +import { initializeApplicationInsights } from '../../azure/app-insights'; +import { toAzureError, toAzureSuccess } from '../../azure/functions'; dotenv.config(); diff --git a/backend/functions/consolidations/consolidations.function.test.ts b/backend/function-apps/api/consolidations/consolidations.function.test.ts similarity index 87% rename from backend/functions/consolidations/consolidations.function.test.ts rename to backend/function-apps/api/consolidations/consolidations.function.test.ts index 655c7f619..3b2c944f7 100644 --- a/backend/functions/consolidations/consolidations.function.test.ts +++ b/backend/function-apps/api/consolidations/consolidations.function.test.ts @@ -1,16 +1,16 @@ -import { MockData } from '../../../common/src/cams/test-utilities/mock-data'; +import { MockData } from '../../../../common/src/cams/test-utilities/mock-data'; import handler from './consolidations.function'; -import { CamsHttpRequest } from '../lib/adapters/types/http'; -import ContextCreator from '../azure/application-context-creator'; +import { CamsHttpRequest } from '../../../lib/adapters/types/http'; +import ContextCreator from '../../azure/application-context-creator'; import { buildTestResponseError, buildTestResponseSuccess, createMockAzureFunctionContext, createMockAzureFunctionRequest, -} from '../azure/testing-helpers'; -import { OrdersController } from '../lib/controllers/orders/orders.controller'; -import { ConsolidationOrder } from '../../../common/src/cams/orders'; -import { BadRequestError } from '../lib/common-errors/bad-request'; +} from '../../azure/testing-helpers'; +import { OrdersController } from '../../../lib/controllers/orders/orders.controller'; +import { ConsolidationOrder } from '../../../../common/src/cams/orders'; +import { BadRequestError } from '../../../lib/common-errors/bad-request'; describe('Consolidations Function tests', () => { const defaultRequestProps: Partial = { diff --git a/backend/functions/consolidations/consolidations.function.ts b/backend/function-apps/api/consolidations/consolidations.function.ts similarity index 76% rename from backend/functions/consolidations/consolidations.function.ts rename to backend/function-apps/api/consolidations/consolidations.function.ts index 8850455d8..107ceef02 100644 --- a/backend/functions/consolidations/consolidations.function.ts +++ b/backend/function-apps/api/consolidations/consolidations.function.ts @@ -1,9 +1,9 @@ import * as dotenv from 'dotenv'; -import { initializeApplicationInsights } from '../azure/app-insights'; +import { initializeApplicationInsights } from '../../azure/app-insights'; import { app, HttpRequest, HttpResponseInit, InvocationContext } from '@azure/functions'; -import ContextCreator from '../azure/application-context-creator'; -import { OrdersController } from '../lib/controllers/orders/orders.controller'; -import { toAzureError, toAzureSuccess } from '../azure/functions'; +import ContextCreator from '../../azure/application-context-creator'; +import { OrdersController } from '../../../lib/controllers/orders/orders.controller'; +import { toAzureError, toAzureSuccess } from '../../azure/functions'; dotenv.config(); diff --git a/backend/functions/courts/courts.function.test.ts b/backend/function-apps/api/courts/courts.function.test.ts similarity index 79% rename from backend/functions/courts/courts.function.test.ts rename to backend/function-apps/api/courts/courts.function.test.ts index a45286d01..aba16c247 100644 --- a/backend/functions/courts/courts.function.test.ts +++ b/backend/function-apps/api/courts/courts.function.test.ts @@ -1,14 +1,14 @@ -import { CamsError } from '../lib/common-errors/cams-error'; +import { CamsError } from '../../../lib/common-errors/cams-error'; import handler from './courts.function'; import { buildTestResponseError, buildTestResponseSuccess, createMockAzureFunctionContext, createMockAzureFunctionRequest, -} from '../azure/testing-helpers'; -import { CourtsController } from '../lib/controllers/courts/courts.controller'; -import { CourtDivisionDetails } from '../../../common/src/cams/courts'; -import { COURT_DIVISIONS } from '../../../common/src/cams/test-utilities/courts.mock'; +} from '../../azure/testing-helpers'; +import { CourtsController } from '../../../lib/controllers/courts/courts.controller'; +import { CourtDivisionDetails } from '../../../../common/src/cams/courts'; +import { COURT_DIVISIONS } from '../../../../common/src/cams/test-utilities/courts.mock'; describe('Courts Function tests', () => { let request; diff --git a/backend/functions/courts/courts.function.ts b/backend/function-apps/api/courts/courts.function.ts similarity index 80% rename from backend/functions/courts/courts.function.ts rename to backend/function-apps/api/courts/courts.function.ts index a97ad560c..21f4e28be 100644 --- a/backend/functions/courts/courts.function.ts +++ b/backend/function-apps/api/courts/courts.function.ts @@ -1,7 +1,7 @@ import { app, HttpRequest, HttpResponseInit, InvocationContext } from '@azure/functions'; -import ContextCreator from '../azure/application-context-creator'; -import { toAzureError, toAzureSuccess } from '../azure/functions'; -import { CourtsController } from '../lib/controllers/courts/courts.controller'; +import ContextCreator from '../../azure/application-context-creator'; +import { toAzureError, toAzureSuccess } from '../../azure/functions'; +import { CourtsController } from '../../../lib/controllers/courts/courts.controller'; const MODULE_NAME = 'COURTS_FUNCTION'; diff --git a/backend/functions/healthcheck/healthcheck.db.cosmos.test.ts b/backend/function-apps/api/healthcheck/healthcheck.db.cosmos.test.ts similarity index 85% rename from backend/functions/healthcheck/healthcheck.db.cosmos.test.ts rename to backend/function-apps/api/healthcheck/healthcheck.db.cosmos.test.ts index 1dc90b893..4ce2530ea 100644 --- a/backend/functions/healthcheck/healthcheck.db.cosmos.test.ts +++ b/backend/function-apps/api/healthcheck/healthcheck.db.cosmos.test.ts @@ -1,11 +1,11 @@ import { describe } from 'node:test'; -import { ApplicationContext } from '../lib/adapters/types/basic'; -import { createMockApplicationContext } from '../lib/testing/testing-utilities'; -import { closeDeferred } from '../lib/deferrable/defer-close'; +import { ApplicationContext } from '../../../lib/adapters/types/basic'; +import { createMockApplicationContext } from '../../../lib/testing/testing-utilities'; +import { closeDeferred } from '../../../lib/deferrable/defer-close'; import HealthcheckCosmosDb, { HealthCheckDocument } from './healthcheck.db.cosmos'; -import { MongoCollectionAdapter } from '../lib/adapters/gateways/mongo/utils/mongo-adapter'; +import { MongoCollectionAdapter } from '../../../lib/adapters/gateways/mongo/utils/mongo-adapter'; describe('healthcheck db tests', () => { let context: ApplicationContext; diff --git a/backend/functions/healthcheck/healthcheck.db.cosmos.ts b/backend/function-apps/api/healthcheck/healthcheck.db.cosmos.ts similarity index 87% rename from backend/functions/healthcheck/healthcheck.db.cosmos.ts rename to backend/function-apps/api/healthcheck/healthcheck.db.cosmos.ts index 3a6344ccd..e055864eb 100644 --- a/backend/functions/healthcheck/healthcheck.db.cosmos.ts +++ b/backend/function-apps/api/healthcheck/healthcheck.db.cosmos.ts @@ -1,9 +1,9 @@ import * as dotenv from 'dotenv'; -import { ApplicationContext } from '../lib/adapters/types/basic'; -import { DocumentClient } from '../lib/humble-objects/mongo-humble'; -import QueryBuilder from '../lib/query/query-builder'; -import { deferClose } from '../lib/deferrable/defer-close'; -import { MongoCollectionAdapter } from '../lib/adapters/gateways/mongo/utils/mongo-adapter'; +import { ApplicationContext } from '../../../lib/adapters/types/basic'; +import { DocumentClient } from '../../../lib/humble-objects/mongo-humble'; +import QueryBuilder from '../../../lib/query/query-builder'; +import { deferClose } from '../../../lib/deferrable/defer-close'; +import { MongoCollectionAdapter } from '../../../lib/adapters/gateways/mongo/utils/mongo-adapter'; dotenv.config(); diff --git a/backend/functions/healthcheck/healthcheck.db.sql.ts b/backend/function-apps/api/healthcheck/healthcheck.db.sql.ts similarity index 85% rename from backend/functions/healthcheck/healthcheck.db.sql.ts rename to backend/function-apps/api/healthcheck/healthcheck.db.sql.ts index 4cf6f4170..08e4501e8 100644 --- a/backend/functions/healthcheck/healthcheck.db.sql.ts +++ b/backend/function-apps/api/healthcheck/healthcheck.db.sql.ts @@ -1,5 +1,5 @@ -import { ApplicationContext } from '../lib/adapters/types/basic'; -import { getSqlConnection } from '../lib/factory'; +import { ApplicationContext } from '../../../lib/adapters/types/basic'; +import { getSqlConnection } from '../../../lib/factory'; const MODULE_NAME = 'HEALTHCHECK-SQL-DB'; diff --git a/backend/functions/healthcheck/healthcheck.function.ts b/backend/function-apps/api/healthcheck/healthcheck.function.ts similarity index 86% rename from backend/functions/healthcheck/healthcheck.function.ts rename to backend/function-apps/api/healthcheck/healthcheck.function.ts index d89d84389..6cc93ae76 100644 --- a/backend/functions/healthcheck/healthcheck.function.ts +++ b/backend/function-apps/api/healthcheck/healthcheck.function.ts @@ -1,14 +1,14 @@ -import ContextCreator from '../azure/application-context-creator'; -import { CamsError } from '../lib/common-errors/cams-error'; +import ContextCreator from '../../azure/application-context-creator'; +import { CamsError } from '../../../lib/common-errors/cams-error'; import HealthcheckCosmosDb from './healthcheck.db.cosmos'; import { app, InvocationContext, HttpResponseInit, HttpRequest } from '@azure/functions'; import HealthcheckSqlDb from './healthcheck.db.sql'; import HealthcheckInfo from './healthcheck.info'; -import { toAzureError, toAzureSuccess } from '../azure/functions'; -import { httpSuccess } from '../lib/adapters/utils/http-response'; -import HttpStatusCodes from '../../../common/src/api/http-status-codes'; -import { closeDeferred } from '../lib/deferrable/defer-close'; +import { toAzureError, toAzureSuccess } from '../../azure/functions'; +import { httpSuccess } from '../../../lib/adapters/utils/http-response'; +import HttpStatusCodes from '../../../../common/src/api/http-status-codes'; +import { closeDeferred } from '../../../lib/deferrable/defer-close'; const MODULE_NAME = 'HEALTHCHECK'; diff --git a/backend/functions/healthcheck/healthcheck.info.ts b/backend/function-apps/api/healthcheck/healthcheck.info.ts similarity index 90% rename from backend/functions/healthcheck/healthcheck.info.ts rename to backend/function-apps/api/healthcheck/healthcheck.info.ts index 856ca6842..ea67fd1fd 100644 --- a/backend/functions/healthcheck/healthcheck.info.ts +++ b/backend/function-apps/api/healthcheck/healthcheck.info.ts @@ -1,5 +1,5 @@ import * as dotenv from 'dotenv'; -import { ApplicationContext } from '../lib/adapters/types/basic'; +import { ApplicationContext } from '../../../lib/adapters/types/basic'; dotenv.config(); diff --git a/backend/functions/healthcheck/healthcheck.test.ts b/backend/function-apps/api/healthcheck/healthcheck.test.ts similarity index 91% rename from backend/functions/healthcheck/healthcheck.test.ts rename to backend/function-apps/api/healthcheck/healthcheck.test.ts index c6a8ecac3..e2271270b 100644 --- a/backend/functions/healthcheck/healthcheck.test.ts +++ b/backend/function-apps/api/healthcheck/healthcheck.test.ts @@ -1,5 +1,5 @@ -import { createMockAzureFunctionRequest } from '../azure/testing-helpers'; -import { MongoCollectionAdapter } from '../lib/adapters/gateways/mongo/utils/mongo-adapter'; +import { createMockAzureFunctionRequest } from '../../azure/testing-helpers'; +import { MongoCollectionAdapter } from '../../../lib/adapters/gateways/mongo/utils/mongo-adapter'; import { HealthCheckDocument } from './healthcheck.db.cosmos'; import handler, { checkResults } from './healthcheck.function'; diff --git a/backend/function-apps/api/host.json b/backend/function-apps/api/host.json new file mode 100644 index 000000000..9093e3097 --- /dev/null +++ b/backend/function-apps/api/host.json @@ -0,0 +1,25 @@ +{ + "version": "2.0", + "logging": { + "applicationInsights": { + "enableDependencyTracking": true, + "dependencyTrackingOptions": { + "enableSqlCommandTextInstrumentation": true + }, + "samplingSettings": { + "isEnabled": true + } + }, + "fileLoggingMode": "always", + "logLevel": { + "default": "Debug", + "Host.Results": "Information", + "Function": "Information", + "Worker": "Information" + } + }, + "extensionBundle": { + "id": "Microsoft.Azure.Functions.ExtensionBundle", + "version": "[4.*, 5.0.0)" + } +} diff --git a/backend/functions/me/me.function.test.ts b/backend/function-apps/api/me/me.function.test.ts similarity index 72% rename from backend/functions/me/me.function.test.ts rename to backend/function-apps/api/me/me.function.test.ts index 0ffe1a0a7..7dea1960c 100644 --- a/backend/functions/me/me.function.test.ts +++ b/backend/function-apps/api/me/me.function.test.ts @@ -2,14 +2,14 @@ import { buildTestResponseError, buildTestResponseSuccess, createMockAzureFunctionRequest, -} from '../azure/testing-helpers'; -import ContextCreator from '../azure/application-context-creator'; -import MockData from '../../../common/src/cams/test-utilities/mock-data'; -import { ForbiddenError } from '../lib/common-errors/forbidden-error'; -import handler from '../me/me.function'; +} from '../../azure/testing-helpers'; +import ContextCreator from '../../azure/application-context-creator'; +import MockData from '../../../../common/src/cams/test-utilities/mock-data'; +import { ForbiddenError } from '../../../lib/common-errors/forbidden-error'; +import handler from './me.function'; import { InvocationContext } from '@azure/functions'; -import { CamsSession } from '../../../common/src/cams/session'; -import { createMockApplicationContext } from '../lib/testing/testing-utilities'; +import { CamsSession } from '../../../../common/src/cams/session'; +import { createMockApplicationContext } from '../../../lib/testing/testing-utilities'; describe('me Function test', () => { const context = new InvocationContext({ diff --git a/backend/functions/me/me.function.ts b/backend/function-apps/api/me/me.function.ts similarity index 79% rename from backend/functions/me/me.function.ts rename to backend/function-apps/api/me/me.function.ts index ed5b536e5..9a43da326 100644 --- a/backend/functions/me/me.function.ts +++ b/backend/function-apps/api/me/me.function.ts @@ -1,7 +1,7 @@ import { app, HttpRequest, HttpResponseInit, InvocationContext } from '@azure/functions'; -import ContextCreator from '../azure/application-context-creator'; -import { toAzureError, toAzureSuccess } from '../azure/functions'; -import { MeController } from '../lib/controllers/me/me.controller'; +import ContextCreator from '../../azure/application-context-creator'; +import { toAzureError, toAzureSuccess } from '../../azure/functions'; +import { MeController } from '../../../lib/controllers/me/me.controller'; const MODULE_NAME = 'ME-FUNCTION'; diff --git a/backend/functions/oauth2/mock-oauth2.function.ts b/backend/function-apps/api/oauth2/mock-oauth2.function.ts similarity index 73% rename from backend/functions/oauth2/mock-oauth2.function.ts rename to backend/function-apps/api/oauth2/mock-oauth2.function.ts index 31eed04be..c4ea70a5d 100644 --- a/backend/functions/oauth2/mock-oauth2.function.ts +++ b/backend/function-apps/api/oauth2/mock-oauth2.function.ts @@ -1,8 +1,8 @@ import { app, HttpRequest, HttpResponseInit, InvocationContext } from '@azure/functions'; -import ContextCreator from '../azure/application-context-creator'; -import { mockAuthentication } from '../lib/testing/mock-gateways/mock-oauth2-gateway'; -import { toAzureError, toAzureSuccess } from '../azure/functions'; -import { httpSuccess } from '../lib/adapters/utils/http-response'; +import ContextCreator from '../../azure/application-context-creator'; +import { mockAuthentication } from '../../../lib/testing/mock-gateways/mock-oauth2-gateway'; +import { toAzureError, toAzureSuccess } from '../../azure/functions'; +import { httpSuccess } from '../../../lib/adapters/utils/http-response'; const MODULE_NAME = 'MOCK-OAUTH2-FUNCTION'; diff --git a/backend/functions/office-staff-sync/office-staff-sync.function.test.ts b/backend/function-apps/api/office-staff-sync/office-staff-sync.function.test.ts similarity index 79% rename from backend/functions/office-staff-sync/office-staff-sync.function.test.ts rename to backend/function-apps/api/office-staff-sync/office-staff-sync.function.test.ts index 18814cdf0..22d239d8e 100644 --- a/backend/functions/office-staff-sync/office-staff-sync.function.test.ts +++ b/backend/function-apps/api/office-staff-sync/office-staff-sync.function.test.ts @@ -1,9 +1,9 @@ -import { LoggerImpl } from '../lib/adapters/services/logger.service'; -import { CamsError } from '../lib/common-errors/cams-error'; +import { LoggerImpl } from '../../../lib/adapters/services/logger.service'; +import { CamsError } from '../../../lib/common-errors/cams-error'; import timerTrigger from './office-staff-sync.function'; import { Timer } from '@azure/functions'; -import { createMockAzureFunctionContext } from '../azure/testing-helpers'; -import { OfficesController } from '../lib/controllers/offices/offices.controller'; +import { createMockAzureFunctionContext } from '../../azure/testing-helpers'; +import { OfficesController } from '../../../lib/controllers/offices/offices.controller'; describe('Office Staff Sync Function tests', () => { const context = createMockAzureFunctionContext(); diff --git a/backend/functions/office-staff-sync/office-staff-sync.function.ts b/backend/function-apps/api/office-staff-sync/office-staff-sync.function.ts similarity index 72% rename from backend/functions/office-staff-sync/office-staff-sync.function.ts rename to backend/function-apps/api/office-staff-sync/office-staff-sync.function.ts index f6e6a17b6..3138d1ab4 100644 --- a/backend/functions/office-staff-sync/office-staff-sync.function.ts +++ b/backend/function-apps/api/office-staff-sync/office-staff-sync.function.ts @@ -1,9 +1,9 @@ import * as dotenv from 'dotenv'; import { app, InvocationContext, Timer } from '@azure/functions'; -import ContextCreator from '../azure/application-context-creator'; -import { initializeApplicationInsights } from '../azure/app-insights'; -import { toAzureError } from '../azure/functions'; -import { OfficesController } from '../lib/controllers/offices/offices.controller'; +import ContextCreator from '../../azure/application-context-creator'; +import { initializeApplicationInsights } from '../../azure/app-insights'; +import { toAzureError } from '../../azure/functions'; +import { OfficesController } from '../../../lib/controllers/offices/offices.controller'; dotenv.config(); diff --git a/backend/functions/offices/offices.function.test.ts b/backend/function-apps/api/offices/offices.function.test.ts similarity index 81% rename from backend/functions/offices/offices.function.test.ts rename to backend/function-apps/api/offices/offices.function.test.ts index 809719c77..73c05950d 100644 --- a/backend/functions/offices/offices.function.test.ts +++ b/backend/function-apps/api/offices/offices.function.test.ts @@ -1,15 +1,15 @@ -import { CamsError } from '../lib/common-errors/cams-error'; -import ContextCreator from '../azure/application-context-creator'; -import MockData from '../../../common/src/cams/test-utilities/mock-data'; +import { CamsError } from '../../../lib/common-errors/cams-error'; +import ContextCreator from '../../azure/application-context-creator'; +import MockData from '../../../../common/src/cams/test-utilities/mock-data'; import handler from './offices.function'; import { buildTestResponseError, buildTestResponseSuccess, createMockAzureFunctionContext, createMockAzureFunctionRequest, -} from '../azure/testing-helpers'; -import { OfficesController } from '../lib/controllers/offices/offices.controller'; -import { USTP_OFFICES_ARRAY, UstpOfficeDetails } from '../../../common/src/cams/offices'; +} from '../../azure/testing-helpers'; +import { OfficesController } from '../../../lib/controllers/offices/offices.controller'; +import { USTP_OFFICES_ARRAY, UstpOfficeDetails } from '../../../../common/src/cams/offices'; describe('offices Function tests', () => { let request; diff --git a/backend/functions/offices/offices.function.ts b/backend/function-apps/api/offices/offices.function.ts similarity index 81% rename from backend/functions/offices/offices.function.ts rename to backend/function-apps/api/offices/offices.function.ts index 1d5560e16..f2737a8fa 100644 --- a/backend/functions/offices/offices.function.ts +++ b/backend/function-apps/api/offices/offices.function.ts @@ -1,7 +1,7 @@ import { app, HttpRequest, HttpResponseInit, InvocationContext } from '@azure/functions'; -import ContextCreator from '../azure/application-context-creator'; -import { OfficesController } from '../lib/controllers/offices/offices.controller'; -import { toAzureError, toAzureSuccess } from '../azure/functions'; +import ContextCreator from '../../azure/application-context-creator'; +import { OfficesController } from '../../../lib/controllers/offices/offices.controller'; +import { toAzureError, toAzureSuccess } from '../../azure/functions'; const MODULE_NAME = 'OFFICES_FUNCTION'; diff --git a/backend/functions/orders-manual-sync/orders-manual-sync.function.test.ts b/backend/function-apps/api/orders-manual-sync/orders-manual-sync.function.test.ts similarity index 81% rename from backend/functions/orders-manual-sync/orders-manual-sync.function.test.ts rename to backend/function-apps/api/orders-manual-sync/orders-manual-sync.function.test.ts index 604496ee7..7383b870d 100644 --- a/backend/functions/orders-manual-sync/orders-manual-sync.function.test.ts +++ b/backend/function-apps/api/orders-manual-sync/orders-manual-sync.function.test.ts @@ -1,9 +1,12 @@ -import { LoggerImpl } from '../lib/adapters/services/logger.service'; -import { CamsError } from '../lib/common-errors/cams-error'; -import { OrdersController } from '../lib/controllers/orders/orders.controller'; -import { SyncOrdersStatus } from '../lib/use-cases/orders/orders'; +import { LoggerImpl } from '../../../lib/adapters/services/logger.service'; +import { CamsError } from '../../../lib/common-errors/cams-error'; +import { OrdersController } from '../../../lib/controllers/orders/orders.controller'; +import { SyncOrdersStatus } from '../../../lib/use-cases/orders/orders'; import handler from './orders-manual-sync.function'; -import { buildTestResponseSuccess, createMockAzureFunctionRequest } from '../azure/testing-helpers'; +import { + buildTestResponseSuccess, + createMockAzureFunctionRequest, +} from '../../azure/testing-helpers'; const syncResponse: SyncOrdersStatus = { options: { diff --git a/backend/functions/orders-manual-sync/orders-manual-sync.function.ts b/backend/function-apps/api/orders-manual-sync/orders-manual-sync.function.ts similarity index 82% rename from backend/functions/orders-manual-sync/orders-manual-sync.function.ts rename to backend/function-apps/api/orders-manual-sync/orders-manual-sync.function.ts index d4c88f8e8..f06830c48 100644 --- a/backend/functions/orders-manual-sync/orders-manual-sync.function.ts +++ b/backend/function-apps/api/orders-manual-sync/orders-manual-sync.function.ts @@ -1,9 +1,9 @@ import * as dotenv from 'dotenv'; import { app, InvocationContext, HttpRequest, HttpResponseInit } from '@azure/functions'; -import ContextCreator from '../azure/application-context-creator'; -import { initializeApplicationInsights } from '../azure/app-insights'; -import { OrdersController } from '../lib/controllers/orders/orders.controller'; -import { toAzureError, toAzureSuccess } from '../azure/functions'; +import ContextCreator from '../../azure/application-context-creator'; +import { initializeApplicationInsights } from '../../azure/app-insights'; +import { OrdersController } from '../../../lib/controllers/orders/orders.controller'; +import { toAzureError, toAzureSuccess } from '../../azure/functions'; dotenv.config(); diff --git a/backend/functions/orders-suggestions/orders-suggestions.function.test.ts b/backend/function-apps/api/orders-suggestions/orders-suggestions.function.test.ts similarity index 79% rename from backend/functions/orders-suggestions/orders-suggestions.function.test.ts rename to backend/function-apps/api/orders-suggestions/orders-suggestions.function.test.ts index 392735266..cc5322c58 100644 --- a/backend/functions/orders-suggestions/orders-suggestions.function.test.ts +++ b/backend/function-apps/api/orders-suggestions/orders-suggestions.function.test.ts @@ -1,14 +1,14 @@ import handler from './orders-suggestions.function'; -import { CamsError } from '../lib/common-errors/cams-error'; +import { CamsError } from '../../../lib/common-errors/cams-error'; import { buildTestResponseSuccess, createMockAzureFunctionContext, createMockAzureFunctionRequest, -} from '../azure/testing-helpers'; -import { OrdersController } from '../lib/controllers/orders/orders.controller'; -import MockData from '../../../common/src/cams/test-utilities/mock-data'; -import { CaseSummary } from '../../../common/src/cams/cases'; -import { buildTestResponseError } from '../azure/testing-helpers'; +} from '../../azure/testing-helpers'; +import { OrdersController } from '../../../lib/controllers/orders/orders.controller'; +import MockData from '../../../../common/src/cams/test-utilities/mock-data'; +import { CaseSummary } from '../../../../common/src/cams/cases'; +import { buildTestResponseError } from '../../azure/testing-helpers'; describe('Orders suggestions function tests', () => { const context = createMockAzureFunctionContext(); diff --git a/backend/functions/orders-suggestions/orders-suggestions.function.ts b/backend/function-apps/api/orders-suggestions/orders-suggestions.function.ts similarity index 76% rename from backend/functions/orders-suggestions/orders-suggestions.function.ts rename to backend/function-apps/api/orders-suggestions/orders-suggestions.function.ts index ba55d0d99..d0e87f994 100644 --- a/backend/functions/orders-suggestions/orders-suggestions.function.ts +++ b/backend/function-apps/api/orders-suggestions/orders-suggestions.function.ts @@ -1,10 +1,10 @@ import { InvocationContext, HttpRequest, HttpResponseInit, app } from '@azure/functions'; -import ContextCreator from '../azure/application-context-creator'; -import { initializeApplicationInsights } from '../azure/app-insights'; -import { OrdersController } from '../lib/controllers/orders/orders.controller'; +import ContextCreator from '../../azure/application-context-creator'; +import { initializeApplicationInsights } from '../../azure/app-insights'; +import { OrdersController } from '../../../lib/controllers/orders/orders.controller'; import * as dotenv from 'dotenv'; -import { toAzureError, toAzureSuccess } from '../azure/functions'; +import { toAzureError, toAzureSuccess } from '../../azure/functions'; dotenv.config(); initializeApplicationInsights(); diff --git a/backend/functions/orders-sync/orders-sync.function.test.ts b/backend/function-apps/api/orders-sync/orders-sync.function.test.ts similarity index 81% rename from backend/functions/orders-sync/orders-sync.function.test.ts rename to backend/function-apps/api/orders-sync/orders-sync.function.test.ts index cd261fb88..46d074acf 100644 --- a/backend/functions/orders-sync/orders-sync.function.test.ts +++ b/backend/function-apps/api/orders-sync/orders-sync.function.test.ts @@ -1,10 +1,10 @@ -import { LoggerImpl } from '../lib/adapters/services/logger.service'; -import { CamsError } from '../lib/common-errors/cams-error'; +import { LoggerImpl } from '../../../lib/adapters/services/logger.service'; +import { CamsError } from '../../../lib/common-errors/cams-error'; import timerTrigger from './orders-sync.function'; import { Timer } from '@azure/functions'; -import { createMockAzureFunctionContext } from '../azure/testing-helpers'; -import { OrdersController } from '../lib/controllers/orders/orders.controller'; -import * as factory from '../lib/factory'; +import { createMockAzureFunctionContext } from '../../azure/testing-helpers'; +import { OrdersController } from '../../../lib/controllers/orders/orders.controller'; +import * as factory from '../../../lib/factory'; describe('Orders Sync Function tests', () => { const context = createMockAzureFunctionContext({ MONGO_CONNECTION_STRING: 'fake' }); diff --git a/backend/functions/orders-sync/orders-sync.function.ts b/backend/function-apps/api/orders-sync/orders-sync.function.ts similarity index 72% rename from backend/functions/orders-sync/orders-sync.function.ts rename to backend/function-apps/api/orders-sync/orders-sync.function.ts index c25213f31..eb269bda3 100644 --- a/backend/functions/orders-sync/orders-sync.function.ts +++ b/backend/function-apps/api/orders-sync/orders-sync.function.ts @@ -1,9 +1,9 @@ import * as dotenv from 'dotenv'; import { app, InvocationContext, Timer } from '@azure/functions'; -import ContextCreator from '../azure/application-context-creator'; -import { initializeApplicationInsights } from '../azure/app-insights'; -import { OrdersController } from '../lib/controllers/orders/orders.controller'; -import { toAzureError } from '../azure/functions'; +import ContextCreator from '../../azure/application-context-creator'; +import { initializeApplicationInsights } from '../../azure/app-insights'; +import { OrdersController } from '../../../lib/controllers/orders/orders.controller'; +import { toAzureError } from '../../azure/functions'; dotenv.config(); diff --git a/backend/functions/orders/orders.function.test.ts b/backend/function-apps/api/orders/orders.function.test.ts similarity index 84% rename from backend/functions/orders/orders.function.test.ts rename to backend/function-apps/api/orders/orders.function.test.ts index cf925ba4c..4d62f8e7b 100644 --- a/backend/functions/orders/orders.function.test.ts +++ b/backend/function-apps/api/orders/orders.function.test.ts @@ -1,17 +1,17 @@ import handler from './orders.function'; -import { CamsError } from '../lib/common-errors/cams-error'; -import { MockData } from '../../../common/src/cams/test-utilities/mock-data'; -import { CamsHttpRequest } from '../lib/adapters/types/http'; -import { OrdersController } from '../lib/controllers/orders/orders.controller'; -import { Order } from '../../../common/src/cams/orders'; +import { CamsError } from '../../../lib/common-errors/cams-error'; +import { MockData } from '../../../../common/src/cams/test-utilities/mock-data'; +import { CamsHttpRequest } from '../../../lib/adapters/types/http'; +import { OrdersController } from '../../../lib/controllers/orders/orders.controller'; +import { Order } from '../../../../common/src/cams/orders'; import { buildTestResponseError, buildTestResponseSuccess, createMockAzureFunctionContext, createMockAzureFunctionRequest, -} from '../azure/testing-helpers'; -import { commonHeaders } from '../lib/adapters/utils/http-response'; -import HttpStatusCodes from '../../../common/src/api/http-status-codes'; +} from '../../azure/testing-helpers'; +import { commonHeaders } from '../../../lib/adapters/utils/http-response'; +import HttpStatusCodes from '../../../../common/src/api/http-status-codes'; describe('Orders Function tests', () => { const request = createMockAzureFunctionRequest({ diff --git a/backend/functions/orders/orders.function.ts b/backend/function-apps/api/orders/orders.function.ts similarity index 75% rename from backend/functions/orders/orders.function.ts rename to backend/function-apps/api/orders/orders.function.ts index 18d1fb842..127a39b5d 100644 --- a/backend/functions/orders/orders.function.ts +++ b/backend/function-apps/api/orders/orders.function.ts @@ -1,9 +1,9 @@ import * as dotenv from 'dotenv'; import { app, HttpRequest, HttpResponseInit, InvocationContext } from '@azure/functions'; -import ContextCreator from '../azure/application-context-creator'; -import { initializeApplicationInsights } from '../azure/app-insights'; -import { OrdersController } from '../lib/controllers/orders/orders.controller'; -import { toAzureError, toAzureSuccess } from '../azure/functions'; +import ContextCreator from '../../azure/application-context-creator'; +import { initializeApplicationInsights } from '../../azure/app-insights'; +import { OrdersController } from '../../../lib/controllers/orders/orders.controller'; +import { toAzureError, toAzureSuccess } from '../../azure/functions'; const MODULE_NAME = 'ORDERS_FUNCTION'; diff --git a/backend/function-apps/api/package.json b/backend/function-apps/api/package.json new file mode 100644 index 000000000..c45a335bb --- /dev/null +++ b/backend/function-apps/api/package.json @@ -0,0 +1,13 @@ +{ + "name": "cams-api", + "version": "1.0.0", + "description": "", + "main": "dist/backend/function-apps/api/*/*.function.js", + "scripts": { + "clean": "rm -rf ./dist ./node_modules *.zip", + "prestart": "npm run build && cp ../../.env .", + "start": "func start --javascript", + "build": "tsc --build tsconfig.build.json", + "pack": "../../pack.sh api" + } +} diff --git a/backend/function-apps/api/tsconfig.build.json b/backend/function-apps/api/tsconfig.build.json new file mode 100644 index 000000000..efef3c642 --- /dev/null +++ b/backend/function-apps/api/tsconfig.build.json @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "outDir": "dist" + }, + "extends": "../../tsconfig.json", + "exclude": ["**/*.test.ts", "**/testing*", "**/fake*", "**/testing/*"] +} diff --git a/backend/functions/azure/app-insights.ts b/backend/function-apps/azure/app-insights.ts similarity index 100% rename from backend/functions/azure/app-insights.ts rename to backend/function-apps/azure/app-insights.ts diff --git a/backend/functions/azure/application-context-creator.test.ts b/backend/function-apps/azure/application-context-creator.test.ts similarity index 87% rename from backend/functions/azure/application-context-creator.test.ts rename to backend/function-apps/azure/application-context-creator.test.ts index 15e76a094..483cea9b1 100644 --- a/backend/functions/azure/application-context-creator.test.ts +++ b/backend/function-apps/azure/application-context-creator.test.ts @@ -1,13 +1,13 @@ import MockData from '../../../common/src/cams/test-utilities/mock-data'; -import { ApplicationContext } from '../lib/adapters/types/basic'; -import * as FeatureFlags from '../lib/adapters/utils/feature-flag'; -import { ApplicationConfiguration } from '../lib/configs/application-configuration'; -import { MockUserSessionUseCase } from '../lib/testing/mock-gateways/mock-user-session-use-case'; -import { createMockApplicationContext } from '../lib/testing/testing-utilities'; +import { ApplicationContext } from '../../lib/adapters/types/basic'; +import * as FeatureFlags from '../../lib/adapters/utils/feature-flag'; +import { ApplicationConfiguration } from '../../lib/configs/application-configuration'; +import { MockUserSessionUseCase } from '../../lib/testing/mock-gateways/mock-user-session-use-case'; +import { createMockApplicationContext } from '../../lib/testing/testing-utilities'; import ContextCreator from './application-context-creator'; import { createMockAzureFunctionContext, createMockAzureFunctionRequest } from './testing-helpers'; import { azureToCamsHttpRequest } from './functions'; -import { LoggerImpl } from '../lib/adapters/services/logger.service'; +import { LoggerImpl } from '../../lib/adapters/services/logger.service'; describe('Application Context Creator', () => { describe('applicationContextCreator', () => { diff --git a/backend/functions/azure/application-context-creator.ts b/backend/function-apps/azure/application-context-creator.ts similarity index 85% rename from backend/functions/azure/application-context-creator.ts rename to backend/function-apps/azure/application-context-creator.ts index adbfdeeb3..861b4374c 100644 --- a/backend/functions/azure/application-context-creator.ts +++ b/backend/function-apps/azure/application-context-creator.ts @@ -1,12 +1,12 @@ import * as jwt from 'jsonwebtoken'; import { InvocationContext, HttpRequest } from '@azure/functions'; -import { ApplicationContext } from '../lib/adapters/types/basic'; -import { ApplicationConfiguration } from '../lib/configs/application-configuration'; -import { getFeatureFlags } from '../lib/adapters/utils/feature-flag'; -import { LoggerImpl } from '../lib/adapters/services/logger.service'; +import { ApplicationContext } from '../../lib/adapters/types/basic'; +import { ApplicationConfiguration } from '../../lib/configs/application-configuration'; +import { getFeatureFlags } from '../../lib/adapters/utils/feature-flag'; +import { LoggerImpl } from '../../lib/adapters/services/logger.service'; import { azureToCamsHttpRequest } from './functions'; -import { UnauthorizedError } from '../lib/common-errors/unauthorized-error'; -import { getUserSessionUseCase } from '../lib/factory'; +import { UnauthorizedError } from '../../lib/common-errors/unauthorized-error'; +import { getUserSessionUseCase } from '../../lib/factory'; const MODULE_NAME = 'APPLICATION-CONTEXT-CREATOR'; diff --git a/backend/functions/azure/functions.test.ts b/backend/function-apps/azure/functions.test.ts similarity index 87% rename from backend/functions/azure/functions.test.ts rename to backend/function-apps/azure/functions.test.ts index ddfa3cc44..ee9a2c9f7 100644 --- a/backend/functions/azure/functions.test.ts +++ b/backend/function-apps/azure/functions.test.ts @@ -1,9 +1,9 @@ import { azureToCamsHttpRequest, toAzureSuccess } from './functions'; import { HttpRequest, HttpResponseInit } from '@azure/functions'; -import { CamsHttpRequest } from '../lib/adapters/types/http'; -import { CamsHttpResponseInit } from '../lib/adapters/utils/http-response'; +import { CamsHttpRequest } from '../../lib/adapters/types/http'; +import { CamsHttpResponseInit } from '../../lib/adapters/utils/http-response'; -describe('functions test', () => { +describe('function-apps test', () => { test('should return properly formatted CamsHttpRequest from malformed headers and query', async () => { const request = { method: 'GET', diff --git a/backend/functions/azure/functions.ts b/backend/function-apps/azure/functions.ts similarity index 77% rename from backend/functions/azure/functions.ts rename to backend/function-apps/azure/functions.ts index e655342b1..58d7e73df 100644 --- a/backend/functions/azure/functions.ts +++ b/backend/function-apps/azure/functions.ts @@ -1,9 +1,9 @@ import { HttpRequest, HttpResponseInit } from '@azure/functions'; -import { CamsDict, CamsHttpMethod, CamsHttpRequest } from '../lib/adapters/types/http'; -import { CamsHttpResponseInit, commonHeaders } from '../lib/adapters/utils/http-response'; -import { ApplicationContext } from '../lib/adapters/types/basic'; -import { getCamsError } from '../lib/common-errors/error-utilities'; -import { LoggerImpl } from '../lib/adapters/services/logger.service'; +import { CamsDict, CamsHttpMethod, CamsHttpRequest } from '../../lib/adapters/types/http'; +import { CamsHttpResponseInit, commonHeaders } from '../../lib/adapters/utils/http-response'; +import { ApplicationContext } from '../../lib/adapters/types/basic'; +import { getCamsError } from '../../lib/common-errors/error-utilities'; +import { LoggerImpl } from '../../lib/adapters/services/logger.service'; function azureToCamsDict(it: Iterable<[string, string]>): CamsDict { if (!it) return {}; diff --git a/backend/functions/azure/testing-helpers.ts b/backend/function-apps/azure/testing-helpers.ts similarity index 89% rename from backend/functions/azure/testing-helpers.ts rename to backend/function-apps/azure/testing-helpers.ts index 290e4aa80..1b51e1cec 100644 --- a/backend/functions/azure/testing-helpers.ts +++ b/backend/function-apps/azure/testing-helpers.ts @@ -1,10 +1,10 @@ import { HttpRequest, InvocationContext } from '@azure/functions'; import { randomUUID } from 'node:crypto'; -import { CamsHttpRequest } from '../lib/adapters/types/http'; +import { CamsHttpRequest } from '../../lib/adapters/types/http'; import MockData from '../../../common/src/cams/test-utilities/mock-data'; -import { httpSuccess } from '../lib/adapters/utils/http-response'; +import { httpSuccess } from '../../lib/adapters/utils/http-response'; import { toAzureError, toAzureSuccess } from './functions'; -import { ApplicationContext } from '../lib/adapters/types/basic'; +import { ApplicationContext } from '../../lib/adapters/types/basic'; import { ResponseBody } from '../../../common/src/api/response'; export function createMockAzureFunctionContext( diff --git a/backend/function-apps/migration/.funcignore b/backend/function-apps/migration/.funcignore new file mode 100644 index 000000000..931ec1df9 --- /dev/null +++ b/backend/function-apps/migration/.funcignore @@ -0,0 +1,15 @@ +*.js.map +*.ts +.git* +.vscode +__azurite_db*__.json +__blobstorage__ +__queuestorage__ +local.settings.json +test +tsconfig.json +*.zip +README.md +.env +.eslint* +*.test.* diff --git a/backend/function-apps/migration/.gitignore b/backend/function-apps/migration/.gitignore new file mode 100644 index 000000000..ee0da9b3f --- /dev/null +++ b/backend/function-apps/migration/.gitignore @@ -0,0 +1,2 @@ +# Ignore package-lock.json as this project should not have its own dependencies +package-lock.json diff --git a/backend/functions/migration/activity/flattenBoundingArrays.test.ts b/backend/function-apps/migration/activity/flattenBoundingArrays.test.ts similarity index 88% rename from backend/functions/migration/activity/flattenBoundingArrays.test.ts rename to backend/function-apps/migration/activity/flattenBoundingArrays.test.ts index 999bbf991..1defc160e 100644 --- a/backend/functions/migration/activity/flattenBoundingArrays.test.ts +++ b/backend/function-apps/migration/activity/flattenBoundingArrays.test.ts @@ -1,5 +1,5 @@ import { InvocationContext } from '@azure/functions'; -import { AcmsBounds, AcmsPredicate } from '../../lib/use-cases/acms-orders/acms-orders'; +import { AcmsBounds, AcmsPredicate } from '../../../lib/use-cases/acms-orders/acms-orders'; import module from './flattenBoundingArrays'; describe('Flatten bounding arrays activity', () => { diff --git a/backend/functions/migration/activity/flattenBoundingArrays.ts b/backend/function-apps/migration/activity/flattenBoundingArrays.ts similarity index 83% rename from backend/functions/migration/activity/flattenBoundingArrays.ts rename to backend/function-apps/migration/activity/flattenBoundingArrays.ts index 0f7f79f06..510a55369 100644 --- a/backend/functions/migration/activity/flattenBoundingArrays.ts +++ b/backend/function-apps/migration/activity/flattenBoundingArrays.ts @@ -1,5 +1,5 @@ import { InvocationContext } from '@azure/functions'; -import { AcmsBounds, AcmsPredicate } from '../../lib/use-cases/acms-orders/acms-orders'; +import { AcmsBounds, AcmsPredicate } from '../../../lib/use-cases/acms-orders/acms-orders'; async function flattenBoundingArrays( bounds: AcmsBounds, diff --git a/backend/functions/migration/activity/getConsolidations.test.ts b/backend/function-apps/migration/activity/getConsolidations.test.ts similarity index 85% rename from backend/functions/migration/activity/getConsolidations.test.ts rename to backend/function-apps/migration/activity/getConsolidations.test.ts index f866c48f9..c71eef9ca 100644 --- a/backend/functions/migration/activity/getConsolidations.test.ts +++ b/backend/function-apps/migration/activity/getConsolidations.test.ts @@ -1,9 +1,9 @@ import { InvocationContext } from '@azure/functions'; -import AcmsOrdersController from '../../lib/controllers/acms-orders/acms-orders.controller'; +import AcmsOrdersController from '../../../lib/controllers/acms-orders/acms-orders.controller'; import module from './getConsolidations'; -import { AcmsPredicateAndPage } from '../../lib/use-cases/acms-orders/acms-orders'; +import { AcmsPredicateAndPage } from '../../../lib/use-cases/acms-orders/acms-orders'; import { createMockAzureFunctionContext } from '../../azure/testing-helpers'; -import { CamsError } from '../../lib/common-errors/cams-error'; +import { CamsError } from '../../../lib/common-errors/cams-error'; describe('getConsolidations test', () => { afterEach(() => { diff --git a/backend/functions/migration/activity/getConsolidations.ts b/backend/function-apps/migration/activity/getConsolidations.ts similarity index 73% rename from backend/functions/migration/activity/getConsolidations.ts rename to backend/function-apps/migration/activity/getConsolidations.ts index a1ae9428f..07cf062e3 100644 --- a/backend/functions/migration/activity/getConsolidations.ts +++ b/backend/function-apps/migration/activity/getConsolidations.ts @@ -1,8 +1,8 @@ import { InvocationContext } from '@azure/functions'; -import { AcmsPredicateAndPage } from '../../lib/use-cases/acms-orders/acms-orders'; +import { AcmsPredicateAndPage } from '../../../lib/use-cases/acms-orders/acms-orders'; import ContextCreator from '../../azure/application-context-creator'; -import AcmsOrdersController from '../../lib/controllers/acms-orders/acms-orders.controller'; -import { getCamsError } from '../../lib/common-errors/error-utilities'; +import AcmsOrdersController from '../../../lib/controllers/acms-orders/acms-orders.controller'; +import { getCamsError } from '../../../lib/common-errors/error-utilities'; const MODULE_NAME = 'IMPORT_ACTION_GET_CONSOLIDATIONS'; diff --git a/backend/functions/migration/activity/getPageCount.test.ts b/backend/function-apps/migration/activity/getPageCount.test.ts similarity index 84% rename from backend/functions/migration/activity/getPageCount.test.ts rename to backend/function-apps/migration/activity/getPageCount.test.ts index 5ba9d2511..26120948c 100644 --- a/backend/functions/migration/activity/getPageCount.test.ts +++ b/backend/function-apps/migration/activity/getPageCount.test.ts @@ -1,8 +1,8 @@ import { InvocationContext } from '@azure/functions'; import { createMockAzureFunctionContext } from '../../azure/testing-helpers'; -import { CamsError } from '../../lib/common-errors/cams-error'; -import AcmsOrdersController from '../../lib/controllers/acms-orders/acms-orders.controller'; -import { AcmsPredicateAndPage } from '../../lib/use-cases/acms-orders/acms-orders'; +import { CamsError } from '../../../lib/common-errors/cams-error'; +import AcmsOrdersController from '../../../lib/controllers/acms-orders/acms-orders.controller'; +import { AcmsPredicateAndPage } from '../../../lib/use-cases/acms-orders/acms-orders'; import module from './getPageCount'; describe('getPageCount test', () => { diff --git a/backend/functions/migration/activity/getPageCount.ts b/backend/function-apps/migration/activity/getPageCount.ts similarity index 72% rename from backend/functions/migration/activity/getPageCount.ts rename to backend/function-apps/migration/activity/getPageCount.ts index b71dc68cd..eb4454f12 100644 --- a/backend/functions/migration/activity/getPageCount.ts +++ b/backend/function-apps/migration/activity/getPageCount.ts @@ -1,8 +1,8 @@ import { InvocationContext } from '@azure/functions'; import ContextCreator from '../../azure/application-context-creator'; -import { AcmsPredicateAndPage } from '../../lib/use-cases/acms-orders/acms-orders'; -import AcmsOrdersController from '../../lib/controllers/acms-orders/acms-orders.controller'; -import { getCamsError } from '../../lib/common-errors/error-utilities'; +import { AcmsPredicateAndPage } from '../../../lib/use-cases/acms-orders/acms-orders'; +import AcmsOrdersController from '../../../lib/controllers/acms-orders/acms-orders.controller'; +import { getCamsError } from '../../../lib/common-errors/error-utilities'; const MODULE_NAME = 'IMPORT-ACTION-GET-PAGE-COUNT'; diff --git a/backend/functions/migration/activity/migrateConsolidation.ts b/backend/function-apps/migration/activity/migrateConsolidation.ts similarity index 74% rename from backend/functions/migration/activity/migrateConsolidation.ts rename to backend/function-apps/migration/activity/migrateConsolidation.ts index ff5077efb..b3b943314 100644 --- a/backend/functions/migration/activity/migrateConsolidation.ts +++ b/backend/function-apps/migration/activity/migrateConsolidation.ts @@ -1,8 +1,8 @@ import { InvocationContext } from '@azure/functions'; import ContextCreator from '../../azure/application-context-creator'; -import AcmsOrdersController from '../../lib/controllers/acms-orders/acms-orders.controller'; -import { getCamsError } from '../../lib/common-errors/error-utilities'; -import { AcmsTransformationResult } from '../../lib/use-cases/acms-orders/acms-orders'; +import AcmsOrdersController from '../../../lib/controllers/acms-orders/acms-orders.controller'; +import { getCamsError } from '../../../lib/common-errors/error-utilities'; +import { AcmsTransformationResult } from '../../../lib/use-cases/acms-orders/acms-orders'; const MODULE_NAME = 'IMPORT_ACTION_MIGRATE_CONSOLIDATION'; diff --git a/backend/functions/migration/activity/migrateConsolidations.test.ts b/backend/function-apps/migration/activity/migrateConsolidations.test.ts similarity index 83% rename from backend/functions/migration/activity/migrateConsolidations.test.ts rename to backend/function-apps/migration/activity/migrateConsolidations.test.ts index e2263fba8..bf135fe0b 100644 --- a/backend/functions/migration/activity/migrateConsolidations.test.ts +++ b/backend/function-apps/migration/activity/migrateConsolidations.test.ts @@ -1,9 +1,9 @@ import { InvocationContext } from '@azure/functions'; -import AcmsOrdersController from '../../lib/controllers/acms-orders/acms-orders.controller'; +import AcmsOrdersController from '../../../lib/controllers/acms-orders/acms-orders.controller'; import module from './migrateConsolidation'; import { createMockAzureFunctionContext } from '../../azure/testing-helpers'; -import { CamsError } from '../../lib/common-errors/cams-error'; -import { AcmsTransformationResult } from '../../lib/use-cases/acms-orders/acms-orders'; +import { CamsError } from '../../../lib/common-errors/cams-error'; +import { AcmsTransformationResult } from '../../../lib/use-cases/acms-orders/acms-orders'; describe('getConsolidations test', () => { afterEach(() => { diff --git a/backend/functions/migration/client/acms-migration-trigger.function.ts b/backend/function-apps/migration/client/acms-migration-trigger.function.ts similarity index 84% rename from backend/functions/migration/client/acms-migration-trigger.function.ts rename to backend/function-apps/migration/client/acms-migration-trigger.function.ts index 7a56ad0e7..478ac0ce4 100644 --- a/backend/functions/migration/client/acms-migration-trigger.function.ts +++ b/backend/function-apps/migration/client/acms-migration-trigger.function.ts @@ -1,10 +1,10 @@ import * as df from 'durable-functions'; import { HttpRequest, HttpResponse, InvocationContext } from '@azure/functions'; import { MAIN_ORCHESTRATOR } from '../loadConsolidations'; -import { TriggerRequest } from '../../lib/use-cases/acms-orders/acms-orders'; -import { BadRequestError } from '../../lib/common-errors/bad-request'; +import { TriggerRequest } from '../../../lib/use-cases/acms-orders/acms-orders'; +import { BadRequestError } from '../../../lib/common-errors/bad-request'; import * as dotenv from 'dotenv'; -import { UnauthorizedError } from '../../lib/common-errors/unauthorized-error'; +import { UnauthorizedError } from '../../../lib/common-errors/unauthorized-error'; const MODULE_NAME = 'ACMS_MIGRATION_TRIGGER'; dotenv.config(); diff --git a/backend/functions/host.json b/backend/function-apps/migration/host.json similarity index 100% rename from backend/functions/host.json rename to backend/function-apps/migration/host.json diff --git a/backend/functions/migration/loadConsolidations.ts b/backend/function-apps/migration/loadConsolidations.ts similarity index 100% rename from backend/functions/migration/loadConsolidations.ts rename to backend/function-apps/migration/loadConsolidations.ts diff --git a/backend/functions/migration/orchestration/orchestrator.ts b/backend/function-apps/migration/orchestration/orchestrator.ts similarity index 96% rename from backend/functions/migration/orchestration/orchestrator.ts rename to backend/function-apps/migration/orchestration/orchestrator.ts index 65d417a16..09ead0161 100644 --- a/backend/functions/migration/orchestration/orchestrator.ts +++ b/backend/function-apps/migration/orchestration/orchestrator.ts @@ -3,7 +3,7 @@ import { AcmsBounds, AcmsPartitionReport, AcmsPredicate, -} from '../../lib/use-cases/acms-orders/acms-orders'; +} from '../../../lib/use-cases/acms-orders/acms-orders'; import { FLATTEN_BOUNDING_ARRAYS, SUB_ORCHESTRATOR_PAGING } from '../loadConsolidations'; import { OrchestrationContext } from 'durable-functions'; diff --git a/backend/functions/migration/orchestration/sub-orchestrator-etl.ts b/backend/function-apps/migration/orchestration/sub-orchestrator-etl.ts similarity index 96% rename from backend/functions/migration/orchestration/sub-orchestrator-etl.ts rename to backend/function-apps/migration/orchestration/sub-orchestrator-etl.ts index 1d1b93669..5c36ce624 100644 --- a/backend/functions/migration/orchestration/sub-orchestrator-etl.ts +++ b/backend/function-apps/migration/orchestration/sub-orchestrator-etl.ts @@ -2,7 +2,7 @@ import { AcmsTransformationResult, AcmsPredicateAndPage, AcmsPageReport, -} from '../../lib/use-cases/acms-orders/acms-orders'; +} from '../../../lib/use-cases/acms-orders/acms-orders'; import { GET_CONSOLIDATIONS, MIGRATE_CONSOLIDATION } from '../loadConsolidations'; import { OrchestrationContext } from 'durable-functions'; diff --git a/backend/functions/migration/orchestration/sub-orchestrator-paging.ts b/backend/function-apps/migration/orchestration/sub-orchestrator-paging.ts similarity index 96% rename from backend/functions/migration/orchestration/sub-orchestrator-paging.ts rename to backend/function-apps/migration/orchestration/sub-orchestrator-paging.ts index 7c780b698..75759ab12 100644 --- a/backend/functions/migration/orchestration/sub-orchestrator-paging.ts +++ b/backend/function-apps/migration/orchestration/sub-orchestrator-paging.ts @@ -5,7 +5,7 @@ import { AcmsPredicate, AcmsPredicateAndPage, AcmsPartitionReport, -} from '../../lib/use-cases/acms-orders/acms-orders'; +} from '../../../lib/use-cases/acms-orders/acms-orders'; export function* subOrchestratorPaging(context: OrchestrationContext) { const predicate: AcmsPredicate = context.df.getInput(); diff --git a/backend/function-apps/migration/package.json b/backend/function-apps/migration/package.json new file mode 100644 index 000000000..6ed42908f --- /dev/null +++ b/backend/function-apps/migration/package.json @@ -0,0 +1,13 @@ +{ + "name": "cams-migration", + "version": "1.0.0", + "description": "", + "main": "dist/backend/function-apps/migration/loadConsolidations.js", + "scripts": { + "clean": "rm -rf ./dist ./node_modules *.zip", + "prestart": "npm run build && cp ../../.env .", + "start": "func start --javascript", + "build": "tsc --build tsconfig.build.json", + "pack": "../../pack.sh migration" + } +} diff --git a/backend/function-apps/migration/tsconfig.build.json b/backend/function-apps/migration/tsconfig.build.json new file mode 100644 index 000000000..efef3c642 --- /dev/null +++ b/backend/function-apps/migration/tsconfig.build.json @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "outDir": "dist" + }, + "extends": "../../tsconfig.json", + "exclude": ["**/*.test.ts", "**/testing*", "**/fake*", "**/testing/*"] +} diff --git a/backend/functions/lib/testing/mock-data/attorneys.mock.ts b/backend/functions/lib/testing/mock-data/attorneys.mock.ts deleted file mode 100644 index 243bfe501..000000000 --- a/backend/functions/lib/testing/mock-data/attorneys.mock.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { TRIAL_ATTORNEYS } from '../../../../../common/src/cams/test-utilities/attorneys.mock'; - -const list = { - attorneyList: TRIAL_ATTORNEYS, -}; - -export { list }; diff --git a/backend/functions/tsconfig.build.json b/backend/functions/tsconfig.build.json deleted file mode 100644 index 276ba9abd..000000000 --- a/backend/functions/tsconfig.build.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "./tsconfig.json", - "exclude": ["**/*.test.ts","**/testing*","**/fake*", "**/testing/*"] -} diff --git a/backend/functions/jest.config.js b/backend/jest.config.js similarity index 83% rename from backend/functions/jest.config.js rename to backend/jest.config.js index ff284ec8a..f2ce5d400 100644 --- a/backend/functions/jest.config.js +++ b/backend/jest.config.js @@ -16,7 +16,7 @@ module.exports = { '.*test.[jt]s', '.*mock.*.ts', '.*.d.ts', - 'azure/app-insights.ts', + 'function-apps/azure/app-insights.ts', 'dist/', 'coverage/', 'lib/adapters/gateways/cases.local.gateway.ts', @@ -28,9 +28,9 @@ module.exports = { 'lib/testing/testing-utilities.ts', 'jest.*config.js', 'lib/adapters/gateways/okta/HumbleVerifier.ts', - 'migration/client/', - 'migration/orchestration/', - 'migration/loadConsolidations.ts', + 'function-apps/migration/client/', + 'function-apps/migration/orchestration/', + 'function-apps/migration/loadConsolidations.ts', ], testMatch: ['**/?(*.)+(spec|test).[jt]s?(x)', '!**/?(*.)+(integration).(spec|test).[jt]s?(x)'], }; diff --git a/backend/functions/lib/adapters/gateways/abstract-mssql-client.exception.test.ts b/backend/lib/adapters/gateways/abstract-mssql-client.exception.test.ts similarity index 100% rename from backend/functions/lib/adapters/gateways/abstract-mssql-client.exception.test.ts rename to backend/lib/adapters/gateways/abstract-mssql-client.exception.test.ts diff --git a/backend/functions/lib/adapters/gateways/abstract-mssql-client.test.ts b/backend/lib/adapters/gateways/abstract-mssql-client.test.ts similarity index 100% rename from backend/functions/lib/adapters/gateways/abstract-mssql-client.test.ts rename to backend/lib/adapters/gateways/abstract-mssql-client.test.ts diff --git a/backend/functions/lib/adapters/gateways/abstract-mssql-client.ts b/backend/lib/adapters/gateways/abstract-mssql-client.ts similarity index 100% rename from backend/functions/lib/adapters/gateways/abstract-mssql-client.ts rename to backend/lib/adapters/gateways/abstract-mssql-client.ts diff --git a/backend/functions/lib/adapters/gateways/acms/acms.gateway.test.ts b/backend/lib/adapters/gateways/acms/acms.gateway.test.ts similarity index 100% rename from backend/functions/lib/adapters/gateways/acms/acms.gateway.test.ts rename to backend/lib/adapters/gateways/acms/acms.gateway.test.ts diff --git a/backend/functions/lib/adapters/gateways/acms/acms.gateway.ts b/backend/lib/adapters/gateways/acms/acms.gateway.ts similarity index 100% rename from backend/functions/lib/adapters/gateways/acms/acms.gateway.ts rename to backend/lib/adapters/gateways/acms/acms.gateway.ts diff --git a/backend/functions/lib/adapters/gateways/cases.local.gateway.ts b/backend/lib/adapters/gateways/cases.local.gateway.ts similarity index 94% rename from backend/functions/lib/adapters/gateways/cases.local.gateway.ts rename to backend/lib/adapters/gateways/cases.local.gateway.ts index 6696d2a08..733cacbf4 100644 --- a/backend/functions/lib/adapters/gateways/cases.local.gateway.ts +++ b/backend/lib/adapters/gateways/cases.local.gateway.ts @@ -2,10 +2,10 @@ import { CasesInterface } from '../../use-cases/cases.interface'; import { ApplicationContext } from '../types/basic'; import { GatewayHelper } from './gateway-helper'; import { getMonthDayYearStringFromDate } from '../utils/date-helper'; -import { CaseBasics, CaseDetail } from '../../../../../common/src/cams/cases'; +import { CaseBasics, CaseDetail } from '../../../../common/src/cams/cases'; import { CamsError } from '../../common-errors/cams-error'; -import { CasesSearchPredicate } from '../../../../../common/src/api/search'; -import MockData from '../../../../../common/src/cams/test-utilities/mock-data'; +import { CasesSearchPredicate } from '../../../../common/src/api/search'; +import MockData from '../../../../common/src/cams/test-utilities/mock-data'; const MODULE_NAME = 'MOCK-CASES-GATEWAY'; diff --git a/backend/functions/lib/adapters/gateways/debtor-type-gateway.test.ts b/backend/lib/adapters/gateways/debtor-type-gateway.test.ts similarity index 100% rename from backend/functions/lib/adapters/gateways/debtor-type-gateway.test.ts rename to backend/lib/adapters/gateways/debtor-type-gateway.test.ts diff --git a/backend/functions/lib/adapters/gateways/debtor-type-gateway.ts b/backend/lib/adapters/gateways/debtor-type-gateway.ts similarity index 100% rename from backend/functions/lib/adapters/gateways/debtor-type-gateway.ts rename to backend/lib/adapters/gateways/debtor-type-gateway.ts diff --git a/backend/functions/lib/adapters/gateways/dxtr/case-docket.dxtr.gateway.test.ts b/backend/lib/adapters/gateways/dxtr/case-docket.dxtr.gateway.test.ts similarity index 100% rename from backend/functions/lib/adapters/gateways/dxtr/case-docket.dxtr.gateway.test.ts rename to backend/lib/adapters/gateways/dxtr/case-docket.dxtr.gateway.test.ts diff --git a/backend/functions/lib/adapters/gateways/dxtr/case-docket.dxtr.gateway.ts b/backend/lib/adapters/gateways/dxtr/case-docket.dxtr.gateway.ts similarity index 99% rename from backend/functions/lib/adapters/gateways/dxtr/case-docket.dxtr.gateway.ts rename to backend/lib/adapters/gateways/dxtr/case-docket.dxtr.gateway.ts index c145b16b2..39b664108 100644 --- a/backend/functions/lib/adapters/gateways/dxtr/case-docket.dxtr.gateway.ts +++ b/backend/lib/adapters/gateways/dxtr/case-docket.dxtr.gateway.ts @@ -7,7 +7,7 @@ import { ApplicationContext } from '../../types/basic'; import { CaseDocketGateway } from '../../../use-cases/gateways.types'; import { CamsError } from '../../../common-errors/cams-error'; import { NotFoundError } from '../../../common-errors/not-found-error'; -import { CaseDocket, CaseDocketEntryDocument } from '../../../../../../common/src/cams/cases'; +import { CaseDocket, CaseDocketEntryDocument } from '../../../../../common/src/cams/cases'; const MODULENAME = 'CASE-DOCKET-DXTR-GATEWAY'; diff --git a/backend/functions/lib/adapters/gateways/dxtr/case-docket.mock.gateway.ts b/backend/lib/adapters/gateways/dxtr/case-docket.mock.gateway.ts similarity index 91% rename from backend/functions/lib/adapters/gateways/dxtr/case-docket.mock.gateway.ts rename to backend/lib/adapters/gateways/dxtr/case-docket.mock.gateway.ts index 0a4038154..16dc39931 100644 --- a/backend/functions/lib/adapters/gateways/dxtr/case-docket.mock.gateway.ts +++ b/backend/lib/adapters/gateways/dxtr/case-docket.mock.gateway.ts @@ -3,7 +3,7 @@ import { ApplicationContext } from '../../types/basic'; import { CaseDocketGateway } from '../../../use-cases/gateways.types'; import { GatewayHelper } from '../gateway-helper'; import { NORMAL_CASE_ID } from '../../../testing/testing-constants'; -import { CaseDocket } from '../../../../../../common/src/cams/cases'; +import { CaseDocket } from '../../../../../common/src/cams/cases'; const MODULE_NAME = 'CASE-DOCKET-MOCK-GATEWAY'; diff --git a/backend/functions/lib/adapters/gateways/dxtr/cases.dxtr.gateway.test.ts b/backend/lib/adapters/gateways/dxtr/cases.dxtr.gateway.test.ts similarity index 99% rename from backend/functions/lib/adapters/gateways/dxtr/cases.dxtr.gateway.test.ts rename to backend/lib/adapters/gateways/dxtr/cases.dxtr.gateway.test.ts index d59f83fab..2b81d97a2 100644 --- a/backend/functions/lib/adapters/gateways/dxtr/cases.dxtr.gateway.test.ts +++ b/backend/lib/adapters/gateways/dxtr/cases.dxtr.gateway.test.ts @@ -1,13 +1,13 @@ import CasesDxtrGateway, { getCaseIdParts } from './cases.dxtr.gateway'; import * as database from '../../utils/database'; import { QueryResults } from '../../types/database'; -import { CaseDetail } from '../../../../../../common/src/cams/cases'; +import { CaseDetail } from '../../../../../common/src/cams/cases'; import * as featureFlags from '../../utils/feature-flag'; import { CamsError } from '../../../common-errors/cams-error'; import { NotFoundError } from '../../../common-errors/not-found-error'; import { CASE_SUMMARIES } from '../../../testing/mock-data/case-summaries.mock'; import { DEBTORS } from '../../../testing/mock-data/debtors.mock'; -import { MockData } from '../../../../../../common/src/cams/test-utilities/mock-data'; +import { MockData } from '../../../../../common/src/cams/test-utilities/mock-data'; import { createMockApplicationContext } from '../../../testing/testing-utilities'; const dxtrDatabaseName = 'some-database-name'; diff --git a/backend/functions/lib/adapters/gateways/dxtr/cases.dxtr.gateway.ts b/backend/lib/adapters/gateways/dxtr/cases.dxtr.gateway.ts similarity index 99% rename from backend/functions/lib/adapters/gateways/dxtr/cases.dxtr.gateway.ts rename to backend/lib/adapters/gateways/dxtr/cases.dxtr.gateway.ts index 2b3f528ad..af955e12d 100644 --- a/backend/functions/lib/adapters/gateways/dxtr/cases.dxtr.gateway.ts +++ b/backend/lib/adapters/gateways/dxtr/cases.dxtr.gateway.ts @@ -12,12 +12,9 @@ import { getDebtorTypeLabel } from '../debtor-type-gateway'; import { getPetitionInfo } from '../petition-gateway'; import { NotFoundError } from '../../../common-errors/not-found-error'; import { CamsError } from '../../../common-errors/cams-error'; -import { - CasesSearchPredicate, - DEFAULT_SEARCH_LIMIT, -} from '../../../../../../common/src/api/search'; -import { CaseBasics, CaseDetail, CaseSummary } from '../../../../../../common/src/cams/cases'; -import { Party, DebtorAttorney } from '../../../../../../common/src/cams/parties'; +import { CasesSearchPredicate, DEFAULT_SEARCH_LIMIT } from '../../../../../common/src/api/search'; +import { CaseBasics, CaseDetail, CaseSummary } from '../../../../../common/src/cams/cases'; +import { Party, DebtorAttorney } from '../../../../../common/src/cams/parties'; const MODULENAME = 'CASES-DXTR-GATEWAY'; diff --git a/backend/functions/lib/adapters/gateways/dxtr/dxtr.constants.ts b/backend/lib/adapters/gateways/dxtr/dxtr.constants.ts similarity index 100% rename from backend/functions/lib/adapters/gateways/dxtr/dxtr.constants.ts rename to backend/lib/adapters/gateways/dxtr/dxtr.constants.ts diff --git a/backend/functions/lib/adapters/gateways/dxtr/dxtr.gateway.helper.test.ts b/backend/lib/adapters/gateways/dxtr/dxtr.gateway.helper.test.ts similarity index 100% rename from backend/functions/lib/adapters/gateways/dxtr/dxtr.gateway.helper.test.ts rename to backend/lib/adapters/gateways/dxtr/dxtr.gateway.helper.test.ts diff --git a/backend/functions/lib/adapters/gateways/dxtr/dxtr.gateway.helper.ts b/backend/lib/adapters/gateways/dxtr/dxtr.gateway.helper.ts similarity index 100% rename from backend/functions/lib/adapters/gateways/dxtr/dxtr.gateway.helper.ts rename to backend/lib/adapters/gateways/dxtr/dxtr.gateway.helper.ts diff --git a/backend/functions/lib/adapters/gateways/dxtr/offices.dxtr.gateway.test.ts b/backend/lib/adapters/gateways/dxtr/offices.dxtr.gateway.test.ts similarity index 95% rename from backend/functions/lib/adapters/gateways/dxtr/offices.dxtr.gateway.test.ts rename to backend/lib/adapters/gateways/dxtr/offices.dxtr.gateway.test.ts index dcef5ec4c..0cad274e1 100644 --- a/backend/functions/lib/adapters/gateways/dxtr/offices.dxtr.gateway.test.ts +++ b/backend/lib/adapters/gateways/dxtr/offices.dxtr.gateway.test.ts @@ -4,8 +4,8 @@ import { ApplicationContext } from '../../types/basic'; import { createMockApplicationContext } from '../../../testing/testing-utilities'; import * as database from '../../utils/database'; import { QueryResults } from '../../types/database'; -import { COURT_DIVISIONS } from '../../../../../../common/src/cams/test-utilities/courts.mock'; -import { USTP_OFFICES_ARRAY, UstpOfficeDetails } from '../../../../../../common/src/cams/offices'; +import { COURT_DIVISIONS } from '../../../../../common/src/cams/test-utilities/courts.mock'; +import { USTP_OFFICES_ARRAY, UstpOfficeDetails } from '../../../../../common/src/cams/offices'; describe('offices gateway tests', () => { describe('getOffice tests', () => { diff --git a/backend/functions/lib/adapters/gateways/dxtr/offices.dxtr.gateway.ts b/backend/lib/adapters/gateways/dxtr/offices.dxtr.gateway.ts similarity index 95% rename from backend/functions/lib/adapters/gateways/dxtr/offices.dxtr.gateway.ts rename to backend/lib/adapters/gateways/dxtr/offices.dxtr.gateway.ts index 0eba548cc..ee47ee3c2 100644 --- a/backend/functions/lib/adapters/gateways/dxtr/offices.dxtr.gateway.ts +++ b/backend/lib/adapters/gateways/dxtr/offices.dxtr.gateway.ts @@ -4,12 +4,8 @@ import { ApplicationContext } from '../../types/basic'; import { DbTableFieldSpec, QueryResults } from '../../types/database'; import { executeQuery } from '../../utils/database'; import { OfficesGateway } from '../../../use-cases/offices/offices.types'; -import { CamsUserReference } from '../../../../../../common/src/cams/users'; -import { - UstpDivision, - UstpGroup, - UstpOfficeDetails, -} from '../../../../../../common/src/cams/offices'; +import { CamsUserReference } from '../../../../../common/src/cams/users'; +import { UstpDivision, UstpGroup, UstpOfficeDetails } from '../../../../../common/src/cams/offices'; import { buildOfficeCode, getOfficeName } from '../../../use-cases/offices/offices'; const MODULE_NAME = 'OFFICES-GATEWAY'; diff --git a/backend/functions/lib/adapters/gateways/dxtr/orders.dxtr.gateway.test.ts b/backend/lib/adapters/gateways/dxtr/orders.dxtr.gateway.test.ts similarity index 99% rename from backend/functions/lib/adapters/gateways/dxtr/orders.dxtr.gateway.test.ts rename to backend/lib/adapters/gateways/dxtr/orders.dxtr.gateway.test.ts index 0d1d983eb..310e87502 100644 --- a/backend/functions/lib/adapters/gateways/dxtr/orders.dxtr.gateway.test.ts +++ b/backend/lib/adapters/gateways/dxtr/orders.dxtr.gateway.test.ts @@ -9,7 +9,7 @@ import { dxtrOrdersSorter, } from './orders.dxtr.gateway'; import { ApplicationContext } from '../../types/basic'; -import { MockData } from '../../../../../../common/src/cams/test-utilities/mock-data'; +import { MockData } from '../../../../../common/src/cams/test-utilities/mock-data'; function getEarliestDate(docket: DxtrOrderDocketEntry[]) { return docket.reduce((earliestDate, de) => { diff --git a/backend/functions/lib/adapters/gateways/dxtr/orders.dxtr.gateway.ts b/backend/lib/adapters/gateways/dxtr/orders.dxtr.gateway.ts similarity index 99% rename from backend/functions/lib/adapters/gateways/dxtr/orders.dxtr.gateway.ts rename to backend/lib/adapters/gateways/dxtr/orders.dxtr.gateway.ts index aa515f110..b93e798a9 100644 --- a/backend/functions/lib/adapters/gateways/dxtr/orders.dxtr.gateway.ts +++ b/backend/lib/adapters/gateways/dxtr/orders.dxtr.gateway.ts @@ -9,9 +9,9 @@ import { RawConsolidationOrder, RawOrderSync, TransferOrder, -} from '../../../../../../common/src/cams/orders'; +} from '../../../../../common/src/cams/orders'; import { DxtrCaseDocketEntryDocument, translateModel } from './case-docket.dxtr.gateway'; -import { CaseDocketEntry } from '../../../../../../common/src/cams/cases'; +import { CaseDocketEntry } from '../../../../../common/src/cams/cases'; const MODULE_NAME = 'ORDERS-DXTR-GATEWAY'; diff --git a/backend/functions/lib/adapters/gateways/gateway-helper.test.ts b/backend/lib/adapters/gateways/gateway-helper.test.ts similarity index 100% rename from backend/functions/lib/adapters/gateways/gateway-helper.test.ts rename to backend/lib/adapters/gateways/gateway-helper.test.ts diff --git a/backend/functions/lib/adapters/gateways/gateway-helper.ts b/backend/lib/adapters/gateways/gateway-helper.ts similarity index 86% rename from backend/functions/lib/adapters/gateways/gateway-helper.ts rename to backend/lib/adapters/gateways/gateway-helper.ts index 714bfdd9c..57ece00e0 100644 --- a/backend/functions/lib/adapters/gateways/gateway-helper.ts +++ b/backend/lib/adapters/gateways/gateway-helper.ts @@ -6,9 +6,9 @@ import { DEBTOR_ATTORNEYS } from '../../testing/mock-data/debtor-attorneys.mock' import { DEBTORS } from '../../testing/mock-data/debtors.mock'; import { DXTR_CASE_DOCKET_ENTRIES } from '../../testing/mock-data/case-docket-entries.mock'; import { CASE_HISTORY } from '../../testing/mock-data/case-history.mock'; -import { CaseDetail, CaseDocketEntry } from '../../../../../common/src/cams/cases'; -import { DebtorAttorney, Party } from '../../../../../common/src/cams/parties'; -import { CaseAssignmentHistory } from '../../../../../common/src/cams/history'; +import { CaseDetail, CaseDocketEntry } from '../../../../common/src/cams/cases'; +import { DebtorAttorney, Party } from '../../../../common/src/cams/parties'; +import { CaseAssignmentHistory } from '../../../../common/src/cams/history'; export class GatewayHelper { getAllCasesMockExtract(): CaseDetail[] { diff --git a/backend/functions/lib/adapters/gateways/mongo/case-assignment.mongo.repository.test.ts b/backend/lib/adapters/gateways/mongo/case-assignment.mongo.repository.test.ts similarity index 98% rename from backend/functions/lib/adapters/gateways/mongo/case-assignment.mongo.repository.test.ts rename to backend/lib/adapters/gateways/mongo/case-assignment.mongo.repository.test.ts index 3f8fa0933..0a2561a9e 100644 --- a/backend/functions/lib/adapters/gateways/mongo/case-assignment.mongo.repository.test.ts +++ b/backend/lib/adapters/gateways/mongo/case-assignment.mongo.repository.test.ts @@ -1,4 +1,4 @@ -import MockData from '../../../../../../common/src/cams/test-utilities/mock-data'; +import MockData from '../../../../../common/src/cams/test-utilities/mock-data'; import { getCamsError } from '../../../common-errors/error-utilities'; import { closeDeferred } from '../../../deferrable/defer-close'; import { createMockApplicationContext } from '../../../testing/testing-utilities'; diff --git a/backend/functions/lib/adapters/gateways/mongo/case-assignment.mongo.repository.ts b/backend/lib/adapters/gateways/mongo/case-assignment.mongo.repository.ts similarity index 97% rename from backend/functions/lib/adapters/gateways/mongo/case-assignment.mongo.repository.ts rename to backend/lib/adapters/gateways/mongo/case-assignment.mongo.repository.ts index 9a1dd124a..db266b923 100644 --- a/backend/functions/lib/adapters/gateways/mongo/case-assignment.mongo.repository.ts +++ b/backend/lib/adapters/gateways/mongo/case-assignment.mongo.repository.ts @@ -1,5 +1,5 @@ import { ApplicationContext } from '../../types/basic'; -import { CaseAssignment } from '../../../../../../common/src/cams/assignments'; +import { CaseAssignment } from '../../../../../common/src/cams/assignments'; import QueryBuilder from '../../../query/query-builder'; import { CaseAssignmentRepository } from '../../../use-cases/gateways.types'; import { getCamsError } from '../../../common-errors/error-utilities'; diff --git a/backend/functions/lib/adapters/gateways/mongo/cases.mongo.repository.test.ts b/backend/lib/adapters/gateways/mongo/cases.mongo.repository.test.ts similarity index 95% rename from backend/functions/lib/adapters/gateways/mongo/cases.mongo.repository.test.ts rename to backend/lib/adapters/gateways/mongo/cases.mongo.repository.test.ts index 0c5170d34..e7723e7c1 100644 --- a/backend/functions/lib/adapters/gateways/mongo/cases.mongo.repository.test.ts +++ b/backend/lib/adapters/gateways/mongo/cases.mongo.repository.test.ts @@ -1,7 +1,7 @@ -import { SYSTEM_USER_REFERENCE } from '../../../../../../common/src/cams/auditable'; -import { TransferFrom, TransferTo } from '../../../../../../common/src/cams/events'; -import { CaseAssignmentHistory } from '../../../../../../common/src/cams/history'; -import MockData from '../../../../../../common/src/cams/test-utilities/mock-data'; +import { SYSTEM_USER_REFERENCE } from '../../../../../common/src/cams/auditable'; +import { TransferFrom, TransferTo } from '../../../../../common/src/cams/events'; +import { CaseAssignmentHistory } from '../../../../../common/src/cams/history'; +import MockData from '../../../../../common/src/cams/test-utilities/mock-data'; import { CamsError } from '../../../common-errors/cams-error'; import { closeDeferred } from '../../../deferrable/defer-close'; import { CASE_HISTORY } from '../../../testing/mock-data/case-history.mock'; diff --git a/backend/functions/lib/adapters/gateways/mongo/cases.mongo.repository.ts b/backend/lib/adapters/gateways/mongo/cases.mongo.repository.ts similarity index 96% rename from backend/functions/lib/adapters/gateways/mongo/cases.mongo.repository.ts rename to backend/lib/adapters/gateways/mongo/cases.mongo.repository.ts index 40178aa32..598225ea3 100644 --- a/backend/functions/lib/adapters/gateways/mongo/cases.mongo.repository.ts +++ b/backend/lib/adapters/gateways/mongo/cases.mongo.repository.ts @@ -4,9 +4,9 @@ import { Transfer, TransferFrom, TransferTo, -} from '../../../../../../common/src/cams/events'; +} from '../../../../../common/src/cams/events'; import { ApplicationContext } from '../../types/basic'; -import { CaseHistory } from '../../../../../../common/src/cams/history'; +import { CaseHistory } from '../../../../../common/src/cams/history'; import QueryBuilder from '../../../query/query-builder'; import { CasesRepository } from '../../../use-cases/gateways.types'; import { getCamsError } from '../../../common-errors/error-utilities'; diff --git a/backend/functions/lib/adapters/gateways/mongo/consolidations.mongo.repository.test.ts b/backend/lib/adapters/gateways/mongo/consolidations.mongo.repository.test.ts similarity index 98% rename from backend/functions/lib/adapters/gateways/mongo/consolidations.mongo.repository.test.ts rename to backend/lib/adapters/gateways/mongo/consolidations.mongo.repository.test.ts index 970520db4..af9632d23 100644 --- a/backend/functions/lib/adapters/gateways/mongo/consolidations.mongo.repository.test.ts +++ b/backend/lib/adapters/gateways/mongo/consolidations.mongo.repository.test.ts @@ -1,6 +1,6 @@ import { ApplicationContext } from '../../types/basic'; import { createMockApplicationContext } from '../../../testing/testing-utilities'; -import MockData from '../../../../../../common/src/cams/test-utilities/mock-data'; +import MockData from '../../../../../common/src/cams/test-utilities/mock-data'; import ConsolidationOrdersMongoRepository from './consolidations.mongo.repository'; import { MongoCollectionAdapter } from './utils/mongo-adapter'; import QueryBuilder from '../../../query/query-builder'; diff --git a/backend/functions/lib/adapters/gateways/mongo/consolidations.mongo.repository.ts b/backend/lib/adapters/gateways/mongo/consolidations.mongo.repository.ts similarity index 93% rename from backend/functions/lib/adapters/gateways/mongo/consolidations.mongo.repository.ts rename to backend/lib/adapters/gateways/mongo/consolidations.mongo.repository.ts index 62c2e08fe..ca6958ec0 100644 --- a/backend/functions/lib/adapters/gateways/mongo/consolidations.mongo.repository.ts +++ b/backend/lib/adapters/gateways/mongo/consolidations.mongo.repository.ts @@ -1,10 +1,10 @@ -import { OrdersSearchPredicate } from '../../../../../../common/src/api/search'; -import { ConsolidationOrder } from '../../../../../../common/src/cams/orders'; +import { OrdersSearchPredicate } from '../../../../../common/src/api/search'; +import { ConsolidationOrder } from '../../../../../common/src/cams/orders'; import QueryBuilder, { ConditionOrConjunction } from '../../../query/query-builder'; import { ConsolidationOrdersRepository } from '../../../use-cases/gateways.types'; import { ApplicationContext } from '../../types/basic'; import { getCamsError } from '../../../common-errors/error-utilities'; -import { CamsDocument } from '../../../../../../common/src/cams/document'; +import { CamsDocument } from '../../../../../common/src/cams/document'; import { BaseMongoRepository } from './utils/base-mongo-repository'; const MODULE_NAME: string = 'CONSOLIDATIONS_MONGO_REPOSITORY'; diff --git a/backend/functions/lib/adapters/gateways/mongo/offices.mongo.repository.test.ts b/backend/lib/adapters/gateways/mongo/offices.mongo.repository.test.ts similarity index 93% rename from backend/functions/lib/adapters/gateways/mongo/offices.mongo.repository.test.ts rename to backend/lib/adapters/gateways/mongo/offices.mongo.repository.test.ts index 8ae93dfaf..1b0cf6d79 100644 --- a/backend/functions/lib/adapters/gateways/mongo/offices.mongo.repository.test.ts +++ b/backend/lib/adapters/gateways/mongo/offices.mongo.repository.test.ts @@ -5,11 +5,11 @@ import { } from '../../../testing/testing-utilities'; import { ApplicationContext } from '../../types/basic'; import { MongoCollectionAdapter } from './utils/mongo-adapter'; -import MockData from '../../../../../../common/src/cams/test-utilities/mock-data'; +import MockData from '../../../../../common/src/cams/test-utilities/mock-data'; import QueryBuilder from '../../../query/query-builder'; -import { CamsRole } from '../../../../../../common/src/cams/roles'; +import { CamsRole } from '../../../../../common/src/cams/roles'; import { closeDeferred } from '../../../deferrable/defer-close'; -import { createAuditRecord } from '../../../../../../common/src/cams/auditable'; +import { createAuditRecord } from '../../../../../common/src/cams/auditable'; import { getCamsError } from '../../../common-errors/error-utilities'; describe('offices repo', () => { diff --git a/backend/functions/lib/adapters/gateways/mongo/offices.mongo.repository.ts b/backend/lib/adapters/gateways/mongo/offices.mongo.repository.ts similarity index 90% rename from backend/functions/lib/adapters/gateways/mongo/offices.mongo.repository.ts rename to backend/lib/adapters/gateways/mongo/offices.mongo.repository.ts index 9ee537311..3f9aab637 100644 --- a/backend/functions/lib/adapters/gateways/mongo/offices.mongo.repository.ts +++ b/backend/lib/adapters/gateways/mongo/offices.mongo.repository.ts @@ -1,8 +1,8 @@ import { ApplicationContext } from '../../types/basic'; -import { AttorneyUser, CamsUserReference, Staff } from '../../../../../../common/src/cams/users'; -import { Auditable, createAuditRecord } from '../../../../../../common/src/cams/auditable'; -import { CamsRole } from '../../../../../../common/src/cams/roles'; -import { getCamsUserReference } from '../../../../../../common/src/cams/session'; +import { AttorneyUser, CamsUserReference, Staff } from '../../../../../common/src/cams/users'; +import { Auditable, createAuditRecord } from '../../../../../common/src/cams/auditable'; +import { CamsRole } from '../../../../../common/src/cams/roles'; +import { getCamsUserReference } from '../../../../../common/src/cams/session'; import QueryBuilder from '../../../query/query-builder'; import { getCamsError } from '../../../common-errors/error-utilities'; import { OfficesRepository } from '../../../use-cases/gateways.types'; diff --git a/backend/functions/lib/adapters/gateways/mongo/orders.mongo.repository.test.ts b/backend/lib/adapters/gateways/mongo/orders.mongo.repository.test.ts similarity index 97% rename from backend/functions/lib/adapters/gateways/mongo/orders.mongo.repository.test.ts rename to backend/lib/adapters/gateways/mongo/orders.mongo.repository.test.ts index 9a8f947e0..0d8210578 100644 --- a/backend/functions/lib/adapters/gateways/mongo/orders.mongo.repository.test.ts +++ b/backend/lib/adapters/gateways/mongo/orders.mongo.repository.test.ts @@ -1,8 +1,8 @@ import { createMockApplicationContext } from '../../../testing/testing-utilities'; import { OrdersMongoRepository } from './orders.mongo.repository'; import { ApplicationContext } from '../../types/basic'; -import MockData from '../../../../../../common/src/cams/test-utilities/mock-data'; -import { TransferOrderAction } from '../../../../../../common/src/cams/orders'; +import MockData from '../../../../../common/src/cams/test-utilities/mock-data'; +import { TransferOrderAction } from '../../../../../common/src/cams/orders'; import { MongoCollectionAdapter } from './utils/mongo-adapter'; import QueryBuilder from '../../../query/query-builder'; import { closeDeferred } from '../../../deferrable/defer-close'; diff --git a/backend/functions/lib/adapters/gateways/mongo/orders.mongo.repository.ts b/backend/lib/adapters/gateways/mongo/orders.mongo.repository.ts similarity index 94% rename from backend/functions/lib/adapters/gateways/mongo/orders.mongo.repository.ts rename to backend/lib/adapters/gateways/mongo/orders.mongo.repository.ts index 40d308f83..417d502ec 100644 --- a/backend/functions/lib/adapters/gateways/mongo/orders.mongo.repository.ts +++ b/backend/lib/adapters/gateways/mongo/orders.mongo.repository.ts @@ -1,9 +1,5 @@ -import { OrdersSearchPredicate } from '../../../../../../common/src/api/search'; -import { - Order, - TransferOrder, - TransferOrderAction, -} from '../../../../../../common/src/cams/orders'; +import { OrdersSearchPredicate } from '../../../../../common/src/api/search'; +import { Order, TransferOrder, TransferOrderAction } from '../../../../../common/src/cams/orders'; import { ApplicationContext } from '../../types/basic'; import { OrdersRepository } from '../../../use-cases/gateways.types'; import QueryBuilder, { ConditionOrConjunction } from '../../../query/query-builder'; diff --git a/backend/functions/lib/adapters/gateways/mongo/runtime-state.mongo.repository.test.ts b/backend/lib/adapters/gateways/mongo/runtime-state.mongo.repository.test.ts similarity index 100% rename from backend/functions/lib/adapters/gateways/mongo/runtime-state.mongo.repository.test.ts rename to backend/lib/adapters/gateways/mongo/runtime-state.mongo.repository.test.ts diff --git a/backend/functions/lib/adapters/gateways/mongo/runtime-state.mongo.repository.ts b/backend/lib/adapters/gateways/mongo/runtime-state.mongo.repository.ts similarity index 100% rename from backend/functions/lib/adapters/gateways/mongo/runtime-state.mongo.repository.ts rename to backend/lib/adapters/gateways/mongo/runtime-state.mongo.repository.ts diff --git a/backend/functions/lib/adapters/gateways/mongo/user-session-cache.mongo.repository.test.ts b/backend/lib/adapters/gateways/mongo/user-session-cache.mongo.repository.test.ts similarity index 95% rename from backend/functions/lib/adapters/gateways/mongo/user-session-cache.mongo.repository.test.ts rename to backend/lib/adapters/gateways/mongo/user-session-cache.mongo.repository.test.ts index de64a44e6..743dfb170 100644 --- a/backend/functions/lib/adapters/gateways/mongo/user-session-cache.mongo.repository.test.ts +++ b/backend/lib/adapters/gateways/mongo/user-session-cache.mongo.repository.test.ts @@ -5,8 +5,8 @@ import { CachedCamsSession, UserSessionCacheMongoRepository, } from './user-session-cache.mongo.repository'; -import { MockData } from '../../../../../../common/src/cams/test-utilities/mock-data'; -import { CamsJwtClaims } from '../../../../../../common/src/cams/jwt'; +import { MockData } from '../../../../../common/src/cams/test-utilities/mock-data'; +import { CamsJwtClaims } from '../../../../../common/src/cams/jwt'; import { MongoCollectionAdapter } from './utils/mongo-adapter'; import { closeDeferred } from '../../../deferrable/defer-close'; import QueryBuilder from '../../../query/query-builder'; diff --git a/backend/functions/lib/adapters/gateways/mongo/user-session-cache.mongo.repository.ts b/backend/lib/adapters/gateways/mongo/user-session-cache.mongo.repository.ts similarity index 95% rename from backend/functions/lib/adapters/gateways/mongo/user-session-cache.mongo.repository.ts rename to backend/lib/adapters/gateways/mongo/user-session-cache.mongo.repository.ts index fdba69d2d..ba3deb9ca 100644 --- a/backend/functions/lib/adapters/gateways/mongo/user-session-cache.mongo.repository.ts +++ b/backend/lib/adapters/gateways/mongo/user-session-cache.mongo.repository.ts @@ -1,8 +1,8 @@ import * as jwt from 'jsonwebtoken'; import { ApplicationContext } from '../../types/basic'; -import { CamsSession } from '../../../../../../common/src/cams/session'; +import { CamsSession } from '../../../../../common/src/cams/session'; import { UnauthorizedError } from '../../../common-errors/unauthorized-error'; -import { CamsJwtClaims } from '../../../../../../common/src/cams/jwt'; +import { CamsJwtClaims } from '../../../../../common/src/cams/jwt'; import { getCamsError } from '../../../common-errors/error-utilities'; import QueryBuilder from '../../../query/query-builder'; import { UserSessionCacheRepository } from '../../../use-cases/gateways.types'; diff --git a/backend/functions/lib/adapters/gateways/mongo/utils/base-mongo-repository.ts b/backend/lib/adapters/gateways/mongo/utils/base-mongo-repository.ts similarity index 100% rename from backend/functions/lib/adapters/gateways/mongo/utils/base-mongo-repository.ts rename to backend/lib/adapters/gateways/mongo/utils/base-mongo-repository.ts diff --git a/backend/functions/lib/adapters/gateways/mongo/utils/mongo-adapter.test.ts b/backend/lib/adapters/gateways/mongo/utils/mongo-adapter.test.ts similarity index 100% rename from backend/functions/lib/adapters/gateways/mongo/utils/mongo-adapter.test.ts rename to backend/lib/adapters/gateways/mongo/utils/mongo-adapter.test.ts diff --git a/backend/functions/lib/adapters/gateways/mongo/utils/mongo-adapter.ts b/backend/lib/adapters/gateways/mongo/utils/mongo-adapter.ts similarity index 100% rename from backend/functions/lib/adapters/gateways/mongo/utils/mongo-adapter.ts rename to backend/lib/adapters/gateways/mongo/utils/mongo-adapter.ts diff --git a/backend/functions/lib/adapters/gateways/mongo/utils/mongo-query-renderer.test.ts b/backend/lib/adapters/gateways/mongo/utils/mongo-query-renderer.test.ts similarity index 100% rename from backend/functions/lib/adapters/gateways/mongo/utils/mongo-query-renderer.test.ts rename to backend/lib/adapters/gateways/mongo/utils/mongo-query-renderer.test.ts diff --git a/backend/functions/lib/adapters/gateways/mongo/utils/mongo-query-renderer.ts b/backend/lib/adapters/gateways/mongo/utils/mongo-query-renderer.ts similarity index 100% rename from backend/functions/lib/adapters/gateways/mongo/utils/mongo-query-renderer.ts rename to backend/lib/adapters/gateways/mongo/utils/mongo-query-renderer.ts diff --git a/backend/functions/lib/adapters/gateways/okta/HumbleVerifier.ts b/backend/lib/adapters/gateways/okta/HumbleVerifier.ts similarity index 94% rename from backend/functions/lib/adapters/gateways/okta/HumbleVerifier.ts rename to backend/lib/adapters/gateways/okta/HumbleVerifier.ts index 71c473e83..d93fc98c1 100644 --- a/backend/functions/lib/adapters/gateways/okta/HumbleVerifier.ts +++ b/backend/lib/adapters/gateways/okta/HumbleVerifier.ts @@ -1,6 +1,6 @@ /* eslint-disable-next-line @typescript-eslint/no-require-imports */ import OktaJwtVerifier = require('@okta/jwt-verifier'); -import { CamsJwt } from '../../../../../../common/src/cams/jwt'; +import { CamsJwt } from '../../../../../common/src/cams/jwt'; type Algorithm = | 'HS256' diff --git a/backend/functions/lib/adapters/gateways/okta/okta-gateway.test.ts b/backend/lib/adapters/gateways/okta/okta-gateway.test.ts similarity index 98% rename from backend/functions/lib/adapters/gateways/okta/okta-gateway.test.ts rename to backend/lib/adapters/gateways/okta/okta-gateway.test.ts index 5254ac71c..7830fb255 100644 --- a/backend/functions/lib/adapters/gateways/okta/okta-gateway.test.ts +++ b/backend/lib/adapters/gateways/okta/okta-gateway.test.ts @@ -2,7 +2,7 @@ import * as Verifier from './HumbleVerifier'; import { UnauthorizedError } from '../../../common-errors/unauthorized-error'; import MockFetch from '../../../testing/mock-fetch'; import OktaGateway from './okta-gateway'; -import { CamsJwtHeader } from '../../../../../../common/src/cams/jwt'; +import { CamsJwtHeader } from '../../../../../common/src/cams/jwt'; import * as AuthorizationConfiguration from '../../../configs/authorization-configuration'; import { AuthorizationConfig } from '../../types/authorization'; diff --git a/backend/functions/lib/adapters/gateways/okta/okta-gateway.ts b/backend/lib/adapters/gateways/okta/okta-gateway.ts similarity index 95% rename from backend/functions/lib/adapters/gateways/okta/okta-gateway.ts rename to backend/lib/adapters/gateways/okta/okta-gateway.ts index 6cd4929b3..d275df5ff 100644 --- a/backend/functions/lib/adapters/gateways/okta/okta-gateway.ts +++ b/backend/lib/adapters/gateways/okta/okta-gateway.ts @@ -3,8 +3,8 @@ import { OpenIdConnectGateway } from '../../types/authorization'; import { ServerConfigError } from '../../../common-errors/server-config-error'; import { UnauthorizedError } from '../../../common-errors/unauthorized-error'; import { verifyAccessToken } from './HumbleVerifier'; -import { CamsUser } from '../../../../../../common/src/cams/users'; -import { CamsJwt } from '../../../../../../common/src/cams/jwt'; +import { CamsUser } from '../../../../../common/src/cams/users'; +import { CamsJwt } from '../../../../../common/src/cams/jwt'; import { isCamsError } from '../../../common-errors/cams-error'; const MODULE_NAME = 'OKTA-GATEWAY'; diff --git a/backend/functions/lib/adapters/gateways/okta/okta-user-group-gateway.test.ts b/backend/lib/adapters/gateways/okta/okta-user-group-gateway.test.ts similarity index 99% rename from backend/functions/lib/adapters/gateways/okta/okta-user-group-gateway.test.ts rename to backend/lib/adapters/gateways/okta/okta-user-group-gateway.test.ts index 1854486db..7aabb24c7 100644 --- a/backend/functions/lib/adapters/gateways/okta/okta-user-group-gateway.test.ts +++ b/backend/lib/adapters/gateways/okta/okta-user-group-gateway.test.ts @@ -1,5 +1,5 @@ import { Collection, Group, User } from '@okta/okta-sdk-nodejs'; -import { CamsUserGroup, CamsUserReference } from '../../../../../../common/src/cams/users'; +import { CamsUserGroup, CamsUserReference } from '../../../../../common/src/cams/users'; import { OktaUserGroupGateway } from './okta-user-group-gateway'; import { UnknownError } from '../../../common-errors/unknown-error'; import { UserGroupGatewayConfig } from '../../types/authorization'; diff --git a/backend/functions/lib/adapters/gateways/okta/okta-user-group-gateway.ts b/backend/lib/adapters/gateways/okta/okta-user-group-gateway.ts similarity index 99% rename from backend/functions/lib/adapters/gateways/okta/okta-user-group-gateway.ts rename to backend/lib/adapters/gateways/okta/okta-user-group-gateway.ts index 27b2416b9..db84fce1b 100644 --- a/backend/functions/lib/adapters/gateways/okta/okta-user-group-gateway.ts +++ b/backend/lib/adapters/gateways/okta/okta-user-group-gateway.ts @@ -3,7 +3,7 @@ import { GroupApiListGroupsRequest, GroupApiListGroupUsersRequest, } from '@okta/okta-sdk-nodejs'; -import { CamsUserGroup, CamsUserReference } from '../../../../../../common/src/cams/users'; +import { CamsUserGroup, CamsUserReference } from '../../../../../common/src/cams/users'; import { UserGroupGateway, UserGroupGatewayConfig } from '../../types/authorization'; import { V2Configuration } from '@okta/okta-sdk-nodejs/src/types/configuration'; import { UnknownError } from '../../../common-errors/unknown-error'; diff --git a/backend/functions/lib/adapters/gateways/petition-gateway.test.ts b/backend/lib/adapters/gateways/petition-gateway.test.ts similarity index 100% rename from backend/functions/lib/adapters/gateways/petition-gateway.test.ts rename to backend/lib/adapters/gateways/petition-gateway.test.ts diff --git a/backend/functions/lib/adapters/gateways/petition-gateway.ts b/backend/lib/adapters/gateways/petition-gateway.ts similarity index 100% rename from backend/functions/lib/adapters/gateways/petition-gateway.ts rename to backend/lib/adapters/gateways/petition-gateway.ts diff --git a/backend/functions/lib/adapters/gateways/storage/local-storage-gateway.test.ts b/backend/lib/adapters/gateways/storage/local-storage-gateway.test.ts similarity index 93% rename from backend/functions/lib/adapters/gateways/storage/local-storage-gateway.test.ts rename to backend/lib/adapters/gateways/storage/local-storage-gateway.test.ts index 2cb4a0d5d..c723fa0e9 100644 --- a/backend/functions/lib/adapters/gateways/storage/local-storage-gateway.test.ts +++ b/backend/lib/adapters/gateways/storage/local-storage-gateway.test.ts @@ -2,7 +2,7 @@ import LocalStorageGateway, { OFFICE_MAPPING_PATH, ROLE_MAPPING_PATH, } from './local-storage-gateway'; -import { CamsRole } from '../../../../../../common/src/cams/roles'; +import { CamsRole } from '../../../../../common/src/cams/roles'; describe('map get', () => { test('should return appropriate string for valid path', () => { diff --git a/backend/functions/lib/adapters/gateways/storage/local-storage-gateway.ts b/backend/lib/adapters/gateways/storage/local-storage-gateway.ts similarity index 96% rename from backend/functions/lib/adapters/gateways/storage/local-storage-gateway.ts rename to backend/lib/adapters/gateways/storage/local-storage-gateway.ts index 038994f52..65e1f0ebf 100644 --- a/backend/functions/lib/adapters/gateways/storage/local-storage-gateway.ts +++ b/backend/lib/adapters/gateways/storage/local-storage-gateway.ts @@ -1,10 +1,10 @@ -import { CamsRole } from '../../../../../../common/src/cams/roles'; +import { CamsRole } from '../../../../../common/src/cams/roles'; import { StorageGateway } from '../../types/storage'; import { USTP_OFFICES_ARRAY, UstpDivisionMeta, UstpOfficeDetails, -} from '../../../../../../common/src/cams/offices'; +} from '../../../../../common/src/cams/offices'; let roleMapping: Map; export const ROLE_MAPPING_PATH = '/rolemapping.csv'; diff --git a/backend/functions/lib/adapters/services/logger.service.test.ts b/backend/lib/adapters/services/logger.service.test.ts similarity index 100% rename from backend/functions/lib/adapters/services/logger.service.test.ts rename to backend/lib/adapters/services/logger.service.test.ts diff --git a/backend/functions/lib/adapters/services/logger.service.ts b/backend/lib/adapters/services/logger.service.ts similarity index 100% rename from backend/functions/lib/adapters/services/logger.service.ts rename to backend/lib/adapters/services/logger.service.ts diff --git a/backend/functions/lib/adapters/types/authorization.ts b/backend/lib/adapters/types/authorization.ts similarity index 90% rename from backend/functions/lib/adapters/types/authorization.ts rename to backend/lib/adapters/types/authorization.ts index 06976d508..8bc125d96 100644 --- a/backend/functions/lib/adapters/types/authorization.ts +++ b/backend/lib/adapters/types/authorization.ts @@ -1,5 +1,5 @@ -import { CamsUser, CamsUserGroup, CamsUserReference } from '../../../../../common/src/cams/users'; -import { CamsJwt } from '../../../../../common/src/cams/jwt'; +import { CamsUser, CamsUserGroup, CamsUserReference } from '../../../../common/src/cams/users'; +import { CamsJwt } from '../../../../common/src/cams/jwt'; import { ApplicationContext } from './basic'; export type AuthorizationConfig = { diff --git a/backend/functions/lib/adapters/types/basic.d.ts b/backend/lib/adapters/types/basic.d.ts similarity index 96% rename from backend/functions/lib/adapters/types/basic.d.ts rename to backend/lib/adapters/types/basic.d.ts index 189afebbc..fa59b19c0 100644 --- a/backend/functions/lib/adapters/types/basic.d.ts +++ b/backend/lib/adapters/types/basic.d.ts @@ -1,6 +1,6 @@ import { ApplicationConfiguration } from '../../configs/application-configuration'; import { CamsError } from '../../common-errors/cams-error'; -import { CamsSession } from '../../../../../common/src/cams/session'; +import { CamsSession } from '../../../../common/src/cams/session'; import { CamsHttpRequest } from './http'; import { Closable } from '../../deferrable/defer-close'; import { Releasable } from '../../use-cases/gateways.types'; diff --git a/backend/functions/lib/adapters/types/cases.d.ts b/backend/lib/adapters/types/cases.d.ts similarity index 100% rename from backend/functions/lib/adapters/types/cases.d.ts rename to backend/lib/adapters/types/cases.d.ts diff --git a/backend/functions/lib/adapters/types/database.d.ts b/backend/lib/adapters/types/database.d.ts similarity index 100% rename from backend/functions/lib/adapters/types/database.d.ts rename to backend/lib/adapters/types/database.d.ts diff --git a/backend/functions/lib/adapters/types/http.d.ts b/backend/lib/adapters/types/http.d.ts similarity index 100% rename from backend/functions/lib/adapters/types/http.d.ts rename to backend/lib/adapters/types/http.d.ts diff --git a/backend/functions/lib/adapters/types/persistence.gateway.d.ts b/backend/lib/adapters/types/persistence.gateway.d.ts similarity index 95% rename from backend/functions/lib/adapters/types/persistence.gateway.d.ts rename to backend/lib/adapters/types/persistence.gateway.d.ts index 15ec70305..c63c9aca4 100644 --- a/backend/functions/lib/adapters/types/persistence.gateway.d.ts +++ b/backend/lib/adapters/types/persistence.gateway.d.ts @@ -1,7 +1,7 @@ import { RecordObj, ObjectKeyVal } from './basic'; import { DbResult } from './database'; import { ApplicationContext } from './basic'; -import { AttorneyUser } from '../../../../../common/src/cams/users'; +import { AttorneyUser } from '../../../../common/src/cams/users'; export interface PersistenceGateway { createRecord( diff --git a/backend/functions/lib/adapters/types/region.d.ts b/backend/lib/adapters/types/region.d.ts similarity index 100% rename from backend/functions/lib/adapters/types/region.d.ts rename to backend/lib/adapters/types/region.d.ts diff --git a/backend/functions/lib/adapters/types/storage.ts b/backend/lib/adapters/types/storage.ts similarity index 74% rename from backend/functions/lib/adapters/types/storage.ts rename to backend/lib/adapters/types/storage.ts index 9636c96b1..9fb1d6bd9 100644 --- a/backend/functions/lib/adapters/types/storage.ts +++ b/backend/lib/adapters/types/storage.ts @@ -1,5 +1,5 @@ -import { CamsRole } from '../../../../../common/src/cams/roles'; -import { UstpDivisionMeta, UstpOfficeDetails } from '../../../../../common/src/cams/offices'; +import { CamsRole } from '../../../../common/src/cams/roles'; +import { UstpDivisionMeta, UstpOfficeDetails } from '../../../../common/src/cams/offices'; export type StorageGateway = { get(key: string): string | null; diff --git a/backend/functions/lib/adapters/utils/database.exception.test.ts b/backend/lib/adapters/utils/database.exception.test.ts similarity index 98% rename from backend/functions/lib/adapters/utils/database.exception.test.ts rename to backend/lib/adapters/utils/database.exception.test.ts index 639be3d72..ac89423ad 100644 --- a/backend/functions/lib/adapters/utils/database.exception.test.ts +++ b/backend/lib/adapters/utils/database.exception.test.ts @@ -1,4 +1,4 @@ -import { executeQuery } from '../utils/database'; +import { executeQuery } from './database'; import { QueryResults, IDbConfig } from '../types/database'; import { ConnectionError, MSSQLError, RequestError } from 'mssql'; import { createMockApplicationContext } from '../../testing/testing-utilities'; diff --git a/backend/functions/lib/adapters/utils/database.test.ts b/backend/lib/adapters/utils/database.test.ts similarity index 97% rename from backend/functions/lib/adapters/utils/database.test.ts rename to backend/lib/adapters/utils/database.test.ts index 9ef67ec4d..458fc8439 100644 --- a/backend/functions/lib/adapters/utils/database.test.ts +++ b/backend/lib/adapters/utils/database.test.ts @@ -1,4 +1,4 @@ -import { executeQuery } from '../utils/database'; +import { executeQuery } from './database'; import { QueryResults, IDbConfig } from '../types/database'; import { createMockApplicationContext } from '../../testing/testing-utilities'; diff --git a/backend/functions/lib/adapters/utils/database.ts b/backend/lib/adapters/utils/database.ts similarity index 100% rename from backend/functions/lib/adapters/utils/database.ts rename to backend/lib/adapters/utils/database.ts diff --git a/backend/functions/lib/adapters/utils/date-helper.test.ts b/backend/lib/adapters/utils/date-helper.test.ts similarity index 100% rename from backend/functions/lib/adapters/utils/date-helper.test.ts rename to backend/lib/adapters/utils/date-helper.test.ts diff --git a/backend/functions/lib/adapters/utils/date-helper.ts b/backend/lib/adapters/utils/date-helper.ts similarity index 100% rename from backend/functions/lib/adapters/utils/date-helper.ts rename to backend/lib/adapters/utils/date-helper.ts diff --git a/backend/functions/lib/adapters/utils/feature-flag.test.ts b/backend/lib/adapters/utils/feature-flag.test.ts similarity index 100% rename from backend/functions/lib/adapters/utils/feature-flag.test.ts rename to backend/lib/adapters/utils/feature-flag.test.ts diff --git a/backend/functions/lib/adapters/utils/feature-flag.ts b/backend/lib/adapters/utils/feature-flag.ts similarity index 92% rename from backend/functions/lib/adapters/utils/feature-flag.ts rename to backend/lib/adapters/utils/feature-flag.ts index 05cd60e68..02bedf958 100644 --- a/backend/functions/lib/adapters/utils/feature-flag.ts +++ b/backend/lib/adapters/utils/feature-flag.ts @@ -1,6 +1,6 @@ import * as ld from '@launchdarkly/node-server-sdk'; import { ApplicationConfiguration } from '../../configs/application-configuration'; -import { defaultFeatureFlags } from '../../../../../common/src/feature-flags'; +import { defaultFeatureFlags } from '../../../../common/src/feature-flags'; import { FeatureFlagSet } from '../types/basic'; export async function getFeatureFlags(config: ApplicationConfiguration): Promise { diff --git a/backend/functions/lib/adapters/utils/http-response.test.ts b/backend/lib/adapters/utils/http-response.test.ts similarity index 100% rename from backend/functions/lib/adapters/utils/http-response.test.ts rename to backend/lib/adapters/utils/http-response.test.ts diff --git a/backend/functions/lib/adapters/utils/http-response.ts b/backend/lib/adapters/utils/http-response.ts similarity index 82% rename from backend/functions/lib/adapters/utils/http-response.ts rename to backend/lib/adapters/utils/http-response.ts index 29e0d2462..b7020bc41 100644 --- a/backend/functions/lib/adapters/utils/http-response.ts +++ b/backend/lib/adapters/utils/http-response.ts @@ -1,5 +1,5 @@ -import HttpStatusCodes from '../../../../../common/src/api/http-status-codes'; -import { ResponseBody } from '../../../../../common/src/api/response'; +import HttpStatusCodes from '../../../../common/src/api/http-status-codes'; +import { ResponseBody } from '../../../../common/src/api/response'; export const commonHeaders: Record = { 'Content-Type': 'application/json', diff --git a/backend/functions/lib/adapters/utils/string-helper.test.ts b/backend/lib/adapters/utils/string-helper.test.ts similarity index 100% rename from backend/functions/lib/adapters/utils/string-helper.test.ts rename to backend/lib/adapters/utils/string-helper.test.ts diff --git a/backend/functions/lib/adapters/utils/string-helper.ts b/backend/lib/adapters/utils/string-helper.ts similarity index 100% rename from backend/functions/lib/adapters/utils/string-helper.ts rename to backend/lib/adapters/utils/string-helper.ts diff --git a/backend/functions/lib/common-errors/bad-request.ts b/backend/lib/common-errors/bad-request.ts similarity index 84% rename from backend/functions/lib/common-errors/bad-request.ts rename to backend/lib/common-errors/bad-request.ts index e05fa6db1..549d453e2 100644 --- a/backend/functions/lib/common-errors/bad-request.ts +++ b/backend/lib/common-errors/bad-request.ts @@ -1,5 +1,5 @@ import { CamsError, CamsErrorOptions } from './cams-error'; -import HttpStatusCodes from '../../../../common/src/api/http-status-codes'; +import HttpStatusCodes from '../../../common/src/api/http-status-codes'; /* eslint-disable-next-line @typescript-eslint/no-empty-object-type */ interface BadRequestErrorOptions extends CamsErrorOptions {} diff --git a/backend/functions/lib/common-errors/cams-error.ts b/backend/lib/common-errors/cams-error.ts similarity index 90% rename from backend/functions/lib/common-errors/cams-error.ts rename to backend/lib/common-errors/cams-error.ts index b8dd9ff37..9685cd13f 100644 --- a/backend/functions/lib/common-errors/cams-error.ts +++ b/backend/lib/common-errors/cams-error.ts @@ -1,4 +1,4 @@ -import HttpStatusCodes from '../../../../common/src/api/http-status-codes'; +import HttpStatusCodes from '../../../common/src/api/http-status-codes'; export interface CamsErrorOptions { status?: number; diff --git a/backend/functions/lib/common-errors/common-errors.test.ts b/backend/lib/common-errors/common-errors.test.ts similarity index 96% rename from backend/functions/lib/common-errors/common-errors.test.ts rename to backend/lib/common-errors/common-errors.test.ts index 8e3059459..9afed4487 100644 --- a/backend/functions/lib/common-errors/common-errors.test.ts +++ b/backend/lib/common-errors/common-errors.test.ts @@ -5,7 +5,7 @@ import { NotFoundError } from './not-found-error'; import { ServerConfigError } from './server-config-error'; import { UnauthorizedError } from './unauthorized-error'; import { UnknownError } from './unknown-error'; -import HttpStatusCodes from '../../../../common/src/api/http-status-codes'; +import HttpStatusCodes from '../../../common/src/api/http-status-codes'; describe('Common errors', () => { const testModuleName = 'Test'; diff --git a/backend/functions/lib/common-errors/error-utilities.test.ts b/backend/lib/common-errors/error-utilities.test.ts similarity index 91% rename from backend/functions/lib/common-errors/error-utilities.test.ts rename to backend/lib/common-errors/error-utilities.test.ts index 03695b9f5..1b68b6972 100644 --- a/backend/functions/lib/common-errors/error-utilities.test.ts +++ b/backend/lib/common-errors/error-utilities.test.ts @@ -1,7 +1,7 @@ import { UnauthorizedError } from './unauthorized-error'; import { getCamsError } from './error-utilities'; import { isCamsError } from './cams-error'; -import HttpStatusCodes from '../../../../common/src/api/http-status-codes'; +import HttpStatusCodes from '../../../common/src/api/http-status-codes'; const MODULE_NAME = 'test-module'; describe('error utilities tests', () => { diff --git a/backend/functions/lib/common-errors/error-utilities.ts b/backend/lib/common-errors/error-utilities.ts similarity index 100% rename from backend/functions/lib/common-errors/error-utilities.ts rename to backend/lib/common-errors/error-utilities.ts diff --git a/backend/functions/lib/common-errors/forbidden-error.ts b/backend/lib/common-errors/forbidden-error.ts similarity index 85% rename from backend/functions/lib/common-errors/forbidden-error.ts rename to backend/lib/common-errors/forbidden-error.ts index 2b32e6f41..c8f3f6e91 100644 --- a/backend/functions/lib/common-errors/forbidden-error.ts +++ b/backend/lib/common-errors/forbidden-error.ts @@ -1,5 +1,5 @@ import { CamsError, CamsErrorOptions } from './cams-error'; -import HttpStatusCodes from '../../../../common/src/api/http-status-codes'; +import HttpStatusCodes from '../../../common/src/api/http-status-codes'; /* eslint-disable-next-line @typescript-eslint/no-empty-object-type */ interface ForbiddenErrorOptions extends CamsErrorOptions {} diff --git a/backend/functions/lib/common-errors/not-found-error.ts b/backend/lib/common-errors/not-found-error.ts similarity index 88% rename from backend/functions/lib/common-errors/not-found-error.ts rename to backend/lib/common-errors/not-found-error.ts index d82f53df5..8d8e6f975 100644 --- a/backend/functions/lib/common-errors/not-found-error.ts +++ b/backend/lib/common-errors/not-found-error.ts @@ -1,5 +1,5 @@ import { CamsError, CamsErrorOptions, isCamsError } from './cams-error'; -import HttpStatusCodes from '../../../../common/src/api/http-status-codes'; +import HttpStatusCodes from '../../../common/src/api/http-status-codes'; /* eslint-disable-next-line @typescript-eslint/no-empty-object-type */ interface NotFoundErrorOptions extends CamsErrorOptions {} diff --git a/backend/functions/lib/common-errors/server-config-error.ts b/backend/lib/common-errors/server-config-error.ts similarity index 86% rename from backend/functions/lib/common-errors/server-config-error.ts rename to backend/lib/common-errors/server-config-error.ts index d0de0694f..85641b335 100644 --- a/backend/functions/lib/common-errors/server-config-error.ts +++ b/backend/lib/common-errors/server-config-error.ts @@ -1,5 +1,5 @@ import { CamsError, CamsErrorOptions } from './cams-error'; -import HttpStatusCodes from '../../../../common/src/api/http-status-codes'; +import HttpStatusCodes from '../../../common/src/api/http-status-codes'; /* eslint-disable-next-line @typescript-eslint/no-empty-object-type */ export interface ServerConfigErrorOptions extends CamsErrorOptions {} diff --git a/backend/functions/lib/common-errors/unauthorized-error.ts b/backend/lib/common-errors/unauthorized-error.ts similarity index 84% rename from backend/functions/lib/common-errors/unauthorized-error.ts rename to backend/lib/common-errors/unauthorized-error.ts index 7d0c50d52..bcdb99834 100644 --- a/backend/functions/lib/common-errors/unauthorized-error.ts +++ b/backend/lib/common-errors/unauthorized-error.ts @@ -1,5 +1,5 @@ import { CamsError, CamsErrorOptions } from './cams-error'; -import HttpStatusCodes from '../../../../common/src/api/http-status-codes'; +import HttpStatusCodes from '../../../common/src/api/http-status-codes'; /* eslint-disable-next-line @typescript-eslint/no-empty-object-type */ interface UnauthorizedErrorOptions extends CamsErrorOptions {} diff --git a/backend/functions/lib/common-errors/unknown-error.ts b/backend/lib/common-errors/unknown-error.ts similarity index 85% rename from backend/functions/lib/common-errors/unknown-error.ts rename to backend/lib/common-errors/unknown-error.ts index fc5c5fd75..49d5c7a9f 100644 --- a/backend/functions/lib/common-errors/unknown-error.ts +++ b/backend/lib/common-errors/unknown-error.ts @@ -1,5 +1,5 @@ import { CamsError, CamsErrorOptions } from './cams-error'; -import HttpStatusCodes from '../../../../common/src/api/http-status-codes'; +import HttpStatusCodes from '../../../common/src/api/http-status-codes'; /* eslint-disable-next-line @typescript-eslint/no-empty-object-type */ interface UnknownErrorOptions extends CamsErrorOptions {} diff --git a/backend/functions/lib/configs/application-configuration.test.ts b/backend/lib/configs/application-configuration.test.ts similarity index 100% rename from backend/functions/lib/configs/application-configuration.test.ts rename to backend/lib/configs/application-configuration.test.ts diff --git a/backend/functions/lib/configs/application-configuration.ts b/backend/lib/configs/application-configuration.ts similarity index 100% rename from backend/functions/lib/configs/application-configuration.ts rename to backend/lib/configs/application-configuration.ts diff --git a/backend/functions/lib/configs/authorization-configuration.test.ts b/backend/lib/configs/authorization-configuration.test.ts similarity index 100% rename from backend/functions/lib/configs/authorization-configuration.test.ts rename to backend/lib/configs/authorization-configuration.test.ts diff --git a/backend/functions/lib/configs/authorization-configuration.ts b/backend/lib/configs/authorization-configuration.ts similarity index 89% rename from backend/functions/lib/configs/authorization-configuration.ts rename to backend/lib/configs/authorization-configuration.ts index 82479b985..9e1c31787 100644 --- a/backend/functions/lib/configs/authorization-configuration.ts +++ b/backend/lib/configs/authorization-configuration.ts @@ -1,7 +1,7 @@ import * as dotenv from 'dotenv'; import { AuthorizationConfig } from '../adapters/types/authorization'; -import { EnvLoginConfig } from '../../../../common/src/cams/login'; -import { keyValuesToRecord } from '../../../../common/src/cams/utilities'; +import { EnvLoginConfig } from '../../../common/src/cams/login'; +import { keyValuesToRecord } from '../../../common/src/cams/utilities'; dotenv.config(); diff --git a/backend/functions/lib/configs/user-groups-gateway-configuration.ts b/backend/lib/configs/user-groups-gateway-configuration.ts similarity index 90% rename from backend/functions/lib/configs/user-groups-gateway-configuration.ts rename to backend/lib/configs/user-groups-gateway-configuration.ts index 756ea8ecb..34b6f95df 100644 --- a/backend/functions/lib/configs/user-groups-gateway-configuration.ts +++ b/backend/lib/configs/user-groups-gateway-configuration.ts @@ -1,6 +1,6 @@ import * as dotenv from 'dotenv'; import { UserGroupGatewayConfig } from '../adapters/types/authorization'; -import { keyValuesToRecord } from '../../../../common/src/cams/utilities'; +import { keyValuesToRecord } from '../../../common/src/cams/utilities'; dotenv.config(); diff --git a/backend/functions/lib/controllers/acms-orders/acms-orders.controller.test.ts b/backend/lib/controllers/acms-orders/acms-orders.controller.test.ts similarity index 100% rename from backend/functions/lib/controllers/acms-orders/acms-orders.controller.test.ts rename to backend/lib/controllers/acms-orders/acms-orders.controller.test.ts diff --git a/backend/functions/lib/controllers/acms-orders/acms-orders.controller.ts b/backend/lib/controllers/acms-orders/acms-orders.controller.ts similarity index 100% rename from backend/functions/lib/controllers/acms-orders/acms-orders.controller.ts rename to backend/lib/controllers/acms-orders/acms-orders.controller.ts diff --git a/backend/functions/lib/controllers/attorneys/attorneys.controller.test.ts b/backend/lib/controllers/attorneys/attorneys.controller.test.ts similarity index 95% rename from backend/functions/lib/controllers/attorneys/attorneys.controller.test.ts rename to backend/lib/controllers/attorneys/attorneys.controller.test.ts index 0638c1537..e49bbaaf2 100644 --- a/backend/functions/lib/controllers/attorneys/attorneys.controller.test.ts +++ b/backend/lib/controllers/attorneys/attorneys.controller.test.ts @@ -1,4 +1,4 @@ -import MockData from '../../../../../common/src/cams/test-utilities/mock-data'; +import MockData from '../../../../common/src/cams/test-utilities/mock-data'; import { createMockApplicationContext } from '../../testing/testing-utilities'; import AttorneysList from '../../use-cases/attorneys'; import { NotFoundError } from '../../common-errors/not-found-error'; diff --git a/backend/functions/lib/controllers/attorneys/attorneys.controller.ts b/backend/lib/controllers/attorneys/attorneys.controller.ts similarity index 94% rename from backend/functions/lib/controllers/attorneys/attorneys.controller.ts rename to backend/lib/controllers/attorneys/attorneys.controller.ts index 0848b5505..f9166a78e 100644 --- a/backend/functions/lib/controllers/attorneys/attorneys.controller.ts +++ b/backend/lib/controllers/attorneys/attorneys.controller.ts @@ -1,6 +1,6 @@ import { ApplicationContext } from '../../adapters/types/basic'; import AttorneysList from '../../use-cases/attorneys'; -import { AttorneyUser } from '../../../../../common/src/cams/users'; +import { AttorneyUser } from '../../../../common/src/cams/users'; import { CamsHttpResponseInit, httpSuccess } from '../../adapters/utils/http-response'; import { getCamsError } from '../../common-errors/error-utilities'; import { CamsController } from '../controller'; diff --git a/backend/functions/lib/controllers/case-assignment/case.assignment.controller.test.ts b/backend/lib/controllers/case-assignment/case.assignment.controller.test.ts similarity index 95% rename from backend/functions/lib/controllers/case-assignment/case.assignment.controller.test.ts rename to backend/lib/controllers/case-assignment/case.assignment.controller.test.ts index d38f6c919..d7c336901 100644 --- a/backend/functions/lib/controllers/case-assignment/case.assignment.controller.test.ts +++ b/backend/lib/controllers/case-assignment/case.assignment.controller.test.ts @@ -3,7 +3,7 @@ import { THROW_PERMISSIONS_ERROR_CASE_ID, THROW_UNKNOWN_ERROR_CASE_ID, } from '../../testing/testing-constants'; -import { MockData } from '../../../../../common/src/cams/test-utilities/mock-data'; +import { MockData } from '../../../../common/src/cams/test-utilities/mock-data'; import { CaseAssignmentUseCase } from '../../use-cases/case-assignment'; import { CamsError } from '../../common-errors/cams-error'; import { ForbiddenError } from '../../common-errors/forbidden-error'; @@ -11,13 +11,13 @@ import { createMockApplicationContext, createMockApplicationContextSession, } from '../../testing/testing-utilities'; -import { CamsRole } from '../../../../../common/src/cams/roles'; -import { CamsUserReference } from '../../../../../common/src/cams/users'; +import { CamsRole } from '../../../../common/src/cams/roles'; +import { CamsUserReference } from '../../../../common/src/cams/users'; import { UnknownError } from '../../common-errors/unknown-error'; -import HttpStatusCodes from '../../../../../common/src/api/http-status-codes'; +import HttpStatusCodes from '../../../../common/src/api/http-status-codes'; import { httpSuccess } from '../../adapters/utils/http-response'; import { mockCamsHttpRequest } from '../../testing/mock-data/cams-http-request-helper'; -import { REGION_02_GROUP_NY } from '../../../../../common/src/cams/test-utilities/mock-user'; +import { REGION_02_GROUP_NY } from '../../../../common/src/cams/test-utilities/mock-user'; import { ApplicationContext } from '../../adapters/types/basic'; const Jane = MockData.getCamsUserReference({ name: 'Jane' }); diff --git a/backend/functions/lib/controllers/case-assignment/case.assignment.controller.ts b/backend/lib/controllers/case-assignment/case.assignment.controller.ts similarity index 91% rename from backend/functions/lib/controllers/case-assignment/case.assignment.controller.ts rename to backend/lib/controllers/case-assignment/case.assignment.controller.ts index e6786eb85..4b21b2292 100644 --- a/backend/functions/lib/controllers/case-assignment/case.assignment.controller.ts +++ b/backend/lib/controllers/case-assignment/case.assignment.controller.ts @@ -1,11 +1,11 @@ import { ApplicationContext } from '../../adapters/types/basic'; import { CaseAssignmentUseCase } from '../../use-cases/case-assignment'; import { AssignmentError } from '../../use-cases/assignment.exception'; -import { CaseAssignment } from '../../../../../common/src/cams/assignments'; -import { CamsUserReference } from '../../../../../common/src/cams/users'; -import { CamsRole } from '../../../../../common/src/cams/roles'; +import { CaseAssignment } from '../../../../common/src/cams/assignments'; +import { CamsUserReference } from '../../../../common/src/cams/users'; +import { CamsRole } from '../../../../common/src/cams/roles'; import { CamsHttpResponseInit, httpSuccess } from '../../adapters/utils/http-response'; -import HttpStatusCodes from '../../../../../common/src/api/http-status-codes'; +import HttpStatusCodes from '../../../../common/src/api/http-status-codes'; import { CamsController } from '../controller'; import { getCamsError } from '../../common-errors/error-utilities'; import { finalizeDeferrable } from '../../deferrable/finalize-deferrable'; diff --git a/backend/functions/lib/controllers/case-associated/case-associated.controller.test.ts b/backend/lib/controllers/case-associated/case-associated.controller.test.ts similarity index 96% rename from backend/functions/lib/controllers/case-associated/case-associated.controller.test.ts rename to backend/lib/controllers/case-associated/case-associated.controller.test.ts index 7aa89b780..e9c75280e 100644 --- a/backend/functions/lib/controllers/case-associated/case-associated.controller.test.ts +++ b/backend/lib/controllers/case-associated/case-associated.controller.test.ts @@ -7,7 +7,7 @@ import { } from '../../testing/testing-constants'; import { NotFoundError } from '../../common-errors/not-found-error'; import { CaseAssociatedUseCase } from '../../use-cases/case-associated/case-associated'; -import { MockData } from '../../../../../common/src/cams/test-utilities/mock-data'; +import { MockData } from '../../../../common/src/cams/test-utilities/mock-data'; describe('Test case-history controller', () => { let applicationContext; diff --git a/backend/functions/lib/controllers/case-associated/case-associated.controller.ts b/backend/lib/controllers/case-associated/case-associated.controller.ts similarity index 93% rename from backend/functions/lib/controllers/case-associated/case-associated.controller.ts rename to backend/lib/controllers/case-associated/case-associated.controller.ts index b9f69784d..1eb6a598f 100644 --- a/backend/functions/lib/controllers/case-associated/case-associated.controller.ts +++ b/backend/lib/controllers/case-associated/case-associated.controller.ts @@ -1,7 +1,7 @@ import { ApplicationContext } from '../../adapters/types/basic'; import { isCamsError } from '../../common-errors/cams-error'; import { UnknownError } from '../../common-errors/unknown-error'; -import { EventCaseReference } from '../../../../../common/src/cams/events'; +import { EventCaseReference } from '../../../../common/src/cams/events'; import { CaseAssociatedUseCase } from '../../use-cases/case-associated/case-associated'; import { CamsHttpResponseInit, httpSuccess } from '../../adapters/utils/http-response'; import { finalizeDeferrable } from '../../deferrable/finalize-deferrable'; diff --git a/backend/functions/lib/controllers/case-docket/case-docket.controller.test.ts b/backend/lib/controllers/case-docket/case-docket.controller.test.ts similarity index 100% rename from backend/functions/lib/controllers/case-docket/case-docket.controller.test.ts rename to backend/lib/controllers/case-docket/case-docket.controller.test.ts diff --git a/backend/functions/lib/controllers/case-docket/case-docket.controller.ts b/backend/lib/controllers/case-docket/case-docket.controller.ts similarity index 95% rename from backend/functions/lib/controllers/case-docket/case-docket.controller.ts rename to backend/lib/controllers/case-docket/case-docket.controller.ts index 68bd9f1ab..5b82875f4 100644 --- a/backend/functions/lib/controllers/case-docket/case-docket.controller.ts +++ b/backend/lib/controllers/case-docket/case-docket.controller.ts @@ -4,7 +4,7 @@ import { getCaseDocketUseCase } from '../../factory'; import { isCamsError } from '../../common-errors/cams-error'; import { UnknownError } from '../../common-errors/unknown-error'; import { CamsHttpResponseInit, httpSuccess } from '../../adapters/utils/http-response'; -import { CaseDocket } from '../../../../../common/src/cams/cases'; +import { CaseDocket } from '../../../../common/src/cams/cases'; import { CamsController } from '../controller'; import { finalizeDeferrable } from '../../deferrable/finalize-deferrable'; diff --git a/backend/functions/lib/controllers/case-history/case-history.controller.test.ts b/backend/lib/controllers/case-history/case-history.controller.test.ts similarity index 100% rename from backend/functions/lib/controllers/case-history/case-history.controller.test.ts rename to backend/lib/controllers/case-history/case-history.controller.test.ts diff --git a/backend/functions/lib/controllers/case-history/case-history.controller.ts b/backend/lib/controllers/case-history/case-history.controller.ts similarity index 94% rename from backend/functions/lib/controllers/case-history/case-history.controller.ts rename to backend/lib/controllers/case-history/case-history.controller.ts index dcef99465..0b30f9791 100644 --- a/backend/functions/lib/controllers/case-history/case-history.controller.ts +++ b/backend/lib/controllers/case-history/case-history.controller.ts @@ -1,6 +1,6 @@ import { ApplicationContext } from '../../adapters/types/basic'; import { CaseHistoryUseCase } from '../../use-cases/case-history/case-history'; -import { CaseHistory } from '../../../../../common/src/cams/history'; +import { CaseHistory } from '../../../../common/src/cams/history'; import { CamsHttpResponseInit, httpSuccess } from '../../adapters/utils/http-response'; import { getCamsError } from '../../common-errors/error-utilities'; import { CamsController } from '../controller'; diff --git a/backend/functions/lib/controllers/case-summary/case-summary.controller.test.ts b/backend/lib/controllers/case-summary/case-summary.controller.test.ts similarity index 95% rename from backend/functions/lib/controllers/case-summary/case-summary.controller.test.ts rename to backend/lib/controllers/case-summary/case-summary.controller.test.ts index c7f1a3815..60245d9ba 100644 --- a/backend/functions/lib/controllers/case-summary/case-summary.controller.test.ts +++ b/backend/lib/controllers/case-summary/case-summary.controller.test.ts @@ -1,7 +1,7 @@ import { createMockApplicationContext } from '../../testing/testing-utilities'; import CaseManagement from '../../use-cases/case-management'; import { NotFoundError } from '../../common-errors/not-found-error'; -import { MockData } from '../../../../../common/src/cams/test-utilities/mock-data'; +import { MockData } from '../../../../common/src/cams/test-utilities/mock-data'; import { CaseSummaryController } from './case-summary.controller'; describe('Test case-summary controller', () => { diff --git a/backend/functions/lib/controllers/case-summary/case-summary.controller.ts b/backend/lib/controllers/case-summary/case-summary.controller.ts similarity index 94% rename from backend/functions/lib/controllers/case-summary/case-summary.controller.ts rename to backend/lib/controllers/case-summary/case-summary.controller.ts index 6aaa42e26..b7ec5e17a 100644 --- a/backend/functions/lib/controllers/case-summary/case-summary.controller.ts +++ b/backend/lib/controllers/case-summary/case-summary.controller.ts @@ -1,5 +1,5 @@ import { ApplicationContext } from '../../adapters/types/basic'; -import { CaseSummary } from '../../../../../common/src/cams/cases'; +import { CaseSummary } from '../../../../common/src/cams/cases'; import CaseManagement from '../../use-cases/case-management'; import { CamsHttpResponseInit, httpSuccess } from '../../adapters/utils/http-response'; import { getCamsError } from '../../common-errors/error-utilities'; diff --git a/backend/functions/lib/controllers/cases/cases.controller.test.ts b/backend/lib/controllers/cases/cases.controller.test.ts similarity index 98% rename from backend/functions/lib/controllers/cases/cases.controller.test.ts rename to backend/lib/controllers/cases/cases.controller.test.ts index edef2a3ee..861db7df9 100644 --- a/backend/functions/lib/controllers/cases/cases.controller.test.ts +++ b/backend/lib/controllers/cases/cases.controller.test.ts @@ -1,15 +1,15 @@ -import { MockData } from '../../../../../common/src/cams/test-utilities/mock-data'; +import { MockData } from '../../../../common/src/cams/test-utilities/mock-data'; import { ApplicationContext } from '../../adapters/types/basic'; import { CamsHttpResponseInit } from '../../adapters/utils/http-response'; import CaseManagement from '../../use-cases/case-management'; import { CasesController } from './cases.controller'; -import { CaseBasics, CaseDetail } from '../../../../../common/src/cams/cases'; +import { CaseBasics, CaseDetail } from '../../../../common/src/cams/cases'; import { mockCamsHttpRequest, mockRequestUrl, } from '../../testing/mock-data/cams-http-request-helper'; import { createMockApplicationContext } from '../../testing/testing-utilities'; -import { ResourceActions } from '../../../../../common/src/cams/actions'; +import { ResourceActions } from '../../../../common/src/cams/actions'; import { CamsError } from '../../common-errors/cams-error'; describe('cases controller test', () => { diff --git a/backend/functions/lib/controllers/cases/cases.controller.ts b/backend/lib/controllers/cases/cases.controller.ts similarity index 90% rename from backend/functions/lib/controllers/cases/cases.controller.ts rename to backend/lib/controllers/cases/cases.controller.ts index 0fc46b73b..65682d2d5 100644 --- a/backend/functions/lib/controllers/cases/cases.controller.ts +++ b/backend/lib/controllers/cases/cases.controller.ts @@ -1,12 +1,12 @@ import { ApplicationContext } from '../../adapters/types/basic'; import CaseManagement from '../../use-cases/case-management'; -import { ResponseBody } from '../../../../../common/src/api/response'; -import { CaseBasics, CaseDetail } from '../../../../../common/src/cams/cases'; -import { CasesSearchPredicate } from '../../../../../common/src/api/search'; +import { ResponseBody } from '../../../../common/src/api/response'; +import { CaseBasics, CaseDetail } from '../../../../common/src/cams/cases'; +import { CasesSearchPredicate } from '../../../../common/src/api/search'; import { CamsHttpRequest } from '../../adapters/types/http'; -import { Pagination } from '../../../../../common/src/api/pagination'; +import { Pagination } from '../../../../common/src/api/pagination'; import { httpSuccess } from '../../adapters/utils/http-response'; -import { ResourceActions } from '../../../../../common/src/cams/actions'; +import { ResourceActions } from '../../../../common/src/cams/actions'; import { CamsController } from '../controller'; import { getCamsError } from '../../common-errors/error-utilities'; import { finalizeDeferrable } from '../../deferrable/finalize-deferrable'; diff --git a/backend/functions/lib/controllers/controller.ts b/backend/lib/controllers/controller.ts similarity index 100% rename from backend/functions/lib/controllers/controller.ts rename to backend/lib/controllers/controller.ts diff --git a/backend/functions/lib/controllers/courts/courts.controller.test.ts b/backend/lib/controllers/courts/courts.controller.test.ts similarity index 96% rename from backend/functions/lib/controllers/courts/courts.controller.test.ts rename to backend/lib/controllers/courts/courts.controller.test.ts index 6f25ab025..150980508 100644 --- a/backend/functions/lib/controllers/courts/courts.controller.test.ts +++ b/backend/lib/controllers/courts/courts.controller.test.ts @@ -1,6 +1,6 @@ import { createMockApplicationContext } from '../../testing/testing-utilities'; import { ApplicationContext } from '../../adapters/types/basic'; -import { COURT_DIVISIONS } from '../../../../../common/src/cams/test-utilities/courts.mock'; +import { COURT_DIVISIONS } from '../../../../common/src/cams/test-utilities/courts.mock'; import { CamsError } from '../../common-errors/cams-error'; import { mockCamsHttpRequest } from '../../testing/mock-data/cams-http-request-helper'; import { CourtsController } from './courts.controller'; diff --git a/backend/functions/lib/controllers/courts/courts.controller.ts b/backend/lib/controllers/courts/courts.controller.ts similarity index 93% rename from backend/functions/lib/controllers/courts/courts.controller.ts rename to backend/lib/controllers/courts/courts.controller.ts index 98bee2796..d36af65c4 100644 --- a/backend/functions/lib/controllers/courts/courts.controller.ts +++ b/backend/lib/controllers/courts/courts.controller.ts @@ -3,7 +3,7 @@ import { CamsHttpResponseInit, httpSuccess } from '../../adapters/utils/http-res import { getCamsError } from '../../common-errors/error-utilities'; import { CamsController } from '../controller'; import { CourtsUseCase } from '../../use-cases/courts/courts'; -import { CourtDivisionDetails } from '../../../../../common/src/cams/courts'; +import { CourtDivisionDetails } from '../../../../common/src/cams/courts'; import { finalizeDeferrable } from '../../deferrable/finalize-deferrable'; const MODULE_NAME = 'COURTS-CONTROLLER'; diff --git a/backend/functions/lib/controllers/me/me.controller.ts b/backend/lib/controllers/me/me.controller.ts similarity index 92% rename from backend/functions/lib/controllers/me/me.controller.ts rename to backend/lib/controllers/me/me.controller.ts index f03976155..e50ad2547 100644 --- a/backend/functions/lib/controllers/me/me.controller.ts +++ b/backend/lib/controllers/me/me.controller.ts @@ -1,4 +1,4 @@ -import { CamsSession } from '../../../../../common/src/cams/session'; +import { CamsSession } from '../../../../common/src/cams/session'; import { ApplicationContext } from '../../adapters/types/basic'; import { CamsHttpResponseInit, httpSuccess } from '../../adapters/utils/http-response'; import { getCamsError } from '../../common-errors/error-utilities'; diff --git a/backend/functions/lib/controllers/offices/offices.controller.test.ts b/backend/lib/controllers/offices/offices.controller.test.ts similarity index 98% rename from backend/functions/lib/controllers/offices/offices.controller.test.ts rename to backend/lib/controllers/offices/offices.controller.test.ts index 25f75b77a..089b6a71b 100644 --- a/backend/functions/lib/controllers/offices/offices.controller.test.ts +++ b/backend/lib/controllers/offices/offices.controller.test.ts @@ -1,7 +1,7 @@ import { createMockApplicationContext } from '../../testing/testing-utilities'; import { ApplicationContext } from '../../adapters/types/basic'; import { OfficesController } from './offices.controller'; -import { COURT_DIVISIONS } from '../../../../../common/src/cams/test-utilities/courts.mock'; +import { COURT_DIVISIONS } from '../../../../common/src/cams/test-utilities/courts.mock'; import { CamsError } from '../../common-errors/cams-error'; import { mockCamsHttpRequest } from '../../testing/mock-data/cams-http-request-helper'; import { UnknownError } from '../../common-errors/unknown-error'; diff --git a/backend/functions/lib/controllers/offices/offices.controller.ts b/backend/lib/controllers/offices/offices.controller.ts similarity index 92% rename from backend/functions/lib/controllers/offices/offices.controller.ts rename to backend/lib/controllers/offices/offices.controller.ts index b151ea0c2..bfbf95dc1 100644 --- a/backend/functions/lib/controllers/offices/offices.controller.ts +++ b/backend/lib/controllers/offices/offices.controller.ts @@ -1,10 +1,10 @@ import { OfficesUseCase } from '../../use-cases/offices/offices'; import { ApplicationContext } from '../../adapters/types/basic'; -import { UstpOfficeDetails } from '../../../../../common/src/cams/offices'; +import { UstpOfficeDetails } from '../../../../common/src/cams/offices'; import { CamsHttpResponseInit, httpSuccess } from '../../adapters/utils/http-response'; import { getCamsError } from '../../common-errors/error-utilities'; import { CamsController, CamsTimerController } from '../controller'; -import { CamsUserReference } from '../../../../../common/src/cams/users'; +import { CamsUserReference } from '../../../../common/src/cams/users'; import { BadRequestError } from '../../common-errors/bad-request'; import { finalizeDeferrable } from '../../deferrable/finalize-deferrable'; diff --git a/backend/functions/lib/controllers/orders/orders.controller.test.ts b/backend/lib/controllers/orders/orders.controller.test.ts similarity index 97% rename from backend/functions/lib/controllers/orders/orders.controller.test.ts rename to backend/lib/controllers/orders/orders.controller.test.ts index 875b54e4c..fe72cfefc 100644 --- a/backend/functions/lib/controllers/orders/orders.controller.test.ts +++ b/backend/lib/controllers/orders/orders.controller.test.ts @@ -11,14 +11,14 @@ import { Order, TransferOrder, TransferOrderAction, -} from '../../../../../common/src/cams/orders'; -import { MockData } from '../../../../../common/src/cams/test-utilities/mock-data'; -import { sortDates } from '../../../../../common/src/date-helper'; +} from '../../../../common/src/cams/orders'; +import { MockData } from '../../../../common/src/cams/test-utilities/mock-data'; +import { sortDates } from '../../../../common/src/date-helper'; import { OrdersController } from './orders.controller'; import { CamsHttpResponseInit, commonHeaders } from '../../adapters/utils/http-response'; -import HttpStatusCodes from '../../../../../common/src/api/http-status-codes'; +import HttpStatusCodes from '../../../../common/src/api/http-status-codes'; import { mockCamsHttpRequest } from '../../testing/mock-data/cams-http-request-helper'; -import { ResponseBody } from '../../../../../common/src/api/response'; +import { ResponseBody } from '../../../../common/src/api/response'; import { NotFoundError } from '../../common-errors/not-found-error'; import { BadRequestError } from '../../common-errors/bad-request'; import * as crypto from 'crypto'; diff --git a/backend/functions/lib/controllers/orders/orders.controller.ts b/backend/lib/controllers/orders/orders.controller.ts similarity index 97% rename from backend/functions/lib/controllers/orders/orders.controller.ts rename to backend/lib/controllers/orders/orders.controller.ts index e2a933919..aaa0b3717 100644 --- a/backend/functions/lib/controllers/orders/orders.controller.ts +++ b/backend/lib/controllers/orders/orders.controller.ts @@ -8,12 +8,12 @@ import { isConsolidationOrderRejection, Order, TransferOrderAction, -} from '../../../../../common/src/cams/orders'; -import { CaseSummary } from '../../../../../common/src/cams/cases'; +} from '../../../../common/src/cams/orders'; +import { CaseSummary } from '../../../../common/src/cams/cases'; import { BadRequestError } from '../../common-errors/bad-request'; import { CamsHttpResponseInit, httpSuccess } from '../../adapters/utils/http-response'; import { getCamsError } from '../../common-errors/error-utilities'; -import HttpStatusCodes from '../../../../../common/src/api/http-status-codes'; +import HttpStatusCodes from '../../../../common/src/api/http-status-codes'; import { CamsController, CamsTimerController } from '../controller'; import { NotFoundError } from '../../common-errors/not-found-error'; import { finalizeDeferrable } from '../../deferrable/finalize-deferrable'; diff --git a/backend/functions/lib/deferrable/defer-close.test.ts b/backend/lib/deferrable/defer-close.test.ts similarity index 100% rename from backend/functions/lib/deferrable/defer-close.test.ts rename to backend/lib/deferrable/defer-close.test.ts diff --git a/backend/functions/lib/deferrable/defer-close.ts b/backend/lib/deferrable/defer-close.ts similarity index 100% rename from backend/functions/lib/deferrable/defer-close.ts rename to backend/lib/deferrable/defer-close.ts diff --git a/backend/functions/lib/deferrable/defer-release.test.ts b/backend/lib/deferrable/defer-release.test.ts similarity index 100% rename from backend/functions/lib/deferrable/defer-release.test.ts rename to backend/lib/deferrable/defer-release.test.ts diff --git a/backend/functions/lib/deferrable/defer-release.ts b/backend/lib/deferrable/defer-release.ts similarity index 100% rename from backend/functions/lib/deferrable/defer-release.ts rename to backend/lib/deferrable/defer-release.ts diff --git a/backend/functions/lib/deferrable/finalize-deferrable.test.ts b/backend/lib/deferrable/finalize-deferrable.test.ts similarity index 100% rename from backend/functions/lib/deferrable/finalize-deferrable.test.ts rename to backend/lib/deferrable/finalize-deferrable.test.ts diff --git a/backend/functions/lib/deferrable/finalize-deferrable.ts b/backend/lib/deferrable/finalize-deferrable.ts similarity index 100% rename from backend/functions/lib/deferrable/finalize-deferrable.ts rename to backend/lib/deferrable/finalize-deferrable.ts diff --git a/backend/functions/lib/factory.test.ts b/backend/lib/factory.test.ts similarity index 99% rename from backend/functions/lib/factory.test.ts rename to backend/lib/factory.test.ts index 265166247..b9c53e2d1 100644 --- a/backend/functions/lib/factory.test.ts +++ b/backend/lib/factory.test.ts @@ -1,7 +1,7 @@ import { ApplicationContext } from './adapters/types/basic'; import { createMockApplicationContext } from './testing/testing-utilities'; -describe('Factory functions', () => { +describe('Factory function-apps', () => { let dbContext: ApplicationContext; let mockDbContext: ApplicationContext; let factory; diff --git a/backend/functions/lib/factory.ts b/backend/lib/factory.ts similarity index 100% rename from backend/functions/lib/factory.ts rename to backend/lib/factory.ts diff --git a/backend/functions/lib/humble-objects/mongo-humble.ts b/backend/lib/humble-objects/mongo-humble.ts similarity index 100% rename from backend/functions/lib/humble-objects/mongo-humble.ts rename to backend/lib/humble-objects/mongo-humble.ts diff --git a/backend/functions/lib/query/query-builder.test.ts b/backend/lib/query/query-builder.test.ts similarity index 100% rename from backend/functions/lib/query/query-builder.test.ts rename to backend/lib/query/query-builder.test.ts diff --git a/backend/functions/lib/query/query-builder.ts b/backend/lib/query/query-builder.ts similarity index 100% rename from backend/functions/lib/query/query-builder.ts rename to backend/lib/query/query-builder.ts diff --git a/backend/functions/lib/testing/analysis/acms-dxtr-divisions/compare-divisions.ts b/backend/lib/testing/analysis/acms-dxtr-divisions/compare-divisions.ts similarity index 98% rename from backend/functions/lib/testing/analysis/acms-dxtr-divisions/compare-divisions.ts rename to backend/lib/testing/analysis/acms-dxtr-divisions/compare-divisions.ts index 8f9fe2bcd..cb14e312f 100644 --- a/backend/functions/lib/testing/analysis/acms-dxtr-divisions/compare-divisions.ts +++ b/backend/lib/testing/analysis/acms-dxtr-divisions/compare-divisions.ts @@ -1,8 +1,8 @@ import { InvocationContext } from '@azure/functions'; -import applicationContextCreator from '../../../../azure/application-context-creator'; +import applicationContextCreator from '../../../../function-apps/azure/application-context-creator'; import { LoggerImpl } from '../../../adapters/services/logger.service'; import OfficesDxtrGateway from '../../../adapters/gateways/dxtr/offices.dxtr.gateway'; -import { UstpOfficeDetails } from '../../../../../../common/src/cams/offices'; +import { UstpOfficeDetails } from '../../../../../common/src/cams/offices'; import * as fs from 'fs/promises'; // Sourced from Office_Regions_and_Divisions.pdf @@ -433,7 +433,7 @@ async function main() { ); // Write the results to the temp directory. - // See: backend/functions/temp/ + // See: backend/function-apps/temp/ await outputResults(output); } diff --git a/backend/functions/lib/testing/analysis/export-office-csv.ts b/backend/lib/testing/analysis/export-office-csv.ts similarity index 91% rename from backend/functions/lib/testing/analysis/export-office-csv.ts rename to backend/lib/testing/analysis/export-office-csv.ts index 4675fe8ed..b89ca92b5 100644 --- a/backend/functions/lib/testing/analysis/export-office-csv.ts +++ b/backend/lib/testing/analysis/export-office-csv.ts @@ -1,8 +1,8 @@ import { InvocationContext } from '@azure/functions'; -import applicationContextCreator from '../../../azure/application-context-creator'; +import applicationContextCreator from '../../../function-apps/azure/application-context-creator'; import { LoggerImpl } from '../../adapters/services/logger.service'; import OfficesDxtrGateway from '../../adapters/gateways/dxtr/offices.dxtr.gateway'; -import { UstpOfficeDetails } from '../../../../../common/src/cams/offices'; +import { UstpOfficeDetails } from '../../../../common/src/cams/offices'; import * as fs from 'fs/promises'; const MODULE_NAME = 'ITEST'; diff --git a/backend/functions/lib/testing/isolated-integration/test-acms-migration.ts b/backend/lib/testing/isolated-integration/test-acms-migration.ts similarity index 76% rename from backend/functions/lib/testing/isolated-integration/test-acms-migration.ts rename to backend/lib/testing/isolated-integration/test-acms-migration.ts index c8e1b17e5..6899421e9 100644 --- a/backend/functions/lib/testing/isolated-integration/test-acms-migration.ts +++ b/backend/lib/testing/isolated-integration/test-acms-migration.ts @@ -1,5 +1,5 @@ -import migrateConsolidation from '../../../migration/activity/migrateConsolidation'; -import { createMockAzureFunctionContext } from '../../../azure/testing-helpers'; +import migrateConsolidation from '../../../function-apps/migration/activity/migrateConsolidation'; +import { createMockAzureFunctionContext } from '../../../function-apps/azure/testing-helpers'; import * as dotenv from 'dotenv'; dotenv.config(); diff --git a/backend/functions/lib/testing/isolated-integration/test-okta-group-api.ts b/backend/lib/testing/isolated-integration/test-okta-group-api.ts similarity index 95% rename from backend/functions/lib/testing/isolated-integration/test-okta-group-api.ts rename to backend/lib/testing/isolated-integration/test-okta-group-api.ts index 1bd03c93c..2b4edab63 100644 --- a/backend/functions/lib/testing/isolated-integration/test-okta-group-api.ts +++ b/backend/lib/testing/isolated-integration/test-okta-group-api.ts @@ -1,6 +1,6 @@ import { InvocationContext } from '@azure/functions'; import { LoggerImpl } from '../../adapters/services/logger.service'; -import applicationContextCreator from '../../../azure/application-context-creator'; +import applicationContextCreator from '../../../function-apps/azure/application-context-creator'; import { UserGroupGatewayConfig } from '../../adapters/types/authorization'; import { getUserGroupGatewayConfig } from '../../configs/user-groups-gateway-configuration'; import OktaUserGroupGateway from '../../adapters/gateways/okta/okta-user-group-gateway'; diff --git a/backend/functions/lib/testing/local-data/local-cases-repository.ts b/backend/lib/testing/local-data/local-cases-repository.ts similarity index 94% rename from backend/functions/lib/testing/local-data/local-cases-repository.ts rename to backend/lib/testing/local-data/local-cases-repository.ts index eb25b823b..6bd05e260 100644 --- a/backend/functions/lib/testing/local-data/local-cases-repository.ts +++ b/backend/lib/testing/local-data/local-cases-repository.ts @@ -6,8 +6,8 @@ import { Transfer, TransferFrom, TransferTo, -} from '../../../../../common/src/cams/events'; -import { CaseHistory } from '../../../../../common/src/cams/history'; +} from '../../../../common/src/cams/events'; +import { CaseHistory } from '../../../../common/src/cams/history'; import { CasesRepository } from '../../use-cases/gateways.types'; export class LocalCasesRepository implements CasesRepository { diff --git a/backend/functions/lib/testing/local-data/local-consolidation-orders-repository.ts b/backend/lib/testing/local-data/local-consolidation-orders-repository.ts similarity index 88% rename from backend/functions/lib/testing/local-data/local-consolidation-orders-repository.ts rename to backend/lib/testing/local-data/local-consolidation-orders-repository.ts index 5dd2f58c1..8135e68f3 100644 --- a/backend/functions/lib/testing/local-data/local-consolidation-orders-repository.ts +++ b/backend/lib/testing/local-data/local-consolidation-orders-repository.ts @@ -1,6 +1,6 @@ -import { ConsolidationOrder } from '../../../../../common/src/cams/orders'; +import { ConsolidationOrder } from '../../../../common/src/cams/orders'; import { ConsolidationOrdersRepository } from '../../use-cases/gateways.types'; -import { OrdersSearchPredicate } from '../../../../../common/src/api/search'; +import { OrdersSearchPredicate } from '../../../../common/src/api/search'; import * as crypto from 'crypto'; import { ApplicationContext } from '../../adapters/types/basic'; diff --git a/backend/lib/testing/mock-data/attorneys.mock.ts b/backend/lib/testing/mock-data/attorneys.mock.ts new file mode 100644 index 000000000..98ee01717 --- /dev/null +++ b/backend/lib/testing/mock-data/attorneys.mock.ts @@ -0,0 +1,7 @@ +import { TRIAL_ATTORNEYS } from '../../../../common/src/cams/test-utilities/attorneys.mock'; + +const list = { + attorneyList: TRIAL_ATTORNEYS, +}; + +export { list }; diff --git a/backend/functions/lib/testing/mock-data/cams-http-request-helper.ts b/backend/lib/testing/mock-data/cams-http-request-helper.ts similarity index 84% rename from backend/functions/lib/testing/mock-data/cams-http-request-helper.ts rename to backend/lib/testing/mock-data/cams-http-request-helper.ts index 4bfd6196e..bb37e17f6 100644 --- a/backend/functions/lib/testing/mock-data/cams-http-request-helper.ts +++ b/backend/lib/testing/mock-data/cams-http-request-helper.ts @@ -1,4 +1,4 @@ -import { MockData } from '../../../../../common/src/cams/test-utilities/mock-data'; +import { MockData } from '../../../../common/src/cams/test-utilities/mock-data'; import { CamsHttpRequest } from '../../adapters/types/http'; export const mockRequestUrl = 'http://mockhost/api'; diff --git a/backend/functions/lib/testing/mock-data/case-docket-entries.mock.ts b/backend/lib/testing/mock-data/case-docket-entries.mock.ts similarity index 99% rename from backend/functions/lib/testing/mock-data/case-docket-entries.mock.ts rename to backend/lib/testing/mock-data/case-docket-entries.mock.ts index b469deb4b..18174fbf5 100644 --- a/backend/functions/lib/testing/mock-data/case-docket-entries.mock.ts +++ b/backend/lib/testing/mock-data/case-docket-entries.mock.ts @@ -1,4 +1,4 @@ -import { CaseDocket, CaseDocketEntryDocument } from '../../../../../common/src/cams/cases'; +import { CaseDocket, CaseDocketEntryDocument } from '../../../../common/src/cams/cases'; import { DxtrCaseDocketEntryDocument } from '../../adapters/gateways/dxtr/case-docket.dxtr.gateway'; export const DXTR_CASE_DOCKET_ENTRIES: CaseDocket = [ diff --git a/backend/functions/lib/testing/mock-data/case-history.mock.ts b/backend/lib/testing/mock-data/case-history.mock.ts similarity index 94% rename from backend/functions/lib/testing/mock-data/case-history.mock.ts rename to backend/lib/testing/mock-data/case-history.mock.ts index 98d451711..b201c044a 100644 --- a/backend/functions/lib/testing/mock-data/case-history.mock.ts +++ b/backend/lib/testing/mock-data/case-history.mock.ts @@ -1,6 +1,6 @@ -import { SYSTEM_USER_REFERENCE } from '../../../../../common/src/cams/auditable'; -import { CaseAssignmentHistory } from '../../../../../common/src/cams/history'; -import MockData from '../../../../../common/src/cams/test-utilities/mock-data'; +import { SYSTEM_USER_REFERENCE } from '../../../../common/src/cams/auditable'; +import { CaseAssignmentHistory } from '../../../../common/src/cams/history'; +import MockData from '../../../../common/src/cams/test-utilities/mock-data'; export const CASE_HISTORY: CaseAssignmentHistory[] = [ { diff --git a/backend/functions/lib/testing/mock-data/case-summaries.mock.ts b/backend/lib/testing/mock-data/case-summaries.mock.ts similarity index 91% rename from backend/functions/lib/testing/mock-data/case-summaries.mock.ts rename to backend/lib/testing/mock-data/case-summaries.mock.ts index bf13d3b49..6f4ff0bf6 100644 --- a/backend/functions/lib/testing/mock-data/case-summaries.mock.ts +++ b/backend/lib/testing/mock-data/case-summaries.mock.ts @@ -1,4 +1,4 @@ -import { CaseSummary } from '../../../../../common/src/cams/cases'; +import { CaseSummary } from '../../../../common/src/cams/cases'; export const CASE_SUMMARIES: CaseSummary[] = [ { diff --git a/backend/functions/lib/testing/mock-data/cases.mock.json b/backend/lib/testing/mock-data/cases.mock.json similarity index 100% rename from backend/functions/lib/testing/mock-data/cases.mock.json rename to backend/lib/testing/mock-data/cases.mock.json diff --git a/backend/functions/lib/testing/mock-data/debtor-attorneys.mock.ts b/backend/lib/testing/mock-data/debtor-attorneys.mock.ts similarity index 97% rename from backend/functions/lib/testing/mock-data/debtor-attorneys.mock.ts rename to backend/lib/testing/mock-data/debtor-attorneys.mock.ts index 37529b668..64300d057 100644 --- a/backend/functions/lib/testing/mock-data/debtor-attorneys.mock.ts +++ b/backend/lib/testing/mock-data/debtor-attorneys.mock.ts @@ -1,4 +1,4 @@ -import { DebtorAttorney } from '../../../../../common/src/cams/parties'; +import { DebtorAttorney } from '../../../../common/src/cams/parties'; export const DEBTOR_ATTORNEYS = new Map([ [ diff --git a/backend/functions/lib/testing/mock-data/debtors.mock.ts b/backend/lib/testing/mock-data/debtors.mock.ts similarity index 97% rename from backend/functions/lib/testing/mock-data/debtors.mock.ts rename to backend/lib/testing/mock-data/debtors.mock.ts index 1afeeb828..f56303c0e 100644 --- a/backend/functions/lib/testing/mock-data/debtors.mock.ts +++ b/backend/lib/testing/mock-data/debtors.mock.ts @@ -1,4 +1,4 @@ -import { Party } from '../../../../../common/src/cams/parties'; +import { Party } from '../../../../common/src/cams/parties'; export const DEBTORS = new Map([ [ diff --git a/backend/functions/lib/testing/mock-data/generic-test-data.mock.ts b/backend/lib/testing/mock-data/generic-test-data.mock.ts similarity index 100% rename from backend/functions/lib/testing/mock-data/generic-test-data.mock.ts rename to backend/lib/testing/mock-data/generic-test-data.mock.ts diff --git a/backend/functions/lib/testing/mock-data/index.ts b/backend/lib/testing/mock-data/index.ts similarity index 100% rename from backend/functions/lib/testing/mock-data/index.ts rename to backend/lib/testing/mock-data/index.ts diff --git a/backend/functions/lib/testing/mock-fetch.ts b/backend/lib/testing/mock-fetch.ts similarity index 100% rename from backend/functions/lib/testing/mock-fetch.ts rename to backend/lib/testing/mock-fetch.ts diff --git a/backend/functions/lib/testing/mock-gateways/mock-attorneys.gateway.ts b/backend/lib/testing/mock-gateways/mock-attorneys.gateway.ts similarity index 81% rename from backend/functions/lib/testing/mock-gateways/mock-attorneys.gateway.ts rename to backend/lib/testing/mock-gateways/mock-attorneys.gateway.ts index 41021efad..69ff425af 100644 --- a/backend/functions/lib/testing/mock-gateways/mock-attorneys.gateway.ts +++ b/backend/lib/testing/mock-gateways/mock-attorneys.gateway.ts @@ -1,5 +1,5 @@ -import { TRIAL_ATTORNEYS } from '../../../../../common/src/cams/test-utilities/attorneys.mock'; -import { AttorneyUser } from '../../../../../common/src/cams/users'; +import { TRIAL_ATTORNEYS } from '../../../../common/src/cams/test-utilities/attorneys.mock'; +import { AttorneyUser } from '../../../../common/src/cams/users'; import { ApplicationContext } from '../../adapters/types/basic'; import { AttorneyGatewayInterface } from '../../use-cases/attorney.gateway.interface'; diff --git a/backend/functions/lib/testing/mock-gateways/mock-mongo.repository.ts b/backend/lib/testing/mock-gateways/mock-mongo.repository.ts similarity index 96% rename from backend/functions/lib/testing/mock-gateways/mock-mongo.repository.ts rename to backend/lib/testing/mock-gateways/mock-mongo.repository.ts index 8e01c99ce..556c1fb57 100644 --- a/backend/functions/lib/testing/mock-gateways/mock-mongo.repository.ts +++ b/backend/lib/testing/mock-gateways/mock-mongo.repository.ts @@ -4,8 +4,8 @@ import { TransferTo, ConsolidationTo, ConsolidationFrom, -} from '../../../../../common/src/cams/events'; -import { CaseHistory } from '../../../../../common/src/cams/history'; +} from '../../../../common/src/cams/events'; +import { CaseHistory } from '../../../../common/src/cams/history'; import { ApplicationContext } from '../../adapters/types/basic'; import { CaseAssignmentRepository, diff --git a/backend/functions/lib/testing/mock-gateways/mock-oauth2-gateway.ts b/backend/lib/testing/mock-gateways/mock-oauth2-gateway.ts similarity index 86% rename from backend/functions/lib/testing/mock-gateways/mock-oauth2-gateway.ts rename to backend/lib/testing/mock-gateways/mock-oauth2-gateway.ts index 5386e4158..2d464504c 100644 --- a/backend/functions/lib/testing/mock-gateways/mock-oauth2-gateway.ts +++ b/backend/lib/testing/mock-gateways/mock-oauth2-gateway.ts @@ -1,12 +1,12 @@ import * as jwt from 'jsonwebtoken'; import { ApplicationContext } from '../../adapters/types/basic'; import { ForbiddenError } from '../../common-errors/forbidden-error'; -import { MockUser, MockUsers } from '../../../../../common/src/cams/test-utilities/mock-user'; -import { CamsUser } from '../../../../../common/src/cams/users'; -import { CamsRole } from '../../../../../common/src/cams/roles'; -import { CamsJwt, CamsJwtClaims, CamsJwtHeader } from '../../../../../common/src/cams/jwt'; +import { MockUser, MockUsers } from '../../../../common/src/cams/test-utilities/mock-user'; +import { CamsUser } from '../../../../common/src/cams/users'; +import { CamsRole } from '../../../../common/src/cams/roles'; +import { CamsJwt, CamsJwtClaims, CamsJwtHeader } from '../../../../common/src/cams/jwt'; import { OpenIdConnectGateway } from '../../adapters/types/authorization'; -import { USTP_OFFICES_ARRAY } from '../../../../../common/src/cams/offices'; +import { USTP_OFFICES_ARRAY } from '../../../../common/src/cams/offices'; const MODULE_NAME = 'MOCK_OAUTH2_GATEWAY'; const mockUsers: MockUser[] = MockUsers; diff --git a/backend/functions/lib/testing/mock-gateways/mock-user-session-use-case.ts b/backend/lib/testing/mock-gateways/mock-user-session-use-case.ts similarity index 78% rename from backend/functions/lib/testing/mock-gateways/mock-user-session-use-case.ts rename to backend/lib/testing/mock-gateways/mock-user-session-use-case.ts index 056db8f41..a40198bb0 100644 --- a/backend/functions/lib/testing/mock-gateways/mock-user-session-use-case.ts +++ b/backend/lib/testing/mock-gateways/mock-user-session-use-case.ts @@ -1,10 +1,10 @@ import * as jwt from 'jsonwebtoken'; import { ApplicationContext } from '../../adapters/types/basic'; import { getUser } from './mock-oauth2-gateway'; -import { CamsSession } from '../../../../../common/src/cams/session'; -import { CamsRole } from '../../../../../common/src/cams/roles'; -import { CamsJwtClaims } from '../../../../../common/src/cams/jwt'; -import { REGION_02_GROUP_NY } from '../../../../../common/src/cams/test-utilities/mock-user'; +import { CamsSession } from '../../../../common/src/cams/session'; +import { CamsRole } from '../../../../common/src/cams/roles'; +import { CamsJwtClaims } from '../../../../common/src/cams/jwt'; +import { REGION_02_GROUP_NY } from '../../../../common/src/cams/test-utilities/mock-user'; const cache = new Map(); diff --git a/backend/functions/lib/testing/mock-gateways/mock.offices.gateway.ts b/backend/lib/testing/mock-gateways/mock.offices.gateway.ts similarity index 96% rename from backend/functions/lib/testing/mock-gateways/mock.offices.gateway.ts rename to backend/lib/testing/mock-gateways/mock.offices.gateway.ts index a53ef9e1c..7fe56747b 100644 --- a/backend/functions/lib/testing/mock-gateways/mock.offices.gateway.ts +++ b/backend/lib/testing/mock-gateways/mock.offices.gateway.ts @@ -1,4 +1,4 @@ -import { USTP_OFFICES_ARRAY, UstpOfficeDetails } from '../../../../../common/src/cams/offices'; +import { USTP_OFFICES_ARRAY, UstpOfficeDetails } from '../../../../common/src/cams/offices'; import { USTP_OFFICE_NAME_MAP } from '../../adapters/gateways/dxtr/dxtr.constants'; import { ApplicationContext } from '../../adapters/types/basic'; import { CamsError } from '../../common-errors/cams-error'; diff --git a/backend/functions/lib/testing/mock-gateways/mock.offices.repository.ts b/backend/lib/testing/mock-gateways/mock.offices.repository.ts similarity index 68% rename from backend/functions/lib/testing/mock-gateways/mock.offices.repository.ts rename to backend/lib/testing/mock-gateways/mock.offices.repository.ts index 39309b511..2537fe3b9 100644 --- a/backend/functions/lib/testing/mock-gateways/mock.offices.repository.ts +++ b/backend/lib/testing/mock-gateways/mock.offices.repository.ts @@ -1,4 +1,4 @@ -import { TRIAL_ATTORNEYS } from '../../../../../common/src/cams/test-utilities/attorneys.mock'; +import { TRIAL_ATTORNEYS } from '../../../../common/src/cams/test-utilities/attorneys.mock'; export const MockOfficesRepository = { release: () => {}, diff --git a/backend/functions/lib/testing/mock-gateways/mock.orders.gateway.ts b/backend/lib/testing/mock-gateways/mock.orders.gateway.ts similarity index 76% rename from backend/functions/lib/testing/mock-gateways/mock.orders.gateway.ts rename to backend/lib/testing/mock-gateways/mock.orders.gateway.ts index 5e98a98ff..c9c14a109 100644 --- a/backend/functions/lib/testing/mock-gateways/mock.orders.gateway.ts +++ b/backend/lib/testing/mock-gateways/mock.orders.gateway.ts @@ -1,5 +1,5 @@ -import { RawOrderSync } from '../../../../../common/src/cams/orders'; -import MockData from '../../../../../common/src/cams/test-utilities/mock-data'; +import { RawOrderSync } from '../../../../common/src/cams/orders'; +import MockData from '../../../../common/src/cams/test-utilities/mock-data'; import { ApplicationContext } from '../../adapters/types/basic'; import { OrdersGateway } from '../../use-cases/gateways.types'; diff --git a/backend/functions/lib/testing/testing-constants.ts b/backend/lib/testing/testing-constants.ts similarity index 100% rename from backend/functions/lib/testing/testing-constants.ts rename to backend/lib/testing/testing-constants.ts diff --git a/backend/functions/lib/testing/testing-utilities.ts b/backend/lib/testing/testing-utilities.ts similarity index 85% rename from backend/functions/lib/testing/testing-utilities.ts rename to backend/lib/testing/testing-utilities.ts index 3b1371dbe..9a59a840c 100644 --- a/backend/functions/lib/testing/testing-utilities.ts +++ b/backend/lib/testing/testing-utilities.ts @@ -1,9 +1,9 @@ import { ApplicationContext } from '../adapters/types/basic'; import { HttpRequest, InvocationContext } from '@azure/functions'; -import { MockData } from '../../../../common/src/cams/test-utilities/mock-data'; -import { CamsSession } from '../../../../common/src/cams/session'; +import { MockData } from '../../../common/src/cams/test-utilities/mock-data'; +import { CamsSession } from '../../../common/src/cams/session'; import { CamsHttpMethod, CamsHttpRequest } from '../adapters/types/http'; -import ContextCreator from '../../azure/application-context-creator'; +import ContextCreator from '../../function-apps/azure/application-context-creator'; import { LoggerImpl } from '../adapters/services/logger.service'; const invocationContext = new InvocationContext(); diff --git a/backend/functions/lib/use-cases/acms-orders/acms-orders.test.ts b/backend/lib/use-cases/acms-orders/acms-orders.test.ts similarity index 97% rename from backend/functions/lib/use-cases/acms-orders/acms-orders.test.ts rename to backend/lib/use-cases/acms-orders/acms-orders.test.ts index 8de6861c8..89493f72b 100644 --- a/backend/functions/lib/use-cases/acms-orders/acms-orders.test.ts +++ b/backend/lib/use-cases/acms-orders/acms-orders.test.ts @@ -3,14 +3,14 @@ import { createMockApplicationContext } from '../../testing/testing-utilities'; import { AcmsGateway } from '../gateways.types'; import AcmsOrders, { AcmsConsolidation, AcmsPredicate, AcmsPredicateAndPage } from './acms-orders'; import { CasesMongoRepository } from '../../adapters/gateways/mongo/cases.mongo.repository'; -import MockData from '../../../../../common/src/cams/test-utilities/mock-data'; +import MockData from '../../../../common/src/cams/test-utilities/mock-data'; import { AcmsGatewayImpl } from '../../adapters/gateways/acms/acms.gateway'; import CasesDxtrGateway from '../../adapters/gateways/dxtr/cases.dxtr.gateway'; -import { CaseSummary } from '../../../../../common/src/cams/cases'; -import { ConsolidationType } from '../../../../../common/src/cams/orders'; -import { CaseConsolidationHistory } from '../../../../../common/src/cams/history'; -import { ACMS_SYSTEM_USER_REFERENCE } from '../../../../../common/src/cams/auditable'; -import { ConsolidationFrom } from '../../../../../common/src/cams/events'; +import { CaseSummary } from '../../../../common/src/cams/cases'; +import { ConsolidationType } from '../../../../common/src/cams/orders'; +import { CaseConsolidationHistory } from '../../../../common/src/cams/history'; +import { ACMS_SYSTEM_USER_REFERENCE } from '../../../../common/src/cams/auditable'; +import { ConsolidationFrom } from '../../../../common/src/cams/events'; const mockAcmsGateway: AcmsGateway = { getPageCount: function (..._ignore): Promise { diff --git a/backend/functions/lib/use-cases/acms-orders/acms-orders.ts b/backend/lib/use-cases/acms-orders/acms-orders.ts similarity index 95% rename from backend/functions/lib/use-cases/acms-orders/acms-orders.ts rename to backend/lib/use-cases/acms-orders/acms-orders.ts index 316b04055..af1c9e8a7 100644 --- a/backend/functions/lib/use-cases/acms-orders/acms-orders.ts +++ b/backend/lib/use-cases/acms-orders/acms-orders.ts @@ -1,10 +1,10 @@ import { ApplicationContext } from '../../adapters/types/basic'; import Factory from '../../factory'; -import { ConsolidationFrom, ConsolidationTo } from '../../../../../common/src/cams/events'; -import { ConsolidationType } from '../../../../../common/src/cams/orders'; -import { CaseSummary } from '../../../../../common/src/cams/cases'; -import { CaseConsolidationHistory } from '../../../../../common/src/cams/history'; -import { ACMS_SYSTEM_USER_REFERENCE } from '../../../../../common/src/cams/auditable'; +import { ConsolidationFrom, ConsolidationTo } from '../../../../common/src/cams/events'; +import { ConsolidationType } from '../../../../common/src/cams/orders'; +import { CaseSummary } from '../../../../common/src/cams/cases'; +import { CaseConsolidationHistory } from '../../../../common/src/cams/history'; +import { ACMS_SYSTEM_USER_REFERENCE } from '../../../../common/src/cams/auditable'; import { getCamsError } from '../../common-errors/error-utilities'; const MODULE_NAME = 'ACMS_ORDERS_USE_CASE'; diff --git a/backend/functions/lib/use-cases/assignment.exception.test.ts b/backend/lib/use-cases/assignment.exception.test.ts similarity index 84% rename from backend/functions/lib/use-cases/assignment.exception.test.ts rename to backend/lib/use-cases/assignment.exception.test.ts index b4af91996..1a8682a3d 100644 --- a/backend/functions/lib/use-cases/assignment.exception.test.ts +++ b/backend/lib/use-cases/assignment.exception.test.ts @@ -1,5 +1,5 @@ import { AssignmentError } from './assignment.exception'; -import HttpStatusCodes from '../../../../common/src/api/http-status-codes'; +import HttpStatusCodes from '../../../common/src/api/http-status-codes'; describe('CAMS Assignment Exception', () => { const testModuleName = 'Test'; diff --git a/backend/functions/lib/use-cases/assignment.exception.ts b/backend/lib/use-cases/assignment.exception.ts similarity index 84% rename from backend/functions/lib/use-cases/assignment.exception.ts rename to backend/lib/use-cases/assignment.exception.ts index dac52dd79..7adbeadbd 100644 --- a/backend/functions/lib/use-cases/assignment.exception.ts +++ b/backend/lib/use-cases/assignment.exception.ts @@ -1,5 +1,5 @@ import { CamsError, CamsErrorOptions } from '../common-errors/cams-error'; -import HttpStatusCodes from '../../../../common/src/api/http-status-codes'; +import HttpStatusCodes from '../../../common/src/api/http-status-codes'; /* eslint-disable-next-line @typescript-eslint/no-empty-object-type */ export interface AssignmentErrorOptions extends CamsErrorOptions {} diff --git a/backend/functions/lib/use-cases/attorney.gateway.interface.d.ts b/backend/lib/use-cases/attorney.gateway.interface.d.ts similarity index 81% rename from backend/functions/lib/use-cases/attorney.gateway.interface.d.ts rename to backend/lib/use-cases/attorney.gateway.interface.d.ts index daccb5487..4a7032ce8 100644 --- a/backend/functions/lib/use-cases/attorney.gateway.interface.d.ts +++ b/backend/lib/use-cases/attorney.gateway.interface.d.ts @@ -1,5 +1,5 @@ import { ApplicationContext } from '../adapters/types/basic'; -import { AttorneyUser } from '../../../../common/src/cams/users'; +import { AttorneyUser } from '../../../common/src/cams/users'; export interface AttorneyGatewayInterface { getAttorneys(applicationContext: ApplicationContext): Promise>; diff --git a/backend/functions/lib/use-cases/attorneys.test.ts b/backend/lib/use-cases/attorneys.test.ts similarity index 94% rename from backend/functions/lib/use-cases/attorneys.test.ts rename to backend/lib/use-cases/attorneys.test.ts index ad5ebc814..86fa8d78d 100644 --- a/backend/functions/lib/use-cases/attorneys.test.ts +++ b/backend/lib/use-cases/attorneys.test.ts @@ -1,4 +1,4 @@ -import { TRIAL_ATTORNEYS } from '../../../../common/src/cams/test-utilities/attorneys.mock'; +import { TRIAL_ATTORNEYS } from '../../../common/src/cams/test-utilities/attorneys.mock'; import { createMockApplicationContext } from '../testing/testing-utilities'; import AttorneysList from './attorneys'; import { CaseAssignmentUseCase } from './case-assignment'; diff --git a/backend/functions/lib/use-cases/attorneys.ts b/backend/lib/use-cases/attorneys.ts similarity index 93% rename from backend/functions/lib/use-cases/attorneys.ts rename to backend/lib/use-cases/attorneys.ts index 30687370e..a362bb589 100644 --- a/backend/functions/lib/use-cases/attorneys.ts +++ b/backend/lib/use-cases/attorneys.ts @@ -2,7 +2,7 @@ import { AttorneyGatewayInterface } from './attorney.gateway.interface'; import { ApplicationContext } from '../adapters/types/basic'; import { getAttorneyGateway } from '../factory'; import { CaseAssignmentUseCase } from './case-assignment'; -import { AttorneyUser } from '../../../../common/src/cams/users'; +import { AttorneyUser } from '../../../common/src/cams/users'; const MODULE_NAME = 'ATTORNEYS-USE-CASE'; diff --git a/backend/functions/lib/use-cases/case-assignment.test.ts b/backend/lib/use-cases/case-assignment.test.ts similarity index 96% rename from backend/functions/lib/use-cases/case-assignment.test.ts rename to backend/lib/use-cases/case-assignment.test.ts index 15ecdb4f6..235170623 100644 --- a/backend/functions/lib/use-cases/case-assignment.test.ts +++ b/backend/lib/use-cases/case-assignment.test.ts @@ -4,12 +4,12 @@ import { createMockApplicationContext, createMockApplicationContextSession, } from '../testing/testing-utilities'; -import MockData from '../../../../common/src/cams/test-utilities/mock-data'; -import { CamsRole } from '../../../../common/src/cams/roles'; +import MockData from '../../../common/src/cams/test-utilities/mock-data'; +import { CamsRole } from '../../../common/src/cams/roles'; import CaseManagement from './case-management'; -import { getCourtDivisionCodes } from '../../../../common/src/cams/users'; +import { getCourtDivisionCodes } from '../../../common/src/cams/users'; import { MockMongoRepository } from '../testing/mock-gateways/mock-mongo.repository'; -import { ConsolidationOrder } from '../../../../common/src/cams/orders'; +import { ConsolidationOrder } from '../../../common/src/cams/orders'; const randomId = () => { return '' + Math.random() * 99999999; diff --git a/backend/functions/lib/use-cases/case-assignment.ts b/backend/lib/use-cases/case-assignment.ts similarity index 94% rename from backend/functions/lib/use-cases/case-assignment.ts rename to backend/lib/use-cases/case-assignment.ts index 69668639b..ea53158cc 100644 --- a/backend/functions/lib/use-cases/case-assignment.ts +++ b/backend/lib/use-cases/case-assignment.ts @@ -1,13 +1,13 @@ import Factory, { getAssignmentRepository } from '../factory'; import { ApplicationContext } from '../adapters/types/basic'; import { CaseAssignmentRepository } from './gateways.types'; -import { CaseAssignment } from '../../../../common/src/cams/assignments'; -import { CaseAssignmentHistory } from '../../../../common/src/cams/history'; +import { CaseAssignment } from '../../../common/src/cams/assignments'; +import { CaseAssignmentHistory } from '../../../common/src/cams/history'; import CaseManagement from './case-management'; -import { CamsUserReference, getCourtDivisionCodes } from '../../../../common/src/cams/users'; -import { CamsRole } from '../../../../common/src/cams/roles'; +import { CamsUserReference, getCourtDivisionCodes } from '../../../common/src/cams/users'; +import { CamsRole } from '../../../common/src/cams/roles'; import { AssignmentError } from './assignment.exception'; -import { createAuditRecord } from '../../../../common/src/cams/auditable'; +import { createAuditRecord } from '../../../common/src/cams/auditable'; const MODULE_NAME = 'CASE-ASSIGNMENT'; diff --git a/backend/functions/lib/use-cases/case-associated/case-associated.ts b/backend/lib/use-cases/case-associated/case-associated.ts similarity index 95% rename from backend/functions/lib/use-cases/case-associated/case-associated.ts rename to backend/lib/use-cases/case-associated/case-associated.ts index 8393ec1d8..e2728b0f7 100644 --- a/backend/functions/lib/use-cases/case-associated/case-associated.ts +++ b/backend/lib/use-cases/case-associated/case-associated.ts @@ -1,6 +1,6 @@ import Factory from '../../factory'; import { ApplicationContext } from '../../adapters/types/basic'; -import { EventCaseReference } from '../../../../../common/src/cams/events'; +import { EventCaseReference } from '../../../../common/src/cams/events'; function getEarliestDate(orders: Array) { const earliestOrder = orders.sort((a, b) => (a.orderDate < b.orderDate ? -1 : 1))[0]; diff --git a/backend/functions/lib/use-cases/case-docket/case-docket.test.ts b/backend/lib/use-cases/case-docket/case-docket.test.ts similarity index 100% rename from backend/functions/lib/use-cases/case-docket/case-docket.test.ts rename to backend/lib/use-cases/case-docket/case-docket.test.ts diff --git a/backend/functions/lib/use-cases/case-docket/case-docket.ts b/backend/lib/use-cases/case-docket/case-docket.ts similarity index 87% rename from backend/functions/lib/use-cases/case-docket/case-docket.ts rename to backend/lib/use-cases/case-docket/case-docket.ts index a5ade3001..fee01510d 100644 --- a/backend/functions/lib/use-cases/case-docket/case-docket.ts +++ b/backend/lib/use-cases/case-docket/case-docket.ts @@ -1,6 +1,6 @@ import { CaseDocketGateway } from '../gateways.types'; import { ApplicationContext } from '../../adapters/types/basic'; -import { CaseDocket } from '../../../../../common/src/cams/cases'; +import { CaseDocket } from '../../../../common/src/cams/cases'; export class CaseDocketUseCase { private readonly gateway: CaseDocketGateway; diff --git a/backend/functions/lib/use-cases/case-history/case-history.test.ts b/backend/lib/use-cases/case-history/case-history.test.ts similarity index 100% rename from backend/functions/lib/use-cases/case-history/case-history.test.ts rename to backend/lib/use-cases/case-history/case-history.test.ts diff --git a/backend/functions/lib/use-cases/case-history/case-history.ts b/backend/lib/use-cases/case-history/case-history.ts similarity index 85% rename from backend/functions/lib/use-cases/case-history/case-history.ts rename to backend/lib/use-cases/case-history/case-history.ts index db878dd26..1b426e825 100644 --- a/backend/functions/lib/use-cases/case-history/case-history.ts +++ b/backend/lib/use-cases/case-history/case-history.ts @@ -1,6 +1,6 @@ import Factory from '../../factory'; import { ApplicationContext } from '../../adapters/types/basic'; -import { CaseHistory } from '../../../../../common/src/cams/history'; +import { CaseHistory } from '../../../../common/src/cams/history'; export class CaseHistoryUseCase { public async getCaseHistory(context: ApplicationContext): Promise { diff --git a/backend/functions/lib/use-cases/case-management.test.ts b/backend/lib/use-cases/case-management.test.ts similarity index 96% rename from backend/functions/lib/use-cases/case-management.test.ts rename to backend/lib/use-cases/case-management.test.ts index 02e76f32c..14dde07f6 100644 --- a/backend/functions/lib/use-cases/case-management.test.ts +++ b/backend/lib/use-cases/case-management.test.ts @@ -1,25 +1,25 @@ import CaseManagement, { getAction } from './case-management'; import { UnknownError } from '../common-errors/unknown-error'; import { CamsError } from '../common-errors/cams-error'; -import { MockData } from '../../../../common/src/cams/test-utilities/mock-data'; -import { CaseAssignment } from '../../../../common/src/cams/assignments'; +import { MockData } from '../../../common/src/cams/test-utilities/mock-data'; +import { CaseAssignment } from '../../../common/src/cams/assignments'; import { createMockApplicationContext, createMockApplicationContextSession, } from '../testing/testing-utilities'; -import { CamsRole } from '../../../../common/src/cams/roles'; +import { CamsRole } from '../../../common/src/cams/roles'; import { getCasesGateway } from '../factory'; import { ApplicationContext } from '../adapters/types/basic'; -import { CamsUser } from '../../../../common/src/cams/users'; +import { CamsUser } from '../../../common/src/cams/users'; import { REGION_02_GROUP_BU, REGION_02_GROUP_NY, -} from '../../../../common/src/cams/test-utilities/mock-user'; -import { ustpOfficeToCourtDivision } from '../../../../common/src/cams/courts'; +} from '../../../common/src/cams/test-utilities/mock-user'; +import { ustpOfficeToCourtDivision } from '../../../common/src/cams/courts'; import { buildOfficeCode } from './offices/offices'; import { MockMongoRepository } from '../testing/mock-gateways/mock-mongo.repository'; -import { TransferOrder } from '../../../../common/src/cams/orders'; -import { ConsolidationTo } from '../../../../common/src/cams/events'; +import { TransferOrder } from '../../../common/src/cams/orders'; +import { ConsolidationTo } from '../../../common/src/cams/events'; const attorneyJaneSmith = { id: '001', name: 'Jane Smith' }; const attorneyJoeNobel = { id: '002', name: 'Joe Nobel' }; diff --git a/backend/functions/lib/use-cases/case-management.ts b/backend/lib/use-cases/case-management.ts similarity index 92% rename from backend/functions/lib/use-cases/case-management.ts rename to backend/lib/use-cases/case-management.ts index d2e6b2610..6656a6f0c 100644 --- a/backend/functions/lib/use-cases/case-management.ts +++ b/backend/lib/use-cases/case-management.ts @@ -1,5 +1,5 @@ import { ApplicationContext } from '../adapters/types/basic'; -import { CaseBasics, CaseDetail, CaseSummary } from '../../../../common/src/cams/cases'; +import { CaseBasics, CaseDetail, CaseSummary } from '../../../common/src/cams/cases'; import Factory, { getAssignmentRepository, getCasesGateway, getOfficesGateway } from '../factory'; import { CasesInterface } from './cases.interface'; import { CaseAssignmentUseCase } from './case-assignment'; @@ -8,12 +8,12 @@ import { isCamsError } from '../common-errors/cams-error'; import { AssignmentError } from './assignment.exception'; import { OfficesGateway } from './offices/offices.types'; import { CaseAssignmentRepository } from './gateways.types'; -import { CasesSearchPredicate } from '../../../../common/src/api/search'; -import Actions, { Action, ResourceActions } from '../../../../common/src/cams/actions'; -import { CamsRole } from '../../../../common/src/cams/roles'; -import { getCourtDivisionCodes } from '../../../../common/src/cams/users'; +import { CasesSearchPredicate } from '../../../common/src/api/search'; +import Actions, { Action, ResourceActions } from '../../../common/src/cams/actions'; +import { CamsRole } from '../../../common/src/cams/roles'; +import { getCourtDivisionCodes } from '../../../common/src/cams/users'; import { buildOfficeCode } from './offices/offices'; -import { CaseAssignment } from '../../../../common/src/cams/assignments'; +import { CaseAssignment } from '../../../common/src/cams/assignments'; import { getCamsError } from '../common-errors/error-utilities'; const MODULE_NAME = 'CASE-MANAGEMENT-USE-CASE'; diff --git a/backend/functions/lib/use-cases/cases.interface.d.ts b/backend/lib/use-cases/cases.interface.d.ts similarity index 76% rename from backend/functions/lib/use-cases/cases.interface.d.ts rename to backend/lib/use-cases/cases.interface.d.ts index 99bc1713d..43e71f034 100644 --- a/backend/functions/lib/use-cases/cases.interface.d.ts +++ b/backend/lib/use-cases/cases.interface.d.ts @@ -1,6 +1,6 @@ import { ApplicationContext } from '../adapters/types/basic'; -import { CaseBasics, CaseDetail, CaseSummary } from '../../../../common/src/cams/cases'; -import { CasesSearchPredicate } from '../../../../common/src/api/search'; +import { CaseBasics, CaseDetail, CaseSummary } from '../../../common/src/cams/cases'; +import { CasesSearchPredicate } from '../../../common/src/api/search'; export interface CasesInterface { getCaseDetail(applicationContext: ApplicationContext, caseId: string): Promise; diff --git a/backend/functions/lib/use-cases/courts/courts.test.ts b/backend/lib/use-cases/courts/courts.test.ts similarity index 87% rename from backend/functions/lib/use-cases/courts/courts.test.ts rename to backend/lib/use-cases/courts/courts.test.ts index 9139e382b..26768fb93 100644 --- a/backend/functions/lib/use-cases/courts/courts.test.ts +++ b/backend/lib/use-cases/courts/courts.test.ts @@ -2,8 +2,8 @@ import { CourtsUseCase } from './courts'; import { ApplicationContext } from '../../adapters/types/basic'; import { createMockApplicationContext } from '../../testing/testing-utilities'; import { OfficesUseCase } from '../offices/offices'; -import { USTP_OFFICES_ARRAY } from '../../../../../common/src/cams/offices'; -import { ustpOfficeToCourtDivision } from '../../../../../common/src/cams/courts'; +import { USTP_OFFICES_ARRAY } from '../../../../common/src/cams/offices'; +import { ustpOfficeToCourtDivision } from '../../../../common/src/cams/courts'; describe('Courts use case tests', () => { let useCase: CourtsUseCase; diff --git a/backend/functions/lib/use-cases/courts/courts.ts b/backend/lib/use-cases/courts/courts.ts similarity index 92% rename from backend/functions/lib/use-cases/courts/courts.ts rename to backend/lib/use-cases/courts/courts.ts index 80288c692..03466e307 100644 --- a/backend/functions/lib/use-cases/courts/courts.ts +++ b/backend/lib/use-cases/courts/courts.ts @@ -2,7 +2,7 @@ import { ApplicationContext } from '../../adapters/types/basic'; import { CourtDivisionDetails, ustpOfficeToCourtDivision, -} from '../../../../../common/src/cams/courts'; +} from '../../../../common/src/cams/courts'; import { OfficesUseCase } from '../offices/offices'; export class CourtsUseCase { diff --git a/backend/functions/lib/use-cases/gateways.types.ts b/backend/lib/use-cases/gateways.types.ts similarity index 89% rename from backend/functions/lib/use-cases/gateways.types.ts rename to backend/lib/use-cases/gateways.types.ts index 8479ad768..95d45ed19 100644 --- a/backend/functions/lib/use-cases/gateways.types.ts +++ b/backend/lib/use-cases/gateways.types.ts @@ -4,20 +4,20 @@ import { Order, RawOrderSync, TransferOrderAction, -} from '../../../../common/src/cams/orders'; +} from '../../../common/src/cams/orders'; import { ConsolidationTo, ConsolidationFrom, TransferFrom, TransferTo, -} from '../../../../common/src/cams/events'; -import { CaseAssignmentHistory, CaseHistory } from '../../../../common/src/cams/history'; -import { CaseDocket } from '../../../../common/src/cams/cases'; -import { OrdersSearchPredicate } from '../../../../common/src/api/search'; -import { AttorneyUser, CamsUserGroup, CamsUserReference } from '../../../../common/src/cams/users'; -import { UstpOfficeDetails } from '../../../../common/src/cams/offices'; -import { CaseAssignment } from '../../../../common/src/cams/assignments'; -import { CamsSession } from '../../../../common/src/cams/session'; +} from '../../../common/src/cams/events'; +import { CaseAssignmentHistory, CaseHistory } from '../../../common/src/cams/history'; +import { CaseDocket } from '../../../common/src/cams/cases'; +import { OrdersSearchPredicate } from '../../../common/src/api/search'; +import { AttorneyUser, CamsUserGroup, CamsUserReference } from '../../../common/src/cams/users'; +import { UstpOfficeDetails } from '../../../common/src/cams/offices'; +import { CaseAssignment } from '../../../common/src/cams/assignments'; +import { CamsSession } from '../../../common/src/cams/session'; import { ConditionOrConjunction, Sort } from '../query/query-builder'; import { AcmsConsolidation, AcmsPredicate, AcmsPredicateAndPage } from './acms-orders/acms-orders'; diff --git a/backend/functions/lib/use-cases/offices/offices.test.ts b/backend/lib/use-cases/offices/offices.test.ts similarity index 95% rename from backend/functions/lib/use-cases/offices/offices.test.ts rename to backend/lib/use-cases/offices/offices.test.ts index 494e3d35e..6068ef853 100644 --- a/backend/functions/lib/use-cases/offices/offices.test.ts +++ b/backend/lib/use-cases/offices/offices.test.ts @@ -4,14 +4,14 @@ import { createMockApplicationContext } from '../../testing/testing-utilities'; import * as factory from '../../factory'; import OktaUserGroupGateway from '../../adapters/gateways/okta/okta-user-group-gateway'; import { UserGroupGatewayConfig } from '../../adapters/types/authorization'; -import { CamsUserGroup, Staff } from '../../../../../common/src/cams/users'; -import MockData from '../../../../../common/src/cams/test-utilities/mock-data'; -import { USTP_OFFICES_ARRAY, UstpDivisionMeta } from '../../../../../common/src/cams/offices'; -import { TRIAL_ATTORNEYS } from '../../../../../common/src/cams/test-utilities/attorneys.mock'; +import { CamsUserGroup, Staff } from '../../../../common/src/cams/users'; +import MockData from '../../../../common/src/cams/test-utilities/mock-data'; +import { USTP_OFFICES_ARRAY, UstpDivisionMeta } from '../../../../common/src/cams/offices'; +import { TRIAL_ATTORNEYS } from '../../../../common/src/cams/test-utilities/attorneys.mock'; import AttorneysList from '../attorneys'; import { MockMongoRepository } from '../../testing/mock-gateways/mock-mongo.repository'; import { MockOfficesRepository } from '../../testing/mock-gateways/mock.offices.repository'; -import { CamsRole } from '../../../../../common/src/cams/roles'; +import { CamsRole } from '../../../../common/src/cams/roles'; describe('offices use case tests', () => { let applicationContext: ApplicationContext; diff --git a/backend/functions/lib/use-cases/offices/offices.ts b/backend/lib/use-cases/offices/offices.ts similarity index 97% rename from backend/functions/lib/use-cases/offices/offices.ts rename to backend/lib/use-cases/offices/offices.ts index b2983f9b4..d700f38a5 100644 --- a/backend/functions/lib/use-cases/offices/offices.ts +++ b/backend/lib/use-cases/offices/offices.ts @@ -1,5 +1,5 @@ -import { UstpOfficeDetails } from '../../../../../common/src/cams/offices'; -import { AttorneyUser, Staff } from '../../../../../common/src/cams/users'; +import { UstpOfficeDetails } from '../../../../common/src/cams/offices'; +import { AttorneyUser, Staff } from '../../../../common/src/cams/users'; import { ApplicationContext } from '../../adapters/types/basic'; import { getOfficesGateway, diff --git a/backend/functions/lib/use-cases/offices/offices.types.ts b/backend/lib/use-cases/offices/offices.types.ts similarity index 77% rename from backend/functions/lib/use-cases/offices/offices.types.ts rename to backend/lib/use-cases/offices/offices.types.ts index 53711d67a..854ce6762 100644 --- a/backend/functions/lib/use-cases/offices/offices.types.ts +++ b/backend/lib/use-cases/offices/offices.types.ts @@ -1,4 +1,4 @@ -import { UstpOfficeDetails } from '../../../../../common/src/cams/offices'; +import { UstpOfficeDetails } from '../../../../common/src/cams/offices'; import { ApplicationContext } from '../../adapters/types/basic'; export interface OfficesGateway { diff --git a/backend/functions/lib/use-cases/orders/orders-consolidation-approval.test.ts b/backend/lib/use-cases/orders/orders-consolidation-approval.test.ts similarity index 96% rename from backend/functions/lib/use-cases/orders/orders-consolidation-approval.test.ts rename to backend/lib/use-cases/orders/orders-consolidation-approval.test.ts index 5db22292c..e7bb63a8b 100644 --- a/backend/functions/lib/use-cases/orders/orders-consolidation-approval.test.ts +++ b/backend/lib/use-cases/orders/orders-consolidation-approval.test.ts @@ -7,15 +7,15 @@ import { getCasesRepository } from '../../factory'; import { ConsolidationOrderActionApproval, getCaseSummaryFromConsolidationOrderCase, -} from '../../../../../common/src/cams/orders'; -import { MockData } from '../../../../../common/src/cams/test-utilities/mock-data'; +} from '../../../../common/src/cams/orders'; +import { MockData } from '../../../../common/src/cams/test-utilities/mock-data'; import { ApplicationContext } from '../../adapters/types/basic'; import * as crypto from 'crypto'; -import { CaseHistory, ConsolidationOrderSummary } from '../../../../../common/src/cams/history'; +import { CaseHistory, ConsolidationOrderSummary } from '../../../../common/src/cams/history'; import { CaseAssignmentUseCase } from '../case-assignment'; -import { CamsRole } from '../../../../../common/src/cams/roles'; -import { SYSTEM_USER_REFERENCE } from '../../../../../common/src/cams/auditable'; -import { REGION_02_GROUP_NY } from '../../../../../common/src/cams/test-utilities/mock-user'; +import { CamsRole } from '../../../../common/src/cams/roles'; +import { SYSTEM_USER_REFERENCE } from '../../../../common/src/cams/auditable'; +import { REGION_02_GROUP_NY } from '../../../../common/src/cams/test-utilities/mock-user'; import { MockMongoRepository } from '../../testing/mock-gateways/mock-mongo.repository'; describe('Orders use case', () => { diff --git a/backend/functions/lib/use-cases/orders/orders-local-gateway.test.ts b/backend/lib/use-cases/orders/orders-local-gateway.test.ts similarity index 94% rename from backend/functions/lib/use-cases/orders/orders-local-gateway.test.ts rename to backend/lib/use-cases/orders/orders-local-gateway.test.ts index bdd542b3b..9e67bd285 100644 --- a/backend/functions/lib/use-cases/orders/orders-local-gateway.test.ts +++ b/backend/lib/use-cases/orders/orders-local-gateway.test.ts @@ -1,18 +1,18 @@ -import { MockData } from '../../../../../common/src/cams/test-utilities/mock-data'; +import { MockData } from '../../../../common/src/cams/test-utilities/mock-data'; import { ConsolidationOrder, ConsolidationOrderActionApproval, -} from '../../../../../common/src/cams/orders'; +} from '../../../../common/src/cams/orders'; import { Factory } from '../../factory'; import { CasesRepository, ConsolidationOrdersRepository } from '../gateways.types'; -import { ConsolidationFrom, ConsolidationTo } from '../../../../../common/src/cams/events'; +import { ConsolidationFrom, ConsolidationTo } from '../../../../common/src/cams/events'; import { createMockApplicationContext, createMockApplicationContextSession, } from '../../testing/testing-utilities'; -import { CamsRole } from '../../../../../common/src/cams/roles'; -import { REGION_02_GROUP_NY } from '../../../../../common/src/cams/test-utilities/mock-user'; +import { CamsRole } from '../../../../common/src/cams/roles'; +import { REGION_02_GROUP_NY } from '../../../../common/src/cams/test-utilities/mock-user'; import { LocalCasesRepository } from '../../testing/local-data/local-cases-repository'; import { LocalConsolidationOrdersRepository } from '../../testing/local-data/local-consolidation-orders-repository'; import { OrdersUseCase } from './orders'; diff --git a/backend/functions/lib/use-cases/orders/orders.test.ts b/backend/lib/use-cases/orders/orders.test.ts similarity index 97% rename from backend/functions/lib/use-cases/orders/orders.test.ts rename to backend/lib/use-cases/orders/orders.test.ts index bceff338e..dd6fdb0e7 100644 --- a/backend/functions/lib/use-cases/orders/orders.test.ts +++ b/backend/lib/use-cases/orders/orders.test.ts @@ -17,29 +17,29 @@ import { getCaseSummaryFromTransferOrder, TransferOrder, TransferOrderAction, -} from '../../../../../common/src/cams/orders'; +} from '../../../../common/src/cams/orders'; import { ConsolidationFrom, ConsolidationTo, TransferFrom, TransferTo, -} from '../../../../../common/src/cams/events'; +} from '../../../../common/src/cams/events'; import { CASE_SUMMARIES } from '../../testing/mock-data/case-summaries.mock'; -import { MockData } from '../../../../../common/src/cams/test-utilities/mock-data'; +import { MockData } from '../../../../common/src/cams/test-utilities/mock-data'; import { CasesLocalGateway } from '../../adapters/gateways/cases.local.gateway'; -import { CaseSummary } from '../../../../../common/src/cams/cases'; +import { CaseSummary } from '../../../../common/src/cams/cases'; import { ApplicationContext } from '../../adapters/types/basic'; import { NotFoundError } from '../../common-errors/not-found-error'; import * as crypto from 'crypto'; -import { CaseHistory, ConsolidationOrderSummary } from '../../../../../common/src/cams/history'; +import { CaseHistory, ConsolidationOrderSummary } from '../../../../common/src/cams/history'; import { MockOrdersGateway } from '../../testing/mock-gateways/mock.orders.gateway'; -import { CamsRole } from '../../../../../common/src/cams/roles'; -import { getCamsUserReference } from '../../../../../common/src/cams/session'; +import { CamsRole } from '../../../../common/src/cams/roles'; +import { getCamsUserReference } from '../../../../common/src/cams/session'; import { CaseAssignmentUseCase } from '../case-assignment'; -import { REGION_02_GROUP_NY } from '../../../../../common/src/cams/test-utilities/mock-user'; -import { getCourtDivisionCodes } from '../../../../../common/src/cams/users'; +import { REGION_02_GROUP_NY } from '../../../../common/src/cams/test-utilities/mock-user'; +import { getCourtDivisionCodes } from '../../../../common/src/cams/users'; import { MockMongoRepository } from '../../testing/mock-gateways/mock-mongo.repository'; -import { UstpDivisionMeta } from '../../../../../common/src/cams/offices'; +import { UstpDivisionMeta } from '../../../../common/src/cams/offices'; describe('Orders use case', () => { const CASE_ID = '000-11-22222'; diff --git a/backend/functions/lib/use-cases/orders/orders.ts b/backend/lib/use-cases/orders/orders.ts similarity index 96% rename from backend/functions/lib/use-cases/orders/orders.ts rename to backend/lib/use-cases/orders/orders.ts index 20b51a78a..06d49ed0f 100644 --- a/backend/functions/lib/use-cases/orders/orders.ts +++ b/backend/lib/use-cases/orders/orders.ts @@ -14,30 +14,30 @@ import { ConsolidationType, getCaseSummaryFromTransferOrder, getCaseSummaryFromConsolidationOrderCase, -} from '../../../../../common/src/cams/orders'; +} from '../../../../common/src/cams/orders'; import { ConsolidationFrom, ConsolidationTo, TransferFrom, TransferTo, -} from '../../../../../common/src/cams/events'; -import { CaseSummary } from '../../../../../common/src/cams/cases'; +} from '../../../../common/src/cams/events'; +import { CaseSummary } from '../../../../common/src/cams/cases'; import { CamsError } from '../../common-errors/cams-error'; -import { sortDates, sortDatesReverse } from '../../../../../common/src/date-helper'; +import { sortDates, sortDatesReverse } from '../../../../common/src/date-helper'; import * as crypto from 'crypto'; import { CaseConsolidationHistory, CaseHistory, ConsolidationOrderSummary, isConsolidationHistory, -} from '../../../../../common/src/cams/history'; +} from '../../../../common/src/cams/history'; import { CaseAssignmentUseCase } from '../case-assignment'; import { BadRequestError } from '../../common-errors/bad-request'; -import { CamsUserReference, getCourtDivisionCodes } from '../../../../../common/src/cams/users'; -import { CamsRole } from '../../../../../common/src/cams/roles'; +import { CamsUserReference, getCourtDivisionCodes } from '../../../../common/src/cams/users'; +import { CamsRole } from '../../../../common/src/cams/roles'; import { UnauthorizedError } from '../../common-errors/unauthorized-error'; -import { createAuditRecord } from '../../../../../common/src/cams/auditable'; -import { OrdersSearchPredicate } from '../../../../../common/src/api/search'; +import { createAuditRecord } from '../../../../common/src/cams/auditable'; +import { OrdersSearchPredicate } from '../../../../common/src/api/search'; import { isNotFoundError } from '../../common-errors/not-found-error'; import { Factory } from '../../factory'; diff --git a/backend/functions/lib/use-cases/user-session/user-session.test.ts b/backend/lib/use-cases/user-session/user-session.test.ts similarity index 93% rename from backend/functions/lib/use-cases/user-session/user-session.test.ts rename to backend/lib/use-cases/user-session/user-session.test.ts index 4097bc89a..72f1aad3c 100644 --- a/backend/functions/lib/use-cases/user-session/user-session.test.ts +++ b/backend/lib/use-cases/user-session/user-session.test.ts @@ -1,17 +1,17 @@ import { UserSessionUseCase } from './user-session'; import { ApplicationContext } from '../../adapters/types/basic'; import { createMockApplicationContext } from '../../testing/testing-utilities'; -import { MockData } from '../../../../../common/src/cams/test-utilities/mock-data'; +import { MockData } from '../../../../common/src/cams/test-utilities/mock-data'; import { UnauthorizedError } from '../../common-errors/unauthorized-error'; import * as factoryModule from '../../factory'; import { ServerConfigError } from '../../common-errors/server-config-error'; -import { CamsSession } from '../../../../../common/src/cams/session'; -import { CamsRole } from '../../../../../common/src/cams/roles'; -import { urlRegex } from '../../../../../common/src/cams/test-utilities/regex'; -import { CamsJwtHeader } from '../../../../../common/src/cams/jwt'; +import { CamsSession } from '../../../../common/src/cams/session'; +import { CamsRole } from '../../../../common/src/cams/roles'; +import { urlRegex } from '../../../../common/src/cams/test-utilities/regex'; +import { CamsJwtHeader } from '../../../../common/src/cams/jwt'; import MockOpenIdConnectGateway from '../../testing/mock-gateways/mock-oauth2-gateway'; import * as Verifier from '../../adapters/gateways/okta/HumbleVerifier'; -import { REGION_02_GROUP_NY } from '../../../../../common/src/cams/test-utilities/mock-user'; +import { REGION_02_GROUP_NY } from '../../../../common/src/cams/test-utilities/mock-user'; import { MockMongoRepository } from '../../testing/mock-gateways/mock-mongo.repository'; import { NotFoundError } from '../../common-errors/not-found-error'; diff --git a/backend/functions/lib/use-cases/user-session/user-session.ts b/backend/lib/use-cases/user-session/user-session.ts similarity index 89% rename from backend/functions/lib/use-cases/user-session/user-session.ts rename to backend/lib/use-cases/user-session/user-session.ts index 04fd1ff9d..83378b55a 100644 --- a/backend/functions/lib/use-cases/user-session/user-session.ts +++ b/backend/lib/use-cases/user-session/user-session.ts @@ -3,11 +3,11 @@ import { ApplicationContext } from '../../adapters/types/basic'; import { UnauthorizedError } from '../../common-errors/unauthorized-error'; import { isCamsError } from '../../common-errors/cams-error'; import { ServerConfigError } from '../../common-errors/server-config-error'; -import { UstpOfficeDetails } from '../../../../../common/src/cams/offices'; +import { UstpOfficeDetails } from '../../../../common/src/cams/offices'; import LocalStorageGateway from '../../adapters/gateways/storage/local-storage-gateway'; -import { CamsRole } from '../../../../../common/src/cams/roles'; -import { CamsSession } from '../../../../../common/src/cams/session'; -import { REGION_02_GROUP_NY } from '../../../../../common/src/cams/test-utilities/mock-user'; +import { CamsRole } from '../../../../common/src/cams/roles'; +import { CamsSession } from '../../../../common/src/cams/session'; +import { REGION_02_GROUP_NY } from '../../../../common/src/cams/test-utilities/mock-user'; import { isNotFoundError } from '../../common-errors/not-found-error'; const MODULE_NAME = 'USER-SESSION-GATEWAY'; diff --git a/backend/pack.sh b/backend/pack.sh new file mode 100755 index 000000000..5bc240a59 --- /dev/null +++ b/backend/pack.sh @@ -0,0 +1,19 @@ +#! /bin/bash + +if [[ $OUT == "" ]]; then + FILE_NAME=$1; +else + FILE_NAME=$OUT; +fi + +PACK_TEMP_DIR="/tmp/build/$1" + +echo "Creating archive $PACK_TEMP_DIR/$FILE_NAME.zip" + +mkdir -p dist/ +mkdir -p node_modules/ +cp -r ../../node_modules/* node_modules/ +mkdir -p "$PACK_TEMP_DIR" +zip -q -r "$PACK_TEMP_DIR/$FILE_NAME.zip" ./dist ./node_modules ./package.json ./host.json --exclude "*.map" --exclude "*.ts" +mv "$PACK_TEMP_DIR/$FILE_NAME.zip" . +rm -rf node_modules diff --git a/backend/functions/package-lock.json b/backend/package-lock.json similarity index 100% rename from backend/functions/package-lock.json rename to backend/package-lock.json diff --git a/backend/functions/package.json b/backend/package.json similarity index 53% rename from backend/functions/package.json rename to backend/package.json index ec0ebc375..5247ec1af 100644 --- a/backend/functions/package.json +++ b/backend/package.json @@ -22,8 +22,8 @@ "typescript": "^5.7.2" }, "dependencies": { - "@azure/cosmos": "^4.2.0", "@azure/functions": "^4.6.0", + "@azure/cosmos": "^4.2.0", "@azure/identity": "^4.5.0", "@azure/keyvault-secrets": "^4.9.0", "@launchdarkly/node-server-sdk": "^9.7.2", @@ -36,30 +36,39 @@ "mongodb": "^6.11.0", "mssql": "^10.0.4" }, - "main": "dist/backend/functions/*/*.js", "overrides": { "@azure/identity": "$@azure/identity", "cookie": "^0.7.2" }, "scripts": { + "all": "npm run clean:all && npm ci && npm run build:all && npm run pack:all", + "clean:all": "npm run clean && npm run clean:api && npm run clean:migration", "clean": "rm -rf ./dist && rm -rf ./node_modules && rm -rf ./coverage", + "clean:api": "pushd function-apps/api && npm run clean && popd", + "clean:migration": "pushd function-apps/migration && npm run clean && popd", + "build:all": "npm run build-common && npm run build && npm run build:api && npm run build:migration", "build": "tsc --build tsconfig.build.json", - "build-common": "pushd ../../common && npm ci && npm run build && popd", - "watch": "tsc --project tsconfig.build.json -w", - "prestart": "npm run build", - "start": "func start --typescript", - "start:dev": "nodemon --esm src/server.ts", + "build-common": "pushd ../common && npm ci && npm run build && popd", + "build:api": "pushd function-apps/api && npm run build && popd", + "build:migration": "pushd function-apps/migration && npm run build && popd", + "pack:all": "npm run pack:api && npm run pack:migration", + "pack": "npm run pack:api", + "pack:api": "pushd function-apps/api && npm run pack && popd", + "pack:migration": "pushd function-apps/migration && npm run pack && popd", + "start": "npm run start:api", + "start:api": "pushd function-apps/api && npm run start && popd", + "start:migration": "pushd function-apps/migration && npm run start && popd", "test": "CAMS_LOGIN_PROVIDER='mock' DATABASE_MOCK='true' MONGO_CONNECTION_STRING='mongodb://test-string' jest -c jest.config.js", "test:open-handles": "CAMS_LOGIN_PROVIDER='mock' DATABASE_MOCK='true' MONGO_CONNECTION_STRING='mongodb://test-string' jest -c jest.config.js --detectOpenHandles", "lint": "eslint .", "lint:fix": "eslint . --fix", - "format": "prettier --write './**/*.{js,ts,css,md,json}' --config ./.prettierrc", - "pack": "mkdir -p /tmp/build && zip -q -r /tmp/build/$OUT.zip . --exclude @.funcignore --exclude .funcignore && mv /tmp/build/$OUT.zip .", + "format": "prettier --write './**/*.{js,ts,css,md,json}' --config .prettierrc", "coverage": "npm test -- --coverage", - "coverage:ci": "npm config set script-shell=/bin/bash && npm run build-common && npm test -- --coverage", - "dependency-cruiser-graphical": "current_time=$(date +'%Y-%m-%d_%H%M') && npx depcruise --output-type dot --do-not-follow '^node_modules($|/)' attorneys case-assignments case-docket case-history case-summary cases consolidations healthcheck offices orders orders-manual-sync orders-sync lib | dot -T svg > ../../docs/architecture/dependency-cruiser/functions/dependency-graph_api_${current_time}.svg", - "dependency-cruiser:ci": "npx depcruise --output-type err-long attorneys case-assignments case-docket case-history case-summary cases consolidations healthcheck offices orders orders-manual-sync orders-sync lib ", - "itest:okta-group-api": "CAMS_LOGIN_PROVIDER=okta npx ts-node ./lib/testing/isolated-integration/test-okta-group-api.ts", - "itest:export-office-csv": "CAMS_LOGIN_PROVIDER=okta npx ts-node ./lib/testing/isolated-integration/export-office-csv.ts" + "use-bash": "npm config set script-shell=/bin/bash", + "coverage:ci": "npm run use-bash && npm run build-common && npm test -- --coverage", + "dependency-cruiser-graphical": "current_time=$(date +'%Y-%m-%d_%H%M') && npx depcruise --output-type dot --do-not-follow '^node_modules($|/)' function-apps/api/attorneys case-assignments case-docket case-history case-summary cases consolidations healthcheck offices orders orders-manual-sync orders-sync ../lib | dot -T svg > ../../docs/architecture/dependency-cruiser/functions/dependency-graph_api_${current_time}.svg", + "dependency-cruiser:ci": "npx depcruise --output-type err-long function-apps/api/attorneys case-assignments case-docket case-history case-summary cases consolidations healthcheck offices orders orders-manual-sync orders-sync ../lib ", + "itest:okta-group-api": "CAMS_LOGIN_PROVIDER=okta npx ts-node lib/testing/isolated-integration/test-okta-group-api.ts", + "itest:export-office-csv": "CAMS_LOGIN_PROVIDER=okta npx ts-node ../lib/testing/isolated-integration/export-office-csv.ts" } } diff --git a/backend/tsconfig.build.json b/backend/tsconfig.build.json new file mode 100644 index 000000000..43ffdae92 --- /dev/null +++ b/backend/tsconfig.build.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "outDir": "dist" + }, + "extends": "./tsconfig.json", + "exclude": ["**/*.test.ts", "**/testing*", "**/fake*", "**/testing/*", + "function-apps" + ] +} diff --git a/backend/functions/tsconfig.json b/backend/tsconfig.json similarity index 81% rename from backend/functions/tsconfig.json rename to backend/tsconfig.json index ce3ea8bb6..ab1da766c 100644 --- a/backend/functions/tsconfig.json +++ b/backend/tsconfig.json @@ -7,6 +7,6 @@ "strict": false, "resolveJsonModule": true }, - "references": [{ "path": "../../common" }], + "references": [{ "path": "../common"}], "exclude": ["node_modules"] } diff --git a/common/src/cams/events.test.ts b/common/src/cams/events.test.ts index 1b90ea819..2a813dfc7 100644 --- a/common/src/cams/events.test.ts +++ b/common/src/cams/events.test.ts @@ -26,7 +26,7 @@ const substantiveConsolidationChildCase: Consolidation[] = [ }), ]; -describe('Event domain helper functions', () => { +describe('Event domain helper function-apps', () => { describe('isJointAdministrationLeadCase', () => { test('should return true', () => { expect(isJointAdministrationLeadCase(jointAdministrationLeadCase)).toBeTruthy(); diff --git a/common/src/cams/users.test.ts b/common/src/cams/users.test.ts index a2f60f4c2..a739d3046 100644 --- a/common/src/cams/users.test.ts +++ b/common/src/cams/users.test.ts @@ -2,7 +2,7 @@ import MockData from './test-utilities/mock-data'; import { REGION_02_GROUP_NY, REGION_02_GROUP_SE } from './test-utilities/mock-user'; import { getCourtDivisionCodes, getGroupDesignators } from './users'; -describe('users helper functions tests', () => { +describe('users helper function-apps tests', () => { describe('getCourtDivisionCodes tests', () => { test('should get division codes from a user with offices', () => { const user = MockData.getCamsUser({ diff --git a/docs/architecture/dependency-cruiser/functions/current.svg b/docs/architecture/dependency-cruiser/functions/current.svg index 1fadda8d1..4e773ff0c 100644 --- a/docs/architecture/dependency-cruiser/functions/current.svg +++ b/docs/architecture/dependency-cruiser/functions/current.svg @@ -728,7 +728,7 @@ - + node_modules/@azure/functions @@ -740,7 +740,7 @@ - + attorneys/attorneys.function.ts->node_modules/@azure/functions @@ -782,7 +782,7 @@ - + lib/adapters/utils/application-context-creator.ts->node_modules/@azure/functions @@ -1061,7 +1061,7 @@ - + case-assignments/case.assignment.function.ts->node_modules/@azure/functions @@ -1085,7 +1085,7 @@ - + lib/adapters/types/basic.d.ts->node_modules/@azure/functions @@ -1232,7 +1232,7 @@ - + case-docket/case-docket.function.ts->node_modules/@azure/functions @@ -1475,7 +1475,7 @@ - + case-history/case-history.function.ts->node_modules/@azure/functions @@ -1679,7 +1679,7 @@ - + case-summary/case-summary.function.ts->node_modules/@azure/functions @@ -1757,7 +1757,7 @@ - + cases/cases.function.ts->node_modules/@azure/functions @@ -1943,7 +1943,7 @@ - + consolidations/consolidations.function.ts->node_modules/@azure/functions @@ -2627,7 +2627,7 @@ - + healthcheck/healthcheck.function.ts->node_modules/@azure/functions @@ -5138,7 +5138,7 @@ - + lib/adapters/services/logger.service.ts->node_modules/@azure/functions @@ -6686,7 +6686,7 @@ - + offices/offices.function.ts->node_modules/@azure/functions @@ -6770,7 +6770,7 @@ - + orders-manual-sync/orders-manual-sync.function.ts->node_modules/@azure/functions @@ -6869,7 +6869,7 @@ - + orders-sync/orders-sync.function.ts->node_modules/@azure/functions @@ -6965,7 +6965,7 @@ - + orders/orders.function.ts->node_modules/@azure/functions diff --git a/docs/architecture/dependency-cruiser/functions/dependency-graph_2023-09-18_1237.svg b/docs/architecture/dependency-cruiser/functions/dependency-graph_2023-09-18_1237.svg index ad578035e..c97f676b0 100644 --- a/docs/architecture/dependency-cruiser/functions/dependency-graph_2023-09-18_1237.svg +++ b/docs/architecture/dependency-cruiser/functions/dependency-graph_2023-09-18_1237.svg @@ -211,7 +211,7 @@ - + node_modules/@azure/functions @@ -223,7 +223,7 @@ - + lib/adapters/controllers/attorneys.controller.ts->node_modules/@azure/functions @@ -280,7 +280,7 @@ - + lib/adapters/utils/http.ts->node_modules/@azure/functions @@ -331,7 +331,7 @@ - + attorneys/attorneys.function.ts->node_modules/@azure/functions @@ -383,7 +383,7 @@ no-circular - + lib/adapters/utils/application-context-creator.ts->node_modules/@azure/functions @@ -500,7 +500,7 @@ - + lib/adapters/controllers/case.assignment.controller.ts->node_modules/@azure/functions @@ -605,7 +605,7 @@ - + case-assignments/case.assignment.function.ts->node_modules/@azure/functions @@ -677,7 +677,7 @@ - + cases/cases.function.ts->node_modules/@azure/functions @@ -743,7 +743,7 @@ - + lib/adapters/controllers/cases.controller.ts->node_modules/@azure/functions @@ -836,7 +836,7 @@ - + lib/adapters/types/basic.d.ts->node_modules/@azure/functions @@ -1121,7 +1121,7 @@ - + healthcheck/healthcheck.function.ts->node_modules/@azure/functions @@ -1382,7 +1382,7 @@ - + lib/adapters/controllers/users.controller.ts->node_modules/@azure/functions @@ -2558,7 +2558,7 @@ - + lib/adapters/gateways/mock-cases.gateway.ts->node_modules/@azure/functions @@ -2759,7 +2759,7 @@ - + lib/adapters/services/logger.service.test.ts->node_modules/@azure/functions @@ -3264,7 +3264,7 @@ - + users/users.function.ts->node_modules/@azure/functions diff --git a/docs/architecture/dependency-cruiser/functions/dependency-graph_2023-09-26_1701.svg b/docs/architecture/dependency-cruiser/functions/dependency-graph_2023-09-26_1701.svg index ad578035e..c97f676b0 100644 --- a/docs/architecture/dependency-cruiser/functions/dependency-graph_2023-09-26_1701.svg +++ b/docs/architecture/dependency-cruiser/functions/dependency-graph_2023-09-26_1701.svg @@ -211,7 +211,7 @@ - + node_modules/@azure/functions @@ -223,7 +223,7 @@ - + lib/adapters/controllers/attorneys.controller.ts->node_modules/@azure/functions @@ -280,7 +280,7 @@ - + lib/adapters/utils/http.ts->node_modules/@azure/functions @@ -331,7 +331,7 @@ - + attorneys/attorneys.function.ts->node_modules/@azure/functions @@ -383,7 +383,7 @@ no-circular - + lib/adapters/utils/application-context-creator.ts->node_modules/@azure/functions @@ -500,7 +500,7 @@ - + lib/adapters/controllers/case.assignment.controller.ts->node_modules/@azure/functions @@ -605,7 +605,7 @@ - + case-assignments/case.assignment.function.ts->node_modules/@azure/functions @@ -677,7 +677,7 @@ - + cases/cases.function.ts->node_modules/@azure/functions @@ -743,7 +743,7 @@ - + lib/adapters/controllers/cases.controller.ts->node_modules/@azure/functions @@ -836,7 +836,7 @@ - + lib/adapters/types/basic.d.ts->node_modules/@azure/functions @@ -1121,7 +1121,7 @@ - + healthcheck/healthcheck.function.ts->node_modules/@azure/functions @@ -1382,7 +1382,7 @@ - + lib/adapters/controllers/users.controller.ts->node_modules/@azure/functions @@ -2558,7 +2558,7 @@ - + lib/adapters/gateways/mock-cases.gateway.ts->node_modules/@azure/functions @@ -2759,7 +2759,7 @@ - + lib/adapters/services/logger.service.test.ts->node_modules/@azure/functions @@ -3264,7 +3264,7 @@ - + users/users.function.ts->node_modules/@azure/functions diff --git a/docs/architecture/dependency-cruiser/functions/dependency-graph_2023-09-27_1700.svg b/docs/architecture/dependency-cruiser/functions/dependency-graph_2023-09-27_1700.svg index 52fc8ace5..7ef051dd0 100644 --- a/docs/architecture/dependency-cruiser/functions/dependency-graph_2023-09-27_1700.svg +++ b/docs/architecture/dependency-cruiser/functions/dependency-graph_2023-09-27_1700.svg @@ -206,7 +206,7 @@ - + node_modules/@azure/functions @@ -218,7 +218,7 @@ - + lib/adapters/controllers/attorneys.controller.ts->node_modules/@azure/functions @@ -275,7 +275,7 @@ - + lib/adapters/utils/http.ts->node_modules/@azure/functions @@ -326,7 +326,7 @@ - + attorneys/attorneys.function.ts->node_modules/@azure/functions @@ -378,7 +378,7 @@ no-circular - + lib/adapters/utils/application-context-creator.ts->node_modules/@azure/functions @@ -495,7 +495,7 @@ - + lib/adapters/controllers/case.assignment.controller.ts->node_modules/@azure/functions @@ -600,7 +600,7 @@ - + case-assignments/case.assignment.function.ts->node_modules/@azure/functions @@ -672,7 +672,7 @@ - + cases/cases.function.ts->node_modules/@azure/functions @@ -738,7 +738,7 @@ - + lib/adapters/controllers/cases.controller.ts->node_modules/@azure/functions @@ -831,7 +831,7 @@ - + lib/adapters/types/basic.d.ts->node_modules/@azure/functions @@ -1071,7 +1071,7 @@ - + healthcheck/healthcheck.function.ts->node_modules/@azure/functions @@ -2013,7 +2013,7 @@ - + lib/adapters/gateways/mock-cases.gateway.ts->node_modules/@azure/functions @@ -2079,7 +2079,7 @@ - + lib/adapters/services/logger.service.test.ts->node_modules/@azure/functions diff --git a/docs/architecture/dependency-cruiser/functions/dependency-graph_2023-10-04_1610.svg b/docs/architecture/dependency-cruiser/functions/dependency-graph_2023-10-04_1610.svg index 518d6a137..3cbf86608 100644 --- a/docs/architecture/dependency-cruiser/functions/dependency-graph_2023-10-04_1610.svg +++ b/docs/architecture/dependency-cruiser/functions/dependency-graph_2023-10-04_1610.svg @@ -206,7 +206,7 @@ - + node_modules/@azure/functions @@ -218,7 +218,7 @@ - + lib/adapters/controllers/attorneys.controller.ts->node_modules/@azure/functions @@ -275,7 +275,7 @@ - + lib/adapters/utils/http.ts->node_modules/@azure/functions @@ -326,7 +326,7 @@ - + attorneys/attorneys.function.ts->node_modules/@azure/functions @@ -378,7 +378,7 @@ no-circular - + lib/adapters/utils/application-context-creator.ts->node_modules/@azure/functions @@ -495,7 +495,7 @@ - + lib/adapters/controllers/case.assignment.controller.ts->node_modules/@azure/functions @@ -600,7 +600,7 @@ - + case-assignments/case.assignment.function.ts->node_modules/@azure/functions @@ -666,7 +666,7 @@ - + cases/cases.function.ts->node_modules/@azure/functions @@ -732,7 +732,7 @@ - + lib/adapters/controllers/cases.controller.ts->node_modules/@azure/functions @@ -849,7 +849,7 @@ - + lib/adapters/types/basic.d.ts->node_modules/@azure/functions @@ -1106,7 +1106,7 @@ - + healthcheck/healthcheck.function.ts->node_modules/@azure/functions @@ -2166,7 +2166,7 @@ - + lib/adapters/gateways/mock-cases.gateway.ts->node_modules/@azure/functions @@ -2232,7 +2232,7 @@ - + lib/adapters/services/logger.service.test.ts->node_modules/@azure/functions diff --git a/docs/architecture/dependency-cruiser/functions/dependency-graph_api_2023-10-19_1223.svg b/docs/architecture/dependency-cruiser/functions/dependency-graph_api_2023-10-19_1223.svg index 56fb60d10..20431c044 100644 --- a/docs/architecture/dependency-cruiser/functions/dependency-graph_api_2023-10-19_1223.svg +++ b/docs/architecture/dependency-cruiser/functions/dependency-graph_api_2023-10-19_1223.svg @@ -398,7 +398,7 @@ - + node_modules/@azure/functions @@ -410,7 +410,7 @@ - + attorneys/attorneys.function.ts->node_modules/@azure/functions @@ -470,7 +470,7 @@ no-circular - + lib/adapters/utils/application-context-creator.ts->node_modules/@azure/functions @@ -731,7 +731,7 @@ - + case-assignments/case.assignment.function.ts->node_modules/@azure/functions @@ -749,7 +749,7 @@ - + lib/adapters/types/basic.d.ts->node_modules/@azure/functions @@ -863,7 +863,7 @@ - + cases/cases.function.ts->node_modules/@azure/functions @@ -1289,7 +1289,7 @@ - + healthcheck/healthcheck.function.ts->node_modules/@azure/functions @@ -2501,7 +2501,7 @@ - + lib/adapters/gateways/mock-cases.gateway.ts->node_modules/@azure/functions @@ -2567,7 +2567,7 @@ - + lib/adapters/services/logger.service.test.ts->node_modules/@azure/functions diff --git a/docs/architecture/dependency-cruiser/functions/dependency-graph_api_2023-12.svg b/docs/architecture/dependency-cruiser/functions/dependency-graph_api_2023-12.svg index 518d6a137..3cbf86608 100644 --- a/docs/architecture/dependency-cruiser/functions/dependency-graph_api_2023-12.svg +++ b/docs/architecture/dependency-cruiser/functions/dependency-graph_api_2023-12.svg @@ -206,7 +206,7 @@ - + node_modules/@azure/functions @@ -218,7 +218,7 @@ - + lib/adapters/controllers/attorneys.controller.ts->node_modules/@azure/functions @@ -275,7 +275,7 @@ - + lib/adapters/utils/http.ts->node_modules/@azure/functions @@ -326,7 +326,7 @@ - + attorneys/attorneys.function.ts->node_modules/@azure/functions @@ -378,7 +378,7 @@ no-circular - + lib/adapters/utils/application-context-creator.ts->node_modules/@azure/functions @@ -495,7 +495,7 @@ - + lib/adapters/controllers/case.assignment.controller.ts->node_modules/@azure/functions @@ -600,7 +600,7 @@ - + case-assignments/case.assignment.function.ts->node_modules/@azure/functions @@ -666,7 +666,7 @@ - + cases/cases.function.ts->node_modules/@azure/functions @@ -732,7 +732,7 @@ - + lib/adapters/controllers/cases.controller.ts->node_modules/@azure/functions @@ -849,7 +849,7 @@ - + lib/adapters/types/basic.d.ts->node_modules/@azure/functions @@ -1106,7 +1106,7 @@ - + healthcheck/healthcheck.function.ts->node_modules/@azure/functions @@ -2166,7 +2166,7 @@ - + lib/adapters/gateways/mock-cases.gateway.ts->node_modules/@azure/functions @@ -2232,7 +2232,7 @@ - + lib/adapters/services/logger.service.test.ts->node_modules/@azure/functions diff --git a/ops/cloud-deployment/backend-api-deploy.bicep b/ops/cloud-deployment/backend-api-deploy.bicep index c29d4459c..e48db2b55 100644 --- a/ops/cloud-deployment/backend-api-deploy.bicep +++ b/ops/cloud-deployment/backend-api-deploy.bicep @@ -37,11 +37,29 @@ var planTypeToSkuMap = { param stackName string = 'ustp-cams' -param functionName string +@description('Azure functions version') +param functionsVersion string = '~4' + +@description('Storage account name. Default creates unique name from resource group id and stack name') +@minLength(3) +@maxLength(24) +param apiFunctionStorageName string = 'ustpfunc${uniqueString(resourceGroup().id, apiFunctionName)}' + +@description('Storage account name. Default creates unique name from resource group id and stack name') +@minLength(3) +@maxLength(24) +param migrationFunctionStorageName string = 'ustpmigr${uniqueString(resourceGroup().id, apiFunctionName)}' + +param apiFunctionName string + +param apiFunctionSubnetId string + +param migrationFunctionName string + +param migrationFunctionSubnetId string param virtualNetworkResourceGroupName string -param functionSubnetId string param privateEndpointSubnetId string @@ -69,14 +87,6 @@ param loginProvider string @description('Is ustp deployment') param isUstpDeployment bool -@description('Azure functions version') -param functionsVersion string = '~4' - -@description('Storage account name. Default creates unique name from resource group id and stack name') -@minLength(3) -@maxLength(24) -param functionsStorageName string = 'ustpfunc${uniqueString(resourceGroup().id, functionName)}' - @description('List of origins to allow. Need to include protocol') param corsAllowOrigins array = [] @@ -130,9 +140,6 @@ resource appConfigIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@202 scope: resourceGroup(kvAppConfigResourceGroupName) } -/* - App service plan (hosting plan) for Azure functions instances -*/ resource servicePlan 'Microsoft.Web/serverfarms@2022-09-01' = { location: location name: planName @@ -152,14 +159,12 @@ resource servicePlan 'Microsoft.Web/serverfarms@2022-09-01' = { } } -/* - Storage resource for Azure functions -*/ -resource storageAccount 'Microsoft.Storage/storageAccounts@2022-09-01' = { - name: functionsStorageName +//Storage Account Resources +resource apiFunctionStorageAccount 'Microsoft.Storage/storageAccounts@2022-09-01' = { + name: apiFunctionStorageName location: location tags: { - 'Stack Name': functionName + 'Stack Name': apiFunctionName } sku: { name: 'Standard_LRS' @@ -171,65 +176,24 @@ resource storageAccount 'Microsoft.Storage/storageAccounts@2022-09-01' = { } } -module appInsights './lib/app-insights/app-insights.bicep' = if (createApplicationInsights) { - name: '${functionName}-application-insights-module' - params: { - location: location - kind: 'web' - appInsightsName: 'appi-${functionName}' - applicationType: 'web' - workspaceResourceId: analyticsWorkspaceId - } -} - -module diagnosticSettings './lib/app-insights/diagnostics-settings-func.bicep' = if (createApplicationInsights) { - name: '${functionName}-diagnostic-settings-module' - params: { - functionAppName: functionName - workspaceResourceId: analyticsWorkspaceId +resource migrationFunctonStorageAccount 'Microsoft.Storage/storageAccounts@2022-09-01' = { + name: migrationFunctionStorageName + location: location + tags: { + 'Stack Name': apiFunctionName } - dependsOn: [ - appInsights - functionApp - ] -} - -module healthAlertRule './lib/monitoring-alerts/metrics-alert-rule.bicep' = if (createAlerts) { - name: '${functionName}-healthcheck-alert-rule-module' - params: { - alertName: '${functionName}-health-check-alert' - appId: functionApp.id - timeAggregation: 'Average' - operator: 'LessThan' - targetResourceType: 'Microsoft.Web/sites' - metricName: 'HealthCheckStatus' - severity: 2 - threshold: 100 - actionGroupName: actionGroupName - actionGroupResourceGroupName: actionGroupResourceGroupName + sku: { + name: 'Standard_LRS' } -} - -module httpAlertRule './lib/monitoring-alerts/metrics-alert-rule.bicep' = if (createAlerts) { - name: '${functionName}-http-error-alert-rule-module' - params: { - alertName: '${functionName}-http-error-alert' - appId: functionApp.id - timeAggregation: 'Total' - operator: 'GreaterThanOrEqual' - targetResourceType: 'Microsoft.Web/sites' - metricName: 'Http5xx' - severity: 1 - threshold: 1 - actionGroupName: actionGroupName - actionGroupResourceGroupName: actionGroupResourceGroupName + kind: 'Storage' + properties: { + supportsHttpsTrafficOnly: true + defaultToOAuthAuthentication: true } } -/* - Create functionapp -*/ +//Function App Resources var userAssignedIdentities = union( { '${appConfigIdentity.id}': {} @@ -237,8 +201,8 @@ var userAssignedIdentities = union( createSqlServerVnetRule ? { '${sqlIdentity.id}': {} } : {} ) -resource functionApp 'Microsoft.Web/sites@2022-09-01' = { - name: functionName +resource apiFunctionApp 'Microsoft.Web/sites@2022-09-01' = { + name: apiFunctionName location: location kind: 'functionapp,linux' identity: { @@ -249,7 +213,7 @@ resource functionApp 'Microsoft.Web/sites@2022-09-01' = { serverFarmId: servicePlan.id enabled: true httpsOnly: true - virtualNetworkSubnetId: functionSubnetId + virtualNetworkSubnetId: apiFunctionSubnetId keyVaultReferenceIdentity: appConfigIdentity.id } dependsOn: [ @@ -258,14 +222,65 @@ resource functionApp 'Microsoft.Web/sites@2022-09-01' = { ] } + +resource migrationFunctionApp 'Microsoft.Web/sites@2022-09-01' = { + name: migrationFunctionName + location: location + kind: 'functionapp,linux' + identity: { + type: 'UserAssigned' + userAssignedIdentities: userAssignedIdentities + } + properties: { + serverFarmId: servicePlan.id + enabled: true + httpsOnly: true + virtualNetworkSubnetId: migrationFunctionSubnetId + keyVaultReferenceIdentity: appConfigIdentity.id + } + dependsOn: [ + appConfigIdentity + sqlIdentity + ] +} + +//Create App Insights +module apiFunctionAppInsights 'lib/app-insights/function-app-insights.bicep' = { + name:'appi-${apiFunctionName}-module' + scope: resourceGroup() + params: { + actionGroupName: actionGroupName + actionGroupResourceGroupName: actionGroupResourceGroupName + analyticsWorkspaceId: analyticsWorkspaceId + createAlerts: createAlerts + createApplicationInsights: createApplicationInsights + functionAppName: apiFunctionName + } + dependsOn: [ + apiFunctionApp + ] +} + +module migrationFunctionAppInsights 'lib/app-insights/function-app-insights.bicep' = { + name:'appi-${migrationFunctionName}-module' + scope: resourceGroup() + params: { + actionGroupName: actionGroupName + actionGroupResourceGroupName: actionGroupResourceGroupName + analyticsWorkspaceId: analyticsWorkspaceId + createAlerts: createAlerts + createApplicationInsights: createApplicationInsights + functionAppName: migrationFunctionName + } + dependsOn: [ + migrationFunctionApp + ] +} + //TODO: Clear segregation with DXTR vs ACMS variable/secret naming in GitHub and ADO secret libraries -var applicationSettings = concat( +var baseApplicationSettings = concat( [ - { - name: 'AzureWebJobsStorage' - value: 'DefaultEndpointsProtocol=https;AccountName=${storageAccount.name};EndpointSuffix=${environment().suffixes.storage};AccountKey=${storageAccount.listKeys().keys[0].value}' - } { name: 'FUNCTIONS_EXTENSION_VERSION' value: functionsVersion @@ -371,9 +386,6 @@ var applicationSettings = concat( value: 'main' } ], - createApplicationInsights - ? [{ name: 'APPLICATIONINSIGHTS_CONNECTION_STRING', value: appInsights.outputs.connectionString }] - : [], isUstpDeployment ? [ { name: 'MSSQL_USER', value: '@Microsoft.KeyVault(VaultName=${kvAppConfigName};SecretName=MSSQL-USER)' } @@ -387,6 +399,34 @@ var applicationSettings = concat( ] ) +//Migration Function Application Settings +var migrationApplicationSettings = concat( + [ + { + name: 'AzureWebJobsStorage' + value: 'DefaultEndpointsProtocol=https;AccountName=${migrationFunctonStorageAccount.name};EndpointSuffix=${environment().suffixes.storage};AccountKey=${migrationFunctonStorageAccount.listKeys().keys[0].value}' + } + ], + baseApplicationSettings, + createApplicationInsights + ? [{ name: 'APPLICATIONINSIGHTS_CONNECTION_STRING', value: migrationFunctionAppInsights.outputs.connectionString }] + : [] +) + +//API Function Application Settings +var apiApplicationSettings = concat( + [ + { + name: 'AzureWebJobsStorage' + value: 'DefaultEndpointsProtocol=https;AccountName=${apiFunctionStorageAccount.name};EndpointSuffix=${environment().suffixes.storage};AccountKey=${apiFunctionStorageAccount.listKeys().keys[0].value}' + } + ], + baseApplicationSettings, + createApplicationInsights + ? [{ name: 'APPLICATIONINSIGHTS_CONNECTION_STRING', value: apiFunctionAppInsights.outputs.connectionString }] + : [] +) + var ipSecurityRestrictionsRules = concat( [ { @@ -410,8 +450,39 @@ var ipSecurityRestrictionsRules = concat( : [] ) -resource functionAppConfig 'Microsoft.Web/sites/config@2022-09-01' = { - parent: functionApp +resource apiFunctionConfig 'Microsoft.Web/sites/config@2022-09-01' = { + parent: apiFunctionApp + name: 'web' + properties: { + cors: { + allowedOrigins: corsAllowOrigins + } + numberOfWorkers: 1 + alwaysOn: true + http20Enabled: true + functionAppScaleLimit: 0 + minimumElasticInstanceCount: 0 + publicNetworkAccess: 'Enabled' + ipSecurityRestrictions: ipSecurityRestrictionsRules + ipSecurityRestrictionsDefaultAction: 'Deny' + scmIpSecurityRestrictions: [ + { + ipAddress: 'Any' + action: 'Deny' + priority: 2147483647 + name: 'Deny all' + description: 'Deny all access' + } + ] + scmIpSecurityRestrictionsDefaultAction: 'Deny' + scmIpSecurityRestrictionsUseMain: false + linuxFxVersion: linuxFxVersionMap['${functionsRuntime}'] + appSettings: apiApplicationSettings + } +} + +resource migrationFunctionConfig 'Microsoft.Web/sites/config@2022-09-01' = { + parent: migrationFunctionApp name: 'web' properties: { cors: { @@ -437,18 +508,34 @@ resource functionAppConfig 'Microsoft.Web/sites/config@2022-09-01' = { scmIpSecurityRestrictionsDefaultAction: 'Deny' scmIpSecurityRestrictionsUseMain: false linuxFxVersion: linuxFxVersionMap['${functionsRuntime}'] - appSettings: applicationSettings + appSettings: migrationApplicationSettings } } -module privateEndpoint './lib/network/subnet-private-endpoint.bicep' = { - name: '${functionName}-pep-module' +//Private Endpoints +module apiPrivateEndpoint './lib/network/subnet-private-endpoint.bicep' = { + name: '${apiFunctionName}-pep-module' scope: resourceGroup(virtualNetworkResourceGroupName) params: { privateLinkGroup: 'sites' - stackName: functionName + stackName: apiFunctionName location: location - privateLinkServiceId: functionApp.id + privateLinkServiceId: apiFunctionApp.id + privateEndpointSubnetId: privateEndpointSubnetId + privateDnsZoneName: privateDnsZoneName + privateDnsZoneResourceGroup: privateDnsZoneResourceGroup + privateDnsZoneSubscriptionId: privateDnsZoneSubscriptionId + } +} + +module migrationFunctionPrivateEndpoint './lib/network/subnet-private-endpoint.bicep' = { + name: '${migrationFunctionName}-pep-module' + scope: resourceGroup(virtualNetworkResourceGroupName) + params: { + privateLinkGroup: 'sites' + stackName: migrationFunctionName + location: location + privateLinkServiceId: migrationFunctionApp.id privateEndpointSubnetId: privateEndpointSubnetId privateDnsZoneName: privateDnsZoneName privateDnsZoneResourceGroup: privateDnsZoneResourceGroup @@ -458,25 +545,35 @@ module privateEndpoint './lib/network/subnet-private-endpoint.bicep' = { var createSqlServerVnetRule = !empty(sqlServerResourceGroupName) && !empty(sqlServerName) && !isUstpDeployment -module setSqlServerVnetRule './lib/network/sql-vnet-rule.bicep' = if (createSqlServerVnetRule) { +module setMigrationFunctionSqlServerVnetRule './lib/network/sql-vnet-rule.bicep' = if (createSqlServerVnetRule) { scope: resourceGroup(sqlServerResourceGroupName) - name: '${functionName}-sql-vnet-rule-module' + name: '${migrationFunctionName}-sql-vnet-rule-module' params: { - stackName: functionName + stackName: migrationFunctionName sqlServerName: sqlServerName - subnetId: functionSubnetId + subnetId: migrationFunctionSubnetId } } -// Creates a managed identity that would be used to grant access to functionapp instance -var sqlIdentityName = !empty(sqlServerIdentityName) ? sqlServerIdentityName : 'id-sql-${functionName}-readonly' +module setApiFunctionSqlServerVnetRule './lib/network/sql-vnet-rule.bicep' = if (createSqlServerVnetRule) { + scope: resourceGroup(sqlServerResourceGroupName) + name: '${apiFunctionName}-sql-vnet-rule-module' + params: { + stackName: apiFunctionName + sqlServerName: sqlServerName + subnetId: apiFunctionSubnetId + } +} + +// Creates a managed identity that would be used to grant access to function instance +var sqlIdentityName = !empty(sqlServerIdentityName) ? sqlServerIdentityName : 'id-sql-${apiFunctionName}-readonly' var sqlIdentityRG = !empty(sqlServerIdentityResourceGroupName) ? sqlServerIdentityResourceGroupName : sqlServerResourceGroupName module sqlManagedIdentity './lib/identity/managed-identity.bicep' = if (createSqlServerVnetRule) { scope: resourceGroup(sqlIdentityRG) - name: '${functionName}-sql-identity-module' + name: '${apiFunctionName}-sql-identity-module' params: { managedIdentityName: sqlIdentityName location: location @@ -487,8 +584,3 @@ resource sqlIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-3 name: sqlIdentityName scope: resourceGroup(sqlIdentityRG) } - -output functionAppName string = functionApp.name -output functionAppId string = functionApp.id -output createdSqlServerVnetRule bool = createSqlServerVnetRule -output keyVaultId string = functionApp.properties.keyVaultReferenceIdentity diff --git a/ops/cloud-deployment/frontend-webapp-deploy.bicep b/ops/cloud-deployment/frontend-webapp-deploy.bicep index 8c04db27d..58b4d5252 100644 --- a/ops/cloud-deployment/frontend-webapp-deploy.bicep +++ b/ops/cloud-deployment/frontend-webapp-deploy.bicep @@ -316,6 +316,3 @@ module privateEndpoint './lib/network/subnet-private-endpoint.bicep' = { privateDnsZoneSubscriptionId: privateDnsZoneSubscriptionId } } -output webappName string = webapp.name -output webappId string = webapp.id -output webappUrl string = webapp.properties.hostNameSslStates[0].name diff --git a/ops/cloud-deployment/lib/app-insights/function-app-insights.bicep b/ops/cloud-deployment/lib/app-insights/function-app-insights.bicep new file mode 100644 index 000000000..f372d58e6 --- /dev/null +++ b/ops/cloud-deployment/lib/app-insights/function-app-insights.bicep @@ -0,0 +1,72 @@ +param functionAppName string + +param analyticsWorkspaceId string + +param createAlerts bool + +param createApplicationInsights bool + +param actionGroupName string + +param actionGroupResourceGroupName string + +resource functionApp 'Microsoft.Web/sites@2022-09-01' existing = { + name: functionAppName +} + +module appInsights '../app-insights/app-insights.bicep' = if (createApplicationInsights) { + name: '${functionAppName}-application-insights-module' + params: { + location: functionApp.location + kind: 'web' + appInsightsName: 'appi-${functionAppName}' + applicationType: 'web' + workspaceResourceId: analyticsWorkspaceId + } +} + +module diagnosticSettings '../app-insights/diagnostics-settings-func.bicep' = if (createApplicationInsights) { + name: '${functionAppName}-diagnostic-settings-module' + params: { + functionAppName: functionAppName + workspaceResourceId: analyticsWorkspaceId + } + dependsOn: [ + appInsights + functionApp + ] +} + +module healthAlertRule '../monitoring-alerts/metrics-alert-rule.bicep' = if (createAlerts) { + name: '${functionAppName}-healthcheck-alert-rule-module' + params: { + alertName: '${functionAppName}-health-check-alert' + appId: functionApp.id + timeAggregation: 'Average' + operator: 'LessThan' + targetResourceType: 'Microsoft.Web/sites' + metricName: 'HealthCheckStatus' + severity: 2 + threshold: 100 + actionGroupName: actionGroupName + actionGroupResourceGroupName: actionGroupResourceGroupName + } +} + +module httpAlertRule '../monitoring-alerts/metrics-alert-rule.bicep' = if (createAlerts) { + name: '${functionAppName}-http-error-alert-rule-module' + params: { + alertName: '${functionAppName}-http-error-alert' + appId: functionApp.id + timeAggregation: 'Total' + operator: 'GreaterThanOrEqual' + targetResourceType: 'Microsoft.Web/sites' + metricName: 'Http5xx' + severity: 1 + threshold: 1 + actionGroupName: actionGroupName + actionGroupResourceGroupName: actionGroupResourceGroupName + } +} + +output connectionString string = appInsights.outputs.connectionString diff --git a/ops/cloud-deployment/lib/network/ustp-cams-network.bicep b/ops/cloud-deployment/lib/network/ustp-cams-network.bicep index 6748c0c46..9f9a5444d 100644 --- a/ops/cloud-deployment/lib/network/ustp-cams-network.bicep +++ b/ops/cloud-deployment/lib/network/ustp-cams-network.bicep @@ -14,17 +14,23 @@ param virtualNetworkName string = 'vnet-${stackName}' param linkVnetIds array = [] -param vnetAddressPrefix array = [ '10.10.0.0/16' ] +param vnetAddressPrefix array = ['10.10.0.0/16'] -param functionName string = '${stackName}-node-api' +param apiFunctionName string = '${stackName}-node-api' -param functionSubnetName string = 'snet-${functionName}' +param apiFunctionSubnetName string = 'snet-${apiFunctionName}' -param functionSubnetAddressPrefix string = '10.10.11.0/28' +param apiFunctionSubnetAddressPrefix string = '10.10.11.0/28' -param webappName string = '${stackName}-node-api' +param migrationFunctionName string = '${stackName}-migration' -param webappSubnetName string = 'snet-${functionName}' +param migrationSubnetAddressPrefix string = '10.10.14.0/28' + +param migrationSubnetName string = 'snet-${migrationFunctionName}' + +param webappName string = '${stackName}-webapp' + +param webappSubnetName string = 'snet-${apiFunctionName}' param webappSubnetAddressPrefix string = '10.10.10.0/28' @@ -41,35 +47,32 @@ param privateDnsZoneResourceGroup string = networkResourceGroupName @description('Private DNS Zone subscription, all 3 params here are set because the Prod environment uses a different subscription and RG for these') param privateDnsZoneSubscriptionId string = subscription().subscriptionId - - -module targetVnet './vnet.bicep' = - if (deployVnet) { - name: '${stackName}-vnet-module' - scope: resourceGroup(networkResourceGroupName) - params: { - vnetName: virtualNetworkName - vnetAddressPrefix: vnetAddressPrefix - location: location - } +module targetVnet './vnet.bicep' = if (deployVnet) { + name: '${stackName}-vnet-module' + scope: resourceGroup(networkResourceGroupName) + params: { + vnetName: virtualNetworkName + vnetAddressPrefix: vnetAddressPrefix + location: location } +} resource ustpVirtualNetwork 'Microsoft.Network/virtualNetworks@2022-09-01' existing = { name: virtualNetworkName scope: resourceGroup(networkResourceGroupName) } -module ustpDnsZones './private-dns-zones.bicep' ={ - name: '${stackName}-network-dns-module' - scope: resourceGroup(privateDnsZoneSubscriptionId, privateDnsZoneResourceGroup) - params: { - stackName: stackName - virtualNetworkId: ustpVirtualNetwork.id - linkVnetIds: linkVnetIds - privateDnsZoneName: privateDnsZoneName - deployDns: deployDns - privateDnsZoneSubscriptionId: privateDnsZoneSubscriptionId - privateDnsZoneResourceGroup: privateDnsZoneResourceGroup +module ustpDnsZones './private-dns-zones.bicep' = { + name: '${stackName}-network-dns-module' + scope: resourceGroup(privateDnsZoneSubscriptionId, privateDnsZoneResourceGroup) + params: { + stackName: stackName + virtualNetworkId: ustpVirtualNetwork.id + linkVnetIds: linkVnetIds + privateDnsZoneName: privateDnsZoneName + deployDns: deployDns + privateDnsZoneSubscriptionId: privateDnsZoneSubscriptionId + privateDnsZoneResourceGroup: privateDnsZoneResourceGroup } } @@ -104,13 +107,50 @@ module privateEndpointSubnet './subnet.bicep' = { ] } -module functionSubnet './subnet.bicep' = { - name: '${functionName}-subnet-module' +module apiFunctionSubnet './subnet.bicep' = { + name: '${apiFunctionName}-subnet-module' + scope: resourceGroup(networkResourceGroupName) + params: { + virtualNetworkName: virtualNetworkName + subnetName: apiFunctionSubnetName + subnetAddressPrefix: apiFunctionSubnetAddressPrefix + subnetServiceEndpoints: [ + { + service: 'Microsoft.Sql' + locations: [ + location + ] + } + { + service: 'Microsoft.AzureCosmosDB' + locations: [ + location + ] + } + ] + subnetDelegations: [ + { + name: 'Microsoft.Web/serverfarms' + properties: { + serviceName: 'Microsoft.Web/serverfarms' + } + } + ] + } + dependsOn: [ + ustpVirtualNetwork + ustpDnsZones + privateEndpointSubnet + ] +} + +module migrationFunctionSubnet './subnet.bicep' = { + name: '${migrationFunctionName}-subnet-module' scope: resourceGroup(networkResourceGroupName) params: { virtualNetworkName: virtualNetworkName - subnetName: functionSubnetName - subnetAddressPrefix: functionSubnetAddressPrefix + subnetName: migrationSubnetName + subnetAddressPrefix: migrationSubnetAddressPrefix subnetServiceEndpoints: [ { service: 'Microsoft.Sql' @@ -138,6 +178,7 @@ module functionSubnet './subnet.bicep' = { ustpVirtualNetwork ustpDnsZones privateEndpointSubnet + apiFunctionSubnet ] } @@ -161,13 +202,19 @@ module webappSubnet './subnet.bicep' = { dependsOn: [ ustpVirtualNetwork ustpDnsZones - functionSubnet + apiFunctionSubnet + migrationFunctionSubnet ] } output privateEndpointSubnetName string = privateEndpointSubnet.outputs.subnetName output privateEndpointSubnetId string = privateEndpointSubnet.outputs.subnetId -output functionSubnetId string = functionSubnet.outputs.subnetId +output apiFunctionSubnetId string = apiFunctionSubnet.outputs.subnetId output webappSubnetId string = webappSubnet.outputs.subnetId +output migrationFunctionSubnetId string = migrationFunctionSubnet.outputs.subnetId output privateDnsZoneId string = ustpDnsZones.outputs.privateDnsZoneId -output cosmosDbAllowedSubnets array = [privateEndpointSubnet.outputs.subnetId, functionSubnet.outputs.subnetId] +output cosmosDbAllowedSubnets array = [ + privateEndpointSubnet.outputs.subnetId + apiFunctionSubnet.outputs.subnetId + migrationFunctionSubnet.outputs.subnetId +] diff --git a/ops/cloud-deployment/main.bicep b/ops/cloud-deployment/main.bicep index f0eeafabc..8c33ed837 100644 --- a/ops/cloud-deployment/main.bicep +++ b/ops/cloud-deployment/main.bicep @@ -44,11 +44,17 @@ param webappSubnetAddressPrefix string = '10.10.10.0/28' ]) param webappPlanType string = 'P1v2' -param functionName string = '${stackName}-node-api' +param apiFunctionName string = '${stackName}-node-api' -param functionSubnetName string = 'snet-${functionName}' +param apiFunctionSubnetName string = 'snet-${apiFunctionName}' -param functionSubnetAddressPrefix string = '10.10.11.0/28' +param apiFunctionSubnetAddressPrefix string = '10.10.11.0/28' + +param migrationFunctionName string = '${stackName}-migration' + +param migrationSubnetAddressPrefix string = '10.10.14.0/28' + +param migrationSubnetName string = 'snet-${migrationFunctionName}' @description('Plan type to determine functionapp service plan Sku') @allowed([ @@ -120,8 +126,6 @@ param camsReactSelectHash string param cosmosDatabaseName string - -//TODO: Break out Alerts && Action Group module actionGroup './lib/monitoring-alerts/alert-action-group.bicep' = if (createAlerts) { name: '${actionGroupName}-action-group-module' @@ -139,9 +143,12 @@ module network './lib//network/ustp-cams-network.bicep' = { networkResourceGroupName: networkResourceGroupName deployVnet: deployVnet location: location - functionName: functionName - functionSubnetName: functionSubnetName - functionSubnetAddressPrefix: functionSubnetAddressPrefix + apiFunctionName: apiFunctionName + apiFunctionSubnetName: apiFunctionSubnetName + apiFunctionSubnetAddressPrefix: apiFunctionSubnetAddressPrefix + migrationFunctionName: migrationFunctionName + migrationSubnetAddressPrefix: migrationSubnetAddressPrefix + migrationSubnetName: migrationSubnetName webappName: webappName webappSubnetAddressPrefix: webappSubnetAddressPrefix webappSubnetName: webappSubnetName @@ -172,7 +179,7 @@ module ustpWebapp 'frontend-webapp-deploy.bicep' = { createAlerts: createAlerts actionGroupName: actionGroupName actionGroupResourceGroupName: analyticsResourceGroupName - targetApiServerHost: '${functionName}.azurewebsites${azHostSuffix} ${functionName}-${slotName}.azurewebsites${azHostSuffix}' //adding both production and slot hostname to CSP + targetApiServerHost: '${apiFunctionName}.azurewebsites${azHostSuffix} ${apiFunctionName}-${slotName}.azurewebsites${azHostSuffix}' //adding both production and slot hostname to CSP ustpIssueCollectorHash: ustpIssueCollectorHash camsReactSelectHash: camsReactSelectHash webappSubnetId: network.outputs.webappSubnetId @@ -196,10 +203,12 @@ module ustpFunctions 'backend-api-deploy.bicep' = { analyticsWorkspaceId: analyticsWorkspaceId location: location planType: functionPlanType - planName: 'plan-${functionName}' - functionName: functionName + planName: 'plan-${stackName}-functions' + apiFunctionName: apiFunctionName + apiFunctionSubnetId: network.outputs.apiFunctionSubnetId + migrationFunctionName: migrationFunctionName + migrationFunctionSubnetId: network.outputs.migrationFunctionSubnetId functionsRuntime: 'node' - functionSubnetId: network.outputs.functionSubnetId sqlServerName: sqlServerName sqlServerResourceGroupName: sqlServerResourceGroupName sqlServerIdentityName: sqlServerIdentityName @@ -227,12 +236,3 @@ module ustpFunctions 'backend-api-deploy.bicep' = { network ] } - -// main.bicep outputs - -resource identityKeyVaultAppConfig 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' existing = { - name: idKeyvaultAppConfiguration - scope: resourceGroup(kvAppConfigResourceGroupName) -} -output keyVaultId string = identityKeyVaultAppConfig.id -output keyVaultManagedIdName string = identityKeyVaultAppConfig.name diff --git a/ops/scripts/pipeline/azure-deploy.sh b/ops/scripts/pipeline/azure-deploy.sh index 8af2415ac..cd51ef69f 100755 --- a/ops/scripts/pipeline/azure-deploy.sh +++ b/ops/scripts/pipeline/azure-deploy.sh @@ -16,12 +16,12 @@ deployment_parameters='' is_ustp_deployment=false inputParams=() -requiredUSTPParams=("--mssqlRequestTimeout" "--isUstpDeployment" "--resource-group" "--file" "--stackName" "--networkResourceGroupName" "--virtualNetworkName" "--analyticsWorkspaceId" "--idKeyvaultAppConfiguration" "--kvAppConfigName" "--cosmosDatabaseName" "--deployVnet" "--camsReactSelectHash" "--ustpIssueCollectorHash" "--createAlerts" "--deployAppInsights" "--functionPlanType" "--webappPlanType" "--loginProvider" "--loginProviderConfig" "--sqlServerName" "--sqlServerResourceGroupName" "--oktaUrl" "--location" "--webappSubnetName" "--functionSubnetName" "--privateEndpointSubnetName" "--webappSubnetAddressPrefix" "--privateEndpointSubnetAddressPrefix" "--functionSubnetAddressPrefix" "--privateDnsZoneName" "--privateDnsZoneResourceGroup" "--privateDnsZoneSubscriptionId" "--analyticsResourceGroupName" "--kvAppConfigResourceGroupName" "--deployDns") +requiredUSTPParams=("--mssqlRequestTimeout" "--isUstpDeployment" "--resource-group" "--file" "--stackName" "--networkResourceGroupName" "--virtualNetworkName" "--analyticsWorkspaceId" "--idKeyvaultAppConfiguration" "--kvAppConfigName" "--cosmosDatabaseName" "--deployVnet" "--camsReactSelectHash" "--ustpIssueCollectorHash" "--createAlerts" "--deployAppInsights" "--functionPlanType" "--webappPlanType" "--loginProvider" "--loginProviderConfig" "--sqlServerName" "--sqlServerResourceGroupName" "--oktaUrl" "--location" "--webappSubnetName" "--apiFunctionSubnetName" "--privateEndpointSubnetName" "--webappSubnetAddressPrefix" "--privateEndpointSubnetAddressPrefix" "--apiFunctionSubnetAddressPrefix" "--migrationSubnetName" "--migrationSubnetAddressPrefix" "--privateDnsZoneName" "--privateDnsZoneResourceGroup" "--privateDnsZoneSubscriptionId" "--analyticsResourceGroupName" "--kvAppConfigResourceGroupName" "--deployDns") requiredFlexionParams=("--mssqlRequestTimeout" "--resource-group" "--file" "--stackName" "--networkResourceGroupName" "--kvAppConfigName" "--kvAppConfigResourceGroupName" "--virtualNetworkName" "--analyticsWorkspaceId" "--idKeyvaultAppConfiguration" "--cosmosDatabaseName" "--deployVnet" "--camsReactSelectHash" "--ustpIssueCollectorHash" "--createAlerts" "--deployAppInsights" "--functionPlanType" "--webappPlanType" "--loginProvider" "--loginProviderConfig" "--sqlServerName" "--sqlServerResourceGroupName" "--sqlServerIdentityName" "--actionGroupName" "--oktaUrl") # shellcheck disable=SC2034 # REASON: to have a reference for all possible parameters -allParams=("--mssqlRequestTimeout" "--isUstpDeployment" "--resource-group" "--file" "--stackName" "--networkResourceGroupName" "--virtualNetworkName" "--analyticsWorkspaceId" "--idKeyvaultAppConfiguration" "--kvAppConfigName" "--cosmosDatabaseName" "--deployVnet" "--camsReactSelectHash" "--ustpIssueCollectorHash" "--createAlerts" "--deployAppInsights" "--functionPlanType" "--webappPlanType" "--loginProvider" "--loginProviderConfig" "--sqlServerName" "--sqlServerResourceGroupName" "--sqlServerIdentityResourceGroupName" "--sqlServerIdentityName" "--actionGroupName" "--oktaUrl" "--location" "--webappSubnetName" "--functionSubnetName" "--privateEndpointSubnetName" "--webappSubnetAddressPrefix" "--functionSubnetAddressPrefix" "--vnetAddressPrefix" "--linkVnetIds" "--privateDnsZoneName" "--privateDnsZoneResourceGroup" "--privateDnsZoneSubscriptionId" "--analyticsResourceGroupName" "--kvAppConfigResourceGroupName" "--deployDns" "--azHostSuffix" "--allowVeracodeScan") +allParams=("--mssqlRequestTimeout" "--isUstpDeployment" "--resource-group" "--file" "--stackName" "--networkResourceGroupName" "--virtualNetworkName" "--analyticsWorkspaceId" "--idKeyvaultAppConfiguration" "--kvAppConfigName" "--cosmosDatabaseName" "--deployVnet" "--camsReactSelectHash" "--ustpIssueCollectorHash" "--createAlerts" "--deployAppInsights" "--functionPlanType" "--webappPlanType" "--loginProvider" "--loginProviderConfig" "--sqlServerName" "--sqlServerResourceGroupName" "--sqlServerIdentityResourceGroupName" "--sqlServerIdentityName" "--actionGroupName" "--oktaUrl" "--location" "--webappSubnetName" "--apiFunctionSubnetName" "--privateEndpointSubnetName" "--webappSubnetAddressPrefix" "--apiFunctionSubnetAddressPrefix" "--migrationSubnetName" "--migrationSubnetAddressPrefix" "--vnetAddressPrefix" "--linkVnetIds" "--privateDnsZoneName" "--privateDnsZoneResourceGroup" "--privateDnsZoneSubscriptionId" "--analyticsResourceGroupName" "--kvAppConfigResourceGroupName" "--deployDns" "--azHostSuffix" "--allowVeracodeScan") function az_vnet_exists_func() { @@ -158,16 +158,28 @@ while [[ $# -gt 0 ]]; do deployment_parameters="${deployment_parameters} ${webapp_subnet_address_prefix_param}" shift 2 ;; - --functionSubnetName) + --apiFunctionSubnetName) inputParams+=("${1}") - function_subnet_name_param="functionSubnetName=${2}" - deployment_parameters="${deployment_parameters} ${function_subnet_name_param}" + api_function_subnet_name_param="apiFunctionSubnetName=${2}" + deployment_parameters="${deployment_parameters} ${api_function_subnet_name_param}" shift 2 ;; - --functionSubnetAddressPrefix) + --apiFunctionSubnetAddressPrefix) inputParams+=("${1}") - function_subnet_address_prefix_param="functionSubnetAddressPrefix=${2}" - deployment_parameters="${deployment_parameters} ${function_subnet_address_prefix_param}" + api_function_subnet_address_prefix_param="apiFunctionSubnetAddressPrefix=${2}" + deployment_parameters="${deployment_parameters} ${api_function_subnet_address_prefix_param}" + shift 2 + ;; + --migrationFunctionSubnetName) + inputParams+=("${1}") + migration_function_subnet_name_param="migrationFunctionSubnetName=${2}" + deployment_parameters="${deployment_parameters} ${migration_function_subnet_name_param}" + shift 2 + ;; + --migrationFunctionSubnetAddressPrefix) + inputParams+=("${1}") + migration_function_subnet_address_prefix_param="migrationFunctionSubnetAddressPrefix=${2}" + deployment_parameters="${deployment_parameters} ${migration_function_subnet_address_prefix_param}" shift 2 ;; --privateEndpointSubnetName) diff --git a/ops/scripts/pipeline/endpoint-test.sh b/ops/scripts/pipeline/endpoint-test.sh index 059b1a3ed..4c6e21e1d 100755 --- a/ops/scripts/pipeline/endpoint-test.sh +++ b/ops/scripts/pipeline/endpoint-test.sh @@ -2,7 +2,7 @@ # Title: endpoint-test.sh # Description: Verify 200 response from frontend and backend -# Usage: ./endpoint-test.sh --webappName webappName --apiName apiName --slot slotName --hostSuffix hostSuffix +# Usage: ./endpoint-test.sh --webappName webappName --apiFunctionName apiFunctionName --slot slotName --hostSuffix hostSuffix # # Exitcodes # ========== @@ -18,11 +18,11 @@ isLocalRun='' while [[ $# -gt 0 ]]; do case $1 in -h | --help) - echo "./endpoint-test.sh --webappName webappName --apiName apiName --slot slotName --hostSuffix hostSuffix" + echo "./endpoint-test.sh --webappName webappName --apiFunctionName apiFunctionName --slot slotName --hostSuffix hostSuffix" exit 0 ;; - --apiName) + --apiFunctionName) api_name="${2}" shift 2 ;; diff --git a/ops/scripts/pipeline/slots/az-slot-api-resource-deploy.sh b/ops/scripts/pipeline/slots/az-slot-api-resource-deploy.sh index 2177855c8..3c413550d 100755 --- a/ops/scripts/pipeline/slots/az-slot-api-resource-deploy.sh +++ b/ops/scripts/pipeline/slots/az-slot-api-resource-deploy.sh @@ -2,7 +2,7 @@ # Title: az-slot-api-resource-deploy.sh # Description: Helper script to provision Azure slot deployment resources for Azure functionapp api -# Usage: ./az-slot-api-resource-deploy.sh -h --resourceGroup resourceGroupName --idResourceGroup managedIdResourceGroup --webappName webappName --apiName functionappName --slotName staging --kvIdName kvManagedIdName --sqlIdName sqlManagedIdName --cosmosIdName cosmosManagedIdName --storageAccName apiStorageAccountName --databaseName cosmosDbName --infoSha environmentHash --isUstpDeployment +# Usage: ./az-slot-api-resource-deploy.sh -h --resourceGroup resourceGroupName --idResourceGroup managedIdResourceGroup --webappName webappName --apiFunctionName functionappName --slotName staging --kvIdName kvManagedIdName --sqlIdName sqlManagedIdName --cosmosIdName cosmosManagedIdName --apiStorageAccName apiStorageAccountName --databaseName cosmosDbName --infoSha environmentHash --isUstpDeployment # # Exitcodes # ========== @@ -18,7 +18,7 @@ info_sha='' while [[ $# -gt 0 ]]; do case $1 in -h | --help) - echo "USAGE: az-slot-api-resource-deploy.sh -h --resourceGroup resourceGroupName --idResourceGroup managedIdResourceGroup --webappName webappName --apiName functionappName --slotName staging --kvIdName kvManagedIdName --sqlIdName sqlManagedIdName --storageAccName apiStorageAccountName --databaseName cosmosDbName --infoSha environmentHash" + echo "USAGE: az-slot-api-resource-deploy.sh -h --resourceGroup resourceGroupName --idResourceGroup managedIdResourceGroup --webappName webappName --apiFunctionName functionappName --slotName staging --kvIdName kvManagedIdName --sqlIdName sqlManagedIdName --apiStorageAccName apiStorageAccountName --databaseName cosmosDbName --infoSha environmentHash" exit 0 ;; --resourceGroup) @@ -31,8 +31,13 @@ while [[ $# -gt 0 ]]; do shift 2 ;; - --apiName) - api_name="${2}" + --apiFunctionName) + api_function_name="${2}" + shift 2 + ;; + + --migrationFunctionName) + migration_function_name="${2}" shift 2 ;; @@ -54,8 +59,12 @@ while [[ $# -gt 0 ]]; do sql_id_name="${2}" shift 2 ;; - --storageAccName) - storage_acc_name="${2}" + --apiStorageAccName) + api_storage_acc_name="${2}" + shift 2 + ;; + --migrationStorageAccName) + migration_storage_acc_name="${2}" shift 2 ;; --databaseName) @@ -78,14 +87,21 @@ done #Function App Slot Deployment and Configuration echo "Creating Storage account for Node API Slot..." -az storage account create --name "$storage_acc_name" --resource-group "$app_rg" -o json -storage_acc_key=$(az storage account keys list -g "$app_rg" --account-name "$storage_acc_name" --query '[0].value' -o tsv) +az storage account create --name "$api_storage_acc_name" --resource-group "$app_rg" -o json -echo "Creating Node API Staging Slot..." -az functionapp deployment slot create --name "$api_name" --resource-group "$app_rg" --slot "$slot_name" --configuration-source "$api_name" +az storage account create --name "$migration_storage_acc_name" --resource-group "$app_rg" -o json -echo "Setting deployment slot settings for storage account and cosmos database for e2e testing..." +api_storage_acc_key=$(az storage account keys list -g "$app_rg" --account-name "$api_storage_acc_name" --query '[0].value' -o tsv) +migration_storage_acc_key=$(az storage account keys list -g "$app_rg" --account-name "$migration_storage_acc_name" --query '[0].value' -o tsv) + + +echo "Creating API Function Staging Slot..." +az functionapp deployment slot create --name "$api_function_name" --resource-group "$app_rg" --slot "$slot_name" --configuration-source "$api_function_name" +echo "Creating Node API Function Staging Slot..." +az functionapp deployment slot create --name "$migration_function_name" --resource-group "$app_rg" --slot "$slot_name" --configuration-source "$migration_function_name" + +echo "Setting deployment slot settings for storage account and cosmos database for e2e testing..." databaseName=$database_name if [[ ${is_ustp_deployment} == true ]]; then @@ -102,13 +118,16 @@ echo "Database Name :${databaseName}" commitSha=$(git rev-parse HEAD) -az functionapp config appsettings set -g "$app_rg" -n "$api_name" --slot "$slot_name" --settings "INFO_SHA=$commitSha" --slot-settings COSMOS_DATABASE_NAME="$databaseName" MyTaskHub="${slot_name}" AzureWebJobsStorage="DefaultEndpointsProtocol=https;AccountName=${storage_acc_name};EndpointSuffix=core.usgovcloudapi.net;AccountKey=${storage_acc_key}" +az functionapp config appsettings set -g "$app_rg" -n "$api_function_name" --slot "$slot_name" --settings "INFO_SHA=$commitSha" --slot-settings COSMOS_DATABASE_NAME="$databaseName" MyTaskHub="${slot_name}" AzureWebJobsStorage="DefaultEndpointsProtocol=https;AccountName=${api_storage_acc_name};EndpointSuffix=core.usgovcloudapi.net;AccountKey=${api_storage_acc_key}" +az functionapp config appsettings set -g "$app_rg" -n "$migration_function_name" --slot "$slot_name" --settings "INFO_SHA=$commitSha" --slot-settings COSMOS_DATABASE_NAME="$databaseName" MyTaskHub="${slot_name}" AzureWebJobsStorage="DefaultEndpointsProtocol=https;AccountName=${migration_storage_acc_name};EndpointSuffix=core.usgovcloudapi.net;AccountKey=${migration_storage_acc_key}" echo "Setting CORS Allowed origins for the API..." -az functionapp cors add -g "$app_rg" --name "$api_name" --slot "$slot_name" --allowed-origins "https://${webapp_name}-${slot_name}.azurewebsites.us" +az functionapp cors add -g "$app_rg" --name "$api_function_name" --slot "$slot_name" --allowed-origins "https://${webapp_name}-${slot_name}.azurewebsites.us" + +echo "Setting CORS Allowed origins for Migration function" +az functionapp cors add -g "$app_rg" --name "$api_function_name" --slot "$slot_name" --allowed-origins "https://portal.azure.us" -echo "Assigning managed Identities..." # Identities occasionally come through with improper id for usage here, this constructs that kv_ref_id=$(az identity list -g "$id_rg" --query "[?name == '$kv_id_name'].id" -o tsv) identities="$kv_ref_id" @@ -118,11 +137,21 @@ if [[ ${sql_id_name} != null && ${sql_id_name} != '' ]]; then identities="$identities $sql_ref_id" fi + +echo "Assigning managed Identities API Function App..." # shellcheck disable=SC2086 # REASON: Adds unwanted quotes after --identities -az functionapp identity assign -g "$app_rg" -n "$api_name" --slot "$slot_name" --identities $identities +az functionapp identity assign -g "$app_rg" -n "$api_function_name" --slot "$slot_name" --identities $identities + +echo "Assigning managed Identities to Migration Function App..." +# shellcheck disable=SC2086 # REASON: Adds unwanted quotes after --identities +az functionapp identity assign -g "$app_rg" -n "$migration_function_name" --slot "$slot_name" --identities $identities + +echo "Setting KeyVaultReferenceIdentity API Function App..." +az functionapp update --resource-group "$app_rg" --name "$api_function_name" --slot "$slot_name" --set keyVaultReferenceIdentity="$kv_ref_id" -echo "Setting KeyVaultReferenceIdentity..." -az functionapp update --resource-group "$app_rg" --name "$api_name" --slot "$slot_name" --set keyVaultReferenceIdentity="$kv_ref_id" +echo "Setting KeyVaultReferenceIdentity for Migration Function App..." +az functionapp update --resource-group "$app_rg" --name "$api_function_name" --slot "$slot_name" --set keyVaultReferenceIdentity="$kv_ref_id" +#TODO: deal with traffic routing if we want to test # shellcheck disable=SC2086 -az webapp traffic-routing set --distribution ${slot_name}=0 --name "${api_name}" --resource-group "${app_rg}" +az webapp traffic-routing set --distribution ${slot_name}=0 --name "${api_function_name}" --resource-group "${app_rg}" diff --git a/ops/scripts/pipeline/slots/az-slot-start-stop-operations.sh b/ops/scripts/pipeline/slots/az-slot-start-stop-operations.sh index 560c94bf0..0af280c67 100755 --- a/ops/scripts/pipeline/slots/az-slot-start-stop-operations.sh +++ b/ops/scripts/pipeline/slots/az-slot-start-stop-operations.sh @@ -4,7 +4,7 @@ # Prerequisite: # - curl # - Azure CLI -# Usage: az-slot-lifecycle.sh -g --apiName --webappName --slotName --operation +# Usage: az-slot-start-stop-operations.sh -g --apiFunctionName --migrationFunctionName --webappName --slotName --operation set -euo pipefail # ensure job step fails in CI pipeline when error occurs @@ -18,8 +18,13 @@ while [[ $# -gt 0 ]]; do shift 2 ;; - --apiName) - api_name="${2}" + --apiFunctionName) + api_function_name="${2}" + shift 2 + ;; + + --migrationFunctionName) + migration_function_name="${2}" shift 2 ;; @@ -46,13 +51,15 @@ done if [[ ${operation} == 'stop' ]]; then echo "Stopping Node API ${slot_name} slot..." - az functionapp stop -g "${app_rg}" --name "${api_name}" --slot "${slot_name}" + az functionapp stop -g "${app_rg}" --name "${api_function_name}" --slot "${slot_name}" + echo "Stopping Migration Function ${slot_name} slot..." + az functionapp stop -g "${app_rg}" --name "${migration_function_name}" --slot "${slot_name}" echo "Stopping Webapp ${slot_name} slot..." az webapp stop -g "${app_rg}" --name "${webapp_name}" --slot "${slot_name}" elif [[ ${operation} == 'start' ]]; then echo "Starting Node API ${slot_name} slot..." - az functionapp start -g "${app_rg}" --name "${api_name}" --slot "${slot_name}" + az functionapp start -g "${app_rg}" --name "${api_function_name}" --slot "${slot_name}" echo "Starting Webapp ${slot_name} slot..." az webapp start -g "${app_rg}" --name "${webapp_name}" --slot "${slot_name}" diff --git a/ops/scripts/pipeline/slots/az-slot-web-resource-deploy.sh b/ops/scripts/pipeline/slots/az-slot-web-resource-deploy.sh index 21d6ea11f..7442c7adc 100755 --- a/ops/scripts/pipeline/slots/az-slot-web-resource-deploy.sh +++ b/ops/scripts/pipeline/slots/az-slot-web-resource-deploy.sh @@ -2,7 +2,7 @@ # Title: az-slot-web-resource-deploy.sh # Description: Helper script to provision Azure slot deployment resources for Azure webapp -# Usage: ./az-slot-web-resource-deploy.sh -h --resourceGroup resourceGroupName --webappName webappName --apiName apiName --slotName staging --subscription networkSubscription --network-rg networkResourceGroup --vnet vnetName --subnet webappSubnetName" +# Usage: ./az-slot-web-resource-deploy.sh -h --resourceGroup resourceGroupName --webappName webappName --apiFunctionName apiFunctionName --slotName staging --subscription networkSubscription --network-rg networkResourceGroup --vnet vnetName --subnet webappSubnetName" # # Exitcodes # ========== @@ -15,7 +15,7 @@ set -euo pipefail # ensure job step fails in CI pipeline when error occurs while [[ $# -gt 0 ]]; do case $1 in -h | --help) - echo "USAGE: az-slot-web-resource-deploy.sh -h --resourceGroup resourceGroupName --webappName webappName --apiName apiName --slotName staging --subscription networkSubscription --network-rg networkResourceGroup --vnet vnetName --subnet webappSubnetName" + echo "USAGE: az-slot-web-resource-deploy.sh -h --resourceGroup resourceGroupName --webappName webappName --apiFunctionName apiFunctionName --slotName staging --subscription networkSubscription --network-rg networkResourceGroup --vnet vnetName --subnet webappSubnetName" exit 0 ;; --resourceGroup) @@ -27,7 +27,7 @@ while [[ $# -gt 0 ]]; do shift 2 ;; - --apiName) + --apiFunctionName) api_name="${2}" shift 2 ;; diff --git a/ops/scripts/utility/audit.sh b/ops/scripts/utility/audit.sh index 9095b53e5..b5dcb8a4d 100755 --- a/ops/scripts/utility/audit.sh +++ b/ops/scripts/utility/audit.sh @@ -59,7 +59,7 @@ trap 'rm -f "$TEMP_FILE"' EXIT cat ./ops/scripts/utility/audit-comment.md >> "$TEMP_FILE" RESULTS=0 -PROJECTS=("backend/functions" "common" "dev-tools" "test/e2e" "user-interface") +PROJECTS=("backend" "common" "dev-tools" "test/e2e" "user-interface") for dir in "${PROJECTS[@]}"; do pushd "${dir}" || exit npm ci diff --git a/ops/scripts/utility/az-delete-branch-resources.sh b/ops/scripts/utility/az-delete-branch-resources.sh index 1e05e73fc..a46dfd139 100755 --- a/ops/scripts/utility/az-delete-branch-resources.sh +++ b/ops/scripts/utility/az-delete-branch-resources.sh @@ -41,8 +41,11 @@ if [[ "${rgAppExists}" == "true" ]]; then echo "Start disconnecting VNET integration" webapp="ustp-cams-dev-${hash_id}-webapp" az webapp vnet-integration remove -g "${app_rg}" -n "${webapp}" - functionapp="ustp-cams-dev-${hash_id}-node-api" - az functionapp vnet-integration remove -g "${app_rg}" -n "${functionapp}" + apiFunctionApp="ustp-cams-dev-${hash_id}-node-api" + az functionapp vnet-integration remove -g "${app_rg}" -n "${apiFunctionApp}" + echo "Completed disconnecting VNET integration" + migrationFunctionApp="ustp-cams-dev-${hash_id}-migration" + az functionapp vnet-integration remove -g "${app_rg}" -n "${migrationFunctionApp}" echo "Completed disconnecting VNET integration" fi diff --git a/ops/scripts/utility/check-outdated.sh b/ops/scripts/utility/check-outdated.sh index 673ca2649..5265900ab 100755 --- a/ops/scripts/utility/check-outdated.sh +++ b/ops/scripts/utility/check-outdated.sh @@ -59,7 +59,7 @@ trap 'rm -f "$TEMP_FILE"' EXIT cat ./ops/scripts/utility/outdated-comment.md >> "$TEMP_FILE" OUTDATED=false -PROJECTS=("backend/functions" "common" "dev-tools" "test/e2e" "user-interface") +PROJECTS=("backend" "common" "dev-tools" "test/e2e" "user-interface") for dir in "${PROJECTS[@]}"; do pushd "${dir}" || exit npm ci diff --git a/ops/scripts/utility/clean-all-projects.sh b/ops/scripts/utility/clean-all-projects.sh index 568fdde6e..efe23c201 100755 --- a/ops/scripts/utility/clean-all-projects.sh +++ b/ops/scripts/utility/clean-all-projects.sh @@ -6,7 +6,7 @@ # From the root directory, run the following command: # ./ops/scripts/utility/clean-all-projects.sh -PROJECTS=("backend/functions" "common" "dev-tools" "test/e2e" "user-interface") +PROJECTS=("backend" "backend/function-apps/api" "backend/function-apps/migration" "common" "dev-tools" "test/e2e" "user-interface") for str in "${PROJECTS[@]}"; do pushd "${str}" || exit diff --git a/ops/scripts/utility/clean-install-all-projects.sh b/ops/scripts/utility/clean-install-all-projects.sh index a6278cebe..82c878a12 100755 --- a/ops/scripts/utility/clean-install-all-projects.sh +++ b/ops/scripts/utility/clean-install-all-projects.sh @@ -6,11 +6,11 @@ # From the root directory, run the following command: # ./ops/scripts/utility/clean-all-projects.sh -PROJECTS=("backend/functions" "common" "dev-tools" "test/e2e" "user-interface") +PROJECTS=("backend" "common" "dev-tools" "test/e2e" "user-interface") for str in "${PROJECTS[@]}"; do pushd "${str}" || exit - echo "Cleaning ${str}." + echo "Clean installing ${str}." npm ci popd || exit done diff --git a/ops/scripts/utility/run-all-tests.sh b/ops/scripts/utility/run-all-tests.sh index 88781d9d2..a3147df43 100755 --- a/ops/scripts/utility/run-all-tests.sh +++ b/ops/scripts/utility/run-all-tests.sh @@ -6,7 +6,7 @@ # From the root directory, run the following command: # ./ops/scripts/utility/run-all-tests.sh -PROJECTS=("backend/functions" "common" "user-interface") +PROJECTS=("backend" "common" "user-interface") for str in "${PROJECTS[@]}"; do pushd "${str}" || exit diff --git a/ops/scripts/utility/update-dependencies.sh b/ops/scripts/utility/update-dependencies.sh index a14721fa6..95710f63b 100755 --- a/ops/scripts/utility/update-dependencies.sh +++ b/ops/scripts/utility/update-dependencies.sh @@ -72,7 +72,7 @@ else fi -PROJECTS=("backend/functions" "common" "dev-tools" "test/e2e" "user-interface") +PROJECTS=("backend" "common" "dev-tools" "test/e2e" "user-interface") for str in "${PROJECTS[@]}"; do pushd "${str}" || exit diff --git a/package.json b/package.json index a6c5ab260..5b1673ea4 100644 --- a/package.json +++ b/package.json @@ -7,12 +7,12 @@ "scripts": { "clean:all": "./ops/scripts/utility/clean-all-projects.sh", "ci:all": "./ops/scripts/utility/clean-install-all-projects.sh", - "start:backend": "cd backend/functions && npm run start", - "start:frontend": "cd user-interface && npm run start", + "start:backend": "pushd backend && npm run start && popd", + "start:frontend": "pushd user-interface && npm run start && popd", "build": "npm run build:common && npm run build:backend && npm run build:frontend", - "build:backend": "cd backend/functions && npm run build", - "build:frontend": "cd user-interface && npm run build", - "build:common": "cd common && npm run build", + "build:backend": "pushd backend && npm run build && npm run build:api && npm run build:migration && popd", + "build:frontend": "pushd user-interface && npm run build && popd", + "build:common": "pushd common && npm run build && popd", "clean-and-build": "npm run clean:all && npm run ci:all && npm run build" } }