oneentry 1.0.38 → 1.0.39
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/dist/base/oneEntry.d.ts +1 -1
- package/dist/base/oneEntry.js +6 -3
- package/dist/file-uploding/fileUploadingApi.d.ts +5 -5
- package/dist/file-uploding/fileUploadingApi.js +7 -5
- package/dist/file-uploding/fileUploadingInterfaces.d.ts +4 -4
- package/dist/formsData/formsDataApi.js +2 -2
- package/dist/products/productsApi.js +2 -2
- package/package.json +1 -1
package/dist/base/oneEntry.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export default abstract class OneEntry {
|
|
|
9
9
|
constructor(url: string, token?: string);
|
|
10
10
|
protected _getFullPath(path: string): string;
|
|
11
11
|
protected _fetchGet(path: string): Promise<any>;
|
|
12
|
-
protected _fetchPost(path: string, data:
|
|
12
|
+
protected _fetchPost(path: string, data: any): Promise<any>;
|
|
13
13
|
protected _fetchDelete(path: string): Promise<any>;
|
|
14
14
|
protected _queryParamsToString(query: IProductsQuery | IUploadingQuery): string;
|
|
15
15
|
protected _parseLangFromString(str: string, lang: string): string;
|
package/dist/base/oneEntry.js
CHANGED
|
@@ -50,14 +50,17 @@ class OneEntry {
|
|
|
50
50
|
const options = {
|
|
51
51
|
method: 'POST',
|
|
52
52
|
headers: {
|
|
53
|
-
'Content-Type': 'application/json',
|
|
54
53
|
'x-app-token': this._token,
|
|
54
|
+
'Content-Type': 'application/json'
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
|
+
if (data instanceof FormData) {
|
|
58
|
+
delete options.headers['Content-Type'];
|
|
59
|
+
}
|
|
57
60
|
if (!this._NO_FETCH) {
|
|
58
61
|
const response = await fetch(this._getFullPath(path), {
|
|
59
62
|
...options,
|
|
60
|
-
body:
|
|
63
|
+
body: data
|
|
61
64
|
});
|
|
62
65
|
return await response.json();
|
|
63
66
|
}
|
|
@@ -76,7 +79,7 @@ class OneEntry {
|
|
|
76
79
|
req.on('error', (error) => {
|
|
77
80
|
reject(error);
|
|
78
81
|
});
|
|
79
|
-
req.write(
|
|
82
|
+
req.write(data);
|
|
80
83
|
req.end();
|
|
81
84
|
});
|
|
82
85
|
}
|
|
@@ -9,19 +9,19 @@ export default class FileUploadingApi extends OneEntry implements IFileUploading
|
|
|
9
9
|
/**
|
|
10
10
|
* Upload file function.
|
|
11
11
|
*
|
|
12
|
-
* @param {
|
|
12
|
+
* @param {File} [data] File objects. Get data as File from your unput as e.target.files[0]
|
|
13
13
|
*
|
|
14
14
|
* @param {IUploadingQuery} [fileQuery] - Optional set query parameters.
|
|
15
|
-
* @param {string}
|
|
16
|
-
* @param {string}
|
|
17
|
-
* @param {number}
|
|
15
|
+
* @param {string} fileQuery.type - Type, determines the folder name in the storage. Example : "page"
|
|
16
|
+
* @param {string} fileQuery.entity - Entity name from which the file is uploaded, determines the folder name in the storage. Example : "editor"
|
|
17
|
+
* @param {number} fileQuery.id - Identifier of the object from which the file is uploaded, determines the folder name in the storage. Example : 3787
|
|
18
18
|
* @param {number} [fileQuery.width] - Optional width parameter. Example : 0
|
|
19
19
|
* @param {number} [fileQuery.height] - Optional height parameter. Example : 0
|
|
20
20
|
* @param {boolean} [fileQuery.compress] - Optional flag of optimization (compression) for images. Example : true
|
|
21
21
|
*
|
|
22
22
|
* @returns Uploads a file to an Amazon S3-compatible cloud file storage
|
|
23
23
|
*/
|
|
24
|
-
upload(data:
|
|
24
|
+
upload(data: File, fileQuery?: IUploadingQuery): Promise<IUploadingReturns>;
|
|
25
25
|
/**
|
|
26
26
|
* Deletes a file from the cloud file storage.
|
|
27
27
|
*
|
|
@@ -20,12 +20,12 @@ class FileUploadingApi extends oneEntry_1.default {
|
|
|
20
20
|
/**
|
|
21
21
|
* Upload file function.
|
|
22
22
|
*
|
|
23
|
-
* @param {
|
|
23
|
+
* @param {File} [data] File objects. Get data as File from your unput as e.target.files[0]
|
|
24
24
|
*
|
|
25
25
|
* @param {IUploadingQuery} [fileQuery] - Optional set query parameters.
|
|
26
|
-
* @param {string}
|
|
27
|
-
* @param {string}
|
|
28
|
-
* @param {number}
|
|
26
|
+
* @param {string} fileQuery.type - Type, determines the folder name in the storage. Example : "page"
|
|
27
|
+
* @param {string} fileQuery.entity - Entity name from which the file is uploaded, determines the folder name in the storage. Example : "editor"
|
|
28
|
+
* @param {number} fileQuery.id - Identifier of the object from which the file is uploaded, determines the folder name in the storage. Example : 3787
|
|
29
29
|
* @param {number} [fileQuery.width] - Optional width parameter. Example : 0
|
|
30
30
|
* @param {number} [fileQuery.height] - Optional height parameter. Example : 0
|
|
31
31
|
* @param {boolean} [fileQuery.compress] - Optional flag of optimization (compression) for images. Example : true
|
|
@@ -34,7 +34,9 @@ class FileUploadingApi extends oneEntry_1.default {
|
|
|
34
34
|
*/
|
|
35
35
|
async upload(data, fileQuery) {
|
|
36
36
|
const query = { ...this._defaultQuery, ...fileQuery };
|
|
37
|
-
const
|
|
37
|
+
const body = new FormData();
|
|
38
|
+
body.append('files', data);
|
|
39
|
+
const result = await this._fetchPost('?' + this._queryParamsToString(query), body);
|
|
38
40
|
return result;
|
|
39
41
|
}
|
|
40
42
|
/**
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @property {function} getFile - Get file by parameters.
|
|
7
7
|
*/
|
|
8
8
|
interface IFileUploading {
|
|
9
|
-
upload(data:
|
|
9
|
+
upload(data: File, fileQuery?: IUploadingQuery): Promise<IUploadingReturns>;
|
|
10
10
|
delete(filename: string, fileQuery?: IUploadingQuery): Promise<any>;
|
|
11
11
|
getFile(id: number, type: string, entity: string, filename?: string): Promise<IFileEntity>;
|
|
12
12
|
}
|
|
@@ -23,9 +23,9 @@ interface IFileEntity {
|
|
|
23
23
|
* @property {boolean} [compress] - Flag of optimization (compression) for images.
|
|
24
24
|
*/
|
|
25
25
|
interface IUploadingQuery {
|
|
26
|
-
type
|
|
27
|
-
entity
|
|
28
|
-
id
|
|
26
|
+
type: string | null;
|
|
27
|
+
entity: string | null;
|
|
28
|
+
id: number | null;
|
|
29
29
|
width?: number | null;
|
|
30
30
|
height?: string | null;
|
|
31
31
|
compress?: boolean | null;
|
|
@@ -20,7 +20,7 @@ class FormsDataApi extends oneEntry_1.default {
|
|
|
20
20
|
*/
|
|
21
21
|
async getFormsData(langCode = 'en_US', offset = 0, limit = 30) {
|
|
22
22
|
const result = await this._fetchGet(`?langCode=${langCode}&offset=${offset}&limit=${limit}`);
|
|
23
|
-
return this._normalizeData(result);
|
|
23
|
+
return this._normalizeData(result.items);
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* Find all product page objects with pagination and multiple filtering.
|
|
@@ -41,7 +41,7 @@ class FormsDataApi extends oneEntry_1.default {
|
|
|
41
41
|
* @returns - Returns created FormData objects.
|
|
42
42
|
*/
|
|
43
43
|
async postFormsData(data) {
|
|
44
|
-
const result = await this._fetchPost('', data);
|
|
44
|
+
const result = await this._fetchPost('', JSON.stringify(data));
|
|
45
45
|
return this._normalizeData(result);
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
@@ -223,7 +223,7 @@ class ProductApi extends oneEntry_1.default {
|
|
|
223
223
|
async filterProduct(data, langCode = 'en_US', userQuery) {
|
|
224
224
|
const query = { ...this._defaultQuery, ...userQuery };
|
|
225
225
|
if (typeof langCode === 'string') {
|
|
226
|
-
const response = await this._fetchPost(`/conditions-filter?langCode=${langCode}&` + this._queryParamsToString(query), data);
|
|
226
|
+
const response = await this._fetchPost(`/conditions-filter?langCode=${langCode}&` + this._queryParamsToString(query), JSON.stringify(data));
|
|
227
227
|
const products = response.items;
|
|
228
228
|
const result = products.map(item => this._normalizeData(item));
|
|
229
229
|
return result;
|
|
@@ -231,7 +231,7 @@ class ProductApi extends oneEntry_1.default {
|
|
|
231
231
|
else {
|
|
232
232
|
const productList = [];
|
|
233
233
|
await Promise.all(langCode.map(async (lang) => {
|
|
234
|
-
const response = await this._fetchPost(`/conditions-filter?langCode=${lang}&` + this._queryParamsToString(query), data);
|
|
234
|
+
const response = await this._fetchPost(`/conditions-filter?langCode=${lang}&` + this._queryParamsToString(query), JSON.stringify(data));
|
|
235
235
|
productList.push(response.items);
|
|
236
236
|
}));
|
|
237
237
|
const result = [];
|