Compare commits
	
		
			3 Commits
		
	
	
		
			stringify-
			...
			AUT-997
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | c191b7a3cf | ||
|   | 69416c24e2 | ||
|   | 2460e9f281 | 
							
								
								
									
										262
									
								
								packages/backend/src/apps/wordpress/actions/create-post/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										262
									
								
								packages/backend/src/apps/wordpress/actions/create-post/index.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,262 @@ | |||||||
|  | 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 }); | ||||||
|  |   }, | ||||||
|  | }); | ||||||
| @@ -0,0 +1,35 @@ | |||||||
|  | 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 }); | ||||||
|  |   }, | ||||||
|  | }); | ||||||
							
								
								
									
										5
									
								
								packages/backend/src/apps/wordpress/actions/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								packages/backend/src/apps/wordpress/actions/index.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | |||||||
|  | import createPost from './create-post/index.js'; | ||||||
|  | import findPost from './find-post/index.js'; | ||||||
|  | import updatePost from './update-post/index.js'; | ||||||
|  |  | ||||||
|  | export default [createPost, findPost, updatePost]; | ||||||
							
								
								
									
										284
									
								
								packages/backend/src/apps/wordpress/actions/update-post/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										284
									
								
								packages/backend/src/apps/wordpress/actions/update-post/index.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,284 @@ | |||||||
|  | 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,3 +1,15 @@ | |||||||
|  | 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 listStatuses from './list-statuses/index.js'; | ||||||
|  | import listTags from './list-tags/index.js'; | ||||||
|  | import listUsers from './list-users/index.js'; | ||||||
|  |  | ||||||
| export default [listStatuses]; | export default [ | ||||||
|  |   listCategories, | ||||||
|  |   listMedia, | ||||||
|  |   listPosts, | ||||||
|  |   listStatuses, | ||||||
|  |   listTags, | ||||||
|  |   listUsers, | ||||||
|  | ]; | ||||||
|   | |||||||
| @@ -0,0 +1,40 @@ | |||||||
|  | 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; | ||||||
|  |   }, | ||||||
|  | }; | ||||||
| @@ -0,0 +1,37 @@ | |||||||
|  | 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; | ||||||
|  |   }, | ||||||
|  | }; | ||||||
| @@ -0,0 +1,37 @@ | |||||||
|  | export default { | ||||||
|  |   name: 'List posts', | ||||||
|  |   key: 'listPosts', | ||||||
|  |  | ||||||
|  |   async run($) { | ||||||
|  |     const posts = { | ||||||
|  |       data: [], | ||||||
|  |     }; | ||||||
|  |  | ||||||
|  |     const params = { | ||||||
|  |       page: 1, | ||||||
|  |       per_page: 100, | ||||||
|  |       order: 'desc', | ||||||
|  |     }; | ||||||
|  |  | ||||||
|  |     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, | ||||||
|  |           }); | ||||||
|  |         } | ||||||
|  |       } | ||||||
|  |     } while (params.page <= totalPages); | ||||||
|  |  | ||||||
|  |     return posts; | ||||||
|  |   }, | ||||||
|  | }; | ||||||
| @@ -0,0 +1,37 @@ | |||||||
|  | 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; | ||||||
|  |   }, | ||||||
|  | }; | ||||||
| @@ -0,0 +1,37 @@ | |||||||
|  | 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,6 +4,7 @@ import setBaseUrl from './common/set-base-url.js'; | |||||||
| import auth from './auth/index.js'; | import auth from './auth/index.js'; | ||||||
| import triggers from './triggers/index.js'; | import triggers from './triggers/index.js'; | ||||||
| import dynamicData from './dynamic-data/index.js'; | import dynamicData from './dynamic-data/index.js'; | ||||||
|  | import actions from './actions/index.js'; | ||||||
|  |  | ||||||
| export default defineApp({ | export default defineApp({ | ||||||
|   name: 'WordPress', |   name: 'WordPress', | ||||||
| @@ -18,4 +19,5 @@ export default defineApp({ | |||||||
|   auth, |   auth, | ||||||
|   triggers, |   triggers, | ||||||
|   dynamicData, |   dynamicData, | ||||||
|  |   actions, | ||||||
| }); | }); | ||||||
|   | |||||||
| @@ -518,6 +518,7 @@ export default defineConfig({ | |||||||
|           collapsible: true, |           collapsible: true, | ||||||
|           collapsed: true, |           collapsed: true, | ||||||
|           items: [ |           items: [ | ||||||
|  |             { text: 'Actions', link: '/apps/wordpress/actions' }, | ||||||
|             { text: 'Triggers', link: '/apps/wordpress/triggers' }, |             { text: 'Triggers', link: '/apps/wordpress/triggers' }, | ||||||
|             { text: 'Connection', link: '/apps/wordpress/connection' }, |             { text: 'Connection', link: '/apps/wordpress/connection' }, | ||||||
|           ], |           ], | ||||||
|   | |||||||
							
								
								
									
										16
									
								
								packages/docs/pages/apps/wordpress/actions.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								packages/docs/pages/apps/wordpress/actions.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,16 @@ | |||||||
|  | --- | ||||||
|  | favicon: /favicons/wordpress.svg | ||||||
|  | items: | ||||||
|  |   - name: Create post | ||||||
|  |     desc: Creates a new post. | ||||||
|  |   - name: Find post | ||||||
|  |     desc: Finds a post. | ||||||
|  |   - name: Update post | ||||||
|  |     desc: Updates a post. | ||||||
|  | --- | ||||||
|  |  | ||||||
|  | <script setup> | ||||||
|  |   import CustomListing from '../../components/CustomListing.vue' | ||||||
|  | </script> | ||||||
|  |  | ||||||
|  | <CustomListing /> | ||||||
		Reference in New Issue
	
	Block a user