Skip to content

Commit eeb7cec

Browse files
fix: remove type from imports and update ScrapboxResponse references
- Remove type keyword from imports where functions are used - Update remaining ScrapboxResponse references to TargetedResponse in search.ts - Fix unused imports across REST API files
1 parent c0fb73e commit eeb7cec

File tree

7 files changed

+16
-12
lines changed

7 files changed

+16
-12
lines changed

rest/auth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { getProfile } from "./profile.ts";
22
import type { TargetedResponse } from "./targeted_response.ts";
3-
import { createErrorResponse, createSuccessResponse } from "./utils.ts";
3+
import { type createErrorResponse, createSuccessResponse } from "./utils.ts";
44
import type { HTTPError } from "./responseIntoResult.ts";
55
import type { AbortError, NetworkError } from "./robustFetch.ts";
66
import type { ExtendedOptions } from "./options.ts";

rest/link.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import type {
77
import { cookie } from "./auth.ts";
88
import { parseHTTPError } from "./parseHTTPError.ts";
99
import type { TargetedResponse } from "./targeted_response.ts";
10+
import { createErrorResponse, createSuccessResponse } from "./utils.ts";
1011
import { type BaseOptions, setDefaults } from "./options.ts";
1112
import type { FetchError } from "./mod.ts";
1213

rest/page-data.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import type {
88
import { cookie, getCSRFToken } from "./auth.ts";
99
import { parseHTTPError } from "./parseHTTPError.ts";
1010
import type { TargetedResponse } from "./targeted_response.ts";
11+
import { createErrorResponse, createSuccessResponse } from "./utils.ts";
1112
import {
1213
type BaseOptions,
1314
type ExtendedOptions,

rest/pages.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { parseHTTPError } from "./parseHTTPError.ts";
1111
import { encodeTitleURI } from "../title.ts";
1212
import { type BaseOptions, setDefaults } from "./options.ts";
1313
import type { TargetedResponse } from "./targeted_response.ts";
14+
import { createErrorResponse, createSuccessResponse } from "./utils.ts";
1415
import type { FetchError } from "./robustFetch.ts";
1516

1617
/** Options for `getPage()` */

rest/parseHTTPError.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { isLiteralOneOf } from "@core/unknownutil/is/literal-one-of";
1313
import { isRecord } from "@core/unknownutil/is/record";
1414
import { isString } from "@core/unknownutil/is/string";
1515
import type { TargetedResponse } from "./targeted_response.ts";
16+
import { createErrorResponse } from "./utils.ts";
1617

1718
export interface RESTfullAPIErrorMap {
1819
BadRequestError: BadRequestError;

rest/profile.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import type { GuestUser, MemberUser } from "@cosense/types/rest";
22
import { cookie } from "./auth.ts";
33
import type { TargetedResponse } from "./targeted_response.ts";
44
import {
5-
createErrorResponse,
6-
createSuccessResponse,
5+
type createErrorResponse,
6+
type createSuccessResponse,
77
createTargetedResponse,
88
} from "./utils.ts";
99
import type { FetchError } from "./robustFetch.ts";
@@ -48,7 +48,7 @@ const getProfile_toRequest: GetProfile["toRequest"] = (
4848
);
4949
};
5050

51-
const getProfile_fromResponse: GetProfile["fromResponse"] = async (res) => {
51+
const getProfile_fromResponse: GetProfile["fromResponse"] = (res) => {
5252
const response = createTargetedResponse<
5353
200 | 400 | 404,
5454
MemberUser | GuestUser | ProfileError

rest/search.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import { cookie } from "./auth.ts";
1010
import { parseHTTPError } from "./parseHTTPError.ts";
1111
import type { TargetedResponse } from "./targeted_response.ts";
1212
import {
13-
createErrorResponse,
14-
createSuccessResponse,
13+
type createErrorResponse,
14+
type createSuccessResponse,
1515
createTargetedResponse,
1616
} from "./utils.ts";
1717
import { type BaseOptions, setDefaults } from "./options.ts";
@@ -79,9 +79,9 @@ export const searchForJoinedProjects = async (
7979
query: string,
8080
init?: BaseOptions,
8181
): Promise<
82-
ScrapboxResponse<
83-
ProjectSearchResult,
84-
SearchForJoinedProjectsError | FetchError
82+
TargetedResponse<
83+
200 | 400 | 404,
84+
ProjectSearchResult | SearchForJoinedProjectsError | FetchError
8585
>
8686
> => {
8787
const { sid, hostName, fetch } = setDefaults(init ?? {});
@@ -124,9 +124,9 @@ export const searchForWatchList = async (
124124
projectIds: string[],
125125
init?: BaseOptions,
126126
): Promise<
127-
ScrapboxResponse<
128-
ProjectSearchResult,
129-
SearchForWatchListError | FetchError
127+
TargetedResponse<
128+
200 | 400 | 404,
129+
ProjectSearchResult | SearchForWatchListError | FetchError
130130
>
131131
> => {
132132
const { sid, hostName, fetch } = setDefaults(init ?? {});

0 commit comments

Comments
 (0)