Skip to content

Commit e92d30b

Browse files
authored
Merge pull request #246 from takker99:infobox
fix(api): Keep up with the return type of `getPage`
2 parents 34ab5a6 + b6714f7 commit e92d30b

File tree

5 files changed

+77
-62
lines changed

5 files changed

+77
-62
lines changed

api/pages/project/title.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import type {
22
NotFoundError,
33
NotLoggedInError,
44
NotMemberError,
5-
Page,
5+
PageWithInfoboxDefinition,
6+
PageWithoutInfoboxDefinition,
67
} from "@cosense/types/rest";
78
import type { ResponseOfEndpoint } from "../../../targeted_response.ts";
89
import { type BaseOptions, setDefaults } from "../../../util.ts";
@@ -70,7 +71,7 @@ export const getPage = <R extends Response | undefined = Response>(
7071
options?: GetPageOption<R>,
7172
): Promise<
7273
ResponseOfEndpoint<{
73-
200: Page;
74+
200: PageWithInfoboxDefinition | PageWithoutInfoboxDefinition;
7475
404: NotFoundError;
7576
401: NotLoggedInError;
7677
403: NotMemberError;
@@ -80,7 +81,7 @@ export const getPage = <R extends Response | undefined = Response>(
8081
makeGetPageRequest(project, title, options),
8182
) as Promise<
8283
ResponseOfEndpoint<{
83-
200: Page;
84+
200: PageWithInfoboxDefinition | PageWithoutInfoboxDefinition;
8485
404: NotFoundError;
8586
401: NotLoggedInError;
8687
403: NotMemberError;

deno.jsonc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,24 @@
4646
},
4747
"imports": {
4848
"@core/iterutil": "jsr:@core/iterutil@^0.9.0",
49-
"@core/unknownutil": "jsr:@core/unknownutil@^4.0.0",
49+
"@core/unknownutil": "jsr:@core/unknownutil@^4.3.0",
5050
"@cosense/std/browser/websocket": "./websocket/mod.ts",
5151
"@cosense/std/rest": "./rest/mod.ts",
5252
"@cosense/std/websocket": "./websocket/mod.ts",
53-
"@cosense/types": "jsr:@cosense/types@^0.11.2",
53+
"@cosense/types": "jsr:@cosense/types@^0.11.3",
5454
"@deno/dnt": "jsr:@deno/dnt@^0.42.3",
55-
"@progfay/scrapbox-parser": "jsr:@progfay/scrapbox-parser@^10.0.1",
56-
"@std/assert": "jsr:@std/assert@1",
55+
"@progfay/scrapbox-parser": "jsr:@progfay/scrapbox-parser@^10.0.2",
56+
"@std/assert": "jsr:@std/assert@^1.0.14",
5757
"@std/async": "jsr:@std/async@^1.0.14",
58-
"@std/encoding": "jsr:@std/encoding@1",
59-
"@std/http": "jsr:@std/http@^1.0.13",
60-
"@std/json": "jsr:@std/json@^1.0.0",
58+
"@std/encoding": "jsr:@std/encoding@^1.0.10",
59+
"@std/http": "jsr:@std/http@^1.0.20",
60+
"@std/json": "jsr:@std/json@^1.0.2",
6161
"@std/jsonc": "jsr:@std/jsonc@^1.0.2",
62-
"@std/testing": "jsr:@std/testing@^1.0.9",
62+
"@std/testing": "jsr:@std/testing@^1.0.15",
6363
"@takker/md5": "jsr:@takker/md5@0.1",
6464
"@takker/onp": "./vendor/raw.githubusercontent.com/takker99/onp/0.0.1/mod.ts",
6565
"option-t": "npm:option-t@53",
66-
"socket.io-client": "npm:socket.io-client@^4.7.5"
66+
"socket.io-client": "npm:socket.io-client@^4.8.1"
6767
},
6868
"lint": {
6969
"exclude": [

deno.lock

Lines changed: 41 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rest/pages.ts

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import type {
33
NotFoundError,
44
NotLoggedInError,
55
NotMemberError,
6-
Page,
76
PageList,
7+
PageWithInfoboxDefinition,
8+
PageWithoutInfoboxDefinition,
89
} from "@cosense/types/rest";
910
import { cookie } from "./auth.ts";
1011
import { parseHTTPError } from "./parseHTTPError.ts";
@@ -57,7 +58,10 @@ const getPage_fromResponse: GetPage["fromResponse"] = async (res) =>
5758
mapErrAsyncForResult(
5859
await mapAsyncForResult(
5960
responseIntoResult(res),
60-
(res) => res.json() as Promise<Page>,
61+
(res) =>
62+
res.json() as Promise<
63+
PageWithInfoboxDefinition | PageWithoutInfoboxDefinition
64+
>,
6165
),
6266
async (
6367
error,
@@ -105,13 +109,22 @@ export interface GetPage {
105109
* - {@linkcode NotMemberError}: User lacks access
106110
* - {@linkcode HTTPError}: Other HTTP errors
107111
*/
108-
fromResponse: (res: Response) => Promise<Result<Page, PageError>>;
112+
fromResponse: (
113+
res: Response,
114+
) => Promise<
115+
Result<PageWithInfoboxDefinition | PageWithoutInfoboxDefinition, PageError>
116+
>;
109117

110118
(
111119
project: string,
112120
title: string,
113121
options?: GetPageOption,
114-
): Promise<Result<Page, PageError | FetchError>>;
122+
): Promise<
123+
Result<
124+
PageWithInfoboxDefinition | PageWithoutInfoboxDefinition,
125+
PageError | FetchError
126+
>
127+
>;
115128
}
116129

117130
export type PageError =
@@ -133,7 +146,11 @@ export const getPage: GetPage = /* @__PURE__ */ (() => {
133146
title,
134147
options,
135148
) =>
136-
andThenAsyncForResult<Response, Page, PageError | FetchError>(
149+
andThenAsyncForResult<
150+
Response,
151+
PageWithInfoboxDefinition | PageWithoutInfoboxDefinition,
152+
PageError | FetchError
153+
>(
137154
await setDefaults(options ?? {}).fetch(
138155
getPage_toRequest(project, title, options),
139156
),

websocket/pull.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import type { BaseOptions } from "../rest/options.ts";
2828
* This interface extends the basic {@linkcode Page} type with additional identifiers
2929
* needed for real-time collaboration and page modifications.
3030
*/
31-
export interface PushMetadata extends Page {
31+
export interface PushMetadata extends Page<boolean> {
3232
/** Unique identifier of the project containing the page */
3333
projectId: string;
3434
/** Unique identifier of the current user */

0 commit comments

Comments
 (0)