diff --git a/src/api/activiti-rest-api/api/index.ts b/src/api/activiti-rest-api/api/index.ts index 044cc73bbe..a5a78ba6e7 100644 --- a/src/api/activiti-rest-api/api/index.ts +++ b/src/api/activiti-rest-api/api/index.ts @@ -16,90 +16,46 @@ */ export * from './about.api'; -import { AboutApi } from './about.api'; export * from './accountIntegration.api'; -import { AccountIntegrationApi } from './accountIntegration.api'; export * from './adminEndpoints.api'; -import { AdminEndpointsApi } from './adminEndpoints.api'; export * from './adminGroups.api'; -import { AdminGroupsApi } from './adminGroups.api'; export * from './adminTenants.api'; -import { AdminTenantsApi } from './adminTenants.api'; export * from './adminUsers.api'; -import { AdminUsersApi } from './adminUsers.api'; export * from './appDefinitions.api'; -import { AppDefinitionsApi } from './appDefinitions.api'; export * from './checklists.api'; -import { ChecklistsApi } from './checklists.api'; export * from './comments.api'; -import { ActivitiCommentsApi } from './comments.api'; -import { ContentApi } from './content.api'; import { ContentApi as ActivitiContentApi} from './content.api'; export { ActivitiContentApi }; export * from './dataSources.api'; -import { DataSourcesApi } from './dataSources.api'; export * from './decisionAudits.api'; -import { DecisionAuditsApi } from './decisionAudits.api'; export * from './decisionTables.api'; -import { DecisionTablesApi } from './decisionTables.api'; export * from './endpoints.api'; -import { EndpointsApi } from './endpoints.api'; export * from './formModels.api'; -import { FormModelsApi } from './formModels.api'; export * from './groups.api'; -import { ActivitiGroupsApi } from './groups.api'; export * from './iDMSync.api'; -import { IDMSyncApi } from './iDMSync.api'; export * from './integrationAlfrescoCloud.api'; -import { IntegrationAlfrescoCloudApi } from './integrationAlfrescoCloud.api'; export * from './integrationAlfrescoOnPremise.api'; -import { IntegrationAlfrescoOnPremiseApi } from './integrationAlfrescoOnPremise.api'; export * from './integrationBox.api'; -import { IntegrationBoxApi } from './integrationBox.api'; export * from './integrationDrive.api'; -import { IntegrationDriveApi } from './integrationDrive.api'; export * from './models.api'; -import { ModelsApi } from './models.api'; export * from './modelsBpmn.api'; -import { ModelsBpmnApi } from './modelsBpmn.api'; export * from './modelsHistory.api'; -import { ModelsHistoryApi } from './modelsHistory.api'; export * from './processDefinitions.api'; -import { ProcessDefinitionsApi } from './processDefinitions.api'; export * from './processInstances.api'; -import { ProcessInstancesApi } from './processInstances.api'; export * from './processInstanceVariables.api'; -import { ProcessInstanceVariablesApi } from './processInstanceVariables.api'; export * from './processScopes.api'; -import { ProcessScopesApi } from './processScopes.api'; export * from './runtimeAppDefinitions.api'; -import { RuntimeAppDefinitionsApi } from './runtimeAppDefinitions.api'; export * from './runtimeAppDeployments.api'; -import { RuntimeAppDeploymentsApi } from './runtimeAppDeployments.api'; export * from './scriptFiles.api'; -import { ScriptFilesApi } from './scriptFiles.api'; export * from './submittedForms.api'; -import { SubmittedFormsApi } from './submittedForms.api'; export * from './systemProperties.api'; -import { SystemPropertiesApi } from './systemProperties.api'; export * from './taskActions.api'; -import { TaskActionsApi } from './taskActions.api'; export * from './taskForms.api'; -import { TaskFormsApi } from './taskForms.api'; export * from './tasks.api'; -import { TasksApi } from './tasks.api'; export * from './taskVariables.api'; -import { TaskVariablesApi } from './taskVariables.api'; export * from './userFilters.api'; -import { UserFiltersApi } from './userFilters.api'; export * from './userProfile.api'; -import { UserProfileApi } from './userProfile.api'; export * from './users.api'; -import { UsersApi } from './users.api'; export * from './report.api'; -import { ReportApi } from './report.api'; export * from './modelJsonBpmn.api'; -import { ModelJsonBpmnApi } from './modelJsonBpmn.api'; export * from './temporary.api'; -import { TemporaryApi } from './temporary.api'; -export const APS_APIS = [AboutApi, AccountIntegrationApi, AdminEndpointsApi, AdminGroupsApi, AdminTenantsApi, AdminUsersApi, AppDefinitionsApi, ChecklistsApi, ActivitiCommentsApi, ContentApi, DataSourcesApi, DecisionAuditsApi, DecisionTablesApi, EndpointsApi, FormModelsApi, ActivitiGroupsApi, IDMSyncApi, IntegrationAlfrescoCloudApi, IntegrationAlfrescoOnPremiseApi, IntegrationBoxApi, IntegrationDriveApi, ModelsApi, ModelJsonBpmnApi, ModelsBpmnApi, ModelsHistoryApi, ProcessDefinitionsApi, ProcessInstancesApi, ProcessInstanceVariablesApi, ProcessScopesApi, RuntimeAppDefinitionsApi, RuntimeAppDeploymentsApi, ScriptFilesApi, SubmittedFormsApi, SystemPropertiesApi, TaskActionsApi, TaskFormsApi, TasksApi, TaskVariablesApi, UserFiltersApi, UserProfileApi, UsersApi, ReportApi, TemporaryApi]; diff --git a/src/api/auth-rest-api/api/index.ts b/src/api/auth-rest-api/api/index.ts index 321991eac0..2bdc302141 100644 --- a/src/api/auth-rest-api/api/index.ts +++ b/src/api/auth-rest-api/api/index.ts @@ -16,6 +16,3 @@ */ export * from './authentication.api'; -import { AuthenticationApi } from './authentication.api'; - -export const AUTH_APIS = { AuthenticationApi: AuthenticationApi }; diff --git a/src/api/content-custom-api/api/classes.api.ts b/src/api/content-custom-api/api/classes.api.ts index be53f8fba2..d15fbc28d5 100755 --- a/src/api/content-custom-api/api/classes.api.ts +++ b/src/api/content-custom-api/api/classes.api.ts @@ -18,12 +18,6 @@ import { ClassDescription } from '../model/classDescription'; import { BaseApi } from './base.api'; -/** - * Classes service. - * @module api/ClassesApi - * @version 1.4.0 - */ - /** * Constructs a new ClassesApi. * @alias module:api/ClassesApi @@ -32,72 +26,37 @@ import { BaseApi } from './base.api'; * default to {@link module:ApiClient#instance} if unspecified. */ export class ClassesApi extends BaseApi { - - private path: string = '/api/classes'; - - /** - * Function to receive the result of the getClass operation. - * @param {String} error Error message, if any. - * @param {module:model/ClassDescription} data The data returned by the service call. - * @param {String} response The complete HTTP response. - */ - /** * Gets the class information for the specified className. * @param {String} className The identifier of the class. - * @param {Object} opts Optional parameters * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/ClassDescription} * data is of type: {module:model/ClassDescription} */ - getClass(className: string, opts?: any): Promise { - opts = opts || {}; - + getClass(className: string): Promise { // verify the required parameter 'className' is set if (className === undefined || className === null) { throw "Missing param 'className' in getClass"; } - let postBody = null; - let pathParams = { - 'className': className - }; - let queryParams = {}; - let headerParams = {}; - let formParams = {}; - - let contentTypes = ['application/json']; - let accepts = ['application/json']; - - return this.apiClientPrivate.callApi( - this.path + '/{className}', 'GET', - pathParams, queryParams, headerParams, formParams, postBody, - contentTypes, accepts, ClassDescription, this.apiClientPrivate.config.contextRoot + '/s' - ); + return this.get({ + path: '/api/classes/{className}', + pathParams: { className }, + returnType: ClassDescription, + contextRoot: this.apiClientPrivate.config.contextRoot + '/s' + }); } - getSubclasses(className: string, opts?: any): Promise { - opts = opts || {}; - + getSubclasses(className: string): Promise { // verify the required parameter 'className' is set if (className === undefined || className === null) { throw "Missing param 'className'"; } - let postBody = null; - let pathParams = { - 'className': className - }; - let queryParams = {}; - let headerParams = {}; - let formParams = {}; - - let contentTypes = ['application/json']; - let accepts = ['application/json']; - - return this.apiClientPrivate.callApi( - `${this.path}/{className}/subclasses`, 'GET', - pathParams, queryParams, headerParams, formParams, postBody, - contentTypes, accepts, ClassDescription, this.apiClientPrivate.config.contextRoot + '/s' - ); + return this.get({ + path: `/api/classes/{className}/subclasses`, + pathParams: { className }, + returnType: ClassDescription, + contextRoot: this.apiClientPrivate.config.contextRoot + '/s' + }); } } diff --git a/src/api/content-custom-api/api/index.ts b/src/api/content-custom-api/api/index.ts index 951d663ada..ead074fa07 100644 --- a/src/api/content-custom-api/api/index.ts +++ b/src/api/content-custom-api/api/index.ts @@ -16,18 +16,7 @@ */ export * from './webscript.api'; -import { WebscriptApi } from './webscript.api'; - export * from './classes.api'; -import { ClassesApi } from './classes.api'; - export * from './upload.api'; -import { UploadApi } from './upload.api'; - export * from './content.api'; -import { ContentApi } from './content.api'; - export * from './customModel.api'; -import { CustomModelApi } from './customModel.api'; - -export const CONTENT_CUSTOM_APIS = [WebscriptApi, ClassesApi, CustomModelApi, UploadApi, ContentApi]; diff --git a/src/api/content-custom-api/api/upload.api.ts b/src/api/content-custom-api/api/upload.api.ts index da19253900..61ee14f504 100644 --- a/src/api/content-custom-api/api/upload.api.ts +++ b/src/api/content-custom-api/api/upload.api.ts @@ -16,18 +16,23 @@ */ import { NodesApi } from '../../content-rest-api/api/nodes.api'; -import { Emitter } from 'event-emitter'; +import { NodeBodyCreate, NodeEntry, CreateNodeOpts } from '../../content-rest-api'; + +export interface UploadFileOpts extends CreateNodeOpts { + name?: string; + renditions?: string; +} export class UploadApi extends NodesApi { - uploadFile(fileDefinition: any, relativePath: string, rootFolderId: string, nodeBody: any, opts?: any): Promise { + uploadFile(fileDefinition: any, relativePath?: string, rootFolderId?: string, nodeBody?: NodeBodyCreate, opts?: UploadFileOpts): Promise { rootFolderId = rootFolderId || '-root-'; opts = opts || {}; - let nodeBodyRequired = { - 'name': fileDefinition.name, - 'nodeType': 'cm:content', - 'relativePath': relativePath + const nodeBodyRequired = { + name: fileDefinition.name, + nodeType: 'cm:content', + relativePath: relativePath }; nodeBody = Object.assign(nodeBodyRequired, nodeBody); diff --git a/src/api/content-custom-api/docs/PermissionsBodyUpdate.md b/src/api/content-custom-api/docs/PermissionsBodyUpdate.md deleted file mode 100644 index b616665191..0000000000 --- a/src/api/content-custom-api/docs/PermissionsBodyUpdate.md +++ /dev/null @@ -1,9 +0,0 @@ -# PermissionsBodyUpdate - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**isInheritanceEnabled** | **boolean** | | [optional] [default to null] -**locallySet** | [**PermissionElement[]**](PermissionElement.md) | | [optional] [default to null] - - diff --git a/src/api/content-custom-api/docs/UploadApi.md b/src/api/content-custom-api/docs/UploadApi.md index c42bb87139..9c3628542b 100644 --- a/src/api/content-custom-api/docs/UploadApi.md +++ b/src/api/content-custom-api/docs/UploadApi.md @@ -1,33 +1,31 @@ # UploadApi -Method | HTTP request | Description -------------- | ------------- | ------------- -[**uploadFile**](UploadApi.md#uploadFile) | | upload file content +| Method | Description | +|-------------------------------------------|---------------------| +| [**uploadFile**](UploadApi.md#uploadFile) | upload file content | # **uploadFile** -> uploadFile(fileDefinition, relativePath: string, rootFolderId: string, nodeBody: any, opts?: any): Promise +> uploadFile(fileDefinition, relativePath: string, rootFolderId: string, nodeBody: any, opts?: any): Promise -### Example +**Example** ```javascript +const alfrescoApi = new AlfrescoApi(/*...*/); +const fs = require('fs'); +const uploadApi = new UploadApi(alfrescoApi); +const fileToUpload = fs.createReadStream('./folderA/folderB/newFile.txt'); -let fs = require('fs'); - -let fileToUpload = fs.createReadStream('./folderA/folderB/newFile.txt'); - -let uploadApi = new UploadApi(this.alfrescoApi); -uploadApi.uploadFile(fileToUpload) - .then(() => { +uploadApi.uploadFile(fileToUpload).then( + () => { console.log('File Uploaded in the root'); - }, (error) => { + }, + (error) => { console.log('Error during the upload' + error); }); - - ``` diff --git a/src/api/content-rest-api/api/groups.api.ts b/src/api/content-rest-api/api/groups.api.ts index 30ac71fdd2..2dd9892342 100644 --- a/src/api/content-rest-api/api/groups.api.ts +++ b/src/api/content-rest-api/api/groups.api.ts @@ -26,6 +26,54 @@ import { BaseApi } from './base.api'; import { throwIfNotDefined } from '../../../assert'; import { buildCollectionParam } from '../../../alfrescoApiClient'; +export interface CreateGroupOpts { + /** + * Returns additional information about the group. + * The following optional fields can be requested: + * - parentIds + * - zones + */ + include?: string[]; + + /** + * A list of field names. + * + * You can use this parameter to restrict the fields + * returned within a response if, for example, you want to save on overall bandwidth. + * + * 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. + */ + fields?: string[]; +} + +export interface CreateGroupMembershipOpts { + /** + * A list of field names. + * + * You can use this parameter to restrict the fields + * returned within a response if, for example, you want to save on overall bandwidth. + * + * 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. + */ + fields?: string[]; +} + +export interface DeleteGroupOpts { + /** + * If **true** then deletion will be applied in cascade to subgroups. (default to false) + */ + cascade?: boolean; +} + /** * Groups service. * @module GroupsApi @@ -54,54 +102,24 @@ You must have admin rights to create a group. * * @param groupBodyCreate The group to create. * @param opts Optional parameters - * @param opts.include Returns additional information about the group. The following optional fields can be requested: -* parentIds -* zones - - * @param opts.fields A list of field names. - -You can use this parameter to restrict the fields -returned within a response if, for example, you want to save on overall bandwidth. - -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. - * @return Promise */ - createGroup(groupBodyCreate: GroupBodyCreate, opts?: any): Promise { - + createGroup(groupBodyCreate: GroupBodyCreate, opts?: CreateGroupOpts): Promise { throwIfNotDefined(groupBodyCreate, 'groupBodyCreate'); - opts = opts || {}; - const postBody = groupBodyCreate; - - const pathParams = { - - }; - const queryParams = { - 'include': buildCollectionParam(opts['include'], 'csv'), - 'fields': buildCollectionParam(opts['fields'], 'csv') - }; - - const headerParams = { - - }; - const formParams = { + include: buildCollectionParam(opts?.include, 'csv'), + fields: buildCollectionParam(opts?.fields, 'csv') }; - const contentTypes = ['application/json']; - const accepts = ['application/json']; - - return this.apiClient.callApi( - '/groups', 'POST', - pathParams, queryParams, headerParams, formParams, postBody, - contentTypes, accepts , GroupEntry); + return this.post({ + path: '/groups', + queryParams, + bodyParam: groupBodyCreate, + returnType: GroupEntry + }) } + /** * Create a group membership * @@ -119,50 +137,25 @@ You must have admin rights to create a group membership. * @param groupId The identifier of a group. * @param groupMembershipBodyCreate The group membership to add (person or sub-group). * @param opts Optional parameters - * @param opts.fields A list of field names. - -You can use this parameter to restrict the fields -returned within a response if, for example, you want to save on overall bandwidth. - -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. - * @return Promise */ - createGroupMembership(groupId: string, groupMembershipBodyCreate: GroupMembershipBodyCreate, opts?: any): Promise { - + createGroupMembership(groupId: string, groupMembershipBodyCreate: GroupMembershipBodyCreate, opts?: CreateGroupMembershipOpts): Promise { throwIfNotDefined(groupId, 'groupId'); throwIfNotDefined(groupMembershipBodyCreate, 'groupMembershipBodyCreate'); - opts = opts || {}; - const postBody = groupMembershipBodyCreate; - - const pathParams = { - 'groupId': groupId - }; - const queryParams = { - 'fields': buildCollectionParam(opts['fields'], 'csv') - }; - - const headerParams = { - - }; - const formParams = { + fields: buildCollectionParam(opts?.fields, 'csv') }; - const contentTypes = ['application/json']; - const accepts = ['application/json']; - - return this.apiClient.callApi( - '/groups/{groupId}/members', 'POST', - pathParams, queryParams, headerParams, formParams, postBody, - contentTypes, accepts , GroupMemberEntry); + return this.post({ + path: '/groups/{groupId}/members', + pathParams: { groupId }, + queryParams, + bodyParam: groupMembershipBodyCreate, + returnType: GroupMemberEntry + }); } + /** * Delete a group * @@ -179,12 +172,9 @@ You must have admin rights to delete a group. * * @param groupId The identifier of a group. * @param opts Optional parameters - * @param opts.cascade If **true** then the delete will be applied in cascade to sub-groups. - (default to false) - * @return Promise<{}> + * @return Promise */ - deleteGroup(groupId: string, opts?: any): Promise { - + deleteGroup(groupId: string, opts?: DeleteGroupOpts): Promise { throwIfNotDefined(groupId, 'groupId'); opts = opts || {}; @@ -232,8 +222,7 @@ You must have admin rights to delete a group membership. * @param groupMemberId The identifier of a person or group. * @return Promise<{}> */ - deleteGroupMembership(groupId: string, groupMemberId: string): Promise { - + deleteGroupMembership(groupId: string, groupMemberId: string): Promise { throwIfNotDefined(groupId, 'groupId'); throwIfNotDefined(groupMemberId, 'groupMemberId'); @@ -260,6 +249,7 @@ You must have admin rights to delete a group membership. pathParams, queryParams, headerParams, formParams, postBody, contentTypes, accepts ); } + /** * Get group details * diff --git a/src/api/content-rest-api/api/index.ts b/src/api/content-rest-api/api/index.ts index be1ff70857..aadfae94bb 100644 --- a/src/api/content-rest-api/api/index.ts +++ b/src/api/content-rest-api/api/index.ts @@ -16,67 +16,23 @@ */ export * from './actions.api'; -import { ActionsApi } from './actions.api'; export * from './activities.api'; -import { ActivitiesApi } from './activities.api'; export * from './audit.api'; -import { AuditApi } from './audit.api'; export * from './categories.api'; -import { CategoriesApi } from './categories.api'; export * from './comments.api'; -import { CommentsApi } from './comments.api'; export * from './downloads.api'; -import { DownloadsApi } from './downloads.api'; export * from './favorites.api'; -import { FavoritesApi } from './favorites.api'; export * from './groups.api'; -import { GroupsApi } from './groups.api'; export * from './networks.api'; -import { NetworksApi } from './networks.api'; export * from './nodes.api'; -import { NodesApi } from './nodes.api'; export * from './people.api'; -import { PeopleApi } from './people.api'; export * from './preferences.api'; -import { PreferencesApi } from './preferences.api'; export * from './probes.api'; -import { ProbesApi } from './probes.api'; export * from './queries.api'; -import { QueriesApi } from './queries.api'; export * from './ratings.api'; -import { RatingsApi } from './ratings.api'; export * from './renditions.api'; -import { RenditionsApi } from './renditions.api'; export * from './sharedlinks.api'; -import { SharedlinksApi } from './sharedlinks.api'; export * from './sites.api'; -import { SitesApi } from './sites.api'; export * from './tags.api'; -import { TagsApi } from './tags.api'; export * from './trashcan.api'; -import { TrashcanApi } from './trashcan.api'; export * from './versions.api'; -import { VersionsApi } from './versions.api'; -export const APIS = { - ActionsApi: ActionsApi, - ActivitiesApi: ActivitiesApi, - AuditApi: AuditApi, - CategoriesApi: CategoriesApi, - CommentsApi: CommentsApi, - DownloadsApi: DownloadsApi, - FavoritesApi: FavoritesApi, - GroupsApi: GroupsApi, - NetworksApi: NetworksApi, - NodesApi: NodesApi, - PeopleApi: PeopleApi, - PreferencesApi: PreferencesApi, - ProbesApi: ProbesApi, - QueriesApi: QueriesApi, - RatingsApi: RatingsApi, - RenditionsApi: RenditionsApi, - SharedlinksApi: SharedlinksApi, - SitesApi: SitesApi, - TagsApi: TagsApi, - TrashcanApi: TrashcanApi, - VersionsApi: VersionsApi -}; diff --git a/src/api/content-rest-api/api/nodes.api.ts b/src/api/content-rest-api/api/nodes.api.ts index 9858204796..77163ebf4c 100644 --- a/src/api/content-rest-api/api/nodes.api.ts +++ b/src/api/content-rest-api/api/nodes.api.ts @@ -32,6 +32,20 @@ import { BaseApi } from './base.api'; import { throwIfNotDefined } from '../../../assert'; import { buildCollectionParam } from '../../../alfrescoApiClient'; +export interface CreateNodeOpts { + [key: string]: any; + // If true, then a name clash will cause an attempt to auto rename by finding a unique name using an integer suffix. + autoRename?: boolean; + // If true, then created node will be version 1.0 MAJOR. If false, then created node will be version 0.1 MINOR. + majorVersion?: boolean; + // If true, then created node will be versioned. If false, then created node will be unversioned and auto-versioning disabled. + versioningEnabled?: boolean; + // Returns additional information about the node. + include?: string[], + // A list of field names. + fields?: string[], +} + /** * Nodes service. * @module NodesApi @@ -437,27 +451,26 @@ parameter are returned in addition to those specified in the **fields** paramete * @return Promise */ - createNode(nodeId: string, nodeBodyCreate: NodeBodyCreate, opts?: any, formParams?: any): Promise { + createNode(nodeId: string, nodeBodyCreate: NodeBodyCreate, opts?: CreateNodeOpts, formParams?: any): Promise { throwIfNotDefined(nodeId, 'nodeId'); throwIfNotDefined(nodeBodyCreate, 'nodeBodyCreate'); opts = opts || {}; - let postBody = nodeBodyCreate; - let pathParams = { - 'nodeId': nodeId + const pathParams = { + nodeId: nodeId }; - let queryParams = { - 'autoRename': opts['autoRename'], - 'include': buildCollectionParam(opts['include'], 'csv'), - 'fields': buildCollectionParam(opts['fields'], 'csv') + const queryParams = { + autoRename: opts.autoRename, + include: buildCollectionParam(opts.include, 'csv'), + fields: buildCollectionParam(opts.fields, 'csv') }; - let headerParams = {}; formParams = formParams || {}; - let contentTypes, returnType = null; + let contentTypes; + let returnType; if (formParams.filedata) { contentTypes = ['multipart/form-data']; @@ -470,7 +483,7 @@ parameter are returned in addition to those specified in the **fields** paramete return this.apiClient.callApi( '/nodes/{nodeId}/children', 'POST', - pathParams, queryParams, headerParams, formParams, postBody, + pathParams, queryParams, {}, formParams, nodeBodyCreate, contentTypes, accepts, returnType); } diff --git a/src/api/discovery-rest-api/api/index.ts b/src/api/discovery-rest-api/api/index.ts index f62c104546..cfb56c6869 100644 --- a/src/api/discovery-rest-api/api/index.ts +++ b/src/api/discovery-rest-api/api/index.ts @@ -15,7 +15,4 @@ * limitations under the License. */ -export { DiscoveryApi } from './discovery.api'; -import { DiscoveryApi } from './discovery.api'; - -export const DISCOVERY_APIS = { DiscoveryApi: DiscoveryApi }; +export * from './discovery.api'; diff --git a/src/api/gs-classification-rest-api/api/index.ts b/src/api/gs-classification-rest-api/api/index.ts index 8df5479dbb..1a590d0d6c 100644 --- a/src/api/gs-classification-rest-api/api/index.ts +++ b/src/api/gs-classification-rest-api/api/index.ts @@ -16,40 +16,11 @@ */ export * from './classificationGuides.api'; -import { ClassificationGuidesApi } from './classificationGuides.api'; - export * from './classificationReasons.api'; -import { ClassificationReasonsApi } from './classificationReasons.api'; - export * from './declassificationExemptions.api'; -import { DeclassificationExemptionsApi } from './declassificationExemptions.api'; - export * from './defaultClassificationValues.api'; -import { DefaultClassificationValuesApi } from './defaultClassificationValues.api'; - export * from './securityControlSettings.api'; -import { SecurityControlSettingsApi } from './securityControlSettings.api'; - export * from './securityMarks.api'; -import { SecurityMarksApi } from './securityMarks.api'; - export * from './securityGroups.api'; -import { SecurityGroupsApi } from './securityGroups.api'; - export * from './nodeSecurityMarks.api'; -import { NodeSecurityMarksApi } from './nodeSecurityMarks.api'; - export * from './authorityClearance.api'; -import { AuthorityClearanceApi } from "./authorityClearance.api"; - -export const GS_CLASSIFICATION_APIS = { - ClassificationGuidesApi: ClassificationGuidesApi, - ClassificationReasonsApi: ClassificationReasonsApi, - DeclassificationExemptionsApi: DeclassificationExemptionsApi, - DefaultClassificationValuesApi: DefaultClassificationValuesApi, - SecurityControlSettingsApi: SecurityControlSettingsApi, - SecurityMarksApi: SecurityMarksApi, - SecurityGroupsApi: SecurityGroupsApi, - NodeSecurityMarksApi: NodeSecurityMarksApi, - AuthorityClearanceApi: AuthorityClearanceApi -}; diff --git a/src/api/gs-core-rest-api/api/index.ts b/src/api/gs-core-rest-api/api/index.ts index e890509365..3247ec7ae6 100644 --- a/src/api/gs-core-rest-api/api/index.ts +++ b/src/api/gs-core-rest-api/api/index.ts @@ -16,44 +16,12 @@ */ export * from './filePlans.api'; -import { FilePlansApi } from './filePlans.api'; - export * from './files.api'; -import { FilesApi } from './files.api'; - export * from './gsSites.api'; -import { GsSitesApi } from './gsSites.api'; - export * from './recordCategories.api'; -import { RecordCategoriesApi } from './recordCategories.api'; - export * from './recordFolders.api'; -import { RecordFoldersApi } from './recordFolders.api'; - export * from './records.api'; -import { RecordsApi } from './records.api'; - export * from './transferContainers.api'; -import { TransferContainersApi } from './transferContainers.api'; - export * from './transfers.api'; -import { TransfersApi } from './transfers.api'; - export * from './unfiledContainers.api'; -import { UnfiledContainersApi } from './unfiledContainers.api'; - export * from './unfiledRecordFolders.api'; -import { UnfiledRecordFoldersApi } from './unfiledRecordFolders.api'; - -export const GS_CORE_APIS = { - FilePlansApi: FilePlansApi, - FilesApi: FilesApi, - GsSitesApi: GsSitesApi, - RecordCategoriesApi: RecordCategoriesApi, - RecordFoldersApi: RecordFoldersApi, - RecordsApi: RecordsApi, - TransferContainersApi: TransferContainersApi, - TransfersApi: TransfersApi, - UnfiledContainersApi: UnfiledContainersApi, - UnfiledRecordFoldersApi: UnfiledRecordFoldersApi -}; diff --git a/src/api/model-rest-api/api/aspects.api.ts b/src/api/model-rest-api/api/aspects.api.ts index a58bcd5ac0..a578ed6e09 100644 --- a/src/api/model-rest-api/api/aspects.api.ts +++ b/src/api/model-rest-api/api/aspects.api.ts @@ -21,6 +21,45 @@ import { BaseApi } from './base.api'; import { throwIfNotDefined } from '../../../assert'; import { buildCollectionParam } from '../../../alfrescoApiClient'; +export class ListAspectsOpts { + /** + * Optionally filter the list. Here are some examples: + * + * An aspect should be represented in the following format(prefix:name). e.g 'cm:title'. + * + * The following where clause will only return aspects from the namespace1:model and namespace2:model. + * + * - where=(modelId in ('namespace1:model','namespace2:model')) + * - where=(modelId in ('namespace1:model INCLUDESUBASPECTS','namespace2:model')) + * + * The following where clause will only return sub aspects for the given parents. + * + * - where=(parentId in ('namespace1:parent','namespace2:parent')) + * + * The following where clause will only return aspects that match the pattern. + * + * - where=(namespaceUri matches('http://www.alfresco.*')) + * + * The following where clause will only return aspects that don't match the pattern. + * + * - where=(not namespaceUri matches('http://www.alfresco.*')) + */ + where?: string; + // The number of entities that exist in the collection before those included in this list. + // If not supplied then the default value is 0. + skipCount?: number; + // The maximum number of items to return in the list. + // If not supplied then the default value is 100. + maxItems?: number; + /** + * Returns additional information about the aspect. The following optional fields can be requested: + * - properties + * - mandatoryAspects + * - associations + */ + include?: string[]; +} + /** * Aspects service. * @module AspectsApi @@ -37,32 +76,19 @@ Get information for aspect **aspectId**. * @return Promise */ getAspect(aspectId: string): Promise { - throwIfNotDefined(aspectId, 'aspectId'); - const postBody: null = null; - const pathParams = { - 'aspectId': aspectId - }; - - const queryParams = { + aspectId }; - const headerParams = { - - }; - const formParams = { - }; - - const contentTypes = ['application/json']; - const accepts = ['application/json']; - - return this.apiClient.callApi( - '/aspects/{aspectId}', 'GET', - pathParams, queryParams, headerParams, formParams, postBody, - contentTypes, accepts , AspectEntry); + return this.get({ + path: '/aspects/{aspectId}', + pathParams, + returnType: AspectEntry + }) } + /** * List aspects * @@ -126,72 +152,22 @@ JSON ] } } - * * @param opts Optional parameters - * @param opts.where Optionally filter the list. Here are some examples: - -An aspect should represented in the following format(prefix:name). e.g 'cm:title'. - -The following where clause will only return aspects from the namespace1:model and namespace2:model. - - where=(modelId in ('namespace1:model','namespace2:model')) - where=(modelId in ('namespace1:model INCLUDESUBASPECTS','namespace2:model')) - -The following where clause will only return sub aspects for the given parents. - - where=(parentId in ('namespace1:parent','namespace2:parent')) - -The following where clause will only return aspects that match the pattern. - - where=(namespaceUri matches('http://www.alfresco.*')) - -The following where clause will only return aspects that don't match the pattern. - - where=(not namespaceUri matches('http://www.alfresco.*')) - - * @param opts.skipCount The number of entities that exist in the collection before those included in this list. -If not supplied then the default value is 0. - (default to 0) - * @param opts.maxItems The maximum number of items to return in the list. -If not supplied then the default value is 100. - (default to 100) - * @param opts.include Returns additional information about the aspect. The following optional fields can be requested: -* properties -* mandatoryAspects -* associations - * @return Promise */ - listAspects(opts?: any): Promise { - - opts = opts || {}; - const postBody: null = null; - - const pathParams = { - - }; - + listAspects(opts?: ListAspectsOpts): Promise { const queryParams = { - 'where': opts['where'], - 'skipCount': opts['skipCount'], - 'maxItems': opts['maxItems'], - 'include': buildCollectionParam(opts['include'], 'csv') - }; - - const headerParams = { - - }; - const formParams = { + where: opts?.where, + skipCount: opts?.skipCount, + maxItems: opts?.maxItems, + include: buildCollectionParam(opts?.include, 'csv') }; - const contentTypes = ['application/json']; - const accepts = ['application/json']; - - return this.apiClient.callApi( - '/aspects', 'GET', - pathParams, queryParams, headerParams, formParams, postBody, - contentTypes, accepts , AspectPaging); + return this.get({ + path: '/aspects', + queryParams, + returnType: AspectPaging + }) } - } diff --git a/src/api/model-rest-api/api/index.ts b/src/api/model-rest-api/api/index.ts index d7362619dd..8cf56e638d 100644 --- a/src/api/model-rest-api/api/index.ts +++ b/src/api/model-rest-api/api/index.ts @@ -16,10 +16,4 @@ */ export * from './aspects.api'; -import { AspectsApi } from './aspects.api'; export * from './types.api'; -import { TypesApi } from './types.api'; -export const MODEL_APIS = { - AspectsApi: AspectsApi, - TypesApi: TypesApi -}; diff --git a/src/api/model-rest-api/api/types.api.ts b/src/api/model-rest-api/api/types.api.ts index 16f9757f53..b664054feb 100644 --- a/src/api/model-rest-api/api/types.api.ts +++ b/src/api/model-rest-api/api/types.api.ts @@ -21,6 +21,42 @@ import { BaseApi } from './base.api'; import { throwIfNotDefined } from '../../../assert'; import { buildCollectionParam } from '../../../alfrescoApiClient'; +export interface ListTypesOpts { + /** + * Optionally filter the list. Here are some examples: + * + * A type should be represented in the following format(prefix:name). e.g 'cm:content'. + * + * The following where clause will only return types from the namespace1:model and namespace2:model. + * - where=(modelId in ('namespace1:model','namespace2:model')) + * - where=(modelId in ('namespace1:model INCLUDESUBTYPES','namespace2:model')) + * + * The following where clause will only return sub types for the given parents. + * - where=(parentId in ('namespace1:parent','namespace2:parent')) + * + * The following where clause will only return types that match the pattern. + * - where=(namespaceUri matches('http://www.alfresco.*')) + * + * The following where clause will only return types that don't match the pattern. + * - where=(not namespaceUri matches('http://www.alfresco.*')) + */ + where?: string; + // The number of entities that exist in the collection before those included in this list. + // If not supplied then the default value is 0. + skipCount?: number; + // The maximum number of items to return in the list. + // If not supplied then the default value is 100. + maxItems?: number; + /** + * Returns additional information about the type. + * The following optional fields can be requested: + * - properties + * - mandatoryAspects + * - associations + */ + include?: string[]; +} + /** * Types service. * @module TypesApi @@ -37,33 +73,20 @@ Get information for type **typeId**. * @return Promise */ getType(typeId: string): Promise { - throwIfNotDefined(typeId, 'typeId'); - const postBody: null = null; - const pathParams = { - 'typeId': typeId + typeId }; - const queryParams = { - }; - - const headerParams = { - - }; - const formParams = { - }; - - const contentTypes = ['application/json']; - const accepts = ['application/json']; - - return this.apiClient.callApi( - '/types/{typeId}', 'GET', - pathParams, queryParams, headerParams, formParams, postBody, - contentTypes, accepts , TypeEntry); + return this.get({ + path: '/types/{typeId}', + pathParams, + returnType: TypeEntry + }); } -/** + + /** * List types * * **Note:** This is available in Alfresco 7.0.0 and newer versions. @@ -133,72 +156,22 @@ JSON ] } } - * * @param opts Optional parameters - * @param opts.where Optionally filter the list. Here are some examples: - -A type should represented in the following format(prefix:name). e.g 'cm:content'. - -The following where clause will only return types from the namespace1:model and namespace2:model. - - where=(modelId in ('namespace1:model','namespace2:model')) - where=(modelId in ('namespace1:model INCLUDESUBTYPES','namespace2:model')) - -The following where clause will only return sub types for the given parents. - - where=(parentId in ('namespace1:parent','namespace2:parent')) - -The following where clause will only return types that match the pattern. - - where=(namespaceUri matches('http://www.alfresco.*')) - -The following where clause will only return types that don't match the pattern. - - where=(not namespaceUri matches('http://www.alfresco.*')) - - * @param opts.skipCount The number of entities that exist in the collection before those included in this list. -If not supplied then the default value is 0. - (default to 0) - * @param opts.maxItems The maximum number of items to return in the list. -If not supplied then the default value is 100. - (default to 100) - * @param opts.include Returns additional information about the type. The following optional fields can be requested: -* properties -* mandatoryAspects -* associations - * @return Promise */ - listTypes(opts?: any): Promise { - - opts = opts || {}; - const postBody: null = null; - - const pathParams = { - - }; - + listTypes(opts?: ListTypesOpts): Promise { const queryParams = { - 'where': opts['where'], - 'skipCount': opts['skipCount'], - 'maxItems': opts['maxItems'], - 'include': buildCollectionParam(opts['include'], 'csv') - }; - - const headerParams = { - - }; - const formParams = { + where: opts?.where, + skipCount: opts?.skipCount, + maxItems: opts?.maxItems, + include: buildCollectionParam(opts?.include, 'csv') }; - const contentTypes = ['application/json']; - const accepts = ['application/json']; - - return this.apiClient.callApi( - '/types', 'GET', - pathParams, queryParams, headerParams, formParams, postBody, - contentTypes, accepts , TypePaging); + return this.get({ + path: '/types', + queryParams, + returnType: TypePaging + }); } - } diff --git a/src/api/search-rest-api/api/index.ts b/src/api/search-rest-api/api/index.ts index a94d541740..75b8feaa50 100644 --- a/src/api/search-rest-api/api/index.ts +++ b/src/api/search-rest-api/api/index.ts @@ -16,6 +16,3 @@ */ export * from './search.api'; -import { SearchApi } from './search.api'; - -export const SEARCH_APIS = { SearchApi: SearchApi }; diff --git a/test/upload.spec.ts b/test/upload.spec.ts index db4059ce8b..bf92107a4b 100644 --- a/test/upload.spec.ts +++ b/test/upload.spec.ts @@ -18,7 +18,7 @@ import { expect } from 'chai'; import { EcmAuthMock, UploadMock } from '../test/mockObjects'; import fs from 'fs'; -import { AlfrescoApiConfig, UploadApi, AlfrescoApi } from '../index'; +import { AlfrescoApiConfig, UploadApi, AlfrescoApi, NodeEntry } from '../index'; describe('Upload', () => { let authResponseMock: EcmAuthMock; @@ -48,7 +48,7 @@ describe('Upload', () => { const file = fs.createReadStream('./test/mockObjects/assets/testFile.txt'); - uploadApi.uploadFile(file, null, null, null).then((data: any) => { + uploadApi.uploadFile(file).then((data: NodeEntry) => { expect(data.entry.isFile).to.be.equal(true); expect(data.entry.name).to.be.equal('testFile.txt'); done(); @@ -60,7 +60,7 @@ describe('Upload', () => { const file = fs.createReadStream('./test/mockObjects/assets/testFile.txt'); - uploadApi.uploadFile(file, null, null, null).then( + uploadApi.uploadFile(file).then( () => {}, (error: any) => { expect(error.status).to.be.equal(409); @@ -100,7 +100,7 @@ describe('Upload', () => { const file = fs.createReadStream('./test/mockObjects/assets/testFile.txt'); - const uploadPromise: any = uploadApi.uploadFile(file, null, null, null); + const uploadPromise: any = uploadApi.uploadFile(file); uploadPromise.catch(() => {}); uploadPromise.on('success', () => { @@ -113,7 +113,7 @@ describe('Upload', () => { const file = fs.createReadStream('./test/mockObjects/assets/testFile.txt'); - const uploadPromise: any = uploadApi.uploadFile(file, null, null, null); + const uploadPromise: any = uploadApi.uploadFile(file); uploadPromise.catch(() => {}); uploadPromise.on('error', () => { done(); @@ -125,7 +125,7 @@ describe('Upload', () => { const file = fs.createReadStream('./test/mockObjects/assets/testFile.txt'); - const uploadPromise: any = uploadApi.uploadFile(file, null, null, null); + const uploadPromise: any = uploadApi.uploadFile(file); uploadPromise.catch(() => {}); uploadPromise.on('unauthorized', () => { @@ -137,17 +137,15 @@ describe('Upload', () => { uploadMock.get201CreationFile(); const file = fs.createReadStream('./test/mockObjects/assets/testFile.txt'); - - const uploadPromise: any = uploadApi.uploadFile(file, null, null, null); + const uploadPromise: any = uploadApi.uploadFile(file); uploadPromise.catch((error: any) => { console.log('error' + error); }); - uploadPromise.once('progress', () => { - done(); - }, (error: any) => { - console.log('error' + error); - }); + uploadPromise.once('progress', + () => done(), + (error: any) => console.log('error' + error) + ); }); it('Multiple Upload should fire progress events on the right promise during the upload', (done) => { @@ -160,7 +158,7 @@ describe('Upload', () => { const promiseProgressOne = new Promise((resolve) => { uploadMock.get201CreationFile(); - const promise: any = uploadApi.uploadFile(file, null, null, null); + const promise: any = uploadApi.uploadFile(file); promise.once('success', () => { progressOneOk = true; resolve('Resolving'); @@ -170,7 +168,7 @@ describe('Upload', () => { const promiseProgressTwo = new Promise((resolve) => { uploadMock.get201CreationFile(); - const promise: any = uploadApi.uploadFile(fileTwo, null, null, null); + const promise: any = uploadApi.uploadFile(fileTwo); promise.once('success', () => { progressTwoOk = true; resolve('Resolving'); @@ -194,7 +192,7 @@ describe('Upload', () => { const promiseErrorOne = new Promise((resolve) => { uploadMock.get201CreationFile(); - const uploadPromise: any = uploadApi.uploadFile(file, null, null, null); + const uploadPromise: any = uploadApi.uploadFile(file); uploadPromise.catch(() => {}); uploadPromise.once('success', () => { errorOneOk = true; @@ -205,7 +203,7 @@ describe('Upload', () => { const promiseErrorTwo = new Promise((resolve) => { uploadMock.get201CreationFile(); - const uploadPromise: any = uploadApi.uploadFile(fileTwo, null, null, null); + const uploadPromise: any = uploadApi.uploadFile(fileTwo); uploadPromise.catch(() => {}); uploadPromise.once('success', () => { errorTwoOk = true; @@ -230,7 +228,7 @@ describe('Upload', () => { const promiseSuccessOne = new Promise((resolve) => { uploadMock.get201CreationFile(); - const uploadPromiseOne: any = uploadApi.uploadFile(file, null, null, null); + const uploadPromiseOne: any = uploadApi.uploadFile(file); uploadPromiseOne.catch(() => {}); uploadPromiseOne.once('success', () => { successOneOk = true; @@ -241,7 +239,7 @@ describe('Upload', () => { const promiseSuccessTwo = new Promise((resolve) => { uploadMock.get201CreationFile(); - const uploadPromiseTwo: any = uploadApi.uploadFile(fileTwo, null, null, null); + const uploadPromiseTwo: any = uploadApi.uploadFile(fileTwo); uploadPromiseTwo.catch(() => {}); uploadPromiseTwo.once('success', () => { successTwoOk = true; @@ -265,13 +263,13 @@ describe('Upload', () => { uploadMock.get201CreationFile(); - const p1 = uploadApi.uploadFile(file, null, null, null).then(() => { + const p1 = uploadApi.uploadFile(file).then(() => { resolveOneOk = true; }); uploadMock.get201CreationFile(); - const p2 = uploadApi.uploadFile(fileTwo, null, null, null).then(() => { + const p2 = uploadApi.uploadFile(fileTwo).then(() => { resolveTwoOk = true; }); @@ -291,13 +289,13 @@ describe('Upload', () => { uploadMock.get409CreationFileNewNameClashes(); - const p1 = uploadApi.uploadFile(file, null, null, null).then(null, () => { + const p1 = uploadApi.uploadFile(file).then(null, () => { rejectOneOk = true; }); uploadMock.get409CreationFileNewNameClashes(); - const p2 = uploadApi.uploadFile(fileTwo, null, null, null).then(null, () => { + const p2 = uploadApi.uploadFile(fileTwo).then(null, () => { rejectTwoOk = true; }); @@ -316,7 +314,7 @@ describe('Upload', () => { let promiseProgressOne = {}; let promiseProgressTwo = {}; - const uploadPromise: any = uploadApi.uploadFile(file, null, null, null); + const uploadPromise: any = uploadApi.uploadFile(file); uploadPromise.catch(() => {}); uploadPromise.once('error', () => {