oneentry 1.0.152 → 1.0.154
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/changelog.md +49 -0
- package/dist/admins/adminsApi.d.ts +2 -1
- package/dist/admins/adminsApi.js +2 -1
- package/dist/admins/adminsInterfaces.d.ts +1 -1
- package/dist/attribute-sets/attributeSetsApi.d.ts +4 -0
- package/dist/attribute-sets/attributeSetsApi.js +4 -0
- package/dist/auth-provider/authProviderApi.d.ts +14 -1
- package/dist/auth-provider/authProviderApi.js +14 -1
- package/dist/base/asyncModules.d.ts +21 -2
- package/dist/base/asyncModules.js +74 -225
- package/dist/base/stateModule.d.ts +4 -13
- package/dist/base/stateModule.js +12 -96
- package/dist/base/syncModules.d.ts +4 -0
- package/dist/base/syncModules.js +5 -1
- package/dist/blocks/blocksApi.d.ts +54 -11
- package/dist/blocks/blocksApi.js +90 -73
- package/dist/blocks/blocksInterfaces.d.ts +18 -9
- package/dist/discounts/discountsApi.d.ts +5 -0
- package/dist/discounts/discountsApi.js +5 -0
- package/dist/events/eventsApi.d.ts +7 -0
- package/dist/events/eventsApi.js +11 -28
- package/dist/file-uploading/fileUploadingApi.d.ts +4 -1
- package/dist/file-uploading/fileUploadingApi.js +4 -1
- package/dist/file-uploading/fileUploadingInterfaces.d.ts +1 -1
- package/dist/filters/filtersApi.d.ts +1 -0
- package/dist/filters/filtersApi.js +1 -0
- package/dist/forms/formsApi.d.ts +2 -0
- package/dist/forms/formsApi.js +2 -0
- package/dist/forms-data/formsDataApi.d.ts +5 -0
- package/dist/forms-data/formsDataApi.js +5 -0
- package/dist/general-types/generalTypesApi.d.ts +1 -0
- package/dist/general-types/generalTypesApi.js +1 -0
- package/dist/index.js +12 -0
- package/dist/integration-collections/integrationCollectionsApi.d.ts +10 -1
- package/dist/integration-collections/integrationCollectionsApi.js +10 -1
- package/dist/integration-collections/integrationCollectionsInterfaces.d.ts +1 -1
- package/dist/locales/localesApi.d.ts +1 -0
- package/dist/locales/localesApi.js +1 -0
- package/dist/menus/menusApi.d.ts +1 -0
- package/dist/menus/menusApi.js +1 -0
- package/dist/orders/ordersApi.d.ts +25 -1
- package/dist/orders/ordersApi.js +36 -12
- package/dist/orders/ordersInterfaces.d.ts +5 -2
- package/dist/pages/pagesApi.d.ts +9 -0
- package/dist/pages/pagesApi.js +35 -39
- package/dist/pages/pagesInterfaces.d.ts +5 -0
- package/dist/payments/paymentsApi.d.ts +6 -0
- package/dist/payments/paymentsApi.js +6 -0
- package/dist/product-statuses/productStatusesApi.d.ts +3 -0
- package/dist/product-statuses/productStatusesApi.js +3 -0
- package/dist/products/productsApi.d.ts +39 -64
- package/dist/products/productsApi.js +33 -61
- package/dist/products/productsInterfaces.d.ts +76 -72
- package/dist/sitemap/sitemapApi.d.ts +2 -0
- package/dist/sitemap/sitemapApi.js +2 -0
- package/dist/subscriptions/subscriptionsApi.d.ts +5 -0
- package/dist/subscriptions/subscriptionsApi.js +7 -14
- package/dist/system/systemApi.d.ts +3 -0
- package/dist/system/systemApi.js +3 -0
- package/dist/templates/templatesApi.d.ts +3 -0
- package/dist/templates/templatesApi.js +3 -0
- package/dist/templates-preview/templatesPreviewApi.d.ts +2 -0
- package/dist/templates-preview/templatesPreviewApi.js +2 -0
- package/dist/user-activity/userActivityApi.d.ts +1 -0
- package/dist/user-activity/userActivityApi.js +1 -0
- package/dist/users/usersApi.d.ts +14 -0
- package/dist/users/usersApi.js +14 -0
- package/dist/web-socket/wsApi.d.ts +1 -1
- package/dist/web-socket/wsApi.js +1 -1
- package/package.json +4 -1
package/changelog.md
CHANGED
|
@@ -1,5 +1,54 @@
|
|
|
1
1
|
# SDK Change Log
|
|
2
2
|
|
|
3
|
+
## v.1.0.154
|
|
4
|
+
|
|
5
|
+
### What's New
|
|
6
|
+
|
|
7
|
+
- Products > per-method query types — the single `IProductsQuery` is split into focused query types so each method only accepts the parameters it actually supports:
|
|
8
|
+
- `IProductsQueryBase` — base query (`offset`, `limit`, `sortOrder`, `sortKey`, `signPrice`) used by `getProducts`, `getProductsEmptyPage`, `getProductsByPageId`, `getProductsByPageUrl`.
|
|
9
|
+
- `IProductsRelatedQuery` — base query plus `statusMarker` and `templateMarker`, used by `getRelatedProductsById`.
|
|
10
|
+
- `IProductsPriceQuery` — base query without `sortKey`, plus `statusMarker`, used by `getProductsPriceByPageUrl`.
|
|
11
|
+
- `IProductsByIdsQuery` — only `signPrice` (`ids` is a dedicated method argument), used by `getProductsByIds`.
|
|
12
|
+
- All four types are now exported.
|
|
13
|
+
|
|
14
|
+
- Orders > `IOrderProductData.signedPrice` — new optional `signedPrice` (`string`) field: the signed (fixed) product price obtained together with the product data when `signPrice` is set. Used to carry the fixed price into an order line item.
|
|
15
|
+
|
|
16
|
+
- Products > `IProductInfo.signedPrice` — new optional `signedPrice` (`string`) field on the price-list items returned by `getProductsPriceByPageUrl`; populated with the signed (fixed) price when `signPrice` is set (mirrors `IProductsEntity.signedPrice`).
|
|
17
|
+
|
|
18
|
+
### What's Changed
|
|
19
|
+
|
|
20
|
+
- Products > `getProducts`, `getProductsEmptyPage`, `getProductsByPageId`, `getProductsByPageUrl`, `getProductsPriceByPageUrl`, `getRelatedProductsById`, `getProductsByIds` — `userQuery` is now typed with the corresponding per-method query type above instead of the broad `IProductsQuery`. `IProductsQuery` is retained as a **deprecated** alias of `IProductsQueryBase` for backward compatibility.
|
|
21
|
+
|
|
22
|
+
- Products > `getProductsByIds` — now accepts only `signPrice` in `userQuery` (`IProductsByIdsQuery`); `limit`/`sort`/filter markers are no longer query parameters of this endpoint. As a result `searchProduct` (quick search) no longer forwards an explicit `limit` to the internal `/ids` request.
|
|
23
|
+
|
|
24
|
+
- Products / Blocks / Orders — JSDoc for `signPrice` / `signedPrice` clarified ("Order storage marker for price fixing…") with links to the "Fixing the price" / "Fixed product price" documentation. Orders > `previewOrder` description cleaned up (removed the stray `???`). No structural change.
|
|
25
|
+
|
|
26
|
+
- HTTP core — the legacy Node.js `< 18` request path was removed. The SDK previously detected old Node versions and routed requests through a dynamically imported `https` module (`_NO_FETCH` / `state._https`); that branch did **not** perform token refresh, response validation, `errorsFunctions` callbacks or `isShell` handling, so behavior silently degraded on old Node. All requests now go through the native `fetch` path (browser and Node 18+), which collapses four duplicated `_fetchGet` / `_fetchPost` / `_fetchPut` / `_fetchDelete` implementations into one and gives every environment the same auth/validation/error behavior. **The SDK now requires Node 18+** (declared via `engines.node >= 18`).
|
|
27
|
+
|
|
28
|
+
### Bug Fixes
|
|
29
|
+
|
|
30
|
+
- Query parameters and free-text search are now URL-encoded (`encodeURIComponent`). Previously values containing spaces, `&`, `=` or non-ASCII characters corrupted the query string — most visibly in the text search of `Products.searchProduct`, `Pages.searchPage` and `Blocks.searchBlock`.
|
|
31
|
+
- `Pages.searchPage` — fixed the `url` query part: when no `url` was passed the request string previously contained stray output (`undefined` / a leading `&`). It is now built correctly and omitted when absent.
|
|
32
|
+
- Auth — the `401 → refresh → retry` path now flows through the same response handling as the initial request. The retried response is checked for `ok`, tolerates an empty body, and runs `errorsFunctions` / honors `isShell`. Previously a failed retry returned the raw error body as if it were successful data, and an empty retry body could throw from `.json()`.
|
|
33
|
+
|
|
34
|
+
- `defineOneEntry` — initializing the SDK without a project URL or app token no longer crashes with a cryptic `TypeError: Cannot read properties of undefined (reading 'endsWith')`. The function now validates its inputs up front and throws a clear, actionable error instead: a missing/empty `url` (PROJECT_URL) and a missing/empty `config.token` (APP_TOKEN) each produce a descriptive message with a correct usage example. Empty / whitespace-only values (e.g. an unfilled `.env` variable) are treated as missing.
|
|
35
|
+
|
|
36
|
+
### What's Deleted
|
|
37
|
+
|
|
38
|
+
- Removed the unused `src/base/result.ts` (dead `Result` class — never imported, and containing a misplaced `await` and unreachable branches).
|
|
39
|
+
|
|
40
|
+
## v.1.0.153
|
|
41
|
+
|
|
42
|
+
### What's New
|
|
43
|
+
|
|
44
|
+
- Pages > `IPositionBlock` — new optional `similarProducts` (`IProductsResponse`) and `products` (`IProductsEntity[]`) fields, populated for `similar_products_block` / `product_block` page blocks (when traffic-saving mode is off).
|
|
45
|
+
|
|
46
|
+
### Bug Fixes
|
|
47
|
+
|
|
48
|
+
- Pages > `getBlocksByPageUrl` — related products are now actually loaded for `product_block` (`products`) and `similar_products_block` (`similarProducts`) blocks. The block-type check ran against the response array instead of each block, so product loading never executed; it now runs per block. `similarProducts` is returned as the full `{ total, items }` response, consistent with `Blocks` block enrichment.
|
|
49
|
+
|
|
50
|
+
- Orders > `getRefunds`, `createRefundRequest`, `cancelRefundRequest` — the base URL is now restored even if the refund request throws (wrapped in `try/finally`). Previously an exception left `_url` switched to `/orders`, which could misroute subsequent calls on the same instance.
|
|
51
|
+
|
|
3
52
|
## v.1.0.152
|
|
4
53
|
|
|
5
54
|
### Bug Fixes
|
|
@@ -40,12 +40,13 @@ export default class AdminsApi extends AsyncModules implements IAdmins {
|
|
|
40
40
|
]
|
|
41
41
|
* @param {string} [body.attributeMarker] - Text identifier (marker) of the attribute in the set. Example: "num".
|
|
42
42
|
* @param {string} [body.conditionMarker] - Text identifier (marker) of the condition in the set. Example: "mth".
|
|
43
|
-
* @param {string} [body.conditionValue] - Value of the condition. Example:
|
|
43
|
+
* @param {number | string | null} [body.conditionValue] - Value of the condition. Example: "new".
|
|
44
44
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
45
45
|
* @param {number} [offset] - Parameter for pagination. Default: 0.
|
|
46
46
|
* @param {number} [limit] - Parameter for pagination. Default: 30.
|
|
47
47
|
* @returns {Promise<IAdminEntity[] | IError>} Returns an array of admin objects.
|
|
48
48
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
49
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/admins/getAdminsInfo getAdminsInfo} documentation.
|
|
49
50
|
*/
|
|
50
51
|
getAdminsInfo(body?: IFilterParams[], langCode?: string, offset?: number, limit?: number): Promise<IAdminEntity[] | IError>;
|
|
51
52
|
}
|
package/dist/admins/adminsApi.js
CHANGED
|
@@ -43,12 +43,13 @@ class AdminsApi extends asyncModules_1.default {
|
|
|
43
43
|
]
|
|
44
44
|
* @param {string} [body.attributeMarker] - Text identifier (marker) of the attribute in the set. Example: "num".
|
|
45
45
|
* @param {string} [body.conditionMarker] - Text identifier (marker) of the condition in the set. Example: "mth".
|
|
46
|
-
* @param {string} [body.conditionValue] - Value of the condition. Example:
|
|
46
|
+
* @param {number | string | null} [body.conditionValue] - Value of the condition. Example: "new".
|
|
47
47
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
48
48
|
* @param {number} [offset] - Parameter for pagination. Default: 0.
|
|
49
49
|
* @param {number} [limit] - Parameter for pagination. Default: 30.
|
|
50
50
|
* @returns {Promise<IAdminEntity[] | IError>} Returns an array of admin objects.
|
|
51
51
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
52
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/admins/getAdminsInfo getAdminsInfo} documentation.
|
|
52
53
|
*/
|
|
53
54
|
async getAdminsInfo(body = [], langCode = this.state.lang, offset = 0, limit = 30) {
|
|
54
55
|
const query = {
|
|
@@ -25,7 +25,7 @@ interface IAdmins {
|
|
|
25
25
|
]
|
|
26
26
|
* @param {string} [body.attributeMarker] - Text identifier (marker) of the attribute in the set. Example: "num".
|
|
27
27
|
* @param {string} [body.conditionMarker] - Text identifier (marker) of the condition in the set. Example: "mth".
|
|
28
|
-
* @param {string} [body.conditionValue] - Value of the condition. Example:
|
|
28
|
+
* @param {number | string | null} [body.conditionValue] - Value of the condition. Example: "new".
|
|
29
29
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
30
30
|
* @param {number} [offset] - Parameter for pagination. Default: 0.
|
|
31
31
|
* @param {number} [limit] - Parameter for pagination. Default: 30.
|
|
@@ -30,6 +30,7 @@ export default class AttributesSetsApi extends AsyncModules implements IAttribut
|
|
|
30
30
|
* @param {string} [sortBy] - identifier of the attribute set type. Default: "id".
|
|
31
31
|
* @returns {Promise<IAttributesSetsResponse | IError>} Returns object with array of IAttributeSetsEntity and total items count.
|
|
32
32
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
33
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/attribute-sets/getAttributes getAttributes} documentation.
|
|
33
34
|
*/
|
|
34
35
|
getAttributes(langCode?: string, offset?: number, limit?: number, typeId?: any, sortBy?: string): Promise<IAttributesSetsResponse | IError>;
|
|
35
36
|
/**
|
|
@@ -39,6 +40,7 @@ export default class AttributesSetsApi extends AsyncModules implements IAttribut
|
|
|
39
40
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
40
41
|
* @returns {Promise<IAttributeSetsEntity[] | IError>} Returns an array of Attributes objects.
|
|
41
42
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
43
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/attribute-sets/getAttributesByMarker getAttributesByMarker} documentation.
|
|
42
44
|
*/
|
|
43
45
|
getAttributesByMarker(marker: string, langCode?: string): Promise<IAttributeSetsEntity[] | IError>;
|
|
44
46
|
/**
|
|
@@ -49,6 +51,7 @@ export default class AttributesSetsApi extends AsyncModules implements IAttribut
|
|
|
49
51
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
50
52
|
* @returns {Promise<IAttributesSetsEntity | IError>} Returns a single attribute object from the attribute set.
|
|
51
53
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
54
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/attribute-sets/getSingleAttributeByMarkerSet getSingleAttributeByMarkerSet} documentation.
|
|
52
55
|
*/
|
|
53
56
|
getSingleAttributeByMarkerSet(setMarker: string, attributeMarker: string, langCode?: string): Promise<IAttributesSetsEntity | IError>;
|
|
54
57
|
/**
|
|
@@ -58,6 +61,7 @@ export default class AttributesSetsApi extends AsyncModules implements IAttribut
|
|
|
58
61
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
59
62
|
* @returns {Promise<IAttributeSetsEntity | IError>} Returns one object of the attribute set.
|
|
60
63
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
64
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/attribute-sets/getAttributeSetByMarker getAttributeSetByMarker} documentation.
|
|
61
65
|
*/
|
|
62
66
|
getAttributeSetByMarker(marker: string, langCode?: string): Promise<IAttributeSetsEntity | IError>;
|
|
63
67
|
}
|
|
@@ -34,6 +34,7 @@ class AttributesSetsApi extends asyncModules_1.default {
|
|
|
34
34
|
* @param {string} [sortBy] - identifier of the attribute set type. Default: "id".
|
|
35
35
|
* @returns {Promise<IAttributesSetsResponse | IError>} Returns object with array of IAttributeSetsEntity and total items count.
|
|
36
36
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
37
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/attribute-sets/getAttributes getAttributes} documentation.
|
|
37
38
|
*/
|
|
38
39
|
async getAttributes(langCode = this.state.lang, offset = 0, limit = 30,
|
|
39
40
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -58,6 +59,7 @@ class AttributesSetsApi extends asyncModules_1.default {
|
|
|
58
59
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
59
60
|
* @returns {Promise<IAttributeSetsEntity[] | IError>} Returns an array of Attributes objects.
|
|
60
61
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
62
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/attribute-sets/getAttributesByMarker getAttributesByMarker} documentation.
|
|
61
63
|
*/
|
|
62
64
|
async getAttributesByMarker(marker, langCode = this.state.lang) {
|
|
63
65
|
const result = await this._fetchGet(`/${marker}/attributes?langCode=${langCode}`);
|
|
@@ -73,6 +75,7 @@ class AttributesSetsApi extends asyncModules_1.default {
|
|
|
73
75
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
74
76
|
* @returns {Promise<IAttributesSetsEntity | IError>} Returns a single attribute object from the attribute set.
|
|
75
77
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
78
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/attribute-sets/getSingleAttributeByMarkerSet getSingleAttributeByMarkerSet} documentation.
|
|
76
79
|
*/
|
|
77
80
|
async getSingleAttributeByMarkerSet(setMarker, attributeMarker, langCode = this.state.lang) {
|
|
78
81
|
const result = await this._fetchGet(`/${setMarker}/attributes/${attributeMarker}?langCode=${langCode}`);
|
|
@@ -87,6 +90,7 @@ class AttributesSetsApi extends asyncModules_1.default {
|
|
|
87
90
|
* @param {string} [langCode] - Language code. Default: "en_US".
|
|
88
91
|
* @returns {Promise<IAttributeSetsEntity | IError>} Returns one object of the attribute set.
|
|
89
92
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
93
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/attribute-sets/getAttributeSetByMarker getAttributeSetByMarker} documentation.
|
|
90
94
|
*/
|
|
91
95
|
async getAttributeSetByMarker(marker, langCode = this.state.lang) {
|
|
92
96
|
const result = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
|
|
@@ -82,6 +82,7 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
|
|
|
82
82
|
* @returns {Promise<ISignUpEntity | IError>} Returns a user object.
|
|
83
83
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
84
84
|
* @description User registration (❗️For a provider with user activation, the activation code is sent through the corresponding user notification method).
|
|
85
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/signUp signUp} documentation.
|
|
85
86
|
*/
|
|
86
87
|
signUp(marker: string, body: ISignUpData, langCode?: string): Promise<ISignUpEntity | IError>;
|
|
87
88
|
/**
|
|
@@ -93,6 +94,7 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
|
|
|
93
94
|
* @returns {Promise<void | IError>} Returns void if the code is successfully generated, or an error object if there was an issue.
|
|
94
95
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
95
96
|
* @description Obtaining a code to activate the user.
|
|
97
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/generateCode generateCode} documentation.
|
|
96
98
|
*/
|
|
97
99
|
generateCode(marker: string, userIdentifier: string, eventIdentifier: string): Promise<void | IError>;
|
|
98
100
|
/**
|
|
@@ -105,6 +107,7 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
|
|
|
105
107
|
* @returns {Promise<boolean | IError>} Returns true if the code is correct, or an error object if there was an issue.
|
|
106
108
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
107
109
|
* @description Checking the user activation code
|
|
110
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/checkCode checkCode} documentation.
|
|
108
111
|
*/
|
|
109
112
|
checkCode(marker: string, userIdentifier: string, eventIdentifier: string, code: string): Promise<boolean | IError>;
|
|
110
113
|
/**
|
|
@@ -116,6 +119,7 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
|
|
|
116
119
|
* @returns {Promise<boolean | IError>} Returns true if the user was successfully activated, or an error object if there was an issue.
|
|
117
120
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
118
121
|
* @description User activation.
|
|
122
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/activateUser activateUser} documentation.
|
|
119
123
|
*/
|
|
120
124
|
activateUser(marker: string, userIdentifier: string, code: string): Promise<boolean | IError>;
|
|
121
125
|
/**
|
|
@@ -149,6 +153,7 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
|
|
|
149
153
|
* @returns {Promise<IAuthEntity | IError>} Returns an auth entity object.
|
|
150
154
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
151
155
|
* @description User authorization.
|
|
156
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/auth auth} documentation.
|
|
152
157
|
*/
|
|
153
158
|
auth(marker: string, body: IAuthPostBody): Promise<IAuthEntity | IError>;
|
|
154
159
|
/**
|
|
@@ -159,6 +164,7 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
|
|
|
159
164
|
* @returns {Promise<IAuthEntity | IError>} Returns an auth entity object with the following values: accessToken, refreshToken, user, and other auth-related data.
|
|
160
165
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
161
166
|
* @description User token refresh.
|
|
167
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/refresh refresh} documentation.
|
|
162
168
|
*/
|
|
163
169
|
refresh(marker: string, token: string): Promise<IAuthEntity | IError>;
|
|
164
170
|
/**
|
|
@@ -170,6 +176,7 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
|
|
|
170
176
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
171
177
|
* @description This method requires user authorization.
|
|
172
178
|
* @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}.
|
|
179
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/logout logout} documentation.
|
|
173
180
|
*/
|
|
174
181
|
logout(marker: string, token: string): Promise<boolean | IError>;
|
|
175
182
|
/**
|
|
@@ -180,6 +187,7 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
|
|
|
180
187
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
181
188
|
* @description This method requires user authorization.
|
|
182
189
|
* @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}.
|
|
190
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/logoutAll logoutAll} documentation.
|
|
183
191
|
*/
|
|
184
192
|
logoutAll(marker: string): Promise<boolean | IError>;
|
|
185
193
|
/**
|
|
@@ -188,13 +196,14 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
|
|
|
188
196
|
* @param {string} marker - The text identifier of the authorization provider. Example: "email".
|
|
189
197
|
* @param {string} userIdentifier - The text identifier of the user's object (user login). Example: "example@oneentry.cloud".
|
|
190
198
|
* @param {string} eventIdentifier - The text identifier of the event. Example: "reg".
|
|
191
|
-
* @param {
|
|
199
|
+
* @param {number} type - Operation type (1 - for changing password, 2 - for recovery). Example: 1.
|
|
192
200
|
* @param {string} code - Service code. Example: "123456".
|
|
193
201
|
* @param {string} newPassword - New password. Example: "newPassword123".
|
|
194
202
|
* @param {string} [repeatPassword] - Optional variable contains repeat new password for validation. Example: "newPassword123".
|
|
195
203
|
* @returns {Promise<boolean | IError>} Returns true if the password was successfully changed, or an error object if there was an issue.
|
|
196
204
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
197
205
|
* @description User password change (only for tariffs with account activation and the Activation feature enabled).
|
|
206
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/changePassword changePassword} documentation.
|
|
198
207
|
*/
|
|
199
208
|
changePassword(marker: string, userIdentifier: string, eventIdentifier: string, type: number, code: string, newPassword: string, repeatPassword?: string): Promise<boolean | IError>;
|
|
200
209
|
/**
|
|
@@ -206,6 +215,7 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
|
|
|
206
215
|
* @returns {Promise<IAuthProvidersEntity[] | IError>} Returns an array of auth provider objects.
|
|
207
216
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
208
217
|
* @description Getting all objects of authorization providers.
|
|
218
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/getAuthProviders getAuthProviders} documentation.
|
|
209
219
|
*/
|
|
210
220
|
getAuthProviders(langCode?: string, offset?: number, limit?: number): Promise<IAuthProvidersEntity[] | IError>;
|
|
211
221
|
/**
|
|
@@ -216,6 +226,7 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
|
|
|
216
226
|
* @returns {Promise<IAuthProvidersEntity | IError>} Returns an auth provider object.
|
|
217
227
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
218
228
|
* @description Getting a single authorization provider object by marker.
|
|
229
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/getAuthProviderByMarker getAuthProviderByMarker} documentation.
|
|
219
230
|
*/
|
|
220
231
|
getAuthProviderByMarker(marker: string, langCode?: string): Promise<IAuthProvidersEntity | IError>;
|
|
221
232
|
/**
|
|
@@ -225,6 +236,7 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
|
|
|
225
236
|
* @returns {Promise<IActiveSession[] | IError>} Returns an auth provider object.
|
|
226
237
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
227
238
|
* @description Getting a single authorization provider object by marker.
|
|
239
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/getActiveSessionsByMarker getActiveSessionsByMarker} documentation.
|
|
228
240
|
*/
|
|
229
241
|
getActiveSessionsByMarker(marker: string): Promise<IActiveSession[] | IError>;
|
|
230
242
|
/**
|
|
@@ -244,6 +256,7 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
|
|
|
244
256
|
* @returns {Promise<ISignUpEntity | IError>} Returns a user object.
|
|
245
257
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
246
258
|
* @description User registration (authorization) via OAUTH.
|
|
259
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/oauth oauth} documentation.
|
|
247
260
|
*/
|
|
248
261
|
oauth(marker: string, body: IOauthData, langCode?: string): Promise<IAuthEntity | IError>;
|
|
249
262
|
}
|
|
@@ -87,6 +87,7 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
87
87
|
* @returns {Promise<ISignUpEntity | IError>} Returns a user object.
|
|
88
88
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
89
89
|
* @description User registration (❗️For a provider with user activation, the activation code is sent through the corresponding user notification method).
|
|
90
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/signUp signUp} documentation.
|
|
90
91
|
*/
|
|
91
92
|
async signUp(marker, body, langCode = this.state.lang) {
|
|
92
93
|
body['langCode'] = langCode;
|
|
@@ -104,6 +105,7 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
104
105
|
* @returns {Promise<void | IError>} Returns void if the code is successfully generated, or an error object if there was an issue.
|
|
105
106
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
106
107
|
* @description Obtaining a code to activate the user.
|
|
108
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/generateCode generateCode} documentation.
|
|
107
109
|
*/
|
|
108
110
|
async generateCode(marker, userIdentifier, eventIdentifier) {
|
|
109
111
|
const data = {
|
|
@@ -123,6 +125,7 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
123
125
|
* @returns {Promise<boolean | IError>} Returns true if the code is correct, or an error object if there was an issue.
|
|
124
126
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
125
127
|
* @description Checking the user activation code
|
|
128
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/checkCode checkCode} documentation.
|
|
126
129
|
*/
|
|
127
130
|
async checkCode(marker, userIdentifier, eventIdentifier, code) {
|
|
128
131
|
const data = {
|
|
@@ -142,6 +145,7 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
142
145
|
* @returns {Promise<boolean | IError>} Returns true if the user was successfully activated, or an error object if there was an issue.
|
|
143
146
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
144
147
|
* @description User activation.
|
|
148
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/activateUser activateUser} documentation.
|
|
145
149
|
*/
|
|
146
150
|
async activateUser(marker, userIdentifier, code) {
|
|
147
151
|
const data = {
|
|
@@ -182,6 +186,7 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
182
186
|
* @returns {Promise<IAuthEntity | IError>} Returns an auth entity object.
|
|
183
187
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
184
188
|
* @description User authorization.
|
|
189
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/auth auth} documentation.
|
|
185
190
|
*/
|
|
186
191
|
async auth(marker, body) {
|
|
187
192
|
const result = await this._fetchPost(`/marker/${marker}/users/auth`, body);
|
|
@@ -204,6 +209,7 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
204
209
|
* @returns {Promise<IAuthEntity | IError>} Returns an auth entity object with the following values: accessToken, refreshToken, user, and other auth-related data.
|
|
205
210
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
206
211
|
* @description User token refresh.
|
|
212
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/refresh refresh} documentation.
|
|
207
213
|
*/
|
|
208
214
|
async refresh(marker, token) {
|
|
209
215
|
const data = { refreshToken: token };
|
|
@@ -226,6 +232,7 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
226
232
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
227
233
|
* @description This method requires user authorization.
|
|
228
234
|
* @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}.
|
|
235
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/logout logout} documentation.
|
|
229
236
|
*/
|
|
230
237
|
async logout(marker, token) {
|
|
231
238
|
const data = {
|
|
@@ -249,6 +256,7 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
249
256
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
250
257
|
* @description This method requires user authorization.
|
|
251
258
|
* @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}.
|
|
259
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/logoutAll logoutAll} documentation.
|
|
252
260
|
*/
|
|
253
261
|
async logoutAll(marker) {
|
|
254
262
|
const result = await this._fetchPost(`/marker/${marker}/users/logout-all`);
|
|
@@ -267,13 +275,14 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
267
275
|
* @param {string} marker - The text identifier of the authorization provider. Example: "email".
|
|
268
276
|
* @param {string} userIdentifier - The text identifier of the user's object (user login). Example: "example@oneentry.cloud".
|
|
269
277
|
* @param {string} eventIdentifier - The text identifier of the event. Example: "reg".
|
|
270
|
-
* @param {
|
|
278
|
+
* @param {number} type - Operation type (1 - for changing password, 2 - for recovery). Example: 1.
|
|
271
279
|
* @param {string} code - Service code. Example: "123456".
|
|
272
280
|
* @param {string} newPassword - New password. Example: "newPassword123".
|
|
273
281
|
* @param {string} [repeatPassword] - Optional variable contains repeat new password for validation. Example: "newPassword123".
|
|
274
282
|
* @returns {Promise<boolean | IError>} Returns true if the password was successfully changed, or an error object if there was an issue.
|
|
275
283
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
276
284
|
* @description User password change (only for tariffs with account activation and the Activation feature enabled).
|
|
285
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/changePassword changePassword} documentation.
|
|
277
286
|
*/
|
|
278
287
|
async changePassword(marker, userIdentifier, eventIdentifier, type, code, newPassword, repeatPassword) {
|
|
279
288
|
const data = {
|
|
@@ -296,6 +305,7 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
296
305
|
* @returns {Promise<IAuthProvidersEntity[] | IError>} Returns an array of auth provider objects.
|
|
297
306
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
298
307
|
* @description Getting all objects of authorization providers.
|
|
308
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/getAuthProviders getAuthProviders} documentation.
|
|
299
309
|
*/
|
|
300
310
|
async getAuthProviders(langCode = this.state.lang, offset = 0, limit = 30) {
|
|
301
311
|
const result = await this._fetchGet(`?langCode=${langCode}&offset=${offset}&limit=${limit}`);
|
|
@@ -311,6 +321,7 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
311
321
|
* @returns {Promise<IAuthProvidersEntity | IError>} Returns an auth provider object.
|
|
312
322
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
313
323
|
* @description Getting a single authorization provider object by marker.
|
|
324
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/getAuthProviderByMarker getAuthProviderByMarker} documentation.
|
|
314
325
|
*/
|
|
315
326
|
async getAuthProviderByMarker(marker, langCode = this.state.lang) {
|
|
316
327
|
const result = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
|
|
@@ -323,6 +334,7 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
323
334
|
* @returns {Promise<IActiveSession[] | IError>} Returns an auth provider object.
|
|
324
335
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
325
336
|
* @description Getting a single authorization provider object by marker.
|
|
337
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/getActiveSessionsByMarker getActiveSessionsByMarker} documentation.
|
|
326
338
|
*/
|
|
327
339
|
async getActiveSessionsByMarker(marker) {
|
|
328
340
|
const result = await this._fetchGet(`/marker/${marker}/users/sessions`);
|
|
@@ -345,6 +357,7 @@ class AuthProviderApi extends asyncModules_1.default {
|
|
|
345
357
|
* @returns {Promise<ISignUpEntity | IError>} Returns a user object.
|
|
346
358
|
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
347
359
|
* @description User registration (authorization) via OAUTH.
|
|
360
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/auth-provider/oauth oauth} documentation.
|
|
348
361
|
*/
|
|
349
362
|
async oauth(marker, body, langCode = this.state.lang) {
|
|
350
363
|
const result = await this._fetchPost(`/marker/${marker}/oauth`, this._normalizePostBody(body, langCode));
|
|
@@ -8,8 +8,6 @@ import type { IError } from './utils';
|
|
|
8
8
|
*/
|
|
9
9
|
export default abstract class AsyncModules extends SyncModules {
|
|
10
10
|
protected state: StateModule;
|
|
11
|
-
protected _NO_FETCH: boolean;
|
|
12
|
-
protected _https: any;
|
|
13
11
|
protected _url: string;
|
|
14
12
|
/**
|
|
15
13
|
* Constructor initializes the AsyncModules with a given state.
|
|
@@ -56,6 +54,17 @@ export default abstract class AsyncModules extends SyncModules {
|
|
|
56
54
|
* @description Define a protected asynchronous method '_fetchDelete' that performs a DELETE request
|
|
57
55
|
*/
|
|
58
56
|
protected _fetchDelete<T = unknown>(path: string, body?: unknown): Promise<T>;
|
|
57
|
+
/**
|
|
58
|
+
* Wraps a fetch call whose only meaningful outcome is success or failure.
|
|
59
|
+
*
|
|
60
|
+
* Several endpoints (cancel/recover subscription, subscribe/unsubscribe to
|
|
61
|
+
* events) return no useful body — callers only care whether the request
|
|
62
|
+
* succeeded. This helper resolves to `true` on success and to the caught
|
|
63
|
+
* error (as IError) on failure, centralizing the repeated try/catch.
|
|
64
|
+
* @param {() => Promise<unknown>} request - Thunk performing the fetch call.
|
|
65
|
+
* @returns {Promise<boolean | IError>} `true` on success, IError on failure.
|
|
66
|
+
*/
|
|
67
|
+
protected _fetchBoolean(request: () => Promise<unknown>): Promise<boolean | IError>;
|
|
59
68
|
/**
|
|
60
69
|
* Refreshes the authentication token (single-flight).
|
|
61
70
|
* @returns {Promise<boolean>} A promise resolving to a boolean indicating success or failure.
|
|
@@ -75,6 +84,16 @@ export default abstract class AsyncModules extends SyncModules {
|
|
|
75
84
|
* @returns {IHttpOptions} An object representing the request options.
|
|
76
85
|
*/
|
|
77
86
|
private makeOptions;
|
|
87
|
+
/**
|
|
88
|
+
* Reads a response body as JSON, tolerating an empty body.
|
|
89
|
+
*
|
|
90
|
+
* `Response.json()` throws on an empty body (e.g. 204 or an empty error
|
|
91
|
+
* payload); this helper mirrors the OK-path guard (`text ? JSON.parse : {}`)
|
|
92
|
+
* so both the success and the error branches handle empty bodies the same way.
|
|
93
|
+
* @param {Response} response - The fetch Response to read.
|
|
94
|
+
* @returns {Promise<unknown>} Parsed JSON, or an empty object when the body is empty/unparsable.
|
|
95
|
+
*/
|
|
96
|
+
private _parseJson;
|
|
78
97
|
/**
|
|
79
98
|
* Handles responses from the browser's fetch API.
|
|
80
99
|
* @param {string} path - The path to append to the base URL.
|