update misskey-js to the new templates

This commit is contained in:
Hazelnoot 2025-10-07 00:39:35 -04:00
parent b25eb703ea
commit 4e30986cda
32 changed files with 258 additions and 409 deletions

View file

@ -79,7 +79,7 @@
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
* DEFAULT VALUE: "<projectFolder>/tsconfig.json"
*/
"tsconfigFilePath": "<projectFolder>/tsconfig.lib.json",
"tsconfigFilePath": "<projectFolder>/src/tsconfig.json",
/**
* Provides a compiler configuration that will be used instead of reading the tsconfig.json file from disk.
* The object must conform to the TypeScript tsconfig schema:

View file

@ -8,11 +8,10 @@ export default [
{
ignores: [
'generator',
'**/lib/',
'**/temp/',
'**/built/',
'**/coverage/',
'**/node_modules/',
'temp',
'built',
'coverage',
'node_modules',
],
},
{
@ -20,7 +19,7 @@ export default [
languageOptions: {
parserOptions: {
parser: tsParser,
project: ['./tsconfig.lib.json'],
project: ['src/tsconfig.json'],
sourceType: 'module',
tsconfigRootDir: import.meta.dirname,
},
@ -31,7 +30,7 @@ export default [
languageOptions: {
parserOptions: {
parser: tsParser,
projectService: ['./tsconfig.test.json'],
projectService: ['test/tsconfig.json'],
sourceType: 'module',
tsconfigRootDir: import.meta.dirname,
},
@ -42,18 +41,18 @@ export default [
languageOptions: {
parserOptions: {
parser: tsParser,
projectService: ['./tsconfig.test-d.json'],
projectService: ['test-d/tsconfig.json'],
sourceType: 'module',
tsconfigRootDir: import.meta.dirname,
},
},
},
{
files: ['*.ts', '*.js', 'scripts/**/*'],
files: ['*.ts', '*.js', 'scripts/**/*.ts', 'scripts/**/*.js', 'scripts/**/*.mjs', 'scripts/**/*.cjs'],
languageOptions: {
parserOptions: {
parser: tsParser,
project: ['./tsconfig.scripts.json'],
project: ['tsconfig.scripts.json'],
sourceType: 'module',
tsconfigRootDir: import.meta.dirname,
},

View file

@ -6,8 +6,8 @@
import type { AuthenticationResponseJSON } from '@simplewebauthn/types';
import { EventEmitter } from 'eventemitter3';
import { Options } from 'reconnecting-websocket';
import type { PublicKeyCredentialRequestOptionsJSON as PublicKeyCredentialRequestOptionsJSON_2 } from '@simplewebauthn/types';
import type { Options } from 'reconnecting-websocket';
import type { PublicKeyCredentialRequestOptionsJSON } from '@simplewebauthn/types';
import _ReconnectingWebSocket from 'reconnecting-websocket';
// Warning: (ae-forgotten-export) The symbol "components" needs to be exported by the entry point index.d.ts
@ -24,7 +24,7 @@ export type Acct = {
declare namespace acct {
export {
parse,
toString_2 as toString,
toString,
Acct
}
}
@ -155,21 +155,12 @@ type AdminCaptchaSaveRequest = operations['admin___captcha___save']['requestBody
// @public (undocumented)
type AdminCwInstanceRequest = operations['admin___cw-instance']['requestBody']['content']['application/json'];
// @public (undocumented)
type AdminCwInstanceResponse = operations['admin___cw-instance']['responses']['200']['content']['application/json'];
// @public (undocumented)
type AdminCwNoteRequest = operations['admin___cw-note']['requestBody']['content']['application/json'];
// @public (undocumented)
type AdminCwNoteResponse = operations['admin___cw-note']['responses']['200']['content']['application/json'];
// @public (undocumented)
type AdminCwUserRequest = operations['admin___cw-user']['requestBody']['content']['application/json'];
// @public (undocumented)
type AdminCwUserResponse = operations['admin___cw-user']['responses']['200']['content']['application/json'];
// @public (undocumented)
type AdminDeclineUserRequest = operations['admin___decline-user']['requestBody']['content']['application/json'];
@ -568,6 +559,12 @@ class APIClient {
fetch: FetchLike;
// (undocumented)
origin: string;
// Warning: (ae-forgotten-export) The symbol "EndpointsWithOptionalParams" needs to be exported by the entry point index.d.ts
//
// (undocumented)
request<E extends keyof EndpointsWithOptionalParams>(endpoint: E, params?: Record<string, never>, credential?: string | null): Promise<SwitchCaseResponseType<E, EmptyRequest>>;
// (undocumented)
request<E extends keyof Endpoints, P extends Endpoints[E]['req']>(endpoint: E, params: P, credential?: string | null): Promise<SwitchCaseResponseType<E, P>>;
}
// @public (undocumented)
@ -685,7 +682,7 @@ export type Channels = {
main: {
params: null;
events: {
notification: (payload: Notification_2) => void;
notification: (payload: Notification) => void;
mention: (payload: Note) => void;
reply: (payload: Note) => void;
renote: (payload: Note) => void;
@ -699,7 +696,7 @@ export type Channels = {
file: DriveFile;
}) => void;
readAllNotifications: () => void;
unreadNotification: (payload: Notification_2) => void;
unreadNotification: (payload: Notification) => void;
notificationFlushed: () => void;
unreadAntenna: (payload: Antenna) => void;
newChatMessage: (payload: ChatMessage) => void;
@ -1564,11 +1561,8 @@ declare namespace entities {
AdminCaptchaCurrentResponse,
AdminCaptchaSaveRequest,
AdminCwInstanceRequest,
AdminCwInstanceResponse,
AdminCwNoteRequest,
AdminCwNoteResponse,
AdminCwUserRequest,
AdminCwUserResponse,
AdminDeclineUserRequest,
AdminDeleteAccountRequest,
AdminDeleteAllFilesOfAUserRequest,
@ -1973,7 +1967,6 @@ declare namespace entities {
IReadAnnouncementRequest,
IRegenerateTokenRequest,
IRegistryGetRequest,
IRegistryGetResponse,
IRegistryGetAllRequest,
IRegistryGetAllResponse,
IRegistryGetDetailRequest,
@ -2211,7 +2204,7 @@ declare namespace entities {
Note,
NoteReaction,
NoteFavorite,
Notification_2 as Notification,
Notification,
DriveFile,
DriveFolder,
Following,
@ -2330,8 +2323,8 @@ type FetchExternalResourcesResponse = operations['fetch-external-resources']['re
type FetchLike = (input: string, init?: {
method?: string;
body?: Blob | FormData | string;
credentials?: RequestCredentials;
cache?: RequestCache;
credentials?: 'include' | 'omit' | 'same-origin';
cache?: 'default' | 'force-cache' | 'no-cache' | 'no-store' | 'only-if-cached' | 'reload';
headers: {
[key in string]: string;
};
@ -2737,9 +2730,6 @@ type IRegistryGetDetailResponse = operations['i___registry___get-detail']['respo
// @public (undocumented)
type IRegistryGetRequest = operations['i___registry___get']['requestBody']['content']['application/json'];
// @public (undocumented)
type IRegistryGetResponse = operations['i___registry___get']['responses']['200']['content']['application/json'];
// @public (undocumented)
type IRegistryGetUnsecureRequest = operations['i___registry___get-unsecure']['requestBody']['content']['application/json'];
@ -3366,7 +3356,7 @@ type NotesVersionsResponse = operations['notes___versions']['responses']['200'][
export const noteVisibilities: readonly ["public", "home", "followers", "specified"];
// @public (undocumented)
type Notification_2 = components['schemas']['Notification'];
type Notification = components['schemas']['Notification'];
// @public (undocumented)
type NotificationsCreateRequest = operations['notifications___create']['requestBody']['content']['application/json'];
@ -3649,12 +3639,12 @@ type SigninFlowResponse = {
} | {
finished: false;
next: 'passkey';
authRequest: PublicKeyCredentialRequestOptionsJSON_2;
authRequest: PublicKeyCredentialRequestOptionsJSON;
};
// @public (undocumented)
type SigninWithPasskeyInitResponse = {
option: PublicKeyCredentialRequestOptionsJSON_2;
option: PublicKeyCredentialRequestOptionsJSON;
context: string;
};
@ -3785,7 +3775,7 @@ type TestRequest = operations['test']['requestBody']['content']['application/jso
type TestResponse = operations['test']['responses']['200']['content']['application/json'];
// @public (undocumented)
function toString_2(acct: Acct): string;
function toString(acct: Acct): string;
// @public (undocumented)
type User = components['schemas']['User'];
@ -3982,7 +3972,7 @@ type V2AdminEmojiListResponse = operations['v2___admin___emoji___list']['respons
// Warnings were encountered during analysis:
//
// built/entities.d.ts:32:5 - (ae-forgotten-export) The symbol "ModerationLogPayloads" needs to be exported by the entry point index.d.ts
// built/streaming.d.ts:39:9 - (ae-forgotten-export) The symbol "ReconnectingWebSocket" needs to be exported by the entry point index.d.ts
// built/streaming.d.ts:40:9 - (ae-forgotten-export) The symbol "ReconnectingWebSocket" needs to be exported by the entry point index.d.ts
// built/streaming.types.d.ts:219:13 - (ae-forgotten-export) The symbol "ReversiUpdateKey" needs to be exported by the entry point index.d.ts
// built/streaming.types.d.ts:233:13 - (ae-forgotten-export) The symbol "ReversiUpdateSettings" needs to be exported by the entry point index.d.ts

View file

@ -33,7 +33,7 @@ export default [
languageOptions: {
parserOptions: {
parser: tsParser,
project: ['./jsconfig.scripts.json'],
project: ['./tsconfig.scripts.json'],
sourceType: 'module',
tsconfigRootDir: import.meta.dirname,
},

View file

@ -1,15 +0,0 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "../../shared/jsconfig.node.json",
"compilerOptions": {
"typeRoots": [
"./node_modules/@types"
]
},
"include": [
"*.js"
],
"exclude": [
"node_modules"
]
}

View file

@ -10,7 +10,7 @@
"typecheck": "pnpm run typecheck:generator && pnpm run typecheck:autogen && pnpm run typecheck:scripts",
"typecheck:generator": "tsc -p tsconfig.generator.json --noEmit",
"typecheck:autogen": "tsc -p tsconfig.autogen.json --noEmit",
"typecheck:scripts": "tsc -p jsconfig.scripts.json --noEmit",
"typecheck:scripts": "tsc -p tsconfig.scripts.json --noEmit",
"lint": "pnpm typecheck && pnpm eslint"
},
"devDependencies": {

View file

@ -1,9 +1,7 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "../../shared/tsconfig.web.json",
"extends": "../../shared/tsconfig.lib.jsonc",
"compilerOptions": {
"noImplicitAny": false,
"isolatedModules": false,
"rootDirs": [
"built",
"../built"

View file

@ -1,6 +1,6 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "../../shared/tsconfig.node.json",
"extends": "../../shared/tsconfig.scripts.jsonc",
"include": [
"src/**/*.ts"
],

View file

@ -5,6 +5,6 @@
"references": [
{ "path": "./tsconfig.generator.json" },
{ "path": "./tsconfig.autogen.json" },
{ "path": "./jsconfig.scripts.json" }
{ "path": "./tsconfig.scripts.json" }
]
}

View file

@ -0,0 +1,8 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "../../shared/tsconfig.scripts.jsonc",
"include": [
"*.js",
"*.ts"
]
}

View file

@ -7,7 +7,7 @@
import { createDefaultEsmPreset, type JestConfigWithTsJest } from 'ts-jest';
const presetConfig = createDefaultEsmPreset({
tsconfig: '<rootDir>/tsconfig.lib.json'
tsconfig: '<rootDir>/test/tsconfig.json',
});
export default {
@ -32,7 +32,7 @@ export default {
collectCoverageFrom: ['src/**/*.ts'],
// The directory where Jest should output its coverage files
coverageDirectory: "coverage",
coverageDirectory: 'coverage',
// An array of regexp pattern strings used to skip coverage collection
// coveragePathIgnorePatterns: [
@ -40,7 +40,7 @@ export default {
// ],
// Indicates which provider should be used to instrument code for coverage
coverageProvider: "v8",
coverageProvider: 'v8',
// A list of reporter names that Jest uses when writing coverage reports
// coverageReporters: [
@ -90,8 +90,8 @@ export default {
// "node"
// ],
moduleFileExtensions: [
"ts",
"js"
'ts',
'js',
],
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
@ -143,7 +143,7 @@ export default {
// A list of paths to directories that Jest should use to search for files in
roots: [
"<rootDir>/test"
'<rootDir>/test',
],
// Allows you to use a custom runner instead of Jest's default test runner
@ -162,7 +162,7 @@ export default {
// snapshotSerializers: [],
// The test environment that will be used for testing
testEnvironment: "node",
testEnvironment: 'node',
// Options that will be passed to the testEnvironment
// testEnvironmentOptions: {},
@ -172,7 +172,7 @@ export default {
// The glob patterns Jest uses to detect test files
testMatch: [
"<rootDir>/test/**/*.ts"
'<rootDir>/test/**/*.ts',
],
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped

View file

@ -8,17 +8,17 @@
"types": "./built/index.d.ts",
"scripts": {
"clean": "node scripts/clean.mjs",
"build": "tsc -p tsconfig.lib.json && node scripts/post-build.mjs",
"rebuild": "pnpm clean && pnpm build",
"build": "tsc -p src/tsconfig.json && node scripts/post-build.mjs",
"rebuild": "pnpm run clean && pnpm run build",
"tsd": "tsd --types \"./temp/built/src/index.d.ts\" --files \"./temp/built/test-d/**/*.ts\"",
"api": "pnpm api-extractor run --local --verbose",
"api-prod": "pnpm api-extractor run --verbose",
"eslint": "eslint --quiet --cache -c eslint.config.js .",
"typecheck-all": "pnpm run --no-bail typecheck:lib && pnpm run --no-bail typecheck:test && pnpm run --no-bail typecheck:test-d && pnpm run --no-bail typecheck:scripts",
"typecheck": "pnpm run typecheck:lib && pnpm run typecheck:test && pnpm run typecheck:test-d && pnpm run typecheck:scripts",
"typecheck:lib": "tsc -p tsconfig.lib.json --noEmit",
"typecheck:test": "tsc -p tsconfig.test.json --noEmit",
"typecheck:test-d": "tsc -p tsconfig.test-d.json --noEmit",
"typecheck:lib": "tsc -p src/tsconfig.json --noEmit",
"typecheck:test": "tsc -p test/tsconfig.json --noEmit",
"typecheck:test-d": "tsc -p test-d/tsconfig.json --noEmit",
"typecheck:scripts": "tsc -p tsconfig.scripts.json --noEmit",
"lint": "pnpm typecheck && pnpm eslint",
"jest": "node --no-experimental-require-module --experimental-vm-modules --experimental-import-meta-resolve node_modules/jest/bin/jest.js --coverage --detectOpenHandles",

View file

@ -4,14 +4,16 @@
*/
import { libBuild, outDir, testDBuild, testDSource } from './_common.mjs';
import { rm, cp } from 'fs/promises';
import { rm, cp, mkdir } from 'fs/promises';
// Always clean the output, because artifacts are cached in the build directory instead.
console.log(`Cleaning output directory ${outDir}...`);
await rm(outDir, { recursive: true, force: true });
// Copy built lib to output directory.
await mkdir(outDir, { recursive: true });
await cp(libBuild, outDir, { recursive: true });
// Stage test-d sources in the build directory so tsd will work.
await mkdir(testDBuild, { recursive: true });
await cp(testDSource, testDBuild, { recursive: true });

View file

@ -6,7 +6,7 @@ export type Acct = {
export function parse(_acct: string): Acct {
let acct = _acct;
if (acct.startsWith('@')) acct = acct.substring(1);
const split = acct.split('@', 2);
const split = acct.split('@', 2) as [string, ...string[]];
return { username: split[0], host: split[1] || null };
}

View file

@ -1,7 +1,6 @@
import './autogen/apiClientJSDoc.js';
import { endpointReqTypes } from './autogen/endpoint.js';
import type { SwitchCaseResponseType, Endpoints } from './api.types.js';
import type { SwitchCaseResponseType, Endpoints, EndpointsWithOptionalParams } from './api.types.js';
import type { EmptyRequest } from './autogen/entities.js';
export type {
SwitchCaseResponseType,
@ -29,8 +28,8 @@ export function isAPIError(reason: unknown): reason is APIError {
export type FetchLike = (input: string, init?: {
method?: string;
body?: Blob | FormData | string;
credentials?: RequestCredentials;
cache?: RequestCache;
credentials?: 'include' | 'omit' | 'same-origin';
cache?: 'default' | 'force-cache' | 'no-cache' | 'no-store' | 'only-if-cached' | 'reload';
headers: { [key in string]: string }
}) => Promise<{
status: number;
@ -64,7 +63,17 @@ export class APIClient {
return ep in endpointReqTypes;
}
public request<E extends keyof Endpoints, P extends Endpoints[E]['req'] & object>(
public request<E extends keyof EndpointsWithOptionalParams>(
endpoint: E,
params?: Record<string, never>,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, EmptyRequest>>;
public request<E extends keyof Endpoints, P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
public request<E extends keyof Endpoints, P extends Endpoints[E]['req']>(
endpoint: E,
params: P = {} as P,
credential?: string | null,

View file

@ -1,6 +1,11 @@
import type { Endpoints as Gen } from './autogen/endpoint.js';
import type { UserDetailed } from './autogen/models.js';
import type { AdminRolesCreateRequest, AdminRolesCreateResponse, UsersShowRequest } from './autogen/entities.js';
import type {
AdminRolesCreateRequest,
AdminRolesCreateResponse,
UsersShowRequest,
EmptyRequest,
} from './autogen/entities.js';
import type {
PartialRolePolicyOverride,
SigninFlowRequest,
@ -109,3 +114,7 @@ export type Endpoints = Overwrite<
}
}
>;
export type EndpointsWithOptionalParams = {
[E in keyof Endpoints]: EmptyRequest extends Endpoints[E]['req'] ? Endpoints[E] : never;
};

View file

@ -257,7 +257,7 @@ declare module '../api.js' {
*/
request<E extends 'admin/captcha/current', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -356,7 +356,7 @@ declare module '../api.js' {
*/
request<E extends 'admin/drive/cleanup', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -588,7 +588,7 @@ declare module '../api.js' {
*/
request<E extends 'admin/gen-vapid-keys', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -599,7 +599,7 @@ declare module '../api.js' {
*/
request<E extends 'admin/get-index-stats', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -610,7 +610,7 @@ declare module '../api.js' {
*/
request<E extends 'admin/get-table-stats', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -654,7 +654,7 @@ declare module '../api.js' {
*/
request<E extends 'admin/meta', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -698,7 +698,7 @@ declare module '../api.js' {
*/
request<E extends 'admin/queue/deliver-delayed', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -709,7 +709,7 @@ declare module '../api.js' {
*/
request<E extends 'admin/queue/inbox-delayed', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -753,7 +753,7 @@ declare module '../api.js' {
*/
request<E extends 'admin/queue/queues', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -797,7 +797,7 @@ declare module '../api.js' {
*/
request<E extends 'admin/queue/stats', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -830,7 +830,7 @@ declare module '../api.js' {
*/
request<E extends 'admin/relays/list', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -929,7 +929,7 @@ declare module '../api.js' {
*/
request<E extends 'admin/roles/list', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -1006,7 +1006,7 @@ declare module '../api.js' {
*/
request<E extends 'admin/server-info', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -1287,7 +1287,7 @@ declare module '../api.js' {
*/
request<E extends 'antennas/list', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -1364,7 +1364,7 @@ declare module '../api.js' {
*/
request<E extends 'app/current', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -1508,7 +1508,7 @@ declare module '../api.js' {
*/
request<E extends 'channels/featured', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -1541,7 +1541,7 @@ declare module '../api.js' {
*/
request<E extends 'channels/my-favorites', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -2069,7 +2069,7 @@ declare module '../api.js' {
*/
request<E extends 'clips/list', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -2080,7 +2080,7 @@ declare module '../api.js' {
*/
request<E extends 'clips/my-favorites', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -2146,7 +2146,7 @@ declare module '../api.js' {
*/
request<E extends 'drive', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -2366,7 +2366,7 @@ declare module '../api.js' {
*/
request<E extends 'emojis', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -2388,7 +2388,7 @@ declare module '../api.js' {
*/
request<E extends 'endpoints', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -2400,7 +2400,7 @@ declare module '../api.js' {
*/
request<E extends 'export-custom-emojis', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -2731,7 +2731,7 @@ declare module '../api.js' {
*/
request<E extends 'gallery/popular', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -2819,7 +2819,7 @@ declare module '../api.js' {
*/
request<E extends 'get-avatar-decorations', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -2830,7 +2830,7 @@ declare module '../api.js' {
*/
request<E extends 'get-online-users-count', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -2874,7 +2874,7 @@ declare module '../api.js' {
*/
request<E extends 'hashtags/trend', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -2896,7 +2896,7 @@ declare module '../api.js' {
*/
request<E extends 'i', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -3063,7 +3063,7 @@ declare module '../api.js' {
*/
request<E extends 'i/export-antennas', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -3075,7 +3075,7 @@ declare module '../api.js' {
*/
request<E extends 'i/export-blocking', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -3087,7 +3087,7 @@ declare module '../api.js' {
*/
request<E extends 'i/export-clips', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -3099,7 +3099,7 @@ declare module '../api.js' {
*/
request<E extends 'i/export-data', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -3111,7 +3111,7 @@ declare module '../api.js' {
*/
request<E extends 'i/export-favorites', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -3135,7 +3135,7 @@ declare module '../api.js' {
*/
request<E extends 'i/export-mute', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -3147,7 +3147,7 @@ declare module '../api.js' {
*/
request<E extends 'i/export-notes', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -3159,7 +3159,7 @@ declare module '../api.js' {
*/
request<E extends 'i/export-user-lists', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -3443,7 +3443,7 @@ declare module '../api.js' {
*/
request<E extends 'i/registry/scopes-with-domain', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -3569,7 +3569,7 @@ declare module '../api.js' {
*/
request<E extends 'i/webhooks/list', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -3614,7 +3614,7 @@ declare module '../api.js' {
*/
request<E extends 'invite/create', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -3636,7 +3636,7 @@ declare module '../api.js' {
*/
request<E extends 'invite/limit', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -4165,7 +4165,7 @@ declare module '../api.js' {
*/
request<E extends 'notifications/flush', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -4176,7 +4176,7 @@ declare module '../api.js' {
*/
request<E extends 'notifications/mark-all-as-read', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -4187,7 +4187,7 @@ declare module '../api.js' {
*/
request<E extends 'notifications/test-notification', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -4232,7 +4232,7 @@ declare module '../api.js' {
*/
request<E extends 'pages/featured', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -4287,7 +4287,7 @@ declare module '../api.js' {
*/
request<E extends 'ping', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -4364,7 +4364,7 @@ declare module '../api.js' {
*/
request<E extends 'reset-db', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -4386,7 +4386,7 @@ declare module '../api.js' {
*/
request<E extends 'retention', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -4419,7 +4419,7 @@ declare module '../api.js' {
*/
request<E extends 'reversi/invitations', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -4474,7 +4474,7 @@ declare module '../api.js' {
*/
request<E extends 'roles/list', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -4518,7 +4518,7 @@ declare module '../api.js' {
*/
request<E extends 'server-info', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
@ -4540,7 +4540,7 @@ declare module '../api.js' {
*/
request<E extends 'stats', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
params?: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;

View file

@ -39,11 +39,8 @@ import type {
AdminCaptchaCurrentResponse,
AdminCaptchaSaveRequest,
AdminCwInstanceRequest,
AdminCwInstanceResponse,
AdminCwNoteRequest,
AdminCwNoteResponse,
AdminCwUserRequest,
AdminCwUserResponse,
AdminDeclineUserRequest,
AdminDeleteAccountRequest,
AdminDeleteAllFilesOfAUserRequest,
@ -448,7 +445,6 @@ import type {
IReadAnnouncementRequest,
IRegenerateTokenRequest,
IRegistryGetRequest,
IRegistryGetResponse,
IRegistryGetAllRequest,
IRegistryGetAllResponse,
IRegistryGetDetailRequest,
@ -700,9 +696,9 @@ export type Endpoints = {
'admin/avatar-decorations/update': { req: AdminAvatarDecorationsUpdateRequest; res: EmptyResponse };
'admin/captcha/current': { req: EmptyRequest; res: AdminCaptchaCurrentResponse };
'admin/captcha/save': { req: AdminCaptchaSaveRequest; res: EmptyResponse };
'admin/cw-instance': { req: AdminCwInstanceRequest; res: AdminCwInstanceResponse };
'admin/cw-note': { req: AdminCwNoteRequest; res: AdminCwNoteResponse };
'admin/cw-user': { req: AdminCwUserRequest; res: AdminCwUserResponse };
'admin/cw-instance': { req: AdminCwInstanceRequest; res: EmptyResponse };
'admin/cw-note': { req: AdminCwNoteRequest; res: EmptyResponse };
'admin/cw-user': { req: AdminCwUserRequest; res: EmptyResponse };
'admin/decline-user': { req: AdminDeclineUserRequest; res: EmptyResponse };
'admin/delete-account': { req: AdminDeleteAccountRequest; res: EmptyResponse };
'admin/delete-all-files-of-a-user': { req: AdminDeleteAllFilesOfAUserRequest; res: EmptyResponse };
@ -977,7 +973,7 @@ export type Endpoints = {
'i/pin': { req: IPinRequest; res: IPinResponse };
'i/read-announcement': { req: IReadAnnouncementRequest; res: EmptyResponse };
'i/regenerate-token': { req: IRegenerateTokenRequest; res: EmptyResponse };
'i/registry/get': { req: IRegistryGetRequest; res: IRegistryGetResponse };
'i/registry/get': { req: IRegistryGetRequest; res: EmptyResponse };
'i/registry/get-all': { req: IRegistryGetAllRequest; res: IRegistryGetAllResponse };
'i/registry/get-detail': { req: IRegistryGetDetailRequest; res: IRegistryGetDetailResponse };
'i/registry/get-unsecure': { req: IRegistryGetUnsecureRequest; res: EmptyResponse };

View file

@ -42,11 +42,8 @@ export type AdminAvatarDecorationsUpdateRequest = operations['admin___avatar-dec
export type AdminCaptchaCurrentResponse = operations['admin___captcha___current']['responses']['200']['content']['application/json'];
export type AdminCaptchaSaveRequest = operations['admin___captcha___save']['requestBody']['content']['application/json'];
export type AdminCwInstanceRequest = operations['admin___cw-instance']['requestBody']['content']['application/json'];
export type AdminCwInstanceResponse = operations['admin___cw-instance']['responses']['200']['content']['application/json'];
export type AdminCwNoteRequest = operations['admin___cw-note']['requestBody']['content']['application/json'];
export type AdminCwNoteResponse = operations['admin___cw-note']['responses']['200']['content']['application/json'];
export type AdminCwUserRequest = operations['admin___cw-user']['requestBody']['content']['application/json'];
export type AdminCwUserResponse = operations['admin___cw-user']['responses']['200']['content']['application/json'];
export type AdminDeclineUserRequest = operations['admin___decline-user']['requestBody']['content']['application/json'];
export type AdminDeleteAccountRequest = operations['admin___delete-account']['requestBody']['content']['application/json'];
export type AdminDeleteAllFilesOfAUserRequest = operations['admin___delete-all-files-of-a-user']['requestBody']['content']['application/json'];
@ -451,7 +448,6 @@ export type IPinResponse = operations['i___pin']['responses']['200']['content'][
export type IReadAnnouncementRequest = operations['i___read-announcement']['requestBody']['content']['application/json'];
export type IRegenerateTokenRequest = operations['i___regenerate-token']['requestBody']['content']['application/json'];
export type IRegistryGetRequest = operations['i___registry___get']['requestBody']['content']['application/json'];
export type IRegistryGetResponse = operations['i___registry___get']['responses']['200']['content']['application/json'];
export type IRegistryGetAllRequest = operations['i___registry___get-all']['requestBody']['content']['application/json'];
export type IRegistryGetAllResponse = operations['i___registry___get-all']['responses']['200']['content']['application/json'];
export type IRegistryGetDetailRequest = operations['i___registry___get-detail']['requestBody']['content']['application/json'];

View file

@ -13595,14 +13595,12 @@ export interface operations {
};
};
responses: {
/** @description OK (with results) */
200: {
/** @description OK (without any results) */
204: {
headers: {
[name: string]: unknown;
};
content: {
'application/json': unknown;
};
content?: never;
};
/** @description Client error */
400: {
@ -13668,14 +13666,12 @@ export interface operations {
};
};
responses: {
/** @description OK (with results) */
200: {
/** @description OK (without any results) */
204: {
headers: {
[name: string]: unknown;
};
content: {
'application/json': unknown;
};
content?: never;
};
/** @description Client error */
400: {
@ -13741,14 +13737,12 @@ export interface operations {
};
};
responses: {
/** @description OK (with results) */
200: {
/** @description OK (without any results) */
204: {
headers: {
[name: string]: unknown;
};
content: {
'application/json': unknown;
};
content?: never;
};
/** @description Client error */
400: {
@ -14242,7 +14236,7 @@ export interface operations {
/** Format: misskey:id */
fileId?: string;
url?: string;
} | unknown | unknown;
};
};
};
responses: {
@ -15275,7 +15269,7 @@ export interface operations {
isSensitive?: boolean;
localOnly?: boolean;
roleIdsThatCanBeUsedThisEmojiAsReaction?: string[];
} | unknown | unknown;
};
};
};
responses: {
@ -27957,7 +27951,7 @@ export interface operations {
/** Format: misskey:id */
fileId?: string;
url?: string;
} | unknown | unknown;
};
};
};
responses: {
@ -36226,14 +36220,12 @@ export interface operations {
};
};
responses: {
/** @description OK (with results) */
200: {
/** @description OK (without any results) */
204: {
headers: {
[name: string]: unknown;
};
content: {
'application/json': unknown;
};
content?: never;
};
/** @description Client error */
400: {
@ -36958,7 +36950,7 @@ export interface operations {
/** Format: misskey:id */
tokenId?: string;
token?: string | null;
} | unknown | unknown;
};
};
};
responses: {
@ -37257,145 +37249,25 @@ export interface operations {
chatScope?: 'everyone' | 'followers' | 'following' | 'mutual' | 'none';
/** Format: misskey:id */
pinnedPageId?: string | null;
mutedWords?: (string[] | string)[];
hardMutedWords?: (string[] | string)[];
mutedWords?: unknown[];
hardMutedWords?: unknown[];
mutedInstances?: string[];
notificationRecieveConfig?: {
note?: {
/** @enum {string} */
type: 'all' | 'following' | 'follower' | 'mutualFollow' | 'followingOrFollower' | 'never';
} | {
/** @enum {string} */
type: 'list';
/** Format: misskey:id */
userListId: string;
};
follow?: {
/** @enum {string} */
type: 'all' | 'following' | 'follower' | 'mutualFollow' | 'followingOrFollower' | 'never';
} | {
/** @enum {string} */
type: 'list';
/** Format: misskey:id */
userListId: string;
};
mention?: {
/** @enum {string} */
type: 'all' | 'following' | 'follower' | 'mutualFollow' | 'followingOrFollower' | 'never';
} | {
/** @enum {string} */
type: 'list';
/** Format: misskey:id */
userListId: string;
};
reply?: {
/** @enum {string} */
type: 'all' | 'following' | 'follower' | 'mutualFollow' | 'followingOrFollower' | 'never';
} | {
/** @enum {string} */
type: 'list';
/** Format: misskey:id */
userListId: string;
};
renote?: {
/** @enum {string} */
type: 'all' | 'following' | 'follower' | 'mutualFollow' | 'followingOrFollower' | 'never';
} | {
/** @enum {string} */
type: 'list';
/** Format: misskey:id */
userListId: string;
};
quote?: {
/** @enum {string} */
type: 'all' | 'following' | 'follower' | 'mutualFollow' | 'followingOrFollower' | 'never';
} | {
/** @enum {string} */
type: 'list';
/** Format: misskey:id */
userListId: string;
};
reaction?: {
/** @enum {string} */
type: 'all' | 'following' | 'follower' | 'mutualFollow' | 'followingOrFollower' | 'never';
} | {
/** @enum {string} */
type: 'list';
/** Format: misskey:id */
userListId: string;
};
pollEnded?: {
/** @enum {string} */
type: 'all' | 'following' | 'follower' | 'mutualFollow' | 'followingOrFollower' | 'never';
} | {
/** @enum {string} */
type: 'list';
/** Format: misskey:id */
userListId: string;
};
receiveFollowRequest?: {
/** @enum {string} */
type: 'all' | 'following' | 'follower' | 'mutualFollow' | 'followingOrFollower' | 'never';
} | {
/** @enum {string} */
type: 'list';
/** Format: misskey:id */
userListId: string;
};
followRequestAccepted?: {
/** @enum {string} */
type: 'all' | 'following' | 'follower' | 'mutualFollow' | 'followingOrFollower' | 'never';
} | {
/** @enum {string} */
type: 'list';
/** Format: misskey:id */
userListId: string;
};
roleAssigned?: {
/** @enum {string} */
type: 'all' | 'following' | 'follower' | 'mutualFollow' | 'followingOrFollower' | 'never';
} | {
/** @enum {string} */
type: 'list';
/** Format: misskey:id */
userListId: string;
};
chatRoomInvitationReceived?: {
/** @enum {string} */
type: 'all' | 'following' | 'follower' | 'mutualFollow' | 'followingOrFollower' | 'never';
} | {
/** @enum {string} */
type: 'list';
/** Format: misskey:id */
userListId: string;
};
achievementEarned?: {
/** @enum {string} */
type: 'all' | 'following' | 'follower' | 'mutualFollow' | 'followingOrFollower' | 'never';
} | {
/** @enum {string} */
type: 'list';
/** Format: misskey:id */
userListId: string;
};
app?: {
/** @enum {string} */
type: 'all' | 'following' | 'follower' | 'mutualFollow' | 'followingOrFollower' | 'never';
} | {
/** @enum {string} */
type: 'list';
/** Format: misskey:id */
userListId: string;
};
test?: {
/** @enum {string} */
type: 'all' | 'following' | 'follower' | 'mutualFollow' | 'followingOrFollower' | 'never';
} | {
/** @enum {string} */
type: 'list';
/** Format: misskey:id */
userListId: string;
};
note?: Record<string, never>;
follow?: Record<string, never>;
mention?: Record<string, never>;
reply?: Record<string, never>;
renote?: Record<string, never>;
quote?: Record<string, never>;
reaction?: Record<string, never>;
pollEnded?: Record<string, never>;
receiveFollowRequest?: Record<string, never>;
followRequestAccepted?: Record<string, never>;
roleAssigned?: Record<string, never>;
chatRoomInvitationReceived?: Record<string, never>;
achievementEarned?: Record<string, never>;
app?: Record<string, never>;
test?: Record<string, never>;
};
emailNotificationTypes?: string[];
alsoKnownAs?: string[];
@ -41160,7 +41032,7 @@ export interface operations {
scheduleNote: {
scheduledAt?: number;
};
} | unknown | unknown | unknown | unknown | unknown;
};
};
};
responses: {
@ -41545,7 +41417,7 @@ export interface operations {
tag?: string;
/** @description The outer arrays are chained with OR, the inner arrays are chained with AND. */
query?: string[][];
} | unknown | unknown;
};
};
};
responses: {
@ -43110,7 +42982,7 @@ export interface operations {
pageId?: string;
name?: string;
username?: string;
} | unknown | unknown;
};
};
};
responses: {
@ -46301,7 +46173,7 @@ export interface operations {
username?: string;
/** @description The local host is represented with `null`. */
host?: string | null;
} | unknown | unknown;
};
};
};
responses: {
@ -46392,7 +46264,7 @@ export interface operations {
/** @description The local host is represented with `null`. */
host?: string | null;
birthday?: string | null;
} | unknown | unknown;
};
};
};
responses: {
@ -48002,7 +47874,7 @@ export interface operations {
requestBody: {
content: {
'application/json': {
userId: string | string[];
userId: unknown;
};
};
};
@ -48285,7 +48157,7 @@ export interface operations {
detail?: boolean;
username?: string | null;
host?: string | null;
} | unknown | unknown;
};
};
};
responses: {
@ -48372,7 +48244,7 @@ export interface operations {
host?: string | null;
/** @default true */
detail?: boolean;
} | unknown | unknown | unknown;
};
};
};
responses: {

View file

@ -9,7 +9,6 @@ import type {
Role,
ReversiGameDetailed,
SystemWebhook,
UserLite,
ChatRoom,
} from './autogen/models.js';

View file

@ -3,9 +3,8 @@ import ReconnectingWebSocket from 'reconnecting-websocket';
import type { Options } from 'reconnecting-websocket';
import type { BroadcastEvents, Channels } from './streaming.types.js';
// // コンストラクタとクラスそのものの定義が上手く解決出来ないため再定義
// const ReconnectingWebSocketConstructor = _ReconnectingWebSocket.default;
// type ReconnectingWebSocket = _ReconnectingWebSocket.default;
// コンストラクタとクラスそのものの定義が上手く解決出来ないため再定義
const ReconnectingWebSocketConstructor = ReconnectingWebSocket as unknown as typeof ReconnectingWebSocket.default;
export function urlQuery(obj: Record<string, string | number | boolean | undefined>): string {
const params = Object.entries(obj)
@ -46,7 +45,7 @@ export interface IStream extends EventEmitter<StreamEvents> {
*/
// eslint-disable-next-line import/no-default-export
export default class Stream extends EventEmitter<StreamEvents> implements IStream {
private stream: ReconnectingWebSocket;
private stream: ReconnectingWebSocket.default;
public state: 'initializing' | 'reconnecting' | 'connected' = 'initializing';
private sharedConnectionPools: Pool[] = [];
private sharedConnections: SharedConnection[] = [];
@ -55,7 +54,7 @@ export default class Stream extends EventEmitter<StreamEvents> implements IStrea
constructor(origin: string, user: { token: string; } | null, options?: {
WebSocket?: Options['WebSocket'];
binaryType?: ReconnectingWebSocket['binaryType'];
binaryType?: 'arraybuffer' | 'blob';
}) {
super();
@ -84,7 +83,7 @@ export default class Stream extends EventEmitter<StreamEvents> implements IStrea
const wsOrigin = origin.replace('http://', 'ws://').replace('https://', 'wss://');
this.stream = new ReconnectingWebSocket(`${wsOrigin}/streaming?${query}`, '', {
this.stream = new ReconnectingWebSocketConstructor(`${wsOrigin}/streaming?${query}`, '', {
minReconnectionDelay: 1, // https://github.com/pladaria/reconnecting-websocket/issues/91
WebSocket: options.WebSocket,
});

View file

@ -0,0 +1,15 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "../../shared/tsconfig.lib.jsonc",
"compilerOptions": {
// Checking
"exactOptionalPropertyTypes": true,
// Output
"outDir": "../temp/built/src",
"tsBuildInfoFile": "../temp/built/src/tsconfig.lib.tsbuildinfo"
},
"include": [
"**/*"
]
}

View file

@ -5,7 +5,7 @@ describe('API', () => {
test('success', async () => {
const cli = new Misskey.api.APIClient({
origin: 'https://misskey.test',
credential: 'TOKEN'
credential: 'TOKEN',
});
const res = await cli.request('meta', { detail: true });
expectType<Misskey.entities.MetaResponse>(res);
@ -14,7 +14,7 @@ describe('API', () => {
test('conditional response type (meta)', async () => {
const cli = new Misskey.api.APIClient({
origin: 'https://misskey.test',
credential: 'TOKEN'
credential: 'TOKEN',
});
const res = await cli.request('meta', { detail: true });
@ -33,7 +33,7 @@ describe('API', () => {
test('conditional response type (users/show)', async () => {
const cli = new Misskey.api.APIClient({
origin: 'https://misskey.test',
credential: 'TOKEN'
credential: 'TOKEN',
});
const res = await cli.request('users/show', { userId: 'xxxxxxxx' });

View file

@ -0,0 +1,14 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "../../shared/tsconfig.lib.jsonc",
"compilerOptions": {
"outDir": "../temp/built/test-d/",
"rootDir": "."
},
"references": [
{ "path": "../src/tsconfig.json" }
],
"include": [
"**/*"
]
}

View file

@ -1,9 +1,12 @@
import fetchMock from 'jest-fetch-mock';
import _fetchMock from 'jest-fetch-mock';
import { APIClient, isAPIError } from '../src/api.js';
import type { Endpoints } from '../src/index.js';
fetchMock.enableMocks();
_fetchMock.enableFetchMocks();
const fetchMock = _fetchMock.default;
function getFetchCall(call: any[]) {
function getFetchCall(call: any[] | undefined) {
if (!call) return undefined;
const { body, method } = call[1];
const contentType = call[1].headers['Content-Type'];
if (
@ -25,7 +28,7 @@ describe('API', () => {
test('success', async () => {
fetchMock.resetMocks();
fetchMock.mockResponse(async (req) => {
const body = await req.json();
const body = await req.json() as Record<string, unknown>;
if (req.method === 'POST' && req.url === 'https://misskey.test/api/i') {
if (body.i === 'TOKEN') {
return JSON.stringify({ id: 'foo' });
@ -59,7 +62,7 @@ describe('API', () => {
test('with params', async () => {
fetchMock.resetMocks();
fetchMock.mockResponse(async (req) => {
const body = await req.json();
const body = await req.json() as Record<string, unknown>;
if (req.method === 'POST' && req.url === 'https://misskey.test/api/notes/show') {
if (body.i === 'TOKEN' && body.noteId === 'aaaaa') {
return JSON.stringify({ id: 'foo' });
@ -161,7 +164,7 @@ describe('API', () => {
test('インスタンスの credential が指定されていても引数で credential が null ならば null としてリクエストされる', async () => {
fetchMock.resetMocks();
fetchMock.mockResponse(async (req) => {
const body = await req.json();
const body = await req.json() as Record<string, unknown>;
if (req.method === 'POST' && req.url === 'https://misskey.test/api/i') {
if (typeof body.i === 'string') {
return JSON.stringify({ id: 'foo' });
@ -196,7 +199,7 @@ describe('API', () => {
test('api error', async () => {
fetchMock.resetMocks();
fetchMock.mockResponse(async (req) => {
fetchMock.mockResponse(async () => {
return {
status: 500,
body: JSON.stringify({
@ -241,7 +244,7 @@ describe('API', () => {
test('json parse error', async () => {
fetchMock.resetMocks();
fetchMock.mockResponse(async (req) => {
fetchMock.mockResponse(async () => {
return {
status: 500,
body: '<html>I AM NOT JSON</html>',
@ -274,7 +277,7 @@ describe('API', () => {
origin: 'https://misskey.test',
credential: 'TOKEN',
});
await cli.request('admin/roles/create', {
await cli.request<'admin/roles/create', Endpoints['admin/roles/create']['req']>('admin/roles/create', {
name: 'aaa',
asBadge: false,
canEditMembersByModerator: false,

View file

@ -0,0 +1,17 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "../../shared/tsconfig.lib.jsonc",
"compilerOptions": {
// Checking
"rootDir": ".",
// Output
"outDir": "../temp/built/test/"
},
"references": [
{ "path": "../src/tsconfig.json" }
],
"include": [
"**/*"
]
}

View file

@ -3,9 +3,9 @@
"files": [],
// WebStorm only reads one tsconfig per directory, so this tricks it into loading both.
"references": [
{ "path": "./tsconfig.lib.json" },
{ "path": "./tsconfig.test.json" },
{ "path": "./tsconfig.test-d.json" },
{ "path": "./src/tsconfig.json" },
{ "path": "./test/tsconfig.json" },
{ "path": "./test-d/tsconfig.json" },
{ "path": "./tsconfig.scripts.json" }
]
}

View file

@ -1,25 +0,0 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "../shared/tsconfig.web.json",
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"inlineSources": true,
"outDir": "./temp/built/",
"rootDir": ".",
"exactOptionalPropertyTypes": true,
"composite": true,
"typeRoots": [
"./node_modules/@types"
]
},
"include": [
"src/**/*",
"test/**/*",
"test-d/**/*"
],
"exclude": [
"node_modules"
]
}

View file

@ -1,15 +1,18 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "../shared/tsconfig.node.json",
"extends": "../shared/tsconfig.scripts.jsonc",
"compilerOptions": {
"noImplicitAny": false
"rootDirs": [
"./scripts",
"."
]
},
"include": [
"*.ts",
"*.js",
"scripts/**/*"
],
"exclude": [
"node_modules"
"scripts/**/*.ts",
"scripts/**/*.js",
"scripts/**/*.mjs",
"scripts/**/*.cjs"
]
}

View file

@ -1,19 +0,0 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "./tsconfig.lib.json",
"compilerOptions": {
"composite": false,
"declaration": false,
"declarationMap": false,
"sourceMap": false,
"inlineSources": false,
"outDir": "./temp/built/test-d/",
"rootDir": "."
},
"references": [
{ "path": "./tsconfig.lib.json" }
],
"include": [
"test-d/**/*"
]
}

View file

@ -1,21 +0,0 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "./tsconfig.lib.json",
"compilerOptions": {
"composite": false,
"declaration": false,
"declarationMap": false,
"sourceMap": false,
"inlineSources": false,
"module": "nodenext",
"moduleResolution": "nodenext",
"outDir": "./temp/built/test/",
"rootDir": "./test/"
},
"references": [
{ "path": "./tsconfig.lib.json" }
],
"include": [
"test/**/*"
]
}