@adobe/aio-lib-events
Advanced tools
Comparing version 2.0.2 to 3.0.0
@@ -37,3 +37,2 @@ /* | ||
const projectId = process.env.EVENTS_PROJECT_ID | ||
const integrationId = process.env.EVENTS_INTEGRATION_ID | ||
const httpOptions = { retries: 3 } | ||
@@ -81,22 +80,21 @@ const randomNumber = Math.round(Math.random() * 100000) | ||
// create journal registration | ||
journalReg = await sdkClient.createWebhookRegistration(consumerOrgId, | ||
integrationId, { | ||
name: 'Test Events SDK ' + randomNumber, | ||
description: 'Test Events SDK ' + randomNumber, | ||
client_id: apiKey, | ||
delivery_type: 'JOURNAL', | ||
events_of_interest: [ | ||
{ | ||
event_code: eventCode, | ||
provider_id: providerId | ||
} | ||
] | ||
}) | ||
expect(journalReg.status).toBe('VERIFIED') | ||
expect(journalReg.integration_status).toBe('ENABLED') | ||
journalReg = await sdkClient.createRegistration(consumerOrgId, projectId, workspaceId, { | ||
name: 'Test Events SDK ' + randomNumber, | ||
description: 'Test Events SDK ' + randomNumber, | ||
client_id: apiKey, | ||
delivery_type: 'journal', | ||
events_of_interest: [ | ||
{ | ||
event_code: eventCode, | ||
provider_id: providerId | ||
} | ||
] | ||
}) | ||
expect(journalReg.webhook_status).toBe('verified') | ||
expect(journalReg.enabled).toBe(true) | ||
}) | ||
test('test fetch journalling position', async () => { | ||
const journallingUrl = journalReg.events_url | ||
logger.info('Journal endpoint has been registered') | ||
const journallingUrl = journalReg._links['rel:events'].href | ||
logger.info('Journal endpoint ' + journallingUrl + ' has been registered') | ||
@@ -129,3 +127,3 @@ // sleep for one min | ||
test('test event received in journalling endpoint', async () => { | ||
var count = 0 | ||
let count = 0 | ||
let nextLink = journalling.link.next | ||
@@ -147,4 +145,3 @@ // retry to fetch from journalling 3 times ( 30 seconds ) | ||
test('delete webhook registration', async () => { | ||
await sdkClient.deleteWebhookRegistration(consumerOrgId, | ||
integrationId, journalReg.registration_id) | ||
await sdkClient.deleteRegistration(consumerOrgId, projectId, workspaceId, journalReg.registration_id) | ||
journalReg = undefined | ||
@@ -168,3 +165,3 @@ }) | ||
if (journalReg) { | ||
await sdkClient.deleteWebhookRegistration(consumerOrgId, integrationId, | ||
await sdkClient.deleteRegistration(consumerOrgId, projectId, workspaceId, | ||
journalReg.registration_id) | ||
@@ -171,0 +168,0 @@ } |
{ | ||
"name": "@adobe/aio-lib-events", | ||
"version": "2.0.2", | ||
"version": "3.0.0", | ||
"description": "Adobe I/O Events", | ||
@@ -17,3 +17,4 @@ "repository": { | ||
"typings": "jsdoc -t node_modules/tsd-jsdoc/dist -r src/index.js -d .", | ||
"generate-docs": "jsdoc2md -t ./docs/readme_template.md ./src/index.js > README.md" | ||
"generate-docs": "npm run typings && npm run jsdoc", | ||
"jsdoc": "jsdoc2md -t ./docs/readme_template.md ./src/index.js > README.md" | ||
}, | ||
@@ -52,3 +53,3 @@ "dependencies": { | ||
"jsdoc": "^3.6.7", | ||
"jsdoc-to-markdown": "^5.0.3", | ||
"jsdoc-to-markdown": "^7.1.1", | ||
"openapi-schema-validator": "^3.0.3", | ||
@@ -55,0 +56,0 @@ "querystring": "^0.2.0", |
172
README.md
@@ -17,2 +17,3 @@ <!-- | ||
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) | ||
[![Greenkeeper badge](https://badges.greenkeeper.io/adobe/aio-lib-events.svg)](https://greenkeeper.io/) | ||
[![Codecov Coverage](https://img.shields.io/codecov/c/github/adobe/aio-lib-events/master.svg?style=flat-square)](https://codecov.io/gh/adobe/aio-lib-events/) | ||
@@ -112,2 +113,14 @@ | ||
<dd></dd> | ||
<dt><a href="#ProviderInputModel">ProviderInputModel</a> : <code>object</code></dt> | ||
<dd></dd> | ||
<dt><a href="#EventMetadataInputModel">EventMetadataInputModel</a> : <code>object</code></dt> | ||
<dd></dd> | ||
<dt><a href="#EventsOfInterest">EventsOfInterest</a> : <code>object</code></dt> | ||
<dd></dd> | ||
<dt><a href="#RegistrationCreateModel">RegistrationCreateModel</a> : <code>object</code></dt> | ||
<dd></dd> | ||
<dt><a href="#RegistrationUpdateModel">RegistrationUpdateModel</a> : <code>object</code></dt> | ||
<dd></dd> | ||
<dt><a href="#Page">Page</a> : <code>object</code></dt> | ||
<dd></dd> | ||
<dt><a href="#EventsJournalOptions">EventsJournalOptions</a> : <code>object</code></dt> | ||
@@ -148,6 +161,8 @@ <dd></dd> | ||
* [.deleteAllEventMetadata(consumerOrgId, projectId, workspaceId, providerId)](#EventsCoreAPI+deleteAllEventMetadata) ⇒ <code>Promise.<object></code> | ||
* [.createWebhookRegistration(consumerOrgId, integrationId, body)](#EventsCoreAPI+createWebhookRegistration) ⇒ <code>Promise.<object></code> | ||
* [.getWebhookRegistration(consumerOrgId, integrationId, registrationId)](#EventsCoreAPI+getWebhookRegistration) ⇒ <code>Promise.<object></code> | ||
* [.getAllWebhookRegistrations(consumerOrgId, integrationId)](#EventsCoreAPI+getAllWebhookRegistrations) ⇒ <code>Promise.<object></code> | ||
* [.deleteWebhookRegistration(consumerOrgId, integrationId, registrationId)](#EventsCoreAPI+deleteWebhookRegistration) ⇒ <code>Promise.<object></code> | ||
* [.createRegistration(consumerOrgId, projectId, workspaceId, body)](#EventsCoreAPI+createRegistration) ⇒ <code>Promise.<object></code> | ||
* [.updateRegistration(consumerOrgId, projectId, workspaceId, registrationId, body)](#EventsCoreAPI+updateRegistration) ⇒ <code>Promise.<object></code> | ||
* [.getRegistration(consumerOrgId, projectId, workspaceId, registrationId)](#EventsCoreAPI+getRegistration) ⇒ <code>Promise.<object></code> | ||
* [.getAllRegistrationsForWorkspace(consumerOrgId, projectId, workspaceId)](#EventsCoreAPI+getAllRegistrationsForWorkspace) ⇒ <code>Promise.<object></code> | ||
* [.getAllRegistrationsForOrg(consumerOrgId, [page])](#EventsCoreAPI+getAllRegistrationsForOrg) ⇒ <code>Promise.<object></code> | ||
* [.deleteRegistration(consumerOrgId, projectId, workspaceId, registrationId)](#EventsCoreAPI+deleteRegistration) ⇒ <code>Promise.<object></code> | ||
* [.publishEvent(cloudEvent)](#EventsCoreAPI+publishEvent) ⇒ <code>Promise.<string></code> | ||
@@ -235,3 +250,3 @@ * [.getEventsFromJournal(journalUrl, [eventsJournalOptions], [fetchResponseHeaders])](#EventsCoreAPI+getEventsFromJournal) ⇒ <code>Promise.<object></code> | ||
| workspaceId | <code>string</code> | Workspace Id from the console | | ||
| body | <code>object</code> | Json data that describes the provider | | ||
| body | [<code>ProviderInputModel</code>](#ProviderInputModel) | Json data that describes the provider | | ||
@@ -252,3 +267,3 @@ <a name="EventsCoreAPI+updateProvider"></a> | ||
| providerId | <code>string</code> | The id that uniquely identifies the provider to be updated | | ||
| body | <code>object</code> | Json data that describes the provider | | ||
| body | [<code>ProviderInputModel</code>](#ProviderInputModel) | Json data that describes the provider | | ||
@@ -309,3 +324,3 @@ <a name="EventsCoreAPI+deleteProvider"></a> | ||
| providerId | <code>string</code> | provider for which the event metadata is to be added | | ||
| body | <code>object</code> | Json data that describes the event metadata | | ||
| body | [<code>EventMetadataInputModel</code>](#EventMetadataInputModel) | Json data that describes the event metadata | | ||
@@ -327,3 +342,3 @@ <a name="EventsCoreAPI+updateEventMetadataForProvider"></a> | ||
| eventCode | <code>string</code> | eventCode of the event metadata to be updated | | ||
| body | <code>object</code> | Json data that describes the event metadata | | ||
| body | [<code>EventMetadataInputModel</code>](#EventMetadataInputModel) | Json data that describes the event metadata | | ||
@@ -361,5 +376,5 @@ <a name="EventsCoreAPI+deleteEventMetadata"></a> | ||
<a name="EventsCoreAPI+createWebhookRegistration"></a> | ||
<a name="EventsCoreAPI+createRegistration"></a> | ||
### eventsCoreAPI.createWebhookRegistration(consumerOrgId, integrationId, body) ⇒ <code>Promise.<object></code> | ||
### eventsCoreAPI.createRegistration(consumerOrgId, projectId, workspaceId, body) ⇒ <code>Promise.<object></code> | ||
Create a webhook or journal registration | ||
@@ -373,8 +388,25 @@ | ||
| consumerOrgId | <code>string</code> | Consumer Org Id from the console | | ||
| integrationId | <code>string</code> | integration Id from the console | | ||
| body | <code>object</code> | Json data contains details of the registration | | ||
| projectId | <code>string</code> | Project Id from the console | | ||
| workspaceId | <code>string</code> | Workspace Id from the console | | ||
| body | [<code>RegistrationCreateModel</code>](#RegistrationCreateModel) | Json data contains details of the registration | | ||
<a name="EventsCoreAPI+getWebhookRegistration"></a> | ||
<a name="EventsCoreAPI+updateRegistration"></a> | ||
### eventsCoreAPI.getWebhookRegistration(consumerOrgId, integrationId, registrationId) ⇒ <code>Promise.<object></code> | ||
### eventsCoreAPI.updateRegistration(consumerOrgId, projectId, workspaceId, registrationId, body) ⇒ <code>Promise.<object></code> | ||
Update a webhook or journal registration | ||
**Kind**: instance method of [<code>EventsCoreAPI</code>](#EventsCoreAPI) | ||
**Returns**: <code>Promise.<object></code> - Details of the webhook/journal registration to be updated | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| consumerOrgId | <code>string</code> | Consumer Org Id from the console | | ||
| projectId | <code>string</code> | Project Id from the console | | ||
| workspaceId | <code>string</code> | Workspace Id from the console | | ||
| registrationId | <code>string</code> | Registration id whose details are to be fetched | | ||
| body | [<code>RegistrationUpdateModel</code>](#RegistrationUpdateModel) | Json data contains details of the registration | | ||
<a name="EventsCoreAPI+getRegistration"></a> | ||
### eventsCoreAPI.getRegistration(consumerOrgId, projectId, workspaceId, registrationId) ⇒ <code>Promise.<object></code> | ||
Get registration details for a given registration | ||
@@ -388,9 +420,10 @@ | ||
| consumerOrgId | <code>string</code> | Consumer Org Id from the console | | ||
| integrationId | <code>string</code> | Integration Id from the console | | ||
| projectId | <code>string</code> | Project Id from the console | | ||
| workspaceId | <code>string</code> | Workspace Id from the console | | ||
| registrationId | <code>string</code> | Registration id whose details are to be fetched | | ||
<a name="EventsCoreAPI+getAllWebhookRegistrations"></a> | ||
<a name="EventsCoreAPI+getAllRegistrationsForWorkspace"></a> | ||
### eventsCoreAPI.getAllWebhookRegistrations(consumerOrgId, integrationId) ⇒ <code>Promise.<object></code> | ||
Get all registration details for a given integration | ||
### eventsCoreAPI.getAllRegistrationsForWorkspace(consumerOrgId, projectId, workspaceId) ⇒ <code>Promise.<object></code> | ||
Get all registration details for a workspace | ||
@@ -403,7 +436,21 @@ **Kind**: instance method of [<code>EventsCoreAPI</code>](#EventsCoreAPI) | ||
| consumerOrgId | <code>string</code> | Consumer Org Id from the console | | ||
| integrationId | <code>string</code> | Integration Id from the console | | ||
| projectId | <code>string</code> | Project Id from the console | | ||
| workspaceId | <code>string</code> | Workspace Id from the console | | ||
<a name="EventsCoreAPI+deleteWebhookRegistration"></a> | ||
<a name="EventsCoreAPI+getAllRegistrationsForOrg"></a> | ||
### eventsCoreAPI.deleteWebhookRegistration(consumerOrgId, integrationId, registrationId) ⇒ <code>Promise.<object></code> | ||
### eventsCoreAPI.getAllRegistrationsForOrg(consumerOrgId, [page]) ⇒ <code>Promise.<object></code> | ||
Get all registration details for an org | ||
**Kind**: instance method of [<code>EventsCoreAPI</code>](#EventsCoreAPI) | ||
**Returns**: <code>Promise.<object></code> - Paginated response of all webhook/journal registrations for an org | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| consumerOrgId | <code>string</code> | Consumer Org Id from the console | | ||
| [page] | [<code>Page</code>](#Page) | page size and page number | | ||
<a name="EventsCoreAPI+deleteRegistration"></a> | ||
### eventsCoreAPI.deleteRegistration(consumerOrgId, projectId, workspaceId, registrationId) ⇒ <code>Promise.<object></code> | ||
Delete webhook registration | ||
@@ -417,3 +464,4 @@ | ||
| consumerOrgId | <code>string</code> | Consumer Org Id from the console | | ||
| integrationId | <code>string</code> | Integration Id from the console | | ||
| projectId | <code>string</code> | Project Id from the console | | ||
| workspaceId | <code>string</code> | Workspace Id from the console | | ||
| registrationId | <code>string</code> | Id of the registration to be deleted | | ||
@@ -426,3 +474,3 @@ | ||
Event publishers can publish events to the Adobe I/O Events using this SDK. The events should follow Cloud Events 1.0 specification: https://github.com/cloudevents/spec/blob/v1.0/spec.md. | ||
Event publishers can publish events to the Adobe I/O Events using this SDK. The events should follow Cloud Events 1.0 specification: https://github.com/cloudevents/spec/blob/v1.0/spec.md. | ||
As of now, only application/json is accepted as the content-type for the "data" field of the cloud event. | ||
@@ -512,2 +560,80 @@ If retries are set, publish events are retried on network issues, 5xx and 429 error response codes. | ||
<a name="ProviderInputModel"></a> | ||
## ProviderInputModel : <code>object</code> | ||
**Kind**: global typedef | ||
**Properties** | ||
| Name | Type | Description | | ||
| --- | --- | --- | | ||
| label | <code>string</code> | The label of this Events Provider | | ||
| [description] | <code>string</code> | The description of this Events Provider | | ||
| [docs_url] | <code>string</code> | The documentation url of this Events Provider | | ||
<a name="EventMetadataInputModel"></a> | ||
## EventMetadataInputModel : <code>object</code> | ||
**Kind**: global typedef | ||
**Properties** | ||
| Name | Type | Description | | ||
| --- | --- | --- | | ||
| label | <code>string</code> | The description of this Event Metadata | | ||
| description | <code>string</code> | The label of this Event Metadata | | ||
| event_code | <code>string</code> | The event_code of this Event Metadata. This event_code describes the type of event. Ideally it should be prefixed with a reverse-DNS name (dictating the organization which defines the semantics of this event type) It is equivalent to the CloudEvents' type. See https://github.com/cloudevents/spec/blob/master/spec.md#type | | ||
| [sample_event_template] | <code>string</code> | An optional base64 encoded sample event template | | ||
<a name="EventsOfInterest"></a> | ||
## EventsOfInterest : <code>object</code> | ||
**Kind**: global typedef | ||
**Properties** | ||
| Name | Type | Description | | ||
| --- | --- | --- | | ||
| provider_id | <code>string</code> | The id of the provider of the events to be subscribed | | ||
| event_code | <code>string</code> | The requested valid event code belonging to the provider | | ||
<a name="RegistrationCreateModel"></a> | ||
## RegistrationCreateModel : <code>object</code> | ||
**Kind**: global typedef | ||
**Properties** | ||
| Name | Type | Description | | ||
| --- | --- | --- | | ||
| client_id | <code>string</code> | Client id for which the registration is created | | ||
| name | <code>string</code> | The name of the registration | | ||
| description | <code>string</code> | The description of the registration | | ||
| [webhook_url] | <code>string</code> | A valid webhook url where the events would be delivered for webhook or webhook_batch delivery_type | | ||
| events_of_interest | [<code>Array.<EventsOfInterest></code>](#EventsOfInterest) | The events for which the registration is to be subscribed to | | ||
| delivery_type | <code>string</code> | Delivery type can either be webhook, webhook_batch or journal. | | ||
| [enabled] | <code>string</code> | Enable or disable the registration. Default true. | | ||
<a name="RegistrationUpdateModel"></a> | ||
## RegistrationUpdateModel : <code>object</code> | ||
**Kind**: global typedef | ||
**Properties** | ||
| Name | Type | Description | | ||
| --- | --- | --- | | ||
| name | <code>string</code> | The name of the registration | | ||
| description | <code>string</code> | The description of the registration | | ||
| [webhook_url] | <code>string</code> | A valid webhook url where the events would be delivered for webhook or webhook_batch delivery_type | | ||
| events_of_interest | [<code>Array.<EventsOfInterest></code>](#EventsOfInterest) | The events for which the registration is to be subscribed to | | ||
| delivery_type | <code>string</code> | Delivery type can either be webhook, webhook_batch or journal. | | ||
| [enabled] | <code>string</code> | Enable or disable the registration. Default true. | | ||
<a name="Page"></a> | ||
## Page : <code>object</code> | ||
**Kind**: global typedef | ||
**Properties** | ||
| Name | Type | Description | | ||
| --- | --- | --- | | ||
| [page] | <code>number</code> | page number to be fetched. Default 0 (optional) | | ||
| [size] | <code>number</code> | size of each page. Default 10 (optional) | | ||
<a name="EventsJournalOptions"></a> | ||
@@ -514,0 +640,0 @@ |
150
src/index.js
@@ -125,3 +125,3 @@ /* | ||
const sdkDetails = { requestOptions: requestOptions, url: url } | ||
return this.__handleRequest(url, requestOptions, sdkDetails, codes.ERROR_GET_ALL_PROVIDERS) | ||
return this.__handleRequest(sdkDetails, codes.ERROR_GET_ALL_PROVIDERS) | ||
} | ||
@@ -141,6 +141,12 @@ | ||
const sdkDetails = { requestOptions: requestOptions, url: url } | ||
return this.__handleRequest(url, requestOptions, sdkDetails, codes.ERROR_GET_PROVIDER) | ||
return this.__handleRequest(sdkDetails, codes.ERROR_GET_PROVIDER) | ||
} | ||
/** | ||
* @typedef {object} ProviderInputModel | ||
* @property {string} label The label of this Events Provider | ||
* @property {string} [description] The description of this Events Provider | ||
* @property {string} [docs_url] The documentation url of this Events Provider | ||
*/ | ||
/** | ||
* Create a new provider given the provider details | ||
@@ -151,3 +157,3 @@ * | ||
* @param {string} workspaceId Workspace Id from the console | ||
* @param {object} body Json data that describes the provider | ||
* @param {ProviderInputModel} body Json data that describes the provider | ||
* @returns {Promise<object>} Returns the details of the provider created | ||
@@ -161,3 +167,3 @@ */ | ||
const sdkDetails = { requestOptions: requestOptions, url: url } | ||
return this.__handleRequest(url, requestOptions, sdkDetails, codes.ERROR_CREATE_PROVIDER) | ||
return this.__handleRequest(sdkDetails, codes.ERROR_CREATE_PROVIDER) | ||
} | ||
@@ -172,3 +178,3 @@ | ||
* @param {string} providerId The id that uniquely identifies the provider to be updated | ||
* @param {object} body Json data that describes the provider | ||
* @param {ProviderInputModel} body Json data that describes the provider | ||
* @returns {Promise<object>} Returns the details of the provider updated | ||
@@ -182,3 +188,3 @@ */ | ||
const sdkDetails = { requestOptions: requestOptions, url: url } | ||
return this.__handleRequest(url, requestOptions, sdkDetails, codes.ERROR_UPDATE_PROVIDER) | ||
return this.__handleRequest(sdkDetails, codes.ERROR_UPDATE_PROVIDER) | ||
} | ||
@@ -200,3 +206,3 @@ | ||
const sdkDetails = { requestOptions: requestOptions, url: url } | ||
return this.__handleRequest(url, requestOptions, sdkDetails, codes.ERROR_DELETE_PROVIDER) | ||
return this.__handleRequest(sdkDetails, codes.ERROR_DELETE_PROVIDER) | ||
} | ||
@@ -221,3 +227,3 @@ | ||
const sdkDetails = { requestOptions: requestOptions, url: url } | ||
return this.__handleRequest(url, requestOptions, sdkDetails, codes.ERROR_GET_ALL_EVENTMETADATA) | ||
return this.__handleRequest(sdkDetails, codes.ERROR_GET_ALL_EVENTMETADATA) | ||
} | ||
@@ -237,6 +243,13 @@ | ||
const sdkDetails = { requestOptions: requestOptions, url: url } | ||
return this.__handleRequest(url, requestOptions, sdkDetails, codes.ERROR_GET_EVENTMETADATA) | ||
return this.__handleRequest(sdkDetails, codes.ERROR_GET_EVENTMETADATA) | ||
} | ||
/** | ||
* @typedef {object} EventMetadataInputModel | ||
* @property {string} label The description of this Event Metadata | ||
* @property {string} description The label of this Event Metadata | ||
* @property {string} event_code The event_code of this Event Metadata. This event_code describes the type of event. Ideally it should be prefixed with a reverse-DNS name (dictating the organization which defines the semantics of this event type) It is equivalent to the CloudEvents' type. See https://github.com/cloudevents/spec/blob/master/spec.md#type | ||
* @property {string} [sample_event_template] An optional base64 encoded sample event template | ||
*/ | ||
/** | ||
* Create an event metadata for a provider | ||
@@ -248,3 +261,3 @@ * | ||
* @param {string} providerId provider for which the event metadata is to be added | ||
* @param {object} body Json data that describes the event metadata | ||
* @param {EventMetadataInputModel} body Json data that describes the event metadata | ||
* @returns {Promise<object>} Details of the event metadata created | ||
@@ -257,3 +270,3 @@ */ | ||
const sdkDetails = { requestOptions: requestOptions, url: url } | ||
return this.__handleRequest(url, requestOptions, sdkDetails, codes.ERROR_CREATE_EVENTMETADATA) | ||
return this.__handleRequest(sdkDetails, codes.ERROR_CREATE_EVENTMETADATA) | ||
} | ||
@@ -269,3 +282,3 @@ | ||
* @param {string} eventCode eventCode of the event metadata to be updated | ||
* @param {object} body Json data that describes the event metadata | ||
* @param {EventMetadataInputModel} body Json data that describes the event metadata | ||
* @returns {Promise<object>} Details of the event metadata updated | ||
@@ -278,3 +291,3 @@ */ | ||
const sdkDetails = { requestOptions: requestOptions, url: url } | ||
return this.__handleRequest(url, requestOptions, sdkDetails, codes.ERROR_UPDATE_EVENTMETADATA) | ||
return this.__handleRequest(sdkDetails, codes.ERROR_UPDATE_EVENTMETADATA) | ||
} | ||
@@ -297,3 +310,3 @@ | ||
const sdkDetails = { requestOptions: requestOptions, url: url } | ||
return this.__handleRequest(url, requestOptions, sdkDetails, codes.ERROR_DELETE_EVENTMETADATA) | ||
return this.__handleRequest(sdkDetails, codes.ERROR_DELETE_EVENTMETADATA) | ||
} | ||
@@ -315,3 +328,3 @@ | ||
const sdkDetails = { requestOptions: requestOptions, url: url } | ||
return this.__handleRequest(url, requestOptions, sdkDetails, codes.ERROR_DELETE_ALL_EVENTMETADATA) | ||
return this.__handleRequest(sdkDetails, codes.ERROR_DELETE_ALL_EVENTMETADATA) | ||
} | ||
@@ -326,62 +339,129 @@ | ||
/** | ||
* @typedef {object} EventsOfInterest | ||
* @property {string} provider_id The id of the provider of the events to be subscribed | ||
* @property {string} event_code The requested valid event code belonging to the provider | ||
*/ | ||
/** | ||
* @typedef {object} RegistrationCreateModel | ||
* @property {string} client_id Client id for which the registration is created | ||
* @property {string} name The name of the registration | ||
* @property {string} description The description of the registration | ||
* @property {string} [webhook_url] A valid webhook url where the events would be delivered for webhook or webhook_batch delivery_type | ||
* @property {Array.<EventsOfInterest>} events_of_interest The events for which the registration is to be subscribed to | ||
* @property {string} delivery_type Delivery type can either be webhook|webhook_batch|journal. | ||
* @property {string} [enabled] Enable or disable the registration. Default true. | ||
*/ | ||
/** | ||
* Create a webhook or journal registration | ||
* | ||
* @param {string} consumerOrgId Consumer Org Id from the console | ||
* @param {string} integrationId integration Id from the console | ||
* @param {object} body Json data contains details of the registration | ||
* @param {string} projectId Project Id from the console | ||
* @param {string} workspaceId Workspace Id from the console | ||
* @param {RegistrationCreateModel} body Json data contains details of the registration | ||
* @returns {Promise<object>} Details of the webhook/journal registration created | ||
*/ | ||
createWebhookRegistration (consumerOrgId, integrationId, body) { | ||
createRegistration (consumerOrgId, projectId, workspaceId, body) { | ||
const headers = {} | ||
const requestOptions = this.__createRequest('POST', headers, JSON.stringify(body)) | ||
const url = this.__getUrl(`/events/organizations/${consumerOrgId}/integrations/${integrationId}/registrations`) | ||
const url = this.__getUrl(`/events/${consumerOrgId}/${projectId}/${workspaceId}/registrations`) | ||
const sdkDetails = { requestOptions: requestOptions, url: url } | ||
return this.__handleRequest(url, requestOptions, sdkDetails, codes.ERROR_CREATE_REGISTRATION) | ||
return this.__handleRequest(sdkDetails, codes.ERROR_CREATE_REGISTRATION) | ||
} | ||
/** | ||
* @typedef {object} RegistrationUpdateModel | ||
* @property {string} name The name of the registration | ||
* @property {string} description The description of the registration | ||
* @property {string} [webhook_url] A valid webhook url where the events would be delivered for webhook or webhook_batch delivery_type | ||
* @property {Array.<EventsOfInterest>} events_of_interest The events for which the registration is to be subscribed to | ||
* @property {string} delivery_type Delivery type can either be webhook|webhook_batch|journal. | ||
* @property {string} [enabled] Enable or disable the registration. Default true. | ||
*/ | ||
/** | ||
* Update a webhook or journal registration | ||
* | ||
* @param {string} consumerOrgId Consumer Org Id from the console | ||
* @param {string} projectId Project Id from the console | ||
* @param {string} workspaceId Workspace Id from the console | ||
* @param {string} registrationId Registration id whose details are to be fetched | ||
* @param {RegistrationUpdateModel} body Json data contains details of the registration | ||
* @returns {Promise<object>} Details of the webhook/journal registration to be updated | ||
*/ | ||
updateRegistration (consumerOrgId, projectId, workspaceId, registrationId, body) { | ||
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 } | ||
return this.__handleRequest(sdkDetails, codes.ERROR_UPDATE_REGISTRATION) | ||
} | ||
/** | ||
* Get registration details for a given registration | ||
* | ||
* @param {string} consumerOrgId Consumer Org Id from the console | ||
* @param {string} integrationId Integration Id from the console | ||
* @param {string} projectId Project Id from the console | ||
* @param {string} workspaceId Workspace Id from the console | ||
* @param {string} registrationId Registration id whose details are to be fetched | ||
* @returns {Promise<object>} Details of the webhook/journal registration | ||
*/ | ||
getWebhookRegistration (consumerOrgId, integrationId, registrationId) { | ||
getRegistration (consumerOrgId, projectId, workspaceId, registrationId) { | ||
const headers = {} | ||
const requestOptions = this.__createRequest('GET', headers) | ||
const url = this.__getUrl(`/events/organizations/${consumerOrgId}/integrations/${integrationId}/registrations/${registrationId}`) | ||
const url = this.__getUrl(`/events/${consumerOrgId}/${projectId}/${workspaceId}/registrations/${registrationId}`) | ||
const sdkDetails = { requestOptions: requestOptions, url: url } | ||
return this.__handleRequest(url, requestOptions, sdkDetails, codes.ERROR_GET_REGISTRATION) | ||
return this.__handleRequest(sdkDetails, codes.ERROR_GET_REGISTRATION) | ||
} | ||
/** | ||
* Get all registration details for a given integration | ||
* Get all registration details for a workspace | ||
* | ||
* @param {string} consumerOrgId Consumer Org Id from the console | ||
* @param {string} integrationId Integration Id from the console | ||
* @param {string} projectId Project Id from the console | ||
* @param {string} workspaceId Workspace Id from the console | ||
* @returns {Promise<object>} List of all webhook/journal registrations | ||
*/ | ||
getAllWebhookRegistrations (consumerOrgId, integrationId) { | ||
getAllRegistrationsForWorkspace (consumerOrgId, projectId, workspaceId) { | ||
const headers = {} | ||
const requestOptions = this.__createRequest('GET', headers) | ||
const url = this.__getUrl(`/events/organizations/${consumerOrgId}/integrations/${integrationId}/registrations`) | ||
const url = this.__getUrl(`/events/${consumerOrgId}/${projectId}/${workspaceId}/registrations`) | ||
const sdkDetails = { requestOptions: requestOptions, url: url } | ||
return this.__handleRequest(url, requestOptions, sdkDetails, codes.ERROR_GET_ALL_REGISTRATION) | ||
return this.__handleRequest(sdkDetails, codes.ERROR_GET_ALL_REGISTRATION) | ||
} | ||
/** | ||
* @typedef {object} Page | ||
* @property {number} [page] page number to be fetched. Default 0 (optional) | ||
* @property {number} [size] size of each page. Default 10 (optional) | ||
*/ | ||
/** | ||
* Get all registration details for an org | ||
* | ||
* @param {string} consumerOrgId Consumer Org Id from the console | ||
* @param {Page} [page] page size and page number | ||
* @returns {Promise<object>} Paginated response of all webhook/journal registrations for an org | ||
*/ | ||
getAllRegistrationsForOrg (consumerOrgId, page) { | ||
const headers = {} | ||
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 } | ||
return this.__handleRequest(sdkDetails, codes.ERROR_GET_ALL_REGISTRATIONS_FOR_ORG) | ||
} | ||
/** | ||
* Delete webhook registration | ||
* | ||
* @param {string} consumerOrgId Consumer Org Id from the console | ||
* @param {string} integrationId Integration Id from the console | ||
* @param {string} projectId Project Id from the console | ||
* @param {string} workspaceId Workspace Id from the console | ||
* @param {string} registrationId Id of the registration to be deleted | ||
* @returns {Promise<object>} Empty object if deletion was successful | ||
*/ | ||
deleteWebhookRegistration (consumerOrgId, integrationId, registrationId) { | ||
deleteRegistration (consumerOrgId, projectId, workspaceId, registrationId) { | ||
const headers = {} | ||
const requestOptions = this.__createRequest('DELETE', headers) | ||
const url = this.__getUrl(`/events/organizations/${consumerOrgId}/integrations/${integrationId}/registrations/${registrationId}`) | ||
const url = this.__getUrl(`/events/${consumerOrgId}/${projectId}/${workspaceId}/registrations/${registrationId}`) | ||
const sdkDetails = { requestOptions: requestOptions, url: url } | ||
return this.__handleRequest(url, requestOptions, sdkDetails, codes.ERROR_DELETE_REGISTRATION) | ||
return this.__handleRequest(sdkDetails, codes.ERROR_DELETE_REGISTRATION) | ||
} | ||
@@ -566,5 +646,5 @@ | ||
*/ | ||
__handleRequest (url, requestOptions, sdkDetails, ErrorCode) { | ||
__handleRequest (sdkDetails, ErrorCode) { | ||
return new Promise((resolve, reject) => { | ||
fetchRetryClient.exponentialBackoff(url, requestOptions, { maxRetries: (this.httpOptions && this.httpOptions.retries) || 0, initialDelayInMillis: 1000 }) | ||
fetchRetryClient.exponentialBackoff(sdkDetails.url, sdkDetails.requestOptions, { maxRetries: (this.httpOptions && this.httpOptions.retries) || 0, initialDelayInMillis: 1000 }) | ||
.then((response) => { | ||
@@ -571,0 +651,0 @@ if (!response.ok) { |
@@ -60,6 +60,8 @@ /* | ||
E('ERROR_CREATE_REGISTRATION', '%s') | ||
E('ERROR_UPDATE_REGISTRATION', '%s') | ||
E('ERROR_GET_REGISTRATION', '%s') | ||
E('ERROR_GET_ALL_REGISTRATION', '%s') | ||
E('ERROR_GET_ALL_REGISTRATIONS_FOR_ORG', '%s') | ||
E('ERROR_DELETE_REGISTRATION', '%s') | ||
E('ERROR_GET_JOURNAL_DATA', '%s') | ||
E('ERROR_PUBLISH_EVENT', '%s') |
@@ -47,4 +47,4 @@ /* | ||
const journalUrl = 'http://journal-url/events/organizations/orgId/integrations/integId/regId' | ||
const EVENTS_BASE_URL = 'fakebaseurl' | ||
const EVENTS_INGRESS_URL = 'fakeingressurl' | ||
const EVENTS_BASE_URL = 'https://api.adobe.io/events' | ||
const EVENTS_INGRESS_URL = 'https://eventsingress.adobe.io' | ||
@@ -127,3 +127,3 @@ // ///////////////////////////////////////////// | ||
exponentialBackoffMockReturnValue(mock.data.getAllProvidersResponse, { status: 200, statusText: 'OK' }) | ||
const res = await sdkClient.getAllProviders('consumerOrgId') | ||
const res = await sdkClient.getAllProviders('consumerId') | ||
expect(res._embedded.providers.length).toBe(2) | ||
@@ -136,3 +136,3 @@ expect(res._embedded.providers[0].id).toBe('test-id-1') | ||
exponentialBackoffMockReturnValue({}, { status: 404, statusText: 'Not Found' }) | ||
await checkErrorResponse(api, new errorSDK.codes.ERROR_GET_ALL_PROVIDERS(), ['consumerOrgId1']) | ||
await checkErrorResponse(api, new errorSDK.codes.ERROR_GET_ALL_PROVIDERS(), ['consumerId1']) | ||
}) | ||
@@ -177,3 +177,3 @@ }) | ||
{ status: 200, statusText: 'OK' }) | ||
const res = await sdkClient.createProvider('consumerOrgId', 'projectId', | ||
const res = await sdkClient.createProvider('consumerId', 'projectId', | ||
'workspaceId', mock.data.createProvider) | ||
@@ -186,3 +186,3 @@ expect(res.id).toBe('test-id') | ||
await checkErrorResponse(api, new errorSDK.codes.ERROR_CREATE_PROVIDER(), | ||
['consumerOrgId', 'projectId', 'workspaceId', mock.data.createProviderBadRequest]) | ||
['consumerId', 'projectId', 'workspaceId', mock.data.createProviderBadRequest]) | ||
}) | ||
@@ -196,3 +196,3 @@ }) | ||
{ status: 200, statusText: 'OK' }) | ||
const res = await sdkClient.updateProvider('consumerOrgId', 'projectId', | ||
const res = await sdkClient.updateProvider('consumerId', 'projectId', | ||
'workspaceId', 'test-id', mock.data.updateProvider) | ||
@@ -206,3 +206,3 @@ expect(res.id).toBe('test-id') | ||
checkErrorResponse(api, new errorSDK.codes.ERROR_UPDATE_PROVIDER(), | ||
['consumerOrgId', 'projectId', 'workspaceId', 'test-id', | ||
['consumerId', 'projectId', 'workspaceId', 'test-id', | ||
mock.data.updateProviderBadRequest]) | ||
@@ -216,3 +216,3 @@ }) | ||
exponentialBackoffMockReturnValue(undefined, { status: 204, statusText: 'No Content' }) | ||
const res = await sdkClient.deleteProvider('consumerOrgId', 'projectId', | ||
const res = await sdkClient.deleteProvider('consumerId', 'projectId', | ||
'workspaceId', 'test-id') | ||
@@ -225,3 +225,3 @@ expect(res).toBe(undefined) | ||
checkErrorResponse(api, new errorSDK.codes.ERROR_DELETE_PROVIDER(), | ||
['consumerOrgId', 'projectId', 'workspaceId', 'test-id1']) | ||
['consumerId', 'projectId', 'workspaceId', 'test-id1']) | ||
}) | ||
@@ -273,3 +273,3 @@ }) | ||
{ status: 200, statusText: 'OK' }) | ||
const res = await sdkClient.createEventMetadataForProvider('consumerOrgId', | ||
const res = await sdkClient.createEventMetadataForProvider('consumerId', | ||
'projectId', 'workspaceId', 'test-id', | ||
@@ -286,3 +286,3 @@ mock.data.createEventMetadataForProvider) | ||
new errorSDK.codes.ERROR_CREATE_EVENTMETADATA(), | ||
['consumerOrgId', 'projectId', 'workspaceId', 'test-id', | ||
['consumerId', 'projectId', 'workspaceId', 'test-id', | ||
mock.data.createEventMetadataBadRequest]) | ||
@@ -297,3 +297,3 @@ }) | ||
{ status: 200, statusText: 'OK' }) | ||
const res = await sdkClient.updateEventMetadataForProvider('consumerOrgId', | ||
const res = await sdkClient.updateEventMetadataForProvider('consumerId', | ||
'projectId', 'workspaceId', 'test-id', 'event_code_1', | ||
@@ -310,3 +310,3 @@ mock.data.createEventMetadataForProvider) | ||
new errorSDK.codes.ERROR_UPDATE_EVENTMETADATA(), | ||
['consumerOrgId', 'projectId', 'workspaceId', 'test-id', 'event_code_1', | ||
['consumerId', 'projectId', 'workspaceId', 'test-id', 'event_code_1', | ||
mock.data.createEventMetadataBadRequest]) | ||
@@ -320,3 +320,3 @@ }) | ||
exponentialBackoffMockReturnValue(undefined, { status: 204, statusText: 'No Content' }) | ||
const res = await sdkClient.deleteEventMetadata('consumerOrgId', 'projectId', | ||
const res = await sdkClient.deleteEventMetadata('consumerId', 'projectId', | ||
'workspaceId', 'test-id', 'event_code_1') | ||
@@ -330,3 +330,3 @@ expect(res).toBe(undefined) | ||
new errorSDK.codes.ERROR_DELETE_EVENTMETADATA(), | ||
['consumerOrgId', 'projectId', 'workspaceId', 'test-id', 'event_code_2']) | ||
['consumerId', 'projectId', 'workspaceId', 'test-id', 'event_code_2']) | ||
}) | ||
@@ -339,3 +339,3 @@ }) | ||
exponentialBackoffMockReturnValue(undefined, { status: 204, statusText: 'No Content' }) | ||
const res = await sdkClient.deleteAllEventMetadata('consumerOrgId', 'projectId', | ||
const res = await sdkClient.deleteAllEventMetadata('consumerId', 'projectId', | ||
'workspaceId', 'test-id') | ||
@@ -349,53 +349,96 @@ expect(res).toBe(undefined) | ||
new errorSDK.codes.ERROR_DELETE_ALL_EVENTMETADATA(), | ||
['consumerOrgId', 'projectId', 'workspaceId', 'test-id']) | ||
['consumerId', 'projectId', 'workspaceId', 'test-id']) | ||
}) | ||
}) | ||
describe('Create webhook registration', () => { | ||
it('Success on create webhook registration', async () => { | ||
describe('Create registration', () => { | ||
it('Success on create registration', async () => { | ||
const sdkClient = await createSdkClient() | ||
exponentialBackoffMockReturnValue(mock.data.createWebhookRegistrationResponse, { status: 200, statusText: 'OK' }) | ||
const res = await sdkClient.createWebhookRegistration('consumerOrgId', 'integrationId', mock.data.createWebhookRegistration) | ||
exponentialBackoffMockReturnValue(mock.data.createRegistrationResponse, { status: 200, statusText: 'OK' }) | ||
const res = await sdkClient.createRegistration('consumerId', 'projectId', 'workspaceId', mock.data.createRegistration) | ||
expect(res.id).toBe(248723) | ||
expect(res.status).toBe('VERIFIED') | ||
expect(res.webhook_status).toBe('verified') | ||
expect(res.enabled).toBe(true) | ||
}) | ||
it('Bad request error on create webhook registration', async () => { | ||
const api = 'createWebhookRegistration' | ||
it('Bad request error on create registration', async () => { | ||
const api = 'createRegistration' | ||
exponentialBackoffMockReturnValue({}, { status: 400, statusText: 'Bad Request' }) | ||
await checkErrorResponse(api, new errorSDK.codes.ERROR_CREATE_REGISTRATION(), ['consumerOrgId', 'integrationId', mock.data.createWebhookRegistrationBadRequest]) | ||
await checkErrorResponse(api, new errorSDK.codes.ERROR_CREATE_REGISTRATION(), ['consumerId', 'projectId', 'workspaceId', mock.data.createRegistrationBadRequest]) | ||
}) | ||
}) | ||
describe('Get all webhook registration', () => { | ||
it('Success on get all webhook registration', async () => { | ||
describe('Update registration', () => { | ||
it('Success on update registration', async () => { | ||
const sdkClient = await createSdkClient() | ||
exponentialBackoffMockReturnValue(mock.data.getAllWebhookRegistrationsResponse, { status: 200, statusText: 'OK' }) | ||
const res = await sdkClient.getAllWebhookRegistrations('consumerOrgId', 'integrationId') | ||
expect(res.length).toBe(2) | ||
expect(res[0].id).toBe(1) | ||
expect(res[1].status).toBe('VERIFIED') | ||
exponentialBackoffMockReturnValue(mock.data.updateRegistrationResponse, { status: 200, statusText: 'OK' }) | ||
const res = await sdkClient.updateRegistration('consumerId', 'projectId', 'workspaceId', 'registrationId', mock.data.updateRegistration) | ||
expect(res.id).toBe(248723) | ||
expect(res.webhook_status).toBe('verified') | ||
expect(res.delivery_type).toBe('webhook_batch') | ||
expect(res.enabled).toBe(true) | ||
}) | ||
it('Not found error on get all webhook registration', async () => { | ||
const api = 'getAllWebhookRegistrations' | ||
it('Bad request error on update registration', async () => { | ||
const api = 'updateRegistration' | ||
exponentialBackoffMockReturnValue({}, { status: 400, statusText: 'Bad Request' }) | ||
await checkErrorResponse(api, new errorSDK.codes.ERROR_UPDATE_REGISTRATION(), ['consumerId', 'projectId', 'workspaceId', 'registrationId', mock.data.createRegistrationBadRequest]) | ||
}) | ||
}) | ||
describe('Get all registration', () => { | ||
it('Success on get all registration', async () => { | ||
const sdkClient = await createSdkClient() | ||
exponentialBackoffMockReturnValue(mock.data.getAllRegistrationsResponse, { status: 200, statusText: 'OK' }) | ||
const res = await sdkClient.getAllRegistrationsForWorkspace('consumerId', 'projectId', 'workspaceId') | ||
expect(res._embedded.registrations.length).toBe(3) | ||
const regs = res._embedded.registrations | ||
expect(res._links.self.href).toBe(EVENTS_BASE_URL + '/consumerId/projectId/workspaceId/registrations') | ||
expect(regs[0].id).toBe(30000) | ||
expect(regs[1].webhook_status).toBe('hook_unreachable') | ||
expect(regs[2].delivery_type).toBe('journal') | ||
}) | ||
it('Not found error on get all registration', async () => { | ||
const api = 'getAllRegistrationsForWorkspace' | ||
exponentialBackoffMockReturnValue({}, { status: 404, statusText: 'Not Found' }) | ||
await checkErrorResponse(api, new errorSDK.codes.ERROR_GET_ALL_REGISTRATION(), ['consumerOrgId', 'integrationId-1']) | ||
await checkErrorResponse(api, new errorSDK.codes.ERROR_GET_ALL_REGISTRATION(), ['consumerId', 'project-1', 'workspace-1']) | ||
}) | ||
}) | ||
describe('Get a webhook registration', () => { | ||
it('Success on get a webhook registration', async () => { | ||
describe('Get a registration', () => { | ||
it('Success on get a registration', async () => { | ||
const sdkClient = await createSdkClient() | ||
exponentialBackoffMockReturnValue(mock.data.createWebhookRegistrationResponse, { status: 200, statusText: 'OK' }) | ||
const res = await sdkClient.getWebhookRegistration('consumerOrgId', 'integrationId', 'registration-id') | ||
exponentialBackoffMockReturnValue(mock.data.createRegistrationResponse, { status: 200, statusText: 'OK' }) | ||
const res = await sdkClient.getRegistration('consumerId', 'projectId', 'workspaceId', 'registrationId') | ||
expect(res._links.self.href).toBe(EVENTS_BASE_URL + '/consumerId/projectId/workspaceId/registrations/registrationId') | ||
expect(res.id).toBe(248723) | ||
expect(res.status).toBe('VERIFIED') | ||
expect(res.webhook_status).toBe('verified') | ||
expect(res.enabled).toBe(true) | ||
}) | ||
it('Not found error on get a webhook registration', async () => { | ||
const api = 'getWebhookRegistration' | ||
it('Not found error on get a registration', async () => { | ||
const api = 'getRegistration' | ||
exponentialBackoffMockReturnValue({}, { status: 404, statusText: 'Not Found' }) | ||
await checkErrorResponse(api, new errorSDK.codes.ERROR_GET_REGISTRATION(), ['consumerOrgId', 'integrationId', 'registration-id-1']) | ||
await checkErrorResponse(api, new errorSDK.codes.ERROR_GET_REGISTRATION(), ['consumerId', 'projectId', 'workspaceId', 'registrationId-1']) | ||
}) | ||
}) | ||
describe('Get webhook registration with retries', () => { | ||
describe('Get all registrations for org', () => { | ||
it('Success on get all registrations for org', async () => { | ||
const sdkClient = await createSdkClient() | ||
exponentialBackoffMockReturnValue(mock.data.getAllRegistrationsForOrgResponse, { status: 200, statusText: 'OK' }) | ||
const res = await sdkClient.getAllRegistrationsForOrg('consumerId', { page: 1, size: 2 }) | ||
expect(res._links.self.href).toBe(EVENTS_BASE_URL + '/consumerId/registrations?page=1&size=2') | ||
expect(res._links.first.href).toBe(EVENTS_BASE_URL + '/consumerId/registrations?page=0&size=2') | ||
expect(res._links.last.href).toBe(EVENTS_BASE_URL + '/consumerId/registrations?page=19&size=2') | ||
expect(res._links.prev.href).toBe(EVENTS_BASE_URL + '/consumerId/registrations?page=0&size=2') | ||
expect(res._embedded.registrations.length).toBe(2) | ||
expect(res.page.numberOfElements).toBe(2) | ||
expect(res.page.totalElements).toBe(19) | ||
}) | ||
it('Not found error on get a registration', async () => { | ||
const api = 'getAllRegistrationsForOrg' | ||
exponentialBackoffMockReturnValue({}, { status: 404, statusText: 'Not Found' }) | ||
await checkErrorResponse(api, new errorSDK.codes.ERROR_GET_ALL_REGISTRATIONS_FOR_ORG(), ['consumerId-2']) | ||
}) | ||
}) | ||
describe('Get registration with retries', () => { | ||
it('Test for retries on 5xx response', async () => { | ||
@@ -405,3 +448,3 @@ const sdkClient = await sdk.init(gOrganizationId, gApiKey, gAccessToken, { retries: 3 }) | ||
exponentialBackoffMockReturnValue({}, { status: 500, statusText: 'Internal Server Error', url: journalUrl }) | ||
await sdkClient.getWebhookRegistration('consumerOrgId', 'integrationId', 'registration-id') | ||
await sdkClient.getRegistration('consumerId', 'projectId', 'workspaceId', 'registrationId') | ||
.then(res => { | ||
@@ -415,3 +458,3 @@ throw new Error(' No error response') | ||
expect(fetchRetry.exponentialBackoff).toHaveBeenCalledWith( | ||
'https://api.adobe.io/events/organizations/consumerOrgId/integrations/integrationId/registrations/registration-id', | ||
EVENTS_BASE_URL + '/consumerId/projectId/workspaceId/registrations/registrationId', | ||
{ | ||
@@ -431,7 +474,7 @@ body: undefined, | ||
describe('test delete webhook registration', () => { | ||
describe('test delete registration', () => { | ||
it('Success on delete registration', async () => { | ||
const sdkClient = await createSdkClient() | ||
exponentialBackoffMockReturnValue(undefined, { status: 204, statusText: 'No Content' }) | ||
const res = await sdkClient.deleteWebhookRegistration('consumerOrgId', 'integrationId', | ||
const res = await sdkClient.deleteRegistration('consumerId', 'projectId', 'workspaceId', | ||
'registrationId') | ||
@@ -441,6 +484,6 @@ expect(res).toBe(undefined) | ||
it('Not found error on delete registration', () => { | ||
const api = 'deleteWebhookRegistration' | ||
const api = 'deleteRegistration' | ||
exponentialBackoffMockReturnValue({}, { status: 404, statusText: 'Not Found' }) | ||
checkErrorResponse(api, new errorSDK.codes.ERROR_DELETE_REGISTRATION(), | ||
['consumerOrgId', 'integrationId', 'registrationId1']) | ||
['consumerId', 'integrationId', 'registrationId1']) | ||
}) | ||
@@ -447,0 +490,0 @@ }) |
380
test/mock.js
@@ -242,4 +242,3 @@ /* | ||
const createEventMetadataBadRequest = | ||
{ | ||
const createEventMetadataBadRequest = { | ||
label: 'test event code 1', | ||
@@ -249,4 +248,3 @@ description: 'Test for SDK 1' | ||
const createWebhookRegistration = | ||
{ | ||
const createRegistration = { | ||
name: 'name', | ||
@@ -256,7 +254,7 @@ description: 'description', | ||
webhook_url: 'https://test-webhook', | ||
delivery_type: 'WEBHOOK', | ||
delivery_type: 'webhook', | ||
events_of_interest: [ | ||
{ | ||
event_code: 'event_code_1', | ||
provider: 'provider_1' | ||
provider_id: 'provider_id_1' | ||
} | ||
@@ -266,6 +264,18 @@ ] | ||
const createWebhookRegistrationBadRequest = | ||
{ | ||
const updateRegistration = { | ||
name: 'name', | ||
description: 'description', | ||
webhook_url: 'https://test-webhook', | ||
delivery_type: 'webhook_batch', | ||
events_of_interest: [ | ||
{ | ||
event_code: 'event_code_1', | ||
provider_id: 'provider_id_1' | ||
} | ||
] | ||
} | ||
const createRegistrationBadRequest = { | ||
name: 'name', | ||
description: 'description', | ||
client_id: 'test-apikey', | ||
@@ -281,3 +291,14 @@ delivery_type: 'WEBHOOK', | ||
const createWebhookRegistrationResponse = { | ||
const createRegistrationResponse = { | ||
_links: { | ||
'rel:events': { | ||
href: 'https://events-va6.adobe.io/events/organizations/consumerId/integrations/integrationId/registrationId' | ||
}, | ||
'rel:trace': { | ||
href: 'https://eventtraces-va6.adobe.io/traces/consumerId/projectId/workspaceId/registration/registrationId' | ||
}, | ||
self: { | ||
href: 'https://api.adobe.io/events/consumerId/projectId/workspaceId/registrations/registrationId' | ||
} | ||
}, | ||
id: 248723, | ||
@@ -287,7 +308,42 @@ name: 'name', | ||
client_id: 'test-apikey', | ||
parent_client_id: 'test-apikey', | ||
registration_id: 'registrationId', | ||
events_of_interest: [ | ||
{ | ||
event_code: 'event_code_1', | ||
event_label: 'event_label', | ||
event_description: 'event_description', | ||
provider_id: 'provider_id', | ||
provider: 'provider_1', | ||
provider_label: 'label', | ||
event_delivery_format: 'cloud_events' | ||
} | ||
], | ||
webhook_status: 'verified', | ||
created_date: '2022-02-21T08:45:16.446Z', | ||
updated_date: '2022-02-21T08:45:16.446Z', | ||
consumer_id: 'consumerId', | ||
project_id: 'projectId', | ||
workspace_id: 'workspaceId', | ||
webhook_url: 'https://test-webhook', | ||
status: 'VERIFIED', | ||
type: 'APP', | ||
integration_status: 'ENABLED', | ||
delivery_type: 'webhook', | ||
enabled: true | ||
} | ||
const updateRegistrationResponse = { | ||
_links: { | ||
'rel:events': { | ||
href: 'https://events-va6.adobe.io/events/organizations/consumerId/integrations/integrationId/registrationId' | ||
}, | ||
'rel:trace': { | ||
href: 'https://eventtraces-va6.adobe.io/traces/consumerId/projectId/workspaceId/registration/registrationId' | ||
}, | ||
self: { | ||
href: 'https://api.adobe.io/events/consumerId/projectId/workspaceId/registrations/registrationId' | ||
} | ||
}, | ||
id: 248723, | ||
name: 'name_updated', | ||
description: 'description_updated', | ||
client_id: 'test-apikey', | ||
registration_id: 'registrationId', | ||
events_of_interest: [ | ||
@@ -304,68 +360,239 @@ { | ||
], | ||
registration_id: 'registration_id', | ||
delivery_type: 'WEBHOOK', | ||
events_url: 'journal_url', | ||
created_date: '2020-02-21T08:45:16.446Z', | ||
updated_date: '2020-02-21T08:45:16.446Z', | ||
runtime_action: '' | ||
webhook_status: 'verified', | ||
created_date: '2022-02-21T08:45:16.446Z', | ||
updated_date: '2022-02-21T08:45:16.446Z', | ||
consumer_id: 'consumerId', | ||
project_id: 'projectId', | ||
workspace_id: 'workspaceId', | ||
webhook_url: 'https://test-webhook', | ||
delivery_type: 'webhook_batch', | ||
enabled: true | ||
} | ||
const getAllWebhookRegistrationsResponse = [ | ||
{ | ||
id: 1, | ||
name: 'name', | ||
description: 'description', | ||
client_id: 'test-apikey', | ||
parent_client_id: 'test-apikey', | ||
webhook_url: 'https://test-webhook', | ||
status: 'VERIFIED', | ||
type: 'APP', | ||
integration_status: 'ENABLED', | ||
events_of_interest: [ | ||
const getAllRegistrationsResponse = { | ||
_links: { | ||
self: { | ||
href: 'https://api.adobe.io/events/consumerId/projectId/workspaceId/registrations' | ||
} | ||
}, | ||
_embedded: { | ||
registrations: [ | ||
{ | ||
event_code: 'event_code_1', | ||
event_label: 'event_label', | ||
event_description: 'event_description', | ||
provider_id: 'provider_id', | ||
provider: 'provider_1', | ||
provider_label: 'label', | ||
event_delivery_format: 'cloud_events' | ||
_links: { | ||
'rel:events': { | ||
href: 'https://events-stage-va6.adobe.io/events/organizations/consumerId/integrations/integrationId/registrationId1' | ||
}, | ||
'rel:trace': { | ||
href: 'https://eventtraces-stage-va6.adobe.io/traces/consumerId/projectId/workspaceId/registration/registrationId1' | ||
}, | ||
self: { | ||
href: 'https://api.adobe.io/events/consumerId/projectId/workspaceId/registrations/registrationId1' | ||
} | ||
}, | ||
id: 30000, | ||
name: 'test name 1', | ||
description: 'test description 1', | ||
client_id: 'test-apikey', | ||
registration_id: 'registrationId1', | ||
events_of_interest: [ | ||
{ | ||
event_code: 'event_code_1', | ||
event_label: 'event_label', | ||
event_description: 'event_description', | ||
provider_id: 'provider_id', | ||
provider_label: 'label', | ||
event_delivery_format: 'adobe_io' | ||
} | ||
], | ||
webhook_status: 'verified', | ||
created_date: '2022-06-13T16:31:57.000Z', | ||
updated_date: '2022-09-19T05:46:36.000Z', | ||
consumer_id: 'consumerId', | ||
project_id: 'projectId', | ||
workspace_id: 'workspaceId', | ||
webhook_url: 'https://test-webhook-1', | ||
delivery_type: 'webhook', | ||
enabled: true | ||
}, | ||
{ | ||
_links: { | ||
'rel:events': { | ||
href: 'https://events-stage-va6.adobe.io/events/organizations/consumerId/integrations/integrationId/registrationId2' | ||
}, | ||
'rel:trace': { | ||
href: 'https://eventtraces-stage-va6.adobe.io/traces/consumerId/projectId/workspaceId/registration/registrationId2' | ||
}, | ||
self: { | ||
href: 'https://csm-stage.adobe.io/consumerId/projectId/workspaceId/registrations/registrationId2' | ||
} | ||
}, | ||
id: 30001, | ||
name: 'test name 2', | ||
description: 'test description 2', | ||
client_id: 'test-apikey', | ||
registration_id: 'registrationId2', | ||
events_of_interest: [ | ||
{ | ||
event_code: 'event_code_2', | ||
event_label: 'event_label_2', | ||
event_description: 'event_description_2', | ||
provider_id: 'provider_id_2', | ||
provider_label: 'label', | ||
event_delivery_format: 'adobe_io' | ||
} | ||
], | ||
webhook_status: 'hook_unreachable', | ||
created_date: '2022-06-13T16:31:57.000Z', | ||
updated_date: '2022-09-19T05:46:36.000Z', | ||
consumer_id: 'consumerId', | ||
project_id: 'projectId', | ||
workspace_id: 'workspaceId', | ||
webhook_url: 'https://test-webhook-2', | ||
delivery_type: 'webhook_batch', | ||
enabled: false | ||
}, | ||
{ | ||
_links: { | ||
'rel:events': { | ||
href: 'https://events-stage-va6.adobe.io/events/organizations/consumerId/integrations/integrationId/registrationId3' | ||
}, | ||
'rel:trace': { | ||
href: 'https://eventtraces-stage-va6.adobe.io/traces/consumerId/projectId/workspaceId/registration/registrationId3' | ||
}, | ||
self: { | ||
href: 'https://csm-stage.adobe.io/consumerId/projectId/workspaceId/registrations/registrationId3' | ||
} | ||
}, | ||
id: 30002, | ||
name: 'test name 3', | ||
description: 'test description 3', | ||
client_id: 'test-apikey', | ||
registration_id: 'registrationId3', | ||
events_of_interest: [ | ||
{ | ||
event_code: 'event_code_3', | ||
event_label: 'event_label_3', | ||
event_description: 'event_description_3', | ||
provider_id: 'provider_id_3', | ||
provider_label: 'label', | ||
event_delivery_format: 'adobe_io' | ||
} | ||
], | ||
webhook_status: 'verified', | ||
created_date: '2022-06-13T16:31:57.000Z', | ||
updated_date: '2022-09-19T05:46:36.000Z', | ||
consumer_id: 'consumerId', | ||
project_id: 'projectId', | ||
workspace_id: 'workspaceId', | ||
delivery_type: 'journal', | ||
enabled: true | ||
} | ||
], | ||
registration_id: 'registration_id', | ||
delivery_type: 'WEBHOOK', | ||
events_url: 'journal_url', | ||
created_date: '2020-02-21T08:45:16.446Z', | ||
updated_date: '2020-02-21T08:45:16.446Z', | ||
runtime_action: '' | ||
] | ||
} | ||
} | ||
const getAllRegistrationsForOrgResponse = { | ||
_links: { | ||
first: { | ||
href: 'https://api.adobe.io/events/consumerId/registrations?page=0&size=2' | ||
}, | ||
last: { | ||
href: 'https://api.adobe.io/events/consumerId/registrations?page=19&size=2' | ||
}, | ||
next: { | ||
href: 'https://api.adobe.io/events/consumerId/registrations?page=2&size=2' | ||
}, | ||
prev: { | ||
href: 'https://api.adobe.io/events/consumerId/registrations?page=0&size=2' | ||
}, | ||
self: { | ||
href: 'https://api.adobe.io/events/consumerId/registrations?page=1&size=2' | ||
} | ||
}, | ||
{ | ||
id: 2, | ||
name: 'name 2', | ||
description: 'description 2', | ||
client_id: 'test-apikey', | ||
parent_client_id: 'test-apikey', | ||
webhook_url: 'https://test-webhook-2', | ||
status: 'VERIFIED', | ||
type: 'APP', | ||
integration_status: 'ENABLED', | ||
events_of_interest: [ | ||
_embedded: { | ||
registrations: [ | ||
{ | ||
event_code: 'event_code_2', | ||
event_label: 'event_label 2', | ||
event_description: 'event_description 2', | ||
provider_id: 'provider_id', | ||
provider: 'provider_1', | ||
provider_label: 'label 2', | ||
event_delivery_format: 'cloud_events' | ||
_links: { | ||
'rel:events': { | ||
href: 'https://events-stage-va6.adobe.io/events/organizations/consumerId/integrations/integrationId/registrationId1' | ||
}, | ||
'rel:trace': { | ||
href: 'https://eventtraces-stage-va6.adobe.io/traces/consumerId/projectId/workspaceId/registration/registrationId1' | ||
}, | ||
self: { | ||
href: 'https://api.adobe.io/events/consumerId/projectId/workspaceId/registrations/registrationId1' | ||
} | ||
}, | ||
id: 30000, | ||
name: 'test name 1', | ||
description: 'test description 1', | ||
client_id: 'test-apikey', | ||
registration_id: 'registrationId1', | ||
events_of_interest: [ | ||
{ | ||
event_code: 'event_code_1', | ||
event_label: 'event_label', | ||
event_description: 'event_description', | ||
provider_id: 'provider_id', | ||
provider_label: 'label', | ||
event_delivery_format: 'adobe_io' | ||
} | ||
], | ||
webhook_status: 'verified', | ||
created_date: '2022-06-13T16:31:57.000Z', | ||
updated_date: '2022-09-19T05:46:36.000Z', | ||
consumer_id: 'consumerId', | ||
project_id: 'projectId', | ||
workspace_id: 'workspaceId', | ||
webhook_url: 'https://test-webhook-1', | ||
delivery_type: 'webhook', | ||
enabled: true | ||
}, | ||
{ | ||
_links: { | ||
'rel:events': { | ||
href: 'https://events-stage-va6.adobe.io/events/organizations/consumerId/integrations/integrationId/registrationId2' | ||
}, | ||
'rel:trace': { | ||
href: 'https://eventtraces-stage-va6.adobe.io/traces/consumerId/projectId/workspaceId/registration/registrationId2' | ||
}, | ||
self: { | ||
href: 'https://csm-stage.adobe.io/consumerId/projectId/workspaceId/registrations/registrationId2' | ||
} | ||
}, | ||
id: 30001, | ||
name: 'test name 2', | ||
description: 'test description 2', | ||
client_id: 'test-apikey', | ||
registration_id: 'registrationId2', | ||
events_of_interest: [ | ||
{ | ||
event_code: 'event_code_2', | ||
event_label: 'event_label_2', | ||
event_description: 'event_description_2', | ||
provider_id: 'provider_id_2', | ||
provider_label: 'label', | ||
event_delivery_format: 'adobe_io' | ||
} | ||
], | ||
webhook_status: 'hook_unreachable', | ||
created_date: '2022-06-13T16:31:57.000Z', | ||
updated_date: '2022-09-19T05:46:36.000Z', | ||
consumer_id: 'consumerId', | ||
project_id: 'projectId', | ||
workspace_id: 'workspaceId', | ||
webhook_url: 'https://test-webhook-2', | ||
delivery_type: 'webhook_batch', | ||
enabled: false | ||
} | ||
], | ||
registration_id: 'registration_id_2', | ||
delivery_type: 'WEBHOOK', | ||
events_url: 'journal_url_2', | ||
created_date: '2020-02-21T08:45:16.446Z', | ||
updated_date: '2020-02-21T08:45:16.446Z', | ||
runtime_action: '' | ||
] | ||
}, | ||
page: { | ||
size: 2, | ||
number: 1, | ||
numberOfElements: 2, | ||
totalElements: 19, | ||
totalPages: 10 | ||
} | ||
] | ||
} | ||
@@ -590,6 +817,9 @@ const cloudEvent = { | ||
createEventMetadataBadRequest: createEventMetadataBadRequest, | ||
createWebhookRegistration: createWebhookRegistration, | ||
createWebhookRegistrationResponse: createWebhookRegistrationResponse, | ||
createWebhookRegistrationBadRequest: createWebhookRegistrationBadRequest, | ||
getAllWebhookRegistrationsResponse: getAllWebhookRegistrationsResponse, | ||
createRegistration: createRegistration, | ||
createRegistrationResponse: createRegistrationResponse, | ||
createRegistrationBadRequest: createRegistrationBadRequest, | ||
updateRegistrationResponse: updateRegistrationResponse, | ||
updateRegistration: updateRegistration, | ||
getAllRegistrationsForOrgResponse: getAllRegistrationsForOrgResponse, | ||
getAllRegistrationsResponse: getAllRegistrationsResponse, | ||
cloudEvent: cloudEvent, | ||
@@ -596,0 +826,0 @@ cloudEventEmptyPayload: cloudEventEmptyPayload, |
363
types.d.ts
@@ -15,8 +15,7 @@ import {Observable} from "rxjs"; | ||
* Returns a Promise that resolves with a new EventsCoreAPI object. | ||
* | ||
* @param {string} organizationId The organization id from your integration | ||
* @param {string} apiKey The api key from your integration | ||
* @param {string} accessToken JWT Token for the integration with IO Management API scope | ||
* @param {EventsCoreAPIOptions} [httpOptions] Options to configure API calls | ||
* @returns {Promise<EventsCoreAPI>} returns object of the class EventsCoreAPI | ||
* @param organizationId - The organization id from your integration | ||
* @param apiKey - The api key from your integration | ||
* @param accessToken - JWT Token for the integration with IO Management API scope | ||
* @param [httpOptions] - Options to configure API calls | ||
* @returns returns object of the class EventsCoreAPI | ||
*/ | ||
@@ -28,3 +27,4 @@ declare function init(organizationId: string, apiKey: string, accessToken: string, httpOptions?: EventsCoreAPIOptions): Promise<EventsCoreAPI>; | ||
* Before calling any method initialize the instance by calling the `init` method on it | ||
* with valid values for organizationId, apiKey and accessToken | ||
* with valid values for organizationId, apiKey, accessToken and optional http options such as timeout | ||
* and max number of retries | ||
*/ | ||
@@ -34,20 +34,23 @@ declare class EventsCoreAPI { | ||
* Initialize SDK. | ||
* | ||
* @param {string} organizationId The organization id from your integration | ||
* @param {string} apiKey The api key from your integration | ||
* @param {string} accessToken JWT Token for the integration with IO Management API scope | ||
* @param {EventsCoreAPIOptions} [httpOptions] Options to configure API calls | ||
* @returns {Promise<EventsCoreAPI>} returns object of the class EventsCoreAPI | ||
* @param organizationId - The organization id from your integration | ||
* @param apiKey - The api key from your integration | ||
* @param accessToken - JWT Token for the integration with IO Management API scope | ||
* @param [httpOptions] - Options to configure API calls | ||
* @returns returns object of the class EventsCoreAPI | ||
*/ | ||
init(organizationId: string, apiKey: string, accessToken: string, httpOptions?: EventsCoreAPIOptions): Promise<EventsCoreAPI>; | ||
/** Http options {retries, timeout} | ||
/** | ||
* Http options {retries, timeout} | ||
*/ | ||
httpOptions: EventsCoreAPIOptions; | ||
/** The organization id from your integration | ||
/** | ||
* The organization id from your integration | ||
*/ | ||
organizationId: string; | ||
/** The api key from your integration | ||
/** | ||
* The api key from your integration | ||
*/ | ||
apiKey: string; | ||
/** The JWT Token for the integration with IO Management API scope | ||
/** | ||
* The JWT Token for the integration with IO Management API scope | ||
*/ | ||
@@ -57,5 +60,4 @@ accessToken: string; | ||
* Fetch all the providers | ||
* | ||
* @param {string} consumerOrgId Consumer Org Id from the console | ||
* @returns {Promise<object>} Returns list of providers for the org | ||
* @param consumerOrgId - Consumer Org Id from the console | ||
* @returns Returns list of providers for the org | ||
*/ | ||
@@ -65,6 +67,5 @@ getAllProviders(consumerOrgId: string): Promise<object>; | ||
* Fetch a provider | ||
* | ||
* @param {string} providerId The id that uniquely identifies the provider to be fetched | ||
* @param {boolean} [fetchEventMetadata] Set this to true if you want to fetch the associated eventmetadata of the provider | ||
* @returns {Promise<object>} Returns the provider specified by the provider id | ||
* @param providerId - The id that uniquely identifies the provider to be fetched | ||
* @param [fetchEventMetadata = false] - Set this to true if you want to fetch the associated eventmetadata of the provider | ||
* @returns Returns the provider specified by the provider id | ||
*/ | ||
@@ -74,29 +75,26 @@ getProvider(providerId: string, fetchEventMetadata?: boolean): Promise<object>; | ||
* Create a new provider given the provider details | ||
* | ||
* @param {string} consumerOrgId Consumer Org Id from the console | ||
* @param {string} projectId Project Id from the console | ||
* @param {string} workspaceId Workspace Id from the console | ||
* @param {object} body Json data that describes the provider | ||
* @returns {Promise<object>} Returns the details of the provider created | ||
* @param consumerOrgId - Consumer Org Id from the console | ||
* @param projectId - Project Id from the console | ||
* @param workspaceId - Workspace Id from the console | ||
* @param body - Json data that describes the provider | ||
* @returns Returns the details of the provider created | ||
*/ | ||
createProvider(consumerOrgId: string, projectId: string, workspaceId: string, body: any): Promise<object>; | ||
createProvider(consumerOrgId: string, projectId: string, workspaceId: string, body: ProviderInputModel): Promise<object>; | ||
/** | ||
* Update a provider given the id and provider details | ||
* | ||
* @param {string} consumerOrgId Consumer Org Id from the console | ||
* @param {string} projectId Project Id from the console | ||
* @param {string} workspaceId Workspace Id from the console | ||
* @param {string} providerId The id that uniquely identifies the provider to be updated | ||
* @param {object} body Json data that describes the provider | ||
* @returns {Promise<object>} Returns the details of the provider updated | ||
* @param consumerOrgId - Consumer Org Id from the console | ||
* @param projectId - Project Id from the console | ||
* @param workspaceId - Workspace Id from the console | ||
* @param providerId - The id that uniquely identifies the provider to be updated | ||
* @param body - Json data that describes the provider | ||
* @returns Returns the details of the provider updated | ||
*/ | ||
updateProvider(consumerOrgId: string, projectId: string, workspaceId: string, providerId: string, body: any): Promise<object>; | ||
updateProvider(consumerOrgId: string, projectId: string, workspaceId: string, providerId: string, body: ProviderInputModel): Promise<object>; | ||
/** | ||
* Delete a provider given the id | ||
* | ||
* @param {string} consumerOrgId Consumer Org Id from the console | ||
* @param {string} projectId Project Id from the console | ||
* @param {string} workspaceId Workspace Id from the console | ||
* @param {string} providerId The id that uniquely identifies the provider to be deleted | ||
* @returns {Promise<object>} Returns an empty object if the deletion was successful | ||
* @param consumerOrgId - Consumer Org Id from the console | ||
* @param projectId - Project Id from the console | ||
* @param workspaceId - Workspace Id from the console | ||
* @param providerId - The id that uniquely identifies the provider to be deleted | ||
* @returns Returns an empty object if the deletion was successful | ||
*/ | ||
@@ -106,5 +104,4 @@ deleteProvider(consumerOrgId: string, projectId: string, workspaceId: string, providerId: string): Promise<object>; | ||
* Get all event metadata for a provider | ||
* | ||
* @param {string} providerId The id that uniquely identifies the provider whose event metadata is to be fetched | ||
* @returns {Promise<object>} List of all event metadata of the provider | ||
* @param providerId - The id that uniquely identifies the provider whose event metadata is to be fetched | ||
* @returns List of all event metadata of the provider | ||
*/ | ||
@@ -114,6 +111,5 @@ getAllEventMetadataForProvider(providerId: string): Promise<object>; | ||
* Get an event metadata for given provider and event code | ||
* | ||
* @param {string} providerId The id that uniquely identifies the provider whose event metadata is to be fetched | ||
* @param {string} eventCode The specific event code for which the details of the event metadata is to be fetched | ||
* @returns {Promise<object>} Event metadata that corresponds to the specified event code | ||
* @param providerId - The id that uniquely identifies the provider whose event metadata is to be fetched | ||
* @param eventCode - The specific event code for which the details of the event metadata is to be fetched | ||
* @returns Event metadata that corresponds to the specified event code | ||
*/ | ||
@@ -123,32 +119,29 @@ getEventMetadataForProvider(providerId: string, eventCode: string): Promise<object>; | ||
* Create an event metadata for a provider | ||
* | ||
* @param {string} consumerOrgId Consumer Org Id from the console | ||
* @param {string} projectId Project Id from the console | ||
* @param {string} workspaceId Workspace Id from the console | ||
* @param {string} providerId provider for which the event metadata is to be added | ||
* @param {object} body Json data that describes the event metadata | ||
* @returns {Promise<object>} Details of the event metadata created | ||
* @param consumerOrgId - Consumer Org Id from the console | ||
* @param projectId - Project Id from the console | ||
* @param workspaceId - Workspace Id from the console | ||
* @param providerId - provider for which the event metadata is to be added | ||
* @param body - Json data that describes the event metadata | ||
* @returns Details of the event metadata created | ||
*/ | ||
createEventMetadataForProvider(consumerOrgId: string, projectId: string, workspaceId: string, providerId: string, body: any): Promise<object>; | ||
createEventMetadataForProvider(consumerOrgId: string, projectId: string, workspaceId: string, providerId: string, body: EventMetadataInputModel): Promise<object>; | ||
/** | ||
* Update the event metadata for a provider | ||
* | ||
* @param {string} consumerOrgId Consumer Org Id from the console | ||
* @param {string} projectId Project Id from the console | ||
* @param {string} workspaceId Workspace Id from the console | ||
* @param {string} providerId provider for which the event metadata is to be updated | ||
* @param {string} eventCode eventCode of the event metadata to be updated | ||
* @param {object} body Json data that describes the event metadata | ||
* @returns {Promise<object>} Details of the event metadata updated | ||
* @param consumerOrgId - Consumer Org Id from the console | ||
* @param projectId - Project Id from the console | ||
* @param workspaceId - Workspace Id from the console | ||
* @param providerId - provider for which the event metadata is to be updated | ||
* @param eventCode - eventCode of the event metadata to be updated | ||
* @param body - Json data that describes the event metadata | ||
* @returns Details of the event metadata updated | ||
*/ | ||
updateEventMetadataForProvider(consumerOrgId: string, projectId: string, workspaceId: string, providerId: string, eventCode: string, body: any): Promise<object>; | ||
updateEventMetadataForProvider(consumerOrgId: string, projectId: string, workspaceId: string, providerId: string, eventCode: string, body: EventMetadataInputModel): Promise<object>; | ||
/** | ||
* Delete an event metadata of a provider | ||
* | ||
* @param {string} consumerOrgId Consumer Org Id from the console | ||
* @param {string} projectId Project Id from the console | ||
* @param {string} workspaceId Workspace Id from the console | ||
* @param {string} providerId provider for which the event metadata is to be updated | ||
* @param {string} eventCode eventCode of the event metadata to be updated | ||
* @returns {Promise<object>} Empty object if deletion was successful | ||
* @param consumerOrgId - Consumer Org Id from the console | ||
* @param projectId - Project Id from the console | ||
* @param workspaceId - Workspace Id from the console | ||
* @param providerId - provider for which the event metadata is to be updated | ||
* @param eventCode - eventCode of the event metadata to be updated | ||
* @returns Empty object if deletion was successful | ||
*/ | ||
@@ -158,8 +151,7 @@ deleteEventMetadata(consumerOrgId: string, projectId: string, workspaceId: string, providerId: string, eventCode: string): Promise<object>; | ||
* Delete all event metadata of a provider | ||
* | ||
* @param {string} consumerOrgId Consumer Org Id from the console | ||
* @param {string} projectId Project Id from the console | ||
* @param {string} workspaceId Workspace Id from the console | ||
* @param {string} providerId provider for which the event metadata is to be updated | ||
* @returns {Promise<object>} Empty object if deletion was successful | ||
* @param consumerOrgId - Consumer Org Id from the console | ||
* @param projectId - Project Id from the console | ||
* @param workspaceId - Workspace Id from the console | ||
* @param providerId - provider for which the event metadata is to be updated | ||
* @returns Empty object if deletion was successful | ||
*/ | ||
@@ -169,40 +161,60 @@ deleteAllEventMetadata(consumerOrgId: string, projectId: string, workspaceId: string, providerId: string): Promise<object>; | ||
* Create a webhook or journal registration | ||
* | ||
* @param {string} consumerOrgId Consumer Org Id from the console | ||
* @param {string} integrationId integration Id from the console | ||
* @param {object} body Json data contains details of the registration | ||
* @returns {Promise<object>} Details of the webhook/journal registration created | ||
* @param consumerOrgId - Consumer Org Id from the console | ||
* @param projectId - Project Id from the console | ||
* @param workspaceId - Workspace Id from the console | ||
* @param body - Json data contains details of the registration | ||
* @returns Details of the webhook/journal registration created | ||
*/ | ||
createWebhookRegistration(consumerOrgId: string, integrationId: string, body: any): Promise<object>; | ||
createRegistration(consumerOrgId: string, projectId: string, workspaceId: string, body: RegistrationCreateModel): Promise<object>; | ||
/** | ||
* Update a webhook or journal registration | ||
* @param consumerOrgId - Consumer Org Id from the console | ||
* @param projectId - Project Id from the console | ||
* @param workspaceId - Workspace Id from the console | ||
* @param registrationId - Registration id whose details are to be fetched | ||
* @param body - Json data contains details of the registration | ||
* @returns Details of the webhook/journal registration to be updated | ||
*/ | ||
updateRegistration(consumerOrgId: string, projectId: string, workspaceId: string, registrationId: string, body: RegistrationUpdateModel): Promise<object>; | ||
/** | ||
* Get registration details for a given registration | ||
* | ||
* @param {string} consumerOrgId Consumer Org Id from the console | ||
* @param {string} integrationId Integration Id from the console | ||
* @param {string} registrationId Registration id whose details are to be fetched | ||
* @returns {Promise<object>} Details of the webhook/journal registration | ||
* @param consumerOrgId - Consumer Org Id from the console | ||
* @param projectId - Project Id from the console | ||
* @param workspaceId - Workspace Id from the console | ||
* @param registrationId - Registration id whose details are to be fetched | ||
* @returns Details of the webhook/journal registration | ||
*/ | ||
getWebhookRegistration(consumerOrgId: string, integrationId: string, registrationId: string): Promise<object>; | ||
getRegistration(consumerOrgId: string, projectId: string, workspaceId: string, registrationId: string): Promise<object>; | ||
/** | ||
* Get all registration details for a given integration | ||
* | ||
* @param {string} consumerOrgId Consumer Org Id from the console | ||
* @param {string} integrationId Integration Id from the console | ||
* @returns {Promise<object>} List of all webhook/journal registrations | ||
* Get all registration details for a workspace | ||
* @param consumerOrgId - Consumer Org Id from the console | ||
* @param projectId - Project Id from the console | ||
* @param workspaceId - Workspace Id from the console | ||
* @returns List of all webhook/journal registrations | ||
*/ | ||
getAllWebhookRegistrations(consumerOrgId: string, integrationId: string): Promise<object>; | ||
getAllRegistrationsForWorkspace(consumerOrgId: string, projectId: string, workspaceId: string): Promise<object>; | ||
/** | ||
* Get all registration details for an org | ||
* @param consumerOrgId - Consumer Org Id from the console | ||
* @param [page] - page size and page number | ||
* @returns Paginated response of all webhook/journal registrations for an org | ||
*/ | ||
getAllRegistrationsForOrg(consumerOrgId: string, page?: Page): Promise<object>; | ||
/** | ||
* Delete webhook registration | ||
* | ||
* @param {string} consumerOrgId Consumer Org Id from the console | ||
* @param {string} integrationId Integration Id from the console | ||
* @param {string} registrationId Id of the registration to be deleted | ||
* @returns {Promise<object>} Empty object if deletion was successful | ||
* @param consumerOrgId - Consumer Org Id from the console | ||
* @param projectId - Project Id from the console | ||
* @param workspaceId - Workspace Id from the console | ||
* @param registrationId - Id of the registration to be deleted | ||
* @returns Empty object if deletion was successful | ||
*/ | ||
deleteWebhookRegistration(consumerOrgId: string, integrationId: string, registrationId: string): Promise<object>; | ||
deleteRegistration(consumerOrgId: string, projectId: string, workspaceId: string, registrationId: string): Promise<object>; | ||
/** | ||
* Publish cloud events to Adobe I/O Events | ||
* Publish Cloud Events | ||
* | ||
* @param {object} cloudEvent Object to be published to event receiver in cloud event format | ||
* @returns {Promise<string>} Returns OK/ undefined in case of success and error in case of failure | ||
* Event publishers can publish events to the Adobe I/O Events using this SDK. The events should follow Cloud Events 1.0 specification: https://github.com/cloudevents/spec/blob/v1.0/spec.md. | ||
* As of now, only application/json is accepted as the content-type for the "data" field of the cloud event. | ||
* If retries are set, publish events are retried on network issues, 5xx and 429 error response codes. | ||
* @param cloudEvent - Object to be published to event receiver in cloud event format | ||
* @returns Returns OK/ undefined in case of success and error in case of failure | ||
*/ | ||
@@ -212,25 +224,29 @@ publishEvent(cloudEvent: any): Promise<string>; | ||
* Get events from a journal. | ||
* | ||
* @param {string} journalUrl URL of the journal or 'next' link to read from (required) | ||
* @param {EventsJournalOptions} [eventsJournalOptions] Query options to send with the URL | ||
* @returns {Promise<object>} with the response json includes events and links (if available) | ||
* @param journalUrl - URL of the journal or 'next' link to read from (required) | ||
* @param [eventsJournalOptions] - Query options to send with the URL | ||
* @param [fetchResponseHeaders] - Set this to true if you want to fetch the complete response headers | ||
* @returns with the response json includes events and links (if available) | ||
*/ | ||
getEventsFromJournal(journalUrl: string, eventsJournalOptions?: EventsJournalOptions): Promise<object>; | ||
getEventsFromJournal(journalUrl: string, eventsJournalOptions?: EventsJournalOptions, fetchResponseHeaders?: boolean): Promise<object>; | ||
/** | ||
* Get observable to start listening to journal events. | ||
* getEventsObservableFromJournal returns an RxJS <a href="https://rxjs-dev.firebaseapp.com/guide/observable">Observable</a> | ||
* | ||
* @param {string} journalUrl URL of the journal or 'next' link to read from (required) | ||
* @param {EventsJournalOptions} [eventsJournalOptions] Query options to send with the Journal URL | ||
* @param {EventsJournalPollingOptions} [eventsJournalPollingOptions] Journal polling options | ||
* @returns {Observable<object>} observable to which the user can subscribe to in order to listen to events | ||
* One can go through the extensive documentation on <a href="https://rxjs-dev.firebaseapp.com/guide/overview">RxJS</a> in order to learn more | ||
* and leverage the various <a href="https://rxjs-dev.firebaseapp.com/guide/operators">RxJS Operators</a> to act on emitted events. | ||
* @param journalUrl - URL of the journal or 'next' link to read from (required) | ||
* @param [eventsJournalOptions] - Query options to send with the Journal URL | ||
* @param [eventsJournalPollingOptions] - Journal polling options | ||
* @returns observable to which the user can subscribe to in order to listen to events | ||
*/ | ||
getEventsObservableFromJournal(journalUrl: string, eventsJournalOptions?: EventsJournalOptions, eventsJournalPollingOptions?: EventsJournalPollingOptions): Observable<object>; | ||
/** | ||
* Authenticating events by verifying digital signature | ||
* @param {object} event JSON payload delivered to the registered webhook URL | ||
* @param {string} recipientClientId Target recipient client id retrieved from the Adobe I/O Console integration | ||
* @param {SignatureOptions} signatureOptions Map of all digital signature header values consisting fields defined in SignatureOptions | ||
* @returns {boolean} If signature matches return true else return false | ||
* @param event - JSON payload delivered to the registered webhook URL | ||
* @param recipientClientId - Target recipient client id retrieved from the Adobe I/O Console integration | ||
* @param signatureOptions - map of all digital signature header values consisting fields as below | ||
* digiSignature1 : Value of digital signature retrieved from the x-adobe-digital-signature1 header in each POST request to webhook | ||
* digiSignature2 : Value of digital signature retrieved from the x-adobe-digital-signature2 header in each POST request to webhook | ||
* publicKeyPath1 : Relative path of ioevents public key retrieved from the x-adobe-public-key1-path header in each POST request to webhook | ||
* publicKeyPath2 : Relative path of ioevents public key retrieved from the x-adobe-public-key2-path header in each POST request to webhook | ||
* @returns If signature matches return true else return false | ||
*/ | ||
@@ -241,7 +257,84 @@ verifyDigitalSignatureForEvent(event: any, recipientClientId: string, signatureOptions?: SignatureOptions): boolean; | ||
/** | ||
* @typedef {object} EventsJournalOptions | ||
* @property {boolean} [latest] Retrieve latest events (optional) | ||
* @property {string} [since] Position at which to start fetching the events from (optional) | ||
* @property {number} [limit] Maximum number of events to retrieve (optional) | ||
* @property label - The label of this Events Provider | ||
* @property [description] - The description of this Events Provider | ||
* @property [docs_url] - The documentation url of this Events Provider | ||
*/ | ||
declare type ProviderInputModel = { | ||
label: string; | ||
description?: string; | ||
docs_url?: string; | ||
}; | ||
/** | ||
* @property label - The description of this Event Metadata | ||
* @property description - The label of this Event Metadata | ||
* @property event_code - The event_code of this Event Metadata. This event_code describes the type of event. Ideally it should be prefixed with a reverse-DNS name (dictating the organization which defines the semantics of this event type) It is equivalent to the CloudEvents' type. See https://github.com/cloudevents/spec/blob/master/spec.md#type | ||
* @property [sample_event_template] - An optional base64 encoded sample event template | ||
*/ | ||
declare type EventMetadataInputModel = { | ||
label: string; | ||
description: string; | ||
event_code: string; | ||
sample_event_template?: string; | ||
}; | ||
/** | ||
* @property provider_id - The id of the provider of the events to be subscribed | ||
* @property event_code - The requested valid event code belonging to the provider | ||
*/ | ||
declare type EventsOfInterest = { | ||
provider_id: string; | ||
event_code: string; | ||
}; | ||
/** | ||
* @property client_id - Client id for which the registration is created | ||
* @property name - The name of the registration | ||
* @property description - The description of the registration | ||
* @property [webhook_url] - A valid webhook url where the events would be delivered for webhook or webhook_batch delivery_type | ||
* @property events_of_interest - The events for which the registration is to be subscribed to | ||
* @property delivery_type - Delivery type can either be webhook|webhook_batch|journal. | ||
* @property [enabled] - Enable or disable the registration. Default true. | ||
*/ | ||
declare type RegistrationCreateModel = { | ||
client_id: string; | ||
name: string; | ||
description: string; | ||
webhook_url?: string; | ||
events_of_interest: EventsOfInterest[]; | ||
delivery_type: string; | ||
enabled?: string; | ||
}; | ||
/** | ||
* @property name - The name of the registration | ||
* @property description - The description of the registration | ||
* @property [webhook_url] - A valid webhook url where the events would be delivered for webhook or webhook_batch delivery_type | ||
* @property events_of_interest - The events for which the registration is to be subscribed to | ||
* @property delivery_type - Delivery type can either be webhook|webhook_batch|journal. | ||
* @property [enabled] - Enable or disable the registration. Default true. | ||
*/ | ||
declare type RegistrationUpdateModel = { | ||
name: string; | ||
description: string; | ||
webhook_url?: string; | ||
events_of_interest: EventsOfInterest[]; | ||
delivery_type: string; | ||
enabled?: string; | ||
}; | ||
/** | ||
* @property [page] - page number to be fetched. Default 0 (optional) | ||
* @property [size] - size of each page. Default 10 (optional) | ||
*/ | ||
declare type Page = { | ||
page?: number; | ||
size?: number; | ||
}; | ||
/** | ||
* @property [latest] - Retrieve latest events (optional) | ||
* @property [since] - Position at which to start fetching the events from (optional) | ||
* @property [limit] - Maximum number of events to retrieve (optional) | ||
*/ | ||
declare type EventsJournalOptions = { | ||
@@ -254,4 +347,3 @@ latest?: boolean; | ||
/** | ||
* @typedef {object} EventsJournalPollingOptions | ||
* @property {number} [interval] Interval at which to poll the journal; If not provided, a default value will be used (optional) | ||
* @property [interval] - Interval at which to poll the journal; If not provided, a default value will be used (optional) | ||
*/ | ||
@@ -264,6 +356,6 @@ declare type EventsJournalPollingOptions = { | ||
* @typedef {object} SignatureOptions | ||
* @property {string} [digiSignature1] Value of digital signature retrieved from the x-adobe-digital-signature1 header in each POST request to webhook | ||
* @property {string} [digiSignature2] Value of digital signature retrieved from the x-adobe-digital-signature2 header in each POST request to webhook | ||
* @property {string} [publicKeyUrl1] Value of public key url retrieved from the x-adobe-public-key1-url header in each POST request to webhook | ||
* @property {string} [publicKeyUrl2] Value of public key url retrieved from the x-adobe-public-key2-url header in each POST request to webhook | ||
* @property [digiSignature1] - Value of digital signature retrieved from the x-adobe-digital-signature1 header in each POST request to webhook | ||
* @property [digiSignature2] - Value of digital signature retrieved from the x-adobe-digital-signature2 header in each POST request to webhook | ||
* @property [publicKeyUrl1] - Value of public key url retrieved from the x-adobe-public-key1-url header in each POST request to webhook | ||
* @property [publicKeyUrl2] - Value of public key url retrieved from the x-adobe-public-key2-url header in each POST request to webhook | ||
*/ | ||
@@ -276,2 +368,1 @@ declare type SignatureOptions = { | ||
}; | ||
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
224611
3697
675
10