@paragraph-com/cli 0.3.0 → 0.3.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.
Files changed (2) hide show
  1. package/dist/index.js +22 -12
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -7613,9 +7613,11 @@ var init_zod = __esm({
7613
7613
  "postPreview": zod.string().max(updatePostBodyPostPreviewMax).optional().describe("Preview text for the post"),
7614
7614
  "categories": zod.union([zod.array(zod.string()), zod.string()]).optional().describe("Category tags for the post. Can also be a comma-separated string."),
7615
7615
  "status": zod.enum(["draft", "published", "archived"]).optional().describe("Set to 'published' to publish, 'draft' to unpublish, or 'archived' to archive"),
7616
- "scheduledAt": zod.number().min(updatePostBodyScheduledAtMin).nullish().describe("Unix timestamp (milliseconds) to schedule the post's first publish at a future time. Must be in the future and at most 30 days out. Only valid for draft posts that haven't been published or already scheduled. Cannot be combined with status: 'draft' or 'archived'. Pass null to cancel a previously scheduled publish."),
7616
+ "scheduledAt": zod.number().min(updatePostBodyScheduledAtMin).nullish().describe("Unix timestamp (milliseconds) to schedule the post's first publish at a future time. Must be in the future and at most 30 days out. Only valid for draft posts that haven't been published or already scheduled. Cannot be combined with status: 'draft' or 'archived'. Pass null to cancel a previously scheduled publish. The value 0 is treated the same as omitting the field (no scheduling request); note that on an already-scheduled post, omitting `scheduledAt` while changing `status` cancels the schedule."),
7617
7617
  "sendNewsletter": zod.union([zod.boolean(), zod.enum(["true", "false", "1", "0"])]).optional().describe("Whether to send an email newsletter to subscribers when the post publishes. Only meaningful when publishing (status: 'published') or scheduling (scheduledAt set). Default: false"),
7618
- "publishedAt": zod.number().min(updatePostBodyPublishedAtMin).optional().describe("Unix timestamp (milliseconds) to set as the post's publish date. Once set, the date is preserved across re-publishes.")
7618
+ "publishedAt": zod.number().min(updatePostBodyPublishedAtMin).optional().describe("Unix timestamp (milliseconds) to set as the post's publish date. Once set, the date is preserved across re-publishes."),
7619
+ "imageUrl": zod.string().url().optional().describe("URL of an image to set as the post's cover/hero image. The image is fetched, re-hosted on Paragraph's CDN, and a placeholder is generated. Pass clearImage: true instead to remove the existing cover."),
7620
+ "clearImage": zod.boolean().optional().describe("When true, removes the post's existing cover/hero image. Ignored if imageUrl is also provided.")
7619
7621
  });
7620
7622
  updatePostResponse = zod.object({
7621
7623
  "success": zod.literal(true).describe("Whether the update succeeded")
@@ -7729,7 +7731,7 @@ var init_zod = __esm({
7729
7731
  "slug": zod.string().min(1).max(createPostBodySlugMax).optional().describe("Optional URL-friendly identifier for the post. If not provided, will be generated from title"),
7730
7732
  "postPreview": zod.string().max(createPostBodyPostPreviewMax).optional().describe("Optional preview text for the post. If not provided, will be generated from content"),
7731
7733
  "categories": zod.union([zod.array(zod.string()), zod.string()]).optional().describe("Optional array of category tags for the post. Can also be a comma-separated string."),
7732
- "scheduledAt": zod.number().min(createPostBodyScheduledAtMin).optional().describe("Optional Unix timestamp (milliseconds) to schedule first-publish of the post at a future time. Must be in the future. Cannot be combined with status: 'draft'. When set, the post is created and queued to publish (and send newsletter, if requested) at the specified time.")
7734
+ "scheduledAt": zod.number().min(createPostBodyScheduledAtMin).optional().describe("Optional Unix timestamp (milliseconds) to schedule first-publish of the post at a future time. Must be in the future. Cannot be combined with status: 'draft'. When set, the post is created and queued to publish (and send newsletter, if requested) at the specified time. Pass 0 or omit the field for an unscheduled post.")
7733
7735
  });
7734
7736
  createPostResponse = zod.object({
7735
7737
  "id": zod.string().describe("The ID of the created post"),
@@ -7803,9 +7805,11 @@ var init_zod = __esm({
7803
7805
  "postPreview": zod.string().max(updatePostBySlugBodyPostPreviewMax).optional().describe("Preview text for the post"),
7804
7806
  "categories": zod.union([zod.array(zod.string()), zod.string()]).optional().describe("Category tags for the post. Can also be a comma-separated string."),
7805
7807
  "status": zod.enum(["draft", "published", "archived"]).optional().describe("Set to 'published' to publish, 'draft' to unpublish, or 'archived' to archive"),
7806
- "scheduledAt": zod.number().min(updatePostBySlugBodyScheduledAtMin).nullish().describe("Unix timestamp (milliseconds) to schedule the post's first publish at a future time. Must be in the future and at most 30 days out. Only valid for draft posts that haven't been published or already scheduled. Cannot be combined with status: 'draft' or 'archived'. Pass null to cancel a previously scheduled publish."),
7808
+ "scheduledAt": zod.number().min(updatePostBySlugBodyScheduledAtMin).nullish().describe("Unix timestamp (milliseconds) to schedule the post's first publish at a future time. Must be in the future and at most 30 days out. Only valid for draft posts that haven't been published or already scheduled. Cannot be combined with status: 'draft' or 'archived'. Pass null to cancel a previously scheduled publish. The value 0 is treated the same as omitting the field (no scheduling request); note that on an already-scheduled post, omitting `scheduledAt` while changing `status` cancels the schedule."),
7807
7809
  "sendNewsletter": zod.union([zod.boolean(), zod.enum(["true", "false", "1", "0"])]).optional().describe("Whether to send an email newsletter to subscribers when the post publishes. Only meaningful when publishing (status: 'published') or scheduling (scheduledAt set). Default: false"),
7808
- "publishedAt": zod.number().min(updatePostBySlugBodyPublishedAtMin).optional().describe("Unix timestamp (milliseconds) to set as the post's publish date. Once set, the date is preserved across re-publishes.")
7810
+ "publishedAt": zod.number().min(updatePostBySlugBodyPublishedAtMin).optional().describe("Unix timestamp (milliseconds) to set as the post's publish date. Once set, the date is preserved across re-publishes."),
7811
+ "imageUrl": zod.string().url().optional().describe("URL of an image to set as the post's cover/hero image. The image is fetched, re-hosted on Paragraph's CDN, and a placeholder is generated. Pass clearImage: true instead to remove the existing cover."),
7812
+ "clearImage": zod.boolean().optional().describe("When true, removes the post's existing cover/hero image. Ignored if imageUrl is also provided.")
7809
7813
  });
7810
7814
  updatePostBySlugResponse = zod.object({
7811
7815
  "success": zod.literal(true).describe("Whether the update succeeded")
@@ -8454,7 +8458,9 @@ async function updatePost(idOrSlug, params) {
8454
8458
  subtitle: params.subtitle,
8455
8459
  markdown: params.markdown,
8456
8460
  categories: params.tags,
8457
- publishedAt: params.publishedAt
8461
+ publishedAt: params.publishedAt,
8462
+ imageUrl: params.imageUrl,
8463
+ clearImage: params.clearImage
8458
8464
  };
8459
8465
  updatePostBody.parse(body);
8460
8466
  const client = createClient(params.apiKey);
@@ -8747,22 +8753,24 @@ Examples:
8747
8753
  handleError(err);
8748
8754
  }
8749
8755
  });
8750
- const updateCmd = (parent) => parent.command("update [id-or-slug]").description("Update a post").option("--id <id-or-slug>", "Post ID or slug").option("--title <title>", "Post title").option("--text <markdown>", "Post content as markdown string").option("--file <path>", "Read post content from a file").option("--subtitle <subtitle>", "Post subtitle").option("--tags <tags>", "Comma-separated tags").option("--published-at <time>", "Set the post's display publish date (ISO 8601 or Unix ms). Sticks across re-publishes \u2014 useful for backdating.").addHelpText("after", `
8756
+ const updateCmd = (parent) => parent.command("update [id-or-slug]").description("Update a post").option("--id <id-or-slug>", "Post ID or slug").option("--title <title>", "Post title").option("--text <markdown>", "Post content as markdown string").option("--file <path>", "Read post content from a file").option("--subtitle <subtitle>", "Post subtitle").option("--tags <tags>", "Comma-separated tags").option("--published-at <time>", "Set the post's display publish date (ISO 8601 or Unix ms). Sticks across re-publishes \u2014 useful for backdating.").option("--image-url <url>", "URL of an image to set as the post's cover. Fetched server-side, re-hosted on Paragraph's CDN.").option("--clear-image", "Remove the post's existing cover image. Ignored if --image-url is also provided.").addHelpText("after", `
8751
8757
  Examples:
8752
8758
  $ paragraph post update my-post --title "New Title"
8753
8759
  $ paragraph post update --id my-post --title "New Title"
8754
8760
  $ paragraph post update my-post --file ./updated.md
8755
8761
  $ cat updated.md | paragraph post update my-post
8756
8762
  $ paragraph post update my-post --tags "web3,defi" --json
8757
- $ paragraph post update my-post --published-at "2024-01-01T00:00:00Z"`).action(async function(idOrSlug, opts) {
8763
+ $ paragraph post update my-post --published-at "2024-01-01T00:00:00Z"
8764
+ $ paragraph post update my-post --image-url https://example.com/cover.jpg
8765
+ $ paragraph post update my-post --clear-image`).action(async function(idOrSlug, opts) {
8758
8766
  try {
8759
8767
  const id = requireArg(idOrSlug, opts.id, "post ID or slug");
8760
8768
  const apiKey = requireApiKey();
8761
8769
  const markdown = await resolveMarkdown(opts);
8762
8770
  const publishedAt = opts.publishedAt ? parseScheduleTime(opts.publishedAt) : void 0;
8763
- if (!opts.title && !opts.subtitle && !markdown && !opts.tags && publishedAt === void 0) {
8771
+ if (!opts.title && !opts.subtitle && !markdown && !opts.tags && publishedAt === void 0 && !opts.imageUrl && !opts.clearImage) {
8764
8772
  throw new Error(
8765
- "Nothing to update. Provide --title, --subtitle, --text, --file, --tags, or --published-at."
8773
+ "Nothing to update. Provide --title, --subtitle, --text, --file, --tags, --published-at, --image-url, or --clear-image."
8766
8774
  );
8767
8775
  }
8768
8776
  await updatePost(id, {
@@ -8771,7 +8779,9 @@ Examples:
8771
8779
  markdown,
8772
8780
  subtitle: opts.subtitle,
8773
8781
  tags: opts.tags?.split(",").map((t) => t.trim()),
8774
- publishedAt
8782
+ publishedAt,
8783
+ imageUrl: opts.imageUrl,
8784
+ clearImage: opts.clearImage
8775
8785
  });
8776
8786
  writeSuccess(`Post updated: ${id}`);
8777
8787
  outputData(
@@ -9886,7 +9896,7 @@ var init_email = __esm({
9886
9896
  // src/cli/program.ts
9887
9897
  function createProgram() {
9888
9898
  const program2 = new Command();
9889
- program2.name("paragraph").description("CLI for Paragraph").version("0.3.0", "-v, --version").option("--json", "Output as JSON").option("--verbose", "Show detailed output for debugging").exitOverride().configureOutput({
9899
+ program2.name("paragraph").description("CLI for Paragraph").version("0.3.1", "-v, --version").option("--json", "Output as JSON").option("--verbose", "Show detailed output for debugging").exitOverride().configureOutput({
9890
9900
  writeOut: (str) => process.stdout.write(str),
9891
9901
  writeErr: (str) => {
9892
9902
  if (process.argv.includes("--json")) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paragraph-com/cli",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "type": "module",
5
5
  "description": "CLI for Paragraph",
6
6
  "repository": {
@@ -43,7 +43,7 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@inkjs/ui": "^2.0.0",
46
- "@paragraph-com/sdk": "^2.2.0",
46
+ "@paragraph-com/sdk": "^2.2.1",
47
47
  "cli-table3": "^0.6.5",
48
48
  "commander": "^12.0.0",
49
49
  "ink": "^5.1.0",