fix(misskey-js): /signupと/signinの定義を作成してフロントの型エラーを抑制する (#12846)

* fix(misskey-js): /signupと/signinの定義を復活してフロントの型エラーを抑制する

* fix ci

* fix ci

* fix

* fix

---------

Co-authored-by: osamu <46447427+sam-osamu@users.noreply.github.com>
This commit is contained in:
おさむのひと 2024-01-03 13:41:28 +09:00 committed by GitHub
parent a9127e3ecd
commit 30311aca18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 170 additions and 53 deletions

View File

@ -24,7 +24,7 @@ import type * as misskey from 'misskey-js';
describe('2要素認証', () => { describe('2要素認証', () => {
let app: INestApplicationContext; let app: INestApplicationContext;
let alice: misskey.entities.MeSignup; let alice: misskey.entities.SignupResponse;
const config = loadConfig(); const config = loadConfig();
const password = 'test'; const password = 'test';

View File

@ -37,7 +37,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.MeSignup; type User = misskey.entities.SignupResponse;
type Note = misskey.entities.Note; type Note = misskey.entities.Note;
// アンテナを作成できる最小のパラメタ // アンテナを作成できる最小のパラメタ

View File

@ -24,15 +24,15 @@ describe('API visibility', () => {
describe('Note visibility', () => { describe('Note visibility', () => {
//#region vars //#region vars
/** ヒロイン */ /** ヒロイン */
let alice: misskey.entities.MeSignup; let alice: misskey.entities.SignupResponse;
/** フォロワー */ /** フォロワー */
let follower: misskey.entities.MeSignup; let follower: misskey.entities.SignupResponse;
/** 非フォロワー */ /** 非フォロワー */
let other: misskey.entities.MeSignup; let other: misskey.entities.SignupResponse;
/** 非フォロワーでもリプライやメンションをされた人 */ /** 非フォロワーでもリプライやメンションをされた人 */
let target: misskey.entities.MeSignup; let target: misskey.entities.SignupResponse;
/** specified mentionでmentionを飛ばされる人 */ /** specified mentionでmentionを飛ばされる人 */
let target2: misskey.entities.MeSignup; let target2: misskey.entities.SignupResponse;
/** public-post */ /** public-post */
let pub: any; let pub: any;

View File

@ -13,9 +13,9 @@ import type * as misskey from 'misskey-js';
describe('API', () => { describe('API', () => {
let app: INestApplicationContext; let app: INestApplicationContext;
let alice: misskey.entities.MeSignup; let alice: misskey.entities.SignupResponse;
let bob: misskey.entities.MeSignup; let bob: misskey.entities.SignupResponse;
let carol: misskey.entities.MeSignup; let carol: misskey.entities.SignupResponse;
beforeAll(async () => { beforeAll(async () => {
app = await startServer(); app = await startServer();

View File

@ -14,9 +14,9 @@ describe('Block', () => {
let app: INestApplicationContext; let app: INestApplicationContext;
// alice blocks bob // alice blocks bob
let alice: misskey.entities.MeSignup; let alice: misskey.entities.SignupResponse;
let bob: misskey.entities.MeSignup; let bob: misskey.entities.SignupResponse;
let carol: misskey.entities.MeSignup; let carol: misskey.entities.SignupResponse;
beforeAll(async () => { beforeAll(async () => {
app = await startServer(); app = await startServer();

View File

@ -17,10 +17,10 @@ import type * as misskey from 'misskey-js';
describe('Endpoints', () => { describe('Endpoints', () => {
let app: INestApplicationContext; let app: INestApplicationContext;
let alice: misskey.entities.MeSignup; let alice: misskey.entities.SignupResponse;
let bob: misskey.entities.MeSignup; let bob: misskey.entities.SignupResponse;
let carol: misskey.entities.MeSignup; let carol: misskey.entities.SignupResponse;
let dave: misskey.entities.MeSignup; let dave: misskey.entities.SignupResponse;
beforeAll(async () => { beforeAll(async () => {
app = await startServer(); app = await startServer();

View File

@ -25,7 +25,7 @@ const JSON_UTF8 = 'application/json; charset=utf-8';
describe('Webリソース', () => { describe('Webリソース', () => {
let app: INestApplicationContext; let app: INestApplicationContext;
let alice: misskey.entities.MeSignup; let alice: misskey.entities.SignupResponse;
let aliceUploadedFile: any; let aliceUploadedFile: any;
let alicesPost: any; let alicesPost: any;
let alicePage: any; let alicePage: any;
@ -34,7 +34,7 @@ describe('Webリソース', () => {
let aliceGalleryPost: any; let aliceGalleryPost: any;
let aliceChannel: any; let aliceChannel: any;
let bob: misskey.entities.MeSignup; let bob: misskey.entities.SignupResponse;
type Request = { type Request = {
path: string, path: string,

View File

@ -13,8 +13,8 @@ import type * as misskey from 'misskey-js';
describe('FF visibility', () => { describe('FF visibility', () => {
let app: INestApplicationContext; let app: INestApplicationContext;
let alice: misskey.entities.MeSignup; let alice: misskey.entities.SignupResponse;
let bob: misskey.entities.MeSignup; let bob: misskey.entities.SignupResponse;
beforeAll(async () => { beforeAll(async () => {
app = await startServer(); app = await startServer();

View File

@ -20,12 +20,12 @@ describe('Account Move', () => {
let url: URL; let url: URL;
let root: any; let root: any;
let alice: misskey.entities.MeSignup; let alice: misskey.entities.SignupResponse;
let bob: misskey.entities.MeSignup; let bob: misskey.entities.SignupResponse;
let carol: misskey.entities.MeSignup; let carol: misskey.entities.SignupResponse;
let dave: misskey.entities.MeSignup; let dave: misskey.entities.SignupResponse;
let eve: misskey.entities.MeSignup; let eve: misskey.entities.SignupResponse;
let frank: misskey.entities.MeSignup; let frank: misskey.entities.SignupResponse;
let Users: UsersRepository; let Users: UsersRepository;

View File

@ -14,9 +14,9 @@ describe('Mute', () => {
let app: INestApplicationContext; let app: INestApplicationContext;
// alice mutes carol // alice mutes carol
let alice: misskey.entities.MeSignup; let alice: misskey.entities.SignupResponse;
let bob: misskey.entities.MeSignup; let bob: misskey.entities.SignupResponse;
let carol: misskey.entities.MeSignup; let carol: misskey.entities.SignupResponse;
beforeAll(async () => { beforeAll(async () => {
app = await startServer(); app = await startServer();

View File

@ -16,8 +16,8 @@ describe('Note', () => {
let app: INestApplicationContext; let app: INestApplicationContext;
let Notes: any; let Notes: any;
let alice: misskey.entities.MeSignup; let alice: misskey.entities.SignupResponse;
let bob: misskey.entities.MeSignup; let bob: misskey.entities.SignupResponse;
beforeAll(async () => { beforeAll(async () => {
app = await startServer(); app = await startServer();

View File

@ -75,7 +75,7 @@ function getMeta(html: string): { transactionId: string | undefined, clientName:
}; };
} }
function fetchDecision(transactionId: string, user: misskey.entities.MeSignup, { cancel }: { cancel?: boolean } = {}): Promise<Response> { function fetchDecision(transactionId: string, user: misskey.entities.SignupResponse, { cancel }: { cancel?: boolean } = {}): Promise<Response> {
return fetch(new URL('/oauth/decision', host), { return fetch(new URL('/oauth/decision', host), {
method: 'post', method: 'post',
body: new URLSearchParams({ body: new URLSearchParams({
@ -90,14 +90,14 @@ function fetchDecision(transactionId: string, user: misskey.entities.MeSignup, {
}); });
} }
async function fetchDecisionFromResponse(response: Response, user: misskey.entities.MeSignup, { cancel }: { cancel?: boolean } = {}): Promise<Response> { async function fetchDecisionFromResponse(response: Response, user: misskey.entities.SignupResponse, { cancel }: { cancel?: boolean } = {}): Promise<Response> {
const { transactionId } = getMeta(await response.text()); const { transactionId } = getMeta(await response.text());
assert.ok(transactionId); assert.ok(transactionId);
return await fetchDecision(transactionId, user, { cancel }); return await fetchDecision(transactionId, user, { cancel });
} }
async function fetchAuthorizationCode(user: misskey.entities.MeSignup, scope: string, code_challenge: string): Promise<{ client: AuthorizationCode, code: string }> { async function fetchAuthorizationCode(user: misskey.entities.SignupResponse, scope: string, code_challenge: string): Promise<{ client: AuthorizationCode, code: string }> {
const client = new AuthorizationCode(clientConfig); const client = new AuthorizationCode(clientConfig);
const response = await fetch(client.authorizeURL({ const response = await fetch(client.authorizeURL({
@ -150,8 +150,8 @@ describe('OAuth', () => {
let app: INestApplicationContext; let app: INestApplicationContext;
let fastify: FastifyInstance; let fastify: FastifyInstance;
let alice: misskey.entities.MeSignup; let alice: misskey.entities.SignupResponse;
let bob: misskey.entities.MeSignup; let bob: misskey.entities.SignupResponse;
let sender: (reply: FastifyReply) => void; let sender: (reply: FastifyReply) => void;

View File

@ -14,9 +14,9 @@ describe('Renote Mute', () => {
let app: INestApplicationContext; let app: INestApplicationContext;
// alice mutes carol // alice mutes carol
let alice: misskey.entities.MeSignup; let alice: misskey.entities.SignupResponse;
let bob: misskey.entities.MeSignup; let bob: misskey.entities.SignupResponse;
let carol: misskey.entities.MeSignup; let carol: misskey.entities.SignupResponse;
beforeAll(async () => { beforeAll(async () => {
app = await startServer(); app = await startServer();

View File

@ -32,15 +32,15 @@ describe('Streaming', () => {
describe('Streaming', () => { describe('Streaming', () => {
// Local users // Local users
let ayano: misskey.entities.MeSignup; let ayano: misskey.entities.SignupResponse;
let kyoko: misskey.entities.MeSignup; let kyoko: misskey.entities.SignupResponse;
let chitose: misskey.entities.MeSignup; let chitose: misskey.entities.SignupResponse;
let kanako: misskey.entities.MeSignup; let kanako: misskey.entities.SignupResponse;
// Remote users // Remote users
let akari: misskey.entities.MeSignup; let akari: misskey.entities.SignupResponse;
let chinatsu: misskey.entities.MeSignup; let chinatsu: misskey.entities.SignupResponse;
let takumi: misskey.entities.MeSignup; let takumi: misskey.entities.SignupResponse;
let kyokoNote: any; let kyokoNote: any;
let kanakoNote: any; let kanakoNote: any;

View File

@ -13,9 +13,9 @@ import type * as misskey from 'misskey-js';
describe('Note thread mute', () => { describe('Note thread mute', () => {
let app: INestApplicationContext; let app: INestApplicationContext;
let alice: misskey.entities.MeSignup; let alice: misskey.entities.SignupResponse;
let bob: misskey.entities.MeSignup; let bob: misskey.entities.SignupResponse;
let carol: misskey.entities.MeSignup; let carol: misskey.entities.SignupResponse;
beforeAll(async () => { beforeAll(async () => {
app = await startServer(); app = await startServer();

View File

@ -13,7 +13,7 @@ import type * as misskey from 'misskey-js';
describe('users/notes', () => { describe('users/notes', () => {
let app: INestApplicationContext; let app: INestApplicationContext;
let alice: misskey.entities.MeSignup; let alice: misskey.entities.SignupResponse;
let jpgNote: any; let jpgNote: any;
let pngNote: any; let pngNote: any;
let jpgPngNote: any; let jpgPngNote: any;

View File

@ -1034,6 +1034,18 @@ export type Endpoints = Overwrite<Endpoints_2, {
}; };
}; };
}; };
'signup': {
req: SignupRequest;
res: SignupResponse;
};
'signup-pending': {
req: SignupPendingRequest;
res: SignupPendingResponse;
};
'signin': {
req: SigninRequest;
res: SigninResponse;
};
}>; }>;
// @public (undocumented) // @public (undocumented)
@ -1053,6 +1065,12 @@ declare namespace entities {
EmojiUpdated, EmojiUpdated,
EmojiDeleted, EmojiDeleted,
AnnouncementCreated, AnnouncementCreated,
SignupRequest,
SignupResponse,
SignupPendingRequest,
SignupPendingResponse,
SigninRequest,
SigninResponse,
EmptyRequest, EmptyRequest,
EmptyResponse, EmptyResponse,
AdminMetaResponse, AdminMetaResponse,
@ -2615,6 +2633,47 @@ type ServerStatsLog = string[];
// @public (undocumented) // @public (undocumented)
type Signin = components['schemas']['Signin']; type Signin = components['schemas']['Signin'];
// @public (undocumented)
type SigninRequest = {
username: string;
password: string;
token?: string;
};
// @public (undocumented)
type SigninResponse = {
id: User['id'];
i: string;
};
// @public (undocumented)
type SignupPendingRequest = {
code: string;
};
// @public (undocumented)
type SignupPendingResponse = {
id: User['id'];
i: string;
};
// @public (undocumented)
type SignupRequest = {
username: string;
password: string;
host?: string;
invitationCode?: string;
emailAddress?: string;
'hcaptcha-response'?: string | null;
'g-recaptcha-response'?: string | null;
'turnstile-response'?: string | null;
};
// @public (undocumented)
type SignupResponse = MeDetailed & {
token: string;
};
// @public (undocumented) // @public (undocumented)
type StatsResponse = operations['stats']['responses']['200']['content']['application/json']; type StatsResponse = operations['stats']['responses']['200']['content']['application/json'];

View File

@ -1,6 +1,14 @@
import { Endpoints as Gen } from './autogen/endpoint'; import { Endpoints as Gen } from './autogen/endpoint';
import { UserDetailed } from './autogen/models'; import { UserDetailed } from './autogen/models';
import { UsersShowRequest } from './autogen/entities'; import { UsersShowRequest } from './autogen/entities';
import {
SigninRequest,
SigninResponse,
SignupPendingRequest,
SignupPendingResponse,
SignupRequest,
SignupResponse,
} from './entities';
type Overwrite<T, U extends { [Key in keyof T]?: unknown }> = Omit< type Overwrite<T, U extends { [Key in keyof T]?: unknown }> = Omit<
T, T,
@ -55,6 +63,21 @@ export type Endpoints = Overwrite<
$default: UserDetailed; $default: UserDetailed;
}; };
}; };
} },
// api.jsonには載せないものなのでここで定義
'signup': {
req: SignupRequest;
res: SignupResponse;
},
// api.jsonには載せないものなのでここで定義
'signup-pending': {
req: SignupPendingRequest;
res: SignupPendingResponse;
},
// api.jsonには載せないものなのでここで定義
'signin': {
req: SigninRequest;
res: SigninResponse;
},
} }
> >

View File

@ -1,5 +1,5 @@
import { ModerationLogPayloads } from './consts.js'; import { ModerationLogPayloads } from './consts.js';
import { Announcement, EmojiDetailed, Page, User, UserDetailed } from './autogen/models'; import { Announcement, EmojiDetailed, MeDetailed, MeDetailedOnly, Page, User, UserDetailed } from './autogen/models';
export * from './autogen/entities'; export * from './autogen/entities';
export * from './autogen/models'; export * from './autogen/models';
@ -183,3 +183,38 @@ export type EmojiDeleted = {
export type AnnouncementCreated = { export type AnnouncementCreated = {
announcement: Announcement; announcement: Announcement;
}; };
export type SignupRequest = {
username: string;
password: string;
host?: string;
invitationCode?: string;
emailAddress?: string;
'hcaptcha-response'?: string | null;
'g-recaptcha-response'?: string | null;
'turnstile-response'?: string | null;
}
export type SignupResponse = MeDetailed & {
token: string;
}
export type SignupPendingRequest = {
code: string;
};
export type SignupPendingResponse = {
id: User['id'],
i: string,
};
export type SigninRequest = {
username: string;
password: string;
token?: string;
};
export type SigninResponse = {
id: User['id'],
i: string,
};