From f66a9fa7f132f41b2e40029f0fb535521c3fb716 Mon Sep 17 00:00:00 2001 From: jw255 Date: Sat, 24 Feb 2018 17:13:43 +0000 Subject: restructuring of tests + yarn install script --- .../src/db/model/ContributorGroup.ts.html | 227 ++++++++++++++++ coverage/project-code/src/db/model/File.ts.html | 206 ++++++++++++++ coverage/project-code/src/db/model/Project.ts.html | 290 ++++++++++++++++++++ coverage/project-code/src/db/model/User.ts.html | 299 +++++++++++++++++++++ .../project-code/src/db/model/UserGroup.ts.html | 221 +++++++++++++++ .../src/db/model/UserJoinsProject.ts.html | 146 ++++++++++ coverage/project-code/src/db/model/index.html | 158 +++++++++++ 7 files changed, 1547 insertions(+) create mode 100644 coverage/project-code/src/db/model/ContributorGroup.ts.html create mode 100644 coverage/project-code/src/db/model/File.ts.html create mode 100644 coverage/project-code/src/db/model/Project.ts.html create mode 100644 coverage/project-code/src/db/model/User.ts.html create mode 100644 coverage/project-code/src/db/model/UserGroup.ts.html create mode 100644 coverage/project-code/src/db/model/UserJoinsProject.ts.html create mode 100644 coverage/project-code/src/db/model/index.html (limited to 'coverage/project-code/src/db/model') diff --git a/coverage/project-code/src/db/model/ContributorGroup.ts.html b/coverage/project-code/src/db/model/ContributorGroup.ts.html new file mode 100644 index 0000000..e8e3ce2 --- /dev/null +++ b/coverage/project-code/src/db/model/ContributorGroup.ts.html @@ -0,0 +1,227 @@ + + +
+| 1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 | 1x + +1x + + +1x + + +1x + + + + +1x + + +1x + + +1x + + +1x + + +1x + + +1x + + +1x + + + +1x + + +1x + + + + + + + + + + + + + + + + | import { AllowNull, Column, DataType, HasMany, Model, Table
+ } from 'sequelize-typescript';
+import { default as UserJoinsProject } from './UserJoinsProject';
+
+@Table
+export default class ContributorGroup extends Model<ContributorGroup> {
+ @AllowNull
+ @Column(DataType.TEXT)
+ public name: string | null = null;
+
+ /* "Error: Foreign key for "ContributorGroup"
+ * is missing on "UserJoinsProject"." */
+ @HasMany(() => UserJoinsProject, 'contributorGroupId')
+ public uses: UserJoinsProject[] = [];
+
+ @Column
+ public canCreateFiles: boolean = false;
+
+ @Column
+ public canDeleteFiles: boolean = false;
+
+ @Column
+ public canViewFiles: boolean = false;
+
+ @Column
+ public canAddUsers: boolean = false;
+
+ @Column
+ public canRemoveUsers: boolean = false;
+
+ @Column
+ public canEditUserPermissions: boolean = false;
+
+ @AllowNull
+ @Column(DataType.TEXT)
+ public description: string | null = null;
+
+ @Column
+ public isInternal: boolean = true;
+
+ public getContributorGroupFullInfo(): ContributorGroupFullInfo {
+ return {
+ role: `${this.name}`,
+ description: `${this.description}`,
+ internal: this.isInternal
+ };
+ }
+}
+
+export interface ContributorGroupFullInfo {
+ role: string;
+ description: string;
+ internal: boolean;
+}
+ |
| 1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 | 1x +1x + +1x + + +1x + +1x + + + +1x + + +1x + + + + +1x + + +1x + + +1x + + + + +1x + + +1x + + +1x + + + +1x + + + +1x + + | import { default as Project } from './Project';
+import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, HasMany,
+ HasOne, Model, PrimaryKey, Table, UpdatedAt } from 'sequelize-typescript';
+import { default as User } from './User';
+
+@Table
+export default class File extends Model<File> {
+ @Column
+ public name: string = '';
+
+ @PrimaryKey
+ @Column
+ public uuid: string = '';
+
+ @Column
+ public mimetype: string = '';
+
+ @ForeignKey(() => File)
+ @AllowNull
+ @Column(DataType.TEXT)
+ public parentFolderId: string | null = null;
+
+ @BelongsTo(() => File)
+ public parentFolder: File = new File();
+
+ @HasMany(() => File)
+ public containedFiles: File[] = [];
+
+ @ForeignKey(() => User)
+ @AllowNull
+ @Column(DataType.TEXT)
+ public creatorName: string | null = null;
+
+ @BelongsTo(() => User)
+ public creator: User = new User();
+
+ @HasOne(() => Project)
+ public rootFolderOf: Project = new Project();
+
+ @CreatedAt
+ @Column
+ public uploadDate: Date = new Date();
+
+ @UpdatedAt
+ @Column
+ public modifyDate: Date = new Date();
+}
+ |
| 1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 | +1x +1x + +1x +1x + + +1x + + + +1x + + +1x + + + +1x + + +1x + + + +1x + + + +1x + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | import { default as ContributorGroup } from './ContributorGroup';
+import { default as File } from './File';
+import { BelongsTo, BelongsToMany, Column, CreatedAt, ForeignKey,
+ Model, PrimaryKey, Table, UpdatedAt } from 'sequelize-typescript';
+import { default as User } from './User';
+import { default as UserJoinsProject } from './UserJoinsProject';
+
+@Table
+export default class Project extends Model<Project> {
+
+ @PrimaryKey
+ @Column
+ public name: string = '';
+
+ @BelongsToMany(() => User, () => UserJoinsProject)
+ public contributors: User[] = [];
+
+ @ForeignKey(() => File)
+ @Column
+ public rootFolderId: string = '';
+
+ @BelongsTo(() => File)
+ public rootFolder: File = new File();
+
+ @CreatedAt
+ @Column
+ public creationDate: Date = new Date();
+
+ @UpdatedAt
+ @Column
+ public lastActivity: Date = new Date();
+
+ public getAccessLevel(user: User): ContributorGroup {
+ throw new Error(`unimplemented, ${this}`);
+ }
+
+ public getUserInfo(user: User): UserInfo {
+ return {
+ username: user.username,
+ access_level: this.getAccessLevel(user)
+ .toString()
+ };
+ }
+
+ public getProjectFullInfo(): ProjectFullInfo {
+ return {
+ project_name: this.name,
+ users: this.contributors
+ .map<UserInfo>(
+ (u: User) => this.getUserInfo(u)
+ ),
+ public_metadata: {
+ creation_date: this.creationDate
+ },
+ // TODO: Check if we have anything to use these for yet?
+ private_metadata: {},
+ admin_metadata: {}
+ };
+ }
+}
+
+interface Metadata {}
+
+interface UserInfo {
+ username: string;
+ access_level: string;
+}
+
+export interface ProjectFullInfo {
+ project_name: string;
+ users: UserInfo[];
+ public_metadata: Metadata;
+ private_metadata?: Metadata;
+ admin_metadata?: Metadata;
+}
+ |
| 1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 | 1x +1x +1x + +1x +1x + + +1x + + +1x + + +1x + + + +1x + + +1x + + +1x + + +1x + + + +1x + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | import { default as File } from './File';
+import { default as Project } from './Project';
+import { BelongsTo, BelongsToMany, Column, CreatedAt, ForeignKey, HasMany,
+ Model, PrimaryKey, Table } from 'sequelize-typescript';
+import { default as UserGroup } from './UserGroup';
+import { default as UserJoinsProject } from './UserJoinsProject';
+
+@Table
+export default class User extends Model<User> {
+ @PrimaryKey
+ @Column
+ public username: string = '';
+
+ @Column
+ public password: string = '';
+
+ @ForeignKey(() => UserGroup)
+ @Column
+ public userGroupId: number = 0;
+
+ @BelongsTo(() => UserGroup)
+ public userGroup: UserGroup = new UserGroup();
+
+ @BelongsToMany(() => Project, () => UserJoinsProject)
+ public projects: Project[] = [];
+
+ @HasMany(() => File)
+ public createdFiles: File[] = [];
+
+ @CreatedAt
+ @Column
+ public creationDate: Date = new Date();
+
+ // TODO implement
+ public getAccessLevel(project: Project): string {
+ throw new Error(`unimplemented, ${this}`);
+ }
+
+ public getProjectInfo(project: Project): ProjectInfo {
+ return {
+ project_name: project.name,
+ access_level: this.getAccessLevel(project)
+ };
+ }
+
+ public getUserFullInfo(): UserFullInfo {
+ return {
+ username : this.username,
+ privileges: [`${this.userGroup.name}`],
+ projects : this.projects.map<ProjectInfo>(
+ (p: Project) => this.getProjectInfo(p)
+ ),
+ // TODO: Check if we have anything to use these for yet?
+ public_user_metadata: {},
+ private_user_metadata: {},
+ public_admin_metadata: {},
+ private_admin_metadata: {}
+ };
+ }
+}
+
+// TODO MAKE PRETTY below
+interface Metadata {}
+
+interface ProjectInfo {
+ project_name: string;
+ access_level: string;
+}
+
+export interface UserFullInfo {
+ username: string;
+ privileges: string[];
+ projects: ProjectInfo[];
+ public_user_metadata: Metadata;
+ private_user_metadata: Metadata;
+ public_admin_metadata: Metadata;
+ private_admin_metadata: Metadata;
+}
+ |
| 1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 | 1x + +1x + + + + + + + + +1x + + +1x + + +1x + + +1x + + +1x + + +1x + + +1x + + +1x + + +1x + + +1x + + + +1x + + + + + + + + + + | import { AllowNull, Column, DataType, HasMany, Model, Table
+ } from 'sequelize-typescript';
+import { default as User } from './User';
+
+interface UserPrivilege {
+ privilege: string;
+ description: string;
+ internal: boolean;
+}
+
+@Table
+export default class UserGroup extends Model<UserGroup> {
+ @AllowNull
+ @Column(DataType.TEXT)
+ public name: string | null = null;
+
+ @HasMany(() => User)
+ public users: User[] = [];
+
+ @Column
+ public canCreateUsers: boolean = false;
+
+ @Column
+ public canDeleteUsers: boolean = false;
+
+ @Column
+ public canEditUsers: boolean = false;
+
+ @Column
+ public canCreateProjects: boolean = false;
+
+ @Column
+ public canDeleteProjects: boolean = false;
+
+ @Column
+ public canEditProjects: boolean = false;
+
+ @Column
+ public isInternal: boolean = true;
+
+ @AllowNull
+ @Column(DataType.TEXT)
+ public description: string | null = null;
+
+ public getPrivelege(): UserPrivilege {
+ return {
+ privilege : `${this.name}`,
+ description : `${this.description}`,
+ internal : this.isInternal
+ };
+ }
+}
+ |
| 1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 | 1x +1x + +1x +1x + + +1x + + +1x + + + +1x + + + +1x + + + +1x + + +1x + + | import { default as Project } from './Project';
+import { BelongsTo, Column, CreatedAt, ForeignKey, Model, Table
+ } from 'sequelize-typescript';
+import { default as User } from './User';
+import { default as ContributorGroup } from './UserGroup';
+
+@Table
+export default class UserJoinsProject extends Model<UserJoinsProject> {
+ @ForeignKey(() => User)
+ @Column
+ public username: string = '';
+
+ @ForeignKey(() => Project)
+ @Column
+ public projectName: string = '';
+
+ @CreatedAt
+ @Column
+ public joinDate: Date = new Date();
+
+ @ForeignKey(() => ContributorGroup)
+ @Column
+ public contributorGroupId: number = 0;
+
+ @BelongsTo(() => ContributorGroup)
+ public contributorGroup: ContributorGroup = new ContributorGroup();
+}
+ |
| File | ++ | Statements | ++ | Branches | ++ | Functions | ++ | Lines | ++ |
|---|---|---|---|---|---|---|---|---|---|
| ContributorGroup.ts | +53.85% | +14/26 | +100% | +0/0 | +0% | +0/3 | +86.67% | +13/15 | +|
| File.ts | +48.48% | +16/33 | +100% | +0/0 | +0% | +0/7 | +71.43% | +15/21 | +|
| Project.ts | +46.15% | +12/26 | +100% | +0/0 | +0% | +0/9 | +61.11% | +11/18 | +|
| User.ts | +46.67% | +14/30 | +100% | +0/0 | +0% | +0/10 | +61.9% | +13/21 | +|
| UserGroup.ts | +53.85% | +14/26 | +100% | +0/0 | +0% | +0/3 | +86.67% | +13/15 | +|
| UserJoinsProject.ts | +55% | +11/20 | +100% | +0/0 | +0% | +0/5 | +71.43% | +10/14 | +