@insight-health/aura 0.0.10-beta.2 → 0.0.10-beta.4
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/dist/auraWidget.d.ts +3 -2
- package/dist/auraWidget.d.ts.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +25 -20
- package/dist/index.umd.js +2 -2
- package/dist/types.d.ts +32 -5
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/auraWidget.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RegisterTemplatesPayload, AuraWidgetInitParams, AuraWidgetEmitEvent, AuthParams, SupportedMethods, AutoRegisterTemplatesPayload } from './types';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Aura service class
|
|
@@ -29,7 +29,8 @@ declare class AuraWidgetService {
|
|
|
29
29
|
command: (event: AuraWidgetEmitEvent) => void;
|
|
30
30
|
emit: (event: AuraWidgetEmitEvent) => void;
|
|
31
31
|
on: (type: string, callback: (payload: unknown) => void) => (() => void);
|
|
32
|
-
registerTemplates: (payload:
|
|
32
|
+
registerTemplates: (payload: RegisterTemplatesPayload) => void;
|
|
33
|
+
autoRegisterTemplates: (payload: AutoRegisterTemplatesPayload) => void;
|
|
33
34
|
/**
|
|
34
35
|
* Register a method that can be called by the iframe widget
|
|
35
36
|
* @param name - The method name identifier
|
package/dist/auraWidget.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auraWidget.d.ts","sourceRoot":"","sources":["../src/auraWidget.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"auraWidget.d.ts","sourceRoot":"","sources":["../src/auraWidget.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EAEpB,mBAAmB,EACnB,UAAU,EAEV,gBAAgB,EAChB,4BAA4B,EAC7B,MAAM,SAAS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M,UAAU,mBAAgB,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A={insightBaseUrl:"https://anywhere.insighthealth.ai"};let w=null;function C(){return w}function x(i){w={...A,...i}}function W(i){x(i)}function c(){const i=C();if(!i)throw new Error("Aura SDK not configured. Call configure() first to set global configuration.");return i}function y(){return"0.0.10-beta.4"}class O{constructor(){this.events={},this.subscribe=(e,t)=>(this.events[e]||(this.events[e]=[]),this.events[e].push(t),()=>{this.events[e]=this.events[e].filter(s=>s!==t)}),this.emit=(e,t)=>{this.events[e]&&this.events[e].forEach(s=>s(t))}}}const u=new O,d={log:i=>{console.log(`[Insight Health Aura Widget]: ${i}`)},warn:i=>{console.warn(`[Insight Health Aura Widget]: ${i}`)},error:i=>{console.error(`[Insight Health Aura Widget]: ${i}`)}},p={opacity:"0",pointerEvents:"none",width:"0",height:"0",maxWidth:"0",maxHeight:"0"},I={border:"none",borderRadius:"10px",boxShadow:"0 0 10px 0 rgba(0, 0, 0, 0.1)",overflow:"hidden",background:"#fff",position:"fixed",bottom:"20px",right:"20px",transition:"opacity 0.2s ease-in-out, width 0.2s ease-in-out, height 0.2s ease-in-out, max-width 0.2s ease-in-out, max-height 0.2s ease-in-out",zIndex:"9999"};class U{constructor(){this.config=null,this.widgetFrame=null,this.unsubsciptions=[],this.messageQueue=[],this.isQueueingEnabled=!1,this.methodRegistry={},this.isFrameReady=!1,this.isFrameAuthenticated=!1,this.postMessage=e=>{var s;if(!((s=this.widgetFrame)!=null&&s.contentWindow)){d.warn("No widget iframe to communicate with");return}const t=c();this.widgetFrame.contentWindow.postMessage(e,{targetOrigin:t.insightBaseUrl})},this.enableQueue=()=>{this.isQueueingEnabled=!0},this.disableQueue=(e=!1)=>{this.isQueueingEnabled=!1,e&&this.flushQueue()},this.flushQueue=()=>{const e=[...this.messageQueue];this.clearQueue(),e.forEach(t=>{this.postMessage(t)})},this.clearQueue=()=>{this.messageQueue=[]},this.sendOrQueue=e=>{if(this.isQueueingEnabled){this.messageQueue.push(e);return}this.postMessage(e)},this.handleMethodCall=async e=>{const{callId:t,methodName:s,args:h}=e,r=this.methodRegistry[s];if(!r){this.postMessage({type:"Method.Response",payload:{callId:t,methodName:s,success:!1,error:{message:`Method "${s}" is not registered`,code:"METHOD_NOT_FOUND"}}});return}try{const n=await r(h||{});this.postMessage({type:"Method.Response",payload:{callId:t,methodName:s,success:!0,result:n}})}catch(n){const a=n instanceof Error?n:new Error(String(n));this.postMessage({type:"Method.Response",payload:{callId:t,success:!1,methodName:s,error:{message:a.message,code:"METHOD_EXECUTION_ERROR",stack:a.stack,name:a.name,cause:a.cause,apiResponse:a.response}}})}},this.init=e=>new Promise(t=>{if(!this.widgetFrame){this.reset(),this.enableQueue();const s=c(),{tenantId:h,tenantName:r,user:n,language:a,container:l,widgetId:b,widgetStyles:o}=e;this.config=e,this.isFrameReady=!1,this.widgetFrame=document.createElement("iframe");const F=(o==null?void 0:o.width)||"350px",M=(o==null?void 0:o.height)||"600px",Q={...I,...o,...p};Object.assign(this.widgetFrame.style,Q),this.widgetFrame.id=b||"aura-widget",this.widgetFrame.setAttribute("allow",`microphone ${s.insightBaseUrl}; camera ${s.insightBaseUrl}; clipboard-read ${s.insightBaseUrl}; clipboard-write ${s.insightBaseUrl};`),this.widgetFrame.src=`${s.insightBaseUrl}`,this.widgetFrame.__desiredWidth=F,this.widgetFrame.__desiredHeight=M,this.widgetFrame.onerror=()=>{d.error(`Failed to load iframe. Please ensure your Content Security Policy includes:
|
|
2
2
|
frame-src ${s.insightBaseUrl}
|
|
3
|
-
`)},(l&&document.querySelector(l)||document.body).appendChild(this.widgetFrame);const
|
|
3
|
+
`)},(l&&document.querySelector(l)||document.body).appendChild(this.widgetFrame);const R=u.subscribe("Auth.Ready",()=>{this.isFrameReady=!0,this.setUser({tenantId:h,tenantName:r,user:n,language:a})}),E=u.subscribe("Auth.Complete",m=>{var f;this.isFrameAuthenticated=!0,this.disableQueue(!0),t(m),(f=e.onAuthenticated)==null||f.call(e,m)});this.unsubsciptions.push(R,E)}}),this.setUser=e=>{const t=this.config.partnerKey,{tenantId:s,tenantName:h,user:r,language:n}=e;this.config.tenantId=s,this.config.tenantName=h,this.config.user=r,this.config.language=n,this.isFrameAuthenticated=!1,this.postMessage({type:"Auth.Login",payload:{partnerKey:t,tenantId:s,tenantName:h,user:r,language:n}})},this.show=()=>{if(this.widgetFrame){const e=this.widgetFrame.__desiredWidth||"350px",t=this.widgetFrame.__desiredHeight||"600px",s={opacity:"1",pointerEvents:"auto",width:e,height:t,maxWidth:e,maxHeight:t};Object.assign(this.widgetFrame.style,{...s})}},this.hide=()=>{this.widgetFrame&&Object.assign(this.widgetFrame.style,{...p})},this.reset=()=>{this.widgetFrame&&this.widgetFrame.remove(),this.widgetFrame=null,this.isFrameReady=!1,this.isFrameAuthenticated=!1,this.unsubsciptions.forEach(e=>e==null?void 0:e()),this.unsubsciptions=[],this.disableQueue(),this.clearQueue(),this.methodRegistry={}},this.command=e=>{this.sendOrQueue(e),this.show()},this.emit=this.command,this.on=(e,t)=>u.subscribe(e,t),this.registerTemplates=e=>{this.sendOrQueue({type:"Template.Register",payload:e})},this.autoRegisterTemplates=e=>{this.sendOrQueue({type:"Template.AutoRegister",payload:e})},this.registerMethod=(e,t)=>{if(typeof e!="string"){d.error("Method name must be a string");return}if(typeof t!="function"){d.error("Method handler for name "+e+" must be a function");return}this.methodRegistry[e]=t},this.unregisterMethod=e=>delete this.methodRegistry[e],this.getConfig=()=>this.config,this.getVersion=()=>y(),window.addEventListener("message",e=>{var t;if(!(e.source!==((t=this.widgetFrame)==null?void 0:t.contentWindow)||!e.data)){if(e.data.type==="Method.Call"){this.handleMethodCall(e.data.payload);return}u.emit(e.data.type,e.data.payload)}})}}let g=null;function _(){return g||(g=new U),g}const H=_();exports.AuraWidget=H;exports.configure=W;exports.getConfig=c;exports.getVersion=y;
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
const
|
|
1
|
+
const E = {
|
|
2
2
|
insightBaseUrl: "https://anywhere.insighthealth.ai"
|
|
3
3
|
};
|
|
4
4
|
let w = null;
|
|
5
5
|
function x() {
|
|
6
6
|
return w;
|
|
7
7
|
}
|
|
8
|
-
function
|
|
9
|
-
w = { ...
|
|
8
|
+
function A(i) {
|
|
9
|
+
w = { ...E, ...i };
|
|
10
10
|
}
|
|
11
11
|
function _(i) {
|
|
12
|
-
|
|
12
|
+
A(i);
|
|
13
13
|
}
|
|
14
14
|
function f() {
|
|
15
15
|
const i = x();
|
|
@@ -19,8 +19,8 @@ function f() {
|
|
|
19
19
|
);
|
|
20
20
|
return i;
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
return "0.0.10-beta.
|
|
22
|
+
function C() {
|
|
23
|
+
return "0.0.10-beta.4";
|
|
24
24
|
}
|
|
25
25
|
class W {
|
|
26
26
|
constructor() {
|
|
@@ -31,7 +31,7 @@ class W {
|
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
const
|
|
34
|
+
const u = new W(), d = {
|
|
35
35
|
log: (i) => {
|
|
36
36
|
console.log(`[Insight Health Aura Widget]: ${i}`);
|
|
37
37
|
},
|
|
@@ -65,7 +65,7 @@ class I {
|
|
|
65
65
|
this.config = null, this.widgetFrame = null, this.unsubsciptions = [], this.messageQueue = [], this.isQueueingEnabled = !1, this.methodRegistry = {}, this.isFrameReady = !1, this.isFrameAuthenticated = !1, this.postMessage = (e) => {
|
|
66
66
|
var s;
|
|
67
67
|
if (!((s = this.widgetFrame) != null && s.contentWindow)) {
|
|
68
|
-
|
|
68
|
+
d.warn("No widget iframe to communicate with");
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
71
|
const t = f();
|
|
@@ -149,31 +149,31 @@ class I {
|
|
|
149
149
|
widgetStyles: o
|
|
150
150
|
} = e;
|
|
151
151
|
this.config = e, this.isFrameReady = !1, this.widgetFrame = document.createElement("iframe");
|
|
152
|
-
const b = (o == null ? void 0 : o.width) || "350px", F = (o == null ? void 0 : o.height) || "600px",
|
|
152
|
+
const b = (o == null ? void 0 : o.width) || "350px", F = (o == null ? void 0 : o.height) || "600px", Q = {
|
|
153
153
|
...O,
|
|
154
154
|
...o,
|
|
155
155
|
...p
|
|
156
156
|
};
|
|
157
|
-
Object.assign(this.widgetFrame.style,
|
|
157
|
+
Object.assign(this.widgetFrame.style, Q), this.widgetFrame.id = y || "aura-widget", this.widgetFrame.setAttribute(
|
|
158
158
|
"allow",
|
|
159
159
|
`microphone ${s.insightBaseUrl}; camera ${s.insightBaseUrl}; clipboard-read ${s.insightBaseUrl}; clipboard-write ${s.insightBaseUrl};`
|
|
160
160
|
), this.widgetFrame.src = `${s.insightBaseUrl}`, this.widgetFrame.__desiredWidth = b, this.widgetFrame.__desiredHeight = F, this.widgetFrame.onerror = () => {
|
|
161
|
-
|
|
161
|
+
d.error(
|
|
162
162
|
`Failed to load iframe. Please ensure your Content Security Policy includes:
|
|
163
163
|
frame-src ${s.insightBaseUrl}
|
|
164
164
|
`
|
|
165
165
|
);
|
|
166
166
|
}, (c && document.querySelector(c) || document.body).appendChild(this.widgetFrame);
|
|
167
|
-
const
|
|
167
|
+
const R = u.subscribe("Auth.Ready", () => {
|
|
168
168
|
this.isFrameReady = !0, this.setUser({ tenantId: h, tenantName: r, user: n, language: a });
|
|
169
|
-
}),
|
|
169
|
+
}), M = u.subscribe(
|
|
170
170
|
"Auth.Complete",
|
|
171
171
|
(l) => {
|
|
172
172
|
var m;
|
|
173
173
|
this.isFrameAuthenticated = !0, this.disableQueue(!0), t(l), (m = e.onAuthenticated) == null || m.call(e, l);
|
|
174
174
|
}
|
|
175
175
|
);
|
|
176
|
-
this.unsubsciptions.push(
|
|
176
|
+
this.unsubsciptions.push(R, M);
|
|
177
177
|
}
|
|
178
178
|
}), this.setUser = (e) => {
|
|
179
179
|
const t = this.config.partnerKey, { tenantId: s, tenantName: h, user: r, language: n } = e;
|
|
@@ -205,22 +205,27 @@ class I {
|
|
|
205
205
|
this.widgetFrame && this.widgetFrame.remove(), this.widgetFrame = null, this.isFrameReady = !1, this.isFrameAuthenticated = !1, this.unsubsciptions.forEach((e) => e == null ? void 0 : e()), this.unsubsciptions = [], this.disableQueue(), this.clearQueue(), this.methodRegistry = {};
|
|
206
206
|
}, this.command = (e) => {
|
|
207
207
|
this.sendOrQueue(e), this.show();
|
|
208
|
-
}, this.emit = this.command, this.on = (e, t) =>
|
|
208
|
+
}, this.emit = this.command, this.on = (e, t) => u.subscribe(e, t), this.registerTemplates = (e) => {
|
|
209
209
|
this.sendOrQueue({
|
|
210
210
|
type: "Template.Register",
|
|
211
211
|
payload: e
|
|
212
212
|
});
|
|
213
|
+
}, this.autoRegisterTemplates = (e) => {
|
|
214
|
+
this.sendOrQueue({
|
|
215
|
+
type: "Template.AutoRegister",
|
|
216
|
+
payload: e
|
|
217
|
+
});
|
|
213
218
|
}, this.registerMethod = (e, t) => {
|
|
214
219
|
if (typeof e != "string") {
|
|
215
|
-
|
|
220
|
+
d.error("Method name must be a string");
|
|
216
221
|
return;
|
|
217
222
|
}
|
|
218
223
|
if (typeof t != "function") {
|
|
219
|
-
|
|
224
|
+
d.error("Method handler for name " + e + " must be a function");
|
|
220
225
|
return;
|
|
221
226
|
}
|
|
222
227
|
this.methodRegistry[e] = t;
|
|
223
|
-
}, this.unregisterMethod = (e) => delete this.methodRegistry[e], this.getConfig = () => this.config, this.getVersion = () =>
|
|
228
|
+
}, this.unregisterMethod = (e) => delete this.methodRegistry[e], this.getConfig = () => this.config, this.getVersion = () => C(), window.addEventListener(
|
|
224
229
|
"message",
|
|
225
230
|
(e) => {
|
|
226
231
|
var t;
|
|
@@ -231,7 +236,7 @@ class I {
|
|
|
231
236
|
);
|
|
232
237
|
return;
|
|
233
238
|
}
|
|
234
|
-
|
|
239
|
+
u.emit(e.data.type, e.data.payload);
|
|
235
240
|
}
|
|
236
241
|
}
|
|
237
242
|
);
|
|
@@ -246,5 +251,5 @@ export {
|
|
|
246
251
|
H as AuraWidget,
|
|
247
252
|
_ as configure,
|
|
248
253
|
f as getConfig,
|
|
249
|
-
|
|
254
|
+
C as getVersion
|
|
250
255
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(r,
|
|
1
|
+
(function(r,d){typeof exports=="object"&&typeof module<"u"?d(exports):typeof define=="function"&&define.amd?define(["exports"],d):(r=typeof globalThis<"u"?globalThis:r||self,d(r.InsightAura={}))})(this,function(r){"use strict";const d={insightBaseUrl:"https://anywhere.insighthealth.ai"};let m=null;function M(){return m}function Q(i){m={...d,...i}}function R(i){Q(i)}function l(){const i=M();if(!i)throw new Error("Aura SDK not configured. Call configure() first to set global configuration.");return i}function p(){return"0.0.10-beta.4"}class A{constructor(){this.events={},this.subscribe=(e,t)=>(this.events[e]||(this.events[e]=[]),this.events[e].push(t),()=>{this.events[e]=this.events[e].filter(s=>s!==t)}),this.emit=(e,t)=>{this.events[e]&&this.events[e].forEach(s=>s(t))}}}const g=new A,c={log:i=>{console.log(`[Insight Health Aura Widget]: ${i}`)},warn:i=>{console.warn(`[Insight Health Aura Widget]: ${i}`)},error:i=>{console.error(`[Insight Health Aura Widget]: ${i}`)}},w={opacity:"0",pointerEvents:"none",width:"0",height:"0",maxWidth:"0",maxHeight:"0"},E={border:"none",borderRadius:"10px",boxShadow:"0 0 10px 0 rgba(0, 0, 0, 0.1)",overflow:"hidden",background:"#fff",position:"fixed",bottom:"20px",right:"20px",transition:"opacity 0.2s ease-in-out, width 0.2s ease-in-out, height 0.2s ease-in-out, max-width 0.2s ease-in-out, max-height 0.2s ease-in-out",zIndex:"9999"};class C{constructor(){this.config=null,this.widgetFrame=null,this.unsubsciptions=[],this.messageQueue=[],this.isQueueingEnabled=!1,this.methodRegistry={},this.isFrameReady=!1,this.isFrameAuthenticated=!1,this.postMessage=e=>{var s;if(!((s=this.widgetFrame)!=null&&s.contentWindow)){c.warn("No widget iframe to communicate with");return}const t=l();this.widgetFrame.contentWindow.postMessage(e,{targetOrigin:t.insightBaseUrl})},this.enableQueue=()=>{this.isQueueingEnabled=!0},this.disableQueue=(e=!1)=>{this.isQueueingEnabled=!1,e&&this.flushQueue()},this.flushQueue=()=>{const e=[...this.messageQueue];this.clearQueue(),e.forEach(t=>{this.postMessage(t)})},this.clearQueue=()=>{this.messageQueue=[]},this.sendOrQueue=e=>{if(this.isQueueingEnabled){this.messageQueue.push(e);return}this.postMessage(e)},this.handleMethodCall=async e=>{const{callId:t,methodName:s,args:u}=e,a=this.methodRegistry[s];if(!a){this.postMessage({type:"Method.Response",payload:{callId:t,methodName:s,success:!1,error:{message:`Method "${s}" is not registered`,code:"METHOD_NOT_FOUND"}}});return}try{const n=await a(u||{});this.postMessage({type:"Method.Response",payload:{callId:t,methodName:s,success:!0,result:n}})}catch(n){const o=n instanceof Error?n:new Error(String(n));this.postMessage({type:"Method.Response",payload:{callId:t,success:!1,methodName:s,error:{message:o.message,code:"METHOD_EXECUTION_ERROR",stack:o.stack,name:o.name,cause:o.cause,apiResponse:o.response}}})}},this.init=e=>new Promise(t=>{if(!this.widgetFrame){this.reset(),this.enableQueue();const s=l(),{tenantId:u,tenantName:a,user:n,language:o,container:y,widgetId:O,widgetStyles:h}=e;this.config=e,this.isFrameReady=!1,this.widgetFrame=document.createElement("iframe");const I=(h==null?void 0:h.width)||"350px",T=(h==null?void 0:h.height)||"600px",U={...E,...h,...w};Object.assign(this.widgetFrame.style,U),this.widgetFrame.id=O||"aura-widget",this.widgetFrame.setAttribute("allow",`microphone ${s.insightBaseUrl}; camera ${s.insightBaseUrl}; clipboard-read ${s.insightBaseUrl}; clipboard-write ${s.insightBaseUrl};`),this.widgetFrame.src=`${s.insightBaseUrl}`,this.widgetFrame.__desiredWidth=I,this.widgetFrame.__desiredHeight=T,this.widgetFrame.onerror=()=>{c.error(`Failed to load iframe. Please ensure your Content Security Policy includes:
|
|
2
2
|
frame-src ${s.insightBaseUrl}
|
|
3
|
-
`)},(y&&document.querySelector(y)||document.body).appendChild(this.widgetFrame);const
|
|
3
|
+
`)},(y&&document.querySelector(y)||document.body).appendChild(this.widgetFrame);const _=g.subscribe("Auth.Ready",()=>{this.isFrameReady=!0,this.setUser({tenantId:u,tenantName:a,user:n,language:o})}),H=g.subscribe("Auth.Complete",b=>{var F;this.isFrameAuthenticated=!0,this.disableQueue(!0),t(b),(F=e.onAuthenticated)==null||F.call(e,b)});this.unsubsciptions.push(_,H)}}),this.setUser=e=>{const t=this.config.partnerKey,{tenantId:s,tenantName:u,user:a,language:n}=e;this.config.tenantId=s,this.config.tenantName=u,this.config.user=a,this.config.language=n,this.isFrameAuthenticated=!1,this.postMessage({type:"Auth.Login",payload:{partnerKey:t,tenantId:s,tenantName:u,user:a,language:n}})},this.show=()=>{if(this.widgetFrame){const e=this.widgetFrame.__desiredWidth||"350px",t=this.widgetFrame.__desiredHeight||"600px",s={opacity:"1",pointerEvents:"auto",width:e,height:t,maxWidth:e,maxHeight:t};Object.assign(this.widgetFrame.style,{...s})}},this.hide=()=>{this.widgetFrame&&Object.assign(this.widgetFrame.style,{...w})},this.reset=()=>{this.widgetFrame&&this.widgetFrame.remove(),this.widgetFrame=null,this.isFrameReady=!1,this.isFrameAuthenticated=!1,this.unsubsciptions.forEach(e=>e==null?void 0:e()),this.unsubsciptions=[],this.disableQueue(),this.clearQueue(),this.methodRegistry={}},this.command=e=>{this.sendOrQueue(e),this.show()},this.emit=this.command,this.on=(e,t)=>g.subscribe(e,t),this.registerTemplates=e=>{this.sendOrQueue({type:"Template.Register",payload:e})},this.autoRegisterTemplates=e=>{this.sendOrQueue({type:"Template.AutoRegister",payload:e})},this.registerMethod=(e,t)=>{if(typeof e!="string"){c.error("Method name must be a string");return}if(typeof t!="function"){c.error("Method handler for name "+e+" must be a function");return}this.methodRegistry[e]=t},this.unregisterMethod=e=>delete this.methodRegistry[e],this.getConfig=()=>this.config,this.getVersion=()=>p(),window.addEventListener("message",e=>{var t;if(!(e.source!==((t=this.widgetFrame)==null?void 0:t.contentWindow)||!e.data)){if(e.data.type==="Method.Call"){this.handleMethodCall(e.data.payload);return}g.emit(e.data.type,e.data.payload)}})}}let f=null;function x(){return f||(f=new C),f}const W=x();r.AuraWidget=W,r.configure=R,r.getConfig=l,r.getVersion=p,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})});
|
package/dist/types.d.ts
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A type that represents an object with any key and value.
|
|
3
|
+
*/
|
|
4
|
+
export type AnyObject = Record<string | number | symbol, any>;
|
|
5
|
+
/**
|
|
6
|
+
* Require at least one of the specified keys to be present.
|
|
7
|
+
*/
|
|
8
|
+
export type AtLeastOneOf<T extends AnyObject, K extends keyof T> = Omit<T, K> & {
|
|
9
|
+
[P in K]: Required<Pick<T, P>> & Partial<Pick<T, Exclude<K, P>>>;
|
|
10
|
+
}[K];
|
|
1
11
|
export type AuraWidgetEmitEvent<T = any> = {
|
|
2
12
|
type: string;
|
|
3
13
|
payload: T;
|
|
@@ -16,25 +26,42 @@ export type AuraWidgetInitParams = {
|
|
|
16
26
|
container?: string;
|
|
17
27
|
widgetId?: string;
|
|
18
28
|
widgetStyles?: Partial<Pick<CSSStyleDeclaration, 'width' | 'height' | 'borderRadius' | 'boxShadow' | 'top' | 'bottom' | 'left' | 'right'>>;
|
|
19
|
-
onAuthenticated?: (data: AuthParams
|
|
29
|
+
onAuthenticated?: (data: AuthParams & {
|
|
30
|
+
templateIds: AuraTemplate['id'][];
|
|
31
|
+
}) => void;
|
|
20
32
|
};
|
|
21
33
|
export type AuthParams = Pick<AuraWidgetInitParams, 'tenantId' | 'tenantName' | 'user' | 'language'>;
|
|
22
34
|
export type AuraWidgetMessageEvent<T = any> = {
|
|
23
35
|
type: string;
|
|
24
36
|
payload: T;
|
|
25
37
|
};
|
|
38
|
+
export type AuraTemplateDefinition = {
|
|
39
|
+
name: string;
|
|
40
|
+
type: 'openText' | 'singleSelect' | 'multiSelect' | 'openSingleSelect' | 'openMultiSelect' | 'boolean';
|
|
41
|
+
options?: string[];
|
|
42
|
+
meta?: {
|
|
43
|
+
additionalInstructions?: string;
|
|
44
|
+
examples?: string[];
|
|
45
|
+
};
|
|
46
|
+
};
|
|
26
47
|
export type AuraTemplate = {
|
|
27
48
|
id: string;
|
|
28
|
-
name
|
|
49
|
+
name?: string;
|
|
50
|
+
description?: string;
|
|
51
|
+
encounterPhase: 'pre-chart' | 'in-visit';
|
|
29
52
|
body: {
|
|
30
53
|
sections: Record<string, any>[];
|
|
31
54
|
};
|
|
32
|
-
description: string;
|
|
33
|
-
encounterPhase: 'pre-chart' | 'in-visit';
|
|
34
55
|
};
|
|
35
|
-
export type
|
|
56
|
+
export type RegisterTemplatesPayload = {
|
|
36
57
|
templates: AuraTemplate[];
|
|
37
58
|
};
|
|
59
|
+
export type AutoRegisterTemplatesPayload = {
|
|
60
|
+
templates: Array<Pick<AuraTemplate, 'id' | 'name' | 'description' | 'encounterPhase'> & AtLeastOneOf<{
|
|
61
|
+
definition?: AuraTemplateDefinition;
|
|
62
|
+
exampleNotes: any[];
|
|
63
|
+
}, 'definition' | 'exampleNotes'>>;
|
|
64
|
+
};
|
|
38
65
|
export type Extended<T> = T & {
|
|
39
66
|
[key: string]: unknown;
|
|
40
67
|
};
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,CAAC,CAAC,GAAG,GAAG,IAAI;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,CAAC,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAA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