Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
3079d8c605 |
@@ -1,262 +0,0 @@
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
import isEmpty from 'lodash/isEmpty.js';
|
||||
import omitBy from 'lodash/omitBy.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Create post',
|
||||
key: 'createPost',
|
||||
description: 'Creates a new post.',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Title',
|
||||
key: 'title',
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: '',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Content',
|
||||
key: 'content',
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Excerpt',
|
||||
key: 'excerpt',
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Password',
|
||||
key: 'password',
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'A password to protect access to the content and excerpt.',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Author',
|
||||
key: 'author',
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listUsers',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Featured Media',
|
||||
key: 'featuredMedia',
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listMedia',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Comment Status',
|
||||
key: 'commentStatus',
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
options: [
|
||||
{ label: 'Open', value: 'open' },
|
||||
{ label: 'Closed', value: 'closed' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'Ping Status',
|
||||
key: 'pingStatus',
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
options: [
|
||||
{ label: 'Open', value: 'open' },
|
||||
{ label: 'Closed', value: 'closed' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'Format',
|
||||
key: 'format',
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
options: [
|
||||
{ label: 'Standard', value: 'standard' },
|
||||
{ label: 'Aside', value: 'aside' },
|
||||
{ label: 'Chat', value: 'chat' },
|
||||
{ label: 'Gallery', value: 'gallery' },
|
||||
{ label: 'Link', value: 'link' },
|
||||
{ label: 'Image', value: 'image' },
|
||||
{ label: 'Quote', value: 'quote' },
|
||||
{ label: 'Status', value: 'status' },
|
||||
{ label: 'Status', value: 'status' },
|
||||
{ label: 'Video', value: 'video' },
|
||||
{ label: 'Audio', value: 'audio' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'Sticky',
|
||||
key: 'sticky',
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
options: [
|
||||
{ label: 'False', value: 'false' },
|
||||
{ label: 'True', value: 'true' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'Categories',
|
||||
key: 'categoryIds',
|
||||
type: 'dynamic',
|
||||
required: false,
|
||||
description: '',
|
||||
fields: [
|
||||
{
|
||||
label: 'Category',
|
||||
key: 'categoryId',
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listCategories',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'Tags',
|
||||
key: 'tagIds',
|
||||
type: 'dynamic',
|
||||
required: false,
|
||||
description: '',
|
||||
fields: [
|
||||
{
|
||||
label: 'Tag',
|
||||
key: 'tagId',
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listTags',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'Status',
|
||||
key: 'status',
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listStatuses',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Date',
|
||||
key: 'date',
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: "Post publish date in the site's timezone",
|
||||
variables: true,
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const {
|
||||
title,
|
||||
content,
|
||||
excerpt,
|
||||
password,
|
||||
author,
|
||||
featuredMedia,
|
||||
commentStatus,
|
||||
pingStatus,
|
||||
format,
|
||||
sticky,
|
||||
categoryIds,
|
||||
tagIds,
|
||||
status,
|
||||
date,
|
||||
} = $.step.parameters;
|
||||
|
||||
const allCategoryIds = categoryIds
|
||||
?.map((categoryId) => categoryId.categoryId)
|
||||
.filter(Boolean);
|
||||
|
||||
const allTagIds = tagIds?.map((tagId) => tagId.tagId).filter(Boolean);
|
||||
|
||||
let body = {
|
||||
title,
|
||||
content,
|
||||
excerpt,
|
||||
password,
|
||||
author,
|
||||
featured_media: featuredMedia,
|
||||
comment_status: commentStatus,
|
||||
ping_status: pingStatus,
|
||||
format,
|
||||
sticky,
|
||||
categories: allCategoryIds,
|
||||
tags: allTagIds,
|
||||
status,
|
||||
date,
|
||||
};
|
||||
|
||||
body = omitBy(body, isEmpty);
|
||||
|
||||
const response = await $.http.post('?rest_route=/wp/v2/posts', body);
|
||||
|
||||
$.setActionItem({ raw: response.data });
|
||||
},
|
||||
});
|
@@ -1,135 +0,0 @@
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
import isEmpty from 'lodash/isEmpty.js';
|
||||
import omitBy from 'lodash/omitBy.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Create user',
|
||||
key: 'createUser',
|
||||
description: 'Creates a new user.',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Email',
|
||||
key: 'email',
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: '',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Username',
|
||||
key: 'username',
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: '',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Password',
|
||||
key: 'password',
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: '',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'First Name',
|
||||
key: 'firstName',
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Last Name',
|
||||
key: 'lastName',
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Display Name',
|
||||
key: 'displayName',
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Nickname',
|
||||
key: 'nickname',
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Description',
|
||||
key: 'description',
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Website',
|
||||
key: 'website',
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Role',
|
||||
key: 'role',
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
options: [
|
||||
{ label: 'Administrator', value: 'administrator' },
|
||||
{ label: 'Author', value: 'author' },
|
||||
{ label: 'Contributor', value: 'contributor' },
|
||||
{ label: 'Editor', value: 'editor' },
|
||||
{ label: 'Subscriber', value: 'subscriber' },
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const {
|
||||
email,
|
||||
username,
|
||||
password,
|
||||
firstName,
|
||||
lastName,
|
||||
displayName,
|
||||
nickname,
|
||||
description,
|
||||
website,
|
||||
role,
|
||||
} = $.step.parameters;
|
||||
|
||||
let body = {
|
||||
email,
|
||||
username,
|
||||
password,
|
||||
first_name: firstName,
|
||||
last_name: lastName,
|
||||
name: displayName,
|
||||
nickname,
|
||||
description,
|
||||
url: website,
|
||||
};
|
||||
|
||||
if (role) {
|
||||
body.roles = [role];
|
||||
}
|
||||
|
||||
body = omitBy(body, isEmpty);
|
||||
|
||||
const response = await $.http.post('?rest_route=/wp/v2/users', body);
|
||||
|
||||
$.setActionItem({ raw: response.data });
|
||||
},
|
||||
});
|
@@ -1,35 +0,0 @@
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Delete post',
|
||||
key: 'deletePost',
|
||||
description: 'Deletes a post.',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Post ID',
|
||||
key: 'postId',
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: 'Choose a post to delete.',
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listPosts',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const { postId } = $.step.parameters;
|
||||
|
||||
const response = await $.http.delete(`?rest_route=/wp/v2/posts/${postId}`);
|
||||
|
||||
$.setActionItem({ raw: response.data });
|
||||
},
|
||||
});
|
@@ -1,35 +0,0 @@
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Find post',
|
||||
key: 'findPost',
|
||||
description: 'Finds a post.',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Post ID',
|
||||
key: 'postId',
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: 'Choose a post to update.',
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listPosts',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const { postId } = $.step.parameters;
|
||||
|
||||
const response = await $.http.get(`?rest_route=/wp/v2/posts/${postId}`);
|
||||
|
||||
$.setActionItem({ raw: response.data });
|
||||
},
|
||||
});
|
@@ -1,35 +0,0 @@
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Find user',
|
||||
key: 'findUser',
|
||||
description: 'Finds a user.',
|
||||
arguments: [
|
||||
{
|
||||
label: 'User ID',
|
||||
key: 'userId',
|
||||
type: 'dropdown',
|
||||
required: true,
|
||||
description: '',
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listUsers',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const userId = $.step.parameters.userId;
|
||||
|
||||
const response = await $.http.get(`?rest_route=/wp/v2/users/${userId}`);
|
||||
|
||||
$.setActionItem({ raw: response.data });
|
||||
},
|
||||
});
|
@@ -1,15 +0,0 @@
|
||||
import createPost from './create-post/index.js';
|
||||
import createUser from './create-user/index.js';
|
||||
import deletePost from './delete-post/index.js';
|
||||
import findPost from './find-post/index.js';
|
||||
import findUser from './find-user/index.js';
|
||||
import updatePost from './update-post/index.js';
|
||||
|
||||
export default [
|
||||
createPost,
|
||||
createUser,
|
||||
deletePost,
|
||||
findPost,
|
||||
findUser,
|
||||
updatePost,
|
||||
];
|
@@ -1,284 +0,0 @@
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
import isEmpty from 'lodash/isEmpty.js';
|
||||
import omitBy from 'lodash/omitBy.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Update post',
|
||||
key: 'updatePost',
|
||||
description: 'Updates a post.',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Post',
|
||||
key: 'postId',
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: 'Choose a post to update.',
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listPosts',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Title',
|
||||
key: 'title',
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: '',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Content',
|
||||
key: 'content',
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Excerpt',
|
||||
key: 'excerpt',
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Password',
|
||||
key: 'password',
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'A password to protect access to the content and excerpt.',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Author',
|
||||
key: 'author',
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listUsers',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Featured Media',
|
||||
key: 'featuredMedia',
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listMedia',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Comment Status',
|
||||
key: 'commentStatus',
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
options: [
|
||||
{ label: 'Open', value: 'open' },
|
||||
{ label: 'Closed', value: 'closed' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'Ping Status',
|
||||
key: 'pingStatus',
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
options: [
|
||||
{ label: 'Open', value: 'open' },
|
||||
{ label: 'Closed', value: 'closed' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'Format',
|
||||
key: 'format',
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
options: [
|
||||
{ label: 'Standard', value: 'standard' },
|
||||
{ label: 'Aside', value: 'aside' },
|
||||
{ label: 'Chat', value: 'chat' },
|
||||
{ label: 'Gallery', value: 'gallery' },
|
||||
{ label: 'Link', value: 'link' },
|
||||
{ label: 'Image', value: 'image' },
|
||||
{ label: 'Quote', value: 'quote' },
|
||||
{ label: 'Status', value: 'status' },
|
||||
{ label: 'Status', value: 'status' },
|
||||
{ label: 'Video', value: 'video' },
|
||||
{ label: 'Audio', value: 'audio' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'Sticky',
|
||||
key: 'sticky',
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
options: [
|
||||
{ label: 'False', value: 'false' },
|
||||
{ label: 'True', value: 'true' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'Categories',
|
||||
key: 'categoryIds',
|
||||
type: 'dynamic',
|
||||
required: false,
|
||||
description: '',
|
||||
fields: [
|
||||
{
|
||||
label: 'Category',
|
||||
key: 'categoryId',
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listCategories',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'Tags',
|
||||
key: 'tagIds',
|
||||
type: 'dynamic',
|
||||
required: false,
|
||||
description: '',
|
||||
fields: [
|
||||
{
|
||||
label: 'Tag',
|
||||
key: 'tagId',
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listTags',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'Status',
|
||||
key: 'status',
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listStatuses',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Date',
|
||||
key: 'date',
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: "Post publish date in the site's timezone",
|
||||
variables: true,
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const {
|
||||
postId,
|
||||
title,
|
||||
content,
|
||||
excerpt,
|
||||
password,
|
||||
author,
|
||||
featuredMedia,
|
||||
commentStatus,
|
||||
pingStatus,
|
||||
format,
|
||||
sticky,
|
||||
categoryIds,
|
||||
tagIds,
|
||||
status,
|
||||
date,
|
||||
} = $.step.parameters;
|
||||
|
||||
const allCategoryIds = categoryIds
|
||||
?.map((categoryId) => categoryId.categoryId)
|
||||
.filter(Boolean);
|
||||
|
||||
const allTagIds = tagIds?.map((tagId) => tagId.tagId).filter(Boolean);
|
||||
|
||||
let body = {
|
||||
title,
|
||||
content,
|
||||
excerpt,
|
||||
password,
|
||||
author,
|
||||
featured_media: featuredMedia,
|
||||
comment_status: commentStatus,
|
||||
ping_status: pingStatus,
|
||||
format,
|
||||
sticky,
|
||||
categories: allCategoryIds,
|
||||
tags: allTagIds,
|
||||
status,
|
||||
date,
|
||||
};
|
||||
|
||||
body = omitBy(body, isEmpty);
|
||||
|
||||
const response = await $.http.post(
|
||||
`?rest_route=/wp/v2/posts/${postId}`,
|
||||
body
|
||||
);
|
||||
|
||||
$.setActionItem({ raw: response.data });
|
||||
},
|
||||
});
|
@@ -1,15 +1,3 @@
|
||||
import listCategories from './list-categories/index.js';
|
||||
import listMedia from './list-media/index.js';
|
||||
import listPosts from './list-posts/index.js';
|
||||
import listStatuses from './list-statuses/index.js';
|
||||
import listTags from './list-tags/index.js';
|
||||
import listUsers from './list-users/index.js';
|
||||
|
||||
export default [
|
||||
listCategories,
|
||||
listMedia,
|
||||
listPosts,
|
||||
listStatuses,
|
||||
listTags,
|
||||
listUsers,
|
||||
];
|
||||
export default [listStatuses];
|
||||
|
@@ -1,40 +0,0 @@
|
||||
export default {
|
||||
name: 'List categories',
|
||||
key: 'listCategories',
|
||||
|
||||
async run($) {
|
||||
const categories = {
|
||||
data: [],
|
||||
};
|
||||
|
||||
const params = {
|
||||
page: 1,
|
||||
per_page: 100,
|
||||
order: 'desc',
|
||||
};
|
||||
|
||||
let totalPages = 1;
|
||||
do {
|
||||
const { data, headers } = await $.http.get(
|
||||
'?rest_route=/wp/v2/categories',
|
||||
{
|
||||
params,
|
||||
}
|
||||
);
|
||||
|
||||
params.page = params.page + 1;
|
||||
totalPages = Number(headers['x-wp-totalpages']);
|
||||
|
||||
if (data) {
|
||||
for (const category of data) {
|
||||
categories.data.push({
|
||||
value: category.id,
|
||||
name: category.name,
|
||||
});
|
||||
}
|
||||
}
|
||||
} while (params.page <= totalPages);
|
||||
|
||||
return categories;
|
||||
},
|
||||
};
|
@@ -1,37 +0,0 @@
|
||||
export default {
|
||||
name: 'List media',
|
||||
key: 'listMedia',
|
||||
|
||||
async run($) {
|
||||
const media = {
|
||||
data: [],
|
||||
};
|
||||
|
||||
const params = {
|
||||
page: 1,
|
||||
per_page: 100,
|
||||
order: 'desc',
|
||||
};
|
||||
|
||||
let totalPages = 1;
|
||||
do {
|
||||
const { data, headers } = await $.http.get('?rest_route=/wp/v2/media', {
|
||||
params,
|
||||
});
|
||||
|
||||
params.page = params.page + 1;
|
||||
totalPages = Number(headers['x-wp-totalpages']);
|
||||
|
||||
if (data) {
|
||||
for (const medium of data) {
|
||||
media.data.push({
|
||||
value: medium.id,
|
||||
name: medium.slug,
|
||||
});
|
||||
}
|
||||
}
|
||||
} while (params.page <= totalPages);
|
||||
|
||||
return media;
|
||||
},
|
||||
};
|
@@ -1,38 +0,0 @@
|
||||
export default {
|
||||
name: 'List posts',
|
||||
key: 'listPosts',
|
||||
|
||||
async run($) {
|
||||
const posts = {
|
||||
data: [],
|
||||
};
|
||||
|
||||
const params = {
|
||||
page: 1,
|
||||
per_page: 100,
|
||||
order: 'desc',
|
||||
status: ['publish', 'future', 'draft', 'pending', 'private'],
|
||||
};
|
||||
|
||||
let totalPages = 1;
|
||||
do {
|
||||
const { data, headers } = await $.http.get('?rest_route=/wp/v2/posts', {
|
||||
params,
|
||||
});
|
||||
|
||||
params.page = params.page + 1;
|
||||
totalPages = Number(headers['x-wp-totalpages']);
|
||||
|
||||
if (data) {
|
||||
for (const post of data) {
|
||||
posts.data.push({
|
||||
value: post.id,
|
||||
name: `${post.title.rendered} (${post.status})`,
|
||||
});
|
||||
}
|
||||
}
|
||||
} while (params.page <= totalPages);
|
||||
|
||||
return posts;
|
||||
},
|
||||
};
|
@@ -1,37 +0,0 @@
|
||||
export default {
|
||||
name: 'List tags',
|
||||
key: 'listTags',
|
||||
|
||||
async run($) {
|
||||
const tags = {
|
||||
data: [],
|
||||
};
|
||||
|
||||
const params = {
|
||||
page: 1,
|
||||
per_page: 100,
|
||||
order: 'desc',
|
||||
};
|
||||
|
||||
let totalPages = 1;
|
||||
do {
|
||||
const { data, headers } = await $.http.get('?rest_route=/wp/v2/tags', {
|
||||
params,
|
||||
});
|
||||
|
||||
params.page = params.page + 1;
|
||||
totalPages = Number(headers['x-wp-totalpages']);
|
||||
|
||||
if (data) {
|
||||
for (const tag of data) {
|
||||
tags.data.push({
|
||||
value: tag.id,
|
||||
name: tag.name,
|
||||
});
|
||||
}
|
||||
}
|
||||
} while (params.page <= totalPages);
|
||||
|
||||
return tags;
|
||||
},
|
||||
};
|
@@ -1,37 +0,0 @@
|
||||
export default {
|
||||
name: 'List users',
|
||||
key: 'listUsers',
|
||||
|
||||
async run($) {
|
||||
const users = {
|
||||
data: [],
|
||||
};
|
||||
|
||||
const params = {
|
||||
page: 1,
|
||||
per_page: 100,
|
||||
order: 'desc',
|
||||
};
|
||||
|
||||
let totalPages = 1;
|
||||
do {
|
||||
const { data, headers } = await $.http.get('?rest_route=/wp/v2/users', {
|
||||
params,
|
||||
});
|
||||
|
||||
params.page = params.page + 1;
|
||||
totalPages = Number(headers['x-wp-totalpages']);
|
||||
|
||||
if (data) {
|
||||
for (const user of data) {
|
||||
users.data.push({
|
||||
value: user.id,
|
||||
name: user.name,
|
||||
});
|
||||
}
|
||||
}
|
||||
} while (params.page <= totalPages);
|
||||
|
||||
return users;
|
||||
},
|
||||
};
|
@@ -4,7 +4,6 @@ import setBaseUrl from './common/set-base-url.js';
|
||||
import auth from './auth/index.js';
|
||||
import triggers from './triggers/index.js';
|
||||
import dynamicData from './dynamic-data/index.js';
|
||||
import actions from './actions/index.js';
|
||||
|
||||
export default defineApp({
|
||||
name: 'WordPress',
|
||||
@@ -19,5 +18,4 @@ export default defineApp({
|
||||
auth,
|
||||
triggers,
|
||||
dynamicData,
|
||||
actions,
|
||||
});
|
||||
|
@@ -52,7 +52,7 @@ const appConfig = {
|
||||
isDev: appEnv === 'development',
|
||||
isTest: appEnv === 'test',
|
||||
isProd: appEnv === 'production',
|
||||
version: '0.11.0',
|
||||
version: '0.12.0',
|
||||
postgresDatabase: process.env.POSTGRES_DATABASE || 'automatisch_development',
|
||||
postgresSchema: process.env.POSTGRES_SCHEMA || 'public',
|
||||
postgresPort: parseInt(process.env.POSTGRES_PORT || '5432'),
|
||||
|
@@ -10,7 +10,7 @@ describe('GET /api/v1/automatisch/version', () => {
|
||||
|
||||
const expectedPayload = {
|
||||
data: {
|
||||
version: '0.11.0',
|
||||
version: '0.12.0',
|
||||
},
|
||||
meta: {
|
||||
count: 1,
|
||||
|
@@ -518,7 +518,6 @@ export default defineConfig({
|
||||
collapsible: true,
|
||||
collapsed: true,
|
||||
items: [
|
||||
{ text: 'Actions', link: '/apps/wordpress/actions' },
|
||||
{ text: 'Triggers', link: '/apps/wordpress/triggers' },
|
||||
{ text: 'Connection', link: '/apps/wordpress/connection' },
|
||||
],
|
||||
|
@@ -1,22 +0,0 @@
|
||||
---
|
||||
favicon: /favicons/wordpress.svg
|
||||
items:
|
||||
- name: Create post
|
||||
desc: Creates a new post.
|
||||
- name: Create user
|
||||
desc: Creates a new user.
|
||||
- name: Delete post
|
||||
desc: Deletes a post.
|
||||
- name: Find post
|
||||
desc: Finds a post.
|
||||
- name: Find user
|
||||
desc: Finds a user.
|
||||
- name: Update post
|
||||
desc: Updates a post.
|
||||
---
|
||||
|
||||
<script setup>
|
||||
import CustomListing from '../../components/CustomListing.vue'
|
||||
</script>
|
||||
|
||||
<CustomListing />
|
Reference in New Issue
Block a user