@studyportals/fawkes 3.0.0 → 3.0.1-3

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 (170) hide show
  1. package/dist/organisations-seo/index.d.ts +3 -0
  2. package/dist/organisations-seo/index.js +3 -1
  3. package/dist/scholarships-seo/index.d.ts +1 -3
  4. package/dist/src/common/FilterKeyValuesMap.d.ts +2 -0
  5. package/dist/src/common/IRule.d.ts +7 -0
  6. package/dist/src/common/ISearchApplicationState.d.ts +3 -0
  7. package/dist/src/common/ISearchDependencies.d.ts +2 -3
  8. package/dist/src/common/ISeoDependencies.d.ts +3 -0
  9. package/dist/src/common/ISitemapDependencies.d.ts +7 -0
  10. package/dist/src/common/index.d.ts +4 -6
  11. package/dist/src/common/index.js +4 -1
  12. package/dist/src/common/policies/BaseSeoIndexabilityPolicy.d.ts +15 -0
  13. package/dist/src/common/{BaseSeoIndexabilityPolicy.js → policies/BaseSeoIndexabilityPolicy.js} +5 -4
  14. package/dist/src/common/policies/RuleBasedIndexabilityPolicy.d.ts +11 -0
  15. package/dist/src/common/policies/RuleBasedIndexabilityPolicy.js +24 -0
  16. package/dist/src/common/rules/BaseFilterKeyValueRule.d.ts +10 -0
  17. package/dist/src/common/rules/BaseFilterKeyValueRule.js +27 -0
  18. package/dist/src/common/rules/OnlyFiltersSelectedRule.d.ts +11 -0
  19. package/dist/src/common/rules/OnlyFiltersSelectedRule.js +27 -0
  20. package/dist/src/common/rules/SingleValueSelectedForFilterRule.d.ts +11 -0
  21. package/dist/src/common/rules/SingleValueSelectedForFilterRule.js +21 -0
  22. package/dist/src/enums/FilterCombinations.d.ts +9 -1
  23. package/dist/src/enums/FilterCombinations.js +9 -0
  24. package/dist/src/errors/DependencyMissingError.d.ts +3 -0
  25. package/dist/src/errors/DependencyMissingError.js +5 -0
  26. package/dist/src/errors/InvalidDependencyTypeError.d.ts +3 -0
  27. package/dist/src/errors/InvalidDependencyTypeError.js +5 -0
  28. package/dist/src/errors/InvalidFilterValueError.d.ts +4 -0
  29. package/dist/src/errors/InvalidFilterValueError.js +5 -0
  30. package/dist/src/organisations/IOrganisationSearchApplicationState.d.ts +4 -0
  31. package/dist/src/organisations/ISeoSortingState.d.ts +4 -0
  32. package/dist/src/organisations/OrganisationsBaseSeoIndexabilityPolicy.d.ts +11 -0
  33. package/dist/src/organisations/OrganisationsBaseSeoIndexabilityPolicy.js +20 -0
  34. package/dist/src/organisations/OrganisationsRuleBasedIndexabilityPolicy.d.ts +11 -0
  35. package/dist/src/organisations/OrganisationsRuleBasedIndexabilityPolicy.js +20 -0
  36. package/dist/src/organisations/SearchIndexabilityManager.d.ts +5 -0
  37. package/dist/src/organisations/SearchIndexabilityManager.js +36 -3
  38. package/dist/src/organisations/index.d.ts +4 -0
  39. package/dist/src/organisations/index.js +4 -1
  40. package/dist/src/organisations/policies/index.d.ts +18 -0
  41. package/dist/src/organisations/policies/index.js +18 -0
  42. package/dist/src/organisations/policies/our-picks/Area.d.ts +11 -0
  43. package/dist/src/organisations/policies/our-picks/Area.js +20 -0
  44. package/dist/src/organisations/policies/our-picks/AreaAttendance.d.ts +13 -0
  45. package/dist/src/organisations/policies/our-picks/AreaAttendance.js +25 -0
  46. package/dist/src/organisations/policies/our-picks/Attendance.d.ts +12 -0
  47. package/dist/src/organisations/policies/our-picks/Attendance.js +21 -0
  48. package/dist/src/organisations/policies/our-picks/Continent.d.ts +11 -0
  49. package/dist/src/organisations/policies/our-picks/Continent.js +19 -0
  50. package/dist/src/organisations/policies/our-picks/Country.d.ts +11 -0
  51. package/dist/src/organisations/policies/our-picks/Country.js +19 -0
  52. package/dist/src/organisations/policies/our-picks/CountryAttendance.d.ts +13 -0
  53. package/dist/src/organisations/policies/our-picks/CountryAttendance.js +24 -0
  54. package/dist/src/organisations/policies/our-picks/Unfiltered.d.ts +10 -0
  55. package/dist/src/organisations/policies/our-picks/Unfiltered.js +16 -0
  56. package/dist/src/organisations/policies/ranked/RankedArea.d.ts +12 -0
  57. package/dist/src/organisations/policies/ranked/RankedArea.js +22 -0
  58. package/dist/src/organisations/policies/ranked/RankedAreaDiscipline.d.ts +13 -0
  59. package/dist/src/organisations/policies/ranked/RankedAreaDiscipline.js +25 -0
  60. package/dist/src/organisations/policies/ranked/RankedAttendance.d.ts +13 -0
  61. package/dist/src/organisations/policies/ranked/RankedAttendance.js +23 -0
  62. package/dist/src/organisations/policies/ranked/RankedAttendanceDiscipline.d.ts +13 -0
  63. package/dist/src/organisations/policies/ranked/RankedAttendanceDiscipline.js +24 -0
  64. package/dist/src/organisations/policies/ranked/RankedContinent.d.ts +12 -0
  65. package/dist/src/organisations/policies/ranked/RankedContinent.js +21 -0
  66. package/dist/src/organisations/policies/ranked/RankedContinentAttendance.d.ts +14 -0
  67. package/dist/src/organisations/policies/ranked/RankedContinentAttendance.js +26 -0
  68. package/dist/src/organisations/policies/ranked/RankedCountry.d.ts +12 -0
  69. package/dist/src/organisations/policies/ranked/RankedCountry.js +21 -0
  70. package/dist/src/organisations/policies/ranked/RankedCountryAttendance.d.ts +13 -0
  71. package/dist/src/organisations/policies/ranked/RankedCountryAttendance.js +24 -0
  72. package/dist/src/organisations/policies/ranked/RankedCountryDiscipline.d.ts +12 -0
  73. package/dist/src/organisations/policies/ranked/RankedCountryDiscipline.js +22 -0
  74. package/dist/src/organisations/policies/ranked/RankedDiscipline.d.ts +12 -0
  75. package/dist/src/organisations/policies/ranked/RankedDiscipline.js +21 -0
  76. package/dist/src/organisations/policies/ranked/RankedUnfiltered.d.ts +11 -0
  77. package/dist/src/organisations/policies/ranked/RankedUnfiltered.js +18 -0
  78. package/dist/src/organisations/rules/AtLeastTwoRankedResultsRule.d.ts +8 -0
  79. package/dist/src/organisations/rules/AtLeastTwoRankedResultsRule.js +14 -0
  80. package/dist/src/organisations/rules/ContinentIsEuropeRule.d.ts +9 -0
  81. package/dist/src/organisations/rules/ContinentIsEuropeRule.js +16 -0
  82. package/dist/src/organisations/rules/NoFiltersSelectedRule.d.ts +8 -0
  83. package/dist/src/organisations/rules/NoFiltersSelectedRule.js +14 -0
  84. package/dist/src/organisations/rules/OnlineAttendanceRule.d.ts +5 -0
  85. package/dist/src/organisations/rules/OnlineAttendanceRule.js +13 -0
  86. package/dist/src/organisations/rules/SearchVolumeAreasAttendanceRule.d.ts +11 -0
  87. package/dist/src/organisations/rules/SearchVolumeAreasAttendanceRule.js +26 -0
  88. package/dist/src/organisations/rules/SearchVolumeAreasDisciplineRule.d.ts +11 -0
  89. package/dist/src/organisations/rules/SearchVolumeAreasDisciplineRule.js +27 -0
  90. package/dist/src/organisations/rules/SearchVolumeCountriesAttendanceRule.d.ts +11 -0
  91. package/dist/src/organisations/rules/SearchVolumeCountriesAttendanceRule.js +28 -0
  92. package/dist/src/organisations/types/IOrganisationSearchDependencies.d.ts +9 -0
  93. package/dist/src/organisations/types/IOrganisationsSeoDependencies.d.ts +3 -0
  94. package/dist/src/organisations/types/IOrganisationsSitemapDependencies.d.ts +5 -0
  95. package/dist/src/organisations/types.d.ts +6 -0
  96. package/dist/src/organisations/types.js +6 -0
  97. package/dist/src/scholarships/SearchIndexabilityManager.d.ts +2 -3
  98. package/dist/src/scholarships/SearchIndexabilityManager.js +19 -14
  99. package/dist/src/scholarships/policies/Area.d.ts +12 -0
  100. package/dist/src/scholarships/policies/Area.js +35 -0
  101. package/dist/src/scholarships/policies/Country.d.ts +11 -0
  102. package/dist/src/scholarships/policies/Country.js +31 -0
  103. package/dist/src/scholarships/policies/Discipline.d.ts +11 -0
  104. package/dist/src/scholarships/policies/Discipline.js +31 -0
  105. package/dist/src/scholarships/policies/DisciplineCountry.d.ts +11 -0
  106. package/dist/src/scholarships/policies/DisciplineCountry.js +37 -0
  107. package/dist/src/scholarships/policies/Unfiltered.d.ts +8 -0
  108. package/dist/src/scholarships/policies/{UnfilteredPolicy.js → Unfiltered.js} +5 -8
  109. package/dist/src/scholarships/policies/UniversityCountry.d.ts +10 -0
  110. package/dist/src/scholarships/policies/{UniversityCountryPolicy.js → UniversityCountry.js} +15 -26
  111. package/dist/src/scholarships/rules/ExceptAustaliaAreasRule.d.ts +9 -10
  112. package/dist/src/scholarships/rules/ExceptAustaliaAreasRule.js +17 -22
  113. package/dist/src/scholarships/rules/SearchVolumeAreasRule.d.ts +8 -9
  114. package/dist/src/scholarships/rules/SearchVolumeAreasRule.js +17 -22
  115. package/dist/src/scholarships/rules/SearchVolumeCountriesDisciplinesRule.d.ts +13 -0
  116. package/dist/src/scholarships/rules/SearchVolumeCountriesDisciplinesRule.js +40 -0
  117. package/dist/src/scholarships/rules/SearchVolumeCountriesRule.d.ts +8 -9
  118. package/dist/src/scholarships/rules/SearchVolumeCountriesRule.js +17 -22
  119. package/dist/src/scholarships/rules/SearchVolumeCountryDisciplineRule.d.ts +10 -9
  120. package/dist/src/scholarships/rules/SearchVolumeCountryDisciplineRule.js +24 -21
  121. package/dist/src/scholarships/rules/SearchVolumeDisciplinesRule.d.ts +8 -9
  122. package/dist/src/scholarships/rules/SearchVolumeDisciplinesRule.js +19 -26
  123. package/dist/src/scholarships/types.d.ts +0 -1
  124. package/dist/src/scholarships/types.js +0 -1
  125. package/dist/src/sitemap-generator/SitemapUrlGeneratorManager.d.ts +3 -2
  126. package/dist/src/sitemap-generator/SitemapUrlGeneratorManager.js +17 -13
  127. package/package.json +10 -3
  128. package/dist/src/common/BaseSeoIndexabilityPolicy.d.ts +0 -16
  129. package/dist/src/common/ICustomRule.d.ts +0 -6
  130. package/dist/src/common/IFilterKeyValues.d.ts +0 -6
  131. package/dist/src/common/IFilterKeyValues.js +0 -1
  132. package/dist/src/common/IIndexabilityPolicyDependencies.d.ts +0 -8
  133. package/dist/src/common/ISeoFilterOptions.d.ts +0 -4
  134. package/dist/src/common/ISeoSearchApplicationState.d.ts +0 -3
  135. package/dist/src/common/RuleBasedIndexabilityPolicy.d.ts +0 -9
  136. package/dist/src/common/RuleBasedIndexabilityPolicy.js +0 -6
  137. package/dist/src/organisations/FilterKeyValuePairs.d.ts +0 -7
  138. package/dist/src/organisations/IOrganisationsProvider.d.ts +0 -3
  139. package/dist/src/organisations/ISeoInfoBaseOrganisations.d.ts +0 -7
  140. package/dist/src/organisations/ISortState.d.ts +0 -4
  141. package/dist/src/organisations/SeoIndexabilityPolicy.d.ts +0 -11
  142. package/dist/src/organisations/SeoIndexabilityPolicy.js +0 -12
  143. package/dist/src/organisations/SeoRuleBasedIndexabilityPolicy.d.ts +0 -10
  144. package/dist/src/organisations/SeoRuleBasedIndexabilityPolicy.js +0 -7
  145. package/dist/src/scholarships/policies/AreaPolicy.d.ts +0 -14
  146. package/dist/src/scholarships/policies/AreaPolicy.js +0 -61
  147. package/dist/src/scholarships/policies/CountryPolicy.d.ts +0 -14
  148. package/dist/src/scholarships/policies/CountryPolicy.js +0 -46
  149. package/dist/src/scholarships/policies/DisciplineCountryPolicy.d.ts +0 -14
  150. package/dist/src/scholarships/policies/DisciplineCountryPolicy.js +0 -62
  151. package/dist/src/scholarships/policies/DisciplinePolicy.d.ts +0 -14
  152. package/dist/src/scholarships/policies/DisciplinePolicy.js +0 -46
  153. package/dist/src/scholarships/policies/UnfilteredPolicy.d.ts +0 -9
  154. package/dist/src/scholarships/policies/UniversityCountryPolicy.d.ts +0 -9
  155. package/dist/src/sitemap-generator/ISitemapDependencies.d.ts +0 -7
  156. package/dist/src/sitemap-generator/ISitemapUrlGeneratorDependencies.d.ts +0 -7
  157. package/dist/src/types/SeoDependencies.d.ts +0 -3
  158. package/dist/src/types/SeoDependencies.js +0 -1
  159. /package/dist/src/common/{ICustomRule.js → FilterKeyValuesMap.js} +0 -0
  160. /package/dist/src/common/{IIndexabilityPolicyDependencies.js → IRule.js} +0 -0
  161. /package/dist/src/common/{ISeoFilterOptions.js → ISearchApplicationState.js} +0 -0
  162. /package/dist/src/common/{ISeoSearchApplicationState.js → ISeoDependencies.js} +0 -0
  163. /package/dist/src/{sitemap-generator → common}/ISitemapDependencies.js +0 -0
  164. /package/dist/src/{organisations → enums}/SortingOptions.d.ts +0 -0
  165. /package/dist/src/{organisations → enums}/SortingOptions.js +0 -0
  166. /package/dist/src/organisations/{FilterKeyValuePairs.js → IOrganisationSearchApplicationState.js} +0 -0
  167. /package/dist/src/organisations/{IOrganisationsProvider.js → ISeoSortingState.js} +0 -0
  168. /package/dist/src/organisations/{ISeoInfoBaseOrganisations.js → types/IOrganisationSearchDependencies.js} +0 -0
  169. /package/dist/src/organisations/{ISortState.js → types/IOrganisationsSeoDependencies.js} +0 -0
  170. /package/dist/src/{sitemap-generator/ISitemapUrlGeneratorDependencies.js → organisations/types/IOrganisationsSitemapDependencies.js} +0 -0
@@ -0,0 +1,3 @@
1
+ export * from "../src/common/ISeoInfoBase";
2
+ export * from "../src/common/ISeoFilterState";
3
+ export * from "../src/organisations";
@@ -1 +1,3 @@
1
- "use strict";
1
+ export * from "../src/common/ISeoInfoBase";
2
+ export * from "../src/common/ISeoFilterState";
3
+ export * from "../src/organisations";
@@ -1,8 +1,6 @@
1
1
  import { ISeoFilterState } from "../src/common/ISeoFilterState";
2
2
  import { ISeoInfoBase } from "../src/common/ISeoInfoBase";
3
- import { ISeoFilterOptions } from "../src/common/ISeoFilterOptions";
4
- import { ISeoSearchApplicationState } from "../src/common/ISeoSearchApplicationState";
5
3
  import { ISearchIndexabilityManager } from "../src/common/ISearchIndexabilityManager";
6
4
  import { SearchIndexabilityManager } from "../src/scholarships/SearchIndexabilityManager";
7
5
  import { types } from "../src/scholarships/types";
8
- export { ISeoFilterState, ISeoInfoBase, ISeoFilterOptions, ISeoSearchApplicationState, ISearchIndexabilityManager, SearchIndexabilityManager, types };
6
+ export { ISeoFilterState, ISeoInfoBase, ISearchIndexabilityManager, SearchIndexabilityManager, types };
@@ -0,0 +1,2 @@
1
+ import { FilterKey } from "@studyportals/search-filters";
2
+ export type FilterKeyValuesMap = Map<FilterKey, string[]>;
@@ -0,0 +1,7 @@
1
+ import { FilterKeyValuesMap } from "./FilterKeyValuesMap";
2
+ import { ISearchDependencies } from "./ISearchDependencies";
3
+ export interface IRule {
4
+ getName(): string;
5
+ forSearch(dependencies: ISearchDependencies): Promise<boolean>;
6
+ forSitemapGenerator(filterKeyValues: FilterKeyValuesMap): Promise<boolean>;
7
+ }
@@ -0,0 +1,3 @@
1
+ export interface ISearchApplicationState {
2
+ getNumberOfResults(): number;
3
+ }
@@ -1,8 +1,7 @@
1
- import { ISeoInfoBase, ISeoFilterState, ISeoFilterOptions, ISeoSearchApplicationState } from "../common";
1
+ import { ISeoInfoBase, ISeoFilterState, ISearchApplicationState } from "../common";
2
2
  import { IDependencies } from "./IDependencies";
3
3
  export interface ISearchDependencies extends IDependencies {
4
4
  seoInfoBase: ISeoInfoBase;
5
5
  filterState: ISeoFilterState;
6
- filterOptions?: ISeoFilterOptions;
7
- applicationState?: ISeoSearchApplicationState;
6
+ applicationState: ISearchApplicationState;
8
7
  }
@@ -0,0 +1,3 @@
1
+ import { ISearchDependencies } from "../common/ISearchDependencies";
2
+ import { ISitemapDependencies } from "../common/ISitemapDependencies";
3
+ export type ISeoDependencies = ISearchDependencies | ISitemapDependencies;
@@ -0,0 +1,7 @@
1
+ import { IDependencies } from "../common/IDependencies";
2
+ import { ISearchApiClient } from "../sitemap-generator/ISearchApiClient";
3
+ import { IOrganisationsClient } from "../sitemap-generator/IOrganisationsClient";
4
+ export interface ISitemapDependencies extends IDependencies {
5
+ searchApiClient: ISearchApiClient;
6
+ organisationsClient: IOrganisationsClient;
7
+ }
@@ -1,6 +1,4 @@
1
- import { ISeoInfoBase } from "./ISeoInfoBase";
2
- import { ISeoFilterState } from "./ISeoFilterState";
3
- import { ISeoFilterOptions } from "./ISeoFilterOptions";
4
- import { ISeoSearchApplicationState } from "./ISeoSearchApplicationState";
5
- import { ISearchIndexabilityManager } from "./ISearchIndexabilityManager";
6
- export { ISeoFilterOptions, ISeoInfoBase, ISeoFilterState, ISeoSearchApplicationState, ISearchIndexabilityManager };
1
+ export * from "./ISeoInfoBase";
2
+ export * from "./ISeoFilterState";
3
+ export * from "./ISearchApplicationState";
4
+ export * from "./ISearchIndexabilityManager";
@@ -1 +1,4 @@
1
- export {};
1
+ export * from "./ISeoInfoBase";
2
+ export * from "./ISeoFilterState";
3
+ export * from "./ISearchApplicationState";
4
+ export * from "./ISearchIndexabilityManager";
@@ -0,0 +1,15 @@
1
+ import { ISitemapUrlGenerator } from "../ISitemapUrlGenerator";
2
+ import { ISeoIndexabilityPolicy } from "../ISeoIndexabilityPolicy";
3
+ import { IDependencies } from "../IDependencies";
4
+ import { FilterCombinations } from "../../enums/FilterCombinations";
5
+ export declare abstract class BaseSeoIndexabilityPolicy<TDependencies extends IDependencies> implements ISeoIndexabilityPolicy, ISitemapUrlGenerator {
6
+ protected readonly dependencies: TDependencies;
7
+ constructor(dependencies: TDependencies);
8
+ shouldIndex(): Promise<boolean>;
9
+ generateSitemapUrls(): Promise<string[]>;
10
+ private isIndexabilityPolicyDependencies;
11
+ private isSitemapUrlGeneratorDependencies;
12
+ protected abstract isIndexable(): Promise<boolean>;
13
+ protected abstract generateUrls(): Promise<string[]>;
14
+ abstract get filterCombination(): FilterCombinations;
15
+ }
@@ -1,4 +1,5 @@
1
- import { DependencyTypes } from "../enums/DependencyTypes";
1
+ import { DependencyTypes } from "../../enums/DependencyTypes";
2
+ import { InvalidDependencyTypeError } from "../../errors/InvalidDependencyTypeError";
2
3
  export class BaseSeoIndexabilityPolicy {
3
4
  dependencies;
4
5
  constructor(dependencies) {
@@ -6,13 +7,13 @@ export class BaseSeoIndexabilityPolicy {
6
7
  }
7
8
  async shouldIndex() {
8
9
  if (!this.isIndexabilityPolicyDependencies()) {
9
- throw new Error('Dependency type is incorrect.');
10
+ throw new InvalidDependencyTypeError();
10
11
  }
11
- return this.matchesFilters();
12
+ return this.isIndexable();
12
13
  }
13
14
  async generateSitemapUrls() {
14
15
  if (!this.isSitemapUrlGeneratorDependencies()) {
15
- throw new Error('Dependency type is incorrect.');
16
+ throw new InvalidDependencyTypeError();
16
17
  }
17
18
  return await this.generateUrls();
18
19
  }
@@ -0,0 +1,11 @@
1
+ import { BaseSeoIndexabilityPolicy } from "./BaseSeoIndexabilityPolicy";
2
+ import { ISearchDependencies } from "../ISearchDependencies";
3
+ import { IDependencies } from "../IDependencies";
4
+ import { IRule } from "../IRule";
5
+ import { FilterKeyValuesMap } from "../FilterKeyValuesMap";
6
+ export declare abstract class RuleBasedIndexabilityPolicy<TDependencies extends IDependencies> extends BaseSeoIndexabilityPolicy<TDependencies> {
7
+ protected abstract readonly rules: IRule[];
8
+ protected isIndexable(): Promise<boolean>;
9
+ protected checkRulesForSearch(dependencies: ISearchDependencies): Promise<boolean>;
10
+ protected checkRulesForSitemap(filterKeyValues: FilterKeyValuesMap): Promise<boolean>;
11
+ }
@@ -0,0 +1,24 @@
1
+ import { BaseSeoIndexabilityPolicy } from "./BaseSeoIndexabilityPolicy";
2
+ export class RuleBasedIndexabilityPolicy extends BaseSeoIndexabilityPolicy {
3
+ async isIndexable() {
4
+ return await this.checkRulesForSearch(this.dependencies);
5
+ }
6
+ async checkRulesForSearch(dependencies) {
7
+ for (const rule of this.rules) {
8
+ const result = await rule.forSearch(dependencies);
9
+ if (!result) {
10
+ return false;
11
+ }
12
+ }
13
+ return true;
14
+ }
15
+ async checkRulesForSitemap(filterKeyValues) {
16
+ for (const rule of this.rules) {
17
+ const result = await rule.forSitemapGenerator(filterKeyValues);
18
+ if (!result) {
19
+ return false;
20
+ }
21
+ }
22
+ return true;
23
+ }
24
+ }
@@ -0,0 +1,10 @@
1
+ import { FilterKeyValuesMap } from "../FilterKeyValuesMap";
2
+ import { IRule } from "../IRule";
3
+ import { ISearchDependencies } from "../ISearchDependencies";
4
+ export declare abstract class BaseFilterKeyValueRule implements IRule {
5
+ private readonly expectedFilterKeyValues;
6
+ constructor(expectedFilterKeyValues: FilterKeyValuesMap);
7
+ abstract getName(): string;
8
+ forSearch(dependencies: ISearchDependencies): Promise<boolean>;
9
+ forSitemapGenerator(filterKeyValues: FilterKeyValuesMap): Promise<boolean>;
10
+ }
@@ -0,0 +1,27 @@
1
+ export class BaseFilterKeyValueRule {
2
+ expectedFilterKeyValues;
3
+ constructor(expectedFilterKeyValues) {
4
+ this.expectedFilterKeyValues = expectedFilterKeyValues;
5
+ }
6
+ forSearch(dependencies) {
7
+ const { seoInfoBase, filterState } = dependencies;
8
+ const result = Array.from(this.expectedFilterKeyValues)
9
+ .reduce((acc, [key, values]) => {
10
+ const optionValue = seoInfoBase.getFilterOptionValueBy(key, filterState);
11
+ return acc && optionValue === values[0];
12
+ }, true);
13
+ return Promise.resolve(result);
14
+ }
15
+ forSitemapGenerator(filterKeyValues) {
16
+ for (const [key, values] of this.expectedFilterKeyValues) {
17
+ const filterValues = filterKeyValues.get(key);
18
+ if (!filterValues || filterValues.length !== values.length) {
19
+ return Promise.resolve(false);
20
+ }
21
+ if (!values.every((value) => filterValues.includes(value))) {
22
+ return Promise.resolve(false);
23
+ }
24
+ }
25
+ return Promise.resolve(true);
26
+ }
27
+ }
@@ -0,0 +1,11 @@
1
+ import { IRule } from "../../common/IRule";
2
+ import { FilterKey } from "@studyportals/search-filters";
3
+ import { ISearchDependencies } from "../../common/ISearchDependencies";
4
+ import { FilterKeyValuesMap } from "../FilterKeyValuesMap";
5
+ export declare class OnlyFiltersSelectedRule implements IRule {
6
+ private readonly filterKeys;
7
+ constructor(filterKeys: FilterKey[]);
8
+ getName(): string;
9
+ forSearch(dependencies: ISearchDependencies): Promise<boolean>;
10
+ forSitemapGenerator(filterKeyValues: FilterKeyValuesMap): Promise<boolean>;
11
+ }
@@ -0,0 +1,27 @@
1
+ export class OnlyFiltersSelectedRule {
2
+ filterKeys;
3
+ constructor(filterKeys) {
4
+ this.filterKeys = filterKeys;
5
+ }
6
+ getName() {
7
+ return 'OneValueSelectedForFilterRule';
8
+ }
9
+ async forSearch(dependencies) {
10
+ const seoInfoBase = dependencies.seoInfoBase;
11
+ const filterState = dependencies.filterState;
12
+ return await seoInfoBase.selectionOnlyFor(this.filterKeys, filterState);
13
+ }
14
+ forSitemapGenerator(filterKeyValues) {
15
+ const filterKeys = Array.from(filterKeyValues.keys());
16
+ if (filterKeys.length !== this.filterKeys.length) {
17
+ return Promise.resolve(false);
18
+ }
19
+ if (!filterKeys.every((filterKey) => this.filterKeys.includes(filterKey))) {
20
+ return Promise.resolve(false);
21
+ }
22
+ if (!this.filterKeys.every((filterKey) => filterKeys.includes(filterKey))) {
23
+ return Promise.resolve(false);
24
+ }
25
+ return Promise.resolve(true);
26
+ }
27
+ }
@@ -0,0 +1,11 @@
1
+ import { IRule } from "../../common/IRule";
2
+ import { FilterKey } from "@studyportals/search-filters";
3
+ import { ISearchDependencies } from "../../common/ISearchDependencies";
4
+ import { FilterKeyValuesMap } from "../FilterKeyValuesMap";
5
+ export declare class SingleValueSelectedForFilterRule implements IRule {
6
+ private readonly filterKey;
7
+ constructor(filterKey: FilterKey);
8
+ getName(): string;
9
+ forSearch(dependencies: ISearchDependencies): Promise<boolean>;
10
+ forSitemapGenerator(filterKeyValues: FilterKeyValuesMap): Promise<boolean>;
11
+ }
@@ -0,0 +1,21 @@
1
+ export class SingleValueSelectedForFilterRule {
2
+ filterKey;
3
+ constructor(filterKey) {
4
+ this.filterKey = filterKey;
5
+ }
6
+ getName() {
7
+ return 'OneValueSelectedForFilterRule';
8
+ }
9
+ async forSearch(dependencies) {
10
+ const seoInfoBase = dependencies.seoInfoBase;
11
+ const filterState = dependencies.filterState;
12
+ return await seoInfoBase.singleSelectionFor(this.filterKey, filterState);
13
+ }
14
+ forSitemapGenerator(filterKeyValues) {
15
+ const filterValues = filterKeyValues.get(this.filterKey);
16
+ if (!filterValues || filterValues.length !== 1) {
17
+ return Promise.resolve(false);
18
+ }
19
+ return Promise.resolve(true);
20
+ }
21
+ }
@@ -1,9 +1,17 @@
1
1
  export declare enum FilterCombinations {
2
2
  AREA = "area",
3
+ AREA_ATTENDANCE = "areaAttendance",
4
+ AREA_DISCIPLINE = "areaDiscipline",
3
5
  COUNTRY = "country",
4
6
  DISCIPLINE_AREA = "disciplineArea",
7
+ DISCIPLINE_ATTENDANCE = "disciplineAttendance",
5
8
  DISCIPLINE_COUNTRY = "disciplineCountry",
6
9
  DISCIPLINE = "discipline",
7
10
  UNFILTERED = "unfiltered",
8
- UNIVERSITY_COUNTRY = "universityCountry"
11
+ UNIVERSITY_COUNTRY = "universityCountry",
12
+ ATTENDANCE_DISCIPLINE = "attendancedDiscipline",
13
+ CONTINENT_ATTENDANCE = "continentAttendance",
14
+ COUNTRY_ATTENDANCE = "countryAttendance",
15
+ ATTENDANCE = "attendance",
16
+ CONTINENT = "continent"
9
17
  }
@@ -1,10 +1,19 @@
1
1
  export var FilterCombinations;
2
2
  (function (FilterCombinations) {
3
3
  FilterCombinations["AREA"] = "area";
4
+ FilterCombinations["AREA_ATTENDANCE"] = "areaAttendance";
5
+ FilterCombinations["AREA_DISCIPLINE"] = "areaDiscipline";
4
6
  FilterCombinations["COUNTRY"] = "country";
5
7
  FilterCombinations["DISCIPLINE_AREA"] = "disciplineArea";
8
+ FilterCombinations["DISCIPLINE_ATTENDANCE"] = "disciplineAttendance";
6
9
  FilterCombinations["DISCIPLINE_COUNTRY"] = "disciplineCountry";
7
10
  FilterCombinations["DISCIPLINE"] = "discipline";
8
11
  FilterCombinations["UNFILTERED"] = "unfiltered";
9
12
  FilterCombinations["UNIVERSITY_COUNTRY"] = "universityCountry";
13
+ // TODO: orgs
14
+ FilterCombinations["ATTENDANCE_DISCIPLINE"] = "attendancedDiscipline";
15
+ FilterCombinations["CONTINENT_ATTENDANCE"] = "continentAttendance";
16
+ FilterCombinations["COUNTRY_ATTENDANCE"] = "countryAttendance";
17
+ FilterCombinations["ATTENDANCE"] = "attendance";
18
+ FilterCombinations["CONTINENT"] = "continent";
10
19
  })(FilterCombinations || (FilterCombinations = {}));
@@ -0,0 +1,3 @@
1
+ export declare class DependencyMissingError extends Error {
2
+ constructor(dependencyName: string);
3
+ }
@@ -0,0 +1,5 @@
1
+ export class DependencyMissingError extends Error {
2
+ constructor(dependencyName) {
3
+ super(`Dependency ${dependencyName} is missing`);
4
+ }
5
+ }
@@ -0,0 +1,3 @@
1
+ export declare class InvalidDependencyTypeError extends Error {
2
+ constructor();
3
+ }
@@ -0,0 +1,5 @@
1
+ export class InvalidDependencyTypeError extends Error {
2
+ constructor() {
3
+ super('Dependency type is incorrect.');
4
+ }
5
+ }
@@ -0,0 +1,4 @@
1
+ import { FilterKey } from "@studyportals/search-filters";
2
+ export declare class InvalidFilterValueError extends Error {
3
+ constructor(filterKey: FilterKey, value: string | undefined);
4
+ }
@@ -0,0 +1,5 @@
1
+ export class InvalidFilterValueError extends Error {
2
+ constructor(filterKey, value) {
3
+ super(`Filter ${filterKey} is missing or has an undefined value. Value: ${value}`);
4
+ }
5
+ }
@@ -0,0 +1,4 @@
1
+ import { ISearchApplicationState } from "../common";
2
+ export interface IOrganisationSearchApplicationState extends ISearchApplicationState {
3
+ getRankedResultsCount(): number;
4
+ }
@@ -0,0 +1,4 @@
1
+ import { SortingOptions } from "../enums/SortingOptions";
2
+ export interface ISeoSortingState {
3
+ getSelectedOption(): SortingOptions;
4
+ }
@@ -0,0 +1,11 @@
1
+ import { PortalType } from "@studyportals/domain-client";
2
+ import { IOrganisationsSeoDependencies } from "./types/IOrganisationsSeoDependencies";
3
+ import { BaseSeoIndexabilityPolicy } from "../common/policies/BaseSeoIndexabilityPolicy";
4
+ import { SortingOptions } from "../enums/SortingOptions";
5
+ export declare abstract class OrganisationsBaseSeoIndexabilityPolicy extends BaseSeoIndexabilityPolicy<IOrganisationsSeoDependencies> {
6
+ protected readonly indexablePortalTypes: PortalType[];
7
+ protected abstract readonly sortingOption: SortingOptions;
8
+ constructor(dependencies: IOrganisationsSeoDependencies);
9
+ shouldIndex(): Promise<boolean>;
10
+ private matchesSortingOption;
11
+ }
@@ -0,0 +1,20 @@
1
+ import { PortalType } from "@studyportals/domain-client";
2
+ import { BaseSeoIndexabilityPolicy } from "../common/policies/BaseSeoIndexabilityPolicy";
3
+ export class OrganisationsBaseSeoIndexabilityPolicy extends BaseSeoIndexabilityPolicy {
4
+ indexablePortalTypes = [PortalType.MASTER];
5
+ constructor(dependencies) {
6
+ super(dependencies);
7
+ }
8
+ async shouldIndex() {
9
+ const shouldIndex = await super.shouldIndex();
10
+ if (!shouldIndex) {
11
+ return false;
12
+ }
13
+ return this.indexablePortalTypes.includes(this.dependencies.portalType)
14
+ && this.matchesSortingOption();
15
+ }
16
+ matchesSortingOption() {
17
+ const dependencies = this.dependencies;
18
+ return dependencies.sortingState.getSelectedOption() === this.sortingOption;
19
+ }
20
+ }
@@ -0,0 +1,11 @@
1
+ import { PortalType } from "@studyportals/domain-client";
2
+ import { RuleBasedIndexabilityPolicy } from "../common/policies/RuleBasedIndexabilityPolicy";
3
+ import { IOrganisationsSeoDependencies } from "./types/IOrganisationsSeoDependencies";
4
+ import { SortingOptions } from "../enums/SortingOptions";
5
+ export declare abstract class OrganisationsRuleBasedIndexabilityPolicy extends RuleBasedIndexabilityPolicy<IOrganisationsSeoDependencies> {
6
+ protected readonly indexablePortalTypes: PortalType[];
7
+ protected abstract readonly sortingOption: SortingOptions;
8
+ constructor(dependencies: IOrganisationsSeoDependencies);
9
+ shouldIndex(): Promise<boolean>;
10
+ private matchesSortingOption;
11
+ }
@@ -0,0 +1,20 @@
1
+ import { PortalType } from "@studyportals/domain-client";
2
+ import { RuleBasedIndexabilityPolicy } from "../common/policies/RuleBasedIndexabilityPolicy";
3
+ export class OrganisationsRuleBasedIndexabilityPolicy extends RuleBasedIndexabilityPolicy {
4
+ indexablePortalTypes = [PortalType.MASTER];
5
+ constructor(dependencies) {
6
+ super(dependencies);
7
+ }
8
+ async shouldIndex() {
9
+ const shouldIndex = await super.shouldIndex();
10
+ if (!shouldIndex) {
11
+ return false;
12
+ }
13
+ return this.indexablePortalTypes.includes(this.dependencies.portalType)
14
+ && this.matchesSortingOption();
15
+ }
16
+ matchesSortingOption() {
17
+ const dependencies = this.dependencies;
18
+ return dependencies.sortingState.getSelectedOption() === this.sortingOption;
19
+ }
20
+ }
@@ -1,6 +1,11 @@
1
1
  import { ISearchIndexabilityManager } from "../common/ISearchIndexabilityManager";
2
2
  import { ISeoIndexabilityPolicy } from "../common/ISeoIndexabilityPolicy";
3
+ import { IOrganisationSearchApplicationState } from "./IOrganisationSearchApplicationState";
4
+ import { ISeoFilterState, ISeoInfoBase } from "../common";
5
+ import { PortalType } from "@studyportals/domain-client";
6
+ import { ISeoSortingState } from "../organisations/ISeoSortingState";
3
7
  export declare class SearchIndexabilityManager implements ISearchIndexabilityManager {
4
8
  policies: ISeoIndexabilityPolicy[];
9
+ constructor(portalType: PortalType, seoInfoBase: ISeoInfoBase, filterState: ISeoFilterState, sortingState: ISeoSortingState, applicationState: IOrganisationSearchApplicationState);
5
10
  shouldIndex(): Promise<boolean>;
6
11
  }
@@ -1,6 +1,39 @@
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 } from "../organisations/policies";
1
3
  export class SearchIndexabilityManager {
2
- policies = [];
3
- shouldIndex() {
4
- throw new Error("Method not implemented.");
4
+ policies;
5
+ constructor(portalType, seoInfoBase, filterState, sortingState, applicationState) {
6
+ const dependencies = {
7
+ dependencyType: DependencyTypes.SEARCH,
8
+ seoInfoBase,
9
+ filterState,
10
+ sortingState,
11
+ applicationState,
12
+ portalType
13
+ };
14
+ this.policies = [
15
+ new Area(dependencies),
16
+ new AreaAttendance(dependencies),
17
+ new Attendance(dependencies),
18
+ new Continent(dependencies),
19
+ new Country(dependencies),
20
+ new CountryAttendance(dependencies),
21
+ new Unfiltered(dependencies),
22
+ new RankedArea(dependencies),
23
+ new RankedAreaDiscipline(dependencies),
24
+ new RankedAttendance(dependencies),
25
+ new RankedAttendanceDiscipline(dependencies),
26
+ new RankedContinent(dependencies),
27
+ new RankedContinentAttendance(dependencies),
28
+ new RankedCountry(dependencies),
29
+ new RankedCountryAttendance(dependencies),
30
+ new RankedCountryDiscipline(dependencies),
31
+ new RankedDiscipline(dependencies),
32
+ new RankedUnfiltered(dependencies)
33
+ ];
34
+ }
35
+ async shouldIndex() {
36
+ const results = await Promise.all(this.policies.map(policy => policy.shouldIndex()));
37
+ return results.some(result => result);
5
38
  }
6
39
  }
@@ -0,0 +1,4 @@
1
+ export * from "./IOrganisationSearchApplicationState";
2
+ export * from "./ISeoSortingState";
3
+ export * from "./SearchIndexabilityManager";
4
+ export * from "./types";
@@ -1 +1,4 @@
1
- "use strict";
1
+ export * from "./IOrganisationSearchApplicationState";
2
+ export * from "./ISeoSortingState";
3
+ export * from "./SearchIndexabilityManager";
4
+ export * from "./types";
@@ -0,0 +1,18 @@
1
+ export * from "./our-picks/Area";
2
+ export * from "./our-picks/AreaAttendance";
3
+ export * from "./our-picks/Attendance";
4
+ export * from "./our-picks/Continent";
5
+ export * from "./our-picks/Country";
6
+ export * from "./our-picks/CountryAttendance";
7
+ export * from "./our-picks/Unfiltered";
8
+ export * from "./ranked/RankedArea";
9
+ export * from "./ranked/RankedAreaDiscipline";
10
+ export * from "./ranked/RankedAttendance";
11
+ export * from "./ranked/RankedAttendanceDiscipline";
12
+ export * from "./ranked/RankedContinent";
13
+ export * from "./ranked/RankedContinentAttendance";
14
+ export * from "./ranked/RankedCountry";
15
+ export * from "./ranked/RankedCountryAttendance";
16
+ export * from "./ranked/RankedCountryDiscipline";
17
+ export * from "./ranked/RankedDiscipline";
18
+ export * from "./ranked/RankedUnfiltered";
@@ -0,0 +1,18 @@
1
+ export * from "./our-picks/Area";
2
+ export * from "./our-picks/AreaAttendance";
3
+ export * from "./our-picks/Attendance";
4
+ export * from "./our-picks/Continent";
5
+ export * from "./our-picks/Country";
6
+ export * from "./our-picks/CountryAttendance";
7
+ export * from "./our-picks/Unfiltered";
8
+ export * from "./ranked/RankedArea";
9
+ export * from "./ranked/RankedAreaDiscipline";
10
+ export * from "./ranked/RankedAttendance";
11
+ export * from "./ranked/RankedAttendanceDiscipline";
12
+ export * from "./ranked/RankedContinent";
13
+ export * from "./ranked/RankedContinentAttendance";
14
+ export * from "./ranked/RankedCountry";
15
+ export * from "./ranked/RankedCountryAttendance";
16
+ export * from "./ranked/RankedCountryDiscipline";
17
+ export * from "./ranked/RankedDiscipline";
18
+ export * from "./ranked/RankedUnfiltered";
@@ -0,0 +1,11 @@
1
+ import { FilterCombinations } from "../../../enums/FilterCombinations";
2
+ import { SortingOptions } from "../../../enums/SortingOptions";
3
+ import { SingleValueSelectedForFilterRule } from "../../../common/rules/SingleValueSelectedForFilterRule";
4
+ import { OrganisationsRuleBasedIndexabilityPolicy } from "../../../organisations/OrganisationsRuleBasedIndexabilityPolicy";
5
+ import { OnlyFiltersSelectedRule } from "../../../common/rules/OnlyFiltersSelectedRule";
6
+ export declare class Area extends OrganisationsRuleBasedIndexabilityPolicy {
7
+ protected readonly sortingOption = SortingOptions.OUR_PICKS;
8
+ protected readonly rules: (SingleValueSelectedForFilterRule | OnlyFiltersSelectedRule)[];
9
+ protected generateUrls(): Promise<string[]>;
10
+ get filterCombination(): FilterCombinations;
11
+ }
@@ -0,0 +1,20 @@
1
+ import { FilterCombinations } from "../../../enums/FilterCombinations";
2
+ import { FilterKey } from "@studyportals/search-filters";
3
+ import { SortingOptions } from "../../../enums/SortingOptions";
4
+ import { SingleValueSelectedForFilterRule } from "../../../common/rules/SingleValueSelectedForFilterRule";
5
+ import { OrganisationsRuleBasedIndexabilityPolicy } from "../../../organisations/OrganisationsRuleBasedIndexabilityPolicy";
6
+ import { OnlyFiltersSelectedRule } from "../../../common/rules/OnlyFiltersSelectedRule";
7
+ export class Area extends OrganisationsRuleBasedIndexabilityPolicy {
8
+ sortingOption = SortingOptions.OUR_PICKS;
9
+ rules = [
10
+ new SingleValueSelectedForFilterRule(FilterKey.AREA),
11
+ new SingleValueSelectedForFilterRule(FilterKey.COUNTRY),
12
+ new OnlyFiltersSelectedRule([FilterKey.AREA, FilterKey.COUNTRY])
13
+ ];
14
+ async generateUrls() {
15
+ return [];
16
+ }
17
+ get filterCombination() {
18
+ return FilterCombinations.AREA;
19
+ }
20
+ }
@@ -0,0 +1,13 @@
1
+ import { OrganisationsRuleBasedIndexabilityPolicy } from "../../../organisations/OrganisationsRuleBasedIndexabilityPolicy";
2
+ import { FilterCombinations } from "../../../enums/FilterCombinations";
3
+ import { SearchVolumeAreasAttendanceRule } from "../../../organisations/rules/SearchVolumeAreasAttendanceRule";
4
+ import { SortingOptions } from "../../../enums/SortingOptions";
5
+ import { SingleValueSelectedForFilterRule } from "../../../common/rules/SingleValueSelectedForFilterRule";
6
+ import { OnlyFiltersSelectedRule } from "../../../common/rules/OnlyFiltersSelectedRule";
7
+ import { OnlineAttendanceRule } from "../../../organisations/rules/OnlineAttendanceRule";
8
+ export declare class AreaAttendance extends OrganisationsRuleBasedIndexabilityPolicy {
9
+ protected readonly sortingOption = SortingOptions.OUR_PICKS;
10
+ protected readonly rules: (SingleValueSelectedForFilterRule | OnlyFiltersSelectedRule | SearchVolumeAreasAttendanceRule | OnlineAttendanceRule)[];
11
+ protected generateUrls(): Promise<string[]>;
12
+ get filterCombination(): FilterCombinations;
13
+ }
@@ -0,0 +1,25 @@
1
+ import { OrganisationsRuleBasedIndexabilityPolicy } from "../../../organisations/OrganisationsRuleBasedIndexabilityPolicy";
2
+ import { FilterCombinations } from "../../../enums/FilterCombinations";
3
+ import { FilterKey } from "@studyportals/search-filters";
4
+ import { SearchVolumeAreasAttendanceRule } from "../../../organisations/rules/SearchVolumeAreasAttendanceRule";
5
+ import { SortingOptions } from "../../../enums/SortingOptions";
6
+ import { SingleValueSelectedForFilterRule } from "../../../common/rules/SingleValueSelectedForFilterRule";
7
+ import { OnlyFiltersSelectedRule } from "../../../common/rules/OnlyFiltersSelectedRule";
8
+ import { OnlineAttendanceRule } from "../../../organisations/rules/OnlineAttendanceRule";
9
+ export class AreaAttendance extends OrganisationsRuleBasedIndexabilityPolicy {
10
+ sortingOption = SortingOptions.OUR_PICKS;
11
+ rules = [
12
+ new SingleValueSelectedForFilterRule(FilterKey.AREA),
13
+ new SingleValueSelectedForFilterRule(FilterKey.COUNTRY),
14
+ new SingleValueSelectedForFilterRule(FilterKey.DELIVERY_METHOD),
15
+ new OnlyFiltersSelectedRule([FilterKey.AREA, FilterKey.COUNTRY, FilterKey.DELIVERY_METHOD]),
16
+ new SearchVolumeAreasAttendanceRule(),
17
+ new OnlineAttendanceRule()
18
+ ];
19
+ async generateUrls() {
20
+ return [];
21
+ }
22
+ get filterCombination() {
23
+ return FilterCombinations.AREA_ATTENDANCE;
24
+ }
25
+ }