From 85614de8fd348d9527609b2bb77f9a002aa2f7e1 Mon Sep 17 00:00:00 2001 From: deonbotha Date: Mon, 9 Mar 2020 15:17:04 +0200 Subject: [PATCH] Settlement v2 (#271) * feature/1095 Close Settlement Window Changes (#220) * Refactor scripts tree structure * Dependencies upgrade * Changed server setup and init. Registered Settlement Window Handler. Added CLI handler management. Shortened {id} paths. Window to PROCESSING state. Settlement window producer. Settlement window consumer. Default config added. Updated package.json scripts * Added broker service health check * SettlementWindowHandler ErrorHandling and async-retry * Fix unit tests. Coverage fails at 91.32% * SettlementWindowHandler Processing * Fix integration tests * Switched the latest release of central-services-shared * Added unit test for API index.js . Code coverage now 89.5 percent * Removed unnecessary commented lines from test * Added unit tests for lib/healthcheck * feature/1096 Create Settlement Changes #1 (#224) * Changed swagger definition * Settlement model validation. Unit tests fail * select distinct * Settlement window content validation. Fixed unit tests * Deleted code to fix the two plugin issues and unit test for Handler - index.js * feature/1097 Create Settlement Changes #2 (#225) * Implemented inserts (not tested). Changed response definition. Unit tests fail * Generate response. Validate proper implementation. Disable failing unit tests to be adjusted * feature/1099 Update Settlement by ID Changes (#229) * Implement updateSettlementByIdChanges enhancement * Entire settlement process verified using various scenarios. Corrections made where applicable * feature/1165 Unit tests for central-settlement part1 * Completed the unit test for register handlers code. * Domain settlement windows close , added unit test * Added more unit testing code to the settlement windows models facade * Added unit tests and fixed existing ones to cover unhappy lines in process * Added unit tests to shared/setup to cope with the service types * Added unit test for shared setup : handler service type - and run handler true without any modules. * Added unit test for settlement window with a handler list * Added unit test to increase code coverage for settlement window facade * Add unit test testing the settlement window state "not Processing" * Added unit test to roll back settlement window facade when error occurs * Added unit test on process to cover rollback on critical error and updated the version on central services shared to "8.8.2", * Added unit testcode to close window * Fixed the knex raw and .join isn't a function errors * Changes: - Added a unit test file and unit tests for SettlementWindow handler - Made some fixes on the SettlementWindow handler * Added last unit test on the facade. the tests are being ran in isolation still. * Added last knex builder stubs to facade unit tests * Combined the Stubs for the facade * Worked on branches to increase covereage Co-authored-by: lazolalucas * feature/1100 Settlement By Currency Wrap Up (#231) * Fixed and extended integration testing for settlement-v2 * Add anchore summary report upload, bump package version to 8.8.0 (#230) * Full coverage for domain/settlement/index & models/lib/enums * Full coverage for inculded scripts * Integration testing config to run properly * Finilize unit tests and full coverage Co-authored-by: Lewis Daly * Feature/1180 enhance get settlement windows by (#238) * Added code changes to DAO and handler to include settlementwindow content * Added code changes to DAO and handler to include settlementwindow content * Added code changes to unit test to increase code coverage * Changed code to fix the integration error * Code review changes : added SettlementWindowContentModel.getBySettlementWindowId function. Unit tests are still failing * Code review changes : Added unit test and fixed unit tests to increase code coverage. * Code review II : Removed settlement window id from response object and added settlement id to it. * Trigger a rebuild. Previous commit failed due to internet failure * Updated swagger definition with the settlementId as integer on the settlementWindowContent * Fixed vulnerabilities * feature/1211 Auto position reset (#240) * Auto position reset functionality * Re-run integration tests * Use newest central-ledger snapshot release for integration tests * feature/1209 Restrict Create Settlement (#249) * Forbid GROSS/IMMEDATE models, when creating new settlement * Corrected typo as per PR request * Feature/926 enhanced get settlement windows by params (#254) * feature/926-EnhancegetSettlementWindowsByParams - Enhanced getSettlementWindowsByParams to query with currency param - Updated the response object to include content * feature/926-EnhancegetSettlementWindowsByParams - Enhanced getSettlementWindowsByParams to query with currency param - Updated the response object to include content * feature/926-EnhancegetSettlementWindowsByParams - Enhanced getSettlementWindowsByParams to query with currency param - Updated the response object to include content * Added async-retry * - Update the facade to be able to query using currency - removed the caret sign ^ from package.json * - Trigger rebuild * Prepare version for PR against master * Trigger circle CI re-run * Downgrade @mojaloop/central-services-database due to integration tests failure * Address PR review request and update dependencies * Updated dependancy * Another test for integration tests * Feature/1241 get settlements by params to include currency (#268) * Re-do code changes to the updated settlements v2 * Added async-retry * Remove caret in package.json * Fixed the filtering on the settlement window(s) per settlement id, added unit test * Fixed the filtering on the settlement window(s) per settlement id, added unit test * Fixed vulnerabilities * Removed the settlement model line in the response object * Removed the settlement model line in the response object * update central ledger * Fix vulnerability * attempt to fix vulnerability * Updated Happi to version 19.1.1 * Fixed the filtering on the settlement window(s) per settlement id, added unit test * Crazy shit happening * test commit * Fixed code review changes * Re-trigger pull request * Revert Recreate DB script * Updated Hapi to LTS version * * Fixed get settlement by params * Included content on the response object * * Fixed Circle ci tests failing * Trigger a rebuild * Removed cache for dependencies under unit test/coverage * Updated circle ci config.yml * Updated circle ci config.yml Co-authored-by: deonbotha * Enhance central-settlement : Return settlement window content for every settlement window when getting settlements by id. (#263) * Re-do code changes to the updated settlements v2 * Added async-retry * Remove caret in package.json * Fixed the filtering on the settlement window(s) per settlement id, added unit test * Fixed the filtering on the settlement window(s) per settlement id, added unit test * Fixed vulnerabilities * Removed the settlement model line in the response object * Removed the settlement model line in the response object * update central ledger * Fix vulnerability * attempt to fix vulnerability * Updated Happi to version 19.1.1 * Fixed the filtering on the settlement window(s) per settlement id, added unit test * Crazy shit happening * test commit * Fixed code review changes * Re-trigger pull request * Revert Recreate DB script * Updated Hapi to LTS version * Added Neal's code review changes for pull request 263 * Update vulnerability issue * Replaced the recursive delete object logic by a "map over" * Ignore the vulnerablity rewire > eslint > espree > acorn for a week Co-authored-by: Georgi Georgiev Co-authored-by: Deon Botha Co-authored-by: lazolalucas Co-authored-by: Lewis Daly --- .circleci/config.yml | 237 +++++++--- audit-resolve.json | 5 + package-lock.json | 429 +++++++++++------- package.json | 11 +- src/domain/settlement/index.js | 39 +- src/models/settlement/facade.js | 11 +- src/models/settlementWindowContent/facade.js | 9 + src/models/settlementWindowContent/index.js | 3 +- test/unit/domain/settlement/index.test.js | 67 ++- test/unit/models/settlement/facade.test.js | 8 +- .../models/settlement/settlementModel.test.js | 1 - .../settlementWindowContent/facade.test.js | 50 ++ 12 files changed, 606 insertions(+), 264 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7b3a9329..697334b9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,14 +1,7 @@ # CircleCI v2.1 Config version: 2.1 - -## -# orbs -# -# Orbs used in this pipeline -## orbs: anchore: anchore/anchore-engine@1.6.0 - deploy-kube: mojaloop/deployment@0.1.6 ## # defaults @@ -16,23 +9,109 @@ orbs: # YAML defaults templates, in alphabetical order ## defaults_Dependencies: &defaults_Dependencies | - apk --no-cache add git - apk --no-cache add ca-certificates - apk --no-cache add curl - apk --no-cache add openssh-client - apk add --no-cache -t build-dependencies make gcc g++ python libtool autoconf automake - npm config set unsafe-perm true - npm install -g node-gyp + apk --no-cache add git + apk --no-cache add ca-certificates + apk --no-cache add curl + apk --no-cache add openssh-client + apk add --no-cache -t build-dependencies make gcc g++ python libtool autoconf automake + npm config set unsafe-perm true + npm install -g node-gyp defaults_awsCliDependencies: &defaults_awsCliDependencies | - apk --no-cache add \ - python \ - py-pip \ - groff \ - less \ - mailcap - pip install --upgrade awscli==1.14.5 s3cmd==2.0.1 python-magic - apk -v --purge del py-pip + apk --no-cache add \ + python \ + py-pip \ + groff \ + less \ + mailcap + pip install --upgrade awscli==1.14.5 s3cmd==2.0.1 python-magic + apk -v --purge del py-pip + +defaults_build_docker_build: &defaults_build_docker_build + name: Build Docker $CIRCLE_TAG image + command: | + echo "Building Docker image: $CIRCLE_TAG" + docker build -t $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$CIRCLE_TAG . + +defaults_build_docker_login: &defaults_build_docker_login + name: Login to Docker Hub + command: | + docker login -u $DOCKER_USER -p $DOCKER_PASS + +defaults_build_docker_publish: &defaults_build_docker_publish + name: Publish Docker image $CIRCLE_TAG & Latest tag to Docker Hub + command: | + echo "Publishing $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$CIRCLE_TAG" + docker push $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$CIRCLE_TAG + echo "Publishing $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$RELEASE_TAG" + docker push $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$RELEASE_TAG + + +defaults_deploy_config_kubernetes_cluster: &defaults_deploy_config_kubernetes_cluster + name: Configure Kubernetes cluster + command: | + echo "Configure Kubernetes cluster ${K8_CLUSTER_NAME}" + kubectl config set-cluster $K8_CLUSTER_NAME --server=$K8_CLUSTER_SERVER --insecure-skip-tls-verify=true + +defaults_deploy_config_kubernetes_context: &defaults_deploy_config_kubernetes_context + name: Confi gure Kubernetes context + command: | + echo "Configure Kubernetes context ${K8_CLUSTER_NAME}" + kubectl config set-context $K8_CLUSTER_NAME --cluster=$K8_CLUSTER_NAME --user=$K8_USER_NAME --namespace=$K8_NAMESPACE + +defaults_deploy_config_kubernetes_credentials: &defaults_deploy_config_kubernetes_credentials + name: Configure Kubernetes credentails + command: | + echo "Configure Kubernetes credentials ${K8_USER_NAME}" + if [ ! -z "$K8_USER_TOKEN" ]; + then + echo "Configure Kubernetes credentials ${K8_USER_NAME} using Token" + kubectl config set-credentials $K8_USER_NAME --token=$K8_USER_TOKEN + else + echo "Configure Kubernetes credentials ${K8_USER_NAME} using Certs" + kubectl config set-credentials $K8_USER_NAME --client-certificate=$CIRCLE_WORKING_DIRECTORY/$AWS_S3_DIR_DEVOPS_DEPLOYMENT_CONFIG_KEYS/$K8_USER_PEM_CERT_FILENAME --client-key=$CIRCLE_WORKING_DIRECTORY/$AWS_S3_DIR_DEVOPS_DEPLOYMENT_CONFIG_KEYS/$K8_USER_PEM_KEY_FILENAME + fi + +defaults_deploy_configure_helm: &defaults_deploy_configure_helm + name: Configure Helm + command: | + helm init --client-only + +defaults_deploy_install_or_upgrade_helm_chart: &defaults_deploy_install_or_upgrade_helm_chart + name: Install or Upgrade Helm Chart + command: | + echo "Install or Upgrade Chart ${K8_RELEASE_NAME} for Docker Image ${DOCKER_ORG}/${CIRCLE_PROJECT_REPONAME}:${CIRCLE_TAG}" + if [ -z "$(helm list -q | grep -E "^${K8_RELEASE_NAME}$")" ] && [ "$(helm list -q | grep -E "^${K8_RELEASE_NAME}$")" != "Error: Unauthorized" ]; + then + echo "Installing ${K8_RELEASE_NAME} new release" + helm install --namespace=$K8_NAMESPACE --name=$K8_RELEASE_NAME --repo=$K8_HELM_REPO --version $K8_HELM_CHART_VERSION $HELM_VALUE_SET_VALUES -f $CIRCLE_WORKING_DIRECTORY/$AWS_S3_DIR_DEVOPS_DEPLOYMENT_CONFIG_HELM/$HELM_VALUE_FILENAME $K8_HELM_CHART_NAME + else + echo "Upgrading ${K8_RELEASE_NAME} release" + helm upgrade $K8_RELEASE_NAME --repo=$K8_HELM_REPO --version $K8_HELM_CHART_VERSION --reuse-values $HELM_VALUE_SET_VALUES -f $CIRCLE_WORKING_DIRECTORY/$AWS_S3_DIR_DEVOPS_DEPLOYMENT_CONFIG_HELM/$HELM_VALUE_FILENAME $K8_HELM_CHART_NAME + fi + +defaults_deploy_prequisites: &defaults_deploy_prequisites + name: Copy deployment pre-requisites from S3 bucket + command: | + if [ -z "$K8_USER_TOKEN" ]; + then + echo "Copying K8 keys into $AWS_S3_DIR_DEVOPS_DEPLOYMENT_CONFIG_KEYS folder" + mkdir $CIRCLE_WORKING_DIRECTORY/$AWS_S3_DIR_DEVOPS_DEPLOYMENT_CONFIG_KEYS + aws s3 cp $AWS_S3_URI_DEVOPS_DEPLOYMENT_CONFIG/$AWS_S3_DIR_DEVOPS_DEPLOYMENT_CONFIG_KEYS/$K8_USER_PEM_KEY_FILENAME $CIRCLE_WORKING_DIRECTORY/$AWS_S3_DIR_DEVOPS_DEPLOYMENT_CONFIG_KEYS/ + aws s3 cp $AWS_S3_URI_DEVOPS_DEPLOYMENT_CONFIG/$AWS_S3_DIR_DEVOPS_DEPLOYMENT_CONFIG_KEYS/$K8_USER_PEM_CERT_FILENAME $CIRCLE_WORKING_DIRECTORY/$AWS_S3_DIR_DEVOPS_DEPLOYMENT_CONFIG_KEYS/ + else + echo "Skipping K8 keys into $AWS_S3_DIR_DEVOPS_DEPLOYMENT_CONFIG_KEYS folder" + fi + + echo "Copying Helm value file into $AWS_S3_DIR_DEVOPS_DEPLOYMENT_CONFIG_HELM folder for $K8_RELEASE_NAME release" + mkdir $CIRCLE_WORKING_DIRECTORY/$AWS_S3_DIR_DEVOPS_DEPLOYMENT_CONFIG_HELM + aws s3 cp $AWS_S3_URI_DEVOPS_DEPLOYMENT_CONFIG/$AWS_S3_DIR_DEVOPS_DEPLOYMENT_CONFIG_HELM/$HELM_VALUE_FILENAME $CIRCLE_WORKING_DIRECTORY/$AWS_S3_DIR_DEVOPS_DEPLOYMENT_CONFIG_HELM/ + +defaults_deploy_set_kubernetes_context: &defaults_deploy_set_kubernetes_context + name: Set Kubernetes context + command: | + echo "Configure Kubernetes context ${K8_CLUSTER_NAME}" + kubectl config use-context $K8_CLUSTER_NAME defaults_license_scanner: &defaults_license_scanner name: Install and set up license-scanner @@ -40,6 +119,15 @@ defaults_license_scanner: &defaults_license_scanner git clone https://github.com/mojaloop/license-scanner /tmp/license-scanner cd /tmp/license-scanner && make build default-files set-up +defaults_slack_announcement: &defaults_slack_announcement + name: Slack announcement for tag releases + command: | + curl -X POST \ + $SLACK_WEBHOOK_ANNOUNCEMENT \ + -H 'Content-type: application/json' \ + -H 'cache-control: no-cache' \ + -d "{\"text\": \"*${CIRCLE_PROJECT_REPONAME}* - Release \`${CIRCLE_TAG}\`: https://github.com/mojaloop/${CIRCLE_PROJECT_REPONAME}/releases/tag/${CIRCLE_TAG}\"}" + ## # Executors # @@ -48,13 +136,18 @@ defaults_license_scanner: &defaults_license_scanner executors: default-docker: working_directory: /home/circleci/project - docker: + docker: - image: node:12.16.0-alpine default-machine: machine: image: ubuntu-1604:201903-01 + helm-kube: + working_directory: /home/circleci/project + docker: + - image: hypnoglow/kubernetes-helm + ## # Jobs # @@ -71,9 +164,6 @@ jobs: - run: name: Access npm folder as root command: cd $(npm root -g)/npm - - run: - name: Install interledgerjs/five-bells-ledger-api-tests - command: npm install github:interledgerjs/five-bells-ledger-api-tests - run: name: Update NPM install command: npm install @@ -95,16 +185,12 @@ jobs: - restore_cache: keys: - dependency-cache-{{ checksum "package.json" }} - - dependency-cache- + - run: + name: Install tape, tapes and tap-xunit + command: npm install -g tape tapes tap-xunit - run: name: Create dir for test results command: mkdir -p ./test/results - - run: - name: Install tape and tap-xunit - command: npm install -g tape tap-xunit - - run: - name: Install tapes - command: npm install -g tapes - run: name: Execute unit tests command: npm -s run test:xunit > ./test/results/tape.xml @@ -127,10 +213,9 @@ jobs: - restore_cache: keys: - dependency-cache-{{ checksum "package.json" }} - - dependency-cache- - run: name: Execute code coverage check - command: npm -s run test:coverage + command: npm -s run test:coverage-check - store_artifacts: path: coverage prefix: test @@ -142,7 +227,7 @@ jobs: if [ "${CIRCLE_BRANCH}" == "master" ]; then echo "Sending lcov.info to SonarQube..." - aws s3 cp coverage/lcov.info $AWS_S3_DIR_SONARQUBE/central-settlement/lcov.info + aws s3 cp coverage/lcov.info $AWS_S3_DIR_SONARQUBE/$CIRCLE_PROJECT_REPONAME/lcov.info else echo "Not a release (env CIRCLE_BRANCH != 'master'), skipping sending lcov.info to SonarQube." fi @@ -152,20 +237,21 @@ jobs: steps: - checkout - restore_cache: - key: dependency-cache-{{ checksum "CACHE_VERSION.txt" }}-{{ checksum "package.json" }} + key: dependency-cache-{{ checksum "package.json" }} - run: name: Create dir for test results command: mkdir -p ./test/results - run: name: Execute integration tests command: npm -s run test:integration + no_output_timeout: 25m - store_artifacts: path: ./test/results prefix: test - store_test_results: path: ./test/results - vulnerability-check: + vulnerability-check: executor: default-docker steps: - checkout @@ -173,9 +259,7 @@ jobs: name: Install general dependencies command: *defaults_Dependencies - restore_cache: - keys: - - dependency-cache-{{ checksum "package.json" }} - - dependency-cache- + key: dependency-cache-{{ checksum "package.json" }} - run: name: Create dir for test results command: mkdir -p ./audit/results @@ -196,9 +280,7 @@ jobs: - run: <<: *defaults_license_scanner - restore_cache: - keys: - - dependency-cache-{{ checksum "package.json" }} - - dependency-cache- + key: dependency-cache-{{ checksum "package.json" }} - run: name: Prune non-production packages before running license-scanner command: npm prune --production @@ -214,10 +296,7 @@ jobs: steps: - checkout - run: - name: Build Docker $CIRCLE_TAG image - command: | - echo "Building Docker image: $CIRCLE_TAG" - docker build -t $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$CIRCLE_TAG . + <<: *defaults_build_docker_build - run: name: Save docker image to workspace command: docker save -o /tmp/docker-image.tar $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$CIRCLE_TAG @@ -228,6 +307,7 @@ jobs: license-scan: executor: default-machine + # <<: *defaults_test_env steps: - attach_workspace: at: /tmp @@ -303,36 +383,43 @@ jobs: name: Load the pre-built docker image from workspace command: docker load -i /tmp/docker-image.tar - run: - name: Login to Docker Hub - command: docker login -u $DOCKER_USER -p $DOCKER_PASS + <<: *defaults_build_docker_login + - run: + name: setup environment vars for release/snapshot + command: ./.circleci/_set_up_deploy_envs.sh - run: name: Re-tag pre built image command: | docker tag $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$CIRCLE_TAG $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$RELEASE_TAG - run: - name: Publish Docker image $CIRCLE_TAG & Latest tag to Docker Hub - command: | - echo "Publishing $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$CIRCLE_TAG" - docker push $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$CIRCLE_TAG - echo "Publishing $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$RELEASE_TAG" - docker push $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$RELEASE_TAG + <<: *defaults_build_docker_publish - run: - name: Slack announcement for tag releases - command: | - curl -X POST \ - $SLACK_WEBHOOK_ANNOUNCEMENT \ - -H 'Content-type: application/json' \ - -H 'cache-control: no-cache' \ - -d "{\"text\": \"*${CIRCLE_PROJECT_REPONAME}* - Release \`${CIRCLE_TAG}\`: https://github.com/mojaloop/${CIRCLE_PROJECT_REPONAME}/releases/tag/${CIRCLE_TAG}\"}" + <<: *defaults_slack_announcement deploy: - executor: deploy-kube/helm-kube + executor: helm-kube steps: - checkout - - deploy-kube/setup_and_run: - helm_set_values: | - --set central.centralsettlement.image.repository=$DOCKER_ORG/$CIRCLE_PROJECT_REPONAME \ - --set central.centralsettlement.image.tag=$CIRCLE_TAG + - run: + name: Install AWS CLI dependencies + command: *defaults_awsCliDependencies + - run: + name: setup environment vars for release/snapshot + command: ./.circleci/_set_up_deploy_envs.sh + - run: + <<: *defaults_deploy_prequisites + - run: + <<: *defaults_deploy_config_kubernetes_cluster + - run: + <<: *defaults_deploy_config_kubernetes_credentials + - run: + <<: *defaults_deploy_config_kubernetes_context + - run: + <<: *defaults_deploy_set_kubernetes_context + - run: + <<: *defaults_deploy_configure_helm + - run: + <<: *defaults_deploy_install_or_upgrade_helm_chart ## # Workflows @@ -374,7 +461,7 @@ workflows: ignore: - /feature*/ - /bugfix*/ - - test-integration: + - vulnerability-check: context: org-global requires: - setup @@ -385,7 +472,7 @@ workflows: ignore: - /feature*/ - /bugfix*/ - - vulnerability-check: + - audit-licenses: context: org-global requires: - setup @@ -396,7 +483,7 @@ workflows: ignore: - /feature*/ - /bugfix*/ - - audit-licenses: + - test-integration: context: org-global requires: - setup @@ -418,7 +505,7 @@ workflows: - audit-licenses filters: tags: - only: /v[0-9]+(\.[0-9]+)*(\-snapshot)?/ + only: /v[0-9]+(\.[0-9]+)*(\-snapshot)?(\-hotfix(\.[0-9]+))?/ branches: ignore: - /.*/ @@ -428,7 +515,7 @@ workflows: - build filters: tags: - only: /v[0-9]+(\.[0-9]+)*(\-snapshot)?/ + only: /v[0-9]+(\.[0-9]+)*(\-snapshot)?(\-hotfix(\.[0-9]+))?/ branches: ignore: - /.*/ @@ -438,7 +525,7 @@ workflows: - build filters: tags: - only: /v[0-9]+(\.[0-9]+)*(\-snapshot)?/ + only: /v[0-9]+(\.[0-9]+)*(\-snapshot)?(\-hotfix(\.[0-9]+))?/ branches: ignore: - /.*/ @@ -449,7 +536,7 @@ workflows: - image-scan filters: tags: - only: /v[0-9]+(\.[0-9]+)*(\-snapshot)?/ + only: /v[0-9]+(\.[0-9]+)*(\-snapshot)?(\-hotfix(\.[0-9]+))?/ branches: ignore: - /.*/ diff --git a/audit-resolve.json b/audit-resolve.json index 99fe4d03..b41fa7d0 100644 --- a/audit-resolve.json +++ b/audit-resolve.json @@ -4,6 +4,11 @@ "decision": "ignore", "madeAt": 1582888595088, "expiresAt": 1585480556972 + }, + "1488|rewire>eslint>espree>acorn": { + "decision": "ignore", + "madeAt": 1583750630347, + "expiresAt": 1584355380671 } }, "rules": {}, diff --git a/package-lock.json b/package-lock.json index d43d63a0..89964b20 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1278,6 +1278,27 @@ "@hapi/hoek": "9.x.x" } }, + "@mojaloop/central-services-shared": { + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/@mojaloop/central-services-shared/-/central-services-shared-9.2.0.tgz", + "integrity": "sha512-RFVXd6hwR66iQzwnU5st68cQBCiJjXHqiQp6sjkUJ+1ElqQjhnDMZJcLM5KAfkpSxDmTwwqqKuLhBYFZN5Jj7A==", + "requires": { + "@hapi/catbox": "11.0.1", + "@hapi/catbox-memory": "5.0.0", + "@mojaloop/central-services-error-handling": "9.1.0", + "@mojaloop/central-services-logger": "9.1.0", + "@mojaloop/central-services-metrics": "9.1.0", + "@mojaloop/event-sdk": "9.2.0", + "axios": "0.19.2", + "base64url": "3.0.1", + "clone": "2.1.2", + "data-urls": "2.0.0", + "immutable": "3.8.2", + "lodash": "4.17.15", + "mustache": "4.0.0", + "raw-body": "2.4.1" + } + }, "hapi-swagger": { "version": "12.1.1", "resolved": "https://registry.npmjs.org/hapi-swagger/-/hapi-swagger-12.1.1.tgz", @@ -1733,16 +1754,16 @@ } }, "@mojaloop/central-services-shared": { - "version": "9.2.0", - "resolved": "https://registry.npmjs.org/@mojaloop/central-services-shared/-/central-services-shared-9.2.0.tgz", - "integrity": "sha512-RFVXd6hwR66iQzwnU5st68cQBCiJjXHqiQp6sjkUJ+1ElqQjhnDMZJcLM5KAfkpSxDmTwwqqKuLhBYFZN5Jj7A==", + "version": "9.3.0", + "resolved": "https://registry.npmjs.org/@mojaloop/central-services-shared/-/central-services-shared-9.3.0.tgz", + "integrity": "sha512-sWQlnbkHNdJFONGeEEBys8oIwm//BYgRiuVbVz/3LAvhiAChKQZkO3fsetKWr42X6MHP64/q9JtoYP0s8sqQ9A==", "requires": { "@hapi/catbox": "11.0.1", "@hapi/catbox-memory": "5.0.0", "@mojaloop/central-services-error-handling": "9.1.0", "@mojaloop/central-services-logger": "9.1.0", "@mojaloop/central-services-metrics": "9.1.0", - "@mojaloop/event-sdk": "9.2.0", + "@mojaloop/event-sdk": "9.3.0", "axios": "0.19.2", "base64url": "3.0.1", "clone": "2.1.2", @@ -1790,6 +1811,34 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/@hapi/teamwork/-/teamwork-4.0.0.tgz", "integrity": "sha512-V6xYOrr5aFv/IJqNPneaYCu8vuGTKisamqHVRS3JJnbZr18TrpXdsJOYk9pjPhFti+M2YETPebQLUr820N5NoQ==" + }, + "@mojaloop/event-sdk": { + "version": "9.3.0", + "resolved": "https://registry.npmjs.org/@mojaloop/event-sdk/-/event-sdk-9.3.0.tgz", + "integrity": "sha512-rImhf/gfjxFQkqvAb0C67rT75Pnlq4T6PMvJlULRYeC44oiVcDneJWbux5jiHDcHulo8cx5D6u6uLYuFU/2OOQ==", + "requires": { + "@grpc/proto-loader": "0.5.3", + "@mojaloop/central-services-logger": "9.1.0", + "brototype": "0.0.6", + "error-callsites": "2.0.2", + "grpc": "1.24.2", + "lodash": "4.17.15", + "moment": "2.24.0", + "parse-strings-in-object": "2.0.0", + "protobufjs": "6.8.8", + "rc": "1.2.8", + "serialize-error": "4.1.0", + "sinon": "9.0.0", + "traceparent": "1.0.0", + "tslib": "1.11.1", + "uuid4": "1.1.4", + "winston": "3.2.1" + } + }, + "tslib": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.11.1.tgz", + "integrity": "sha512-aZW88SY8kQbU7gpV19lN24LtXh/yD4ZZg6qieAJDDg+YBsJcSmLGK9QpnUjAKVG/xefmvJGd1WUmfpT/g6AJGA==" } } }, @@ -2005,7 +2054,6 @@ "version": "6.0.0", "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-6.0.0.tgz", "integrity": "sha512-atR1J/jRXvQAb47gfzSK8zavXy7BcpnYq21ALon0U99etu99vsir0trzIO3wpeLtW+LLVY6X7EkfVTbjGSH8Ww==", - "dev": true, "requires": { "@sinonjs/commons": "^1.7.0" } @@ -2070,9 +2118,9 @@ "integrity": "sha512-5tXH6Bx/kNGd3MgffdmP4dy2Z+G4eaXw0SE81Tq3BNadtnMR5/ySMzX4SLEzHJzSmPNn4HIdpQsBvXMUykr58w==" }, "@types/node": { - "version": "10.17.16", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.16.tgz", - "integrity": "sha512-A4283YSA1OmnIivcpy/4nN86YlnKRiQp8PYwI2KdPCONEBN093QTb0gCtERtkLyVNGKKIGazTZ2nAmVzQU51zA==" + "version": "10.17.17", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.17.tgz", + "integrity": "sha512-gpNnRnZP3VWzzj5k3qrpRC6Rk3H/uclhAVo1aIvwzK5p5cOrs9yEyQ8H/HBsBY0u5rrWxXEiVPQ0dEB6pkjE8Q==" }, "@types/protobufjs": { "version": "6.0.0", @@ -2094,9 +2142,9 @@ "dev": true }, "acorn": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.0.tgz", - "integrity": "sha512-kL5CuoXA/dgxlBbVrflsflzQ3PAas7RYZB52NOm/6839iVYJgKMJ3cQJD+t2i5+qFa8h3MDpEOJiS64E8JLnSQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.1.tgz", + "integrity": "sha512-add7dgA5ppRPxCFJoAGfMDi7PIBXq1RtGo7BhbLaxwrXPOmw8gq48Y9ozT01hUKy9byMjlR20EJhu5zlkErEkg==", "dev": true }, "acorn-jsx": { @@ -2217,18 +2265,18 @@ } }, "ansi-escapes": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.0.tgz", - "integrity": "sha512-EiYhwo0v255HUL6eDyuLrXEkTi7WwVCLAw+SeOQ7M7qdun1z1pum4DEm/nuqIVbPvi9RPPc9k9LbyBv6H0DwVg==", + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.1.tgz", + "integrity": "sha512-JWF7ocqNrp8u9oqpgV+wH5ftbt+cfvv+PTjOvKLT3AdYly/LmORARfEVT1iyjwN+4MqE5UmVKoAdIBqeoCHgLA==", "dev": true, "requires": { - "type-fest": "^0.8.1" + "type-fest": "^0.11.0" }, "dependencies": { "type-fest": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", - "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.11.0.tgz", + "integrity": "sha512-OdjXJxnCN1AvyLSzeKIgXTXxV+99ZuXl3Hpo9XpJAv9MBcHrrJOQ5kV7ypXOuQie+AmWG25hLbiKdwYTifzcfQ==", "dev": true } } @@ -4304,13 +4352,13 @@ "integrity": "sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA==" }, "espree": { - "version": "6.1.2", - "resolved": "https://registry.npmjs.org/espree/-/espree-6.1.2.tgz", - "integrity": "sha512-2iUPuuPP+yW1PZaMSDM9eyVf8D5P0Hi8h83YtZ5bPc/zHYjII5khoixIUTMO794NOY8F/ThF1Bo8ncZILarUTA==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-6.2.0.tgz", + "integrity": "sha512-Xs8airJ7RQolnDIbLtRutmfvSsAe0xqMMAantCN/GMoqf81TFbeI1T7Jpd56qYu1uuh32dOG5W/X9uO+ghPXzA==", "dev": true, "requires": { "acorn": "^7.1.0", - "acorn-jsx": "^5.1.0", + "acorn-jsx": "^5.2.0", "eslint-visitor-keys": "^1.1.0" } }, @@ -5136,19 +5184,23 @@ "dependencies": { "abbrev": { "version": "1.1.1", - "bundled": true + "resolved": false, + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==" }, "ansi-regex": { "version": "2.1.1", - "bundled": true + "resolved": false, + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" }, "aproba": { "version": "1.2.0", - "bundled": true + "resolved": false, + "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==" }, "are-we-there-yet": { "version": "1.1.5", - "bundled": true, + "resolved": false, + "integrity": "sha512-5hYdAkZlcG8tOLujVDTgCT+uPX0VnpAH28gWsLfzpXYm7wP6mp5Q/gYyR7YQ0cKVJcXJnl3j2kpBan13PtQf6w==", "requires": { "delegates": "^1.0.0", "readable-stream": "^2.0.6" @@ -5156,11 +5208,13 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true + "resolved": false, + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" }, "brace-expansion": { "version": "1.1.11", - "bundled": true, + "resolved": false, + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -5168,57 +5222,69 @@ }, "chownr": { "version": "1.1.3", - "bundled": true + "resolved": false, + "integrity": "sha512-i70fVHhmV3DtTl6nqvZOnIjbY0Pe4kAUjwHj8z0zAdgBtYrJyYwLKCCuRBQ5ppkyL0AkN7HKRnETdmdp1zqNXw==" }, "code-point-at": { "version": "1.1.0", - "bundled": true + "resolved": false, + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" }, "concat-map": { "version": "0.0.1", - "bundled": true + "resolved": false, + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" }, "console-control-strings": { "version": "1.1.0", - "bundled": true + "resolved": false, + "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=" }, "core-util-is": { "version": "1.0.2", - "bundled": true + "resolved": false, + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" }, "debug": { "version": "3.2.6", - "bundled": true, + "resolved": false, + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", "requires": { "ms": "^2.1.1" } }, "deep-extend": { "version": "0.6.0", - "bundled": true + "resolved": false, + "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==" }, "delegates": { "version": "1.0.0", - "bundled": true + "resolved": false, + "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=" }, "detect-libc": { "version": "1.0.3", - "bundled": true + "resolved": false, + "integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=" }, "fs-minipass": { "version": "1.2.7", - "bundled": true, + "resolved": false, + "integrity": "sha512-GWSSJGFy4e9GUeCcbIkED+bgAoFyj7XF1mV8rma3QW4NIqX9Kyx79N/PF61H5udOV3aY1IaMLs6pGbH71nlCTA==", "requires": { "minipass": "^2.6.0" } }, "fs.realpath": { "version": "1.0.0", - "bundled": true + "resolved": false, + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" }, "gauge": { "version": "2.7.4", - "bundled": true, + "resolved": false, + "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", "requires": { "aproba": "^1.0.3", "console-control-strings": "^1.0.0", @@ -5232,7 +5298,8 @@ }, "glob": { "version": "7.1.4", - "bundled": true, + "resolved": false, + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -5244,25 +5311,29 @@ }, "has-unicode": { "version": "2.0.1", - "bundled": true + "resolved": false, + "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=" }, "iconv-lite": { "version": "0.4.24", - "bundled": true, + "resolved": false, + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", "requires": { "safer-buffer": ">= 2.1.2 < 3" } }, "ignore-walk": { "version": "3.0.3", - "bundled": true, + "resolved": false, + "integrity": "sha512-m7o6xuOaT1aqheYHKf8W6J5pYH85ZI9w077erOzLje3JsB1gkafkAhHHY19dqjulgIZHFm32Cp5uNZgcQqdJKw==", "requires": { "minimatch": "^3.0.4" } }, "inflight": { "version": "1.0.6", - "bundled": true, + "resolved": false, + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", "requires": { "once": "^1.3.0", "wrappy": "1" @@ -5270,37 +5341,44 @@ }, "inherits": { "version": "2.0.4", - "bundled": true + "resolved": false, + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, "ini": { "version": "1.3.5", - "bundled": true + "resolved": false, + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==" }, "is-fullwidth-code-point": { "version": "1.0.0", - "bundled": true, + "resolved": false, + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "requires": { "number-is-nan": "^1.0.0" } }, "isarray": { "version": "1.0.0", - "bundled": true + "resolved": false, + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" }, "minimatch": { "version": "3.0.4", - "bundled": true, + "resolved": false, + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { "version": "1.2.0", - "bundled": true + "resolved": false, + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" }, "minipass": { "version": "2.9.0", - "bundled": true, + "resolved": false, + "integrity": "sha512-wxfUjg9WebH+CUDX/CdbRlh5SmfZiy/hpkxaRI16Y9W56Pa75sWgd/rvFilSgrauD9NyFymP/+JFV3KwzIsJeg==", "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -5308,31 +5386,36 @@ }, "minizlib": { "version": "1.3.3", - "bundled": true, + "resolved": false, + "integrity": "sha512-6ZYMOEnmVsdCeTJVE0W9ZD+pVnE8h9Hma/iOwwRDsdQoePpoX56/8B6z3P9VNwppJuBKNRuFDRNRqRWexT9G9Q==", "requires": { "minipass": "^2.9.0" } }, "mkdirp": { "version": "0.5.1", - "bundled": true, + "resolved": false, + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "requires": { "minimist": "0.0.8" }, "dependencies": { "minimist": { "version": "0.0.8", - "bundled": true + "resolved": false, + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" } } }, "ms": { "version": "2.1.2", - "bundled": true + "resolved": false, + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "needle": { "version": "2.4.0", - "bundled": true, + "resolved": false, + "integrity": "sha512-4Hnwzr3mi5L97hMYeNl8wRW/Onhy4nUKR/lVemJ8gJedxxUyBLm9kkrDColJvoSfwi0jCNhD+xCdOtiGDQiRZg==", "requires": { "debug": "^3.2.6", "iconv-lite": "^0.4.4", @@ -5341,7 +5424,8 @@ }, "node-pre-gyp": { "version": "0.14.0", - "bundled": true, + "resolved": false, + "integrity": "sha512-+CvDC7ZttU/sSt9rFjix/P05iS43qHCOOGzcr3Ry99bXG7VX953+vFyEuph/tfqoYu8dttBkE86JSKBO2OzcxA==", "requires": { "detect-libc": "^1.0.2", "mkdirp": "^0.5.1", @@ -5357,7 +5441,8 @@ }, "nopt": { "version": "4.0.1", - "bundled": true, + "resolved": false, + "integrity": "sha1-0NRoWv1UFRk8jHUFYC0NF81kR00=", "requires": { "abbrev": "1", "osenv": "^0.1.4" @@ -5365,11 +5450,13 @@ }, "npm-bundled": { "version": "1.0.6", - "bundled": true + "resolved": false, + "integrity": "sha512-8/JCaftHwbd//k6y2rEWp6k1wxVfpFzB6t1p825+cUb7Ym2XQfhwIC5KwhrvzZRJu+LtDE585zVaS32+CGtf0g==" }, "npm-packlist": { "version": "1.4.6", - "bundled": true, + "resolved": false, + "integrity": "sha512-u65uQdb+qwtGvEJh/DgQgW1Xg7sqeNbmxYyrvlNznaVTjV3E5P6F/EFjM+BVHXl7JJlsdG8A64M0XI8FI/IOlg==", "requires": { "ignore-walk": "^3.0.1", "npm-bundled": "^1.0.1" @@ -5377,7 +5464,8 @@ }, "npmlog": { "version": "4.1.2", - "bundled": true, + "resolved": false, + "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", "requires": { "are-we-there-yet": "~1.1.2", "console-control-strings": "~1.1.0", @@ -5387,30 +5475,36 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true + "resolved": false, + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" }, "object-assign": { "version": "4.1.1", - "bundled": true + "resolved": false, + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" }, "once": { "version": "1.4.0", - "bundled": true, + "resolved": false, + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "requires": { "wrappy": "1" } }, "os-homedir": { "version": "1.0.2", - "bundled": true + "resolved": false, + "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=" }, "os-tmpdir": { "version": "1.0.2", - "bundled": true + "resolved": false, + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=" }, "osenv": { "version": "0.1.5", - "bundled": true, + "resolved": false, + "integrity": "sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==", "requires": { "os-homedir": "^1.0.0", "os-tmpdir": "^1.0.0" @@ -5418,11 +5512,13 @@ }, "path-is-absolute": { "version": "1.0.1", - "bundled": true + "resolved": false, + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" }, "process-nextick-args": { "version": "2.0.1", - "bundled": true + "resolved": false, + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" }, "protobufjs": { "version": "5.0.3", @@ -5437,7 +5533,8 @@ }, "rc": { "version": "1.2.8", - "bundled": true, + "resolved": false, + "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", "requires": { "deep-extend": "^0.6.0", "ini": "~1.3.0", @@ -5447,7 +5544,8 @@ }, "readable-stream": { "version": "2.3.6", - "bundled": true, + "resolved": false, + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "requires": { "core-util-is": "~1.0.0", "inherits": "~2.0.3", @@ -5460,38 +5558,46 @@ }, "rimraf": { "version": "2.7.1", - "bundled": true, + "resolved": false, + "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", "requires": { "glob": "^7.1.3" } }, "safe-buffer": { "version": "5.1.2", - "bundled": true + "resolved": false, + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" }, "safer-buffer": { "version": "2.1.2", - "bundled": true + "resolved": false, + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, "sax": { "version": "1.2.4", - "bundled": true + "resolved": false, + "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==" }, "semver": { "version": "5.7.1", - "bundled": true + "resolved": false, + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" }, "set-blocking": { "version": "2.0.0", - "bundled": true + "resolved": false, + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" }, "signal-exit": { "version": "3.0.2", - "bundled": true + "resolved": false, + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=" }, "string-width": { "version": "1.0.2", - "bundled": true, + "resolved": false, + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -5500,25 +5606,29 @@ }, "string_decoder": { "version": "1.1.1", - "bundled": true, + "resolved": false, + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "requires": { "safe-buffer": "~5.1.0" } }, "strip-ansi": { "version": "3.0.1", - "bundled": true, + "resolved": false, + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "requires": { "ansi-regex": "^2.0.0" } }, "strip-json-comments": { "version": "2.0.1", - "bundled": true + "resolved": false, + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" }, "tar": { "version": "4.4.13", - "bundled": true, + "resolved": false, + "integrity": "sha512-w2VwSrBoHa5BsSyH+KxEqeQBAllHhccyMFVHtGtdMpF4W7IRWfZjFiQceJPChOeTsSDVUpER2T8FA93pr0L+QA==", "requires": { "chownr": "^1.1.1", "fs-minipass": "^1.2.5", @@ -5531,22 +5641,26 @@ }, "util-deprecate": { "version": "1.0.2", - "bundled": true + "resolved": false, + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" }, "wide-align": { "version": "1.1.3", - "bundled": true, + "resolved": false, + "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", "requires": { "string-width": "^1.0.2 || 2" } }, "wrappy": { "version": "1.0.2", - "bundled": true + "resolved": false, + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, "yallist": { "version": "3.1.1", - "bundled": true + "resolved": false, + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==" } } }, @@ -5844,9 +5958,9 @@ } }, "hosted-git-info": { - "version": "2.8.7", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.7.tgz", - "integrity": "sha512-ChkjQtKJ3GI6SsI4O5jwr8q8EPrWCnxuc4Tbx+vRI5x6mDOpjKKltNo1lRlszw3xwgTOSns1ZRBiMmmwpcvLxg==" + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.8.tgz", + "integrity": "sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==" }, "html-escaper": { "version": "2.0.0", @@ -5855,9 +5969,9 @@ "dev": true }, "http-cache-semantics": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.0.4.tgz", - "integrity": "sha512-Z2EICWNJou7Tr9Bd2M2UqDJq3A9F2ePG9w3lIpjoyuSyXFP9QbniJVu3XQYytuw5ebmG7dXSXO9PgAjJG8DDKA==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz", + "integrity": "sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ==", "dev": true }, "http-errors": { @@ -6074,23 +6188,23 @@ "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==" }, "inquirer": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.0.4.tgz", - "integrity": "sha512-Bu5Td5+j11sCkqfqmUTiwv+tWisMtP0L7Q8WrqA2C/BbBhy1YTdFrvjjlrKq8oagA/tLQBski2Gcx/Sqyi2qSQ==", + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.0.5.tgz", + "integrity": "sha512-6Z5cP+LAO0rzNE7xWjWtT84jxKa5ScLEGLgegPXeO3dGeU8lNe5Ii7SlXH6KVtLGlDuaEhsvsFjrjWjw8j5lFg==", "dev": true, "requires": { "ansi-escapes": "^4.2.1", - "chalk": "^2.4.2", + "chalk": "^3.0.0", "cli-cursor": "^3.1.0", "cli-width": "^2.0.0", "external-editor": "^3.0.3", "figures": "^3.0.0", "lodash": "^4.17.15", "mute-stream": "0.0.8", - "run-async": "^2.2.0", + "run-async": "^2.4.0", "rxjs": "^6.5.3", "string-width": "^4.1.0", - "strip-ansi": "^5.1.0", + "strip-ansi": "^6.0.0", "through": "^2.3.6" }, "dependencies": { @@ -6100,6 +6214,41 @@ "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", "dev": true }, + "ansi-styles": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "dev": true, + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz", + "integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, "is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", @@ -6115,34 +6264,15 @@ "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", "strip-ansi": "^6.0.0" - }, - "dependencies": { - "strip-ansi": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", - "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", - "dev": true, - "requires": { - "ansi-regex": "^5.0.0" - } - } } }, "strip-ansi": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", - "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", "dev": true, "requires": { - "ansi-regex": "^4.1.0" - }, - "dependencies": { - "ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", - "dev": true - } + "ansi-regex": "^5.0.0" } } } @@ -6727,9 +6857,9 @@ "integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==" }, "json-parse-even-better-errors": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.0.1.tgz", - "integrity": "sha512-XFY2Mbnmg+8r7MRsxfArVkZcfjxGlF/NjM3LsPXVeCX/GBF/1FTCv+idHBYC4qLPtK7q8HC8bapLoWqnhP/bXw==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.2.0.tgz", + "integrity": "sha512-2tLgY7LRNZ9Hd6gmCuBG5/OjRHQpSgJQqJoYyLLOhUgn8LdOYrjaZLcxkWnDads+AD/haWWioPNziXQcgvQJ/g==", "dev": true }, "json-parse-helpfulerror": { @@ -7131,9 +7261,9 @@ } }, "make-fetch-happen": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/make-fetch-happen/-/make-fetch-happen-8.0.2.tgz", - "integrity": "sha512-jRqI9zjLyz8ufXfLSbEObJ6a8sv8geeKYEPFpI+b39JjYU14MZtCiJGazSWPZMjCm7161b4r57N/na5fBXpooQ==", + "version": "8.0.3", + "resolved": "https://registry.npmjs.org/make-fetch-happen/-/make-fetch-happen-8.0.3.tgz", + "integrity": "sha512-3ulUor6Xf8g+T0x4vvsV6mIYchThPR6sl2J3lSRF9I5ygI5/qScRnDToTLRMNXPlnB6cpO2cfQ+r088T7GYwxA==", "dev": true, "requires": { "agentkeepalive": "^4.1.0", @@ -7787,9 +7917,9 @@ } }, "npm-check-updates": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/npm-check-updates/-/npm-check-updates-4.0.2.tgz", - "integrity": "sha512-EVJzwOIIdm58ug0vInAlkvkvfX603Szl614c/FFpttzexXG8KXQXj+Cf0GJ+9HEfBb8hPc8rLk4Csq9h7kL+ig==", + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/npm-check-updates/-/npm-check-updates-4.0.4.tgz", + "integrity": "sha512-o1Db+kfi8Vvs345Xxpn+3WSUJtLa85F2hMF6v6kYfQuvTulsphvDzgbiVkp4vEKC8+BQETCag730XPJudYf4mA==", "dev": true, "requires": { "chalk": "^3.0.0", @@ -10572,7 +10702,6 @@ "version": "9.0.0", "resolved": "https://registry.npmjs.org/sinon/-/sinon-9.0.0.tgz", "integrity": "sha512-c4bREcvuK5VuEGyMW/Oim9I3Rq49Vzb0aMdxouFaA44QCFpilc5LJOugrX+mkrvikbqCimxuK+4cnHVNnLR41g==", - "dev": true, "requires": { "@sinonjs/commons": "^1.7.0", "@sinonjs/fake-timers": "^6.0.0", @@ -10587,33 +10716,28 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/@sinonjs/formatio/-/formatio-5.0.1.tgz", "integrity": "sha512-KaiQ5pBf1MpS09MuA0kp6KBQt2JUOQycqVG1NZXvzeaXe5LGFqAKueIS0bw4w0P9r7KuBSVdUk5QjXsUdu2CxQ==", - "dev": true, "requires": { "@sinonjs/commons": "^1", "@sinonjs/samsam": "^5.0.2" } }, "@sinonjs/samsam": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-5.0.2.tgz", - "integrity": "sha512-p3yrEVB5F/1wI+835n+X8llOGRgV8+jw5BHQ/cJoLBUXXZ5U8Tr5ApwPc4L4av/vjla48kVPoN0t6dykQm+Rvg==", - "dev": true, + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-5.0.3.tgz", + "integrity": "sha512-QucHkc2uMJ0pFGjJUDP3F9dq5dx8QIaqISl9QgwLOh6P9yv877uONPGXh/OH/0zmM3tW1JjuJltAZV2l7zU+uQ==", "requires": { "@sinonjs/commons": "^1.6.0", - "@sinonjs/formatio": "^5.0.0", "lodash.get": "^4.4.2", "type-detect": "^4.0.8" } }, "nise": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/nise/-/nise-4.0.2.tgz", - "integrity": "sha512-ALDnm0pTTyeGdbg5FCpWGd58Nmp3qO8d8x+dU2Fw8lApeJTEBSjkBZZM4S8t6GpKh+czxkfM/TKxpRMroZzwOg==", - "dev": true, + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/nise/-/nise-4.0.3.tgz", + "integrity": "sha512-EGlhjm7/4KvmmE6B/UFsKh7eHykRl9VH+au8dduHLCyWUO/hr7+N+WtTvDUwc9zHuM1IaIJs/0lQ6Ag1jDkQSg==", "requires": { "@sinonjs/commons": "^1.7.0", "@sinonjs/fake-timers": "^6.0.0", - "@sinonjs/formatio": "^5.0.1", "@sinonjs/text-encoding": "^0.7.1", "just-extend": "^4.0.2", "path-to-regexp": "^1.7.0" @@ -11596,9 +11720,9 @@ } }, "tape": { - "version": "4.13.0", - "resolved": "https://registry.npmjs.org/tape/-/tape-4.13.0.tgz", - "integrity": "sha512-J/hvA+GJnuWJ0Sj8Z0dmu3JgMNU+MmusvkCT7+SN4/2TklW18FNCp/UuHIEhPZwHfy4sXfKYgC7kypKg4umbOw==", + "version": "4.13.2", + "resolved": "https://registry.npmjs.org/tape/-/tape-4.13.2.tgz", + "integrity": "sha512-waWwC/OqYVE9TS6r1IynlP2sEdk4Lfo6jazlgkuNkPTHIbuG2BTABIaKdlQWwPeB6Oo4ksZ1j33Yt0NTOAlYMQ==", "dev": true, "requires": { "deep-equal": "~1.1.1", @@ -11612,7 +11736,7 @@ "is-regex": "~1.0.5", "minimist": "~1.2.0", "object-inspect": "~1.7.0", - "resolve": "~1.14.2", + "resolve": "~1.15.1", "resumer": "~0.0.0", "string.prototype.trim": "~1.2.1", "through": "~2.3.8" @@ -11637,15 +11761,6 @@ "resolved": "https://registry.npmjs.org/defined/-/defined-1.0.0.tgz", "integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=", "dev": true - }, - "resolve": { - "version": "1.14.2", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.14.2.tgz", - "integrity": "sha512-EjlOBLBO1kxsUxsKjLt7TAECyKW6fOh1VRkykQkKGzcBbjjPIxBqGh0jf7GJ3k/f5mxMqW3htMD3WdTUVtW8HQ==", - "dev": true, - "requires": { - "path-parse": "^1.0.6" - } } } }, diff --git a/package.json b/package.json index 7390c7b6..183412fb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "central-settlement", - "description": "Central settlements hosted by a scheme to record and make settlements", + "description": "Central settlements hosted by a scheme to record and make settlements.", "version": "9.2.2", "license": "Apache-2.0", "private": false, @@ -10,7 +10,8 @@ "Valentin Genev ", "Deon Botha ", "Miguel de Barros ", - "Rajiv Mothilal " + "Rajiv Mothilal ", + "Lazola Lucas " ], "repository": { "type": "git", @@ -33,7 +34,7 @@ "@mojaloop/central-services-error-handling": "9.1.0", "@mojaloop/central-services-health": "9.2.0", "@mojaloop/central-services-logger": "9.1.0", - "@mojaloop/central-services-shared": "9.2.0", + "@mojaloop/central-services-shared": "9.3.0", "@mojaloop/central-services-stream": "9.2.0", "@mojaloop/ml-number": "8.2.0", "@now-ims/hapi-now-auth": "2.0.1", @@ -57,7 +58,7 @@ "node-fetch": "2.6.0", "nodemon": "2.0.2", "npm-audit-resolver": "2.2.0", - "npm-check-updates": "4.0.2", + "npm-check-updates": "4.0.4", "nyc": "15.0.0", "pre-commit": "1.2.2", "proxyquire": "2.1.3", @@ -66,7 +67,7 @@ "standard": "14.3.1", "swagmock": "1.0.0", "tap-xunit": "2.4.1", - "tape": "4.13.0", + "tape": "4.13.2", "tapes": "4.1.0" }, "pre-commit": [ diff --git a/src/domain/settlement/index.js b/src/domain/settlement/index.js index b4da442c..4a66d4a3 100644 --- a/src/domain/settlement/index.js +++ b/src/domain/settlement/index.js @@ -91,6 +91,25 @@ module.exports = { const settlementWindowsList = await SettlementWindowModel.getBySettlementId({ settlementId }, enums) const participantCurrenciesList = await SettlementModel.settlementParticipantCurrency.getParticipantCurrencyBySettlementId({ settlementId }, enums) const participants = prepareParticipantsResult(participantCurrenciesList) + + // Build settlement window content array and insert into settlement window list object + const windowContentRecords = [] + let windowContentResponseData = {} + + for (var key of Object.keys(settlementWindowsList)) { + const windowContentRecord = await SettlementWindowContentModel.getBySettlementAndWindowId(settlementId, settlementWindowsList[key].id) + windowContentResponseData = { + id: windowContentRecord[key].id, + state: windowContentRecord[key].state, + ledgerAccountType: windowContentRecord[key].ledgerAccountType, + currencyId: windowContentRecord[key].currencyId, + createdDate: windowContentRecord[key].createdDate, + changedDate: windowContentRecord[key].changedDate + } + windowContentRecords.push(windowContentResponseData) + settlementWindowsList[key].content = windowContentRecords + } + return { id: settlement.settlementId, state: settlement.state, @@ -119,24 +138,24 @@ module.exports = { if (settlementsData && settlementsData.length > 0) { for (const s of settlementsData) { if (!settlements[s.settlementId]) { + const settlementId = s.settlementId + const settlementWindowsList = await SettlementWindowModel.getBySettlementId({ settlementId }) + for (var key of Object.keys(settlementWindowsList)) { + settlementWindowsList[key].content = await SettlementWindowContentModel.getBySettlementAndWindowId(s.settlementId, settlementWindowsList[key].id) + } settlements[s.settlementId] = { id: s.settlementId, - state: s.settlementStateId + state: s.settlementStateId, + reason: s.settlementWindowReason, + createdDate: s.createdDate, + changedDate: s.changedDate, + settlementWindows: settlementWindowsList } } settlement = settlements[s.settlementId] if (!settlement.settlementWindows) { settlement.settlementWindows = {} } - if (!settlement.settlementWindows[s.settlementWindowId]) { - settlement.settlementWindows[s.settlementWindowId] = { - id: s.settlementWindowId, - state: s.settlementWindowStateId, - reason: s.settlementWindowReason, - createdDate: s.createdDate, - changedDate: s.changedDate - } - } if (!settlement.participants) { settlement.participants = {} } diff --git a/src/models/settlement/facade.js b/src/models/settlement/facade.js index 68889d35..dd35169f 100644 --- a/src/models/settlement/facade.js +++ b/src/models/settlement/facade.js @@ -1332,6 +1332,7 @@ const Facade = { return builder .join('settlementStateChange AS ssc', 'ssc.settlementStateChangeId', 'settlement.currentStateChangeId') .select('settlement.settlementId', + 'settlement.settlementModelId', 'ssc.settlementStateId AS state', 'ssc.reason', 'settlement.createdDate', @@ -1348,14 +1349,8 @@ const Facade = { .innerJoin('settlementSettlementWindow AS ssw', 'ssw.settlementId', 'settlement.settlementId') .innerJoin('settlementWindow AS sw', 'sw.settlementWindowId', 'ssw.settlementWindowId') .innerJoin('settlementWindowStateChange AS swsc', 'swsc.settlementWindowStateChangeId', 'sw.currentStateChangeId') - .innerJoin('settlementTransferParticipant AS stp', function () { - this.on('stp.settlementId', 'settlement.settlementId') - .andOn('stp.settlementWindowId', 'sw.settlementWindowId') - }) - .innerJoin('settlementParticipantCurrency AS spc', function () { - this.on('spc.settlementId', 'stp.settlementId') - .andOn('spc.participantCurrencyId', 'stp.participantCurrencyId') - }) + .innerJoin('settlementContentAggregation AS sca', 'sca.settlementId', 'settlement.settlementId') + .innerJoin('settlementParticipantCurrency AS spc', 'spc.settlementId', 'sca.settlementId') .innerJoin('settlementParticipantCurrencyStateChange AS spcsc', 'spcsc.settlementParticipantCurrencyStateChangeId', 'spc.currentStateChangeId') .innerJoin('participantCurrency AS pc', 'pc.participantCurrencyId', 'spc.participantCurrencyId') .distinct('settlement.settlementId', 'ssc.settlementStateId', 'ssw.settlementWindowId', diff --git a/src/models/settlementWindowContent/facade.js b/src/models/settlementWindowContent/facade.js index 171e57da..05b8c108 100644 --- a/src/models/settlementWindowContent/facade.js +++ b/src/models/settlementWindowContent/facade.js @@ -60,6 +60,15 @@ const Facade = { .where('swc.settlementWindowId', id) .select('swc.settlementWindowContentId AS id', 'swcsc.settlementWindowStateId AS state', 'lat.name AS ledgerAccountType', 'swc.currencyId', 'swc.createdDate', 'swcsc.createdDate AS changedDate', 'swc.settlementId') + }, + getBySettlementAndWindowId: async (settlementId, settlementWindowId) => { + const knex = await Db.getKnex() + return knex('settlementWindowContent AS swc') + .join('settlementWindowContentStateChange AS swcsc', 'swcsc.settlementWindowContentStateChangeId', 'swc.currentStateChangeId') + .join('ledgerAccountType AS lat', 'lat.ledgerAccountTypeId', 'swc.ledgerAccountTypeId') + .where({ 'swc.settlementId': settlementId, 'swc.settlementWindowId': settlementWindowId }) + .select('swc.settlementWindowContentId AS id', 'swc.settlementWindowId', 'swcsc.settlementWindowStateId AS state', + 'lat.name AS ledgerAccountType', 'swc.currencyId', 'swc.createdDate', 'swcsc.createdDate AS changedDate') } } diff --git a/src/models/settlementWindowContent/index.js b/src/models/settlementWindowContent/index.js index 4b264e85..2881efc5 100644 --- a/src/models/settlementWindowContent/index.js +++ b/src/models/settlementWindowContent/index.js @@ -31,5 +31,6 @@ module.exports = { createSettlementWindowContentState: SettlementWindowContentStateChangeModel.create, getApplicableByWindowIdList: Facade.getApplicableByWindowIdList, getBySettlementId: Facade.getBySettlementId, - getBySettlementWindowId: Facade.getBySettlementWindowId + getBySettlementWindowId: Facade.getBySettlementWindowId, + getBySettlementAndWindowId: Facade.getBySettlementAndWindowId } diff --git a/test/unit/domain/settlement/index.test.js b/test/unit/domain/settlement/index.test.js index 36f7003a..1fe04697 100644 --- a/test/unit/domain/settlement/index.test.js +++ b/test/unit/domain/settlement/index.test.js @@ -50,6 +50,7 @@ Test('SettlementService', async (settlementServiceTest) => { await settlementServiceTest.test('getById should', async getByIdTest => { try { const settlementId = 1 + const settlementWindowId = 1 const enums = {} const options = { logger: Logger @@ -62,6 +63,26 @@ Test('SettlementService', async (settlementServiceTest) => { id: 1, state: 'PENDING_SETTLEMENT' }] + const settlementWindowContentMock = [ + { + id: 10, + state: 'PENDING_SETTLEMENT', + ledgerAccountType: 'POSITION', + currencyId: 'USD', + createdDate: '2020-02-07T11:07:07.000Z', + changedDate: '2020-02-07T09:07:07.000Z', + settlementId: 6 + }, + { + id: 11, + state: 'CLOSED', + ledgerAccountType: 'POSITION', + currencyId: 'TZS', + createdDate: '2020-02-07T11:07:07.000Z', + changedDate: '2020-02-07T11:07:07.000Z', + settlementId: null + } + ] const participantCurrenciesListMock = [{ id: 1, participantCurrencyId: 1, @@ -79,11 +100,26 @@ Test('SettlementService', async (settlementServiceTest) => { currency: 'ZAR', key: 2 }] + const settlementModelModelNameMock = { + settlementModelId: 1, + name: 'DEFERRED_NET', + isActive: 1, + settlementGranularityId: 2, + settlementInterchangeId: 2, + settlementDelayId: 2, + currencyId: null, + requireLiquidityCheck: 1, + ledgerAccountTypeId: 1, + autoPositionReset: 1 + } + SettlementModel.getById = sandbox.stub().returns(settlementMock) SettlementWindowModel.getBySettlementId = sandbox.stub().returns(settlementWindowsListMock) SettlementModel.settlementParticipantCurrency = { getParticipantCurrencyBySettlementId: sandbox.stub().returns(participantCurrenciesListMock) } + SettlementWindowContentModel.getBySettlementAndWindowId = sandbox.stub().returns(settlementWindowContentMock) + SettlementModelModel.getById = sandbox.stub().returns(settlementModelModelNameMock) await getByIdTest.test('return settlement participant accounts', async test => { try { @@ -92,6 +128,7 @@ Test('SettlementService', async (settlementServiceTest) => { test.ok(SettlementModel.getById.withArgs({ settlementId }, enums).calledOnce, 'SettlementModel.getById with args ... called once') test.ok(SettlementWindowModel.getBySettlementId.withArgs({ settlementId }, enums).calledOnce, 'SettlementWindowModel.getBySettlementId with args ... called once') test.ok(SettlementModel.settlementParticipantCurrency.getParticipantCurrencyBySettlementId.withArgs({ settlementId }, enums).calledOnce, 'SettlementModel.spc.getParticipantCurrencyBySettlementId with args ... called once') + test.ok(SettlementWindowContentModel.getBySettlementAndWindowId.withArgs(settlementId, settlementWindowId).calledOnce, 'SettlementWindowContentModel.getBySettlementAndWindowId with args ... called once') test.end() } catch (err) { Logger.error(`getByIdTest failed with error - ${err}`) @@ -146,6 +183,33 @@ Test('SettlementService', async (settlementServiceTest) => { const options = { logger: Logger } + const settlementWindowContentMock = [ + { + id: 10, + state: 'PENDING_SETTLEMENT', + ledgerAccountType: 'POSITION', + currencyId: 'USD', + createdDate: '2020-02-07T11:07:07.000Z', + changedDate: '2020-02-07T09:07:07.000Z', + settlementId: 6 + + }, + { + id: 11, + state: 'CLOSED', + ledgerAccountType: 'POSITION', + currencyId: 'TZS', + createdDate: '2020-02-07T11:07:07.000Z', + changedDate: '2020-02-07T11:07:07.000Z', + settlementId: null + + } + ] + const settlementWindowsListMock = [{ + id: 1, + state: 'PENDING_SETTLEMENT', + reason: 'settlement window reason text' + }] const settlementsMockData = [{ settlementId: 1, settlementStateId: 'PENDING_SETTLEMENT', @@ -175,8 +239,9 @@ Test('SettlementService', async (settlementServiceTest) => { accountAmount: 100, accountCurrency: 'USD' }] + SettlementWindowModel.getBySettlementId = sandbox.stub().returns(settlementWindowsListMock) + SettlementWindowContentModel.getBySettlementAndWindowId = sandbox.stub().returns(settlementWindowContentMock) SettlementModel.getByParams = sandbox.stub().returns(settlementsMockData) - await getSettlementsByParamsTest.test('return settlement participant accounts', async test => { try { const result = await SettlementService.getSettlementsByParams(params, enums, options) diff --git a/test/unit/models/settlement/facade.test.js b/test/unit/models/settlement/facade.test.js index 7408a893..6749823c 100644 --- a/test/unit/models/settlement/facade.test.js +++ b/test/unit/models/settlement/facade.test.js @@ -4038,17 +4038,13 @@ Test('Settlement facade', async (settlementFacadeTest) => { context.on.returns({ andOn: sandbox.stub() }) - const innerJoin5 = sandbox.stub() - innerJoin5.callsArgOn(1, context) - const innerJoin6 = sandbox.stub() - innerJoin6.callsArgOn(1, context) builderStub.innerJoin.returns({ innerJoin: sandbox.stub().returns({ innerJoin: sandbox.stub().returns({ innerJoin: sandbox.stub().returns({ - innerJoin: innerJoin5.returns({ - innerJoin: innerJoin6.returns({ + innerJoin: sandbox.stub().returns({ + innerJoin: sandbox.stub().returns({ innerJoin: sandbox.stub().returns({ innerJoin: sandbox.stub().returns({ distinct: sandbox.stub().returns({ diff --git a/test/unit/models/settlement/settlementModel.test.js b/test/unit/models/settlement/settlementModel.test.js index a6662847..78cbc555 100644 --- a/test/unit/models/settlement/settlementModel.test.js +++ b/test/unit/models/settlement/settlementModel.test.js @@ -65,6 +65,5 @@ Test('SettlementModelModel', async (settlementModelModelTest) => { test.end() } }) - settlementModelModelTest.end() }) diff --git a/test/unit/models/settlementWindowContent/facade.test.js b/test/unit/models/settlementWindowContent/facade.test.js index e53b2740..a5badce9 100644 --- a/test/unit/models/settlementWindowContent/facade.test.js +++ b/test/unit/models/settlementWindowContent/facade.test.js @@ -211,5 +211,55 @@ Test('SettlementWindowContentFacade', async (settlementWindowContentModelTest) = } }) + await settlementWindowContentModelTest.test('getBySettlementAndWindowId', async getBySettlementWindowContentIdTest => { + try { + await getBySettlementWindowContentIdTest.test('return content for a specific settlementId and windowId ', async test => { + try { + const settlementId = 1 + const settlementWindowId = 1 + const settlementWindowContent = [{ + id: 1, + settlementWindowId: 1, + state: 'PENDING_SETTLEMENT', + ledgerAccountType: 1, + currencyId: 'USD', + createdDate: 'date', + changedDate: 'date' + }, { + id: 2, + settlementWindowId: 1, + state: 'SETTLED', + ledgerAccountType: 6, + currencyId: 'USD', + createdDate: 'date', + changedDate: 'date' + }] + Db.getKnex = sandbox.stub() + const knexStub = sandbox.stub() + Db.getKnex.returns(knexStub) + knexStub.returns({ + join: sandbox.stub().returns({ + join: sandbox.stub().returns({ + where: sandbox.stub().returns({ + select: sandbox.stub().returns(settlementWindowContent) + }) + }) + }) + }) + const result = await SettlementWindowContentFacade.getBySettlementAndWindowId(settlementId, settlementWindowId) + test.deepEqual(result, settlementWindowContent, 'results match') + test.end() + } catch (err) { + test.pass('Error thrown') + test.end() + } + }) + await getBySettlementWindowContentIdTest.end() + } catch (err) { + Logger.error(`getBySettlementWindowContentIdTest failed with error - ${err}`) + getBySettlementWindowContentIdTest.fail() + getBySettlementWindowContentIdTest.end() + } + }) await settlementWindowContentModelTest.end() })