@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.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,
@@ -3327,14 +3338,35 @@ var CustomerRepository = class extends AbstractResourceRepository {
3327
3338
  ]
3328
3339
  });
3329
3340
  }
3341
+ const addresses = draft.addresses?.map((address) => ({
3342
+ ...address,
3343
+ id: generateRandomString(5)
3344
+ })) ?? [];
3345
+ const defaultBillingAddressId = addresses.length > 0 && draft.defaultBillingAddress !== void 0 ? addresses[draft.defaultBillingAddress].id : void 0;
3346
+ const defaultShippingAddressId = addresses.length > 0 && draft.defaultShippingAddress !== void 0 ? addresses[draft.defaultShippingAddress].id : void 0;
3330
3347
  const resource = {
3331
3348
  ...getBaseResourceProperties(),
3349
+ key: draft.key,
3332
3350
  authenticationMode: draft.authenticationMode || "Password",
3351
+ firstName: draft.firstName,
3352
+ lastName: draft.lastName,
3353
+ middleName: draft.middleName,
3354
+ title: draft.title,
3355
+ dateOfBirth: draft.dateOfBirth,
3356
+ companyName: draft.companyName,
3333
3357
  email: draft.email.toLowerCase(),
3334
3358
  password: draft.password ? hashPassword(draft.password) : void 0,
3335
3359
  isEmailVerified: draft.isEmailVerified || false,
3336
- addresses: [],
3337
- customerNumber: draft.customerNumber
3360
+ addresses,
3361
+ customerNumber: draft.customerNumber,
3362
+ externalId: draft.externalId,
3363
+ defaultBillingAddressId,
3364
+ defaultShippingAddressId,
3365
+ custom: createCustomFields(
3366
+ draft.custom,
3367
+ context.projectKey,
3368
+ this._storage
3369
+ )
3338
3370
  };
3339
3371
  return this.saveNew(context, resource);
3340
3372
  }