@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 CHANGED
@@ -3947,6 +3947,23 @@ var CustomerRepository = class extends AbstractResourceRepository {
3947
3947
  const billingAddressIds = draft.billingAddresses?.map(
3948
3948
  (addressId) => lookupAdressId(addresses, addressId)
3949
3949
  ) ?? [];
3950
+ let storesForCustomer = [];
3951
+ if (draft.stores) {
3952
+ const storeIds = draft.stores.map((storeReference) => storeReference.id).filter(Boolean);
3953
+ const stores = this._storage.query(context.projectKey, "store", {
3954
+ where: storeIds.map((id) => `id="${id}"`)
3955
+ }).results;
3956
+ if (storeIds.length !== stores.length) {
3957
+ throw new CommercetoolsError({
3958
+ code: "ResourceNotFound",
3959
+ message: `Store with ID '${storeIds.find((id) => !stores.some((store) => store.id === id))}' was not found.`
3960
+ });
3961
+ }
3962
+ storesForCustomer = draft.stores.map((storeReference) => ({
3963
+ typeId: "store",
3964
+ key: storeReference.key ?? stores.find((store) => store.id === storeReference.id)?.key
3965
+ }));
3966
+ }
3950
3967
  const resource = {
3951
3968
  ...getBaseResourceProperties(),
3952
3969
  key: draft.key,
@@ -3972,7 +3989,7 @@ var CustomerRepository = class extends AbstractResourceRepository {
3972
3989
  context.projectKey,
3973
3990
  this._storage
3974
3991
  ),
3975
- stores: []
3992
+ stores: storesForCustomer
3976
3993
  };
3977
3994
  return this.saveNew(context, resource);
3978
3995
  }