@twilltac/compliance-sdk 0.1.9 → 0.1.11
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 +20 -13
- package/build-revision.txt +1 -1
- package/index.cjs +20 -12
- package/index.js +20 -12
- package/libs/twilltac/plugins/compliance/sdk/src/lib/compliance-plugin.events.d.ts +1 -1
- package/libs/twilltac/plugins/compliance/sdk/src/lib/compliance.plugin.d.ts +2 -1
- package/libs/twilltac/plugins/compliance/sdk/src/lib/create-compliance.plugin.d.ts +5 -3
- package/libs/twilltac/plugins/compliance/types/src/lib/compliance-plugin-initialisation.data.d.ts +5 -0
- package/libs/twilltac/plugins/compliance/types/src/lib/compliance-plugin-post.messages.d.ts +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,7 +21,8 @@ const plugin = await createCompliancePlugin({
|
|
|
21
21
|
workspace: 'YOUR_WORKSPACE_KEY',
|
|
22
22
|
flow: 'journey',
|
|
23
23
|
customerReference: 'YOUR_CUSTOMER_REFERENCE',
|
|
24
|
-
authToken: 'YOUR_AUTH_TOKEN'
|
|
24
|
+
authToken: 'YOUR_AUTH_TOKEN',
|
|
25
|
+
sizing: 'content'
|
|
25
26
|
}
|
|
26
27
|
}).catch((error) => {
|
|
27
28
|
console.error('The plugin failed to load', error);
|
|
@@ -36,13 +37,14 @@ Creates and initialises the compliance plugin within a container element.
|
|
|
36
37
|
|
|
37
38
|
**Parameters:**
|
|
38
39
|
|
|
39
|
-
| Name | Type | Description
|
|
40
|
-
| -------------------------------- | ------------- |
|
|
41
|
-
| `options.containerElement` | `HTMLElement` | The DOM element where the plugin will be rendered
|
|
42
|
-
| `options.data.
|
|
43
|
-
| `options.data.
|
|
44
|
-
| `options.data.
|
|
45
|
-
| `options.data.
|
|
40
|
+
| Name | Type | Required | Description |
|
|
41
|
+
| -------------------------------- | ------------- | -------- | ------------------------------------------------------------------------------------------------------------------- |
|
|
42
|
+
| `options.containerElement` | `HTMLElement` | Yes | The DOM element where the plugin will be rendered |
|
|
43
|
+
| `options.data.customerReference` | `string` | Yes | Reference identifier for the customer |
|
|
44
|
+
| `options.data.workspace` | `string` | Yes | Your Twilltac workspace identifier |
|
|
45
|
+
| `options.data.authToken` | `string` | Yes | Authentication token for the plugin session |
|
|
46
|
+
| `options.data.flow` | `string` | Yes | The plugin flow to load. One of `journey`, `handover`, or `documents` |
|
|
47
|
+
| `options.data.sizing` | `string` | No | `'content'` (default) — plugin element grows to fit content. <br/>`'container'` — plugin fills its container height |
|
|
46
48
|
|
|
47
49
|
**Returns:** `Promise<CompliancePlugin>`
|
|
48
50
|
|
|
@@ -94,7 +96,7 @@ plugin.on('session:expired', () => {
|
|
|
94
96
|
| ----- | ---- | ----------- |
|
|
95
97
|
| `flow.journey.started` | `void` | Emits when the user starts the journey and IDD document is generated. |
|
|
96
98
|
| `flow.journey.section:started` | `SectionStartedEvent` | Emits when the user starts a section. |
|
|
97
|
-
| `flow.journey.section:completed` | `SectionEndedEvent` | Emits when the user
|
|
99
|
+
| `flow.journey.section:completed` | `SectionEndedEvent` | Emits when the user completes the question set and submits their recommendations. |
|
|
98
100
|
| `flow.documents:list` | `ComplianceDocument[]` | Emits when the user completes the journey and recommendations are produced. |
|
|
99
101
|
| `session:expired` | `void` | Emits when the session has expired. This would typically trigger your auth flow followed by re-initialising the plugin. |
|
|
100
102
|
|
|
@@ -144,6 +146,7 @@ export class ComplianceComponent {
|
|
|
144
146
|
readonly flow = input.required<string>();
|
|
145
147
|
readonly customerReference = input.required<string>();
|
|
146
148
|
readonly authToken = input.required<string>();
|
|
149
|
+
readonly sizing = input<'content' | 'container'>('content');
|
|
147
150
|
|
|
148
151
|
private readonly _container = viewChild.required<ElementRef<HTMLDivElement>>('container');
|
|
149
152
|
|
|
@@ -163,7 +166,8 @@ export class ComplianceComponent {
|
|
|
163
166
|
workspace: this.workspace(),
|
|
164
167
|
flow: this.flow(),
|
|
165
168
|
customerReference: this.customerReference(),
|
|
166
|
-
authToken: this.authToken()
|
|
169
|
+
authToken: this.authToken(),
|
|
170
|
+
sizing: this.sizing()
|
|
167
171
|
}
|
|
168
172
|
})
|
|
169
173
|
);
|
|
@@ -197,6 +201,7 @@ export class ComplianceComponent {
|
|
|
197
201
|
readonly flow = input.required<string>();
|
|
198
202
|
readonly customerReference = input.required<string>();
|
|
199
203
|
readonly authToken = input.required<string>();
|
|
204
|
+
readonly sizing = input<'content' | 'container'>('content');
|
|
200
205
|
|
|
201
206
|
private readonly _container = viewChild.required<ElementRef<HTMLDivElement>>('container');
|
|
202
207
|
|
|
@@ -219,7 +224,8 @@ export class ComplianceComponent {
|
|
|
219
224
|
workspace: this.workspace(),
|
|
220
225
|
flow: this.flow(),
|
|
221
226
|
customerReference: this.customerReference(),
|
|
222
|
-
authToken: this.authToken()
|
|
227
|
+
authToken: this.authToken(),
|
|
228
|
+
sizing: this.sizing()
|
|
223
229
|
}
|
|
224
230
|
});
|
|
225
231
|
} catch (error) {
|
|
@@ -240,9 +246,10 @@ interface ComplianceWidgetProps {
|
|
|
240
246
|
flow: 'journey' | 'handover' | 'documents';
|
|
241
247
|
customerReference: string;
|
|
242
248
|
authToken: string;
|
|
249
|
+
sizing?: 'content' | 'container';
|
|
243
250
|
}
|
|
244
251
|
|
|
245
|
-
function ComplianceWidget({ workspace, flow, customerReference, authToken }: ComplianceWidgetProps) {
|
|
252
|
+
function ComplianceWidget({ workspace, flow, customerReference, authToken, sizing }: ComplianceWidgetProps) {
|
|
246
253
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
247
254
|
const pluginRef = useRef<CompliancePlugin | null>(null);
|
|
248
255
|
|
|
@@ -254,7 +261,7 @@ function ComplianceWidget({ workspace, flow, customerReference, authToken }: Com
|
|
|
254
261
|
|
|
255
262
|
createCompliancePlugin({
|
|
256
263
|
containerElement: containerRef.current,
|
|
257
|
-
data: { workspace, flow, customerReference, authToken }
|
|
264
|
+
data: { workspace, flow, customerReference, authToken, sizing }
|
|
258
265
|
})
|
|
259
266
|
.then((plugin) => {
|
|
260
267
|
pluginRef.current = plugin;
|
package/build-revision.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
23739221278-1
|
package/index.cjs
CHANGED
|
@@ -26,6 +26,14 @@ __export(index_exports, {
|
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(index_exports);
|
|
28
28
|
|
|
29
|
+
// libs/twilltac/plugins/compliance/types/src/lib/compliance-plugin-initialisation.data.ts
|
|
30
|
+
var CompliancePluginFlow = /* @__PURE__ */ ((CompliancePluginFlow2) => {
|
|
31
|
+
CompliancePluginFlow2["JOURNEY"] = "journey";
|
|
32
|
+
CompliancePluginFlow2["HANDOVER"] = "handover";
|
|
33
|
+
CompliancePluginFlow2["DOCUMENTS"] = "documents";
|
|
34
|
+
return CompliancePluginFlow2;
|
|
35
|
+
})(CompliancePluginFlow || {});
|
|
36
|
+
|
|
29
37
|
// libs/twilltac/plugins/utils/typed-event-emitter/src/lib/typed-event-emitter.ts
|
|
30
38
|
var TypedEventEmitter = class {
|
|
31
39
|
_handlers = /* @__PURE__ */ new Map();
|
|
@@ -71,8 +79,11 @@ var CompliancePlugin = class {
|
|
|
71
79
|
constructor(opts) {
|
|
72
80
|
this._postMessageBus = opts.postMessageBus;
|
|
73
81
|
opts.iframeElement.style.visibility = "visible";
|
|
74
|
-
opts.
|
|
75
|
-
|
|
82
|
+
if (opts.initialisationOptions.sizing === "content" /* CONTENT */) {
|
|
83
|
+
opts.iframeElement.style.minHeight = `${opts.initialisationData.documentHeight}px`;
|
|
84
|
+
opts.postMessageBus.on("window:resize", (data) => opts.iframeElement.style.minHeight = `${data.height}px`);
|
|
85
|
+
opts.postMessageBus.on("navigation:start", () => opts.iframeElement.style.minHeight = "");
|
|
86
|
+
}
|
|
76
87
|
opts.postMessageBus.on("session:expired-token", () => this._events.emit("session:expired"));
|
|
77
88
|
opts.postMessageBus.on("journey:started", () => this._events.emit("flow.journey.started"));
|
|
78
89
|
opts.postMessageBus.on("journey.section:started", (data) => this._events.emit("flow.journey.section:started", data));
|
|
@@ -105,14 +116,6 @@ var CompliancePlugin = class {
|
|
|
105
116
|
}
|
|
106
117
|
};
|
|
107
118
|
|
|
108
|
-
// libs/twilltac/plugins/compliance/types/src/lib/compliance-plugin-initialisation.data.ts
|
|
109
|
-
var CompliancePluginFlow = /* @__PURE__ */ ((CompliancePluginFlow2) => {
|
|
110
|
-
CompliancePluginFlow2["JOURNEY"] = "journey";
|
|
111
|
-
CompliancePluginFlow2["HANDOVER"] = "handover";
|
|
112
|
-
CompliancePluginFlow2["DOCUMENTS"] = "documents";
|
|
113
|
-
return CompliancePluginFlow2;
|
|
114
|
-
})(CompliancePluginFlow || {});
|
|
115
|
-
|
|
116
119
|
// libs/twilltac/plugins/utils/post-messenger/src/lib/post-message.bus.ts
|
|
117
120
|
var PostMessageBus = class {
|
|
118
121
|
_channel;
|
|
@@ -289,17 +292,21 @@ function validateOptions(options) {
|
|
|
289
292
|
}
|
|
290
293
|
function createCompliancePlugin(options) {
|
|
291
294
|
validateOptions(options);
|
|
295
|
+
const sizing = options.data.sizing ?? "content" /* CONTENT */;
|
|
296
|
+
const resolvedData = { ...options.data, sizing };
|
|
292
297
|
const production = !window.location.hostname.endsWith(".ngserve");
|
|
293
298
|
const baseUrl = "https://compliance.plugins.twilltac.app";
|
|
294
299
|
const url = production ? baseUrl : `${baseUrl}.ngserve`;
|
|
295
300
|
const iframe = document.createElement("iframe");
|
|
296
301
|
iframe.name = "compliance-plugin-iframe";
|
|
297
|
-
iframe.setAttribute("scrolling", "no");
|
|
298
302
|
iframe.style.width = "100%";
|
|
299
303
|
iframe.style.height = "100%";
|
|
300
304
|
iframe.style.border = "none";
|
|
301
305
|
iframe.style.overflow = "hidden";
|
|
302
306
|
iframe.style.visibility = "hidden";
|
|
307
|
+
if (sizing === "content" /* CONTENT */) {
|
|
308
|
+
iframe.setAttribute("scrolling", "no");
|
|
309
|
+
}
|
|
303
310
|
const form = document.createElement("form");
|
|
304
311
|
form.method = "POST";
|
|
305
312
|
form.action = `${url}/en-gb`;
|
|
@@ -308,7 +315,7 @@ function createCompliancePlugin(options) {
|
|
|
308
315
|
const input = document.createElement("input");
|
|
309
316
|
input.type = "hidden";
|
|
310
317
|
input.name = "data";
|
|
311
|
-
input.value = JSON.stringify(
|
|
318
|
+
input.value = JSON.stringify(resolvedData);
|
|
312
319
|
form.appendChild(input);
|
|
313
320
|
options.containerElement.innerHTML = "";
|
|
314
321
|
options.containerElement.appendChild(iframe);
|
|
@@ -319,6 +326,7 @@ function createCompliancePlugin(options) {
|
|
|
319
326
|
resolve(
|
|
320
327
|
new CompliancePlugin({
|
|
321
328
|
initialisationData: data,
|
|
329
|
+
initialisationOptions: resolvedData,
|
|
322
330
|
postMessageBus,
|
|
323
331
|
iframeElement: iframe
|
|
324
332
|
})
|
package/index.js
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
+
// libs/twilltac/plugins/compliance/types/src/lib/compliance-plugin-initialisation.data.ts
|
|
4
|
+
var CompliancePluginFlow = /* @__PURE__ */ ((CompliancePluginFlow2) => {
|
|
5
|
+
CompliancePluginFlow2["JOURNEY"] = "journey";
|
|
6
|
+
CompliancePluginFlow2["HANDOVER"] = "handover";
|
|
7
|
+
CompliancePluginFlow2["DOCUMENTS"] = "documents";
|
|
8
|
+
return CompliancePluginFlow2;
|
|
9
|
+
})(CompliancePluginFlow || {});
|
|
10
|
+
|
|
3
11
|
// libs/twilltac/plugins/utils/typed-event-emitter/src/lib/typed-event-emitter.ts
|
|
4
12
|
var TypedEventEmitter = class {
|
|
5
13
|
_handlers = /* @__PURE__ */ new Map();
|
|
@@ -45,8 +53,11 @@ var CompliancePlugin = class {
|
|
|
45
53
|
constructor(opts) {
|
|
46
54
|
this._postMessageBus = opts.postMessageBus;
|
|
47
55
|
opts.iframeElement.style.visibility = "visible";
|
|
48
|
-
opts.
|
|
49
|
-
|
|
56
|
+
if (opts.initialisationOptions.sizing === "content" /* CONTENT */) {
|
|
57
|
+
opts.iframeElement.style.minHeight = `${opts.initialisationData.documentHeight}px`;
|
|
58
|
+
opts.postMessageBus.on("window:resize", (data) => opts.iframeElement.style.minHeight = `${data.height}px`);
|
|
59
|
+
opts.postMessageBus.on("navigation:start", () => opts.iframeElement.style.minHeight = "");
|
|
60
|
+
}
|
|
50
61
|
opts.postMessageBus.on("session:expired-token", () => this._events.emit("session:expired"));
|
|
51
62
|
opts.postMessageBus.on("journey:started", () => this._events.emit("flow.journey.started"));
|
|
52
63
|
opts.postMessageBus.on("journey.section:started", (data) => this._events.emit("flow.journey.section:started", data));
|
|
@@ -79,14 +90,6 @@ var CompliancePlugin = class {
|
|
|
79
90
|
}
|
|
80
91
|
};
|
|
81
92
|
|
|
82
|
-
// libs/twilltac/plugins/compliance/types/src/lib/compliance-plugin-initialisation.data.ts
|
|
83
|
-
var CompliancePluginFlow = /* @__PURE__ */ ((CompliancePluginFlow2) => {
|
|
84
|
-
CompliancePluginFlow2["JOURNEY"] = "journey";
|
|
85
|
-
CompliancePluginFlow2["HANDOVER"] = "handover";
|
|
86
|
-
CompliancePluginFlow2["DOCUMENTS"] = "documents";
|
|
87
|
-
return CompliancePluginFlow2;
|
|
88
|
-
})(CompliancePluginFlow || {});
|
|
89
|
-
|
|
90
93
|
// libs/twilltac/plugins/utils/post-messenger/src/lib/post-message.bus.ts
|
|
91
94
|
var PostMessageBus = class {
|
|
92
95
|
_channel;
|
|
@@ -263,17 +266,21 @@ function validateOptions(options) {
|
|
|
263
266
|
}
|
|
264
267
|
function createCompliancePlugin(options) {
|
|
265
268
|
validateOptions(options);
|
|
269
|
+
const sizing = options.data.sizing ?? "content" /* CONTENT */;
|
|
270
|
+
const resolvedData = { ...options.data, sizing };
|
|
266
271
|
const production = !window.location.hostname.endsWith(".ngserve");
|
|
267
272
|
const baseUrl = "https://compliance.plugins.twilltac.app";
|
|
268
273
|
const url = production ? baseUrl : `${baseUrl}.ngserve`;
|
|
269
274
|
const iframe = document.createElement("iframe");
|
|
270
275
|
iframe.name = "compliance-plugin-iframe";
|
|
271
|
-
iframe.setAttribute("scrolling", "no");
|
|
272
276
|
iframe.style.width = "100%";
|
|
273
277
|
iframe.style.height = "100%";
|
|
274
278
|
iframe.style.border = "none";
|
|
275
279
|
iframe.style.overflow = "hidden";
|
|
276
280
|
iframe.style.visibility = "hidden";
|
|
281
|
+
if (sizing === "content" /* CONTENT */) {
|
|
282
|
+
iframe.setAttribute("scrolling", "no");
|
|
283
|
+
}
|
|
277
284
|
const form = document.createElement("form");
|
|
278
285
|
form.method = "POST";
|
|
279
286
|
form.action = `${url}/en-gb`;
|
|
@@ -282,7 +289,7 @@ function createCompliancePlugin(options) {
|
|
|
282
289
|
const input = document.createElement("input");
|
|
283
290
|
input.type = "hidden";
|
|
284
291
|
input.name = "data";
|
|
285
|
-
input.value = JSON.stringify(
|
|
292
|
+
input.value = JSON.stringify(resolvedData);
|
|
286
293
|
form.appendChild(input);
|
|
287
294
|
options.containerElement.innerHTML = "";
|
|
288
295
|
options.containerElement.appendChild(iframe);
|
|
@@ -293,6 +300,7 @@ function createCompliancePlugin(options) {
|
|
|
293
300
|
resolve(
|
|
294
301
|
new CompliancePlugin({
|
|
295
302
|
initialisationData: data,
|
|
303
|
+
initialisationOptions: resolvedData,
|
|
296
304
|
postMessageBus,
|
|
297
305
|
iframeElement: iframe
|
|
298
306
|
})
|
|
@@ -22,7 +22,7 @@ export interface CompliancePluginEvents {
|
|
|
22
22
|
['flow.journey.started']: void;
|
|
23
23
|
/** Emits when the user starts a section. */
|
|
24
24
|
['flow.journey.section:started']: SectionStartedEvent;
|
|
25
|
-
/** Emits when the user
|
|
25
|
+
/** Emits when the user completes the question set and submits their recommendations. */
|
|
26
26
|
['flow.journey.section:completed']: SectionEndedEvent;
|
|
27
27
|
/** Emits when the user completes the journey and recommendations are produced. */
|
|
28
28
|
['flow.documents:list']: ComplianceDocument[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CompliancePluginPostMessages, InitialisationData } from '@twilltac/compliance-plugin-types';
|
|
1
|
+
import { CompliancePluginInitialisationData, CompliancePluginPostMessages, InitialisationData } from '@twilltac/compliance-plugin-types';
|
|
2
2
|
import { EventHandler, ExtractEventData } from '@twilltac/plugin-skd-event-emitter';
|
|
3
3
|
import { PostMessageBus } from '@twilltac/plugin-skd-post-messenger';
|
|
4
4
|
import { CompliancePluginEvents } from './compliance-plugin.events';
|
|
@@ -6,6 +6,7 @@ type WildcardHandler = (event: keyof CompliancePluginEvents & string, data: Extr
|
|
|
6
6
|
interface CompliancePluginData {
|
|
7
7
|
postMessageBus: PostMessageBus<CompliancePluginPostMessages>;
|
|
8
8
|
initialisationData: InitialisationData;
|
|
9
|
+
initialisationOptions: CompliancePluginInitialisationData;
|
|
9
10
|
iframeElement: HTMLIFrameElement;
|
|
10
11
|
}
|
|
11
12
|
export declare class CompliancePlugin {
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { CompliancePluginInitialisationData } from '@twilltac/compliance-plugin-types';
|
|
1
|
+
import { CompliancePluginInitialisationData, CompliancePluginSizing } from '@twilltac/compliance-plugin-types';
|
|
2
2
|
import { CompliancePlugin } from './compliance.plugin';
|
|
3
3
|
interface InitialisationOptions {
|
|
4
|
-
containerElement: HTMLElement;
|
|
5
|
-
data: CompliancePluginInitialisationData
|
|
4
|
+
readonly containerElement: HTMLElement;
|
|
5
|
+
readonly data: Omit<CompliancePluginInitialisationData, 'sizing'> & {
|
|
6
|
+
readonly sizing?: CompliancePluginSizing;
|
|
7
|
+
};
|
|
6
8
|
}
|
|
7
9
|
export declare function createCompliancePlugin(options: InitialisationOptions): Promise<CompliancePlugin>;
|
|
8
10
|
export {};
|
package/libs/twilltac/plugins/compliance/types/src/lib/compliance-plugin-initialisation.data.d.ts
CHANGED
|
@@ -3,9 +3,14 @@ export declare enum CompliancePluginFlow {
|
|
|
3
3
|
HANDOVER = "handover",
|
|
4
4
|
DOCUMENTS = "documents"
|
|
5
5
|
}
|
|
6
|
+
export declare enum CompliancePluginSizing {
|
|
7
|
+
CONTAINER = "container",
|
|
8
|
+
CONTENT = "content"
|
|
9
|
+
}
|
|
6
10
|
export interface CompliancePluginInitialisationData {
|
|
7
11
|
readonly workspace: string;
|
|
8
12
|
readonly flow: CompliancePluginFlow;
|
|
9
13
|
readonly customerReference: string;
|
|
10
14
|
readonly authToken: string;
|
|
15
|
+
readonly sizing: CompliancePluginSizing;
|
|
11
16
|
}
|