From fe49359134441eedea73550bb989c7303db4ec42 Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Tue, 3 Dec 2024 17:07:00 +0530 Subject: [PATCH 01/15] [MNT-24575] Added APIs folder information --- .../lib/common/services/nodes-api.service.ts | 8 ++++++ .../src/api/content-rest-api/api/nodes.api.ts | 28 +++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/lib/content-services/src/lib/common/services/nodes-api.service.ts b/lib/content-services/src/lib/common/services/nodes-api.service.ts index 0d49083aea7..253cbe79017 100644 --- a/lib/content-services/src/lib/common/services/nodes-api.service.ts +++ b/lib/content-services/src/lib/common/services/nodes-api.service.ts @@ -246,6 +246,14 @@ export class NodesApiService { return this.createNodeInsideRoot(name || this.randomNodeName(), nodeType, properties, path); } + initiateFolderSizeCalculation(nodeId: string): Observable<{ entry: { jobId: string } }> { + return from(this.nodesApi.initialFolderSizeCalculation(nodeId)); + } + + getFolderSizeInfo(nodeId: string, jobId: string): Observable { + return from(this.nodesApi.getFolderSizeInfo(nodeId, jobId)); + } + private randomNodeName(): string { return `node_${Date.now()}`; } diff --git a/lib/js-api/src/api/content-rest-api/api/nodes.api.ts b/lib/js-api/src/api/content-rest-api/api/nodes.api.ts index 4f2129d30ec..b8216496a3c 100644 --- a/lib/js-api/src/api/content-rest-api/api/nodes.api.ts +++ b/lib/js-api/src/api/content-rest-api/api/nodes.api.ts @@ -960,4 +960,32 @@ export class NodesApi extends BaseApi { returnType: DirectAccessUrlEntry }); } + + initialFolderSizeCalculation(nodeId: string): Promise<{ entry: { jobId: string } }> { + throwIfNotDefined(nodeId, 'nodeId'); + + const pathParams = { + nodeId + }; + + return this.post({ + path: '/nodes/{nodeId}/size-details', + pathParams + }); + } + + getFolderSizeInfo(nodeId: string, jobId: string): Promise { + throwIfNotDefined(nodeId, 'nodeId'); + throwIfNotDefined(jobId, 'jobId'); + + const pathParams = { + nodeId, + jobId + }; + + return this.get({ + path: 'nodes/{nodeId}/size-details/{jobId}', + pathParams + }); + } } From 92017f973ab7e3d6e4345cac192f0fbf64df44af Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Thu, 5 Dec 2024 12:27:12 +0530 Subject: [PATCH 02/15] [MNT-24575] Added models --- .../lib/common/services/nodes-api.service.ts | 17 ++++++++++--- .../src/api/content-rest-api/api/nodes.api.ts | 14 +++++++---- .../src/api/content-rest-api/model/index.ts | 4 +++ .../api/content-rest-api/model/jobIdBody.ts | 20 +++++++++++++++ .../content-rest-api/model/jobIdBodyEntry.ts | 22 ++++++++++++++++ .../api/content-rest-api/model/sizeDetails.ts | 25 +++++++++++++++++++ .../model/sizeDetailsEntry.ts | 22 ++++++++++++++++ 7 files changed, 116 insertions(+), 8 deletions(-) create mode 100644 lib/js-api/src/api/content-rest-api/model/jobIdBody.ts create mode 100644 lib/js-api/src/api/content-rest-api/model/jobIdBodyEntry.ts create mode 100644 lib/js-api/src/api/content-rest-api/model/sizeDetails.ts create mode 100644 lib/js-api/src/api/content-rest-api/model/sizeDetailsEntry.ts diff --git a/lib/content-services/src/lib/common/services/nodes-api.service.ts b/lib/content-services/src/lib/common/services/nodes-api.service.ts index 253cbe79017..ff6fb5ea53e 100644 --- a/lib/content-services/src/lib/common/services/nodes-api.service.ts +++ b/lib/content-services/src/lib/common/services/nodes-api.service.ts @@ -16,7 +16,18 @@ */ import { UserPreferencesService } from '@alfresco/adf-core'; -import { ContentPagingQuery, Node, NodeAssignedHold, NodeEntry, NodePaging, NodesApi, NodesIncludeQuery, TrashcanApi } from '@alfresco/js-api'; +import { + ContentPagingQuery, + Node, + NodeAssignedHold, + NodeEntry, + NodePaging, + NodesApi, + NodesIncludeQuery, + TrashcanApi, + SizeDetailsEntry, + JobIdBodyEntry +} from '@alfresco/js-api'; import { Injectable } from '@angular/core'; import { from, Observable, Subject, throwError } from 'rxjs'; import { catchError, map } from 'rxjs/operators'; @@ -246,11 +257,11 @@ export class NodesApiService { return this.createNodeInsideRoot(name || this.randomNodeName(), nodeType, properties, path); } - initiateFolderSizeCalculation(nodeId: string): Observable<{ entry: { jobId: string } }> { + initiateFolderSizeCalculation(nodeId: string): Observable { return from(this.nodesApi.initialFolderSizeCalculation(nodeId)); } - getFolderSizeInfo(nodeId: string, jobId: string): Observable { + getFolderSizeInfo(nodeId: string, jobId: string): Observable { return from(this.nodesApi.getFolderSizeInfo(nodeId, jobId)); } diff --git a/lib/js-api/src/api/content-rest-api/api/nodes.api.ts b/lib/js-api/src/api/content-rest-api/api/nodes.api.ts index b8216496a3c..5d3ac70c1d8 100644 --- a/lib/js-api/src/api/content-rest-api/api/nodes.api.ts +++ b/lib/js-api/src/api/content-rest-api/api/nodes.api.ts @@ -28,7 +28,9 @@ import { NodeBodyMove, NodeBodyUpdate, NodeChildAssociationPaging, - NodeEntry + NodeEntry, + SizeDetailsEntry, + JobIdBodyEntry } from '../model'; import { BaseApi } from './base.api'; import { throwIfNotDefined } from '../../../assert'; @@ -961,7 +963,7 @@ export class NodesApi extends BaseApi { }); } - initialFolderSizeCalculation(nodeId: string): Promise<{ entry: { jobId: string } }> { + initialFolderSizeCalculation(nodeId: string): Promise { throwIfNotDefined(nodeId, 'nodeId'); const pathParams = { @@ -970,11 +972,12 @@ export class NodesApi extends BaseApi { return this.post({ path: '/nodes/{nodeId}/size-details', - pathParams + pathParams, + returnType: JobIdBodyEntry }); } - getFolderSizeInfo(nodeId: string, jobId: string): Promise { + getFolderSizeInfo(nodeId: string, jobId: string): Promise { throwIfNotDefined(nodeId, 'nodeId'); throwIfNotDefined(jobId, 'jobId'); @@ -985,7 +988,8 @@ export class NodesApi extends BaseApi { return this.get({ path: 'nodes/{nodeId}/size-details/{jobId}', - pathParams + pathParams, + returnType: SizeDetailsEntry }); } } diff --git a/lib/js-api/src/api/content-rest-api/model/index.ts b/lib/js-api/src/api/content-rest-api/model/index.ts index b3752363175..b8d8b818453 100644 --- a/lib/js-api/src/api/content-rest-api/model/index.ts +++ b/lib/js-api/src/api/content-rest-api/model/index.ts @@ -211,3 +211,7 @@ export * from './versionPagingList'; export * from './deletedNode'; export * from './nodeAssociation'; export * from './nodeChildAssociation'; +export * from './sizeDetails'; +export * from './sizeDetailsEntry'; +export * from './jobIdBody'; +export * from './jobIdBodyEntry'; diff --git a/lib/js-api/src/api/content-rest-api/model/jobIdBody.ts b/lib/js-api/src/api/content-rest-api/model/jobIdBody.ts new file mode 100644 index 00000000000..3f71f30b695 --- /dev/null +++ b/lib/js-api/src/api/content-rest-api/model/jobIdBody.ts @@ -0,0 +1,20 @@ +/*! + * @license + * Copyright © 2005-2024 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. + */ + +export class JobIdBody { + jobId: string; +} diff --git a/lib/js-api/src/api/content-rest-api/model/jobIdBodyEntry.ts b/lib/js-api/src/api/content-rest-api/model/jobIdBodyEntry.ts new file mode 100644 index 00000000000..36c64c4f3f1 --- /dev/null +++ b/lib/js-api/src/api/content-rest-api/model/jobIdBodyEntry.ts @@ -0,0 +1,22 @@ +/*! + * @license + * Copyright © 2005-2024 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 { JobIdBody } from './jobIdBody'; + +export class JobIdBodyEntry { + entry: JobIdBody; +} diff --git a/lib/js-api/src/api/content-rest-api/model/sizeDetails.ts b/lib/js-api/src/api/content-rest-api/model/sizeDetails.ts new file mode 100644 index 00000000000..3dfe5d8829d --- /dev/null +++ b/lib/js-api/src/api/content-rest-api/model/sizeDetails.ts @@ -0,0 +1,25 @@ +/*! + * @license + * Copyright © 2005-2024 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. + */ + +export class SizeDetails { + id: string; + sizeInBytes: string; + calculatedAt: string; + numberOfFiles: number; + status: string; + jobId: string; +} diff --git a/lib/js-api/src/api/content-rest-api/model/sizeDetailsEntry.ts b/lib/js-api/src/api/content-rest-api/model/sizeDetailsEntry.ts new file mode 100644 index 00000000000..4f295a701fe --- /dev/null +++ b/lib/js-api/src/api/content-rest-api/model/sizeDetailsEntry.ts @@ -0,0 +1,22 @@ +/*! + * @license + * Copyright © 2005-2024 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 { SizeDetails } from './sizeDetails'; + +export class SizeDetailsEntry { + entry: SizeDetails; +} From f641439ed464ba8f3a8409f1364e80ef470282b2 Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Thu, 5 Dec 2024 17:10:35 +0530 Subject: [PATCH 03/15] [MNT-24575] Added constructors to model --- lib/js-api/src/api/content-rest-api/model/jobIdBody.ts | 4 ++++ .../src/api/content-rest-api/model/jobIdBodyEntry.ts | 7 +++++++ lib/js-api/src/api/content-rest-api/model/sizeDetails.ts | 9 +++++++++ .../src/api/content-rest-api/model/sizeDetailsEntry.ts | 7 +++++++ 4 files changed, 27 insertions(+) diff --git a/lib/js-api/src/api/content-rest-api/model/jobIdBody.ts b/lib/js-api/src/api/content-rest-api/model/jobIdBody.ts index 3f71f30b695..1541418fda8 100644 --- a/lib/js-api/src/api/content-rest-api/model/jobIdBody.ts +++ b/lib/js-api/src/api/content-rest-api/model/jobIdBody.ts @@ -17,4 +17,8 @@ export class JobIdBody { jobId: string; + + constructor(jobIdBody: JobIdBody) { + this.jobId = jobIdBody.jobId; + } } diff --git a/lib/js-api/src/api/content-rest-api/model/jobIdBodyEntry.ts b/lib/js-api/src/api/content-rest-api/model/jobIdBodyEntry.ts index 36c64c4f3f1..41e817b5852 100644 --- a/lib/js-api/src/api/content-rest-api/model/jobIdBodyEntry.ts +++ b/lib/js-api/src/api/content-rest-api/model/jobIdBodyEntry.ts @@ -19,4 +19,11 @@ import { JobIdBody } from './jobIdBody'; export class JobIdBodyEntry { entry: JobIdBody; + + constructor(input?: Partial) { + if (input) { + Object.assign(this, input); + this.entry = input.entry ? new JobIdBody(input.entry) : undefined; + } + } } diff --git a/lib/js-api/src/api/content-rest-api/model/sizeDetails.ts b/lib/js-api/src/api/content-rest-api/model/sizeDetails.ts index 3dfe5d8829d..644af38c471 100644 --- a/lib/js-api/src/api/content-rest-api/model/sizeDetails.ts +++ b/lib/js-api/src/api/content-rest-api/model/sizeDetails.ts @@ -22,4 +22,13 @@ export class SizeDetails { numberOfFiles: number; status: string; jobId: string; + + constructor(entry: SizeDetails) { + this.id = entry.id; + this.sizeInBytes = entry.sizeInBytes; + this.calculatedAt = entry.calculatedAt; + this.numberOfFiles = entry.numberOfFiles; + this.status = entry.status; + this.jobId = entry.jobId; + } } diff --git a/lib/js-api/src/api/content-rest-api/model/sizeDetailsEntry.ts b/lib/js-api/src/api/content-rest-api/model/sizeDetailsEntry.ts index 4f295a701fe..0f8fac85d5c 100644 --- a/lib/js-api/src/api/content-rest-api/model/sizeDetailsEntry.ts +++ b/lib/js-api/src/api/content-rest-api/model/sizeDetailsEntry.ts @@ -19,4 +19,11 @@ import { SizeDetails } from './sizeDetails'; export class SizeDetailsEntry { entry: SizeDetails; + + constructor(input?: Partial) { + if (input) { + Object.assign(this, input); + this.entry = input.entry ? new SizeDetails(input.entry) : undefined; + } + } } From 670ce911aaf3ad9382759400d9ba0013fb595fe9 Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Fri, 6 Dec 2024 17:44:59 +0530 Subject: [PATCH 04/15] [MNT-24575] Added documentation --- docs/core/services/nodes-api.service.md | 9 +++++++++ .../src/api/content-rest-api/docs/JobIdBody.md | 7 +++++++ .../src/api/content-rest-api/docs/JobIdBodyEntry.md | 7 +++++++ .../src/api/content-rest-api/docs/SizeDetails.md | 12 ++++++++++++ .../api/content-rest-api/docs/SizeDetailsEntry.md | 7 +++++++ 5 files changed, 42 insertions(+) create mode 100644 lib/js-api/src/api/content-rest-api/docs/JobIdBody.md create mode 100644 lib/js-api/src/api/content-rest-api/docs/JobIdBodyEntry.md create mode 100644 lib/js-api/src/api/content-rest-api/docs/SizeDetails.md create mode 100644 lib/js-api/src/api/content-rest-api/docs/SizeDetailsEntry.md diff --git a/docs/core/services/nodes-api.service.md b/docs/core/services/nodes-api.service.md index ce6ef9582de..82beb830e6c 100644 --- a/docs/core/services/nodes-api.service.md +++ b/docs/core/services/nodes-api.service.md @@ -89,6 +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)`>`
+ 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)`>`
+ 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 ## Details diff --git a/lib/js-api/src/api/content-rest-api/docs/JobIdBody.md b/lib/js-api/src/api/content-rest-api/docs/JobIdBody.md new file mode 100644 index 00000000000..a7e3900d903 --- /dev/null +++ b/lib/js-api/src/api/content-rest-api/docs/JobIdBody.md @@ -0,0 +1,7 @@ +# 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] diff --git a/lib/js-api/src/api/content-rest-api/docs/JobIdBodyEntry.md b/lib/js-api/src/api/content-rest-api/docs/JobIdBodyEntry.md new file mode 100644 index 00000000000..c90bf91177a --- /dev/null +++ b/lib/js-api/src/api/content-rest-api/docs/JobIdBodyEntry.md @@ -0,0 +1,7 @@ +# JobIdBodyEntry + +**Properties** + +| Name | Type | +|-----------|---------------------------| +| **entry** | [JobIdBody](JobIdBody.md) | diff --git a/lib/js-api/src/api/content-rest-api/docs/SizeDetails.md b/lib/js-api/src/api/content-rest-api/docs/SizeDetails.md new file mode 100644 index 00000000000..8e865fa6858 --- /dev/null +++ b/lib/js-api/src/api/content-rest-api/docs/SizeDetails.md @@ -0,0 +1,12 @@ +# Size Details + +## Properties + + Name | Type | Description | Notes +-------------------|--------|-----------------------------------------------------------------------------|------------------- + **id** | string | | [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] diff --git a/lib/js-api/src/api/content-rest-api/docs/SizeDetailsEntry.md b/lib/js-api/src/api/content-rest-api/docs/SizeDetailsEntry.md new file mode 100644 index 00000000000..5ac215ff886 --- /dev/null +++ b/lib/js-api/src/api/content-rest-api/docs/SizeDetailsEntry.md @@ -0,0 +1,7 @@ +# SizeDetailsEntry + +**Properties** + +| Name | Type | +|-----------|-------------------------------| +| **entry** | [SizeDetails](SizeDetails.md) | From 03202a0b79bcdd0418d61a042a182956ca608f1a Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Fri, 6 Dec 2024 18:11:08 +0530 Subject: [PATCH 05/15] [MNT-24575] Added documentation --- .../lib/common/services/nodes-api.service.ts | 11 +++++++++++ .../src/api/content-rest-api/api/nodes.api.ts | 18 ++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/lib/content-services/src/lib/common/services/nodes-api.service.ts b/lib/content-services/src/lib/common/services/nodes-api.service.ts index ff6fb5ea53e..70bb7b5fe6a 100644 --- a/lib/content-services/src/lib/common/services/nodes-api.service.ts +++ b/lib/content-services/src/lib/common/services/nodes-api.service.ts @@ -257,10 +257,21 @@ export class NodesApiService { return this.createNodeInsideRoot(name || this.randomNodeName(), nodeType, properties, path); } + /** + * 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 { return from(this.nodesApi.initialFolderSizeCalculation(nodeId)); } + /** + * Gets the size of a folder. + * @param nodeId Node Id + * @param jobId Job Id + * @returns Folder details + */ getFolderSizeInfo(nodeId: string, jobId: string): Observable { return from(this.nodesApi.getFolderSizeInfo(nodeId, jobId)); } diff --git a/lib/js-api/src/api/content-rest-api/api/nodes.api.ts b/lib/js-api/src/api/content-rest-api/api/nodes.api.ts index 5d3ac70c1d8..23db7503f75 100644 --- a/lib/js-api/src/api/content-rest-api/api/nodes.api.ts +++ b/lib/js-api/src/api/content-rest-api/api/nodes.api.ts @@ -963,6 +963,14 @@ export class NodesApi extends BaseApi { }); } + /** + * Initiate a new request to calculate folder size. + * + * **Note:** this endpoint is available in Alfresco 7.1 and newer versions. + * + * @param nodeId Node Id + * @returns The job id which can be used to track request status + */ initialFolderSizeCalculation(nodeId: string): Promise { throwIfNotDefined(nodeId, 'nodeId'); @@ -977,6 +985,16 @@ export class NodesApi extends BaseApi { }); } + /** + * Gets the size of a folder. + * + * **Note:** this endpoint is available in Alfresco 7.1 and newer versions. + * + * @param nodeId Node Id + * @param jobId Job Id + * @returns Folder details + */ + getFolderSizeInfo(nodeId: string, jobId: string): Promise { throwIfNotDefined(nodeId, 'nodeId'); throwIfNotDefined(jobId, 'jobId'); From d5717eeb0be511fa03a1d4aa855241c38adb9e2e Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Wed, 18 Dec 2024 11:50:28 +0530 Subject: [PATCH 06/15] [MNT-24575] Addressed Code review comments --- docs/core/services/nodes-api.service.md | 8 +- .../lib/common/services/nodes-api.service.ts | 4 +- .../src/api/content-rest-api/api/nodes.api.ts | 2 +- .../api/content-rest-api/docs/JobIdBody.md | 7 -- .../content-rest-api/docs/JobIdBodyEntry.md | 7 -- .../src/api/content-rest-api/docs/NodesApi.md | 96 +++++++++++++++++++ .../api/content-rest-api/docs/SizeDetails.md | 12 --- .../content-rest-api/docs/SizeDetailsEntry.md | 7 -- .../api/content-rest-api/model/sizeDetails.ts | 10 +- 9 files changed, 113 insertions(+), 40 deletions(-) delete mode 100644 lib/js-api/src/api/content-rest-api/docs/JobIdBody.md delete mode 100644 lib/js-api/src/api/content-rest-api/docs/JobIdBodyEntry.md delete mode 100644 lib/js-api/src/api/content-rest-api/docs/SizeDetails.md delete mode 100644 lib/js-api/src/api/content-rest-api/docs/SizeDetailsEntry.md diff --git a/docs/core/services/nodes-api.service.md b/docs/core/services/nodes-api.service.md index 82beb830e6c..b9b9d89110d 100644 --- a/docs/core/services/nodes-api.service.md +++ b/docs/core/services/nodes-api.service.md @@ -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)`>`
+- **initiateFolderSizeCalculation**(nodeId: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`JobIdBodyEntry`](../../../lib/js-api/src/api/content-rest-api/docs/NodesApi.md#jobidbodyentry)`>`
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)`>`
+ - **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)`>`
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 diff --git a/lib/content-services/src/lib/common/services/nodes-api.service.ts b/lib/content-services/src/lib/common/services/nodes-api.service.ts index 70bb7b5fe6a..01a896fbcf0 100644 --- a/lib/content-services/src/lib/common/services/nodes-api.service.ts +++ b/lib/content-services/src/lib/common/services/nodes-api.service.ts @@ -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 { - 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 diff --git a/lib/js-api/src/api/content-rest-api/api/nodes.api.ts b/lib/js-api/src/api/content-rest-api/api/nodes.api.ts index 23db7503f75..e8db760303e 100644 --- a/lib/js-api/src/api/content-rest-api/api/nodes.api.ts +++ b/lib/js-api/src/api/content-rest-api/api/nodes.api.ts @@ -971,7 +971,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 { + initiateFolderSizeCalculation(nodeId: string): Promise { throwIfNotDefined(nodeId, 'nodeId'); const pathParams = { diff --git a/lib/js-api/src/api/content-rest-api/docs/JobIdBody.md b/lib/js-api/src/api/content-rest-api/docs/JobIdBody.md deleted file mode 100644 index a7e3900d903..00000000000 --- a/lib/js-api/src/api/content-rest-api/docs/JobIdBody.md +++ /dev/null @@ -1,7 +0,0 @@ -# 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] diff --git a/lib/js-api/src/api/content-rest-api/docs/JobIdBodyEntry.md b/lib/js-api/src/api/content-rest-api/docs/JobIdBodyEntry.md deleted file mode 100644 index c90bf91177a..00000000000 --- a/lib/js-api/src/api/content-rest-api/docs/JobIdBodyEntry.md +++ /dev/null @@ -1,7 +0,0 @@ -# JobIdBodyEntry - -**Properties** - -| Name | Type | -|-----------|---------------------------| -| **entry** | [JobIdBody](JobIdBody.md) | diff --git a/lib/js-api/src/api/content-rest-api/docs/NodesApi.md b/lib/js-api/src/api/content-rest-api/docs/NodesApi.md index e760708db4f..9a55040b6b2 100644 --- a/lib/js-api/src/api/content-rest-api/docs/NodesApi.md +++ b/lib/js-api/src/api/content-rest-api/docs/NodesApi.md @@ -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 @@ -1196,6 +1198,67 @@ nodesApi.updateNodeContent(``, 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(``).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(``, ``).then((data) => { + console.log('API called successfully. Returned data: ' + data); +}); +``` # Models @@ -1409,6 +1472,39 @@ nodesApi.updateNodeContent(``, 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]| diff --git a/lib/js-api/src/api/content-rest-api/docs/SizeDetails.md b/lib/js-api/src/api/content-rest-api/docs/SizeDetails.md deleted file mode 100644 index 8e865fa6858..00000000000 --- a/lib/js-api/src/api/content-rest-api/docs/SizeDetails.md +++ /dev/null @@ -1,12 +0,0 @@ -# Size Details - -## Properties - - Name | Type | Description | Notes --------------------|--------|-----------------------------------------------------------------------------|------------------- - **id** | string | | [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] diff --git a/lib/js-api/src/api/content-rest-api/docs/SizeDetailsEntry.md b/lib/js-api/src/api/content-rest-api/docs/SizeDetailsEntry.md deleted file mode 100644 index 5ac215ff886..00000000000 --- a/lib/js-api/src/api/content-rest-api/docs/SizeDetailsEntry.md +++ /dev/null @@ -1,7 +0,0 @@ -# SizeDetailsEntry - -**Properties** - -| Name | Type | -|-----------|-------------------------------| -| **entry** | [SizeDetails](SizeDetails.md) | diff --git a/lib/js-api/src/api/content-rest-api/model/sizeDetails.ts b/lib/js-api/src/api/content-rest-api/model/sizeDetails.ts index 644af38c471..4d697a13513 100644 --- a/lib/js-api/src/api/content-rest-api/model/sizeDetails.ts +++ b/lib/js-api/src/api/content-rest-api/model/sizeDetails.ts @@ -20,7 +20,7 @@ export class SizeDetails { sizeInBytes: string; calculatedAt: string; numberOfFiles: number; - status: string; + status: SizeDetails.StatusEnum; jobId: string; constructor(entry: SizeDetails) { @@ -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 + }; +} From 8430b1311d712d63a3d1a0f19fdaaf6f8325361f Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Fri, 20 Dec 2024 12:03:36 +0530 Subject: [PATCH 07/15] [MNT-24575] Added unit tests. Fixed typo --- .../common/services/nodes-api.service.spec.ts | 71 +++++++++++++++++++ .../src/api/content-rest-api/docs/NodesApi.md | 6 +- 2 files changed, 74 insertions(+), 3 deletions(-) create mode 100644 lib/content-services/src/lib/common/services/nodes-api.service.spec.ts diff --git a/lib/content-services/src/lib/common/services/nodes-api.service.spec.ts b/lib/content-services/src/lib/common/services/nodes-api.service.spec.ts new file mode 100644 index 00000000000..6e21ccca974 --- /dev/null +++ b/lib/content-services/src/lib/common/services/nodes-api.service.spec.ts @@ -0,0 +1,71 @@ +/*! + * @license + * Copyright © 2005-2024 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 { TestBed } from '@angular/core/testing'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { AlfrescoApiService, AlfrescoApiServiceMock, NodesApiService } from '@alfresco/adf-content-services'; +import { CoreTestingModule, RedirectAuthService } from '@alfresco/adf-core'; +import { EMPTY, firstValueFrom, of } from 'rxjs'; +import { JobIdBodyEntry, SizeDetails, SizeDetailsEntry } from '@alfresco/js-api'; + +const fakeInitiateFolderSizeResponse: JobIdBodyEntry = { + entry: { + jobId: 'fake-job-id' + } +}; + +const fakeFolderSizeResponse: SizeDetailsEntry = { + entry: { + jobId: 'fake-job-id', + calculatedAt: new Date().toString(), + sizeInBytes: '1234', + numberOfFiles: 1, + status: SizeDetails.StatusEnum.COMPLETE, + id: 'fake-id' + } +}; + +describe('NodesApiService', () => { + let nodesApiService: NodesApiService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule, CoreTestingModule], + providers: [ + NodesApiService, + { provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock }, + { provide: RedirectAuthService, useValue: { onLogin: EMPTY, onTokenReceived: of(), init: () => {} } } + ] + }); + + nodesApiService = TestBed.inject(NodesApiService); + }); + + it('should call initiateFolderSizeCalculation api with nodeId parameter', async () => { + spyOn(nodesApiService.nodesApi, 'initiateFolderSizeCalculation').and.returnValue(Promise.resolve(fakeInitiateFolderSizeResponse)); + await firstValueFrom(nodesApiService.initiateFolderSizeCalculation('fake-node-id')); + + expect(nodesApiService.nodesApi.initiateFolderSizeCalculation).toHaveBeenCalledWith('fake-node-id'); + }); + + it('should call getFolderSizeInfo api with nodeId and jobId parameter', async () => { + spyOn(nodesApiService.nodesApi, 'getFolderSizeInfo').and.returnValue(Promise.resolve(fakeFolderSizeResponse)); + await firstValueFrom(nodesApiService.getFolderSizeInfo('fake-node-id', 'fake-job-id')); + + expect(nodesApiService.nodesApi.getFolderSizeInfo).toHaveBeenCalledWith('fake-node-id', 'fake-job-id'); + }); +}); diff --git a/lib/js-api/src/api/content-rest-api/docs/NodesApi.md b/lib/js-api/src/api/content-rest-api/docs/NodesApi.md index 9a55040b6b2..e642208404e 100644 --- a/lib/js-api/src/api/content-rest-api/docs/NodesApi.md +++ b/lib/js-api/src/api/content-rest-api/docs/NodesApi.md @@ -25,7 +25,7 @@ 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 | +| [initiateFolderSizeCalculation](#initiateFolderSizeCalculation) | **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 @@ -1198,7 +1198,7 @@ nodesApi.updateNodeContent(``, contentBodyUpdate, opts).then((data) => { console.log('API called successfully. Returned data: ' + data); }); ``` -## initialFolderSizeCalculation +## initiateFolderSizeCalculation Initiate a new request to calculate folder size. @@ -1241,7 +1241,7 @@ Fetches the size details of folder with the identifier **nodeId** | 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 | +| **jobId** | string | The identifier for the job which is calculating the currently selected node's size | **Return type**: [SizeDetailsEntry](#SizeDetailsEntry) From 7dae91db15e86fa54aab9c280697fcc8179cdf6d Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Fri, 20 Dec 2024 14:32:34 +0530 Subject: [PATCH 08/15] [MNT-24575] Fixed accesibility issue in DialogComponent. Fixed typo in enum --- lib/core/src/lib/dialogs/dialog/dialog.component.html | 1 + lib/js-api/src/api/content-rest-api/model/sizeDetails.ts | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/core/src/lib/dialogs/dialog/dialog.component.html b/lib/core/src/lib/dialogs/dialog/dialog.component.html index e87b915292d..a4baa769de7 100644 --- a/lib/core/src/lib/dialogs/dialog/dialog.component.html +++ b/lib/core/src/lib/dialogs/dialog/dialog.component.html @@ -22,6 +22,7 @@

{{ data.title | translate }}

*ngIf="!isCloseButtonHidden" mat-icon-button mat-dialog-close + title="{{'CLOSE' | translate }}" data-automation-id="adf-dialog-close-button" > close diff --git a/lib/js-api/src/api/content-rest-api/model/sizeDetails.ts b/lib/js-api/src/api/content-rest-api/model/sizeDetails.ts index 4d697a13513..cc1a22371c6 100644 --- a/lib/js-api/src/api/content-rest-api/model/sizeDetails.ts +++ b/lib/js-api/src/api/content-rest-api/model/sizeDetails.ts @@ -33,10 +33,10 @@ export class SizeDetails { } } export namespace SizeDetails { - export type StatusEnum = 'IN-PROGRESS' | 'COMPLETE' | 'NOT-INITIATED'; + export type StatusEnum = 'IN-PROGRESS' | 'COMPLETED' | 'NOT-INITIATED'; export const StatusEnum = { IN_PROGRESS: 'IN-PROGRESS' as StatusEnum, - COMPLETE: 'COMPLETE' as StatusEnum, + COMPLETE: 'COMPLETED' as StatusEnum, NOT_INITIATED: 'NOT-INITIATED' as StatusEnum }; } From 5ef3fc9e2b52278cf26cff7ae996eac489340b18 Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Thu, 2 Jan 2025 16:51:53 +0530 Subject: [PATCH 09/15] [MNT-24575] Fixed typo, incorrect ACS version, and incorrect imports --- .../src/lib/common/services/nodes-api.service.spec.ts | 4 +++- lib/js-api/src/api/content-rest-api/api/nodes.api.ts | 4 ++-- lib/js-api/src/api/content-rest-api/docs/NodesApi.md | 6 +++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/content-services/src/lib/common/services/nodes-api.service.spec.ts b/lib/content-services/src/lib/common/services/nodes-api.service.spec.ts index 6e21ccca974..70f31fb41a9 100644 --- a/lib/content-services/src/lib/common/services/nodes-api.service.spec.ts +++ b/lib/content-services/src/lib/common/services/nodes-api.service.spec.ts @@ -17,10 +17,12 @@ import { TestBed } from '@angular/core/testing'; import { HttpClientTestingModule } from '@angular/common/http/testing'; -import { AlfrescoApiService, AlfrescoApiServiceMock, NodesApiService } from '@alfresco/adf-content-services'; import { CoreTestingModule, RedirectAuthService } from '@alfresco/adf-core'; import { EMPTY, firstValueFrom, of } from 'rxjs'; import { JobIdBodyEntry, SizeDetails, SizeDetailsEntry } from '@alfresco/js-api'; +import { NodesApiService } from './nodes-api.service'; +import { AlfrescoApiService } from '../../services/alfresco-api.service'; +import { AlfrescoApiServiceMock } from '../../mock/alfresco-api.service.mock'; const fakeInitiateFolderSizeResponse: JobIdBodyEntry = { entry: { diff --git a/lib/js-api/src/api/content-rest-api/api/nodes.api.ts b/lib/js-api/src/api/content-rest-api/api/nodes.api.ts index e8db760303e..74ed73db181 100644 --- a/lib/js-api/src/api/content-rest-api/api/nodes.api.ts +++ b/lib/js-api/src/api/content-rest-api/api/nodes.api.ts @@ -966,7 +966,7 @@ export class NodesApi extends BaseApi { /** * Initiate a new request to calculate folder size. * - * **Note:** this endpoint is available in Alfresco 7.1 and newer versions. + * **Note:** this endpoint is available in Alfresco 25.1.0 and newer versions. * * @param nodeId Node Id * @returns The job id which can be used to track request status @@ -988,7 +988,7 @@ export class NodesApi extends BaseApi { /** * Gets the size of a folder. * - * **Note:** this endpoint is available in Alfresco 7.1 and newer versions. + * **Note:** this endpoint is available in Alfresco 25.1.0 and newer versions. * * @param nodeId Node Id * @param jobId Job Id diff --git a/lib/js-api/src/api/content-rest-api/docs/NodesApi.md b/lib/js-api/src/api/content-rest-api/docs/NodesApi.md index e642208404e..a2be1713088 100644 --- a/lib/js-api/src/api/content-rest-api/docs/NodesApi.md +++ b/lib/js-api/src/api/content-rest-api/docs/NodesApi.md @@ -1200,9 +1200,9 @@ nodesApi.updateNodeContent(``, contentBodyUpdate, opts).then((data) => { ``` ## initiateFolderSizeCalculation -Initiate a new request to calculate folder size. +Initiates a new request to calculate folder size. -> this endpoint is available in **Alfresco 7.1** and newer versions. +> this endpoint is available in **Alfresco 25.1.0** and newer versions. Initiates a request to calculate the size of the node with identifier **nodeId**. @@ -1232,7 +1232,7 @@ nodesApi.initiateFolderSizeCalculation(``).then((data) => { Gets the size details of a folder -> this endpoint is available in **Alfresco 7.1** and newer versions. +> this endpoint is available in **Alfresco 25.1.0** and newer versions. Fetches the size details of folder with the identifier **nodeId** From 5e250c25fefa8bd9e69406e5dae50ddfc96e5d9d Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Fri, 3 Jan 2025 14:37:13 +0530 Subject: [PATCH 10/15] [MNT-24575] Added unit tests to js-api --- .../test/content-services/nodeApi.spec.ts | 55 +++++++++++++++++ .../mockObjects/content-services/node.mock.ts | 59 +++++++++++++++++++ 2 files changed, 114 insertions(+) diff --git a/lib/js-api/test/content-services/nodeApi.spec.ts b/lib/js-api/test/content-services/nodeApi.spec.ts index bf46b3f0387..f6f9e96dfca 100644 --- a/lib/js-api/test/content-services/nodeApi.spec.ts +++ b/lib/js-api/test/content-services/nodeApi.spec.ts @@ -150,4 +150,59 @@ describe('Node', () => { ); }); }); + + describe('FolderInformation', () => { + it('should return jobId on initiateFolderSizeCalculation API call if everything is ok', (done) => { + nodeMock.post200ResponseInitiateFolderSizeCalculation(); + + nodesApi.initiateFolderSizeCalculation('b4cff62a-664d-4d45-9302-98723eac1319').then((response) => { + assert.equal(response.entry.jobId, '5ade426e-8a04-4d50-9e42-6e8a041d50f3'); + done(); + }); + }); + + it('should return 404 error on initiateFolderSizeCalculation API call if nodeId is not found', (done) => { + nodeMock.post404NodeIdNotFound(); + + nodesApi.initiateFolderSizeCalculation('b4cff62a-664d-4d45-9302-98723eac1319').then( + () => {}, + (err) => { + const { error } = JSON.parse(err.response.text); + assert.equal(error.statusCode, 404); + assert.equal(error.errorKey, 'framework.exception.EntityNotFound'); + assert.equal(error.briefSummary, '11207522 The entity with id: b4cff62a-664d-4d45-9302-98723eac1319 was not found'); + done(); + } + ); + }); + + it('should return size details on getFolderSizeInfo API call if everything is ok', (done) => { + nodeMock.get200ResponseGetFolderSizeInfo(); + + nodesApi.getFolderSizeInfo('b4cff62a-664d-4d45-9302-98723eac1319', '5ade426e-8a04-4d50-9e42-6e8a041d50f3').then((response) => { + assert.equal(response.entry.id, '32e522f1-1f28-4ea3-a522-f11f284ea397'); + assert.equal(response.entry.jobId, '5ade426e-8a04-4d50-9e42-6e8a041d50f3'); + assert.equal(response.entry.sizeInBytes, 2689); + assert.equal(response.entry.numberOfFiles, 100); + assert.equal(response.entry.calculatedAt, '2024-12-20T12:02:23.989+0000'); + assert.equal(response.entry.status, 'COMPLETED'); + done(); + }); + }); + + it('should return 404 error on getFolderSizeInfo API call if jobId is not found', (done) => { + nodeMock.get404JobIdNotFound(); + + nodesApi.getFolderSizeInfo('b4cff62a-664d-4d45-9302-98723eac1319', '5ade426e-8a04-4d50-9e42-6e8a041d50f3').then( + () => {}, + (err) => { + const { error } = JSON.parse(err.response.text); + assert.equal(error.statusCode, 404); + assert.equal(error.errorKey, 'jobId does not exist'); + assert.equal(error.briefSummary, '11207212 jobId does not exist'); + done(); + } + ); + }); + }); }); diff --git a/lib/js-api/test/mockObjects/content-services/node.mock.ts b/lib/js-api/test/mockObjects/content-services/node.mock.ts index d960b924e5a..a47787c5a84 100644 --- a/lib/js-api/test/mockObjects/content-services/node.mock.ts +++ b/lib/js-api/test/mockObjects/content-services/node.mock.ts @@ -230,4 +230,63 @@ export class NodeMock extends BaseMock { } }); } + + post200ResponseInitiateFolderSizeCalculation(): void { + nock(this.host, { encodedQueryParams: true }) + .post('/alfresco/api/-default-/public/alfresco/versions/1/nodes/b4cff62a-664d-4d45-9302-98723eac1319/size-details') + .reply(200, { + entry: { + jobId: '5ade426e-8a04-4d50-9e42-6e8a041d50f3' + } + }); + } + + post404NodeIdNotFound(): void { + nock(this.host, { encodedQueryParams: true }) + .post('/alfresco/api/-default-/public/alfresco/versions/1/nodes/b4cff62a-664d-4d45-9302-98723eac1319/size-details') + .reply(404, { + error: { + errorKey: 'framework.exception.EntityNotFound', + statusCode: 404, + briefSummary: '11207522 The entity with id: b4cff62a-664d-4d45-9302-98723eac1319 was not found', + stackTrace: 'For security reasons the stack trace is no longer displayed, but the property is kept for previous versions', + descriptionURL: 'https://api-explorer.alfresco.com', + logId: 'fafaf3c9-4e23-412b-baf3-c94e23912be5' + } + }); + } + + get200ResponseGetFolderSizeInfo(): void { + nock(this.host, { encodedQueryParams: true }) + .get( + '/alfresco/api/-default-/public/alfresco/versions/1/nodes/b4cff62a-664d-4d45-9302-98723eac1319/size-details/5ade426e-8a04-4d50-9e42-6e8a041d50f3' + ) + .reply(200, { + entry: { + numberOfFiles: 100, + jobId: '5ade426e-8a04-4d50-9e42-6e8a041d50f3', + sizeInBytes: 2689, + id: '32e522f1-1f28-4ea3-a522-f11f284ea397', + calculatedAt: '2024-12-20T12:02:23.989+0000', + status: 'COMPLETED' + } + }); + } + + get404JobIdNotFound(): void { + nock(this.host, { encodedQueryParams: true }) + .get( + '/alfresco/api/-default-/public/alfresco/versions/1/nodes/b4cff62a-664d-4d45-9302-98723eac1319/size-details/5ade426e-8a04-4d50-9e42-6e8a041d50f3' + ) + .reply(404, { + error: { + errorKey: 'jobId does not exist', + statusCode: 404, + briefSummary: '11207212 jobId does not exist', + stackTrace: 'For security reasons the stack trace is no longer displayed, but the property is kept for previous versions', + descriptionURL: 'https://api-explorer.alfresco.com', + logId: 'a98180c0-b1c0-48cb-8180-c0b1c0f8cba8' + } + }); + } } From f12d570693f8b1c5d32b75599ab6b6ae7022ce97 Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Tue, 7 Jan 2025 11:37:39 +0530 Subject: [PATCH 11/15] Empty commit to trigger GHA From 377c0710574ae9475ec5161cfbe22239284016a4 Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Tue, 7 Jan 2025 12:34:30 +0530 Subject: [PATCH 12/15] [ci:force] Empty force commit to trigger GHA From 4fe8d1620b6f7d0fb485c02efbb517b2fc1aab32 Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Tue, 7 Jan 2025 14:09:47 +0530 Subject: [PATCH 13/15] [MNT-24575] Fixed linting issue --- lib/js-api/src/api/content-rest-api/api/nodes.api.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/js-api/src/api/content-rest-api/api/nodes.api.ts b/lib/js-api/src/api/content-rest-api/api/nodes.api.ts index 74ed73db181..d0fdc629067 100644 --- a/lib/js-api/src/api/content-rest-api/api/nodes.api.ts +++ b/lib/js-api/src/api/content-rest-api/api/nodes.api.ts @@ -964,10 +964,9 @@ export class NodesApi extends BaseApi { } /** - * Initiate a new request to calculate folder size. + * Initiate a new request to calculate folder size.* * * **Note:** this endpoint is available in Alfresco 25.1.0 and newer versions. - * * @param nodeId Node Id * @returns The job id which can be used to track request status */ @@ -989,7 +988,6 @@ export class NodesApi extends BaseApi { * Gets the size of a folder. * * **Note:** this endpoint is available in Alfresco 25.1.0 and newer versions. - * * @param nodeId Node Id * @param jobId Job Id * @returns Folder details From 83b094ada61c246124b7aa3faf6c971a99ca4c9a Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Tue, 7 Jan 2025 14:31:32 +0530 Subject: [PATCH 14/15] [MNT-24575] Removed redundant * --- lib/js-api/src/api/content-rest-api/api/nodes.api.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/js-api/src/api/content-rest-api/api/nodes.api.ts b/lib/js-api/src/api/content-rest-api/api/nodes.api.ts index d0fdc629067..7fe53721c8b 100644 --- a/lib/js-api/src/api/content-rest-api/api/nodes.api.ts +++ b/lib/js-api/src/api/content-rest-api/api/nodes.api.ts @@ -964,7 +964,7 @@ export class NodesApi extends BaseApi { } /** - * Initiate a new request to calculate folder size.* + * Initiate a new request to calculate folder size. * * **Note:** this endpoint is available in Alfresco 25.1.0 and newer versions. * @param nodeId Node Id From 8a19b121ddb7dcbae204cf5a9539129de5d19027 Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Tue, 7 Jan 2025 14:53:48 +0530 Subject: [PATCH 15/15] [ci:force] Empty force commit to trigger GHA