Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions api/pages/project/title.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import type {
NotFoundError,
NotLoggedInError,
NotMemberError,
Page,
PageWithInfoboxDefinition,
PageWithoutInfoboxDefinition,
} from "@cosense/types/rest";
import type { ResponseOfEndpoint } from "../../../targeted_response.ts";
import { type BaseOptions, setDefaults } from "../../../util.ts";
Expand Down Expand Up @@ -70,7 +71,7 @@ export const getPage = <R extends Response | undefined = Response>(
options?: GetPageOption<R>,
): Promise<
ResponseOfEndpoint<{
200: Page;
200: PageWithInfoboxDefinition | PageWithoutInfoboxDefinition;
404: NotFoundError;
401: NotLoggedInError;
403: NotMemberError;
Expand All @@ -80,7 +81,7 @@ export const getPage = <R extends Response | undefined = Response>(
makeGetPageRequest(project, title, options),
) as Promise<
ResponseOfEndpoint<{
200: Page;
200: PageWithInfoboxDefinition | PageWithoutInfoboxDefinition;
404: NotFoundError;
401: NotLoggedInError;
403: NotMemberError;
Expand Down
18 changes: 9 additions & 9 deletions deno.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,24 @@
},
"imports": {
"@core/iterutil": "jsr:@core/iterutil@^0.9.0",
"@core/unknownutil": "jsr:@core/unknownutil@^4.0.0",
"@core/unknownutil": "jsr:@core/unknownutil@^4.3.0",
"@cosense/std/browser/websocket": "./websocket/mod.ts",
"@cosense/std/rest": "./rest/mod.ts",
"@cosense/std/websocket": "./websocket/mod.ts",
"@cosense/types": "jsr:@cosense/types@^0.11.2",
"@cosense/types": "jsr:@cosense/types@^0.11.3",
"@deno/dnt": "jsr:@deno/dnt@^0.42.3",
"@progfay/scrapbox-parser": "jsr:@progfay/scrapbox-parser@^10.0.1",
"@std/assert": "jsr:@std/assert@1",
"@progfay/scrapbox-parser": "jsr:@progfay/scrapbox-parser@^10.0.2",
"@std/assert": "jsr:@std/assert@^1.0.14",
"@std/async": "jsr:@std/async@^1.0.14",
"@std/encoding": "jsr:@std/encoding@1",
"@std/http": "jsr:@std/http@^1.0.13",
"@std/json": "jsr:@std/json@^1.0.0",
"@std/encoding": "jsr:@std/encoding@^1.0.10",
"@std/http": "jsr:@std/http@^1.0.20",
"@std/json": "jsr:@std/json@^1.0.2",
"@std/jsonc": "jsr:@std/jsonc@^1.0.2",
"@std/testing": "jsr:@std/testing@^1.0.9",
"@std/testing": "jsr:@std/testing@^1.0.15",
"@takker/md5": "jsr:@takker/md5@0.1",
"@takker/onp": "./vendor/raw.githubusercontent.com/takker99/onp/0.0.1/mod.ts",
"option-t": "npm:option-t@53",
"socket.io-client": "npm:socket.io-client@^4.7.5"
"socket.io-client": "npm:socket.io-client@^4.8.1"
},
"lint": {
"exclude": [
Expand Down
85 changes: 41 additions & 44 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 22 additions & 5 deletions rest/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import type {
NotFoundError,
NotLoggedInError,
NotMemberError,
Page,
PageList,
PageWithInfoboxDefinition,
PageWithoutInfoboxDefinition,
} from "@cosense/types/rest";
import { cookie } from "./auth.ts";
import { parseHTTPError } from "./parseHTTPError.ts";
Expand Down Expand Up @@ -57,7 +58,10 @@ const getPage_fromResponse: GetPage["fromResponse"] = async (res) =>
mapErrAsyncForResult(
await mapAsyncForResult(
responseIntoResult(res),
(res) => res.json() as Promise<Page>,
(res) =>
res.json() as Promise<
PageWithInfoboxDefinition | PageWithoutInfoboxDefinition
>,
),
async (
error,
Expand Down Expand Up @@ -105,13 +109,22 @@ export interface GetPage {
* - {@linkcode NotMemberError}: User lacks access
* - {@linkcode HTTPError}: Other HTTP errors
*/
fromResponse: (res: Response) => Promise<Result<Page, PageError>>;
fromResponse: (
res: Response,
) => Promise<
Result<PageWithInfoboxDefinition | PageWithoutInfoboxDefinition, PageError>
>;

(
project: string,
title: string,
options?: GetPageOption,
): Promise<Result<Page, PageError | FetchError>>;
): Promise<
Result<
PageWithInfoboxDefinition | PageWithoutInfoboxDefinition,
PageError | FetchError
>
>;
}

export type PageError =
Expand All @@ -133,7 +146,11 @@ export const getPage: GetPage = /* @__PURE__ */ (() => {
title,
options,
) =>
andThenAsyncForResult<Response, Page, PageError | FetchError>(
andThenAsyncForResult<
Response,
PageWithInfoboxDefinition | PageWithoutInfoboxDefinition,
PageError | FetchError
>(
await setDefaults(options ?? {}).fetch(
getPage_toRequest(project, title, options),
),
Expand Down
2 changes: 1 addition & 1 deletion websocket/pull.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import type { BaseOptions } from "../rest/options.ts";
* This interface extends the basic {@linkcode Page} type with additional identifiers
* needed for real-time collaboration and page modifications.
*/
export interface PushMetadata extends Page {
export interface PushMetadata extends Page<boolean> {
/** Unique identifier of the project containing the page */
projectId: string;
/** Unique identifier of the current user */
Expand Down