@labdigital/commercetools-mock 2.20.2 → 2.21.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
@@ -480,6 +480,15 @@ var mapHeaderType = (outgoingHttpHeaders) => {
480
480
  }
481
481
  return headersInit;
482
482
  };
483
+ var generateRandomString = (length) => {
484
+ const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
485
+ let result = "";
486
+ for (let i = 0; i < length; i++) {
487
+ const randomIndex = Math.floor(Math.random() * characters.length);
488
+ result += characters[randomIndex];
489
+ }
490
+ return result;
491
+ };
483
492
 
484
493
  // src/projectAPI.ts
485
494
  var ProjectAPI = class {
@@ -1826,7 +1835,9 @@ var AbstractResourceRepository = class extends AbstractRepository {
1826
1835
  ...params
1827
1836
  });
1828
1837
  const data = result.results.map(
1829
- (r) => this.postProcessResource(context, r)
1838
+ (r) => this.postProcessResource(context, r, {
1839
+ expand: params.expand
1840
+ })
1830
1841
  );
1831
1842
  return {
1832
1843
  ...result,
@@ -3364,14 +3375,35 @@ var CustomerRepository = class extends AbstractResourceRepository {
3364
3375
  ]
3365
3376
  });
3366
3377
  }
3378
+ const addresses = draft.addresses?.map((address) => ({
3379
+ ...address,
3380
+ id: generateRandomString(5)
3381
+ })) ?? [];
3382
+ const defaultBillingAddressId = addresses.length > 0 && draft.defaultBillingAddress !== void 0 ? addresses[draft.defaultBillingAddress].id : void 0;
3383
+ const defaultShippingAddressId = addresses.length > 0 && draft.defaultShippingAddress !== void 0 ? addresses[draft.defaultShippingAddress].id : void 0;
3367
3384
  const resource = {
3368
3385
  ...getBaseResourceProperties(),
3386
+ key: draft.key,
3369
3387
  authenticationMode: draft.authenticationMode || "Password",
3388
+ firstName: draft.firstName,
3389
+ lastName: draft.lastName,
3390
+ middleName: draft.middleName,
3391
+ title: draft.title,
3392
+ dateOfBirth: draft.dateOfBirth,
3393
+ companyName: draft.companyName,
3370
3394
  email: draft.email.toLowerCase(),
3371
3395
  password: draft.password ? hashPassword(draft.password) : void 0,
3372
3396
  isEmailVerified: draft.isEmailVerified || false,
3373
- addresses: [],
3374
- customerNumber: draft.customerNumber
3397
+ addresses,
3398
+ customerNumber: draft.customerNumber,
3399
+ externalId: draft.externalId,
3400
+ defaultBillingAddressId,
3401
+ defaultShippingAddressId,
3402
+ custom: createCustomFields(
3403
+ draft.custom,
3404
+ context.projectKey,
3405
+ this._storage
3406
+ )
3375
3407
  };
3376
3408
  return this.saveNew(context, resource);
3377
3409
  }