Edits history of script submission #23259 for ' List Project Statuses (linear)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    /**
     * List Project Statuses
     * List the workspace's project statuses. Use an id as status_id in Update Project. Types: backlog, planned, started, paused, completed, canceled.
     */
    export async function main(
      auth: RT.Linear,
      first: number = 50,
      after: string | undefined
    ) {
      const response = await fetch("https://api.linear.app/graphql", {
        method: "POST",
        headers: {
          Authorization: auth.apiKey,
          "Content-Type": "application/json",
          Accept: "application/json",
        },
        body: JSON.stringify({
          query: `query ($first: Int, $after: String) { projectStatuses(first: $first, after: $after) { nodes { id name type color position description } pageInfo { hasNextPage endCursor } } }`,
          variables: { first, after: after || undefined },
        }),
      })
    
      if (!response.ok) {
        throw new Error(`${response.status} ${await response.text()}`)
      }
    
      const { data, errors } = await response.json()
      if (errors) {
        throw new Error(JSON.stringify(errors))
      }
    
      return data.projectStatuses
    }
    

    Submitted by hugo989 2 hours ago