@passband/sdk - v0.0.0
    Preparing search index...

    Class DraftsResource

    Drafts resource — GET/POST /drafts, GET/PATCH /drafts/{id}, POST /drafts/bulk.

    Index

    Constructors

    • Parameters

      • http: HttpClient

      Returns DraftsResource

    Methods

    • Approve a draft. Convenience over update. PATCH /drafts/{id}

      Parameters

      • id: string

      Returns Promise<
          {
              confidence?: number;
              createdAt?: string;
              feedback?: string
              | null;
              format?: "SHORT" | "THREAD" | "BLOG";
              id?: string;
              itemId?: string;
              postedAt?: string | null;
              postId?: string | null;
              regeneratedFromId?: string | null;
              rejectionFeedback?: string | null;
              scheduledAt?: string | null;
              status?:
                  | "pending_generation"
                  | "generation_failed"
                  | "pending_review"
                  | "awaiting_review"
                  | "approved"
                  | "rejected"
                  | "changes_requested"
                  | "pending_regeneration"
                  | "scheduled"
                  | "posting"
                  | "missed"
                  | "posted";
              text?: string;
              updatedAt?: string;
          },
      >

    • Create one or more drafts. POST /drafts

      Parameters

      • body: {
            format?: "SHORT" | "THREAD" | "BLOG";
            formats?: ("SHORT" | "THREAD" | "BLOG")[];
            images?: {
                alt?: string;
                position?: number;
                source: "OG" | "UPLOAD" | "AI_OPENAI" | "AI_GEMINI";
                url: string;
            }[];
            prompt?: string;
            tags?: string[];
            targetPlatforms?: string[];
            text?: string;
            url?: string;
        }
        • Optionalformat?: "SHORT" | "THREAD" | "BLOG"

          Draft format (direct mode). Defaults to SHORT.

        • Optionalformats?: ("SHORT" | "THREAD" | "BLOG")[]

          Formats to generate (generate mode). Defaults to ["SHORT"].

        • Optionalimages?: {
              alt?: string;
              position?: number;
              source: "OG" | "UPLOAD" | "AI_OPENAI" | "AI_GEMINI";
              url: string;
          }[]

          Image attachments. In generate mode, images attach to the first draft.

        • Optionalprompt?: string

          Prompt for AI generation (generate mode). Can be combined with url.

        • Optionaltags?: string[]

          Tags for the created draft(s).

        • OptionaltargetPlatforms?: string[]

          Target publishing platforms.

        • Optionaltext?: string

          Draft content (direct mode). Mutually exclusive with url/prompt.

        • Optionalurl?: string

          Format: uri

          Source URL for AI generation (generate mode).

      Returns Promise<
          {
              drafts?: {
                  confidence?: number;
                  createdAt?: string;
                  format?: "SHORT"
                  | "THREAD"
                  | "BLOG";
                  id?: string;
                  images?: {
                      alt?: string | null;
                      id?: string;
                      position?: number;
                      source?: "OG" | "UPLOAD" | "AI_OPENAI" | "AI_GEMINI";
                      url?: string;
                  }[];
                  status?: string;
                  text?: string;
              }[];
              itemId?: string;
              mode?: "direct"
              | "generate";
          },
      >

    • Get a single draft by id. GET /drafts/{id}

      Parameters

      • id: string

      Returns Promise<
          {
              confidence?: number;
              createdAt?: string;
              feedback?: string
              | null;
              format?: "SHORT" | "THREAD" | "BLOG";
              id?: string;
              itemId?: string;
              postedAt?: string | null;
              postId?: string | null;
              regeneratedFromId?: string | null;
              rejectionFeedback?: string | null;
              scheduledAt?: string | null;
              status?:
                  | "pending_generation"
                  | "generation_failed"
                  | "pending_review"
                  | "awaiting_review"
                  | "approved"
                  | "rejected"
                  | "changes_requested"
                  | "pending_regeneration"
                  | "scheduled"
                  | "posting"
                  | "missed"
                  | "posted";
              text?: string;
              updatedAt?: string;
          } & { item?: { id?: string; sourceType?: string; title?: string } },
      >

    • Iterate every draft across all pages, transparently following nextCursor. Each await yields one DraftSummary; the underlying GET /drafts is paged lazily as the iterator is consumed.

      for await (const draft of pb.drafts.iterate({ status: 'pending_review' })) {
      console.log(draft.id)
      }

      The cursor field of params is used as the starting point; it is then managed automatically and should not be set when resuming.

      Parameters

      Returns AsyncIterableIterator<
          {
              confidence?: number;
              createdAt?: string;
              feedback?: string
              | null;
              format?: "SHORT" | "THREAD" | "BLOG";
              id?: string;
              itemId?: string;
              postedAt?: string | null;
              postId?: string | null;
              regeneratedFromId?: string | null;
              rejectionFeedback?: string | null;
              scheduledAt?: string | null;
              status?:
                  | "pending_generation"
                  | "generation_failed"
                  | "pending_review"
                  | "awaiting_review"
                  | "approved"
                  | "rejected"
                  | "changes_requested"
                  | "pending_regeneration"
                  | "scheduled"
                  | "posting"
                  | "missed"
                  | "posted";
              text?: string;
              updatedAt?: string;
          } & { item?: { id?: string; sourceType?: string; title?: string } },
      >

    • List drafts (single page). GET /drafts

      Parameters

      Returns Promise<
          {
              drafts?: (
                  {
                      confidence?: number;
                      createdAt?: string;
                      feedback?: string
                      | null;
                      format?: "SHORT" | "THREAD" | "BLOG";
                      id?: string;
                      itemId?: string;
                      postedAt?: string | null;
                      postId?: string | null;
                      regeneratedFromId?: string | null;
                      rejectionFeedback?: string | null;
                      scheduledAt?: string | null;
                      status?:
                          | "pending_generation"
                          | "generation_failed"
                          | "pending_review"
                          | "awaiting_review"
                          | "approved"
                          | "rejected"
                          | "changes_requested"
                          | "pending_regeneration"
                          | "scheduled"
                          | "posting"
                          | "missed"
                          | "posted";
                      text?: string;
                      updatedAt?: string;
                  } & { item?: { id?: string; sourceType?: string; title?: string } }
              )[];
              nextCursor?: string | null;
          },
      >

    post

    • post(
          id: string,
          body?: PostDraftBody,
      ): Promise<
          {
              draft: {
                  confidence?: number;
                  createdAt?: string;
                  feedback?: string
                  | null;
                  format?: "SHORT" | "THREAD" | "BLOG";
                  id?: string;
                  itemId?: string;
                  postedAt?: string | null;
                  postId?: string | null;
                  regeneratedFromId?: string | null;
                  rejectionFeedback?: string | null;
                  scheduledAt?: string | null;
                  status?:
                      | "pending_generation"
                      | "generation_failed"
                      | "pending_review"
                      | "awaiting_review"
                      | "approved"
                      | "rejected"
                      | "changes_requested"
                      | "pending_regeneration"
                      | "scheduled"
                      | "posting"
                      | "missed"
                      | "posted";
                  text?: string;
                  updatedAt?: string;
              };
              failed: string[];
              posted: string[];
          },
      >

      Post a draft to its connected platforms. PATCH /drafts/{id} with action: 'post'. Unlike update, this returns a PostResult wrapper ({ posted, failed, draft }) matching the route's actual response.

      Parameters

      Returns Promise<
          {
              draft: {
                  confidence?: number;
                  createdAt?: string;
                  feedback?: string
                  | null;
                  format?: "SHORT" | "THREAD" | "BLOG";
                  id?: string;
                  itemId?: string;
                  postedAt?: string | null;
                  postId?: string | null;
                  regeneratedFromId?: string | null;
                  rejectionFeedback?: string | null;
                  scheduledAt?: string | null;
                  status?:
                      | "pending_generation"
                      | "generation_failed"
                      | "pending_review"
                      | "awaiting_review"
                      | "approved"
                      | "rejected"
                      | "changes_requested"
                      | "pending_regeneration"
                      | "scheduled"
                      | "posting"
                      | "missed"
                      | "posted";
                  text?: string;
                  updatedAt?: string;
              };
              failed: string[];
              posted: string[];
          },
      >

    • Apply a state transition or content edit to a draft. PATCH /drafts/{id}

      Parameters

      Returns Promise<
          {
              confidence?: number;
              createdAt?: string;
              feedback?: string
              | null;
              format?: "SHORT" | "THREAD" | "BLOG";
              id?: string;
              itemId?: string;
              postedAt?: string | null;
              postId?: string | null;
              regeneratedFromId?: string | null;
              rejectionFeedback?: string | null;
              scheduledAt?: string | null;
              status?:
                  | "pending_generation"
                  | "generation_failed"
                  | "pending_review"
                  | "awaiting_review"
                  | "approved"
                  | "rejected"
                  | "changes_requested"
                  | "pending_regeneration"
                  | "scheduled"
                  | "posting"
                  | "missed"
                  | "posted";
              text?: string;
              updatedAt?: string;
          },
      >