@labdigital/commercetools-mock 2.59.1 → 2.61.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{index.d.ts → index.d.mts} +154 -275
- package/dist/{index.js → index.mjs} +413 -401
- 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 +119 -0
- package/src/lib/tax.ts +186 -0
- 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 +21 -23
- package/src/repositories/cart/actions.ts +79 -15
- package/src/repositories/cart/helpers.ts +5 -84
- package/src/repositories/cart/index.test.ts +53 -10
- package/src/repositories/cart/index.ts +17 -21
- 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 +9 -9
- 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.ts +9 -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 +191 -9
- package/src/repositories/order/index.ts +63 -21
- 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 +213 -2
- 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
|
@@ -13,22 +13,25 @@ import type {
|
|
|
13
13
|
StoreKeyReference,
|
|
14
14
|
StoreResourceIdentifier,
|
|
15
15
|
} from "@commercetools/platform-sdk";
|
|
16
|
-
import type { Config } from "
|
|
17
|
-
import { CommercetoolsError } from "
|
|
18
|
-
import {
|
|
16
|
+
import type { Config } from "#src/config.ts";
|
|
17
|
+
import { CommercetoolsError } from "#src/exceptions.ts";
|
|
18
|
+
import {
|
|
19
|
+
generateRandomString,
|
|
20
|
+
getBaseResourceProperties,
|
|
21
|
+
} from "#src/helpers.ts";
|
|
19
22
|
import {
|
|
20
23
|
createEmailVerifyToken,
|
|
21
24
|
createPasswordResetToken,
|
|
22
25
|
hashPassword,
|
|
23
26
|
validatePasswordResetToken,
|
|
24
|
-
} from "
|
|
25
|
-
import type { ResourceMap, ShallowWritable, Writable } from "
|
|
27
|
+
} from "#src/lib/password.ts";
|
|
28
|
+
import type { ResourceMap, ShallowWritable, Writable } from "#src/types.ts";
|
|
26
29
|
import {
|
|
27
30
|
AbstractResourceRepository,
|
|
28
31
|
type RepositoryContext,
|
|
29
|
-
} from "../abstract";
|
|
30
|
-
import { createCustomFields } from "../helpers";
|
|
31
|
-
import { CustomerUpdateHandler } from "./actions";
|
|
32
|
+
} from "../abstract.ts";
|
|
33
|
+
import { createCustomFields } from "../helpers.ts";
|
|
34
|
+
import { CustomerUpdateHandler } from "./actions.ts";
|
|
32
35
|
|
|
33
36
|
export class CustomerRepository extends AbstractResourceRepository<"customer"> {
|
|
34
37
|
constructor(config: Config) {
|
|
@@ -176,7 +179,7 @@ export class CustomerRepository extends AbstractResourceRepository<"customer"> {
|
|
|
176
179
|
|
|
177
180
|
const ttlMinutes = request.ttlMinutes ?? 34560; // 34560 is CT default
|
|
178
181
|
|
|
179
|
-
const expiresAt = new Date(
|
|
182
|
+
const expiresAt = new Date(Date.now() + ttlMinutes * 60 * 1000);
|
|
180
183
|
const customer = results.results[0] as Customer;
|
|
181
184
|
const rest = getBaseResourceProperties();
|
|
182
185
|
|
|
@@ -6,10 +6,10 @@ import type {
|
|
|
6
6
|
CustomerGroupSetKeyAction,
|
|
7
7
|
} from "@commercetools/platform-sdk";
|
|
8
8
|
import { describe, expect, test } from "vitest";
|
|
9
|
-
import type { Config } from "
|
|
10
|
-
import { getBaseResourceProperties } from "
|
|
11
|
-
import { InMemoryStorage } from "
|
|
12
|
-
import { CustomerGroupRepository } from "./customer-group";
|
|
9
|
+
import type { Config } from "#src/config.ts";
|
|
10
|
+
import { getBaseResourceProperties } from "#src/helpers.ts";
|
|
11
|
+
import { InMemoryStorage } from "#src/storage/index.ts";
|
|
12
|
+
import { CustomerGroupRepository } from "./customer-group.ts";
|
|
13
13
|
|
|
14
14
|
describe("CustomerGroup Repository", () => {
|
|
15
15
|
const storage = new InMemoryStorage();
|
|
@@ -7,16 +7,16 @@ import type {
|
|
|
7
7
|
CustomerGroupSetKeyAction,
|
|
8
8
|
CustomerGroupUpdateAction,
|
|
9
9
|
} from "@commercetools/platform-sdk";
|
|
10
|
-
import type { Config } from "
|
|
11
|
-
import { getBaseResourceProperties } from "../helpers";
|
|
12
|
-
import type { Writable } from "../types";
|
|
13
|
-
import type { UpdateHandlerInterface } from "./abstract";
|
|
10
|
+
import type { Config } from "#src/config.ts";
|
|
11
|
+
import { getBaseResourceProperties } from "../helpers.ts";
|
|
12
|
+
import type { Writable } from "../types.ts";
|
|
13
|
+
import type { UpdateHandlerInterface } from "./abstract.ts";
|
|
14
14
|
import {
|
|
15
15
|
AbstractResourceRepository,
|
|
16
16
|
AbstractUpdateHandler,
|
|
17
17
|
type RepositoryContext,
|
|
18
|
-
} from "./abstract";
|
|
19
|
-
import { createCustomFields } from "./helpers";
|
|
18
|
+
} from "./abstract.ts";
|
|
19
|
+
import { createCustomFields } from "./helpers.ts";
|
|
20
20
|
|
|
21
21
|
export class CustomerGroupRepository extends AbstractResourceRepository<"customer-group"> {
|
|
22
22
|
constructor(config: Config) {
|
|
@@ -15,10 +15,10 @@ import type {
|
|
|
15
15
|
DiscountCodeSetValidUntilAction,
|
|
16
16
|
DiscountCodeUpdateAction,
|
|
17
17
|
} from "@commercetools/platform-sdk";
|
|
18
|
-
import type { Writable } from "
|
|
19
|
-
import type { UpdateHandlerInterface } from "../abstract";
|
|
20
|
-
import { AbstractUpdateHandler, type RepositoryContext } from "../abstract";
|
|
21
|
-
import { createCustomFields } from "../helpers";
|
|
18
|
+
import type { Writable } from "#src/types.ts";
|
|
19
|
+
import type { UpdateHandlerInterface } from "../abstract.ts";
|
|
20
|
+
import { AbstractUpdateHandler, type RepositoryContext } from "../abstract.ts";
|
|
21
|
+
import { createCustomFields } from "../helpers.ts";
|
|
22
22
|
|
|
23
23
|
export class DiscountCodeUpdateHandler
|
|
24
24
|
extends AbstractUpdateHandler
|
|
@@ -3,14 +3,14 @@ import type {
|
|
|
3
3
|
DiscountCode,
|
|
4
4
|
DiscountCodeDraft,
|
|
5
5
|
} from "@commercetools/platform-sdk";
|
|
6
|
-
import type { Config } from "
|
|
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 { createCustomFields } from "../helpers";
|
|
13
|
-
import { DiscountCodeUpdateHandler } from "./actions";
|
|
11
|
+
} from "../abstract.ts";
|
|
12
|
+
import { createCustomFields } from "../helpers.ts";
|
|
13
|
+
import { DiscountCodeUpdateHandler } from "./actions.ts";
|
|
14
14
|
|
|
15
15
|
export class DiscountCodeRepository extends AbstractResourceRepository<"discount-code"> {
|
|
16
16
|
constructor(config: Config) {
|
|
@@ -6,10 +6,9 @@ import type {
|
|
|
6
6
|
DiscountGroupSetSortOrderAction,
|
|
7
7
|
DiscountGroupUpdateAction,
|
|
8
8
|
} from "@commercetools/platform-sdk";
|
|
9
|
-
import type { Writable } from "
|
|
10
|
-
import type { UpdateHandlerInterface } from "../abstract";
|
|
11
|
-
import { AbstractUpdateHandler, type RepositoryContext } from "../abstract";
|
|
12
|
-
import { createCustomFields } from "../helpers";
|
|
9
|
+
import type { Writable } from "#src/types.ts";
|
|
10
|
+
import type { UpdateHandlerInterface } from "../abstract.ts";
|
|
11
|
+
import { AbstractUpdateHandler, type RepositoryContext } from "../abstract.ts";
|
|
13
12
|
|
|
14
13
|
export class DiscountGroupUpdateHandler
|
|
15
14
|
extends AbstractUpdateHandler
|
|
@@ -2,13 +2,13 @@ import type {
|
|
|
2
2
|
DiscountGroup,
|
|
3
3
|
DiscountGroupDraft,
|
|
4
4
|
} from "@commercetools/platform-sdk";
|
|
5
|
-
import type { Config } from "
|
|
6
|
-
import { getBaseResourceProperties } from "
|
|
5
|
+
import type { Config } from "#src/config.ts";
|
|
6
|
+
import { getBaseResourceProperties } from "#src/helpers.ts";
|
|
7
7
|
import {
|
|
8
8
|
AbstractResourceRepository,
|
|
9
9
|
type RepositoryContext,
|
|
10
|
-
} from "../abstract";
|
|
11
|
-
import { DiscountGroupUpdateHandler } from "./actions";
|
|
10
|
+
} from "../abstract.ts";
|
|
11
|
+
import { DiscountGroupUpdateHandler } from "./actions.ts";
|
|
12
12
|
|
|
13
13
|
export class DiscountGroupRepository extends AbstractResourceRepository<"discount-group"> {
|
|
14
14
|
constructor(config: Config) {
|
|
@@ -7,9 +7,9 @@ import type {
|
|
|
7
7
|
ExtensionSetTimeoutInMsAction,
|
|
8
8
|
} from "@commercetools/platform-sdk";
|
|
9
9
|
import { describe, expect, test } from "vitest";
|
|
10
|
-
import type { Config } from "
|
|
11
|
-
import { InMemoryStorage } from "
|
|
12
|
-
import { ExtensionRepository } from "./extension";
|
|
10
|
+
import type { Config } from "#src/config.ts";
|
|
11
|
+
import { InMemoryStorage } from "#src/storage/index.ts";
|
|
12
|
+
import { ExtensionRepository } from "./extension.ts";
|
|
13
13
|
|
|
14
14
|
describe("Extension Repository", () => {
|
|
15
15
|
const storage = new InMemoryStorage();
|
|
@@ -7,16 +7,16 @@ import type {
|
|
|
7
7
|
ExtensionSetTimeoutInMsAction,
|
|
8
8
|
ExtensionUpdateAction,
|
|
9
9
|
} from "@commercetools/platform-sdk";
|
|
10
|
-
import type { Config } from "
|
|
11
|
-
import { getBaseResourceProperties } from "../helpers";
|
|
12
|
-
import { maskSecretValue } from "../lib/masking";
|
|
13
|
-
import type { Writable } from "../types";
|
|
14
|
-
import type { UpdateHandlerInterface } from "./abstract";
|
|
10
|
+
import type { Config } from "#src/config.ts";
|
|
11
|
+
import { getBaseResourceProperties } from "../helpers.ts";
|
|
12
|
+
import { maskSecretValue } from "../lib/masking.ts";
|
|
13
|
+
import type { Writable } from "../types.ts";
|
|
14
|
+
import type { UpdateHandlerInterface } from "./abstract.ts";
|
|
15
15
|
import {
|
|
16
16
|
AbstractResourceRepository,
|
|
17
17
|
AbstractUpdateHandler,
|
|
18
18
|
type RepositoryContext,
|
|
19
|
-
} from "./abstract";
|
|
19
|
+
} from "./abstract.ts";
|
|
20
20
|
|
|
21
21
|
export class ExtensionRepository extends AbstractResourceRepository<"extension"> {
|
|
22
22
|
constructor(config: Config) {
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
|
|
3
|
-
BusinessUnitKeyReference,
|
|
4
|
-
BusinessUnitReference,
|
|
5
|
-
BusinessUnitResourceIdentifier,
|
|
6
|
-
RoundingMode,
|
|
7
|
-
} from "@commercetools/platform-sdk";
|
|
8
|
-
import type {
|
|
2
|
+
_Money,
|
|
9
3
|
Address,
|
|
10
4
|
Associate,
|
|
11
5
|
AssociateDraft,
|
|
12
6
|
AssociateRoleAssignment,
|
|
13
7
|
AssociateRoleAssignmentDraft,
|
|
14
8
|
AssociateRoleKeyReference,
|
|
9
|
+
AssociateRoleReference,
|
|
15
10
|
AssociateRoleResourceIdentifier,
|
|
16
11
|
BaseAddress,
|
|
12
|
+
BusinessUnitKeyReference,
|
|
13
|
+
BusinessUnitReference,
|
|
14
|
+
BusinessUnitResourceIdentifier,
|
|
17
15
|
CentPrecisionMoney,
|
|
18
16
|
CustomFields,
|
|
19
17
|
CustomFieldsDraft,
|
|
@@ -25,19 +23,19 @@ import type {
|
|
|
25
23
|
Reference,
|
|
26
24
|
ReferencedResourceNotFoundError,
|
|
27
25
|
ResourceIdentifier,
|
|
26
|
+
RoundingMode,
|
|
28
27
|
Store,
|
|
29
28
|
StoreKeyReference,
|
|
30
29
|
StoreReference,
|
|
31
30
|
StoreResourceIdentifier,
|
|
32
31
|
Type,
|
|
33
|
-
_Money,
|
|
34
32
|
} from "@commercetools/platform-sdk";
|
|
35
33
|
import { Decimal } from "decimal.js/decimal";
|
|
36
34
|
import type { Request } from "express";
|
|
37
35
|
import { v4 as uuidv4 } from "uuid";
|
|
38
|
-
import { CommercetoolsError } from "
|
|
39
|
-
import type { AbstractStorage } from "../storage";
|
|
40
|
-
import type { RepositoryContext } from "./abstract";
|
|
36
|
+
import { CommercetoolsError } from "#src/exceptions.ts";
|
|
37
|
+
import type { AbstractStorage } from "../storage/index.ts";
|
|
38
|
+
import type { RepositoryContext } from "./abstract.ts";
|
|
41
39
|
|
|
42
40
|
export const createAddress = (
|
|
43
41
|
base: BaseAddress | undefined,
|
|
@@ -206,7 +204,6 @@ export const getReferenceFromResourceIdentifier = <T extends Reference>(
|
|
|
206
204
|
throw new CommercetoolsError<ReferencedResourceNotFoundError>(
|
|
207
205
|
{
|
|
208
206
|
code: "ReferencedResourceNotFound",
|
|
209
|
-
// @ts-ignore
|
|
210
207
|
typeId: resourceIdentifier.typeId,
|
|
211
208
|
message: `The referenced object of type '${resourceIdentifier.typeId}' with '${errIdentifier}' was not found. It either doesn't exist, or it can't be accessed from this endpoint (e.g., if the endpoint filters by store or customer account).`,
|
|
212
209
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, expect, test } from "vitest";
|
|
2
|
-
import type { Config } from "
|
|
3
|
-
import { InMemoryStorage } from "
|
|
4
|
-
import { createRepositories } from "./index";
|
|
2
|
+
import type { Config } from "#src/config.ts";
|
|
3
|
+
import { InMemoryStorage } from "#src/storage/index.ts";
|
|
4
|
+
import { createRepositories } from "./index.ts";
|
|
5
5
|
|
|
6
6
|
describe("Repository Index", () => {
|
|
7
7
|
const storage = new InMemoryStorage();
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import type { Config } from "
|
|
2
|
-
import { ProductTailoringRepository } from "
|
|
1
|
+
import type { Config } from "#src/config.ts";
|
|
2
|
+
import { ProductTailoringRepository } from "#src/repositories/product-tailoring.ts";
|
|
3
3
|
import {
|
|
4
4
|
AsAssociateCartRepository,
|
|
5
5
|
AsAssociateOrderRepository,
|
|
6
6
|
AsAssociateQuoteRequestRepository,
|
|
7
|
-
} from "./as-associate";
|
|
8
|
-
import { AssociateRoleRepository } from "./associate-role";
|
|
9
|
-
import { AttributeGroupRepository } from "./attribute-group";
|
|
10
|
-
import { BusinessUnitRepository } from "./business-unit";
|
|
11
|
-
import { CartRepository } from "./cart";
|
|
12
|
-
import { CartDiscountRepository } from "./cart-discount";
|
|
13
|
-
import { CategoryRepository } from "./category";
|
|
14
|
-
import { ChannelRepository } from "./channel";
|
|
15
|
-
import { CustomObjectRepository } from "./custom-object";
|
|
16
|
-
import { CustomerRepository } from "./customer";
|
|
17
|
-
import { CustomerGroupRepository } from "./customer-group";
|
|
18
|
-
import { DiscountCodeRepository } from "./discount-code";
|
|
19
|
-
import { DiscountGroupRepository } from "./discount-group";
|
|
20
|
-
import { ExtensionRepository } from "./extension";
|
|
21
|
-
import { InventoryEntryRepository } from "./inventory-entry";
|
|
22
|
-
import { MyCustomerRepository } from "./my-customer";
|
|
23
|
-
import { MyOrderRepository } from "./my-order";
|
|
24
|
-
import { OrderRepository } from "./order";
|
|
25
|
-
import { OrderEditRepository } from "./order-edit";
|
|
26
|
-
import { PaymentRepository } from "./payment";
|
|
27
|
-
import { ProductRepository } from "./product";
|
|
28
|
-
import { ProductDiscountRepository } from "./product-discount";
|
|
29
|
-
import { ProductProjectionRepository } from "./product-projection";
|
|
30
|
-
import { ProductSelectionRepository } from "./product-selection";
|
|
31
|
-
import { ProductTypeRepository } from "./product-type";
|
|
32
|
-
import { ProjectRepository } from "./project";
|
|
33
|
-
import { QuoteRepository } from "./quote";
|
|
34
|
-
import { QuoteRequestRepository } from "./quote-request";
|
|
35
|
-
import { StagedQuoteRepository } from "./quote-staged";
|
|
36
|
-
import { RecurrencePolicyRepository } from "./recurrence-policy";
|
|
37
|
-
import { RecurringOrderRepository } from "./recurring-order";
|
|
38
|
-
import { ReviewRepository } from "./review";
|
|
39
|
-
import { ShippingMethodRepository } from "./shipping-method";
|
|
40
|
-
import { ShoppingListRepository } from "./shopping-list";
|
|
41
|
-
import { StandAlonePriceRepository } from "./standalone-price";
|
|
42
|
-
import { StateRepository } from "./state";
|
|
43
|
-
import { StoreRepository } from "./store";
|
|
44
|
-
import { SubscriptionRepository } from "./subscription";
|
|
45
|
-
import { TaxCategoryRepository } from "./tax-category";
|
|
46
|
-
import { TypeRepository } from "./type";
|
|
47
|
-
import { ZoneRepository } from "./zone";
|
|
7
|
+
} from "./as-associate.ts";
|
|
8
|
+
import { AssociateRoleRepository } from "./associate-role.ts";
|
|
9
|
+
import { AttributeGroupRepository } from "./attribute-group.ts";
|
|
10
|
+
import { BusinessUnitRepository } from "./business-unit.ts";
|
|
11
|
+
import { CartRepository } from "./cart/index.ts";
|
|
12
|
+
import { CartDiscountRepository } from "./cart-discount/index.ts";
|
|
13
|
+
import { CategoryRepository } from "./category/index.ts";
|
|
14
|
+
import { ChannelRepository } from "./channel.ts";
|
|
15
|
+
import { CustomObjectRepository } from "./custom-object.ts";
|
|
16
|
+
import { CustomerRepository } from "./customer/index.ts";
|
|
17
|
+
import { CustomerGroupRepository } from "./customer-group.ts";
|
|
18
|
+
import { DiscountCodeRepository } from "./discount-code/index.ts";
|
|
19
|
+
import { DiscountGroupRepository } from "./discount-group/index.ts";
|
|
20
|
+
import { ExtensionRepository } from "./extension.ts";
|
|
21
|
+
import { InventoryEntryRepository } from "./inventory-entry/index.ts";
|
|
22
|
+
import { MyCustomerRepository } from "./my-customer.ts";
|
|
23
|
+
import { MyOrderRepository } from "./my-order.ts";
|
|
24
|
+
import { OrderRepository } from "./order/index.ts";
|
|
25
|
+
import { OrderEditRepository } from "./order-edit.ts";
|
|
26
|
+
import { PaymentRepository } from "./payment/index.ts";
|
|
27
|
+
import { ProductRepository } from "./product/index.ts";
|
|
28
|
+
import { ProductDiscountRepository } from "./product-discount.ts";
|
|
29
|
+
import { ProductProjectionRepository } from "./product-projection.ts";
|
|
30
|
+
import { ProductSelectionRepository } from "./product-selection.ts";
|
|
31
|
+
import { ProductTypeRepository } from "./product-type.ts";
|
|
32
|
+
import { ProjectRepository } from "./project.ts";
|
|
33
|
+
import { QuoteRepository } from "./quote/index.ts";
|
|
34
|
+
import { QuoteRequestRepository } from "./quote-request/index.ts";
|
|
35
|
+
import { StagedQuoteRepository } from "./quote-staged/index.ts";
|
|
36
|
+
import { RecurrencePolicyRepository } from "./recurrence-policy/index.ts";
|
|
37
|
+
import { RecurringOrderRepository } from "./recurring-order/index.ts";
|
|
38
|
+
import { ReviewRepository } from "./review.ts";
|
|
39
|
+
import { ShippingMethodRepository } from "./shipping-method/index.ts";
|
|
40
|
+
import { ShoppingListRepository } from "./shopping-list/index.ts";
|
|
41
|
+
import { StandAlonePriceRepository } from "./standalone-price.ts";
|
|
42
|
+
import { StateRepository } from "./state.ts";
|
|
43
|
+
import { StoreRepository } from "./store.ts";
|
|
44
|
+
import { SubscriptionRepository } from "./subscription.ts";
|
|
45
|
+
import { TaxCategoryRepository } from "./tax-category/index.ts";
|
|
46
|
+
import { TypeRepository } from "./type/index.ts";
|
|
47
|
+
import { ZoneRepository } from "./zone.ts";
|
|
48
48
|
|
|
49
49
|
export type RepositoryMap = ReturnType<typeof createRepositories>;
|
|
50
50
|
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
InventoryEntry,
|
|
3
3
|
InventoryEntryChangeQuantityAction,
|
|
4
|
+
InventoryEntryRemoveQuantityAction,
|
|
4
5
|
InventoryEntrySetCustomFieldAction,
|
|
5
6
|
InventoryEntrySetCustomTypeAction,
|
|
6
7
|
InventoryEntrySetExpectedDeliveryAction,
|
|
7
8
|
InventoryEntrySetRestockableInDaysAction,
|
|
8
9
|
InventoryEntryUpdateAction,
|
|
9
10
|
} from "@commercetools/platform-sdk";
|
|
10
|
-
import type { Writable } from "
|
|
11
|
-
import type { UpdateHandlerInterface } from "../abstract";
|
|
12
|
-
import { AbstractUpdateHandler, type RepositoryContext } from "../abstract";
|
|
11
|
+
import type { Writable } from "#src/types.ts";
|
|
12
|
+
import type { UpdateHandlerInterface } from "../abstract.ts";
|
|
13
|
+
import { AbstractUpdateHandler, type RepositoryContext } from "../abstract.ts";
|
|
13
14
|
|
|
14
15
|
export class InventoryEntryUpdateHandler
|
|
15
16
|
extends AbstractUpdateHandler
|
|
@@ -26,6 +27,17 @@ export class InventoryEntryUpdateHandler
|
|
|
26
27
|
resource.availableQuantity = quantity;
|
|
27
28
|
}
|
|
28
29
|
|
|
30
|
+
removeQuantity(
|
|
31
|
+
context: RepositoryContext,
|
|
32
|
+
resource: Writable<InventoryEntry>,
|
|
33
|
+
{ quantity }: InventoryEntryRemoveQuantityAction,
|
|
34
|
+
) {
|
|
35
|
+
const newQuantity = Math.max(0, resource.quantityOnStock - quantity);
|
|
36
|
+
resource.quantityOnStock = newQuantity;
|
|
37
|
+
// don't know active reservations so just set to same value
|
|
38
|
+
resource.availableQuantity = newQuantity;
|
|
39
|
+
}
|
|
40
|
+
|
|
29
41
|
setCustomField(
|
|
30
42
|
context: RepositoryContext,
|
|
31
43
|
resource: InventoryEntry,
|
|
@@ -2,14 +2,14 @@ import type {
|
|
|
2
2
|
InventoryEntry,
|
|
3
3
|
InventoryEntryDraft,
|
|
4
4
|
} from "@commercetools/platform-sdk";
|
|
5
|
-
import type { Config } from "
|
|
6
|
-
import { getBaseResourceProperties } from "
|
|
5
|
+
import type { Config } from "#src/config.ts";
|
|
6
|
+
import { getBaseResourceProperties } from "#src/helpers.ts";
|
|
7
7
|
import {
|
|
8
8
|
AbstractResourceRepository,
|
|
9
9
|
type RepositoryContext,
|
|
10
|
-
} from "../abstract";
|
|
11
|
-
import { createCustomFields } from "../helpers";
|
|
12
|
-
import { InventoryEntryUpdateHandler } from "./actions";
|
|
10
|
+
} from "../abstract.ts";
|
|
11
|
+
import { createCustomFields } from "../helpers.ts";
|
|
12
|
+
import { InventoryEntryUpdateHandler } from "./actions.ts";
|
|
13
13
|
|
|
14
14
|
export class InventoryEntryRepository extends AbstractResourceRepository<"inventory-entry"> {
|
|
15
15
|
constructor(config: Config) {
|
|
@@ -5,11 +5,11 @@ import type {
|
|
|
5
5
|
MyCustomerEmailVerify,
|
|
6
6
|
ResourceNotFoundError,
|
|
7
7
|
} from "@commercetools/platform-sdk";
|
|
8
|
-
import { CommercetoolsError } from "
|
|
9
|
-
import { hashPassword, validateEmailVerifyToken } from "../lib/password";
|
|
10
|
-
import type { Writable } from "../types";
|
|
11
|
-
import type { RepositoryContext } from "./abstract";
|
|
12
|
-
import { CustomerRepository } from "./customer";
|
|
8
|
+
import { CommercetoolsError } from "#src/exceptions.ts";
|
|
9
|
+
import { hashPassword, validateEmailVerifyToken } from "../lib/password.ts";
|
|
10
|
+
import type { Writable } from "../types.ts";
|
|
11
|
+
import type { RepositoryContext } from "./abstract.ts";
|
|
12
|
+
import { CustomerRepository } from "./customer/index.ts";
|
|
13
13
|
|
|
14
14
|
export class MyCustomerRepository extends CustomerRepository {
|
|
15
15
|
changePassword(
|
|
@@ -4,8 +4,8 @@ import type {
|
|
|
4
4
|
MyOrderFromCartDraft,
|
|
5
5
|
Order,
|
|
6
6
|
} from "@commercetools/platform-sdk";
|
|
7
|
-
import type { RepositoryContext } from "./abstract";
|
|
8
|
-
import { OrderRepository } from "./order";
|
|
7
|
+
import type { RepositoryContext } from "./abstract.ts";
|
|
8
|
+
import { OrderRepository } from "./order/index.ts";
|
|
9
9
|
|
|
10
10
|
export class MyOrderRepository extends OrderRepository {
|
|
11
11
|
create(context: RepositoryContext, draft: MyOrderFromCartDraft): Order {
|
|
@@ -9,11 +9,10 @@ import type {
|
|
|
9
9
|
OrderChangePaymentStateAction,
|
|
10
10
|
OrderChangeShipmentStateAction,
|
|
11
11
|
OrderSetBillingAddressAction,
|
|
12
|
-
OrderSetCustomFieldAction,
|
|
13
|
-
OrderSetCustomLineItemCustomTypeAction,
|
|
14
|
-
OrderSetCustomTypeAction,
|
|
15
12
|
OrderSetCustomerEmailAction,
|
|
16
13
|
OrderSetCustomerIdAction,
|
|
14
|
+
OrderSetCustomFieldAction,
|
|
15
|
+
OrderSetCustomTypeAction,
|
|
17
16
|
OrderSetDeliveryCustomFieldAction,
|
|
18
17
|
OrderSetLineItemCustomFieldAction,
|
|
19
18
|
OrderSetLineItemCustomTypeAction,
|
|
@@ -31,12 +30,12 @@ import type {
|
|
|
31
30
|
Store,
|
|
32
31
|
SyncInfo,
|
|
33
32
|
} from "@commercetools/platform-sdk";
|
|
34
|
-
import { CommercetoolsError } from "
|
|
35
|
-
import { getBaseResourceProperties } from "
|
|
36
|
-
import type { Writable } from "
|
|
37
|
-
import type { RepositoryContext, UpdateHandlerInterface } from "../abstract";
|
|
38
|
-
import { AbstractUpdateHandler } from "../abstract";
|
|
39
|
-
import { createAddress } from "../helpers";
|
|
33
|
+
import { CommercetoolsError } from "#src/exceptions.ts";
|
|
34
|
+
import { getBaseResourceProperties } from "#src/helpers.ts";
|
|
35
|
+
import type { Writable } from "#src/types.ts";
|
|
36
|
+
import type { RepositoryContext, UpdateHandlerInterface } from "../abstract.ts";
|
|
37
|
+
import { AbstractUpdateHandler } from "../abstract.ts";
|
|
38
|
+
import { createAddress } from "../helpers.ts";
|
|
40
39
|
|
|
41
40
|
export class OrderUpdateHandler
|
|
42
41
|
extends AbstractUpdateHandler
|