@labdigital/commercetools-mock 2.35.0 → 2.36.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.js CHANGED
@@ -3708,8 +3708,34 @@ var CustomerRepository = class extends AbstractResourceRepository {
3708
3708
  ...address,
3709
3709
  id: generateRandomString(5)
3710
3710
  })) ?? [];
3711
- const defaultBillingAddressId = addresses.length > 0 && draft.defaultBillingAddress !== void 0 ? addresses[draft.defaultBillingAddress].id : void 0;
3712
- const defaultShippingAddressId = addresses.length > 0 && draft.defaultShippingAddress !== void 0 ? addresses[draft.defaultShippingAddress].id : void 0;
3711
+ const lookupAdressId = (addresses2, addressId) => {
3712
+ if (addressId < addresses2.length) {
3713
+ const id = addresses2[addressId].id;
3714
+ if (!id) {
3715
+ throw new Error("Address ID is missing");
3716
+ }
3717
+ return id;
3718
+ }
3719
+ throw new CommercetoolsError({
3720
+ code: "InvalidInput",
3721
+ message: `Address with ID '${addressId}' not found.`,
3722
+ errors: [
3723
+ {
3724
+ code: "InvalidInput",
3725
+ message: `Address with ID '${addressId}' not found.`,
3726
+ field: "addressId"
3727
+ }
3728
+ ]
3729
+ });
3730
+ };
3731
+ const defaultBillingAddressId = draft.defaultBillingAddress ? lookupAdressId(addresses, draft.defaultBillingAddress) : void 0;
3732
+ const defaultShippingAddressId = draft.defaultShippingAddress ? lookupAdressId(addresses, draft.defaultShippingAddress) : void 0;
3733
+ const shippingAddressIds = draft.shippingAddresses?.map(
3734
+ (addressId) => lookupAdressId(addresses, addressId)
3735
+ ) ?? [];
3736
+ const billingAddressIds = draft.billingAddresses?.map(
3737
+ (addressId) => lookupAdressId(addresses, addressId)
3738
+ ) ?? [];
3713
3739
  const resource = {
3714
3740
  ...getBaseResourceProperties(),
3715
3741
  key: draft.key,
@@ -3728,6 +3754,8 @@ var CustomerRepository = class extends AbstractResourceRepository {
3728
3754
  externalId: draft.externalId,
3729
3755
  defaultBillingAddressId,
3730
3756
  defaultShippingAddressId,
3757
+ shippingAddressIds,
3758
+ billingAddressIds,
3731
3759
  custom: createCustomFields(
3732
3760
  draft.custom,
3733
3761
  context.projectKey,
@@ -8222,9 +8250,9 @@ var InventoryEntryService = class extends AbstractService {
8222
8250
  }
8223
8251
  };
8224
8252
 
8225
- // src/services/my-cart.ts
8253
+ // src/services/my-business-unit.ts
8226
8254
  import { Router as Router2 } from "express";
8227
- var MyCartService = class extends AbstractService {
8255
+ var MyBusinessUnitService = class extends AbstractService {
8228
8256
  repository;
8229
8257
  constructor(parent, repository) {
8230
8258
  super(parent);
@@ -8237,6 +8265,26 @@ var MyCartService = class extends AbstractService {
8237
8265
  const basePath = this.getBasePath();
8238
8266
  const router = Router2({ mergeParams: true });
8239
8267
  this.extraRoutes(router);
8268
+ router.get("/business-units/", this.get.bind(this));
8269
+ parent.use(`/${basePath}`, router);
8270
+ }
8271
+ };
8272
+
8273
+ // src/services/my-cart.ts
8274
+ import { Router as Router3 } from "express";
8275
+ var MyCartService = class extends AbstractService {
8276
+ repository;
8277
+ constructor(parent, repository) {
8278
+ super(parent);
8279
+ this.repository = repository;
8280
+ }
8281
+ getBasePath() {
8282
+ return "me";
8283
+ }
8284
+ registerRoutes(parent) {
8285
+ const basePath = this.getBasePath();
8286
+ const router = Router3({ mergeParams: true });
8287
+ this.extraRoutes(router);
8240
8288
  router.get("/active-cart", this.activeCart.bind(this));
8241
8289
  router.get("/carts/", this.get.bind(this));
8242
8290
  router.get("/carts/:id", this.getWithId.bind(this));
@@ -8255,7 +8303,7 @@ var MyCartService = class extends AbstractService {
8255
8303
  };
8256
8304
 
8257
8305
  // src/services/my-customer.ts
8258
- import { Router as Router3 } from "express";
8306
+ import { Router as Router4 } from "express";
8259
8307
  var MyCustomerService = class extends AbstractService {
8260
8308
  repository;
8261
8309
  constructor(parent, repository) {
@@ -8267,7 +8315,7 @@ var MyCustomerService = class extends AbstractService {
8267
8315
  }
8268
8316
  registerRoutes(parent) {
8269
8317
  const basePath = this.getBasePath();
8270
- const router = Router3({ mergeParams: true });
8318
+ const router = Router4({ mergeParams: true });
8271
8319
  this.extraRoutes(router);
8272
8320
  router.get("", this.getMe.bind(this));
8273
8321
  router.post("", this.updateMe.bind(this));
@@ -8363,7 +8411,7 @@ var MyCustomerService = class extends AbstractService {
8363
8411
  };
8364
8412
 
8365
8413
  // src/services/my-order.ts
8366
- import { Router as Router4 } from "express";
8414
+ import { Router as Router5 } from "express";
8367
8415
  var MyOrderService = class extends AbstractService {
8368
8416
  repository;
8369
8417
  constructor(parent, repository) {
@@ -8375,7 +8423,7 @@ var MyOrderService = class extends AbstractService {
8375
8423
  }
8376
8424
  registerRoutes(parent) {
8377
8425
  const basePath = this.getBasePath();
8378
- const router = Router4({ mergeParams: true });
8426
+ const router = Router5({ mergeParams: true });
8379
8427
  this.extraRoutes(router);
8380
8428
  router.get("/orders/", this.get.bind(this));
8381
8429
  router.get("/orders/:id", this.getWithId.bind(this));
@@ -8737,6 +8785,7 @@ var createServices = (router, repos) => ({
8737
8785
  "my-cart": new MyCartService(router, repos["my-cart"]),
8738
8786
  "my-order": new MyOrderService(router, repos["my-order"]),
8739
8787
  "my-customer": new MyCustomerService(router, repos["my-customer"]),
8788
+ "my-business-unit": new MyBusinessUnitService(router, repos["business-unit"]),
8740
8789
  "my-payment": new MyPaymentService(router, repos["my-payment"]),
8741
8790
  "my-shopping-list": new MyShoppingListService(
8742
8791
  router,