oneentry 1.0.63 → 1.0.65
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 +846 -259
- package/dist/auth-provider/authProviderApi.d.ts +18 -10
- package/dist/auth-provider/authProviderApi.js +25 -22
- package/dist/auth-provider/authProvidersInterfaces.d.ts +9 -3
- package/dist/base/oneEntry.d.ts +1 -0
- package/dist/base/oneEntry.js +10 -5
- package/dist/base/utils.d.ts +2 -0
- package/dist/blocks/blocksApi.d.ts +7 -1
- package/dist/blocks/blocksApi.js +9 -0
- package/dist/blocks/blocksInterfaces.d.ts +8 -1
- package/dist/formsData/formsDataInterfaces.d.ts +1 -3
- package/dist/orders/ordersApi.d.ts +49 -10
- package/dist/orders/ordersApi.js +61 -13
- package/dist/orders/ordersInterfaces.d.ts +36 -1
- package/dist/products/productsInterfaces.d.ts +9 -0
- package/dist/templates/templatesApi.d.ts +8 -0
- package/dist/templates/templatesApi.js +11 -0
- package/dist/templates/templatesInterfaces.d.ts +4 -3
- package/dist/templates-preview/templatesPreviewInterfaces.d.ts +1 -1
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import OneEntry from "../base/oneEntry";
|
|
2
2
|
import { IConfig } from "../base/utils";
|
|
3
|
-
import { IAuthProvider, ISignUpData, ISignUpEntity, ICodeEntity, IAuthEntity, IAuthProvidersEntity } from "./authProvidersInterfaces";
|
|
3
|
+
import { IAuthProvider, ISignUpData, ISignUpEntity, ICodeEntity, IAuthEntity, IAuthProvidersEntity, IAuthPostBody } from "./authProvidersInterfaces";
|
|
4
4
|
/**
|
|
5
5
|
* Controllers for working with auth services.
|
|
6
6
|
*/
|
|
@@ -44,11 +44,6 @@ export default class AuthProviderApi extends OneEntry implements IAuthProvider {
|
|
|
44
44
|
* Getting a user activation code
|
|
45
45
|
* @param {string} marker - The text identifier of the authorization provider. Example - email
|
|
46
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
47
|
*/
|
|
53
48
|
generateCode(marker: string, userIdentifier: string): Promise<ICodeEntity>;
|
|
54
49
|
/**
|
|
@@ -61,11 +56,24 @@ export default class AuthProviderApi extends OneEntry implements IAuthProvider {
|
|
|
61
56
|
/**
|
|
62
57
|
* User authorization
|
|
63
58
|
* @param {string} marker - The text identifier of the authorization provider. Example - email
|
|
64
|
-
* @param {
|
|
65
|
-
*
|
|
59
|
+
* @param {IAuthPostBody} data - Array of objects contains auth information
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* const data = {
|
|
63
|
+
* authData: [
|
|
64
|
+
* {
|
|
65
|
+
* marker: "login",
|
|
66
|
+
* value: "test"
|
|
67
|
+
* },
|
|
68
|
+
* {
|
|
69
|
+
* marker: "password",
|
|
70
|
+
* value: "12345"
|
|
71
|
+
* }
|
|
72
|
+
* ]
|
|
73
|
+
* }
|
|
66
74
|
*
|
|
67
75
|
*/
|
|
68
|
-
auth(marker: string,
|
|
76
|
+
auth(marker: string, data: IAuthPostBody): Promise<IAuthEntity>;
|
|
69
77
|
/**
|
|
70
78
|
* Refresh token
|
|
71
79
|
* @param {string} marker - The text identifier of the authorization provider. Example - email
|
|
@@ -94,7 +102,7 @@ export default class AuthProviderApi extends OneEntry implements IAuthProvider {
|
|
|
94
102
|
* @param {number} [offset] - Parameter for pagination. Default 0
|
|
95
103
|
* @param {number} [limit] - Parameter for pagination. Default 30
|
|
96
104
|
*/
|
|
97
|
-
getAuthProviders(langCode
|
|
105
|
+
getAuthProviders(langCode?: string, offset?: number, limit?: number): Promise<Array<IAuthProvidersEntity>>;
|
|
98
106
|
/**
|
|
99
107
|
* Get one auth provider object by marker
|
|
100
108
|
* @param {string} marker - The text identifier of the authorization provider. Example - email
|
|
@@ -43,18 +43,14 @@ class AuthProviderApi extends oneEntry_1.default {
|
|
|
43
43
|
* }
|
|
44
44
|
*/
|
|
45
45
|
async signUp(marker, data, langCode = this._defaultLangCode) {
|
|
46
|
-
const
|
|
46
|
+
const body = this._normalizePostBody(data, langCode);
|
|
47
|
+
const result = await this._fetchPost(`/marker/${marker}/users/sign-up`, body);
|
|
47
48
|
return this._normalizeData(result);
|
|
48
49
|
}
|
|
49
50
|
/**
|
|
50
51
|
* Getting a user activation code
|
|
51
52
|
* @param {string} marker - The text identifier of the authorization provider. Example - email
|
|
52
53
|
* @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
54
|
*/
|
|
59
55
|
async generateCode(marker, userIdentifier) {
|
|
60
56
|
const data = {
|
|
@@ -80,22 +76,26 @@ class AuthProviderApi extends oneEntry_1.default {
|
|
|
80
76
|
/**
|
|
81
77
|
* User authorization
|
|
82
78
|
* @param {string} marker - The text identifier of the authorization provider. Example - email
|
|
83
|
-
* @param {
|
|
84
|
-
*
|
|
79
|
+
* @param {IAuthPostBody} data - Array of objects contains auth information
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* const data = {
|
|
83
|
+
* authData: [
|
|
84
|
+
* {
|
|
85
|
+
* marker: "login",
|
|
86
|
+
* value: "test"
|
|
87
|
+
* },
|
|
88
|
+
* {
|
|
89
|
+
* marker: "password",
|
|
90
|
+
* value: "12345"
|
|
91
|
+
* }
|
|
92
|
+
* ]
|
|
93
|
+
* }
|
|
85
94
|
*
|
|
86
95
|
*/
|
|
87
|
-
async auth(marker,
|
|
88
|
-
const
|
|
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);
|
|
96
|
+
async auth(marker, data) {
|
|
97
|
+
const result = await this._fetchPost(`/marker/${marker}/users/auth`, data);
|
|
98
|
+
this._userToken = result.accessToken;
|
|
99
99
|
return result;
|
|
100
100
|
}
|
|
101
101
|
/**
|
|
@@ -119,6 +119,9 @@ class AuthProviderApi extends oneEntry_1.default {
|
|
|
119
119
|
"refreshToken": token
|
|
120
120
|
};
|
|
121
121
|
const result = await this._fetchPost(`/marker/${marker}/users/logout`, data);
|
|
122
|
+
if (result) {
|
|
123
|
+
this._userToken = null;
|
|
124
|
+
}
|
|
122
125
|
return result;
|
|
123
126
|
}
|
|
124
127
|
/**
|
|
@@ -145,7 +148,7 @@ class AuthProviderApi extends oneEntry_1.default {
|
|
|
145
148
|
* @param {number} [offset] - Parameter for pagination. Default 0
|
|
146
149
|
* @param {number} [limit] - Parameter for pagination. Default 30
|
|
147
150
|
*/
|
|
148
|
-
async getAuthProviders(langCode, offset, limit) {
|
|
151
|
+
async getAuthProviders(langCode = this._defaultLangCode, offset = 0, limit = 30) {
|
|
149
152
|
const result = await this._fetchGet(`?langCode=${langCode}&offset=${offset}&limit=${limit}`);
|
|
150
153
|
return this._normalizeData(result);
|
|
151
154
|
}
|
|
@@ -154,7 +157,7 @@ class AuthProviderApi extends oneEntry_1.default {
|
|
|
154
157
|
* @param {string} marker - The text identifier of the authorization provider. Example - email
|
|
155
158
|
* @param {string} [langCode] - Optional parameter language code. Default "en_US"
|
|
156
159
|
*/
|
|
157
|
-
async getMarker(marker, langCode) {
|
|
160
|
+
async getMarker(marker, langCode = this._defaultLangCode) {
|
|
158
161
|
const result = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
|
|
159
162
|
return this._normalizeData(result);
|
|
160
163
|
}
|
|
@@ -16,11 +16,11 @@ interface IAuthProvider {
|
|
|
16
16
|
signUp(marker: string, data: ISignUpData, langCode?: string): Promise<ISignUpEntity>;
|
|
17
17
|
generateCode(marker: string, userIdentifier: string): Promise<ICodeEntity>;
|
|
18
18
|
activateUser(marker: string, userIdentifier: string, code: string): Promise<boolean>;
|
|
19
|
-
auth(marker: string,
|
|
19
|
+
auth(marker: string, data: IAuthPostBody): Promise<IAuthEntity>;
|
|
20
20
|
refresh(marker: string, token: string): Promise<IAuthEntity>;
|
|
21
21
|
logout(marker: string, token: string): Promise<boolean>;
|
|
22
22
|
changePassword(marker: string, userIdentifier: string, code: string, newPassword: string, repeatPassword?: string): Promise<boolean>;
|
|
23
|
-
getAuthProviders(langCode
|
|
23
|
+
getAuthProviders(langCode?: string, offset?: number, limit?: number): Promise<Array<IAuthProvidersEntity>>;
|
|
24
24
|
getMarker(marker: string, langCode?: string): Promise<IAuthProvidersEntity>;
|
|
25
25
|
}
|
|
26
26
|
interface IAuthFormData {
|
|
@@ -78,4 +78,10 @@ interface IAuthProvidersEntity {
|
|
|
78
78
|
type: string;
|
|
79
79
|
formIdentifier: string | null;
|
|
80
80
|
}
|
|
81
|
-
|
|
81
|
+
interface IAuthPostBody {
|
|
82
|
+
authData: Array<{
|
|
83
|
+
marker: string;
|
|
84
|
+
value: string | number;
|
|
85
|
+
}>;
|
|
86
|
+
}
|
|
87
|
+
export { IAuthProvider, IAuthFormData, ISignUpData, ISignUpEntity, ICodeEntity, IAuthEntity, IAuthProvidersEntity, IAuthPostBody };
|
package/dist/base/oneEntry.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { IUploadingQuery } from "../file-uploding/fileUploadingInterfaces";
|
|
|
4
4
|
export default abstract class OneEntry {
|
|
5
5
|
protected _url: string;
|
|
6
6
|
protected _token: string | undefined;
|
|
7
|
+
protected _userToken: string | undefined;
|
|
7
8
|
protected _defaultLangCode: string;
|
|
8
9
|
protected _multipleResponse: boolean;
|
|
9
10
|
protected _NO_FETCH: boolean;
|
package/dist/base/oneEntry.js
CHANGED
|
@@ -5,6 +5,7 @@ class OneEntry {
|
|
|
5
5
|
var _a;
|
|
6
6
|
this._url = url;
|
|
7
7
|
this._token = config.token;
|
|
8
|
+
this._userToken = config.userToken;
|
|
8
9
|
this._defaultLangCode = config.langCode ? config.langCode : 'en_US';
|
|
9
10
|
this._multipleResponse = (_a = config.multipleRequests) !== null && _a !== void 0 ? _a : true;
|
|
10
11
|
this._NO_FETCH = !!(typeof process === 'object' && process.versions);
|
|
@@ -24,6 +25,7 @@ class OneEntry {
|
|
|
24
25
|
headers: {
|
|
25
26
|
'Content-Type': 'application/json',
|
|
26
27
|
'x-app-token': this._token,
|
|
28
|
+
'Authorization': this._userToken
|
|
27
29
|
}
|
|
28
30
|
};
|
|
29
31
|
if (!this._NO_FETCH) {
|
|
@@ -56,7 +58,8 @@ class OneEntry {
|
|
|
56
58
|
method: 'POST',
|
|
57
59
|
headers: {
|
|
58
60
|
'x-app-token': this._token,
|
|
59
|
-
'Content-Type': 'application/json'
|
|
61
|
+
'Content-Type': 'application/json',
|
|
62
|
+
'Authorization': this._userToken ? 'Bearer ' + this._userToken : null
|
|
60
63
|
}
|
|
61
64
|
};
|
|
62
65
|
if (data instanceof FormData || data instanceof Blob) {
|
|
@@ -65,7 +68,7 @@ class OneEntry {
|
|
|
65
68
|
if (!this._NO_FETCH) {
|
|
66
69
|
const response = await fetch(this._getFullPath(path), {
|
|
67
70
|
...options,
|
|
68
|
-
body: data
|
|
71
|
+
body: JSON.stringify(data)
|
|
69
72
|
});
|
|
70
73
|
if (!response.ok) {
|
|
71
74
|
const error = await response.json();
|
|
@@ -87,7 +90,7 @@ class OneEntry {
|
|
|
87
90
|
req.on('error', (error) => {
|
|
88
91
|
reject(error);
|
|
89
92
|
});
|
|
90
|
-
req.write(data);
|
|
93
|
+
req.write(JSON.stringify(data));
|
|
91
94
|
req.end();
|
|
92
95
|
});
|
|
93
96
|
}
|
|
@@ -98,6 +101,7 @@ class OneEntry {
|
|
|
98
101
|
headers: {
|
|
99
102
|
'x-app-token': this._token,
|
|
100
103
|
'Content-Type': 'application/json',
|
|
104
|
+
'Authorization': this._userToken ? 'Bearer ' + this._userToken : null
|
|
101
105
|
},
|
|
102
106
|
};
|
|
103
107
|
if (data instanceof FormData || data instanceof Blob) {
|
|
@@ -106,7 +110,7 @@ class OneEntry {
|
|
|
106
110
|
if (!this._NO_FETCH) {
|
|
107
111
|
const response = await fetch(this._getFullPath(path), {
|
|
108
112
|
...options,
|
|
109
|
-
body: data,
|
|
113
|
+
body: JSON.stringify(data),
|
|
110
114
|
});
|
|
111
115
|
if (!response.ok) {
|
|
112
116
|
const error = await response.json();
|
|
@@ -128,7 +132,7 @@ class OneEntry {
|
|
|
128
132
|
req.on('error', (error) => {
|
|
129
133
|
reject(error);
|
|
130
134
|
});
|
|
131
|
-
req.write(data);
|
|
135
|
+
req.write(JSON.stringify(data));
|
|
132
136
|
req.end();
|
|
133
137
|
});
|
|
134
138
|
}
|
|
@@ -139,6 +143,7 @@ class OneEntry {
|
|
|
139
143
|
headers: {
|
|
140
144
|
'Content-Type': 'application/json',
|
|
141
145
|
'x-app-token': this._token,
|
|
146
|
+
'Authorization': this._userToken ? 'Bearer ' + this._userToken : null
|
|
142
147
|
},
|
|
143
148
|
body: data
|
|
144
149
|
};
|
package/dist/base/utils.d.ts
CHANGED
|
@@ -23,9 +23,11 @@ declare enum Types {
|
|
|
23
23
|
* @param {string} [token] - If your project is protected by a token, specify this token in this parameter.
|
|
24
24
|
* @param {string} [langCode] - specify the default language to avoid specifying it in every request.
|
|
25
25
|
* @param {boolean} [multipleRequests] - Some methods use multiple queries to make it easier to work with the API. Set this parameter to "false" to save traffic and decide for yourself what data you need.
|
|
26
|
+
* @param {boolean} [userToken] - If your project uses user authorization, pass the user access token to the "userToken" variable to use methods that require authorization.
|
|
26
27
|
*/
|
|
27
28
|
interface IConfig {
|
|
28
29
|
token?: string;
|
|
30
|
+
userToken?: string;
|
|
29
31
|
langCode?: string;
|
|
30
32
|
multipleRequests?: boolean;
|
|
31
33
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import OneEntry from "../base/oneEntry";
|
|
2
|
-
import { IBlocks, IBlocksResponse, IBlockEntity } from "./blocksInterfaces";
|
|
2
|
+
import { IBlocks, IBlocksResponse, IBlockEntity, ISearchBlock } from "./blocksInterfaces";
|
|
3
3
|
import { IProductsEntity } from "../products/productsInterfaces";
|
|
4
4
|
import { IConfig } from "../base/utils";
|
|
5
5
|
/**
|
|
@@ -48,4 +48,10 @@ export default class BlocksApi extends OneEntry implements IBlocks {
|
|
|
48
48
|
* @returns Return array of BlocksEntity object.
|
|
49
49
|
*/
|
|
50
50
|
getProductsByBlockMarker(marker: string, langCode?: string, offset?: number, limit?: number): Promise<Array<IProductsEntity>>;
|
|
51
|
+
/**
|
|
52
|
+
* Quick search for block objects with limited output
|
|
53
|
+
* @param name - Search string
|
|
54
|
+
* @param [langCode] - Language code. Default "en_US"
|
|
55
|
+
*/
|
|
56
|
+
searchBlock(name: string, langCode?: string): Promise<Array<ISearchBlock>>;
|
|
51
57
|
}
|
package/dist/blocks/blocksApi.js
CHANGED
|
@@ -131,5 +131,14 @@ class BlocksApi extends oneEntry_1.default {
|
|
|
131
131
|
const result = await this._fetchGet(`/${marker}/products?langCode=${langCode}&offset=${offset}&limit=${limit}`);
|
|
132
132
|
return this._normalizeData(result.items);
|
|
133
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* Quick search for block objects with limited output
|
|
136
|
+
* @param name - Search string
|
|
137
|
+
* @param [langCode] - Language code. Default "en_US"
|
|
138
|
+
*/
|
|
139
|
+
async searchBlock(name, langCode = this._defaultLangCode) {
|
|
140
|
+
const result = await this._fetchGet(`/quick/search?langCode=${langCode}&name=${name}`);
|
|
141
|
+
return result;
|
|
142
|
+
}
|
|
134
143
|
}
|
|
135
144
|
exports.default = BlocksApi;
|
|
@@ -6,12 +6,14 @@ import { IProductsEntity } from "../products/productsInterfaces";
|
|
|
6
6
|
* @property {function} getBlockByMarker - Get Block object by marker.
|
|
7
7
|
* @property {function} getSimilarProducts - Get Array of similar products from product-similar block.
|
|
8
8
|
* @property {function} getProductsByBlockMarker - Get Array of products from product block.
|
|
9
|
+
* @property {function} searchBlock - Quick search for block objects with limited output.
|
|
9
10
|
*/
|
|
10
11
|
interface IBlocks {
|
|
11
12
|
getBlocks(langCode: string, offset?: number, limit?: number): Promise<Array<IBlockEntity | IBlocksResponse>>;
|
|
12
13
|
getBlockByMarker(marker: string, langCode: string): Promise<IBlockEntity>;
|
|
13
14
|
getSimilarProducts(marker: string, langCode?: string, offset?: number, limit?: number): Promise<Array<IProductsEntity>>;
|
|
14
15
|
getProductsByBlockMarker(marker: string, langCode?: string, offset?: number, limit?: number): Promise<Array<IProductsEntity>>;
|
|
16
|
+
searchBlock(name: string, langCode?: string): Promise<Array<ISearchBlock>>;
|
|
15
17
|
}
|
|
16
18
|
interface IBlocksResponse {
|
|
17
19
|
id: number;
|
|
@@ -59,4 +61,9 @@ interface ICustomSetting {
|
|
|
59
61
|
}> | Record<string, any>;
|
|
60
62
|
[key: string]: any;
|
|
61
63
|
}
|
|
62
|
-
|
|
64
|
+
interface ISearchBlock {
|
|
65
|
+
id: number;
|
|
66
|
+
name: string;
|
|
67
|
+
identifier: string;
|
|
68
|
+
}
|
|
69
|
+
export { IBlocks, IBlockEntity, IBlocksResponse, ICustomSetting, ISearchBlock };
|
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
* Represents a interface object of Forms Api.
|
|
3
3
|
*
|
|
4
4
|
* @property {function} getFormsData - Get all forms data.
|
|
5
|
-
*
|
|
6
5
|
* @property {function} postFormsData - Find all product page objects with pagination and multiple filtering.
|
|
7
|
-
*
|
|
8
6
|
* @property {function} getFormsDataByMarker - Get one object of form data by marker.
|
|
9
7
|
*/
|
|
10
8
|
interface IFormsData {
|
|
@@ -52,7 +50,7 @@ interface IFormsPost {
|
|
|
52
50
|
id?: number;
|
|
53
51
|
formIdentifier: string;
|
|
54
52
|
time?: Date | string;
|
|
55
|
-
formData: Array<IBodyTypeStringNumberFloat | IBodyTypeTimeDate | IBodyTypeText | IBodyTypeTextWithHeader | IBodyTypeImageGroupOfImages | IBodyTypeFile | IBodyTypeRadioButtonList
|
|
53
|
+
formData: Array<IBodyTypeStringNumberFloat | IBodyTypeTimeDate | IBodyTypeText | IBodyTypeTextWithHeader | IBodyTypeImageGroupOfImages | IBodyTypeFile | IBodyTypeRadioButtonList | Record<string, any>>;
|
|
56
54
|
}
|
|
57
55
|
/**
|
|
58
56
|
* @property {string} marker - marker name
|
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
import OneEntry from "../base/oneEntry";
|
|
2
2
|
import { IConfig } from "../base/utils";
|
|
3
|
-
import { IOrdersApi, IOrdersEntity, IBaseOrdersEntity, IOrderData } from "./ordersInterfaces";
|
|
3
|
+
import { IOrdersApi, IOrdersEntity, IBaseOrdersEntity, IOrderData, IOrdersByMarkersEntity } from "./ordersInterfaces";
|
|
4
4
|
/**
|
|
5
5
|
* Controllers for working with orders
|
|
6
6
|
*/
|
|
7
7
|
export default class OrdersApi extends OneEntry implements IOrdersApi {
|
|
8
8
|
constructor(url: string, config: IConfig);
|
|
9
|
-
/**
|
|
10
|
-
* Retrieve one order storage object by marker.
|
|
11
|
-
*
|
|
12
|
-
* @param {string} marker - Marker of the order object
|
|
13
|
-
* @param {string} [langCode] - Language code
|
|
14
|
-
*
|
|
15
|
-
* @returns Return object of order information.
|
|
16
|
-
*/
|
|
17
|
-
getOrderByMarker(marker: string, langCode?: string): Promise<IOrdersEntity>;
|
|
18
9
|
/**
|
|
19
10
|
* Creation of an order in the order storage.
|
|
20
11
|
*
|
|
@@ -43,4 +34,52 @@ export default class OrdersApi extends OneEntry implements IOrdersApi {
|
|
|
43
34
|
* @returns Returns object for creating an order.
|
|
44
35
|
*/
|
|
45
36
|
createOrder(marker: string, data: IOrderData, langCode?: string): Promise<IBaseOrdersEntity>;
|
|
37
|
+
/**
|
|
38
|
+
* Getting all order storage object by marker
|
|
39
|
+
* @param {number} marker - Textual identifier of the order storage object
|
|
40
|
+
* @param {number} [langCode] Optional language field
|
|
41
|
+
*/
|
|
42
|
+
getAllOrdersByMarker(marker: string, langCode?: string): Promise<Array<IOrdersByMarkersEntity>>;
|
|
43
|
+
/**
|
|
44
|
+
* Changing an order in the order store
|
|
45
|
+
* @param marker - The text identifier of the order storage object
|
|
46
|
+
* @param id - ID of the order object
|
|
47
|
+
* @param data Object for updating an order
|
|
48
|
+
* @param langCode Optional language field
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* const body = {
|
|
52
|
+
* "formIdentifier": "bar-orders-form",
|
|
53
|
+
* "paymentIdentifier": "usd-payment",
|
|
54
|
+
* "formData": {
|
|
55
|
+
* "marker": "name_1",
|
|
56
|
+
* "value": "Name"
|
|
57
|
+
* },
|
|
58
|
+
* "products": [
|
|
59
|
+
* {
|
|
60
|
+
* "productId": 1,
|
|
61
|
+
* "quantity": 2,
|
|
62
|
+
* "price": "23.02"
|
|
63
|
+
* }
|
|
64
|
+
* ],
|
|
65
|
+
* "currency": "USD"
|
|
66
|
+
* }
|
|
67
|
+
*/
|
|
68
|
+
updateOrderByMarkerAndId(marker: string, id: string, data: IOrderData, langCode?: string): Promise<IBaseOrdersEntity>;
|
|
69
|
+
/**
|
|
70
|
+
* Getting all the order storage objects
|
|
71
|
+
* @param {number} [langCode] Optional language field
|
|
72
|
+
* @param {number} [limit] - Optional parameter for pagination, default is 0
|
|
73
|
+
* @param {number} [offset] - Optional parameter for pagination, default is 30
|
|
74
|
+
*/
|
|
75
|
+
getAllOrders(langCode?: string, limit?: number, offset?: number): Promise<Array<IOrdersEntity>>;
|
|
76
|
+
/**
|
|
77
|
+
* Retrieve one order storage object by marker.
|
|
78
|
+
*
|
|
79
|
+
* @param {string} marker - Marker of the order object
|
|
80
|
+
* @param {string} [langCode] - Language code
|
|
81
|
+
*
|
|
82
|
+
* @returns Return object of order information.
|
|
83
|
+
*/
|
|
84
|
+
getOrderByMarker(marker: string, langCode?: string): Promise<IOrdersEntity>;
|
|
46
85
|
}
|
package/dist/orders/ordersApi.js
CHANGED
|
@@ -9,18 +9,6 @@ class OrdersApi extends oneEntry_1.default {
|
|
|
9
9
|
super(url, config);
|
|
10
10
|
this._url += '/api/content/orders-storage';
|
|
11
11
|
}
|
|
12
|
-
/**
|
|
13
|
-
* Retrieve one order storage object by marker.
|
|
14
|
-
*
|
|
15
|
-
* @param {string} marker - Marker of the order object
|
|
16
|
-
* @param {string} [langCode] - Language code
|
|
17
|
-
*
|
|
18
|
-
* @returns Return object of order information.
|
|
19
|
-
*/
|
|
20
|
-
async getOrderByMarker(marker, langCode = this._defaultLangCode) {
|
|
21
|
-
const result = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
|
|
22
|
-
return this._normalizeData(result);
|
|
23
|
-
}
|
|
24
12
|
/**
|
|
25
13
|
* Creation of an order in the order storage.
|
|
26
14
|
*
|
|
@@ -52,7 +40,67 @@ class OrdersApi extends oneEntry_1.default {
|
|
|
52
40
|
const formData = {};
|
|
53
41
|
formData[langCode] = Array.isArray(data.formData) ? data.formData : [data.formData];
|
|
54
42
|
data.formData = formData;
|
|
55
|
-
const result = await this._fetchPost(`/marker/${marker}/
|
|
43
|
+
const result = await this._fetchPost(`/marker/${marker}/orders`, data);
|
|
44
|
+
return this._normalizeData(result);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Getting all order storage object by marker
|
|
48
|
+
* @param {number} marker - Textual identifier of the order storage object
|
|
49
|
+
* @param {number} [langCode] Optional language field
|
|
50
|
+
*/
|
|
51
|
+
async getAllOrdersByMarker(marker, langCode = this._defaultLangCode) {
|
|
52
|
+
const result = this._fetchGet(`/marker/${marker}/orders?langCode=${langCode}`);
|
|
53
|
+
return this._normalizeData(result.items);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Changing an order in the order store
|
|
57
|
+
* @param marker - The text identifier of the order storage object
|
|
58
|
+
* @param id - ID of the order object
|
|
59
|
+
* @param data Object for updating an order
|
|
60
|
+
* @param langCode Optional language field
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* const body = {
|
|
64
|
+
* "formIdentifier": "bar-orders-form",
|
|
65
|
+
* "paymentIdentifier": "usd-payment",
|
|
66
|
+
* "formData": {
|
|
67
|
+
* "marker": "name_1",
|
|
68
|
+
* "value": "Name"
|
|
69
|
+
* },
|
|
70
|
+
* "products": [
|
|
71
|
+
* {
|
|
72
|
+
* "productId": 1,
|
|
73
|
+
* "quantity": 2,
|
|
74
|
+
* "price": "23.02"
|
|
75
|
+
* }
|
|
76
|
+
* ],
|
|
77
|
+
* "currency": "USD"
|
|
78
|
+
* }
|
|
79
|
+
*/
|
|
80
|
+
async updateOrderByMarkerAndId(marker, id, data, langCode = this._defaultLangCode) {
|
|
81
|
+
const result = await this._fetchPut(`/marker/${marker}/orders/${id}?langCode=${langCode}`, data);
|
|
82
|
+
return this._normalizeData(result);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Getting all the order storage objects
|
|
86
|
+
* @param {number} [langCode] Optional language field
|
|
87
|
+
* @param {number} [limit] - Optional parameter for pagination, default is 0
|
|
88
|
+
* @param {number} [offset] - Optional parameter for pagination, default is 30
|
|
89
|
+
*/
|
|
90
|
+
async getAllOrders(langCode = this._defaultLangCode, limit = 30, offset = 0) {
|
|
91
|
+
const result = await this._fetchGet(`?langCode=${langCode}&limit=${limit}&offset=${offset}`);
|
|
92
|
+
return this._normalizeData(result);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Retrieve one order storage object by marker.
|
|
96
|
+
*
|
|
97
|
+
* @param {string} marker - Marker of the order object
|
|
98
|
+
* @param {string} [langCode] - Language code
|
|
99
|
+
*
|
|
100
|
+
* @returns Return object of order information.
|
|
101
|
+
*/
|
|
102
|
+
async getOrderByMarker(marker, langCode = this._defaultLangCode) {
|
|
103
|
+
const result = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
|
|
56
104
|
return this._normalizeData(result);
|
|
57
105
|
}
|
|
58
106
|
}
|
|
@@ -3,11 +3,17 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @property {function} getOrderByMarker - Retrieve one order storage object by marker.
|
|
5
5
|
* @property {function} createOrder - Creation of an order in the order storage.
|
|
6
|
+
* @property {function} updateOrderByMarkerAndId - Changing an order in the order store.
|
|
7
|
+
* @property {function} getAllOrders - Getting all the order storage objects.
|
|
8
|
+
* @property {function} getAllOrdersByMarker - Getting one order storage object by marker.
|
|
6
9
|
|
|
7
10
|
*/
|
|
8
11
|
interface IOrdersApi {
|
|
9
12
|
getOrderByMarker(marker: string, langCode?: string): Promise<IOrdersEntity>;
|
|
10
13
|
createOrder(marker: string, data: IOrderData): Promise<IBaseOrdersEntity>;
|
|
14
|
+
updateOrderByMarkerAndId(marker: string, id: string, data: IOrderData, langCode?: string): Promise<IBaseOrdersEntity>;
|
|
15
|
+
getAllOrders(langCode?: string, limit?: number, offset?: number): Promise<Array<IOrdersEntity>>;
|
|
16
|
+
getAllOrdersByMarker(marker: string, langCode?: string): Promise<Array<IOrdersByMarkersEntity>>;
|
|
11
17
|
}
|
|
12
18
|
interface IPicture {
|
|
13
19
|
filename: string;
|
|
@@ -105,4 +111,33 @@ interface IOrderData {
|
|
|
105
111
|
products: Array<IOrderProductData>;
|
|
106
112
|
currency: string;
|
|
107
113
|
}
|
|
108
|
-
|
|
114
|
+
/**
|
|
115
|
+
* @interface
|
|
116
|
+
* @property {string} statusIdentifier - Text identifier of the order status.
|
|
117
|
+
* @property {string} formIdentifier - Text identifier of the form status.
|
|
118
|
+
* @property {string} paymentIdentifier - Text identifier of the order payment.
|
|
119
|
+
* @property {Array<IOrdersFormData>} formData - Data submitted by the form linked to the order store.
|
|
120
|
+
* @property {Array<IOrderProducts>} products - Array of products added to order.
|
|
121
|
+
* @property {string} totalSum - Total order amount.
|
|
122
|
+
* @property {number} price - Price order.
|
|
123
|
+
* @property {string} currency - Currency used to pay for the order.
|
|
124
|
+
* @property {string} createdDate - Date when the order was created.
|
|
125
|
+
* @property {string} paymentAccountIdentifier - Textual identifier for the order payment.
|
|
126
|
+
* @property {Record<string, any>} paymentAccountLocalizeInfos - Payment account name considering localization.
|
|
127
|
+
* @property {boolean} isHistory - Indicates that the order has been saved in the order history.
|
|
128
|
+
*/
|
|
129
|
+
interface IOrdersByMarkersEntity {
|
|
130
|
+
statusIdentifier: string;
|
|
131
|
+
formIdentifier: string;
|
|
132
|
+
paymentIdentifier: string;
|
|
133
|
+
formData: Array<IOrdersFormData>;
|
|
134
|
+
products: Array<IOrderProducts>;
|
|
135
|
+
totalSum: string;
|
|
136
|
+
currency: string;
|
|
137
|
+
createdDate: string;
|
|
138
|
+
price: number;
|
|
139
|
+
paymentAccountIdentifier: string;
|
|
140
|
+
paymentAccountLocalizeInfos: Record<string, any>;
|
|
141
|
+
isHistory: boolean;
|
|
142
|
+
}
|
|
143
|
+
export { IOrdersEntity, IBaseOrdersEntity, IOrderProducts, IPicture, IOrdersApi, IOrderData, IOrderProductData, IOrderMarkerData, IOrdersFormData, IOrdersByMarkersEntity };
|
|
@@ -93,6 +93,7 @@ interface IFilterParams {
|
|
|
93
93
|
*
|
|
94
94
|
* @interface
|
|
95
95
|
* @property {number} id - The unique identifier.
|
|
96
|
+
* @property {object} additional - Additional value from the index.
|
|
96
97
|
* @property {Record<string, any>} localizeInfos - The name of the products, taking into account localization.
|
|
97
98
|
* @property {boolean} isVisible - A sign of page visibility.
|
|
98
99
|
* @property {number | null} statusId - Product page status identifiers (may be null).
|
|
@@ -102,10 +103,17 @@ interface IFilterParams {
|
|
|
102
103
|
* @property {number} price - The value of the product page price taken from the index.
|
|
103
104
|
* @property {string} templateIdentifier - User id of the linked template.
|
|
104
105
|
* @property {string} shortDescTemplateIdentifier - User id of the linked template for a short description.
|
|
106
|
+
* @property {Record<string, any>} statusLocalizeInfos - JSON description of the item status object, taking into account the language.
|
|
105
107
|
* @property {number} position - Item number (for sorting).
|
|
106
108
|
*/
|
|
107
109
|
interface IProductsEntity {
|
|
108
110
|
id: number;
|
|
111
|
+
additional: {
|
|
112
|
+
prices: {
|
|
113
|
+
min: number;
|
|
114
|
+
max: number;
|
|
115
|
+
};
|
|
116
|
+
};
|
|
109
117
|
localizeInfos: Record<string, any>;
|
|
110
118
|
blocks?: string | Array<string>;
|
|
111
119
|
isVisible: boolean;
|
|
@@ -116,6 +124,7 @@ interface IProductsEntity {
|
|
|
116
124
|
price: number;
|
|
117
125
|
templateIdentifier: string | null;
|
|
118
126
|
shortDescTemplateIdentifier: string;
|
|
127
|
+
statusLocalizeInfos: Record<string, any>;
|
|
119
128
|
attributeValues: Record<string, any>;
|
|
120
129
|
position: number;
|
|
121
130
|
sku: string | null;
|
|
@@ -22,4 +22,12 @@ export default class TemplatesPreviewApi extends OneEntry implements ITemplatesA
|
|
|
22
22
|
* @returns Returns a TemplateEntity object
|
|
23
23
|
*/
|
|
24
24
|
getTemplateByType(type: Types, langCode?: string): Promise<Array<ITemplateEntity>>;
|
|
25
|
+
/**
|
|
26
|
+
* Get one template object by id.
|
|
27
|
+
*
|
|
28
|
+
* @param {string} id - Template id
|
|
29
|
+
*
|
|
30
|
+
* @returns Returns a TemplateEntity object
|
|
31
|
+
*/
|
|
32
|
+
getTemplateById(id: string): Promise<ITemplateList>;
|
|
25
33
|
}
|
|
@@ -35,5 +35,16 @@ class TemplatesPreviewApi extends oneEntry_1.default {
|
|
|
35
35
|
const result = await this._fetchGet(`?type=${type}`);
|
|
36
36
|
return this._normalizeData(result, langCode);
|
|
37
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Get one template object by id.
|
|
40
|
+
*
|
|
41
|
+
* @param {string} id - Template id
|
|
42
|
+
*
|
|
43
|
+
* @returns Returns a TemplateEntity object
|
|
44
|
+
*/
|
|
45
|
+
async getTemplateById(id) {
|
|
46
|
+
const result = await this._fetchGet(`/${id}`);
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
38
49
|
}
|
|
39
50
|
exports.default = TemplatesPreviewApi;
|
|
@@ -4,12 +4,13 @@ import { Types } from "../base/utils";
|
|
|
4
4
|
* Represents an interface object of Templates Api.
|
|
5
5
|
*
|
|
6
6
|
* @property {function} getAllTemplates - Get all template objects grouped by types.
|
|
7
|
-
*
|
|
8
7
|
* @property {function} getTemplateByType - Get template objects by type.
|
|
8
|
+
* @property {function} getTemplateById - Get one template object by id.
|
|
9
9
|
*/
|
|
10
10
|
interface ITemplatesApi {
|
|
11
11
|
getAllTemplates(langCode: string): Promise<ITemplateList>;
|
|
12
12
|
getTemplateByType(type: Types, langCode: string): Promise<Array<ITemplateEntity>>;
|
|
13
|
+
getTemplateById(id: string): Promise<ITemplateList>;
|
|
13
14
|
}
|
|
14
15
|
/**
|
|
15
16
|
* Represents a template entity object.
|
|
@@ -21,7 +22,7 @@ interface ITemplatesApi {
|
|
|
21
22
|
* @property {string} identifier - The textual identifier for the record field.
|
|
22
23
|
* @property {IGeneralTypesEntity} generalType - General type Entity object.
|
|
23
24
|
* @property {number} generalTypeId - General type Entity id.
|
|
24
|
-
* @property {
|
|
25
|
+
* @property {string} title - The name of the template.
|
|
25
26
|
* @property {number} position - The position of the object.
|
|
26
27
|
* @property {number | string} positionId - Id of the item object.
|
|
27
28
|
* @property {Types} generalTypeName - General type name.
|
|
@@ -34,7 +35,7 @@ interface ITemplateEntity {
|
|
|
34
35
|
identifier: string;
|
|
35
36
|
generalType?: IGeneralTypesEntity;
|
|
36
37
|
generalTypeId: number;
|
|
37
|
-
|
|
38
|
+
title: string;
|
|
38
39
|
position: number;
|
|
39
40
|
positionId?: number;
|
|
40
41
|
generalTypeName: Types;
|