Skip to content

Commit 3eb9ae9

Browse files
github-actions[bot]mvantellingen
authored andcommitted
update version (beta)
1 parent b75f4f9 commit 3eb9ae9

3 files changed

Lines changed: 113 additions & 2 deletions

File tree

.changeset/pre.json

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,23 @@
44
"initialVersions": {
55
"@labdigital/commercetools-mock": "2.66.0"
66
},
7-
"changesets": []
7+
"changesets": [
8+
"add-created-last-modified-by",
9+
"add-draft-validation",
10+
"add-product-type-update-actions",
11+
"add-sqlite-storage",
12+
"async-storage-layer",
13+
"fix-cart-discount-codes",
14+
"fix-category-parent-by-key",
15+
"fix-empty-json-body-on-delete",
16+
"log-errors-when-not-silent",
17+
"move-to-fastify",
18+
"optimize-custom-object-lookup",
19+
"optimize-resource-creation-perf",
20+
"optimize-sqlite-large-datasets",
21+
"remove-deprecated-methods",
22+
"unified-pino-logging",
23+
"update-dependencies",
24+
"upgrade-zod-v4"
25+
]
826
}

CHANGELOG.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,98 @@
11
# CHANGELOG
22

3+
## 3.0.0-beta.0
4+
5+
### Major Changes
6+
7+
- [#377](https://github.com/labd/commercetools-node-mock/pull/377) [`48ca265`](https://github.com/labd/commercetools-node-mock/commit/48ca2656ddde72f9996abdd5c652d2a187a86df4) Thanks [@mvantellingen](https://github.com/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.
8+
9+
### Breaking changes
10+
11+
- `ctMock.project().unsafeAdd(type, resource)` is now async — use `await ctMock.project().unsafeAdd(type, resource)`
12+
- `ctMock.project().get(type, id)` is now async — use `await ctMock.project().get(type, id)`
13+
- `ctMock.clear()` is now async — use `await ctMock.clear()`
14+
15+
### New features
16+
17+
- `AbstractStorage` and `InMemoryStorage` are now exported from the package, allowing custom storage backend implementations
18+
- New `storage` option on `CommercetoolsMockOptions` to inject a custom storage backend
19+
20+
- [#377](https://github.com/labd/commercetools-node-mock/pull/377) [`50bcd7d`](https://github.com/labd/commercetools-node-mock/commit/50bcd7defba1eecd5be045a4c2fd315a71ec7811) Thanks [@mvantellingen](https://github.com/mvantellingen)! - Replace the internal HTTP server with Fastify. The standalone mock server now uses Fastify for routing and request handling, improving performance and maintainability.
21+
22+
- [#377](https://github.com/labd/commercetools-node-mock/pull/377) [`ba62b38`](https://github.com/labd/commercetools-node-mock/commit/ba62b38cb5bfb5feb829569275848b9ff8952c4e) Thanks [@mvantellingen](https://github.com/mvantellingen)! - Remove deprecated `start()`, `stop()`, and `add()` methods. Use `registerHandlers()` to bind to an msw server and `unsafeAdd()` for adding resources directly.
23+
24+
### Minor Changes
25+
26+
- [#377](https://github.com/labd/commercetools-node-mock/pull/377) [`50bcd7d`](https://github.com/labd/commercetools-node-mock/commit/50bcd7defba1eecd5be045a4c2fd315a71ec7811) Thanks [@mvantellingen](https://github.com/mvantellingen)! - Add `createdBy` and `lastModifiedBy` fields to all resources, reflecting the client credentials used when creating or updating them.
27+
28+
- [#377](https://github.com/labd/commercetools-node-mock/pull/377) [`5056e4a`](https://github.com/labd/commercetools-node-mock/commit/5056e4aa75525d5385516e0cf97d84c79a3887d2) Thanks [@mvantellingen](https://github.com/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.
29+
30+
- [#377](https://github.com/labd/commercetools-node-mock/pull/377) [`35bd4ca`](https://github.com/labd/commercetools-node-mock/commit/35bd4cae1c6a489d4c8bf4bced4a6f2cbbc7e102) Thanks [@mvantellingen](https://github.com/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.
31+
32+
`SQLiteStorage` is available as a separate entry point to avoid breaking compatibility with Node.js < 22.5.0:
33+
34+
### Usage
35+
36+
```typescript
37+
import { CommercetoolsMock } from "@labdigital/commercetools-mock";
38+
import { SQLiteStorage } from "@labdigital/commercetools-mock/sqlite";
39+
40+
// File-based persistent storage
41+
const storage = new SQLiteStorage({ filename: "my-mock.db" });
42+
const ctMock = new CommercetoolsMock({ storage });
43+
44+
// In-memory SQLite (useful for tests)
45+
const storage = new SQLiteStorage({ filename: ":memory:" });
46+
```
47+
48+
### New exports
49+
50+
- `@labdigital/commercetools-mock/sqlite` — Separate entry point exporting `SQLiteStorage` and `SQLiteStorageOptions`
51+
52+
- [#379](https://github.com/labd/commercetools-node-mock/pull/379) [`90d3287`](https://github.com/labd/commercetools-node-mock/commit/90d3287d7e439d58afe937571cf7a8fa26cf4ed7) Thanks [@mvantellingen](https://github.com/mvantellingen)! - Unify logging to use Pino (via Fastify's built-in logger) instead of
53+
console.error. Add support for passing a custom Pino logger instance via the
54+
new `logger` option on `CommercetoolsMockOptions`. The standalone server now
55+
uses pino-pretty for human-readable output.
56+
57+
### Patch Changes
58+
59+
- [#377](https://github.com/labd/commercetools-node-mock/pull/377) [`16dc10e`](https://github.com/labd/commercetools-node-mock/commit/16dc10e7122e26d20cf04318251fcf1ab9aca62f) Thanks [@mvantellingen](https://github.com/mvantellingen)! - Add setKey, changeName, and changeDescription update actions for product types
60+
61+
- [#377](https://github.com/labd/commercetools-node-mock/pull/377) [`50bcd7d`](https://github.com/labd/commercetools-node-mock/commit/50bcd7defba1eecd5be045a4c2fd315a71ec7811) Thanks [@mvantellingen](https://github.com/mvantellingen)! - Fix cart discount code handling based on review feedback from PR #360.
62+
63+
- [#379](https://github.com/labd/commercetools-node-mock/pull/379) [`5f269f2`](https://github.com/labd/commercetools-node-mock/commit/5f269f2397cb050cfedd7a59eb77f5b05b2c2b0f) Thanks [@mvantellingen](https://github.com/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.
64+
65+
- [#379](https://github.com/labd/commercetools-node-mock/pull/379) [`c8511f9`](https://github.com/labd/commercetools-node-mock/commit/c8511f9e2469e07a18c287ba4a4687356c9ef64e) Thanks [@mvantellingen](https://github.com/mvantellingen)! - Fix Fastify rejecting DELETE requests with an empty JSON body by adding a custom content-type parser that tolerates empty bodies.
66+
67+
- [#379](https://github.com/labd/commercetools-node-mock/pull/379) [`7dc5dcc`](https://github.com/labd/commercetools-node-mock/commit/7dc5dcc1f2195c3b6830cb822fd7f26fb5bad96e) Thanks [@mvantellingen](https://github.com/mvantellingen)! - Route all error responses through the central error handler by converting direct
68+
`reply.status(4xx).send()` calls to throw `CommercetoolsError` instead. This
69+
ensures all error responses are logged when the `silent` option is set to `false`
70+
and provides consistent error response bodies with `statusCode`, `message`, and
71+
`errors` fields.
72+
73+
- [#379](https://github.com/labd/commercetools-node-mock/pull/379) [`1e9b331`](https://github.com/labd/commercetools-node-mock/commit/1e9b331204ee212d5cf2238c56249db1b0d668be) Thanks [@mvantellingen](https://github.com/mvantellingen)! - Optimize custom object lookups by container and key from O(n) to O(1):
74+
75+
- Add a secondary in-memory index (container+key -> id) in InMemoryStorage, maintained on add/delete
76+
- Add a `json_extract` expression index in SQLiteStorage for direct SQL lookup instead of loading all rows
77+
- Replace the full-scan `all()` + `find()` in `CustomObjectRepository.getWithContainerAndKey()` with the new indexed lookup
78+
79+
- [#379](https://github.com/labd/commercetools-node-mock/pull/379) [`b573a84`](https://github.com/labd/commercetools-node-mock/commit/b573a8487d22105cfe297503e4ab72a4da7da307) Thanks [@mvantellingen](https://github.com/mvantellingen)! - Improve resource creation performance, especially noticeable with SQLite storage and large numbers of resources:
80+
81+
- Eliminate redundant re-fetch after inserting a resource in both SQLite and InMemory storage backends
82+
- Cache known project keys in SQLite storage to skip repeated INSERT+SELECT on the projects table
83+
- Avoid double-fetching the resource in the service POST handler by reusing the already-created resource instead of re-fetching from storage
84+
85+
- [#379](https://github.com/labd/commercetools-node-mock/pull/379) [`1e9b331`](https://github.com/labd/commercetools-node-mock/commit/1e9b331204ee212d5cf2238c56249db1b0d668be) Thanks [@mvantellingen](https://github.com/mvantellingen)! - Fix performance degradation with large datasets (40k+ resources) in SQLite storage:
86+
87+
- 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
88+
- Include automatic schema migration for existing databases
89+
- Add `count()` method to storage backends, enabling fast O(1) existence checks
90+
- Short-circuit review statistics calculation when no reviews exist, avoiding a full table scan on every product creation/retrieval
91+
92+
- [#377](https://github.com/labd/commercetools-node-mock/pull/377) [`50bcd7d`](https://github.com/labd/commercetools-node-mock/commit/50bcd7defba1eecd5be045a4c2fd315a71ec7811) Thanks [@mvantellingen](https://github.com/mvantellingen)! - Update project dependencies to their latest compatible versions.
93+
94+
- [#377](https://github.com/labd/commercetools-node-mock/pull/377) [`0b36231`](https://github.com/labd/commercetools-node-mock/commit/0b3623102790ebb4b20398d84ee5438d78f7364d) Thanks [@mvantellingen](https://github.com/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.
95+
396
## 2.66.0
497

598
### Minor Changes

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@labdigital/commercetools-mock",
3-
"version": "2.66.0",
3+
"version": "3.0.0-beta.0",
44
"license": "MIT",
55
"author": "Michael van Tellingen",
66
"type": "module",

0 commit comments

Comments
 (0)