0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-30 20:33:54 -05:00

refactor: rename DTO -> Dto (#1522)

This commit is contained in:
Xiao Yijun 2022-07-12 18:35:51 +08:00 committed by GitHub
parent 074d455370
commit acefafed72
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 33 additions and 33 deletions

View file

@ -1,4 +1,4 @@
import { LogDTO, LogResult } from '@logto/schemas';
import { LogDto, LogResult } from '@logto/schemas';
import { conditionalString } from '@silverhand/essentials';
import classNames from 'classnames';
import React from 'react';
@ -42,7 +42,7 @@ const AuditLogTable = ({ userId }: Props) => {
]
.filter(Boolean)
.join('&');
const { data, error, mutate } = useSWR<[LogDTO[], number], RequestError>(
const { data, error, mutate } = useSWR<[LogDto[], number], RequestError>(
`/api/logs?${queryString}`
);
const isLoading = !data && !error;

View file

@ -1,4 +1,4 @@
import { ConnectorDTO, ConnectorType } from '@logto/schemas';
import { ConnectorDto, ConnectorType } from '@logto/schemas';
import { useMemo } from 'react';
import useSWR from 'swr';
@ -7,7 +7,7 @@ import { ConnectorGroup } from '@/types/connector';
// Group connectors by target
const useConnectorGroups = () => {
const { data, ...rest } = useSWR<ConnectorDTO[], RequestError>('/api/connectors');
const { data, ...rest } = useSWR<ConnectorDto[], RequestError>('/api/connectors');
const groups = useMemo(() => {
if (!data) {

View file

@ -1,4 +1,4 @@
import { LogDTO, User } from '@logto/schemas';
import { LogDto, User } from '@logto/schemas';
import classNames from 'classnames';
import dayjs from 'dayjs';
import React from 'react';
@ -30,7 +30,7 @@ const AuditLogDetails = () => {
const { userId, logId } = useParams();
const { pathname } = useLocation();
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
const { data, error } = useSWR<LogDTO, RequestError>(logId && `/api/logs/${logId}`);
const { data, error } = useSWR<LogDto, RequestError>(logId && `/api/logs/${logId}`);
const { data: userData } = useSWR<User, RequestError>(userId && `/api/users/${userId}`);
const isLoading = !data && !error;

View file

@ -1,4 +1,4 @@
import { Connector, ConnectorDTO, ConnectorMetadata, ConnectorType } from '@logto/schemas';
import { Connector, ConnectorDto, ConnectorMetadata, ConnectorType } from '@logto/schemas';
import React, { useEffect, useMemo, useState } from 'react';
import { toast } from 'react-hot-toast';
import { useTranslation } from 'react-i18next';
@ -15,8 +15,8 @@ import SenderTester from './SenderTester';
type Props = {
isDeleted: boolean;
connectorData: ConnectorDTO;
onConnectorUpdated: (connector: ConnectorDTO) => void;
connectorData: ConnectorDto;
onConnectorUpdated: (connector: ConnectorDto) => void;
};
const ConnectorContent = ({ isDeleted, connectorData, onConnectorUpdated }: Props) => {

View file

@ -1,4 +1,4 @@
import { ConnectorDTO, ConnectorPlatform } from '@logto/schemas';
import { ConnectorDto, ConnectorPlatform } from '@logto/schemas';
import classNames from 'classnames';
import React, { useMemo } from 'react';
import { useTranslation } from 'react-i18next';
@ -17,7 +17,7 @@ type Props = {
const ConnectorTabs = ({ target, connectorId }: Props) => {
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
const { data } = useSWR<ConnectorDTO[]>(`/api/connectors?target=${target}`);
const { data } = useSWR<ConnectorDto[]>(`/api/connectors?target=${target}`);
const connectors = useMemo(() => {
if (!data) {

View file

@ -1,4 +1,4 @@
import { AppearanceMode, ConnectorDTO, ConnectorType } from '@logto/schemas';
import { AppearanceMode, ConnectorDto, ConnectorType } from '@logto/schemas';
import classNames from 'classnames';
import React, { useState } from 'react';
import { toast } from 'react-hot-toast';
@ -39,7 +39,7 @@ const ConnectorDetails = () => {
const [isReadMeOpen, setIsReadMeOpen] = useState(false);
const [isSetupOpen, setIsSetupOpen] = useState(false);
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
const { data, error, mutate } = useSWR<ConnectorDTO, RequestError>(
const { data, error, mutate } = useSWR<ConnectorDto, RequestError>(
connectorId && `/api/connectors/${connectorId}`
);
const inUse = useConnectorInUse(data?.type, data?.target);
@ -57,7 +57,7 @@ const ConnectorDetails = () => {
.patch(`/api/connectors/${connectorId}/enabled`, {
json: { enabled: false },
})
.json<ConnectorDTO>();
.json<ConnectorDto>();
toast.success(t('connector_details.connector_deleted'));
await mutateGlobal('/api/connectors');

View file

@ -1,4 +1,4 @@
import { AppearanceMode, ConnectorDTO, ConnectorType } from '@logto/schemas';
import { AppearanceMode, ConnectorDto, ConnectorType } from '@logto/schemas';
import React from 'react';
import { useTranslation } from 'react-i18next';
import { Link } from 'react-router-dom';
@ -18,7 +18,7 @@ import * as styles from './index.module.scss';
type Props = {
type: ConnectorType;
connectors: ConnectorDTO[];
connectors: ConnectorDto[];
onClickSetup?: () => void;
};

View file

@ -1,4 +1,4 @@
import { ConnectorDTO, ConnectorType } from '@logto/schemas';
import { ConnectorDto, ConnectorType } from '@logto/schemas';
import { conditional } from '@silverhand/essentials';
import React from 'react';
import { useTranslation } from 'react-i18next';
@ -13,7 +13,7 @@ import ConnectorName from '../ConnectorName';
type Props = {
type: ConnectorType;
connectors: ConnectorDTO[];
connectors: ConnectorDto[];
onClickSetup?: () => void;
};

View file

@ -1,4 +1,4 @@
import { ConnectorDTO, ConnectorType } from '@logto/schemas';
import { ConnectorDto, ConnectorType } from '@logto/schemas';
import { conditional } from '@silverhand/essentials';
import i18next from 'i18next';
import React from 'react';
@ -21,7 +21,7 @@ import { GuideForm } from '@/types/guide';
import * as styles from './index.module.scss';
type Props = {
connector: ConnectorDTO;
connector: ConnectorDto;
onClose: () => void;
};
@ -56,12 +56,12 @@ const Guide = ({ connector, onClose }: Props) => {
.patch(`/api/connectors/${connectorId}`, {
json: { config },
})
.json<ConnectorDTO>();
.json<ConnectorDto>();
await api
.patch(`/api/connectors/${connectorId}/enabled`, {
json: { enabled: true },
})
.json<ConnectorDTO>();
.json<ConnectorDto>();
await updateSettings({
...conditional(!isSocialConnector && { passwordlessConfigured: true }),

View file

@ -1,4 +1,4 @@
import { ConnectorDTO, ConnectorType, SignInMethodKey } from '@logto/schemas';
import { ConnectorDto, ConnectorType, SignInMethodKey } from '@logto/schemas';
import React, { useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import useSWR from 'swr';
@ -11,7 +11,7 @@ type Props = {
};
const ConnectorSetupWarning = ({ method }: Props) => {
const { data: connectors } = useSWR<ConnectorDTO[], RequestError>('/api/connectors');
const { data: connectors } = useSWR<ConnectorDto[], RequestError>('/api/connectors');
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
const type = useMemo(() => {

View file

@ -1,5 +1,5 @@
import { Language } from '@logto/phrases';
import { AppearanceMode, ConnectorDTO, ConnectorMetadata, SignInExperience } from '@logto/schemas';
import { AppearanceMode, ConnectorDto, ConnectorMetadata, SignInExperience } from '@logto/schemas';
import { conditional } from '@silverhand/essentials';
import classNames from 'classnames';
import dayjs from 'dayjs';
@ -25,7 +25,7 @@ const Preview = ({ signInExperience, className }: Props) => {
const [language, setLanguage] = useState<Language>(Language.English);
const [mode, setMode] = useState<AppearanceMode>(AppearanceMode.LightMode);
const [platform, setPlatform] = useState<'desktopWeb' | 'mobile' | 'mobileWeb'>('desktopWeb');
const { data: allConnectors } = useSWR<ConnectorDTO[], RequestError>('/api/connectors');
const { data: allConnectors } = useSWR<ConnectorDto[], RequestError>('/api/connectors');
const previewRef = useRef<HTMLIFrameElement>(null);
const modeOptions = useMemo(() => {

View file

@ -1,10 +1,10 @@
import { ConnectorDTO } from '@logto/schemas';
import { ConnectorDto } from '@logto/schemas';
export type ConnectorGroup = Pick<
ConnectorDTO,
ConnectorDto,
'name' | 'logo' | 'logoDark' | 'target' | 'type' | 'description'
> & {
id: string;
enabled: boolean;
connectors: ConnectorDTO[];
connectors: ConnectorDto[];
};

View file

@ -1,4 +1,4 @@
import { arbitraryObjectGuard, ConnectorDTO, Connectors, ConnectorType } from '@logto/schemas';
import { arbitraryObjectGuard, ConnectorDto, Connectors, ConnectorType } from '@logto/schemas';
import { emailRegEx, phoneRegEx } from '@logto/shared';
import { object, string } from 'zod';
@ -15,7 +15,7 @@ import assertThat from '@/utils/assert-that';
import { AuthedRouter } from './types';
const transpileConnectorInstance = ({ connector, metadata }: ConnectorInstance): ConnectorDTO => ({
const transpileConnectorInstance = ({ connector, metadata }: ConnectorInstance): ConnectorDto => ({
...connector,
...metadata,
});

View file

@ -5,4 +5,4 @@ import { Connector } from '../db-entries';
export type { ConnectorMetadata } from '@logto/connector-types';
export { ConnectorType, ConnectorPlatform } from '@logto/connector-types';
export type ConnectorDTO = Connector & ConnectorMetadata;
export type ConnectorDto = Connector & ConnectorMetadata;

View file

@ -140,7 +140,7 @@ export type LogType = keyof LogPayloads;
export type LogPayload = LogPayloads[LogType];
export type LogDTO = Omit<Log, 'payload'> & {
export type LogDto = Omit<Log, 'payload'> & {
payload: {
userId?: string;
applicationId?: string;