@studyportals/fawkes 8.2.4-9 → 8.3.1-0
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/dist/src/common/IPresenter.d.ts +1 -0
- package/dist/src/enums/FilterCombinations.d.ts +2 -1
- package/dist/src/enums/FilterCombinations.js +2 -1
- package/dist/src/organisations/policies/our-picks/CountryAreaCity.d.ts +2 -1
- package/dist/src/organisations/policies/our-picks/CountryAreaCity.js +26 -5
- package/dist/src/organisations/policies/our-picks/CountryCity.d.ts +2 -1
- package/dist/src/organisations/policies/our-picks/CountryCity.js +6 -3
- package/dist/src/organisations/policies/ranked/RankedCountryAreaCity.d.ts +11 -0
- package/dist/src/organisations/policies/ranked/RankedCountryAreaCity.js +42 -0
- package/dist/src/organisations/policies/ranked/RankedCountryCity.d.ts +11 -0
- package/dist/src/organisations/policies/ranked/RankedCountryCity.js +36 -0
- package/dist/src/organisations/rules/ExcludeByIdForCitiesRule.d.ts +13 -0
- package/dist/src/organisations/rules/ExcludeByIdForCitiesRule.js +31 -0
- package/dist/src/presenters/CityPresenter.d.ts +1 -0
- package/dist/src/presenters/CityPresenter.js +16 -25
- package/dist/src/presenters/fragments/ICityFragment.d.ts +1 -1
- package/dist/src/sitemap-generator/ICity.d.ts +7 -0
- package/dist/src/sitemap-generator/ICity.js +1 -0
- package/package.json +1 -1
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export declare enum FilterCombinations {
|
|
2
|
-
CITY = "city",
|
|
3
2
|
AREA = "area",
|
|
4
3
|
AREA_ATTENDANCE = "areaAttendance",
|
|
5
4
|
AREA_DISCIPLINE = "areaDiscipline",
|
|
6
5
|
COUNTRY = "country",
|
|
6
|
+
COUNTRY_CITY = "countryCity",
|
|
7
|
+
COUNTRY_AREA_CITY = "countryAreaCity",
|
|
7
8
|
DEGREE = "degree",
|
|
8
9
|
DURATION = "duration",
|
|
9
10
|
FORMAT = "format",
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export var FilterCombinations;
|
|
2
2
|
(function (FilterCombinations) {
|
|
3
|
-
FilterCombinations["CITY"] = "city";
|
|
4
3
|
FilterCombinations["AREA"] = "area";
|
|
5
4
|
FilterCombinations["AREA_ATTENDANCE"] = "areaAttendance";
|
|
6
5
|
FilterCombinations["AREA_DISCIPLINE"] = "areaDiscipline";
|
|
7
6
|
FilterCombinations["COUNTRY"] = "country";
|
|
7
|
+
FilterCombinations["COUNTRY_CITY"] = "countryCity";
|
|
8
|
+
FilterCombinations["COUNTRY_AREA_CITY"] = "countryAreaCity";
|
|
8
9
|
FilterCombinations["DEGREE"] = "degree";
|
|
9
10
|
FilterCombinations["DURATION"] = "duration";
|
|
10
11
|
FilterCombinations["FORMAT"] = "format";
|
|
@@ -3,11 +3,12 @@ import { SortingOptions } from '../../../enums/SortingOptions';
|
|
|
3
3
|
import { OrganisationsSeoIndexabilityPolicy } from '../../../organisations/policies/OrganisationsSeoIndexabilityPolicy';
|
|
4
4
|
import { SingleValueSelectedForFilterRule } from '../../../common/rules/SingleValueSelectedForFilterRule';
|
|
5
5
|
import { OnlyFiltersSelectedRule } from '../../../common/rules/OnlyFiltersSelectedRule';
|
|
6
|
+
import { ExcludeByIdForCitiesRule } from '../../../organisations/rules/ExcludeByIdForCitiesRule';
|
|
6
7
|
export declare class CountryAreaCity extends OrganisationsSeoIndexabilityPolicy {
|
|
7
8
|
readonly name: string;
|
|
8
9
|
readonly description: string;
|
|
9
10
|
protected readonly sortingOption = SortingOptions.OUR_PICKS;
|
|
10
|
-
protected readonly baseRules: (SingleValueSelectedForFilterRule | OnlyFiltersSelectedRule)[];
|
|
11
|
+
protected readonly baseRules: (SingleValueSelectedForFilterRule | OnlyFiltersSelectedRule | ExcludeByIdForCitiesRule)[];
|
|
11
12
|
protected generateUrls(): Promise<string[]>;
|
|
12
13
|
get filterCombination(): FilterCombinations;
|
|
13
14
|
}
|
|
@@ -4,6 +4,8 @@ import { SortingOptions } from '../../../enums/SortingOptions';
|
|
|
4
4
|
import { OrganisationsSeoIndexabilityPolicy } from '../../../organisations/policies/OrganisationsSeoIndexabilityPolicy';
|
|
5
5
|
import { SingleValueSelectedForFilterRule } from '../../../common/rules/SingleValueSelectedForFilterRule';
|
|
6
6
|
import { OnlyFiltersSelectedRule } from '../../../common/rules/OnlyFiltersSelectedRule';
|
|
7
|
+
import { CityPresenter } from '../../../presenters/CityPresenter';
|
|
8
|
+
import { ExcludeByIdForCitiesRule } from '../../../organisations/rules/ExcludeByIdForCitiesRule';
|
|
7
9
|
export class CountryAreaCity extends OrganisationsSeoIndexabilityPolicy {
|
|
8
10
|
name = 'Country Area City Policy';
|
|
9
11
|
description = 'Controls indexing of pages filtered by geographic cities and areas, ensuring only SEO-valuable regional content with sufficient search volume is indexed.';
|
|
@@ -12,14 +14,33 @@ export class CountryAreaCity extends OrganisationsSeoIndexabilityPolicy {
|
|
|
12
14
|
new SingleValueSelectedForFilterRule(FilterKey.CITY),
|
|
13
15
|
new SingleValueSelectedForFilterRule(FilterKey.COUNTRY),
|
|
14
16
|
new SingleValueSelectedForFilterRule(FilterKey.AREA),
|
|
15
|
-
new OnlyFiltersSelectedRule([FilterKey.CITY, FilterKey.COUNTRY, FilterKey.AREA])
|
|
17
|
+
new OnlyFiltersSelectedRule([FilterKey.CITY, FilterKey.COUNTRY, FilterKey.AREA]),
|
|
18
|
+
new ExcludeByIdForCitiesRule(FilterKey.CITY)
|
|
16
19
|
];
|
|
17
20
|
async generateUrls() {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
const cityFragments = await CityPresenter
|
|
22
|
+
.getInstance(this.dependencies.searchApiClient)
|
|
23
|
+
.getFragments();
|
|
24
|
+
const paths = [];
|
|
25
|
+
const filteredFragmentsForCountryAreaCity = cityFragments.filter(city => city.areaId !== null && city.areaId !== undefined);
|
|
26
|
+
for (const city of filteredFragmentsForCountryAreaCity) {
|
|
27
|
+
const areaId = city.areaId?.toString() || '';
|
|
28
|
+
if (areaId === '') {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
const filterKeyValues = new Map([
|
|
32
|
+
[FilterKey.CITY, [city.id]],
|
|
33
|
+
[FilterKey.AREA, [areaId]],
|
|
34
|
+
[FilterKey.COUNTRY, [city.countryId]]
|
|
35
|
+
]);
|
|
36
|
+
const result = await this.checkRulesForSitemap(filterKeyValues);
|
|
37
|
+
if (result) {
|
|
38
|
+
paths.push(this.getPathWithSortingOption(city.path));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return paths;
|
|
21
42
|
}
|
|
22
43
|
get filterCombination() {
|
|
23
|
-
return FilterCombinations.
|
|
44
|
+
return FilterCombinations.COUNTRY_AREA_CITY;
|
|
24
45
|
}
|
|
25
46
|
}
|
|
@@ -3,11 +3,12 @@ import { SortingOptions } from '../../../enums/SortingOptions';
|
|
|
3
3
|
import { OrganisationsSeoIndexabilityPolicy } from '../../../organisations/policies/OrganisationsSeoIndexabilityPolicy';
|
|
4
4
|
import { SingleValueSelectedForFilterRule } from '../../../common/rules/SingleValueSelectedForFilterRule';
|
|
5
5
|
import { OnlyFiltersSelectedRule } from '../../../common/rules/OnlyFiltersSelectedRule';
|
|
6
|
+
import { ExcludeByIdForCitiesRule } from '../../../organisations/rules/ExcludeByIdForCitiesRule';
|
|
6
7
|
export declare class CountryCity extends OrganisationsSeoIndexabilityPolicy {
|
|
7
8
|
readonly name: string;
|
|
8
9
|
readonly description: string;
|
|
9
10
|
protected readonly sortingOption = SortingOptions.OUR_PICKS;
|
|
10
|
-
protected readonly baseRules: (SingleValueSelectedForFilterRule | OnlyFiltersSelectedRule)[];
|
|
11
|
+
protected readonly baseRules: (SingleValueSelectedForFilterRule | OnlyFiltersSelectedRule | ExcludeByIdForCitiesRule)[];
|
|
11
12
|
protected generateUrls(): Promise<string[]>;
|
|
12
13
|
get filterCombination(): FilterCombinations;
|
|
13
14
|
}
|
|
@@ -5,6 +5,7 @@ import { OrganisationsSeoIndexabilityPolicy } from '../../../organisations/polic
|
|
|
5
5
|
import { CityPresenter } from '../../../presenters/CityPresenter';
|
|
6
6
|
import { SingleValueSelectedForFilterRule } from '../../../common/rules/SingleValueSelectedForFilterRule';
|
|
7
7
|
import { OnlyFiltersSelectedRule } from '../../../common/rules/OnlyFiltersSelectedRule';
|
|
8
|
+
import { ExcludeByIdForCitiesRule } from '../../../organisations/rules/ExcludeByIdForCitiesRule';
|
|
8
9
|
export class CountryCity extends OrganisationsSeoIndexabilityPolicy {
|
|
9
10
|
name = 'Country City Policy';
|
|
10
11
|
description = 'Controls indexing of pages filtered by geographic cities, ensuring only SEO-valuable regional content with sufficient search volume is indexed.';
|
|
@@ -12,14 +13,16 @@ export class CountryCity extends OrganisationsSeoIndexabilityPolicy {
|
|
|
12
13
|
baseRules = [
|
|
13
14
|
new SingleValueSelectedForFilterRule(FilterKey.CITY),
|
|
14
15
|
new SingleValueSelectedForFilterRule(FilterKey.COUNTRY),
|
|
15
|
-
new OnlyFiltersSelectedRule([FilterKey.CITY, FilterKey.COUNTRY])
|
|
16
|
+
new OnlyFiltersSelectedRule([FilterKey.CITY, FilterKey.COUNTRY]),
|
|
17
|
+
new ExcludeByIdForCitiesRule(FilterKey.CITY)
|
|
16
18
|
];
|
|
17
19
|
async generateUrls() {
|
|
18
20
|
const cityFragments = await CityPresenter
|
|
19
21
|
.getInstance(this.dependencies.searchApiClient)
|
|
20
22
|
.getFragments();
|
|
21
23
|
const paths = [];
|
|
22
|
-
|
|
24
|
+
const filteredFragmentsForCountryCity = cityFragments.filter(city => city.areaId === null || city.areaId === undefined);
|
|
25
|
+
for (const city of filteredFragmentsForCountryCity) {
|
|
23
26
|
const filterKeyValues = new Map([
|
|
24
27
|
[FilterKey.CITY, [city.id]],
|
|
25
28
|
[FilterKey.COUNTRY, [city.countryId]]
|
|
@@ -32,6 +35,6 @@ export class CountryCity extends OrganisationsSeoIndexabilityPolicy {
|
|
|
32
35
|
return paths;
|
|
33
36
|
}
|
|
34
37
|
get filterCombination() {
|
|
35
|
-
return FilterCombinations.
|
|
38
|
+
return FilterCombinations.COUNTRY_CITY;
|
|
36
39
|
}
|
|
37
40
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { OnlyFiltersSelectedRule } from "../../../common/rules/OnlyFiltersSelectedRule";
|
|
2
|
+
import { SingleValueSelectedForFilterRule } from "../../../common/rules/SingleValueSelectedForFilterRule";
|
|
3
|
+
import { RankedOrganisationsSeoIndexabilityPolicy } from "../RankedOrganisationsSeoIndexabilityPolicy";
|
|
4
|
+
import { FilterCombinations } from '../../../enums/FilterCombinations';
|
|
5
|
+
export declare class RankedCountryAreaCity extends RankedOrganisationsSeoIndexabilityPolicy {
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly description: string;
|
|
8
|
+
protected readonly baseRules: (SingleValueSelectedForFilterRule | OnlyFiltersSelectedRule)[];
|
|
9
|
+
protected generateUrls(): Promise<string[]>;
|
|
10
|
+
get filterCombination(): FilterCombinations;
|
|
11
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { OnlyFiltersSelectedRule } from "../../../common/rules/OnlyFiltersSelectedRule";
|
|
2
|
+
import { SingleValueSelectedForFilterRule } from "../../../common/rules/SingleValueSelectedForFilterRule";
|
|
3
|
+
import { FilterKey } from "@studyportals/search-filters/server-side";
|
|
4
|
+
import { RankedOrganisationsSeoIndexabilityPolicy } from "../RankedOrganisationsSeoIndexabilityPolicy";
|
|
5
|
+
import { FilterCombinations } from '../../../enums/FilterCombinations';
|
|
6
|
+
import { CityPresenter } from "../../../presenters/CityPresenter";
|
|
7
|
+
export class RankedCountryAreaCity extends RankedOrganisationsSeoIndexabilityPolicy {
|
|
8
|
+
name = 'Ranked Country Area City Policy';
|
|
9
|
+
description = 'Manages indexability of ranking-sorted country and area-specific city pages, applying rules to prioritize regions where quality-based sorting adds search value.';
|
|
10
|
+
baseRules = [
|
|
11
|
+
new SingleValueSelectedForFilterRule(FilterKey.CITY),
|
|
12
|
+
new SingleValueSelectedForFilterRule(FilterKey.COUNTRY),
|
|
13
|
+
new OnlyFiltersSelectedRule([FilterKey.CITY, FilterKey.COUNTRY])
|
|
14
|
+
];
|
|
15
|
+
async generateUrls() {
|
|
16
|
+
const cityFragments = await CityPresenter
|
|
17
|
+
.getInstance(this.dependencies.searchApiClient)
|
|
18
|
+
.getFragmentsAsync();
|
|
19
|
+
const paths = [];
|
|
20
|
+
console.warn(`Total city fragments fetched: ${cityFragments.length}`);
|
|
21
|
+
const filteredFragmentsForCountryAreaCity = cityFragments.filter(city => city.areaId !== null && city.areaId !== undefined);
|
|
22
|
+
for (const city of filteredFragmentsForCountryAreaCity) {
|
|
23
|
+
const areaId = city.areaId?.toString() || '';
|
|
24
|
+
if (areaId === '') {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
const filterKeyValues = new Map([
|
|
28
|
+
[FilterKey.CITY, [city.id]],
|
|
29
|
+
[FilterKey.AREA, [areaId]],
|
|
30
|
+
[FilterKey.COUNTRY, [city.countryId]]
|
|
31
|
+
]);
|
|
32
|
+
const result = await this.checkRulesForSitemap(filterKeyValues);
|
|
33
|
+
if (result) {
|
|
34
|
+
paths.push(this.getPathWithSortingOption(city.path));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return paths;
|
|
38
|
+
}
|
|
39
|
+
get filterCombination() {
|
|
40
|
+
return FilterCombinations.RANKED_COUNTRY_AREA_CITY;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { OnlyFiltersSelectedRule } from "../../../common/rules/OnlyFiltersSelectedRule";
|
|
2
|
+
import { SingleValueSelectedForFilterRule } from "../../../common/rules/SingleValueSelectedForFilterRule";
|
|
3
|
+
import { RankedOrganisationsSeoIndexabilityPolicy } from "../RankedOrganisationsSeoIndexabilityPolicy";
|
|
4
|
+
import { FilterCombinations } from '../../../enums/FilterCombinations';
|
|
5
|
+
export declare class RankedCountryCity extends RankedOrganisationsSeoIndexabilityPolicy {
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly description: string;
|
|
8
|
+
protected readonly baseRules: (SingleValueSelectedForFilterRule | OnlyFiltersSelectedRule)[];
|
|
9
|
+
protected generateUrls(): Promise<string[]>;
|
|
10
|
+
get filterCombination(): FilterCombinations;
|
|
11
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { OnlyFiltersSelectedRule } from "../../../common/rules/OnlyFiltersSelectedRule";
|
|
2
|
+
import { SingleValueSelectedForFilterRule } from "../../../common/rules/SingleValueSelectedForFilterRule";
|
|
3
|
+
import { FilterKey } from "@studyportals/search-filters/server-side";
|
|
4
|
+
import { RankedOrganisationsSeoIndexabilityPolicy } from "../RankedOrganisationsSeoIndexabilityPolicy";
|
|
5
|
+
import { FilterCombinations } from '../../../enums/FilterCombinations';
|
|
6
|
+
import { CityPresenter } from "../../../presenters/CityPresenter";
|
|
7
|
+
export class RankedCountryCity extends RankedOrganisationsSeoIndexabilityPolicy {
|
|
8
|
+
name = 'Ranked Country City Policy';
|
|
9
|
+
description = 'Manages indexability of ranking-sorted country and city-specific pages, applying rules to prioritize regions where quality-based sorting adds search value.';
|
|
10
|
+
baseRules = [
|
|
11
|
+
new SingleValueSelectedForFilterRule(FilterKey.CITY),
|
|
12
|
+
new SingleValueSelectedForFilterRule(FilterKey.COUNTRY),
|
|
13
|
+
new OnlyFiltersSelectedRule([FilterKey.CITY, FilterKey.COUNTRY])
|
|
14
|
+
];
|
|
15
|
+
async generateUrls() {
|
|
16
|
+
const cityFragments = await CityPresenter
|
|
17
|
+
.getInstance(this.dependencies.searchApiClient)
|
|
18
|
+
.getFragmentsAsync();
|
|
19
|
+
const paths = [];
|
|
20
|
+
const filteredFragmentsForCountryCity = cityFragments.filter(city => city.areaId === null || city.areaId === undefined);
|
|
21
|
+
for (const city of filteredFragmentsForCountryCity) {
|
|
22
|
+
const filterKeyValues = new Map([
|
|
23
|
+
[FilterKey.CITY, [city.id]],
|
|
24
|
+
[FilterKey.COUNTRY, [city.countryId]]
|
|
25
|
+
]);
|
|
26
|
+
const result = await this.checkRulesForSitemap(filterKeyValues);
|
|
27
|
+
if (result) {
|
|
28
|
+
paths.push(this.getPathWithSortingOption(city.path));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return paths;
|
|
32
|
+
}
|
|
33
|
+
get filterCombination() {
|
|
34
|
+
return FilterCombinations.RANKED_COUNTRY_CITY;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IRule } from "../../common/IRule";
|
|
2
|
+
import { ISearchDependencies } from "../../common/ISearchDependencies";
|
|
3
|
+
import { FilterKey } from "@studyportals/search-filters/server-side";
|
|
4
|
+
import { FilterKeyValuesMap } from "../../../sitemap-generator-seo";
|
|
5
|
+
export declare class ExcludeByIdForCitiesRule implements IRule {
|
|
6
|
+
private readonly filterKey;
|
|
7
|
+
private excludedIds;
|
|
8
|
+
constructor(filterKey: FilterKey);
|
|
9
|
+
forSearch(dependencies: ISearchDependencies): Promise<boolean>;
|
|
10
|
+
forSitemapGenerator(filterKeyValues: FilterKeyValuesMap): Promise<boolean>;
|
|
11
|
+
getName(): string;
|
|
12
|
+
getDescription(): string;
|
|
13
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { FilterKey } from "@studyportals/search-filters/server-side";
|
|
2
|
+
export class ExcludeByIdForCitiesRule {
|
|
3
|
+
filterKey;
|
|
4
|
+
excludedIds;
|
|
5
|
+
constructor(filterKey) {
|
|
6
|
+
this.filterKey = filterKey;
|
|
7
|
+
// Exclude city with ID 532 (Washington D.C.)
|
|
8
|
+
this.excludedIds = ['532'];
|
|
9
|
+
}
|
|
10
|
+
async forSearch(dependencies) {
|
|
11
|
+
const selectedCities = dependencies.seoInfoBase.getFilterOptionValueBy(this.filterKey, dependencies.filterState);
|
|
12
|
+
if (!selectedCities || selectedCities.trim() === '') {
|
|
13
|
+
return Promise.resolve(false);
|
|
14
|
+
}
|
|
15
|
+
return Promise.resolve(!this.excludedIds.includes(selectedCities));
|
|
16
|
+
}
|
|
17
|
+
async forSitemapGenerator(filterKeyValues) {
|
|
18
|
+
const cities = filterKeyValues.get(FilterKey.CITY);
|
|
19
|
+
if (cities && cities.length > 0) {
|
|
20
|
+
const filteredCities = cities.filter(city => !this.excludedIds.includes(city));
|
|
21
|
+
return Promise.resolve(filteredCities.length > 0);
|
|
22
|
+
}
|
|
23
|
+
return Promise.resolve(true);
|
|
24
|
+
}
|
|
25
|
+
getName() {
|
|
26
|
+
return 'ExcludeByIdForCitiesRule';
|
|
27
|
+
}
|
|
28
|
+
getDescription() {
|
|
29
|
+
return `This rule excludes specific city IDs from the search results. (${this.excludedIds.join(", ")})`;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -28,31 +28,8 @@ export class CityPresenter {
|
|
|
28
28
|
console.error('searchApiClient.getCities is not found');
|
|
29
29
|
throw new Error('searchApiClient.getCities is not found');
|
|
30
30
|
}
|
|
31
|
-
const
|
|
32
|
-
const cityFragments =
|
|
33
|
-
const country = countriesExtendedAll.find(item => item.iso?.toLowerCase() === city.countryIsoCode?.toLowerCase());
|
|
34
|
-
let cityPath = ``;
|
|
35
|
-
const countryPath = countryGetIsoCodePath(country?.iso || '');
|
|
36
|
-
if (city.areaId === null || city.areaId === undefined) {
|
|
37
|
-
cityPath += `${countryPath}/`;
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
const area = areaGetPath(city.areaId?.toString() || '');
|
|
41
|
-
if (area && area !== '') {
|
|
42
|
-
cityPath += `${area}/`;
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
cityPath += `${countryPath}/`;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
cityPath += `${city.virtualPath}`;
|
|
49
|
-
return {
|
|
50
|
-
id: city.id.toString(),
|
|
51
|
-
path: cityPath,
|
|
52
|
-
areaId: city.areaId?.toString(),
|
|
53
|
-
countryId: country ? country.id.toString() : '',
|
|
54
|
-
};
|
|
55
|
-
});
|
|
31
|
+
const cities = await this.searchApiClient.getCities();
|
|
32
|
+
const cityFragments = cities.map(city => this.processCity(city));
|
|
56
33
|
return cityFragments;
|
|
57
34
|
}
|
|
58
35
|
catch (error) {
|
|
@@ -60,4 +37,18 @@ export class CityPresenter {
|
|
|
60
37
|
throw error;
|
|
61
38
|
}
|
|
62
39
|
}
|
|
40
|
+
processCity(city) {
|
|
41
|
+
const country = countriesExtendedAll.find(item => item.iso?.toLowerCase() === city.countryIsoCode?.toLowerCase());
|
|
42
|
+
const countryPath = countryGetIsoCodePath(country?.iso || '');
|
|
43
|
+
const areaPath = city.areaId != null ? areaGetPath(city.areaId.toString()) : '';
|
|
44
|
+
const useAreaPath = areaPath && areaPath.trim() !== '';
|
|
45
|
+
// AreaPath do also includes country, for that reason, we do not need to add countryPath if area exists
|
|
46
|
+
const cityPath = `${useAreaPath ? areaPath : countryPath}/${city.virtualPath}`;
|
|
47
|
+
return {
|
|
48
|
+
id: city.id.toString(),
|
|
49
|
+
path: cityPath,
|
|
50
|
+
areaId: useAreaPath ? city.areaId?.toString() : null,
|
|
51
|
+
countryId: country ? country.id.toString() : '',
|
|
52
|
+
};
|
|
53
|
+
}
|
|
63
54
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|