@flatfile/listener 0.0.6 → 0.0.8

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @flatfile/listener@0.0.6 build
2
+ > @flatfile/listener@0.0.8 build
3
3
  > tsup src/index.ts --format esm,cjs --dts
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -8,10 +8,10 @@
8
8
  CLI Target: es6
9
9
  ESM Build start
10
10
  CJS Build start
11
- ESM dist/index.mjs 632.79 KB
12
- ESM ⚡️ Build success in 316ms
13
- CJS dist/index.js 633.59 KB
14
- CJS ⚡️ Build success in 327ms
11
+ ESM dist/index.mjs 638.80 KB
12
+ ESM ⚡️ Build success in 339ms
13
+ CJS dist/index.js 639.47 KB
14
+ CJS ⚡️ Build success in 346ms
15
15
  DTS Build start
16
- DTS ⚡️ Build success in 1631ms
17
- DTS dist/index.d.ts 6.12 KB
16
+ DTS ⚡️ Build success in 1683ms
17
+ DTS dist/index.d.ts 7.14 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @flatfile/listener
2
2
 
3
+ ## 0.0.8
4
+
5
+ ### Patch Changes
6
+
7
+ - 74852f3: Adds Event Cache
8
+ - 65aea7a: Adds conditional fetchApi variable to authenticated client to allow for client-side use
9
+
10
+ ## 0.0.7
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies [72447b1]
15
+ - @flatfile/hooks@1.3.0
16
+
3
17
  ## 0.0.6
4
18
 
5
19
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,10 +1,25 @@
1
- import { DefaultApi, Event } from '@flatfile/api';
1
+ import { FetchAPI, DefaultApi, Event } from '@flatfile/api';
2
2
 
3
3
  declare class AuthenticatedClient {
4
+ private _accessToken?;
5
+ private _apiUrl?;
4
6
  private _api?;
7
+ fetchApi: FetchAPI;
5
8
  get api(): DefaultApi;
6
- private _fetch?;
7
9
  fetch(url: string): any;
10
+ setVariables({ accessToken, apiUrl, fetchApi, }: {
11
+ accessToken?: string;
12
+ apiUrl?: string;
13
+ fetchApi?: any;
14
+ }): void;
15
+ }
16
+
17
+ declare class EventCache {
18
+ private eventCache;
19
+ init<T>(key: string, callback: () => Promise<T>): Promise<T>;
20
+ set<T>(key: string, callback: () => Promise<T>): Promise<T>;
21
+ get<T>(key: string): T;
22
+ delete(key?: string | string[]): void;
8
23
  }
9
24
 
10
25
  declare class FlatfileEvent extends AuthenticatedClient {
@@ -29,6 +44,7 @@ declare class FlatfileEvent extends AuthenticatedClient {
29
44
  readonly action: string;
30
45
  readonly context: any;
31
46
  readonly payload: any;
47
+ readonly cache: EventCache;
32
48
  constructor(src: Event);
33
49
  /**
34
50
  * Should return either event body if expanded already or fetch data from the
@@ -37,6 +53,8 @@ declare class FlatfileEvent extends AuthenticatedClient {
37
53
  * @todo this should work with the included callback URL
38
54
  */
39
55
  get data(): Promise<any>;
56
+ private afterAllCallbacks;
57
+ afterAll<T>(callback: () => T, cacheKey?: string): void;
40
58
  }
41
59
  type EventCallback = (evt: FlatfileEvent) => void;
42
60
 
@@ -198,6 +216,20 @@ declare class Client extends EventHandler {
198
216
  }
199
217
  type SubFn = (client: Client) => void;
200
218
 
219
+ declare class Browser extends EventDriver {
220
+ _accessToken?: string;
221
+ _apiUrl?: string;
222
+ _environmentId?: string;
223
+ _fetchApi: FetchAPI;
224
+ constructor({ apiUrl, accessToken, environmentId, fetchApi, }: {
225
+ apiUrl: string;
226
+ accessToken: string;
227
+ environmentId?: string;
228
+ fetchApi: FetchAPI;
229
+ });
230
+ mountEventHandler(handler: EventHandler): this;
231
+ }
232
+
201
233
  declare class PollingEventDriver extends EventDriver {
202
234
  private options;
203
235
  constructor(options: {
@@ -221,6 +253,7 @@ declare class FlatfileVirtualMachine extends EventDriver {
221
253
  * @param event
222
254
  */
223
255
  handle(event: FlatfileEvent): void;
256
+ mountEventHandler(handler: EventHandler): this;
224
257
  }
225
258
 
226
- export { Arrayable, AuthenticatedClient, Client, EventCallback, EventFilter, EventHandler, FlatfileEvent, FlatfileVirtualMachine, PollingEventDriver };
259
+ export { Arrayable, AuthenticatedClient, Browser, Client, EventCallback, EventFilter, EventHandler, FlatfileEvent, FlatfileVirtualMachine, PollingEventDriver };