@labdigital/commercetools-mock 2.20.2 → 2.21.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
@@ -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,
@@ -3064,6 +3075,9 @@ var CategoryRepository = class extends AbstractResourceRepository {
3064
3075
  key: draft.key,
3065
3076
  name: draft.name,
3066
3077
  slug: draft.slug,
3078
+ description: draft.description,
3079
+ metaDescription: draft.metaDescription,
3080
+ metaKeywords: draft.metaKeywords,
3067
3081
  orderHint: draft.orderHint || "",
3068
3082
  externalId: draft.externalId || "",
3069
3083
  parent: draft.parent ? { typeId: "category", id: draft.parent.id } : void 0,
@@ -3364,14 +3378,35 @@ var CustomerRepository = class extends AbstractResourceRepository {
3364
3378
  ]
3365
3379
  });
3366
3380
  }
3381
+ const addresses = draft.addresses?.map((address) => ({
3382
+ ...address,
3383
+ id: generateRandomString(5)
3384
+ })) ?? [];
3385
+ const defaultBillingAddressId = addresses.length > 0 && draft.defaultBillingAddress !== void 0 ? addresses[draft.defaultBillingAddress].id : void 0;
3386
+ const defaultShippingAddressId = addresses.length > 0 && draft.defaultShippingAddress !== void 0 ? addresses[draft.defaultShippingAddress].id : void 0;
3367
3387
  const resource = {
3368
3388
  ...getBaseResourceProperties(),
3389
+ key: draft.key,
3369
3390
  authenticationMode: draft.authenticationMode || "Password",
3391
+ firstName: draft.firstName,
3392
+ lastName: draft.lastName,
3393
+ middleName: draft.middleName,
3394
+ title: draft.title,
3395
+ dateOfBirth: draft.dateOfBirth,
3396
+ companyName: draft.companyName,
3370
3397
  email: draft.email.toLowerCase(),
3371
3398
  password: draft.password ? hashPassword(draft.password) : void 0,
3372
3399
  isEmailVerified: draft.isEmailVerified || false,
3373
- addresses: [],
3374
- customerNumber: draft.customerNumber
3400
+ addresses,
3401
+ customerNumber: draft.customerNumber,
3402
+ externalId: draft.externalId,
3403
+ defaultBillingAddressId,
3404
+ defaultShippingAddressId,
3405
+ custom: createCustomFields(
3406
+ draft.custom,
3407
+ context.projectKey,
3408
+ this._storage
3409
+ )
3375
3410
  };
3376
3411
  return this.saveNew(context, resource);
3377
3412
  }