@twilltac/compliance-sdk 0.1.10 → 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 +19 -12
- package/build-revision.txt +1 -1
- package/index.cjs +20 -13
- package/index.js +20 -13
- 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/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
|
|
|
@@ -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,10 +79,12 @@ 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
|
-
opts.postMessageBus.on("navigation:start", () => opts.iframeElement.style.minHeight = "");
|
|
78
88
|
opts.postMessageBus.on("journey:started", () => this._events.emit("flow.journey.started"));
|
|
79
89
|
opts.postMessageBus.on("journey.section:started", (data) => this._events.emit("flow.journey.section:started", data));
|
|
80
90
|
opts.postMessageBus.on("journey.section:completed", (data) => this._events.emit("flow.journey.section:completed", data));
|
|
@@ -106,14 +116,6 @@ var CompliancePlugin = class {
|
|
|
106
116
|
}
|
|
107
117
|
};
|
|
108
118
|
|
|
109
|
-
// libs/twilltac/plugins/compliance/types/src/lib/compliance-plugin-initialisation.data.ts
|
|
110
|
-
var CompliancePluginFlow = /* @__PURE__ */ ((CompliancePluginFlow2) => {
|
|
111
|
-
CompliancePluginFlow2["JOURNEY"] = "journey";
|
|
112
|
-
CompliancePluginFlow2["HANDOVER"] = "handover";
|
|
113
|
-
CompliancePluginFlow2["DOCUMENTS"] = "documents";
|
|
114
|
-
return CompliancePluginFlow2;
|
|
115
|
-
})(CompliancePluginFlow || {});
|
|
116
|
-
|
|
117
119
|
// libs/twilltac/plugins/utils/post-messenger/src/lib/post-message.bus.ts
|
|
118
120
|
var PostMessageBus = class {
|
|
119
121
|
_channel;
|
|
@@ -290,17 +292,21 @@ function validateOptions(options) {
|
|
|
290
292
|
}
|
|
291
293
|
function createCompliancePlugin(options) {
|
|
292
294
|
validateOptions(options);
|
|
295
|
+
const sizing = options.data.sizing ?? "content" /* CONTENT */;
|
|
296
|
+
const resolvedData = { ...options.data, sizing };
|
|
293
297
|
const production = !window.location.hostname.endsWith(".ngserve");
|
|
294
298
|
const baseUrl = "https://compliance.plugins.twilltac.app";
|
|
295
299
|
const url = production ? baseUrl : `${baseUrl}.ngserve`;
|
|
296
300
|
const iframe = document.createElement("iframe");
|
|
297
301
|
iframe.name = "compliance-plugin-iframe";
|
|
298
|
-
iframe.setAttribute("scrolling", "no");
|
|
299
302
|
iframe.style.width = "100%";
|
|
300
303
|
iframe.style.height = "100%";
|
|
301
304
|
iframe.style.border = "none";
|
|
302
305
|
iframe.style.overflow = "hidden";
|
|
303
306
|
iframe.style.visibility = "hidden";
|
|
307
|
+
if (sizing === "content" /* CONTENT */) {
|
|
308
|
+
iframe.setAttribute("scrolling", "no");
|
|
309
|
+
}
|
|
304
310
|
const form = document.createElement("form");
|
|
305
311
|
form.method = "POST";
|
|
306
312
|
form.action = `${url}/en-gb`;
|
|
@@ -309,7 +315,7 @@ function createCompliancePlugin(options) {
|
|
|
309
315
|
const input = document.createElement("input");
|
|
310
316
|
input.type = "hidden";
|
|
311
317
|
input.name = "data";
|
|
312
|
-
input.value = JSON.stringify(
|
|
318
|
+
input.value = JSON.stringify(resolvedData);
|
|
313
319
|
form.appendChild(input);
|
|
314
320
|
options.containerElement.innerHTML = "";
|
|
315
321
|
options.containerElement.appendChild(iframe);
|
|
@@ -320,6 +326,7 @@ function createCompliancePlugin(options) {
|
|
|
320
326
|
resolve(
|
|
321
327
|
new CompliancePlugin({
|
|
322
328
|
initialisationData: data,
|
|
329
|
+
initialisationOptions: resolvedData,
|
|
323
330
|
postMessageBus,
|
|
324
331
|
iframeElement: iframe
|
|
325
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,10 +53,12 @@ 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
|
-
opts.postMessageBus.on("navigation:start", () => opts.iframeElement.style.minHeight = "");
|
|
52
62
|
opts.postMessageBus.on("journey:started", () => this._events.emit("flow.journey.started"));
|
|
53
63
|
opts.postMessageBus.on("journey.section:started", (data) => this._events.emit("flow.journey.section:started", data));
|
|
54
64
|
opts.postMessageBus.on("journey.section:completed", (data) => this._events.emit("flow.journey.section:completed", data));
|
|
@@ -80,14 +90,6 @@ var CompliancePlugin = class {
|
|
|
80
90
|
}
|
|
81
91
|
};
|
|
82
92
|
|
|
83
|
-
// libs/twilltac/plugins/compliance/types/src/lib/compliance-plugin-initialisation.data.ts
|
|
84
|
-
var CompliancePluginFlow = /* @__PURE__ */ ((CompliancePluginFlow2) => {
|
|
85
|
-
CompliancePluginFlow2["JOURNEY"] = "journey";
|
|
86
|
-
CompliancePluginFlow2["HANDOVER"] = "handover";
|
|
87
|
-
CompliancePluginFlow2["DOCUMENTS"] = "documents";
|
|
88
|
-
return CompliancePluginFlow2;
|
|
89
|
-
})(CompliancePluginFlow || {});
|
|
90
|
-
|
|
91
93
|
// libs/twilltac/plugins/utils/post-messenger/src/lib/post-message.bus.ts
|
|
92
94
|
var PostMessageBus = class {
|
|
93
95
|
_channel;
|
|
@@ -264,17 +266,21 @@ function validateOptions(options) {
|
|
|
264
266
|
}
|
|
265
267
|
function createCompliancePlugin(options) {
|
|
266
268
|
validateOptions(options);
|
|
269
|
+
const sizing = options.data.sizing ?? "content" /* CONTENT */;
|
|
270
|
+
const resolvedData = { ...options.data, sizing };
|
|
267
271
|
const production = !window.location.hostname.endsWith(".ngserve");
|
|
268
272
|
const baseUrl = "https://compliance.plugins.twilltac.app";
|
|
269
273
|
const url = production ? baseUrl : `${baseUrl}.ngserve`;
|
|
270
274
|
const iframe = document.createElement("iframe");
|
|
271
275
|
iframe.name = "compliance-plugin-iframe";
|
|
272
|
-
iframe.setAttribute("scrolling", "no");
|
|
273
276
|
iframe.style.width = "100%";
|
|
274
277
|
iframe.style.height = "100%";
|
|
275
278
|
iframe.style.border = "none";
|
|
276
279
|
iframe.style.overflow = "hidden";
|
|
277
280
|
iframe.style.visibility = "hidden";
|
|
281
|
+
if (sizing === "content" /* CONTENT */) {
|
|
282
|
+
iframe.setAttribute("scrolling", "no");
|
|
283
|
+
}
|
|
278
284
|
const form = document.createElement("form");
|
|
279
285
|
form.method = "POST";
|
|
280
286
|
form.action = `${url}/en-gb`;
|
|
@@ -283,7 +289,7 @@ function createCompliancePlugin(options) {
|
|
|
283
289
|
const input = document.createElement("input");
|
|
284
290
|
input.type = "hidden";
|
|
285
291
|
input.name = "data";
|
|
286
|
-
input.value = JSON.stringify(
|
|
292
|
+
input.value = JSON.stringify(resolvedData);
|
|
287
293
|
form.appendChild(input);
|
|
288
294
|
options.containerElement.innerHTML = "";
|
|
289
295
|
options.containerElement.appendChild(iframe);
|
|
@@ -294,6 +300,7 @@ function createCompliancePlugin(options) {
|
|
|
294
300
|
resolve(
|
|
295
301
|
new CompliancePlugin({
|
|
296
302
|
initialisationData: data,
|
|
303
|
+
initialisationOptions: resolvedData,
|
|
297
304
|
postMessageBus,
|
|
298
305
|
iframeElement: iframe
|
|
299
306
|
})
|
|
@@ -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
|
}
|