oneentry 1.0.159 → 1.0.161
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 +2 -0
- package/changelog.md +56 -1
- package/dist/admins/adminsApi.d.ts +15 -1
- package/dist/admins/adminsApi.js +29 -0
- package/dist/admins/adminsInterfaces.d.ts +37 -1
- package/dist/base/lazySchema.d.ts +15 -0
- package/dist/base/lazySchema.js +20 -0
- package/dist/discounts/discountsApi.d.ts +14 -1
- package/dist/discounts/discountsApi.js +21 -0
- package/dist/discounts/discountsInterfaces.d.ts +27 -1
- package/dist/filters/filtersInterfaces.d.ts +2 -2
- package/dist/filters/filtersSchemas.d.ts +1 -1
- package/dist/filters/filtersSchemas.js +4 -1
- package/dist/forms-data/formsDataApi.d.ts +14 -1
- package/dist/forms-data/formsDataApi.js +21 -0
- package/dist/forms-data/formsDataInterfaces.d.ts +74 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +3 -0
- package/dist/orders/ordersApi.d.ts +15 -1
- package/dist/orders/ordersApi.js +22 -0
- package/dist/orders/ordersInterfaces.d.ts +27 -1
- package/dist/pages/pagesApi.d.ts +14 -1
- package/dist/pages/pagesApi.js +21 -0
- package/dist/pages/pagesInterfaces.d.ts +38 -1
- package/dist/payments/paymentsInterfaces.d.ts +2 -2
- package/dist/products/productsInterfaces.d.ts +1 -1
- package/dist/search/searchApi.d.ts +35 -0
- package/dist/search/searchApi.js +86 -0
- package/dist/search/searchInterfaces.d.ts +94 -0
- package/dist/search/searchInterfaces.js +2 -0
- package/dist/search/searchSchemas.d.ts +73 -0
- package/dist/search/searchSchemas.js +44 -0
- package/dist/templates-preview/templatesPreviewInterfaces.d.ts +0 -2
- package/dist/templates-preview/templatesPreviewSchemas.d.ts +0 -2
- package/dist/templates-preview/templatesPreviewSchemas.js +0 -1
- package/dist/types.d.ts +35 -0
- package/dist/types.js +2 -0
- package/dist/users/usersApi.d.ts +15 -1
- package/dist/users/usersApi.js +22 -0
- package/dist/users/usersInterfaces.d.ts +39 -1
- package/dist/web-socket/lazySocket.d.ts +18 -0
- package/dist/web-socket/lazySocket.js +70 -0
- package/esm/admins/adminsApi.d.ts +66 -0
- package/esm/admins/adminsApi.js +90 -0
- package/esm/admins/adminsInterfaces.d.ts +137 -0
- package/esm/admins/adminsInterfaces.js +1 -0
- package/esm/admins/adminsSchemas.d.ts +48 -0
- package/esm/admins/adminsSchemas.js +31 -0
- package/esm/attribute-sets/attributeSetsApi.d.ts +67 -0
- package/esm/attribute-sets/attributeSetsApi.js +97 -0
- package/esm/attribute-sets/attributeSetsInterfaces.d.ts +285 -0
- package/esm/attribute-sets/attributeSetsInterfaces.js +1 -0
- package/esm/attribute-sets/attributeSetsSchemas.d.ts +84 -0
- package/esm/attribute-sets/attributeSetsSchemas.js +66 -0
- package/esm/auth-provider/authProviderApi.d.ts +262 -0
- package/esm/auth-provider/authProviderApi.js +362 -0
- package/esm/auth-provider/authProviderSchemas.d.ts +124 -0
- package/esm/auth-provider/authProviderSchemas.js +92 -0
- package/esm/auth-provider/authProvidersInterfaces.d.ts +430 -0
- package/esm/auth-provider/authProvidersInterfaces.js +1 -0
- package/esm/base/asyncModules.d.ts +123 -0
- package/esm/base/asyncModules.js +382 -0
- package/esm/base/lazySchema.d.ts +15 -0
- package/esm/base/lazySchema.js +17 -0
- package/esm/base/stateModule.d.ts +35 -0
- package/esm/base/stateModule.js +51 -0
- package/esm/base/syncModules.d.ts +245 -0
- package/esm/base/syncModules.js +555 -0
- package/esm/base/timeIntervals.d.ts +95 -0
- package/esm/base/timeIntervals.js +317 -0
- package/esm/base/utils.d.ts +354 -0
- package/esm/base/utils.js +1 -0
- package/esm/base/validation.d.ts +98 -0
- package/esm/base/validation.js +118 -0
- package/esm/blocks/blocksApi.d.ts +252 -0
- package/esm/blocks/blocksApi.js +394 -0
- package/esm/blocks/blocksInterfaces.d.ts +361 -0
- package/esm/blocks/blocksInterfaces.js +1 -0
- package/esm/blocks/blocksSchemas.d.ts +213 -0
- package/esm/blocks/blocksSchemas.js +40 -0
- package/esm/discounts/discountsApi.d.ts +94 -0
- package/esm/discounts/discountsApi.js +136 -0
- package/esm/discounts/discountsInterfaces.d.ts +293 -0
- package/esm/discounts/discountsInterfaces.js +1 -0
- package/esm/events/eventsApi.d.ts +108 -0
- package/esm/events/eventsApi.js +141 -0
- package/esm/events/eventsInterfaces.d.ts +176 -0
- package/esm/events/eventsInterfaces.js +1 -0
- package/esm/file-uploading/fileUploadingApi.d.ts +91 -0
- package/esm/file-uploading/fileUploadingApi.js +127 -0
- package/esm/file-uploading/fileUploadingInterfaces.d.ts +116 -0
- package/esm/file-uploading/fileUploadingInterfaces.js +1 -0
- package/esm/file-uploading/fileUploadingSchemas.d.ts +24 -0
- package/esm/file-uploading/fileUploadingSchemas.js +19 -0
- package/esm/filters/filtersApi.d.ts +32 -0
- package/esm/filters/filtersApi.js +36 -0
- package/esm/filters/filtersInterfaces.d.ts +56 -0
- package/esm/filters/filtersInterfaces.js +1 -0
- package/esm/filters/filtersSchemas.d.ts +32 -0
- package/esm/filters/filtersSchemas.js +29 -0
- package/esm/forms/formsApi.d.ts +44 -0
- package/esm/forms/formsApi.js +54 -0
- package/esm/forms/formsInterfaces.d.ts +237 -0
- package/esm/forms/formsInterfaces.js +1 -0
- package/esm/forms/formsSchemas.d.ts +56 -0
- package/esm/forms/formsSchemas.js +32 -0
- package/esm/forms-data/formsDataApi.d.ts +124 -0
- package/esm/forms-data/formsDataApi.js +210 -0
- package/esm/forms-data/formsDataInterfaces.d.ts +670 -0
- package/esm/forms-data/formsDataInterfaces.js +1 -0
- package/esm/forms-data/formsDataSchemas.d.ts +107 -0
- package/esm/forms-data/formsDataSchemas.js +83 -0
- package/esm/general-types/generalTypesApi.d.ts +29 -0
- package/esm/general-types/generalTypesApi.js +34 -0
- package/esm/general-types/generalTypesInterfaces.d.ts +29 -0
- package/esm/general-types/generalTypesInterfaces.js +1 -0
- package/esm/general-types/generalTypesSchemas.d.ts +68 -0
- package/esm/general-types/generalTypesSchemas.js +42 -0
- package/esm/index.d.ts +143 -0
- package/esm/index.js +124 -0
- package/esm/integration-collections/integrationCollectionsApi.d.ts +172 -0
- package/esm/integration-collections/integrationCollectionsApi.js +224 -0
- package/esm/integration-collections/integrationCollectionsInterfaces.d.ts +317 -0
- package/esm/integration-collections/integrationCollectionsInterfaces.js +1 -0
- package/esm/integration-collections/integrationCollectionsSchemas.d.ts +84 -0
- package/esm/integration-collections/integrationCollectionsSchemas.js +60 -0
- package/esm/locales/localesApi.d.ts +28 -0
- package/esm/locales/localesApi.js +33 -0
- package/esm/locales/localesInterfaces.d.ts +40 -0
- package/esm/locales/localesInterfaces.js +1 -0
- package/esm/locales/localesSchemas.d.ts +32 -0
- package/esm/locales/localesSchemas.js +23 -0
- package/esm/menus/menusApi.d.ts +30 -0
- package/esm/menus/menusApi.js +35 -0
- package/esm/menus/menusInterfaces.d.ts +87 -0
- package/esm/menus/menusInterfaces.js +2 -0
- package/esm/menus/menusSchemas.d.ts +16 -0
- package/esm/menus/menusSchemas.js +25 -0
- package/esm/orders/ordersApi.d.ts +213 -0
- package/esm/orders/ordersApi.js +288 -0
- package/esm/orders/ordersInterfaces.d.ts +763 -0
- package/esm/orders/ordersInterfaces.js +1 -0
- package/esm/orders/ordersSchemas.d.ts +312 -0
- package/esm/orders/ordersSchemas.js +171 -0
- package/esm/package.json +4 -0
- package/esm/pages/pagesApi.d.ts +173 -0
- package/esm/pages/pagesApi.js +414 -0
- package/esm/pages/pagesInterfaces.d.ts +344 -0
- package/esm/pages/pagesInterfaces.js +1 -0
- package/esm/pages/pagesSchemas.d.ts +121 -0
- package/esm/pages/pagesSchemas.js +60 -0
- package/esm/payments/paymentsApi.d.ts +88 -0
- package/esm/payments/paymentsApi.js +122 -0
- package/esm/payments/paymentsInterfaces.d.ts +189 -0
- package/esm/payments/paymentsInterfaces.js +1 -0
- package/esm/payments/paymentsSchemas.d.ts +94 -0
- package/esm/payments/paymentsSchemas.js +53 -0
- package/esm/product-statuses/productStatusesApi.d.ts +50 -0
- package/esm/product-statuses/productStatusesApi.js +68 -0
- package/esm/product-statuses/productStatusesInterfaces.d.ts +62 -0
- package/esm/product-statuses/productStatusesInterfaces.js +1 -0
- package/esm/product-statuses/productStatusesSchemas.d.ts +34 -0
- package/esm/product-statuses/productStatusesSchemas.js +27 -0
- package/esm/products/productsApi.d.ts +366 -0
- package/esm/products/productsApi.js +468 -0
- package/esm/products/productsInterfaces.d.ts +723 -0
- package/esm/products/productsInterfaces.js +1 -0
- package/esm/products/productsSchemas.d.ts +234 -0
- package/esm/products/productsSchemas.js +121 -0
- package/esm/search/searchApi.d.ts +35 -0
- package/esm/search/searchApi.js +47 -0
- package/esm/search/searchInterfaces.d.ts +94 -0
- package/esm/search/searchInterfaces.js +1 -0
- package/esm/search/searchSchemas.d.ts +73 -0
- package/esm/search/searchSchemas.js +41 -0
- package/esm/sitemap/sitemapApi.d.ts +37 -0
- package/esm/sitemap/sitemapApi.js +41 -0
- package/esm/sitemap/sitemapInterfaces.d.ts +51 -0
- package/esm/sitemap/sitemapInterfaces.js +1 -0
- package/esm/subscriptions/subscriptionsApi.d.ts +74 -0
- package/esm/subscriptions/subscriptionsApi.js +90 -0
- package/esm/subscriptions/subscriptionsInterfaces.d.ts +111 -0
- package/esm/subscriptions/subscriptionsInterfaces.js +1 -0
- package/esm/subscriptions/subscriptionsSchemas.d.ts +46 -0
- package/esm/subscriptions/subscriptionsSchemas.js +38 -0
- package/esm/system/systemApi.d.ts +46 -0
- package/esm/system/systemApi.js +53 -0
- package/esm/system/systemInterfaces.d.ts +29 -0
- package/esm/system/systemInterfaces.js +1 -0
- package/esm/templates/templatesApi.d.ts +53 -0
- package/esm/templates/templatesApi.js +78 -0
- package/esm/templates/templatesInterfaces.d.ts +68 -0
- package/esm/templates/templatesInterfaces.js +1 -0
- package/esm/templates/templatesSchemas.d.ts +48 -0
- package/esm/templates/templatesSchemas.js +28 -0
- package/esm/templates-preview/templatesPreviewApi.d.ts +40 -0
- package/esm/templates-preview/templatesPreviewApi.js +50 -0
- package/esm/templates-preview/templatesPreviewInterfaces.d.ts +129 -0
- package/esm/templates-preview/templatesPreviewInterfaces.js +1 -0
- package/esm/templates-preview/templatesPreviewSchemas.d.ts +79 -0
- package/esm/templates-preview/templatesPreviewSchemas.js +43 -0
- package/esm/types.d.ts +35 -0
- package/esm/types.js +1 -0
- package/esm/user-activity/userActivityApi.d.ts +31 -0
- package/esm/user-activity/userActivityApi.js +37 -0
- package/esm/user-activity/userActivityInterfaces.d.ts +42 -0
- package/esm/user-activity/userActivityInterfaces.js +1 -0
- package/esm/users/usersApi.d.ts +249 -0
- package/esm/users/usersApi.js +312 -0
- package/esm/users/usersInterfaces.d.ts +419 -0
- package/esm/users/usersInterfaces.js +1 -0
- package/esm/users/usersSchemas.d.ts +72 -0
- package/esm/users/usersSchemas.js +55 -0
- package/esm/web-socket/lazySocket.d.ts +18 -0
- package/esm/web-socket/lazySocket.js +67 -0
- package/esm/web-socket/wsApi.d.ts +27 -0
- package/esm/web-socket/wsApi.js +43 -0
- package/esm/web-socket/wsInterfaces.d.ts +16 -0
- package/esm/web-socket/wsInterfaces.js +1 -0
- package/package.json +47 -2
- package/types.d.ts +1 -0
- package/types.js +1 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import AsyncModules from '../base/asyncModules.js';
|
|
2
|
+
import type StateModule from '../base/stateModule.js';
|
|
3
|
+
import type { IError } from '../base/utils.js';
|
|
4
|
+
import type { ISitemapApi, ISitemapQuery } from './sitemapInterfaces.js';
|
|
5
|
+
/**
|
|
6
|
+
* Controllers for working with sitemaps.
|
|
7
|
+
* @handle /api/content/sitemap
|
|
8
|
+
* @class SitemapApi
|
|
9
|
+
* @augments AsyncModules
|
|
10
|
+
* @implements {ISitemapApi}
|
|
11
|
+
*/
|
|
12
|
+
export default class SitemapApi extends AsyncModules implements ISitemapApi {
|
|
13
|
+
protected state: StateModule;
|
|
14
|
+
protected _url: string;
|
|
15
|
+
/**
|
|
16
|
+
* Constructor for SitemapApi class.
|
|
17
|
+
* @param {StateModule} state - The state module.
|
|
18
|
+
*/
|
|
19
|
+
constructor(state: StateModule);
|
|
20
|
+
/**
|
|
21
|
+
* Retrieves the set of sitemaps.
|
|
22
|
+
* @handleName getSitemap
|
|
23
|
+
* @returns {Promise<string[] | IError>} Returns an array of sitemap URLs.
|
|
24
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
25
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/sitemap/getSitemap getSitemap} documentation.
|
|
26
|
+
*/
|
|
27
|
+
getSitemap(): Promise<string[] | IError>;
|
|
28
|
+
/**
|
|
29
|
+
* Generates a new set of sitemaps.
|
|
30
|
+
* @handleName updateSitemap
|
|
31
|
+
* @param {ISitemapQuery} body - Sitemap body params (e.g. `{ baseUrls: { en_US: "https://…" } }`).
|
|
32
|
+
* @returns {Promise<string[] | IError>} Returns an array of generated sitemap URLs.
|
|
33
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
34
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/sitemap/updateSitemap updateSitemap} documentation.
|
|
35
|
+
*/
|
|
36
|
+
updateSitemap(body: ISitemapQuery): Promise<string[] | IError>;
|
|
37
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import AsyncModules from '../base/asyncModules.js';
|
|
2
|
+
/**
|
|
3
|
+
* Controllers for working with sitemaps.
|
|
4
|
+
* @handle /api/content/sitemap
|
|
5
|
+
* @class SitemapApi
|
|
6
|
+
* @augments AsyncModules
|
|
7
|
+
* @implements {ISitemapApi}
|
|
8
|
+
*/
|
|
9
|
+
export default class SitemapApi extends AsyncModules {
|
|
10
|
+
/**
|
|
11
|
+
* Constructor for SitemapApi class.
|
|
12
|
+
* @param {StateModule} state - The state module.
|
|
13
|
+
*/
|
|
14
|
+
constructor(state) {
|
|
15
|
+
super(state);
|
|
16
|
+
this._url = state.url + '/api/content/sitemap';
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Retrieves the set of sitemaps.
|
|
20
|
+
* @handleName getSitemap
|
|
21
|
+
* @returns {Promise<string[] | IError>} Returns an array of sitemap URLs.
|
|
22
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
23
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/sitemap/getSitemap getSitemap} documentation.
|
|
24
|
+
*/
|
|
25
|
+
async getSitemap() {
|
|
26
|
+
const data = await this._fetchGet(`/`);
|
|
27
|
+
return this._normalizeData(data);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Generates a new set of sitemaps.
|
|
31
|
+
* @handleName updateSitemap
|
|
32
|
+
* @param {ISitemapQuery} body - Sitemap body params (e.g. `{ baseUrls: { en_US: "https://…" } }`).
|
|
33
|
+
* @returns {Promise<string[] | IError>} Returns an array of generated sitemap URLs.
|
|
34
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
35
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/sitemap/updateSitemap updateSitemap} documentation.
|
|
36
|
+
*/
|
|
37
|
+
async updateSitemap(body) {
|
|
38
|
+
const data = await this._fetchPost(`/`, body);
|
|
39
|
+
return this._normalizeData(data);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { IError } from '../base/utils.js';
|
|
2
|
+
/**
|
|
3
|
+
* Interface for the Sitemap API module.
|
|
4
|
+
* @interface ISitemapApi
|
|
5
|
+
*/
|
|
6
|
+
interface ISitemapApi {
|
|
7
|
+
/**
|
|
8
|
+
* Retrieves the set of sitemaps.
|
|
9
|
+
* @handleName getSitemap
|
|
10
|
+
* @returns {Promise<Array<string> | IError>}
|
|
11
|
+
*/
|
|
12
|
+
getSitemap(): Promise<Array<string> | IError>;
|
|
13
|
+
/**
|
|
14
|
+
* Generates a new set of sitemaps.
|
|
15
|
+
* @handleName updateSitemap
|
|
16
|
+
* @param {ISitemapQuery} body - Sitemap body params.
|
|
17
|
+
* @returns {Promise<string[] | IError>} Returns an array of generated sitemap URLs.
|
|
18
|
+
*/
|
|
19
|
+
updateSitemap(body: ISitemapQuery): Promise<string[] | IError>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Query parameters for sitemap requests.
|
|
23
|
+
* @interface ISitemapQuery
|
|
24
|
+
* @property {Record<string, string>} [baseUrls] - Base URLs per language for sitemap generation. Example: `{ "en_US": "https://example.com/" }`.
|
|
25
|
+
* @property {string} [url] - URL of a single sitemap entry.
|
|
26
|
+
* @property {string} [lastmod] - Last modification date of the entry.
|
|
27
|
+
* @property {string} [changefreq] - Frequency of changes for the entry.
|
|
28
|
+
* @property {number} [priority] - Priority of the entry.
|
|
29
|
+
*/
|
|
30
|
+
interface ISitemapQuery {
|
|
31
|
+
baseUrls?: Record<string, string>;
|
|
32
|
+
url?: string;
|
|
33
|
+
lastmod?: string;
|
|
34
|
+
changefreq?: string;
|
|
35
|
+
priority?: number;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Entity interface for sitemap.
|
|
39
|
+
* @interface ISitemapEntity
|
|
40
|
+
* @property {string} url - URL of the sitemap.
|
|
41
|
+
* @property {string} lastmod - Last modification date of the sitemap.
|
|
42
|
+
* @property {string} changefreq - Frequency of changes for the sitemap.
|
|
43
|
+
* @property {number} priority - Priority of the sitemap.
|
|
44
|
+
*/
|
|
45
|
+
interface ISitemapEntity {
|
|
46
|
+
url: string;
|
|
47
|
+
lastmod: string;
|
|
48
|
+
changefreq: string;
|
|
49
|
+
priority: number;
|
|
50
|
+
}
|
|
51
|
+
export type { ISitemapApi, ISitemapEntity, ISitemapQuery };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import AsyncModules from '../base/asyncModules.js';
|
|
2
|
+
import type StateModule from '../base/stateModule.js';
|
|
3
|
+
import type { IError } from '../base/utils.js';
|
|
4
|
+
import type { ICancelSubscription, ICreatedSubscription, ISubscribe, ISubscriptionEntity, ISubscriptionsApi } from './subscriptionsInterfaces.js';
|
|
5
|
+
/**
|
|
6
|
+
* Controllers for working with paid subscriptions.
|
|
7
|
+
* @handle /api/content/subscriptions
|
|
8
|
+
* @class SubscriptionsApi
|
|
9
|
+
* @augments AsyncModules
|
|
10
|
+
* @implements {ISubscriptionsApi}
|
|
11
|
+
* @description This class provides methods to interact with paid subscriptions: creating, cancelling, recovering, and listing available/active subscriptions.
|
|
12
|
+
*/
|
|
13
|
+
export default class SubscriptionsApi extends AsyncModules implements ISubscriptionsApi {
|
|
14
|
+
protected state: StateModule;
|
|
15
|
+
protected _url: string;
|
|
16
|
+
/**
|
|
17
|
+
* Constructor for SubscriptionsApi class.
|
|
18
|
+
* @param {StateModule} state - The state module.
|
|
19
|
+
*/
|
|
20
|
+
constructor(state: StateModule);
|
|
21
|
+
/**
|
|
22
|
+
* Create a new subscription and get a payment session for it.
|
|
23
|
+
* @handleName subscribe
|
|
24
|
+
* @param {ISubscribe} body - Subscription body. Example: `{ marker: "premium" }`.
|
|
25
|
+
* @returns {Promise<ICreatedSubscription | IError>} Returns the created payment session for the subscription.
|
|
26
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
27
|
+
* @description This method requires user authorization.
|
|
28
|
+
* @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}.
|
|
29
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/subscriptions/subscribe subscribe} documentation.
|
|
30
|
+
*/
|
|
31
|
+
subscribe(body: ISubscribe): Promise<ICreatedSubscription | IError>;
|
|
32
|
+
/**
|
|
33
|
+
* Cancel a subscription.
|
|
34
|
+
* @handleName cancelSubscription
|
|
35
|
+
* @param {ICancelSubscription} body - Subscription body. Example: `{ marker: "premium" }`.
|
|
36
|
+
* @returns {Promise<boolean | IError>} Returns true if the subscription was cancelled, or an error object if there was an issue.
|
|
37
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
38
|
+
* @description This method requires user authorization.
|
|
39
|
+
* @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}.
|
|
40
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/subscriptions/cancelSubscription cancelSubscription} documentation.
|
|
41
|
+
*/
|
|
42
|
+
cancelSubscription(body: ICancelSubscription): Promise<boolean | IError>;
|
|
43
|
+
/**
|
|
44
|
+
* Get all available subscriptions.
|
|
45
|
+
* @handleName getAllSubscriptions
|
|
46
|
+
* @returns {Promise<ISubscriptionEntity[] | IError>} Returns an array of available subscriptions.
|
|
47
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
48
|
+
* @description This method requires user authorization.
|
|
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
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/subscriptions/getAllSubscriptions getAllSubscriptions} documentation.
|
|
51
|
+
*/
|
|
52
|
+
getAllSubscriptions(): Promise<ISubscriptionEntity[] | IError>;
|
|
53
|
+
/**
|
|
54
|
+
* Get markers of the user's active subscriptions.
|
|
55
|
+
* @handleName getActiveSubscriptions
|
|
56
|
+
* @returns {Promise<string[] | IError>} Returns an array of active subscription markers.
|
|
57
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
58
|
+
* @description This method requires user authorization.
|
|
59
|
+
* @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}.
|
|
60
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/subscriptions/getActiveSubscriptions getActiveSubscriptions} documentation.
|
|
61
|
+
*/
|
|
62
|
+
getActiveSubscriptions(): Promise<string[] | IError>;
|
|
63
|
+
/**
|
|
64
|
+
* Recover a subscription through the Stripe Billing Portal.
|
|
65
|
+
* @handleName recoverSubscriptions
|
|
66
|
+
* @param {ICancelSubscription} body - Subscription body. Example: `{ marker: "premium" }`.
|
|
67
|
+
* @returns {Promise<boolean | IError>} Returns true if the recovery request was accepted, or an error object if there was an issue.
|
|
68
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
69
|
+
* @description This method requires user authorization.
|
|
70
|
+
* @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}.
|
|
71
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/subscriptions/recoverSubscriptions recoverSubscriptions} documentation.
|
|
72
|
+
*/
|
|
73
|
+
recoverSubscriptions(body: ICancelSubscription): Promise<boolean | IError>;
|
|
74
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import AsyncModules from '../base/asyncModules.js';
|
|
2
|
+
import createSchemaLoader from '../base/lazySchema.js';
|
|
3
|
+
const schema = createSchemaLoader(() => import('./subscriptionsSchemas.js'));
|
|
4
|
+
/**
|
|
5
|
+
* Controllers for working with paid subscriptions.
|
|
6
|
+
* @handle /api/content/subscriptions
|
|
7
|
+
* @class SubscriptionsApi
|
|
8
|
+
* @augments AsyncModules
|
|
9
|
+
* @implements {ISubscriptionsApi}
|
|
10
|
+
* @description This class provides methods to interact with paid subscriptions: creating, cancelling, recovering, and listing available/active subscriptions.
|
|
11
|
+
*/
|
|
12
|
+
export default class SubscriptionsApi extends AsyncModules {
|
|
13
|
+
/**
|
|
14
|
+
* Constructor for SubscriptionsApi class.
|
|
15
|
+
* @param {StateModule} state - The state module.
|
|
16
|
+
*/
|
|
17
|
+
constructor(state) {
|
|
18
|
+
super(state);
|
|
19
|
+
this._url = state.url + '/api/content/subscriptions';
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Create a new subscription and get a payment session for it.
|
|
23
|
+
* @handleName subscribe
|
|
24
|
+
* @param {ISubscribe} body - Subscription body. Example: `{ marker: "premium" }`.
|
|
25
|
+
* @returns {Promise<ICreatedSubscription | IError>} Returns the created payment session for the subscription.
|
|
26
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
27
|
+
* @description This method requires user authorization.
|
|
28
|
+
* @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}.
|
|
29
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/subscriptions/subscribe subscribe} documentation.
|
|
30
|
+
*/
|
|
31
|
+
async subscribe(body) {
|
|
32
|
+
const data = await this._fetchPost(``, body);
|
|
33
|
+
const validated = await this._validateResponse(data, schema('CreatedSubscriptionSchema'));
|
|
34
|
+
return this._normalizeData(validated);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Cancel a subscription.
|
|
38
|
+
* @handleName cancelSubscription
|
|
39
|
+
* @param {ICancelSubscription} body - Subscription body. Example: `{ marker: "premium" }`.
|
|
40
|
+
* @returns {Promise<boolean | IError>} Returns true if the subscription was cancelled, or an error object if there was an issue.
|
|
41
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
42
|
+
* @description This method requires user authorization.
|
|
43
|
+
* @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}.
|
|
44
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/subscriptions/cancelSubscription cancelSubscription} documentation.
|
|
45
|
+
*/
|
|
46
|
+
async cancelSubscription(body) {
|
|
47
|
+
return this._fetchBoolean(() => this._fetchDelete(``, body));
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Get all available subscriptions.
|
|
51
|
+
* @handleName getAllSubscriptions
|
|
52
|
+
* @returns {Promise<ISubscriptionEntity[] | IError>} Returns an array of available subscriptions.
|
|
53
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
54
|
+
* @description This method requires user authorization.
|
|
55
|
+
* @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
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/subscriptions/getAllSubscriptions getAllSubscriptions} documentation.
|
|
57
|
+
*/
|
|
58
|
+
async getAllSubscriptions() {
|
|
59
|
+
const data = await this._fetchGet(``);
|
|
60
|
+
const validated = await this._validateResponse(data, schema('SubscriptionsListSchema'));
|
|
61
|
+
return this._normalizeData(validated);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Get markers of the user's active subscriptions.
|
|
65
|
+
* @handleName getActiveSubscriptions
|
|
66
|
+
* @returns {Promise<string[] | IError>} Returns an array of active subscription markers.
|
|
67
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
68
|
+
* @description This method requires user authorization.
|
|
69
|
+
* @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}.
|
|
70
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/subscriptions/getActiveSubscriptions getActiveSubscriptions} documentation.
|
|
71
|
+
*/
|
|
72
|
+
async getActiveSubscriptions() {
|
|
73
|
+
const data = await this._fetchGet(`/active`);
|
|
74
|
+
const validated = await this._validateResponse(data, schema('SubscriptionMarkersSchema'));
|
|
75
|
+
return this._normalizeData(validated);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Recover a subscription through the Stripe Billing Portal.
|
|
79
|
+
* @handleName recoverSubscriptions
|
|
80
|
+
* @param {ICancelSubscription} body - Subscription body. Example: `{ marker: "premium" }`.
|
|
81
|
+
* @returns {Promise<boolean | IError>} Returns true if the recovery request was accepted, or an error object if there was an issue.
|
|
82
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
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}.
|
|
85
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/subscriptions/recoverSubscriptions recoverSubscriptions} documentation.
|
|
86
|
+
*/
|
|
87
|
+
async recoverSubscriptions(body) {
|
|
88
|
+
return this._fetchBoolean(() => this._fetchPost(`/recover`, body));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { IError, ILocalizeInfo } from '../base/utils.js';
|
|
2
|
+
/**
|
|
3
|
+
* Interface for the Subscriptions API module.
|
|
4
|
+
* @interface ISubscriptionsApi
|
|
5
|
+
* @description This interface defines methods for managing paid subscriptions: creating, cancelling, recovering, and listing available/active subscriptions.
|
|
6
|
+
*/
|
|
7
|
+
interface ISubscriptionsApi {
|
|
8
|
+
/**
|
|
9
|
+
* Create a new subscription and get a payment session for it.
|
|
10
|
+
* @handleName subscribe
|
|
11
|
+
* @param {ISubscribe} body - Subscription body. Example: `{ marker: "premium" }`.
|
|
12
|
+
* @returns {Promise<ICreatedSubscription | IError>} Returns the created payment session for the subscription.
|
|
13
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
14
|
+
* @description This method requires user authorization.
|
|
15
|
+
* @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}.
|
|
16
|
+
*/
|
|
17
|
+
subscribe(body: ISubscribe): Promise<ICreatedSubscription | IError>;
|
|
18
|
+
/**
|
|
19
|
+
* Cancel a subscription.
|
|
20
|
+
* @handleName cancelSubscription
|
|
21
|
+
* @param {ICancelSubscription} body - Subscription body. Example: `{ marker: "premium" }`.
|
|
22
|
+
* @returns {Promise<boolean | IError>} Returns true if the subscription was cancelled, or an error object if there was an issue.
|
|
23
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
24
|
+
* @description This method requires user authorization.
|
|
25
|
+
* @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}.
|
|
26
|
+
*/
|
|
27
|
+
cancelSubscription(body: ICancelSubscription): Promise<boolean | IError>;
|
|
28
|
+
/**
|
|
29
|
+
* Get all available subscriptions.
|
|
30
|
+
* @handleName getAllSubscriptions
|
|
31
|
+
* @returns {Promise<ISubscriptionEntity[] | IError>} Returns an array of available subscriptions.
|
|
32
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
33
|
+
* @description This method requires user authorization.
|
|
34
|
+
* @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}.
|
|
35
|
+
*/
|
|
36
|
+
getAllSubscriptions(): Promise<ISubscriptionEntity[] | IError>;
|
|
37
|
+
/**
|
|
38
|
+
* Get markers of the user's active subscriptions.
|
|
39
|
+
* @handleName getActiveSubscriptions
|
|
40
|
+
* @returns {Promise<string[] | IError>} Returns an array of active subscription markers.
|
|
41
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
42
|
+
* @description This method requires user authorization.
|
|
43
|
+
* @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}.
|
|
44
|
+
*/
|
|
45
|
+
getActiveSubscriptions(): Promise<string[] | IError>;
|
|
46
|
+
/**
|
|
47
|
+
* Recover a subscription through the Stripe Billing Portal.
|
|
48
|
+
* @handleName recoverSubscriptions
|
|
49
|
+
* @param {ICancelSubscription} body - Subscription body. Example: `{ marker: "premium" }`.
|
|
50
|
+
* @returns {Promise<boolean | IError>} Returns true if the recovery request was accepted, or an error object if there was an issue.
|
|
51
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
52
|
+
* @description This method requires user authorization.
|
|
53
|
+
* @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}.
|
|
54
|
+
*/
|
|
55
|
+
recoverSubscriptions(body: ICancelSubscription): Promise<boolean | IError>;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Body for creating a subscription.
|
|
59
|
+
* @interface ISubscribe
|
|
60
|
+
* @property {string} marker - Subscription marker. Example: "premium".
|
|
61
|
+
* @description Body for creating a subscription.
|
|
62
|
+
*/
|
|
63
|
+
interface ISubscribe {
|
|
64
|
+
marker: string;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Body for cancelling or recovering a subscription.
|
|
68
|
+
* @interface ICancelSubscription
|
|
69
|
+
* @property {string} marker - Subscription marker. Example: "premium".
|
|
70
|
+
* @description Body for cancelling or recovering a subscription.
|
|
71
|
+
*/
|
|
72
|
+
interface ICancelSubscription {
|
|
73
|
+
marker: string;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Created subscription payment session.
|
|
77
|
+
* @interface ICreatedSubscription
|
|
78
|
+
* @property {number} id - Payment session identifier. Example: 1.
|
|
79
|
+
* @property {number} amount - Amount to be paid. Example: 100.
|
|
80
|
+
* @property {string} paymentUrl - Payment page URL. Example: "https://checkout.stripe.com/c/pay/...".
|
|
81
|
+
* @property {string} status - Payment session status. Example: "waiting".
|
|
82
|
+
* @description Created subscription payment session returned after subscribing.
|
|
83
|
+
*/
|
|
84
|
+
interface ICreatedSubscription {
|
|
85
|
+
id: number;
|
|
86
|
+
amount: number;
|
|
87
|
+
paymentUrl: string;
|
|
88
|
+
status: string;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Available subscription.
|
|
92
|
+
* @interface ISubscriptionEntity
|
|
93
|
+
* @property {number} id - Subscription identifier. Example: 1.
|
|
94
|
+
* @property {string} identifier - Subscription textual identifier (marker). Example: "test_subscription".
|
|
95
|
+
* @property {ILocalizeInfo} localizeInfos - Localized subscription info for the current language. Example: `{ title: "Test subscription" }`.
|
|
96
|
+
* @property {number[]} productIds - Identifiers of the products included in the subscription. Example: [3445].
|
|
97
|
+
* @property {number} periodInDays - Subscription period in days. Example: 30.
|
|
98
|
+
* @property {number} paymentAccountId - Identifier of the payment account the subscription is billed through. Example: 1.
|
|
99
|
+
* @property {boolean} isUsed - Indicates whether the subscription is in use. Example: false.
|
|
100
|
+
* @description Subscription configured in the project, returned by getAllSubscriptions.
|
|
101
|
+
*/
|
|
102
|
+
interface ISubscriptionEntity {
|
|
103
|
+
id: number;
|
|
104
|
+
identifier: string;
|
|
105
|
+
localizeInfos: ILocalizeInfo;
|
|
106
|
+
productIds: number[];
|
|
107
|
+
periodInDays: number;
|
|
108
|
+
paymentAccountId: number;
|
|
109
|
+
isUsed: boolean;
|
|
110
|
+
}
|
|
111
|
+
export type { ICancelSubscription, ICreatedSubscription, ISubscribe, ISubscriptionEntity, ISubscriptionsApi, };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation schemas for Subscriptions module
|
|
3
|
+
* @description Zod schemas for validating subscriptions-related API responses
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
/**
|
|
7
|
+
* Created subscription schema
|
|
8
|
+
* @description Schema for the payment session returned after creating a subscription
|
|
9
|
+
*/
|
|
10
|
+
export declare const CreatedSubscriptionSchema: z.ZodObject<{
|
|
11
|
+
id: z.ZodNumber;
|
|
12
|
+
amount: z.ZodNumber;
|
|
13
|
+
paymentUrl: z.ZodString;
|
|
14
|
+
status: z.ZodString;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
/**
|
|
17
|
+
* Subscription entity schema
|
|
18
|
+
* @description Schema for an available subscription as returned by the API (localizeInfos kept as a locale map)
|
|
19
|
+
*/
|
|
20
|
+
export declare const SubscriptionEntitySchema: z.ZodObject<{
|
|
21
|
+
id: z.ZodNumber;
|
|
22
|
+
identifier: z.ZodString;
|
|
23
|
+
localizeInfos: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
24
|
+
productIds: z.ZodArray<z.ZodNumber>;
|
|
25
|
+
periodInDays: z.ZodNumber;
|
|
26
|
+
paymentAccountId: z.ZodNumber;
|
|
27
|
+
isUsed: z.ZodBoolean;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
/**
|
|
30
|
+
* Subscriptions list schema
|
|
31
|
+
* @description Schema for the array of available subscriptions returned by getAllSubscriptions
|
|
32
|
+
*/
|
|
33
|
+
export declare const SubscriptionsListSchema: z.ZodArray<z.ZodObject<{
|
|
34
|
+
id: z.ZodNumber;
|
|
35
|
+
identifier: z.ZodString;
|
|
36
|
+
localizeInfos: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
37
|
+
productIds: z.ZodArray<z.ZodNumber>;
|
|
38
|
+
periodInDays: z.ZodNumber;
|
|
39
|
+
paymentAccountId: z.ZodNumber;
|
|
40
|
+
isUsed: z.ZodBoolean;
|
|
41
|
+
}, z.core.$strip>>;
|
|
42
|
+
/**
|
|
43
|
+
* Subscription markers schema
|
|
44
|
+
* @description Schema for the array of active subscription markers returned by getActiveSubscriptions
|
|
45
|
+
*/
|
|
46
|
+
export declare const SubscriptionMarkersSchema: z.ZodArray<z.ZodString>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation schemas for Subscriptions module
|
|
3
|
+
* @description Zod schemas for validating subscriptions-related API responses
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
/**
|
|
7
|
+
* Created subscription schema
|
|
8
|
+
* @description Schema for the payment session returned after creating a subscription
|
|
9
|
+
*/
|
|
10
|
+
export const CreatedSubscriptionSchema = z.object({
|
|
11
|
+
id: z.number(),
|
|
12
|
+
amount: z.number(),
|
|
13
|
+
paymentUrl: z.string(),
|
|
14
|
+
status: z.string(),
|
|
15
|
+
});
|
|
16
|
+
/**
|
|
17
|
+
* Subscription entity schema
|
|
18
|
+
* @description Schema for an available subscription as returned by the API (localizeInfos kept as a locale map)
|
|
19
|
+
*/
|
|
20
|
+
export const SubscriptionEntitySchema = z.object({
|
|
21
|
+
id: z.number(),
|
|
22
|
+
identifier: z.string(),
|
|
23
|
+
localizeInfos: z.record(z.string(), z.any()),
|
|
24
|
+
productIds: z.array(z.number()),
|
|
25
|
+
periodInDays: z.number(),
|
|
26
|
+
paymentAccountId: z.number(),
|
|
27
|
+
isUsed: z.boolean(),
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* Subscriptions list schema
|
|
31
|
+
* @description Schema for the array of available subscriptions returned by getAllSubscriptions
|
|
32
|
+
*/
|
|
33
|
+
export const SubscriptionsListSchema = z.array(SubscriptionEntitySchema);
|
|
34
|
+
/**
|
|
35
|
+
* Subscription markers schema
|
|
36
|
+
* @description Schema for the array of active subscription markers returned by getActiveSubscriptions
|
|
37
|
+
*/
|
|
38
|
+
export const SubscriptionMarkersSchema = z.array(z.string());
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import AsyncModules from '../base/asyncModules.js';
|
|
2
|
+
import type StateModule from '../base/stateModule.js';
|
|
3
|
+
import type { IError } from '../base/utils.js';
|
|
4
|
+
import type { ISystemApi } from './systemInterfaces.js';
|
|
5
|
+
/**
|
|
6
|
+
* Controllers for working with system components
|
|
7
|
+
* @handle /api/content/system
|
|
8
|
+
* @description Controllers for working with system components
|
|
9
|
+
*/
|
|
10
|
+
export default class SystemApi extends AsyncModules implements ISystemApi {
|
|
11
|
+
protected state: StateModule;
|
|
12
|
+
protected _url: string;
|
|
13
|
+
/**
|
|
14
|
+
* Constructor
|
|
15
|
+
* @param {StateModule} state - The state module.
|
|
16
|
+
* @description Constructor initializes the SystemApi with a given state.
|
|
17
|
+
*/
|
|
18
|
+
constructor(state: StateModule);
|
|
19
|
+
/**
|
|
20
|
+
* Sends a GET request to the '/test404' endpoint and returns the result.
|
|
21
|
+
* @handleName test404
|
|
22
|
+
* @returns {Promise<unknown | IError>} The response from the server after fetching data from the '/test404' endpoint.
|
|
23
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
24
|
+
* @description This method is used to test the 404 error handling by sending a GET request to a specific endpoint.
|
|
25
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/system/test404 test404} documentation.
|
|
26
|
+
*/
|
|
27
|
+
test404(): Promise<unknown | IError>;
|
|
28
|
+
/**
|
|
29
|
+
* Sends a GET request to the '/test500' endpoint and returns the result.
|
|
30
|
+
* @handleName test500
|
|
31
|
+
* @returns {Promise<unknown | IError>} The response from the server after fetching data from the '/test500' endpoint.
|
|
32
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
33
|
+
* @description This method is used to test the 500 error handling by sending a GET request to a specific endpoint.
|
|
34
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/system/test500 test500} documentation.
|
|
35
|
+
*/
|
|
36
|
+
test500(): Promise<unknown | IError>;
|
|
37
|
+
/**
|
|
38
|
+
* Getting the number of requests to API.
|
|
39
|
+
* @handleName getApiStat
|
|
40
|
+
* @returns {Promise<unknown | IError>} Return object with date and count.
|
|
41
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
42
|
+
* @description Getting the number of requests to API.
|
|
43
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/system/getApiStat getApiStat} documentation.
|
|
44
|
+
*/
|
|
45
|
+
getApiStat(): Promise<unknown>;
|
|
46
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import AsyncModules from '../base/asyncModules.js';
|
|
2
|
+
/**
|
|
3
|
+
* Controllers for working with system components
|
|
4
|
+
* @handle /api/content/system
|
|
5
|
+
* @description Controllers for working with system components
|
|
6
|
+
*/
|
|
7
|
+
export default class SystemApi extends AsyncModules {
|
|
8
|
+
/**
|
|
9
|
+
* Constructor
|
|
10
|
+
* @param {StateModule} state - The state module.
|
|
11
|
+
* @description Constructor initializes the SystemApi with a given state.
|
|
12
|
+
*/
|
|
13
|
+
constructor(state) {
|
|
14
|
+
super(state);
|
|
15
|
+
this._url = state.url + '/api/content/system';
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Sends a GET request to the '/test404' endpoint and returns the result.
|
|
19
|
+
* @handleName test404
|
|
20
|
+
* @returns {Promise<unknown | IError>} The response from the server after fetching data from the '/test404' endpoint.
|
|
21
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
22
|
+
* @description This method is used to test the 404 error handling by sending a GET request to a specific endpoint.
|
|
23
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/system/test404 test404} documentation.
|
|
24
|
+
*/
|
|
25
|
+
async test404() {
|
|
26
|
+
const result = await this._fetchGet('/test404');
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Sends a GET request to the '/test500' endpoint and returns the result.
|
|
31
|
+
* @handleName test500
|
|
32
|
+
* @returns {Promise<unknown | IError>} The response from the server after fetching data from the '/test500' endpoint.
|
|
33
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
34
|
+
* @description This method is used to test the 500 error handling by sending a GET request to a specific endpoint.
|
|
35
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/system/test500 test500} documentation.
|
|
36
|
+
*/
|
|
37
|
+
async test500() {
|
|
38
|
+
const result = await this._fetchGet('/test500');
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Getting the number of requests to API.
|
|
43
|
+
* @handleName getApiStat
|
|
44
|
+
* @returns {Promise<unknown | IError>} Return object with date and count.
|
|
45
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
46
|
+
* @description Getting the number of requests to API.
|
|
47
|
+
* @see {@link https://js-sdk.oneentry.cloud/docs/system/getApiStat getApiStat} documentation.
|
|
48
|
+
*/
|
|
49
|
+
async getApiStat() {
|
|
50
|
+
const result = await this._fetchGet('/api-stat');
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { IError } from '../base/utils.js';
|
|
2
|
+
/**
|
|
3
|
+
* @interface ISystemApi
|
|
4
|
+
* @description Represents a interface object of System Api.
|
|
5
|
+
*/
|
|
6
|
+
interface ISystemApi {
|
|
7
|
+
/**
|
|
8
|
+
* Test 404 error.
|
|
9
|
+
* @handleName test404
|
|
10
|
+
* @returns {unknown} Returns a Promise that resolves with any data.
|
|
11
|
+
* @description This method tests 404 error.
|
|
12
|
+
*/
|
|
13
|
+
test404(): Promise<unknown | IError>;
|
|
14
|
+
/**
|
|
15
|
+
* Test 500 error.
|
|
16
|
+
* @handleName test500
|
|
17
|
+
* @returns {unknown} Returns a Promise that resolves with any data.
|
|
18
|
+
* @description This method tests 500 error.
|
|
19
|
+
*/
|
|
20
|
+
test500(): Promise<unknown | IError>;
|
|
21
|
+
/**
|
|
22
|
+
* getApiStat
|
|
23
|
+
* @handleName getApiStat
|
|
24
|
+
* @returns {unknown} Returns a Promise that resolves with any data.
|
|
25
|
+
* @description This method getApiStat.
|
|
26
|
+
*/
|
|
27
|
+
getApiStat(): Promise<unknown>;
|
|
28
|
+
}
|
|
29
|
+
export type { ISystemApi };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|