@labdigital/commercetools-mock 2.39.0 → 2.40.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 +18 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +18 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/repositories/customer/index.test.ts +75 -0
- package/src/repositories/customer/index.ts +29 -1
package/dist/index.js
CHANGED
|
@@ -3910,6 +3910,23 @@ var CustomerRepository = class extends AbstractResourceRepository {
|
|
|
3910
3910
|
const billingAddressIds = draft.billingAddresses?.map(
|
|
3911
3911
|
(addressId) => lookupAdressId(addresses, addressId)
|
|
3912
3912
|
) ?? [];
|
|
3913
|
+
let storesForCustomer = [];
|
|
3914
|
+
if (draft.stores) {
|
|
3915
|
+
const storeIds = draft.stores.map((storeReference) => storeReference.id).filter(Boolean);
|
|
3916
|
+
const stores = this._storage.query(context.projectKey, "store", {
|
|
3917
|
+
where: storeIds.map((id) => `id="${id}"`)
|
|
3918
|
+
}).results;
|
|
3919
|
+
if (storeIds.length !== stores.length) {
|
|
3920
|
+
throw new CommercetoolsError({
|
|
3921
|
+
code: "ResourceNotFound",
|
|
3922
|
+
message: `Store with ID '${storeIds.find((id) => !stores.some((store) => store.id === id))}' was not found.`
|
|
3923
|
+
});
|
|
3924
|
+
}
|
|
3925
|
+
storesForCustomer = draft.stores.map((storeReference) => ({
|
|
3926
|
+
typeId: "store",
|
|
3927
|
+
key: storeReference.key ?? stores.find((store) => store.id === storeReference.id)?.key
|
|
3928
|
+
}));
|
|
3929
|
+
}
|
|
3913
3930
|
const resource = {
|
|
3914
3931
|
...getBaseResourceProperties(),
|
|
3915
3932
|
key: draft.key,
|
|
@@ -3935,7 +3952,7 @@ var CustomerRepository = class extends AbstractResourceRepository {
|
|
|
3935
3952
|
context.projectKey,
|
|
3936
3953
|
this._storage
|
|
3937
3954
|
),
|
|
3938
|
-
stores:
|
|
3955
|
+
stores: storesForCustomer
|
|
3939
3956
|
};
|
|
3940
3957
|
return this.saveNew(context, resource);
|
|
3941
3958
|
}
|