@gradientedge/commercetools-utils 4.11.1 → 4.12.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/ge-commercetools-utils-browser.cjs.js +2 -0
- package/dist/ge-commercetools-utils-browser.cjs.js.map +1 -0
- package/dist/ge-commercetools-utils-browser.esm.js +2 -0
- package/dist/ge-commercetools-utils-browser.esm.js.map +1 -0
- package/dist/ge-commercetools-utils-node.cjs.js +2 -0
- package/dist/ge-commercetools-utils-node.cjs.js.map +1 -0
- package/dist/ge-commercetools-utils-node.esm.js +1 -0
- package/dist/typings/api/CommercetoolsApi.d.ts +436 -0
- package/{build → dist/typings}/api/index.d.ts +0 -1
- package/dist/typings/api/types.d.ts +12 -0
- package/dist/typings/auth/CommercetoolsAuth.d.ts +22 -0
- package/dist/typings/auth/CommercetoolsAuthApi.d.ts +21 -0
- package/dist/typings/auth/CommercetoolsGrant.d.ts +13 -0
- package/{build → dist/typings}/auth/constants.d.ts +0 -4
- package/dist/typings/auth/index.d.ts +3 -0
- package/dist/typings/auth/scopes.d.ts +2 -0
- package/dist/typings/auth/types.d.ts +43 -0
- package/{build → dist/typings}/auth/utils.d.ts +0 -1
- package/dist/typings/constants.d.ts +1 -0
- package/dist/typings/error/CommercetoolsError.d.ts +16 -0
- package/{build → dist/typings}/error/index.d.ts +0 -1
- package/dist/typings/index.d.ts +6 -0
- package/dist/typings/models/cart-discount.d.ts +196 -0
- package/dist/typings/models/cart.d.ts +597 -0
- package/dist/typings/models/category.d.ts +166 -0
- package/dist/typings/models/channel.d.ts +103 -0
- package/dist/typings/models/common.d.ts +232 -0
- package/dist/typings/models/custom-object.d.ts +30 -0
- package/dist/typings/models/customer-group.d.ts +58 -0
- package/dist/typings/models/customer.d.ts +276 -0
- package/dist/typings/models/discount-code.d.ts +116 -0
- package/dist/typings/models/error.d.ts +412 -0
- package/dist/typings/models/extension.d.ts +78 -0
- package/dist/typings/models/graph-ql.d.ts +21 -0
- package/dist/typings/models/index.d.ts +33 -0
- package/dist/typings/models/inventory.d.ts +82 -0
- package/dist/typings/models/me.d.ts +481 -0
- package/dist/typings/models/message.d.ts +1823 -0
- package/dist/typings/models/order-edit.d.ts +565 -0
- package/dist/typings/models/order.d.ts +558 -0
- package/dist/typings/models/payment.d.ts +208 -0
- package/dist/typings/models/product-discount.d.ts +123 -0
- package/dist/typings/models/product-selection.d.ts +106 -0
- package/dist/typings/models/product-type.d.ts +216 -0
- package/dist/typings/models/product.d.ts +517 -0
- package/dist/typings/models/project.d.ts +108 -0
- package/dist/typings/models/review.d.ts +115 -0
- package/dist/typings/models/scalar-types.d.ts +4 -0
- package/dist/typings/models/shipping-method.d.ts +160 -0
- package/dist/typings/models/shopping-list.d.ts +217 -0
- package/dist/typings/models/state.d.ts +86 -0
- package/dist/typings/models/store.d.ts +121 -0
- package/dist/typings/models/subscription.d.ts +148 -0
- package/dist/typings/models/tax-category.d.ts +87 -0
- package/dist/typings/models/type.d.ts +182 -0
- package/dist/typings/models/zone.d.ts +65 -0
- package/dist/typings/types.d.ts +21 -0
- package/dist/typings/utils/format.d.ts +1 -0
- package/{build → dist/typings}/utils/index.d.ts +0 -1
- package/dist/typings/utils/mask.d.ts +6 -0
- package/dist/typings/utils/useragent.d.ts +1 -0
- package/package.json +40 -18
- package/.husky/pre-commit +0 -4
- package/.nvmrc +0 -1
- package/build/api/CommercetoolsApi.d.ts +0 -1096
- package/build/api/CommercetoolsApi.d.ts.map +0 -1
- package/build/api/CommercetoolsApi.js +0 -1419
- package/build/api/CommercetoolsApi.js.map +0 -1
- package/build/api/index.d.ts.map +0 -1
- package/build/api/index.js +0 -15
- package/build/api/index.js.map +0 -1
- package/build/api/types.d.ts +0 -33
- package/build/api/types.d.ts.map +0 -1
- package/build/api/types.js +0 -3
- package/build/api/types.js.map +0 -1
- package/build/auth/CommercetoolsAuth.d.ts +0 -182
- package/build/auth/CommercetoolsAuth.d.ts.map +0 -1
- package/build/auth/CommercetoolsAuth.js +0 -326
- package/build/auth/CommercetoolsAuth.js.map +0 -1
- package/build/auth/CommercetoolsAuthApi.d.ts +0 -74
- package/build/auth/CommercetoolsAuthApi.d.ts.map +0 -1
- package/build/auth/CommercetoolsAuthApi.js +0 -249
- package/build/auth/CommercetoolsAuthApi.js.map +0 -1
- package/build/auth/CommercetoolsGrant.d.ts +0 -66
- package/build/auth/CommercetoolsGrant.d.ts.map +0 -1
- package/build/auth/CommercetoolsGrant.js +0 -82
- package/build/auth/CommercetoolsGrant.js.map +0 -1
- package/build/auth/constants.d.ts.map +0 -1
- package/build/auth/constants.js +0 -32
- package/build/auth/constants.js.map +0 -1
- package/build/auth/index.d.ts +0 -4
- package/build/auth/index.d.ts.map +0 -1
- package/build/auth/index.js +0 -18
- package/build/auth/index.js.map +0 -1
- package/build/auth/scopes.d.ts +0 -11
- package/build/auth/scopes.d.ts.map +0 -1
- package/build/auth/scopes.js +0 -30
- package/build/auth/scopes.js.map +0 -1
- package/build/auth/types.d.ts +0 -120
- package/build/auth/types.d.ts.map +0 -1
- package/build/auth/types.js +0 -28
- package/build/auth/types.js.map +0 -1
- package/build/auth/utils.d.ts.map +0 -1
- package/build/auth/utils.js +0 -8
- package/build/auth/utils.js.map +0 -1
- package/build/constants.d.ts +0 -6
- package/build/constants.d.ts.map +0 -1
- package/build/constants.js +0 -9
- package/build/constants.js.map +0 -1
- package/build/error/CommercetoolsError.d.ts +0 -38
- package/build/error/CommercetoolsError.d.ts.map +0 -1
- package/build/error/CommercetoolsError.js +0 -117
- package/build/error/CommercetoolsError.js.map +0 -1
- package/build/error/index.d.ts.map +0 -1
- package/build/error/index.js +0 -14
- package/build/error/index.js.map +0 -1
- package/build/index.d.ts +0 -7
- package/build/index.d.ts.map +0 -1
- package/build/index.js +0 -21
- package/build/index.js.map +0 -1
- package/build/types.d.ts +0 -44
- package/build/types.d.ts.map +0 -1
- package/build/types.js +0 -16
- package/build/types.js.map +0 -1
- package/build/utils/format.d.ts +0 -11
- package/build/utils/format.d.ts.map +0 -1
- package/build/utils/format.js +0 -48
- package/build/utils/format.js.map +0 -1
- package/build/utils/index.d.ts.map +0 -1
- package/build/utils/index.js +0 -16
- package/build/utils/index.js.map +0 -1
- package/build/utils/mask.d.ts +0 -28
- package/build/utils/mask.d.ts.map +0 -1
- package/build/utils/mask.js +0 -56
- package/build/utils/mask.js.map +0 -1
- package/build/utils/useragent.d.ts +0 -10
- package/build/utils/useragent.d.ts.map +0 -1
- package/build/utils/useragent.js +0 -20
- package/build/utils/useragent.js.map +0 -1
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { CommercetoolsApiConfig, CommercetoolsRetryConfig } from './types';
|
|
3
|
+
import { CommercetoolsAuth } from '../';
|
|
4
|
+
import { RegionEndpoints } from '../types';
|
|
5
|
+
import type { Cart, CartDiscount, CartDiscountPagedQueryResponse, CartDraft, CartPagedQueryResponse, CartUpdateAction, Category, CategoryDraft, CategoryPagedQueryResponse, CategoryUpdate, Channel, ChannelPagedQueryResponse, Customer, CustomerCreatePasswordResetToken, CustomerDraft, CustomerGroup, CustomerGroupDraft, CustomerGroupPagedQueryResponse, CustomerGroupUpdate, CustomerPagedQueryResponse, CustomerResetPassword, CustomerSignin, CustomerSignInResult, CustomerToken, CustomerUpdate, CustomObject, CustomObjectDraft, DiscountCode, GraphQLRequest, GraphQLResponse, MyCartDraft, MyCustomerDraft, MyPayment, MyPaymentDraft, MyPaymentPagedQueryResponse, MyPaymentUpdate, Order, OrderImportDraft, OrderPagedQueryResponse, OrderUpdate, Payment, PaymentPagedQueryResponse, PaymentUpdate, Product, ProductDraft, ProductProjection, ProductProjectionPagedQueryResponse, ProductsInStorePagedQueryResponse, ProductSelection, ProductSelectionDraft, ProductSelectionPagedQueryResponse, ProductSelectionUpdateAction, ProductType, ProductUpdate, ShippingMethod, ShippingMethodPagedQueryResponse, Store, StoreDraft, StorePagedQueryResponse, StoreUpdate, Type } from '../models';
|
|
6
|
+
export interface FetchOptions<T = Record<string, any>> {
|
|
7
|
+
path: string;
|
|
8
|
+
headers?: Record<string, string>;
|
|
9
|
+
method: 'GET' | 'POST' | 'DELETE' | 'HEAD';
|
|
10
|
+
params?: Record<string, any>;
|
|
11
|
+
data?: T;
|
|
12
|
+
accessToken?: string;
|
|
13
|
+
correlationId?: string;
|
|
14
|
+
retry?: CommercetoolsRetryConfig;
|
|
15
|
+
}
|
|
16
|
+
export interface CommonRequestOptions {
|
|
17
|
+
correlationId?: string;
|
|
18
|
+
params?: Record<string, any>;
|
|
19
|
+
retry?: CommercetoolsRetryConfig;
|
|
20
|
+
}
|
|
21
|
+
export interface CommonStoreEnabledRequestOptions extends CommonRequestOptions {
|
|
22
|
+
storeKey?: string;
|
|
23
|
+
}
|
|
24
|
+
export declare class CommercetoolsApi {
|
|
25
|
+
readonly auth: CommercetoolsAuth;
|
|
26
|
+
readonly config: CommercetoolsApiConfig;
|
|
27
|
+
readonly endpoints: RegionEndpoints;
|
|
28
|
+
private readonly userAgent;
|
|
29
|
+
private readonly axios;
|
|
30
|
+
private readonly retry;
|
|
31
|
+
constructor(config: CommercetoolsApiConfig);
|
|
32
|
+
createAxiosInstance(): AxiosInstance;
|
|
33
|
+
getStoreById(options: CommonRequestOptions & {
|
|
34
|
+
id: string;
|
|
35
|
+
}): Promise<Store>;
|
|
36
|
+
getStoreByKey(options: CommonRequestOptions & {
|
|
37
|
+
key: string;
|
|
38
|
+
}): Promise<Store>;
|
|
39
|
+
queryStores(options?: CommonRequestOptions): Promise<StorePagedQueryResponse>;
|
|
40
|
+
createStore(options: CommonRequestOptions & {
|
|
41
|
+
data: StoreDraft;
|
|
42
|
+
}): Promise<Store>;
|
|
43
|
+
updateStoreById(options: CommonRequestOptions & {
|
|
44
|
+
id: string;
|
|
45
|
+
data: StoreUpdate;
|
|
46
|
+
}): Promise<Store>;
|
|
47
|
+
updateStoreByKey(options: CommonRequestOptions & {
|
|
48
|
+
key: string;
|
|
49
|
+
data: StoreUpdate;
|
|
50
|
+
}): Promise<Store>;
|
|
51
|
+
deleteStoreById(options: CommonRequestOptions & {
|
|
52
|
+
id: string;
|
|
53
|
+
version: number;
|
|
54
|
+
}): Promise<Store>;
|
|
55
|
+
deleteStoreByKey(options: CommonRequestOptions & {
|
|
56
|
+
key: string;
|
|
57
|
+
version: number;
|
|
58
|
+
}): Promise<Store>;
|
|
59
|
+
getCategoryById(options: CommonRequestOptions & {
|
|
60
|
+
id: string;
|
|
61
|
+
}): Promise<Category>;
|
|
62
|
+
getCategoryByKey(options: CommonRequestOptions & {
|
|
63
|
+
key: string;
|
|
64
|
+
}): Promise<Category>;
|
|
65
|
+
queryChannels(options?: CommonRequestOptions): Promise<ChannelPagedQueryResponse>;
|
|
66
|
+
importOrder(options: CommonRequestOptions & {
|
|
67
|
+
data: OrderImportDraft;
|
|
68
|
+
}): Promise<Order>;
|
|
69
|
+
getChannelById(options: CommonRequestOptions & {
|
|
70
|
+
id: string;
|
|
71
|
+
}): Promise<Channel>;
|
|
72
|
+
getCategory(options: CommonRequestOptions & {
|
|
73
|
+
id?: string;
|
|
74
|
+
key?: string;
|
|
75
|
+
}): Promise<Category>;
|
|
76
|
+
getCategoryBySlug(options: CommonRequestOptions & {
|
|
77
|
+
slug: string;
|
|
78
|
+
languageCode?: string;
|
|
79
|
+
languageCodes?: string[];
|
|
80
|
+
}): Promise<Category>;
|
|
81
|
+
queryCategories(options?: CommonRequestOptions): Promise<CategoryPagedQueryResponse>;
|
|
82
|
+
getCategoryParents(options: CommonRequestOptions & {
|
|
83
|
+
id?: string;
|
|
84
|
+
key?: string;
|
|
85
|
+
}): Promise<Array<Category>>;
|
|
86
|
+
getProductById(options: CommonRequestOptions & {
|
|
87
|
+
id: string;
|
|
88
|
+
}): Promise<Product>;
|
|
89
|
+
getProductByKey(options: CommonRequestOptions & {
|
|
90
|
+
key: string;
|
|
91
|
+
}): Promise<Product>;
|
|
92
|
+
getProductProjectionById(options: CommonStoreEnabledRequestOptions & {
|
|
93
|
+
id: string;
|
|
94
|
+
}): Promise<ProductProjection>;
|
|
95
|
+
getProductProjectionByKey(options: CommonStoreEnabledRequestOptions & {
|
|
96
|
+
key: string;
|
|
97
|
+
}): Promise<ProductProjection>;
|
|
98
|
+
getProductProjectionBySlug(options: CommonRequestOptions & {
|
|
99
|
+
slug: string;
|
|
100
|
+
languageCode?: string;
|
|
101
|
+
languageCodes?: string[];
|
|
102
|
+
}): Promise<ProductProjection>;
|
|
103
|
+
queryProductProjections(options?: CommonRequestOptions): Promise<ProductProjectionPagedQueryResponse>;
|
|
104
|
+
searchProductProjections(options: CommonStoreEnabledRequestOptions): Promise<ProductProjectionPagedQueryResponse>;
|
|
105
|
+
getProductSelectionById(options: CommonStoreEnabledRequestOptions & {
|
|
106
|
+
id: string;
|
|
107
|
+
}): Promise<ProductSelection>;
|
|
108
|
+
getProductSelectionByKey(options: CommonStoreEnabledRequestOptions & {
|
|
109
|
+
key: string;
|
|
110
|
+
}): Promise<ProductSelection>;
|
|
111
|
+
queryProductSelections(options?: CommonStoreEnabledRequestOptions): Promise<ProductSelectionPagedQueryResponse>;
|
|
112
|
+
createProductSelection(options: CommonStoreEnabledRequestOptions & {
|
|
113
|
+
data: ProductSelectionDraft;
|
|
114
|
+
}): Promise<ProductSelection>;
|
|
115
|
+
updateProductSelectionByKey(options: CommonStoreEnabledRequestOptions & {
|
|
116
|
+
key: string;
|
|
117
|
+
version: number;
|
|
118
|
+
actions: ProductSelectionUpdateAction[];
|
|
119
|
+
}): Promise<ProductSelection>;
|
|
120
|
+
deleteProductSelectionByKey(options: CommonStoreEnabledRequestOptions & {
|
|
121
|
+
key: string;
|
|
122
|
+
version: number;
|
|
123
|
+
}): Promise<ProductSelection>;
|
|
124
|
+
queryProductsInStore(options: CommonStoreEnabledRequestOptions): Promise<ProductsInStorePagedQueryResponse>;
|
|
125
|
+
getCartById(options: CommonStoreEnabledRequestOptions & {
|
|
126
|
+
id: string;
|
|
127
|
+
}): Promise<Cart>;
|
|
128
|
+
queryCarts(options?: CommonStoreEnabledRequestOptions): Promise<CartPagedQueryResponse>;
|
|
129
|
+
queryMyCarts(options: CommonStoreEnabledRequestOptions & {
|
|
130
|
+
accessToken: string;
|
|
131
|
+
}): Promise<CartPagedQueryResponse>;
|
|
132
|
+
createCart(options: CommonStoreEnabledRequestOptions & {
|
|
133
|
+
data: CartDraft;
|
|
134
|
+
}): Promise<Cart>;
|
|
135
|
+
updateCartById(options: CommonStoreEnabledRequestOptions & {
|
|
136
|
+
id: string;
|
|
137
|
+
version: number;
|
|
138
|
+
actions: CartUpdateAction[];
|
|
139
|
+
}): Promise<Cart>;
|
|
140
|
+
getMyActiveCart(options: CommonStoreEnabledRequestOptions & {
|
|
141
|
+
accessToken: string;
|
|
142
|
+
}): Promise<Cart>;
|
|
143
|
+
getMyCartById(options: CommonStoreEnabledRequestOptions & {
|
|
144
|
+
accessToken: string;
|
|
145
|
+
cartId: string;
|
|
146
|
+
}): Promise<Cart>;
|
|
147
|
+
createMyCart(options: CommonStoreEnabledRequestOptions & {
|
|
148
|
+
accessToken: string;
|
|
149
|
+
data: MyCartDraft;
|
|
150
|
+
}): Promise<Cart>;
|
|
151
|
+
deleteMyActiveCart(options: CommonStoreEnabledRequestOptions & {
|
|
152
|
+
accessToken: string;
|
|
153
|
+
}): Promise<Cart>;
|
|
154
|
+
deleteMyCartById(options: CommonStoreEnabledRequestOptions & {
|
|
155
|
+
accessToken: string;
|
|
156
|
+
cartId: string;
|
|
157
|
+
}): Promise<Cart>;
|
|
158
|
+
updateMyActiveCart(options: CommonStoreEnabledRequestOptions & {
|
|
159
|
+
accessToken: string;
|
|
160
|
+
actions: CartUpdateAction[];
|
|
161
|
+
}): Promise<Cart>;
|
|
162
|
+
createMyOrderFromActiveCart(options: CommonStoreEnabledRequestOptions & {
|
|
163
|
+
accessToken: string;
|
|
164
|
+
}): Promise<Order>;
|
|
165
|
+
deleteCartById(options: CommonStoreEnabledRequestOptions & {
|
|
166
|
+
id: string;
|
|
167
|
+
version: number;
|
|
168
|
+
}): Promise<Cart>;
|
|
169
|
+
createPayment(options: CommonRequestOptions & {
|
|
170
|
+
data: MyPaymentDraft;
|
|
171
|
+
}): Promise<Payment>;
|
|
172
|
+
deletePaymentById(options: CommonRequestOptions & {
|
|
173
|
+
id: string;
|
|
174
|
+
version: number;
|
|
175
|
+
}): Promise<Payment>;
|
|
176
|
+
updatePaymentById(options: CommonRequestOptions & {
|
|
177
|
+
id: string;
|
|
178
|
+
data: PaymentUpdate;
|
|
179
|
+
}): Promise<Payment>;
|
|
180
|
+
getPaymentById(options: CommonRequestOptions & {
|
|
181
|
+
id: string;
|
|
182
|
+
}): Promise<Payment>;
|
|
183
|
+
queryPayments(options: CommonRequestOptions): Promise<PaymentPagedQueryResponse>;
|
|
184
|
+
createMyPayment(options: CommonRequestOptions & {
|
|
185
|
+
data: MyPaymentDraft;
|
|
186
|
+
accessToken: string;
|
|
187
|
+
}): Promise<MyPayment>;
|
|
188
|
+
updateMyPaymentById(options: CommonRequestOptions & {
|
|
189
|
+
id: string;
|
|
190
|
+
data: MyPaymentUpdate;
|
|
191
|
+
accessToken: string;
|
|
192
|
+
}): Promise<MyPayment>;
|
|
193
|
+
getMyPaymentById(options: CommonRequestOptions & {
|
|
194
|
+
id: string;
|
|
195
|
+
accessToken: string;
|
|
196
|
+
}): Promise<MyPayment>;
|
|
197
|
+
queryMyPayments(options: CommonRequestOptions & {
|
|
198
|
+
accessToken: string;
|
|
199
|
+
}): Promise<MyPaymentPagedQueryResponse>;
|
|
200
|
+
getMyOrderById(options: CommonStoreEnabledRequestOptions & {
|
|
201
|
+
id: string;
|
|
202
|
+
accessToken: string;
|
|
203
|
+
}): Promise<Order>;
|
|
204
|
+
queryMyOrders(options: CommonStoreEnabledRequestOptions & {
|
|
205
|
+
accessToken: string;
|
|
206
|
+
}): Promise<OrderPagedQueryResponse>;
|
|
207
|
+
updateOrderById(options: CommonStoreEnabledRequestOptions & {
|
|
208
|
+
id: string;
|
|
209
|
+
data: OrderUpdate;
|
|
210
|
+
}): Promise<Order>;
|
|
211
|
+
updateOrderByOrderNumber(options: CommonStoreEnabledRequestOptions & {
|
|
212
|
+
orderNumber: string;
|
|
213
|
+
data: OrderUpdate;
|
|
214
|
+
}): Promise<Order>;
|
|
215
|
+
getOrderById(options: CommonStoreEnabledRequestOptions & {
|
|
216
|
+
id: string;
|
|
217
|
+
}): Promise<Order>;
|
|
218
|
+
getOrderByOrderNumber(options: CommonStoreEnabledRequestOptions & {
|
|
219
|
+
orderNumber: string;
|
|
220
|
+
}): Promise<Order>;
|
|
221
|
+
deleteOrderById(options: CommonStoreEnabledRequestOptions & {
|
|
222
|
+
id: string;
|
|
223
|
+
version: number;
|
|
224
|
+
dataErasure?: boolean;
|
|
225
|
+
}): Promise<Order>;
|
|
226
|
+
deleteOrderByOrderNumber(options: CommonStoreEnabledRequestOptions & {
|
|
227
|
+
orderNo: string;
|
|
228
|
+
version: number;
|
|
229
|
+
dataErasure?: boolean;
|
|
230
|
+
}): Promise<Order>;
|
|
231
|
+
queryOrders(options: CommonStoreEnabledRequestOptions): Promise<OrderPagedQueryResponse>;
|
|
232
|
+
createProduct(options: CommonRequestOptions & {
|
|
233
|
+
data: ProductDraft;
|
|
234
|
+
}): Promise<Product>;
|
|
235
|
+
updateProductByKey(options: CommonRequestOptions & {
|
|
236
|
+
key: string;
|
|
237
|
+
data: ProductUpdate;
|
|
238
|
+
}): Promise<Product>;
|
|
239
|
+
updateProductById(options: CommonRequestOptions & {
|
|
240
|
+
id: string;
|
|
241
|
+
data: ProductUpdate;
|
|
242
|
+
}): Promise<Product>;
|
|
243
|
+
deleteProductById(options: CommonRequestOptions & {
|
|
244
|
+
id: string;
|
|
245
|
+
version: number;
|
|
246
|
+
unpublish?: boolean;
|
|
247
|
+
}): Promise<Product>;
|
|
248
|
+
deleteProductByKey(options: CommonRequestOptions & {
|
|
249
|
+
key: string;
|
|
250
|
+
version: number;
|
|
251
|
+
unpublish?: boolean;
|
|
252
|
+
}): Promise<Product>;
|
|
253
|
+
unpublishProductByKey(options: CommonRequestOptions & {
|
|
254
|
+
key: string;
|
|
255
|
+
version: number;
|
|
256
|
+
}): Promise<Product>;
|
|
257
|
+
unpublishProductById(options: CommonRequestOptions & {
|
|
258
|
+
id: string;
|
|
259
|
+
version: number;
|
|
260
|
+
}): Promise<Product>;
|
|
261
|
+
createCategory(options: CommonRequestOptions & {
|
|
262
|
+
data: CategoryDraft;
|
|
263
|
+
}): Promise<Category>;
|
|
264
|
+
updateCategoryByKey(options: CommonRequestOptions & {
|
|
265
|
+
key: string;
|
|
266
|
+
data: CategoryUpdate;
|
|
267
|
+
}): Promise<Category>;
|
|
268
|
+
updateCategoryById(options: CommonRequestOptions & {
|
|
269
|
+
id: string;
|
|
270
|
+
data: CategoryUpdate;
|
|
271
|
+
}): Promise<Category>;
|
|
272
|
+
deleteCategoryById(options: CommonRequestOptions & {
|
|
273
|
+
id: string;
|
|
274
|
+
version: number;
|
|
275
|
+
}): Promise<Category>;
|
|
276
|
+
deleteCategoryByKey(options: CommonRequestOptions & {
|
|
277
|
+
key: string;
|
|
278
|
+
version: number;
|
|
279
|
+
}): Promise<Category>;
|
|
280
|
+
createAccount(options: CommonStoreEnabledRequestOptions & {
|
|
281
|
+
data: CustomerDraft;
|
|
282
|
+
}): Promise<CustomerSignInResult>;
|
|
283
|
+
deleteCustomerById(options: CommonStoreEnabledRequestOptions & {
|
|
284
|
+
id: string;
|
|
285
|
+
version: number;
|
|
286
|
+
dataErasure?: boolean;
|
|
287
|
+
}): Promise<Customer>;
|
|
288
|
+
deleteCustomerByKey(options: CommonStoreEnabledRequestOptions & {
|
|
289
|
+
key: string;
|
|
290
|
+
version: number;
|
|
291
|
+
dataErasure?: boolean;
|
|
292
|
+
}): Promise<Customer>;
|
|
293
|
+
createMyAccount(options: CommonStoreEnabledRequestOptions & {
|
|
294
|
+
accessToken?: string;
|
|
295
|
+
data: MyCustomerDraft;
|
|
296
|
+
}): Promise<CustomerSignInResult>;
|
|
297
|
+
loginMyAccount(options: CommonStoreEnabledRequestOptions & {
|
|
298
|
+
accessToken?: string;
|
|
299
|
+
data: CustomerSignin;
|
|
300
|
+
}): Promise<CustomerSignInResult>;
|
|
301
|
+
login(options: CommonStoreEnabledRequestOptions & {
|
|
302
|
+
data: CustomerSignin;
|
|
303
|
+
}): Promise<CustomerSignInResult>;
|
|
304
|
+
getMyAccount(options: CommonStoreEnabledRequestOptions & {
|
|
305
|
+
accessToken: string;
|
|
306
|
+
}): Promise<Customer>;
|
|
307
|
+
updateMyAccount(options: CommonStoreEnabledRequestOptions & {
|
|
308
|
+
accessToken: string;
|
|
309
|
+
data: CustomerUpdate;
|
|
310
|
+
}): Promise<Customer>;
|
|
311
|
+
changeMyPassword(options: CommonStoreEnabledRequestOptions & {
|
|
312
|
+
accessToken: string;
|
|
313
|
+
data: {
|
|
314
|
+
version: number;
|
|
315
|
+
currentPassword: string;
|
|
316
|
+
newPassword: string;
|
|
317
|
+
};
|
|
318
|
+
}): Promise<Customer>;
|
|
319
|
+
resetMyPassword(options: CommonStoreEnabledRequestOptions & {
|
|
320
|
+
accessToken: string;
|
|
321
|
+
data: CustomerResetPassword;
|
|
322
|
+
}): Promise<Customer>;
|
|
323
|
+
getPasswordResetToken(options: CommonStoreEnabledRequestOptions & {
|
|
324
|
+
data: CustomerCreatePasswordResetToken;
|
|
325
|
+
}): Promise<CustomerToken>;
|
|
326
|
+
getCustomerById(options: CommonStoreEnabledRequestOptions & {
|
|
327
|
+
id: string;
|
|
328
|
+
}): Promise<Customer>;
|
|
329
|
+
getCustomerByKey(options: CommonStoreEnabledRequestOptions & {
|
|
330
|
+
key: string;
|
|
331
|
+
}): Promise<Customer>;
|
|
332
|
+
getCustomerByPasswordToken(options: CommonStoreEnabledRequestOptions & {
|
|
333
|
+
token: string;
|
|
334
|
+
}): Promise<Customer>;
|
|
335
|
+
queryCustomers(options: CommonStoreEnabledRequestOptions): Promise<CustomerPagedQueryResponse>;
|
|
336
|
+
updateCustomerById(options: CommonStoreEnabledRequestOptions & {
|
|
337
|
+
id: string;
|
|
338
|
+
data: CustomerUpdate;
|
|
339
|
+
}): Promise<Customer>;
|
|
340
|
+
updateCustomerByKey(options: CommonStoreEnabledRequestOptions & {
|
|
341
|
+
key: string;
|
|
342
|
+
data: CustomerUpdate;
|
|
343
|
+
}): Promise<Customer>;
|
|
344
|
+
getProductTypeById(options: CommonRequestOptions & {
|
|
345
|
+
id: string;
|
|
346
|
+
}): Promise<ProductType>;
|
|
347
|
+
getProductTypeByKey(options: CommonRequestOptions & {
|
|
348
|
+
key: string;
|
|
349
|
+
}): Promise<ProductType>;
|
|
350
|
+
getTypeById(options: CommonRequestOptions & {
|
|
351
|
+
id: string;
|
|
352
|
+
}): Promise<Type>;
|
|
353
|
+
getTypeByKey(options: CommonRequestOptions & {
|
|
354
|
+
key: string;
|
|
355
|
+
}): Promise<Type>;
|
|
356
|
+
getDiscountCodeById(options: CommonRequestOptions & {
|
|
357
|
+
id: string;
|
|
358
|
+
}): Promise<DiscountCode>;
|
|
359
|
+
getCartDiscountById(options: CommonRequestOptions & {
|
|
360
|
+
id: string;
|
|
361
|
+
}): Promise<CartDiscount>;
|
|
362
|
+
getCartDiscountByKey(options: CommonRequestOptions & {
|
|
363
|
+
key: string;
|
|
364
|
+
}): Promise<CartDiscount>;
|
|
365
|
+
queryCartDiscounts(options?: CommonRequestOptions): Promise<CartDiscountPagedQueryResponse>;
|
|
366
|
+
getCustomObject(options: CommonRequestOptions & {
|
|
367
|
+
container: string;
|
|
368
|
+
key: string;
|
|
369
|
+
}): Promise<CustomObject>;
|
|
370
|
+
getCustomObjectById(options: CommonRequestOptions & {
|
|
371
|
+
id: string;
|
|
372
|
+
}): Promise<CustomObject>;
|
|
373
|
+
saveCustomObject(options: CommonRequestOptions & {
|
|
374
|
+
data: CustomObjectDraft;
|
|
375
|
+
}): Promise<CustomObject>;
|
|
376
|
+
deleteCustomObject(options: CommonRequestOptions & {
|
|
377
|
+
container: string;
|
|
378
|
+
key: string;
|
|
379
|
+
}): Promise<CustomObject>;
|
|
380
|
+
getShippingMethodById(options: CommonRequestOptions & {
|
|
381
|
+
id: string;
|
|
382
|
+
}): Promise<ShippingMethod>;
|
|
383
|
+
getShippingMethodByKey(options: CommonRequestOptions & {
|
|
384
|
+
key: string;
|
|
385
|
+
}): Promise<ShippingMethod>;
|
|
386
|
+
getShippingMethodsForLocation(options: CommonRequestOptions & {
|
|
387
|
+
accessToken?: string;
|
|
388
|
+
country: string;
|
|
389
|
+
state?: string;
|
|
390
|
+
currency?: string;
|
|
391
|
+
}): Promise<ShippingMethodPagedQueryResponse>;
|
|
392
|
+
getShippingMethodsForCart(options: CommonStoreEnabledRequestOptions & {
|
|
393
|
+
accessToken?: string;
|
|
394
|
+
cartId: string;
|
|
395
|
+
}): Promise<ShippingMethodPagedQueryResponse>;
|
|
396
|
+
queryShippingMethods(options?: CommonRequestOptions): Promise<ShippingMethodPagedQueryResponse>;
|
|
397
|
+
getCustomerGroupById(options: CommonRequestOptions & {
|
|
398
|
+
id: string;
|
|
399
|
+
}): Promise<CustomerGroup>;
|
|
400
|
+
getCustomerGroupByKey(options: CommonRequestOptions & {
|
|
401
|
+
key: string;
|
|
402
|
+
}): Promise<CustomerGroup>;
|
|
403
|
+
queryCustomerGroups(options?: CommonRequestOptions): Promise<CustomerGroupPagedQueryResponse>;
|
|
404
|
+
createCustomerGroup(options: CommonRequestOptions & {
|
|
405
|
+
data: CustomerGroupDraft;
|
|
406
|
+
}): Promise<CustomerGroup>;
|
|
407
|
+
updateCustomerGroupByKey(options: CommonRequestOptions & {
|
|
408
|
+
key: string;
|
|
409
|
+
data: CustomerGroupUpdate;
|
|
410
|
+
}): Promise<CustomerGroup>;
|
|
411
|
+
updateCustomerGroupById(options: CommonRequestOptions & {
|
|
412
|
+
id: string;
|
|
413
|
+
data: CustomerGroupUpdate;
|
|
414
|
+
}): Promise<CustomerGroup>;
|
|
415
|
+
deleteCustomerGroupById(options: CommonRequestOptions & {
|
|
416
|
+
id: string;
|
|
417
|
+
version: number;
|
|
418
|
+
}): Promise<CustomerGroup>;
|
|
419
|
+
deleteCustomerGroupByKey(options: CommonRequestOptions & {
|
|
420
|
+
key: string;
|
|
421
|
+
version: number;
|
|
422
|
+
}): Promise<CustomerGroup>;
|
|
423
|
+
graphql(options: CommonRequestOptions & {
|
|
424
|
+
accessToken?: string;
|
|
425
|
+
data: GraphQLRequest;
|
|
426
|
+
}): Promise<GraphQLResponse>;
|
|
427
|
+
request<T = any, R = any>(options: FetchOptions<T>): Promise<R>;
|
|
428
|
+
getRetryConfig(methodRetryConfig?: CommercetoolsRetryConfig): CommercetoolsRetryConfig;
|
|
429
|
+
getRequestOptions(options: FetchOptions): Promise<any>;
|
|
430
|
+
calculateDelay(retryCount: number, retryConfig?: CommercetoolsRetryConfig): number;
|
|
431
|
+
isRetryableError(error: any): boolean;
|
|
432
|
+
extractCommonRequestOptions(options?: CommonRequestOptions): CommonRequestOptions;
|
|
433
|
+
applyStore(path: string, storeKey: string | undefined | null): string;
|
|
434
|
+
transformError(lastError: any): any;
|
|
435
|
+
static validateConfig(config: any): void;
|
|
436
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import * as https from 'https';
|
|
3
|
+
import { CommercetoolsAuthConfig } from '../auth';
|
|
4
|
+
export interface CommercetoolsApiConfig extends CommercetoolsAuthConfig {
|
|
5
|
+
retry?: CommercetoolsRetryConfig;
|
|
6
|
+
httpsAgent?: https.Agent;
|
|
7
|
+
}
|
|
8
|
+
export interface CommercetoolsRetryConfig {
|
|
9
|
+
delayMs: number;
|
|
10
|
+
maxRetries: number;
|
|
11
|
+
jitter?: boolean;
|
|
12
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AnonymousGrantOptions, CommercetoolsAuthConfig, LoginOptions, LogoutOptions, RevokeTokenOptions } from './types';
|
|
2
|
+
import { CommercetoolsGrant } from './CommercetoolsGrant';
|
|
3
|
+
interface Config extends CommercetoolsAuthConfig {
|
|
4
|
+
clientScopes: string[];
|
|
5
|
+
refreshIfWithinSecs: number;
|
|
6
|
+
timeoutMs: number;
|
|
7
|
+
storeKey?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare class CommercetoolsAuth {
|
|
10
|
+
readonly config: Config;
|
|
11
|
+
private grant?;
|
|
12
|
+
private grantPromise;
|
|
13
|
+
private api;
|
|
14
|
+
constructor(config: CommercetoolsAuthConfig);
|
|
15
|
+
getClientGrant(): Promise<CommercetoolsGrant>;
|
|
16
|
+
refreshCustomerGrant(refreshToken: string): Promise<CommercetoolsGrant>;
|
|
17
|
+
login(options: LoginOptions): Promise<CommercetoolsGrant>;
|
|
18
|
+
getAnonymousGrant(options?: AnonymousGrantOptions): Promise<CommercetoolsGrant>;
|
|
19
|
+
logout(options: LogoutOptions): Promise<void>;
|
|
20
|
+
revokeToken(options: RevokeTokenOptions): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { CommercetoolsAuthApiConfig, CommercetoolsGrantResponse, LoginOptions, LogoutOptions, RevokeTokenOptions } from './types';
|
|
2
|
+
import { RegionEndpoints } from '../types';
|
|
3
|
+
export declare class CommercetoolsAuthApi {
|
|
4
|
+
readonly config: CommercetoolsAuthApiConfig;
|
|
5
|
+
readonly endpoints: RegionEndpoints;
|
|
6
|
+
private readonly userAgent;
|
|
7
|
+
constructor(config: CommercetoolsAuthApiConfig);
|
|
8
|
+
getClientGrant(scopes: string[]): Promise<CommercetoolsGrantResponse>;
|
|
9
|
+
refreshGrant(refreshToken: string): Promise<CommercetoolsGrantResponse>;
|
|
10
|
+
login(options: LoginOptions & {
|
|
11
|
+
scopes: string[];
|
|
12
|
+
}): Promise<CommercetoolsGrantResponse>;
|
|
13
|
+
revokeToken(options: RevokeTokenOptions): Promise<void>;
|
|
14
|
+
logout(options: LogoutOptions): Promise<void>;
|
|
15
|
+
getAnonymousGrant(options?: {
|
|
16
|
+
anonymousId?: string;
|
|
17
|
+
scopes: string[];
|
|
18
|
+
}): Promise<CommercetoolsGrantResponse>;
|
|
19
|
+
post(path: string, body: Record<string, any>): Promise<CommercetoolsGrantResponse>;
|
|
20
|
+
applyStore(path: string, storeKey: string | undefined | null): string;
|
|
21
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CommercetoolsGrantResponse } from './types';
|
|
2
|
+
export declare class CommercetoolsGrant {
|
|
3
|
+
accessToken: string;
|
|
4
|
+
refreshToken?: string;
|
|
5
|
+
expiresIn: number;
|
|
6
|
+
expiresAt: Date;
|
|
7
|
+
scopes: string[];
|
|
8
|
+
anonymousId?: string;
|
|
9
|
+
customerId?: string;
|
|
10
|
+
constructor(data: CommercetoolsGrantResponse);
|
|
11
|
+
expiresWithin(refreshIfWithinSecs: number): boolean;
|
|
12
|
+
extractKeyFromScope(key: string, scope: string): string | undefined;
|
|
13
|
+
}
|
|
@@ -1,7 +1,3 @@
|
|
|
1
1
|
import { Region, RegionEndpoints } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Commercetools regions and cloud providers - https://docs.commercetools.com/api/general-concepts#hosts
|
|
4
|
-
*/
|
|
5
2
|
export declare const REGION_URLS: Record<Region, RegionEndpoints>;
|
|
6
3
|
export declare const INVALID_SCOPES: string[];
|
|
7
|
-
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { CommercetoolsBaseConfig, Region } from '../types';
|
|
2
|
+
export interface CommercetoolsAuthConfig extends CommercetoolsBaseConfig {
|
|
3
|
+
refreshIfWithinSecs?: number;
|
|
4
|
+
customerScopes?: string[];
|
|
5
|
+
}
|
|
6
|
+
export interface CommercetoolsAuthApiConfig {
|
|
7
|
+
projectKey: string;
|
|
8
|
+
clientId: string;
|
|
9
|
+
clientSecret: string;
|
|
10
|
+
region: Region;
|
|
11
|
+
timeoutMs?: number;
|
|
12
|
+
systemIdentifier?: string;
|
|
13
|
+
storeKey?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface CommercetoolsGrantResponse {
|
|
16
|
+
access_token: string;
|
|
17
|
+
refresh_token?: string;
|
|
18
|
+
expires_in: number;
|
|
19
|
+
scope: string;
|
|
20
|
+
}
|
|
21
|
+
export interface LoginOptions {
|
|
22
|
+
username: string;
|
|
23
|
+
password: string;
|
|
24
|
+
scopes?: string[];
|
|
25
|
+
storeKey?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface RevokeTokenOptions {
|
|
28
|
+
tokenType: 'access_token' | 'refresh_token';
|
|
29
|
+
tokenValue: string;
|
|
30
|
+
}
|
|
31
|
+
export interface LogoutOptions {
|
|
32
|
+
accessToken: string;
|
|
33
|
+
refreshToken: string;
|
|
34
|
+
}
|
|
35
|
+
export interface AnonymousGrantOptions {
|
|
36
|
+
scopes?: string[];
|
|
37
|
+
anonymousId?: string;
|
|
38
|
+
}
|
|
39
|
+
export declare enum GrantType {
|
|
40
|
+
CLIENT_CREDENTIALS = "client_credentials",
|
|
41
|
+
REFRESH_TOKEN = "refresh_token",
|
|
42
|
+
PASSWORD = "password"
|
|
43
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DEFAULT_REQUEST_TIMEOUT_MS = 5000;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AxiosError, AxiosRequestConfig } from 'axios';
|
|
2
|
+
export declare class CommercetoolsError extends Error {
|
|
3
|
+
readonly data?: any;
|
|
4
|
+
readonly status: number | undefined;
|
|
5
|
+
readonly isCommercetoolsError = true;
|
|
6
|
+
constructor(message: string, data?: any, status?: number);
|
|
7
|
+
static fromAxiosError(e: AxiosError): CommercetoolsError;
|
|
8
|
+
static parseRequestData(config: AxiosRequestConfig): any;
|
|
9
|
+
toJSON(): {
|
|
10
|
+
status: number | undefined;
|
|
11
|
+
message: string;
|
|
12
|
+
data: any;
|
|
13
|
+
isCommercetoolsError: boolean;
|
|
14
|
+
};
|
|
15
|
+
toString(): string;
|
|
16
|
+
}
|