merge: upstream

This commit is contained in:
Marie 2024-01-15 12:07:35 +01:00
commit 4c1f6be735
No known key found for this signature in database
GPG key ID: 56569BBE47D2C828
132 changed files with 12167 additions and 792 deletions

View file

@ -473,6 +473,18 @@ type BlockingListRequest = operations['blocking/list']['requestBody']['content']
// @public (undocumented)
type BlockingListResponse = operations['blocking/list']['responses']['200']['content']['application/json'];
// @public (undocumented)
type BubbleGameRankingRequest = operations['bubble-game/ranking']['requestBody']['content']['application/json'];
// @public (undocumented)
type BubbleGameRankingResponse = operations['bubble-game/ranking']['responses']['200']['content']['application/json'];
// @public (undocumented)
type BubbleGameRegisterRequest = operations['bubble-game/register']['requestBody']['content']['application/json'];
// @public (undocumented)
type BubbleGameRegisterResponse = operations['bubble-game/register']['responses']['200']['content']['application/json'];
// @public (undocumented)
type Channel = components['schemas']['Channel'];
@ -1607,6 +1619,10 @@ declare namespace entities {
FetchExternalResourcesRequest,
FetchExternalResourcesResponse,
RetentionResponse,
BubbleGameRegisterRequest,
BubbleGameRegisterResponse,
BubbleGameRankingRequest,
BubbleGameRankingResponse,
Error_2 as Error,
UserLite,
UserDetailedNotMeOnly,

View file

@ -7,14 +7,14 @@
"generate": "tsx src/generator.ts && eslint ./built/**/* --ext .ts --fix"
},
"devDependencies": {
"@apidevtools/swagger-parser": "10.1.0",
"@misskey-dev/eslint-plugin": "^1.0.0",
"@readme/openapi-parser": "2.5.0",
"@types/node": "20.9.1",
"@typescript-eslint/eslint-plugin": "6.11.0",
"@typescript-eslint/parser": "6.11.0",
"eslint": "8.53.0",
"openapi-types": "12.1.3",
"openapi-typescript": "6.7.1",
"openapi-typescript": "6.7.3",
"ts-case-convert": "2.0.2",
"tsx": "4.4.0",
"typescript": "5.3.3"

View file

@ -1,10 +1,10 @@
import { mkdir, writeFile } from 'fs/promises';
import { OpenAPIV3 } from 'openapi-types';
import { OpenAPIV3_1 } from 'openapi-types';
import { toPascal } from 'ts-case-convert';
import SwaggerParser from '@apidevtools/swagger-parser';
import OpenAPIParser from '@readme/openapi-parser';
import openapiTS from 'openapi-typescript';
function generateVersionHeaderComment(openApiDocs: OpenAPIV3.Document): string {
function generateVersionHeaderComment(openApiDocs: OpenAPIV3_1.Document): string {
const contents = {
version: openApiDocs.info.version,
generatedAt: new Date().toISOString(),
@ -21,7 +21,7 @@ function generateVersionHeaderComment(openApiDocs: OpenAPIV3.Document): string {
}
async function generateBaseTypes(
openApiDocs: OpenAPIV3.Document,
openApiDocs: OpenAPIV3_1.Document,
openApiJsonPath: string,
typeFileName: string,
) {
@ -47,7 +47,7 @@ async function generateBaseTypes(
}
async function generateSchemaEntities(
openApiDocs: OpenAPIV3.Document,
openApiDocs: OpenAPIV3_1.Document,
typeFileName: string,
outputPath: string,
) {
@ -71,7 +71,7 @@ async function generateSchemaEntities(
}
async function generateEndpoints(
openApiDocs: OpenAPIV3.Document,
openApiDocs: OpenAPIV3_1.Document,
typeFileName: string,
entitiesOutputPath: string,
endpointOutputPath: string,
@ -79,7 +79,7 @@ async function generateEndpoints(
const endpoints: Endpoint[] = [];
// misskey-jsはPOST固定で送っているので、こちらも決め打ちする。別メソッドに対応することがあればこちらも直す必要あり
const paths = openApiDocs.paths;
const paths = openApiDocs.paths ?? {};
const postPathItems = Object.keys(paths)
.map(it => paths[it]?.post)
.filter(filterUndefined);
@ -160,7 +160,7 @@ async function generateEndpoints(
}
async function generateApiClientJSDoc(
openApiDocs: OpenAPIV3.Document,
openApiDocs: OpenAPIV3_1.Document,
apiClientFileName: string,
endpointsFileName: string,
warningsOutputPath: string,
@ -168,7 +168,7 @@ async function generateApiClientJSDoc(
const endpoints: { operationId: string; description: string; }[] = [];
// misskey-jsはPOST固定で送っているので、こちらも決め打ちする。別メソッドに対応することがあればこちらも直す必要あり
const paths = openApiDocs.paths;
const paths = openApiDocs.paths ?? {};
const postPathItems = Object.keys(paths)
.map(it => paths[it]?.post)
.filter(filterUndefined);
@ -221,21 +221,21 @@ async function generateApiClientJSDoc(
await writeFile(warningsOutputPath, endpointOutputLine.join('\n'));
}
function isRequestBodyObject(value: unknown): value is OpenAPIV3.RequestBodyObject {
function isRequestBodyObject(value: unknown): value is OpenAPIV3_1.RequestBodyObject {
if (!value) {
return false;
}
const { content } = value as Record<keyof OpenAPIV3.RequestBodyObject, unknown>;
const { content } = value as Record<keyof OpenAPIV3_1.RequestBodyObject, unknown>;
return content !== undefined;
}
function isResponseObject(value: unknown): value is OpenAPIV3.ResponseObject {
function isResponseObject(value: unknown): value is OpenAPIV3_1.ResponseObject {
if (!value) {
return false;
}
const { description } = value as Record<keyof OpenAPIV3.ResponseObject, unknown>;
const { description } = value as Record<keyof OpenAPIV3_1.ResponseObject, unknown>;
return description !== undefined;
}
@ -330,7 +330,7 @@ async function main() {
await mkdir(generatePath, { recursive: true });
const openApiJsonPath = './api.json';
const openApiDocs = await SwaggerParser.validate(openApiJsonPath) as OpenAPIV3.Document;
const openApiDocs = await OpenAPIParser.parse(openApiJsonPath) as OpenAPIV3_1.Document;
const typeFileName = './built/autogen/types.ts';
await generateBaseTypes(openApiDocs, openApiJsonPath, typeFileName);

View file

@ -1,6 +1,6 @@
/*
* version: 2023.12.2
* generatedAt: 2024-01-07T15:22:15.630Z
* generatedAt: 2024-01-13T04:31:38.782Z
*/
import type { SwitchCaseResponseType } from '../api.js';
@ -4053,5 +4053,26 @@ declare module '../api.js' {
params: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
/** No description provided.
*
* **Credential required**: *Yes* / **Permission**: *write:account*
*/
request<E extends 'bubble-game/register', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
/**
* No description provided.
*
* **Credential required**: *No*
*/
request<E extends 'bubble-game/ranking', P extends Endpoints[E]['req']>(
endpoint: E,
params: P,
credential?: string | null,
): Promise<SwitchCaseResponseType<E, P>>;
}
}

View file

@ -1,6 +1,6 @@
/*
* version: 2023.12.2
* generatedAt: 2024-01-07T15:22:15.626Z
* generatedAt: 2024-01-13T04:31:38.778Z
*/
import type {
@ -555,6 +555,10 @@ import type {
FetchExternalResourcesResponse,
RetentionResponse,
SponsorsRequest,
BubbleGameRegisterRequest,
BubbleGameRegisterResponse,
BubbleGameRankingRequest,
BubbleGameRankingResponse,
} from './entities.js';
export type Endpoints = {
@ -929,4 +933,6 @@ export type Endpoints = {
'fetch-external-resources': { req: FetchExternalResourcesRequest; res: FetchExternalResourcesResponse };
'retention': { req: EmptyRequest; res: RetentionResponse };
'sponsors': { req: SponsorsRequest; res: EmptyResponse };
'bubble-game/register': { req: BubbleGameRegisterRequest; res: BubbleGameRegisterResponse };
'bubble-game/ranking': { req: BubbleGameRankingRequest; res: BubbleGameRankingResponse };
}

View file

@ -1,6 +1,6 @@
/*
* version: 2023.12.2
* generatedAt: 2024-01-07T15:22:15.624Z
* generatedAt: 2024-01-13T04:31:38.775Z
*/
import { operations } from './types.js';
@ -557,3 +557,7 @@ export type FetchExternalResourcesRequest = operations['fetch-external-resources
export type FetchExternalResourcesResponse = operations['fetch-external-resources']['responses']['200']['content']['application/json'];
export type RetentionResponse = operations['retention']['responses']['200']['content']['application/json'];
export type SponsorsRequest = operations['sponsors']['requestBody']['content']['application/json'];
export type BubbleGameRegisterRequest = operations['bubble-game/register']['requestBody']['content']['application/json'];
export type BubbleGameRegisterResponse = operations['bubble-game/register']['responses']['200']['content']['application/json'];
export type BubbleGameRankingRequest = operations['bubble-game/ranking']['requestBody']['content']['application/json'];
export type BubbleGameRankingResponse = operations['bubble-game/ranking']['responses']['200']['content']['application/json'];

View file

@ -1,6 +1,6 @@
/*
* version: 2023.12.2
* generatedAt: 2024-01-07T15:22:15.623Z
* generatedAt: 2024-01-13T04:31:38.773Z
*/
import { components } from './types.js';

View file

@ -3,7 +3,7 @@
/*
* version: 2023.12.2
* generatedAt: 2024-01-07T15:22:15.494Z
* generatedAt: 2024-01-13T04:31:38.633Z
*/
/**
@ -3566,6 +3566,31 @@ export type paths = {
*/
post: operations['sponsors'];
};
'/bubble-game/register': {
/**
* bubble-game/register
* @description No description provided.
*
* **Credential required**: *Yes* / **Permission**: *write:account*
*/
post: operations['bubble-game/register'];
};
'/bubble-game/ranking': {
/**
* bubble-game/ranking
* @description No description provided.
*
* **Credential required**: *No*
*/
get: operations['bubble-game/ranking'];
/**
* bubble-game/ranking
* @description No description provided.
*
* **Credential required**: *No*
*/
post: operations['bubble-game/ranking'];
};
};
export type webhooks = Record<string, never>;
@ -3923,7 +3948,7 @@ export type components = {
fileIds?: string[];
files?: components['schemas']['DriveFile'][];
tags?: string[];
poll?: Record<string, unknown> | null;
poll?: Record<string, never> | null;
/**
* Format: id
* @example xxxxxxxxxx
@ -3946,7 +3971,7 @@ export type components = {
url?: string;
reactionAndUserPairCache?: string[];
clippedCount?: number;
myReaction?: Record<string, unknown> | null;
myReaction?: Record<string, never> | null;
};
NoteReaction: {
/**
@ -26282,6 +26307,96 @@ export type operations = {
204: {
content: never;
};
};
};
/** bubble-game/register
* @description No description provided.
*
* **Credential required**: *Yes* / **Permission**: *write:account*
*/
'bubble-game/register': {
requestBody: {
content: {
'application/json': {
score: number;
seed: string;
logs: unknown[];
gameMode: string;
gameVersion: number;
};
};
};
responses: {
/** @description OK (with results) */
200: {
content: {
'application/json': unknown;
};
};
/** @description Client error */
400: {
content: {
'application/json': components['schemas']['Error'];
};
};
/** @description Authentication error */
401: {
content: {
'application/json': components['schemas']['Error'];
};
};
/** @description Forbidden error */
403: {
content: {
'application/json': components['schemas']['Error'];
};
};
/** @description I'm Ai */
418: {
content: {
'application/json': components['schemas']['Error'];
};
};
/** @description To many requests */
429: {
content: {
'application/json': components['schemas']['Error'];
};
};
/** @description Internal server error */
500: {
content: {
'application/json': components['schemas']['Error'];
};
};
};
};
/**
* bubble-game/ranking
* @description No description provided.
*
* **Credential required**: *No*
*/
'bubble-game/ranking': {
requestBody: {
content: {
'application/json': {
gameMode: string;
};
};
};
responses: {
/** @description OK (with results) */
200: {
content: {
'application/json': {
/** Format: misskey:id */
id: string;
score: number;
user: components['schemas']['UserLite'];
}[];
};
};
/** @description Client error */
400: {
content: {