obi-sdk 0.10.0 → 0.11.0
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/modular/chunks/index-4be516d9.js +6 -0
- package/dist/modular/chunks/index-4be516d9.js.map +1 -0
- package/dist/modular/chunks/{obi-widget-d8d64ad7.js → obi-widget-585f773a.js} +191 -20
- package/dist/modular/chunks/obi-widget-585f773a.js.map +1 -0
- package/dist/modular/index.js +1 -1
- package/dist/modular/ui.js +10 -10
- package/dist/obi-sdk.standalone.iife.js +31 -31
- package/dist/obi-sdk.standalone.iife.js.map +1 -1
- package/dist/react.es.js +1266 -1151
- package/dist/react.es.js.map +1 -1
- package/dist/react.umd.js +68 -68
- package/dist/react.umd.js.map +1 -1
- package/dist/ui/components/obi-widget/obi-widget.d.ts +11 -0
- package/package.json +1 -1
- package/dist/modular/chunks/index-e3a03e58.js +0 -6
- package/dist/modular/chunks/index-e3a03e58.js.map +0 -1
- package/dist/modular/chunks/obi-widget-d8d64ad7.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-4be516d9.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
|
@@ -460,6 +460,12 @@ class ObiClient {
|
|
|
460
460
|
params: { path: { id } }
|
|
461
461
|
});
|
|
462
462
|
}
|
|
463
|
+
async getOnboardeeWidgetConfig(id, signal) {
|
|
464
|
+
return await this.client.GET("/onboardees/{id}/config", {
|
|
465
|
+
params: { path: { id } },
|
|
466
|
+
signal
|
|
467
|
+
});
|
|
468
|
+
}
|
|
463
469
|
// Plans
|
|
464
470
|
async listPlans() {
|
|
465
471
|
return await this.client.GET("/plans");
|
|
@@ -468,6 +474,17 @@ class ObiClient {
|
|
|
468
474
|
async listProducts() {
|
|
469
475
|
return await this.client.GET("/products");
|
|
470
476
|
}
|
|
477
|
+
async createProduct(data) {
|
|
478
|
+
return await this.client.POST("/products", {
|
|
479
|
+
body: data
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
async updateProduct(id, data) {
|
|
483
|
+
return await this.client.PATCH("/products/{id}", {
|
|
484
|
+
params: { path: { id } },
|
|
485
|
+
body: data
|
|
486
|
+
});
|
|
487
|
+
}
|
|
471
488
|
async createPlan(data) {
|
|
472
489
|
return await this.client.POST("/plans", {
|
|
473
490
|
body: data
|
|
@@ -495,6 +512,44 @@ class ObiClient {
|
|
|
495
512
|
params: { path: { id } }
|
|
496
513
|
});
|
|
497
514
|
}
|
|
515
|
+
async deletePlan(id) {
|
|
516
|
+
return await this.client.DELETE("/admin/plans/{id}", {
|
|
517
|
+
params: { path: { id } }
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
async publishPlanRevision(id, data) {
|
|
521
|
+
return await this.client.POST("/plans/{id}/publish", {
|
|
522
|
+
params: { path: { id } },
|
|
523
|
+
body: data
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
async listPlanRevisions(id) {
|
|
527
|
+
return await this.client.GET("/plans/{id}/revisions", {
|
|
528
|
+
params: { path: { id } }
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
async getRevisionNavigationIndex(revisionId) {
|
|
532
|
+
return await this.client.GET("/revisions/{id}/navigation-index", {
|
|
533
|
+
params: { path: { id: revisionId } }
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
async replaceRevisionNavigationIndex(revisionId, data) {
|
|
537
|
+
return await this.client.PUT("/revisions/{id}/navigation-index", {
|
|
538
|
+
params: { path: { id: revisionId } },
|
|
539
|
+
body: data
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
async getRevisionFAQ(revisionId) {
|
|
543
|
+
return await this.client.GET("/revisions/{id}/faq", {
|
|
544
|
+
params: { path: { id: revisionId } }
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
async replaceRevisionFAQ(revisionId, data) {
|
|
548
|
+
return await this.client.PUT("/revisions/{id}/faq", {
|
|
549
|
+
params: { path: { id: revisionId } },
|
|
550
|
+
body: data
|
|
551
|
+
});
|
|
552
|
+
}
|
|
498
553
|
// Sessions
|
|
499
554
|
async listSessions(token) {
|
|
500
555
|
return await this.client.GET("/sessions", {
|
|
@@ -16056,8 +16111,8 @@ function isCurrentUrlBlacklisted(blacklist) {
|
|
|
16056
16111
|
if (!blacklist || blacklist.length === 0) {
|
|
16057
16112
|
return false;
|
|
16058
16113
|
}
|
|
16059
|
-
const
|
|
16060
|
-
return matchesUrlPattern(
|
|
16114
|
+
const pathOnlyUrl = window.location.origin + window.location.pathname;
|
|
16115
|
+
return matchesUrlPattern(pathOnlyUrl, blacklist);
|
|
16061
16116
|
}
|
|
16062
16117
|
var __defProp$7 = Object.defineProperty;
|
|
16063
16118
|
var __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor;
|
|
@@ -17926,6 +17981,9 @@ class ObiWidget extends i$1 {
|
|
|
17926
17981
|
volume: 0,
|
|
17927
17982
|
spectrum: []
|
|
17928
17983
|
};
|
|
17984
|
+
this.databaseConfig = null;
|
|
17985
|
+
this.configLoaded = false;
|
|
17986
|
+
this.configInCode = false;
|
|
17929
17987
|
this.sessionToken = null;
|
|
17930
17988
|
this.roomToken = null;
|
|
17931
17989
|
this.roomUrl = null;
|
|
@@ -17933,6 +17991,8 @@ class ObiWidget extends i$1 {
|
|
|
17933
17991
|
this.obiClient = null;
|
|
17934
17992
|
this.closeNavTimeoutRef = null;
|
|
17935
17993
|
this.researchingTimeoutRef = null;
|
|
17994
|
+
this.urlCheckInterval = null;
|
|
17995
|
+
this.currentUrl = "";
|
|
17936
17996
|
this.connectObi = withSentryAsyncHandler(
|
|
17937
17997
|
async (sessionToken) => {
|
|
17938
17998
|
if (this.activeSession) {
|
|
@@ -18188,6 +18248,7 @@ class ObiWidget extends i$1 {
|
|
|
18188
18248
|
this.obiClient = new ObiClient({
|
|
18189
18249
|
baseUrl: API_BASE_URL
|
|
18190
18250
|
});
|
|
18251
|
+
this.currentUrl = window.location.href;
|
|
18191
18252
|
const handleUnload = () => {
|
|
18192
18253
|
try {
|
|
18193
18254
|
if (this.activeSession && this.sessionToken && this.roomToken && this.roomUrl) {
|
|
@@ -18205,29 +18266,29 @@ class ObiWidget extends i$1 {
|
|
|
18205
18266
|
throw error;
|
|
18206
18267
|
}
|
|
18207
18268
|
}
|
|
18208
|
-
// Method to get values from window.obiWidgetConfig
|
|
18209
18269
|
updateFromConfig() {
|
|
18210
18270
|
if (window.obiWidgetConfig) {
|
|
18211
18271
|
this.apiKey = window.obiWidgetConfig.apiKey || this.apiKey;
|
|
18212
|
-
|
|
18213
|
-
|
|
18214
|
-
|
|
18215
|
-
|
|
18216
|
-
|
|
18217
|
-
if (
|
|
18218
|
-
this.
|
|
18219
|
-
|
|
18220
|
-
if (
|
|
18221
|
-
this.
|
|
18272
|
+
const hasPosition = window.obiWidgetConfig.position !== void 0;
|
|
18273
|
+
const hasPrimaryColor = window.obiWidgetConfig.primaryColor !== void 0;
|
|
18274
|
+
const hasLinkOnlyAccess = window.obiWidgetConfig.linkOnlyAccess !== void 0;
|
|
18275
|
+
const hasUrlBlacklist = window.obiWidgetConfig.urlBlacklist !== void 0;
|
|
18276
|
+
this.configInCode = hasPosition && hasPrimaryColor && hasLinkOnlyAccess && hasUrlBlacklist;
|
|
18277
|
+
if (this.configInCode) {
|
|
18278
|
+
this.configLoaded = true;
|
|
18279
|
+
this.applyFinalConfiguration();
|
|
18280
|
+
} else if (!this.configLoaded) {
|
|
18281
|
+
this.fetchDatabaseConfig();
|
|
18222
18282
|
}
|
|
18223
18283
|
if (window.obiWidgetConfig.showMenu === true) {
|
|
18224
18284
|
this.state = SDKState.LOADING;
|
|
18225
18285
|
this.showCourseModal = true;
|
|
18226
18286
|
window.obiWidgetConfig.showMenu = false;
|
|
18227
18287
|
}
|
|
18228
|
-
|
|
18229
|
-
this.
|
|
18230
|
-
|
|
18288
|
+
} else {
|
|
18289
|
+
if (!this.configLoaded) {
|
|
18290
|
+
this.fetchDatabaseConfig();
|
|
18291
|
+
}
|
|
18231
18292
|
}
|
|
18232
18293
|
}
|
|
18233
18294
|
/**
|
|
@@ -18332,6 +18393,15 @@ class ObiWidget extends i$1 {
|
|
|
18332
18393
|
clearSessionStorage() {
|
|
18333
18394
|
storage.removeItem(STORAGE_KEYS.SESSION_DATA);
|
|
18334
18395
|
}
|
|
18396
|
+
/**
|
|
18397
|
+
* Handle URL changes to check if the new URL is blacklisted
|
|
18398
|
+
*/
|
|
18399
|
+
handleUrlChange() {
|
|
18400
|
+
this.requestUpdate();
|
|
18401
|
+
if (isCurrentUrlBlacklisted(this.urlBlacklist) && this.activeSession) {
|
|
18402
|
+
this.terminateSession();
|
|
18403
|
+
}
|
|
18404
|
+
}
|
|
18335
18405
|
// Method to save session data
|
|
18336
18406
|
saveSessionData() {
|
|
18337
18407
|
if (!this.activeSession)
|
|
@@ -18386,10 +18456,15 @@ class ObiWidget extends i$1 {
|
|
|
18386
18456
|
this.boundSaveSessionData = this.saveSessionData.bind(this);
|
|
18387
18457
|
window.addEventListener("beforeunload", this.boundSaveSessionData);
|
|
18388
18458
|
window.addEventListener("pagehide", this.boundSaveSessionData);
|
|
18389
|
-
|
|
18390
|
-
|
|
18391
|
-
|
|
18459
|
+
if (this.isActive) {
|
|
18460
|
+
this.urlCheckInterval = window.setInterval(() => {
|
|
18461
|
+
if (this.currentUrl !== window.location.href) {
|
|
18462
|
+
this.currentUrl = window.location.href;
|
|
18463
|
+
this.handleUrlChange();
|
|
18464
|
+
}
|
|
18465
|
+
}, 1e3);
|
|
18392
18466
|
}
|
|
18467
|
+
this.addEventListener("course-select", this.handleCourseSelectEvent);
|
|
18393
18468
|
}
|
|
18394
18469
|
disconnectedCallback() {
|
|
18395
18470
|
super.disconnectedCallback();
|
|
@@ -18405,6 +18480,10 @@ class ObiWidget extends i$1 {
|
|
|
18405
18480
|
window.removeEventListener("beforeunload", this.boundSaveSessionData);
|
|
18406
18481
|
window.removeEventListener("pagehide", this.boundSaveSessionData);
|
|
18407
18482
|
}
|
|
18483
|
+
if (this.urlCheckInterval !== null) {
|
|
18484
|
+
clearInterval(this.urlCheckInterval);
|
|
18485
|
+
this.urlCheckInterval = null;
|
|
18486
|
+
}
|
|
18408
18487
|
this.removeSessionUrlParams();
|
|
18409
18488
|
}
|
|
18410
18489
|
handleConfigUpdate(event) {
|
|
@@ -18470,7 +18549,90 @@ class ObiWidget extends i$1 {
|
|
|
18470
18549
|
return;
|
|
18471
18550
|
});
|
|
18472
18551
|
}
|
|
18552
|
+
async fetchDatabaseConfig() {
|
|
18553
|
+
if (!this.apiKey) {
|
|
18554
|
+
this.configLoaded = true;
|
|
18555
|
+
this.applyFinalConfiguration();
|
|
18556
|
+
return;
|
|
18557
|
+
}
|
|
18558
|
+
try {
|
|
18559
|
+
const cacheKey = `obi-widget-config-${this.apiKey}`;
|
|
18560
|
+
const cachedConfig = localStorage.getItem(cacheKey);
|
|
18561
|
+
const cacheTimestamp = localStorage.getItem(`${cacheKey}-timestamp`);
|
|
18562
|
+
if (cachedConfig && cacheTimestamp) {
|
|
18563
|
+
const age = Date.now() - parseInt(cacheTimestamp, 10);
|
|
18564
|
+
const maxAge = 10 * 60 * 1e3;
|
|
18565
|
+
if (age < maxAge) {
|
|
18566
|
+
const dbConfig2 = JSON.parse(cachedConfig);
|
|
18567
|
+
this.databaseConfig = dbConfig2;
|
|
18568
|
+
this.configLoaded = true;
|
|
18569
|
+
this.applyFinalConfiguration();
|
|
18570
|
+
return;
|
|
18571
|
+
}
|
|
18572
|
+
}
|
|
18573
|
+
const controller = new AbortController();
|
|
18574
|
+
const timeoutId = setTimeout(() => controller.abort(), 3e3);
|
|
18575
|
+
const result = await this.obiClient.getOnboardeeWidgetConfig(this.apiKey, controller.signal);
|
|
18576
|
+
clearTimeout(timeoutId);
|
|
18577
|
+
if (result.error) {
|
|
18578
|
+
if (result.response?.status === 404) {
|
|
18579
|
+
localStorage.removeItem(cacheKey);
|
|
18580
|
+
localStorage.removeItem(`${cacheKey}-timestamp`);
|
|
18581
|
+
this.databaseConfig = null;
|
|
18582
|
+
this.configLoaded = true;
|
|
18583
|
+
this.applyFinalConfiguration();
|
|
18584
|
+
return;
|
|
18585
|
+
}
|
|
18586
|
+
throw new Error(`HTTP ${result.response?.status || "Unknown error"}`);
|
|
18587
|
+
}
|
|
18588
|
+
const dbConfig = result.data;
|
|
18589
|
+
localStorage.setItem(cacheKey, JSON.stringify(dbConfig));
|
|
18590
|
+
localStorage.setItem(`${cacheKey}-timestamp`, Date.now().toString());
|
|
18591
|
+
this.databaseConfig = dbConfig;
|
|
18592
|
+
this.configLoaded = true;
|
|
18593
|
+
this.applyFinalConfiguration();
|
|
18594
|
+
} catch (error) {
|
|
18595
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
18596
|
+
console.warn("Widget config fetch timed out, using defaults");
|
|
18597
|
+
} else {
|
|
18598
|
+
console.warn("Failed to fetch widget config from database:", error);
|
|
18599
|
+
}
|
|
18600
|
+
this.databaseConfig = null;
|
|
18601
|
+
this.configLoaded = true;
|
|
18602
|
+
this.applyFinalConfiguration();
|
|
18603
|
+
}
|
|
18604
|
+
}
|
|
18605
|
+
// Apply final configuration by merging code config (priority) with database config
|
|
18606
|
+
applyFinalConfiguration() {
|
|
18607
|
+
const windowConfig = window.obiWidgetConfig;
|
|
18608
|
+
const dbConfig = this.databaseConfig;
|
|
18609
|
+
this.user = windowConfig?.user || this.user;
|
|
18610
|
+
this.position = windowConfig?.position || dbConfig?.position || this.position;
|
|
18611
|
+
this.setAttribute("position", this.position);
|
|
18612
|
+
if (windowConfig?.isActive !== void 0) {
|
|
18613
|
+
this.isActive = windowConfig.isActive;
|
|
18614
|
+
}
|
|
18615
|
+
if (windowConfig?.linkOnlyAccess !== void 0) {
|
|
18616
|
+
this.linkOnlyAccess = windowConfig.linkOnlyAccess;
|
|
18617
|
+
} else if (dbConfig?.linkOnlyAccess !== void 0) {
|
|
18618
|
+
this.linkOnlyAccess = dbConfig.linkOnlyAccess;
|
|
18619
|
+
}
|
|
18620
|
+
const codeBlacklist = windowConfig?.urlBlacklist || [];
|
|
18621
|
+
const dbBlacklist = dbConfig?.urlBlacklist || [];
|
|
18622
|
+
if (codeBlacklist.length > 0 || dbBlacklist.length > 0) {
|
|
18623
|
+
const merged = [...codeBlacklist, ...dbBlacklist];
|
|
18624
|
+
this.urlBlacklist = [...new Set(merged)];
|
|
18625
|
+
}
|
|
18626
|
+
const primaryColor = windowConfig?.primaryColor || dbConfig?.primaryColor || OBI_PRIMARY_COLOR;
|
|
18627
|
+
this.style.setProperty("--obi-primary", primaryColor);
|
|
18628
|
+
this.generateColorVariables(primaryColor);
|
|
18629
|
+
if (this.isActive && !isCurrentUrlBlacklisted(this.urlBlacklist)) {
|
|
18630
|
+
this.sessionConnectionCheck();
|
|
18631
|
+
}
|
|
18632
|
+
}
|
|
18473
18633
|
render() {
|
|
18634
|
+
if (!this.configLoaded)
|
|
18635
|
+
return E;
|
|
18474
18636
|
if (!this.isActive)
|
|
18475
18637
|
return E;
|
|
18476
18638
|
if (this.linkOnlyAccess && this.state === SDKState.READY)
|
|
@@ -18726,6 +18888,15 @@ __decorateClass([
|
|
|
18726
18888
|
__decorateClass([
|
|
18727
18889
|
r$1()
|
|
18728
18890
|
], ObiWidget.prototype, "volume", 2);
|
|
18891
|
+
__decorateClass([
|
|
18892
|
+
r$1()
|
|
18893
|
+
], ObiWidget.prototype, "databaseConfig", 2);
|
|
18894
|
+
__decorateClass([
|
|
18895
|
+
r$1()
|
|
18896
|
+
], ObiWidget.prototype, "configLoaded", 2);
|
|
18897
|
+
__decorateClass([
|
|
18898
|
+
r$1()
|
|
18899
|
+
], ObiWidget.prototype, "configInCode", 2);
|
|
18729
18900
|
if (!customElements.get("obi-widget")) {
|
|
18730
18901
|
customElements.define("obi-widget", ObiWidget);
|
|
18731
18902
|
}
|
|
@@ -18756,4 +18927,4 @@ export {
|
|
|
18756
18927
|
withSentryAsyncHandler as w,
|
|
18757
18928
|
x
|
|
18758
18929
|
};
|
|
18759
|
-
//# sourceMappingURL=obi-widget-
|
|
18930
|
+
//# sourceMappingURL=obi-widget-585f773a.js.map
|