mirror of
https://github.com/logto-io/logto.git
synced 2025-01-06 20:40:08 -05:00
chore(schemas,core,console): rename ConnectorDto to ConnectorResponse (#1884)
This commit is contained in:
parent
c6764f95f7
commit
2e0ab8988a
14 changed files with 45 additions and 35 deletions
|
@ -1,4 +1,4 @@
|
|||
import { ConnectorDto, ConnectorType } from '@logto/schemas';
|
||||
import { ConnectorResponse, 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<ConnectorResponse[], RequestError>('/api/connectors');
|
||||
|
||||
const groups = useMemo(() => {
|
||||
if (!data) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Connector, ConnectorDto, ConnectorMetadata, ConnectorType } from '@logto/schemas';
|
||||
import { Connector, ConnectorResponse, ConnectorMetadata, ConnectorType } from '@logto/schemas';
|
||||
import { useMemo } from 'react';
|
||||
import { Controller, useForm } from 'react-hook-form';
|
||||
import { toast } from 'react-hot-toast';
|
||||
|
@ -17,8 +17,8 @@ import SenderTester from './SenderTester';
|
|||
|
||||
type Props = {
|
||||
isDeleted: boolean;
|
||||
connectorData: ConnectorDto;
|
||||
onConnectorUpdated: (connector: ConnectorDto) => void;
|
||||
connectorData: ConnectorResponse;
|
||||
onConnectorUpdated: (connector: ConnectorResponse) => void;
|
||||
};
|
||||
|
||||
const ConnectorContent = ({ isDeleted, connectorData, onConnectorUpdated }: Props) => {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { ConnectorDto, ConnectorPlatform } from '@logto/schemas';
|
||||
import { ConnectorResponse, ConnectorPlatform } from '@logto/schemas';
|
||||
import classNames from 'classnames';
|
||||
import { 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<ConnectorResponse[]>(`/api/connectors?target=${target}`);
|
||||
|
||||
const connectors = useMemo(() => {
|
||||
if (!data) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { AppearanceMode, ConnectorDto, ConnectorType } from '@logto/schemas';
|
||||
import { AppearanceMode, ConnectorResponse, ConnectorType } from '@logto/schemas';
|
||||
import classNames from 'classnames';
|
||||
import { 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<ConnectorResponse, 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<ConnectorResponse>();
|
||||
toast.success(t('connector_details.connector_deleted'));
|
||||
|
||||
await mutateGlobal('/api/connectors');
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { AppearanceMode, ConnectorDto, ConnectorType } from '@logto/schemas';
|
||||
import { AppearanceMode, ConnectorResponse, ConnectorType } from '@logto/schemas';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
|
@ -17,7 +17,7 @@ import * as styles from './index.module.scss';
|
|||
|
||||
type Props = {
|
||||
type: ConnectorType;
|
||||
connectors: ConnectorDto[];
|
||||
connectors: ConnectorResponse[];
|
||||
onClickSetup?: () => void;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { ConnectorDto, ConnectorType } from '@logto/schemas';
|
||||
import { ConnectorResponse, ConnectorType } from '@logto/schemas';
|
||||
import { conditional } from '@silverhand/essentials';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
@ -12,7 +12,7 @@ import ConnectorName from '../ConnectorName';
|
|||
|
||||
type Props = {
|
||||
type: ConnectorType;
|
||||
connectors: ConnectorDto[];
|
||||
connectors: ConnectorResponse[];
|
||||
onClickSetup?: () => void;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { ConnectorDto, ConnectorType } from '@logto/schemas';
|
||||
import { ConnectorResponse, ConnectorType } from '@logto/schemas';
|
||||
import { getDefaultLanguage } from '@logto/shared';
|
||||
import { conditional } from '@silverhand/essentials';
|
||||
import i18next from 'i18next';
|
||||
|
@ -22,7 +22,7 @@ import { safeParseJson } from '@/utilities/json';
|
|||
import * as styles from './index.module.scss';
|
||||
|
||||
type Props = {
|
||||
connector: ConnectorDto;
|
||||
connector: ConnectorResponse;
|
||||
onClose: () => void;
|
||||
};
|
||||
|
||||
|
@ -57,10 +57,10 @@ const Guide = ({ connector, onClose }: Props) => {
|
|||
|
||||
await api
|
||||
.patch(`/api/connectors/${connectorId}`, { json: { config: result.data } })
|
||||
.json<ConnectorDto>();
|
||||
.json<ConnectorResponse>();
|
||||
await api
|
||||
.patch(`/api/connectors/${connectorId}/enabled`, { json: { enabled: true } })
|
||||
.json<ConnectorDto>();
|
||||
.json<ConnectorResponse>();
|
||||
|
||||
await updateSettings({
|
||||
...conditional(!isSocialConnector && { passwordlessConfigured: true }),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { ConnectorDto, ConnectorType, SignInMethodKey } from '@logto/schemas';
|
||||
import { ConnectorResponse, ConnectorType, SignInMethodKey } from '@logto/schemas';
|
||||
import { 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<ConnectorResponse[], RequestError>('/api/connectors');
|
||||
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
|
||||
|
||||
const type = useMemo(() => {
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
// FIXME: @sijie
|
||||
/* eslint-disable react/iframe-missing-sandbox */
|
||||
import { languageOptions } from '@logto/phrases-ui';
|
||||
import { AppearanceMode, ConnectorDto, ConnectorMetadata, SignInExperience } from '@logto/schemas';
|
||||
import {
|
||||
AppearanceMode,
|
||||
ConnectorResponse,
|
||||
ConnectorMetadata,
|
||||
SignInExperience,
|
||||
} from '@logto/schemas';
|
||||
import type { LanguageKey } from '@logto/shared';
|
||||
import { conditional } from '@silverhand/essentials';
|
||||
import classNames from 'classnames';
|
||||
|
@ -28,7 +33,7 @@ const Preview = ({ signInExperience, className }: Props) => {
|
|||
const [language, setLanguage] = useState<LanguageKey>('en');
|
||||
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<ConnectorResponse[], RequestError>('/api/connectors');
|
||||
const previewRef = useRef<HTMLIFrameElement>(null);
|
||||
|
||||
const modeOptions = useMemo(() => {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import type { Identities, ConnectorDto } from '@logto/schemas';
|
||||
import type { Identities, ConnectorResponse } from '@logto/schemas';
|
||||
import { Optional } from '@silverhand/essentials';
|
||||
import { useMemo, useState } from 'react';
|
||||
import { Trans, useTranslation } from 'react-i18next';
|
||||
|
@ -19,7 +19,7 @@ type Props = {
|
|||
onDelete?: (connectorId: string) => void;
|
||||
};
|
||||
|
||||
type DisplayConnector = Pick<ConnectorDto, 'target' | 'logo' | 'name'> & { userId?: string };
|
||||
type DisplayConnector = Pick<ConnectorResponse, 'target' | 'logo' | 'name'> & { userId?: string };
|
||||
|
||||
const UserConnectors = ({ userId, connectors, onDelete }: Props) => {
|
||||
const api = useApi();
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { ConnectorDto } from '@logto/schemas';
|
||||
import { ConnectorResponse } from '@logto/schemas';
|
||||
|
||||
export type ConnectorGroup = Pick<
|
||||
ConnectorDto,
|
||||
ConnectorResponse,
|
||||
'name' | 'logo' | 'logoDark' | 'target' | 'type' | 'description'
|
||||
> & {
|
||||
id: string;
|
||||
enabled: boolean;
|
||||
connectors: ConnectorDto[];
|
||||
connectors: ConnectorResponse[];
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { MessageTypes } from '@logto/connector-core';
|
||||
import { arbitraryObjectGuard, ConnectorDto, Connectors, ConnectorType } from '@logto/schemas';
|
||||
import { arbitraryObjectGuard, ConnectorResponse, Connectors, ConnectorType } from '@logto/schemas';
|
||||
import { emailRegEx, phoneRegEx } from '@logto/shared';
|
||||
import { object, string } from 'zod';
|
||||
|
||||
|
@ -12,7 +12,11 @@ import assertThat from '@/utils/assert-that';
|
|||
|
||||
import { AuthedRouter } from './types';
|
||||
|
||||
const transpileLogtoConnector = ({ dbEntry, metadata, type }: LogtoConnector): ConnectorDto => ({
|
||||
const transpileLogtoConnector = ({
|
||||
dbEntry,
|
||||
metadata,
|
||||
type,
|
||||
}: LogtoConnector): ConnectorResponse => ({
|
||||
type,
|
||||
...metadata,
|
||||
...dbEntry,
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
import { ConnectorDto } from '@logto/schemas';
|
||||
import { ConnectorResponse } from '@logto/schemas';
|
||||
|
||||
import { authedAdminApi } from './api';
|
||||
|
||||
export const listConnectors = async () => authedAdminApi.get('connectors').json<ConnectorDto[]>();
|
||||
export const listConnectors = async () =>
|
||||
authedAdminApi.get('connectors').json<ConnectorResponse[]>();
|
||||
|
||||
export const getConnector = async (connectorId: string) =>
|
||||
authedAdminApi.get(`connectors/${connectorId}`).json<ConnectorDto>();
|
||||
authedAdminApi.get(`connectors/${connectorId}`).json<ConnectorResponse>();
|
||||
|
||||
export const updateConnectorConfig = async (connectorId: string, config: Record<string, unknown>) =>
|
||||
authedAdminApi
|
||||
|
@ -13,7 +14,7 @@ export const updateConnectorConfig = async (connectorId: string, config: Record<
|
|||
url: `connectors/${connectorId}`,
|
||||
json: { config },
|
||||
})
|
||||
.json<ConnectorDto>();
|
||||
.json<ConnectorResponse>();
|
||||
|
||||
export const enableConnector = async (connectorId: string) =>
|
||||
updateConnectorEnabledProperty(connectorId, true);
|
||||
|
@ -27,7 +28,7 @@ const updateConnectorEnabledProperty = (connectorId: string, enabled: boolean) =
|
|||
url: `connectors/${connectorId}/enabled`,
|
||||
json: { enabled },
|
||||
})
|
||||
.json<ConnectorDto>();
|
||||
.json<ConnectorResponse>();
|
||||
|
||||
export const sendSmsTestMessage = async (
|
||||
connectorId: string,
|
||||
|
|
|
@ -5,6 +5,6 @@ import { Connector } from '../db-entries';
|
|||
export type { ConnectorMetadata } from '@logto/connector-core';
|
||||
export { ConnectorType, ConnectorPlatform } from '@logto/connector-core';
|
||||
|
||||
export type ConnectorDto = Connector &
|
||||
export type ConnectorResponse = Connector &
|
||||
Omit<BaseConnector<ConnectorType>, 'configGuard' | 'metadata'> &
|
||||
ConnectorMetadata;
|
||||
|
|
Loading…
Reference in a new issue