@flatfile/listener 0.3.15 → 0.3.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/event-drivers/Browser.d.ts +18 -0
- package/dist/event-drivers/Browser.d.ts.map +1 -0
- package/dist/event-drivers/FlatfileVirtualMachine.d.ts +18 -0
- package/dist/event-drivers/FlatfileVirtualMachine.d.ts.map +1 -0
- package/dist/event-drivers/Webhook.d.ts +1 -0
- package/dist/event-drivers/Webhook.d.ts.map +1 -0
- package/dist/event-drivers/_EventDriver.d.ts +18 -0
- package/dist/event-drivers/_EventDriver.d.ts.map +1 -0
- package/dist/event-drivers/index.d.ts +4 -0
- package/dist/event-drivers/index.d.ts.map +1 -0
- package/dist/events/authenticated.client.d.ts +15 -0
- package/dist/events/authenticated.client.d.ts.map +1 -0
- package/dist/events/cache.d.ts +8 -0
- package/dist/events/cache.d.ts.map +1 -0
- package/dist/events/event.handler.d.ts +91 -0
- package/dist/events/event.handler.d.ts.map +1 -0
- package/dist/events/event.handler.spec.d.ts +2 -0
- package/dist/events/event.handler.spec.d.ts.map +1 -0
- package/dist/events/flatfile.event.d.ts +69 -0
- package/dist/events/flatfile.event.d.ts.map +1 -0
- package/dist/events/glob.match.d.ts +19 -0
- package/dist/events/glob.match.d.ts.map +1 -0
- package/dist/events/glob.match.spec.d.ts +2 -0
- package/dist/events/glob.match.spec.d.ts.map +1 -0
- package/dist/events/index.d.ts +4 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/flatfile.listener.d.ts +63 -0
- package/dist/flatfile.listener.d.ts.map +1 -0
- package/dist/flatfile.listener.spec.d.ts +2 -0
- package/dist/flatfile.listener.spec.d.ts.map +1 -0
- package/dist/index.cjs +1007 -0
- package/dist/index.d.ts +7 -292
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +934 -685
- package/dist/index.mjs +829 -556
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/useConfigure.d.ts +1 -0
- package/dist/plugins/useConfigure.d.ts.map +1 -0
- package/dist/utils/helpers.d.ts +2 -0
- package/dist/utils/helpers.d.ts.map +1 -0
- package/package.json +11 -7
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { EventDriver } from './_EventDriver';
|
|
2
|
+
import { EventHandler } from '../events';
|
|
3
|
+
export declare class Browser extends EventDriver {
|
|
4
|
+
_accessToken?: string;
|
|
5
|
+
_apiUrl?: string;
|
|
6
|
+
_environmentId?: string;
|
|
7
|
+
constructor({ apiUrl, accessToken, environmentId, }: {
|
|
8
|
+
apiUrl: string;
|
|
9
|
+
accessToken: string;
|
|
10
|
+
environmentId?: string;
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated
|
|
13
|
+
*/
|
|
14
|
+
fetchApi: any;
|
|
15
|
+
});
|
|
16
|
+
mountEventHandler(handler: EventHandler): this;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=Browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Browser.d.ts","sourceRoot":"","sources":["../../src/event-drivers/Browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAExC,qBAAa,OAAQ,SAAQ,WAAW;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,cAAc,CAAC,EAAE,MAAM,CAAA;gBAElB,EACV,MAAM,EACN,WAAW,EACX,aAAa,GACd,EAAE;QACD,MAAM,EAAE,MAAM,CAAA;QACd,WAAW,EAAE,MAAM,CAAA;QACnB,aAAa,CAAC,EAAE,MAAM,CAAA;QACtB;;WAEG;QACH,QAAQ,EAAE,GAAG,CAAA;KACd;IAOD,iBAAiB,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI;CAS/C"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { EventDriver } from './_EventDriver';
|
|
2
|
+
import { EventHandler, FlatfileEvent } from '../events';
|
|
3
|
+
/**
|
|
4
|
+
* Flatfile's Virtual Machine is stateless / serverless. So when a new event
|
|
5
|
+
* is handled, it will just call `handle(event)`.
|
|
6
|
+
*/
|
|
7
|
+
export declare class FlatfileVirtualMachine extends EventDriver {
|
|
8
|
+
/**
|
|
9
|
+
* This method is triggered from within the Flatfile Core VM Runner. This
|
|
10
|
+
* EventDriver does not have to listen for events because this method will
|
|
11
|
+
* be invoked as necessary.
|
|
12
|
+
*
|
|
13
|
+
* @param event
|
|
14
|
+
*/
|
|
15
|
+
handle(event: FlatfileEvent): void;
|
|
16
|
+
mountEventHandler(handler: EventHandler): this;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=FlatfileVirtualMachine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FlatfileVirtualMachine.d.ts","sourceRoot":"","sources":["../../src/event-drivers/FlatfileVirtualMachine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAEvD;;;GAGG;AACH,qBAAa,sBAAuB,SAAQ,WAAW;IACrD;;;;;;OAMG;IAEH,MAAM,CAAC,KAAK,EAAE,aAAa;IAI3B,iBAAiB,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI;CAI/C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=Webhook.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Webhook.d.ts","sourceRoot":"","sources":["../../src/event-drivers/Webhook.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { EventHandler } from '../events';
|
|
2
|
+
export declare abstract class EventDriver {
|
|
3
|
+
_handler?: EventHandler;
|
|
4
|
+
get handler(): EventHandler;
|
|
5
|
+
/**
|
|
6
|
+
* Mount an event handler
|
|
7
|
+
*
|
|
8
|
+
* @param handler
|
|
9
|
+
*/
|
|
10
|
+
mountEventHandler(handler: EventHandler): this;
|
|
11
|
+
/**
|
|
12
|
+
* Dispatch an event
|
|
13
|
+
*
|
|
14
|
+
* @param e
|
|
15
|
+
*/
|
|
16
|
+
dispatchEvent(e: any): this;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=_EventDriver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_EventDriver.d.ts","sourceRoot":"","sources":["../../src/event-drivers/_EventDriver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAExC,8BAAsB,WAAW;IAC/B,QAAQ,CAAC,EAAE,YAAY,CAAA;IAEvB,IAAW,OAAO,IAAI,YAAY,CAKjC;IAED;;;;OAIG;IACH,iBAAiB,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI;IAK9C;;;;OAIG;IACH,aAAa,CAAC,CAAC,EAAE,GAAG,GAAG,IAAI;CAI5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/event-drivers/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,0BAA0B,CAAA;AACxC,cAAc,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare class AuthenticatedClient {
|
|
2
|
+
_accessToken?: string;
|
|
3
|
+
_apiUrl?: string;
|
|
4
|
+
constructor(accessToken?: string, apiUrl?: string);
|
|
5
|
+
fetch(url: string, options?: any): Promise<any>;
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @deprecated use @flatfile/cross-env-config instead
|
|
9
|
+
*/
|
|
10
|
+
setVariables({ accessToken, apiUrl, }: {
|
|
11
|
+
accessToken?: string;
|
|
12
|
+
apiUrl?: string;
|
|
13
|
+
}): void;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=authenticated.client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authenticated.client.d.ts","sourceRoot":"","sources":["../../src/events/authenticated.client.ts"],"names":[],"mappings":"AAIA,qBAAa,mBAAmB;IACvB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,OAAO,CAAC,EAAE,MAAM,CAAA;gBAEX,WAAW,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;IAa3C,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG;IAwBtC;;;OAGG;IACI,YAAY,CAAC,EAClB,WAAW,EACX,MAAM,GACP,EAAE;QACD,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB;CAIF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare class EventCache {
|
|
2
|
+
private eventCache;
|
|
3
|
+
init<T>(key: string, callback: () => Promise<T>): Promise<T>;
|
|
4
|
+
set<T>(key: string, callback: () => Promise<T>): Promise<T>;
|
|
5
|
+
get<T>(key: string): T;
|
|
6
|
+
delete(key?: string | string[]): void;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/events/cache.ts"],"names":[],"mappings":"AAAA,qBAAa,UAAU;IACrB,OAAO,CAAC,UAAU,CAA2B;IAEvC,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAU5D,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAUjE,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC;IAQtB,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI;CAatC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { AuthenticatedClient } from './authenticated.client';
|
|
2
|
+
import { EventCallback, FlatfileEvent } from './flatfile.event';
|
|
3
|
+
import type { Flatfile } from '@flatfile/api';
|
|
4
|
+
/**
|
|
5
|
+
* EventHandler is a Flatfile flavored implementation of EventTarget
|
|
6
|
+
*/
|
|
7
|
+
export declare class EventHandler extends AuthenticatedClient {
|
|
8
|
+
/**
|
|
9
|
+
* Apply a filter to the values of an event
|
|
10
|
+
*/
|
|
11
|
+
readonly filterQuery?: EventFilter;
|
|
12
|
+
/**
|
|
13
|
+
* Cache of registered listeners on this instance
|
|
14
|
+
* @private
|
|
15
|
+
*/
|
|
16
|
+
protected listeners: [string | string[], EventFilter, EventCallback][];
|
|
17
|
+
constructor(filter?: EventFilter, accessToken?: string, apiUrl?: string);
|
|
18
|
+
/**
|
|
19
|
+
* Cache of registered child nodes for this listener. These nodes will
|
|
20
|
+
* only receive events that pass the parent filter.
|
|
21
|
+
*
|
|
22
|
+
* @private
|
|
23
|
+
*/
|
|
24
|
+
protected nodes: EventHandler[];
|
|
25
|
+
/**
|
|
26
|
+
* Register a subscriber for events that match this path
|
|
27
|
+
*/
|
|
28
|
+
on(query: Arrayable<string>, callback: EventCallback): this;
|
|
29
|
+
on(query: Arrayable<string>, filter: EventFilter, callback: EventCallback): this;
|
|
30
|
+
/**
|
|
31
|
+
* Add child nodes to send this event to as well
|
|
32
|
+
*
|
|
33
|
+
* @param node
|
|
34
|
+
*/
|
|
35
|
+
addNode(node: EventHandler): this;
|
|
36
|
+
/**
|
|
37
|
+
* Dispatch an event and resolve the promise once it has completed (or
|
|
38
|
+
* errored
|
|
39
|
+
*
|
|
40
|
+
* @todo - is there a right order in which to resolve event listeners?
|
|
41
|
+
* Should it matter?
|
|
42
|
+
*
|
|
43
|
+
* @param event
|
|
44
|
+
*/
|
|
45
|
+
dispatchEvent(event: FlatfileEvent | Flatfile.Event | any): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* @deprecated legacy shim for receiving events from the VM layer
|
|
48
|
+
* @alias dispatchEvent
|
|
49
|
+
* @param event
|
|
50
|
+
*/
|
|
51
|
+
routeEvent(event: Flatfile.Event): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Actually trigger the event listeners on this particular target
|
|
54
|
+
*
|
|
55
|
+
* @note It is safer for now to run this in series to avoid IO locks and
|
|
56
|
+
* potential race conditions and uncaught errors
|
|
57
|
+
*
|
|
58
|
+
* @param event
|
|
59
|
+
* @param recursive
|
|
60
|
+
*/
|
|
61
|
+
trigger(event: FlatfileEvent, recursive?: boolean): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Get any listeners from this target subscribing to this event
|
|
64
|
+
*
|
|
65
|
+
* @param event
|
|
66
|
+
* @param recursive
|
|
67
|
+
*/
|
|
68
|
+
getListeners(event: FlatfileEvent, recursive?: boolean): Listener[];
|
|
69
|
+
/**
|
|
70
|
+
* Attach more event listeners using a callback function. Used most
|
|
71
|
+
* frequently for plugins.
|
|
72
|
+
*
|
|
73
|
+
* @param fn
|
|
74
|
+
*/
|
|
75
|
+
use(fn: (handler: this) => void): this;
|
|
76
|
+
/**
|
|
77
|
+
* Filter an event out based on glob filter object
|
|
78
|
+
*
|
|
79
|
+
* @param event
|
|
80
|
+
* @param filter
|
|
81
|
+
*/
|
|
82
|
+
matchEvent(event: FlatfileEvent, filter: EventFilter | undefined): boolean;
|
|
83
|
+
}
|
|
84
|
+
export type EventFilter = Record<string, any>;
|
|
85
|
+
export type Arrayable<T> = T | Array<T>;
|
|
86
|
+
export type Listener = {
|
|
87
|
+
query: string | string[];
|
|
88
|
+
filter: any;
|
|
89
|
+
callback: EventCallback;
|
|
90
|
+
};
|
|
91
|
+
//# sourceMappingURL=event.handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event.handler.d.ts","sourceRoot":"","sources":["../../src/events/event.handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAE/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAE7C;;GAEG;AACH,qBAAa,YAAa,SAAQ,mBAAmB;IACnD;;OAEG;IACH,SAAgB,WAAW,CAAC,EAAE,WAAW,CAAA;IAEzC;;;OAGG;IACH,SAAS,CAAC,SAAS,EAAE,CAAC,MAAM,GAAG,MAAM,EAAE,EAAE,WAAW,EAAE,aAAa,CAAC,EAAE,CAAK;gBAE/D,MAAM,CAAC,EAAE,WAAW,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;IAOvE;;;;;OAKG;IACH,SAAS,CAAC,KAAK,EAAE,YAAY,EAAE,CAAK;IAEpC;;OAEG;IACH,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI;IAC3D,EAAE,CACA,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,EACxB,MAAM,EAAE,WAAW,EACnB,QAAQ,EAAE,aAAa,GACtB,IAAI;IAiBP;;;;OAIG;IACH,OAAO,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI;IAKjC;;;;;;;;OAQG;IACG,aAAa,CACjB,KAAK,EAAE,aAAa,GAAG,QAAQ,CAAC,KAAK,GAAG,GAAG,GAC1C,OAAO,CAAC,IAAI,CAAC;IAehB;;;;OAIG;IACG,UAAU,CAAC,KAAK,EAAE,QAAQ,CAAC,KAAK;IAItC;;;;;;;;OAQG;IACG,OAAO,CACX,KAAK,EAAE,aAAa,EACpB,SAAS,GAAE,OAAe,GACzB,OAAO,CAAC,IAAI,CAAC;IAOhB;;;;;OAKG;IACI,YAAY,CACjB,KAAK,EAAE,aAAa,EACpB,SAAS,GAAE,OAAe,GACzB,QAAQ,EAAE;IAwBb;;;;;OAKG;IACH,GAAG,CAAC,EAAE,EAAE,CAAC,OAAO,EAAE,IAAI,KAAK,IAAI,GAAG,IAAI;IAKtC;;;;;OAKG;IACI,UAAU,CACf,KAAK,EAAE,aAAa,EACpB,MAAM,EAAE,WAAW,GAAG,SAAS,GAC9B,OAAO;CAGX;AAED,MAAM,MAAM,WAAW,GAAG,MAAM,CAC9B,MAAM,EACN,GAAG,CAGJ,CAAA;AAED,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;AACvC,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IACxB,MAAM,EAAE,GAAG,CAAA;IACX,QAAQ,EAAE,aAAa,CAAA;CACxB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event.handler.spec.d.ts","sourceRoot":"","sources":["../../src/events/event.handler.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { AuthenticatedClient } from './authenticated.client';
|
|
2
|
+
import { Event, RecordsWithLinks } from '@flatfile/api/api';
|
|
3
|
+
import { EventCache } from './cache';
|
|
4
|
+
type GetDataOptions = {
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
};
|
|
7
|
+
interface GetData extends Function {
|
|
8
|
+
(options?: GetDataOptions): Promise<any>;
|
|
9
|
+
then<TResult1 = any, TResult2 = any>(onfulfilled?: ((value: any) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
10
|
+
}
|
|
11
|
+
export declare class FlatfileEvent extends AuthenticatedClient {
|
|
12
|
+
readonly src: Event;
|
|
13
|
+
/**
|
|
14
|
+
* Event ID from the API
|
|
15
|
+
*
|
|
16
|
+
* @example us0_ev_82hgidh9skd
|
|
17
|
+
* @readonly
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
readonly id?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Topic the event was produced on
|
|
23
|
+
*
|
|
24
|
+
* @example workbook:created
|
|
25
|
+
* @readonly
|
|
26
|
+
*/
|
|
27
|
+
readonly topic: string;
|
|
28
|
+
readonly domain: string;
|
|
29
|
+
readonly target: string;
|
|
30
|
+
readonly origin: object;
|
|
31
|
+
readonly action: string;
|
|
32
|
+
readonly context: any;
|
|
33
|
+
readonly payload: any;
|
|
34
|
+
readonly cache: EventCache;
|
|
35
|
+
readonly namespace: string[];
|
|
36
|
+
readonly createdAt?: Date;
|
|
37
|
+
/**
|
|
38
|
+
* Fetch record data from Flatfile API via the event's dataUrl
|
|
39
|
+
*
|
|
40
|
+
* @async
|
|
41
|
+
* @param {object} options
|
|
42
|
+
* @returns {Promise<any>} JSON
|
|
43
|
+
*/
|
|
44
|
+
data: GetData;
|
|
45
|
+
constructor(src: Event, accessToken?: string, apiUrl?: string);
|
|
46
|
+
/**
|
|
47
|
+
* Should return either event body if expanded already or fetch data from the
|
|
48
|
+
* signed dataURL
|
|
49
|
+
*/
|
|
50
|
+
private fetchData;
|
|
51
|
+
private afterAllCallbacks;
|
|
52
|
+
afterAll<T>(callback: () => T, cacheKey?: string): void;
|
|
53
|
+
update(records: RecordsWithLinks): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Fetch the Secrets as indicated by this event context
|
|
56
|
+
*
|
|
57
|
+
* @param key - The name of the secret to fetch
|
|
58
|
+
* @param options - (Optional) environmentId and spaceId to override event context
|
|
59
|
+
*
|
|
60
|
+
* @returns The value of the secret (usually a credential or token)
|
|
61
|
+
*/
|
|
62
|
+
secrets(key: string, options?: {
|
|
63
|
+
environmentId?: string;
|
|
64
|
+
spaceId?: string;
|
|
65
|
+
}): Promise<string>;
|
|
66
|
+
}
|
|
67
|
+
export type EventCallback = (evt: FlatfileEvent) => void;
|
|
68
|
+
export {};
|
|
69
|
+
//# sourceMappingURL=flatfile.event.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flatfile.event.d.ts","sourceRoot":"","sources":["../../src/events/flatfile.event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAE5D,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEpC,KAAK,cAAc,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,CAAA;AAC5C,UAAU,OAAQ,SAAQ,QAAQ;IAChC,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,CAAA;IACxC,IAAI,CAAC,QAAQ,GAAG,GAAG,EAAE,QAAQ,GAAG,GAAG,EACjC,WAAW,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,EACvE,UAAU,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,GAAG,KAAK,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,GACtE,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC,CAAA;CAChC;AAED,qBAAa,aAAc,SAAQ,mBAAmB;aAoClC,GAAG,EAAE,KAAK;IAnC5B;;;;;;OAMG;IACH,SAAgB,EAAE,CAAC,EAAE,MAAM,CAAA;IAE3B;;;;;OAKG;IACH,SAAgB,KAAK,EAAE,MAAM,CAAA;IAC7B,SAAgB,MAAM,EAAE,MAAM,CAAA;IAC9B,SAAgB,MAAM,EAAE,MAAM,CAAA;IAC9B,SAAgB,MAAM,EAAE,MAAM,CAAA;IAC9B,SAAgB,MAAM,EAAE,MAAM,CAAA;IAC9B,SAAgB,OAAO,EAAE,GAAG,CAAA;IAC5B,SAAgB,OAAO,EAAE,GAAG,CAAA;IAC5B,SAAgB,KAAK,EAAE,UAAU,CAAA;IACjC,SAAgB,SAAS,EAAE,MAAM,EAAE,CAAA;IACnC,SAAgB,SAAS,CAAC,EAAE,IAAI,CAAA;IAChC;;;;;;OAMG;IACI,IAAI,EAAE,OAAO,CAAA;gBAGF,GAAG,EAAE,KAAK,EAC1B,WAAW,CAAC,EAAE,MAAM,EACpB,MAAM,CAAC,EAAE,MAAM;IA2BjB;;;OAGG;YACW,SAAS;IAqBvB,OAAO,CAAC,iBAAiB,CAA2B;IACpD,QAAQ,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI;IAOjD,MAAM,CAAC,OAAO,EAAE,gBAAgB;IAkBtC;;;;;;;OAOG;IACG,OAAO,CACX,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE;CAkCzD;AAED,MAAM,MAAM,aAAa,GAAG,CAAC,GAAG,EAAE,aAAa,KAAK,IAAI,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Arrayable } from './event.handler';
|
|
2
|
+
/**
|
|
3
|
+
* Glob style matching of a value
|
|
4
|
+
*
|
|
5
|
+
* @param val
|
|
6
|
+
* @param filter
|
|
7
|
+
*/
|
|
8
|
+
export declare function glob(val: any, filter: string | string[]): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Glob style matching of values in an object
|
|
11
|
+
*
|
|
12
|
+
* @param object
|
|
13
|
+
* @param filterObject
|
|
14
|
+
*/
|
|
15
|
+
export declare function objectMatches(object: Record<string, any>, filterObject: JSONPrimitive | FilterObj): boolean;
|
|
16
|
+
type JSONPrimitive = string | number | boolean | null;
|
|
17
|
+
type FilterObj = Record<string, Arrayable<JSONPrimitive> | Record<string, Arrayable<JSONPrimitive>>>;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=glob.match.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glob.match.d.ts","sourceRoot":"","sources":["../../src/events/glob.match.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAI3C;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAKjE;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,YAAY,EAAE,aAAa,GAAG,SAAS,GACtC,OAAO,CAiCT;AAmCD,KAAK,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAA;AAErD,KAAK,SAAS,GAAG,MAAM,CACrB,MAAM,EACN,SAAS,CAAC,aAAa,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,aAAa,CAAC,CAAC,CACpE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glob.match.spec.d.ts","sourceRoot":"","sources":["../../src/events/glob.match.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/events/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,wBAAwB,CAAA"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Flatfile Listener
|
|
3
|
+
*
|
|
4
|
+
* The Flatfile PubSub Client is just a simple event subscriber. It can
|
|
5
|
+
* receive events from any PubSub driver. The default drivers are:
|
|
6
|
+
*
|
|
7
|
+
* - Webhook (for simply processing events sent to URL)
|
|
8
|
+
* - Websocket (for subscribing real time on an HTTP2 connection)
|
|
9
|
+
* - Serverless (for stateless invocations via AWS Lambda or similar)
|
|
10
|
+
*
|
|
11
|
+
* Once an event is received, it is routed to any awaiting listeners which
|
|
12
|
+
* are added with `addEventListener()` or its alias `on()`.
|
|
13
|
+
*
|
|
14
|
+
* Flatfile events follow a standard structure and event listeners can use
|
|
15
|
+
* any of the following syntaxes to react to events within Flatfile.
|
|
16
|
+
*
|
|
17
|
+
* // listen to an event
|
|
18
|
+
* addEventListener('entity:topic')
|
|
19
|
+
*
|
|
20
|
+
* // listen to an event on a specific namespace
|
|
21
|
+
* addEventListener('entity:topic@namespace')
|
|
22
|
+
*
|
|
23
|
+
* // listen to a specific context on a namespace
|
|
24
|
+
* addEventListener('entity:topic@namespace?context=us_sp_89234oihsdo')
|
|
25
|
+
*
|
|
26
|
+
* // filter by any
|
|
27
|
+
* addEventListener('entity:topic@namespace?')
|
|
28
|
+
*
|
|
29
|
+
*/
|
|
30
|
+
import { EventFilter, EventHandler } from './events';
|
|
31
|
+
import { EventDriver } from './event-drivers';
|
|
32
|
+
export declare class FlatfileListener extends EventHandler {
|
|
33
|
+
/**
|
|
34
|
+
* Subscribe to events only within a certain namespace.
|
|
35
|
+
*
|
|
36
|
+
* @param namespace
|
|
37
|
+
* @param cb
|
|
38
|
+
*/
|
|
39
|
+
namespace(namespaces: string | string[], cb?: SubFn<this>): this;
|
|
40
|
+
/**
|
|
41
|
+
* Filter by namespace
|
|
42
|
+
*
|
|
43
|
+
* @param filter
|
|
44
|
+
* @param cb
|
|
45
|
+
*/
|
|
46
|
+
filter(filter: EventFilter, cb?: SubFn<this>): this;
|
|
47
|
+
/**
|
|
48
|
+
* Start subscribing to events
|
|
49
|
+
*
|
|
50
|
+
* @param cb
|
|
51
|
+
*/
|
|
52
|
+
static create<T extends FlatfileListener>(this: Constructor<T>, cb: SubFn<T>): T;
|
|
53
|
+
/**
|
|
54
|
+
* Mount this client using an acceptable Event Driver
|
|
55
|
+
*/
|
|
56
|
+
mount(driver: EventDriver): this;
|
|
57
|
+
}
|
|
58
|
+
type SubFn<T extends FlatfileListener> = (client: T) => void;
|
|
59
|
+
type Constructor<T> = {
|
|
60
|
+
new (): T;
|
|
61
|
+
};
|
|
62
|
+
export {};
|
|
63
|
+
//# sourceMappingURL=flatfile.listener.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flatfile.listener.d.ts","sourceRoot":"","sources":["../src/flatfile.listener.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAE7C,qBAAa,gBAAiB,SAAQ,YAAY;IAChD;;;;;OAKG;IACH,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC;IAIzD;;;;;OAKG;IACH,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI;IAOnD;;;;OAIG;WACW,MAAM,CAAC,CAAC,SAAS,gBAAgB,EAC7C,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,EACpB,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,GACX,CAAC;IAMJ;;OAEG;IACH,KAAK,CAAC,MAAM,EAAE,WAAW;CAI1B;AAED,KAAK,KAAK,CAAC,CAAC,SAAS,gBAAgB,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,IAAI,CAAA;AAE5D,KAAK,WAAW,CAAC,CAAC,IAAI;IAAE,QAAQ,CAAC,CAAA;CAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flatfile.listener.spec.d.ts","sourceRoot":"","sources":["../src/flatfile.listener.spec.ts"],"names":[],"mappings":""}
|