@tryghost/ghst 0.13.0 → 0.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -165,10 +165,12 @@ Interactive destructive confirmations also emit `GHST_AGENT_NOTICE:` lines on st
165
165
  Create and publish:
166
166
 
167
167
  ```bash
168
- ghst post create --title "Launch" --markdown-file ./launch.md --newsletter weekly --email-segment all
169
- ghst post publish <post-id>
168
+ ghst post create --title "Launch" --markdown-file ./launch.md
169
+ ghst post publish <post-id> --newsletter weekly --email-segment all
170
170
  ```
171
171
 
172
+ The email delivery flags (`--newsletter`, `--email-only`, `--email-segment`) belong on `post publish` (or `post schedule` / `post update`) — Ghost's email send pipeline fires on the publish transition, not on create.
173
+
172
174
  Bulk updates:
173
175
 
174
176
  ```bash
package/dist/index.js CHANGED
@@ -4631,6 +4631,19 @@ async function bulkPages(global, options) {
4631
4631
  }
4632
4632
 
4633
4633
  // src/lib/posts.ts
4634
+ function buildEmailParams(options = {}) {
4635
+ const params = {};
4636
+ if (options.newsletter) {
4637
+ params.newsletter = options.newsletter;
4638
+ }
4639
+ if (options.email_segment) {
4640
+ params.email_segment = options.email_segment;
4641
+ }
4642
+ if (options.email_only !== void 0) {
4643
+ params.email_only = String(options.email_only);
4644
+ }
4645
+ return Object.keys(params).length > 0 ? params : void 0;
4646
+ }
4634
4647
  function getFirstPost(payload) {
4635
4648
  const posts = payload.posts;
4636
4649
  if (!Array.isArray(posts) || posts.length === 0) {
@@ -4712,32 +4725,18 @@ async function deletePost(global, id) {
4712
4725
  async function publishPost(global, id, options) {
4713
4726
  return updatePost(global, {
4714
4727
  id,
4715
- patch: {
4716
- status: "published",
4717
- newsletter: options?.newsletter,
4718
- email_only: options?.email_only,
4719
- email_segment: options?.email_segment
4720
- }
4728
+ patch: { status: "published" },
4729
+ params: buildEmailParams(options)
4721
4730
  });
4722
4731
  }
4723
4732
  async function schedulePost(global, id, at, options) {
4724
- const params = {};
4725
- if (options?.newsletter) {
4726
- params.newsletter = options.newsletter;
4727
- }
4728
- if (options?.email_segment) {
4729
- params.email_segment = options.email_segment;
4730
- }
4731
- if (options?.email_only !== void 0) {
4732
- params.email_only = String(options.email_only);
4733
- }
4734
4733
  return updatePost(global, {
4735
4734
  id,
4736
4735
  patch: {
4737
4736
  status: "scheduled",
4738
4737
  published_at: at
4739
4738
  },
4740
- params: Object.keys(params).length > 0 ? params : void 0
4739
+ params: buildEmailParams(options)
4741
4740
  });
4742
4741
  }
4743
4742
  async function unschedulePost(global, id) {
@@ -7398,7 +7397,7 @@ function registerCoreTools(server, global, enabledGroups) {
7398
7397
  "posts",
7399
7398
  "ghost_post_update",
7400
7399
  {
7401
- description: "Update a Ghost post by id or slug.",
7400
+ description: "Update a Ghost post by id or slug, with optional email delivery settings on the publish transition.",
7402
7401
  inputSchema: z6.object({
7403
7402
  id: z6.string().optional(),
7404
7403
  slug: z6.string().optional(),
@@ -7407,7 +7406,10 @@ function registerCoreTools(server, global, enabledGroups) {
7407
7406
  status: z6.enum(["draft", "published", "scheduled"]).optional(),
7408
7407
  publish_at: z6.string().datetime().optional(),
7409
7408
  tags: z6.array(z6.string()).optional(),
7410
- visibility: z6.enum(["public", "members", "paid", "tiers"]).optional()
7409
+ visibility: z6.enum(["public", "members", "paid", "tiers"]).optional(),
7410
+ newsletter: z6.string().optional(),
7411
+ email_only: z6.boolean().optional(),
7412
+ email_segment: z6.string().optional()
7411
7413
  })
7412
7414
  },
7413
7415
  async (global2, args) => {
@@ -7422,7 +7424,12 @@ function registerCoreTools(server, global, enabledGroups) {
7422
7424
  tags: args.tags,
7423
7425
  visibility: args.visibility
7424
7426
  },
7425
- source: args.html ? "html" : void 0
7427
+ source: args.html ? "html" : void 0,
7428
+ params: buildEmailParams({
7429
+ newsletter: args.newsletter,
7430
+ email_only: args.email_only,
7431
+ email_segment: args.email_segment
7432
+ })
7426
7433
  });
7427
7434
  return toolResult(payload);
7428
7435
  }
@@ -7451,13 +7458,20 @@ function registerCoreTools(server, global, enabledGroups) {
7451
7458
  "posts",
7452
7459
  "ghost_post_publish",
7453
7460
  {
7454
- description: "Publish a Ghost post.",
7461
+ description: "Publish a Ghost post, with optional email delivery settings.",
7455
7462
  inputSchema: z6.object({
7456
- id: z6.string()
7463
+ id: z6.string(),
7464
+ newsletter: z6.string().optional(),
7465
+ email_only: z6.boolean().optional(),
7466
+ email_segment: z6.string().optional()
7457
7467
  })
7458
7468
  },
7459
7469
  async (global2, args) => {
7460
- const payload = await publishPost(global2, args.id);
7470
+ const payload = await publishPost(global2, args.id, {
7471
+ newsletter: args.newsletter,
7472
+ email_only: args.email_only,
7473
+ email_segment: args.email_segment
7474
+ });
7461
7475
  return toolResult(payload);
7462
7476
  }
7463
7477
  );
@@ -11092,10 +11106,7 @@ var PostCreateInputSchema = withSingleContentSource2(
11092
11106
  metaDescription: z12.string().optional(),
11093
11107
  ogTitle: z12.string().optional(),
11094
11108
  ogImage: z12.string().url().optional(),
11095
- codeInjectionHead: z12.string().optional(),
11096
- newsletter: z12.string().optional(),
11097
- emailOnly: z12.boolean().optional(),
11098
- emailSegment: z12.string().optional()
11109
+ codeInjectionHead: z12.string().optional()
11099
11110
  }).refine((data) => Boolean(data.title || data.fromJson), {
11100
11111
  message: "Provide --title or --from-json.",
11101
11112
  path: ["title"]
@@ -11356,7 +11367,7 @@ function registerPostCommands(program) {
11356
11367
  }
11357
11368
  printPostHuman(payload);
11358
11369
  });
11359
- post.command("create").description("Create a post").option("--title <title>", "Post title").option("--status <status>", "Post status").option("--publish-at <datetime>", "Publish date-time for scheduled posts").option("--html <html>", "Post HTML content").option("--html-file <path>", "Path to HTML file").option("--lexical-file <path>", "Path to Lexical JSON file").option("--markdown-file <path>", "Path to Markdown file").option("--markdown-stdin", "Read Markdown content from stdin").option("--html-raw-file <path>", "Path to raw HTML file wrapped in an HTML card").option("--from-json <path>", "Read post payload from JSON file").option("--tags <tags>", "Comma separated tag names").option("--authors <authors>", "Comma separated author emails").option("--featured", "Mark as featured").option("--visibility <visibility>", "public|members|paid|tiers").option("--tier <slug>", "Tier slug for tier visibility access").option("--feature-image <url>", "Feature image URL").option("--excerpt <excerpt>", "Custom excerpt").option("--meta-title <title>", "Meta title").option("--meta-description <description>", "Meta description").option("--og-title <title>", "Open Graph title").option("--og-image <url>", "Open Graph image URL").option("--code-injection-head <value>", "Code injection head HTML").option("--newsletter <slug>", "Newsletter slug for published posts").option("--email-only", "Publish as email-only").option("--email-segment <segment>", "Email segment for publish email").action(async (options, command) => {
11370
+ post.command("create").description("Create a post").option("--title <title>", "Post title").option("--status <status>", "Post status").option("--publish-at <datetime>", "Publish date-time for scheduled posts").option("--html <html>", "Post HTML content").option("--html-file <path>", "Path to HTML file").option("--lexical-file <path>", "Path to Lexical JSON file").option("--markdown-file <path>", "Path to Markdown file").option("--markdown-stdin", "Read Markdown content from stdin").option("--html-raw-file <path>", "Path to raw HTML file wrapped in an HTML card").option("--from-json <path>", "Read post payload from JSON file").option("--tags <tags>", "Comma separated tag names").option("--authors <authors>", "Comma separated author emails").option("--featured", "Mark as featured").option("--visibility <visibility>", "public|members|paid|tiers").option("--tier <slug>", "Tier slug for tier visibility access").option("--feature-image <url>", "Feature image URL").option("--excerpt <excerpt>", "Custom excerpt").option("--meta-title <title>", "Meta title").option("--meta-description <description>", "Meta description").option("--og-title <title>", "Open Graph title").option("--og-image <url>", "Open Graph image URL").option("--code-injection-head <value>", "Code injection head HTML").action(async (options, command) => {
11360
11371
  const global = getGlobalOptions(command);
11361
11372
  const parsed = PostCreateInputSchema.safeParse({
11362
11373
  title: options.title,
@@ -11380,10 +11391,7 @@ function registerPostCommands(program) {
11380
11391
  metaDescription: options.metaDescription,
11381
11392
  ogTitle: options.ogTitle,
11382
11393
  ogImage: options.ogImage,
11383
- codeInjectionHead: options.codeInjectionHead,
11384
- newsletter: options.newsletter,
11385
- emailOnly: parseBooleanFlag(options.emailOnly),
11386
- emailSegment: options.emailSegment
11394
+ codeInjectionHead: options.codeInjectionHead
11387
11395
  });
11388
11396
  if (!parsed.success) {
11389
11397
  throwValidationError9(parsed.error);
@@ -11419,10 +11427,7 @@ function registerPostCommands(program) {
11419
11427
  meta_description: parsed.data.metaDescription,
11420
11428
  og_title: parsed.data.ogTitle,
11421
11429
  og_image: parsed.data.ogImage,
11422
- codeinjection_head: parsed.data.codeInjectionHead,
11423
- newsletter: parsed.data.newsletter,
11424
- email_only: parsed.data.emailOnly,
11425
- email_segment: parsed.data.emailSegment
11430
+ codeinjection_head: parsed.data.codeInjectionHead
11426
11431
  }
11427
11432
  );
11428
11433
  const payload = await createPost(global, createPayload, source);
@@ -11432,7 +11437,7 @@ function registerPostCommands(program) {
11432
11437
  }
11433
11438
  printPostHuman(payload);
11434
11439
  });
11435
- post.command("update [id]").description("Update a post by id or slug").option("--slug <slug>", "Post slug lookup").option("--title <title>", "Post title").option("--status <status>", "Post status").option("--publish-at <datetime>", "Publish date-time for scheduled posts").option("--html <html>", "Post HTML content").option("--html-file <path>", "Path to HTML file").option("--lexical-file <path>", "Path to Lexical JSON file").option("--markdown-file <path>", "Path to Markdown file").option("--markdown-stdin", "Read Markdown content from stdin").option("--html-raw-file <path>", "Path to raw HTML file wrapped in an HTML card").option("--from-json <path>", "Read post patch from JSON file").option("--tags <tags>", "Comma separated tag names").option("--authors <authors>", "Comma separated author emails").option("--featured <value>", "true|false").option("--visibility <visibility>", "public|members|paid|tiers").option("--tier <slug>", "Tier slug for tier visibility access").option("--feature-image <url>", "Feature image URL").option("--excerpt <excerpt>", "Custom excerpt").option("--meta-title <title>", "Meta title").option("--meta-description <description>", "Meta description").option("--og-title <title>", "Open Graph title").option("--og-image <url>", "Open Graph image URL").option("--code-injection-head <value>", "Code injection head HTML").option("--newsletter <slug>", "Newsletter slug").option("--email-only <value>", "true|false").option("--email-segment <segment>", "Email segment").action(async (id, options, command) => {
11440
+ post.command("update [id]").description("Update a post by id or slug").option("--slug <slug>", "Post slug lookup").option("--title <title>", "Post title").option("--status <status>", "Post status").option("--publish-at <datetime>", "Publish date-time for scheduled posts").option("--html <html>", "Post HTML content").option("--html-file <path>", "Path to HTML file").option("--lexical-file <path>", "Path to Lexical JSON file").option("--markdown-file <path>", "Path to Markdown file").option("--markdown-stdin", "Read Markdown content from stdin").option("--html-raw-file <path>", "Path to raw HTML file wrapped in an HTML card").option("--from-json <path>", "Read post patch from JSON file").option("--tags <tags>", "Comma separated tag names").option("--authors <authors>", "Comma separated author emails").option("--featured <value>", "true|false").option("--visibility <visibility>", "public|members|paid|tiers").option("--tier <slug>", "Tier slug for tier visibility access").option("--feature-image <url>", "Feature image URL").option("--excerpt <excerpt>", "Custom excerpt").option("--meta-title <title>", "Meta title").option("--meta-description <description>", "Meta description").option("--og-title <title>", "Open Graph title").option("--og-image <url>", "Open Graph image URL").option("--code-injection-head <value>", "Code injection head HTML").option("--newsletter <slug>", "Newsletter slug for email delivery").option("--email-only <value>", "Send as email only (true|false)").option("--email-segment <segment>", "Email segment for delivery").action(async (id, options, command) => {
11436
11441
  const global = getGlobalOptions(command);
11437
11442
  const parsed = PostUpdateInputSchema.safeParse({
11438
11443
  id,
@@ -11497,17 +11502,19 @@ function registerPostCommands(program) {
11497
11502
  meta_description: parsed.data.metaDescription,
11498
11503
  og_title: parsed.data.ogTitle,
11499
11504
  og_image: parsed.data.ogImage,
11500
- codeinjection_head: parsed.data.codeInjectionHead,
11501
- newsletter: parsed.data.newsletter,
11502
- email_only: parsed.data.emailOnly,
11503
- email_segment: parsed.data.emailSegment
11505
+ codeinjection_head: parsed.data.codeInjectionHead
11504
11506
  }
11505
11507
  );
11506
11508
  const payload = await updatePost(global, {
11507
11509
  id: parsed.data.id,
11508
11510
  slug: parsed.data.slug,
11509
11511
  patch,
11510
- source
11512
+ source,
11513
+ params: buildEmailParams({
11514
+ newsletter: parsed.data.newsletter,
11515
+ email_only: parsed.data.emailOnly,
11516
+ email_segment: parsed.data.emailSegment
11517
+ })
11511
11518
  });
11512
11519
  if (global.json) {
11513
11520
  printJson(payload, global.jq);
@@ -11571,7 +11578,7 @@ function registerPostCommands(program) {
11571
11578
  }
11572
11579
  console.log(`Deleted post '${parsed.data.id ?? ""}'.`);
11573
11580
  });
11574
- post.command("publish <id>").description("Publish a post").option("--newsletter <slug>", "Newsletter slug").option("--email-segment <segment>", "Email segment").option("--email-only", "Email only publish").action(async (id, options, command) => {
11581
+ post.command("publish <id>").description("Publish a post").option("--newsletter <slug>", "Newsletter slug for email delivery").option("--email-segment <segment>", "Email segment for delivery").option("--email-only", "Send as email only").action(async (id, options, command) => {
11575
11582
  const global = getGlobalOptions(command);
11576
11583
  const parsed = PostPublishInputSchema.safeParse({
11577
11584
  id,
@@ -11593,7 +11600,7 @@ function registerPostCommands(program) {
11593
11600
  }
11594
11601
  printPostHuman(payload);
11595
11602
  });
11596
- post.command("schedule <id>").description("Schedule a post").requiredOption("--at <datetime>", "ISO datetime for scheduled publish").option("--newsletter <slug>", "Newsletter slug for email delivery").option("--email-only", "Email only publish").option("--email-segment <segment>", "Email segment").action(async (id, options, command) => {
11603
+ post.command("schedule <id>").description("Schedule a post").requiredOption("--at <datetime>", "ISO datetime for scheduled publish").option("--newsletter <slug>", "Newsletter slug for email delivery").option("--email-only", "Send as email only").option("--email-segment <segment>", "Email segment for delivery").action(async (id, options, command) => {
11597
11604
  const global = getGlobalOptions(command);
11598
11605
  const parsed = PostScheduleInputSchema.safeParse({
11599
11606
  id,