Release new version#391
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.
Releases
@labdigital/commercetools-mock@3.0.0
Major Changes
#377
48ca265Thanks @mvantellingen! - Make the storage engine async to support pluggable persistent storage backends (e.g., SQLite, PostgreSQL). AllAbstractStoragemethods now return Promises. This is a breaking change for users who callctMock.project().unsafeAdd(),ctMock.project().get(), orctMock.clear()— these methods are now async and must be awaited.Breaking changes
ctMock.project().unsafeAdd(type, resource)is now async — useawait ctMock.project().unsafeAdd(type, resource)ctMock.project().get(type, id)is now async — useawait ctMock.project().get(type, id)ctMock.clear()is now async — useawait ctMock.clear()New features
AbstractStorageandInMemoryStorageare now exported from the package, allowing custom storage backend implementationsstorageoption onCommercetoolsMockOptionsto inject a custom storage backend#377
50bcd7dThanks @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
ba62b38Thanks @mvantellingen! - Remove deprecatedstart(),stop(), andadd()methods. UseregisterHandlers()to bind to an msw server andunsafeAdd()for adding resources directly.Minor Changes
#377
50bcd7dThanks @mvantellingen! - AddcreatedByandlastModifiedByfields to all resources, reflecting the client credentials used when creating or updating them.#377
5056e4aThanks @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
35bd4caThanks @mvantellingen! - AddSQLiteStoragebackend using Node.js built-innode:sqlitemodule (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.SQLiteStorageis available as a separate entry point to avoid breaking compatibility with Node.js < 22.5.0:Usage
New exports
@labdigital/commercetools-mock/sqlite— Separate entry point exportingSQLiteStorageandSQLiteStorageOptions#388
f053fb9Thanks @BramKaashoek! - Add support forExternalandExternalAmounttax modes on carts.New behavior
Externaltax mode —LineItem,CustomLineItem, and shipping methods can now carry anexternalTaxRate:createCarthonorsLineItemDraft.externalTaxRate,CustomLineItemDraft.externalTaxRate, andCartDraft.externalTaxRateForShippingMethod.addLineItem,addCustomLineItem, andsetShippingMethod/setCustomShippingMethodacceptexternalTaxRate.setLineItemTaxRate,setCustomLineItemTaxRate,setShippingMethodTaxRate.ExternalAmounttax mode — explicit gross amounts can be supplied per item and at the cart level:setLineItemTaxAmount,setCustomLineItemTaxAmount,setShippingMethodTaxAmount,setCartTotalTax.taxedPriceis whateversetCartTotalTaxlast set; it is no longer aggregated from line items.taxedShippingPricecontinues to mirrorshippingInfo.taxedPrice.cart.taxRoundingMode(HalfEven/HalfUp/HalfDown) instead of always usingMath.round.Cart total recomputation after update actions
CartUpdateHandler.applynow recomputescart.taxedPriceandcart.taxedShippingPriceafter every update batch (except inExternalAmountmode, where the cart total is authoritative viasetCartTotalTax).This fixes a pre-existing latent bug: previously these fields were only computed once during
create()and were never refreshed after update actions, so e.g. runningsetShippingMethodafter cart creation would leave the cart-level aggregate stale. It didn't show up before becauseLineItem.taxedPricewas never populated in any mode, so the aggregate had no contributors that could drift. With the new tax-mode work, line items and custom line items now actually carrytaxedPrice, which made the gap observable and required fixing.#379
90d3287Thanks @mvantellingen! - Unify logging to use Pino (via Fastify's built-in logger) instead ofconsole.error. Add support for passing a custom Pino logger instance via the
new
loggeroption onCommercetoolsMockOptions. The standalone server nowuses pino-pretty for human-readable output.
Patch Changes
#377
16dc10eThanks @mvantellingen! - Add setKey, changeName, and changeDescription update actions for product types708b7b3Thanks @mvantellingen! - Update dependencies#377
50bcd7dThanks @mvantellingen! - Fix cart discount code handling based on review feedback from PR #360.#379
5f269f2Thanks @mvantellingen! - Fix creating categories with a parent specified by key instead of id. Previously, only theidfield 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
c8511f9Thanks @mvantellingen! - Fix Fastify rejecting DELETE requests with an empty JSON body by adding a custom content-type parser that tolerates empty bodies.3ef1b3fThanks @mvantellingen! - return typeAnyHandler[]for the.getHandlers()call#379
7dc5dccThanks @mvantellingen! - Route all error responses through the central error handler by converting directreply.status(4xx).send()calls to throwCommercetoolsErrorinstead. Thisensures all error responses are logged when the
silentoption is set tofalseand provides consistent error response bodies with
statusCode,message, anderrorsfields.#381
2d16f79Thanks @demeyerthom! - Made generated optional fields nullish instead of optional, as the commercetools API also accepts null as input and treats it as empty, but the mock explicitly expects undefined#383
11acea0Thanks @demeyerthom! - Add experimental, opt-in SQLite storage enabled via the EXPERIMENTAL_SQLITE_STORAGE environment variable#379
1e9b331Thanks @mvantellingen! - Optimize custom object lookups by container and key from O(n) to O(1):json_extractexpression index in SQLiteStorage for direct SQL lookup instead of loading all rowsall()+find()inCustomObjectRepository.getWithContainerAndKey()with the new indexed lookup#379
b573a84Thanks @mvantellingen! - Improve resource creation performance, especially noticeable with SQLite storage and large numbers of resources:#379
1e9b331Thanks @mvantellingen! - Fix performance degradation with large datasets (40k+ resources) in SQLite storage:containerandco_keycolumns to the SQLite resources table, replacing the O(n)json_extract-based custom object lookup with an O(log n) indexed querycount()method to storage backends, enabling fast O(1) existence checks#381
2d16f79Thanks @demeyerthom! - Push multiple docker image tags so we can pin versions if necessary, ignore beta tags for latest#377
50bcd7dThanks @mvantellingen! - Update project dependencies to their latest compatible versions.#377
0b36231Thanks @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.#385
886fd3bThanks @BramKaashoek! - Allow for deliveries on order import