### Basic Usage Example Source: https://github.com/adobe/aio-lib-events/blob/master/README.md An example demonstrating how to initialize the SDK and call a method. ```APIDOC ## Basic Usage Example ```javascript const sdk = require('@adobe/aio-lib-events'); async function exampleUsage() { // Initialize SDK const client = await sdk.init('', '', '', ''); try { // Call a method on the client, e.g., getSomething const result = await client.getSomething({}); console.log(result); } catch (e) { console.error(e); } } ``` ``` -------------------------------- ### Installation Source: https://github.com/adobe/aio-lib-events/blob/master/README.md Install the Adobe I/O Events library using npm. ```APIDOC ## Installation ```bash $ npm install @adobe/aio-lib-events ``` ``` -------------------------------- ### Install Adobe I/O Events Library Source: https://github.com/adobe/aio-lib-events/blob/master/docs/readme_template.md Use npm to install the library. This is the first step before using the SDK. ```bash npm install @adobe/aio-lib-events ``` -------------------------------- ### Get All Registrations for Workspace Source: https://github.com/adobe/aio-lib-events/blob/master/README.md Retrieves all webhook or journal registration details for a given workspace. ```APIDOC ## GET /api/events/registrations?workspaceId={workspaceId} ### Description Get all registration details for a workspace. ### Method GET ### Endpoint /api/events/registrations ### Parameters #### Query Parameters - **consumerOrgId** (string) - Required - Consumer Org Id from the console - **projectId** (string) - Required - Project Id from the console - **workspaceId** (string) - Required - Workspace Id from the console ### Response #### Success Response (200) - **object** - List of all webhook/journal registrations ### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Call SDK Methods Source: https://github.com/adobe/aio-lib-events/blob/master/docs/readme_template.md After initializing the SDK, you can call its methods to interact with the Adobe I/O Events API. This example shows how to call `getSomething` and log the result or any errors. ```javascript const sdk = require('@adobe/aio-lib-events') async function sdkTest() { // initialize sdk const client = await sdk.init('', 'x-api-key', '', '') // call methods try { // get profiles by custom filters const result = await client.getSomething({}) console.log(result) } catch (e) { console.error(e) } } ``` -------------------------------- ### Get All Registrations for Org Source: https://github.com/adobe/aio-lib-events/blob/master/README.md Retrieves all webhook or journal registration details for an organization, with pagination. ```APIDOC ## GET /api/events/registrations?page={page} ### Description Get all registration details for an org. ### Method GET ### Endpoint /api/events/registrations ### Parameters #### Query Parameters - **consumerOrgId** (string) - Required - Consumer Org Id from the console - **page** (Page) - Optional - page size and page number ### Response #### Success Response (200) - **object** - Paginated response of all webhook/journal registrations for an org ### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Get Registration Details Source: https://github.com/adobe/aio-lib-events/blob/master/README.md Retrieves the details for a specific webhook or journal registration. ```APIDOC ## GET /api/events/registrations/{registrationId} ### Description Get registration details for a given registration. ### Method GET ### Endpoint /api/events/registrations/{registrationId} ### Parameters #### Path Parameters - **consumerOrgId** (string) - Required - Consumer Org Id from the console - **projectId** (string) - Required - Project Id from the console - **workspaceId** (string) - Required - Workspace Id from the console - **registrationId** (string) - Required - Registration id whose details are to be fetched ### Response #### Success Response (200) - **object** - Details of the webhook/journal registration ### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Event Journaling with Poller Source: https://github.com/adobe/aio-lib-events/blob/master/README.md Example of using the poller for event journaling to subscribe to events. ```APIDOC ## Event Journaling with Poller ```javascript const sdk = require('@adobe/aio-lib-events'); async function journalEvents() { // Initialize SDK const client = await sdk.init('', '', '', ''); // Get the journalling observable const journalling = client.getEventsObservableFromJournal('', ''); // Subscribe to events const subscription = journalling.subscribe({ next: (event) => console.log('Received event:', event), // Action on event error: (err) => console.error('Error:', err), // Action on error complete: () => console.log('Journaling complete') // Action on completion }); // Optional: Unsubscribe after a timeout setTimeout(() => { subscription.unsubscribe(); console.log('Unsubscribed from journal.'); }, ); } ``` **Note:** One observable can have multiple subscribers. Each subscription can be handled differently. For more details, refer to the `getEventsObservableFromJournal` documentation. ``` -------------------------------- ### Get All Event Metadata for a Provider Source: https://github.com/adobe/aio-lib-events/blob/master/README.md Retrieves all event metadata associated with a specific provider. ```APIDOC ## GET /api/events/core/providers/{providerId}/metadata ### Description Get all event metadata for a provider. ### Method GET ### Endpoint /api/events/core/providers/{providerId}/metadata ### Parameters #### Path Parameters - **providerId** (string) - Required - The id that uniquely identifies the provider whose event metadata is to be fetched ### Response #### Success Response (200) - **object** - List of all event metadata of the provider ``` -------------------------------- ### Get Registration Details Source: https://context7.com/adobe/aio-lib-events/llms.txt Retrieves details of a specific registration by its ID. Requires consumer organization, project, workspace, and registration IDs. ```javascript async function getRegistration(client) { const consumerOrgId = 'consumer-org-id-123' const projectId = 'project-id-456' const workspaceId = 'workspace-id-789' const registrationId = 'reg-id-abc123' try { const registration = await client.getRegistration( consumerOrgId, projectId, workspaceId, registrationId ) console.log('Registration:', JSON.stringify(registration, null, 2)) return registration } catch (error) { console.error('Error fetching registration:', error.message) throw error } } // Expected output: // { // "registration_id": "reg-id-abc123", // "name": "My Webhook Registration", // "delivery_type": "webhook", // "enabled": true // } ``` -------------------------------- ### Get Provider Source: https://context7.com/adobe/aio-lib-events/llms.txt Fetches a single provider by its unique identifier with optional event metadata. ```APIDOC ## Get Provider Fetches a single provider by its unique identifier with optional event metadata. ### Method GET ### Endpoint /api/events/providers/{providerId} ### Parameters #### Path Parameters - **providerId** (string) - Required - The unique identifier of the provider. #### Query Parameters - **fetchEventMetadata** (boolean) - Optional - If true, includes associated event metadata. ### Request Example ```javascript // Fetch provider without event metadata client.getProvider('provider-id-123') // Fetch provider with event metadata client.getProvider('provider-id-123', true) ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier of the provider. - **label** (string) - The display name of the provider. - **description** (string) - A description of the provider. - **docs_url** (string) - URL to the provider's documentation. - **_embedded.eventmetadata** (array) - (Optional) An array of event metadata objects if `fetchEventMetadata` is true. #### Response Example ```json { "id": "provider-id-123", "label": "My Custom Provider", "description": "Custom events provider", "docs_url": "https://example.com/docs/events", "_embedded": { "eventmetadata": [...] } } ``` ``` -------------------------------- ### Get All Registrations for Organization with Pagination Source: https://context7.com/adobe/aio-lib-events/llms.txt Retrieves all registrations across an organization, supporting pagination for handling large numbers of registrations. Use 'page' and 'size' parameters to control the results. ```javascript async function getAllRegistrationsForOrg(client) { const consumerOrgId = 'consumer-org-id-123' try { // First page const page1 = await client.getAllRegistrationsForOrg(consumerOrgId, { page: 0, size: 10 }) console.log('Page 1:', JSON.stringify(page1, null, 2)) // Second page const page2 = await client.getAllRegistrationsForOrg(consumerOrgId, { page: 1, size: 10 }) console.log('Page 2:', JSON.stringify(page2, null, 2)) return page1 } catch (error) { console.error('Error fetching registrations:', error.message) throw error } } // Expected output: // { // "_embedded": { // "registrations": [...] // }, // "page": { "size": 10, "number": 0, "totalElements": 25 } // } ``` -------------------------------- ### Get All Event Metadata for a Provider Source: https://context7.com/adobe/aio-lib-events/llms.txt Retrieves all event types (metadata) registered for a specific provider. Requires the provider ID. ```javascript async function getAllEventMetadata(client) { const providerId = 'provider-id-123' try { const eventMetadata = await client.getAllEventMetadataForProvider(providerId) console.log('Event Metadata:', JSON.stringify(eventMetadata, null, 2)) return eventMetadata } catch (error) { console.error('Error fetching event metadata:', error.message) throw error } } ``` -------------------------------- ### Get All Event Providers Source: https://context7.com/adobe/aio-lib-events/llms.txt Fetches all event providers for a consumer organization. Supports fetching associated event metadata and filtering by provider metadata IDs. Requires a valid client instance and consumer organization ID. ```javascript async function getAllProviders(client) { const consumerOrgId = 'consumer-org-id-123' try { const providers = await client.getAllProviders(consumerOrgId) console.log('Providers:', JSON.stringify(providers, null, 2)) const filteredProviders = await client.getAllProviders(consumerOrgId, { fetchEventMetadata: true, filterBy: { providerMetadataIds: ['metadata-id-1', 'metadata-id-2'] } }) console.log('Filtered Providers:', JSON.stringify(filteredProviders, null, 2)) return providers } catch (error) { console.error('Error fetching providers:', error.message) throw error } } ``` -------------------------------- ### Get Provider Metadata API Source: https://context7.com/adobe/aio-lib-events/llms.txt Retrieves all entitled provider metadata for the organization. ```APIDOC ## Get Provider Metadata ### Description Retrieves all entitled provider metadata for the organization. ### Method GET ### Endpoint /api/v1/events/providermetadata ### Parameters No parameters required. ### Response #### Success Response (200) - **_embedded.providermetadata** (array) - An array of provider metadata objects. - **id** (string) - The unique identifier of the provider metadata. - **label** (string) - The label of the provider metadata. #### Response Example ```json { "_embedded": { "providermetadata": [ { "id": "metadata-id", "label": "Adobe Analytics", ... } ] } } ``` ``` -------------------------------- ### Get All Provider Metadata Source: https://context7.com/adobe/aio-lib-events/llms.txt Retrieves all entitled provider metadata for the organization. No specific IDs are required for this operation. ```javascript async function getProviderMetadata(client) { try { const metadata = await client.getProviderMetadata() console.log('Provider Metadata:', JSON.stringify(metadata, null, 2)) return metadata } catch (error) { console.error('Error fetching provider metadata:', error.message) throw error } } ``` -------------------------------- ### Get All Providers Source: https://context7.com/adobe/aio-lib-events/llms.txt Fetches all event providers available for a consumer organization. Supports filtering by provider metadata ID and optionally fetching associated event metadata. ```APIDOC ## Get All Providers Fetches all event providers available for a consumer organization. Supports filtering by provider metadata ID and optionally fetching associated event metadata. ### Method GET ### Endpoint /api/events/providers ### Parameters #### Query Parameters - **consumerOrgId** (string) - Required - The ID of the consumer organization. - **fetchEventMetadata** (boolean) - Optional - If true, includes associated event metadata. - **filterBy.providerMetadataIds** (array of strings) - Optional - Filters providers by a list of provider metadata IDs. ### Request Example ```javascript // Basic fetch client.getAllProviders('consumer-org-id-123') // With event metadata and filtering client.getAllProviders('consumer-org-id-123', { fetchEventMetadata: true, filterBy: { providerMetadataIds: ['metadata-id-1', 'metadata-id-2'] } }) ``` ### Response #### Success Response (200) - **_embedded.providers** (array) - An array of provider objects. - **id** (string) - The unique identifier of the provider. - **label** (string) - The display name of the provider. - **description** (string) - A description of the provider. - **_embedded.eventmetadata** (array) - (Optional) An array of event metadata objects if `fetchEventMetadata` is true. #### Response Example ```json { "_embedded": { "providers": [ { "id": "provider-id-123", "label": "My Provider", "description": "...", "_embedded": { "eventmetadata": [...] } } ] } } ``` ``` -------------------------------- ### Get All Registrations for Workspace Source: https://context7.com/adobe/aio-lib-events/llms.txt Retrieves all registrations within a specified workspace. This function is useful for auditing or managing registrations at the workspace level. ```javascript async function getAllRegistrationsForWorkspace(client) { const consumerOrgId = 'consumer-org-id-123' const projectId = 'project-id-456' const workspaceId = 'workspace-id-789' try { const registrations = await client.getAllRegistrationsForWorkspace( consumerOrgId, projectId, workspaceId ) console.log('Registrations:', JSON.stringify(registrations, null, 2)) return registrations } catch (error) { console.error('Error fetching registrations:', error.message) throw error } } // Expected output: // { // "_embedded": { // "registrations": [ // { "registration_id": "reg-1", "name": "Webhook 1", ... }, // { "registration_id": "reg-2", "name": "Journal 1", ... } // ] // } // } ``` -------------------------------- ### Get Events from Journal Source: https://github.com/adobe/aio-lib-events/blob/master/README.md Retrieve events from a journal using a provided URL and optional query parameters. ```APIDOC ## GET /journal ### Description Get events from a journal. This method allows fetching events from a specified journal URL, with options for query parameters and fetching response headers. ### Method GET ### Endpoint /journal ### Parameters #### Query Parameters - **journalUrl** (string) - Required - URL of the journal or 'next' link to read from - **eventsJournalOptions** (EventsJournalOptions) - Optional - Query options to send with the URL - **fetchResponseHeaders** (boolean) - Optional - Set this to true if you want to fetch the complete response headers ### Response #### Success Response (200) - **object** - with the response json includes events and links (if available) #### Response Example ```json { "events": [ { "id": "event-id-1", "data": { "message": "Event 1 data" } }, { "id": "event-id-2", "data": { "message": "Event 2 data" } } ], "links": { "next": "/journal?cursor=next-cursor" } } ``` ``` -------------------------------- ### Get All Event Metadata for Provider API Source: https://context7.com/adobe/aio-lib-events/llms.txt Retrieves all event types (metadata) registered for a specific provider. ```APIDOC ## Get All Event Metadata for Provider ### Description Retrieves all event types (metadata) registered for a specific provider. ### Method GET ### Endpoint /api/v1/events/providers/{providerId}/eventmetadata ### Parameters #### Path Parameters - **providerId** (string) - Required - The unique identifier of the provider. ### Response #### Success Response (200) - **_embedded.eventmetadata** (array) - An array of event metadata objects. - **event_code** (string) - The code of the event. - **label** (string) - The label of the event. #### Response Example ```json { "_embedded": { "eventmetadata": [ { "event_code": "com.myapp.user.created", "label": "User Created", ... } ] } } ``` ``` -------------------------------- ### Get Event Metadata for a Provider Source: https://github.com/adobe/aio-lib-events/blob/master/README.md Retrieves specific event metadata for a given provider and event code. ```APIDOC ## GET /api/events/core/providers/{providerId}/events/{eventCode}/metadata ### Description Get an event metadata for given provider and event code. ### Method GET ### Endpoint /api/events/core/providers/{providerId}/events/{eventCode}/metadata ### Parameters #### Path Parameters - **providerId** (string) - Required - The id that uniquely identifies the provider whose event metadata is to be fetched - **eventCode** (string) - Required - The specific event code for which the details of the event metadata is to be fetched ### Response #### Success Response (200) - **object** - Event metadata that corresponds to the specified event code ``` -------------------------------- ### Get Specific Event Metadata for a Provider Source: https://context7.com/adobe/aio-lib-events/llms.txt Retrieves a specific event type by its event code for a given provider. Requires both provider ID and event code. ```javascript async function getEventMetadata(client) { const providerId = 'provider-id-123' const eventCode = 'com.myapp.user.created' try { const eventMetadata = await client.getEventMetadataForProvider(providerId, eventCode) console.log('Event Metadata:', JSON.stringify(eventMetadata, null, 2)) return eventMetadata } catch (error) { console.error('Error fetching event metadata:', error.message) throw error } } ``` -------------------------------- ### Get Events from Journal Source: https://context7.com/adobe/aio-lib-events/llms.txt Retrieves events from a journal registration. Supports pagination via link headers and position-based fetching. The 'latest: true' option fetches the most recent events, while 'since' and 'limit' allow for specific range retrieval. Fetching with 'true' as the last argument returns response headers. ```javascript async function getEventsFromJournal(client) { const journalUrl = 'https://events.adobe.io/events/organizations/org-id/integrations/int-id/journal-reg-id' try { // Get latest events const latestEvents = await client.getEventsFromJournal(journalUrl, { latest: true }) console.log('Latest Events:', JSON.stringify(latestEvents, null, 2)) // Get events from a specific position with limit const eventsFromPosition = await client.getEventsFromJournal(journalUrl, { since: 'position-token-abc123', limit: 100 }) console.log('Events from position:', JSON.stringify(eventsFromPosition, null, 2)) // Follow the next link for more events if (eventsFromPosition.link && eventsFromPosition.link.next) { const moreEvents = await client.getEventsFromJournal(eventsFromPosition.link.next) console.log('More Events:', JSON.stringify(moreEvents, null, 2)) } // Fetch with response headers const eventsWithHeaders = await client.getEventsFromJournal(journalUrl, {}, true) console.log('Response Headers:', eventsWithHeaders.responseHeaders) return latestEvents } catch (error) { console.error('Error fetching journal events:', error.message) throw error } } // Expected output: // { // "events": [ // { "event_id": "evt-1", "event": { "type": "com.myapp.user.created", ... } } // ], // "link": { "next": "https://events.adobe.io/events/.../journal?since=..." }, // "retryAfter": 2000 // } ``` -------------------------------- ### Get Specific Event Provider Source: https://context7.com/adobe/aio-lib-events/llms.txt Fetches a single event provider by its unique ID. Can optionally include event metadata in the response. Requires a valid client instance and provider ID. ```javascript async function getProvider(client) { const providerId = 'provider-id-123' try { const provider = await client.getProvider(providerId) console.log('Provider:', JSON.stringify(provider, null, 2)) const providerWithMetadata = await client.getProvider(providerId, true) console.log('Provider with metadata:', JSON.stringify(providerWithMetadata, null, 2)) return provider } catch (error) { console.error('Error fetching provider:', error.message) throw error } } ``` -------------------------------- ### init Function Source: https://github.com/adobe/aio-lib-events/blob/master/README.md Initializes the SDK and returns a Promise that resolves with an EventsCoreAPI object. ```APIDOC ## init Function ### Signature `init(organizationId, apiKey, accessToken, [httpOptions])` ### Returns - Returns a Promise that resolves with a new `EventsCoreAPI` object. ``` -------------------------------- ### SDK Initialization Source: https://github.com/adobe/aio-lib-events/blob/master/README.md Initialize the Adobe I/O Events SDK with your credentials. ```APIDOC ## Initialize the SDK ```javascript const sdk = require('@adobe/aio-lib-events') async function initializeSdk() { // Initialize SDK with organization ID, API key, access token, and optional http options const client = await sdk.init('', '', '', ''); return client; } ``` ``` -------------------------------- ### Initialize EventsCoreAPI Source: https://github.com/adobe/aio-lib-events/blob/master/README.md Initializes the EventsCoreAPI SDK with the provided credentials and options. ```APIDOC ## Initialize EventsCoreAPI ### Description Initializes the SDK with organization ID, API key, and access token. ### Method `init` ### Parameters #### Path Parameters - **organizationId** (string) - Required - The organization id from your integration - **apiKey** (string) - Required - The api key from your integration - **accessToken** (string) - Required - JWT Token for the integration with IO Management API scope - **httpOptions** (EventsCoreAPIOptions) - Optional - Options to configure API calls ### Response #### Success Response (200) - **EventsCoreAPI** (Promise) - returns object of the class EventsCoreAPI ``` -------------------------------- ### SDK Initialization Source: https://context7.com/adobe/aio-lib-events/llms.txt Initializes the Adobe I/O Events SDK with authentication credentials. Returns a Promise that resolves with an EventsCoreAPI client instance configured with your organization ID, API key, and access token. ```APIDOC ## SDK Initialization Initializes the Adobe I/O Events SDK with authentication credentials. Returns a Promise that resolves with an EventsCoreAPI client instance configured with your organization ID, API key, and access token. ### Method POST ### Endpoint /api/events/initialize ### Parameters #### Request Body - **organizationId** (string) - Required - The Adobe organization ID. - **apiKey** (string) - Required - The x-api-key from your Adobe I/O integration. - **accessToken** (string) - Required - A valid JWT access token. - **options** (object) - Optional - Configuration options. - **timeout** (number) - Optional - HTTP request timeout in milliseconds. - **retries** (number) - Optional - Retry count for 5xx errors. - **eventsBaseURL** (string) - Optional - Custom base URL for the Events API. - **eventsIngressURL** (string) - Optional - Custom ingress URL for events. ### Request Example ```javascript { "organizationId": "ORGANIZATION_ID@AdobeOrg", "apiKey": "your-api-key", "accessToken": "eyJhbGciOiJSUzI1NiIsInR5cCI6...", "options": { "timeout": 30000, "retries": 3, "eventsBaseURL": "https://api.adobe.io", "eventsIngressURL": "https://eventsingress.adobe.io" } } ``` ### Response #### Success Response (200) - **client** (object) - An initialized EventsCoreAPI client instance. #### Response Example ```json { "message": "SDK initialized successfully" } ``` ``` -------------------------------- ### EventsCoreAPI Initialization Source: https://github.com/adobe/aio-lib-events/blob/master/README.md Initialize the EventsCoreAPI instance with your integration details. This must be done before calling any other methods. ```APIDOC ## EventsCoreAPI Initialization ### Description Initializes the EventsCoreAPI with necessary credentials and optional HTTP configurations. ### Method `init(organizationId, apiKey, accessToken, [httpOptions])` ### Parameters - **organizationId** (string) - Required - The organization ID from your integration. - **apiKey** (string) - Required - The API key for your integration. - **accessToken** (string) - Required - The JWT Token for the integration with IO Management API scope. - **httpOptions** (object) - Optional - HTTP options such as timeout and max number of retries. - **retries** (number) - Optional - The maximum number of retries for HTTP requests. - **timeout** (number) - Optional - The timeout in milliseconds for HTTP requests. ### Returns - A Promise that resolves to the initialized `EventsCoreAPI` instance. ``` -------------------------------- ### Initialize EventsCoreAPI Source: https://github.com/adobe/aio-lib-events/blob/master/README.md Initializes and returns a new EventsCoreAPI object with provided credentials and optional HTTP options. ```APIDOC ## init(organizationId, apiKey, accessToken, [httpOptions]) ### Description Returns a Promise that resolves with a new EventsCoreAPI object. This is the entry point for using the EventsCoreAPI. ### Method init ### Parameters #### Parameters - **organizationId** (string) - Required - The organization id from your integration - **apiKey** (string) - Required - The api key from your integration - **accessToken** (string) - Required - JWT Token for the integration with IO Management API scope - **httpOptions** (EventsCoreAPIOptions) - Optional - Options to configure API calls ### Response #### Success Response - **Promise<EventsCoreAPI>** - returns object of the class EventsCoreAPI #### Response Example ```javascript // Assuming you have your credentials and httpOptions defined const { EventsCoreAPI } = require('@adobe/aio-lib-events'); async function initializeApi() { try { const eventsCoreAPI = await EventsCoreAPI.init(organizationId, apiKey, accessToken, httpOptions); console.log('EventsCoreAPI initialized successfully'); return eventsCoreAPI; } catch (error) { console.error('Error initializing EventsCoreAPI:', error); throw error; } } ``` ``` -------------------------------- ### Initialize Adobe I/O Events SDK Source: https://github.com/adobe/aio-lib-events/blob/master/docs/readme_template.md Initialize the SDK with your organization ID, API key, authentication token, and optional options. This client object is used to interact with the Adobe I/O Events API. ```javascript const sdk = require('@adobe/aio-lib-events') async function sdkTest() { //initialize sdk const client = await sdk.init('', 'x-api-key', '', '') } ``` -------------------------------- ### Get Event Metadata for Provider API Source: https://context7.com/adobe/aio-lib-events/llms.txt Retrieves a specific event type by event code for a provider. ```APIDOC ## Get Event Metadata for Provider ### Description Retrieves a specific event type by event code for a provider. ### Method GET ### Endpoint /api/v1/events/providers/{providerId}/eventmetadata/{eventCode} ### Parameters #### Path Parameters - **providerId** (string) - Required - The unique identifier of the provider. - **eventCode** (string) - Required - The code of the event to retrieve. ### Response #### Success Response (200) - **event_code** (string) - The code of the event. - **label** (string) - The label of the event. - **description** (string) - The description of the event. #### Response Example ```json { "event_code": "com.myapp.user.created", "label": "User Created", "description": "Triggered when a new user is created" } ``` ``` -------------------------------- ### Enable Debug Logs Source: https://github.com/adobe/aio-lib-events/blob/master/docs/readme_template.md Prepend the `LOG_LEVEL` environment variable with the value `debug` to the command that invokes your function. This will output detailed debug information for your SDK calls. ```bash LOG_LEVEL=debug ``` -------------------------------- ### Run E2E Tests Source: https://github.com/adobe/aio-lib-events/blob/master/e2e/README.md Execute the end-to-end tests using the npm script. Ensure all required environment variables are set before running. ```bash npm run e2e ``` -------------------------------- ### Create Registration Source: https://github.com/adobe/aio-lib-events/blob/master/README.md Creates a new webhook or journal registration for events. ```APIDOC ## POST /api/events/registrations ### Description Create a webhook or journal registration. ### Method POST ### Endpoint /api/events/registrations ### Parameters #### Path Parameters - **consumerOrgId** (string) - Required - Consumer Org Id from the console - **projectId** (string) - Required - Project Id from the console - **workspaceId** (string) - Required - Workspace Id from the console #### Request Body - **body** (RegistrationCreateModel) - Required - Json data contains details of the registration ### Response #### Success Response (200) - **object** - Details of the webhook/journal registration created ### Request Example ```json { "example": "request body" } ``` ### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Debug Logs Source: https://github.com/adobe/aio-lib-events/blob/master/README.md Instructions on how to enable debug logging for SDK calls. ```APIDOC ## Debug Logs ### Description Prepend the `LOG_LEVEL` environment variable and `debug` value to the command line call to enable detailed debug output for SDK interactions. ### Usage ```bash LOG_LEVEL=debug ``` ``` -------------------------------- ### Create Custom Event Provider Source: https://context7.com/adobe/aio-lib-events/llms.txt Creates a new custom event provider within a specified workspace. Requires consumer organization ID, project ID, workspace ID, and provider data including label and description. ```javascript async function createProvider(client) { const consumerOrgId = 'consumer-org-id-123' const projectId = 'project-id-456' const workspaceId = 'workspace-id-789' const providerData = { label: 'My Custom Events Provider', description: 'Publishes custom application events', docs_url: 'https://example.com/docs/events' } try { const newProvider = await client.createProvider( consumerOrgId, projectId, workspaceId, providerData ) console.log('Created provider:', JSON.stringify(newProvider, null, 2)) return newProvider } catch (error) { console.error('Error creating provider:', error.message) throw error } } ``` -------------------------------- ### Get Events Observable from Journal Source: https://github.com/adobe/aio-lib-events/blob/master/README.md Returns an RxJS Observable to listen to events from a journal, supporting polling options. ```APIDOC ## GET /journal/observable ### Description getEventsObservableFromJournal returns an RxJS Observable. Users can subscribe to this observable to listen to events and leverage RxJS Operators for event processing. ### Method GET ### Endpoint /journal/observable ### Parameters #### Query Parameters - **journalUrl** (string) - Required - URL of the journal or 'next' link to read from - **eventsJournalOptions** (EventsJournalOptions) - Optional - Query options to send with the Journal URL - **eventsJournalPollingOptions** (EventsJournalPollingOptions) - Optional - Journal polling options ### Response #### Success Response (200) - **Observable** - observable to which the user can subscribe to in order to listen to events #### Response Example ```javascript // Example of subscribing to the observable const eventObservable = eventsCoreAPI.getEventsObservableFromJournal('journal-url'); eventObservable.subscribe( event => console.log('Received event:', event), error => console.error('Error receiving events:', error) ); ``` ``` -------------------------------- ### RegistrationCreateModel Source: https://github.com/adobe/aio-lib-events/blob/master/README.md Model for creating a new event registration. ```APIDOC ## RegistrationCreateModel : object ### 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. | ``` -------------------------------- ### Use Poller for Journalling Source: https://github.com/adobe/aio-lib-events/blob/master/docs/readme_template.md Utilize the `getEventsObservableFromJournal` method to get an observable for journalling events. Subscribe to this observable to receive events, and manage the subscription with `unsubscribe`. ```javascript const sdk = require('@adobe/aio-lib-events') async function sdkTest() { // initialize sdk const client = await sdk.init('', 'x-api-key', '', '') // get the journalling observable const journalling = client.getEventsObservableFromJournal('', '') // call methods const subscription = journalling.subscribe({ next: (v) => console.log(v), // Action to be taken on event error: (e) => console.log(e), // Action to be taken on error complete: () => console.log('Complete') // Action to be taken on complete }) // To stop receiving events from this subscription based on a timeout setTimeout(() => subscription.unsubscribe(), ) } ``` -------------------------------- ### Create Provider Source: https://context7.com/adobe/aio-lib-events/llms.txt Creates a new custom event provider within a workspace. ```APIDOC ## Create Provider Creates a new custom event provider within a workspace. ### Method POST ### Endpoint /api/events/providers ### Parameters #### Request Body - **consumerOrgId** (string) - Required - The ID of the consumer organization. - **projectId** (string) - Required - The ID of the project. - **workspaceId** (string) - Required - The ID of the workspace. - **providerData** (object) - Required - Data for the new provider. - **label** (string) - Required - The display name of the provider. - **description** (string) - Optional - A description of the provider. - **docs_url** (string) - Optional - URL to the provider's documentation. ### Request Example ```javascript const providerData = { label: 'My Custom Events Provider', description: 'Publishes custom application events', docs_url: 'https://example.com/docs/events' } client.createProvider( 'consumer-org-id-123', 'project-id-456', 'workspace-id-789', providerData ) ``` ### Response #### Success Response (201) - **id** (string) - The unique identifier of the newly created provider. - **label** (string) - The display name of the provider. - **description** (string) - A description of the provider. - **docs_url** (string) - URL to the provider's documentation. #### Response Example ```json { "id": "new-provider-id", "label": "My Custom Events Provider", "description": "Publishes custom application events", "docs_url": "https://example.com/docs/events" } ``` ``` -------------------------------- ### Create Event Registration Source: https://context7.com/adobe/aio-lib-events/llms.txt Creates a new registration for receiving events, supporting webhook, webhook_batch, and journal delivery types. Configure `events_of_interest` to specify which events to subscribe to. ```javascript async function createRegistration(client) { const consumerOrgId = 'consumer-org-123' const projectId = 'project-id-456' const workspaceId = 'workspace-id-789' // Webhook registration const webhookRegistration = { client_id: 'your-client-id', name: 'My Webhook Registration', description: 'Receives user events via webhook', webhook_url: 'https://myapp.example.com/webhook/events', events_of_interest: [ { provider_id: 'provider-id-123', event_code: 'com.myapp.user.created' }, { provider_id: 'provider-id-123', event_code: 'com.myapp.user.updated' } ], delivery_type: 'webhook', // or 'webhook_batch' or 'journal' enabled: 'true' } try { const registration = await client.createRegistration( consumerOrgId, projectId, workspaceId, webhookRegistration ) console.log('Created registration:', JSON.stringify(registration, null, 2)) return registration } catch (error) { console.error('Error creating registration:', error.message) throw error } } // Expected output: // { // "registration_id": "reg-id-abc123", // "name": "My Webhook Registration", // "delivery_type": "webhook", // "webhook_url": "https://myapp.example.com/webhook/events", // "events_of_interest": [...], // "enabled": true // } ``` -------------------------------- ### ProviderOptions Source: https://github.com/adobe/aio-lib-events/blob/master/README.md Options for configuring provider retrieval, including event metadata fetching and filtering. ```APIDOC ## ProviderOptions : object ### Properties | Name | Type | Description | | --- | --- | --- | | fetchEventMetadata | boolean | Option to fetch event metadata for each of the the providers in the list | | filterBy | [ProviderFilterOptions](#ProviderFilterOptions) | Provider filtering options based on either (providerMetadataId and instanceId) or list of providerMetadataIds | ``` -------------------------------- ### Get Events Observable from Journal Source: https://context7.com/adobe/aio-lib-events/llms.txt Returns an RxJS Observable for continuously polling events from a journal. Supports automatic polling with configurable intervals. The subscription can be manually unsubscribed, and a timeout is demonstrated for automatic unsubscription. ```javascript async function getEventsObservable(client) { const journalUrl = 'https://events.adobe.io/events/organizations/org-id/integrations/int-id/journal-reg-id' // Get the observable with polling options const journalObservable = client.getEventsObservableFromJournal( journalUrl, { latest: true }, // Journal options { interval: 5000 } // Poll every 5 seconds ) // Subscribe to receive events const subscription = journalObservable.subscribe({ next: (event) => { console.log('Received event:', JSON.stringify(event, null, 2)) // Process the event processEvent(event) }, error: (error) => { console.error('Journal error:', error.message) }, complete: () => { console.log('Journal subscription completed') } }) // Unsubscribe after 60 seconds setTimeout(() => { console.log('Unsubscribing from journal...') subscription.unsubscribe() }, 60000) return subscription } function processEvent(event) { // Your event processing logic here console.log('Processing event type:', event.type) } // Expected output (continuous): // Received event: { "event_id": "evt-1", "type": "com.myapp.user.created", ... } // Processing event type: com.myapp.user.created // Received event: { "event_id": "evt-2", "type": "com.myapp.user.updated", ... } // Processing event type: com.myapp.user.updated // ... ``` -------------------------------- ### EventsCoreAPI Class Source: https://github.com/adobe/aio-lib-events/blob/master/README.md The EventsCoreAPI class provides methods to interact with Adobe I/O Events APIs. It must be initialized before use. ```APIDOC ## EventsCoreAPI Class This class provides methods to call your Adobe I/O Events APIs. Before calling any method, initialize the instance by calling the `init` method with valid values for `organizationId`, `apiKey`, `accessToken`, and optional `httpOptions` (such as timeout and max number of retries). ``` -------------------------------- ### Enable Debug Logging with JavaScript Source: https://context7.com/adobe/aio-lib-events/llms.txt Enables verbose debug logging for troubleshooting SDK operations. Set the LOG_LEVEL environment variable to 'debug' before running your application or programmatically. ```javascript // Enable debug logging via environment variable // Set LOG_LEVEL=debug before running your application // Bash: // LOG_LEVEL=debug node your-app.js // Or programmatically in Node.js: process.env.LOG_LEVEL = 'debug' const sdk = require('@adobe/aio-lib-events') async function runWithDebugLogging() { // All SDK operations will now output debug information const client = await sdk.init( 'ORGANIZATION_ID@AdobeOrg', 'your-api-key', 'your-access-token' ) // Operations will log detailed debug output const providers = await client.getAllProviders('consumer-org-id') console.log('Providers fetched with debug logging enabled') } // Expected debug output: // [DEBUG] @adobe/aio-lib-events: sdk initialized successfully // [DEBUG] @adobe/aio-lib-events: Request: GET https://api.adobe.io/events/... // [DEBUG] @adobe/aio-lib-events: Response: 200 OK ``` -------------------------------- ### Data Types Source: https://github.com/adobe/aio-lib-events/blob/master/README.md Defines the structure for pagination and event journal options. ```APIDOC ## Page Object ### Description Represents pagination options for fetching data. ### Properties - **page** (number) - Optional - Page number to be fetched. Default 0. - **size** (number) - Optional - Size of each page. Default 10. ``` ```APIDOC ## EventsJournalOptions Object ### Description Options for retrieving events from a journal. ### Properties - **latest** (boolean) - Optional - Retrieve latest events. - **since** (string) - Optional - Position at which to start fetching the events from. - **limit** (number) - Optional - Maximum number of events to retrieve. ``` ```APIDOC ## EventsJournalPollingOptions Object ### Description Options for polling the event journal. ### Properties - **interval** (number) - Optional - Interval at which to poll the journal. If not provided, a default value will be used. ``` -------------------------------- ### Create Event Metadata for Provider Source: https://context7.com/adobe/aio-lib-events/llms.txt Creates a new event type for a provider, following CloudEvents type specification. Requires consumer organization, project, workspace, provider IDs, and event metadata details including a base64 encoded sample event. ```javascript async function createEventMetadata(client) { const consumerOrgId = 'consumer-org-id-123' const projectId = 'project-id-456' const workspaceId = 'workspace-id-789' const providerId = 'provider-id-123' const eventMetadataBody = { label: 'User Created Event', description: 'Triggered when a new user is created in the system', event_code: 'com.myapp.user.created', sample_event_template: Buffer.from(JSON.stringify({ userId: '12345', email: 'user@example.com', createdAt: '2024-01-15T10:30:00Z' })).toString('base64') } try { const newEventMetadata = await client.createEventMetadataForProvider( consumerOrgId, projectId, workspaceId, providerId, eventMetadataBody ) console.log('Created event metadata:', JSON.stringify(newEventMetadata, null, 2)) return newEventMetadata } catch (error) { console.error('Error creating event metadata:', error.message) throw error } } ``` -------------------------------- ### ProviderInputModel Source: https://github.com/adobe/aio-lib-events/blob/master/README.md Model for creating or updating an Events Provider. ```APIDOC ## ProviderInputModel : object ### 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 | ``` -------------------------------- ### Create Event Metadata for a Provider Source: https://github.com/adobe/aio-lib-events/blob/master/README.md Creates new event metadata for a specified provider. ```APIDOC ## POST /api/events/core/consumers/{consumerOrgId}/projects/{projectId}/workspaces/{workspaceId}/providers/{providerId}/metadata ### Description Create an event metadata for a provider. ### Method POST ### Endpoint /api/events/core/consumers/{consumerOrgId}/projects/{projectId}/workspaces/{workspaceId}/providers/{providerId}/metadata ### Parameters #### Path Parameters - **consumerOrgId** (string) - Required - Consumer Org Id from the console - **projectId** (string) - Required - Project Id from the console - **workspaceId** (string) - Required - Workspace Id from the console - **providerId** (string) - Required - provider for which the event metadata is to be added #### Request Body - **body** (EventMetadataInputModel) - Required - Json data that describes the event metadata ### Response #### Success Response (200) - **object** - Details of the event metadata created ```