@spiffcommerce/core 12.7.0 → 12.7.1
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/main.js +10 -10
- package/dist/module.js +2 -2
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
package/dist/module.js
CHANGED
|
@@ -625,7 +625,7 @@ import{CommandContext as t,AssetType as A,BringForwardCommand as e,BringToFrontC
|
|
|
625
625
|
}
|
|
626
626
|
}
|
|
627
627
|
}
|
|
628
|
-
`;function oa(t,A,e){return(A=function(t){var A=function(t,A){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,A||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===A?String:Number)(t)}(t,"string");return"symbol"==typeof A?A:String(A)}(A))in t?Object.defineProperty(t,A,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[A]=e,t}class ra{constructor(t,A){oa(this,"bundle",void 0),oa(this,"property",void 0),this.bundle=t,this.property=A}getName(){return this.property.name}getDescription(){return this.property.description}getType(){return this.property.type}getSharedSteps(){return this.bundle.getWorkflowExperiences().flatMap((t=>t.getSteps().filter((t=>{t.getRaw().globalPropertyConfigurationAspectNames?.includes(this.property.name)}))))}}class sa extends ra{constructor(t,A){super(t,A)}selectImage(t){const A=this.getSharedSteps().map((A=>A.selectImage(t)));return Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t.key),...A])}}class ca extends ra{constructor(t,A){super(t,A)}getCurrentVariant(){const t=this.
|
|
628
|
+
`;function oa(t,A,e){return(A=function(t){var A=function(t,A){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,A||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===A?String:Number)(t)}(t,"string");return"symbol"==typeof A?A:String(A)}(A))in t?Object.defineProperty(t,A,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[A]=e,t}class ra{constructor(t,A){oa(this,"bundle",void 0),oa(this,"property",void 0),this.bundle=t,this.property=A}getName(){return this.property.name}getDescription(){return this.property.description}getType(){return this.property.type}getSharedSteps(){return this.bundle.getWorkflowExperiences().flatMap((t=>t.getSteps().filter((t=>{t.getRaw().globalPropertyConfigurationAspectNames?.includes(this.property.name)}))))}}class sa extends ra{constructor(t,A){super(t,A)}selectImage(t){const A=this.getSharedSteps().map((A=>A.selectImage(t)));return Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t.key),...A])}}class ca extends ra{constructor(t,A,e){super(t,A),oa(this,"optionResource",void 0),this.optionResource=e}getCurrentVariant(){if(!this.optionResource)return;const t=this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name);if(!t)return;const A=this.optionResource.variants?.find((A=>A.id===t));return A?new fi(A):void 0}getAvailableVariants(){return(this.optionResource?.variants?.filter((t=>t.enabled))||[]).map((t=>new fi(t)))}getAllVariants(){return(this.optionResource?.variants||[]).map((t=>new fi(t)))}selectVariant(t){const A=this.getSharedSteps().map((A=>A.selectVariant(t)));return Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t.getId()),...A])}}const ga=Zt`
|
|
629
629
|
mutation CreateGlobalPropertyState($bundleId: String!) {
|
|
630
630
|
globalPropertyStateCreate(bundleId: $bundleId) {
|
|
631
631
|
id
|
|
@@ -651,7 +651,7 @@ import{CommandContext as t,AssetType as A,BringForwardCommand as e,BringToFrontC
|
|
|
651
651
|
}
|
|
652
652
|
}
|
|
653
653
|
}
|
|
654
|
-
`;function wa(t,A,e){return(A=function(t){var A=function(t,A){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,A||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===A?String:Number)(t)}(t,"string");return"symbol"==typeof A?A:String(A)}(A))in t?Object.defineProperty(t,A,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[A]=e,t}class da{constructor(t){wa(this,"bundleId",void 0),wa(this,"globalPropertyState",void 0),this.bundleId=t,this.getOrCreateGlobalPropertyState().then((t=>this.globalPropertyState=t))}getGlobalPropertyState(){return this.globalPropertyState}setAspect(t,A){if(!this.globalPropertyState)throw new Error("Global property state not initialized");const e=this.globalPropertyState.aspects.find((A=>A.name===t));return e?e.value=A:this.globalPropertyState.aspects.push({name:t,value:A}),this.updateGlobalPropertyState()}async updateGlobalPropertyState(){if(!this.globalPropertyState)throw new Error("Global property state not initialized");const t=await yA.getShadowGraphqlClient().mutate({mutation:la,variables:{id:this.globalPropertyState.id,aspects:this.globalPropertyState.aspects}});if(!t.data?.globalPropertyStateUpdate)throw new Error("Unable to update global property state");this.globalPropertyState=t.data.globalPropertyStateUpdate}async getOrCreateGlobalPropertyState(){const t=await yA.getShadowGraphqlClient().query({query:Ba,errorPolicy:"all",fetchPolicy:"no-cache",variables:{bundleId:this.bundleId}});if(t.data.globalPropertyState&&t.data.globalPropertyState.id)return t.data.globalPropertyState;const A=await yA.getShadowGraphqlClient().mutate({mutation:ga,variables:{bundleId:this.bundleId}});if(A.data?.globalPropertyStateCreate&&A.data.globalPropertyStateCreate.id)return A.data.globalPropertyStateCreate;throw new Error(`Unable to create global property state for bundle: ${this.bundleId}`)}}function ha(t,A,e){return(A=function(t){var A=function(t,A){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,A||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===A?String:Number)(t)}(t,"string");return"symbol"==typeof A?A:String(A)}(A))in t?Object.defineProperty(t,A,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[A]=e,t}class Ea{constructor(t,A){ha(this,"client",void 0),ha(this,"id",void 0),ha(this,"name",void 0),ha(this,"metadata",void 0),ha(this,"productCollection",void 0),ha(this,"globalConfigurations",void 0),ha(this,"globalPropertyStateManager",void 0),ha(this,"workflowExperiences",[]),this.client=t,this.id=A.id,this.name=A.name||"",this.metadata=new Map(A.metadata?.map((t=>[t.key,t.value]))||[]),this.productCollection=A.productCollection,this.globalConfigurations=this.resolveGlobalProperties(),this.globalPropertyStateManager=new da(this.id)}getClient(){return this.client}getId(){return this.id}getName(){return this.name}setName(t){return this.name=t,this.updateBundle()}getMetadata(){return new Map(this.metadata)}setMetadata(t){return this.metadata=new Map(t),this.updateBundle()}async hasGlobalProperties(){const t=await this.globalConfigurations;return t.length>0&&t.some((t=>t.aspects.length>0))}async getGlobalProperties(){const t=await this.globalConfigurations;if(0===t.length)throw new Error("Bundle does not have global properties");return t.
|
|
654
|
+
`;function wa(t,A,e){return(A=function(t){var A=function(t,A){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,A||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===A?String:Number)(t)}(t,"string");return"symbol"==typeof A?A:String(A)}(A))in t?Object.defineProperty(t,A,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[A]=e,t}class da{constructor(t){wa(this,"bundleId",void 0),wa(this,"globalPropertyState",void 0),this.bundleId=t,this.getOrCreateGlobalPropertyState().then((t=>this.globalPropertyState=t))}getGlobalPropertyState(){return this.globalPropertyState}getAspect(t){if(!this.globalPropertyState)throw new Error("Global property state not initialized");const A=this.globalPropertyState.aspects.find((A=>A.name===t));if(A)return A.value}setAspect(t,A){if(!this.globalPropertyState)throw new Error("Global property state not initialized");const e=this.globalPropertyState.aspects.find((A=>A.name===t));return e?e.value=A:this.globalPropertyState.aspects.push({name:t,value:A}),this.updateGlobalPropertyState()}async updateGlobalPropertyState(){if(!this.globalPropertyState)throw new Error("Global property state not initialized");const t=await yA.getShadowGraphqlClient().mutate({mutation:la,variables:{id:this.globalPropertyState.id,aspects:this.globalPropertyState.aspects}});if(!t.data?.globalPropertyStateUpdate)throw new Error("Unable to update global property state");this.globalPropertyState=t.data.globalPropertyStateUpdate}async getOrCreateGlobalPropertyState(){const t=await yA.getShadowGraphqlClient().query({query:Ba,errorPolicy:"all",fetchPolicy:"no-cache",variables:{bundleId:this.bundleId}});if(t.data.globalPropertyState&&t.data.globalPropertyState.id)return t.data.globalPropertyState;const A=await yA.getShadowGraphqlClient().mutate({mutation:ga,variables:{bundleId:this.bundleId}});if(A.data?.globalPropertyStateCreate&&A.data.globalPropertyStateCreate.id)return A.data.globalPropertyStateCreate;throw new Error(`Unable to create global property state for bundle: ${this.bundleId}`)}}function ha(t,A,e){return(A=function(t){var A=function(t,A){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,A||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===A?String:Number)(t)}(t,"string");return"symbol"==typeof A?A:String(A)}(A))in t?Object.defineProperty(t,A,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[A]=e,t}class Ea{constructor(t,A){ha(this,"client",void 0),ha(this,"id",void 0),ha(this,"name",void 0),ha(this,"metadata",void 0),ha(this,"productCollection",void 0),ha(this,"globalConfigurations",void 0),ha(this,"globalPropertyStateManager",void 0),ha(this,"workflowExperiences",[]),this.client=t,this.id=A.id,this.name=A.name||"",this.metadata=new Map(A.metadata?.map((t=>[t.key,t.value]))||[]),this.productCollection=A.productCollection,this.globalConfigurations=this.resolveGlobalProperties(),this.globalPropertyStateManager=new da(this.id)}getClient(){return this.client}getId(){return this.id}getName(){return this.name}setName(t){return this.name=t,this.updateBundle()}getMetadata(){return new Map(this.metadata)}setMetadata(t){return this.metadata=new Map(t),this.updateBundle()}async hasGlobalProperties(){const t=await this.globalConfigurations;return t.length>0&&t.some((t=>t.aspects.length>0))}async getGlobalProperties(){const t=await this.globalConfigurations;if(0===t.length)throw new Error("Bundle does not have global properties");return(await Promise.all(t.map((t=>Promise.all(t.aspects.map((async t=>{switch(t.type){case It.FileUpload:return new sa(this,t);case It.Option:return new ca(this,t,t.entityId?await bA.getOption(t.entityId):void 0)}}))))))).flat()}getGlobalPropertyStateManager(){return this.globalPropertyStateManager}getTotalSubunits(){return this.workflowExperiences.map((t=>t.getTotalPriceSubunits())).reduce(((t,A)=>t+A),0)}getProductCollection(){return this.productCollection}async addWorkflowExperience(t){const A=t.getWorkflowManager().getTransaction().id;if(this.workflowExperiences.find((t=>t.getWorkflowManager().getTransaction().id===A)))throw new Error("Unable to add transaction to bundle - Already Exists!");await yA.getShadowGraphqlClient().mutate({mutation:Aa,variables:{id:this.id,transactionId:A}}),this.workflowExperiences.push(t)}async removeWorkflowExperience(t){const A=this.workflowExperiences.indexOf(t);if(!(A>-1))throw new Error("Unable to remove workflow experience from bundle - Not Found!");await yA.getShadowGraphqlClient().mutate({mutation:ea,variables:{id:this.id,transactionId:t.getWorkflowManager().getTransaction().id}}),this.workflowExperiences.splice(A,1)}getWorkflowExperiences(){return[...this.workflowExperiences]}sortWorkflowExperiences(t){this.workflowExperiences=this.workflowExperiences.sort(t)}getWorkflowExperienceCount(){return this.workflowExperiences.length}async addStakeholder(t,A){await yA.getShadowGraphqlClient().mutate({mutation:na,variables:{id:this.id,details:t,type:A||oe.Owner}})}async updateStakeholders(t){await yA.getShadowGraphqlClient().mutate({mutation:ia,variables:{id:this.id,input:t}})}async getAllStakeholders(){const t=await yA.getShadowGraphqlClient().query({query:$i,errorPolicy:"all",variables:{id:this.id}});if(!t.data.bundles||0===t.data.bundles.length)throw new Error("Bundle not found!");return t.data.bundles[0].bundleStakeholders||[]}async reloadWorkflowExperience(t,A){const e=A?e=>A(e,t):void 0,n=await this.client.getWorkflowExperience(void 0,void 0,e,{type:"transaction",transactionId:t}),i=this.workflowExperiences.findIndex((A=>A.getWorkflowManager().getTransaction().id===t));return i>-1?this.workflowExperiences[i]=n:this.workflowExperiences.push(n),n}async updateBundle(){if(!(await yA.getShadowGraphqlClient().mutate({mutation:ta,variables:{id:this.id,name:this.name,metadata:Array.from(this.metadata.entries()).map((([t,A])=>({key:t,value:A})))}})).data?.bundleUpdate)throw new Error("Bundle not found!")}async resolveGlobalProperties(){const t=this.productCollection;if(!t)return Promise.resolve([]);const A=new Set;t.products.forEach((t=>t.workflows?.forEach((t=>A.add(t.workflowName)))));const e=await yA.getShadowGraphqlClient().query({query:aa,errorPolicy:"all",variables:{ids:Array.from(A)}}),n=new Map;return e.data.workflows?.forEach((t=>{t.globalPropertyConfiguration&&n.set(t.globalPropertyConfiguration.id,t.globalPropertyConfiguration)})),Object.values(n)}}function Ca(t,A,e){return(A=function(t){var A=function(t,A){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,A||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===A?String:Number)(t)}(t,"string");return"symbol"==typeof A?A:String(A)}(A))in t?Object.defineProperty(t,A,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[A]=e,t}const Qa=ft`
|
|
655
655
|
${FA}
|
|
656
656
|
${SA}
|
|
657
657
|
${GA}
|
package/dist/types.d.ts
CHANGED
|
@@ -1923,6 +1923,7 @@ declare abstract class GlobalPropertyHandle {
|
|
|
1923
1923
|
}
|
|
1924
1924
|
interface GlobalPropertyStateManager {
|
|
1925
1925
|
getGlobalPropertyState(): GlobalPropertyState | undefined;
|
|
1926
|
+
getAspect(name: string): string | undefined;
|
|
1926
1927
|
setAspect(name: string, value: string): Promise<void>;
|
|
1927
1928
|
}
|
|
1928
1929
|
/**
|