@labdigital/commercetools-mock 2.12.2 → 2.13.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 +46 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +46 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/repositories/customer.ts +16 -0
- package/src/repositories/order.ts +38 -0
- package/src/services/my-customer.test.ts +26 -0
- package/src/services/my-customer.ts +9 -0
- package/src/services/order.test.ts +34 -0
package/dist/index.cjs
CHANGED
|
@@ -3175,6 +3175,17 @@ var CustomerRepository = class extends AbstractResourceRepository {
|
|
|
3175
3175
|
}
|
|
3176
3176
|
return;
|
|
3177
3177
|
}
|
|
3178
|
+
deleteMe(context) {
|
|
3179
|
+
const results = this._storage.query(
|
|
3180
|
+
context.projectKey,
|
|
3181
|
+
this.getTypeId(),
|
|
3182
|
+
{}
|
|
3183
|
+
);
|
|
3184
|
+
if (results.count > 0) {
|
|
3185
|
+
return this.delete(context, results.results[0].id);
|
|
3186
|
+
}
|
|
3187
|
+
return;
|
|
3188
|
+
}
|
|
3178
3189
|
actions = {
|
|
3179
3190
|
changeEmail: (_context, resource, { email }) => {
|
|
3180
3191
|
resource.email = email;
|
|
@@ -3822,6 +3833,33 @@ var OrderRepository = class extends AbstractResourceRepository {
|
|
|
3822
3833
|
typeId: "store",
|
|
3823
3834
|
key: storeReference.key
|
|
3824
3835
|
};
|
|
3836
|
+
},
|
|
3837
|
+
updateSyncInfo: (context, resource, { channel, externalId, syncedAt }) => {
|
|
3838
|
+
if (!channel)
|
|
3839
|
+
return;
|
|
3840
|
+
const resolvedType = this._storage.getByResourceIdentifier(
|
|
3841
|
+
context.projectKey,
|
|
3842
|
+
channel
|
|
3843
|
+
);
|
|
3844
|
+
if (!resolvedType) {
|
|
3845
|
+
throw new Error(`Channel ${channel} not found`);
|
|
3846
|
+
}
|
|
3847
|
+
const syncData = {
|
|
3848
|
+
channel: {
|
|
3849
|
+
typeId: "channel",
|
|
3850
|
+
id: resolvedType.id
|
|
3851
|
+
},
|
|
3852
|
+
externalId,
|
|
3853
|
+
syncedAt: syncedAt ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
3854
|
+
};
|
|
3855
|
+
if (!resource.syncInfo?.length) {
|
|
3856
|
+
resource.syncInfo = [syncData];
|
|
3857
|
+
} else {
|
|
3858
|
+
const lastSyncInfo = resource.syncInfo[resource.syncInfo.length - 1];
|
|
3859
|
+
if (lastSyncInfo.channel.id !== syncData.channel.id || lastSyncInfo.externalId !== syncData.externalId) {
|
|
3860
|
+
resource.syncInfo.push(syncData);
|
|
3861
|
+
}
|
|
3862
|
+
}
|
|
3825
3863
|
}
|
|
3826
3864
|
};
|
|
3827
3865
|
};
|
|
@@ -6816,6 +6854,7 @@ var MyCustomerService = class extends AbstractService {
|
|
|
6816
6854
|
this.extraRoutes(router);
|
|
6817
6855
|
router.get("", this.getMe.bind(this));
|
|
6818
6856
|
router.post("", this.updateMe.bind(this));
|
|
6857
|
+
router.delete("", this.deleteMe.bind(this));
|
|
6819
6858
|
router.post("/signup", this.signUp.bind(this));
|
|
6820
6859
|
router.post("/login", this.signIn.bind(this));
|
|
6821
6860
|
parent.use(`/${basePath}`, router);
|
|
@@ -6842,6 +6881,13 @@ var MyCustomerService = class extends AbstractService {
|
|
|
6842
6881
|
const result = this._expandWithId(request, updatedResource.id);
|
|
6843
6882
|
return response.status(200).send(result);
|
|
6844
6883
|
}
|
|
6884
|
+
deleteMe(request, response) {
|
|
6885
|
+
const resource = this.repository.deleteMe(getRepositoryContext(request));
|
|
6886
|
+
if (!resource) {
|
|
6887
|
+
return response.status(404).send("Not found");
|
|
6888
|
+
}
|
|
6889
|
+
return response.status(200).send(resource);
|
|
6890
|
+
}
|
|
6845
6891
|
signUp(request, response) {
|
|
6846
6892
|
const draft = request.body;
|
|
6847
6893
|
const resource = this.repository.create(
|