diff --git a/apps/red-ui/src/app/modules/dossier/screens/search-screen/search-screen.component.ts b/apps/red-ui/src/app/modules/dossier/screens/search-screen/search-screen.component.ts index 60695ee80..6607f2927 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/search-screen/search-screen.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/search-screen/search-screen.component.ts @@ -10,7 +10,6 @@ import { SearchPositions, TableColumnConfig, } from '@iqser/common-ui'; -import { MatchedDocument, SearchResult } from '@redaction/red-ui-http'; import { BehaviorSubject, Observable } from 'rxjs'; import { debounceTime, map, skip, switchMap, tap } from 'rxjs/operators'; import { ActivatedRoute, Router } from '@angular/router'; @@ -20,6 +19,7 @@ import { TranslateService } from '@ngx-translate/core'; import { RouterHistoryService } from '@services/router-history.service'; import { DossiersService } from '@services/entity-services/dossiers.service'; import { PlatformSearchService } from '../../shared/services/platform-search.service'; +import { IMatchedDocument, ISearchResponse } from '@red/domain'; interface ListItem extends IListable { readonly dossierId: string; @@ -109,7 +109,7 @@ export class SearchScreenComponent extends ListingComponent implements this._router.navigate([], { queryParams }).then(); } - private _search(searchInput: SearchInput): Observable { + private _search(searchInput: SearchInput): Observable { return this._platformSearchService.search({ dossierIds: [...searchInput.dossierIds], queryString: searchInput.query ?? '', @@ -127,15 +127,15 @@ export class SearchScreenComponent extends ListingComponent implements this.search$.next({ query, dossierIds: dossierId ? [dossierId] : [] }); } - private _toMatchedDocuments({ matchedDocuments }: SearchResult): MatchedDocument[] { + private _toMatchedDocuments({ matchedDocuments }: ISearchResponse): IMatchedDocument[] { return matchedDocuments.filter(doc => doc.score > 0 && doc.matchedTerms.length > 0); } - private _toListItems(matchedDocuments: MatchedDocument[]): ListItem[] { + private _toListItems(matchedDocuments: IMatchedDocument[]): ListItem[] { return matchedDocuments.map(document => this._toListItem(document)).filter(value => value); } - private _toListItem({ dossierId, fileId, unmatchedTerms, highlights }: MatchedDocument): ListItem { + private _toListItem({ dossierId, fileId, unmatchedTerms, highlights }: IMatchedDocument): ListItem { const file = this._dossiersService.find(dossierId, fileId); if (!file) { return undefined; diff --git a/apps/red-ui/src/app/modules/dossier/shared/services/platform-search.service.ts b/apps/red-ui/src/app/modules/dossier/shared/services/platform-search.service.ts index ff8f8a55c..1eb744b27 100644 --- a/apps/red-ui/src/app/modules/dossier/shared/services/platform-search.service.ts +++ b/apps/red-ui/src/app/modules/dossier/shared/services/platform-search.service.ts @@ -1,14 +1,14 @@ import { Injectable, Injector } from '@angular/core'; import { GenericService } from '@iqser/common-ui'; -import { SearchRequest, SearchResult } from '@redaction/red-ui-http'; +import { ISearchRequest, ISearchResponse } from '@red/domain'; @Injectable() -export class PlatformSearchService extends GenericService { +export class PlatformSearchService extends GenericService { constructor(protected readonly _injector: Injector) { super(_injector, 'search'); } - search(body: SearchRequest) { + search(body: ISearchRequest) { return this._post(body); } } diff --git a/libs/red-domain/src/index.ts b/libs/red-domain/src/index.ts index 8671dfe75..fa34be26a 100644 --- a/libs/red-domain/src/index.ts +++ b/libs/red-domain/src/index.ts @@ -1,2 +1,3 @@ export * from './lib/dossiers'; +export * from './lib/search'; export * from './lib/shared/types'; diff --git a/libs/red-domain/src/lib/search/index.ts b/libs/red-domain/src/lib/search/index.ts new file mode 100644 index 000000000..78ecaf160 --- /dev/null +++ b/libs/red-domain/src/lib/search/index.ts @@ -0,0 +1,4 @@ +export * from './matched-document'; +export * from './matched-section'; +export * from './search.request'; +export * from './search.response'; diff --git a/libs/red-ui-http/src/lib/model/matchedDocument.ts b/libs/red-domain/src/lib/search/matched-document.ts similarity index 61% rename from libs/red-ui-http/src/lib/model/matchedDocument.ts rename to libs/red-domain/src/lib/search/matched-document.ts index 28d35624e..20180f32c 100644 --- a/libs/red-ui-http/src/lib/model/matchedDocument.ts +++ b/libs/red-domain/src/lib/search/matched-document.ts @@ -9,16 +9,17 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ -import { MatchedSection } from './matchedSection'; +import { IMatchedSection } from './matched-section'; +import { List } from '@iqser/common-ui'; -export interface MatchedDocument { +export interface IMatchedDocument { containsAllMatchedSections?: boolean; dossierId?: string; dossierTemplateId?: string; fileId?: string; - highlights?: { [key: string]: Array }; - matchedSections?: Array; - matchedTerms?: Array; + highlights?: { [key: string]: List }; + matchedSections?: List; + matchedTerms?: List; score?: number; - unmatchedTerms?: Array; + unmatchedTerms?: List; } diff --git a/libs/red-ui-http/src/lib/model/matchedSection.ts b/libs/red-domain/src/lib/search/matched-section.ts similarity index 72% rename from libs/red-ui-http/src/lib/model/matchedSection.ts rename to libs/red-domain/src/lib/search/matched-section.ts index 0a6caaca3..ba969568c 100644 --- a/libs/red-ui-http/src/lib/model/matchedSection.ts +++ b/libs/red-domain/src/lib/search/matched-section.ts @@ -9,10 +9,11 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ +import { List } from '@iqser/common-ui'; -export interface MatchedSection { +export interface IMatchedSection { headline?: string; - matchedTerms?: Array; - pages?: Array; + matchedTerms?: List; + pages?: List; sectionNumber?: number; } diff --git a/libs/red-ui-http/src/lib/model/searchRequest.ts b/libs/red-domain/src/lib/search/search.request.ts similarity index 75% rename from libs/red-ui-http/src/lib/model/searchRequest.ts rename to libs/red-domain/src/lib/search/search.request.ts index bb5a86150..9c8c77a0b 100644 --- a/libs/red-ui-http/src/lib/model/searchRequest.ts +++ b/libs/red-domain/src/lib/search/search.request.ts @@ -9,10 +9,11 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ +import { List } from '@iqser/common-ui'; -export interface SearchRequest { - dossierIds?: Array; - dossierTemplateIds?: Array; +export interface ISearchRequest { + dossierIds?: List; + dossierTemplateIds?: List; fileId?: string; page?: number; pageSize?: number; diff --git a/libs/red-ui-http/src/lib/model/searchResult.ts b/libs/red-domain/src/lib/search/search.response.ts similarity index 64% rename from libs/red-ui-http/src/lib/model/searchResult.ts rename to libs/red-domain/src/lib/search/search.response.ts index 8a63fc012..8796d1bd5 100644 --- a/libs/red-ui-http/src/lib/model/searchResult.ts +++ b/libs/red-domain/src/lib/search/search.response.ts @@ -9,10 +9,11 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ -import { MatchedDocument } from './matchedDocument'; +import { IMatchedDocument } from './matched-document'; +import { List } from '@iqser/common-ui'; -export interface SearchResult { - matchedDocuments?: Array; +export interface ISearchResponse { + matchedDocuments?: List; maxScore?: number; total?: number; } diff --git a/libs/red-ui-http/src/lib/model/models.ts b/libs/red-ui-http/src/lib/model/models.ts index e118c67c6..1b7e13d3e 100644 --- a/libs/red-ui-http/src/lib/model/models.ts +++ b/libs/red-ui-http/src/lib/model/models.ts @@ -37,8 +37,6 @@ export * from './licenseReport'; export * from './licenseReportRequest'; export * from './manualAddResponse'; export * from './manualRedactionEntry'; -export * from './matchedDocument'; -export * from './matchedSection'; export * from './notification.model'; export * from './notificationResponse'; export * from './pageExclusionRequest'; @@ -56,8 +54,6 @@ export * from './reportTemplate'; export * from './resetPasswordRequest'; export * from './rules'; export * from './smtp-configuration'; -export * from './searchRequest'; -export * from './searchResult'; export * from './sectionGrid'; export * from './sectionRectangle'; export * from './updateMyProfileRequest';