Skip to content

Commit

Permalink
Merge pull request #680 from flexion/staging
Browse files Browse the repository at this point in the history
Sprint 6
  • Loading branch information
codyseibert authored Jan 22, 2019
2 parents f9d57fd + e79254a commit 93c448a
Show file tree
Hide file tree
Showing 253 changed files with 53,343 additions and 1,728 deletions.
17,390 changes: 17,390 additions & 0 deletions efcms-service/package-lock.json

Large diffs are not rendered by default.

15 changes: 8 additions & 7 deletions efcms-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,33 @@
"version": "0.1.0",
"dependencies": {
"ef-cms-shared": "file:../shared",
"serverless": "^1.35.1",
"serverless": "^1.36.0",
"serverless-aws-documentation": "^1.1.0",
"serverless-domain-manager": "^2.6.10",
"serverless-dynamodb-local": "0.2.35",
"serverless-offline": "^3.30.0",
"serverless-offline": "^3.32.2",
"serverless-plugin-aws-alerts": "^1.2.4",
"serverless-plugin-bind-deployment-id": "github:codyseibert/serverless-plugin-bind-deployment-id#update_lodash",
"serverless-plugin-bind-deployment-id": "github:ustaxcourt/serverless-plugin-bind-deployment-id#update_lodash",
"serverless-plugin-git-variables": "^3.2.0",
"serverless-plugin-split-stacks": "^1.7.0",
"serverless-s3-local": "github:codyseibert/serverless-s3-local",
"serverless-s3-local": "github:ustaxcourt/serverless-s3-local",
"uuid": "^3.3.2"
},
"license": "CC0-1.0",
"devDependencies": {
"artillery": "^1.6.0-25",
"aws-sdk": "^2.382.0",
"artillery-plugin-fuzzer": "^1.0.1",
"aws-sdk": "^2.386.0",
"aws-sdk-mock": "^4.2.0",
"chai": "^4.1.2",
"chai-string": "^1.4.0",
"dynamodb-admin": "^3.0.2",
"eslint": "^5.11.1",
"eslint": "^5.12.0",
"eslint-config-prettier": "^3.1.0",
"eslint-plugin-cypress": "^2.2.0",
"eslint-plugin-jsx-a11y": "^6.1.2",
"eslint-plugin-prettier": "^3.0.1",
"eslint-plugin-react": "^7.12.1",
"eslint-plugin-react": "^7.12.3",
"eslint-plugin-security": "^1.4.0",
"husky": "^1.3.1",
"lambda-tester": "^3.4.1",
Expand Down
20 changes: 20 additions & 0 deletions efcms-service/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,26 @@ resources:
MetricsEnabled: true

functions:
createDocument:
handler: src/documents/createDocumentLambda.createDocument
events:
- http:
path: v1/cases/{caseId}/documents
method: post
cors: true
documentation:
summary: create a new document inside of a case
tags:
- documents
description: >
Create a new document and attaches it to a case. It will also create a generic work item.
methodResponses:
- statusCode: '200'
responseBody:
description: 'the document metadata'
responseModels:
'application/json': 'document'

getUploadPolicy:
handler: src/documents/getUploadPolicyLambda.create
events:
Expand Down
47 changes: 23 additions & 24 deletions efcms-service/src/applicationContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ const {
const {
saveCase,
} = require('ef-cms-shared/src/persistence/dynamo/cases/saveCase');
const {
createCase,
} = require('ef-cms-shared/src/persistence/dynamo/cases/createCase');
const {
getCaseByCaseId,
} = require('ef-cms-shared/src/persistence/dynamo/cases/getCaseByCaseId');
Expand Down Expand Up @@ -65,7 +62,7 @@ const {
getCasesByStatus: getCasesByStatusUC,
} = require('ef-cms-shared/src/business/useCases/getCasesByStatus.interactor');
const {
createCase: createCaseUC,
createCase,
} = require('ef-cms-shared/src/business/useCases/createCase.interactor');
const {
getCasesByUser: getCasesByUserUC,
Expand All @@ -79,9 +76,6 @@ const {
const {
updateCase,
} = require('ef-cms-shared/src/business/useCases/updateCase.interactor');
const {
uploadCasePdfs,
} = require('ef-cms-shared/src/business/useCases/uploadCasePdfs.interactor');
const {
getCasesForRespondent: getCasesForRespondentUC,
} = require('ef-cms-shared/src/business/useCases/respondent/getCasesForRespondent.interactor');
Expand All @@ -95,11 +89,8 @@ const {
updateWorkItem,
} = require('ef-cms-shared/src/business/useCases/workitems/updateWorkItem.interactor');
const {
associateRespondentDocumentToCase,
} = require('ef-cms-shared/src/business/useCases/respondent/associateRespondentDocumentToCase.interactor');
const {
associateDocumentToCase,
} = require('ef-cms-shared/src/business/useCases/associateDocumentToCase.interactor');
createDocument,
} = require('ef-cms-shared/src/business/useCases/createDocument.interactor');
const {
getInteractorForGettingCases,
} = require('ef-cms-shared/src/business/useCases/utilities/getInteractorForGettingCases');
Expand All @@ -117,9 +108,13 @@ const {
const {
isAuthorized,
WORKITEM,
CASE_METADATA,
} = require('ef-cms-shared/src/authorization/authorizationClientService');

const PetitionWithoutFiles = require('ef-cms-shared/src/business/entities/PetitionWithoutFiles');

const User = require('ef-cms-shared/src/business/entities/User');
const Case = require('ef-cms-shared/src/business/entities/Case');

const environment = {
documentsBucketName: process.env.DOCUMENTS_BUCKET_NAME || '',
Expand All @@ -128,11 +123,17 @@ const environment = {
s3Endpoint: process.env.S3_ENDPOINT || 'localhost',
stage: process.env.STAGE || 'local',
};
let user;
const getCurrentUser = () => {
return user;
};
const setCurrentUser = newUser => {
user = newUser;
};

module.exports = ({ userId } = {}) => {
let user;
if (userId) {
user = new User({ userId });
setCurrentUser(new User({ userId }));
}
return {
getStorageClient: () => {
Expand All @@ -154,6 +155,9 @@ module.exports = ({ userId } = {}) => {
getUniqueId: () => {
return uuidv4();
},
getEntityConstructors: () => ({
Petition: PetitionWithoutFiles,
}),
getPersistenceGateway: () => {
return {
incrementCounter,
Expand All @@ -174,7 +178,6 @@ module.exports = ({ userId } = {}) => {
getCasesByUser,
getCasesForRespondent,
saveCase,
createCase,
getCaseByCaseId,
getCaseByDocketNumber,
};
Expand All @@ -188,26 +191,25 @@ module.exports = ({ userId } = {}) => {
s3Endpoint: process.env.S3_ENDPOINT || 'localhost',
documentsBucketName: process.env.DOCUMENTS_BUCKET_NAME || '',
},
user,
getCurrentUser,
isAuthorized,
isAuthorizedForWorkItems: () => isAuthorized(userId, WORKITEM),
isAuthorizedForCaseMetadata: () => isAuthorized(userId, CASE_METADATA),
getUseCases: () => {
return {
createCase: createCaseUC,
createCase,
getCase,
getCasesByStatus: getCasesByStatusUC,
getCasesByUser: getCasesByUserUC,
getUser,
forwardWorkItem,
sendPetitionToIRS,
updateCase,
uploadCasePdfs,
getCasesForRespondent: getCasesForRespondentUC,
getWorkItem,
getWorkItems,
updateWorkItem,
associateDocumentToCase,
associateRespondentDocumentToCase,
createDocument,
getWorkItemsBySection: getWorkItemsBySectionUC,
assignWorkItems: assignWorkItemsUC,
};
Expand All @@ -216,10 +218,6 @@ module.exports = ({ userId } = {}) => {
const interactorName =
(event.queryStringParameters || {}).interactorName || 'updateCase';
switch (interactorName) {
case 'associateRespondentDocumentToCase':
return associateRespondentDocumentToCase;
case 'associateDocumentToCase':
return associateDocumentToCase;
default:
return updateCase;
}
Expand All @@ -242,6 +240,7 @@ module.exports = ({ userId } = {}) => {
return getWorkItemsForUser;
}
},
filterCaseMetadata: Case.filterMetadata,
getInteractorForGettingCases,
};
};
3 changes: 1 addition & 2 deletions efcms-service/src/cases/createCaseLambda.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ exports.create = event =>
const userId = getAuthHeader(event);
const applicationContext = createApplicationContext({ userId });
return applicationContext.getUseCases().createCase({
userId,
documents: JSON.parse(event.body).documents,
...JSON.parse(event.body),
applicationContext,
});
});
20 changes: 20 additions & 0 deletions efcms-service/src/documents/createDocumentLambda.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const { getAuthHeader } = require('../middleware/apiGatewayHelper');
const { handle } = require('../middleware/apiGatewayHelper');
const createApplicationContext = require('../applicationContext');

/**
* creates a new document and attaches it to a case. It also creates a work item on the docket section.
*
* @param {Object} event
* @returns {Promise<*|undefined>}
*/
exports.createDocument = event =>
handle(() => {
const userId = getAuthHeader(event);
const applicationContext = createApplicationContext({ userId });
return applicationContext.getUseCases().createDocument({
caseId: event.pathParameters.caseId,
document: JSON.parse(event.body),
applicationContext,
});
});
Loading

0 comments on commit 93c448a

Please sign in to comment.