@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.
- package/dist/index.cjs +2911 -2865
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +179 -170
- package/dist/index.d.ts +179 -170
- package/dist/index.js +2920 -2874
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/config.ts +6 -0
- package/src/ctMock.ts +25 -14
- package/src/index.test.ts +20 -16
- package/src/oauth/server.test.ts +3 -1
- package/src/product-projection-search.ts +3 -2
- package/src/product-search.ts +3 -2
- package/src/projectAPI.ts +18 -6
- package/src/repositories/abstract.ts +8 -4
- package/src/repositories/associate-role.ts +20 -3
- package/src/repositories/attribute-group.ts +3 -3
- package/src/repositories/business-unit.ts +20 -3
- package/src/repositories/cart/index.test.ts +3 -1
- package/src/repositories/cart/index.ts +3 -3
- package/src/repositories/cart-discount/index.ts +4 -6
- package/src/repositories/category/index.test.ts +3 -1
- package/src/repositories/category/index.ts +3 -3
- package/src/repositories/channel.ts +3 -3
- package/src/repositories/custom-object.ts +3 -3
- package/src/repositories/customer/index.test.ts +3 -1
- package/src/repositories/customer/index.ts +4 -4
- package/src/repositories/customer-group.ts +4 -4
- package/src/repositories/discount-code/index.ts +4 -4
- package/src/repositories/extension.ts +4 -4
- package/src/repositories/index.ts +45 -45
- package/src/repositories/inventory-entry/index.ts +4 -4
- package/src/repositories/order/index.test.ts +6 -1
- package/src/repositories/order/index.ts +4 -4
- package/src/repositories/order-edit.ts +3 -3
- package/src/repositories/payment/index.ts +3 -3
- package/src/repositories/product/index.ts +10 -6
- package/src/repositories/product-discount.ts +3 -3
- package/src/repositories/product-projection.ts +4 -4
- package/src/repositories/product-selection.ts +21 -3
- package/src/repositories/product-tailoring.ts +3 -3
- package/src/repositories/product-type.ts +4 -4
- package/src/repositories/project.ts +4 -4
- package/src/repositories/quote-request.ts +3 -3
- package/src/repositories/quote.ts +3 -3
- package/src/repositories/review.ts +3 -3
- package/src/repositories/shipping-method/index.ts +4 -4
- package/src/repositories/shopping-list/index.ts +4 -4
- package/src/repositories/staged-quote.ts +3 -3
- package/src/repositories/standalone-price.ts +3 -3
- package/src/repositories/state.ts +4 -4
- package/src/repositories/store.ts +3 -2
- package/src/repositories/subscription.ts +4 -4
- package/src/repositories/tax-category/index.ts +3 -3
- package/src/repositories/type/index.ts +4 -4
- package/src/repositories/zone.ts +4 -4
- package/src/services/project.test.ts +1 -13
- package/src/services/store.test.ts +1 -13
- package/src/deprecation.ts +0 -8
|
@@ -3,8 +3,8 @@ import type {
|
|
|
3
3
|
CustomObjectDraft,
|
|
4
4
|
InvalidOperationError,
|
|
5
5
|
} from "@commercetools/platform-sdk";
|
|
6
|
+
import type { Config } from "~src/config";
|
|
6
7
|
import { CommercetoolsError } from "~src/exceptions";
|
|
7
|
-
import type { AbstractStorage } from "~src/storage";
|
|
8
8
|
import { cloneObject, getBaseResourceProperties } from "../helpers";
|
|
9
9
|
import type { Writable } from "../types";
|
|
10
10
|
import type { QueryParams } from "./abstract";
|
|
@@ -12,8 +12,8 @@ import { AbstractResourceRepository, type RepositoryContext } from "./abstract";
|
|
|
12
12
|
import { checkConcurrentModification } from "./errors";
|
|
13
13
|
|
|
14
14
|
export class CustomObjectRepository extends AbstractResourceRepository<"key-value-document"> {
|
|
15
|
-
constructor(
|
|
16
|
-
super("key-value-document",
|
|
15
|
+
constructor(config: Config) {
|
|
16
|
+
super("key-value-document", config);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
create(
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { Store } from "@commercetools/platform-sdk";
|
|
2
2
|
import { describe, expect, test } from "vitest";
|
|
3
|
+
import type { Config } from "~src/config";
|
|
3
4
|
import { InMemoryStorage } from "~src/storage";
|
|
4
5
|
import { CustomerRepository } from "./index";
|
|
5
6
|
|
|
6
7
|
describe("Customer repository", () => {
|
|
7
8
|
const storage = new InMemoryStorage();
|
|
8
|
-
const
|
|
9
|
+
const config: Config = { storage, strict: false };
|
|
10
|
+
const repository = new CustomerRepository(config);
|
|
9
11
|
|
|
10
12
|
test("query by lowercaseEmail", async () => {
|
|
11
13
|
const customer = repository.create(
|
|
@@ -13,6 +13,7 @@ import type {
|
|
|
13
13
|
StoreKeyReference,
|
|
14
14
|
StoreResourceIdentifier,
|
|
15
15
|
} from "@commercetools/platform-sdk";
|
|
16
|
+
import type { Config } from "~src/config";
|
|
16
17
|
import { CommercetoolsError } from "~src/exceptions";
|
|
17
18
|
import { generateRandomString, getBaseResourceProperties } from "~src/helpers";
|
|
18
19
|
import {
|
|
@@ -21,7 +22,6 @@ import {
|
|
|
21
22
|
hashPassword,
|
|
22
23
|
validatePasswordResetToken,
|
|
23
24
|
} from "~src/lib/password";
|
|
24
|
-
import type { AbstractStorage } from "~src/storage/abstract";
|
|
25
25
|
import type { ResourceMap, ShallowWritable, Writable } from "~src/types";
|
|
26
26
|
import {
|
|
27
27
|
AbstractResourceRepository,
|
|
@@ -31,9 +31,9 @@ import { createCustomFields } from "../helpers";
|
|
|
31
31
|
import { CustomerUpdateHandler } from "./actions";
|
|
32
32
|
|
|
33
33
|
export class CustomerRepository extends AbstractResourceRepository<"customer"> {
|
|
34
|
-
constructor(
|
|
35
|
-
super("customer",
|
|
36
|
-
this.actions = new CustomerUpdateHandler(storage);
|
|
34
|
+
constructor(config: Config) {
|
|
35
|
+
super("customer", config);
|
|
36
|
+
this.actions = new CustomerUpdateHandler(config.storage);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
create(context: RepositoryContext, draft: CustomerDraft): Customer {
|
|
@@ -7,8 +7,8 @@ import type {
|
|
|
7
7
|
CustomerGroupSetKeyAction,
|
|
8
8
|
CustomerGroupUpdateAction,
|
|
9
9
|
} from "@commercetools/platform-sdk";
|
|
10
|
+
import type { Config } from "~src/config";
|
|
10
11
|
import { getBaseResourceProperties } from "../helpers";
|
|
11
|
-
import type { AbstractStorage } from "../storage/abstract";
|
|
12
12
|
import type { Writable } from "../types";
|
|
13
13
|
import type { UpdateHandlerInterface } from "./abstract";
|
|
14
14
|
import {
|
|
@@ -19,9 +19,9 @@ import {
|
|
|
19
19
|
import { createCustomFields } from "./helpers";
|
|
20
20
|
|
|
21
21
|
export class CustomerGroupRepository extends AbstractResourceRepository<"customer-group"> {
|
|
22
|
-
constructor(
|
|
23
|
-
super("customer-group",
|
|
24
|
-
this.actions = new CustomerGroupUpdateHandler(storage);
|
|
22
|
+
constructor(config: Config) {
|
|
23
|
+
super("customer-group", config);
|
|
24
|
+
this.actions = new CustomerGroupUpdateHandler(config.storage);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
create(context: RepositoryContext, draft: CustomerGroupDraft): CustomerGroup {
|
|
@@ -3,8 +3,8 @@ import type {
|
|
|
3
3
|
DiscountCode,
|
|
4
4
|
DiscountCodeDraft,
|
|
5
5
|
} from "@commercetools/platform-sdk";
|
|
6
|
+
import type { Config } from "~src/config";
|
|
6
7
|
import { getBaseResourceProperties } from "~src/helpers";
|
|
7
|
-
import type { AbstractStorage } from "~src/storage/abstract";
|
|
8
8
|
import {
|
|
9
9
|
AbstractResourceRepository,
|
|
10
10
|
type RepositoryContext,
|
|
@@ -13,9 +13,9 @@ import { createCustomFields } from "../helpers";
|
|
|
13
13
|
import { DiscountCodeUpdateHandler } from "./actions";
|
|
14
14
|
|
|
15
15
|
export class DiscountCodeRepository extends AbstractResourceRepository<"discount-code"> {
|
|
16
|
-
constructor(
|
|
17
|
-
super("discount-code",
|
|
18
|
-
this.actions = new DiscountCodeUpdateHandler(storage);
|
|
16
|
+
constructor(config: Config) {
|
|
17
|
+
super("discount-code", config);
|
|
18
|
+
this.actions = new DiscountCodeUpdateHandler(config.storage);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
create(context: RepositoryContext, draft: DiscountCodeDraft): DiscountCode {
|
|
@@ -7,7 +7,7 @@ import type {
|
|
|
7
7
|
ExtensionSetTimeoutInMsAction,
|
|
8
8
|
ExtensionUpdateAction,
|
|
9
9
|
} from "@commercetools/platform-sdk";
|
|
10
|
-
import type {
|
|
10
|
+
import type { Config } from "~src/config";
|
|
11
11
|
import { getBaseResourceProperties } from "../helpers";
|
|
12
12
|
import { maskSecretValue } from "../lib/masking";
|
|
13
13
|
import type { Writable } from "../types";
|
|
@@ -19,9 +19,9 @@ import {
|
|
|
19
19
|
} from "./abstract";
|
|
20
20
|
|
|
21
21
|
export class ExtensionRepository extends AbstractResourceRepository<"extension"> {
|
|
22
|
-
constructor(
|
|
23
|
-
super("extension",
|
|
24
|
-
this.actions = new ExtensionUpdateHandler(storage);
|
|
22
|
+
constructor(config: Config) {
|
|
23
|
+
super("extension", config);
|
|
24
|
+
this.actions = new ExtensionUpdateHandler(config.storage);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
create(context: RepositoryContext, draft: ExtensionDraft): Extension {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { Config } from "~src/config";
|
|
1
2
|
import { ProductTailoringRepository } from "~src/repositories/product-tailoring";
|
|
2
|
-
import type { AbstractStorage } from "../storage";
|
|
3
3
|
import {
|
|
4
4
|
AsAssociateCartRepository,
|
|
5
5
|
AsAssociateOrderRepository,
|
|
@@ -44,50 +44,50 @@ import { ZoneRepository } from "./zone";
|
|
|
44
44
|
|
|
45
45
|
export type RepositoryMap = ReturnType<typeof createRepositories>;
|
|
46
46
|
|
|
47
|
-
export const createRepositories = (
|
|
47
|
+
export const createRepositories = (config: Config) => ({
|
|
48
48
|
"as-associate": {
|
|
49
|
-
cart: new AsAssociateCartRepository(
|
|
50
|
-
order: new AsAssociateOrderRepository(
|
|
49
|
+
cart: new AsAssociateCartRepository(config),
|
|
50
|
+
order: new AsAssociateOrderRepository(config),
|
|
51
51
|
},
|
|
52
|
-
"associate-role": new AssociateRoleRepository(
|
|
53
|
-
"attribute-group": new AttributeGroupRepository(
|
|
54
|
-
"business-unit": new BusinessUnitRepository(
|
|
55
|
-
"category": new CategoryRepository(
|
|
56
|
-
"cart": new CartRepository(
|
|
57
|
-
"cart-discount": new CartDiscountRepository(
|
|
58
|
-
"customer": new CustomerRepository(
|
|
59
|
-
"channel": new ChannelRepository(
|
|
60
|
-
"customer-group": new CustomerGroupRepository(
|
|
61
|
-
"discount-code": new DiscountCodeRepository(
|
|
62
|
-
"extension": new ExtensionRepository(
|
|
63
|
-
"inventory-entry": new InventoryEntryRepository(
|
|
64
|
-
"key-value-document": new CustomObjectRepository(
|
|
65
|
-
"order": new OrderRepository(
|
|
66
|
-
"order-edit": new OrderEditRepository(
|
|
67
|
-
"payment": new PaymentRepository(
|
|
68
|
-
"my-cart": new CartRepository(
|
|
69
|
-
"my-order": new MyOrderRepository(
|
|
70
|
-
"my-customer": new MyCustomerRepository(
|
|
71
|
-
"my-payment": new PaymentRepository(
|
|
72
|
-
"my-shopping-list": new ShoppingListRepository(
|
|
73
|
-
"product": new ProductRepository(
|
|
74
|
-
"product-type": new ProductTypeRepository(
|
|
75
|
-
"product-discount": new ProductDiscountRepository(
|
|
76
|
-
"product-projection": new ProductProjectionRepository(
|
|
77
|
-
"product-selection": new ProductSelectionRepository(
|
|
78
|
-
"product-tailoring": new ProductTailoringRepository(
|
|
79
|
-
"project": new ProjectRepository(
|
|
80
|
-
"review": new ReviewRepository(
|
|
81
|
-
"quote": new QuoteRepository(
|
|
82
|
-
"quote-request": new QuoteRequestRepository(
|
|
83
|
-
"shipping-method": new ShippingMethodRepository(
|
|
84
|
-
"shopping-list": new ShoppingListRepository(
|
|
85
|
-
"staged-quote": new StagedQuoteRepository(
|
|
86
|
-
"standalone-price": new StandAlonePriceRepository(
|
|
87
|
-
"state": new StateRepository(
|
|
88
|
-
"store": new StoreRepository(
|
|
89
|
-
"subscription": new SubscriptionRepository(
|
|
90
|
-
"tax-category": new TaxCategoryRepository(
|
|
91
|
-
"type": new TypeRepository(
|
|
92
|
-
"zone": new ZoneRepository(
|
|
52
|
+
"associate-role": new AssociateRoleRepository(config),
|
|
53
|
+
"attribute-group": new AttributeGroupRepository(config),
|
|
54
|
+
"business-unit": new BusinessUnitRepository(config),
|
|
55
|
+
"category": new CategoryRepository(config),
|
|
56
|
+
"cart": new CartRepository(config),
|
|
57
|
+
"cart-discount": new CartDiscountRepository(config),
|
|
58
|
+
"customer": new CustomerRepository(config),
|
|
59
|
+
"channel": new ChannelRepository(config),
|
|
60
|
+
"customer-group": new CustomerGroupRepository(config),
|
|
61
|
+
"discount-code": new DiscountCodeRepository(config),
|
|
62
|
+
"extension": new ExtensionRepository(config),
|
|
63
|
+
"inventory-entry": new InventoryEntryRepository(config),
|
|
64
|
+
"key-value-document": new CustomObjectRepository(config),
|
|
65
|
+
"order": new OrderRepository(config),
|
|
66
|
+
"order-edit": new OrderEditRepository(config),
|
|
67
|
+
"payment": new PaymentRepository(config),
|
|
68
|
+
"my-cart": new CartRepository(config),
|
|
69
|
+
"my-order": new MyOrderRepository(config),
|
|
70
|
+
"my-customer": new MyCustomerRepository(config),
|
|
71
|
+
"my-payment": new PaymentRepository(config),
|
|
72
|
+
"my-shopping-list": new ShoppingListRepository(config),
|
|
73
|
+
"product": new ProductRepository(config),
|
|
74
|
+
"product-type": new ProductTypeRepository(config),
|
|
75
|
+
"product-discount": new ProductDiscountRepository(config),
|
|
76
|
+
"product-projection": new ProductProjectionRepository(config),
|
|
77
|
+
"product-selection": new ProductSelectionRepository(config),
|
|
78
|
+
"product-tailoring": new ProductTailoringRepository(config),
|
|
79
|
+
"project": new ProjectRepository(config),
|
|
80
|
+
"review": new ReviewRepository(config),
|
|
81
|
+
"quote": new QuoteRepository(config),
|
|
82
|
+
"quote-request": new QuoteRequestRepository(config),
|
|
83
|
+
"shipping-method": new ShippingMethodRepository(config),
|
|
84
|
+
"shopping-list": new ShoppingListRepository(config),
|
|
85
|
+
"staged-quote": new StagedQuoteRepository(config),
|
|
86
|
+
"standalone-price": new StandAlonePriceRepository(config),
|
|
87
|
+
"state": new StateRepository(config),
|
|
88
|
+
"store": new StoreRepository(config),
|
|
89
|
+
"subscription": new SubscriptionRepository(config),
|
|
90
|
+
"tax-category": new TaxCategoryRepository(config),
|
|
91
|
+
"type": new TypeRepository(config),
|
|
92
|
+
"zone": new ZoneRepository(config),
|
|
93
93
|
});
|
|
@@ -2,8 +2,8 @@ import type {
|
|
|
2
2
|
InventoryEntry,
|
|
3
3
|
InventoryEntryDraft,
|
|
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 {
|
|
8
8
|
AbstractResourceRepository,
|
|
9
9
|
type RepositoryContext,
|
|
@@ -12,9 +12,9 @@ import { createCustomFields } from "../helpers";
|
|
|
12
12
|
import { InventoryEntryUpdateHandler } from "./actions";
|
|
13
13
|
|
|
14
14
|
export class InventoryEntryRepository extends AbstractResourceRepository<"inventory-entry"> {
|
|
15
|
-
constructor(
|
|
16
|
-
super("inventory-entry",
|
|
17
|
-
this.actions = new InventoryEntryUpdateHandler(storage);
|
|
15
|
+
constructor(config: Config) {
|
|
16
|
+
super("inventory-entry", config);
|
|
17
|
+
this.actions = new InventoryEntryUpdateHandler(config.storage);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
create(
|
|
@@ -4,12 +4,17 @@ import type {
|
|
|
4
4
|
OrderImportDraft,
|
|
5
5
|
} from "@commercetools/platform-sdk";
|
|
6
6
|
import { describe, expect, test } from "vitest";
|
|
7
|
+
import type { Config } from "~src/config";
|
|
7
8
|
import { InMemoryStorage } from "~src/storage";
|
|
8
9
|
import { OrderRepository } from "./index";
|
|
9
10
|
|
|
10
11
|
describe("Order repository", () => {
|
|
11
12
|
const storage = new InMemoryStorage();
|
|
12
|
-
const
|
|
13
|
+
const config: Config = {
|
|
14
|
+
storage,
|
|
15
|
+
strict: false,
|
|
16
|
+
};
|
|
17
|
+
const repository = new OrderRepository(config);
|
|
13
18
|
|
|
14
19
|
test("create from cart", async () => {
|
|
15
20
|
const cart: Cart = {
|
|
@@ -14,9 +14,9 @@ import type {
|
|
|
14
14
|
ProductVariant,
|
|
15
15
|
} from "@commercetools/platform-sdk";
|
|
16
16
|
import assert from "assert";
|
|
17
|
+
import type { Config } from "~src/config";
|
|
17
18
|
import { CommercetoolsError } from "~src/exceptions";
|
|
18
19
|
import { generateRandomString, getBaseResourceProperties } from "~src/helpers";
|
|
19
|
-
import type { AbstractStorage } from "~src/storage/abstract";
|
|
20
20
|
import type { RepositoryContext } from "../abstract";
|
|
21
21
|
import { AbstractResourceRepository, type QueryParams } from "../abstract";
|
|
22
22
|
import {
|
|
@@ -30,9 +30,9 @@ import {
|
|
|
30
30
|
import { OrderUpdateHandler } from "./actions";
|
|
31
31
|
|
|
32
32
|
export class OrderRepository extends AbstractResourceRepository<"order"> {
|
|
33
|
-
constructor(
|
|
34
|
-
super("order",
|
|
35
|
-
this.actions = new OrderUpdateHandler(storage);
|
|
33
|
+
constructor(config: Config) {
|
|
34
|
+
super("order", config);
|
|
35
|
+
this.actions = new OrderUpdateHandler(config.storage);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
create(context: RepositoryContext, draft: OrderFromCartDraft): Order {
|
|
@@ -3,14 +3,14 @@ import type {
|
|
|
3
3
|
OrderEditDraft,
|
|
4
4
|
OrderEditResult,
|
|
5
5
|
} from "@commercetools/platform-sdk";
|
|
6
|
-
import type {
|
|
6
|
+
import type { Config } from "~src/config";
|
|
7
7
|
import { getBaseResourceProperties } from "../helpers";
|
|
8
8
|
import type { RepositoryContext } from "./abstract";
|
|
9
9
|
import { AbstractResourceRepository } from "./abstract";
|
|
10
10
|
|
|
11
11
|
export class OrderEditRepository extends AbstractResourceRepository<"order-edit"> {
|
|
12
|
-
constructor(
|
|
13
|
-
super("order-edit",
|
|
12
|
+
constructor(config: Config) {
|
|
13
|
+
super("order-edit", config);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
create(context: RepositoryContext, draft: OrderEditDraft): OrderEdit {
|
|
@@ -3,8 +3,8 @@ import type {
|
|
|
3
3
|
PaymentDraft,
|
|
4
4
|
StateReference,
|
|
5
5
|
} from "@commercetools/platform-sdk";
|
|
6
|
+
import type { Config } from "~src/config";
|
|
6
7
|
import { getBaseResourceProperties } from "~src/helpers";
|
|
7
|
-
import type { AbstractStorage } from "~src/storage/abstract";
|
|
8
8
|
import type { RepositoryContext } from "../abstract";
|
|
9
9
|
import { AbstractResourceRepository } from "../abstract";
|
|
10
10
|
import {
|
|
@@ -16,8 +16,8 @@ import { PaymentUpdateHandler } from "./actions";
|
|
|
16
16
|
import { transactionFromTransactionDraft } from "./helpers";
|
|
17
17
|
|
|
18
18
|
export class PaymentRepository extends AbstractResourceRepository<"payment"> {
|
|
19
|
-
constructor(
|
|
20
|
-
super("payment",
|
|
19
|
+
constructor(config: Config) {
|
|
20
|
+
super("payment", config);
|
|
21
21
|
this.actions = new PaymentUpdateHandler(this._storage);
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -10,10 +10,10 @@ import type {
|
|
|
10
10
|
StateReference,
|
|
11
11
|
TaxCategoryReference,
|
|
12
12
|
} from "@commercetools/platform-sdk";
|
|
13
|
+
import type { Config } from "~src/config";
|
|
13
14
|
import { CommercetoolsError } from "~src/exceptions";
|
|
14
15
|
import { getBaseResourceProperties } from "~src/helpers";
|
|
15
16
|
import { ProductSearch } from "~src/product-search";
|
|
16
|
-
import type { AbstractStorage } from "~src/storage/abstract";
|
|
17
17
|
import type { RepositoryContext } from "../abstract";
|
|
18
18
|
import { AbstractResourceRepository } from "../abstract";
|
|
19
19
|
import { getReferenceFromResourceIdentifier } from "../helpers";
|
|
@@ -23,10 +23,10 @@ import { variantFromDraft } from "./helpers";
|
|
|
23
23
|
export class ProductRepository extends AbstractResourceRepository<"product"> {
|
|
24
24
|
protected _searchService: ProductSearch;
|
|
25
25
|
|
|
26
|
-
constructor(
|
|
27
|
-
super("product",
|
|
28
|
-
this.actions = new ProductUpdateHandler(storage);
|
|
29
|
-
this._searchService = new ProductSearch(
|
|
26
|
+
constructor(config: Config) {
|
|
27
|
+
super("product", config);
|
|
28
|
+
this.actions = new ProductUpdateHandler(config.storage);
|
|
29
|
+
this._searchService = new ProductSearch(config);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
create(context: RepositoryContext, draft: ProductDraft): Product {
|
|
@@ -42,8 +42,12 @@ export class ProductRepository extends AbstractResourceRepository<"product"> {
|
|
|
42
42
|
this._storage,
|
|
43
43
|
);
|
|
44
44
|
} catch (err) {
|
|
45
|
+
if (this.config.strict) {
|
|
46
|
+
throw err;
|
|
47
|
+
}
|
|
48
|
+
|
|
45
49
|
// For now accept missing product types (but warn)
|
|
46
|
-
|
|
50
|
+
process.emitWarning(
|
|
47
51
|
`Error resolving product-type '${draft.productType.id}'. This will be throw an error in later releases.`,
|
|
48
52
|
);
|
|
49
53
|
productType = {
|
|
@@ -18,16 +18,16 @@ import type {
|
|
|
18
18
|
ProductDiscountValueExternal,
|
|
19
19
|
ProductDiscountValueRelative,
|
|
20
20
|
} from "@commercetools/platform-sdk";
|
|
21
|
+
import type { Config } from "~src/config";
|
|
21
22
|
import { getBaseResourceProperties } from "../helpers";
|
|
22
|
-
import type { AbstractStorage } from "../storage/abstract";
|
|
23
23
|
import type { Writable } from "../types";
|
|
24
24
|
import type { RepositoryContext, UpdateHandlerInterface } from "./abstract";
|
|
25
25
|
import { AbstractResourceRepository, AbstractUpdateHandler } from "./abstract";
|
|
26
26
|
import { createTypedMoney } from "./helpers";
|
|
27
27
|
|
|
28
28
|
export class ProductDiscountRepository extends AbstractResourceRepository<"product-discount"> {
|
|
29
|
-
constructor(
|
|
30
|
-
super("product-discount",
|
|
29
|
+
constructor(config: Config) {
|
|
30
|
+
super("product-discount", config);
|
|
31
31
|
this.actions = new ProductDiscountUpdateHandler(this._storage);
|
|
32
32
|
}
|
|
33
33
|
|
|
@@ -4,11 +4,11 @@ import type {
|
|
|
4
4
|
ProductProjection,
|
|
5
5
|
QueryParam,
|
|
6
6
|
} from "@commercetools/platform-sdk";
|
|
7
|
+
import type { Config } from "~src/config";
|
|
7
8
|
import { CommercetoolsError } from "~src/exceptions";
|
|
8
9
|
import { parseQueryExpression } from "../lib/predicateParser";
|
|
9
10
|
import { applyPriceSelector } from "../priceSelector";
|
|
10
11
|
import { ProductProjectionSearch } from "../product-projection-search";
|
|
11
|
-
import { type AbstractStorage } from "../storage";
|
|
12
12
|
import type { GetParams, RepositoryContext } from "./abstract";
|
|
13
13
|
import { AbstractResourceRepository } from "./abstract";
|
|
14
14
|
|
|
@@ -32,9 +32,9 @@ export type ProductProjectionQueryParams = {
|
|
|
32
32
|
export class ProductProjectionRepository extends AbstractResourceRepository<"product-projection"> {
|
|
33
33
|
protected _searchService: ProductProjectionSearch;
|
|
34
34
|
|
|
35
|
-
constructor(
|
|
36
|
-
super("product-projection",
|
|
37
|
-
this._searchService = new ProductProjectionSearch(
|
|
35
|
+
constructor(config: Config) {
|
|
36
|
+
super("product-projection", config);
|
|
37
|
+
this._searchService = new ProductProjectionSearch(config);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
create(context: RepositoryContext, draft: ProductDraft): ProductProjection {
|
|
@@ -2,17 +2,19 @@ import type {
|
|
|
2
2
|
ProductSelection,
|
|
3
3
|
ProductSelectionChangeNameAction,
|
|
4
4
|
ProductSelectionDraft,
|
|
5
|
+
ProductSelectionSetCustomTypeAction,
|
|
5
6
|
ProductSelectionUpdateAction,
|
|
6
7
|
} from "@commercetools/platform-sdk";
|
|
8
|
+
import type { Config } from "~src/config";
|
|
9
|
+
import { createCustomFields } from "~src/repositories/helpers";
|
|
7
10
|
import { getBaseResourceProperties } from "../helpers";
|
|
8
|
-
import type { AbstractStorage } from "../storage/abstract";
|
|
9
11
|
import type { Writable } from "../types";
|
|
10
12
|
import type { RepositoryContext, UpdateHandlerInterface } from "./abstract";
|
|
11
13
|
import { AbstractResourceRepository, AbstractUpdateHandler } from "./abstract";
|
|
12
14
|
|
|
13
15
|
export class ProductSelectionRepository extends AbstractResourceRepository<"product-selection"> {
|
|
14
|
-
constructor(
|
|
15
|
-
super("product-selection",
|
|
16
|
+
constructor(config: Config) {
|
|
17
|
+
super("product-selection", config);
|
|
16
18
|
this.actions = new ProductSelectionUpdateHandler(this._storage);
|
|
17
19
|
}
|
|
18
20
|
|
|
@@ -45,4 +47,20 @@ class ProductSelectionUpdateHandler
|
|
|
45
47
|
) {
|
|
46
48
|
resource.name = name;
|
|
47
49
|
}
|
|
50
|
+
|
|
51
|
+
setCustomType(
|
|
52
|
+
context: RepositoryContext,
|
|
53
|
+
resource: Writable<ProductSelection>,
|
|
54
|
+
{ type, fields }: ProductSelectionSetCustomTypeAction,
|
|
55
|
+
) {
|
|
56
|
+
if (type) {
|
|
57
|
+
resource.custom = createCustomFields(
|
|
58
|
+
{ type, fields },
|
|
59
|
+
context.projectKey,
|
|
60
|
+
this._storage,
|
|
61
|
+
);
|
|
62
|
+
} else {
|
|
63
|
+
resource.custom = undefined;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
48
66
|
}
|
|
@@ -2,13 +2,13 @@ import type {
|
|
|
2
2
|
ProductTailoring,
|
|
3
3
|
ProductTailoringUpdateAction,
|
|
4
4
|
} from "@commercetools/platform-sdk";
|
|
5
|
-
import type {
|
|
5
|
+
import type { Config } from "~src/config";
|
|
6
6
|
import type { RepositoryContext, UpdateHandlerInterface } from "./abstract";
|
|
7
7
|
import { AbstractResourceRepository, AbstractUpdateHandler } from "./abstract";
|
|
8
8
|
|
|
9
9
|
export class ProductTailoringRepository extends AbstractResourceRepository<"product-tailoring"> {
|
|
10
|
-
constructor(
|
|
11
|
-
super("product-tailoring",
|
|
10
|
+
constructor(config: Config) {
|
|
11
|
+
super("product-tailoring", config);
|
|
12
12
|
this.actions = new ProductTailoringUpdateHandler(this._storage);
|
|
13
13
|
}
|
|
14
14
|
|
|
@@ -12,16 +12,16 @@ import type {
|
|
|
12
12
|
ProductTypeRemoveEnumValuesAction,
|
|
13
13
|
ProductTypeUpdateAction,
|
|
14
14
|
} from "@commercetools/platform-sdk";
|
|
15
|
+
import type { Config } from "~src/config";
|
|
15
16
|
import { getBaseResourceProperties } from "../helpers";
|
|
16
|
-
import type { AbstractStorage } from "../storage/abstract";
|
|
17
17
|
import type { Writable } from "../types";
|
|
18
18
|
import type { RepositoryContext, UpdateHandlerInterface } from "./abstract";
|
|
19
19
|
import { AbstractResourceRepository, AbstractUpdateHandler } from "./abstract";
|
|
20
20
|
|
|
21
21
|
export class ProductTypeRepository extends AbstractResourceRepository<"product-type"> {
|
|
22
|
-
constructor(
|
|
23
|
-
super("product-type",
|
|
24
|
-
this.actions = new ProductTypeUpdateHandler(storage);
|
|
22
|
+
constructor(config: Config) {
|
|
23
|
+
super("product-type", config);
|
|
24
|
+
this.actions = new ProductTypeUpdateHandler(config.storage);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
create(context: RepositoryContext, draft: ProductTypeDraft): ProductType {
|
|
@@ -16,16 +16,16 @@ import type {
|
|
|
16
16
|
ProjectUpdateAction,
|
|
17
17
|
} from "@commercetools/platform-sdk";
|
|
18
18
|
import type { ProjectSetBusinessUnitAssociateRoleOnCreationAction } from "@commercetools/platform-sdk/dist/declarations/src/generated/models/project";
|
|
19
|
+
import type { Config } from "~src/config";
|
|
19
20
|
import { maskSecretValue } from "../lib/masking";
|
|
20
|
-
import type { AbstractStorage } from "../storage/abstract";
|
|
21
21
|
import type { Writable } from "../types";
|
|
22
22
|
import type { RepositoryContext, UpdateHandlerInterface } from "./abstract";
|
|
23
23
|
import { AbstractRepository, AbstractUpdateHandler } from "./abstract";
|
|
24
24
|
|
|
25
25
|
export class ProjectRepository extends AbstractRepository<Project> {
|
|
26
|
-
constructor(
|
|
27
|
-
super(
|
|
28
|
-
this.actions = new ProjectUpdateHandler(storage);
|
|
26
|
+
constructor(config: Config) {
|
|
27
|
+
super(config);
|
|
28
|
+
this.actions = new ProjectUpdateHandler(config.storage);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
get(context: RepositoryContext): Project | null {
|
|
@@ -2,13 +2,13 @@ import type {
|
|
|
2
2
|
QuoteRequest,
|
|
3
3
|
QuoteRequestDraft,
|
|
4
4
|
} from "@commercetools/platform-sdk";
|
|
5
|
-
import type {
|
|
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 QuoteRequestRepository extends AbstractResourceRepository<"quote-request"> {
|
|
10
|
-
constructor(
|
|
11
|
-
super("quote-request",
|
|
10
|
+
constructor(config: Config) {
|
|
11
|
+
super("quote-request", config);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
create(context: RepositoryContext, draft: QuoteRequestDraft): QuoteRequest {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Quote, QuoteDraft } from "@commercetools/platform-sdk";
|
|
2
|
-
import type {
|
|
2
|
+
import type { Config } from "~src/config";
|
|
3
3
|
import type { RepositoryContext } from "./abstract";
|
|
4
4
|
import { AbstractResourceRepository } from "./abstract";
|
|
5
5
|
|
|
6
6
|
export class QuoteRepository extends AbstractResourceRepository<"quote"> {
|
|
7
|
-
constructor(
|
|
8
|
-
super("quote",
|
|
7
|
+
constructor(config: Config) {
|
|
8
|
+
super("quote", config);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
create(context: RepositoryContext, draft: QuoteDraft): Quote {
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
type ReviewDraft,
|
|
8
8
|
type StateReference,
|
|
9
9
|
} from "@commercetools/platform-sdk";
|
|
10
|
-
import type {
|
|
10
|
+
import type { Config } from "~src/config";
|
|
11
11
|
import { getBaseResourceProperties } from "../helpers";
|
|
12
12
|
import type { RepositoryContext } from "./abstract";
|
|
13
13
|
import { AbstractResourceRepository } from "./abstract";
|
|
@@ -17,8 +17,8 @@ import {
|
|
|
17
17
|
} from "./helpers";
|
|
18
18
|
|
|
19
19
|
export class ReviewRepository extends AbstractResourceRepository<"review"> {
|
|
20
|
-
constructor(
|
|
21
|
-
super("review",
|
|
20
|
+
constructor(config: Config) {
|
|
21
|
+
super("review", config);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
create(context: RepositoryContext, draft: ReviewDraft): Review {
|
|
@@ -5,9 +5,9 @@ import {
|
|
|
5
5
|
type ZoneRateDraft,
|
|
6
6
|
type ZoneReference,
|
|
7
7
|
} from "@commercetools/platform-sdk";
|
|
8
|
+
import type { Config } from "~src/config";
|
|
8
9
|
import { getBaseResourceProperties } from "../../helpers";
|
|
9
10
|
import { getShippingMethodsMatchingCart } from "../../shipping";
|
|
10
|
-
import type { AbstractStorage } from "../../storage/abstract";
|
|
11
11
|
import type { GetParams, RepositoryContext } from "../abstract";
|
|
12
12
|
import { AbstractResourceRepository } from "../abstract";
|
|
13
13
|
import {
|
|
@@ -18,9 +18,9 @@ import { ShippingMethodUpdateHandler } from "./actions";
|
|
|
18
18
|
import { transformShippingRate } from "./helpers";
|
|
19
19
|
|
|
20
20
|
export class ShippingMethodRepository extends AbstractResourceRepository<"shipping-method"> {
|
|
21
|
-
constructor(
|
|
22
|
-
super("shipping-method",
|
|
23
|
-
this.actions = new ShippingMethodUpdateHandler(storage);
|
|
21
|
+
constructor(config: Config) {
|
|
22
|
+
super("shipping-method", config);
|
|
23
|
+
this.actions = new ShippingMethodUpdateHandler(config.storage);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
create(
|
|
@@ -6,8 +6,8 @@ import type {
|
|
|
6
6
|
ShoppingListDraft,
|
|
7
7
|
ShoppingListLineItem,
|
|
8
8
|
} from "@commercetools/platform-sdk";
|
|
9
|
+
import type { Config } from "~src/config";
|
|
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 } from "../abstract";
|
|
13
13
|
import { AbstractResourceRepository } from "../abstract";
|
|
@@ -19,9 +19,9 @@ import {
|
|
|
19
19
|
import { ShoppingListUpdateHandler } from "./actions";
|
|
20
20
|
|
|
21
21
|
export class ShoppingListRepository extends AbstractResourceRepository<"shopping-list"> {
|
|
22
|
-
constructor(
|
|
23
|
-
super("shopping-list",
|
|
24
|
-
this.actions = new ShoppingListUpdateHandler(storage);
|
|
22
|
+
constructor(config: Config) {
|
|
23
|
+
super("shopping-list", config);
|
|
24
|
+
this.actions = new ShoppingListUpdateHandler(config.storage);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
create(context: RepositoryContext, draft: ShoppingListDraft): ShoppingList {
|