@@ -143,10 +146,12 @@ and max number of retries
* [.updateEventMetadataForProvider(consumerOrgId, projectId, workspaceId, providerId, eventCode, body)](#EventsCoreAPI+updateEventMetadataForProvider) ⇒ Promise.<object>
* [.deleteEventMetadata(consumerOrgId, projectId, workspaceId, providerId, eventCode)](#EventsCoreAPI+deleteEventMetadata) ⇒ Promise.<object>
* [.deleteAllEventMetadata(consumerOrgId, projectId, workspaceId, providerId)](#EventsCoreAPI+deleteAllEventMetadata) ⇒ Promise.<object>
- * [.createWebhookRegistration(consumerOrgId, integrationId, body)](#EventsCoreAPI+createWebhookRegistration) ⇒ Promise.<object>
- * [.getWebhookRegistration(consumerOrgId, integrationId, registrationId)](#EventsCoreAPI+getWebhookRegistration) ⇒ Promise.<object>
- * [.getAllWebhookRegistrations(consumerOrgId, integrationId)](#EventsCoreAPI+getAllWebhookRegistrations) ⇒ Promise.<object>
- * [.deleteWebhookRegistration(consumerOrgId, integrationId, registrationId)](#EventsCoreAPI+deleteWebhookRegistration) ⇒ Promise.<object>
+ * [.createRegistration(consumerOrgId, projectId, workspaceId, body)](#EventsCoreAPI+createRegistration) ⇒ Promise.<object>
+ * [.updateRegistration(consumerOrgId, projectId, workspaceId, registrationId, body)](#EventsCoreAPI+updateRegistration) ⇒ Promise.<object>
+ * [.getRegistration(consumerOrgId, projectId, workspaceId, registrationId)](#EventsCoreAPI+getRegistration) ⇒ Promise.<object>
+ * [.getAllRegistrationsForWorkspace(consumerOrgId, projectId, workspaceId)](#EventsCoreAPI+getAllRegistrationsForWorkspace) ⇒ Promise.<object>
+ * [.getAllRegistrationsForOrg(consumerOrgId, [page])](#EventsCoreAPI+getAllRegistrationsForOrg) ⇒ Promise.<object>
+ * [.deleteRegistration(consumerOrgId, projectId, workspaceId, registrationId)](#EventsCoreAPI+deleteRegistration) ⇒ Promise.<object>
* [.publishEvent(cloudEvent)](#EventsCoreAPI+publishEvent) ⇒ Promise.<string>
* [.getEventsFromJournal(journalUrl, [eventsJournalOptions], [fetchResponseHeaders])](#EventsCoreAPI+getEventsFromJournal) ⇒ Promise.<object>
* [.getEventsObservableFromJournal(journalUrl, [eventsJournalOptions], [eventsJournalPollingOptions])](#EventsCoreAPI+getEventsObservableFromJournal) ⇒ Observable
@@ -351,9 +356,9 @@ Delete all event metadata of a provider
| workspaceId | string | Workspace Id from the console |
| providerId | string | provider for which the event metadata is to be updated |
-
+
-### eventsCoreAPI.createWebhookRegistration(consumerOrgId, integrationId, body) ⇒ Promise.<object>
+### eventsCoreAPI.createRegistration(consumerOrgId, projectId, workspaceId, body) ⇒ Promise.<object>
Create a webhook or journal registration
**Kind**: instance method of [EventsCoreAPI](#EventsCoreAPI)
@@ -362,12 +367,29 @@ Create a webhook or journal registration
| Param | Type | Description |
| --- | --- | --- |
| consumerOrgId | string | Consumer Org Id from the console |
-| integrationId | string | integration Id from the console |
+| projectId | string | Project Id from the console |
+| workspaceId | string | Workspace Id from the console |
+| body | object | Json data contains details of the registration |
+
+
+
+### eventsCoreAPI.updateRegistration(consumerOrgId, projectId, workspaceId, registrationId, body) ⇒ Promise.<object>
+Update a webhook or journal registration
+
+**Kind**: instance method of [EventsCoreAPI](#EventsCoreAPI)
+**Returns**: Promise.<object> - Details of the webhook/journal registration to be updated
+
+| Param | Type | Description |
+| --- | --- | --- |
+| consumerOrgId | string | Consumer Org Id from the console |
+| projectId | string | Project Id from the console |
+| workspaceId | string | Workspace Id from the console |
+| registrationId | string | Registration id whose details are to be fetched |
| body | object | Json data contains details of the registration |
-
+
-### eventsCoreAPI.getWebhookRegistration(consumerOrgId, integrationId, registrationId) ⇒ Promise.<object>
+### eventsCoreAPI.getRegistration(consumerOrgId, projectId, workspaceId, registrationId) ⇒ Promise.<object>
Get registration details for a given registration
**Kind**: instance method of [EventsCoreAPI](#EventsCoreAPI)
@@ -376,13 +398,14 @@ Get registration details for a given registration
| Param | Type | Description |
| --- | --- | --- |
| consumerOrgId | string | Consumer Org Id from the console |
-| integrationId | string | Integration Id from the console |
+| projectId | string | Project Id from the console |
+| workspaceId | string | Workspace Id from the console |
| registrationId | string | Registration id whose details are to be fetched |
-
+
-### eventsCoreAPI.getAllWebhookRegistrations(consumerOrgId, integrationId) ⇒ Promise.<object>
-Get all registration details for a given integration
+### eventsCoreAPI.getAllRegistrationsForWorkspace(consumerOrgId, projectId, workspaceId) ⇒ Promise.<object>
+Get all registration details for a workspace
**Kind**: instance method of [EventsCoreAPI](#EventsCoreAPI)
**Returns**: Promise.<object> - List of all webhook/journal registrations
@@ -390,11 +413,25 @@ Get all registration details for a given integration
| Param | Type | Description |
| --- | --- | --- |
| consumerOrgId | string | Consumer Org Id from the console |
-| integrationId | string | Integration Id from the console |
+| projectId | string | Project Id from the console |
+| workspaceId | string | Workspace Id from the console |
+
+
+
+### eventsCoreAPI.getAllRegistrationsForOrg(consumerOrgId, [page]) ⇒ Promise.<object>
+Get all registration details for an org
+
+**Kind**: instance method of [EventsCoreAPI](#EventsCoreAPI)
+**Returns**: Promise.<object> - Paginated response of all webhook/journal registrations for an org
+
+| Param | Type | Description |
+| --- | --- | --- |
+| consumerOrgId | string | Consumer Org Id from the console |
+| [page] | [Page](#Page) | page size and page number |
-
+
-### eventsCoreAPI.deleteWebhookRegistration(consumerOrgId, integrationId, registrationId) ⇒ Promise.<object>
+### eventsCoreAPI.deleteRegistration(consumerOrgId, projectId, workspaceId, registrationId) ⇒ Promise.<object>
Delete webhook registration
**Kind**: instance method of [EventsCoreAPI](#EventsCoreAPI)
@@ -403,7 +440,8 @@ Delete webhook registration
| Param | Type | Description |
| --- | --- | --- |
| consumerOrgId | string | Consumer Org Id from the console |
-| integrationId | string | Integration Id from the console |
+| projectId | string | Project Id from the console |
+| workspaceId | string | Workspace Id from the console |
| registrationId | string | Id of the registration to be deleted |
@@ -411,7 +449,7 @@ Delete webhook registration
### eventsCoreAPI.publishEvent(cloudEvent) ⇒ Promise.<string>
Publish Cloud Events
-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.
If retries are set, publish events are retried on network issues, 5xx and 429 error response codes.
@@ -496,6 +534,17 @@ Returns a Promise that resolves with a new EventsCoreAPI object.
| [eventsBaseURL] | string | Base URL for Events Default https://api.adobe.io (optional) |
| [eventsIngressURL] | string | Ingress URL for Events. Default https://eventsingress.adobe.io (optional) |
+
+
+## Page : object
+**Kind**: global typedef
+**Properties**
+
+| Name | Type | Description |
+| --- | --- | --- |
+| [page] | number | page number to be fetched. Default 0 (optional) |
+| [size] | number | size of each page. Default 10 (optional) |
+
## EventsJournalOptions : object
diff --git a/package.json b/package.json
index be96c32..913abc2 100644
--- a/package.json
+++ b/package.json
@@ -14,7 +14,8 @@
"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 .",
- "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"
},
"dependencies": {
"@adobe/aio-lib-core-errors": "^3.1.1",
@@ -48,7 +49,7 @@
"jest-junit": "^10.0.0",
"jest-plugin-fs": "^2.9.0",
"jsdoc": "^3.6.7",
- "jsdoc-to-markdown": "^5.0.3",
+ "jsdoc-to-markdown": "^7.1.1",
"openapi-schema-validator": "^3.0.3",
"querystring": "^0.2.0",
"stdout-stderr": "^0.1.13",
diff --git a/types.d.ts b/types.d.ts
index 7e2749d..2ff0880 100644
--- a/types.d.ts
+++ b/types.d.ts
@@ -12,224 +12,248 @@ declare type EventsCoreAPIOptions = {
/**
* 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} 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
*/
declare function init(organizationId: string, apiKey: string, accessToken: string, httpOptions?: EventsCoreAPIOptions): Promise;
/**
* This class provides methods to call your Adobe I/O Events APIs.
* 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
*/
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} 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;
- /** 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
*/
accessToken: string;
/**
* Fetch all the providers
- *
- * @param {string} consumerOrgId Consumer Org Id from the console
- * @returns {Promise} Returns list of providers for the org
+ * @param consumerOrgId - Consumer Org Id from the console
+ * @returns Returns list of providers for the org
*/
getAllProviders(consumerOrgId: string): Promise;
/**
* 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} 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
*/
getProvider(providerId: string, fetchEventMetadata?: boolean): Promise;
/**
* 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} 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;
/**
* 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} 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;
/**
* 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} 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
*/
deleteProvider(consumerOrgId: string, projectId: string, workspaceId: string, providerId: string): Promise;
/**
* 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} 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
*/
getAllEventMetadataForProvider(providerId: string): Promise;
/**
* 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} 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
*/
getEventMetadataForProvider(providerId: string, eventCode: string): Promise;
/**
* 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} 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;
/**
* 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} 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;
/**
* 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} 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
*/
deleteEventMetadata(consumerOrgId: string, projectId: string, workspaceId: string, providerId: string, eventCode: string): Promise;
/**
* 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} 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
*/
deleteAllEventMetadata(consumerOrgId: string, projectId: string, workspaceId: string, providerId: string): Promise;
/**
* 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} 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
+ */
+ createRegistration(consumerOrgId: string, projectId: string, workspaceId: string, body: any): Promise;
+ /**
+ * 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
*/
- createWebhookRegistration(consumerOrgId: string, integrationId: string, body: any): Promise;
+ updateRegistration(consumerOrgId: string, projectId: string, workspaceId: string, registrationId: string, body: any): Promise;
/**
* 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} 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;
+ getRegistration(consumerOrgId: string, projectId: string, workspaceId: string, registrationId: string): Promise;
/**
- * 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} 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
+ */
+ getAllRegistrationsForWorkspace(consumerOrgId: string, projectId: string, workspaceId: string): Promise;
+ /**
+ * 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
*/
- getAllWebhookRegistrations(consumerOrgId: string, integrationId: string): Promise;
+ getAllRegistrationsForOrg(consumerOrgId: string, page?: Page): Promise;
/**
* 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} 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;
+ deleteRegistration(consumerOrgId: string, projectId: string, workspaceId: string, registrationId: string): Promise;
/**
- * 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} 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
*/
publishEvent(cloudEvent: any): Promise;
/**
* 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} 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;
-
+ getEventsFromJournal(journalUrl: string, eventsJournalOptions?: EventsJournalOptions, fetchResponseHeaders?: boolean): Promise;
/**
- * Get observable to start listening to journal events.
+ * getEventsObservableFromJournal returns an RxJS Observable
*
- * @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} observable to which the user can subscribe to in order to listen to events
+ * One can go through the extensive documentation on RxJS in order to learn more
+ * and leverage the various RxJS Operators 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;
-
/**
* 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
*/
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 [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 = {
latest?: boolean;
@@ -238,8 +262,7 @@ declare type EventsJournalOptions = {
};
/**
- * @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)
*/
declare type EventsJournalPollingOptions = {
interval?: number;
@@ -247,10 +270,10 @@ 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
*/
declare type SignatureOptions = {
digiSignature1: string;
@@ -258,4 +281,3 @@ declare type SignatureOptions = {
publicKeyUrl1: string;
publicKeyUrl2: string;
};
-
From 3fc8d2ae449165b5334a80e11aef302957bc4dec Mon Sep 17 00:00:00 2001
From: Sangeetha Krishnan
Date: Tue, 27 Sep 2022 23:36:36 +0530
Subject: [PATCH 4/9] address review comments
---
src/SDKErrors.js | 2 +-
src/index.js | 38 +++++++++++++++++++-------------------
test/index.test.js | 2 +-
3 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/src/SDKErrors.js b/src/SDKErrors.js
index 143d8c1..02f353b 100644
--- a/src/SDKErrors.js
+++ b/src/SDKErrors.js
@@ -60,7 +60,7 @@ 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_REGISTRATION_FOR_ORG', '%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')
diff --git a/src/index.js b/src/index.js
index 8858daa..6a943f9 100644
--- a/src/index.js
+++ b/src/index.js
@@ -122,7 +122,7 @@ class EventsCoreAPI {
const requestOptions = this.__createRequest('GET', headers)
const url = this.__getUrl(`/events/${consumerOrgId}/providers`)
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)
}
/**
@@ -137,7 +137,7 @@ class EventsCoreAPI {
const requestOptions = this.__createRequest('GET', headers)
const url = this.__getUrl(`/events/providers/${providerId}?eventmetadata=${fetchEventMetadata}`)
const sdkDetails = { requestOptions: requestOptions, url: url }
- return this.__handleRequest(url, requestOptions, sdkDetails, codes.ERROR_GET_PROVIDER)
+ return this.__handleRequest(sdkDetails, codes.ERROR_GET_PROVIDER)
}
/**
@@ -155,7 +155,7 @@ class EventsCoreAPI {
JSON.stringify(body))
const url = this.__getUrl(`/events/${consumerOrgId}/${projectId}/${workspaceId}/providers`)
const sdkDetails = { requestOptions: requestOptions, url: url }
- return this.__handleRequest(url, requestOptions, sdkDetails, codes.ERROR_CREATE_PROVIDER)
+ return this.__handleRequest(sdkDetails, codes.ERROR_CREATE_PROVIDER)
}
/**
@@ -174,7 +174,7 @@ class EventsCoreAPI {
JSON.stringify(body))
const url = this.__getUrl(`/events/${consumerOrgId}/${projectId}/${workspaceId}/providers/${providerId}`)
const sdkDetails = { requestOptions: requestOptions, url: url }
- return this.__handleRequest(url, requestOptions, sdkDetails, codes.ERROR_UPDATE_PROVIDER)
+ return this.__handleRequest(sdkDetails, codes.ERROR_UPDATE_PROVIDER)
}
/**
@@ -191,7 +191,7 @@ class EventsCoreAPI {
const requestOptions = this.__createRequest('DELETE', headers)
const url = this.__getUrl(`/events/${consumerOrgId}/${projectId}/${workspaceId}/providers/${providerId}`)
const sdkDetails = { requestOptions: requestOptions, url: url }
- return this.__handleRequest(url, requestOptions, sdkDetails, codes.ERROR_DELETE_PROVIDER)
+ return this.__handleRequest(sdkDetails, codes.ERROR_DELETE_PROVIDER)
}
/**
@@ -211,7 +211,7 @@ class EventsCoreAPI {
const requestOptions = this.__createRequest('GET', headers)
const url = this.__getUrl(`/events/providers/${providerId}/eventmetadata`)
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)
}
/**
@@ -226,7 +226,7 @@ class EventsCoreAPI {
const requestOptions = this.__createRequest('GET', headers)
const url = this.__getUrl(`/events/providers/${providerId}/eventmetadata/${eventCode}`)
const sdkDetails = { requestOptions: requestOptions, url: url }
- return this.__handleRequest(url, requestOptions, sdkDetails, codes.ERROR_GET_EVENTMETADATA)
+ return this.__handleRequest(sdkDetails, codes.ERROR_GET_EVENTMETADATA)
}
/**
@@ -244,7 +244,7 @@ class EventsCoreAPI {
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 }
- return this.__handleRequest(url, requestOptions, sdkDetails, codes.ERROR_CREATE_EVENTMETADATA)
+ return this.__handleRequest(sdkDetails, codes.ERROR_CREATE_EVENTMETADATA)
}
/**
@@ -263,7 +263,7 @@ class EventsCoreAPI {
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 }
- return this.__handleRequest(url, requestOptions, sdkDetails, codes.ERROR_UPDATE_EVENTMETADATA)
+ return this.__handleRequest(sdkDetails, codes.ERROR_UPDATE_EVENTMETADATA)
}
/**
@@ -281,7 +281,7 @@ class EventsCoreAPI {
const requestOptions = this.__createRequest('DELETE', headers)
const url = this.__getUrl(`/events/${consumerOrgId}/${projectId}/${workspaceId}/providers/${providerId}/eventmetadata/${eventCode}`)
const sdkDetails = { requestOptions: requestOptions, url: url }
- return this.__handleRequest(url, requestOptions, sdkDetails, codes.ERROR_DELETE_EVENTMETADATA)
+ return this.__handleRequest(sdkDetails, codes.ERROR_DELETE_EVENTMETADATA)
}
/**
@@ -298,7 +298,7 @@ class EventsCoreAPI {
const requestOptions = this.__createRequest('DELETE', headers)
const url = this.__getUrl(`/events/${consumerOrgId}/${projectId}/${workspaceId}/providers/${providerId}/eventmetadata`)
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)
}
/**
@@ -321,7 +321,7 @@ class EventsCoreAPI {
const requestOptions = this.__createRequest('POST', headers, JSON.stringify(body))
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)
}
/**
@@ -339,7 +339,7 @@ class EventsCoreAPI {
const requestOptions = this.__createRequest('POST', headers, JSON.stringify(body))
const url = this.__getUrl(`/events/${consumerOrgId}/${projectId}/${workspaceId}/registrations/${registrationId}`)
const sdkDetails = { requestOptions: requestOptions, url: url }
- return this.__handleRequest(url, requestOptions, sdkDetails, codes.ERROR_UPDATE_REGISTRATION)
+ return this.__handleRequest(sdkDetails, codes.ERROR_UPDATE_REGISTRATION)
}
/**
@@ -356,7 +356,7 @@ class EventsCoreAPI {
const requestOptions = this.__createRequest('GET', headers)
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)
}
/**
@@ -372,7 +372,7 @@ class EventsCoreAPI {
const requestOptions = this.__createRequest('GET', headers)
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)
}
/**
@@ -393,7 +393,7 @@ class EventsCoreAPI {
const url = this.__getUrl(`/events/${consumerOrgId}/registrations`)
const urlWithQueryParams = helpers.appendQueryParams(url, page)
const sdkDetails = { requestOptions: requestOptions, url: urlWithQueryParams }
- return this.__handleRequest(url, requestOptions, sdkDetails, codes.ERROR_GET_ALL_REGISTRATION_FOR_ORG)
+ return this.__handleRequest(sdkDetails, codes.ERROR_GET_ALL_REGISTRATIONS_FOR_ORG)
}
/**
@@ -410,7 +410,7 @@ class EventsCoreAPI {
const requestOptions = this.__createRequest('DELETE', headers)
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)
}
/**
@@ -590,9 +590,9 @@ class EventsCoreAPI {
* @returns {Promise} returns the json result
* @private
*/
- __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) => {
if (!response.ok) {
sdkDetails.requestId = response.headers.get('x-request-id')
diff --git a/test/index.test.js b/test/index.test.js
index fb33d91..0a1b582 100644
--- a/test/index.test.js
+++ b/test/index.test.js
@@ -419,7 +419,7 @@ describe('Get all registrations for org', () => {
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_REGISTRATION_FOR_ORG(), ['consumerId-2'])
+ await checkErrorResponse(api, new errorSDK.codes.ERROR_GET_ALL_REGISTRATIONS_FOR_ORG(), ['consumerId-2'])
})
})
From abfca520051e06064390b329c6b957d09fa6b406 Mon Sep 17 00:00:00 2001
From: Sangeetha Krishnan
Date: Wed, 28 Sep 2022 10:46:17 +0530
Subject: [PATCH 5/9] update registration to use PUT method
---
src/index.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/index.js b/src/index.js
index 6a943f9..42b2da5 100644
--- a/src/index.js
+++ b/src/index.js
@@ -336,7 +336,7 @@ class EventsCoreAPI {
*/
updateRegistration (consumerOrgId, projectId, workspaceId, registrationId, body) {
const headers = {}
- const requestOptions = this.__createRequest('POST', headers, JSON.stringify(body))
+ 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)
From 7b949aa74f4b1c2ef6e5c399126427de6a4769ef Mon Sep 17 00:00:00 2001
From: Sangeetha Krishnan
Date: Wed, 28 Sep 2022 15:10:19 +0530
Subject: [PATCH 6/9] Make events base url const in test
---
test/index.test.js | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/test/index.test.js b/test/index.test.js
index 0a1b582..4917a07 100644
--- a/test/index.test.js
+++ b/test/index.test.js
@@ -44,8 +44,8 @@ const gOrganizationId = 'test-org'
const gApiKey = 'test-apikey'
const gAccessToken = 'test-token'
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'
// /////////////////////////////////////////////
@@ -374,7 +374,7 @@ describe('Get all registration', () => {
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('https://api.adobe.io/events/consumerId/projectId/workspaceId/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')
@@ -391,7 +391,7 @@ describe('Get a registration', () => {
const sdkClient = await createSdkClient()
exponentialBackoffMockReturnValue(mock.data.createRegistrationResponse, { status: 200, statusText: 'OK' })
const res = await sdkClient.getRegistration('consumerId', 'projectId', 'workspaceId', 'registrationId')
- expect(res._links.self.href).toBe('https://api.adobe.io/events/consumerId/projectId/workspaceId/registrations/registrationId')
+ expect(res._links.self.href).toBe(EVENTS_BASE_URL + '/consumerId/projectId/workspaceId/registrations/registrationId')
expect(res.id).toBe(248723)
expect(res.webhook_status).toBe('verified')
expect(res.enabled).toBe(true)
@@ -408,10 +408,10 @@ describe('Get all registrations for org', () => {
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('https://api.adobe.io/events/consumerId/registrations?page=1&size=2')
- expect(res._links.first.href).toBe('https://api.adobe.io/events/consumerId/registrations?page=0&size=2')
- expect(res._links.last.href).toBe('https://api.adobe.io/events/consumerId/registrations?page=19&size=2')
- expect(res._links.prev.href).toBe('https://api.adobe.io/events/consumerId/registrations?page=0&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)
@@ -437,7 +437,7 @@ describe('Get registration with retries', () => {
expect(e.code).toEqual(error.code)
})
expect(fetchRetry.exponentialBackoff).toHaveBeenCalledWith(
- 'https://api.adobe.io/events/consumerId/projectId/workspaceId/registrations/registrationId',
+ EVENTS_BASE_URL + '/consumerId/projectId/workspaceId/registrations/registrationId',
{
body: undefined,
headers: {
From fdc7bf970c361460831852bffc8f81c8f1b09618 Mon Sep 17 00:00:00 2001
From: Sangeetha Krishnan
Date: Thu, 29 Sep 2022 14:12:12 +0530
Subject: [PATCH 7/9] add registration create and update model typedefs
---
README.md | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++--
src/index.js | 28 ++++++++++++++++++++++++++--
types.d.ts | 49 +++++++++++++++++++++++++++++++++++++++++++++++--
3 files changed, 123 insertions(+), 6 deletions(-)
diff --git a/README.md b/README.md
index 3524da8..460986b 100644
--- a/README.md
+++ b/README.md
@@ -109,6 +109,12 @@ and max number of retries
@@ -369,7 +375,7 @@ Create a webhook or journal registration
| consumerOrgId | string | Consumer Org Id from the console |
| projectId | string | Project Id from the console |
| workspaceId | string | Workspace Id from the console |
-| body | object | Json data contains details of the registration |
+| body | [RegistrationCreateModel](#RegistrationCreateModel) | Json data contains details of the registration |
@@ -385,7 +391,7 @@ Update a webhook or journal registration
| projectId | string | Project Id from the console |
| workspaceId | string | Workspace Id from the console |
| registrationId | string | Registration id whose details are to be fetched |
-| body | object | Json data contains details of the registration |
+| body | [RegistrationUpdateModel](#RegistrationUpdateModel) | Json data contains details of the registration |
@@ -534,6 +540,48 @@ Returns a Promise that resolves with a new EventsCoreAPI object.
| [eventsBaseURL] | string | Base URL for Events Default https://api.adobe.io (optional) |
| [eventsIngressURL] | string | Ingress URL for Events. Default https://eventsingress.adobe.io (optional) |
+
+
+## EventsOfInterest : object
+**Kind**: global typedef
+**Properties**
+
+| Name | Type | Description |
+| --- | --- | --- |
+| provider_id | string | The id of the provider of the events to be subscribed |
+| event_code | string | The requested valid event code belonging to the provider |
+
+
+
+## RegistrationCreateModel : object
+**Kind**: global typedef
+**Properties**
+
+| Name | Type | Description |
+| --- | --- | --- |
+| client_id | string | Client id for which the registration is created |
+| name | string | The name of the registration |
+| description | string | The description of the registration |
+| [webhook_url] | string | A valid webhook url where the events would be delivered for webhook or webhook_batch delivery_type |
+| events_of_interest | [Array.<EventsOfInterest>](#EventsOfInterest) | The events for which the registration is to be subscribed to |
+| delivery_type | string | Delivery type can either be webhook|webhook_batch|journal. |
+| [enabled] | string | Enable or disable the registration. Default true. |
+
+
+
+## RegistrationUpdateModel : object
+**Kind**: global typedef
+**Properties**
+
+| Name | Type | Description |
+| --- | --- | --- |
+| name | string | The name of the registration |
+| description | string | The description of the registration |
+| [webhook_url] | string | A valid webhook url where the events would be delivered for webhook or webhook_batch delivery_type |
+| events_of_interest | [Array.<EventsOfInterest>](#EventsOfInterest) | The events for which the registration is to be subscribed to |
+| delivery_type | string | Delivery type can either be webhook|webhook_batch|journal. |
+| [enabled] | string | Enable or disable the registration. Default true. |
+
## Page : object
diff --git a/src/index.js b/src/index.js
index 42b2da5..70337fb 100644
--- a/src/index.js
+++ b/src/index.js
@@ -307,13 +307,28 @@ class EventsCoreAPI {
* =========================================================================
*/
+ /**
+ * @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.} 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} projectId Project Id from the console
* @param {string} workspaceId Workspace Id from the console
- * @param {object} body Json data contains details of the registration
+ * @param {RegistrationCreateModel} body Json data contains details of the registration
* @returns {Promise} Details of the webhook/journal registration created
*/
createRegistration (consumerOrgId, projectId, workspaceId, body) {
@@ -324,6 +339,15 @@ class EventsCoreAPI {
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.} 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
*
@@ -331,7 +355,7 @@ class EventsCoreAPI {
* @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 {object} body Json data contains details of the registration
+ * @param {RegistrationUpdateModel} body Json data contains details of the registration
* @returns {Promise} Details of the webhook/journal registration to be updated
*/
updateRegistration (consumerOrgId, projectId, workspaceId, registrationId, body) {
diff --git a/types.d.ts b/types.d.ts
index 2ff0880..b2acdf3 100644
--- a/types.d.ts
+++ b/types.d.ts
@@ -154,7 +154,7 @@ declare class EventsCoreAPI {
* @param body - Json data contains details of the registration
* @returns Details of the webhook/journal registration created
*/
- createRegistration(consumerOrgId: string, projectId: string, workspaceId: string, body: any): Promise;
+ createRegistration(consumerOrgId: string, projectId: string, workspaceId: string, body: RegistrationCreateModel): Promise;
/**
* Update a webhook or journal registration
* @param consumerOrgId - Consumer Org Id from the console
@@ -164,7 +164,7 @@ declare class EventsCoreAPI {
* @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: any): Promise;
+ updateRegistration(consumerOrgId: string, projectId: string, workspaceId: string, registrationId: string, body: RegistrationUpdateModel): Promise;
/**
* Get registration details for a given registration
* @param consumerOrgId - Consumer Org Id from the console
@@ -241,6 +241,51 @@ declare class EventsCoreAPI {
verifyDigitalSignatureForEvent(event: any, recipientClientId: string, signatureOptions?: SignatureOptions): boolean;
}
+/**
+ * @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)
From 82ff1edcdb94ef6929309147aca8bccf7cfd4720 Mon Sep 17 00:00:00 2001
From: Sangeetha Krishnan
Date: Thu, 29 Sep 2022 14:16:43 +0530
Subject: [PATCH 8/9] add typedefs for Provider and EventMetadata input models
---
README.md | 37 +++++++++++++++++++++++++++++++++----
src/index.js | 21 +++++++++++++++++----
types.d.ts | 32 ++++++++++++++++++++++++++++----
3 files changed, 78 insertions(+), 12 deletions(-)
diff --git a/README.md b/README.md
index 460986b..6fe6f87 100644
--- a/README.md
+++ b/README.md
@@ -109,6 +109,10 @@ and max number of retries
@@ -240,7 +244,7 @@ Create a new provider given the provider details
| consumerOrgId | string | Consumer Org Id from the console |
| projectId | string | Project Id from the console |
| workspaceId | string | Workspace Id from the console |
-| body | object | Json data that describes the provider |
+| body | [ProviderInputModel](#ProviderInputModel) | Json data that describes the provider |
@@ -256,7 +260,7 @@ Update a provider given the id and provider details
| projectId | string | Project Id from the console |
| workspaceId | string | Workspace Id from the console |
| providerId | string | The id that uniquely identifies the provider to be updated |
-| body | object | Json data that describes the provider |
+| body | [ProviderInputModel](#ProviderInputModel) | Json data that describes the provider |
@@ -312,7 +316,7 @@ Create an event metadata for a provider
| projectId | string | Project Id from the console |
| workspaceId | string | Workspace Id from the console |
| providerId | string | provider for which the event metadata is to be added |
-| body | object | Json data that describes the event metadata |
+| body | [EventMetadataInputModel](#EventMetadataInputModel) | Json data that describes the event metadata |
@@ -329,7 +333,7 @@ Update the event metadata for a provider
| workspaceId | string | Workspace Id from the console |
| providerId | string | provider for which the event metadata is to be updated |
| eventCode | string | eventCode of the event metadata to be updated |
-| body | object | Json data that describes the event metadata |
+| body | [EventMetadataInputModel](#EventMetadataInputModel) | Json data that describes the event metadata |
@@ -540,6 +544,31 @@ Returns a Promise that resolves with a new EventsCoreAPI object.
| [eventsBaseURL] | string | Base URL for Events Default https://api.adobe.io (optional) |
| [eventsIngressURL] | string | Ingress URL for Events. Default https://eventsingress.adobe.io (optional) |
+
+
+## ProviderInputModel : object
+**Kind**: global typedef
+**Properties**
+
+| Name | Type | Description |
+| --- | --- | --- |
+| label | string | The label of this Events Provider |
+| [description] | string | The description of this Events Provider |
+| [docs_url] | string | The documentation url of this Events Provider |
+
+
+
+## EventMetadataInputModel : object
+**Kind**: global typedef
+**Properties**
+
+| Name | Type | Description |
+| --- | --- | --- |
+| label | string | The description of this Event Metadata |
+| description | string | The label of this Event Metadata |
+| event_code | string | 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] | string | An optional base64 encoded sample event template |
+
## EventsOfInterest : object
diff --git a/src/index.js b/src/index.js
index 70337fb..4a26b51 100644
--- a/src/index.js
+++ b/src/index.js
@@ -140,13 +140,19 @@ class EventsCoreAPI {
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
*
* @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
+ * @param {ProviderInputModel} body Json data that describes the provider
* @returns {Promise} Returns the details of the provider created
*/
createProvider (consumerOrgId, projectId, workspaceId, body) {
@@ -165,7 +171,7 @@ class EventsCoreAPI {
* @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
+ * @param {ProviderInputModel} body Json data that describes the provider
* @returns {Promise} Returns the details of the provider updated
*/
updateProvider (consumerOrgId, projectId, workspaceId, providerId, body) {
@@ -229,6 +235,13 @@ class EventsCoreAPI {
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
*
@@ -236,7 +249,7 @@ class EventsCoreAPI {
* @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
+ * @param {EventMetadataInputModel} body Json data that describes the event metadata
* @returns {Promise} Details of the event metadata created
*/
createEventMetadataForProvider (consumerOrgId, projectId, workspaceId, providerId, body) {
@@ -255,7 +268,7 @@ class EventsCoreAPI {
* @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
+ * @param {EventMetadataInputModel} body Json data that describes the event metadata
* @returns {Promise} Details of the event metadata updated
*/
updateEventMetadataForProvider (consumerOrgId, projectId, workspaceId, providerId, eventCode, body) {
diff --git a/types.d.ts b/types.d.ts
index b2acdf3..3660983 100644
--- a/types.d.ts
+++ b/types.d.ts
@@ -73,7 +73,7 @@ declare class EventsCoreAPI {
* @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;
+ createProvider(consumerOrgId: string, projectId: string, workspaceId: string, body: ProviderInputModel): Promise;
/**
* Update a provider given the id and provider details
* @param consumerOrgId - Consumer Org Id from the console
@@ -83,7 +83,7 @@ declare class EventsCoreAPI {
* @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;
+ updateProvider(consumerOrgId: string, projectId: string, workspaceId: string, providerId: string, body: ProviderInputModel): Promise;
/**
* Delete a provider given the id
* @param consumerOrgId - Consumer Org Id from the console
@@ -115,7 +115,7 @@ declare class EventsCoreAPI {
* @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;
+ createEventMetadataForProvider(consumerOrgId: string, projectId: string, workspaceId: string, providerId: string, body: EventMetadataInputModel): Promise;
/**
* Update the event metadata for a provider
* @param consumerOrgId - Consumer Org Id from the console
@@ -126,7 +126,7 @@ declare class EventsCoreAPI {
* @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;
+ updateEventMetadataForProvider(consumerOrgId: string, projectId: string, workspaceId: string, providerId: string, eventCode: string, body: EventMetadataInputModel): Promise;
/**
* Delete an event metadata of a provider
* @param consumerOrgId - Consumer Org Id from the console
@@ -241,6 +241,30 @@ declare class EventsCoreAPI {
verifyDigitalSignatureForEvent(event: any, recipientClientId: string, signatureOptions?: SignatureOptions): boolean;
}
+/**
+ * @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
From 6cc5908ddc09bf775808eeea48ec151bf549d0eb Mon Sep 17 00:00:00 2001
From: Sangeetha Krishnan
Date: Wed, 5 Oct 2022 15:03:08 +0530
Subject: [PATCH 9/9] Update README.md
Fix delivery type options Registration create and update models in the Readme file.
---
README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 6fe6f87..eb2235c 100644
--- a/README.md
+++ b/README.md
@@ -593,7 +593,7 @@ Returns a Promise that resolves with a new EventsCoreAPI object.
| description | string | The description of the registration |
| [webhook_url] | string | A valid webhook url where the events would be delivered for webhook or webhook_batch delivery_type |
| events_of_interest | [Array.<EventsOfInterest>](#EventsOfInterest) | The events for which the registration is to be subscribed to |
-| delivery_type | string | Delivery type can either be webhook|webhook_batch|journal. |
+| delivery_type | string | Delivery type can either be webhook, webhook_batch or journal. |
| [enabled] | string | Enable or disable the registration. Default true. |
@@ -608,7 +608,7 @@ Returns a Promise that resolves with a new EventsCoreAPI object.
| description | string | The description of the registration |
| [webhook_url] | string | A valid webhook url where the events would be delivered for webhook or webhook_batch delivery_type |
| events_of_interest | [Array.<EventsOfInterest>](#EventsOfInterest) | The events for which the registration is to be subscribed to |
-| delivery_type | string | Delivery type can either be webhook|webhook_batch|journal. |
+| delivery_type | string | Delivery type can either be webhook, webhook_batch or journal. |
| [enabled] | string | Enable or disable the registration. Default true. |