Skip to content

Commit

Permalink
[MNT-24575] Addressed Code review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
swapnil-verma-gl committed Dec 18, 2024
1 parent 88e99ac commit f54345a
Show file tree
Hide file tree
Showing 9 changed files with 113 additions and 40 deletions.
8 changes: 4 additions & 4 deletions docs/core/services/nodes-api.service.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ Accesses and manipulates ACS document nodes using their node IDs.
- _nodeId:_ `string` - ID of the target node
- _options:_ `{ includeSource?: boolean; } & NodesIncludeQuery & ContentPagingQuery` - Optional parameters supported by JS-API
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`Hold[]`](../../../lib/js-api/src/api/gs-core-rest-api/docs/Hold.md)`>` - List of assigned holds
- **initiateFolderSizeCalculation**(nodeId: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`JobIdBodyEntry`](../../../lib/js-api/src/api/content-rest-api/docs/JobIdBodyEntry.md)`>`<br/>
- **initiateFolderSizeCalculation**(nodeId: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`JobIdBodyEntry`](../../../lib/js-api/src/api/content-rest-api/docs/NodesApi.md#jobidbodyentry)`>`<br/>
Initiate a new request to calculate folder size.
- _nodeId:_ `string` - ID of the target node
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`JobIdBodyEntry`](../../../lib/js-api/src/api/content-rest-api/docs/JobIdBodyEntry.md)`>` - Job id which can be used to track request status
- **getFolderSizeInfo**(nodeId: `string`, jobId: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SizeDetailsEntry`](../../../lib/js-api/src/api/content-rest-api/docs/SizeDetailsEntry.md)`>`<br/>
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`JobIdBodyEntry`](../../../lib/js-api/src/api/content-rest-api/docs/NodesApi.md#jobidbodyentry)`>` - Job id which can be used to track request status
- **getFolderSizeInfo**(nodeId: `string`, jobId: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SizeDetailsEntry`](../../../lib/js-api/src/api/content-rest-api/docs/NodesApi.md#sizedetailsentry)`>`<br/>
Gets the size of a folder.
- _nodeId:_ `string` - ID of the target node
- _jobId:_ `string` - ID of the job started by the `initiateFolderSizeCalculation` request
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SizeDetailsEntry`](../../../lib/js-api/src/api/content-rest-api/docs/SizeDetailsEntry.md)`>` - Details of the folder
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SizeDetailsEntry`](../../../lib/js-api/src/api/content-rest-api/docs/NodesApi.md#sizedetailsentry)`>` - Details of the folder

## Details

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,15 +259,17 @@ export class NodesApiService {

/**
* Initiate a new request to calculate folder size.
*
* @param nodeId Node Id
* @returns The job id which can be used to track request status
*/
initiateFolderSizeCalculation(nodeId: string): Observable<JobIdBodyEntry> {
return from(this.nodesApi.initialFolderSizeCalculation(nodeId));
return from(this.nodesApi.initiateFolderSizeCalculation(nodeId));
}

/**
* Gets the size of a folder.
*
* @param nodeId Node Id
* @param jobId Job Id
* @returns Folder details
Expand Down
2 changes: 1 addition & 1 deletion lib/js-api/src/api/content-rest-api/api/nodes.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ export class NodesApi extends BaseApi {
* @param nodeId Node Id
* @returns The job id which can be used to track request status
*/
initialFolderSizeCalculation(nodeId: string): Promise<JobIdBodyEntry> {
initiateFolderSizeCalculation(nodeId: string): Promise<JobIdBodyEntry> {
throwIfNotDefined(nodeId, 'nodeId');

const pathParams = {
Expand Down
7 changes: 0 additions & 7 deletions lib/js-api/src/api/content-rest-api/docs/JobIdBody.md

This file was deleted.

7 changes: 0 additions & 7 deletions lib/js-api/src/api/content-rest-api/docs/JobIdBodyEntry.md

This file was deleted.

96 changes: 96 additions & 0 deletions lib/js-api/src/api/content-rest-api/docs/NodesApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ All URIs are relative to *https://localhost/alfresco/api/-default-/public/alfres
| [unlockNode](#unlockNode) | **POST** /nodes/{nodeId}/unlock | Unlock a node |
| [updateNode](#updateNode) | **PUT** /nodes/{nodeId} | Update a node |
| [updateNodeContent](#updateNodeContent) | **PUT** /nodes/{nodeId}/content | Update node content |
| [initialFolderSizeCalculation](#initialFolderSizeCalculation) | **POST** /nodes/{nodeId}/size-details | Initiate a new request to calculate folder size |
| [getFolderSizeInfo](#getFolderSizeInfo) | **GET** /nodes/{nodeId}/size-details/{jobId} | Gets the details of a folder |

## copyNode

Expand Down Expand Up @@ -1196,6 +1198,67 @@ nodesApi.updateNodeContent(`<nodeId>`, contentBodyUpdate, opts).then((data) => {
console.log('API called successfully. Returned data: ' + data);
});
```
## initialFolderSizeCalculation

Initiate a new request to calculate folder size.

> this endpoint is available in **Alfresco 7.1** and newer versions.
Initiates a request to calculate the size of the node with identifier **nodeId**.

**Parameters**

| Name | Type | Description |
|-----------------------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **nodeId** | string | The identifier of a node. |

**Return type**: [JobIdBodyEntry](#JobIdBodyEntry)

**Example**

```javascript
import {AlfrescoApi, NodesApi} from '@alfresco/js-api';

const alfrescoApi = new AlfrescoApi(/*..*/);
const nodesApi = new NodesApi(alfrescoApi);
const contentBodyUpdate = {};
const opts = {};

nodesApi.initiateFolderSizeCalculation(`<nodeId>`).then((data) => {
console.log('API called successfully. Returned data: ' + data);
});
```
## getFolderSizeInfo

Gets the size details of a folder

> this endpoint is available in **Alfresco 7.1** and newer versions.
Fetches the size details of folder with the identifier **nodeId**

**Parameters**

| Name | Type | Description |
|------------|----------|------------------------------------------------------------------------------------|
| **nodeId** | string | The identifier of a node. |
| **jobId** | string | The identifier for the job which is calculating the currently selected node's size |

**Return type**: [SizeDetailsEntry](#SizeDetailsEntry)

**Example**

```javascript
import {AlfrescoApi, NodesApi} from '@alfresco/js-api';

const alfrescoApi = new AlfrescoApi(/*..*/);
const nodesApi = new NodesApi(alfrescoApi);
const contentBodyUpdate = {};
const opts = {};

nodesApi.getFolderSizeInfo(`<nodeId>`, `<jobId>`).then((data) => {
console.log('API called successfully. Returned data: ' + data);
});
```

# Models

Expand Down Expand Up @@ -1409,6 +1472,39 @@ nodesApi.updateNodeContent(`<nodeId>`, contentBodyUpdate, opts).then((data) => {
| isInheritanceEnabled | boolean |
| locallySet | [PermissionElement[]](PermissionElement.md) |

# JobIdBodyEntry

**Properties**

| Name | Type |
|-----------|-------------------------|
| **entry** | [JobIdBody](#JobIdBody) |

# JobIdBody

**Properties**

| Name | Type | Description | Notes |
|-----------|--------|---------------------------------------------------------------------------------------|-------------------|
| **jobId** | string | Id of the job that can be used to track the status of folder size calculation request | [default to null] |

# SizeDetailsEntry

**Properties**

| Name | Type |
|-----------|-----------------------------|
| **entry** | [SizeDetails](#SizeDetails) |

# SizeDetails

**Properties**

| Name | Type | Description | Notes |
|-------------------|--------|-----------------------------------------------------------------------------|------------------|
| **id** | string | Unique alphanumeric id unique to this response request | [default to null]|
| **sizeInBytes** | string | Size of the folder in bytes | [default to null]|
| **calculatedAt** | string | Timestamp of when the folder size was calculated | [default to null]|
| **numberOfFiles** | number | Number of files present within the folder | [default to null]|
| **status** | string | Status of the request. Can be 'NOT-INITIATED', 'IN-PROGRESS' or 'COMPLETED' | [default to null]|
| **jobId** | string | The job ID which was used to track down the folder details | [default to null]|
12 changes: 0 additions & 12 deletions lib/js-api/src/api/content-rest-api/docs/SizeDetails.md

This file was deleted.

7 changes: 0 additions & 7 deletions lib/js-api/src/api/content-rest-api/docs/SizeDetailsEntry.md

This file was deleted.

10 changes: 9 additions & 1 deletion lib/js-api/src/api/content-rest-api/model/sizeDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class SizeDetails {
sizeInBytes: string;
calculatedAt: string;
numberOfFiles: number;
status: string;
status: SizeDetails.StatusEnum;
jobId: string;

constructor(entry: SizeDetails) {
Expand All @@ -32,3 +32,11 @@ export class SizeDetails {
this.jobId = entry.jobId;
}
}
export namespace SizeDetails {
export type StatusEnum = 'IN-PROGRESS' | 'COMPLETE' | 'NOT-INITIATED';
export const StatusEnum = {
IN_PROGRESS: 'IN-PROGRESS' as StatusEnum,
COMPLETE: 'COMPLETE' as StatusEnum,
NOT_INITIATED: 'NOT-INITIATED' as StatusEnum
};
}

0 comments on commit f54345a

Please sign in to comment.