Skip to content

Commit 2d0d03f

Browse files
committed
Merge branch 'main' into copilot/fix-6ec0a2ff-f2ad-42c5-b65e-98e76f6953de
2 parents 4e2bee8 + e1fda30 commit 2d0d03f

File tree

22 files changed

+207
-97
lines changed

22 files changed

+207
-97
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@ on: [push, pull_request]
99
jobs:
1010
test:
1111
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
1214
steps:
1315
- uses: actions/checkout@v4
1416
- uses: denoland/setup-deno@v2
1517
with:
1618
deno-version: ${{ env.DENO_VERSION }}
19+
cache: true
1720
- name: Check fmt & lint & type check & test
1821
run: deno task check

.github/workflows/publish.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ jobs:
2323
- uses: denoland/setup-deno@v2
2424
with:
2525
deno-version: ${{ env.DENO_VERSION }}
26+
cache: true
2627
- name: Publish to JSR
2728
run: deno run --allow-env --allow-run=deno --allow-read --allow-write=deno.jsonc jsr:@david/[email protected]
28-
29+
2930
publish-npm:
3031
runs-on: ubuntu-latest
3132
steps:

.github/workflows/udd.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@ jobs:
2121
- uses: denoland/setup-deno@v2
2222
with:
2323
deno-version: ${{ env.DENO_VERSION }}
24+
cache: true
2425
- name: Update
2526
run: deno task update

api.ts

Lines changed: 4 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,6 @@
1-
export * as pages from "./api/pages.ts";
2-
export * as projects from "./api/projects.ts";
3-
export * as users from "./api/users.ts";
1+
export * from "./api/pages.ts";
2+
export * from "./api/projects.ts";
3+
export * from "./api/users.ts";
4+
export * from "./api/smart-context.ts";
45
export type { HTTPError, TypedError } from "./error.ts";
56
export type { BaseOptions, ExtendedOptions, OAuthOptions } from "./util.ts";
6-
7-
export {
8-
get as listPages,
9-
list as listPagesStream,
10-
type ListPagesOption,
11-
type ListPagesStreamOption,
12-
makeGetRequest as makeListPagesRequest,
13-
} from "./api/pages/project.ts";
14-
export {
15-
makePostRequest as makeReplaceLinksRequest,
16-
post as replaceLinks,
17-
} from "./api/pages/project/replace/links.ts";
18-
export {
19-
get as searchForPages,
20-
makeGetRequest as makeSearchForPagesRequest,
21-
} from "./api/pages/project/search/query.ts";
22-
export {
23-
get as getLinks,
24-
type GetLinksOptions,
25-
list as readLinks,
26-
makeGetRequest as makeGetLinksRequest,
27-
} from "./api/pages/project/search/titles.ts";
28-
export {
29-
get as getPage,
30-
type GetPageOption,
31-
makeGetRequest as makeGetPageRequest,
32-
} from "./api/pages/project/title.ts";
33-
export {
34-
get as getText,
35-
type GetTextOption,
36-
makeGetRequest as makeGetTextRequest,
37-
} from "./api/pages/project/title/text.ts";
38-
export {
39-
get as getIcon,
40-
type GetIconOption,
41-
makeGetRequest as makeGetIconRequest,
42-
} from "./api/pages/project/title/icon.ts";
43-
export {
44-
get as getProject,
45-
makeGetRequest as makeGetProjectRequest,
46-
} from "./api/projects/project.ts";
47-
export {
48-
get as getUser,
49-
makeGetRequest as makeGetUserRequest,
50-
} from "./api/users/me.ts";

api/pages.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * as project from "./pages/project.ts";
1+
export * from "./pages/project.ts";

api/pages/project.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { pooledMap } from "@std/async/pool";
2121
import { range } from "@core/iterutil/range";
2222
import { flatten } from "@core/iterutil/async/flatten";
2323

24-
/** Options for {@linkcode get}
24+
/** Options for {@linkcode listPages}
2525
*
2626
* @experimental **UNSTABLE**: New API, yet to be vetted.
2727
*/
@@ -102,7 +102,7 @@ export const makeGetRequest = <R extends Response | undefined>(
102102
* - {@linkcode NotLoggedInError}: Authentication required
103103
* - {@linkcode NotMemberError}: User lacks access
104104
*/
105-
export const get = <R extends Response | undefined = Response>(
105+
export const listPages = <R extends Response | undefined = Response>(
106106
project: string,
107107
options?: ListPagesOption<R>,
108108
): Promise<
@@ -125,7 +125,7 @@ export const get = <R extends Response | undefined = Response>(
125125
>;
126126

127127
/**
128-
* Options for {@linkcode list}
128+
* Options for {@linkcode listPagesStream}
129129
*
130130
* @experimental **UNSTABLE**: New API, yet to be vetted.
131131
*/
@@ -147,7 +147,7 @@ export interface ListPagesStreamOption<R extends Response | undefined>
147147
* @param options Configuration options for pagination and sorting
148148
* @throws {HTTPError | TypedError<"NotLoggedInError" | "NotMemberError" | "NotFoundError">} If any requests in the pagination sequence fail
149149
*/
150-
export async function* list(
150+
export async function* listPagesStream(
151151
project: string,
152152
options?: ListPagesStreamOption<Response>,
153153
): AsyncGenerator<BasePage, void, unknown> {
@@ -156,7 +156,7 @@ export async function* list(
156156
skip: options?.skip ?? 0,
157157
limit: options?.limit ?? 100,
158158
};
159-
const response = await ensureResponse(await get(project, props));
159+
const response = await ensureResponse(await listPages(project, props));
160160
const list = await response.json();
161161
yield* list.pages;
162162

@@ -170,7 +170,7 @@ export async function* list(
170170
range(0, times - 1),
171171
async (i) => {
172172
const response = await ensureResponse(
173-
await get(project, { ...props, skip: skip + i * limit, limit }),
173+
await listPages(project, { ...props, skip: skip + i * limit, limit }),
174174
);
175175
const list = await response.json();
176176
return list.pages;
@@ -203,6 +203,6 @@ const ensureResponse = async (
203203
}
204204
};
205205

206-
export * as replace from "./project/replace.ts";
207-
export * as search from "./project/search.ts";
208-
export * as title from "./project/title.ts";
206+
export * from "./project/replace.ts";
207+
export * from "./project/search.ts";
208+
export * from "./project/title.ts";

api/pages/project/replace.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * as links from "./replace/links.ts";
1+
export * from "./replace/links.ts";

api/pages/project/replace/links.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {
66
import type { ResponseOfEndpoint } from "../../../../targeted_response.ts";
77
import { type ExtendedOptions, setDefaults } from "../../../../util.ts";
88
import { cookie } from "../../../../rest/auth.ts";
9-
import { get } from "../../../users/me.ts";
9+
import { getUser } from "../../../users/me.ts";
1010

1111
/** Constructs a request for the `/api/pages/:project/replace/links` endpoint
1212
*
@@ -18,7 +18,7 @@ import { get } from "../../../users/me.ts";
1818
* @param init - Additional configuration options
1919
* @returns A {@linkcode Request} object for replacing links in `project`
2020
*/
21-
export const makePostRequest = <R extends Response | undefined>(
21+
export const makeReplaceLinksRequest = <R extends Response | undefined>(
2222
project: string,
2323
from: string,
2424
to: string,
@@ -55,7 +55,7 @@ export const makePostRequest = <R extends Response | undefined>(
5555
* - {@linkcode NotLoggedInError}: Authentication required
5656
* - {@linkcode NotMemberError}: User lacks access
5757
*/
58-
export const post = async <R extends Response | undefined = Response>(
58+
export const replaceLinks = async <R extends Response | undefined = Response>(
5959
project: string,
6060
from: string,
6161
to: string,
@@ -71,13 +71,13 @@ export const post = async <R extends Response | undefined = Response>(
7171
let { csrf, fetch, ...init2 } = setDefaults(init ?? {});
7272

7373
if (!csrf) {
74-
const res = await get(init2);
74+
const res = await getUser(init2);
7575
if (!res.ok) return res;
7676
csrf = (await res.json()).csrfToken;
7777
}
7878

7979
return fetch(
80-
makePostRequest(project, from, to, { csrf, ...init2 }),
80+
makeReplaceLinksRequest(project, from, to, { csrf, ...init2 }),
8181
) as Promise<
8282
ResponseOfEndpoint<{
8383
200: string;

api/pages/project/search.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export * as query from "./search/query.ts";
2-
export * as titles from "./search/titles.ts";
1+
export * from "./search/query.ts";
2+
export * from "./search/titles.ts";

api/pages/project/search/query.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { cookie } from "../../../../rest/auth.ts";
1717
* @param options - Additional configuration options
1818
* @returns A {@linkcode Request} object for fetching page data
1919
*/
20-
export const makeGetRequest = <R extends Response | undefined>(
20+
export const makeSearchForPagesRequest = <R extends Response | undefined>(
2121
project: string,
2222
query: string,
2323
options?: BaseOptions<R>,
@@ -41,7 +41,7 @@ export const makeGetRequest = <R extends Response | undefined>(
4141
* @param options Additional configuration options for the request
4242
* @returns A {@linkcode Response} object containing the search results
4343
*/
44-
export const get = <R extends Response | undefined = Response>(
44+
export const searchForPages = <R extends Response | undefined = Response>(
4545
project: string,
4646
query: string,
4747
options?: BaseOptions<R>,
@@ -55,7 +55,7 @@ export const get = <R extends Response | undefined = Response>(
5555
}, R>
5656
> =>
5757
setDefaults(options ?? {}).fetch(
58-
makeGetRequest(project, query, options),
58+
makeSearchForPagesRequest(project, query, options),
5959
) as Promise<
6060
ResponseOfEndpoint<{
6161
200: SearchResult;

0 commit comments

Comments
 (0)