oneentry 1.0.149 → 1.0.151
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 +8 -0
- package/changelog.md +453 -0
- package/dist/base/asyncModules.js +13 -0
- package/dist/base/stateModule.d.ts +1 -0
- package/dist/base/stateModule.js +3 -0
- package/dist/base/syncModules.d.ts +30 -1
- package/dist/base/syncModules.js +102 -30
- package/dist/base/utils.d.ts +4 -1
- package/dist/blocks/blocksApi.d.ts +124 -3
- package/dist/blocks/blocksApi.js +169 -4
- package/dist/blocks/blocksInterfaces.d.ts +177 -4
- package/dist/blocks/blocksSchemas.d.ts +4 -0
- package/dist/events/eventsApi.d.ts +42 -1
- package/dist/events/eventsApi.js +67 -0
- package/dist/events/eventsInterfaces.d.ts +79 -1
- package/dist/file-uploading/fileUploadingInterfaces.d.ts +2 -0
- package/dist/file-uploading/fileUploadingSchemas.d.ts +2 -0
- package/dist/file-uploading/fileUploadingSchemas.js +1 -0
- package/dist/filters/filtersApi.d.ts +31 -0
- package/dist/filters/filtersApi.js +40 -0
- package/dist/filters/filtersInterfaces.d.ts +56 -0
- package/dist/filters/filtersInterfaces.js +2 -0
- package/dist/filters/filtersSchemas.d.ts +32 -0
- package/dist/filters/filtersSchemas.js +29 -0
- package/dist/forms-data/formsDataInterfaces.d.ts +2 -2
- package/dist/forms-data/formsDataSchemas.d.ts +1 -1
- package/dist/forms-data/formsDataSchemas.js +1 -1
- package/dist/general-types/generalTypesSchemas.d.ts +16 -0
- package/dist/general-types/generalTypesSchemas.js +10 -1
- package/dist/index.d.ts +13 -0
- package/dist/index.js +10 -0
- package/dist/orders/ordersInterfaces.d.ts +51 -3
- package/dist/orders/ordersSchemas.d.ts +127 -31
- package/dist/orders/ordersSchemas.js +53 -30
- package/dist/pages/pagesInterfaces.d.ts +14 -8
- package/dist/pages/pagesSchemas.d.ts +24 -9
- package/dist/pages/pagesSchemas.js +4 -3
- package/dist/products/productsApi.d.ts +19 -1
- package/dist/products/productsApi.js +42 -8
- package/dist/products/productsInterfaces.d.ts +35 -6
- package/dist/products/productsSchemas.d.ts +4 -0
- package/dist/products/productsSchemas.js +1 -0
- package/dist/subscriptions/subscriptionsApi.d.ts +69 -0
- package/dist/subscriptions/subscriptionsApi.js +102 -0
- package/dist/subscriptions/subscriptionsInterfaces.d.ts +90 -0
- package/dist/subscriptions/subscriptionsInterfaces.js +2 -0
- package/dist/subscriptions/subscriptionsSchemas.d.ts +20 -0
- package/dist/subscriptions/subscriptionsSchemas.js +23 -0
- package/dist/user-activity/userActivityApi.d.ts +30 -0
- package/dist/user-activity/userActivityApi.js +42 -0
- package/dist/user-activity/userActivityInterfaces.d.ts +42 -0
- package/dist/user-activity/userActivityInterfaces.js +2 -0
- package/dist/users/usersApi.d.ts +79 -1
- package/dist/users/usersApi.js +110 -0
- package/dist/users/usersInterfaces.d.ts +155 -1
- package/dist/users/usersSchemas.d.ts +40 -0
- package/dist/users/usersSchemas.js +34 -1
- package/package.json +3 -2
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const asyncModules_1 = __importDefault(require("../base/asyncModules"));
|
|
7
|
+
const subscriptionsSchemas_1 = require("./subscriptionsSchemas");
|
|
8
|
+
/**
|
|
9
|
+
* Controllers for working with paid subscriptions.
|
|
10
|
+
* @handle /api/content/subscriptions
|
|
11
|
+
* @class SubscriptionsApi
|
|
12
|
+
* @augments AsyncModules
|
|
13
|
+
* @implements {ISubscriptionsApi}
|
|
14
|
+
* @description This class provides methods to interact with paid subscriptions: creating, cancelling, recovering, and listing available/active subscriptions.
|
|
15
|
+
*/
|
|
16
|
+
class SubscriptionsApi extends asyncModules_1.default {
|
|
17
|
+
/**
|
|
18
|
+
* Constructor for SubscriptionsApi class.
|
|
19
|
+
* @param {StateModule} state - The state module.
|
|
20
|
+
*/
|
|
21
|
+
constructor(state) {
|
|
22
|
+
super(state);
|
|
23
|
+
this._url = state.url + '/api/content/subscriptions';
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Create a new subscription and get a payment session for it.
|
|
27
|
+
* @handleName subscribe
|
|
28
|
+
* @param {ISubscribe} body - Subscription body. Example: `{ marker: "premium" }`.
|
|
29
|
+
* @returns {Promise<ICreatedSubscription | IError>} Returns the created payment session for the subscription.
|
|
30
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
31
|
+
* @description This method requires user authorization.
|
|
32
|
+
* @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}.
|
|
33
|
+
*/
|
|
34
|
+
async subscribe(body) {
|
|
35
|
+
const data = await this._fetchPost(``, body);
|
|
36
|
+
const validated = this._validateResponse(data, subscriptionsSchemas_1.CreatedSubscriptionSchema);
|
|
37
|
+
return this._normalizeData(validated);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Cancel a subscription.
|
|
41
|
+
* @handleName cancelSubscription
|
|
42
|
+
* @param {ICancelSubscription} body - Subscription body. Example: `{ marker: "premium" }`.
|
|
43
|
+
* @returns {Promise<boolean | IError>} Returns true if the subscription was cancelled, or an error object if there was an issue.
|
|
44
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
45
|
+
* @description This method requires user authorization.
|
|
46
|
+
* @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}.
|
|
47
|
+
*/
|
|
48
|
+
async cancelSubscription(body) {
|
|
49
|
+
try {
|
|
50
|
+
await this._fetchDelete(``, body);
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
catch (e) {
|
|
54
|
+
return e;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Get all available subscription markers.
|
|
59
|
+
* @handleName getAllSubscriptions
|
|
60
|
+
* @returns {Promise<string[] | IError>} Returns an array of available subscription markers.
|
|
61
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
62
|
+
* @description This method requires user authorization.
|
|
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}.
|
|
64
|
+
*/
|
|
65
|
+
async getAllSubscriptions() {
|
|
66
|
+
const data = await this._fetchGet(``);
|
|
67
|
+
const validated = this._validateResponse(data, subscriptionsSchemas_1.SubscriptionMarkersSchema);
|
|
68
|
+
return this._normalizeData(validated);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Get markers of the user's active subscriptions.
|
|
72
|
+
* @handleName getActiveSubscriptions
|
|
73
|
+
* @returns {Promise<string[] | IError>} Returns an array of active subscription markers.
|
|
74
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
75
|
+
* @description This method requires user authorization.
|
|
76
|
+
* @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}.
|
|
77
|
+
*/
|
|
78
|
+
async getActiveSubscriptions() {
|
|
79
|
+
const data = await this._fetchGet(`/active`);
|
|
80
|
+
const validated = this._validateResponse(data, subscriptionsSchemas_1.SubscriptionMarkersSchema);
|
|
81
|
+
return this._normalizeData(validated);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Recover a subscription through the Stripe Billing Portal.
|
|
85
|
+
* @handleName recoverSubscriptions
|
|
86
|
+
* @param {ICancelSubscription} body - Subscription body. Example: `{ marker: "premium" }`.
|
|
87
|
+
* @returns {Promise<boolean | IError>} Returns true if the recovery request was accepted, or an error object if there was an issue.
|
|
88
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
89
|
+
* @description This method requires user authorization.
|
|
90
|
+
* @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}.
|
|
91
|
+
*/
|
|
92
|
+
async recoverSubscriptions(body) {
|
|
93
|
+
try {
|
|
94
|
+
await this._fetchPost(`/recover`, body);
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
catch (e) {
|
|
98
|
+
return e;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.default = SubscriptionsApi;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { IError } from '../base/utils';
|
|
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 subscription markers.
|
|
30
|
+
* @handleName getAllSubscriptions
|
|
31
|
+
* @returns {Promise<string[] | IError>} Returns an array of available subscription markers.
|
|
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<string[] | 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
|
+
export type { ICancelSubscription, ICreatedSubscription, ISubscribe, ISubscriptionsApi, };
|
|
@@ -0,0 +1,20 @@
|
|
|
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 markers schema
|
|
18
|
+
* @description Schema for arrays of subscription markers (available and active subscriptions)
|
|
19
|
+
*/
|
|
20
|
+
export declare const SubscriptionMarkersSchema: z.ZodArray<z.ZodString>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SubscriptionMarkersSchema = exports.CreatedSubscriptionSchema = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Validation schemas for Subscriptions module
|
|
6
|
+
* @description Zod schemas for validating subscriptions-related API responses
|
|
7
|
+
*/
|
|
8
|
+
const zod_1 = require("zod");
|
|
9
|
+
/**
|
|
10
|
+
* Created subscription schema
|
|
11
|
+
* @description Schema for the payment session returned after creating a subscription
|
|
12
|
+
*/
|
|
13
|
+
exports.CreatedSubscriptionSchema = zod_1.z.object({
|
|
14
|
+
id: zod_1.z.number(),
|
|
15
|
+
amount: zod_1.z.number(),
|
|
16
|
+
paymentUrl: zod_1.z.string(),
|
|
17
|
+
status: zod_1.z.string(),
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* Subscription markers schema
|
|
21
|
+
* @description Schema for arrays of subscription markers (available and active subscriptions)
|
|
22
|
+
*/
|
|
23
|
+
exports.SubscriptionMarkersSchema = zod_1.z.array(zod_1.z.string());
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import AsyncModules from '../base/asyncModules';
|
|
2
|
+
import type StateModule from '../base/stateModule';
|
|
3
|
+
import type { IError } from '../base/utils';
|
|
4
|
+
import type { ITrackActivity, IUserActivityApi } from './userActivityInterfaces';
|
|
5
|
+
/**
|
|
6
|
+
* Controllers for working with user activity.
|
|
7
|
+
* @handle /api/content/user-activity
|
|
8
|
+
* @class UserActivityApi
|
|
9
|
+
* @augments AsyncModules
|
|
10
|
+
* @implements {IUserActivityApi}
|
|
11
|
+
* @description This class provides methods to track user/guest activity events.
|
|
12
|
+
*/
|
|
13
|
+
export default class UserActivityApi extends AsyncModules implements IUserActivityApi {
|
|
14
|
+
protected state: StateModule;
|
|
15
|
+
protected _url: string;
|
|
16
|
+
/**
|
|
17
|
+
* Constructor for UserActivityApi class.
|
|
18
|
+
* @param {StateModule} state - The state module.
|
|
19
|
+
*/
|
|
20
|
+
constructor(state: StateModule);
|
|
21
|
+
/**
|
|
22
|
+
* Track a user or guest activity event.
|
|
23
|
+
* @handleName trackUserActivity
|
|
24
|
+
* @param {ITrackActivity} body - Activity event body. Example: `{ type: "product_view", productId: 12345 }`.
|
|
25
|
+
* @returns {Promise<boolean | IError>} Returns true if the event was recorded, or an error object if there was an issue.
|
|
26
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
27
|
+
* @description Records an activity event for the current authorized user or guest.
|
|
28
|
+
*/
|
|
29
|
+
trackUserActivity(body: ITrackActivity): Promise<boolean | IError>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const asyncModules_1 = __importDefault(require("../base/asyncModules"));
|
|
7
|
+
/**
|
|
8
|
+
* Controllers for working with user activity.
|
|
9
|
+
* @handle /api/content/user-activity
|
|
10
|
+
* @class UserActivityApi
|
|
11
|
+
* @augments AsyncModules
|
|
12
|
+
* @implements {IUserActivityApi}
|
|
13
|
+
* @description This class provides methods to track user/guest activity events.
|
|
14
|
+
*/
|
|
15
|
+
class UserActivityApi extends asyncModules_1.default {
|
|
16
|
+
/**
|
|
17
|
+
* Constructor for UserActivityApi class.
|
|
18
|
+
* @param {StateModule} state - The state module.
|
|
19
|
+
*/
|
|
20
|
+
constructor(state) {
|
|
21
|
+
super(state);
|
|
22
|
+
this._url = state.url + '/api/content/user-activity';
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Track a user or guest activity event.
|
|
26
|
+
* @handleName trackUserActivity
|
|
27
|
+
* @param {ITrackActivity} body - Activity event body. Example: `{ type: "product_view", productId: 12345 }`.
|
|
28
|
+
* @returns {Promise<boolean | IError>} Returns true if the event was recorded, or an error object if there was an issue.
|
|
29
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
30
|
+
* @description Records an activity event for the current authorized user or guest.
|
|
31
|
+
*/
|
|
32
|
+
async trackUserActivity(body) {
|
|
33
|
+
try {
|
|
34
|
+
await this._fetchPost(`/track`, body);
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
catch (e) {
|
|
38
|
+
return e;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.default = UserActivityApi;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { IError } from '../base/utils';
|
|
2
|
+
/**
|
|
3
|
+
* Interface for the UserActivity API module.
|
|
4
|
+
* @interface IUserActivityApi
|
|
5
|
+
* @description This interface defines methods for tracking user/guest activity events.
|
|
6
|
+
*/
|
|
7
|
+
interface IUserActivityApi {
|
|
8
|
+
/**
|
|
9
|
+
* Track a user or guest activity event.
|
|
10
|
+
* @handleName trackUserActivity
|
|
11
|
+
* @param {ITrackActivity} body - Activity event body. Example: `{ type: "product_view", productId: 12345 }`.
|
|
12
|
+
* @returns {Promise<boolean | IError>} Returns true if the event was recorded, or an error object if there was an issue.
|
|
13
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
14
|
+
* @description Records an activity event for the current authorized user or guest.
|
|
15
|
+
*/
|
|
16
|
+
trackUserActivity(body: ITrackActivity): Promise<boolean | IError>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* User activity event type.
|
|
20
|
+
* @description Type of the tracked user activity event.
|
|
21
|
+
*/
|
|
22
|
+
type TUserActivityType = 'product_view' | 'page_view' | 'category_view' | 'search' | 'product_add_to_cart' | 'product_remove_from_cart' | 'product_add_to_wishlist' | 'product_remove_from_wishlist' | 'product_purchase' | 'product_rating';
|
|
23
|
+
/**
|
|
24
|
+
* Body for tracking a user activity event.
|
|
25
|
+
* @interface ITrackActivity
|
|
26
|
+
* @property {TUserActivityType} type - Activity event type. Example: "product_view".
|
|
27
|
+
* @property {number} [productId] - Product identifier. Example: 12345.
|
|
28
|
+
* @property {number} [pageId] - Page identifier (for page_view, category_view). Example: 7.
|
|
29
|
+
* @property {number} [categoryId] - Legacy category identifier. Example: 67.
|
|
30
|
+
* @property {string} [query] - Search query (for type=search). Example: "iphone case".
|
|
31
|
+
* @property {Record<string, unknown>} [meta] - Arbitrary meta information (source block, A/B variant, scroll-depth).
|
|
32
|
+
* @description Body for tracking a user activity event.
|
|
33
|
+
*/
|
|
34
|
+
interface ITrackActivity {
|
|
35
|
+
type: TUserActivityType;
|
|
36
|
+
productId?: number;
|
|
37
|
+
pageId?: number;
|
|
38
|
+
categoryId?: number;
|
|
39
|
+
query?: string;
|
|
40
|
+
meta?: Record<string, unknown>;
|
|
41
|
+
}
|
|
42
|
+
export type { ITrackActivity, IUserActivityApi, TUserActivityType };
|
package/dist/users/usersApi.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import AsyncModules from '../base/asyncModules';
|
|
2
2
|
import type StateModule from '../base/stateModule';
|
|
3
3
|
import type { IError } from '../base/utils';
|
|
4
|
-
import type { IUserBody, IUserEntity, IUsersApi } from './usersInterfaces';
|
|
4
|
+
import type { ICartAddItem, ICartResponse, ICartSet, IUserBody, IUserEntity, IUsersApi, IWishlistAddItem, IWishlistResponse, IWishlistSet } from './usersInterfaces';
|
|
5
5
|
/**
|
|
6
6
|
* Controllers for working with users
|
|
7
7
|
* @handle /api/content/users
|
|
@@ -140,4 +140,82 @@ export default class UsersApi extends AsyncModules implements IUsersApi {
|
|
|
140
140
|
* @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}.
|
|
141
141
|
*/
|
|
142
142
|
deleteFCMToken(token: string): Promise<boolean | IError>;
|
|
143
|
+
/**
|
|
144
|
+
* Get the current user's or guest's cart.
|
|
145
|
+
* @handleName getCart
|
|
146
|
+
* @returns {Promise<ICartResponse | IError>} Returns the cart with its items and total.
|
|
147
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
148
|
+
* @description This method requires user authorization (or a guest context).
|
|
149
|
+
* @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}.
|
|
150
|
+
*/
|
|
151
|
+
getCart(): Promise<ICartResponse | IError>;
|
|
152
|
+
/**
|
|
153
|
+
* Replace the current user's or guest's cart.
|
|
154
|
+
* @handleName setCart
|
|
155
|
+
* @param {ICartSet} body - New cart contents. Example: `{ items: [{ productId: 1, qty: 2 }] }`.
|
|
156
|
+
* @returns {Promise<ICartResponse | IError>} Returns the updated cart.
|
|
157
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
158
|
+
* @description This method requires user authorization (or a guest context).
|
|
159
|
+
* @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}.
|
|
160
|
+
*/
|
|
161
|
+
setCart(body: ICartSet): Promise<ICartResponse | IError>;
|
|
162
|
+
/**
|
|
163
|
+
* Add an item to the cart (or update qty of an existing one).
|
|
164
|
+
* @handleName addCartItem
|
|
165
|
+
* @param {ICartAddItem} body - Item to add. Example: `{ productId: 1, qty: 2 }`.
|
|
166
|
+
* @returns {Promise<ICartResponse | IError>} Returns the updated cart.
|
|
167
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
168
|
+
* @description This method requires user authorization (or a guest context).
|
|
169
|
+
* @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}.
|
|
170
|
+
*/
|
|
171
|
+
addCartItem(body: ICartAddItem): Promise<ICartResponse | IError>;
|
|
172
|
+
/**
|
|
173
|
+
* Remove an item from the cart.
|
|
174
|
+
* @handleName removeCartItem
|
|
175
|
+
* @param {number} productId - Product identifier. Example: 12345.
|
|
176
|
+
* @returns {Promise<ICartResponse | IError>} Returns the updated cart.
|
|
177
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
178
|
+
* @description This method requires user authorization (or a guest context).
|
|
179
|
+
* @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}.
|
|
180
|
+
*/
|
|
181
|
+
removeCartItem(productId: number): Promise<ICartResponse | IError>;
|
|
182
|
+
/**
|
|
183
|
+
* Get the current user's or guest's wishlist.
|
|
184
|
+
* @handleName getWishlist
|
|
185
|
+
* @returns {Promise<IWishlistResponse | IError>} Returns the wishlist with its items and total.
|
|
186
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
187
|
+
* @description This method requires user authorization (or a guest context).
|
|
188
|
+
* @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}.
|
|
189
|
+
*/
|
|
190
|
+
getWishlist(): Promise<IWishlistResponse | IError>;
|
|
191
|
+
/**
|
|
192
|
+
* Replace the current user's or guest's wishlist.
|
|
193
|
+
* @handleName setWishlist
|
|
194
|
+
* @param {IWishlistSet} body - New wishlist contents. Example: `{ items: [{ productId: 1 }] }`.
|
|
195
|
+
* @returns {Promise<IWishlistResponse | IError>} Returns the updated wishlist.
|
|
196
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
197
|
+
* @description This method requires user authorization (or a guest context).
|
|
198
|
+
* @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}.
|
|
199
|
+
*/
|
|
200
|
+
setWishlist(body: IWishlistSet): Promise<IWishlistResponse | IError>;
|
|
201
|
+
/**
|
|
202
|
+
* Add an item to the wishlist.
|
|
203
|
+
* @handleName addWishlistItem
|
|
204
|
+
* @param {IWishlistAddItem} body - Item to add. Example: `{ productId: 1 }`.
|
|
205
|
+
* @returns {Promise<IWishlistResponse | IError>} Returns the updated wishlist.
|
|
206
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
207
|
+
* @description This method requires user authorization (or a guest context).
|
|
208
|
+
* @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}.
|
|
209
|
+
*/
|
|
210
|
+
addWishlistItem(body: IWishlistAddItem): Promise<IWishlistResponse | IError>;
|
|
211
|
+
/**
|
|
212
|
+
* Remove an item from the wishlist.
|
|
213
|
+
* @handleName removeWishlistItem
|
|
214
|
+
* @param {number} productId - Product identifier. Example: 12345.
|
|
215
|
+
* @returns {Promise<IWishlistResponse | IError>} Returns the updated wishlist.
|
|
216
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
217
|
+
* @description This method requires user authorization (or a guest context).
|
|
218
|
+
* @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}.
|
|
219
|
+
*/
|
|
220
|
+
removeWishlistItem(productId: number): Promise<IWishlistResponse | IError>;
|
|
143
221
|
}
|
package/dist/users/usersApi.js
CHANGED
|
@@ -167,5 +167,115 @@ class UsersApi extends asyncModules_1.default {
|
|
|
167
167
|
const result = await this._fetchDelete(`/me/fcm-token/${token}`);
|
|
168
168
|
return result;
|
|
169
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* Get the current user's or guest's cart.
|
|
172
|
+
* @handleName getCart
|
|
173
|
+
* @returns {Promise<ICartResponse | IError>} Returns the cart with its items and total.
|
|
174
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
175
|
+
* @description This method requires user authorization (or a guest context).
|
|
176
|
+
* @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}.
|
|
177
|
+
*/
|
|
178
|
+
async getCart() {
|
|
179
|
+
const result = await this._fetchGet('/me/cart');
|
|
180
|
+
const validated = this._validateResponse(result, usersSchemas_1.CartResponseSchema);
|
|
181
|
+
return this._normalizeData(validated);
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Replace the current user's or guest's cart.
|
|
185
|
+
* @handleName setCart
|
|
186
|
+
* @param {ICartSet} body - New cart contents. Example: `{ items: [{ productId: 1, qty: 2 }] }`.
|
|
187
|
+
* @returns {Promise<ICartResponse | IError>} Returns the updated cart.
|
|
188
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
189
|
+
* @description This method requires user authorization (or a guest context).
|
|
190
|
+
* @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}.
|
|
191
|
+
*/
|
|
192
|
+
async setCart(body) {
|
|
193
|
+
const result = await this._fetchPut('/me/cart', body);
|
|
194
|
+
const validated = this._validateResponse(result, usersSchemas_1.CartResponseSchema);
|
|
195
|
+
return this._normalizeData(validated);
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Add an item to the cart (or update qty of an existing one).
|
|
199
|
+
* @handleName addCartItem
|
|
200
|
+
* @param {ICartAddItem} body - Item to add. Example: `{ productId: 1, qty: 2 }`.
|
|
201
|
+
* @returns {Promise<ICartResponse | IError>} Returns the updated cart.
|
|
202
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
203
|
+
* @description This method requires user authorization (or a guest context).
|
|
204
|
+
* @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}.
|
|
205
|
+
*/
|
|
206
|
+
async addCartItem(body) {
|
|
207
|
+
const result = await this._fetchPost('/me/cart/items', body);
|
|
208
|
+
const validated = this._validateResponse(result, usersSchemas_1.CartResponseSchema);
|
|
209
|
+
return this._normalizeData(validated);
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Remove an item from the cart.
|
|
213
|
+
* @handleName removeCartItem
|
|
214
|
+
* @param {number} productId - Product identifier. Example: 12345.
|
|
215
|
+
* @returns {Promise<ICartResponse | IError>} Returns the updated cart.
|
|
216
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
217
|
+
* @description This method requires user authorization (or a guest context).
|
|
218
|
+
* @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}.
|
|
219
|
+
*/
|
|
220
|
+
async removeCartItem(productId) {
|
|
221
|
+
const result = await this._fetchDelete(`/me/cart/items/${productId}`);
|
|
222
|
+
const validated = this._validateResponse(result, usersSchemas_1.CartResponseSchema);
|
|
223
|
+
return this._normalizeData(validated);
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Get the current user's or guest's wishlist.
|
|
227
|
+
* @handleName getWishlist
|
|
228
|
+
* @returns {Promise<IWishlistResponse | IError>} Returns the wishlist with its items and total.
|
|
229
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
230
|
+
* @description This method requires user authorization (or a guest context).
|
|
231
|
+
* @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}.
|
|
232
|
+
*/
|
|
233
|
+
async getWishlist() {
|
|
234
|
+
const result = await this._fetchGet('/me/wishlist');
|
|
235
|
+
const validated = this._validateResponse(result, usersSchemas_1.WishlistResponseSchema);
|
|
236
|
+
return this._normalizeData(validated);
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Replace the current user's or guest's wishlist.
|
|
240
|
+
* @handleName setWishlist
|
|
241
|
+
* @param {IWishlistSet} body - New wishlist contents. Example: `{ items: [{ productId: 1 }] }`.
|
|
242
|
+
* @returns {Promise<IWishlistResponse | IError>} Returns the updated wishlist.
|
|
243
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
244
|
+
* @description This method requires user authorization (or a guest context).
|
|
245
|
+
* @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}.
|
|
246
|
+
*/
|
|
247
|
+
async setWishlist(body) {
|
|
248
|
+
const result = await this._fetchPut('/me/wishlist', body);
|
|
249
|
+
const validated = this._validateResponse(result, usersSchemas_1.WishlistResponseSchema);
|
|
250
|
+
return this._normalizeData(validated);
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Add an item to the wishlist.
|
|
254
|
+
* @handleName addWishlistItem
|
|
255
|
+
* @param {IWishlistAddItem} body - Item to add. Example: `{ productId: 1 }`.
|
|
256
|
+
* @returns {Promise<IWishlistResponse | IError>} Returns the updated wishlist.
|
|
257
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
258
|
+
* @description This method requires user authorization (or a guest context).
|
|
259
|
+
* @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}.
|
|
260
|
+
*/
|
|
261
|
+
async addWishlistItem(body) {
|
|
262
|
+
const result = await this._fetchPost('/me/wishlist/items', body);
|
|
263
|
+
const validated = this._validateResponse(result, usersSchemas_1.WishlistResponseSchema);
|
|
264
|
+
return this._normalizeData(validated);
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Remove an item from the wishlist.
|
|
268
|
+
* @handleName removeWishlistItem
|
|
269
|
+
* @param {number} productId - Product identifier. Example: 12345.
|
|
270
|
+
* @returns {Promise<IWishlistResponse | IError>} Returns the updated wishlist.
|
|
271
|
+
* @throws {IError} When isShell=false and an error occurs during the fetch
|
|
272
|
+
* @description This method requires user authorization (or a guest context).
|
|
273
|
+
* @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}.
|
|
274
|
+
*/
|
|
275
|
+
async removeWishlistItem(productId) {
|
|
276
|
+
const result = await this._fetchDelete(`/me/wishlist/items/${productId}`);
|
|
277
|
+
const validated = this._validateResponse(result, usersSchemas_1.WishlistResponseSchema);
|
|
278
|
+
return this._normalizeData(validated);
|
|
279
|
+
}
|
|
170
280
|
}
|
|
171
281
|
exports.default = UsersApi;
|