@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.
- package/dist/{index.d.ts → index.d.mts} +154 -275
- package/dist/{index.js → index.mjs} +255 -359
- package/dist/index.mjs.map +1 -0
- package/package.json +30 -18
- package/src/config.ts +1 -1
- package/src/ctMock.test.ts +1 -1
- package/src/ctMock.ts +22 -21
- package/src/index.test.ts +1 -1
- package/src/index.ts +3 -3
- package/src/lib/haversine.test.ts +2 -2
- package/src/lib/masking.ts +1 -1
- package/src/lib/parser.ts +2 -2
- package/src/lib/password.ts +1 -1
- package/src/lib/predicateParser.test.ts +1 -1
- package/src/lib/predicateParser.ts +4 -4
- package/src/lib/product-review-statistics.test.ts +4 -8
- package/src/lib/productSearchFilter.test.ts +3 -3
- package/src/lib/productSearchFilter.ts +6 -6
- package/src/lib/projectionSearchFilter.test.ts +3 -3
- package/src/lib/projectionSearchFilter.ts +4 -4
- package/src/lib/review-statistics.ts +1 -1
- package/src/lib/searchQueryTypeChecker.test.ts +3 -3
- package/src/lib/searchQueryTypeChecker.ts +8 -4
- package/src/lib/tax.test.ts +3 -3
- package/src/lib/tax.ts +3 -3
- package/src/oauth/server.test.ts +7 -7
- package/src/oauth/server.ts +7 -7
- package/src/priceSelector.test.ts +1 -1
- package/src/priceSelector.ts +2 -2
- package/src/product-projection-search.ts +10 -12
- package/src/product-search-availability.test.ts +1 -1
- package/src/product-search.ts +6 -7
- package/src/projectAPI.test.ts +1 -1
- package/src/projectAPI.ts +7 -7
- package/src/repositories/abstract.ts +8 -10
- package/src/repositories/as-associate.test.ts +4 -4
- package/src/repositories/as-associate.ts +3 -3
- package/src/repositories/associate-role.ts +7 -9
- package/src/repositories/attribute-group.test.ts +3 -3
- package/src/repositories/attribute-group.ts +5 -5
- package/src/repositories/business-unit.test.ts +6 -6
- package/src/repositories/business-unit.ts +23 -28
- package/src/repositories/cart/actions.ts +12 -15
- package/src/repositories/cart/helpers.ts +5 -5
- package/src/repositories/cart/index.test.ts +5 -10
- package/src/repositories/cart/index.ts +13 -18
- package/src/repositories/cart-discount/actions.ts +5 -6
- package/src/repositories/cart-discount/index.ts +5 -5
- package/src/repositories/category/actions.ts +4 -4
- package/src/repositories/category/index.test.ts +3 -3
- package/src/repositories/category/index.ts +8 -8
- package/src/repositories/channel.test.ts +4 -4
- package/src/repositories/channel.ts +6 -6
- package/src/repositories/custom-object.ts +11 -8
- package/src/repositories/customer/actions.ts +11 -14
- package/src/repositories/customer/index.test.ts +3 -3
- package/src/repositories/customer/index.ts +12 -9
- package/src/repositories/customer-group.test.ts +4 -4
- package/src/repositories/customer-group.ts +6 -6
- package/src/repositories/discount-code/actions.ts +4 -4
- package/src/repositories/discount-code/index.ts +5 -5
- package/src/repositories/discount-group/actions.ts +3 -4
- package/src/repositories/discount-group/index.ts +4 -4
- package/src/repositories/errors.ts +1 -1
- package/src/repositories/extension.test.ts +3 -3
- package/src/repositories/extension.ts +6 -6
- package/src/repositories/helpers.test.ts +25 -0
- package/src/repositories/helpers.ts +14 -12
- package/src/repositories/index.test.ts +3 -3
- package/src/repositories/index.ts +43 -43
- package/src/repositories/inventory-entry/actions.ts +15 -3
- package/src/repositories/inventory-entry/index.ts +5 -5
- package/src/repositories/my-customer.ts +5 -5
- package/src/repositories/my-order.ts +2 -2
- package/src/repositories/my-quote-request.ts +1 -1
- package/src/repositories/order/actions.ts +8 -9
- package/src/repositories/order/index.test.ts +8 -9
- package/src/repositories/order/index.ts +16 -17
- package/src/repositories/order-edit.ts +4 -4
- package/src/repositories/payment/actions.ts +6 -6
- package/src/repositories/payment/helpers.ts +3 -3
- package/src/repositories/payment/index.ts +7 -7
- package/src/repositories/product/actions.ts +7 -7
- package/src/repositories/product/helpers.ts +4 -4
- package/src/repositories/product/index.ts +13 -13
- package/src/repositories/product-discount.ts +9 -6
- package/src/repositories/product-projection.ts +7 -7
- package/src/repositories/product-selection.ts +9 -6
- package/src/repositories/product-tailoring.ts +6 -3
- package/src/repositories/product-type.ts +8 -5
- package/src/repositories/project.ts +5 -5
- package/src/repositories/quote/actions.ts +6 -6
- package/src/repositories/quote/index.ts +5 -5
- package/src/repositories/quote-request/actions.ts +6 -6
- package/src/repositories/quote-request/index.test.ts +3 -3
- package/src/repositories/quote-request/index.ts +5 -5
- package/src/repositories/quote-staged/actions.ts +6 -6
- package/src/repositories/quote-staged/index.ts +5 -5
- package/src/repositories/recurrence-policy/actions.ts +3 -3
- package/src/repositories/recurrence-policy/index.ts +4 -8
- package/src/repositories/recurring-order/actions.ts +3 -3
- package/src/repositories/recurring-order/index.ts +5 -5
- package/src/repositories/review.test.ts +5 -5
- package/src/repositories/review.ts +10 -9
- package/src/repositories/shipping-method/actions.ts +7 -9
- package/src/repositories/shipping-method/helpers.ts +1 -1
- package/src/repositories/shipping-method/index.ts +8 -8
- package/src/repositories/shopping-list/actions.ts +5 -5
- package/src/repositories/shopping-list/index.ts +7 -7
- package/src/repositories/standalone-price.ts +9 -6
- package/src/repositories/state.ts +9 -6
- package/src/repositories/store.ts +10 -7
- package/src/repositories/subscription.test.ts +3 -3
- package/src/repositories/subscription.ts +9 -6
- package/src/repositories/tax-category/actions.ts +4 -4
- package/src/repositories/tax-category/index.ts +6 -6
- package/src/repositories/type/actions.ts +4 -4
- package/src/repositories/type/index.ts +5 -5
- package/src/repositories/zone.test.ts +3 -3
- package/src/repositories/zone.ts +8 -5
- package/src/server.ts +4 -3
- package/src/services/abstract.ts +5 -5
- package/src/services/as-associate-cart.test.ts +1 -1
- package/src/services/as-associate-cart.ts +2 -2
- package/src/services/as-associate-order.test.ts +1 -1
- package/src/services/as-associate-order.ts +2 -2
- package/src/services/as-associate-quote-request.ts +2 -3
- package/src/services/as-associate.test.ts +1 -1
- package/src/services/as-associate.ts +4 -4
- package/src/services/associate-roles.test.ts +1 -1
- package/src/services/associate-roles.ts +2 -2
- package/src/services/attribute-group.test.ts +1 -1
- package/src/services/attribute-group.ts +2 -2
- package/src/services/business-units.test.ts +5 -5
- package/src/services/business-units.ts +2 -2
- package/src/services/cart-discount.ts +2 -2
- package/src/services/cart.test.ts +7 -3
- package/src/services/cart.ts +4 -5
- package/src/services/category.test.ts +1 -1
- package/src/services/category.ts +2 -2
- package/src/services/channel.test.ts +1 -1
- package/src/services/channel.ts +2 -2
- package/src/services/custom-object.test.ts +2 -2
- package/src/services/custom-object.ts +3 -3
- package/src/services/customer-group.test.ts +1 -1
- package/src/services/customer-group.ts +2 -2
- package/src/services/customer.test.ts +3 -3
- package/src/services/customer.ts +4 -5
- package/src/services/discount-code.test.ts +1 -1
- package/src/services/discount-code.ts +2 -2
- package/src/services/discount-group.test.ts +1 -1
- package/src/services/discount-group.ts +2 -2
- package/src/services/extension.test.ts +1 -1
- package/src/services/extension.ts +2 -2
- package/src/services/index.ts +44 -44
- package/src/services/inventory-entry.test.ts +16 -1
- package/src/services/inventory-entry.ts +2 -2
- package/src/services/my-business-unit.test.ts +1 -1
- package/src/services/my-business-unit.ts +2 -2
- package/src/services/my-cart.test.ts +1 -1
- package/src/services/my-cart.ts +2 -2
- package/src/services/my-customer.test.ts +2 -2
- package/src/services/my-customer.ts +6 -6
- package/src/services/my-order.ts +2 -2
- package/src/services/my-payment.test.ts +1 -1
- package/src/services/my-payment.ts +2 -2
- package/src/services/my-shopping-list.ts +2 -2
- package/src/services/order.test.ts +4 -11
- package/src/services/order.ts +4 -4
- package/src/services/payment.test.ts +1 -1
- package/src/services/payment.ts +2 -2
- package/src/services/product-discount.test.ts +1 -1
- package/src/services/product-discount.ts +2 -2
- package/src/services/product-projection.test.ts +2 -2
- package/src/services/product-projection.ts +4 -4
- package/src/services/product-selection.test.ts +1 -1
- package/src/services/product-selection.ts +2 -2
- package/src/services/product-type.test.ts +1 -1
- package/src/services/product-type.ts +2 -2
- package/src/services/product.test.ts +1 -1
- package/src/services/product.ts +3 -3
- package/src/services/project.test.ts +1 -1
- package/src/services/project.ts +4 -4
- package/src/services/quote-request.test.ts +2 -2
- package/src/services/quote-request.ts +2 -2
- package/src/services/quote-staged.ts +2 -2
- package/src/services/quote.ts +2 -2
- package/src/services/recurrence-policy.test.ts +1 -1
- package/src/services/recurrence-policy.ts +2 -2
- package/src/services/recurring-order.test.ts +1 -1
- package/src/services/recurring-order.ts +2 -2
- package/src/services/reviews.test.ts +1 -1
- package/src/services/reviews.ts +2 -2
- package/src/services/shipping-method.test.ts +2 -2
- package/src/services/shipping-method.ts +4 -4
- package/src/services/shopping-list.test.ts +1 -1
- package/src/services/shopping-list.ts +2 -2
- package/src/services/standalone-price.test.ts +1 -1
- package/src/services/standalone-price.ts +2 -2
- package/src/services/state.test.ts +1 -1
- package/src/services/state.ts +2 -2
- package/src/services/store.test.ts +1 -1
- package/src/services/store.ts +2 -2
- package/src/services/subscription.test.ts +1 -1
- package/src/services/subscription.ts +2 -2
- package/src/services/tax-category.test.ts +1 -1
- package/src/services/tax-category.ts +2 -2
- package/src/services/type.test.ts +1 -1
- package/src/services/type.ts +2 -2
- package/src/services/zone.test.ts +1 -1
- package/src/services/zone.ts +2 -2
- package/src/shipping.test.ts +1 -1
- package/src/shipping.ts +8 -8
- package/src/storage/abstract.ts +1 -1
- package/src/storage/in-memory.ts +15 -17
- package/src/storage/index.ts +2 -2
- package/src/testing/business-unit.ts +1 -2
- package/src/testing/customer.ts +1 -1
- package/src/testing/type.ts +1 -1
- package/src/types.ts +1 -1
- package/src/validate.ts +1 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
|
@@ -11,9 +11,9 @@ import type {
|
|
|
11
11
|
RecurringOrderTransitionStateAction,
|
|
12
12
|
RecurringOrderUpdateAction,
|
|
13
13
|
} from "@commercetools/platform-sdk";
|
|
14
|
-
import type { Writable } from "
|
|
15
|
-
import type { UpdateHandlerInterface } from "../abstract";
|
|
16
|
-
import { AbstractUpdateHandler, type RepositoryContext } from "../abstract";
|
|
14
|
+
import type { Writable } from "#src/types.ts";
|
|
15
|
+
import type { UpdateHandlerInterface } from "../abstract.ts";
|
|
16
|
+
import { AbstractUpdateHandler, type RepositoryContext } from "../abstract.ts";
|
|
17
17
|
|
|
18
18
|
export class RecurringOrderUpdateHandler
|
|
19
19
|
extends AbstractUpdateHandler
|
|
@@ -3,14 +3,14 @@ import type {
|
|
|
3
3
|
RecurringOrder,
|
|
4
4
|
RecurringOrderDraft,
|
|
5
5
|
} from "@commercetools/platform-sdk";
|
|
6
|
-
import type { Config } from "
|
|
7
|
-
import { getBaseResourceProperties } from "
|
|
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 { OrderRepository } from "../order";
|
|
13
|
-
import { RecurringOrderUpdateHandler } from "./actions";
|
|
11
|
+
} from "../abstract.ts";
|
|
12
|
+
import { OrderRepository } from "../order/index.ts";
|
|
13
|
+
import { RecurringOrderUpdateHandler } from "./actions.ts";
|
|
14
14
|
|
|
15
15
|
export class RecurringOrderRepository extends AbstractResourceRepository<"recurring-order"> {
|
|
16
16
|
constructor(config: Config) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
ReviewDraft,
|
|
3
3
|
ReviewSetAuthorNameAction,
|
|
4
|
+
ReviewSetCustomerAction,
|
|
4
5
|
ReviewSetCustomFieldAction,
|
|
5
6
|
ReviewSetCustomTypeAction,
|
|
6
|
-
ReviewSetCustomerAction,
|
|
7
7
|
ReviewSetKeyAction,
|
|
8
8
|
ReviewSetLocaleAction,
|
|
9
9
|
ReviewSetRatingAction,
|
|
@@ -13,10 +13,10 @@ import type {
|
|
|
13
13
|
ReviewTransitionStateAction,
|
|
14
14
|
} from "@commercetools/platform-sdk";
|
|
15
15
|
import { describe, expect, test } from "vitest";
|
|
16
|
-
import type { Config } from "
|
|
17
|
-
import { getBaseResourceProperties } from "
|
|
18
|
-
import { InMemoryStorage } from "
|
|
19
|
-
import { ReviewRepository } from "./review";
|
|
16
|
+
import type { Config } from "#src/config.ts";
|
|
17
|
+
import { getBaseResourceProperties } from "#src/helpers.ts";
|
|
18
|
+
import { InMemoryStorage } from "#src/storage/index.ts";
|
|
19
|
+
import { ReviewRepository } from "./review.ts";
|
|
20
20
|
|
|
21
21
|
describe("Review Repository", () => {
|
|
22
22
|
const storage = new InMemoryStorage();
|
|
@@ -2,14 +2,12 @@ import type {
|
|
|
2
2
|
ChannelReference,
|
|
3
3
|
CustomerReference,
|
|
4
4
|
ProductReference,
|
|
5
|
-
} from "@commercetools/platform-sdk";
|
|
6
|
-
import type {
|
|
7
5
|
Review,
|
|
8
6
|
ReviewDraft,
|
|
9
7
|
ReviewSetAuthorNameAction,
|
|
8
|
+
ReviewSetCustomerAction,
|
|
10
9
|
ReviewSetCustomFieldAction,
|
|
11
10
|
ReviewSetCustomTypeAction,
|
|
12
|
-
ReviewSetCustomerAction,
|
|
13
11
|
ReviewSetKeyAction,
|
|
14
12
|
ReviewSetLocaleAction,
|
|
15
13
|
ReviewSetRatingAction,
|
|
@@ -20,15 +18,18 @@ import type {
|
|
|
20
18
|
ReviewUpdateAction,
|
|
21
19
|
StateReference,
|
|
22
20
|
} from "@commercetools/platform-sdk";
|
|
23
|
-
import type { Config } from "
|
|
24
|
-
import { getBaseResourceProperties } from "../helpers";
|
|
25
|
-
import type { Writable } from "../types";
|
|
26
|
-
import type { RepositoryContext, UpdateHandlerInterface } from "./abstract";
|
|
27
|
-
import {
|
|
21
|
+
import type { Config } from "#src/config.ts";
|
|
22
|
+
import { getBaseResourceProperties } from "../helpers.ts";
|
|
23
|
+
import type { Writable } from "../types.ts";
|
|
24
|
+
import type { RepositoryContext, UpdateHandlerInterface } from "./abstract.ts";
|
|
25
|
+
import {
|
|
26
|
+
AbstractResourceRepository,
|
|
27
|
+
AbstractUpdateHandler,
|
|
28
|
+
} from "./abstract.ts";
|
|
28
29
|
import {
|
|
29
30
|
createCustomFields,
|
|
30
31
|
getReferenceFromResourceIdentifier,
|
|
31
|
-
} from "./helpers";
|
|
32
|
+
} from "./helpers.ts";
|
|
32
33
|
|
|
33
34
|
export class ReviewRepository extends AbstractResourceRepository<"review"> {
|
|
34
35
|
constructor(config: Config) {
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import { isDeepStrictEqual } from "node:util";
|
|
2
|
-
import type {
|
|
3
|
-
ShippingMethodChangeTaxCategoryAction,
|
|
4
|
-
ShippingMethodRemoveShippingRateAction,
|
|
5
|
-
} from "@commercetools/platform-sdk";
|
|
6
2
|
import type {
|
|
7
3
|
ShippingMethod,
|
|
8
4
|
ShippingMethodAddShippingRateAction,
|
|
@@ -10,6 +6,8 @@ import type {
|
|
|
10
6
|
ShippingMethodChangeActiveAction,
|
|
11
7
|
ShippingMethodChangeIsDefaultAction,
|
|
12
8
|
ShippingMethodChangeNameAction,
|
|
9
|
+
ShippingMethodChangeTaxCategoryAction,
|
|
10
|
+
ShippingMethodRemoveShippingRateAction,
|
|
13
11
|
ShippingMethodRemoveZoneAction,
|
|
14
12
|
ShippingMethodSetCustomFieldAction,
|
|
15
13
|
ShippingMethodSetCustomTypeAction,
|
|
@@ -21,14 +19,14 @@ import type {
|
|
|
21
19
|
ShippingMethodUpdateAction,
|
|
22
20
|
ZoneReference,
|
|
23
21
|
} from "@commercetools/platform-sdk";
|
|
24
|
-
import type { Writable } from "
|
|
25
|
-
import type { RepositoryContext, UpdateHandlerInterface } from "../abstract";
|
|
26
|
-
import { AbstractUpdateHandler } from "../abstract";
|
|
22
|
+
import type { Writable } from "#src/types.ts";
|
|
23
|
+
import type { RepositoryContext, UpdateHandlerInterface } from "../abstract.ts";
|
|
24
|
+
import { AbstractUpdateHandler } from "../abstract.ts";
|
|
27
25
|
import {
|
|
28
26
|
createCustomFields,
|
|
29
27
|
getReferenceFromResourceIdentifier,
|
|
30
|
-
} from "../helpers";
|
|
31
|
-
import { transformShippingRate } from "./helpers";
|
|
28
|
+
} from "../helpers.ts";
|
|
29
|
+
import { transformShippingRate } from "./helpers.ts";
|
|
32
30
|
|
|
33
31
|
export class ShippingMethodUpdateHandler
|
|
34
32
|
extends AbstractUpdateHandler
|
|
@@ -5,17 +5,17 @@ import type {
|
|
|
5
5
|
ZoneRateDraft,
|
|
6
6
|
ZoneReference,
|
|
7
7
|
} from "@commercetools/platform-sdk";
|
|
8
|
-
import type { Config } from "
|
|
9
|
-
import { getBaseResourceProperties } from "../../helpers";
|
|
10
|
-
import { getShippingMethodsMatchingCart } from "../../shipping";
|
|
11
|
-
import type { GetParams, RepositoryContext } from "../abstract";
|
|
12
|
-
import { AbstractResourceRepository } from "../abstract";
|
|
8
|
+
import type { Config } from "#src/config.ts";
|
|
9
|
+
import { getBaseResourceProperties } from "../../helpers.ts";
|
|
10
|
+
import { getShippingMethodsMatchingCart } from "../../shipping.ts";
|
|
11
|
+
import type { GetParams, RepositoryContext } from "../abstract.ts";
|
|
12
|
+
import { AbstractResourceRepository } from "../abstract.ts";
|
|
13
13
|
import {
|
|
14
14
|
createCustomFields,
|
|
15
15
|
getReferenceFromResourceIdentifier,
|
|
16
|
-
} from "../helpers";
|
|
17
|
-
import { ShippingMethodUpdateHandler } from "./actions";
|
|
18
|
-
import { transformShippingRate } from "./helpers";
|
|
16
|
+
} from "../helpers.ts";
|
|
17
|
+
import { ShippingMethodUpdateHandler } from "./actions.ts";
|
|
18
|
+
import { transformShippingRate } from "./helpers.ts";
|
|
19
19
|
|
|
20
20
|
export class ShippingMethodRepository extends AbstractResourceRepository<"shipping-method"> {
|
|
21
21
|
constructor(config: Config) {
|
|
@@ -9,9 +9,9 @@ import type {
|
|
|
9
9
|
ShoppingListLineItem,
|
|
10
10
|
ShoppingListRemoveLineItemAction,
|
|
11
11
|
ShoppingListSetAnonymousIdAction,
|
|
12
|
+
ShoppingListSetCustomerAction,
|
|
12
13
|
ShoppingListSetCustomFieldAction,
|
|
13
14
|
ShoppingListSetCustomTypeAction,
|
|
14
|
-
ShoppingListSetCustomerAction,
|
|
15
15
|
ShoppingListSetDeleteDaysAfterLastModificationAction,
|
|
16
16
|
ShoppingListSetDescriptionAction,
|
|
17
17
|
ShoppingListSetKeyAction,
|
|
@@ -20,10 +20,10 @@ import type {
|
|
|
20
20
|
ShoppingListUpdateAction,
|
|
21
21
|
} from "@commercetools/platform-sdk";
|
|
22
22
|
import { v4 as uuidv4 } from "uuid";
|
|
23
|
-
import { CommercetoolsError } from "
|
|
24
|
-
import type { Writable } from "../../types";
|
|
25
|
-
import type { RepositoryContext, UpdateHandlerInterface } from "../abstract";
|
|
26
|
-
import { AbstractUpdateHandler } from "../abstract";
|
|
23
|
+
import { CommercetoolsError } from "#src/exceptions.ts";
|
|
24
|
+
import type { Writable } from "../../types.ts";
|
|
25
|
+
import type { RepositoryContext, UpdateHandlerInterface } from "../abstract.ts";
|
|
26
|
+
import { AbstractUpdateHandler } from "../abstract.ts";
|
|
27
27
|
|
|
28
28
|
export class ShoppingListUpdateHandler
|
|
29
29
|
extends AbstractUpdateHandler
|
|
@@ -6,18 +6,18 @@ import type {
|
|
|
6
6
|
ShoppingListDraft,
|
|
7
7
|
ShoppingListLineItem,
|
|
8
8
|
} from "@commercetools/platform-sdk";
|
|
9
|
-
import type { Config } from "
|
|
10
|
-
import { getBaseResourceProperties } from "../../helpers";
|
|
11
|
-
import type { Writable } from "../../types";
|
|
12
|
-
import type { RepositoryContext } from "../abstract";
|
|
13
|
-
import { AbstractResourceRepository } from "../abstract";
|
|
9
|
+
import type { Config } from "#src/config.ts";
|
|
10
|
+
import { getBaseResourceProperties } from "../../helpers.ts";
|
|
11
|
+
import type { Writable } from "../../types.ts";
|
|
12
|
+
import type { RepositoryContext } from "../abstract.ts";
|
|
13
|
+
import { AbstractResourceRepository } from "../abstract.ts";
|
|
14
14
|
import {
|
|
15
15
|
createCustomFields,
|
|
16
16
|
getBusinessUnitKeyReference,
|
|
17
17
|
getReferenceFromResourceIdentifier,
|
|
18
18
|
getStoreKeyReference,
|
|
19
|
-
} from "../helpers";
|
|
20
|
-
import { ShoppingListUpdateHandler } from "./actions";
|
|
19
|
+
} from "../helpers.ts";
|
|
20
|
+
import { ShoppingListUpdateHandler } from "./actions.ts";
|
|
21
21
|
|
|
22
22
|
export class ShoppingListRepository extends AbstractResourceRepository<"shopping-list"> {
|
|
23
23
|
constructor(config: Config) {
|
|
@@ -9,12 +9,15 @@ import type {
|
|
|
9
9
|
StandalonePriceSetDiscountedPriceAction,
|
|
10
10
|
StandalonePriceUpdateAction,
|
|
11
11
|
} from "@commercetools/platform-sdk";
|
|
12
|
-
import type { Config } from "
|
|
13
|
-
import { getBaseResourceProperties } from "../helpers";
|
|
14
|
-
import type { Writable } from "../types";
|
|
15
|
-
import type { RepositoryContext, UpdateHandlerInterface } from "./abstract";
|
|
16
|
-
import {
|
|
17
|
-
|
|
12
|
+
import type { Config } from "#src/config.ts";
|
|
13
|
+
import { getBaseResourceProperties } from "../helpers.ts";
|
|
14
|
+
import type { Writable } from "../types.ts";
|
|
15
|
+
import type { RepositoryContext, UpdateHandlerInterface } from "./abstract.ts";
|
|
16
|
+
import {
|
|
17
|
+
AbstractResourceRepository,
|
|
18
|
+
AbstractUpdateHandler,
|
|
19
|
+
} from "./abstract.ts";
|
|
20
|
+
import { createTypedMoney } from "./helpers.ts";
|
|
18
21
|
|
|
19
22
|
export class StandAlonePriceRepository extends AbstractResourceRepository<"standalone-price"> {
|
|
20
23
|
constructor(config: Config) {
|
|
@@ -13,12 +13,15 @@ import type {
|
|
|
13
13
|
StateSetTransitionsAction,
|
|
14
14
|
StateUpdateAction,
|
|
15
15
|
} from "@commercetools/platform-sdk";
|
|
16
|
-
import type { Config } from "
|
|
17
|
-
import { getBaseResourceProperties } from "../helpers";
|
|
18
|
-
import type { Writable } from "../types";
|
|
19
|
-
import type { RepositoryContext, UpdateHandlerInterface } from "./abstract";
|
|
20
|
-
import {
|
|
21
|
-
|
|
16
|
+
import type { Config } from "#src/config.ts";
|
|
17
|
+
import { getBaseResourceProperties } from "../helpers.ts";
|
|
18
|
+
import type { Writable } from "../types.ts";
|
|
19
|
+
import type { RepositoryContext, UpdateHandlerInterface } from "./abstract.ts";
|
|
20
|
+
import {
|
|
21
|
+
AbstractResourceRepository,
|
|
22
|
+
AbstractUpdateHandler,
|
|
23
|
+
} from "./abstract.ts";
|
|
24
|
+
import { getReferenceFromResourceIdentifier } from "./helpers.ts";
|
|
22
25
|
|
|
23
26
|
export class StateRepository extends AbstractResourceRepository<"state"> {
|
|
24
27
|
constructor(config: Config) {
|
|
@@ -11,16 +11,19 @@ import type {
|
|
|
11
11
|
StoreSetNameAction,
|
|
12
12
|
StoreUpdateAction,
|
|
13
13
|
} from "@commercetools/platform-sdk";
|
|
14
|
-
import type { Config } from "
|
|
15
|
-
import { getBaseResourceProperties } from "../helpers";
|
|
16
|
-
import type { AbstractStorage } from "../storage/abstract";
|
|
17
|
-
import type { Writable } from "../types";
|
|
18
|
-
import type { RepositoryContext, UpdateHandlerInterface } from "./abstract";
|
|
19
|
-
import {
|
|
14
|
+
import type { Config } from "#src/config.ts";
|
|
15
|
+
import { getBaseResourceProperties } from "../helpers.ts";
|
|
16
|
+
import type { AbstractStorage } from "../storage/abstract.ts";
|
|
17
|
+
import type { Writable } from "../types.ts";
|
|
18
|
+
import type { RepositoryContext, UpdateHandlerInterface } from "./abstract.ts";
|
|
19
|
+
import {
|
|
20
|
+
AbstractResourceRepository,
|
|
21
|
+
AbstractUpdateHandler,
|
|
22
|
+
} from "./abstract.ts";
|
|
20
23
|
import {
|
|
21
24
|
createCustomFields,
|
|
22
25
|
getReferenceFromResourceIdentifier,
|
|
23
|
-
} from "./helpers";
|
|
26
|
+
} from "./helpers.ts";
|
|
24
27
|
|
|
25
28
|
export class StoreRepository extends AbstractResourceRepository<"store"> {
|
|
26
29
|
constructor(config: Config) {
|
|
@@ -3,9 +3,9 @@ import type {
|
|
|
3
3
|
SubscriptionSetKeyAction,
|
|
4
4
|
} from "@commercetools/platform-sdk";
|
|
5
5
|
import { describe, expect, test } from "vitest";
|
|
6
|
-
import type { Config } from "
|
|
7
|
-
import { InMemoryStorage } from "
|
|
8
|
-
import { SubscriptionRepository } from "./subscription";
|
|
6
|
+
import type { Config } from "#src/config.ts";
|
|
7
|
+
import { InMemoryStorage } from "#src/storage/index.ts";
|
|
8
|
+
import { SubscriptionRepository } from "./subscription.ts";
|
|
9
9
|
|
|
10
10
|
describe("Subscription Repository", () => {
|
|
11
11
|
const storage = new InMemoryStorage();
|
|
@@ -5,12 +5,15 @@ import type {
|
|
|
5
5
|
SubscriptionSetKeyAction,
|
|
6
6
|
SubscriptionUpdateAction,
|
|
7
7
|
} from "@commercetools/platform-sdk";
|
|
8
|
-
import type { Config } from "
|
|
9
|
-
import { CommercetoolsError } from "
|
|
10
|
-
import { getBaseResourceProperties } from "../helpers";
|
|
11
|
-
import type { Writable } from "../types";
|
|
12
|
-
import type { RepositoryContext, UpdateHandlerInterface } from "./abstract";
|
|
13
|
-
import {
|
|
8
|
+
import type { Config } from "#src/config.ts";
|
|
9
|
+
import { CommercetoolsError } from "#src/exceptions.ts";
|
|
10
|
+
import { getBaseResourceProperties } from "../helpers.ts";
|
|
11
|
+
import type { Writable } from "../types.ts";
|
|
12
|
+
import type { RepositoryContext, UpdateHandlerInterface } from "./abstract.ts";
|
|
13
|
+
import {
|
|
14
|
+
AbstractResourceRepository,
|
|
15
|
+
AbstractUpdateHandler,
|
|
16
|
+
} from "./abstract.ts";
|
|
14
17
|
|
|
15
18
|
export class SubscriptionRepository extends AbstractResourceRepository<"subscription"> {
|
|
16
19
|
constructor(config: Config) {
|
|
@@ -8,10 +8,10 @@ import type {
|
|
|
8
8
|
TaxCategorySetKeyAction,
|
|
9
9
|
TaxCategoryUpdateAction,
|
|
10
10
|
} from "@commercetools/platform-sdk";
|
|
11
|
-
import type { Writable } from "
|
|
12
|
-
import type { RepositoryContext } from "../abstract";
|
|
13
|
-
import { AbstractUpdateHandler } from "../abstract";
|
|
14
|
-
import { taxRateFromTaxRateDraft } from "./helpers";
|
|
11
|
+
import type { Writable } from "#src/types.ts";
|
|
12
|
+
import type { RepositoryContext } from "../abstract.ts";
|
|
13
|
+
import { AbstractUpdateHandler } from "../abstract.ts";
|
|
14
|
+
import { taxRateFromTaxRateDraft } from "./helpers.ts";
|
|
15
15
|
|
|
16
16
|
type TaxCategoryUpdateHandlerMethod<T> = (
|
|
17
17
|
context: RepositoryContext,
|
|
@@ -2,12 +2,12 @@ import type {
|
|
|
2
2
|
TaxCategory,
|
|
3
3
|
TaxCategoryDraft,
|
|
4
4
|
} from "@commercetools/platform-sdk";
|
|
5
|
-
import type { Config } from "
|
|
6
|
-
import { getBaseResourceProperties } from "
|
|
7
|
-
import type { RepositoryContext } from "../abstract";
|
|
8
|
-
import { AbstractResourceRepository } from "../abstract";
|
|
9
|
-
import { TaxCategoryUpdateHandler } from "./actions";
|
|
10
|
-
import { taxRateFromTaxRateDraft } from "./helpers";
|
|
5
|
+
import type { Config } from "#src/config.ts";
|
|
6
|
+
import { getBaseResourceProperties } from "#src/helpers.ts";
|
|
7
|
+
import type { RepositoryContext } from "../abstract.ts";
|
|
8
|
+
import { AbstractResourceRepository } from "../abstract.ts";
|
|
9
|
+
import { TaxCategoryUpdateHandler } from "./actions.ts";
|
|
10
|
+
import { taxRateFromTaxRateDraft } from "./helpers.ts";
|
|
11
11
|
|
|
12
12
|
export class TaxCategoryRepository extends AbstractResourceRepository<"tax-category"> {
|
|
13
13
|
constructor(config: Config) {
|
|
@@ -12,10 +12,10 @@ import type {
|
|
|
12
12
|
TypeSetDescriptionAction,
|
|
13
13
|
TypeUpdateAction,
|
|
14
14
|
} from "@commercetools/platform-sdk";
|
|
15
|
-
import { CommercetoolsError } from "
|
|
16
|
-
import type { Writable } from "
|
|
17
|
-
import type { RepositoryContext } from "../abstract";
|
|
18
|
-
import { AbstractUpdateHandler } from "../abstract";
|
|
15
|
+
import { CommercetoolsError } from "#src/exceptions.ts";
|
|
16
|
+
import type { Writable } from "#src/types.ts";
|
|
17
|
+
import type { RepositoryContext } from "../abstract.ts";
|
|
18
|
+
import { AbstractUpdateHandler } from "../abstract.ts";
|
|
19
19
|
|
|
20
20
|
type TypeUpdateHandlerMethod<T> = (
|
|
21
21
|
context: RepositoryContext,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Type, TypeDraft } from "@commercetools/platform-sdk";
|
|
2
|
-
import type { Config } from "
|
|
3
|
-
import { getBaseResourceProperties } from "
|
|
4
|
-
import type { RepositoryContext } from "../abstract";
|
|
5
|
-
import { AbstractResourceRepository } from "../abstract";
|
|
6
|
-
import { TypeUpdateHandler } from "./actions";
|
|
2
|
+
import type { Config } from "#src/config.ts";
|
|
3
|
+
import { getBaseResourceProperties } from "#src/helpers.ts";
|
|
4
|
+
import type { RepositoryContext } from "../abstract.ts";
|
|
5
|
+
import { AbstractResourceRepository } from "../abstract.ts";
|
|
6
|
+
import { TypeUpdateHandler } from "./actions.ts";
|
|
7
7
|
|
|
8
8
|
export class TypeRepository extends AbstractResourceRepository<"type"> {
|
|
9
9
|
constructor(config: Config) {
|
|
@@ -7,9 +7,9 @@ import type {
|
|
|
7
7
|
ZoneSetKeyAction,
|
|
8
8
|
} from "@commercetools/platform-sdk";
|
|
9
9
|
import { describe, expect, test } from "vitest";
|
|
10
|
-
import type { Config } from "
|
|
11
|
-
import { InMemoryStorage } from "
|
|
12
|
-
import { ZoneRepository } from "./zone";
|
|
10
|
+
import type { Config } from "#src/config.ts";
|
|
11
|
+
import { InMemoryStorage } from "#src/storage/index.ts";
|
|
12
|
+
import { ZoneRepository } from "./zone.ts";
|
|
13
13
|
|
|
14
14
|
describe("Zone Repository", () => {
|
|
15
15
|
const storage = new InMemoryStorage();
|
package/src/repositories/zone.ts
CHANGED
|
@@ -8,11 +8,14 @@ import type {
|
|
|
8
8
|
ZoneSetKeyAction,
|
|
9
9
|
ZoneUpdateAction,
|
|
10
10
|
} from "@commercetools/platform-sdk";
|
|
11
|
-
import type { Config } from "
|
|
12
|
-
import { getBaseResourceProperties } from "../helpers";
|
|
13
|
-
import type { Writable } from "../types";
|
|
14
|
-
import type { RepositoryContext, UpdateHandlerInterface } from "./abstract";
|
|
15
|
-
import {
|
|
11
|
+
import type { Config } from "#src/config.ts";
|
|
12
|
+
import { getBaseResourceProperties } from "../helpers.ts";
|
|
13
|
+
import type { Writable } from "../types.ts";
|
|
14
|
+
import type { RepositoryContext, UpdateHandlerInterface } from "./abstract.ts";
|
|
15
|
+
import {
|
|
16
|
+
AbstractResourceRepository,
|
|
17
|
+
AbstractUpdateHandler,
|
|
18
|
+
} from "./abstract.ts";
|
|
16
19
|
|
|
17
20
|
export class ZoneRepository extends AbstractResourceRepository<"zone"> {
|
|
18
21
|
constructor(config: Config) {
|
package/src/server.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { CommercetoolsMock } from "./index";
|
|
1
|
+
import { CommercetoolsMock } from "./index.ts";
|
|
2
2
|
|
|
3
3
|
process.on("SIGINT", () => {
|
|
4
|
-
console.info("Stopping server...");
|
|
5
4
|
process.exit();
|
|
6
5
|
});
|
|
7
6
|
|
|
@@ -10,6 +9,8 @@ const instance = new CommercetoolsMock();
|
|
|
10
9
|
let port = 3000;
|
|
11
10
|
|
|
12
11
|
if (process.env.HTTP_SERVER_PORT)
|
|
13
|
-
port = Number.parseInt(process.env.HTTP_SERVER_PORT);
|
|
12
|
+
port = Number.parseInt(process.env.HTTP_SERVER_PORT, 10);
|
|
14
13
|
|
|
14
|
+
// biome-ignore lint: lint/correctness/noConsoleLog
|
|
15
|
+
console.info("Starting commercetools-mock on http://localhost:" + port);
|
|
15
16
|
instance.runServer(port);
|
package/src/services/abstract.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { Update } from "@commercetools/platform-sdk";
|
|
2
2
|
import { type Request, type Response, Router } from "express";
|
|
3
3
|
import type { ParsedQs } from "qs";
|
|
4
|
-
import { updateRequestSchema } from "
|
|
5
|
-
import { validateData } from "
|
|
6
|
-
import { queryParamsArray } from "../helpers";
|
|
4
|
+
import { updateRequestSchema } from "#src/schemas/update-request.ts";
|
|
5
|
+
import { validateData } from "#src/validate.ts";
|
|
6
|
+
import { queryParamsArray } from "../helpers.ts";
|
|
7
7
|
import type {
|
|
8
8
|
AbstractResourceRepository,
|
|
9
9
|
QueryParams,
|
|
10
|
-
} from "../repositories/abstract";
|
|
11
|
-
import { getRepositoryContext } from "../repositories/helpers";
|
|
10
|
+
} from "../repositories/abstract.ts";
|
|
11
|
+
import { getRepositoryContext } from "../repositories/helpers.ts";
|
|
12
12
|
|
|
13
13
|
export default abstract class AbstractService {
|
|
14
14
|
public abstract repository: AbstractResourceRepository<any>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Router } from "express";
|
|
2
|
-
import type { CartRepository } from "../repositories/cart";
|
|
3
|
-
import AbstractService from "./abstract";
|
|
2
|
+
import type { CartRepository } from "../repositories/cart/index.ts";
|
|
3
|
+
import AbstractService from "./abstract.ts";
|
|
4
4
|
|
|
5
5
|
export class AsAssociateCartService extends AbstractService {
|
|
6
6
|
public repository: CartRepository;
|
|
@@ -2,7 +2,7 @@ import assert from "node:assert";
|
|
|
2
2
|
import type { Order } 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("Order Query", () => {
|
|
8
8
|
const ctMock = new CommercetoolsMock();
|
|
@@ -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 AsAssociateOrderService extends AbstractService {
|
|
6
6
|
public repository: MyOrderRepository;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Router } from "express";
|
|
2
|
-
import type { MyQuoteRequestRepository } from "
|
|
3
|
-
import
|
|
4
|
-
import AbstractService from "./abstract";
|
|
2
|
+
import type { MyQuoteRequestRepository } from "#src/repositories/my-quote-request.ts";
|
|
3
|
+
import AbstractService from "./abstract.ts";
|
|
5
4
|
|
|
6
5
|
export class AsAssociateQuoteRequestService extends AbstractService {
|
|
7
6
|
public repository: MyQuoteRequestRepository;
|
|
@@ -3,10 +3,10 @@ import type {
|
|
|
3
3
|
AsAssociateCartRepository,
|
|
4
4
|
AsAssociateOrderRepository,
|
|
5
5
|
AsAssociateQuoteRequestRepository,
|
|
6
|
-
} from "
|
|
7
|
-
import { AsAssociateCartService } from "./as-associate-cart";
|
|
8
|
-
import { AsAssociateOrderService } from "./as-associate-order";
|
|
9
|
-
import { AsAssociateQuoteRequestService } from "./as-associate-quote-request";
|
|
6
|
+
} from "#src/repositories/as-associate.ts";
|
|
7
|
+
import { AsAssociateCartService } from "./as-associate-cart.ts";
|
|
8
|
+
import { AsAssociateOrderService } from "./as-associate-order.ts";
|
|
9
|
+
import { AsAssociateQuoteRequestService } from "./as-associate-quote-request.ts";
|
|
10
10
|
|
|
11
11
|
type Repositories = {
|
|
12
12
|
cart: AsAssociateCartRepository;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AssociateRole } from "@commercetools/platform-sdk";
|
|
2
2
|
import supertest from "supertest";
|
|
3
3
|
import { afterEach, beforeEach, describe, expect, test } from "vitest";
|
|
4
|
-
import { CommercetoolsMock } from "../ctMock";
|
|
4
|
+
import { CommercetoolsMock } from "../ctMock.ts";
|
|
5
5
|
|
|
6
6
|
describe("Associate roles query", () => {
|
|
7
7
|
const ctMock = new CommercetoolsMock();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Router } from "express";
|
|
2
|
-
import type { AssociateRoleRepository } from "../repositories/associate-role";
|
|
3
|
-
import AbstractService from "./abstract";
|
|
2
|
+
import type { AssociateRoleRepository } from "../repositories/associate-role.ts";
|
|
3
|
+
import AbstractService from "./abstract.ts";
|
|
4
4
|
|
|
5
5
|
export class AssociateRoleServices extends AbstractService {
|
|
6
6
|
public repository: AssociateRoleRepository;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AttributeGroupDraft } 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 { AttributeGroupRepository } from "../repositories/attribute-group";
|
|
3
|
-
import AbstractService from "./abstract";
|
|
2
|
+
import type { AttributeGroupRepository } from "../repositories/attribute-group.ts";
|
|
3
|
+
import AbstractService from "./abstract.ts";
|
|
4
4
|
|
|
5
5
|
export class AttributeGroupService extends AbstractService {
|
|
6
6
|
public repository: AttributeGroupRepository;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { BusinessUnit
|
|
1
|
+
import type { BusinessUnit } from "@commercetools/platform-sdk";
|
|
2
2
|
import supertest from "supertest";
|
|
3
3
|
import { afterEach, beforeEach, describe, expect, test } from "vitest";
|
|
4
|
-
import { businessUnitDraftFactory } from "
|
|
5
|
-
import { customerDraftFactory } from "
|
|
6
|
-
import { typeDraftFactory } from "
|
|
7
|
-
import { CommercetoolsMock } from "../ctMock";
|
|
4
|
+
import { businessUnitDraftFactory } from "#src/testing/business-unit.ts";
|
|
5
|
+
import { customerDraftFactory } from "#src/testing/customer.ts";
|
|
6
|
+
import { typeDraftFactory } from "#src/testing/type.ts";
|
|
7
|
+
import { CommercetoolsMock } from "../ctMock.ts";
|
|
8
8
|
|
|
9
9
|
describe("Business units query", () => {
|
|
10
10
|
const ctMock = new CommercetoolsMock();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Router } from "express";
|
|
2
|
-
import type { BusinessUnitRepository } from "../repositories/business-unit";
|
|
3
|
-
import AbstractService from "./abstract";
|
|
2
|
+
import type { BusinessUnitRepository } from "../repositories/business-unit.ts";
|
|
3
|
+
import AbstractService from "./abstract.ts";
|
|
4
4
|
|
|
5
5
|
export class BusinessUnitServices extends AbstractService {
|
|
6
6
|
public repository: BusinessUnitRepository;
|