Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see .
*/
import { RepoApi } from '../repo-api';
import { RepoClient } from './../../repo-client';
import { Utils } from '../../../../utilities/utils';
import { FavoritesApi as AdfFavoritesApi, SitesApi as AdfSiteApi, FavoriteEntry } from '@alfresco/js-api';
export class FavoritesApi extends RepoApi {
favoritesApi = new AdfFavoritesApi(this.alfrescoJsApi);
sitesApi = new AdfSiteApi(this.alfrescoJsApi);
constructor(username?, password?) {
super(username, password);
}
async addFavorite(api: RepoClient, nodeType: string, name: string) {
const nodeId = (await api.nodes.getNodeByPath(name)).entry.id;
const data = {
target: {
[nodeType]: {
guid: nodeId
}
}
};
return await this.favoritesApi.createFavorite('-me-', data);