[PRODENG-211] integrate JS-API with monorepo (part 1) (#9081)

* integrate JS-API with monorepo

* [ci:force] fix token issue

[ci:force] migrate docs folder

[ci:force] clean personal tokens

* [ci:force] gha workflow support

* [ci:force] npm publish target

* fix js-api test linting

* [ci:force] fix test linting, mocks, https scheme

* [ci:force] fix https scheme

* [ci:force] typescript mappings

* [ci:force] update scripts

* lint fixes

* linting fixes

* fix linting

* [ci:force] linting fixes

* linting fixes

* [ci:force] remove js-api upstream and corresponding scripts

* [ci:force] jsdoc fixes

* fix jsdoc linting

* [ci:force] jsdoc fixes

* [ci:force] jsdoc fixes

* jsdoc fixes

* jsdoc fixes

* jsdoc fixes

* [ci:force] fix jsdoc

* [ci:force] reduce code duplication

* replace 'chai' expect with node.js assert

* replace 'chai' expect with node.js assert

* [ci:force] remove chai and chai-spies for js-api testing

* [ci:force] cleanup and fix imports

* [ci:force] fix linting

* [ci:force] fix unit test

* [ci:force] fix sonar linting findings

* [ci:force] switch activiti api models to interfaces (-2.5% reduction of bundle)

* [ci:force] switch activiti api models to interfaces

* [ci:force] switch AGS api models to interfaces

* [ci:force] switch AGS api models to interfaces

* [ci:force] switch search api models to interfaces

* [ci:force] switch content api models to interfaces where applicable
This commit is contained in:
Denys Vuika
2023-11-21 10:27:51 +00:00
committed by GitHub
parent 804fa2ffd4
commit ea2c0ce229
1334 changed files with 82605 additions and 1068 deletions

View File

@@ -0,0 +1,347 @@
/*!
* @license
* Copyright © 2005-2023 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 nock from 'nock';
import { BaseMock } from '../base.mock';
export class CategoriesMock extends BaseMock {
get200ResponseSubcategories(categoryId: string): void {
nock(this.host, { encodedQueryParams: true })
.get(`/alfresco/api/-default-/public/alfresco/versions/1/categories/${categoryId}/subcategories`)
.reply(200, {
list: {
pagination: {
count: 2,
hasMoreItems: false,
totalItems: 2,
skipCount: 0,
maxItems: 100
},
entries: [
{
entry: {
id: 'testId1',
name: 'testName1',
parentId: '-root-',
hasChildren: true,
count: 0
}
},
{
entry: {
id: 'testId2',
name: 'testName2',
parentId: '-root-',
hasChildren: true,
count: 0
}
}
]
}
});
}
get404SubcategoryNotExist(categoryId: string): void {
nock(this.host, { encodedQueryParams: true })
.get(`/alfresco/api/-default-/public/alfresco/versions/1/categories/${categoryId}/subcategories`)
.reply(404, {
error: {
errorKey: 'framework.exception.EntityNotFound',
statusCode: 404,
briefSummary: `05220073 The entity with id: ${categoryId} 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'
}
});
}
get200ResponseCategory(categoryId: string): void {
nock(this.host, { encodedQueryParams: true })
.get(`/alfresco/api/-default-/public/alfresco/versions/1/categories/${categoryId}`)
.reply(200, {
entry: {
id: 'testId1',
name: 'testName1',
parentId: '-root-',
hasChildren: true,
count: 0
}
});
}
get404CategoryNotExist(categoryId: string): void {
nock(this.host, { encodedQueryParams: true })
.get(`/alfresco/api/-default-/public/alfresco/versions/1/categories/${categoryId}`)
.reply(404, {
error: {
errorKey: 'framework.exception.EntityNotFound',
statusCode: 404,
briefSummary: `05220073 The entity with id: ${categoryId} 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'
}
});
}
get200ResponseNodeCategoryLinks(nodeId: string): void {
nock(this.host, { encodedQueryParams: true })
.get(`/alfresco/api/-default-/public/alfresco/versions/1/nodes/${nodeId}/category-links`)
.reply(200, {
list: {
pagination: {
count: 1,
hasMoreItems: false,
totalItems: 1,
skipCount: 0,
maxItems: 100
},
entries: [
{
entry: {
id: 'testId1',
name: 'testName1',
parentId: 'testNode',
hasChildren: true,
count: 0
}
}
]
}
});
}
get403NodeCategoryLinksPermissionDenied(nodeId: string): void {
nock(this.host, { encodedQueryParams: true })
.get(`/alfresco/api/-default-/public/alfresco/versions/1/nodes/${nodeId}/category-links`)
.reply(403, {
error: {
statusCode: 403
}
});
}
get404NodeNotExist(nodeId: string): void {
nock(this.host, { encodedQueryParams: true })
.get(`/alfresco/api/-default-/public/alfresco/versions/1/nodes/${nodeId}/category-links`)
.reply(404, {
error: {
errorKey: 'framework.exception.EntityNotFound',
statusCode: 404,
briefSummary: `05220073 The entity with id: ${nodeId} 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'
}
});
}
get204CategoryUnlinked(nodeId: string, categoryId: string): void {
nock(this.host, { encodedQueryParams: true })
.delete(`/alfresco/api/-default-/public/alfresco/versions/1/nodes/${nodeId}/category-links/${categoryId}`)
.reply(204);
}
get403CategoryUnlinkPermissionDenied(nodeId: string, categoryId: string): void {
nock(this.host, { encodedQueryParams: true })
.delete(`/alfresco/api/-default-/public/alfresco/versions/1/nodes/${nodeId}/category-links/${categoryId}`)
.reply(403, {
error: {
statusCode: 403
}
});
}
get404CategoryUnlinkNotFound(nodeId: string, categoryId: string): void {
nock(this.host, { encodedQueryParams: true })
.delete(`/alfresco/api/-default-/public/alfresco/versions/1/nodes/${nodeId}/category-links/${categoryId}`)
.reply(404, {
error: {
errorKey: 'framework.exception.EntityNotFound',
statusCode: 404,
briefSummary: `05230078 The entity with id: ${nodeId} or ${categoryId} 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'
}
});
}
get200ResponseCategoryUpdated(categoryId: string): void {
nock(this.host, { encodedQueryParams: true })
.put(`/alfresco/api/-default-/public/alfresco/versions/1/categories/${categoryId}`, { name: 'testName1' })
.reply(200, {
entry: {
id: 'testId1',
name: 'testName1',
parentId: '-root-',
hasChildren: true,
count: 0
}
});
}
get403CategoryUpdatePermissionDenied(categoryId: string): void {
nock(this.host, { encodedQueryParams: true })
.put(`/alfresco/api/-default-/public/alfresco/versions/1/categories/${categoryId}`, { name: 'testName1' })
.reply(403, {
error: {
statusCode: 403
}
});
}
get404CategoryUpdateNotFound(categoryId: string): void {
nock(this.host, { encodedQueryParams: true })
.put(`/alfresco/api/-default-/public/alfresco/versions/1/categories/${categoryId}`, { name: 'testName1' })
.reply(404, {
error: {
errorKey: 'framework.exception.EntityNotFound',
statusCode: 404,
briefSummary: `05230078 The entity with id: ${categoryId} 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'
}
});
}
get201ResponseCategoryCreated(categoryId: string): void {
nock(this.host, { encodedQueryParams: true })
.post(`/alfresco/api/-default-/public/alfresco/versions/1/categories/${categoryId}/subcategories`, [{ name: 'testName10' }])
.reply(201, {
entry: {
id: 'testId10',
name: 'testName10',
parentId: categoryId,
hasChildren: true,
count: 0
}
});
}
get403CategoryCreatedPermissionDenied(categoryId: string): void {
nock(this.host, { encodedQueryParams: true })
.post(`/alfresco/api/-default-/public/alfresco/versions/1/categories/${categoryId}/subcategories`, [{ name: 'testName10' }])
.reply(403, {
error: {
statusCode: 403
}
});
}
get409CategoryCreateAlreadyExists(categoryId: string): void {
nock(this.host, { encodedQueryParams: true })
.post(`/alfresco/api/-default-/public/alfresco/versions/1/categories/${categoryId}/subcategories`, [{ name: 'testName10' }])
.reply(409, {
error: {
errorKey: 'Duplicate child name not allowed: testName10',
statusCode: 409,
briefSummary: '06050055 Duplicate child name not allowed: testName10',
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'
}
});
}
get201ResponseCategoryLinked(nodeId: string): void {
nock(this.host, { encodedQueryParams: true })
.post(`/alfresco/api/-default-/public/alfresco/versions/1/nodes/${nodeId}/category-links`, [{ categoryId: 'testId1' }])
.reply(201, {
entry: {
id: 'testId1',
name: 'testName1',
parentId: nodeId,
hasChildren: true,
count: 0
}
});
}
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, {
error: {
statusCode: 403
}
});
}
get404CategoryLinkNotFound(nodeId: string): void {
nock(this.host, { encodedQueryParams: true })
.post(`/alfresco/api/-default-/public/alfresco/versions/1/nodes/${nodeId}/category-links`, [{ categoryId: 'testId1' }])
.reply(404, {
error: {
errorKey: 'framework.exception.EntityNotFound',
statusCode: 404,
briefSummary: `05230078 The entity with id: ${nodeId} or testId1 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'
}
});
}
get405CategoryLinkCannotAssign(nodeId: string): void {
nock(this.host, { encodedQueryParams: true })
.post(`/alfresco/api/-default-/public/alfresco/versions/1/nodes/${nodeId}/category-links`, [{ categoryId: 'testId1' }])
.reply(405, {
error: {
errorKey: 'Cannot assign node of this type to a category',
statusCode: 405,
briefSummary: `05230078 Cannot assign a node of this type to a category`,
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'
}
});
}
}

View File

@@ -0,0 +1,105 @@
/*!
* @license
* Copyright © 2005-2023 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.
*/
'use strict';
import nock from 'nock';
import { BaseMock } from '../base.mock';
const adminUser = {
aspectNames: ['cm:ownable'],
firstName: 'Administrator',
emailNotificationsEnabled: true,
company: {},
id: 'admin',
enabled: true,
email: 'admin@alfresco.com',
properties: {
'cm:homeFolderProvider': 'bootstrapHomeFolderProvider',
'cm:authorizationStatus': 'AUTHORIZED',
'cm:homeFolder': '72866d2e-64ee-45a2-ae00-30a5ced96a41',
'cm:name': '56f78250-37a7-4e22-b35a-64b53ae1e5ca',
'cm:owner': { id: 'admin', displayName: 'Administrator' },
'cm:organizationId': ''
}
};
export class CommentMock extends BaseMock {
post201Response(): void {
nock(this.host, { encodedQueryParams: true })
.post('/alfresco/api/-default-/public/alfresco/versions/1/nodes/74cd8a96-8a21-47e5-9b3b-a1b3e296787d/comments', {
content: 'This is a comment'
})
.reply(201, {
entry: {
createdAt: '2017-04-11T09:31:21.452+0000',
createdBy: adminUser,
edited: false,
modifiedAt: '2017-04-11T09:31:21.452+0000',
canEdit: true,
modifiedBy: adminUser,
canDelete: true,
id: 'c294cf79-49c1-483e-ac86-39c8fe3cce8f',
content: 'This is a comment'
}
});
}
get200Response(): void {
nock(this.host, { encodedQueryParams: true })
.get('/alfresco/api/-default-/public/alfresco/versions/1/nodes/74cd8a96-8a21-47e5-9b3b-a1b3e296787d/comments')
.reply(200, {
list: {
pagination: {
count: 2,
hasMoreItems: false,
totalItems: 2,
skipCount: 0,
maxItems: 100
},
entries: [
{
entry: {
createdAt: '2017-04-11T09:31:21.658+0000',
createdBy: adminUser,
edited: false,
modifiedAt: '2017-04-11T09:31:21.658+0000',
canEdit: true,
modifiedBy: adminUser,
canDelete: true,
id: '539fc9b2-7d5b-4966-9e44-fcf433647f25',
content: 'This is another comment'
}
},
{
entry: {
createdAt: '2017-04-11T09:31:21.452+0000',
createdBy: adminUser,
edited: false,
modifiedAt: '2017-04-11T09:31:21.452+0000',
canEdit: true,
modifiedBy: adminUser,
canDelete: true,
id: 'c294cf79-49c1-483e-ac86-39c8fe3cce8f',
content: 'This is a comment'
}
}
]
}
});
}
}

View File

@@ -0,0 +1,69 @@
/*!
* @license
* Copyright © 2005-2023 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 nock from 'nock';
import { BaseMock } from '../base.mock';
export class CustomModelMock extends BaseMock {
get200AllCustomModel(): void {
nock(this.host, { encodedQueryParams: true })
.get('/alfresco/api/-default-/private/alfresco/versions/1/cmm')
.reply(200, {
list: {
pagination: {
count: 0,
hasMoreItems: false,
totalItems: 0,
skipCount: 0,
maxItems: 100
},
entries: []
}
});
}
create201CustomModel(): void {
nock(this.host, { encodedQueryParams: true })
.post('/alfresco/api/-default-/private/alfresco/versions/1/cmm')
.reply(201, {
entry: {
author: 'Administrator',
name: 'testModel',
description: 'Test model description',
namespaceUri: 'https://www.alfresco.org/model/testNamespace/1.0',
namespacePrefix: 'test',
status: 'DRAFT'
}
});
}
activateCustomModel200(): void {
nock(this.host, { encodedQueryParams: true })
.put('/alfresco/api/-default-/private/alfresco/versions/1/cmm/testModel', { status: 'ACTIVE' })
.query({ select: 'status' })
.reply(200, {
entry: {
author: 'Administrator',
name: 'testModel',
description: 'Test model description',
namespaceUri: 'https://www.alfresco.org/model/testNamespace/1.0',
namespacePrefix: 'test',
status: 'ACTIVE'
}
});
}
}

View File

@@ -0,0 +1,86 @@
/*!
* @license
* Copyright © 2005-2023 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 nock from 'nock';
import { BaseMock } from '../base.mock';
export class DiscoveryMock extends BaseMock {
get200Response(): void {
nock(this.host, { encodedQueryParams: true })
.get('/alfresco/api/discovery')
.reply(200, {
entry: {
repository: {
edition: 'Enterprise',
version: {
major: '5',
minor: '2',
patch: '1',
hotfix: '0',
schema: 10052,
label: 'r133188-b433',
display: '5.2.1.0 (r133188-b433) schema 10052'
},
license: {
issuedAt: '2017-04-10T10:45:00.177+0000',
expiresAt: '2017-05-10T00:00:00.000+0000',
remainingDays: 16,
holder: 'Trial User',
mode: 'ENTERPRISE',
entitlements: { isClusterEnabled: false, isCryptodocEnabled: false }
},
status: {
isReadOnly: false,
isAuditEnabled: true,
isQuickShareEnabled: true,
isThumbnailGenerationEnabled: true
},
modules: [
{
id: 'alfresco-share-services',
title: 'Alfresco Share Services AMP',
description: 'Module to be applied to alfresco.war, containing APIs for Alfresco Share',
version: '5.2.0',
installDate: '2016-11-28T18:59:22.555+0000',
installState: 'INSTALLED',
versionMin: '5.1',
versionMax: '999'
},
{
id: 'alfresco-trashcan-cleaner',
title: 'alfresco-trashcan-cleaner project',
description: 'The Alfresco Trash Can Cleaner (Alfresco Module)',
version: '2.2',
installState: 'UNKNOWN',
versionMin: '0',
versionMax: '999'
},
{
id: 'enablecors',
title: 'Enable Cors support',
description: 'Adds a web-fragment with the filter config for Cors support',
version: '1.0-SNAPSHOT',
installState: 'UNKNOWN',
versionMin: '0',
versionMax: '999'
}
]
}
}
});
}
}

View File

@@ -0,0 +1,108 @@
/*!
* @license
* Copyright © 2005-2023 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 nock from 'nock';
import { BaseMock } from '../base.mock';
export class EcmAuthMock extends BaseMock {
username: string;
password: string;
constructor(host?: string, username?: string, password?: string) {
super(host);
this.username = username || 'admin';
this.password = password || 'admin';
}
get201Response(forceTicket?: string): void {
const returnMockTicket = forceTicket || 'TICKET_4479f4d3bb155195879bfbb8d5206f433488a1b1';
nock(this.host, { encodedQueryParams: true })
.post('/alfresco/api/-default-/public/authentication/versions/1/tickets', {
userId: this.username,
password: this.password
})
.reply(201, { entry: { id: returnMockTicket, userId: 'admin' } });
}
get200ValidTicket(forceTicket?: string): void {
const returnMockTicket = forceTicket || 'TICKET_4479f4d3bb155195879bfbb8d5206f433488a1b1';
nock(this.host, { encodedQueryParams: true })
.get('/alfresco/api/-default-/public/authentication/versions/1/tickets/-me-')
.reply(200, { entry: { id: returnMockTicket } });
}
get403Response(): void {
nock(this.host, { encodedQueryParams: true })
.post('/alfresco/api/-default-/public/authentication/versions/1/tickets', {
userId: 'wrong',
password: 'name'
})
.reply(403, {
error: {
errorKey: 'Login failed',
statusCode: 403,
briefSummary: '05150009 Login failed',
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'
}
});
}
get400Response(): void {
nock(this.host, { encodedQueryParams: true })
.post('/alfresco/api/-default-/public/authentication/versions/1/tickets', {
userId: null,
password: null
})
.reply(400, {
error: {
errorKey: 'Invalid login details.',
statusCode: 400,
briefSummary: '05160045 Invalid login details.',
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'
}
});
}
get401Response(): void {
nock(this.host, { encodedQueryParams: true })
.post('/alfresco/api/-default-/public/authentication/versions/1/tickets', {
userId: 'wrong',
password: 'name'
})
.reply(401, {
error: {
errorKey: 'framework.exception.ApiDefault',
statusCode: 401,
briefSummary: '05210059 Authentication failed for Web Script org/alfresco/api/ResourceWebScript.get',
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'
}
});
}
get204ResponseLogout(): void {
nock(this.host, { encodedQueryParams: true }).delete('/alfresco/api/-default-/public/authentication/versions/1/tickets/-me-').reply(204, '');
}
get404ResponseLogout(): void {
nock(this.host, { encodedQueryParams: true }).delete('/alfresco/api/-default-/public/authentication/versions/1/tickets/-me-').reply(404, '');
}
}

View File

@@ -0,0 +1,93 @@
/*!
* @license
* Copyright © 2005-2023 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 nock from 'nock';
import { BaseMock } from '../base.mock';
export class FindNodesMock extends BaseMock {
get200Response(): void {
nock(this.host, { encodedQueryParams: true })
.get('/alfresco/api/-default-/public/alfresco/versions/1/queries/nodes?term=test')
.reply(200, {
list: {
pagination: {
count: 2,
hasMoreItems: false,
totalItems: 2,
skipCount: 0,
maxItems: 100
},
entries: [
{
entry: {
createdAt: '2011-03-03T10:34:52.092+0000',
isFolder: false,
isFile: true,
createdByUser: { id: 'abeecher', displayName: 'Alice Beecher' },
modifiedAt: '2011-03-03T10:34:52.092+0000',
modifiedByUser: { id: 'abeecher', displayName: 'Alice Beecher' },
name: 'coins1.JPG',
id: '7bb9c846-fcc5-43b5-a893-39e46ebe94d4',
nodeType: 'cm:content',
content: {
mimeType: 'image/jpeg',
mimeTypeName: 'JPEG Image',
sizeInBytes: 501641,
encoding: 'UTF-8'
},
parentId: '880a0f47-31b1-4101-b20b-4d325e54e8b1'
}
},
{
entry: {
createdAt: '2011-03-03T10:34:52.092+0000',
isFolder: false,
isFile: true,
createdByUser: { id: 'abeecher', displayName: 'Alice Beecher' },
modifiedAt: '2011-03-03T10:34:52.092+0000',
modifiedByUser: { id: 'abeecher', displayName: 'Alice Beecher' },
name: 'coins2.JPG',
id: '7bb9c846-fcc5-43b5-a893-39e46ebe94d4',
nodeType: 'cm:content',
content: {
mimeType: 'image/jpeg',
mimeTypeName: 'JPEG Image',
sizeInBytes: 501641,
encoding: 'UTF-8'
},
parentId: '880a0f47-31b1-4101-b20b-4d325e54e8b1'
}
}
]
}
});
}
get401Response(): void {
nock(this.host, { encodedQueryParams: true })
.get('/alfresco/api/-default-/public/alfresco/versions/1/queries/nodes?term=test')
.reply(401, {
error: {
errorKey: 'framework.exception.ApiDefault',
statusCode: 401,
briefSummary: '05210059 Authentication failed for Web Script org/alfresco/api/ResourceWebScript.get',
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'
}
});
}
}

View File

@@ -0,0 +1,139 @@
/*!
* @license
* Copyright © 2005-2023 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 nock from 'nock';
import { BaseMock } from '../base.mock';
export class GroupsMock extends BaseMock {
get200GetGroups(): void {
nock(this.host, { encodedQueryParams: true })
.get('/alfresco/api/-default-/public/alfresco/versions/1/groups')
.reply(200, {
list: {
pagination: {
count: 2,
hasMoreItems: true,
totalItems: 279,
skipCount: 0,
maxItems: 2
},
entries: [
{
entry: {
isRoot: true,
displayName: 'alfalfb',
id: 'GROUP_alfalfa'
}
},
{
entry: {
isRoot: true,
displayName: 'Call CenterAA',
id: 'GROUP_CallCenterAA'
}
}
]
}
});
}
getDeleteGroupSuccessfulResponse(groupName: string): void {
nock(this.host, { encodedQueryParams: true })
.delete('/alfresco/api/-default-/public/alfresco/versions/1/groups/' + groupName)
.query({ cascade: 'false' })
.reply(200);
}
getDeleteMemberForGroupSuccessfulResponse(groupName: string, memberName: string): void {
nock(this.host, { encodedQueryParams: true })
.delete('/alfresco/api/-default-/public/alfresco/versions/1/groups/' + groupName + '/members/' + memberName)
.reply(200);
}
get200CreateGroupResponse(): void {
nock(this.host, { encodedQueryParams: true })
.post('/alfresco/api/-default-/public/alfresco/versions/1/groups')
.reply(200, {
entry: {
isRoot: true,
displayName: 'SAMPLE',
id: 'GROUP_TEST'
}
});
}
get200GetSingleGroup(): void {
nock(this.host, { encodedQueryParams: true })
.get('/alfresco/api/-default-/public/alfresco/versions/1/groups/GROUP_TEST')
.reply(200, {
entry: {
isRoot: true,
displayName: 'SAMPLE',
id: 'GROUP_TEST'
}
});
}
get200UpdateGroupResponse(): void {
nock(this.host, { encodedQueryParams: true })
.put('/alfresco/api/-default-/public/alfresco/versions/1/groups/GROUP_TEST')
.reply(200, {
entry: {
isRoot: true,
displayName: 'CHANGED',
id: 'GROUP_TEST'
}
});
}
get200GetGroupMemberships(): void {
nock(this.host, { encodedQueryParams: true })
.get('/alfresco/api/-default-/public/alfresco/versions/1/groups/GROUP_TEST/members')
.reply(200, {
list: {
pagination: {
count: 1,
hasMoreItems: false,
totalItems: 1,
skipCount: 0,
maxItems: 100
},
entries: [
{
entry: {
displayName: 'SAMPLE',
id: 'GROUP_SUB_TEST',
memberType: 'GROUP'
}
}
]
}
});
}
get200AddGroupMembershipResponse(): void {
nock(this.host, { encodedQueryParams: true })
.post('/alfresco/api/-default-/public/alfresco/versions/1/groups/GROUP_TEST/members')
.reply(200, {
entry: {
displayName: 'SAMPLE',
id: 'GROUP_SUB_TEST',
memberType: 'GROUP'
}
});
}
}

View File

@@ -0,0 +1,233 @@
/*!
* @license
* Copyright © 2005-2023 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 nock from 'nock';
import { BaseMock } from '../base.mock';
export class NodeMock extends BaseMock {
get200ResponseChildren(): void {
nock(this.host, { encodedQueryParams: true })
.get('/alfresco/api/-default-/public/alfresco/versions/1/nodes/b4cff62a-664d-4d45-9302-98723eac1319/children')
.reply(200, {
list: {
pagination: {
count: 5,
hasMoreItems: false,
totalItems: 5,
skipCount: 0,
maxItems: 100
},
entries: [
{
entry: {
createdAt: '2011-02-15T20:19:00.007+0000',
isFolder: true,
isFile: false,
createdByUser: { id: 'mjackson', displayName: 'Mike Jackson' },
modifiedAt: '2011-02-15T20:19:00.007+0000',
modifiedByUser: { id: 'mjackson', displayName: 'Mike Jackson' },
name: 'dataLists',
id: '64f69e69-f61e-42a3-8697-95eea1f2bda2',
nodeType: 'cm:folder',
parentId: 'b4cff62a-664d-4d45-9302-98723eac1319'
}
},
{
entry: {
createdAt: '2011-02-15T22:04:54.290+0000',
isFolder: true,
isFile: false,
createdByUser: { id: 'mjackson', displayName: 'Mike Jackson' },
modifiedAt: '2011-02-15T22:04:54.290+0000',
modifiedByUser: { id: 'mjackson', displayName: 'Mike Jackson' },
name: 'discussions',
id: '059c5bc7-2d38-4dc5-96b8-d09cd3c69b4c',
nodeType: 'cm:folder',
parentId: 'b4cff62a-664d-4d45-9302-98723eac1319'
}
},
{
entry: {
createdAt: '2011-02-15T20:16:28.292+0000',
isFolder: true,
isFile: false,
createdByUser: { id: 'mjackson', displayName: 'Mike Jackson' },
modifiedAt: '2016-06-27T14:31:10.007+0000',
modifiedByUser: { id: 'admin', displayName: 'Administrator' },
name: 'documentLibrary',
id: '8f2105b4-daaf-4874-9e8a-2152569d109b',
nodeType: 'cm:folder',
parentId: 'b4cff62a-664d-4d45-9302-98723eac1319'
}
},
{
entry: {
createdAt: '2011-02-15T20:18:59.808+0000',
isFolder: true,
isFile: false,
createdByUser: { id: 'mjackson', displayName: 'Mike Jackson' },
modifiedAt: '2011-02-15T20:18:59.808+0000',
modifiedByUser: { id: 'mjackson', displayName: 'Mike Jackson' },
name: 'links',
id: '0e24b99c-41f0-43e1-a55e-fb9f50d73820',
nodeType: 'cm:folder',
parentId: 'b4cff62a-664d-4d45-9302-98723eac1319'
}
},
{
entry: {
createdAt: '2011-02-15T21:46:01.603+0000',
isFolder: true,
isFile: false,
createdByUser: { id: 'mjackson', displayName: 'Mike Jackson' },
modifiedAt: '2011-02-15T21:46:01.603+0000',
modifiedByUser: { id: 'mjackson', displayName: 'Mike Jackson' },
name: 'wiki',
id: 'cdefb3a9-8f55-4771-a9e3-06fa370250f6',
nodeType: 'cm:folder',
parentId: 'b4cff62a-664d-4d45-9302-98723eac1319'
}
}
]
}
});
}
get200ResponseChildrenNonUTCTimes(): void {
nock(this.host, { encodedQueryParams: true })
.get('/alfresco/api/-default-/public/alfresco/versions/1/nodes/b4cff62a-664d-4d45-9302-98723eac1320/children')
.reply(200, {
list: {
pagination: {
count: 5,
hasMoreItems: false,
totalItems: 5,
skipCount: 0,
maxItems: 100
},
entries: [
{
entry: {
createdAt: '2011-03-15T12:04:54.290-0500',
isFolder: true,
isFile: false,
createdByUser: { id: 'mjackson', displayName: 'Mike Jackson' },
modifiedAt: '2011-03-15T12:04:54.290-0500',
modifiedByUser: { id: 'mjackson', displayName: 'Mike Jackson' },
name: 'discussions',
id: '059c5bc7-2d38-4dc5-96b8-d09cd3c69b4c',
nodeType: 'cm:folder',
parentId: 'b4cff62a-664d-4d45-9302-98723eac1320'
}
}
]
}
});
}
get404ChildrenNotExist(): void {
nock(this.host, { encodedQueryParams: true })
.get('/alfresco/api/-default-/public/alfresco/versions/1/nodes/b4cff62a-664d-4d45-9302-98723eac1319/children')
.reply(404, {
error: {
errorKey: 'framework.exception.EntityNotFound',
statusCode: 404,
briefSummary: '05220073 The entity with id: 80a94ac4-3ec4-47ad-864e-5d939424c47c 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'
}
});
}
get401CreationFolder(): void {
nock(this.host, { encodedQueryParams: true }).post('/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children').reply(401);
}
get204SuccessfullyDeleted(): void {
nock(this.host, { encodedQueryParams: true })
.delete('/alfresco/api/-default-/public/alfresco/versions/1/nodes/80a94ac8-3ece-47ad-864e-5d939424c47c')
.reply(204);
}
get403DeletePermissionDenied(): void {
nock(this.host, { encodedQueryParams: true })
.delete('/alfresco/api/-default-/public/alfresco/versions/1/nodes/80a94ac8-3ece-47ad-864e-5d939424c47c')
.reply(403);
}
get404DeleteNotFound(): void {
nock(this.host, { encodedQueryParams: true })
.delete('/alfresco/api/-default-/public/alfresco/versions/1/nodes/80a94ac8-test-47ad-864e-5d939424c47c')
.reply(404, {
error: {
errorKey: 'framework.exception.EntityNotFound',
statusCode: 404,
briefSummary: '05230078 The entity with id: 80a94ac8-test-47ad-864e-5d939424c47c 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'
}
});
}
get200ResponseChildrenFutureNewPossibleValue(): void {
nock(this.host, { encodedQueryParams: true })
.get('/alfresco/api/-default-/public/alfresco/versions/1/nodes/b4cff62a-664d-4d45-9302-98723eac1319/children')
.reply(200, {
list: {
pagination: {
count: 2,
hasMoreItems: false,
totalItems: 2,
skipCount: 0,
maxItems: 100
},
entries: [
{
entry: {
createdAt: '2011-02-15T20:19:00.007+0000',
isFolder: true,
isFile: false,
createdByUser: { id: 'mjackson', displayName: 'Mike Jackson' },
modifiedAt: '2011-02-15T20:19:00.007+0000',
modifiedByUser: { id: 'mjackson', displayName: 'Mike Jackson' },
name: 'dataLists',
id: '64f69e69-f61e-42a3-8697-95eea1f2bda2',
nodeType: 'cm:folder',
parentId: 'b4cff62a-664d-4d45-9302-98723eac1319',
impossibleProperties: 'impossibleRightValue'
}
},
{
entry: {
createdAt: '2011-02-15T22:04:54.290+0000',
isFolder: true,
isFile: false,
createdByUser: { id: 'mjackson', displayName: 'Mike Jackson' },
modifiedAt: '2011-02-15T22:04:54.290+0000',
modifiedByUser: { id: 'mjackson', displayName: 'Mike Jackson' },
name: 'discussions',
id: '059c5bc7-2d38-4dc5-96b8-d09cd3c69b4c',
nodeType: 'cm:folder',
parentId: 'b4cff62a-664d-4d45-9302-98723eac1319',
impossibleProperties: 'impossibleRightValue'
}
}
]
}
});
}
}

View File

@@ -0,0 +1,115 @@
/*!
* @license
* Copyright © 2005-2023 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 nock from 'nock';
import { BaseMock } from '../base.mock';
export class PeopleMock extends BaseMock {
get201Response(): void {
nock(this.host, { encodedQueryParams: true })
.post('/alfresco/api/-default-/public/alfresco/versions/1/people')
.reply(201, {
entry: {
firstName: 'chewbacca',
lastName: 'Chewbe',
emailNotificationsEnabled: true,
company: {},
id: 'chewbe',
enabled: true,
email: 'chewbe@millenniumfalcon.com'
}
});
}
get200ResponsePersons(): void {
nock(this.host, { encodedQueryParams: true })
.get('/alfresco/api/-default-/public/alfresco/versions/1/people')
.reply(200, {
list: {
pagination: {
count: 5,
hasMoreItems: true,
totalItems: 153,
skipCount: 0,
maxItems: 5
},
entries: [
{
entry: {
firstName: 'anSNSlXA',
lastName: '3PhtPlBO',
jobTitle: 'N/A',
emailNotificationsEnabled: true,
company: {},
id: '0jl2FBTc',
enabled: true,
email: 'owAwLISy'
}
},
{
entry: {
firstName: '84N1jji3',
lastName: '748zEwJV',
jobTitle: 'N/A',
emailNotificationsEnabled: true,
company: {},
id: '0kd3jA3b',
enabled: true,
email: 'm1ooPRIu'
}
},
{
entry: {
firstName: 'cPuvOYnb',
lastName: 'GZK6IenG',
jobTitle: 'N/A',
emailNotificationsEnabled: true,
company: {},
id: '1BJSWj5u',
enabled: true,
email: 'UtKzKjje'
}
},
{
entry: {
firstName: '87vRSHzf',
lastName: 'OiLjkq9z',
jobTitle: 'N/A',
emailNotificationsEnabled: true,
company: {},
id: '1pvBqbmT',
enabled: true,
email: '72GemSCB'
}
},
{
entry: {
firstName: 'QTxD4AWn',
lastName: 'IHb5JiaR',
jobTitle: 'N/A',
emailNotificationsEnabled: true,
company: {},
id: '2fOamhbL',
enabled: true,
email: 'hhhQHpmZ'
}
}
]
}
});
}
}

View File

@@ -0,0 +1,99 @@
/*!
* @license
* Copyright © 2005-2023 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 nock from 'nock';
import { BaseMock } from '../base.mock';
export class RenditionMock extends BaseMock {
get200RenditionResponse(): void {
nock(this.host, { encodedQueryParams: true })
.get('/alfresco/api/-default-/public/alfresco/versions/1/nodes/97a29e9c-1e4f-4d9d-bb02-1ec920dda045/renditions/pdf')
.reply(200, {
entry: {
id: 'pdf',
content: { mimeType: 'application/pdf', mimeTypeName: 'Adobe PDF Document' },
status: 'NOT_CREATED'
}
});
}
createRendition200(): void {
nock(this.host, { encodedQueryParams: true })
.post('/alfresco/api/-default-/public/alfresco/versions/1/nodes/97a29e9c-1e4f-4d9d-bb02-1ec920dda045/renditions', { id: 'pdf' })
.reply(202, '');
}
get200RenditionList(): void {
nock(this.host, { encodedQueryParams: true })
.get('/alfresco/api/-default-/public/alfresco/versions/1/nodes/97a29e9c-1e4f-4d9d-bb02-1ec920dda045/renditions')
.reply(200, {
list: {
pagination: {
count: 6,
hasMoreItems: false,
totalItems: 6,
skipCount: 0,
maxItems: 100
},
entries: [
{
entry: {
id: 'avatar',
content: { mimeType: 'image/png', mimeTypeName: 'PNG Image' },
status: 'NOT_CREATED'
}
},
{
entry: {
id: 'avatar32',
content: { mimeType: 'image/png', mimeTypeName: 'PNG Image' },
status: 'NOT_CREATED'
}
},
{
entry: {
id: 'doclib',
content: { mimeType: 'image/png', mimeTypeName: 'PNG Image' },
status: 'NOT_CREATED'
}
},
{
entry: {
id: 'imgpreview',
content: { mimeType: 'image/jpeg', mimeTypeName: 'JPEG Image' },
status: 'NOT_CREATED'
}
},
{
entry: {
id: 'medium',
content: { mimeType: 'image/jpeg', mimeTypeName: 'JPEG Image' },
status: 'NOT_CREATED'
}
},
{
entry: {
id: 'pdf',
content: { mimeType: 'application/pdf', mimeTypeName: 'Adobe PDF Document' },
status: 'NOT_CREATED'
}
}
]
}
});
}
}

View File

@@ -0,0 +1,53 @@
/*!
* @license
* Copyright © 2005-2023 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 nock from 'nock';
import { BaseMock } from '../base.mock';
export class SearchMock extends BaseMock {
get200Response(): void {
nock(this.host, { encodedQueryParams: true })
.post('/alfresco/api/-default-/public/search/versions/1/search', {
query: {
query: 'select * from cmis:folder',
language: 'cmis'
}
})
.reply(200, {
list: {
pagination: { count: 100, hasMoreItems: true, skipCount: 0, maxItems: 100 },
entries: [
{
entry: {
createdAt: '2017-04-10T10:52:30.868+0000',
isFolder: true,
search: { score: 1 },
isFile: false,
createdByUser: { id: 'admin', displayName: 'Administrator' },
modifiedAt: '2017-04-10T10:52:30.868+0000',
modifiedByUser: { id: 'admin', displayName: 'Administrator' },
name: 'user',
id: '224e30f4-a7b3-4192-b6e6-dc27d95e26ef',
nodeType: 'cm:folder',
parentId: '83551834-75d6-4e07-a318-46d5d176738a'
}
}
]
}
});
}
}

View File

@@ -0,0 +1,99 @@
/*!
* @license
* Copyright © 2005-2023 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 nock from 'nock';
import { BaseMock } from '../base.mock';
import { TagBody, TagEntry, TagPaging } from '../../../src/api/content-rest-api';
export class TagMock extends BaseMock {
get200Response(): void {
nock(this.host, { encodedQueryParams: true })
.get('/alfresco/api/-default-/public/alfresco/versions/1/tags')
.reply(200, this.getPaginatedListOfTags());
}
getTagsByNameFilteredByMatching200Response(): void {
nock(this.host, { encodedQueryParams: true })
.get('/alfresco/api/-default-/public/alfresco/versions/1/tags?where=(tag%20matches%20(%27*tag-test*%27))')
.reply(200, this.getPaginatedListOfTags());
}
getTagsByNamesFilterByExactTag200Response(): void {
nock(this.host, { encodedQueryParams: true })
.get('/alfresco/api/-default-/public/alfresco/versions/1/tags?where=(tag%3D%27tag-test-1%27)')
.reply(200, {
list: {
pagination: {
count: 1,
hasMoreItems: false,
skipCount: 0,
maxItems: 100
},
entries: [this.mockTagEntry()]
}
});
}
get401Response(): void {
nock(this.host, { encodedQueryParams: true })
.get('/alfresco/api/-default-/public/alfresco/versions/1/tags')
.reply(401, {
error: {
errorKey: 'framework.exception.ApiDefault',
statusCode: 401,
briefSummary: '05210059 Authentication failed for Web Script org/alfresco/api/ResourceWebScript.get',
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'
}
});
}
createTags201Response(): void {
nock(this.host, { encodedQueryParams: true })
.post('/alfresco/api/-default-/public/alfresco/versions/1/tags')
.reply(201, [this.mockTagEntry(), this.mockTagEntry('tag-test-2', 'd79bdbd0-9f55-45bb-9521-811e15bf48f6')]);
}
get201ResponseForAssigningTagsToNode(body: TagBody[]): void {
nock(this.host, { encodedQueryParams: true })
.post('/alfresco/api/-default-/public/alfresco/versions/1/nodes/someNodeId/tags', JSON.stringify(body))
.reply(201, body.length > 1 ? this.getPaginatedListOfTags() : this.mockTagEntry());
}
private getPaginatedListOfTags(): TagPaging {
return {
list: {
pagination: {
count: 2,
hasMoreItems: false,
skipCount: 0,
maxItems: 100
},
entries: [this.mockTagEntry(), this.mockTagEntry('tag-test-2', 'd79bdbd0-9f55-45bb-9521-811e15bf48f6')]
}
};
}
private mockTagEntry(tag = 'tag-test-1', id = '0d89aa82-f2b8-4a37-9a54-f4c5148174d6'): TagEntry {
return {
entry: {
tag,
id
}
};
}
}

View File

@@ -0,0 +1,104 @@
/*!
* @license
* Copyright © 2005-2023 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 nock from 'nock';
import { BaseMock } from '../base.mock';
export class UploadMock extends BaseMock {
get201CreationFile(): void {
nock(this.host, { encodedQueryParams: true })
.post('/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children')
.reply(201, {
entry: {
isFile: true,
createdByUser: { id: 'admin', displayName: 'Administrator' },
modifiedAt: '2016-07-08T16:08:10.218+0000',
nodeType: 'cm:content',
content: {
mimeType: 'text/plain',
mimeTypeName: 'Plain Text',
sizeInBytes: 28,
encoding: 'ISO-8859-2'
},
parentId: '55290409-3c61-41e5-80f6-8354ed133ce0',
aspectNames: ['cm:versionable', 'cm:titled', 'cm:auditable', 'cm:author'],
createdAt: '2016-07-08T16:08:10.218+0000',
isFolder: false,
modifiedByUser: { id: 'admin', displayName: 'Administrator' },
name: 'testFile.txt',
id: '2857abfd-0ac6-459d-a22d-ec78770570f3',
properties: { 'cm:versionLabel': '1.0', 'cm:versionType': 'MAJOR' }
}
});
}
get201CreationFileAutoRename(): void {
nock(this.host, { encodedQueryParams: true })
.post('/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children')
.query({ autoRename: 'true' })
.reply(201, {
entry: {
isFile: true,
createdByUser: { id: 'admin', displayName: 'Administrator' },
modifiedAt: '2016-07-08T17:04:34.684+0000',
nodeType: 'cm:content',
content: {
mimeType: 'text/plain',
mimeTypeName: 'Plain Text',
sizeInBytes: 28,
encoding: 'ISO-8859-2'
},
parentId: '55290409-3c61-41e5-80f6-8354ed133ce0',
aspectNames: ['cm:versionable', 'cm:titled', 'cm:auditable', 'cm:author'],
createdAt: '2016-07-08T17:04:34.684+0000',
isFolder: false,
modifiedByUser: { id: 'admin', displayName: 'Administrator' },
name: 'testFile-2.txt',
id: 'ae314293-27e8-4221-9a09-699f103db5f3',
properties: { 'cm:versionLabel': '1.0', 'cm:versionType': 'MAJOR' }
}
});
}
get409CreationFileNewNameClashes(): void {
nock(this.host, { encodedQueryParams: true })
.post('/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children')
.reply(409, {
error: {
errorKey: 'Duplicate child name not allowed: newFile',
statusCode: 409,
briefSummary: '06070090 Duplicate child name not allowed: newFile',
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'
}
});
}
get401Response(): void {
nock(this.host, { encodedQueryParams: true })
.post('/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children')
.reply(401, {
error: {
errorKey: 'framework.exception.ApiDefault',
statusCode: 401,
briefSummary: '05210059 Authentication failed for Web Script org/alfresco/api/ResourceWebScript.get',
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'
}
});
}
}

View File

@@ -0,0 +1,122 @@
/*!
* @license
* Copyright © 2005-2023 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 nock from 'nock';
import { BaseMock } from '../base.mock';
export class VersionMock extends BaseMock {
post201Response(nodeId: string, versionId: string): void {
nock(this.host, { encodedQueryParams: true })
.post('/alfresco/api/-default-/public/alfresco/versions/1/nodes/' + nodeId + '/versions/' + versionId + '/revert')
.reply(201, { entry: { id: '3.0' } });
}
get200Response(nodeId: string): void {
nock(this.host, { encodedQueryParams: true })
.get('/alfresco/api/-default-/public/alfresco/versions/1/nodes/' + nodeId + '/versions')
.reply(200, {
list: {
pagination: {
count: 2,
hasMoreItems: false,
totalItems: 2,
skipCount: 0,
maxItems: 100
},
entries: [{ entry: { id: '2.0' } }, { entry: { id: '1.0' } }]
}
});
}
get200ResponseVersionRenditions(nodeId: string, versionId: string): void {
nock(this.host, { encodedQueryParams: true })
.get('/alfresco/api/-default-/public/alfresco/versions/1/nodes/' + nodeId + '/versions/' + versionId + '/renditions')
.reply(200, {
list: {
pagination: {
count: 6,
hasMoreItems: false,
totalItems: 6,
skipCount: 0,
maxItems: 100
},
entries: [
{
entry: {
id: 'avatar',
content: { mimeType: 'image/png', mimeTypeName: 'PNG Image' },
status: 'NOT_CREATED'
}
},
{
entry: {
id: 'avatar32',
content: { mimeType: 'image/png', mimeTypeName: 'PNG Image' },
status: 'NOT_CREATED'
}
},
{
entry: {
id: 'doclib',
content: { mimeType: 'image/png', mimeTypeName: 'PNG Image' },
status: 'NOT_CREATED'
}
},
{
entry: {
id: 'imgpreview',
content: { mimeType: 'image/jpeg', mimeTypeName: 'JPEG Image' },
status: 'NOT_CREATED'
}
},
{
entry: {
id: 'medium',
content: { mimeType: 'image/jpeg', mimeTypeName: 'JPEG Image' },
status: 'NOT_CREATED'
}
},
{
entry: {
id: 'pdf',
content: { mimeType: 'application/pdf', mimeTypeName: 'Adobe PDF Document' },
status: 'NOT_CREATED'
}
}
]
}
});
}
get200VersionRendition(nodeId: string, versionId: string, renditionId: string): void {
nock(this.host, { encodedQueryParams: true })
.get('/alfresco/api/-default-/public/alfresco/versions/1/nodes/' + nodeId + '/versions/' + versionId + '/renditions/' + renditionId)
.reply(200, {
entry: {
id: 'pdf',
content: { mimeType: 'application/pdf', mimeTypeName: 'Adobe PDF Document' },
status: 'NOT_CREATED'
}
});
}
create200VersionRendition(nodeId: string, versionId: string): void {
nock(this.host, { encodedQueryParams: true })
.post('/alfresco/api/-default-/public/alfresco/versions/1/nodes/' + nodeId + '/versions/' + versionId + '/renditions', { id: 'pdf' })
.reply(202, '');
}
}

View File

@@ -0,0 +1,84 @@
/*!
* @license
* Copyright © 2005-2023 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 nock from 'nock';
import { BaseMock } from '../base.mock';
export class WebScriptMock extends BaseMock {
contextRoot: string;
servicePath: string;
scriptPath: string;
scriptSlug: string;
constructor(host?: string, contextRoot?: string, servicePath?: string, scriptPath?: string) {
super(host);
this.contextRoot = contextRoot || 'alfresco';
this.servicePath = servicePath || 'service';
this.scriptPath = scriptPath;
this.scriptSlug = '/' + this.contextRoot + '/' + this.servicePath + '/' + this.scriptPath;
}
get404Response(): void {
nock(this.host, { encodedQueryParams: true })
.get(this.scriptSlug)
.reply(404, {
error: {
errorKey: 'Unable to locate resource resource for :alfresco ',
statusCode: 404,
briefSummary: '06130000 Unable to locate resource resource for :alfresco ',
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'
}
});
}
get200Response(): void {
nock(this.host, { encodedQueryParams: true })
.get(this.scriptSlug)
.reply(200, {
randomStructure: {
exampleInt: 1,
exampleString: 'string test'
}
});
}
get200ResponseHTMLFormat(): void {
nock(this.host, { encodedQueryParams: true })
.get('/alfresco/service/sample/folder/Company%20Home')
.reply(
200,
// eslint-disable-next-line max-len
'<html>\n <head>\n <title>/Company Home</title>\n </head>\n <body>\n Folder: /Company Home\n <br>\n <table>\n <tr>\n <td>&gt;<td><a href="/alfresco/service/sample/folder/Company%20Home/Data%20Dictionary">Data Dictionary</a>\n </tr>\n <tr>\n <td>&gt;<td><a href="/alfresco/service/sample/folder/Company%20Home/Guest%20Home">Guest Home</a>\n </tr>\n <tr>\n <td>&gt;<td><a href="/alfresco/service/sample/folder/Company%20Home/User%20Homes">User Homes</a>\n </tr>\n <tr>\n <td>&gt;<td><a href="/alfresco/service/sample/folder/Company%20Home/Shared">Shared</a>\n </tr>\n <tr>\n <td>&gt;<td><a href="/alfresco/service/sample/folder/Company%20Home/Imap%20Attachments">Imap Attachments</a>\n </tr>\n <tr>\n <td>&gt;<td><a href="/alfresco/service/sample/folder/Company%20Home/IMAP%20Home">IMAP Home</a>\n </tr>\n <tr>\n <td>&gt;<td><a href="/alfresco/service/sample/folder/Company%20Home/Sites">Sites</a>\n </tr>\n <tr>\n <td>&gt;<td><a href="/alfresco/service/sample/folder/Company%20Home/x">x</a>\n </tr>\n <tr>\n <td><td><a href="/alfresco/service/api/node/content/workspace/SpacesStore/2857abfd-0ac6-459d-a22d-ec78770570f3/testFile.txt">testFile.txt</a>\n </tr>\n <tr>\n <td>&gt;<td><a href="/alfresco/service/sample/folder/Company%20Home/newFolder">newFolder</a>\n </tr>\n <tr>\n <td>&gt;<td><a href="/alfresco/service/sample/folder/Company%20Home/newFolder-1">newFolder-1</a>\n </tr>\n <tr>\n <td><td><a href="/alfresco/service/api/node/content/workspace/SpacesStore/21ce66a9-6bc5-4c49-8ad3-43d3b824a9a3/testFile-1.txt">testFile-1.txt</a>\n </tr>\n <tr>\n <td><td><a href="/alfresco/service/api/node/content/workspace/SpacesStore/ae314293-27e8-4221-9a09-699f103db5f3/testFile-2.txt">testFile-2.txt</a>\n </tr>\n <tr>\n <td><td><a href="/alfresco/service/api/node/content/workspace/SpacesStore/935c1a72-647f-4c8f-aab6-e3b161978427/testFile-3.txt">testFile-3.txt</a>\n </tr>\n </table>\n </body>\n</html>\n\n'
); // jshint ignore:line
}
get401Response(): void {
nock(this.host, { encodedQueryParams: true })
.get(this.scriptSlug)
.reply(401, {
error: {
errorKey: 'framework.exception.ApiDefault',
statusCode: 401,
briefSummary: '05210059 Authentication failed for Web Script org/alfresco/api/ResourceWebScript.get',
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'
}
});
}
}