oneentry 1.0.62 → 1.0.63
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 +731 -218
- package/dist/auth-provider/authProviderApi.d.ts +104 -0
- package/dist/auth-provider/authProviderApi.js +162 -0
- package/dist/auth-provider/authProvidersInterfaces.d.ts +81 -0
- package/dist/auth-provider/authProvidersInterfaces.js +2 -0
- package/dist/base/oneEntry.d.ts +3 -1
- package/dist/base/oneEntry.js +50 -2
- package/dist/events/eventsApi.d.ts +23 -0
- package/dist/events/eventsApi.js +39 -0
- package/dist/events/eventsInterfaces.d.ts +11 -0
- package/dist/events/eventsInterfaces.js +2 -0
- package/dist/formsData/formsDataApi.d.ts +2 -2
- package/dist/formsData/formsDataApi.js +2 -2
- package/dist/formsData/formsDataInterfaces.d.ts +118 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +10 -4
- package/dist/users/usersApi.d.ts +41 -0
- package/dist/users/usersApi.js +51 -0
- package/dist/users/usersInterfaces.d.ts +30 -0
- package/dist/users/usersInterfaces.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import OneEntry from "../base/oneEntry";
|
|
2
|
+
import { IConfig } from "../base/utils";
|
|
3
|
+
import { IAuthProvider, ISignUpData, ISignUpEntity, ICodeEntity, IAuthEntity, IAuthProvidersEntity } from "./authProvidersInterfaces";
|
|
4
|
+
/**
|
|
5
|
+
* Controllers for working with auth services.
|
|
6
|
+
*/
|
|
7
|
+
export default class AuthProviderApi extends OneEntry implements IAuthProvider {
|
|
8
|
+
constructor(url: string, config: IConfig);
|
|
9
|
+
/**
|
|
10
|
+
* User registration
|
|
11
|
+
* @param {string} marker - The text identifier of the authorization provider. Example - email
|
|
12
|
+
* @param data - Request body
|
|
13
|
+
* @param {string} langCode - Optional language field
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* const data = {
|
|
17
|
+
* "formIdentifier": "reg",
|
|
18
|
+
* "authData": [
|
|
19
|
+
* {
|
|
20
|
+
* "marker": "login",
|
|
21
|
+
* "value": "test"
|
|
22
|
+
* },
|
|
23
|
+
* {
|
|
24
|
+
* "marker": "password",
|
|
25
|
+
* "value": "12345"
|
|
26
|
+
* }
|
|
27
|
+
* ],
|
|
28
|
+
* "formData": [
|
|
29
|
+
* {
|
|
30
|
+
* "marker": "last_name",
|
|
31
|
+
* "type": "string",
|
|
32
|
+
* "value": "Name"
|
|
33
|
+
* }
|
|
34
|
+
* ],
|
|
35
|
+
* "notificationData": {
|
|
36
|
+
* "email": "test@test.com",
|
|
37
|
+
* "phonePush": "",
|
|
38
|
+
* "phoneSMS": "+79991234567"
|
|
39
|
+
* }
|
|
40
|
+
* }
|
|
41
|
+
*/
|
|
42
|
+
signUp(marker: string, data: ISignUpData, langCode?: string): Promise<ISignUpEntity>;
|
|
43
|
+
/**
|
|
44
|
+
* Getting a user activation code
|
|
45
|
+
* @param {string} marker - The text identifier of the authorization provider. Example - email
|
|
46
|
+
* @param {string} userIdentifier - The text identifier of the user's object (user login)
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* const data = {
|
|
50
|
+
* "userIdentifier": "test@test.com"
|
|
51
|
+
* }
|
|
52
|
+
*/
|
|
53
|
+
generateCode(marker: string, userIdentifier: string): Promise<ICodeEntity>;
|
|
54
|
+
/**
|
|
55
|
+
* User activate.
|
|
56
|
+
* @param {string} marker - The text identifier of the authorization provider. Example - email
|
|
57
|
+
* @param {string} userIdentifier - The text identifier of the user's object (user login)
|
|
58
|
+
* @param {string} code - Service code
|
|
59
|
+
*/
|
|
60
|
+
activateUser(marker: string, userIdentifier: string, code: string): Promise<boolean>;
|
|
61
|
+
/**
|
|
62
|
+
* User authorization
|
|
63
|
+
* @param {string} marker - The text identifier of the authorization provider. Example - email
|
|
64
|
+
* @param {string} login - User login
|
|
65
|
+
* @param {string} password - User password
|
|
66
|
+
*
|
|
67
|
+
*/
|
|
68
|
+
auth(marker: string, login: string, password: string): Promise<IAuthEntity>;
|
|
69
|
+
/**
|
|
70
|
+
* Refresh token
|
|
71
|
+
* @param {string} marker - The text identifier of the authorization provider. Example - email
|
|
72
|
+
* @param {string} token - Refresh token
|
|
73
|
+
*
|
|
74
|
+
*/
|
|
75
|
+
refresh(marker: string, token: string): Promise<IAuthEntity>;
|
|
76
|
+
/**
|
|
77
|
+
* User logout
|
|
78
|
+
* @param {string} marker - The text identifier of the authorization provider. Example - email
|
|
79
|
+
* @param {string} token - Refresh token
|
|
80
|
+
*/
|
|
81
|
+
logout(marker: string, token: string): Promise<boolean>;
|
|
82
|
+
/**
|
|
83
|
+
* Change password
|
|
84
|
+
* @param {string} marker - The text identifier of the authorization provider. Example - email
|
|
85
|
+
* @param {string} userIdentifier - The text identifier of the user's object (user login)
|
|
86
|
+
* @param {string} code - Service code
|
|
87
|
+
* @param {string} newPassword - New password
|
|
88
|
+
* @param {string} [repeatPassword] - Optional variable contains repeat new password for validation
|
|
89
|
+
*/
|
|
90
|
+
changePassword(marker: string, userIdentifier: string, code: string, newPassword: string, repeatPassword?: string): Promise<boolean>;
|
|
91
|
+
/**
|
|
92
|
+
* Get all auth providers objects
|
|
93
|
+
* @param {string} [langCode] - Language code. Default "en_US"
|
|
94
|
+
* @param {number} [offset] - Parameter for pagination. Default 0
|
|
95
|
+
* @param {number} [limit] - Parameter for pagination. Default 30
|
|
96
|
+
*/
|
|
97
|
+
getAuthProviders(langCode: string, offset: number, limit: number): Promise<Array<IAuthProvidersEntity>>;
|
|
98
|
+
/**
|
|
99
|
+
* Get one auth provider object by marker
|
|
100
|
+
* @param {string} marker - The text identifier of the authorization provider. Example - email
|
|
101
|
+
* @param {string} [langCode] - Optional parameter language code. Default "en_US"
|
|
102
|
+
*/
|
|
103
|
+
getMarker(marker: string, langCode?: string): Promise<IAuthProvidersEntity>;
|
|
104
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const oneEntry_1 = require("../base/oneEntry");
|
|
4
|
+
/**
|
|
5
|
+
* Controllers for working with auth services.
|
|
6
|
+
*/
|
|
7
|
+
class AuthProviderApi extends oneEntry_1.default {
|
|
8
|
+
constructor(url, config) {
|
|
9
|
+
super(url, config);
|
|
10
|
+
this._url += '/api/content/users-auth-providers';
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* User registration
|
|
14
|
+
* @param {string} marker - The text identifier of the authorization provider. Example - email
|
|
15
|
+
* @param data - Request body
|
|
16
|
+
* @param {string} langCode - Optional language field
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* const data = {
|
|
20
|
+
* "formIdentifier": "reg",
|
|
21
|
+
* "authData": [
|
|
22
|
+
* {
|
|
23
|
+
* "marker": "login",
|
|
24
|
+
* "value": "test"
|
|
25
|
+
* },
|
|
26
|
+
* {
|
|
27
|
+
* "marker": "password",
|
|
28
|
+
* "value": "12345"
|
|
29
|
+
* }
|
|
30
|
+
* ],
|
|
31
|
+
* "formData": [
|
|
32
|
+
* {
|
|
33
|
+
* "marker": "last_name",
|
|
34
|
+
* "type": "string",
|
|
35
|
+
* "value": "Name"
|
|
36
|
+
* }
|
|
37
|
+
* ],
|
|
38
|
+
* "notificationData": {
|
|
39
|
+
* "email": "test@test.com",
|
|
40
|
+
* "phonePush": "",
|
|
41
|
+
* "phoneSMS": "+79991234567"
|
|
42
|
+
* }
|
|
43
|
+
* }
|
|
44
|
+
*/
|
|
45
|
+
async signUp(marker, data, langCode = this._defaultLangCode) {
|
|
46
|
+
const result = await this._fetchPost(`/marker/${marker}/users/sign-up`, this._normalizePostBody(data, langCode));
|
|
47
|
+
return this._normalizeData(result);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Getting a user activation code
|
|
51
|
+
* @param {string} marker - The text identifier of the authorization provider. Example - email
|
|
52
|
+
* @param {string} userIdentifier - The text identifier of the user's object (user login)
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* const data = {
|
|
56
|
+
* "userIdentifier": "test@test.com"
|
|
57
|
+
* }
|
|
58
|
+
*/
|
|
59
|
+
async generateCode(marker, userIdentifier) {
|
|
60
|
+
const data = {
|
|
61
|
+
"userIdentifier": userIdentifier
|
|
62
|
+
};
|
|
63
|
+
const result = await this._fetchPost(`/marker/${marker}/users/generate-code`, data);
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* User activate.
|
|
68
|
+
* @param {string} marker - The text identifier of the authorization provider. Example - email
|
|
69
|
+
* @param {string} userIdentifier - The text identifier of the user's object (user login)
|
|
70
|
+
* @param {string} code - Service code
|
|
71
|
+
*/
|
|
72
|
+
async activateUser(marker, userIdentifier, code) {
|
|
73
|
+
const data = {
|
|
74
|
+
"userIdentifier": userIdentifier,
|
|
75
|
+
"code": code
|
|
76
|
+
};
|
|
77
|
+
const result = await this._fetchPost(`/marker/${marker}/users/activate`, data);
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* User authorization
|
|
82
|
+
* @param {string} marker - The text identifier of the authorization provider. Example - email
|
|
83
|
+
* @param {string} login - User login
|
|
84
|
+
* @param {string} password - User password
|
|
85
|
+
*
|
|
86
|
+
*/
|
|
87
|
+
async auth(marker, login, password) {
|
|
88
|
+
const data = [
|
|
89
|
+
{
|
|
90
|
+
"marker": "login",
|
|
91
|
+
"value": login
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"marker": "password",
|
|
95
|
+
"value": password
|
|
96
|
+
}
|
|
97
|
+
];
|
|
98
|
+
const result = await this._fetchPost(`/marker/${marker}/users/activate`, data);
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Refresh token
|
|
103
|
+
* @param {string} marker - The text identifier of the authorization provider. Example - email
|
|
104
|
+
* @param {string} token - Refresh token
|
|
105
|
+
*
|
|
106
|
+
*/
|
|
107
|
+
async refresh(marker, token) {
|
|
108
|
+
const data = { refreshToken: token };
|
|
109
|
+
const result = await this._fetchPost(`/marker/${marker}/users/refresh`, data);
|
|
110
|
+
return result;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* User logout
|
|
114
|
+
* @param {string} marker - The text identifier of the authorization provider. Example - email
|
|
115
|
+
* @param {string} token - Refresh token
|
|
116
|
+
*/
|
|
117
|
+
async logout(marker, token) {
|
|
118
|
+
const data = {
|
|
119
|
+
"refreshToken": token
|
|
120
|
+
};
|
|
121
|
+
const result = await this._fetchPost(`/marker/${marker}/users/logout`, data);
|
|
122
|
+
return result;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Change password
|
|
126
|
+
* @param {string} marker - The text identifier of the authorization provider. Example - email
|
|
127
|
+
* @param {string} userIdentifier - The text identifier of the user's object (user login)
|
|
128
|
+
* @param {string} code - Service code
|
|
129
|
+
* @param {string} newPassword - New password
|
|
130
|
+
* @param {string} [repeatPassword] - Optional variable contains repeat new password for validation
|
|
131
|
+
*/
|
|
132
|
+
async changePassword(marker, userIdentifier, code, newPassword, repeatPassword) {
|
|
133
|
+
const data = {
|
|
134
|
+
"userIdentifier": userIdentifier,
|
|
135
|
+
"code": code,
|
|
136
|
+
"password1": newPassword,
|
|
137
|
+
"password2": repeatPassword !== null && repeatPassword !== void 0 ? repeatPassword : newPassword
|
|
138
|
+
};
|
|
139
|
+
const result = await this._fetchPost(`/marker/${marker}/users/change-password`, data);
|
|
140
|
+
return result;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Get all auth providers objects
|
|
144
|
+
* @param {string} [langCode] - Language code. Default "en_US"
|
|
145
|
+
* @param {number} [offset] - Parameter for pagination. Default 0
|
|
146
|
+
* @param {number} [limit] - Parameter for pagination. Default 30
|
|
147
|
+
*/
|
|
148
|
+
async getAuthProviders(langCode, offset, limit) {
|
|
149
|
+
const result = await this._fetchGet(`?langCode=${langCode}&offset=${offset}&limit=${limit}`);
|
|
150
|
+
return this._normalizeData(result);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Get one auth provider object by marker
|
|
154
|
+
* @param {string} marker - The text identifier of the authorization provider. Example - email
|
|
155
|
+
* @param {string} [langCode] - Optional parameter language code. Default "en_US"
|
|
156
|
+
*/
|
|
157
|
+
async getMarker(marker, langCode) {
|
|
158
|
+
const result = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
|
|
159
|
+
return this._normalizeData(result);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
exports.default = AuthProviderApi;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { ILocalizeInfo } from "../base/utils";
|
|
2
|
+
/**
|
|
3
|
+
* Represents a interface object of User Auth Provider Api.
|
|
4
|
+
*
|
|
5
|
+
* @property {function} signUp - User registration.
|
|
6
|
+
* @property {function} generateCode - Getting a user activation code.
|
|
7
|
+
* @property {function} activateUser - User activate.
|
|
8
|
+
* @property {function} auth - User authorization.
|
|
9
|
+
* @property {function} refresh - Refresh token.
|
|
10
|
+
* @property {function} logout - User logout.
|
|
11
|
+
* @property {function} changePassword - Change password.
|
|
12
|
+
* @property {function} getAuthProviders - Get all auth providers objects.
|
|
13
|
+
* @property {function} getMarker - Get one auth provider object by marker.
|
|
14
|
+
*/
|
|
15
|
+
interface IAuthProvider {
|
|
16
|
+
signUp(marker: string, data: ISignUpData, langCode?: string): Promise<ISignUpEntity>;
|
|
17
|
+
generateCode(marker: string, userIdentifier: string): Promise<ICodeEntity>;
|
|
18
|
+
activateUser(marker: string, userIdentifier: string, code: string): Promise<boolean>;
|
|
19
|
+
auth(marker: string, login: string, password: string): Promise<IAuthEntity>;
|
|
20
|
+
refresh(marker: string, token: string): Promise<IAuthEntity>;
|
|
21
|
+
logout(marker: string, token: string): Promise<boolean>;
|
|
22
|
+
changePassword(marker: string, userIdentifier: string, code: string, newPassword: string, repeatPassword?: string): Promise<boolean>;
|
|
23
|
+
getAuthProviders(langCode: string, offset: number, limit: number): Promise<Array<IAuthProvidersEntity>>;
|
|
24
|
+
getMarker(marker: string, langCode?: string): Promise<IAuthProvidersEntity>;
|
|
25
|
+
}
|
|
26
|
+
interface IAuthFormData {
|
|
27
|
+
marker: string;
|
|
28
|
+
type: string;
|
|
29
|
+
value: string;
|
|
30
|
+
}
|
|
31
|
+
interface ISignUpData {
|
|
32
|
+
formIdentifier: string;
|
|
33
|
+
authData: Array<{
|
|
34
|
+
marker: 'login' | 'password';
|
|
35
|
+
value: string;
|
|
36
|
+
}>;
|
|
37
|
+
formData: IAuthFormData | Array<IAuthFormData>;
|
|
38
|
+
notificationData: {
|
|
39
|
+
email: string;
|
|
40
|
+
phonePush: string;
|
|
41
|
+
phoneSMS: string;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
interface ISignUpEntity {
|
|
45
|
+
id: number;
|
|
46
|
+
updatedDate: string;
|
|
47
|
+
version: number;
|
|
48
|
+
identifier: string;
|
|
49
|
+
isActive: boolean;
|
|
50
|
+
authProviderId: number;
|
|
51
|
+
formData: Array<{
|
|
52
|
+
marker: 'login' | 'password';
|
|
53
|
+
value: string;
|
|
54
|
+
}>;
|
|
55
|
+
notificationData: IAuthFormData | Array<IAuthFormData>;
|
|
56
|
+
systemCode: {
|
|
57
|
+
value: string;
|
|
58
|
+
expiredDate: string;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
interface ICodeEntity {
|
|
62
|
+
code: string;
|
|
63
|
+
expiredDate: string;
|
|
64
|
+
}
|
|
65
|
+
interface IAuthEntity {
|
|
66
|
+
userIdentifier: string;
|
|
67
|
+
authProviderIdentifier: string;
|
|
68
|
+
accessToken: string;
|
|
69
|
+
refreshToken: string;
|
|
70
|
+
}
|
|
71
|
+
interface IAuthProvidersEntity {
|
|
72
|
+
id: number;
|
|
73
|
+
localizeInfos: ILocalizeInfo;
|
|
74
|
+
version: number;
|
|
75
|
+
identifier: string;
|
|
76
|
+
isActive: boolean;
|
|
77
|
+
isCheckCode: boolean;
|
|
78
|
+
type: string;
|
|
79
|
+
formIdentifier: string | null;
|
|
80
|
+
}
|
|
81
|
+
export { IAuthProvider, IAuthFormData, ISignUpData, ISignUpEntity, ICodeEntity, IAuthEntity, IAuthProvidersEntity };
|
package/dist/base/oneEntry.d.ts
CHANGED
|
@@ -12,9 +12,11 @@ export default abstract class OneEntry {
|
|
|
12
12
|
protected _getFullPath(path: string): string;
|
|
13
13
|
protected _fetchGet(path: string): Promise<any>;
|
|
14
14
|
protected _fetchPost(path: string, data: any): Promise<any>;
|
|
15
|
-
protected
|
|
15
|
+
protected _fetchPut(path: string, data: any): Promise<any>;
|
|
16
|
+
protected _fetchDelete(path: string, data?: any): Promise<any>;
|
|
16
17
|
protected _queryParamsToString(query: IProductsQuery | IUploadingQuery): string;
|
|
17
18
|
protected _normalizeData(data: any, langCode?: string): any;
|
|
19
|
+
protected _normalizePostBody(body: any, langCode?: string): any;
|
|
18
20
|
protected _clearArray(data: Record<string, any>): any;
|
|
19
21
|
protected _dataPostProcess(data: any, langCode?: string): any;
|
|
20
22
|
}
|
package/dist/base/oneEntry.js
CHANGED
|
@@ -92,13 +92,55 @@ class OneEntry {
|
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
-
async
|
|
95
|
+
async _fetchPut(path, data) {
|
|
96
|
+
const options = {
|
|
97
|
+
method: 'PUT',
|
|
98
|
+
headers: {
|
|
99
|
+
'x-app-token': this._token,
|
|
100
|
+
'Content-Type': 'application/json',
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
if (data instanceof FormData || data instanceof Blob) {
|
|
104
|
+
delete options.headers['Content-Type'];
|
|
105
|
+
}
|
|
106
|
+
if (!this._NO_FETCH) {
|
|
107
|
+
const response = await fetch(this._getFullPath(path), {
|
|
108
|
+
...options,
|
|
109
|
+
body: data,
|
|
110
|
+
});
|
|
111
|
+
if (!response.ok) {
|
|
112
|
+
const error = await response.json();
|
|
113
|
+
throw error;
|
|
114
|
+
}
|
|
115
|
+
return await response.json();
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
return new Promise((resolve, reject) => {
|
|
119
|
+
const req = this._https.request(this._getFullPath(path), options, (res) => {
|
|
120
|
+
let responseData = '';
|
|
121
|
+
res.on('data', (chunk) => {
|
|
122
|
+
responseData += chunk;
|
|
123
|
+
});
|
|
124
|
+
res.on('end', () => {
|
|
125
|
+
resolve(JSON.parse(responseData));
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
req.on('error', (error) => {
|
|
129
|
+
reject(error);
|
|
130
|
+
});
|
|
131
|
+
req.write(data);
|
|
132
|
+
req.end();
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
async _fetchDelete(path, data) {
|
|
96
137
|
const options = {
|
|
97
138
|
method: 'DELETE',
|
|
98
139
|
headers: {
|
|
99
140
|
'Content-Type': 'application/json',
|
|
100
141
|
'x-app-token': this._token,
|
|
101
|
-
}
|
|
142
|
+
},
|
|
143
|
+
body: data
|
|
102
144
|
};
|
|
103
145
|
if (!this._NO_FETCH) {
|
|
104
146
|
const response = await fetch(this._getFullPath(path), options);
|
|
@@ -154,6 +196,12 @@ class OneEntry {
|
|
|
154
196
|
return normalizeData;
|
|
155
197
|
}
|
|
156
198
|
}
|
|
199
|
+
_normalizePostBody(body, langCode = this._defaultLangCode) {
|
|
200
|
+
const formData = {};
|
|
201
|
+
formData[langCode] = Array.isArray(body.formData) ? body.formData : [body.formData];
|
|
202
|
+
body.formData = formData;
|
|
203
|
+
return body;
|
|
204
|
+
}
|
|
157
205
|
_clearArray(data) {
|
|
158
206
|
if (Array.isArray(data)) {
|
|
159
207
|
return data.map(item => this._clearArray(item));
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import OneEntry from "../base/oneEntry";
|
|
2
|
+
import { IConfig } from "../base/utils";
|
|
3
|
+
import { IEvents } from "./eventsInterfaces";
|
|
4
|
+
/**
|
|
5
|
+
* Controllers for working with events
|
|
6
|
+
*/
|
|
7
|
+
export default class EventsApi extends OneEntry implements IEvents {
|
|
8
|
+
constructor(url: string, config: IConfig);
|
|
9
|
+
/**
|
|
10
|
+
* Subscribing to an event on a product.
|
|
11
|
+
* @param marker - Event marker.
|
|
12
|
+
* @param userId - User id.
|
|
13
|
+
* @param productId - Product id.
|
|
14
|
+
*/
|
|
15
|
+
subscribeByMarker(marker: string, userId: number, productId: number): Promise<any>;
|
|
16
|
+
/**
|
|
17
|
+
* Unsubscribing to an event on a product.
|
|
18
|
+
* @param marker - Event marker.
|
|
19
|
+
* @param userId - User id.
|
|
20
|
+
* @param productId - Product id.
|
|
21
|
+
*/
|
|
22
|
+
unsubscribeByMarker(marker: string, userId: number, productId: number): Promise<any>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const oneEntry_1 = require("../base/oneEntry");
|
|
4
|
+
/**
|
|
5
|
+
* Controllers for working with events
|
|
6
|
+
*/
|
|
7
|
+
class EventsApi extends oneEntry_1.default {
|
|
8
|
+
constructor(url, config) {
|
|
9
|
+
super(url, config);
|
|
10
|
+
this._url += '/api/content/events';
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Subscribing to an event on a product.
|
|
14
|
+
* @param marker - Event marker.
|
|
15
|
+
* @param userId - User id.
|
|
16
|
+
* @param productId - Product id.
|
|
17
|
+
*/
|
|
18
|
+
async subscribeByMarker(marker, userId, productId) {
|
|
19
|
+
const result = await this._fetchPost(`/subscribe/marker/${marker}`, {
|
|
20
|
+
"userId": userId,
|
|
21
|
+
"productId": productId
|
|
22
|
+
});
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Unsubscribing to an event on a product.
|
|
27
|
+
* @param marker - Event marker.
|
|
28
|
+
* @param userId - User id.
|
|
29
|
+
* @param productId - Product id.
|
|
30
|
+
*/
|
|
31
|
+
async unsubscribeByMarker(marker, userId, productId) {
|
|
32
|
+
const result = await this._fetchDelete('', {
|
|
33
|
+
"userId": userId,
|
|
34
|
+
"productId": productId
|
|
35
|
+
});
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.default = EventsApi;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a interface object of Events Api.
|
|
3
|
+
*
|
|
4
|
+
* @property {function} subscribeByMarker - Subscribing to an event on a product.
|
|
5
|
+
* @property {function} unsubscribeByMarker - Unsubscribing to an event on a product.
|
|
6
|
+
*/
|
|
7
|
+
interface IEvents {
|
|
8
|
+
subscribeByMarker(marker: string, userId: number, productId: number): Promise<any>;
|
|
9
|
+
unsubscribeByMarker(marker: string, userId: number, productId: number): Promise<any>;
|
|
10
|
+
}
|
|
11
|
+
export { IEvents };
|
|
@@ -19,11 +19,11 @@ export default class FormsDataApi extends OneEntry implements IFormsData {
|
|
|
19
19
|
/**
|
|
20
20
|
* Find all product page objects with pagination and multiple filtering.
|
|
21
21
|
*
|
|
22
|
-
* @param {object}
|
|
22
|
+
* @param {object} data - Request body.
|
|
23
23
|
* @param {string} langCode - Optional language field
|
|
24
24
|
*
|
|
25
25
|
* @example
|
|
26
|
-
* const
|
|
26
|
+
* const data = {
|
|
27
27
|
* formIdentifier: 'test',
|
|
28
28
|
* formData: {
|
|
29
29
|
* marker: 'test',
|
|
@@ -25,11 +25,11 @@ class FormsDataApi extends oneEntry_1.default {
|
|
|
25
25
|
/**
|
|
26
26
|
* Find all product page objects with pagination and multiple filtering.
|
|
27
27
|
*
|
|
28
|
-
* @param {object}
|
|
28
|
+
* @param {object} data - Request body.
|
|
29
29
|
* @param {string} langCode - Optional language field
|
|
30
30
|
*
|
|
31
31
|
* @example
|
|
32
|
-
* const
|
|
32
|
+
* const data = {
|
|
33
33
|
* formIdentifier: 'test',
|
|
34
34
|
* formData: {
|
|
35
35
|
* marker: 'test',
|
|
@@ -52,6 +52,122 @@ interface IFormsPost {
|
|
|
52
52
|
id?: number;
|
|
53
53
|
formIdentifier: string;
|
|
54
54
|
time?: Date | string;
|
|
55
|
-
formData:
|
|
55
|
+
formData: Array<IBodyTypeStringNumberFloat | IBodyTypeTimeDate | IBodyTypeText | IBodyTypeTextWithHeader | IBodyTypeImageGroupOfImages | IBodyTypeFile | IBodyTypeRadioButtonList>;
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
/**
|
|
58
|
+
* @property {string} marker - marker name
|
|
59
|
+
* @property {'string' | 'number' | 'float'} type - Type value
|
|
60
|
+
* @property {string} value
|
|
61
|
+
*/
|
|
62
|
+
interface IBodyTypeStringNumberFloat {
|
|
63
|
+
marker: string;
|
|
64
|
+
type: 'string' | 'number' | 'float';
|
|
65
|
+
value: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* @property {string} marker - marker name
|
|
69
|
+
* @property {'date' | 'dateTime' | 'time'} type - Type value
|
|
70
|
+
* @property {object} value - Date object. Contains fullDate, formattedValue, formatString
|
|
71
|
+
*/
|
|
72
|
+
interface IBodyTypeTimeDate {
|
|
73
|
+
marker: string;
|
|
74
|
+
type: 'date' | 'dateTime' | 'time';
|
|
75
|
+
value: {
|
|
76
|
+
fullDate: string;
|
|
77
|
+
formattedValue: string;
|
|
78
|
+
formatString: string;
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* @property {string} marker - marker name
|
|
83
|
+
* @property {'text'} type - Type value
|
|
84
|
+
* @property {object} value - Text Object. Contains html as string and params
|
|
85
|
+
*/
|
|
86
|
+
interface IBodyTypeText {
|
|
87
|
+
marker: string;
|
|
88
|
+
type: 'text';
|
|
89
|
+
value: {
|
|
90
|
+
htmlValue: string;
|
|
91
|
+
plainValue: string;
|
|
92
|
+
params: {
|
|
93
|
+
isEditorDisabled: boolean;
|
|
94
|
+
isImageCompressed: boolean;
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* @property {string} marker - marker name
|
|
100
|
+
* @property {'textWithHeader'} type - Type value
|
|
101
|
+
* @property {object} value - Text Object. Contains html as string, header and params
|
|
102
|
+
*/
|
|
103
|
+
interface IBodyTypeTextWithHeader {
|
|
104
|
+
marker: string;
|
|
105
|
+
type: 'textWithHeader';
|
|
106
|
+
value: {
|
|
107
|
+
header: string;
|
|
108
|
+
htmlValue: string;
|
|
109
|
+
plainValue: string;
|
|
110
|
+
params: {
|
|
111
|
+
isEditorDisabled: boolean;
|
|
112
|
+
isImageCompressed: boolean;
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* @property {string} marker - marker name
|
|
118
|
+
* @property {'image' | 'groupOfImage'} type - Type value
|
|
119
|
+
* @property {object} value - Image Object. Contains image information
|
|
120
|
+
*/
|
|
121
|
+
interface IBodyTypeImageGroupOfImages {
|
|
122
|
+
marker: string;
|
|
123
|
+
type: 'image' | 'groupOfImage';
|
|
124
|
+
value: {
|
|
125
|
+
filename: string;
|
|
126
|
+
downloadLink: string;
|
|
127
|
+
size: number;
|
|
128
|
+
previewLink: string;
|
|
129
|
+
params: {
|
|
130
|
+
isImageCompressed: boolean;
|
|
131
|
+
};
|
|
132
|
+
} | Array<{
|
|
133
|
+
filename: string;
|
|
134
|
+
downloadLink: string;
|
|
135
|
+
size: number;
|
|
136
|
+
previewLink: string;
|
|
137
|
+
params: {
|
|
138
|
+
isImageCompressed: boolean;
|
|
139
|
+
};
|
|
140
|
+
}>;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* @property {string} marker - marker name
|
|
144
|
+
* @property {'file'} type - Type value
|
|
145
|
+
* @property {object} value - File Object. Contains file information
|
|
146
|
+
*/
|
|
147
|
+
interface IBodyTypeFile {
|
|
148
|
+
marker: string;
|
|
149
|
+
type: 'file';
|
|
150
|
+
value: {
|
|
151
|
+
filename: string;
|
|
152
|
+
downloadLink: string;
|
|
153
|
+
size: number;
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* @property {string} marker - marker name
|
|
158
|
+
* @property {'file'} type - Type value
|
|
159
|
+
* @property {array} value - Array of list or radioButton bojects.
|
|
160
|
+
*/
|
|
161
|
+
interface IBodyTypeRadioButtonList {
|
|
162
|
+
marker: string;
|
|
163
|
+
type: 'list' | 'radioButton';
|
|
164
|
+
value: Array<{
|
|
165
|
+
title: string;
|
|
166
|
+
value: string;
|
|
167
|
+
extended: {
|
|
168
|
+
value: string;
|
|
169
|
+
type: string;
|
|
170
|
+
};
|
|
171
|
+
}>;
|
|
172
|
+
}
|
|
173
|
+
export { IFormsPost, IFormsData, IFormData, IFormsDataEntity, IBodyTypeStringNumberFloat, IBodyTypeTimeDate, IBodyTypeText, IBodyTypeTextWithHeader, IBodyTypeImageGroupOfImages, IBodyTypeFile, IBodyTypeRadioButtonList };
|