diff --git a/src/api/content-rest-api/api/categories.api.ts b/src/api/content-rest-api/api/categories.api.ts index 98c35c3f17..be9d462f99 100644 --- a/src/api/content-rest-api/api/categories.api.ts +++ b/src/api/content-rest-api/api/categories.api.ts @@ -58,6 +58,7 @@ export class CategoriesApi extends BaseApi { * @param opts.include Returns additional information about the category. The following optional fields can be requested: * count + * path * @return Promise */ @@ -112,6 +113,7 @@ export class CategoriesApi extends BaseApi { * @param opts.include Returns additional information about the category. The following optional fields can be requested: * count + * path * @return Promise */ @@ -162,6 +164,13 @@ export class CategoriesApi extends BaseApi { The list applies to a returned individual entity or entries within a collection. + If the API method also supports the **include** + parameter, then the fields specified in the **include** + parameter are returned in addition to those specified in the **fields** parameter. + + * @param opts.include Returns additional information about the category. The following optional fields can be requested: + * path + * @return Promise */ getCategoryLinksForNode(nodeId: string, opts?: any): Promise { @@ -176,7 +185,8 @@ export class CategoriesApi extends BaseApi { const queryParams = { 'skipCount': opts['skipCount'], 'maxItems': opts['maxItems'], - 'fields': buildCollectionParam(opts['fields'], 'csv') + 'fields': buildCollectionParam(opts['fields'], 'csv'), + 'include': buildCollectionParam(opts['include'], 'csv') }; const headerParams = {}; @@ -274,6 +284,10 @@ export class CategoriesApi extends BaseApi { parameter, then the fields specified in the **include** parameter are returned in addition to those specified in the **fields** parameter. + * @param opts.include Returns additional information about the category. The following optional fields can be requested: + * count + * path + * @return Promise */ updateCategory(categoryId: string, categoryBodyUpdate: CategoryBody, opts?: any): Promise { @@ -289,7 +303,8 @@ export class CategoriesApi extends BaseApi { }; const queryParams = { - 'fields': buildCollectionParam(opts['fields'], 'csv') + 'fields': buildCollectionParam(opts['fields'], 'csv'), + 'include': buildCollectionParam(opts['include'], 'csv') }; const headerParams = {}; @@ -372,6 +387,10 @@ export class CategoriesApi extends BaseApi { parameter, then the fields specified in the **include** parameter are returned in addition to those specified in the **fields** parameter. + * @param opts.include Returns additional information about the category. The following optional fields can be requested: + * count + * path + * @return Promise */ createSubcategories(categoryId: string, categoryBodyCreate: CategoryBody[], opts?: any): Promise { @@ -387,7 +406,8 @@ export class CategoriesApi extends BaseApi { }; const queryParams = { - 'fields': buildCollectionParam(opts['fields'], 'csv') + 'fields': buildCollectionParam(opts['fields'], 'csv'), + 'include': buildCollectionParam(opts['include'], 'csv') }; const headerParams = {}; @@ -468,9 +488,12 @@ export class CategoriesApi extends BaseApi { parameter, then the fields specified in the **include** parameter are returned in addition to those specified in the **fields** parameter. - * @return Promise + * @param opts.include Returns additional information about the category. The following optional fields can be requested: + * path + + * @return Promise */ - linkNodeToCategory(nodeId: string, categoryLinkBodyCreate: CategoryLinkBody[], opts?: any): Promise { + linkNodeToCategory(nodeId: string, categoryLinkBodyCreate: CategoryLinkBody[], opts?: any): Promise { throwIfNotDefined(nodeId, 'nodeId'); throwIfNotDefined(categoryLinkBodyCreate, 'categoryLinkBodyCreate'); @@ -483,7 +506,8 @@ export class CategoriesApi extends BaseApi { }; const queryParams = { - 'fields': buildCollectionParam(opts['fields'], 'csv') + 'fields': buildCollectionParam(opts['fields'], 'csv'), + 'include': buildCollectionParam(opts['include'], 'csv') }; const headerParams = {}; diff --git a/src/api/content-rest-api/docs/Category.md b/src/api/content-rest-api/docs/Category.md index e8f204af9e..da9a94e030 100644 --- a/src/api/content-rest-api/docs/Category.md +++ b/src/api/content-rest-api/docs/Category.md @@ -8,5 +8,6 @@ Name | Type | Description | Notes **parentId** | **string** | | [optional] [default to null] **hasChildren** | **boolean** | | [optional] [default to null] **count** | **number** | | [optional] [default to null] +**path** | **string** | | [optional] [default to null] diff --git a/src/api/content-rest-api/model/category.ts b/src/api/content-rest-api/model/category.ts index 6b8e491d0a..f3da622601 100644 --- a/src/api/content-rest-api/model/category.ts +++ b/src/api/content-rest-api/model/category.ts @@ -21,6 +21,7 @@ export class Category { parentId?: string; hasChildren?: boolean; count?: number; + path?: string; constructor(input?: any) { if (input) { diff --git a/test/content-services/categoriesApi.spec.ts b/test/content-services/categoriesApi.spec.ts index aece0f603e..b0cba9f74b 100644 --- a/test/content-services/categoriesApi.spec.ts +++ b/test/content-services/categoriesApi.spec.ts @@ -6,6 +6,7 @@ import { EcmAuthMock } from '../../test/mockObjects'; import { CategoriesMock } from '../mockObjects/content-services/categories.mock'; import { CategoryPaging } from '../../src/api/content-rest-api/model/categoryPaging'; import { CategoryEntry } from '../../src/api/content-rest-api/model/categoryEntry'; +import { fail } from 'assert'; describe('Categories', () => { let authResponseMock: EcmAuthMock; @@ -195,9 +196,26 @@ describe('Categories', () => { it('should return 201 while linking category if all is ok', (done) => { categoriesMock.get201ResponseCategoryLinked('testNode'); - categoriesApi.linkNodeToCategory('testNode', [{ categoryId: 'testId1' }]).then((response: CategoryEntry) => { - expect(response.entry.id).equal('testId1'); - expect(response.entry.name).equal('testName1'); + categoriesApi.linkNodeToCategory('testNode', [{ categoryId: 'testId1' }]).then((response) => { + if (response instanceof CategoryEntry) { + expect(response.entry.id).equal('testId1'); + expect(response.entry.name).equal('testName1'); + done(); + } else { + fail(); + } + }); + }); + + it('should return 201 while linking multiple categories if all is ok', (done) => { + categoriesMock.get201ResponseCategoryLinkedArray('testNodeArr'); + categoriesApi.linkNodeToCategory('testNodeArr', [{ categoryId: 'testId1' }, { categoryId: 'testId2' }]).then((response) => { + const categoriesPaging = response as CategoryPaging; + expect(categoriesPaging.list.pagination.count).equal(2); + expect(categoriesPaging.list.entries[0].entry.id).equal('testId1'); + expect(categoriesPaging.list.entries[0].entry.name).equal('testName1'); + expect(categoriesPaging.list.entries[1].entry.id).equal('testId2'); + expect(categoriesPaging.list.entries[1].entry.name).equal('testName2'); done(); }); }); diff --git a/test/mockObjects/content-services/categories.mock.ts b/test/mockObjects/content-services/categories.mock.ts index db5bbee175..5f5901ca38 100644 --- a/test/mockObjects/content-services/categories.mock.ts +++ b/test/mockObjects/content-services/categories.mock.ts @@ -249,6 +249,42 @@ export class CategoriesMock extends BaseMock { }); } + get201ResponseCategoryLinkedArray(nodeId: string): void { + nock(this.host, { encodedQueryParams: true }) + .post(`/alfresco/api/-default-/public/alfresco/versions/1/nodes/${nodeId}/category-links`, [{ categoryId: 'testId1' }, { categoryId: 'testId2' }]) + .reply(201, { + list: { + pagination: { + count: 2, + hasMoreItems: false, + totalItems: 2, + skipCount: 0, + maxItems: 100, + }, + entries: [ + { + entry: { + id: 'testId1', + name: 'testName1', + parentId: 'testNodeArr', + hasChildren: true, + count: 0 + } + }, + { + entry: { + id: 'testId2', + name: 'testName2', + parentId: 'testNodeArr', + hasChildren: true, + count: 0 + } + } + ] + } + }); + } + get403CategoryLinkPermissionDenied(nodeId: string): void { nock(this.host, { encodedQueryParams: true }).post(`/alfresco/api/-default-/public/alfresco/versions/1/nodes/${nodeId}/category-links`, [{ categoryId: 'testId1' }]) .reply(403, {