@inploi/sdk 0.7.0 → 1.4.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 +52 -8
- package/cdn/index.js +3 -0
- package/dist/index.d.mts +57 -0
- package/dist/index.d.ts +57 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +42 -45
- package/cdn/plugins/accessibility.js +0 -76
- package/cdn/plugins/journeys.js +0 -89
- package/cdn/sdk.js +0 -115
- package/dist/accessibility/accessibility.d.mts +0 -63
- package/dist/accessibility/accessibility.d.ts +0 -63
- package/dist/accessibility/accessibility.js +0 -2
- package/dist/accessibility/accessibility.js.map +0 -1
- package/dist/accessibility/accessibility.mjs +0 -2
- package/dist/accessibility/accessibility.mjs.map +0 -1
- package/dist/chunk-NLLAI5ZB.mjs +0 -2
- package/dist/chunk-NLLAI5ZB.mjs.map +0 -1
- package/dist/chunk-WFTFPD6B.mjs +0 -2
- package/dist/chunk-WFTFPD6B.mjs.map +0 -1
- package/dist/common.plugins-2d10f2e9.d.ts +0 -36
- package/dist/journeys/journeys.d.mts +0 -77
- package/dist/journeys/journeys.d.ts +0 -77
- package/dist/journeys/journeys.js +0 -2
- package/dist/journeys/journeys.js.map +0 -1
- package/dist/journeys/journeys.mjs +0 -2
- package/dist/journeys/journeys.mjs.map +0 -1
- package/dist/sdk.d.mts +0 -31
- package/dist/sdk.d.ts +0 -31
- package/dist/sdk.js +0 -2
- package/dist/sdk.js.map +0 -1
- package/dist/sdk.mjs +0 -2
- package/dist/sdk.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -14,28 +14,72 @@ You can initialise the SDK by calling `initialiseInploiSdk` with the following o
|
|
|
14
14
|
|
|
15
15
|
```javascript
|
|
16
16
|
import { initialiseInploiSdk } from '@inploi/sdk';
|
|
17
|
-
import { journeysPlugin } from '@inploi/sdk/journeys';
|
|
18
17
|
|
|
19
18
|
const sdk = initialiseInploiSdk({
|
|
20
19
|
publishableKey: 'your-publishable-key',
|
|
21
|
-
plugins: [],
|
|
22
20
|
env: 'sandbox',
|
|
23
21
|
});
|
|
24
22
|
```
|
|
25
23
|
|
|
26
24
|
## Plugins
|
|
27
25
|
|
|
28
|
-
|
|
26
|
+
You can write custom plugins via the `createPlugin` function. The plugin will have two dependencies injected: a `logger` service and a an `apiClient` service, which can be used to make requests to the inploi API.
|
|
27
|
+
|
|
28
|
+
Example:
|
|
29
29
|
|
|
30
30
|
```javascript
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
export const myCounterPlugin = createPlugin(({ logger, apiClient }) => {
|
|
32
|
+
let count = 0;
|
|
33
|
+
logger.info('myCounterPlugin initialised');
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
add: () => {
|
|
37
|
+
count++;
|
|
38
|
+
logger.info(`count is now ${count}`);
|
|
39
|
+
},
|
|
40
|
+
getCount: () => count,
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## External dependencies
|
|
46
|
+
|
|
47
|
+
If your plugin requires external dependencies, you may want to wrap the `createPlugin` function with whatever it takes, to then generate a function that returns a plugin:
|
|
48
|
+
|
|
49
|
+
```javascript
|
|
50
|
+
import { createPlugin } from '@inploi/sdk';
|
|
51
|
+
|
|
52
|
+
type CounterExternalDeps = {onUpdate: (newCounter: number) => void};
|
|
33
53
|
|
|
54
|
+
export const myCounterPlugin = ({onUpdate}: CounterExternalDeps) =>
|
|
55
|
+
createPlugin(({ logger, apiClient }) => {
|
|
56
|
+
let count = 0;
|
|
57
|
+
logger.info('myCounterPlugin initialised');
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
add: () => {
|
|
61
|
+
count++;
|
|
62
|
+
logger.info(`count is now ${count}`);
|
|
63
|
+
onUpdate(count);
|
|
64
|
+
},
|
|
65
|
+
getCount: () => count,
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Using plugins
|
|
71
|
+
|
|
72
|
+
Users of the SDK may invoke `sdk.registerPlugin` with a plugin to register it. The plugin will be initialised with the dependencies it requires, and the returned object will be returned to the user.
|
|
73
|
+
|
|
74
|
+
```javascript
|
|
34
75
|
const sdk = initialiseInploiSdk({
|
|
35
76
|
publishableKey: 'your-publishable-key',
|
|
36
|
-
plugins: [journeysPlugin],
|
|
37
77
|
env: 'sandbox',
|
|
38
78
|
});
|
|
39
|
-
|
|
40
|
-
sdk.
|
|
79
|
+
|
|
80
|
+
const mySimplePlugin = sdk.registerPlugin(mySimplePlugin);
|
|
81
|
+
|
|
82
|
+
const myCounterPlugin = sdk.registerPlugin(myPluginWithDeps({ onUpdate: newCounter => console.log(newCounter) }));
|
|
83
|
+
|
|
84
|
+
myCounterPlugin.add();
|
|
41
85
|
```
|
package/cdn/index.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// This is an inploi sdk script. Learn more at https://inploi.com
|
|
2
|
+
|
|
3
|
+
"use strict";(()=>{var y=Object.defineProperty,P=Object.defineProperties;var E=Object.getOwnPropertyDescriptors;var u=Object.getOwnPropertySymbols;var A=Object.prototype.hasOwnProperty,I=Object.prototype.propertyIsEnumerable;var f=(e,i,o)=>i in e?y(e,i,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[i]=o,a=(e,i)=>{for(var o in i||(i={}))A.call(i,o)&&f(e,o,i[o]);if(u)for(var o of u(i))I.call(i,o)&&f(e,o,i[o]);return e},m=(e,i)=>P(e,E(i));var h=(e,i,o)=>new Promise((r,g)=>{var s=n=>{try{t(o.next(n))}catch(d){g(d)}},c=n=>{try{t(o.throw(n))}catch(d){g(d)}},t=n=>n.done?r(n.value):Promise.resolve(n.value).then(s,c);t((o=o.apply(e,i)).next())});var S="Unauthenticated",k="This action is unauthorized.",w=e=>{let i={Accept:"application/json","Content-Type":"application/json","x-publishable-key":e.publishableKey};return{fetch:(g,...s)=>h(void 0,[g,...s],function*(o,r={}){let c=m(a({},r),{headers:a(a({},r.headers),i)}),t=yield fetch(`${e.baseUrl}${o}`,c),n=yield t.json();if(typeof n=="object"&&n!==null&&"message"in n){if(n.message===S)throw new Error("You are not authenticated.");if(n.message===k)throw new Error("You are not authorised to perform this action.");if("exception"in t)throw new Error(`API error: \u201C${n.message}\u201D`);if("errors"in t)throw new Error(`API error: \u201C${n.message}\u201D`)}return n})}};var x={sandbox:"https://preview.api.inploi.com",production:"https://api.inploi.com"};var p="%c[inploi SDK]",l="color: #65BC67; font-weight: bold;",L={warn:(...e)=>console.warn(p,l,...e),error:(...e)=>console.error(p,l,...e),info:(...e)=>console.info(p,l,...e),log:(...e)=>console.log(p,l,...e)};function b({publishableKey:e,env:i,logger:o=L}){let r=w({baseUrl:x[i],publishableKey:e});return{registerPlugin:s=>(o.info(`Registering plugin ${s.name}`),s({logger:o,apiClient:r}))}}typeof window.inploi!="object"&&(window.inploi={});window.inploi.initialiseSdk=b;})();
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
type LogMessage = (...data: any[]) => void;
|
|
2
|
+
type Logger = {
|
|
3
|
+
warn: LogMessage;
|
|
4
|
+
error: LogMessage;
|
|
5
|
+
info: LogMessage;
|
|
6
|
+
log: LogMessage;
|
|
7
|
+
};
|
|
8
|
+
declare const inploiBrandedLogger: Logger;
|
|
9
|
+
declare const noLogging: Logger;
|
|
10
|
+
|
|
11
|
+
type ApiClient = {
|
|
12
|
+
fetch: (pathname: string, options?: RequestInit) => Promise<unknown>;
|
|
13
|
+
};
|
|
14
|
+
declare const createApiClient: (params: {
|
|
15
|
+
baseUrl: string;
|
|
16
|
+
publishableKey: string;
|
|
17
|
+
}) => ApiClient;
|
|
18
|
+
|
|
19
|
+
type PluginParams = {
|
|
20
|
+
apiClient: ApiClient;
|
|
21
|
+
logger?: Logger;
|
|
22
|
+
};
|
|
23
|
+
type Plugin<T extends string, P extends Record<string, unknown>> = {
|
|
24
|
+
pluginName: T;
|
|
25
|
+
pure_createActions: (params: PluginParams) => P;
|
|
26
|
+
};
|
|
27
|
+
type PluginDependencies = {
|
|
28
|
+
apiClient: ApiClient;
|
|
29
|
+
logger: Logger;
|
|
30
|
+
};
|
|
31
|
+
type InploiSdkPlugin = (dependencies: PluginDependencies) => any;
|
|
32
|
+
declare const createPlugin: <T extends InploiSdkPlugin>(pluginFn: T) => T;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The environment the SDK should run in.
|
|
36
|
+
* - `production`: data will be stored and displayed on dashboards
|
|
37
|
+
* - `sandbox`: data will be stored temporarily and purged periodically
|
|
38
|
+
*/
|
|
39
|
+
type AppEnvironment = 'production' | 'sandbox';
|
|
40
|
+
|
|
41
|
+
type InitialiseInploiSdkParams = {
|
|
42
|
+
/** Your public API key for the inploi SDK. */
|
|
43
|
+
publishableKey: string;
|
|
44
|
+
/** Which app environment to run. This ultimately affects which inploi endpoints to gather data are going to be used.
|
|
45
|
+
* Anything other than `production` should be considered a development environment and the data periodicaly purged. */
|
|
46
|
+
env: AppEnvironment;
|
|
47
|
+
/** Logger object that handles logging of different levels.
|
|
48
|
+
* You can override this to use your own logger, or to disable logging altogether by importing and passing `noLogging`.
|
|
49
|
+
* @default inploiBrandedLogger
|
|
50
|
+
* */
|
|
51
|
+
logger?: Logger;
|
|
52
|
+
};
|
|
53
|
+
declare function initialiseSdk({ publishableKey, env, logger }: InitialiseInploiSdkParams): {
|
|
54
|
+
registerPlugin: <P extends InploiSdkPlugin>(plugin: P) => ReturnType<P>;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export { ApiClient, InitialiseInploiSdkParams, Logger, Plugin, PluginParams, createApiClient, createPlugin, initialiseSdk, inploiBrandedLogger, noLogging };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
type LogMessage = (...data: any[]) => void;
|
|
2
|
+
type Logger = {
|
|
3
|
+
warn: LogMessage;
|
|
4
|
+
error: LogMessage;
|
|
5
|
+
info: LogMessage;
|
|
6
|
+
log: LogMessage;
|
|
7
|
+
};
|
|
8
|
+
declare const inploiBrandedLogger: Logger;
|
|
9
|
+
declare const noLogging: Logger;
|
|
10
|
+
|
|
11
|
+
type ApiClient = {
|
|
12
|
+
fetch: (pathname: string, options?: RequestInit) => Promise<unknown>;
|
|
13
|
+
};
|
|
14
|
+
declare const createApiClient: (params: {
|
|
15
|
+
baseUrl: string;
|
|
16
|
+
publishableKey: string;
|
|
17
|
+
}) => ApiClient;
|
|
18
|
+
|
|
19
|
+
type PluginParams = {
|
|
20
|
+
apiClient: ApiClient;
|
|
21
|
+
logger?: Logger;
|
|
22
|
+
};
|
|
23
|
+
type Plugin<T extends string, P extends Record<string, unknown>> = {
|
|
24
|
+
pluginName: T;
|
|
25
|
+
pure_createActions: (params: PluginParams) => P;
|
|
26
|
+
};
|
|
27
|
+
type PluginDependencies = {
|
|
28
|
+
apiClient: ApiClient;
|
|
29
|
+
logger: Logger;
|
|
30
|
+
};
|
|
31
|
+
type InploiSdkPlugin = (dependencies: PluginDependencies) => any;
|
|
32
|
+
declare const createPlugin: <T extends InploiSdkPlugin>(pluginFn: T) => T;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The environment the SDK should run in.
|
|
36
|
+
* - `production`: data will be stored and displayed on dashboards
|
|
37
|
+
* - `sandbox`: data will be stored temporarily and purged periodically
|
|
38
|
+
*/
|
|
39
|
+
type AppEnvironment = 'production' | 'sandbox';
|
|
40
|
+
|
|
41
|
+
type InitialiseInploiSdkParams = {
|
|
42
|
+
/** Your public API key for the inploi SDK. */
|
|
43
|
+
publishableKey: string;
|
|
44
|
+
/** Which app environment to run. This ultimately affects which inploi endpoints to gather data are going to be used.
|
|
45
|
+
* Anything other than `production` should be considered a development environment and the data periodicaly purged. */
|
|
46
|
+
env: AppEnvironment;
|
|
47
|
+
/** Logger object that handles logging of different levels.
|
|
48
|
+
* You can override this to use your own logger, or to disable logging altogether by importing and passing `noLogging`.
|
|
49
|
+
* @default inploiBrandedLogger
|
|
50
|
+
* */
|
|
51
|
+
logger?: Logger;
|
|
52
|
+
};
|
|
53
|
+
declare function initialiseSdk({ publishableKey, env, logger }: InitialiseInploiSdkParams): {
|
|
54
|
+
registerPlugin: <P extends InploiSdkPlugin>(plugin: P) => ReturnType<P>;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export { ApiClient, InitialiseInploiSdkParams, Logger, Plugin, PluginParams, createApiClient, createPlugin, initialiseSdk, inploiBrandedLogger, noLogging };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var a=Object.defineProperty,C=Object.defineProperties,b=Object.getOwnPropertyDescriptor,E=Object.getOwnPropertyDescriptors,S=Object.getOwnPropertyNames,f=Object.getOwnPropertySymbols;var h=Object.prototype.hasOwnProperty,v=Object.prototype.propertyIsEnumerable;var P=(e,o,n)=>o in e?a(e,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[o]=n,g=(e,o)=>{for(var n in o||(o={}))h.call(o,n)&&P(e,n,o[n]);if(f)for(var n of f(o))v.call(o,n)&&P(e,n,o[n]);return e},L=(e,o)=>C(e,E(o));var T=(e,o)=>{for(var n in o)a(e,n,{get:o[n],enumerable:!0})},_=(e,o,n,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of S(o))!h.call(e,t)&&t!==n&&a(e,t,{get:()=>o[t],enumerable:!(i=b(o,t))||i.enumerable});return e};var R=e=>_(a({},"__esModule",{value:!0}),e);var y=(e,o,n)=>new Promise((i,t)=>{var s=r=>{try{p(n.next(r))}catch(x){t(x)}},m=r=>{try{p(n.throw(r))}catch(x){t(x)}},p=r=>r.done?i(r.value):Promise.resolve(r.value).then(s,m);p((n=n.apply(e,o)).next())});var U={};T(U,{createApiClient:()=>u,createPlugin:()=>w,initialiseSdk:()=>k,inploiBrandedLogger:()=>d,noLogging:()=>A});module.exports=R(U);var l="%c[inploi SDK]",c="color: #65BC67; font-weight: bold;",d={warn:(...e)=>console.warn(l,c,...e),error:(...e)=>console.error(l,c,...e),info:(...e)=>console.info(l,c,...e),log:(...e)=>console.log(l,c,...e)},A={info:()=>{},error:()=>{},log:()=>{},warn:()=>{}};var w=e=>e;var M="Unauthenticated",O="This action is unauthorized.",u=e=>{let o={Accept:"application/json","Content-Type":"application/json","x-publishable-key":e.publishableKey};return{fetch:(t,...s)=>y(void 0,[t,...s],function*(n,i={}){let m=L(g({},i),{headers:g(g({},i.headers),o)}),p=yield fetch(`${e.baseUrl}${n}`,m),r=yield p.json();if(typeof r=="object"&&r!==null&&"message"in r){if(r.message===M)throw new Error("You are not authenticated.");if(r.message===O)throw new Error("You are not authorised to perform this action.");if("exception"in p)throw new Error(`API error: \u201C${r.message}\u201D`);if("errors"in p)throw new Error(`API error: \u201C${r.message}\u201D`)}return r})}};var I={sandbox:"https://preview.api.inploi.com",production:"https://api.inploi.com"};function k({publishableKey:e,env:o,logger:n=d}){let i=u({baseUrl:I[o],publishableKey:e});return{registerPlugin:s=>(n.info(`Registering plugin ${s.name}`),s({logger:n,apiClient:i}))}}0&&(module.exports={createApiClient,createPlugin,initialiseSdk,inploiBrandedLogger,noLogging});
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/sdk.logger.ts","../src/sdk.plugins.ts","../src/sdk.api.ts","../src/sdk.constants.ts","../src/sdk.ts"],"sourcesContent":["export { inploiBrandedLogger, noLogging } from './sdk.logger';\nexport type { Logger } from './sdk.logger';\n\nexport type { Plugin, PluginParams } from './sdk.plugins';\nexport { createPlugin } from './sdk.plugins';\n\nexport { createApiClient } from './sdk.api';\nexport type { ApiClient } from './sdk.api';\n\nexport { initialiseSdk } from './sdk';\nexport type { InitialiseInploiSdkParams } from './sdk';\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: (...args) => console.warn(CONSOLE_PREFIX, CONSOLE_STYLE, ...args),\n\terror: (...args) => console.error(CONSOLE_PREFIX, CONSOLE_STYLE, ...args),\n\tinfo: (...args) => console.info(CONSOLE_PREFIX, CONSOLE_STYLE, ...args),\n\tlog: (...args) => console.log(CONSOLE_PREFIX, CONSOLE_STYLE, ...args),\n};\n\nexport const noLogging: Logger = { info: () => void 0, error: () => void 0, log: () => void 0, warn: () => void 0 };\n","import { ApiClient } from './sdk.api';\nimport { Logger } from './sdk.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\ntype PluginDependencies = {\n\tapiClient: ApiClient;\n\tlogger: Logger;\n};\n\nexport type InploiSdkPlugin = (dependencies: PluginDependencies) => any;\n\nexport const createPlugin = <T extends InploiSdkPlugin>(pluginFn: T) => pluginFn;\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\t/** Fetches from a pathname with a pre-established base path.\n\t\t * Parses received output as JSON, and throw if one of the common error messages is received.\n\t\t */\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);\n\t\t\tconst json = await response.json();\n\n\t\t\tif (typeof json === 'object' && json !== null && 'message' in json) {\n\t\t\t\tif (json.message === unauthenticatedMessage) {\n\t\t\t\t\tthrow new Error('You are not authenticated.');\n\t\t\t\t}\n\t\t\t\tif (json.message === unauthorisedMessage) {\n\t\t\t\t\tthrow new Error('You are not authorised to perform this action.');\n\t\t\t\t}\n\t\t\t\tif ('exception' in response) {\n\t\t\t\t\tthrow new Error(`API error: “${json.message}”`);\n\t\t\t\t}\n\t\t\t\tif ('errors' in response) {\n\t\t\t\t\tthrow new Error(`API error: “${json.message}”`);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn json;\n\t\t},\n\t};\n};\n","/**\n * The environment the SDK should run in.\n * - `production`: data will be stored and displayed on dashboards\n * - `sandbox`: data will be stored temporarily and purged periodically\n */\nexport type AppEnvironment = 'production' | 'sandbox';\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","import { createApiClient } from './sdk.api';\nimport { AppEnvironment, ENV_TO_API_URL } from './sdk.constants';\nimport { Logger, inploiBrandedLogger } from './sdk.logger';\nimport { InploiSdkPlugin } from './sdk.plugins';\n\nexport type InitialiseInploiSdkParams = {\n\t/** Your public API key for the inploi SDK. */\n\tpublishableKey: string;\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({ publishableKey, env, logger = inploiBrandedLogger }: InitialiseInploiSdkParams) {\n\tconst apiClient = createApiClient({ baseUrl: ENV_TO_API_URL[env], publishableKey });\n\n\tconst registerPlugin = <P extends InploiSdkPlugin>(plugin: P): ReturnType<P> => {\n\t\tlogger.info(`Registering plugin ${plugin.name}`);\n\t\treturn plugin({ logger, apiClient });\n\t};\n\n\treturn { registerPlugin };\n}\n"],"mappings":"i9BAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,EAAA,iBAAAC,EAAA,kBAAAC,EAAA,wBAAAC,EAAA,cAAAC,IAAA,eAAAC,EAAAP,GCAO,IAAMQ,EAAiB,iBACjBC,EAAgB,qCAUhBC,EAA8B,CAC1C,KAAM,IAAIC,IAAS,QAAQ,KAAKH,EAAgBC,EAAe,GAAGE,CAAI,EACtE,MAAO,IAAIA,IAAS,QAAQ,MAAMH,EAAgBC,EAAe,GAAGE,CAAI,EACxE,KAAM,IAAIA,IAAS,QAAQ,KAAKH,EAAgBC,EAAe,GAAGE,CAAI,EACtE,IAAK,IAAIA,IAAS,QAAQ,IAAIH,EAAgBC,EAAe,GAAGE,CAAI,CACrE,EAEaC,EAAoB,CAAE,KAAM,IAAG,GAAW,MAAO,IAAG,GAAW,IAAK,IAAG,GAAW,KAAM,IAAG,EAAU,ECE3G,IAAMC,EAA2CC,GAAgBA,ECpBjE,IAAMC,EAAyB,kBACzBC,EAAsB,+BAMtBC,EAAmBC,GAAmE,CAClG,IAAMC,EAA8B,CACnC,OAAQ,mBACR,eAAgB,mBAChB,oBAAqBD,EAAO,cAC7B,EAEA,MAAO,CAIN,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,EAC3DI,EAAO,MAAMD,EAAS,KAAK,EAEjC,GAAI,OAAOC,GAAS,UAAYA,IAAS,MAAQ,YAAaA,EAAM,CACnE,GAAIA,EAAK,UAAYd,EACpB,MAAM,IAAI,MAAM,4BAA4B,EAE7C,GAAIc,EAAK,UAAYb,EACpB,MAAM,IAAI,MAAM,gDAAgD,EAEjE,GAAI,cAAeY,EAClB,MAAM,IAAI,MAAM,oBAAeC,EAAK,OAAO,QAAG,EAE/C,GAAI,WAAYD,EACf,MAAM,IAAI,MAAM,oBAAeC,EAAK,OAAO,QAAG,CAEhD,CACA,OAAOA,CACR,EACD,CACD,ECjCO,IAAMC,EAAiD,CAC7D,QAAS,iCACT,WAAY,wBACb,ECQO,SAASC,EAAc,CAAE,eAAAC,EAAgB,IAAAC,EAAK,OAAAC,EAASC,CAAoB,EAA8B,CAC/G,IAAMC,EAAYC,EAAgB,CAAE,QAASC,EAAeL,CAAG,EAAG,eAAAD,CAAe,CAAC,EAOlF,MAAO,CAAE,eAL0CO,IAClDL,EAAO,KAAK,sBAAsBK,EAAO,IAAI,EAAE,EACxCA,EAAO,CAAE,OAAAL,EAAQ,UAAAE,CAAU,CAAC,EAGZ,CACzB","names":["src_exports","__export","createApiClient","createPlugin","initialiseSdk","inploiBrandedLogger","noLogging","__toCommonJS","CONSOLE_PREFIX","CONSOLE_STYLE","inploiBrandedLogger","args","noLogging","createPlugin","pluginFn","unauthenticatedMessage","unauthorisedMessage","createApiClient","params","defaultHeaders","_0","_1","__async","pathname","options","init","__spreadProps","__spreadValues","response","json","ENV_TO_API_URL","initialiseSdk","publishableKey","env","logger","inploiBrandedLogger","apiClient","createApiClient","ENV_TO_API_URL","plugin"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var y=Object.defineProperty,A=Object.defineProperties;var w=Object.getOwnPropertyDescriptors;var x=Object.getOwnPropertySymbols;var I=Object.prototype.hasOwnProperty,k=Object.prototype.propertyIsEnumerable;var f=(e,n,o)=>n in e?y(e,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[n]=o,s=(e,n)=>{for(var o in n||(n={}))I.call(n,o)&&f(e,o,n[o]);if(x)for(var o of x(n))k.call(n,o)&&f(e,o,n[o]);return e},P=(e,n)=>A(e,w(n));var h=(e,n,o)=>new Promise((t,l)=>{var p=r=>{try{i(o.next(r))}catch(d){l(d)}},c=r=>{try{i(o.throw(r))}catch(d){l(d)}},i=r=>r.done?t(r.value):Promise.resolve(r.value).then(p,c);i((o=o.apply(e,n)).next())});var a="%c[inploi SDK]",g="color: #65BC67; font-weight: bold;",u={warn:(...e)=>console.warn(a,g,...e),error:(...e)=>console.error(a,g,...e),info:(...e)=>console.info(a,g,...e),log:(...e)=>console.log(a,g,...e)},C={info:()=>{},error:()=>{},log:()=>{},warn:()=>{}};var b=e=>e;var E="Unauthenticated",S="This action is unauthorized.",m=e=>{let n={Accept:"application/json","Content-Type":"application/json","x-publishable-key":e.publishableKey};return{fetch:(l,...p)=>h(void 0,[l,...p],function*(o,t={}){let c=P(s({},t),{headers:s(s({},t.headers),n)}),i=yield fetch(`${e.baseUrl}${o}`,c),r=yield i.json();if(typeof r=="object"&&r!==null&&"message"in r){if(r.message===E)throw new Error("You are not authenticated.");if(r.message===S)throw new Error("You are not authorised to perform this action.");if("exception"in i)throw new Error(`API error: \u201C${r.message}\u201D`);if("errors"in i)throw new Error(`API error: \u201C${r.message}\u201D`)}return r})}};var L={sandbox:"https://preview.api.inploi.com",production:"https://api.inploi.com"};function v({publishableKey:e,env:n,logger:o=u}){let t=m({baseUrl:L[n],publishableKey:e});return{registerPlugin:p=>(o.info(`Registering plugin ${p.name}`),p({logger:o,apiClient:t}))}}export{m as createApiClient,b as createPlugin,v as initialiseSdk,u as inploiBrandedLogger,C as noLogging};
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/sdk.logger.ts","../src/sdk.plugins.ts","../src/sdk.api.ts","../src/sdk.constants.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: (...args) => console.warn(CONSOLE_PREFIX, CONSOLE_STYLE, ...args),\n\terror: (...args) => console.error(CONSOLE_PREFIX, CONSOLE_STYLE, ...args),\n\tinfo: (...args) => console.info(CONSOLE_PREFIX, CONSOLE_STYLE, ...args),\n\tlog: (...args) => console.log(CONSOLE_PREFIX, CONSOLE_STYLE, ...args),\n};\n\nexport const noLogging: Logger = { info: () => void 0, error: () => void 0, log: () => void 0, warn: () => void 0 };\n","import { ApiClient } from './sdk.api';\nimport { Logger } from './sdk.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\ntype PluginDependencies = {\n\tapiClient: ApiClient;\n\tlogger: Logger;\n};\n\nexport type InploiSdkPlugin = (dependencies: PluginDependencies) => any;\n\nexport const createPlugin = <T extends InploiSdkPlugin>(pluginFn: T) => pluginFn;\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\t/** Fetches from a pathname with a pre-established base path.\n\t\t * Parses received output as JSON, and throw if one of the common error messages is received.\n\t\t */\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);\n\t\t\tconst json = await response.json();\n\n\t\t\tif (typeof json === 'object' && json !== null && 'message' in json) {\n\t\t\t\tif (json.message === unauthenticatedMessage) {\n\t\t\t\t\tthrow new Error('You are not authenticated.');\n\t\t\t\t}\n\t\t\t\tif (json.message === unauthorisedMessage) {\n\t\t\t\t\tthrow new Error('You are not authorised to perform this action.');\n\t\t\t\t}\n\t\t\t\tif ('exception' in response) {\n\t\t\t\t\tthrow new Error(`API error: “${json.message}”`);\n\t\t\t\t}\n\t\t\t\tif ('errors' in response) {\n\t\t\t\t\tthrow new Error(`API error: “${json.message}”`);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn json;\n\t\t},\n\t};\n};\n","/**\n * The environment the SDK should run in.\n * - `production`: data will be stored and displayed on dashboards\n * - `sandbox`: data will be stored temporarily and purged periodically\n */\nexport type AppEnvironment = 'production' | 'sandbox';\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","import { createApiClient } from './sdk.api';\nimport { AppEnvironment, ENV_TO_API_URL } from './sdk.constants';\nimport { Logger, inploiBrandedLogger } from './sdk.logger';\nimport { InploiSdkPlugin } from './sdk.plugins';\n\nexport type InitialiseInploiSdkParams = {\n\t/** Your public API key for the inploi SDK. */\n\tpublishableKey: string;\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({ publishableKey, env, logger = inploiBrandedLogger }: InitialiseInploiSdkParams) {\n\tconst apiClient = createApiClient({ baseUrl: ENV_TO_API_URL[env], publishableKey });\n\n\tconst registerPlugin = <P extends InploiSdkPlugin>(plugin: P): ReturnType<P> => {\n\t\tlogger.info(`Registering plugin ${plugin.name}`);\n\t\treturn plugin({ logger, apiClient });\n\t};\n\n\treturn { registerPlugin };\n}\n"],"mappings":"0nBAAO,IAAMA,EAAiB,iBACjBC,EAAgB,qCAUhBC,EAA8B,CAC1C,KAAM,IAAIC,IAAS,QAAQ,KAAKH,EAAgBC,EAAe,GAAGE,CAAI,EACtE,MAAO,IAAIA,IAAS,QAAQ,MAAMH,EAAgBC,EAAe,GAAGE,CAAI,EACxE,KAAM,IAAIA,IAAS,QAAQ,KAAKH,EAAgBC,EAAe,GAAGE,CAAI,EACtE,IAAK,IAAIA,IAAS,QAAQ,IAAIH,EAAgBC,EAAe,GAAGE,CAAI,CACrE,EAEaC,EAAoB,CAAE,KAAM,IAAG,GAAW,MAAO,IAAG,GAAW,IAAK,IAAG,GAAW,KAAM,IAAG,EAAU,ECE3G,IAAMC,EAA2CC,GAAgBA,ECpBjE,IAAMC,EAAyB,kBACzBC,EAAsB,+BAMtBC,EAAmBC,GAAmE,CAClG,IAAMC,EAA8B,CACnC,OAAQ,mBACR,eAAgB,mBAChB,oBAAqBD,EAAO,cAC7B,EAEA,MAAO,CAIN,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,EAC3DI,EAAO,MAAMD,EAAS,KAAK,EAEjC,GAAI,OAAOC,GAAS,UAAYA,IAAS,MAAQ,YAAaA,EAAM,CACnE,GAAIA,EAAK,UAAYd,EACpB,MAAM,IAAI,MAAM,4BAA4B,EAE7C,GAAIc,EAAK,UAAYb,EACpB,MAAM,IAAI,MAAM,gDAAgD,EAEjE,GAAI,cAAeY,EAClB,MAAM,IAAI,MAAM,oBAAeC,EAAK,OAAO,QAAG,EAE/C,GAAI,WAAYD,EACf,MAAM,IAAI,MAAM,oBAAeC,EAAK,OAAO,QAAG,CAEhD,CACA,OAAOA,CACR,EACD,CACD,ECjCO,IAAMC,EAAiD,CAC7D,QAAS,iCACT,WAAY,wBACb,ECQO,SAASC,EAAc,CAAE,eAAAC,EAAgB,IAAAC,EAAK,OAAAC,EAASC,CAAoB,EAA8B,CAC/G,IAAMC,EAAYC,EAAgB,CAAE,QAASC,EAAeL,CAAG,EAAG,eAAAD,CAAe,CAAC,EAOlF,MAAO,CAAE,eAL0CO,IAClDL,EAAO,KAAK,sBAAsBK,EAAO,IAAI,EAAE,EACxCA,EAAO,CAAE,OAAAL,EAAQ,UAAAE,CAAU,CAAC,EAGZ,CACzB","names":["CONSOLE_PREFIX","CONSOLE_STYLE","inploiBrandedLogger","args","noLogging","createPlugin","pluginFn","unauthenticatedMessage","unauthorisedMessage","createApiClient","params","defaultHeaders","_0","_1","__async","pathname","options","init","__spreadProps","__spreadValues","response","json","ENV_TO_API_URL","initialiseSdk","publishableKey","env","logger","inploiBrandedLogger","apiClient","createApiClient","ENV_TO_API_URL","plugin"]}
|
package/package.json
CHANGED
|
@@ -1,46 +1,43 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
"typescript": "^5.1.6"
|
|
45
|
-
}
|
|
46
|
-
}
|
|
2
|
+
"name": "@inploi/sdk",
|
|
3
|
+
"version": "1.4.0",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"files": [
|
|
8
|
+
"/dist",
|
|
9
|
+
"/cdn"
|
|
10
|
+
],
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"require": "./dist/index.js",
|
|
14
|
+
"import": "./dist/index.mjs",
|
|
15
|
+
"types": "./dist/index.d.ts"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@inploi/core": "1.4.0"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@happy-dom/global-registrator": "^12.6.0",
|
|
23
|
+
"@total-typescript/ts-reset": "^0.5.1",
|
|
24
|
+
"@types/react": "^18.2.33",
|
|
25
|
+
"@types/react-dom": "^18.2.14",
|
|
26
|
+
"autoprefixer": "^10.4.16",
|
|
27
|
+
"eslint": "^7.32.0",
|
|
28
|
+
"happy-dom": "^12.6.0",
|
|
29
|
+
"ts-toolbelt": "^9.6.0",
|
|
30
|
+
"tsup": "^7.2.0",
|
|
31
|
+
"typescript": "^5.1.6",
|
|
32
|
+
"eslint-config-custom": "0.1.0",
|
|
33
|
+
"tsconfig": "0.1.0"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build:npm": "tsup --dts --dts-resolve",
|
|
37
|
+
"build:cdn": "tsup --config tsup.cdn.config.ts",
|
|
38
|
+
"build": "concurrently 'pnpm run build:npm' 'pnpm run build:cdn'",
|
|
39
|
+
"dev": "tsup --watch --config tsup.cdn.config.ts",
|
|
40
|
+
"lint": "eslint \"**/*.ts*\"",
|
|
41
|
+
"test": "bun test"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
// This file is generated automatically. Do not edit it manually.
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
(() => {
|
|
5
|
-
// src/common/common.plugins.ts
|
|
6
|
-
var createPlugin = (pluginName, {
|
|
7
|
-
pure_createActions
|
|
8
|
-
}) => ({
|
|
9
|
-
pluginName,
|
|
10
|
-
pure_createActions
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
// src/accessibility/accessibility.constants.ts
|
|
14
|
-
var WIDGET_SCRIPT_ID = "inploi-a11y";
|
|
15
|
-
|
|
16
|
-
// src/accessibility/accessibility.ts
|
|
17
|
-
var createAccessibilityPlugin = (params) => createPlugin("accessibility", {
|
|
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
|
-
};
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
// src/accessibility/accessibility.cdn.ts
|
|
72
|
-
if (typeof window.inploi !== "object") {
|
|
73
|
-
throw new Error("Please insert the SDK script tag above the plugins.");
|
|
74
|
-
}
|
|
75
|
-
window.inploi.createAccessibilityPlugin = createAccessibilityPlugin;
|
|
76
|
-
})();
|
package/cdn/plugins/journeys.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
// This file is generated automatically. Do not edit it manually.
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
(() => {
|
|
5
|
-
var __async = (__this, __arguments, generator) => {
|
|
6
|
-
return new Promise((resolve, reject) => {
|
|
7
|
-
var fulfilled = (value) => {
|
|
8
|
-
try {
|
|
9
|
-
step(generator.next(value));
|
|
10
|
-
} catch (e) {
|
|
11
|
-
reject(e);
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
var rejected = (value) => {
|
|
15
|
-
try {
|
|
16
|
-
step(generator.throw(value));
|
|
17
|
-
} catch (e) {
|
|
18
|
-
reject(e);
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
22
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
// src/common/common.plugins.ts
|
|
27
|
-
var createPlugin = (pluginName, {
|
|
28
|
-
pure_createActions
|
|
29
|
-
}) => ({
|
|
30
|
-
pluginName,
|
|
31
|
-
pure_createActions
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
// src/common/common.constants.ts
|
|
35
|
-
var SDK_VERSION = 1;
|
|
36
|
-
|
|
37
|
-
// src/journeys/journeys.constants.ts
|
|
38
|
-
var JOURNEY_PATHNAME = "/journey/log";
|
|
39
|
-
|
|
40
|
-
// src/journeys/journeys.log.ts
|
|
41
|
-
function initialiseJourneysPlugin({ apiClient, logger }) {
|
|
42
|
-
function log(params) {
|
|
43
|
-
return __async(this, null, function* () {
|
|
44
|
-
try {
|
|
45
|
-
const data = {
|
|
46
|
-
event: params.event,
|
|
47
|
-
sent_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
48
|
-
context: {
|
|
49
|
-
library: {
|
|
50
|
-
name: "inploi-sdk",
|
|
51
|
-
version: SDK_VERSION
|
|
52
|
-
},
|
|
53
|
-
page: {
|
|
54
|
-
href: location.href,
|
|
55
|
-
referrer: document.referrer,
|
|
56
|
-
title: document.title
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
properties: params.properties,
|
|
60
|
-
custom_properties: params.customProperties
|
|
61
|
-
};
|
|
62
|
-
yield apiClient.fetch(JOURNEY_PATHNAME, {
|
|
63
|
-
method: "POST",
|
|
64
|
-
body: JSON.stringify(data)
|
|
65
|
-
});
|
|
66
|
-
return { success: true, data };
|
|
67
|
-
} catch (e) {
|
|
68
|
-
logger == null ? void 0 : logger.error("Failed to send journey log to API. Inspect error response of `log` for more information.");
|
|
69
|
-
return { success: false, error: e };
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
}
|
|
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
|
-
};
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// src/journeys/journeys.ts
|
|
82
|
-
var journeysPlugin = createPlugin("journey", { pure_createActions: initialiseJourneysPlugin });
|
|
83
|
-
|
|
84
|
-
// src/journeys/journeys.cdn.ts
|
|
85
|
-
if (typeof window.inploi !== "object") {
|
|
86
|
-
throw new Error("Please insert the SDK script tag above the plugins.");
|
|
87
|
-
}
|
|
88
|
-
window.inploi.journeysPlugin = journeysPlugin;
|
|
89
|
-
})();
|
package/cdn/sdk.js
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
// This file is generated automatically. Do not edit it manually.
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
(() => {
|
|
5
|
-
var __defProp = Object.defineProperty;
|
|
6
|
-
var __defProps = Object.defineProperties;
|
|
7
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
8
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
-
var __spreadValues = (a, b) => {
|
|
13
|
-
for (var prop in b || (b = {}))
|
|
14
|
-
if (__hasOwnProp.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
if (__getOwnPropSymbols)
|
|
17
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
-
if (__propIsEnum.call(b, prop))
|
|
19
|
-
__defNormalProp(a, prop, b[prop]);
|
|
20
|
-
}
|
|
21
|
-
return a;
|
|
22
|
-
};
|
|
23
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
-
var __async = (__this, __arguments, generator) => {
|
|
25
|
-
return new Promise((resolve, reject) => {
|
|
26
|
-
var fulfilled = (value) => {
|
|
27
|
-
try {
|
|
28
|
-
step(generator.next(value));
|
|
29
|
-
} catch (e) {
|
|
30
|
-
reject(e);
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
var rejected = (value) => {
|
|
34
|
-
try {
|
|
35
|
-
step(generator.throw(value));
|
|
36
|
-
} catch (e) {
|
|
37
|
-
reject(e);
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
41
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
|
|
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)
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
// src/journeys/journeys.api.ts
|
|
56
|
-
var unauthenticatedMessage = "Unauthenticated";
|
|
57
|
-
var unauthorisedMessage = "This action is unauthorized.";
|
|
58
|
-
var createApiClient = (params) => {
|
|
59
|
-
const defaultHeaders = {
|
|
60
|
-
Accept: "application/json",
|
|
61
|
-
"Content-Type": "application/json",
|
|
62
|
-
"x-publishable-key": params.publishableKey
|
|
63
|
-
};
|
|
64
|
-
return {
|
|
65
|
-
fetch: (_0, ..._1) => __async(void 0, [_0, ..._1], function* (pathname, options = {}) {
|
|
66
|
-
const init = __spreadProps(__spreadValues({}, options), { headers: __spreadValues(__spreadValues({}, options.headers), defaultHeaders) });
|
|
67
|
-
const response = yield fetch(`${params.baseUrl}${pathname}`, init).then((res) => res.json());
|
|
68
|
-
if ("message" in response) {
|
|
69
|
-
if (response.message === unauthenticatedMessage) {
|
|
70
|
-
throw new Error("You are not authenticated.");
|
|
71
|
-
}
|
|
72
|
-
if (response.message === unauthorisedMessage) {
|
|
73
|
-
throw new Error("You are not authenticated.");
|
|
74
|
-
}
|
|
75
|
-
if ("exception" in response) {
|
|
76
|
-
throw new Error(`API error: \u201C${response.message}\u201D`);
|
|
77
|
-
}
|
|
78
|
-
if ("errors" in response) {
|
|
79
|
-
throw new Error(`API error: \u201C${response.message}\u201D`);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return response;
|
|
83
|
-
})
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
|
|
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
|
-
};
|
|
92
|
-
|
|
93
|
-
// src/sdk.ts
|
|
94
|
-
function initialiseSdk({
|
|
95
|
-
publishableKey,
|
|
96
|
-
env,
|
|
97
|
-
plugins,
|
|
98
|
-
logger = inploiBrandedLogger
|
|
99
|
-
}) {
|
|
100
|
-
const apiClient = createApiClient({ baseUrl: ENV_TO_API_URL[env], publishableKey });
|
|
101
|
-
const pluginActions = plugins.reduce(
|
|
102
|
-
(acc, plugin) => {
|
|
103
|
-
acc[plugin.pluginName] = plugin.pure_createActions({ apiClient, logger });
|
|
104
|
-
return acc;
|
|
105
|
-
},
|
|
106
|
-
{}
|
|
107
|
-
);
|
|
108
|
-
return pluginActions;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// src/sdk.cdn.ts
|
|
112
|
-
if (typeof window.inploi !== "object")
|
|
113
|
-
window.inploi = {};
|
|
114
|
-
window.inploi.initialiseSdk = initialiseSdk;
|
|
115
|
-
})();
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { P as Plugin } from '../common.plugins-2d10f2e9.js';
|
|
2
|
-
|
|
3
|
-
type AccessibeSize = 'small' | 'medium' | 'big';
|
|
4
|
-
type HorizontalPosition = 'left' | 'right';
|
|
5
|
-
type VerticalPosition = 'top' | 'center' | 'bottom';
|
|
6
|
-
type AccessibilityPluginLanguage = 'en' | 'es' | 'fr' | 'de' | 'pl' | 'it' | 'pt' | 'nl' | 'hu' | 'sl' | 'sk' | 'cs' | 'tr' | 'ja' | 'tw' | 'zh' | 'he' | 'ru' | 'ar';
|
|
7
|
-
type AccessibeParams = {
|
|
8
|
-
statementLink: string;
|
|
9
|
-
footerHtml: string;
|
|
10
|
-
hideMobile: boolean;
|
|
11
|
-
hideTrigger: boolean;
|
|
12
|
-
disableBgProcess: boolean;
|
|
13
|
-
language: AccessibilityPluginLanguage;
|
|
14
|
-
position: HorizontalPosition;
|
|
15
|
-
leadColor: string;
|
|
16
|
-
triggerColor: string;
|
|
17
|
-
triggerRadius: string;
|
|
18
|
-
triggerPositionX: HorizontalPosition;
|
|
19
|
-
triggerPositionY: VerticalPosition;
|
|
20
|
-
triggerIcon: string;
|
|
21
|
-
triggerSize: AccessibeSize;
|
|
22
|
-
triggerOffsetX: number | undefined;
|
|
23
|
-
triggerOffsetY: number | undefined;
|
|
24
|
-
mobile: {
|
|
25
|
-
triggerSize: AccessibeSize;
|
|
26
|
-
triggerPositionX: HorizontalPosition;
|
|
27
|
-
triggerPositionY: VerticalPosition;
|
|
28
|
-
triggerOffsetX: number;
|
|
29
|
-
triggerOffsetY: number;
|
|
30
|
-
triggerRadius: string;
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
declare global {
|
|
34
|
-
interface Window {
|
|
35
|
-
acsbJS: {
|
|
36
|
-
init: (params: AccessibeParams) => void;
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
type Responsive<T> = {
|
|
42
|
-
mobile: T;
|
|
43
|
-
desktop: T;
|
|
44
|
-
};
|
|
45
|
-
type AccessibilityPluginParams = {
|
|
46
|
-
language?: AccessibilityPluginLanguage;
|
|
47
|
-
colors: {
|
|
48
|
-
interface: string;
|
|
49
|
-
trigger: string;
|
|
50
|
-
};
|
|
51
|
-
showTrigger?: boolean;
|
|
52
|
-
position?: {
|
|
53
|
-
x?: Responsive<HorizontalPosition>;
|
|
54
|
-
y?: Responsive<VerticalPosition>;
|
|
55
|
-
offsetX?: Responsive<number>;
|
|
56
|
-
offsetY?: Responsive<number>;
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
declare const createAccessibilityPlugin: (params: AccessibilityPluginParams) => Plugin<"accessibility", {
|
|
60
|
-
initialise: () => void;
|
|
61
|
-
}>;
|
|
62
|
-
|
|
63
|
-
export { AccessibilityPluginParams, createAccessibilityPlugin };
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { P as Plugin } from '../common.plugins-2d10f2e9.js';
|
|
2
|
-
|
|
3
|
-
type AccessibeSize = 'small' | 'medium' | 'big';
|
|
4
|
-
type HorizontalPosition = 'left' | 'right';
|
|
5
|
-
type VerticalPosition = 'top' | 'center' | 'bottom';
|
|
6
|
-
type AccessibilityPluginLanguage = 'en' | 'es' | 'fr' | 'de' | 'pl' | 'it' | 'pt' | 'nl' | 'hu' | 'sl' | 'sk' | 'cs' | 'tr' | 'ja' | 'tw' | 'zh' | 'he' | 'ru' | 'ar';
|
|
7
|
-
type AccessibeParams = {
|
|
8
|
-
statementLink: string;
|
|
9
|
-
footerHtml: string;
|
|
10
|
-
hideMobile: boolean;
|
|
11
|
-
hideTrigger: boolean;
|
|
12
|
-
disableBgProcess: boolean;
|
|
13
|
-
language: AccessibilityPluginLanguage;
|
|
14
|
-
position: HorizontalPosition;
|
|
15
|
-
leadColor: string;
|
|
16
|
-
triggerColor: string;
|
|
17
|
-
triggerRadius: string;
|
|
18
|
-
triggerPositionX: HorizontalPosition;
|
|
19
|
-
triggerPositionY: VerticalPosition;
|
|
20
|
-
triggerIcon: string;
|
|
21
|
-
triggerSize: AccessibeSize;
|
|
22
|
-
triggerOffsetX: number | undefined;
|
|
23
|
-
triggerOffsetY: number | undefined;
|
|
24
|
-
mobile: {
|
|
25
|
-
triggerSize: AccessibeSize;
|
|
26
|
-
triggerPositionX: HorizontalPosition;
|
|
27
|
-
triggerPositionY: VerticalPosition;
|
|
28
|
-
triggerOffsetX: number;
|
|
29
|
-
triggerOffsetY: number;
|
|
30
|
-
triggerRadius: string;
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
declare global {
|
|
34
|
-
interface Window {
|
|
35
|
-
acsbJS: {
|
|
36
|
-
init: (params: AccessibeParams) => void;
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
type Responsive<T> = {
|
|
42
|
-
mobile: T;
|
|
43
|
-
desktop: T;
|
|
44
|
-
};
|
|
45
|
-
type AccessibilityPluginParams = {
|
|
46
|
-
language?: AccessibilityPluginLanguage;
|
|
47
|
-
colors: {
|
|
48
|
-
interface: string;
|
|
49
|
-
trigger: string;
|
|
50
|
-
};
|
|
51
|
-
showTrigger?: boolean;
|
|
52
|
-
position?: {
|
|
53
|
-
x?: Responsive<HorizontalPosition>;
|
|
54
|
-
y?: Responsive<VerticalPosition>;
|
|
55
|
-
offsetX?: Responsive<number>;
|
|
56
|
-
offsetY?: Responsive<number>;
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
declare const createAccessibilityPlugin: (params: AccessibilityPluginParams) => Plugin<"accessibility", {
|
|
60
|
-
initialise: () => void;
|
|
61
|
-
}>;
|
|
62
|
-
|
|
63
|
-
export { AccessibilityPluginParams, createAccessibilityPlugin };
|
|
@@ -1,2 +0,0 @@
|
|
|
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
|
-
//# sourceMappingURL=accessibility.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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
|
-
//# sourceMappingURL=accessibility.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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"]}
|
package/dist/chunk-NLLAI5ZB.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/journeys/journeys.constants.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"],"mappings":"AAEO,IAAMA,EAAiD,CAC7D,QAAS,iCACT,WAAY,wBACb,EAEaC,EAAmB","names":["ENV_TO_API_URL","JOURNEY_PATHNAME"]}
|
package/dist/chunk-WFTFPD6B.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
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
|
|
@@ -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 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"]}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
declare const CONSOLE_PREFIX = "%c[inploi SDK]";
|
|
2
|
-
declare const CONSOLE_STYLE = "color: #65BC67; font-weight: bold;";
|
|
3
|
-
type LogMessage = (...data: any[]) => void;
|
|
4
|
-
type Logger = {
|
|
5
|
-
warn: LogMessage;
|
|
6
|
-
error: LogMessage;
|
|
7
|
-
info: LogMessage;
|
|
8
|
-
log: LogMessage;
|
|
9
|
-
};
|
|
10
|
-
declare const inploiBrandedLogger: Logger;
|
|
11
|
-
declare const noLogging: Logger;
|
|
12
|
-
|
|
13
|
-
type ApiClient = {
|
|
14
|
-
fetch: (pathname: string, options?: RequestInit) => Promise<unknown>;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
type PluginParams = {
|
|
18
|
-
apiClient: ApiClient;
|
|
19
|
-
logger?: Logger;
|
|
20
|
-
};
|
|
21
|
-
type Plugin<T extends string, P extends Record<string, unknown>> = {
|
|
22
|
-
pluginName: T;
|
|
23
|
-
pure_createActions: (params: PluginParams) => P;
|
|
24
|
-
};
|
|
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
|
-
* @example const plugin = createPlugin('foo', { initialise: () => ({ bar: 'baz' }) });
|
|
30
|
-
* const sdk = initialiseSdk({plugins: [plugin]});
|
|
31
|
-
* sdk.foo.bar // 'baz'
|
|
32
|
-
*/
|
|
33
|
-
pure_createActions: (params: PluginParams) => P;
|
|
34
|
-
}) => Plugin<T, P>;
|
|
35
|
-
|
|
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,77 +0,0 @@
|
|
|
1
|
-
import { P as Plugin } from '../common.plugins-2d10f2e9.js';
|
|
2
|
-
import * as _inploi_core_common from '@inploi/core/common';
|
|
3
|
-
|
|
4
|
-
declare const journeysPlugin: Plugin<"journey", {
|
|
5
|
-
log: <T extends "VIEW_JOB" | "APPLY_START" | "APPLY_COMPLETE" | "IDENTIFY" | "SUBMIT_FORM" | "VIEW_PAGE">(params: {
|
|
6
|
-
event: T;
|
|
7
|
-
customProperties?: Record<string, unknown> | undefined;
|
|
8
|
-
} & {
|
|
9
|
-
VIEW_JOB: {
|
|
10
|
-
properties: {
|
|
11
|
-
job_id?: string | number | null | undefined;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
APPLY_START: {
|
|
15
|
-
properties: {
|
|
16
|
-
job_id?: string | number | null | undefined;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
APPLY_COMPLETE: {
|
|
20
|
-
properties: {
|
|
21
|
-
job_id?: string | number | null | undefined;
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
IDENTIFY: {
|
|
25
|
-
properties?: undefined;
|
|
26
|
-
};
|
|
27
|
-
SUBMIT_FORM: {
|
|
28
|
-
properties?: undefined;
|
|
29
|
-
};
|
|
30
|
-
VIEW_PAGE: {
|
|
31
|
-
properties?: undefined;
|
|
32
|
-
};
|
|
33
|
-
}[T]) => Promise<_inploi_core_common.ResponseObj<{
|
|
34
|
-
event: "VIEW_JOB" | "APPLY_START" | "APPLY_COMPLETE" | "IDENTIFY" | "SUBMIT_FORM" | "VIEW_PAGE";
|
|
35
|
-
sent_at: string;
|
|
36
|
-
context: {
|
|
37
|
-
library: {
|
|
38
|
-
name: "inploi-sdk";
|
|
39
|
-
version: number;
|
|
40
|
-
};
|
|
41
|
-
page: {
|
|
42
|
-
href: string;
|
|
43
|
-
referrer: string;
|
|
44
|
-
title: string;
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
properties: {
|
|
48
|
-
VIEW_JOB: {
|
|
49
|
-
properties: {
|
|
50
|
-
job_id?: string | number | null | undefined;
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
APPLY_START: {
|
|
54
|
-
properties: {
|
|
55
|
-
job_id?: string | number | null | undefined;
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
APPLY_COMPLETE: {
|
|
59
|
-
properties: {
|
|
60
|
-
job_id?: string | number | null | undefined;
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
IDENTIFY: {
|
|
64
|
-
properties?: undefined;
|
|
65
|
-
};
|
|
66
|
-
SUBMIT_FORM: {
|
|
67
|
-
properties?: undefined;
|
|
68
|
-
};
|
|
69
|
-
VIEW_PAGE: {
|
|
70
|
-
properties?: undefined;
|
|
71
|
-
};
|
|
72
|
-
}[T]["properties"];
|
|
73
|
-
custom_properties?: Record<string, unknown> | undefined;
|
|
74
|
-
}>>;
|
|
75
|
-
}>;
|
|
76
|
-
|
|
77
|
-
export { journeysPlugin };
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { P as Plugin } from '../common.plugins-2d10f2e9.js';
|
|
2
|
-
import * as _inploi_core_common from '@inploi/core/common';
|
|
3
|
-
|
|
4
|
-
declare const journeysPlugin: Plugin<"journey", {
|
|
5
|
-
log: <T extends "VIEW_JOB" | "APPLY_START" | "APPLY_COMPLETE" | "IDENTIFY" | "SUBMIT_FORM" | "VIEW_PAGE">(params: {
|
|
6
|
-
event: T;
|
|
7
|
-
customProperties?: Record<string, unknown> | undefined;
|
|
8
|
-
} & {
|
|
9
|
-
VIEW_JOB: {
|
|
10
|
-
properties: {
|
|
11
|
-
job_id?: string | number | null | undefined;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
APPLY_START: {
|
|
15
|
-
properties: {
|
|
16
|
-
job_id?: string | number | null | undefined;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
APPLY_COMPLETE: {
|
|
20
|
-
properties: {
|
|
21
|
-
job_id?: string | number | null | undefined;
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
IDENTIFY: {
|
|
25
|
-
properties?: undefined;
|
|
26
|
-
};
|
|
27
|
-
SUBMIT_FORM: {
|
|
28
|
-
properties?: undefined;
|
|
29
|
-
};
|
|
30
|
-
VIEW_PAGE: {
|
|
31
|
-
properties?: undefined;
|
|
32
|
-
};
|
|
33
|
-
}[T]) => Promise<_inploi_core_common.ResponseObj<{
|
|
34
|
-
event: "VIEW_JOB" | "APPLY_START" | "APPLY_COMPLETE" | "IDENTIFY" | "SUBMIT_FORM" | "VIEW_PAGE";
|
|
35
|
-
sent_at: string;
|
|
36
|
-
context: {
|
|
37
|
-
library: {
|
|
38
|
-
name: "inploi-sdk";
|
|
39
|
-
version: number;
|
|
40
|
-
};
|
|
41
|
-
page: {
|
|
42
|
-
href: string;
|
|
43
|
-
referrer: string;
|
|
44
|
-
title: string;
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
properties: {
|
|
48
|
-
VIEW_JOB: {
|
|
49
|
-
properties: {
|
|
50
|
-
job_id?: string | number | null | undefined;
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
APPLY_START: {
|
|
54
|
-
properties: {
|
|
55
|
-
job_id?: string | number | null | undefined;
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
APPLY_COMPLETE: {
|
|
59
|
-
properties: {
|
|
60
|
-
job_id?: string | number | null | undefined;
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
IDENTIFY: {
|
|
64
|
-
properties?: undefined;
|
|
65
|
-
};
|
|
66
|
-
SUBMIT_FORM: {
|
|
67
|
-
properties?: undefined;
|
|
68
|
-
};
|
|
69
|
-
VIEW_PAGE: {
|
|
70
|
-
properties?: undefined;
|
|
71
|
-
};
|
|
72
|
-
}[T]["properties"];
|
|
73
|
-
custom_properties?: Record<string, unknown> | undefined;
|
|
74
|
-
}>>;
|
|
75
|
-
}>;
|
|
76
|
-
|
|
77
|
-
export { journeysPlugin };
|
|
@@ -1,2 +0,0 @@
|
|
|
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
|
-
//# sourceMappingURL=journeys.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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
|
-
//# sourceMappingURL=journeys.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
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
|
-
|
|
4
|
-
/**
|
|
5
|
-
* The environment the SDK should run in.
|
|
6
|
-
* - `production`: data will be stored and displayed on dashboards
|
|
7
|
-
* - `sandbox`: data will be stored temporarily and purged periodically
|
|
8
|
-
*/
|
|
9
|
-
type AppEnvironment = 'production' | 'sandbox';
|
|
10
|
-
|
|
11
|
-
type InitialiseInploiSdkParams<P extends Plugin<any, any>> = {
|
|
12
|
-
/** Your public API key for the inploi SDK. */
|
|
13
|
-
publishableKey: string;
|
|
14
|
-
/** Add your plugins here. Try importing and passing `journeysPlugin` ;) */
|
|
15
|
-
plugins: P[];
|
|
16
|
-
/** Which app environment to run. This ultimately affects which inploi endpoints to gather data are going to be used.
|
|
17
|
-
* Anything other than `production` should be considered a development environment and the data periodicaly purged. */
|
|
18
|
-
env: AppEnvironment;
|
|
19
|
-
/** Logger object that handles logging of different levels.
|
|
20
|
-
* You can override this to use your own logger, or to disable logging altogether by importing and passing `noLogging`.
|
|
21
|
-
* @default inploiBrandedLogger
|
|
22
|
-
* */
|
|
23
|
-
logger?: Logger;
|
|
24
|
-
};
|
|
25
|
-
declare function initialiseSdk<TPlugin extends Plugin<any, any>>({ publishableKey, env, plugins, logger, }: InitialiseInploiSdkParams<TPlugin>): { [K in TPlugin["pluginName"]]: ReturnType<(TPlugin & {
|
|
26
|
-
pluginName: K;
|
|
27
|
-
} extends infer T ? { [k in keyof T]: (TPlugin & {
|
|
28
|
-
pluginName: K;
|
|
29
|
-
})[k]; } : never)["pure_createActions"]>; };
|
|
30
|
-
|
|
31
|
-
export { InitialiseInploiSdkParams, Logger, Plugin, initialiseSdk };
|
package/dist/sdk.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
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
|
-
|
|
4
|
-
/**
|
|
5
|
-
* The environment the SDK should run in.
|
|
6
|
-
* - `production`: data will be stored and displayed on dashboards
|
|
7
|
-
* - `sandbox`: data will be stored temporarily and purged periodically
|
|
8
|
-
*/
|
|
9
|
-
type AppEnvironment = 'production' | 'sandbox';
|
|
10
|
-
|
|
11
|
-
type InitialiseInploiSdkParams<P extends Plugin<any, any>> = {
|
|
12
|
-
/** Your public API key for the inploi SDK. */
|
|
13
|
-
publishableKey: string;
|
|
14
|
-
/** Add your plugins here. Try importing and passing `journeysPlugin` ;) */
|
|
15
|
-
plugins: P[];
|
|
16
|
-
/** Which app environment to run. This ultimately affects which inploi endpoints to gather data are going to be used.
|
|
17
|
-
* Anything other than `production` should be considered a development environment and the data periodicaly purged. */
|
|
18
|
-
env: AppEnvironment;
|
|
19
|
-
/** Logger object that handles logging of different levels.
|
|
20
|
-
* You can override this to use your own logger, or to disable logging altogether by importing and passing `noLogging`.
|
|
21
|
-
* @default inploiBrandedLogger
|
|
22
|
-
* */
|
|
23
|
-
logger?: Logger;
|
|
24
|
-
};
|
|
25
|
-
declare function initialiseSdk<TPlugin extends Plugin<any, any>>({ publishableKey, env, plugins, logger, }: InitialiseInploiSdkParams<TPlugin>): { [K in TPlugin["pluginName"]]: ReturnType<(TPlugin & {
|
|
26
|
-
pluginName: K;
|
|
27
|
-
} extends infer T ? { [k in keyof T]: (TPlugin & {
|
|
28
|
-
pluginName: K;
|
|
29
|
-
})[k]; } : never)["pure_createActions"]>; };
|
|
30
|
-
|
|
31
|
-
export { InitialiseInploiSdkParams, Logger, Plugin, initialiseSdk };
|
package/dist/sdk.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
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
|
-
//# sourceMappingURL=sdk.js.map
|
package/dist/sdk.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
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
|
-
//# sourceMappingURL=sdk.mjs.map
|
package/dist/sdk.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"]}
|