@flatfile/listener 0.3.7 → 0.3.9
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/README.md +49 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -2
- package/dist/index.mjs +3 -2
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# @flatfile/listener
|
|
2
|
+
|
|
3
|
+
`@flatfile/listener` is Flatfile's core library. It combines event handling capabilities with Flatfile-specific functionality, such as working with Flatfile records and sessions. Simply put, it receives events and it responds to events. Period.
|
|
4
|
+
|
|
5
|
+
The `AuthenticatedClient` class serves as a foundation for authenticated API communication, while the event-related classes enable event-driven workflows within the Flatfile ecosystem.
|
|
6
|
+
|
|
7
|
+
## Components
|
|
8
|
+
|
|
9
|
+
Here's an overview of the package and its components:
|
|
10
|
+
|
|
11
|
+
### `FlatfileRecord and FlatfileRecords`
|
|
12
|
+
|
|
13
|
+
- These classes represent records and collections of records in the Flatfile format.
|
|
14
|
+
- They provide methods for manipulating and retrieving record data.
|
|
15
|
+
|
|
16
|
+
### `FlatfileSession`
|
|
17
|
+
|
|
18
|
+
- This class represents a session in the Flatfile platform.
|
|
19
|
+
- It stores information about the workspace, workbook, schema, uploads, and other session-related data.
|
|
20
|
+
|
|
21
|
+
### `EventCache`
|
|
22
|
+
|
|
23
|
+
- This class implements an event caching mechanism.
|
|
24
|
+
- It allows for caching and retrieval of event data based on cache keys.
|
|
25
|
+
|
|
26
|
+
### `EventHandler`
|
|
27
|
+
|
|
28
|
+
This class is an event handler implementation that extends the AuthenticatedClient class.
|
|
29
|
+
|
|
30
|
+
- It provides methods for registering event listeners, dispatching events, and managing child event handlers.
|
|
31
|
+
- It supports filtering events based on topic and context.
|
|
32
|
+
- It can be used to handle and process events in the Flatfile platform.
|
|
33
|
+
|
|
34
|
+
### `AuthenticatedClient`
|
|
35
|
+
|
|
36
|
+
This class is a base class for authenticated HTTP clients.
|
|
37
|
+
|
|
38
|
+
- It provides functionality for making authenticated HTTP requests using Axios.
|
|
39
|
+
- It handles access tokens, API URLs, and HTTP headers.
|
|
40
|
+
|
|
41
|
+
### Various utility functions and types:
|
|
42
|
+
|
|
43
|
+
`@flatfile/listener` includes utility functions and types related to event handling, filtering, and data manipulation.
|
|
44
|
+
|
|
45
|
+
These utilities support the functionality of the event handling and data processing components.
|
|
46
|
+
|
|
47
|
+
## Get Started
|
|
48
|
+
|
|
49
|
+
To get started with @flatfile/listener, follow our [Quickstart guide](https://flatfile.com/docs/quickstart/meet-the-workbook).
|
package/dist/index.d.ts
CHANGED
|
@@ -48,6 +48,7 @@ declare class FlatfileEvent extends AuthenticatedClient {
|
|
|
48
48
|
readonly context: any;
|
|
49
49
|
readonly payload: any;
|
|
50
50
|
readonly cache: EventCache;
|
|
51
|
+
readonly namespace: string[];
|
|
51
52
|
constructor(src: Event, accessToken?: string, apiUrl?: string);
|
|
52
53
|
/**
|
|
53
54
|
* Should return either event body if expanded already or fetch data from the
|
|
@@ -236,7 +237,7 @@ declare class FlatfileListener extends EventHandler {
|
|
|
236
237
|
* @param namespace
|
|
237
238
|
* @param cb
|
|
238
239
|
*/
|
|
239
|
-
namespace(
|
|
240
|
+
namespace(namespaces: string | string[], cb?: SubFn<this>): this;
|
|
240
241
|
/**
|
|
241
242
|
* Filter by namespace
|
|
242
243
|
*
|
package/dist/index.js
CHANGED
|
@@ -251,6 +251,7 @@ var FlatfileEvent = class extends AuthenticatedClient {
|
|
|
251
251
|
this.target = src.target || "";
|
|
252
252
|
this.origin = src.origin || {};
|
|
253
253
|
this.action = src.context?.actionName || "";
|
|
254
|
+
this.namespace = src.namespaces || [];
|
|
254
255
|
}
|
|
255
256
|
/**
|
|
256
257
|
* Should return either event body if expanded already or fetch data from the
|
|
@@ -584,8 +585,8 @@ var FlatfileListener = class extends EventHandler {
|
|
|
584
585
|
* @param namespace
|
|
585
586
|
* @param cb
|
|
586
587
|
*/
|
|
587
|
-
namespace(
|
|
588
|
-
return this.filter({
|
|
588
|
+
namespace(namespaces, cb) {
|
|
589
|
+
return this.filter({ namespaces }, cb);
|
|
589
590
|
}
|
|
590
591
|
/**
|
|
591
592
|
* Filter by namespace
|
package/dist/index.mjs
CHANGED
|
@@ -208,6 +208,7 @@ var FlatfileEvent = class extends AuthenticatedClient {
|
|
|
208
208
|
this.target = src.target || "";
|
|
209
209
|
this.origin = src.origin || {};
|
|
210
210
|
this.action = src.context?.actionName || "";
|
|
211
|
+
this.namespace = src.namespaces || [];
|
|
211
212
|
}
|
|
212
213
|
/**
|
|
213
214
|
* Should return either event body if expanded already or fetch data from the
|
|
@@ -541,8 +542,8 @@ var FlatfileListener = class extends EventHandler {
|
|
|
541
542
|
* @param namespace
|
|
542
543
|
* @param cb
|
|
543
544
|
*/
|
|
544
|
-
namespace(
|
|
545
|
-
return this.filter({
|
|
545
|
+
namespace(namespaces, cb) {
|
|
546
|
+
return this.filter({ namespaces }, cb);
|
|
546
547
|
}
|
|
547
548
|
/**
|
|
548
549
|
* Filter by namespace
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flatfile/listener",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.9",
|
|
4
4
|
"description": "A PubSub Listener for configuring and using Flatfile",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"flat": "^5.0.2"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@flatfile/api": "^1.
|
|
38
|
+
"@flatfile/api": "^1.5.10",
|
|
39
39
|
"axios": "^1.4.0"
|
|
40
40
|
}
|
|
41
41
|
}
|