@labdigital/commercetools-mock 2.42.0 → 2.43.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 (59) hide show
  1. package/dist/index.cjs +2911 -2865
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +179 -170
  4. package/dist/index.d.ts +179 -170
  5. package/dist/index.js +2920 -2874
  6. package/dist/index.js.map +1 -1
  7. package/package.json +3 -3
  8. package/src/config.ts +6 -0
  9. package/src/ctMock.ts +25 -14
  10. package/src/index.test.ts +20 -16
  11. package/src/oauth/server.test.ts +3 -1
  12. package/src/product-projection-search.ts +3 -2
  13. package/src/product-search.ts +3 -2
  14. package/src/projectAPI.ts +18 -6
  15. package/src/repositories/abstract.ts +8 -4
  16. package/src/repositories/associate-role.ts +20 -3
  17. package/src/repositories/attribute-group.ts +3 -3
  18. package/src/repositories/business-unit.ts +20 -3
  19. package/src/repositories/cart/index.test.ts +3 -1
  20. package/src/repositories/cart/index.ts +3 -3
  21. package/src/repositories/cart-discount/index.ts +4 -6
  22. package/src/repositories/category/index.test.ts +3 -1
  23. package/src/repositories/category/index.ts +3 -3
  24. package/src/repositories/channel.ts +3 -3
  25. package/src/repositories/custom-object.ts +3 -3
  26. package/src/repositories/customer/index.test.ts +3 -1
  27. package/src/repositories/customer/index.ts +4 -4
  28. package/src/repositories/customer-group.ts +4 -4
  29. package/src/repositories/discount-code/index.ts +4 -4
  30. package/src/repositories/extension.ts +4 -4
  31. package/src/repositories/index.ts +45 -45
  32. package/src/repositories/inventory-entry/index.ts +4 -4
  33. package/src/repositories/order/index.test.ts +6 -1
  34. package/src/repositories/order/index.ts +4 -4
  35. package/src/repositories/order-edit.ts +3 -3
  36. package/src/repositories/payment/index.ts +3 -3
  37. package/src/repositories/product/index.ts +10 -6
  38. package/src/repositories/product-discount.ts +3 -3
  39. package/src/repositories/product-projection.ts +4 -4
  40. package/src/repositories/product-selection.ts +21 -3
  41. package/src/repositories/product-tailoring.ts +3 -3
  42. package/src/repositories/product-type.ts +4 -4
  43. package/src/repositories/project.ts +4 -4
  44. package/src/repositories/quote-request.ts +3 -3
  45. package/src/repositories/quote.ts +3 -3
  46. package/src/repositories/review.ts +3 -3
  47. package/src/repositories/shipping-method/index.ts +4 -4
  48. package/src/repositories/shopping-list/index.ts +4 -4
  49. package/src/repositories/staged-quote.ts +3 -3
  50. package/src/repositories/standalone-price.ts +3 -3
  51. package/src/repositories/state.ts +4 -4
  52. package/src/repositories/store.ts +3 -2
  53. package/src/repositories/subscription.ts +4 -4
  54. package/src/repositories/tax-category/index.ts +3 -3
  55. package/src/repositories/type/index.ts +4 -4
  56. package/src/repositories/zone.ts +4 -4
  57. package/src/services/project.test.ts +1 -13
  58. package/src/services/store.test.ts +1 -13
  59. package/src/deprecation.ts +0 -8
@@ -2,13 +2,13 @@ import type {
2
2
  StagedQuote,
3
3
  StagedQuoteDraft,
4
4
  } from "@commercetools/platform-sdk";
5
- import type { AbstractStorage } from "~src/storage";
5
+ import type { Config } from "~src/config";
6
6
  import type { RepositoryContext } from "./abstract";
7
7
  import { AbstractResourceRepository } from "./abstract";
8
8
 
9
9
  export class StagedQuoteRepository extends AbstractResourceRepository<"staged-quote"> {
10
- constructor(storage: AbstractStorage) {
11
- super("staged-quote", storage);
10
+ constructor(config: Config) {
11
+ super("staged-quote", config);
12
12
  }
13
13
 
14
14
  create(context: RepositoryContext, draft: StagedQuoteDraft): StagedQuote {
@@ -9,16 +9,16 @@ import type {
9
9
  StandalonePriceSetDiscountedPriceAction,
10
10
  StandalonePriceUpdateAction,
11
11
  } from "@commercetools/platform-sdk";
12
+ import type { Config } from "~src/config";
12
13
  import { getBaseResourceProperties } from "../helpers";
13
- import type { AbstractStorage } from "../storage/abstract";
14
14
  import type { Writable } from "../types";
15
15
  import type { RepositoryContext, UpdateHandlerInterface } from "./abstract";
16
16
  import { AbstractResourceRepository, AbstractUpdateHandler } from "./abstract";
17
17
  import { createTypedMoney } from "./helpers";
18
18
 
19
19
  export class StandAlonePriceRepository extends AbstractResourceRepository<"standalone-price"> {
20
- constructor(storage: AbstractStorage) {
21
- super("standalone-price", storage);
20
+ constructor(config: Config) {
21
+ super("standalone-price", config);
22
22
  this.actions = new StandalonePriceUpdateHandler(this._storage);
23
23
  }
24
24
 
@@ -13,17 +13,17 @@ import type {
13
13
  StateSetTransitionsAction,
14
14
  StateUpdateAction,
15
15
  } from "@commercetools/platform-sdk";
16
+ import type { Config } from "~src/config";
16
17
  import { getBaseResourceProperties } from "../helpers";
17
- import type { AbstractStorage } from "../storage/abstract";
18
18
  import type { Writable } from "../types";
19
19
  import type { RepositoryContext, UpdateHandlerInterface } from "./abstract";
20
20
  import { AbstractResourceRepository, AbstractUpdateHandler } from "./abstract";
21
21
  import { getReferenceFromResourceIdentifier } from "./helpers";
22
22
 
23
23
  export class StateRepository extends AbstractResourceRepository<"state"> {
24
- constructor(storage: AbstractStorage) {
25
- super("state", storage);
26
- this.actions = new StateUpdateHandler(storage);
24
+ constructor(config: Config) {
25
+ super("state", config);
26
+ this.actions = new StateUpdateHandler(config.storage);
27
27
  }
28
28
 
29
29
  create(context: RepositoryContext, draft: StateDraft): State {
@@ -11,6 +11,7 @@ import type {
11
11
  StoreSetNameAction,
12
12
  StoreUpdateAction,
13
13
  } from "@commercetools/platform-sdk";
14
+ import type { Config } from "~src/config";
14
15
  import { getBaseResourceProperties } from "../helpers";
15
16
  import type { AbstractStorage } from "../storage/abstract";
16
17
  import type { Writable } from "../types";
@@ -22,8 +23,8 @@ import {
22
23
  } from "./helpers";
23
24
 
24
25
  export class StoreRepository extends AbstractResourceRepository<"store"> {
25
- constructor(storage: AbstractStorage) {
26
- super("store", storage);
26
+ constructor(config: Config) {
27
+ super("store", config);
27
28
  this.actions = new StoreUpdateHandler(this._storage);
28
29
  }
29
30
 
@@ -5,17 +5,17 @@ import type {
5
5
  SubscriptionSetKeyAction,
6
6
  SubscriptionUpdateAction,
7
7
  } from "@commercetools/platform-sdk";
8
+ import type { Config } from "~src/config";
8
9
  import { CommercetoolsError } from "~src/exceptions";
9
10
  import { getBaseResourceProperties } from "../helpers";
10
- import type { AbstractStorage } from "../storage/abstract";
11
11
  import type { Writable } from "../types";
12
12
  import type { RepositoryContext, UpdateHandlerInterface } from "./abstract";
13
13
  import { AbstractResourceRepository, AbstractUpdateHandler } from "./abstract";
14
14
 
15
15
  export class SubscriptionRepository extends AbstractResourceRepository<"subscription"> {
16
- constructor(storage: AbstractStorage) {
17
- super("subscription", storage);
18
- this.actions = new SubscriptionUpdateHandler(storage);
16
+ constructor(config: Config) {
17
+ super("subscription", config);
18
+ this.actions = new SubscriptionUpdateHandler(config.storage);
19
19
  }
20
20
 
21
21
  create(context: RepositoryContext, draft: SubscriptionDraft): Subscription {
@@ -2,16 +2,16 @@ import type {
2
2
  TaxCategory,
3
3
  TaxCategoryDraft,
4
4
  } from "@commercetools/platform-sdk";
5
+ import type { Config } from "~src/config";
5
6
  import { getBaseResourceProperties } from "~src/helpers";
6
- import type { AbstractStorage } from "~src/storage/abstract";
7
7
  import type { RepositoryContext } from "../abstract";
8
8
  import { AbstractResourceRepository } from "../abstract";
9
9
  import { TaxCategoryUpdateHandler } from "./actions";
10
10
  import { taxRateFromTaxRateDraft } from "./helpers";
11
11
 
12
12
  export class TaxCategoryRepository extends AbstractResourceRepository<"tax-category"> {
13
- constructor(storage: AbstractStorage) {
14
- super("tax-category", storage);
13
+ constructor(config: Config) {
14
+ super("tax-category", config);
15
15
  this.actions = new TaxCategoryUpdateHandler(this._storage);
16
16
  }
17
17
 
@@ -1,14 +1,14 @@
1
1
  import type { Type, TypeDraft } from "@commercetools/platform-sdk";
2
+ import type { Config } from "~src/config";
2
3
  import { getBaseResourceProperties } from "~src/helpers";
3
- import type { AbstractStorage } from "~src/storage/abstract";
4
4
  import type { RepositoryContext } from "../abstract";
5
5
  import { AbstractResourceRepository } from "../abstract";
6
6
  import { TypeUpdateHandler } from "./actions";
7
7
 
8
8
  export class TypeRepository extends AbstractResourceRepository<"type"> {
9
- constructor(storage: AbstractStorage) {
10
- super("type", storage);
11
- this.actions = new TypeUpdateHandler(storage);
9
+ constructor(config: Config) {
10
+ super("type", config);
11
+ this.actions = new TypeUpdateHandler(config.storage);
12
12
  }
13
13
 
14
14
  create(context: RepositoryContext, draft: TypeDraft): Type {
@@ -8,16 +8,16 @@ import type {
8
8
  ZoneSetKeyAction,
9
9
  ZoneUpdateAction,
10
10
  } from "@commercetools/platform-sdk";
11
+ import type { Config } from "~src/config";
11
12
  import { getBaseResourceProperties } from "../helpers";
12
- import type { AbstractStorage } from "../storage/abstract";
13
13
  import type { Writable } from "../types";
14
14
  import type { RepositoryContext, UpdateHandlerInterface } from "./abstract";
15
15
  import { AbstractResourceRepository, AbstractUpdateHandler } from "./abstract";
16
16
 
17
17
  export class ZoneRepository extends AbstractResourceRepository<"zone"> {
18
- constructor(storage: AbstractStorage) {
19
- super("zone", storage);
20
- this.actions = new ZoneUpdateHandler(storage);
18
+ constructor(config: Config) {
19
+ super("zone", config);
20
+ this.actions = new ZoneUpdateHandler(config.storage);
21
21
  }
22
22
 
23
23
  create(context: RepositoryContext, draft: ZoneDraft): Zone {
@@ -1,23 +1,11 @@
1
1
  import type { Project } from "@commercetools/platform-sdk";
2
2
  import supertest from "supertest";
3
- import { afterAll, afterEach, beforeAll, describe, expect, test } from "vitest";
3
+ import { describe, expect, test } from "vitest";
4
4
  import { CommercetoolsMock } from "../index";
5
5
 
6
6
  const ctMock = new CommercetoolsMock();
7
7
 
8
8
  describe("Project", () => {
9
- beforeAll(() => {
10
- ctMock.start();
11
- });
12
-
13
- afterEach(() => {
14
- ctMock.clear();
15
- });
16
-
17
- afterAll(() => {
18
- ctMock.stop();
19
- });
20
-
21
9
  test("Get project by key", async () => {
22
10
  const response = await supertest(ctMock.app).get("/dummy/");
23
11
 
@@ -1,23 +1,11 @@
1
1
  import type { Store } from "@commercetools/platform-sdk";
2
2
  import supertest from "supertest";
3
- import { afterAll, afterEach, beforeAll, describe, expect, test } from "vitest";
3
+ import { describe, expect, test } from "vitest";
4
4
  import { CommercetoolsMock } from "../index";
5
5
 
6
6
  const ctMock = new CommercetoolsMock();
7
7
 
8
8
  describe("Store", () => {
9
- beforeAll(() => {
10
- ctMock.start();
11
- });
12
-
13
- afterEach(() => {
14
- ctMock.clear();
15
- });
16
-
17
- afterAll(() => {
18
- ctMock.stop();
19
- });
20
-
21
9
  test("Get store by key", async () => {
22
10
  ctMock.project("dummy").add("store", {
23
11
  id: "fake-store",
@@ -1,8 +0,0 @@
1
- const shownWarnings = new Set();
2
-
3
- export const warnDeprecation = (msg: string) => {
4
- if (!shownWarnings.has(msg)) {
5
- console.warn(msg);
6
- shownWarnings.add(msg);
7
- }
8
- };