@labdigital/commercetools-mock 2.6.0 → 2.7.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 +33 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +33 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/ctMock.ts +0 -1
- package/src/repositories/index.ts +1 -0
- package/src/services/index.ts +5 -0
- package/src/services/my-customer.test.ts +56 -1
- package/src/services/my-customer.ts +20 -0
- package/src/services/my-shopping-list.ts +16 -0
package/dist/index.cjs
CHANGED
|
@@ -6031,6 +6031,7 @@ var createRepositories = (storage) => ({
|
|
|
6031
6031
|
"my-order": new MyOrderRepository(storage),
|
|
6032
6032
|
"my-customer": new CustomerRepository(storage),
|
|
6033
6033
|
"my-payment": new PaymentRepository(storage),
|
|
6034
|
+
"my-shopping-list": new ShoppingListRepository(storage),
|
|
6034
6035
|
product: new ProductRepository(storage),
|
|
6035
6036
|
"product-type": new ProductTypeRepository(storage),
|
|
6036
6037
|
"product-discount": new ProductDiscountRepository(storage),
|
|
@@ -6486,6 +6487,7 @@ var MyCustomerService = class extends AbstractService {
|
|
|
6486
6487
|
const router = (0, import_express4.Router)({ mergeParams: true });
|
|
6487
6488
|
this.extraRoutes(router);
|
|
6488
6489
|
router.get("", this.getMe.bind(this));
|
|
6490
|
+
router.post("", this.updateMe.bind(this));
|
|
6489
6491
|
router.post("/signup", this.signUp.bind(this));
|
|
6490
6492
|
router.post("/login", this.signIn.bind(this));
|
|
6491
6493
|
parent.use(`/${basePath}`, router);
|
|
@@ -6497,6 +6499,21 @@ var MyCustomerService = class extends AbstractService {
|
|
|
6497
6499
|
}
|
|
6498
6500
|
return response.status(200).send(resource);
|
|
6499
6501
|
}
|
|
6502
|
+
updateMe(request, response) {
|
|
6503
|
+
const resource = this.repository.getMe(getRepositoryContext(request));
|
|
6504
|
+
if (!resource) {
|
|
6505
|
+
return response.status(404).send("Not found");
|
|
6506
|
+
}
|
|
6507
|
+
const updateRequest = request.body;
|
|
6508
|
+
const updatedResource = this.repository.processUpdateActions(
|
|
6509
|
+
getRepositoryContext(request),
|
|
6510
|
+
resource,
|
|
6511
|
+
updateRequest.version,
|
|
6512
|
+
updateRequest.actions
|
|
6513
|
+
);
|
|
6514
|
+
const result = this._expandWithId(request, updatedResource.id);
|
|
6515
|
+
return response.status(200).send(result);
|
|
6516
|
+
}
|
|
6500
6517
|
signUp(request, response) {
|
|
6501
6518
|
const draft = request.body;
|
|
6502
6519
|
const resource = this.repository.create(
|
|
@@ -6563,6 +6580,18 @@ var MyPaymentService = class extends AbstractService {
|
|
|
6563
6580
|
}
|
|
6564
6581
|
};
|
|
6565
6582
|
|
|
6583
|
+
// src/services/my-shopping-list.ts
|
|
6584
|
+
var MyShoppingListService = class extends AbstractService {
|
|
6585
|
+
repository;
|
|
6586
|
+
constructor(parent, repository) {
|
|
6587
|
+
super(parent);
|
|
6588
|
+
this.repository = repository;
|
|
6589
|
+
}
|
|
6590
|
+
getBasePath() {
|
|
6591
|
+
return "me/shopping-lists";
|
|
6592
|
+
}
|
|
6593
|
+
};
|
|
6594
|
+
|
|
6566
6595
|
// src/services/order.ts
|
|
6567
6596
|
var OrderService = class extends AbstractService {
|
|
6568
6597
|
repository;
|
|
@@ -6850,6 +6879,10 @@ var createServices = (router, repos) => ({
|
|
|
6850
6879
|
"my-order": new MyOrderService(router, repos["my-order"]),
|
|
6851
6880
|
"my-customer": new MyCustomerService(router, repos["my-customer"]),
|
|
6852
6881
|
"my-payment": new MyPaymentService(router, repos["my-payment"]),
|
|
6882
|
+
"my-shopping-list": new MyShoppingListService(
|
|
6883
|
+
router,
|
|
6884
|
+
repos["my-shopping-list"]
|
|
6885
|
+
),
|
|
6853
6886
|
"shipping-method": new ShippingMethodService(
|
|
6854
6887
|
router,
|
|
6855
6888
|
repos["shipping-method"]
|
|
@@ -6921,7 +6954,6 @@ var CommercetoolsMock = class {
|
|
|
6921
6954
|
this._mswServer = void 0;
|
|
6922
6955
|
}
|
|
6923
6956
|
clear() {
|
|
6924
|
-
this._mswServer?.resetHandlers();
|
|
6925
6957
|
this._storage.clear();
|
|
6926
6958
|
}
|
|
6927
6959
|
project(projectKey) {
|