oneentry 1.0.176 → 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 +116 -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 +90 -23
- 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 +62 -1
- package/dist/base/asyncModules.js +219 -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 +82 -64
- package/dist/blocks/blocksInterfaces.d.ts +8 -8
- package/dist/discounts/discountsApi.d.ts +9 -7
- package/dist/discounts/discountsApi.js +16 -13
- package/dist/discounts/discountsInterfaces.d.ts +14 -10
- package/dist/events/eventsApi.d.ts +3 -3
- package/dist/events/eventsApi.js +3 -3
- 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 +16 -0
- package/dist/forms-data/formsDataApi.js +32 -5
- package/dist/forms-data/formsDataInterfaces.d.ts +17 -13
- 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 +41 -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 +21 -42
- 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 +3 -3
- 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 +90 -23
- 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 +62 -1
- package/esm/base/asyncModules.js +219 -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 +82 -64
- package/esm/blocks/blocksInterfaces.d.ts +8 -8
- package/esm/discounts/discountsApi.d.ts +9 -7
- package/esm/discounts/discountsApi.js +16 -13
- package/esm/discounts/discountsInterfaces.d.ts +14 -10
- package/esm/events/eventsApi.d.ts +3 -3
- package/esm/events/eventsApi.js +3 -3
- 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 +16 -0
- package/esm/forms-data/formsDataApi.js +32 -5
- package/esm/forms-data/formsDataInterfaces.d.ts +17 -13
- 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 +41 -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 +21 -42
- 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 +3 -3
- 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/esm/pages/pagesApi.js
CHANGED
|
@@ -30,11 +30,11 @@ export default class PagesApi extends AsyncModules {
|
|
|
30
30
|
*/
|
|
31
31
|
async getRootPages(langCode = this.state.lang) {
|
|
32
32
|
// Fetch data from the server using a GET request to retrieve root pages for the specified language code
|
|
33
|
-
const data = await this._fetchGet(`/root?langCode=${langCode}`);
|
|
33
|
+
const data = await this._fetchGet(`/root?langCode=${encodeURIComponent(langCode)}`);
|
|
34
34
|
// Validate response if validation is enabled
|
|
35
35
|
const validated = await this._validateResponse(data, schema('PagesResponseSchema'));
|
|
36
36
|
// Add template information to each page in the fetched root pages data
|
|
37
|
-
const withTemplate = await this.addTemplateToPages(validated);
|
|
37
|
+
const withTemplate = await this.addTemplateToPages(validated, langCode);
|
|
38
38
|
// Normalize the data and return it; ensures consistent structure or handles errors
|
|
39
39
|
return this._normalizeData(withTemplate, langCode);
|
|
40
40
|
}
|
|
@@ -49,11 +49,11 @@ export default class PagesApi extends AsyncModules {
|
|
|
49
49
|
*/
|
|
50
50
|
async getPages(langCode = this.state.lang) {
|
|
51
51
|
// Fetch data from the server using a GET request to retrieve all pages for the specified language code
|
|
52
|
-
const data = await this._fetchGet(`?langCode=${langCode}`);
|
|
52
|
+
const data = await this._fetchGet(`?langCode=${encodeURIComponent(langCode)}`);
|
|
53
53
|
// Validate response if validation is enabled
|
|
54
54
|
const validated = await this._validateResponse(data, schema('PagesResponseSchema'));
|
|
55
55
|
// Add template information to each page in the fetched data
|
|
56
|
-
const withTemplate = await this.addTemplateToPages(validated);
|
|
56
|
+
const withTemplate = await this.addTemplateToPages(validated, langCode);
|
|
57
57
|
// Normalize the data and return it; ensures consistent structure or handles errors
|
|
58
58
|
return this._normalizeData(withTemplate, langCode);
|
|
59
59
|
}
|
|
@@ -69,11 +69,11 @@ export default class PagesApi extends AsyncModules {
|
|
|
69
69
|
*/
|
|
70
70
|
async getPageById(id, langCode = this.state.lang) {
|
|
71
71
|
// Fetch data from the server using a GET request to retrieve page details by ID and language code
|
|
72
|
-
const data = await this._fetchGet(`/${id}?langCode=${langCode}`);
|
|
72
|
+
const data = await this._fetchGet(`/${this._pathSegment(String(id))}?langCode=${encodeURIComponent(langCode)}`);
|
|
73
73
|
// Validate response if validation is enabled
|
|
74
74
|
const validated = await this._validateResponse(data, schema('PageEntitySchema'));
|
|
75
75
|
// Add template information to the fetched page data
|
|
76
|
-
const withTemplate = await this.addTemplateToPage(validated);
|
|
76
|
+
const withTemplate = await this.addTemplateToPage(validated, langCode);
|
|
77
77
|
// Normalize the data and return it; ensures consistent structure or handles errors
|
|
78
78
|
return this._normalizeData(withTemplate, langCode);
|
|
79
79
|
}
|
|
@@ -89,31 +89,31 @@ export default class PagesApi extends AsyncModules {
|
|
|
89
89
|
*/
|
|
90
90
|
async getPageByUrl(url, langCode = this.state.lang) {
|
|
91
91
|
// Fetch data from the server using a GET request with the specified URL and language code
|
|
92
|
-
const data = await this._fetchGet(`/url/${url}?langCode=${langCode}`);
|
|
92
|
+
const data = await this._fetchGet(`/url/${this._pathSegments(url)}?langCode=${encodeURIComponent(langCode)}`);
|
|
93
93
|
// Validate response if validation is enabled
|
|
94
94
|
const validated = await this._validateResponse(data, schema('PageEntitySchema'));
|
|
95
95
|
// Add template information to the fetched page data
|
|
96
|
-
const withTemplate = await this.addTemplateToPage(validated);
|
|
96
|
+
const withTemplate = await this.addTemplateToPage(validated, langCode);
|
|
97
97
|
// Normalize the result data and return it; ensures consistent structure or handles errors
|
|
98
98
|
return this._normalizeData(withTemplate, langCode);
|
|
99
99
|
}
|
|
100
100
|
/**
|
|
101
101
|
* Get child pages object with information as an array.
|
|
102
102
|
* @handleName getChildPagesByParentUrl
|
|
103
|
-
* @param {string} url - URL of the parent page whose child pages to fetch
|
|
103
|
+
* @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".
|
|
104
104
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
105
|
-
* @returns {Promise<IPagesEntity | IError>} Returns
|
|
105
|
+
* @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).
|
|
106
106
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
107
107
|
* @description Get child pages object with information as an array.
|
|
108
108
|
* @see {@link https://js-sdk.oneentry.cloud/docs/pages/getChildPagesByParentUrl getChildPagesByParentUrl} documentation.
|
|
109
109
|
*/
|
|
110
110
|
async getChildPagesByParentUrl(url, langCode = this.state.lang) {
|
|
111
111
|
// Fetch data from the server using a GET request to retrieve child pages for the specified parent URL and language code
|
|
112
|
-
const data = await this._fetchGet(`/${url}/children?langCode=${langCode}`);
|
|
112
|
+
const data = await this._fetchGet(`/${this._pathSegments(url)}/children?langCode=${encodeURIComponent(langCode)}`);
|
|
113
113
|
// Validate response if validation is enabled
|
|
114
114
|
const validated = await this._validateResponse(data, schema('PagesResponseSchema'));
|
|
115
115
|
// Add template information to each of the fetched child pages
|
|
116
|
-
const withTemplate = await this.addTemplateToPages(validated);
|
|
116
|
+
const withTemplate = await this.addTemplateToPages(validated, langCode);
|
|
117
117
|
// Normalize the result data and return it; ensures consistent structure or handles errors
|
|
118
118
|
return this._normalizeData(withTemplate, langCode);
|
|
119
119
|
}
|
|
@@ -128,9 +128,9 @@ export default class PagesApi extends AsyncModules {
|
|
|
128
128
|
* @see {@link https://js-sdk.oneentry.cloud/docs/pages/getBlocksByPageUrl getBlocksByPageUrl} documentation.
|
|
129
129
|
*/
|
|
130
130
|
async getBlocksByPageUrl(url, langCode = this.state.lang) {
|
|
131
|
-
const response = await this._fetchGet(`/${url}/blocks?langCode=${langCode}`);
|
|
132
|
-
// Normalize the
|
|
133
|
-
const normalizeResponse = this._normalizeData(response);
|
|
131
|
+
const response = await this._fetchGet(`/${this._pathSegments(url)}/blocks?langCode=${encodeURIComponent(langCode)}`);
|
|
132
|
+
// Normalize by the language of the call, not by the client's one
|
|
133
|
+
const normalizeResponse = this._normalizeData(response, langCode);
|
|
134
134
|
if (!Array.isArray(normalizeResponse)) {
|
|
135
135
|
return normalizeResponse;
|
|
136
136
|
}
|
|
@@ -150,22 +150,27 @@ export default class PagesApi extends AsyncModules {
|
|
|
150
150
|
}
|
|
151
151
|
// Remove internal-only properties from the result.
|
|
152
152
|
delete item.customSettings;
|
|
153
|
-
delete item.attributesSetIdentifier;
|
|
154
153
|
// In traffic-saving mode skip the extra product requests.
|
|
155
154
|
if (this.state.traficLimit)
|
|
156
155
|
return;
|
|
157
156
|
// Attach related products by block type. StaffModule already normalizes its results.
|
|
157
|
+
// A failed sub-request leaves an empty value of the declared type: with isShell the
|
|
158
|
+
// error comes back as a value, and it used to land in `products`/`similarProducts`
|
|
158
159
|
if (item.type === 'similar_products_block') {
|
|
159
160
|
try {
|
|
160
|
-
|
|
161
|
+
const similar = await AsyncModules._subRequestOf(staffModule).getSimilarProducts(item.identifier, langCode);
|
|
162
|
+
item.similarProducts = this._isErrorResponse(similar)
|
|
163
|
+
? { items: [], total: 0 }
|
|
164
|
+
: similar;
|
|
161
165
|
}
|
|
162
166
|
catch {
|
|
163
|
-
item.similarProducts = [];
|
|
167
|
+
item.similarProducts = { items: [], total: 0 };
|
|
164
168
|
}
|
|
165
169
|
}
|
|
166
170
|
else if (item.type === 'product_block') {
|
|
167
171
|
try {
|
|
168
|
-
|
|
172
|
+
const products = await AsyncModules._subRequestOf(staffModule).getProductsByBlockMarker(item.identifier, langCode);
|
|
173
|
+
item.products = this._isErrorResponse(products) ? [] : products;
|
|
169
174
|
}
|
|
170
175
|
catch {
|
|
171
176
|
item.products = [];
|
|
@@ -200,7 +205,7 @@ export default class PagesApi extends AsyncModules {
|
|
|
200
205
|
// and broke `page.localizeInfos.title` on the caller's side (CMS-1068)
|
|
201
206
|
const pageList = fetched.filter((page) => !this._isErrorResponse(page));
|
|
202
207
|
// Add templates to the fetched pages
|
|
203
|
-
const withTemplate = await this.addTemplateToPages(pageList);
|
|
208
|
+
const withTemplate = await this.addTemplateToPages(pageList, langCode);
|
|
204
209
|
// Normalize the data and return it; ensures consistent structure or handles errors
|
|
205
210
|
return this._normalizeData(withTemplate, langCode);
|
|
206
211
|
}
|
|
@@ -233,6 +238,7 @@ export default class PagesApi extends AsyncModules {
|
|
|
233
238
|
* Add template data to pages
|
|
234
239
|
* @handleName addTemplateToPages
|
|
235
240
|
* @param {IPagesEntity[]} data - An array of page objects (IPagesEntity[]) to which template data will be added.
|
|
241
|
+
* @param {string} [langCode] - Language the templates are fetched and unwrapped in. Default: the client's language.
|
|
236
242
|
* @example
|
|
237
243
|
[
|
|
238
244
|
{
|
|
@@ -273,7 +279,7 @@ export default class PagesApi extends AsyncModules {
|
|
|
273
279
|
* @description Add template data to pages. Optimized to avoid N+1 query problem by fetching only unique templates in parallel.
|
|
274
280
|
* For example, if 100 pages use 3 different templates, this method makes 3 requests instead of 100.
|
|
275
281
|
*/
|
|
276
|
-
async addTemplateToPages(data) {
|
|
282
|
+
async addTemplateToPages(data, langCode = this.state.lang) {
|
|
277
283
|
// On API error responses (e.g. 403 without list permission, 422) the value
|
|
278
284
|
// is an IError, not an array — return it as-is instead of calling array
|
|
279
285
|
// methods (.filter/.map) on it and throwing a TypeError.
|
|
@@ -294,7 +300,9 @@ export default class PagesApi extends AsyncModules {
|
|
|
294
300
|
}
|
|
295
301
|
// Step 3: Fetch unique templates in parallel (not N queries, but unique count queries)
|
|
296
302
|
const Templates = new templatesApi(this.state);
|
|
297
|
-
const templatePromises = uniqueIdentifiers.map((identifier) =>
|
|
303
|
+
const templatePromises = uniqueIdentifiers.map((identifier) => AsyncModules._subRequestOf(Templates)
|
|
304
|
+
.getTemplateByMarker(identifier, langCode)
|
|
305
|
+
.catch((error) => {
|
|
298
306
|
// eslint-disable-next-line no-undef, no-console
|
|
299
307
|
console.error(`Template fetch error for ${identifier}: `, error);
|
|
300
308
|
return null; // Return null for failed templates
|
|
@@ -303,7 +311,8 @@ export default class PagesApi extends AsyncModules {
|
|
|
303
311
|
// Step 4: Create a Map for O(1) template lookup
|
|
304
312
|
const templateMap = new Map();
|
|
305
313
|
templates.forEach((template, index) => {
|
|
306
|
-
|
|
314
|
+
// An error comes back as a value with isShell: it is not a template
|
|
315
|
+
if (template !== null && !this._isErrorResponse(template)) {
|
|
307
316
|
templateMap.set(uniqueIdentifiers[index], template);
|
|
308
317
|
}
|
|
309
318
|
});
|
|
@@ -328,12 +337,12 @@ export default class PagesApi extends AsyncModules {
|
|
|
328
337
|
* Add template data to page by page templateIdentifier
|
|
329
338
|
* @handleName addTemplateToPage
|
|
330
339
|
* @param {IPagesEntity} data - Page object (IPagesEntity) to which template data will be added.
|
|
340
|
+
* @param {string} [langCode] - Language the templates are fetched and unwrapped in. Default: the client's language.
|
|
331
341
|
* @returns {Promise<any | IError>} An array of page objects with template data added
|
|
332
342
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
333
343
|
* @description Add template data to page by page templateIdentifier
|
|
334
|
-
* @see {@link https://js-sdk.oneentry.cloud/docs/pages/addTemplateToPage addTemplateToPage} documentation.
|
|
335
344
|
*/
|
|
336
|
-
async addTemplateToPage(data) {
|
|
345
|
+
async addTemplateToPage(data, langCode = this.state.lang) {
|
|
337
346
|
// Check if 'templateIdentifier' exists in 'data' and is not null or an empty string
|
|
338
347
|
if ('templateIdentifier' in data &&
|
|
339
348
|
data.templateIdentifier !== null &&
|
|
@@ -344,7 +353,11 @@ export default class PagesApi extends AsyncModules {
|
|
|
344
353
|
// Create a new instance of templatesApi with the current state
|
|
345
354
|
const Templates = new templatesApi(this.state);
|
|
346
355
|
// Fetch the template using the 'templateIdentifier'
|
|
347
|
-
const result = await Templates.getTemplateByMarker(templateIdentifier);
|
|
356
|
+
const result = await AsyncModules._subRequestOf(Templates).getTemplateByMarker(templateIdentifier, langCode);
|
|
357
|
+
// An error comes back as a value with isShell: leave the page without a template
|
|
358
|
+
if (this._isErrorResponse(result)) {
|
|
359
|
+
return data;
|
|
360
|
+
}
|
|
348
361
|
// Return the original data object with the fetched template added
|
|
349
362
|
return {
|
|
350
363
|
...data,
|
|
@@ -376,18 +389,18 @@ class StaffModule extends AsyncModules {
|
|
|
376
389
|
// ({ total, items }) to match BlocksApi's similarProducts contract.
|
|
377
390
|
async getSimilarProducts(marker, langCode = this.state.lang, offset = 0, limit = 30) {
|
|
378
391
|
// Fetch similar products from the server
|
|
379
|
-
const result = await this._fetchGet(`/${this._pathSegment(marker)}/similar-products?langCode=${langCode}&offset=${offset}&limit=${limit}`);
|
|
380
|
-
return this._normalizeData(result);
|
|
392
|
+
const result = await this._fetchGet(`/${this._pathSegment(marker)}/similar-products?langCode=${encodeURIComponent(langCode)}&offset=${encodeURIComponent(String(offset))}&limit=${encodeURIComponent(String(limit))}`);
|
|
393
|
+
return this._normalizeData(result, langCode);
|
|
381
394
|
}
|
|
382
395
|
// Method to fetch products by block marker
|
|
383
396
|
async getProductsByBlockMarker(marker, langCode = this.state.lang, offset = 0, limit = 30) {
|
|
384
397
|
// Fetch products from the server
|
|
385
|
-
const result = await this._fetchGet(`/${this._pathSegment(marker)}/products?langCode=${langCode}&offset=${offset}&limit=${limit}`);
|
|
398
|
+
const result = await this._fetchGet(`/${this._pathSegment(marker)}/products?langCode=${encodeURIComponent(langCode)}&offset=${encodeURIComponent(String(offset))}&limit=${encodeURIComponent(String(limit))}`);
|
|
386
399
|
// On API error responses there is no `items` array — return the (normalized)
|
|
387
400
|
// error as-is instead of producing `undefined` from `result.items`.
|
|
388
401
|
if (!Array.isArray(result === null || result === void 0 ? void 0 : result.items)) {
|
|
389
|
-
return this._normalizeData(result);
|
|
402
|
+
return this._normalizeData(result, langCode);
|
|
390
403
|
}
|
|
391
|
-
return this._normalizeData(result.items);
|
|
404
|
+
return this._normalizeData(result.items, langCode);
|
|
392
405
|
}
|
|
393
406
|
}
|
|
@@ -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>;
|
|
@@ -29,7 +29,6 @@ export const PageEntitySchema = z.object({
|
|
|
29
29
|
config: z.record(z.string(), z.number()).optional(),
|
|
30
30
|
products: z.number().optional(),
|
|
31
31
|
childrenCount: z.number().optional(),
|
|
32
|
-
total: z.string().optional(),
|
|
33
32
|
categoryPath: z.string().nullable().optional(),
|
|
34
33
|
distance: z.number().optional(),
|
|
35
34
|
});
|
|
@@ -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
|
|
@@ -48,21 +48,23 @@ export default class PaymentsApi extends AsyncModules {
|
|
|
48
48
|
* @see {@link https://js-sdk.oneentry.cloud/docs/payments/getSessionById getSessionById} documentation.
|
|
49
49
|
*/
|
|
50
50
|
async getSessionById(id) {
|
|
51
|
-
const result = await this._fetchGet(`/sessions/${id}`);
|
|
52
|
-
|
|
51
|
+
const result = await this._fetchGet(`/sessions/${this._pathSegment(String(id))}`);
|
|
52
|
+
// Validate response if validation is enabled
|
|
53
|
+
const validated = await this._validateResponse(result, schema('PaymentSessionSchema'));
|
|
54
|
+
return validated;
|
|
53
55
|
}
|
|
54
56
|
/**
|
|
55
57
|
* Get one payment session object by order identifier
|
|
56
58
|
* @handleName getSessionByOrderId
|
|
57
59
|
* @param {number} id - Order ID. Example: 12345.
|
|
58
|
-
* @returns {Promise<
|
|
60
|
+
* @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.
|
|
59
61
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
60
|
-
* @description This method gets
|
|
62
|
+
* @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.
|
|
61
63
|
* @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}.
|
|
62
64
|
* @see {@link https://js-sdk.oneentry.cloud/docs/payments/getSessionByOrderId getSessionByOrderId} documentation.
|
|
63
65
|
*/
|
|
64
66
|
async getSessionByOrderId(id) {
|
|
65
|
-
const result = await this._fetchGet(`/sessions/order/${id}`);
|
|
67
|
+
const result = await this._fetchGet(`/sessions/order/${this._pathSegment(String(id))}`);
|
|
66
68
|
// Validate response if validation is enabled
|
|
67
69
|
const validated = await this._validateResponse(result, schema('SinglePaymentSessionSchema'));
|
|
68
70
|
return validated;
|
|
@@ -92,32 +94,34 @@ export default class PaymentsApi extends AsyncModules {
|
|
|
92
94
|
/**
|
|
93
95
|
* Get all payment accounts as an array.
|
|
94
96
|
* @handleName getAccounts
|
|
95
|
-
* @
|
|
97
|
+
* @param {string} [langCode] - Language code. Default: the client's language.
|
|
98
|
+
* @returns {Promise<IAccountsEntity[] | IError>} Returns all created payment accounts as an array of PaymentAccountEntity objects.
|
|
96
99
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
97
|
-
* @description This method gets all payment accounts as an array.
|
|
98
|
-
* @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
|
+
* @description This method gets all payment accounts as an array. It does not require user authorization: a guest gets the accounts too.
|
|
99
101
|
* @see {@link https://js-sdk.oneentry.cloud/docs/payments/getAccounts getAccounts} documentation.
|
|
100
102
|
*/
|
|
101
|
-
async getAccounts() {
|
|
102
|
-
const result = await this._fetchGet('/accounts');
|
|
103
|
+
async getAccounts(langCode = this.state.lang) {
|
|
104
|
+
const result = await this._fetchGet('/accounts?' + this._queryParamsToString({ langCode }));
|
|
103
105
|
// Validate response if validation is enabled
|
|
104
106
|
const validated = await this._validateResponse(result, schema('PaymentAccountsResponseSchema'));
|
|
105
|
-
return this._normalizeData(validated);
|
|
107
|
+
return this._normalizeData(validated, langCode);
|
|
106
108
|
}
|
|
107
109
|
/**
|
|
108
110
|
* Get a single payment account object by its identifier.
|
|
109
111
|
* @handleName getAccountById
|
|
110
112
|
* @param {number} id - Payment account ID. Example: 12345.
|
|
113
|
+
* @param {string} [langCode] - Language code. Default: the client's language.
|
|
111
114
|
* @returns {Promise<IAccountsEntity | IError>} Returns a single payment account object.
|
|
112
115
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
113
|
-
* @description Get a single payment account object by its identifier.
|
|
114
|
-
* @description This method requires user authorization.
|
|
115
|
-
* @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}.
|
|
116
|
+
* @description Get a single payment account object by its identifier. It does not require user authorization: a guest gets the account too.
|
|
116
117
|
* @see {@link https://js-sdk.oneentry.cloud/docs/payments/getAccountById getAccountById} documentation.
|
|
117
118
|
*/
|
|
118
|
-
async getAccountById(id) {
|
|
119
|
-
const result = await this._fetchGet(`/accounts/${id}
|
|
120
|
-
|
|
119
|
+
async getAccountById(id, langCode = this.state.lang) {
|
|
120
|
+
const result = await this._fetchGet(`/accounts/${this._pathSegment(String(id))}?` +
|
|
121
|
+
this._queryParamsToString({ langCode }));
|
|
122
|
+
// Validate response if validation is enabled
|
|
123
|
+
const validated = await this._validateResponse(result, schema('PaymentAccountSchema'));
|
|
124
|
+
return this._normalizeData(validated, langCode);
|
|
121
125
|
}
|
|
122
126
|
/**
|
|
123
127
|
* Get the payment progress of an order: its stages and whether they are paid.
|
|
@@ -132,7 +136,7 @@ export default class PaymentsApi extends AsyncModules {
|
|
|
132
136
|
* @see {@link https://js-sdk.oneentry.cloud/docs/payments/getPaymentStagesByOrderId getPaymentStagesByOrderId} documentation.
|
|
133
137
|
*/
|
|
134
138
|
async getPaymentStagesByOrderId(id) {
|
|
135
|
-
const result = await this._fetchGet(`/stages/order/${id}`);
|
|
139
|
+
const result = await this._fetchGet(`/stages/order/${this._pathSegment(String(id))}`);
|
|
136
140
|
// Validate response if validation is enabled
|
|
137
141
|
const validated = await this._validateResponse(result, schema('PaymentProgressSchema'));
|
|
138
142
|
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
|
/**
|