@melio-eng/web-sdk 1.3.0 → 1.4.0-pr.97.9921247
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 +1 -1
- package/dist/flows/Flow.js +15 -6
- package/dist/types.d.ts +5 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -185,7 +185,7 @@ flow.on("navigated", (p) => console.log("Navigated to:", p.target));
|
|
|
185
185
|
**Available Events:**
|
|
186
186
|
- `loaded`: The flow iframe has rendered
|
|
187
187
|
- `completed`: The user successfully finished a flow
|
|
188
|
-
- `error`: A flow error occurred (
|
|
188
|
+
- `error`: A flow error occurred (`billsSyncFailed`, or `vendorsSyncFailed` in the Just Pay flow)
|
|
189
189
|
- `exit`: The user exited the iframe
|
|
190
190
|
- `navigated`: Navigation occurred inside the iframe
|
|
191
191
|
- `buttonClicked`: The user clicked a button whose destination is in your product (see below)
|
package/dist/flows/Flow.js
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { getBaseUrl } from './utils.js';
|
|
2
2
|
import { logger, describeError, describeConfig, redactUrl } from './logger.js';
|
|
3
|
+
/**
|
|
4
|
+
* MELIO_ERROR codes the embedded app reports, mapped to the host-facing error
|
|
5
|
+
* codes the SDK emits. A code that is absent here is logged but not forwarded.
|
|
6
|
+
*/
|
|
7
|
+
const HOST_FACING_ERROR_CODES = {
|
|
8
|
+
failed_to_sync_bills: 'billsSyncFailed',
|
|
9
|
+
failed_to_sync_vendors: 'vendorsSyncFailed',
|
|
10
|
+
};
|
|
3
11
|
/**
|
|
4
12
|
* Flow class implementation for handling iframe flows and events
|
|
5
13
|
*/
|
|
@@ -155,17 +163,18 @@ export class Flow {
|
|
|
155
163
|
case 'PAYMENT_SCHEDULED':
|
|
156
164
|
this.emit('completed', { flowName: 'payment', ...data });
|
|
157
165
|
break;
|
|
158
|
-
case 'MELIO_ERROR':
|
|
159
|
-
|
|
160
|
-
//
|
|
166
|
+
case 'MELIO_ERROR': {
|
|
167
|
+
const errorCode = HOST_FACING_ERROR_CODES[data.code];
|
|
168
|
+
// Logged even when unmapped, so a new code cannot be dropped silently.
|
|
161
169
|
logger.error('Embedded app reported MELIO_ERROR', {
|
|
162
170
|
...data,
|
|
163
|
-
forwardedToHost:
|
|
171
|
+
forwardedToHost: Boolean(errorCode),
|
|
164
172
|
});
|
|
165
|
-
if (
|
|
166
|
-
this.emit('error', { errorCode
|
|
173
|
+
if (errorCode) {
|
|
174
|
+
this.emit('error', { errorCode });
|
|
167
175
|
}
|
|
168
176
|
break;
|
|
177
|
+
}
|
|
169
178
|
case 'HEIGHT_CHANGE':
|
|
170
179
|
if (this.iframe) {
|
|
171
180
|
this.iframe.style.height = `${data.height}px`;
|
package/dist/types.d.ts
CHANGED
|
@@ -165,9 +165,13 @@ export interface FlowCompletionData {
|
|
|
165
165
|
* 1. Trying to sync a non-USD bill
|
|
166
166
|
* 2. Trying to sync an already paid bill / draft bill
|
|
167
167
|
* 3. Trying to sync bills with an unsupported amount (amount 0 or greater than $1M)
|
|
168
|
+
*
|
|
169
|
+
* vendorsSyncFailed is returned when the Just Pay flow could not load any of the
|
|
170
|
+
* requested vendors from the accounting platform. The flow cannot continue, so
|
|
171
|
+
* close it and surface the failure in your own product.
|
|
168
172
|
*/
|
|
169
173
|
export interface ErrorData {
|
|
170
|
-
errorCode: 'billsSyncFailed';
|
|
174
|
+
errorCode: 'billsSyncFailed' | 'vendorsSyncFailed';
|
|
171
175
|
}
|
|
172
176
|
/**
|
|
173
177
|
* Event types that can be listened to
|
package/package.json
CHANGED