oneentry 1.0.50 → 1.0.51
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 +4 -5
- package/dist/admins/adminsApi.js +2 -2
- package/dist/base/oneEntry.js +3 -2
- package/dist/base/result.d.ts +8 -0
- package/dist/base/result.js +90 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1179,11 +1179,9 @@ Example return:
|
|
|
1179
1179
|
"id": 11,
|
|
1180
1180
|
"pageUrl": "122",
|
|
1181
1181
|
"localizeInfos": {
|
|
1182
|
-
"
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
"menuTitle": "12"
|
|
1186
|
-
}
|
|
1182
|
+
"title": "12",
|
|
1183
|
+
"content": "",
|
|
1184
|
+
"menuTitle": "12"
|
|
1187
1185
|
},
|
|
1188
1186
|
"position": 0,
|
|
1189
1187
|
"parentId": null
|
|
@@ -1216,6 +1214,7 @@ example: List [ OrderedMap { "id": 11, "pageUrl": "122", "localizeInfos": Ordere
|
|
|
1216
1214
|
|
|
1217
1215
|
## <h2 id="pages"> Pages </h2>
|
|
1218
1216
|
|
|
1217
|
+
|
|
1219
1218
|
```js
|
|
1220
1219
|
const { Pages } = defineOneEntry('your-url')
|
|
1221
1220
|
```
|
package/dist/admins/adminsApi.js
CHANGED
|
@@ -19,8 +19,8 @@ class AdminsApi extends oneEntry_1.default {
|
|
|
19
19
|
* @returns Returns all AdminEntity user objects
|
|
20
20
|
*/
|
|
21
21
|
async getAdminsInfo(langCode = this._defaultLangCode, offset = 0, limit = 30) {
|
|
22
|
-
const
|
|
23
|
-
return this._normalizeData(
|
|
22
|
+
const response = await this._fetchGet(`?langCode=${langCode}&offset=${offset}&limit=${limit}`);
|
|
23
|
+
return this._normalizeData(response, langCode);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
exports.default = AdminsApi;
|
package/dist/base/oneEntry.js
CHANGED
|
@@ -26,8 +26,8 @@ class OneEntry {
|
|
|
26
26
|
};
|
|
27
27
|
if (!this._NO_FETCH) {
|
|
28
28
|
const response = await fetch(this._getFullPath(path), options);
|
|
29
|
-
const result = await response.json()
|
|
30
|
-
return
|
|
29
|
+
// const result = await response.json()
|
|
30
|
+
return await response.json();
|
|
31
31
|
}
|
|
32
32
|
else {
|
|
33
33
|
return new Promise((resolve, reject) => {
|
|
@@ -37,6 +37,7 @@ class OneEntry {
|
|
|
37
37
|
data += chunk;
|
|
38
38
|
});
|
|
39
39
|
res.on('end', () => {
|
|
40
|
+
// const result = new Result(JSON.parse(data))
|
|
40
41
|
resolve(JSON.parse(data));
|
|
41
42
|
});
|
|
42
43
|
});
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class Result {
|
|
4
|
+
constructor(data) {
|
|
5
|
+
this.body = data;
|
|
6
|
+
}
|
|
7
|
+
async blob() {
|
|
8
|
+
this.body = await this.body.blob();
|
|
9
|
+
return this;
|
|
10
|
+
}
|
|
11
|
+
async json() {
|
|
12
|
+
this.body = await typeof this.body === 'string' ? JSON.parse(this.body) : this.body.json();
|
|
13
|
+
return this;
|
|
14
|
+
}
|
|
15
|
+
makeDataWithoutLang(langCode, data) {
|
|
16
|
+
if (data) {
|
|
17
|
+
if (Array.isArray(data)) {
|
|
18
|
+
return data.map((item) => this.makeDataWithoutLang(langCode, item));
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
for (let key in data) {
|
|
22
|
+
if (typeof data[key] === 'object' && data[key] && langCode in data[key]) {
|
|
23
|
+
data[key] = data[key][langCode];
|
|
24
|
+
}
|
|
25
|
+
else if (typeof data[key] === 'object' && data[key] != null) {
|
|
26
|
+
data[key] = this.makeDataWithoutLang(langCode, data[key]);
|
|
27
|
+
}
|
|
28
|
+
else if (Array.isArray(data[key])) {
|
|
29
|
+
data[key] = data.map((item) => this.makeDataWithoutLang(langCode, item));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return data;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
if (Array.isArray(this.body)) {
|
|
37
|
+
this.body = this.body.map((item) => this.makeDataWithoutLang(langCode, item));
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
for (let key in this.body) {
|
|
41
|
+
if (typeof this.body[key] === 'object' && this.body[key] && langCode in this.body[key]) {
|
|
42
|
+
this.body[key] = this.body[key][langCode];
|
|
43
|
+
}
|
|
44
|
+
else if (typeof this.body[key] === 'object' && this.body[key] != null) {
|
|
45
|
+
this.body[key] = this.makeDataWithoutLang(langCode, this.body[key]);
|
|
46
|
+
}
|
|
47
|
+
else if (Array.isArray(this.body[key])) {
|
|
48
|
+
this.body[key] = this.body[key].map((item) => this.makeDataWithoutLang(langCode, item));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return this;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
makeDataWithoutArray(data) {
|
|
56
|
+
if (data) {
|
|
57
|
+
if (Array.isArray(data)) {
|
|
58
|
+
return data.map(item => this.makeDataWithoutArray(item));
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
for (let key in data) {
|
|
62
|
+
if (Array.isArray(data[key]) && data[key].length === 1) {
|
|
63
|
+
data[key] = data[key][0];
|
|
64
|
+
}
|
|
65
|
+
else if (typeof data[key] === 'object' && data[key] && !Array.isArray(data[key])) {
|
|
66
|
+
data[key] = this.makeDataWithoutArray(data[key]);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return data;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
if (Array.isArray(this.body)) {
|
|
74
|
+
return this.body.map(item => this.makeDataWithoutArray(item));
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
for (let key in this.body) {
|
|
78
|
+
if (Array.isArray(this.body[key]) && this.body[key].length === 1) {
|
|
79
|
+
this.body[key] = this.body[key][0];
|
|
80
|
+
}
|
|
81
|
+
else if (typeof this.body[key] === 'object' && this.body[key] && !Array.isArray(this.body[key])) {
|
|
82
|
+
this.body[key] = this.makeDataWithoutArray(this.body[key]);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return this;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.default = Result;
|