@dirayaah/assessment-module 1.0.7 → 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 (50) hide show
  1. package/dist/src/dto/assessment.dto.d.ts +1 -0
  2. package/dist/src/dto/assessment.dto.js +6 -0
  3. package/dist/src/dto/assessment.dto.js.map +1 -1
  4. package/dist/src/entities/assessment-report-section.d.ts +10 -0
  5. package/dist/src/entities/assessment-report-section.js +49 -0
  6. package/dist/src/entities/assessment-report-section.js.map +1 -0
  7. package/dist/src/entities/assessment-report-template.d.ts +8 -0
  8. package/dist/src/entities/assessment-report-template.js +38 -0
  9. package/dist/src/entities/assessment-report-template.js.map +1 -0
  10. package/dist/src/entities/assessment.entity.d.ts +3 -0
  11. package/dist/src/entities/assessment.entity.js +9 -0
  12. package/dist/src/entities/assessment.entity.js.map +1 -1
  13. package/dist/src/entities/index.d.ts +3 -1
  14. package/dist/src/entities/index.js +5 -1
  15. package/dist/src/entities/index.js.map +1 -1
  16. package/dist/src/migrations/1771928046729-AlterAssessmentsAddAnalyzerHelperUrl.d.ts +7 -0
  17. package/dist/src/migrations/1771928046729-AlterAssessmentsAddAnalyzerHelperUrl.js +26 -0
  18. package/dist/src/migrations/1771928046729-AlterAssessmentsAddAnalyzerHelperUrl.js.map +1 -0
  19. package/dist/src/migrations/1772483026912-CreateAssessmentReportTemplate.d.ts +6 -0
  20. package/dist/src/migrations/1772483026912-CreateAssessmentReportTemplate.js +49 -0
  21. package/dist/src/migrations/1772483026912-CreateAssessmentReportTemplate.js.map +1 -0
  22. package/dist/src/migrations/1772497129497-createAssessmentReportSectionTable.d.ts +6 -0
  23. package/dist/src/migrations/1772497129497-createAssessmentReportSectionTable.js +70 -0
  24. package/dist/src/migrations/1772497129497-createAssessmentReportSectionTable.js.map +1 -0
  25. package/dist/src/migrations/index.d.ts +4 -1
  26. package/dist/src/migrations/index.js +10 -1
  27. package/dist/src/migrations/index.js.map +1 -1
  28. package/dist/src/repositories/assessment-report-section.repository.d.ts +4 -0
  29. package/dist/src/repositories/assessment-report-section.repository.js +19 -0
  30. package/dist/src/repositories/assessment-report-section.repository.js.map +1 -0
  31. package/dist/src/repositories/assessment-report-template.repository.d.ts +4 -0
  32. package/dist/src/repositories/assessment-report-template.repository.js +19 -0
  33. package/dist/src/repositories/assessment-report-template.repository.js.map +1 -0
  34. package/dist/src/repositories/index.d.ts +3 -1
  35. package/dist/src/repositories/index.js +5 -1
  36. package/dist/src/repositories/index.js.map +1 -1
  37. package/dist/tsconfig.tsbuildinfo +1 -1
  38. package/package.json +1 -1
  39. package/src/dto/assessment.dto.ts +5 -0
  40. package/src/entities/assessment-report-section.ts +36 -0
  41. package/src/entities/assessment-report-template.ts +30 -0
  42. package/src/entities/assessment.entity.ts +9 -1
  43. package/src/entities/index.ts +4 -0
  44. package/src/migrations/1771928046729-AlterAssessmentsAddAnalyzerHelperUrl.ts +25 -0
  45. package/src/migrations/1772483026912-CreateAssessmentReportTemplate.ts +49 -0
  46. package/src/migrations/1772497129497-CreateAssessmentReportSectionTable.ts +70 -0
  47. package/src/migrations/index.ts +9 -0
  48. package/src/repositories/assessment-report-section.repository.ts +6 -0
  49. package/src/repositories/assessment-report-template.repository.ts +6 -0
  50. 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.7",
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",
@@ -68,6 +68,11 @@ export class AssessmentDto extends BaseDTO {
68
68
  @IsString()
69
69
  metaDescription?: string;
70
70
 
71
+ @ApiPropertyOptional({ example: 'Url of assessment analyzer helper' })
72
+ @IsOptional()
73
+ @IsString()
74
+ analyzerHelperUrl?: string;
75
+
71
76
  @ApiPropertyOptional({ example: 'SEO meta description for the assessment' })
72
77
  @IsOptional()
73
78
  @IsObject()
@@ -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 {
@@ -40,9 +42,15 @@ export class AssessmentEntity extends BaseEntity {
40
42
  @Column({ nullable: true, name: 'meta_description' })
41
43
  metaDescription?: string;
42
44
 
45
+ @Column({ nullable: true, name: 'analyzer_helper_url' })
46
+ analyzerHelperUrl?: string;
47
+
43
48
  @OneToMany(
44
49
  () => AssessmentResponseEntity,
45
50
  (assessmentResponse) => assessmentResponse.assessment,
46
51
  )
47
52
  responses?: AssessmentResponseEntity[];
53
+
54
+ @OneToOne(() => AssessmentReportTemplateEntity, (report) => report.assessment)
55
+ report?: AssessmentReportTemplateEntity;
48
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,25 @@
1
+ import { MigrationInterface, QueryRunner, TableColumn } from 'typeorm';
2
+
3
+ export class AlterAssessmentsAddAnalyzerHelperUrl1771928046729 implements MigrationInterface {
4
+ private tableName = 'assessment';
5
+ private columnName = 'analyzer_helper_url';
6
+
7
+ public async up(queryRunner: QueryRunner): Promise<void> {
8
+ if (!(await queryRunner.hasColumn(this.tableName, this.columnName))) {
9
+ await queryRunner.addColumn(
10
+ this.tableName,
11
+ new TableColumn({
12
+ name: this.columnName,
13
+ type: 'varchar',
14
+ isNullable: true,
15
+ }),
16
+ );
17
+ }
18
+ }
19
+
20
+ public async down(queryRunner: QueryRunner): Promise<void> {
21
+ if (await queryRunner.hasColumn(this.tableName, this.columnName)) {
22
+ await queryRunner.dropColumn(this.tableName, this.columnName);
23
+ }
24
+ }
25
+ }
@@ -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
+ }
@@ -8,6 +8,9 @@ import { AddMetaFieldsToAssessmentTable1767651698587 } from './1767651698587-Add
8
8
  import { CreateAssessmentResponseTable1769428739895 } from './1769428739895-CreateAssessmentResponseTable';
9
9
  import { AlterAssessmentResponseTable1771110620466 } from './1771110620466-AlterAssessmentResponseTable';
10
10
  import { AlterAssessmentResponseAddSummary1771247066741 } from './1771247066741-AlterAssessmentResponseAddSummary';
11
+ import { AlterAssessmentsAddAnalyzerHelperUrl1771928046729 } from './1771928046729-AlterAssessmentsAddAnalyzerHelperUrl';
12
+ import { CreateAssessmentReportSectionTable1772497129497 } from './1772497129497-createAssessmentReportSectionTable';
13
+ import { CreateAssessmentReportTemplate1772483026912 } from './1772483026912-CreateAssessmentReportTemplate';
11
14
  export const AssessmentMigrations = [
12
15
  CreateAssessmentTable1767108782301,
13
16
  CreatePredefinedAssessmentTable1767200020161,
@@ -16,6 +19,9 @@ export const AssessmentMigrations = [
16
19
  CreateAssessmentResponseTable1769428739895,
17
20
  AlterAssessmentResponseTable1771110620466,
18
21
  AlterAssessmentResponseAddSummary1771247066741,
22
+ AlterAssessmentsAddAnalyzerHelperUrl1771928046729,
23
+ CreateAssessmentReportSectionTable1772497129497,
24
+ CreateAssessmentReportTemplate1772483026912,
19
25
  ];
20
26
 
21
27
  export {
@@ -26,4 +32,7 @@ export {
26
32
  CreateAssessmentResponseTable1769428739895,
27
33
  AlterAssessmentResponseTable1771110620466,
28
34
  AlterAssessmentResponseAddSummary1771247066741,
35
+ AlterAssessmentsAddAnalyzerHelperUrl1771928046729,
36
+ CreateAssessmentReportSectionTable1772497129497,
37
+ CreateAssessmentReportTemplate1772483026912,
29
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
  };