mirror of
https://github.com/logto-io/logto.git
synced 2025-01-06 20:40:08 -05:00
refactor(core,schemas,ui): fix non-consistent type definitions (#1742)
This commit is contained in:
parent
f0347a7a6f
commit
6327eb6c57
6 changed files with 45 additions and 61 deletions
|
@ -14,12 +14,10 @@ import {
|
|||
} from '@/queries/user';
|
||||
import assertThat from '@/utils/assert-that';
|
||||
|
||||
// FIXME: @Darcy
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
|
||||
export interface SocialUserInfoSession {
|
||||
export type SocialUserInfoSession = {
|
||||
connectorId: string;
|
||||
userInfo: SocialUserInfo;
|
||||
}
|
||||
};
|
||||
|
||||
const getConnector = async (connectorId: string) => {
|
||||
try {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// FIXME: @sijie
|
||||
/* eslint-disable @typescript-eslint/consistent-type-definitions */
|
||||
import { MiddlewareType } from 'koa';
|
||||
import { IMiddleware } from 'koa-router';
|
||||
import { number } from 'zod';
|
||||
|
@ -7,20 +5,20 @@ import { number } from 'zod';
|
|||
import RequestError from '@/errors/RequestError';
|
||||
import { buildLink } from '@/utils/pagination';
|
||||
|
||||
export interface Pagination {
|
||||
export type Pagination = {
|
||||
offset: number;
|
||||
limit: number;
|
||||
totalCount?: number;
|
||||
}
|
||||
};
|
||||
|
||||
export type WithPaginationContext<ContextT> = ContextT & {
|
||||
pagination: Pagination;
|
||||
};
|
||||
|
||||
export interface PaginationConfig {
|
||||
export type PaginationConfig = {
|
||||
defaultPageSize?: number;
|
||||
maxPageSize?: number;
|
||||
}
|
||||
};
|
||||
|
||||
export const isPaginationMiddleware = <Type extends IMiddleware>(
|
||||
function_: Type
|
||||
|
@ -84,4 +82,3 @@ export default function koaPagination<StateT, ContextT, ResponseBodyT>({
|
|||
|
||||
return paginationMiddleware;
|
||||
}
|
||||
/* eslint-enable @typescript-eslint/consistent-type-definitions */
|
||||
|
|
|
@ -10,13 +10,11 @@ const { table, fields } = convertToIdentifiers(Logs);
|
|||
|
||||
export const insertLog = buildInsertInto<CreateLog>(Logs);
|
||||
|
||||
// FIXME: @IceHe
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
|
||||
export interface LogCondition {
|
||||
export type LogCondition = {
|
||||
logType?: string;
|
||||
applicationId?: string;
|
||||
userId?: string;
|
||||
}
|
||||
};
|
||||
|
||||
const buildLogConditionSql = (logCondition: LogCondition) =>
|
||||
conditionalSql(logCondition, ({ logType, applicationId, userId }) => {
|
||||
|
|
|
@ -21,14 +21,12 @@ export const addOidcEventListeners = (provider: Provider) => {
|
|||
* - https://github.com/panva/node-oidc-provider/blob/564b1095ee869c89381d63dfdb5875c99f870f5f/lib/actions/grants/refresh_token.js#L225
|
||||
* - ……
|
||||
*/
|
||||
// FIXME: @IceHe
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
|
||||
interface GrantBody {
|
||||
type GrantBody = {
|
||||
access_token?: string;
|
||||
refresh_token?: string;
|
||||
id_token?: string;
|
||||
scope?: string; // AccessToken.scope
|
||||
}
|
||||
};
|
||||
|
||||
const getLogType = (grantType: unknown) => {
|
||||
const allowedGrantType = new Set<unknown>([GrantType.AuthorizationCode, GrantType.RefreshToken]);
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// FIXME: @IceHe
|
||||
/* eslint-disable @typescript-eslint/consistent-type-definitions */
|
||||
import { Log } from '../db-entries';
|
||||
|
||||
export enum LogResult {
|
||||
|
@ -7,96 +5,96 @@ export enum LogResult {
|
|||
Error = 'Error',
|
||||
}
|
||||
|
||||
export interface BaseLogPayload {
|
||||
export type BaseLogPayload = {
|
||||
result?: LogResult;
|
||||
error?: Record<string, unknown>;
|
||||
ip?: string;
|
||||
userAgent?: string;
|
||||
applicationId?: string;
|
||||
sessionId?: string;
|
||||
}
|
||||
};
|
||||
|
||||
type ArbitraryLogPayload = Record<string, unknown>;
|
||||
|
||||
interface RegisterUsernamePasswordLogPayload extends ArbitraryLogPayload {
|
||||
type RegisterUsernamePasswordLogPayload = ArbitraryLogPayload & {
|
||||
userId?: string;
|
||||
username?: string;
|
||||
}
|
||||
};
|
||||
|
||||
interface RegisterEmailSendPasscodeLogPayload extends ArbitraryLogPayload {
|
||||
type RegisterEmailSendPasscodeLogPayload = ArbitraryLogPayload & {
|
||||
email?: string;
|
||||
connectorId?: string;
|
||||
}
|
||||
};
|
||||
|
||||
interface RegisterEmailLogPayload extends ArbitraryLogPayload {
|
||||
type RegisterEmailLogPayload = ArbitraryLogPayload & {
|
||||
email?: string;
|
||||
code?: string;
|
||||
userId?: string;
|
||||
}
|
||||
};
|
||||
|
||||
interface RegisterSmsSendPasscodeLogPayload extends ArbitraryLogPayload {
|
||||
type RegisterSmsSendPasscodeLogPayload = {
|
||||
phone?: string;
|
||||
connectorId?: string;
|
||||
}
|
||||
} & ArbitraryLogPayload;
|
||||
|
||||
interface RegisterSmsLogPayload extends ArbitraryLogPayload {
|
||||
type RegisterSmsLogPayload = ArbitraryLogPayload & {
|
||||
phone?: string;
|
||||
code?: string;
|
||||
userId?: string;
|
||||
}
|
||||
};
|
||||
|
||||
interface RegisterSocialBindLogPayload extends ArbitraryLogPayload {
|
||||
type RegisterSocialBindLogPayload = ArbitraryLogPayload & {
|
||||
connectorId?: string;
|
||||
userInfo?: object;
|
||||
userId?: string;
|
||||
}
|
||||
};
|
||||
|
||||
interface RegisterSocialLogPayload extends RegisterSocialBindLogPayload {
|
||||
type RegisterSocialLogPayload = RegisterSocialBindLogPayload & {
|
||||
code?: string;
|
||||
state?: string;
|
||||
redirectUri?: string;
|
||||
redirectTo?: string;
|
||||
}
|
||||
};
|
||||
|
||||
interface SignInUsernamePasswordLogPayload extends ArbitraryLogPayload {
|
||||
type SignInUsernamePasswordLogPayload = ArbitraryLogPayload & {
|
||||
userId?: string;
|
||||
username?: string;
|
||||
}
|
||||
};
|
||||
|
||||
interface SignInEmailSendPasscodeLogPayload extends ArbitraryLogPayload {
|
||||
type SignInEmailSendPasscodeLogPayload = ArbitraryLogPayload & {
|
||||
email?: string;
|
||||
connectorId?: string;
|
||||
}
|
||||
};
|
||||
|
||||
interface SignInEmailLogPayload extends ArbitraryLogPayload {
|
||||
type SignInEmailLogPayload = ArbitraryLogPayload & {
|
||||
email?: string;
|
||||
code?: string;
|
||||
userId?: string;
|
||||
}
|
||||
};
|
||||
|
||||
interface SignInSmsSendPasscodeLogPayload extends ArbitraryLogPayload {
|
||||
type SignInSmsSendPasscodeLogPayload = ArbitraryLogPayload & {
|
||||
phone?: string;
|
||||
connectorId?: string;
|
||||
}
|
||||
};
|
||||
|
||||
interface SignInSmsLogPayload extends ArbitraryLogPayload {
|
||||
type SignInSmsLogPayload = ArbitraryLogPayload & {
|
||||
phone?: string;
|
||||
code?: string;
|
||||
userId?: string;
|
||||
}
|
||||
};
|
||||
|
||||
interface SignInSocialBindLogPayload extends ArbitraryLogPayload {
|
||||
type SignInSocialBindLogPayload = ArbitraryLogPayload & {
|
||||
connectorId?: string;
|
||||
userInfo?: object;
|
||||
userId?: string;
|
||||
}
|
||||
};
|
||||
|
||||
interface SignInSocialLogPayload extends SignInSocialBindLogPayload {
|
||||
type SignInSocialLogPayload = SignInSocialBindLogPayload & {
|
||||
code?: string;
|
||||
state?: string;
|
||||
redirectUri?: string;
|
||||
redirectTo?: string;
|
||||
}
|
||||
};
|
||||
|
||||
export enum TokenType {
|
||||
AccessToken = 'AccessToken',
|
||||
|
@ -104,19 +102,19 @@ export enum TokenType {
|
|||
IdToken = 'IdToken',
|
||||
}
|
||||
|
||||
interface ExchangeTokenLogPayload extends ArbitraryLogPayload {
|
||||
type ExchangeTokenLogPayload = ArbitraryLogPayload & {
|
||||
userId?: string;
|
||||
params?: Record<string, unknown>;
|
||||
issued?: TokenType[];
|
||||
scope?: string;
|
||||
}
|
||||
};
|
||||
|
||||
interface RevokeTokenLogPayload extends ArbitraryLogPayload {
|
||||
type RevokeTokenLogPayload = ArbitraryLogPayload & {
|
||||
userId?: string;
|
||||
params?: Record<string, unknown>;
|
||||
grantId?: string;
|
||||
tokenType?: TokenType;
|
||||
}
|
||||
};
|
||||
|
||||
export type LogPayloads = {
|
||||
RegisterUsernamePassword: RegisterUsernamePasswordLogPayload;
|
||||
|
@ -151,4 +149,3 @@ export type LogDto = Omit<Log, 'payload'> & {
|
|||
ip?: string;
|
||||
};
|
||||
};
|
||||
/* eslint-enable @typescript-eslint/consistent-type-definitions */
|
||||
|
|
|
@ -15,11 +15,7 @@ export type Platform = 'web' | 'mobile';
|
|||
|
||||
export type Theme = 'dark' | 'light';
|
||||
|
||||
// FIXME: @Darcy
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
|
||||
export interface ConnectorData extends ConnectorMetadata {
|
||||
id: string;
|
||||
}
|
||||
export type ConnectorData = ConnectorMetadata & { id: string };
|
||||
|
||||
export type SignInExperienceSettingsResponse = SignInExperience & {
|
||||
socialConnectors: ConnectorData[];
|
||||
|
|
Loading…
Reference in a new issue