@studyportals/fawkes 6.0.1-2 → 6.0.1-5

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.
@@ -0,0 +1,6 @@
1
+ import { IRule } from "./IRule";
2
+ export interface IPolicyMetaData {
3
+ getAllRules(): IRule[];
4
+ getName(): string;
5
+ getDescription(): string;
6
+ }
@@ -17,7 +17,7 @@ export declare abstract class BaseSeoIndexabilityPolicy<TDependencies extends ID
17
17
  generateSitemapUrls(): Promise<string[]>;
18
18
  protected isIndexable(): Promise<boolean>;
19
19
  protected checkRulesForSearch(dependencies: ISearchDependencies): Promise<boolean>;
20
- protected checkRulesForSitemap(filterKeyValues: FilterKeyValuesMap): Promise<boolean>;
20
+ checkRulesForSitemap(filterKeyValues: FilterKeyValuesMap): Promise<boolean>;
21
21
  protected isIndexabilityPolicyDependencies(): boolean;
22
22
  protected isSitemapUrlGeneratorDependencies(): boolean;
23
23
  getAllRules(): IRule[];
@@ -0,0 +1,11 @@
1
+ import { PortalType } from '@studyportals/domain-client';
2
+ import { IOrganisationsSeoDependencies } from './types/IOrganisationsSeoDependencies';
3
+ import { SortingOptions } from '../enums/SortingOptions';
4
+ import { BaseSeoIndexabilityPolicy } from '../common/policies/BaseSeoIndexabilityPolicy';
5
+ export declare abstract class OrganisationsRuleBasedIndexabilityPolicy extends BaseSeoIndexabilityPolicy<IOrganisationsSeoDependencies> {
6
+ protected readonly indexablePortalTypes: PortalType[];
7
+ protected abstract readonly sortingOption: SortingOptions;
8
+ constructor(dependencies: IOrganisationsSeoDependencies);
9
+ protected isIndexable(): Promise<boolean>;
10
+ private matchesSortingOption;
11
+ }
@@ -0,0 +1,19 @@
1
+ import { PortalType } from '@studyportals/domain-client';
2
+ import { BaseSeoIndexabilityPolicy } from '../common/policies/BaseSeoIndexabilityPolicy';
3
+ export class OrganisationsRuleBasedIndexabilityPolicy extends BaseSeoIndexabilityPolicy {
4
+ indexablePortalTypes = [PortalType.MASTER];
5
+ constructor(dependencies) {
6
+ super(dependencies);
7
+ }
8
+ async isIndexable() {
9
+ const isIndexable = await super.isIndexable();
10
+ if (!isIndexable) {
11
+ return false;
12
+ }
13
+ return this.indexablePortalTypes.includes(this.dependencies.portalType) && this.matchesSortingOption();
14
+ }
15
+ matchesSortingOption() {
16
+ const dependencies = this.dependencies;
17
+ return dependencies.sortingState.getSelectedOption() === this.sortingOption;
18
+ }
19
+ }
@@ -2,4 +2,5 @@ import { BaseFilterKeyValueRule } from '../../common/rules/BaseFilterKeyValueRul
2
2
  export declare class OnlineAttendanceRule extends BaseFilterKeyValueRule {
3
3
  constructor();
4
4
  getName(): string;
5
+ getDescription(): string;
5
6
  }
@@ -8,4 +8,7 @@ export class OnlineAttendanceRule extends BaseFilterKeyValueRule {
8
8
  getName() {
9
9
  return 'OnlineAttendanceRule';
10
10
  }
11
+ getDescription() {
12
+ return 'Indexable if attendance is online';
13
+ }
11
14
  }
@@ -0,0 +1,4 @@
1
+ import { ISearchApplicationState } from '../common';
2
+ export interface IProgrammeSearchApplicationState extends ISearchApplicationState {
3
+ getPageNumber(): number;
4
+ }
@@ -0,0 +1,7 @@
1
+ import { ISearchDependencies } from '../common/ISearchDependencies';
2
+ import { IProgrammeSearchApplicationState } from './IProgrammeSearchApplicationState';
3
+ import { PortalType } from '@studyportals/domain-client';
4
+ export interface IProgrammeSearchDependencies extends ISearchDependencies {
5
+ portalType: PortalType;
6
+ applicationState: IProgrammeSearchApplicationState;
7
+ }
@@ -0,0 +1,2 @@
1
+ import { IProgrammeSearchDependencies } from "./IProgrammeSearchDependencies";
2
+ export type IProgrammesSeoDependencies = IProgrammeSearchDependencies;
@@ -0,0 +1 @@
1
+ export {};
@@ -22,8 +22,7 @@ export class Area extends ProgrammesBaseIndexabilityPolicy {
22
22
  const paths = [];
23
23
  for (const area of areaFragments) {
24
24
  const filterKeyValues = new Map([
25
- [FilterKey.AREA, [area.id]],
26
- [FilterKey.COUNTRY, [area.countryId]]
25
+ [FilterKey.AREA, [area.id]]
27
26
  ]);
28
27
  const result = await this.checkRulesForSitemap(filterKeyValues);
29
28
  if (result) {
@@ -0,0 +1,5 @@
1
+ import { BaseFilterKeyValueRule } from '../../common/rules/BaseFilterKeyValueRule';
2
+ export declare class OnlineAttendanceRule extends BaseFilterKeyValueRule {
3
+ constructor();
4
+ getName(): string;
5
+ }
@@ -0,0 +1,11 @@
1
+ import { FilterKey } from '@studyportals/search-filters';
2
+ import { BaseFilterKeyValueRule } from '../../common/rules/BaseFilterKeyValueRule';
3
+ export class OnlineAttendanceRule extends BaseFilterKeyValueRule {
4
+ constructor() {
5
+ const filterKeyValues = new Map([[FilterKey.DELIVERY_METHOD, ['online']]]);
6
+ super(filterKeyValues);
7
+ }
8
+ getName() {
9
+ return 'OnlineAttendanceRule';
10
+ }
11
+ }
@@ -1,13 +1,13 @@
1
- import { ISitemapUrlGenerator } from '../common/ISitemapUrlGenerator';
2
1
  import { ISearchApiClient } from '../sitemap-generator/ISearchApiClient';
3
2
  import { BaseSitemapUrlGeneratorManager } from './BaseSitemapUrlGeneratorManager';
4
3
  import { PortalType } from '@studyportals/domain-client';
5
4
  import { IPageNumberProvider } from './IPageNumberProvider';
6
5
  import { FilterKey } from '@studyportals/search-filters';
7
6
  import { IPresenter } from '../common';
7
+ import { IProgrammeSitemapUrlGenerator } from '../programmes/types/IProgrammeSitemapUrlGenerator';
8
8
  export declare class ProgrammesSitemapUrlGeneratorManager extends BaseSitemapUrlGeneratorManager {
9
9
  readonly portalType: PortalType;
10
- readonly policies: ISitemapUrlGenerator[];
10
+ readonly policies: IProgrammeSitemapUrlGenerator[];
11
11
  readonly presenters: Map<FilterKey, IPresenter>;
12
12
  constructor(portalType: PortalType, searchApiClient: ISearchApiClient, pageNumberProvider: IPageNumberProvider);
13
13
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@studyportals/fawkes",
3
- "version": "6.0.1-2",
3
+ "version": "6.0.1-5",
4
4
  "description": "A package to centralize SEO related logic for SBLP and Sitemap Generator.",
5
5
  "files": [
6
6
  "./dist"
@@ -16,7 +16,7 @@
16
16
  "publish-beta": "npm run prepare-deployment && npm version prerelease && npm publish --tag beta --access=public",
17
17
  "prepare": "husky install",
18
18
  "test": "vitest run --coverage",
19
- "test:dev": "vitest --coverage",
19
+ "test:dev": "vitest --coverage tests/programmes",
20
20
  "lint": "eslint . --ext .ts",
21
21
  "lint:fix": "eslint . --ext .ts --fix",
22
22
  "prettier:fix": "npx prettier --use-tabs --ignore-path .gitignore --write ."
@@ -1,3 +0,0 @@
1
- export interface IRankingApiClient {
2
- getFacets(): Promise<string[]>;
3
- }
@@ -1,9 +0,0 @@
1
- import { ISitemapUrlGeneratorManager } from './ISitemapUrlGeneratorManager';
2
- import { FilterCombinations } from '../enums/FilterCombinations';
3
- import { IOrganisationsClient } from '../sitemap-generator/IOrganisationsClient';
4
- import { ISearchApiClient } from '../sitemap-generator/ISearchApiClient';
5
- export declare class SitemapUrlGeneratorManager implements ISitemapUrlGeneratorManager {
6
- private readonly policies;
7
- constructor(searchApiClient: ISearchApiClient, organisationsClient: IOrganisationsClient);
8
- generateUrls(): Promise<Map<FilterCombinations, string[]>>;
9
- }
@@ -1,34 +0,0 @@
1
- import { DependencyTypes } from '../enums/DependencyTypes';
2
- import { Area } from '../scholarships/policies/Area';
3
- import { Country } from '../scholarships/policies/Country';
4
- import { Discipline } from '../scholarships/policies/Discipline';
5
- import { DisciplineCountry } from '../scholarships/policies/DisciplineCountry';
6
- import { UniversityCountry } from '../scholarships/policies/UniversityCountry';
7
- import { Unfiltered } from '../scholarships/policies/Unfiltered';
8
- export class SitemapUrlGeneratorManager {
9
- policies;
10
- constructor(searchApiClient, organisationsClient) {
11
- const dependencies = {
12
- dependencyType: DependencyTypes.SITEMAP_GENERATOR,
13
- searchApiClient,
14
- organisationsClient
15
- };
16
- this.policies = [
17
- new Area(dependencies),
18
- new Country(dependencies),
19
- new DisciplineCountry(dependencies),
20
- new Discipline(dependencies),
21
- new UniversityCountry(dependencies),
22
- new Unfiltered(dependencies)
23
- ];
24
- }
25
- async generateUrls() {
26
- const map = new Map();
27
- await Promise.all(this.policies.map(async (policy) => {
28
- const filterCombination = policy.filterCombination;
29
- const urls = await policy.generateSitemapUrls();
30
- map.set(filterCombination, urls);
31
- }));
32
- return map;
33
- }
34
- }