Merged
Conversation
1c75132 to
db04d7e
Compare
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.
mainis currently in pre mode so this branch has prereleases rather than normal releases. If you want to exit prereleases, runchangeset pre exitonmain.Releases
@labdigital/commercetools-mock@3.0.0-beta.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#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 types#377
50bcd7dThanks @mvantellingen! - Fix cart discount code handling based on review feedback from PR Add basic support for discount codes in the cart repository #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.#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.#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#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.