@twilltac/compliance-sdk 0.1.4 → 0.1.5

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 CHANGED
@@ -19,6 +19,7 @@ const plugin = await createCompliancePlugin({
19
19
  containerElement: container,
20
20
  data: {
21
21
  workspace: 'YOUR_WORKSPACE_KEY',
22
+ view: 'journey',
22
23
  customerReference: 'YOUR_CUSTOMER_REFERENCE',
23
24
  authToken: 'YOUR_AUTH_TOKEN'
24
25
  }
@@ -39,6 +40,7 @@ Creates and initialises the compliance plugin within a container element.
39
40
  | -------------------------------- | ------------- | ------------------------------------------------- |
40
41
  | `options.containerElement` | `HTMLElement` | The DOM element where the plugin will be rendered |
41
42
  | `options.data.workspace` | `string` | Your Twilltac workspace identifier |
43
+ | `options.data.view` | `string` | The plugin view to load. Either `journey` or `handover` |
42
44
  | `options.data.customerReference` | `string` | Reference identifier for the customer |
43
45
  | `options.data.authToken` | `string` | Authentication token for the plugin session |
44
46
 
@@ -67,10 +69,10 @@ plugin.on('session:expired', () => {
67
69
  <!-- EVENTS_TABLE_START -->
68
70
  | Event | Data | Description |
69
71
  | ----- | ---- | ----------- |
70
- | `session:expired` | `void` | Emits when the session has expired. This would typically trigger your auth flow followed by re-initialising the plugin. |
71
72
  | `started` | `void` | Emits when the user starts the journey and IDD document is generated. |
72
73
  | `section:started` | `SectionStartedEvent` | Emits when the user starts a section. |
73
74
  | `section:completed` | `SectionEndedEvent` | Emits when the user starts a completes the question set and selects their recommendations. |
75
+ | `session:expired` | `void` | Emits when the session has expired. This would typically trigger your auth flow followed by re-initialising the plugin. |
74
76
 
75
77
  #### Type Definitions
76
78
 
@@ -110,6 +112,7 @@ import { from, switchMap } from 'rxjs';
110
112
  })
111
113
  export class ComplianceComponent {
112
114
  readonly workspace = input.required<string>();
115
+ readonly view = input.required<string>();
113
116
  readonly customerReference = input.required<string>();
114
117
  readonly authToken = input.required<string>();
115
118
 
@@ -126,6 +129,7 @@ export class ComplianceComponent {
126
129
  containerElement: container.nativeElement,
127
130
  data: {
128
131
  workspace: this.workspace(),
132
+ view: this.view(),
129
133
  customerReference: this.customerReference(),
130
134
  authToken: this.authToken()
131
135
  }
@@ -158,6 +162,7 @@ import { createCompliancePlugin, CompliancePlugin } from '@twilltac/compliance-s
158
162
  })
159
163
  export class ComplianceComponent {
160
164
  readonly workspace = input.required<string>();
165
+ readonly view = input.required<string>();
161
166
  readonly customerReference = input.required<string>();
162
167
  readonly authToken = input.required<string>();
163
168
 
@@ -196,11 +201,12 @@ import { createCompliancePlugin, CompliancePlugin } from '@twilltac/compliance-s
196
201
 
197
202
  interface ComplianceWidgetProps {
198
203
  workspace: string;
204
+ view: 'journey' | 'handover';
199
205
  customerReference: string;
200
206
  authToken: string;
201
207
  }
202
208
 
203
- function ComplianceWidget({ workspace, customerReference, authToken }: ComplianceWidgetProps) {
209
+ function ComplianceWidget({ workspace, view, customerReference, authToken }: ComplianceWidgetProps) {
204
210
  const containerRef = useRef<HTMLDivElement>(null);
205
211
  const pluginRef = useRef<CompliancePlugin | null>(null);
206
212
 
@@ -209,13 +215,13 @@ function ComplianceWidget({ workspace, customerReference, authToken }: Complianc
209
215
 
210
216
  createCompliancePlugin({
211
217
  containerElement: containerRef.current,
212
- data: { workspace, customerReference, authToken }
218
+ data: { workspace, view, customerReference, authToken }
213
219
  })
214
220
  .then((plugin) => {
215
221
  pluginRef.current = plugin;
216
222
  })
217
223
  .catch(console.error);
218
- }, [workspace, customerReference, authToken]);
224
+ }, [workspace, view, customerReference, authToken]);
219
225
 
220
226
  return <div ref={containerRef} style={{ width: '100%', height: '600px' }} />;
221
227
  }
@@ -1 +1 @@
1
- 21181652609-1
1
+ 22776693444-1
package/index.cjs CHANGED
@@ -80,6 +80,13 @@ var CompliancePlugin = class {
80
80
  }
81
81
  };
82
82
 
83
+ // libs/twilltac/plugins/compliance/types/src/lib/compliance-plugin-initialisation.data.ts
84
+ var CompliancePluginView = /* @__PURE__ */ ((CompliancePluginView2) => {
85
+ CompliancePluginView2["JOURNEY"] = "journey";
86
+ CompliancePluginView2["HANDOVER"] = "handover";
87
+ return CompliancePluginView2;
88
+ })(CompliancePluginView || {});
89
+
83
90
  // libs/twilltac/plugins/utils/post-messenger/src/lib/post-message.bus.ts
84
91
  var PostMessageBus = class {
85
92
  _channel;
@@ -230,7 +237,32 @@ var PostMessageBus = class {
230
237
  };
231
238
 
232
239
  // libs/twilltac/plugins/compliance/sdk/src/lib/create-compliance.plugin.ts
240
+ function validateOptions(options) {
241
+ if (!options.containerElement) {
242
+ throw new Error("[CompliancePlugin] containerElement is required.");
243
+ }
244
+ if (!(options.containerElement instanceof HTMLElement)) {
245
+ throw new Error("[CompliancePlugin] containerElement must be an HTMLElement.");
246
+ }
247
+ if (!options.data) {
248
+ throw new Error("[CompliancePlugin] data is required.");
249
+ }
250
+ if (!options.data.workspace) {
251
+ throw new Error("[CompliancePlugin] data.workspace is required.");
252
+ }
253
+ const validViews = Object.values(CompliancePluginView);
254
+ if (!options.data.view || !validViews.includes(options.data.view)) {
255
+ throw new Error(`[CompliancePlugin] data.view is required and must be one of: ${validViews.join(", ")}.`);
256
+ }
257
+ if (!options.data.customerReference) {
258
+ throw new Error("[CompliancePlugin] data.customerReference is required.");
259
+ }
260
+ if (!options.data.authToken) {
261
+ throw new Error("[CompliancePlugin] data.authToken is required.");
262
+ }
263
+ }
233
264
  function createCompliancePlugin(options) {
265
+ validateOptions(options);
234
266
  const production = !window.location.hostname.endsWith(".ngserve");
235
267
  const baseUrl = "https://compliance.plugins.twilltac.app";
236
268
  const url = production ? baseUrl : `${baseUrl}.ngserve`;
package/index.js CHANGED
@@ -54,6 +54,13 @@ var CompliancePlugin = class {
54
54
  }
55
55
  };
56
56
 
57
+ // libs/twilltac/plugins/compliance/types/src/lib/compliance-plugin-initialisation.data.ts
58
+ var CompliancePluginView = /* @__PURE__ */ ((CompliancePluginView2) => {
59
+ CompliancePluginView2["JOURNEY"] = "journey";
60
+ CompliancePluginView2["HANDOVER"] = "handover";
61
+ return CompliancePluginView2;
62
+ })(CompliancePluginView || {});
63
+
57
64
  // libs/twilltac/plugins/utils/post-messenger/src/lib/post-message.bus.ts
58
65
  var PostMessageBus = class {
59
66
  _channel;
@@ -204,7 +211,32 @@ var PostMessageBus = class {
204
211
  };
205
212
 
206
213
  // libs/twilltac/plugins/compliance/sdk/src/lib/create-compliance.plugin.ts
214
+ function validateOptions(options) {
215
+ if (!options.containerElement) {
216
+ throw new Error("[CompliancePlugin] containerElement is required.");
217
+ }
218
+ if (!(options.containerElement instanceof HTMLElement)) {
219
+ throw new Error("[CompliancePlugin] containerElement must be an HTMLElement.");
220
+ }
221
+ if (!options.data) {
222
+ throw new Error("[CompliancePlugin] data is required.");
223
+ }
224
+ if (!options.data.workspace) {
225
+ throw new Error("[CompliancePlugin] data.workspace is required.");
226
+ }
227
+ const validViews = Object.values(CompliancePluginView);
228
+ if (!options.data.view || !validViews.includes(options.data.view)) {
229
+ throw new Error(`[CompliancePlugin] data.view is required and must be one of: ${validViews.join(", ")}.`);
230
+ }
231
+ if (!options.data.customerReference) {
232
+ throw new Error("[CompliancePlugin] data.customerReference is required.");
233
+ }
234
+ if (!options.data.authToken) {
235
+ throw new Error("[CompliancePlugin] data.authToken is required.");
236
+ }
237
+ }
207
238
  function createCompliancePlugin(options) {
239
+ validateOptions(options);
208
240
  const production = !window.location.hostname.endsWith(".ngserve");
209
241
  const baseUrl = "https://compliance.plugins.twilltac.app";
210
242
  const url = production ? baseUrl : `${baseUrl}.ngserve`;
@@ -14,13 +14,13 @@ interface SectionEndedEvent {
14
14
  }[];
15
15
  }
16
16
  export interface CompliancePluginEvents {
17
- /** Emits when the session has expired. This would typically trigger your auth flow followed by re-initialising the plugin. */
18
- ['session:expired']: void;
19
17
  /** Emits when the user starts the journey and IDD document is generated. */
20
18
  ['started']: void;
21
19
  /** Emits when the user starts a section. */
22
20
  ['section:started']: SectionStartedEvent;
23
21
  /** Emits when the user starts a completes the question set and selects their recommendations. */
24
22
  ['section:completed']: SectionEndedEvent;
23
+ /** Emits when the session has expired. This would typically trigger your auth flow followed by re-initialising the plugin. */
24
+ ['session:expired']: void;
25
25
  }
26
26
  export {};
@@ -1,5 +1,10 @@
1
+ export declare enum CompliancePluginView {
2
+ JOURNEY = "journey",
3
+ HANDOVER = "handover"
4
+ }
1
5
  export interface CompliancePluginInitialisationData {
2
6
  readonly workspace: string;
7
+ readonly view: CompliancePluginView;
3
8
  readonly customerReference: string;
4
9
  readonly authToken: string;
5
10
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twilltac/compliance-sdk",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "type": "module",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",