@callimacus/thamyr-liquid 4.6.0 → 4.8.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/CHANGELOG.core.md +14 -0
- package/CHANGELOG.md +29 -0
- package/README.md +124 -2
- package/dist/browser/callimacus-runtime.min.js +2 -2
- package/dist/browser/callimacus-runtime.min.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/types/index.d.ts +98 -7
- package/package.json +2 -2
package/dist/esm/index.js
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* See LICENSE.md for the full terms.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import{ThamyrResponseType as e,ChapterStatus as t,UserInteractionType as r,CallimacusService as n}from"@callimacus/thamyr-core";const o="https://api.callimacus.ai",a="/cart/add.js",c="[callimacus]";class i extends Error{code;constructor(e,t,r){super(t,r),this.name="CallimacusError",this.code=e}}function s(e){if(void 0===e||""===e)return{};try{const t=JSON.parse(e);if("object"==typeof t&&null!==t&&!Array.isArray(t))return t;console.warn(`${c} [data-callimacus-settings] must be a JSON object — using {}`)}catch(e){console.warn(`${c} [data-callimacus-settings] is not valid JSON — using {}`,e)}return{}}function u(e,t){return void 0===e||""===e?t:e}function l(e){return`server_${e.code??"error"}`}function d(e,t){e.dataset.callimacusState=t,e.setAttribute("aria-busy",String("loading"===t))}function m(e,t,r){e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:r}))}function f(e){const{data:t}=e;return"object"!=typeof t||null===t?[]:Object.values(t)}function p(e){let t=e.language;try{Intl.NumberFormat.supportedLocalesOf(t)}catch{console.warn(`${c} invalid data-language "${t}" — formatting with "en"`),t="en"}const r=new Map;return Object.freeze({locale:t,currency:e.currency,settings:e.settings,picks(e){for(const t of f(e)){if(!Array.isArray(t))continue;const e=t.filter(e=>Boolean(e?.fields?.["shopify-handle"]));if(e.length>0)return e}return[]},text(e){for(const t of f(e)){if("string"==typeof t&&""!==t.trim())return t.trim();const e=t?.text;if("string"==typeof e&&""!==e.trim())return e.trim()}},money(n){const o="number"==typeof n?n:n?.amount;if("number"!=typeof o)return"";const a="object"==typeof n?n?.currency:void 0,i=void 0===a||""===a?e.currency??"USD":a;return function(e){if(!r.has(e))try{r.set(e,new Intl.NumberFormat(t,{style:"currency",currency:e}))}catch{console.warn(`${c} invalid currency code "${e}" — showing bare amounts`),r.set(e,void 0)}return r.get(e)}(i)?.format(o)??o.toFixed(2)},productUrl(t){const r=t?.fields?.["shopify-handle"];if(void 0===r||""===r)return;return`${e.rootUrl.endsWith("/")?e.rootUrl.slice(0,-1):e.rootUrl}/products/${r}`},imageUrl(e,{width:t=800,index:r=0}={}){const n=e?.fields?.images?.[r]?.url;return void 0===n||""===n?void 0:`${n.split("?",1)[0]}?width=${t}`},variantId(e){const t=e?.fields?.variantTree?.variants??[],r=t.find(e=>e.orderable)??t[0];return void 0===r?.id?void 0:String(r.id).split("/").pop()},async addToCart(t,r=1){let n;try{n=await fetch(e.cartAddUrl,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({items:[{id:Number(t),quantity:r}]})})}catch(e){throw new i("cart_unreachable","Could not reach the cart",{cause:e})}const o=await n.json().catch(()=>(console.warn(`${c} cart response was not JSON (HTTP ${n.status})`),{}));if(!n.ok){const{description:e,message:t}=o??{};throw new i("cart_rejected",e??t??`Could not add to cart (HTTP ${n.status})`)}return document.dispatchEvent(new CustomEvent("cart:refresh",{bubbles:!0,detail:o})),o}})}function y(e){return function(){const e=globalThis;return e.callimacusRenderers??=[],e.callimacusRenderers}().find(t=>{const r=t;return r?.type===e&&"function"==typeof r.render})}function g(f,g={}){if(!Object.hasOwn(f.dataset,"callimacusReady")){f.dataset.callimacusReady="";try{!function(f,g){const{dataset:h}=f,v={clientId:h.clientId,endpoint:u(h.endpoint,o),language:u(h.language,"en"),currency:""===h.currency?void 0:h.currency,rootUrl:u(h.rootUrl,"/"),cartAddUrl:u(h.cartAddUrl,a),settings:s(f.querySelector("[data-callimacus-settings]")?.textContent??void 0)};if("true"===h.designMode)return void d(f,"design-mode");if(void 0===v.clientId||""===v.clientId)return d(f,"error"),void console.warn(`${c} no client id — leaving your markup in place`);f.querySelector("[data-callimacus-output]")||console.warn(`${c} no [data-callimacus-output] inside this mount — rendered blocks will replace the mount element's entire contents`);const{clientId:w}=v,$=g.roundTimeoutMs??45e3,b=p(v),S=new Set;let E,T,C=!1;function A(){return E||(E=g.transport??new n,E.onError(e=>{T=`${l(e)}: ${e.message??""}`,C||console.warn(`${c} transport error between rounds — ${T}`)}),E.connect(v.endpoint,{Authorization:`Bearer ${w}`},{token:w}),E)}async function U(n){const o=A();return new Promise((a,c)=>{function s(){clearTimeout(u),d(),m()}const u=setTimeout(()=>{s();c(new i("timeout",`Callimacus did not answer in time${void 0===T?"":` (last transport error: ${T})`}`))},$),d=o.onServerResponse(r=>{if(r.type!==e.CHAPTER_EVENT)return;const o=r.chapter;if(o?.status!==t.done||S.has(o.id))return;const c=o.inputEvent?.data?.value;"string"==typeof c&&c!==n||(S.add(o.id),s(),a(o))}),m=o.onError(e=>{s(),c(new i(l(e),e.message??"Callimacus error",{cause:e}))});try{o.sendUserInteraction(r.CREATE_ROUND,{inputEvent:{type:"question",data:{value:n}},language:v.language})}catch(e){s(),c(new i("send_failed","Could not send the request",{cause:e}))}})}async function j(e){if(!C&&""!==e){C=!0,d(f,"loading"),m(f,"callimacus:loading",{value:e});try{const t=await U(e),r=[...t.blocks??[]].sort((e,t)=>(e.priority??0)-(t.priority??0)),{fragment:n,rendered:o}=function(e,t){const r=document.createDocumentFragment();let n=0;for(const o of e){const e=y(o.type);if(e)try{const a=e.render(o,t);a instanceof Node?(r.append(a),n++):null!=a&&console.error(`${c} renderer for ${o.type} returned a non-Node value — skipped`)}catch(e){console.error(`${c} renderer for ${o.type} threw`,e)}else console.info(`${c} no renderer for ${o.type} — skipped`)}return{fragment:r,rendered:n}}(r,b);if(0===o)return d(f,"empty"),void m(f,"callimacus:empty",{chapter:t});(f.querySelector("[data-callimacus-output]")??f).replaceChildren(n),d(f,"ready"),m(f,"callimacus:ready",{chapter:t,blocks:r,rendered:o})}catch(e){d(f,"error"),m(f,"callimacus:error",{error:e});const{code:t,message:r}=e instanceof i?e:{code:"error",message:String(e)};console.error(`${c} ${t}: ${r} — your markup is untouched`)}finally{C=!1}}}const k={ask:j,ctx:b,get state(){return f.dataset.callimacusState}};f.callimacus=k,m(f,"callimacus:mounted",k),void 0!==h.prompt&&""!==h.prompt&&j(h.prompt)}(f,g)}catch(e){d(f,"error"),m(f,"callimacus:error",{error:e}),console.error(`${c} mount failed — your markup is untouched`,e)}}}function h(e,t={}){for(const r of e.querySelectorAll("[data-callimacus]"))g(r,t)}export{i as CallimacusError,p as makeCtx,g as mount,h as mountAll};
|
|
8
|
+
import{CallimacusService as t,ThamyrResponseType as e,ChapterStatus as n,UserInteractionType as r,interactionRound as o,landingRound as a}from"@callimacus/thamyr-core";const i="https://api.callimacus.ai",s="/cart/add.js",c="[callimacus]";class u extends Error{code;constructor(t,e,n){super(e,n),this.name="CallimacusError",this.code=t}}function l(t){return d(t,"[data-callimacus-settings]","using {}")??{}}function d(t,e,n){if(void 0!==t&&""!==t)try{const r=JSON.parse(t);if("object"==typeof r&&null!==r&&!Array.isArray(r))return r;console.warn(`${c} ${e} must be a JSON object — ${n}`)}catch(t){console.warn(`${c} ${e} is not valid JSON — ${n}`,t)}}function f(t,e){return void 0===t||""===t?e:t}function p(t){return`server_${t.code??"error"}`}function y(t,e){t.dataset.callimacusState=e,t.setAttribute("aria-busy",String("loading"===e))}function m(t,e,n){t.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:n}))}function g(t){const{data:e}=t;return"object"!=typeof e||null===e?[]:Object.values(e)}function h(t){let e=t.language;try{Intl.NumberFormat.supportedLocalesOf(e)}catch{console.warn(`${c} invalid data-language "${e}" — formatting with "en"`),e="en"}const n=new Map;const r=function(t,e){let n;try{n=new URL(t,"https://storefront.invalid").pathname.split("/").find(t=>""!==t)}catch{n=void 0}const r=void 0!==n&&/^[a-z]{2,3}(?:-[\da-z]{2,4})?$/iu.test(n)?n:e;try{return Intl.getCanonicalLocales(r)[0]??r}catch{return r}}(t.rootUrl,t.language);async function o(e,n,o,a={}){const i="string"==typeof n?n:n?.id,{clientId:s}=t;if(void 0===i||""===i)throw new u("send_failed","The item has no id to look up");if(void 0===s||""===s)throw new u("send_failed","No client id to look up with");const c=new AbortController,l=setTimeout(()=>{c.abort()},o.timeoutMs??1e4);try{let n;try{n=await fetch(`${new URL("api/v3",t.endpoint).href}/skesis/query/${e}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`,"x-sl-access-token":s},body:JSON.stringify({anchorId:i,locale:o.locale??r,...a}),signal:c.signal})}catch(t){throw new u("lookup_unreachable","Could not reach the catalogue",{cause:t})}if(!n.ok)throw new u(`server_${n.status}`,`The catalogue refused the lookup (HTTP ${n.status})`);return await n.json().catch(t=>{throw new u("lookup_unreachable","The catalogue sent an unreadable answer",{cause:t})})}finally{clearTimeout(l)}}const a=t=>(Array.isArray(t)?t:[]).filter(t=>"object"==typeof t?.item).map(t=>void 0===t.score?t.item:{...t.item,score:t.score});return Object.freeze({locale:e,currency:t.currency,settings:t.settings,picks(t){for(const e of g(t)){if(!Array.isArray(e))continue;const t=e.filter(t=>Boolean(t?.fields?.["shopify-handle"]));if(t.length>0)return t}return[]},text(t){for(const e of g(t)){if("string"==typeof e&&""!==e.trim())return e.trim();const t=e?.text;if("string"==typeof t&&""!==t.trim())return t.trim()}},money(r){const o="number"==typeof r?r:r?.amount;if("number"!=typeof o)return"";const a="object"==typeof r?r?.currency:void 0,i=void 0===a||""===a?t.currency??"USD":a;return function(t){if(!n.has(t))try{n.set(t,new Intl.NumberFormat(e,{style:"currency",currency:t}))}catch{console.warn(`${c} invalid currency code "${t}" — showing bare amounts`),n.set(t,void 0)}return n.get(t)}(i)?.format(o)??o.toFixed(2)},productUrl(e){const n=e?.fields?.["shopify-handle"];if(void 0===n||""===n)return;return`${t.rootUrl.endsWith("/")?t.rootUrl.slice(0,-1):t.rootUrl}/products/${n}`},imageUrl(t,{width:e=800,index:n=0}={}){const r=t?.fields?.images?.[n]?.url;return void 0===r||""===r?void 0:`${r.split("?",1)[0]}?width=${e}`},variantId(t){const e=t?.fields?.variantTree?.variants??[],n=e.find(t=>t.orderable)??e[0];return void 0===n?.id?void 0:String(n.id).split("/").pop()},async addToCart(e,n=1){let r;try{r=await fetch(t.cartAddUrl,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({items:[{id:Number(e),quantity:n}]})})}catch(t){throw new u("cart_unreachable","Could not reach the cart",{cause:t})}const o=await r.json().catch(()=>(console.warn(`${c} cart response was not JSON (HTTP ${r.status})`),{}));if(!r.ok){const{description:t,message:e}=o??{};throw new u("cart_rejected",t??e??`Could not add to cart (HTTP ${r.status})`)}return document.dispatchEvent(new CustomEvent("cart:refresh",{bubbles:!0,detail:o})),o},async similar(t,{topK:e,...n}={}){const r=await o("similar",t,n,void 0===e?{}:{topK:e});return a(r?.hits)},async related(t,e={}){const n=await o("related",t,e)??{};return{related:a(n.related),siblingColors:a(n.siblingColors),usedFallback:!0===n.usedFallback}}})}function v(t){return function(){const t=globalThis;return t.callimacusRenderers??=[],t.callimacusRenderers}().find(e=>{const n=e;return n?.type===t&&"function"==typeof n.render})}function w(g,w={}){if(!Object.hasOwn(g.dataset,"callimacusReady")){g.dataset.callimacusReady="";try{!function(g,w){const{dataset:b}=g,$={clientId:b.clientId,endpoint:f(b.endpoint,i),language:f(b.language,"en"),currency:""===b.currency?void 0:b.currency,rootUrl:f(b.rootUrl,"/"),cartAddUrl:f(b.cartAddUrl,s),settings:l(g.querySelector("[data-callimacus-settings]")?.textContent??void 0)};if("true"===b.designMode)return void y(g,"design-mode");if(void 0===$.clientId||""===$.clientId)return y(g,"error"),void console.warn(`${c} no client id — leaving your markup in place`);g.querySelector("[data-callimacus-output]")||console.warn(`${c} no [data-callimacus-output] inside this mount — rendered blocks will replace the mount element's entire contents`);const{clientId:T}=$,I=w.roundTimeoutMs??45e3,S=h($),k=new Set;let C,E,O=!1,A=""===b.storyId?void 0:b.storyId,j=!1,U=!1;const N=new Set,R=void 0!==b.uiObserver&&"false"!==b.uiObserver,_=""===b.uiObserver?void 0:b.uiObserver;function x(){return C||(C=w.transport??new t,R&&C.configureUiObserver?.({enabled:!0,...void 0!==_&&{productSelector:_}}),C.onConnectionStatus&&(U=!0,C.onConnectionStatus(t=>{if(j=t,t){for(const t of N)t();N.clear()}})),C.onError(t=>{E=`${p(t)}: ${t.message??""}`,O||console.warn(`${c} transport error between rounds — ${E}`)}),C.onServerResponse(t=>{if(t.type!==e.STORY_CREATED)return;const n=t.story?.id;"string"==typeof n&&""!==n&&n!==A&&(A=n,m(g,"callimacus:story",{storyId:n}))}),C.connect($.endpoint,{Authorization:`Bearer ${T}`},{token:T}),C)}async function q(t){const o=x();return new Promise((a,i)=>{function s(){clearTimeout(c),l(),d()}const c=setTimeout(()=>{s();i(new u("timeout",`Callimacus did not answer in time${void 0===E?"":` (last transport error: ${E})`}`))},I),l=o.onServerResponse(r=>{if(r.type!==e.CHAPTER_EVENT)return;const o=r.chapter;o?.status!==n.done||k.has(o.id)||function(t,e){if("object"!=typeof t||null===t)return!0;const{type:n,data:r}=t;if(void 0!==n&&n!==e.type)return!1;const o=e.data;return!(void 0!==r?.interactionId&&r.interactionId!==o.interactionId||"string"==typeof r?.value&&"string"==typeof o.value&&r.value!==o.value)}(o.inputEvent,t.inputEvent)&&(k.add(o.id),s(),a(o))}),d=o.onError(t=>{s(),i(new u(p(t),t.message??"Callimacus error",{cause:t}))});try{o.sendUserInteraction(r.CREATE_ROUND,t)}catch(t){s(),i(new u("send_failed","Could not send the request",{cause:t}))}})}function P(t={}){const e=t.storyId??A;return{language:t.language??$.language,...null!=e&&{storyId:e}}}async function L(t){if(!O){O=!0;try{let e;try{e=t()}catch(t){throw new u("send_failed",t instanceof Error?t.message:"Could not build the request",{cause:t})}const{inputEvent:n}=e;y(g,"loading"),m(g,"callimacus:loading",{value:n.data.value,inputEvent:n});const r=await q(e),o=[...r.blocks??[]].sort((t,e)=>(t.priority??0)-(e.priority??0)),{fragment:a,rendered:i}=function(t,e,n=!1){const r=document.createDocumentFragment();let o=0;for(const a of t){const t=v(a.type);if(t)try{const i=t.render(a,e);n&&i instanceof HTMLElement&&void 0===i.dataset.blockId&&(i.dataset.blockId=a.id),i instanceof Node?(r.append(i),o++):null!=i&&console.error(`${c} renderer for ${a.type} returned a non-Node value — skipped`)}catch(t){console.error(`${c} renderer for ${a.type} threw`,t)}else console.info(`${c} no renderer for ${a.type} — skipped`)}return{fragment:r,rendered:o}}(o,S,R);if(0===i)return y(g,"empty"),void m(g,"callimacus:empty",{chapter:r});(g.querySelector("[data-callimacus-output]")??g).replaceChildren(a),y(g,"ready"),m(g,"callimacus:ready",{chapter:r,blocks:o,rendered:i})}catch(t){y(g,"error"),m(g,"callimacus:error",{error:t});const{code:e,message:n}=t instanceof u?t:{code:"error",message:String(t)};console.error(`${c} ${e}: ${n} — your markup is untouched`)}finally{O=!1}}}async function M(t){if(""!==t)return L(()=>({inputEvent:{type:"question",data:{value:t}},...P()}))}async function F(t,e={}){return L(()=>o(t,{...e,...P(e)}))}async function J(t,e={}){return L(()=>a(t,P(e)))}async function z(t){return!(!j&&U)||new Promise(e=>{const n=()=>{clearTimeout(r),e(!0)},r=setTimeout(()=>{N.delete(n),e(!1)},t);N.add(n)})}async function H(t="",e={}){const n={suggestions:[]},r=x(),o=e.timeoutMs??4e3;if(!r.suggest||!await z(o))return n;const{language:a,storyId:i}=P(e);return r.suggest({prefix:t,...void 0!==a&&{language:a},..."string"==typeof i&&{storyId:i}},{timeoutMs:o})}const D={ask:M,sendInteraction:F,openLanding:J,suggest:H,ctx:S,get state(){return g.dataset.callimacusState},get storyId(){return A},resetStory(){A=void 0}};g.callimacus=D,m(g,"callimacus:mounted",D),function(t,e){const{dataset:n}=t,r=""===n.interaction?void 0:n.interaction,o=""===n.prompt?void 0:n.prompt,{landing:a}=n,i=[void 0===r?void 0:"data-interaction",void 0===a?void 0:"data-landing",void 0===o?void 0:"data-prompt"].filter(t=>void 0!==t);i.length>1&&console.warn(`${c} ${i.join(", ")} each open the first round — using ${i[0]}`);if(void 0!==r){const t=""===n.interactionValue?void 0:n.interactionValue,o=d(n.interactionPayload,"[data-interaction-payload]","sending the interaction without one");e.sendInteraction(r,{...void 0!==t&&{value:t},...void 0!==o&&{payload:o}})}else void 0!==a?e.openLanding(""===a?void 0:a):void 0!==o&&e.ask(o)}(g,D)}(g,w)}catch(t){y(g,"error"),m(g,"callimacus:error",{error:t}),console.error(`${c} mount failed — your markup is untouched`,t)}}}function b(t,e={}){for(const n of t.querySelectorAll("[data-callimacus]"))w(n,e)}export{u as CallimacusError,h as makeCtx,w as mount,b as mountAll};
|
|
9
9
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/index.ts"],"sourcesContent":[null],"names":["DEFAULT_ENDPOINT","DEFAULT_CART_ADD_URL","LOG","CallimacusError","Error","code","constructor","message","options","super","this","name","parseSettings","text","undefined","parsed","JSON","parse","Array","isArray","console","warn","error","attr","value","fallback","serverCode","setState","root","state","dataset","callimacusState","setAttribute","String","emit","detail","dispatchEvent","CustomEvent","bubbles","dataValues","block","data","Object","values","makeCtx","config","locale","language","Intl","NumberFormat","supportedLocalesOf","formatters","Map","freeze","currency","settings","picks","items","filter","item","Boolean","fields","length","trim","nested","money","price","amount","own","has","set","style","get","formatterFor","format","toFixed","productUrl","handle","rootUrl","endsWith","slice","imageUrl","width","index","url","images","split","variantId","variants","variantTree","variant","find","candidate","orderable","id","pop","addToCart","quantity","response","fetch","cartAddUrl","method","headers","Accept","body","stringify","Number","cause","json","catch","status","ok","description","document","rendererFor","type","host","globalThis","callimacusRenderers","registry","entry","render","mount","hasOwn","callimacusReady","clientId","endpoint","querySelector","textContent","designMode","roundTimeoutMs","ctx","consumedChapters","Set","transport","lastTransportError","isInFlight","ensureTransport","CallimacusService","onError","connect","Authorization","token","async","requestRound","activeTransport","Promise","resolve","reject","cleanup","clearTimeout","timer","offResponse","offError","setTimeout","onServerResponse","ThamyrResponseType","CHAPTER_EVENT","chapter","ChapterStatus","done","echoed","inputEvent","add","sendUserInteraction","UserInteractionType","CREATE_ROUND","ask","blocks","sort","a","b","priority","fragment","rendered","createDocumentFragment","renderer","node","Node","append","info","renderBlocks","replaceChildren","callimacus","prompt","mountRoot","mountAll","scope","querySelectorAll"],"mappings":";;;;;;;gIAwBA,MAAMA,EAAmB,4BAMnBC,EAAuB,eAEvBC,EAAM,eAyBN,MAAOC,UAAwBC,MAC3BC,KAET,WAAAC,CAAYD,EAA2BE,EAAiBC,GACvDC,MAAMF,EAASC,GACfE,KAAKC,KAAO,kBACZD,KAAKL,KAAOA,CACb,EAkKD,SAASO,EAAcC,GACtB,QAAaC,IAATD,GAA+B,KAATA,EACzB,MAAO,CAAA,EAGR,IACC,MAAME,EAAkBC,KAAKC,MAAMJ,GACnC,GAAsB,iBAAXE,GAAkC,OAAXA,IAAoBG,MAAMC,QAAQJ,GACnE,OAAOA,EAGRK,QAAQC,KAAK,GAAGnB,gEACjB,CAAE,MAAOoB,GACRF,QAAQC,KAAK,GAAGnB,4DAA+DoB,EAChF,CAEA,MAAO,CAAA,CACR,CAQA,SAASC,EAAKC,EAA2BC,GACxC,YAAiBX,IAAVU,GAAiC,KAAVA,EAAeC,EAAWD,CACzD,CAMA,SAASE,EAAWJ,GACnB,MAAO,UAAUA,EAAMjB,MAAQ,SAChC,CAEA,SAASsB,EAASC,EAAmBC,GACpCD,EAAKE,QAAQC,gBAAkBF,EAC/BD,EAAKI,aAAa,YAAaC,OAAiB,YAAVJ,GACvC,CAEA,SAASK,EAAKN,EAAmBjB,EAAcwB,GAC9CP,EAAKQ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ACA,EAAIE,QAAEA,GAAWe,aAAiBnB,EAAkBmB,EAAQ,CAACjB,KAAM,QAASE,QAAS0B,OAAOX,IACnGF,QAAQE,MAAM,GAAGpB,KAAOG,MAASE,+BAClC,SACCiI,GAAa,CACd,CA5BA,CA6BD,CAEA,MAAM3D,EAA2B,CAChC0F,MACApC,MACA,SAAItG,GACH,OAAOD,EAAKE,QAAQC,eACrB,GAEDH,EAAK2J,WAAa1G,EAClB3C,EAAKN,EAAM,qBAAsBiD,QAEV/D,IAAnBgB,EAAQ0J,QAA2C,KAAnB1J,EAAQ0J,QACtCjB,EAAIzI,EAAQ0J,OAEnB,CAnLEC,CAAU7J,EAAMpB,EACjB,CAAE,MAAOc,GACRK,EAASC,EAAM,SACfM,EAAKN,EAAM,mBAAoB,CAACN,UAChCF,QAAQE,MAAM,GAAGpB,4CAA+CoB,EACjE,CAVA,CAWD,UAkLgBoK,EAASC,EAAmBnL,EAAwB,IACnE,IAAK,MAAMoB,KAAQ+J,EAAMC,iBAAwC,qBAChElE,EAAM9F,EAAMpB,EAEd"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/index.ts"],"sourcesContent":[null],"names":["DEFAULT_ENDPOINT","DEFAULT_CART_ADD_URL","LOG","CallimacusError","Error","code","constructor","message","options","super","this","name","parseSettings","text","parseJsonObject","source","fallback","undefined","parsed","JSON","parse","Array","isArray","console","warn","error","attr","value","serverCode","setState","root","state","dataset","callimacusState","setAttribute","String","emit","detail","dispatchEvent","CustomEvent","bubbles","dataValues","block","data","Object","values","makeCtx","config","locale","language","Intl","NumberFormat","supportedLocalesOf","formatters","Map","catalogLocale","rootUrl","segment","URL","pathname","split","find","part","candidate","test","getCanonicalLocales","catalogLocaleOf","async","lookup","operation","anchor","extra","anchorId","id","clientId","controller","AbortController","timer","setTimeout","abort","timeoutMs","response","fetch","endpoint","href","method","headers","Authorization","body","stringify","signal","cause","ok","status","json","catch","clearTimeout","unwrap","hits","filter","hit","item","map","score","freeze","currency","settings","picks","items","Boolean","fields","length","trim","nested","money","price","amount","own","has","set","style","get","formatterFor","format","toFixed","productUrl","handle","endsWith","slice","imageUrl","width","index","url","images","variantId","variants","variantTree","variant","orderable","pop","addToCart","quantity","cartAddUrl","Accept","Number","description","document","similar","topK","related","siblingColors","usedFallback","rendererFor","type","host","globalThis","callimacusRenderers","registry","entry","render","mount","hasOwn","callimacusReady","querySelector","textContent","designMode","roundTimeoutMs","ctx","consumedChapters","Set","transport","lastTransportError","isInFlight","storyId","isConnected","isTrackingConnection","connectionWaiters","isObservingUi","uiObserver","productSelector","ensureTransport","CallimacusService","configureUiObserver","enabled","onConnectionStatus","connected","wake","clear","onError","onServerResponse","ThamyrResponseType","STORY_CREATED","story","connect","token","requestRound","payload","activeTransport","Promise","resolve","reject","cleanup","offResponse","offError","CHAPTER_EVENT","chapter","ChapterStatus","done","echoed","sent","ours","interactionId","isAnswerTo","inputEvent","add","sendUserInteraction","UserInteractionType","CREATE_ROUND","roundOptions","overrides","run","build","blocks","sort","a","b","priority","fragment","rendered","isStampingBlockIds","createDocumentFragment","renderer","node","HTMLElement","blockId","Node","append","info","renderBlocks","replaceChildren","ask","sendInteraction","interaction","interactionRound","openLanding","landingRound","isConnectedWithin","delete","suggest","prefix","none","suggestions","resetStory","callimacus","prompt","landing","named","join","interactionValue","interactionPayload","openingRound","mountRoot","mountAll","scope","querySelectorAll"],"mappings":";;;;;;;wKA8BA,MAAMA,EAAmB,4BAMnBC,EAAuB,eAOvBC,EAAM,eA2BN,MAAOC,UAAwBC,MAC3BC,KAET,WAAAC,CAAYD,EAA2BE,EAAiBC,GACvDC,MAAMF,EAASC,GACfE,KAAKC,KAAO,kBACZD,KAAKL,KAAOA,CACb,EAgQD,SAASO,EAAcC,GACtB,OAAOC,EAAgBD,EAAM,6BAA8B,aAAe,CAAA,CAC3E,CAOA,SAASC,EAAgBD,EAA0BE,EAAgBC,GAClE,QAAaC,IAATJ,GAA+B,KAATA,EAI1B,IACC,MAAMK,EAAkBC,KA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MAAM,GAAGvB,4CAA+CuB,EACjE,CAVA,CAWD,UAuVgB6O,EAASC,EAAmB/P,EAAwB,IACnE,IAAK,MAAMsB,KAAQyO,EAAMC,iBAAwC,qBAChExG,EAAMlI,EAAMtB,EAEd"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* See LICENSE.md for the full terms.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import { CallimacusService } from '@callimacus/thamyr-core';
|
|
8
|
+
import { InteractionId, InteractionOptions, RoundOptions, Suggestions, CallimacusService } from '@callimacus/thamyr-core';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
Headless Callimacus runtime for Shopify Liquid themes.
|
|
@@ -30,11 +30,12 @@ import { CallimacusService } from '@callimacus/thamyr-core';
|
|
|
30
30
|
type MountState = 'loading' | 'ready' | 'empty' | 'error' | 'design-mode';
|
|
31
31
|
/**
|
|
32
32
|
The machine-readable grammar of {@link CallimacusError.code}: `timeout` and
|
|
33
|
-
`send_failed` from the round lifecycle
|
|
34
|
-
`
|
|
35
|
-
from
|
|
33
|
+
`send_failed` from the round lifecycle (`send_failed` also from a lookup
|
|
34
|
+
with no item id), `cart_rejected` and `cart_unreachable` from
|
|
35
|
+
`ctx.addToCart`, `lookup_unreachable` from `ctx.similar` / `ctx.related`,
|
|
36
|
+
`server_<code>` for errors relayed from Callimacus.
|
|
36
37
|
*/
|
|
37
|
-
type CallimacusErrorCode = 'timeout' | 'send_failed' | 'cart_rejected' | 'cart_unreachable' | `server_${string}`;
|
|
38
|
+
type CallimacusErrorCode = 'timeout' | 'send_failed' | 'cart_rejected' | 'cart_unreachable' | 'lookup_unreachable' | `server_${string}`;
|
|
38
39
|
/**
|
|
39
40
|
Error surfaced by the runtime, both to `callimacus:error` listeners and from
|
|
40
41
|
`ctx.addToCart`. The original failure, when there is one, rides on `cause`.
|
|
@@ -58,6 +59,15 @@ type CatalogVariant = {
|
|
|
58
59
|
A catalogue hit as Skesis returns it for a Shopify-connected project.
|
|
59
60
|
*/
|
|
60
61
|
type CatalogItem = {
|
|
62
|
+
/**
|
|
63
|
+
The item's full id (`shopify:product:gid://…`) — what `data-product-id`
|
|
64
|
+
carries for the on-screen context (`data-ui-observer`).
|
|
65
|
+
*/
|
|
66
|
+
id?: string;
|
|
67
|
+
/**
|
|
68
|
+
How close the item is to what found it, when something ranked it.
|
|
69
|
+
*/
|
|
70
|
+
score?: number;
|
|
61
71
|
fields?: {
|
|
62
72
|
title?: string;
|
|
63
73
|
'shopify-handle'?: string;
|
|
@@ -71,6 +81,31 @@ type CatalogItem = {
|
|
|
71
81
|
};
|
|
72
82
|
} & Record<string, unknown>;
|
|
73
83
|
} & Record<string, unknown>;
|
|
84
|
+
/**
|
|
85
|
+
Options for a catalogue lookup. `locale` is the catalogue locale to read —
|
|
86
|
+
by default the one the storefront's route names (`/it-it/` reads `it-IT`).
|
|
87
|
+
*/
|
|
88
|
+
type LookupOptions = {
|
|
89
|
+
locale?: string;
|
|
90
|
+
timeoutMs?: number;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
What `ctx.related` resolves with: items unwrapped like `ctx.picks` hands them out.
|
|
94
|
+
*/
|
|
95
|
+
type RelatedItems = {
|
|
96
|
+
/**
|
|
97
|
+
What the item references and what references it.
|
|
98
|
+
*/
|
|
99
|
+
related: CatalogItem[];
|
|
100
|
+
/**
|
|
101
|
+
The item's other colours, when the catalogue links them.
|
|
102
|
+
*/
|
|
103
|
+
siblingColors: CatalogItem[];
|
|
104
|
+
/**
|
|
105
|
+
The item had no links of its own: these are its nearest neighbour's.
|
|
106
|
+
*/
|
|
107
|
+
usedFallback: boolean;
|
|
108
|
+
};
|
|
74
109
|
/**
|
|
75
110
|
The slice of a server block a renderer works with. Custom blocks arrive with
|
|
76
111
|
their type prefixed on the wire: a block saved as `giftGuide` is
|
|
@@ -136,6 +171,23 @@ type RendererContext = {
|
|
|
136
171
|
failed at the network level.
|
|
137
172
|
*/
|
|
138
173
|
addToCart(variantId: string | number, quantity?: number): Promise<unknown>;
|
|
174
|
+
/**
|
|
175
|
+
Items like this one, by meaning and look, straight from the catalogue —
|
|
176
|
+
the TypeScript SDK's `skesis.similar`, with no round: nothing composed,
|
|
177
|
+
nothing generated, a few hundred milliseconds. Items come shaped like
|
|
178
|
+
`picks` hands them out, each with its `score`. Takes an item or its id.
|
|
179
|
+
Rejects with a {@link CallimacusError}: `lookup_unreachable` when the
|
|
180
|
+
request failed or ran out of time (`timeoutMs`, 10 s by default),
|
|
181
|
+
`server_<status>` when Callimacus refused it.
|
|
182
|
+
*/
|
|
183
|
+
similar(item: CatalogItem | string, options?: LookupOptions & {
|
|
184
|
+
topK?: number;
|
|
185
|
+
}): Promise<CatalogItem[]>;
|
|
186
|
+
/**
|
|
187
|
+
What an item references, what references it, and its other colours — the
|
|
188
|
+
TypeScript SDK's `skesis.related`, with no round. Rejects like `similar`.
|
|
189
|
+
*/
|
|
190
|
+
related(item: CatalogItem | string, options?: LookupOptions): Promise<RelatedItems>;
|
|
139
191
|
};
|
|
140
192
|
/**
|
|
141
193
|
One renderer: owns the markup for one block type. Return a Node, or
|
|
@@ -151,9 +203,48 @@ type CallimacusRenderer = {
|
|
|
151
203
|
`callimacus:mounted` event detail.
|
|
152
204
|
*/
|
|
153
205
|
type CallimacusHandle = {
|
|
206
|
+
/**
|
|
207
|
+
Sends a typed question. Empty is ignored.
|
|
208
|
+
*/
|
|
154
209
|
ask(value: string): Promise<void>;
|
|
210
|
+
/**
|
|
211
|
+
Sends one of the interactions the project declared in its configuration
|
|
212
|
+
document — a click, a product viewed — as what it is, not as a typed
|
|
213
|
+
question. The TypeScript SDK's `sendInteraction`, and a round like an
|
|
214
|
+
`ask`: the same states and events, one at a time.
|
|
215
|
+
*/
|
|
216
|
+
sendInteraction<I extends InteractionId>(id: I, options?: InteractionOptions<I>): Promise<void>;
|
|
217
|
+
/**
|
|
218
|
+
Opens the project's custom landing: a round with no message, composed from
|
|
219
|
+
its landing configuration. `value` (at most 200 characters) is what its
|
|
220
|
+
blocks read as `{{input.value}}`. The TypeScript SDK's `openLanding`.
|
|
221
|
+
*/
|
|
222
|
+
openLanding(value?: string, options?: RoundOptions): Promise<void>;
|
|
223
|
+
/**
|
|
224
|
+
Suggestions for a prompt bar: the project's starter questions on an empty
|
|
225
|
+
or short prefix, autocomplete while the visitor types. The TypeScript
|
|
226
|
+
SDK's `suggest`, fail-open like it: no connection, a timeout or an error
|
|
227
|
+
all resolve to no suggestions. It opens no round and changes no state.
|
|
228
|
+
*/
|
|
229
|
+
suggest(prefix?: string, options?: RoundOptions & {
|
|
230
|
+
timeoutMs?: number;
|
|
231
|
+
}): Promise<Suggestions>;
|
|
155
232
|
readonly ctx: RendererContext;
|
|
156
233
|
readonly state: string | undefined;
|
|
234
|
+
/**
|
|
235
|
+
The story this mount's rounds continue: the one `data-story-id` named, or
|
|
236
|
+
the one the server opened, `undefined` before the first round reaches it.
|
|
237
|
+
A new one is announced as `callimacus:story` (detail `{storyId}`), so a
|
|
238
|
+
theme can keep it and name it on the next page.
|
|
239
|
+
*/
|
|
240
|
+
readonly storyId: string | undefined;
|
|
241
|
+
/**
|
|
242
|
+
Starts the conversation over: the next round opens a new story, announced
|
|
243
|
+
as `callimacus:story`. The old one stays as it was — this is not the
|
|
244
|
+
wire's `reset-story`, which deletes a story's rounds. A theme that keeps
|
|
245
|
+
the id across pages forgets its copy too.
|
|
246
|
+
*/
|
|
247
|
+
resetStory(): void;
|
|
157
248
|
};
|
|
158
249
|
/**
|
|
159
250
|
A mount element once the runtime has taken it over.
|
|
@@ -165,7 +256,7 @@ type CallimacusHostElement = HTMLElement & {
|
|
|
165
256
|
The transport surface the runtime needs — {@link CallimacusService}
|
|
166
257
|
satisfies it. Injectable so tests can drive rounds without a socket.
|
|
167
258
|
*/
|
|
168
|
-
type RoundTransport = Pick<CallimacusService, 'connect' | 'sendUserInteraction' | 'onServerResponse' | 'onError'
|
|
259
|
+
type RoundTransport = Pick<CallimacusService, 'connect' | 'sendUserInteraction' | 'onServerResponse' | 'onError'> & Partial<Pick<CallimacusService, 'suggest' | 'onConnectionStatus' | 'configureUiObserver'>>;
|
|
169
260
|
type MountOptions = {
|
|
170
261
|
transport?: RoundTransport;
|
|
171
262
|
roundTimeoutMs?: number;
|
|
@@ -198,4 +289,4 @@ Mounts every `[data-callimacus]` element in scope not already mounted.
|
|
|
198
289
|
declare function mountAll(scope: ParentNode, options?: MountOptions): void;
|
|
199
290
|
|
|
200
291
|
export { CallimacusError, makeCtx, mount, mountAll };
|
|
201
|
-
export type { CallimacusErrorCode, CallimacusHandle, CallimacusHostElement, CallimacusRenderer, CatalogItem, CatalogVariant, MountOptions, MountState, Price, RenderableBlock, RendererContext, RoundTransport };
|
|
292
|
+
export type { CallimacusErrorCode, CallimacusHandle, CallimacusHostElement, CallimacusRenderer, CatalogItem, CatalogVariant, LookupOptions, MountOptions, MountState, Price, RelatedItems, RenderableBlock, RendererContext, RoundTransport };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@callimacus/thamyr-liquid",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.8.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Headless Callimacus runtime for Shopify Liquid themes",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"lint": "eslint src"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@callimacus/thamyr-core": "^4.
|
|
41
|
+
"@callimacus/thamyr-core": "^4.8.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"eslint-config-xo": "^5.0.0",
|