@melio-eng/web-sdk 1.0.24 → 1.0.25-pr.50.812a656
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/index.js +3 -0
- package/dist/types.d.ts +15 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -108,6 +108,9 @@ class Flow {
|
|
|
108
108
|
case 'ONBOARDING_COMPLETED':
|
|
109
109
|
this.emit('completed', { flowName: 'onboarding', ...data });
|
|
110
110
|
break;
|
|
111
|
+
case 'FLOW_LOADED':
|
|
112
|
+
this.emit('loaded', { flowName: data.flowName });
|
|
113
|
+
break;
|
|
111
114
|
case 'MELIO_ERROR':
|
|
112
115
|
if (data.code === 'failed_to_sync_bills') {
|
|
113
116
|
this.emit('error', { errorCode: 'billsSyncFailed' });
|
package/dist/types.d.ts
CHANGED
|
@@ -88,19 +88,30 @@ export interface FlowCompletionData {
|
|
|
88
88
|
[key: string]: any;
|
|
89
89
|
}
|
|
90
90
|
/**
|
|
91
|
-
* Flow error data
|
|
91
|
+
* Flow error data.
|
|
92
|
+
* billsSyncFailed could be returned if the following cases:
|
|
93
|
+
* 1. Trying to sync a non-USD bill
|
|
94
|
+
* 2. Trying to sync an already paid bill / draft bill
|
|
95
|
+
* 3. Trying to sync bills with an unsupported amount (amount 0 or greater than $1M)
|
|
92
96
|
*/
|
|
93
97
|
export interface ErrorData {
|
|
94
98
|
errorCode: 'billsSyncFailed';
|
|
95
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Flow loaded data
|
|
102
|
+
*/
|
|
103
|
+
export interface FlowLoadedData {
|
|
104
|
+
/** The name of the flow that was loaded */
|
|
105
|
+
flowName: 'onboarding' | 'payment' | 'settings' | 'dashboard';
|
|
106
|
+
}
|
|
96
107
|
/**
|
|
97
108
|
* Event types that can be listened to
|
|
98
109
|
*/
|
|
99
|
-
export type FlowEventType = 'completed' | 'exit' | 'navigated' | 'authenticationSucceeded' | 'authenticationFailed' | 'error';
|
|
110
|
+
export type FlowEventType = 'completed' | 'exit' | 'navigated' | 'authenticationSucceeded' | 'authenticationFailed' | 'error' | 'loaded';
|
|
100
111
|
/**
|
|
101
112
|
* Event callback function types
|
|
102
113
|
*/
|
|
103
|
-
export type FlowEventCallback = ((data: FlowCompletionData | NavigationData | ErrorData) => void) | (() => void);
|
|
114
|
+
export type FlowEventCallback = ((data: FlowCompletionData | NavigationData | ErrorData | FlowLoadedData) => void) | (() => void);
|
|
104
115
|
/**
|
|
105
116
|
* Flow instance interface for event handling
|
|
106
117
|
*/
|
|
@@ -116,6 +127,7 @@ export interface FlowInstance {
|
|
|
116
127
|
on(event: 'authenticationSucceeded', callback: () => void): void;
|
|
117
128
|
on(event: 'authenticationFailed', callback: () => void): void;
|
|
118
129
|
on(event: 'error', callback: (data: ErrorData) => void): void;
|
|
130
|
+
on(event: 'loaded', callback: (data: FlowLoadedData) => void): void;
|
|
119
131
|
/**
|
|
120
132
|
* Remove an event listener for this flow
|
|
121
133
|
* @param event - The event type to remove listener for
|
package/package.json
CHANGED