diff --git a/api.ts b/api.ts index d3adbc3..fc4d2f1 100644 --- a/api.ts +++ b/api.ts @@ -1,50 +1,5 @@ -export * as pages from "./api/pages.ts"; -export * as projects from "./api/projects.ts"; -export * as users from "./api/users.ts"; +export * from "./api/pages.ts"; +export * from "./api/projects.ts"; +export * from "./api/users.ts"; export type { HTTPError, TypedError } from "./error.ts"; export type { BaseOptions, ExtendedOptions, OAuthOptions } from "./util.ts"; - -export { - get as listPages, - list as listPagesStream, - type ListPagesOption, - type ListPagesStreamOption, - makeGetRequest as makeListPagesRequest, -} from "./api/pages/project.ts"; -export { - makePostRequest as makeReplaceLinksRequest, - post as replaceLinks, -} from "./api/pages/project/replace/links.ts"; -export { - get as searchForPages, - makeGetRequest as makeSearchForPagesRequest, -} from "./api/pages/project/search/query.ts"; -export { - get as getLinks, - type GetLinksOptions, - list as readLinks, - makeGetRequest as makeGetLinksRequest, -} from "./api/pages/project/search/titles.ts"; -export { - get as getPage, - type GetPageOption, - makeGetRequest as makeGetPageRequest, -} from "./api/pages/project/title.ts"; -export { - get as getText, - type GetTextOption, - makeGetRequest as makeGetTextRequest, -} from "./api/pages/project/title/text.ts"; -export { - get as getIcon, - type GetIconOption, - makeGetRequest as makeGetIconRequest, -} from "./api/pages/project/title/icon.ts"; -export { - get as getProject, - makeGetRequest as makeGetProjectRequest, -} from "./api/projects/project.ts"; -export { - get as getUser, - makeGetRequest as makeGetUserRequest, -} from "./api/users/me.ts"; diff --git a/api/pages.ts b/api/pages.ts index ee9af7c..1fd2482 100644 --- a/api/pages.ts +++ b/api/pages.ts @@ -1 +1 @@ -export * as project from "./pages/project.ts"; +export * from "./pages/project.ts"; diff --git a/api/pages/project.ts b/api/pages/project.ts index 55af0b2..e93402b 100644 --- a/api/pages/project.ts +++ b/api/pages/project.ts @@ -21,7 +21,7 @@ import { pooledMap } from "@std/async/pool"; import { range } from "@core/iterutil/range"; import { flatten } from "@core/iterutil/async/flatten"; -/** Options for {@linkcode get} +/** Options for {@linkcode listPages} * * @experimental **UNSTABLE**: New API, yet to be vetted. */ @@ -102,7 +102,7 @@ export const makeGetRequest = ( * - {@linkcode NotLoggedInError}: Authentication required * - {@linkcode NotMemberError}: User lacks access */ -export const get = ( +export const listPages = ( project: string, options?: ListPagesOption, ): Promise< @@ -125,7 +125,7 @@ export const get = ( >; /** - * Options for {@linkcode list} + * Options for {@linkcode listPagesStream} * * @experimental **UNSTABLE**: New API, yet to be vetted. */ @@ -147,7 +147,7 @@ export interface ListPagesStreamOption * @param options Configuration options for pagination and sorting * @throws {HTTPError | TypedError<"NotLoggedInError" | "NotMemberError" | "NotFoundError">} If any requests in the pagination sequence fail */ -export async function* list( +export async function* listPagesStream( project: string, options?: ListPagesStreamOption, ): AsyncGenerator { @@ -156,7 +156,7 @@ export async function* list( skip: options?.skip ?? 0, limit: options?.limit ?? 100, }; - const response = await ensureResponse(await get(project, props)); + const response = await ensureResponse(await listPages(project, props)); const list = await response.json(); yield* list.pages; @@ -170,7 +170,7 @@ export async function* list( range(0, times - 1), async (i) => { const response = await ensureResponse( - await get(project, { ...props, skip: skip + i * limit, limit }), + await listPages(project, { ...props, skip: skip + i * limit, limit }), ); const list = await response.json(); return list.pages; @@ -203,6 +203,6 @@ const ensureResponse = async ( } }; -export * as replace from "./project/replace.ts"; -export * as search from "./project/search.ts"; -export * as title from "./project/title.ts"; +export * from "./project/replace.ts"; +export * from "./project/search.ts"; +export * from "./project/title.ts"; diff --git a/api/pages/project/replace.ts b/api/pages/project/replace.ts index b811f7e..01d0e35 100644 --- a/api/pages/project/replace.ts +++ b/api/pages/project/replace.ts @@ -1 +1 @@ -export * as links from "./replace/links.ts"; +export * from "./replace/links.ts"; diff --git a/api/pages/project/replace/links.ts b/api/pages/project/replace/links.ts index 9503f23..9f4635d 100644 --- a/api/pages/project/replace/links.ts +++ b/api/pages/project/replace/links.ts @@ -6,7 +6,7 @@ import type { import type { ResponseOfEndpoint } from "../../../../targeted_response.ts"; import { type ExtendedOptions, setDefaults } from "../../../../util.ts"; import { cookie } from "../../../../rest/auth.ts"; -import { get } from "../../../users/me.ts"; +import { getUser } from "../../../users/me.ts"; /** Constructs a request for the `/api/pages/:project/replace/links` endpoint * @@ -18,7 +18,7 @@ import { get } from "../../../users/me.ts"; * @param init - Additional configuration options * @returns A {@linkcode Request} object for replacing links in `project` */ -export const makePostRequest = ( +export const makeReplaceLinksRequest = ( project: string, from: string, to: string, @@ -55,7 +55,7 @@ export const makePostRequest = ( * - {@linkcode NotLoggedInError}: Authentication required * - {@linkcode NotMemberError}: User lacks access */ -export const post = async ( +export const replaceLinks = async ( project: string, from: string, to: string, @@ -71,13 +71,13 @@ export const post = async ( let { csrf, fetch, ...init2 } = setDefaults(init ?? {}); if (!csrf) { - const res = await get(init2); + const res = await getUser(init2); if (!res.ok) return res; csrf = (await res.json()).csrfToken; } return fetch( - makePostRequest(project, from, to, { csrf, ...init2 }), + makeReplaceLinksRequest(project, from, to, { csrf, ...init2 }), ) as Promise< ResponseOfEndpoint<{ 200: string; diff --git a/api/pages/project/search.ts b/api/pages/project/search.ts index 0d80f9d..7e49096 100644 --- a/api/pages/project/search.ts +++ b/api/pages/project/search.ts @@ -1,2 +1,2 @@ -export * as query from "./search/query.ts"; -export * as titles from "./search/titles.ts"; +export * from "./search/query.ts"; +export * from "./search/titles.ts"; diff --git a/api/pages/project/search/query.ts b/api/pages/project/search/query.ts index 2ca88e2..a9284a6 100644 --- a/api/pages/project/search/query.ts +++ b/api/pages/project/search/query.ts @@ -17,7 +17,7 @@ import { cookie } from "../../../../rest/auth.ts"; * @param options - Additional configuration options * @returns A {@linkcode Request} object for fetching page data */ -export const makeGetRequest = ( +export const makeSearchForPagesRequest = ( project: string, query: string, options?: BaseOptions, @@ -41,7 +41,7 @@ export const makeGetRequest = ( * @param options Additional configuration options for the request * @returns A {@linkcode Response} object containing the search results */ -export const get = ( +export const searchForPages = ( project: string, query: string, options?: BaseOptions, @@ -55,7 +55,7 @@ export const get = ( }, R> > => setDefaults(options ?? {}).fetch( - makeGetRequest(project, query, options), + makeSearchForPagesRequest(project, query, options), ) as Promise< ResponseOfEndpoint<{ 200: SearchResult; diff --git a/api/pages/project/title.ts b/api/pages/project/title.ts index 9390cbb..bc03402 100644 --- a/api/pages/project/title.ts +++ b/api/pages/project/title.ts @@ -32,7 +32,7 @@ export interface GetPageOption * @param options - Additional configuration options * @returns A {@linkcode Request} object for fetching page data */ -export const makeGetRequest = ( +export const makeGetPageRequest = ( project: string, title: string, options?: GetPageOption, @@ -64,7 +64,7 @@ export const makeGetRequest = ( * - {@linkcode NotLoggedInError}: Authentication required * - {@linkcode NotMemberError}: User lacks access */ -export const get = ( +export const getPage = ( project: string, title: string, options?: GetPageOption, @@ -77,7 +77,7 @@ export const get = ( }, R> > => setDefaults(options ?? {}).fetch( - makeGetRequest(project, title, options), + makeGetPageRequest(project, title, options), ) as Promise< ResponseOfEndpoint<{ 200: Page; @@ -87,5 +87,5 @@ export const get = ( }, R> >; -export * as text from "./title/text.ts"; -export * as icon from "./title/icon.ts"; +export * from "./title/text.ts"; +export * from "./title/icon.ts"; diff --git a/api/pages/project/title/icon.ts b/api/pages/project/title/icon.ts index 00cab99..390cd58 100644 --- a/api/pages/project/title/icon.ts +++ b/api/pages/project/title/icon.ts @@ -9,7 +9,7 @@ import { encodeTitleURI } from "../../../../title.ts"; import { cookie } from "../../../../rest/auth.ts"; /** - * Options for {@linkcode get} + * Options for {@linkcode getIcon} * * @experimental **UNSTABLE**: New API, yet to be vetted. */ @@ -28,7 +28,7 @@ export interface GetIconOption * @param options - Additional configuration options * @returns A {@linkcode Request} object for fetching page data */ -export const makeGetRequest = ( +export const makeGetIconRequest = ( project: string, title: string, options?: GetIconOption, @@ -52,7 +52,7 @@ export const makeGetRequest = ( * @param options Additional configuration options for the request * @returns A {@linkcode Response} object containing the page image */ -export const get = ( +export const getIcon = ( project: string, title: string, options?: GetIconOption, @@ -65,7 +65,7 @@ export const get = ( }, R> > => setDefaults(options ?? {}).fetch( - makeGetRequest(project, title, options), + makeGetIconRequest(project, title, options), ) as Promise< ResponseOfEndpoint<{ 200: Blob; diff --git a/api/pages/project/title/text.ts b/api/pages/project/title/text.ts index 9235472..609132a 100644 --- a/api/pages/project/title/text.ts +++ b/api/pages/project/title/text.ts @@ -9,7 +9,7 @@ import { encodeTitleURI } from "../../../../title.ts"; import { cookie } from "../../../../rest/auth.ts"; /** - * Options for {@linkcode get} + * Options for {@linkcode getText} * * @experimental **UNSTABLE**: New API, yet to be vetted. */ @@ -28,7 +28,7 @@ export interface GetTextOption * @param options - Additional configuration options * @returns A {@linkcode Request} object for fetching page data */ -export const makeGetRequest = ( +export const makeGetTextRequest = ( project: string, title: string, options?: GetTextOption, @@ -52,7 +52,7 @@ export const makeGetRequest = ( * @param options Additional configuration options for the request * @returns A {@linkcode Response} object containing the page text */ -export const get = ( +export const getText = ( project: string, title: string, options?: GetTextOption, @@ -65,7 +65,7 @@ export const get = ( }, R> > => setDefaults(options ?? {}).fetch( - makeGetRequest(project, title, options), + makeGetTextRequest(project, title, options), ) as Promise< ResponseOfEndpoint<{ 200: string; diff --git a/api/projects.ts b/api/projects.ts index 36f503d..f596ea9 100644 --- a/api/projects.ts +++ b/api/projects.ts @@ -1 +1 @@ -export * as project from "./projects/project.ts"; +export * from "./projects/project.ts"; diff --git a/api/projects/project.ts b/api/projects/project.ts index 90865e4..740d72e 100644 --- a/api/projects/project.ts +++ b/api/projects/project.ts @@ -17,7 +17,7 @@ import { cookie } from "../../rest/auth.ts"; * @param options - Additional configuration options * @returns A {@linkcode Request} object for fetching project data */ -export const makeGetRequest = ( +export const makeGetProjectRequest = ( project: string, options?: BaseOptions, ): Request => { @@ -41,7 +41,7 @@ export const makeGetRequest = ( * @param options Additional configuration options for the request * @returns A {@linkcode Response} object containing the project data */ -export const get = ( +export const getProject = ( project: string, options?: BaseOptions, ): Promise< @@ -53,7 +53,7 @@ export const get = ( }, R> > => setDefaults(options ?? {}).fetch( - makeGetRequest(project, options), + makeGetProjectRequest(project, options), ) as Promise< ResponseOfEndpoint<{ 200: MemberProject | NotMemberProject; diff --git a/api/users.ts b/api/users.ts index 508ba8d..45bd723 100644 --- a/api/users.ts +++ b/api/users.ts @@ -1 +1 @@ -export * as me from "./users/me.ts"; +export * from "./users/me.ts"; diff --git a/api/users/me.ts b/api/users/me.ts index 8fb5616..2c34e80 100644 --- a/api/users/me.ts +++ b/api/users/me.ts @@ -13,7 +13,7 @@ import { cookie } from "../../rest/auth.ts"; * @param init - Options including `connect.sid` (session ID) and other configuration * @returns A {@linkcode Request} object for fetching user profile data */ -export const makeGetRequest = ( +export const makeGetUserRequest = ( init?: BaseOptions, ): Request => { const { sid, baseURL } = setDefaults(init ?? {}); @@ -30,11 +30,11 @@ export const makeGetRequest = ( * @param init - Options including `connect.sid` (session ID) and other configuration * @returns A {@linkcode Response} object containing the user profile data */ -export const get = ( +export const getUser = ( init?: BaseOptions, ): Promise< ResponseOfEndpoint<{ 200: MemberUser | GuestUser }, R> > => setDefaults(init ?? {}).fetch( - makeGetRequest(init), + makeGetUserRequest(init), ) as Promise>;