@spiffcommerce/core 27.2.1-beta.f9f891fb-9e3d-52fc-8c9a-0382e6e1afa4 → 27.3.0-beta.03158811-571a-5ee0-a571-7a626071de03

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.md CHANGED
@@ -14,6 +14,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
14
14
  - `Fixed` for any bug fixes.
15
15
  - `Security` in case of vulnerabilities.
16
16
 
17
+ ## [27.3.0] - 28-07-2025
18
+
19
+ ## Added
20
+
21
+ - CurrencyService & CurrencyContext can now be used to correctly transform values for display. See `client.getCurrencyContext`
22
+
17
23
  ## [27.2.1] - 28-07-2025
18
24
 
19
25
  ## Fixed
package/dist/index.d.ts CHANGED
@@ -5,6 +5,7 @@ import { RenderableContextService, RenderableContext, ThreeDPreviewService, Mode
5
5
  import * as lodash from 'lodash';
6
6
  import { CompleteQuoteMessage, ThemeInstallConfigurationGraphQl, ConversionConfiguration } from '@spiffcommerce/theme-bridge';
7
7
  export { ConversionConfiguration, ConversionData, ConversionDataType, ConversionLocation } from '@spiffcommerce/theme-bridge';
8
+ import { Currency } from 'dinero.js';
8
9
  import { FuseResult } from 'fuse.js';
9
10
  import { Font } from 'opentype.js';
10
11
 
@@ -1374,14 +1375,13 @@ declare abstract class GlobalPropertyHandle {
1374
1375
  /**
1375
1376
  * Applies the global state to all shared steps, if the state is set.
1376
1377
  * @param targetExperiences Optionally filter the workflow experiences it should be applied to.
1377
- * @param checkAllSteps Whether to consider all steps in the workflow, not just the ones that are conditionally active.
1378
1378
  */
1379
- abstract applyGlobalState(targetExperiences?: WorkflowExperience[], checkAllSteps?: boolean): Promise<void>;
1379
+ abstract applyGlobalState(targetExperiences?: WorkflowExperience[]): Promise<void>;
1380
1380
  /**
1381
1381
  * Returns all steps that share this property.
1382
1382
  * @param targetExperiences Optionally filter the steps to only those in the given experiences.
1383
1383
  */
1384
- protected getSharedSteps(targetExperiences?: WorkflowExperience[], checkAllSteps?: boolean): StepHandle<AnyStepData>[];
1384
+ protected getSharedSteps(targetExperiences?: WorkflowExperience[]): StepHandle<AnyStepData>[];
1385
1385
  protected getStateValue(): string | undefined;
1386
1386
  }
1387
1387
  /**
@@ -1428,7 +1428,7 @@ declare class FileUploadGlobalPropertyHandle extends GlobalPropertyHandle {
1428
1428
  getBackgroundRemovedImage(): Promise<Asset | undefined>;
1429
1429
  getUseOriginalImage(): boolean;
1430
1430
  setUseOriginalImage(value: boolean): Promise<void>;
1431
- applyGlobalState(targetExperiences?: WorkflowExperience[], checkAllSteps?: boolean): Promise<void>;
1431
+ applyGlobalState(targetExperiences?: WorkflowExperience[]): Promise<void>;
1432
1432
  getAvailableColors(): ColorOption[];
1433
1433
  getCurrentColors(): {
1434
1434
  [key: string]: ColorDefinition;
@@ -1440,7 +1440,7 @@ declare class FileUploadGlobalPropertyHandle extends GlobalPropertyHandle {
1440
1440
  } | undefined>;
1441
1441
  changeColors(newFills: {
1442
1442
  [key: string]: ColorDefinition;
1443
- }, checkAllSteps?: boolean): Promise<void>;
1443
+ }): Promise<void>;
1444
1444
  private applyImageSelection;
1445
1445
  private updateSharedStepStorage;
1446
1446
  }
@@ -1453,7 +1453,7 @@ declare class TextGlobalPropertyHandle extends GlobalPropertyHandle {
1453
1453
  /**
1454
1454
  * Set the text.
1455
1455
  */
1456
- setText(text: string, checkAllSteps?: boolean): Promise<void>;
1456
+ setText(text: string): Promise<void>;
1457
1457
  applyGlobalState(targetExperiences?: WorkflowExperience[]): Promise<void>;
1458
1458
  private applyTextSelection;
1459
1459
  }
@@ -1484,7 +1484,7 @@ declare class OptionGlobalPropertyHandle extends GlobalPropertyHandle {
1484
1484
  * Select a given variant on the option for all shared steps.
1485
1485
  * @param variant The variant to select.
1486
1486
  */
1487
- selectVariant(variant: Variant, channel?: number, checkAllSteps?: boolean): Promise<void>;
1487
+ selectVariant(variant: Variant, channel?: number): Promise<void>;
1488
1488
  applyGlobalState(targetExperiences?: WorkflowExperience[]): Promise<void>;
1489
1489
  private applyVariantSelection;
1490
1490
  }
@@ -1505,7 +1505,7 @@ declare class ColorOptionGlobalPropertyHandle extends OptionGlobalPropertyHandle
1505
1505
  /**
1506
1506
  * Sets a custom color on the global state.
1507
1507
  */
1508
- setCustomColor(color: string, checkAllSteps?: boolean): void;
1508
+ setCustomColor(color: string): void;
1509
1509
  /**
1510
1510
  * Gets the custom color used by the global state.
1511
1511
  */
@@ -2188,6 +2188,57 @@ declare class IntegrationProduct {
2188
2188
  getAllWorkflows(): ProductWorkflow$1[];
2189
2189
  }
2190
2190
 
2191
+ declare class CurrencyService {
2192
+ /**
2193
+ * Returns a formatted string representing a given amount with desired currency.
2194
+ * @param currency The currency to represent the amount in.
2195
+ * @param amount The amount in minor units to format.
2196
+ */
2197
+ formatCurrencyForDisplay(currency: Currency, amount: number): any;
2198
+ /**
2199
+ * Get the number of decimal places expected in a currency string.
2200
+ * @param currency The currency to determine precision for.
2201
+ */
2202
+ getPrecisionForCurrency(currency: Currency): number;
2203
+ /**
2204
+ * Sometimes default formatting will display format in a way that isn't natural
2205
+ * for natives of a currency. This function is intended to capture those specific cases and return a format
2206
+ * that makes the most sense.
2207
+ * @param currency The currency to test for special format.
2208
+ */
2209
+ private getSpecialFormat;
2210
+ }
2211
+ declare class CurrencyContext {
2212
+ private readonly presentmentCurrency?;
2213
+ private readonly partnerCurrency;
2214
+ private readonly rateFrom;
2215
+ private readonly rateTo;
2216
+ constructor(rateFrom: number, rateTo: number, partnerCurrency: Currency, presentmentCurrency?: Currency);
2217
+ /**
2218
+ * @returns The currency code for the currency being used for monetary display.
2219
+ */
2220
+ code(): Currency;
2221
+ /**
2222
+ * @returns true if the conversion is required, false otherwise.
2223
+ */
2224
+ conversionRequired(): boolean;
2225
+ /**
2226
+ * Converts a monetary value from a workflow in a partner specified currency
2227
+ * to the units of the currency being used for display.
2228
+ * @param amount The amount in minor units to convert.
2229
+ * @returns
2230
+ */
2231
+ getConvertedSubunits(amount: number): number;
2232
+ /**
2233
+ * Converts a monetary value from the database to the units of its currency.
2234
+ */
2235
+ private units;
2236
+ /**
2237
+ * Converts a monetary value in units to the subunits of its currency.
2238
+ */
2239
+ private subunits;
2240
+ }
2241
+
2191
2242
  declare const getWorkflows: (ids: string[], options?: GetWorkflowGraphqlOptions) => Promise<Workflow[]>;
2192
2243
  declare const getWorkflow: (id: string, options?: GetWorkflowGraphqlOptions) => Promise<Workflow>;
2193
2244
  /**
@@ -2299,7 +2350,6 @@ interface ClientConfiguration {
2299
2350
  */
2300
2351
  declare class SpiffCommerceClient {
2301
2352
  private options;
2302
- private currencyCode?;
2303
2353
  private customer?;
2304
2354
  private activeIntegration?;
2305
2355
  private marketplaceThemeInstallId?;
@@ -2314,8 +2364,8 @@ declare class SpiffCommerceClient {
2314
2364
  * and the Spiff Commerce platform.
2315
2365
  */
2316
2366
  getAssetManager(): AssetManager;
2317
- getCurrencyCode(): string;
2318
2367
  getFlowService(): FlowService;
2368
+ getCurrencyContext(presentmentCurrency: string): Promise<CurrencyContext>;
2319
2369
  getIntegration(): Promise<Integration>;
2320
2370
  canUseAddon(addonHandle: AddonHandle): Promise<boolean>;
2321
2371
  /**
@@ -2400,7 +2450,7 @@ declare class SpiffCommerceClient {
2400
2450
  * @param duplicateTransactions Optional: Whether to also duplicate the original bundle's transactions. Default is true.
2401
2451
  * @returns A bundle to be used for grouping and operating on large amounts of workflow experiences.
2402
2452
  */
2403
- duplicateBundle(bundleId: string, template?: boolean, duplicateTransactions?: boolean, options?: GetBundleOptions): Promise<Bundle$1>;
2453
+ duplicateBundle(bundleId: string, template?: boolean, duplicateTransactions?: boolean, options?: GetBundleOptions): Promise<() => Promise<Bundle$1>>;
2404
2454
  /**
2405
2455
  * Fetches information about the currently authenticated customer's bundles.
2406
2456
  * NOTE: This does not initialize a bundle for active use.
@@ -5854,4 +5904,4 @@ declare const validateWorkflowExperienceRecipients: (workflowExperiences: Workfl
5854
5904
  */
5855
5905
  declare const getGlobalPropertyStateForBundle: (bundleId: string) => Promise<GlobalPropertyState | undefined>;
5856
5906
 
5857
- export { AddonHandle, AddressComponent, AddressValidationJob, AddressValidationJobStatus, AddressValidationResult, AddressValidationResultConfirmationLevel, Animatable, AnyStepData, ArrayInput, AspectType, Asset, AssetConfiguration, AssetNotFoundError, AssetObjectVersion, AssetType, BringForwardCommand, BringToBackCommand, BringToFrontCommand, Bundle$1 as Bundle, BundleDesignCreationCartAddMode, BundleDesignCreationMessage, BundleEvent, BundleEventData, BundleEventType, Bundle as BundleRaw, BundleStakeholder, CanvasCommand, CollectionProduct, ColorDefinition, ColorOption, ColorOptionGlobalPropertyHandle, ColorProfileProps, CommandContext, CommandState, Condition, ConditionalGlobalPropertiesChangedEventData, CreateElementCommand, CreateLayoutCommand, Customer, CustomerDetailsInput, DeleteElementCommand, DesignCreationMessage, DesignCreationProgressUpdate, DesignInputStep, DigitalContentStepData, DigitalContentStepHandle, EditedSteps, FileUploadGlobalPropertyHandle, FlowExecutionNodeResult, FlowExecutionResult, FlowService, FontAlignmentCommand, FontColorCommand, FontSizeCommand, FontSourceCommand, FrameElement, FrameService, FrameStep, FrameStepData, FrameStepHandle, FrameThresholdSettings, GetNewWorkflowOptions, GetWorkflowOptions, GlobalPropertyConfiguration, GlobalPropertyHandle, GroupCommand, ILayout, IllustrationElement, IllustrationStepData, IllustrationStepHandle, ImageElement, InformationMessageType, InformationResult, InformationStepData, InformationStepHandle, Integration, IntegrationOptionResource, IntegrationProduct, IntegrationType, LayoutComponentConfiguration, LayoutData, LayoutElement, LayoutElementFactory, LayoutElementType, LayoutNotFoundError, LayoutRenderingPurpose, LayoutState, LayoutsState, MandatorySteps, MaterialEffectMode, MaterialStepData, MaterialStepHandle, MisconfigurationError, MockWorkflowManager, ModelStepData, ModelStepHandle, ModuleStepData, ModuleStepHandle, MoveCommand, NodeType, ObjectInput, ObjectInputType, OptionGlobalPropertyHandle, OptionNotFoundError, OptionResource, Order, OrderItem, PapyrusComponent, ParseError, PictureStepData, PictureStepHandle, Placeable, PmsSearchResult, Point, Product, ProductCameraRig, ProductCollection, ProductCollectionProductSortKey, ProductWorkflow$1 as ProductWorkflow, promiseCache as PromiseCache, PromiseQueue, QuestionStepData, QuestionStepHandle, QueueablePromise, Recipient, Region, RegionElement, RenderableScene, ResizeCommand, ResourceNotFoundError, RotateCommand, SavedDesign, ScaleAxis, SelectionStorage, SendBackwardsCommand, ShapeStepData, ShapeStepHandle, ShareAction, ShareActionType, SilentIllustrationStepData, SpiffCommerceClient, Stakeholder, StakeholderType, StateMutationFunc, Step, StepAspect, StepAspectType, StepElements, StepGroup, StepHandle, StepStorage, StepType, TextAlgorithm, TextChangeCommand, TextChangeResult, TextGlobalPropertyHandle, TextInput, TextStepData, TextStepHandle, TextStepStorage, TextboxElement, Theme, ToastCallback, Transaction, Transform, TransformCollection$1 as TransformCollection, UnhandledBehaviorError, UnitOfMeasurement, UpdateImageSourceCommand, Variant, VariantResource, Vector3, Workflow, WorkflowExperience, WorkflowExperienceEventType, WorkflowExperienceHoverEventData, WorkflowExperienceImpl, WorkflowManager, WorkflowMetadata, WorkflowPanel, WorkflowScene, WorkflowSelections, WorkflowStorage, assetService, browserColorToHex, cmPerPixel, createDesign, currentDirection, dataUrlFromExternalUrl, designService, determineCorrectFontSizeAndLines, digitalContentStepService, domParser, duplicateBundle, duplicateTransaction, fetchAsString, findAngle, findElement, findPmsColors, frameDataCache, frameStepService, generate, generateCommands, generateSVGWithUnknownColors, generateStateFromDesignInputSteps, getAddressValidationJobs, getAttributesFromArrayBuffer, getAxisAlignedBoundingBox, getBoundedOffsets, getBundleThemeConfiguration, getCustomer, getCustomerBundles, getElementVertices, getFrameData, getGlobalPropertyStateForBundle, getIntegration, getNEPoint, getNWPoint, getOrderedTransactions, getOverrideThemeConfiguration, getPointOfRotation, getProductCollections, getSEPoint, getSvgElement, getTemplateBundles, getTemplateTransactions, getTransaction, getTransactionThemeConfiguration, getTransactionsForBundle, getTrueCoordinates, getUnorderedTransactions, getValidationJobsForWorkflowExperiences, getWorkflow, getWorkflows, graphQlManager, illustrationStepService, isCloseToValue, loadFont, matchHexToPms, materialStepService, metafieldManager, mmPerPixel, modelStepService, modifySVGColors, moduleStepService, nameBundle, nameTransaction, optionService, outlineFontsInSvg, patternImageDataCache, persistenceService, pictureStepService, pmsToRgb, questionStepService, registerFetchImplementation, registerWindowImplementation, rehydrateSerializedLayout, rgbToPms, rotateAroundPoint, sanitizeSvgTree, setBearerAuthenticationToken, setCanvasModule, shapeStepService, shortenUrl, spiffCoreConfiguration, stepAspectValuesToDesignInputSteps, svgColorValueToDefinition, svgStringDimensions, svgToDataUrl, textStepService, toast, validateWorkflowExperienceRecipient, validateWorkflowExperienceRecipients, xmlSerializer };
5907
+ export { AddonHandle, AddressComponent, AddressValidationJob, AddressValidationJobStatus, AddressValidationResult, AddressValidationResultConfirmationLevel, Animatable, AnyStepData, ArrayInput, AspectType, Asset, AssetConfiguration, AssetNotFoundError, AssetObjectVersion, AssetType, BringForwardCommand, BringToBackCommand, BringToFrontCommand, Bundle$1 as Bundle, BundleDesignCreationCartAddMode, BundleDesignCreationMessage, BundleEvent, BundleEventData, BundleEventType, Bundle as BundleRaw, BundleStakeholder, CanvasCommand, CollectionProduct, ColorDefinition, ColorOption, ColorOptionGlobalPropertyHandle, ColorProfileProps, CommandContext, CommandState, Condition, ConditionalGlobalPropertiesChangedEventData, CreateElementCommand, CreateLayoutCommand, CurrencyContext, CurrencyService, Customer, CustomerDetailsInput, DeleteElementCommand, DesignCreationMessage, DesignCreationProgressUpdate, DesignInputStep, DigitalContentStepData, DigitalContentStepHandle, EditedSteps, FileUploadGlobalPropertyHandle, FlowExecutionNodeResult, FlowExecutionResult, FlowService, FontAlignmentCommand, FontColorCommand, FontSizeCommand, FontSourceCommand, FrameElement, FrameService, FrameStep, FrameStepData, FrameStepHandle, FrameThresholdSettings, GetNewWorkflowOptions, GetWorkflowOptions, GlobalPropertyConfiguration, GlobalPropertyHandle, GroupCommand, ILayout, IllustrationElement, IllustrationStepData, IllustrationStepHandle, ImageElement, InformationMessageType, InformationResult, InformationStepData, InformationStepHandle, Integration, IntegrationOptionResource, IntegrationProduct, IntegrationType, LayoutComponentConfiguration, LayoutData, LayoutElement, LayoutElementFactory, LayoutElementType, LayoutNotFoundError, LayoutRenderingPurpose, LayoutState, LayoutsState, MandatorySteps, MaterialEffectMode, MaterialStepData, MaterialStepHandle, MisconfigurationError, MockWorkflowManager, ModelStepData, ModelStepHandle, ModuleStepData, ModuleStepHandle, MoveCommand, NodeType, ObjectInput, ObjectInputType, OptionGlobalPropertyHandle, OptionNotFoundError, OptionResource, Order, OrderItem, PapyrusComponent, ParseError, PictureStepData, PictureStepHandle, Placeable, PmsSearchResult, Point, Product, ProductCameraRig, ProductCollection, ProductCollectionProductSortKey, ProductWorkflow$1 as ProductWorkflow, promiseCache as PromiseCache, PromiseQueue, QuestionStepData, QuestionStepHandle, QueueablePromise, Recipient, Region, RegionElement, RenderableScene, ResizeCommand, ResourceNotFoundError, RotateCommand, SavedDesign, ScaleAxis, SelectionStorage, SendBackwardsCommand, ShapeStepData, ShapeStepHandle, ShareAction, ShareActionType, SilentIllustrationStepData, SpiffCommerceClient, Stakeholder, StakeholderType, StateMutationFunc, Step, StepAspect, StepAspectType, StepElements, StepGroup, StepHandle, StepStorage, StepType, TextAlgorithm, TextChangeCommand, TextChangeResult, TextGlobalPropertyHandle, TextInput, TextStepData, TextStepHandle, TextStepStorage, TextboxElement, Theme, ToastCallback, Transaction, Transform, TransformCollection$1 as TransformCollection, UnhandledBehaviorError, UnitOfMeasurement, UpdateImageSourceCommand, Variant, VariantResource, Vector3, Workflow, WorkflowExperience, WorkflowExperienceEventType, WorkflowExperienceHoverEventData, WorkflowExperienceImpl, WorkflowManager, WorkflowMetadata, WorkflowPanel, WorkflowScene, WorkflowSelections, WorkflowStorage, assetService, browserColorToHex, cmPerPixel, createDesign, currentDirection, dataUrlFromExternalUrl, designService, determineCorrectFontSizeAndLines, digitalContentStepService, domParser, duplicateBundle, duplicateTransaction, fetchAsString, findAngle, findElement, findPmsColors, frameDataCache, frameStepService, generate, generateCommands, generateSVGWithUnknownColors, generateStateFromDesignInputSteps, getAddressValidationJobs, getAttributesFromArrayBuffer, getAxisAlignedBoundingBox, getBoundedOffsets, getBundleThemeConfiguration, getCustomer, getCustomerBundles, getElementVertices, getFrameData, getGlobalPropertyStateForBundle, getIntegration, getNEPoint, getNWPoint, getOrderedTransactions, getOverrideThemeConfiguration, getPointOfRotation, getProductCollections, getSEPoint, getSvgElement, getTemplateBundles, getTemplateTransactions, getTransaction, getTransactionThemeConfiguration, getTransactionsForBundle, getTrueCoordinates, getUnorderedTransactions, getValidationJobsForWorkflowExperiences, getWorkflow, getWorkflows, graphQlManager, illustrationStepService, isCloseToValue, loadFont, matchHexToPms, materialStepService, metafieldManager, mmPerPixel, modelStepService, modifySVGColors, moduleStepService, nameBundle, nameTransaction, optionService, outlineFontsInSvg, patternImageDataCache, persistenceService, pictureStepService, pmsToRgb, questionStepService, registerFetchImplementation, registerWindowImplementation, rehydrateSerializedLayout, rgbToPms, rotateAroundPoint, sanitizeSvgTree, setBearerAuthenticationToken, setCanvasModule, shapeStepService, shortenUrl, spiffCoreConfiguration, stepAspectValuesToDesignInputSteps, svgColorValueToDefinition, svgStringDimensions, svgToDataUrl, textStepService, toast, validateWorkflowExperienceRecipient, validateWorkflowExperienceRecipients, xmlSerializer };