1.0.0 • Published 4 years ago

aix-event-client v1.0.0

Weekly downloads
-
License
Commercial/Propri...
Repository
github
Last release
4 years ago

aix-event-client

Client library for accessing aix-event-service.

USAGE

import { Auth0Client } from './Auth0Client';
import { AIXEventClient } from 'aix-event-client';
import { Feed } from 'aix-event-client/lib/models/Feed';

let accessToken: string;

try {
    const auth0Client: Auth0Client = Auth0Client.getInstance(
        <string>process.env.AUTH0_TENANT
    );
    accessToken = await auth0Client.getAuthToken(
        <string>process.env.AUTH0_CLIENT_ID,
        <string>process.env.AUTH0_CLIENT_SECRET,
        <string>process.env.AUTH0_AUDIENCE
    );
} catch (err) {
    console.error(err);
    throw new Error('Failed to obtain token from Auth0');
}

const client = new AIXEventClient('http://localhost:3000', accessToken);

try { 
    const feeds:Feed[] = await client.getFeeds();
    // ...
} 
catch(err) { 
    console.error(err);
    throw new Error('Failed to obtain feeds from aix-event-service');
} 

API Docs

AIXEventClient

Client library for interacting with the aix-event-service.

Kind: global class

new AIXEventClient(baseUrl, accessToken, debug)

ParamTypeDescription
baseUrlstringbase URL for the aix-event-service (exclude any version modifiers)
accessTokenstringservice-to-service access token (JWT)
debugbooleanoptional, enable request debugging

Example

const accessToken:string = await auth0client.getAuthToken(...);
const client:AIXEventClient = new AIXEventClient('https://localhost:3000',accessToken);

aixEventClient.heartbeat() ⇒

Ask the service for a current status

Kind: instance method of AIXEventClient
Returns: ServiceStatus

aixEventClient.handleEvent(event) ⇒

Given an Event object, search Triggers for matching Feeds and execute the associated Task.

Kind: instance method of AIXEventClient
Returns: TaskRunnerResult[] - list of results from the Tasks

ParamTypeDescription
eventWebhookModelan event used to find Triggers

aixEventClient.testEvent(event) ⇒

Given an Event object, search Triggers for matching Feeds and return the list of Feed Ids (without executing Tasks)

Kind: instance method of AIXEventClient
Returns: string[] - list of Feed ids

ParamTypeDescription
eventWebhookModelan event use to find Triggers

aixEventClient.getFeeds(opt) ⇒

Return a (possibly filtered) list of Feeds

Kind: instance method of AIXEventClient
Returns: Feed[]

ParamTypeDescription
optobject
opt.tenantstringoptional tenant name to filter by
opt.typestringoptional feed type to filter by
opt.activebooleanoptional active flag to filter by
opt.includeDeletedbooleanoptional flag to include/exclude deleted Feeds

aixEventClient.createFeed(feed) ⇒

Creates a Feed, and returns the result. The Feed you pass in should have a blank 'id'; it will be populated on return.

Kind: instance method of AIXEventClient
Returns: Feed

ParamTypeDescription
feedFeedobject to create

aixEventClient.getFeed(feedId, opt) ⇒

Returns a specific Feed object.

Kind: instance method of AIXEventClient
Returns: Feed

ParamTypeDescription
feedIdstringunique id for the Feed to find
optobject
opt.triggersbooleaninclude associated Trigger objects, default: false
opt.schedulesbooleaninclude associated Schedule objects, default: false
opt.filesbooleaninclude associated File objects, default: false
opt.activitybooleaninclude associated Activity objects, default: false

aixEventClient.updateFeed(feed) ⇒

Updates a Feed object

Kind: instance method of AIXEventClient
Returns: boolean

ParamTypeDescription
feedFeedobject to update

aixEventClient.deleteFeed(feedId) ⇒

Marks a feed as deleted

Kind: instance method of AIXEventClient
Returns: boolean

ParamTypeDescription
feedIdstringunique id for the Feed to remove

aixEventClient.restoreFeed(feedId) ⇒

Restores a previously deleted Feed

Kind: instance method of AIXEventClient
Returns: Feed

ParamTypeDescription
feedIdstringunique id for the Feed to restore
1.0.0

4 years ago