@spiffcommerce/core 15.2.3 → 15.2.4

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 CHANGED
@@ -897,7 +897,7 @@ var t=require("@apollo/client"),e=require("lodash.clonedeep"),i=require("react/j
897
897
  id
898
898
  }
899
899
  }
900
- `;function Cc(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Qc{constructor(t){Cc(this,"bundle",void 0),Cc(this,"handleCache",{}),this.bundle=t}async getHandle(t){if(this.handleCache[t.name])return this.handleCache[t.name];const e=await this.createHandle(t);return this.handleCache[t.name]=e,e}async getHandles(){if(!this.bundle.getProductCollection()?.getResource().globalPropertyConfiguration)return[];const t=this.bundle.getProductCollection().getResource().globalPropertyConfiguration;return Promise.all(t.aspects.map((t=>this.getHandle(t))))}applyConditionsFromState(t,e){return e?t.filter((t=>this.aspectConditionsSatisfied(t.getRawProperty(),e))):t}aspectConditionsSatisfied(t,e){return!t.conditions||0===t.conditions.length||t.conditions.some((t=>{const i=e.aspects.find((e=>e.name===t.targetAspectName));return!!i&&t.requiredVariantSelections.some((t=>t===i.value))}))}async createHandle(t){switch(t.type){case ei.FileUpload:return new Ic(this.bundle,t);case ei.Option:{const e=t.entityId?await Ja.getOption(t.entityId):void 0;return"Color"===e?.type?new vc(this.bundle,t,e):new xc(this.bundle,t,e)}case ei.Text:return new Dc(this.bundle,t)}}}class yc{constructor(t,e){Cc(this,"bundle",void 0),Cc(this,"property",void 0),this.bundle=t,this.property=e}getName(){return this.property.name}getTitle(){return this.property.title}getDescription(){return this.property.description}getType(){return this.property.type}getRawProperty(){return this.property}getSharedSteps(t){return(t??this.bundle.getWorkflowExperiences()).flatMap((t=>t.getSteps().filter((t=>t.getRaw().globalPropertyAspectConfigurations?.some((t=>t.globalPropertyConfigurationId===this.bundle.getProductCollection()?.getResource().globalPropertyConfiguration?.id&&t.aspectName===this.property.name))))))}}class Ic extends yc{constructor(t,e){super(t,e)}async selectImage(t){await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t.key),this.applyImageSelection(t)])}async applyGlobalState(t){const e=this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name);if(!e)return Promise.resolve();const i=await ka.getLocalOrFromServer(e);return i?this.applyImageSelection(i,t):Promise.resolve()}async applyImageSelection(t,e){const i=this.getSharedSteps(e).map((e=>e.selectImage(t)));await Promise.all(i)}}class Dc extends yc{constructor(t,e){super(t,e)}getText(){const t=this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name);return t||""}async setText(t){await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t),this.applyTextSelection(t)])}async applyGlobalState(t){const e=this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name);if(!e)return Promise.resolve();await this.applyTextSelection(e,t)}async applyTextSelection(t,e){const i=this.getSharedSteps(e).map((e=>{e.setText(t)}));await Promise.all(i)}}class xc extends yc{constructor(t,e,i){super(t,e),Cc(this,"optionResource",void 0),this.optionResource=i}getCurrentVariant(){if(!this.optionResource)return;const t=this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name);if(t){const e=this.optionResource.variants?.find((e=>e.id===t));if(!e)return;return new bs(e)}{const t=this.optionResource.variants?.find((t=>t.default));if(!t)return;return new bs(t)}}getAvailableVariants(){return(this.optionResource?.variants?.filter((t=>t.enabled))||[]).map((t=>new bs(t)))}getAllVariants(){return(this.optionResource?.variants||[]).map((t=>new bs(t)))}async selectVariant(t){await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t.getId()),this.applyVariantSelection(t)])}async applyGlobalState(t){const e=this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name);if(!e)return Promise.resolve();const i=this.optionResource?.variants?.find((t=>t.id===e));return i?this.applyVariantSelection(new bs(i),t):Promise.resolve()}async applyVariantSelection(t,e){const i=this.getSharedSteps(e).map((e=>e.selectVariant(t)));await Promise.all(i)}}class vc extends xc{constructor(t,e,i){super(t,e,i)}setCustomColor(t){this.getSharedSteps().forEach((e=>e.setCustomColor(t)))}getCustomColor(){return this.getSharedSteps()[0].getCustomColor()}}const Mc=v.gql`
900
+ `;function Cc(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Qc{constructor(t){Cc(this,"bundle",void 0),Cc(this,"handleCache",{}),this.bundle=t}async getHandle(t){if(this.handleCache[t.name])return this.handleCache[t.name];const e=await this.createHandle(t);return this.handleCache[t.name]=e,e}async getHandles(){if(!this.bundle.getProductCollection()?.getResource().globalPropertyConfiguration)return[];const t=this.bundle.getProductCollection().getResource().globalPropertyConfiguration;return Promise.all(t.aspects.map((t=>this.getHandle(t))))}applyConditionsFromState(t,e){return e?t.filter((t=>this.aspectConditionsSatisfied(t.getRawProperty(),e))):t}aspectConditionsSatisfied(t,e){return!t.conditions||0===t.conditions.length||t.conditions.some((t=>{const i=e.aspects.find((e=>e.name===t.targetAspectName));return!!i&&t.requiredVariantSelections.some((t=>t===i.value))}))}async createHandle(t){switch(t.type){case ei.FileUpload:return new Ic(this.bundle,t);case ei.Option:{const e=t.entityId?await Ja.getOption(t.entityId):void 0;return"Color"===e?.type?new vc(this.bundle,t,e):new xc(this.bundle,t,e)}case ei.Text:return new Dc(this.bundle,t)}}}class yc{constructor(t,e){Cc(this,"bundle",void 0),Cc(this,"property",void 0),this.bundle=t,this.property=e}getName(){return this.property.name}getTitle(){return this.property.title}getDescription(){return this.property.description}getType(){return this.property.type}getRawProperty(){return this.property}getSharedSteps(t){return(t??this.bundle.getWorkflowExperiences()).flatMap((t=>t.getSteps().filter((t=>t.getRaw().globalPropertyAspectConfigurations?.some((t=>t.globalPropertyConfigurationId===this.bundle.getProductCollection()?.getResource().globalPropertyConfiguration?.id&&t.aspectName===this.property.name))))))}}class Ic extends yc{constructor(t,e){super(t,e)}async selectImage(t){await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t.key),this.applyImageSelection(t)])}async applyGlobalState(t){const e=this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name);if(!e)return Promise.resolve();const i=await ka.getLocalOrFromServer(e);return i?this.applyImageSelection(i,t):Promise.resolve()}async applyImageSelection(t,e){const i=this.getSharedSteps(e).map((e=>e.selectImage(t)));await Promise.all(i)}}class Dc extends yc{constructor(t,e){super(t,e)}getText(){const t=this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name);return t||""}async setText(t){await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t),this.applyTextSelection(t)])}async applyGlobalState(t){const e=this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name);if(!e)return Promise.resolve();await this.applyTextSelection(e,t)}async applyTextSelection(t,e){const i=this.getSharedSteps(e).map((e=>{e.setText(t)}));await Promise.all(i)}}class xc extends yc{constructor(t,e,i){super(t,e),Cc(this,"optionResource",void 0),this.optionResource=i}getCurrentVariant(){if(!this.optionResource)return;const t=this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name);if(t){const e=this.optionResource.variants?.find((e=>e.id===t));if(!e)return;return new bs(e)}{const t=this.optionResource.variants?.find((t=>t.id===this.optionResource?.defaultVariant?.id));if(!t)return;return new bs(t)}}getAvailableVariants(){return(this.optionResource?.variants?.filter((t=>t.enabled))||[]).map((t=>new bs(t)))}getAllVariants(){return(this.optionResource?.variants||[]).map((t=>new bs(t)))}async selectVariant(t){await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t.getId()),this.applyVariantSelection(t)])}async applyGlobalState(t){const e=this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name);if(!e)return Promise.resolve();const i=this.optionResource?.variants?.find((t=>t.id===e));return i?this.applyVariantSelection(new bs(i),t):Promise.resolve()}async applyVariantSelection(t,e){const i=this.getSharedSteps(e).map((e=>e.selectVariant(t)));await Promise.all(i)}}class vc extends xc{constructor(t,e,i){super(t,e,i)}setCustomColor(t){this.getSharedSteps().forEach((e=>e.setCustomColor(t)))}getCustomColor(){return this.getSharedSteps()[0].getCustomColor()}}const Mc=v.gql`
901
901
  mutation CreateGlobalPropertyState($bundleId: String!) {
902
902
  globalPropertyStateCreate(bundleId: $bundleId) {
903
903
  id
package/dist/module.js CHANGED
@@ -897,7 +897,7 @@ import{CommandContext as t,AssetType as e,BringForwardCommand as A,BringToFrontC
897
897
  id
898
898
  }
899
899
  }
900
- `;function mi(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var n=A.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class fi{constructor(t){mi(this,"bundle",void 0),mi(this,"handleCache",{}),this.bundle=t}async getHandle(t){if(this.handleCache[t.name])return this.handleCache[t.name];const e=await this.createHandle(t);return this.handleCache[t.name]=e,e}async getHandles(){if(!this.bundle.getProductCollection()?.getResource().globalPropertyConfiguration)return[];const t=this.bundle.getProductCollection().getResource().globalPropertyConfiguration;return Promise.all(t.aspects.map((t=>this.getHandle(t))))}applyConditionsFromState(t,e){return e?t.filter((t=>this.aspectConditionsSatisfied(t.getRawProperty(),e))):t}aspectConditionsSatisfied(t,e){return!t.conditions||0===t.conditions.length||t.conditions.some((t=>{const A=e.aspects.find((e=>e.name===t.targetAspectName));return!!A&&t.requiredVariantSelections.some((t=>t===A.value))}))}async createHandle(t){switch(t.type){case Dt.FileUpload:return new Ii(this.bundle,t);case Dt.Option:{const e=t.entityId?await Oe.getOption(t.entityId):void 0;return"Color"===e?.type?new Fi(this.bundle,t,e):new Mi(this.bundle,t,e)}case Dt.Text:return new yi(this.bundle,t)}}}class Di{constructor(t,e){mi(this,"bundle",void 0),mi(this,"property",void 0),this.bundle=t,this.property=e}getName(){return this.property.name}getTitle(){return this.property.title}getDescription(){return this.property.description}getType(){return this.property.type}getRawProperty(){return this.property}getSharedSteps(t){return(t??this.bundle.getWorkflowExperiences()).flatMap((t=>t.getSteps().filter((t=>t.getRaw().globalPropertyAspectConfigurations?.some((t=>t.globalPropertyConfigurationId===this.bundle.getProductCollection()?.getResource().globalPropertyConfiguration?.id&&t.aspectName===this.property.name))))))}}class Ii extends Di{constructor(t,e){super(t,e)}async selectImage(t){await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t.key),this.applyImageSelection(t)])}async applyGlobalState(t){const e=this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name);if(!e)return Promise.resolve();const A=await be.getLocalOrFromServer(e);return A?this.applyImageSelection(A,t):Promise.resolve()}async applyImageSelection(t,e){const A=this.getSharedSteps(e).map((e=>e.selectImage(t)));await Promise.all(A)}}class yi extends Di{constructor(t,e){super(t,e)}getText(){const t=this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name);return t||""}async setText(t){await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t),this.applyTextSelection(t)])}async applyGlobalState(t){const e=this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name);if(!e)return Promise.resolve();await this.applyTextSelection(e,t)}async applyTextSelection(t,e){const A=this.getSharedSteps(e).map((e=>{e.setText(t)}));await Promise.all(A)}}class Mi extends Di{constructor(t,e,A){super(t,e),mi(this,"optionResource",void 0),this.optionResource=A}getCurrentVariant(){if(!this.optionResource)return;const t=this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name);if(t){const e=this.optionResource.variants?.find((e=>e.id===t));if(!e)return;return new xa(e)}{const t=this.optionResource.variants?.find((t=>t.default));if(!t)return;return new xa(t)}}getAvailableVariants(){return(this.optionResource?.variants?.filter((t=>t.enabled))||[]).map((t=>new xa(t)))}getAllVariants(){return(this.optionResource?.variants||[]).map((t=>new xa(t)))}async selectVariant(t){await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t.getId()),this.applyVariantSelection(t)])}async applyGlobalState(t){const e=this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name);if(!e)return Promise.resolve();const A=this.optionResource?.variants?.find((t=>t.id===e));return A?this.applyVariantSelection(new xa(A),t):Promise.resolve()}async applyVariantSelection(t,e){const A=this.getSharedSteps(e).map((e=>e.selectVariant(t)));await Promise.all(A)}}class Fi extends Mi{constructor(t,e,A){super(t,e,A)}setCustomColor(t){this.getSharedSteps().forEach((e=>e.setCustomColor(t)))}getCustomColor(){return this.getSharedSteps()[0].getCustomColor()}}const Si=Zt`
900
+ `;function mi(t,e,A){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var A=t[Symbol.toPrimitive];if(void 0!==A){var n=A.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):t[e]=A,t}class fi{constructor(t){mi(this,"bundle",void 0),mi(this,"handleCache",{}),this.bundle=t}async getHandle(t){if(this.handleCache[t.name])return this.handleCache[t.name];const e=await this.createHandle(t);return this.handleCache[t.name]=e,e}async getHandles(){if(!this.bundle.getProductCollection()?.getResource().globalPropertyConfiguration)return[];const t=this.bundle.getProductCollection().getResource().globalPropertyConfiguration;return Promise.all(t.aspects.map((t=>this.getHandle(t))))}applyConditionsFromState(t,e){return e?t.filter((t=>this.aspectConditionsSatisfied(t.getRawProperty(),e))):t}aspectConditionsSatisfied(t,e){return!t.conditions||0===t.conditions.length||t.conditions.some((t=>{const A=e.aspects.find((e=>e.name===t.targetAspectName));return!!A&&t.requiredVariantSelections.some((t=>t===A.value))}))}async createHandle(t){switch(t.type){case Dt.FileUpload:return new Ii(this.bundle,t);case Dt.Option:{const e=t.entityId?await Oe.getOption(t.entityId):void 0;return"Color"===e?.type?new Fi(this.bundle,t,e):new Mi(this.bundle,t,e)}case Dt.Text:return new yi(this.bundle,t)}}}class Di{constructor(t,e){mi(this,"bundle",void 0),mi(this,"property",void 0),this.bundle=t,this.property=e}getName(){return this.property.name}getTitle(){return this.property.title}getDescription(){return this.property.description}getType(){return this.property.type}getRawProperty(){return this.property}getSharedSteps(t){return(t??this.bundle.getWorkflowExperiences()).flatMap((t=>t.getSteps().filter((t=>t.getRaw().globalPropertyAspectConfigurations?.some((t=>t.globalPropertyConfigurationId===this.bundle.getProductCollection()?.getResource().globalPropertyConfiguration?.id&&t.aspectName===this.property.name))))))}}class Ii extends Di{constructor(t,e){super(t,e)}async selectImage(t){await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t.key),this.applyImageSelection(t)])}async applyGlobalState(t){const e=this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name);if(!e)return Promise.resolve();const A=await be.getLocalOrFromServer(e);return A?this.applyImageSelection(A,t):Promise.resolve()}async applyImageSelection(t,e){const A=this.getSharedSteps(e).map((e=>e.selectImage(t)));await Promise.all(A)}}class yi extends Di{constructor(t,e){super(t,e)}getText(){const t=this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name);return t||""}async setText(t){await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t),this.applyTextSelection(t)])}async applyGlobalState(t){const e=this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name);if(!e)return Promise.resolve();await this.applyTextSelection(e,t)}async applyTextSelection(t,e){const A=this.getSharedSteps(e).map((e=>{e.setText(t)}));await Promise.all(A)}}class Mi extends Di{constructor(t,e,A){super(t,e),mi(this,"optionResource",void 0),this.optionResource=A}getCurrentVariant(){if(!this.optionResource)return;const t=this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name);if(t){const e=this.optionResource.variants?.find((e=>e.id===t));if(!e)return;return new xa(e)}{const t=this.optionResource.variants?.find((t=>t.id===this.optionResource?.defaultVariant?.id));if(!t)return;return new xa(t)}}getAvailableVariants(){return(this.optionResource?.variants?.filter((t=>t.enabled))||[]).map((t=>new xa(t)))}getAllVariants(){return(this.optionResource?.variants||[]).map((t=>new xa(t)))}async selectVariant(t){await Promise.all([this.bundle.getGlobalPropertyStateManager().setAspect(this.property.name,t.getId()),this.applyVariantSelection(t)])}async applyGlobalState(t){const e=this.bundle.getGlobalPropertyStateManager().getAspect(this.property.name);if(!e)return Promise.resolve();const A=this.optionResource?.variants?.find((t=>t.id===e));return A?this.applyVariantSelection(new xa(A),t):Promise.resolve()}async applyVariantSelection(t,e){const A=this.getSharedSteps(e).map((e=>e.selectVariant(t)));await Promise.all(A)}}class Fi extends Mi{constructor(t,e,A){super(t,e,A)}setCustomColor(t){this.getSharedSteps().forEach((e=>e.setCustomColor(t)))}getCustomColor(){return this.getSharedSteps()[0].getCustomColor()}}const Si=Zt`
901
901
  mutation CreateGlobalPropertyState($bundleId: String!) {
902
902
  globalPropertyStateCreate(bundleId: $bundleId) {
903
903
  id
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spiffcommerce/core",
3
- "version": "15.2.3",
3
+ "version": "15.2.4",
4
4
  "description": "Core client API for interacting with the Spiff Commerce backend.",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/main.js",