AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
feat(ghostcms): let AI agents manage Ghost posts, pages, members, newsletters and more (#15901)
Odai Ahmada921e4587821
diff --git a/bun.lock b/bun.lockindex 113c5400e82..55b22787598 100644--- a/bun.lock+++ b/bun.lock@@ -3633,17 +3633,19 @@},"packages/pieces/community/ghostcms": {"name": "@activepieces/piece-ghostcms",- "version": "0.2.1",+ "version": "0.3.0","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*","@activepieces/pieces-common": "workspace:*","@activepieces/pieces-framework": "workspace:*",+ "form-data": "4.0.6","jsonwebtoken": "9.0.1",},"devDependencies": {"@types/jsonwebtoken": "9.0.10","tslib": "2.6.2",+ "vitest": "3.2.6",},},"packages/pieces/community/giftbit": {diff --git a/packages/pieces/community/ghostcms/package.json b/packages/pieces/community/ghostcms/package.jsonindex 4424388768b..fdbea9912b7 100644--- a/packages/pieces/community/ghostcms/package.json+++ b/packages/pieces/community/ghostcms/package.json@@ -1,22 +1,25 @@{"name": "@activepieces/piece-ghostcms",- "version": "0.2.1",+ "version": "0.3.0","main": "./dist/src/index.js","types": "./dist/src/index.d.ts","scripts": {"build": "tsc -p tsconfig.lib.json && cp package.json dist/","bundle": "node ../../../../dist/packages/cli/src/index.js pieces bundle",- "lint": "eslint 'src/**/*.ts'"+ "lint": "eslint 'src/**/*.ts'",+ "test": "vitest run"},"dependencies": {"@activepieces/pieces-common": "workspace:*","@activepieces/pieces-framework": "workspace:*","jsonwebtoken": "9.0.1","@activepieces/core-piece-types": "workspace:*",- "@activepieces/core-utils": "workspace:*"+ "@activepieces/core-utils": "workspace:*",+ "form-data": "4.0.6"},"devDependencies": {"@types/jsonwebtoken": "9.0.10",- "tslib": "2.6.2"+ "tslib": "2.6.2",+ "vitest": "3.2.6"}}diff --git a/packages/pieces/community/ghostcms/src/i18n/translation.json b/packages/pieces/community/ghostcms/src/i18n/translation.jsonindex f333f747720..07629de7407 100644--- a/packages/pieces/community/ghostcms/src/i18n/translation.json+++ b/packages/pieces/community/ghostcms/src/i18n/translation.json@@ -10,12 +10,135 @@"Create Post": "Create Post","Find Member": "Find Member","Find User": "Find User",+ "List Posts": "List Posts",+ "Get Post": "Get Post",+ "Get Post by Slug": "Get Post by Slug",+ "Update Post": "Update Post",+ "Publish Post": "Publish Post",+ "Schedule Post": "Schedule Post",+ "Unpublish Post": "Unpublish Post",+ "Copy Post": "Copy Post",+ "Delete Post": "Delete Post",+ "List Pages": "List Pages",+ "Get Page": "Get Page",+ "Get Page by Slug": "Get Page by Slug",+ "Create Page": "Create Page",+ "Update Page": "Update Page",+ "Copy Page": "Copy Page",+ "Delete Page": "Delete Page",+ "List Tags": "List Tags",+ "Get Tag": "Get Tag",+ "Get Tag by Slug": "Get Tag by Slug",+ "Create Tag": "Create Tag",+ "Update Tag": "Update Tag",+ "Delete Tag": "Delete Tag",+ "List Members": "List Members",+ "Get Member": "Get Member",+ "Get Member by Email": "Get Member by Email",+ "Delete Member": "Delete Member",+ "Add Member Label": "Add Member Label",+ "Remove Member Label": "Remove Member Label",+ "Subscribe Member to Newsletters": "Subscribe Member to Newsletters",+ "Unsubscribe Member from Newsletters": "Unsubscribe Member from Newsletters",+ "List Labels": "List Labels",+ "Get Label": "Get Label",+ "Create Label": "Create Label",+ "Update Label": "Update Label",+ "Delete Label": "Delete Label",+ "List Newsletters": "List Newsletters",+ "Get Newsletter": "Get Newsletter",+ "Create Newsletter": "Create Newsletter",+ "Update Newsletter": "Update Newsletter",+ "Archive Newsletter": "Archive Newsletter",+ "List Tiers": "List Tiers",+ "Get Tier": "Get Tier",+ "Create Tier": "Create Tier",+ "Update Tier": "Update Tier",+ "Archive Tier": "Archive Tier",+ "List Offers": "List Offers",+ "Get Offer": "Get Offer",+ "Create Offer": "Create Offer",+ "Update Offer": "Update Offer",+ "Archive Offer": "Archive Offer",+ "List Users": "List Users",+ "Get User": "Get User",+ "Get User by Email": "Get User by Email",+ "Upload Image": "Upload Image",+ "Get Site": "Get Site",+ "Upload Media": "Upload Media",+ "Upload File": "Upload File",+ "Get Settings": "Get Settings",+ "List Member Activity": "List Member Activity",+ "Get Member Stats": "Get Member Stats","Custom API Call": "Custom API Call","Create a new member": "Create a new member","Update a member": "Update a member","Create a new post": "Create a new post","Find a member by email": "Find a member by email","Find a staff user by email": "Find a staff user by email",+ "List or search posts with an optional filter.": "List or search posts with an optional filter.",+ "Get a post by ID, including its HTML content.": "Get a post by ID, including its HTML content.",+ "Get a post by its URL slug.": "Get a post by its URL slug.",+ "Create a post as a draft, published or scheduled.": "Create a post as a draft, published or scheduled.",+ "Update the content or settings of a post.": "Update the content or settings of a post.",+ "Publish a draft post now, optionally emailing it to a newsletter.": "Publish a draft post now, optionally emailing it to a newsletter.",+ "Schedule a draft post to publish at a future time.": "Schedule a draft post to publish at a future time.",+ "Move a published or scheduled post back to draft.": "Move a published or scheduled post back to draft.",+ "Duplicate a post as a new draft.": "Duplicate a post as a new draft.",+ "Permanently delete a post.": "Permanently delete a post.",+ "List or search pages with an optional filter.": "List or search pages with an optional filter.",+ "Get a page by ID, including its HTML content.": "Get a page by ID, including its HTML content.",+ "Get a page by its URL slug.": "Get a page by its URL slug.",+ "Create a static page as a draft, published or scheduled.": "Create a static page as a draft, published or scheduled.",+ "Update the content, settings or status of a page.": "Update the content, settings or status of a page.",+ "Duplicate a page as a new draft.": "Duplicate a page as a new draft.",+ "Permanently delete a page.": "Permanently delete a page.",+ "List or search post tags.": "List or search post tags.",+ "Get a tag by ID.": "Get a tag by ID.",+ "Get a tag by its slug.": "Get a tag by its slug.",+ "Create a post tag.": "Create a post tag.",+ "Update the name or settings of a tag.": "Update the name or settings of a tag.",+ "Permanently delete a tag.": "Permanently delete a tag.",+ "List or search members.": "List or search members.",+ "Get a member by ID.": "Get a member by ID.",+ "Find a member by exact email address.": "Find a member by exact email address.",+ "Add a new member to the publication.": "Add a new member to the publication.",+ "Update the details, labels or newsletters of a member.": "Update the details, labels or newsletters of a member.",+ "Permanently delete a member.": "Permanently delete a member.",+ "Add one label to a member, keeping their other labels.": "Add one label to a member, keeping their other labels.",+ "Remove one label from a member, keeping their other labels.": "Remove one label from a member, keeping their other labels.",+ "Add newsletter subscriptions to a member, keeping existing ones.": "Add newsletter subscriptions to a member, keeping existing ones.",+ "Remove newsletter subscriptions from a member.": "Remove newsletter subscriptions from a member.",+ "List member labels.": "List member labels.",+ "Get a member label by ID.": "Get a member label by ID.",+ "Create a member label.": "Create a member label.",+ "Rename a member label.": "Rename a member label.",+ "Permanently delete a member label.": "Permanently delete a member label.",+ "List the newsletters of the publication.": "List the newsletters of the publication.",+ "Get a newsletter by ID.": "Get a newsletter by ID.",+ "Create a new newsletter.": "Create a new newsletter.",+ "Update the name or settings of a newsletter.": "Update the name or settings of a newsletter.",+ "Archive a newsletter so it can no longer be sent or subscribed to.": "Archive a newsletter so it can no longer be sent or subscribed to.",+ "List membership tiers with prices and benefits.": "List membership tiers with prices and benefits.",+ "Get a membership tier by ID.": "Get a membership tier by ID.",+ "Create a paid membership tier.": "Create a paid membership tier.",+ "Update the prices, benefits or settings of a tier.": "Update the prices, benefits or settings of a tier.",+ "Archive a paid tier so new members can no longer buy it.": "Archive a paid tier so new members can no longer buy it.",+ "List discount and trial offers.": "List discount and trial offers.",+ "Get an offer by ID.": "Get an offer by ID.",+ "Create a discount or free-trial offer for a paid tier.": "Create a discount or free-trial offer for a paid tier.",+ "Update the name, code or display text of an offer.": "Update the name, code or display text of an offer.",+ "Archive an offer so it can no longer be redeemed.": "Archive an offer so it can no longer be redeemed.",+ "List staff users such as authors and editors.": "List staff users such as authors and editors.",+ "Get a staff user by ID.": "Get a staff user by ID.",+ "Find a staff user by exact email address.": "Find a staff user by exact email address.",+ "Upload an image to Ghost and get its URL.": "Upload an image to Ghost and get its URL.",+ "Get the site title, URL and Ghost version.": "Get the site title, URL and Ghost version.",+ "Upload a video or audio file to Ghost and get its URL.": "Upload a video or audio file to Ghost and get its URL.",+ "Upload a downloadable file (PDF, ZIP, CSV and more) to Ghost and get its URL.": "Upload a downloadable file (PDF, ZIP, CSV and more) to Ghost and get its URL.",+ "Get the publication settings: branding, SEO, navigation, timezone and membership options.": "Get the publication settings: branding, SEO, navigation, timezone and membership options.",+ "List member activity events such as signups, logins, newsletter changes, email opens and payments.": "List member activity events such as signups, logins, newsletter changes, email opens and payments.",+ "Get the current member totals (free, paid, comped) and the daily history.": "Get the current member totals (free, paid, comped) and the daily history.","Make a custom API call to a specific endpoint": "Make a custom API call to a specific endpoint","Email": "Email","Full Name": "Full Name",@@ -31,30 +154,246 @@"Author": "Author","Featured": "Featured","Tags": "Tags",+ "Filter": "Filter",+ "Limit": "Limit",+ "Page": "Page",+ "Order": "Order",+ "Include Content": "Include Content",+ "Post ID": "Post ID",+ "Excerpt": "Excerpt",+ "Feature Image URL": "Feature Image URL",+ "Visibility": "Visibility",+ "Authors": "Authors",+ "Meta Title": "Meta Title",+ "Meta Description": "Meta Description",+ "Clear Fields": "Clear Fields",+ "Newsletter Slug": "Newsletter Slug",+ "Email Segment": "Email Segment",+ "Email Only": "Email Only",+ "Page ID": "Page ID",+ "Tag ID": "Tag ID",+ "Name": "Name",+ "Description": "Description",+ "Accent Color": "Accent Color",+ "Search": "Search",+ "Member ID": "Member ID",+ "Labels": "Labels",+ "Newsletter IDs": "Newsletter IDs",+ "Cancel Stripe Subscriptions": "Cancel Stripe Subscriptions",+ "Label ID": "Label ID",+ "Unsubscribe from All": "Unsubscribe from All",+ "Newsletter ID": "Newsletter ID",+ "Sender Name": "Sender Name",+ "Reply-To": "Reply-To",+ "Audience": "Audience",+ "Subscribe on Signup": "Subscribe on Signup",+ "Opt In Existing Members": "Opt In Existing Members",+ "Tier ID": "Tier ID",+ "Monthly Price": "Monthly Price",+ "Yearly Price": "Yearly Price",+ "Currency": "Currency",+ "Benefits": "Benefits",+ "Welcome Page URL": "Welcome Page URL",+ "Trial Days": "Trial Days",+ "Offer ID": "Offer ID",+ "Code": "Code",+ "Cadence": "Cadence",+ "Type": "Type",+ "Amount": "Amount",+ "Duration": "Duration",+ "Duration in Months": "Duration in Months",+ "Display Title": "Display Title",+ "Display Description": "Display Description",+ "User ID": "User ID",+ "Image": "Image",+ "Purpose": "Purpose",+ "Reference": "Reference",+ "Media File": "Media File",+ "File": "File",+ "Event Type": "Event Type","Method": "Method","Headers": "Headers","Query Parameters": "Query Parameters","Body Type": "Body Type","Body": "Body",- "Response is Binary ?": "Response is Binary ?",- "No Error on Failure": "No Error on Failure",- "Timeout (in seconds)": "Timeout (in seconds)",+ "Response is Binary": "Response is Binary",+ "Return Error as Output": "Return Error as Output",+ "Timeout": "Timeout","Follow redirects": "Follow redirects",+ "A Ghost NQL filter, e.g. status:published+tag:news or title:~'launch'. Quote values that contain spaces or special characters with single quotes.": "A Ghost NQL filter, e.g. status:published+tag:news or title:~'launch'. Quote values that contain spaces or special characters with single quotes.",+ "How many records to return per page, from 1 to 100. Defaults to 15.": "How many records to return per page, from 1 to 100. Defaults to 15.",+ "The page number to return. Defaults to 1.": "The page number to return. Defaults to 1.",+ "Sort order as \"<field> asc|desc\", e.g. published_at desc.": "Sort order as \"<field> asc|desc\", e.g. published_at desc.",+ "Return the HTML body of each post. Off by default to keep the result small.": "Return the HTML body of each post. Off by default to keep the result small.",+ "The post ID, from List Posts.": "The post ID, from List Posts.",+ "The post slug, e.g. \"welcome\" for https://example.com/welcome/.": "The post slug, e.g. \"welcome\" for https://example.com/welcome/.",+ "The post title.": "The post title.",+ "The post body as HTML. Ghost converts it to its editor format.": "The post body as HTML. Ghost converts it to its editor format.",+ "The URL slug of the post. Ghost generates one from the title when empty.": "The URL slug of the post. Ghost generates one from the title when empty.",+ "A short summary shown in lists and previews.": "A short summary shown in lists and previews.",+ "The URL of the feature image, for example one returned by Upload Image.": "The URL of the feature image, for example one returned by Upload Image.",+ "Mark the post as featured. Leave empty to keep the current value.": "Mark the post as featured. Leave empty to keep the current value.",+ "Who can read the content on the site.": "Who can read the content on the site.",+ "Tag names. Missing tags are created.": "Tag names. Missing tags are created.",+ "Staff user IDs or emails, from List Users. Defaults to the integration owner.": "Staff user IDs or emails, from List Users. Defaults to the integration owner.",+ "The SEO title.": "The SEO title.",+ "The SEO description.": "The SEO description.",+ "Draft (default), published now, or scheduled for Published At.": "Draft (default), published now, or scheduled for Published At.",+ "Required when Status is Scheduled and must be in the future. Optional backdate for Published.": "Required when Status is Scheduled and must be in the future. Optional backdate for Published.",+ "The post body as HTML. Ghost converts it to its editor format. Supplying it replaces the whole body.": "The post body as HTML. Ghost converts it to its editor format. Supplying it replaces the whole body.",+ "Tag names. Missing tags are created. Supplying tags replaces the full tag list; an empty list removes every tag, and leaving it out keeps the current tags.": "Tag names. Missing tags are created. Supplying tags replaces the full tag list; an empty list removes every tag, and leaving it out keeps the current tags.",+ "Staff user IDs or emails, from List Users. Supplying authors replaces the full author list. Ghost needs at least one author, so an empty list is rejected.": "Staff user IDs or emails, from List Users. Supplying authors replaces the full author list. Ghost needs at least one author, so an empty list is rejected.",+ "Fields to blank out on the record. A field listed here must not also be given a new value. Leave empty to clear nothing.": "Fields to blank out on the record. A field listed here must not also be given a new value. Leave empty to clear nothing.",+ "Send the post by email to this newsletter, e.g. \"default-newsletter\". Get slugs from List Newsletters. Leave empty to publish on the site only.": "Send the post by email to this newsletter, e.g. \"default-newsletter\". Get slugs from List Newsletters. Leave empty to publish on the site only.",+ "Which members receive the email: \"all\", \"status:free\", \"status:-free\" (paid) or another member NQL filter. Only used with Newsletter Slug. Defaults to all.": "Which members receive the email: \"all\", \"status:free\", \"status:-free\" (paid) or another member NQL filter. Only used with Newsletter Slug. Defaults to all.",+ "Send the post as an email to the newsletter without publishing it on the site. Requires Newsletter Slug.": "Send the post as an email to the newsletter without publishing it on the site. Requires Newsletter Slug.",+ "When to publish. Must be in the future.": "When to publish. Must be in the future.",+ "The ID of the post to copy, from List Posts.": "The ID of the post to copy, from List Posts.",+ "A Ghost NQL filter, e.g. status:published or title:~'about'. Quote values that contain spaces or special characters with single quotes.": "A Ghost NQL filter, e.g. status:published or title:~'about'. Quote values that contain spaces or special characters with single quotes.",+ "Sort order as \"<field> asc|desc\", e.g. updated_at desc.": "Sort order as \"<field> asc|desc\", e.g. updated_at desc.",+ "Return the HTML body of each page. Off by default to keep the result small.": "Return the HTML body of each page. Off by default to keep the result small.",+ "The page ID, from List Pages.": "The page ID, from List Pages.",+ "The page slug, e.g. \"about\" for https://example.com/about/.": "The page slug, e.g. \"about\" for https://example.com/about/.",+ "The page title.": "The page title.",+ "The page body as HTML. Ghost converts it to its editor format.": "The page body as HTML. Ghost converts it to its editor format.",+ "The URL slug of the page. Ghost generates one from the title when empty.": "The URL slug of the page. Ghost generates one from the title when empty.",+ "Mark the page as featured. Leave empty to keep the current value.": "Mark the page as featured. Leave empty to keep the current value.",+ "Required when Status is Scheduled and must be in the future.": "Required when Status is Scheduled and must be in the future.",+ "The page body as HTML. Ghost converts it to its editor format. Supplying it replaces the whole body.": "The page body as HTML. Ghost converts it to its editor format. Supplying it replaces the whole body.",+ "Change the page status. Scheduled requires a future Published At. Leave empty to keep it.": "Change the page status. Scheduled requires a future Published At. Leave empty to keep it.",+ "The publish time. Must be in the future when Status is Scheduled.": "The publish time. Must be in the future when Status is Scheduled.",+ "The ID of the page to copy, from List Pages.": "The ID of the page to copy, from List Pages.",+ "A Ghost NQL filter, e.g. visibility:public or name:~'news'. Quote values that contain spaces or special characters with single quotes.": "A Ghost NQL filter, e.g. visibility:public or name:~'news'. Quote values that contain spaces or special characters with single quotes.",+ "Sort order as \"<field> asc|desc\", e.g. name asc.": "Sort order as \"<field> asc|desc\", e.g. name asc.",+ "The tag ID, from List Tags.": "The tag ID, from List Tags.",+ "The tag slug, e.g. \"news\".": "The tag slug, e.g. \"news\".",+ "The tag name. Start it with # to make an internal tag that is hidden from readers.": "The tag name. Start it with # to make an internal tag that is hidden from readers.",+ "The URL slug. Ghost generates one from the name when empty.": "The URL slug. Ghost generates one from the name when empty.",+ "The tag description shown on its archive page.": "The tag description shown on its archive page.",+ "A hex color, e.g. #FF5733.": "A hex color, e.g. #FF5733.",+ "The SEO title of the tag page.": "The SEO title of the tag page.",+ "The SEO description of the tag page.": "The SEO description of the tag page.",+ "A Ghost NQL filter, e.g. status:paid+label:vip. Quote values that contain spaces or special characters with single quotes.": "A Ghost NQL filter, e.g. status:paid+label:vip. Quote values that contain spaces or special characters with single quotes.",+ "Free-text search on member name and email.": "Free-text search on member name and email.",+ "Sort order as \"<field> asc|desc\", e.g. created_at desc.": "Sort order as \"<field> asc|desc\", e.g. created_at desc.",+ "The member ID, from List Members or Get Member by Email.": "The member ID, from List Members or Get Member by Email.",+ "The member email address.": "The member email address.",+ "The member full name.": "The member full name.",+ "A private note about the member, visible only to staff.": "A private note about the member, visible only to staff.",+ "Label names to apply. Missing labels are created.": "Label names to apply. Missing labels are created.",+ "The newsletters to subscribe the member to, from List Newsletters.": "The newsletters to subscribe the member to, from List Newsletters.",+ "The new email address.": "The new email address.",+ "The new full name.": "The new full name.",+ "The new private staff note.": "The new private staff note.",+ "The complete list of label names the member should have. Missing labels are created, and an empty list removes every label.": "The complete list of label names the member should have. Missing labels are created, and an empty list removes every label.",+ "The complete list of newsletter IDs the member should be subscribed to. An empty list unsubscribes the member from every newsletter.": "The complete list of newsletter IDs the member should be subscribed to. An empty list unsubscribes the member from every newsletter.",+ "Also cancel the member paid Stripe subscriptions. Off by default.": "Also cancel the member paid Stripe subscriptions. Off by default.",+ "The label ID, from List Labels.": "The label ID, from List Labels.",+ "The label ID, from List Labels or Get Member.": "The label ID, from List Labels or Get Member.",+ "The newsletters to add, from List Newsletters.": "The newsletters to add, from List Newsletters.",+ "The newsletters to remove, from Get Member or List Newsletters.": "The newsletters to remove, from Get Member or List Newsletters.",+ "Remove every newsletter subscription. Newsletter IDs are ignored when on.": "Remove every newsletter subscription. Newsletter IDs are ignored when on.",+ "A Ghost NQL filter, e.g. name:~'vip'. Quote values that contain spaces or special characters with single quotes.": "A Ghost NQL filter, e.g. name:~'vip'. Quote values that contain spaces or special characters with single quotes.",+ "The label name.": "The label name.",+ "The new label name.": "The new label name.",+ "The new label slug.": "The new label slug.",+ "A Ghost NQL filter, e.g. status:active. Quote values that contain spaces or special characters with single quotes.": "A Ghost NQL filter, e.g. status:active. Quote values that contain spaces or special characters with single quotes.",+ "Sort order as \"<field> asc|desc\", e.g. sort_order asc.": "Sort order as \"<field> asc|desc\", e.g. sort_order asc.",+ "The newsletter ID, from List Newsletters.": "The newsletter ID, from List Newsletters.",+ "The newsletter name.": "The newsletter name.",+ "A description shown to members when they choose newsletters.": "A description shown to members when they choose newsletters.",+ "The From name of the emails. Defaults to the site title.": "The From name of the emails. Defaults to the site title.",+ "Where member replies go.": "Where member replies go.",+ "Who can subscribe to the newsletter.": "Who can subscribe to the newsletter.",+ "Automatically subscribe new members to this newsletter. Leave empty to keep the current value.": "Automatically subscribe new members to this newsletter. Leave empty to keep the current value.",+ "Subscribe every existing member who is subscribed to at least one newsletter.": "Subscribe every existing member who is subscribed to at least one newsletter.",+ "A Ghost NQL filter, e.g. type:paid+active:true. Quote values that contain spaces or special characters with single quotes.": "A Ghost NQL filter, e.g. type:paid+active:true. Quote values that contain spaces or special characters with single quotes.",+ "Sort order as \"<field> asc|desc\", e.g. monthly_price asc.": "Sort order as \"<field> asc|desc\", e.g. monthly_price asc.",+ "The tier ID, from List Tiers.": "The tier ID, from List Tiers.",+ "The tier name shown on the pricing page.": "The tier name shown on the pricing page.",+ "A short description shown on the pricing page.": "A short description shown on the pricing page.",+ "The monthly price in the smallest currency unit, e.g. 500 for 5.00 USD.": "The monthly price in the smallest currency unit, e.g. 500 for 5.00 USD.",+ "The yearly price in the smallest currency unit, e.g. 5000 for 50.00 USD.": "The yearly price in the smallest currency unit, e.g. 5000 for 50.00 USD.",+ "The three-letter currency code, e.g. usd. Required with a price.": "The three-letter currency code, e.g. usd. Required with a price.",+ "The benefit lines shown on the pricing page.": "The benefit lines shown on the pricing page.",+ "Whether the tier is shown on the public pricing page.": "Whether the tier is shown on the public pricing page.",+ "Where new subscribers of this tier land after signup.": "Where new subscribers of this tier land after signup.",+ "The free trial length in days. 0 for no trial.": "The free trial length in days. 0 for no trial.",+ "The benefit lines shown on the pricing page. Supplying benefits replaces the full list, and an empty list removes every benefit.": "The benefit lines shown on the pricing page. Supplying benefits replaces the full list, and an empty list removes every benefit.",+ "The offer ID, from List Offers.": "The offer ID, from List Offers.",+ "The internal offer name.": "The internal offer name.",+ "The code used in the offer URL, e.g. black-friday.": "The code used in the offer URL, e.g. black-friday.",+ "The paid tier the offer applies to, from List Tiers.": "The paid tier the offer applies to, from List Tiers.",+ "Whether the offer applies to the monthly or the yearly price.": "Whether the offer applies to the monthly or the yearly price.",+ "Percentage discount, fixed amount off, or a free trial.": "Percentage discount, fixed amount off, or a free trial.",+ "Percent: 1 to 100. Fixed: the amount off in the smallest currency unit (500 = 5.00). Trial: the number of free days.": "Percent: 1 to 100. Fixed: the amount off in the smallest currency unit (500 = 5.00). Trial: the number of free days.",+ "How long a percent or fixed discount lasts. Ignored for trials.": "How long a percent or fixed discount lasts. Ignored for trials.",+ "Required when Duration is Several months.": "Required when Duration is Several months.",+ "The three-letter currency code of a fixed discount, e.g. usd.": "The three-letter currency code of a fixed discount, e.g. usd.",+ "The headline shown to visitors on the offer page.": "The headline shown to visitors on the offer page.",+ "The text shown to visitors on the offer page.": "The text shown to visitors on the offer page.",+ "The new internal name.": "The new internal name.",+ "The new offer code.": "The new offer code.",+ "The new headline shown on the offer page.": "The new headline shown on the offer page.",+ "The new text shown on the offer page.": "The new text shown on the offer page.",+ "The staff user ID, from List Users.": "The staff user ID, from List Users.",+ "The staff user email address.": "The staff user email address.",+ "The image file to upload.": "The image file to upload.",+ "How Ghost validates the image. Defaults to a content image.": "How Ghost validates the image. Defaults to a content image.",+ "An optional value returned unchanged, e.g. the original file name.": "An optional value returned unchanged, e.g. the original file name.",+ "The video or audio file to upload.": "The video or audio file to upload.",+ "The file to upload. Its name must end with a supported extension, e.g. .pdf or .zip.": "The file to upload. Its name must end with a supported extension, e.g. .pdf or .zip.",+ "Only return events for this member. Get the ID from List Members or Get Member by Email.": "Only return events for this member. Get the ID from List Members or Get Member by Email.",+ "Only return this kind of event.": "Only return this kind of event.",+ "A Ghost NQL filter, e.g. data.created_at:<'2026-01-01 00:00:00'. Quote values that contain spaces or special characters with single quotes.": "A Ghost NQL filter, e.g. data.created_at:<'2026-01-01 00:00:00'. Quote values that contain spaces or special characters with single quotes.","Authorization headers are injected automatically from your connection.": "Authorization headers are injected automatically from your connection.",+ "Appended to the URL as ?key=value.": "Appended to the URL as ?key=value.","Enable for files like PDFs, images, etc.": "Enable for files like PDFs, images, etc.",+ "On a failed request, output the error instead of failing the step.": "On a failed request, output the error instead of failing the step.",+ "Seconds to wait for a response. Empty: up to the flow limit (10 min).": "Seconds to wait for a response. Empty: up to the flow limit (10 min).",+ "Follow 3xx redirects instead of returning them as the response.": "Follow 3xx redirects instead of returning them as the response.","Draft": "Draft","Published": "Published","Scheduled": "Scheduled",+ "Yes": "Yes",+ "No": "No",+ "Public": "Public",+ "Members only": "Members only",+ "Paid members only": "Paid members only",+ "Newsletter sender address": "Newsletter sender address",+ "Support address": "Support address",+ "All members": "All members",+ "Hidden": "Hidden",+ "Monthly": "Monthly",+ "Yearly": "Yearly",+ "Percentage discount": "Percentage discount",+ "Fixed amount discount": "Fixed amount discount",+ "Free trial": "Free trial",+ "First payment only": "First payment only",+ "Several months": "Several months",+ "Forever": "Forever",+ "Content or feature image": "Content or feature image",+ "Profile image (square)": "Profile image (square)",+ "Site icon (square)": "Site icon (square)",+ "Signup": "Signup",+ "Login": "Login",+ "Newsletter subscribe or unsubscribe": "Newsletter subscribe or unsubscribe",+ "Email delivered": "Email delivered",+ "Email opened": "Email opened",+ "Email link clicked": "Email link clicked",+ "Email failed": "Email failed",+ "Comment": "Comment",+ "Feedback": "Feedback",+ "Paid subscription change": "Paid subscription change",+ "Payment": "Payment",+ "Email address change": "Email address change",+ "Donation": "Donation","GET": "GET","POST": "POST","PATCH": "PATCH","PUT": "PUT","DELETE": "DELETE","HEAD": "HEAD",- "None": "None",- "JSON": "JSON",- "Form Data": "Form Data",- "Raw": "Raw","Member Added": "Member Added","Member Edited": "Member Edited","Member Deleted": "Member Deleted",diff --git a/packages/pieces/community/ghostcms/src/index.ts b/packages/pieces/community/ghostcms/src/index.tsindex 0702a7555e6..67973d2da3d 100644--- a/packages/pieces/community/ghostcms/src/index.ts+++ b/packages/pieces/community/ghostcms/src/index.ts@@ -1,17 +1,79 @@-import {- createPiece,- PieceAuth,- Property,-} from '@activepieces/pieces-framework';+import { createPiece } from '@activepieces/pieces-framework';import { createCustomApiCallAction } from '@activepieces/pieces-common';import { PieceCategory } from '@activepieces/pieces-framework';+import { ghostAuth } from './lib/auth';import { createMember } from './lib/actions/create-member';import { createPost } from './lib/actions/create-post';import { findMember } from './lib/actions/find-member';import { findUser } from './lib/actions/find-user';import { updateMember } from './lib/actions/update-member';+import { ghostListPosts } from './lib/actions/ai/list-posts';+import { ghostGetPost } from './lib/actions/ai/get-post';+import { ghostGetPostBySlug } from './lib/actions/ai/get-post-by-slug';+import { ghostCreatePost } from './lib/actions/ai/create-post';+import { ghostUpdatePost } from './lib/actions/ai/update-post';+import { ghostPublishPost } from './lib/actions/ai/publish-post';+import { ghostSchedulePost } from './lib/actions/ai/schedule-post';+import { ghostUnpublishPost } from './lib/actions/ai/unpublish-post';+import { ghostCopyPost } from './lib/actions/ai/copy-post';+import { ghostDeletePost } from './lib/actions/ai/delete-post';+import { ghostListPages } from './lib/actions/ai/list-pages';+import { ghostGetPage } from './lib/actions/ai/get-page';+import { ghostGetPageBySlug } from './lib/actions/ai/get-page-by-slug';+import { ghostCreatePage } from './lib/actions/ai/create-page';+import { ghostUpdatePage } from './lib/actions/ai/update-page';+import { ghostCopyPage } from './lib/actions/ai/copy-page';+import { ghostDeletePage } from './lib/actions/ai/delete-page';+import { ghostListTags } from './lib/actions/ai/list-tags';+import { ghostGetTag } from './lib/actions/ai/get-tag';+import { ghostGetTagBySlug } from './lib/actions/ai/get-tag-by-slug';+import { ghostCreateTag } from './lib/actions/ai/create-tag';+import { ghostUpdateTag } from './lib/actions/ai/update-tag';+import { ghostDeleteTag } from './lib/actions/ai/delete-tag';+import { ghostListMembers } from './lib/actions/ai/list-members';+import { ghostGetMember } from './lib/actions/ai/get-member';+import { ghostGetMemberByEmail } from './lib/actions/ai/get-member-by-email';+import { ghostCreateMember } from './lib/actions/ai/create-member';+import { ghostUpdateMember } from './lib/actions/ai/update-member';+import { ghostDeleteMember } from './lib/actions/ai/delete-member';+import { ghostAddMemberLabel } from './lib/actions/ai/add-member-label';+import { ghostRemoveMemberLabel } from './lib/actions/ai/remove-member-label';+import { ghostSubscribeMemberToNewsletters } from './lib/actions/ai/subscribe-member-to-newsletters';+import { ghostUnsubscribeMemberFromNewsletters } from './lib/actions/ai/unsubscribe-member-from-newsletters';+import { ghostListLabels } from './lib/actions/ai/list-labels';+import { ghostGetLabel } from './lib/actions/ai/get-label';+import { ghostCreateLabel } from './lib/actions/ai/create-label';+import { ghostUpdateLabel } from './lib/actions/ai/update-label';+import { ghostDeleteLabel } from './lib/actions/ai/delete-label';+import { ghostListNewsletters } from './lib/actions/ai/list-newsletters';+import { ghostGetNewsletter } from './lib/actions/ai/get-newsletter';+import { ghostCreateNewsletter } from './lib/actions/ai/create-newsletter';+import { ghostUpdateNewsletter } from './lib/actions/ai/update-newsletter';+import { ghostArchiveNewsletter } from './lib/actions/ai/archive-newsletter';+import { ghostListTiers } from './lib/actions/ai/list-tiers';+import { ghostGetTier } from './lib/actions/ai/get-tier';+import { ghostCreateTier } from './lib/actions/ai/create-tier';+import { ghostUpdateTier } from './lib/actions/ai/update-tier';+import { ghostArchiveTier } from './lib/actions/ai/archive-tier';+import { ghostListOffers } from './lib/actions/ai/list-offers';+import { ghostGetOffer } from './lib/actions/ai/get-offer';+import { ghostCreateOffer } from './lib/actions/ai/create-offer';+import { ghostUpdateOffer } from './lib/actions/ai/update-offer';+import { ghostArchiveOffer } from './lib/actions/ai/archive-offer';+import { ghostListUsers } from './lib/actions/ai/list-users';+import { ghostGetUser } from './lib/actions/ai/get-user';+import { ghostGetUserByEmail } from './lib/actions/ai/get-user-by-email';+import { ghostUploadImage } from './lib/actions/ai/upload-image';+import { ghostGetSite } from './lib/actions/ai/get-site';+import { ghostUploadMedia } from './lib/actions/ai/upload-media';+import { ghostUploadFile } from './lib/actions/ai/upload-file';+import { ghostGetSettings } from './lib/actions/ai/get-settings';+import { ghostListMemberActivity } from './lib/actions/ai/list-member-activity';+import { ghostGetMemberStats } from './lib/actions/ai/get-member-stats';import { common } from './lib/common';+import { ghostClient } from './lib/common/client';+import { assertGhostUrl } from './lib/common/custom-api-guard';import { memberAdded } from './lib/triggers/member-added';import { memberDeleted } from './lib/triggers/member-deleted';import { memberEdited } from './lib/triggers/member-edited';@@ -19,38 +81,14 @@ import { pagePublished } from './lib/triggers/page-published';import { postPublished } from './lib/triggers/post-published';import { postScheduled } from './lib/triggers/post-scheduled';-const authMarkdown = `-To generate an API key, follow the steps below in GhostCMS:-1. Go to Settings -> Advanced -> Integrations.-2. Scroll down to Custom Integrations and click Add custom integration.-3. Enter integration name and click create.-4. Copy the API URL and the Admin API Key into the fields below.-`;--export const ghostAuth = PieceAuth.CustomAuth({- description: authMarkdown,- required: true,- props: {- baseUrl: Property.ShortText({- displayName: 'API URL',- description:- 'The API URL of your application (https://test-publication.ghost.io)',- required: true,- }),- apiKey: PieceAuth.SecretText({- displayName: 'Admin API Key',- description: 'The admin API key for your application',- required: true,- }),- },-});+export { ghostAuth };export const ghostcms = createPiece({displayName: 'GhostCMS',description: 'Publishing platform for professional bloggers',auth: ghostAuth,- minimumSupportedRelease: '0.30.0',+ minimumSupportedRelease: '0.88.2',logoUrl: 'https://cdn.activepieces.com/pieces/ghostcms.png',categories: [PieceCategory.MARKETING],authors: ["kishanprmr","MoShizzle","abuaboud"],@@ -60,15 +98,78 @@ export const ghostcms = createPiece({createPost,findMember,findUser,+ ghostListPosts,+ ghostGetPost,+ ghostGetPostBySlug,+ ghostCreatePost,+ ghostUpdatePost,+ ghostPublishPost,+ ghostSchedulePost,+ ghostUnpublishPost,+ ghostCopyPost,+ ghostDeletePost,+ ghostListPages,+ ghostGetPage,+ ghostGetPageBySlug,+ ghostCreatePage,+ ghostUpdatePage,+ ghostCopyPage,+ ghostDeletePage,+ ghostListTags,+ ghostGetTag,+ ghostGetTagBySlug,+ ghostCreateTag,+ ghostUpdateTag,+ ghostDeleteTag,+ ghostListMembers,+ ghostGetMember,+ ghostGetMemberByEmail,+ ghostCreateMember,+ ghostUpdateMember,+ ghostDeleteMember,+ ghostAddMemberLabel,+ ghostRemoveMemberLabel,+ ghostSubscribeMemberToNewsletters,+ ghostUnsubscribeMemberFromNewsletters,+ ghostListLabels,+ ghostGetLabel,+ ghostCreateLabel,+ ghostUpdateLabel,+ ghostDeleteLabel,+ ghostListNewsletters,+ ghostGetNewsletter,+ ghostCreateNewsletter,+ ghostUpdateNewsletter,+ ghostArchiveNewsletter,+ ghostListTiers,+ ghostGetTier,+ ghostCreateTier,+ ghostUpdateTier,+ ghostArchiveTier,+ ghostListOffers,+ ghostGetOffer,+ ghostCreateOffer,+ ghostUpdateOffer,+ ghostArchiveOffer,+ ghostListUsers,+ ghostGetUser,+ ghostGetUserByEmail,+ ghostUploadImage,+ ghostGetSite,+ ghostUploadMedia,+ ghostUploadFile,+ ghostGetSettings,+ ghostListMemberActivity,+ ghostGetMemberStats,createCustomApiCallAction({- baseUrl: (auth) =>auth ?- `${auth.props.baseUrl}/ghost/api/admin` : '',+ baseUrl: (auth) => (auth ? ghostClient.adminUrl(auth) : ''),auth: ghostAuth,- authMapping: async (auth) => ({- Authorization: `Ghost ${common.jwtFromApiKey(- auth.props.apiKey- )}`,- }),+ authMapping: async (auth, propsValue) => {+ assertGhostUrl({ auth, propsValue });+ return {+ Authorization: `Ghost ${common.jwtFromApiKey(auth.props.apiKey)}`,+ };+ },}),],triggers: [diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/add-member-label.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/add-member-label.tsnew file mode 100644index 00000000000..8a2162d173e--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/add-member-label.ts@@ -0,0 +1,32 @@+import { createAction } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { changeMemberLabel } from '../../common/member-labels';+import { ghostMemberOutputSchema } from '../../output-schemas';++export const ghostAddMemberLabel = createAction({+ auth: ghostAuth,+ name: 'ghost_add_member_label',+ outputSchema: ghostMemberOutputSchema,+ classification: 'WRITE',+ displayName: 'Add Member Label',+ description: 'Add one label to a member, keeping their other labels.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Adds one existing label to a member without touching their other labels, and returns the updated member. Get the label ID from List Labels or Create Label. Adding a label the member already has is a no-op.',+ idempotent: true,+ },+ props: {+ member_id: ghostProps.id('Member ID', 'The member ID, from List Members or Get Member by Email.'),+ label_id: ghostProps.id('Label ID', 'The label ID, from List Labels.'),+ },+ async run(context) {+ return changeMemberLabel({+ auth: context.auth,+ memberId: context.propsValue.member_id,+ labelId: context.propsValue.label_id,+ action: 'addLabel',+ });+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/archive-newsletter.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/archive-newsletter.tsnew file mode 100644index 00000000000..b6ccf02c8a7--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/archive-newsletter.ts@@ -0,0 +1,28 @@+import { createAction } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { ghostCommon } from '../../common/client';+import { ghostResource } from '../../common/resources';+import { ghostNewsletterOutputSchema } from '../../output-schemas';++export const ghostArchiveNewsletter = createAction({+ auth: ghostAuth,+ name: 'ghost_archive_newsletter',+ outputSchema: ghostNewsletterOutputSchema,+ classification: 'DESTRUCTIVE',+ displayName: 'Archive Newsletter',+ description: 'Archive a newsletter so it can no longer be sent or subscribed to.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Archives a newsletter: members can no longer subscribe and posts can no longer be emailed to it. Staff can reactivate it in Ghost Admin. Archiving an archived newsletter is a no-op.',+ idempotent: true,+ },+ props: {+ newsletter_id: ghostProps.id('Newsletter ID', 'The newsletter ID, from List Newsletters.'),+ },+ async run(context) {+ const id = ghostCommon.id(context.propsValue.newsletter_id, 'Newsletter ID');+ return ghostResource.edit(context.auth, 'newsletters', id, { status: 'archived' });+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/archive-offer.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/archive-offer.tsnew file mode 100644index 00000000000..517ccac1d3c--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/archive-offer.ts@@ -0,0 +1,28 @@+import { createAction } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { ghostCommon } from '../../common/client';+import { ghostResource } from '../../common/resources';+import { ghostOfferOutputSchema } from '../../output-schemas';++export const ghostArchiveOffer = createAction({+ auth: ghostAuth,+ name: 'ghost_archive_offer',+ outputSchema: ghostOfferOutputSchema,+ classification: 'DESTRUCTIVE',+ displayName: 'Archive Offer',+ description: 'Archive an offer so it can no longer be redeemed.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Archives an offer: its link and code stop working for new redemptions, while members who already redeemed it keep their discount. Staff can reactivate it in Ghost Admin. Archiving an archived offer is a no-op.',+ idempotent: true,+ },+ props: {+ offer_id: ghostProps.id('Offer ID', 'The offer ID, from List Offers.'),+ },+ async run(context) {+ const id = ghostCommon.id(context.propsValue.offer_id, 'Offer ID');+ return ghostResource.edit(context.auth, 'offers', id, { status: 'archived' });+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/archive-tier.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/archive-tier.tsnew file mode 100644index 00000000000..39ad747778d--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/archive-tier.ts@@ -0,0 +1,29 @@+import { createAction } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { ghostCommon } from '../../common/client';+import { ghostResource } from '../../common/resources';+import { TIER_QUERY } from '../../common/tier-props';+import { ghostTierOutputSchema } from '../../output-schemas';++export const ghostArchiveTier = createAction({+ auth: ghostAuth,+ name: 'ghost_archive_tier',+ outputSchema: ghostTierOutputSchema,+ classification: 'DESTRUCTIVE',+ displayName: 'Archive Tier',+ description: 'Archive a paid tier so new members can no longer buy it.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Archives a paid membership tier: it disappears from the pricing page and cannot be bought, while existing subscribers keep it. Staff can reactivate it in Ghost Admin. Archiving an archived tier is a no-op.',+ idempotent: true,+ },+ props: {+ tier_id: ghostProps.id('Tier ID', 'The tier ID, from List Tiers.'),+ },+ async run(context) {+ const id = ghostCommon.id(context.propsValue.tier_id, 'Tier ID');+ return ghostResource.edit(context.auth, 'tiers', id, { active: false }, TIER_QUERY);+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/copy-page.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/copy-page.tsnew file mode 100644index 00000000000..a9107b331bd--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/copy-page.ts@@ -0,0 +1,27 @@+import { createAction } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { ghostCommon } from '../../common/client';+import { ghostContent } from '../../common/content';+import { ghostPageOutputSchema } from '../../output-schemas';++export const ghostCopyPage = createAction({+ auth: ghostAuth,+ name: 'ghost_copy_page',+ outputSchema: ghostPageOutputSchema,+ classification: 'WRITE',+ displayName: 'Copy Page',+ description: 'Duplicate a page as a new draft.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Duplicates a static page into a new draft with the same content and returns the copy. Each call creates another copy.',+ idempotent: false,+ },+ props: {+ page_id: ghostProps.id('Page ID', 'The ID of the page to copy, from List Pages.'),+ },+ async run(context) {+ return ghostContent.copy(context.auth, 'pages', ghostCommon.id(context.propsValue.page_id, 'Page ID'));+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/copy-post.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/copy-post.tsnew file mode 100644index 00000000000..719b59b6af0--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/copy-post.ts@@ -0,0 +1,27 @@+import { createAction } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { ghostCommon } from '../../common/client';+import { ghostContent } from '../../common/content';+import { ghostPostOutputSchema } from '../../output-schemas';++export const ghostCopyPost = createAction({+ auth: ghostAuth,+ name: 'ghost_copy_post',+ outputSchema: ghostPostOutputSchema,+ classification: 'WRITE',+ displayName: 'Copy Post',+ description: 'Duplicate a post as a new draft.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Duplicates a post into a new draft with the same content, tags and authors and returns the copy. Each call creates another copy.',+ idempotent: false,+ },+ props: {+ post_id: ghostProps.id('Post ID', 'The ID of the post to copy, from List Posts.'),+ },+ async run(context) {+ return ghostContent.copy(context.auth, 'posts', ghostCommon.id(context.propsValue.post_id, 'Post ID'));+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/create-label.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/create-label.tsnew file mode 100644index 00000000000..7cb7cffeadd--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/create-label.ts@@ -0,0 +1,29 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostResource } from '../../common/resources';+import { ghostCreateLabelOutputSchema } from '../../output-schemas';++export const ghostCreateLabel = createAction({+ auth: ghostAuth,+ name: 'ghost_create_label',+ outputSchema: ghostCreateLabelOutputSchema,+ classification: 'WRITE',+ displayName: 'Create Label',+ description: 'Create a member label.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Creates a member label used to segment members. Ghost rejects a duplicate name, so check List Labels first. Returns the label ID for Add Member Label.',+ idempotent: false,+ },+ props: {+ name: Property.ShortText({+ displayName: 'Name',+ description: 'The label name.',+ required: true,+ }),+ },+ async run(context) {+ return ghostResource.create(context.auth, 'labels', ghostResource.pick(context.propsValue, ['name']));+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/create-member.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/create-member.tsnew file mode 100644index 00000000000..2909619e985--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/create-member.ts@@ -0,0 +1,61 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { ghostCommon } from '../../common/client';+import { ghostResource } from '../../common/resources';+import { ghostMemberOutputSchema } from '../../output-schemas';++export const ghostCreateMember = createAction({+ auth: ghostAuth,+ name: 'ghost_create_member',+ outputSchema: ghostMemberOutputSchema,+ classification: 'WRITE',+ displayName: 'Create Member',+ description: 'Add a new member to the publication.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Adds a free member by email with optional name, note, labels (by name, created if missing) and newsletter IDs. Without Newsletter IDs Ghost subscribes the member to the newsletters that auto-subscribe new signups. Ghost rejects an email that is already a member, so use Get Member by Email first.',+ idempotent: false,+ },+ props: {+ email: Property.ShortText({+ displayName: 'Email',+ description: 'The member email address.',+ required: true,+ }),+ name: Property.ShortText({+ displayName: 'Name',+ description: 'The member full name.',+ required: false,+ }),+ note: Property.LongText({+ displayName: 'Note',+ description: 'A private note about the member, visible only to staff.',+ required: false,+ }),+ labels: Property.Array({+ displayName: 'Labels',+ description: 'Label names to apply. Missing labels are created.',+ required: false,+ }),+ newsletter_ids: ghostProps.newsletterIds(+ 'Newsletter IDs',+ 'The newsletters to subscribe the member to, from List Newsletters.',+ false+ ),+ },+ async run(context) {+ const { email, name, note, labels, newsletter_ids } = context.propsValue;+ const body = ghostResource.pick({ email, name, note }, ['email', 'name', 'note']);+ const labelNames = ghostCommon.stringList(labels);+ if (labelNames) {+ body['labels'] = labelNames.map((label) => ({ name: label }));+ }+ const newsletters = ghostCommon.stringList(newsletter_ids);+ if (newsletters) {+ body['newsletters'] = newsletters.map((id) => ({ id }));+ }+ return ghostResource.create(context.auth, 'members', body);+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/create-newsletter.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/create-newsletter.tsnew file mode 100644index 00000000000..a41ab32a0ef--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/create-newsletter.ts@@ -0,0 +1,40 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostCommon } from '../../common/client';+import { NEWSLETTER_FIELDS, newsletterProps } from '../../common/newsletter-props';+import { ghostResource } from '../../common/resources';+import { ghostNewsletterOutputSchema } from '../../output-schemas';++export const ghostCreateNewsletter = createAction({+ auth: ghostAuth,+ name: 'ghost_create_newsletter',+ outputSchema: ghostNewsletterOutputSchema,+ classification: 'WRITE',+ displayName: 'Create Newsletter',+ description: 'Create a new newsletter.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Creates a newsletter members can subscribe to; it changes the public signup options of the site. Opt In Existing Members subscribes every current member at once. The sender email is not set here because Ghost must verify it by email first. Each call creates a new newsletter.',+ idempotent: false,+ },+ props: {+ ...newsletterProps('create'),+ opt_in_existing: Property.Checkbox({+ displayName: 'Opt In Existing Members',+ description: 'Subscribe every existing member who is subscribed to at least one newsletter.',+ required: false,+ defaultValue: false,+ }),+ },+ async run(context) {+ const body = ghostResource.pick(context.propsValue, NEWSLETTER_FIELDS);+ const subscribeOnSignup = ghostCommon.triState(context.propsValue.subscribe_on_signup);+ if (subscribeOnSignup !== undefined) {+ body['subscribe_on_signup'] = subscribeOnSignup;+ }+ return ghostResource.create(context.auth, 'newsletters', body, {+ opt_in_existing: context.propsValue.opt_in_existing === true ? 'true' : undefined,+ });+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/create-offer.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/create-offer.tsnew file mode 100644index 00000000000..ea92f36ce9d--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/create-offer.ts@@ -0,0 +1,133 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostCommon } from '../../common/client';+import { ghostResource } from '../../common/resources';+import { ghostCreateOfferOutputSchema } from '../../output-schemas';++export const ghostCreateOffer = createAction({+ auth: ghostAuth,+ name: 'ghost_create_offer',+ outputSchema: ghostCreateOfferOutputSchema,+ classification: 'WRITE',+ displayName: 'Create Offer',+ description: 'Create a discount or free-trial offer for a paid tier.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Creates a public discount or free-trial offer on a paid tier; anyone with the code or offer link can redeem it, so confirm the terms before calling. Percent and fixed offers need Duration, and a fixed offer needs Currency. Ghost rejects a code already in use.',+ idempotent: false,+ },+ props: {+ name: Property.ShortText({+ displayName: 'Name',+ description: 'The internal offer name.',+ required: true,+ }),+ code: Property.ShortText({+ displayName: 'Code',+ description: 'The code used in the offer URL, e.g. black-friday.',+ required: true,+ }),+ tier_id: Property.ShortText({+ displayName: 'Tier ID',+ description: 'The paid tier the offer applies to, from List Tiers.',+ required: true,+ }),+ cadence: Property.StaticDropdown({+ displayName: 'Cadence',+ description: 'Whether the offer applies to the monthly or the yearly price.',+ required: true,+ options: {+ options: [+ { label: 'Monthly', value: 'month' },+ { label: 'Yearly', value: 'year' },+ ],+ },+ }),+ type: Property.StaticDropdown({+ displayName: 'Type',+ description: 'Percentage discount, fixed amount off, or a free trial.',+ required: true,+ options: {+ options: [+ { label: 'Percentage discount', value: 'percent' },+ { label: 'Fixed amount discount', value: 'fixed' },+ { label: 'Free trial', value: 'trial' },+ ],+ },+ }),+ amount: Property.Number({+ displayName: 'Amount',+ description:+ 'Percent: 1 to 100. Fixed: the amount off in the smallest currency unit (500 = 5.00). Trial: the number of free days.',+ required: true,+ }),+ duration: Property.StaticDropdown({+ displayName: 'Duration',+ description: 'How long a percent or fixed discount lasts. Ignored for trials.',+ required: false,+ options: {+ options: [+ { label: 'First payment only', value: 'once' },+ { label: 'Several months', value: 'repeating' },+ { label: 'Forever', value: 'forever' },+ ],+ },+ }),+ duration_in_months: Property.Number({+ displayName: 'Duration in Months',+ description: 'Required when Duration is Several months.',+ required: false,+ }),+ currency: Property.ShortText({+ displayName: 'Currency',+ description: 'The three-letter currency code of a fixed discount, e.g. usd.',+ required: false,+ }),+ display_title: Property.ShortText({+ displayName: 'Display Title',+ description: 'The headline shown to visitors on the offer page.',+ required: false,+ }),+ display_description: Property.LongText({+ displayName: 'Display Description',+ description: 'The text shown to visitors on the offer page.',+ required: false,+ }),+ },+ async run(context) {+ const props = context.propsValue;+ const body = ghostResource.pick(props, ['name', 'code', 'cadence', 'type', 'display_title', 'display_description']);+ const amount = Number(props.amount);+ if (!Number.isInteger(amount) || amount <= 0) {+ throw new Error('Amount must be a whole number above 0.');+ }+ body['amount'] = amount;+ body['tier'] = { id: props.tier_id.trim() };+ if (props.type === 'trial') {+ body['duration'] = 'trial';+ } else {+ if (!ghostCommon.hasText(props.duration)) {+ throw new Error('Duration is required for percent and fixed offers.');+ }+ body['duration'] = props.duration;+ if (props.duration === 'repeating') {+ const months = Number(props.duration_in_months);+ if (!Number.isInteger(months) || months <= 0) {+ throw new Error('Duration in Months is required when Duration is Several months.');+ }+ body['duration_in_months'] = months;+ }+ if (props.type === 'percent' && amount > 100) {+ throw new Error('A percentage discount cannot exceed 100.');+ }+ if (props.type === 'fixed') {+ if (!ghostCommon.hasText(props.currency)) {+ throw new Error('Currency is required for a fixed discount.');+ }+ body['currency'] = props.currency.trim().toLowerCase();+ }+ }+ return ghostResource.create(context.auth, 'offers', body);+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/create-page.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/create-page.tsnew file mode 100644index 00000000000..0adb49029f7--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/create-page.ts@@ -0,0 +1,53 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostCommon } from '../../common/client';+import { contentProps, ghostContent } from '../../common/content';+import { ghostPageOutputSchema } from '../../output-schemas';++export const ghostCreatePage = createAction({+ auth: ghostAuth,+ name: 'ghost_create_page',+ outputSchema: ghostPageOutputSchema,+ classification: 'WRITE',+ displayName: 'Create Page',+ description: 'Create a static page as a draft, published or scheduled.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Creates a static page (such as About or Contact, not a blog post) from a title and optional HTML. It is saved as a draft unless Status says otherwise; pages are never emailed. Each call creates a new page.',+ idempotent: false,+ },+ props: {+ ...contentProps({ label: 'page', mode: 'create' }),+ status: Property.StaticDropdown({+ displayName: 'Status',+ description: 'Draft (default), published now, or scheduled for Published At.',+ required: false,+ defaultValue: 'draft',+ options: {+ options: [+ { label: 'Draft', value: 'draft' },+ { label: 'Published', value: 'published' },+ { label: 'Scheduled', value: 'scheduled' },+ ],+ },+ }),+ published_at: Property.DateTime({+ displayName: 'Published At',+ description: 'Required when Status is Scheduled and must be in the future.',+ required: false,+ }),+ },+ async run(context) {+ const props = context.propsValue;+ const body = ghostContent.body(props);+ const status = props.status ?? 'draft';+ body['status'] = status;+ if (status === 'scheduled') {+ body['published_at'] = ghostCommon.futureDate(props.published_at, 'Published At');+ } else if (ghostCommon.hasText(props.published_at)) {+ body['published_at'] = props.published_at;+ }+ return ghostContent.create(context.auth, 'pages', body);+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/create-post.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/create-post.tsnew file mode 100644index 00000000000..8a8fe42d9a6--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/create-post.ts@@ -0,0 +1,53 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostCommon } from '../../common/client';+import { contentProps, ghostContent } from '../../common/content';+import { ghostPostOutputSchema } from '../../output-schemas';++export const ghostCreatePost = createAction({+ auth: ghostAuth,+ name: 'ghost_create_post',+ outputSchema: ghostPostOutputSchema,+ classification: 'WRITE',+ displayName: 'Create Post',+ description: 'Create a post as a draft, published or scheduled.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Creates a post from a title and optional HTML, tags (by name, created if missing) and authors. It is saved as a draft unless Status says otherwise; this never emails subscribers, so use Publish Post with a newsletter to send it. Each call creates a new post.',+ idempotent: false,+ },+ props: {+ ...contentProps({ label: 'post', mode: 'create' }),+ status: Property.StaticDropdown({+ displayName: 'Status',+ description: 'Draft (default), published now, or scheduled for Published At.',+ required: false,+ defaultValue: 'draft',+ options: {+ options: [+ { label: 'Draft', value: 'draft' },+ { label: 'Published', value: 'published' },+ { label: 'Scheduled', value: 'scheduled' },+ ],+ },+ }),+ published_at: Property.DateTime({+ displayName: 'Published At',+ description: 'Required when Status is Scheduled and must be in the future. Optional backdate for Published.',+ required: false,+ }),+ },+ async run(context) {+ const props = context.propsValue;+ const body = ghostContent.body(props);+ const status = props.status ?? 'draft';+ body['status'] = status;+ if (status === 'scheduled') {+ body['published_at'] = ghostCommon.futureDate(props.published_at, 'Published At');+ } else if (ghostCommon.hasText(props.published_at)) {+ body['published_at'] = props.published_at;+ }+ return ghostContent.create(context.auth, 'posts', body);+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/create-tag.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/create-tag.tsnew file mode 100644index 00000000000..7cded629518--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/create-tag.ts@@ -0,0 +1,24 @@+import { createAction } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostResource } from '../../common/resources';+import { TAG_FIELDS, tagProps } from '../../common/tag-props';+import { ghostCreateTagOutputSchema } from '../../output-schemas';++export const ghostCreateTag = createAction({+ auth: ghostAuth,+ name: 'ghost_create_tag',+ outputSchema: ghostCreateTagOutputSchema,+ classification: 'WRITE',+ displayName: 'Create Tag',+ description: 'Create a post tag.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Creates a post tag. Not needed before tagging a post, because Create Post and Update Post create missing tags by name. Each call creates a new tag, so check List Tags first to avoid duplicates.',+ idempotent: false,+ },+ props: tagProps('create'),+ async run(context) {+ return ghostResource.create(context.auth, 'tags', ghostResource.pick(context.propsValue, TAG_FIELDS));+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/create-tier.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/create-tier.tsnew file mode 100644index 00000000000..0736a84c84e--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/create-tier.ts@@ -0,0 +1,29 @@+import { createAction } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostResource } from '../../common/resources';+import { tierBody } from '../../common/tier-body';+import { TIER_QUERY, tierProps } from '../../common/tier-props';+import { ghostTierOutputSchema } from '../../output-schemas';++export const ghostCreateTier = createAction({+ auth: ghostAuth,+ name: 'ghost_create_tier',+ outputSchema: ghostTierOutputSchema,+ classification: 'WRITE',+ displayName: 'Create Tier',+ description: 'Create a paid membership tier.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Creates a paid membership tier with prices in the smallest currency unit; a public tier appears on the site pricing page right away, so confirm pricing before calling. Selling it needs Stripe connected in Ghost. Each call creates a new tier.',+ idempotent: false,+ },+ props: tierProps('create'),+ async run(context) {+ const body = tierBody(context.propsValue);+ if ((body['monthly_price'] !== undefined || body['yearly_price'] !== undefined) && !body['currency']) {+ throw new Error('Currency is required when setting a price.');+ }+ return ghostResource.create(context.auth, 'tiers', body, TIER_QUERY);+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/delete-label.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/delete-label.tsnew file mode 100644index 00000000000..ba7ef8471a7--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/delete-label.ts@@ -0,0 +1,29 @@+import { createAction } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { ghostCommon } from '../../common/client';+import { ghostResource } from '../../common/resources';+import { ghostDeleteLabelOutputSchema } from '../../output-schemas';++export const ghostDeleteLabel = createAction({+ auth: ghostAuth,+ name: 'ghost_delete_label',+ outputSchema: ghostDeleteLabelOutputSchema,+ classification: 'DESTRUCTIVE',+ displayName: 'Delete Label',+ description: 'Permanently delete a member label.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Permanently deletes a member label and removes it from every member; the members stay. It cannot be restored, and a retry fails with not found.',+ idempotent: false,+ },+ props: {+ label_id: ghostProps.id('Label ID', 'The label ID, from List Labels.'),+ },+ async run(context) {+ const label_id = context.propsValue.label_id.trim();+ await ghostResource.remove(context.auth, 'labels', ghostCommon.id(label_id, 'Label ID'));+ return { success: true, label_id };+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/delete-member.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/delete-member.tsnew file mode 100644index 00000000000..448eec67c05--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/delete-member.ts@@ -0,0 +1,38 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { ghostCommon } from '../../common/client';+import { ghostResource } from '../../common/resources';+import { ghostDeleteMemberOutputSchema } from '../../output-schemas';++export const ghostDeleteMember = createAction({+ auth: ghostAuth,+ name: 'ghost_delete_member',+ outputSchema: ghostDeleteMemberOutputSchema,+ classification: 'DESTRUCTIVE',+ displayName: 'Delete Member',+ description: 'Permanently delete a member.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Permanently deletes a member and their history; it cannot be restored. A paid member keeps being billed by Stripe unless Cancel Stripe Subscriptions is on. A retry fails with not found.',+ idempotent: false,+ },+ props: {+ member_id: ghostProps.id('Member ID', 'The member ID, from List Members or Get Member by Email.'),+ cancel_stripe_subscriptions: Property.Checkbox({+ displayName: 'Cancel Stripe Subscriptions',+ description: 'Also cancel the member paid Stripe subscriptions. Off by default.',+ required: false,+ defaultValue: false,+ }),+ },+ async run(context) {+ const member_id = context.propsValue.member_id.trim();+ const cancel = context.propsValue.cancel_stripe_subscriptions === true;+ await ghostResource.remove(context.auth, 'members', ghostCommon.id(member_id, 'Member ID'), {+ cancel: cancel ? 'true' : undefined,+ });+ return { success: true, member_id, stripe_subscriptions_cancelled: cancel };+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/delete-page.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/delete-page.tsnew file mode 100644index 00000000000..1b51dcdb431--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/delete-page.ts@@ -0,0 +1,29 @@+import { createAction } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { ghostCommon } from '../../common/client';+import { ghostContent } from '../../common/content';+import { ghostDeletePageOutputSchema } from '../../output-schemas';++export const ghostDeletePage = createAction({+ auth: ghostAuth,+ name: 'ghost_delete_page',+ outputSchema: ghostDeletePageOutputSchema,+ classification: 'DESTRUCTIVE',+ displayName: 'Delete Page',+ description: 'Permanently delete a page.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Permanently deletes a static page by ID; it cannot be restored. Prefer Update Page with Status Draft to take it off the site. A retry fails with not found.',+ idempotent: false,+ },+ props: {+ page_id: ghostProps.id('Page ID', 'The page ID, from List Pages.'),+ },+ async run(context) {+ const page_id = context.propsValue.page_id.trim();+ await ghostContent.remove(context.auth, 'pages', ghostCommon.id(page_id, 'Page ID'));+ return { success: true, page_id };+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/delete-post.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/delete-post.tsnew file mode 100644index 00000000000..85e76e472c0--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/delete-post.ts@@ -0,0 +1,29 @@+import { createAction } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { ghostCommon } from '../../common/client';+import { ghostContent } from '../../common/content';+import { ghostDeletePostOutputSchema } from '../../output-schemas';++export const ghostDeletePost = createAction({+ auth: ghostAuth,+ name: 'ghost_delete_post',+ outputSchema: ghostDeletePostOutputSchema,+ classification: 'DESTRUCTIVE',+ displayName: 'Delete Post',+ description: 'Permanently delete a post.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Permanently deletes a post by ID; it cannot be restored. Prefer Unpublish Post to take a post off the site. A retry fails with not found.',+ idempotent: false,+ },+ props: {+ post_id: ghostProps.id('Post ID', 'The post ID, from List Posts.'),+ },+ async run(context) {+ const post_id = context.propsValue.post_id.trim();+ await ghostContent.remove(context.auth, 'posts', ghostCommon.id(post_id, 'Post ID'));+ return { success: true, post_id };+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/delete-tag.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/delete-tag.tsnew file mode 100644index 00000000000..b012a33a32d--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/delete-tag.ts@@ -0,0 +1,29 @@+import { createAction } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { ghostCommon } from '../../common/client';+import { ghostResource } from '../../common/resources';+import { ghostDeleteTagOutputSchema } from '../../output-schemas';++export const ghostDeleteTag = createAction({+ auth: ghostAuth,+ name: 'ghost_delete_tag',+ outputSchema: ghostDeleteTagOutputSchema,+ classification: 'DESTRUCTIVE',+ displayName: 'Delete Tag',+ description: 'Permanently delete a tag.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Permanently deletes a tag and removes it from every post that has it; the posts themselves stay. It cannot be restored, and a retry fails with not found.',+ idempotent: false,+ },+ props: {+ tag_id: ghostProps.id('Tag ID', 'The tag ID, from List Tags.'),+ },+ async run(context) {+ const tag_id = context.propsValue.tag_id.trim();+ await ghostResource.remove(context.auth, 'tags', ghostCommon.id(tag_id, 'Tag ID'));+ return { success: true, tag_id };+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/get-label.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/get-label.tsnew file mode 100644index 00000000000..a1676b1e9fe--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/get-label.ts@@ -0,0 +1,28 @@+import { createAction } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { ghostCommon } from '../../common/client';+import { ghostResource } from '../../common/resources';+import { ghostLabelOutputSchema } from '../../output-schemas';++export const ghostGetLabel = createAction({+ auth: ghostAuth,+ name: 'ghost_get_label',+ outputSchema: ghostLabelOutputSchema,+ classification: 'READ',+ displayName: 'Get Label',+ description: 'Get a member label by ID.',+ audience: 'ai',+ aiMetadata: {+ description: 'Returns one member label by ID with its name, slug and member count.',+ idempotent: true,+ },+ props: {+ label_id: ghostProps.id('Label ID', 'The label ID, from List Labels.'),+ },+ async run(context) {+ return ghostResource.get(context.auth, 'labels', ghostCommon.id(context.propsValue.label_id, 'Label ID'), {+ include: 'count.members',+ });+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/get-member-by-email.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/get-member-by-email.tsnew file mode 100644index 00000000000..678ed8c27ba--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/get-member-by-email.ts@@ -0,0 +1,41 @@+import { HttpMethod } from '@activepieces/pieces-common';+import { createAction, Property } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostClient, ghostCommon } from '../../common/client';+import { ghostGetMemberByEmailOutputSchema } from '../../output-schemas';++export const ghostGetMemberByEmail = createAction({+ auth: ghostAuth,+ name: 'ghost_get_member_by_email',+ outputSchema: ghostGetMemberByEmailOutputSchema,+ classification: 'READ',+ displayName: 'Get Member by Email',+ description: 'Find a member by exact email address.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Looks up a member by exact email address and returns found true with the member, or found false when no member has that email. Use it to check whether someone is already a member before Create Member.',+ idempotent: true,+ },+ props: {+ email: Property.ShortText({+ displayName: 'Email',+ description: 'The member email address.',+ required: true,+ }),+ },+ async run(context) {+ const email = context.propsValue.email.trim();+ if (!email) {+ throw new Error('Email is required.');+ }+ const response = await ghostClient.request<{ members?: Record<string, unknown>[] }>({+ auth: context.auth,+ method: HttpMethod.GET,+ path: '/members',+ query: { filter: `email:${ghostCommon.nqlString(email)}`, limit: 1 },+ });+ const member = response.members?.[0] ?? null;+ return { found: member !== null, member };+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/get-member-stats.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/get-member-stats.tsnew file mode 100644index 00000000000..8aa28728db4--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/get-member-stats.ts@@ -0,0 +1,53 @@+import { HttpMethod } from '@activepieces/pieces-common';+import { createAction } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostClient } from '../../common/client';+import { ghostMemberStatsOutputSchema } from '../../output-schemas';++type MemberCount = {+ date: string;+ paid: number;+ free: number;+ comped: number;+ gift?: number;+};++export const ghostGetMemberStats = createAction({+ auth: ghostAuth,+ name: 'ghost_get_member_stats',+ outputSchema: ghostMemberStatsOutputSchema,+ classification: 'READ',+ displayName: 'Get Member Stats',+ description: 'Get the current member totals (free, paid, comped) and the daily history.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Returns how many members the publication has right now, split into free, paid, comped and gift, plus one row per day with the counts on that day. Use it to answer growth questions; use List Members to see who the members are.',+ idempotent: true,+ },+ props: {},+ async run(context) {+ const response = await ghostClient.request<{ total?: number; data?: MemberCount[] }>({+ auth: context.auth,+ method: HttpMethod.GET,+ path: '/members/stats/count',+ });+ const history = (response.data ?? []).map((day) => ({+ date: day.date,+ free: day.free ?? 0,+ paid: day.paid ?? 0,+ comped: day.comped ?? 0,+ gift: day.gift ?? 0,+ }));+ const latest = history[history.length - 1];+ return {+ total: response.total ?? 0,+ free: latest?.free ?? 0,+ paid: latest?.paid ?? 0,+ comped: latest?.comped ?? 0,+ gift: latest?.gift ?? 0,+ as_of: latest?.date ?? null,+ history,+ };+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/get-member.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/get-member.tsnew file mode 100644index 00000000000..5c607069622--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/get-member.ts@@ -0,0 +1,27 @@+import { createAction } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { ghostCommon } from '../../common/client';+import { ghostResource } from '../../common/resources';+import { ghostMemberOutputSchema } from '../../output-schemas';++export const ghostGetMember = createAction({+ auth: ghostAuth,+ name: 'ghost_get_member',+ outputSchema: ghostMemberOutputSchema,+ classification: 'READ',+ displayName: 'Get Member',+ description: 'Get a member by ID.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Returns one member by ID with labels, newsletter subscriptions, tiers and paid status. Use Get Member by Email when only the email is known.',+ idempotent: true,+ },+ props: {+ member_id: ghostProps.id('Member ID', 'The member ID, from List Members or Get Member by Email.'),+ },+ async run(context) {+ return ghostResource.get(context.auth, 'members', ghostCommon.id(context.propsValue.member_id, 'Member ID'));+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/get-newsletter.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/get-newsletter.tsnew file mode 100644index 00000000000..8d1161dc7c4--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/get-newsletter.ts@@ -0,0 +1,30 @@+import { createAction } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { ghostCommon } from '../../common/client';+import { ghostResource } from '../../common/resources';+import { ghostNewsletterOutputSchema } from '../../output-schemas';++export const ghostGetNewsletter = createAction({+ auth: ghostAuth,+ name: 'ghost_get_newsletter',+ outputSchema: ghostNewsletterOutputSchema,+ classification: 'READ',+ displayName: 'Get Newsletter',+ description: 'Get a newsletter by ID.',+ audience: 'ai',+ aiMetadata: {+ description: 'Returns one newsletter by ID with its slug, status, sender and design settings.',+ idempotent: true,+ },+ props: {+ newsletter_id: ghostProps.id('Newsletter ID', 'The newsletter ID, from List Newsletters.'),+ },+ async run(context) {+ return ghostResource.get(+ context.auth,+ 'newsletters',+ ghostCommon.id(context.propsValue.newsletter_id, 'Newsletter ID')+ );+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/get-offer.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/get-offer.tsnew file mode 100644index 00000000000..e50729689bf--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/get-offer.ts@@ -0,0 +1,26 @@+import { createAction } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { ghostCommon } from '../../common/client';+import { ghostResource } from '../../common/resources';+import { ghostOfferOutputSchema } from '../../output-schemas';++export const ghostGetOffer = createAction({+ auth: ghostAuth,+ name: 'ghost_get_offer',+ outputSchema: ghostOfferOutputSchema,+ classification: 'READ',+ displayName: 'Get Offer',+ description: 'Get an offer by ID.',+ audience: 'ai',+ aiMetadata: {+ description: 'Returns one offer by ID with its code, discount type and amount, duration, cadence, tier and redemption count.',+ idempotent: true,+ },+ props: {+ offer_id: ghostProps.id('Offer ID', 'The offer ID, from List Offers.'),+ },+ async run(context) {+ return ghostResource.get(context.auth, 'offers', ghostCommon.id(context.propsValue.offer_id, 'Offer ID'));+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/get-page-by-slug.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/get-page-by-slug.tsnew file mode 100644index 00000000000..8bcbaa3db83--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/get-page-by-slug.ts@@ -0,0 +1,27 @@+import { createAction } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { ghostCommon } from '../../common/client';+import { ghostContent } from '../../common/content';+import { ghostPageOutputSchema } from '../../output-schemas';++export const ghostGetPageBySlug = createAction({+ auth: ghostAuth,+ name: 'ghost_get_page_by_slug',+ outputSchema: ghostPageOutputSchema,+ classification: 'READ',+ displayName: 'Get Page by Slug',+ description: 'Get a page by its URL slug.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Returns one static page by its slug, the last part of its URL, with its HTML body. Use Get Page when the ID is known.',+ idempotent: true,+ },+ props: {+ slug: ghostProps.slug('The page slug, e.g. "about" for https://example.com/about/.'),+ },+ async run(context) {+ return ghostContent.get(context.auth, 'pages', `slug/${ghostCommon.id(context.propsValue.slug, 'Slug')}`);+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/get-page.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/get-page.tsnew file mode 100644index 00000000000..d9012df403d--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/get-page.ts@@ -0,0 +1,27 @@+import { createAction } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { ghostCommon } from '../../common/client';+import { ghostContent } from '../../common/content';+import { ghostPageOutputSchema } from '../../output-schemas';++export const ghostGetPage = createAction({+ auth: ghostAuth,+ name: 'ghost_get_page',+ outputSchema: ghostPageOutputSchema,+ classification: 'READ',+ displayName: 'Get Page',+ description: 'Get a page by ID, including its HTML content.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Returns one static page by ID with its HTML body, tags, authors, status and URL. Use Get Page by Slug when only the slug is known.',+ idempotent: true,+ },+ props: {+ page_id: ghostProps.id('Page ID', 'The page ID, from List Pages.'),+ },+ async run(context) {+ return ghostContent.get(context.auth, 'pages', ghostCommon.id(context.propsValue.page_id, 'Page ID'));+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/get-post-by-slug.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/get-post-by-slug.tsnew file mode 100644index 00000000000..fd4c9fa05b2--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/get-post-by-slug.ts@@ -0,0 +1,27 @@+import { createAction } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { ghostCommon } from '../../common/client';+import { ghostContent } from '../../common/content';+import { ghostPostOutputSchema } from '../../output-schemas';++export const ghostGetPostBySlug = createAction({+ auth: ghostAuth,+ name: 'ghost_get_post_by_slug',+ outputSchema: ghostPostOutputSchema,+ classification: 'READ',+ displayName: 'Get Post by Slug',+ description: 'Get a post by its URL slug.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Returns one post by its slug, the last part of the post URL, with its HTML body, tags and authors. Use Get Post when the ID is known.',+ idempotent: true,+ },+ props: {+ slug: ghostProps.slug('The post slug, e.g. "welcome" for https://example.com/welcome/.'),+ },+ async run(context) {+ return ghostContent.get(context.auth, 'posts', `slug/${ghostCommon.id(context.propsValue.slug, 'Slug')}`);+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/get-post.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/get-post.tsnew file mode 100644index 00000000000..fbc5e70ecc3--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/get-post.ts@@ -0,0 +1,27 @@+import { createAction } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { ghostCommon } from '../../common/client';+import { ghostContent } from '../../common/content';+import { ghostPostOutputSchema } from '../../output-schemas';++export const ghostGetPost = createAction({+ auth: ghostAuth,+ name: 'ghost_get_post',+ outputSchema: ghostPostOutputSchema,+ classification: 'READ',+ displayName: 'Get Post',+ description: 'Get a post by ID, including its HTML content.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Returns one post by ID with its HTML body, tags, authors, status and URL. Use Get Post by Slug when only the slug is known, or List Posts to find the ID.',+ idempotent: true,+ },+ props: {+ post_id: ghostProps.id('Post ID', 'The post ID, from List Posts.'),+ },+ async run(context) {+ return ghostContent.get(context.auth, 'posts', ghostCommon.id(context.propsValue.post_id, 'Post ID'));+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/get-settings.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/get-settings.tsnew file mode 100644index 00000000000..efe91cad446--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/get-settings.ts@@ -0,0 +1,97 @@+import { HttpMethod } from '@activepieces/pieces-common';+import { createAction } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostClient } from '../../common/client';+import { ghostSettingsOutputSchema } from '../../output-schemas';++const PUBLIC_SETTING_KEYS = [+ 'title',+ 'description',+ 'logo',+ 'cover_image',+ 'icon',+ 'accent_color',+ 'locale',+ 'timezone',+ 'meta_title',+ 'meta_description',+ 'og_image',+ 'og_title',+ 'og_description',+ 'twitter_image',+ 'twitter_title',+ 'twitter_description',+ 'facebook',+ 'twitter',+ 'navigation',+ 'secondary_navigation',+ 'active_theme',+ 'is_private',+ 'default_content_visibility',+ 'members_enabled',+ 'members_invite_only',+ 'members_signup_access',+ 'members_support_address',+ 'paid_members_enabled',+ 'portal_name',+ 'portal_plans',+ 'portal_default_plan',+ 'comments_enabled',+ 'recommendations_enabled',+ 'email_track_opens',+ 'email_track_clicks',+ 'donations_enabled',+ 'donations_currency',+ 'donations_suggested_amount',+ 'editor_default_email_recipients',+ 'default_email_address',+ 'support_email_address',+] as const;++const parseValue = (value: unknown): unknown => {+ if (typeof value !== 'string') {+ return value ?? null;+ }+ const text = value.trim();+ if (text.startsWith('[') || text.startsWith('{')) {+ try {+ return JSON.parse(text);+ } catch {+ return value;+ }+ }+ return value;+};++export const ghostGetSettings = createAction({+ auth: ghostAuth,+ name: 'ghost_get_settings',+ outputSchema: ghostSettingsOutputSchema,+ classification: 'READ',+ displayName: 'Get Settings',+ description: 'Get the publication settings: branding, SEO, navigation, timezone and membership options.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Returns the publication settings an editor needs: title, description, branding images, accent color, locale and timezone, SEO and social meta, navigation menus, active theme, and membership, portal, comments and email-tracking options. Secrets such as Stripe or Mailgun keys and the site password are never returned. Use Get Site for the Ghost version and URL.',+ idempotent: true,+ },+ props: {},+ async run(context) {+ const response = await ghostClient.request<{+ settings?: { key: string; value: unknown }[];+ }>({+ auth: context.auth,+ method: HttpMethod.GET,+ path: '/settings',+ });+ const byKey = new Map((response.settings ?? []).map((setting) => [setting.key, setting.value]));+ const result: Record<string, unknown> = {};+ for (const key of PUBLIC_SETTING_KEYS) {+ if (byKey.has(key)) {+ result[key] = parseValue(byKey.get(key));+ }+ }+ return result;+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/get-site.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/get-site.tsnew file mode 100644index 00000000000..7cdd89df149--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/get-site.ts@@ -0,0 +1,29 @@+import { HttpMethod } from '@activepieces/pieces-common';+import { createAction } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostClient } from '../../common/client';+import { ghostSiteOutputSchema } from '../../output-schemas';++export const ghostGetSite = createAction({+ auth: ghostAuth,+ name: 'ghost_get_site',+ outputSchema: ghostSiteOutputSchema,+ classification: 'READ',+ displayName: 'Get Site',+ description: 'Get the site title, URL and Ghost version.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Returns basic site information: title, description, public URL, logo, icon, accent color and Ghost version. Use it to confirm which publication the connection points at.',+ idempotent: true,+ },+ props: {},+ async run(context) {+ const response = await ghostClient.request<{ site: Record<string, unknown> }>({+ auth: context.auth,+ method: HttpMethod.GET,+ path: '/site',+ });+ return response.site;+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/get-tag-by-slug.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/get-tag-by-slug.tsnew file mode 100644index 00000000000..d4eef683d0c--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/get-tag-by-slug.ts@@ -0,0 +1,29 @@+import { createAction } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { ghostCommon } from '../../common/client';+import { ghostResource } from '../../common/resources';+import { ghostTagOutputSchema } from '../../output-schemas';++export const ghostGetTagBySlug = createAction({+ auth: ghostAuth,+ name: 'ghost_get_tag_by_slug',+ outputSchema: ghostTagOutputSchema,+ classification: 'READ',+ displayName: 'Get Tag by Slug',+ description: 'Get a tag by its slug.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Returns one tag by its slug, e.g. "news" from /tag/news/, with its post count. Use Get Tag when the ID is known.',+ idempotent: true,+ },+ props: {+ slug: ghostProps.slug('The tag slug, e.g. "news".'),+ },+ async run(context) {+ return ghostResource.get(context.auth, 'tags', `slug/${ghostCommon.id(context.propsValue.slug, 'Slug')}`, {+ include: 'count.posts',+ });+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/get-tag.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/get-tag.tsnew file mode 100644index 00000000000..6ef1d066025--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/get-tag.ts@@ -0,0 +1,29 @@+import { createAction } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { ghostCommon } from '../../common/client';+import { ghostResource } from '../../common/resources';+import { ghostTagOutputSchema } from '../../output-schemas';++export const ghostGetTag = createAction({+ auth: ghostAuth,+ name: 'ghost_get_tag',+ outputSchema: ghostTagOutputSchema,+ classification: 'READ',+ displayName: 'Get Tag',+ description: 'Get a tag by ID.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Returns one tag by ID with its description, visibility and post count. Use Get Tag by Slug when only the slug is known.',+ idempotent: true,+ },+ props: {+ tag_id: ghostProps.id('Tag ID', 'The tag ID, from List Tags.'),+ },+ async run(context) {+ return ghostResource.get(context.auth, 'tags', ghostCommon.id(context.propsValue.tag_id, 'Tag ID'), {+ include: 'count.posts',+ });+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/get-tier.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/get-tier.tsnew file mode 100644index 00000000000..00dfc8f526a--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/get-tier.ts@@ -0,0 +1,27 @@+import { createAction } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { ghostCommon } from '../../common/client';+import { ghostResource } from '../../common/resources';+import { TIER_QUERY } from '../../common/tier-props';+import { ghostTierOutputSchema } from '../../output-schemas';++export const ghostGetTier = createAction({+ auth: ghostAuth,+ name: 'ghost_get_tier',+ outputSchema: ghostTierOutputSchema,+ classification: 'READ',+ displayName: 'Get Tier',+ description: 'Get a membership tier by ID.',+ audience: 'ai',+ aiMetadata: {+ description: 'Returns one membership tier by ID with its prices, currency, benefits, visibility and active state.',+ idempotent: true,+ },+ props: {+ tier_id: ghostProps.id('Tier ID', 'The tier ID, from List Tiers.'),+ },+ async run(context) {+ return ghostResource.get(context.auth, 'tiers', ghostCommon.id(context.propsValue.tier_id, 'Tier ID'), TIER_QUERY);+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/get-user-by-email.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/get-user-by-email.tsnew file mode 100644index 00000000000..ece1d141c97--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/get-user-by-email.ts@@ -0,0 +1,44 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { GhostApiError } from '../../common/client';+import { ghostResource } from '../../common/resources';+import { ghostGetUserByEmailOutputSchema } from '../../output-schemas';++export const ghostGetUserByEmail = createAction({+ auth: ghostAuth,+ name: 'ghost_get_user_by_email',+ outputSchema: ghostGetUserByEmailOutputSchema,+ classification: 'READ',+ displayName: 'Get User by Email',+ description: 'Find a staff user by exact email address.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Looks up a staff user (not a member) by exact email and returns found true with the user, or found false. Use Get Member by Email for members.',+ idempotent: true,+ },+ props: {+ email: Property.ShortText({+ displayName: 'Email',+ description: 'The staff user email address.',+ required: true,+ }),+ },+ async run(context) {+ const email = context.propsValue.email.trim();+ if (!email) {+ throw new Error('Email is required.');+ }+ try {+ const user = await ghostResource.get(context.auth, 'users', `email/${encodeURIComponent(email)}`, {+ include: 'roles,count.posts',+ });+ return { found: true, user };+ } catch (error) {+ if (error instanceof GhostApiError && error.status === 404) {+ return { found: false, user: null };+ }+ throw error;+ }+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/get-user.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/get-user.tsnew file mode 100644index 00000000000..3c26f5376cc--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/get-user.ts@@ -0,0 +1,28 @@+import { createAction } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { ghostCommon } from '../../common/client';+import { ghostResource } from '../../common/resources';+import { ghostUserOutputSchema } from '../../output-schemas';++export const ghostGetUser = createAction({+ auth: ghostAuth,+ name: 'ghost_get_user',+ outputSchema: ghostUserOutputSchema,+ classification: 'READ',+ displayName: 'Get User',+ description: 'Get a staff user by ID.',+ audience: 'ai',+ aiMetadata: {+ description: 'Returns one staff user by ID with their name, email, slug, bio, roles and post count.',+ idempotent: true,+ },+ props: {+ user_id: ghostProps.id('User ID', 'The staff user ID, from List Users.'),+ },+ async run(context) {+ return ghostResource.get(context.auth, 'users', ghostCommon.id(context.propsValue.user_id, 'User ID'), {+ include: 'roles,count.posts',+ });+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/list-labels.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/list-labels.tsnew file mode 100644index 00000000000..65978084244--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/list-labels.ts@@ -0,0 +1,33 @@+import { createAction } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { ghostCommon } from '../../common/client';+import { ghostResource } from '../../common/resources';+import { ghostListLabelsOutputSchema } from '../../output-schemas';++export const ghostListLabels = createAction({+ auth: ghostAuth,+ name: 'ghost_list_labels',+ outputSchema: ghostListLabelsOutputSchema,+ classification: 'SEARCH',+ displayName: 'List Labels',+ description: 'List member labels.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Lists member labels (not post tags) with member counts and pagination totals. Use it to find the label ID that Add Member Label and Remove Member Label need.',+ idempotent: true,+ },+ props: {+ filter: ghostProps.filter("name:~'vip'"),+ limit: ghostProps.limit,+ page: ghostProps.page,+ order: ghostProps.order('name asc'),+ },+ async run(context) {+ return ghostResource.list(context.auth, 'labels', {+ ...ghostCommon.listQuery(context.propsValue),+ include: 'count.members',+ });+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/list-member-activity.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/list-member-activity.tsnew file mode 100644index 00000000000..50f578a6793--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/list-member-activity.ts@@ -0,0 +1,101 @@+import { HttpMethod } from '@activepieces/pieces-common';+import { createAction, Property } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { ghostClient, ghostCommon } from '../../common/client';+import { ghostListMemberActivityOutputSchema } from '../../output-schemas';++type MemberEvent = {+ type: string;+ data: Record<string, unknown> & {+ id?: string;+ member_id?: string;+ created_at?: string;+ member?: { id?: string; name?: string | null; email?: string };+ };+};++export const ghostListMemberActivity = createAction({+ auth: ghostAuth,+ name: 'ghost_list_member_activity',+ outputSchema: ghostListMemberActivityOutputSchema,+ classification: 'SEARCH',+ displayName: 'List Member Activity',+ description: 'List member activity events such as signups, logins, newsletter changes, email opens and payments.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Returns the newest member activity events, newest first: signups, logins, newsletter subscribe/unsubscribe, email deliveries, opens and clicks, comments, feedback, donations, email address changes and paid subscription changes. Give a Member ID for one member\'s timeline, an Event Type to narrow it, or an NQL filter for anything else. Page back by filtering on data.created_at older than the last event returned.',+ idempotent: true,+ },+ props: {+ memberId: Property.ShortText({+ displayName: 'Member ID',+ description: 'Only return events for this member. Get the ID from List Members or Get Member by Email.',+ required: false,+ }),+ eventType: Property.StaticDropdown({+ displayName: 'Event Type',+ description: 'Only return this kind of event.',+ required: false,+ options: {+ options: [+ { label: 'Signup', value: 'signup_event' },+ { label: 'Login', value: 'login_event' },+ { label: 'Newsletter subscribe or unsubscribe', value: 'newsletter_event' },+ { label: 'Email delivered', value: 'email_delivered_event' },+ { label: 'Email opened', value: 'email_opened_event' },+ { label: 'Email link clicked', value: 'click_event' },+ { label: 'Email failed', value: 'email_failed_event' },+ { label: 'Comment', value: 'comment_event' },+ { label: 'Feedback', value: 'feedback_event' },+ { label: 'Paid subscription change', value: 'subscription_event' },+ { label: 'Payment', value: 'payment_event' },+ { label: 'Email address change', value: 'email_change_event' },+ { label: 'Donation', value: 'donation_event' },+ ],+ },+ }),+ filter: ghostProps.filter("data.created_at:<'2026-01-01 00:00:00'"),+ limit: ghostProps.limit,+ },+ async run(context) {+ const { memberId, eventType, filter, limit } = context.propsValue;+ const parts: string[] = [];+ if (ghostCommon.hasText(memberId)) {+ parts.push(`data.member_id:${ghostCommon.nqlString(memberId.trim())}`);+ }+ if (ghostCommon.hasText(eventType)) {+ parts.push(`type:${eventType}`);+ }+ if (ghostCommon.hasText(filter)) {+ parts.push(`(${filter.trim()})`);+ }+ const response = await ghostClient.request<{ events?: MemberEvent[]; meta?: unknown }>({+ auth: context.auth,+ method: HttpMethod.GET,+ path: '/members/events',+ query: {+ filter: parts.length > 0 ? parts.join('+') : undefined,+ limit: ghostCommon.listQuery({ limit })['limit'],+ },+ });+ const events = (response.events ?? []).map((event) => {+ const { member, ...data } = event.data ?? {};+ return {+ type: event.type,+ id: data.id ?? null,+ created_at: data.created_at ?? null,+ member_id: data.member_id ?? member?.id ?? null,+ member_name: member?.name ?? null,+ member_email: member?.email ?? null,+ data,+ };+ });+ return {+ events,+ count: events.length,+ total: ghostCommon.pagination(response.meta).total,+ };+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/list-members.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/list-members.tsnew file mode 100644index 00000000000..f5bf30b4972--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/list-members.ts@@ -0,0 +1,38 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { ghostCommon } from '../../common/client';+import { ghostResource } from '../../common/resources';+import { ghostListMembersOutputSchema } from '../../output-schemas';++export const ghostListMembers = createAction({+ auth: ghostAuth,+ name: 'ghost_list_members',+ outputSchema: ghostListMembersOutputSchema,+ classification: 'SEARCH',+ displayName: 'List Members',+ description: 'List or search members.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Lists members with their labels, newsletters and status and pagination totals. Narrow with an NQL filter (status:paid, label:vip, subscribed:true) or a free-text Search on name and email. Use Get Member by Email for an exact email.',+ idempotent: true,+ },+ props: {+ filter: ghostProps.filter('status:paid+label:vip'),+ search: Property.ShortText({+ displayName: 'Search',+ description: 'Free-text search on member name and email.',+ required: false,+ }),+ limit: ghostProps.limit,+ page: ghostProps.page,+ order: ghostProps.order('created_at desc'),+ },+ async run(context) {+ return ghostResource.list(context.auth, 'members', {+ ...ghostCommon.listQuery(context.propsValue),+ search: context.propsValue.search?.trim(),+ });+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/list-newsletters.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/list-newsletters.tsnew file mode 100644index 00000000000..38239871b45--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/list-newsletters.ts@@ -0,0 +1,30 @@+import { createAction } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { ghostCommon } from '../../common/client';+import { ghostResource } from '../../common/resources';+import { ghostListNewslettersOutputSchema } from '../../output-schemas';++export const ghostListNewsletters = createAction({+ auth: ghostAuth,+ name: 'ghost_list_newsletters',+ outputSchema: ghostListNewslettersOutputSchema,+ classification: 'SEARCH',+ displayName: 'List Newsletters',+ description: 'List the newsletters of the publication.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Lists newsletters with their ID, slug, status and settings. The slug is what Publish Post and Schedule Post need to email a post, and the ID is what the member subscribe actions need. Filter status:active to hide archived ones.',+ idempotent: true,+ },+ props: {+ filter: ghostProps.filter('status:active'),+ limit: ghostProps.limit,+ page: ghostProps.page,+ order: ghostProps.order('sort_order asc'),+ },+ async run(context) {+ return ghostResource.list(context.auth, 'newsletters', ghostCommon.listQuery(context.propsValue));+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/list-offers.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/list-offers.tsnew file mode 100644index 00000000000..e1149eb11ac--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/list-offers.ts@@ -0,0 +1,26 @@+import { createAction } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { ghostResource } from '../../common/resources';+import { ghostListOffersOutputSchema } from '../../output-schemas';++export const ghostListOffers = createAction({+ auth: ghostAuth,+ name: 'ghost_list_offers',+ outputSchema: ghostListOffersOutputSchema,+ classification: 'SEARCH',+ displayName: 'List Offers',+ description: 'List discount and trial offers.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Lists all discount and free-trial offers with their code, discount, duration, tier and status in one call; Ghost does not paginate offers. Filter status:active to hide archived ones.',+ idempotent: true,+ },+ props: {+ filter: ghostProps.filter('status:active'),+ },+ async run(context) {+ return ghostResource.list(context.auth, 'offers', { filter: context.propsValue.filter?.trim() }, false);+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/list-pages.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/list-pages.tsnew file mode 100644index 00000000000..a6bb0111e50--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/list-pages.ts@@ -0,0 +1,35 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { ghostContent } from '../../common/content';+import { ghostListPagesOutputSchema } from '../../output-schemas';++export const ghostListPages = createAction({+ auth: ghostAuth,+ name: 'ghost_list_pages',+ outputSchema: ghostListPagesOutputSchema,+ classification: 'SEARCH',+ displayName: 'List Pages',+ description: 'List or search pages with an optional filter.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Lists static pages (not posts) of any status with pagination totals, optionally narrowed by an NQL filter. Use it to find a page ID or slug; use Get Page for the full HTML.',+ idempotent: true,+ },+ props: {+ filter: ghostProps.filter("status:published or title:~'about'"),+ limit: ghostProps.limit,+ page: ghostProps.page,+ order: ghostProps.order('updated_at desc'),+ include_content: Property.Checkbox({+ displayName: 'Include Content',+ description: 'Return the HTML body of each page. Off by default to keep the result small.',+ required: false,+ defaultValue: false,+ }),+ },+ async run(context) {+ return ghostContent.list(context.auth, 'pages', context.propsValue);+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/list-posts.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/list-posts.tsnew file mode 100644index 00000000000..d1473318169--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/list-posts.ts@@ -0,0 +1,35 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { ghostContent } from '../../common/content';+import { ghostListPostsOutputSchema } from '../../output-schemas';++export const ghostListPosts = createAction({+ auth: ghostAuth,+ name: 'ghost_list_posts',+ outputSchema: ghostListPostsOutputSchema,+ classification: 'SEARCH',+ displayName: 'List Posts',+ description: 'List or search posts with an optional filter.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Lists posts of any status with pagination totals, optionally narrowed by an NQL filter such as status:draft or tag:news. Use it to find a post ID or slug; use Get Post for one post with its full HTML.',+ idempotent: true,+ },+ props: {+ filter: ghostProps.filter("status:published+tag:news or title:~'launch'"),+ limit: ghostProps.limit,+ page: ghostProps.page,+ order: ghostProps.order('published_at desc'),+ include_content: Property.Checkbox({+ displayName: 'Include Content',+ description: 'Return the HTML body of each post. Off by default to keep the result small.',+ required: false,+ defaultValue: false,+ }),+ },+ async run(context) {+ return ghostContent.list(context.auth, 'posts', context.propsValue);+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/list-tags.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/list-tags.tsnew file mode 100644index 00000000000..4400331b133--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/list-tags.ts@@ -0,0 +1,33 @@+import { createAction } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { ghostCommon } from '../../common/client';+import { ghostResource } from '../../common/resources';+import { ghostListTagsOutputSchema } from '../../output-schemas';++export const ghostListTags = createAction({+ auth: ghostAuth,+ name: 'ghost_list_tags',+ outputSchema: ghostListTagsOutputSchema,+ classification: 'SEARCH',+ displayName: 'List Tags',+ description: 'List or search post tags.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Lists post tags with their post counts and pagination totals, optionally narrowed by an NQL filter such as visibility:public. Use it to find a tag ID or slug.',+ idempotent: true,+ },+ props: {+ filter: ghostProps.filter("visibility:public or name:~'news'"),+ limit: ghostProps.limit,+ page: ghostProps.page,+ order: ghostProps.order('name asc'),+ },+ async run(context) {+ return ghostResource.list(context.auth, 'tags', {+ ...ghostCommon.listQuery(context.propsValue),+ include: 'count.posts',+ });+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/list-tiers.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/list-tiers.tsnew file mode 100644index 00000000000..5992de29da4--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/list-tiers.ts@@ -0,0 +1,34 @@+import { createAction } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { ghostCommon } from '../../common/client';+import { ghostResource } from '../../common/resources';+import { TIER_QUERY } from '../../common/tier-props';+import { ghostListTiersOutputSchema } from '../../output-schemas';++export const ghostListTiers = createAction({+ auth: ghostAuth,+ name: 'ghost_list_tiers',+ outputSchema: ghostListTiersOutputSchema,+ classification: 'SEARCH',+ displayName: 'List Tiers',+ description: 'List membership tiers with prices and benefits.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Lists membership tiers (the free tier and paid tiers) with prices, benefits and active state. Filter type:paid+active:true for sellable paid tiers. The tier ID is what Create Offer needs.',+ idempotent: true,+ },+ props: {+ filter: ghostProps.filter('type:paid+active:true'),+ limit: ghostProps.limit,+ page: ghostProps.page,+ order: ghostProps.order('monthly_price asc'),+ },+ async run(context) {+ return ghostResource.list(context.auth, 'tiers', {+ ...ghostCommon.listQuery(context.propsValue),+ ...TIER_QUERY,+ });+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/list-users.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/list-users.tsnew file mode 100644index 00000000000..13dd2693b5b--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/list-users.ts@@ -0,0 +1,33 @@+import { createAction } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { ghostCommon } from '../../common/client';+import { ghostResource } from '../../common/resources';+import { ghostListUsersOutputSchema } from '../../output-schemas';++export const ghostListUsers = createAction({+ auth: ghostAuth,+ name: 'ghost_list_users',+ outputSchema: ghostListUsersOutputSchema,+ classification: 'SEARCH',+ displayName: 'List Users',+ description: 'List staff users such as authors and editors.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Lists staff users (owner, admins, editors, authors, contributors), not members, with their roles and post counts. Use it to find the author IDs that Create Post and Update Post accept.',+ idempotent: true,+ },+ props: {+ filter: ghostProps.filter('status:active'),+ limit: ghostProps.limit,+ page: ghostProps.page,+ order: ghostProps.order('name asc'),+ },+ async run(context) {+ return ghostResource.list(context.auth, 'users', {+ ...ghostCommon.listQuery(context.propsValue),+ include: 'roles,count.posts',+ });+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/publish-post.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/publish-post.tsnew file mode 100644index 00000000000..1b6f40b065a--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/publish-post.ts@@ -0,0 +1,43 @@+import { createAction } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { ghostCommon } from '../../common/client';+import { ghostContent } from '../../common/content';+import { ghostPublishPostOutputSchema } from '../../output-schemas';++export const ghostPublishPost = createAction({+ auth: ghostAuth,+ name: 'ghost_publish_post',+ outputSchema: ghostPublishPostOutputSchema,+ classification: 'WRITE',+ displayName: 'Publish Post',+ description: 'Publish a draft post now, optionally emailing it to a newsletter.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Publishes a post immediately. With Newsletter Slug it also emails the post to that newsletter (all members, or Email Segment), and Email Only sends the email without putting it on the site. An email can only be sent once, so do not retry after success.',+ idempotent: false,+ },+ props: {+ post_id: ghostProps.id('Post ID', 'The post ID, from List Posts.'),+ newsletter: ghostProps.newsletterSlug,+ email_segment: ghostProps.emailSegment,+ email_only: ghostProps.emailOnly,+ },+ async run(context) {+ const { post_id, newsletter, email_segment, email_only } = context.propsValue;+ const id = ghostCommon.id(post_id, 'Post ID');+ const hasNewsletter = ghostCommon.hasText(newsletter);+ if (email_only && !hasNewsletter) {+ throw new Error('Email Only requires Newsletter Slug.');+ }+ const body: Record<string, unknown> = { status: 'published' };+ if (email_only) {+ body['email_only'] = true;+ }+ return ghostContent.edit(context.auth, 'posts', id, body, {+ newsletter: hasNewsletter ? newsletter.trim() : undefined,+ email_segment: hasNewsletter ? email_segment?.trim() || 'all' : undefined,+ });+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/remove-member-label.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/remove-member-label.tsnew file mode 100644index 00000000000..e92c199f826--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/remove-member-label.ts@@ -0,0 +1,32 @@+import { createAction } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { changeMemberLabel } from '../../common/member-labels';+import { ghostMemberOutputSchema } from '../../output-schemas';++export const ghostRemoveMemberLabel = createAction({+ auth: ghostAuth,+ name: 'ghost_remove_member_label',+ outputSchema: ghostMemberOutputSchema,+ classification: 'WRITE',+ displayName: 'Remove Member Label',+ description: 'Remove one label from a member, keeping their other labels.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Removes one label from a member without touching their other labels, and returns the updated member. The label itself is kept; use Delete Label to remove it everywhere. Removing a label the member does not have is a no-op.',+ idempotent: true,+ },+ props: {+ member_id: ghostProps.id('Member ID', 'The member ID, from List Members or Get Member by Email.'),+ label_id: ghostProps.id('Label ID', 'The label ID, from List Labels or Get Member.'),+ },+ async run(context) {+ return changeMemberLabel({+ auth: context.auth,+ memberId: context.propsValue.member_id,+ labelId: context.propsValue.label_id,+ action: 'removeLabel',+ });+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/schedule-post.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/schedule-post.tsnew file mode 100644index 00000000000..afc33723a7b--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/schedule-post.ts@@ -0,0 +1,51 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { ghostCommon } from '../../common/client';+import { ghostContent } from '../../common/content';+import { ghostPostOutputSchema } from '../../output-schemas';++export const ghostSchedulePost = createAction({+ auth: ghostAuth,+ name: 'ghost_schedule_post',+ outputSchema: ghostPostOutputSchema,+ classification: 'WRITE',+ displayName: 'Schedule Post',+ description: 'Schedule a draft post to publish at a future time.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Schedules a draft or already scheduled post to publish at a future Published At; Ghost rejects times in the past or only moments away. With Newsletter Slug the post is also emailed when it goes live. Use Unpublish Post to cancel.',+ idempotent: false,+ },+ props: {+ post_id: ghostProps.id('Post ID', 'The post ID, from List Posts.'),+ published_at: Property.DateTime({+ displayName: 'Published At',+ description: 'When to publish. Must be in the future.',+ required: true,+ }),+ newsletter: ghostProps.newsletterSlug,+ email_segment: ghostProps.emailSegment,+ email_only: ghostProps.emailOnly,+ },+ async run(context) {+ const { post_id, published_at, newsletter, email_segment, email_only } = context.propsValue;+ const id = ghostCommon.id(post_id, 'Post ID');+ const hasNewsletter = ghostCommon.hasText(newsletter);+ if (email_only && !hasNewsletter) {+ throw new Error('Email Only requires Newsletter Slug.');+ }+ const body: Record<string, unknown> = {+ status: 'scheduled',+ published_at: ghostCommon.futureDate(published_at, 'Published At'),+ };+ if (email_only) {+ body['email_only'] = true;+ }+ return ghostContent.edit(context.auth, 'posts', id, body, {+ newsletter: hasNewsletter ? newsletter.trim() : undefined,+ email_segment: hasNewsletter ? email_segment?.trim() || 'all' : undefined,+ });+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/subscribe-member-to-newsletters.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/subscribe-member-to-newsletters.tsnew file mode 100644index 00000000000..60e27a4c09b--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/subscribe-member-to-newsletters.ts@@ -0,0 +1,31 @@+import { createAction } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { ghostCommon } from '../../common/client';+import { currentNewsletterIds, requireIds, saveNewsletters } from '../../common/member-newsletters';+import { ghostMemberOutputSchema } from '../../output-schemas';++export const ghostSubscribeMemberToNewsletters = createAction({+ auth: ghostAuth,+ name: 'ghost_subscribe_member_to_newsletters',+ outputSchema: ghostMemberOutputSchema,+ classification: 'WRITE',+ displayName: 'Subscribe Member to Newsletters',+ description: 'Add newsletter subscriptions to a member, keeping existing ones.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Subscribes a member to one or more newsletters while keeping their current subscriptions, and returns the updated member. Newsletter IDs come from List Newsletters. Re-subscribing is a no-op. Ghost has no single-newsletter subscribe call, so this reads the member subscription list and saves it back in one step; a change to that member subscription list made in the same moment can be overwritten.',+ idempotent: true,+ },+ props: {+ member_id: ghostProps.id('Member ID', 'The member ID, from List Members or Get Member by Email.'),+ newsletter_ids: ghostProps.newsletterIds('Newsletter IDs', 'The newsletters to add, from List Newsletters.', true),+ },+ async run(context) {+ const id = ghostCommon.id(context.propsValue.member_id, 'Member ID');+ const add = requireIds(context.propsValue.newsletter_ids);+ const current = await currentNewsletterIds({ auth: context.auth, memberId: id });+ return saveNewsletters({ auth: context.auth, memberId: id, ids: Array.from(new Set([...current, ...add])) });+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/unpublish-post.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/unpublish-post.tsnew file mode 100644index 00000000000..32624b2b4a8--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/unpublish-post.ts@@ -0,0 +1,28 @@+import { createAction } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { ghostCommon } from '../../common/client';+import { ghostContent } from '../../common/content';+import { ghostPostOutputSchema } from '../../output-schemas';++export const ghostUnpublishPost = createAction({+ auth: ghostAuth,+ name: 'ghost_unpublish_post',+ outputSchema: ghostPostOutputSchema,+ classification: 'WRITE',+ displayName: 'Unpublish Post',+ description: 'Move a published or scheduled post back to draft.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Sets a published or scheduled post back to draft, which removes it from the site and cancels a pending scheduled publish and its email. An email that was already sent cannot be recalled. Safe to retry.',+ idempotent: true,+ },+ props: {+ post_id: ghostProps.id('Post ID', 'The post ID, from List Posts.'),+ },+ async run(context) {+ const id = ghostCommon.id(context.propsValue.post_id, 'Post ID');+ return ghostContent.edit(context.auth, 'posts', id, { status: 'draft' });+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/unsubscribe-member-from-newsletters.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/unsubscribe-member-from-newsletters.tsnew file mode 100644index 00000000000..3fc5cc78434--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/unsubscribe-member-from-newsletters.ts@@ -0,0 +1,48 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { ghostCommon } from '../../common/client';+import { requireIds, saveNewsletters, unsubscribeFromNewsletter } from '../../common/member-newsletters';+import { ghostResource } from '../../common/resources';+import { ghostMemberOutputSchema } from '../../output-schemas';++export const ghostUnsubscribeMemberFromNewsletters = createAction({+ auth: ghostAuth,+ name: 'ghost_unsubscribe_member_from_newsletters',+ outputSchema: ghostMemberOutputSchema,+ classification: 'DESTRUCTIVE',+ displayName: 'Unsubscribe Member from Newsletters',+ description: 'Remove newsletter subscriptions from a member.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Unsubscribes a member from the given newsletters, or from every newsletter when Unsubscribe from All is on, keeping the member account. Each newsletter is removed on its own in Ghost, so a subscription added to the member at the same time is never lost. Returns the updated member. Unsubscribing twice is a no-op.',+ idempotent: true,+ },+ props: {+ member_id: ghostProps.id('Member ID', 'The member ID, from List Members or Get Member by Email.'),+ newsletter_ids: ghostProps.newsletterIds(+ 'Newsletter IDs',+ 'The newsletters to remove, from Get Member or List Newsletters.',+ false+ ),+ unsubscribe_from_all: Property.Checkbox({+ displayName: 'Unsubscribe from All',+ description: 'Remove every newsletter subscription. Newsletter IDs are ignored when on.',+ required: false,+ defaultValue: false,+ }),+ },+ async run(context) {+ const id = ghostCommon.id(context.propsValue.member_id, 'Member ID');+ if (context.propsValue.unsubscribe_from_all === true) {+ return saveNewsletters({ auth: context.auth, memberId: id, ids: [] });+ }+ const remove = Array.from(new Set(requireIds(context.propsValue.newsletter_ids)));+ await ghostResource.get(context.auth, 'members', id);+ for (const newsletterId of remove) {+ await unsubscribeFromNewsletter({ auth: context.auth, memberId: id, newsletterId });+ }+ return ghostResource.get(context.auth, 'members', id);+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/update-label.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/update-label.tsnew file mode 100644index 00000000000..f82081ce8a9--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/update-label.ts@@ -0,0 +1,38 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { ghostCommon } from '../../common/client';+import { ghostResource } from '../../common/resources';+import { ghostCreateLabelOutputSchema } from '../../output-schemas';++export const ghostUpdateLabel = createAction({+ auth: ghostAuth,+ name: 'ghost_update_label',+ outputSchema: ghostCreateLabelOutputSchema,+ classification: 'WRITE',+ displayName: 'Update Label',+ description: 'Rename a member label.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Renames a member label by ID; members keep the label. Filters that reference the old label slug may stop matching.',+ idempotent: true,+ },+ props: {+ label_id: ghostProps.id('Label ID', 'The label ID, from List Labels.'),+ name: Property.ShortText({+ displayName: 'Name',+ description: 'The new label name.',+ required: false,+ }),+ slug: Property.ShortText({+ displayName: 'Slug',+ description: 'The new label slug.',+ required: false,+ }),+ },+ async run(context) {+ const id = ghostCommon.id(context.propsValue.label_id, 'Label ID');+ return ghostResource.edit(context.auth, 'labels', id, ghostResource.pick(context.propsValue, ['name', 'slug']));+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/update-member.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/update-member.tsnew file mode 100644index 00000000000..e5881e1da19--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/update-member.ts@@ -0,0 +1,71 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { applyClearFields, clearFieldsProp } from '../../common/clear-fields';+import { ghostCommon } from '../../common/client';+import { ghostResource } from '../../common/resources';+import { ghostMemberOutputSchema } from '../../output-schemas';++export const ghostUpdateMember = createAction({+ auth: ghostAuth,+ name: 'ghost_update_member',+ outputSchema: ghostMemberOutputSchema,+ classification: 'WRITE',+ displayName: 'Update Member',+ description: 'Update the details, labels or newsletters of a member.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Edits a member by ID; only the inputs you supply change, and Clear Fields blanks the name or note. Labels and Newsletter IDs replace the full list, and an empty list removes all of them; to add or remove one item use Add Member Label, Remove Member Label, Subscribe Member to Newsletters or Unsubscribe Member from Newsletters.',+ idempotent: true,+ },+ props: {+ member_id: ghostProps.id('Member ID', 'The member ID, from List Members or Get Member by Email.'),+ email: Property.ShortText({+ displayName: 'Email',+ description: 'The new email address.',+ required: false,+ }),+ name: Property.ShortText({+ displayName: 'Name',+ description: 'The new full name.',+ required: false,+ }),+ note: Property.LongText({+ displayName: 'Note',+ description: 'The new private staff note.',+ required: false,+ }),+ labels: Property.Array({+ displayName: 'Labels',+ description: 'The complete list of label names the member should have. Missing labels are created, and an empty list removes every label.',+ required: false,+ }),+ newsletter_ids: ghostProps.newsletterIds(+ 'Newsletter IDs',+ 'The complete list of newsletter IDs the member should be subscribed to. An empty list unsubscribes the member from every newsletter.',+ false+ ),+ clear_fields: clearFieldsProp([+ { label: 'Name', value: 'name' },+ { label: 'Note', value: 'note' },+ ]),+ },+ async run(context) {+ const { member_id, email, name, note, labels, newsletter_ids, clear_fields } = context.propsValue;+ const id = ghostCommon.id(member_id, 'Member ID');+ const body = applyClearFields({+ body: ghostResource.pick({ email, name, note }, ['email', 'name', 'note']),+ clear: clear_fields,+ allowed: ['name', 'note'],+ clearValue: '',+ });+ if (Array.isArray(labels)) {+ body['labels'] = (ghostCommon.stringList(labels) ?? []).map((label) => ({ name: label }));+ }+ if (Array.isArray(newsletter_ids)) {+ body['newsletters'] = (ghostCommon.stringList(newsletter_ids) ?? []).map((newsletterId) => ({ id: newsletterId }));+ }+ return ghostResource.edit(context.auth, 'members', id, body);+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/update-newsletter.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/update-newsletter.tsnew file mode 100644index 00000000000..d551976289f--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/update-newsletter.ts@@ -0,0 +1,45 @@+import { createAction } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { applyClearFields, clearFieldsProp } from '../../common/clear-fields';+import { ghostCommon } from '../../common/client';+import { NEWSLETTER_FIELDS, newsletterProps } from '../../common/newsletter-props';+import { ghostResource } from '../../common/resources';+import { ghostNewsletterOutputSchema } from '../../output-schemas';++export const ghostUpdateNewsletter = createAction({+ auth: ghostAuth,+ name: 'ghost_update_newsletter',+ outputSchema: ghostNewsletterOutputSchema,+ classification: 'WRITE',+ displayName: 'Update Newsletter',+ description: 'Update the name or settings of a newsletter.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Edits a newsletter by ID; only the inputs you supply change, and Clear Fields blanks the description or sender name. It cannot archive the newsletter (use Archive Newsletter) or change the sender email, which Ghost must verify by email first.',+ idempotent: true,+ },+ props: {+ newsletter_id: ghostProps.id('Newsletter ID', 'The newsletter ID, from List Newsletters.'),+ ...newsletterProps('update'),+ clear_fields: clearFieldsProp([+ { label: 'Description', value: 'description' },+ { label: 'Sender Name', value: 'sender_name' },+ ]),+ },+ async run(context) {+ const id = ghostCommon.id(context.propsValue.newsletter_id, 'Newsletter ID');+ const body = applyClearFields({+ body: ghostResource.pick(context.propsValue, NEWSLETTER_FIELDS),+ clear: context.propsValue.clear_fields,+ allowed: ['description', 'sender_name'],+ clearValue: null,+ });+ const subscribeOnSignup = ghostCommon.triState(context.propsValue.subscribe_on_signup);+ if (subscribeOnSignup !== undefined) {+ body['subscribe_on_signup'] = subscribeOnSignup;+ }+ return ghostResource.edit(context.auth, 'newsletters', id, body);+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/update-offer.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/update-offer.tsnew file mode 100644index 00000000000..f93f1510665--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/update-offer.ts@@ -0,0 +1,60 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { applyClearFields, clearFieldsProp } from '../../common/clear-fields';+import { ghostCommon } from '../../common/client';+import { ghostResource } from '../../common/resources';+import { ghostOfferOutputSchema } from '../../output-schemas';++export const ghostUpdateOffer = createAction({+ auth: ghostAuth,+ name: 'ghost_update_offer',+ outputSchema: ghostOfferOutputSchema,+ classification: 'WRITE',+ displayName: 'Update Offer',+ description: 'Update the name, code or display text of an offer.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Edits an offer by ID; only the name, code and display text can change, not the discount terms, and Clear Fields blanks the display description. Changing the code breaks links that use the old code. Use Archive Offer to stop redemptions.',+ idempotent: true,+ },+ props: {+ offer_id: ghostProps.id('Offer ID', 'The offer ID, from List Offers.'),+ name: Property.ShortText({+ displayName: 'Name',+ description: 'The new internal name.',+ required: false,+ }),+ code: Property.ShortText({+ displayName: 'Code',+ description: 'The new offer code.',+ required: false,+ }),+ display_title: Property.ShortText({+ displayName: 'Display Title',+ description: 'The new headline shown on the offer page.',+ required: false,+ }),+ display_description: Property.LongText({+ displayName: 'Display Description',+ description: 'The new text shown on the offer page.',+ required: false,+ }),+ clear_fields: clearFieldsProp([{ label: 'Display Description', value: 'display_description' }]),+ },+ async run(context) {+ const id = ghostCommon.id(context.propsValue.offer_id, 'Offer ID');+ return ghostResource.edit(+ context.auth,+ 'offers',+ id,+ applyClearFields({+ body: ghostResource.pick(context.propsValue, ['name', 'code', 'display_title', 'display_description']),+ clear: context.propsValue.clear_fields,+ allowed: ['display_description'],+ clearValue: null,+ })+ );+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/update-page.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/update-page.tsnew file mode 100644index 00000000000..1fe28d809de--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/update-page.ts@@ -0,0 +1,59 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { ghostCommon } from '../../common/client';+import { contentProps, ghostContent } from '../../common/content';+import { ghostPageOutputSchema } from '../../output-schemas';++export const ghostUpdatePage = createAction({+ auth: ghostAuth,+ name: 'ghost_update_page',+ outputSchema: ghostPageOutputSchema,+ classification: 'WRITE',+ displayName: 'Update Page',+ description: 'Update the content, settings or status of a page.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Edits a static page by ID; only the inputs you supply change, and Status can publish, schedule or unpublish it because pages are never emailed. Tags and Authors replace the whole list; an empty Tags list removes every tag, and Authors can never be empty. Clear Fields blanks the excerpt, feature image or SEO fields.',+ idempotent: true,+ },+ props: {+ page_id: ghostProps.id('Page ID', 'The page ID, from List Pages.'),+ ...contentProps({ label: 'page', mode: 'update' }),+ status: Property.StaticDropdown({+ displayName: 'Status',+ description: 'Change the page status. Scheduled requires a future Published At. Leave empty to keep it.',+ required: false,+ options: {+ options: [+ { label: 'Draft', value: 'draft' },+ { label: 'Published', value: 'published' },+ { label: 'Scheduled', value: 'scheduled' },+ ],+ },+ }),+ published_at: Property.DateTime({+ displayName: 'Published At',+ description: 'The publish time. Must be in the future when Status is Scheduled.',+ required: false,+ }),+ },+ async run(context) {+ const props = context.propsValue;+ const id = ghostCommon.id(props.page_id, 'Page ID');+ const body = ghostContent.body(props);+ if (ghostCommon.hasText(props.status)) {+ body['status'] = props.status;+ }+ if (props.status === 'scheduled') {+ body['published_at'] = ghostCommon.futureDate(props.published_at, 'Published At');+ } else if (ghostCommon.hasText(props.published_at)) {+ body['published_at'] = props.published_at;+ }+ if (Object.keys(body).length === 0) {+ throw new Error('Provide at least one field to change.');+ }+ return ghostContent.edit(context.auth, 'pages', id, body);+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/update-post.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/update-post.tsnew file mode 100644index 00000000000..4a7e35049d1--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/update-post.ts@@ -0,0 +1,33 @@+import { createAction } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { ghostCommon } from '../../common/client';+import { contentProps, ghostContent } from '../../common/content';+import { ghostPostOutputSchema } from '../../output-schemas';++export const ghostUpdatePost = createAction({+ auth: ghostAuth,+ name: 'ghost_update_post',+ outputSchema: ghostPostOutputSchema,+ classification: 'WRITE',+ displayName: 'Update Post',+ description: 'Update the content or settings of a post.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Edits a post by ID; only the inputs you supply change. Tags and Authors replace the whole list, so pass the full list you want; an empty Tags list removes every tag, and Authors can never be empty. Clear Fields blanks the excerpt, feature image or SEO fields. It cannot change status: use Publish Post, Schedule Post or Unpublish Post for that.',+ idempotent: true,+ },+ props: {+ post_id: ghostProps.id('Post ID', 'The post ID, from List Posts.'),+ ...contentProps({ label: 'post', mode: 'update' }),+ },+ async run(context) {+ const id = ghostCommon.id(context.propsValue.post_id, 'Post ID');+ const body = ghostContent.body(context.propsValue);+ if (Object.keys(body).length === 0) {+ throw new Error('Provide at least one field to change.');+ }+ return ghostContent.edit(context.auth, 'posts', id, body);+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/update-tag.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/update-tag.tsnew file mode 100644index 00000000000..0dc36aa4e9b--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/update-tag.ts@@ -0,0 +1,43 @@+import { createAction } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { applyClearFields, clearFieldsProp } from '../../common/clear-fields';+import { ghostCommon } from '../../common/client';+import { ghostResource } from '../../common/resources';+import { TAG_FIELDS, tagProps } from '../../common/tag-props';+import { ghostCreateTagOutputSchema } from '../../output-schemas';++export const ghostUpdateTag = createAction({+ auth: ghostAuth,+ name: 'ghost_update_tag',+ outputSchema: ghostCreateTagOutputSchema,+ classification: 'WRITE',+ displayName: 'Update Tag',+ description: 'Update the name or settings of a tag.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Edits a tag by ID; only the inputs you supply change, and Clear Fields blanks the description, accent color or SEO fields. Changing the slug changes the tag page URL.',+ idempotent: true,+ },+ props: {+ tag_id: ghostProps.id('Tag ID', 'The tag ID, from List Tags.'),+ ...tagProps('update'),+ clear_fields: clearFieldsProp([+ { label: 'Description', value: 'description' },+ { label: 'Accent Color', value: 'accent_color' },+ { label: 'Meta Title', value: 'meta_title' },+ { label: 'Meta Description', value: 'meta_description' },+ ]),+ },+ async run(context) {+ const id = ghostCommon.id(context.propsValue.tag_id, 'Tag ID');+ const body = applyClearFields({+ body: ghostResource.pick(context.propsValue, TAG_FIELDS),+ clear: context.propsValue.clear_fields,+ allowed: ['description', 'accent_color', 'meta_title', 'meta_description'],+ clearValue: null,+ });+ return ghostResource.edit(context.auth, 'tags', id, body);+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/update-tier.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/update-tier.tsnew file mode 100644index 00000000000..2e530806db5--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/update-tier.ts@@ -0,0 +1,42 @@+import { createAction } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostProps } from '../../common/ai-props';+import { applyClearFields, clearFieldsProp } from '../../common/clear-fields';+import { ghostCommon } from '../../common/client';+import { ghostResource } from '../../common/resources';+import { tierBody } from '../../common/tier-body';+import { TIER_QUERY, tierProps } from '../../common/tier-props';+import { ghostTierOutputSchema } from '../../output-schemas';++export const ghostUpdateTier = createAction({+ auth: ghostAuth,+ name: 'ghost_update_tier',+ outputSchema: ghostTierOutputSchema,+ classification: 'WRITE',+ displayName: 'Update Tier',+ description: 'Update the prices, benefits or settings of a tier.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Edits a membership tier by ID; only the inputs you supply change, Benefits replaces the full list (an empty list removes every benefit), and Clear Fields blanks the description or welcome page URL. New prices apply to new subscribers only and change the public pricing page. Use Archive Tier to stop selling it.',+ idempotent: true,+ },+ props: {+ tier_id: ghostProps.id('Tier ID', 'The tier ID, from List Tiers.'),+ ...tierProps('update'),+ clear_fields: clearFieldsProp([+ { label: 'Description', value: 'description' },+ { label: 'Welcome Page URL', value: 'welcome_page_url' },+ ]),+ },+ async run(context) {+ const id = ghostCommon.id(context.propsValue.tier_id, 'Tier ID');+ const body = applyClearFields({+ body: tierBody(context.propsValue),+ clear: context.propsValue.clear_fields,+ allowed: ['description', 'welcome_page_url'],+ clearValue: null,+ });+ return ghostResource.edit(context.auth, 'tiers', id, body, TIER_QUERY);+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/upload-file.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/upload-file.tsnew file mode 100644index 00000000000..7a8575a19c3--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/upload-file.ts@@ -0,0 +1,56 @@+import { HttpMethod } from '@activepieces/pieces-common';+import { createAction, Property } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostClient } from '../../common/client';+import FormData from 'form-data';+import { ghostUploadFileOutputSchema } from '../../output-schemas';++export const ghostUploadFile = createAction({+ auth: ghostAuth,+ name: 'ghost_upload_file',+ outputSchema: ghostUploadFileOutputSchema,+ classification: 'WRITE',+ displayName: 'Upload File',+ description: 'Upload a downloadable file (PDF, ZIP, CSV and more) to Ghost and get its URL.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Uploads a file such as a PDF, ZIP, CSV, DOCX or EPUB to Ghost and returns its public URL, to link from a post as a file card or download. Ghost only accepts known extensions; zip anything else. Use Upload Image or Upload Media for pictures, video and audio. Each call stores a new file.',+ idempotent: false,+ },+ props: {+ file: Property.File({+ displayName: 'File',+ description: 'The file to upload. Its name must end with a supported extension, e.g. .pdf or .zip.',+ required: true,+ }),+ ref: Property.ShortText({+ displayName: 'Reference',+ description: 'An optional value returned unchanged, e.g. the original file name.',+ required: false,+ }),+ },+ async run(context) {+ const { file, ref } = context.propsValue;+ const filename = file.filename || 'file';+ const data = Buffer.isBuffer(file.data) ? file.data : Buffer.from(file.base64, 'base64');+ const form = new FormData();+ form.append('file', data, { filename, contentType: 'application/octet-stream' });+ if (ref && ref.trim()) {+ form.append('ref', ref.trim());+ }+ const response = await ghostClient.request<{+ files?: { url: string; ref: string | null }[];+ }>({+ auth: context.auth,+ method: HttpMethod.POST,+ path: '/files/upload',+ body: form,+ });+ const uploaded = response.files?.[0];+ if (!uploaded) {+ throw new Error('Ghost did not return the uploaded file.');+ }+ return { url: uploaded.url, ref: uploaded.ref ?? null };+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/upload-image.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/upload-image.tsnew file mode 100644index 00000000000..0fe18b22032--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/upload-image.ts@@ -0,0 +1,84 @@+import { HttpMethod } from '@activepieces/pieces-common';+import { createAction, Property } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostClient } from '../../common/client';+import FormData from 'form-data';+import { ghostUploadImageOutputSchema } from '../../output-schemas';++const MIME_TYPES: Record<string, string> = {+ png: 'image/png',+ jpg: 'image/jpeg',+ jpeg: 'image/jpeg',+ gif: 'image/gif',+ webp: 'image/webp',+ svg: 'image/svg+xml',+ svgz: 'image/svg+xml',+ ico: 'image/x-icon',+};++export const ghostUploadImage = createAction({+ auth: ghostAuth,+ name: 'ghost_upload_image',+ outputSchema: ghostUploadImageOutputSchema,+ classification: 'WRITE',+ displayName: 'Upload Image',+ description: 'Upload an image to Ghost and get its URL.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Uploads a PNG, JPG, GIF, WebP, SVG or ICO image to the Ghost media library and returns its public URL, to use as a post Feature Image URL or inside post HTML. Each call stores a new file.',+ idempotent: false,+ },+ props: {+ file: Property.File({+ displayName: 'Image',+ description: 'The image file to upload.',+ required: true,+ }),+ purpose: Property.StaticDropdown({+ displayName: 'Purpose',+ description: 'How Ghost validates the image. Defaults to a content image.',+ required: false,+ defaultValue: 'image',+ options: {+ options: [+ { label: 'Content or feature image', value: 'image' },+ { label: 'Profile image (square)', value: 'profile_image' },+ { label: 'Site icon (square)', value: 'icon' },+ ],+ },+ }),+ ref: Property.ShortText({+ displayName: 'Reference',+ description: 'An optional value returned unchanged, e.g. the original file name.',+ required: false,+ }),+ },+ async run(context) {+ const { file, purpose, ref } = context.propsValue;+ const filename = file.filename || 'image';+ const extension = (file.extension || filename.split('.').pop() || '').toLowerCase();+ const mimeType = MIME_TYPES[extension];+ if (!mimeType) {+ throw new Error(`Unsupported image type "${extension}". Use PNG, JPG, GIF, WebP, SVG or ICO.`);+ }+ const data = Buffer.isBuffer(file.data) ? file.data : Buffer.from(file.base64, 'base64');+ const form = new FormData();+ form.append('file', data, { filename, contentType: mimeType });+ form.append('purpose', purpose || 'image');+ if (ref && ref.trim()) {+ form.append('ref', ref.trim());+ }+ const response = await ghostClient.request<{ images?: { url: string; ref: string | null }[] }>({+ auth: context.auth,+ method: HttpMethod.POST,+ path: '/images/upload',+ body: form,+ });+ const image = response.images?.[0];+ if (!image) {+ throw new Error('Ghost did not return the uploaded image.');+ }+ return { url: image.url, ref: image.ref ?? null };+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/ai/upload-media.ts b/packages/pieces/community/ghostcms/src/lib/actions/ai/upload-media.tsnew file mode 100644index 00000000000..3ca431c0b55--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/actions/ai/upload-media.ts@@ -0,0 +1,77 @@+import { HttpMethod } from '@activepieces/pieces-common';+import { createAction, Property } from '@activepieces/pieces-framework';+import { ghostAuth } from '../../auth';+import { ghostClient } from '../../common/client';+import FormData from 'form-data';+import { ghostUploadMediaOutputSchema } from '../../output-schemas';++const MIME_TYPES: Record<string, string> = {+ mp4: 'video/mp4',+ webm: 'video/webm',+ ogv: 'video/ogg',+ mp3: 'audio/mpeg',+ wav: 'audio/wav',+ ogg: 'audio/ogg',+ m4a: 'audio/mp4',+};++export const ghostUploadMedia = createAction({+ auth: ghostAuth,+ name: 'ghost_upload_media',+ outputSchema: ghostUploadMediaOutputSchema,+ classification: 'WRITE',+ displayName: 'Upload Media',+ description: 'Upload a video or audio file to Ghost and get its URL.',+ audience: 'ai',+ aiMetadata: {+ description:+ 'Uploads an MP4, WebM, OGV, MP3, WAV, OGG or M4A file to the Ghost media library and returns its public URL, to embed in post HTML as a video or audio card. Use Upload Image for pictures and Upload File for any other download. Each call stores a new file.',+ idempotent: false,+ },+ props: {+ file: Property.File({+ displayName: 'Media File',+ description: 'The video or audio file to upload.',+ required: true,+ }),+ ref: Property.ShortText({+ displayName: 'Reference',+ description: 'An optional value returned unchanged, e.g. the original file name.',+ required: false,+ }),+ },+ async run(context) {+ const { file, ref } = context.propsValue;+ const filename = file.filename || 'media';+ const extension = (file.extension || filename.split('.').pop() || '').toLowerCase();+ const mimeType = MIME_TYPES[extension];+ if (!mimeType) {+ throw new Error(+ `Unsupported media type "${extension}". Use MP4, WebM, OGV, MP3, WAV, OGG or M4A.`+ );+ }+ const data = Buffer.isBuffer(file.data) ? file.data : Buffer.from(file.base64, 'base64');+ const form = new FormData();+ form.append('file', data, { filename, contentType: mimeType });+ if (ref && ref.trim()) {+ form.append('ref', ref.trim());+ }+ const response = await ghostClient.request<{+ media?: { url: string; thumbnail_url: string | null; ref: string | null }[];+ }>({+ auth: context.auth,+ method: HttpMethod.POST,+ path: '/media/upload',+ body: form,+ });+ const media = response.media?.[0];+ if (!media) {+ throw new Error('Ghost did not return the uploaded media.');+ }+ return {+ url: media.url,+ thumbnail_url: media.thumbnail_url ?? null,+ ref: media.ref ?? null,+ };+ },+});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/create-member.ts b/packages/pieces/community/ghostcms/src/lib/actions/create-member.tsindex f1fbeb0100f..302aa2a6931 100644--- a/packages/pieces/community/ghostcms/src/lib/actions/create-member.ts+++ b/packages/pieces/community/ghostcms/src/lib/actions/create-member.ts@@ -1,15 +1,17 @@import { createAction, Property } from '@activepieces/pieces-framework';import { HttpMethod, httpClient } from '@activepieces/pieces-common';-import { ghostAuth } from '../..';+import { ghostAuth } from '../auth';import { common } from '../common';+import { ghostOriginalMembersOutputSchema } from '../output-schemas';export const createMember = createAction({name: 'create_member',+ outputSchema: ghostOriginalMembersOutputSchema,classification: 'WRITE',displayName: 'Create Member',description: 'Create a new member',- audience: 'both',+ audience: 'human',aiMetadata: { description: 'Creates a new member in a Ghost publication from an email (required), with optional name, internal note, and newsletter subscriptions. Use to add a subscriber/member to the audience. Not idempotent: each call creates a member and re-running with the same email may produce a duplicate or error.', idempotent: false },auth: ghostAuth,props: {diff --git a/packages/pieces/community/ghostcms/src/lib/actions/create-post.ts b/packages/pieces/community/ghostcms/src/lib/actions/create-post.tsindex 50813d8501c..9186719f74e 100644--- a/packages/pieces/community/ghostcms/src/lib/actions/create-post.ts+++ b/packages/pieces/community/ghostcms/src/lib/actions/create-post.ts@@ -5,15 +5,17 @@ import {} from '@activepieces/pieces-framework';import { HttpMethod, httpClient } from '@activepieces/pieces-common';-import { ghostAuth } from '../..';+import { ghostAuth } from '../auth';import { common } from '../common';+import { ghostOriginalCreatePostOutputSchema } from '../output-schemas';export const createPost = createAction({name: 'create_post',+ outputSchema: ghostOriginalCreatePostOutputSchema,classification: 'WRITE',displayName: 'Create Post',description: 'Create a new post',- audience: 'both',+ audience: 'human',aiMetadata: { description: 'Creates a new post in a Ghost publication from a title and HTML content, with the status controlling whether it is saved as a draft, published immediately, or scheduled (scheduled requires a future Published At). Supports optional slug, excerpt, author, tags, and a featured flag. Not idempotent: each call creates a separate post.', idempotent: false },auth: ghostAuth,props: {diff --git a/packages/pieces/community/ghostcms/src/lib/actions/find-member.ts b/packages/pieces/community/ghostcms/src/lib/actions/find-member.tsindex b7d8a8e58ba..dd4bd71a61a 100644--- a/packages/pieces/community/ghostcms/src/lib/actions/find-member.ts+++ b/packages/pieces/community/ghostcms/src/lib/actions/find-member.ts@@ -1,15 +1,18 @@import { createAction, Property } from '@activepieces/pieces-framework';import { HttpMethod, httpClient } from '@activepieces/pieces-common';-import { ghostAuth } from '../..';+import { ghostAuth } from '../auth';import { common } from '../common';+import { ghostCommon } from '../common/client';+import { ghostOriginalFindMemberOutputSchema } from '../output-schemas';export const findMember = createAction({name: 'find_member',+ outputSchema: ghostOriginalFindMemberOutputSchema,classification: 'READ',displayName: 'Find Member',description: 'Find a member by email',- audience: 'both',+ audience: 'human',aiMetadata: { description: 'Looks up Ghost members filtered by an exact email address and returns the matches. Use to check whether a member exists or to resolve a member id before updating. Read-only and idempotent.', idempotent: true },auth: ghostAuth,props: {@@ -27,7 +30,7 @@ export const findMember = createAction({Authorization: `Ghost ${common.jwtFromApiKey(context.auth.props.apiKey)}`,},queryParams: {- filter: `email:${context.propsValue.email}`,+ filter: `email:${ghostCommon.nqlString(context.propsValue.email.trim())}`,},});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/find-user.ts b/packages/pieces/community/ghostcms/src/lib/actions/find-user.tsindex 1f399154aee..76902e842da 100644--- a/packages/pieces/community/ghostcms/src/lib/actions/find-user.ts+++ b/packages/pieces/community/ghostcms/src/lib/actions/find-user.ts@@ -1,15 +1,18 @@import { createAction, Property } from '@activepieces/pieces-framework';import { HttpMethod, httpClient } from '@activepieces/pieces-common';-import { ghostAuth } from '../..';+import { ghostAuth } from '../auth';import { common } from '../common';+import { ghostCommon } from '../common/client';+import { ghostOriginalFindUserOutputSchema } from '../output-schemas';export const findUser = createAction({name: 'find_user',+ outputSchema: ghostOriginalFindUserOutputSchema,classification: 'READ',displayName: 'Find User',description: 'Find a staff user by email',- audience: 'both',+ audience: 'human',aiMetadata: { description: 'Looks up Ghost staff users (authors/admins, not members) filtered by an exact email address and returns the matches. Use to resolve a staff user id, e.g. to set as a post author. Read-only and idempotent.', idempotent: true },auth: ghostAuth,props: {@@ -27,7 +30,7 @@ export const findUser = createAction({Authorization: `Ghost ${common.jwtFromApiKey(context.auth.props.apiKey)}`,},queryParams: {- filter: `email:${context.propsValue.email}`,+ filter: `email:${ghostCommon.nqlString(context.propsValue.email.trim())}`,},});diff --git a/packages/pieces/community/ghostcms/src/lib/actions/update-member.ts b/packages/pieces/community/ghostcms/src/lib/actions/update-member.tsindex 2e52beece54..4955d30307a 100644--- a/packages/pieces/community/ghostcms/src/lib/actions/update-member.ts+++ b/packages/pieces/community/ghostcms/src/lib/actions/update-member.ts@@ -1,15 +1,17 @@import { createAction, Property } from '@activepieces/pieces-framework';import { HttpMethod, httpClient } from '@activepieces/pieces-common';-import { ghostAuth } from '../..';+import { ghostAuth } from '../auth';import { common } from '../common';+import { ghostOriginalMembersOutputSchema } from '../output-schemas';export const updateMember = createAction({name: 'update_member',+ outputSchema: ghostOriginalMembersOutputSchema,classification: 'WRITE',displayName: 'Update Member',description: 'Update a member',- audience: 'both',+ audience: 'human',aiMetadata: { description: 'Updates an existing Ghost member identified by member id, changing any supplied fields (email, name, note, newsletter subscriptions); omitted fields are left unchanged. Use to edit a known member. Requires the target member id. Idempotent: re-applying the same field values yields the same member state.', idempotent: true },auth: ghostAuth,props: {@@ -50,7 +52,7 @@ export const updateMember = createAction({if (context.propsValue.name) data.name = context.propsValue.name;if (context.propsValue.note) data.note = context.propsValue.note;if (context.propsValue.newsletters)- data.newsletters = context.propsValue.newsletters;+ data.newsletters = newsletters;const response = await httpClient.sendRequest({url: `${context.auth.props.baseUrl}/ghost/api/admin/members/${context.propsValue.member}`,diff --git a/packages/pieces/community/ghostcms/src/lib/auth.ts b/packages/pieces/community/ghostcms/src/lib/auth.tsnew file mode 100644index 00000000000..c104a92bf7c--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/auth.ts@@ -0,0 +1,71 @@+import { HttpMethod } from '@activepieces/pieces-common';+import { PieceAuth, Property } from '@activepieces/pieces-framework';+import { GhostApiError, ghostClient } from './common/client';++const authMarkdown = `+To generate an API key, follow the steps below in GhostCMS:+1. Go to Settings -> Advanced -> Integrations.+2. Scroll down to Custom Integrations and click Add custom integration.+3. Enter integration name and click create.+4. Copy the API URL and the Admin API Key into the fields below.+`;++export const ghostAuth = PieceAuth.CustomAuth({+ description: authMarkdown,+ required: true,+ props: {+ baseUrl: Property.ShortText({+ displayName: 'API URL',+ description:+ 'The API URL of your application (https://test-publication.ghost.io)',+ required: true,+ }),+ apiKey: PieceAuth.SecretText({+ displayName: 'Admin API Key',+ description: 'The admin API key for your application',+ required: true,+ }),+ },+ validate: async ({ auth }) => {+ const urlProblem = baseUrlProblem(auth.baseUrl);+ if (urlProblem) {+ return { valid: false, error: urlProblem };+ }+ try {+ await ghostClient.request<unknown>({+ auth: { props: { baseUrl: auth.baseUrl, apiKey: auth.apiKey } },+ method: HttpMethod.GET,+ path: '/users/',+ query: { limit: 1 },+ });+ return { valid: true };+ } catch (error) {+ if (error instanceof GhostApiError && (error.status === 401 || error.status === 403)) {+ return { valid: false, error: 'Invalid Admin API Key. Copy the Admin API Key of the custom integration from Ghost Settings > Advanced > Integrations.' };+ }+ return {+ valid: false,+ error: error instanceof Error ? `Could not verify the connection: ${error.message}` : 'Could not verify the connection.',+ };+ }+ },+});++function baseUrlProblem(value: string): string | null {+ const parsed = parseUrl((value ?? '').trim());+ if (!parsed || (parsed.protocol !== 'https:' && parsed.protocol !== 'http:')) {+ return 'API URL must be the http(s) address of your Ghost site, e.g. https://your-site.ghost.io.';+ }+ if (parsed.username || parsed.password) {+ return 'API URL must not contain a username or password.';+ }+ return null;+}++function parseUrl(value: string): URL | null {+ try {+ return new URL(value);+ } catch {+ return null;+ }+}diff --git a/packages/pieces/community/ghostcms/src/lib/common/ai-props.ts b/packages/pieces/community/ghostcms/src/lib/common/ai-props.tsnew file mode 100644index 00000000000..12da9cdb8b0--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/common/ai-props.ts@@ -0,0 +1,77 @@+import { Property } from '@activepieces/pieces-framework';++export const ghostProps = {+ filter: (example: string) =>+ Property.ShortText({+ displayName: 'Filter',+ description: `A Ghost NQL filter, e.g. ${example}. Quote values that contain spaces or special characters with single quotes.`,+ required: false,+ }),+ limit: Property.Number({+ displayName: 'Limit',+ description: 'How many records to return per page, from 1 to 100. Defaults to 15.',+ required: false,+ defaultValue: 15,+ }),+ page: Property.Number({+ displayName: 'Page',+ description: 'The page number to return. Defaults to 1.',+ required: false,+ defaultValue: 1,+ }),+ order: (example: string) =>+ Property.ShortText({+ displayName: 'Order',+ description: `Sort order as "<field> asc|desc", e.g. ${example}.`,+ required: false,+ }),+ id: (displayName: string, description: string) =>+ Property.ShortText({+ displayName,+ description,+ required: true,+ }),+ slug: (description: string) =>+ Property.ShortText({+ displayName: 'Slug',+ description,+ required: true,+ }),+ triState: (displayName: string, description: string) =>+ Property.StaticDropdown({+ displayName,+ description: `${description} Leave empty to keep the current value.`,+ required: false,+ options: {+ options: [+ { label: 'Yes', value: 'true' },+ { label: 'No', value: 'false' },+ ],+ },+ }),+ newsletterSlug: Property.ShortText({+ displayName: 'Newsletter Slug',+ description:+ 'Send the post by email to this newsletter, e.g. "default-newsletter". Get slugs from List Newsletters. Leave empty to publish on the site only.',+ required: false,+ }),+ emailSegment: Property.ShortText({+ displayName: 'Email Segment',+ description:+ 'Which members receive the email: "all", "status:free", "status:-free" (paid) or another member NQL filter. Only used with Newsletter Slug. Defaults to all.',+ required: false,+ }),+ emailOnly: Property.Checkbox({+ displayName: 'Email Only',+ description:+ 'Send the post as an email to the newsletter without publishing it on the site. Requires Newsletter Slug.',+ required: false,+ defaultValue: false,+ }),+ newsletterIds: (displayName: string, description: string, required: boolean) =>+ Property.Array({+ displayName,+ description,+ required,+ }),+};diff --git a/packages/pieces/community/ghostcms/src/lib/common/clear-fields.ts b/packages/pieces/community/ghostcms/src/lib/common/clear-fields.tsnew file mode 100644index 00000000000..41f7eabbae6--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/common/clear-fields.ts@@ -0,0 +1,37 @@+import { Property } from '@activepieces/pieces-framework';+import { ghostCommon } from './client';++type ClearableField = { label: string; value: string };++export const clearFieldsProp = (fields: ClearableField[]) =>+ Property.StaticMultiSelectDropdown({+ displayName: 'Clear Fields',+ description:+ 'Fields to blank out on the record. A field listed here must not also be given a new value. Leave empty to clear nothing.',+ required: false,+ options: { options: fields },+ });++export const applyClearFields = ({+ body,+ clear,+ allowed,+ clearValue,+}: {+ body: Record<string, unknown>;+ clear: unknown;+ allowed: string[];+ clearValue: null | '';+}): Record<string, unknown> => {+ const fields = ghostCommon.stringList(clear) ?? [];+ for (const field of fields) {+ if (!allowed.includes(field)) {+ throw new Error(`"${field}" cannot be cleared. Clearable fields: ${allowed.join(', ')}.`);+ }+ if (body[field] !== undefined) {+ throw new Error(`"${field}" is both set to a new value and listed in Clear Fields. Choose one.`);+ }+ body[field] = clearValue;+ }+ return body;+};diff --git a/packages/pieces/community/ghostcms/src/lib/common/client.ts b/packages/pieces/community/ghostcms/src/lib/common/client.tsnew file mode 100644index 00000000000..b8fecd97d3e--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/common/client.ts@@ -0,0 +1,218 @@+import { httpClient, HttpMethod } from '@activepieces/pieces-common';+import jwt from 'jsonwebtoken';++type QueryValue = string | number | boolean | undefined | null;++export type GhostAuthValue = {+ props: {+ baseUrl: string;+ apiKey: string;+ };+};++export type GhostPagination = {+ page: number | null;+ limit: number | string | null;+ total_pages: number | null;+ total: number | null;+ next: number | null;+ prev: number | null;+};++export class GhostApiError extends Error {+ constructor(message: string, public readonly status: number) {+ super(message);+ }+}++const isRecord = (value: unknown): value is Record<string, unknown> =>+ typeof value === 'object' && value !== null && !Array.isArray(value);++const errorText = (error: Record<string, unknown>): string =>+ [error['message'], error['context']]+ .filter((part): part is string => typeof part === 'string' && part.length > 0)+ .join(' ');++const describeError = ({ status, body }: { status: number; body: unknown }): string => {+ const errors = isRecord(body) && Array.isArray(body['errors']) ? body['errors'].filter(isRecord) : [];+ const detail =+ errors.length > 0+ ? errors.map(errorText).join('; ')+ : typeof body === 'string'+ ? body+ : JSON.stringify(body);+ if (status === 401 || status === 403) {+ return `Ghost rejected the Admin API key (${status}). Check the API URL and the Admin API Key of the custom integration. ${detail}`;+ }+ if (status === 404) {+ return `Ghost could not find the requested resource (404). Check the ID or slug. ${detail}`;+ }+ if (status === 409) {+ return `Ghost reported an update collision (409): the record changed while it was being saved. Retry the action. ${detail}`;+ }+ if (status === 422) {+ return `Ghost rejected the request (422). ${detail}`;+ }+ if (status === 429) {+ return `Ghost rate limit reached (429). Wait a moment and retry. ${detail}`;+ }+ return `Ghost API request failed (${status}). ${detail}`;+};++const signToken = (apiKey: string): string => {+ const [id, secret] = (apiKey ?? '').trim().split(':');+ if (!id || !secret) {+ throw new Error(+ 'The Admin API Key must look like "<id>:<secret>". Copy the Admin API Key of the custom integration from Ghost Settings > Advanced > Integrations.'+ );+ }+ return jwt.sign({}, Buffer.from(secret, 'hex'), {+ keyid: id,+ expiresIn: '5m',+ audience: '/admin/',+ });+};++const toQueryParams = (query?: Record<string, QueryValue>): Record<string, string> => {+ const params: Record<string, string> = {};+ for (const [key, value] of Object.entries(query ?? {})) {+ if (value !== undefined && value !== null && value !== '') {+ params[key] = String(value);+ }+ }+ return params;+};++export const ghostClient = {+ adminUrl(auth: GhostAuthValue): string {+ return `${auth.props.baseUrl.trim().replace(/\/+$/, '')}/ghost/api/admin`;+ },+ async request<T>({+ auth,+ method,+ path,+ query,+ body,+ headers,+ }: {+ auth: GhostAuthValue;+ method: HttpMethod;+ path: string;+ query?: Record<string, QueryValue>;+ body?: unknown;+ headers?: Record<string, string>;+ }): Promise<T> {+ try {+ const response = await httpClient.sendRequest<T>({+ method,+ url: `${ghostClient.adminUrl(auth)}${path}`,+ headers: {+ ...(headers ?? {}),+ Authorization: `Ghost ${signToken(auth.props.apiKey)}`,+ },+ queryParams: toQueryParams(query),+ body,+ });+ return response.body;+ } catch (error) {+ const response = isRecord(error) && isRecord(error['response']) ? error['response'] : undefined;+ const status = response && typeof response['status'] === 'number' ? response['status'] : undefined;+ if (response && status) {+ throw new GhostApiError(describeError({ status, body: response['body'] }), status);+ }+ throw error;+ }+ },+};++export const ghostCommon = {+ pagination(meta: unknown): GhostPagination {+ const pagination = isRecord(meta) && isRecord(meta['pagination']) ? meta['pagination'] : {};+ const numberOrNull = (value: unknown): number | null => (typeof value === 'number' ? value : null);+ const limit = pagination['limit'];+ return {+ page: numberOrNull(pagination['page']),+ limit: typeof limit === 'number' || typeof limit === 'string' ? limit : null,+ total_pages: numberOrNull(pagination['pages']),+ total: numberOrNull(pagination['total']),+ next: numberOrNull(pagination['next']),+ prev: numberOrNull(pagination['prev']),+ };+ },+ isRecord,+ records(value: unknown): Record<string, unknown>[] {+ return Array.isArray(value) ? value.filter(isRecord) : [];+ },+ listQuery(props: {+ filter?: string | null;+ limit?: number | null;+ page?: number | null;+ order?: string | null;+ }): Record<string, QueryValue> {+ const limit =+ props.limit === undefined || props.limit === null+ ? 15+ : Math.min(Math.max(Math.trunc(props.limit), 1), 100);+ return {+ filter: props.filter?.trim(),+ limit,+ page: props.page ?? 1,+ order: props.order?.trim(),+ };+ },+ nqlString(value: string): string {+ return `'${value.replace(/\\/g, '\\\\').replace(/'/g, "\\'")}'`;+ },+ id(value: string, label: string): string {+ const text = (value ?? '').trim();+ if (!text) {+ throw new Error(`${label} is required.`);+ }+ return encodeURIComponent(text);+ },+ stringList(value: unknown): string[] | undefined {+ if (value === undefined || value === null) {+ return undefined;+ }+ const items = Array.isArray(value) ? value : [value];+ const list = items+ .map((item) => {+ if (item !== null && typeof item === 'object') {+ const first = Object.values(item).find((entry) => typeof entry === 'string');+ return typeof first === 'string' ? first : '';+ }+ return String(item ?? '');+ })+ .map((item) => item.trim())+ .filter((item) => item.length > 0);+ return list.length > 0 ? list : undefined;+ },+ triState(value: unknown): boolean | undefined {+ if (value === true || value === 'true') {+ return true;+ }+ if (value === false || value === 'false') {+ return false;+ }+ return undefined;+ },+ hasText(value: unknown): value is string {+ return typeof value === 'string' && value.trim().length > 0;+ },+ first<T>(items: T[] | undefined, resource: string): T {+ if (!items || items.length === 0) {+ throw new Error(`Ghost returned no ${resource}.`);+ }+ return items[0];+ },+ futureDate(value: unknown, label: string): string {+ const date = new Date(String(value ?? ''));+ if (Number.isNaN(date.getTime())) {+ throw new Error(`${label} must be a valid date and time.`);+ }+ if (date.getTime() <= Date.now()) {+ throw new Error(`${label} must be in the future.`);+ }+ return date.toISOString();+ },+};diff --git a/packages/pieces/community/ghostcms/src/lib/common/content.ts b/packages/pieces/community/ghostcms/src/lib/common/content.tsnew file mode 100644index 00000000000..2f3cd7a6a77--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/common/content.ts@@ -0,0 +1,212 @@+import { HttpMethod } from '@activepieces/pieces-common';+import { Property } from '@activepieces/pieces-framework';+import { GhostAuthValue, ghostClient, ghostCommon } from './client';+import { ghostProps } from './ai-props';+import { applyClearFields, clearFieldsProp } from './clear-fields';++export type GhostContentResource = 'posts' | 'pages';++type ContentItem = Record<string, unknown> & { id: string; updated_at: string; status?: string };++const CONTENT_QUERY = { formats: 'html', include: 'tags,authors' };++const visibility = Property.StaticDropdown({+ displayName: 'Visibility',+ description: 'Who can read the content on the site.',+ required: false,+ options: {+ options: [+ { label: 'Public', value: 'public' },+ { label: 'Members only', value: 'members' },+ { label: 'Paid members only', value: 'paid' },+ ],+ },+});++export const contentProps = ({ label, mode }: { label: 'post' | 'page'; mode: 'create' | 'update' }) => ({+ title: Property.ShortText({+ displayName: 'Title',+ description: `The ${label} title.`,+ required: mode === 'create',+ }),+ html: Property.LongText({+ displayName: 'Content (HTML)',+ description: `The ${label} body as HTML. Ghost converts it to its editor format.${+ mode === 'update' ? ' Supplying it replaces the whole body.' : ''+ }`,+ required: false,+ }),+ slug: Property.ShortText({+ displayName: 'Slug',+ description: `The URL slug of the ${label}. Ghost generates one from the title when empty.`,+ required: false,+ }),+ custom_excerpt: Property.LongText({+ displayName: 'Excerpt',+ description: 'A short summary shown in lists and previews.',+ required: false,+ }),+ feature_image: Property.ShortText({+ displayName: 'Feature Image URL',+ description: 'The URL of the feature image, for example one returned by Upload Image.',+ required: false,+ }),+ featured: ghostProps.triState('Featured', `Mark the ${label} as featured.`),+ visibility,+ tags: Property.Array({+ displayName: 'Tags',+ description: `Tag names. Missing tags are created.${+ mode === 'update' ? ' Supplying tags replaces the full tag list; an empty list removes every tag, and leaving it out keeps the current tags.' : ''+ }`,+ required: false,+ }),+ authors: Property.Array({+ displayName: 'Authors',+ description: `Staff user IDs or emails, from List Users.${+ mode === 'update'+ ? ' Supplying authors replaces the full author list. Ghost needs at least one author, so an empty list is rejected.'+ : ' Defaults to the integration owner.'+ }`,+ required: false,+ }),+ meta_title: Property.ShortText({+ displayName: 'Meta Title',+ description: 'The SEO title.',+ required: false,+ }),+ meta_description: Property.LongText({+ displayName: 'Meta Description',+ description: 'The SEO description.',+ required: false,+ }),+ ...(mode === 'update' ? { clear_fields: clearFieldsProp(CLEARABLE_CONTENT_FIELDS) } : {}),+});++const CLEARABLE_CONTENT_FIELDS = [+ { label: 'Excerpt', value: 'custom_excerpt' },+ { label: 'Feature Image URL', value: 'feature_image' },+ { label: 'Meta Title', value: 'meta_title' },+ { label: 'Meta Description', value: 'meta_description' },+];++export const ghostContent = {+ strip<T extends Record<string, unknown>>(item: T): T {+ const copy = { ...item };+ delete copy['lexical'];+ delete copy['mobiledoc'];+ return copy;+ },+ body(props: Record<string, unknown>): Record<string, unknown> {+ const body: Record<string, unknown> = {};+ for (const key of ['title', 'html', 'slug', 'custom_excerpt', 'feature_image', 'meta_title', 'meta_description']) {+ const value = props[key];+ if (typeof value === 'string' && value.trim().length > 0) {+ body[key] = key === 'html' ? value : value.trim();+ }+ }+ const featured = ghostCommon.triState(props['featured']);+ if (featured !== undefined) {+ body['featured'] = featured;+ }+ if (ghostCommon.hasText(props['visibility'])) {+ body['visibility'] = props['visibility'];+ }+ const rawTags = props['tags'];+ const tags = ghostCommon.stringList(rawTags);+ if (tags) {+ body['tags'] = tags.map((name) => ({ name }));+ } else if (Array.isArray(rawTags)) {+ body['tags'] = [];+ }+ const rawAuthors = props['authors'];+ const authors = ghostCommon.stringList(rawAuthors);+ if (authors) {+ body['authors'] = authors.map((value) => (value.includes('@') ? { email: value } : { id: value }));+ } else if (Array.isArray(rawAuthors)) {+ throw new Error('Ghost requires at least one author. Leave Authors out to keep the current authors, or pass the staff user IDs or emails you want.');+ }+ return applyClearFields({+ body,+ clear: props['clear_fields'],+ allowed: CLEARABLE_CONTENT_FIELDS.map((field) => field.value),+ clearValue: null,+ });+ },+ async list(+ auth: GhostAuthValue,+ resource: GhostContentResource,+ props: { filter?: string | null; limit?: number | null; page?: number | null; order?: string | null; include_content?: boolean | null }+ ) {+ const response = await ghostClient.request<Record<string, unknown>>({+ auth,+ method: HttpMethod.GET,+ path: `/${resource}`,+ query: {+ ...ghostCommon.listQuery(props),+ include: 'tags,authors',+ formats: props.include_content ? 'html' : undefined,+ },+ });+ const items = ghostCommon.records(response[resource]).map((item) => {+ const stripped = ghostContent.strip(item);+ if (!props.include_content) {+ delete stripped['html'];+ }+ return stripped;+ });+ return { [resource]: items, ...ghostCommon.pagination(response['meta']) };+ },+ async get(auth: GhostAuthValue, resource: GhostContentResource, path: string): Promise<ContentItem> {+ const response = await ghostClient.request<Record<string, ContentItem[]>>({+ auth,+ method: HttpMethod.GET,+ path: `/${resource}/${path}`,+ query: CONTENT_QUERY,+ });+ return ghostContent.strip(ghostCommon.first(response[resource], resource));+ },+ async create(auth: GhostAuthValue, resource: GhostContentResource, body: Record<string, unknown>) {+ const response = await ghostClient.request<Record<string, ContentItem[]>>({+ auth,+ method: HttpMethod.POST,+ path: `/${resource}`,+ query: { ...CONTENT_QUERY, source: body['html'] !== undefined ? 'html' : undefined },+ body: { [resource]: [body] },+ });+ return ghostContent.strip(ghostCommon.first(response[resource], resource));+ },+ async edit(+ auth: GhostAuthValue,+ resource: GhostContentResource,+ id: string,+ changes: Record<string, unknown> | ((current: ContentItem) => Record<string, unknown>),+ query?: Record<string, string | undefined>+ ) {+ const current = await ghostContent.get(auth, resource, id);+ const body = typeof changes === 'function' ? changes(current) : changes;+ const response = await ghostClient.request<Record<string, ContentItem[]>>({+ auth,+ method: HttpMethod.PUT,+ path: `/${resource}/${id}`,+ query: { ...CONTENT_QUERY, source: body['html'] !== undefined ? 'html' : undefined, ...(query ?? {}) },+ body: { [resource]: [{ ...body, updated_at: current.updated_at }] },+ });+ return ghostContent.strip(ghostCommon.first(response[resource], resource));+ },+ async copy(auth: GhostAuthValue, resource: GhostContentResource, id: string) {+ const response = await ghostClient.request<Record<string, ContentItem[]>>({+ auth,+ method: HttpMethod.POST,+ path: `/${resource}/${id}/copy`,+ query: CONTENT_QUERY,+ });+ return ghostContent.strip(ghostCommon.first(response[resource], resource));+ },+ async remove(auth: GhostAuthValue, resource: GhostContentResource, id: string) {+ await ghostClient.request<unknown>({+ auth,+ method: HttpMethod.DELETE,+ path: `/${resource}/${id}`,+ });+ },+};diff --git a/packages/pieces/community/ghostcms/src/lib/common/custom-api-guard.ts b/packages/pieces/community/ghostcms/src/lib/common/custom-api-guard.tsnew file mode 100644index 00000000000..c75adac3bc9--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/common/custom-api-guard.ts@@ -0,0 +1,35 @@+import { GhostAuthValue, ghostClient, ghostCommon } from './client';++const ABSOLUTE = /^[a-z][a-z0-9+.-]*:/i;++export const assertGhostUrl = ({ auth, propsValue }: { auth: GhostAuthValue; propsValue: unknown }): void => {+ const urlProp = ghostCommon.isRecord(propsValue) ? propsValue['url'] : undefined;+ const url = ghostCommon.isRecord(urlProp) ? urlProp['url'] : undefined;+ if (typeof url !== 'string') {+ return;+ }+ const target = url.trim();+ const base = ghostClient.adminUrl(auth);+ const refuse = (): never => {+ throw new Error(+ `Custom API Call only sends your Ghost Admin API key to ${base}. Use a path relative to it, e.g. /posts/.`+ );+ };+ if (ABSOLUTE.test(target) || target.startsWith('//') || target.startsWith('\\')) {+ if (!(target === base || target.startsWith(`${base}/`) || target.startsWith(`${base}?`))) {+ refuse();+ }+ }+ const path = target.split(/[?#]/)[0];+ if (path.split(/[/\\]/).some((segment) => decodeSegment(segment) === '..')) {+ refuse();+ }+};++const decodeSegment = (segment: string): string => {+ try {+ return decodeURIComponent(segment);+ } catch {+ return segment;+ }+};diff --git a/packages/pieces/community/ghostcms/src/lib/common/index.ts b/packages/pieces/community/ghostcms/src/lib/common/index.tsindex e730741dc24..f09785f5937 100644--- a/packages/pieces/community/ghostcms/src/lib/common/index.ts+++ b/packages/pieces/community/ghostcms/src/lib/common/index.ts@@ -2,7 +2,7 @@ import { HttpMethod, httpClient } from '@activepieces/pieces-common';import { Property } from '@activepieces/pieces-framework';import jwt from 'jsonwebtoken';-import { ghostAuth } from '../..';+import { ghostAuth } from '../auth';export const common = {properties: {diff --git a/packages/pieces/community/ghostcms/src/lib/common/member-labels.ts b/packages/pieces/community/ghostcms/src/lib/common/member-labels.tsnew file mode 100644index 00000000000..e583539e37d--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/common/member-labels.ts@@ -0,0 +1,39 @@+import { HttpMethod } from '@activepieces/pieces-common';+import { GhostAuthValue, ghostClient, ghostCommon } from './client';+import { ghostResource } from './resources';++// Ghost wraps bulk stats in `bulk.meta` (core/server/api/endpoints/utils/serializers/output/members.js bulkAction).+type BulkResponse = {+ bulk?: { meta?: { stats?: { successful?: number; unsuccessful?: number }; errors?: unknown[] } };+};++export const changeMemberLabel = async ({+ auth,+ memberId,+ labelId,+ action,+}: {+ auth: GhostAuthValue;+ memberId: string;+ labelId: string;+ action: 'addLabel' | 'removeLabel';+}) => {+ const id = ghostCommon.id(memberId, 'Member ID');+ const label = (labelId ?? '').trim();+ if (!label) {+ throw new Error('Label ID is required.');+ }+ await ghostResource.get(auth, 'members', id);+ const response = await ghostClient.request<BulkResponse>({+ auth,+ method: HttpMethod.PUT,+ path: '/members/bulk',+ query: { filter: `id:${ghostCommon.nqlString(memberId.trim())}` },+ body: { bulk: { action, meta: { label: { id: label } } } },+ });+ const unsuccessful = response.bulk?.meta?.stats?.unsuccessful ?? 0;+ if (unsuccessful > 0) {+ throw new Error(`Ghost could not update the member label: ${JSON.stringify(response.bulk?.meta?.errors ?? [])}`);+ }+ return ghostResource.get(auth, 'members', id);+};diff --git a/packages/pieces/community/ghostcms/src/lib/common/member-newsletters.ts b/packages/pieces/community/ghostcms/src/lib/common/member-newsletters.tsnew file mode 100644index 00000000000..99fbbe8e28f--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/common/member-newsletters.ts@@ -0,0 +1,50 @@+import { HttpMethod } from '@activepieces/pieces-common';+import { GhostAuthValue, ghostClient, ghostCommon } from './client';+import { ghostResource } from './resources';++export const currentNewsletterIds = async ({ auth, memberId }: { auth: GhostAuthValue; memberId: string }) => {+ const member = await ghostResource.get(auth, 'members', memberId);+ return ghostCommon+ .records(member['newsletters'])+ .map((newsletter) => newsletter['id'])+ .filter((id): id is string => typeof id === 'string');+};++export const saveNewsletters = async ({ auth, memberId, ids }: { auth: GhostAuthValue; memberId: string; ids: string[] }) =>+ ghostResource.edit(auth, 'members', memberId, {+ newsletters: ids.map((id) => ({ id })),+ });++export const requireIds = (value: unknown): string[] => {+ const ids = ghostCommon.stringList(value);+ if (!ids) {+ throw new Error('Provide at least one newsletter ID, from List Newsletters.');+ }+ return ids;+};++// Ghost wraps bulk stats in `bulk.meta` (core/server/api/endpoints/utils/serializers/output/members.js bulkAction).+type BulkUnsubscribeResponse = {+ bulk?: { meta?: { stats?: { unsuccessful?: number }; errors?: unknown[] } };+};++export const unsubscribeFromNewsletter = async ({+ auth,+ memberId,+ newsletterId,+}: {+ auth: GhostAuthValue;+ memberId: string;+ newsletterId: string;+}) => {+ const response = await ghostClient.request<BulkUnsubscribeResponse>({+ auth,+ method: HttpMethod.PUT,+ path: '/members/bulk',+ query: { filter: `id:${ghostCommon.nqlString(memberId)}` },+ body: { bulk: { action: 'unsubscribe', newsletter: newsletterId } },+ });+ if ((response.bulk?.meta?.stats?.unsuccessful ?? 0) > 0) {+ throw new Error(`Ghost could not remove the newsletter subscription: ${JSON.stringify(response.bulk?.meta?.errors ?? [])}`);+ }+};diff --git a/packages/pieces/community/ghostcms/src/lib/common/newsletter-props.ts b/packages/pieces/community/ghostcms/src/lib/common/newsletter-props.tsnew file mode 100644index 00000000000..c4b26e0e06b--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/common/newsletter-props.ts@@ -0,0 +1,48 @@+import { Property } from '@activepieces/pieces-framework';+import { ghostProps } from './ai-props';++export const NEWSLETTER_FIELDS = ['name', 'description', 'sender_name', 'sender_reply_to', 'visibility'];++export const newsletterProps = (mode: 'create' | 'update') => ({+ name: Property.ShortText({+ displayName: 'Name',+ description: 'The newsletter name.',+ required: mode === 'create',+ }),+ description: Property.LongText({+ displayName: 'Description',+ description: 'A description shown to members when they choose newsletters.',+ required: false,+ }),+ sender_name: Property.ShortText({+ displayName: 'Sender Name',+ description: 'The From name of the emails. Defaults to the site title.',+ required: false,+ }),+ sender_reply_to: Property.StaticDropdown({+ displayName: 'Reply-To',+ description: 'Where member replies go.',+ required: false,+ options: {+ options: [+ { label: 'Newsletter sender address', value: 'newsletter' },+ { label: 'Support address', value: 'support' },+ ],+ },+ }),+ visibility: Property.StaticDropdown({+ displayName: 'Audience',+ description: 'Who can subscribe to the newsletter.',+ required: false,+ options: {+ options: [+ { label: 'All members', value: 'members' },+ { label: 'Paid members only', value: 'paid' },+ ],+ },+ }),+ subscribe_on_signup: ghostProps.triState(+ 'Subscribe on Signup',+ 'Automatically subscribe new members to this newsletter.'+ ),+});diff --git a/packages/pieces/community/ghostcms/src/lib/common/resources.ts b/packages/pieces/community/ghostcms/src/lib/common/resources.tsnew file mode 100644index 00000000000..bb5b4fc6fd9--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/common/resources.ts@@ -0,0 +1,90 @@+import { HttpMethod } from '@activepieces/pieces-common';+import { GhostAuthValue, ghostClient, ghostCommon } from './client';++type QueryValue = string | number | boolean | undefined | null;+type Item = Record<string, unknown>;++export const ghostResource = {+ async list(+ auth: GhostAuthValue,+ resource: string,+ query: Record<string, QueryValue>,+ paginated = true+ ) {+ const response = await ghostClient.request<Record<string, unknown>>({+ auth,+ method: HttpMethod.GET,+ path: `/${resource}`,+ query,+ });+ const items = ghostCommon.records(response[resource]);+ return paginated+ ? { [resource]: items, ...ghostCommon.pagination(response['meta']) }+ : { [resource]: items, count: items.length };+ },+ async get(auth: GhostAuthValue, resource: string, path: string, query?: Record<string, QueryValue>) {+ const response = await ghostClient.request<Record<string, Item[]>>({+ auth,+ method: HttpMethod.GET,+ path: `/${resource}/${path}`,+ query,+ });+ return ghostCommon.first(response[resource], resource);+ },+ async create(+ auth: GhostAuthValue,+ resource: string,+ body: Item,+ query?: Record<string, QueryValue>+ ) {+ const response = await ghostClient.request<Record<string, Item[]>>({+ auth,+ method: HttpMethod.POST,+ path: `/${resource}`,+ query,+ body: { [resource]: [body] },+ });+ return ghostCommon.first(response[resource], resource);+ },+ async edit(+ auth: GhostAuthValue,+ resource: string,+ id: string,+ body: Item,+ query?: Record<string, QueryValue>+ ) {+ if (Object.keys(body).length === 0) {+ throw new Error('Provide at least one field to change.');+ }+ const response = await ghostClient.request<Record<string, Item[]>>({+ auth,+ method: HttpMethod.PUT,+ path: `/${resource}/${id}`,+ query,+ body: { [resource]: [body] },+ });+ return ghostCommon.first(response[resource], resource);+ },+ async remove(auth: GhostAuthValue, resource: string, id: string, query?: Record<string, QueryValue>) {+ await ghostClient.request<unknown>({+ auth,+ method: HttpMethod.DELETE,+ path: `/${resource}/${id}`,+ query,+ });+ },+ pick(props: Record<string, unknown>, keys: string[]): Item {+ const body: Item = {};+ for (const key of keys) {+ const value = props[key];+ if (typeof value === 'string') {+ if (value.trim().length > 0) {+ body[key] = value.trim();+ }+ } else if (value !== undefined && value !== null) {+ body[key] = value;+ }+ }+ return body;+ },+};diff --git a/packages/pieces/community/ghostcms/src/lib/common/tag-props.ts b/packages/pieces/community/ghostcms/src/lib/common/tag-props.tsnew file mode 100644index 00000000000..9ba4aff5389--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/common/tag-props.ts@@ -0,0 +1,36 @@+import { Property } from '@activepieces/pieces-framework';++export const TAG_FIELDS = ['name', 'slug', 'description', 'accent_color', 'meta_title', 'meta_description'];++export const tagProps = (mode: 'create' | 'update') => ({+ name: Property.ShortText({+ displayName: 'Name',+ description: 'The tag name. Start it with # to make an internal tag that is hidden from readers.',+ required: mode === 'create',+ }),+ slug: Property.ShortText({+ displayName: 'Slug',+ description: 'The URL slug. Ghost generates one from the name when empty.',+ required: false,+ }),+ description: Property.LongText({+ displayName: 'Description',+ description: 'The tag description shown on its archive page.',+ required: false,+ }),+ accent_color: Property.ShortText({+ displayName: 'Accent Color',+ description: 'A hex color, e.g. #FF5733.',+ required: false,+ }),+ meta_title: Property.ShortText({+ displayName: 'Meta Title',+ description: 'The SEO title of the tag page.',+ required: false,+ }),+ meta_description: Property.LongText({+ displayName: 'Meta Description',+ description: 'The SEO description of the tag page.',+ required: false,+ }),+});diff --git a/packages/pieces/community/ghostcms/src/lib/common/tier-body.ts b/packages/pieces/community/ghostcms/src/lib/common/tier-body.tsnew file mode 100644index 00000000000..5de43866fb8--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/common/tier-body.ts@@ -0,0 +1,24 @@+import { ghostCommon } from './client';+import { ghostResource } from './resources';+import { TIER_FIELDS } from './tier-props';++export const tierBody = (props: Record<string, unknown>) => {+ const body = ghostResource.pick(props, TIER_FIELDS);+ for (const key of ['monthly_price', 'yearly_price', 'trial_days']) {+ if (body[key] !== undefined) {+ const value = Number(body[key]);+ if (!Number.isInteger(value) || value < 0) {+ throw new Error(`${key} must be a whole number of 0 or more.`);+ }+ body[key] = value;+ }+ }+ const currency = body['currency'];+ if (typeof currency === 'string') {+ body['currency'] = currency.toLowerCase();+ }+ if (Array.isArray(props['benefits'])) {+ body['benefits'] = ghostCommon.stringList(props['benefits']) ?? [];+ }+ return body;+};diff --git a/packages/pieces/community/ghostcms/src/lib/common/tier-props.ts b/packages/pieces/community/ghostcms/src/lib/common/tier-props.tsnew file mode 100644index 00000000000..30fce98d433--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/common/tier-props.ts@@ -0,0 +1,70 @@+import { Property } from '@activepieces/pieces-framework';++export const TIER_QUERY = { include: 'monthly_price,yearly_price,benefits' };++export const TIER_FIELDS = [+ 'name',+ 'description',+ 'monthly_price',+ 'yearly_price',+ 'currency',+ 'visibility',+ 'welcome_page_url',+ 'trial_days',+];++export const tierProps = (mode: 'create' | 'update') => ({+ name: Property.ShortText({+ displayName: 'Name',+ description: 'The tier name shown on the pricing page.',+ required: mode === 'create',+ }),+ description: Property.LongText({+ displayName: 'Description',+ description: 'A short description shown on the pricing page.',+ required: false,+ }),+ monthly_price: Property.Number({+ displayName: 'Monthly Price',+ description: 'The monthly price in the smallest currency unit, e.g. 500 for 5.00 USD.',+ required: false,+ }),+ yearly_price: Property.Number({+ displayName: 'Yearly Price',+ description: 'The yearly price in the smallest currency unit, e.g. 5000 for 50.00 USD.',+ required: false,+ }),+ currency: Property.ShortText({+ displayName: 'Currency',+ description: 'The three-letter currency code, e.g. usd. Required with a price.',+ required: false,+ }),+ benefits: Property.Array({+ displayName: 'Benefits',+ description: `The benefit lines shown on the pricing page.${+ mode === 'update' ? ' Supplying benefits replaces the full list, and an empty list removes every benefit.' : ''+ }`,+ required: false,+ }),+ visibility: Property.StaticDropdown({+ displayName: 'Visibility',+ description: 'Whether the tier is shown on the public pricing page.',+ required: false,+ options: {+ options: [+ { label: 'Public', value: 'public' },+ { label: 'Hidden', value: 'none' },+ ],+ },+ }),+ welcome_page_url: Property.ShortText({+ displayName: 'Welcome Page URL',+ description: 'Where new subscribers of this tier land after signup.',+ required: false,+ }),+ trial_days: Property.Number({+ displayName: 'Trial Days',+ description: 'The free trial length in days. 0 for no trial.',+ required: false,+ }),+});diff --git a/packages/pieces/community/ghostcms/src/lib/common/webhooks.ts b/packages/pieces/community/ghostcms/src/lib/common/webhooks.tsnew file mode 100644index 00000000000..d73a4fd87fa--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/common/webhooks.ts@@ -0,0 +1,150 @@+import { HttpMethod } from '@activepieces/pieces-common';+import crypto from 'crypto';+import { GhostApiError, GhostAuthValue, ghostClient, ghostCommon } from './client';++type WebhookStore = {+ put(key: string, value: StoredWebhook): Promise<unknown>;+ get(key: string): Promise<unknown>;+ delete(key: string): Promise<void>;+};++type StoredWebhook = { webhookId: string; secret?: string };++const SIGNATURE_HEADER = 'x-ghost-signature';++const storedWebhookOf = (value: unknown): StoredWebhook | null => {+ if (!ghostCommon.isRecord(value) || typeof value['webhookId'] !== 'string') {+ return null;+ }+ return {+ webhookId: value['webhookId'],+ secret: typeof value['secret'] === 'string' ? value['secret'] : undefined,+ };+};++const deleteWebhook = async ({ auth, webhookId }: { auth: GhostAuthValue; webhookId: string }) => {+ try {+ await ghostClient.request<unknown>({+ auth,+ method: HttpMethod.DELETE,+ path: `/webhooks/${encodeURIComponent(webhookId)}`,+ });+ } catch (error) {+ if (error instanceof GhostApiError && error.status === 404) {+ return;+ }+ throw error;+ }+};++const signatureHeaderOf = (headers: unknown): string | undefined => {+ if (!ghostCommon.isRecord(headers)) {+ return undefined;+ }+ const name = Object.keys(headers).find((key) => key.toLowerCase() === SIGNATURE_HEADER);+ const value = name ? headers[name] : undefined;+ return typeof value === 'string' ? value : undefined;+};++const signatureMatches = ({+ secret,+ rawBody,+ signatureHeader,+}: {+ secret: string;+ rawBody: unknown;+ signatureHeader: string | undefined;+}): boolean => {+ if (!signatureHeader || !(typeof rawBody === 'string' || Buffer.isBuffer(rawBody))) {+ return false;+ }+ const parts: Record<string, string> = {};+ for (const part of signatureHeader.split(',')) {+ const [key, ...rest] = part.trim().split('=');+ if (key && rest.length > 0) {+ parts[key] = rest.join('=');+ }+ }+ const provided = parts['sha256'];+ const timestamp = parts['t'];+ if (!provided || !timestamp) {+ return false;+ }+ const expected = crypto+ .createHmac('sha256', secret)+ .update(Buffer.concat([Buffer.isBuffer(rawBody) ? rawBody : Buffer.from(rawBody), Buffer.from(timestamp)]))+ .digest();+ const providedBytes = Buffer.from(provided, 'hex');+ return providedBytes.length === expected.length && crypto.timingSafeEqual(providedBytes, expected);+};++export const ghostWebhook = {+ async enable({+ auth,+ event,+ webhookUrl,+ store,+ storeKey,+ }: {+ auth: GhostAuthValue;+ event: string;+ webhookUrl: string;+ store: WebhookStore;+ storeKey: string;+ }): Promise<void> {+ const secret = crypto.randomBytes(32).toString('hex');+ const response = await ghostClient.request<{ webhooks?: { id?: string }[] }>({+ auth,+ method: HttpMethod.POST,+ path: '/webhooks',+ body: { webhooks: [{ event, target_url: webhookUrl, secret }] },+ });+ const webhookId = response.webhooks?.[0]?.id;+ if (!webhookId) {+ throw new Error(`Ghost did not return an ID for the ${event} webhook.`);+ }+ try {+ await store.put(storeKey, { webhookId, secret });+ } catch (error) {+ await deleteWebhook({ auth, webhookId });+ throw error;+ }+ },+ async disable({+ auth,+ store,+ storeKey,+ }: {+ auth: GhostAuthValue;+ store: WebhookStore;+ storeKey: string;+ }): Promise<void> {+ const stored = storedWebhookOf(await store.get(storeKey));+ if (!stored) {+ return;+ }+ await deleteWebhook({ auth, webhookId: stored.webhookId });+ await store.delete(storeKey);+ },+ async assertSigned({+ store,+ storeKey,+ rawBody,+ headers,+ }: {+ store: WebhookStore;+ storeKey: string;+ rawBody: unknown;+ headers: unknown;+ }): Promise<void> {+ const stored = storedWebhookOf(await store.get(storeKey));+ if (!stored?.secret) {+ return;+ }+ if (!signatureMatches({ secret: stored.secret, rawBody, signatureHeader: signatureHeaderOf(headers) })) {+ throw new Error(+ 'The X-Ghost-Signature header did not match the secret this trigger registered with Ghost, so the request was not accepted.'+ );+ }+ },+};diff --git a/packages/pieces/community/ghostcms/src/lib/output-schemas.ts b/packages/pieces/community/ghostcms/src/lib/output-schemas.tsnew file mode 100644index 00000000000..88133de6b49--- /dev/null+++ b/packages/pieces/community/ghostcms/src/lib/output-schemas.ts@@ -0,0 +1,619 @@+import { OutputSchema } from '@activepieces/pieces-framework';++type Fields = OutputSchema['fields'];++const paginationFields: Fields = [+ { key: 'page', label: 'Page', format: 'number' },+ { key: 'limit', label: 'Limit' },+ { key: 'total_pages', label: 'Total Pages', format: 'number' },+ { key: 'total', label: 'Total', format: 'number' },+ { key: 'next', label: 'Next Page', format: 'number' },+ { key: 'prev', label: 'Previous Page', format: 'number' },+];++const tagFields: Fields = [+ { key: 'id', label: 'Tag ID' },+ { key: 'name', label: 'Name' },+ { key: 'slug', label: 'Slug' },+ { key: 'description', label: 'Description' },+ { key: 'visibility', label: 'Visibility' },+ { key: 'accent_color', label: 'Accent Color' },+ { key: 'feature_image', label: 'Feature Image', format: 'image' },+ { key: 'meta_title', label: 'Meta Title' },+ { key: 'meta_description', label: 'Meta Description' },+ { key: 'url', label: 'URL', format: 'url' },+ { key: 'created_at', label: 'Created At', format: 'datetime' },+ { key: 'updated_at', label: 'Updated At', format: 'datetime' },+];++const tagWithCountFields: Fields = [+ ...tagFields,+ {+ key: 'count',+ label: 'Count',+ children: [{ key: 'posts', label: 'Posts', format: 'number' }],+ },+];++const authorFields: Fields = [+ { key: 'id', label: 'User ID' },+ { key: 'name', label: 'Name' },+ { key: 'slug', label: 'Slug' },+ { key: 'email', label: 'Email', format: 'email' },+ { key: 'status', label: 'Status' },+ { key: 'profile_image', label: 'Profile Image', format: 'image' },+ { key: 'bio', label: 'Bio' },+ { key: 'website', label: 'Website', format: 'url' },+ { key: 'location', label: 'Location' },+ { key: 'url', label: 'Author Page URL', format: 'url' },+];++const userBaseFields: Fields = [+ ...authorFields,+ { key: 'cover_image', label: 'Cover Image', format: 'image' },+ { key: 'last_seen', label: 'Last Seen', format: 'datetime' },+ { key: 'created_at', label: 'Created At', format: 'datetime' },+ { key: 'updated_at', label: 'Updated At', format: 'datetime' },+];++const userFields: Fields = [+ ...userBaseFields,+ {+ key: 'roles',+ label: 'Roles',+ labelKey: 'name',+ listItems: [+ { key: 'id', label: 'Role ID' },+ { key: 'name', label: 'Name' },+ { key: 'description', label: 'Description' },+ ],+ },+ {+ key: 'count',+ label: 'Count',+ children: [{ key: 'posts', label: 'Posts', format: 'number' }],+ },+];++const contentBaseFields: Fields = [+ { key: 'id', label: 'ID' },+ { key: 'uuid', label: 'UUID' },+ { key: 'title', label: 'Title' },+ { key: 'slug', label: 'Slug' },+ { key: 'status', label: 'Status' },+ { key: 'visibility', label: 'Visibility' },+ { key: 'url', label: 'URL', format: 'url' },+ { key: 'html', label: 'HTML', format: 'html' },+ { key: 'excerpt', label: 'Excerpt' },+ { key: 'custom_excerpt', label: 'Custom Excerpt' },+ { key: 'featured', label: 'Featured', format: 'boolean' },+ { key: 'feature_image', label: 'Feature Image', format: 'image' },+ { key: 'feature_image_alt', label: 'Feature Image Alt Text' },+ { key: 'feature_image_caption', label: 'Feature Image Caption' },+ { key: 'reading_time', label: 'Reading Time (minutes)', format: 'number' },+ { key: 'meta_title', label: 'Meta Title' },+ { key: 'meta_description', label: 'Meta Description' },+ { key: 'canonical_url', label: 'Canonical URL', format: 'url' },+ { key: 'created_at', label: 'Created At', format: 'datetime' },+ { key: 'updated_at', label: 'Updated At', format: 'datetime' },+ { key: 'published_at', label: 'Published At', format: 'datetime' },+ { key: 'tags', label: 'Tags', labelKey: 'name', listItems: tagFields },+ { key: 'authors', label: 'Authors', labelKey: 'name', listItems: authorFields },+ { key: 'primary_tag', label: 'Primary Tag', children: tagFields },+ { key: 'primary_author', label: 'Primary Author', children: authorFields },+];++const postFields: Fields = [+ ...contentBaseFields,+ { key: 'email_only', label: 'Email Only', format: 'boolean' },+ { key: 'email_segment', label: 'Email Segment' },+ { key: 'email_subject', label: 'Email Subject' },+];++const pageFields: Fields = [+ ...contentBaseFields,+ {+ key: 'show_title_and_feature_image',+ label: 'Show Title and Feature Image',+ format: 'boolean',+ },+];++const labelFields: Fields = [+ { key: 'id', label: 'Label ID' },+ { key: 'name', label: 'Name' },+ { key: 'slug', label: 'Slug' },+ { key: 'created_at', label: 'Created At', format: 'datetime' },+ { key: 'updated_at', label: 'Updated At', format: 'datetime' },+];++const labelWithCountFields: Fields = [+ ...labelFields,+ {+ key: 'count',+ label: 'Count',+ children: [{ key: 'members', label: 'Members', format: 'number' }],+ },+];++const memberNewsletterFields: Fields = [+ { key: 'id', label: 'Newsletter ID' },+ { key: 'name', label: 'Name' },+ { key: 'description', label: 'Description' },+ { key: 'status', label: 'Status' },+];++const memberCoreFields: Fields = [+ { key: 'id', label: 'Member ID' },+ { key: 'uuid', label: 'UUID' },+ { key: 'email', label: 'Email', format: 'email' },+ { key: 'name', label: 'Name' },+ { key: 'note', label: 'Note' },+ { key: 'status', label: 'Status' },+ { key: 'geolocation', label: 'Geolocation' },+ { key: 'email_count', label: 'Emails Received', format: 'number' },+ { key: 'email_opened_count', label: 'Emails Opened', format: 'number' },+ { key: 'email_open_rate', label: 'Email Open Rate', format: 'number' },+ { key: 'last_seen_at', label: 'Last Seen At', format: 'datetime' },+ { key: 'created_at', label: 'Created At', format: 'datetime' },+ { key: 'updated_at', label: 'Updated At', format: 'datetime' },+ { key: 'labels', label: 'Labels', labelKey: 'name', listItems: labelFields },+ {+ key: 'newsletters',+ label: 'Newsletters',+ labelKey: 'name',+ listItems: memberNewsletterFields,+ },+];++const memberListFields: Fields = [+ ...memberCoreFields,+ { key: 'subscribed', label: 'Subscribed', format: 'boolean' },+ { key: 'comped', label: 'Comped', format: 'boolean' },+ { key: 'avatar_image', label: 'Avatar Image', format: 'image' },+];++const memberFields: Fields = [...memberListFields, { key: 'tiers', label: 'Tiers' }];++const memberWithAttributionFields: Fields = [+ ...memberFields,+ { key: 'unsubscribe_url', label: 'Unsubscribe URL', format: 'url' },+ {+ key: 'attribution',+ label: 'Attribution',+ children: [+ { key: 'referrer_source', label: 'Referrer Source' },+ { key: 'referrer_medium', label: 'Referrer Medium' },+ { key: 'referrer_url', label: 'Referrer URL', format: 'url' },+ { key: 'url', label: 'Signup Page URL', format: 'url' },+ { key: 'title', label: 'Signup Page Title' },+ ],+ },+];++const newsletterFields: Fields = [+ { key: 'id', label: 'Newsletter ID' },+ { key: 'uuid', label: 'UUID' },+ { key: 'name', label: 'Name' },+ { key: 'slug', label: 'Slug' },+ { key: 'description', label: 'Description' },+ { key: 'status', label: 'Status' },+ { key: 'visibility', label: 'Visibility' },+ { key: 'subscribe_on_signup', label: 'Subscribe on Signup', format: 'boolean' },+ { key: 'sender_name', label: 'Sender Name' },+ { key: 'sender_email', label: 'Sender Email', format: 'email' },+ { key: 'sender_reply_to', label: 'Reply To' },+ { key: 'sort_order', label: 'Sort Order', format: 'number' },+ { key: 'created_at', label: 'Created At', format: 'datetime' },+ { key: 'updated_at', label: 'Updated At', format: 'datetime' },+];++const tierFields: Fields = [+ { key: 'id', label: 'Tier ID' },+ { key: 'name', label: 'Name' },+ { key: 'slug', label: 'Slug' },+ { key: 'description', label: 'Description' },+ { key: 'type', label: 'Type' },+ { key: 'active', label: 'Active', format: 'boolean' },+ { key: 'visibility', label: 'Visibility' },+ { key: 'welcome_page_url', label: 'Welcome Page URL', format: 'url' },+ { key: 'trial_days', label: 'Trial Days', format: 'number' },+ { key: 'benefits', label: 'Benefits' },+ { key: 'created_at', label: 'Created At', format: 'datetime' },+ { key: 'updated_at', label: 'Updated At', format: 'datetime' },+];++const tierWithPriceFields: Fields = [+ ...tierFields,+ { key: 'currency', label: 'Currency' },+ { key: 'monthly_price', label: 'Monthly Price (cents)', format: 'number' },+ { key: 'yearly_price', label: 'Yearly Price (cents)', format: 'number' },+];++const offerFields: Fields = [+ { key: 'id', label: 'Offer ID' },+ { key: 'name', label: 'Name' },+ { key: 'code', label: 'Code' },+ { key: 'display_title', label: 'Display Title' },+ { key: 'display_description', label: 'Display Description' },+ { key: 'type', label: 'Discount Type' },+ { key: 'amount', label: 'Amount', format: 'number' },+ { key: 'currency', label: 'Currency' },+ { key: 'cadence', label: 'Cadence' },+ { key: 'duration', label: 'Duration' },+ { key: 'duration_in_months', label: 'Duration in Months', format: 'number' },+ { key: 'status', label: 'Status' },+ { key: 'redemption_count', label: 'Redemptions', format: 'number' },+ { key: 'redemption_type', label: 'Redemption Type' },+ { key: 'created_at', label: 'Created At', format: 'datetime' },+ { key: 'last_redeemed', label: 'Last Redeemed', format: 'datetime' },+];++const offerWithTierFields: Fields = [+ ...offerFields,+ {+ key: 'tier',+ label: 'Tier',+ children: [+ { key: 'id', label: 'Tier ID' },+ { key: 'name', label: 'Name' },+ ],+ },+];++const createdOfferFields: Fields = [+ ...offerFields,+ { key: 'tier', label: 'Tier', children: [{ key: 'id', label: 'Tier ID' }] },+];++const emailFields: Fields = [+ { key: 'id', label: 'Email ID' },+ { key: 'status', label: 'Status' },+ { key: 'subject', label: 'Subject' },+ { key: 'recipient_filter', label: 'Recipient Filter' },+ { key: 'email_count', label: 'Recipients', format: 'number' },+ { key: 'delivered_count', label: 'Delivered', format: 'number' },+ { key: 'opened_count', label: 'Opened', format: 'number' },+ { key: 'failed_count', label: 'Failed', format: 'number' },+ { key: 'submitted_at', label: 'Submitted At', format: 'datetime' },+ { key: 'newsletter_id', label: 'Newsletter ID' },+ { key: 'error', label: 'Error' },+];++const publishedPostFields: Fields = [+ ...postFields,+ { key: 'email', label: 'Email', children: emailFields },+ {+ key: 'newsletter',+ label: 'Newsletter',+ children: [+ { key: 'id', label: 'Newsletter ID' },+ { key: 'name', label: 'Name' },+ { key: 'slug', label: 'Slug' },+ { key: 'status', label: 'Status' },+ ],+ },+];++const listSchema = ({+ key,+ label,+ labelKey,+ items,+}: {+ key: string;+ label: string;+ labelKey: string;+ items: Fields;+}): OutputSchema => ({+ fields: [{ key, label, labelKey, listItems: items }, ...paginationFields],+});++const deleteSchema = ({ idKey, idLabel }: { idKey: string; idLabel: string }): OutputSchema => ({+ fields: [+ { key: 'success', label: 'Success', format: 'boolean' },+ { key: idKey, label: idLabel },+ ],+});++export const ghostPostOutputSchema: OutputSchema = { fields: postFields };+export const ghostPublishPostOutputSchema: OutputSchema = { fields: publishedPostFields };+export const ghostListPostsOutputSchema = listSchema({ key: 'posts', label: 'Posts', labelKey: 'title', items: postFields });+export const ghostDeletePostOutputSchema = deleteSchema({ idKey: 'post_id', idLabel: 'Post ID' });++export const ghostPageOutputSchema: OutputSchema = { fields: pageFields };+export const ghostListPagesOutputSchema = listSchema({ key: 'pages', label: 'Pages', labelKey: 'title', items: pageFields });+export const ghostDeletePageOutputSchema = deleteSchema({ idKey: 'page_id', idLabel: 'Page ID' });++export const ghostTagOutputSchema: OutputSchema = { fields: tagWithCountFields };+export const ghostCreateTagOutputSchema: OutputSchema = { fields: tagFields };+export const ghostListTagsOutputSchema = listSchema({ key: 'tags', label: 'Tags', labelKey: 'name', items: tagWithCountFields });+export const ghostDeleteTagOutputSchema = deleteSchema({ idKey: 'tag_id', idLabel: 'Tag ID' });++export const ghostMemberOutputSchema: OutputSchema = { fields: memberWithAttributionFields };+export const ghostListMembersOutputSchema = listSchema({ key: 'members', label: 'Members', labelKey: 'email', items: memberListFields });+export const ghostGetMemberByEmailOutputSchema: OutputSchema = {+ fields: [+ { key: 'found', label: 'Found', format: 'boolean' },+ { key: 'member', label: 'Member', children: memberListFields },+ ],+};+export const ghostDeleteMemberOutputSchema: OutputSchema = {+ fields: [+ { key: 'success', label: 'Success', format: 'boolean' },+ { key: 'member_id', label: 'Member ID' },+ {+ key: 'stripe_subscriptions_cancelled',+ label: 'Stripe Subscriptions Cancelled',+ format: 'boolean',+ },+ ],+};++export const ghostLabelOutputSchema: OutputSchema = { fields: labelWithCountFields };+export const ghostCreateLabelOutputSchema: OutputSchema = { fields: labelFields };+export const ghostListLabelsOutputSchema = listSchema({ key: 'labels', label: 'Labels', labelKey: 'name', items: labelWithCountFields });+export const ghostDeleteLabelOutputSchema = deleteSchema({ idKey: 'label_id', idLabel: 'Label ID' });++export const ghostNewsletterOutputSchema: OutputSchema = { fields: newsletterFields };+export const ghostListNewslettersOutputSchema = listSchema({ key: 'newsletters', label: 'Newsletters', labelKey: 'name', items: newsletterFields });++export const ghostTierOutputSchema: OutputSchema = { fields: tierWithPriceFields };+export const ghostListTiersOutputSchema = listSchema({ key: 'tiers', label: 'Tiers', labelKey: 'name', items: tierWithPriceFields });++export const ghostOfferOutputSchema: OutputSchema = { fields: offerWithTierFields };+export const ghostCreateOfferOutputSchema: OutputSchema = { fields: createdOfferFields };+export const ghostListOffersOutputSchema: OutputSchema = {+ fields: [+ { key: 'offers', label: 'Offers', labelKey: 'name', listItems: offerWithTierFields },+ { key: 'count', label: 'Count', format: 'number' },+ ],+};++export const ghostUserOutputSchema: OutputSchema = { fields: userFields };+export const ghostListUsersOutputSchema = listSchema({ key: 'users', label: 'Users', labelKey: 'name', items: userFields });+export const ghostGetUserByEmailOutputSchema: OutputSchema = {+ fields: [+ { key: 'found', label: 'Found', format: 'boolean' },+ { key: 'user', label: 'User', children: userFields },+ ],+};++export const ghostUploadImageOutputSchema: OutputSchema = {+ fields: [+ { key: 'url', label: 'Image URL', format: 'image' },+ { key: 'ref', label: 'Reference' },+ ],+};+export const ghostUploadFileOutputSchema: OutputSchema = {+ fields: [+ { key: 'url', label: 'File URL', format: 'url' },+ { key: 'ref', label: 'Reference' },+ ],+};+export const ghostUploadMediaOutputSchema: OutputSchema = {+ fields: [+ { key: 'url', label: 'Media URL', format: 'url' },+ { key: 'thumbnail_url', label: 'Thumbnail URL', format: 'image' },+ { key: 'ref', label: 'Reference' },+ ],+};++export const ghostSiteOutputSchema: OutputSchema = {+ fields: [+ { key: 'title', label: 'Title' },+ { key: 'description', label: 'Description' },+ { key: 'url', label: 'URL', format: 'url' },+ { key: 'version', label: 'Ghost Version' },+ { key: 'locale', label: 'Locale' },+ { key: 'timezone', label: 'Timezone' },+ { key: 'accent_color', label: 'Accent Color' },+ { key: 'logo', label: 'Logo', format: 'image' },+ { key: 'icon', label: 'Icon', format: 'image' },+ { key: 'cover_image', label: 'Cover Image', format: 'image' },+ { key: 'allow_external_signup', label: 'Allows External Signup', format: 'boolean' },+ { key: 'site_uuid', label: 'Site UUID' },+ ],+};++const navigationFields: Fields = [+ { key: 'label', label: 'Label' },+ { key: 'url', label: 'URL', format: 'url' },+];++export const ghostSettingsOutputSchema: OutputSchema = {+ fields: [+ { key: 'title', label: 'Title' },+ { key: 'description', label: 'Description' },+ { key: 'timezone', label: 'Timezone' },+ { key: 'locale', label: 'Locale' },+ { key: 'accent_color', label: 'Accent Color' },+ { key: 'logo', label: 'Logo', format: 'image' },+ { key: 'icon', label: 'Icon', format: 'image' },+ { key: 'cover_image', label: 'Cover Image', format: 'image' },+ { key: 'meta_title', label: 'Meta Title' },+ { key: 'meta_description', label: 'Meta Description' },+ { key: 'og_image', label: 'Open Graph Image', format: 'image' },+ { key: 'og_title', label: 'Open Graph Title' },+ { key: 'og_description', label: 'Open Graph Description' },+ { key: 'twitter_image', label: 'X Card Image', format: 'image' },+ { key: 'twitter_title', label: 'X Card Title' },+ { key: 'twitter_description', label: 'X Card Description' },+ { key: 'facebook', label: 'Facebook' },+ { key: 'twitter', label: 'X (Twitter)' },+ { key: 'navigation', label: 'Navigation', labelKey: 'label', listItems: navigationFields },+ {+ key: 'secondary_navigation',+ label: 'Secondary Navigation',+ labelKey: 'label',+ listItems: navigationFields,+ },+ { key: 'active_theme', label: 'Active Theme' },+ { key: 'is_private', label: 'Private Site', format: 'boolean' },+ { key: 'default_content_visibility', label: 'Default Content Visibility' },+ { key: 'members_enabled', label: 'Members Enabled', format: 'boolean' },+ { key: 'members_invite_only', label: 'Members Invite Only', format: 'boolean' },+ { key: 'members_signup_access', label: 'Member Signup Access' },+ { key: 'members_support_address', label: 'Members Support Address' },+ { key: 'paid_members_enabled', label: 'Paid Members Enabled', format: 'boolean' },+ { key: 'portal_name', label: 'Portal Asks for Name', format: 'boolean' },+ { key: 'portal_plans', label: 'Portal Plans' },+ { key: 'portal_default_plan', label: 'Portal Default Plan' },+ { key: 'comments_enabled', label: 'Comments Enabled' },+ { key: 'recommendations_enabled', label: 'Recommendations Enabled', format: 'boolean' },+ { key: 'email_track_opens', label: 'Track Email Opens', format: 'boolean' },+ { key: 'email_track_clicks', label: 'Track Email Clicks', format: 'boolean' },+ { key: 'donations_enabled', label: 'Donations Enabled', format: 'boolean' },+ { key: 'donations_currency', label: 'Donations Currency' },+ { key: 'donations_suggested_amount', label: 'Suggested Donation (cents)', format: 'number' },+ { key: 'editor_default_email_recipients', label: 'Default Email Recipients' },+ { key: 'default_email_address', label: 'Default Email Address', format: 'email' },+ { key: 'support_email_address', label: 'Support Email Address', format: 'email' },+ ],+};++export const ghostMemberStatsOutputSchema: OutputSchema = {+ fields: [+ { key: 'total', label: 'Total Members', format: 'number' },+ { key: 'free', label: 'Free', format: 'number' },+ { key: 'paid', label: 'Paid', format: 'number' },+ { key: 'comped', label: 'Comped', format: 'number' },+ { key: 'gift', label: 'Gift', format: 'number' },+ { key: 'as_of', label: 'As Of', format: 'date' },+ {+ key: 'history',+ label: 'History',+ labelKey: 'date',+ listItems: [+ { key: 'date', label: 'Date', format: 'date' },+ { key: 'free', label: 'Free', format: 'number' },+ { key: 'paid', label: 'Paid', format: 'number' },+ { key: 'comped', label: 'Comped', format: 'number' },+ { key: 'gift', label: 'Gift', format: 'number' },+ ],+ },+ ],+};++export const ghostListMemberActivityOutputSchema: OutputSchema = {+ fields: [+ {+ key: 'events',+ label: 'Events',+ labelKey: 'type',+ listItems: [+ { key: 'type', label: 'Event Type' },+ { key: 'id', label: 'Event ID' },+ { key: 'created_at', label: 'Created At', format: 'datetime' },+ { key: 'member_id', label: 'Member ID' },+ { key: 'member_name', label: 'Member Name' },+ { key: 'member_email', label: 'Member Email', format: 'email' },+ { key: 'data', label: 'Event Data' },+ ],+ },+ { key: 'count', label: 'Count', format: 'number' },+ { key: 'total', label: 'Total', format: 'number' },+ ],+};++export const ghostOriginalMembersOutputSchema: OutputSchema = {+ fields: [+ { key: 'members', label: 'Members', labelKey: 'email', listItems: memberWithAttributionFields },+ ],+};++export const ghostOriginalFindMemberOutputSchema: OutputSchema = {+ fields: [{ key: 'members', label: 'Members', labelKey: 'email', listItems: memberListFields }],+};++export const ghostOriginalFindUserOutputSchema: OutputSchema = {+ fields: [{ key: 'users', label: 'Users', labelKey: 'name', listItems: userBaseFields }],+};++export const ghostOriginalCreatePostOutputSchema: OutputSchema = {+ fields: [+ {+ key: 'posts',+ label: 'Posts',+ labelKey: 'title',+ listItems: postFields.filter((field) => field.key !== 'html'),+ },+ ],+};++const triggerPostPreviousFields: Fields = [+ { key: 'status', label: 'Previous Status' },+ { key: 'published_at', label: 'Previous Published At', format: 'datetime' },+ { key: 'updated_at', label: 'Previous Updated At', format: 'datetime' },+];++const triggerMemberFields: Fields = memberListFields;++export const ghostMemberAddedTriggerOutputSchema: OutputSchema = {+ fields: [+ { key: 'event', label: 'Event' },+ {+ key: 'member',+ label: 'Member',+ children: [{ key: 'current', label: 'Member', children: triggerMemberFields }],+ },+ ],+};++export const ghostMemberEditedTriggerOutputSchema: OutputSchema = {+ fields: [+ { key: 'event', label: 'Event' },+ {+ key: 'member',+ label: 'Member',+ children: [+ { key: 'current', label: 'Current Member', children: triggerMemberFields },+ {+ key: 'previous',+ label: 'Changed Fields (Previous Values)',+ children: [+ { key: 'name', label: 'Previous Name' },+ { key: 'note', label: 'Previous Note' },+ { key: 'updated_at', label: 'Previous Updated At', format: 'datetime' },+ ],+ },+ ],+ },+ ],+};++export const ghostMemberDeletedTriggerOutputSchema: OutputSchema = {+ fields: [+ { key: 'event', label: 'Event' },+ {+ key: 'member',+ label: 'Member',+ children: [{ key: 'previous', label: 'Deleted Member', children: memberCoreFields }],+ },+ ],+};++export const ghostPostPublishedTriggerOutputSchema: OutputSchema = {+ fields: [+ { key: 'event', label: 'Event' },+ {+ key: 'post',+ label: 'Post',+ children: [+ { key: 'current', label: 'Post', children: postFields },+ { key: 'previous', label: 'Previous Values', children: triggerPostPreviousFields },+ ],+ },+ ],+};++export const ghostPagePublishedTriggerOutputSchema: OutputSchema = {+ fields: [+ { key: 'event', label: 'Event' },+ {+ key: 'page',+ label: 'Page',+ children: [{ key: 'current', label: 'Page', children: pageFields }],+ },+ ],+};diff --git a/packages/pieces/community/ghostcms/src/lib/triggers/member-added.ts b/packages/pieces/community/ghostcms/src/lib/triggers/member-added.tsindex 4afc85cec26..6090ed006be 100644--- a/packages/pieces/community/ghostcms/src/lib/triggers/member-added.ts+++ b/packages/pieces/community/ghostcms/src/lib/triggers/member-added.ts@@ -1,11 +1,13 @@import { TriggerStrategy, createTrigger } from '@activepieces/pieces-framework';-import { ghostAuth } from '../..';-import { common } from '../common';+import { ghostAuth } from '../auth';+import { ghostWebhook } from '../common/webhooks';+import { ghostMemberAddedTriggerOutputSchema } from '../output-schemas';export const memberAdded = createTrigger({auth: ghostAuth,name: 'member_added',+ outputSchema: ghostMemberAddedTriggerOutputSchema,classification: 'READ',displayName: 'Member Added',description: 'Triggers when a new member is added',@@ -15,26 +17,24 @@ export const memberAdded = createTrigger({type: TriggerStrategy.WEBHOOK,props: {},async onEnable(context) {- const webhookData: any = await common.subscribeWebhook(- context.auth,- 'member.added',- context.webhookUrl- );-- await context.store?.put('_member_added_trigger', {- webhookId: webhookData.webhooks[0].id,+ await ghostWebhook.enable({+ auth: context.auth,+ event: 'member.added',+ webhookUrl: context.webhookUrl,+ store: context.store,+ storeKey: '_member_added_trigger',});},async onDisable(context) {- const response: {- webhookId: string;- } | null = await context.store?.get('_member_added_trigger');-- if (response !== null && response !== undefined) {- await common.unsubscribeWebhook(context.auth, response.webhookId);- }+ await ghostWebhook.disable({ auth: context.auth, store: context.store, storeKey: '_member_added_trigger' });},async run(context) {+ await ghostWebhook.assertSigned({+ store: context.store,+ storeKey: '_member_added_trigger',+ rawBody: context.payload.rawBody,+ headers: context.payload.headers,+ });return [context.payload.body];},diff --git a/packages/pieces/community/ghostcms/src/lib/triggers/member-deleted.ts b/packages/pieces/community/ghostcms/src/lib/triggers/member-deleted.tsindex 328586ec325..ccacdccf6e5 100644--- a/packages/pieces/community/ghostcms/src/lib/triggers/member-deleted.ts+++ b/packages/pieces/community/ghostcms/src/lib/triggers/member-deleted.ts@@ -1,11 +1,13 @@import { TriggerStrategy, createTrigger } from '@activepieces/pieces-framework';-import { ghostAuth } from '../..';-import { common } from '../common';+import { ghostAuth } from '../auth';+import { ghostWebhook } from '../common/webhooks';+import { ghostMemberDeletedTriggerOutputSchema } from '../output-schemas';export const memberDeleted = createTrigger({auth: ghostAuth,name: 'member_deleted',+ outputSchema: ghostMemberDeletedTriggerOutputSchema,classification: 'READ',displayName: 'Member Deleted',description: 'Triggers when a member is deleted',@@ -15,26 +17,24 @@ export const memberDeleted = createTrigger({type: TriggerStrategy.WEBHOOK,props: {},async onEnable(context) {- const webhookData: any = await common.subscribeWebhook(- context.auth,- 'member.deleted',- context.webhookUrl- );-- await context.store?.put('_member_deleted_trigger', {- webhookId: webhookData.webhooks[0].id,+ await ghostWebhook.enable({+ auth: context.auth,+ event: 'member.deleted',+ webhookUrl: context.webhookUrl,+ store: context.store,+ storeKey: '_member_deleted_trigger',});},async onDisable(context) {- const response: {- webhookId: string;- } | null = await context.store?.get('_member_deleted_trigger');-- if (response !== null && response !== undefined) {- await common.unsubscribeWebhook(context.auth, response.webhookId);- }+ await ghostWebhook.disable({ auth: context.auth, store: context.store, storeKey: '_member_deleted_trigger' });},async run(context) {+ await ghostWebhook.assertSigned({+ store: context.store,+ storeKey: '_member_deleted_trigger',+ rawBody: context.payload.rawBody,+ headers: context.payload.headers,+ });return [context.payload.body];},diff --git a/packages/pieces/community/ghostcms/src/lib/triggers/member-edited.ts b/packages/pieces/community/ghostcms/src/lib/triggers/member-edited.tsindex 067f5c42cda..597160bdb0a 100644--- a/packages/pieces/community/ghostcms/src/lib/triggers/member-edited.ts+++ b/packages/pieces/community/ghostcms/src/lib/triggers/member-edited.ts@@ -1,11 +1,13 @@import { TriggerStrategy, createTrigger } from '@activepieces/pieces-framework';-import { ghostAuth } from '../..';-import { common } from '../common';+import { ghostAuth } from '../auth';+import { ghostWebhook } from '../common/webhooks';+import { ghostMemberEditedTriggerOutputSchema } from '../output-schemas';export const memberEdited = createTrigger({auth: ghostAuth,name: 'member_edited',+ outputSchema: ghostMemberEditedTriggerOutputSchema,classification: 'READ',displayName: 'Member Edited',description: 'Triggers when a member is edited',@@ -15,26 +17,24 @@ export const memberEdited = createTrigger({type: TriggerStrategy.WEBHOOK,props: {},async onEnable(context) {- const webhookData: any = await common.subscribeWebhook(- context.auth,- 'member.edited',- context.webhookUrl- );-- await context.store?.put('_member_edited_trigger', {- webhookId: webhookData.webhooks[0].id,+ await ghostWebhook.enable({+ auth: context.auth,+ event: 'member.edited',+ webhookUrl: context.webhookUrl,+ store: context.store,+ storeKey: '_member_edited_trigger',});},async onDisable(context) {- const response: {- webhookId: string;- } | null = await context.store?.get('_member_edited_trigger');-- if (response !== null && response !== undefined) {- await common.unsubscribeWebhook(context.auth, response.webhookId);- }+ await ghostWebhook.disable({ auth: context.auth, store: context.store, storeKey: '_member_edited_trigger' });},async run(context) {+ await ghostWebhook.assertSigned({+ store: context.store,+ storeKey: '_member_edited_trigger',+ rawBody: context.payload.rawBody,+ headers: context.payload.headers,+ });const payload = context.payload.body as any;if (payload.event != 'member.edited') {return [];diff --git a/packages/pieces/community/ghostcms/src/lib/triggers/page-published.ts b/packages/pieces/community/ghostcms/src/lib/triggers/page-published.tsindex e9ff0acb0dc..13d079e3c66 100644--- a/packages/pieces/community/ghostcms/src/lib/triggers/page-published.ts+++ b/packages/pieces/community/ghostcms/src/lib/triggers/page-published.ts@@ -1,11 +1,13 @@import { TriggerStrategy, createTrigger } from '@activepieces/pieces-framework';-import { ghostAuth } from '../..';-import { common } from '../common';+import { ghostAuth } from '../auth';+import { ghostWebhook } from '../common/webhooks';+import { ghostPagePublishedTriggerOutputSchema } from '../output-schemas';export const pagePublished = createTrigger({auth: ghostAuth,name: 'page_published',+ outputSchema: ghostPagePublishedTriggerOutputSchema,classification: 'READ',displayName: 'Page Published',description: 'Triggers when a page is published',@@ -15,26 +17,24 @@ export const pagePublished = createTrigger({type: TriggerStrategy.WEBHOOK,props: {},async onEnable(context) {- const webhookData: any = await common.subscribeWebhook(- context.auth,- 'page.published',- context.webhookUrl- );-- await context.store?.put('_page_published_trigger', {- webhookId: webhookData.webhooks[0].id,+ await ghostWebhook.enable({+ auth: context.auth,+ event: 'page.published',+ webhookUrl: context.webhookUrl,+ store: context.store,+ storeKey: '_page_published_trigger',});},async onDisable(context) {- const response: {- webhookId: string;- } | null = await context.store?.get('_page_published_trigger');-- if (response !== null && response !== undefined) {- await common.unsubscribeWebhook(context.auth, response.webhookId);- }+ await ghostWebhook.disable({ auth: context.auth, store: context.store, storeKey: '_page_published_trigger' });},async run(context) {+ await ghostWebhook.assertSigned({+ store: context.store,+ storeKey: '_page_published_trigger',+ rawBody: context.payload.rawBody,+ headers: context.payload.headers,+ });return [context.payload.body];},diff --git a/packages/pieces/community/ghostcms/src/lib/triggers/post-published.ts b/packages/pieces/community/ghostcms/src/lib/triggers/post-published.tsindex 09cee27c41f..b29ac4fadc7 100644--- a/packages/pieces/community/ghostcms/src/lib/triggers/post-published.ts+++ b/packages/pieces/community/ghostcms/src/lib/triggers/post-published.ts@@ -1,11 +1,13 @@import { TriggerStrategy, createTrigger } from '@activepieces/pieces-framework';-import { ghostAuth } from '../..';-import { common } from '../common';+import { ghostAuth } from '../auth';+import { ghostWebhook } from '../common/webhooks';+import { ghostPostPublishedTriggerOutputSchema } from '../output-schemas';export const postPublished = createTrigger({auth: ghostAuth,name: 'post_published',+ outputSchema: ghostPostPublishedTriggerOutputSchema,classification: 'READ',displayName: 'Post Published',description: 'Triggers when a post is published',@@ -15,26 +17,24 @@ export const postPublished = createTrigger({type: TriggerStrategy.WEBHOOK,props: {},async onEnable(context) {- const webhookData: any = await common.subscribeWebhook(- context.auth,- 'post.published',- context.webhookUrl- );-- await context.store?.put('_post_published_trigger', {- webhookId: webhookData.webhooks[0].id,+ await ghostWebhook.enable({+ auth: context.auth,+ event: 'post.published',+ webhookUrl: context.webhookUrl,+ store: context.store,+ storeKey: '_post_published_trigger',});},async onDisable(context) {- const response: {- webhookId: string;- } | null = await context.store?.get('_post_published_trigger');-- if (response !== null && response !== undefined) {- await common.unsubscribeWebhook(context.auth, response.webhookId);- }+ await ghostWebhook.disable({ auth: context.auth, store: context.store, storeKey: '_post_published_trigger' });},async run(context) {+ await ghostWebhook.assertSigned({+ store: context.store,+ storeKey: '_post_published_trigger',+ rawBody: context.payload.rawBody,+ headers: context.payload.headers,+ });return [context.payload.body];},diff --git a/packages/pieces/community/ghostcms/src/lib/triggers/post-scheduled.ts b/packages/pieces/community/ghostcms/src/lib/triggers/post-scheduled.tsindex dad3c1cee99..d0518519b0a 100644--- a/packages/pieces/community/ghostcms/src/lib/triggers/post-scheduled.ts+++ b/packages/pieces/community/ghostcms/src/lib/triggers/post-scheduled.ts@@ -1,11 +1,13 @@import { TriggerStrategy, createTrigger } from '@activepieces/pieces-framework';-import { ghostAuth } from '../..';-import { common } from '../common';+import { ghostAuth } from '../auth';+import { ghostWebhook } from '../common/webhooks';+import { ghostPostPublishedTriggerOutputSchema } from '../output-schemas';export const postScheduled = createTrigger({auth: ghostAuth,name: 'post_scheduled',+ outputSchema: ghostPostPublishedTriggerOutputSchema,classification: 'READ',displayName: 'Post Scheduled',description: 'Triggers when a post is scheduled',@@ -15,26 +17,24 @@ export const postScheduled = createTrigger({type: TriggerStrategy.WEBHOOK,props: {},async onEnable(context) {- const webhookData: any = await common.subscribeWebhook(- context.auth,- 'post.scheduled',- context.webhookUrl- );-- await context.store?.put('_post_scheduled_trigger', {- webhookId: webhookData.webhooks[0].id,+ await ghostWebhook.enable({+ auth: context.auth,+ event: 'post.scheduled',+ webhookUrl: context.webhookUrl,+ store: context.store,+ storeKey: '_post_scheduled_trigger',});},async onDisable(context) {- const response: {- webhookId: string;- } | null = await context.store?.get('_post_scheduled_trigger');-- if (response !== null && response !== undefined) {- await common.unsubscribeWebhook(context.auth, response.webhookId);- }+ await ghostWebhook.disable({ auth: context.auth, store: context.store, storeKey: '_post_scheduled_trigger' });},async run(context) {+ await ghostWebhook.assertSigned({+ store: context.store,+ storeKey: '_post_scheduled_trigger',+ rawBody: context.payload.rawBody,+ headers: context.payload.headers,+ });return [context.payload.body];},diff --git a/packages/pieces/community/ghostcms/test/content.test.ts b/packages/pieces/community/ghostcms/test/content.test.tsnew file mode 100644index 00000000000..5cdec8cb546--- /dev/null+++ b/packages/pieces/community/ghostcms/test/content.test.ts@@ -0,0 +1,114 @@+/// <reference types="vitest/globals" />++import jwt from 'jsonwebtoken';+import { ghostCreatePost } from '../src/lib/actions/ai/create-post';+import { ghostListPosts } from '../src/lib/actions/ai/list-posts';+import { ghostUpdatePage } from '../src/lib/actions/ai/update-page';+import { ghostUpdatePost } from '../src/lib/actions/ai/update-post';+import { ADMIN_URL, FIXTURE_KEY_ID, FIXTURE_KEY_SECRET, mockGhost, runAction } from './helpers';++const CURRENT = { id: 'p1', title: 'Old', updated_at: '2026-09-01T10:00:00.000Z' };++afterEach(() => {+ vi.restoreAllMocks();+});++describe('requests', () => {+ test('signs a short-lived admin JWT with the key id and sends it to the admin API of the connection', async () => {+ const requests = mockGhost({ replies: [{ body: { posts: [], meta: { pagination: { page: 1, pages: 1, total: 0 } } } }] });+ await runAction({ action: ghostListPosts, propsValue: {} });+ expect(requests[0].url).toBe(`${ADMIN_URL}/posts`);+ const token = String(requests[0].headers?.['Authorization']).replace(/^Ghost /, '');+ const decoded = jwt.verify(token, Buffer.from(FIXTURE_KEY_SECRET, 'hex'), { audience: '/admin/', complete: true });+ expect(decoded.header.kid).toBe(FIXTURE_KEY_ID);+ });++ test('list posts sends paging defaults, includes tags and authors, and drops the body unless asked', async () => {+ const requests = mockGhost({+ replies: [+ {+ body: {+ posts: [{ id: 'p1', title: 'T', html: '<p>x</p>', lexical: '{}' }],+ meta: { pagination: { page: 1, limit: 15, pages: 3, total: 31, next: 2, prev: null } },+ },+ },+ ],+ });+ const result = await runAction({ action: ghostListPosts, propsValue: {} });+ expect(requests[0].method).toBe('GET');+ expect(requests[0].queryParams).toEqual({ limit: '15', page: '1', include: 'tags,authors' });+ expect(result).toEqual({ posts: [{ id: 'p1', title: 'T' }], page: 1, limit: 15, total_pages: 3, total: 31, next: 2, prev: null });+ });++ test('list posts asks for html only when Include Content is on', async () => {+ const requests = mockGhost({ replies: [{ body: { posts: [{ id: 'p1', html: '<p>x</p>' }], meta: {} } }] });+ const result = await runAction({ action: ghostListPosts, propsValue: { include_content: true, limit: 500 } });+ expect(requests[0].queryParams).toEqual({ limit: '100', page: '1', include: 'tags,authors', formats: 'html' });+ expect(result).toMatchObject({ posts: [{ id: 'p1', html: '<p>x</p>' }] });+ });++ test('create post wraps the body as a draft, marks the html source and turns tag names into objects', async () => {+ const requests = mockGhost({ replies: [{ body: { posts: [{ id: 'p1' }] } }] });+ await runAction({ action: ghostCreatePost, propsValue: { title: ' Hello ', html: '<p>x</p>', tags: ['news', ' '] } });+ expect(requests[0].method).toBe('POST');+ expect(requests[0].url).toBe(`${ADMIN_URL}/posts`);+ expect(requests[0].queryParams).toEqual({ formats: 'html', include: 'tags,authors', source: 'html' });+ expect(requests[0].body).toEqual({ posts: [{ title: 'Hello', html: '<p>x</p>', tags: [{ name: 'news' }], status: 'draft' }] });+ });+});++describe('updates have three states', () => {+ test('omitted fields are not sent and updated_at comes from a fresh read', async () => {+ const requests = mockGhost({ replies: [{ body: { posts: [CURRENT] } }, { body: { posts: [{ id: 'p1' }] } }] });+ await runAction({ action: ghostUpdatePost, propsValue: { post_id: 'p1', custom_excerpt: 'New excerpt' } });+ expect(requests.map((request) => request.method)).toEqual(['GET', 'PUT']);+ expect(requests[1].url).toBe(`${ADMIN_URL}/posts/p1`);+ expect(requests[1].body).toEqual({ posts: [{ custom_excerpt: 'New excerpt', updated_at: CURRENT.updated_at }] });+ });++ test('an explicit empty Tags list clears the tags', async () => {+ const requests = mockGhost({ replies: [{ body: { posts: [CURRENT] } }, { body: { posts: [{ id: 'p1' }] } }] });+ await runAction({ action: ghostUpdatePost, propsValue: { post_id: 'p1', tags: [] } });+ expect(requests[1].body).toEqual({ posts: [{ tags: [], updated_at: CURRENT.updated_at }] });+ });++ test('an empty Authors list is refused before any request, because Ghost needs one author', async () => {+ const requests = mockGhost({ replies: [] });+ await expect(runAction({ action: ghostUpdatePost, propsValue: { post_id: 'p1', authors: [] } })).rejects.toThrow(+ 'Ghost requires at least one author'+ );+ expect(requests).toHaveLength(0);+ });++ test('Clear Fields sends null for the listed fields', async () => {+ const requests = mockGhost({ replies: [{ body: { posts: [CURRENT] } }, { body: { posts: [{ id: 'p1' }] } }] });+ await runAction({ action: ghostUpdatePost, propsValue: { post_id: 'p1', clear_fields: ['custom_excerpt', 'meta_title'] } });+ expect(requests[1].body).toEqual({+ posts: [{ custom_excerpt: null, meta_title: null, updated_at: CURRENT.updated_at }],+ });+ });++ test('a field that is both set and cleared is refused before any request', async () => {+ const requests = mockGhost({ replies: [] });+ await expect(+ runAction({ action: ghostUpdatePost, propsValue: { post_id: 'p1', meta_title: 'SEO', clear_fields: ['meta_title'] } })+ ).rejects.toThrow('both set to a new value and listed in Clear Fields');+ expect(requests).toHaveLength(0);+ });++ test('an update with nothing to change is refused before any request', async () => {+ const requests = mockGhost({ replies: [] });+ await expect(runAction({ action: ghostUpdatePost, propsValue: { post_id: 'p1' } })).rejects.toThrow(+ 'Provide at least one field to change.'+ );+ expect(requests).toHaveLength(0);+ });++ test('scheduling a page requires a future publish time', async () => {+ const requests = mockGhost({ replies: [] });+ await expect(+ runAction({ action: ghostUpdatePage, propsValue: { page_id: 'g1', status: 'scheduled', published_at: '2020-01-01T00:00:00Z' } })+ ).rejects.toThrow('Published At must be in the future.');+ expect(requests).toHaveLength(0);+ });+});diff --git a/packages/pieces/community/ghostcms/test/helpers.ts b/packages/pieces/community/ghostcms/test/helpers.tsnew file mode 100644index 00000000000..db11eccc16e--- /dev/null+++ b/packages/pieces/community/ghostcms/test/helpers.ts@@ -0,0 +1,72 @@+/// <reference types="vitest/globals" />++import { HttpRequest, HttpResponse, httpClient } from '@activepieces/pieces-common';+import {+ ActionContext,+ AppConnectionType,+ InputPropertyMap,+ StaticPropsValue,+} from '@activepieces/pieces-framework';+import { createMockActionContext } from '../../../framework/src/lib/test';+import { ghostAuth } from '../src/lib/auth';++export function mockGhost({ replies }: { replies: Reply[] }): HttpRequest[] {+ const requests: HttpRequest[] = [];+ const queue = [...replies];+ vi.spyOn(httpClient, 'sendRequest').mockImplementation(async (request: HttpRequest): Promise<HttpResponse> => {+ requests.push(request);+ const reply = queue.shift();+ if (!reply) {+ throw new Error(`unexpected request ${request.method} ${request.url}`);+ }+ if ('error' in reply) {+ throw Object.assign(new Error(`Request failed with status ${reply.error.status}`), {+ response: { status: reply.error.status, body: reply.error.body },+ });+ }+ return { status: reply.status ?? 200, headers: {}, body: reply.body };+ });+ return requests;+}++export function memoryStore({ initial }: { initial?: Record<string, unknown> } = {}) {+ const data = new Map<string, unknown>(Object.entries(initial ?? {}));+ return {+ data,+ put: async (key: string, value: unknown): Promise<unknown> => {+ data.set(key, value);+ return value;+ },+ get: async (key: string): Promise<unknown> => data.get(key) ?? null,+ delete: async (key: string): Promise<void> => {+ data.delete(key);+ },+ };+}++export function runAction<Props extends InputPropertyMap>({ action, propsValue }: RunActionParams<Props>) {+ const context: ActionContext<GhostAuth, Props> = {+ ...createMockActionContext<Props>({ propsValue }),+ auth: { type: AppConnectionType.CUSTOM_AUTH, props: FIXTURE_AUTH.props },+ };+ return action.run(context);+}++export const FIXTURE_KEY_ID = '6aba8a1beab048bef80c3b7e';+export const FIXTURE_KEY_SECRET = '0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef';+export const FIXTURE_AUTH = {+ props: { baseUrl: 'https://blog.example.com/', apiKey: `${FIXTURE_KEY_ID}:${FIXTURE_KEY_SECRET}` },+};+export const ADMIN_URL = 'https://blog.example.com/ghost/api/admin';++type GhostAuth = typeof ghostAuth;++type Reply = { status?: number; body: unknown } | { error: { status: number; body: unknown } };++type RunActionParams<Props extends InputPropertyMap> = {+ action: {+ props: Props;+ run: (context: ActionContext<GhostAuth, Props>) => Promise<unknown>;+ };+ propsValue: StaticPropsValue<Props>;+};diff --git a/packages/pieces/community/ghostcms/test/members.test.ts b/packages/pieces/community/ghostcms/test/members.test.tsnew file mode 100644index 00000000000..0adf1a43f22--- /dev/null+++ b/packages/pieces/community/ghostcms/test/members.test.ts@@ -0,0 +1,175 @@+/// <reference types="vitest/globals" />++import { ghostAddMemberLabel } from '../src/lib/actions/ai/add-member-label';+import { ghostDeleteMember } from '../src/lib/actions/ai/delete-member';+import { ghostGetMemberByEmail } from '../src/lib/actions/ai/get-member-by-email';+import { ghostGetMemberStats } from '../src/lib/actions/ai/get-member-stats';+import { ghostGetSettings } from '../src/lib/actions/ai/get-settings';+import { ghostSubscribeMemberToNewsletters } from '../src/lib/actions/ai/subscribe-member-to-newsletters';+import { ghostUnsubscribeMemberFromNewsletters } from '../src/lib/actions/ai/unsubscribe-member-from-newsletters';+import { ghostUpdateMember } from '../src/lib/actions/ai/update-member';+import { ghostUpdateTier } from '../src/lib/actions/ai/update-tier';+import { ADMIN_URL, FIXTURE_KEY_SECRET, mockGhost, runAction } from './helpers';++const MEMBER = { id: 'm1', email: '[email protected]', newsletters: [{ id: 'n1' }], labels: [] };++afterEach(() => {+ vi.restoreAllMocks();+});++describe('member lookups', () => {+ test('get member by email quotes the email so a plus sign stays literal', async () => {+ const requests = mockGhost({ replies: [{ body: { members: [MEMBER] } }] });+ const result = await runAction({ action: ghostGetMemberByEmail, propsValue: { email: ' [email protected] ' } });+ expect(requests[0].queryParams).toEqual({ filter: "email:'[email protected]'", limit: '1' });+ expect(result).toEqual({ found: true, member: MEMBER });+ });++ test('get member by email escapes a quote inside the email', async () => {+ const requests = mockGhost({ replies: [{ body: { members: [] } }] });+ const result = await runAction({ action: ghostGetMemberByEmail, propsValue: { email: "o'[email protected]" } });+ expect(requests[0].queryParams?.['filter']).toBe("email:'o\\'[email protected]'");+ expect(result).toEqual({ found: false, member: null });+ });++ test('member stats reads the top-level total and the latest daily row', async () => {+ mockGhost({+ replies: [+ {+ body: {+ total: 12,+ data: [+ { date: '2026-09-27', free: 9, paid: 1, comped: 0 },+ { date: '2026-09-28', free: 10, paid: 2, comped: 0 },+ ],+ },+ },+ ],+ });+ const result = await runAction({ action: ghostGetMemberStats, propsValue: {} });+ expect(result).toMatchObject({ total: 12, free: 10, paid: 2, as_of: '2026-09-28' });+ });++ test('get settings never returns secret settings', async () => {+ mockGhost({+ replies: [+ {+ body: {+ settings: [+ { key: 'title', value: 'Blog' },+ { key: 'stripe_secret_key', value: 'sk_live_x' },+ { key: 'mailgun_api_key', value: 'key-x' },+ { key: 'members_private_key', value: 'pk' },+ ],+ },+ },+ ],+ });+ const result = JSON.stringify(await runAction({ action: ghostGetSettings, propsValue: {} }));+ expect(result).toContain('Blog');+ expect(result).not.toMatch(/sk_live_x|key-x|"pk"/);+ });+});++describe('member writes', () => {+ test('add label uses the bulk endpoint filtered to the one member', async () => {+ const requests = mockGhost({+ replies: [+ { body: { members: [MEMBER] } },+ { body: { bulk: { meta: { stats: { successful: 1, unsuccessful: 0 } } } } },+ { body: { members: [{ ...MEMBER, labels: [{ id: 'l1' }] }] } },+ ],+ });+ await runAction({ action: ghostAddMemberLabel, propsValue: { member_id: 'm1', label_id: 'l1' } });+ expect(requests[1].method).toBe('PUT');+ expect(requests[1].url).toBe(`${ADMIN_URL}/members/bulk`);+ expect(requests[1].queryParams).toEqual({ filter: "id:'m1'" });+ expect(requests[1].body).toEqual({ bulk: { action: 'addLabel', meta: { label: { id: 'l1' } } } });+ });++ test('a label change Ghost reports as unsuccessful fails the step', async () => {+ const requests = mockGhost({+ replies: [+ { body: { members: [MEMBER] } },+ { body: { bulk: { meta: { stats: { successful: 0, unsuccessful: 1 }, errors: [{ message: 'Label not found' }] } } } },+ ],+ });+ await expect(runAction({ action: ghostAddMemberLabel, propsValue: { member_id: 'm1', label_id: 'nope' } })).rejects.toThrow(+ 'Ghost could not update the member label'+ );+ expect(requests).toHaveLength(2);+ });++ test('unsubscribe removes each newsletter with its own bulk call and never rewrites the list', async () => {+ const requests = mockGhost({+ replies: [+ { body: { members: [MEMBER] } },+ { body: { bulk: { meta: { stats: { successful: 1, unsuccessful: 0 } } } } },+ { body: { bulk: { meta: { stats: { successful: 1, unsuccessful: 0 } } } } },+ { body: { members: [{ ...MEMBER, newsletters: [] }] } },+ ],+ });+ await runAction({+ action: ghostUnsubscribeMemberFromNewsletters,+ propsValue: { member_id: 'm1', newsletter_ids: ['n1', 'n2', 'n1'] },+ });+ const bulk = requests.filter((request) => request.url.endsWith('/members/bulk'));+ expect(bulk.map((request) => request.body)).toEqual([+ { bulk: { action: 'unsubscribe', newsletter: 'n1' } },+ { bulk: { action: 'unsubscribe', newsletter: 'n2' } },+ ]);+ expect(requests.some((request) => request.method === 'PUT' && request.url.endsWith('/members/m1'))).toBe(false);+ });++ test('an unsubscribe Ghost reports as unsuccessful fails the step', async () => {+ const requests = mockGhost({+ replies: [+ { body: { members: [MEMBER] } },+ { body: { bulk: { action: 'unsubscribe', meta: { stats: { successful: 0, unsuccessful: 1 }, errors: [{ message: 'Newsletter not found' }] } } } },+ ],+ });+ await expect(+ runAction({ action: ghostUnsubscribeMemberFromNewsletters, propsValue: { member_id: 'm1', newsletter_ids: ['nope'] } })+ ).rejects.toThrow('Ghost could not remove the newsletter subscription');+ expect(requests).toHaveLength(2);+ });++ test('subscribe keeps the existing newsletters and adds the new ones', async () => {+ const requests = mockGhost({ replies: [{ body: { members: [MEMBER] } }, { body: { members: [MEMBER] } }] });+ await runAction({ action: ghostSubscribeMemberToNewsletters, propsValue: { member_id: 'm1', newsletter_ids: ['n2', 'n1'] } });+ expect(requests[1].body).toEqual({ members: [{ newsletters: [{ id: 'n1' }, { id: 'n2' }] }] });+ });++ test('update member leaves omitted lists alone, clears an empty list and blanks cleared text', async () => {+ const requests = mockGhost({ replies: [{ body: { members: [MEMBER] } }] });+ await runAction({ action: ghostUpdateMember, propsValue: { member_id: 'm1', labels: [], clear_fields: ['note'] } });+ expect(requests[0].body).toEqual({ members: [{ note: '', labels: [] }] });+ });++ test('delete member only cancels Stripe subscriptions when asked', async () => {+ const requests = mockGhost({ replies: [{ status: 204, body: '' }, { status: 204, body: '' }] });+ await runAction({ action: ghostDeleteMember, propsValue: { member_id: 'm1' } });+ await runAction({ action: ghostDeleteMember, propsValue: { member_id: 'm1', cancel_stripe_subscriptions: true } });+ expect(requests.map((request) => request.queryParams)).toEqual([{}, { cancel: 'true' }]);+ });++ test('update tier sends an empty Benefits list to clear benefits and null for a cleared description', async () => {+ const requests = mockGhost({ replies: [{ body: { tiers: [{ id: 't1' }] } }] });+ await runAction({ action: ghostUpdateTier, propsValue: { tier_id: 't1', benefits: [], clear_fields: ['description'] } });+ expect(requests[0].body).toEqual({ tiers: [{ benefits: [], description: null }] });+ });+});++describe('errors', () => {+ test('an API error names the status and never carries the key or token', async () => {+ mockGhost({ replies: [{ error: { status: 404, body: { errors: [{ message: 'Member not found.' }] } } }] });+ const error = await runAction({ action: ghostUpdateMember, propsValue: { member_id: 'gone', name: 'X' } }).catch(+ (caught: unknown) => caught+ );+ expect(error).toBeInstanceOf(Error);+ const text = error instanceof Error ? error.message : '';+ expect(text).toContain('Ghost could not find the requested resource (404)');+ expect(text).not.toContain(FIXTURE_KEY_SECRET);+ expect(text).not.toMatch(/Ghost eyJ/);+ });+});diff --git a/packages/pieces/community/ghostcms/test/security.test.ts b/packages/pieces/community/ghostcms/test/security.test.tsnew file mode 100644index 00000000000..f830463cd01--- /dev/null+++ b/packages/pieces/community/ghostcms/test/security.test.ts@@ -0,0 +1,122 @@+/// <reference types="vitest/globals" />++import crypto from 'crypto';+import { ghostAuth } from '../src/lib/auth';+import { assertGhostUrl } from '../src/lib/common/custom-api-guard';+import { ghostWebhook } from '../src/lib/common/webhooks';+import { ADMIN_URL, FIXTURE_AUTH, memoryStore, mockGhost } from './helpers';++const STORE_KEY = '_member_added_trigger';+const SERVER = { apiUrl: 'http://localhost:3000', publicUrl: 'http://localhost:4200', mintOidcToken: async () => '' };++afterEach(() => {+ vi.restoreAllMocks();+});++describe('Custom API Call only sends the key to the connection admin API', () => {+ test.each(['/posts/', 'posts/?limit=1', `${ADMIN_URL}/site/`, `${ADMIN_URL}?x=1`])('allows %s', (url) => {+ expect(() => assertGhostUrl({ auth: FIXTURE_AUTH, propsValue: { url: { url } } })).not.toThrow();+ });++ test.each([+ 'https://blog.example.com.evil.io/ghost/api/admin/site/',+ 'https://evil.io/ghost/api/admin/site/',+ 'http://blog.example.com/ghost/api/admin/site/',+ 'https://blog.example.com/ghost/api/content/posts/',+ '//evil.io/x',+ 'HTTPS://evil.io/',+ '/../content/',+ '/%2e%2e/content/',+ ])('refuses %s', (url) => {+ expect(() => assertGhostUrl({ auth: FIXTURE_AUTH, propsValue: { url: { url } } })).toThrow(+ 'Custom API Call only sends your Ghost Admin API key'+ );+ });+});++describe('webhook triggers', () => {+ test('enable registers the webhook with a signing secret and stores both', async () => {+ const requests = mockGhost({ replies: [{ status: 201, body: { webhooks: [{ id: 'w1' }] } }] });+ const store = memoryStore();+ await ghostWebhook.enable({ auth: FIXTURE_AUTH, event: 'member.added', webhookUrl: 'https://ap.test/hook', store, storeKey: STORE_KEY });+ const sent = JSON.stringify(requests[0].body);+ const stored = store.data.get(STORE_KEY);+ expect(requests[0].url).toBe(`${ADMIN_URL}/webhooks`);+ expect(sent).toContain('"event":"member.added"');+ expect(stored).toMatchObject({ webhookId: 'w1' });+ expect(JSON.stringify(stored)).toMatch(/"secret":"[0-9a-f]{64}"/);+ });++ test('enable deletes the webhook it created when the store write fails', async () => {+ const requests = mockGhost({ replies: [{ status: 201, body: { webhooks: [{ id: 'w1' }] } }, { status: 204, body: '' }] });+ const store = { ...memoryStore(), put: async () => Promise.reject(new Error('store down')) };+ await expect(+ ghostWebhook.enable({ auth: FIXTURE_AUTH, event: 'member.added', webhookUrl: 'https://ap.test/hook', store, storeKey: STORE_KEY })+ ).rejects.toThrow('store down');+ expect(requests[1].method).toBe('DELETE');+ expect(requests[1].url).toBe(`${ADMIN_URL}/webhooks/w1`);+ });++ test('disable forgets the webhook after a confirmed delete, and a 404 counts as deleted', async () => {+ mockGhost({ replies: [{ error: { status: 404, body: { errors: [{ message: 'Webhook not found.' }] } } }] });+ const store = memoryStore({ initial: { [STORE_KEY]: { webhookId: 'w1', secret: 's' } } });+ await ghostWebhook.disable({ auth: FIXTURE_AUTH, store, storeKey: STORE_KEY });+ expect(store.data.has(STORE_KEY)).toBe(false);+ });++ test('disable keeps the webhook ID when Ghost fails to delete it', async () => {+ mockGhost({ replies: [{ error: { status: 500, body: { errors: [{ message: 'boom' }] } } }] });+ const store = memoryStore({ initial: { [STORE_KEY]: { webhookId: 'w1', secret: 's' } } });+ await expect(ghostWebhook.disable({ auth: FIXTURE_AUTH, store, storeKey: STORE_KEY })).rejects.toThrow('(500)');+ expect(store.data.has(STORE_KEY)).toBe(true);+ });++ test('a delivery signed with the stored secret is accepted, and a tampered or unsigned one is refused', async () => {+ const secret = 'a'.repeat(64);+ const rawBody = '{"member":{"current":{"id":"m1"}}}';+ const timestamp = '1790623913000';+ const signature = crypto.createHmac('sha256', secret).update(`${rawBody}${timestamp}`).digest('hex');+ const store = memoryStore({ initial: { [STORE_KEY]: { webhookId: 'w1', secret } } });+ const headers = { 'X-Ghost-Signature': `sha256=${signature}, t=${timestamp}` };+ await expect(ghostWebhook.assertSigned({ store, storeKey: STORE_KEY, rawBody, headers })).resolves.toBeUndefined();+ await expect(+ ghostWebhook.assertSigned({ store, storeKey: STORE_KEY, rawBody: rawBody.replace('m1', 'm2'), headers })+ ).rejects.toThrow('did not match');+ await expect(ghostWebhook.assertSigned({ store, storeKey: STORE_KEY, rawBody, headers: {} })).rejects.toThrow('did not match');+ });++ test('a trigger enabled before signing existed keeps accepting deliveries', async () => {+ const store = memoryStore({ initial: { [STORE_KEY]: { webhookId: 'w1' } } });+ await expect(ghostWebhook.assertSigned({ store, storeKey: STORE_KEY, rawBody: '{}', headers: {} })).resolves.toBeUndefined();+ });+});++describe('connection check', () => {+ const validate = ghostAuth.validate;++ test('a working key is valid', async () => {+ const requests = mockGhost({ replies: [{ body: { users: [] } }] });+ await expect(validate?.({ auth: { baseUrl: 'https://blog.example.com', apiKey: FIXTURE_AUTH.props.apiKey }, server: SERVER })).resolves.toEqual({ valid: true });+ expect(requests[0].url).toBe(`${ADMIN_URL}/users/`);+ });++ test('only a 401 or 403 is reported as an invalid key', async () => {+ mockGhost({ replies: [{ error: { status: 401, body: {} } }, { error: { status: 500, body: {} } }] });+ const auth = { baseUrl: 'https://blog.example.com', apiKey: FIXTURE_AUTH.props.apiKey };+ const rejected = await validate?.({ auth, server: SERVER });+ const unreachable = await validate?.({ auth, server: SERVER });+ expect(rejected).toMatchObject({ valid: false, error: expect.stringContaining('Invalid Admin API Key') });+ expect(unreachable).toMatchObject({ valid: false, error: expect.stringContaining('Could not verify the connection') });+ expect(JSON.stringify(unreachable)).not.toContain('Invalid Admin API Key');+ });++ test.each(['ftp://blog.example.com', 'blog.example.com', 'https://user:[email protected]'])(+ 'refuses the API URL %s without calling Ghost',+ async (baseUrl) => {+ const requests = mockGhost({ replies: [] });+ const result = await validate?.({ auth: { baseUrl, apiKey: FIXTURE_AUTH.props.apiKey }, server: SERVER });+ expect(result).toMatchObject({ valid: false });+ expect(requests).toHaveLength(0);+ }+ );+});diff --git a/packages/pieces/community/ghostcms/vitest.config.ts b/packages/pieces/community/ghostcms/vitest.config.tsnew file mode 100644index 00000000000..ba8ade4a178--- /dev/null+++ b/packages/pieces/community/ghostcms/vitest.config.ts@@ -0,0 +1,17 @@+import path from 'path'+import { defineConfig } from 'vitest/config'++const repoRoot = path.resolve(__dirname, '../../../..')++export default defineConfig({+ test: {+ globals: true,+ environment: 'node',+ },+ resolve: {+ alias: {+ '@activepieces/pieces-framework': path.resolve(repoRoot, 'packages/pieces/framework/src/index.ts'),+ '@activepieces/pieces-common': path.resolve(repoRoot, 'packages/pieces/common/src/index.ts'),+ },+ },+})