oneentry 1.0.175 → 1.0.177
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 +12 -5
- package/changelog.md +140 -0
- package/dist/admins/adminsApi.js +2 -9
- package/dist/admins/adminsInterfaces.d.ts +5 -5
- package/dist/admins/adminsSchemas.d.ts +4 -4
- package/dist/admins/adminsSchemas.js +2 -2
- package/dist/attribute-sets/attributeSetsApi.d.ts +1 -1
- package/dist/attribute-sets/attributeSetsApi.js +4 -4
- package/dist/attribute-sets/attributeSetsInterfaces.d.ts +65 -14
- package/dist/attribute-sets/attributeSetsSchemas.d.ts +8 -6
- package/dist/attribute-sets/attributeSetsSchemas.js +6 -9
- package/dist/auth-provider/authProviderApi.d.ts +4 -4
- package/dist/auth-provider/authProviderApi.js +96 -29
- package/dist/auth-provider/authProviderSchemas.d.ts +1 -0
- package/dist/auth-provider/authProviderSchemas.js +1 -0
- package/dist/auth-provider/authProvidersInterfaces.d.ts +8 -6
- package/dist/base/asyncModules.d.ts +73 -1
- package/dist/base/asyncModules.js +233 -37
- package/dist/base/stateModule.d.ts +2 -0
- package/dist/base/stateModule.js +22 -12
- package/dist/base/syncModules.d.ts +18 -10
- package/dist/base/syncModules.js +100 -29
- package/dist/base/utils.d.ts +26 -21
- package/dist/base/validation.d.ts +3 -3
- package/dist/base/validation.js +6 -7
- package/dist/blocks/blocksApi.d.ts +20 -17
- package/dist/blocks/blocksApi.js +101 -74
- package/dist/blocks/blocksInterfaces.d.ts +8 -8
- package/dist/discounts/discountsApi.d.ts +9 -7
- package/dist/discounts/discountsApi.js +18 -14
- package/dist/discounts/discountsInterfaces.d.ts +14 -10
- package/dist/events/eventsApi.d.ts +3 -3
- package/dist/events/eventsApi.js +7 -7
- package/dist/events/eventsInterfaces.d.ts +10 -14
- package/dist/file-uploading/fileUploadingApi.d.ts +4 -4
- package/dist/file-uploading/fileUploadingApi.js +13 -5
- package/dist/file-uploading/fileUploadingInterfaces.d.ts +5 -6
- package/dist/filters/filtersApi.js +2 -2
- package/dist/forms/formsApi.js +2 -2
- package/dist/forms/formsInterfaces.d.ts +1 -3
- package/dist/forms/formsSchemas.d.ts +3 -6
- package/dist/forms/formsSchemas.js +2 -4
- package/dist/forms-data/formsDataApi.d.ts +26 -8
- package/dist/forms-data/formsDataApi.js +45 -14
- package/dist/forms-data/formsDataInterfaces.d.ts +91 -66
- package/dist/general-types/generalTypesInterfaces.d.ts +1 -1
- package/dist/index.d.ts +7 -6
- package/dist/index.js +50 -7
- package/dist/integration-collections/integrationCollectionsApi.d.ts +15 -4
- package/dist/integration-collections/integrationCollectionsApi.js +42 -14
- package/dist/integration-collections/integrationCollectionsInterfaces.d.ts +8 -9
- package/dist/integration-collections/integrationCollectionsSchemas.d.ts +0 -2
- package/dist/integration-collections/integrationCollectionsSchemas.js +0 -1
- package/dist/menus/menusApi.js +1 -1
- package/dist/orders/ordersApi.d.ts +1 -13
- package/dist/orders/ordersApi.js +24 -44
- package/dist/orders/ordersInterfaces.d.ts +21 -14
- package/dist/pages/pagesApi.d.ts +6 -5
- package/dist/pages/pagesApi.js +44 -31
- package/dist/pages/pagesInterfaces.d.ts +18 -15
- package/dist/pages/pagesSchemas.d.ts +0 -3
- package/dist/pages/pagesSchemas.js +0 -1
- package/dist/payments/paymentsApi.d.ts +10 -11
- package/dist/payments/paymentsApi.js +22 -18
- package/dist/payments/paymentsInterfaces.d.ts +12 -14
- package/dist/payments/paymentsSchemas.d.ts +21 -20
- package/dist/payments/paymentsSchemas.js +5 -8
- package/dist/product-statuses/productStatusesApi.d.ts +1 -1
- package/dist/product-statuses/productStatusesApi.js +4 -4
- package/dist/product-statuses/productStatusesInterfaces.d.ts +1 -4
- package/dist/products/productsApi.d.ts +38 -58
- package/dist/products/productsApi.js +59 -72
- package/dist/products/productsInterfaces.d.ts +48 -85
- package/dist/search/searchApi.d.ts +1 -1
- package/dist/search/searchApi.js +4 -3
- package/dist/sitemap/sitemapInterfaces.d.ts +10 -6
- package/dist/subscriptions/subscriptionsApi.d.ts +1 -1
- package/dist/subscriptions/subscriptionsApi.js +1 -1
- package/dist/subscriptions/subscriptionsInterfaces.d.ts +1 -1
- package/dist/system/systemApi.d.ts +2 -0
- package/dist/system/systemApi.js +2 -0
- package/dist/system/systemInterfaces.d.ts +2 -0
- package/dist/templates/templatesApi.d.ts +2 -2
- package/dist/templates/templatesApi.js +12 -11
- package/dist/templates/templatesInterfaces.d.ts +2 -2
- package/dist/templates-preview/templatesPreviewApi.js +2 -2
- package/dist/templates-preview/templatesPreviewInterfaces.d.ts +23 -13
- package/dist/templates-preview/templatesPreviewSchemas.d.ts +7 -0
- package/dist/templates-preview/templatesPreviewSchemas.js +2 -0
- package/dist/user-groups/userGroupsApi.js +5 -5
- package/dist/user-groups/userGroupsSchemas.d.ts +4 -4
- package/dist/users/usersApi.d.ts +1 -1
- package/dist/users/usersApi.js +28 -15
- package/dist/users/usersInterfaces.d.ts +2 -9
- package/dist/web-socket/lazySocket.d.ts +6 -5
- package/dist/web-socket/lazySocket.js +212 -15
- package/dist/web-socket/wsApi.d.ts +7 -4
- package/dist/web-socket/wsApi.js +49 -12
- package/dist/web-socket/wsInterfaces.d.ts +41 -4
- package/esm/admins/adminsApi.js +2 -9
- package/esm/admins/adminsInterfaces.d.ts +5 -5
- package/esm/admins/adminsSchemas.d.ts +4 -4
- package/esm/admins/adminsSchemas.js +2 -2
- package/esm/attribute-sets/attributeSetsApi.d.ts +1 -1
- package/esm/attribute-sets/attributeSetsApi.js +4 -4
- package/esm/attribute-sets/attributeSetsInterfaces.d.ts +65 -14
- package/esm/attribute-sets/attributeSetsSchemas.d.ts +8 -6
- package/esm/attribute-sets/attributeSetsSchemas.js +6 -9
- package/esm/auth-provider/authProviderApi.d.ts +4 -4
- package/esm/auth-provider/authProviderApi.js +96 -29
- package/esm/auth-provider/authProviderSchemas.d.ts +1 -0
- package/esm/auth-provider/authProviderSchemas.js +1 -0
- package/esm/auth-provider/authProvidersInterfaces.d.ts +8 -6
- package/esm/base/asyncModules.d.ts +73 -1
- package/esm/base/asyncModules.js +233 -37
- package/esm/base/stateModule.d.ts +2 -0
- package/esm/base/stateModule.js +22 -12
- package/esm/base/syncModules.d.ts +18 -10
- package/esm/base/syncModules.js +99 -29
- package/esm/base/utils.d.ts +26 -21
- package/esm/base/validation.d.ts +3 -3
- package/esm/base/validation.js +6 -7
- package/esm/blocks/blocksApi.d.ts +20 -17
- package/esm/blocks/blocksApi.js +101 -74
- package/esm/blocks/blocksInterfaces.d.ts +8 -8
- package/esm/discounts/discountsApi.d.ts +9 -7
- package/esm/discounts/discountsApi.js +18 -14
- package/esm/discounts/discountsInterfaces.d.ts +14 -10
- package/esm/events/eventsApi.d.ts +3 -3
- package/esm/events/eventsApi.js +7 -7
- package/esm/events/eventsInterfaces.d.ts +10 -14
- package/esm/file-uploading/fileUploadingApi.d.ts +4 -4
- package/esm/file-uploading/fileUploadingApi.js +13 -5
- package/esm/file-uploading/fileUploadingInterfaces.d.ts +5 -6
- package/esm/filters/filtersApi.js +2 -2
- package/esm/forms/formsApi.js +2 -2
- package/esm/forms/formsInterfaces.d.ts +1 -3
- package/esm/forms/formsSchemas.d.ts +3 -6
- package/esm/forms/formsSchemas.js +2 -4
- package/esm/forms-data/formsDataApi.d.ts +26 -8
- package/esm/forms-data/formsDataApi.js +45 -14
- package/esm/forms-data/formsDataInterfaces.d.ts +91 -66
- package/esm/general-types/generalTypesInterfaces.d.ts +1 -1
- package/esm/index.d.ts +7 -6
- package/esm/index.js +50 -7
- package/esm/integration-collections/integrationCollectionsApi.d.ts +15 -4
- package/esm/integration-collections/integrationCollectionsApi.js +42 -14
- package/esm/integration-collections/integrationCollectionsInterfaces.d.ts +8 -9
- package/esm/integration-collections/integrationCollectionsSchemas.d.ts +0 -2
- package/esm/integration-collections/integrationCollectionsSchemas.js +0 -1
- package/esm/menus/menusApi.js +1 -1
- package/esm/orders/ordersApi.d.ts +1 -13
- package/esm/orders/ordersApi.js +24 -44
- package/esm/orders/ordersInterfaces.d.ts +21 -14
- package/esm/pages/pagesApi.d.ts +6 -5
- package/esm/pages/pagesApi.js +44 -31
- package/esm/pages/pagesInterfaces.d.ts +18 -15
- package/esm/pages/pagesSchemas.d.ts +0 -3
- package/esm/pages/pagesSchemas.js +0 -1
- package/esm/payments/paymentsApi.d.ts +10 -11
- package/esm/payments/paymentsApi.js +22 -18
- package/esm/payments/paymentsInterfaces.d.ts +12 -14
- package/esm/payments/paymentsSchemas.d.ts +21 -20
- package/esm/payments/paymentsSchemas.js +5 -8
- package/esm/product-statuses/productStatusesApi.d.ts +1 -1
- package/esm/product-statuses/productStatusesApi.js +4 -4
- package/esm/product-statuses/productStatusesInterfaces.d.ts +1 -4
- package/esm/products/productsApi.d.ts +38 -58
- package/esm/products/productsApi.js +59 -72
- package/esm/products/productsInterfaces.d.ts +48 -85
- package/esm/search/searchApi.d.ts +1 -1
- package/esm/search/searchApi.js +4 -3
- package/esm/sitemap/sitemapInterfaces.d.ts +10 -6
- package/esm/subscriptions/subscriptionsApi.d.ts +1 -1
- package/esm/subscriptions/subscriptionsApi.js +1 -1
- package/esm/subscriptions/subscriptionsInterfaces.d.ts +1 -1
- package/esm/system/systemApi.d.ts +2 -0
- package/esm/system/systemApi.js +2 -0
- package/esm/system/systemInterfaces.d.ts +2 -0
- package/esm/templates/templatesApi.d.ts +2 -2
- package/esm/templates/templatesApi.js +11 -10
- package/esm/templates/templatesInterfaces.d.ts +2 -2
- package/esm/templates-preview/templatesPreviewApi.js +2 -2
- package/esm/templates-preview/templatesPreviewInterfaces.d.ts +23 -13
- package/esm/templates-preview/templatesPreviewSchemas.d.ts +7 -0
- package/esm/templates-preview/templatesPreviewSchemas.js +2 -0
- package/esm/user-groups/userGroupsApi.js +5 -5
- package/esm/user-groups/userGroupsSchemas.d.ts +4 -4
- package/esm/users/usersApi.d.ts +1 -1
- package/esm/users/usersApi.js +28 -15
- package/esm/users/usersInterfaces.d.ts +2 -9
- package/esm/web-socket/lazySocket.d.ts +6 -5
- package/esm/web-socket/lazySocket.js +212 -15
- package/esm/web-socket/wsApi.d.ts +7 -4
- package/esm/web-socket/wsApi.js +49 -12
- package/esm/web-socket/wsInterfaces.d.ts +41 -4
- package/package.json +2 -2
package/dist/pages/pagesApi.js
CHANGED
|
@@ -68,11 +68,11 @@ class PagesApi extends asyncModules_1.default {
|
|
|
68
68
|
*/
|
|
69
69
|
async getRootPages(langCode = this.state.lang) {
|
|
70
70
|
// Fetch data from the server using a GET request to retrieve root pages for the specified language code
|
|
71
|
-
const data = await this._fetchGet(`/root?langCode=${langCode}`);
|
|
71
|
+
const data = await this._fetchGet(`/root?langCode=${encodeURIComponent(langCode)}`);
|
|
72
72
|
// Validate response if validation is enabled
|
|
73
73
|
const validated = await this._validateResponse(data, schema('PagesResponseSchema'));
|
|
74
74
|
// Add template information to each page in the fetched root pages data
|
|
75
|
-
const withTemplate = await this.addTemplateToPages(validated);
|
|
75
|
+
const withTemplate = await this.addTemplateToPages(validated, langCode);
|
|
76
76
|
// Normalize the data and return it; ensures consistent structure or handles errors
|
|
77
77
|
return this._normalizeData(withTemplate, langCode);
|
|
78
78
|
}
|
|
@@ -87,11 +87,11 @@ class PagesApi extends asyncModules_1.default {
|
|
|
87
87
|
*/
|
|
88
88
|
async getPages(langCode = this.state.lang) {
|
|
89
89
|
// Fetch data from the server using a GET request to retrieve all pages for the specified language code
|
|
90
|
-
const data = await this._fetchGet(`?langCode=${langCode}`);
|
|
90
|
+
const data = await this._fetchGet(`?langCode=${encodeURIComponent(langCode)}`);
|
|
91
91
|
// Validate response if validation is enabled
|
|
92
92
|
const validated = await this._validateResponse(data, schema('PagesResponseSchema'));
|
|
93
93
|
// Add template information to each page in the fetched data
|
|
94
|
-
const withTemplate = await this.addTemplateToPages(validated);
|
|
94
|
+
const withTemplate = await this.addTemplateToPages(validated, langCode);
|
|
95
95
|
// Normalize the data and return it; ensures consistent structure or handles errors
|
|
96
96
|
return this._normalizeData(withTemplate, langCode);
|
|
97
97
|
}
|
|
@@ -107,11 +107,11 @@ class PagesApi extends asyncModules_1.default {
|
|
|
107
107
|
*/
|
|
108
108
|
async getPageById(id, langCode = this.state.lang) {
|
|
109
109
|
// Fetch data from the server using a GET request to retrieve page details by ID and language code
|
|
110
|
-
const data = await this._fetchGet(`/${id}?langCode=${langCode}`);
|
|
110
|
+
const data = await this._fetchGet(`/${this._pathSegment(String(id))}?langCode=${encodeURIComponent(langCode)}`);
|
|
111
111
|
// Validate response if validation is enabled
|
|
112
112
|
const validated = await this._validateResponse(data, schema('PageEntitySchema'));
|
|
113
113
|
// Add template information to the fetched page data
|
|
114
|
-
const withTemplate = await this.addTemplateToPage(validated);
|
|
114
|
+
const withTemplate = await this.addTemplateToPage(validated, langCode);
|
|
115
115
|
// Normalize the data and return it; ensures consistent structure or handles errors
|
|
116
116
|
return this._normalizeData(withTemplate, langCode);
|
|
117
117
|
}
|
|
@@ -127,31 +127,31 @@ class PagesApi extends asyncModules_1.default {
|
|
|
127
127
|
*/
|
|
128
128
|
async getPageByUrl(url, langCode = this.state.lang) {
|
|
129
129
|
// Fetch data from the server using a GET request with the specified URL and language code
|
|
130
|
-
const data = await this._fetchGet(`/url/${url}?langCode=${langCode}`);
|
|
130
|
+
const data = await this._fetchGet(`/url/${this._pathSegments(url)}?langCode=${encodeURIComponent(langCode)}`);
|
|
131
131
|
// Validate response if validation is enabled
|
|
132
132
|
const validated = await this._validateResponse(data, schema('PageEntitySchema'));
|
|
133
133
|
// Add template information to the fetched page data
|
|
134
|
-
const withTemplate = await this.addTemplateToPage(validated);
|
|
134
|
+
const withTemplate = await this.addTemplateToPage(validated, langCode);
|
|
135
135
|
// Normalize the result data and return it; ensures consistent structure or handles errors
|
|
136
136
|
return this._normalizeData(withTemplate, langCode);
|
|
137
137
|
}
|
|
138
138
|
/**
|
|
139
139
|
* Get child pages object with information as an array.
|
|
140
140
|
* @handleName getChildPagesByParentUrl
|
|
141
|
-
* @param {string} url - URL of the parent page whose child pages to fetch
|
|
141
|
+
* @param {string} url - URL of the parent page whose child pages to fetch — the page's own `pageUrl`, not a nested path: `blog/blog1` answers `404`. Example: "blog".
|
|
142
142
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
143
|
-
* @returns {Promise<IPagesEntity | IError>} Returns
|
|
143
|
+
* @returns {Promise<IPagesEntity[] | IError>} Returns an array of PageEntity objects for the selected parent, or an empty array [] when it has no child pages. A parent page that does not exist answers `404 Parent page not found` (IError).
|
|
144
144
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
145
145
|
* @description Get child pages object with information as an array.
|
|
146
146
|
* @see {@link https://js-sdk.oneentry.cloud/docs/pages/getChildPagesByParentUrl getChildPagesByParentUrl} documentation.
|
|
147
147
|
*/
|
|
148
148
|
async getChildPagesByParentUrl(url, langCode = this.state.lang) {
|
|
149
149
|
// Fetch data from the server using a GET request to retrieve child pages for the specified parent URL and language code
|
|
150
|
-
const data = await this._fetchGet(`/${url}/children?langCode=${langCode}`);
|
|
150
|
+
const data = await this._fetchGet(`/${this._pathSegments(url)}/children?langCode=${encodeURIComponent(langCode)}`);
|
|
151
151
|
// Validate response if validation is enabled
|
|
152
152
|
const validated = await this._validateResponse(data, schema('PagesResponseSchema'));
|
|
153
153
|
// Add template information to each of the fetched child pages
|
|
154
|
-
const withTemplate = await this.addTemplateToPages(validated);
|
|
154
|
+
const withTemplate = await this.addTemplateToPages(validated, langCode);
|
|
155
155
|
// Normalize the result data and return it; ensures consistent structure or handles errors
|
|
156
156
|
return this._normalizeData(withTemplate, langCode);
|
|
157
157
|
}
|
|
@@ -166,9 +166,9 @@ class PagesApi extends asyncModules_1.default {
|
|
|
166
166
|
* @see {@link https://js-sdk.oneentry.cloud/docs/pages/getBlocksByPageUrl getBlocksByPageUrl} documentation.
|
|
167
167
|
*/
|
|
168
168
|
async getBlocksByPageUrl(url, langCode = this.state.lang) {
|
|
169
|
-
const response = await this._fetchGet(`/${url}/blocks?langCode=${langCode}`);
|
|
170
|
-
// Normalize the
|
|
171
|
-
const normalizeResponse = this._normalizeData(response);
|
|
169
|
+
const response = await this._fetchGet(`/${this._pathSegments(url)}/blocks?langCode=${encodeURIComponent(langCode)}`);
|
|
170
|
+
// Normalize by the language of the call, not by the client's one
|
|
171
|
+
const normalizeResponse = this._normalizeData(response, langCode);
|
|
172
172
|
if (!Array.isArray(normalizeResponse)) {
|
|
173
173
|
return normalizeResponse;
|
|
174
174
|
}
|
|
@@ -188,22 +188,27 @@ class PagesApi extends asyncModules_1.default {
|
|
|
188
188
|
}
|
|
189
189
|
// Remove internal-only properties from the result.
|
|
190
190
|
delete item.customSettings;
|
|
191
|
-
delete item.attributesSetIdentifier;
|
|
192
191
|
// In traffic-saving mode skip the extra product requests.
|
|
193
192
|
if (this.state.traficLimit)
|
|
194
193
|
return;
|
|
195
194
|
// Attach related products by block type. StaffModule already normalizes its results.
|
|
195
|
+
// A failed sub-request leaves an empty value of the declared type: with isShell the
|
|
196
|
+
// error comes back as a value, and it used to land in `products`/`similarProducts`
|
|
196
197
|
if (item.type === 'similar_products_block') {
|
|
197
198
|
try {
|
|
198
|
-
|
|
199
|
+
const similar = await asyncModules_1.default._subRequestOf(staffModule).getSimilarProducts(item.identifier, langCode);
|
|
200
|
+
item.similarProducts = this._isErrorResponse(similar)
|
|
201
|
+
? { items: [], total: 0 }
|
|
202
|
+
: similar;
|
|
199
203
|
}
|
|
200
204
|
catch {
|
|
201
|
-
item.similarProducts = [];
|
|
205
|
+
item.similarProducts = { items: [], total: 0 };
|
|
202
206
|
}
|
|
203
207
|
}
|
|
204
208
|
else if (item.type === 'product_block') {
|
|
205
209
|
try {
|
|
206
|
-
|
|
210
|
+
const products = await asyncModules_1.default._subRequestOf(staffModule).getProductsByBlockMarker(item.identifier, langCode);
|
|
211
|
+
item.products = this._isErrorResponse(products) ? [] : products;
|
|
207
212
|
}
|
|
208
213
|
catch {
|
|
209
214
|
item.products = [];
|
|
@@ -238,7 +243,7 @@ class PagesApi extends asyncModules_1.default {
|
|
|
238
243
|
// and broke `page.localizeInfos.title` on the caller's side (CMS-1068)
|
|
239
244
|
const pageList = fetched.filter((page) => !this._isErrorResponse(page));
|
|
240
245
|
// Add templates to the fetched pages
|
|
241
|
-
const withTemplate = await this.addTemplateToPages(pageList);
|
|
246
|
+
const withTemplate = await this.addTemplateToPages(pageList, langCode);
|
|
242
247
|
// Normalize the data and return it; ensures consistent structure or handles errors
|
|
243
248
|
return this._normalizeData(withTemplate, langCode);
|
|
244
249
|
}
|
|
@@ -271,6 +276,7 @@ class PagesApi extends asyncModules_1.default {
|
|
|
271
276
|
* Add template data to pages
|
|
272
277
|
* @handleName addTemplateToPages
|
|
273
278
|
* @param {IPagesEntity[]} data - An array of page objects (IPagesEntity[]) to which template data will be added.
|
|
279
|
+
* @param {string} [langCode] - Language the templates are fetched and unwrapped in. Default: the client's language.
|
|
274
280
|
* @example
|
|
275
281
|
[
|
|
276
282
|
{
|
|
@@ -311,7 +317,7 @@ class PagesApi extends asyncModules_1.default {
|
|
|
311
317
|
* @description Add template data to pages. Optimized to avoid N+1 query problem by fetching only unique templates in parallel.
|
|
312
318
|
* For example, if 100 pages use 3 different templates, this method makes 3 requests instead of 100.
|
|
313
319
|
*/
|
|
314
|
-
async addTemplateToPages(data) {
|
|
320
|
+
async addTemplateToPages(data, langCode = this.state.lang) {
|
|
315
321
|
// On API error responses (e.g. 403 without list permission, 422) the value
|
|
316
322
|
// is an IError, not an array — return it as-is instead of calling array
|
|
317
323
|
// methods (.filter/.map) on it and throwing a TypeError.
|
|
@@ -332,7 +338,9 @@ class PagesApi extends asyncModules_1.default {
|
|
|
332
338
|
}
|
|
333
339
|
// Step 3: Fetch unique templates in parallel (not N queries, but unique count queries)
|
|
334
340
|
const Templates = new templatesApi_1.default(this.state);
|
|
335
|
-
const templatePromises = uniqueIdentifiers.map((identifier) =>
|
|
341
|
+
const templatePromises = uniqueIdentifiers.map((identifier) => asyncModules_1.default._subRequestOf(Templates)
|
|
342
|
+
.getTemplateByMarker(identifier, langCode)
|
|
343
|
+
.catch((error) => {
|
|
336
344
|
// eslint-disable-next-line no-undef, no-console
|
|
337
345
|
console.error(`Template fetch error for ${identifier}: `, error);
|
|
338
346
|
return null; // Return null for failed templates
|
|
@@ -341,7 +349,8 @@ class PagesApi extends asyncModules_1.default {
|
|
|
341
349
|
// Step 4: Create a Map for O(1) template lookup
|
|
342
350
|
const templateMap = new Map();
|
|
343
351
|
templates.forEach((template, index) => {
|
|
344
|
-
|
|
352
|
+
// An error comes back as a value with isShell: it is not a template
|
|
353
|
+
if (template !== null && !this._isErrorResponse(template)) {
|
|
345
354
|
templateMap.set(uniqueIdentifiers[index], template);
|
|
346
355
|
}
|
|
347
356
|
});
|
|
@@ -366,12 +375,12 @@ class PagesApi extends asyncModules_1.default {
|
|
|
366
375
|
* Add template data to page by page templateIdentifier
|
|
367
376
|
* @handleName addTemplateToPage
|
|
368
377
|
* @param {IPagesEntity} data - Page object (IPagesEntity) to which template data will be added.
|
|
378
|
+
* @param {string} [langCode] - Language the templates are fetched and unwrapped in. Default: the client's language.
|
|
369
379
|
* @returns {Promise<any | IError>} An array of page objects with template data added
|
|
370
380
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
371
381
|
* @description Add template data to page by page templateIdentifier
|
|
372
|
-
* @see {@link https://js-sdk.oneentry.cloud/docs/pages/addTemplateToPage addTemplateToPage} documentation.
|
|
373
382
|
*/
|
|
374
|
-
async addTemplateToPage(data) {
|
|
383
|
+
async addTemplateToPage(data, langCode = this.state.lang) {
|
|
375
384
|
// Check if 'templateIdentifier' exists in 'data' and is not null or an empty string
|
|
376
385
|
if ('templateIdentifier' in data &&
|
|
377
386
|
data.templateIdentifier !== null &&
|
|
@@ -382,7 +391,11 @@ class PagesApi extends asyncModules_1.default {
|
|
|
382
391
|
// Create a new instance of templatesApi with the current state
|
|
383
392
|
const Templates = new templatesApi_1.default(this.state);
|
|
384
393
|
// Fetch the template using the 'templateIdentifier'
|
|
385
|
-
const result = await Templates.getTemplateByMarker(templateIdentifier);
|
|
394
|
+
const result = await asyncModules_1.default._subRequestOf(Templates).getTemplateByMarker(templateIdentifier, langCode);
|
|
395
|
+
// An error comes back as a value with isShell: leave the page without a template
|
|
396
|
+
if (this._isErrorResponse(result)) {
|
|
397
|
+
return data;
|
|
398
|
+
}
|
|
386
399
|
// Return the original data object with the fetched template added
|
|
387
400
|
return {
|
|
388
401
|
...data,
|
|
@@ -415,18 +428,18 @@ class StaffModule extends asyncModules_1.default {
|
|
|
415
428
|
// ({ total, items }) to match BlocksApi's similarProducts contract.
|
|
416
429
|
async getSimilarProducts(marker, langCode = this.state.lang, offset = 0, limit = 30) {
|
|
417
430
|
// Fetch similar products from the server
|
|
418
|
-
const result = await this._fetchGet(`/${marker}/similar-products?langCode=${langCode}&offset=${offset}&limit=${limit}`);
|
|
419
|
-
return this._normalizeData(result);
|
|
431
|
+
const result = await this._fetchGet(`/${this._pathSegment(marker)}/similar-products?langCode=${encodeURIComponent(langCode)}&offset=${encodeURIComponent(String(offset))}&limit=${encodeURIComponent(String(limit))}`);
|
|
432
|
+
return this._normalizeData(result, langCode);
|
|
420
433
|
}
|
|
421
434
|
// Method to fetch products by block marker
|
|
422
435
|
async getProductsByBlockMarker(marker, langCode = this.state.lang, offset = 0, limit = 30) {
|
|
423
436
|
// Fetch products from the server
|
|
424
|
-
const result = await this._fetchGet(`/${marker}/products?langCode=${langCode}&offset=${offset}&limit=${limit}`);
|
|
437
|
+
const result = await this._fetchGet(`/${this._pathSegment(marker)}/products?langCode=${encodeURIComponent(langCode)}&offset=${encodeURIComponent(String(offset))}&limit=${encodeURIComponent(String(limit))}`);
|
|
425
438
|
// On API error responses there is no `items` array — return the (normalized)
|
|
426
439
|
// error as-is instead of producing `undefined` from `result.items`.
|
|
427
440
|
if (!Array.isArray(result === null || result === void 0 ? void 0 : result.items)) {
|
|
428
|
-
return this._normalizeData(result);
|
|
441
|
+
return this._normalizeData(result, langCode);
|
|
429
442
|
}
|
|
430
|
-
return this._normalizeData(result.items);
|
|
443
|
+
return this._normalizeData(result.items, langCode);
|
|
431
444
|
}
|
|
432
445
|
}
|
|
@@ -49,9 +49,9 @@ interface IPagesApi {
|
|
|
49
49
|
/**
|
|
50
50
|
* Get child pages object with information as an array.
|
|
51
51
|
* @handleName getChildPagesByParentUrl
|
|
52
|
-
* @param {string} url - URL of the parent page whose child pages to fetch
|
|
52
|
+
* @param {string} url - URL of the parent page whose child pages to fetch — the page's own `pageUrl`, not a nested path: `blog/blog1` answers `404`. Example: "blog".
|
|
53
53
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
54
|
-
* @returns {IPagesEntity} Returns
|
|
54
|
+
* @returns {IPagesEntity[]} Returns an array of PageEntity objects for the selected parent, or an empty array [] when it has no child pages. A parent page that does not exist answers `404 Parent page not found` (IError).
|
|
55
55
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
56
56
|
* @description This method gets child pages object with information as an array.
|
|
57
57
|
*/
|
|
@@ -121,7 +121,7 @@ interface IPagesResponse {
|
|
|
121
121
|
* @property {number} version - Version number of the object; changes with each update. Example: 10.
|
|
122
122
|
* @property {string} identifier - Text identifier (marker) of the object. Example: "catalog".
|
|
123
123
|
* @property {number} attributeSetId - ID of the attribute set in use. Example: 0.
|
|
124
|
-
* @property {string} processingType - How form submissions are processed
|
|
124
|
+
* @property {string} processingType - How form submissions are processed: the processing type chosen in the form settings. Example: "script".
|
|
125
125
|
* @property {ILocalizeInfo} localizeInfos - Localized name and content of the page.
|
|
126
126
|
* @example
|
|
127
127
|
{
|
|
@@ -142,22 +142,27 @@ interface IPagesResponse {
|
|
|
142
142
|
"listTitles": [
|
|
143
143
|
{
|
|
144
144
|
"title": "red",
|
|
145
|
-
"value": 1,
|
|
146
|
-
"
|
|
147
|
-
|
|
148
|
-
|
|
145
|
+
"value": "1",
|
|
146
|
+
"extended": {
|
|
147
|
+
"type": null,
|
|
148
|
+
"value": null
|
|
149
|
+
},
|
|
150
|
+
"position": 1
|
|
149
151
|
},
|
|
150
152
|
{
|
|
151
153
|
"title": "yellow",
|
|
152
|
-
"value": 2,
|
|
153
|
-
"
|
|
154
|
-
|
|
155
|
-
|
|
154
|
+
"value": "2",
|
|
155
|
+
"extended": {
|
|
156
|
+
"type": null,
|
|
157
|
+
"value": null
|
|
158
|
+
},
|
|
159
|
+
"position": 2
|
|
156
160
|
}
|
|
157
161
|
],
|
|
158
162
|
"validators": {},
|
|
159
163
|
"localizeInfos": {
|
|
160
|
-
|
|
164
|
+
"title": "l1"
|
|
165
|
+
}
|
|
161
166
|
}
|
|
162
167
|
]
|
|
163
168
|
* @description This interface defines the structure of a position form entity, including its identifiers, attributes, and processing data.
|
|
@@ -188,7 +193,7 @@ interface IPositionForm {
|
|
|
188
193
|
* @property {number} version - Version number of the object; changes with each update. Example: 0.
|
|
189
194
|
* @property {number} position - Position of the object, used for sorting. Example: 1.
|
|
190
195
|
* @property {string} identifier - Text identifier (marker) of the object. Example: "product_block".
|
|
191
|
-
* @property {BlockType} type - Block type. Example: "
|
|
196
|
+
* @property {BlockType} type - Block type. Example: "product_block".
|
|
192
197
|
* @property {string | null} templateIdentifier - Marker of the linked template, or `null` when none is linked. Example: null.
|
|
193
198
|
* @property {boolean} isVisible - Whether the page is visible. Example: true.
|
|
194
199
|
* @property {boolean} isSync - Whether the page is indexed. Example: false.
|
|
@@ -285,7 +290,6 @@ type PageType = 'catalog_page' | 'common_page' | 'error_page' | 'external_page';
|
|
|
285
290
|
}
|
|
286
291
|
* @property {Array<IFormConfig>} [moduleFormConfigs] - Form configurations of the module linked to the page.
|
|
287
292
|
* @property {IRating} [rating] - Rating data: average value, likes and dislikes, and the calculation method.
|
|
288
|
-
* @property {string} [total] - Total number of products linked to the page. Example: "10".
|
|
289
293
|
* @property {string | null} [categoryPath] - Category path; `null` for nested pages that have no category path of their own. Example: "catalog".
|
|
290
294
|
* @property {number} [distance] - Cosine distance to the query. Returned only by the semantic (vector) search endpoint when `debug: true` is passed in the search body. Example: 0.12.
|
|
291
295
|
* @description This interface defines the structure of a page entity, including its identifiers, attributes, and hierarchical relationships.
|
|
@@ -310,7 +314,6 @@ interface IPagesEntity {
|
|
|
310
314
|
config?: Record<string, number>;
|
|
311
315
|
products?: number;
|
|
312
316
|
childrenCount?: number;
|
|
313
|
-
total?: string;
|
|
314
317
|
categoryPath?: string | null;
|
|
315
318
|
distance?: number;
|
|
316
319
|
}
|
|
@@ -32,7 +32,6 @@ export declare const PageEntitySchema: z.ZodObject<{
|
|
|
32
32
|
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
33
33
|
products: z.ZodOptional<z.ZodNumber>;
|
|
34
34
|
childrenCount: z.ZodOptional<z.ZodNumber>;
|
|
35
|
-
total: z.ZodOptional<z.ZodString>;
|
|
36
35
|
categoryPath: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
37
36
|
distance: z.ZodOptional<z.ZodNumber>;
|
|
38
37
|
}, z.core.$strip>;
|
|
@@ -64,7 +63,6 @@ export declare const PagesResponseSchema: z.ZodArray<z.ZodObject<{
|
|
|
64
63
|
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
65
64
|
products: z.ZodOptional<z.ZodNumber>;
|
|
66
65
|
childrenCount: z.ZodOptional<z.ZodNumber>;
|
|
67
|
-
total: z.ZodOptional<z.ZodString>;
|
|
68
66
|
categoryPath: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
69
67
|
distance: z.ZodOptional<z.ZodNumber>;
|
|
70
68
|
}, z.core.$strip>>;
|
|
@@ -111,7 +109,6 @@ export declare const SinglePageSchema: z.ZodObject<{
|
|
|
111
109
|
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
112
110
|
products: z.ZodOptional<z.ZodNumber>;
|
|
113
111
|
childrenCount: z.ZodOptional<z.ZodNumber>;
|
|
114
|
-
total: z.ZodOptional<z.ZodString>;
|
|
115
112
|
categoryPath: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
116
113
|
distance: z.ZodOptional<z.ZodNumber>;
|
|
117
114
|
}, z.core.$strip>;
|
|
@@ -32,7 +32,6 @@ exports.PageEntitySchema = zod_1.z.object({
|
|
|
32
32
|
config: zod_1.z.record(zod_1.z.string(), zod_1.z.number()).optional(),
|
|
33
33
|
products: zod_1.z.number().optional(),
|
|
34
34
|
childrenCount: zod_1.z.number().optional(),
|
|
35
|
-
total: zod_1.z.string().optional(),
|
|
36
35
|
categoryPath: zod_1.z.string().nullable().optional(),
|
|
37
36
|
distance: zod_1.z.number().optional(),
|
|
38
37
|
});
|
|
@@ -43,13 +43,13 @@ export default class PaymentsApi extends AsyncModules implements IPaymentsApi {
|
|
|
43
43
|
* Get one payment session object by order identifier
|
|
44
44
|
* @handleName getSessionByOrderId
|
|
45
45
|
* @param {number} id - Order ID. Example: 12345.
|
|
46
|
-
* @returns {Promise<
|
|
46
|
+
* @returns {Promise<ISessionEntity[] | IError>} Returns the payment sessions of the order — an **array**, `[]` (with `200`) for an order without sessions, an order that does not exist or an order of another user.
|
|
47
47
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
48
|
-
* @description This method gets
|
|
48
|
+
* @description This method gets the payment sessions of an order by its identifier. The answer is an array even for one session. This method requires user authorization.
|
|
49
49
|
* @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
|
|
50
50
|
* @see {@link https://js-sdk.oneentry.cloud/docs/payments/getSessionByOrderId getSessionByOrderId} documentation.
|
|
51
51
|
*/
|
|
52
|
-
getSessionByOrderId(id: number): Promise<ISessionEntity
|
|
52
|
+
getSessionByOrderId(id: number): Promise<ISessionEntity[] | IError>;
|
|
53
53
|
/**
|
|
54
54
|
* Creation of payment session.
|
|
55
55
|
* @handleName createSession
|
|
@@ -66,25 +66,24 @@ export default class PaymentsApi extends AsyncModules implements IPaymentsApi {
|
|
|
66
66
|
/**
|
|
67
67
|
* Get all payment accounts as an array.
|
|
68
68
|
* @handleName getAccounts
|
|
69
|
-
* @
|
|
69
|
+
* @param {string} [langCode] - Language code. Default: the client's language.
|
|
70
|
+
* @returns {Promise<IAccountsEntity[] | IError>} Returns all created payment accounts as an array of PaymentAccountEntity objects.
|
|
70
71
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
71
|
-
* @description This method gets all payment accounts as an array.
|
|
72
|
-
* @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
|
|
72
|
+
* @description This method gets all payment accounts as an array. It does not require user authorization: a guest gets the accounts too.
|
|
73
73
|
* @see {@link https://js-sdk.oneentry.cloud/docs/payments/getAccounts getAccounts} documentation.
|
|
74
74
|
*/
|
|
75
|
-
getAccounts(): Promise<IAccountsEntity[] | IError>;
|
|
75
|
+
getAccounts(langCode?: string): Promise<IAccountsEntity[] | IError>;
|
|
76
76
|
/**
|
|
77
77
|
* Get a single payment account object by its identifier.
|
|
78
78
|
* @handleName getAccountById
|
|
79
79
|
* @param {number} id - Payment account ID. Example: 12345.
|
|
80
|
+
* @param {string} [langCode] - Language code. Default: the client's language.
|
|
80
81
|
* @returns {Promise<IAccountsEntity | IError>} Returns a single payment account object.
|
|
81
82
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
82
|
-
* @description Get a single payment account object by its identifier.
|
|
83
|
-
* @description This method requires user authorization.
|
|
84
|
-
* @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
|
|
83
|
+
* @description Get a single payment account object by its identifier. It does not require user authorization: a guest gets the account too.
|
|
85
84
|
* @see {@link https://js-sdk.oneentry.cloud/docs/payments/getAccountById getAccountById} documentation.
|
|
86
85
|
*/
|
|
87
|
-
getAccountById(id: number): Promise<IAccountsEntity | IError>;
|
|
86
|
+
getAccountById(id: number, langCode?: string): Promise<IAccountsEntity | IError>;
|
|
88
87
|
/**
|
|
89
88
|
* Get the payment progress of an order: its stages and whether they are paid.
|
|
90
89
|
* @handleName getPaymentStagesByOrderId
|
|
@@ -86,21 +86,23 @@ class PaymentsApi extends asyncModules_1.default {
|
|
|
86
86
|
* @see {@link https://js-sdk.oneentry.cloud/docs/payments/getSessionById getSessionById} documentation.
|
|
87
87
|
*/
|
|
88
88
|
async getSessionById(id) {
|
|
89
|
-
const result = await this._fetchGet(`/sessions/${id}`);
|
|
90
|
-
|
|
89
|
+
const result = await this._fetchGet(`/sessions/${this._pathSegment(String(id))}`);
|
|
90
|
+
// Validate response if validation is enabled
|
|
91
|
+
const validated = await this._validateResponse(result, schema('PaymentSessionSchema'));
|
|
92
|
+
return validated;
|
|
91
93
|
}
|
|
92
94
|
/**
|
|
93
95
|
* Get one payment session object by order identifier
|
|
94
96
|
* @handleName getSessionByOrderId
|
|
95
97
|
* @param {number} id - Order ID. Example: 12345.
|
|
96
|
-
* @returns {Promise<
|
|
98
|
+
* @returns {Promise<ISessionEntity[] | IError>} Returns the payment sessions of the order — an **array**, `[]` (with `200`) for an order without sessions, an order that does not exist or an order of another user.
|
|
97
99
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
98
|
-
* @description This method gets
|
|
100
|
+
* @description This method gets the payment sessions of an order by its identifier. The answer is an array even for one session. This method requires user authorization.
|
|
99
101
|
* @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
|
|
100
102
|
* @see {@link https://js-sdk.oneentry.cloud/docs/payments/getSessionByOrderId getSessionByOrderId} documentation.
|
|
101
103
|
*/
|
|
102
104
|
async getSessionByOrderId(id) {
|
|
103
|
-
const result = await this._fetchGet(`/sessions/order/${id}`);
|
|
105
|
+
const result = await this._fetchGet(`/sessions/order/${this._pathSegment(String(id))}`);
|
|
104
106
|
// Validate response if validation is enabled
|
|
105
107
|
const validated = await this._validateResponse(result, schema('SinglePaymentSessionSchema'));
|
|
106
108
|
return validated;
|
|
@@ -130,32 +132,34 @@ class PaymentsApi extends asyncModules_1.default {
|
|
|
130
132
|
/**
|
|
131
133
|
* Get all payment accounts as an array.
|
|
132
134
|
* @handleName getAccounts
|
|
133
|
-
* @
|
|
135
|
+
* @param {string} [langCode] - Language code. Default: the client's language.
|
|
136
|
+
* @returns {Promise<IAccountsEntity[] | IError>} Returns all created payment accounts as an array of PaymentAccountEntity objects.
|
|
134
137
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
135
|
-
* @description This method gets all payment accounts as an array.
|
|
136
|
-
* @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
|
|
138
|
+
* @description This method gets all payment accounts as an array. It does not require user authorization: a guest gets the accounts too.
|
|
137
139
|
* @see {@link https://js-sdk.oneentry.cloud/docs/payments/getAccounts getAccounts} documentation.
|
|
138
140
|
*/
|
|
139
|
-
async getAccounts() {
|
|
140
|
-
const result = await this._fetchGet('/accounts');
|
|
141
|
+
async getAccounts(langCode = this.state.lang) {
|
|
142
|
+
const result = await this._fetchGet('/accounts?' + this._queryParamsToString({ langCode }));
|
|
141
143
|
// Validate response if validation is enabled
|
|
142
144
|
const validated = await this._validateResponse(result, schema('PaymentAccountsResponseSchema'));
|
|
143
|
-
return this._normalizeData(validated);
|
|
145
|
+
return this._normalizeData(validated, langCode);
|
|
144
146
|
}
|
|
145
147
|
/**
|
|
146
148
|
* Get a single payment account object by its identifier.
|
|
147
149
|
* @handleName getAccountById
|
|
148
150
|
* @param {number} id - Payment account ID. Example: 12345.
|
|
151
|
+
* @param {string} [langCode] - Language code. Default: the client's language.
|
|
149
152
|
* @returns {Promise<IAccountsEntity | IError>} Returns a single payment account object.
|
|
150
153
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
151
|
-
* @description Get a single payment account object by its identifier.
|
|
152
|
-
* @description This method requires user authorization.
|
|
153
|
-
* @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
|
|
154
|
+
* @description Get a single payment account object by its identifier. It does not require user authorization: a guest gets the account too.
|
|
154
155
|
* @see {@link https://js-sdk.oneentry.cloud/docs/payments/getAccountById getAccountById} documentation.
|
|
155
156
|
*/
|
|
156
|
-
async getAccountById(id) {
|
|
157
|
-
const result = await this._fetchGet(`/accounts/${id}
|
|
158
|
-
|
|
157
|
+
async getAccountById(id, langCode = this.state.lang) {
|
|
158
|
+
const result = await this._fetchGet(`/accounts/${this._pathSegment(String(id))}?` +
|
|
159
|
+
this._queryParamsToString({ langCode }));
|
|
160
|
+
// Validate response if validation is enabled
|
|
161
|
+
const validated = await this._validateResponse(result, schema('PaymentAccountSchema'));
|
|
162
|
+
return this._normalizeData(validated, langCode);
|
|
159
163
|
}
|
|
160
164
|
/**
|
|
161
165
|
* Get the payment progress of an order: its stages and whether they are paid.
|
|
@@ -170,7 +174,7 @@ class PaymentsApi extends asyncModules_1.default {
|
|
|
170
174
|
* @see {@link https://js-sdk.oneentry.cloud/docs/payments/getPaymentStagesByOrderId getPaymentStagesByOrderId} documentation.
|
|
171
175
|
*/
|
|
172
176
|
async getPaymentStagesByOrderId(id) {
|
|
173
|
-
const result = await this._fetchGet(`/stages/order/${id}`);
|
|
177
|
+
const result = await this._fetchGet(`/stages/order/${this._pathSegment(String(id))}`);
|
|
174
178
|
// Validate response if validation is enabled
|
|
175
179
|
const validated = await this._validateResponse(result, schema('PaymentProgressSchema'));
|
|
176
180
|
return this._normalizeData(validated);
|
|
@@ -29,12 +29,12 @@ interface IPaymentsApi {
|
|
|
29
29
|
* Get one payment session object by order identifier 🔐
|
|
30
30
|
* @handleName getSessionByOrderId
|
|
31
31
|
* @param {number} id - Order ID. Example: 12345.
|
|
32
|
-
* @returns {ISessionEntity}
|
|
32
|
+
* @returns {ISessionEntity[]} The payment sessions of the order — an **array**, `[]` (with `200`) for an order without sessions or one that does not exist.
|
|
33
33
|
* @throws {IError} If there is an error during the fetch operation, it will return an error object.
|
|
34
|
-
* @description This method gets
|
|
34
|
+
* @description This method gets the payment sessions of an order by its identifier. The answer is an array even for one session. This method requires user authorization.
|
|
35
35
|
* @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
|
|
36
36
|
*/
|
|
37
|
-
getSessionByOrderId(id: number): Promise<ISessionEntity
|
|
37
|
+
getSessionByOrderId(id: number): Promise<ISessionEntity[] | IError>;
|
|
38
38
|
/**
|
|
39
39
|
* Creation of payment session.
|
|
40
40
|
* @handleName createSession
|
|
@@ -50,22 +50,22 @@ interface IPaymentsApi {
|
|
|
50
50
|
/**
|
|
51
51
|
* Get all payment accounts as an array.
|
|
52
52
|
* @handleName getAccounts
|
|
53
|
-
* @
|
|
53
|
+
* @param {string} [langCode] - Language code. Default: the client's language.
|
|
54
|
+
* @returns {IAccountsEntity[]} Returns all created payment accounts as an array of PaymentAccountEntity objects.
|
|
54
55
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
55
|
-
* @description This method gets all payment accounts as an array.
|
|
56
|
-
* @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
|
|
56
|
+
* @description This method gets all payment accounts as an array. It does not require user authorization: a guest gets the accounts too.
|
|
57
57
|
*/
|
|
58
|
-
getAccounts(): Promise<IAccountsEntity[] | IError>;
|
|
58
|
+
getAccounts(langCode?: string): Promise<IAccountsEntity[] | IError>;
|
|
59
59
|
/**
|
|
60
60
|
* Get a single payment account object by its identifier.
|
|
61
61
|
* @handleName getAccountById
|
|
62
62
|
* @param {number} id - Payment account ID. Example: 12345.
|
|
63
|
+
* @param {string} [langCode] - Language code. Default: the client's language.
|
|
63
64
|
* @returns {IAccountsEntity} Returns a single payment account object.
|
|
64
65
|
* @throws {IError} - If there is an error during the fetch operation, it will return an error object.
|
|
65
|
-
* @description This method gets a single payment account object by its identifier.
|
|
66
|
-
* @see For more information about configuring the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider authorization module}, see the documentation in the {@link https://js-sdk.oneentry.cloud/docs/category/authprovider configuration settings section of the SDK}.
|
|
66
|
+
* @description This method gets a single payment account object by its identifier. It does not require user authorization: a guest gets the account too.
|
|
67
67
|
*/
|
|
68
|
-
getAccountById(id: number): Promise<IAccountsEntity | IError>;
|
|
68
|
+
getAccountById(id: number, langCode?: string): Promise<IAccountsEntity | IError>;
|
|
69
69
|
/**
|
|
70
70
|
* Get the payment progress of an order: its stages and whether they are paid.
|
|
71
71
|
* @handleName getPaymentStagesByOrderId
|
|
@@ -108,7 +108,7 @@ interface ISessionsEntity {
|
|
|
108
108
|
* @property {'session' | 'intent'} type - Session type: "session" or "intent". Example: "session".
|
|
109
109
|
* @property {string} status - Payment status. Example: "completed".
|
|
110
110
|
* @property {number} paymentAccountId - ID of the payment account. Example: 1.
|
|
111
|
-
* @property {number} orderId - ID of the order. Example: 1.
|
|
111
|
+
* @property {number | null} orderId - ID of the order; `null` for the session of a subscription, which has no order. Example: 1.
|
|
112
112
|
* @property {string | null} paymentUrl - Payment page URL. Example: " https://www.sandbox.paypal.com/checkoutnow?token=9BE88048TU058770M".
|
|
113
113
|
* @property {number | null} [amount] - Payment session amount. Example: 100.
|
|
114
114
|
* @property {string} [clientSecret] - Client secret returned by the payment provider (for example, Stripe) when the session is created. Example: "pi_3MtwBwLkdIwHu7ix28a3tqPa_secret_YrKJUKribcBjcG8HVhfZluoGH".
|
|
@@ -121,7 +121,7 @@ interface ISessionEntity {
|
|
|
121
121
|
type: 'session' | 'intent';
|
|
122
122
|
status: string;
|
|
123
123
|
paymentAccountId: number;
|
|
124
|
-
orderId: number;
|
|
124
|
+
orderId: number | null;
|
|
125
125
|
paymentUrl: string | null;
|
|
126
126
|
amount?: number | null;
|
|
127
127
|
clientSecret?: string;
|
|
@@ -180,7 +180,6 @@ interface IPaymentAccountSettings {
|
|
|
180
180
|
* @property {string} [stripeRedirectUrl] - Stripe onboarding redirect URL.
|
|
181
181
|
* @property {boolean} [stripeOnboardingComplete] - Whether Stripe onboarding finished. Example: true.
|
|
182
182
|
* @property {string} [stripePublishableKey] - Stripe publishable key.
|
|
183
|
-
* @property {string} [signingSecretKey] - Stripe webhook signing secret. Example: "whsec_...".
|
|
184
183
|
* @property {boolean} [useWebHookValidation] - Whether incoming webhooks must be signature-validated. Example: true.
|
|
185
184
|
* @description Test-mode configuration of a payment account; field set depends on the provider (Stripe-specific fields are optional).
|
|
186
185
|
*/
|
|
@@ -193,7 +192,6 @@ interface IPaymentAccountTestSettings {
|
|
|
193
192
|
stripeRedirectUrl?: string;
|
|
194
193
|
stripeOnboardingComplete?: boolean;
|
|
195
194
|
stripePublishableKey?: string;
|
|
196
|
-
signingSecretKey?: string;
|
|
197
195
|
useWebHookValidation?: boolean;
|
|
198
196
|
}
|
|
199
197
|
/**
|