@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.js
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
3789
|
+
import assert4 from "node:assert";
|
|
3676
3790
|
var MyOrderRepository = class extends OrderRepository {
|
|
3677
3791
|
create(context, draft) {
|
|
3678
|
-
|
|
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
|
|
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.
|
|
8166
|
+
response.sendStatus(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.
|
|
8177
|
+
response.sendStatus(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.
|
|
8188
|
+
response.sendStatus(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.
|
|
8212
|
+
response.sendStatus(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.
|
|
8234
|
+
response.sendStatus(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 =
|
|
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.
|
|
8506
|
+
response.sendStatus(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.
|
|
8527
|
+
response.sendStatus(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
|
|
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 =
|
|
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
|
|
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 =
|
|
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,7 @@ 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.
|
|
8683
|
+
response.sendStatus(404);
|
|
8629
8684
|
return;
|
|
8630
8685
|
}
|
|
8631
8686
|
response.status(200).send(resource);
|
|
@@ -8633,7 +8688,7 @@ var MyCartService = class extends AbstractService {
|
|
|
8633
8688
|
};
|
|
8634
8689
|
|
|
8635
8690
|
// src/services/my-customer.ts
|
|
8636
|
-
import { Router as
|
|
8691
|
+
import { Router as Router8 } from "express";
|
|
8637
8692
|
var MyCustomerService = class extends AbstractService {
|
|
8638
8693
|
repository;
|
|
8639
8694
|
constructor(parent, repository) {
|
|
@@ -8645,7 +8700,7 @@ var MyCustomerService = class extends AbstractService {
|
|
|
8645
8700
|
}
|
|
8646
8701
|
registerRoutes(parent) {
|
|
8647
8702
|
const basePath = this.getBasePath();
|
|
8648
|
-
const router =
|
|
8703
|
+
const router = Router8({ mergeParams: true });
|
|
8649
8704
|
this.extraRoutes(router);
|
|
8650
8705
|
router.get("", this.getMe.bind(this));
|
|
8651
8706
|
router.post("", this.updateMe.bind(this));
|
|
@@ -8660,7 +8715,7 @@ var MyCustomerService = class extends AbstractService {
|
|
|
8660
8715
|
getMe(request, response) {
|
|
8661
8716
|
const resource = this.repository.getMe(getRepositoryContext(request));
|
|
8662
8717
|
if (!resource) {
|
|
8663
|
-
response.
|
|
8718
|
+
response.sendStatus(404);
|
|
8664
8719
|
return;
|
|
8665
8720
|
}
|
|
8666
8721
|
response.status(200).send(resource);
|
|
@@ -8668,7 +8723,7 @@ var MyCustomerService = class extends AbstractService {
|
|
|
8668
8723
|
updateMe(request, response) {
|
|
8669
8724
|
const resource = this.repository.getMe(getRepositoryContext(request));
|
|
8670
8725
|
if (!resource) {
|
|
8671
|
-
response.
|
|
8726
|
+
response.sendStatus(404);
|
|
8672
8727
|
return;
|
|
8673
8728
|
}
|
|
8674
8729
|
const updateRequest = validateData(
|
|
@@ -8687,7 +8742,7 @@ var MyCustomerService = class extends AbstractService {
|
|
|
8687
8742
|
deleteMe(request, response) {
|
|
8688
8743
|
const resource = this.repository.deleteMe(getRepositoryContext(request));
|
|
8689
8744
|
if (!resource) {
|
|
8690
|
-
response.
|
|
8745
|
+
response.sendStatus(404);
|
|
8691
8746
|
return;
|
|
8692
8747
|
}
|
|
8693
8748
|
response.status(200).send(resource);
|
|
@@ -8745,7 +8800,7 @@ var MyCustomerService = class extends AbstractService {
|
|
|
8745
8800
|
};
|
|
8746
8801
|
|
|
8747
8802
|
// src/services/my-order.ts
|
|
8748
|
-
import { Router as
|
|
8803
|
+
import { Router as Router9 } from "express";
|
|
8749
8804
|
var MyOrderService = class extends AbstractService {
|
|
8750
8805
|
repository;
|
|
8751
8806
|
constructor(parent, repository) {
|
|
@@ -8757,7 +8812,7 @@ var MyOrderService = class extends AbstractService {
|
|
|
8757
8812
|
}
|
|
8758
8813
|
registerRoutes(parent) {
|
|
8759
8814
|
const basePath = this.getBasePath();
|
|
8760
|
-
const router =
|
|
8815
|
+
const router = Router9({ mergeParams: true });
|
|
8761
8816
|
this.extraRoutes(router);
|
|
8762
8817
|
router.get("/orders/", this.get.bind(this));
|
|
8763
8818
|
router.get("/orders/:id", this.getWithId.bind(this));
|
|
@@ -8828,7 +8883,7 @@ var OrderService = class extends AbstractService {
|
|
|
8828
8883
|
response.status(200).send(resource);
|
|
8829
8884
|
return;
|
|
8830
8885
|
}
|
|
8831
|
-
response.
|
|
8886
|
+
response.sendStatus(404);
|
|
8832
8887
|
}
|
|
8833
8888
|
};
|
|
8834
8889
|
|
|
@@ -9222,7 +9277,7 @@ var ProjectService = class {
|
|
|
9222
9277
|
);
|
|
9223
9278
|
const project = this.repository.get(getRepositoryContext(request));
|
|
9224
9279
|
if (!project) {
|
|
9225
|
-
response.
|
|
9280
|
+
response.sendStatus(404);
|
|
9226
9281
|
return;
|
|
9227
9282
|
}
|
|
9228
9283
|
const updatedResource = this.repository.processUpdateActions(
|