-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
createAssessmentSchema: add activity_log (#1007)
* createAssessmentSchema: add activity_log * fix typo, remove constraint * meta/activityLog: created definition * repository/activityLog: add insertActivityLog * service/createAssessment: add transaction with activityLog * core/activityLog: countryIso optional * schemas: useassessment.props.name * repository/insertActivityLog: minor changes * repository/assessment: add createAssessment * createAssessment: minor updates * service/createAssessment: return assessment only * repository/createAssessment: use one instead of query * Meta/users (#1011) * service/createAssessment: return assessment only * repository/createAssessment: use one instead of query * add users migartions * service/assessment: move old code under _legacy * repository/user: old code under _legacy * add jest * core/user: add user definitions * jest config * server: use create * tsconfig test * temporary path for integration tests * rename tables without _legacy in legacy schema * core/user: rename Provider to AuthProvider * create-users-tables-up.sql: add defaults * create-users-tables-up: set unique email * {service,repository}/user: read, update * test/integration: added password, provider * repository/userProvider: create * test/integration: set user inactive/active * General changes Drop row if user_id deleted from users (different tables) Add user remove service and test Use single index under test/integration * move tests under test/ * minor changes - activityLog target createdAssessment - rename test files * core/activityLog: use meta/user * server/schemas: update assessment type * test: create, remove assessment * server/assessment: read, remove, minor updates * test: rename tests without dash * server/repository: add camelize * test/removeAssessment: test no assessment returned after remove * github/test: add integration test * github/test: remove integration test * .github/test: use docker, run integration tests * add .github/test: yarn watch * server/db: add run-migrations * server/run-migrations: remove .env * .github/test: add local env * add debug * .github/test: update prot * .github/test: add inline vars * add test env * remove inline variables
- Loading branch information
Showing
103 changed files
with
2,608 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
NODE_ENV=test | ||
|
||
# Default web server port | ||
PORT=9001 | ||
APP_URI=http://localhost:9001 | ||
|
||
# DB | ||
PGHOST=localhost | ||
PGPORT=5442 | ||
PGDATABASE=frap-dev | ||
PGUSER=frap | ||
PGPASSWORD=frap | ||
|
||
DEBUG=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { User } from '@core/meta/user' | ||
|
||
export enum ActivityLogMessage { | ||
assessmentCreate = 'assessmentCreate', | ||
} | ||
|
||
export interface ActivityLog<Target> { | ||
target: Target | ||
message: ActivityLogMessage | ||
countryIso?: string | ||
section: string | ||
user: User | ||
time?: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
export enum UserStatus { | ||
invitationPending = 'invitationPending', | ||
active = 'active', | ||
inactive = 'inactive', | ||
} | ||
|
||
export interface User { | ||
institution?: string | ||
lang: string | ||
id: number | ||
profilePictureFilename?: string | ||
name: string | ||
status: UserStatus | ||
profilePictureFile?: string | ||
position?: string | ||
email: string | ||
} | ||
|
||
export enum AuthProvider { | ||
google = 'google', | ||
local = 'local', | ||
} | ||
|
||
export interface UserProvider<P = void> { | ||
id: number | ||
userId: number | ||
provider: AuthProvider | ||
props: P | ||
} | ||
|
||
export interface UserInvitation { | ||
uuid: string | ||
invitedAt: string | ||
acceptedAt: string | ||
userId: number | ||
} | ||
|
||
export interface UserResetPassword { | ||
uuid: string | ||
changedAt: string | ||
createdAt: string | ||
userId: number | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
roots: ['<rootDir>/dist/'], | ||
testEnvironment: 'node', | ||
verbose: true, | ||
testRegex: 'dist/test/integration/index.js', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
server/db/migration/migrations/20211111105502-fra-users-legacy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
'use strict'; | ||
|
||
var dbm; | ||
var type; | ||
var seed; | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var Promise; | ||
|
||
/** | ||
* We receive the dbmigrate dependency from dbmigrate initially. | ||
* This enables us to not have to rely on NODE_PATH. | ||
*/ | ||
exports.setup = function(options, seedLink) { | ||
dbm = options.dbmigrate; | ||
type = dbm.dataType; | ||
seed = seedLink; | ||
Promise = options.Promise; | ||
}; | ||
|
||
exports.up = function(db) { | ||
var filePath = path.join(__dirname, 'sqls', '20211111105502-fra-users-legacy-up.sql'); | ||
return new Promise( function( resolve, reject ) { | ||
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){ | ||
if (err) return reject(err); | ||
console.log('received data: ' + data); | ||
|
||
resolve(data); | ||
}); | ||
}) | ||
.then(function(data) { | ||
return db.runSql(data); | ||
}); | ||
}; | ||
|
||
exports.down = function(db) { | ||
var filePath = path.join(__dirname, 'sqls', '20211111105502-fra-users-legacy-down.sql'); | ||
return new Promise( function( resolve, reject ) { | ||
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){ | ||
if (err) return reject(err); | ||
console.log('received data: ' + data); | ||
|
||
resolve(data); | ||
}); | ||
}) | ||
.then(function(data) { | ||
return db.runSql(data); | ||
}); | ||
}; | ||
|
||
exports._meta = { | ||
"version": 1 | ||
}; |
50 changes: 50 additions & 0 deletions
50
server/db/migration/migrations/20211111110342-move-to-legacy-schema.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
let dbm | ||
let type | ||
let seed | ||
const fs = require('fs') | ||
const path = require('path') | ||
|
||
let Promise | ||
|
||
/** | ||
* We receive the dbmigrate dependency from dbmigrate initially. | ||
* This enables us to not have to rely on NODE_PATH. | ||
*/ | ||
exports.setup = function (options, seedLink) { | ||
dbm = options.dbmigrate | ||
type = dbm.dataType | ||
seed = seedLink | ||
Promise = options.Promise | ||
} | ||
|
||
exports.up = function (db) { | ||
const filePath = path.join(__dirname, 'sqls', '20211111110342-move-to-legacy-schema-up.sql') | ||
return new Promise(function (resolve, reject) { | ||
fs.readFile(filePath, { encoding: 'utf-8' }, function (err, data) { | ||
if (err) return reject(err) | ||
console.log(`received data: ${data}`) | ||
|
||
resolve(data) | ||
}) | ||
}).then(function (data) { | ||
return db.runSql(data) | ||
}) | ||
} | ||
|
||
exports.down = function (db) { | ||
const filePath = path.join(__dirname, 'sqls', '20211111110342-move-to-legacy-schema-down.sql') | ||
return new Promise(function (resolve, reject) { | ||
fs.readFile(filePath, { encoding: 'utf-8' }, function (err, data) { | ||
if (err) return reject(err) | ||
console.log(`received data: ${data}`) | ||
|
||
resolve(data) | ||
}) | ||
}).then(function (data) { | ||
return db.runSql(data) | ||
}) | ||
} | ||
|
||
exports._meta = { | ||
version: 1, | ||
} |
53 changes: 53 additions & 0 deletions
53
server/db/migration/migrations/20211111111648-create-users-tables.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
'use strict'; | ||
|
||
var dbm; | ||
var type; | ||
var seed; | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var Promise; | ||
|
||
/** | ||
* We receive the dbmigrate dependency from dbmigrate initially. | ||
* This enables us to not have to rely on NODE_PATH. | ||
*/ | ||
exports.setup = function(options, seedLink) { | ||
dbm = options.dbmigrate; | ||
type = dbm.dataType; | ||
seed = seedLink; | ||
Promise = options.Promise; | ||
}; | ||
|
||
exports.up = function(db) { | ||
var filePath = path.join(__dirname, 'sqls', '20211111111648-create-users-tables-up.sql'); | ||
return new Promise( function( resolve, reject ) { | ||
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){ | ||
if (err) return reject(err); | ||
console.log('received data: ' + data); | ||
|
||
resolve(data); | ||
}); | ||
}) | ||
.then(function(data) { | ||
return db.runSql(data); | ||
}); | ||
}; | ||
|
||
exports.down = function(db) { | ||
var filePath = path.join(__dirname, 'sqls', '20211111111648-create-users-tables-down.sql'); | ||
return new Promise( function( resolve, reject ) { | ||
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){ | ||
if (err) return reject(err); | ||
console.log('received data: ' + data); | ||
|
||
resolve(data); | ||
}); | ||
}) | ||
.then(function(data) { | ||
return db.runSql(data); | ||
}); | ||
}; | ||
|
||
exports._meta = { | ||
"version": 1 | ||
}; |
1 change: 1 addition & 0 deletions
1
server/db/migration/migrations/sqls/20211111105502-fra-users-legacy-down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* Replace with your SQL commands */ |
2 changes: 2 additions & 0 deletions
2
server/db/migration/migrations/sqls/20211111105502-fra-users-legacy-up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
alter table fra_user | ||
rename to _legacy_fra_user; |
1 change: 1 addition & 0 deletions
1
server/db/migration/migrations/sqls/20211111110342-move-to-legacy-schema-down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* Replace with your SQL commands */ |
14 changes: 14 additions & 0 deletions
14
server/db/migration/migrations/sqls/20211111110342-move-to-legacy-schema-up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
create schema _legacy; | ||
|
||
alter table public._legacy_assessment set schema _legacy; | ||
alter table public._legacy_fra_user set schema _legacy; | ||
alter table public._legacy_odp set schema _legacy; | ||
alter table public._legacy_odp_class set schema _legacy; | ||
alter table public._legacy_odp_version set schema _legacy; | ||
|
||
|
||
alter table _legacy._legacy_assessment rename to assessment; | ||
alter table _legacy._legacy_fra_user rename to fra_user; | ||
alter table _legacy._legacy_odp rename to odp; | ||
alter table _legacy._legacy_odp_class rename to odp_class; | ||
alter table _legacy._legacy_odp_version rename to odp_version; |
1 change: 1 addition & 0 deletions
1
server/db/migration/migrations/sqls/20211111111648-create-users-tables-down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* Replace with your SQL commands */ |
Oops, something went wrong.