@labdigital/commercetools-mock 2.61.0 → 2.61.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.mjs +14 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/repositories/business-unit.ts +2 -5
- package/src/repositories/customer/actions.ts +2 -5
- package/src/repositories/helpers.test.ts +25 -0
- package/src/repositories/helpers.ts +5 -0
- package/src/services/cart.test.ts +5 -1
package/dist/index.mjs
CHANGED
|
@@ -513,7 +513,11 @@ var ProductTailoringUpdateHandler = class extends AbstractUpdateHandler {
|
|
|
513
513
|
const createAddress = (base, projectKey, storage) => {
|
|
514
514
|
if (!base) return void 0;
|
|
515
515
|
if (!base?.country) throw new Error("Country is required");
|
|
516
|
-
|
|
516
|
+
const generateRandomId = () => Math.random().toString(36).substring(2, 10).padEnd(8, "0");
|
|
517
|
+
return {
|
|
518
|
+
...base,
|
|
519
|
+
id: base.id ?? generateRandomId()
|
|
520
|
+
};
|
|
517
521
|
};
|
|
518
522
|
const createCustomFields = (draft, projectKey, storage) => {
|
|
519
523
|
if (!draft) return void 0;
|
|
@@ -2137,11 +2141,11 @@ var BusinessUnitUpdateHandler = class extends AbstractUpdateHandler {
|
|
|
2137
2141
|
changeAddress(context, resource, { addressId, address }) {
|
|
2138
2142
|
const existingAddressIndex = resource.addresses.findIndex((addr) => addr.id === addressId);
|
|
2139
2143
|
if (existingAddressIndex === -1) throw new Error(`Address with id ${addressId} not found`);
|
|
2140
|
-
const newAddress = createAddress(
|
|
2141
|
-
|
|
2142
|
-
...newAddress,
|
|
2144
|
+
const newAddress = createAddress({
|
|
2145
|
+
...address,
|
|
2143
2146
|
id: addressId
|
|
2144
|
-
};
|
|
2147
|
+
}, context.projectKey, this._storage);
|
|
2148
|
+
if (newAddress) resource.addresses[existingAddressIndex] = newAddress;
|
|
2145
2149
|
}
|
|
2146
2150
|
changeApprovalRuleMode(context, resource, { approvalRuleMode }) {
|
|
2147
2151
|
resource.approvalRuleMode = approvalRuleMode;
|
|
@@ -2619,11 +2623,11 @@ var CustomerUpdateHandler = class extends AbstractUpdateHandler {
|
|
|
2619
2623
|
const current = this._findAddress(resource, addressId, addressKey, true);
|
|
2620
2624
|
assert(current?.id);
|
|
2621
2625
|
const oldAddressIndex = resource.addresses.findIndex((a) => a.id === current.id);
|
|
2622
|
-
const newAddress = createAddress(
|
|
2623
|
-
|
|
2624
|
-
id:
|
|
2625
|
-
|
|
2626
|
-
|
|
2626
|
+
const newAddress = createAddress({
|
|
2627
|
+
...address,
|
|
2628
|
+
id: current.id
|
|
2629
|
+
}, context.projectKey, this._storage);
|
|
2630
|
+
if (newAddress) resource.addresses[oldAddressIndex] = newAddress;
|
|
2627
2631
|
}
|
|
2628
2632
|
changeEmail(_context, resource, { email }) {
|
|
2629
2633
|
resource.email = email;
|