diff --git a/apps/data-platform/src/app/dataviz/dataviz.model.ts b/apps/data-platform/src/app/dataviz/dataviz.model.ts index d58fc8e551..95593df559 100644 --- a/apps/data-platform/src/app/dataviz/dataviz.model.ts +++ b/apps/data-platform/src/app/dataviz/dataviz.model.ts @@ -1,3 +1,3 @@ -import { DatavizConfigurationModel } from '@geonetwork-ui/common/domain/dataviz-configuration.model' +import { DatavizConfigurationModel } from '@geonetwork-ui/common/domain/model/dataviz/dataviz-configuration.model' export type DatavizConfigModel = DatavizConfigurationModel diff --git a/apps/datahub/src/app/app.module.ts b/apps/datahub/src/app/app.module.ts index 6d7754b4b0..ec0746b964 100644 --- a/apps/datahub/src/app/app.module.ts +++ b/apps/datahub/src/app/app.module.ts @@ -73,7 +73,7 @@ import { provideRepositoryUrl, } from '@geonetwork-ui/api/repository' import { BrowserAnimationsModule } from '@angular/platform-browser/animations' -import { LOGIN_URL } from '@geonetwork-ui/api/repository/gn4' +import { LOGIN_URL, provideGn4 } from '@geonetwork-ui/api/repository/gn4' import { RecordRelatedRecordsComponent } from './record/record-related-records/record-related-records.component' import { RecordMetadataComponent } from './record/record-metadata/record-metadata.component' import { RecordOtherlinksComponent } from './record/record-otherlinks/record-otherlinks.component' @@ -148,6 +148,7 @@ export const metaReducers: MetaReducer[] = !environment.production ? [] : [] providers: [ importProvidersFrom(FeatureAuthModule), provideRepositoryUrl(() => getGlobalConfig().GN4_API_URL), + provideGn4(), { provide: RouterService, useClass: DatahubRouterService }, { provide: GN_UI_VERSION, useValue: environment.version }, { diff --git a/apps/datahub/src/app/home/home-header/home-header.component.spec.ts b/apps/datahub/src/app/home/home-header/home-header.component.spec.ts index e8dcde96ee..1d764bdd72 100644 --- a/apps/datahub/src/app/home/home-header/home-header.component.spec.ts +++ b/apps/datahub/src/app/home/home-header/home-header.component.spec.ts @@ -2,8 +2,8 @@ import { NO_ERRORS_SCHEMA } from '@angular/core' import { ComponentFixture, TestBed } from '@angular/core/testing' import { By } from '@angular/platform-browser' import { - RouterFacade, ROUTER_ROUTE_SEARCH, + RouterFacade, } from '@geonetwork-ui/feature/router' import { FieldsService, @@ -15,10 +15,10 @@ import { BehaviorSubject, firstValueFrom, of } from 'rxjs' import { ROUTER_ROUTE_NEWS } from '../../router/constants' import { HeaderBadgeButtonComponent } from '../header-badge-button/header-badge-button.component' import { HomeHeaderComponent } from './home-header.component' -import resetAllMocks = jest.resetAllMocks -import { SortByEnum } from '@geonetwork-ui/common/domain/search' -import { AuthService } from '@geonetwork-ui/api/repository/gn4' +import { SortByEnum } from '@geonetwork-ui/common/domain/model/search' import { _setLanguages } from '@geonetwork-ui/util/app-config' +import { PlatformServiceInterface } from '@geonetwork-ui/common/domain/platform.service.interface' +import resetAllMocks = jest.resetAllMocks jest.mock('@geonetwork-ui/util/app-config', () => { let _languages = ['pt', 'de'] @@ -71,9 +71,9 @@ class searchServiceMock { setFilters = jest.fn() } -class AuthServiceMock { - authReady = jest.fn(() => this._authSubject$) - _authSubject$ = new BehaviorSubject({}) +class PlatformServiceMock { + isAnonymous = jest.fn(() => this._isAnonymous$) + _isAnonymous$ = new BehaviorSubject(true) } class FieldsServiceMock { @@ -83,10 +83,10 @@ class FieldsServiceMock { describe('HeaderComponent', () => { let component: HomeHeaderComponent let fixture: ComponentFixture - let authService: AuthService let searchService: SearchService let searchFacade: SearchFacade let routerFacade: RouterFacade + let platform: PlatformServiceInterface beforeEach(async () => { _setLanguages(['fr', 'de']) @@ -108,8 +108,8 @@ describe('HeaderComponent', () => { useClass: searchServiceMock, }, { - provide: AuthService, - useClass: AuthServiceMock, + provide: PlatformServiceInterface, + useClass: PlatformServiceMock, }, { provide: FieldsService, @@ -117,10 +117,10 @@ describe('HeaderComponent', () => { }, ], }).compileComponents() - authService = TestBed.inject(AuthService) searchService = TestBed.inject(SearchService) searchFacade = TestBed.inject(SearchFacade) routerFacade = TestBed.inject(RouterFacade) + platform = TestBed.inject(PlatformServiceInterface) }) beforeEach(() => { @@ -140,10 +140,7 @@ describe('HeaderComponent', () => { describe('isAuthenticated$', () => { describe('user is authenticated', () => { beforeEach(() => { - ;(authService as any)._authSubject$.next({ - id: 'user-id', - name: 'testuser', - }) + ;(platform as any)._isAnonymous$.next(false) }) it('displays favoriteBadge when authenticated', async () => { const isAuthenticated = await firstValueFrom( @@ -154,7 +151,7 @@ describe('HeaderComponent', () => { }) describe('user is NOT authenticated', () => { beforeEach(() => { - ;(authService as any)._authSubject$.next(null) + ;(platform as any)._isAnonymous$.next(true) }) it('does NOT display favoriteBadge when NOT authenticated', async () => { const isAuthenticated = await firstValueFrom( diff --git a/apps/datahub/src/app/home/home-header/home-header.component.ts b/apps/datahub/src/app/home/home-header/home-header.component.ts index 3de50bf71b..959596af08 100644 --- a/apps/datahub/src/app/home/home-header/home-header.component.ts +++ b/apps/datahub/src/app/home/home-header/home-header.component.ts @@ -1,8 +1,8 @@ import { ChangeDetectionStrategy, Component, Input } from '@angular/core' import { marker } from '@biesbjerg/ngx-translate-extract-marker' import { - RouterFacade, ROUTER_ROUTE_SEARCH, + RouterFacade, } from '@geonetwork-ui/feature/router' import { FieldsService, @@ -16,13 +16,16 @@ import { SearchConfig, SearchPreset, } from '@geonetwork-ui/util/app-config' -import { SortByEnum, SortByField } from '@geonetwork-ui/common/domain/search' +import { + SortByEnum, + SortByField, +} from '@geonetwork-ui/common/domain/model/search' import { map } from 'rxjs/operators' import { ROUTER_ROUTE_NEWS } from '../../router/constants' -import { firstValueFrom, lastValueFrom } from 'rxjs' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' +import { lastValueFrom } from 'rxjs' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' import { sortByFromString } from '@geonetwork-ui/util/shared' -import { AuthService } from '@geonetwork-ui/api/repository/gn4' +import { PlatformServiceInterface } from '@geonetwork-ui/common/domain/platform.service.interface' marker('datahub.header.myfavorites') marker('datahub.header.lastRecords') @@ -50,7 +53,7 @@ export class HomeHeaderComponent { public routerFacade: RouterFacade, public searchFacade: SearchFacade, private searchService: SearchService, - private authService: AuthService, + private platformService: PlatformServiceInterface, private fieldsService: FieldsService ) {} @@ -62,9 +65,9 @@ export class HomeHeaderComponent { ) ) - isAuthenticated$ = this.authService - .authReady() - .pipe(map((user) => !!user?.id)) + isAuthenticated$ = this.platformService + .isAnonymous() + .pipe(map((isAnonymous) => !isAnonymous)) onFuzzySearchSelection(record: CatalogRecord) { this.routerFacade.goToMetadata(record) diff --git a/apps/datahub/src/app/home/news-page/last-created/last-created.component.ts b/apps/datahub/src/app/home/news-page/last-created/last-created.component.ts index 40479410d1..e6d472d9c8 100644 --- a/apps/datahub/src/app/home/news-page/last-created/last-created.component.ts +++ b/apps/datahub/src/app/home/news-page/last-created/last-created.component.ts @@ -1,7 +1,7 @@ import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core' import { RouterFacade } from '@geonetwork-ui/feature/router' import { FIELDS_BRIEF, SearchFacade } from '@geonetwork-ui/feature/search' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' @Component({ selector: 'datahub-last-created', diff --git a/apps/datahub/src/app/home/organisations-page/organisations-page.component.ts b/apps/datahub/src/app/home/organisations-page/organisations-page.component.ts index c7bcfd0c16..3abb743666 100644 --- a/apps/datahub/src/app/home/organisations-page/organisations-page.component.ts +++ b/apps/datahub/src/app/home/organisations-page/organisations-page.component.ts @@ -1,7 +1,7 @@ import { ChangeDetectionStrategy, Component } from '@angular/core' import { SearchService } from '@geonetwork-ui/feature/search' import { OrganizationsServiceInterface } from '@geonetwork-ui/common/domain/organizations.service.interface' -import { Organization } from '@geonetwork-ui/common/domain/record' +import { Organization } from '@geonetwork-ui/common/domain/model/record' @Component({ selector: 'datahub-organisations-page', diff --git a/apps/datahub/src/app/home/search/search-filters/search-filters.component.spec.ts b/apps/datahub/src/app/home/search/search-filters/search-filters.component.spec.ts index 6256fa1dd1..95b4bc3bb7 100644 --- a/apps/datahub/src/app/home/search/search-filters/search-filters.component.spec.ts +++ b/apps/datahub/src/app/home/search/search-filters/search-filters.component.spec.ts @@ -19,9 +19,10 @@ import { SearchFiltersComponent } from './search-filters.component' import { TranslateModule } from '@ngx-translate/core' import { By } from '@angular/platform-browser' import { FormsModule } from '@angular/forms' -import { FieldFilters } from '@geonetwork-ui/common/domain/search' +import { FieldFilters } from '@geonetwork-ui/common/domain/model/search' import { USER_FIXTURE } from '@geonetwork-ui/common/fixtures' import { AuthService } from '@geonetwork-ui/api/repository/gn4' +import { PlatformServiceInterface } from '@geonetwork-ui/common/domain/platform.service.interface' jest.mock('@geonetwork-ui/util/app-config', () => ({ getOptionalSearchConfig: () => ({ @@ -103,10 +104,8 @@ class FieldsServiceMock { } } -class AuthServiceMock { - user$ = new BehaviorSubject(user) - authReady = jest.fn(() => this._authSubject$) - _authSubject$ = new BehaviorSubject({}) +class PlatformServiceMock { + getMe = jest.fn(() => new BehaviorSubject(user)) } describe('SearchFiltersComponent', () => { @@ -138,8 +137,8 @@ describe('SearchFiltersComponent', () => { useClass: FieldsServiceMock, }, { - provide: AuthService, - useClass: AuthServiceMock, + provide: PlatformServiceInterface, + useClass: PlatformServiceMock, }, ], }) diff --git a/apps/datahub/src/app/home/search/search-filters/search-filters.component.ts b/apps/datahub/src/app/home/search/search-filters/search-filters.component.ts index 49d1991ea8..508e335189 100644 --- a/apps/datahub/src/app/home/search/search-filters/search-filters.component.ts +++ b/apps/datahub/src/app/home/search/search-filters/search-filters.component.ts @@ -6,7 +6,6 @@ import { QueryList, ViewChildren, } from '@angular/core' -import { AuthService } from '@geonetwork-ui/api/repository/gn4' import { FieldsService, FilterDropdownComponent, @@ -16,6 +15,7 @@ import { import { getOptionalSearchConfig } from '@geonetwork-ui/util/app-config' import { Observable, switchMap } from 'rxjs' import { map } from 'rxjs/operators' +import { PlatformServiceInterface } from '@geonetwork-ui/common/domain/platform.service.interface' @Component({ selector: 'datahub-search-filters', @@ -46,11 +46,11 @@ export class SearchFiltersComponent implements OnInit { public searchFacade: SearchFacade, private searchService: SearchService, private fieldsService: FieldsService, - private authService: AuthService + private platformService: PlatformServiceInterface ) {} ngOnInit(): void { - this.authService.user$.subscribe((user) => (this.userId = user?.id)) + this.platformService.getMe().subscribe((user) => (this.userId = user?.id)) this.searchConfig = ( getOptionalSearchConfig().ADVANCED_FILTERS || [ 'publisher', diff --git a/apps/datahub/src/app/home/search/search-page/search-page.component.ts b/apps/datahub/src/app/home/search/search-page/search-page.component.ts index 24f77cbfd0..45fb3d014a 100644 --- a/apps/datahub/src/app/home/search/search-page/search-page.component.ts +++ b/apps/datahub/src/app/home/search/search-page/search-page.component.ts @@ -1,7 +1,7 @@ import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core' import { RouterFacade } from '@geonetwork-ui/feature/router' import { SearchFacade } from '@geonetwork-ui/feature/search' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' import { MetadataQualityDisplay } from '@geonetwork-ui/ui/elements' import { MetadataQualityConfig, diff --git a/apps/datahub/src/app/record/header-record/header-record.component.ts b/apps/datahub/src/app/record/header-record/header-record.component.ts index 2161552f84..248db72c3d 100644 --- a/apps/datahub/src/app/record/header-record/header-record.component.ts +++ b/apps/datahub/src/app/record/header-record/header-record.component.ts @@ -1,7 +1,7 @@ import { ChangeDetectionStrategy, Component, Input } from '@angular/core' import { SearchService } from '@geonetwork-ui/feature/search' import { getThemeConfig } from '@geonetwork-ui/util/app-config' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' @Component({ selector: 'datahub-header-record', diff --git a/apps/datahub/src/app/record/record-downloads/record-downloads.component.spec.ts b/apps/datahub/src/app/record/record-downloads/record-downloads.component.spec.ts index 5212cc1e04..866b597369 100644 --- a/apps/datahub/src/app/record/record-downloads/record-downloads.component.spec.ts +++ b/apps/datahub/src/app/record/record-downloads/record-downloads.component.spec.ts @@ -9,7 +9,7 @@ import { RecordDownloadsComponent } from './record-downloads.component' import { Component, Input, NO_ERRORS_SCHEMA } from '@angular/core' import { By } from '@angular/platform-browser' import { DataService } from '@geonetwork-ui/feature/dataviz' -import { DatasetDistribution } from '@geonetwork-ui/common/domain/record' +import { DatasetDistribution } from '@geonetwork-ui/common/domain/model/record' import { MdViewFacade } from '@geonetwork-ui/feature/record' // This is used to work around a very weird bug when comparing URL objects would fail diff --git a/apps/datahub/src/app/record/record-downloads/record-downloads.component.ts b/apps/datahub/src/app/record/record-downloads/record-downloads.component.ts index 2e4a2e708e..65f013ed6b 100644 --- a/apps/datahub/src/app/record/record-downloads/record-downloads.component.ts +++ b/apps/datahub/src/app/record/record-downloads/record-downloads.component.ts @@ -6,7 +6,7 @@ import { catchError, map, switchMap } from 'rxjs/operators' import { DatasetDistribution, DatasetServiceDistribution, -} from '@geonetwork-ui/common/domain/record' +} from '@geonetwork-ui/common/domain/model/record' import { MdViewFacade } from '@geonetwork-ui/feature/record' @Component({ diff --git a/apps/datahub/src/app/record/record-metadata/record-metadata.component.ts b/apps/datahub/src/app/record/record-metadata/record-metadata.component.ts index ed410fd33e..d34405d576 100644 --- a/apps/datahub/src/app/record/record-metadata/record-metadata.component.ts +++ b/apps/datahub/src/app/record/record-metadata/record-metadata.component.ts @@ -5,7 +5,7 @@ import { ErrorType, MetadataQualityDisplay } from '@geonetwork-ui/ui/elements' import { BehaviorSubject, combineLatest } from 'rxjs' import { filter, map, mergeMap } from 'rxjs/operators' import { OrganizationsServiceInterface } from '@geonetwork-ui/common/domain/organizations.service.interface' -import { Organization } from '@geonetwork-ui/common/domain/record' +import { Organization } from '@geonetwork-ui/common/domain/model/record' import { MdViewFacade } from '@geonetwork-ui/feature/record' @Component({ diff --git a/apps/datahub/src/app/record/record-related-records/record-related-records.component.ts b/apps/datahub/src/app/record/record-related-records/record-related-records.component.ts index 4706ff96a0..d82b51ff1f 100644 --- a/apps/datahub/src/app/record/record-related-records/record-related-records.component.ts +++ b/apps/datahub/src/app/record/record-related-records/record-related-records.component.ts @@ -1,5 +1,5 @@ import { ChangeDetectionStrategy, Component, Input } from '@angular/core' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' @Component({ selector: 'datahub-record-related-records', diff --git a/apps/metadata-converter/src/app/app.component.ts b/apps/metadata-converter/src/app/app.component.ts index a81a408b43..4895dcaab4 100644 --- a/apps/metadata-converter/src/app/app.component.ts +++ b/apps/metadata-converter/src/app/app.component.ts @@ -1,5 +1,5 @@ import { Component, ViewChild } from '@angular/core' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' import { StatusComponent } from './components/status/status.component' import { RecordOutputXmlComponent } from './components/record-output-xml/record-output-xml.component' import { RecordFormComponent } from './components/record-form/record-form.component' diff --git a/apps/metadata-converter/src/app/components/record-form/record-form.component.ts b/apps/metadata-converter/src/app/components/record-form/record-form.component.ts index 7d5d1bb93c..69dcad5fda 100644 --- a/apps/metadata-converter/src/app/components/record-form/record-form.component.ts +++ b/apps/metadata-converter/src/app/components/record-form/record-form.component.ts @@ -16,7 +16,7 @@ import { ServiceOnlineResource, ServiceOnlineResourceType, ServiceRecord, -} from '@geonetwork-ui/common/domain/record' +} from '@geonetwork-ui/common/domain/model/record' @Component({ selector: 'gn-ui-record-form', diff --git a/apps/metadata-converter/src/app/components/status/status.component.ts b/apps/metadata-converter/src/app/components/status/status.component.ts index edce2fe9b4..85a5309b45 100644 --- a/apps/metadata-converter/src/app/components/status/status.component.ts +++ b/apps/metadata-converter/src/app/components/status/status.component.ts @@ -1,6 +1,6 @@ import { Component, EventEmitter, Input, Output } from '@angular/core' import { toModel, toXml } from '@geonetwork-ui/api/metadata-converter' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' @Component({ selector: 'gn-ui-status', diff --git a/apps/metadata-editor/src/app/app.module.ts b/apps/metadata-editor/src/app/app.module.ts index dca34bf612..ebb9d99e7c 100644 --- a/apps/metadata-editor/src/app/app.module.ts +++ b/apps/metadata-editor/src/app/app.module.ts @@ -25,6 +25,7 @@ import { extModules } from './build-specifics' import { DashboardPageComponent } from './dashboard/dashboard-page.component' import { EditorRouterService } from './router.service' import { provideRepositoryUrl } from '@geonetwork-ui/api/repository' +import { provideGn4 } from '@geonetwork-ui/api/repository/gn4' @NgModule({ declarations: [AppComponent], @@ -58,6 +59,7 @@ import { provideRepositoryUrl } from '@geonetwork-ui/api/repository' importProvidersFrom(TranslateModule.forRoot(TRANSLATE_DEFAULT_CONFIG)), provideRepositoryUrl(() => getGlobalConfig().GN4_API_URL), importProvidersFrom(EffectsModule.forRoot()), + provideGn4(), ], bootstrap: [AppComponent], }) diff --git a/apps/metadata-editor/src/app/dashboard/search-header/search-header.component.html b/apps/metadata-editor/src/app/dashboard/search-header/search-header.component.html index f64b9b66e2..2326ec526b 100644 --- a/apps/metadata-editor/src/app/dashboard/search-header/search-header.component.html +++ b/apps/metadata-editor/src/app/dashboard/search-header/search-header.component.html @@ -16,7 +16,7 @@ - + this._authSubject$) - _authSubject$ = new BehaviorSubject({}) -} +import { PlatformServiceInterface } from '@geonetwork-ui/common/domain/platform.service.interface' +import { AvatarServiceInterface } from '@geonetwork-ui/api/repository/gn4' class AvatarServiceInterfaceMock { placeholder = 'http://placeholder.com' getProfileIcon = (hash: string) => `${hash}` } -class OrganisationsServiceMock { - organisationsCount$ = of(456) -} -class SearchFacadeMock { - init = jest.fn() - results$ = of(summaryHits) - setPagination = jest.fn(() => this) - setSortBy = jest.fn(() => this) - setConfigRequestFields = jest.fn(() => this) - setResultsLayout = jest.fn(() => this) - searchFilters$ = new BehaviorSubject(user) - authReady = jest.fn(() => this.searchFilters$) -} - -class searchServiceMock { - updateSearchFilters = jest.fn() - setSearch = jest.fn() - setSortBy = jest.fn() - setSortAndFilters = jest.fn() +const me$ = new BehaviorSubject(USER_FIXTURE()) +class PlatformServiceMock { + getMe = jest.fn(() => me$) } describe('SearchHeaderComponent', () => { @@ -63,28 +39,22 @@ describe('SearchHeaderComponent', () => { ], schemas: [NO_ERRORS_SCHEMA], providers: [ - provideRepositoryUrl('/geonetwork/srv/api'), - { provide: AuthService, useClass: AuthServiceMock }, { provide: AvatarServiceInterface, useClass: AvatarServiceInterfaceMock, }, { - provide: OrganizationsServiceInterface, - useClass: OrganisationsServiceMock, - }, - { - provide: SearchFacade, - useClass: SearchFacadeMock, - }, - { - provide: SearchService, - useClass: searchServiceMock, + provide: PlatformServiceInterface, + useClass: PlatformServiceMock, }, ], }) .overrideComponent(SearchHeaderComponent, { - set: { changeDetection: ChangeDetectionStrategy.Default }, + set: { + changeDetection: ChangeDetectionStrategy.Default, + imports: [], + schemas: [CUSTOM_ELEMENTS_SCHEMA], + }, }) .compileComponents() diff --git a/apps/metadata-editor/src/app/dashboard/search-header/search-header.component.ts b/apps/metadata-editor/src/app/dashboard/search-header/search-header.component.ts index c339c74fcc..7ce966490d 100644 --- a/apps/metadata-editor/src/app/dashboard/search-header/search-header.component.ts +++ b/apps/metadata-editor/src/app/dashboard/search-header/search-header.component.ts @@ -4,10 +4,8 @@ import { MatIconModule } from '@angular/material/icon' import { LetDirective } from '@ngrx/component' import { FeatureSearchModule } from '@geonetwork-ui/feature/search' import { UiElementsModule } from '@geonetwork-ui/ui/elements' -import { - AuthService, - AvatarServiceInterface, -} from '@geonetwork-ui/api/repository/gn4' +import { AvatarServiceInterface } from '@geonetwork-ui/api/repository/gn4' +import { PlatformServiceInterface } from '@geonetwork-ui/common/domain/platform.service.interface' @Component({ selector: 'md-editor-search-header', @@ -27,7 +25,7 @@ export class SearchHeaderComponent { public placeholder = this.avatarService.placeholder constructor( - public authService: AuthService, + public platformService: PlatformServiceInterface, private avatarService: AvatarServiceInterface ) {} } diff --git a/apps/metadata-editor/src/app/edit-record.resolver.ts b/apps/metadata-editor/src/app/edit-record.resolver.ts index d6f7c5f442..06f7fd71ac 100644 --- a/apps/metadata-editor/src/app/edit-record.resolver.ts +++ b/apps/metadata-editor/src/app/edit-record.resolver.ts @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core' import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router' import { Observable } from 'rxjs' import { EditorService } from '@geonetwork-ui/feature/editor' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' @Injectable({ providedIn: 'root', diff --git a/apps/metadata-editor/src/app/my-org-users/my-org-users.component.ts b/apps/metadata-editor/src/app/my-org-users/my-org-users.component.ts index aae4f1a49f..2ff8d66819 100644 --- a/apps/metadata-editor/src/app/my-org-users/my-org-users.component.ts +++ b/apps/metadata-editor/src/app/my-org-users/my-org-users.component.ts @@ -5,7 +5,7 @@ import { TranslateModule } from '@ngx-translate/core' import { CommonModule } from '@angular/common' import { MyOrgService } from '@geonetwork-ui/feature/catalog' import { SearchFacade } from '@geonetwork-ui/feature/search' -import { UserApiModel } from '@geonetwork-ui/data-access/gn4' +import { UserModel } from '@geonetwork-ui/common/domain/model/user/user.model' @Component({ selector: 'md-editor-my-org-users', @@ -25,7 +25,7 @@ export class MyOrgUsersComponent implements OnDestroy { logoUrl: string recordCount: number userCount: number - userList: UserApiModel[] + userList: UserModel[] } private myOrgDataSubscription diff --git a/apps/metadata-editor/src/app/records/my-org-records/my-org-records.component.ts b/apps/metadata-editor/src/app/records/my-org-records/my-org-records.component.ts index 16fbbfebd0..be7294e334 100644 --- a/apps/metadata-editor/src/app/records/my-org-records/my-org-records.component.ts +++ b/apps/metadata-editor/src/app/records/my-org-records/my-org-records.component.ts @@ -4,10 +4,10 @@ import { TranslateModule } from '@ngx-translate/core' import { RecordsListComponent } from '../records-list.component' import { MyOrgService } from '@geonetwork-ui/feature/catalog' import { SearchFacade } from '@geonetwork-ui/feature/search' -import { Organization } from '@geonetwork-ui/common/domain/record' +import { Organization } from '@geonetwork-ui/common/domain/model/record' import { OrganizationsServiceInterface } from '@geonetwork-ui/common/domain/organizations.service.interface' -import { UserApiModel } from '@geonetwork-ui/data-access/gn4' import { EditorRouterService } from '../../router.service' +import { UserModel } from '@geonetwork-ui/common/domain/model/user/user.model' @Component({ selector: 'md-editor-my-org-records', @@ -22,7 +22,7 @@ export class MyOrgRecordsComponent implements OnDestroy { logoUrl: string recordCount: number userCount: number - userList: UserApiModel[] + userList: UserModel[] } public myOrgDataSubscription diff --git a/apps/metadata-editor/src/app/records/my-records/my-records.component.spec.ts b/apps/metadata-editor/src/app/records/my-records/my-records.component.spec.ts index f1fbc3d519..4c67889604 100644 --- a/apps/metadata-editor/src/app/records/my-records/my-records.component.spec.ts +++ b/apps/metadata-editor/src/app/records/my-records/my-records.component.spec.ts @@ -8,6 +8,7 @@ import { BehaviorSubject, of } from 'rxjs' import { USER_FIXTURE } from '@geonetwork-ui/common/fixtures' import { AuthService } from '@geonetwork-ui/api/repository/gn4' import { EditorRouterService } from '../../router.service' +import { PlatformServiceInterface } from '@geonetwork-ui/common/domain/platform.service.interface' @Component({ // eslint-disable-next-line @@ -38,6 +39,11 @@ class FieldsServiceMock { buildFiltersFromFieldValues = jest.fn((val) => of(val)) } +const me$ = new BehaviorSubject(USER_FIXTURE()) +class PlatformServiceMock { + getMe = jest.fn(() => me$) +} + describe('MyRecordsComponent', () => { let component: MyRecordsComponent let fixture: ComponentFixture @@ -56,8 +62,8 @@ describe('MyRecordsComponent', () => { useClass: SearchFacadeMock, }, { - provide: AuthService, - useClass: AuthServiceMock, + provide: PlatformServiceInterface, + useClass: PlatformServiceMock, }, { provide: EditorRouterService, diff --git a/apps/metadata-editor/src/app/records/my-records/my-records.component.ts b/apps/metadata-editor/src/app/records/my-records/my-records.component.ts index cd12f08f91..fa1cf714d4 100644 --- a/apps/metadata-editor/src/app/records/my-records/my-records.component.ts +++ b/apps/metadata-editor/src/app/records/my-records/my-records.component.ts @@ -6,6 +6,7 @@ import { FieldsService, SearchFacade } from '@geonetwork-ui/feature/search' import { AuthService } from '@geonetwork-ui/api/repository/gn4' import { EditorRouterService } from '../../router.service' import { Subscription } from 'rxjs' +import { PlatformServiceInterface } from '@geonetwork-ui/common/domain/platform.service.interface' @Component({ selector: 'md-editor-my-records', @@ -21,13 +22,13 @@ export class MyRecordsComponent implements OnInit, OnDestroy { constructor( public fieldsService: FieldsService, public searchFacade: SearchFacade, - private authService: AuthService, + private platformService: PlatformServiceInterface, private router: EditorRouterService ) {} ngOnInit() { this.searchFacade.resetSearch() - this.sub = this.authService.user$.subscribe((user) => { + this.sub = this.platformService.getMe().subscribe((user) => { this.ownerId = user.id this.fieldsService .buildFiltersFromFieldValues({ owner: user.id }) diff --git a/apps/metadata-editor/src/app/records/records-list.component.spec.ts b/apps/metadata-editor/src/app/records/records-list.component.spec.ts index 1193416a72..8c5983a12f 100644 --- a/apps/metadata-editor/src/app/records/records-list.component.spec.ts +++ b/apps/metadata-editor/src/app/records/records-list.component.spec.ts @@ -2,7 +2,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing' import { SearchFacade, SearchService } from '@geonetwork-ui/feature/search' import { RecordsListComponent } from './records-list.component' import { Component, EventEmitter, Input, Output } from '@angular/core' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' import { By } from '@angular/platform-browser' import { Router } from '@angular/router' import { BehaviorSubject } from 'rxjs' diff --git a/apps/metadata-editor/src/app/records/records-list.component.ts b/apps/metadata-editor/src/app/records/records-list.component.ts index 4e5c033613..f06d1d8203 100644 --- a/apps/metadata-editor/src/app/records/records-list.component.ts +++ b/apps/metadata-editor/src/app/records/records-list.component.ts @@ -2,11 +2,11 @@ import { CommonModule } from '@angular/common' import { Component, Input } from '@angular/core' import { MatIconModule } from '@angular/material/icon' import { Router } from '@angular/router' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' import { SearchFacade, SearchService } from '@geonetwork-ui/feature/search' import { UiSearchModule } from '@geonetwork-ui/ui/search' import { UiElementsModule } from '@geonetwork-ui/ui/elements' -import { SortByField } from '@geonetwork-ui/common/domain/search' +import { SortByField } from '@geonetwork-ui/common/domain/model/search' import { TranslateModule } from '@ngx-translate/core' import { SelectionService } from '@geonetwork-ui/api/repository/gn4' import { Subject } from 'rxjs' diff --git a/apps/webcomponents/src/app/components/base.component.ts b/apps/webcomponents/src/app/components/base.component.ts index 59394945c8..5c8851ab01 100644 --- a/apps/webcomponents/src/app/components/base.component.ts +++ b/apps/webcomponents/src/app/components/base.component.ts @@ -15,8 +15,8 @@ import { Configuration, SearchApiService } from '@geonetwork-ui/data-access/gn4' import { SearchFacade } from '@geonetwork-ui/feature/search' import { TranslateService } from '@ngx-translate/core' import { firstValueFrom } from 'rxjs' -import { DatasetDistribution } from '@geonetwork-ui/common/domain/record' -import { RecordsRepositoryInterface } from '@geonetwork-ui/common/domain/records-repository.interface' +import { DatasetDistribution } from '@geonetwork-ui/common/domain/model/record' +import { RecordsRepositoryInterface } from '@geonetwork-ui/common/domain/repository/records-repository.interface' import { OverlayContainer } from '@angular/cdk/overlay' import { WebcomponentOverlayContainer } from '../webcomponent-overlay-container' diff --git a/apps/webcomponents/src/app/components/gn-dataset-view-chart/gn-dataset-view-chart.component.ts b/apps/webcomponents/src/app/components/gn-dataset-view-chart/gn-dataset-view-chart.component.ts index 948e0c2dfc..6a044f7c42 100644 --- a/apps/webcomponents/src/app/components/gn-dataset-view-chart/gn-dataset-view-chart.component.ts +++ b/apps/webcomponents/src/app/components/gn-dataset-view-chart/gn-dataset-view-chart.component.ts @@ -10,7 +10,7 @@ import { import { SearchFacade, SearchService } from '@geonetwork-ui/feature/search' import { BaseComponent } from '../base.component' import { LinkUsage } from '@geonetwork-ui/util/shared' -import { DatasetDistribution } from '@geonetwork-ui/common/domain/record' +import { DatasetDistribution } from '@geonetwork-ui/common/domain/model/record' @Component({ selector: 'wc-gn-dataset-view-chart', diff --git a/apps/webcomponents/src/app/components/gn-dataset-view-table/gn-dataset-view-table.component.ts b/apps/webcomponents/src/app/components/gn-dataset-view-table/gn-dataset-view-table.component.ts index e2388c98c2..6a87ff5c99 100644 --- a/apps/webcomponents/src/app/components/gn-dataset-view-table/gn-dataset-view-table.component.ts +++ b/apps/webcomponents/src/app/components/gn-dataset-view-table/gn-dataset-view-table.component.ts @@ -10,7 +10,7 @@ import { import { SearchFacade, SearchService } from '@geonetwork-ui/feature/search' import { BaseComponent } from '../base.component' import { LinkUsage } from '@geonetwork-ui/util/shared' -import { DatasetDistribution } from '@geonetwork-ui/common/domain/record' +import { DatasetDistribution } from '@geonetwork-ui/common/domain/model/record' @Component({ selector: 'wc-gn-dataset-view-table', diff --git a/apps/webcomponents/src/app/components/gn-results-list/gn-results-list.component.ts b/apps/webcomponents/src/app/components/gn-results-list/gn-results-list.component.ts index a4cc8aa7ab..c6614381ff 100644 --- a/apps/webcomponents/src/app/components/gn-results-list/gn-results-list.component.ts +++ b/apps/webcomponents/src/app/components/gn-results-list/gn-results-list.component.ts @@ -11,9 +11,9 @@ import { SearchFacade, SearchStateParams, } from '@geonetwork-ui/feature/search' -import { FieldFilters } from '@geonetwork-ui/common/domain/search' +import { FieldFilters } from '@geonetwork-ui/common/domain/model/search' import { BaseComponent } from '../base.component' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' @Component({ selector: 'wc-gn-results-list-component', diff --git a/apps/webcomponents/src/app/components/gn-search-input/gn-search-input.component.ts b/apps/webcomponents/src/app/components/gn-search-input/gn-search-input.component.ts index dac2b2e7f9..ee4176eeec 100644 --- a/apps/webcomponents/src/app/components/gn-search-input/gn-search-input.component.ts +++ b/apps/webcomponents/src/app/components/gn-search-input/gn-search-input.component.ts @@ -9,7 +9,7 @@ import { import { SearchFacade, SearchService } from '@geonetwork-ui/feature/search' import { BaseComponent } from '../base.component' import { FuzzySearchComponent } from '@geonetwork-ui/feature/search' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' @Component({ selector: 'wc-gn-search-input', diff --git a/libs/api/metadata-converter/src/lib/common/distribution.mapper.ts b/libs/api/metadata-converter/src/lib/common/distribution.mapper.ts index 9c0aa2c6c8..bde80a250e 100644 --- a/libs/api/metadata-converter/src/lib/common/distribution.mapper.ts +++ b/libs/api/metadata-converter/src/lib/common/distribution.mapper.ts @@ -1,4 +1,4 @@ -import { ServiceProtocol } from '@geonetwork-ui/common/domain/record' +import { ServiceProtocol } from '@geonetwork-ui/common/domain/model/record' export function matchProtocol(protocol: string): ServiceProtocol { if (/wms/i.test(protocol)) return 'wms' diff --git a/libs/api/metadata-converter/src/lib/fixtures/generic.records.ts b/libs/api/metadata-converter/src/lib/fixtures/generic.records.ts index b38c878280..4d460377a2 100644 --- a/libs/api/metadata-converter/src/lib/fixtures/generic.records.ts +++ b/libs/api/metadata-converter/src/lib/fixtures/generic.records.ts @@ -1,4 +1,4 @@ -import { DatasetRecord } from '@geonetwork-ui/common/domain/record' +import { DatasetRecord } from '@geonetwork-ui/common/domain/model/record' export const GENERIC_DATASET_RECORD: DatasetRecord = { uniqueIdentifier: 'my-dataset-001', diff --git a/libs/api/metadata-converter/src/lib/fixtures/geo2france.records.ts b/libs/api/metadata-converter/src/lib/fixtures/geo2france.records.ts index 255e6ea04f..95b7912821 100644 --- a/libs/api/metadata-converter/src/lib/fixtures/geo2france.records.ts +++ b/libs/api/metadata-converter/src/lib/fixtures/geo2france.records.ts @@ -1,4 +1,4 @@ -import { DatasetRecord } from '@geonetwork-ui/common/domain/record' +import { DatasetRecord } from '@geonetwork-ui/common/domain/model/record' export const GEO2FRANCE_PLU_DATASET_RECORD: DatasetRecord = { uniqueIdentifier: '7d002c4c-92ef-4b9f-a568-d732f740b99e', diff --git a/libs/api/metadata-converter/src/lib/fixtures/geocat-ch.records.ts b/libs/api/metadata-converter/src/lib/fixtures/geocat-ch.records.ts index fe15e817fe..fa17276e77 100644 --- a/libs/api/metadata-converter/src/lib/fixtures/geocat-ch.records.ts +++ b/libs/api/metadata-converter/src/lib/fixtures/geocat-ch.records.ts @@ -1,7 +1,7 @@ import { DatasetRecord, ServiceRecord, -} from '@geonetwork-ui/common/domain/record' +} from '@geonetwork-ui/common/domain/model/record' export const GEOCAT_CH_DATASET_RECORD: DatasetRecord = { uniqueIdentifier: '8698bf0b-fceb-4f0f-989b-111e7c4af0a4', diff --git a/libs/api/metadata-converter/src/lib/gn4/atomic-operations.ts b/libs/api/metadata-converter/src/lib/gn4/atomic-operations.ts index 602ef9677e..fd4280502b 100644 --- a/libs/api/metadata-converter/src/lib/gn4/atomic-operations.ts +++ b/libs/api/metadata-converter/src/lib/gn4/atomic-operations.ts @@ -1,4 +1,7 @@ -import { Individual, Organization } from '@geonetwork-ui/common/domain/record' +import { + Individual, + Organization, +} from '@geonetwork-ui/common/domain/model/record' import { getRoleFromRoleCode } from '../iso19139/codelists/role.mapper' export type SourceWithUnknownProps = { [key: string]: unknown } diff --git a/libs/api/metadata-converter/src/lib/gn4/gn4.field.mapper.ts b/libs/api/metadata-converter/src/lib/gn4/gn4.field.mapper.ts index a655863db5..c9ab874094 100644 --- a/libs/api/metadata-converter/src/lib/gn4/gn4.field.mapper.ts +++ b/libs/api/metadata-converter/src/lib/gn4/gn4.field.mapper.ts @@ -23,7 +23,7 @@ import { DatasetDownloadDistribution, DatasetServiceDistribution, OnlineLinkResource, -} from '@geonetwork-ui/common/domain/record' +} from '@geonetwork-ui/common/domain/model/record' import { matchProtocol } from '../common/distribution.mapper' import { LangService } from '@geonetwork-ui/util/i18n' diff --git a/libs/api/metadata-converter/src/lib/gn4/gn4.metadata.mapper.spec.ts b/libs/api/metadata-converter/src/lib/gn4/gn4.metadata.mapper.spec.ts index 6a96feee92..77e1f42cc3 100644 --- a/libs/api/metadata-converter/src/lib/gn4/gn4.metadata.mapper.spec.ts +++ b/libs/api/metadata-converter/src/lib/gn4/gn4.metadata.mapper.spec.ts @@ -11,7 +11,7 @@ import { OrganizationsServiceInterface } from '@geonetwork-ui/common/domain/orga import { CatalogRecord, DatasetRecord, -} from '@geonetwork-ui/common/domain/record' +} from '@geonetwork-ui/common/domain/model/record' import { TranslateService } from '@ngx-translate/core' class MetadataUrlServiceMock { diff --git a/libs/api/metadata-converter/src/lib/gn4/gn4.metadata.mapper.ts b/libs/api/metadata-converter/src/lib/gn4/gn4.metadata.mapper.ts index 2870353baf..a324fe1742 100644 --- a/libs/api/metadata-converter/src/lib/gn4/gn4.metadata.mapper.ts +++ b/libs/api/metadata-converter/src/lib/gn4/gn4.metadata.mapper.ts @@ -1,7 +1,7 @@ import { Gn4FieldMapper } from './gn4.field.mapper' import { lastValueFrom } from 'rxjs' import { OrganizationsServiceInterface } from '@geonetwork-ui/common/domain/organizations.service.interface' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' import { MetadataBaseMapper } from '../metadata-base.mapper' import { Injectable } from '@angular/core' import { Gn4Record } from './types' diff --git a/libs/api/metadata-converter/src/lib/iso19139/codelists/role.mapper.ts b/libs/api/metadata-converter/src/lib/iso19139/codelists/role.mapper.ts index c5f15cf4ca..90bc9254fd 100644 --- a/libs/api/metadata-converter/src/lib/iso19139/codelists/role.mapper.ts +++ b/libs/api/metadata-converter/src/lib/iso19139/codelists/role.mapper.ts @@ -1,4 +1,4 @@ -import { Role } from '@geonetwork-ui/common/domain/record' +import { Role } from '@geonetwork-ui/common/domain/model/record' export function getRoleFromRoleCode(roleCode: string): Role { if (!roleCode) return 'unspecified' diff --git a/libs/api/metadata-converter/src/lib/iso19139/codelists/status.mapper.ts b/libs/api/metadata-converter/src/lib/iso19139/codelists/status.mapper.ts index 642a5dc4bb..f10f508b95 100644 --- a/libs/api/metadata-converter/src/lib/iso19139/codelists/status.mapper.ts +++ b/libs/api/metadata-converter/src/lib/iso19139/codelists/status.mapper.ts @@ -1,4 +1,4 @@ -import { RecordStatus } from '@geonetwork-ui/common/domain/record' +import { RecordStatus } from '@geonetwork-ui/common/domain/model/record' export function getStatusFromStatusCode(statusCode: string): RecordStatus { switch (statusCode) { diff --git a/libs/api/metadata-converter/src/lib/iso19139/codelists/update-frequency.mapper.ts b/libs/api/metadata-converter/src/lib/iso19139/codelists/update-frequency.mapper.ts index 8bff304994..fff97e9677 100644 --- a/libs/api/metadata-converter/src/lib/iso19139/codelists/update-frequency.mapper.ts +++ b/libs/api/metadata-converter/src/lib/iso19139/codelists/update-frequency.mapper.ts @@ -1,4 +1,4 @@ -import { UpdateFrequency } from '@geonetwork-ui/common/domain/record' +import { UpdateFrequency } from '@geonetwork-ui/common/domain/model/record' export function getUpdateFrequencyFromFrequencyCode( frequencyCode: string diff --git a/libs/api/metadata-converter/src/lib/iso19139/converter.ts b/libs/api/metadata-converter/src/lib/iso19139/converter.ts index 42c651aa2f..b8da417204 100644 --- a/libs/api/metadata-converter/src/lib/iso19139/converter.ts +++ b/libs/api/metadata-converter/src/lib/iso19139/converter.ts @@ -2,7 +2,7 @@ import { CatalogRecord, DatasetRecord, ServiceRecord, -} from '@geonetwork-ui/common/domain/record' +} from '@geonetwork-ui/common/domain/model/record' import { createDocument, createElement, diff --git a/libs/api/metadata-converter/src/lib/iso19139/read-parts.ts b/libs/api/metadata-converter/src/lib/iso19139/read-parts.ts index 8ac2bb7789..6e9cc42126 100644 --- a/libs/api/metadata-converter/src/lib/iso19139/read-parts.ts +++ b/libs/api/metadata-converter/src/lib/iso19139/read-parts.ts @@ -15,7 +15,7 @@ import { SpatialRepresentationType, UpdateFrequency, UpdateFrequencyCustom, -} from '@geonetwork-ui/common/domain/record' +} from '@geonetwork-ui/common/domain/model/record' import { getStatusFromStatusCode } from './codelists/status.mapper' import { getUpdateFrequencyFromFrequencyCode } from './codelists/update-frequency.mapper' import { diff --git a/libs/api/metadata-converter/src/lib/iso19139/write-parts.spec.ts b/libs/api/metadata-converter/src/lib/iso19139/write-parts.spec.ts index e26b95dbb1..568d6397ab 100644 --- a/libs/api/metadata-converter/src/lib/iso19139/write-parts.spec.ts +++ b/libs/api/metadata-converter/src/lib/iso19139/write-parts.spec.ts @@ -7,7 +7,7 @@ import { } from '../xml-utils' import { writeDistributions } from './write-parts' import { GENERIC_DATASET_RECORD } from '../fixtures/generic.records' -import { DatasetRecord } from '@geonetwork-ui/common/domain/record' +import { DatasetRecord } from '@geonetwork-ui/common/domain/model/record' describe('write parts', () => { let rootEl: XmlElement diff --git a/libs/api/metadata-converter/src/lib/iso19139/write-parts.ts b/libs/api/metadata-converter/src/lib/iso19139/write-parts.ts index 990f003af1..20bfbdd000 100644 --- a/libs/api/metadata-converter/src/lib/iso19139/write-parts.ts +++ b/libs/api/metadata-converter/src/lib/iso19139/write-parts.ts @@ -13,7 +13,7 @@ import { ServiceRecord, UpdateFrequencyCode, UpdateFrequencyCustom, -} from '@geonetwork-ui/common/domain/record' +} from '@geonetwork-ui/common/domain/model/record' import { addAttribute, appendChildren, diff --git a/libs/api/metadata-converter/src/lib/metadata-base.mapper.ts b/libs/api/metadata-converter/src/lib/metadata-base.mapper.ts index e61846c093..d8a0939016 100644 --- a/libs/api/metadata-converter/src/lib/metadata-base.mapper.ts +++ b/libs/api/metadata-converter/src/lib/metadata-base.mapper.ts @@ -1,7 +1,7 @@ import { CatalogRecord, DatasetRecord, -} from '@geonetwork-ui/common/domain/record' +} from '@geonetwork-ui/common/domain/model/record' export class MetadataMapperContext { readonly location? diff --git a/libs/api/repository/src/lib/gn4/auth/auth.service.spec.ts b/libs/api/repository/src/lib/gn4/auth/auth.service.spec.ts index c587381c57..f604788788 100644 --- a/libs/api/repository/src/lib/gn4/auth/auth.service.spec.ts +++ b/libs/api/repository/src/lib/gn4/auth/auth.service.spec.ts @@ -1,38 +1,12 @@ import { AuthService, LOGIN_URL } from './auth.service' -import { Subject } from 'rxjs' import { TestBed } from '@angular/core/testing' -import { MeApiService } from '@geonetwork-ui/data-access/gn4' import { TranslateService } from '@ngx-translate/core' -import { AvatarServiceInterface } from './avatar.service.interface' import { HttpClientTestingModule } from '@angular/common/http/testing' -const userMock = { - id: '21737', - profile: 'Administrator', - username: 'C2C-gravin', - name: 'Florent', - surname: 'Gravin', - email: 'florent.gravin@camptocamp.com', - hash: 'girafe', - organisation: null, - admin: true, - groupsWithRegisteredUser: [], - groupsWithEditor: [], - groupsWithReviewer: [], - groupsWithUserAdmin: [], -} let loginUrlTokenMock const translateServiceMock = { currentLang: 'fr', } -const me$ = new Subject() -const meApiMock = { - getMe: () => me$, -} -class AvatarServiceInterfaceMock { - placeholder = 'http://placeholder.com' - getProfileIcon = jest.fn((hash: string) => `http://icon_service.com/${hash}`) -} let windowLocation Object.defineProperties((global as any).window, { @@ -52,18 +26,10 @@ describe('AuthService', () => { provide: LOGIN_URL, useFactory: () => loginUrlTokenMock, }, - { - provide: MeApiService, - useValue: meApiMock, - }, { provide: TranslateService, useValue: translateServiceMock, }, - { - provide: AvatarServiceInterface, - useClass: AvatarServiceInterfaceMock, - }, ], imports: [HttpClientTestingModule], }) @@ -74,33 +40,6 @@ describe('AuthService', () => { expect(service).toBeTruthy() }) - describe('authentication', () => { - beforeEach(() => { - service = TestBed.inject(AuthService) - }) - describe('#authReady', () => { - it('emits a value on subscribe after auth was queried', () => { - let emitted = false - service.authReady().subscribe(() => (emitted = true)) - me$.next(null) - expect(emitted).toBeTruthy() - }) - }) - describe('#isAnonymous', () => { - it('returns true for anonymous user', () => { - let isAnonymous = false - service.isAnonymous$.subscribe((anonymous) => (isAnonymous = anonymous)) - me$.next(null) - expect(isAnonymous).toBeTruthy() - }) - it('returns false for authenticated user', () => { - let isAnonymous = true - service.isAnonymous$.subscribe((anonymous) => (isAnonymous = anonymous)) - me$.next(userMock) - expect(isAnonymous).toBeFalsy() - }) - }) - }) describe('login URL (default)', () => { beforeEach(() => { loginUrlTokenMock = undefined @@ -143,18 +82,4 @@ describe('AuthService', () => { ) }) }) - describe('#mapToUserModel', () => { - it('maps to UserModel', () => { - expect(service['mapToUserModel'](userMock)).toEqual({ - id: '21737', - profile: 'Administrator', - username: 'C2C-gravin', - name: 'Florent', - surname: 'Gravin', - email: 'florent.gravin@camptocamp.com', - profileIcon: 'http://icon_service.com/girafe', - organisation: null, - }) - }) - }) }) diff --git a/libs/api/repository/src/lib/gn4/auth/auth.service.ts b/libs/api/repository/src/lib/gn4/auth/auth.service.ts index b901e4fdbb..fae24500ba 100644 --- a/libs/api/repository/src/lib/gn4/auth/auth.service.ts +++ b/libs/api/repository/src/lib/gn4/auth/auth.service.ts @@ -1,16 +1,6 @@ import { Inject, Injectable, InjectionToken, Optional } from '@angular/core' -import { - MeApiService, - MeResponseApiModel, - UserApiModel, - UsersApiService, -} from '@geonetwork-ui/data-access/gn4' import { LANG_2_TO_3_MAPPER } from '@geonetwork-ui/util/i18n' -import { UserModel } from '@geonetwork-ui/common/domain/user.model' import { TranslateService } from '@ngx-translate/core' -import { Observable } from 'rxjs' -import { map, shareReplay } from 'rxjs/operators' -import { AvatarServiceInterface } from './avatar.service.interface' export const DEFAULT_GN4_LOGIN_URL = `/geonetwork/srv/\${lang3}/catalog.signin?redirect=\${current_url}` export const LOGIN_URL = new InjectionToken('loginUrl') @@ -19,11 +9,6 @@ export const LOGIN_URL = new InjectionToken('loginUrl') providedIn: 'root', }) export class AuthService { - authReady$: Observable - user$: Observable - allUsers$: Observable - isAnonymous$ = this.authReady().pipe(map((user) => !user || !('id' in user))) - baseLoginUrl = this.baseLoginUrlToken || DEFAULT_GN4_LOGIN_URL get loginUrl() { let baseUrl = this.baseLoginUrl @@ -44,41 +29,6 @@ export class AuthService { @Optional() @Inject(LOGIN_URL) private baseLoginUrlToken: string, - private meApi: MeApiService, - private usersApi: UsersApiService, - private translateService: TranslateService, - private avatarService: AvatarServiceInterface - ) { - this.user$ = this.meApi.getMe().pipe( - map((apiUser) => this.mapToUserModel(apiUser)), - shareReplay({ bufferSize: 1, refCount: true }) - ) - this.allUsers$ = this.usersApi.getUsers().pipe(shareReplay()) - } - - // TODO: refactor authReady - authReady(): Observable { - if (!this.authReady$) { - this.authReady$ = this.meApi.getMe().pipe( - map((apiUser) => this.mapToUserModel(apiUser)), - shareReplay({ bufferSize: 1, refCount: true }) - ) - } - return this.authReady$ - } - - private mapToUserModel(apiUser: MeResponseApiModel): UserModel { - if (!apiUser) return null - const { - hash, - groupsWithRegisteredUser, - groupsWithEditor, - groupsWithReviewer, - groupsWithUserAdmin, - admin, - ...user - } = apiUser - const icon = this.avatarService.getProfileIcon(apiUser.hash) - return { ...user, profileIcon: icon } as UserModel - } + private translateService: TranslateService + ) {} } diff --git a/libs/api/repository/src/lib/gn4/elasticsearch/elasticsearch.service.ts b/libs/api/repository/src/lib/gn4/elasticsearch/elasticsearch.service.ts index c5981a1e43..f897a5b942 100644 --- a/libs/api/repository/src/lib/gn4/elasticsearch/elasticsearch.service.ts +++ b/libs/api/repository/src/lib/gn4/elasticsearch/elasticsearch.service.ts @@ -13,7 +13,7 @@ import { FieldFilters, FilterAggregationParams, SortByField, -} from '@geonetwork-ui/common/domain/search' +} from '@geonetwork-ui/common/domain/model/search' import { METADATA_LANGUAGE } from '../../metadata-language' import { AggregationResult, diff --git a/libs/api/repository/src/lib/gn4/favorites/favorites.service.spec.ts b/libs/api/repository/src/lib/gn4/favorites/favorites.service.spec.ts index e9184daf64..9b69a93a60 100644 --- a/libs/api/repository/src/lib/gn4/favorites/favorites.service.spec.ts +++ b/libs/api/repository/src/lib/gn4/favorites/favorites.service.spec.ts @@ -1,5 +1,4 @@ import { FavoritesService } from './favorites.service' -import { AuthService } from '../auth/auth.service' import { MeResponseApiModel, UserselectionsApiService, @@ -7,9 +6,10 @@ import { import { firstValueFrom, of, throwError } from 'rxjs' import { delay } from 'rxjs/operators' import { fakeAsync, tick } from '@angular/core/testing' +import { PlatformServiceInterface } from '@geonetwork-ui/common/domain/platform.service.interface' -class AuthServiceMock { - authReady = jest.fn(() => +class Gn4PlatformServiceMock { + getMe = jest.fn(() => of({ id: '1234', name: 'fakeuser', @@ -26,12 +26,12 @@ class UserSelectionsServiceMock { describe('FavoritesService', () => { let service: FavoritesService let userSelectionsService: UserselectionsApiService - let authService: AuthService + let platform: PlatformServiceInterface beforeEach(() => { userSelectionsService = new UserSelectionsServiceMock() as any - authService = new AuthServiceMock() as any - service = new FavoritesService(userSelectionsService, authService) + platform = new Gn4PlatformServiceMock() as any + service = new FavoritesService(userSelectionsService, platform) }) it('should be created', () => { @@ -41,8 +41,8 @@ describe('FavoritesService', () => { describe('myFavorites$', () => { describe('when not authenticated', () => { beforeEach(() => { - authService.authReady = () => of(null) - service = new FavoritesService(userSelectionsService, authService) + platform.getMe = () => of(null) + service = new FavoritesService(userSelectionsService, platform) }) it('returns an empty array', async () => { const uuids = await firstValueFrom(service.myFavoritesUuid$) @@ -98,8 +98,8 @@ describe('FavoritesService', () => { let favorites describe('when not authenticated', () => { beforeEach(() => { - authService.authReady = () => of(null) - service = new FavoritesService(userSelectionsService, authService) + platform.getMe = () => of(null) + service = new FavoritesService(userSelectionsService, platform) }) it('throws an error', async () => { expect.assertions(1) @@ -160,8 +160,8 @@ describe('FavoritesService', () => { let favorites describe('when not authenticated', () => { beforeEach(() => { - authService.authReady = () => of(null) - service = new FavoritesService(userSelectionsService, authService) + platform.getMe = () => of(null) + service = new FavoritesService(userSelectionsService, platform) }) it('throws an error', async () => { expect.assertions(1) diff --git a/libs/api/repository/src/lib/gn4/favorites/favorites.service.ts b/libs/api/repository/src/lib/gn4/favorites/favorites.service.ts index ab6ad1d10c..ad7ab09510 100644 --- a/libs/api/repository/src/lib/gn4/favorites/favorites.service.ts +++ b/libs/api/repository/src/lib/gn4/favorites/favorites.service.ts @@ -1,7 +1,6 @@ import { Injectable } from '@angular/core' import { merge, Observable, of, Subject, throwError } from 'rxjs' import { UserselectionsApiService } from '@geonetwork-ui/data-access/gn4' -import { AuthService } from '../auth/auth.service' import { catchError, map, @@ -11,6 +10,7 @@ import { tap, withLatestFrom, } from 'rxjs/operators' +import { PlatformServiceInterface } from '@geonetwork-ui/common/domain/platform.service.interface' const SELECTION_ID = 0 // hardcoded to always point on the first selection @@ -18,8 +18,8 @@ const SELECTION_ID = 0 // hardcoded to always point on the first selection providedIn: 'root', }) export class FavoritesService { - private myUserId$ = this.authService - .authReady() + private myUserId$ = this.platformService + .getMe() .pipe(map((userInfo) => (userInfo ? parseInt(userInfo.id) : null))) // this observable loads the current list of favorites from the API @@ -52,7 +52,7 @@ export class FavoritesService { constructor( private userSelectionsService: UserselectionsApiService, - private authService: AuthService + private platformService: PlatformServiceInterface ) {} addToFavorites(uuids: string[]): Observable { diff --git a/libs/api/repository/src/lib/gn4/gn4-repository.spec.ts b/libs/api/repository/src/lib/gn4/gn4-repository.spec.ts index b363375441..3906434766 100644 --- a/libs/api/repository/src/lib/gn4/gn4-repository.spec.ts +++ b/libs/api/repository/src/lib/gn4/gn4-repository.spec.ts @@ -10,9 +10,9 @@ import { import { Aggregations, SearchResults, -} from '@geonetwork-ui/common/domain/search' +} from '@geonetwork-ui/common/domain/model/search' import { DATASET_RECORDS } from '@geonetwork-ui/common/fixtures' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' class Gn4MetadataMapperMock { readRecords = jest.fn((records) => diff --git a/libs/api/repository/src/lib/gn4/gn4-repository.ts b/libs/api/repository/src/lib/gn4/gn4-repository.ts index 74e8ad498f..79902ccd79 100644 --- a/libs/api/repository/src/lib/gn4/gn4-repository.ts +++ b/libs/api/repository/src/lib/gn4/gn4-repository.ts @@ -2,22 +2,22 @@ import { Injectable } from '@angular/core' import { SearchApiService } from '@geonetwork-ui/data-access/gn4' import { ElasticsearchService } from './elasticsearch' import { Observable, of, switchMap } from 'rxjs' -import { RecordsRepositoryInterface } from '@geonetwork-ui/common/domain/records-repository.interface' +import { RecordsRepositoryInterface } from '@geonetwork-ui/common/domain/repository/records-repository.interface' import { SearchParams, SearchResults, -} from '@geonetwork-ui/common/domain/search/search.model' +} from '@geonetwork-ui/common/domain/model/search/search.model' import { Aggregations, AggregationsParams, FieldFilters, -} from '@geonetwork-ui/common/domain/search' +} from '@geonetwork-ui/common/domain/model/search' import { map } from 'rxjs/operators' import { Gn4MetadataMapper, Gn4SearchResults, } from '@geonetwork-ui/api/metadata-converter' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' @Injectable() export class Gn4Repository implements RecordsRepositoryInterface { diff --git a/libs/api/repository/src/lib/gn4/gn4.provider.ts b/libs/api/repository/src/lib/gn4/gn4.provider.ts new file mode 100644 index 0000000000..96661cb9b1 --- /dev/null +++ b/libs/api/repository/src/lib/gn4/gn4.provider.ts @@ -0,0 +1,14 @@ +import { Provider } from '@angular/core' +import { PlatformServiceInterface } from '@geonetwork-ui/common/domain/platform.service.interface' +import { Gn4PlatformService } from './platform/gn4-platform.service' +import { Gn4PlatformMapper } from './platform/gn4-platform.mapper' + +export function provideGn4(): Provider[] { + return [ + { + provide: PlatformServiceInterface, + useClass: Gn4PlatformService, + }, + Gn4PlatformMapper, + ] +} diff --git a/libs/api/repository/src/lib/gn4/index.ts b/libs/api/repository/src/lib/gn4/index.ts index bfbbbd4fee..2e56374154 100644 --- a/libs/api/repository/src/lib/gn4/index.ts +++ b/libs/api/repository/src/lib/gn4/index.ts @@ -5,3 +5,4 @@ export * from './settings/gn4-settings.service' export * from './auth' export * from './favorites/favorites.service' export * from './selection/selection.service' +export * from './gn4.provider' diff --git a/libs/api/repository/src/lib/gn4/organizations/organizations-from-groups.service.spec.ts b/libs/api/repository/src/lib/gn4/organizations/organizations-from-groups.service.spec.ts index 0c0a782b25..fe4c0ad104 100644 --- a/libs/api/repository/src/lib/gn4/organizations/organizations-from-groups.service.spec.ts +++ b/libs/api/repository/src/lib/gn4/organizations/organizations-from-groups.service.spec.ts @@ -9,7 +9,7 @@ import { TranslateService } from '@ngx-translate/core' import { CatalogRecord, Organization, -} from '@geonetwork-ui/common/domain/record' +} from '@geonetwork-ui/common/domain/model/record' import { ES_FIXTURE_FULL_RESPONSE, GROUPS_FIXTURE, diff --git a/libs/api/repository/src/lib/gn4/organizations/organizations-from-groups.service.ts b/libs/api/repository/src/lib/gn4/organizations/organizations-from-groups.service.ts index 944e942c6e..7f9b8de7d2 100644 --- a/libs/api/repository/src/lib/gn4/organizations/organizations-from-groups.service.ts +++ b/libs/api/repository/src/lib/gn4/organizations/organizations-from-groups.service.ts @@ -8,11 +8,11 @@ import { forkJoin, Observable, of } from 'rxjs' import { map, shareReplay } from 'rxjs/operators' import { TranslateService } from '@ngx-translate/core' import { LANG_2_TO_3_MAPPER } from '@geonetwork-ui/util/i18n' -import { FieldFilters } from '@geonetwork-ui/common/domain/search' +import { FieldFilters } from '@geonetwork-ui/common/domain/model/search' import { CatalogRecord, Organization, -} from '@geonetwork-ui/common/domain/record' +} from '@geonetwork-ui/common/domain/model/record' import { OrganizationsServiceInterface } from '@geonetwork-ui/common/domain/organizations.service.interface' import { ElasticsearchService } from '../elasticsearch' import { getAsUrl, MetadataObject } from '@geonetwork-ui/api/metadata-converter' diff --git a/libs/api/repository/src/lib/gn4/organizations/organizations-from-metadata.service.spec.ts b/libs/api/repository/src/lib/gn4/organizations/organizations-from-metadata.service.spec.ts index 879763bec1..9678169e26 100644 --- a/libs/api/repository/src/lib/gn4/organizations/organizations-from-metadata.service.spec.ts +++ b/libs/api/repository/src/lib/gn4/organizations/organizations-from-metadata.service.spec.ts @@ -2,7 +2,6 @@ import { TestBed } from '@angular/core/testing' import { GroupsApiService, SearchApiService, - SiteApiService, } from '@geonetwork-ui/data-access/gn4' import { firstValueFrom, lastValueFrom, of } from 'rxjs' import { take } from 'rxjs/operators' @@ -10,12 +9,13 @@ import { OrganizationsFromMetadataService } from './organizations-from-metadata. import { CatalogRecord, Organization, -} from '@geonetwork-ui/common/domain/record' +} from '@geonetwork-ui/common/domain/model/record' import { ES_FIXTURE_FULL_RESPONSE, GROUPS_FIXTURE, } from '@geonetwork-ui/common/fixtures' import { LangService } from '@geonetwork-ui/util/i18n' +import { PlatformServiceInterface } from '@geonetwork-ui/common/domain/platform.service.interface' const sampleOrgA: Organization = { description: 'A description for ARE', @@ -145,12 +145,8 @@ class GoupsApiServiceMock { getGroups = jest.fn(() => of(GROUPS_FIXTURE)) } -class SiteApiServiceMock { - getSiteOrPortalDescription = jest.fn(() => - of({ - 'system/platform/version': geonetworkVersion, - }) - ) +class Gn4PlatformServiceMock { + getApiVersion = jest.fn(() => of(geonetworkVersion)) } class LangServiceMock { @@ -179,14 +175,14 @@ describe.each(['4.2.2-00', '4.2.3-xx', '4.2.5-xx'])( provide: SearchApiService, useClass: SearchApiServiceMock, }, - { - provide: SiteApiService, - useClass: SiteApiServiceMock, - }, { provide: LangService, useClass: LangServiceMock, }, + { + provide: PlatformServiceInterface, + useClass: Gn4PlatformServiceMock, + }, ], }) service = TestBed.inject(OrganizationsFromMetadataService) diff --git a/libs/api/repository/src/lib/gn4/organizations/organizations-from-metadata.service.ts b/libs/api/repository/src/lib/gn4/organizations/organizations-from-metadata.service.ts index 20b79e78c9..504412fb37 100644 --- a/libs/api/repository/src/lib/gn4/organizations/organizations-from-metadata.service.ts +++ b/libs/api/repository/src/lib/gn4/organizations/organizations-from-metadata.service.ts @@ -3,16 +3,15 @@ import { GroupApiModel, GroupsApiService, SearchApiService, - SiteApiService, } from '@geonetwork-ui/data-access/gn4' import { FieldFilterByValues, FieldFilters, -} from '@geonetwork-ui/common/domain/search' +} from '@geonetwork-ui/common/domain/model/search' import { CatalogRecord, Organization, -} from '@geonetwork-ui/common/domain/record' +} from '@geonetwork-ui/common/domain/model/record' import { OrganizationsServiceInterface } from '@geonetwork-ui/common/domain/organizations.service.interface' import { ElasticsearchService } from '../elasticsearch' import { @@ -28,6 +27,7 @@ import { import { combineLatest, Observable, of, switchMap, takeLast } from 'rxjs' import { filter, map, shareReplay, startWith, tap } from 'rxjs/operators' import { LangService } from '@geonetwork-ui/util/i18n' +import { PlatformServiceInterface } from '@geonetwork-ui/common/domain/platform.service.interface' const IMAGE_URL = '/geonetwork/images/harvesting/' @@ -53,18 +53,12 @@ interface IncompleteOrganization { export class OrganizationsFromMetadataService implements OrganizationsServiceInterface { - geonetworkVersion$ = of(true).pipe( - switchMap(() => this.siteApiService.getSiteOrPortalDescription()), - map((info) => info['system/platform/version']), - shareReplay(1) - ) - private groups$: Observable = of(true).pipe( switchMap(() => this.groupsApiService.getGroups()), shareReplay() ) private organisationsAggs$: Observable = - this.geonetworkVersion$.pipe( + this.platformService.getApiVersion().pipe( switchMap((version) => this.searchApiService.search( 'bucket', @@ -117,7 +111,7 @@ export class OrganizationsFromMetadataService private esService: ElasticsearchService, private searchApiService: SearchApiService, private groupsApiService: GroupsApiService, - private siteApiService: SiteApiService, + private platformService: PlatformServiceInterface, private langService: LangService ) {} @@ -235,7 +229,7 @@ export class OrganizationsFromMetadataService } getFiltersForOrgs(organisations: Organization[]): Observable { - return this.geonetworkVersion$.pipe( + return this.platformService.getApiVersion().pipe( map((gnVersion) => { const fieldName = gnVersion.startsWith('4.2.2') ? 'OrgForResource' @@ -251,7 +245,7 @@ export class OrganizationsFromMetadataService } getOrgsFromFilters(filters: FieldFilters): Observable { - return this.geonetworkVersion$.pipe( + return this.platformService.getApiVersion().pipe( switchMap((gnVersion) => { const fieldName = gnVersion.startsWith('4.2.2') ? 'OrgForResource' diff --git a/libs/api/repository/src/lib/gn4/platform/gn4-platform.mapper.ts b/libs/api/repository/src/lib/gn4/platform/gn4-platform.mapper.ts new file mode 100644 index 0000000000..bb34126673 --- /dev/null +++ b/libs/api/repository/src/lib/gn4/platform/gn4-platform.mapper.ts @@ -0,0 +1,42 @@ +import { + MeResponseApiModel, + UserApiModel, +} from '@geonetwork-ui/data-access/gn4' +import { UserModel } from '@geonetwork-ui/common/domain/model/user/user.model' +import { Injectable } from '@angular/core' +import { AvatarServiceInterface } from '../auth/avatar.service.interface' + +@Injectable() +export class Gn4PlatformMapper { + constructor(private avatarService: AvatarServiceInterface) {} + userFromMeApi(apiUser: MeResponseApiModel): UserModel { + if (!apiUser) return null + const { + hash, + groupsWithRegisteredUser, + groupsWithEditor, + groupsWithReviewer, + groupsWithUserAdmin, + admin, + ...user + } = apiUser + const icon = this.avatarService.getProfileIcon(hash) + return { ...user, profileIcon: icon } as UserModel + } + userFromApi(apiUser: UserApiModel): UserModel { + if (!apiUser) return null + const { + enabled, + emailAddresses, + organisation, + kind, + lastLoginDate, + accountNonExpired, + accountNonLocked, + id, + credentialsNonExpired, + ...user + } = apiUser + return { ...apiUser, id: id + '' } as UserModel + } +} diff --git a/libs/api/repository/src/lib/gn4/platform/gn4-platform.service.spec.ts b/libs/api/repository/src/lib/gn4/platform/gn4-platform.service.spec.ts new file mode 100644 index 0000000000..4d42efc935 --- /dev/null +++ b/libs/api/repository/src/lib/gn4/platform/gn4-platform.service.spec.ts @@ -0,0 +1,164 @@ +import { + MeApiService, + SiteApiService, + UsersApiService, +} from '@geonetwork-ui/data-access/gn4' +import { TestBed } from '@angular/core/testing' +import { Gn4PlatformService } from './gn4-platform.service' +import { firstValueFrom, lastValueFrom, of, Subject } from 'rxjs' +import { AvatarServiceInterface } from '../auth/avatar.service.interface' +import { Gn4PlatformMapper } from './gn4-platform.mapper' + +let geonetworkVersion: string + +const userMock = { + id: '21737', + profile: 'Administrator', + username: 'C2C-gravin', + name: 'Florent', + surname: 'Gravin', + email: 'florent.gravin@camptocamp.com', + hash: 'girafe', + organisation: null, + admin: true, + groupsWithRegisteredUser: [], + groupsWithEditor: [], + groupsWithReviewer: [], + groupsWithUserAdmin: [], +} + +class MeApiMock { + getMe() { + return this._me$ + } + _me$ = new Subject() +} + +class AvatarServiceInterfaceMock { + placeholder = 'http://placeholder.com' + getProfileIcon = jest.fn((hash: string) => `http://icon_service.com/${hash}`) +} + +class SiteApiServiceMock { + getSiteOrPortalDescription = jest.fn(() => + of({ + 'system/platform/version': geonetworkVersion, + }) + ) +} +class UsersApiServiceMock { + getUsers() { + return of([ + { + username: 'ken', + email: 'ken@sf2.com', + id: 1, + }, + { + username: 'ryu', + email: 'ryu@sf2.com', + id: 2, + }, + ]) + } +} + +describe('Gn4PlatformService', () => { + let service: Gn4PlatformService + let meApiService: MeApiService + + beforeEach(() => { + TestBed.configureTestingModule({ + providers: [ + Gn4PlatformService, + Gn4PlatformMapper, + { + provide: SiteApiService, + useClass: SiteApiServiceMock, + }, + { + provide: UsersApiService, + useClass: UsersApiServiceMock, + }, + { + provide: MeApiService, + useClass: MeApiMock, + }, + { + provide: AvatarServiceInterface, + useClass: AvatarServiceInterfaceMock, + }, + ], + }) + service = TestBed.inject(Gn4PlatformService) + meApiService = TestBed.inject(MeApiService) + }) + + it('creates', () => { + expect(service).toBeTruthy() + }) + + it('fetches version from settings', async () => { + geonetworkVersion = '4.2.0' + const version = await firstValueFrom(service.getApiVersion()) + expect(version).toEqual('4.2.0') + }) + it('fetches users from api', async () => { + const users = await firstValueFrom(service.getUsers()) + expect(users).toEqual([ + { + username: 'ken', + email: 'ken@sf2.com', + id: '1', + }, + { + username: 'ryu', + email: 'ryu@sf2.com', + id: '2', + }, + ]) + }) + it('is of type GeoNetwork', async () => { + expect(service.getType()).toEqual('GeoNetwork') + }) + describe('MeService', () => { + let me + beforeEach(() => { + service.getMe().subscribe((response) => (me = response)) + }) + describe('When user is logged in', () => { + beforeEach(() => { + ;(meApiService as any)._me$.next(userMock) + }) + it('returns mapped user ', async () => { + expect(me).toEqual({ + id: '21737', + profile: 'Administrator', + username: 'C2C-gravin', + name: 'Florent', + surname: 'Gravin', + email: 'florent.gravin@camptocamp.com', + profileIcon: 'http://icon_service.com/girafe', + organisation: null, + }) + }) + it('is not anonymous ', async () => { + const isAnonymous = await firstValueFrom(service.isAnonymous()) + expect(isAnonymous).toBe(false) + }) + }) + describe('When no user is logged in', () => { + beforeEach(() => { + ;(meApiService as any)._me$.next({}) + }) + it('returns no user ', async () => { + const me = await firstValueFrom(service.getMe()) + expect(me).toEqual({ profileIcon: 'http://icon_service.com/undefined' }) + }) + it('is anonymous ', async () => { + const isAnonymous = await firstValueFrom(service.isAnonymous()) + expect(isAnonymous).toBe(true) + }) + }) + }) +}) diff --git a/libs/api/repository/src/lib/gn4/platform/gn4-platform.service.ts b/libs/api/repository/src/lib/gn4/platform/gn4-platform.service.ts new file mode 100644 index 0000000000..5e4807ade3 --- /dev/null +++ b/libs/api/repository/src/lib/gn4/platform/gn4-platform.service.ts @@ -0,0 +1,88 @@ +import { Injectable } from '@angular/core' +import { Observable, of, switchMap } from 'rxjs' +import { map, shareReplay, tap } from 'rxjs/operators' +import { + MeApiService, + SiteApiService, + UsersApiService, +} from '@geonetwork-ui/data-access/gn4' +import { PlatformServiceInterface } from '@geonetwork-ui/common/domain/platform.service.interface' +import { UserModel } from '@geonetwork-ui/common/domain/model/user/user.model' +import { Organization } from '@geonetwork-ui/common/domain/model/record' +import { Gn4PlatformMapper } from './gn4-platform.mapper' + +const minApiVersion = '4.2.0' +@Injectable() +export class Gn4PlatformService implements PlatformServiceInterface { + private readonly type = 'GeoNetwork' + private me$: Observable + private users$: Observable + isAnonymous$: Observable + + private settings$ = of(true).pipe( + switchMap(() => this.siteApiService.getSiteOrPortalDescription()), + shareReplay(1) + ) + + private readonly apiVersion$ = this.settings$.pipe( + map((info) => info['system/platform/version'] as string), + shareReplay(1) + ) + + private readonly isApiCompatible$ = this.apiVersion$.pipe( + tap( + (version) => + version < minApiVersion && + console.warn(`The GeoNetwork Api version is too low ${version}`) + ), + map((version) => version >= minApiVersion) + ) + + constructor( + private siteApiService: SiteApiService, + private meApi: MeApiService, + private usersApi: UsersApiService, + private mapper: Gn4PlatformMapper + ) { + this.me$ = this.meApi.getMe().pipe( + map((apiUser) => this.mapper.userFromMeApi(apiUser)), + shareReplay({ bufferSize: 1, refCount: true }) + ) + this.isAnonymous$ = this.me$.pipe(map((user) => !user || !('id' in user))) + this.users$ = this.usersApi.getUsers().pipe( + map((users) => users.map((user) => this.mapper.userFromApi(user))), + shareReplay() + ) + } + + getType(): string { + return this.type + } + + getApiVersion(): Observable { + return this.apiVersion$ + } + isApiCompatible(): Observable { + return this.isApiCompatible$ + } + + getMe(): Observable { + return this.me$ + } + + isAnonymous(): Observable { + return this.isAnonymous$ + } + + getOrganizations(): Observable { + return undefined + } + + getUsersByOrganization(organisation: Organization): Observable { + return undefined + } + + getUsers(): Observable { + return this.users$ + } +} diff --git a/libs/api/repository/src/lib/gn4/selection/selection.service.spec.ts b/libs/api/repository/src/lib/gn4/selection/selection.service.spec.ts index 8df5a3f655..22fec4ffa4 100644 --- a/libs/api/repository/src/lib/gn4/selection/selection.service.spec.ts +++ b/libs/api/repository/src/lib/gn4/selection/selection.service.spec.ts @@ -1,7 +1,7 @@ import { SelectionsApiService } from '@geonetwork-ui/data-access/gn4' import { SelectionService } from './selection.service' import { firstValueFrom, of } from 'rxjs' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' function record(uuid: string): CatalogRecord { return { diff --git a/libs/api/repository/src/lib/gn4/selection/selection.service.ts b/libs/api/repository/src/lib/gn4/selection/selection.service.ts index 20113654a7..e2f3c3cd7d 100644 --- a/libs/api/repository/src/lib/gn4/selection/selection.service.ts +++ b/libs/api/repository/src/lib/gn4/selection/selection.service.ts @@ -1,5 +1,5 @@ import { Injectable } from '@angular/core' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' import { SelectionsApiService } from '@geonetwork-ui/data-access/gn4' import { BehaviorSubject, Observable, Subscription, map, tap } from 'rxjs' diff --git a/libs/common/domain/src/lib/dataviz-configuration.model.ts b/libs/common/domain/src/lib/model/dataviz/dataviz-configuration.model.ts similarity index 100% rename from libs/common/domain/src/lib/dataviz-configuration.model.ts rename to libs/common/domain/src/lib/model/dataviz/dataviz-configuration.model.ts diff --git a/libs/common/domain/src/lib/record/contact.model.ts b/libs/common/domain/src/lib/model/record/contact.model.ts similarity index 100% rename from libs/common/domain/src/lib/record/contact.model.ts rename to libs/common/domain/src/lib/model/record/contact.model.ts diff --git a/libs/common/domain/src/lib/record/index.ts b/libs/common/domain/src/lib/model/record/index.ts similarity index 100% rename from libs/common/domain/src/lib/record/index.ts rename to libs/common/domain/src/lib/model/record/index.ts diff --git a/libs/common/domain/src/lib/record/metadata.model.ts b/libs/common/domain/src/lib/model/record/metadata.model.ts similarity index 100% rename from libs/common/domain/src/lib/record/metadata.model.ts rename to libs/common/domain/src/lib/model/record/metadata.model.ts diff --git a/libs/common/domain/src/lib/record/organization.model.ts b/libs/common/domain/src/lib/model/record/organization.model.ts similarity index 100% rename from libs/common/domain/src/lib/record/organization.model.ts rename to libs/common/domain/src/lib/model/record/organization.model.ts diff --git a/libs/common/domain/src/lib/search/aggregation.model.ts b/libs/common/domain/src/lib/model/search/aggregation.model.ts similarity index 100% rename from libs/common/domain/src/lib/search/aggregation.model.ts rename to libs/common/domain/src/lib/model/search/aggregation.model.ts diff --git a/libs/common/domain/src/lib/search/filter.model.ts b/libs/common/domain/src/lib/model/search/filter.model.ts similarity index 100% rename from libs/common/domain/src/lib/search/filter.model.ts rename to libs/common/domain/src/lib/model/search/filter.model.ts diff --git a/libs/common/domain/src/lib/search/index.ts b/libs/common/domain/src/lib/model/search/index.ts similarity index 100% rename from libs/common/domain/src/lib/search/index.ts rename to libs/common/domain/src/lib/model/search/index.ts diff --git a/libs/common/domain/src/lib/search/search.model.ts b/libs/common/domain/src/lib/model/search/search.model.ts similarity index 100% rename from libs/common/domain/src/lib/search/search.model.ts rename to libs/common/domain/src/lib/model/search/search.model.ts diff --git a/libs/common/domain/src/lib/search/sort-by.model.ts b/libs/common/domain/src/lib/model/search/sort-by.model.ts similarity index 100% rename from libs/common/domain/src/lib/search/sort-by.model.ts rename to libs/common/domain/src/lib/model/search/sort-by.model.ts diff --git a/libs/common/domain/src/lib/user.model.ts b/libs/common/domain/src/lib/model/user/user.model.ts similarity index 100% rename from libs/common/domain/src/lib/user.model.ts rename to libs/common/domain/src/lib/model/user/user.model.ts diff --git a/libs/common/domain/src/lib/organizations.service.interface.ts b/libs/common/domain/src/lib/organizations.service.interface.ts index c415a0e5a5..75b023c8fb 100644 --- a/libs/common/domain/src/lib/organizations.service.interface.ts +++ b/libs/common/domain/src/lib/organizations.service.interface.ts @@ -1,7 +1,6 @@ import { Observable } from 'rxjs' -import { FieldFilters } from './search/filter.model' -import { Organization } from './record/organization.model' -import { BaseRecord, CatalogRecord } from './record/metadata.model' +import { BaseRecord, CatalogRecord, Organization } from './model/record' +import { FieldFilters } from './model/search' export abstract class OrganizationsServiceInterface { public abstract organisations$: Observable diff --git a/libs/common/domain/src/lib/platform.service.interface.ts b/libs/common/domain/src/lib/platform.service.interface.ts new file mode 100644 index 0000000000..7872c2d052 --- /dev/null +++ b/libs/common/domain/src/lib/platform.service.interface.ts @@ -0,0 +1,17 @@ +import { Observable } from 'rxjs' +import { UserModel } from './model/user/user.model' +import { Organization } from './model/record/organization.model' + +export abstract class PlatformServiceInterface { + abstract getType(): string + abstract getApiVersion(): Observable + abstract isApiCompatible(): Observable + + abstract getMe(): Observable + abstract isAnonymous(): Observable + abstract getUsers(): Observable + abstract getUsersByOrganization( + organisation: Organization + ): Observable + abstract getOrganizations(): Observable +} diff --git a/libs/common/domain/src/lib/records-repository.interface.ts b/libs/common/domain/src/lib/repository/records-repository.interface.ts similarity index 89% rename from libs/common/domain/src/lib/records-repository.interface.ts rename to libs/common/domain/src/lib/repository/records-repository.interface.ts index 7e0efada38..063873bc99 100644 --- a/libs/common/domain/src/lib/records-repository.interface.ts +++ b/libs/common/domain/src/lib/repository/records-repository.interface.ts @@ -5,8 +5,8 @@ import { FieldFilters, SearchParams, SearchResults, -} from './search' -import { CatalogRecord } from './record/metadata.model' +} from '../model/search' +import { CatalogRecord } from '../model/record' export abstract class RecordsRepositoryInterface { abstract search(params: SearchParams): Observable diff --git a/libs/common/fixtures/src/lib/link.fixtures.ts b/libs/common/fixtures/src/lib/link.fixtures.ts index bc875d57f8..7d1aa5014b 100644 --- a/libs/common/fixtures/src/lib/link.fixtures.ts +++ b/libs/common/fixtures/src/lib/link.fixtures.ts @@ -1,5 +1,5 @@ import { deepFreeze } from './utils/freeze' -import { DatasetDistribution } from '@geonetwork-ui/common/domain/record' +import { DatasetDistribution } from '@geonetwork-ui/common/domain/model/record' export const LINK_FIXTURES: Record = deepFreeze({ readmeLink: { diff --git a/libs/common/fixtures/src/lib/organisations.fixture.ts b/libs/common/fixtures/src/lib/organisations.fixture.ts index 833d53a5b7..d613bc2148 100644 --- a/libs/common/fixtures/src/lib/organisations.fixture.ts +++ b/libs/common/fixtures/src/lib/organisations.fixture.ts @@ -1,5 +1,5 @@ import { deepFreeze } from './utils/freeze' -import { Organization } from '@geonetwork-ui/common/domain/record' +import { Organization } from '@geonetwork-ui/common/domain/model/record' export const ORGANISATIONS_FIXTURE: Organization[] = deepFreeze([ { diff --git a/libs/common/fixtures/src/lib/records.fixtures.ts b/libs/common/fixtures/src/lib/records.fixtures.ts index 0c76cee7e3..5cfef15e19 100644 --- a/libs/common/fixtures/src/lib/records.fixtures.ts +++ b/libs/common/fixtures/src/lib/records.fixtures.ts @@ -1,4 +1,4 @@ -import { DatasetRecord } from '@geonetwork-ui/common/domain/record' +import { DatasetRecord } from '@geonetwork-ui/common/domain/model/record' import { deepFreeze } from './utils/freeze' export const DATASET_RECORDS: DatasetRecord[] = deepFreeze([ diff --git a/libs/common/fixtures/src/lib/repository.fixtures.ts b/libs/common/fixtures/src/lib/repository.fixtures.ts index 4c1d2a8b90..6f408a6524 100644 --- a/libs/common/fixtures/src/lib/repository.fixtures.ts +++ b/libs/common/fixtures/src/lib/repository.fixtures.ts @@ -1,5 +1,5 @@ import { deepFreeze } from './utils/freeze' -import { SearchResults } from '@geonetwork-ui/common/domain/search' +import { SearchResults } from '@geonetwork-ui/common/domain/model/search' import { DATASET_RECORDS } from './records.fixtures' export const SAMPLE_SEARCH_RESULTS: SearchResults = deepFreeze({ diff --git a/libs/common/fixtures/src/lib/search/aggregations.ts b/libs/common/fixtures/src/lib/search/aggregations.ts index 410a8b13f9..9f55a7c43f 100644 --- a/libs/common/fixtures/src/lib/search/aggregations.ts +++ b/libs/common/fixtures/src/lib/search/aggregations.ts @@ -3,7 +3,7 @@ import { AggregationParams, Aggregations, AggregationsParams, -} from '@geonetwork-ui/common/domain/search' +} from '@geonetwork-ui/common/domain/model/search' export const TERMS_AGGREGATION: AggregationParams = { type: 'terms', diff --git a/libs/common/fixtures/src/lib/user.fixtures.ts b/libs/common/fixtures/src/lib/user.fixtures.ts index 654fc14d21..9d55502797 100644 --- a/libs/common/fixtures/src/lib/user.fixtures.ts +++ b/libs/common/fixtures/src/lib/user.fixtures.ts @@ -1,4 +1,4 @@ -import { UserModel } from '@geonetwork-ui/common/domain/user.model' +import { UserModel } from '@geonetwork-ui/common/domain/model/user/user.model' export const USER_FIXTURE = (): UserModel => ({ id: '46798', diff --git a/libs/feature/catalog/src/lib/feature-catalog.module.ts b/libs/feature/catalog/src/lib/feature-catalog.module.ts index f7856b0b09..91862c7f73 100644 --- a/libs/feature/catalog/src/lib/feature-catalog.module.ts +++ b/libs/feature/catalog/src/lib/feature-catalog.module.ts @@ -21,6 +21,7 @@ import { OrganizationsFromMetadataService, OrganizationsStrategy, } from '@geonetwork-ui/api/repository/gn4' +import { PlatformServiceInterface } from '@geonetwork-ui/common/domain/platform.service.interface' // expects the replacement key ${name} export const ORGANIZATION_URL_TOKEN = new InjectionToken( @@ -33,7 +34,7 @@ const organizationsServiceFactory = ( searchApiService: SearchApiService, groupsApiService: GroupsApiService, translateService: TranslateService, - siteApiService: SiteApiService, + platformService: PlatformServiceInterface, langService: LangService ) => strategy === 'groups' @@ -47,7 +48,7 @@ const organizationsServiceFactory = ( esService, searchApiService, groupsApiService, - siteApiService, + platformService, langService ) @@ -76,7 +77,7 @@ const organizationsServiceFactory = ( SearchApiService, GroupsApiService, TranslateService, - SiteApiService, + PlatformServiceInterface, LangService, ], }, diff --git a/libs/feature/catalog/src/lib/my-org/my-org.service.spec.ts b/libs/feature/catalog/src/lib/my-org/my-org.service.spec.ts index e4def91fa1..824c64f1b0 100644 --- a/libs/feature/catalog/src/lib/my-org/my-org.service.spec.ts +++ b/libs/feature/catalog/src/lib/my-org/my-org.service.spec.ts @@ -1,13 +1,13 @@ import { TestBed } from '@angular/core/testing' import { MyOrgService } from './my-org.service' -import { AuthService } from '@geonetwork-ui/api/repository/gn4' +import { AvatarServiceInterface } from '@geonetwork-ui/api/repository/gn4' import { OrganizationsServiceInterface } from '@geonetwork-ui/common/domain/organizations.service.interface' -import { BehaviorSubject, Observable, of, Subject } from 'rxjs' +import { BehaviorSubject, of } from 'rxjs' import { UserApiModel } from '@geonetwork-ui/data-access/gn4' -import { UserModel } from '@geonetwork-ui/common/domain/user.model' +import { UserModel } from '@geonetwork-ui/common/domain/model/user/user.model' import { HttpClientTestingModule } from '@angular/common/http/testing' import { TranslateService } from '@ngx-translate/core' -import { AvatarServiceInterface } from '@geonetwork-ui/api/repository/gn4' +import { PlatformServiceInterface } from '@geonetwork-ui/common/domain/platform.service.interface' const translateServiceMock = { currentLang: 'fr', @@ -27,9 +27,16 @@ class orgServiceMock { organisations$ = orgs$ } +const userSubject = new BehaviorSubject(null) +const allUsersSubject = new BehaviorSubject([]) + +class PlatformServiceMock { + getMe = jest.fn(() => userSubject) + getUsers = jest.fn(() => allUsersSubject) +} + describe('MyOrgService', () => { let myOrgService: MyOrgService - let authService: AuthService let orgService: OrganizationsServiceInterface beforeEach(() => { @@ -45,12 +52,14 @@ describe('MyOrgService', () => { useClass: AvatarServiceInterfaceMock, }, { provide: OrganizationsServiceInterface, useClass: orgServiceMock }, - AuthService, + { + provide: PlatformServiceInterface, + useClass: PlatformServiceMock, + }, ], imports: [HttpClientTestingModule], }) myOrgService = TestBed.inject(MyOrgService) - authService = TestBed.inject(AuthService) orgService = TestBed.inject(OrganizationsServiceInterface) }) @@ -59,7 +68,6 @@ describe('MyOrgService', () => { }) it('should update myOrgDataSubject when authService user$ emits a user', () => { - const userSubject = new BehaviorSubject(null) const user: UserModel = { organisation: 'Géo2France', id: '2', @@ -70,7 +78,6 @@ describe('MyOrgService', () => { email: 'email@email', profileIcon: 'icon.com', } - authService.user$ = userSubject.asObservable() userSubject.next(user) @@ -96,13 +103,10 @@ describe('MyOrgService', () => { }) it('should update myOrgDataSubject when authService allUsers$ emits users', () => { - const allUsersSubject = new BehaviorSubject([]) const users: UserApiModel[] = [ { organisation: 'Géo2France' }, { organisation: 'Géo2France' }, ] - authService.allUsers$ = allUsersSubject.asObservable() - allUsersSubject.next(users) myOrgService.myOrgData$.subscribe((data) => { diff --git a/libs/feature/catalog/src/lib/my-org/my-org.service.ts b/libs/feature/catalog/src/lib/my-org/my-org.service.ts index 1161cfa0c8..d01f743a6f 100644 --- a/libs/feature/catalog/src/lib/my-org/my-org.service.ts +++ b/libs/feature/catalog/src/lib/my-org/my-org.service.ts @@ -1,8 +1,8 @@ import { Injectable } from '@angular/core' import { OrganizationsServiceInterface } from '@geonetwork-ui/common/domain/organizations.service.interface' -import { AuthService } from '@geonetwork-ui/api/repository/gn4' import { BehaviorSubject, combineLatest, map, Observable } from 'rxjs' -import { UserApiModel } from '@geonetwork-ui/data-access/gn4' +import { UserModel } from '@geonetwork-ui/common/domain/model/user/user.model' +import { PlatformServiceInterface } from '@geonetwork-ui/common/domain/platform.service.interface' @Injectable({ providedIn: 'root', @@ -13,7 +13,7 @@ export class MyOrgService { logoUrl: string recordCount: number userCount: number - userList: UserApiModel[] + userList: UserModel[] }> private myOrgDataSubject = new BehaviorSubject<{ @@ -21,7 +21,7 @@ export class MyOrgService { logoUrl: string recordCount: number userCount: number - userList: UserApiModel[] + userList: UserModel[] }>({ orgName: '', logoUrl: '', @@ -31,12 +31,12 @@ export class MyOrgService { }) constructor( - private authService: AuthService, + private platformService: PlatformServiceInterface, private orgService: OrganizationsServiceInterface ) { this.myOrgData$ = combineLatest([ - this.authService.user$, - this.authService.allUsers$, + this.platformService.getMe(), + this.platformService.getUsers(), this.orgService.organisations$, ]).pipe( map(([user, allUsers, orgs]) => { diff --git a/libs/feature/catalog/src/lib/organisations/organisations.component.spec.ts b/libs/feature/catalog/src/lib/organisations/organisations.component.spec.ts index d5ef56539e..87708db479 100644 --- a/libs/feature/catalog/src/lib/organisations/organisations.component.spec.ts +++ b/libs/feature/catalog/src/lib/organisations/organisations.component.spec.ts @@ -9,7 +9,7 @@ import { import { ComponentFixture, TestBed } from '@angular/core/testing' import { By } from '@angular/platform-browser' import { ContentGhostComponent } from '@geonetwork-ui/ui/elements' -import { Organization } from '@geonetwork-ui/common/domain/record' +import { Organization } from '@geonetwork-ui/common/domain/model/record' import { firstValueFrom, of } from 'rxjs' import { ORGANISATIONS_FIXTURE } from '@geonetwork-ui/common/fixtures' import { OrganisationsComponent } from './organisations.component' diff --git a/libs/feature/catalog/src/lib/organisations/organisations.component.ts b/libs/feature/catalog/src/lib/organisations/organisations.component.ts index 5905e2a19e..79d1c3e25c 100644 --- a/libs/feature/catalog/src/lib/organisations/organisations.component.ts +++ b/libs/feature/catalog/src/lib/organisations/organisations.component.ts @@ -7,12 +7,12 @@ import { Optional, Output, } from '@angular/core' -import { Organization } from '@geonetwork-ui/common/domain/record' +import { Organization } from '@geonetwork-ui/common/domain/model/record' import { BehaviorSubject, combineLatest, Observable } from 'rxjs' import { map, startWith, tap } from 'rxjs/operators' import { ORGANIZATION_URL_TOKEN } from '../feature-catalog.module' import { OrganizationsServiceInterface } from '@geonetwork-ui/common/domain/organizations.service.interface' -import { SortByField } from '@geonetwork-ui/common/domain/search' +import { SortByField } from '@geonetwork-ui/common/domain/model/search' @Component({ selector: 'gn-ui-organisations', diff --git a/libs/feature/catalog/src/lib/records/records.service.spec.ts b/libs/feature/catalog/src/lib/records/records.service.spec.ts index 2b0b6f4d6b..be91cb1cb2 100644 --- a/libs/feature/catalog/src/lib/records/records.service.spec.ts +++ b/libs/feature/catalog/src/lib/records/records.service.spec.ts @@ -1,6 +1,6 @@ import { RecordsService } from './records.service' import { of, throwError } from 'rxjs' -import { RecordsRepositoryInterface } from '@geonetwork-ui/common/domain/records-repository.interface' +import { RecordsRepositoryInterface } from '@geonetwork-ui/common/domain/repository/records-repository.interface' class RecordsRepositoryMock { getMatchesCount = jest.fn(() => of(123)) diff --git a/libs/feature/catalog/src/lib/records/records.service.ts b/libs/feature/catalog/src/lib/records/records.service.ts index deb144f961..1d435aa47b 100644 --- a/libs/feature/catalog/src/lib/records/records.service.ts +++ b/libs/feature/catalog/src/lib/records/records.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core' import { Observable, of } from 'rxjs' import { catchError, shareReplay } from 'rxjs/operators' -import { RecordsRepositoryInterface } from '@geonetwork-ui/common/domain/records-repository.interface' +import { RecordsRepositoryInterface } from '@geonetwork-ui/common/domain/repository/records-repository.interface' @Injectable({ providedIn: 'root', diff --git a/libs/feature/dataviz/src/lib/chart-view/chart-view.component.ts b/libs/feature/dataviz/src/lib/chart-view/chart-view.component.ts index 2deda3803b..24d24f9f72 100644 --- a/libs/feature/dataviz/src/lib/chart-view/chart-view.component.ts +++ b/libs/feature/dataviz/src/lib/chart-view/chart-view.component.ts @@ -24,8 +24,8 @@ import { tap, } from 'rxjs/operators' import { DataService } from '../service/data.service' -import { InputChartType } from '@geonetwork-ui/common/domain/dataviz-configuration.model' -import { DatasetDistribution } from '@geonetwork-ui/common/domain/record' +import { InputChartType } from '@geonetwork-ui/common/domain/model/dataviz/dataviz-configuration.model' +import { DatasetDistribution } from '@geonetwork-ui/common/domain/model/record' import { TranslateService } from '@ngx-translate/core' marker('chart.type.bar') diff --git a/libs/feature/dataviz/src/lib/service/data.service.ts b/libs/feature/dataviz/src/lib/service/data.service.ts index a8f7cb2b99..66dce6ce87 100644 --- a/libs/feature/dataviz/src/lib/service/data.service.ts +++ b/libs/feature/dataviz/src/lib/service/data.service.ts @@ -20,7 +20,7 @@ import { catchError, map, switchMap, tap } from 'rxjs/operators' import { DatasetDistribution, DatasetServiceDistribution, -} from '@geonetwork-ui/common/domain/record' +} from '@geonetwork-ui/common/domain/model/record' marker('wfs.unreachable.cors') marker('wfs.unreachable.http') diff --git a/libs/feature/dataviz/src/lib/table-view/table-view.component.ts b/libs/feature/dataviz/src/lib/table-view/table-view.component.ts index 836c802741..576c57f780 100644 --- a/libs/feature/dataviz/src/lib/table-view/table-view.component.ts +++ b/libs/feature/dataviz/src/lib/table-view/table-view.component.ts @@ -11,7 +11,7 @@ import { import { DataItem, FetchError } from '@geonetwork-ui/data-fetcher' import { DataService } from '../service/data.service' import { TableItemModel } from '@geonetwork-ui/ui/dataviz' -import { DatasetDistribution } from '@geonetwork-ui/common/domain/record' +import { DatasetDistribution } from '@geonetwork-ui/common/domain/model/record' import { TranslateService } from '@ngx-translate/core' @Component({ diff --git a/libs/feature/editor/src/lib/services/editor.service.spec.ts b/libs/feature/editor/src/lib/services/editor.service.spec.ts index 6283564334..d6eb6b9eb6 100644 --- a/libs/feature/editor/src/lib/services/editor.service.spec.ts +++ b/libs/feature/editor/src/lib/services/editor.service.spec.ts @@ -4,7 +4,7 @@ import { HttpClientTestingModule, HttpTestingController, } from '@angular/common/http/testing' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' import { firstValueFrom } from 'rxjs' const SAMPLE_RECORD: CatalogRecord = { diff --git a/libs/feature/editor/src/lib/services/editor.service.ts b/libs/feature/editor/src/lib/services/editor.service.ts index aa3dbb1f08..c6987567ab 100644 --- a/libs/feature/editor/src/lib/services/editor.service.ts +++ b/libs/feature/editor/src/lib/services/editor.service.ts @@ -5,7 +5,7 @@ import { BehaviorSubject, Observable } from 'rxjs' import { finalize, map, switchMap, take, tap } from 'rxjs/operators' import { HttpClient } from '@angular/common/http' import { FormFieldConfig } from '@geonetwork-ui/ui/inputs' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' export interface FormField { config: FormFieldConfig diff --git a/libs/feature/map/src/lib/add-layer-from-catalog/add-layer-record-preview/add-layer-record-preview.component.ts b/libs/feature/map/src/lib/add-layer-from-catalog/add-layer-record-preview/add-layer-record-preview.component.ts index 4d5520fafd..07bc6804a1 100644 --- a/libs/feature/map/src/lib/add-layer-from-catalog/add-layer-record-preview/add-layer-record-preview.component.ts +++ b/libs/feature/map/src/lib/add-layer-from-catalog/add-layer-record-preview/add-layer-record-preview.component.ts @@ -16,7 +16,7 @@ import { import { DatasetDistribution, DatasetRecord, -} from '@geonetwork-ui/common/domain/record' +} from '@geonetwork-ui/common/domain/model/record' @Component({ selector: 'gn-ui-add-layer-record-preview', diff --git a/libs/feature/map/src/lib/utils/map-utils.service.spec.ts b/libs/feature/map/src/lib/utils/map-utils.service.spec.ts index 96a2230581..14b1014b0c 100644 --- a/libs/feature/map/src/lib/utils/map-utils.service.spec.ts +++ b/libs/feature/map/src/lib/utils/map-utils.service.spec.ts @@ -25,7 +25,7 @@ import { MouseWheelZoom, PinchRotate, } from 'ol/interaction' -import { DatasetServiceDistribution } from '@geonetwork-ui/common/domain/record' +import { DatasetServiceDistribution } from '@geonetwork-ui/common/domain/model/record' import MapBrowserEvent from 'ol/MapBrowserEvent' const wmsUtilsMock = { diff --git a/libs/feature/map/src/lib/utils/map-utils.service.ts b/libs/feature/map/src/lib/utils/map-utils.service.ts index 486e3074d7..c90e6be388 100644 --- a/libs/feature/map/src/lib/utils/map-utils.service.ts +++ b/libs/feature/map/src/lib/utils/map-utils.service.ts @@ -27,7 +27,7 @@ import { MapContextLayerModel } from '../map-context/map-context.model' import { MapUtilsWMSService } from './map-utils-wms.service' import Collection from 'ol/Collection' import MapBrowserEvent from 'ol/MapBrowserEvent' -import { DatasetDistribution } from '@geonetwork-ui/common/domain/record' +import { DatasetDistribution } from '@geonetwork-ui/common/domain/model/record' const FEATURE_PROJECTION = 'EPSG:3857' const DATA_PROJECTION = 'EPSG:4326' diff --git a/libs/feature/record/src/lib/data-view/data-view.component.spec.ts b/libs/feature/record/src/lib/data-view/data-view.component.spec.ts index 170845356a..cb504a4f84 100644 --- a/libs/feature/record/src/lib/data-view/data-view.component.spec.ts +++ b/libs/feature/record/src/lib/data-view/data-view.component.spec.ts @@ -10,8 +10,8 @@ import { BehaviorSubject, Subject } from 'rxjs' import { MdViewFacade } from '../state' import { DataViewComponent } from './data-view.component' import { TranslateModule } from '@ngx-translate/core' -import { DatavizConfigurationModel } from '@geonetwork-ui/common/domain/dataviz-configuration.model' -import { DatasetDistribution } from '@geonetwork-ui/common/domain/record' +import { DatavizConfigurationModel } from '@geonetwork-ui/common/domain/model/dataviz/dataviz-configuration.model' +import { DatasetDistribution } from '@geonetwork-ui/common/domain/model/record' import { LINK_FIXTURES } from '@geonetwork-ui/common/fixtures' const DATALINKS_FIXTURE: DatasetDistribution[] = [ diff --git a/libs/feature/record/src/lib/data-view/data-view.component.ts b/libs/feature/record/src/lib/data-view/data-view.component.ts index 95fb586b56..1e8df07b26 100644 --- a/libs/feature/record/src/lib/data-view/data-view.component.ts +++ b/libs/feature/record/src/lib/data-view/data-view.component.ts @@ -8,8 +8,8 @@ import { getLinkLabel, getLinkPriority } from '@geonetwork-ui/util/shared' import { BehaviorSubject, combineLatest } from 'rxjs' import { map, tap } from 'rxjs/operators' import { MdViewFacade } from '../state' -import { DatavizConfigurationModel } from '@geonetwork-ui/common/domain/dataviz-configuration.model' -import { DatasetDistribution } from '@geonetwork-ui/common/domain/record' +import { DatavizConfigurationModel } from '@geonetwork-ui/common/domain/model/dataviz/dataviz-configuration.model' +import { DatasetDistribution } from '@geonetwork-ui/common/domain/model/record' @Component({ selector: 'gn-ui-data-view', diff --git a/libs/feature/record/src/lib/external-viewer-button/external-viewer-button.component.ts b/libs/feature/record/src/lib/external-viewer-button/external-viewer-button.component.ts index 6328f81e42..9724ffcd44 100644 --- a/libs/feature/record/src/lib/external-viewer-button/external-viewer-button.component.ts +++ b/libs/feature/record/src/lib/external-viewer-button/external-viewer-button.component.ts @@ -1,6 +1,6 @@ import { ChangeDetectionStrategy, Component, Input } from '@angular/core' import { MapConfig } from '@geonetwork-ui/util/app-config' -import { DatasetDistribution } from '@geonetwork-ui/common/domain/record' +import { DatasetDistribution } from '@geonetwork-ui/common/domain/model/record' @Component({ selector: 'gn-ui-external-viewer-button', diff --git a/libs/feature/record/src/lib/map-view/map-view.component.spec.ts b/libs/feature/record/src/lib/map-view/map-view.component.spec.ts index a2f4e83ab1..a056787d47 100644 --- a/libs/feature/record/src/lib/map-view/map-view.component.spec.ts +++ b/libs/feature/record/src/lib/map-view/map-view.component.spec.ts @@ -39,7 +39,7 @@ import { FEATURE_COLLECTION_POINT_FIXTURE_4326 } from '@geonetwork-ui/common/fix import { Collection } from 'ol' import { Interaction } from 'ol/interaction' import { DataService } from '@geonetwork-ui/feature/dataviz' -import { DatasetDistribution } from '@geonetwork-ui/common/domain/record' +import { DatasetDistribution } from '@geonetwork-ui/common/domain/model/record' const mapConfigMock = { MAX_ZOOM: 10, diff --git a/libs/feature/record/src/lib/map-view/map-view.component.ts b/libs/feature/record/src/lib/map-view/map-view.component.ts index a3b21e44d2..e638a14263 100644 --- a/libs/feature/record/src/lib/map-view/map-view.component.ts +++ b/libs/feature/record/src/lib/map-view/map-view.component.ts @@ -37,7 +37,7 @@ import { } from 'rxjs/operators' import { MdViewFacade } from '../state/mdview.facade' import { DataService } from '@geonetwork-ui/feature/dataviz' -import { DatasetDistribution } from '@geonetwork-ui/common/domain/record' +import { DatasetDistribution } from '@geonetwork-ui/common/domain/model/record' @Component({ selector: 'gn-ui-map-view', diff --git a/libs/feature/record/src/lib/state/mdview.actions.ts b/libs/feature/record/src/lib/state/mdview.actions.ts index f5dfab6bce..9b2172888c 100644 --- a/libs/feature/record/src/lib/state/mdview.actions.ts +++ b/libs/feature/record/src/lib/state/mdview.actions.ts @@ -1,6 +1,6 @@ -import { DatavizConfigurationModel } from '@geonetwork-ui/common/domain/dataviz-configuration.model' +import { DatavizConfigurationModel } from '@geonetwork-ui/common/domain/model/dataviz/dataviz-configuration.model' import { createAction, props } from '@ngrx/store' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' export const loadFullMetadata = createAction( '[Metadata view] Load full metadata', diff --git a/libs/feature/record/src/lib/state/mdview.effects.spec.ts b/libs/feature/record/src/lib/state/mdview.effects.spec.ts index 4db350d295..23b11a8804 100644 --- a/libs/feature/record/src/lib/state/mdview.effects.spec.ts +++ b/libs/feature/record/src/lib/state/mdview.effects.spec.ts @@ -13,8 +13,8 @@ import { Observable, of, throwError } from 'rxjs' import * as MdViewActions from './mdview.actions' import { MdViewEffects } from './mdview.effects' import { hot } from 'jasmine-marbles' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' -import { RecordsRepositoryInterface } from '@geonetwork-ui/common/domain/records-repository.interface' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' +import { RecordsRepositoryInterface } from '@geonetwork-ui/common/domain/repository/records-repository.interface' const full = { uniqueIdentifier: '1231321321', diff --git a/libs/feature/record/src/lib/state/mdview.effects.ts b/libs/feature/record/src/lib/state/mdview.effects.ts index 59e308547a..66893f90f4 100644 --- a/libs/feature/record/src/lib/state/mdview.effects.ts +++ b/libs/feature/record/src/lib/state/mdview.effects.ts @@ -3,7 +3,7 @@ import { Actions, createEffect, ofType } from '@ngrx/effects' import { of } from 'rxjs' import { catchError, map, switchMap } from 'rxjs/operators' import * as MdViewActions from './mdview.actions' -import { RecordsRepositoryInterface } from '@geonetwork-ui/common/domain/records-repository.interface' +import { RecordsRepositoryInterface } from '@geonetwork-ui/common/domain/repository/records-repository.interface' @Injectable() export class MdViewEffects { diff --git a/libs/feature/record/src/lib/state/mdview.facade.ts b/libs/feature/record/src/lib/state/mdview.facade.ts index 04ceade50d..a2e4a0064f 100644 --- a/libs/feature/record/src/lib/state/mdview.facade.ts +++ b/libs/feature/record/src/lib/state/mdview.facade.ts @@ -4,8 +4,8 @@ import { filter, map } from 'rxjs/operators' import * as MdViewActions from './mdview.actions' import * as MdViewSelectors from './mdview.selectors' import { LinkClassifierService, LinkUsage } from '@geonetwork-ui/util/shared' -import { DatavizConfigurationModel } from '@geonetwork-ui/common/domain/dataviz-configuration.model' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' +import { DatavizConfigurationModel } from '@geonetwork-ui/common/domain/model/dataviz/dataviz-configuration.model' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' @Injectable() /** diff --git a/libs/feature/record/src/lib/state/mdview.reducer.ts b/libs/feature/record/src/lib/state/mdview.reducer.ts index 2689d0108c..02fe1dbfb7 100644 --- a/libs/feature/record/src/lib/state/mdview.reducer.ts +++ b/libs/feature/record/src/lib/state/mdview.reducer.ts @@ -1,7 +1,7 @@ import { Action, createReducer, on } from '@ngrx/store' import * as MdViewActions from './mdview.actions' -import { DatavizConfigurationModel } from '@geonetwork-ui/common/domain/dataviz-configuration.model' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' +import { DatavizConfigurationModel } from '@geonetwork-ui/common/domain/model/dataviz/dataviz-configuration.model' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' export const MD_VIEW_FEATURE_STATE_KEY = 'mdView' diff --git a/libs/feature/router/src/lib/default/services/router-search.service.spec.ts b/libs/feature/router/src/lib/default/services/router-search.service.spec.ts index edd7301fe8..c9f7446bd3 100644 --- a/libs/feature/router/src/lib/default/services/router-search.service.spec.ts +++ b/libs/feature/router/src/lib/default/services/router-search.service.spec.ts @@ -1,5 +1,8 @@ import { FieldsService, SearchFacade } from '@geonetwork-ui/feature/search' -import { SortByEnum, SortByField } from '@geonetwork-ui/common/domain/search' +import { + SortByEnum, + SortByField, +} from '@geonetwork-ui/common/domain/model/search' import { BehaviorSubject, of } from 'rxjs' import { RouterFacade } from '../state' import { RouterSearchService } from './router-search.service' diff --git a/libs/feature/router/src/lib/default/services/router-search.service.ts b/libs/feature/router/src/lib/default/services/router-search.service.ts index 4b41664f19..c6375a0d70 100644 --- a/libs/feature/router/src/lib/default/services/router-search.service.ts +++ b/libs/feature/router/src/lib/default/services/router-search.service.ts @@ -4,7 +4,10 @@ import { SearchFacade, SearchServiceI, } from '@geonetwork-ui/feature/search' -import { FieldFilters, SortByField } from '@geonetwork-ui/common/domain/search' +import { + FieldFilters, + SortByField, +} from '@geonetwork-ui/common/domain/model/search' import { ROUTE_PARAMS, SearchRouteParams } from '../constants' import { RouterFacade } from '../state/router.facade' import { firstValueFrom } from 'rxjs' diff --git a/libs/feature/router/src/lib/default/state/router.effects.ts b/libs/feature/router/src/lib/default/state/router.effects.ts index 41c16ed7a9..822b6c9a2b 100644 --- a/libs/feature/router/src/lib/default/state/router.effects.ts +++ b/libs/feature/router/src/lib/default/state/router.effects.ts @@ -9,7 +9,10 @@ import { SetFilters, SetSortBy, } from '@geonetwork-ui/feature/search' -import { FieldFilters, SortByEnum } from '@geonetwork-ui/common/domain/search' +import { + FieldFilters, + SortByEnum, +} from '@geonetwork-ui/common/domain/model/search' import { Actions, createEffect, ofType } from '@ngrx/effects' import { navigation } from '@ngrx/router-store/data-persistence' import { of, pairwise, startWith, withLatestFrom } from 'rxjs' diff --git a/libs/feature/router/src/lib/default/state/router.facade.ts b/libs/feature/router/src/lib/default/state/router.facade.ts index 7012d3dd9c..a8e6ddfe40 100644 --- a/libs/feature/router/src/lib/default/state/router.facade.ts +++ b/libs/feature/router/src/lib/default/state/router.facade.ts @@ -16,7 +16,7 @@ import { RouterGoActionPayload, } from './router.actions' import { selectCurrentRoute, selectRouteParams } from './router.selectors' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' @Injectable() export class RouterFacade { diff --git a/libs/feature/search/src/lib/constants.ts b/libs/feature/search/src/lib/constants.ts index 72ff6f05ae..28c3d59cb0 100644 --- a/libs/feature/search/src/lib/constants.ts +++ b/libs/feature/search/src/lib/constants.ts @@ -1,4 +1,4 @@ -import { FieldName } from '@geonetwork-ui/common/domain/search' +import { FieldName } from '@geonetwork-ui/common/domain/model/search' export const DEFAULT_PAGE_SIZE = 10 diff --git a/libs/feature/search/src/lib/facets/facets-container/facets-container.component.ts b/libs/feature/search/src/lib/facets/facets-container/facets-container.component.ts index 8b2789bbfd..bd9482251a 100644 --- a/libs/feature/search/src/lib/facets/facets-container/facets-container.component.ts +++ b/libs/feature/search/src/lib/facets/facets-container/facets-container.component.ts @@ -5,7 +5,7 @@ import { map, take } from 'rxjs/operators' import { SearchFacade } from '../../state/search.facade' import { FacetsService } from '../facets.service' import { marker } from '@biesbjerg/ngx-translate-extract-marker' -import { FieldFilters } from '@geonetwork-ui/common/domain/search' +import { FieldFilters } from '@geonetwork-ui/common/domain/model/search' import { EsRequestAggTerm } from '@geonetwork-ui/api/metadata-converter' marker('facets.block.title.OrgForResource') diff --git a/libs/feature/search/src/lib/facets/facets.service.ts b/libs/feature/search/src/lib/facets/facets.service.ts index 367445877d..e528f27d63 100644 --- a/libs/feature/search/src/lib/facets/facets.service.ts +++ b/libs/feature/search/src/lib/facets/facets.service.ts @@ -1,7 +1,10 @@ import { Injectable } from '@angular/core' import { LogService, parse, PARSE_DELIMITER } from '@geonetwork-ui/util/shared' import { FacetPath, ModelBlock, ModelItem } from '@geonetwork-ui/ui/search' -import { FieldFilter, FieldFilters } from '@geonetwork-ui/common/domain/search' +import { + FieldFilter, + FieldFilters, +} from '@geonetwork-ui/common/domain/model/search' @Injectable({ providedIn: 'root', diff --git a/libs/feature/search/src/lib/favorites/favorite-star/favorite-star.component.spec.ts b/libs/feature/search/src/lib/favorites/favorite-star/favorite-star.component.spec.ts index 156c66f26f..c123fe48ff 100644 --- a/libs/feature/search/src/lib/favorites/favorite-star/favorite-star.component.spec.ts +++ b/libs/feature/search/src/lib/favorites/favorite-star/favorite-star.component.spec.ts @@ -7,14 +7,13 @@ import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core' import { TranslateModule, TranslateService } from '@ngx-translate/core' import tippy from 'tippy.js' import { DATASET_RECORDS } from '@geonetwork-ui/common/fixtures' -import { - AuthService, - FavoritesService, -} from '@geonetwork-ui/api/repository/gn4' +import { FavoritesService } from '@geonetwork-ui/api/repository/gn4' +import { PlatformServiceInterface } from '@geonetwork-ui/common/domain/platform.service.interface' tippy = jest.fn() -class AuthServiceMock { - isAnonymous$ = new BehaviorSubject(false) +const isAnonymous$ = new BehaviorSubject(false) +class PlatformServiceMock { + isAnonymous = jest.fn(() => isAnonymous$) } class FavoritesServiceMock { @@ -31,7 +30,7 @@ class TranslateServiceMock { describe('FavoriteStarComponent', () => { let component: FavoriteStarComponent let fixture: ComponentFixture - let authService: AuthService + let platformService: PlatformServiceInterface let favoritesService: FavoritesService let favoriteCountHTMLEl: HTMLElement let starToggle: StarToggleComponent @@ -42,8 +41,8 @@ describe('FavoriteStarComponent', () => { imports: [TranslateModule.forRoot()], providers: [ { - provide: AuthService, - useClass: AuthServiceMock, + provide: PlatformServiceInterface, + useClass: PlatformServiceMock, }, { provide: FavoritesService, @@ -63,7 +62,7 @@ describe('FavoriteStarComponent', () => { }) .compileComponents() - authService = TestBed.inject(AuthService) + platformService = TestBed.inject(PlatformServiceInterface) favoritesService = TestBed.inject(FavoritesService) fixture = TestBed.createComponent(FavoriteStarComponent) component = fixture.componentInstance @@ -120,7 +119,7 @@ describe('FavoriteStarComponent', () => { }) describe('when not authenticated', () => { beforeEach(() => { - ;(authService as any).isAnonymous$.next(true) + isAnonymous$.next(true) fixture.detectChanges() }) it('star toggle is disabled', () => { @@ -194,7 +193,7 @@ describe('FavoriteStarComponent', () => { }) it('increase record favorite count by one', () => { expect(favoriteCountHTMLEl.textContent).toEqual( - (component.record.extras.favoriteCount + 1).toString() + ((component.record.extras.favoriteCount as number) + 1).toString() ) }) }) diff --git a/libs/feature/search/src/lib/favorites/favorite-star/favorite-star.component.ts b/libs/feature/search/src/lib/favorites/favorite-star/favorite-star.component.ts index 7b1a4b420c..ddc2b9186a 100644 --- a/libs/feature/search/src/lib/favorites/favorite-star/favorite-star.component.ts +++ b/libs/feature/search/src/lib/favorites/favorite-star/favorite-star.component.ts @@ -13,11 +13,12 @@ import tippy from 'tippy.js' import { TranslateService } from '@ngx-translate/core' import { StarToggleComponent } from '@geonetwork-ui/ui/inputs' import { Observable, Subscription } from 'rxjs' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' import { AuthService, FavoritesService, } from '@geonetwork-ui/api/repository/gn4' +import { PlatformServiceInterface } from '@geonetwork-ui/common/domain/platform.service.interface' @Component({ selector: 'gn-ui-favorite-star', @@ -39,7 +40,7 @@ export class FavoriteStarComponent implements AfterViewInit, OnDestroy { isFavorite$ = this.favoritesService.myFavoritesUuid$.pipe( map((favorites) => favorites.indexOf(this.record.uniqueIdentifier) > -1) ) - isAnonymous$ = this.authService.isAnonymous$ + isAnonymous$ = this.platformService.isAnonymous() record_: CatalogRecord favoriteCount: number | null loading = false @@ -61,8 +62,9 @@ export class FavoriteStarComponent implements AfterViewInit, OnDestroy { constructor( private favoritesService: FavoritesService, - private authService: AuthService, + private platformService: PlatformServiceInterface, private changeDetector: ChangeDetectorRef, + private authService: AuthService, private translateService: TranslateService ) {} diff --git a/libs/feature/search/src/lib/feature-search.module.ts b/libs/feature/search/src/lib/feature-search.module.ts index eecd3c8ab5..92203f0904 100644 --- a/libs/feature/search/src/lib/feature-search.module.ts +++ b/libs/feature/search/src/lib/feature-search.module.ts @@ -22,7 +22,7 @@ import { MatIconModule } from '@angular/material/icon' import { FilterDropdownComponent } from './filter-dropdown/filter-dropdown.component' import { Geometry } from 'geojson' import { UiWidgetsModule } from '@geonetwork-ui/ui/widgets' -import { RecordsRepositoryInterface } from '@geonetwork-ui/common/domain/records-repository.interface' +import { RecordsRepositoryInterface } from '@geonetwork-ui/common/domain/repository/records-repository.interface' import { Gn4Repository } from '@geonetwork-ui/api/repository/gn4' // this geometry will be used to filter & boost results accordingly diff --git a/libs/feature/search/src/lib/fuzzy-search/fuzzy-search.component.spec.ts b/libs/feature/search/src/lib/fuzzy-search/fuzzy-search.component.spec.ts index b4f31ca72a..4928fbe9ef 100644 --- a/libs/feature/search/src/lib/fuzzy-search/fuzzy-search.component.spec.ts +++ b/libs/feature/search/src/lib/fuzzy-search/fuzzy-search.component.spec.ts @@ -6,12 +6,12 @@ import { BehaviorSubject, of } from 'rxjs' import { SearchFacade } from '../state/search.facade' import { SearchService } from '../utils/service/search.service' import { FuzzySearchComponent } from './fuzzy-search.component' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' import { DATASET_RECORDS, SAMPLE_SEARCH_RESULTS, } from '@geonetwork-ui/common/fixtures' -import { RecordsRepositoryInterface } from '@geonetwork-ui/common/domain/records-repository.interface' +import { RecordsRepositoryInterface } from '@geonetwork-ui/common/domain/repository/records-repository.interface' class SearchFacadeMock { setFilters = jest.fn() diff --git a/libs/feature/search/src/lib/fuzzy-search/fuzzy-search.component.ts b/libs/feature/search/src/lib/fuzzy-search/fuzzy-search.component.ts index 5177aad279..0fc610446f 100644 --- a/libs/feature/search/src/lib/fuzzy-search/fuzzy-search.component.ts +++ b/libs/feature/search/src/lib/fuzzy-search/fuzzy-search.component.ts @@ -15,8 +15,8 @@ import { Observable } from 'rxjs' import { map } from 'rxjs/operators' import { SearchFacade } from '../state/search.facade' import { SearchService } from '../utils/service/search.service' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' -import { RecordsRepositoryInterface } from '@geonetwork-ui/common/domain/records-repository.interface' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' +import { RecordsRepositoryInterface } from '@geonetwork-ui/common/domain/repository/records-repository.interface' @Component({ selector: 'gn-ui-fuzzy-search', diff --git a/libs/feature/search/src/lib/records-metrics/records-metrics.component.spec.ts b/libs/feature/search/src/lib/records-metrics/records-metrics.component.spec.ts index 6f14be4022..773d909807 100644 --- a/libs/feature/search/src/lib/records-metrics/records-metrics.component.spec.ts +++ b/libs/feature/search/src/lib/records-metrics/records-metrics.component.spec.ts @@ -7,7 +7,7 @@ import { SAMPLE_AGGREGATIONS_RESULTS, } from '@geonetwork-ui/common/fixtures' import { of } from 'rxjs' -import { RecordsRepositoryInterface } from '@geonetwork-ui/common/domain/records-repository.interface' +import { RecordsRepositoryInterface } from '@geonetwork-ui/common/domain/repository/records-repository.interface' class RecordsRepositoryMock { aggregate = jest.fn(() => of(SAMPLE_AGGREGATIONS_RESULTS)) diff --git a/libs/feature/search/src/lib/records-metrics/records-metrics.component.ts b/libs/feature/search/src/lib/records-metrics/records-metrics.component.ts index c06780fbc2..258f33702a 100644 --- a/libs/feature/search/src/lib/records-metrics/records-metrics.component.ts +++ b/libs/feature/search/src/lib/records-metrics/records-metrics.component.ts @@ -1,12 +1,12 @@ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' import { Observable } from 'rxjs' import { map, share } from 'rxjs/operators' -import { RecordsRepositoryInterface } from '@geonetwork-ui/common/domain/records-repository.interface' +import { RecordsRepositoryInterface } from '@geonetwork-ui/common/domain/repository/records-repository.interface' import { AggregationBuckets, Aggregations, TermBucket, -} from '@geonetwork-ui/common/domain/search' +} from '@geonetwork-ui/common/domain/model/search' import { RecordMetric } from '@geonetwork-ui/api/metadata-converter' @Component({ diff --git a/libs/feature/search/src/lib/results-list/results-list.container.component.spec.ts b/libs/feature/search/src/lib/results-list/results-list.container.component.spec.ts index 1deda28580..8dfff1db99 100644 --- a/libs/feature/search/src/lib/results-list/results-list.container.component.spec.ts +++ b/libs/feature/search/src/lib/results-list/results-list.container.component.spec.ts @@ -10,7 +10,7 @@ import { SearchFacade } from '../state/search.facade' import { ResultsListContainerComponent } from './results-list.container.component' import { ButtonComponent } from '@geonetwork-ui/ui/inputs' import { DATASET_RECORDS } from '@geonetwork-ui/common/fixtures' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' @Component({ selector: 'gn-ui-results-list', diff --git a/libs/feature/search/src/lib/results-list/results-list.container.component.ts b/libs/feature/search/src/lib/results-list/results-list.container.component.ts index a31ca67329..9ab9fae9fb 100644 --- a/libs/feature/search/src/lib/results-list/results-list.container.component.ts +++ b/libs/feature/search/src/lib/results-list/results-list.container.component.ts @@ -18,7 +18,7 @@ import { ResultsLayoutConfigModel, } from '@geonetwork-ui/ui/search' import { RECORD_URL_TOKEN } from '../feature-search.module' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' export type ResultsListShowMoreStrategy = 'auto' | 'button' | 'none' diff --git a/libs/feature/search/src/lib/sort-by/sort-by.component.ts b/libs/feature/search/src/lib/sort-by/sort-by.component.ts index 7c099af17d..b3e78d3f91 100644 --- a/libs/feature/search/src/lib/sort-by/sort-by.component.ts +++ b/libs/feature/search/src/lib/sort-by/sort-by.component.ts @@ -1,6 +1,9 @@ import { Component, Input, OnInit } from '@angular/core' import { marker } from '@biesbjerg/ngx-translate-extract-marker' -import { SortByEnum, SortByField } from '@geonetwork-ui/common/domain/search' +import { + SortByEnum, + SortByField, +} from '@geonetwork-ui/common/domain/model/search' import { SearchFacade } from '../state/search.facade' import { SearchService } from '../utils/service/search.service' import { filter, map } from 'rxjs/operators' diff --git a/libs/feature/search/src/lib/state/actions.ts b/libs/feature/search/src/lib/state/actions.ts index 2d6d2638b2..e580bc248a 100644 --- a/libs/feature/search/src/lib/state/actions.ts +++ b/libs/feature/search/src/lib/state/actions.ts @@ -7,8 +7,8 @@ import { FieldFilters, FieldName, SortByField, -} from '@geonetwork-ui/common/domain/search' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' +} from '@geonetwork-ui/common/domain/model/search' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' export const ADD_SEARCH = '[Search] Add search instance' export const SET_FILTERS = '[Search] Set Filters' diff --git a/libs/feature/search/src/lib/state/effects.spec.ts b/libs/feature/search/src/lib/state/effects.spec.ts index 1e5af29902..cce5831230 100644 --- a/libs/feature/search/src/lib/state/effects.spec.ts +++ b/libs/feature/search/src/lib/state/effects.spec.ts @@ -43,12 +43,10 @@ import { import { HttpErrorResponse } from '@angular/common/http' import { delay } from 'rxjs/operators' import { FILTER_GEOMETRY } from '../feature-search.module' -import { RecordsRepositoryInterface } from '@geonetwork-ui/common/domain/records-repository.interface' +import { RecordsRepositoryInterface } from '@geonetwork-ui/common/domain/repository/records-repository.interface' import { TestScheduler } from 'rxjs/internal/testing/TestScheduler' -import { - AuthService, - FavoritesService, -} from '@geonetwork-ui/api/repository/gn4' +import { FavoritesService } from '@geonetwork-ui/api/repository/gn4' +import { PlatformServiceInterface } from '@geonetwork-ui/common/domain/platform.service.interface' const defaultSearchState = initialState[DEFAULT_SEARCH_KEY] const stateWithSearches = { @@ -69,8 +67,8 @@ const stateWithSearches = { }, } -class AuthServiceMock { - authReady = () => of(true) +class PlatformServiceMock { + getMe = jest.fn(() => of(true)) } class FavoritesServiceMock { myFavoritesUuid$ = of(['fav001', 'fav002', 'fav003']) @@ -100,8 +98,8 @@ describe('Effects', () => { provideMockActions(() => actions$), SearchEffects, { - provide: AuthService, - useClass: AuthServiceMock, + provide: PlatformServiceInterface, + useClass: PlatformServiceMock, }, { provide: FavoritesService, diff --git a/libs/feature/search/src/lib/state/effects.ts b/libs/feature/search/src/lib/state/effects.ts index 4272e79ff4..d175ee3782 100644 --- a/libs/feature/search/src/lib/state/effects.ts +++ b/libs/feature/search/src/lib/state/effects.ts @@ -42,11 +42,9 @@ import { HttpErrorResponse } from '@angular/common/http' import { switchMapWithSearchId } from '../utils/operators/search.operator' import { Geometry } from 'geojson' import { FILTER_GEOMETRY } from '../feature-search.module' -import { RecordsRepositoryInterface } from '@geonetwork-ui/common/domain/records-repository.interface' -import { - AuthService, - FavoritesService, -} from '@geonetwork-ui/api/repository/gn4' +import { RecordsRepositoryInterface } from '@geonetwork-ui/common/domain/repository/records-repository.interface' +import { FavoritesService } from '@geonetwork-ui/api/repository/gn4' +import { PlatformServiceInterface } from '@geonetwork-ui/common/domain/platform.service.interface' @Injectable() export class SearchEffects { @@ -58,8 +56,8 @@ export class SearchEffects { private actions$: Actions, private store$: Store, private recordsRepository: RecordsRepositoryInterface, - private authService: AuthService, private favoritesService: FavoritesService, + private platformService: PlatformServiceInterface, @Optional() @Inject(FILTER_GEOMETRY) private filterGeometry: Promise @@ -110,7 +108,7 @@ export class SearchEffects { this.actions$.pipe( ofType(REQUEST_MORE_RESULTS, REQUEST_NEW_RESULTS), switchMapWithSearchId((action: SearchActions) => - this.authService.authReady().pipe( + this.platformService.getMe().pipe( withLatestFrom( this.store$.pipe(select(getSearchStateSearch, action.id)) ), @@ -194,7 +192,7 @@ export class SearchEffects { REQUEST_MORE_ON_AGGREGATION ), switchMap((action) => - this.authService.authReady().pipe( + this.platformService.getMe().pipe( withLatestFrom( this.store$.pipe(select(getSearchStateSearch, action.id)) ), diff --git a/libs/feature/search/src/lib/state/reducer.spec.ts b/libs/feature/search/src/lib/state/reducer.spec.ts index c4a70ed919..a0c8084813 100644 --- a/libs/feature/search/src/lib/state/reducer.spec.ts +++ b/libs/feature/search/src/lib/state/reducer.spec.ts @@ -14,7 +14,7 @@ import { reducerSearch, SearchStateParams, } from './reducer' -import { TermsAggregationParams } from '@geonetwork-ui/common/domain/search' +import { TermsAggregationParams } from '@geonetwork-ui/common/domain/model/search' const initialStateSearch = initialState[DEFAULT_SEARCH_KEY] diff --git a/libs/feature/search/src/lib/state/reducer.ts b/libs/feature/search/src/lib/state/reducer.ts index 6f9dcd6b94..fbf637959f 100644 --- a/libs/feature/search/src/lib/state/reducer.ts +++ b/libs/feature/search/src/lib/state/reducer.ts @@ -6,9 +6,9 @@ import { FieldFilters, FieldName, SortByField, -} from '@geonetwork-ui/common/domain/search' +} from '@geonetwork-ui/common/domain/model/search' import { DEFAULT_PAGE_SIZE, FIELDS_SUMMARY } from '../constants' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' export const SEARCH_FEATURE_KEY = 'searchState' diff --git a/libs/feature/search/src/lib/state/search.facade.ts b/libs/feature/search/src/lib/state/search.facade.ts index 9300c61985..de217e3bf3 100644 --- a/libs/feature/search/src/lib/state/search.facade.ts +++ b/libs/feature/search/src/lib/state/search.facade.ts @@ -49,8 +49,8 @@ import { FieldFilters, FieldName, SortByField, -} from '@geonetwork-ui/common/domain/search' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' +} from '@geonetwork-ui/common/domain/model/search' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' @Injectable() export class SearchFacade { diff --git a/libs/feature/search/src/lib/utils/service/fields.service.spec.ts b/libs/feature/search/src/lib/utils/service/fields.service.spec.ts index d2b8d9b669..138965ffba 100644 --- a/libs/feature/search/src/lib/utils/service/fields.service.spec.ts +++ b/libs/feature/search/src/lib/utils/service/fields.service.spec.ts @@ -4,7 +4,7 @@ import { EMPTY, lastValueFrom, of } from 'rxjs' import { ToolsApiService } from '@geonetwork-ui/data-access/gn4' import { TranslateModule } from '@ngx-translate/core' import { OrganizationsServiceInterface } from '@geonetwork-ui/common/domain/organizations.service.interface' -import { RecordsRepositoryInterface } from '@geonetwork-ui/common/domain/records-repository.interface' +import { RecordsRepositoryInterface } from '@geonetwork-ui/common/domain/repository/records-repository.interface' import { ElasticsearchService } from '@geonetwork-ui/api/repository/gn4' class RecordsRepositoryMock { diff --git a/libs/feature/search/src/lib/utils/service/fields.service.ts b/libs/feature/search/src/lib/utils/service/fields.service.ts index 8c2bed40ae..8ef7ae172e 100644 --- a/libs/feature/search/src/lib/utils/service/fields.service.ts +++ b/libs/feature/search/src/lib/utils/service/fields.service.ts @@ -12,7 +12,7 @@ import { } from './fields' import { forkJoin, Observable, of } from 'rxjs' import { map } from 'rxjs/operators' -import { FieldFilters } from '@geonetwork-ui/common/domain/search' +import { FieldFilters } from '@geonetwork-ui/common/domain/model/search' import { marker } from '@biesbjerg/ngx-translate-extract-marker' // key is the field name diff --git a/libs/feature/search/src/lib/utils/service/fields.spec.ts b/libs/feature/search/src/lib/utils/service/fields.spec.ts index f89ae971cc..01b5259af5 100644 --- a/libs/feature/search/src/lib/utils/service/fields.spec.ts +++ b/libs/feature/search/src/lib/utils/service/fields.spec.ts @@ -13,9 +13,9 @@ import { TestBed } from '@angular/core/testing' import { Injector } from '@angular/core' import { TranslateModule, TranslateService } from '@ngx-translate/core' import { OrganizationsServiceInterface } from '@geonetwork-ui/common/domain/organizations.service.interface' -import { Organization } from '@geonetwork-ui/common/domain/record' +import { Organization } from '@geonetwork-ui/common/domain/model/record' import { ElasticsearchService } from '@geonetwork-ui/api/repository/gn4' -import { RecordsRepositoryInterface } from '@geonetwork-ui/common/domain/records-repository.interface' +import { RecordsRepositoryInterface } from '@geonetwork-ui/common/domain/repository/records-repository.interface' class ElasticsearchServiceMock { registerRuntimeField = jest.fn() diff --git a/libs/feature/search/src/lib/utils/service/fields.ts b/libs/feature/search/src/lib/utils/service/fields.ts index 272fb73362..41949fe408 100644 --- a/libs/feature/search/src/lib/utils/service/fields.ts +++ b/libs/feature/search/src/lib/utils/service/fields.ts @@ -11,8 +11,8 @@ import { FieldFilterByExpression, FieldFilters, TermBucket, -} from '@geonetwork-ui/common/domain/search' -import { RecordsRepositoryInterface } from '@geonetwork-ui/common/domain/records-repository.interface' +} from '@geonetwork-ui/common/domain/model/search' +import { RecordsRepositoryInterface } from '@geonetwork-ui/common/domain/repository/records-repository.interface' import { ElasticsearchService } from '@geonetwork-ui/api/repository/gn4' export type FieldValue = string | number diff --git a/libs/feature/search/src/lib/utils/service/search.service.spec.ts b/libs/feature/search/src/lib/utils/service/search.service.spec.ts index 147aa6d6c2..336ac89e8a 100644 --- a/libs/feature/search/src/lib/utils/service/search.service.spec.ts +++ b/libs/feature/search/src/lib/utils/service/search.service.spec.ts @@ -1,4 +1,4 @@ -import { SortByEnum } from '@geonetwork-ui/common/domain/search' +import { SortByEnum } from '@geonetwork-ui/common/domain/model/search' import { BehaviorSubject } from 'rxjs' import { SearchService } from './search.service' diff --git a/libs/feature/search/src/lib/utils/service/search.service.ts b/libs/feature/search/src/lib/utils/service/search.service.ts index f168cb8894..c222003b33 100644 --- a/libs/feature/search/src/lib/utils/service/search.service.ts +++ b/libs/feature/search/src/lib/utils/service/search.service.ts @@ -1,6 +1,9 @@ import { Injectable } from '@angular/core' import { SearchFacade } from '../../state/search.facade' -import { FieldFilters, SortByField } from '@geonetwork-ui/common/domain/search' +import { + FieldFilters, + SortByField, +} from '@geonetwork-ui/common/domain/model/search' import { first, map } from 'rxjs/operators' export interface SearchServiceI { diff --git a/libs/ui/catalog/src/lib/organisation-preview/organisation-preview.component.ts b/libs/ui/catalog/src/lib/organisation-preview/organisation-preview.component.ts index 1ff5940722..0cc798faab 100644 --- a/libs/ui/catalog/src/lib/organisation-preview/organisation-preview.component.ts +++ b/libs/ui/catalog/src/lib/organisation-preview/organisation-preview.component.ts @@ -5,7 +5,7 @@ import { Input, Output, } from '@angular/core' -import { Organization } from '@geonetwork-ui/common/domain/record' +import { Organization } from '@geonetwork-ui/common/domain/model/record' @Component({ selector: 'gn-ui-organisation-preview', diff --git a/libs/ui/catalog/src/lib/organisations-sort/organisations-sort.component.ts b/libs/ui/catalog/src/lib/organisations-sort/organisations-sort.component.ts index dff069765e..682eb36f7f 100644 --- a/libs/ui/catalog/src/lib/organisations-sort/organisations-sort.component.ts +++ b/libs/ui/catalog/src/lib/organisations-sort/organisations-sort.component.ts @@ -5,7 +5,7 @@ import { Output, } from '@angular/core' import { marker } from '@biesbjerg/ngx-translate-extract-marker' -import { SortByField } from '@geonetwork-ui/common/domain/search' +import { SortByField } from '@geonetwork-ui/common/domain/model/search' @Component({ selector: 'gn-ui-organisations-sort', diff --git a/libs/ui/dataviz/src/lib/chart/chart.component.stories.ts b/libs/ui/dataviz/src/lib/chart/chart.component.stories.ts index 7c02ad28e8..9f942ec730 100644 --- a/libs/ui/dataviz/src/lib/chart/chart.component.stories.ts +++ b/libs/ui/dataviz/src/lib/chart/chart.component.stories.ts @@ -1,6 +1,6 @@ import { HttpClientModule } from '@angular/common/http' import { TranslateModule } from '@ngx-translate/core' -import { CHART_TYPE_VALUES } from '@geonetwork-ui/common/domain/dataviz-configuration.model' +import { CHART_TYPE_VALUES } from '@geonetwork-ui/common/domain/model/dataviz/dataviz-configuration.model' import { applicationConfig, componentWrapperDecorator, diff --git a/libs/ui/dataviz/src/lib/chart/chart.component.ts b/libs/ui/dataviz/src/lib/chart/chart.component.ts index aac76b438f..dab03672f3 100644 --- a/libs/ui/dataviz/src/lib/chart/chart.component.ts +++ b/libs/ui/dataviz/src/lib/chart/chart.component.ts @@ -7,7 +7,7 @@ import { OnChanges, ViewChild, } from '@angular/core' -import { InputChartType } from '@geonetwork-ui/common/domain/dataviz-configuration.model' +import { InputChartType } from '@geonetwork-ui/common/domain/model/dataviz/dataviz-configuration.model' import { ArcElement, BarController, diff --git a/libs/ui/elements/src/lib/api-card/api-card.component.ts b/libs/ui/elements/src/lib/api-card/api-card.component.ts index 8966a34f1b..9f9888d3a0 100644 --- a/libs/ui/elements/src/lib/api-card/api-card.component.ts +++ b/libs/ui/elements/src/lib/api-card/api-card.component.ts @@ -1,5 +1,5 @@ import { ChangeDetectionStrategy, Component, Input } from '@angular/core' -import { DatasetServiceDistribution } from '@geonetwork-ui/common/domain/record' +import { DatasetServiceDistribution } from '@geonetwork-ui/common/domain/model/record' @Component({ selector: 'gn-ui-api-card', diff --git a/libs/ui/elements/src/lib/download-item/download-item.component.ts b/libs/ui/elements/src/lib/download-item/download-item.component.ts index 9338075a69..7ec3ec24ed 100644 --- a/libs/ui/elements/src/lib/download-item/download-item.component.ts +++ b/libs/ui/elements/src/lib/download-item/download-item.component.ts @@ -5,7 +5,7 @@ import { Output, EventEmitter, } from '@angular/core' -import { DatasetDistribution } from '@geonetwork-ui/common/domain/record' +import { DatasetDistribution } from '@geonetwork-ui/common/domain/model/record' @Component({ selector: 'gn-ui-download-item', diff --git a/libs/ui/elements/src/lib/downloads-list/downloads-list.component.spec.ts b/libs/ui/elements/src/lib/downloads-list/downloads-list.component.spec.ts index 5f224193a6..1abb05ee73 100644 --- a/libs/ui/elements/src/lib/downloads-list/downloads-list.component.spec.ts +++ b/libs/ui/elements/src/lib/downloads-list/downloads-list.component.spec.ts @@ -14,7 +14,7 @@ import { DownloadsListComponent } from './downloads-list.component' import { DatasetDistribution, DatasetDownloadDistribution, -} from '@geonetwork-ui/common/domain/record' +} from '@geonetwork-ui/common/domain/model/record' @Component({ selector: 'gn-ui-download-item', diff --git a/libs/ui/elements/src/lib/downloads-list/downloads-list.component.ts b/libs/ui/elements/src/lib/downloads-list/downloads-list.component.ts index 861bfd2737..722fd71d74 100644 --- a/libs/ui/elements/src/lib/downloads-list/downloads-list.component.ts +++ b/libs/ui/elements/src/lib/downloads-list/downloads-list.component.ts @@ -2,7 +2,7 @@ import { ChangeDetectionStrategy, Component, Input } from '@angular/core' import { TranslateService } from '@ngx-translate/core' import { marker } from '@biesbjerg/ngx-translate-extract-marker' import { getBadgeColor, getFileFormat } from '@geonetwork-ui/util/shared' -import { DatasetDistribution } from '@geonetwork-ui/common/domain/record' +import { DatasetDistribution } from '@geonetwork-ui/common/domain/model/record' marker('datahub.search.filter.all') marker('datahub.search.filter.others') diff --git a/libs/ui/elements/src/lib/link-card/link-card.component.ts b/libs/ui/elements/src/lib/link-card/link-card.component.ts index 72ab5ed10d..8cea45b83e 100644 --- a/libs/ui/elements/src/lib/link-card/link-card.component.ts +++ b/libs/ui/elements/src/lib/link-card/link-card.component.ts @@ -1,5 +1,5 @@ import { Component, ChangeDetectionStrategy, Input } from '@angular/core' -import { DatasetDistribution } from '@geonetwork-ui/common/domain/record' +import { DatasetDistribution } from '@geonetwork-ui/common/domain/model/record' @Component({ selector: 'gn-ui-link-card', diff --git a/libs/ui/elements/src/lib/metadata-contact/metadata-contact.component.ts b/libs/ui/elements/src/lib/metadata-contact/metadata-contact.component.ts index 96fb00490e..a605bc3d8b 100644 --- a/libs/ui/elements/src/lib/metadata-contact/metadata-contact.component.ts +++ b/libs/ui/elements/src/lib/metadata-contact/metadata-contact.component.ts @@ -9,7 +9,7 @@ import { CatalogRecord, Individual, Organization, -} from '@geonetwork-ui/common/domain/record' +} from '@geonetwork-ui/common/domain/model/record' @Component({ selector: 'gn-ui-metadata-contact', diff --git a/libs/ui/elements/src/lib/metadata-info/metadata-info.component.ts b/libs/ui/elements/src/lib/metadata-info/metadata-info.component.ts index f74ea4df78..b489a1913e 100644 --- a/libs/ui/elements/src/lib/metadata-info/metadata-info.component.ts +++ b/libs/ui/elements/src/lib/metadata-info/metadata-info.component.ts @@ -5,7 +5,7 @@ import { Input, Output, } from '@angular/core' -import { DatasetRecord } from '@geonetwork-ui/common/domain/record' +import { DatasetRecord } from '@geonetwork-ui/common/domain/model/record' @Component({ selector: 'gn-ui-metadata-info', diff --git a/libs/ui/elements/src/lib/metadata-quality/metadata-quality.component.ts b/libs/ui/elements/src/lib/metadata-quality/metadata-quality.component.ts index 926641f3bd..99849ec44b 100644 --- a/libs/ui/elements/src/lib/metadata-quality/metadata-quality.component.ts +++ b/libs/ui/elements/src/lib/metadata-quality/metadata-quality.component.ts @@ -6,7 +6,7 @@ import { SimpleChanges, } from '@angular/core' import { MetadataQualityItem } from '../metadata-quality-item/metadata-quality-item.component' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' export interface MetadataQualityDisplay { widget: boolean diff --git a/libs/ui/elements/src/lib/related-record-card/related-record-card.component.ts b/libs/ui/elements/src/lib/related-record-card/related-record-card.component.ts index 1f5d71f611..f883b3c31b 100644 --- a/libs/ui/elements/src/lib/related-record-card/related-record-card.component.ts +++ b/libs/ui/elements/src/lib/related-record-card/related-record-card.component.ts @@ -1,5 +1,5 @@ import { Component, ChangeDetectionStrategy, Input } from '@angular/core' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' @Component({ selector: 'gn-ui-related-record-card', diff --git a/libs/ui/elements/src/lib/user-preview/user-preview.component.ts b/libs/ui/elements/src/lib/user-preview/user-preview.component.ts index bbe169b7bd..779ac1b654 100644 --- a/libs/ui/elements/src/lib/user-preview/user-preview.component.ts +++ b/libs/ui/elements/src/lib/user-preview/user-preview.component.ts @@ -1,5 +1,5 @@ import { ChangeDetectionStrategy, Component, Input } from '@angular/core' -import { UserModel } from '@geonetwork-ui/common/domain/user.model' +import { UserModel } from '@geonetwork-ui/common/domain/model/user/user.model' @Component({ selector: 'gn-ui-user-preview', diff --git a/libs/ui/search/src/lib/facets/facets.model.ts b/libs/ui/search/src/lib/facets/facets.model.ts index 4f405d6067..543c6776fb 100644 --- a/libs/ui/search/src/lib/facets/facets.model.ts +++ b/libs/ui/search/src/lib/facets/facets.model.ts @@ -1,4 +1,4 @@ -import { AggregationsTypes } from '@geonetwork-ui/common/domain/search' +import { AggregationsTypes } from '@geonetwork-ui/common/domain/model/search' export type FacetPath = string[] diff --git a/libs/ui/search/src/lib/record-preview-card/record-preview-card.component.spec.ts b/libs/ui/search/src/lib/record-preview-card/record-preview-card.component.spec.ts index 791c499aeb..6a4590a437 100644 --- a/libs/ui/search/src/lib/record-preview-card/record-preview-card.component.spec.ts +++ b/libs/ui/search/src/lib/record-preview-card/record-preview-card.component.spec.ts @@ -2,7 +2,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing' import { NO_ERRORS_SCHEMA } from '@angular/core' import { RecordPreviewCardComponent } from './record-preview-card.component' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' describe('RecordPreviewCardComponent', () => { let component: RecordPreviewCardComponent diff --git a/libs/ui/search/src/lib/record-preview-feed/record-preview-feed.component.spec.ts b/libs/ui/search/src/lib/record-preview-feed/record-preview-feed.component.spec.ts index 53c60df5ae..4b48bdfba0 100644 --- a/libs/ui/search/src/lib/record-preview-feed/record-preview-feed.component.spec.ts +++ b/libs/ui/search/src/lib/record-preview-feed/record-preview-feed.component.spec.ts @@ -2,7 +2,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing' import { RecordPreviewFeedComponent } from './record-preview-feed.component' import { NO_ERRORS_SCHEMA } from '@angular/core' import { TranslateModule } from '@ngx-translate/core' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' import { ORGANISATIONS_FIXTURE } from '@geonetwork-ui/common/fixtures' describe('RecordPreviewFeedComponent', () => { diff --git a/libs/ui/search/src/lib/record-preview-list/record-preview-list.component.spec.ts b/libs/ui/search/src/lib/record-preview-list/record-preview-list.component.spec.ts index d639e1af27..57386c2344 100644 --- a/libs/ui/search/src/lib/record-preview-list/record-preview-list.component.spec.ts +++ b/libs/ui/search/src/lib/record-preview-list/record-preview-list.component.spec.ts @@ -1,7 +1,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing' import { RecordPreviewListComponent } from './record-preview-list.component' import { NO_ERRORS_SCHEMA } from '@angular/core' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' describe('RecordPreviewListComponent', () => { let component: RecordPreviewListComponent diff --git a/libs/ui/search/src/lib/record-preview-row/record-preview-row.component.spec.ts b/libs/ui/search/src/lib/record-preview-row/record-preview-row.component.spec.ts index 5144362323..421c355f21 100644 --- a/libs/ui/search/src/lib/record-preview-row/record-preview-row.component.spec.ts +++ b/libs/ui/search/src/lib/record-preview-row/record-preview-row.component.spec.ts @@ -2,7 +2,7 @@ import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core' import { ComponentFixture, TestBed } from '@angular/core/testing' import { UtilSharedModule } from '@geonetwork-ui/util/shared' import { RecordPreviewRowComponent } from './record-preview-row.component' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' describe('RecordPreviewDatahubComponent', () => { let component: RecordPreviewRowComponent diff --git a/libs/ui/search/src/lib/record-preview-text/record-preview-text.component.spec.ts b/libs/ui/search/src/lib/record-preview-text/record-preview-text.component.spec.ts index b592ac530c..6ca6cc1ba0 100644 --- a/libs/ui/search/src/lib/record-preview-text/record-preview-text.component.spec.ts +++ b/libs/ui/search/src/lib/record-preview-text/record-preview-text.component.spec.ts @@ -1,7 +1,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing' import { RecordPreviewTextComponent } from './record-preview-text.component' import { NO_ERRORS_SCHEMA } from '@angular/core' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' describe('RecordPreviewTextComponent', () => { let component: RecordPreviewTextComponent diff --git a/libs/ui/search/src/lib/record-preview-title/record-preview-title.component.spec.ts b/libs/ui/search/src/lib/record-preview-title/record-preview-title.component.spec.ts index 858116c1f8..d8f86eb73e 100644 --- a/libs/ui/search/src/lib/record-preview-title/record-preview-title.component.spec.ts +++ b/libs/ui/search/src/lib/record-preview-title/record-preview-title.component.spec.ts @@ -1,7 +1,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing' import { NO_ERRORS_SCHEMA } from '@angular/core' import { RecordPreviewTitleComponent } from './record-preview-title.component' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' describe('RecordPreviewTextComponent', () => { let component: RecordPreviewTitleComponent diff --git a/libs/ui/search/src/lib/record-preview/record-preview.component.ts b/libs/ui/search/src/lib/record-preview/record-preview.component.ts index 93de822d70..277d6be2b3 100644 --- a/libs/ui/search/src/lib/record-preview/record-preview.component.ts +++ b/libs/ui/search/src/lib/record-preview/record-preview.component.ts @@ -20,7 +20,7 @@ import { DatasetRecord, Individual, Organization, -} from '@geonetwork-ui/common/domain/record' +} from '@geonetwork-ui/common/domain/model/record' @Component({ selector: 'gn-ui-record-preview', diff --git a/libs/ui/search/src/lib/record-table/record-table.component.spec.ts b/libs/ui/search/src/lib/record-table/record-table.component.spec.ts index 3b8b8ce869..01a89a3d73 100644 --- a/libs/ui/search/src/lib/record-table/record-table.component.spec.ts +++ b/libs/ui/search/src/lib/record-table/record-table.component.spec.ts @@ -2,8 +2,8 @@ import { ComponentFixture, TestBed } from '@angular/core/testing' import { DATASET_RECORDS } from '@geonetwork-ui/common/fixtures' import { RecordTableComponent } from './record-table.component' -import { SortByField } from '@geonetwork-ui/common/domain/search' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' +import { SortByField } from '@geonetwork-ui/common/domain/model/search' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' describe('RecordTableComponent', () => { let component: RecordTableComponent diff --git a/libs/ui/search/src/lib/record-table/record-table.component.ts b/libs/ui/search/src/lib/record-table/record-table.component.ts index ddae7d03ce..7f51ff6661 100644 --- a/libs/ui/search/src/lib/record-table/record-table.component.ts +++ b/libs/ui/search/src/lib/record-table/record-table.component.ts @@ -1,12 +1,12 @@ import { Component, EventEmitter, Input, Output } from '@angular/core' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' import { FileFormat, getBadgeColor, getFileFormat, getFormatPriority, } from '@geonetwork-ui/util/shared' -import { SortByField } from '@geonetwork-ui/common/domain/search' +import { SortByField } from '@geonetwork-ui/common/domain/model/search' @Component({ selector: 'gn-ui-record-table', diff --git a/libs/ui/search/src/lib/results-list-item/results-list-item.component.ts b/libs/ui/search/src/lib/results-list-item/results-list-item.component.ts index 6be88cf666..4edb676732 100644 --- a/libs/ui/search/src/lib/results-list-item/results-list-item.component.ts +++ b/libs/ui/search/src/lib/results-list-item/results-list-item.component.ts @@ -13,7 +13,7 @@ import { } from '@angular/core' import { RecordPreviewComponent } from '../record-preview/record-preview.component' import { ResultsLayoutConfigItem } from '../results-list/results-layout.config' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' import { MetadataQualityDisplay } from '@geonetwork-ui/ui/elements' @Component({ diff --git a/libs/ui/search/src/lib/results-list/results-list.component.ts b/libs/ui/search/src/lib/results-list/results-list.component.ts index 365330886c..0297391f84 100644 --- a/libs/ui/search/src/lib/results-list/results-list.component.ts +++ b/libs/ui/search/src/lib/results-list/results-list.component.ts @@ -10,7 +10,7 @@ import { DEFAULT_RESULTS_LAYOUT_CONFIG, ResultsLayoutConfigItem, } from './results-layout.config' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' import { MetadataQualityDisplay } from '@geonetwork-ui/ui/elements' @Component({ diff --git a/libs/util/shared/src/lib/links/link-classifier.service.ts b/libs/util/shared/src/lib/links/link-classifier.service.ts index 81511e1800..f25fc65103 100644 --- a/libs/util/shared/src/lib/links/link-classifier.service.ts +++ b/libs/util/shared/src/lib/links/link-classifier.service.ts @@ -1,5 +1,5 @@ import { Injectable } from '@angular/core' -import { DatasetDistribution } from '@geonetwork-ui/common/domain/record' +import { DatasetDistribution } from '@geonetwork-ui/common/domain/model/record' import { getFileFormat } from './link-utils' export enum LinkUsage { API = 'api', diff --git a/libs/util/shared/src/lib/links/link-utils.spec.ts b/libs/util/shared/src/lib/links/link-utils.spec.ts index 4c5364073e..454adce206 100644 --- a/libs/util/shared/src/lib/links/link-utils.spec.ts +++ b/libs/util/shared/src/lib/links/link-utils.spec.ts @@ -9,7 +9,7 @@ import { mimeTypeToFormat, getLinkPriority, } from './link-utils' -import { DatasetDownloadDistribution } from '@geonetwork-ui/common/domain/record' +import { DatasetDownloadDistribution } from '@geonetwork-ui/common/domain/model/record' describe('link utils', () => { describe('#getFileFormat', () => { diff --git a/libs/util/shared/src/lib/links/link-utils.ts b/libs/util/shared/src/lib/links/link-utils.ts index ab21cce3fb..6c4cbb6c05 100644 --- a/libs/util/shared/src/lib/links/link-utils.ts +++ b/libs/util/shared/src/lib/links/link-utils.ts @@ -1,5 +1,5 @@ import { marker } from '@biesbjerg/ngx-translate-extract-marker' -import { DatasetDistribution } from '@geonetwork-ui/common/domain/record' +import { DatasetDistribution } from '@geonetwork-ui/common/domain/model/record' marker('downloads.wfs.featuretype.not.found') diff --git a/libs/util/shared/src/lib/utils/sort-by.ts b/libs/util/shared/src/lib/utils/sort-by.ts index 42ce16f9a8..f77b12223e 100644 --- a/libs/util/shared/src/lib/utils/sort-by.ts +++ b/libs/util/shared/src/lib/utils/sort-by.ts @@ -1,4 +1,4 @@ -import { SortByField } from '@geonetwork-ui/common/domain/search' +import { SortByField } from '@geonetwork-ui/common/domain/model/search' export function sortByToStrings(sortBy: SortByField): string[] { const array = Array.isArray(sortBy[0]) ? sortBy : [sortBy] diff --git a/ssr/formatter/src/app/app.component.ts b/ssr/formatter/src/app/app.component.ts index 59f333bff0..994747471f 100644 --- a/ssr/formatter/src/app/app.component.ts +++ b/ssr/formatter/src/app/app.component.ts @@ -1,7 +1,7 @@ import { HttpClient } from '@angular/common/http' import { Component, OnInit } from '@angular/core' import { map } from 'rxjs/operators' -import { CatalogRecord } from '@geonetwork-ui/common/domain/record' +import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' @Component({ selector: 'gn-ui-root',