@labdigital/commercetools-mock 2.47.1 → 2.48.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 +203 -148
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -7
- package/dist/index.d.ts +10 -7
- package/dist/index.js +199 -144
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/repositories/as-associate.ts +2 -0
- package/src/repositories/index.ts +2 -0
- package/src/repositories/my-quote-request.ts +3 -0
- package/src/repositories/quote-request/index.ts +13 -1
- package/src/services/abstract.ts +25 -7
- package/src/services/as-associate-quote-request.ts +34 -0
- package/src/services/as-associate.ts +8 -0
- package/src/services/custom-object.ts +2 -2
- package/src/services/my-cart.ts +1 -1
- package/src/services/my-customer.ts +3 -3
- package/src/services/order.ts +1 -1
- package/src/services/project.ts +1 -1
package/dist/index.cjs
CHANGED
|
@@ -36,7 +36,7 @@ __export(index_exports, {
|
|
|
36
36
|
module.exports = __toCommonJS(index_exports);
|
|
37
37
|
|
|
38
38
|
// src/ctMock.ts
|
|
39
|
-
var
|
|
39
|
+
var import_express11 = __toESM(require("express"), 1);
|
|
40
40
|
var import_light_my_request = __toESM(require("light-my-request"), 1);
|
|
41
41
|
var import_morgan = __toESM(require("morgan"), 1);
|
|
42
42
|
var import_msw = require("msw");
|
|
@@ -2133,11 +2133,125 @@ var OrderRepository = class extends AbstractResourceRepository {
|
|
|
2133
2133
|
}
|
|
2134
2134
|
};
|
|
2135
2135
|
|
|
2136
|
+
// src/repositories/quote-request/index.ts
|
|
2137
|
+
var import_node_assert2 = __toESM(require("assert"), 1);
|
|
2138
|
+
|
|
2139
|
+
// src/repositories/quote-request/actions.ts
|
|
2140
|
+
var QuoteRequestUpdateHandler = class extends AbstractUpdateHandler {
|
|
2141
|
+
setCustomField(context, resource, { name, value }) {
|
|
2142
|
+
if (!resource.custom) {
|
|
2143
|
+
throw new Error("Resource has no custom field");
|
|
2144
|
+
}
|
|
2145
|
+
resource.custom.fields[name] = value;
|
|
2146
|
+
}
|
|
2147
|
+
setCustomType(context, resource, { type, fields }) {
|
|
2148
|
+
if (!type) {
|
|
2149
|
+
resource.custom = void 0;
|
|
2150
|
+
} else {
|
|
2151
|
+
const resolvedType = this._storage.getByResourceIdentifier(
|
|
2152
|
+
context.projectKey,
|
|
2153
|
+
type
|
|
2154
|
+
);
|
|
2155
|
+
if (!resolvedType) {
|
|
2156
|
+
throw new Error(`Type ${type} not found`);
|
|
2157
|
+
}
|
|
2158
|
+
resource.custom = {
|
|
2159
|
+
type: {
|
|
2160
|
+
typeId: "type",
|
|
2161
|
+
id: resolvedType.id
|
|
2162
|
+
},
|
|
2163
|
+
fields: fields || {}
|
|
2164
|
+
};
|
|
2165
|
+
}
|
|
2166
|
+
}
|
|
2167
|
+
transitionState(context, resource, { state, force }) {
|
|
2168
|
+
let stateReference = void 0;
|
|
2169
|
+
if (state) {
|
|
2170
|
+
stateReference = getReferenceFromResourceIdentifier(
|
|
2171
|
+
state,
|
|
2172
|
+
context.projectKey,
|
|
2173
|
+
this._storage
|
|
2174
|
+
);
|
|
2175
|
+
resource.state = stateReference;
|
|
2176
|
+
} else {
|
|
2177
|
+
throw new CommercetoolsError(
|
|
2178
|
+
{
|
|
2179
|
+
code: "InvalidJsonInput",
|
|
2180
|
+
message: "Request body does not contain valid JSON.",
|
|
2181
|
+
detailedErrorMessage: "actions -> state: Missing required value"
|
|
2182
|
+
},
|
|
2183
|
+
400
|
|
2184
|
+
);
|
|
2185
|
+
}
|
|
2186
|
+
return resource;
|
|
2187
|
+
}
|
|
2188
|
+
};
|
|
2189
|
+
|
|
2190
|
+
// src/repositories/quote-request/index.ts
|
|
2191
|
+
var QuoteRequestRepository = class extends AbstractResourceRepository {
|
|
2192
|
+
constructor(config) {
|
|
2193
|
+
super("quote-request", config);
|
|
2194
|
+
this.actions = new QuoteRequestUpdateHandler(config.storage);
|
|
2195
|
+
}
|
|
2196
|
+
create(context, draft) {
|
|
2197
|
+
if ("cartId" in draft) {
|
|
2198
|
+
return this.createFromCart(context, {
|
|
2199
|
+
id: draft.cartId,
|
|
2200
|
+
typeId: "cart"
|
|
2201
|
+
});
|
|
2202
|
+
}
|
|
2203
|
+
(0, import_node_assert2.default)(draft.cart, "draft.cart is missing");
|
|
2204
|
+
return this.createFromCart(context, {
|
|
2205
|
+
id: draft.cart.id,
|
|
2206
|
+
typeId: "cart"
|
|
2207
|
+
});
|
|
2208
|
+
}
|
|
2209
|
+
createFromCart(context, cartReference) {
|
|
2210
|
+
const cart = this._storage.getByResourceIdentifier(
|
|
2211
|
+
context.projectKey,
|
|
2212
|
+
cartReference
|
|
2213
|
+
);
|
|
2214
|
+
if (!cart) {
|
|
2215
|
+
throw new Error("Cannot find cart");
|
|
2216
|
+
}
|
|
2217
|
+
if (!cart.customerId) {
|
|
2218
|
+
throw new Error("Cart does not have a customer");
|
|
2219
|
+
}
|
|
2220
|
+
const resource = {
|
|
2221
|
+
...getBaseResourceProperties(),
|
|
2222
|
+
billingAddress: cart.billingAddress,
|
|
2223
|
+
cart: cartReference,
|
|
2224
|
+
country: cart.country,
|
|
2225
|
+
custom: cart.custom,
|
|
2226
|
+
customer: {
|
|
2227
|
+
typeId: "customer",
|
|
2228
|
+
id: cart.customerId
|
|
2229
|
+
},
|
|
2230
|
+
customerGroup: cart.customerGroup,
|
|
2231
|
+
customLineItems: [],
|
|
2232
|
+
directDiscounts: cart.directDiscounts,
|
|
2233
|
+
lineItems: cart.lineItems,
|
|
2234
|
+
paymentInfo: cart.paymentInfo,
|
|
2235
|
+
quoteRequestState: "Submitted",
|
|
2236
|
+
shippingAddress: cart.shippingAddress,
|
|
2237
|
+
taxCalculationMode: cart.taxCalculationMode,
|
|
2238
|
+
taxedPrice: cart.taxedPrice,
|
|
2239
|
+
taxMode: cart.taxMode,
|
|
2240
|
+
taxRoundingMode: cart.taxRoundingMode,
|
|
2241
|
+
totalPrice: cart.totalPrice,
|
|
2242
|
+
store: cart.store
|
|
2243
|
+
};
|
|
2244
|
+
return this.saveNew(context, resource);
|
|
2245
|
+
}
|
|
2246
|
+
};
|
|
2247
|
+
|
|
2136
2248
|
// src/repositories/as-associate.ts
|
|
2137
2249
|
var AsAssociateOrderRepository = class extends OrderRepository {
|
|
2138
2250
|
};
|
|
2139
2251
|
var AsAssociateCartRepository = class extends CartRepository {
|
|
2140
2252
|
};
|
|
2253
|
+
var AsAssociateQuoteRequestRepository = class extends QuoteRequestRepository {
|
|
2254
|
+
};
|
|
2141
2255
|
|
|
2142
2256
|
// src/repositories/associate-role.ts
|
|
2143
2257
|
var AssociateRoleRepository = class extends AbstractResourceRepository {
|
|
@@ -2873,7 +2987,7 @@ var CustomObjectRepository = class extends AbstractResourceRepository {
|
|
|
2873
2987
|
};
|
|
2874
2988
|
|
|
2875
2989
|
// src/repositories/customer/actions.ts
|
|
2876
|
-
var
|
|
2990
|
+
var import_node_assert3 = __toESM(require("assert"), 1);
|
|
2877
2991
|
var CustomerUpdateHandler = class extends AbstractUpdateHandler {
|
|
2878
2992
|
addAddress(_context, resource, { address }) {
|
|
2879
2993
|
resource.addresses.push({
|
|
@@ -2883,7 +2997,7 @@ var CustomerUpdateHandler = class extends AbstractUpdateHandler {
|
|
|
2883
2997
|
}
|
|
2884
2998
|
addBillingAddressId(_context, resource, { addressId, addressKey }) {
|
|
2885
2999
|
const address = this._findAddress(resource, addressId, addressKey, true);
|
|
2886
|
-
(0,
|
|
3000
|
+
(0, import_node_assert3.default)(address?.id);
|
|
2887
3001
|
if (resource.billingAddressIds === void 0) {
|
|
2888
3002
|
resource.billingAddressIds = [];
|
|
2889
3003
|
}
|
|
@@ -2893,7 +3007,7 @@ var CustomerUpdateHandler = class extends AbstractUpdateHandler {
|
|
|
2893
3007
|
}
|
|
2894
3008
|
addShippingAddressId(_context, resource, { addressId, addressKey }) {
|
|
2895
3009
|
const address = this._findAddress(resource, addressId, addressKey, true);
|
|
2896
|
-
(0,
|
|
3010
|
+
(0, import_node_assert3.default)(address?.id);
|
|
2897
3011
|
if (resource.shippingAddressIds === void 0) {
|
|
2898
3012
|
resource.shippingAddressIds = [];
|
|
2899
3013
|
}
|
|
@@ -2907,7 +3021,7 @@ var CustomerUpdateHandler = class extends AbstractUpdateHandler {
|
|
|
2907
3021
|
}
|
|
2908
3022
|
changeAddress(context, resource, { addressId, addressKey, address }) {
|
|
2909
3023
|
const current = this._findAddress(resource, addressId, addressKey, true);
|
|
2910
|
-
(0,
|
|
3024
|
+
(0, import_node_assert3.default)(current?.id);
|
|
2911
3025
|
const oldAddressIndex = resource.addresses.findIndex(
|
|
2912
3026
|
(a) => a.id === current.id
|
|
2913
3027
|
);
|
|
@@ -2933,7 +3047,7 @@ var CustomerUpdateHandler = class extends AbstractUpdateHandler {
|
|
|
2933
3047
|
action.addressKey,
|
|
2934
3048
|
true
|
|
2935
3049
|
);
|
|
2936
|
-
(0,
|
|
3050
|
+
(0, import_node_assert3.default)(address?.id);
|
|
2937
3051
|
resource.addresses = resource.addresses.filter((a) => a.id !== address.id);
|
|
2938
3052
|
}
|
|
2939
3053
|
removeBillingAddressId(context, resource, action) {
|
|
@@ -2943,7 +3057,7 @@ var CustomerUpdateHandler = class extends AbstractUpdateHandler {
|
|
|
2943
3057
|
action.addressKey,
|
|
2944
3058
|
true
|
|
2945
3059
|
);
|
|
2946
|
-
(0,
|
|
3060
|
+
(0, import_node_assert3.default)(address?.id);
|
|
2947
3061
|
resource.billingAddressIds = resource.billingAddressIds?.filter(
|
|
2948
3062
|
(id) => id !== address.id
|
|
2949
3063
|
);
|
|
@@ -2958,7 +3072,7 @@ var CustomerUpdateHandler = class extends AbstractUpdateHandler {
|
|
|
2958
3072
|
action.addressKey,
|
|
2959
3073
|
true
|
|
2960
3074
|
);
|
|
2961
|
-
(0,
|
|
3075
|
+
(0, import_node_assert3.default)(address?.id);
|
|
2962
3076
|
resource.shippingAddressIds = resource.shippingAddressIds?.filter(
|
|
2963
3077
|
(id) => id !== address.id
|
|
2964
3078
|
);
|
|
@@ -3060,7 +3174,7 @@ var CustomerUpdateHandler = class extends AbstractUpdateHandler {
|
|
|
3060
3174
|
action.addressKey,
|
|
3061
3175
|
true
|
|
3062
3176
|
);
|
|
3063
|
-
(0,
|
|
3177
|
+
(0, import_node_assert3.default)(address?.id);
|
|
3064
3178
|
resource.defaultBillingAddressId = address.id;
|
|
3065
3179
|
if (resource.billingAddressIds === void 0) {
|
|
3066
3180
|
resource.billingAddressIds = [];
|
|
@@ -3076,7 +3190,7 @@ var CustomerUpdateHandler = class extends AbstractUpdateHandler {
|
|
|
3076
3190
|
action.addressKey,
|
|
3077
3191
|
true
|
|
3078
3192
|
);
|
|
3079
|
-
(0,
|
|
3193
|
+
(0, import_node_assert3.default)(address?.id);
|
|
3080
3194
|
resource.defaultShippingAddressId = address.id;
|
|
3081
3195
|
if (resource.shippingAddressIds === void 0) {
|
|
3082
3196
|
resource.shippingAddressIds = [];
|
|
@@ -3709,10 +3823,10 @@ var MyCustomerRepository = class extends CustomerRepository {
|
|
|
3709
3823
|
};
|
|
3710
3824
|
|
|
3711
3825
|
// src/repositories/my-order.ts
|
|
3712
|
-
var
|
|
3826
|
+
var import_node_assert4 = __toESM(require("assert"), 1);
|
|
3713
3827
|
var MyOrderRepository = class extends OrderRepository {
|
|
3714
3828
|
create(context, draft) {
|
|
3715
|
-
(0,
|
|
3829
|
+
(0, import_node_assert4.default)(draft.id, "draft.id is missing");
|
|
3716
3830
|
const cartIdentifier = {
|
|
3717
3831
|
id: draft.id,
|
|
3718
3832
|
typeId: "cart"
|
|
@@ -6919,112 +7033,6 @@ var QuoteRepository = class extends AbstractResourceRepository {
|
|
|
6919
7033
|
}
|
|
6920
7034
|
};
|
|
6921
7035
|
|
|
6922
|
-
// src/repositories/quote-request/index.ts
|
|
6923
|
-
var import_node_assert4 = __toESM(require("assert"), 1);
|
|
6924
|
-
|
|
6925
|
-
// src/repositories/quote-request/actions.ts
|
|
6926
|
-
var QuoteRequestUpdateHandler = class extends AbstractUpdateHandler {
|
|
6927
|
-
setCustomField(context, resource, { name, value }) {
|
|
6928
|
-
if (!resource.custom) {
|
|
6929
|
-
throw new Error("Resource has no custom field");
|
|
6930
|
-
}
|
|
6931
|
-
resource.custom.fields[name] = value;
|
|
6932
|
-
}
|
|
6933
|
-
setCustomType(context, resource, { type, fields }) {
|
|
6934
|
-
if (!type) {
|
|
6935
|
-
resource.custom = void 0;
|
|
6936
|
-
} else {
|
|
6937
|
-
const resolvedType = this._storage.getByResourceIdentifier(
|
|
6938
|
-
context.projectKey,
|
|
6939
|
-
type
|
|
6940
|
-
);
|
|
6941
|
-
if (!resolvedType) {
|
|
6942
|
-
throw new Error(`Type ${type} not found`);
|
|
6943
|
-
}
|
|
6944
|
-
resource.custom = {
|
|
6945
|
-
type: {
|
|
6946
|
-
typeId: "type",
|
|
6947
|
-
id: resolvedType.id
|
|
6948
|
-
},
|
|
6949
|
-
fields: fields || {}
|
|
6950
|
-
};
|
|
6951
|
-
}
|
|
6952
|
-
}
|
|
6953
|
-
transitionState(context, resource, { state, force }) {
|
|
6954
|
-
let stateReference = void 0;
|
|
6955
|
-
if (state) {
|
|
6956
|
-
stateReference = getReferenceFromResourceIdentifier(
|
|
6957
|
-
state,
|
|
6958
|
-
context.projectKey,
|
|
6959
|
-
this._storage
|
|
6960
|
-
);
|
|
6961
|
-
resource.state = stateReference;
|
|
6962
|
-
} else {
|
|
6963
|
-
throw new CommercetoolsError(
|
|
6964
|
-
{
|
|
6965
|
-
code: "InvalidJsonInput",
|
|
6966
|
-
message: "Request body does not contain valid JSON.",
|
|
6967
|
-
detailedErrorMessage: "actions -> state: Missing required value"
|
|
6968
|
-
},
|
|
6969
|
-
400
|
|
6970
|
-
);
|
|
6971
|
-
}
|
|
6972
|
-
return resource;
|
|
6973
|
-
}
|
|
6974
|
-
};
|
|
6975
|
-
|
|
6976
|
-
// src/repositories/quote-request/index.ts
|
|
6977
|
-
var QuoteRequestRepository = class extends AbstractResourceRepository {
|
|
6978
|
-
constructor(config) {
|
|
6979
|
-
super("quote-request", config);
|
|
6980
|
-
this.actions = new QuoteRequestUpdateHandler(config.storage);
|
|
6981
|
-
}
|
|
6982
|
-
create(context, draft) {
|
|
6983
|
-
(0, import_node_assert4.default)(draft.cart, "draft.cart is missing");
|
|
6984
|
-
return this.createFromCart(context, {
|
|
6985
|
-
id: draft.cart.id,
|
|
6986
|
-
typeId: "cart"
|
|
6987
|
-
});
|
|
6988
|
-
}
|
|
6989
|
-
createFromCart(context, cartReference) {
|
|
6990
|
-
const cart = this._storage.getByResourceIdentifier(
|
|
6991
|
-
context.projectKey,
|
|
6992
|
-
cartReference
|
|
6993
|
-
);
|
|
6994
|
-
if (!cart) {
|
|
6995
|
-
throw new Error("Cannot find cart");
|
|
6996
|
-
}
|
|
6997
|
-
if (!cart.customerId) {
|
|
6998
|
-
throw new Error("Cart does not have a customer");
|
|
6999
|
-
}
|
|
7000
|
-
const resource = {
|
|
7001
|
-
...getBaseResourceProperties(),
|
|
7002
|
-
billingAddress: cart.billingAddress,
|
|
7003
|
-
cart: cartReference,
|
|
7004
|
-
country: cart.country,
|
|
7005
|
-
custom: cart.custom,
|
|
7006
|
-
customer: {
|
|
7007
|
-
typeId: "customer",
|
|
7008
|
-
id: cart.customerId
|
|
7009
|
-
},
|
|
7010
|
-
customerGroup: cart.customerGroup,
|
|
7011
|
-
customLineItems: [],
|
|
7012
|
-
directDiscounts: cart.directDiscounts,
|
|
7013
|
-
lineItems: cart.lineItems,
|
|
7014
|
-
paymentInfo: cart.paymentInfo,
|
|
7015
|
-
quoteRequestState: "Submitted",
|
|
7016
|
-
shippingAddress: cart.shippingAddress,
|
|
7017
|
-
taxCalculationMode: cart.taxCalculationMode,
|
|
7018
|
-
taxedPrice: cart.taxedPrice,
|
|
7019
|
-
taxMode: cart.taxMode,
|
|
7020
|
-
taxRoundingMode: cart.taxRoundingMode,
|
|
7021
|
-
totalPrice: cart.totalPrice,
|
|
7022
|
-
store: cart.store
|
|
7023
|
-
};
|
|
7024
|
-
return this.saveNew(context, resource);
|
|
7025
|
-
}
|
|
7026
|
-
};
|
|
7027
|
-
|
|
7028
7036
|
// src/repositories/quote-staged/actions.ts
|
|
7029
7037
|
var StagedQuoteUpdateHandler = class extends AbstractUpdateHandler {
|
|
7030
7038
|
setCustomField(context, resource, { name, value }) {
|
|
@@ -8019,7 +8027,8 @@ var ZoneUpdateHandler = class extends AbstractUpdateHandler {
|
|
|
8019
8027
|
var createRepositories = (config) => ({
|
|
8020
8028
|
"as-associate": {
|
|
8021
8029
|
cart: new AsAssociateCartRepository(config),
|
|
8022
|
-
order: new AsAssociateOrderRepository(config)
|
|
8030
|
+
order: new AsAssociateOrderRepository(config),
|
|
8031
|
+
"quote-request": new AsAssociateQuoteRequestRepository(config)
|
|
8023
8032
|
},
|
|
8024
8033
|
"associate-role": new AssociateRoleRepository(config),
|
|
8025
8034
|
"attribute-group": new AttributeGroupRepository(config),
|
|
@@ -8065,7 +8074,7 @@ var createRepositories = (config) => ({
|
|
|
8065
8074
|
});
|
|
8066
8075
|
|
|
8067
8076
|
// src/services/as-associate.ts
|
|
8068
|
-
var
|
|
8077
|
+
var import_express6 = require("express");
|
|
8069
8078
|
|
|
8070
8079
|
// src/services/as-associate-cart.ts
|
|
8071
8080
|
var import_express3 = require("express");
|
|
@@ -8145,7 +8154,16 @@ var AbstractService = class {
|
|
|
8145
8154
|
getWithId(request, response) {
|
|
8146
8155
|
const result = this._expandWithId(request, request.params.id);
|
|
8147
8156
|
if (!result) {
|
|
8148
|
-
response.status(404).send(
|
|
8157
|
+
response.status(404).send({
|
|
8158
|
+
statusCode: 404,
|
|
8159
|
+
message: `The Resource with ID '${request.params.id} was not found.`,
|
|
8160
|
+
errors: [
|
|
8161
|
+
{
|
|
8162
|
+
code: "ResourceNotFound",
|
|
8163
|
+
message: `The Resource with ID '${request.params.id} was not found.`
|
|
8164
|
+
}
|
|
8165
|
+
]
|
|
8166
|
+
});
|
|
8149
8167
|
return;
|
|
8150
8168
|
}
|
|
8151
8169
|
response.status(200).send(result);
|
|
@@ -8159,7 +8177,16 @@ var AbstractService = class {
|
|
|
8159
8177
|
}
|
|
8160
8178
|
);
|
|
8161
8179
|
if (!result) {
|
|
8162
|
-
response.status(404).send(
|
|
8180
|
+
response.status(404).send({
|
|
8181
|
+
statusCode: 404,
|
|
8182
|
+
message: `The Resource with key '${request.params.id} was not found.`,
|
|
8183
|
+
errors: [
|
|
8184
|
+
{
|
|
8185
|
+
code: "ResourceNotFound",
|
|
8186
|
+
message: `The Resource with key '${request.params.id} was not found.`
|
|
8187
|
+
}
|
|
8188
|
+
]
|
|
8189
|
+
});
|
|
8163
8190
|
return;
|
|
8164
8191
|
}
|
|
8165
8192
|
response.status(200).send(result);
|
|
@@ -8173,7 +8200,7 @@ var AbstractService = class {
|
|
|
8173
8200
|
}
|
|
8174
8201
|
);
|
|
8175
8202
|
if (!result) {
|
|
8176
|
-
response.
|
|
8203
|
+
response.sendStatus(404);
|
|
8177
8204
|
return;
|
|
8178
8205
|
}
|
|
8179
8206
|
response.status(200).send(result);
|
|
@@ -8184,7 +8211,7 @@ var AbstractService = class {
|
|
|
8184
8211
|
request.params.key
|
|
8185
8212
|
);
|
|
8186
8213
|
if (!resource) {
|
|
8187
|
-
response.
|
|
8214
|
+
response.sendStatus(404);
|
|
8188
8215
|
return;
|
|
8189
8216
|
}
|
|
8190
8217
|
const result = this.repository.delete(
|
|
@@ -8195,7 +8222,7 @@ var AbstractService = class {
|
|
|
8195
8222
|
}
|
|
8196
8223
|
);
|
|
8197
8224
|
if (!result) {
|
|
8198
|
-
response.
|
|
8225
|
+
response.sendStatus(404);
|
|
8199
8226
|
return;
|
|
8200
8227
|
}
|
|
8201
8228
|
response.status(200).send(result);
|
|
@@ -8219,7 +8246,7 @@ var AbstractService = class {
|
|
|
8219
8246
|
request.params.id
|
|
8220
8247
|
);
|
|
8221
8248
|
if (!resource) {
|
|
8222
|
-
response.
|
|
8249
|
+
response.sendStatus(404);
|
|
8223
8250
|
return;
|
|
8224
8251
|
}
|
|
8225
8252
|
const updatedResource = this.repository.processUpdateActions(
|
|
@@ -8241,7 +8268,7 @@ var AbstractService = class {
|
|
|
8241
8268
|
request.params.key
|
|
8242
8269
|
);
|
|
8243
8270
|
if (!resource) {
|
|
8244
|
-
response.
|
|
8271
|
+
response.sendStatus(404);
|
|
8245
8272
|
return;
|
|
8246
8273
|
}
|
|
8247
8274
|
const updatedResource = this.repository.processUpdateActions(
|
|
@@ -8316,15 +8343,43 @@ var AsAssociateOrderService = class extends AbstractService {
|
|
|
8316
8343
|
}
|
|
8317
8344
|
};
|
|
8318
8345
|
|
|
8346
|
+
// src/services/as-associate-quote-request.ts
|
|
8347
|
+
var import_express5 = require("express");
|
|
8348
|
+
var AsAssociateQuoteRequestService = class extends AbstractService {
|
|
8349
|
+
repository;
|
|
8350
|
+
constructor(parent, repository) {
|
|
8351
|
+
super(parent);
|
|
8352
|
+
this.repository = repository;
|
|
8353
|
+
}
|
|
8354
|
+
getBasePath() {
|
|
8355
|
+
return "quote-requests";
|
|
8356
|
+
}
|
|
8357
|
+
registerRoutes(parent) {
|
|
8358
|
+
const basePath = this.getBasePath();
|
|
8359
|
+
const router = (0, import_express5.Router)({ mergeParams: true });
|
|
8360
|
+
this.extraRoutes(router);
|
|
8361
|
+
router.get("/", this.get.bind(this));
|
|
8362
|
+
router.get("/:id", this.getWithId.bind(this));
|
|
8363
|
+
router.delete("/:id", this.deleteWithId.bind(this));
|
|
8364
|
+
router.post("/", this.post.bind(this));
|
|
8365
|
+
router.post("/:id", this.postWithId.bind(this));
|
|
8366
|
+
parent.use(`/${basePath}`, router);
|
|
8367
|
+
}
|
|
8368
|
+
};
|
|
8369
|
+
|
|
8319
8370
|
// src/services/as-associate.ts
|
|
8320
8371
|
var AsAssociateService = class {
|
|
8321
8372
|
router;
|
|
8322
8373
|
subServices;
|
|
8323
8374
|
constructor(parent, repositories) {
|
|
8324
|
-
this.router = (0,
|
|
8375
|
+
this.router = (0, import_express6.Router)({ mergeParams: true });
|
|
8325
8376
|
this.subServices = {
|
|
8326
8377
|
order: new AsAssociateOrderService(this.router, repositories.order),
|
|
8327
|
-
cart: new AsAssociateCartService(this.router, repositories.cart)
|
|
8378
|
+
cart: new AsAssociateCartService(this.router, repositories.cart),
|
|
8379
|
+
"quote-request": new AsAssociateQuoteRequestService(
|
|
8380
|
+
this.router,
|
|
8381
|
+
repositories["quote-request"]
|
|
8382
|
+
)
|
|
8328
8383
|
};
|
|
8329
8384
|
parent.use(
|
|
8330
8385
|
"/as-associate/:associateId/in-business-unit/key=:businessUnitId",
|
|
@@ -8485,7 +8540,7 @@ var CustomObjectService = class extends AbstractService {
|
|
|
8485
8540
|
request.params.key
|
|
8486
8541
|
);
|
|
8487
8542
|
if (!result) {
|
|
8488
|
-
response.
|
|
8543
|
+
response.sendStatus(404);
|
|
8489
8544
|
return;
|
|
8490
8545
|
}
|
|
8491
8546
|
response.status(200).send(result);
|
|
@@ -8506,7 +8561,7 @@ var CustomObjectService = class extends AbstractService {
|
|
|
8506
8561
|
request.params.key
|
|
8507
8562
|
);
|
|
8508
8563
|
if (!current) {
|
|
8509
|
-
response.
|
|
8564
|
+
response.sendStatus(404);
|
|
8510
8565
|
return;
|
|
8511
8566
|
}
|
|
8512
8567
|
const result = this.repository.delete(
|
|
@@ -8617,7 +8672,7 @@ var InventoryEntryService = class extends AbstractService {
|
|
|
8617
8672
|
};
|
|
8618
8673
|
|
|
8619
8674
|
// src/services/my-business-unit.ts
|
|
8620
|
-
var
|
|
8675
|
+
var import_express7 = require("express");
|
|
8621
8676
|
var MyBusinessUnitService = class extends AbstractService {
|
|
8622
8677
|
repository;
|
|
8623
8678
|
constructor(parent, repository) {
|
|
@@ -8629,7 +8684,7 @@ var MyBusinessUnitService = class extends AbstractService {
|
|
|
8629
8684
|
}
|
|
8630
8685
|
registerRoutes(parent) {
|
|
8631
8686
|
const basePath = this.getBasePath();
|
|
8632
|
-
const router = (0,
|
|
8687
|
+
const router = (0, import_express7.Router)({ mergeParams: true });
|
|
8633
8688
|
this.extraRoutes(router);
|
|
8634
8689
|
router.get("/business-units/", this.get.bind(this));
|
|
8635
8690
|
parent.use(`/${basePath}`, router);
|
|
@@ -8637,7 +8692,7 @@ var MyBusinessUnitService = class extends AbstractService {
|
|
|
8637
8692
|
};
|
|
8638
8693
|
|
|
8639
8694
|
// src/services/my-cart.ts
|
|
8640
|
-
var
|
|
8695
|
+
var import_express8 = require("express");
|
|
8641
8696
|
var MyCartService = class extends AbstractService {
|
|
8642
8697
|
repository;
|
|
8643
8698
|
constructor(parent, repository) {
|
|
@@ -8649,7 +8704,7 @@ var MyCartService = class extends AbstractService {
|
|
|
8649
8704
|
}
|
|
8650
8705
|
registerRoutes(parent) {
|
|
8651
8706
|
const basePath = this.getBasePath();
|
|
8652
|
-
const router = (0,
|
|
8707
|
+
const router = (0, import_express8.Router)({ mergeParams: true });
|
|
8653
8708
|
this.extraRoutes(router);
|
|
8654
8709
|
router.get("/active-cart", this.activeCart.bind(this));
|
|
8655
8710
|
router.get("/carts/", this.get.bind(this));
|
|
@@ -8662,7 +8717,7 @@ var MyCartService = class extends AbstractService {
|
|
|
8662
8717
|
activeCart(request, response) {
|
|
8663
8718
|
const resource = this.repository.getActiveCart(request.params.projectKey);
|
|
8664
8719
|
if (!resource) {
|
|
8665
|
-
response.
|
|
8720
|
+
response.sendStatus(404);
|
|
8666
8721
|
return;
|
|
8667
8722
|
}
|
|
8668
8723
|
response.status(200).send(resource);
|
|
@@ -8670,7 +8725,7 @@ var MyCartService = class extends AbstractService {
|
|
|
8670
8725
|
};
|
|
8671
8726
|
|
|
8672
8727
|
// src/services/my-customer.ts
|
|
8673
|
-
var
|
|
8728
|
+
var import_express9 = require("express");
|
|
8674
8729
|
var MyCustomerService = class extends AbstractService {
|
|
8675
8730
|
repository;
|
|
8676
8731
|
constructor(parent, repository) {
|
|
@@ -8682,7 +8737,7 @@ var MyCustomerService = class extends AbstractService {
|
|
|
8682
8737
|
}
|
|
8683
8738
|
registerRoutes(parent) {
|
|
8684
8739
|
const basePath = this.getBasePath();
|
|
8685
|
-
const router = (0,
|
|
8740
|
+
const router = (0, import_express9.Router)({ mergeParams: true });
|
|
8686
8741
|
this.extraRoutes(router);
|
|
8687
8742
|
router.get("", this.getMe.bind(this));
|
|
8688
8743
|
router.post("", this.updateMe.bind(this));
|
|
@@ -8697,7 +8752,7 @@ var MyCustomerService = class extends AbstractService {
|
|
|
8697
8752
|
getMe(request, response) {
|
|
8698
8753
|
const resource = this.repository.getMe(getRepositoryContext(request));
|
|
8699
8754
|
if (!resource) {
|
|
8700
|
-
response.
|
|
8755
|
+
response.sendStatus(404);
|
|
8701
8756
|
return;
|
|
8702
8757
|
}
|
|
8703
8758
|
response.status(200).send(resource);
|
|
@@ -8705,7 +8760,7 @@ var MyCustomerService = class extends AbstractService {
|
|
|
8705
8760
|
updateMe(request, response) {
|
|
8706
8761
|
const resource = this.repository.getMe(getRepositoryContext(request));
|
|
8707
8762
|
if (!resource) {
|
|
8708
|
-
response.
|
|
8763
|
+
response.sendStatus(404);
|
|
8709
8764
|
return;
|
|
8710
8765
|
}
|
|
8711
8766
|
const updateRequest = validateData(
|
|
@@ -8724,7 +8779,7 @@ var MyCustomerService = class extends AbstractService {
|
|
|
8724
8779
|
deleteMe(request, response) {
|
|
8725
8780
|
const resource = this.repository.deleteMe(getRepositoryContext(request));
|
|
8726
8781
|
if (!resource) {
|
|
8727
|
-
response.
|
|
8782
|
+
response.sendStatus(404);
|
|
8728
8783
|
return;
|
|
8729
8784
|
}
|
|
8730
8785
|
response.status(200).send(resource);
|
|
@@ -8782,7 +8837,7 @@ var MyCustomerService = class extends AbstractService {
|
|
|
8782
8837
|
};
|
|
8783
8838
|
|
|
8784
8839
|
// src/services/my-order.ts
|
|
8785
|
-
var
|
|
8840
|
+
var import_express10 = require("express");
|
|
8786
8841
|
var MyOrderService = class extends AbstractService {
|
|
8787
8842
|
repository;
|
|
8788
8843
|
constructor(parent, repository) {
|
|
@@ -8794,7 +8849,7 @@ var MyOrderService = class extends AbstractService {
|
|
|
8794
8849
|
}
|
|
8795
8850
|
registerRoutes(parent) {
|
|
8796
8851
|
const basePath = this.getBasePath();
|
|
8797
|
-
const router = (0,
|
|
8852
|
+
const router = (0, import_express10.Router)({ mergeParams: true });
|
|
8798
8853
|
this.extraRoutes(router);
|
|
8799
8854
|
router.get("/orders/", this.get.bind(this));
|
|
8800
8855
|
router.get("/orders/:id", this.getWithId.bind(this));
|
|
@@ -8865,7 +8920,7 @@ var OrderService = class extends AbstractService {
|
|
|
8865
8920
|
response.status(200).send(resource);
|
|
8866
8921
|
return;
|
|
8867
8922
|
}
|
|
8868
|
-
response.
|
|
8923
|
+
response.sendStatus(404);
|
|
8869
8924
|
}
|
|
8870
8925
|
};
|
|
8871
8926
|
|
|
@@ -9259,7 +9314,7 @@ var ProjectService = class {
|
|
|
9259
9314
|
);
|
|
9260
9315
|
const project = this.repository.get(getRepositoryContext(request));
|
|
9261
9316
|
if (!project) {
|
|
9262
|
-
response.
|
|
9317
|
+
response.sendStatus(404);
|
|
9263
9318
|
return;
|
|
9264
9319
|
}
|
|
9265
9320
|
const updatedResource = this.repository.processUpdateActions(
|
|
@@ -9688,9 +9743,9 @@ var CommercetoolsMock = class {
|
|
|
9688
9743
|
};
|
|
9689
9744
|
this._repositories = createRepositories(config);
|
|
9690
9745
|
this._oauth2.setCustomerRepository(this._repositories.customer);
|
|
9691
|
-
const app = (0,
|
|
9692
|
-
const projectRouter =
|
|
9693
|
-
projectRouter.use(
|
|
9746
|
+
const app = (0, import_express11.default)();
|
|
9747
|
+
const projectRouter = import_express11.default.Router({ mergeParams: true });
|
|
9748
|
+
projectRouter.use(import_express11.default.json());
|
|
9694
9749
|
if (!options?.silent) {
|
|
9695
9750
|
app.use((0, import_morgan.default)("tiny"));
|
|
9696
9751
|
}
|