Skip to content

Commit

Permalink
merge develop
Browse files Browse the repository at this point in the history
  • Loading branch information
sou-chon committed Jul 22, 2020
2 parents cf88f25 + e0a0d0e commit 35ba26f
Show file tree
Hide file tree
Showing 29 changed files with 2,353 additions and 1,782 deletions.
15 changes: 4 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[![Total alerts](https://img.shields.io/lgtm/alerts/g/dsi-icl/itmat-broker.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/dsi-icl/itmat-broker/alerts/)
[![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/dsi-icl/itmat-broker.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/dsi-icl/itmat-broker/context:javascript)
![Build status](https://github.com/dsi-icl/itmat-broker/workflows/Test%20and%20Build%20CI/badge.svg)

#Develop branch

To deploy the app, some programs need to be installed:
Expand All @@ -17,17 +21,6 @@ Or [convert a standalone to a replica set](https://docs.mongodb.com/manual/tutor

MinIO is required for high-performance object storage. Refer [this to install MinIO](https://docs.min.io/docs/minio-quickstart-guide.html)

### - Initalise the database for the app:

Go to `packages/itmat-interface/src/databaseSetup` to initialise the database using the script `collectionsAndIndexes.ts`.

This script needs to be editted to run the `setupDatabase` function:
`setupDatabase(mongostr, databaseName).then(() => {});;`

Where `mongostr` and `databaseName` are mongodb connection string and database name for the app, respectively.


To start the app, run the following commands at root folder (you will have to have `yarn` installed):

## 1. Install dependencies and build
```bash
Expand Down
27 changes: 14 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"lint": "lerna run --no-bail --stream lint",
"lint:fix": "lerna run --no-bail --stream lint:fix",
"clean": "lerna run clean",
"publish": "lerna run tsc && lerna publish"
"publish": "lerna run tsc && lerna publish",
"test:unit": "lerna run --no-bail --concurrency 1 --stream --scope itmat-interface test"
},
"workspaces": {
"packages": [
Expand All @@ -33,30 +34,30 @@
]
},
"devDependencies": {
"@types/jest": "26.0.3",
"@typescript-eslint/eslint-plugin": "3.4.0",
"@typescript-eslint/parser": "3.4.0",
"@types/jest": "26.0.5",
"@typescript-eslint/eslint-plugin": "3.7.0",
"@typescript-eslint/parser": "3.7.0",
"babel-eslint": "10.1.0",
"eslint": "7.3.1",
"eslint": "7.5.0",
"eslint-config-react-app": "5.2.1",
"eslint-plugin-cypress": "2.11.1",
"eslint-plugin-flowtype": "5.1.3",
"eslint-plugin-jest": "23.17.1",
"eslint-plugin-flowtype": "5.2.0",
"eslint-plugin-import": "2.22.0",
"eslint-plugin-jsx-a11y": "6.2.3",
"eslint-plugin-react": "7.20.0",
"eslint-plugin-react-hooks": "4.0.5",
"eslint-plugin-jest": "23.18.0",
"eslint-plugin-jsx-a11y": "6.3.1",
"eslint-plugin-react": "7.20.3",
"eslint-plugin-react-hooks": "4.0.8",
"husky": "4.2.5",
"start-server-and-test": "1.11.0",
"jest-environment-node": "26.1.0",
"lerna": "3.22.1",
"typescript": "3.9.6"
"typescript": "3.9.7"
},
"resolutions": {
"**/**/fs-capacitor": "^6.0.0",
"**/graphql-upload": "^11.0.0",
"**/graphql": "14.5.3",
"**/moment": "2.26.0"
"**/graphql": "14.7.0",
"**/moment": "2.27.0"
},
"eslintConfig": {
"extends": "./config/eslint.config.js"
Expand Down
14 changes: 7 additions & 7 deletions packages/itmat-commons/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@
},
"dependencies": {
"graphql": "15.0.0",
"graphql-tag": "2.10.3",
"graphql-tag": "2.10.4",
"minio": "7.0.16",
"uuid": "8.1.0"
},
"devDependencies": {
"@types/express": "4.17.6",
"@types/jest": "26.0.3",
"@types/express": "4.17.7",
"@types/jest": "26.0.5",
"@types/minio": "7.0.5",
"@types/mongodb": "3.5.25",
"@types/node": "13.13.12",
"@types/supertest": "2.0.9",
"@types/node": "14.0.23",
"@types/supertest": "2.0.10",
"chalk": "4.1.0",
"jest": "26.1.0",
"rimraf": "3.0.2",
"ts-jest": "26.1.1",
"typescript": "3.9.6"
"ts-jest": "26.1.3",
"typescript": "3.9.7"
},
"eslintConfig": {
"extends": "./config/eslint.config.js"
Expand Down
5 changes: 3 additions & 2 deletions packages/itmat-commons/src/graphql/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as appUsers from './appUsers';
import * as curation from './curation';
import * as fields from './fields';
import * as files from './files';
import * as log from './log';
import * as permission from './permission';
import * as projects from './projects';
import * as query from './query';
Expand All @@ -12,11 +13,11 @@ export * from './appUsers';
export * from './curation';
export * from './fields';
export * from './files';
export * from './log';
export * from './permission';
export * from './projects';
export * from './query';
export * from './study';
export * from './user';
export * from './subscription';

export const GQLRequests = { ...subscription, ...appUsers, ...curation, ...fields, ...files, ...permission, ...projects, ...query, ...study, ...user };
export const GQLRequests = { ...subscription, ...appUsers, ...curation, ...fields, ...files, ...log, ...permission, ...projects, ...query, ...study, ...user };
29 changes: 29 additions & 0 deletions packages/itmat-commons/src/graphql/log.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import gql from 'graphql-tag';

export const GET_LOGS = gql`
query getLogs(
$requesterName: String,
$requesterType: USERTYPE,
$logType: LOG_TYPE,
$actionType: LOG_ACTION,
$status: LOG_STATUS
) {
getLogs (
requesterName: $requesterName,
requesterType: $requesterType,
logType: $logType,
actionType: $actionType,
status: $status
) {
id,
requesterName,
requesterType,
logType,
actionType,
actionData,
time,
status,
error
}
}
`;
4 changes: 3 additions & 1 deletion packages/itmat-commons/src/models/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as Field from './field';
import * as File from './file';
import * as JobModels from './job';
import * as Log from './log';
import * as Query from './query';
import * as Study from './study';
import * as UserModels from './user';
Expand All @@ -9,8 +10,9 @@ import * as Data from './data';
export * from './field';
export * from './file/index';
export * from './job';
export * from './log';
export * from './query';
export * from './study';
export * from './user';
export * from './data';
export { File, JobModels, UserModels, Study, Query, Field, Data };
export { File, JobModels, Log, UserModels, Study, Query, Field, Data };
83 changes: 68 additions & 15 deletions packages/itmat-commons/src/models/log.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,74 @@
import { userTypes } from './user';

export interface ILogEntry {
type: LOG_TYPE;
subtype?: LOG_SUBTYPE;
user?: string;
ref: string;
content: string;
request: string;
outcome: string;
id: string,
requesterName: string,
requesterType: userTypes,
logType: LOG_TYPE,
actionType: LOG_ACTION,
actionData: any,
time: number,
status: LOG_STATUS,
errors: string | null
}

export enum LOG_TYPE {
SYSTEM_LOG = 'SYSTEM_LOG',
REQUEST_LOG = 'REQUEST_LOG'
}

enum LOG_TYPE {
ERROR = 'ERROR',
USER_ACTION = 'USER_ACTION',
LOGIN_ATTEMPT = 'LOGIN_ATTEMPT',
SYSTEM_LOG = 'SYSTEM_LOG'
export enum LOG_ACTION {
// SYSTEM
startSERVER = 'START_SERVER',
stopSERVER = 'STOP_SERVER',

// USER
getUsers = 'GET_USERS',
EditUser = 'EDIT_USER',
DeleteUser = 'DELETE_USER',
CreateUser = 'CREATE_USER',
login = 'LOGIN_USER',
whoAmI = 'WHO_AM_I',
logout = 'LOGOUT',
requestUsernameOrResetPassword = 'REQUEST_USERNAME_OR_RESET_PASSWORD',
resetPassword = 'RESET_PASSWORD',

// PROJECT
getProject = 'GET_PROJECT',
// GET_PROJECT_PATIENT_MAPPING = 'GET_PROJECT_PATIENT_MAPPING',
editProjectApprovedFields = 'EDIT_PROJECT_APPROVED_FIELDS',
editProjectApprovedFiles = 'EDIT_PROJECT_APPROVED_FILES',
createProject = 'CREATE_PROJECT',
deleteProject = 'DELETE_PROJECT',
setDataversionAsCurrent = 'SET_DATAVERSION_AS_CURRENT',
subscribeToJobStatusChange = 'SUBSCRIBE_TO_JOB_STATUS',

// STUDY | DATASET
deleteStudy = 'DELETE_STUDY',
getStudy = 'GET_STUDY',
getStudyFields = 'GET_STUDY_FIELDS',
createStudy = 'CREATE_STUDY',
createDataCurationJob = 'CREATE_DATA_CREATION_JOB',
//createDataCurationJob = 'CREATE_FIELD_CURATION_JOB',

// STUDY & PROJECT
editRole = 'EDIT_ROLE',
addRoleToStudyOrProject = 'ADD_NEW_ROLE',
removeRole = 'REMOVE_ROLE',

// FILE
uploadFile = 'UPLOAD_FILE',
DOWNLOAD_FILE = 'DOWNLOAD_FILE',
deleteFile = 'DELETE_FILE',

//QUERY
getQueries = 'GET_QUERY',
createQuery = 'CREATE_QUERY',
//GET_QUERY_RESULT = 'GET_QUERY_RESULT'

}

enum LOG_SUBTYPE {
DATADASE_WRITE = 'DATABASE_WRITE',
DATADASE_READ = 'DATABASE_READ'
export enum LOG_STATUS {
SUCCESS = 'SUCCESS',
FAIL = 'FAIL'
}
3 changes: 2 additions & 1 deletion packages/itmat-commons/src/models/user.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export enum userTypes {
ADMIN = 'ADMIN',
STANDARD = 'STANDARD'
STANDARD = 'STANDARD',
SYSTEM = 'SYSTEM'
}

export interface IUserWithoutToken {
Expand Down
6 changes: 5 additions & 1 deletion packages/itmat-interface/config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ module.exports = {
express: 'commonjs express',
mongodb: 'commonjs mongodb',
// "subscriptions-transport-ws": "commonjs subscriptions-transport-ws",
<<<<<<< HEAD
isobject: 'commonjs isobject',
=======
isobject: 'commonjs isobject',
>>>>>>> develop
require_optional: 'commonjs require_optional'
}],
module: {
Expand Down Expand Up @@ -60,4 +64,4 @@ module.exports = {
libraryTarget: NODE_ENV === 'development' ? undefined : 'umd',
umdNamedDefine: NODE_ENV === 'development' ? undefined : true
}
};
};
22 changes: 11 additions & 11 deletions packages/itmat-interface/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"prepublishOnly": "yarn run build"
},
"dependencies": {
"apollo-server-express": "2.15.1",
"apollo-server-express": "2.16.0",
"bcrypt": "5.0.0",
"body-parser": "1.19.0",
"connect-mongo": "3.2.0",
Expand All @@ -43,19 +43,19 @@
"devDependencies": {
"@types/bcrypt": "3.0.0",
"@types/connect-mongo": "3.1.3",
"@types/express": "4.17.6",
"@types/express": "4.17.7",
"@types/express-session": "1.17.0",
"@types/graphql": "14.5.0",
"@types/jest": "26.0.3",
"@types/jest": "26.0.5",
"@types/mongodb": "3.5.25",
"@types/mongodb-memory-server": "2.3.0",
"@types/multer": "1.4.3",
"@types/node": "13.13.12",
"@types/node": "14.0.23",
"@types/node-fetch": "2.5.7",
"@types/nodemailer": "6.4.0",
"@types/passport": "1.0.3",
"@types/passport": "1.0.4",
"@types/passport-local": "1.0.33",
"@types/supertest": "2.0.9",
"@types/supertest": "2.0.10",
"@types/uuid": "8.0.0",
"@types/webpack-env": "1.15.2",
"chalk": "4.1.0",
Expand All @@ -71,17 +71,17 @@
"rimraf": "3.0.2",
"start-server-webpack-plugin": "2.2.5",
"supertest": "4.0.2",
"ts-jest": "26.1.1",
"ts-loader": "7.0.5",
"typescript": "3.9.6",
"ts-jest": "26.1.3",
"ts-loader": "8.0.1",
"typescript": "3.9.7",
"typescript-eslint-parser": "22.0.0",
"webpack": "4.43.0",
"webpack-cli": "3.3.11"
"webpack-cli": "3.3.12"
},
"resolutions": {
"**/**/fs-capacitor": "^6.0.0",
"**/graphql-upload": "^11.0.0",
"**/graphql": "14.5.3"
"**/graphql": "14.7.0"
},
"eslintConfig": {
"extends": "./config/eslint.config.js"
Expand Down
6 changes: 4 additions & 2 deletions packages/itmat-interface/src/graphql/resolvers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ import { userResolvers } from './userResolvers';
import { ApolloError } from 'apollo-server-core';
import { errorCodes } from '../errors';
import { IUser } from 'itmat-commons';
import { logResolvers } from './logResolvers';

const modules = [
studyResolvers,
userResolvers,
queryResolvers,
permissionResolvers,
jobResolvers,
fileResolvers
fileResolvers,
logResolvers
];

// const loggingDecorator = (reducerFunction: Function) => {
Expand All @@ -27,7 +29,7 @@ const modules = [

const bounceNotLoggedInDecorator = (reducerFunction: any) => {
return async (parent: any, args: any, context: any, info: any) => {
const uncheckedFunctionWhitelist = ['login', 'whoAmI', 'requestUsernameOrResetPassword', 'resetPassword', 'createUser'];
const uncheckedFunctionWhitelist = ['login', 'whoAmI', 'requestUsernameOrResetPassword', 'resetPassword', 'createUser', 'writeLog'];
const requester: IUser = context.req.user;
if (!requester) {
if (!(uncheckedFunctionWhitelist as any).includes(reducerFunction.name)) {
Expand Down
Loading

0 comments on commit 35ba26f

Please sign in to comment.