@labdigital/commercetools-mock 2.21.1 → 2.21.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@labdigital/commercetools-mock",
3
- "version": "2.21.1",
3
+ "version": "2.21.2",
4
4
  "license": "MIT",
5
5
  "author": "Michael van Tellingen",
6
6
  "type": "module",
@@ -4,7 +4,10 @@ import { ParsedQs } from "qs";
4
4
  import { updateRequestSchema } from "~src/schemas/update-request";
5
5
  import { validateData } from "~src/validate";
6
6
  import { queryParamsArray } from "../helpers";
7
- import { AbstractResourceRepository } from "../repositories/abstract";
7
+ import {
8
+ AbstractResourceRepository,
9
+ QueryParams,
10
+ } from "../repositories/abstract";
8
11
  import { getRepositoryContext } from "../repositories/helpers";
9
12
 
10
13
  export default abstract class AbstractService {
@@ -44,13 +47,23 @@ export default abstract class AbstractService {
44
47
  get(request: Request, response: Response) {
45
48
  const limit = this._parseParam(request.query.limit);
46
49
  const offset = this._parseParam(request.query.offset);
47
-
48
- const result = this.repository.query(getRepositoryContext(request), {
50
+ const params: QueryParams = {
49
51
  expand: this._parseParam(request.query.expand),
50
52
  where: this._parseParam(request.query.where),
51
53
  limit: limit !== undefined ? Number(limit) : undefined,
52
54
  offset: offset !== undefined ? Number(offset) : undefined,
53
- });
55
+ };
56
+
57
+ for (const key in request.query) {
58
+ if (key.startsWith("var.")) {
59
+ const items = this._parseParam(request.query[key]);
60
+ if (items) {
61
+ params[key] = items.length === 1 ? items[0] : items;
62
+ }
63
+ }
64
+ }
65
+
66
+ const result = this.repository.query(getRepositoryContext(request), params);
54
67
  return response.status(200).send(result);
55
68
  }
56
69