2020-12-07 23:40:29 -08:00
import {
INodeProperties ,
} from 'n8n-workflow' ;
2021-12-03 00:44:16 -08:00
export const postOperations : INodeProperties [ ] = [
2020-12-07 23:40:29 -08:00
{
displayName : 'Operation' ,
name : 'operation' ,
2022-05-14 01:39:28 -07:00
noDataExpression : true ,
2020-12-07 23:40:29 -08:00
type : 'options' ,
displayOptions : {
show : {
source : [
'contentApi' ,
] ,
resource : [
'post' ,
] ,
} ,
} ,
options : [
{
name : 'Get' ,
value : 'get' ,
description : 'Get a post' ,
} ,
{
name : 'Get All' ,
value : 'getAll' ,
description : 'Get all posts' ,
} ,
] ,
default : 'get' ,
} ,
{
displayName : 'Operation' ,
name : 'operation' ,
2022-05-14 01:39:28 -07:00
noDataExpression : true ,
2020-12-07 23:40:29 -08:00
type : 'options' ,
displayOptions : {
show : {
source : [
'adminApi' ,
] ,
resource : [
'post' ,
] ,
} ,
} ,
options : [
{
name : 'Create' ,
value : 'create' ,
description : 'Create a post' ,
} ,
{
name : 'Delete' ,
value : 'delete' ,
description : 'Delete a post' ,
} ,
{
name : 'Get' ,
value : 'get' ,
description : 'Get a post' ,
} ,
{
name : 'Get All' ,
value : 'getAll' ,
description : 'Get all posts' ,
} ,
{
name : 'Update' ,
value : 'update' ,
description : 'Update a post' ,
} ,
] ,
default : 'get' ,
} ,
2021-12-03 00:44:16 -08:00
] ;
2020-12-07 23:40:29 -08:00
2021-12-03 00:44:16 -08:00
export const postFields : INodeProperties [ ] = [
2020-12-07 23:40:29 -08:00
/* -------------------------------------------------------------------------- */
/* post:create */
/* -------------------------------------------------------------------------- */
{
displayName : 'Title' ,
name : 'title' ,
type : 'string' ,
default : '' ,
required : true ,
displayOptions : {
show : {
source : [
'adminApi' ,
] ,
resource : [
'post' ,
] ,
operation : [
'create' ,
] ,
} ,
} ,
2022-05-06 14:01:25 -07:00
description : 'Post\'s title' ,
2020-12-07 23:40:29 -08:00
} ,
{
displayName : 'Content Format' ,
name : 'contentFormat' ,
type : 'options' ,
displayOptions : {
show : {
source : [
'adminApi' ,
] ,
resource : [
'post' ,
] ,
operation : [
'create' ,
] ,
} ,
} ,
options : [
{
name : 'HTML' ,
value : 'html' ,
} ,
{
name : 'Mobile Doc' ,
value : 'mobileDoc' ,
} ,
] ,
default : 'html' ,
2022-05-06 14:01:25 -07:00
description : 'The format of the post' ,
2020-12-07 23:40:29 -08:00
} ,
{
displayName : 'Content' ,
name : 'content' ,
type : 'string' ,
typeOptions : {
alwaysOpenEditWindow : true ,
} ,
displayOptions : {
show : {
source : [
'adminApi' ,
] ,
resource : [
'post' ,
] ,
operation : [
'create' ,
] ,
contentFormat : [
'html' ,
] ,
} ,
} ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'The content of the post to create' ,
2020-12-07 23:40:29 -08:00
} ,
{
displayName : 'Content (JSON)' ,
name : 'content' ,
type : 'json' ,
displayOptions : {
show : {
source : [
'adminApi' ,
] ,
resource : [
'post' ,
] ,
operation : [
'create' ,
] ,
contentFormat : [
'mobileDoc' ,
] ,
} ,
} ,
default : '' ,
2022-04-22 09:29:51 -07:00
description : 'Mobiledoc is the raw JSON format that Ghost uses to store post contents. <a href="https://ghost.org/docs/concepts/posts/#document-storage">Info</a>.' ,
2020-12-07 23:40:29 -08:00
} ,
{
displayName : 'Additional Fields' ,
name : 'additionalFields' ,
type : 'collection' ,
placeholder : 'Add Field' ,
default : { } ,
displayOptions : {
show : {
source : [
'adminApi' ,
] ,
resource : [
'post' ,
] ,
operation : [
'create' ,
] ,
} ,
} ,
options : [
{
displayName : 'Authors IDs' ,
name : 'authors' ,
type : 'multiOptions' ,
typeOptions : {
loadOptionsMethod : 'getAuthors' ,
} ,
default : [ ] ,
} ,
{
displayName : 'Cannonical URL' ,
name : 'canonical_url' ,
type : 'string' ,
default : '' ,
} ,
{
displayName : 'Code Injection Foot' ,
name : 'codeinjection_foot' ,
type : 'string' ,
default : '' ,
description : 'The Code Injection allows you inject a small snippet into your Ghost site' ,
} ,
{
displayName : 'Code Injection Head' ,
name : 'codeinjection_head' ,
type : 'string' ,
default : '' ,
description : 'The Code Injection allows you inject a small snippet into your Ghost site' ,
} ,
{
displayName : 'Featured' ,
name : 'featured' ,
type : 'boolean' ,
default : false ,
} ,
{
displayName : 'Meta Description' ,
name : 'meta_description' ,
type : 'string' ,
default : '' ,
} ,
{
displayName : 'Meta Title' ,
name : 'meta_title' ,
type : 'string' ,
default : '' ,
} ,
{
displayName : 'Open Graph Description' ,
name : 'og_description' ,
type : 'string' ,
default : '' ,
} ,
{
displayName : 'Open Graph Image' ,
name : 'og_image' ,
type : 'string' ,
default : '' ,
description : 'URL of the image' ,
} ,
2022-05-14 01:39:28 -07:00
{
displayName : 'Open Graph Title' ,
name : 'og_title' ,
type : 'string' ,
default : '' ,
} ,
2020-12-07 23:40:29 -08:00
{
displayName : 'Published At' ,
name : 'published_at' ,
type : 'dateTime' ,
default : '' ,
} ,
{
displayName : 'Slug' ,
name : 'slug' ,
type : 'string' ,
default : '' ,
} ,
{
displayName : 'Status' ,
name : 'status' ,
type : 'options' ,
options : [
{
name : 'Draft' ,
value : 'draft' ,
} ,
{
name : 'Published' ,
value : 'published' ,
} ,
{
name : 'Scheduled' ,
value : 'scheduled' ,
} ,
] ,
default : 'draft' ,
} ,
{
2022-05-14 01:39:28 -07:00
displayName : 'Tags' ,
2020-12-07 23:40:29 -08:00
name : 'tags' ,
type : 'multiOptions' ,
typeOptions : {
loadOptionsMethod : 'getTags' ,
} ,
default : [ ] ,
} ,
{
displayName : 'Twitter Description' ,
name : 'twitter_description' ,
type : 'string' ,
default : '' ,
} ,
{
displayName : 'Twitter Image' ,
name : 'twitter_image' ,
type : 'string' ,
default : '' ,
description : 'URL of the image' ,
} ,
{
displayName : 'Twitter Title' ,
name : 'twitter_title' ,
type : 'string' ,
default : '' ,
} ,
] ,
} ,
/* -------------------------------------------------------------------------- */
/* post:delete */
/* -------------------------------------------------------------------------- */
{
displayName : 'Post ID' ,
name : 'postId' ,
type : 'string' ,
default : '' ,
required : true ,
displayOptions : {
show : {
source : [
'adminApi' ,
] ,
resource : [
'post' ,
] ,
operation : [
'delete' ,
] ,
} ,
} ,
2022-05-06 14:01:25 -07:00
description : 'The ID of the post to delete' ,
2020-12-07 23:40:29 -08:00
} ,
/* -------------------------------------------------------------------------- */
/* post:get */
/* -------------------------------------------------------------------------- */
{
displayName : 'By' ,
name : 'by' ,
type : 'options' ,
2022-05-14 01:39:28 -07:00
default : 'id' ,
2020-12-07 23:40:29 -08:00
required : true ,
options : [
{
name : 'ID' ,
value : 'id' ,
} ,
{
name : 'Slug' ,
value : 'slug' ,
} ,
] ,
displayOptions : {
show : {
source : [
'contentApi' ,
'adminApi' ,
] ,
resource : [
'post' ,
] ,
operation : [
'get' ,
] ,
} ,
} ,
2022-05-06 14:01:25 -07:00
description : 'Get the post either by slug or ID' ,
2020-12-07 23:40:29 -08:00
} ,
{
displayName : 'Identifier' ,
name : 'identifier' ,
type : 'string' ,
default : '' ,
required : true ,
displayOptions : {
show : {
source : [
'contentApi' ,
'adminApi' ,
] ,
resource : [
'post' ,
] ,
operation : [
'get' ,
] ,
} ,
} ,
2022-05-06 14:01:25 -07:00
description : 'The ID or slug of the post to get' ,
2020-12-07 23:40:29 -08:00
} ,
{
displayName : 'Options' ,
name : 'options' ,
type : 'collection' ,
placeholder : 'Add Option' ,
default : { } ,
displayOptions : {
show : {
source : [
'adminApi' ,
] ,
resource : [
'post' ,
] ,
operation : [
'get' ,
] ,
} ,
} ,
options : [
{
displayName : 'Fields' ,
name : 'fields' ,
type : 'string' ,
default : '' ,
description : 'Limit the fields returned in the response object. E.g. for posts fields=title,url.' ,
} ,
{
displayName : 'Formats' ,
name : 'formats' ,
type : 'multiOptions' ,
options : [
{
name : 'HTML' ,
value : 'html' ,
} ,
{
name : 'Mobile Doc' ,
value : 'mobiledoc' ,
} ,
] ,
default : [
'mobiledoc' ,
] ,
} ,
] ,
} ,
{
displayName : 'Options' ,
name : 'options' ,
type : 'collection' ,
placeholder : 'Add Option' ,
default : { } ,
displayOptions : {
show : {
source : [
'contentApi' ,
] ,
resource : [
'post' ,
] ,
operation : [
'get' ,
] ,
} ,
} ,
options : [
{
displayName : 'Fields' ,
name : 'fields' ,
type : 'string' ,
default : '' ,
description : 'Limit the fields returned in the response object. E.g. for posts fields=title,url.' ,
} ,
{
displayName : 'Formats' ,
name : 'formats' ,
type : 'multiOptions' ,
options : [
{
name : 'HTML' ,
value : 'html' ,
} ,
{
name : 'Plaintext' ,
value : 'plaintext' ,
} ,
] ,
default : [
'html' ,
] ,
} ,
] ,
} ,
/* -------------------------------------------------------------------------- */
/* post:getAll */
/* -------------------------------------------------------------------------- */
{
displayName : 'Return All' ,
name : 'returnAll' ,
type : 'boolean' ,
displayOptions : {
show : {
source : [
'contentApi' ,
'adminApi' ,
] ,
resource : [
'post' ,
] ,
operation : [
'getAll' ,
] ,
} ,
} ,
default : false ,
2022-05-06 14:01:25 -07:00
description : 'Whether to return all results or only up to a given limit' ,
2020-12-07 23:40:29 -08:00
} ,
{
displayName : 'Limit' ,
name : 'limit' ,
type : 'number' ,
displayOptions : {
show : {
source : [
'adminApi' ,
'contentApi' ,
] ,
resource : [
'post' ,
] ,
operation : [
'getAll' ,
] ,
returnAll : [
false ,
] ,
} ,
} ,
typeOptions : {
minValue : 1 ,
maxValue : 100 ,
} ,
default : 50 ,
2022-05-06 14:01:25 -07:00
description : 'Max number of results to return' ,
2020-12-07 23:40:29 -08:00
} ,
{
displayName : 'Options' ,
name : 'options' ,
type : 'collection' ,
placeholder : 'Add Option' ,
default : { } ,
displayOptions : {
show : {
source : [
'contentApi' ,
] ,
resource : [
'post' ,
] ,
operation : [
'getAll' ,
] ,
} ,
} ,
options : [
{
displayName : 'Include' ,
name : 'include' ,
type : 'multiOptions' ,
options : [
{
name : 'Authors' ,
value : 'authors' ,
} ,
{
name : 'Tags' ,
value : 'tags' ,
} ,
] ,
default : [ ] ,
description : 'Tells the API to return additional data related to the resource you have requested' ,
} ,
{
displayName : 'Fields' ,
name : 'fields' ,
type : 'string' ,
default : '' ,
description : 'Limit the fields returned in the response object. E.g. for posts fields=title,url.' ,
} ,
{
displayName : 'Formats' ,
name : 'formats' ,
type : 'multiOptions' ,
options : [
{
name : 'HTML' ,
value : 'html' ,
} ,
{
name : 'Plaintext' ,
value : 'plaintext' ,
} ,
] ,
default : [
'html' ,
] ,
2022-05-06 14:01:25 -07:00
description : 'By default, only html is returned, however each post and page in Ghost has 2 available formats: html and plaintext' ,
2020-12-07 23:40:29 -08:00
} ,
] ,
} ,
{
displayName : 'Options' ,
name : 'options' ,
type : 'collection' ,
placeholder : 'Add Option' ,
default : { } ,
displayOptions : {
show : {
source : [
'adminApi' ,
] ,
resource : [
'post' ,
] ,
operation : [
'getAll' ,
] ,
} ,
} ,
options : [
{
displayName : 'Include' ,
name : 'include' ,
type : 'multiOptions' ,
options : [
{
name : 'Authors' ,
value : 'authors' ,
} ,
{
name : 'Tags' ,
value : 'tags' ,
} ,
] ,
default : [ ] ,
description : 'Tells the API to return additional data related to the resource you have requested' ,
} ,
{
displayName : 'Fields' ,
name : 'fields' ,
type : 'string' ,
default : '' ,
description : 'Limit the fields returned in the response object. E.g. for posts fields=title,url.' ,
} ,
{
displayName : 'Formats' ,
name : 'formats' ,
type : 'multiOptions' ,
options : [
{
name : 'HTML' ,
value : 'html' ,
} ,
{
name : 'Mobile Doc' ,
value : 'mobiledoc' ,
} ,
] ,
default : [
'mobiledoc' ,
] ,
} ,
] ,
} ,
/* -------------------------------------------------------------------------- */
/* post:update */
/* -------------------------------------------------------------------------- */
{
displayName : 'Post ID' ,
name : 'postId' ,
type : 'string' ,
displayOptions : {
show : {
source : [
'adminApi' ,
] ,
resource : [
'post' ,
] ,
operation : [
'update' ,
] ,
} ,
} ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'The ID of the post to update' ,
2020-12-07 23:40:29 -08:00
} ,
{
displayName : 'Content Format' ,
name : 'contentFormat' ,
type : 'options' ,
displayOptions : {
show : {
source : [
'adminApi' ,
] ,
resource : [
'post' ,
] ,
operation : [
'update' ,
] ,
} ,
} ,
options : [
{
name : 'HTML' ,
value : 'html' ,
} ,
{
name : 'Mobile Doc' ,
value : 'mobileDoc' ,
} ,
] ,
default : 'html' ,
2022-05-06 14:01:25 -07:00
description : 'The format of the post' ,
2020-12-07 23:40:29 -08:00
} ,
{
displayName : 'Update Fields' ,
name : 'updateFields' ,
type : 'collection' ,
placeholder : 'Add Field' ,
default : { } ,
displayOptions : {
show : {
source : [
'adminApi' ,
] ,
resource : [
'post' ,
] ,
operation : [
'update' ,
] ,
} ,
} ,
options : [
{
displayName : 'Authors IDs' ,
name : 'authors' ,
type : 'multiOptions' ,
typeOptions : {
loadOptionsMethod : 'getAuthors' ,
} ,
default : [ ] ,
} ,
{
displayName : 'Cannonical URL' ,
name : 'canonical_url' ,
type : 'string' ,
default : '' ,
} ,
{
displayName : 'Code Injection Foot' ,
name : 'codeinjection_foot' ,
type : 'string' ,
default : '' ,
} ,
{
displayName : 'Code Injection Head' ,
name : 'codeinjection_head' ,
type : 'string' ,
default : '' ,
} ,
{
displayName : 'Content' ,
name : 'content' ,
type : 'string' ,
displayOptions : {
show : {
'/contentFormat' : [
'html' ,
] ,
} ,
} ,
typeOptions : {
alwaysOpenEditWindow : true ,
} ,
default : '' ,
} ,
{
displayName : 'Content (JSON)' ,
name : 'contentJson' ,
type : 'json' ,
displayOptions : {
show : {
'/contentFormat' : [
'mobileDoc' ,
] ,
} ,
} ,
default : '' ,
2022-04-22 09:29:51 -07:00
description : 'Mobiledoc is the raw JSON format that Ghost uses to store post contents. <a href="https://ghost.org/docs/concepts/posts/#document-storage">Info.</a>.' ,
2020-12-07 23:40:29 -08:00
} ,
{
displayName : 'Featured' ,
name : 'featured' ,
type : 'boolean' ,
default : false ,
} ,
{
displayName : 'Meta Description' ,
name : 'meta_description' ,
type : 'string' ,
default : '' ,
} ,
{
displayName : 'Meta Title' ,
name : 'meta_title' ,
type : 'string' ,
default : '' ,
} ,
{
displayName : 'Open Graph Description' ,
name : 'og_description' ,
type : 'string' ,
default : '' ,
} ,
{
2022-05-14 01:39:28 -07:00
displayName : 'Open Graph Image' ,
name : 'og_image' ,
2020-12-07 23:40:29 -08:00
type : 'string' ,
default : '' ,
2022-05-14 01:39:28 -07:00
description : 'URL of the image' ,
2020-12-07 23:40:29 -08:00
} ,
{
2022-05-14 01:39:28 -07:00
displayName : 'Open Graph Title' ,
name : 'og_title' ,
2020-12-07 23:40:29 -08:00
type : 'string' ,
default : '' ,
} ,
{
displayName : 'Published At' ,
name : 'published_at' ,
type : 'dateTime' ,
default : '' ,
} ,
{
displayName : 'Slug' ,
name : 'slug' ,
type : 'string' ,
default : '' ,
} ,
{
displayName : 'Status' ,
name : 'status' ,
type : 'options' ,
options : [
{
name : 'Draft' ,
value : 'draft' ,
} ,
{
name : 'Published' ,
value : 'published' ,
} ,
{
name : 'Scheduled' ,
value : 'scheduled' ,
} ,
] ,
default : 'draft' ,
} ,
{
2022-05-14 01:39:28 -07:00
displayName : 'Tags' ,
2020-12-07 23:40:29 -08:00
name : 'tags' ,
type : 'multiOptions' ,
typeOptions : {
loadOptionsMethod : 'getTags' ,
} ,
default : [ ] ,
} ,
{
displayName : 'Title' ,
name : 'title' ,
type : 'string' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'Post\'s title' ,
2020-12-07 23:40:29 -08:00
} ,
{
displayName : 'Twitter Description' ,
name : 'twitter_description' ,
type : 'string' ,
default : '' ,
} ,
{
displayName : 'Twitter Image' ,
name : 'twitter_image' ,
type : 'string' ,
default : '' ,
description : 'URL of the image' ,
} ,
{
displayName : 'Twitter Title' ,
name : 'twitter_title' ,
type : 'string' ,
default : '' ,
} ,
] ,
} ,
2021-12-03 00:44:16 -08:00
] ;