@studyportals/fawkes 7.2.2-11 → 7.2.2-13

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.
@@ -28,12 +28,11 @@ export class DegreeAttendanceDiscipline extends ProgrammesBaseIndexabilityPolicy
28
28
  const attendanceFragments = AttendancePresenter.getInstance().getFragments();
29
29
  const disciplineFragments = DisciplinePresenter.getInstance().getFragments();
30
30
  const paths = [];
31
- // Process Master of Science, Master of Arts, and Master of Business Administration degrees with online attendance
32
31
  const allowedDegreeIds = [
33
32
  DegreeTypeFilterOptionValue.MA,
34
33
  DegreeTypeFilterOptionValue.MSC,
35
34
  DegreeTypeFilterOptionValue.MBA
36
- ].map(id => id.valueOf());
35
+ ];
37
36
  const onlineAttendance = attendanceFragments.find(a => a.id === 'online');
38
37
  if (!onlineAttendance) {
39
38
  return paths;
@@ -2,7 +2,6 @@ import { FilterKey } from '@studyportals/search-filters';
2
2
  import { OnlyFiltersSelectedRule } from '../../common/rules/OnlyFiltersSelectedRule';
3
3
  import { SingleValueSelectedForFilterRule } from '../../common/rules/SingleValueSelectedForFilterRule';
4
4
  import { FilterCombinations } from '../../enums/FilterCombinations';
5
- import { IndexableDegreeRule } from '../rules/IndexableDegreeRule';
6
5
  import { DegreeDisciplineRule } from '../rules/DegreeDisciplineRule';
7
6
  import { ProgrammesBaseIndexabilityPolicy } from '../ProgrammesBaseIndexabilityPolicy';
8
7
  import { IProgrammeSeoDependencies } from '../types/IProgrammeSeoDependencies';
@@ -10,7 +9,7 @@ export declare class DisciplineDegree extends ProgrammesBaseIndexabilityPolicy {
10
9
  readonly name: string;
11
10
  readonly description: string;
12
11
  readonly filterKeys: FilterKey[];
13
- protected readonly rules: (SingleValueSelectedForFilterRule | OnlyFiltersSelectedRule | IndexableDegreeRule | DegreeDisciplineRule)[];
12
+ protected readonly rules: (SingleValueSelectedForFilterRule | OnlyFiltersSelectedRule | DegreeDisciplineRule)[];
14
13
  constructor(dependencies: IProgrammeSeoDependencies);
15
14
  protected generateUrls(): Promise<string[]>;
16
15
  get filterCombination(): FilterCombinations;
@@ -2,7 +2,6 @@ import { FilterKey } from '@studyportals/search-filters';
2
2
  import { OnlyFiltersSelectedRule } from '../../common/rules/OnlyFiltersSelectedRule';
3
3
  import { SingleValueSelectedForFilterRule } from '../../common/rules/SingleValueSelectedForFilterRule';
4
4
  import { FilterCombinations } from '../../enums/FilterCombinations';
5
- import { IndexableDegreeRule } from '../rules/IndexableDegreeRule';
6
5
  import { DegreeDisciplineRule } from '../rules/DegreeDisciplineRule';
7
6
  import { ProgrammesBaseIndexabilityPolicy } from '../ProgrammesBaseIndexabilityPolicy';
8
7
  import { DisciplinePresenter } from '../../presenters/DisciplinePresenter';
@@ -15,7 +14,6 @@ export class DisciplineDegree extends ProgrammesBaseIndexabilityPolicy {
15
14
  new SingleValueSelectedForFilterRule(FilterKey.DISCIPLINES),
16
15
  new SingleValueSelectedForFilterRule(FilterKey.DEGREE_TYPE),
17
16
  new OnlyFiltersSelectedRule([FilterKey.DISCIPLINES, FilterKey.DEGREE_TYPE]),
18
- new IndexableDegreeRule(),
19
17
  new DegreeDisciplineRule()
20
18
  ];
21
19
  constructor(dependencies) {
@@ -6,7 +6,7 @@ export class DegreeAttendanceDisciplineSpecificRule extends BaseProgrammeRule {
6
6
  DegreeTypeFilterOptionValue.MSC,
7
7
  DegreeTypeFilterOptionValue.MA,
8
8
  DegreeTypeFilterOptionValue.MBA
9
- ].map(id => id.valueOf());
9
+ ];
10
10
  allowedAttendance = 'online';
11
11
  getName() {
12
12
  return 'DegreeAttendanceDisciplineSpecificRule';
@@ -18,7 +18,8 @@ export class DegreeAttendanceDisciplineSpecificRule extends BaseProgrammeRule {
18
18
  const { seoInfoBase, filterState } = dependencies;
19
19
  const degreeTypeValue = seoInfoBase.getFilterOptionValueBy(FilterKey.DEGREE_TYPE, filterState);
20
20
  const attendanceValue = seoInfoBase.getFilterOptionValueBy(FilterKey.DELIVERY_METHOD, filterState);
21
- if (!degreeTypeValue || !attendanceValue) {
21
+ const disciplineValue = seoInfoBase.getFilterOptionValueBy(FilterKey.DISCIPLINES, filterState);
22
+ if (!degreeTypeValue || !attendanceValue || !disciplineValue) {
22
23
  return Promise.resolve(false);
23
24
  }
24
25
  return Promise.resolve(this.allowedDegrees.includes(degreeTypeValue) &&
@@ -3,15 +3,11 @@ import { FilterKeyValuesMap } from '../../common/FilterKeyValuesMap';
3
3
  import { BaseProgrammeRule } from '../BaseProgrammeRule';
4
4
  export declare class DegreeDisciplineRule extends BaseProgrammeRule {
5
5
  private readonly degreesAcceptingAllDisciplines;
6
- private readonly masterOfLawsDegree;
6
+ private readonly allIndexableDegrees;
7
7
  private readonly lawDisciplineIds;
8
- private readonly masterOfPhilosophyDegree;
9
8
  private readonly masterOfPhilosophyDisciplineIds;
10
- private readonly masterOfEducationDegree;
11
9
  private readonly educationDisciplineIds;
12
- private readonly masterOfEngineeringDegree;
13
10
  private readonly engineeringDisciplineIds;
14
- private readonly postgraduateDiplomaDegree;
15
11
  private readonly postgraduateDiplomaDisciplineIds;
16
12
  getName(): string;
17
13
  getDescription(): string;
@@ -6,8 +6,17 @@ export class DegreeDisciplineRule extends BaseProgrammeRule {
6
6
  DegreeTypeFilterOptionValue.MA,
7
7
  DegreeTypeFilterOptionValue.MSC,
8
8
  DegreeTypeFilterOptionValue.MBA
9
- ].map(id => id.valueOf());
10
- masterOfLawsDegree = DegreeTypeFilterOptionValue.LLM.valueOf();
9
+ ];
10
+ allIndexableDegrees = [
11
+ DegreeTypeFilterOptionValue.MA,
12
+ DegreeTypeFilterOptionValue.MSC,
13
+ DegreeTypeFilterOptionValue.MBA,
14
+ DegreeTypeFilterOptionValue.LLM,
15
+ DegreeTypeFilterOptionValue.MPHIL,
16
+ DegreeTypeFilterOptionValue.MED,
17
+ DegreeTypeFilterOptionValue.MENG,
18
+ DegreeTypeFilterOptionValue.POSTGRADIP
19
+ ];
11
20
  lawDisciplineIds = [
12
21
  '6', // Law (main discipline)
13
22
  '219', // Business Law
@@ -19,15 +28,21 @@ export class DegreeDisciplineRule extends BaseProgrammeRule {
19
28
  '220', // Legal Studies
20
29
  '221', // Master of Laws (LLM)
21
30
  '49', // Patent & Intellectual Property Law
22
- '115' // Public Law
31
+ '115', // Public Law
32
+ '247',
33
+ '278',
34
+ '87',
35
+ '323',
36
+ '108',
37
+ '362',
38
+ '241',
39
+ '127'
23
40
  ];
24
- masterOfPhilosophyDegree = DegreeTypeFilterOptionValue.MPHIL.valueOf();
25
41
  masterOfPhilosophyDisciplineIds = [
26
42
  '118', '23', '335', '71', '281', '4', '8', '293',
27
43
  '272', '330', '87', '111', '6', '332', '40', '308',
28
44
  '224', '113', '84', '38', '79', '278', '80'
29
45
  ];
30
- masterOfEducationDegree = DegreeTypeFilterOptionValue.MED.valueOf();
31
46
  educationDisciplineIds = [
32
47
  '289', // Education & Training (main discipline)
33
48
  '290', // Adult Education
@@ -50,7 +65,6 @@ export class DegreeDisciplineRule extends BaseProgrammeRule {
50
65
  '295', // Teaching
51
66
  '358' // Teaching English as a Foreign Language
52
67
  ];
53
- masterOfEngineeringDegree = DegreeTypeFilterOptionValue.MENG.valueOf();
54
68
  engineeringDisciplineIds = [
55
69
  '7', // Engineering & Technology (main discipline)
56
70
  '24', // Computer Science & IT
@@ -79,7 +93,6 @@ export class DegreeDisciplineRule extends BaseProgrammeRule {
79
93
  '397', // Production and Manufacturing Engineering
80
94
  '399' // Structural Engineering
81
95
  ];
82
- postgraduateDiplomaDegree = DegreeTypeFilterOptionValue.POSTGRADIP.valueOf();
83
96
  postgraduateDiplomaDisciplineIds = [
84
97
  '362', '241', '108', '133', '373', '356', '282', '311', '113', '79'
85
98
  ];
@@ -96,19 +109,22 @@ export class DegreeDisciplineRule extends BaseProgrammeRule {
96
109
  if (!degreeTypeValue || !disciplineValue) {
97
110
  return Promise.resolve(false);
98
111
  }
99
- if (degreeTypeValue === this.masterOfLawsDegree) {
112
+ if (!this.allIndexableDegrees.includes(degreeTypeValue)) {
113
+ return Promise.resolve(false);
114
+ }
115
+ if (degreeTypeValue === DegreeTypeFilterOptionValue.LLM) {
100
116
  return Promise.resolve(this.lawDisciplineIds.includes(disciplineValue));
101
117
  }
102
- if (degreeTypeValue === this.masterOfPhilosophyDegree) {
118
+ if (degreeTypeValue === DegreeTypeFilterOptionValue.MPHIL) {
103
119
  return Promise.resolve(this.masterOfPhilosophyDisciplineIds.includes(disciplineValue));
104
120
  }
105
- if (degreeTypeValue === this.masterOfEducationDegree) {
121
+ if (degreeTypeValue === DegreeTypeFilterOptionValue.MED) {
106
122
  return Promise.resolve(this.educationDisciplineIds.includes(disciplineValue));
107
123
  }
108
- if (degreeTypeValue === this.masterOfEngineeringDegree) {
124
+ if (degreeTypeValue === DegreeTypeFilterOptionValue.MENG) {
109
125
  return Promise.resolve(this.engineeringDisciplineIds.includes(disciplineValue));
110
126
  }
111
- if (degreeTypeValue === this.postgraduateDiplomaDegree) {
127
+ if (degreeTypeValue === DegreeTypeFilterOptionValue.POSTGRADIP) {
112
128
  return Promise.resolve(this.postgraduateDiplomaDisciplineIds.includes(disciplineValue));
113
129
  }
114
130
  if (this.degreesAcceptingAllDisciplines.includes(degreeTypeValue)) {
@@ -124,19 +140,25 @@ export class DegreeDisciplineRule extends BaseProgrammeRule {
124
140
  }
125
141
  const degreeTypeValue = degreeTypeValues[0];
126
142
  const disciplineValue = disciplineValues[0];
127
- if (degreeTypeValue === this.masterOfLawsDegree) {
143
+ if (!degreeTypeValue || !disciplineValue) {
144
+ return Promise.resolve(false);
145
+ }
146
+ if (!this.allIndexableDegrees.includes(degreeTypeValue)) {
147
+ return Promise.resolve(false);
148
+ }
149
+ if (degreeTypeValue === DegreeTypeFilterOptionValue.LLM) {
128
150
  return Promise.resolve(this.lawDisciplineIds.includes(disciplineValue));
129
151
  }
130
- if (degreeTypeValue === this.masterOfPhilosophyDegree) {
152
+ if (degreeTypeValue === DegreeTypeFilterOptionValue.MPHIL) {
131
153
  return Promise.resolve(this.masterOfPhilosophyDisciplineIds.includes(disciplineValue));
132
154
  }
133
- if (degreeTypeValue === this.masterOfEducationDegree) {
155
+ if (degreeTypeValue === DegreeTypeFilterOptionValue.MED) {
134
156
  return Promise.resolve(this.educationDisciplineIds.includes(disciplineValue));
135
157
  }
136
- if (degreeTypeValue === this.masterOfEngineeringDegree) {
158
+ if (degreeTypeValue === DegreeTypeFilterOptionValue.MENG) {
137
159
  return Promise.resolve(this.engineeringDisciplineIds.includes(disciplineValue));
138
160
  }
139
- if (degreeTypeValue === this.postgraduateDiplomaDegree) {
161
+ if (degreeTypeValue === DegreeTypeFilterOptionValue.POSTGRADIP) {
140
162
  return Promise.resolve(this.postgraduateDiplomaDisciplineIds.includes(disciplineValue));
141
163
  }
142
164
  if (this.degreesAcceptingAllDisciplines.includes(degreeTypeValue)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@studyportals/fawkes",
3
- "version": "7.2.2-11",
3
+ "version": "7.2.2-13",
4
4
  "description": "A package to centralize SEO related logic for SBLP and Sitemap Generator.",
5
5
  "files": [
6
6
  "./dist"
@@ -18,7 +18,7 @@
18
18
  "publish-minor": "npm run prepare-deployment && npm version minor && npm publish",
19
19
  "prepare": "husky install",
20
20
  "test": "vitest run --coverage",
21
- "test:dev": "vitest --coverage tests/programmes",
21
+ "test:dev": "vitest --coverage tests/programmes/policies/DegreeAttendanceDiscipline.test.mts",
22
22
  "lint": "eslint . --ext .ts",
23
23
  "lint:fix": "eslint . --ext .ts --fix",
24
24
  "prettier:fix": "npx prettier --use-tabs --ignore-path .gitignore --write ."