fix(misskey-js): miauth checkの型を追加

This commit is contained in:
kakkokari-gtyih 2024-11-03 16:21:55 +09:00
parent 6718a54f6f
commit 99e74cc53c
3 changed files with 28 additions and 1 deletions

View file

@ -1194,6 +1194,10 @@ export type Endpoints = Overwrite<Endpoints_2, {
}>; }>;
res: AdminRolesCreateResponse; res: AdminRolesCreateResponse;
}; };
[ep: `miauth/${string}/check`]: {
req: EmptyRequest;
res: MiAuthCheckResponse;
};
}>; }>;
// @public (undocumented) // @public (undocumented)
@ -1223,6 +1227,7 @@ declare namespace entities {
SigninWithPasskeyRequest, SigninWithPasskeyRequest,
SigninWithPasskeyInitResponse, SigninWithPasskeyInitResponse,
SigninWithPasskeyResponse, SigninWithPasskeyResponse,
MiAuthCheckResponse,
PartialRolePolicyOverride, PartialRolePolicyOverride,
EmptyRequest, EmptyRequest,
EmptyResponse, EmptyResponse,
@ -2439,6 +2444,15 @@ type MetaRequest = operations['meta']['requestBody']['content']['application/jso
// @public (undocumented) // @public (undocumented)
type MetaResponse = operations['meta']['responses']['200']['content']['application/json']; type MetaResponse = operations['meta']['responses']['200']['content']['application/json'];
// @public (undocumented)
type MiAuthCheckResponse = {
ok: true;
token: string;
user: User;
} | {
ok: false;
};
// @public (undocumented) // @public (undocumented)
type MiauthGenTokenRequest = operations['miauth___gen-token']['requestBody']['content']['application/json']; type MiauthGenTokenRequest = operations['miauth___gen-token']['requestBody']['content']['application/json'];

View file

@ -1,6 +1,6 @@
import { Endpoints as Gen } from './autogen/endpoint.js'; import { Endpoints as Gen } from './autogen/endpoint.js';
import { UserDetailed } from './autogen/models.js'; import { UserDetailed } from './autogen/models.js';
import { AdminRolesCreateRequest, AdminRolesCreateResponse, UsersShowRequest } from './autogen/entities.js'; import { AdminRolesCreateRequest, AdminRolesCreateResponse, UsersShowRequest, EmptyRequest } from './autogen/entities.js';
import { import {
PartialRolePolicyOverride, PartialRolePolicyOverride,
SigninFlowRequest, SigninFlowRequest,
@ -12,6 +12,7 @@ import {
SignupPendingResponse, SignupPendingResponse,
SignupRequest, SignupRequest,
SignupResponse, SignupResponse,
MiAuthCheckResponse,
} from './entities.js'; } from './entities.js';
type Overwrite<T, U extends { [Key in keyof T]?: unknown }> = Omit< type Overwrite<T, U extends { [Key in keyof T]?: unknown }> = Omit<
@ -104,6 +105,10 @@ export type Endpoints = Overwrite<
'admin/roles/create': { 'admin/roles/create': {
req: Overwrite<AdminRolesCreateRequest, { policies: PartialRolePolicyOverride }>; req: Overwrite<AdminRolesCreateRequest, { policies: PartialRolePolicyOverride }>;
res: AdminRolesCreateResponse; res: AdminRolesCreateResponse;
},
[ep: `miauth/${string}/check`]: {
req: EmptyRequest;
res: MiAuthCheckResponse;
} }
} }
> >

View file

@ -311,6 +311,14 @@ export type SigninWithPasskeyResponse = {
signinResponse: SigninFlowResponse & { finished: true }; signinResponse: SigninFlowResponse & { finished: true };
}; };
export type MiAuthCheckResponse = {
ok: true;
token: string;
user: User;
} | {
ok: false;
};
type Values<T extends Record<PropertyKey, unknown>> = T[keyof T]; type Values<T extends Record<PropertyKey, unknown>> = T[keyof T];
export type PartialRolePolicyOverride = Partial<{[k in keyof RolePolicies]: Omit<Values<Role['policies']>, 'value'> & { value: RolePolicies[k] }}>; export type PartialRolePolicyOverride = Partial<{[k in keyof RolePolicies]: Omit<Values<Role['policies']>, 'value'> & { value: RolePolicies[k] }}>;