diff --git a/app/lib/zeebe-api/zeebe-api.js b/app/lib/zeebe-api/zeebe-api.js index ad20aa7555..52e2de9fd3 100644 --- a/app/lib/zeebe-api/zeebe-api.js +++ b/app/lib/zeebe-api/zeebe-api.js @@ -22,7 +22,7 @@ const { reduce } = require('min-dash'); -const errorReasons = { +const ERROR_REASONS = { UNKNOWN: 'UNKNOWN', CONTACT_POINT_UNAVAILABLE: 'CONTACT_POINT_UNAVAILABLE', UNAUTHORIZED: 'UNAUTHORIZED', @@ -34,20 +34,20 @@ const errorReasons = { INVALID_CREDENTIALS: 'INVALID_CREDENTIALS' }; -const endpointTypes = { +const ENDPOINT_TYPES = { SELF_HOSTED: 'selfHosted', OAUTH: 'oauth', CAMUNDA_CLOUD: 'camundaCloud' }; -const resourceTypes = { +const RESOURCE_TYPES = { BPMN: 'bpmn', DMN: 'dmn', FORM: 'form' }; /** - * @typedef {object} ZeebeClientParameters + * @typedef {Object} ZeebeClientParameters * @property {Endpoint} endpoint */ @@ -56,13 +56,13 @@ const resourceTypes = { */ /** - * @typedef {object} SelfHostedNoAuthEndpoint + * @typedef {Object} SelfHostedNoAuthEndpoint * @property {'selfHosted'} type * @property {string} url */ /** - * @typedef {object} SelfHostedOAuthEndpoint + * @typedef {Object} SelfHostedOAuthEndpoint * @property {'oauth'} type * @property {string} url * @property {string} audience @@ -71,7 +71,7 @@ const resourceTypes = { */ /** - * @typedef {object} CamundaCloudEndpoint + * @typedef {Object} CamundaCloudEndpoint * @property {'camundaCloud'} type * @property {string} clusterId * @property {string} clientId @@ -80,7 +80,7 @@ const resourceTypes = { */ /** - * @typedef {object} TopologyResponse + * @typedef {Object} TopologyResponse * @property {'brokers'} type * @property {number} clusterSize * @property {number} partitionsCount @@ -104,7 +104,8 @@ class ZeebeAPI { * Check connection with given broker/cluster. * * @param {ZeebeClientParameters} parameters - * @returns {{ success: boolean, reason?: string }} + * + * @return {{ success: boolean, reason?: string }} */ async checkConnection(parameters) { @@ -138,7 +139,8 @@ class ZeebeAPI { * Deploy Process. * * @param {ZeebeClientParameters & { name: string, filePath: string }} parameters - * @returns {Promise<{ success: boolean, response: object }>} + * + * @return {Promise<{ success: boolean, response: object }>} */ async deploy(parameters) { @@ -187,7 +189,8 @@ class ZeebeAPI { * Run process instance. * * @param {ZeebeClientParameters & { endpoint: object, processId: string, variables: object }} parameters - * @returns {{ success: boolean, response: object }} + * + * @return {{ success: boolean, response: object }} */ async run(parameters) { @@ -233,7 +236,8 @@ class ZeebeAPI { * Get gateway version of given broker/cluster endpoint. * * @param {ZeebeClientParameters} parameters - * @returns {{ success: boolean, response?: object, response?.gatewayVersion: string }} + * + * @return {{ success: boolean, response?: object, response?.gatewayVersion: string }} */ async getGatewayVersion(parameters) { @@ -309,11 +313,11 @@ class ZeebeAPI { retry: false }; - if (!values(endpointTypes).includes(type)) { + if (!values(ENDPOINT_TYPES).includes(type)) { return; } - if (type === endpointTypes.OAUTH) { + if (type === ENDPOINT_TYPES.OAUTH) { options = { ...options, oAuth: { @@ -324,7 +328,7 @@ class ZeebeAPI { cacheOnDisk: false } }; - } else if (type === endpointTypes.CAMUNDA_CLOUD) { + } else if (type === ENDPOINT_TYPES.CAMUNDA_CLOUD) { options = { ...options, camundaCloud: { @@ -463,7 +467,8 @@ class ZeebeAPI { * @param {string} name * @param {string} filePath * @param {'bpmn'|'dmn'|'form'} [fileType='bpmn'] - * @returns {`${string}.${'bpmn'|'dmn'|'form'}`} + * + * @return {`${string}.${'bpmn'|'dmn'|'form'}`} */ _prepareDeploymentName(name, filePath, fileType = 'bpmn') { @@ -490,10 +495,11 @@ class ZeebeAPI { module.exports = ZeebeAPI; -// helpers ////////////////////// +// helpers ////////// /** * @param {string} message + * * @return {number|undefined} */ function getErrorCode(message) { @@ -520,46 +526,46 @@ function getErrorReason(error, endpoint) { // (1) handle grpc errors if (code === 14 || code === 13) { - return type === endpointTypes.CAMUNDA_CLOUD - ? errorReasons.CLUSTER_UNAVAILABLE - : errorReasons.CONTACT_POINT_UNAVAILABLE; + return type === ENDPOINT_TYPES.CAMUNDA_CLOUD + ? ERROR_REASONS.CLUSTER_UNAVAILABLE + : ERROR_REASONS.CONTACT_POINT_UNAVAILABLE; } else if (code === 12) { - return errorReasons.UNSUPPORTED_ENGINE; + return ERROR_REASONS.UNSUPPORTED_ENGINE; } // (2) handle if (!message) { - return errorReasons.UNKNOWN; + return ERROR_REASONS.UNKNOWN; } // (3) handle if (message.includes('ENOTFOUND') || message.includes('Not Found')) { - if (type === endpointTypes.OAUTH) { - return errorReasons.OAUTH_URL; - } else if (type === endpointTypes.CAMUNDA_CLOUD) { - return errorReasons.INVALID_CLIENT_ID; + if (type === ENDPOINT_TYPES.OAUTH) { + return ERROR_REASONS.OAUTH_URL; + } else if (type === ENDPOINT_TYPES.CAMUNDA_CLOUD) { + return ERROR_REASONS.INVALID_CLIENT_ID; } - return errorReasons.CONTACT_POINT_UNAVAILABLE; + return ERROR_REASONS.CONTACT_POINT_UNAVAILABLE; } // (4) handle other error messages if (message.includes('Unauthorized')) { - return (type === endpointTypes.CAMUNDA_CLOUD - ? errorReasons.INVALID_CREDENTIALS - : errorReasons.UNAUTHORIZED + return (type === ENDPOINT_TYPES.CAMUNDA_CLOUD + ? ERROR_REASONS.INVALID_CREDENTIALS + : ERROR_REASONS.UNAUTHORIZED ); } if (message.includes('Forbidden')) { - return errorReasons.FORBIDDEN; + return ERROR_REASONS.FORBIDDEN; } - if (message.includes('Unsupported protocol') && type === endpointTypes.OAUTH) { - return errorReasons.OAUTH_URL; + if (message.includes('Unsupported protocol') && type === ENDPOINT_TYPES.OAUTH) { + return ERROR_REASONS.OAUTH_URL; } - return errorReasons.UNKNOWN; + return ERROR_REASONS.UNKNOWN; } function isHashEqual(parameter1, parameter2) { @@ -628,11 +634,11 @@ function getResource(parameters, contents, resourceName) { name: resourceName }; - if (resourceType === resourceTypes.BPMN) { + if (resourceType === RESOURCE_TYPES.BPMN) { resource.process = contents; - } else if (resourceType === resourceTypes.DMN) { + } else if (resourceType === RESOURCE_TYPES.DMN) { resource.decision = contents; - } else if (resourceType === resourceTypes.FORM) { + } else if (resourceType === RESOURCE_TYPES.FORM) { resource.form = contents; } diff --git a/app/test/spec/zeebe-api/zeebe-api-spec.js b/app/test/spec/zeebe-api/zeebe-api-spec.js index 79627d6228..7757a63ad7 100644 --- a/app/test/spec/zeebe-api/zeebe-api-spec.js +++ b/app/test/spec/zeebe-api/zeebe-api-spec.js @@ -46,7 +46,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: 'https://google.com' } }; @@ -74,7 +74,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: 'https://google.com' } }; @@ -104,7 +104,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: TEST_URL } }; @@ -131,7 +131,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'camundaCloud' + type: ENDPOINT_TYPES.CAMUNDA_CLOUD } }; @@ -157,7 +157,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'camundaCloud' + type: ENDPOINT_TYPES.CAMUNDA_CLOUD } }; @@ -183,7 +183,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: TEST_URL } }; @@ -210,7 +210,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: TEST_URL } }; @@ -237,7 +237,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: TEST_URL } }; @@ -264,7 +264,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'oauth', + type: ENDPOINT_TYPES.OAUTH, url: TEST_URL } }; @@ -291,7 +291,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'camundaCloud' + type: ENDPOINT_TYPES.CAMUNDA_CLOUD } }; @@ -317,7 +317,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: TEST_URL } }; @@ -344,7 +344,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'camundaCloud' + type: ENDPOINT_TYPES.CAMUNDA_CLOUD } }; @@ -370,7 +370,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'camundaCloud' + type: ENDPOINT_TYPES.CAMUNDA_CLOUD } }; @@ -396,7 +396,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'oauth', + type: ENDPOINT_TYPES.OAUTH, url: TEST_URL } }; @@ -423,7 +423,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'oauth', + type: ENDPOINT_TYPES.OAUTH, url: TEST_URL } }; @@ -450,7 +450,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'oauth', + type: ENDPOINT_TYPES.OAUTH, url: TEST_URL } }; @@ -477,7 +477,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: TEST_URL } }; @@ -504,7 +504,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: TEST_URL } }; @@ -533,7 +533,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: TEST_URL } }; @@ -564,7 +564,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: TEST_URL } }; @@ -589,7 +589,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: TEST_URL } }; @@ -620,7 +620,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: TEST_URL } }; @@ -652,7 +652,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: TEST_URL } }; @@ -678,7 +678,7 @@ describe('ZeebeAPI', function() { const parameters = { filePath: 'filePath', endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: TEST_URL } }; @@ -828,7 +828,7 @@ describe('ZeebeAPI', function() { filePath: 'filePath', name: 'not_suffixed', endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: TEST_URL } }); @@ -858,7 +858,7 @@ describe('ZeebeAPI', function() { filePath: 'filePath', name: 'not_suffixed', endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: TEST_URL }, resourceType: 'dmn' @@ -889,7 +889,7 @@ describe('ZeebeAPI', function() { filePath: 'filePath', name: 'not_suffixed', endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: TEST_URL }, resourceType: 'form' @@ -920,7 +920,7 @@ describe('ZeebeAPI', function() { filePath: 'filePath', name: 'suffixed.bpmn', endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: TEST_URL } }); @@ -950,7 +950,7 @@ describe('ZeebeAPI', function() { filePath: 'filePath', name: 'suffixed.dmn', endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: TEST_URL }, resourceType: 'dmn' @@ -981,7 +981,7 @@ describe('ZeebeAPI', function() { filePath: 'filePath', name: 'suffixed.form', endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: TEST_URL }, resourceType: 'form' @@ -1012,7 +1012,7 @@ describe('ZeebeAPI', function() { filePath: '/Users/Test/Stuff/Zeebe/process.bpmn', name: '', endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: TEST_URL } }); @@ -1042,7 +1042,7 @@ describe('ZeebeAPI', function() { filePath: '/Users/Test/Stuff/Zeebe/xmlFile.xml', name: '', endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: TEST_URL } }); @@ -1072,7 +1072,7 @@ describe('ZeebeAPI', function() { filePath: '/Users/Test/Stuff/Zeebe/xmlFile.xml', name: 'orchestrae-location-check-bpmn', endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: TEST_URL } }); @@ -1102,7 +1102,7 @@ describe('ZeebeAPI', function() { filePath: '/Users/Test/Stuff/Zeebe/xmlFile.xml', name: '', endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: TEST_URL }, resourceType: 'dmn' @@ -1133,7 +1133,7 @@ describe('ZeebeAPI', function() { filePath: '/Users/Test/Stuff/Zeebe/xmlFile.xml', name: 'orchestrae-location-check-dmn', endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: TEST_URL }, resourceType: 'dmn' @@ -1164,7 +1164,7 @@ describe('ZeebeAPI', function() { filePath: '/Users/Test/Stuff/Zeebe/jsonFile.json', name: '', endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: TEST_URL }, resourceType: 'form' @@ -1195,7 +1195,7 @@ describe('ZeebeAPI', function() { filePath: '/Users/Test/Stuff/Zeebe/jsonFile.json', name: 'application-form', endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: TEST_URL }, resourceType: 'form' @@ -1270,7 +1270,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: 'https://google.com' } }; @@ -1300,7 +1300,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: 'https://google.com' } }; @@ -1329,7 +1329,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: 'https://google.com' } }; @@ -1360,7 +1360,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: TEST_URL } }; @@ -1387,7 +1387,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'camundaCloud' + type: ENDPOINT_TYPES.CAMUNDA_CLOUD } }; @@ -1413,7 +1413,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'camundaCloud' + type: ENDPOINT_TYPES.CAMUNDA_CLOUD } }; @@ -1439,7 +1439,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: TEST_URL } }; @@ -1466,7 +1466,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'oauth', + type: ENDPOINT_TYPES.OAUTH, url: TEST_URL } }; @@ -1493,7 +1493,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'camundaCloud' + type: ENDPOINT_TYPES.CAMUNDA_CLOUD } }; @@ -1519,7 +1519,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: TEST_URL } }; @@ -1546,7 +1546,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'camundaCloud' + type: ENDPOINT_TYPES.CAMUNDA_CLOUD } }; @@ -1572,7 +1572,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'camundaCloud' + type: ENDPOINT_TYPES.CAMUNDA_CLOUD } }; @@ -1598,7 +1598,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'oauth', + type: ENDPOINT_TYPES.OAUTH, url: TEST_URL } }; @@ -1625,7 +1625,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'oauth', + type: ENDPOINT_TYPES.OAUTH, url: TEST_URL } }; @@ -1652,7 +1652,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'oauth', + type: ENDPOINT_TYPES.OAUTH, url: TEST_URL } }; @@ -1687,7 +1687,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: 'https://camunda.com' } }; @@ -1734,7 +1734,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: TEST_URL } }; @@ -1763,7 +1763,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: TEST_URL } }; @@ -1774,7 +1774,7 @@ describe('ZeebeAPI', function() { await zeebeAPI.deploy({ ...parameters, endpoint: { - type: 'oauth', + type: ENDPOINT_TYPES.OAUTH, url: TEST_URL } }); @@ -1799,7 +1799,7 @@ describe('ZeebeAPI', function() { }); const parameters = { endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: TEST_URL } }; @@ -1810,7 +1810,7 @@ describe('ZeebeAPI', function() { await zeebeAPI.deploy({ ...parameters, endpoint: { - type: 'oauth', + type: ENDPOINT_TYPES.OAUTH, url: TEST_URL } }); @@ -1837,7 +1837,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: 'https://camunda.com' } }; @@ -1867,7 +1867,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: 'http://camunda.com' } }; @@ -1897,7 +1897,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'oauth', + type: ENDPOINT_TYPES.OAUTH, url: 'http://camunda.com' } }; @@ -1927,7 +1927,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'camundaCloud', + type: ENDPOINT_TYPES.CAMUNDA_CLOUD, url: 'camunda.com' } }; @@ -1957,7 +1957,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: 'http://camunda.com:1337' } }; @@ -1987,7 +1987,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: 'http://camunda.com' } }; @@ -2017,7 +2017,7 @@ describe('ZeebeAPI', function() { const parameters = { endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: 'https://camunda.com' } }; @@ -2083,7 +2083,7 @@ describe('ZeebeAPI', function() { const parameters = { filePath: '/path/to/file.bpmn', endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: 'https://camunda.com' } }; @@ -2112,7 +2112,7 @@ describe('ZeebeAPI', function() { const parameters = { filePath: '/path/to/file.bpmn', endpoint: { - type: 'oauth', + type: ENDPOINT_TYPES.OAUTH, url: 'https://camunda.com' } }; @@ -2141,7 +2141,7 @@ describe('ZeebeAPI', function() { const parameters = { filePath: '/path/to/file.bpmn', endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: 'https://camunda.com' } }; @@ -2170,7 +2170,7 @@ describe('ZeebeAPI', function() { const parameters = { filePath: '/path/to/file.bpmn', endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: 'https://camunda.com' } }; @@ -2198,7 +2198,7 @@ describe('ZeebeAPI', function() { const parameters = { filePath: '/path/to/file.bpmn', endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: 'https://camunda.com' } }; @@ -2223,7 +2223,7 @@ describe('ZeebeAPI', function() { const parameters = { filePath: '/path/to/file.bpmn', endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: 'https://camunda.com' } }; @@ -2247,7 +2247,7 @@ describe('ZeebeAPI', function() { const parameters = { filePath: '/path/to/file.bpmn', endpoint: { - type: 'selfHosted', + type: ENDPOINT_TYPES.SELF_HOSTED, url: 'https://camunda.com' } }; diff --git a/client/src/remote/ZeebeAPI.js b/client/src/remote/ZeebeAPI.js index bc9dee58e8..55816599db 100644 --- a/client/src/remote/ZeebeAPI.js +++ b/client/src/remote/ZeebeAPI.js @@ -8,12 +8,12 @@ * except in compliance with the MIT License. */ -export const authTypes = { +export const AUTH_TYPES = { NONE: 'none', OAUTH: 'oauth', }; -export const targetTypes = { +export const ENDPOINT_TYPES = { SELF_HOSTED: 'selfHosted', CAMUNDA_CLOUD: 'camundaCloud' }; @@ -65,7 +65,6 @@ export default class ZeebeAPI { return this.backend.send('zeebe:getGatewayVersion', { endpoint: configuration }); } - } @@ -87,18 +86,18 @@ function getEndpointConfiguration(endpoint) { camundaCloudClusterRegion } = endpoint; - if (targetType === targetTypes.SELF_HOSTED) { + if (targetType === ENDPOINT_TYPES.SELF_HOSTED) { switch (authType) { - case authTypes.NONE: + case AUTH_TYPES.NONE: return { - type: targetTypes.SELF_HOSTED, + type: ENDPOINT_TYPES.SELF_HOSTED, url: contactPoint }; - case authTypes.OAUTH: + case AUTH_TYPES.OAUTH: return { - type: authTypes.OAUTH, + type: AUTH_TYPES.OAUTH, url: contactPoint, oauthURL, audience, @@ -108,9 +107,9 @@ function getEndpointConfiguration(endpoint) { } } - if (targetType === targetTypes.CAMUNDA_CLOUD) { + if (targetType === ENDPOINT_TYPES.CAMUNDA_CLOUD) { return { - type: targetTypes.CAMUNDA_CLOUD, + type: ENDPOINT_TYPES.CAMUNDA_CLOUD, clientId: camundaCloudClientId, clientSecret: camundaCloudClientSecret, clusterId: camundaCloudClusterId, diff --git a/client/src/remote/__tests__/ZeebeAPISpec.js b/client/src/remote/__tests__/ZeebeAPISpec.js index 490ef3d80b..dd7c54f32d 100644 --- a/client/src/remote/__tests__/ZeebeAPISpec.js +++ b/client/src/remote/__tests__/ZeebeAPISpec.js @@ -13,8 +13,8 @@ import ZeebeAPI from '../ZeebeAPI'; import { - targetTypes, - authTypes + AUTH_TYPES, + ENDPOINT_TYPES } from '../ZeebeAPI'; @@ -41,8 +41,8 @@ describe('', function() { const contactPoint = 'contactPoint'; const endpoint = { - targetType: targetTypes.SELF_HOSTED, - authType: authTypes.NONE, + targetType: ENDPOINT_TYPES.SELF_HOSTED, + authType: AUTH_TYPES.NONE, contactPoint }; @@ -52,7 +52,7 @@ describe('', function() { // then expect(sendSpy).to.have.been.calledWith('zeebe:checkConnection', { endpoint: { - type: targetTypes.SELF_HOSTED, + type: ENDPOINT_TYPES.SELF_HOSTED, url: contactPoint } }); @@ -64,8 +64,8 @@ describe('', function() { // given const zeebeAPI = new ZeebeAPI(backend); - const targetType = targetTypes.SELF_HOSTED; - const authType = authTypes.OAUTH; + const targetType = ENDPOINT_TYPES.SELF_HOSTED; + const authType = AUTH_TYPES.OAUTH; const contactPoint = 'contactPoint'; const oauthURL = 'oauthURL'; const audience = 'audience'; @@ -103,7 +103,7 @@ describe('', function() { // given const zeebeAPI = new ZeebeAPI(backend); - const targetType = targetTypes.CAMUNDA_CLOUD; + const targetType = ENDPOINT_TYPES.CAMUNDA_CLOUD; const camundaCloudClientId = 'camundaCloudClientId'; const camundaCloudClientSecret = 'camundaCloudClientSecret'; const camundaCloudClusterId = 'camundaCloudClusterId'; @@ -120,7 +120,7 @@ describe('', function() { // then expect(sendSpy).to.have.been.calledWith('zeebe:checkConnection', { endpoint: { - type: targetTypes.CAMUNDA_CLOUD, + type: ENDPOINT_TYPES.CAMUNDA_CLOUD, clientId: camundaCloudClientId, clientSecret: camundaCloudClientSecret, clusterId: camundaCloudClusterId @@ -144,8 +144,8 @@ describe('', function() { const processId = 'processId'; const endpoint = { - targetType: targetTypes.SELF_HOSTED, - authType: authTypes.NONE, + targetType: ENDPOINT_TYPES.SELF_HOSTED, + authType: AUTH_TYPES.NONE, contactPoint }; @@ -159,7 +159,7 @@ describe('', function() { expect(sendSpy).to.have.been.calledWith('zeebe:run', { processId, endpoint: { - type: targetTypes.SELF_HOSTED, + type: ENDPOINT_TYPES.SELF_HOSTED, url: contactPoint } }); @@ -183,8 +183,8 @@ describe('', function() { const name = 'deployment'; const endpoint = { - targetType: targetTypes.SELF_HOSTED, - authType: authTypes.NONE, + targetType: ENDPOINT_TYPES.SELF_HOSTED, + authType: AUTH_TYPES.NONE, contactPoint }; @@ -200,7 +200,7 @@ describe('', function() { filePath, name, endpoint: { - type: targetTypes.SELF_HOSTED, + type: ENDPOINT_TYPES.SELF_HOSTED, url: contactPoint } }); @@ -222,8 +222,8 @@ describe('', function() { const tenantId = 'tenant-1'; const endpoint = { - targetType: targetTypes.SELF_HOSTED, - authType: authTypes.OAUTH, + targetType: ENDPOINT_TYPES.SELF_HOSTED, + authType: AUTH_TYPES.OAUTH, contactPoint, oauthURL: 'oauthURL', audience: 'audience', @@ -245,7 +245,7 @@ describe('', function() { name, tenantId, endpoint: { - type: authTypes.OAUTH, + type: AUTH_TYPES.OAUTH, url: contactPoint, oauthURL: 'oauthURL', audience: 'audience', @@ -269,8 +269,8 @@ describe('', function() { const contactPoint = 'contactPoint'; const endpoint = { - targetType: targetTypes.SELF_HOSTED, - authType: authTypes.NONE, + targetType: ENDPOINT_TYPES.SELF_HOSTED, + authType: AUTH_TYPES.NONE, contactPoint }; @@ -280,7 +280,7 @@ describe('', function() { // then expect(sendSpy).to.have.been.calledWith('zeebe:getGatewayVersion', { endpoint: { - type: targetTypes.SELF_HOSTED, + type: ENDPOINT_TYPES.SELF_HOSTED, url: contactPoint } });