@miso.ai/server-wordpress 0.6.3-beta.8 → 0.6.3-beta.9
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/package.json +2 -2
- package/src/client.js +1 -1
- package/src/entities/index.js +6 -1
- package/src/entities/transform-default.js +4 -3
- package/src/source/base.js +5 -2
- package/src/source/paged.js +2 -2
- package/src/version.js +1 -1
package/package.json
CHANGED
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
"simonpai <simon.pai@askmiso.com>"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@miso.ai/server-commons": "0.6.3-beta.
|
|
20
|
+
"@miso.ai/server-commons": "0.6.3-beta.9",
|
|
21
21
|
"axios": "^0.27.2",
|
|
22
22
|
"axios-retry": "^3.3.1"
|
|
23
23
|
},
|
|
24
|
-
"version": "0.6.3-beta.
|
|
24
|
+
"version": "0.6.3-beta.9"
|
|
25
25
|
}
|
package/src/client.js
CHANGED
package/src/entities/index.js
CHANGED
|
@@ -27,12 +27,17 @@ export default class Entities {
|
|
|
27
27
|
// we need taxonomy fetched so we know whether it's hierarchical
|
|
28
28
|
const taxonomies = await client._helpers.findAssociatedTaxonomies(this.name);
|
|
29
29
|
|
|
30
|
+
// TODO: omit specific indicies by config
|
|
30
31
|
// prepare entity indicies
|
|
32
|
+
const { resources = {} } = client._profile || {};
|
|
33
|
+
const ignored = new Set(resources.ignore || []);
|
|
34
|
+
|
|
31
35
|
const indicies = [
|
|
32
36
|
client.users.index,
|
|
33
37
|
client.media.index,
|
|
34
38
|
...taxonomies.map(({ rest_base }) => client.entities(rest_base).index),
|
|
35
|
-
];
|
|
39
|
+
].filter(index => !ignored.has(index.name));
|
|
40
|
+
|
|
36
41
|
await Promise.all(indicies.map(index => index.ready()));
|
|
37
42
|
for (const index of indicies) {
|
|
38
43
|
if (index.hierarchical) {
|
|
@@ -14,14 +14,14 @@ export default function transform({
|
|
|
14
14
|
modified_gmt,
|
|
15
15
|
guid: {
|
|
16
16
|
rendered: guid,
|
|
17
|
-
},
|
|
17
|
+
} = {},
|
|
18
18
|
slug,
|
|
19
19
|
title: {
|
|
20
20
|
rendered: title,
|
|
21
|
-
},
|
|
21
|
+
} = {},
|
|
22
22
|
content: {
|
|
23
23
|
rendered: html,
|
|
24
|
-
},
|
|
24
|
+
} = {},
|
|
25
25
|
link: url,
|
|
26
26
|
status,
|
|
27
27
|
sticky,
|
|
@@ -42,6 +42,7 @@ export default function transform({
|
|
|
42
42
|
product_id,
|
|
43
43
|
type,
|
|
44
44
|
created_at,
|
|
45
|
+
published_at: created_at,
|
|
45
46
|
updated_at,
|
|
46
47
|
title,
|
|
47
48
|
cover_image,
|
package/src/source/base.js
CHANGED
|
@@ -32,14 +32,17 @@ export default class WordPressDataSource {
|
|
|
32
32
|
this._debug(`[WordPressDataSource] request ${url}`);
|
|
33
33
|
const response = await this._axiosGet(url);
|
|
34
34
|
this._debug(`[WordPressDataSource] response ${response.status} ${url}`);
|
|
35
|
-
return this._process(response);
|
|
35
|
+
return this._process(response, { url });
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
_process({ status, data }) {
|
|
38
|
+
_process({ status, data }, { url }) {
|
|
39
39
|
if (status >= 400 && status < 500 && data.code === 'rest_post_invalid_page_number') {
|
|
40
40
|
// out of bound, so there is no more data
|
|
41
41
|
return { data: [], terminate: true };
|
|
42
42
|
}
|
|
43
|
+
if (!Array.isArray(data)) {
|
|
44
|
+
throw new Error(`Unexpected response from WordPress API for ${url}. Expected an array of objects: ${data}`);
|
|
45
|
+
}
|
|
43
46
|
if (!this._options.preserveLinks) {
|
|
44
47
|
data = data.map(this._helpers.removeLinks);
|
|
45
48
|
}
|
package/src/source/paged.js
CHANGED
|
@@ -50,8 +50,8 @@ export default class PagedWordPressDataSource extends WordPressDataSource {
|
|
|
50
50
|
return total;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
_process({ status, data, headers }) {
|
|
54
|
-
const result = super._process({ status, data, headers });
|
|
53
|
+
_process({ status, data, headers }, meta) {
|
|
54
|
+
const result = super._process({ status, data, headers }, meta);
|
|
55
55
|
const total = asNumber(headers['x-wp-total']);
|
|
56
56
|
if (total !== undefined) {
|
|
57
57
|
result.total = total;
|
package/src/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '0.6.3-beta.
|
|
1
|
+
export default '0.6.3-beta.9';
|