# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

#### Types of changes

-   `Added` for new features.
-   `Changed` for changes in existing functionality.
-   `Deprecated` for soon-to-be removed features.
-   `Removed` for now removed features.
-   `Fixed` for any bug fixes.
-   `Security` in case of vulnerabilities.

## [26.1.2] - 30-10-2024

### Fixed

-   The ProductCollection class will no longer request the products it contains if they are already present in the cache.

## [26.1.1] - 30-10-2024

### Changed

-   Merged some GraphQL calls to reduce the number of requests made when loading a bundle.

## [26.1.0] - 30-10-2024

### Changed

-   Several internal functions have been changed, been merged or removed. This should not affect any public API.
-   `rehydrateSerializedLayout` is no longer exported from the package. No functionality is intended to take its place. The function was always intended for internal use only.

## [26.0.0] - 30-10-2024

### Changed

-   `getWorkflowExperience` has removed 3 deprecated parameters in favor of the options object. The options object is no longer optional.
-   `configureUrls` has been removed in favor of the `configure` function. Please use `configure` moving forwards.
-   The client constructor should know be called with an application in most use cases. We'll continue locking down functionality to require this in the future.

## [22.0.0] - 10-07-2024

### Changed

-   `matchHexToPms` now returns a list of objects of `{ pms: string; hex: string; }` rather than strings.

### Added

-   `findPmsColors(input: string, limit?: number): PmsSearchResult[]`: A function to find PMS colors by name using fuzzy search.

## [21.8.1] - 27-03-2024

### Fixed

-   `WorkflowExperience.getTotalPriceSubunits` no longer always returns the discounted price.

## [21.8.0] - 26-03-2024

### Added

-   `Bundle.removeStakeholder(email: string): Promise<void>`: Removes a single stakeholder from the Bundle, via email address.

## [21.7.1] - 25-03-2024

### Fixed

-   `Bundle.getAllStakeholders()` now returns correct results on subsequent calls.

## [21.7.0] - 25-03-2024

### Added

-   `CollectionProduct.getAllWorkflows(): ProductWorkflow[]`: Returns all workflows associated with this product.

## [21.6.0] - 22-03-2024

### Added

-   `WorkflowExperienceEventType.PriceBreakChanged`: The relevant event fires whenever the price break to be used in a WorkflowExperience changes. This even will fire when the quantity changes, and will also fire when in a Bundle when other WorkflowExperiences using the same Product have quantity changes (or are added & removed from the Bundle).

## [21.5.0] - 22-03-2024

### Changed

-   `StepHandle`: The override global property state setting now has a different value for each Global Property Aspect type. The get/set functions have been renamed and have an extra parameter to determine the Aspect Type.
    -   `getOverrideGlobalPreviewConfiguration` -> `getOverrideGlobalPropertyConfiguration(type: AspectType): boolean`.
    -   `setOverrideGlobalPreviewConfiguration` -> `setOverrideGlobalPropertyConfiguration(type: AspectType, value: boolean): void`

## [21.4.1] - 21-03-2024

### Changed

-   `readTransactionsQuery` now fetches `printFileUrl1` to `printFileUrl5` for each transaction.

## [21.4.0] - 20-03-2024

### Added

-   `StepHandle`:
    -   `getOverrideGlobalPreviewConfiguration(): boolean`: Returns a boolean that indicates whether this step should override (ignore) Global Property state.
    -   `setOverrideGlobalPreviewConfiguration(value: boolean): void`: Modifies whether this step should override (ignore) Global Property state.
    -   `getGlobalPropertyAspects(configurationId: string): string[]`: Returns all Aspect names in the supplied Global Property Configuration that this step is configured to use.
-   `Bundle.getGlobalPropertyConfiguration(): GlobalPropertyConfiguration | undefined`: Returns the Global Property Configuration object associated with the Bundle, if it exists.

## [21.3.1] - 20-03-2024

### Fixed

-   When a `Bundle` is loaded by ID, the `WorkflowExperience` objects it loads will not correctly be linked internally. This resolves issues regarding price breaks not calculating correctly on bundle reload when multiple transactions share a product.

## [21.3.0] - 20-03-2024

### Added

-   `WorkflowExperience.priceBreakToBeApplied()` returns the percentage that will be used in `WorkflowExperience.getTotalPriceSubunits()` and related methods.

### Changed

-   `WorkflowExperience.getTotalPriceSubunits()` and related methods now consider price breaks in their calculations, but also now have a `disablePriceBreaks` argument.

## [21.2.1] - 15-03-2024

### Fixed

-   Fixed Global Property Handles not updating values when WorkflowExperiences in the Bundle share the same Workflow.

## [21.2.0] - 15-03-2024

### Added

-   `FileUploadGlobalPropertyHandle`:
    -   `hasImage(): boolean`: Returns a boolean value indicating if the associated state has an image.
    -   `getImage(): Promise<Asset | undefined>`: Retrieves the current image from the server.

## [21.1.1] - 15-03-2024

### Fixed

-   Exported missing `AspectType` for global property handles.

## [21.1.0] - 14-03-2024

### Added

-   `Bundle.hasGlobalProperties(): boolean`: Returns true when the bundle is linked to a Global Property Configuration.

## [21.0.1] - 13-03-2024

### Fixed

-   Package now supplies this `CHANGELOG.md` in published releases.

## [21.0.0] - 13-03-2024

### Added

-   `DesignCreationMessage` now has `quantity: number | undefined`.

### Changed

-   `Bundle.finish()` no longer returns an array of `DesignCreationMessage` objects, but instead returns a `BundleDesignCreationMessage` object which wraps the array of `DesignCreationMessage` entries.

## [20.5.1] - 12-03-2024

### Fixed

-   `WorkflowExperience.getSelectionPriceSubunits()` (and consequently `getTotalPriceSubunits()`) can no longer return `NaN`.

## [20.5.0] - 12-03-2024

### Added

-   `WorkflowManager.injectIntoPreviewService()` now has a second argument `refocusCamera`, a boolean which allows you to disable the automatic refocusing of the camera when the model is loaded. This requires `@spiffcommerce/preview@^5.7.0`.

## [20.4.5] - 08-03-2024

### Added

-   `RenderableScene` objects will now contain a `workflowScene: WorkflowScene` field. This is only provided for backwards compatibility and is considered deprecated functionality.

## [20.4.4] - 08-03-2024

### Fixed

-   Updating quantity via `WorkflowExperience.setQuantity()` will now correctly update on the server.

## [20.4.3] - 08-03-2024

### Changed

-   `WorkflowExperience.setQuantity()` now returns a promise that resolves once the quantity has been updated on the server.

## [20.4.0] - 08-03-2024

### Added

-   `Transaction` entities now have `quantity: number | undefined`.
-   New functions on `WorkflowExperience` for managing quantity:
    -   `getQuantity()`: The amount that was, or will be, ordered of the underlying `Transaction`. This will default to `1` if the value is undefined. If you want to read the raw value, use `getWorkflowManager().getTransaction().quantity`.
    -   `setQuantity(<number>)`: Updates the quantity value on the underlying `Transaction` entity. Must be >= 1.
-   New events functionality on `WorkflowExperience`. Currently the only event is `QuantityChanged`.
    -   `addEventListener(<type>, <callback>)`: Registers a callback function to be called when the specified event is raised. The associated `WorkflowExperience` is passed as a parameter to the callback function.
    -   `removeEventListener(<type>, <callback>)`: Removes a previously registered callback.

## [20.3.0] - 07-03-2024

### Added

-   `CollectionProduct.getCurrentIntegration()`: returns the `IntegrationProductResource` associated with the product that is linked to the current Integration (resolved via the application key).

## [20.2.2] - 05-03-2024

### Changed

-   `WorkflowExperience.getStepById(<string>)` now internally caches the `StepHandle` objects that it creates. This resolves an issue with functional rendering systems that re-render when the object reference changes, where they would re-renderer whenever this function was called even if the object was identical.

## [20.2.1] - 29-02-2024

### Changed

-   The union type `GetWorkflowOptions` has some of its entries wrapped in another union. The types that will create a brand new `Transaction` are now nested under `GetNewWorkflowOptions`:

    ```ts
    // Before
    export type GetWorkflowOptions =
        | GetWorkflowFromTransactionOptions
        | GetWorkflowFromIntegrationProductOptions
        | GetWorkflowFromExternalProductOptions;

    // After
    export type GetNewWorkflowOptions =
        | GetWorkflowFromIntegrationProductOptions
        | GetWorkflowFromExternalProductOptions;

    export type GetWorkflowOptions = GetWorkflowFromTransactionOptions | GetNewWorkflowOptions;
    ```

## [20.2.0] - 29-02-2024

### Added

-   `SpiffCommerceClient.getIntegrationProduct(<options>)`: Fetches an `IntegrationProduct` object. Essentially a wrapper for the functions `getIntegrationProductById` and `getIntegrationProductFromExternalIds`. The options object type is as follows:
    ```ts
    {
        type: "integration";
        integrationProductId: string;
    } | {
        type: "external";
        externalIntegrationId: string;
        externalProductId: string;
    }
    ```

## [20.1.0] - 23-02-2024

### Added

-   `IntegrationProduct.getAllWorkflows()`: Returns an array of `ProductWorkflow`, ordered by their internal `index` value (matches the order seen on the SpiffCommerce Hub).

## [20.0.1] - 23-02-2024

### Changed

-   `StepHandle.executeAnimations()` now logs a warning to the console when the associated `WorkflowManager` is not associated with a `ThreeDPreviewService`.

## [20.0.0] - 15-02-2024

### Added

-   Additional configuration options for GraphQL on bundles.
-   A separate fetchProducts function on the ProductCollection interface.

### Changed

-   Removed async on getProducts call.

### Removed

-   Unused normalize.css file.
-   Identical links assigned in each translation file.
-   Duplicate index file for the english version.
