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

View file

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

View file

@ -3,6 +3,7 @@ process.env.NODE_ENV = 'test';
import * as assert from 'assert';
import { signup, api, post, startServer } from '../utils.js';
import type { INestApplicationContext } from '@nestjs/common';
import type * as misskey from 'misskey-js';
describe('API visibility', () => {
let app: INestApplicationContext;
@ -18,15 +19,15 @@ describe('API visibility', () => {
describe('Note visibility', () => {
//#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を飛ばされる人 */
let target2: any;
let target2: misskey.entities.MeSignup;
/** public-post */
let pub: any;

View file

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

View file

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

View file

@ -4,17 +4,18 @@ import * as assert from 'assert';
// node-fetch only supports it's own Blob yet
// https://github.com/node-fetch/node-fetch/pull/1664
import { Blob } from 'node-fetch';
import { User } from '@/models/index.js';
import { startServer, signup, post, api, uploadFile, simpleGet, initTestDb } from '../utils.js';
import type { INestApplicationContext } from '@nestjs/common';
import { User } from '@/models/index.js';
import type * as misskey from 'misskey-js';
describe('Endpoints', () => {
let app: INestApplicationContext;
let alice: any;
let bob: any;
let carol: any;
let dave: any;
let alice: misskey.entities.MeSignup;
let bob: misskey.entities.MeSignup;
let carol: misskey.entities.MeSignup;
let dave: misskey.entities.MeSignup;
beforeAll(async () => {
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 type { SimpleGetResponse } from '../utils.js';
import type { INestApplicationContext } from '@nestjs/common';
import type * as misskey from 'misskey-js';
// Request Accept
const ONLY_AP = 'application/activity+json';
@ -19,7 +20,7 @@ const JSON_UTF8 = 'application/json; charset=utf-8';
describe('Webリソース', () => {
let app: INestApplicationContext;
let alice: any;
let alice: misskey.entities.MeSignup;
let aliceUploadedFile: any;
let alicesPost: any;
let alicePage: any;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1942,6 +1942,19 @@ export type Endpoints = {
req: 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': {
req: NoParams;
res: Stats;
@ -2159,6 +2172,8 @@ declare namespace entities {
UserGroup,
UserList,
MeDetailed,
MeDetailedWithSecret,
MeSignup,
DriveFile,
DriveFolder,
GalleryPost,
@ -2374,6 +2389,22 @@ type MeDetailed = UserDetailed & {
[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)
type MessagingMessage = {
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: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
// (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,
LiteInstanceMetadata,
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';
type TODO = Record<string, any> | null;
@ -549,6 +549,21 @@ export type Endpoints = {
'room/show': { 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': { req: NoParams; res: Stats; };

View file

@ -107,6 +107,20 @@ export type MeDetailed = UserDetailed & {
[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 = {
id: ID;
createdAt: DateString;