@inploi/sdk 0.6.0 → 0.7.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/cdn/plugins/accessibility.js +52 -48
- package/cdn/plugins/journeys.js +3 -3
- package/cdn/sdk.js +3 -3
- package/dist/accessibility/accessibility.d.mts +4 -2
- package/dist/accessibility/accessibility.d.ts +4 -2
- package/dist/accessibility/accessibility.js +1 -1
- package/dist/accessibility/accessibility.js.map +1 -1
- package/dist/accessibility/accessibility.mjs +1 -1
- package/dist/accessibility/accessibility.mjs.map +1 -1
- package/dist/chunk-WFTFPD6B.mjs +2 -0
- package/dist/chunk-WFTFPD6B.mjs.map +1 -0
- package/dist/{common.plugins-1ba83e05.d.ts → common.plugins-2d10f2e9.d.ts} +7 -7
- package/dist/journeys/journeys.d.mts +1 -1
- package/dist/journeys/journeys.d.ts +1 -1
- package/dist/journeys/journeys.js +1 -1
- package/dist/journeys/journeys.js.map +1 -1
- package/dist/journeys/journeys.mjs +1 -1
- package/dist/journeys/journeys.mjs.map +1 -1
- package/dist/sdk.d.mts +3 -3
- package/dist/sdk.d.ts +3 -3
- package/dist/sdk.js +1 -1
- package/dist/sdk.js.map +1 -1
- package/dist/sdk.mjs +1 -1
- package/dist/sdk.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-DG423OQK.mjs +0 -2
- package/dist/chunk-DG423OQK.mjs.map +0 -1
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
(() => {
|
|
5
5
|
// src/common/common.plugins.ts
|
|
6
6
|
var createPlugin = (pluginName, {
|
|
7
|
-
|
|
7
|
+
pure_createActions
|
|
8
8
|
}) => ({
|
|
9
9
|
pluginName,
|
|
10
|
-
|
|
10
|
+
pure_createActions
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
// src/accessibility/accessibility.constants.ts
|
|
@@ -15,52 +15,56 @@
|
|
|
15
15
|
|
|
16
16
|
// src/accessibility/accessibility.ts
|
|
17
17
|
var createAccessibilityPlugin = (params) => createPlugin("accessibility", {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
18
|
+
pure_createActions: ({ logger }) => {
|
|
19
|
+
return {
|
|
20
|
+
initialise: () => {
|
|
21
|
+
if (typeof window === "undefined")
|
|
22
|
+
return;
|
|
23
|
+
const a11yWidget = document.getElementById(WIDGET_SCRIPT_ID);
|
|
24
|
+
if (a11yWidget !== null)
|
|
25
|
+
return;
|
|
26
|
+
try {
|
|
27
|
+
const script = document.createElement("script");
|
|
28
|
+
const head = document.querySelector("head") || document.body;
|
|
29
|
+
script.id = WIDGET_SCRIPT_ID;
|
|
30
|
+
script.src = "https://acsbapp.com/apps/app/dist/js/app.js";
|
|
31
|
+
script.async = true;
|
|
32
|
+
script.onload = function() {
|
|
33
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
|
34
|
+
window.acsbJS.init({
|
|
35
|
+
statementLink: "",
|
|
36
|
+
footerHtml: "Powered by inploi",
|
|
37
|
+
hideMobile: false,
|
|
38
|
+
hideTrigger: params.showTrigger === false,
|
|
39
|
+
disableBgProcess: false,
|
|
40
|
+
language: (_a = params.language) != null ? _a : "en",
|
|
41
|
+
position: (_d = (_c = (_b = params.position) == null ? void 0 : _b.x) == null ? void 0 : _c.desktop) != null ? _d : "right",
|
|
42
|
+
leadColor: params.colors.interface,
|
|
43
|
+
triggerColor: params.colors.trigger,
|
|
44
|
+
triggerRadius: "50%",
|
|
45
|
+
triggerPositionX: (_g = (_f = (_e = params.position) == null ? void 0 : _e.x) == null ? void 0 : _f.desktop) != null ? _g : "right",
|
|
46
|
+
triggerPositionY: (_j = (_i = (_h = params.position) == null ? void 0 : _h.y) == null ? void 0 : _i.desktop) != null ? _j : "bottom",
|
|
47
|
+
triggerIcon: "people",
|
|
48
|
+
triggerSize: "medium",
|
|
49
|
+
triggerOffsetX: (_l = (_k = params.position) == null ? void 0 : _k.offsetX) == null ? void 0 : _l.desktop,
|
|
50
|
+
triggerOffsetY: (_n = (_m = params.position) == null ? void 0 : _m.offsetY) == null ? void 0 : _n.desktop,
|
|
51
|
+
mobile: {
|
|
52
|
+
triggerSize: "small",
|
|
53
|
+
triggerPositionX: (_q = (_p = (_o = params.position) == null ? void 0 : _o.x) == null ? void 0 : _p.mobile) != null ? _q : "right",
|
|
54
|
+
triggerPositionY: (_t = (_s = (_r = params.position) == null ? void 0 : _r.y) == null ? void 0 : _s.mobile) != null ? _t : "bottom",
|
|
55
|
+
triggerOffsetX: (_w = (_v = (_u = params.position) == null ? void 0 : _u.offsetX) == null ? void 0 : _v.mobile) != null ? _w : 4,
|
|
56
|
+
triggerOffsetY: (_z = (_y = (_x = params.position) == null ? void 0 : _x.offsetY) == null ? void 0 : _y.mobile) != null ? _z : 4,
|
|
57
|
+
triggerRadius: "20"
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
head.appendChild(script);
|
|
62
|
+
logger == null ? void 0 : logger.info("Accessibility plugin initialised");
|
|
63
|
+
} catch (error) {
|
|
64
|
+
logger == null ? void 0 : logger.error("Accessibility plugin failed to initialise", error);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
64
68
|
}
|
|
65
69
|
});
|
|
66
70
|
|
package/cdn/plugins/journeys.js
CHANGED
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
|
|
26
26
|
// src/common/common.plugins.ts
|
|
27
27
|
var createPlugin = (pluginName, {
|
|
28
|
-
|
|
28
|
+
pure_createActions
|
|
29
29
|
}) => ({
|
|
30
30
|
pluginName,
|
|
31
|
-
|
|
31
|
+
pure_createActions
|
|
32
32
|
});
|
|
33
33
|
|
|
34
34
|
// src/common/common.constants.ts
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
// src/journeys/journeys.ts
|
|
82
|
-
var journeysPlugin = createPlugin("journey", {
|
|
82
|
+
var journeysPlugin = createPlugin("journey", { pure_createActions: initialiseJourneysPlugin });
|
|
83
83
|
|
|
84
84
|
// src/journeys/journeys.cdn.ts
|
|
85
85
|
if (typeof window.inploi !== "object") {
|
package/cdn/sdk.js
CHANGED
|
@@ -98,14 +98,14 @@
|
|
|
98
98
|
logger = inploiBrandedLogger
|
|
99
99
|
}) {
|
|
100
100
|
const apiClient = createApiClient({ baseUrl: ENV_TO_API_URL[env], publishableKey });
|
|
101
|
-
const
|
|
101
|
+
const pluginActions = plugins.reduce(
|
|
102
102
|
(acc, plugin) => {
|
|
103
|
-
acc[plugin.pluginName] = plugin.
|
|
103
|
+
acc[plugin.pluginName] = plugin.pure_createActions({ apiClient, logger });
|
|
104
104
|
return acc;
|
|
105
105
|
},
|
|
106
106
|
{}
|
|
107
107
|
);
|
|
108
|
-
return
|
|
108
|
+
return pluginActions;
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
// src/sdk.cdn.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as Plugin } from '../common.plugins-
|
|
1
|
+
import { P as Plugin } from '../common.plugins-2d10f2e9.js';
|
|
2
2
|
|
|
3
3
|
type AccessibeSize = 'small' | 'medium' | 'big';
|
|
4
4
|
type HorizontalPosition = 'left' | 'right';
|
|
@@ -56,6 +56,8 @@ type AccessibilityPluginParams = {
|
|
|
56
56
|
offsetY?: Responsive<number>;
|
|
57
57
|
};
|
|
58
58
|
};
|
|
59
|
-
declare const createAccessibilityPlugin: (params: AccessibilityPluginParams) => Plugin<"accessibility",
|
|
59
|
+
declare const createAccessibilityPlugin: (params: AccessibilityPluginParams) => Plugin<"accessibility", {
|
|
60
|
+
initialise: () => void;
|
|
61
|
+
}>;
|
|
60
62
|
|
|
61
63
|
export { AccessibilityPluginParams, createAccessibilityPlugin };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as Plugin } from '../common.plugins-
|
|
1
|
+
import { P as Plugin } from '../common.plugins-2d10f2e9.js';
|
|
2
2
|
|
|
3
3
|
type AccessibeSize = 'small' | 'medium' | 'big';
|
|
4
4
|
type HorizontalPosition = 'left' | 'right';
|
|
@@ -56,6 +56,8 @@ type AccessibilityPluginParams = {
|
|
|
56
56
|
offsetY?: Responsive<number>;
|
|
57
57
|
};
|
|
58
58
|
};
|
|
59
|
-
declare const createAccessibilityPlugin: (params: AccessibilityPluginParams) => Plugin<"accessibility",
|
|
59
|
+
declare const createAccessibilityPlugin: (params: AccessibilityPluginParams) => Plugin<"accessibility", {
|
|
60
|
+
initialise: () => void;
|
|
61
|
+
}>;
|
|
60
62
|
|
|
61
63
|
export { AccessibilityPluginParams, createAccessibilityPlugin };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var s=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var O=(i,e)=>{for(var n in e)s(i,n,{get:e[n],enumerable:!0})},W=(i,e,n,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of D(e))!E.call(i,o)&&o!==n&&s(i,o,{get:()=>e[o],enumerable:!(t=z(e,o))||t.enumerable});return i};var H=i=>W(s({},"__esModule",{value:!0}),i);var B={};O(B,{createAccessibilityPlugin:()=>j});module.exports=H(B);var L=(i,{pure_createActions:e})=>({pluginName:i,pure_createActions:e});var r="inploi-a11y";var j=i=>L("accessibility",{pure_createActions:({logger:e})=>({initialise:()=>{if(!(typeof window=="undefined"||document.getElementById(r)!==null))try{let t=document.createElement("script"),o=document.querySelector("head")||document.body;t.id=r,t.src="https://acsbapp.com/apps/app/dist/js/app.js",t.async=!0,t.onload=function(){var g,l,c,p,a,u,d,f,P,m,b,y,T,x,h,A,R,k,w,C,I,X,Y,_,S,v;window.acsbJS.init({statementLink:"",footerHtml:"Powered by inploi",hideMobile:!1,hideTrigger:i.showTrigger===!1,disableBgProcess:!1,language:(g=i.language)!=null?g:"en",position:(p=(c=(l=i.position)==null?void 0:l.x)==null?void 0:c.desktop)!=null?p:"right",leadColor:i.colors.interface,triggerColor:i.colors.trigger,triggerRadius:"50%",triggerPositionX:(d=(u=(a=i.position)==null?void 0:a.x)==null?void 0:u.desktop)!=null?d:"right",triggerPositionY:(m=(P=(f=i.position)==null?void 0:f.y)==null?void 0:P.desktop)!=null?m:"bottom",triggerIcon:"people",triggerSize:"medium",triggerOffsetX:(y=(b=i.position)==null?void 0:b.offsetX)==null?void 0:y.desktop,triggerOffsetY:(x=(T=i.position)==null?void 0:T.offsetY)==null?void 0:x.desktop,mobile:{triggerSize:"small",triggerPositionX:(R=(A=(h=i.position)==null?void 0:h.x)==null?void 0:A.mobile)!=null?R:"right",triggerPositionY:(C=(w=(k=i.position)==null?void 0:k.y)==null?void 0:w.mobile)!=null?C:"bottom",triggerOffsetX:(Y=(X=(I=i.position)==null?void 0:I.offsetX)==null?void 0:X.mobile)!=null?Y:4,triggerOffsetY:(v=(S=(_=i.position)==null?void 0:_.offsetY)==null?void 0:S.mobile)!=null?v:4,triggerRadius:"20"}})},o.appendChild(t),e==null||e.info("Accessibility plugin initialised")}catch(t){e==null||e.error("Accessibility plugin failed to initialise",t)}}})});0&&(module.exports={createAccessibilityPlugin});
|
|
2
2
|
//# sourceMappingURL=accessibility.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/accessibility/accessibility.ts","../../src/common/common.plugins.ts","../../src/accessibility/accessibility.constants.ts"],"sourcesContent":["import { createPlugin } from '../common/common.plugins';\nimport { WIDGET_SCRIPT_ID } from './accessibility.constants';\nimport { AccessibilityPluginLanguage, HorizontalPosition, VerticalPosition } from './accessibility.types';\n\ntype Responsive<T> = {\n\tmobile: T;\n\tdesktop: T;\n};\n\nexport type AccessibilityPluginParams = {\n\tlanguage?: AccessibilityPluginLanguage;\n\tcolors: {\n\t\tinterface: string;\n\t\ttrigger: string;\n\t};\n\tshowTrigger?: boolean;\n\tposition?: {\n\t\tx?: Responsive<HorizontalPosition>;\n\t\ty?: Responsive<VerticalPosition>;\n\t\toffsetX?: Responsive<number>;\n\t\toffsetY?: Responsive<number>;\n\t};\n};\n\nexport const createAccessibilityPlugin = (params: AccessibilityPluginParams) =>\n\tcreatePlugin('accessibility', {\n\t\
|
|
1
|
+
{"version":3,"sources":["../../src/accessibility/accessibility.ts","../../src/common/common.plugins.ts","../../src/accessibility/accessibility.constants.ts"],"sourcesContent":["import { createPlugin } from '../common/common.plugins';\nimport { WIDGET_SCRIPT_ID } from './accessibility.constants';\nimport { AccessibilityPluginLanguage, HorizontalPosition, VerticalPosition } from './accessibility.types';\n\ntype Responsive<T> = {\n\tmobile: T;\n\tdesktop: T;\n};\n\nexport type AccessibilityPluginParams = {\n\tlanguage?: AccessibilityPluginLanguage;\n\tcolors: {\n\t\tinterface: string;\n\t\ttrigger: string;\n\t};\n\tshowTrigger?: boolean;\n\tposition?: {\n\t\tx?: Responsive<HorizontalPosition>;\n\t\ty?: Responsive<VerticalPosition>;\n\t\toffsetX?: Responsive<number>;\n\t\toffsetY?: Responsive<number>;\n\t};\n};\n\nexport const createAccessibilityPlugin = (params: AccessibilityPluginParams) =>\n\tcreatePlugin('accessibility', {\n\t\tpure_createActions: ({ logger }) => {\n\t\t\treturn {\n\t\t\t\tinitialise: () => {\n\t\t\t\t\tif (typeof window === 'undefined') return;\n\t\t\t\t\tconst a11yWidget = document.getElementById(WIDGET_SCRIPT_ID);\n\t\t\t\t\tif (a11yWidget !== null) return;\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst script = document.createElement('script');\n\t\t\t\t\t\tconst head = document.querySelector('head') || document.body;\n\t\t\t\t\t\tscript.id = WIDGET_SCRIPT_ID;\n\t\t\t\t\t\tscript.src = 'https://acsbapp.com/apps/app/dist/js/app.js';\n\t\t\t\t\t\tscript.async = true;\n\t\t\t\t\t\tscript.onload = function () {\n\t\t\t\t\t\t\twindow.acsbJS.init({\n\t\t\t\t\t\t\t\tstatementLink: '',\n\t\t\t\t\t\t\t\tfooterHtml: 'Powered by inploi',\n\t\t\t\t\t\t\t\thideMobile: false,\n\t\t\t\t\t\t\t\thideTrigger: params.showTrigger === false,\n\t\t\t\t\t\t\t\tdisableBgProcess: false,\n\t\t\t\t\t\t\t\tlanguage: params.language ?? 'en',\n\t\t\t\t\t\t\t\tposition: params.position?.x?.desktop ?? 'right',\n\t\t\t\t\t\t\t\tleadColor: params.colors.interface,\n\t\t\t\t\t\t\t\ttriggerColor: params.colors.trigger,\n\t\t\t\t\t\t\t\ttriggerRadius: '50%',\n\t\t\t\t\t\t\t\ttriggerPositionX: params.position?.x?.desktop ?? 'right',\n\t\t\t\t\t\t\t\ttriggerPositionY: params.position?.y?.desktop ?? 'bottom',\n\t\t\t\t\t\t\t\ttriggerIcon: 'people',\n\t\t\t\t\t\t\t\ttriggerSize: 'medium',\n\t\t\t\t\t\t\t\ttriggerOffsetX: params.position?.offsetX?.desktop,\n\t\t\t\t\t\t\t\ttriggerOffsetY: params.position?.offsetY?.desktop,\n\t\t\t\t\t\t\t\tmobile: {\n\t\t\t\t\t\t\t\t\ttriggerSize: 'small',\n\t\t\t\t\t\t\t\t\ttriggerPositionX: params.position?.x?.mobile ?? 'right',\n\t\t\t\t\t\t\t\t\ttriggerPositionY: params.position?.y?.mobile ?? 'bottom',\n\t\t\t\t\t\t\t\t\ttriggerOffsetX: params.position?.offsetX?.mobile ?? 4,\n\t\t\t\t\t\t\t\t\ttriggerOffsetY: params.position?.offsetY?.mobile ?? 4,\n\t\t\t\t\t\t\t\t\ttriggerRadius: '20',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t};\n\t\t\t\t\t\thead.appendChild(script);\n\t\t\t\t\t\tlogger?.info('Accessibility plugin initialised');\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tlogger?.error('Accessibility plugin failed to initialise', error);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t});\n","import { ApiClient } from '../journeys/journeys.api';\nimport { Logger } from './common.logger';\n\nexport type PluginParams = {\n\tapiClient: ApiClient;\n\tlogger?: Logger;\n};\n\nexport type Plugin<T extends string, P extends Record<string, unknown>> = {\n\tpluginName: T;\n\tpure_createActions: (params: PluginParams) => P;\n};\n\nexport const createPlugin = <T extends string, P extends Record<string, unknown>>(\n\t/** The plugin name to access its properties.\n\t * @example const myPluginVariable = createPlugin('myPluginName', { initialise: () => 'works' });\n\t * const sdk = initialiseSdk({plugins: [myPluginVariable]});\n\t * sdk.myPluginName // 'works'\n\t * sdk.myPluginVariable // undefined\n\t */\n\tpluginName: T,\n\t{\n\t\tpure_createActions,\n\t}: {\n\t\t/** **Pure** function that returns the plugin’s exposed actions.\n\t\t * ⚠️ any code ran inside this function is **not** guaranteed to run on browser initialisation.\n\t\t * If your plugin requires initialisation, or sideEffects, expose an `initialise` function from this.\n\t\t * @example const plugin = createPlugin('foo', { initialise: () => ({ bar: 'baz' }) });\n\t\t * const sdk = initialiseSdk({plugins: [plugin]});\n\t\t * sdk.foo.bar // 'baz'\n\t\t */\n\t\tpure_createActions: (params: PluginParams) => P;\n\t},\n): Plugin<T, P> => ({\n\tpluginName,\n\tpure_createActions,\n});\n","export const WIDGET_SCRIPT_ID = 'inploi-a11y';\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,+BAAAE,IAAA,eAAAC,EAAAH,GCaO,IAAMI,EAAe,CAO3BC,EACA,CACC,mBAAAC,CACD,KAUmB,CACnB,WAAAD,EACA,mBAAAC,CACD,GCpCO,IAAMC,EAAmB,cFwBzB,IAAMC,EAA6BC,GACzCC,EAAa,gBAAiB,CAC7B,mBAAoB,CAAC,CAAE,OAAAC,CAAO,KACtB,CACN,WAAY,IAAM,CAGjB,GAFI,SAAO,QAAW,aACH,SAAS,eAAeC,CAAgB,IACxC,MAEnB,GAAI,CACH,IAAMC,EAAS,SAAS,cAAc,QAAQ,EACxCC,EAAO,SAAS,cAAc,MAAM,GAAK,SAAS,KACxDD,EAAO,GAAKD,EACZC,EAAO,IAAM,8CACbA,EAAO,MAAQ,GACfA,EAAO,OAAS,UAAY,CAvClC,IAAAE,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAwCO,OAAO,OAAO,KAAK,CAClB,cAAe,GACf,WAAY,oBACZ,WAAY,GACZ,YAAa/B,EAAO,cAAgB,GACpC,iBAAkB,GAClB,UAAUM,EAAAN,EAAO,WAAP,KAAAM,EAAmB,KAC7B,UAAUG,GAAAD,GAAAD,EAAAP,EAAO,WAAP,YAAAO,EAAiB,IAAjB,YAAAC,EAAoB,UAApB,KAAAC,EAA+B,QACzC,UAAWT,EAAO,OAAO,UACzB,aAAcA,EAAO,OAAO,QAC5B,cAAe,MACf,kBAAkBY,GAAAD,GAAAD,EAAAV,EAAO,WAAP,YAAAU,EAAiB,IAAjB,YAAAC,EAAoB,UAApB,KAAAC,EAA+B,QACjD,kBAAkBG,GAAAD,GAAAD,EAAAb,EAAO,WAAP,YAAAa,EAAiB,IAAjB,YAAAC,EAAoB,UAApB,KAAAC,EAA+B,SACjD,YAAa,SACb,YAAa,SACb,gBAAgBE,GAAAD,EAAAhB,EAAO,WAAP,YAAAgB,EAAiB,UAAjB,YAAAC,EAA0B,QAC1C,gBAAgBE,GAAAD,EAAAlB,EAAO,WAAP,YAAAkB,EAAiB,UAAjB,YAAAC,EAA0B,QAC1C,OAAQ,CACP,YAAa,QACb,kBAAkBG,GAAAD,GAAAD,EAAApB,EAAO,WAAP,YAAAoB,EAAiB,IAAjB,YAAAC,EAAoB,SAApB,KAAAC,EAA8B,QAChD,kBAAkBG,GAAAD,GAAAD,EAAAvB,EAAO,WAAP,YAAAuB,EAAiB,IAAjB,YAAAC,EAAoB,SAApB,KAAAC,EAA8B,SAChD,gBAAgBG,GAAAD,GAAAD,EAAA1B,EAAO,WAAP,YAAA0B,EAAiB,UAAjB,YAAAC,EAA0B,SAA1B,KAAAC,EAAoC,EACpD,gBAAgBG,GAAAD,GAAAD,EAAA7B,EAAO,WAAP,YAAA6B,EAAiB,UAAjB,YAAAC,EAA0B,SAA1B,KAAAC,EAAoC,EACpD,cAAe,IAChB,CACD,CAAC,CACF,EACA1B,EAAK,YAAYD,CAAM,EACvBF,GAAA,MAAAA,EAAQ,KAAK,mCACd,OAAS8B,EAAO,CACf9B,GAAA,MAAAA,EAAQ,MAAM,4CAA6C8B,EAC5D,CACD,CACD,EAEF,CAAC","names":["accessibility_exports","__export","createAccessibilityPlugin","__toCommonJS","createPlugin","pluginName","pure_createActions","WIDGET_SCRIPT_ID","createAccessibilityPlugin","params","createPlugin","logger","WIDGET_SCRIPT_ID","script","head","_a","_b","_c","_d","_e","_f","_g","_h","_i","_j","_k","_l","_m","_n","_o","_p","_q","_r","_s","_t","_u","_v","_w","_x","_y","_z","error"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{d as v}from"../chunk-
|
|
1
|
+
import{d as v}from"../chunk-WFTFPD6B.mjs";var o="inploi-a11y";var O=i=>v("accessibility",{pure_createActions:({logger:t})=>({initialise:()=>{if(!(typeof window=="undefined"||document.getElementById(o)!==null))try{let e=document.createElement("script"),C=document.querySelector("head")||document.body;e.id=o,e.src="https://acsbapp.com/apps/app/dist/js/app.js",e.async=!0,e.onload=function(){var s,n,r,c,l,g,p,f,d,u,a,b,y,P,m,h,T,R,A,I,k,w,x,X,Y,S;window.acsbJS.init({statementLink:"",footerHtml:"Powered by inploi",hideMobile:!1,hideTrigger:i.showTrigger===!1,disableBgProcess:!1,language:(s=i.language)!=null?s:"en",position:(c=(r=(n=i.position)==null?void 0:n.x)==null?void 0:r.desktop)!=null?c:"right",leadColor:i.colors.interface,triggerColor:i.colors.trigger,triggerRadius:"50%",triggerPositionX:(p=(g=(l=i.position)==null?void 0:l.x)==null?void 0:g.desktop)!=null?p:"right",triggerPositionY:(u=(d=(f=i.position)==null?void 0:f.y)==null?void 0:d.desktop)!=null?u:"bottom",triggerIcon:"people",triggerSize:"medium",triggerOffsetX:(b=(a=i.position)==null?void 0:a.offsetX)==null?void 0:b.desktop,triggerOffsetY:(P=(y=i.position)==null?void 0:y.offsetY)==null?void 0:P.desktop,mobile:{triggerSize:"small",triggerPositionX:(T=(h=(m=i.position)==null?void 0:m.x)==null?void 0:h.mobile)!=null?T:"right",triggerPositionY:(I=(A=(R=i.position)==null?void 0:R.y)==null?void 0:A.mobile)!=null?I:"bottom",triggerOffsetX:(x=(w=(k=i.position)==null?void 0:k.offsetX)==null?void 0:w.mobile)!=null?x:4,triggerOffsetY:(S=(Y=(X=i.position)==null?void 0:X.offsetY)==null?void 0:Y.mobile)!=null?S:4,triggerRadius:"20"}})},C.appendChild(e),t==null||t.info("Accessibility plugin initialised")}catch(e){t==null||t.error("Accessibility plugin failed to initialise",e)}}})});export{O as createAccessibilityPlugin};
|
|
2
2
|
//# sourceMappingURL=accessibility.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/accessibility/accessibility.constants.ts","../../src/accessibility/accessibility.ts"],"sourcesContent":["export const WIDGET_SCRIPT_ID = 'inploi-a11y';\n","import { createPlugin } from '../common/common.plugins';\nimport { WIDGET_SCRIPT_ID } from './accessibility.constants';\nimport { AccessibilityPluginLanguage, HorizontalPosition, VerticalPosition } from './accessibility.types';\n\ntype Responsive<T> = {\n\tmobile: T;\n\tdesktop: T;\n};\n\nexport type AccessibilityPluginParams = {\n\tlanguage?: AccessibilityPluginLanguage;\n\tcolors: {\n\t\tinterface: string;\n\t\ttrigger: string;\n\t};\n\tshowTrigger?: boolean;\n\tposition?: {\n\t\tx?: Responsive<HorizontalPosition>;\n\t\ty?: Responsive<VerticalPosition>;\n\t\toffsetX?: Responsive<number>;\n\t\toffsetY?: Responsive<number>;\n\t};\n};\n\nexport const createAccessibilityPlugin = (params: AccessibilityPluginParams) =>\n\tcreatePlugin('accessibility', {\n\t\
|
|
1
|
+
{"version":3,"sources":["../../src/accessibility/accessibility.constants.ts","../../src/accessibility/accessibility.ts"],"sourcesContent":["export const WIDGET_SCRIPT_ID = 'inploi-a11y';\n","import { createPlugin } from '../common/common.plugins';\nimport { WIDGET_SCRIPT_ID } from './accessibility.constants';\nimport { AccessibilityPluginLanguage, HorizontalPosition, VerticalPosition } from './accessibility.types';\n\ntype Responsive<T> = {\n\tmobile: T;\n\tdesktop: T;\n};\n\nexport type AccessibilityPluginParams = {\n\tlanguage?: AccessibilityPluginLanguage;\n\tcolors: {\n\t\tinterface: string;\n\t\ttrigger: string;\n\t};\n\tshowTrigger?: boolean;\n\tposition?: {\n\t\tx?: Responsive<HorizontalPosition>;\n\t\ty?: Responsive<VerticalPosition>;\n\t\toffsetX?: Responsive<number>;\n\t\toffsetY?: Responsive<number>;\n\t};\n};\n\nexport const createAccessibilityPlugin = (params: AccessibilityPluginParams) =>\n\tcreatePlugin('accessibility', {\n\t\tpure_createActions: ({ logger }) => {\n\t\t\treturn {\n\t\t\t\tinitialise: () => {\n\t\t\t\t\tif (typeof window === 'undefined') return;\n\t\t\t\t\tconst a11yWidget = document.getElementById(WIDGET_SCRIPT_ID);\n\t\t\t\t\tif (a11yWidget !== null) return;\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst script = document.createElement('script');\n\t\t\t\t\t\tconst head = document.querySelector('head') || document.body;\n\t\t\t\t\t\tscript.id = WIDGET_SCRIPT_ID;\n\t\t\t\t\t\tscript.src = 'https://acsbapp.com/apps/app/dist/js/app.js';\n\t\t\t\t\t\tscript.async = true;\n\t\t\t\t\t\tscript.onload = function () {\n\t\t\t\t\t\t\twindow.acsbJS.init({\n\t\t\t\t\t\t\t\tstatementLink: '',\n\t\t\t\t\t\t\t\tfooterHtml: 'Powered by inploi',\n\t\t\t\t\t\t\t\thideMobile: false,\n\t\t\t\t\t\t\t\thideTrigger: params.showTrigger === false,\n\t\t\t\t\t\t\t\tdisableBgProcess: false,\n\t\t\t\t\t\t\t\tlanguage: params.language ?? 'en',\n\t\t\t\t\t\t\t\tposition: params.position?.x?.desktop ?? 'right',\n\t\t\t\t\t\t\t\tleadColor: params.colors.interface,\n\t\t\t\t\t\t\t\ttriggerColor: params.colors.trigger,\n\t\t\t\t\t\t\t\ttriggerRadius: '50%',\n\t\t\t\t\t\t\t\ttriggerPositionX: params.position?.x?.desktop ?? 'right',\n\t\t\t\t\t\t\t\ttriggerPositionY: params.position?.y?.desktop ?? 'bottom',\n\t\t\t\t\t\t\t\ttriggerIcon: 'people',\n\t\t\t\t\t\t\t\ttriggerSize: 'medium',\n\t\t\t\t\t\t\t\ttriggerOffsetX: params.position?.offsetX?.desktop,\n\t\t\t\t\t\t\t\ttriggerOffsetY: params.position?.offsetY?.desktop,\n\t\t\t\t\t\t\t\tmobile: {\n\t\t\t\t\t\t\t\t\ttriggerSize: 'small',\n\t\t\t\t\t\t\t\t\ttriggerPositionX: params.position?.x?.mobile ?? 'right',\n\t\t\t\t\t\t\t\t\ttriggerPositionY: params.position?.y?.mobile ?? 'bottom',\n\t\t\t\t\t\t\t\t\ttriggerOffsetX: params.position?.offsetX?.mobile ?? 4,\n\t\t\t\t\t\t\t\t\ttriggerOffsetY: params.position?.offsetY?.mobile ?? 4,\n\t\t\t\t\t\t\t\t\ttriggerRadius: '20',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t};\n\t\t\t\t\t\thead.appendChild(script);\n\t\t\t\t\t\tlogger?.info('Accessibility plugin initialised');\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tlogger?.error('Accessibility plugin failed to initialise', error);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t});\n"],"mappings":"0CAAO,IAAMA,EAAmB,cCwBzB,IAAMC,EAA6BC,GACzCC,EAAa,gBAAiB,CAC7B,mBAAoB,CAAC,CAAE,OAAAC,CAAO,KACtB,CACN,WAAY,IAAM,CAGjB,GAFI,SAAO,QAAW,aACH,SAAS,eAAeC,CAAgB,IACxC,MAEnB,GAAI,CACH,IAAMC,EAAS,SAAS,cAAc,QAAQ,EACxCC,EAAO,SAAS,cAAc,MAAM,GAAK,SAAS,KACxDD,EAAO,GAAKD,EACZC,EAAO,IAAM,8CACbA,EAAO,MAAQ,GACfA,EAAO,OAAS,UAAY,CAvClC,IAAAE,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAwCO,OAAO,OAAO,KAAK,CAClB,cAAe,GACf,WAAY,oBACZ,WAAY,GACZ,YAAa/B,EAAO,cAAgB,GACpC,iBAAkB,GAClB,UAAUM,EAAAN,EAAO,WAAP,KAAAM,EAAmB,KAC7B,UAAUG,GAAAD,GAAAD,EAAAP,EAAO,WAAP,YAAAO,EAAiB,IAAjB,YAAAC,EAAoB,UAApB,KAAAC,EAA+B,QACzC,UAAWT,EAAO,OAAO,UACzB,aAAcA,EAAO,OAAO,QAC5B,cAAe,MACf,kBAAkBY,GAAAD,GAAAD,EAAAV,EAAO,WAAP,YAAAU,EAAiB,IAAjB,YAAAC,EAAoB,UAApB,KAAAC,EAA+B,QACjD,kBAAkBG,GAAAD,GAAAD,EAAAb,EAAO,WAAP,YAAAa,EAAiB,IAAjB,YAAAC,EAAoB,UAApB,KAAAC,EAA+B,SACjD,YAAa,SACb,YAAa,SACb,gBAAgBE,GAAAD,EAAAhB,EAAO,WAAP,YAAAgB,EAAiB,UAAjB,YAAAC,EAA0B,QAC1C,gBAAgBE,GAAAD,EAAAlB,EAAO,WAAP,YAAAkB,EAAiB,UAAjB,YAAAC,EAA0B,QAC1C,OAAQ,CACP,YAAa,QACb,kBAAkBG,GAAAD,GAAAD,EAAApB,EAAO,WAAP,YAAAoB,EAAiB,IAAjB,YAAAC,EAAoB,SAApB,KAAAC,EAA8B,QAChD,kBAAkBG,GAAAD,GAAAD,EAAAvB,EAAO,WAAP,YAAAuB,EAAiB,IAAjB,YAAAC,EAAoB,SAApB,KAAAC,EAA8B,SAChD,gBAAgBG,GAAAD,GAAAD,EAAA1B,EAAO,WAAP,YAAA0B,EAAiB,UAAjB,YAAAC,EAA0B,SAA1B,KAAAC,EAAoC,EACpD,gBAAgBG,GAAAD,GAAAD,EAAA7B,EAAO,WAAP,YAAA6B,EAAiB,UAAjB,YAAAC,EAA0B,SAA1B,KAAAC,EAAoC,EACpD,cAAe,IAChB,CACD,CAAC,CACF,EACA1B,EAAK,YAAYD,CAAM,EACvBF,GAAA,MAAAA,EAAQ,KAAK,mCACd,OAAS8B,EAAO,CACf9B,GAAA,MAAAA,EAAQ,MAAM,4CAA6C8B,EAC5D,CACD,CACD,EAEF,CAAC","names":["WIDGET_SCRIPT_ID","createAccessibilityPlugin","params","createPlugin","logger","WIDGET_SCRIPT_ID","script","head","_a","_b","_c","_d","_e","_f","_g","_h","_i","_j","_k","_l","_m","_n","_o","_p","_q","_r","_s","_t","_u","_v","_w","_x","_y","_z","error"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var u=Object.defineProperty,m=Object.defineProperties;var c=Object.getOwnPropertyDescriptors;var s=Object.getOwnPropertySymbols;var x=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable;var a=(r,e,n)=>e in r?u(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n,T=(r,e)=>{for(var n in e||(e={}))x.call(e,n)&&a(r,n,e[n]);if(s)for(var n of s(e))d.call(e,n)&&a(r,n,e[n]);return r},A=(r,e)=>m(r,c(e));var C=(r,e,n)=>new Promise((p,o)=>{var P=t=>{try{i(n.next(t))}catch(g){o(g)}},l=t=>{try{i(n.throw(t))}catch(g){o(g)}},i=t=>t.done?p(t.value):Promise.resolve(t.value).then(P,l);i((n=n.apply(r,e)).next())});var k=(r,{pure_createActions:e})=>({pluginName:r,pure_createActions:e});export{T as a,A as b,C as c,k as d};
|
|
2
|
+
//# sourceMappingURL=chunk-WFTFPD6B.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/common/common.plugins.ts"],"sourcesContent":["import { ApiClient } from '../journeys/journeys.api';\nimport { Logger } from './common.logger';\n\nexport type PluginParams = {\n\tapiClient: ApiClient;\n\tlogger?: Logger;\n};\n\nexport type Plugin<T extends string, P extends Record<string, unknown>> = {\n\tpluginName: T;\n\tpure_createActions: (params: PluginParams) => P;\n};\n\nexport const createPlugin = <T extends string, P extends Record<string, unknown>>(\n\t/** The plugin name to access its properties.\n\t * @example const myPluginVariable = createPlugin('myPluginName', { initialise: () => 'works' });\n\t * const sdk = initialiseSdk({plugins: [myPluginVariable]});\n\t * sdk.myPluginName // 'works'\n\t * sdk.myPluginVariable // undefined\n\t */\n\tpluginName: T,\n\t{\n\t\tpure_createActions,\n\t}: {\n\t\t/** **Pure** function that returns the plugin’s exposed actions.\n\t\t * ⚠️ any code ran inside this function is **not** guaranteed to run on browser initialisation.\n\t\t * If your plugin requires initialisation, or sideEffects, expose an `initialise` function from this.\n\t\t * @example const plugin = createPlugin('foo', { initialise: () => ({ bar: 'baz' }) });\n\t\t * const sdk = initialiseSdk({plugins: [plugin]});\n\t\t * sdk.foo.bar // 'baz'\n\t\t */\n\t\tpure_createActions: (params: PluginParams) => P;\n\t},\n): Plugin<T, P> => ({\n\tpluginName,\n\tpure_createActions,\n});\n"],"mappings":"0nBAaO,IAAMA,EAAe,CAO3BC,EACA,CACC,mBAAAC,CACD,KAUmB,CACnB,WAAAD,EACA,mBAAAC,CACD","names":["createPlugin","pluginName","pure_createActions"]}
|
|
@@ -18,19 +18,19 @@ type PluginParams = {
|
|
|
18
18
|
apiClient: ApiClient;
|
|
19
19
|
logger?: Logger;
|
|
20
20
|
};
|
|
21
|
-
type Plugin<T extends string, P
|
|
21
|
+
type Plugin<T extends string, P extends Record<string, unknown>> = {
|
|
22
22
|
pluginName: T;
|
|
23
|
-
|
|
23
|
+
pure_createActions: (params: PluginParams) => P;
|
|
24
24
|
};
|
|
25
|
-
declare const createPlugin: <T extends string, P
|
|
26
|
-
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
25
|
+
declare const createPlugin: <T extends string, P extends Record<string, unknown>>(pluginName: T, { pure_createActions, }: {
|
|
26
|
+
/** **Pure** function that returns the plugin’s exposed actions.
|
|
27
|
+
* ⚠️ any code ran inside this function is **not** guaranteed to run on browser initialisation.
|
|
28
|
+
* If your plugin requires initialisation, or sideEffects, expose an `initialise` function from this.
|
|
29
29
|
* @example const plugin = createPlugin('foo', { initialise: () => ({ bar: 'baz' }) });
|
|
30
30
|
* const sdk = initialiseSdk({plugins: [plugin]});
|
|
31
31
|
* sdk.foo.bar // 'baz'
|
|
32
32
|
*/
|
|
33
|
-
|
|
33
|
+
pure_createActions: (params: PluginParams) => P;
|
|
34
34
|
}) => Plugin<T, P>;
|
|
35
35
|
|
|
36
36
|
export { CONSOLE_PREFIX as C, Logger as L, Plugin as P, CONSOLE_STYLE as a, createPlugin as c, inploiBrandedLogger as i, noLogging as n };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var a=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var E=(r,e)=>{for(var n in e)a(r,n,{get:e[n],enumerable:!0})},v=(r,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of d(e))!f.call(r,t)&&t!==n&&a(r,t,{get:()=>e[t],enumerable:!(o=y(e,t))||o.enumerable});return r};var T=r=>v(a({},"__esModule",{value:!0}),r);var P=(r,e,n)=>new Promise((o,t)=>{var
|
|
1
|
+
"use strict";var a=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var E=(r,e)=>{for(var n in e)a(r,n,{get:e[n],enumerable:!0})},v=(r,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of d(e))!f.call(r,t)&&t!==n&&a(r,t,{get:()=>e[t],enumerable:!(o=y(e,t))||o.enumerable});return r};var T=r=>v(a({},"__esModule",{value:!0}),r);var P=(r,e,n)=>new Promise((o,t)=>{var l=i=>{try{p(n.next(i))}catch(s){t(s)}},g=i=>{try{p(n.throw(i))}catch(s){t(s)}},p=i=>i.done?o(i.value):Promise.resolve(i.value).then(l,g);p((n=n.apply(r,e)).next())});var A={};E(A,{journeysPlugin:()=>x});module.exports=T(A);var u=(r,{pure_createActions:e})=>({pluginName:r,pure_createActions:e});var m="/journey/log";function c({apiClient:r,logger:e}){function n(o){return P(this,null,function*(){try{let t={event:o.event,sent_at:new Date().toISOString(),context:{library:{name:"inploi-sdk",version:1},page:{href:location.href,referrer:document.referrer,title:document.title}},properties:o.properties,custom_properties:o.customProperties};return yield r.fetch(m,{method:"POST",body:JSON.stringify(t)}),{success:!0,data:t}}catch(t){return e==null||e.error("Failed to send journey log to API. Inspect error response of `log` for more information."),{success:!1,error:t}}})}return{log:n}}var x=u("journey",{pure_createActions:c});0&&(module.exports={journeysPlugin});
|
|
2
2
|
//# sourceMappingURL=journeys.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/journeys/journeys.ts","../../src/common/common.plugins.ts","../../src/journeys/journeys.constants.ts","../../src/journeys/journeys.log.ts"],"sourcesContent":["import { createPlugin } from '../common/common.plugins';\nimport { initialiseJourneysPlugin } from './journeys.log';\n\nexport const journeysPlugin = createPlugin('journey', {
|
|
1
|
+
{"version":3,"sources":["../../src/journeys/journeys.ts","../../src/common/common.plugins.ts","../../src/journeys/journeys.constants.ts","../../src/journeys/journeys.log.ts"],"sourcesContent":["import { createPlugin } from '../common/common.plugins';\nimport { initialiseJourneysPlugin } from './journeys.log';\n\nexport const journeysPlugin = createPlugin('journey', { pure_createActions: initialiseJourneysPlugin });\n","import { ApiClient } from '../journeys/journeys.api';\nimport { Logger } from './common.logger';\n\nexport type PluginParams = {\n\tapiClient: ApiClient;\n\tlogger?: Logger;\n};\n\nexport type Plugin<T extends string, P extends Record<string, unknown>> = {\n\tpluginName: T;\n\tpure_createActions: (params: PluginParams) => P;\n};\n\nexport const createPlugin = <T extends string, P extends Record<string, unknown>>(\n\t/** The plugin name to access its properties.\n\t * @example const myPluginVariable = createPlugin('myPluginName', { initialise: () => 'works' });\n\t * const sdk = initialiseSdk({plugins: [myPluginVariable]});\n\t * sdk.myPluginName // 'works'\n\t * sdk.myPluginVariable // undefined\n\t */\n\tpluginName: T,\n\t{\n\t\tpure_createActions,\n\t}: {\n\t\t/** **Pure** function that returns the plugin’s exposed actions.\n\t\t * ⚠️ any code ran inside this function is **not** guaranteed to run on browser initialisation.\n\t\t * If your plugin requires initialisation, or sideEffects, expose an `initialise` function from this.\n\t\t * @example const plugin = createPlugin('foo', { initialise: () => ({ bar: 'baz' }) });\n\t\t * const sdk = initialiseSdk({plugins: [plugin]});\n\t\t * sdk.foo.bar // 'baz'\n\t\t */\n\t\tpure_createActions: (params: PluginParams) => P;\n\t},\n): Plugin<T, P> => ({\n\tpluginName,\n\tpure_createActions,\n});\n","import { AppEnvironment } from '../common/common.constants';\n\nexport const ENV_TO_API_URL: Record<AppEnvironment, string> = {\n\tsandbox: 'https://preview.api.inploi.com',\n\tproduction: 'https://api.inploi.com',\n};\n\nexport const JOURNEY_PATHNAME = '/journey/log';\n","import { Flatten, ResponseObj } from '@inploi/core/common';\n\nimport { SDK_VERSION } from '../common/common.constants';\nimport { PluginParams } from '../common/common.plugins';\nimport { JOURNEY_PATHNAME } from './journeys.constants';\n\ntype JourneyLogParams =\n\t| {\n\t\t\tevent: 'VIEW_JOB' | 'APPLY_START' | 'APPLY_COMPLETE';\n\t\t\tproperties: {\n\t\t\t\tjob_id?: string | number | null; // * inploi job id or external job id?\n\t\t\t};\n\t }\n\t| {\n\t\t\tevent: 'IDENTIFY' | 'SUBMIT_FORM' | 'VIEW_PAGE';\n\t\t\tproperties?: undefined;\n\t };\n\nexport type JourneyLogEvent = JourneyLogParams['event'];\n\ntype EventPropertyMap = {\n\t[Param in JourneyLogParams as Param['event']]: Flatten<Omit<Param, 'event'>>;\n};\n\ntype TrackPayload<P> = {\n\tevent: JourneyLogEvent;\n\tsent_at: string;\n\tcontext: {\n\t\tlibrary: {\n\t\t\tname: 'inploi-sdk';\n\t\t\tversion: number;\n\t\t};\n\t\tpage: {\n\t\t\thref: string;\n\t\t\treferrer: string;\n\t\t\ttitle: string;\n\t\t};\n\t};\n\tproperties: P;\n\tcustom_properties?: Record<string, unknown>;\n};\n\nexport function initialiseJourneysPlugin({ apiClient, logger }: PluginParams) {\n\tasync function log<T extends keyof EventPropertyMap>(\n\t\tparams: { event: T; customProperties?: Record<string, unknown> } & EventPropertyMap[T],\n\t): Promise<ResponseObj<TrackPayload<EventPropertyMap[T]['properties']>>> {\n\t\ttry {\n\t\t\tconst data: TrackPayload<EventPropertyMap[T]['properties']> = {\n\t\t\t\tevent: params.event,\n\t\t\t\tsent_at: new Date().toISOString(),\n\t\t\t\tcontext: {\n\t\t\t\t\tlibrary: {\n\t\t\t\t\t\tname: 'inploi-sdk' as const,\n\t\t\t\t\t\tversion: SDK_VERSION,\n\t\t\t\t\t},\n\t\t\t\t\tpage: {\n\t\t\t\t\t\thref: location.href,\n\t\t\t\t\t\treferrer: document.referrer,\n\t\t\t\t\t\ttitle: document.title,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tproperties: params.properties as EventPropertyMap[T]['properties'],\n\t\t\t\tcustom_properties: params.customProperties,\n\t\t\t};\n\n\t\t\tawait apiClient.fetch(JOURNEY_PATHNAME, {\n\t\t\t\tmethod: 'POST',\n\t\t\t\tbody: JSON.stringify(data),\n\t\t\t});\n\n\t\t\treturn { success: true, data };\n\t\t} catch (e) {\n\t\t\t/** We dont’t log any PII on the console */\n\t\t\tlogger?.error('Failed to send journey log to API. Inspect error response of `log` for more information.');\n\t\t\treturn { success: false, error: e };\n\t\t}\n\t}\n\n\treturn {\n\t\t/** Logs an event including some client-side metadata.\n\t\t * Will fail if called on the server, as it needs access to window and document.\n\t\t */\n\t\tlog,\n\t};\n}\n"],"mappings":"snBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,IAAA,eAAAC,EAAAH,GCaO,IAAMI,EAAe,CAO3BC,EACA,CACC,mBAAAC,CACD,KAUmB,CACnB,WAAAD,EACA,mBAAAC,CACD,GC7BO,IAAMC,EAAmB,eCmCzB,SAASC,EAAyB,CAAE,UAAAC,EAAW,OAAAC,CAAO,EAAiB,CAC7E,SAAeC,EACdC,EACwE,QAAAC,EAAA,sBACxE,GAAI,CACH,IAAMC,EAAwD,CAC7D,MAAOF,EAAO,MACd,QAAS,IAAI,KAAK,EAAE,YAAY,EAChC,QAAS,CACR,QAAS,CACR,KAAM,aACN,QAAS,CACV,EACA,KAAM,CACL,KAAM,SAAS,KACf,SAAU,SAAS,SACnB,MAAO,SAAS,KACjB,CACD,EACA,WAAYA,EAAO,WACnB,kBAAmBA,EAAO,gBAC3B,EAEA,aAAMH,EAAU,MAAMM,EAAkB,CACvC,OAAQ,OACR,KAAM,KAAK,UAAUD,CAAI,CAC1B,CAAC,EAEM,CAAE,QAAS,GAAM,KAAAA,CAAK,CAC9B,OAASE,EAAG,CAEX,OAAAN,GAAA,MAAAA,EAAQ,MAAM,4FACP,CAAE,QAAS,GAAO,MAAOM,CAAE,CACnC,CACD,GAEA,MAAO,CAIN,IAAAL,CACD,CACD,CHjFO,IAAMM,EAAiBC,EAAa,UAAW,CAAE,mBAAoBC,CAAyB,CAAC","names":["journeys_exports","__export","journeysPlugin","__toCommonJS","createPlugin","pluginName","pure_createActions","JOURNEY_PATHNAME","initialiseJourneysPlugin","apiClient","logger","log","params","__async","data","JOURNEY_PATHNAME","e","journeysPlugin","createPlugin","initialiseJourneysPlugin"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as n}from"../chunk-NLLAI5ZB.mjs";import{c as o,d as i}from"../chunk-
|
|
1
|
+
import{b as n}from"../chunk-NLLAI5ZB.mjs";import{c as o,d as i}from"../chunk-WFTFPD6B.mjs";function s({apiClient:p,logger:r}){function a(t){return o(this,null,function*(){try{let e={event:t.event,sent_at:new Date().toISOString(),context:{library:{name:"inploi-sdk",version:1},page:{href:location.href,referrer:document.referrer,title:document.title}},properties:t.properties,custom_properties:t.customProperties};return yield p.fetch(n,{method:"POST",body:JSON.stringify(e)}),{success:!0,data:e}}catch(e){return r==null||r.error("Failed to send journey log to API. Inspect error response of `log` for more information."),{success:!1,error:e}}})}return{log:a}}var v=i("journey",{pure_createActions:s});export{v as journeysPlugin};
|
|
2
2
|
//# sourceMappingURL=journeys.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/journeys/journeys.log.ts","../../src/journeys/journeys.ts"],"sourcesContent":["import { Flatten, ResponseObj } from '@inploi/core/common';\n\nimport { SDK_VERSION } from '../common/common.constants';\nimport { PluginParams } from '../common/common.plugins';\nimport { JOURNEY_PATHNAME } from './journeys.constants';\n\ntype JourneyLogParams =\n\t| {\n\t\t\tevent: 'VIEW_JOB' | 'APPLY_START' | 'APPLY_COMPLETE';\n\t\t\tproperties: {\n\t\t\t\tjob_id?: string | number | null; // * inploi job id or external job id?\n\t\t\t};\n\t }\n\t| {\n\t\t\tevent: 'IDENTIFY' | 'SUBMIT_FORM' | 'VIEW_PAGE';\n\t\t\tproperties?: undefined;\n\t };\n\nexport type JourneyLogEvent = JourneyLogParams['event'];\n\ntype EventPropertyMap = {\n\t[Param in JourneyLogParams as Param['event']]: Flatten<Omit<Param, 'event'>>;\n};\n\ntype TrackPayload<P> = {\n\tevent: JourneyLogEvent;\n\tsent_at: string;\n\tcontext: {\n\t\tlibrary: {\n\t\t\tname: 'inploi-sdk';\n\t\t\tversion: number;\n\t\t};\n\t\tpage: {\n\t\t\thref: string;\n\t\t\treferrer: string;\n\t\t\ttitle: string;\n\t\t};\n\t};\n\tproperties: P;\n\tcustom_properties?: Record<string, unknown>;\n};\n\nexport function initialiseJourneysPlugin({ apiClient, logger }: PluginParams) {\n\tasync function log<T extends keyof EventPropertyMap>(\n\t\tparams: { event: T; customProperties?: Record<string, unknown> } & EventPropertyMap[T],\n\t): Promise<ResponseObj<TrackPayload<EventPropertyMap[T]['properties']>>> {\n\t\ttry {\n\t\t\tconst data: TrackPayload<EventPropertyMap[T]['properties']> = {\n\t\t\t\tevent: params.event,\n\t\t\t\tsent_at: new Date().toISOString(),\n\t\t\t\tcontext: {\n\t\t\t\t\tlibrary: {\n\t\t\t\t\t\tname: 'inploi-sdk' as const,\n\t\t\t\t\t\tversion: SDK_VERSION,\n\t\t\t\t\t},\n\t\t\t\t\tpage: {\n\t\t\t\t\t\thref: location.href,\n\t\t\t\t\t\treferrer: document.referrer,\n\t\t\t\t\t\ttitle: document.title,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tproperties: params.properties as EventPropertyMap[T]['properties'],\n\t\t\t\tcustom_properties: params.customProperties,\n\t\t\t};\n\n\t\t\tawait apiClient.fetch(JOURNEY_PATHNAME, {\n\t\t\t\tmethod: 'POST',\n\t\t\t\tbody: JSON.stringify(data),\n\t\t\t});\n\n\t\t\treturn { success: true, data };\n\t\t} catch (e) {\n\t\t\t/** We dont’t log any PII on the console */\n\t\t\tlogger?.error('Failed to send journey log to API. Inspect error response of `log` for more information.');\n\t\t\treturn { success: false, error: e };\n\t\t}\n\t}\n\n\treturn {\n\t\t/** Logs an event including some client-side metadata.\n\t\t * Will fail if called on the server, as it needs access to window and document.\n\t\t */\n\t\tlog,\n\t};\n}\n","import { createPlugin } from '../common/common.plugins';\nimport { initialiseJourneysPlugin } from './journeys.log';\n\nexport const journeysPlugin = createPlugin('journey', {
|
|
1
|
+
{"version":3,"sources":["../../src/journeys/journeys.log.ts","../../src/journeys/journeys.ts"],"sourcesContent":["import { Flatten, ResponseObj } from '@inploi/core/common';\n\nimport { SDK_VERSION } from '../common/common.constants';\nimport { PluginParams } from '../common/common.plugins';\nimport { JOURNEY_PATHNAME } from './journeys.constants';\n\ntype JourneyLogParams =\n\t| {\n\t\t\tevent: 'VIEW_JOB' | 'APPLY_START' | 'APPLY_COMPLETE';\n\t\t\tproperties: {\n\t\t\t\tjob_id?: string | number | null; // * inploi job id or external job id?\n\t\t\t};\n\t }\n\t| {\n\t\t\tevent: 'IDENTIFY' | 'SUBMIT_FORM' | 'VIEW_PAGE';\n\t\t\tproperties?: undefined;\n\t };\n\nexport type JourneyLogEvent = JourneyLogParams['event'];\n\ntype EventPropertyMap = {\n\t[Param in JourneyLogParams as Param['event']]: Flatten<Omit<Param, 'event'>>;\n};\n\ntype TrackPayload<P> = {\n\tevent: JourneyLogEvent;\n\tsent_at: string;\n\tcontext: {\n\t\tlibrary: {\n\t\t\tname: 'inploi-sdk';\n\t\t\tversion: number;\n\t\t};\n\t\tpage: {\n\t\t\thref: string;\n\t\t\treferrer: string;\n\t\t\ttitle: string;\n\t\t};\n\t};\n\tproperties: P;\n\tcustom_properties?: Record<string, unknown>;\n};\n\nexport function initialiseJourneysPlugin({ apiClient, logger }: PluginParams) {\n\tasync function log<T extends keyof EventPropertyMap>(\n\t\tparams: { event: T; customProperties?: Record<string, unknown> } & EventPropertyMap[T],\n\t): Promise<ResponseObj<TrackPayload<EventPropertyMap[T]['properties']>>> {\n\t\ttry {\n\t\t\tconst data: TrackPayload<EventPropertyMap[T]['properties']> = {\n\t\t\t\tevent: params.event,\n\t\t\t\tsent_at: new Date().toISOString(),\n\t\t\t\tcontext: {\n\t\t\t\t\tlibrary: {\n\t\t\t\t\t\tname: 'inploi-sdk' as const,\n\t\t\t\t\t\tversion: SDK_VERSION,\n\t\t\t\t\t},\n\t\t\t\t\tpage: {\n\t\t\t\t\t\thref: location.href,\n\t\t\t\t\t\treferrer: document.referrer,\n\t\t\t\t\t\ttitle: document.title,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tproperties: params.properties as EventPropertyMap[T]['properties'],\n\t\t\t\tcustom_properties: params.customProperties,\n\t\t\t};\n\n\t\t\tawait apiClient.fetch(JOURNEY_PATHNAME, {\n\t\t\t\tmethod: 'POST',\n\t\t\t\tbody: JSON.stringify(data),\n\t\t\t});\n\n\t\t\treturn { success: true, data };\n\t\t} catch (e) {\n\t\t\t/** We dont’t log any PII on the console */\n\t\t\tlogger?.error('Failed to send journey log to API. Inspect error response of `log` for more information.');\n\t\t\treturn { success: false, error: e };\n\t\t}\n\t}\n\n\treturn {\n\t\t/** Logs an event including some client-side metadata.\n\t\t * Will fail if called on the server, as it needs access to window and document.\n\t\t */\n\t\tlog,\n\t};\n}\n","import { createPlugin } from '../common/common.plugins';\nimport { initialiseJourneysPlugin } from './journeys.log';\n\nexport const journeysPlugin = createPlugin('journey', { pure_createActions: initialiseJourneysPlugin });\n"],"mappings":"2FA0CO,SAASA,EAAyB,CAAE,UAAAC,EAAW,OAAAC,CAAO,EAAiB,CAC7E,SAAeC,EACdC,EACwE,QAAAC,EAAA,sBACxE,GAAI,CACH,IAAMC,EAAwD,CAC7D,MAAOF,EAAO,MACd,QAAS,IAAI,KAAK,EAAE,YAAY,EAChC,QAAS,CACR,QAAS,CACR,KAAM,aACN,QAAS,CACV,EACA,KAAM,CACL,KAAM,SAAS,KACf,SAAU,SAAS,SACnB,MAAO,SAAS,KACjB,CACD,EACA,WAAYA,EAAO,WACnB,kBAAmBA,EAAO,gBAC3B,EAEA,aAAMH,EAAU,MAAMM,EAAkB,CACvC,OAAQ,OACR,KAAM,KAAK,UAAUD,CAAI,CAC1B,CAAC,EAEM,CAAE,QAAS,GAAM,KAAAA,CAAK,CAC9B,OAAS,EAAG,CAEX,OAAAJ,GAAA,MAAAA,EAAQ,MAAM,4FACP,CAAE,QAAS,GAAO,MAAO,CAAE,CACnC,CACD,GAEA,MAAO,CAIN,IAAAC,CACD,CACD,CCjFO,IAAMK,EAAiBC,EAAa,UAAW,CAAE,mBAAoBC,CAAyB,CAAC","names":["initialiseJourneysPlugin","apiClient","logger","log","params","__async","data","JOURNEY_PATHNAME","journeysPlugin","createPlugin","initialiseJourneysPlugin"]}
|
package/dist/sdk.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as Plugin, L as Logger } from './common.plugins-
|
|
2
|
-
export { C as CONSOLE_PREFIX, a as CONSOLE_STYLE, c as createPlugin, i as inploiBrandedLogger, n as noLogging } from './common.plugins-
|
|
1
|
+
import { P as Plugin, L as Logger } from './common.plugins-2d10f2e9.js';
|
|
2
|
+
export { C as CONSOLE_PREFIX, a as CONSOLE_STYLE, c as createPlugin, i as inploiBrandedLogger, n as noLogging } from './common.plugins-2d10f2e9.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The environment the SDK should run in.
|
|
@@ -26,6 +26,6 @@ declare function initialiseSdk<TPlugin extends Plugin<any, any>>({ publishableKe
|
|
|
26
26
|
pluginName: K;
|
|
27
27
|
} extends infer T ? { [k in keyof T]: (TPlugin & {
|
|
28
28
|
pluginName: K;
|
|
29
|
-
})[k]; } : never)["
|
|
29
|
+
})[k]; } : never)["pure_createActions"]>; };
|
|
30
30
|
|
|
31
31
|
export { InitialiseInploiSdkParams, Logger, Plugin, initialiseSdk };
|
package/dist/sdk.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as Plugin, L as Logger } from './common.plugins-
|
|
2
|
-
export { C as CONSOLE_PREFIX, a as CONSOLE_STYLE, c as createPlugin, i as inploiBrandedLogger, n as noLogging } from './common.plugins-
|
|
1
|
+
import { P as Plugin, L as Logger } from './common.plugins-2d10f2e9.js';
|
|
2
|
+
export { C as CONSOLE_PREFIX, a as CONSOLE_STYLE, c as createPlugin, i as inploiBrandedLogger, n as noLogging } from './common.plugins-2d10f2e9.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The environment the SDK should run in.
|
|
@@ -26,6 +26,6 @@ declare function initialiseSdk<TPlugin extends Plugin<any, any>>({ publishableKe
|
|
|
26
26
|
pluginName: K;
|
|
27
27
|
} extends infer T ? { [k in keyof T]: (TPlugin & {
|
|
28
28
|
pluginName: K;
|
|
29
|
-
})[k]; } : never)["
|
|
29
|
+
})[k]; } : never)["pure_createActions"]>; };
|
|
30
30
|
|
|
31
31
|
export { InitialiseInploiSdkParams, Logger, Plugin, initialiseSdk };
|
package/dist/sdk.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var l=Object.defineProperty,
|
|
1
|
+
"use strict";var l=Object.defineProperty,T=Object.defineProperties,E=Object.getOwnPropertyDescriptor,b=Object.getOwnPropertyDescriptors,_=Object.getOwnPropertyNames,P=Object.getOwnPropertySymbols;var f=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable;var x=(e,n,o)=>n in e?l(e,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[n]=o,c=(e,n)=>{for(var o in n||(n={}))f.call(n,o)&&x(e,o,n[o]);if(P)for(var o of P(n))C.call(n,o)&&x(e,o,n[o]);return e},h=(e,n)=>T(e,b(n));var v=(e,n)=>{for(var o in n)l(e,o,{get:n[o],enumerable:!0})},I=(e,n,o,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of _(n))!f.call(e,t)&&t!==o&&l(e,t,{get:()=>n[t],enumerable:!(i=E(n,t))||i.enumerable});return e};var N=e=>I(l({},"__esModule",{value:!0}),e);var A=(e,n,o)=>new Promise((i,t)=>{var d=s=>{try{r(o.next(s))}catch(u){t(u)}},a=s=>{try{r(o.throw(s))}catch(u){t(u)}},r=s=>s.done?i(s.value):Promise.resolve(s.value).then(d,a);r((o=o.apply(e,n)).next())});var S={};v(S,{CONSOLE_PREFIX:()=>p,CONSOLE_STYLE:()=>g,createPlugin:()=>w,initialiseSdk:()=>O,inploiBrandedLogger:()=>m,noLogging:()=>R});module.exports=N(S);var p="%c[inploi SDK]",g="color: #65BC67; font-weight: bold;",m={warn:e=>console.warn(p,g,e),error:e=>console.error(p,g,e),info:e=>console.info(p,g,e),log:e=>console.log(p,g,e)},R={info:()=>{},error:()=>{},log:()=>{},warn:()=>{}};var M="Unauthenticated",k="This action is unauthorized.",y=e=>{let n={Accept:"application/json","Content-Type":"application/json","x-publishable-key":e.publishableKey};return{fetch:(t,...d)=>A(void 0,[t,...d],function*(o,i={}){let a=h(c({},i),{headers:c(c({},i.headers),n)}),r=yield fetch(`${e.baseUrl}${o}`,a).then(s=>s.json());if("message"in r){if(r.message===M)throw new Error("You are not authenticated.");if(r.message===k)throw new Error("You are not authenticated.");if("exception"in r)throw new Error(`API error: \u201C${r.message}\u201D`);if("errors"in r)throw new Error(`API error: \u201C${r.message}\u201D`)}return r})}};var L={sandbox:"https://preview.api.inploi.com",production:"https://api.inploi.com"};var w=(e,{pure_createActions:n})=>({pluginName:e,pure_createActions:n});function O({publishableKey:e,env:n,plugins:o,logger:i=m}){let t=y({baseUrl:L[n],publishableKey:e});return o.reduce((a,r)=>(a[r.pluginName]=r.pure_createActions({apiClient:t,logger:i}),a),{})}0&&(module.exports={CONSOLE_PREFIX,CONSOLE_STYLE,createPlugin,initialiseSdk,inploiBrandedLogger,noLogging});
|
|
2
2
|
//# sourceMappingURL=sdk.js.map
|
package/dist/sdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/sdk.ts","../src/common/common.logger.ts","../src/journeys/journeys.api.ts","../src/journeys/journeys.constants.ts","../src/common/common.plugins.ts"],"sourcesContent":["import { Flatten } from '@inploi/core/common';\n\nimport { AppEnvironment } from './common/common.constants';\nimport { Logger, inploiBrandedLogger } from './common/common.logger';\nimport { Plugin } from './common/common.plugins';\nimport { createApiClient } from './journeys/journeys.api';\nimport { ENV_TO_API_URL } from './journeys/journeys.constants';\n\n/** Different loggers so people can use `noLogging` */\nexport * from './common/common.logger';\nexport type { Plugin } from './common/common.plugins';\nexport { createPlugin } from './common/common.plugins';\n\nexport type InitialiseInploiSdkParams<P extends Plugin<any, any>> = {\n\t/** Your public API key for the inploi SDK. */\n\tpublishableKey: string;\n\t/** Add your plugins here. Try importing and passing `journeysPlugin` ;) */\n\tplugins: P[];\n\t/** Which app environment to run. This ultimately affects which inploi endpoints to gather data are going to be used.\n\t * Anything other than `production` should be considered a development environment and the data periodicaly purged. */\n\tenv: AppEnvironment;\n\t/** Logger object that handles logging of different levels.\n\t * You can override this to use your own logger, or to disable logging altogether by importing and passing `noLogging`.\n\t * @default inploiBrandedLogger\n\t * */\n\tlogger?: Logger;\n};\n\nexport function initialiseSdk<TPlugin extends Plugin<any, any>>({\n\tpublishableKey,\n\tenv,\n\tplugins,\n\tlogger = inploiBrandedLogger,\n}: InitialiseInploiSdkParams<TPlugin>) {\n\tconst apiClient = createApiClient({ baseUrl: ENV_TO_API_URL[env], publishableKey });\n\n\tconst
|
|
1
|
+
{"version":3,"sources":["../src/sdk.ts","../src/common/common.logger.ts","../src/journeys/journeys.api.ts","../src/journeys/journeys.constants.ts","../src/common/common.plugins.ts"],"sourcesContent":["import { Flatten } from '@inploi/core/common';\n\nimport { AppEnvironment } from './common/common.constants';\nimport { Logger, inploiBrandedLogger } from './common/common.logger';\nimport { Plugin } from './common/common.plugins';\nimport { createApiClient } from './journeys/journeys.api';\nimport { ENV_TO_API_URL } from './journeys/journeys.constants';\n\n/** Different loggers so people can use `noLogging` */\nexport * from './common/common.logger';\nexport type { Plugin } from './common/common.plugins';\nexport { createPlugin } from './common/common.plugins';\n\nexport type InitialiseInploiSdkParams<P extends Plugin<any, any>> = {\n\t/** Your public API key for the inploi SDK. */\n\tpublishableKey: string;\n\t/** Add your plugins here. Try importing and passing `journeysPlugin` ;) */\n\tplugins: P[];\n\t/** Which app environment to run. This ultimately affects which inploi endpoints to gather data are going to be used.\n\t * Anything other than `production` should be considered a development environment and the data periodicaly purged. */\n\tenv: AppEnvironment;\n\t/** Logger object that handles logging of different levels.\n\t * You can override this to use your own logger, or to disable logging altogether by importing and passing `noLogging`.\n\t * @default inploiBrandedLogger\n\t * */\n\tlogger?: Logger;\n};\n\nexport function initialiseSdk<TPlugin extends Plugin<any, any>>({\n\tpublishableKey,\n\tenv,\n\tplugins,\n\tlogger = inploiBrandedLogger,\n}: InitialiseInploiSdkParams<TPlugin>) {\n\tconst apiClient = createApiClient({ baseUrl: ENV_TO_API_URL[env], publishableKey });\n\n\tconst pluginActions = plugins.reduce(\n\t\t(acc, plugin) => {\n\t\t\tacc[plugin.pluginName as TPlugin['pluginName']] = plugin.pure_createActions({ apiClient, logger });\n\t\t\treturn acc;\n\t\t},\n\t\t{} as { [K in TPlugin['pluginName']]: ReturnType<Flatten<TPlugin & { pluginName: K }>['pure_createActions']> },\n\t);\n\n\treturn pluginActions;\n}\n","export const CONSOLE_PREFIX = '%c[inploi SDK]';\nexport const CONSOLE_STYLE = 'color: #65BC67; font-weight: bold;';\n\ntype LogMessage = (...data: any[]) => void;\nexport type Logger = {\n\twarn: LogMessage;\n\terror: LogMessage;\n\tinfo: LogMessage;\n\tlog: LogMessage;\n};\n\nexport const inploiBrandedLogger: Logger = {\n\twarn: message => console.warn(CONSOLE_PREFIX, CONSOLE_STYLE, message),\n\terror: message => console.error(CONSOLE_PREFIX, CONSOLE_STYLE, message),\n\tinfo: message => console.info(CONSOLE_PREFIX, CONSOLE_STYLE, message),\n\tlog: message => console.log(CONSOLE_PREFIX, CONSOLE_STYLE, message),\n};\n\nexport const noLogging: Logger = { info: () => void 0, error: () => void 0, log: () => void 0, warn: () => void 0 };\n","export const unauthenticatedMessage = 'Unauthenticated';\nexport const unauthorisedMessage = 'This action is unauthorized.';\n\nexport type ApiClient = {\n\tfetch: (pathname: string, options?: RequestInit) => Promise<unknown>;\n};\n\nexport const createApiClient = (params: { baseUrl: string; publishableKey: string }): ApiClient => {\n\tconst defaultHeaders: HeadersInit = {\n\t\tAccept: 'application/json',\n\t\t'Content-Type': 'application/json',\n\t\t'x-publishable-key': params.publishableKey,\n\t};\n\n\treturn {\n\t\tfetch: async (pathname, options = {}) => {\n\t\t\tconst init = { ...options, headers: { ...options.headers, ...defaultHeaders } };\n\t\t\tconst response = await fetch(`${params.baseUrl}${pathname}`, init).then(res => res.json());\n\n\t\t\tif ('message' in response) {\n\t\t\t\tif (response.message === unauthenticatedMessage) {\n\t\t\t\t\tthrow new Error('You are not authenticated.');\n\t\t\t\t}\n\t\t\t\tif (response.message === unauthorisedMessage) {\n\t\t\t\t\tthrow new Error('You are not authenticated.');\n\t\t\t\t}\n\t\t\t\tif ('exception' in response) {\n\t\t\t\t\tthrow new Error(`API error: “${response.message}”`);\n\t\t\t\t}\n\t\t\t\tif ('errors' in response) {\n\t\t\t\t\tthrow new Error(`API error: “${response.message}”`);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn response;\n\t\t},\n\t};\n};\n","import { AppEnvironment } from '../common/common.constants';\n\nexport const ENV_TO_API_URL: Record<AppEnvironment, string> = {\n\tsandbox: 'https://preview.api.inploi.com',\n\tproduction: 'https://api.inploi.com',\n};\n\nexport const JOURNEY_PATHNAME = '/journey/log';\n","import { ApiClient } from '../journeys/journeys.api';\nimport { Logger } from './common.logger';\n\nexport type PluginParams = {\n\tapiClient: ApiClient;\n\tlogger?: Logger;\n};\n\nexport type Plugin<T extends string, P extends Record<string, unknown>> = {\n\tpluginName: T;\n\tpure_createActions: (params: PluginParams) => P;\n};\n\nexport const createPlugin = <T extends string, P extends Record<string, unknown>>(\n\t/** The plugin name to access its properties.\n\t * @example const myPluginVariable = createPlugin('myPluginName', { initialise: () => 'works' });\n\t * const sdk = initialiseSdk({plugins: [myPluginVariable]});\n\t * sdk.myPluginName // 'works'\n\t * sdk.myPluginVariable // undefined\n\t */\n\tpluginName: T,\n\t{\n\t\tpure_createActions,\n\t}: {\n\t\t/** **Pure** function that returns the plugin’s exposed actions.\n\t\t * ⚠️ any code ran inside this function is **not** guaranteed to run on browser initialisation.\n\t\t * If your plugin requires initialisation, or sideEffects, expose an `initialise` function from this.\n\t\t * @example const plugin = createPlugin('foo', { initialise: () => ({ bar: 'baz' }) });\n\t\t * const sdk = initialiseSdk({plugins: [plugin]});\n\t\t * sdk.foo.bar // 'baz'\n\t\t */\n\t\tpure_createActions: (params: PluginParams) => P;\n\t},\n): Plugin<T, P> => ({\n\tpluginName,\n\tpure_createActions,\n});\n"],"mappings":"i9BAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,EAAA,kBAAAC,EAAA,iBAAAC,EAAA,kBAAAC,EAAA,wBAAAC,EAAA,cAAAC,IAAA,eAAAC,EAAAR,GCAO,IAAMS,EAAiB,iBACjBC,EAAgB,qCAUhBC,EAA8B,CAC1C,KAAMC,GAAW,QAAQ,KAAKH,EAAgBC,EAAeE,CAAO,EACpE,MAAOA,GAAW,QAAQ,MAAMH,EAAgBC,EAAeE,CAAO,EACtE,KAAMA,GAAW,QAAQ,KAAKH,EAAgBC,EAAeE,CAAO,EACpE,IAAKA,GAAW,QAAQ,IAAIH,EAAgBC,EAAeE,CAAO,CACnE,EAEaC,EAAoB,CAAE,KAAM,IAAG,GAAW,MAAO,IAAG,GAAW,IAAK,IAAG,GAAW,KAAM,IAAG,EAAU,EClB3G,IAAMC,EAAyB,kBACzBC,EAAsB,+BAMtBC,EAAmBC,GAAmE,CAClG,IAAMC,EAA8B,CACnC,OAAQ,mBACR,eAAgB,mBAChB,oBAAqBD,EAAO,cAC7B,EAEA,MAAO,CACN,MAAO,CAAOE,KAA2BC,IAAAC,EAAA,QAA3BF,EAA2B,GAAAC,GAAA,UAA3BE,EAAUC,EAAU,CAAC,EAAM,CACxC,IAAMC,EAAOC,EAAAC,EAAA,GAAKH,GAAL,CAAc,QAASG,IAAA,GAAKH,EAAQ,SAAYL,EAAiB,GACxES,EAAW,MAAM,MAAM,GAAGV,EAAO,OAAO,GAAGK,CAAQ,GAAIE,CAAI,EAAE,KAAKI,GAAOA,EAAI,KAAK,CAAC,EAEzF,GAAI,YAAaD,EAAU,CAC1B,GAAIA,EAAS,UAAYb,EACxB,MAAM,IAAI,MAAM,4BAA4B,EAE7C,GAAIa,EAAS,UAAYZ,EACxB,MAAM,IAAI,MAAM,4BAA4B,EAE7C,GAAI,cAAeY,EAClB,MAAM,IAAI,MAAM,oBAAeA,EAAS,OAAO,QAAG,EAEnD,GAAI,WAAYA,EACf,MAAM,IAAI,MAAM,oBAAeA,EAAS,OAAO,QAAG,CAEpD,CACA,OAAOA,CACR,EACD,CACD,EClCO,IAAME,EAAiD,CAC7D,QAAS,iCACT,WAAY,wBACb,ECQO,IAAMC,EAAe,CAO3BC,EACA,CACC,mBAAAC,CACD,KAUmB,CACnB,WAAAD,EACA,mBAAAC,CACD,GJRO,SAASC,EAAgD,CAC/D,eAAAC,EACA,IAAAC,EACA,QAAAC,EACA,OAAAC,EAASC,CACV,EAAuC,CACtC,IAAMC,EAAYC,EAAgB,CAAE,QAASC,EAAeN,CAAG,EAAG,eAAAD,CAAe,CAAC,EAUlF,OARsBE,EAAQ,OAC7B,CAACM,EAAKC,KACLD,EAAIC,EAAO,UAAmC,EAAIA,EAAO,mBAAmB,CAAE,UAAAJ,EAAW,OAAAF,CAAO,CAAC,EAC1FK,GAER,CAAC,CACF,CAGD","names":["sdk_exports","__export","CONSOLE_PREFIX","CONSOLE_STYLE","createPlugin","initialiseSdk","inploiBrandedLogger","noLogging","__toCommonJS","CONSOLE_PREFIX","CONSOLE_STYLE","inploiBrandedLogger","message","noLogging","unauthenticatedMessage","unauthorisedMessage","createApiClient","params","defaultHeaders","_0","_1","__async","pathname","options","init","__spreadProps","__spreadValues","response","res","ENV_TO_API_URL","createPlugin","pluginName","pure_createActions","initialiseSdk","publishableKey","env","plugins","logger","inploiBrandedLogger","apiClient","createApiClient","ENV_TO_API_URL","acc","plugin"]}
|
package/dist/sdk.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as u}from"./chunk-NLLAI5ZB.mjs";import{a as
|
|
1
|
+
import{a as u}from"./chunk-NLLAI5ZB.mjs";import{a as t,b as p,c as l,d as h}from"./chunk-WFTFPD6B.mjs";var i="%c[inploi SDK]",s="color: #65BC67; font-weight: bold;",c={warn:e=>console.warn(i,s,e),error:e=>console.error(i,s,e),info:e=>console.info(i,s,e),log:e=>console.log(i,s,e)},L={info:()=>{},error:()=>{},log:()=>{},warn:()=>{}};var P="Unauthenticated",x="This action is unauthorized.",m=e=>{let a={Accept:"application/json","Content-Type":"application/json","x-publishable-key":e.publishableKey};return{fetch:(d,...y)=>l(void 0,[d,...y],function*(g,o={}){let r=p(t({},o),{headers:t(t({},o.headers),a)}),n=yield fetch(`${e.baseUrl}${g}`,r).then(f=>f.json());if("message"in n){if(n.message===P)throw new Error("You are not authenticated.");if(n.message===x)throw new Error("You are not authenticated.");if("exception"in n)throw new Error(`API error: \u201C${n.message}\u201D`);if("errors"in n)throw new Error(`API error: \u201C${n.message}\u201D`)}return n})}};function v({publishableKey:e,env:a,plugins:g,logger:o=c}){let d=m({baseUrl:u[a],publishableKey:e});return g.reduce((r,n)=>(r[n.pluginName]=n.pure_createActions({apiClient:d,logger:o}),r),{})}export{i as CONSOLE_PREFIX,s as CONSOLE_STYLE,h as createPlugin,v as initialiseSdk,c as inploiBrandedLogger,L as noLogging};
|
|
2
2
|
//# sourceMappingURL=sdk.mjs.map
|
package/dist/sdk.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/common/common.logger.ts","../src/journeys/journeys.api.ts","../src/sdk.ts"],"sourcesContent":["export const CONSOLE_PREFIX = '%c[inploi SDK]';\nexport const CONSOLE_STYLE = 'color: #65BC67; font-weight: bold;';\n\ntype LogMessage = (...data: any[]) => void;\nexport type Logger = {\n\twarn: LogMessage;\n\terror: LogMessage;\n\tinfo: LogMessage;\n\tlog: LogMessage;\n};\n\nexport const inploiBrandedLogger: Logger = {\n\twarn: message => console.warn(CONSOLE_PREFIX, CONSOLE_STYLE, message),\n\terror: message => console.error(CONSOLE_PREFIX, CONSOLE_STYLE, message),\n\tinfo: message => console.info(CONSOLE_PREFIX, CONSOLE_STYLE, message),\n\tlog: message => console.log(CONSOLE_PREFIX, CONSOLE_STYLE, message),\n};\n\nexport const noLogging: Logger = { info: () => void 0, error: () => void 0, log: () => void 0, warn: () => void 0 };\n","export const unauthenticatedMessage = 'Unauthenticated';\nexport const unauthorisedMessage = 'This action is unauthorized.';\n\nexport type ApiClient = {\n\tfetch: (pathname: string, options?: RequestInit) => Promise<unknown>;\n};\n\nexport const createApiClient = (params: { baseUrl: string; publishableKey: string }): ApiClient => {\n\tconst defaultHeaders: HeadersInit = {\n\t\tAccept: 'application/json',\n\t\t'Content-Type': 'application/json',\n\t\t'x-publishable-key': params.publishableKey,\n\t};\n\n\treturn {\n\t\tfetch: async (pathname, options = {}) => {\n\t\t\tconst init = { ...options, headers: { ...options.headers, ...defaultHeaders } };\n\t\t\tconst response = await fetch(`${params.baseUrl}${pathname}`, init).then(res => res.json());\n\n\t\t\tif ('message' in response) {\n\t\t\t\tif (response.message === unauthenticatedMessage) {\n\t\t\t\t\tthrow new Error('You are not authenticated.');\n\t\t\t\t}\n\t\t\t\tif (response.message === unauthorisedMessage) {\n\t\t\t\t\tthrow new Error('You are not authenticated.');\n\t\t\t\t}\n\t\t\t\tif ('exception' in response) {\n\t\t\t\t\tthrow new Error(`API error: “${response.message}”`);\n\t\t\t\t}\n\t\t\t\tif ('errors' in response) {\n\t\t\t\t\tthrow new Error(`API error: “${response.message}”`);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn response;\n\t\t},\n\t};\n};\n","import { Flatten } from '@inploi/core/common';\n\nimport { AppEnvironment } from './common/common.constants';\nimport { Logger, inploiBrandedLogger } from './common/common.logger';\nimport { Plugin } from './common/common.plugins';\nimport { createApiClient } from './journeys/journeys.api';\nimport { ENV_TO_API_URL } from './journeys/journeys.constants';\n\n/** Different loggers so people can use `noLogging` */\nexport * from './common/common.logger';\nexport type { Plugin } from './common/common.plugins';\nexport { createPlugin } from './common/common.plugins';\n\nexport type InitialiseInploiSdkParams<P extends Plugin<any, any>> = {\n\t/** Your public API key for the inploi SDK. */\n\tpublishableKey: string;\n\t/** Add your plugins here. Try importing and passing `journeysPlugin` ;) */\n\tplugins: P[];\n\t/** Which app environment to run. This ultimately affects which inploi endpoints to gather data are going to be used.\n\t * Anything other than `production` should be considered a development environment and the data periodicaly purged. */\n\tenv: AppEnvironment;\n\t/** Logger object that handles logging of different levels.\n\t * You can override this to use your own logger, or to disable logging altogether by importing and passing `noLogging`.\n\t * @default inploiBrandedLogger\n\t * */\n\tlogger?: Logger;\n};\n\nexport function initialiseSdk<TPlugin extends Plugin<any, any>>({\n\tpublishableKey,\n\tenv,\n\tplugins,\n\tlogger = inploiBrandedLogger,\n}: InitialiseInploiSdkParams<TPlugin>) {\n\tconst apiClient = createApiClient({ baseUrl: ENV_TO_API_URL[env], publishableKey });\n\n\tconst
|
|
1
|
+
{"version":3,"sources":["../src/common/common.logger.ts","../src/journeys/journeys.api.ts","../src/sdk.ts"],"sourcesContent":["export const CONSOLE_PREFIX = '%c[inploi SDK]';\nexport const CONSOLE_STYLE = 'color: #65BC67; font-weight: bold;';\n\ntype LogMessage = (...data: any[]) => void;\nexport type Logger = {\n\twarn: LogMessage;\n\terror: LogMessage;\n\tinfo: LogMessage;\n\tlog: LogMessage;\n};\n\nexport const inploiBrandedLogger: Logger = {\n\twarn: message => console.warn(CONSOLE_PREFIX, CONSOLE_STYLE, message),\n\terror: message => console.error(CONSOLE_PREFIX, CONSOLE_STYLE, message),\n\tinfo: message => console.info(CONSOLE_PREFIX, CONSOLE_STYLE, message),\n\tlog: message => console.log(CONSOLE_PREFIX, CONSOLE_STYLE, message),\n};\n\nexport const noLogging: Logger = { info: () => void 0, error: () => void 0, log: () => void 0, warn: () => void 0 };\n","export const unauthenticatedMessage = 'Unauthenticated';\nexport const unauthorisedMessage = 'This action is unauthorized.';\n\nexport type ApiClient = {\n\tfetch: (pathname: string, options?: RequestInit) => Promise<unknown>;\n};\n\nexport const createApiClient = (params: { baseUrl: string; publishableKey: string }): ApiClient => {\n\tconst defaultHeaders: HeadersInit = {\n\t\tAccept: 'application/json',\n\t\t'Content-Type': 'application/json',\n\t\t'x-publishable-key': params.publishableKey,\n\t};\n\n\treturn {\n\t\tfetch: async (pathname, options = {}) => {\n\t\t\tconst init = { ...options, headers: { ...options.headers, ...defaultHeaders } };\n\t\t\tconst response = await fetch(`${params.baseUrl}${pathname}`, init).then(res => res.json());\n\n\t\t\tif ('message' in response) {\n\t\t\t\tif (response.message === unauthenticatedMessage) {\n\t\t\t\t\tthrow new Error('You are not authenticated.');\n\t\t\t\t}\n\t\t\t\tif (response.message === unauthorisedMessage) {\n\t\t\t\t\tthrow new Error('You are not authenticated.');\n\t\t\t\t}\n\t\t\t\tif ('exception' in response) {\n\t\t\t\t\tthrow new Error(`API error: “${response.message}”`);\n\t\t\t\t}\n\t\t\t\tif ('errors' in response) {\n\t\t\t\t\tthrow new Error(`API error: “${response.message}”`);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn response;\n\t\t},\n\t};\n};\n","import { Flatten } from '@inploi/core/common';\n\nimport { AppEnvironment } from './common/common.constants';\nimport { Logger, inploiBrandedLogger } from './common/common.logger';\nimport { Plugin } from './common/common.plugins';\nimport { createApiClient } from './journeys/journeys.api';\nimport { ENV_TO_API_URL } from './journeys/journeys.constants';\n\n/** Different loggers so people can use `noLogging` */\nexport * from './common/common.logger';\nexport type { Plugin } from './common/common.plugins';\nexport { createPlugin } from './common/common.plugins';\n\nexport type InitialiseInploiSdkParams<P extends Plugin<any, any>> = {\n\t/** Your public API key for the inploi SDK. */\n\tpublishableKey: string;\n\t/** Add your plugins here. Try importing and passing `journeysPlugin` ;) */\n\tplugins: P[];\n\t/** Which app environment to run. This ultimately affects which inploi endpoints to gather data are going to be used.\n\t * Anything other than `production` should be considered a development environment and the data periodicaly purged. */\n\tenv: AppEnvironment;\n\t/** Logger object that handles logging of different levels.\n\t * You can override this to use your own logger, or to disable logging altogether by importing and passing `noLogging`.\n\t * @default inploiBrandedLogger\n\t * */\n\tlogger?: Logger;\n};\n\nexport function initialiseSdk<TPlugin extends Plugin<any, any>>({\n\tpublishableKey,\n\tenv,\n\tplugins,\n\tlogger = inploiBrandedLogger,\n}: InitialiseInploiSdkParams<TPlugin>) {\n\tconst apiClient = createApiClient({ baseUrl: ENV_TO_API_URL[env], publishableKey });\n\n\tconst pluginActions = plugins.reduce(\n\t\t(acc, plugin) => {\n\t\t\tacc[plugin.pluginName as TPlugin['pluginName']] = plugin.pure_createActions({ apiClient, logger });\n\t\t\treturn acc;\n\t\t},\n\t\t{} as { [K in TPlugin['pluginName']]: ReturnType<Flatten<TPlugin & { pluginName: K }>['pure_createActions']> },\n\t);\n\n\treturn pluginActions;\n}\n"],"mappings":"uGAAO,IAAMA,EAAiB,iBACjBC,EAAgB,qCAUhBC,EAA8B,CAC1C,KAAMC,GAAW,QAAQ,KAAKH,EAAgBC,EAAeE,CAAO,EACpE,MAAOA,GAAW,QAAQ,MAAMH,EAAgBC,EAAeE,CAAO,EACtE,KAAMA,GAAW,QAAQ,KAAKH,EAAgBC,EAAeE,CAAO,EACpE,IAAKA,GAAW,QAAQ,IAAIH,EAAgBC,EAAeE,CAAO,CACnE,EAEaC,EAAoB,CAAE,KAAM,IAAG,GAAW,MAAO,IAAG,GAAW,IAAK,IAAG,GAAW,KAAM,IAAG,EAAU,EClB3G,IAAMC,EAAyB,kBACzBC,EAAsB,+BAMtBC,EAAmBC,GAAmE,CAClG,IAAMC,EAA8B,CACnC,OAAQ,mBACR,eAAgB,mBAChB,oBAAqBD,EAAO,cAC7B,EAEA,MAAO,CACN,MAAO,CAAOE,KAA2BC,IAAAC,EAAA,QAA3BF,EAA2B,GAAAC,GAAA,UAA3BE,EAAUC,EAAU,CAAC,EAAM,CACxC,IAAMC,EAAOC,EAAAC,EAAA,GAAKH,GAAL,CAAc,QAASG,IAAA,GAAKH,EAAQ,SAAYL,EAAiB,GACxES,EAAW,MAAM,MAAM,GAAGV,EAAO,OAAO,GAAGK,CAAQ,GAAIE,CAAI,EAAE,KAAKI,GAAOA,EAAI,KAAK,CAAC,EAEzF,GAAI,YAAaD,EAAU,CAC1B,GAAIA,EAAS,UAAYb,EACxB,MAAM,IAAI,MAAM,4BAA4B,EAE7C,GAAIa,EAAS,UAAYZ,EACxB,MAAM,IAAI,MAAM,4BAA4B,EAE7C,GAAI,cAAeY,EAClB,MAAM,IAAI,MAAM,oBAAeA,EAAS,OAAO,QAAG,EAEnD,GAAI,WAAYA,EACf,MAAM,IAAI,MAAM,oBAAeA,EAAS,OAAO,QAAG,CAEpD,CACA,OAAOA,CACR,EACD,CACD,ECRO,SAASE,EAAgD,CAC/D,eAAAC,EACA,IAAAC,EACA,QAAAC,EACA,OAAAC,EAASC,CACV,EAAuC,CACtC,IAAMC,EAAYC,EAAgB,CAAE,QAASC,EAAeN,CAAG,EAAG,eAAAD,CAAe,CAAC,EAUlF,OARsBE,EAAQ,OAC7B,CAACM,EAAKC,KACLD,EAAIC,EAAO,UAAmC,EAAIA,EAAO,mBAAmB,CAAE,UAAAJ,EAAW,OAAAF,CAAO,CAAC,EAC1FK,GAER,CAAC,CACF,CAGD","names":["CONSOLE_PREFIX","CONSOLE_STYLE","inploiBrandedLogger","message","noLogging","unauthenticatedMessage","unauthorisedMessage","createApiClient","params","defaultHeaders","_0","_1","__async","pathname","options","init","__spreadProps","__spreadValues","response","res","initialiseSdk","publishableKey","env","plugins","logger","inploiBrandedLogger","apiClient","createApiClient","ENV_TO_API_URL","acc","plugin"]}
|
package/package.json
CHANGED
package/dist/chunk-DG423OQK.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var m=Object.defineProperty,u=Object.defineProperties;var x=Object.getOwnPropertyDescriptors;var P=Object.getOwnPropertySymbols;var T=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable;var l=(r,i,e)=>i in r?m(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e,c=(r,i)=>{for(var e in i||(i={}))T.call(i,e)&&l(r,e,i[e]);if(P)for(var e of P(i))C.call(i,e)&&l(r,e,i[e]);return r},d=(r,i)=>u(r,x(i));var f=(r,i,e)=>new Promise((p,g)=>{var s=t=>{try{n(e.next(t))}catch(a){g(a)}},o=t=>{try{n(e.throw(t))}catch(a){g(a)}},n=t=>t.done?p(t.value):Promise.resolve(t.value).then(s,o);n((e=e.apply(r,i)).next())});var A=(r,{initialise:i})=>({pluginName:r,initialise:i});export{c as a,d as b,f as c,A as d};
|
|
2
|
-
//# sourceMappingURL=chunk-DG423OQK.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/common/common.plugins.ts"],"sourcesContent":["import { ApiClient } from '../journeys/journeys.api';\nimport { Logger } from './common.logger';\n\nexport type PluginParams = {\n\tapiClient: ApiClient;\n\tlogger?: Logger;\n};\n\nexport type Plugin<T extends string, P> = {\n\tpluginName: T;\n\tinitialise: (params: PluginParams) => P;\n};\n\nexport const createPlugin = <T extends string, P>(\n\t/** The plugin name to access its properties.\n\t * @example const myPluginVariable = createPlugin('myPluginName', { initialise: () => 'works' });\n\t * const sdk = initialiseSdk({plugins: [myPluginVariable]});\n\t * sdk.myPluginName // 'works'\n\t * sdk.myPluginVariable // undefined\n\t */\n\tpluginName: T,\n\t{\n\t\tinitialise,\n\t}: {\n\t\t/** Called when the SDK is initialised.\n\t\t * Here’s where you can do any one-off initialisation.\n\t\t * Returning a value or function will make it available to the SDK client.\n\t\t * @example const plugin = createPlugin('foo', { initialise: () => ({ bar: 'baz' }) });\n\t\t * const sdk = initialiseSdk({plugins: [plugin]});\n\t\t * sdk.foo.bar // 'baz'\n\t\t */\n\t\tinitialise: (params: PluginParams) => P;\n\t},\n): Plugin<T, P> => ({\n\tpluginName,\n\tinitialise,\n});\n"],"mappings":"0nBAaO,IAAMA,EAAe,CAO3BC,EACA,CACC,WAAAC,CACD,KAUmB,CACnB,WAAAD,EACA,WAAAC,CACD","names":["createPlugin","pluginName","initialise"]}
|