@fire-spark/realtime 0.0.1

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.
@@ -0,0 +1,80 @@
1
+ import { ServiceHttpOptions } from "@fire-spark/core";
2
+ import { KioskCommandPayload, KioskCommandPayload as KioskCommandPayload$1, KioskConfigChangedPayload, KioskConfigChangedPayload as KioskConfigChangedPayload$1, KioskRealtimeToken, KioskRealtimeToken as KioskRealtimeToken$1, OrderChangedPayload, OrderChangedPayload as OrderChangedPayload$1, StorefrontAvailabilityChangedPayload, StorefrontAvailabilityChangedPayload as StorefrontAvailabilityChangedPayload$1, StorefrontCmsChangedPayload, StorefrontCmsChangedPayload as StorefrontCmsChangedPayload$1, StorefrontMenuChangedPayload, StorefrontMenuChangedPayload as StorefrontMenuChangedPayload$1, StorefrontMenuScope, StorefrontRealtimeToken, StorefrontWorkspaceChangedPayload, StorefrontWorkspaceChangedPayload as StorefrontWorkspaceChangedPayload$1 } from "@fire-spark/types";
3
+ //#region src/listen.types.d.ts
4
+ declare const MENU_CHANGED_EVENT = "menu.changed";
5
+ declare const AVAILABILITY_CHANGED_EVENT = "availability.changed";
6
+ declare const ORDER_CHANGED_EVENT = "order.changed";
7
+ declare const KIOSK_CONFIG_CHANGED_EVENT = "kiosk.config.changed";
8
+ declare const KIOSK_COMMAND_EVENT = "kiosk.command";
9
+ declare const CMS_CHANGED_EVENT = "cms.changed";
10
+ interface RealtimeListenEvents {
11
+ menuChanged?: (payload: StorefrontMenuChangedPayload$1) => void;
12
+ availabilityChanged?: (payload: StorefrontAvailabilityChangedPayload$1) => void;
13
+ paymentsChanged?: (payload: StorefrontWorkspaceChangedPayload$1) => void;
14
+ fulfillmentsChanged?: (payload: StorefrontWorkspaceChangedPayload$1) => void;
15
+ }
16
+ interface RealtimeListenOptions extends ServiceHttpOptions {
17
+ scope?: StorefrontMenuScope;
18
+ on: RealtimeListenEvents;
19
+ }
20
+ interface RealtimeChannelHandle {
21
+ on: (type: string, filter: {
22
+ event: string;
23
+ }, cb: (msg: {
24
+ payload: unknown;
25
+ }) => void) => RealtimeChannelHandle;
26
+ subscribe: (cb?: (status: string, err?: Error) => void) => RealtimeChannelHandle;
27
+ unsubscribe: () => Promise<unknown> | void;
28
+ }
29
+ interface RealtimeSocket {
30
+ setAuth: (token: string) => Promise<unknown> | void;
31
+ connect: () => void;
32
+ disconnect: () => void;
33
+ channel: (topic: string, opts: {
34
+ config: {
35
+ private: boolean;
36
+ };
37
+ }) => RealtimeChannelHandle;
38
+ }
39
+ interface RealtimeListenDeps {
40
+ createClient?: (url: string, key: string) => RealtimeSocket;
41
+ setIntervalFn?: typeof setInterval;
42
+ clearIntervalFn?: typeof clearInterval;
43
+ }
44
+ interface RealtimeListenOrderEvents {
45
+ changed: (payload: OrderChangedPayload$1) => void;
46
+ subscribed?: () => void;
47
+ }
48
+ interface RealtimeListenOrderOptions extends ServiceHttpOptions {
49
+ orderId: string;
50
+ on: RealtimeListenOrderEvents;
51
+ }
52
+ interface RealtimeListenKioskEvents {
53
+ configChanged?: (payload: KioskConfigChangedPayload$1) => void;
54
+ command?: (payload: KioskCommandPayload$1) => void;
55
+ cmsChanged?: (payload: StorefrontCmsChangedPayload$1) => void;
56
+ }
57
+ interface RealtimeListenKioskOptions {
58
+ fetchToken: () => Promise<KioskRealtimeToken$1>;
59
+ /** CMS block names this device renders; only these topics are joined. */
60
+ cmsBlocks?: string[];
61
+ on: RealtimeListenKioskEvents;
62
+ }
63
+ //#endregion
64
+ //#region src/listen.d.ts
65
+ declare const listen: (options: RealtimeListenOptions, deps?: RealtimeListenDeps) => () => void;
66
+ //#endregion
67
+ //#region src/listenKiosk.d.ts
68
+ declare const listenKiosk: (options: RealtimeListenKioskOptions, deps?: RealtimeListenDeps) => () => void;
69
+ //#endregion
70
+ //#region src/listenOrder.d.ts
71
+ declare const listenOrder: (options: RealtimeListenOrderOptions, deps?: RealtimeListenDeps) => () => void;
72
+ //#endregion
73
+ //#region src/index.d.ts
74
+ declare const realtime: {
75
+ listen: typeof listen;
76
+ listenKiosk: typeof listenKiosk;
77
+ listenOrder: typeof listenOrder;
78
+ };
79
+ //#endregion
80
+ export { AVAILABILITY_CHANGED_EVENT, CMS_CHANGED_EVENT, KIOSK_COMMAND_EVENT, KIOSK_CONFIG_CHANGED_EVENT, type KioskCommandPayload, type KioskConfigChangedPayload, type KioskRealtimeToken, MENU_CHANGED_EVENT, ORDER_CHANGED_EVENT, type OrderChangedPayload, type RealtimeListenEvents, type RealtimeListenKioskOptions, type RealtimeListenOptions, type RealtimeListenOrderOptions, type StorefrontAvailabilityChangedPayload, type StorefrontCmsChangedPayload, type StorefrontMenuChangedPayload, type StorefrontRealtimeToken, type StorefrontWorkspaceChangedPayload, listen, listenKiosk, listenOrder, realtime };