@labdigital/commercetools-mock 2.41.0 → 2.41.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 CHANGED
@@ -3949,20 +3949,10 @@ var CustomerRepository = class extends AbstractResourceRepository {
3949
3949
  ) ?? [];
3950
3950
  let storesForCustomer = [];
3951
3951
  if (draft.stores && draft.stores.length > 0) {
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
- }));
3952
+ storesForCustomer = this.storeReferenceToStoreKeyReference(
3953
+ draft.stores,
3954
+ context.projectKey
3955
+ );
3966
3956
  }
3967
3957
  const resource = {
3968
3958
  ...getBaseResourceProperties(),
@@ -4073,6 +4063,25 @@ var CustomerRepository = class extends AbstractResourceRepository {
4073
4063
  value: token
4074
4064
  };
4075
4065
  }
4066
+ storeReferenceToStoreKeyReference(draftStores, projectKey) {
4067
+ const storeIds = draftStores.map((storeReference) => storeReference.id).filter(Boolean);
4068
+ let stores = [];
4069
+ if (storeIds.length > 0) {
4070
+ stores = this._storage.query(projectKey, "store", {
4071
+ where: storeIds.map((id) => `id="${id}"`)
4072
+ }).results;
4073
+ if (storeIds.length !== stores.length) {
4074
+ throw new CommercetoolsError({
4075
+ code: "ResourceNotFound",
4076
+ message: `Store with ID '${storeIds.find((id) => !stores.some((store) => store.id === id))}' was not found.`
4077
+ });
4078
+ }
4079
+ }
4080
+ return draftStores.map((storeReference) => ({
4081
+ typeId: "store",
4082
+ key: storeReference.key ?? stores.find((store) => store.id === storeReference.id)?.key
4083
+ }));
4084
+ }
4076
4085
  };
4077
4086
 
4078
4087
  // src/repositories/customer-group.ts