@dirayaah/assessment-module 1.0.8 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/src/entities/assessment-report-section.d.ts +10 -0
  2. package/dist/src/entities/assessment-report-section.js +49 -0
  3. package/dist/src/entities/assessment-report-section.js.map +1 -0
  4. package/dist/src/entities/assessment-report-template.d.ts +8 -0
  5. package/dist/src/entities/assessment-report-template.js +38 -0
  6. package/dist/src/entities/assessment-report-template.js.map +1 -0
  7. package/dist/src/entities/assessment.entity.d.ts +2 -0
  8. package/dist/src/entities/assessment.entity.js +5 -0
  9. package/dist/src/entities/assessment.entity.js.map +1 -1
  10. package/dist/src/entities/index.d.ts +3 -1
  11. package/dist/src/entities/index.js +5 -1
  12. package/dist/src/entities/index.js.map +1 -1
  13. package/dist/src/migrations/1772483026912-CreateAssessmentReportTemplate.d.ts +6 -0
  14. package/dist/src/migrations/1772483026912-CreateAssessmentReportTemplate.js +49 -0
  15. package/dist/src/migrations/1772483026912-CreateAssessmentReportTemplate.js.map +1 -0
  16. package/dist/src/migrations/1772497129497-createAssessmentReportSectionTable.d.ts +6 -0
  17. package/dist/src/migrations/1772497129497-createAssessmentReportSectionTable.js +70 -0
  18. package/dist/src/migrations/1772497129497-createAssessmentReportSectionTable.js.map +1 -0
  19. package/dist/src/migrations/index.d.ts +3 -1
  20. package/dist/src/migrations/index.js +7 -1
  21. package/dist/src/migrations/index.js.map +1 -1
  22. package/dist/src/repositories/assessment-report-section.repository.d.ts +4 -0
  23. package/dist/src/repositories/assessment-report-section.repository.js +19 -0
  24. package/dist/src/repositories/assessment-report-section.repository.js.map +1 -0
  25. package/dist/src/repositories/assessment-report-template.repository.d.ts +4 -0
  26. package/dist/src/repositories/assessment-report-template.repository.js +19 -0
  27. package/dist/src/repositories/assessment-report-template.repository.js.map +1 -0
  28. package/dist/src/repositories/index.d.ts +3 -1
  29. package/dist/src/repositories/index.js +5 -1
  30. package/dist/src/repositories/index.js.map +1 -1
  31. package/dist/tsconfig.tsbuildinfo +1 -1
  32. package/package.json +1 -1
  33. package/src/entities/assessment-report-section.ts +36 -0
  34. package/src/entities/assessment-report-template.ts +30 -0
  35. package/src/entities/assessment.entity.ts +6 -1
  36. package/src/entities/index.ts +4 -0
  37. package/src/migrations/1772483026912-CreateAssessmentReportTemplate.ts +49 -0
  38. package/src/migrations/1772497129497-CreateAssessmentReportSectionTable.ts +70 -0
  39. package/src/migrations/index.ts +6 -0
  40. package/src/repositories/assessment-report-section.repository.ts +6 -0
  41. package/src/repositories/assessment-report-template.repository.ts +6 -0
  42. package/src/repositories/index.ts +4 -1
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.0.8",
6
+ "version": "1.1.0",
7
7
  "description": "A reusable module for handling assessments in nestjs applications",
8
8
  "main": "dist/index.js",
9
9
  "type": "commonjs",
@@ -0,0 +1,36 @@
1
+ /* eslint-disable @typescript-eslint/no-unused-vars */
2
+ import { Entity, Column, ManyToOne, JoinColumn } from 'typeorm';
3
+ import { BaseEntity } from './base.entity';
4
+ import { AssessmentEntity } from './assessment.entity';
5
+ import { AssessmentReportTemplateEntity } from './assessment-report-template';
6
+
7
+ /**
8
+ * An Assessment Report Section.
9
+ */
10
+ @Entity('assessment_report_section')
11
+ export class AssessmentReportSectionEntity extends BaseEntity {
12
+ @Column({ name: 'title', nullable: true })
13
+ title?: string;
14
+
15
+ @Column({ name: 'content', nullable: true })
16
+ content?: string;
17
+
18
+ @Column({ name: 'type' })
19
+ type!: string;
20
+
21
+ @Column({ name: 'order', type: 'int' })
22
+ order!: number;
23
+
24
+ @Column({ type: 'jsonb', name: 'configuration', nullable: true })
25
+ configuration?: Record<string, string> | null;
26
+
27
+ @ManyToOne(
28
+ () => AssessmentReportTemplateEntity,
29
+ (report) => report.sections,
30
+ {
31
+ onDelete: 'CASCADE',
32
+ },
33
+ )
34
+ @JoinColumn({ name: 'reportId' })
35
+ report!: AssessmentReportTemplateEntity;
36
+ }
@@ -0,0 +1,30 @@
1
+ /* eslint-disable @typescript-eslint/no-unused-vars */
2
+ import {
3
+ Entity,
4
+ Column,
5
+ ManyToOne,
6
+ JoinColumn,
7
+ OneToOne,
8
+ OneToMany,
9
+ } from 'typeorm';
10
+ import { BaseEntity } from './base.entity';
11
+ import { AssessmentEntity } from './assessment.entity';
12
+ import { AssessmentReportSectionEntity } from './assessment-report-section';
13
+
14
+ /**
15
+ * An Assessment Report Template.
16
+ */
17
+ @Entity('assessment_report_template')
18
+ export class AssessmentReportTemplateEntity extends BaseEntity {
19
+ @Column({ name: 'title', nullable: true })
20
+ title?: string;
21
+
22
+ @OneToOne(() => AssessmentEntity, (assessment) => assessment.report, {
23
+ onDelete: 'CASCADE',
24
+ })
25
+ @JoinColumn({ name: 'assessmentId' })
26
+ assessment!: AssessmentEntity;
27
+
28
+ @OneToMany(() => AssessmentReportSectionEntity, (section) => section.report)
29
+ sections!: AssessmentReportSectionEntity[];
30
+ }
@@ -1,6 +1,8 @@
1
- import { Column, Entity, OneToMany } from 'typeorm/index.js';
1
+ import { Column, Entity, OneToMany, OneToOne } from 'typeorm/index.js';
2
2
  import { BaseEntity } from './base.entity';
3
3
  import { AssessmentResponseEntity } from './assessment-response.entity';
4
+ import { AssessmentReportSectionEntity } from './assessment-report-section';
5
+ import { AssessmentReportTemplateEntity } from './assessment-report-template';
4
6
 
5
7
  @Entity('assessment')
6
8
  export class AssessmentEntity extends BaseEntity {
@@ -48,4 +50,7 @@ export class AssessmentEntity extends BaseEntity {
48
50
  (assessmentResponse) => assessmentResponse.assessment,
49
51
  )
50
52
  responses?: AssessmentResponseEntity[];
53
+
54
+ @OneToOne(() => AssessmentReportTemplateEntity, (report) => report.assessment)
55
+ report?: AssessmentReportTemplateEntity;
51
56
  }
@@ -1,9 +1,13 @@
1
1
  import { AssessmentEntity } from './assessment.entity';
2
2
  import { PredefinedAssessmentEntity } from './predefined-assessment.entity';
3
3
  import { AssessmentResponseEntity } from './assessment-response.entity';
4
+ import { AssessmentReportSectionEntity } from './assessment-report-section';
5
+ import { AssessmentReportTemplateEntity } from './assessment-report-template';
4
6
 
5
7
  export {
6
8
  AssessmentEntity,
7
9
  PredefinedAssessmentEntity,
8
10
  AssessmentResponseEntity,
11
+ AssessmentReportSectionEntity,
12
+ AssessmentReportTemplateEntity,
9
13
  };
@@ -0,0 +1,49 @@
1
+ import { baseColumns } from '../utilities/migrations/get-base-columns';
2
+ import { MigrationInterface, QueryRunner, Table } from 'typeorm';
3
+
4
+ export class CreateAssessmentReportTemplate1772483026912 implements MigrationInterface {
5
+ private tableName = 'assessment_report_template';
6
+
7
+ public async up(queryRunner: QueryRunner): Promise<void> {
8
+ const [idColumn, ...otherBaseColumns] = baseColumns;
9
+
10
+ await queryRunner.createTable(
11
+ new Table({
12
+ name: this.tableName,
13
+ columns: [
14
+ idColumn,
15
+ {
16
+ name: 'title',
17
+ type: 'varchar',
18
+ isNullable: true,
19
+ },
20
+ {
21
+ name: 'assessmentId',
22
+ type: 'int4',
23
+ },
24
+ ...otherBaseColumns,
25
+ ],
26
+ foreignKeys: [
27
+ {
28
+ columnNames: ['assessmentId'],
29
+ referencedColumnNames: ['id'],
30
+ referencedTableName: 'assessment',
31
+ onDelete: 'CASCADE',
32
+ name: `${this.tableName}_assessment_id_fk`,
33
+ },
34
+ ],
35
+ indices: [
36
+ {
37
+ columnNames: ['assessmentId'],
38
+ name: `IDX_${this.tableName}_assessment_id`,
39
+ },
40
+ ],
41
+ }),
42
+ false,
43
+ );
44
+ }
45
+
46
+ public async down(queryRunner: QueryRunner): Promise<void> {
47
+ await queryRunner.dropTable(this.tableName, true, true, true);
48
+ }
49
+ }
@@ -0,0 +1,70 @@
1
+ import { baseColumns } from '../utilities/migrations/get-base-columns';
2
+ import { MigrationInterface, QueryRunner, Table } from 'typeorm';
3
+
4
+ export class CreateAssessmentReportSectionTable1772497129497 implements MigrationInterface {
5
+ private tableName = 'assessment_report_section';
6
+
7
+ public async up(queryRunner: QueryRunner): Promise<void> {
8
+ const [idColumn, ...otherBaseColumns] = baseColumns;
9
+
10
+ await queryRunner.createTable(
11
+ new Table({
12
+ name: this.tableName,
13
+ columns: [
14
+ idColumn,
15
+ {
16
+ name: 'title',
17
+ type: 'varchar',
18
+ isNullable: true,
19
+ },
20
+ {
21
+ name: 'content',
22
+ type: 'varchar',
23
+ isNullable: true,
24
+ },
25
+ {
26
+ name: 'type',
27
+ type: 'varchar',
28
+ isNullable: false,
29
+ },
30
+ {
31
+ name: 'order',
32
+ type: 'int4',
33
+ isNullable: false,
34
+ },
35
+ {
36
+ name: 'reportId',
37
+ type: 'int4',
38
+ isNullable: false,
39
+ },
40
+ {
41
+ name: 'configuration',
42
+ type: 'jsonb',
43
+ isNullable: true,
44
+ },
45
+ ...otherBaseColumns,
46
+ ],
47
+ foreignKeys: [
48
+ {
49
+ columnNames: ['reportId'],
50
+ referencedColumnNames: ['id'],
51
+ referencedTableName: 'assessment_report_template',
52
+ onDelete: 'CASCADE',
53
+ name: `${this.tableName}_report_id_fk`,
54
+ },
55
+ ],
56
+ indices: [
57
+ {
58
+ columnNames: ['reportId'],
59
+ name: `IDX_${this.tableName}_report_id`,
60
+ },
61
+ ],
62
+ }),
63
+ false,
64
+ );
65
+ }
66
+
67
+ public async down(queryRunner: QueryRunner): Promise<void> {
68
+ await queryRunner.dropTable(this.tableName, true, true, true);
69
+ }
70
+ }
@@ -9,6 +9,8 @@ import { CreateAssessmentResponseTable1769428739895 } from './1769428739895-Crea
9
9
  import { AlterAssessmentResponseTable1771110620466 } from './1771110620466-AlterAssessmentResponseTable';
10
10
  import { AlterAssessmentResponseAddSummary1771247066741 } from './1771247066741-AlterAssessmentResponseAddSummary';
11
11
  import { AlterAssessmentsAddAnalyzerHelperUrl1771928046729 } from './1771928046729-AlterAssessmentsAddAnalyzerHelperUrl';
12
+ import { CreateAssessmentReportSectionTable1772497129497 } from './1772497129497-createAssessmentReportSectionTable';
13
+ import { CreateAssessmentReportTemplate1772483026912 } from './1772483026912-CreateAssessmentReportTemplate';
12
14
  export const AssessmentMigrations = [
13
15
  CreateAssessmentTable1767108782301,
14
16
  CreatePredefinedAssessmentTable1767200020161,
@@ -18,6 +20,8 @@ export const AssessmentMigrations = [
18
20
  AlterAssessmentResponseTable1771110620466,
19
21
  AlterAssessmentResponseAddSummary1771247066741,
20
22
  AlterAssessmentsAddAnalyzerHelperUrl1771928046729,
23
+ CreateAssessmentReportSectionTable1772497129497,
24
+ CreateAssessmentReportTemplate1772483026912,
21
25
  ];
22
26
 
23
27
  export {
@@ -29,4 +33,6 @@ export {
29
33
  AlterAssessmentResponseTable1771110620466,
30
34
  AlterAssessmentResponseAddSummary1771247066741,
31
35
  AlterAssessmentsAddAnalyzerHelperUrl1771928046729,
36
+ CreateAssessmentReportSectionTable1772497129497,
37
+ CreateAssessmentReportTemplate1772483026912,
32
38
  };
@@ -0,0 +1,6 @@
1
+ import { EntityRepository } from 'typeorm';
2
+ import { AssessmentReportSectionEntity } from '../entities';
3
+ import { BaseRepository } from './base.repository';
4
+
5
+ @EntityRepository(AssessmentReportSectionEntity)
6
+ export class AssessmentReportSectionRepository extends BaseRepository<AssessmentReportSectionEntity> {}
@@ -0,0 +1,6 @@
1
+ import { EntityRepository } from 'typeorm';
2
+ import { AssessmentReportTemplateEntity } from '../entities';
3
+ import { BaseRepository } from './base.repository';
4
+
5
+ @EntityRepository(AssessmentReportTemplateEntity)
6
+ export class AssessmentReportTemplateRepository extends BaseRepository<AssessmentReportTemplateEntity> {}
@@ -1,9 +1,12 @@
1
1
  import { AssessmentRepository } from './assessment.repository';
2
2
  import { PredefinedAssessmentRepository } from './predefined-assessment.repository';
3
3
  import { AssessmentResponseRepository } from './assessment-response.repository';
4
-
4
+ import { AssessmentReportSectionRepository } from './assessment-report-section.repository';
5
+ import { AssessmentReportTemplateRepository } from './assessment-report-template.repository';
5
6
  export {
6
7
  AssessmentRepository,
7
8
  PredefinedAssessmentRepository,
8
9
  AssessmentResponseRepository,
10
+ AssessmentReportSectionRepository,
11
+ AssessmentReportTemplateRepository,
9
12
  };