@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
@@ -1,6 +1,6 @@
1
1
  import type { Router } from "express";
2
- import type { CartDiscountRepository } from "../repositories/cart-discount";
3
- import AbstractService from "./abstract";
2
+ import type { CartDiscountRepository } from "../repositories/cart-discount/index.ts";
3
+ import AbstractService from "./abstract.ts";
4
4
 
5
5
  export class CartDiscountService extends AbstractService {
6
6
  public repository: CartDiscountRepository;
@@ -13,8 +13,8 @@ import type {
13
13
  } from "@commercetools/platform-sdk";
14
14
  import supertest from "supertest";
15
15
  import { afterEach, beforeEach, describe, expect, test } from "vitest";
16
- import { customerDraftFactory } from "~src/testing/customer";
17
- import { CommercetoolsMock } from "../index";
16
+ import { customerDraftFactory } from "#src/testing/customer.ts";
17
+ import { CommercetoolsMock } from "../index.ts";
18
18
 
19
19
  describe("Carts Query", () => {
20
20
  const ctMock = new CommercetoolsMock();
@@ -644,7 +644,10 @@ describe("Cart Update Actions", () => {
644
644
  });
645
645
  expect(response.status).toBe(200);
646
646
  expect(response.body.version).toBe(2);
647
- expect(response.body.billingAddress).toEqual(address);
647
+ expect(response.body.billingAddress).toEqual({
648
+ ...address,
649
+ id: expect.any(String),
650
+ });
648
651
  });
649
652
 
650
653
  test("setCountry", async () => {
@@ -1187,6 +1190,7 @@ describe("Cart Update Actions", () => {
1187
1190
  expect(response.body.version).toBe(3);
1188
1191
  expect(response.body.billingAddress).toEqual({
1189
1192
  ...address,
1193
+ id: expect.any(String),
1190
1194
  custom: {
1191
1195
  type: { typeId: "type", id: type.id },
1192
1196
  fields: { foo: "bar" },
@@ -1,9 +1,9 @@
1
1
  import type { Cart, CartDraft, Order } from "@commercetools/platform-sdk";
2
2
  import type { Request, Response, Router } from "express";
3
- import type { CartRepository } from "../repositories/cart";
4
- import { getRepositoryContext } from "../repositories/helpers";
5
- import type { OrderRepository } from "../repositories/order";
6
- import AbstractService from "./abstract";
3
+ import type { CartRepository } from "../repositories/cart/index.ts";
4
+ import { getRepositoryContext } from "../repositories/helpers.ts";
5
+ import type { OrderRepository } from "../repositories/order/index.ts";
6
+ import AbstractService from "./abstract.ts";
7
7
 
8
8
  export class CartService extends AbstractService {
9
9
  public repository: CartRepository;
@@ -31,7 +31,6 @@ export class CartService extends AbstractService {
31
31
  replicate(request: Request, response: Response) {
32
32
  const context = getRepositoryContext(request);
33
33
 
34
- // @ts-ignore
35
34
  const cartOrOrder: Cart | Order | null =
36
35
  request.body.reference.typeId === "order"
37
36
  ? this.orderRepository.get(context, request.body.reference.id)
@@ -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("Categories Query", () => {
12
12
  const ctMock = new CommercetoolsMock();
@@ -1,6 +1,6 @@
1
1
  import type { Router } from "express";
2
- import type { CategoryRepository } from "../repositories/category/index";
3
- import AbstractService from "./abstract";
2
+ import type { CategoryRepository } from "../repositories/category/index.ts";
3
+ import AbstractService from "./abstract.ts";
4
4
 
5
5
  export class CategoryServices extends AbstractService {
6
6
  public repository: CategoryRepository;
@@ -1,7 +1,7 @@
1
1
  import type { ChannelDraft } from "@commercetools/platform-sdk";
2
2
  import supertest from "supertest";
3
3
  import { describe, expect, test } from "vitest";
4
- import { CommercetoolsMock } from "../index";
4
+ import { CommercetoolsMock } from "../index.ts";
5
5
 
6
6
  const ctMock = new CommercetoolsMock();
7
7
 
@@ -1,6 +1,6 @@
1
1
  import type { Router } from "express";
2
- import type { ChannelRepository } from "../repositories/channel";
3
- import AbstractService from "./abstract";
2
+ import type { ChannelRepository } from "../repositories/channel.ts";
3
+ import AbstractService from "./abstract.ts";
4
4
 
5
5
  export class ChannelService extends AbstractService {
6
6
  public repository: ChannelRepository;
@@ -1,8 +1,8 @@
1
1
  import type { CustomObject } from "@commercetools/platform-sdk";
2
2
  import supertest from "supertest";
3
3
  import { afterEach, beforeEach, describe, expect, test } from "vitest";
4
- import { getBaseResourceProperties } from "../helpers";
5
- import { CommercetoolsMock } from "../index";
4
+ import { getBaseResourceProperties } from "../helpers.ts";
5
+ import { CommercetoolsMock } from "../index.ts";
6
6
 
7
7
  describe("CustomObject create", () => {
8
8
  const ctMock = new CommercetoolsMock();
@@ -1,8 +1,8 @@
1
1
  import type { CustomObjectDraft } from "@commercetools/platform-sdk";
2
2
  import type { Request, Response, Router } from "express";
3
- import type { CustomObjectRepository } from "../repositories/custom-object";
4
- import { getRepositoryContext } from "../repositories/helpers";
5
- import AbstractService from "./abstract";
3
+ import type { CustomObjectRepository } from "../repositories/custom-object.ts";
4
+ import { getRepositoryContext } from "../repositories/helpers.ts";
5
+ import AbstractService from "./abstract.ts";
6
6
 
7
7
  export class CustomObjectService extends AbstractService {
8
8
  public repository: CustomObjectRepository;
@@ -1,7 +1,7 @@
1
1
  import type { CustomerGroupDraft } from "@commercetools/platform-sdk";
2
2
  import supertest from "supertest";
3
3
  import { describe, expect, test } from "vitest";
4
- import { CommercetoolsMock } from "../index";
4
+ import { CommercetoolsMock } from "../index.ts";
5
5
 
6
6
  const ctMock = new CommercetoolsMock();
7
7
 
@@ -1,6 +1,6 @@
1
1
  import type { Router } from "express";
2
- import type { CustomerGroupRepository } from "../repositories/customer-group";
3
- import AbstractService from "./abstract";
2
+ import type { CustomerGroupRepository } from "../repositories/customer-group.ts";
3
+ import AbstractService from "./abstract.ts";
4
4
 
5
5
  export class CustomerGroupService extends AbstractService {
6
6
  public repository: CustomerGroupRepository;
@@ -6,9 +6,9 @@ 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 { hashPassword } from "~src/lib/password";
10
- import { customerDraftFactory } from "~src/testing/customer";
11
- import { CommercetoolsMock, getBaseResourceProperties } from "../index";
9
+ import { hashPassword } from "#src/lib/password.ts";
10
+ import { customerDraftFactory } from "#src/testing/customer.ts";
11
+ import { CommercetoolsMock, getBaseResourceProperties } from "../index.ts";
12
12
 
13
13
  const ctMock = new CommercetoolsMock();
14
14
 
@@ -1,9 +1,8 @@
1
1
  import type { CustomerSignInResult } from "@commercetools/platform-sdk";
2
- import type { Router } from "express";
3
- import type { Request, Response } from "express";
4
- import type { CustomerRepository } from "../repositories/customer";
5
- import { getRepositoryContext } from "../repositories/helpers";
6
- import AbstractService from "./abstract";
2
+ import type { Request, Response, Router } from "express";
3
+ import type { CustomerRepository } from "../repositories/customer/index.ts";
4
+ import { getRepositoryContext } from "../repositories/helpers.ts";
5
+ import AbstractService from "./abstract.ts";
7
6
 
8
7
  export class CustomerService extends AbstractService {
9
8
  public repository: CustomerRepository;
@@ -1,7 +1,7 @@
1
1
  import type { DiscountCodeDraft } from "@commercetools/platform-sdk";
2
2
  import supertest from "supertest";
3
3
  import { describe, expect, test } from "vitest";
4
- import { CommercetoolsMock } from "../index";
4
+ import { CommercetoolsMock } from "../index.ts";
5
5
 
6
6
  const ctMock = new CommercetoolsMock();
7
7
 
@@ -1,6 +1,6 @@
1
1
  import type { Router } from "express";
2
- import type { DiscountCodeRepository } from "../repositories/discount-code/index";
3
- import AbstractService from "./abstract";
2
+ import type { DiscountCodeRepository } from "../repositories/discount-code/index.ts";
3
+ import AbstractService from "./abstract.ts";
4
4
 
5
5
  export class DiscountCodeService extends AbstractService {
6
6
  public repository: DiscountCodeRepository;
@@ -1,7 +1,7 @@
1
1
  import type { DiscountGroupDraft } from "@commercetools/platform-sdk";
2
2
  import supertest from "supertest";
3
3
  import { describe, expect, test } from "vitest";
4
- import { CommercetoolsMock } from "../index";
4
+ import { CommercetoolsMock } from "../index.ts";
5
5
 
6
6
  const ctMock = new CommercetoolsMock();
7
7
 
@@ -1,6 +1,6 @@
1
1
  import type { Router } from "express";
2
- import type { DiscountGroupRepository } from "../repositories/discount-group/index";
3
- import AbstractService from "./abstract";
2
+ import type { DiscountGroupRepository } from "../repositories/discount-group/index.ts";
3
+ import AbstractService from "./abstract.ts";
4
4
 
5
5
  export class DiscountGroupService extends AbstractService {
6
6
  public repository: DiscountGroupRepository;
@@ -1,7 +1,7 @@
1
1
  import type { ExtensionDraft } from "@commercetools/platform-sdk";
2
2
  import supertest from "supertest";
3
3
  import { describe, expect, test } from "vitest";
4
- import { CommercetoolsMock } from "../index";
4
+ import { CommercetoolsMock } from "../index.ts";
5
5
 
6
6
  const ctMock = new CommercetoolsMock();
7
7
 
@@ -1,6 +1,6 @@
1
1
  import type { Router } from "express";
2
- import type { ExtensionRepository } from "../repositories/extension";
3
- import AbstractService from "./abstract";
2
+ import type { ExtensionRepository } from "../repositories/extension.ts";
3
+ import AbstractService from "./abstract.ts";
4
4
 
5
5
  export class ExtensionServices extends AbstractService {
6
6
  public repository: ExtensionRepository;
@@ -1,47 +1,47 @@
1
- import type { createRepositories } from "../repositories";
2
- import { AsAssociateService } from "./as-associate";
3
- import { AssociateRoleServices } from "./associate-roles";
4
- import { AttributeGroupService } from "./attribute-group";
5
- import { BusinessUnitServices } from "./business-units";
6
- import { CartService } from "./cart";
7
- import { CartDiscountService } from "./cart-discount";
8
- import { CategoryServices } from "./category";
9
- import { ChannelService } from "./channel";
10
- import { CustomObjectService } from "./custom-object";
11
- import { CustomerService } from "./customer";
12
- import { CustomerGroupService } from "./customer-group";
13
- import { DiscountCodeService } from "./discount-code";
14
- import { DiscountGroupService } from "./discount-group";
15
- import { ExtensionServices } from "./extension";
16
- import { InventoryEntryService } from "./inventory-entry";
17
- import { MyBusinessUnitService } from "./my-business-unit";
18
- import { MyCartService } from "./my-cart";
19
- import { MyCustomerService } from "./my-customer";
20
- import { MyOrderService } from "./my-order";
21
- import { MyPaymentService } from "./my-payment";
22
- import { MyShoppingListService } from "./my-shopping-list";
23
- import { OrderService } from "./order";
24
- import { PaymentService } from "./payment";
25
- import { ProductService } from "./product";
26
- import { ProductDiscountService } from "./product-discount";
27
- import { ProductProjectionService } from "./product-projection";
28
- import { ProductSelectionService } from "./product-selection";
29
- import { ProductTypeService } from "./product-type";
30
- import { QuoteService } from "./quote";
31
- import { QuoteRequestService } from "./quote-request";
32
- import { StagedQuoteService } from "./quote-staged";
33
- import { RecurrencePolicyService } from "./recurrence-policy";
34
- import { RecurringOrderService } from "./recurring-order";
35
- import { ReviewService } from "./reviews";
36
- import { ShippingMethodService } from "./shipping-method";
37
- import { ShoppingListService } from "./shopping-list";
38
- import { StandAlonePriceService } from "./standalone-price";
39
- import { StateService } from "./state";
40
- import { StoreService } from "./store";
41
- import { SubscriptionService } from "./subscription";
42
- import { TaxCategoryService } from "./tax-category";
43
- import { TypeService } from "./type";
44
- import { ZoneService } from "./zone";
1
+ import type { createRepositories } from "../repositories/index.ts";
2
+ import { AsAssociateService } from "./as-associate.ts";
3
+ import { AssociateRoleServices } from "./associate-roles.ts";
4
+ import { AttributeGroupService } from "./attribute-group.ts";
5
+ import { BusinessUnitServices } from "./business-units.ts";
6
+ import { CartService } from "./cart.ts";
7
+ import { CartDiscountService } from "./cart-discount.ts";
8
+ import { CategoryServices } from "./category.ts";
9
+ import { ChannelService } from "./channel.ts";
10
+ import { CustomObjectService } from "./custom-object.ts";
11
+ import { CustomerService } from "./customer.ts";
12
+ import { CustomerGroupService } from "./customer-group.ts";
13
+ import { DiscountCodeService } from "./discount-code.ts";
14
+ import { DiscountGroupService } from "./discount-group.ts";
15
+ import { ExtensionServices } from "./extension.ts";
16
+ import { InventoryEntryService } from "./inventory-entry.ts";
17
+ import { MyBusinessUnitService } from "./my-business-unit.ts";
18
+ import { MyCartService } from "./my-cart.ts";
19
+ import { MyCustomerService } from "./my-customer.ts";
20
+ import { MyOrderService } from "./my-order.ts";
21
+ import { MyPaymentService } from "./my-payment.ts";
22
+ import { MyShoppingListService } from "./my-shopping-list.ts";
23
+ import { OrderService } from "./order.ts";
24
+ import { PaymentService } from "./payment.ts";
25
+ import { ProductService } from "./product.ts";
26
+ import { ProductDiscountService } from "./product-discount.ts";
27
+ import { ProductProjectionService } from "./product-projection.ts";
28
+ import { ProductSelectionService } from "./product-selection.ts";
29
+ import { ProductTypeService } from "./product-type.ts";
30
+ import { QuoteService } from "./quote.ts";
31
+ import { QuoteRequestService } from "./quote-request.ts";
32
+ import { StagedQuoteService } from "./quote-staged.ts";
33
+ import { RecurrencePolicyService } from "./recurrence-policy.ts";
34
+ import { RecurringOrderService } from "./recurring-order.ts";
35
+ import { ReviewService } from "./reviews.ts";
36
+ import { ShippingMethodService } from "./shipping-method.ts";
37
+ import { ShoppingListService } from "./shopping-list.ts";
38
+ import { StandAlonePriceService } from "./standalone-price.ts";
39
+ import { StateService } from "./state.ts";
40
+ import { StoreService } from "./store.ts";
41
+ import { SubscriptionService } from "./subscription.ts";
42
+ import { TaxCategoryService } from "./tax-category.ts";
43
+ import { TypeService } from "./type.ts";
44
+ import { ZoneService } from "./zone.ts";
45
45
 
46
46
  export const createServices = (
47
47
  router: any,
@@ -2,7 +2,7 @@ import assert from "node:assert";
2
2
  import type { InventoryEntry, Type } from "@commercetools/platform-sdk";
3
3
  import supertest from "supertest";
4
4
  import { afterEach, beforeEach, describe, expect, test } from "vitest";
5
- import { CommercetoolsMock } from "../index";
5
+ import { CommercetoolsMock } from "../index.ts";
6
6
 
7
7
  describe("Inventory Entry Query", () => {
8
8
  const ctMock = new CommercetoolsMock();
@@ -93,6 +93,21 @@ describe("Inventory Entry Update Actions", () => {
93
93
  expect(response.body.quantityOnStock).toBe(300);
94
94
  });
95
95
 
96
+ test("removeQuantity", async () => {
97
+ assert(inventoryEntry, "inventory entry not created");
98
+
99
+ const response = await supertest(ctMock.app)
100
+ .post(`/dummy/inventory/${inventoryEntry.id}`)
101
+ .send({
102
+ version: 1,
103
+ actions: [{ action: "removeQuantity", quantity: 15 }],
104
+ });
105
+ expect(response.status).toBe(200);
106
+ expect(response.body.version).toBe(2);
107
+ expect(response.body.availableQuantity).toBe(85);
108
+ expect(response.body.quantityOnStock).toBe(85);
109
+ });
110
+
96
111
  test("set custom type", async () => {
97
112
  assert(inventoryEntry, "inventory entry not created");
98
113
  assert(customType, "custom type not created");
@@ -1,6 +1,6 @@
1
1
  import type { Router } from "express";
2
- import type { InventoryEntryRepository } from "../repositories/inventory-entry";
3
- import AbstractService from "./abstract";
2
+ import type { InventoryEntryRepository } from "../repositories/inventory-entry/index.ts";
3
+ import AbstractService from "./abstract.ts";
4
4
 
5
5
  export class InventoryEntryService extends AbstractService {
6
6
  public repository: InventoryEntryRepository;
@@ -1,7 +1,7 @@
1
1
  import type { BusinessUnitDraft } from "@commercetools/platform-sdk";
2
2
  import supertest from "supertest";
3
3
  import { afterEach, describe, expect, test } from "vitest";
4
- import { CommercetoolsMock } from "../index";
4
+ import { CommercetoolsMock } from "../index.ts";
5
5
 
6
6
  const ctMock = new CommercetoolsMock();
7
7
 
@@ -1,6 +1,6 @@
1
1
  import { Router } from "express";
2
- import type { BusinessUnitRepository } from "~src/repositories/business-unit";
3
- import AbstractService from "./abstract";
2
+ import type { BusinessUnitRepository } from "#src/repositories/business-unit.ts";
3
+ import AbstractService from "./abstract.ts";
4
4
 
5
5
  export class MyBusinessUnitService extends AbstractService {
6
6
  public repository: BusinessUnitRepository;
@@ -1,7 +1,7 @@
1
1
  import type { Cart, MyCartDraft } from "@commercetools/platform-sdk";
2
2
  import supertest from "supertest";
3
3
  import { afterEach, beforeEach, describe, expect, test } from "vitest";
4
- import { CommercetoolsMock } from "../index";
4
+ import { CommercetoolsMock } from "../index.ts";
5
5
 
6
6
  const ctMock = new CommercetoolsMock();
7
7
 
@@ -1,7 +1,7 @@
1
1
  import type { Request, Response } from "express";
2
2
  import { Router } from "express";
3
- import type { CartRepository } from "../repositories/cart";
4
- import AbstractService from "./abstract";
3
+ import type { CartRepository } from "../repositories/cart/index.ts";
4
+ import AbstractService from "./abstract.ts";
5
5
 
6
6
  export class MyCartService extends AbstractService {
7
7
  public repository: CartRepository;
@@ -6,8 +6,8 @@ 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, getBaseResourceProperties } from "../index";
10
- import { hashPassword } from "../lib/password";
9
+ import { CommercetoolsMock, getBaseResourceProperties } from "../index.ts";
10
+ import { hashPassword } from "../lib/password.ts";
11
11
 
12
12
  const ctMock = new CommercetoolsMock();
13
13
 
@@ -1,12 +1,12 @@
1
1
  import type { Update } from "@commercetools/platform-sdk";
2
2
  import type { Request, Response } from "express";
3
3
  import { Router } from "express";
4
- import { updateRequestSchema } from "~src/schemas/update-request";
5
- import { validateData } from "~src/validate";
6
- import { hashPassword } from "../lib/password";
7
- import { getRepositoryContext } from "../repositories/helpers";
8
- import type { MyCustomerRepository } from "../repositories/my-customer";
9
- import AbstractService from "./abstract";
4
+ import { updateRequestSchema } from "#src/schemas/update-request.ts";
5
+ import { validateData } from "#src/validate.ts";
6
+ import { hashPassword } from "../lib/password.ts";
7
+ import { getRepositoryContext } from "../repositories/helpers.ts";
8
+ import type { MyCustomerRepository } from "../repositories/my-customer.ts";
9
+ import AbstractService from "./abstract.ts";
10
10
 
11
11
  export class MyCustomerService extends AbstractService {
12
12
  public repository: MyCustomerRepository;
@@ -1,6 +1,6 @@
1
1
  import { Router } from "express";
2
- import type { MyOrderRepository } from "../repositories/my-order";
3
- import AbstractService from "./abstract";
2
+ import type { MyOrderRepository } from "../repositories/my-order.ts";
3
+ import AbstractService from "./abstract.ts";
4
4
 
5
5
  export class MyOrderService extends AbstractService {
6
6
  public repository: MyOrderRepository;
@@ -1,7 +1,7 @@
1
1
  import type { MyPaymentDraft } from "@commercetools/platform-sdk";
2
2
  import supertest from "supertest";
3
3
  import { beforeEach, describe, expect, test } from "vitest";
4
- import { CommercetoolsMock } from "../index";
4
+ import { CommercetoolsMock } from "../index.ts";
5
5
 
6
6
  const ctMock = new CommercetoolsMock();
7
7
 
@@ -1,6 +1,6 @@
1
1
  import type { Router } from "express";
2
- import type { PaymentRepository } from "../repositories/payment";
3
- import AbstractService from "./abstract";
2
+ import type { PaymentRepository } from "../repositories/payment/index.ts";
3
+ import AbstractService from "./abstract.ts";
4
4
 
5
5
  export class MyPaymentService extends AbstractService {
6
6
  public repository: PaymentRepository;
@@ -1,6 +1,6 @@
1
1
  import type { Router } from "express";
2
- import type { ShoppingListRepository } from "../repositories/shopping-list";
3
- import AbstractService from "./abstract";
2
+ import type { ShoppingListRepository } from "../repositories/shopping-list/index.ts";
3
+ import AbstractService from "./abstract.ts";
4
4
 
5
5
  export class MyShoppingListService extends AbstractService {
6
6
  public repository: ShoppingListRepository;
@@ -1,14 +1,9 @@
1
1
  import assert from "node:assert";
2
- import type {
3
- CentPrecisionMoney,
4
- Order,
5
- Payment,
6
- State,
7
- } from "@commercetools/platform-sdk";
2
+ import type { Order, Payment, State } from "@commercetools/platform-sdk";
8
3
  import supertest from "supertest";
9
4
  import { afterEach, beforeEach, describe, expect, test } from "vitest";
10
- import { generateRandomString } from "~src/helpers";
11
- import { CommercetoolsMock, getBaseResourceProperties } from "../index";
5
+ import { generateRandomString } from "#src/helpers.ts";
6
+ import { CommercetoolsMock, getBaseResourceProperties } from "../index.ts";
12
7
 
13
8
  describe("Order Query", () => {
14
9
  const ctMock = new CommercetoolsMock();
@@ -1035,9 +1030,8 @@ describe("Order Import", () => {
1035
1030
  const ctMock = new CommercetoolsMock();
1036
1031
  ctMock.project("dummy").add("product", {
1037
1032
  id: "15fc56ba-a74e-4cf8-b4b0-bada5c101541",
1038
- // @ts-ignore
1039
1033
  masterData: {
1040
- // @ts-ignore
1034
+ // @ts-expect-error
1041
1035
  current: {
1042
1036
  name: { "nl-NL": "Dummy" },
1043
1037
  slug: { "nl-NL": "Dummy" },
@@ -1092,7 +1086,6 @@ describe("Order Import", () => {
1092
1086
  productType: {
1093
1087
  typeId: "product-type",
1094
1088
  id: "109caecb-abe6-4900-ab03-7af5af985ff3",
1095
- // @ts-ignore
1096
1089
  version: 1,
1097
1090
  },
1098
1091
  variant: {
@@ -1,7 +1,7 @@
1
1
  import type { Request, Response, Router } from "express";
2
- import { getRepositoryContext } from "../repositories/helpers";
3
- import type { OrderRepository } from "../repositories/order/index";
4
- import AbstractService from "./abstract";
2
+ import { getRepositoryContext } from "../repositories/helpers.ts";
3
+ import type { OrderRepository } from "../repositories/order/index.ts";
4
+ import AbstractService from "./abstract.ts";
5
5
 
6
6
  export class OrderService extends AbstractService {
7
7
  public repository: OrderRepository;
@@ -38,7 +38,7 @@ export class OrderService extends AbstractService {
38
38
  getRepositoryContext(request),
39
39
  orderNumber,
40
40
 
41
- // @ts-ignore
41
+ // @ts-expect-error
42
42
  request.query,
43
43
  );
44
44
  if (resource) {
@@ -1,7 +1,7 @@
1
1
  import type { PaymentDraft } from "@commercetools/platform-sdk";
2
2
  import supertest from "supertest";
3
3
  import { beforeEach, describe, expect, test } from "vitest";
4
- import { CommercetoolsMock } from "../index";
4
+ import { CommercetoolsMock } from "../index.ts";
5
5
 
6
6
  const ctMock = new CommercetoolsMock();
7
7
 
@@ -1,6 +1,6 @@
1
1
  import type { Router } from "express";
2
- import type { PaymentRepository } from "../repositories/payment";
3
- import AbstractService from "./abstract";
2
+ import type { PaymentRepository } from "../repositories/payment/index.ts";
3
+ import AbstractService from "./abstract.ts";
4
4
 
5
5
  export class PaymentService extends AbstractService {
6
6
  public repository: PaymentRepository;
@@ -1,7 +1,7 @@
1
1
  import type { ProductDiscountDraft } from "@commercetools/platform-sdk";
2
2
  import supertest from "supertest";
3
3
  import { describe, expect, test } from "vitest";
4
- import { CommercetoolsMock } from "../index";
4
+ import { CommercetoolsMock } from "../index.ts";
5
5
 
6
6
  const ctMock = new CommercetoolsMock();
7
7
 
@@ -1,6 +1,6 @@
1
1
  import type { Router } from "express";
2
- import type { ProductDiscountRepository } from "../repositories/product-discount";
3
- import AbstractService from "./abstract";
2
+ import type { ProductDiscountRepository } from "../repositories/product-discount.ts";
3
+ import AbstractService from "./abstract.ts";
4
4
 
5
5
  export class ProductDiscountService extends AbstractService {
6
6
  public repository: ProductDiscountRepository;
@@ -9,8 +9,8 @@ import type {
9
9
  import supertest from "supertest";
10
10
  import * as timekeeper from "timekeeper";
11
11
  import { afterEach, beforeEach, describe, expect, test } from "vitest";
12
- import { CommercetoolsMock } from "../index";
13
- import type { Writable } from "../types";
12
+ import { CommercetoolsMock } from "../index.ts";
13
+ import type { Writable } from "../types.ts";
14
14
 
15
15
  const ctMock = new CommercetoolsMock();
16
16
 
@@ -1,11 +1,11 @@
1
1
  import type { Request, Response, Router } from "express";
2
- import { queryParamsArray, queryParamsValue } from "../helpers";
3
- import { getRepositoryContext } from "../repositories/helpers";
2
+ import { queryParamsArray, queryParamsValue } from "../helpers.ts";
3
+ import { getRepositoryContext } from "../repositories/helpers.ts";
4
4
  import type {
5
5
  ProductProjectionQueryParams,
6
6
  ProductProjectionRepository,
7
- } from "./../repositories/product-projection";
8
- import AbstractService from "./abstract";
7
+ } from "./../repositories/product-projection.ts";
8
+ import AbstractService from "./abstract.ts";
9
9
 
10
10
  export class ProductProjectionService extends AbstractService {
11
11
  public repository: ProductProjectionRepository;