obi-sdk 0.12.4 → 0.12.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/dist/react.umd.js CHANGED
@@ -514,7 +514,7 @@ Url: ${io(A)}`),!0}return!1}function $F(A,e){return e?.length?Gg(A).some(t=>Xs(t
514
514
  .error {
515
515
  color: #ef4444;
516
516
  }
517
- `,Ft([z({type:Array})],ln.prototype,"courses",2),Ft([z({type:String})],ln.prototype,"selectedCourseId",2),Ft([z({type:Boolean})],ln.prototype,"loading",2),Ft([z({type:String})],ln.prototype,"error",2),Ft([z({type:String})],ln.prototype,"searchTerm",2),customElements.get("obi-course")||customElements.define("obi-course",PA),customElements.get("obi-course-list")||customElements.define("obi-course-list",ln);var WI=Object.defineProperty,JI=Object.getOwnPropertyDescriptor,LA=(A,e,t,n)=>{for(var i=n>1?void 0:n?JI(e,t):e,r=A.length-1,s;r>=0;r--)(s=A[r])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&WI(e,t,i),i};let kt=class extends L.LitElement{constructor(){super(...arguments),this.courses=[],this.loading=!0,this.error="",this.apiKey="",this.apiBaseUrl="",this.selectedCourse=null,this.agentName=""}handleClose(){this.onClose&&this.onClose()}handleGetStarted(){this.selectedCourse&&this.dispatchEvent(new CustomEvent("course-select",{detail:this.selectedCourse,bubbles:!0,composed:!0}))}async fetchCourses(){try{this.loading=!0,console.log("[CourseModal] Fetching sessions from API",{apiKey:this.apiKey?"present":"missing"});const e=await fetch(`${this.apiBaseUrl}/sessions?token=${this.apiKey}`,{cache:"no-cache"});if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);const t=await e.json();let n="";const r=(t.sessions?.map(s=>(n||(n=s.onboarding_plan.product.agent_name),{id:s.uuid,name:s.onboarding_plan.name,description:s.onboarding_plan.description,duration:s.onboarding_plan.duration,order:s.onboarding_plan.order}))).filter(s=>!!s.name);this.agentName=n||"Obi",this.courses=[...r],this.error="",console.log("[CourseModal] Sessions fetched successfully",{sessionCount:r.length,sessions:r.map(s=>({id:s.id,name:s.name}))}),this.requestUpdate()}catch(e){console.error("[CourseModal] Fetch error:",e),this.error=`Failed to fetch courses: ${e instanceof Error?e.message:"Unknown error"}`}finally{this.loading=!1,this.requestUpdate()}}handleCourseCardClick(e){const{id:t,name:n,description:i,duration:r}=e.detail;this.selectedCourse={id:t,name:n,description:i,duration:r}}connectedCallback(){super.connectedCallback(),window.obiWidgetConfig?.apiKey&&(this.apiKey=window.obiWidgetConfig.apiKey),this.apiBaseUrl=Ka,this.apiBaseUrl&&this.apiKey?this.fetchCourses():(this.loading=!1,this.error="API base URL or API key is missing")}render(){return L.html`
517
+ `,Ft([z({type:Array})],ln.prototype,"courses",2),Ft([z({type:String})],ln.prototype,"selectedCourseId",2),Ft([z({type:Boolean})],ln.prototype,"loading",2),Ft([z({type:String})],ln.prototype,"error",2),Ft([z({type:String})],ln.prototype,"searchTerm",2),customElements.get("obi-course")||customElements.define("obi-course",PA),customElements.get("obi-course-list")||customElements.define("obi-course-list",ln);var WI=Object.defineProperty,JI=Object.getOwnPropertyDescriptor,LA=(A,e,t,n)=>{for(var i=n>1?void 0:n?JI(e,t):e,r=A.length-1,s;r>=0;r--)(s=A[r])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&WI(e,t,i),i};let kt=class extends L.LitElement{constructor(){super(...arguments),this.courses=[],this.loading=!0,this.error="",this.apiKey="",this.apiBaseUrl="",this.selectedCourse=null,this.agentName=""}handleClose(){this.onClose&&this.onClose()}handleGetStarted(){this.selectedCourse&&this.dispatchEvent(new CustomEvent("course-select",{detail:this.selectedCourse,bubbles:!0,composed:!0}))}async fetchCourses(){try{this.loading=!0,console.log("[CourseModal] Fetching sessions from API",{apiKey:this.apiKey?"present":"missing"});const e=await fetch(`${this.apiBaseUrl}/api/sessions?token=${this.apiKey}`,{cache:"no-cache"});if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);const t=await e.json();let n="";const r=(t.sessions?.map(s=>(n||(n=s.onboarding_plan.product.agent_name),{id:s.uuid,name:s.onboarding_plan.name,description:s.onboarding_plan.description,duration:s.onboarding_plan.duration,order:s.onboarding_plan.order}))).filter(s=>!!s.name);this.agentName=n||"Obi",this.courses=[...r],this.error="",console.log("[CourseModal] Sessions fetched successfully",{sessionCount:r.length,sessions:r.map(s=>({id:s.id,name:s.name}))}),this.requestUpdate()}catch(e){console.error("[CourseModal] Fetch error:",e),this.error=`Failed to fetch courses: ${e instanceof Error?e.message:"Unknown error"}`}finally{this.loading=!1,this.requestUpdate()}}handleCourseCardClick(e){const{id:t,name:n,description:i,duration:r}=e.detail;this.selectedCourse={id:t,name:n,description:i,duration:r}}connectedCallback(){super.connectedCallback(),window.obiWidgetConfig?.apiKey&&(this.apiKey=window.obiWidgetConfig.apiKey),this.apiBaseUrl=Ka,this.apiBaseUrl&&this.apiKey?this.fetchCourses():(this.loading=!1,this.error="API base URL or API key is missing")}render(){return L.html`
518
518
  <div class="backdrop"></div>
519
519
  <div class="container">
520
520
  <div class="header">