@spiffcommerce/core 21.9.1-2 → 21.9.1-3
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/index.js +16 -13
- package/dist/index.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6270,25 +6270,28 @@ const ln = async (c) => {
|
|
|
6270
6270
|
}
|
|
6271
6271
|
})).data) == null ? void 0 : s.designCreate;
|
|
6272
6272
|
}, Bn = async (c) => {
|
|
6273
|
-
var
|
|
6274
|
-
const t = ((
|
|
6275
|
-
return A && gt(A), (
|
|
6273
|
+
var i, s;
|
|
6274
|
+
const t = ((i = Object.entries(localStorage).find(([o, r]) => o.startsWith("CognitoIdentityServiceProvider") && o.endsWith("idToken"))) == null ? void 0 : i[0]) || "", A = localStorage.getItem(t), a = {};
|
|
6275
|
+
return A && !gt(A) && (a.Authorization = `Bearer ${A}`), (s = (await x.getShadowGraphqlClient().mutate({
|
|
6276
6276
|
mutation: gn,
|
|
6277
6277
|
errorPolicy: "all",
|
|
6278
6278
|
fetchPolicy: "no-cache",
|
|
6279
6279
|
variables: {
|
|
6280
|
-
inputs: c.map((
|
|
6281
|
-
name:
|
|
6282
|
-
layouts:
|
|
6283
|
-
workflowId:
|
|
6284
|
-
transactionId:
|
|
6285
|
-
previewImage:
|
|
6286
|
-
useThreeDimPreview:
|
|
6287
|
-
metadata:
|
|
6288
|
-
selectedVariants:
|
|
6280
|
+
inputs: c.map((o) => ({
|
|
6281
|
+
name: o.name,
|
|
6282
|
+
layouts: o.layouts,
|
|
6283
|
+
workflowId: o.workflowId,
|
|
6284
|
+
transactionId: o.transactionId,
|
|
6285
|
+
previewImage: o.previewImage,
|
|
6286
|
+
useThreeDimPreview: o.useThreeDimPreview,
|
|
6287
|
+
metadata: o.metadata,
|
|
6288
|
+
selectedVariants: o.selectedVariants
|
|
6289
6289
|
}))
|
|
6290
|
+
},
|
|
6291
|
+
context: {
|
|
6292
|
+
headers: a
|
|
6290
6293
|
}
|
|
6291
|
-
})).data) == null ? void 0 :
|
|
6294
|
+
})).data) == null ? void 0 : s.designCreateMany;
|
|
6292
6295
|
}, Ze = (c, e, t) => {
|
|
6293
6296
|
const A = (n) => {
|
|
6294
6297
|
const i = {};
|
package/dist/index.umd.cjs
CHANGED
|
@@ -2002,7 +2002,7 @@ IfnI8vaNAAAAAElFTkSuQmCC" transform="matrix(0.13 0.0141 -0.0141 0.1301 104.926 1
|
|
|
2002
2002
|
}
|
|
2003
2003
|
}
|
|
2004
2004
|
}
|
|
2005
|
-
`;function je(c){const e=JSON.parse(atob(c.split(".")[1])).exp;return Math.floor(new Date().getTime()/1e3)>=e}const Qn=async c=>{var i,o;const t=((i=Object.entries(localStorage).find(([s,r])=>s.startsWith("CognitoIdentityServiceProvider")&&s.endsWith("idToken")))==null?void 0:i[0])||"",A=localStorage.getItem(t),n={};return A&&!je(A)&&(n.Authorization=`Bearer ${A}`),(o=(await N.getShadowGraphqlClient().mutate({mutation:Cn,errorPolicy:"all",fetchPolicy:"no-cache",variables:{name:c.name,layouts:c.layouts,workflowId:c.workflowId,transactionId:c.transactionId,previewImage:c.previewImage,useThreeDimPreview:c.useThreeDimPreview,metadata:c.metadata,selectedVariants:c.selectedVariants},context:{headers:n}})).data)==null?void 0:o.designCreate},mn=async c=>{var
|
|
2005
|
+
`;function je(c){const e=JSON.parse(atob(c.split(".")[1])).exp;return Math.floor(new Date().getTime()/1e3)>=e}const Qn=async c=>{var i,o;const t=((i=Object.entries(localStorage).find(([s,r])=>s.startsWith("CognitoIdentityServiceProvider")&&s.endsWith("idToken")))==null?void 0:i[0])||"",A=localStorage.getItem(t),n={};return A&&!je(A)&&(n.Authorization=`Bearer ${A}`),(o=(await N.getShadowGraphqlClient().mutate({mutation:Cn,errorPolicy:"all",fetchPolicy:"no-cache",variables:{name:c.name,layouts:c.layouts,workflowId:c.workflowId,transactionId:c.transactionId,previewImage:c.previewImage,useThreeDimPreview:c.useThreeDimPreview,metadata:c.metadata,selectedVariants:c.selectedVariants},context:{headers:n}})).data)==null?void 0:o.designCreate},mn=async c=>{var i,o;const t=((i=Object.entries(localStorage).find(([s,r])=>s.startsWith("CognitoIdentityServiceProvider")&&s.endsWith("idToken")))==null?void 0:i[0])||"",A=localStorage.getItem(t),n={};return A&&!je(A)&&(n.Authorization=`Bearer ${A}`),(o=(await N.getShadowGraphqlClient().mutate({mutation:un,errorPolicy:"all",fetchPolicy:"no-cache",variables:{inputs:c.map(s=>({name:s.name,layouts:s.layouts,workflowId:s.workflowId,transactionId:s.transactionId,previewImage:s.previewImage,useThreeDimPreview:s.useThreeDimPreview,metadata:s.metadata,selectedVariants:s.selectedVariants}))},context:{headers:n}})).data)==null?void 0:o.designCreateMany},Ke=(c,e,t)=>{const A=a=>{const i={};if(a.type==="Frame"){const o=c[a.stepName],s=a.data;if(!o||!o.image||s.hideImageInCart&&t)return i;i[`${a.stepTitle} image`]=o.image}if(a.type==="Illustration"){const o=c[a.stepName],s=a.data;if(!o||s.hideColorsInCart&&t||!o.colors)return i;if(o.colors.length>0){const r=o.colors.join(", ").toUpperCase();i[`${a.stepTitle} colors`]=r}}if(a.type==="Module"){const o=c[a.stepName],s=a.data;if(!o||o.text===void 0||o.text===null||s.hideTextInCart&&t)return i;i[`${a.stepTitle} text`]=o.text}if(a.type==="Text"){const o=c[a.stepName];if(!o)return i;const s=a.data;(!s.hideTextInCart||!t&&o.text!==void 0&&o.text!==null)&&(i[`${a.stepTitle} text`]=o.text),o.color&&(!s.hideColorInCart||!t)&&(i[`${a.stepTitle} color`]=o.color)}return i},n={};return e.steps.forEach(a=>{Object.assign(n,A(a))}),n},In=(c,e,t,A)=>{const n={};let a;if(t){a=Ke(t,e,!1);for(const i of Object.keys(a))n[i]={value:a[i],priceModifier:0}}else if(A){a=A;for(const i of Object.keys(a))n[i]={value:a[i],priceModifier:0}}for(const i of Object.keys(c)){const o=c[i],s=e.steps.find(r=>r.stepTitle===i);if(o.length===1)n[`${s==null?void 0:s.stepTitle} selection`]={value:o[0].name,priceModifier:o[0].priceModifier};else if(o.length>1)for(let r=0;r<o.length;r++)n[`${s==null?void 0:s.stepTitle} selection ${r+1}`]={value:o[r].name,priceModifier:o[r].priceModifier}}return n},jt=(c,e,t,A,n,a,i,o)=>{var h,C;const s=e.basePrice||0,r=c.priceModifierTotal||0,g=In(A,t,void 0,a),d=(P.getMap("transactionOwnerIds")||new Map).get(c.id),w={additionalExternalProductId:(h=c.integrationProduct)==null?void 0:h.additionalExternalProductId,additionalExternalVariantId:(C=c.integrationProduct)==null?void 0:C.additionalExternalVariantId,baseCost:s,designProductId:c.externalDesignProductId,designProductVariantId:c.externalDesignProductVariantId,event:"onComplete",exportedData:g,externalCartProductId:c.externalCartProductId,externalCartProductVariantId:c.externalCartProductVariantId,lineItemImageUrl:i||"",optionsCost:r,processExecutionId:o,quantity:c.quantity,transactionId:c.id,transactionOwnerId:d,weight:e.weight,workflowViewerLink:c.workflowViewerLink||"",workflowViewerReadOnlyLink:c.workflowViewerReadOnlyLink||""};return a&&(w.metadata=a),A&&(w.selectedVariants=A),n&&(w.sku=n),w},Kt=async(c,e,t,A,n,a,i,o,s,r)=>{var S;await(async()=>{var T;if(r!==void 0)return r;await c.outstandingRequestsPromise();const x=(P.getMap("transactionOwnerIds")||new Map).get(n.id),H=await N.getShadowGraphqlClient().query({query:ut,variables:{ids:[n.id]},fetchPolicy:"no-cache",errorPolicy:"all",context:{transactionOwnerId:x}}),R=(T=H.data)==null?void 0:T.transactions[0].workflowState;return H.errors?(H.errors.forEach(b=>{H.errors&&console.log("Server Error:",b.message)}),null):R??null})()||(console.warn("State mismatch detected. Uploading known state explicitly"),console.warn("State Object:",JSON.stringify(A())),await c.updateStateWithServerImmediate(A),console.log("Server state is undefined @ Workflow completion"));const d=c.getPreviewService(),w=(S=e==null?void 0:e.finalizeStepConfig)==null?void 0:S.lookAtAnimation,h=d&&e.showModelOnFinishStep&&!!w,C=s&&Ke(s,e,!0),E=s&&Ke(s,e,!1),m=async y=>{const x={};let Y=0;if(Object.keys(a).length>0)for(const H of Object.keys(a)){const R=a[H],T=e.steps.find(b=>b.stepName===H);for(let b=0;b<R.selections.length;++b){const z=R.selections[b];if(T&&(!y||T.option&&(T.option.variants||[]).length>1&&!T.data.hideSelectionInCart&&!T.data.hideSelectionsInCart)){const et=T.stepTitle;x[et]?x[et].push({id:z.id||"",name:z.name,priceModifier:z.priceModifier}):x[et]=[{id:z.id||"",name:z.name,priceModifier:z.priceModifier}]}Y+=z.priceModifier}}return[x,Y]},[Q]=await m(!0),F=Object.fromEntries(Object.keys(Q).map(y=>[y,Q[y].map(x=>x.id)])),[I]=await m(!1),f=Object.fromEntries(Object.keys(I).map(y=>[y,I[y].map(x=>x.id)])),D=await o(h,n.id);return{designDetails:(()=>{const y={name:i,layouts:t.map(x=>({index:x.index,panelId:x.panelId})),workflowId:e.id,transactionId:n.id,useThreeDimPreview:!!h,previewImage:D};if(E){const x=[];for(const[Y,H]of Object.entries(E))x.push({key:Y,value:H});y.metadata=x}if(F){const x=[];for(const[Y,H]of Object.entries(f))x.push({key:Y,ids:H});y.selectedVariants=x}return y})(),cartSelectionsWithPrices:Q,cartMetadata:C}},Vt=async(c,e,t,A,n,a,i,o,s,r,g)=>{var m,Q;s("workflow.steps.finish.finalize.buildingLayouts");const{designDetails:B,cartSelectionsWithPrices:d,cartMetadata:w}=await Kt(c,e,t,A,a,i,o,r,g);s("workflow.steps.finish.finalize.creatingDesign");const h=await Qn(B),C=(m=h==null?void 0:h.transaction)==null?void 0:m.previewImageLink;if(!(h!=null&&h.transaction))throw new Error("Failed to create design");s("workflow.steps.finish.finalize.updatingTransaction");const E=h.transaction;return jt(E,n,e,d,h==null?void 0:h.sku,w,C,(Q=h==null?void 0:h.processExecution)==null?void 0:Q.id)},fn=async(c,e,t)=>{e("workflow.steps.finish.finalize.buildingLayouts"),await Promise.all(c.map(async o=>{await o.workflowManager.outstandingRequestsPromise()}));const n=await(async()=>{var r;const s=await N.getShadowGraphqlClient().query({query:ut,variables:{ids:c.map(g=>g.transaction.id)},fetchPolicy:"no-cache",errorPolicy:"all"});return s.errors?(s.errors.forEach(g=>{s.errors&&console.log("Server Error:",g.message)}),null):(r=s.data)!=null&&r.transactions?s.data.transactions.map(g=>g.workflowState??null):null})(),a=await Promise.all(c.map(async(o,s)=>await Kt(o.workflowManager,o.workflow,o.layouts,o.getReducerState,o.transaction,o.workflowSelections,o.designName,t??(()=>Promise.resolve(void 0)),o.workflowMetadata,n?n[s]:void 0)));e("workflow.steps.finish.finalize.creatingDesign");const i=await mn(a.map(o=>o.designDetails));if(!i)throw new Error("Failed to create designs");return e("workflow.steps.finish.finalize.updatingTransaction"),i.map((o,s)=>{var d;const r=c[s],g=a[s],B=o.transaction;return jt(B,r.product,r.workflow,g.cartSelectionsWithPrices,o.sku,g.cartMetadata,void 0,(d=o.processExecution)==null?void 0:d.id)})};class Dn{constructor(){this.localPersistenceKey="designTransactions",this.storageMethod="Local",this.designSavedListeners=[]}attachSaveListener(e){this.designSavedListeners.push(e)}detachSaveListener(e){this.designSavedListeners=this.designSavedListeners.filter(t=>t!==e)}async getSavedDesigns(){if(this.storageMethod==="Local"){const e=P.get(this.localPersistenceKey);return e?JSON.parse(e):[]}throw new k("Unexpected storage method requested")}async getSavedDesignByTransaction(e){return(await this.getSavedDesigns()).find(A=>A.transactionId===e)}async addDesign(e){const A=(await this.getSavedDesigns()).filter(n=>n.transactionId!==e.transactionId);A.unshift(e),await this.setDesigns(A),this.designSavedListeners.forEach(n=>n(e))}async renameDesign(e,t){const A=await this.getSavedDesigns(),n=A.find(a=>a.transactionId===e);if(!n)throw new Error(`No saved design for transaction ${e}.`);n.title=t,await this.setDesigns(A)}async removeDesign(e){const t=await this.getSavedDesigns();await this.setDesigns(t.filter(A=>A.transactionId!==e))}async setDesigns(e){if(this.storageMethod==="Local"){P.set(this.localPersistenceKey,JSON.stringify(e));return}throw new k("Unexpected storage method requested")}}const Fe=new Dn,pn=M.gql`
|
|
2006
2006
|
mutation AddTransactionStakeholder($id: String!, $type: String!, $details: CustomerDetailsInput!) {
|
|
2007
2007
|
transactionAddStakeholder(id: $id, details: $details, type: $type) {
|
|
2008
2008
|
id
|