[MNT-25478] Expose list parents method in nodes api service (#11622)

* [MNT-25478] Expose list parents method in nodes api service

* [MNT-25478] CR fixes
This commit is contained in:
Michal Kinas
2026-02-11 13:09:22 +01:00
committed by GitHub
parent 30afd2d863
commit 4df5b9282c
3 changed files with 36 additions and 2 deletions
@@ -68,4 +68,11 @@ describe('NodesApiService', () => {
expect(nodesApiService.nodesApi.getFolderSizeInfo).toHaveBeenCalledWith('fake-node-id', 'fake-job-id');
});
it('should call listParents api with nodeId and optional params', async () => {
spyOn(nodesApiService.nodesApi, 'listParents').and.returnValue(Promise.resolve({ list: { entries: [] } }));
await firstValueFrom(nodesApiService.listParents('fake-node-id', { include: ['path'], where: 'isPrimary=true' }));
expect(nodesApiService.nodesApi.listParents).toHaveBeenCalledWith('fake-node-id', { include: ['path'], where: 'isPrimary=true' });
});
});
@@ -26,7 +26,8 @@ import {
NodesIncludeQuery,
TrashcanApi,
SizeDetailsEntry,
JobIdBodyEntry
JobIdBodyEntry,
NodeAssociationPaging
} from '@alfresco/js-api';
import { Injectable } from '@angular/core';
import { from, Observable, Subject, throwError } from 'rxjs';
@@ -55,7 +56,10 @@ export class NodesApiService {
return this._nodesApi;
}
constructor(private apiService: AlfrescoApiService, private preferences: UserPreferencesService) {}
constructor(
private readonly apiService: AlfrescoApiService,
private readonly preferences: UserPreferencesService
) {}
private getEntryFromEntity(entity: NodeEntry): Node {
return entity.entry;
@@ -278,6 +282,24 @@ export class NodesApiService {
return from(this.nodesApi.getFolderSizeInfo(nodeId, jobId));
}
/**
* Lists parents of a given node.
*
* @param nodeId Node ID
* @param opts Optional parameters
* @returns List of parent nodes
*/
listParents(
nodeId: string,
opts?: {
where?: string;
includeSource?: boolean;
} & NodesIncludeQuery &
ContentPagingQuery
): Observable<NodeAssociationPaging> {
return from(this.nodesApi.listParents(nodeId, opts));
}
private randomNodeName(): string {
return `node_${Date.now()}`;
}