From cdb65bf204ac22a064ecc04b9dc4dbe667068c84 Mon Sep 17 00:00:00 2001 From: AleksanderSklorz <115619721+AleksanderSklorz@users.noreply.github.com> Date: Mon, 2 Jun 2025 10:15:19 +0200 Subject: [PATCH] [ACS-9377] remove the join button for records management library for user s without permissions for that library (#10901) * [ACS-9377] Added function for file plans to get file plan roles * [ACS-9377] Types and documentation * [ACS-9377] Unit tests * [ACS-9377] Fixed sonar cloud issue --- .../api/gs-core-rest-api/api/filePlans.api.ts | 23 ++++ .../api/gs-core-rest-api/docs/FilePlanRole.md | 12 ++ .../docs/FilePlanRoleCapability.md | 11 ++ .../docs/FilePlanRoleCapabilityGroup.md | 9 ++ .../docs/FilePlanRoleEntry.md | 8 ++ .../docs/FilePlanRolePaging.md | 8 ++ .../docs/FilePlanRolePagingList.md | 9 ++ .../docs/FilePlanRoleParameters.md | 8 ++ .../docs/FilePlanRoleParametersWhere.md | 8 ++ .../api/gs-core-rest-api/docs/FilePlansApi.md | 50 ++++++- .../gs-core-rest-api/model/filePlanRole.ts | 33 +++++ .../model/filePlanRoleCapability.ts | 32 +++++ .../model/filePlanRoleCapabilityGroup.ts | 27 ++++ .../model/filePlanRoleEntry.ts | 29 ++++ .../model/filePlanRolePaging.ts | 29 ++++ .../model/filePlanRolePagingList.ts | 32 +++++ .../model/filePlanRoleParameters.ts | 22 +++ .../model/filePlanRoleParametersWhere.ts | 20 +++ .../src/api/gs-core-rest-api/model/index.ts | 8 ++ .../governance-services/filePlansApi.spec.ts | 129 ++++++++++++++++++ .../goverance-services/file-plans.mock.ts | 101 ++++++++++++++ lib/js-api/test/mockObjects/index.ts | 1 + 22 files changed, 602 insertions(+), 7 deletions(-) create mode 100644 lib/js-api/src/api/gs-core-rest-api/docs/FilePlanRole.md create mode 100644 lib/js-api/src/api/gs-core-rest-api/docs/FilePlanRoleCapability.md create mode 100644 lib/js-api/src/api/gs-core-rest-api/docs/FilePlanRoleCapabilityGroup.md create mode 100644 lib/js-api/src/api/gs-core-rest-api/docs/FilePlanRoleEntry.md create mode 100644 lib/js-api/src/api/gs-core-rest-api/docs/FilePlanRolePaging.md create mode 100644 lib/js-api/src/api/gs-core-rest-api/docs/FilePlanRolePagingList.md create mode 100644 lib/js-api/src/api/gs-core-rest-api/docs/FilePlanRoleParameters.md create mode 100644 lib/js-api/src/api/gs-core-rest-api/docs/FilePlanRoleParametersWhere.md create mode 100644 lib/js-api/src/api/gs-core-rest-api/model/filePlanRole.ts create mode 100644 lib/js-api/src/api/gs-core-rest-api/model/filePlanRoleCapability.ts create mode 100644 lib/js-api/src/api/gs-core-rest-api/model/filePlanRoleCapabilityGroup.ts create mode 100644 lib/js-api/src/api/gs-core-rest-api/model/filePlanRoleEntry.ts create mode 100644 lib/js-api/src/api/gs-core-rest-api/model/filePlanRolePaging.ts create mode 100644 lib/js-api/src/api/gs-core-rest-api/model/filePlanRolePagingList.ts create mode 100644 lib/js-api/src/api/gs-core-rest-api/model/filePlanRoleParameters.ts create mode 100644 lib/js-api/src/api/gs-core-rest-api/model/filePlanRoleParametersWhere.ts create mode 100644 lib/js-api/test/governance-services/filePlansApi.spec.ts create mode 100644 lib/js-api/test/mockObjects/goverance-services/file-plans.mock.ts diff --git a/lib/js-api/src/api/gs-core-rest-api/api/filePlans.api.ts b/lib/js-api/src/api/gs-core-rest-api/api/filePlans.api.ts index e0e1817020..00e89bde09 100644 --- a/lib/js-api/src/api/gs-core-rest-api/api/filePlans.api.ts +++ b/lib/js-api/src/api/gs-core-rest-api/api/filePlans.api.ts @@ -24,6 +24,7 @@ import { BaseApi } from './base.api'; import { buildCollectionParam } from '../../../alfrescoApiClient'; import { throwIfNotDefined } from '../../../assert'; import { RecordsIncludeQuery, RecordsPagingQuery, RecordsSourceQuery } from './types'; +import { FilePlanRolePaging, FilePlanRoleParameters } from '../model'; /** * FilePlansApi service. @@ -158,4 +159,26 @@ export class FilePlansApi extends BaseApi { returnType: FilePlanEntry }); } + + /** + * Gets a list of roles for the specified file plan. + * @param filePlanId The identifier of a file plan. You can also use the -filePlan- alias. + * @param parameters Optional parameters + * @returns Promise + */ + getFilePlanRoles(filePlanId: string, parameters?: FilePlanRoleParameters): Promise { + throwIfNotDefined(filePlanId, 'filePlanId'); + + return this.get({ + path: '/file-plans/{filePlanId}/roles', + pathParams: { + filePlanId + }, + queryParams: { + where: parameters?.where?.capabilityNames + ? `(capabilityName in (${parameters.where.capabilityNames.map((value) => "'" + value + "'").join(', ')}))` + : undefined + } + }); + } } diff --git a/lib/js-api/src/api/gs-core-rest-api/docs/FilePlanRole.md b/lib/js-api/src/api/gs-core-rest-api/docs/FilePlanRole.md new file mode 100644 index 0000000000..9d5103e3da --- /dev/null +++ b/lib/js-api/src/api/gs-core-rest-api/docs/FilePlanRole.md @@ -0,0 +1,12 @@ +# FilePlanRole + +## Properties +| Name | Type | +|--------------------|-----------------------------------------------------------| +| **displayLabel** | string | +| **groupShortName** | string | +| **name** | string | +| **roleGroupName** | string | +| **capabilities** | [**FilePlanRoleCapability[]**](FilePlanRoleCapability.md) | + + diff --git a/lib/js-api/src/api/gs-core-rest-api/docs/FilePlanRoleCapability.md b/lib/js-api/src/api/gs-core-rest-api/docs/FilePlanRoleCapability.md new file mode 100644 index 0000000000..4491569660 --- /dev/null +++ b/lib/js-api/src/api/gs-core-rest-api/docs/FilePlanRoleCapability.md @@ -0,0 +1,11 @@ +# FilePLanRoleCapability + +## Properties +| Name | Type | +|-----------|-------------------------------------------------------------------| +| **group** | [**FilePlanRoleCapabilityGroup**](FilePlanRoleCapabilityGroup.md) | +| **index** | number | +| **name** | string | +| **title** | string | + + diff --git a/lib/js-api/src/api/gs-core-rest-api/docs/FilePlanRoleCapabilityGroup.md b/lib/js-api/src/api/gs-core-rest-api/docs/FilePlanRoleCapabilityGroup.md new file mode 100644 index 0000000000..ff7545ae7c --- /dev/null +++ b/lib/js-api/src/api/gs-core-rest-api/docs/FilePlanRoleCapabilityGroup.md @@ -0,0 +1,9 @@ +# FilePlanRoleCapabilityGroup + +## Properties +| Name | Type | +|-----------|--------| +| **id** | string | +| **title** | string | + + diff --git a/lib/js-api/src/api/gs-core-rest-api/docs/FilePlanRoleEntry.md b/lib/js-api/src/api/gs-core-rest-api/docs/FilePlanRoleEntry.md new file mode 100644 index 0000000000..d9397df114 --- /dev/null +++ b/lib/js-api/src/api/gs-core-rest-api/docs/FilePlanRoleEntry.md @@ -0,0 +1,8 @@ +# FilePlanRoleEntry + +## Properties +| Name | Type | +|-----------|-------------------------------------| +| **entry** | [**FilePlanRole**](FilePlanRole.md) | + + diff --git a/lib/js-api/src/api/gs-core-rest-api/docs/FilePlanRolePaging.md b/lib/js-api/src/api/gs-core-rest-api/docs/FilePlanRolePaging.md new file mode 100644 index 0000000000..a7ef29cb6a --- /dev/null +++ b/lib/js-api/src/api/gs-core-rest-api/docs/FilePlanRolePaging.md @@ -0,0 +1,8 @@ +# FilePLanRolePaging + +## Properties +| Name | Type | +|----------|---------------------------------------------------------| +| **list** | [**FilePlanRolePagingList**](FilePlanRolePagingList.md) | + + diff --git a/lib/js-api/src/api/gs-core-rest-api/docs/FilePlanRolePagingList.md b/lib/js-api/src/api/gs-core-rest-api/docs/FilePlanRolePagingList.md new file mode 100644 index 0000000000..29d7fee347 --- /dev/null +++ b/lib/js-api/src/api/gs-core-rest-api/docs/FilePlanRolePagingList.md @@ -0,0 +1,9 @@ +# FilePLanRolePagingList + +## Properties +| Name | Type | +|----------------|-------------------------------------------------------------| +| **entries** | [**FilePlanRoleEntry[]**](FilePlanRoleEntry.md) | +| **pagination** | [**Pagination**](../../content-rest-api/docs/Pagination.md) | + + diff --git a/lib/js-api/src/api/gs-core-rest-api/docs/FilePlanRoleParameters.md b/lib/js-api/src/api/gs-core-rest-api/docs/FilePlanRoleParameters.md new file mode 100644 index 0000000000..5999e6b1ff --- /dev/null +++ b/lib/js-api/src/api/gs-core-rest-api/docs/FilePlanRoleParameters.md @@ -0,0 +1,8 @@ +# FilePlanRoleParameters + +## Properties +| Name | Type | +|-----------|-------------------------------------------------------------------| +| **where** | [**FilePlanRoleParametersWhere**](FilePlanRoleParametersWhere.md) | + + diff --git a/lib/js-api/src/api/gs-core-rest-api/docs/FilePlanRoleParametersWhere.md b/lib/js-api/src/api/gs-core-rest-api/docs/FilePlanRoleParametersWhere.md new file mode 100644 index 0000000000..95b50cad52 --- /dev/null +++ b/lib/js-api/src/api/gs-core-rest-api/docs/FilePlanRoleParametersWhere.md @@ -0,0 +1,8 @@ +# FilePlanRoleParametersWhere + +## Properties +| Name | Type | +|---------------------|----------| +| **capabilityNames** | string[] | + + diff --git a/lib/js-api/src/api/gs-core-rest-api/docs/FilePlansApi.md b/lib/js-api/src/api/gs-core-rest-api/docs/FilePlansApi.md index 61be364a89..0ec839ce02 100644 --- a/lib/js-api/src/api/gs-core-rest-api/docs/FilePlansApi.md +++ b/lib/js-api/src/api/gs-core-rest-api/docs/FilePlansApi.md @@ -2,13 +2,13 @@ All URIs are relative to *https://localhost/alfresco/api/-default-/public/gs/versions/1* -Method | HTTP request | Description -------------- | ------------- | ------------- -[**createFilePlanCategories**](FilePlansApi.md#createFilePlanCategories) | **POST** /file-plans/{filePlanId}/categories | Create record categories for a file plan -[**getFilePlan**](FilePlansApi.md#getFilePlan) | **GET** /file-plans/{filePlanId} | Get a file plan -[**getFilePlanCategories**](FilePlansApi.md#getFilePlanCategories) | **GET** /file-plans/{filePlanId}/categories | List file plans's children -[**updateFilePlan**](FilePlansApi.md#updateFilePlan) | **PUT** /file-plans/{filePlanId} | Update a file plan - +| Method | HTTP request | Description | +|--------------------------------------------------------------------------|----------------------------------------------|---------------------------------------------------| +| [**createFilePlanCategories**](FilePlansApi.md#createFilePlanCategories) | **POST** /file-plans/{filePlanId}/categories | Create record categories for a file plan | +| [**getFilePlan**](FilePlansApi.md#getFilePlan) | **GET** /file-plans/{filePlanId} | Get a file plan | +| [**getFilePlanCategories**](FilePlansApi.md#getFilePlanCategories) | **GET** /file-plans/{filePlanId}/categories | List file plans's children | +| [**updateFilePlan**](FilePlansApi.md#updateFilePlan) | **PUT** /file-plans/{filePlanId} | Update a file plan | +| [**getFilePlanRoles**](FilePlansApi.md#getFilePlanRoles) | **GET** /file-plans/{filePlanId}/roles | Gets a list of roles for the specified file plan. | # **createFilePlanCategories** @@ -402,3 +402,39 @@ parameter are returned in addition to those specified in the **fields** paramete [**FilePlanEntry**](FilePlanEntry.md) + +# **getFilePlanRoles** +> FilePlanEntry getFilePlanRoles(filePlanId, parameters) + +Gets a list of roles for the specified file plan. + +### Example +```javascript +import FilePlansApi from 'FilePlansApi'; +import { AlfrescoApi } from '@alfresco/js-api'; + +this.alfrescoApi = new AlfrescoApi(); +this.alfrescoApi.setConfig({ + hostEcm: 'http://127.0.0.1:8080' +}); + +let fileplansApi = new FilePlansApi(this.alfrescoApi); +const filePlanId = 'some id'; +fileplansApi.updateFilePlan(filePlanId, { + where: { + capabilityNames: ['ViewRecords'] + } +}).then((data) => console.log('API called successfully. Returned data: ' + data)) + .catch((error) => console.log(error)); +``` + +### Parameters + +| Name | Type | Description | +|----------------|---------------------------------------------------------|-----------------------------------------------------------------------| +| **filePlanId** | **string** | The identifier of a file plan. You can also use the -filePlan- alias. | +| **parameters** | [**FilePlanRoleParameters**](FilePlanRoleParameters.md) | Optional parameters. | + +### Return type + +[**FilePlanRolePaging**](FilePlanRolePaging.md) diff --git a/lib/js-api/src/api/gs-core-rest-api/model/filePlanRole.ts b/lib/js-api/src/api/gs-core-rest-api/model/filePlanRole.ts new file mode 100644 index 0000000000..ca6c2d5eb9 --- /dev/null +++ b/lib/js-api/src/api/gs-core-rest-api/model/filePlanRole.ts @@ -0,0 +1,33 @@ +/*! + * @license + * Copyright © 2005-2025 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 { FilePlanRoleCapability } from './filePlanRoleCapability'; + +export class FilePlanRole { + displayLabel: string; + groupShortName: string; + name: string; + roleGroupName: string; + capabilities: FilePlanRoleCapability[]; + + constructor(input?: Partial) { + if (input) { + Object.assign(this, input); + this.capabilities = input.capabilities?.map((capability) => new FilePlanRoleCapability(capability)); + } + } +} diff --git a/lib/js-api/src/api/gs-core-rest-api/model/filePlanRoleCapability.ts b/lib/js-api/src/api/gs-core-rest-api/model/filePlanRoleCapability.ts new file mode 100644 index 0000000000..57b21370dd --- /dev/null +++ b/lib/js-api/src/api/gs-core-rest-api/model/filePlanRoleCapability.ts @@ -0,0 +1,32 @@ +/*! + * @license + * Copyright © 2005-2025 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 { FilePlanRoleCapabilityGroup } from './filePlanRoleCapabilityGroup'; + +export class FilePlanRoleCapability { + group: FilePlanRoleCapabilityGroup; + index: number; + name: string; + title: string; + + constructor(input?: Partial) { + if (input) { + Object.assign(this, input); + this.group = input.group ? new FilePlanRoleCapabilityGroup(input.group) : undefined; + } + } +} diff --git a/lib/js-api/src/api/gs-core-rest-api/model/filePlanRoleCapabilityGroup.ts b/lib/js-api/src/api/gs-core-rest-api/model/filePlanRoleCapabilityGroup.ts new file mode 100644 index 0000000000..ace918541c --- /dev/null +++ b/lib/js-api/src/api/gs-core-rest-api/model/filePlanRoleCapabilityGroup.ts @@ -0,0 +1,27 @@ +/*! + * @license + * Copyright © 2005-2025 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 FilePlanRoleCapabilityGroup { + id: string; + title: string; + + constructor(input?: Partial) { + if (input) { + Object.assign(this, input); + } + } +} diff --git a/lib/js-api/src/api/gs-core-rest-api/model/filePlanRoleEntry.ts b/lib/js-api/src/api/gs-core-rest-api/model/filePlanRoleEntry.ts new file mode 100644 index 0000000000..af0e9ee0b8 --- /dev/null +++ b/lib/js-api/src/api/gs-core-rest-api/model/filePlanRoleEntry.ts @@ -0,0 +1,29 @@ +/*! + * @license + * Copyright © 2005-2025 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 { FilePlanRole } from './filePlanRole'; + +export class FilePlanRoleEntry { + entry: FilePlanRole; + + constructor(input?: Partial) { + if (input) { + Object.assign(this, input); + this.entry = input.entry ? new FilePlanRole(input.entry) : undefined; + } + } +} diff --git a/lib/js-api/src/api/gs-core-rest-api/model/filePlanRolePaging.ts b/lib/js-api/src/api/gs-core-rest-api/model/filePlanRolePaging.ts new file mode 100644 index 0000000000..aa1ea6f2f2 --- /dev/null +++ b/lib/js-api/src/api/gs-core-rest-api/model/filePlanRolePaging.ts @@ -0,0 +1,29 @@ +/*! + * @license + * Copyright © 2005-2025 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 { FilePlanRolePagingList } from './filePlanRolePagingList'; + +export class FilePlanRolePaging { + list: FilePlanRolePagingList; + + constructor(input: Partial) { + if (input) { + Object.assign(this, input); + this.list = input.list ? new FilePlanRolePagingList(input.list) : undefined; + } + } +} diff --git a/lib/js-api/src/api/gs-core-rest-api/model/filePlanRolePagingList.ts b/lib/js-api/src/api/gs-core-rest-api/model/filePlanRolePagingList.ts new file mode 100644 index 0000000000..dc75c4d03a --- /dev/null +++ b/lib/js-api/src/api/gs-core-rest-api/model/filePlanRolePagingList.ts @@ -0,0 +1,32 @@ +/*! + * @license + * Copyright © 2005-2025 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 { Pagination } from '../../content-rest-api'; +import { FilePlanRoleEntry } from './filePlanRoleEntry'; + +export class FilePlanRolePagingList { + entries: FilePlanRoleEntry[]; + pagination: Pagination; + + constructor(input: Partial) { + if (input) { + Object.assign(this, input); + this.pagination = input.pagination ? new Pagination(input.pagination) : undefined; + this.entries = input?.entries.map((entry) => new FilePlanRoleEntry(entry)); + } + } +} diff --git a/lib/js-api/src/api/gs-core-rest-api/model/filePlanRoleParameters.ts b/lib/js-api/src/api/gs-core-rest-api/model/filePlanRoleParameters.ts new file mode 100644 index 0000000000..5690658cec --- /dev/null +++ b/lib/js-api/src/api/gs-core-rest-api/model/filePlanRoleParameters.ts @@ -0,0 +1,22 @@ +/*! + * @license + * Copyright © 2005-2025 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 { FilePlanRoleParametersWhere } from './filePlanRoleParametersWhere'; + +export interface FilePlanRoleParameters { + where?: FilePlanRoleParametersWhere; +} diff --git a/lib/js-api/src/api/gs-core-rest-api/model/filePlanRoleParametersWhere.ts b/lib/js-api/src/api/gs-core-rest-api/model/filePlanRoleParametersWhere.ts new file mode 100644 index 0000000000..c0c81553c3 --- /dev/null +++ b/lib/js-api/src/api/gs-core-rest-api/model/filePlanRoleParametersWhere.ts @@ -0,0 +1,20 @@ +/*! + * @license + * Copyright © 2005-2025 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 interface FilePlanRoleParametersWhere { + capabilityNames?: string[]; +} diff --git a/lib/js-api/src/api/gs-core-rest-api/model/index.ts b/lib/js-api/src/api/gs-core-rest-api/model/index.ts index 8711ce5038..bd5d57e5a4 100644 --- a/lib/js-api/src/api/gs-core-rest-api/model/index.ts +++ b/lib/js-api/src/api/gs-core-rest-api/model/index.ts @@ -19,6 +19,14 @@ export * from './filePlan'; export * from './filePlanBodyUpdate'; export * from './filePlanComponentBodyUpdate'; export * from './filePlanEntry'; +export * from './filePlanRole'; +export * from './filePlanRoleCapability'; +export * from './filePlanRoleCapabilityGroup'; +export * from './filePlanRoleEntry'; +export * from './filePlanRolePaging'; +export * from './filePlanRolePagingList'; +export * from './filePlanRoleParameters'; +export * from './filePlanRoleParametersWhere'; export * from './rMNodeBodyCreate'; export * from './rMNodeBodyCreateWithRelativePath'; export * from './rMSite'; diff --git a/lib/js-api/test/governance-services/filePlansApi.spec.ts b/lib/js-api/test/governance-services/filePlansApi.spec.ts new file mode 100644 index 0000000000..c48788ea65 --- /dev/null +++ b/lib/js-api/test/governance-services/filePlansApi.spec.ts @@ -0,0 +1,129 @@ +/*! + * @license + * Copyright © 2005-2025 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 { EcmAuthMock, FilePlansMock } from '../mockObjects'; +import { AlfrescoApi, FilePlanRolePaging, FilePlansApi } from '../../src'; + +describe('FilePlansApi', () => { + let filePlansApiMock: FilePlansMock; + let filePlansApi: FilePlansApi; + + beforeEach(async () => { + const hostEcm = 'https://127.0.0.1:8080'; + const authResponseMock = new EcmAuthMock(hostEcm); + authResponseMock.get201Response(); + filePlansApiMock = new FilePlansMock(hostEcm); + const alfrescoApi = new AlfrescoApi({ + hostEcm + }); + filePlansApi = new FilePlansApi(alfrescoApi); + await alfrescoApi.login('admin', 'admin'); + }); + + describe('getFilePlanRoles', () => { + let expectedRolePaging: FilePlanRolePaging; + + beforeEach(() => { + expectedRolePaging = { + list: { + pagination: { + count: 2, + hasMoreItems: false, + totalItems: 2, + skipCount: 0, + maxItems: 100 + }, + entries: [ + { + entry: { + displayLabel: 'Role One', + groupShortName: 'group short name 1', + name: 'role1', + roleGroupName: 'role group name 1', + capabilities: [ + { + index: 0, + name: 'capability1', + title: 'Capability One', + group: { + id: 'group1', + title: 'Group One' + } + }, + { + index: 1, + name: 'capability2', + title: 'Capability Two', + group: { + id: 'group2', + title: 'Group Two' + } + } + ] + } + }, + { + entry: { + displayLabel: 'Role Two', + groupShortName: 'group short name 2', + name: 'role2', + roleGroupName: 'role group name 2', + capabilities: [ + { + index: 0, + name: 'capability3', + title: 'Capability Three', + group: { + id: 'group3', + title: 'Group Three' + } + } + ] + } + } + ] + } + }; + }); + + it('should get file plan roles', (done) => { + const filePlanId = 'filePlanId123'; + filePlansApiMock.get200FilePlanRoles(filePlanId); + + filePlansApi.getFilePlanRoles(filePlanId).then((rolePaging) => { + expect(rolePaging).toEqual(expectedRolePaging); + done(); + }); + }); + + it('should get file plan roles with filtering by capability names', (done) => { + const filePlanId = 'filePlanId123'; + filePlansApiMock.get200FilePlanRolesWithFilteringByCapabilityNames(filePlanId); + + filePlansApi + .getFilePlanRoles(filePlanId, { + where: { + capabilityNames: ['capability1', 'capability2'] + } + }) + .then((rolePaging) => { + expect(rolePaging).toEqual(expectedRolePaging); + done(); + }); + }); + }); +}); diff --git a/lib/js-api/test/mockObjects/goverance-services/file-plans.mock.ts b/lib/js-api/test/mockObjects/goverance-services/file-plans.mock.ts new file mode 100644 index 0000000000..bdaf094e07 --- /dev/null +++ b/lib/js-api/test/mockObjects/goverance-services/file-plans.mock.ts @@ -0,0 +1,101 @@ +/*! + * @license + * Copyright © 2005-2025 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 { BaseMock } from '../base.mock'; +import nock from 'nock'; +import { FilePlanRolePaging } from '@alfresco/js-api'; + +export class FilePlansMock extends BaseMock { + get200FilePlanRoles(filePlanId: string): void { + nock(this.host, { encodedQueryParams: true }) + .get(`/alfresco/api/-default-/public/gs/versions/1/file-plans/${filePlanId}/roles`) + .query({}) + .reply(200, this.mockFilePlanRolePaging()); + } + + get200FilePlanRolesWithFilteringByCapabilityNames(filePlanId: string): void { + nock(this.host, { encodedQueryParams: true }) + .get(`/alfresco/api/-default-/public/gs/versions/1/file-plans/${filePlanId}/roles`) + .query({ + where: "(capabilityName in ('capability1', 'capability2'))" + }) + .reply(200, this.mockFilePlanRolePaging()); + } + + private mockFilePlanRolePaging(): FilePlanRolePaging { + return { + list: { + pagination: { + count: 2, + hasMoreItems: false, + totalItems: 2, + skipCount: 0, + maxItems: 100 + }, + entries: [ + { + entry: { + displayLabel: 'Role One', + groupShortName: 'group short name 1', + name: 'role1', + roleGroupName: 'role group name 1', + capabilities: [ + { + index: 0, + name: 'capability1', + title: 'Capability One', + group: { + id: 'group1', + title: 'Group One' + } + }, + { + index: 1, + name: 'capability2', + title: 'Capability Two', + group: { + id: 'group2', + title: 'Group Two' + } + } + ] + } + }, + { + entry: { + displayLabel: 'Role Two', + groupShortName: 'group short name 2', + name: 'role2', + roleGroupName: 'role group name 2', + capabilities: [ + { + index: 0, + name: 'capability3', + title: 'Capability Three', + group: { + id: 'group3', + title: 'Group Three' + } + } + ] + } + } + ] + } + }; + } +} diff --git a/lib/js-api/test/mockObjects/index.ts b/lib/js-api/test/mockObjects/index.ts index 8464703adf..4aca06f614 100644 --- a/lib/js-api/test/mockObjects/index.ts +++ b/lib/js-api/test/mockObjects/index.ts @@ -34,6 +34,7 @@ export * from './content-services/version.mock'; export * from './content-services/webscript.mock'; export * from './goverance-services/authority-clearance.mock'; +export * from './goverance-services/file-plans.mock'; export * from './goverance-services/gs-sites.mock'; export * from './goverance-services/node-security-marks.mock'; export * from './goverance-services/security-groups.mock';