@spiffcommerce/core 27.2.1 → 27.3.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/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
 
@@ -2187,6 +2188,57 @@ declare class IntegrationProduct {
2187
2188
  getAllWorkflows(): ProductWorkflow$1[];
2188
2189
  }
2189
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
+
2190
2242
  declare const getWorkflows: (ids: string[], options?: GetWorkflowGraphqlOptions) => Promise<Workflow[]>;
2191
2243
  declare const getWorkflow: (id: string, options?: GetWorkflowGraphqlOptions) => Promise<Workflow>;
2192
2244
  /**
@@ -2298,7 +2350,6 @@ interface ClientConfiguration {
2298
2350
  */
2299
2351
  declare class SpiffCommerceClient {
2300
2352
  private options;
2301
- private currencyCode?;
2302
2353
  private customer?;
2303
2354
  private activeIntegration?;
2304
2355
  private marketplaceThemeInstallId?;
@@ -2313,8 +2364,8 @@ declare class SpiffCommerceClient {
2313
2364
  * and the Spiff Commerce platform.
2314
2365
  */
2315
2366
  getAssetManager(): AssetManager;
2316
- getCurrencyCode(): string;
2317
2367
  getFlowService(): FlowService;
2368
+ getCurrencyContext(presentmentCurrency: string): Promise<CurrencyContext>;
2318
2369
  getIntegration(): Promise<Integration>;
2319
2370
  canUseAddon(addonHandle: AddonHandle): Promise<boolean>;
2320
2371
  /**
@@ -5853,4 +5904,4 @@ declare const validateWorkflowExperienceRecipients: (workflowExperiences: Workfl
5853
5904
  */
5854
5905
  declare const getGlobalPropertyStateForBundle: (bundleId: string) => Promise<GlobalPropertyState | undefined>;
5855
5906
 
5856
- 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 };