@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.js CHANGED
@@ -443,6 +443,15 @@ var mapHeaderType = (outgoingHttpHeaders) => {
443
443
  }
444
444
  return headersInit;
445
445
  };
446
+ var generateRandomString = (length) => {
447
+ const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
448
+ let result = "";
449
+ for (let i = 0; i < length; i++) {
450
+ const randomIndex = Math.floor(Math.random() * characters.length);
451
+ result += characters[randomIndex];
452
+ }
453
+ return result;
454
+ };
446
455
 
447
456
  // src/projectAPI.ts
448
457
  var ProjectAPI = class {
@@ -1789,7 +1798,9 @@ var AbstractResourceRepository = class extends AbstractRepository {
1789
1798
  ...params
1790
1799
  });
1791
1800
  const data = result.results.map(
1792
- (r) => this.postProcessResource(context, r)
1801
+ (r) => this.postProcessResource(context, r, {
1802
+ expand: params.expand
1803
+ })
1793
1804
  );
1794
1805
  return {
1795
1806
  ...result,
@@ -3027,6 +3038,9 @@ var CategoryRepository = class extends AbstractResourceRepository {
3027
3038
  key: draft.key,
3028
3039
  name: draft.name,
3029
3040
  slug: draft.slug,
3041
+ description: draft.description,
3042
+ metaDescription: draft.metaDescription,
3043
+ metaKeywords: draft.metaKeywords,
3030
3044
  orderHint: draft.orderHint || "",
3031
3045
  externalId: draft.externalId || "",
3032
3046
  parent: draft.parent ? { typeId: "category", id: draft.parent.id } : void 0,
@@ -3327,14 +3341,35 @@ var CustomerRepository = class extends AbstractResourceRepository {
3327
3341
  ]
3328
3342
  });
3329
3343
  }
3344
+ const addresses = draft.addresses?.map((address) => ({
3345
+ ...address,
3346
+ id: generateRandomString(5)
3347
+ })) ?? [];
3348
+ const defaultBillingAddressId = addresses.length > 0 && draft.defaultBillingAddress !== void 0 ? addresses[draft.defaultBillingAddress].id : void 0;
3349
+ const defaultShippingAddressId = addresses.length > 0 && draft.defaultShippingAddress !== void 0 ? addresses[draft.defaultShippingAddress].id : void 0;
3330
3350
  const resource = {
3331
3351
  ...getBaseResourceProperties(),
3352
+ key: draft.key,
3332
3353
  authenticationMode: draft.authenticationMode || "Password",
3354
+ firstName: draft.firstName,
3355
+ lastName: draft.lastName,
3356
+ middleName: draft.middleName,
3357
+ title: draft.title,
3358
+ dateOfBirth: draft.dateOfBirth,
3359
+ companyName: draft.companyName,
3333
3360
  email: draft.email.toLowerCase(),
3334
3361
  password: draft.password ? hashPassword(draft.password) : void 0,
3335
3362
  isEmailVerified: draft.isEmailVerified || false,
3336
- addresses: [],
3337
- customerNumber: draft.customerNumber
3363
+ addresses,
3364
+ customerNumber: draft.customerNumber,
3365
+ externalId: draft.externalId,
3366
+ defaultBillingAddressId,
3367
+ defaultShippingAddressId,
3368
+ custom: createCustomFields(
3369
+ draft.custom,
3370
+ context.projectKey,
3371
+ this._storage
3372
+ )
3338
3373
  };
3339
3374
  return this.saveNew(context, resource);
3340
3375
  }