@ecomweb/sdk 0.13.1 → 0.14.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/README.md +11 -2
- package/dist/index.d.ts +657 -1
- package/dist/index.js +492 -2
- package/dist/index.js.map +1 -1
- package/package.json +4 -2
package/dist/index.js
CHANGED
|
@@ -1,3 +1,36 @@
|
|
|
1
|
+
// src/core/client-info.ts
|
|
2
|
+
var SDK_VERSION = true ? "0.14.1" : "dev";
|
|
3
|
+
var CLIENT_HEADER = "X-Ecomweb-Client";
|
|
4
|
+
var SDK_CLIENT_TOKEN = `@ecomweb/sdk/${SDK_VERSION}`;
|
|
5
|
+
function clientHeaderValue(clientInfo) {
|
|
6
|
+
const prefix = clientInfo?.trim();
|
|
7
|
+
return prefix ? `${prefix} ${SDK_CLIENT_TOKEN}` : SDK_CLIENT_TOKEN;
|
|
8
|
+
}
|
|
9
|
+
var WRAPPED = /* @__PURE__ */ Symbol.for("ecomweb.sdk.clientHeader");
|
|
10
|
+
function withHeader(options, value) {
|
|
11
|
+
const headers = options?.headers ?? {};
|
|
12
|
+
const present2 = Object.keys(headers).some(
|
|
13
|
+
(name) => name.toLowerCase() === CLIENT_HEADER.toLowerCase()
|
|
14
|
+
);
|
|
15
|
+
return {
|
|
16
|
+
...options,
|
|
17
|
+
headers: present2 ? headers : { [CLIENT_HEADER]: value, ...headers }
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function withClientHeader(http, clientInfo) {
|
|
21
|
+
if (http[WRAPPED]) return http;
|
|
22
|
+
const value = clientHeaderValue(clientInfo);
|
|
23
|
+
const wrapped = {
|
|
24
|
+
[WRAPPED]: true,
|
|
25
|
+
get: (url, options) => http.get(url, withHeader(options, value)),
|
|
26
|
+
post: (url, data, options) => http.post(url, data, withHeader(options, value)),
|
|
27
|
+
put: (url, data, options) => http.put(url, data, withHeader(options, value)),
|
|
28
|
+
patch: (url, data, options) => http.patch(url, data, withHeader(options, value)),
|
|
29
|
+
delete: (url, options) => http.delete(url, withHeader(options, value))
|
|
30
|
+
};
|
|
31
|
+
return wrapped;
|
|
32
|
+
}
|
|
33
|
+
|
|
1
34
|
// src/core/response.ts
|
|
2
35
|
var ApiClientError = class extends Error {
|
|
3
36
|
constructor(message, statusCode = 0, code, details) {
|
|
@@ -2923,6 +2956,14 @@ var ProductsApi = class {
|
|
|
2923
2956
|
constructor(http) {
|
|
2924
2957
|
this.http = http;
|
|
2925
2958
|
}
|
|
2959
|
+
/**
|
|
2960
|
+
* Gets one product by id.
|
|
2961
|
+
*
|
|
2962
|
+
* @param storeRef - the store's ref or handle
|
|
2963
|
+
* @param productId - the product id
|
|
2964
|
+
* @param query - optional fields to include
|
|
2965
|
+
* @returns The product, or `null` when it is not found; throws {@link ApiClientError} on any other API error
|
|
2966
|
+
*/
|
|
2926
2967
|
async getById(storeRef, productId, query) {
|
|
2927
2968
|
const queryString = stringify(query ?? {});
|
|
2928
2969
|
const res = await this.http.get(
|
|
@@ -2930,6 +2971,14 @@ var ProductsApi = class {
|
|
|
2930
2971
|
);
|
|
2931
2972
|
return unwrapOrNull(res);
|
|
2932
2973
|
}
|
|
2974
|
+
/**
|
|
2975
|
+
* Gets one product by slug.
|
|
2976
|
+
*
|
|
2977
|
+
* @param storeRef - the store's ref or handle
|
|
2978
|
+
* @param slug - the product slug
|
|
2979
|
+
* @param query - optional fields to include
|
|
2980
|
+
* @returns The product, or `null` when it is not found; throws {@link ApiClientError} on any other API error
|
|
2981
|
+
*/
|
|
2933
2982
|
async getBySlug(storeRef, slug, query) {
|
|
2934
2983
|
const normalizedSlug = slug.normalize("NFC");
|
|
2935
2984
|
const encodedSlug = encodeURIComponent(normalizedSlug);
|
|
@@ -2946,6 +2995,13 @@ var CollectionsApi = class {
|
|
|
2946
2995
|
constructor(http) {
|
|
2947
2996
|
this.http = http;
|
|
2948
2997
|
}
|
|
2998
|
+
/**
|
|
2999
|
+
* Lists collections, one page at a time.
|
|
3000
|
+
*
|
|
3001
|
+
* @param storeRef - the store's ref or handle
|
|
3002
|
+
* @param params - filters, sorting and paging
|
|
3003
|
+
* @returns A page of collections; throws {@link ApiClientError} when the API answers with an error
|
|
3004
|
+
*/
|
|
2949
3005
|
async getAllPaginated(storeRef, params) {
|
|
2950
3006
|
const queryString = stringify(params ?? {});
|
|
2951
3007
|
const res = await this.http.get(
|
|
@@ -2953,6 +3009,13 @@ var CollectionsApi = class {
|
|
|
2953
3009
|
);
|
|
2954
3010
|
return unwrap(res);
|
|
2955
3011
|
}
|
|
3012
|
+
/**
|
|
3013
|
+
* Lists up to 100 collections in one call.
|
|
3014
|
+
*
|
|
3015
|
+
* @param storeRef - the store's ref or handle
|
|
3016
|
+
* @param ids - limit the result to these collection ids
|
|
3017
|
+
* @returns The collections; throws {@link ApiClientError} when the API answers with an error
|
|
3018
|
+
*/
|
|
2956
3019
|
async getAll(storeRef, ids) {
|
|
2957
3020
|
const result = await this.getAllPaginated(storeRef, {
|
|
2958
3021
|
ids,
|
|
@@ -2960,6 +3023,14 @@ var CollectionsApi = class {
|
|
|
2960
3023
|
});
|
|
2961
3024
|
return result.data;
|
|
2962
3025
|
}
|
|
3026
|
+
/**
|
|
3027
|
+
* Gets one collection by slug.
|
|
3028
|
+
*
|
|
3029
|
+
* @param storeRef - the store's ref or handle
|
|
3030
|
+
* @param slug - the collection slug
|
|
3031
|
+
* @param query - `include_seo_metadata` adds the SEO fields
|
|
3032
|
+
* @returns The collection, or `null` when it is not found; throws {@link ApiClientError} on any other API error
|
|
3033
|
+
*/
|
|
2963
3034
|
async getBySlug(storeRef, slug, query) {
|
|
2964
3035
|
const queryString = query ? stringify(query) : "";
|
|
2965
3036
|
const res = await this.http.get(
|
|
@@ -2974,6 +3045,13 @@ var CategoriesApi = class {
|
|
|
2974
3045
|
constructor(http) {
|
|
2975
3046
|
this.http = http;
|
|
2976
3047
|
}
|
|
3048
|
+
/**
|
|
3049
|
+
* Lists categories, one page at a time.
|
|
3050
|
+
*
|
|
3051
|
+
* @param storeRef - the store's ref or handle
|
|
3052
|
+
* @param params - filters, sorting and paging
|
|
3053
|
+
* @returns A page of categories; throws {@link ApiClientError} when the API answers with an error
|
|
3054
|
+
*/
|
|
2977
3055
|
async getAllPaginated(storeRef, params) {
|
|
2978
3056
|
const queryString = stringify(params ?? {});
|
|
2979
3057
|
const res = await this.http.get(
|
|
@@ -2981,6 +3059,13 @@ var CategoriesApi = class {
|
|
|
2981
3059
|
);
|
|
2982
3060
|
return unwrap(res);
|
|
2983
3061
|
}
|
|
3062
|
+
/**
|
|
3063
|
+
* Lists up to 1,000 categories in one call.
|
|
3064
|
+
*
|
|
3065
|
+
* @param storeRef - the store's ref or handle
|
|
3066
|
+
* @param activeOnly - `true` (the default) returns only active categories
|
|
3067
|
+
* @returns The categories; throws {@link ApiClientError} when the API answers with an error
|
|
3068
|
+
*/
|
|
2984
3069
|
async getAll(storeRef, activeOnly = true) {
|
|
2985
3070
|
const result = await this.getAllPaginated(storeRef, {
|
|
2986
3071
|
is_active: activeOnly,
|
|
@@ -2988,12 +3073,26 @@ var CategoriesApi = class {
|
|
|
2988
3073
|
});
|
|
2989
3074
|
return result.data;
|
|
2990
3075
|
}
|
|
3076
|
+
/**
|
|
3077
|
+
* Gets one category by id.
|
|
3078
|
+
*
|
|
3079
|
+
* @param storeRef - the store's ref or handle
|
|
3080
|
+
* @param categoryId - the category id
|
|
3081
|
+
* @returns The category, or `null` when it is not found; throws {@link ApiClientError} on any other API error
|
|
3082
|
+
*/
|
|
2991
3083
|
async getById(storeRef, categoryId) {
|
|
2992
3084
|
const res = await this.http.get(
|
|
2993
3085
|
`/public/stores/${storeRef}/categories/${categoryId}`
|
|
2994
3086
|
);
|
|
2995
3087
|
return unwrapOrNull(res);
|
|
2996
3088
|
}
|
|
3089
|
+
/**
|
|
3090
|
+
* Gets one category by slug.
|
|
3091
|
+
*
|
|
3092
|
+
* @param storeRef - the store's ref or handle
|
|
3093
|
+
* @param slug - the category slug
|
|
3094
|
+
* @returns The category, or `null` when it is not found; throws {@link ApiClientError} on any other API error
|
|
3095
|
+
*/
|
|
2997
3096
|
async getBySlug(storeRef, slug) {
|
|
2998
3097
|
const res = await this.http.get(
|
|
2999
3098
|
`/public/stores/${storeRef}/categories/${encodeURIComponent(slug)}`
|
|
@@ -3014,6 +3113,14 @@ var CartApi = class {
|
|
|
3014
3113
|
basePath(isAuth) {
|
|
3015
3114
|
return isAuth ? "stores" : "public/stores";
|
|
3016
3115
|
}
|
|
3116
|
+
/**
|
|
3117
|
+
* Gets the shopper's cart.
|
|
3118
|
+
*
|
|
3119
|
+
* @param storeRef - the store's ref or handle
|
|
3120
|
+
* @param sessionId - the guest cart session id
|
|
3121
|
+
* @param isAuth - `true` for the signed-in customer's cart, `false` for the guest cart
|
|
3122
|
+
* @returns The cart, or `null` when it is not found; throws {@link ApiClientError} on any other API error
|
|
3123
|
+
*/
|
|
3017
3124
|
async getCart(storeRef, sessionId, isAuth) {
|
|
3018
3125
|
const res = await this.client(isAuth).get(
|
|
3019
3126
|
`/${this.basePath(isAuth)}/${storeRef}/cart`,
|
|
@@ -3021,24 +3128,60 @@ var CartApi = class {
|
|
|
3021
3128
|
);
|
|
3022
3129
|
return unwrapOrNull(res);
|
|
3023
3130
|
}
|
|
3131
|
+
/**
|
|
3132
|
+
* Adds a product variant to the cart.
|
|
3133
|
+
*
|
|
3134
|
+
* @param storeRef - the store's ref or handle
|
|
3135
|
+
* @param data - the variant and the quantity
|
|
3136
|
+
* @param sessionId - the guest cart session id
|
|
3137
|
+
* @param isAuth - `true` for the signed-in customer's cart, `false` for the guest cart
|
|
3138
|
+
* @returns The cart id and the added item; throws {@link ApiClientError} when the API answers with an error
|
|
3139
|
+
*/
|
|
3024
3140
|
async addItem(storeRef, data, sessionId, isAuth) {
|
|
3025
3141
|
const res = await this.client(isAuth).post(`/${this.basePath(isAuth)}/${storeRef}/cart/items`, data, {
|
|
3026
3142
|
headers: { "x-session-id": sessionId }
|
|
3027
3143
|
});
|
|
3028
3144
|
return unwrap(res);
|
|
3029
3145
|
}
|
|
3146
|
+
/**
|
|
3147
|
+
* Changes the quantity of a cart line.
|
|
3148
|
+
*
|
|
3149
|
+
* @param storeRef - the store's ref or handle
|
|
3150
|
+
* @param itemId - the cart line id
|
|
3151
|
+
* @param data - the new quantity
|
|
3152
|
+
* @param sessionId - the guest cart session id
|
|
3153
|
+
* @param isAuth - `true` for the signed-in customer's cart, `false` for the guest cart
|
|
3154
|
+
* @returns The cart id and the updated item (`null` when the line was removed); throws {@link ApiClientError} when the API answers with an error
|
|
3155
|
+
*/
|
|
3030
3156
|
async updateItem(storeRef, itemId, data, sessionId, isAuth) {
|
|
3031
3157
|
const res = await this.client(isAuth).put(`/${this.basePath(isAuth)}/${storeRef}/cart/items/${itemId}`, data, {
|
|
3032
3158
|
headers: { "x-session-id": sessionId }
|
|
3033
3159
|
});
|
|
3034
3160
|
return unwrap(res);
|
|
3035
3161
|
}
|
|
3162
|
+
/**
|
|
3163
|
+
* Removes a line from the cart.
|
|
3164
|
+
*
|
|
3165
|
+
* @param storeRef - the store's ref or handle
|
|
3166
|
+
* @param itemId - the cart line id
|
|
3167
|
+
* @param sessionId - the guest cart session id
|
|
3168
|
+
* @param isAuth - `true` for the signed-in customer's cart, `false` for the guest cart
|
|
3169
|
+
* @returns The cart id and the removed line's id; throws {@link ApiClientError} when the API answers with an error
|
|
3170
|
+
*/
|
|
3036
3171
|
async removeItem(storeRef, itemId, sessionId, isAuth) {
|
|
3037
3172
|
const res = await this.client(isAuth).delete(`/${this.basePath(isAuth)}/${storeRef}/cart/items/${itemId}`, {
|
|
3038
3173
|
headers: { "x-session-id": sessionId }
|
|
3039
3174
|
});
|
|
3040
3175
|
return unwrap(res);
|
|
3041
3176
|
}
|
|
3177
|
+
/**
|
|
3178
|
+
* Empties the cart.
|
|
3179
|
+
*
|
|
3180
|
+
* @param storeRef - the store's ref or handle
|
|
3181
|
+
* @param sessionId - the guest cart session id
|
|
3182
|
+
* @param isAuth - `true` for the signed-in customer's cart, `false` for the guest cart
|
|
3183
|
+
* @returns The cart id; throws {@link ApiClientError} when the API answers with an error
|
|
3184
|
+
*/
|
|
3042
3185
|
async clear(storeRef, sessionId, isAuth) {
|
|
3043
3186
|
const res = await this.client(isAuth).delete(
|
|
3044
3187
|
`/${this.basePath(isAuth)}/${storeRef}/cart`,
|
|
@@ -3085,6 +3228,14 @@ var OrdersApi = class {
|
|
|
3085
3228
|
if (!data || !("id" in data) || data.id == null) return null;
|
|
3086
3229
|
return data;
|
|
3087
3230
|
}
|
|
3231
|
+
/**
|
|
3232
|
+
* Places an order.
|
|
3233
|
+
*
|
|
3234
|
+
* @param storeRef - the store's ref or handle
|
|
3235
|
+
* @param data - the order details
|
|
3236
|
+
* @param isAuth - `true` to place it as the signed-in customer, `false` as a guest
|
|
3237
|
+
* @returns The created order with its items; throws {@link ApiClientError} when the API answers with an error
|
|
3238
|
+
*/
|
|
3088
3239
|
async create(storeRef, data, isAuth) {
|
|
3089
3240
|
if (isAuth) {
|
|
3090
3241
|
const res2 = await this.authHttp.post(
|
|
@@ -3099,6 +3250,13 @@ var OrdersApi = class {
|
|
|
3099
3250
|
);
|
|
3100
3251
|
return unwrap(res);
|
|
3101
3252
|
}
|
|
3253
|
+
/**
|
|
3254
|
+
* Lists the signed-in customer's orders, newest first by default.
|
|
3255
|
+
*
|
|
3256
|
+
* @param storeRef - the store's ref or handle
|
|
3257
|
+
* @param params - search, status filter, sorting and paging (`page`, or `limit` and `offset`)
|
|
3258
|
+
* @returns A page of orders; throws {@link ApiClientError} when the API answers with an error
|
|
3259
|
+
*/
|
|
3102
3260
|
async listCustomerOrders(storeRef, params = {}) {
|
|
3103
3261
|
const limit = params.limit ?? 10;
|
|
3104
3262
|
const page = params.page ?? (params.offset ? Math.floor(params.offset / limit) + 1 : 1);
|
|
@@ -3145,6 +3303,13 @@ var BlogApi = class {
|
|
|
3145
3303
|
this.publicHttp = publicHttp;
|
|
3146
3304
|
this.authHttp = authHttp;
|
|
3147
3305
|
}
|
|
3306
|
+
/**
|
|
3307
|
+
* Lists published blog posts.
|
|
3308
|
+
*
|
|
3309
|
+
* @param storeRef - the store's ref or handle
|
|
3310
|
+
* @param query - filters, sorting and paging
|
|
3311
|
+
* @returns A page of posts; throws {@link ApiClientError} when the API answers with an error
|
|
3312
|
+
*/
|
|
3148
3313
|
async getPosts(storeRef, query = {}) {
|
|
3149
3314
|
const qsStr = stringify(query);
|
|
3150
3315
|
const res = await this.publicHttp.get(
|
|
@@ -3152,6 +3317,14 @@ var BlogApi = class {
|
|
|
3152
3317
|
);
|
|
3153
3318
|
return unwrap(res);
|
|
3154
3319
|
}
|
|
3320
|
+
/**
|
|
3321
|
+
* Gets one published blog post by its slug.
|
|
3322
|
+
*
|
|
3323
|
+
* @param storeRef - the store's ref or handle
|
|
3324
|
+
* @param slug - the post slug
|
|
3325
|
+
* @param options - `incrementView` counts a view; `include_seo_metadata` and `include_products` add those fields
|
|
3326
|
+
* @returns The post, or `null` when it is not found; throws {@link ApiClientError} on any other API error
|
|
3327
|
+
*/
|
|
3155
3328
|
async getPostBySlug(storeRef, slug, options = {}) {
|
|
3156
3329
|
const query = stringify({
|
|
3157
3330
|
increment_view: options.incrementView,
|
|
@@ -3163,6 +3336,13 @@ var BlogApi = class {
|
|
|
3163
3336
|
);
|
|
3164
3337
|
return unwrapOrNull(res);
|
|
3165
3338
|
}
|
|
3339
|
+
/**
|
|
3340
|
+
* Lists blog categories.
|
|
3341
|
+
*
|
|
3342
|
+
* @param storeRef - the store's ref or handle
|
|
3343
|
+
* @param query - filters and paging
|
|
3344
|
+
* @returns A page of categories; throws {@link ApiClientError} when the API answers with an error
|
|
3345
|
+
*/
|
|
3166
3346
|
async getCategories(storeRef, query = {}) {
|
|
3167
3347
|
const qsStr = stringify(query);
|
|
3168
3348
|
const res = await this.publicHttp.get(
|
|
@@ -3170,6 +3350,13 @@ var BlogApi = class {
|
|
|
3170
3350
|
);
|
|
3171
3351
|
return unwrap(res);
|
|
3172
3352
|
}
|
|
3353
|
+
/**
|
|
3354
|
+
* Lists blog tags.
|
|
3355
|
+
*
|
|
3356
|
+
* @param storeRef - the store's ref or handle
|
|
3357
|
+
* @param query - filters and paging
|
|
3358
|
+
* @returns A page of tags; throws {@link ApiClientError} when the API answers with an error
|
|
3359
|
+
*/
|
|
3173
3360
|
async getTags(storeRef, query = {}) {
|
|
3174
3361
|
const qsStr = stringify(query);
|
|
3175
3362
|
const res = await this.publicHttp.get(
|
|
@@ -3177,18 +3364,40 @@ var BlogApi = class {
|
|
|
3177
3364
|
);
|
|
3178
3365
|
return unwrap(res);
|
|
3179
3366
|
}
|
|
3367
|
+
/**
|
|
3368
|
+
* Lists the approved comments of a post, as an anonymous visitor.
|
|
3369
|
+
*
|
|
3370
|
+
* @param storeRef - the store's ref or handle
|
|
3371
|
+
* @param postId - the post id
|
|
3372
|
+
* @returns The comments; throws {@link ApiClientError} when the API answers with an error
|
|
3373
|
+
*/
|
|
3180
3374
|
async getPostComments(storeRef, postId) {
|
|
3181
3375
|
const res = await this.publicHttp.get(
|
|
3182
3376
|
`/public/stores/${storeRef}/blog/posts/${postId}/comments`
|
|
3183
3377
|
);
|
|
3184
3378
|
return unwrap(res);
|
|
3185
3379
|
}
|
|
3380
|
+
/**
|
|
3381
|
+
* Lists the approved comments of a post, sending the signed-in customer's credentials.
|
|
3382
|
+
*
|
|
3383
|
+
* @param storeRef - the store's ref or handle
|
|
3384
|
+
* @param postId - the post id
|
|
3385
|
+
* @returns The comments; throws {@link ApiClientError} when the API answers with an error
|
|
3386
|
+
*/
|
|
3186
3387
|
async getPostCommentsAuth(storeRef, postId) {
|
|
3187
3388
|
const res = await this.authHttp.get(
|
|
3188
3389
|
`/public/stores/${storeRef}/blog/posts/${postId}/comments`
|
|
3189
3390
|
);
|
|
3190
3391
|
return unwrap(res);
|
|
3191
3392
|
}
|
|
3393
|
+
/**
|
|
3394
|
+
* Submits a comment on a post, as the signed-in customer. It may wait for moderation.
|
|
3395
|
+
*
|
|
3396
|
+
* @param storeRef - the store's ref or handle
|
|
3397
|
+
* @param postId - the post id
|
|
3398
|
+
* @param data - the author name, the text, and optionally a website and the parent comment id
|
|
3399
|
+
* @returns The created comment; throws {@link ApiClientError} when the API answers with an error
|
|
3400
|
+
*/
|
|
3192
3401
|
async submitComment(storeRef, postId, data) {
|
|
3193
3402
|
const res = await this.authHttp.post(
|
|
3194
3403
|
`/public/stores/${storeRef}/blog/posts/${postId}/comments`,
|
|
@@ -3203,6 +3412,14 @@ var StoresApi = class {
|
|
|
3203
3412
|
constructor(http) {
|
|
3204
3413
|
this.http = http;
|
|
3205
3414
|
}
|
|
3415
|
+
/**
|
|
3416
|
+
* Gets a store's public information, by default with its configuration, settings and embedded scripts.
|
|
3417
|
+
*
|
|
3418
|
+
* @param storeRef - the store's ref or handle
|
|
3419
|
+
* @param options - set `includeConfig`, `includeSettings` or `includeEmbeddedScripts` to `false` to leave that part out
|
|
3420
|
+
* @param requestOptions - extra request options, passed to the HTTP client only when given
|
|
3421
|
+
* @returns The store information, or `null` when it is not found; throws {@link ApiClientError} on any other API error
|
|
3422
|
+
*/
|
|
3206
3423
|
async getById(storeRef, options, requestOptions) {
|
|
3207
3424
|
const params = new URLSearchParams();
|
|
3208
3425
|
if (options?.includeConfig ?? true) params.set("include_config", "1");
|
|
@@ -3214,6 +3431,12 @@ var StoresApi = class {
|
|
|
3214
3431
|
const res = requestOptions ? await this.http.get(url, requestOptions) : await this.http.get(url);
|
|
3215
3432
|
return unwrapOrNull(res);
|
|
3216
3433
|
}
|
|
3434
|
+
/**
|
|
3435
|
+
* Gets a store by its subdomain.
|
|
3436
|
+
*
|
|
3437
|
+
* @param subdomain - the store's subdomain
|
|
3438
|
+
* @returns The store, or `null` when it is not found; throws {@link ApiClientError} on any other API error
|
|
3439
|
+
*/
|
|
3217
3440
|
async getBySubdomain(subdomain) {
|
|
3218
3441
|
const res = await this.http.get(
|
|
3219
3442
|
`/public/stores/exists/subdomain/${subdomain}`
|
|
@@ -3294,6 +3517,13 @@ var SearchApi = class {
|
|
|
3294
3517
|
constructor(http) {
|
|
3295
3518
|
this.http = http;
|
|
3296
3519
|
}
|
|
3520
|
+
/**
|
|
3521
|
+
* Searches products.
|
|
3522
|
+
*
|
|
3523
|
+
* @param storeRef - the store's ref or handle
|
|
3524
|
+
* @param params - the query, filters and paging
|
|
3525
|
+
* @returns The matching products; throws {@link ApiClientError} when the API answers with an error
|
|
3526
|
+
*/
|
|
3297
3527
|
async searchCatalog(storeRef, params) {
|
|
3298
3528
|
const queryString = stringify(params);
|
|
3299
3529
|
const res = await this.http.get(
|
|
@@ -3301,6 +3531,13 @@ var SearchApi = class {
|
|
|
3301
3531
|
);
|
|
3302
3532
|
return unwrap(res);
|
|
3303
3533
|
}
|
|
3534
|
+
/**
|
|
3535
|
+
* Suggests product matches while the shopper is typing.
|
|
3536
|
+
*
|
|
3537
|
+
* @param storeRef - the store's ref or handle
|
|
3538
|
+
* @param params - the partial query and the suggestion limit
|
|
3539
|
+
* @returns The suggestions; throws {@link ApiClientError} when the API answers with an error
|
|
3540
|
+
*/
|
|
3304
3541
|
async autocompleteCatalog(storeRef, params) {
|
|
3305
3542
|
const queryString = stringify(params);
|
|
3306
3543
|
const res = await this.http.get(
|
|
@@ -3308,6 +3545,13 @@ var SearchApi = class {
|
|
|
3308
3545
|
);
|
|
3309
3546
|
return unwrap(res);
|
|
3310
3547
|
}
|
|
3548
|
+
/**
|
|
3549
|
+
* Searches published blog posts.
|
|
3550
|
+
*
|
|
3551
|
+
* @param storeRef - the store's ref or handle
|
|
3552
|
+
* @param params - the query and paging
|
|
3553
|
+
* @returns The matching posts; throws {@link ApiClientError} when the API answers with an error
|
|
3554
|
+
*/
|
|
3311
3555
|
async searchBlog(storeRef, params) {
|
|
3312
3556
|
const queryString = stringify(params);
|
|
3313
3557
|
const res = await this.http.get(
|
|
@@ -3337,6 +3581,13 @@ var ShippingApi = class {
|
|
|
3337
3581
|
);
|
|
3338
3582
|
return unwrap(res);
|
|
3339
3583
|
}
|
|
3584
|
+
/**
|
|
3585
|
+
* Works out the shipping options and prices for a cart and a destination.
|
|
3586
|
+
*
|
|
3587
|
+
* @param storeRef - the store's ref or handle
|
|
3588
|
+
* @param data - the destination and the cart contents
|
|
3589
|
+
* @returns The available shipping options; throws {@link ApiClientError} when the API answers with an error
|
|
3590
|
+
*/
|
|
3340
3591
|
async calculate(storeRef, data) {
|
|
3341
3592
|
const res = await this.http.post(
|
|
3342
3593
|
`/public/stores/${storeRef}/shipping/calculate`,
|
|
@@ -3351,6 +3602,13 @@ var PromotionsApi = class {
|
|
|
3351
3602
|
constructor(http) {
|
|
3352
3603
|
this.http = http;
|
|
3353
3604
|
}
|
|
3605
|
+
/**
|
|
3606
|
+
* Checks a promotion code against a cart.
|
|
3607
|
+
*
|
|
3608
|
+
* @param storeRef - the store's ref or handle
|
|
3609
|
+
* @param data - the code and the cart details
|
|
3610
|
+
* @returns The validation result; throws {@link ApiClientError} when the API answers with an error
|
|
3611
|
+
*/
|
|
3354
3612
|
async validate(storeRef, data) {
|
|
3355
3613
|
const res = await this.http.post(
|
|
3356
3614
|
`/public/stores/${storeRef}/promotions/validate`,
|
|
@@ -3358,6 +3616,13 @@ var PromotionsApi = class {
|
|
|
3358
3616
|
);
|
|
3359
3617
|
return unwrap(res);
|
|
3360
3618
|
}
|
|
3619
|
+
/**
|
|
3620
|
+
* Lists promotions the shopper could use, optionally for a given cart subtotal.
|
|
3621
|
+
*
|
|
3622
|
+
* @param storeRef - the store's ref or handle
|
|
3623
|
+
* @param subtotal - the cart subtotal in the store's currency
|
|
3624
|
+
* @returns The suggested promotions; throws {@link ApiClientError} when the API answers with an error
|
|
3625
|
+
*/
|
|
3361
3626
|
async getSuggestions(storeRef, subtotal) {
|
|
3362
3627
|
const params = new URLSearchParams();
|
|
3363
3628
|
if (subtotal !== void 0) params.append("subtotal", subtotal.toString());
|
|
@@ -3373,6 +3638,12 @@ var PaymentMethodsApi = class {
|
|
|
3373
3638
|
constructor(http) {
|
|
3374
3639
|
this.http = http;
|
|
3375
3640
|
}
|
|
3641
|
+
/**
|
|
3642
|
+
* Lists the payment methods the store has turned on.
|
|
3643
|
+
*
|
|
3644
|
+
* @param storeRef - the store's ref or handle
|
|
3645
|
+
* @returns The enabled payment methods; throws {@link ApiClientError} when the API answers with an error
|
|
3646
|
+
*/
|
|
3376
3647
|
async getEnabled(storeRef) {
|
|
3377
3648
|
const res = await this.http.get(
|
|
3378
3649
|
`/public/stores/${storeRef}/payment-methods`
|
|
@@ -3419,6 +3690,14 @@ var ReviewsApi = class {
|
|
|
3419
3690
|
constructor(http) {
|
|
3420
3691
|
this.http = http;
|
|
3421
3692
|
}
|
|
3693
|
+
/**
|
|
3694
|
+
* Lists the published reviews of a product.
|
|
3695
|
+
*
|
|
3696
|
+
* @param storeRef - the store's ref or handle
|
|
3697
|
+
* @param productId - the product id
|
|
3698
|
+
* @param query - filters and paging
|
|
3699
|
+
* @returns A page of reviews; throws {@link ApiClientError} when the API answers with an error
|
|
3700
|
+
*/
|
|
3422
3701
|
async getProductReviews(storeRef, productId, query) {
|
|
3423
3702
|
const queryString = stringify(query ?? {});
|
|
3424
3703
|
const res = await this.http.get(
|
|
@@ -3426,12 +3705,27 @@ var ReviewsApi = class {
|
|
|
3426
3705
|
);
|
|
3427
3706
|
return unwrap(res);
|
|
3428
3707
|
}
|
|
3708
|
+
/**
|
|
3709
|
+
* Gets the public details behind a review invitation link.
|
|
3710
|
+
*
|
|
3711
|
+
* @param storeRef - the store's ref or handle
|
|
3712
|
+
* @param token - the token from the invitation link
|
|
3713
|
+
* @returns The invitation details; throws {@link ApiClientError} when the API answers with an error
|
|
3714
|
+
*/
|
|
3429
3715
|
async getReviewInvitation(storeRef, token) {
|
|
3430
3716
|
const res = await this.http.get(
|
|
3431
3717
|
`public/stores/${storeRef}/review-invitations/${token}`
|
|
3432
3718
|
);
|
|
3433
3719
|
return unwrap(res);
|
|
3434
3720
|
}
|
|
3721
|
+
/**
|
|
3722
|
+
* Lists the review invitations for one order.
|
|
3723
|
+
*
|
|
3724
|
+
* @param storeRef - the store's ref or handle
|
|
3725
|
+
* @param orderNumber - the order number
|
|
3726
|
+
* @param email - the email address on the order
|
|
3727
|
+
* @returns The invitation summaries; throws {@link ApiClientError} when the API answers with an error
|
|
3728
|
+
*/
|
|
3435
3729
|
async getOrderReviewInvitations(storeRef, orderNumber, email) {
|
|
3436
3730
|
const queryString = stringify({ order_number: orderNumber, email });
|
|
3437
3731
|
const res = await this.http.get(
|
|
@@ -3439,6 +3733,14 @@ var ReviewsApi = class {
|
|
|
3439
3733
|
);
|
|
3440
3734
|
return unwrap(res);
|
|
3441
3735
|
}
|
|
3736
|
+
/**
|
|
3737
|
+
* Lists the review invitations for several orders at once.
|
|
3738
|
+
*
|
|
3739
|
+
* @param storeRef - the store's ref or handle
|
|
3740
|
+
* @param orderNumbers - the order numbers
|
|
3741
|
+
* @param email - the email address on the orders
|
|
3742
|
+
* @returns The invitations grouped by order; throws {@link ApiClientError} when the API answers with an error
|
|
3743
|
+
*/
|
|
3442
3744
|
async getBatchOrderReviewInvitations(storeRef, orderNumbers, email) {
|
|
3443
3745
|
const queryString = stringify({ order_numbers: orderNumbers.join(","), email });
|
|
3444
3746
|
const res = await this.http.get(
|
|
@@ -3446,6 +3748,14 @@ var ReviewsApi = class {
|
|
|
3446
3748
|
);
|
|
3447
3749
|
return unwrap(res);
|
|
3448
3750
|
}
|
|
3751
|
+
/**
|
|
3752
|
+
* Submits a review through an invitation link.
|
|
3753
|
+
*
|
|
3754
|
+
* @param storeRef - the store's ref or handle
|
|
3755
|
+
* @param token - the token from the invitation link
|
|
3756
|
+
* @param payload - the rating and review text
|
|
3757
|
+
* @returns The API's answer; throws {@link ApiClientError} when the API answers with an error
|
|
3758
|
+
*/
|
|
3449
3759
|
async submitReviewInvitation(storeRef, token, payload) {
|
|
3450
3760
|
const res = await this.http.post(
|
|
3451
3761
|
`public/stores/${storeRef}/review-invitations/${token}/submit`,
|
|
@@ -3460,6 +3770,13 @@ var CustomersApi = class {
|
|
|
3460
3770
|
constructor(http) {
|
|
3461
3771
|
this.http = http;
|
|
3462
3772
|
}
|
|
3773
|
+
/**
|
|
3774
|
+
* Creates the customer record for a newly signed-in user, or updates it when it exists.
|
|
3775
|
+
*
|
|
3776
|
+
* @param storeRef - the store's ref or handle
|
|
3777
|
+
* @param payload - the identity fields to store
|
|
3778
|
+
* @returns The customer, as the raw {@link ApiResponse}; it does not throw, so check `success`
|
|
3779
|
+
*/
|
|
3463
3780
|
async upsertForAuth(storeRef, payload) {
|
|
3464
3781
|
return this.http.post(
|
|
3465
3782
|
`/stores/${storeRef}/customers/auth/upsert`,
|
|
@@ -3491,18 +3808,38 @@ var AddressesApi = class {
|
|
|
3491
3808
|
constructor(http) {
|
|
3492
3809
|
this.http = http;
|
|
3493
3810
|
}
|
|
3811
|
+
/**
|
|
3812
|
+
* Lists the signed-in customer's saved addresses.
|
|
3813
|
+
*
|
|
3814
|
+
* @param storeRef - the store's ref or handle
|
|
3815
|
+
* @returns The addresses, or `null` when it is not found; throws {@link ApiClientError} on any other API error
|
|
3816
|
+
*/
|
|
3494
3817
|
async list(storeRef) {
|
|
3495
3818
|
const res = await this.http.get(
|
|
3496
3819
|
`/tenant/stores/${storeRef}/customers/address`
|
|
3497
3820
|
);
|
|
3498
3821
|
return unwrapOrNull(res);
|
|
3499
3822
|
}
|
|
3823
|
+
/**
|
|
3824
|
+
* Gets one of the signed-in customer's saved addresses.
|
|
3825
|
+
*
|
|
3826
|
+
* @param storeRef - the store's ref or handle
|
|
3827
|
+
* @param addressId - the address id
|
|
3828
|
+
* @returns The address, or `null` when it is not found; throws {@link ApiClientError} on any other API error
|
|
3829
|
+
*/
|
|
3500
3830
|
async getById(storeRef, addressId) {
|
|
3501
3831
|
const res = await this.http.get(
|
|
3502
3832
|
`/tenant/stores/${storeRef}/customers/address/${addressId}`
|
|
3503
3833
|
);
|
|
3504
3834
|
return unwrapOrNull(res);
|
|
3505
3835
|
}
|
|
3836
|
+
/**
|
|
3837
|
+
* Saves a new address for the signed-in customer.
|
|
3838
|
+
*
|
|
3839
|
+
* @param storeRef - the store's ref or handle
|
|
3840
|
+
* @param data - the address fields
|
|
3841
|
+
* @returns The created address, or `null` when it is not found; throws {@link ApiClientError} on any other API error
|
|
3842
|
+
*/
|
|
3506
3843
|
async create(storeRef, data) {
|
|
3507
3844
|
const res = await this.http.post(
|
|
3508
3845
|
`/tenant/stores/${storeRef}/customers/address`,
|
|
@@ -3510,6 +3847,14 @@ var AddressesApi = class {
|
|
|
3510
3847
|
);
|
|
3511
3848
|
return unwrapOrNull(res);
|
|
3512
3849
|
}
|
|
3850
|
+
/**
|
|
3851
|
+
* Updates one of the signed-in customer's saved addresses.
|
|
3852
|
+
*
|
|
3853
|
+
* @param storeRef - the store's ref or handle
|
|
3854
|
+
* @param addressId - the address id
|
|
3855
|
+
* @param data - the fields to change
|
|
3856
|
+
* @returns The updated address, or `null` when it is not found; throws {@link ApiClientError} on any other API error
|
|
3857
|
+
*/
|
|
3513
3858
|
async update(storeRef, addressId, data) {
|
|
3514
3859
|
const res = await this.http.patch(
|
|
3515
3860
|
`/tenant/stores/${storeRef}/customers/address/${addressId}`,
|
|
@@ -3517,12 +3862,26 @@ var AddressesApi = class {
|
|
|
3517
3862
|
);
|
|
3518
3863
|
return unwrapOrNull(res);
|
|
3519
3864
|
}
|
|
3865
|
+
/**
|
|
3866
|
+
* Deletes one of the signed-in customer's saved addresses.
|
|
3867
|
+
*
|
|
3868
|
+
* @param storeRef - the store's ref or handle
|
|
3869
|
+
* @param addressId - the address id
|
|
3870
|
+
* @returns `true` when the API accepted the deletion, `false` otherwise; it does not throw
|
|
3871
|
+
*/
|
|
3520
3872
|
async delete(storeRef, addressId) {
|
|
3521
3873
|
const res = await this.http.delete(
|
|
3522
3874
|
`/tenant/stores/${storeRef}/customers/address/${addressId}`
|
|
3523
3875
|
);
|
|
3524
3876
|
return res.success;
|
|
3525
3877
|
}
|
|
3878
|
+
/**
|
|
3879
|
+
* Makes a saved address the customer's default.
|
|
3880
|
+
*
|
|
3881
|
+
* @param storeRef - the store's ref or handle
|
|
3882
|
+
* @param addressId - the address id
|
|
3883
|
+
* @returns The updated address, or `null` when it is not found; throws {@link ApiClientError} on any other API error
|
|
3884
|
+
*/
|
|
3526
3885
|
async setDefault(storeRef, addressId) {
|
|
3527
3886
|
const res = await this.http.patch(
|
|
3528
3887
|
`/tenant/stores/${storeRef}/customers/address/${addressId}/set-default`
|
|
@@ -3536,12 +3895,26 @@ var ContentPagesApi = class {
|
|
|
3536
3895
|
constructor(http) {
|
|
3537
3896
|
this.http = http;
|
|
3538
3897
|
}
|
|
3898
|
+
/**
|
|
3899
|
+
* Lists the published content pages.
|
|
3900
|
+
*
|
|
3901
|
+
* @param storeRef - the store's ref or handle
|
|
3902
|
+
* @returns A page of content pages; throws {@link ApiClientError} when the API answers with an error
|
|
3903
|
+
*/
|
|
3539
3904
|
async getPublished(storeRef) {
|
|
3540
3905
|
const res = await this.http.get(
|
|
3541
3906
|
`/public/stores/${storeRef}/content-pages`
|
|
3542
3907
|
);
|
|
3543
3908
|
return unwrap(res);
|
|
3544
3909
|
}
|
|
3910
|
+
/**
|
|
3911
|
+
* Gets one published content page by slug.
|
|
3912
|
+
*
|
|
3913
|
+
* @param storeRef - the store's ref or handle
|
|
3914
|
+
* @param slug - the page slug
|
|
3915
|
+
* @param query - `include_seo_metadata` adds the SEO fields
|
|
3916
|
+
* @returns The page; throws {@link ApiClientError} when the API answers with an error
|
|
3917
|
+
*/
|
|
3545
3918
|
async getBySlug(storeRef, slug, query) {
|
|
3546
3919
|
const queryString = query ? stringify(query) : "";
|
|
3547
3920
|
const res = await this.http.get(
|
|
@@ -3556,6 +3929,14 @@ var MenusApi = class {
|
|
|
3556
3929
|
constructor(http) {
|
|
3557
3930
|
this.http = http;
|
|
3558
3931
|
}
|
|
3932
|
+
/**
|
|
3933
|
+
* Gets a navigation menu by its ref.
|
|
3934
|
+
*
|
|
3935
|
+
* @param storeRef - the store's ref or handle
|
|
3936
|
+
* @param ref - the menu ref
|
|
3937
|
+
* @param includeItems - `true` (the default) includes the menu items
|
|
3938
|
+
* @returns The menu, or `null` when it is not found; throws {@link ApiClientError} on any other API error
|
|
3939
|
+
*/
|
|
3559
3940
|
async getByRef(storeRef, ref, includeItems = true) {
|
|
3560
3941
|
const query = includeItems ? "?include_items=true" : "";
|
|
3561
3942
|
const res = await this.http.get(
|
|
@@ -3601,9 +3982,21 @@ var AuthApi = class {
|
|
|
3601
3982
|
async register(payload) {
|
|
3602
3983
|
return this.http.post(this.publicPath("register"), payload, void 0);
|
|
3603
3984
|
}
|
|
3985
|
+
/**
|
|
3986
|
+
* Signs a customer in with email and password.
|
|
3987
|
+
*
|
|
3988
|
+
* @param payload - the login credentials
|
|
3989
|
+
* @returns The auth result with the token pair, as the raw {@link ApiResponse}; it does not throw, so check `success`
|
|
3990
|
+
*/
|
|
3604
3991
|
async login(payload) {
|
|
3605
3992
|
return this.http.post(this.publicPath("login"), payload, void 0);
|
|
3606
3993
|
}
|
|
3994
|
+
/**
|
|
3995
|
+
* Exchanges a refresh token for a new token pair. The old refresh token stops working.
|
|
3996
|
+
*
|
|
3997
|
+
* @param refresh_token - the customer's current refresh token
|
|
3998
|
+
* @returns The new token pair, as the raw {@link ApiResponse}; it does not throw, so check `success`
|
|
3999
|
+
*/
|
|
3607
4000
|
async refresh(refresh_token) {
|
|
3608
4001
|
return this.http.post(
|
|
3609
4002
|
this.publicPath("refresh"),
|
|
@@ -3623,6 +4016,12 @@ var AuthApi = class {
|
|
|
3623
4016
|
void 0
|
|
3624
4017
|
);
|
|
3625
4018
|
}
|
|
4019
|
+
/**
|
|
4020
|
+
* Sends the email-verification message again.
|
|
4021
|
+
*
|
|
4022
|
+
* @param email - the address to verify
|
|
4023
|
+
* @returns The send result, as the raw {@link ApiResponse}; it does not throw, so check `success`
|
|
4024
|
+
*/
|
|
3626
4025
|
async resendVerification(email) {
|
|
3627
4026
|
return this.http.post(
|
|
3628
4027
|
this.publicPath("resend-verification"),
|
|
@@ -3630,6 +4029,12 @@ var AuthApi = class {
|
|
|
3630
4029
|
void 0
|
|
3631
4030
|
);
|
|
3632
4031
|
}
|
|
4032
|
+
/**
|
|
4033
|
+
* Starts a password reset by emailing a reset link.
|
|
4034
|
+
*
|
|
4035
|
+
* @param email - the account's email address
|
|
4036
|
+
* @returns The send result, as the raw {@link ApiResponse}; it does not throw, so check `success`
|
|
4037
|
+
*/
|
|
3633
4038
|
async forgotPassword(email) {
|
|
3634
4039
|
return this.http.post(
|
|
3635
4040
|
this.publicPath("forgot-password"),
|
|
@@ -3637,6 +4042,12 @@ var AuthApi = class {
|
|
|
3637
4042
|
void 0
|
|
3638
4043
|
);
|
|
3639
4044
|
}
|
|
4045
|
+
/**
|
|
4046
|
+
* Sets a new password using the token from the reset email.
|
|
4047
|
+
*
|
|
4048
|
+
* @param payload - the reset token and the new password
|
|
4049
|
+
* @returns The reset result, as the raw {@link ApiResponse}; it does not throw, so check `success`
|
|
4050
|
+
*/
|
|
3640
4051
|
async resetPassword(payload) {
|
|
3641
4052
|
return this.http.post(
|
|
3642
4053
|
this.publicPath("reset-password"),
|
|
@@ -3652,6 +4063,12 @@ var AuthApi = class {
|
|
|
3652
4063
|
void 0
|
|
3653
4064
|
);
|
|
3654
4065
|
}
|
|
4066
|
+
/**
|
|
4067
|
+
* Emails a one-time sign-in code.
|
|
4068
|
+
*
|
|
4069
|
+
* @param email - the account's email address
|
|
4070
|
+
* @returns The send result, as the raw {@link ApiResponse}; it does not throw, so check `success`
|
|
4071
|
+
*/
|
|
3655
4072
|
async requestOtp(email) {
|
|
3656
4073
|
return this.http.post(
|
|
3657
4074
|
this.publicPath("otp/request"),
|
|
@@ -3659,6 +4076,12 @@ var AuthApi = class {
|
|
|
3659
4076
|
void 0
|
|
3660
4077
|
);
|
|
3661
4078
|
}
|
|
4079
|
+
/**
|
|
4080
|
+
* Signs a customer in with the one-time code from the email.
|
|
4081
|
+
*
|
|
4082
|
+
* @param payload - the email and the code
|
|
4083
|
+
* @returns The auth result with the token pair, as the raw {@link ApiResponse}; it does not throw, so check `success`
|
|
4084
|
+
*/
|
|
3662
4085
|
async verifyOtp(payload) {
|
|
3663
4086
|
return this.http.post(
|
|
3664
4087
|
this.publicPath("otp/verify"),
|
|
@@ -3666,9 +4089,20 @@ var AuthApi = class {
|
|
|
3666
4089
|
void 0
|
|
3667
4090
|
);
|
|
3668
4091
|
}
|
|
4092
|
+
/**
|
|
4093
|
+
* Starts an anonymous (guest) session.
|
|
4094
|
+
*
|
|
4095
|
+
* @returns The auth result with the token pair, as the raw {@link ApiResponse}; it does not throw, so check `success`
|
|
4096
|
+
*/
|
|
3669
4097
|
async anonymous() {
|
|
3670
4098
|
return this.http.post(this.publicPath("anonymous"), void 0, void 0);
|
|
3671
4099
|
}
|
|
4100
|
+
/**
|
|
4101
|
+
* Gets the URL that starts Google sign-in.
|
|
4102
|
+
*
|
|
4103
|
+
* @param redirect_to - where to send the customer after sign-in, `/` by default
|
|
4104
|
+
* @returns The Google sign-in URL, as the raw {@link ApiResponse}; it does not throw, so check `success`
|
|
4105
|
+
*/
|
|
3672
4106
|
async getGoogleUrl(redirect_to = "/") {
|
|
3673
4107
|
const query = `?redirect_to=${encodeURIComponent(redirect_to)}`;
|
|
3674
4108
|
return this.http.get(
|
|
@@ -3676,6 +4110,12 @@ var AuthApi = class {
|
|
|
3676
4110
|
void 0
|
|
3677
4111
|
);
|
|
3678
4112
|
}
|
|
4113
|
+
/**
|
|
4114
|
+
* Completes Google sign-in by exchanging the authorization code.
|
|
4115
|
+
*
|
|
4116
|
+
* @param code - the authorization code Google returned
|
|
4117
|
+
* @returns The auth result with the token pair, as the raw {@link ApiResponse}; it does not throw, so check `success`
|
|
4118
|
+
*/
|
|
3679
4119
|
async exchangeGoogleCode(code) {
|
|
3680
4120
|
return this.http.post(
|
|
3681
4121
|
this.publicPath("google/exchange"),
|
|
@@ -3683,10 +4123,21 @@ var AuthApi = class {
|
|
|
3683
4123
|
void 0
|
|
3684
4124
|
);
|
|
3685
4125
|
}
|
|
4126
|
+
/**
|
|
4127
|
+
* Reads which sign-in methods this store has turned on.
|
|
4128
|
+
*
|
|
4129
|
+
* @returns The public auth configuration, as the raw {@link ApiResponse}; it does not throw, so check `success`
|
|
4130
|
+
*/
|
|
3686
4131
|
async getAuthConfig() {
|
|
3687
4132
|
return this.http.get(this.publicPath("config"), void 0);
|
|
3688
4133
|
}
|
|
3689
4134
|
// ---- access token required -------------------------------------------
|
|
4135
|
+
/**
|
|
4136
|
+
* Reads the signed-in customer's identity.
|
|
4137
|
+
*
|
|
4138
|
+
* @param access_token - the signed-in customer's access token
|
|
4139
|
+
* @returns The current identity, as the raw {@link ApiResponse}; it does not throw, so check `success`
|
|
4140
|
+
*/
|
|
3690
4141
|
async me(access_token) {
|
|
3691
4142
|
return this.http.get(
|
|
3692
4143
|
this.tenantPath("me"),
|
|
@@ -3701,6 +4152,12 @@ var AuthApi = class {
|
|
|
3701
4152
|
this.auth(access_token)
|
|
3702
4153
|
);
|
|
3703
4154
|
}
|
|
4155
|
+
/**
|
|
4156
|
+
* Signs the customer out of every session.
|
|
4157
|
+
*
|
|
4158
|
+
* @param access_token - the signed-in customer's access token
|
|
4159
|
+
* @returns The API's answer, as the raw {@link ApiResponse}; it does not throw, so check `success`
|
|
4160
|
+
*/
|
|
3704
4161
|
async logoutAll(access_token) {
|
|
3705
4162
|
return this.http.post(
|
|
3706
4163
|
this.tenantPath("logout-all"),
|
|
@@ -3708,6 +4165,13 @@ var AuthApi = class {
|
|
|
3708
4165
|
this.auth(access_token)
|
|
3709
4166
|
);
|
|
3710
4167
|
}
|
|
4168
|
+
/**
|
|
4169
|
+
* Changes the signed-in customer's password.
|
|
4170
|
+
*
|
|
4171
|
+
* @param access_token - the signed-in customer's access token
|
|
4172
|
+
* @param payload - the current and the new password
|
|
4173
|
+
* @returns The API's answer, as the raw {@link ApiResponse}; it does not throw, so check `success`
|
|
4174
|
+
*/
|
|
3711
4175
|
async changePassword(access_token, payload) {
|
|
3712
4176
|
return this.http.post(
|
|
3713
4177
|
this.tenantPath("change-password"),
|
|
@@ -3715,6 +4179,13 @@ var AuthApi = class {
|
|
|
3715
4179
|
this.auth(access_token)
|
|
3716
4180
|
);
|
|
3717
4181
|
}
|
|
4182
|
+
/**
|
|
4183
|
+
* Starts an email change; the new address must be confirmed from the message sent to it.
|
|
4184
|
+
*
|
|
4185
|
+
* @param access_token - the signed-in customer's access token
|
|
4186
|
+
* @param payload - the new email address and the current password
|
|
4187
|
+
* @returns The change-email result, as the raw {@link ApiResponse}; it does not throw, so check `success`
|
|
4188
|
+
*/
|
|
3718
4189
|
async changeEmail(access_token, payload) {
|
|
3719
4190
|
return this.http.post(
|
|
3720
4191
|
this.tenantPath("change-email"),
|
|
@@ -3729,12 +4200,25 @@ var MemoryTokenStorage = class {
|
|
|
3729
4200
|
constructor(initial = null) {
|
|
3730
4201
|
this.tokens = initial;
|
|
3731
4202
|
}
|
|
4203
|
+
/**
|
|
4204
|
+
* Reads the stored token pair.
|
|
4205
|
+
*
|
|
4206
|
+
* @returns The stored tokens, or `null` when none are stored
|
|
4207
|
+
*/
|
|
3732
4208
|
async get() {
|
|
3733
4209
|
return this.tokens;
|
|
3734
4210
|
}
|
|
4211
|
+
/**
|
|
4212
|
+
* Stores a token pair, replacing any earlier one.
|
|
4213
|
+
*
|
|
4214
|
+
* @param tokens - the access and refresh tokens
|
|
4215
|
+
*/
|
|
3735
4216
|
async set(tokens) {
|
|
3736
4217
|
this.tokens = tokens;
|
|
3737
4218
|
}
|
|
4219
|
+
/**
|
|
4220
|
+
* Forgets the stored token pair.
|
|
4221
|
+
*/
|
|
3738
4222
|
async clear() {
|
|
3739
4223
|
this.tokens = null;
|
|
3740
4224
|
}
|
|
@@ -3939,7 +4423,8 @@ var SHIPPING_ERROR_CODES = {
|
|
|
3939
4423
|
|
|
3940
4424
|
// src/index.ts
|
|
3941
4425
|
function createEcomwebSdk(options) {
|
|
3942
|
-
const
|
|
4426
|
+
const publicHttp = withClientHeader(options.publicHttp, options.clientInfo);
|
|
4427
|
+
const authHttp = withClientHeader(options.authHttp, options.clientInfo);
|
|
3943
4428
|
return {
|
|
3944
4429
|
products: new ProductsApi(publicHttp),
|
|
3945
4430
|
collections: new CollectionsApi(publicHttp),
|
|
@@ -3970,6 +4455,7 @@ export {
|
|
|
3970
4455
|
ApiClientError,
|
|
3971
4456
|
AuthApi,
|
|
3972
4457
|
BlogApi,
|
|
4458
|
+
CLIENT_HEADER,
|
|
3973
4459
|
COLLECTION_RULE_MATRIX,
|
|
3974
4460
|
CONDITION_TYPE_LABELS,
|
|
3975
4461
|
CartApi,
|
|
@@ -4049,6 +4535,8 @@ export {
|
|
|
4049
4535
|
RULE_FIELDS,
|
|
4050
4536
|
RedirectsApi,
|
|
4051
4537
|
ReviewsApi,
|
|
4538
|
+
SDK_CLIENT_TOKEN,
|
|
4539
|
+
SDK_VERSION,
|
|
4052
4540
|
SHIPMENT_STATUSES,
|
|
4053
4541
|
SHIPPING_CONDITION_TYPES,
|
|
4054
4542
|
SHIPPING_DELIVERY_TYPES,
|
|
@@ -4089,6 +4577,7 @@ export {
|
|
|
4089
4577
|
categoryTreeSchema,
|
|
4090
4578
|
categoryWithChildrenSchema,
|
|
4091
4579
|
checkMetaobjectFieldChanges,
|
|
4580
|
+
clientHeaderValue,
|
|
4092
4581
|
colorSchema,
|
|
4093
4582
|
compareDecimal,
|
|
4094
4583
|
contentPageSchema,
|
|
@@ -4251,6 +4740,7 @@ export {
|
|
|
4251
4740
|
valueKindFor,
|
|
4252
4741
|
variantOptionSchema,
|
|
4253
4742
|
variantOptionValueSchema,
|
|
4254
|
-
variantStatusSchema
|
|
4743
|
+
variantStatusSchema,
|
|
4744
|
+
withClientHeader
|
|
4255
4745
|
};
|
|
4256
4746
|
//# sourceMappingURL=index.js.map
|