@labdigital/commercetools-mock 2.47.1 → 2.48.1

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
@@ -257,7 +257,7 @@ var OAuth2Server = class {
257
257
  return async (request, response, next) => {
258
258
  const token = getBearerToken(request);
259
259
  if (!token) {
260
- next(
260
+ return next(
261
261
  new CommercetoolsError(
262
262
  {
263
263
  code: "invalid_token",
@@ -268,7 +268,7 @@ var OAuth2Server = class {
268
268
  );
269
269
  }
270
270
  if (!token || !this.store.validateToken(token)) {
271
- next(
271
+ return next(
272
272
  new CommercetoolsError(
273
273
  {
274
274
  code: "invalid_token",
@@ -278,7 +278,7 @@ var OAuth2Server = class {
278
278
  )
279
279
  );
280
280
  }
281
- next();
281
+ return next();
282
282
  };
283
283
  }
284
284
  async validateClientCredentials(request, response, next) {
@@ -2096,11 +2096,125 @@ var OrderRepository = class extends AbstractResourceRepository {
2096
2096
  }
2097
2097
  };
2098
2098
 
2099
+ // src/repositories/quote-request/index.ts
2100
+ import assert2 from "node:assert";
2101
+
2102
+ // src/repositories/quote-request/actions.ts
2103
+ var QuoteRequestUpdateHandler = class extends AbstractUpdateHandler {
2104
+ setCustomField(context, resource, { name, value }) {
2105
+ if (!resource.custom) {
2106
+ throw new Error("Resource has no custom field");
2107
+ }
2108
+ resource.custom.fields[name] = value;
2109
+ }
2110
+ setCustomType(context, resource, { type, fields }) {
2111
+ if (!type) {
2112
+ resource.custom = void 0;
2113
+ } else {
2114
+ const resolvedType = this._storage.getByResourceIdentifier(
2115
+ context.projectKey,
2116
+ type
2117
+ );
2118
+ if (!resolvedType) {
2119
+ throw new Error(`Type ${type} not found`);
2120
+ }
2121
+ resource.custom = {
2122
+ type: {
2123
+ typeId: "type",
2124
+ id: resolvedType.id
2125
+ },
2126
+ fields: fields || {}
2127
+ };
2128
+ }
2129
+ }
2130
+ transitionState(context, resource, { state, force }) {
2131
+ let stateReference = void 0;
2132
+ if (state) {
2133
+ stateReference = getReferenceFromResourceIdentifier(
2134
+ state,
2135
+ context.projectKey,
2136
+ this._storage
2137
+ );
2138
+ resource.state = stateReference;
2139
+ } else {
2140
+ throw new CommercetoolsError(
2141
+ {
2142
+ code: "InvalidJsonInput",
2143
+ message: "Request body does not contain valid JSON.",
2144
+ detailedErrorMessage: "actions -> state: Missing required value"
2145
+ },
2146
+ 400
2147
+ );
2148
+ }
2149
+ return resource;
2150
+ }
2151
+ };
2152
+
2153
+ // src/repositories/quote-request/index.ts
2154
+ var QuoteRequestRepository = class extends AbstractResourceRepository {
2155
+ constructor(config) {
2156
+ super("quote-request", config);
2157
+ this.actions = new QuoteRequestUpdateHandler(config.storage);
2158
+ }
2159
+ create(context, draft) {
2160
+ if ("cartId" in draft) {
2161
+ return this.createFromCart(context, {
2162
+ id: draft.cartId,
2163
+ typeId: "cart"
2164
+ });
2165
+ }
2166
+ assert2(draft.cart, "draft.cart is missing");
2167
+ return this.createFromCart(context, {
2168
+ id: draft.cart.id,
2169
+ typeId: "cart"
2170
+ });
2171
+ }
2172
+ createFromCart(context, cartReference) {
2173
+ const cart = this._storage.getByResourceIdentifier(
2174
+ context.projectKey,
2175
+ cartReference
2176
+ );
2177
+ if (!cart) {
2178
+ throw new Error("Cannot find cart");
2179
+ }
2180
+ if (!cart.customerId) {
2181
+ throw new Error("Cart does not have a customer");
2182
+ }
2183
+ const resource = {
2184
+ ...getBaseResourceProperties(),
2185
+ billingAddress: cart.billingAddress,
2186
+ cart: cartReference,
2187
+ country: cart.country,
2188
+ custom: cart.custom,
2189
+ customer: {
2190
+ typeId: "customer",
2191
+ id: cart.customerId
2192
+ },
2193
+ customerGroup: cart.customerGroup,
2194
+ customLineItems: [],
2195
+ directDiscounts: cart.directDiscounts,
2196
+ lineItems: cart.lineItems,
2197
+ paymentInfo: cart.paymentInfo,
2198
+ quoteRequestState: "Submitted",
2199
+ shippingAddress: cart.shippingAddress,
2200
+ taxCalculationMode: cart.taxCalculationMode,
2201
+ taxedPrice: cart.taxedPrice,
2202
+ taxMode: cart.taxMode,
2203
+ taxRoundingMode: cart.taxRoundingMode,
2204
+ totalPrice: cart.totalPrice,
2205
+ store: cart.store
2206
+ };
2207
+ return this.saveNew(context, resource);
2208
+ }
2209
+ };
2210
+
2099
2211
  // src/repositories/as-associate.ts
2100
2212
  var AsAssociateOrderRepository = class extends OrderRepository {
2101
2213
  };
2102
2214
  var AsAssociateCartRepository = class extends CartRepository {
2103
2215
  };
2216
+ var AsAssociateQuoteRequestRepository = class extends QuoteRequestRepository {
2217
+ };
2104
2218
 
2105
2219
  // src/repositories/associate-role.ts
2106
2220
  var AssociateRoleRepository = class extends AbstractResourceRepository {
@@ -2836,7 +2950,7 @@ var CustomObjectRepository = class extends AbstractResourceRepository {
2836
2950
  };
2837
2951
 
2838
2952
  // src/repositories/customer/actions.ts
2839
- import assert2 from "node:assert";
2953
+ import assert3 from "node:assert";
2840
2954
  var CustomerUpdateHandler = class extends AbstractUpdateHandler {
2841
2955
  addAddress(_context, resource, { address }) {
2842
2956
  resource.addresses.push({
@@ -2846,7 +2960,7 @@ var CustomerUpdateHandler = class extends AbstractUpdateHandler {
2846
2960
  }
2847
2961
  addBillingAddressId(_context, resource, { addressId, addressKey }) {
2848
2962
  const address = this._findAddress(resource, addressId, addressKey, true);
2849
- assert2(address?.id);
2963
+ assert3(address?.id);
2850
2964
  if (resource.billingAddressIds === void 0) {
2851
2965
  resource.billingAddressIds = [];
2852
2966
  }
@@ -2856,7 +2970,7 @@ var CustomerUpdateHandler = class extends AbstractUpdateHandler {
2856
2970
  }
2857
2971
  addShippingAddressId(_context, resource, { addressId, addressKey }) {
2858
2972
  const address = this._findAddress(resource, addressId, addressKey, true);
2859
- assert2(address?.id);
2973
+ assert3(address?.id);
2860
2974
  if (resource.shippingAddressIds === void 0) {
2861
2975
  resource.shippingAddressIds = [];
2862
2976
  }
@@ -2870,7 +2984,7 @@ var CustomerUpdateHandler = class extends AbstractUpdateHandler {
2870
2984
  }
2871
2985
  changeAddress(context, resource, { addressId, addressKey, address }) {
2872
2986
  const current = this._findAddress(resource, addressId, addressKey, true);
2873
- assert2(current?.id);
2987
+ assert3(current?.id);
2874
2988
  const oldAddressIndex = resource.addresses.findIndex(
2875
2989
  (a) => a.id === current.id
2876
2990
  );
@@ -2896,7 +3010,7 @@ var CustomerUpdateHandler = class extends AbstractUpdateHandler {
2896
3010
  action.addressKey,
2897
3011
  true
2898
3012
  );
2899
- assert2(address?.id);
3013
+ assert3(address?.id);
2900
3014
  resource.addresses = resource.addresses.filter((a) => a.id !== address.id);
2901
3015
  }
2902
3016
  removeBillingAddressId(context, resource, action) {
@@ -2906,7 +3020,7 @@ var CustomerUpdateHandler = class extends AbstractUpdateHandler {
2906
3020
  action.addressKey,
2907
3021
  true
2908
3022
  );
2909
- assert2(address?.id);
3023
+ assert3(address?.id);
2910
3024
  resource.billingAddressIds = resource.billingAddressIds?.filter(
2911
3025
  (id) => id !== address.id
2912
3026
  );
@@ -2921,7 +3035,7 @@ var CustomerUpdateHandler = class extends AbstractUpdateHandler {
2921
3035
  action.addressKey,
2922
3036
  true
2923
3037
  );
2924
- assert2(address?.id);
3038
+ assert3(address?.id);
2925
3039
  resource.shippingAddressIds = resource.shippingAddressIds?.filter(
2926
3040
  (id) => id !== address.id
2927
3041
  );
@@ -3023,7 +3137,7 @@ var CustomerUpdateHandler = class extends AbstractUpdateHandler {
3023
3137
  action.addressKey,
3024
3138
  true
3025
3139
  );
3026
- assert2(address?.id);
3140
+ assert3(address?.id);
3027
3141
  resource.defaultBillingAddressId = address.id;
3028
3142
  if (resource.billingAddressIds === void 0) {
3029
3143
  resource.billingAddressIds = [];
@@ -3039,7 +3153,7 @@ var CustomerUpdateHandler = class extends AbstractUpdateHandler {
3039
3153
  action.addressKey,
3040
3154
  true
3041
3155
  );
3042
- assert2(address?.id);
3156
+ assert3(address?.id);
3043
3157
  resource.defaultShippingAddressId = address.id;
3044
3158
  if (resource.shippingAddressIds === void 0) {
3045
3159
  resource.shippingAddressIds = [];
@@ -3672,10 +3786,10 @@ var MyCustomerRepository = class extends CustomerRepository {
3672
3786
  };
3673
3787
 
3674
3788
  // src/repositories/my-order.ts
3675
- import assert3 from "node:assert";
3789
+ import assert4 from "node:assert";
3676
3790
  var MyOrderRepository = class extends OrderRepository {
3677
3791
  create(context, draft) {
3678
- assert3(draft.id, "draft.id is missing");
3792
+ assert4(draft.id, "draft.id is missing");
3679
3793
  const cartIdentifier = {
3680
3794
  id: draft.id,
3681
3795
  typeId: "cart"
@@ -6882,112 +6996,6 @@ var QuoteRepository = class extends AbstractResourceRepository {
6882
6996
  }
6883
6997
  };
6884
6998
 
6885
- // src/repositories/quote-request/index.ts
6886
- import assert4 from "node:assert";
6887
-
6888
- // src/repositories/quote-request/actions.ts
6889
- var QuoteRequestUpdateHandler = class extends AbstractUpdateHandler {
6890
- setCustomField(context, resource, { name, value }) {
6891
- if (!resource.custom) {
6892
- throw new Error("Resource has no custom field");
6893
- }
6894
- resource.custom.fields[name] = value;
6895
- }
6896
- setCustomType(context, resource, { type, fields }) {
6897
- if (!type) {
6898
- resource.custom = void 0;
6899
- } else {
6900
- const resolvedType = this._storage.getByResourceIdentifier(
6901
- context.projectKey,
6902
- type
6903
- );
6904
- if (!resolvedType) {
6905
- throw new Error(`Type ${type} not found`);
6906
- }
6907
- resource.custom = {
6908
- type: {
6909
- typeId: "type",
6910
- id: resolvedType.id
6911
- },
6912
- fields: fields || {}
6913
- };
6914
- }
6915
- }
6916
- transitionState(context, resource, { state, force }) {
6917
- let stateReference = void 0;
6918
- if (state) {
6919
- stateReference = getReferenceFromResourceIdentifier(
6920
- state,
6921
- context.projectKey,
6922
- this._storage
6923
- );
6924
- resource.state = stateReference;
6925
- } else {
6926
- throw new CommercetoolsError(
6927
- {
6928
- code: "InvalidJsonInput",
6929
- message: "Request body does not contain valid JSON.",
6930
- detailedErrorMessage: "actions -> state: Missing required value"
6931
- },
6932
- 400
6933
- );
6934
- }
6935
- return resource;
6936
- }
6937
- };
6938
-
6939
- // src/repositories/quote-request/index.ts
6940
- var QuoteRequestRepository = class extends AbstractResourceRepository {
6941
- constructor(config) {
6942
- super("quote-request", config);
6943
- this.actions = new QuoteRequestUpdateHandler(config.storage);
6944
- }
6945
- create(context, draft) {
6946
- assert4(draft.cart, "draft.cart is missing");
6947
- return this.createFromCart(context, {
6948
- id: draft.cart.id,
6949
- typeId: "cart"
6950
- });
6951
- }
6952
- createFromCart(context, cartReference) {
6953
- const cart = this._storage.getByResourceIdentifier(
6954
- context.projectKey,
6955
- cartReference
6956
- );
6957
- if (!cart) {
6958
- throw new Error("Cannot find cart");
6959
- }
6960
- if (!cart.customerId) {
6961
- throw new Error("Cart does not have a customer");
6962
- }
6963
- const resource = {
6964
- ...getBaseResourceProperties(),
6965
- billingAddress: cart.billingAddress,
6966
- cart: cartReference,
6967
- country: cart.country,
6968
- custom: cart.custom,
6969
- customer: {
6970
- typeId: "customer",
6971
- id: cart.customerId
6972
- },
6973
- customerGroup: cart.customerGroup,
6974
- customLineItems: [],
6975
- directDiscounts: cart.directDiscounts,
6976
- lineItems: cart.lineItems,
6977
- paymentInfo: cart.paymentInfo,
6978
- quoteRequestState: "Submitted",
6979
- shippingAddress: cart.shippingAddress,
6980
- taxCalculationMode: cart.taxCalculationMode,
6981
- taxedPrice: cart.taxedPrice,
6982
- taxMode: cart.taxMode,
6983
- taxRoundingMode: cart.taxRoundingMode,
6984
- totalPrice: cart.totalPrice,
6985
- store: cart.store
6986
- };
6987
- return this.saveNew(context, resource);
6988
- }
6989
- };
6990
-
6991
6999
  // src/repositories/quote-staged/actions.ts
6992
7000
  var StagedQuoteUpdateHandler = class extends AbstractUpdateHandler {
6993
7001
  setCustomField(context, resource, { name, value }) {
@@ -7982,7 +7990,8 @@ var ZoneUpdateHandler = class extends AbstractUpdateHandler {
7982
7990
  var createRepositories = (config) => ({
7983
7991
  "as-associate": {
7984
7992
  cart: new AsAssociateCartRepository(config),
7985
- order: new AsAssociateOrderRepository(config)
7993
+ order: new AsAssociateOrderRepository(config),
7994
+ "quote-request": new AsAssociateQuoteRequestRepository(config)
7986
7995
  },
7987
7996
  "associate-role": new AssociateRoleRepository(config),
7988
7997
  "attribute-group": new AttributeGroupRepository(config),
@@ -8028,7 +8037,7 @@ var createRepositories = (config) => ({
8028
8037
  });
8029
8038
 
8030
8039
  // src/services/as-associate.ts
8031
- import { Router as Router4 } from "express";
8040
+ import { Router as Router5 } from "express";
8032
8041
 
8033
8042
  // src/services/as-associate-cart.ts
8034
8043
  import { Router as Router2 } from "express";
@@ -8108,7 +8117,16 @@ var AbstractService = class {
8108
8117
  getWithId(request, response) {
8109
8118
  const result = this._expandWithId(request, request.params.id);
8110
8119
  if (!result) {
8111
- response.status(404).send();
8120
+ response.status(404).send({
8121
+ statusCode: 404,
8122
+ message: `The Resource with ID '${request.params.id} was not found.`,
8123
+ errors: [
8124
+ {
8125
+ code: "ResourceNotFound",
8126
+ message: `The Resource with ID '${request.params.id} was not found.`
8127
+ }
8128
+ ]
8129
+ });
8112
8130
  return;
8113
8131
  }
8114
8132
  response.status(200).send(result);
@@ -8122,7 +8140,16 @@ var AbstractService = class {
8122
8140
  }
8123
8141
  );
8124
8142
  if (!result) {
8125
- response.status(404).send();
8143
+ response.status(404).send({
8144
+ statusCode: 404,
8145
+ message: `The Resource with key '${request.params.id} was not found.`,
8146
+ errors: [
8147
+ {
8148
+ code: "ResourceNotFound",
8149
+ message: `The Resource with key '${request.params.id} was not found.`
8150
+ }
8151
+ ]
8152
+ });
8126
8153
  return;
8127
8154
  }
8128
8155
  response.status(200).send(result);
@@ -8136,7 +8163,7 @@ var AbstractService = class {
8136
8163
  }
8137
8164
  );
8138
8165
  if (!result) {
8139
- response.status(404).send("Not found");
8166
+ response.status(404).send({ statusCode: 404 });
8140
8167
  return;
8141
8168
  }
8142
8169
  response.status(200).send(result);
@@ -8147,7 +8174,7 @@ var AbstractService = class {
8147
8174
  request.params.key
8148
8175
  );
8149
8176
  if (!resource) {
8150
- response.status(404).send("Not found");
8177
+ response.status(404).send({ statusCode: 404 });
8151
8178
  return;
8152
8179
  }
8153
8180
  const result = this.repository.delete(
@@ -8158,7 +8185,7 @@ var AbstractService = class {
8158
8185
  }
8159
8186
  );
8160
8187
  if (!result) {
8161
- response.status(404).send("Not found");
8188
+ response.status(404).send({ statusCode: 404 });
8162
8189
  return;
8163
8190
  }
8164
8191
  response.status(200).send(result);
@@ -8182,7 +8209,7 @@ var AbstractService = class {
8182
8209
  request.params.id
8183
8210
  );
8184
8211
  if (!resource) {
8185
- response.status(404).send("Not found");
8212
+ response.status(404).send({ statusCode: 404 });
8186
8213
  return;
8187
8214
  }
8188
8215
  const updatedResource = this.repository.processUpdateActions(
@@ -8204,7 +8231,7 @@ var AbstractService = class {
8204
8231
  request.params.key
8205
8232
  );
8206
8233
  if (!resource) {
8207
- response.status(404).send("Not found");
8234
+ response.status(404).send({ statusCode: 404 });
8208
8235
  return;
8209
8236
  }
8210
8237
  const updatedResource = this.repository.processUpdateActions(
@@ -8279,15 +8306,43 @@ var AsAssociateOrderService = class extends AbstractService {
8279
8306
  }
8280
8307
  };
8281
8308
 
8309
+ // src/services/as-associate-quote-request.ts
8310
+ import { Router as Router4 } from "express";
8311
+ var AsAssociateQuoteRequestService = class extends AbstractService {
8312
+ repository;
8313
+ constructor(parent, repository) {
8314
+ super(parent);
8315
+ this.repository = repository;
8316
+ }
8317
+ getBasePath() {
8318
+ return "quote-requests";
8319
+ }
8320
+ registerRoutes(parent) {
8321
+ const basePath = this.getBasePath();
8322
+ const router = Router4({ mergeParams: true });
8323
+ this.extraRoutes(router);
8324
+ router.get("/", this.get.bind(this));
8325
+ router.get("/:id", this.getWithId.bind(this));
8326
+ router.delete("/:id", this.deleteWithId.bind(this));
8327
+ router.post("/", this.post.bind(this));
8328
+ router.post("/:id", this.postWithId.bind(this));
8329
+ parent.use(`/${basePath}`, router);
8330
+ }
8331
+ };
8332
+
8282
8333
  // src/services/as-associate.ts
8283
8334
  var AsAssociateService = class {
8284
8335
  router;
8285
8336
  subServices;
8286
8337
  constructor(parent, repositories) {
8287
- this.router = Router4({ mergeParams: true });
8338
+ this.router = Router5({ mergeParams: true });
8288
8339
  this.subServices = {
8289
8340
  order: new AsAssociateOrderService(this.router, repositories.order),
8290
- cart: new AsAssociateCartService(this.router, repositories.cart)
8341
+ cart: new AsAssociateCartService(this.router, repositories.cart),
8342
+ "quote-request": new AsAssociateQuoteRequestService(
8343
+ this.router,
8344
+ repositories["quote-request"]
8345
+ )
8291
8346
  };
8292
8347
  parent.use(
8293
8348
  "/as-associate/:associateId/in-business-unit/key=:businessUnitId",
@@ -8448,7 +8503,7 @@ var CustomObjectService = class extends AbstractService {
8448
8503
  request.params.key
8449
8504
  );
8450
8505
  if (!result) {
8451
- response.status(404).send("Not Found");
8506
+ response.status(404).send({ statusCode: 404 });
8452
8507
  return;
8453
8508
  }
8454
8509
  response.status(200).send(result);
@@ -8469,7 +8524,7 @@ var CustomObjectService = class extends AbstractService {
8469
8524
  request.params.key
8470
8525
  );
8471
8526
  if (!current) {
8472
- response.status(404).send("Not Found");
8527
+ response.status(404).send({ statusCode: 404 });
8473
8528
  return;
8474
8529
  }
8475
8530
  const result = this.repository.delete(
@@ -8580,7 +8635,7 @@ var InventoryEntryService = class extends AbstractService {
8580
8635
  };
8581
8636
 
8582
8637
  // src/services/my-business-unit.ts
8583
- import { Router as Router5 } from "express";
8638
+ import { Router as Router6 } from "express";
8584
8639
  var MyBusinessUnitService = class extends AbstractService {
8585
8640
  repository;
8586
8641
  constructor(parent, repository) {
@@ -8592,7 +8647,7 @@ var MyBusinessUnitService = class extends AbstractService {
8592
8647
  }
8593
8648
  registerRoutes(parent) {
8594
8649
  const basePath = this.getBasePath();
8595
- const router = Router5({ mergeParams: true });
8650
+ const router = Router6({ mergeParams: true });
8596
8651
  this.extraRoutes(router);
8597
8652
  router.get("/business-units/", this.get.bind(this));
8598
8653
  parent.use(`/${basePath}`, router);
@@ -8600,7 +8655,7 @@ var MyBusinessUnitService = class extends AbstractService {
8600
8655
  };
8601
8656
 
8602
8657
  // src/services/my-cart.ts
8603
- import { Router as Router6 } from "express";
8658
+ import { Router as Router7 } from "express";
8604
8659
  var MyCartService = class extends AbstractService {
8605
8660
  repository;
8606
8661
  constructor(parent, repository) {
@@ -8612,7 +8667,7 @@ var MyCartService = class extends AbstractService {
8612
8667
  }
8613
8668
  registerRoutes(parent) {
8614
8669
  const basePath = this.getBasePath();
8615
- const router = Router6({ mergeParams: true });
8670
+ const router = Router7({ mergeParams: true });
8616
8671
  this.extraRoutes(router);
8617
8672
  router.get("/active-cart", this.activeCart.bind(this));
8618
8673
  router.get("/carts/", this.get.bind(this));
@@ -8625,7 +8680,16 @@ var MyCartService = class extends AbstractService {
8625
8680
  activeCart(request, response) {
8626
8681
  const resource = this.repository.getActiveCart(request.params.projectKey);
8627
8682
  if (!resource) {
8628
- response.status(404).send("Not found");
8683
+ response.status(404).send({
8684
+ statusCode: 404,
8685
+ message: "No active cart exists.",
8686
+ errors: [
8687
+ {
8688
+ code: "ResourceNotFound",
8689
+ message: "No active cart exists."
8690
+ }
8691
+ ]
8692
+ });
8629
8693
  return;
8630
8694
  }
8631
8695
  response.status(200).send(resource);
@@ -8633,7 +8697,7 @@ var MyCartService = class extends AbstractService {
8633
8697
  };
8634
8698
 
8635
8699
  // src/services/my-customer.ts
8636
- import { Router as Router7 } from "express";
8700
+ import { Router as Router8 } from "express";
8637
8701
  var MyCustomerService = class extends AbstractService {
8638
8702
  repository;
8639
8703
  constructor(parent, repository) {
@@ -8645,7 +8709,7 @@ var MyCustomerService = class extends AbstractService {
8645
8709
  }
8646
8710
  registerRoutes(parent) {
8647
8711
  const basePath = this.getBasePath();
8648
- const router = Router7({ mergeParams: true });
8712
+ const router = Router8({ mergeParams: true });
8649
8713
  this.extraRoutes(router);
8650
8714
  router.get("", this.getMe.bind(this));
8651
8715
  router.post("", this.updateMe.bind(this));
@@ -8660,7 +8724,7 @@ var MyCustomerService = class extends AbstractService {
8660
8724
  getMe(request, response) {
8661
8725
  const resource = this.repository.getMe(getRepositoryContext(request));
8662
8726
  if (!resource) {
8663
- response.status(404).send("Not found");
8727
+ response.status(404).send({ statusCode: 404 });
8664
8728
  return;
8665
8729
  }
8666
8730
  response.status(200).send(resource);
@@ -8668,7 +8732,7 @@ var MyCustomerService = class extends AbstractService {
8668
8732
  updateMe(request, response) {
8669
8733
  const resource = this.repository.getMe(getRepositoryContext(request));
8670
8734
  if (!resource) {
8671
- response.status(404).send("Not found");
8735
+ response.status(404).send({ statusCode: 404 });
8672
8736
  return;
8673
8737
  }
8674
8738
  const updateRequest = validateData(
@@ -8687,7 +8751,7 @@ var MyCustomerService = class extends AbstractService {
8687
8751
  deleteMe(request, response) {
8688
8752
  const resource = this.repository.deleteMe(getRepositoryContext(request));
8689
8753
  if (!resource) {
8690
- response.status(404).send("Not found");
8754
+ response.status(404).send({ statusCode: 404 });
8691
8755
  return;
8692
8756
  }
8693
8757
  response.status(200).send(resource);
@@ -8745,7 +8809,7 @@ var MyCustomerService = class extends AbstractService {
8745
8809
  };
8746
8810
 
8747
8811
  // src/services/my-order.ts
8748
- import { Router as Router8 } from "express";
8812
+ import { Router as Router9 } from "express";
8749
8813
  var MyOrderService = class extends AbstractService {
8750
8814
  repository;
8751
8815
  constructor(parent, repository) {
@@ -8757,7 +8821,7 @@ var MyOrderService = class extends AbstractService {
8757
8821
  }
8758
8822
  registerRoutes(parent) {
8759
8823
  const basePath = this.getBasePath();
8760
- const router = Router8({ mergeParams: true });
8824
+ const router = Router9({ mergeParams: true });
8761
8825
  this.extraRoutes(router);
8762
8826
  router.get("/orders/", this.get.bind(this));
8763
8827
  router.get("/orders/:id", this.getWithId.bind(this));
@@ -8818,9 +8882,10 @@ var OrderService = class extends AbstractService {
8818
8882
  response.status(200).send(resource);
8819
8883
  }
8820
8884
  getWithOrderNumber(request, response) {
8885
+ const orderNumber = request.params.orderNumber;
8821
8886
  const resource = this.repository.getWithOrderNumber(
8822
8887
  getRepositoryContext(request),
8823
- request.params.orderNumber,
8888
+ orderNumber,
8824
8889
  // @ts-ignore
8825
8890
  request.query
8826
8891
  );
@@ -8828,7 +8893,16 @@ var OrderService = class extends AbstractService {
8828
8893
  response.status(200).send(resource);
8829
8894
  return;
8830
8895
  }
8831
- response.status(404).send("Not found");
8896
+ response.status(404).send({
8897
+ statusCode: 404,
8898
+ message: `The Resource with key '${orderNumber}' was not found.`,
8899
+ errors: [
8900
+ {
8901
+ code: "ResourceNotFound",
8902
+ message: `The Resource with key '${orderNumber}' was not found.`
8903
+ }
8904
+ ]
8905
+ });
8832
8906
  }
8833
8907
  };
8834
8908
 
@@ -9222,7 +9296,7 @@ var ProjectService = class {
9222
9296
  );
9223
9297
  const project = this.repository.get(getRepositoryContext(request));
9224
9298
  if (!project) {
9225
- response.status(404).send({});
9299
+ response.status(404).send({ statusCode: 404 });
9226
9300
  return;
9227
9301
  }
9228
9302
  const updatedResource = this.repository.processUpdateActions(
@@ -9652,8 +9726,8 @@ var CommercetoolsMock = class {
9652
9726
  this._repositories = createRepositories(config);
9653
9727
  this._oauth2.setCustomerRepository(this._repositories.customer);
9654
9728
  const app = express2();
9729
+ app.use(express2.json());
9655
9730
  const projectRouter = express2.Router({ mergeParams: true });
9656
- projectRouter.use(express2.json());
9657
9731
  if (!options?.silent) {
9658
9732
  app.use(morgan("tiny"));
9659
9733
  }