@miso.ai/server-wordpress 0.6.5-beta.0 → 0.6.5-beta.10
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/cli/index.js +2 -0
- package/cli/types.js +20 -0
- package/cli/utils.js +3 -3
- package/package.json +2 -2
- package/src/client.js +4 -0
- package/src/helpers.js +15 -0
- package/src/version.js +1 -1
package/cli/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import version from '../src/version.js';
|
|
|
4
4
|
import { profile, init } from './profile.js';
|
|
5
5
|
import taxonomies from './taxonomies.js';
|
|
6
6
|
import entities from './entities.js';
|
|
7
|
+
import types from './types.js';
|
|
7
8
|
import summarize from './summarize.js';
|
|
8
9
|
import download from './download.js';
|
|
9
10
|
import xml from './xml.js';
|
|
@@ -33,6 +34,7 @@ yargs.build(yargs => {
|
|
|
33
34
|
.command(summarize)
|
|
34
35
|
.command(download)
|
|
35
36
|
.command(taxonomies)
|
|
37
|
+
.command(types)
|
|
36
38
|
.command(entities)
|
|
37
39
|
.version(version);
|
|
38
40
|
});
|
package/cli/types.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { WordPressClient } from '../src/index.js';
|
|
2
|
+
|
|
3
|
+
function build(yargs) {
|
|
4
|
+
return yargs;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
async function run(options) {
|
|
8
|
+
const client = new WordPressClient(options);
|
|
9
|
+
const types = await client.types({ noCache: true });
|
|
10
|
+
for (const type of types) {
|
|
11
|
+
console.log(JSON.stringify(type));
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default {
|
|
16
|
+
command: 'types',
|
|
17
|
+
desc: 'List all post types from WordPress REST API',
|
|
18
|
+
builder: build,
|
|
19
|
+
handler: run,
|
|
20
|
+
};
|
package/cli/utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { startOfDate, endOfDate } from '@miso.ai/server-commons';
|
|
1
|
+
import { startOfDate, endOfDate, yargs as _yargs } from '@miso.ai/server-commons';
|
|
2
2
|
|
|
3
3
|
export function normalizeOptions({ date, after, before, ids, include, ...options }) {
|
|
4
4
|
// TODO: should be able to turn this off, as it's covered by helper
|
|
@@ -49,12 +49,12 @@ export function buildForEntities(yargs) {
|
|
|
49
49
|
.option('fields', {
|
|
50
50
|
describe: 'Specify which record fields are retrieved',
|
|
51
51
|
type: 'array',
|
|
52
|
-
coerce:
|
|
52
|
+
coerce: _yargs.coerceToArray,
|
|
53
53
|
})
|
|
54
54
|
.option('params', {
|
|
55
55
|
describe: 'Specify additional query parameters in the form of key=value',
|
|
56
56
|
type: 'array',
|
|
57
|
-
coerce:
|
|
57
|
+
coerce: _yargs.coerceToArray,
|
|
58
58
|
})
|
|
59
59
|
.option('resolve', {
|
|
60
60
|
alias: 'r',
|
package/package.json
CHANGED
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
"simonpai <simon.pai@askmiso.com>"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@miso.ai/server-commons": "0.6.5-beta.
|
|
20
|
+
"@miso.ai/server-commons": "0.6.5-beta.10",
|
|
21
21
|
"axios": "^1.6.2",
|
|
22
22
|
"axios-retry": "^3.3.1",
|
|
23
23
|
"dotenv": "^16.4.5",
|
|
24
24
|
"saxes": "^6.0.0",
|
|
25
25
|
"split2": "^4.2.0"
|
|
26
26
|
},
|
|
27
|
-
"version": "0.6.5-beta.
|
|
27
|
+
"version": "0.6.5-beta.10"
|
|
28
28
|
}
|
package/src/client.js
CHANGED
package/src/helpers.js
CHANGED
|
@@ -104,6 +104,21 @@ export default class Helpers {
|
|
|
104
104
|
return Object.values(data);
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
+
async types({ noCache = false } = {}) {
|
|
108
|
+
if (noCache || !this._types) {
|
|
109
|
+
// don't await, save the promise
|
|
110
|
+
this._types = this._fetchTypes();
|
|
111
|
+
}
|
|
112
|
+
return this._types;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
async _fetchTypes() {
|
|
116
|
+
const url = await this.url.build('types');
|
|
117
|
+
const { data } = await this.axios.get(url);
|
|
118
|
+
this.debug(`Fetched types.`);
|
|
119
|
+
return Object.values(data);
|
|
120
|
+
}
|
|
121
|
+
|
|
107
122
|
extractTerms(data) {
|
|
108
123
|
return data._links['wp:term'] || [];
|
|
109
124
|
}
|
package/src/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '0.6.5-beta.
|
|
1
|
+
export default '0.6.5-beta.10';
|