import { PagerParams } from './lib/pager.js'; import { OperationString } from './lib/graphql.js'; import { IsEmptyObject, DeepFlatten } from './lib/types.js'; import { ReactionContent } from './__generated__/codegen/graphql.js'; type SortDescAsc = "interactions" | "reactions" | "author-date" | "created" | "updated"; type SortReaction = "reactions-+1" | "reactions--1" | "reactions-smile" | "reactions-tada" | "reactions-heart"; type Sort = SortDescAsc | `${SortDescAsc}-asc` | `${SortDescAsc}-desc` | SortReaction; type QueryParams = { state?: "published" | "draft"; author?: string | string[]; notAuthor?: string | string[]; label?: string | string[]; notLabel?: string | string[]; sort?: Sort; search?: string; }; declare function buildQuery(this: Publissue, args?: QueryParams): string; type PublissueOptions = { /** * Full repo string containing owner and name. * @example { repo: "my-user/posts" } */ repo: string; /** * GitHub access token */ token: string; /** * Optional configuration */ config?: { /** * A label that controls published state * @default "state:published" */ publishedLabel?: string; /** * A label that controls draft state * @default "state:draft" */ draftLabel?: string; }; }; declare class Publissue { options: PublissueOptions; repo: { owner: string; name: string; fullName: string; id?: string; }; constructor(options: PublissueOptions); getRepoId(): Promise; rest(endpoint: `${"GET" | "POST" | "PUT" | "PATCH" | "DELETE"} /${string}`, init?: RequestInit): Promise<{ ok: false; response: Response; data: E; } | { ok: true; response: Response; data: T; }>; graphql(document: OperationString): { execute: (...[variables]: IsEmptyObject extends true ? [variables?: undefined] : [variables: DeepFlatten]) => Promise; }; addComment: (props: { body: string; postId: string; }) => Promise<{ comment: { id: string; reactions: { name: ReactionContent; count: number; }[]; author: { name: string; avatarUrl: string | null; login: string | null; twitterUsername: string | null; } | null; createdAt: string; body: string; lastEditedAt: string | null; isMinimized: boolean; minimizedReason: string | null; totalReactions: number; }; }>; createLabel: (props: { color: string; description?: string; name: string; }) => Promise<{ id: string; name: string; color: string; prefix: string | null; count: number; fullName: string; }>; createPost: (props: { title: string; body: string; meta?: { [key: string]: string | number; }; labelIds?: string[]; coauthorIds?: string[]; }) => Promise<{ number: number; id: string; reactions: { name: ReactionContent; count: number; }[]; author: { name: string; avatarUrl: string | null; login: string | null; twitterUsername: string | null; } | null; url: string; updatedAt: string; createdAt: string; title: string; body: string; coauthors: { name?: (string | null) | undefined; avatarUrl: string; login: string; twitterUsername?: (string | null) | undefined; }[]; labels: { id: string; name: string; color: string; prefix: string | null; count: number; fullName: string; }[]; meta: { [x: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | any | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null; }; }>; createRepository: (props?: { description?: string; homepageUrl?: string; } | undefined) => Promise<{ id: string; url: string; }>; deleteLabel: (id: string) => Promise<{ valueOf: () => boolean; } | { valueOf: () => boolean; }>; findPost: (props?: { query?: QueryParams; omitBody?: boolean; } | undefined) => Promise<{ number: number; id: string; reactions: { name: ReactionContent; count: number; }[]; author: { name: string; avatarUrl: string | null; login: string | null; twitterUsername: string | null; } | null; url: string; updatedAt: string; createdAt: string; title: string; body: string; coauthors: { name?: (string | null) | undefined; avatarUrl: string; login: string; twitterUsername?: (string | null) | undefined; }[]; labels: { id: string; name: string; color: string; prefix: string | null; count: number; fullName: string; }[]; meta: { [x: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | any | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null; }; } | null>; findPosts: (props?: (QueryParams & PagerParams & { omitBody?: boolean; }) | undefined) => Promise<{ totalCount: number; pageInfo: { __typename?: "PageInfo"; endCursor?: string | null; startCursor?: string | null; hasNextPage: boolean; hasPreviousPage: boolean; }; edges: { cursor: string; post: { number: number; id: string; reactions: { name: ReactionContent; count: number; }[]; author: { name: string; avatarUrl: string | null; login: string | null; twitterUsername: string | null; } | null; url: string; updatedAt: string; createdAt: string; title: string; body: string; coauthors: { name?: (string | null) | undefined; avatarUrl: string; login: string; twitterUsername?: (string | null) | undefined; }[]; labels: { id: string; name: string; color: string; prefix: string | null; count: number; fullName: string; }[]; meta: { [x: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | any | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null; }; } | null; }[] | undefined; }>; getComments: (props: ({ postNumber: number; } & PagerParams) | ({ postId: string; } & PagerParams)) => Promise<{ totalCount?: undefined; pageInfo?: undefined; edges?: undefined; } | { totalCount: number; pageInfo: { __typename?: "PageInfo"; endCursor?: string | null; startCursor?: string | null; hasNextPage: boolean; hasPreviousPage: boolean; }; edges: { cursor: string; comment: { id: string; reactions: { name: ReactionContent; count: number; }[]; author: { name: string; avatarUrl: string | null; login: string | null; twitterUsername: string | null; } | null; createdAt: string; body: string; lastEditedAt: string | null; isMinimized: boolean; minimizedReason: string | null; totalReactions: number; } | null; }[] | undefined; }>; getLabels: (props?: ({ search?: string; } & PagerParams) | undefined) => Promise<{ totalCount: number; pageInfo: {}; edges: { cursor: string; label: { id: string; name: string; color: string; prefix: string | null; count: number; fullName: string; }; }[]; }>; getPinnedPosts: (props?: { omitBody?: boolean; } | undefined) => Promise<{ pinnedPosts: { pinnedBy: { name: string; avatarUrl: string | null; login: string | null; twitterUsername: string | null; }; post: { number: number; id: string; reactions: { name: ReactionContent; count: number; }[]; author: { name: string; avatarUrl: string | null; login: string | null; twitterUsername: string | null; } | null; url: string; updatedAt: string; createdAt: string; title: string; body: string; coauthors: { name?: (string | null) | undefined; avatarUrl: string; login: string; twitterUsername?: (string | null) | undefined; }[]; labels: { id: string; name: string; color: string; prefix: string | null; count: number; fullName: string; }[]; meta: { [x: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | any | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null; }; }; }[]; }>; getPost: (props: ({ number: number; } | { id: string; }) & { omitBody?: boolean; }) => Promise<{ post: { number: number; id: string; reactions: { name: ReactionContent; count: number; }[]; author: { name: string; avatarUrl: string | null; login: string | null; twitterUsername: string | null; } | null; url: string; updatedAt: string; createdAt: string; title: string; body: string; coauthors: { name?: (string | null) | undefined; avatarUrl: string; login: string; twitterUsername?: (string | null) | undefined; }[]; labels: { id: string; name: string; color: string; prefix: string | null; count: number; fullName: string; }[]; meta: { [x: string]: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | any | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null)[] | { [x: string]: string | number | boolean | any | any | null; } | null; }; } | null; }>; getRateLimit: () => Promise<{ limit: number; used: number; resetAt: string; remaining: number; } | null | undefined>; getMe: () => Promise<{ id: string; login: string; email: string; }>; getRepository: () => Promise<{ id: string; url: string; }>; } export { Publissue as P, type QueryParams as Q, type SortDescAsc as S, type SortReaction as a, type Sort as b, buildQuery as c };