@labdigital/commercetools-mock 2.60.0 → 2.61.1

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.
Files changed (223) hide show
  1. package/dist/{index.d.ts → index.d.mts} +154 -275
  2. package/dist/{index.js → index.mjs} +255 -359
  3. package/dist/index.mjs.map +1 -0
  4. package/package.json +30 -18
  5. package/src/config.ts +1 -1
  6. package/src/ctMock.test.ts +1 -1
  7. package/src/ctMock.ts +22 -21
  8. package/src/index.test.ts +1 -1
  9. package/src/index.ts +3 -3
  10. package/src/lib/haversine.test.ts +2 -2
  11. package/src/lib/masking.ts +1 -1
  12. package/src/lib/parser.ts +2 -2
  13. package/src/lib/password.ts +1 -1
  14. package/src/lib/predicateParser.test.ts +1 -1
  15. package/src/lib/predicateParser.ts +4 -4
  16. package/src/lib/product-review-statistics.test.ts +4 -8
  17. package/src/lib/productSearchFilter.test.ts +3 -3
  18. package/src/lib/productSearchFilter.ts +6 -6
  19. package/src/lib/projectionSearchFilter.test.ts +3 -3
  20. package/src/lib/projectionSearchFilter.ts +4 -4
  21. package/src/lib/review-statistics.ts +1 -1
  22. package/src/lib/searchQueryTypeChecker.test.ts +3 -3
  23. package/src/lib/searchQueryTypeChecker.ts +8 -4
  24. package/src/lib/tax.test.ts +3 -3
  25. package/src/lib/tax.ts +3 -3
  26. package/src/oauth/server.test.ts +7 -7
  27. package/src/oauth/server.ts +7 -7
  28. package/src/priceSelector.test.ts +1 -1
  29. package/src/priceSelector.ts +2 -2
  30. package/src/product-projection-search.ts +10 -12
  31. package/src/product-search-availability.test.ts +1 -1
  32. package/src/product-search.ts +6 -7
  33. package/src/projectAPI.test.ts +1 -1
  34. package/src/projectAPI.ts +7 -7
  35. package/src/repositories/abstract.ts +8 -10
  36. package/src/repositories/as-associate.test.ts +4 -4
  37. package/src/repositories/as-associate.ts +3 -3
  38. package/src/repositories/associate-role.ts +7 -9
  39. package/src/repositories/attribute-group.test.ts +3 -3
  40. package/src/repositories/attribute-group.ts +5 -5
  41. package/src/repositories/business-unit.test.ts +6 -6
  42. package/src/repositories/business-unit.ts +23 -28
  43. package/src/repositories/cart/actions.ts +12 -15
  44. package/src/repositories/cart/helpers.ts +5 -5
  45. package/src/repositories/cart/index.test.ts +5 -10
  46. package/src/repositories/cart/index.ts +13 -18
  47. package/src/repositories/cart-discount/actions.ts +5 -6
  48. package/src/repositories/cart-discount/index.ts +5 -5
  49. package/src/repositories/category/actions.ts +4 -4
  50. package/src/repositories/category/index.test.ts +3 -3
  51. package/src/repositories/category/index.ts +8 -8
  52. package/src/repositories/channel.test.ts +4 -4
  53. package/src/repositories/channel.ts +6 -6
  54. package/src/repositories/custom-object.ts +11 -8
  55. package/src/repositories/customer/actions.ts +11 -14
  56. package/src/repositories/customer/index.test.ts +3 -3
  57. package/src/repositories/customer/index.ts +12 -9
  58. package/src/repositories/customer-group.test.ts +4 -4
  59. package/src/repositories/customer-group.ts +6 -6
  60. package/src/repositories/discount-code/actions.ts +4 -4
  61. package/src/repositories/discount-code/index.ts +5 -5
  62. package/src/repositories/discount-group/actions.ts +3 -4
  63. package/src/repositories/discount-group/index.ts +4 -4
  64. package/src/repositories/errors.ts +1 -1
  65. package/src/repositories/extension.test.ts +3 -3
  66. package/src/repositories/extension.ts +6 -6
  67. package/src/repositories/helpers.test.ts +25 -0
  68. package/src/repositories/helpers.ts +14 -12
  69. package/src/repositories/index.test.ts +3 -3
  70. package/src/repositories/index.ts +43 -43
  71. package/src/repositories/inventory-entry/actions.ts +15 -3
  72. package/src/repositories/inventory-entry/index.ts +5 -5
  73. package/src/repositories/my-customer.ts +5 -5
  74. package/src/repositories/my-order.ts +2 -2
  75. package/src/repositories/my-quote-request.ts +1 -1
  76. package/src/repositories/order/actions.ts +8 -9
  77. package/src/repositories/order/index.test.ts +8 -9
  78. package/src/repositories/order/index.ts +16 -17
  79. package/src/repositories/order-edit.ts +4 -4
  80. package/src/repositories/payment/actions.ts +6 -6
  81. package/src/repositories/payment/helpers.ts +3 -3
  82. package/src/repositories/payment/index.ts +7 -7
  83. package/src/repositories/product/actions.ts +7 -7
  84. package/src/repositories/product/helpers.ts +4 -4
  85. package/src/repositories/product/index.ts +13 -13
  86. package/src/repositories/product-discount.ts +9 -6
  87. package/src/repositories/product-projection.ts +7 -7
  88. package/src/repositories/product-selection.ts +9 -6
  89. package/src/repositories/product-tailoring.ts +6 -3
  90. package/src/repositories/product-type.ts +8 -5
  91. package/src/repositories/project.ts +5 -5
  92. package/src/repositories/quote/actions.ts +6 -6
  93. package/src/repositories/quote/index.ts +5 -5
  94. package/src/repositories/quote-request/actions.ts +6 -6
  95. package/src/repositories/quote-request/index.test.ts +3 -3
  96. package/src/repositories/quote-request/index.ts +5 -5
  97. package/src/repositories/quote-staged/actions.ts +6 -6
  98. package/src/repositories/quote-staged/index.ts +5 -5
  99. package/src/repositories/recurrence-policy/actions.ts +3 -3
  100. package/src/repositories/recurrence-policy/index.ts +4 -8
  101. package/src/repositories/recurring-order/actions.ts +3 -3
  102. package/src/repositories/recurring-order/index.ts +5 -5
  103. package/src/repositories/review.test.ts +5 -5
  104. package/src/repositories/review.ts +10 -9
  105. package/src/repositories/shipping-method/actions.ts +7 -9
  106. package/src/repositories/shipping-method/helpers.ts +1 -1
  107. package/src/repositories/shipping-method/index.ts +8 -8
  108. package/src/repositories/shopping-list/actions.ts +5 -5
  109. package/src/repositories/shopping-list/index.ts +7 -7
  110. package/src/repositories/standalone-price.ts +9 -6
  111. package/src/repositories/state.ts +9 -6
  112. package/src/repositories/store.ts +10 -7
  113. package/src/repositories/subscription.test.ts +3 -3
  114. package/src/repositories/subscription.ts +9 -6
  115. package/src/repositories/tax-category/actions.ts +4 -4
  116. package/src/repositories/tax-category/index.ts +6 -6
  117. package/src/repositories/type/actions.ts +4 -4
  118. package/src/repositories/type/index.ts +5 -5
  119. package/src/repositories/zone.test.ts +3 -3
  120. package/src/repositories/zone.ts +8 -5
  121. package/src/server.ts +4 -3
  122. package/src/services/abstract.ts +5 -5
  123. package/src/services/as-associate-cart.test.ts +1 -1
  124. package/src/services/as-associate-cart.ts +2 -2
  125. package/src/services/as-associate-order.test.ts +1 -1
  126. package/src/services/as-associate-order.ts +2 -2
  127. package/src/services/as-associate-quote-request.ts +2 -3
  128. package/src/services/as-associate.test.ts +1 -1
  129. package/src/services/as-associate.ts +4 -4
  130. package/src/services/associate-roles.test.ts +1 -1
  131. package/src/services/associate-roles.ts +2 -2
  132. package/src/services/attribute-group.test.ts +1 -1
  133. package/src/services/attribute-group.ts +2 -2
  134. package/src/services/business-units.test.ts +5 -5
  135. package/src/services/business-units.ts +2 -2
  136. package/src/services/cart-discount.ts +2 -2
  137. package/src/services/cart.test.ts +7 -3
  138. package/src/services/cart.ts +4 -5
  139. package/src/services/category.test.ts +1 -1
  140. package/src/services/category.ts +2 -2
  141. package/src/services/channel.test.ts +1 -1
  142. package/src/services/channel.ts +2 -2
  143. package/src/services/custom-object.test.ts +2 -2
  144. package/src/services/custom-object.ts +3 -3
  145. package/src/services/customer-group.test.ts +1 -1
  146. package/src/services/customer-group.ts +2 -2
  147. package/src/services/customer.test.ts +3 -3
  148. package/src/services/customer.ts +4 -5
  149. package/src/services/discount-code.test.ts +1 -1
  150. package/src/services/discount-code.ts +2 -2
  151. package/src/services/discount-group.test.ts +1 -1
  152. package/src/services/discount-group.ts +2 -2
  153. package/src/services/extension.test.ts +1 -1
  154. package/src/services/extension.ts +2 -2
  155. package/src/services/index.ts +44 -44
  156. package/src/services/inventory-entry.test.ts +16 -1
  157. package/src/services/inventory-entry.ts +2 -2
  158. package/src/services/my-business-unit.test.ts +1 -1
  159. package/src/services/my-business-unit.ts +2 -2
  160. package/src/services/my-cart.test.ts +1 -1
  161. package/src/services/my-cart.ts +2 -2
  162. package/src/services/my-customer.test.ts +2 -2
  163. package/src/services/my-customer.ts +6 -6
  164. package/src/services/my-order.ts +2 -2
  165. package/src/services/my-payment.test.ts +1 -1
  166. package/src/services/my-payment.ts +2 -2
  167. package/src/services/my-shopping-list.ts +2 -2
  168. package/src/services/order.test.ts +4 -11
  169. package/src/services/order.ts +4 -4
  170. package/src/services/payment.test.ts +1 -1
  171. package/src/services/payment.ts +2 -2
  172. package/src/services/product-discount.test.ts +1 -1
  173. package/src/services/product-discount.ts +2 -2
  174. package/src/services/product-projection.test.ts +2 -2
  175. package/src/services/product-projection.ts +4 -4
  176. package/src/services/product-selection.test.ts +1 -1
  177. package/src/services/product-selection.ts +2 -2
  178. package/src/services/product-type.test.ts +1 -1
  179. package/src/services/product-type.ts +2 -2
  180. package/src/services/product.test.ts +1 -1
  181. package/src/services/product.ts +3 -3
  182. package/src/services/project.test.ts +1 -1
  183. package/src/services/project.ts +4 -4
  184. package/src/services/quote-request.test.ts +2 -2
  185. package/src/services/quote-request.ts +2 -2
  186. package/src/services/quote-staged.ts +2 -2
  187. package/src/services/quote.ts +2 -2
  188. package/src/services/recurrence-policy.test.ts +1 -1
  189. package/src/services/recurrence-policy.ts +2 -2
  190. package/src/services/recurring-order.test.ts +1 -1
  191. package/src/services/recurring-order.ts +2 -2
  192. package/src/services/reviews.test.ts +1 -1
  193. package/src/services/reviews.ts +2 -2
  194. package/src/services/shipping-method.test.ts +2 -2
  195. package/src/services/shipping-method.ts +4 -4
  196. package/src/services/shopping-list.test.ts +1 -1
  197. package/src/services/shopping-list.ts +2 -2
  198. package/src/services/standalone-price.test.ts +1 -1
  199. package/src/services/standalone-price.ts +2 -2
  200. package/src/services/state.test.ts +1 -1
  201. package/src/services/state.ts +2 -2
  202. package/src/services/store.test.ts +1 -1
  203. package/src/services/store.ts +2 -2
  204. package/src/services/subscription.test.ts +1 -1
  205. package/src/services/subscription.ts +2 -2
  206. package/src/services/tax-category.test.ts +1 -1
  207. package/src/services/tax-category.ts +2 -2
  208. package/src/services/type.test.ts +1 -1
  209. package/src/services/type.ts +2 -2
  210. package/src/services/zone.test.ts +1 -1
  211. package/src/services/zone.ts +2 -2
  212. package/src/shipping.test.ts +1 -1
  213. package/src/shipping.ts +8 -8
  214. package/src/storage/abstract.ts +1 -1
  215. package/src/storage/in-memory.ts +15 -17
  216. package/src/storage/index.ts +2 -2
  217. package/src/testing/business-unit.ts +1 -2
  218. package/src/testing/customer.ts +1 -1
  219. package/src/testing/type.ts +1 -1
  220. package/src/types.ts +1 -1
  221. package/src/validate.ts +1 -1
  222. package/dist/index.d.ts.map +0 -1
  223. package/dist/index.js.map +0 -1
package/package.json CHANGED
@@ -1,12 +1,16 @@
1
1
  {
2
2
  "name": "@labdigital/commercetools-mock",
3
- "version": "2.60.0",
3
+ "version": "2.61.1",
4
4
  "license": "MIT",
5
5
  "author": "Michael van Tellingen",
6
6
  "type": "module",
7
7
  "exports": {
8
8
  ".": "./dist/index.js"
9
9
  },
10
+ "imports": {
11
+ "#src/*": "./src/*",
12
+ "#vendor/*": "./vendor/*"
13
+ },
10
14
  "main": "dist/index.js",
11
15
  "module": "dist/index.js",
12
16
  "typings": "dist/index.d.ts",
@@ -16,49 +20,57 @@
16
20
  ],
17
21
  "dependencies": {
18
22
  "basic-auth": "2.0.1",
19
- "body-parser": "2.2.0",
23
+ "body-parser": "2.2.1",
20
24
  "decimal.js": "10.5.0",
21
25
  "express": "5.1.0",
22
26
  "light-my-request": "6.6.0",
23
- "morgan": "1.10.0",
27
+ "morgan": "1.10.1",
24
28
  "msw": "2.8.4",
25
29
  "uuid": "11.1.0",
26
30
  "zod": "3.24.2",
27
31
  "zod-validation-error": "3.4.0"
28
32
  },
29
33
  "devDependencies": {
30
- "@biomejs/biome": "1.9.4",
31
- "@types/express": "^5.0.1",
32
- "@changesets/changelog-github": "0.5.1",
33
- "@changesets/cli": "2.28.1",
34
+ "@biomejs/biome": "2.3.7",
35
+ "@changesets/changelog-github": "0.5.2",
36
+ "@changesets/cli": "2.29.7",
34
37
  "@commercetools/platform-sdk": "8.16.0",
35
38
  "@types/basic-auth": "1.1.8",
36
39
  "@types/body-parser": "1.19.5",
37
- "@types/express-serve-static-core": "^5.0.6",
40
+ "@types/express": "5.0.5",
41
+ "@types/express-serve-static-core": "^5.1.0",
38
42
  "@types/morgan": "1.9.9",
39
43
  "@types/node": "20.16.14",
40
44
  "@types/qs": "6.9.11",
41
- "@types/supertest": "6.0.2",
45
+ "@types/supertest": "6.0.3",
42
46
  "@types/uuid": "9.0.8",
43
- "@vitest/coverage-v8": "3.1.1",
44
- "esbuild": "0.25.2",
47
+ "@vitest/coverage-v8": "4.0.13",
45
48
  "fishery": "2.2.3",
46
- "supertest": "7.1.0",
49
+ "supertest": "7.1.4",
47
50
  "timekeeper": "2.3.1",
48
- "tsdown": "^0.9.9",
49
- "typescript": "5.8.3",
50
- "vitest": "3.1.1"
51
+ "tsdown": "0.16.8",
52
+ "typescript": "5.9.3",
53
+ "vitest": "4.0.13"
51
54
  },
52
55
  "engines": {
53
56
  "node": ">=18",
54
- "pnpm": ">=9.0.2"
57
+ "pnpm": ">=10.8.0"
55
58
  },
56
59
  "publishConfig": {
57
- "access": "public"
60
+ "access": "public",
61
+ "provenance": true
62
+ },
63
+ "repository": {
64
+ "type": "git",
65
+ "url": "git+https://github.com/labd/commercetools-node-mock.git"
66
+ },
67
+ "bugs": {
68
+ "url": "https://github.com/labd/commercetools-node-mock/issues"
58
69
  },
70
+ "homepage": "https://github.com/labd/commercetools-node-mock#readme",
59
71
  "scripts": {
60
72
  "build": "tsdown",
61
- "build:server": "esbuild src/server.ts --bundle --outfile=dist/server.js --platform=node",
73
+ "build:server": "tsdown src/server.ts --platform=node",
62
74
  "check": "biome check && tsc",
63
75
  "format": "biome check --fix",
64
76
  "lint": "biome check",
package/src/config.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { AbstractStorage } from "./storage";
1
+ import type { AbstractStorage } from "./storage/index.ts";
2
2
 
3
3
  export type Config = {
4
4
  strict: boolean;
@@ -1,5 +1,5 @@
1
1
  import { test } from "vitest";
2
- import { CommercetoolsMock } from "./index";
2
+ import { CommercetoolsMock } from "./index.ts";
3
3
 
4
4
  test("ctMock.authServer", async () => {
5
5
  const ctMock = new CommercetoolsMock({
package/src/ctMock.ts CHANGED
@@ -2,23 +2,23 @@ import type { NextFunction, Request, Response } from "express";
2
2
  import express from "express";
3
3
  import inject from "light-my-request";
4
4
  import morgan from "morgan";
5
- import { http, HttpResponse } from "msw";
5
+ import { HttpResponse, http } from "msw";
6
6
  import type { SetupServer, SetupServerApi } from "msw/node";
7
7
  import { setupServer } from "msw/node";
8
- import type { Config } from "./config";
9
- import { DEFAULT_API_HOSTNAME, DEFAULT_AUTH_HOSTNAME } from "./constants";
10
- import { CommercetoolsError } from "./exceptions";
11
- import { mapHeaderType } from "./helpers";
12
- import { copyHeaders } from "./lib/proxy";
13
- import { OAuth2Server } from "./oauth/server";
14
- import { ProjectAPI } from "./projectAPI";
15
- import type { RepositoryMap } from "./repositories";
16
- import { createRepositories } from "./repositories";
17
- import type { ProjectRepository } from "./repositories/project";
18
- import { createServices } from "./services";
19
- import { ProjectService } from "./services/project";
20
- import type { AbstractStorage } from "./storage";
21
- import { InMemoryStorage } from "./storage";
8
+ import type { Config } from "./config.ts";
9
+ import { DEFAULT_API_HOSTNAME, DEFAULT_AUTH_HOSTNAME } from "./constants.ts";
10
+ import { CommercetoolsError } from "./exceptions.ts";
11
+ import { mapHeaderType } from "./helpers.ts";
12
+ import { copyHeaders } from "./lib/proxy.ts";
13
+ import { OAuth2Server } from "./oauth/server.ts";
14
+ import { ProjectAPI } from "./projectAPI.ts";
15
+ import type { RepositoryMap } from "./repositories/index.ts";
16
+ import { createRepositories } from "./repositories/index.ts";
17
+ import type { ProjectRepository } from "./repositories/project.ts";
18
+ import { createServices } from "./services/index.ts";
19
+ import { ProjectService } from "./services/project.ts";
20
+ import type { AbstractStorage } from "./storage/index.ts";
21
+ import { InMemoryStorage } from "./storage/index.ts";
22
22
 
23
23
  export type CommercetoolsMockOptions = {
24
24
  validateCredentials: boolean;
@@ -57,7 +57,8 @@ export class CommercetoolsMock {
57
57
 
58
58
  private _repositories: RepositoryMap | null;
59
59
 
60
- private _projectService?: ProjectService;
60
+ // biome-ignore lint: lint/correctness/noUnusedPrivateClassMembers
61
+ private _projectService: ProjectService | undefined;
61
62
 
62
63
  constructor(options: Partial<CommercetoolsMockOptions> = {}) {
63
64
  this.options = { ...DEFAULT_OPTIONS, ...options };
@@ -123,9 +124,7 @@ export class CommercetoolsMock {
123
124
  }
124
125
 
125
126
  runServer(port = 3000, options?: AppOptions) {
126
- const server = this.app.listen(port, () => {
127
- console.info(`Mock server listening at http://localhost:${port}`);
128
- });
127
+ const server = this.app.listen(port, () => {});
129
128
  server.keepAliveTimeout = 60 * 1000;
130
129
  }
131
130
 
@@ -186,7 +185,6 @@ export class CommercetoolsMock {
186
185
  });
187
186
  return;
188
187
  }
189
- console.error(err);
190
188
  resp.status(500).send({
191
189
  error: err.message,
192
190
  });
@@ -312,7 +310,10 @@ export class CommercetoolsMock {
312
310
  throw new Error("Server already started");
313
311
  }
314
312
  process.emitWarning("Server wasn't stopped properly, clearing");
315
- _globalListeners.forEach((listener) => listener.close());
313
+ for (const listener of _globalListeners) {
314
+ listener.close();
315
+ }
316
+ _globalListeners.length = 0;
316
317
  }
317
318
 
318
319
  const server = setupServer();
package/src/index.test.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { InvalidTokenError } from "@commercetools/platform-sdk";
2
2
  import { setupServer } from "msw/node";
3
3
  import { afterEach, beforeAll, expect, test } from "vitest";
4
- import { CommercetoolsMock } from "./index";
4
+ import { CommercetoolsMock } from "./index.ts";
5
5
 
6
6
  const mswServer = setupServer();
7
7
 
package/src/index.ts CHANGED
@@ -1,6 +1,6 @@
1
- import type { CommercetoolsMockOptions } from "./ctMock";
2
- import { CommercetoolsMock } from "./ctMock";
3
- import { getBaseResourceProperties } from "./helpers";
1
+ import type { CommercetoolsMockOptions } from "./ctMock.ts";
2
+ import { CommercetoolsMock } from "./ctMock.ts";
3
+ import { getBaseResourceProperties } from "./helpers.ts";
4
4
 
5
5
  export {
6
6
  CommercetoolsMock,
@@ -1,6 +1,6 @@
1
1
  import { expect, test } from "vitest";
2
- import type { Location } from "./haversine";
3
- import { haversineDistance } from "./haversine";
2
+ import type { Location } from "./haversine.ts";
3
+ import { haversineDistance } from "./haversine.ts";
4
4
 
5
5
  test("haversine", () => {
6
6
  // Lab Digital
@@ -1,4 +1,4 @@
1
- import { cloneObject } from "../helpers";
1
+ import { cloneObject } from "../helpers.ts";
2
2
 
3
3
  export const maskSecretValue = <T>(resource: T, path: string): T => {
4
4
  const parts = path.split(".");
package/src/lib/parser.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { Lexer } from "~vendor/perplex/lexer";
2
- export { Parser, type ITokenPosition } from "~vendor/pratt";
1
+ export { Lexer } from "#vendor/perplex/lexer.ts";
2
+ export { type ITokenPosition, Parser } from "#vendor/pratt/index.ts";
@@ -31,7 +31,7 @@ export const validatePasswordResetToken = (token: string) => {
31
31
  }
32
32
 
33
33
  // Check if the token is expired
34
- if (Number.parseInt(time) < new Date().getTime()) {
34
+ if (Number.parseInt(time, 10) < Date.now()) {
35
35
  return undefined;
36
36
  }
37
37
 
@@ -1,6 +1,6 @@
1
1
  import type { VariableMap } from "@commercetools/platform-sdk";
2
2
  import { describe, expect, test } from "vitest";
3
- import { PredicateError, parseQueryExpression } from "./predicateParser";
3
+ import { PredicateError, parseQueryExpression } from "./predicateParser.ts";
4
4
 
5
5
  describe("Predicate filter", () => {
6
6
  const exampleObject = {
@@ -4,8 +4,8 @@
4
4
  *
5
5
  * See https://docs.commercetools.com/api/predicates/query
6
6
  */
7
- import { haversineDistance } from "./haversine";
8
- import { type ITokenPosition, Lexer, Parser } from "./parser";
7
+ import { haversineDistance } from "./haversine.ts";
8
+ import { type ITokenPosition, Lexer, Parser } from "./parser.ts";
9
9
 
10
10
  export class PredicateError {
11
11
  message: string;
@@ -194,7 +194,7 @@ const generateMatchFunc = (predicate: string): MatchFunc => {
194
194
  (t) =>
195
195
  ({
196
196
  type: "var",
197
- // @ts-ignore
197
+ // @ts-expect-error
198
198
  value: t.token.groups[1],
199
199
  pos: t.token.strpos(),
200
200
  }) as TypeSymbol,
@@ -205,7 +205,7 @@ const generateMatchFunc = (predicate: string): MatchFunc => {
205
205
  (t) =>
206
206
  ({
207
207
  type: "string",
208
- // @ts-ignore
208
+ // @ts-expect-error
209
209
  value: t.token.groups[1],
210
210
  pos: t.token.strpos(),
211
211
  }) as TypeSymbol,
@@ -1,11 +1,7 @@
1
- import type {
2
- Product,
3
- ProductProjection,
4
- Review,
5
- } from "@commercetools/platform-sdk";
1
+ import type { Product } from "@commercetools/platform-sdk";
6
2
  import supertest from "supertest";
7
3
  import { beforeEach, describe, expect, test } from "vitest";
8
- import { CommercetoolsMock } from "~src/index";
4
+ import { CommercetoolsMock } from "#src/index.ts";
9
5
 
10
6
  describe("Product Review Statistics", () => {
11
7
  let ctMock: CommercetoolsMock;
@@ -179,7 +175,7 @@ describe("Product Review Statistics", () => {
179
175
 
180
176
  test("only reviews with includedInStatistics=true are counted", async () => {
181
177
  // Create reviews - both will be included by default
182
- const review1Response = await supertest(ctMock.app)
178
+ const _review1Response = await supertest(ctMock.app)
183
179
  .post("/dummy/reviews")
184
180
  .send({
185
181
  authorName: "Reviewer 1",
@@ -190,7 +186,7 @@ describe("Product Review Statistics", () => {
190
186
  },
191
187
  });
192
188
 
193
- const review2Response = await supertest(ctMock.app)
189
+ const _review2Response = await supertest(ctMock.app)
194
190
  .post("/dummy/reviews")
195
191
  .send({
196
192
  authorName: "Reviewer 2",
@@ -1,10 +1,10 @@
1
1
  import type {
2
- ProductProjection,
3
2
  _SearchQuery,
3
+ ProductProjection,
4
4
  } from "@commercetools/platform-sdk";
5
5
  import { describe, expect, test } from "vitest";
6
- import { cloneObject } from "~src/helpers";
7
- import { parseSearchQuery } from "./productSearchFilter";
6
+ import { cloneObject } from "#src/helpers.ts";
7
+ import { parseSearchQuery } from "./productSearchFilter.ts";
8
8
 
9
9
  describe("Product search filter", () => {
10
10
  const exampleProduct: ProductProjection = {
@@ -1,4 +1,7 @@
1
1
  import type {
2
+ _SearchQuery,
3
+ _SearchQueryExpression,
4
+ _SearchQueryExpressionValue,
2
5
  ProductProjection,
3
6
  ProductVariant,
4
7
  SearchAndExpression,
@@ -16,13 +19,10 @@ import type {
16
19
  SearchPrefixExpression,
17
20
  SearchTimeRangeExpression,
18
21
  SearchWildCardExpression,
19
- _SearchQuery,
20
- _SearchQueryExpression,
21
- _SearchQueryExpressionValue,
22
22
  } from "@commercetools/platform-sdk";
23
- import { nestedLookup } from "~src/helpers";
24
- import type { Writable } from "../types";
25
- import { getVariants } from "./projectionSearchFilter";
23
+ import { nestedLookup } from "#src/helpers.ts";
24
+ import type { Writable } from "../types.ts";
25
+ import { getVariants } from "./projectionSearchFilter.ts";
26
26
 
27
27
  type ProductSearchFilterFunc = (
28
28
  p: Writable<ProductProjection>,
@@ -1,8 +1,8 @@
1
1
  import type { ProductProjection } from "@commercetools/platform-sdk";
2
2
  import { describe, expect, test } from "vitest";
3
- import { cloneObject } from "../helpers";
4
- import { applyPriceSelector } from "../priceSelector";
5
- import { parseFilterExpression } from "./projectionSearchFilter";
3
+ import { cloneObject } from "../helpers.ts";
4
+ import { applyPriceSelector } from "../priceSelector.ts";
5
+ import { parseFilterExpression } from "./projectionSearchFilter.ts";
6
6
 
7
7
  describe("Search filter", () => {
8
8
  const exampleProduct: ProductProjection = {
@@ -6,9 +6,9 @@ import type {
6
6
  ProductProjection,
7
7
  ProductVariant,
8
8
  } from "@commercetools/platform-sdk";
9
- import { nestedLookup } from "../helpers";
10
- import type { Writable } from "../types";
11
- import { Lexer, Parser } from "./parser";
9
+ import { nestedLookup } from "../helpers.ts";
10
+ import type { Writable } from "../types.ts";
11
+ import { Lexer, Parser } from "./parser.ts";
12
12
 
13
13
  type MatchFunc = (target: any) => boolean;
14
14
 
@@ -143,7 +143,7 @@ const parseFilter = (filter: string): ExpressionSet => {
143
143
  ({
144
144
  type: "Symbol",
145
145
  kind: "string",
146
- // @ts-ignore
146
+ // @ts-expect-error
147
147
  value: t.token.groups[1],
148
148
  }) as TypeSymbol,
149
149
  )
@@ -2,7 +2,7 @@ import type {
2
2
  Review,
3
3
  ReviewRatingStatistics,
4
4
  } from "@commercetools/platform-sdk";
5
- import type { AbstractStorage } from "../storage";
5
+ import type { AbstractStorage } from "../storage/index.ts";
6
6
 
7
7
  export class ReviewStatisticsService {
8
8
  constructor(private _storage: AbstractStorage) {}
@@ -1,8 +1,8 @@
1
1
  import type {
2
- SearchAndExpression,
3
- SearchOrExpression,
4
2
  _SearchQuery,
5
3
  _SearchQueryExpression,
4
+ SearchAndExpression,
5
+ SearchOrExpression,
6
6
  } from "@commercetools/platform-sdk";
7
7
  import { describe, expect, it } from "vitest";
8
8
  import {
@@ -19,7 +19,7 @@ import {
19
19
  isSearchRangeExpression,
20
20
  isSearchWildCardExpression,
21
21
  validateSearchQuery,
22
- } from "./searchQueryTypeChecker";
22
+ } from "./searchQueryTypeChecker.ts";
23
23
 
24
24
  describe("searchQueryTypeChecker", () => {
25
25
  it("should validate SearchAndExpression", () => {
@@ -1,4 +1,6 @@
1
1
  import type {
2
+ _SearchQuery,
3
+ _SearchQueryExpression,
2
4
  SearchAndExpression,
3
5
  SearchAnyValue,
4
6
  SearchDateRangeExpression,
@@ -15,15 +17,17 @@ import type {
15
17
  SearchPrefixExpression,
16
18
  SearchTimeRangeExpression,
17
19
  SearchWildCardExpression,
18
- _SearchQuery,
19
- _SearchQueryExpression,
20
20
  } from "@commercetools/platform-sdk";
21
21
 
22
22
  export const validateSearchQuery = (query: _SearchQuery): void => {
23
23
  if (isSearchAndExpression(query)) {
24
- query.and.forEach((expr) => validateSearchQuery(expr));
24
+ for (const expr of query.and) {
25
+ validateSearchQuery(expr);
26
+ }
25
27
  } else if (isSearchOrExpression(query)) {
26
- query.or.forEach((expr) => validateSearchQuery(expr));
28
+ for (const expr of query.or) {
29
+ validateSearchQuery(expr);
30
+ }
27
31
  } else if (isSearchNotExpression(query)) {
28
32
  validateSearchQuery(query.not);
29
33
  } else if (
@@ -1,14 +1,14 @@
1
1
  import type {
2
2
  TaxCategory,
3
- TaxRate,
4
3
  TaxedItemPrice,
4
+ TaxRate,
5
5
  } from "@commercetools/platform-sdk";
6
6
  import { describe, expect, test } from "vitest";
7
7
  import {
8
- calculateTaxTotals,
9
8
  calculateTaxedPrice,
10
9
  calculateTaxedPriceFromRate,
11
- } from "~src/lib/tax";
10
+ calculateTaxTotals,
11
+ } from "#src/lib/tax.ts";
12
12
 
13
13
  const money = (centAmount: number) => ({
14
14
  type: "centPrecision" as const,
package/src/lib/tax.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import type {
2
2
  Cart,
3
3
  TaxCategory,
4
- TaxPortion,
5
- TaxRate,
6
4
  TaxedItemPrice,
7
5
  TaxedPrice,
6
+ TaxPortion,
7
+ TaxRate,
8
8
  } from "@commercetools/platform-sdk";
9
- import { createCentPrecisionMoney } from "~src/repositories/helpers";
9
+ import { createCentPrecisionMoney } from "#src/repositories/helpers.ts";
10
10
 
11
11
  type TaxableResource = Pick<
12
12
  Cart,
@@ -1,13 +1,13 @@
1
1
  import express from "express";
2
2
  import supertest from "supertest";
3
3
  import { beforeEach, describe, expect, it } from "vitest";
4
- import type { Config } from "~src/config";
5
- import { getBaseResourceProperties } from "../helpers";
6
- import { hashPassword } from "../lib/password";
7
- import { CustomerRepository } from "../repositories/customer";
8
- import type { AbstractStorage } from "../storage";
9
- import { InMemoryStorage } from "../storage";
10
- import { OAuth2Server } from "./server";
4
+ import type { Config } from "#src/config.ts";
5
+ import { getBaseResourceProperties } from "../helpers.ts";
6
+ import { hashPassword } from "../lib/password.ts";
7
+ import { CustomerRepository } from "../repositories/customer/index.ts";
8
+ import type { AbstractStorage } from "../storage/index.ts";
9
+ import { InMemoryStorage } from "../storage/index.ts";
10
+ import { OAuth2Server } from "./server.ts";
11
11
 
12
12
  describe("OAuth2Server", () => {
13
13
  let app: express.Express;
@@ -6,13 +6,13 @@ import express, {
6
6
  type Request,
7
7
  type Response,
8
8
  } from "express";
9
- import type { AuthError, InvalidRequestError } from "~src/exceptions";
10
- import { CommercetoolsError } from "~src/exceptions";
11
- import { hashPassword } from "../lib/password";
12
- import type { CustomerRepository } from "../repositories/customer";
13
- import type { InvalidClientError, UnsupportedGrantType } from "./errors";
14
- import { getBearerToken } from "./helpers";
15
- import { OAuth2Store } from "./store";
9
+ import type { AuthError, InvalidRequestError } from "#src/exceptions.ts";
10
+ import { CommercetoolsError } from "#src/exceptions.ts";
11
+ import { hashPassword } from "../lib/password.ts";
12
+ import type { CustomerRepository } from "../repositories/customer/index.ts";
13
+ import type { InvalidClientError, UnsupportedGrantType } from "./errors.ts";
14
+ import { getBearerToken } from "./helpers.ts";
15
+ import { OAuth2Store } from "./store.ts";
16
16
 
17
17
  type AuthRequest = Request & {
18
18
  credentials?: {
@@ -1,6 +1,6 @@
1
1
  import type { ProductProjection } from "@commercetools/platform-sdk";
2
2
  import { beforeEach, describe, expect, test } from "vitest";
3
- import { applyPriceSelector } from "./priceSelector";
3
+ import { applyPriceSelector } from "./priceSelector.ts";
4
4
 
5
5
  describe("priceSelector", () => {
6
6
  let product: ProductProjection;
@@ -4,8 +4,8 @@ import type {
4
4
  ProductProjection,
5
5
  ProductVariant,
6
6
  } from "@commercetools/platform-sdk";
7
- import { CommercetoolsError } from "./exceptions";
8
- import type { Writable } from "./types";
7
+ import { CommercetoolsError } from "./exceptions.ts";
8
+ import type { Writable } from "./types.ts";
9
9
 
10
10
  export type PriceSelector = {
11
11
  currency?: string;
@@ -3,30 +3,29 @@ import type {
3
3
  FilteredFacetResult,
4
4
  InvalidInputError,
5
5
  Product,
6
- ProductData,
7
6
  ProductProjection,
8
7
  ProductProjectionPagedSearchResponse,
9
8
  QueryParam,
10
9
  RangeFacetResult,
11
10
  TermFacetResult,
12
11
  } from "@commercetools/platform-sdk";
13
- import type { Config } from "./config";
14
- import { CommercetoolsError } from "./exceptions";
15
- import { nestedLookup } from "./helpers";
12
+ import type { Config } from "./config.ts";
13
+ import { CommercetoolsError } from "./exceptions.ts";
14
+ import { nestedLookup } from "./helpers.ts";
16
15
  import type {
17
16
  FilterExpression,
18
17
  RangeExpression,
19
- } from "./lib/projectionSearchFilter";
18
+ } from "./lib/projectionSearchFilter.ts";
20
19
  import {
21
20
  generateFacetFunc,
22
21
  getVariants,
23
22
  parseFilterExpression,
24
23
  resolveVariantValue,
25
- } from "./lib/projectionSearchFilter";
26
- import { ReviewStatisticsService } from "./lib/review-statistics";
27
- import { applyPriceSelector } from "./priceSelector";
28
- import type { AbstractStorage } from "./storage";
29
- import type { Writable } from "./types";
24
+ } from "./lib/projectionSearchFilter.ts";
25
+ import { ReviewStatisticsService } from "./lib/review-statistics.ts";
26
+ import { applyPriceSelector } from "./priceSelector.ts";
27
+ import type { AbstractStorage } from "./storage/index.ts";
28
+ import type { Writable } from "./types.ts";
30
29
 
31
30
  export type ProductProjectionSearchParams = {
32
31
  fuzzy?: boolean;
@@ -94,7 +93,6 @@ export class ProductProjectionSearch {
94
93
  filters.every((f) => f(resource, markMatchingVariant)),
95
94
  );
96
95
  } catch (err) {
97
- console.error(err);
98
96
  throw new CommercetoolsError<InvalidInputError>(
99
97
  {
100
98
  code: "InvalidInput",
@@ -364,7 +362,7 @@ export class ProductProjectionSearch {
364
362
  }) || [];
365
363
  const data: RangeFacetResult = {
366
364
  type: "range",
367
- // @ts-ignore
365
+ // @ts-expect-error
368
366
  dataType: "number",
369
367
  ranges: counts,
370
368
  };
@@ -6,7 +6,7 @@ import type {
6
6
  } from "@commercetools/platform-sdk";
7
7
  import supertest from "supertest";
8
8
  import { afterEach, beforeEach, describe, expect, test } from "vitest";
9
- import { CommercetoolsMock } from "./index";
9
+ import { CommercetoolsMock } from "./index.ts";
10
10
 
11
11
  describe("Product Search - Availability Filtering", () => {
12
12
  const ctMock = new CommercetoolsMock();
@@ -6,12 +6,12 @@ import type {
6
6
  ProductSearchRequest,
7
7
  ProductSearchResult,
8
8
  } from "@commercetools/platform-sdk";
9
- import type { Config } from "./config";
10
- import { CommercetoolsError } from "./exceptions";
11
- import { parseSearchQuery } from "./lib/productSearchFilter";
12
- import { validateSearchQuery } from "./lib/searchQueryTypeChecker";
13
- import { applyPriceSelector } from "./priceSelector";
14
- import type { AbstractStorage } from "./storage";
9
+ import type { Config } from "./config.ts";
10
+ import { CommercetoolsError } from "./exceptions.ts";
11
+ import { parseSearchQuery } from "./lib/productSearchFilter.ts";
12
+ import { validateSearchQuery } from "./lib/searchQueryTypeChecker.ts";
13
+ import { applyPriceSelector } from "./priceSelector.ts";
14
+ import type { AbstractStorage } from "./storage/index.ts";
15
15
 
16
16
  interface ProductSearchVariantAvailability {
17
17
  isOnStock: boolean;
@@ -78,7 +78,6 @@ export class ProductSearch {
78
78
  matchFunc(resource, markMatchingVariant),
79
79
  );
80
80
  } catch (err) {
81
- console.error(err);
82
81
  throw new CommercetoolsError<InvalidInputError>(
83
82
  {
84
83
  code: "InvalidInput",