[MNT-25629] Add batch document-runtime endpoint support (#12121)

* [MNT-25629] Add batch document-runtime endpoint support

* [MNT-25629] cr fixes

* [MNT-25629] cr fixes

* [MNT-25629] add tests for api method
This commit is contained in:
Mykyta Maliarchuk
2026-08-07 10:37:57 +02:00
committed by GitHub
parent 33cf47342d
commit 1ab385a3c9
10 changed files with 253 additions and 1 deletions
@@ -27,6 +27,11 @@ import { throwIfNotDefined } from '../../../assert';
* Content service.
*/
export class ContentApi extends BaseApi {
/**
* Maximum number of source document ids accepted by the batch document-runtime endpoint in a single request.
*/
static readonly DOCUMENT_RUNTIME_BATCH_SIZE_LIMIT = 500;
/**
* Attach existing content to a process instance
*
@@ -318,4 +323,34 @@ export class ContentApi extends BaseApi {
}
});
}
/**
* Batch variant of getProcessesAndTasksOnContent. Accepts multiple source document ids
* in one request (up to 500) and returns the related processes and tasks for all of them.
*
* @param sourceIds - ids of the documents to query process participation for (up to 500)
* @param source - source of the documents that workflows or tasks have been started with
* @param size - size of the entries to get
* @param page - page number
* @return Promise<ResultListDataRepresentationRelatedProcessTask>
* @throws {Error} if sourceIds exceeds DOCUMENT_RUNTIME_BATCH_SIZE_LIMIT
*/
getProcessesAndTasksOnContentBatch(
sourceIds: string[],
source: string,
size?: number,
page?: number
): Promise<ResultListDataRepresentationRelatedProcessTask> {
throwIfNotDefined(sourceIds, 'sourceIds');
throwIfNotDefined(source, 'source');
if (sourceIds.length > ContentApi.DOCUMENT_RUNTIME_BATCH_SIZE_LIMIT) {
throw new Error(`sourceIds length exceeds the maximum batch size of ${ContentApi.DOCUMENT_RUNTIME_BATCH_SIZE_LIMIT}`);
}
return this.post({
path: '/api/enterprise/document-runtime',
bodyParam: { sourceIds, source, size, page }
});
}
}
@@ -17,6 +17,7 @@ Method | HTTP request | Description
[**getRelatedContentForProcessInstance**](ContentApi.md#getRelatedContentForProcessInstance) | **GET** /enterprise/process-instances/{processInstanceId}/content | List content attached to a process instance
[**getRelatedContentForTask**](ContentApi.md#getRelatedContentForTask) | **GET** /enterprise/tasks/{taskId}/content | List content attached to a task
[**getProcessesAndTasksOnContent**](ContentApi.md#getProcessesAndTasksOnContent) | **GET** enterprise/content/document-runtime | Lists processes and tasks on workflow started with provided document
[**getProcessesAndTasksOnContentBatch**](ContentApi.md#getProcessesAndTasksOnContentBatch) | **POST** /enterprise/document-runtime | Batch lookup of processes and tasks for multiple source documents
<a name="createRelatedContentOnProcessInstance"></a>
# **createRelatedContentOnProcessInstance**
@@ -530,5 +531,42 @@ contentApi.getProcessesAndTasksOnContent('sourceId', 'source').then((data) => {
[**ResultListDataRepresentationRelatedProcessTask**](ResultListDataRepresentationRelatedProcessTask.md)
<a name="getProcessesAndTasksOnContentBatch"></a>
# **getProcessesAndTasksOnContentBatch**
> ResultListDataRepresentationRelatedProcessTask getProcessesAndTasksOnContentBatch(sourceIds, source, size, page)
Batch variant of getProcessesAndTasksOnContent. Accepts up to 500 source document ids in one request and returns the related processes and tasks for all of them.
### Example
```javascript
import ContentApi from 'ContentApi';
import { AlfrescoApi } from '@alfresco/js-api';
const alfrescoApi = new AlfrescoApi();
alfrescoApi.setConfig({
hostEcm: 'http://127.0.0.1:8080'
});
const contentApi = new ContentApi(alfrescoApi);
contentApi.getProcessesAndTasksOnContentBatch(['id1', 'id2'], 'source').then((data) => {
console.log('API called successfully. Returned data: ' + data);
}, function(error) {
console.error(error);
});
```
### Parameters
| Name | Type | Description | Notes |
|---------------|--------------|-----------------------------------------|----------|
| **sourceIds** | **string[]** | List of source document ids (up to 500) | |
| **source** | **string** | Source repository identifier | |
| **size** | **number** | Page size | optional |
| **page** | **number** | Page number (zero-based) | optional |
### Return type
[**ResultListDataRepresentationRelatedProcessTask**](ResultListDataRepresentationRelatedProcessTask.md)
@@ -5,3 +5,4 @@
| ------------ | ------------- | ------------- | ------------- |
| **processId** | **string** | | [optional] [default to undefined] |
| **taskId** | **string** | | [optional] [default to undefined] |
| **sourceId** | **string** | | [optional] [default to undefined] |
@@ -18,4 +18,5 @@
export interface RelatedProcessTask {
processId?: string;
taskId?: string;
sourceId?: string;
}