chore(backend, misskey-js): add type for signup (#11043)

* chore(backend, misskey-js): add type for signup

* rerun
This commit is contained in:
Kagami Sascha Rosylight 2023-06-25 01:34:18 +02:00 committed by GitHub
parent a2c0573f84
commit 7bb8c71543
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 354 additions and 280 deletions

View File

@ -7,10 +7,11 @@ import * as OTPAuth from 'otpauth';
import { loadConfig } from '../../src/config.js'; import { loadConfig } from '../../src/config.js';
import { signup, api, post, react, startServer, waitFire } from '../utils.js'; import { signup, api, post, react, startServer, waitFire } from '../utils.js';
import type { INestApplicationContext } from '@nestjs/common'; import type { INestApplicationContext } from '@nestjs/common';
import type * as misskey from 'misskey-js';
describe('2要素認証', () => { describe('2要素認証', () => {
let app: INestApplicationContext; let app: INestApplicationContext;
let alice: unknown; let alice: misskey.entities.MeSignup;
const config = loadConfig(); const config = loadConfig();
const password = 'test'; const password = 'test';

View File

@ -32,7 +32,7 @@ describe('アンテナ', () => {
// - srcのenumにgroupが残っている // - srcのenumにgroupが残っている
// - userGroupIdが残っている, isActiveがない // - userGroupIdが残っている, isActiveがない
type Antenna = misskey.entities.Antenna | Packed<'Antenna'>; type Antenna = misskey.entities.Antenna | Packed<'Antenna'>;
type User = misskey.entities.MeDetailed & { token: string }; type User = misskey.entities.MeSignup;
type Note = misskey.entities.Note; type Note = misskey.entities.Note;
// アンテナを作成できる最小のパラメタ // アンテナを作成できる最小のパラメタ

View File

@ -3,6 +3,7 @@ process.env.NODE_ENV = 'test';
import * as assert from 'assert'; import * as assert from 'assert';
import { signup, api, post, startServer } from '../utils.js'; import { signup, api, post, startServer } from '../utils.js';
import type { INestApplicationContext } from '@nestjs/common'; import type { INestApplicationContext } from '@nestjs/common';
import type * as misskey from 'misskey-js';
describe('API visibility', () => { describe('API visibility', () => {
let app: INestApplicationContext; let app: INestApplicationContext;
@ -18,15 +19,15 @@ describe('API visibility', () => {
describe('Note visibility', () => { describe('Note visibility', () => {
//#region vars //#region vars
/** ヒロイン */ /** ヒロイン */
let alice: any; let alice: misskey.entities.MeSignup;
/** フォロワー */ /** フォロワー */
let follower: any; let follower: misskey.entities.MeSignup;
/** 非フォロワー */ /** 非フォロワー */
let other: any; let other: misskey.entities.MeSignup;
/** 非フォロワーでもリプライやメンションをされた人 */ /** 非フォロワーでもリプライやメンションをされた人 */
let target: any; let target: misskey.entities.MeSignup;
/** specified mentionでmentionを飛ばされる人 */ /** specified mentionでmentionを飛ばされる人 */
let target2: any; let target2: misskey.entities.MeSignup;
/** public-post */ /** public-post */
let pub: any; let pub: any;

View File

@ -3,12 +3,13 @@ process.env.NODE_ENV = 'test';
import * as assert from 'assert'; import * as assert from 'assert';
import { signup, api, startServer } from '../utils.js'; import { signup, api, startServer } from '../utils.js';
import type { INestApplicationContext } from '@nestjs/common'; import type { INestApplicationContext } from '@nestjs/common';
import type * as misskey from 'misskey-js';
describe('API', () => { describe('API', () => {
let app: INestApplicationContext; let app: INestApplicationContext;
let alice: any; let alice: misskey.entities.MeSignup;
let bob: any; let bob: misskey.entities.MeSignup;
let carol: any; let carol: misskey.entities.MeSignup;
beforeAll(async () => { beforeAll(async () => {
app = await startServer(); app = await startServer();

View File

@ -3,14 +3,15 @@ process.env.NODE_ENV = 'test';
import * as assert from 'assert'; import * as assert from 'assert';
import { signup, api, post, startServer } from '../utils.js'; import { signup, api, post, startServer } from '../utils.js';
import type { INestApplicationContext } from '@nestjs/common'; import type { INestApplicationContext } from '@nestjs/common';
import type * as misskey from 'misskey-js';
describe('Block', () => { describe('Block', () => {
let app: INestApplicationContext; let app: INestApplicationContext;
// alice blocks bob // alice blocks bob
let alice: any; let alice: misskey.entities.MeSignup;
let bob: any; let bob: misskey.entities.MeSignup;
let carol: any; let carol: misskey.entities.MeSignup;
beforeAll(async () => { beforeAll(async () => {
app = await startServer(); app = await startServer();

View File

@ -4,17 +4,18 @@ import * as assert from 'assert';
// node-fetch only supports it's own Blob yet // node-fetch only supports it's own Blob yet
// https://github.com/node-fetch/node-fetch/pull/1664 // https://github.com/node-fetch/node-fetch/pull/1664
import { Blob } from 'node-fetch'; import { Blob } from 'node-fetch';
import { User } from '@/models/index.js';
import { startServer, signup, post, api, uploadFile, simpleGet, initTestDb } from '../utils.js'; import { startServer, signup, post, api, uploadFile, simpleGet, initTestDb } from '../utils.js';
import type { INestApplicationContext } from '@nestjs/common'; import type { INestApplicationContext } from '@nestjs/common';
import { User } from '@/models/index.js'; import type * as misskey from 'misskey-js';
describe('Endpoints', () => { describe('Endpoints', () => {
let app: INestApplicationContext; let app: INestApplicationContext;
let alice: any; let alice: misskey.entities.MeSignup;
let bob: any; let bob: misskey.entities.MeSignup;
let carol: any; let carol: misskey.entities.MeSignup;
let dave: any; let dave: misskey.entities.MeSignup;
beforeAll(async () => { beforeAll(async () => {
app = await startServer(); app = await startServer();

View File

@ -4,6 +4,7 @@ import * as assert from 'assert';
import { startServer, channel, clip, cookie, galleryPost, signup, page, play, post, simpleGet, uploadFile } from '../utils.js'; import { startServer, channel, clip, cookie, galleryPost, signup, page, play, post, simpleGet, uploadFile } from '../utils.js';
import type { SimpleGetResponse } from '../utils.js'; import type { SimpleGetResponse } from '../utils.js';
import type { INestApplicationContext } from '@nestjs/common'; import type { INestApplicationContext } from '@nestjs/common';
import type * as misskey from 'misskey-js';
// Request Accept // Request Accept
const ONLY_AP = 'application/activity+json'; const ONLY_AP = 'application/activity+json';
@ -19,7 +20,7 @@ const JSON_UTF8 = 'application/json; charset=utf-8';
describe('Webリソース', () => { describe('Webリソース', () => {
let app: INestApplicationContext; let app: INestApplicationContext;
let alice: any; let alice: misskey.entities.MeSignup;
let aliceUploadedFile: any; let aliceUploadedFile: any;
let alicesPost: any; let alicesPost: any;
let alicePage: any; let alicePage: any;

View File

@ -3,12 +3,13 @@ process.env.NODE_ENV = 'test';
import * as assert from 'assert'; import * as assert from 'assert';
import { signup, api, startServer, simpleGet } from '../utils.js'; import { signup, api, startServer, simpleGet } from '../utils.js';
import type { INestApplicationContext } from '@nestjs/common'; import type { INestApplicationContext } from '@nestjs/common';
import type * as misskey from 'misskey-js';
describe('FF visibility', () => { describe('FF visibility', () => {
let app: INestApplicationContext; let app: INestApplicationContext;
let alice: any; let alice: misskey.entities.MeSignup;
let bob: any; let bob: misskey.entities.MeSignup;
beforeAll(async () => { beforeAll(async () => {
app = await startServer(); app = await startServer();

View File

@ -7,6 +7,7 @@ import { User, UsersRepository } from '@/models/index.js';
import { jobQueue } from '@/boot/common.js'; import { jobQueue } from '@/boot/common.js';
import { uploadFile, signup, startServer, initTestDb, api, sleep, successfulApiCall } from '../utils.js'; import { uploadFile, signup, startServer, initTestDb, api, sleep, successfulApiCall } from '../utils.js';
import type { INestApplicationContext } from '@nestjs/common'; import type { INestApplicationContext } from '@nestjs/common';
import type * as misskey from 'misskey-js';
describe('Account Move', () => { describe('Account Move', () => {
let app: INestApplicationContext; let app: INestApplicationContext;
@ -14,12 +15,12 @@ describe('Account Move', () => {
let url: URL; let url: URL;
let root: any; let root: any;
let alice: any; let alice: misskey.entities.MeSignup;
let bob: any; let bob: misskey.entities.MeSignup;
let carol: any; let carol: misskey.entities.MeSignup;
let dave: any; let dave: misskey.entities.MeSignup;
let eve: any; let eve: misskey.entities.MeSignup;
let frank: any; let frank: misskey.entities.MeSignup;
let Users: UsersRepository; let Users: UsersRepository;

View File

@ -3,14 +3,15 @@ process.env.NODE_ENV = 'test';
import * as assert from 'assert'; import * as assert from 'assert';
import { signup, api, post, react, startServer, waitFire } from '../utils.js'; import { signup, api, post, react, startServer, waitFire } from '../utils.js';
import type { INestApplicationContext } from '@nestjs/common'; import type { INestApplicationContext } from '@nestjs/common';
import type * as misskey from 'misskey-js';
describe('Mute', () => { describe('Mute', () => {
let app: INestApplicationContext; let app: INestApplicationContext;
// alice mutes carol // alice mutes carol
let alice: any; let alice: misskey.entities.MeSignup;
let bob: any; let bob: misskey.entities.MeSignup;
let carol: any; let carol: misskey.entities.MeSignup;
beforeAll(async () => { beforeAll(async () => {
app = await startServer(); app = await startServer();

View File

@ -4,13 +4,14 @@ import * as assert from 'assert';
import { Note } from '@/models/entities/Note.js'; import { Note } from '@/models/entities/Note.js';
import { signup, post, uploadUrl, startServer, initTestDb, api, uploadFile } from '../utils.js'; import { signup, post, uploadUrl, startServer, initTestDb, api, uploadFile } from '../utils.js';
import type { INestApplicationContext } from '@nestjs/common'; import type { INestApplicationContext } from '@nestjs/common';
import type * as misskey from 'misskey-js';
describe('Note', () => { describe('Note', () => {
let app: INestApplicationContext; let app: INestApplicationContext;
let Notes: any; let Notes: any;
let alice: any; let alice: misskey.entities.MeSignup;
let bob: any; let bob: misskey.entities.MeSignup;
beforeAll(async () => { beforeAll(async () => {
app = await startServer(); app = await startServer();

View File

@ -3,14 +3,15 @@ process.env.NODE_ENV = 'test';
import * as assert from 'assert'; import * as assert from 'assert';
import { signup, api, post, react, startServer, waitFire } from '../utils.js'; import { signup, api, post, react, startServer, waitFire } from '../utils.js';
import type { INestApplicationContext } from '@nestjs/common'; import type { INestApplicationContext } from '@nestjs/common';
import type * as misskey from 'misskey-js';
describe('Renote Mute', () => { describe('Renote Mute', () => {
let app: INestApplicationContext; let app: INestApplicationContext;
// alice mutes carol // alice mutes carol
let alice: any; let alice: misskey.entities.MeSignup;
let bob: any; let bob: misskey.entities.MeSignup;
let carol: any; let carol: misskey.entities.MeSignup;
beforeAll(async () => { beforeAll(async () => {
app = await startServer(); app = await startServer();

View File

@ -4,6 +4,7 @@ import * as assert from 'assert';
import { Following } from '@/models/entities/Following.js'; import { Following } from '@/models/entities/Following.js';
import { connectStream, signup, api, post, startServer, initTestDb, waitFire } from '../utils.js'; import { connectStream, signup, api, post, startServer, initTestDb, waitFire } from '../utils.js';
import type { INestApplicationContext } from '@nestjs/common'; import type { INestApplicationContext } from '@nestjs/common';
import type * as misskey from 'misskey-js';
describe('Streaming', () => { describe('Streaming', () => {
let app: INestApplicationContext; let app: INestApplicationContext;
@ -26,13 +27,13 @@ describe('Streaming', () => {
describe('Streaming', () => { describe('Streaming', () => {
// Local users // Local users
let ayano: any; let ayano: misskey.entities.MeSignup;
let kyoko: any; let kyoko: misskey.entities.MeSignup;
let chitose: any; let chitose: misskey.entities.MeSignup;
// Remote users // Remote users
let akari: any; let akari: misskey.entities.MeSignup;
let chinatsu: any; let chinatsu: misskey.entities.MeSignup;
let kyokoNote: any; let kyokoNote: any;
let list: any; let list: any;

View File

@ -3,13 +3,14 @@ process.env.NODE_ENV = 'test';
import * as assert from 'assert'; import * as assert from 'assert';
import { signup, api, post, connectStream, startServer } from '../utils.js'; import { signup, api, post, connectStream, startServer } from '../utils.js';
import type { INestApplicationContext } from '@nestjs/common'; import type { INestApplicationContext } from '@nestjs/common';
import type * as misskey from 'misskey-js';
describe('Note thread mute', () => { describe('Note thread mute', () => {
let app: INestApplicationContext; let app: INestApplicationContext;
let alice: any; let alice: misskey.entities.MeSignup;
let bob: any; let bob: misskey.entities.MeSignup;
let carol: any; let carol: misskey.entities.MeSignup;
beforeAll(async () => { beforeAll(async () => {
app = await startServer(); app = await startServer();

View File

@ -3,11 +3,12 @@ process.env.NODE_ENV = 'test';
import * as assert from 'assert'; import * as assert from 'assert';
import { signup, api, post, uploadUrl, startServer } from '../utils.js'; import { signup, api, post, uploadUrl, startServer } from '../utils.js';
import type { INestApplicationContext } from '@nestjs/common'; import type { INestApplicationContext } from '@nestjs/common';
import type * as misskey from 'misskey-js';
describe('users/notes', () => { describe('users/notes', () => {
let app: INestApplicationContext; let app: INestApplicationContext;
let alice: any; let alice: misskey.entities.MeSignup;
let jpgNote: any; let jpgNote: any;
let pngNote: any; let pngNote: any;
let jpgPngNote: any; let jpgPngNote: any;

View File

@ -83,7 +83,7 @@ const relativeFetch = async (path: string, init?: RequestInit | undefined) => {
return await fetch(new URL(path, `http://127.0.0.1:${port}/`).toString(), init); return await fetch(new URL(path, `http://127.0.0.1:${port}/`).toString(), init);
}; };
export const signup = async (params?: any): Promise<any> => { export const signup = async (params?: Partial<misskey.Endpoints['signup']['req']>): Promise<NonNullable<misskey.Endpoints['signup']['res']>> => {
const q = Object.assign({ const q = Object.assign({
username: 'test', username: 'test',
password: 'test', password: 'test',

View File

@ -1942,6 +1942,19 @@ export type Endpoints = {
req: TODO; req: TODO;
res: TODO; res: TODO;
}; };
'signup': {
req: {
username: string;
password: string;
host?: string;
invitationCode?: string;
emailAddress?: string;
'hcaptcha-response'?: string;
'g-recaptcha-response'?: string;
'turnstile-response'?: string;
};
res: MeSignup | null;
};
'stats': { 'stats': {
req: NoParams; req: NoParams;
res: Stats; res: Stats;
@ -2159,6 +2172,8 @@ declare namespace entities {
UserGroup, UserGroup,
UserList, UserList,
MeDetailed, MeDetailed,
MeDetailedWithSecret,
MeSignup,
DriveFile, DriveFile,
DriveFolder, DriveFolder,
GalleryPost, GalleryPost,
@ -2374,6 +2389,22 @@ type MeDetailed = UserDetailed & {
[other: string]: any; [other: string]: any;
}; };
// @public (undocumented)
type MeDetailedWithSecret = MeDetailed & {
email: string;
emailVerified: boolean;
securityKeysList: {
id: string;
name: string;
lastUsed: string;
}[];
};
// @public (undocumented)
type MeSignup = MeDetailedWithSecret & {
token: string;
};
// @public (undocumented) // @public (undocumented)
type MessagingMessage = { type MessagingMessage = {
id: ID; id: ID;
@ -2719,7 +2750,7 @@ type UserSorting = '+follower' | '-follower' | '+createdAt' | '-createdAt' | '+u
// //
// src/api.types.ts:16:32 - (ae-forgotten-export) The symbol "TODO" needs to be exported by the entry point index.d.ts // src/api.types.ts:16:32 - (ae-forgotten-export) The symbol "TODO" needs to be exported by the entry point index.d.ts
// src/api.types.ts:18:25 - (ae-forgotten-export) The symbol "NoParams" needs to be exported by the entry point index.d.ts // src/api.types.ts:18:25 - (ae-forgotten-export) The symbol "NoParams" needs to be exported by the entry point index.d.ts
// src/api.types.ts:596:18 - (ae-forgotten-export) The symbol "ShowUserReq" needs to be exported by the entry point index.d.ts // src/api.types.ts:611:18 - (ae-forgotten-export) The symbol "ShowUserReq" needs to be exported by the entry point index.d.ts
// src/streaming.types.ts:33:4 - (ae-forgotten-export) The symbol "FIXME" needs to be exported by the entry point index.d.ts // src/streaming.types.ts:33:4 - (ae-forgotten-export) The symbol "FIXME" needs to be exported by the entry point index.d.ts
// (No @packageDocumentation comment for this package) // (No @packageDocumentation comment for this package)

View File

@ -2,7 +2,7 @@ import type {
Ad, Announcement, Antenna, App, AuthSession, Blocking, Channel, Clip, DateString, DetailedInstanceMetadata, DriveFile, DriveFolder, Following, FollowingFolloweePopulated, FollowingFollowerPopulated, FollowRequest, GalleryPost, Instance, Ad, Announcement, Antenna, App, AuthSession, Blocking, Channel, Clip, DateString, DetailedInstanceMetadata, DriveFile, DriveFolder, Following, FollowingFolloweePopulated, FollowingFollowerPopulated, FollowRequest, GalleryPost, Instance,
LiteInstanceMetadata, LiteInstanceMetadata,
MeDetailed, MeDetailed,
Note, NoteFavorite, OriginType, Page, ServerInfo, Stats, User, UserDetailed, UserGroup, UserList, UserSorting, Notification, NoteReaction, Signin, MessagingMessage, Note, NoteFavorite, OriginType, Page, ServerInfo, Stats, User, UserDetailed, MeSignup, UserGroup, UserList, UserSorting, Notification, NoteReaction, Signin, MessagingMessage,
} from './entities.js'; } from './entities.js';
type TODO = Record<string, any> | null; type TODO = Record<string, any> | null;
@ -549,6 +549,21 @@ export type Endpoints = {
'room/show': { req: TODO; res: TODO; }; 'room/show': { req: TODO; res: TODO; };
'room/update': { req: TODO; res: TODO; }; 'room/update': { req: TODO; res: TODO; };
// signup
'signup': {
req: {
username: string;
password: string;
host?: string;
invitationCode?: string;
emailAddress?: string;
'hcaptcha-response'?: string;
'g-recaptcha-response'?: string;
'turnstile-response'?: string;
};
res: MeSignup | null;
};
// stats // stats
'stats': { req: NoParams; res: Stats; }; 'stats': { req: NoParams; res: Stats; };

View File

@ -107,6 +107,20 @@ export type MeDetailed = UserDetailed & {
[other: string]: any; [other: string]: any;
}; };
export type MeDetailedWithSecret = MeDetailed & {
email: string;
emailVerified: boolean;
securityKeysList: {
id: string;
name: string;
lastUsed: string;
}[];
};
export type MeSignup = MeDetailedWithSecret & {
token: string;
};
export type DriveFile = { export type DriveFile = {
id: ID; id: ID;
createdAt: DateString; createdAt: DateString;