@labdigital/commercetools-mock 2.60.0 → 2.61.0

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 (222) hide show
  1. package/dist/{index.d.ts → index.d.mts} +154 -275
  2. package/dist/{index.js → index.mjs} +241 -349
  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 +21 -23
  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 +9 -9
  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.ts +9 -12
  68. package/src/repositories/index.test.ts +3 -3
  69. package/src/repositories/index.ts +43 -43
  70. package/src/repositories/inventory-entry/actions.ts +15 -3
  71. package/src/repositories/inventory-entry/index.ts +5 -5
  72. package/src/repositories/my-customer.ts +5 -5
  73. package/src/repositories/my-order.ts +2 -2
  74. package/src/repositories/my-quote-request.ts +1 -1
  75. package/src/repositories/order/actions.ts +8 -9
  76. package/src/repositories/order/index.test.ts +8 -9
  77. package/src/repositories/order/index.ts +16 -17
  78. package/src/repositories/order-edit.ts +4 -4
  79. package/src/repositories/payment/actions.ts +6 -6
  80. package/src/repositories/payment/helpers.ts +3 -3
  81. package/src/repositories/payment/index.ts +7 -7
  82. package/src/repositories/product/actions.ts +7 -7
  83. package/src/repositories/product/helpers.ts +4 -4
  84. package/src/repositories/product/index.ts +13 -13
  85. package/src/repositories/product-discount.ts +9 -6
  86. package/src/repositories/product-projection.ts +7 -7
  87. package/src/repositories/product-selection.ts +9 -6
  88. package/src/repositories/product-tailoring.ts +6 -3
  89. package/src/repositories/product-type.ts +8 -5
  90. package/src/repositories/project.ts +5 -5
  91. package/src/repositories/quote/actions.ts +6 -6
  92. package/src/repositories/quote/index.ts +5 -5
  93. package/src/repositories/quote-request/actions.ts +6 -6
  94. package/src/repositories/quote-request/index.test.ts +3 -3
  95. package/src/repositories/quote-request/index.ts +5 -5
  96. package/src/repositories/quote-staged/actions.ts +6 -6
  97. package/src/repositories/quote-staged/index.ts +5 -5
  98. package/src/repositories/recurrence-policy/actions.ts +3 -3
  99. package/src/repositories/recurrence-policy/index.ts +4 -8
  100. package/src/repositories/recurring-order/actions.ts +3 -3
  101. package/src/repositories/recurring-order/index.ts +5 -5
  102. package/src/repositories/review.test.ts +5 -5
  103. package/src/repositories/review.ts +10 -9
  104. package/src/repositories/shipping-method/actions.ts +7 -9
  105. package/src/repositories/shipping-method/helpers.ts +1 -1
  106. package/src/repositories/shipping-method/index.ts +8 -8
  107. package/src/repositories/shopping-list/actions.ts +5 -5
  108. package/src/repositories/shopping-list/index.ts +7 -7
  109. package/src/repositories/standalone-price.ts +9 -6
  110. package/src/repositories/state.ts +9 -6
  111. package/src/repositories/store.ts +10 -7
  112. package/src/repositories/subscription.test.ts +3 -3
  113. package/src/repositories/subscription.ts +9 -6
  114. package/src/repositories/tax-category/actions.ts +4 -4
  115. package/src/repositories/tax-category/index.ts +6 -6
  116. package/src/repositories/type/actions.ts +4 -4
  117. package/src/repositories/type/index.ts +5 -5
  118. package/src/repositories/zone.test.ts +3 -3
  119. package/src/repositories/zone.ts +8 -5
  120. package/src/server.ts +4 -3
  121. package/src/services/abstract.ts +5 -5
  122. package/src/services/as-associate-cart.test.ts +1 -1
  123. package/src/services/as-associate-cart.ts +2 -2
  124. package/src/services/as-associate-order.test.ts +1 -1
  125. package/src/services/as-associate-order.ts +2 -2
  126. package/src/services/as-associate-quote-request.ts +2 -3
  127. package/src/services/as-associate.test.ts +1 -1
  128. package/src/services/as-associate.ts +4 -4
  129. package/src/services/associate-roles.test.ts +1 -1
  130. package/src/services/associate-roles.ts +2 -2
  131. package/src/services/attribute-group.test.ts +1 -1
  132. package/src/services/attribute-group.ts +2 -2
  133. package/src/services/business-units.test.ts +5 -5
  134. package/src/services/business-units.ts +2 -2
  135. package/src/services/cart-discount.ts +2 -2
  136. package/src/services/cart.test.ts +2 -2
  137. package/src/services/cart.ts +4 -5
  138. package/src/services/category.test.ts +1 -1
  139. package/src/services/category.ts +2 -2
  140. package/src/services/channel.test.ts +1 -1
  141. package/src/services/channel.ts +2 -2
  142. package/src/services/custom-object.test.ts +2 -2
  143. package/src/services/custom-object.ts +3 -3
  144. package/src/services/customer-group.test.ts +1 -1
  145. package/src/services/customer-group.ts +2 -2
  146. package/src/services/customer.test.ts +3 -3
  147. package/src/services/customer.ts +4 -5
  148. package/src/services/discount-code.test.ts +1 -1
  149. package/src/services/discount-code.ts +2 -2
  150. package/src/services/discount-group.test.ts +1 -1
  151. package/src/services/discount-group.ts +2 -2
  152. package/src/services/extension.test.ts +1 -1
  153. package/src/services/extension.ts +2 -2
  154. package/src/services/index.ts +44 -44
  155. package/src/services/inventory-entry.test.ts +16 -1
  156. package/src/services/inventory-entry.ts +2 -2
  157. package/src/services/my-business-unit.test.ts +1 -1
  158. package/src/services/my-business-unit.ts +2 -2
  159. package/src/services/my-cart.test.ts +1 -1
  160. package/src/services/my-cart.ts +2 -2
  161. package/src/services/my-customer.test.ts +2 -2
  162. package/src/services/my-customer.ts +6 -6
  163. package/src/services/my-order.ts +2 -2
  164. package/src/services/my-payment.test.ts +1 -1
  165. package/src/services/my-payment.ts +2 -2
  166. package/src/services/my-shopping-list.ts +2 -2
  167. package/src/services/order.test.ts +4 -11
  168. package/src/services/order.ts +4 -4
  169. package/src/services/payment.test.ts +1 -1
  170. package/src/services/payment.ts +2 -2
  171. package/src/services/product-discount.test.ts +1 -1
  172. package/src/services/product-discount.ts +2 -2
  173. package/src/services/product-projection.test.ts +2 -2
  174. package/src/services/product-projection.ts +4 -4
  175. package/src/services/product-selection.test.ts +1 -1
  176. package/src/services/product-selection.ts +2 -2
  177. package/src/services/product-type.test.ts +1 -1
  178. package/src/services/product-type.ts +2 -2
  179. package/src/services/product.test.ts +1 -1
  180. package/src/services/product.ts +3 -3
  181. package/src/services/project.test.ts +1 -1
  182. package/src/services/project.ts +4 -4
  183. package/src/services/quote-request.test.ts +2 -2
  184. package/src/services/quote-request.ts +2 -2
  185. package/src/services/quote-staged.ts +2 -2
  186. package/src/services/quote.ts +2 -2
  187. package/src/services/recurrence-policy.test.ts +1 -1
  188. package/src/services/recurrence-policy.ts +2 -2
  189. package/src/services/recurring-order.test.ts +1 -1
  190. package/src/services/recurring-order.ts +2 -2
  191. package/src/services/reviews.test.ts +1 -1
  192. package/src/services/reviews.ts +2 -2
  193. package/src/services/shipping-method.test.ts +2 -2
  194. package/src/services/shipping-method.ts +4 -4
  195. package/src/services/shopping-list.test.ts +1 -1
  196. package/src/services/shopping-list.ts +2 -2
  197. package/src/services/standalone-price.test.ts +1 -1
  198. package/src/services/standalone-price.ts +2 -2
  199. package/src/services/state.test.ts +1 -1
  200. package/src/services/state.ts +2 -2
  201. package/src/services/store.test.ts +1 -1
  202. package/src/services/store.ts +2 -2
  203. package/src/services/subscription.test.ts +1 -1
  204. package/src/services/subscription.ts +2 -2
  205. package/src/services/tax-category.test.ts +1 -1
  206. package/src/services/tax-category.ts +2 -2
  207. package/src/services/type.test.ts +1 -1
  208. package/src/services/type.ts +2 -2
  209. package/src/services/zone.test.ts +1 -1
  210. package/src/services/zone.ts +2 -2
  211. package/src/shipping.test.ts +1 -1
  212. package/src/shipping.ts +8 -8
  213. package/src/storage/abstract.ts +1 -1
  214. package/src/storage/in-memory.ts +15 -17
  215. package/src/storage/index.ts +2 -2
  216. package/src/testing/business-unit.ts +1 -2
  217. package/src/testing/customer.ts +1 -1
  218. package/src/testing/type.ts +1 -1
  219. package/src/types.ts +1 -1
  220. package/src/validate.ts +1 -1
  221. package/dist/index.d.ts.map +0 -1
  222. package/dist/index.js.map +0 -1
@@ -3,13 +3,16 @@ import type {
3
3
  CustomObjectDraft,
4
4
  InvalidOperationError,
5
5
  } from "@commercetools/platform-sdk";
6
- import type { Config } from "~src/config";
7
- import { CommercetoolsError } from "~src/exceptions";
8
- import { cloneObject, getBaseResourceProperties } from "../helpers";
9
- import type { Writable } from "../types";
10
- import type { QueryParams } from "./abstract";
11
- import { AbstractResourceRepository, type RepositoryContext } from "./abstract";
12
- import { checkConcurrentModification } from "./errors";
6
+ import type { Config } from "#src/config.ts";
7
+ import { CommercetoolsError } from "#src/exceptions.ts";
8
+ import { cloneObject, getBaseResourceProperties } from "../helpers.ts";
9
+ import type { Writable } from "../types.ts";
10
+ import type { QueryParams } from "./abstract.ts";
11
+ import {
12
+ AbstractResourceRepository,
13
+ type RepositoryContext,
14
+ } from "./abstract.ts";
15
+ import { checkConcurrentModification } from "./errors.ts";
13
16
 
14
17
  export class CustomObjectRepository extends AbstractResourceRepository<"key-value-document"> {
15
18
  constructor(config: Config) {
@@ -88,7 +91,7 @@ export class CustomObjectRepository extends AbstractResourceRepository<"key-valu
88
91
  where: whereClause,
89
92
  });
90
93
 
91
- // @ts-ignore
94
+ // @ts-expect-error
92
95
  result.results = result.results.map((r) =>
93
96
  this.postProcessResource(context, r as CustomObject, {
94
97
  expand: params.expand,
@@ -17,10 +17,10 @@ import type {
17
17
  CustomerSetAddressCustomTypeAction,
18
18
  CustomerSetAuthenticationModeAction,
19
19
  CustomerSetCompanyNameAction,
20
- CustomerSetCustomFieldAction,
21
- CustomerSetCustomTypeAction,
22
20
  CustomerSetCustomerGroupAction,
23
21
  CustomerSetCustomerNumberAction,
22
+ CustomerSetCustomFieldAction,
23
+ CustomerSetCustomTypeAction,
24
24
  CustomerSetDateOfBirthAction,
25
25
  CustomerSetDefaultBillingAddressAction,
26
26
  CustomerSetDefaultShippingAddressAction,
@@ -39,13 +39,13 @@ import type {
39
39
  InvalidJsonInputError,
40
40
  InvalidOperationError,
41
41
  } from "@commercetools/platform-sdk";
42
- import { CommercetoolsError } from "~src/exceptions";
43
- import { generateRandomString } from "~src/helpers";
44
- import { hashPassword } from "~src/lib/password";
45
- import type { Writable } from "~src/types";
46
- import type { UpdateHandlerInterface } from "../abstract";
47
- import { AbstractUpdateHandler, type RepositoryContext } from "../abstract";
48
- import { createAddress, createCustomFields } from "../helpers";
42
+ import { CommercetoolsError } from "#src/exceptions.ts";
43
+ import { generateRandomString } from "#src/helpers.ts";
44
+ import { hashPassword } from "#src/lib/password.ts";
45
+ import type { Writable } from "#src/types.ts";
46
+ import type { UpdateHandlerInterface } from "../abstract.ts";
47
+ import { AbstractUpdateHandler, type RepositoryContext } from "../abstract.ts";
48
+ import { createAddress, createCustomFields } from "../helpers.ts";
49
49
 
50
50
  export class CustomerUpdateHandler
51
51
  extends AbstractUpdateHandler
@@ -1,8 +1,8 @@
1
1
  import type { Store } from "@commercetools/platform-sdk";
2
2
  import { describe, expect, test } from "vitest";
3
- import type { Config } from "~src/config";
4
- import { InMemoryStorage } from "~src/storage";
5
- import { CustomerRepository } from "./index";
3
+ import type { Config } from "#src/config.ts";
4
+ import { InMemoryStorage } from "#src/storage/index.ts";
5
+ import { CustomerRepository } from "./index.ts";
6
6
 
7
7
  describe("Customer repository", () => {
8
8
  const storage = new InMemoryStorage();
@@ -13,22 +13,25 @@ import type {
13
13
  StoreKeyReference,
14
14
  StoreResourceIdentifier,
15
15
  } from "@commercetools/platform-sdk";
16
- import type { Config } from "~src/config";
17
- import { CommercetoolsError } from "~src/exceptions";
18
- import { generateRandomString, getBaseResourceProperties } from "~src/helpers";
16
+ import type { Config } from "#src/config.ts";
17
+ import { CommercetoolsError } from "#src/exceptions.ts";
18
+ import {
19
+ generateRandomString,
20
+ getBaseResourceProperties,
21
+ } from "#src/helpers.ts";
19
22
  import {
20
23
  createEmailVerifyToken,
21
24
  createPasswordResetToken,
22
25
  hashPassword,
23
26
  validatePasswordResetToken,
24
- } from "~src/lib/password";
25
- import type { ResourceMap, ShallowWritable, Writable } from "~src/types";
27
+ } from "#src/lib/password.ts";
28
+ import type { ResourceMap, ShallowWritable, Writable } from "#src/types.ts";
26
29
  import {
27
30
  AbstractResourceRepository,
28
31
  type RepositoryContext,
29
- } from "../abstract";
30
- import { createCustomFields } from "../helpers";
31
- import { CustomerUpdateHandler } from "./actions";
32
+ } from "../abstract.ts";
33
+ import { createCustomFields } from "../helpers.ts";
34
+ import { CustomerUpdateHandler } from "./actions.ts";
32
35
 
33
36
  export class CustomerRepository extends AbstractResourceRepository<"customer"> {
34
37
  constructor(config: Config) {
@@ -176,7 +179,7 @@ export class CustomerRepository extends AbstractResourceRepository<"customer"> {
176
179
 
177
180
  const ttlMinutes = request.ttlMinutes ?? 34560; // 34560 is CT default
178
181
 
179
- const expiresAt = new Date(new Date().getTime() + ttlMinutes * 60 * 1000);
182
+ const expiresAt = new Date(Date.now() + ttlMinutes * 60 * 1000);
180
183
  const customer = results.results[0] as Customer;
181
184
  const rest = getBaseResourceProperties();
182
185
 
@@ -6,10 +6,10 @@ import type {
6
6
  CustomerGroupSetKeyAction,
7
7
  } from "@commercetools/platform-sdk";
8
8
  import { describe, expect, test } from "vitest";
9
- import type { Config } from "~src/config";
10
- import { getBaseResourceProperties } from "~src/helpers";
11
- import { InMemoryStorage } from "~src/storage";
12
- import { CustomerGroupRepository } from "./customer-group";
9
+ import type { Config } from "#src/config.ts";
10
+ import { getBaseResourceProperties } from "#src/helpers.ts";
11
+ import { InMemoryStorage } from "#src/storage/index.ts";
12
+ import { CustomerGroupRepository } from "./customer-group.ts";
13
13
 
14
14
  describe("CustomerGroup Repository", () => {
15
15
  const storage = new InMemoryStorage();
@@ -7,16 +7,16 @@ import type {
7
7
  CustomerGroupSetKeyAction,
8
8
  CustomerGroupUpdateAction,
9
9
  } from "@commercetools/platform-sdk";
10
- import type { Config } from "~src/config";
11
- import { getBaseResourceProperties } from "../helpers";
12
- import type { Writable } from "../types";
13
- import type { UpdateHandlerInterface } from "./abstract";
10
+ import type { Config } from "#src/config.ts";
11
+ import { getBaseResourceProperties } from "../helpers.ts";
12
+ import type { Writable } from "../types.ts";
13
+ import type { UpdateHandlerInterface } from "./abstract.ts";
14
14
  import {
15
15
  AbstractResourceRepository,
16
16
  AbstractUpdateHandler,
17
17
  type RepositoryContext,
18
- } from "./abstract";
19
- import { createCustomFields } from "./helpers";
18
+ } from "./abstract.ts";
19
+ import { createCustomFields } from "./helpers.ts";
20
20
 
21
21
  export class CustomerGroupRepository extends AbstractResourceRepository<"customer-group"> {
22
22
  constructor(config: Config) {
@@ -15,10 +15,10 @@ import type {
15
15
  DiscountCodeSetValidUntilAction,
16
16
  DiscountCodeUpdateAction,
17
17
  } from "@commercetools/platform-sdk";
18
- import type { Writable } from "~src/types";
19
- import type { UpdateHandlerInterface } from "../abstract";
20
- import { AbstractUpdateHandler, type RepositoryContext } from "../abstract";
21
- import { createCustomFields } from "../helpers";
18
+ import type { Writable } from "#src/types.ts";
19
+ import type { UpdateHandlerInterface } from "../abstract.ts";
20
+ import { AbstractUpdateHandler, type RepositoryContext } from "../abstract.ts";
21
+ import { createCustomFields } from "../helpers.ts";
22
22
 
23
23
  export class DiscountCodeUpdateHandler
24
24
  extends AbstractUpdateHandler
@@ -3,14 +3,14 @@ import type {
3
3
  DiscountCode,
4
4
  DiscountCodeDraft,
5
5
  } from "@commercetools/platform-sdk";
6
- import type { Config } from "~src/config";
7
- import { getBaseResourceProperties } from "~src/helpers";
6
+ import type { Config } from "#src/config.ts";
7
+ import { getBaseResourceProperties } from "#src/helpers.ts";
8
8
  import {
9
9
  AbstractResourceRepository,
10
10
  type RepositoryContext,
11
- } from "../abstract";
12
- import { createCustomFields } from "../helpers";
13
- import { DiscountCodeUpdateHandler } from "./actions";
11
+ } from "../abstract.ts";
12
+ import { createCustomFields } from "../helpers.ts";
13
+ import { DiscountCodeUpdateHandler } from "./actions.ts";
14
14
 
15
15
  export class DiscountCodeRepository extends AbstractResourceRepository<"discount-code"> {
16
16
  constructor(config: Config) {
@@ -6,10 +6,9 @@ import type {
6
6
  DiscountGroupSetSortOrderAction,
7
7
  DiscountGroupUpdateAction,
8
8
  } from "@commercetools/platform-sdk";
9
- import type { Writable } from "~src/types";
10
- import type { UpdateHandlerInterface } from "../abstract";
11
- import { AbstractUpdateHandler, type RepositoryContext } from "../abstract";
12
- import { createCustomFields } from "../helpers";
9
+ import type { Writable } from "#src/types.ts";
10
+ import type { UpdateHandlerInterface } from "../abstract.ts";
11
+ import { AbstractUpdateHandler, type RepositoryContext } from "../abstract.ts";
13
12
 
14
13
  export class DiscountGroupUpdateHandler
15
14
  extends AbstractUpdateHandler
@@ -2,13 +2,13 @@ import type {
2
2
  DiscountGroup,
3
3
  DiscountGroupDraft,
4
4
  } from "@commercetools/platform-sdk";
5
- import type { Config } from "~src/config";
6
- import { getBaseResourceProperties } from "~src/helpers";
5
+ import type { Config } from "#src/config.ts";
6
+ import { getBaseResourceProperties } from "#src/helpers.ts";
7
7
  import {
8
8
  AbstractResourceRepository,
9
9
  type RepositoryContext,
10
- } from "../abstract";
11
- import { DiscountGroupUpdateHandler } from "./actions";
10
+ } from "../abstract.ts";
11
+ import { DiscountGroupUpdateHandler } from "./actions.ts";
12
12
 
13
13
  export class DiscountGroupRepository extends AbstractResourceRepository<"discount-group"> {
14
14
  constructor(config: Config) {
@@ -1,5 +1,5 @@
1
1
  import type { ConcurrentModificationError } from "@commercetools/platform-sdk";
2
- import { CommercetoolsError } from "~src/exceptions";
2
+ import { CommercetoolsError } from "#src/exceptions.ts";
3
3
 
4
4
  export const checkConcurrentModification = (
5
5
  currentVersion: number,
@@ -7,9 +7,9 @@ import type {
7
7
  ExtensionSetTimeoutInMsAction,
8
8
  } from "@commercetools/platform-sdk";
9
9
  import { describe, expect, test } from "vitest";
10
- import type { Config } from "~src/config";
11
- import { InMemoryStorage } from "~src/storage";
12
- import { ExtensionRepository } from "./extension";
10
+ import type { Config } from "#src/config.ts";
11
+ import { InMemoryStorage } from "#src/storage/index.ts";
12
+ import { ExtensionRepository } from "./extension.ts";
13
13
 
14
14
  describe("Extension Repository", () => {
15
15
  const storage = new InMemoryStorage();
@@ -7,16 +7,16 @@ import type {
7
7
  ExtensionSetTimeoutInMsAction,
8
8
  ExtensionUpdateAction,
9
9
  } from "@commercetools/platform-sdk";
10
- import type { Config } from "~src/config";
11
- import { getBaseResourceProperties } from "../helpers";
12
- import { maskSecretValue } from "../lib/masking";
13
- import type { Writable } from "../types";
14
- import type { UpdateHandlerInterface } from "./abstract";
10
+ import type { Config } from "#src/config.ts";
11
+ import { getBaseResourceProperties } from "../helpers.ts";
12
+ import { maskSecretValue } from "../lib/masking.ts";
13
+ import type { Writable } from "../types.ts";
14
+ import type { UpdateHandlerInterface } from "./abstract.ts";
15
15
  import {
16
16
  AbstractResourceRepository,
17
17
  AbstractUpdateHandler,
18
18
  type RepositoryContext,
19
- } from "./abstract";
19
+ } from "./abstract.ts";
20
20
 
21
21
  export class ExtensionRepository extends AbstractResourceRepository<"extension"> {
22
22
  constructor(config: Config) {
@@ -1,19 +1,17 @@
1
1
  import type {
2
- AssociateRoleReference,
3
- BusinessUnitKeyReference,
4
- BusinessUnitReference,
5
- BusinessUnitResourceIdentifier,
6
- RoundingMode,
7
- } from "@commercetools/platform-sdk";
8
- import type {
2
+ _Money,
9
3
  Address,
10
4
  Associate,
11
5
  AssociateDraft,
12
6
  AssociateRoleAssignment,
13
7
  AssociateRoleAssignmentDraft,
14
8
  AssociateRoleKeyReference,
9
+ AssociateRoleReference,
15
10
  AssociateRoleResourceIdentifier,
16
11
  BaseAddress,
12
+ BusinessUnitKeyReference,
13
+ BusinessUnitReference,
14
+ BusinessUnitResourceIdentifier,
17
15
  CentPrecisionMoney,
18
16
  CustomFields,
19
17
  CustomFieldsDraft,
@@ -25,19 +23,19 @@ import type {
25
23
  Reference,
26
24
  ReferencedResourceNotFoundError,
27
25
  ResourceIdentifier,
26
+ RoundingMode,
28
27
  Store,
29
28
  StoreKeyReference,
30
29
  StoreReference,
31
30
  StoreResourceIdentifier,
32
31
  Type,
33
- _Money,
34
32
  } from "@commercetools/platform-sdk";
35
33
  import { Decimal } from "decimal.js/decimal";
36
34
  import type { Request } from "express";
37
35
  import { v4 as uuidv4 } from "uuid";
38
- import { CommercetoolsError } from "~src/exceptions";
39
- import type { AbstractStorage } from "../storage";
40
- import type { RepositoryContext } from "./abstract";
36
+ import { CommercetoolsError } from "#src/exceptions.ts";
37
+ import type { AbstractStorage } from "../storage/index.ts";
38
+ import type { RepositoryContext } from "./abstract.ts";
41
39
 
42
40
  export const createAddress = (
43
41
  base: BaseAddress | undefined,
@@ -206,7 +204,6 @@ export const getReferenceFromResourceIdentifier = <T extends Reference>(
206
204
  throw new CommercetoolsError<ReferencedResourceNotFoundError>(
207
205
  {
208
206
  code: "ReferencedResourceNotFound",
209
- // @ts-ignore
210
207
  typeId: resourceIdentifier.typeId,
211
208
  message: `The referenced object of type '${resourceIdentifier.typeId}' with '${errIdentifier}' was not found. It either doesn't exist, or it can't be accessed from this endpoint (e.g., if the endpoint filters by store or customer account).`,
212
209
  },
@@ -1,7 +1,7 @@
1
1
  import { describe, expect, test } from "vitest";
2
- import type { Config } from "~src/config";
3
- import { InMemoryStorage } from "~src/storage";
4
- import { createRepositories } from "./index";
2
+ import type { Config } from "#src/config.ts";
3
+ import { InMemoryStorage } from "#src/storage/index.ts";
4
+ import { createRepositories } from "./index.ts";
5
5
 
6
6
  describe("Repository Index", () => {
7
7
  const storage = new InMemoryStorage();
@@ -1,50 +1,50 @@
1
- import type { Config } from "~src/config";
2
- import { ProductTailoringRepository } from "~src/repositories/product-tailoring";
1
+ import type { Config } from "#src/config.ts";
2
+ import { ProductTailoringRepository } from "#src/repositories/product-tailoring.ts";
3
3
  import {
4
4
  AsAssociateCartRepository,
5
5
  AsAssociateOrderRepository,
6
6
  AsAssociateQuoteRequestRepository,
7
- } from "./as-associate";
8
- import { AssociateRoleRepository } from "./associate-role";
9
- import { AttributeGroupRepository } from "./attribute-group";
10
- import { BusinessUnitRepository } from "./business-unit";
11
- import { CartRepository } from "./cart";
12
- import { CartDiscountRepository } from "./cart-discount";
13
- import { CategoryRepository } from "./category";
14
- import { ChannelRepository } from "./channel";
15
- import { CustomObjectRepository } from "./custom-object";
16
- import { CustomerRepository } from "./customer";
17
- import { CustomerGroupRepository } from "./customer-group";
18
- import { DiscountCodeRepository } from "./discount-code";
19
- import { DiscountGroupRepository } from "./discount-group";
20
- import { ExtensionRepository } from "./extension";
21
- import { InventoryEntryRepository } from "./inventory-entry";
22
- import { MyCustomerRepository } from "./my-customer";
23
- import { MyOrderRepository } from "./my-order";
24
- import { OrderRepository } from "./order";
25
- import { OrderEditRepository } from "./order-edit";
26
- import { PaymentRepository } from "./payment";
27
- import { ProductRepository } from "./product";
28
- import { ProductDiscountRepository } from "./product-discount";
29
- import { ProductProjectionRepository } from "./product-projection";
30
- import { ProductSelectionRepository } from "./product-selection";
31
- import { ProductTypeRepository } from "./product-type";
32
- import { ProjectRepository } from "./project";
33
- import { QuoteRepository } from "./quote";
34
- import { QuoteRequestRepository } from "./quote-request";
35
- import { StagedQuoteRepository } from "./quote-staged";
36
- import { RecurrencePolicyRepository } from "./recurrence-policy";
37
- import { RecurringOrderRepository } from "./recurring-order";
38
- import { ReviewRepository } from "./review";
39
- import { ShippingMethodRepository } from "./shipping-method";
40
- import { ShoppingListRepository } from "./shopping-list";
41
- import { StandAlonePriceRepository } from "./standalone-price";
42
- import { StateRepository } from "./state";
43
- import { StoreRepository } from "./store";
44
- import { SubscriptionRepository } from "./subscription";
45
- import { TaxCategoryRepository } from "./tax-category";
46
- import { TypeRepository } from "./type";
47
- import { ZoneRepository } from "./zone";
7
+ } from "./as-associate.ts";
8
+ import { AssociateRoleRepository } from "./associate-role.ts";
9
+ import { AttributeGroupRepository } from "./attribute-group.ts";
10
+ import { BusinessUnitRepository } from "./business-unit.ts";
11
+ import { CartRepository } from "./cart/index.ts";
12
+ import { CartDiscountRepository } from "./cart-discount/index.ts";
13
+ import { CategoryRepository } from "./category/index.ts";
14
+ import { ChannelRepository } from "./channel.ts";
15
+ import { CustomObjectRepository } from "./custom-object.ts";
16
+ import { CustomerRepository } from "./customer/index.ts";
17
+ import { CustomerGroupRepository } from "./customer-group.ts";
18
+ import { DiscountCodeRepository } from "./discount-code/index.ts";
19
+ import { DiscountGroupRepository } from "./discount-group/index.ts";
20
+ import { ExtensionRepository } from "./extension.ts";
21
+ import { InventoryEntryRepository } from "./inventory-entry/index.ts";
22
+ import { MyCustomerRepository } from "./my-customer.ts";
23
+ import { MyOrderRepository } from "./my-order.ts";
24
+ import { OrderRepository } from "./order/index.ts";
25
+ import { OrderEditRepository } from "./order-edit.ts";
26
+ import { PaymentRepository } from "./payment/index.ts";
27
+ import { ProductRepository } from "./product/index.ts";
28
+ import { ProductDiscountRepository } from "./product-discount.ts";
29
+ import { ProductProjectionRepository } from "./product-projection.ts";
30
+ import { ProductSelectionRepository } from "./product-selection.ts";
31
+ import { ProductTypeRepository } from "./product-type.ts";
32
+ import { ProjectRepository } from "./project.ts";
33
+ import { QuoteRepository } from "./quote/index.ts";
34
+ import { QuoteRequestRepository } from "./quote-request/index.ts";
35
+ import { StagedQuoteRepository } from "./quote-staged/index.ts";
36
+ import { RecurrencePolicyRepository } from "./recurrence-policy/index.ts";
37
+ import { RecurringOrderRepository } from "./recurring-order/index.ts";
38
+ import { ReviewRepository } from "./review.ts";
39
+ import { ShippingMethodRepository } from "./shipping-method/index.ts";
40
+ import { ShoppingListRepository } from "./shopping-list/index.ts";
41
+ import { StandAlonePriceRepository } from "./standalone-price.ts";
42
+ import { StateRepository } from "./state.ts";
43
+ import { StoreRepository } from "./store.ts";
44
+ import { SubscriptionRepository } from "./subscription.ts";
45
+ import { TaxCategoryRepository } from "./tax-category/index.ts";
46
+ import { TypeRepository } from "./type/index.ts";
47
+ import { ZoneRepository } from "./zone.ts";
48
48
 
49
49
  export type RepositoryMap = ReturnType<typeof createRepositories>;
50
50
 
@@ -1,15 +1,16 @@
1
1
  import type {
2
2
  InventoryEntry,
3
3
  InventoryEntryChangeQuantityAction,
4
+ InventoryEntryRemoveQuantityAction,
4
5
  InventoryEntrySetCustomFieldAction,
5
6
  InventoryEntrySetCustomTypeAction,
6
7
  InventoryEntrySetExpectedDeliveryAction,
7
8
  InventoryEntrySetRestockableInDaysAction,
8
9
  InventoryEntryUpdateAction,
9
10
  } from "@commercetools/platform-sdk";
10
- import type { Writable } from "~src/types";
11
- import type { UpdateHandlerInterface } from "../abstract";
12
- import { AbstractUpdateHandler, type RepositoryContext } from "../abstract";
11
+ import type { Writable } from "#src/types.ts";
12
+ import type { UpdateHandlerInterface } from "../abstract.ts";
13
+ import { AbstractUpdateHandler, type RepositoryContext } from "../abstract.ts";
13
14
 
14
15
  export class InventoryEntryUpdateHandler
15
16
  extends AbstractUpdateHandler
@@ -26,6 +27,17 @@ export class InventoryEntryUpdateHandler
26
27
  resource.availableQuantity = quantity;
27
28
  }
28
29
 
30
+ removeQuantity(
31
+ context: RepositoryContext,
32
+ resource: Writable<InventoryEntry>,
33
+ { quantity }: InventoryEntryRemoveQuantityAction,
34
+ ) {
35
+ const newQuantity = Math.max(0, resource.quantityOnStock - quantity);
36
+ resource.quantityOnStock = newQuantity;
37
+ // don't know active reservations so just set to same value
38
+ resource.availableQuantity = newQuantity;
39
+ }
40
+
29
41
  setCustomField(
30
42
  context: RepositoryContext,
31
43
  resource: InventoryEntry,
@@ -2,14 +2,14 @@ import type {
2
2
  InventoryEntry,
3
3
  InventoryEntryDraft,
4
4
  } from "@commercetools/platform-sdk";
5
- import type { Config } from "~src/config";
6
- import { getBaseResourceProperties } from "~src/helpers";
5
+ import type { Config } from "#src/config.ts";
6
+ import { getBaseResourceProperties } from "#src/helpers.ts";
7
7
  import {
8
8
  AbstractResourceRepository,
9
9
  type RepositoryContext,
10
- } from "../abstract";
11
- import { createCustomFields } from "../helpers";
12
- import { InventoryEntryUpdateHandler } from "./actions";
10
+ } from "../abstract.ts";
11
+ import { createCustomFields } from "../helpers.ts";
12
+ import { InventoryEntryUpdateHandler } from "./actions.ts";
13
13
 
14
14
  export class InventoryEntryRepository extends AbstractResourceRepository<"inventory-entry"> {
15
15
  constructor(config: Config) {
@@ -5,11 +5,11 @@ import type {
5
5
  MyCustomerEmailVerify,
6
6
  ResourceNotFoundError,
7
7
  } from "@commercetools/platform-sdk";
8
- import { CommercetoolsError } from "~src/exceptions";
9
- import { hashPassword, validateEmailVerifyToken } from "../lib/password";
10
- import type { Writable } from "../types";
11
- import type { RepositoryContext } from "./abstract";
12
- import { CustomerRepository } from "./customer";
8
+ import { CommercetoolsError } from "#src/exceptions.ts";
9
+ import { hashPassword, validateEmailVerifyToken } from "../lib/password.ts";
10
+ import type { Writable } from "../types.ts";
11
+ import type { RepositoryContext } from "./abstract.ts";
12
+ import { CustomerRepository } from "./customer/index.ts";
13
13
 
14
14
  export class MyCustomerRepository extends CustomerRepository {
15
15
  changePassword(
@@ -4,8 +4,8 @@ import type {
4
4
  MyOrderFromCartDraft,
5
5
  Order,
6
6
  } from "@commercetools/platform-sdk";
7
- import type { RepositoryContext } from "./abstract";
8
- import { OrderRepository } from "./order";
7
+ import type { RepositoryContext } from "./abstract.ts";
8
+ import { OrderRepository } from "./order/index.ts";
9
9
 
10
10
  export class MyOrderRepository extends OrderRepository {
11
11
  create(context: RepositoryContext, draft: MyOrderFromCartDraft): Order {
@@ -1,3 +1,3 @@
1
- import { QuoteRequestRepository } from "./quote-request";
1
+ import { QuoteRequestRepository } from "./quote-request/index.ts";
2
2
 
3
3
  export class MyQuoteRequestRepository extends QuoteRequestRepository {}
@@ -9,11 +9,10 @@ import type {
9
9
  OrderChangePaymentStateAction,
10
10
  OrderChangeShipmentStateAction,
11
11
  OrderSetBillingAddressAction,
12
- OrderSetCustomFieldAction,
13
- OrderSetCustomLineItemCustomTypeAction,
14
- OrderSetCustomTypeAction,
15
12
  OrderSetCustomerEmailAction,
16
13
  OrderSetCustomerIdAction,
14
+ OrderSetCustomFieldAction,
15
+ OrderSetCustomTypeAction,
17
16
  OrderSetDeliveryCustomFieldAction,
18
17
  OrderSetLineItemCustomFieldAction,
19
18
  OrderSetLineItemCustomTypeAction,
@@ -31,12 +30,12 @@ import type {
31
30
  Store,
32
31
  SyncInfo,
33
32
  } from "@commercetools/platform-sdk";
34
- import { CommercetoolsError } from "~src/exceptions";
35
- import { getBaseResourceProperties } from "~src/helpers";
36
- import type { Writable } from "~src/types";
37
- import type { RepositoryContext, UpdateHandlerInterface } from "../abstract";
38
- import { AbstractUpdateHandler } from "../abstract";
39
- import { createAddress } from "../helpers";
33
+ import { CommercetoolsError } from "#src/exceptions.ts";
34
+ import { getBaseResourceProperties } from "#src/helpers.ts";
35
+ import type { Writable } from "#src/types.ts";
36
+ import type { RepositoryContext, UpdateHandlerInterface } from "../abstract.ts";
37
+ import { AbstractUpdateHandler } from "../abstract.ts";
38
+ import { createAddress } from "../helpers.ts";
40
39
 
41
40
  export class OrderUpdateHandler
42
41
  extends AbstractUpdateHandler
@@ -6,10 +6,10 @@ import type {
6
6
  OrderImportDraft,
7
7
  } from "@commercetools/platform-sdk";
8
8
  import { describe, expect, test } from "vitest";
9
- import type { Config } from "~src/config";
10
- import { getBaseResourceProperties } from "~src/helpers";
11
- import { InMemoryStorage } from "~src/storage";
12
- import { OrderRepository } from "./index";
9
+ import type { Config } from "#src/config.ts";
10
+ import { getBaseResourceProperties } from "#src/helpers.ts";
11
+ import { InMemoryStorage } from "#src/storage/index.ts";
12
+ import { OrderRepository } from "./index.ts";
13
13
 
14
14
  describe("Order repository", () => {
15
15
  const storage = new InMemoryStorage();
@@ -460,9 +460,8 @@ describe("Order repository", () => {
460
460
  test("import exiting product", async () => {
461
461
  storage.add("dummy", "product", {
462
462
  id: "15fc56ba-a74e-4cf8-b4b0-bada5c101541",
463
- // @ts-ignore
464
463
  masterData: {
465
- // @ts-ignore
464
+ // @ts-expect-error
466
465
  current: {
467
466
  name: { "nl-NL": "Dummy" },
468
467
  slug: { "nl-NL": "Dummy" },
@@ -585,7 +584,7 @@ describe("Order repository", () => {
585
584
  productType: {
586
585
  typeId: 'product-type',
587
586
  id: '109caecb-abe6-4900-ab03-7af5af985ff3',
588
- // @ts-ignore
587
+ // @ts-expect-error
589
588
  version: 1,
590
589
  },
591
590
  variant: {
@@ -595,7 +594,7 @@ describe("Order repository", () => {
595
594
  prices: [
596
595
  {
597
596
  value: {
598
- // @ts-ignore
597
+ // @ts-expect-error
599
598
  type: 'centPrecision',
600
599
  currencyCode: 'EUR',
601
600
  centAmount: 14900,
@@ -622,7 +621,7 @@ describe("Order repository", () => {
622
621
  },
623
622
  price: {
624
623
  value: {
625
- // @ts-ignore
624
+ // @ts-expect-error
626
625
  type: 'centPrecision',
627
626
  currencyCode: 'EUR',
628
627
  centAmount: 14900,