@labdigital/commercetools-mock 2.44.0 → 2.45.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.cjs +11 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +11 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/repositories/payment/index.ts +1 -0
- package/src/repositories/product/helpers.ts +18 -2
package/package.json
CHANGED
|
@@ -24,6 +24,7 @@ export class PaymentRepository extends AbstractResourceRepository<"payment"> {
|
|
|
24
24
|
create(context: RepositoryContext, draft: PaymentDraft): Payment {
|
|
25
25
|
const resource: Payment = {
|
|
26
26
|
...getBaseResourceProperties(),
|
|
27
|
+
key: draft.key,
|
|
27
28
|
amountPlanned: createCentPrecisionMoney(draft.amountPlanned),
|
|
28
29
|
paymentMethodInfo: draft.paymentMethodInfo!,
|
|
29
30
|
paymentStatus: draft.paymentStatus
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type {
|
|
2
|
+
Asset,
|
|
3
|
+
AssetDraft,
|
|
2
4
|
ChannelReference,
|
|
3
5
|
Price,
|
|
4
6
|
PriceDraft,
|
|
@@ -13,6 +15,7 @@ import type { AbstractStorage } from "~src/storage";
|
|
|
13
15
|
import type { Writable } from "~src/types";
|
|
14
16
|
import type { RepositoryContext } from "../abstract";
|
|
15
17
|
import {
|
|
18
|
+
createCustomFields,
|
|
16
19
|
createTypedMoney,
|
|
17
20
|
getReferenceFromResourceIdentifier,
|
|
18
21
|
} from "../helpers";
|
|
@@ -75,10 +78,23 @@ export const variantFromDraft = (
|
|
|
75
78
|
key: variant?.key,
|
|
76
79
|
attributes: variant?.attributes ?? [],
|
|
77
80
|
prices: variant?.prices?.map((p) => priceFromDraft(context, storage, p)),
|
|
78
|
-
assets: [],
|
|
79
|
-
images: [],
|
|
81
|
+
assets: variant.assets?.map((a) => assetFromDraft(context, storage, a)) ?? [],
|
|
82
|
+
images: variant.images ?? [],
|
|
80
83
|
});
|
|
81
84
|
|
|
85
|
+
export const assetFromDraft = (
|
|
86
|
+
context: RepositoryContext,
|
|
87
|
+
storage: AbstractStorage,
|
|
88
|
+
draft: AssetDraft,
|
|
89
|
+
): Asset => {
|
|
90
|
+
const asset: Asset = {
|
|
91
|
+
...draft,
|
|
92
|
+
id: uuidv4(),
|
|
93
|
+
custom: createCustomFields(draft.custom, context.projectKey, storage),
|
|
94
|
+
};
|
|
95
|
+
return asset;
|
|
96
|
+
};
|
|
97
|
+
|
|
82
98
|
export const priceFromDraft = (
|
|
83
99
|
context: RepositoryContext,
|
|
84
100
|
storage: AbstractStorage,
|