@melio-eng/web-sdk 1.0.6 → 1.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.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { InitOptions, OnboardingConfig, SinglePayFlowConfig, BatchPayConfig, SettingsConfig, FlowInstance } from "./types.js";
1
+ import { InitOptions, OnboardingConfig, SinglePayFlowConfig, BatchPayConfig, SettingsConfig, FlowInstance, PaymentsDashboardConfig } from './types.js';
2
2
  /**
3
3
  * Main SDK implementation - now partner agnostic
4
4
  */
@@ -40,6 +40,10 @@ export declare class MelioSDK implements MelioSDK {
40
40
  * Launch the settings flow
41
41
  */
42
42
  openSettings(config: SettingsConfig): FlowInstance;
43
+ /**
44
+ * Launch the payments dashboard flow
45
+ */
46
+ openPaymentsDashboard(config: PaymentsDashboardConfig): FlowInstance;
43
47
  }
44
48
  /**
45
49
  * Export the SDK instance
package/dist/index.js CHANGED
@@ -73,15 +73,19 @@ class Flow {
73
73
  return finalUrl;
74
74
  }
75
75
  setupEventListeners() {
76
- //add post message handlers for internal events - setHeight, scroll etc
77
- //also need to implement callbacks for flow completed exit etc in the platform-app
76
+ // Add post message handlers for internal events - setHeight, scroll etc
77
+ // Also need to implement callbacks for flow completed exit etc in the platform-app
78
78
  window.addEventListener('message', (event) => {
79
79
  // Verify origin for security
80
80
  if (event.origin !== 'https://app.melio.com') {
81
81
  return;
82
82
  }
83
83
  const { type, data } = event.data;
84
- console.log('📬 Received message from iframe:', { type, data, origin: event.origin });
84
+ console.log('📬 Received message from iframe:', {
85
+ type,
86
+ data,
87
+ origin: event.origin,
88
+ });
85
89
  switch (type) {
86
90
  case 'FLOW_COMPLETED':
87
91
  this.emit('completed', data);
@@ -103,7 +107,7 @@ class Flow {
103
107
  emit(event, data) {
104
108
  const listeners = this.eventListeners.get(event);
105
109
  if (listeners) {
106
- listeners.forEach(callback => {
110
+ listeners.forEach((callback) => {
107
111
  try {
108
112
  callback(data);
109
113
  }
@@ -155,7 +159,7 @@ class SinglePayFlow extends Flow {
155
159
  * Construct the specific flow URL for bill payment
156
160
  */
157
161
  constructFlowUrl(baseUrl) {
158
- return `${baseUrl}/${this.partnerName}/payment/new?billId=bill_${this.billId}`;
162
+ return `${baseUrl}/${this.partnerName}/payment/new?billId=${this.billId}`;
159
163
  }
160
164
  }
161
165
  /**
@@ -164,13 +168,13 @@ class SinglePayFlow extends Flow {
164
168
  class BatchPayFlow extends Flow {
165
169
  constructor(containerId, config, partnerName, environment) {
166
170
  super(containerId, config, partnerName, environment);
167
- this.bills = config.bills;
171
+ this.billIds = config.billIds;
168
172
  }
169
173
  /**
170
174
  * Construct the specific flow URL for batch payments
171
175
  */
172
176
  constructFlowUrl(baseUrl) {
173
- const billIds = this.bills.map(bill => `bill_${bill.billId}`).join(',');
177
+ const billIds = this.billIds.join(',');
174
178
  return `${baseUrl}/${this.partnerName}/batch-payments/${billIds}`;
175
179
  }
176
180
  }
@@ -178,9 +182,6 @@ class BatchPayFlow extends Flow {
178
182
  * SettingsFlow subclass with custom URL construction
179
183
  */
180
184
  class SettingsFlow extends Flow {
181
- constructor(containerId, config, partnerName, environment) {
182
- super(containerId, config, partnerName, environment);
183
- }
184
185
  /**
185
186
  * Construct the specific flow URL for settings
186
187
  */
@@ -188,6 +189,14 @@ class SettingsFlow extends Flow {
188
189
  return `${baseUrl}/${this.partnerName}/settings`;
189
190
  }
190
191
  }
192
+ class PaymentsDashboardFlow extends Flow {
193
+ /**
194
+ * Construct the specific flow URL for payments dashboard
195
+ */
196
+ constructFlowUrl(baseUrl) {
197
+ return `${baseUrl}/${this.partnerName}/pay-dashboard/payments`;
198
+ }
199
+ }
191
200
  /**
192
201
  * Main SDK implementation - now partner agnostic
193
202
  */
@@ -241,7 +250,7 @@ export class MelioSDK {
241
250
  createAuthInitUrl(authorizationCode) {
242
251
  const params = new URLSearchParams({
243
252
  code: authorizationCode,
244
- theme: this.partnerName
253
+ theme: this.partnerName,
245
254
  });
246
255
  const baseUrl = getBaseUrl(this.environment);
247
256
  let finalUrl = `${baseUrl}/${this.partnerName}/auth?${params.toString()}`;
@@ -256,7 +265,7 @@ export class MelioSDK {
256
265
  this.keepAliveInterval = window.setInterval(() => {
257
266
  if (this.keepAliveIframe && this.keepAliveIframe.contentWindow) {
258
267
  this.keepAliveIframe.contentWindow.postMessage({
259
- type: 'USER_ACTIVE_PING'
268
+ type: 'USER_ACTIVE_PING',
260
269
  }, 'https://app.melio.com');
261
270
  }
262
271
  }, 30000); // Send ping every 30 seconds
@@ -293,6 +302,14 @@ export class MelioSDK {
293
302
  flow.initialize();
294
303
  return flow;
295
304
  }
305
+ /**
306
+ * Launch the payments dashboard flow
307
+ */
308
+ openPaymentsDashboard(config) {
309
+ const flow = new PaymentsDashboardFlow(config.containerId, config, this.partnerName, this.environment);
310
+ flow.initialize();
311
+ return flow;
312
+ }
296
313
  }
297
314
  /**
298
315
  * Export the SDK instance
package/dist/types.d.ts CHANGED
@@ -31,23 +31,26 @@ export interface OnboardingConfig extends BaseFlowConfig {
31
31
  * Configuration for single pay flow
32
32
  */
33
33
  export interface SinglePayFlowConfig extends BaseFlowConfig {
34
- /** The Melio bill ID to pay */
34
+ /** The bill ID to pay */
35
35
  billId: string;
36
36
  }
37
37
  /**
38
38
  * Configuration for batch pay flow
39
39
  */
40
40
  export interface BatchPayConfig extends BaseFlowConfig {
41
- /** Array of bills to pay */
42
- bills: Array<{
43
- billId: string;
44
- }>;
41
+ /** Array of bill IDs to pay */
42
+ billIds: Array<string>;
45
43
  }
46
44
  /**
47
45
  * Configuration for settings flow
48
46
  */
49
47
  export interface SettingsConfig extends BaseFlowConfig {
50
48
  }
49
+ /**
50
+ * Configuration for payments dashboard flow
51
+ */
52
+ export interface PaymentsDashboardConfig extends BaseFlowConfig {
53
+ }
51
54
  /**
52
55
  * Event payload for navigation events
53
56
  */
@@ -127,4 +130,10 @@ export interface MelioSDK {
127
130
  * @returns Flow instance for event handling
128
131
  */
129
132
  openSettings(config: SettingsConfig): FlowInstance;
133
+ /**
134
+ * Launch the payments dashboard flow
135
+ * @param config - Configuration for the payments dashboard flow
136
+ * @returns Flow instance for event handling
137
+ */
138
+ openPaymentsDashboard(config: PaymentsDashboardConfig): FlowInstance;
130
139
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@melio-eng/web-sdk",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Melio Web SDK - Embed core Melio workflows directly into partner UI with minimal effort",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",