@melio-eng/web-sdk 1.0.6 → 1.0.7

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, SinglePaymentConfig } from './types.js';
2
2
  /**
3
3
  * Main SDK implementation - now partner agnostic
4
4
  */
@@ -40,6 +40,14 @@ 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;
47
+ /**
48
+ * Launch single payment details
49
+ */
50
+ openSinglePayment(config: SinglePaymentConfig): FlowInstance;
43
51
  }
44
52
  /**
45
53
  * Export the SDK instance
package/dist/index.js CHANGED
@@ -81,7 +81,11 @@ class Flow {
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
  /**
@@ -170,7 +174,7 @@ class BatchPayFlow extends Flow {
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.bills.join(',');
174
178
  return `${baseUrl}/${this.partnerName}/batch-payments/${billIds}`;
175
179
  }
176
180
  }
@@ -178,14 +182,31 @@ class BatchPayFlow extends Flow {
178
182
  * SettingsFlow subclass with custom URL construction
179
183
  */
180
184
  class SettingsFlow extends Flow {
185
+ /**
186
+ * Construct the specific flow URL for settings
187
+ */
188
+ constructFlowUrl(baseUrl) {
189
+ return `${baseUrl}/${this.partnerName}/settings`;
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
+ }
200
+ class SinglePaymentFlow extends Flow {
181
201
  constructor(containerId, config, partnerName, environment) {
182
202
  super(containerId, config, partnerName, environment);
203
+ this.paymentId = config.paymentId;
183
204
  }
184
205
  /**
185
- * Construct the specific flow URL for settings
206
+ * Construct the specific flow URL for single payment
186
207
  */
187
208
  constructFlowUrl(baseUrl) {
188
- return `${baseUrl}/${this.partnerName}/settings`;
209
+ return `${baseUrl}/${this.partnerName}/pay-dashboard/payments/${this.paymentId}`;
189
210
  }
190
211
  }
191
212
  /**
@@ -241,7 +262,7 @@ export class MelioSDK {
241
262
  createAuthInitUrl(authorizationCode) {
242
263
  const params = new URLSearchParams({
243
264
  code: authorizationCode,
244
- theme: this.partnerName
265
+ theme: this.partnerName,
245
266
  });
246
267
  const baseUrl = getBaseUrl(this.environment);
247
268
  let finalUrl = `${baseUrl}/${this.partnerName}/auth?${params.toString()}`;
@@ -256,7 +277,7 @@ export class MelioSDK {
256
277
  this.keepAliveInterval = window.setInterval(() => {
257
278
  if (this.keepAliveIframe && this.keepAliveIframe.contentWindow) {
258
279
  this.keepAliveIframe.contentWindow.postMessage({
259
- type: 'USER_ACTIVE_PING'
280
+ type: 'USER_ACTIVE_PING',
260
281
  }, 'https://app.melio.com');
261
282
  }
262
283
  }, 30000); // Send ping every 30 seconds
@@ -293,6 +314,22 @@ export class MelioSDK {
293
314
  flow.initialize();
294
315
  return flow;
295
316
  }
317
+ /**
318
+ * Launch the payments dashboard flow
319
+ */
320
+ openPaymentsDashboard(config) {
321
+ const flow = new PaymentsDashboardFlow(config.containerId, config, this.partnerName, this.environment);
322
+ flow.initialize();
323
+ return flow;
324
+ }
325
+ /**
326
+ * Launch single payment details
327
+ */
328
+ openSinglePayment(config) {
329
+ const flow = new SinglePaymentFlow(config.containerId, config, this.partnerName, this.environment);
330
+ flow.initialize();
331
+ return flow;
332
+ }
296
333
  }
297
334
  /**
298
335
  * Export the SDK instance
package/dist/types.d.ts CHANGED
@@ -48,6 +48,18 @@ export interface BatchPayConfig extends BaseFlowConfig {
48
48
  */
49
49
  export interface SettingsConfig extends BaseFlowConfig {
50
50
  }
51
+ /**
52
+ * Configuration for payments dashboard flow
53
+ */
54
+ export interface PaymentsDashboardConfig extends BaseFlowConfig {
55
+ }
56
+ /**
57
+ * Configuration for single payment
58
+ */
59
+ export interface SinglePaymentConfig extends BaseFlowConfig {
60
+ /** The Melio bill ID to pay */
61
+ paymentId: string;
62
+ }
51
63
  /**
52
64
  * Event payload for navigation events
53
65
  */
@@ -127,4 +139,16 @@ export interface MelioSDK {
127
139
  * @returns Flow instance for event handling
128
140
  */
129
141
  openSettings(config: SettingsConfig): FlowInstance;
142
+ /**
143
+ * Launch the payments dashboard flow
144
+ * @param config - Configuration for the payments dashboard flow
145
+ * @returns Flow instance for event handling
146
+ */
147
+ openPaymentsDashboard(config: PaymentsDashboardConfig): FlowInstance;
148
+ /**
149
+ * Launch the single payment flow
150
+ * @param config - Configuration for the single payment flow
151
+ * @returns Flow instance for event handling
152
+ */
153
+ openSinglePayment(config: SinglePaymentConfig): FlowInstance;
130
154
  }
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.7",
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",