@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 +23 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +23 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/repositories/customer/index.test.ts +41 -1
- package/src/repositories/customer/index.ts +37 -22
package/dist/index.d.cts
CHANGED
|
@@ -246,6 +246,7 @@ declare class CustomerRepository extends AbstractResourceRepository<"customer">
|
|
|
246
246
|
passwordResetToken(context: RepositoryContext, request: CustomerCreatePasswordResetToken): CustomerToken;
|
|
247
247
|
passwordReset(context: RepositoryContext, resetPassword: CustomerResetPassword | MyCustomerResetPassword): Writable<Customer>;
|
|
248
248
|
verifyEmailToken(context: RepositoryContext, id: string): CustomerToken;
|
|
249
|
+
private storeReferenceToStoreKeyReference;
|
|
249
250
|
}
|
|
250
251
|
|
|
251
252
|
declare class CustomerGroupRepository extends AbstractResourceRepository<"customer-group"> {
|
package/dist/index.d.ts
CHANGED
|
@@ -246,6 +246,7 @@ declare class CustomerRepository extends AbstractResourceRepository<"customer">
|
|
|
246
246
|
passwordResetToken(context: RepositoryContext, request: CustomerCreatePasswordResetToken): CustomerToken;
|
|
247
247
|
passwordReset(context: RepositoryContext, resetPassword: CustomerResetPassword | MyCustomerResetPassword): Writable<Customer>;
|
|
248
248
|
verifyEmailToken(context: RepositoryContext, id: string): CustomerToken;
|
|
249
|
+
private storeReferenceToStoreKeyReference;
|
|
249
250
|
}
|
|
250
251
|
|
|
251
252
|
declare class CustomerGroupRepository extends AbstractResourceRepository<"customer-group"> {
|
package/dist/index.js
CHANGED
|
@@ -3912,20 +3912,10 @@ var CustomerRepository = class extends AbstractResourceRepository {
|
|
|
3912
3912
|
) ?? [];
|
|
3913
3913
|
let storesForCustomer = [];
|
|
3914
3914
|
if (draft.stores && draft.stores.length > 0) {
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
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
|
-
}));
|
|
3915
|
+
storesForCustomer = this.storeReferenceToStoreKeyReference(
|
|
3916
|
+
draft.stores,
|
|
3917
|
+
context.projectKey
|
|
3918
|
+
);
|
|
3929
3919
|
}
|
|
3930
3920
|
const resource = {
|
|
3931
3921
|
...getBaseResourceProperties(),
|
|
@@ -4036,6 +4026,25 @@ var CustomerRepository = class extends AbstractResourceRepository {
|
|
|
4036
4026
|
value: token
|
|
4037
4027
|
};
|
|
4038
4028
|
}
|
|
4029
|
+
storeReferenceToStoreKeyReference(draftStores, projectKey) {
|
|
4030
|
+
const storeIds = draftStores.map((storeReference) => storeReference.id).filter(Boolean);
|
|
4031
|
+
let stores = [];
|
|
4032
|
+
if (storeIds.length > 0) {
|
|
4033
|
+
stores = this._storage.query(projectKey, "store", {
|
|
4034
|
+
where: storeIds.map((id) => `id="${id}"`)
|
|
4035
|
+
}).results;
|
|
4036
|
+
if (storeIds.length !== stores.length) {
|
|
4037
|
+
throw new CommercetoolsError({
|
|
4038
|
+
code: "ResourceNotFound",
|
|
4039
|
+
message: `Store with ID '${storeIds.find((id) => !stores.some((store) => store.id === id))}' was not found.`
|
|
4040
|
+
});
|
|
4041
|
+
}
|
|
4042
|
+
}
|
|
4043
|
+
return draftStores.map((storeReference) => ({
|
|
4044
|
+
typeId: "store",
|
|
4045
|
+
key: storeReference.key ?? stores.find((store) => store.id === storeReference.id)?.key
|
|
4046
|
+
}));
|
|
4047
|
+
}
|
|
4039
4048
|
};
|
|
4040
4049
|
|
|
4041
4050
|
// src/repositories/customer-group.ts
|