@studyportals/fawkes 8.5.3-1 → 8.5.3-2

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.
package/README.md CHANGED
@@ -1,176 +1,176 @@
1
- # fawkes
2
-
3
- This project is used to centralize indexability logic for our Search
4
- microservices and Sitemap Generator. The main purpose is to completely remove
5
- discrepancies between pages indexed by Search and page URLs stored in Sitemap.
6
-
7
- Link to documentation: https://studyportals.atlassian.net/wiki/x/BwAdvw
8
-
9
- ## Base structure
10
-
11
- - organisations-seo (used by Organisation Search)
12
- - scholarships-seo (used by Scholarship Search)
13
- - sitemap-generator-seo (used by Sitemap Generator)
14
- - src
15
- - common
16
- - organisations
17
- - scholarships
18
- - sitemap-generator
19
-
20
- # Automatic Documentation System
21
-
22
- ## Overview
23
-
24
- This system automatically generates and maintains documentation for Fawkes
25
- indexing rules across multiple projects. It creates a hierarchical structure of
26
- Confluence pages that document all indexing policies and rules, ensuring that
27
- the documentation is always up-to-date with the actual codebase.
28
-
29
- Link to documentation:
30
- [Fawkes Indexing Rules Documentation](https://studyportals.atlassian.net/wiki/spaces/T/pages/3494969354/Fawkes+Indexing+Rules+Documentation)
31
-
32
- ## Features
33
-
34
- - **Dynamic Documentation**: Automatically extracts indexing rules and policies
35
- directly from the codebase
36
- - **Multi-Page Structure**: Creates a main index page with separate pages for
37
- each project
38
- - **Hierarchical Organization**: Structures content as Projects → Policies →
39
- Rules
40
- - **Automatic Page Creation**: Intelligently creates or updates pages as needed
41
- - **Cross-Page Navigation**: Provides intuitive navigation between all pages
42
-
43
- ## Architecture
44
-
45
- The system follows SOLID design principles to ensure maintainability and
46
- extensibility:
47
-
48
- - **Single Responsibility**: Each class has one specific responsibility
49
- - **Open/Closed**: Easily extendable without modifying existing code
50
- - **Liskov Substitution**: Interchangeable components through well-defined
51
- interfaces
52
- - **Interface Segregation**: Clean, focused interfaces
53
- - **Dependency Inversion**: High-level modules depend on abstractions
54
-
55
- ### Key Components
56
-
57
- 1. **Content Builder**: Extracts project, policy, and rule data from the Fawkes
58
- system
59
- 2. **Policy Fetchers**: Project-specific components that fetch and format policy
60
- data
61
- 3. **Document Builder**: Generates structured HTML content for Confluence pages
62
- 4. **Confluence Updater**: Handles creation and updating of Confluence pages
63
- 5. **Token Retriever**: Securely retrieves API token for Confluence access
64
-
65
- ## How It Works
66
-
67
- 1. The system starts by collecting all project data using the `ContentBuilder`
68
- 2. For each project, it extracts policies and rules using project-specific
69
- fetchers
70
- 3. The `DocumentBuilder` generates the content for the main index page and each
71
- project page
72
- 4. The `ConfluenceUpdater` creates or updates pages in Confluence as needed
73
- 5. Each project page links back to the main index, and the main index links to
74
- all project pages
75
-
76
- ## Setup and Configuration
77
-
78
- ### Environment Variables
79
-
80
- The system requires the following environment variables:
81
-
82
- ```
83
- CONFLUENCE_EMAIL=your-email@example.com
84
- CONFLUENCE_API_TOKEN=your-api-token
85
- CONFLUENCE_BASE_URL=https://your-instance.atlassian.net
86
- CONFLUENCE_SPACE_KEY=YOUR_SPACE_KEY
87
- CONFLUENCE_MAIN_PAGE_TITLE=Fawkes Indexing Rules Documentation
88
- ```
89
-
90
- > **Important Note on Credentials**: Currently, the system uses personal
91
- > credentials (email and API token) for Confluence access. This is a temporary
92
- > solution and should be replaced with a team or service account in the future
93
- > to avoid dependency on a specific individual's account.
94
-
95
- ### Deployment and Triggering
96
-
97
- The system runs as an AWS Lambda function and is automatically triggered as part
98
- of the CI/CD pipeline. This ensures documentation is always updated whenever new
99
- code is deployed:
100
-
101
- ```yaml
102
- # buildspec.yml (excerpt)
103
- post_build:
104
- commands:
105
- - |
106
- if [ -z "$PR_ID" ]; then
107
- LAMBDA_NAME="FawkesConfluenceUpdater-$STAGE"
108
- echo "Invoking Lambda function $LAMBDA_NAME"
109
- echo '{"source":"cicd-pipeline","timestamp":"'$(date -u +"%Y-%m-%dT%H:%M:%SZ")'"}' > payload.json
110
- aws lambda invoke --function-name $LAMBDA_NAME --invocation-type Event --payload fileb://payload.json response.json || echo "Lambda invocation failed, but continuing"
111
- fi
112
- ```
113
-
114
- **Trigger Flow:**
115
-
116
- 1. When code is pushed to the `main` branch, the CI/CD pipeline is triggered
117
- 2. After successful deployment of a new Fawkes version, the post-build phase
118
- executes
119
- 3. The Lambda function is invoked with a simple payload containing the source
120
- and timestamp
121
- 4. The Lambda function authenticates with Confluence and executes the
122
- documentation generation process
123
- 5. This only happens for production deployments (not PR builds)
124
-
125
- This automated approach ensures documentation stays in sync with the actual
126
- codebase without manual intervention.
127
-
128
- ## Scalability and Extension
129
-
130
- ### Adding New Projects
131
-
132
- To add documentation for a new project:
133
-
134
- 1. Create a new class that implements the `IPolicyFetcher` interface
135
- 2. Implement the `getProjectName()` and `fetchPolicies()` methods
136
- 3. Register the new fetcher in the `ContentBuilder` constructor
137
-
138
- Example:
139
-
140
- ```typescript
141
- export class NewProjectPolicyFetcher implements IPolicyFetcher {
142
- getProjectName(): string {
143
- return 'New Project Name';
144
- }
145
-
146
- fetchPolicies(): IPolicy[] {
147
- // Implement policy fetching logic
148
- return [...policies];
149
- }
150
- }
151
-
152
- // Then update ContentBuilder:
153
- constructor(fetchers?: IPolicyFetcher[]) {
154
- this.policyFetchers = fetchers || [
155
- // Existing fetchers
156
- new NewProjectPolicyFetcher()
157
- ];
158
- }
159
- ```
160
-
161
- ### Customizing Page Content
162
-
163
- The `DocumentBuilder` class contains methods for generating page content. To
164
- customize the format:
165
-
166
- 1. Modify the `buildMainDocument()` method for changes to the main index page
167
- 2. Modify the `buildProjectDocument()` method for changes to project pages
168
- 3. Modify the `buildPolicySection()` and `buildRulesTable()` methods for changes
169
- to policy and rule sections
170
-
171
- ## Conclusion
172
-
173
- This documentation system ensures that Fawkes indexing rules are always
174
- well-documented and accessible to the team. By automatically generating
175
- documentation directly from the codebase, it eliminates the risk of
176
- documentation becoming outdated or inconsistent with the actual implementation.
1
+ # fawkes
2
+
3
+ This project is used to centralize indexability logic for our Search
4
+ microservices and Sitemap Generator. The main purpose is to completely remove
5
+ discrepancies between pages indexed by Search and page URLs stored in Sitemap.
6
+
7
+ Link to documentation: https://studyportals.atlassian.net/wiki/x/BwAdvw
8
+
9
+ ## Base structure
10
+
11
+ - organisations-seo (used by Organisation Search)
12
+ - scholarships-seo (used by Scholarship Search)
13
+ - sitemap-generator-seo (used by Sitemap Generator)
14
+ - src
15
+ - common
16
+ - organisations
17
+ - scholarships
18
+ - sitemap-generator
19
+
20
+ # Automatic Documentation System
21
+
22
+ ## Overview
23
+
24
+ This system automatically generates and maintains documentation for Fawkes
25
+ indexing rules across multiple projects. It creates a hierarchical structure of
26
+ Confluence pages that document all indexing policies and rules, ensuring that
27
+ the documentation is always up-to-date with the actual codebase.
28
+
29
+ Link to documentation:
30
+ [Fawkes Indexing Rules Documentation](https://studyportals.atlassian.net/wiki/spaces/T/pages/3494969354/Fawkes+Indexing+Rules+Documentation)
31
+
32
+ ## Features
33
+
34
+ - **Dynamic Documentation**: Automatically extracts indexing rules and policies
35
+ directly from the codebase
36
+ - **Multi-Page Structure**: Creates a main index page with separate pages for
37
+ each project
38
+ - **Hierarchical Organization**: Structures content as Projects → Policies →
39
+ Rules
40
+ - **Automatic Page Creation**: Intelligently creates or updates pages as needed
41
+ - **Cross-Page Navigation**: Provides intuitive navigation between all pages
42
+
43
+ ## Architecture
44
+
45
+ The system follows SOLID design principles to ensure maintainability and
46
+ extensibility:
47
+
48
+ - **Single Responsibility**: Each class has one specific responsibility
49
+ - **Open/Closed**: Easily extendable without modifying existing code
50
+ - **Liskov Substitution**: Interchangeable components through well-defined
51
+ interfaces
52
+ - **Interface Segregation**: Clean, focused interfaces
53
+ - **Dependency Inversion**: High-level modules depend on abstractions
54
+
55
+ ### Key Components
56
+
57
+ 1. **Content Builder**: Extracts project, policy, and rule data from the Fawkes
58
+ system
59
+ 2. **Policy Fetchers**: Project-specific components that fetch and format policy
60
+ data
61
+ 3. **Document Builder**: Generates structured HTML content for Confluence pages
62
+ 4. **Confluence Updater**: Handles creation and updating of Confluence pages
63
+ 5. **Token Retriever**: Securely retrieves API token for Confluence access
64
+
65
+ ## How It Works
66
+
67
+ 1. The system starts by collecting all project data using the `ContentBuilder`
68
+ 2. For each project, it extracts policies and rules using project-specific
69
+ fetchers
70
+ 3. The `DocumentBuilder` generates the content for the main index page and each
71
+ project page
72
+ 4. The `ConfluenceUpdater` creates or updates pages in Confluence as needed
73
+ 5. Each project page links back to the main index, and the main index links to
74
+ all project pages
75
+
76
+ ## Setup and Configuration
77
+
78
+ ### Environment Variables
79
+
80
+ The system requires the following environment variables:
81
+
82
+ ```
83
+ CONFLUENCE_EMAIL=your-email@example.com
84
+ CONFLUENCE_API_TOKEN=your-api-token
85
+ CONFLUENCE_BASE_URL=https://your-instance.atlassian.net
86
+ CONFLUENCE_SPACE_KEY=YOUR_SPACE_KEY
87
+ CONFLUENCE_MAIN_PAGE_TITLE=Fawkes Indexing Rules Documentation
88
+ ```
89
+
90
+ > **Important Note on Credentials**: Currently, the system uses personal
91
+ > credentials (email and API token) for Confluence access. This is a temporary
92
+ > solution and should be replaced with a team or service account in the future
93
+ > to avoid dependency on a specific individual's account.
94
+
95
+ ### Deployment and Triggering
96
+
97
+ The system runs as an AWS Lambda function and is automatically triggered as part
98
+ of the CI/CD pipeline. This ensures documentation is always updated whenever new
99
+ code is deployed:
100
+
101
+ ```yaml
102
+ # buildspec.yml (excerpt)
103
+ post_build:
104
+ commands:
105
+ - |
106
+ if [ -z "$PR_ID" ]; then
107
+ LAMBDA_NAME="FawkesConfluenceUpdater-$STAGE"
108
+ echo "Invoking Lambda function $LAMBDA_NAME"
109
+ echo '{"source":"cicd-pipeline","timestamp":"'$(date -u +"%Y-%m-%dT%H:%M:%SZ")'"}' > payload.json
110
+ aws lambda invoke --function-name $LAMBDA_NAME --invocation-type Event --payload fileb://payload.json response.json || echo "Lambda invocation failed, but continuing"
111
+ fi
112
+ ```
113
+
114
+ **Trigger Flow:**
115
+
116
+ 1. When code is pushed to the `main` branch, the CI/CD pipeline is triggered
117
+ 2. After successful deployment of a new Fawkes version, the post-build phase
118
+ executes
119
+ 3. The Lambda function is invoked with a simple payload containing the source
120
+ and timestamp
121
+ 4. The Lambda function authenticates with Confluence and executes the
122
+ documentation generation process
123
+ 5. This only happens for production deployments (not PR builds)
124
+
125
+ This automated approach ensures documentation stays in sync with the actual
126
+ codebase without manual intervention.
127
+
128
+ ## Scalability and Extension
129
+
130
+ ### Adding New Projects
131
+
132
+ To add documentation for a new project:
133
+
134
+ 1. Create a new class that implements the `IPolicyFetcher` interface
135
+ 2. Implement the `getProjectName()` and `fetchPolicies()` methods
136
+ 3. Register the new fetcher in the `ContentBuilder` constructor
137
+
138
+ Example:
139
+
140
+ ```typescript
141
+ export class NewProjectPolicyFetcher implements IPolicyFetcher {
142
+ getProjectName(): string {
143
+ return 'New Project Name';
144
+ }
145
+
146
+ fetchPolicies(): IPolicy[] {
147
+ // Implement policy fetching logic
148
+ return [...policies];
149
+ }
150
+ }
151
+
152
+ // Then update ContentBuilder:
153
+ constructor(fetchers?: IPolicyFetcher[]) {
154
+ this.policyFetchers = fetchers || [
155
+ // Existing fetchers
156
+ new NewProjectPolicyFetcher()
157
+ ];
158
+ }
159
+ ```
160
+
161
+ ### Customizing Page Content
162
+
163
+ The `DocumentBuilder` class contains methods for generating page content. To
164
+ customize the format:
165
+
166
+ 1. Modify the `buildMainDocument()` method for changes to the main index page
167
+ 2. Modify the `buildProjectDocument()` method for changes to project pages
168
+ 3. Modify the `buildPolicySection()` and `buildRulesTable()` methods for changes
169
+ to policy and rule sections
170
+
171
+ ## Conclusion
172
+
173
+ This documentation system ensures that Fawkes indexing rules are always
174
+ well-documented and accessible to the team. By automatically generating
175
+ documentation directly from the codebase, it eliminates the risk of
176
+ documentation becoming outdated or inconsistent with the actual implementation.
@@ -73,8 +73,6 @@ export declare enum FilterCombinations {
73
73
  RANKED_CONTINENT = "rankedContinent",
74
74
  RANKED_CONTINENT_ATTENDANCE = "rankedContinentAttendance",
75
75
  RANKED_COUNTRY = "rankedCountry",
76
- RANKED_COUNTRY_CITY = "rankedCountryCity",
77
- RANKED_COUNTRY_AREA_CITY = "rankedCountryAreaCity",
78
76
  RANKED_COUNTRY_ATTENDANCE = "rankedCountryAttendance",
79
77
  RANKED_DISCIPLINE_COUNTRY = "rankedDisciplineCountry",
80
78
  RANKED_DISCIPLINE = "rankedDiscipline",
@@ -74,8 +74,6 @@ export var FilterCombinations;
74
74
  FilterCombinations["RANKED_CONTINENT"] = "rankedContinent";
75
75
  FilterCombinations["RANKED_CONTINENT_ATTENDANCE"] = "rankedContinentAttendance";
76
76
  FilterCombinations["RANKED_COUNTRY"] = "rankedCountry";
77
- FilterCombinations["RANKED_COUNTRY_CITY"] = "rankedCountryCity";
78
- FilterCombinations["RANKED_COUNTRY_AREA_CITY"] = "rankedCountryAreaCity";
79
77
  FilterCombinations["RANKED_COUNTRY_ATTENDANCE"] = "rankedCountryAttendance";
80
78
  FilterCombinations["RANKED_DISCIPLINE_COUNTRY"] = "rankedDisciplineCountry";
81
79
  FilterCombinations["RANKED_DISCIPLINE"] = "rankedDiscipline";
@@ -1,5 +1,5 @@
1
1
  import { DependencyTypes } from '../enums/DependencyTypes';
2
- import { Area, AreaAttendance, Attendance, Continent, Country, CountryAttendance, Unfiltered, RankedArea, RankedAreaDiscipline, RankedAttendance, RankedAttendanceDiscipline, RankedContinent, RankedContinentAttendance, RankedCountry, RankedCountryAttendance, RankedCountryDiscipline, RankedDiscipline, RankedUnfiltered, CountryCity, CountryAreaCity, RankedCountryCity, RankedCountryAreaCity } from '../organisations/policies';
2
+ import { Area, AreaAttendance, Attendance, Continent, Country, CountryAttendance, Unfiltered, RankedArea, RankedAreaDiscipline, RankedAttendance, RankedAttendanceDiscipline, RankedContinent, RankedContinentAttendance, RankedCountry, RankedCountryAttendance, RankedCountryDiscipline, RankedDiscipline, RankedUnfiltered, CountryCity, CountryAreaCity } from '../organisations/policies';
3
3
  export class SearchIndexabilityManager {
4
4
  policies;
5
5
  constructor(portalType, seoInfoBase, filterState, sortingState, applicationState) {
@@ -31,8 +31,6 @@ export class SearchIndexabilityManager {
31
31
  new RankedCountryAttendance(dependencies),
32
32
  new RankedCountryDiscipline(dependencies),
33
33
  new RankedDiscipline(dependencies),
34
- new RankedCountryCity(dependencies),
35
- new RankedCountryAreaCity(dependencies),
36
34
  new RankedUnfiltered(dependencies)
37
35
  ];
38
36
  }
@@ -18,5 +18,3 @@ export * from './ranked/RankedCountryAttendance';
18
18
  export * from './ranked/RankedCountryDiscipline';
19
19
  export * from './ranked/RankedDiscipline';
20
20
  export * from './ranked/RankedUnfiltered';
21
- export * from './ranked/RankedCountryCity';
22
- export * from './ranked/RankedCountryAreaCity';
@@ -18,5 +18,3 @@ export * from './ranked/RankedCountryAttendance';
18
18
  export * from './ranked/RankedCountryDiscipline';
19
19
  export * from './ranked/RankedDiscipline';
20
20
  export * from './ranked/RankedUnfiltered';
21
- export * from './ranked/RankedCountryCity';
22
- export * from './ranked/RankedCountryAreaCity';
@@ -2,6 +2,7 @@ import { MinimumAmountOfResultsRule } from './rules/MinimumAmountOfResultsRule';
2
2
  import { IndexablePageNumberRule } from './rules/IndexablePageNumberRule';
3
3
  import { NotDistanceLearningPortalRule } from './rules/NotDistanceLearningPortalRule';
4
4
  import { BaseSeoIndexabilityPolicy } from '../common/policies/BaseSeoIndexabilityPolicy';
5
+ import { FilterKey } from '@studyportals/search-filters/server-side';
5
6
  export class ProgrammesBaseIndexabilityPolicy extends BaseSeoIndexabilityPolicy {
6
7
  indexablePageNumbers = [1];
7
8
  initateBaseRules() {
@@ -20,6 +21,10 @@ export class ProgrammesBaseIndexabilityPolicy extends BaseSeoIndexabilityPolicy
20
21
  this.rules.push(atLeastSevenResultsRule, notDistanceLearningPortalRule, indexablePageNumberRule);
21
22
  }
22
23
  async checkRulesForSitemapWithPageNumber(filterKeyValues, pageNumber) {
24
+ const dependencies = this.dependencies;
25
+ if (!Object.keys(filterKeyValues).some(key => key === FilterKey.EDUCATION_LEVEL)) {
26
+ filterKeyValues[FilterKey.EDUCATION_LEVEL] = [dependencies.portalType];
27
+ }
23
28
  for (const rule of this.rules) {
24
29
  let result;
25
30
  if ('forSitemapGeneratorWithPageNumber' in rule) {
@@ -10,7 +10,7 @@ import { AttendancePresenter } from '../../presenters/AttendancePresenter';
10
10
  import { DegreePresenter } from '../../presenters/DegreePresenter';
11
11
  export class CountryAttendanceDegree extends ProgrammesBaseIndexabilityPolicy {
12
12
  name = 'Country Attendance Degree Policy';
13
- description = `Determines indexing rules for pages filtered by country,
13
+ description = `Determines indexing rules for pages filtered by country,
14
14
  study format (online, on-campus, etc.), and degree type.`;
15
15
  filterKeys = [FilterKey.COUNTRY, FilterKey.DELIVERY_METHOD, FilterKey.DEGREE_TYPE];
16
16
  rules = [
@@ -10,7 +10,7 @@ import { DegreePresenter } from '../../presenters/DegreePresenter';
10
10
  import { DurationPresenter } from '../../presenters/DurationPresenter';
11
11
  export class CountryDurationDegree extends ProgrammesBaseIndexabilityPolicy {
12
12
  name = 'Country Duration Degree Policy';
13
- description = `Determines indexing rules for pages filtered by country,
13
+ description = `Determines indexing rules for pages filtered by country,
14
14
  duration (1 year, 2 years, etc.), and degree type.`;
15
15
  filterKeys = [FilterKey.COUNTRY, FilterKey.DURATION, FilterKey.DEGREE_TYPE];
16
16
  rules = [
@@ -8,7 +8,7 @@ import { CountryPresenter } from '../../presenters/CountryPresenter';
8
8
  import { EducationalFormPresenter } from '../../presenters/EducationalFormPresenter';
9
9
  export class CountryEducationalForm extends ProgrammesBaseIndexabilityPolicy {
10
10
  name = 'Country Educational Form Policy';
11
- description = `Determines indexing rules for pages filtered by both country,
11
+ description = `Determines indexing rules for pages filtered by both country,
12
12
  and educational form (academic, semester, summer school, etc.).`;
13
13
  filterKeys = [FilterKey.COUNTRY, FilterKey.EDUCATIONAL_FORM];
14
14
  rules = [
@@ -9,7 +9,7 @@ import { CountryPresenter } from '../../presenters/CountryPresenter';
9
9
  import { EducationalFormPresenter } from '../../presenters/EducationalFormPresenter';
10
10
  export class DisciplineCountryEducationalForm extends ProgrammesBaseIndexabilityPolicy {
11
11
  name = 'Discipline Country Educational Form Policy';
12
- description = `Determines indexing rules for pages filtered by discipline,
12
+ description = `Determines indexing rules for pages filtered by discipline,
13
13
  country, and educational form (academic, semester, summer school, etc.).`;
14
14
  filterKeys = [FilterKey.DISCIPLINES, FilterKey.COUNTRY, FilterKey.EDUCATIONAL_FORM];
15
15
  rules = [
@@ -8,7 +8,7 @@ import { DisciplinePresenter } from '../../presenters/DisciplinePresenter';
8
8
  import { EducationalFormPresenter } from '../../presenters/EducationalFormPresenter';
9
9
  export class DisciplineEducationalForm extends ProgrammesBaseIndexabilityPolicy {
10
10
  name = 'Discipline Educational Form Policy';
11
- description = `Determines indexing rules for pages filtered by both discipline,
11
+ description = `Determines indexing rules for pages filtered by both discipline,
12
12
  and educational form (academic, semester, summer school, etc.).`;
13
13
  filterKeys = [FilterKey.DISCIPLINES, FilterKey.EDUCATIONAL_FORM];
14
14
  rules = [
@@ -6,5 +6,5 @@ export declare class IndexableDegreeRule extends BaseProgrammeRule {
6
6
  forSitemapGenerator(filterKeyValues: FilterKeyValuesMap): Promise<boolean>;
7
7
  getName(): string;
8
8
  getDescription(): string;
9
- private get indexableDegreeTypes();
9
+ private getIndexableDegreeTypes;
10
10
  }
@@ -1,53 +1,71 @@
1
1
  import { FilterKey } from '@studyportals/search-filters/server-side';
2
2
  import { DegreeTypeFilterOptionValue } from '@studyportals/search-filters/server-side';
3
3
  import { BaseProgrammeRule } from '../BaseProgrammeRule';
4
+ import { PortalType } from '@studyportals/domain-client';
4
5
  export class IndexableDegreeRule extends BaseProgrammeRule {
5
6
  forSearch(dependencies) {
6
7
  const { seoInfoBase, filterState } = dependencies;
8
+ const programmeSearchDependencies = dependencies;
9
+ const portalType = programmeSearchDependencies.portalType;
7
10
  const selectedDegree = seoInfoBase.getFilterOptionValueBy(FilterKey.DEGREE_TYPE, filterState);
8
11
  if (!selectedDegree) {
9
12
  return Promise.resolve(false);
10
13
  }
11
- const isIndexable = this.indexableDegreeTypes.includes(selectedDegree);
14
+ const isIndexable = this.getIndexableDegreeTypes(portalType).includes(selectedDegree);
12
15
  return Promise.resolve(isIndexable);
13
16
  }
14
17
  forSitemapGenerator(filterKeyValues) {
18
+ const portalType = filterKeyValues.get(FilterKey.EDUCATION_LEVEL)?.[0];
15
19
  const [selectedDegree] = filterKeyValues.get(FilterKey.DEGREE_TYPE);
16
- if (!selectedDegree) {
20
+ if (!selectedDegree || !portalType) {
17
21
  return Promise.resolve(false);
18
22
  }
19
- const isIndexable = this.indexableDegreeTypes.includes(selectedDegree);
23
+ const isIndexable = this.getIndexableDegreeTypes(portalType).includes(selectedDegree);
20
24
  return Promise.resolve(isIndexable);
21
25
  }
22
26
  getName() {
23
27
  return 'IndexableDegreeRule';
24
28
  }
25
29
  getDescription() {
26
- return `Indexable if the selected degree type is one of the following: ${this.indexableDegreeTypes.join(', ')}`;
30
+ return `Indexable if the selected degree type is one of the indexable degrees for the portal type`;
27
31
  }
28
- get indexableDegreeTypes() {
29
- return [
30
- DegreeTypeFilterOptionValue.DOCTORATE,
31
- DegreeTypeFilterOptionValue.DBA,
32
- DegreeTypeFilterOptionValue.PHD,
33
- DegreeTypeFilterOptionValue.MSC,
34
- DegreeTypeFilterOptionValue.MA,
35
- DegreeTypeFilterOptionValue.MBA,
36
- DegreeTypeFilterOptionValue.LLM,
37
- DegreeTypeFilterOptionValue.MPHIL,
38
- DegreeTypeFilterOptionValue.MED,
39
- DegreeTypeFilterOptionValue.MENG,
40
- DegreeTypeFilterOptionValue.POSTGRADIP,
41
- DegreeTypeFilterOptionValue.POSTGRADCERT,
42
- DegreeTypeFilterOptionValue.PREMASTER,
43
- DegreeTypeFilterOptionValue.BSC,
44
- DegreeTypeFilterOptionValue.BA,
45
- DegreeTypeFilterOptionValue.BBA,
46
- DegreeTypeFilterOptionValue.ASSOCIATE_DEGREE,
47
- DegreeTypeFilterOptionValue.GRADUATE_CERTTIFICATE,
48
- DegreeTypeFilterOptionValue.GRADUATE_DIPLOMA,
49
- DegreeTypeFilterOptionValue.PREBACHELOR,
50
- DegreeTypeFilterOptionValue.CERTIFICATE
51
- ];
32
+ getIndexableDegreeTypes(portalType) {
33
+ switch (portalType) {
34
+ case PortalType.MASTER:
35
+ return [
36
+ DegreeTypeFilterOptionValue.MSC,
37
+ DegreeTypeFilterOptionValue.MA,
38
+ DegreeTypeFilterOptionValue.MBA,
39
+ DegreeTypeFilterOptionValue.LLM,
40
+ DegreeTypeFilterOptionValue.MPHIL,
41
+ DegreeTypeFilterOptionValue.MED,
42
+ DegreeTypeFilterOptionValue.MENG,
43
+ DegreeTypeFilterOptionValue.POSTGRADIP,
44
+ DegreeTypeFilterOptionValue.POSTGRADCERT,
45
+ DegreeTypeFilterOptionValue.PREMASTER
46
+ ];
47
+ case PortalType.BACHELOR:
48
+ return [
49
+ DegreeTypeFilterOptionValue.BSC,
50
+ DegreeTypeFilterOptionValue.BA,
51
+ DegreeTypeFilterOptionValue.BBA,
52
+ DegreeTypeFilterOptionValue.ASSOCIATE_DEGREE,
53
+ DegreeTypeFilterOptionValue.GRADUATE_CERTTIFICATE,
54
+ DegreeTypeFilterOptionValue.GRADUATE_DIPLOMA,
55
+ DegreeTypeFilterOptionValue.PREBACHELOR
56
+ ];
57
+ case PortalType.PHD:
58
+ return [
59
+ DegreeTypeFilterOptionValue.PHD,
60
+ DegreeTypeFilterOptionValue.DBA,
61
+ DegreeTypeFilterOptionValue.DOCTORATE
62
+ ];
63
+ case PortalType.SHORT:
64
+ return [
65
+ DegreeTypeFilterOptionValue.CERTIFICATE
66
+ ];
67
+ default:
68
+ return [];
69
+ }
52
70
  }
53
71
  }
@@ -1,6 +1,6 @@
1
1
  import { DependencyTypes } from '../enums/DependencyTypes';
2
2
  import { BaseSitemapUrlGeneratorManager } from './BaseSitemapUrlGeneratorManager';
3
- import { Area, AreaAttendance, Attendance, Continent, Country, CountryCity, CountryAttendance, RankedArea, RankedAreaDiscipline, RankedAttendance, RankedAttendanceDiscipline, RankedContinent, RankedContinentAttendance, RankedCountry, RankedCountryAttendance, RankedCountryDiscipline, RankedDiscipline, RankedUnfiltered, Unfiltered, RankedCountryCity, RankedCountryAreaCity } from '../organisations/policies';
3
+ import { Area, AreaAttendance, Attendance, Continent, Country, CountryCity, CountryAttendance, RankedArea, RankedAreaDiscipline, RankedAttendance, RankedAttendanceDiscipline, RankedContinent, RankedContinentAttendance, RankedCountry, RankedCountryAttendance, RankedCountryDiscipline, RankedDiscipline, RankedUnfiltered, Unfiltered } from '../organisations/policies';
4
4
  import { AreaPresenter } from '../presenters/AreaPresenter';
5
5
  import { AttendancePresenter } from '../presenters/AttendancePresenter';
6
6
  import { ContinentPresenter } from '../presenters/ContinentPresenter';
@@ -39,8 +39,6 @@ export class OrganisationsSitemapUrlGeneratorManager extends BaseSitemapUrlGener
39
39
  new RankedContinent(dependencies),
40
40
  new RankedContinentAttendance(dependencies),
41
41
  new RankedCountry(dependencies),
42
- new RankedCountryCity(dependencies),
43
- new RankedCountryAreaCity(dependencies),
44
42
  new RankedCountryAttendance(dependencies),
45
43
  new RankedCountryDiscipline(dependencies),
46
44
  new RankedDiscipline(dependencies),
package/package.json CHANGED
@@ -1,105 +1,105 @@
1
- {
2
- "name": "@studyportals/fawkes",
3
- "version": "8.5.3-1",
4
- "description": "A package to centralize SEO related logic for SBLP and Sitemap Generator.",
5
- "files": [
6
- "./dist"
7
- ],
8
- "scripts": {
9
- "prepush": "npm run test",
10
- "precommit": "npm run lint",
11
- "compile": "npx tsc && tsc-alias && rm -r ./dist/tests",
12
- "build": "npm run clean && npm run compile",
13
- "clean": "rimraf \"!(node_modules)/**/dist\"",
14
- "prepare-deployment": "npm run test && npm run build",
15
- "publish-major": "npm run prepare-deployment && npm version major && npm publish",
16
- "publish-beta": "npm run prepare-deployment && npm version prerelease && npm publish --tag beta --access=public",
17
- "publish-patch": "npm run prepare-deployment && npm version patch && npm publish",
18
- "publish-minor": "npm run prepare-deployment && npm version minor && npm publish",
19
- "prepare": "husky install",
20
- "test": "vitest run --coverage",
21
- "test:dev": "vitest --coverage tests/programmes",
22
- "lint": "eslint . --ext .ts",
23
- "lint:fix": "eslint . --ext .ts --fix",
24
- "prettier:fix": "npx prettier --use-tabs --ignore-path .gitignore --write ."
25
- },
26
- "exports": {
27
- "./organisations-search-seo": {
28
- "import": "./dist/organisations-seo/index.js",
29
- "require": "./dist/organisations-seo/index.js",
30
- "types": "./dist/organisations-seo/index.d.ts"
31
- },
32
- "./programmes-search-seo": {
33
- "import": "./dist/programmes-seo/index.js",
34
- "require": "./dist/programmes-seo/index.js",
35
- "types": "./dist/programmes-seo/index.d.ts"
36
- },
37
- "./scholarships-search-seo": {
38
- "import": "./dist/scholarships-seo/index.js",
39
- "require": "./dist/scholarships-seo/index.js",
40
- "types": "./dist/scholarships-seo/index.d.ts"
41
- },
42
- "./sitemap-generator-seo": {
43
- "import": "./dist/sitemap-generator-seo/index.js",
44
- "require": "./dist/sitemap-generator-seo/index.js",
45
- "types": "./dist/sitemap-generator-seo/index.d.ts"
46
- },
47
- "./structured-data-seo": {
48
- "import": "./dist/structured-data-seo/index.js",
49
- "require": "./dist/structured-data-seo/index.js",
50
- "types": "./dist/structured-data-seo/index.d.ts"
51
- }
52
- },
53
- "typesVersions": {
54
- "*": {
55
- "organisations-search-seo": [
56
- "dist/organisations-seo/index.d.ts"
57
- ],
58
- "programmes-search-seo": [
59
- "dist/programmes-seo/index.d.ts"
60
- ],
61
- "scholarships-search-seo": [
62
- "dist/scholarships-seo/index.d.ts"
63
- ],
64
- "sitemap-generator-seo": [
65
- "dist/sitemap-generator-seo/index.d.ts"
66
- ],
67
- "structured-data-seo": [
68
- "dist/structured-data-seo/index.d.ts"
69
- ],
70
- "*": [
71
- "dist/index.d.ts"
72
- ]
73
- }
74
- },
75
- "author": "The Jedi Council",
76
- "license": "ISC",
77
- "devDependencies": {
78
- "@adobe/structured-data-validator": "^1.4.1",
79
- "@studyportals/code-style": "^2.2.1",
80
- "@studyportals/webpack-helper": "^6.0.6",
81
- "@vitest/coverage-istanbul": "^2.1.8",
82
- "husky": "^8.0.3",
83
- "jsdom": "^26.0.0",
84
- "prettier": "^3.5.3",
85
- "schema-dts": "^1.1.5",
86
- "ts-loader": "^9.5.2",
87
- "tsc-alias": "^1.8.11",
88
- "typemoq": "^2.1.0",
89
- "typescript": "^5.7.3",
90
- "vitest": "^2.1.8"
91
- },
92
- "dependencies": {
93
- "@studyportals/domain-client": "7.1.0",
94
- "@studyportals/ranking-api-interface": "^1.3.12",
95
- "@studyportals/search-filters": "^6.3.1",
96
- "@studyportals/static-domain-data": "^6.1.0"
97
- },
98
- "optionalDependencies": {
99
- "@rollup/rollup-linux-x64-gnu": "4.24.0"
100
- },
101
- "engines": {
102
- "node": ">=18 <=24",
103
- "npm": ">=8 <=11"
104
- }
105
- }
1
+ {
2
+ "name": "@studyportals/fawkes",
3
+ "version": "8.5.3-2",
4
+ "description": "A package to centralize SEO related logic for SBLP and Sitemap Generator.",
5
+ "files": [
6
+ "./dist"
7
+ ],
8
+ "scripts": {
9
+ "prepush": "npm run test",
10
+ "precommit": "npm run lint",
11
+ "compile": "npx tsc && tsc-alias && rm -r ./dist/tests",
12
+ "build": "npm run clean && npm run compile",
13
+ "clean": "rimraf \"!(node_modules)/**/dist\"",
14
+ "prepare-deployment": "npm run test && npm run build",
15
+ "publish-major": "npm run prepare-deployment && npm version major && npm publish",
16
+ "publish-beta": "npm run prepare-deployment && npm version prerelease && npm publish --tag beta --access=public",
17
+ "publish-patch": "npm run prepare-deployment && npm version patch && npm publish",
18
+ "publish-minor": "npm run prepare-deployment && npm version minor && npm publish",
19
+ "prepare": "husky install",
20
+ "test": "vitest run --coverage",
21
+ "test:dev": "vitest --coverage tests/programmes",
22
+ "lint": "eslint . --ext .ts",
23
+ "lint:fix": "eslint . --ext .ts --fix",
24
+ "prettier:fix": "npx prettier --use-tabs --ignore-path .gitignore --write ."
25
+ },
26
+ "exports": {
27
+ "./organisations-search-seo": {
28
+ "import": "./dist/organisations-seo/index.js",
29
+ "require": "./dist/organisations-seo/index.js",
30
+ "types": "./dist/organisations-seo/index.d.ts"
31
+ },
32
+ "./programmes-search-seo": {
33
+ "import": "./dist/programmes-seo/index.js",
34
+ "require": "./dist/programmes-seo/index.js",
35
+ "types": "./dist/programmes-seo/index.d.ts"
36
+ },
37
+ "./scholarships-search-seo": {
38
+ "import": "./dist/scholarships-seo/index.js",
39
+ "require": "./dist/scholarships-seo/index.js",
40
+ "types": "./dist/scholarships-seo/index.d.ts"
41
+ },
42
+ "./sitemap-generator-seo": {
43
+ "import": "./dist/sitemap-generator-seo/index.js",
44
+ "require": "./dist/sitemap-generator-seo/index.js",
45
+ "types": "./dist/sitemap-generator-seo/index.d.ts"
46
+ },
47
+ "./structured-data-seo": {
48
+ "import": "./dist/structured-data-seo/index.js",
49
+ "require": "./dist/structured-data-seo/index.js",
50
+ "types": "./dist/structured-data-seo/index.d.ts"
51
+ }
52
+ },
53
+ "typesVersions": {
54
+ "*": {
55
+ "organisations-search-seo": [
56
+ "dist/organisations-seo/index.d.ts"
57
+ ],
58
+ "programmes-search-seo": [
59
+ "dist/programmes-seo/index.d.ts"
60
+ ],
61
+ "scholarships-search-seo": [
62
+ "dist/scholarships-seo/index.d.ts"
63
+ ],
64
+ "sitemap-generator-seo": [
65
+ "dist/sitemap-generator-seo/index.d.ts"
66
+ ],
67
+ "structured-data-seo": [
68
+ "dist/structured-data-seo/index.d.ts"
69
+ ],
70
+ "*": [
71
+ "dist/index.d.ts"
72
+ ]
73
+ }
74
+ },
75
+ "author": "The Jedi Council",
76
+ "license": "ISC",
77
+ "devDependencies": {
78
+ "@adobe/structured-data-validator": "^1.4.1",
79
+ "@studyportals/code-style": "^2.2.1",
80
+ "@studyportals/webpack-helper": "^6.0.6",
81
+ "@vitest/coverage-istanbul": "^2.1.8",
82
+ "husky": "^8.0.3",
83
+ "jsdom": "^26.0.0",
84
+ "prettier": "^3.5.3",
85
+ "schema-dts": "^1.1.5",
86
+ "ts-loader": "^9.5.2",
87
+ "tsc-alias": "^1.8.11",
88
+ "typemoq": "^2.1.0",
89
+ "typescript": "^5.7.3",
90
+ "vitest": "^2.1.8"
91
+ },
92
+ "dependencies": {
93
+ "@studyportals/domain-client": "7.1.0",
94
+ "@studyportals/ranking-api-interface": "^1.3.12",
95
+ "@studyportals/search-filters": "^6.3.1",
96
+ "@studyportals/static-domain-data": "^6.1.0"
97
+ },
98
+ "optionalDependencies": {
99
+ "@rollup/rollup-linux-x64-gnu": "4.24.0"
100
+ },
101
+ "engines": {
102
+ "node": ">=18 <=24",
103
+ "npm": ">=8 <=11"
104
+ }
105
+ }
@@ -1,13 +0,0 @@
1
- import { RankedOrganisationsSeoIndexabilityPolicy } from "../RankedOrganisationsSeoIndexabilityPolicy";
2
- import { IOrganisationsSeoDependencies } from "../../../organisations/types/IOrganisationsSeoDependencies";
3
- import { OnlyFiltersSelectedRule } from "../../../common/rules/OnlyFiltersSelectedRule";
4
- import { SingleValueSelectedForFilterRule } from "../../../common/rules/SingleValueSelectedForFilterRule";
5
- import { FilterCombinations } from "../../../enums/FilterCombinations";
6
- export declare class RankedCountryAreaCity extends RankedOrganisationsSeoIndexabilityPolicy {
7
- readonly name: string;
8
- readonly description: string;
9
- protected readonly baseRules: (SingleValueSelectedForFilterRule | OnlyFiltersSelectedRule)[];
10
- constructor(dependencies: IOrganisationsSeoDependencies);
11
- protected generateUrls(): Promise<string[]>;
12
- get filterCombination(): FilterCombinations;
13
- }
@@ -1,43 +0,0 @@
1
- import { RankedOrganisationsSeoIndexabilityPolicy } from "../RankedOrganisationsSeoIndexabilityPolicy";
2
- import { OnlyFiltersSelectedRule } from "../../../common/rules/OnlyFiltersSelectedRule";
3
- import { FilterKey } from "@studyportals/search-filters/server-side";
4
- import { SingleValueSelectedForFilterRule } from "../../../common/rules/SingleValueSelectedForFilterRule";
5
- import { CityPresenter } from "../../../presenters/CityPresenter";
6
- import { FilterCombinations } from "../../../enums/FilterCombinations";
7
- export class RankedCountryAreaCity extends RankedOrganisationsSeoIndexabilityPolicy {
8
- name = 'Ranked Country/Area/City Policy';
9
- description = 'Regulates indexability of ranking-sorted country, area, and city-level filtered pages, prioritizing high-value geographic views with quality-based sorting.';
10
- baseRules = [
11
- new SingleValueSelectedForFilterRule(FilterKey.CONTINENT),
12
- new OnlyFiltersSelectedRule([FilterKey.CONTINENT])
13
- ];
14
- constructor(dependencies) {
15
- super(dependencies);
16
- }
17
- async generateUrls() {
18
- const cityFragments = await CityPresenter
19
- .getInstance(this.dependencies.searchApiClient)
20
- .getFragments();
21
- const paths = [];
22
- const filteredFragmentsForCountryAreaCity = cityFragments.filter(city => city.areaId !== null && city.areaId !== undefined);
23
- for (const city of filteredFragmentsForCountryAreaCity) {
24
- const areaId = city.areaId?.toString() || '';
25
- if (areaId === '') {
26
- continue;
27
- }
28
- const filterKeyValues = new Map([
29
- [FilterKey.CITY, [city.id]],
30
- [FilterKey.AREA, [areaId]],
31
- [FilterKey.COUNTRY, [city.countryId]]
32
- ]);
33
- const result = await this.checkRulesForSitemap(filterKeyValues);
34
- if (result) {
35
- paths.push(this.getPathWithSortingOption(city.path));
36
- }
37
- }
38
- return paths;
39
- }
40
- get filterCombination() {
41
- return FilterCombinations.RANKED_COUNTRY_AREA_CITY;
42
- }
43
- }
@@ -1,14 +0,0 @@
1
- import { RankedOrganisationsSeoIndexabilityPolicy } from "../RankedOrganisationsSeoIndexabilityPolicy";
2
- import { IOrganisationsSeoDependencies } from "../../../organisations/types/IOrganisationsSeoDependencies";
3
- import { OnlyFiltersSelectedRule } from "../../../common/rules/OnlyFiltersSelectedRule";
4
- import { SingleValueSelectedForFilterRule } from "../../../common/rules/SingleValueSelectedForFilterRule";
5
- import { ExcludeByIdForCitiesRule } from "../../../organisations/rules/ExcludeByIdForCitiesRule";
6
- import { FilterCombinations } from "../../../enums/FilterCombinations";
7
- export declare class RankedCountryCity extends RankedOrganisationsSeoIndexabilityPolicy {
8
- readonly name: string;
9
- readonly description: string;
10
- protected readonly baseRules: (SingleValueSelectedForFilterRule | OnlyFiltersSelectedRule | ExcludeByIdForCitiesRule)[];
11
- constructor(dependencies: IOrganisationsSeoDependencies);
12
- protected generateUrls(): Promise<string[]>;
13
- get filterCombination(): FilterCombinations;
14
- }
@@ -1,41 +0,0 @@
1
- import { RankedOrganisationsSeoIndexabilityPolicy } from "../RankedOrganisationsSeoIndexabilityPolicy";
2
- import { OnlyFiltersSelectedRule } from "../../../common/rules/OnlyFiltersSelectedRule";
3
- import { FilterKey } from "@studyportals/search-filters/server-side";
4
- import { SingleValueSelectedForFilterRule } from "../../../common/rules/SingleValueSelectedForFilterRule";
5
- import { ExcludeByIdForCitiesRule } from "../../../organisations/rules/ExcludeByIdForCitiesRule";
6
- import { CityPresenter } from "../../../presenters/CityPresenter";
7
- import { FilterCombinations } from "../../../enums/FilterCombinations";
8
- export class RankedCountryCity extends RankedOrganisationsSeoIndexabilityPolicy {
9
- name = 'Ranked Country/City Policy';
10
- description = 'Regulates indexability of ranking-sorted country, and city-level filtered pages, prioritizing high-value geographic views with quality-based sorting.';
11
- baseRules = [
12
- new SingleValueSelectedForFilterRule(FilterKey.CITY),
13
- new SingleValueSelectedForFilterRule(FilterKey.COUNTRY),
14
- new OnlyFiltersSelectedRule([FilterKey.CITY, FilterKey.COUNTRY]),
15
- new ExcludeByIdForCitiesRule(FilterKey.CITY)
16
- ];
17
- constructor(dependencies) {
18
- super(dependencies);
19
- }
20
- async generateUrls() {
21
- const cityFragments = await CityPresenter
22
- .getInstance(this.dependencies.searchApiClient)
23
- .getFragments();
24
- const paths = [];
25
- const filteredFragmentsForCountryCity = cityFragments.filter(city => city.areaId === null || city.areaId === undefined);
26
- for (const city of filteredFragmentsForCountryCity) {
27
- const filterKeyValues = new Map([
28
- [FilterKey.CITY, [city.id]],
29
- [FilterKey.COUNTRY, [city.countryId]]
30
- ]);
31
- const result = await this.checkRulesForSitemap(filterKeyValues);
32
- if (result) {
33
- paths.push(this.getPathWithSortingOption(city.path));
34
- }
35
- }
36
- return paths;
37
- }
38
- get filterCombination() {
39
- return FilterCombinations.RANKED_COUNTRY_CITY;
40
- }
41
- }