oneentry 1.0.150 → 1.0.152
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/changelog.md +30 -0
- package/dist/base/asyncModules.d.ts +8 -2
- package/dist/base/asyncModules.js +55 -4
- package/dist/base/stateModule.d.ts +1 -0
- package/dist/base/stateModule.js +4 -0
- package/dist/blocks/blocksApi.d.ts +19 -4
- package/dist/blocks/blocksApi.js +24 -6
- package/dist/blocks/blocksInterfaces.d.ts +20 -5
- package/dist/file-uploading/fileUploadingInterfaces.d.ts +2 -0
- package/dist/file-uploading/fileUploadingSchemas.d.ts +2 -0
- package/dist/file-uploading/fileUploadingSchemas.js +1 -0
- package/dist/forms-data/formsDataInterfaces.d.ts +2 -2
- package/dist/forms-data/formsDataSchemas.d.ts +1 -1
- package/dist/forms-data/formsDataSchemas.js +1 -1
- package/dist/orders/ordersInterfaces.d.ts +51 -3
- package/dist/orders/ordersSchemas.d.ts +127 -31
- package/dist/orders/ordersSchemas.js +53 -30
- package/dist/pages/pagesInterfaces.d.ts +12 -6
- package/dist/pages/pagesSchemas.d.ts +21 -6
- package/dist/pages/pagesSchemas.js +3 -2
- package/dist/products/productsApi.js +16 -4
- package/dist/products/productsInterfaces.d.ts +5 -5
- package/package.json +1 -1
package/changelog.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# SDK Change Log
|
|
2
2
|
|
|
3
|
+
## v.1.0.152
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
- Auth — eliminated the spurious `401` logged on every page load for a valid restored session. `browserResponse` now does a **proactive refresh** when a refresh token is present but there is no access token yet: it fetches the access token *before* the first request (clean `200`) instead of sending an unauthenticated request that is guaranteed to `401` and then reactively refreshing. After the proactive refresh it attaches `Authorization` and drops the `x-guest-id` scoping. The reactive `401 → refresh → retry` path is retained for mid-session token expiry.
|
|
8
|
+
|
|
9
|
+
- Auth — `refreshToken` is now **single-flight**.
|
|
10
|
+
|
|
11
|
+
## v.1.0.151
|
|
12
|
+
|
|
13
|
+
### What's New
|
|
14
|
+
|
|
15
|
+
- Pages > `PageType` — new page-specific type union (`'catalog_page' | 'common_page' | 'error_page' | 'external_page'`), a page subset of `BlockType`.
|
|
16
|
+
|
|
17
|
+
- Orders > `IOrderSplit`, `IOrderSplitStage` — new interfaces describing the split (staged) payment configuration returned by the by-id order endpoint.
|
|
18
|
+
|
|
19
|
+
### What's Changed
|
|
20
|
+
|
|
21
|
+
- Pages > `IPagesEntity.type` — now typed as the page-specific `PageType` instead of the broad `BlockType` (the value set is unchanged, just narrowed semantically). The page Zod schema validates `type` against the same set.
|
|
22
|
+
|
|
23
|
+
- Pages > `IPagesEntity.categoryPath` — now `string | null` (was `string`); the API returns `null` for nested pages. Page Zod schema relaxed to `z.string().nullable().optional()`.
|
|
24
|
+
|
|
25
|
+
- FormsData > `IPostFormResponseData.fingerprint` — now `string | null` (was `string`); anonymous / app-token submissions return `null`. `PostFormResponseSchema` relaxed to `z.string().nullable()` (previously rejected the real response under strict validation).
|
|
26
|
+
|
|
27
|
+
- Orders > `IOrderDiscountConfig.bonus` — now optional (`bonus?`); the API omits the key entirely on orders without a bonus context (previously failed validation when embedded in create/update order responses).
|
|
28
|
+
|
|
29
|
+
- Orders > `IOrderByMarkerEntity` — now exposes `discountConfig` (`IOrderDiscountConfig | null`), `totalSumRaw`, `isPartial` (`boolean | null`), `paymentStrategy`, and `split`; these fields are returned by the API and were previously stripped from the validated result. `OrderEntitySchema` extended accordingly, and `IOrderDiscountSettings` / `OrderDiscountConfigSchema.settings` gained `giftRefundPolicy`, `maxBonusPaymentPercent`, `minBonusAmount`, `minOrderAmountForBonus`.
|
|
30
|
+
|
|
31
|
+
- FileUploading > `IUploadingReturn.contentType` — added (the upload endpoint always returns the file MIME type); `UploadingReturnSchema` extended with `contentType: z.string()`.
|
|
32
|
+
|
|
3
33
|
## v.1.0.150
|
|
4
34
|
|
|
5
35
|
### What's New
|
|
@@ -57,11 +57,17 @@ export default abstract class AsyncModules extends SyncModules {
|
|
|
57
57
|
*/
|
|
58
58
|
protected _fetchDelete<T = unknown>(path: string, body?: unknown): Promise<T>;
|
|
59
59
|
/**
|
|
60
|
-
* Refreshes the authentication token.
|
|
60
|
+
* Refreshes the authentication token (single-flight).
|
|
61
61
|
* @returns {Promise<boolean>} A promise resolving to a boolean indicating success or failure.
|
|
62
|
-
* @description
|
|
62
|
+
* @description De-duplicates concurrent refreshes — the refresh token is single-use, so parallel requests must share one refresh call instead of each burning a rotated token.
|
|
63
63
|
*/
|
|
64
64
|
protected refreshToken(): Promise<boolean>;
|
|
65
|
+
/**
|
|
66
|
+
* Performs the actual token refresh request (without de-duplication).
|
|
67
|
+
* @returns {Promise<boolean>} A promise resolving to a boolean indicating success or failure.
|
|
68
|
+
* @description Sends POST /users/refresh and, on success, stores the rotated access/refresh tokens and calls saveFunction.
|
|
69
|
+
*/
|
|
70
|
+
private _performRefresh;
|
|
65
71
|
/**
|
|
66
72
|
* Creates options for HTTP requests.
|
|
67
73
|
* @param {string} method - The HTTP method (GET, POST, PUT, DELETE, etc.).
|
|
@@ -282,11 +282,33 @@ class AsyncModules extends syncModules_1.default {
|
|
|
282
282
|
}
|
|
283
283
|
}
|
|
284
284
|
/**
|
|
285
|
-
* Refreshes the authentication token.
|
|
285
|
+
* Refreshes the authentication token (single-flight).
|
|
286
286
|
* @returns {Promise<boolean>} A promise resolving to a boolean indicating success or failure.
|
|
287
|
-
* @description
|
|
287
|
+
* @description De-duplicates concurrent refreshes — the refresh token is single-use, so parallel requests must share one refresh call instead of each burning a rotated token.
|
|
288
288
|
*/
|
|
289
289
|
async refreshToken() {
|
|
290
|
+
// Reuse an in-flight refresh if one is already running (shared via state
|
|
291
|
+
// across all module instances). Prevents parallel requests from each firing
|
|
292
|
+
// their own refresh and invalidating the single-use refresh token.
|
|
293
|
+
if (this.state._refreshPromise) {
|
|
294
|
+
return this.state._refreshPromise;
|
|
295
|
+
}
|
|
296
|
+
const promise = this._performRefresh();
|
|
297
|
+
this.state._refreshPromise = promise;
|
|
298
|
+
try {
|
|
299
|
+
return await promise;
|
|
300
|
+
}
|
|
301
|
+
finally {
|
|
302
|
+
// Clear so the next genuine 401 (e.g. mid-session expiry) can refresh again.
|
|
303
|
+
this.state._refreshPromise = null;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Performs the actual token refresh request (without de-duplication).
|
|
308
|
+
* @returns {Promise<boolean>} A promise resolving to a boolean indicating success or failure.
|
|
309
|
+
* @description Sends POST /users/refresh and, on success, stores the rotated access/refresh tokens and calls saveFunction.
|
|
310
|
+
*/
|
|
311
|
+
async _performRefresh() {
|
|
290
312
|
const url = this.state.url +
|
|
291
313
|
`/api/content/users-auth-providers/marker/` +
|
|
292
314
|
this.state.providerMarker +
|
|
@@ -396,7 +418,32 @@ class AsyncModules extends syncModules_1.default {
|
|
|
396
418
|
* @description Define an asynchronous method 'browserResponse' that takes a path and options as parameters
|
|
397
419
|
*/
|
|
398
420
|
async browserResponse(path, options) {
|
|
421
|
+
// Set when a proactive refresh ran and failed (dead/expired refresh token):
|
|
422
|
+
// used below to skip the reactive refresh so we don't fire a second,
|
|
423
|
+
// equally-doomed refresh on the 401 that the request is about to return.
|
|
424
|
+
let proactiveRefreshFailed = false;
|
|
399
425
|
try {
|
|
426
|
+
// Proactive (eager) refresh: a session restored from storage has a refresh
|
|
427
|
+
// token but no access token yet. Sending the first authenticated request
|
|
428
|
+
// without an access token GUARANTEES a 401 (then a reactive refresh + retry)
|
|
429
|
+
// — a spurious 401 logged on every page load even for a perfectly valid
|
|
430
|
+
// session. Obtaining the access token up-front turns that into a clean 200.
|
|
431
|
+
// Fires at most once per session (skipped once accessToken is set), and is
|
|
432
|
+
// off for custom-auth callers who manage tokens themselves.
|
|
433
|
+
if (!this.state.accessToken &&
|
|
434
|
+
this.state.refreshToken &&
|
|
435
|
+
!this.state.customAuth) {
|
|
436
|
+
const refreshed = await this.refreshToken();
|
|
437
|
+
if (refreshed) {
|
|
438
|
+
// Authenticated now — attach the bearer and drop the guest scoping
|
|
439
|
+
// that makeOptions added while no access token was present.
|
|
440
|
+
options.headers['Authorization'] = 'Bearer ' + this.state.accessToken;
|
|
441
|
+
delete options.headers['x-guest-id'];
|
|
442
|
+
}
|
|
443
|
+
else {
|
|
444
|
+
proactiveRefreshFailed = true;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
400
447
|
// Perform a fetch request using the full URL obtained from '_getFullPath' and the provided options
|
|
401
448
|
const response = await fetch(this._getFullPath(path), options);
|
|
402
449
|
// Check if the response status is OK (status code 200-299)
|
|
@@ -415,8 +462,12 @@ class AsyncModules extends syncModules_1.default {
|
|
|
415
462
|
}
|
|
416
463
|
else {
|
|
417
464
|
// Handle non-OK responses
|
|
418
|
-
//
|
|
419
|
-
|
|
465
|
+
// Reactive refresh for mid-session expiry: access token was present but
|
|
466
|
+
// the server rejected it. Skipped when a proactive refresh already ran
|
|
467
|
+
// and failed (the refresh token is dead — retrying would 400 again).
|
|
468
|
+
if (response.status === 401 &&
|
|
469
|
+
!this.state.customAuth &&
|
|
470
|
+
!proactiveRefreshFailed) {
|
|
420
471
|
// Attempt to refresh the access token
|
|
421
472
|
const refresh = await this.refreshToken();
|
|
422
473
|
if (refresh) {
|
package/dist/base/stateModule.js
CHANGED
|
@@ -46,6 +46,10 @@ class StateModule {
|
|
|
46
46
|
*/
|
|
47
47
|
constructor(url, config) {
|
|
48
48
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
|
|
49
|
+
// In-flight token refresh, shared across all module instances (they share this
|
|
50
|
+
// state object). De-duplicates concurrent refreshes so the single-use refresh
|
|
51
|
+
// token is not burned by parallel requests. Null when no refresh is running.
|
|
52
|
+
this._refreshPromise = null;
|
|
49
53
|
this.url = url;
|
|
50
54
|
this.lang = (_a = config.langCode) !== null && _a !== void 0 ? _a : 'en_US';
|
|
51
55
|
this.token = config.token;
|
|
@@ -21,7 +21,7 @@ export default class BlocksApi extends AsyncModules implements IBlocks {
|
|
|
21
21
|
/**
|
|
22
22
|
* Get blocks by parameters.
|
|
23
23
|
* @handleName getBlocks
|
|
24
|
-
* @param {BlockType} type - Available values: "product" | "error_page" | "catalog_page" | "product_preview" | "similar_products_block" | "product_block" | "form" | "common_page" | "common_block" | "order" | "service" | "none". Example: 'product'.
|
|
24
|
+
* @param {BlockType} [type] - Optional block type to filter by. Available values: "product" | "error_page" | "catalog_page" | "product_preview" | "similar_products_block" | "product_block" | "form" | "common_page" | "common_block" | "order" | "service" | "none". When omitted, blocks of all types are returned. Example: 'product'.
|
|
25
25
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
26
26
|
* @param {number} [offset] - Parameter for pagination. Default: 0.
|
|
27
27
|
* @param {number} [limit] - Parameter for pagination. Default: 30.
|
|
@@ -100,7 +100,12 @@ export default class BlocksApi extends AsyncModules implements IBlocks {
|
|
|
100
100
|
* Get "complete your cart" products by an explicit list of productIds (POST body).
|
|
101
101
|
* @handleName getCartComplementByProductIds
|
|
102
102
|
* @param {string} marker - Block marker. Example: "cart_complement_block".
|
|
103
|
-
* @param {IBlockProductsLookup} body - Lookup body.
|
|
103
|
+
* @param {IBlockProductsLookup} body - Lookup body.
|
|
104
|
+
* @example
|
|
105
|
+
{
|
|
106
|
+
"productIds": [1, 2],
|
|
107
|
+
"langCode": "en_US"
|
|
108
|
+
}
|
|
104
109
|
* @returns {Promise<IProductsEntity[] | IError>} Returns an array of products.
|
|
105
110
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
106
111
|
*/
|
|
@@ -119,7 +124,12 @@ export default class BlocksApi extends AsyncModules implements IBlocks {
|
|
|
119
124
|
* Get "similar to cart" products by an explicit list of productIds (POST body).
|
|
120
125
|
* @handleName getCartSimilarByProductIds
|
|
121
126
|
* @param {string} marker - Block marker. Example: "cart_similar_block".
|
|
122
|
-
* @param {IBlockProductsLookup} body - Lookup body.
|
|
127
|
+
* @param {IBlockProductsLookup} body - Lookup body.
|
|
128
|
+
* @example
|
|
129
|
+
{
|
|
130
|
+
"productIds": [1, 2],
|
|
131
|
+
"langCode": "en_US"
|
|
132
|
+
}
|
|
123
133
|
* @returns {Promise<IProductsEntity[] | IError>} Returns an array of products.
|
|
124
134
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
125
135
|
*/
|
|
@@ -186,7 +196,12 @@ export default class BlocksApi extends AsyncModules implements IBlocks {
|
|
|
186
196
|
* Get "similar to wishlist" products by an explicit list of productIds (POST body).
|
|
187
197
|
* @handleName getWishlistSimilarByProductIds
|
|
188
198
|
* @param {string} marker - Block marker. Example: "wishlist_similar_block".
|
|
189
|
-
* @param {IBlockProductsLookup} body - Lookup body.
|
|
199
|
+
* @param {IBlockProductsLookup} body - Lookup body.
|
|
200
|
+
* @example
|
|
201
|
+
{
|
|
202
|
+
"productIds": [1, 2],
|
|
203
|
+
"langCode": "en_US"
|
|
204
|
+
}
|
|
190
205
|
* @returns {Promise<IProductsEntity[] | IError>} Returns an array of products.
|
|
191
206
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
192
207
|
*/
|
package/dist/blocks/blocksApi.js
CHANGED
|
@@ -25,15 +25,18 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
25
25
|
/**
|
|
26
26
|
* Get blocks by parameters.
|
|
27
27
|
* @handleName getBlocks
|
|
28
|
-
* @param {BlockType} type - Available values: "product" | "error_page" | "catalog_page" | "product_preview" | "similar_products_block" | "product_block" | "form" | "common_page" | "common_block" | "order" | "service" | "none". Example: 'product'.
|
|
28
|
+
* @param {BlockType} [type] - Optional block type to filter by. Available values: "product" | "error_page" | "catalog_page" | "product_preview" | "similar_products_block" | "product_block" | "form" | "common_page" | "common_block" | "order" | "service" | "none". When omitted, blocks of all types are returned. Example: 'product'.
|
|
29
29
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
30
30
|
* @param {number} [offset] - Parameter for pagination. Default: 0.
|
|
31
31
|
* @param {number} [limit] - Parameter for pagination. Default: 30.
|
|
32
32
|
* @returns {Promise<IBlocksResponse | IError>} Returns BlocksEntity object.
|
|
33
33
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
34
34
|
*/
|
|
35
|
-
async getBlocks(type
|
|
36
|
-
|
|
35
|
+
async getBlocks(type, langCode = this.state.lang, offset = 0, limit = 30) {
|
|
36
|
+
// type is omitted from the query when not provided — the API rejects an
|
|
37
|
+
// empty type value, so it must not be sent at all.
|
|
38
|
+
const query = this._queryParamsToString({ langCode, type, offset, limit });
|
|
39
|
+
const response = await this._fetchPost(`?${query}`);
|
|
37
40
|
// Validate response if validation is enabled
|
|
38
41
|
const validated = this._validateResponse(response, blocksSchemas_1.BlocksResponseSchema);
|
|
39
42
|
if (!this.state.traficLimit) {
|
|
@@ -223,7 +226,12 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
223
226
|
* Get "complete your cart" products by an explicit list of productIds (POST body).
|
|
224
227
|
* @handleName getCartComplementByProductIds
|
|
225
228
|
* @param {string} marker - Block marker. Example: "cart_complement_block".
|
|
226
|
-
* @param {IBlockProductsLookup} body - Lookup body.
|
|
229
|
+
* @param {IBlockProductsLookup} body - Lookup body.
|
|
230
|
+
* @example
|
|
231
|
+
{
|
|
232
|
+
"productIds": [1, 2],
|
|
233
|
+
"langCode": "en_US"
|
|
234
|
+
}
|
|
227
235
|
* @returns {Promise<IProductsEntity[] | IError>} Returns an array of products.
|
|
228
236
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
229
237
|
*/
|
|
@@ -249,7 +257,12 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
249
257
|
* Get "similar to cart" products by an explicit list of productIds (POST body).
|
|
250
258
|
* @handleName getCartSimilarByProductIds
|
|
251
259
|
* @param {string} marker - Block marker. Example: "cart_similar_block".
|
|
252
|
-
* @param {IBlockProductsLookup} body - Lookup body.
|
|
260
|
+
* @param {IBlockProductsLookup} body - Lookup body.
|
|
261
|
+
* @example
|
|
262
|
+
{
|
|
263
|
+
"productIds": [1, 2],
|
|
264
|
+
"langCode": "en_US"
|
|
265
|
+
}
|
|
253
266
|
* @returns {Promise<IProductsEntity[] | IError>} Returns an array of products.
|
|
254
267
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
255
268
|
*/
|
|
@@ -342,7 +355,12 @@ class BlocksApi extends asyncModules_1.default {
|
|
|
342
355
|
* Get "similar to wishlist" products by an explicit list of productIds (POST body).
|
|
343
356
|
* @handleName getWishlistSimilarByProductIds
|
|
344
357
|
* @param {string} marker - Block marker. Example: "wishlist_similar_block".
|
|
345
|
-
* @param {IBlockProductsLookup} body - Lookup body.
|
|
358
|
+
* @param {IBlockProductsLookup} body - Lookup body.
|
|
359
|
+
* @example
|
|
360
|
+
{
|
|
361
|
+
"productIds": [1, 2],
|
|
362
|
+
"langCode": "en_US"
|
|
363
|
+
}
|
|
346
364
|
* @returns {Promise<IProductsEntity[] | IError>} Returns an array of products.
|
|
347
365
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
348
366
|
*/
|
|
@@ -9,7 +9,7 @@ interface IBlocks {
|
|
|
9
9
|
/**
|
|
10
10
|
* Retrieves all block objects of a specific type.
|
|
11
11
|
* @handleName getBlocks
|
|
12
|
-
* @param {BlockType} type -
|
|
12
|
+
* @param {BlockType} [type] - Optional type of blocks to retrieve. When omitted, blocks of all types are returned. Example: "product".
|
|
13
13
|
* @param {string} [langCode] - Optional language code for localization. Default: "en_US".
|
|
14
14
|
* @param {number} [offset] - Optional offset for pagination. Default: 0.
|
|
15
15
|
* @param {number} [limit] - Optional limit for pagination. Default: 30.
|
|
@@ -17,7 +17,7 @@ interface IBlocks {
|
|
|
17
17
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
18
18
|
* @description This method retrieves all block objects of a specific type.
|
|
19
19
|
*/
|
|
20
|
-
getBlocks(type
|
|
20
|
+
getBlocks(type?: BlockType, langCode?: string, offset?: number, limit?: number): Promise<IBlocksResponse | IError>;
|
|
21
21
|
/**
|
|
22
22
|
* Retrieves a block object by its marker.
|
|
23
23
|
* @handleName getBlockByMarker
|
|
@@ -65,7 +65,12 @@ interface IBlocks {
|
|
|
65
65
|
* Get "complete your cart" products by an explicit list of productIds (POST body).
|
|
66
66
|
* @handleName getCartComplementByProductIds
|
|
67
67
|
* @param {string} marker - Block marker. Example: "cart_complement_block".
|
|
68
|
-
* @param {IBlockProductsLookup} body - Lookup body.
|
|
68
|
+
* @param {IBlockProductsLookup} body - Lookup body.
|
|
69
|
+
* @example
|
|
70
|
+
{
|
|
71
|
+
"productIds": [1, 2],
|
|
72
|
+
"langCode": "en_US"
|
|
73
|
+
}
|
|
69
74
|
* @returns {IProductsEntity[]} A promise that resolves to an array of products or an error.
|
|
70
75
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
71
76
|
*/
|
|
@@ -84,7 +89,12 @@ interface IBlocks {
|
|
|
84
89
|
* Get "similar to cart" products by an explicit list of productIds (POST body).
|
|
85
90
|
* @handleName getCartSimilarByProductIds
|
|
86
91
|
* @param {string} marker - Block marker. Example: "cart_similar_block".
|
|
87
|
-
* @param {IBlockProductsLookup} body - Lookup body.
|
|
92
|
+
* @param {IBlockProductsLookup} body - Lookup body.
|
|
93
|
+
* @example
|
|
94
|
+
{
|
|
95
|
+
"productIds": [1, 2],
|
|
96
|
+
"langCode": "en_US"
|
|
97
|
+
}
|
|
88
98
|
* @returns {IProductsEntity[]} A promise that resolves to an array of products or an error.
|
|
89
99
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
90
100
|
*/
|
|
@@ -151,7 +161,12 @@ interface IBlocks {
|
|
|
151
161
|
* Get "similar to wishlist" products by an explicit list of productIds (POST body).
|
|
152
162
|
* @handleName getWishlistSimilarByProductIds
|
|
153
163
|
* @param {string} marker - Block marker. Example: "wishlist_similar_block".
|
|
154
|
-
* @param {IBlockProductsLookup} body - Lookup body.
|
|
164
|
+
* @param {IBlockProductsLookup} body - Lookup body.
|
|
165
|
+
* @example
|
|
166
|
+
{
|
|
167
|
+
"productIds": [1, 2],
|
|
168
|
+
"langCode": "en_US"
|
|
169
|
+
}
|
|
155
170
|
* @returns {IProductsEntity[]} A promise that resolves to an array of products or an error.
|
|
156
171
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
157
172
|
*/
|
|
@@ -104,11 +104,13 @@ interface IUploadingQuery {
|
|
|
104
104
|
* @property {string} filename - Filename with relative path. Example: "uploads/file.png".
|
|
105
105
|
* @property {string} downloadLink - Link for downloading the file. Example: "https://example.com/uploads/file.png".
|
|
106
106
|
* @property {number} size - Size of the file in bytes. Example: 1024.
|
|
107
|
+
* @property {string} contentType - MIME type of the uploaded file. Example: "image/png".
|
|
107
108
|
* @description Represents the return value of an uploading operation, including the filename, download link, and file size.
|
|
108
109
|
*/
|
|
109
110
|
interface IUploadingReturn {
|
|
110
111
|
filename: string;
|
|
111
112
|
downloadLink: string;
|
|
112
113
|
size: number;
|
|
114
|
+
contentType: string;
|
|
113
115
|
}
|
|
114
116
|
export type { IFileEntity, IFileUploading, IUploadingQuery, IUploadingReturn };
|
|
@@ -11,6 +11,7 @@ export declare const UploadingReturnSchema: z.ZodObject<{
|
|
|
11
11
|
filename: z.ZodString;
|
|
12
12
|
downloadLink: z.ZodString;
|
|
13
13
|
size: z.ZodNumber;
|
|
14
|
+
contentType: z.ZodString;
|
|
14
15
|
}, z.core.$strip>;
|
|
15
16
|
/**
|
|
16
17
|
* Upload response schema (array of upload results)
|
|
@@ -19,4 +20,5 @@ export declare const UploadResponseSchema: z.ZodArray<z.ZodObject<{
|
|
|
19
20
|
filename: z.ZodString;
|
|
20
21
|
downloadLink: z.ZodString;
|
|
21
22
|
size: z.ZodNumber;
|
|
23
|
+
contentType: z.ZodString;
|
|
22
24
|
}, z.core.$strip>>;
|
|
@@ -253,7 +253,7 @@ interface IPostFormResponse {
|
|
|
253
253
|
* @property {string} formIdentifier - Identifier of the form. Example: "contact_form".
|
|
254
254
|
* @property {string} time - Time of submission. Example: "2023-10-01T12:00:00Z".
|
|
255
255
|
* @property {string} entityIdentifier - Identifier of the entity the form is attached to. Example: "blog".
|
|
256
|
-
* @property {string} fingerprint - Submission fingerprint.
|
|
256
|
+
* @property {string | null} fingerprint - Submission fingerprint, or null for anonymous / app-token submissions.
|
|
257
257
|
* @property {boolean} isUserAdmin - Whether the submitting user is an administrator. Example: false.
|
|
258
258
|
* @property {number} formModuleId - Form module configuration identifier. Example: 2.
|
|
259
259
|
* @property {string | null} userIdentifier - Identifier of the submitting user, or null when anonymous.
|
|
@@ -266,7 +266,7 @@ interface IPostFormResponseData {
|
|
|
266
266
|
formIdentifier: string;
|
|
267
267
|
time: string;
|
|
268
268
|
entityIdentifier: string;
|
|
269
|
-
fingerprint: string;
|
|
269
|
+
fingerprint: string | null;
|
|
270
270
|
isUserAdmin: boolean;
|
|
271
271
|
formModuleId: number;
|
|
272
272
|
userIdentifier: string | null;
|
|
@@ -74,7 +74,7 @@ export declare const PostFormResponseSchema: z.ZodObject<{
|
|
|
74
74
|
formIdentifier: z.ZodString;
|
|
75
75
|
time: z.ZodString;
|
|
76
76
|
entityIdentifier: z.ZodString;
|
|
77
|
-
fingerprint: z.ZodString
|
|
77
|
+
fingerprint: z.ZodNullable<z.ZodString>;
|
|
78
78
|
isUserAdmin: z.ZodBoolean;
|
|
79
79
|
formModuleId: z.ZodNumber;
|
|
80
80
|
userIdentifier: z.ZodNullable<z.ZodString>;
|
|
@@ -58,7 +58,7 @@ exports.PostFormResponseSchema = zod_1.z.object({
|
|
|
58
58
|
formIdentifier: zod_1.z.string(),
|
|
59
59
|
time: zod_1.z.string(),
|
|
60
60
|
entityIdentifier: zod_1.z.string(),
|
|
61
|
-
fingerprint: zod_1.z.string(),
|
|
61
|
+
fingerprint: zod_1.z.string().nullable(),
|
|
62
62
|
isUserAdmin: zod_1.z.boolean(),
|
|
63
63
|
formModuleId: zod_1.z.number(),
|
|
64
64
|
userIdentifier: zod_1.z.string().nullable(),
|
|
@@ -359,16 +359,24 @@ interface IOrderDiscountBonus {
|
|
|
359
359
|
* @property {boolean} allowGiftStacking - Whether multiple gift discounts can be combined. Example: false.
|
|
360
360
|
* @property {boolean} allowStacking - Whether multiple non-gift discounts can be combined. Example: false.
|
|
361
361
|
* @property {number | null} maxDiscountValue - Hard cap on total discount value, or null if uncapped. Example: null.
|
|
362
|
+
* @property {string} [giftRefundPolicy] - Refund policy applied to gift products (present on newer orders). Example: "refund".
|
|
363
|
+
* @property {number | null} [maxBonusPaymentPercent] - Maximum share of the order payable with bonuses, or null if uncapped (present on newer orders).
|
|
364
|
+
* @property {number | null} [minBonusAmount] - Minimum bonus amount required to apply bonuses, or null when not configured (present on newer orders).
|
|
365
|
+
* @property {number | null} [minOrderAmountForBonus] - Minimum order amount required to earn/spend bonuses, or null when not configured (present on newer orders).
|
|
362
366
|
* @description Stacking and cap settings for the order discount engine.
|
|
363
367
|
*/
|
|
364
368
|
interface IOrderDiscountSettings {
|
|
365
369
|
allowGiftStacking: boolean;
|
|
366
370
|
allowStacking: boolean;
|
|
367
371
|
maxDiscountValue: number | null;
|
|
372
|
+
giftRefundPolicy?: string;
|
|
373
|
+
maxBonusPaymentPercent?: number | null;
|
|
374
|
+
minBonusAmount?: number | null;
|
|
375
|
+
minOrderAmountForBonus?: number | null;
|
|
368
376
|
}
|
|
369
377
|
/**
|
|
370
378
|
* @interface IOrderDiscountConfig
|
|
371
|
-
* @property {IOrderDiscountBonus | null} bonus - Bonus calculation result,
|
|
379
|
+
* @property {IOrderDiscountBonus | null} [bonus] - Bonus calculation result, null when bonuses are not used, or omitted entirely when the order has no bonus context.
|
|
372
380
|
* @property {unknown | null} coupon - Resolved coupon, or null when no coupon is applied.
|
|
373
381
|
* @property {unknown[]} orderDiscounts - Order-level discounts that were matched and applied.
|
|
374
382
|
* @property {unknown[]} productDiscounts - Product-level discounts that were matched and applied.
|
|
@@ -382,7 +390,7 @@ interface IOrderDiscountSettings {
|
|
|
382
390
|
* @description Resolved discount configuration returned alongside an order or order preview. Preview responses include only the calculation inputs (bonus, coupon, orderDiscounts, productDiscounts, settings); created/updated orders also carry the totals and applied markers.
|
|
383
391
|
*/
|
|
384
392
|
interface IOrderDiscountConfig {
|
|
385
|
-
bonus
|
|
393
|
+
bonus?: IOrderDiscountBonus | null;
|
|
386
394
|
coupon: unknown | null;
|
|
387
395
|
orderDiscounts: unknown[];
|
|
388
396
|
productDiscounts: unknown[];
|
|
@@ -485,6 +493,36 @@ interface IOrderData {
|
|
|
485
493
|
additionalDiscountsMarkers?: string[];
|
|
486
494
|
bonusAmount?: number;
|
|
487
495
|
}
|
|
496
|
+
/**
|
|
497
|
+
* @interface IOrderSplitStage
|
|
498
|
+
* @property {string} marker - Stage marker. Example: "stage-1".
|
|
499
|
+
* @property {string | null} sessionId - Payment session identifier for the stage, or null when not yet started. Example: null.
|
|
500
|
+
* @property {number} productId - Identifier of the product covered by the stage. Example: 1.
|
|
501
|
+
* @property {string} title - Stage title. Example: "Deposit".
|
|
502
|
+
* @property {number} value - Stage amount. Example: 100.
|
|
503
|
+
* @property {string} status - Stage status. Example: "pending".
|
|
504
|
+
* @description A single stage of a split (staged) order payment.
|
|
505
|
+
*/
|
|
506
|
+
interface IOrderSplitStage {
|
|
507
|
+
marker: string;
|
|
508
|
+
sessionId: string | null;
|
|
509
|
+
productId: number;
|
|
510
|
+
title: string;
|
|
511
|
+
value: number;
|
|
512
|
+
status: string;
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* @interface IOrderSplit
|
|
516
|
+
* @property {boolean} completed - Whether all split stages are completed. Example: false.
|
|
517
|
+
* @property {boolean} partial - Whether the split is partially paid. Example: false.
|
|
518
|
+
* @property {IOrderSplitStage[]} stages - Ordered list of split payment stages.
|
|
519
|
+
* @description Split (staged) payment configuration of an order; returned by the by-id order endpoint.
|
|
520
|
+
*/
|
|
521
|
+
interface IOrderSplit {
|
|
522
|
+
completed: boolean;
|
|
523
|
+
partial: boolean;
|
|
524
|
+
stages: IOrderSplitStage[];
|
|
525
|
+
}
|
|
488
526
|
/**
|
|
489
527
|
* Interface representing an order product data.
|
|
490
528
|
* @interface IOrderByMarkerEntity
|
|
@@ -504,6 +542,7 @@ interface IOrderData {
|
|
|
504
542
|
]
|
|
505
543
|
* @property {string | null} [attributeSetIdentifier] - Text identifier of the attribute set. Example: "attribute-set-1".
|
|
506
544
|
* @property {string} totalSum - Total order amount. Example: "100.00".
|
|
545
|
+
* @property {string} [totalSumRaw] - Raw total order amount with full precision. Example: "100.00".
|
|
507
546
|
* @property {string} currency - Currency used to pay for the order. Example: "USD".
|
|
508
547
|
* @property {string | null} [paymentAccountIdentifier] - Textual identifier for the order payment. Example: "payment-1".
|
|
509
548
|
* @property {ILocalizeInfo} [paymentAccountLocalizeInfos] - Payment account name considering localization.
|
|
@@ -522,7 +561,11 @@ interface IOrderData {
|
|
|
522
561
|
]
|
|
523
562
|
* @property {string | null} paymentUrl - Payment link. Example: "https://example.com/pay/123".
|
|
524
563
|
* @property {boolean | null} isCompleted - Indicates that the order has been completed. Example: true.
|
|
564
|
+
* @property {boolean | null} [isPartial] - Indicates that the order is partially paid; null on older orders where it was not tracked. Example: false.
|
|
565
|
+
* @property {string} [paymentStrategy] - Payment strategy of the order. Example: "once".
|
|
525
566
|
* @property {ILocalizeInfo} [statusLocalizeInfos] - Localized status name.
|
|
567
|
+
* @property {IOrderDiscountConfig | null} [discountConfig] - Resolved discount configuration applied to the order (orderDiscounts, productDiscounts, coupon, settings, bonus, totals); null on older orders without a resolved discount config.
|
|
568
|
+
* @property {IOrderSplit} [split] - Split (staged) payment configuration; present on the by-id order endpoint.
|
|
526
569
|
* @description Represents an order storage object created by the user.
|
|
527
570
|
*/
|
|
528
571
|
interface IOrderByMarkerEntity {
|
|
@@ -534,13 +577,18 @@ interface IOrderByMarkerEntity {
|
|
|
534
577
|
formData: IOrdersFormData[];
|
|
535
578
|
attributeSetIdentifier?: string;
|
|
536
579
|
totalSum: string;
|
|
580
|
+
totalSumRaw?: string;
|
|
537
581
|
currency: string;
|
|
538
582
|
paymentAccountIdentifier?: string;
|
|
539
583
|
paymentAccountLocalizeInfos?: ILocalizeInfo;
|
|
540
584
|
paymentUrl: string | null;
|
|
541
585
|
products: IOrderProducts[];
|
|
542
586
|
isCompleted: boolean | null;
|
|
587
|
+
isPartial?: boolean | null;
|
|
588
|
+
paymentStrategy?: string;
|
|
543
589
|
statusLocalizeInfos?: ILocalizeInfo;
|
|
590
|
+
discountConfig?: IOrderDiscountConfig | null;
|
|
591
|
+
split?: IOrderSplit;
|
|
544
592
|
}
|
|
545
593
|
/**
|
|
546
594
|
* Interface representing an order status object.
|
|
@@ -665,4 +713,4 @@ interface ICreateRefundRequest {
|
|
|
665
713
|
products: Record<string, IRefundProduct>;
|
|
666
714
|
note?: string;
|
|
667
715
|
}
|
|
668
|
-
export type { IBaseOrdersEntity, IBaseOrdersEntityResponse, ICreateOrderPreview, ICreateRefundRequest, IOrderByMarkerEntity, IOrderData, IOrderDiscountBonus, IOrderDiscountConfig, IOrderDiscountSettings, IOrderPreviewItem, IOrderPreviewResponse, IOrderProductData, IOrderProducts, IOrdersApi, IOrdersByMarkerEntity, IOrdersEntity, IOrdersFormData, IOrderStatus, IPaymentAccountIdentifiers, IPicture, IPreviewOrderProduct, IRefundProduct, IRefundRequest, };
|
|
716
|
+
export type { IBaseOrdersEntity, IBaseOrdersEntityResponse, ICreateOrderPreview, ICreateRefundRequest, IOrderByMarkerEntity, IOrderData, IOrderDiscountBonus, IOrderDiscountConfig, IOrderDiscountSettings, IOrderPreviewItem, IOrderPreviewResponse, IOrderProductData, IOrderProducts, IOrdersApi, IOrdersByMarkerEntity, IOrdersEntity, IOrdersFormData, IOrderSplit, IOrderSplitStage, IOrderStatus, IPaymentAccountIdentifiers, IPicture, IPreviewOrderProduct, IRefundProduct, IRefundRequest, };
|
|
@@ -15,6 +15,37 @@ export declare const OrderItemSchema: z.ZodObject<{
|
|
|
15
15
|
total: z.ZodNumber;
|
|
16
16
|
attributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
17
17
|
}, z.core.$strip>;
|
|
18
|
+
/**
|
|
19
|
+
* Order discount config schema
|
|
20
|
+
* @description Resolved discount configuration returned with an order or order preview.
|
|
21
|
+
*/
|
|
22
|
+
export declare const OrderDiscountConfigSchema: z.ZodObject<{
|
|
23
|
+
bonus: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
24
|
+
availableBalance: z.ZodNumber;
|
|
25
|
+
bonusApplied: z.ZodNumber;
|
|
26
|
+
maxBonusDiscount: z.ZodNumber;
|
|
27
|
+
minBonusAmount: z.ZodNullable<z.ZodNumber>;
|
|
28
|
+
minOrderAmountForBonus: z.ZodNullable<z.ZodNumber>;
|
|
29
|
+
}, z.core.$strip>>>;
|
|
30
|
+
coupon: z.ZodNullable<z.ZodUnknown>;
|
|
31
|
+
orderDiscounts: z.ZodArray<z.ZodUnknown>;
|
|
32
|
+
productDiscounts: z.ZodArray<z.ZodUnknown>;
|
|
33
|
+
settings: z.ZodObject<{
|
|
34
|
+
allowGiftStacking: z.ZodBoolean;
|
|
35
|
+
allowStacking: z.ZodBoolean;
|
|
36
|
+
maxDiscountValue: z.ZodNullable<z.ZodNumber>;
|
|
37
|
+
giftRefundPolicy: z.ZodOptional<z.ZodString>;
|
|
38
|
+
maxBonusPaymentPercent: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
39
|
+
minBonusAmount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
40
|
+
minOrderAmountForBonus: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
41
|
+
}, z.core.$strip>;
|
|
42
|
+
additionalDiscountsMarkers: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
43
|
+
bonusApplied: z.ZodOptional<z.ZodNumber>;
|
|
44
|
+
excludedGiftProductIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
45
|
+
totalDue: z.ZodOptional<z.ZodNumber>;
|
|
46
|
+
totalRaw: z.ZodOptional<z.ZodNumber>;
|
|
47
|
+
totalSumWithDiscount: z.ZodOptional<z.ZodNumber>;
|
|
48
|
+
}, z.core.$strip>;
|
|
18
49
|
/**
|
|
19
50
|
* Order entity schema
|
|
20
51
|
* @description Order entity schema for validating orders-related API responses
|
|
@@ -28,13 +59,55 @@ export declare const OrderEntitySchema: z.ZodObject<{
|
|
|
28
59
|
formData: z.ZodUnion<readonly [z.ZodArray<z.ZodAny>, z.ZodRecord<z.ZodString, z.ZodAny>]>;
|
|
29
60
|
attributeSetIdentifier: z.ZodOptional<z.ZodString>;
|
|
30
61
|
totalSum: z.ZodString;
|
|
62
|
+
totalSumRaw: z.ZodOptional<z.ZodString>;
|
|
31
63
|
currency: z.ZodString;
|
|
32
64
|
paymentAccountIdentifier: z.ZodOptional<z.ZodString>;
|
|
33
65
|
paymentAccountLocalizeInfos: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
34
66
|
paymentUrl: z.ZodNullable<z.ZodString>;
|
|
35
67
|
products: z.ZodArray<z.ZodAny>;
|
|
36
68
|
isCompleted: z.ZodNullable<z.ZodBoolean>;
|
|
69
|
+
isPartial: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
70
|
+
paymentStrategy: z.ZodOptional<z.ZodString>;
|
|
37
71
|
statusLocalizeInfos: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
72
|
+
discountConfig: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
73
|
+
bonus: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
74
|
+
availableBalance: z.ZodNumber;
|
|
75
|
+
bonusApplied: z.ZodNumber;
|
|
76
|
+
maxBonusDiscount: z.ZodNumber;
|
|
77
|
+
minBonusAmount: z.ZodNullable<z.ZodNumber>;
|
|
78
|
+
minOrderAmountForBonus: z.ZodNullable<z.ZodNumber>;
|
|
79
|
+
}, z.core.$strip>>>;
|
|
80
|
+
coupon: z.ZodNullable<z.ZodUnknown>;
|
|
81
|
+
orderDiscounts: z.ZodArray<z.ZodUnknown>;
|
|
82
|
+
productDiscounts: z.ZodArray<z.ZodUnknown>;
|
|
83
|
+
settings: z.ZodObject<{
|
|
84
|
+
allowGiftStacking: z.ZodBoolean;
|
|
85
|
+
allowStacking: z.ZodBoolean;
|
|
86
|
+
maxDiscountValue: z.ZodNullable<z.ZodNumber>;
|
|
87
|
+
giftRefundPolicy: z.ZodOptional<z.ZodString>;
|
|
88
|
+
maxBonusPaymentPercent: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
89
|
+
minBonusAmount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
90
|
+
minOrderAmountForBonus: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
91
|
+
}, z.core.$strip>;
|
|
92
|
+
additionalDiscountsMarkers: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
93
|
+
bonusApplied: z.ZodOptional<z.ZodNumber>;
|
|
94
|
+
excludedGiftProductIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
95
|
+
totalDue: z.ZodOptional<z.ZodNumber>;
|
|
96
|
+
totalRaw: z.ZodOptional<z.ZodNumber>;
|
|
97
|
+
totalSumWithDiscount: z.ZodOptional<z.ZodNumber>;
|
|
98
|
+
}, z.core.$strip>>>;
|
|
99
|
+
split: z.ZodOptional<z.ZodObject<{
|
|
100
|
+
completed: z.ZodBoolean;
|
|
101
|
+
partial: z.ZodBoolean;
|
|
102
|
+
stages: z.ZodArray<z.ZodObject<{
|
|
103
|
+
marker: z.ZodString;
|
|
104
|
+
sessionId: z.ZodNullable<z.ZodString>;
|
|
105
|
+
productId: z.ZodNumber;
|
|
106
|
+
title: z.ZodString;
|
|
107
|
+
value: z.ZodNumber;
|
|
108
|
+
status: z.ZodString;
|
|
109
|
+
}, z.core.$strip>>;
|
|
110
|
+
}, z.core.$strip>>;
|
|
38
111
|
}, z.core.$strip>;
|
|
39
112
|
/**
|
|
40
113
|
* Orders list response schema
|
|
@@ -50,13 +123,55 @@ export declare const OrdersResponseSchema: z.ZodObject<{
|
|
|
50
123
|
formData: z.ZodUnion<readonly [z.ZodArray<z.ZodAny>, z.ZodRecord<z.ZodString, z.ZodAny>]>;
|
|
51
124
|
attributeSetIdentifier: z.ZodOptional<z.ZodString>;
|
|
52
125
|
totalSum: z.ZodString;
|
|
126
|
+
totalSumRaw: z.ZodOptional<z.ZodString>;
|
|
53
127
|
currency: z.ZodString;
|
|
54
128
|
paymentAccountIdentifier: z.ZodOptional<z.ZodString>;
|
|
55
129
|
paymentAccountLocalizeInfos: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
56
130
|
paymentUrl: z.ZodNullable<z.ZodString>;
|
|
57
131
|
products: z.ZodArray<z.ZodAny>;
|
|
58
132
|
isCompleted: z.ZodNullable<z.ZodBoolean>;
|
|
133
|
+
isPartial: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
134
|
+
paymentStrategy: z.ZodOptional<z.ZodString>;
|
|
59
135
|
statusLocalizeInfos: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
136
|
+
discountConfig: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
137
|
+
bonus: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
138
|
+
availableBalance: z.ZodNumber;
|
|
139
|
+
bonusApplied: z.ZodNumber;
|
|
140
|
+
maxBonusDiscount: z.ZodNumber;
|
|
141
|
+
minBonusAmount: z.ZodNullable<z.ZodNumber>;
|
|
142
|
+
minOrderAmountForBonus: z.ZodNullable<z.ZodNumber>;
|
|
143
|
+
}, z.core.$strip>>>;
|
|
144
|
+
coupon: z.ZodNullable<z.ZodUnknown>;
|
|
145
|
+
orderDiscounts: z.ZodArray<z.ZodUnknown>;
|
|
146
|
+
productDiscounts: z.ZodArray<z.ZodUnknown>;
|
|
147
|
+
settings: z.ZodObject<{
|
|
148
|
+
allowGiftStacking: z.ZodBoolean;
|
|
149
|
+
allowStacking: z.ZodBoolean;
|
|
150
|
+
maxDiscountValue: z.ZodNullable<z.ZodNumber>;
|
|
151
|
+
giftRefundPolicy: z.ZodOptional<z.ZodString>;
|
|
152
|
+
maxBonusPaymentPercent: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
153
|
+
minBonusAmount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
154
|
+
minOrderAmountForBonus: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
155
|
+
}, z.core.$strip>;
|
|
156
|
+
additionalDiscountsMarkers: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
157
|
+
bonusApplied: z.ZodOptional<z.ZodNumber>;
|
|
158
|
+
excludedGiftProductIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
159
|
+
totalDue: z.ZodOptional<z.ZodNumber>;
|
|
160
|
+
totalRaw: z.ZodOptional<z.ZodNumber>;
|
|
161
|
+
totalSumWithDiscount: z.ZodOptional<z.ZodNumber>;
|
|
162
|
+
}, z.core.$strip>>>;
|
|
163
|
+
split: z.ZodOptional<z.ZodObject<{
|
|
164
|
+
completed: z.ZodBoolean;
|
|
165
|
+
partial: z.ZodBoolean;
|
|
166
|
+
stages: z.ZodArray<z.ZodObject<{
|
|
167
|
+
marker: z.ZodString;
|
|
168
|
+
sessionId: z.ZodNullable<z.ZodString>;
|
|
169
|
+
productId: z.ZodNumber;
|
|
170
|
+
title: z.ZodString;
|
|
171
|
+
value: z.ZodNumber;
|
|
172
|
+
status: z.ZodString;
|
|
173
|
+
}, z.core.$strip>>;
|
|
174
|
+
}, z.core.$strip>>;
|
|
60
175
|
}, z.core.$strip>>;
|
|
61
176
|
total: z.ZodNumber;
|
|
62
177
|
}, z.core.$strip>;
|
|
@@ -90,33 +205,6 @@ export declare const OrdersStorageResponseSchema: z.ZodArray<z.ZodObject<{
|
|
|
90
205
|
}, z.core.$strip>>;
|
|
91
206
|
position: z.ZodNullable<z.ZodNumber>;
|
|
92
207
|
}, z.core.$strip>>;
|
|
93
|
-
/**
|
|
94
|
-
* Order discount config schema
|
|
95
|
-
* @description Resolved discount configuration returned with an order or order preview.
|
|
96
|
-
*/
|
|
97
|
-
export declare const OrderDiscountConfigSchema: z.ZodObject<{
|
|
98
|
-
bonus: z.ZodNullable<z.ZodObject<{
|
|
99
|
-
availableBalance: z.ZodNumber;
|
|
100
|
-
bonusApplied: z.ZodNumber;
|
|
101
|
-
maxBonusDiscount: z.ZodNumber;
|
|
102
|
-
minBonusAmount: z.ZodNullable<z.ZodNumber>;
|
|
103
|
-
minOrderAmountForBonus: z.ZodNullable<z.ZodNumber>;
|
|
104
|
-
}, z.core.$strip>>;
|
|
105
|
-
coupon: z.ZodNullable<z.ZodUnknown>;
|
|
106
|
-
orderDiscounts: z.ZodArray<z.ZodUnknown>;
|
|
107
|
-
productDiscounts: z.ZodArray<z.ZodUnknown>;
|
|
108
|
-
settings: z.ZodObject<{
|
|
109
|
-
allowGiftStacking: z.ZodBoolean;
|
|
110
|
-
allowStacking: z.ZodBoolean;
|
|
111
|
-
maxDiscountValue: z.ZodNullable<z.ZodNumber>;
|
|
112
|
-
}, z.core.$strip>;
|
|
113
|
-
additionalDiscountsMarkers: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
114
|
-
bonusApplied: z.ZodOptional<z.ZodNumber>;
|
|
115
|
-
excludedGiftProductIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
116
|
-
totalDue: z.ZodOptional<z.ZodNumber>;
|
|
117
|
-
totalRaw: z.ZodOptional<z.ZodNumber>;
|
|
118
|
-
totalSumWithDiscount: z.ZodOptional<z.ZodNumber>;
|
|
119
|
-
}, z.core.$strip>;
|
|
120
208
|
/**
|
|
121
209
|
* Create order response schema
|
|
122
210
|
* API returns a simplified order object after creation
|
|
@@ -135,13 +223,13 @@ export declare const CreateOrderResponseSchema: z.ZodObject<{
|
|
|
135
223
|
couponCode: z.ZodOptional<z.ZodString>;
|
|
136
224
|
additionalDiscountsMarkers: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
137
225
|
discountConfig: z.ZodOptional<z.ZodObject<{
|
|
138
|
-
bonus: z.ZodNullable<z.ZodObject<{
|
|
226
|
+
bonus: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
139
227
|
availableBalance: z.ZodNumber;
|
|
140
228
|
bonusApplied: z.ZodNumber;
|
|
141
229
|
maxBonusDiscount: z.ZodNumber;
|
|
142
230
|
minBonusAmount: z.ZodNullable<z.ZodNumber>;
|
|
143
231
|
minOrderAmountForBonus: z.ZodNullable<z.ZodNumber>;
|
|
144
|
-
}, z.core.$strip
|
|
232
|
+
}, z.core.$strip>>>;
|
|
145
233
|
coupon: z.ZodNullable<z.ZodUnknown>;
|
|
146
234
|
orderDiscounts: z.ZodArray<z.ZodUnknown>;
|
|
147
235
|
productDiscounts: z.ZodArray<z.ZodUnknown>;
|
|
@@ -149,6 +237,10 @@ export declare const CreateOrderResponseSchema: z.ZodObject<{
|
|
|
149
237
|
allowGiftStacking: z.ZodBoolean;
|
|
150
238
|
allowStacking: z.ZodBoolean;
|
|
151
239
|
maxDiscountValue: z.ZodNullable<z.ZodNumber>;
|
|
240
|
+
giftRefundPolicy: z.ZodOptional<z.ZodString>;
|
|
241
|
+
maxBonusPaymentPercent: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
242
|
+
minBonusAmount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
243
|
+
minOrderAmountForBonus: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
152
244
|
}, z.core.$strip>;
|
|
153
245
|
additionalDiscountsMarkers: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
154
246
|
bonusApplied: z.ZodOptional<z.ZodNumber>;
|
|
@@ -178,13 +270,13 @@ export declare const UpdateOrderResponseSchema: z.ZodObject<{
|
|
|
178
270
|
couponCode: z.ZodOptional<z.ZodString>;
|
|
179
271
|
additionalDiscountsMarkers: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
180
272
|
discountConfig: z.ZodOptional<z.ZodObject<{
|
|
181
|
-
bonus: z.ZodNullable<z.ZodObject<{
|
|
273
|
+
bonus: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
182
274
|
availableBalance: z.ZodNumber;
|
|
183
275
|
bonusApplied: z.ZodNumber;
|
|
184
276
|
maxBonusDiscount: z.ZodNumber;
|
|
185
277
|
minBonusAmount: z.ZodNullable<z.ZodNumber>;
|
|
186
278
|
minOrderAmountForBonus: z.ZodNullable<z.ZodNumber>;
|
|
187
|
-
}, z.core.$strip
|
|
279
|
+
}, z.core.$strip>>>;
|
|
188
280
|
coupon: z.ZodNullable<z.ZodUnknown>;
|
|
189
281
|
orderDiscounts: z.ZodArray<z.ZodUnknown>;
|
|
190
282
|
productDiscounts: z.ZodArray<z.ZodUnknown>;
|
|
@@ -192,6 +284,10 @@ export declare const UpdateOrderResponseSchema: z.ZodObject<{
|
|
|
192
284
|
allowGiftStacking: z.ZodBoolean;
|
|
193
285
|
allowStacking: z.ZodBoolean;
|
|
194
286
|
maxDiscountValue: z.ZodNullable<z.ZodNumber>;
|
|
287
|
+
giftRefundPolicy: z.ZodOptional<z.ZodString>;
|
|
288
|
+
maxBonusPaymentPercent: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
289
|
+
minBonusAmount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
290
|
+
minOrderAmountForBonus: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
195
291
|
}, z.core.$strip>;
|
|
196
292
|
additionalDiscountsMarkers: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
197
293
|
bonusApplied: z.ZodOptional<z.ZodNumber>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UpdateOrderResponseSchema = exports.CreateOrderResponseSchema = exports.
|
|
3
|
+
exports.UpdateOrderResponseSchema = exports.CreateOrderResponseSchema = exports.OrdersStorageResponseSchema = exports.OrderStorageSchema = exports.OrdersResponseSchema = exports.OrderEntitySchema = exports.OrderDiscountConfigSchema = exports.OrderItemSchema = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Validation schemas for Orders module
|
|
6
6
|
* @description Zod schemas for validating orders-related API responses
|
|
@@ -18,6 +18,40 @@ exports.OrderItemSchema = zod_1.z.object({
|
|
|
18
18
|
total: zod_1.z.number(),
|
|
19
19
|
attributes: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
|
|
20
20
|
});
|
|
21
|
+
/**
|
|
22
|
+
* Order discount config schema
|
|
23
|
+
* @description Resolved discount configuration returned with an order or order preview.
|
|
24
|
+
*/
|
|
25
|
+
exports.OrderDiscountConfigSchema = zod_1.z.object({
|
|
26
|
+
bonus: zod_1.z
|
|
27
|
+
.object({
|
|
28
|
+
availableBalance: zod_1.z.number(),
|
|
29
|
+
bonusApplied: zod_1.z.number(),
|
|
30
|
+
maxBonusDiscount: zod_1.z.number(),
|
|
31
|
+
minBonusAmount: zod_1.z.number().nullable(),
|
|
32
|
+
minOrderAmountForBonus: zod_1.z.number().nullable(),
|
|
33
|
+
})
|
|
34
|
+
.nullable()
|
|
35
|
+
.optional(),
|
|
36
|
+
coupon: zod_1.z.unknown().nullable(),
|
|
37
|
+
orderDiscounts: zod_1.z.array(zod_1.z.unknown()),
|
|
38
|
+
productDiscounts: zod_1.z.array(zod_1.z.unknown()),
|
|
39
|
+
settings: zod_1.z.object({
|
|
40
|
+
allowGiftStacking: zod_1.z.boolean(),
|
|
41
|
+
allowStacking: zod_1.z.boolean(),
|
|
42
|
+
maxDiscountValue: zod_1.z.number().nullable(),
|
|
43
|
+
giftRefundPolicy: zod_1.z.string().optional(),
|
|
44
|
+
maxBonusPaymentPercent: zod_1.z.number().nullable().optional(),
|
|
45
|
+
minBonusAmount: zod_1.z.number().nullable().optional(),
|
|
46
|
+
minOrderAmountForBonus: zod_1.z.number().nullable().optional(),
|
|
47
|
+
}),
|
|
48
|
+
additionalDiscountsMarkers: zod_1.z.array(zod_1.z.string()).optional(),
|
|
49
|
+
bonusApplied: zod_1.z.number().optional(),
|
|
50
|
+
excludedGiftProductIds: zod_1.z.array(zod_1.z.string()).optional(),
|
|
51
|
+
totalDue: zod_1.z.number().optional(),
|
|
52
|
+
totalRaw: zod_1.z.number().optional(),
|
|
53
|
+
totalSumWithDiscount: zod_1.z.number().optional(),
|
|
54
|
+
});
|
|
21
55
|
/**
|
|
22
56
|
* Order entity schema
|
|
23
57
|
* @description Order entity schema for validating orders-related API responses
|
|
@@ -31,13 +65,31 @@ exports.OrderEntitySchema = zod_1.z.object({
|
|
|
31
65
|
formData: zod_1.z.union([zod_1.z.array(zod_1.z.any()), zod_1.z.record(zod_1.z.string(), zod_1.z.any())]),
|
|
32
66
|
attributeSetIdentifier: zod_1.z.string().optional(),
|
|
33
67
|
totalSum: zod_1.z.string(),
|
|
68
|
+
totalSumRaw: zod_1.z.string().optional(),
|
|
34
69
|
currency: zod_1.z.string(),
|
|
35
70
|
paymentAccountIdentifier: zod_1.z.string().optional(),
|
|
36
71
|
paymentAccountLocalizeInfos: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
|
|
37
72
|
paymentUrl: zod_1.z.string().nullable(),
|
|
38
73
|
products: zod_1.z.array(zod_1.z.any()),
|
|
39
74
|
isCompleted: zod_1.z.boolean().nullable(),
|
|
75
|
+
isPartial: zod_1.z.boolean().nullable().optional(),
|
|
76
|
+
paymentStrategy: zod_1.z.string().optional(),
|
|
40
77
|
statusLocalizeInfos: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
|
|
78
|
+
discountConfig: exports.OrderDiscountConfigSchema.nullable().optional(),
|
|
79
|
+
split: zod_1.z
|
|
80
|
+
.object({
|
|
81
|
+
completed: zod_1.z.boolean(),
|
|
82
|
+
partial: zod_1.z.boolean(),
|
|
83
|
+
stages: zod_1.z.array(zod_1.z.object({
|
|
84
|
+
marker: zod_1.z.string(),
|
|
85
|
+
sessionId: zod_1.z.string().nullable(),
|
|
86
|
+
productId: zod_1.z.number(),
|
|
87
|
+
title: zod_1.z.string(),
|
|
88
|
+
value: zod_1.z.number(),
|
|
89
|
+
status: zod_1.z.string(),
|
|
90
|
+
})),
|
|
91
|
+
})
|
|
92
|
+
.optional(),
|
|
41
93
|
});
|
|
42
94
|
/**
|
|
43
95
|
* Orders list response schema
|
|
@@ -65,35 +117,6 @@ exports.OrderStorageSchema = zod_1.z.object({
|
|
|
65
117
|
* @returns Orders storage list response schema
|
|
66
118
|
*/
|
|
67
119
|
exports.OrdersStorageResponseSchema = zod_1.z.array(exports.OrderStorageSchema);
|
|
68
|
-
/**
|
|
69
|
-
* Order discount config schema
|
|
70
|
-
* @description Resolved discount configuration returned with an order or order preview.
|
|
71
|
-
*/
|
|
72
|
-
exports.OrderDiscountConfigSchema = zod_1.z.object({
|
|
73
|
-
bonus: zod_1.z
|
|
74
|
-
.object({
|
|
75
|
-
availableBalance: zod_1.z.number(),
|
|
76
|
-
bonusApplied: zod_1.z.number(),
|
|
77
|
-
maxBonusDiscount: zod_1.z.number(),
|
|
78
|
-
minBonusAmount: zod_1.z.number().nullable(),
|
|
79
|
-
minOrderAmountForBonus: zod_1.z.number().nullable(),
|
|
80
|
-
})
|
|
81
|
-
.nullable(),
|
|
82
|
-
coupon: zod_1.z.unknown().nullable(),
|
|
83
|
-
orderDiscounts: zod_1.z.array(zod_1.z.unknown()),
|
|
84
|
-
productDiscounts: zod_1.z.array(zod_1.z.unknown()),
|
|
85
|
-
settings: zod_1.z.object({
|
|
86
|
-
allowGiftStacking: zod_1.z.boolean(),
|
|
87
|
-
allowStacking: zod_1.z.boolean(),
|
|
88
|
-
maxDiscountValue: zod_1.z.number().nullable(),
|
|
89
|
-
}),
|
|
90
|
-
additionalDiscountsMarkers: zod_1.z.array(zod_1.z.string()).optional(),
|
|
91
|
-
bonusApplied: zod_1.z.number().optional(),
|
|
92
|
-
excludedGiftProductIds: zod_1.z.array(zod_1.z.string()).optional(),
|
|
93
|
-
totalDue: zod_1.z.number().optional(),
|
|
94
|
-
totalRaw: zod_1.z.number().optional(),
|
|
95
|
-
totalSumWithDiscount: zod_1.z.number().optional(),
|
|
96
|
-
});
|
|
97
120
|
/**
|
|
98
121
|
* Create order response schema
|
|
99
122
|
* API returns a simplified order object after creation
|
|
@@ -169,7 +169,7 @@ interface IPositionForm {
|
|
|
169
169
|
* @property {number} version - The version number of the object. Example: 0.
|
|
170
170
|
* @property {number} position - The position of the object. Example: 1.
|
|
171
171
|
* @property {string} identifier - The textual identifier for the record field. Example: "product_block".
|
|
172
|
-
* @property {BlockType} type -
|
|
172
|
+
* @property {BlockType} type - Block type. Example: "product".
|
|
173
173
|
* @property {string | null} templateIdentifier - User id of the linked template. Example: null.
|
|
174
174
|
* @property {boolean} isVisible - A sign of page visibility. Example: true.
|
|
175
175
|
* @property {boolean} isSync - Indication of page indexing. Example: false.
|
|
@@ -202,6 +202,12 @@ interface IPositionBlock {
|
|
|
202
202
|
countElementsPerRow?: number;
|
|
203
203
|
quantity?: number;
|
|
204
204
|
}
|
|
205
|
+
/**
|
|
206
|
+
* PageType
|
|
207
|
+
* @type {PageType}
|
|
208
|
+
* @description This type defines the possible values for page types used in the system. It is a page-specific subset of {@link BlockType}.
|
|
209
|
+
*/
|
|
210
|
+
type PageType = 'catalog_page' | 'common_page' | 'error_page' | 'external_page';
|
|
205
211
|
/**
|
|
206
212
|
* @interface IPagesEntity
|
|
207
213
|
* @property {number} id - The identifier of the object. Example: 8.
|
|
@@ -217,7 +223,7 @@ interface IPositionBlock {
|
|
|
217
223
|
"plainContent": ""
|
|
218
224
|
}
|
|
219
225
|
* @property {boolean} isVisible - A sign of page visibility. Example: true.
|
|
220
|
-
* @property {
|
|
226
|
+
* @property {PageType} type - Page type. Example: "common_page".
|
|
221
227
|
* @property {string | null} templateIdentifier - User id of the linked template. Example: "template".
|
|
222
228
|
* @property {string | null} attributeSetIdentifier - Set of attributes id. Example: "page".
|
|
223
229
|
* @property {IAttributeValues} attributeValues - Map of attribute values keyed by marker; empty object when none.
|
|
@@ -257,7 +263,7 @@ interface IPositionBlock {
|
|
|
257
263
|
* @property {Array<IFormConfig>} [moduleFormConfigs] - Module form configurations linked to the page.
|
|
258
264
|
* @property {IRating} [rating] - Rating data.
|
|
259
265
|
* @property {string} [total] - Total number of products linked to the page. Example: "10".
|
|
260
|
-
* @property {string} [categoryPath] - Category path string. Example: "catalog".
|
|
266
|
+
* @property {string | null} [categoryPath] - Category path string; null for nested pages that have no own category path. Example: "catalog".
|
|
261
267
|
* @description This interface defines the structure of a page entity, including its identifiers, attributes, and hierarchical relationships.
|
|
262
268
|
*/
|
|
263
269
|
interface IPagesEntity {
|
|
@@ -267,7 +273,7 @@ interface IPagesEntity {
|
|
|
267
273
|
depth: number;
|
|
268
274
|
localizeInfos: ILocalizeInfo;
|
|
269
275
|
isVisible: boolean;
|
|
270
|
-
type:
|
|
276
|
+
type: PageType;
|
|
271
277
|
templateIdentifier: string | null;
|
|
272
278
|
attributeSetIdentifier: string | null;
|
|
273
279
|
attributeValues: IAttributeValues;
|
|
@@ -281,6 +287,6 @@ interface IPagesEntity {
|
|
|
281
287
|
products?: number;
|
|
282
288
|
childrenCount?: number;
|
|
283
289
|
total?: string;
|
|
284
|
-
categoryPath?: string;
|
|
290
|
+
categoryPath?: string | null;
|
|
285
291
|
}
|
|
286
|
-
export type { IPageConfig, IPagesApi, IPagesEntity, IPositionBlock, IPositionForm, };
|
|
292
|
+
export type { IPageConfig, IPagesApi, IPagesEntity, IPositionBlock, IPositionForm, PageType, };
|
|
@@ -14,7 +14,12 @@ export declare const PageEntitySchema: z.ZodObject<{
|
|
|
14
14
|
depth: z.ZodNumber;
|
|
15
15
|
localizeInfos: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
16
16
|
isVisible: z.ZodBoolean;
|
|
17
|
-
type: z.
|
|
17
|
+
type: z.ZodEnum<{
|
|
18
|
+
error_page: "error_page";
|
|
19
|
+
catalog_page: "catalog_page";
|
|
20
|
+
common_page: "common_page";
|
|
21
|
+
external_page: "external_page";
|
|
22
|
+
}>;
|
|
18
23
|
templateIdentifier: z.ZodNullable<z.ZodString>;
|
|
19
24
|
attributeSetIdentifier: z.ZodNullable<z.ZodString>;
|
|
20
25
|
attributeValues: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
@@ -28,7 +33,7 @@ export declare const PageEntitySchema: z.ZodObject<{
|
|
|
28
33
|
products: z.ZodOptional<z.ZodNumber>;
|
|
29
34
|
childrenCount: z.ZodOptional<z.ZodNumber>;
|
|
30
35
|
total: z.ZodOptional<z.ZodString>;
|
|
31
|
-
categoryPath: z.ZodOptional<z.ZodString
|
|
36
|
+
categoryPath: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
32
37
|
}, z.core.$strip>;
|
|
33
38
|
/**
|
|
34
39
|
* Pages response schema (array of pages)
|
|
@@ -40,7 +45,12 @@ export declare const PagesResponseSchema: z.ZodArray<z.ZodObject<{
|
|
|
40
45
|
depth: z.ZodNumber;
|
|
41
46
|
localizeInfos: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
42
47
|
isVisible: z.ZodBoolean;
|
|
43
|
-
type: z.
|
|
48
|
+
type: z.ZodEnum<{
|
|
49
|
+
error_page: "error_page";
|
|
50
|
+
catalog_page: "catalog_page";
|
|
51
|
+
common_page: "common_page";
|
|
52
|
+
external_page: "external_page";
|
|
53
|
+
}>;
|
|
44
54
|
templateIdentifier: z.ZodNullable<z.ZodString>;
|
|
45
55
|
attributeSetIdentifier: z.ZodNullable<z.ZodString>;
|
|
46
56
|
attributeValues: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
@@ -54,7 +64,7 @@ export declare const PagesResponseSchema: z.ZodArray<z.ZodObject<{
|
|
|
54
64
|
products: z.ZodOptional<z.ZodNumber>;
|
|
55
65
|
childrenCount: z.ZodOptional<z.ZodNumber>;
|
|
56
66
|
total: z.ZodOptional<z.ZodString>;
|
|
57
|
-
categoryPath: z.ZodOptional<z.ZodString
|
|
67
|
+
categoryPath: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
58
68
|
}, z.core.$strip>>;
|
|
59
69
|
/**
|
|
60
70
|
* Single page response schema
|
|
@@ -66,7 +76,12 @@ export declare const SinglePageSchema: z.ZodObject<{
|
|
|
66
76
|
depth: z.ZodNumber;
|
|
67
77
|
localizeInfos: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
68
78
|
isVisible: z.ZodBoolean;
|
|
69
|
-
type: z.
|
|
79
|
+
type: z.ZodEnum<{
|
|
80
|
+
error_page: "error_page";
|
|
81
|
+
catalog_page: "catalog_page";
|
|
82
|
+
common_page: "common_page";
|
|
83
|
+
external_page: "external_page";
|
|
84
|
+
}>;
|
|
70
85
|
templateIdentifier: z.ZodNullable<z.ZodString>;
|
|
71
86
|
attributeSetIdentifier: z.ZodNullable<z.ZodString>;
|
|
72
87
|
attributeValues: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
@@ -80,7 +95,7 @@ export declare const SinglePageSchema: z.ZodObject<{
|
|
|
80
95
|
products: z.ZodOptional<z.ZodNumber>;
|
|
81
96
|
childrenCount: z.ZodOptional<z.ZodNumber>;
|
|
82
97
|
total: z.ZodOptional<z.ZodString>;
|
|
83
|
-
categoryPath: z.ZodOptional<z.ZodString
|
|
98
|
+
categoryPath: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
84
99
|
}, z.core.$strip>;
|
|
85
100
|
/**
|
|
86
101
|
* Page config schema
|
|
@@ -17,7 +17,8 @@ exports.PageEntitySchema = zod_1.z.object({
|
|
|
17
17
|
depth: zod_1.z.number(),
|
|
18
18
|
localizeInfos: zod_1.z.record(zod_1.z.string(), zod_1.z.any()),
|
|
19
19
|
isVisible: zod_1.z.boolean(),
|
|
20
|
-
|
|
20
|
+
// Must stay in sync with PageType in src/pages/pagesInterfaces.ts
|
|
21
|
+
type: zod_1.z.enum(['catalog_page', 'common_page', 'error_page', 'external_page']),
|
|
21
22
|
templateIdentifier: zod_1.z.string().nullable(),
|
|
22
23
|
attributeSetIdentifier: zod_1.z.string().nullable(),
|
|
23
24
|
attributeValues: zod_1.z.record(zod_1.z.string(), zod_1.z.any()),
|
|
@@ -31,7 +32,7 @@ exports.PageEntitySchema = zod_1.z.object({
|
|
|
31
32
|
products: zod_1.z.number().optional(),
|
|
32
33
|
childrenCount: zod_1.z.number().optional(),
|
|
33
34
|
total: zod_1.z.string().optional(),
|
|
34
|
-
categoryPath: zod_1.z.string().optional(),
|
|
35
|
+
categoryPath: zod_1.z.string().nullable().optional(),
|
|
35
36
|
});
|
|
36
37
|
/**
|
|
37
38
|
* Pages response schema (array of pages)
|
|
@@ -367,10 +367,22 @@ class ProductsApi extends asyncModules_1.default {
|
|
|
367
367
|
async searchProduct(name, langCode = this.state.lang) {
|
|
368
368
|
const searchProducts = await this._fetchGet(`/quick/search?langCode=${langCode}&name=${name}`);
|
|
369
369
|
if (!this.state.traficLimit && Array.isArray(searchProducts)) {
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
const
|
|
373
|
-
|
|
370
|
+
if (searchProducts.length === 0)
|
|
371
|
+
return searchProducts;
|
|
372
|
+
const ids = searchProducts.map((product) => product.id);
|
|
373
|
+
// One /ids request instead of one getProductById per result.
|
|
374
|
+
// limit is set to the number of ids so the default 30 does not truncate.
|
|
375
|
+
const products = await this.getProductsByIds(ids.join(','), langCode, {
|
|
376
|
+
limit: ids.length,
|
|
377
|
+
});
|
|
378
|
+
if (!Array.isArray(products))
|
|
379
|
+
return products;
|
|
380
|
+
// /ids re-sorts by id (DESC) by default, so restore the original
|
|
381
|
+
// search relevance order from the quick search response.
|
|
382
|
+
const byId = new Map(products.map((product) => [product.id, product]));
|
|
383
|
+
return ids
|
|
384
|
+
.map((id) => byId.get(id))
|
|
385
|
+
.filter((product) => product !== undefined);
|
|
374
386
|
}
|
|
375
387
|
return searchProducts;
|
|
376
388
|
}
|
|
@@ -432,12 +432,12 @@ interface IProductPageRef {
|
|
|
432
432
|
* @property {number | null} price - The value of the product page price taken from the index. Example: 150.00.
|
|
433
433
|
* @property {object} additional - Additional value from the index.
|
|
434
434
|
* @example
|
|
435
|
-
|
|
436
|
-
prices: {
|
|
437
|
-
min: 5
|
|
438
|
-
max: 150
|
|
435
|
+
{
|
|
436
|
+
"prices": {
|
|
437
|
+
"min": 5,
|
|
438
|
+
"max": 150
|
|
439
439
|
}
|
|
440
|
-
}
|
|
440
|
+
}
|
|
441
441
|
* @property {string | null} sku - Product SKU (Stock Keeping Unit), may be null. Example: "SKU_12345".
|
|
442
442
|
* @property {boolean} isSync - Indication of page indexing. Example: true.
|
|
443
443
|
* @property {IAttributeValues} attributeValues - Array of attribute values from the index, represented.
|