Skip to content

Commit

Permalink
fix: eslint issues (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
shazron authored Jul 12, 2023
1 parent f058b03 commit b484c25
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 69 deletions.
5 changes: 5 additions & 0 deletions e2e/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"node/no-unpublished-require": 0
}
}
13 changes: 8 additions & 5 deletions e2e/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,22 @@ test('test event received in journalling endpoint', async () => {
})

test('delete webhook registration', async () => {
await sdkClient.deleteRegistration(consumerOrgId, projectId, workspaceId, journalReg.registration_id)
await expect(sdkClient.deleteRegistration(consumerOrgId, projectId, workspaceId, journalReg.registration_id))
.resolves.not.toThrow()
journalReg = undefined
})

test('delete event metadata', async () => {
await sdkClient.deleteAllEventMetadata(consumerOrgId, projectId,
workspaceId, providerId)
await expect(sdkClient.deleteAllEventMetadata(consumerOrgId, projectId,
workspaceId, providerId))
.resolves.not.toThrow()
eventMetadata = undefined
})

test('delete provider', async () => {
await sdkClient.deleteProvider(consumerOrgId, projectId, workspaceId,
providerId)
await expect(sdkClient.deleteProvider(consumerOrgId, projectId, workspaceId,
providerId))
.resolves.not.toThrow()
provider = undefined
})

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"main": "src/index.js",
"scripts": {
"test": "npm run lint && npm run unit-tests",
"lint": "eslint src test",
"lint": "eslint src test e2e",
"unit-tests": "jest --config test/jest.config.js --maxWorkers=2",
"e2e": "jest --config e2e/jest.config.js",
"typings": "jsdoc -t node_modules/tsd-jsdoc/dist -r src/index.js -d .",
Expand Down
2 changes: 1 addition & 1 deletion src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function isBase64Encoded (eventPayload) {
*/
function genErrorResponse (statusCode, message) {
const response = {
statusCode: statusCode,
statusCode,
body: message,
headers: {
'Content-Type': 'application/json'
Expand Down
46 changes: 23 additions & 23 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class EventsCoreAPI {
const url = this.__getUrl(`/events/${consumerOrgId}/providers`)
let urlWithQueryParams = helpers.appendQueryParams(url, filterOptions)
urlWithQueryParams = helpers.appendQueryParams(urlWithQueryParams, { eventmetadata: providerOptions.fetchEventMetadata })
const sdkDetails = { requestOptions: requestOptions, url: urlWithQueryParams }
const sdkDetails = { requestOptions, url: urlWithQueryParams }
return this.__handleRequest(sdkDetails, codes.ERROR_GET_ALL_PROVIDERS)
}

Expand All @@ -155,7 +155,7 @@ class EventsCoreAPI {
const requestOptions = this.__createRequest('GET', headers)
const url = this.__getUrl(`/events/providers/${providerId}`)
const urlWithQueryParams = helpers.appendQueryParams(url, { eventmetadata: fetchEventMetadata })
const sdkDetails = { requestOptions: requestOptions, url: urlWithQueryParams }
const sdkDetails = { requestOptions, url: urlWithQueryParams }
return this.__handleRequest(sdkDetails, codes.ERROR_GET_PROVIDER)
}

Expand All @@ -179,7 +179,7 @@ class EventsCoreAPI {
const requestOptions = this.__createRequest('POST', headers,
JSON.stringify(body))
const url = this.__getUrl(`/events/${consumerOrgId}/${projectId}/${workspaceId}/providers`)
const sdkDetails = { requestOptions: requestOptions, url: url }
const sdkDetails = { requestOptions, url }
return this.__handleRequest(sdkDetails, codes.ERROR_CREATE_PROVIDER)
}

Expand All @@ -198,7 +198,7 @@ class EventsCoreAPI {
const requestOptions = this.__createRequest('PUT', headers,
JSON.stringify(body))
const url = this.__getUrl(`/events/${consumerOrgId}/${projectId}/${workspaceId}/providers/${providerId}`)
const sdkDetails = { requestOptions: requestOptions, url: url }
const sdkDetails = { requestOptions, url }
return this.__handleRequest(sdkDetails, codes.ERROR_UPDATE_PROVIDER)
}

Expand All @@ -215,7 +215,7 @@ class EventsCoreAPI {
const headers = {}
const requestOptions = this.__createRequest('DELETE', headers)
const url = this.__getUrl(`/events/${consumerOrgId}/${projectId}/${workspaceId}/providers/${providerId}`)
const sdkDetails = { requestOptions: requestOptions, url: url }
const sdkDetails = { requestOptions, url }
return this.__handleRequest(sdkDetails, codes.ERROR_DELETE_PROVIDER)
}

Expand All @@ -232,7 +232,7 @@ class EventsCoreAPI {
const headers = {}
const requestOptions = this.__createRequest('GET', headers)
const url = this.__getUrl('/events/providermetadata')
const sdkDetails = { requestOptions: requestOptions, url: url }
const sdkDetails = { requestOptions, url }
return this.__handleRequest(sdkDetails, codes.ERROR_GET_ALL_PROVIDER_METADATA)
}

Expand All @@ -252,7 +252,7 @@ class EventsCoreAPI {
const headers = {}
const requestOptions = this.__createRequest('GET', headers)
const url = this.__getUrl(`/events/providers/${providerId}/eventmetadata`)
const sdkDetails = { requestOptions: requestOptions, url: url }
const sdkDetails = { requestOptions, url }
return this.__handleRequest(sdkDetails, codes.ERROR_GET_ALL_EVENTMETADATA)
}

Expand All @@ -267,7 +267,7 @@ class EventsCoreAPI {
const headers = {}
const requestOptions = this.__createRequest('GET', headers)
const url = this.__getUrl(`/events/providers/${providerId}/eventmetadata/${eventCode}`)
const sdkDetails = { requestOptions: requestOptions, url: url }
const sdkDetails = { requestOptions, url }
return this.__handleRequest(sdkDetails, codes.ERROR_GET_EVENTMETADATA)
}

Expand All @@ -292,7 +292,7 @@ class EventsCoreAPI {
const headers = {}
const requestOptions = this.__createRequest('POST', headers, JSON.stringify(body))
const url = this.__getUrl(`/events/${consumerOrgId}/${projectId}/${workspaceId}/providers/${providerId}/eventmetadata`)
const sdkDetails = { requestOptions: requestOptions, url: url }
const sdkDetails = { requestOptions, url }
return this.__handleRequest(sdkDetails, codes.ERROR_CREATE_EVENTMETADATA)
}

Expand All @@ -311,7 +311,7 @@ class EventsCoreAPI {
const headers = {}
const requestOptions = this.__createRequest('PUT', headers, JSON.stringify(body))
const url = this.__getUrl(`/events/${consumerOrgId}/${projectId}/${workspaceId}/providers/${providerId}/eventmetadata/${eventCode}`)
const sdkDetails = { requestOptions: requestOptions, url: url }
const sdkDetails = { requestOptions, url }
return this.__handleRequest(sdkDetails, codes.ERROR_UPDATE_EVENTMETADATA)
}

Expand All @@ -329,7 +329,7 @@ class EventsCoreAPI {
const headers = {}
const requestOptions = this.__createRequest('DELETE', headers)
const url = this.__getUrl(`/events/${consumerOrgId}/${projectId}/${workspaceId}/providers/${providerId}/eventmetadata/${eventCode}`)
const sdkDetails = { requestOptions: requestOptions, url: url }
const sdkDetails = { requestOptions, url }
return this.__handleRequest(sdkDetails, codes.ERROR_DELETE_EVENTMETADATA)
}

Expand All @@ -346,7 +346,7 @@ class EventsCoreAPI {
const headers = {}
const requestOptions = this.__createRequest('DELETE', headers)
const url = this.__getUrl(`/events/${consumerOrgId}/${projectId}/${workspaceId}/providers/${providerId}/eventmetadata`)
const sdkDetails = { requestOptions: requestOptions, url: url }
const sdkDetails = { requestOptions, url }
return this.__handleRequest(sdkDetails, codes.ERROR_DELETE_ALL_EVENTMETADATA)
}

Expand Down Expand Up @@ -384,7 +384,7 @@ class EventsCoreAPI {
const headers = {}
const requestOptions = this.__createRequest('POST', headers, JSON.stringify(body))
const url = this.__getUrl(`/events/${consumerOrgId}/${projectId}/${workspaceId}/registrations`)
const sdkDetails = { requestOptions: requestOptions, url: url }
const sdkDetails = { requestOptions, url }
return this.__handleRequest(sdkDetails, codes.ERROR_CREATE_REGISTRATION)
}

Expand All @@ -411,7 +411,7 @@ class EventsCoreAPI {
const headers = {}
const requestOptions = this.__createRequest('PUT', headers, JSON.stringify(body))
const url = this.__getUrl(`/events/${consumerOrgId}/${projectId}/${workspaceId}/registrations/${registrationId}`)
const sdkDetails = { requestOptions: requestOptions, url: url }
const sdkDetails = { requestOptions, url }
return this.__handleRequest(sdkDetails, codes.ERROR_UPDATE_REGISTRATION)
}

Expand All @@ -428,7 +428,7 @@ class EventsCoreAPI {
const headers = {}
const requestOptions = this.__createRequest('GET', headers)
const url = this.__getUrl(`/events/${consumerOrgId}/${projectId}/${workspaceId}/registrations/${registrationId}`)
const sdkDetails = { requestOptions: requestOptions, url: url }
const sdkDetails = { requestOptions, url }
return this.__handleRequest(sdkDetails, codes.ERROR_GET_REGISTRATION)
}

Expand All @@ -444,7 +444,7 @@ class EventsCoreAPI {
const headers = {}
const requestOptions = this.__createRequest('GET', headers)
const url = this.__getUrl(`/events/${consumerOrgId}/${projectId}/${workspaceId}/registrations`)
const sdkDetails = { requestOptions: requestOptions, url: url }
const sdkDetails = { requestOptions, url }
return this.__handleRequest(sdkDetails, codes.ERROR_GET_ALL_REGISTRATION)
}

Expand All @@ -465,7 +465,7 @@ class EventsCoreAPI {
const requestOptions = this.__createRequest('GET', headers)
const url = this.__getUrl(`/events/${consumerOrgId}/registrations`)
const urlWithQueryParams = helpers.appendQueryParams(url, page)
const sdkDetails = { requestOptions: requestOptions, url: urlWithQueryParams }
const sdkDetails = { requestOptions, url: urlWithQueryParams }
return this.__handleRequest(sdkDetails, codes.ERROR_GET_ALL_REGISTRATIONS_FOR_ORG)
}

Expand All @@ -482,7 +482,7 @@ class EventsCoreAPI {
const headers = {}
const requestOptions = this.__createRequest('DELETE', headers)
const url = this.__getUrl(`/events/${consumerOrgId}/${projectId}/${workspaceId}/registrations/${registrationId}`)
const sdkDetails = { requestOptions: requestOptions, url: url }
const sdkDetails = { requestOptions, url }
return this.__handleRequest(sdkDetails, codes.ERROR_DELETE_REGISTRATION)
}

Expand All @@ -508,7 +508,7 @@ class EventsCoreAPI {
const requestOptions = this.__createRequest('POST', headers, JSON.stringify(cloudEvent))
const retries = (this.httpOptions && this.httpOptions.retries) || 0
const url = this.httpOptions.eventsIngressURL
const sdkDetails = { requestOptions: requestOptions, url: url }
const sdkDetails = { requestOptions, url }
return new Promise((resolve, reject) => {
fetchRetryClient.exponentialBackoff(url, requestOptions, { maxRetries: retries, initialDelayInMillis: 1000 }, this.__getRetryOn(retries))
.then((response) => {
Expand Down Expand Up @@ -549,7 +549,7 @@ class EventsCoreAPI {
const url = helpers.appendQueryParams(journalUrl, eventsJournalOptions)
const headers = {}
const requestOptions = this.__createRequest('GET', headers)
const sdkDetails = { requestOptions: requestOptions, url: url }
const sdkDetails = { requestOptions, url }
const retries = (this.httpOptions && this.httpOptions.retries) || 0
const response = await fetchRetryClient.exponentialBackoff(url, requestOptions, { maxRetries: retries, initialDelayInMillis: 1000 }, this.__getRetryOn(retries))
if ((response.status === 200) || (response.status === 204)) {
Expand Down Expand Up @@ -694,9 +694,9 @@ class EventsCoreAPI {
*/
__createRequest (method, headers, body) {
return {
method: method,
method,
headers: this.__setHeaders(headers),
body: body,
body,
timeout: this.httpOptions && this.httpOptions.timeout
}
}
Expand Down Expand Up @@ -748,5 +748,5 @@ class EventsCoreAPI {
}

module.exports = {
init: init
init
}
78 changes: 39 additions & 39 deletions test/mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -874,46 +874,46 @@ const testPubKeys = {
}

const data = {
providerResponse: providerResponse,
providerWithEventMetadataResponse: providerWithEventMetadataResponse,
getAllProvidersResponse: getAllProvidersResponse,
getAllProvidersWithEventMetadataResponse: getAllProvidersWithEventMetadataResponse,
createProvider: createProvider,
createProviderBadRequest: createProviderBadRequest,
updateProvider: updateProvider,
updateProviderBadRequest: updateProviderBadRequest,
updateProviderResponse: updateProviderResponse,
getProviderMetadataForOrg: getProviderMetadataForOrg,
getAllEventMetadataResponse: getAllEventMetadataResponse,
getEventMetadataResponse: getEventMetadataResponse,
createEventMetadataForProvider: createEventMetadataForProvider,
createEventMetadataForProviderResponse: createEventMetadataForProviderResponse,
createEventMetadataBadRequest: createEventMetadataBadRequest,
createRegistration: createRegistration,
createRegistrationResponse: createRegistrationResponse,
createRegistrationBadRequest: createRegistrationBadRequest,
updateRegistrationResponse: updateRegistrationResponse,
updateRegistration: updateRegistration,
getAllRegistrationsForOrgResponse: getAllRegistrationsForOrgResponse,
getAllRegistrationsResponse: getAllRegistrationsResponse,
cloudEvent: cloudEvent,
cloudEventEmptyPayload: cloudEventEmptyPayload,
journalResponseBody: journalResponseBody,
journalResponseHeader200: journalResponseHeader200,
journalResponseHeader204: journalResponseHeader204,
journalResponseHeader204MissingLinks: journalResponseHeader204MissingLinks,
journalResponseHeader204DateTime: journalResponseHeader204DateTime,
journalPollerResponse: journalPollerResponse,
journalPollerNoContentResponse: journalPollerNoContentResponse,
journalPollerNoContentMissingRetryAfter: journalPollerNoContentMissingRetryAfter,
signatureOptions: signatureOptions,
testEvent: testEvent,
testEncodedPayload: testEncodedPayload,
testEncodedInvalidPayload: testEncodedInvalidPayload,
testClientId: testClientId,
testPubKeys: testPubKeys
providerResponse,
providerWithEventMetadataResponse,
getAllProvidersResponse,
getAllProvidersWithEventMetadataResponse,
createProvider,
createProviderBadRequest,
updateProvider,
updateProviderBadRequest,
updateProviderResponse,
getProviderMetadataForOrg,
getAllEventMetadataResponse,
getEventMetadataResponse,
createEventMetadataForProvider,
createEventMetadataForProviderResponse,
createEventMetadataBadRequest,
createRegistration,
createRegistrationResponse,
createRegistrationBadRequest,
updateRegistrationResponse,
updateRegistration,
getAllRegistrationsForOrgResponse,
getAllRegistrationsResponse,
cloudEvent,
cloudEventEmptyPayload,
journalResponseBody,
journalResponseHeader200,
journalResponseHeader204,
journalResponseHeader204MissingLinks,
journalResponseHeader204DateTime,
journalPollerResponse,
journalPollerNoContentResponse,
journalPollerNoContentMissingRetryAfter,
signatureOptions,
testEvent,
testEncodedPayload,
testEncodedInvalidPayload,
testClientId,
testPubKeys
}

module.exports = {
data: data
data
}

0 comments on commit b484c25

Please sign in to comment.