@wf-financing/ui-sdk 0.1.2 → 1.0.0

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 CHANGED
@@ -4,28 +4,27 @@ Wayflyer provides a `@wf-financing/ui-sdk` package that can be used as a client-
4
4
 
5
5
  ## Installation
6
6
 
7
- Install the package directly from NPM with `npm install @wf-financing/ui-sdk`.
8
- To minimize the bundle size and reduce the impact on partners' page load times, the SDK uses dynamic imports to load the main part of the functionality.
7
+ Install the package directly from NPM with `npm install @wf-financing/ui-sdk`. To minimize the bundle size and reduce the impact on partners' page load times, the SDK uses dynamic imports to load the main part of the functionality.
9
8
 
10
9
  ## Instantiation
11
10
 
12
11
  To initialize `WayflyerUiSdk`, call the static method `loadSdk` with the following parameters:
13
12
 
14
13
  1. `targetId` - The DOM element's ID where the CTA is supposed to be mounted.
15
- 2. `partnerDesignId` - The ID of the partner theme that needs to be applied to the CTA.
16
- - **Note**: The partner must request Wayflyer to generate a special theme ID.
17
- 3. `partnerCallback` - A function of type `PartnerCallbackType`, which is also provided by the `@wf-financing/ui-sdk` package.
18
- 4. `companyToken` - The merchant identifier.
14
+ 2. `partnerCallback` - A function of type `PartnerCallbackType`, which is also provided by the `@wf-financing/ui-sdk` package.
15
+ 3. `companyToken` - The merchant identifier.
19
16
  - **Note**: The `companyToken` should be minted using the Company Token endpoint on the partner's backend. See the Authentication section [here](https://docs.wayflyer.com/embedded-finance/authentication) for more details.
20
17
 
21
18
  ```jsx
22
19
  import { type IWayflyerUiCtaSdk, WayflyerUiSdk } from '@wf-financing/ui-sdk';
23
20
 
24
- const wayflyerSdk = (await WayflyerUiSdk.loadSdk(targetId, partnerDesignId, partnerCallback, companyToken)) as IWayflyerUiCtaSdk;
21
+ const wayflyerSdk = (await WayflyerUiSdk.loadSdk(targetId, partnerCallback, companyToken)) as IWayflyerUiCtaSdk;
25
22
  ```
26
23
 
27
24
  ## SDK methods
25
+
28
26
  ### `mountCta()`
27
+
29
28
  This function mounts the CTA banner once it's called.
30
29
 
31
30
  ```jsx
@@ -33,8 +32,8 @@ wayflyerSdk.mountCta();
33
32
  ```
34
33
 
35
34
  ## Mocked mode
36
- To simplify the testing process, the SDK can be initialized in mock mode. To do so, pass a fifth argument of type `MockedModeType`.
37
- In mock mode, the partner can manually set responses for SDK methods via the `sdkScenario` field in the optional `mockedMode` argument.
35
+
36
+ To simplify the testing process, the SDK can be initialized in mock mode. To do so, pass the fourth argument of type `MockedModeType`. In mock mode, the partner can manually set responses for SDK methods via the `sdkScenario` field in the optional `mockedMode` argument.
38
37
 
39
38
  ```jsx
40
39
  import { WayflyerUiSdk, type MockedModeType, SdkScenarios } from '@wf-financing/ui-sdk';
@@ -59,6 +58,7 @@ const mockedModeNoCta: MockedModeType = {
59
58
  sdkScenario: SdkScenarios.NO_CTA,
60
59
  };
61
60
 
62
- const wayflyerSdk = (await WayflyerUiSdk.loadSdk(targetId, partnerDesignId, partnerCallback, companyToken, mockedMode)) as IWayflyerUiCtaSdk;
61
+ const wayflyerSdk = (await WayflyerUiSdk.loadSdk(targetId, partnerCallback, companyToken, mockedMode)) as IWayflyerUiCtaSdk;
63
62
  ```
63
+
64
64
  After instantiation with the mockedMode parameter, the CTA banner will behave according to the specified scenario.
@@ -1 +1 @@
1
- export declare const UI_PACKAGE_URL = "https://unpkg.com/@wf-financing/ui@1/dist/index.es.js";
1
+ export declare const UI_PACKAGE_URL = "https://embedded-finance-frontend.vercel.app/npm/@wf-financing/ui@2";
package/dist/index.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var l=(i=>(i.NO_CTA="no_cta",i.CONTINUE_APPLICATION="continue_application",i.GENERIC_NEW_APPLICATION="generic_new_application",i.INDICATIVE_NEW_APPLICATION="indicative_new_application",i))(l||{});const c="wayflyer-ui-package",w="https://unpkg.com/@wf-financing/ui@1/dist/index.es.js",s=(i,e,a,n,o)=>{if(!window.WayflyerUiCtaSdk)throw new Error("Failed to load WayflyerUiCtaSdk from the script.");const t=window.WayflyerUiCtaSdk;return new t(i,e,a,n,o)},d=(i,e,a,n,o,t)=>new Promise((r,y)=>{i.onload=()=>{try{r(s(e,a,n,o,t))}catch(S){y(S)}}}),f=async(i,e,a,n,o)=>{try{const t=document.getElementById(c);if(window.WayflyerUiCtaSdk)return s(i,e,a,n,o);if(t)return d(t,i,e,a,n,o);const r=document.createElement("script");return r.src=w,r.type="module",r.id=c,r.async=!0,document.head.appendChild(r),d(r,i,e,a,n,o)}catch(t){throw console.error("Error in loading headless SDK:",t),new Error("Failed to load script")}};class u{static async loadSdk(e,a,n,o,t){return await f(e,a,n,o,t)}}exports.SdkScenarios=l;exports.WayflyerUiSdk=u;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n="wayflyer-ui-package",s="https://embedded-finance-frontend.vercel.app/npm/@wf-financing/ui@2",c=(a,t,i,d)=>{if(!window.WayflyerUiCtaSdk)throw new Error("Failed to load WayflyerUiCtaSdk from the script.");const e=window.WayflyerUiCtaSdk;return new e(a,t,i,d)},o=(a,t,i,d,e)=>new Promise((r,y)=>{a.onload=()=>{try{r(c(t,i,d,e))}catch(l){y(l)}}}),f=async(a,t,i,d)=>{try{const e=document.getElementById(n);if(window.WayflyerUiCtaSdk)return c(a,t,i,d);if(e)return o(e,a,t,i,d);const r=document.createElement("script");return r.src=s,r.type="module",r.id=n,r.async=!0,document.head.appendChild(r),o(r,a,t,i,d)}catch(e){throw console.error("Error in loading headless SDK:",e),new Error("Failed to load script")}};class S{static async loadSdk(t,i,d,e){return await f(t,i,d,e)}}exports.WayflyerUiSdk=S;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,2 @@
1
- export type { IWayflyerUiCtaSdk, PartnerCallbackType, MockedModeType } from '@wf-financing/embedded-types';
2
- export { SdkScenarios } from '@wf-financing/embedded-types';
1
+ export type { IWayflyerUiCtaSdk, PartnerCallbackType, SdkOptionsType } from '@wf-financing/embedded-types';
3
2
  export { WayflyerUiSdk } from './sdk';
package/dist/index.es.js CHANGED
@@ -1,43 +1,34 @@
1
- var w = /* @__PURE__ */ ((i) => (i.NO_CTA = "no_cta", i.CONTINUE_APPLICATION = "continue_application", i.GENERIC_NEW_APPLICATION = "generic_new_application", i.INDICATIVE_NEW_APPLICATION = "indicative_new_application", i))(w || {});
2
- const c = "wayflyer-ui-package", S = "https://unpkg.com/@wf-financing/ui@1/dist/index.es.js", s = (i, e, a, n, o) => {
1
+ const a = "wayflyer-ui-package", s = "https://embedded-finance-frontend.vercel.app/npm/@wf-financing/ui@2", c = (n, t, i, d) => {
3
2
  if (!window.WayflyerUiCtaSdk)
4
3
  throw new Error("Failed to load WayflyerUiCtaSdk from the script.");
5
- const t = window.WayflyerUiCtaSdk;
6
- return new t(i, e, a, n, o);
7
- }, d = (i, e, a, n, o, t) => new Promise((r, l) => {
8
- i.onload = () => {
4
+ const e = window.WayflyerUiCtaSdk;
5
+ return new e(n, t, i, d);
6
+ }, o = (n, t, i, d, e) => new Promise((r, y) => {
7
+ n.onload = () => {
9
8
  try {
10
- r(s(e, a, n, o, t));
11
- } catch (y) {
12
- l(y);
9
+ r(c(t, i, d, e));
10
+ } catch (l) {
11
+ y(l);
13
12
  }
14
13
  };
15
- }), f = async (i, e, a, n, o) => {
14
+ }), f = async (n, t, i, d) => {
16
15
  try {
17
- const t = document.getElementById(c);
16
+ const e = document.getElementById(a);
18
17
  if (window.WayflyerUiCtaSdk)
19
- return s(i, e, a, n, o);
20
- if (t)
21
- return d(
22
- t,
23
- i,
24
- e,
25
- a,
26
- n,
27
- o
28
- );
18
+ return c(n, t, i, d);
19
+ if (e)
20
+ return o(e, n, t, i, d);
29
21
  const r = document.createElement("script");
30
- return r.src = S, r.type = "module", r.id = c, r.async = !0, document.head.appendChild(r), d(r, i, e, a, n, o);
31
- } catch (t) {
32
- throw console.error("Error in loading headless SDK:", t), new Error("Failed to load script");
22
+ return r.src = s, r.type = "module", r.id = a, r.async = !0, document.head.appendChild(r), o(r, n, t, i, d);
23
+ } catch (e) {
24
+ throw console.error("Error in loading headless SDK:", e), new Error("Failed to load script");
33
25
  }
34
26
  };
35
- class C {
36
- static async loadSdk(e, a, n, o, t) {
37
- return await f(e, a, n, o, t);
27
+ class w {
28
+ static async loadSdk(t, i, d, e) {
29
+ return await f(t, i, d, e);
38
30
  }
39
31
  }
40
32
  export {
41
- w as SdkScenarios,
42
- C as WayflyerUiSdk
33
+ w as WayflyerUiSdk
43
34
  };
@@ -1,5 +1,5 @@
1
- import { PartnerCallbackType, MockedModeType } from '@wf-financing/embedded-types';
1
+ import { PartnerCallbackType, SdkOptionsType } from '@wf-financing/embedded-types';
2
2
 
3
3
  export declare class WayflyerUiSdk {
4
- static loadSdk(targetId: string, partnerDesignId: string, partnerCallback: PartnerCallbackType, companyToken: string, mockedMode?: MockedModeType): Promise<void | import('@wf-financing/embedded-types').IWayflyerUiCtaSdk>;
4
+ static loadSdk(targetId: string, partnerCallback: PartnerCallbackType, companyToken: string, options?: SdkOptionsType): Promise<void | import('@wf-financing/embedded-types').IWayflyerUiCtaSdk>;
5
5
  }
@@ -1,5 +1,5 @@
1
- import { IWayflyerUiCtaSdk, PartnerCallbackType, MockedModeType } from '@wf-financing/embedded-types';
1
+ import { IWayflyerUiCtaSdk, PartnerCallbackType, SdkOptionsType } from '@wf-financing/embedded-types';
2
2
 
3
- type LoadUiSdkModeType = (targetId: string, partnerDesignId: string, partnerCallback: PartnerCallbackType, companyToken: string, mockedMode?: MockedModeType) => Promise<IWayflyerUiCtaSdk | void>;
3
+ type LoadUiSdkModeType = (targetId: string, partnerCallback: PartnerCallbackType, companyToken: string, options?: SdkOptionsType) => Promise<IWayflyerUiCtaSdk | void>;
4
4
  export declare const loadUiSdkMode: LoadUiSdkModeType;
5
5
  export {};
@@ -1,3 +1,3 @@
1
- import { IWayflyerUiCtaSdk, PartnerCallbackType, MockedModeType } from '@wf-financing/embedded-types';
1
+ import { IWayflyerUiCtaSdk, SdkOptionsType, PartnerCallbackType } from '@wf-financing/embedded-types';
2
2
 
3
- export declare const initializeUiSdk: (targetId: string, partnerDesignId: string, partnerCallback: PartnerCallbackType, companyToken: string, mockedMode?: MockedModeType) => IWayflyerUiCtaSdk;
3
+ export declare const initializeUiSdk: (targetId: string, partnerCallback: PartnerCallbackType, companyToken: string, options?: SdkOptionsType) => IWayflyerUiCtaSdk;
@@ -1,3 +1,3 @@
1
- import { IWayflyerUiCtaSdk, PartnerCallbackType, MockedModeType } from '@wf-financing/embedded-types';
1
+ import { IWayflyerUiCtaSdk, PartnerCallbackType, SdkOptionsType } from '@wf-financing/embedded-types';
2
2
 
3
- export declare const loadScriptAndInitializeSdk: (script: HTMLScriptElement, targetId: string, partnerDesignId: string, partnerCallback: PartnerCallbackType, companyToken: string, isMockedMode?: MockedModeType) => Promise<IWayflyerUiCtaSdk>;
3
+ export declare const loadScriptAndInitializeSdk: (script: HTMLScriptElement, targetId: string, partnerCallback: PartnerCallbackType, companyToken: string, options?: SdkOptionsType) => Promise<IWayflyerUiCtaSdk>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wf-financing/ui-sdk",
3
- "version": "0.1.2",
3
+ "version": "1.0.0",
4
4
  "main": "dist/index.cjs.js",
5
5
  "module": "dist/index.es.js",
6
6
  "types": "dist/index.d.ts",
@@ -15,7 +15,7 @@
15
15
  "dist"
16
16
  ],
17
17
  "dependencies": {
18
- "@wf-financing/embedded-types": "0.3.0"
18
+ "@wf-financing/embedded-types": "0.4.0"
19
19
  },
20
20
  "devDependencies": {
21
21
  "vite": "^6.3.5",