@inploi/sdk 0.4.2 → 0.5.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 +1 -3
- package/cdn/plugins/journeys.js +9 -2
- package/cdn/sdk.js +19 -25
- package/dist/{chunk-KHVPBEFD.mjs → chunk-DK3TFXRH.mjs} +1 -1
- package/dist/chunk-DK3TFXRH.mjs.map +1 -0
- package/dist/{common.plugins-030c372f.d.ts → common.plugins-1ba83e05.d.ts} +8 -1
- package/dist/journeys/journeys.d.mts +1 -1
- package/dist/journeys/journeys.d.ts +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 +2 -2
- package/dist/sdk.d.ts +2 -2
- 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-KHVPBEFD.mjs.map +0 -1
package/README.md
CHANGED
package/cdn/plugins/journeys.js
CHANGED
|
@@ -24,7 +24,9 @@
|
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
// src/common/common.plugins.ts
|
|
27
|
-
var createPlugin = (pluginName, {
|
|
27
|
+
var createPlugin = (pluginName, {
|
|
28
|
+
initialise
|
|
29
|
+
}) => ({
|
|
28
30
|
pluginName,
|
|
29
31
|
initialise
|
|
30
32
|
});
|
|
@@ -68,7 +70,12 @@
|
|
|
68
70
|
}
|
|
69
71
|
});
|
|
70
72
|
}
|
|
71
|
-
return {
|
|
73
|
+
return {
|
|
74
|
+
/** Logs an event including some client-side metadata.
|
|
75
|
+
* Will fail if called on the server, as it needs access to window and document.
|
|
76
|
+
*/
|
|
77
|
+
log
|
|
78
|
+
};
|
|
72
79
|
}
|
|
73
80
|
|
|
74
81
|
// src/journeys/journeys.ts
|
package/cdn/sdk.js
CHANGED
|
@@ -42,10 +42,14 @@
|
|
|
42
42
|
});
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
// src/
|
|
46
|
-
var
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
// src/common/common.logger.ts
|
|
46
|
+
var CONSOLE_PREFIX = "%c[inploi SDK]";
|
|
47
|
+
var CONSOLE_STYLE = "color: #65BC67; font-weight: bold;";
|
|
48
|
+
var inploiBrandedLogger = {
|
|
49
|
+
warn: (message) => console.warn(CONSOLE_PREFIX, CONSOLE_STYLE, message),
|
|
50
|
+
error: (message) => console.error(CONSOLE_PREFIX, CONSOLE_STYLE, message),
|
|
51
|
+
info: (message) => console.info(CONSOLE_PREFIX, CONSOLE_STYLE, message),
|
|
52
|
+
log: (message) => console.log(CONSOLE_PREFIX, CONSOLE_STYLE, message)
|
|
49
53
|
};
|
|
50
54
|
|
|
51
55
|
// src/journeys/journeys.api.ts
|
|
@@ -80,24 +84,12 @@
|
|
|
80
84
|
};
|
|
81
85
|
};
|
|
82
86
|
|
|
83
|
-
// src/
|
|
84
|
-
var
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
warn: (message) => console.warn(CONSOLE_PREFIX, CONSOLE_STYLE, message),
|
|
88
|
-
error: (message) => console.error(CONSOLE_PREFIX, CONSOLE_STYLE, message),
|
|
89
|
-
info: (message) => console.info(CONSOLE_PREFIX, CONSOLE_STYLE, message),
|
|
90
|
-
log: (message) => console.log(CONSOLE_PREFIX, CONSOLE_STYLE, message)
|
|
87
|
+
// src/journeys/journeys.constants.ts
|
|
88
|
+
var ENV_TO_API_URL = {
|
|
89
|
+
sandbox: "https://preview.api.inploi.com",
|
|
90
|
+
production: "https://api.inploi.com"
|
|
91
91
|
};
|
|
92
92
|
|
|
93
|
-
// ../core/dist/chunk-H7ZOE7ZC.mjs
|
|
94
|
-
function invariant(condition, message) {
|
|
95
|
-
if (condition) {
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
throw new Error(message);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
93
|
// src/sdk.ts
|
|
102
94
|
function initialiseSdk({
|
|
103
95
|
publishableKey,
|
|
@@ -105,12 +97,14 @@
|
|
|
105
97
|
plugins,
|
|
106
98
|
logger = inploiBrandedLogger
|
|
107
99
|
}) {
|
|
108
|
-
invariant(typeof window !== "undefined", "Can't initialise the inploi SDK outside of a browser environment.");
|
|
109
100
|
const apiClient = createApiClient({ baseUrl: ENV_TO_API_URL[env], publishableKey });
|
|
110
|
-
const pluginsObj = plugins.reduce(
|
|
111
|
-
acc
|
|
112
|
-
|
|
113
|
-
|
|
101
|
+
const pluginsObj = plugins.reduce(
|
|
102
|
+
(acc, plugin) => {
|
|
103
|
+
acc[plugin.pluginName] = plugin.initialise({ apiClient, logger });
|
|
104
|
+
return acc;
|
|
105
|
+
},
|
|
106
|
+
{}
|
|
107
|
+
);
|
|
114
108
|
return pluginsObj;
|
|
115
109
|
}
|
|
116
110
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
var P=Object.defineProperty,u=Object.defineProperties;var c=Object.getOwnPropertyDescriptors;var a=Object.getOwnPropertySymbols;var x=Object.prototype.hasOwnProperty,A=Object.prototype.propertyIsEnumerable;var s=(t,i,n)=>i in t?P(t,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[i]=n,T=(t,i)=>{for(var n in i||(i={}))x.call(i,n)&&s(t,n,i[n]);if(a)for(var n of a(i))A.call(i,n)&&s(t,n,i[n]);return t},d=(t,i)=>u(t,c(i));var E=(t,i,n)=>new Promise((g,p)=>{var l=o=>{try{r(n.next(o))}catch(e){p(e)}},m=o=>{try{r(n.throw(o))}catch(e){p(e)}},r=o=>o.done?g(o.value):Promise.resolve(o.value).then(l,m);r((n=n.apply(t,i)).next())});var _={sandbox:"https://preview.api.inploi.com",production:"https://api.inploi.com"},f="/journey/log";var y=(t,{initialise:i})=>({pluginName:t,initialise:i});export{T as a,d as b,E as c,_ as d,f as e,y as f};
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
2
|
+
//# sourceMappingURL=chunk-DK3TFXRH.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/journeys/journeys.constants.ts","../src/common/common.plugins.ts"],"sourcesContent":["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> = {\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":"0nBAEO,IAAMA,EAAiD,CAC7D,QAAS,iCACT,WAAY,wBACb,EAEaC,EAAmB,eCMzB,IAAMC,EAAe,CAO3BC,EACA,CACC,WAAAC,CACD,KAUmB,CACnB,WAAAD,EACA,WAAAC,CACD","names":["ENV_TO_API_URL","JOURNEY_PATHNAME","createPlugin","pluginName","initialise"]}
|
|
@@ -22,7 +22,14 @@ type Plugin<T extends string, P> = {
|
|
|
22
22
|
pluginName: T;
|
|
23
23
|
initialise: (params: PluginParams) => P;
|
|
24
24
|
};
|
|
25
|
-
declare const createPlugin: <T extends string, P>(pluginName: T, { initialise }: {
|
|
25
|
+
declare const createPlugin: <T extends string, P>(pluginName: T, { initialise, }: {
|
|
26
|
+
/** Called when the SDK is initialised.
|
|
27
|
+
* Here’s where you can do any one-off initialisation.
|
|
28
|
+
* Returning a value or function will make it available to the SDK client.
|
|
29
|
+
* @example const plugin = createPlugin('foo', { initialise: () => ({ bar: 'baz' }) });
|
|
30
|
+
* const sdk = initialiseSdk({plugins: [plugin]});
|
|
31
|
+
* sdk.foo.bar // 'baz'
|
|
32
|
+
*/
|
|
26
33
|
initialise: (params: PluginParams) => P;
|
|
27
34
|
}) => Plugin<T, P>;
|
|
28
35
|
|
|
@@ -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', { initialise: initialiseJourneysPlugin });\n","import {
|
|
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', { initialise: 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> = {\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","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,WAAAC,CACD,KAUmB,CACnB,WAAAD,EACA,WAAAC,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,WAAYC,CAAyB,CAAC","names":["journeys_exports","__export","journeysPlugin","__toCommonJS","createPlugin","pluginName","initialise","JOURNEY_PATHNAME","initialiseJourneysPlugin","apiClient","logger","log","params","__async","data","JOURNEY_PATHNAME","e","journeysPlugin","createPlugin","initialiseJourneysPlugin"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as o,e as n,f as i}from"../chunk-
|
|
1
|
+
import{c as o,e as n,f as i}from"../chunk-DK3TFXRH.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",{initialise: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';\nimport { SDK_VERSION } from '../common/common.constants';\nimport {
|
|
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', { initialise: initialiseJourneysPlugin });\n"],"mappings":"wDA0CO,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,WAAYC,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-1ba83e05.js';
|
|
2
|
+
export { C as CONSOLE_PREFIX, a as CONSOLE_STYLE, c as createPlugin, i as inploiBrandedLogger, n as noLogging } from './common.plugins-1ba83e05.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The environment the SDK should run in.
|
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-1ba83e05.js';
|
|
2
|
+
export { C as CONSOLE_PREFIX, a as CONSOLE_STYLE, c as createPlugin, i as inploiBrandedLogger, n as noLogging } from './common.plugins-1ba83e05.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The environment the SDK should run in.
|
package/dist/sdk.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var l=Object.defineProperty,w=Object.defineProperties,E=Object.getOwnPropertyDescriptor,b=Object.getOwnPropertyDescriptors,C=Object.getOwnPropertyNames,d=Object.getOwnPropertySymbols;var x=Object.prototype.hasOwnProperty,v=Object.prototype.propertyIsEnumerable;var f=(e,n,o)=>n in e?l(e,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[n]=o,u=(e,n)=>{for(var o in n||(n={}))x.call(n,o)&&f(e,o,n[o]);if(d)for(var o of d(n))v.call(n,o)&&f(e,o,n[o]);return e},h=(e,n)=>w(e,b(n));var I=(e,n)=>{for(var o in n)l(e,o,{get:n[o],enumerable:!0})},N=(e,n,o,t)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of C(n))!x.call(e,r)&&r!==o&&l(e,r,{get:()=>n[r],enumerable:!(t=E(n,r))||t.enumerable});return e};var O=e=>N(l({},"__esModule",{value:!0}),e);var y=(e,n,o)=>new Promise((t,r)=>{var P=s=>{try{i(o.next(s))}catch(m){r(m)}},a=s=>{try{i(o.throw(s))}catch(m){r(m)}},i=s=>s.done?t(s.value):Promise.resolve(s.value).then(P,a);i((o=o.apply(e,n)).next())});var U={};I(U,{CONSOLE_PREFIX:()=>p,CONSOLE_STYLE:()=>g,createPlugin:()=>T,initialiseSdk:()=>S,inploiBrandedLogger:()=>c,noLogging:()=>_});module.exports=O(U);var p="%c[inploi SDK]",g="color: #65BC67; font-weight: bold;",c={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)},_={info:()=>{},error:()=>{},log:()=>{},warn:()=>{}};var M="Unauthenticated",R="This action is unauthorized.",L=e=>{let n={Accept:"application/json","Content-Type":"application/json","x-publishable-key":e.publishableKey};return{fetch:(r,...P)=>y(void 0,[r,...P],function*(o,t={}){let a=h(u({},t),{headers:u(u({},t.headers),n)}),i=yield fetch(`${e.baseUrl}${o}`,a).then(s=>s.json());if("message"in i){if(i.message===M)throw new Error("You are not authenticated.");if(i.message===R)throw new Error("You are not authenticated.");if("exception"in i)throw new Error(`API error: \u201C${i.message}\u201D`);if("errors"in i)throw new Error(`API error: \u201C${i.message}\u201D`)}return i})}};var A={sandbox:"https://preview.api.inploi.com",production:"https://api.inploi.com"};var T=(e,{initialise:n})=>({pluginName:e,initialise:n});function S({publishableKey:e,env:n,plugins:o,logger:t=c}){let r=L({baseUrl:A[n],publishableKey:e});return o.reduce((a,i)=>(a[i.pluginName]=i.initialise({apiClient:r,logger:t}),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/
|
|
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 pluginsObj = plugins.reduce(\n\t\t(acc, plugin) => {\n\t\t\tacc[plugin.pluginName as TPlugin['pluginName']] = plugin.initialise({ apiClient, logger });\n\t\t\treturn acc;\n\t\t},\n\t\t{} as { [K in TPlugin['pluginName']]: ReturnType<Flatten<TPlugin & { pluginName: K }>['initialise']> },\n\t);\n\n\treturn pluginsObj;\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> = {\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":"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,WAAAC,CACD,KAUmB,CACnB,WAAAD,EACA,WAAAC,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,OARmBE,EAAQ,OAC1B,CAACM,EAAKC,KACLD,EAAIC,EAAO,UAAmC,EAAIA,EAAO,WAAW,CAAE,UAAAJ,EAAW,OAAAF,CAAO,CAAC,EAClFK,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","initialise","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
|
|
1
|
+
import{a as i,b as l,c as p,d as u,f as h}from"./chunk-DK3TFXRH.mjs";var t="%c[inploi SDK]",s="color: #65BC67; font-weight: bold;",c={warn:e=>console.warn(t,s,e),error:e=>console.error(t,s,e),info:e=>console.info(t,s,e),log:e=>console.log(t,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)=>p(void 0,[d,...y],function*(g,o={}){let r=l(i({},o),{headers:i(i({},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.initialise({apiClient:d,logger:o}),r),{})}export{t 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/
|
|
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 pluginsObj = plugins.reduce(\n\t\t(acc, plugin) => {\n\t\t\tacc[plugin.pluginName as TPlugin['pluginName']] = plugin.initialise({ apiClient, logger });\n\t\t\treturn acc;\n\t\t},\n\t\t{} as { [K in TPlugin['pluginName']]: ReturnType<Flatten<TPlugin & { pluginName: K }>['initialise']> },\n\t);\n\n\treturn pluginsObj;\n}\n"],"mappings":"qEAAO,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,OARmBE,EAAQ,OAC1B,CAACM,EAAKC,KACLD,EAAIC,EAAO,UAAmC,EAAIA,EAAO,WAAW,CAAE,UAAAJ,EAAW,OAAAF,CAAO,CAAC,EAClFK,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
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/journeys/journeys.constants.ts","../src/common/common.plugins.ts"],"sourcesContent":["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 { Logger } from './common.logger';\nimport { ApiClient } from '../journeys/journeys.api';\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\tpluginName: T,\n\t{ initialise }: { initialise: (params: PluginParams) => P }\n): Plugin<T, P> => ({\n\tpluginName,\n\tinitialise,\n});\n"],"mappings":"0nBAEO,IAAMA,EAAiD,CAC7D,QAAS,iCACT,WAAY,wBACb,EAEaC,EAAmB,eCMzB,IAAMC,EAAe,CAC3BC,EACA,CAAE,WAAAC,CAAW,KACM,CACnB,WAAAD,EACA,WAAAC,CACD","names":["ENV_TO_API_URL","JOURNEY_PATHNAME","createPlugin","pluginName","initialise"]}
|