deps(misskey-js): Update openapi-typescript to v7
This commit is contained in:
parent
208b201776
commit
2d15123387
|
@ -2907,10 +2907,11 @@ type PinnedUsersResponse = operations['pinned-users']['responses']['200']['conte
|
|||
type PromoReadRequest = operations['promo___read']['requestBody']['content']['application/json'];
|
||||
|
||||
// Warning: (ae-forgotten-export) The symbol "AllNullRecord" needs to be exported by the entry point index.d.ts
|
||||
// Warning: (ae-forgotten-export) The symbol "AllNullOrOptionalRecord" needs to be exported by the entry point index.d.ts
|
||||
// Warning: (ae-forgotten-export) The symbol "NonNullableRecord" needs to be exported by the entry point index.d.ts
|
||||
//
|
||||
// @public (undocumented)
|
||||
type PureRenote = Omit<Note, 'renote' | 'renoteId' | 'reply' | 'replyId' | 'text' | 'cw' | 'files' | 'fileIds' | 'poll'> & AllNullRecord<Pick<Note, 'reply' | 'replyId' | 'text' | 'cw' | 'poll'>> & {
|
||||
type PureRenote = Omit<Note, 'renote' | 'renoteId' | 'reply' | 'replyId' | 'text' | 'cw' | 'files' | 'fileIds' | 'poll'> & AllNullRecord<Pick<Note, 'text'>> & AllNullOrOptionalRecord<Pick<Note, 'reply' | 'replyId' | 'cw' | 'poll'>> & {
|
||||
files: [];
|
||||
fileIds: [];
|
||||
} & NonNullableRecord<Pick<Note, 'renote' | 'renoteId'>>;
|
||||
|
@ -3434,7 +3435,7 @@ type V2AdminEmojiListResponse = operations['v2___admin___emoji___list']['respons
|
|||
|
||||
// Warnings were encountered during analysis:
|
||||
//
|
||||
// src/entities.ts:50:2 - (ae-forgotten-export) The symbol "ModerationLogPayloads" needs to be exported by the entry point index.d.ts
|
||||
// src/entities.ts:54:2 - (ae-forgotten-export) The symbol "ModerationLogPayloads" needs to be exported by the entry point index.d.ts
|
||||
// src/streaming.ts:57:3 - (ae-forgotten-export) The symbol "ReconnectingWebSocket" needs to be exported by the entry point index.d.ts
|
||||
// src/streaming.types.ts:220:4 - (ae-forgotten-export) The symbol "ReversiUpdateKey" needs to be exported by the entry point index.d.ts
|
||||
// src/streaming.types.ts:230:4 - (ae-forgotten-export) The symbol "ReversiUpdateSettings" needs to be exported by the entry point index.d.ts
|
||||
|
|
|
@ -7,12 +7,12 @@
|
|||
"generate": "tsx src/generator.ts && eslint ./built/**/*.ts --fix"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@readme/openapi-parser": "2.6.0",
|
||||
"@readme/openapi-parser": "2.7.0",
|
||||
"@types/node": "22.10.7",
|
||||
"@typescript-eslint/eslint-plugin": "8.20.0",
|
||||
"@typescript-eslint/parser": "8.20.0",
|
||||
"openapi-types": "12.1.3",
|
||||
"openapi-typescript": "6.7.6",
|
||||
"openapi-typescript": "7.6.1",
|
||||
"ts-case-convert": "2.1.0",
|
||||
"tsx": "4.19.2",
|
||||
"typescript": "5.7.3"
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import assert from 'assert';
|
||||
import { mkdir, readFile, writeFile } from 'fs/promises';
|
||||
import { OpenAPIV3_1 } from 'openapi-types';
|
||||
import type { OpenAPIV3_1 } from 'openapi-types';
|
||||
import { toPascal } from 'ts-case-convert';
|
||||
import OpenAPIParser from '@readme/openapi-parser';
|
||||
import openapiTS, { OpenAPI3, OperationObject, PathItemObject } from 'openapi-typescript';
|
||||
import openapiTS, { astToString } from 'openapi-typescript';
|
||||
import type { OpenAPI3, OperationObject, PathItemObject } from 'openapi-typescript';
|
||||
import ts from 'typescript';
|
||||
|
||||
async function generateBaseTypes(
|
||||
openApiDocs: OpenAPIV3_1.Document,
|
||||
|
@ -28,13 +30,6 @@ async function generateBaseTypes(
|
|||
assert('post' in item);
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
openApi.paths![key] = {
|
||||
...('get' in item ? {
|
||||
get: {
|
||||
...item.get,
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
operationId: ((item as PathItemObject).get as OperationObject).operationId!.replaceAll('get___', ''),
|
||||
},
|
||||
} : {}),
|
||||
post: {
|
||||
...item.post,
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
|
@ -43,15 +38,22 @@ async function generateBaseTypes(
|
|||
};
|
||||
}
|
||||
|
||||
const generatedTypes = await openapiTS(openApi, {
|
||||
const tsNullNode = ts.factory.createLiteralTypeNode(ts.factory.createNull());
|
||||
const tsBlobNode = ts.factory.createTypeReferenceNode(ts.factory.createIdentifier('Blob'));
|
||||
|
||||
const generatedTypesAst = await openapiTS(openApi, {
|
||||
exportType: true,
|
||||
transform(schemaObject) {
|
||||
if ('format' in schemaObject && schemaObject.format === 'binary') {
|
||||
return schemaObject.nullable ? 'Blob | null' : 'Blob';
|
||||
if (schemaObject.nullable) {
|
||||
return ts.factory.createUnionTypeNode([tsBlobNode, tsNullNode]);
|
||||
} else {
|
||||
return tsBlobNode;
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
lines.push(generatedTypes);
|
||||
lines.push(astToString(generatedTypesAst));
|
||||
lines.push('');
|
||||
|
||||
await writeFile(typeFileName, lines.join('\n'));
|
||||
|
|
|
@ -77,7 +77,7 @@ export class APIClient {
|
|||
|
||||
if (mediaType === 'application/json') {
|
||||
payload = JSON.stringify({
|
||||
...params,
|
||||
...(this.assertIsRecord(params) ? params : {}),
|
||||
i: credential !== undefined ? credential : this.credential,
|
||||
});
|
||||
} else if (mediaType === 'multipart/form-data') {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -24,10 +24,14 @@ type NonNullableRecord<T> = {
|
|||
type AllNullRecord<T> = {
|
||||
[P in keyof T]: null;
|
||||
};
|
||||
type AllNullOrOptionalRecord<T> = {
|
||||
[P in keyof T]: never;
|
||||
};
|
||||
|
||||
export type PureRenote =
|
||||
Omit<Note, 'renote' | 'renoteId' | 'reply' | 'replyId' | 'text' | 'cw' | 'files' | 'fileIds' | 'poll'>
|
||||
& AllNullRecord<Pick<Note, 'reply' | 'replyId' | 'text' | 'cw' | 'poll'>>
|
||||
& AllNullRecord<Pick<Note, 'text'>>
|
||||
& AllNullOrOptionalRecord<Pick<Note, 'reply' | 'replyId' | 'cw' | 'poll'>>
|
||||
& { files: []; fileIds: []; }
|
||||
& NonNullableRecord<Pick<Note, 'renote' | 'renoteId'>>;
|
||||
|
||||
|
|
3948
pnpm-lock.yaml
3948
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue