@labdigital/commercetools-mock 2.21.2 → 2.22.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@labdigital/commercetools-mock",
3
- "version": "2.21.2",
3
+ "version": "2.22.0",
4
4
  "license": "MIT",
5
5
  "author": "Michael van Tellingen",
6
6
  "type": "module",
@@ -1,4 +1,6 @@
1
1
  import {
2
+ CartSetAnonymousIdAction,
3
+ CartSetCustomerIdAction,
2
4
  CartUpdateAction,
3
5
  type Address,
4
6
  type AddressDraft,
@@ -281,6 +283,15 @@ export class CartUpdateHandler
281
283
  resource.totalPrice.centAmount = calculateCartTotalPrice(resource);
282
284
  }
283
285
 
286
+ setAnonymousId(
287
+ _context: RepositoryContext,
288
+ resource: Writable<Cart>,
289
+ { anonymousId }: CartSetAnonymousIdAction,
290
+ ) {
291
+ resource.anonymousId = anonymousId;
292
+ resource.customerId = undefined;
293
+ }
294
+
284
295
  setBillingAddress(
285
296
  context: RepositoryContext,
286
297
  resource: Writable<Cart>,
@@ -309,6 +320,15 @@ export class CartUpdateHandler
309
320
  resource.customerEmail = email;
310
321
  }
311
322
 
323
+ setCustomerId(
324
+ _context: RepositoryContext,
325
+ resource: Writable<Cart>,
326
+ { customerId }: CartSetCustomerIdAction,
327
+ ) {
328
+ resource.anonymousId = undefined;
329
+ resource.customerId = customerId;
330
+ }
331
+
312
332
  setCustomField(
313
333
  context: RepositoryContext,
314
334
  resource: Cart,
@@ -60,7 +60,6 @@ export const createCustomFields = (
60
60
  if (!draft) return undefined;
61
61
  if (!draft.type) return undefined;
62
62
  if (!draft.type.typeId) return undefined;
63
- if (!draft.fields) return undefined;
64
63
  const typeResource = storage.getByResourceIdentifier(
65
64
  projectKey,
66
65
  draft.type,
@@ -77,7 +76,7 @@ export const createCustomFields = (
77
76
  typeId: draft.type.typeId,
78
77
  id: typeResource.id,
79
78
  },
80
- fields: draft.fields,
79
+ fields: draft.fields ?? {},
81
80
  };
82
81
  };
83
82
 
@@ -82,6 +82,7 @@ export class OrderRepository extends AbstractResourceRepository<"order"> {
82
82
  typeId: "store",
83
83
  }
84
84
  : undefined,
85
+ custom: cart.custom,
85
86
  lastMessageSequenceNumber: 0,
86
87
  };
87
88
  return this.saveNew(context, resource);