@callimacus/thamyr-liquid 4.7.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/dist/esm/index.js CHANGED
@@ -5,5 +5,5 @@
5
5
  * See LICENSE.md for the full terms.
6
6
  *
7
7
  */
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",c="/cart/add.js",s="[callimacus]";class u extends Error{code;constructor(t,e,n){super(e,n),this.name="CallimacusError",this.code=t}}function d(t){return l(t,"[data-callimacus-settings]","using {}")??{}}function l(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(`${s} ${e} must be a JSON object — ${n}`)}catch(t){console.warn(`${s} ${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 v(t){const{data:e}=t;return"object"!=typeof e||null===e?[]:Object.values(e)}function g(t){let e=t.language;try{Intl.NumberFormat.supportedLocalesOf(e)}catch{console.warn(`${s} invalid data-language "${e}" — formatting with "en"`),e="en"}const n=new Map;return Object.freeze({locale:e,currency:t.currency,settings:t.settings,picks(t){for(const e of v(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 v(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(`${s} 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(`${s} 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}})}function h(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(v,w={}){if(!Object.hasOwn(v.dataset,"callimacusReady")){v.dataset.callimacusReady="";try{!function(v,w){const{dataset:b}=v,$={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,c),settings:d(v.querySelector("[data-callimacus-settings]")?.textContent??void 0)};if("true"===b.designMode)return void y(v,"design-mode");if(void 0===$.clientId||""===$.clientId)return y(v,"error"),void console.warn(`${s} no client id — leaving your markup in place`);v.querySelector("[data-callimacus-output]")||console.warn(`${s} no [data-callimacus-output] inside this mount — rendered blocks will replace the mount element's entire contents`);const{clientId:S}=$,I=w.roundTimeoutMs??45e3,E=g($),T=new Set;let C,O,k=!1,j=""===b.storyId?void 0:b.storyId,A=!1,U=!1;const N=new Set,R=void 0!==b.uiObserver&&"false"!==b.uiObserver,x=""===b.uiObserver?void 0:b.uiObserver;function q(){return C||(C=w.transport??new t,R&&C.configureUiObserver?.({enabled:!0,...void 0!==x&&{productSelector:x}}),C.onConnectionStatus&&(U=!0,C.onConnectionStatus(t=>{if(A=t,t){for(const t of N)t();N.clear()}})),C.onError(t=>{O=`${p(t)}: ${t.message??""}`,k||console.warn(`${s} transport error between rounds — ${O}`)}),C.onServerResponse(t=>{if(t.type!==e.STORY_CREATED)return;const n=t.story?.id;"string"==typeof n&&""!==n&&n!==j&&(j=n,m(v,"callimacus:story",{storyId:n}))}),C.connect($.endpoint,{Authorization:`Bearer ${S}`},{token:S}),C)}async function _(t){const o=q();return new Promise((a,i)=>{function c(){clearTimeout(s),d(),l()}const s=setTimeout(()=>{c();i(new u("timeout",`Callimacus did not answer in time${void 0===O?"":` (last transport error: ${O})`}`))},I),d=o.onServerResponse(r=>{if(r.type!==e.CHAPTER_EVENT)return;const o=r.chapter;o?.status!==n.done||T.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)&&(T.add(o.id),c(),a(o))}),l=o.onError(t=>{c(),i(new u(p(t),t.message??"Callimacus error",{cause:t}))});try{o.sendUserInteraction(r.CREATE_ROUND,t)}catch(t){c(),i(new u("send_failed","Could not send the request",{cause:t}))}})}function P(t={}){const e=t.storyId??j;return{language:t.language??$.language,...null!=e&&{storyId:e}}}async function M(t){if(!k){k=!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(v,"loading"),m(v,"callimacus:loading",{value:n.data.value,inputEvent:n});const r=await _(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=h(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(`${s} renderer for ${a.type} returned a non-Node value — skipped`)}catch(t){console.error(`${s} renderer for ${a.type} threw`,t)}else console.info(`${s} no renderer for ${a.type} — skipped`)}return{fragment:r,rendered:o}}(o,E,R);if(0===i)return y(v,"empty"),void m(v,"callimacus:empty",{chapter:r});(v.querySelector("[data-callimacus-output]")??v).replaceChildren(a),y(v,"ready"),m(v,"callimacus:ready",{chapter:r,blocks:o,rendered:i})}catch(t){y(v,"error"),m(v,"callimacus:error",{error:t});const{code:e,message:n}=t instanceof u?t:{code:"error",message:String(t)};console.error(`${s} ${e}: ${n} — your markup is untouched`)}finally{k=!1}}}async function J(t){if(""!==t)return M(()=>({inputEvent:{type:"question",data:{value:t}},...P()}))}async function D(t,e={}){return M(()=>o(t,{...e,...P(e)}))}async function F(t,e={}){return M(()=>a(t,P(e)))}async function H(t){return!(!A&&U)||new Promise(e=>{const n=()=>{clearTimeout(r),e(!0)},r=setTimeout(()=>{N.delete(n),e(!1)},t);N.add(n)})}async function L(t="",e={}){const n={suggestions:[]},r=q(),o=e.timeoutMs??4e3;if(!r.suggest||!await H(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 V={ask:J,sendInteraction:D,openLanding:F,suggest:L,ctx:E,get state(){return v.dataset.callimacusState},get storyId(){return j},resetStory(){j=void 0}};v.callimacus=V,m(v,"callimacus:mounted",V),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(`${s} ${i.join(", ")} each open the first round — using ${i[0]}`);if(void 0!==r){const t=""===n.interactionValue?void 0:n.interactionValue,o=l(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)}(v,V)}(v,w)}catch(t){y(v,"error"),m(v,"callimacus:error",{error:t}),console.error(`${s} 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,g as makeCtx,w as mount,b 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
@@ -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","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","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","storyId","isConnected","isTrackingConnection","connectionWaiters","isObservingUi","uiObserver","productSelector","ensureTransport","CallimacusService","configureUiObserver","enabled","onConnectionStatus","connected","wake","clear","onError","onServerResponse","ThamyrResponseType","STORY_CREATED","story","connect","Authorization","token","async","requestRound","payload","activeTransport","Promise","resolve","reject","cleanup","clearTimeout","timer","offResponse","offError","setTimeout","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","timeoutMs","delete","suggest","prefix","none","suggestions","resetStory","callimacus","prompt","landing","named","join","interactionValue","interactionPayload","openingRound","mountRoot","mountAll","scope","querySelectorAll"],"mappings":";;;;;;;wKA8BA,MAAMA,EAAmB,4BAMnBC,EAAuB,eAMvBC,EAAM,eAyBN,MAAOC,UAAwBC,MAC3BC,KAET,WAAAC,CAAYD,EAA2BE,EAAiBC,GACvDC,MAAMF,EAASC,GACfE,KAAKC,KAAO,kBACZD,KAAKL,KAAOA,CACb,EAkND,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,KAAKC,MAAMP,GACnC,GAAsB,iBAAXK,GAAkC,OAAXA,IAAoBG,MAAMC,QAAQJ,GACnE,OAAOA,EAGRK,QAAQC,KAAK,GAAGtB,KAAOa,6BAAkCC,IAC1D,CAAE,MAAOS,GACRF,QAAQC,KAAK,GAAGtB,K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EAAa,SAC1BpM,IAAVU,GAAuB,CAACA,iBACZV,IAAZmJ,GAAyB,CAACA,YAEhC,WAAuBnJ,IAAZkN,EACLpJ,EAAOwI,YAAwB,KAAZY,OAAiBlN,EAAYkN,QAChClN,IAAXiN,GACLnJ,EAAOoI,IAAIe,EAElB,CAnCCM,CAAa1M,EAAMiD,EACpB,CAtTE0J,CAAU3M,EAAMtB,EACjB,CAAE,MAAOiB,GACRI,EAASC,EAAM,SACfM,EAAKN,EAAM,mBAAoB,CAACL,UAChCF,QAAQE,MAAM,GAAGvB,4CAA+CuB,EACjE,CAVA,CAWD,UAuVgBiN,EAASC,EAAmBnO,EAAwB,IACnE,IAAK,MAAMsB,KAAQ6M,EAAMC,iBAAwC,qBAChEhH,EAAM9F,EAAMtB,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,KAAKC,MAAMP,GACnC,GAAsB,iBAAXK,GAAkC,OAAXA,IAAoBG,MAAMC,QAAQJ,GACnE,OAAOA,EAGRK,QAAQC,KAAK,GAAGtB,KAAOa,6BAAkCC,IAC1D,CAAE,MAAOS,GACRF,QAAQC,KAAK,GAAGtB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teractionId, InteractionOptions, RoundOptions, Suggestions, Callimacu
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, `cart_rejected` and
34
- `cart_unreachable` from `ctx.addToCart`, `server_<code>` for errors relayed
35
- from Callimacus.
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`.
@@ -63,6 +64,10 @@ type CatalogItem = {
63
64
  carries for the on-screen context (`data-ui-observer`).
64
65
  */
65
66
  id?: string;
67
+ /**
68
+ How close the item is to what found it, when something ranked it.
69
+ */
70
+ score?: number;
66
71
  fields?: {
67
72
  title?: string;
68
73
  'shopify-handle'?: string;
@@ -76,6 +81,31 @@ type CatalogItem = {
76
81
  };
77
82
  } & Record<string, unknown>;
78
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
+ };
79
109
  /**
80
110
  The slice of a server block a renderer works with. Custom blocks arrive with
81
111
  their type prefixed on the wire: a block saved as `giftGuide` is
@@ -141,6 +171,23 @@ type RendererContext = {
141
171
  failed at the network level.
142
172
  */
143
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>;
144
191
  };
145
192
  /**
146
193
  One renderer: owns the markup for one block type. Return a Node, or
@@ -242,4 +289,4 @@ Mounts every `[data-callimacus]` element in scope not already mounted.
242
289
  declare function mountAll(scope: ParentNode, options?: MountOptions): void;
243
290
 
244
291
  export { CallimacusError, makeCtx, mount, mountAll };
245
- 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.7.0",
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.7.0"
41
+ "@callimacus/thamyr-core": "^4.8.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "eslint-config-xo": "^5.0.0",