@twilltac/compliance-sdk 0.1.11 → 0.2.1
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 +13 -5
- package/build-revision.txt +1 -1
- package/index.cjs +5 -0
- package/index.js +5 -0
- package/libs/twilltac/plugins/compliance/sdk/src/lib/compliance-plugin.events.d.ts +4 -2
- package/libs/twilltac/plugins/compliance/types/src/lib/compliance-plugin-initialisation.data.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,6 +21,7 @@ const plugin = await createCompliancePlugin({
|
|
|
21
21
|
workspace: 'YOUR_WORKSPACE_KEY',
|
|
22
22
|
flow: 'journey',
|
|
23
23
|
customerReference: 'YOUR_CUSTOMER_REFERENCE',
|
|
24
|
+
offerReference: 'YOUR_OFFER_REFERENCE',
|
|
24
25
|
authToken: 'YOUR_AUTH_TOKEN',
|
|
25
26
|
sizing: 'content'
|
|
26
27
|
}
|
|
@@ -41,6 +42,7 @@ Creates and initialises the compliance plugin within a container element.
|
|
|
41
42
|
| -------------------------------- | ------------- | -------- | ------------------------------------------------------------------------------------------------------------------- |
|
|
42
43
|
| `options.containerElement` | `HTMLElement` | Yes | The DOM element where the plugin will be rendered |
|
|
43
44
|
| `options.data.customerReference` | `string` | Yes | Reference identifier for the customer |
|
|
45
|
+
| `options.data.offerReference` | `string` | Yes | Reference identifier for the compliance customer offer |
|
|
44
46
|
| `options.data.workspace` | `string` | Yes | Your Twilltac workspace identifier |
|
|
45
47
|
| `options.data.authToken` | `string` | Yes | Authentication token for the plugin session |
|
|
46
48
|
| `options.data.flow` | `string` | Yes | The plugin flow to load. One of `journey`, `handover`, or `documents` |
|
|
@@ -94,10 +96,11 @@ plugin.on('session:expired', () => {
|
|
|
94
96
|
<!-- EVENTS_TABLE_START -->
|
|
95
97
|
| Event | Data | Description |
|
|
96
98
|
| ----- | ---- | ----------- |
|
|
97
|
-
| `flow.journey.started` | `void` | Emits when the user starts the journey and
|
|
99
|
+
| `flow.journey.started` | `void` | Emits when the user starts the journey and Initial Disclosure Document is generated. |
|
|
98
100
|
| `flow.journey.section:started` | `SectionStartedEvent` | Emits when the user starts a section. |
|
|
99
101
|
| `flow.journey.section:completed` | `SectionEndedEvent` | Emits when the user completes the question set and submits their recommendations. |
|
|
100
|
-
| `flow.
|
|
102
|
+
| `flow.journey:completed` | `void` | Emits when the user completes the journey and summary page is presented. |
|
|
103
|
+
| `flow.documents:list` | `ComplianceDocument[]` | Emits when with a list of available documents. |
|
|
101
104
|
| `session:expired` | `void` | Emits when the session has expired. This would typically trigger your auth flow followed by re-initialising the plugin. |
|
|
102
105
|
|
|
103
106
|
#### Type Definitions
|
|
@@ -145,6 +148,7 @@ export class ComplianceComponent {
|
|
|
145
148
|
readonly workspace = input.required<string>();
|
|
146
149
|
readonly flow = input.required<string>();
|
|
147
150
|
readonly customerReference = input.required<string>();
|
|
151
|
+
readonly offerReference = input.required<string>();
|
|
148
152
|
readonly authToken = input.required<string>();
|
|
149
153
|
readonly sizing = input<'content' | 'container'>('content');
|
|
150
154
|
|
|
@@ -166,6 +170,7 @@ export class ComplianceComponent {
|
|
|
166
170
|
workspace: this.workspace(),
|
|
167
171
|
flow: this.flow(),
|
|
168
172
|
customerReference: this.customerReference(),
|
|
173
|
+
offerReference: this.offerReference(),
|
|
169
174
|
authToken: this.authToken(),
|
|
170
175
|
sizing: this.sizing()
|
|
171
176
|
}
|
|
@@ -200,6 +205,7 @@ export class ComplianceComponent {
|
|
|
200
205
|
readonly workspace = input.required<string>();
|
|
201
206
|
readonly flow = input.required<string>();
|
|
202
207
|
readonly customerReference = input.required<string>();
|
|
208
|
+
readonly offerReference = input.required<string>();
|
|
203
209
|
readonly authToken = input.required<string>();
|
|
204
210
|
readonly sizing = input<'content' | 'container'>('content');
|
|
205
211
|
|
|
@@ -224,6 +230,7 @@ export class ComplianceComponent {
|
|
|
224
230
|
workspace: this.workspace(),
|
|
225
231
|
flow: this.flow(),
|
|
226
232
|
customerReference: this.customerReference(),
|
|
233
|
+
offerReference: this.offerReference(),
|
|
227
234
|
authToken: this.authToken(),
|
|
228
235
|
sizing: this.sizing()
|
|
229
236
|
}
|
|
@@ -245,11 +252,12 @@ interface ComplianceWidgetProps {
|
|
|
245
252
|
workspace: string;
|
|
246
253
|
flow: 'journey' | 'handover' | 'documents';
|
|
247
254
|
customerReference: string;
|
|
255
|
+
offerReference: string;
|
|
248
256
|
authToken: string;
|
|
249
257
|
sizing?: 'content' | 'container';
|
|
250
258
|
}
|
|
251
259
|
|
|
252
|
-
function ComplianceWidget({ workspace, flow, customerReference, authToken, sizing }: ComplianceWidgetProps) {
|
|
260
|
+
function ComplianceWidget({ workspace, flow, customerReference, offerReference, authToken, sizing }: ComplianceWidgetProps) {
|
|
253
261
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
254
262
|
const pluginRef = useRef<CompliancePlugin | null>(null);
|
|
255
263
|
|
|
@@ -261,7 +269,7 @@ function ComplianceWidget({ workspace, flow, customerReference, authToken, sizin
|
|
|
261
269
|
|
|
262
270
|
createCompliancePlugin({
|
|
263
271
|
containerElement: containerRef.current,
|
|
264
|
-
data: { workspace, flow, customerReference, authToken, sizing }
|
|
272
|
+
data: { workspace, flow, customerReference, offerReference, authToken, sizing }
|
|
265
273
|
})
|
|
266
274
|
.then((plugin) => {
|
|
267
275
|
pluginRef.current = plugin;
|
|
@@ -272,7 +280,7 @@ function ComplianceWidget({ workspace, flow, customerReference, authToken, sizin
|
|
|
272
280
|
pluginRef.current?.destroy();
|
|
273
281
|
pluginRef.current = null;
|
|
274
282
|
};
|
|
275
|
-
}, [workspace, flow, customerReference, authToken]);
|
|
283
|
+
}, [workspace, flow, customerReference, offerReference, authToken]);
|
|
276
284
|
|
|
277
285
|
return <div ref={containerRef} style={{ width: '100%', height: '600px' }} />;
|
|
278
286
|
}
|
package/build-revision.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
25108298654-1
|
package/index.cjs
CHANGED
|
@@ -88,12 +88,14 @@ var CompliancePlugin = class {
|
|
|
88
88
|
opts.postMessageBus.on("journey:started", () => this._events.emit("flow.journey.started"));
|
|
89
89
|
opts.postMessageBus.on("journey.section:started", (data) => this._events.emit("flow.journey.section:started", data));
|
|
90
90
|
opts.postMessageBus.on("journey.section:completed", (data) => this._events.emit("flow.journey.section:completed", data));
|
|
91
|
+
opts.postMessageBus.on("journey:completed", () => this._events.emit("flow.journey:completed"));
|
|
91
92
|
opts.postMessageBus.on("documents:loaded", (data) => this._events.emit("flow.documents:list", data));
|
|
92
93
|
const eventNames = [
|
|
93
94
|
"session:expired",
|
|
94
95
|
"flow.journey.started",
|
|
95
96
|
"flow.journey.section:started",
|
|
96
97
|
"flow.journey.section:completed",
|
|
98
|
+
"flow.journey:completed",
|
|
97
99
|
"flow.documents:list"
|
|
98
100
|
];
|
|
99
101
|
for (const eventName of eventNames) {
|
|
@@ -286,6 +288,9 @@ function validateOptions(options) {
|
|
|
286
288
|
if (!options.data.customerReference) {
|
|
287
289
|
throw new Error("[CompliancePlugin] data.customerReference is required.");
|
|
288
290
|
}
|
|
291
|
+
if (!options.data.offerReference) {
|
|
292
|
+
throw new Error("[CompliancePlugin] data.offerReference is required.");
|
|
293
|
+
}
|
|
289
294
|
if (!options.data.authToken) {
|
|
290
295
|
throw new Error("[CompliancePlugin] data.authToken is required.");
|
|
291
296
|
}
|
package/index.js
CHANGED
|
@@ -62,12 +62,14 @@ var CompliancePlugin = class {
|
|
|
62
62
|
opts.postMessageBus.on("journey:started", () => this._events.emit("flow.journey.started"));
|
|
63
63
|
opts.postMessageBus.on("journey.section:started", (data) => this._events.emit("flow.journey.section:started", data));
|
|
64
64
|
opts.postMessageBus.on("journey.section:completed", (data) => this._events.emit("flow.journey.section:completed", data));
|
|
65
|
+
opts.postMessageBus.on("journey:completed", () => this._events.emit("flow.journey:completed"));
|
|
65
66
|
opts.postMessageBus.on("documents:loaded", (data) => this._events.emit("flow.documents:list", data));
|
|
66
67
|
const eventNames = [
|
|
67
68
|
"session:expired",
|
|
68
69
|
"flow.journey.started",
|
|
69
70
|
"flow.journey.section:started",
|
|
70
71
|
"flow.journey.section:completed",
|
|
72
|
+
"flow.journey:completed",
|
|
71
73
|
"flow.documents:list"
|
|
72
74
|
];
|
|
73
75
|
for (const eventName of eventNames) {
|
|
@@ -260,6 +262,9 @@ function validateOptions(options) {
|
|
|
260
262
|
if (!options.data.customerReference) {
|
|
261
263
|
throw new Error("[CompliancePlugin] data.customerReference is required.");
|
|
262
264
|
}
|
|
265
|
+
if (!options.data.offerReference) {
|
|
266
|
+
throw new Error("[CompliancePlugin] data.offerReference is required.");
|
|
267
|
+
}
|
|
263
268
|
if (!options.data.authToken) {
|
|
264
269
|
throw new Error("[CompliancePlugin] data.authToken is required.");
|
|
265
270
|
}
|
|
@@ -18,13 +18,15 @@ interface ComplianceDocument {
|
|
|
18
18
|
readonly reference: string;
|
|
19
19
|
}
|
|
20
20
|
export interface CompliancePluginEvents {
|
|
21
|
-
/** Emits when the user starts the journey and
|
|
21
|
+
/** Emits when the user starts the journey and Initial Disclosure Document is generated. */
|
|
22
22
|
['flow.journey.started']: void;
|
|
23
23
|
/** Emits when the user starts a section. */
|
|
24
24
|
['flow.journey.section:started']: SectionStartedEvent;
|
|
25
25
|
/** Emits when the user completes the question set and submits their recommendations. */
|
|
26
26
|
['flow.journey.section:completed']: SectionEndedEvent;
|
|
27
|
-
/** Emits when the user completes the journey and
|
|
27
|
+
/** Emits when the user completes the journey and summary page is presented. */
|
|
28
|
+
['flow.journey:completed']: void;
|
|
29
|
+
/** Emits when with a list of available documents. */
|
|
28
30
|
['flow.documents:list']: ComplianceDocument[];
|
|
29
31
|
/** Emits when the session has expired. This would typically trigger your auth flow followed by re-initialising the plugin. */
|
|
30
32
|
['session:expired']: void;
|
package/libs/twilltac/plugins/compliance/types/src/lib/compliance-plugin-initialisation.data.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export interface CompliancePluginInitialisationData {
|
|
|
11
11
|
readonly workspace: string;
|
|
12
12
|
readonly flow: CompliancePluginFlow;
|
|
13
13
|
readonly customerReference: string;
|
|
14
|
+
readonly offerReference: string;
|
|
14
15
|
readonly authToken: string;
|
|
15
16
|
readonly sizing: CompliancePluginSizing;
|
|
16
17
|
}
|