@labdigital/commercetools-mock 2.12.2 → 2.14.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 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
  };
@@ -3901,32 +3939,6 @@ var PaymentRepository = class extends AbstractResourceRepository {
3901
3939
  // Documented as default
3902
3940
  });
3903
3941
  actions = {
3904
- setCustomField: (context, resource, { name, value }) => {
3905
- if (!resource.custom) {
3906
- throw new Error("Resource has no custom field");
3907
- }
3908
- resource.custom.fields[name] = value;
3909
- },
3910
- setCustomType: (context, resource, { type, fields }) => {
3911
- if (!type) {
3912
- resource.custom = void 0;
3913
- } else {
3914
- const resolvedType = this._storage.getByResourceIdentifier(
3915
- context.projectKey,
3916
- type
3917
- );
3918
- if (!resolvedType) {
3919
- throw new Error(`Type ${type} not found`);
3920
- }
3921
- resource.custom = {
3922
- type: {
3923
- typeId: "type",
3924
- id: resolvedType.id
3925
- },
3926
- fields: fields ?? {}
3927
- };
3928
- }
3929
- },
3930
3942
  addTransaction: (context, resource, { transaction }) => {
3931
3943
  resource.transactions = [
3932
3944
  ...resource.transactions,
@@ -3956,24 +3968,60 @@ var PaymentRepository = class extends AbstractResourceRepository {
3956
3968
  id: stateObj.id,
3957
3969
  obj: stateObj
3958
3970
  };
3971
+ },
3972
+ setCustomField: (context, resource, { name, value }) => {
3973
+ if (!resource.custom) {
3974
+ throw new Error("Resource has no custom field");
3975
+ }
3976
+ resource.custom.fields[name] = value;
3977
+ },
3978
+ setCustomType: (context, resource, { type, fields }) => {
3979
+ if (!type) {
3980
+ resource.custom = void 0;
3981
+ } else {
3982
+ const resolvedType = this._storage.getByResourceIdentifier(
3983
+ context.projectKey,
3984
+ type
3985
+ );
3986
+ if (!resolvedType) {
3987
+ throw new Error(`Type ${type} not found`);
3988
+ }
3989
+ resource.custom = {
3990
+ type: {
3991
+ typeId: "type",
3992
+ id: resolvedType.id
3993
+ },
3994
+ fields: fields ?? {}
3995
+ };
3996
+ }
3997
+ },
3998
+ setKey: (_context, resource, { key }) => {
3999
+ resource.key = key;
4000
+ },
4001
+ setStatusInterfaceCode: (_context, resource, { interfaceCode }) => {
4002
+ resource.paymentStatus.interfaceCode = interfaceCode;
4003
+ },
4004
+ setStatusInterfaceText: (_context, resource, { interfaceText }) => {
4005
+ resource.paymentStatus.interfaceText = interfaceText;
4006
+ },
4007
+ setMethodInfoName: (_context, resource, { name }) => {
4008
+ resource.paymentMethodInfo.name = name;
4009
+ },
4010
+ setMethodInfoMethod: (_context, resource, { method }) => {
4011
+ resource.paymentMethodInfo.method = method;
4012
+ },
4013
+ setMethodInfoInterface: (_context, resource, args) => {
4014
+ resource.paymentMethodInfo.paymentInterface = args.interface;
4015
+ },
4016
+ setInterfaceId: (_context, resource, { interfaceId }) => {
4017
+ resource.interfaceId = interfaceId;
3959
4018
  }
3960
4019
  // addInterfaceInteraction: () => {},
3961
4020
  // changeAmountPlanned: () => {},
3962
4021
  // changeTransactionInteractionId: () => {},
3963
4022
  // changeTransactionTimestamp: () => {},
3964
- // setAmountPaid: () => {},
3965
- // setAmountRefunded: () => {},
3966
4023
  // setAnonymousId: () => {},
3967
- // setAuthorization: () => {},
3968
4024
  // setCustomer: () => {},
3969
- // setExternalId: () => {},
3970
- // setInterfaceId: () => {},
3971
- // setKey: () => {},
3972
- // setMethodInfoInterface: () => {},
3973
- // setMethodInfoMethod: () => {},
3974
- // setMethodInfoName: () => {},
3975
- // setStatusInterfaceCode: () => {},
3976
- // setStatusInterfaceText: () => {},
3977
4025
  };
3978
4026
  };
3979
4027
 
@@ -6816,6 +6864,7 @@ var MyCustomerService = class extends AbstractService {
6816
6864
  this.extraRoutes(router);
6817
6865
  router.get("", this.getMe.bind(this));
6818
6866
  router.post("", this.updateMe.bind(this));
6867
+ router.delete("", this.deleteMe.bind(this));
6819
6868
  router.post("/signup", this.signUp.bind(this));
6820
6869
  router.post("/login", this.signIn.bind(this));
6821
6870
  parent.use(`/${basePath}`, router);
@@ -6842,6 +6891,13 @@ var MyCustomerService = class extends AbstractService {
6842
6891
  const result = this._expandWithId(request, updatedResource.id);
6843
6892
  return response.status(200).send(result);
6844
6893
  }
6894
+ deleteMe(request, response) {
6895
+ const resource = this.repository.deleteMe(getRepositoryContext(request));
6896
+ if (!resource) {
6897
+ return response.status(404).send("Not found");
6898
+ }
6899
+ return response.status(200).send(resource);
6900
+ }
6845
6901
  signUp(request, response) {
6846
6902
  const draft = request.body;
6847
6903
  const resource = this.repository.create(