@studyportals/fawkes 7.3.4 → 7.3.6
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 +176 -176
- package/dist/src/programmes/policies/CountryAttendanceDegree.js +1 -1
- package/dist/src/programmes/policies/CountryDurationDegree.js +1 -1
- package/dist/src/programmes/policies/CountryEducationalForm.js +1 -1
- package/dist/src/programmes/policies/DisciplineCountryEducationalForm.js +1 -1
- package/dist/src/programmes/policies/DisciplineEducationalForm.js +1 -1
- package/dist/src/structured-data/ProgrammeStructuredDataFactory.d.ts +18 -0
- package/dist/src/structured-data/ProgrammeStructuredDataFactory.js +91 -0
- package/dist/src/structured-data/SearchStructuredDataFactory.d.ts +34 -0
- package/dist/src/structured-data/SearchStructuredDataFactory.js +144 -0
- package/dist/src/structured-data/dto/BreadcrumbDTO.d.ts +5 -0
- package/dist/src/structured-data/dto/EntityDTO.d.ts +7 -0
- package/dist/src/structured-data/dto/FAQItemDto.d.ts +4 -0
- package/dist/src/structured-data/dto/OfferDTO.d.ts +5 -0
- package/dist/src/structured-data/dto/ReviewRatingDTO.d.ts +4 -0
- package/dist/src/structured-data/dto/index.d.ts +5 -0
- package/dist/src/structured-data/dto/index.js +5 -0
- package/dist/src/structured-data/index.d.ts +2 -0
- package/dist/src/structured-data/index.js +2 -0
- package/dist/src/structured-data/interface/StructuredDataCurrencyConversionService.d.ts +3 -0
- package/dist/src/structured-data/interface/StructuredDataCurrencyConversionService.js +1 -0
- package/dist/structured-data/index.d.ts +1 -0
- package/dist/structured-data/index.js +1 -0
- package/dist/structured-data-seo/index.d.ts +1 -0
- package/dist/structured-data-seo/index.js +1 -0
- package/dist/structured-markup-seo/index.d.ts +1 -0
- package/dist/structured-markup-seo/index.js +1 -0
- package/package.json +105 -95
- package/dist/src/common/IPolicyMetaData.d.ts +0 -6
- package/dist/src/organisations/OrganisationsRuleBasedIndexabilityPolicy.d.ts +0 -11
- package/dist/src/organisations/OrganisationsRuleBasedIndexabilityPolicy.js +0 -19
- package/dist/src/organisations/rules/OnlineAttendanceRule.d.ts +0 -6
- package/dist/src/organisations/rules/OnlineAttendanceRule.js +0 -14
- package/dist/src/programmes/IProgrammeSearchApplicationState.d.ts +0 -4
- package/dist/src/programmes/IProgrammeSearchDependencies.d.ts +0 -7
- package/dist/src/programmes/IProgrammesSeoDependencies.d.ts +0 -2
- package/dist/src/programmes/policies/DisciplineCountryDegree.d.ts +0 -16
- package/dist/src/programmes/policies/DisciplineCountryDegree.js +0 -53
- package/dist/src/programmes/rules/DegreeAttendanceSpecificRule.d.ts +0 -10
- package/dist/src/programmes/rules/DegreeAttendanceSpecificRule.js +0 -42
- package/dist/src/programmes/rules/DegreeCountrySpecificRule.d.ts +0 -10
- package/dist/src/programmes/rules/DegreeCountrySpecificRule.js +0 -43
- package/dist/src/programmes/rules/DegreeCountryTuitionFeeRule.d.ts +0 -11
- package/dist/src/programmes/rules/DegreeCountryTuitionFeeRule.js +0 -40
- package/dist/src/programmes/rules/MBACountryAttendanceRule.d.ts +0 -11
- package/dist/src/programmes/rules/MBACountryAttendanceRule.js +0 -40
- package/dist/src/programmes/rules/MasterOfArtsDisciplineRule.d.ts +0 -10
- package/dist/src/programmes/rules/MasterOfArtsDisciplineRule.js +0 -41
- package/dist/src/programmes/rules/MasterOfEducationCountryDisciplineRule.d.ts +0 -11
- package/dist/src/programmes/rules/MasterOfEducationCountryDisciplineRule.js +0 -69
- package/dist/src/programmes/rules/MasterOfLawsCountryAttendanceRule.d.ts +0 -12
- package/dist/src/programmes/rules/MasterOfLawsCountryAttendanceRule.js +0 -43
- package/dist/src/programmes/rules/MasterOfLawsCountryTuitionFeeRule.d.ts +0 -12
- package/dist/src/programmes/rules/MasterOfLawsCountryTuitionFeeRule.js +0 -46
- package/dist/src/programmes/rules/MasterOfPhilosophyCountryAttendanceRule.d.ts +0 -12
- package/dist/src/programmes/rules/MasterOfPhilosophyCountryAttendanceRule.js +0 -43
- package/dist/src/programmes/rules/MasterOfScienceDisciplineRule.d.ts +0 -10
- package/dist/src/programmes/rules/MasterOfScienceDisciplineRule.js +0 -41
- package/dist/src/programmes/rules/OnlineAttendanceRule.d.ts +0 -5
- package/dist/src/programmes/rules/OnlineAttendanceRule.js +0 -11
- package/dist/src/sitemap-generator/IPageNumberProvider.d.ts +0 -3
- /package/dist/src/{common/IPolicyMetaData.js → structured-data/dto/BreadcrumbDTO.js} +0 -0
- /package/dist/src/{programmes/IProgrammeSearchApplicationState.js → structured-data/dto/EntityDTO.js} +0 -0
- /package/dist/src/{programmes/IProgrammeSearchDependencies.js → structured-data/dto/FAQItemDto.js} +0 -0
- /package/dist/src/{programmes/IProgrammesSeoDependencies.js → structured-data/dto/OfferDTO.js} +0 -0
- /package/dist/src/{sitemap-generator/IPageNumberProvider.js → structured-data/dto/ReviewRatingDTO.js} +0 -0
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.
|
|
@@ -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 = [
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SearchStructuredDataFactory } from "./SearchStructuredDataFactory";
|
|
2
|
+
import { IProgrammeCard } from "@studyportals/domain-client";
|
|
3
|
+
import { ReviewRatingDTO } from "./dto/ReviewRatingDTO";
|
|
4
|
+
import { OfferDTO } from "./dto/OfferDTO";
|
|
5
|
+
import { Course } from "schema-dts";
|
|
6
|
+
import { EntityDTO } from "./dto/EntityDTO";
|
|
7
|
+
import { StructuredDataCurrencyConversionService } from "../structured-data/interface/StructuredDataCurrencyConversionService";
|
|
8
|
+
export declare class ProgrammeStructuredDataFactory extends SearchStructuredDataFactory<IProgrammeCard> {
|
|
9
|
+
private currencyConversionService;
|
|
10
|
+
constructor(currencyConversionService: StructuredDataCurrencyConversionService);
|
|
11
|
+
private regionalDataPriority;
|
|
12
|
+
protected getRating(card: IProgrammeCard): ReviewRatingDTO | undefined;
|
|
13
|
+
protected getOfferData(card: IProgrammeCard): Promise<OfferDTO | undefined>;
|
|
14
|
+
protected buildStructuredDataForCard(entity: EntityDTO<IProgrammeCard>): Course | undefined;
|
|
15
|
+
private getCourseMode;
|
|
16
|
+
private getCourseWorkload;
|
|
17
|
+
private getCourseStartDate;
|
|
18
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { SearchStructuredDataFactory } from "./SearchStructuredDataFactory";
|
|
2
|
+
export class ProgrammeStructuredDataFactory extends SearchStructuredDataFactory {
|
|
3
|
+
currencyConversionService;
|
|
4
|
+
constructor(currencyConversionService) {
|
|
5
|
+
super();
|
|
6
|
+
this.currencyConversionService = currencyConversionService;
|
|
7
|
+
}
|
|
8
|
+
regionalDataPriority = ['international', 'general', 'eea', 'national'];
|
|
9
|
+
getRating(card) {
|
|
10
|
+
if (typeof card.getReviewRating === 'undefined')
|
|
11
|
+
return;
|
|
12
|
+
const rating = card.getReviewRating();
|
|
13
|
+
if (!rating)
|
|
14
|
+
return;
|
|
15
|
+
return {
|
|
16
|
+
rating: rating?.getAverageStarRating(),
|
|
17
|
+
quantity: rating?.getQuantity(),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
async getOfferData(card) {
|
|
21
|
+
if (!card.canShowTuitionFees())
|
|
22
|
+
return;
|
|
23
|
+
const tuitionFees = card.getTuitionFees();
|
|
24
|
+
let tuition;
|
|
25
|
+
let timing;
|
|
26
|
+
for (const target of this.regionalDataPriority) {
|
|
27
|
+
if (!tuition) {
|
|
28
|
+
tuition = tuitionFees.find(t => t.getTarget() === target);
|
|
29
|
+
}
|
|
30
|
+
if (!timing) {
|
|
31
|
+
timing = card.canShowTimings() ? card.getTimings().find(t => t.getType() === target && t.canShowStartDate()) : undefined;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (!tuition) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
price: Math.round(await this.currencyConversionService.convert(tuition.getAmount(), tuition.getCurrency(), 'USD')),
|
|
39
|
+
category: 'tuition',
|
|
40
|
+
validFrom: timing ? timing.getStartDate().getDate() : undefined
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
buildStructuredDataForCard(entity) {
|
|
44
|
+
const offer = this.constructOffer(entity.offer);
|
|
45
|
+
if (!offer)
|
|
46
|
+
return undefined;
|
|
47
|
+
const card = entity.card;
|
|
48
|
+
return {
|
|
49
|
+
"@type": "Course",
|
|
50
|
+
"name": card.getTitle(),
|
|
51
|
+
"description": card.getSummary(),
|
|
52
|
+
"url": card.getProgrammeLink().getUrl(),
|
|
53
|
+
"provider": {
|
|
54
|
+
"@type": "EducationalOrganization",
|
|
55
|
+
"name": card.getUniversityLink().getDescription(),
|
|
56
|
+
"url": `https://${window.location.host}${card.getUniversityLink().getUrl()}`
|
|
57
|
+
},
|
|
58
|
+
"offers": offer,
|
|
59
|
+
"aggregateRating": this.constructAggregateRating(entity.reviewRating),
|
|
60
|
+
"hasCourseInstance": {
|
|
61
|
+
"@type": "CourseInstance",
|
|
62
|
+
"startDate": this.getCourseStartDate(card),
|
|
63
|
+
"courseWorkload": this.getCourseWorkload(card),
|
|
64
|
+
"courseMode": this.getCourseMode(card),
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
getCourseMode(card) {
|
|
69
|
+
if (card.isBlended())
|
|
70
|
+
return 'blended';
|
|
71
|
+
if (card.isOnline())
|
|
72
|
+
return 'online';
|
|
73
|
+
if (card.isOnCampus())
|
|
74
|
+
return 'onsite';
|
|
75
|
+
}
|
|
76
|
+
getCourseWorkload(card) {
|
|
77
|
+
if (card.isFullTime())
|
|
78
|
+
return 'PT40H';
|
|
79
|
+
if (card.isPartTime())
|
|
80
|
+
return 'PT20H';
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
getCourseStartDate(card) {
|
|
84
|
+
for (const target of this.regionalDataPriority) {
|
|
85
|
+
const timing = card.canShowTimings() ? card.getTimings().find(t => t.getType() === target && t.canShowStartDate()) : undefined;
|
|
86
|
+
if (timing) {
|
|
87
|
+
return timing.getStartDate().getDate().toISOString().split('T')[0];
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { SearchResultsPage, WithContext, Offer, AggregateRating, Thing, FAQPage } from 'schema-dts';
|
|
2
|
+
import { ReviewRatingDTO } from './dto/ReviewRatingDTO';
|
|
3
|
+
import { OfferDTO } from './dto/OfferDTO';
|
|
4
|
+
import { EntityDTO } from './dto/EntityDTO';
|
|
5
|
+
import { FAQItemDto } from './dto/FAQItemDto';
|
|
6
|
+
import { BreadcrumbDTO } from './dto/BreadcrumbDTO';
|
|
7
|
+
export declare abstract class SearchStructuredDataFactory<TCard> {
|
|
8
|
+
buildStructuredData(title: string, description: string, cards: TCard[], faqItems?: FAQItemDto[], breadcrumbs?: BreadcrumbDTO[]): Promise<WithContext<SearchResultsPage>>;
|
|
9
|
+
protected abstract buildStructuredDataForCard(entity: EntityDTO<TCard>): Thing | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Get the rating for a card.
|
|
12
|
+
* This method should be overridden by subclasses to provide the specific rating logic.
|
|
13
|
+
* If no rating is available, return undefined and no aggregate rating will be constructed for the card & page.
|
|
14
|
+
*
|
|
15
|
+
* @param card
|
|
16
|
+
* @protected
|
|
17
|
+
*/
|
|
18
|
+
protected getRating(card: TCard): ReviewRatingDTO | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Get the offer data for a card.
|
|
21
|
+
* This method should be overridden by subclasses to provide the specific offer logic.
|
|
22
|
+
* If no offer is available, return undefined and no aggregate offer will be constructed for the card & page.
|
|
23
|
+
*
|
|
24
|
+
* @param card
|
|
25
|
+
* @protected
|
|
26
|
+
*/
|
|
27
|
+
protected getOfferData(card: TCard): Promise<OfferDTO | undefined>;
|
|
28
|
+
private constructOptionalPageOffers;
|
|
29
|
+
protected constructOptionalFaqPage(faqItems: FAQItemDto[]): FAQPage | undefined;
|
|
30
|
+
private constructOptionalBreadcrumbs;
|
|
31
|
+
protected constructAggregateRating(reviewRating?: ReviewRatingDTO): AggregateRating | undefined;
|
|
32
|
+
protected constructOffer(offerData?: OfferDTO): Offer | undefined;
|
|
33
|
+
private stripHtmlWithListRetain;
|
|
34
|
+
}
|