Skip to content

Latest commit

 

History

History
1137 lines (595 loc) · 67.3 KB

File metadata and controls

1137 lines (595 loc) · 67.3 KB

CHANGELOG

3.0.0-beta.0

Major Changes

  • #377 48ca265 Thanks @mvantellingen! - Make the storage engine async to support pluggable persistent storage backends (e.g., SQLite, PostgreSQL). All AbstractStorage methods now return Promises. This is a breaking change for users who call ctMock.project().unsafeAdd(), ctMock.project().get(), or ctMock.clear() — these methods are now async and must be awaited.

    Breaking changes

    • ctMock.project().unsafeAdd(type, resource) is now async — use await ctMock.project().unsafeAdd(type, resource)
    • ctMock.project().get(type, id) is now async — use await ctMock.project().get(type, id)
    • ctMock.clear() is now async — use await ctMock.clear()

    New features

    • AbstractStorage and InMemoryStorage are now exported from the package, allowing custom storage backend implementations
    • New storage option on CommercetoolsMockOptions to inject a custom storage backend
  • #377 50bcd7d Thanks @mvantellingen! - Replace the internal HTTP server with Fastify. The standalone mock server now uses Fastify for routing and request handling, improving performance and maintainability.

  • #377 ba62b38 Thanks @mvantellingen! - Remove deprecated start(), stop(), and add() methods. Use registerHandlers() to bind to an msw server and unsafeAdd() for adding resources directly.

Minor Changes

  • #377 50bcd7d Thanks @mvantellingen! - Add createdBy and lastModifiedBy fields to all resources, reflecting the client credentials used when creating or updating them.

  • #377 5056e4a Thanks @mvantellingen! - Add draft validation for resource creation when strict mode is enabled. Generated Zod schemas validate incoming request bodies against the commercetools API spec before passing them to repositories.

  • #377 35bd4ca Thanks @mvantellingen! - Add SQLiteStorage backend using Node.js built-in node:sqlite module (available since v22.5.0). This provides a persistent storage option that stores data in a SQLite database file while maintaining full compatibility with the existing in-memory backend.

    SQLiteStorage is available as a separate entry point to avoid breaking compatibility with Node.js < 22.5.0:

    Usage

    import { CommercetoolsMock } from "@labdigital/commercetools-mock";
    import { SQLiteStorage } from "@labdigital/commercetools-mock/sqlite";
    
    // File-based persistent storage
    const storage = new SQLiteStorage({ filename: "my-mock.db" });
    const ctMock = new CommercetoolsMock({ storage });
    
    // In-memory SQLite (useful for tests)
    const storage = new SQLiteStorage({ filename: ":memory:" });

    New exports

    • @labdigital/commercetools-mock/sqlite — Separate entry point exporting SQLiteStorage and SQLiteStorageOptions
  • #379 90d3287 Thanks @mvantellingen! - Unify logging to use Pino (via Fastify's built-in logger) instead of console.error. Add support for passing a custom Pino logger instance via the new logger option on CommercetoolsMockOptions. The standalone server now uses pino-pretty for human-readable output.

Patch Changes

  • #377 16dc10e Thanks @mvantellingen! - Add setKey, changeName, and changeDescription update actions for product types

  • #377 50bcd7d Thanks @mvantellingen! - Fix cart discount code handling based on review feedback from PR #360.

  • #379 5f269f2 Thanks @mvantellingen! - Fix creating categories with a parent specified by key instead of id. Previously, only the id field was used when storing the parent reference, causing a "ResourceIdentifier requires an 'id' xor a 'key'" error when the parent was specified by key.

  • #379 c8511f9 Thanks @mvantellingen! - Fix Fastify rejecting DELETE requests with an empty JSON body by adding a custom content-type parser that tolerates empty bodies.

  • #379 7dc5dcc Thanks @mvantellingen! - Route all error responses through the central error handler by converting direct reply.status(4xx).send() calls to throw CommercetoolsError instead. This ensures all error responses are logged when the silent option is set to false and provides consistent error response bodies with statusCode, message, and errors fields.

  • #379 1e9b331 Thanks @mvantellingen! - Optimize custom object lookups by container and key from O(n) to O(1):

    • Add a secondary in-memory index (container+key -> id) in InMemoryStorage, maintained on add/delete
    • Add a json_extract expression index in SQLiteStorage for direct SQL lookup instead of loading all rows
    • Replace the full-scan all() + find() in CustomObjectRepository.getWithContainerAndKey() with the new indexed lookup
  • #379 b573a84 Thanks @mvantellingen! - Improve resource creation performance, especially noticeable with SQLite storage and large numbers of resources:

    • Eliminate redundant re-fetch after inserting a resource in both SQLite and InMemory storage backends
    • Cache known project keys in SQLite storage to skip repeated INSERT+SELECT on the projects table
    • Avoid double-fetching the resource in the service POST handler by reusing the already-created resource instead of re-fetching from storage
  • #379 1e9b331 Thanks @mvantellingen! - Fix performance degradation with large datasets (40k+ resources) in SQLite storage:

    • Add indexed container and co_key columns to the SQLite resources table, replacing the O(n) json_extract-based custom object lookup with an O(log n) indexed query
    • Include automatic schema migration for existing databases
    • Add count() method to storage backends, enabling fast O(1) existence checks
    • Short-circuit review statistics calculation when no reviews exist, avoiding a full table scan on every product creation/retrieval
  • #377 50bcd7d Thanks @mvantellingen! - Update project dependencies to their latest compatible versions.

  • #377 0b36231 Thanks @mvantellingen! - Upgrade zod from v3 to v4 and remove zod-validation-error dependency. Validation error messages now use a built-in formatter that produces commercetools-style error details.

2.66.0

Minor Changes

2.65.1

Patch Changes

2.65.0

Minor Changes

2.64.0

Minor Changes

2.63.0

Minor Changes

2.62.1

Patch Changes

2.62.0

Minor Changes

2.61.3

Patch Changes

2.61.2

Patch Changes

2.61.1

Patch Changes

2.61.0

Minor Changes

Patch Changes

2.60.0

Minor Changes

2.59.1

Patch Changes

2.59.0

Minor Changes

2.58.0

Minor Changes

2.57.1

Patch Changes

2.57.0

Minor Changes

  • #332 71ecce0 Thanks @jsm1t! - Add support for get my business unit by key

  • #333 7948f69 Thanks @demeyerthom! - Added additional features to project endpoints, updated project starting defaults to align with commercetools

2.56.1

Patch Changes

2.56.0

Minor Changes

Patch Changes

2.55.0

Minor Changes

  • #323 e29f6e1 Thanks @BramKaashoek! - Add support for attributes at Product level Add DiscountGroup, RecurrencePolicy, and RecurringOrder services Add PaymentUpdateAction methods Add invalidateOlderTokens to customer token creation

2.54.0

Minor Changes

  • #321 43a4299 Thanks @BramKaashoek! - Implements the following previously missing BusinessUnit update action handlers:

    • removeShippingAddressId - Remove an address ID from shipping addresses
    • addBillingAddressId - Add an address ID to billing addresses
    • removeBillingAddressId - Remove an address ID from billing addresses
    • setDefaultBillingAddress - Set the default billing address
    • setCustomField - Set a custom field value on the business unit
    • setAddressCustomField - Set a custom field value on a specific address
    • setAddressCustomType - Set the custom type for a specific address
    • removeAssociate - Remove an associate from the business unit
    • changeAssociate - Change an existing associate's role assignments

    Fixes the changeAddress action to properly replace an existing address instead of adding a new one.

2.53.2

Patch Changes

2.53.1

Patch Changes

  • #316 e455a60 Thanks @BramKaashoek! - Fixes a bug where main variants were not included in where predicates. Fixes a bug where vars were not read in predicates with AND statements

2.53.0

Minor Changes

Patch Changes

2.52.0

Minor Changes

Patch Changes

2.51.0

Minor Changes

2.50.1

Patch Changes

  • #296 0f56caf Thanks @demeyerthom! - Set request document size limit to 16mb to allow for testing scenarios with large documents

2.50.0

Minor Changes

Patch Changes

2.50.0-beta.0

Minor Changes

Patch Changes

2.49.1

Patch Changes

2.49.0

Minor Changes

2.48.1

Patch Changes

2.48.0

Minor Changes

Patch Changes

2.47.1

Patch Changes

2.47.0

Minor Changes

2.46.0

Minor Changes

  • #277 3e41eaf Thanks @jsm1t! - Add support for availability querying in product search

Patch Changes

2.45.1

Patch Changes

2.45.0

Minor Changes

2.44.0

Minor Changes

2.43.3

Patch Changes

2.43.2

Patch Changes

2.43.1

Patch Changes

2.43.0

Minor Changes

2.42.1

Patch Changes

  • #261 d20c176 Thanks @demeyerthom! - Added missing mutations for custom fields on associate roles, product selections and business units

2.42.0

Minor Changes

Patch Changes

  • #257 36c79e2 Thanks @jsm1t! - Allow setting associates to business unit, if its created without associates

2.41.1

Patch Changes

2.41.0

Minor Changes

Patch Changes

2.40.0

Minor Changes

2.39.0

Minor Changes

2.38.0

Minor Changes

  • #245 ac90ac3 Thanks @mvantellingen! - Improve mocking of customer updates. This includes adding support for removeAddress, removeBillingAddressId, removeShippingAddressId, setCustomerGroup, setDateOfBirth, setDefaultShippingAddress, setDefaultBillingAddress, setMiddleName, setTitle.

  • d9cc9b1 Thanks @mvantellingen! - Use type-safe quality operators (===)

Patch Changes

  • #243 3a148e0 Thanks @jsm1t! - Fix for defaultBillingAddress & defaultShippingAddress customer create options not working

2.37.0

Minor Changes

2.36.0

Minor Changes

2.35.0

Minor Changes

2.34.3

Patch Changes

2.34.2

Patch Changes

2.34.1

Patch Changes

2.34.0

Minor Changes

2.33.1

Patch Changes

  • #224 1177aa1 Thanks @webwiebe! - Added the setShippingAddressCustomType and setBillingAddressCustomType actions to the cart repository

2.33.0

Minor Changes

2.32.0

Minor Changes

  • #219 0fd9b7b Thanks @mikedebock! - add support for "addAddress", "addBillingAddressId" and "addShippingAddressId" customer update actions

2.31.2

Patch Changes

2.31.1

Patch Changes

2.31.0

Minor Changes

2.30.1

Patch Changes

2.30.0

Minor Changes

  • #209 2b74155 Thanks @borisvankatwijk! - Addition of "products/search" POST endpoint. Also known as "Storefront Search -> Product Search".

2.29.1

Patch Changes

2.29.0

Minor Changes

2.28.1

Patch Changes

  • #204 a4e5a6c Thanks @yugaWicaksono! - Added missing test to cover OrderSetDeliveryCustomFieldAction in the form of method setDeliveryCustomField inside of OrderUpdateHandler

2.28.0

Minor Changes

2.27.0

Minor Changes

2.26.1

Patch Changes

2.26.0

Minor Changes

2.25.0

Minor Changes

2.24.0

Minor Changes

Patch Changes

2.23.0

Minor Changes

Patch Changes

2.22.1

Patch Changes

2.22.0

Minor Changes

2.21.2

Patch Changes

2.21.1

Patch Changes

2.21.0

Minor Changes

Patch Changes

2.20.2

Patch Changes

2.20.1

Patch Changes

2.20.0

Minor Changes

2.19.0

Minor Changes

2.18.2

Patch Changes

2.18.1

Patch Changes

2.18.0

Minor Changes

2.17.1

Patch Changes

2.17.0

Minor Changes

2.16.1

Patch Changes

2.16.0

Minor Changes

  • #154 282bf59 Thanks @mikedebock! - add support for customer setCustomerNumber action

  • #152 7c83048 Thanks @BramKaashoek! - Adds variant IDs when creating ShoppingListLineItems. Implement Variant expansion on ShoppingListLineItems. Implement ShoppingList update actions.

2.15.0

Minor Changes

2.14.2

Patch Changes

2.14.1

Patch Changes

2.14.0

Minor Changes

2.13.0

Minor Changes

2.12.2

Patch Changes

2.12.1

Patch Changes

2.12.0

Minor Changes

2.11.0

Minor Changes

2.10.0

Minor Changes

2.9.0

Minor Changes

Patch Changes

2.8.0

Minor Changes

Patch Changes

2.7.0

Minor Changes

Patch Changes

2.6.0

Minor Changes

2.5.0

Minor Changes

2.4.0

Minor Changes

2.3.0

Minor Changes

2.2.0

Minor Changes

  • f66d431 Thanks @mvantellingen! - Fix Premature close errors by switching from supertest to light-my-request for mapping between msw and express

2.1.0

Minor Changes

2.0.0

Major Changes

1.11.0

Minor Changes

  • #117 a8b52d9 Thanks @mikedebock! - add support for cart addItemShippingAddress and setLineItemShippingDetails

1.10.0

Minor Changes

1.9.0

Minor Changes

1.8.1

Patch Changes

1.8.0

Minor Changes

1.7.0

Minor Changes

1.6.2

Patch Changes

1.6.1

Patch Changes

1.6.0

Minor Changes

  • #92 c53c2b4 Thanks @demeyerthom! - Added logic for attribute groups

  • #95 957864d Thanks @mvantellingen! - Fix implementation of the product projection query endpoint. This also fixes some issues with passing condition values as separate values (var.name)

1.5.0

Minor Changes

Patch Changes

1.4.0

Minor Changes

Patch Changes

1.3.2

Patch Changes

1.3.1

Patch Changes

1.3.0

Minor Changes

Patch Changes

1.2.0

Minor Changes

1.1.3

Patch Changes

1.1.2

Patch Changes

1.1.1

Patch Changes

1.1.0

Minor Changes

  • #70 2776347 Thanks @mikedebock! -

    • Add addPrice product update action
    • Add changePrice product update action
    • Add removePrice product update action

1.0.0

Major Changes

  • #68 7b74869 Thanks @okkevandereijk! - ⚠️ This is a major update dropping support for Node 14 and under.

    • Updated node to version 18
    • Updated pnpm to version 8
    • Enforce eslint with default library

0.14.1

Patch Changes

Minor Changes

0.13.0

Minor Changes

0.11.1 (2023-03-01)

  • Store deleteDaysAfterCreation on project settings
  • Add addExternalImage and removeImage product update actions

0.10.1 (2022-10-13)

  • Various fixes to the internal type system

0.10.0 (2022-10-10)

  • Implement update by key and delete by key support for all resources
  • Added support for updating authenticationMode of a customer
  • Improve handling of staged vs current product data for products
  • Improve version identifier increments to match commercetools
  • Refactor product projection to handle published vs non published products

0.9.1 (2022-09-08)

  • Added boolean parsing logic for predicates.

0.9.0 (2022-08-23)

  • Include key, description and metaDescription when converting product to product projection
  • Add support for updating transitions in state
  • Set fractionDigits for money based on currency code
  • Improve logic to mask secret values in resources

0.8.0 (2022-07-27)

  • Implement experimental support for facets in the product projection search.

0.7.2 (2022-07-26)

  • Add support for multiple RANGE() clauses in the product projection endpoint.

0.7.1 (2022-07-25)

  • Fix a packaging error in the GitHub workflow. The artifact for version 0.7.0 didn't contain the bundled output files.

0.7.0 (2022-07-25)

  • Rewrite the mock implementation of the product projection search endpoint to work with products created via the product endpoint. This also adds support for multiple filters.
  • Replace tsdx with tsup for building the library
  • Drop support for Node 12 and add Node 18.