@alfresco/adf-content-services
Version:
Alfresco ADF content services
84 lines (83 loc) • 3.7 kB
TypeScript
/*!
* @license
* Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { NodesApi, NodeEntry, ContentFieldsQuery, PreferenceEntry } from '@alfresco/js-api';
import { InjectionToken } from '@angular/core';
import { Observable, ReplaySubject } from 'rxjs';
import { AlfrescoApiService } from '../../services/alfresco-api.service';
import { SavedSearch } from '../interfaces/saved-search.interface';
import { AuthenticationService } from '@alfresco/adf-core';
import * as i0 from "@angular/core";
export interface SavedSearchesPreferencesApiService {
getPreference: (personId: string, preferenceName: string, opts?: ContentFieldsQuery) => Promise<PreferenceEntry> | Observable<PreferenceEntry>;
updatePreference: (personId: string, preferenceName: string, preferenceValue: string) => Promise<PreferenceEntry> | Observable<PreferenceEntry>;
}
export declare const SAVED_SEARCHES_SERVICE_PREFERENCES: InjectionToken<SavedSearchesPreferencesApiService>;
export declare class SavedSearchesService {
private readonly apiService;
private readonly authService;
private savedSearchFileNodeId;
private _nodesApi;
private _preferencesApi;
private preferencesService;
get nodesApi(): NodesApi;
get preferencesApi(): SavedSearchesPreferencesApiService;
readonly savedSearches$: ReplaySubject<SavedSearch[]>;
constructor(apiService: AlfrescoApiService, authService: AuthenticationService);
init(): void;
/**
* Gets a list of saved searches by user.
*
* @returns SavedSearch list containing user saved searches
*/
getSavedSearches(): Observable<SavedSearch[]>;
/**
* Saves a new search into state and updates state. If there are less than 5 searches,
* it will be pushed on first place, if more it will be pushed to 6th place.
*
* @param newSaveSearch object { name: string, description: string, encodedUrl: string }
* @returns NodeEntry
*/
saveSearch(newSaveSearch: Pick<SavedSearch, 'name' | 'description' | 'encodedUrl'>): Observable<NodeEntry>;
/**
* Replace Save Search with new one and also updates the state.
*
* @param updatedSavedSearch - updated Save Search
* @returns NodeEntry
*/
editSavedSearch(updatedSavedSearch: SavedSearch): Observable<NodeEntry>;
/**
* Deletes Save Search and update state.
*
* @param deletedSavedSearch - Save Search to delete
* @returns NodeEntry
*/
deleteSavedSearch(deletedSavedSearch: SavedSearch): Observable<NodeEntry>;
/**
* Reorders saved search place
*
* @param previousIndex - previous index of saved search
* @param currentIndex - new index of saved search
*/
changeOrder(previousIndex: number, currentIndex: number): void;
private getSavedSearchesNodeId;
private mapFileContentToSavedSearches;
private getLocalStorageKey;
private fetchSavedSearches;
private migrateSavedSearches;
static ɵfac: i0.ɵɵFactoryDeclaration<SavedSearchesService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<SavedSearchesService>;
}