shared: types: move API types to api folder

This commit is contained in:
Jesse Chan
2020-10-08 22:21:37 +08:00
parent f6896413a3
commit 61e6e79497
11 changed files with 40 additions and 36 deletions
+2 -2
View File
@@ -5,8 +5,8 @@ import type {
AuthRegisterOptions,
AuthUpdateUserOptions,
AuthVerificationResponse,
Credentials,
} from '@shared/types/Auth';
} from '@shared/types/api/auth';
import type {Credentials} from '@shared/types/Auth';
import AppDispatcher from '../dispatcher/AppDispatcher';
import ClientActions from './ClientActions';
@@ -11,7 +11,7 @@ import type {
SetTorrentsTagsOptions,
StartTorrentsOptions,
StopTorrentsOptions,
} from '@shared/types/Action';
} from '@shared/types/api/torrents';
import type {TorrentProperties} from '@shared/types/Torrent';
import AppDispatcher from '../dispatcher/AppDispatcher';
@@ -1,7 +1,7 @@
import {injectIntl, WrappedComponentProps} from 'react-intl';
import React from 'react';
import type {MoveTorrentsOptions} from '@shared/types/Action';
import type {MoveTorrentsOptions} from '@shared/types/api/torrents';
import {Form} from '../../../ui';
import Modal from '../Modal';
@@ -1,4 +1,5 @@
import type {AuthAuthenticationResponse, AuthVerificationResponse, Credentials} from '@shared/types/Auth';
import type {AuthAuthenticationResponse, AuthVerificationResponse} from '@shared/types/api/auth';
import type {Credentials} from '@shared/types/Auth';
import type {ClientSettings} from '@shared/constants/clientSettingsMap';
import type {NotificationFetchOptions, NotificationState} from '@shared/types/Notification';
import type {ServerEvents} from '@shared/types/ServerEvents';
+2 -1
View File
@@ -1,4 +1,5 @@
import type {AuthAuthenticationResponse, AuthVerificationResponse, Credentials} from '@shared/types/Auth';
import type {AuthAuthenticationResponse, AuthVerificationResponse} from '@shared/types/api/auth';
import type {Credentials} from '@shared/types/Auth';
import AppDispatcher from '../dispatcher/AppDispatcher';
import BaseStore from './BaseStore';
+2 -1
View File
@@ -4,7 +4,8 @@ import jwt from 'jsonwebtoken';
import passport from 'passport';
import type {Response} from 'express';
import type {AuthRegisterOptions, AuthUpdateUserOptions, Credentials} from '@shared/types/Auth';
import type {AuthRegisterOptions, AuthUpdateUserOptions} from '@shared/types/api/auth';
import type {Credentials} from '@shared/types/Auth';
import ajaxUtil from '../../util/ajaxUtil';
import config from '../../../config';
+1 -1
View File
@@ -11,7 +11,7 @@ import {
SetTorrentsTagsOptions,
StartTorrentsOptions,
StopTorrentsOptions,
} from '@shared/types/Action';
} from '@shared/types/api/torrents';
import ajaxUtil from '../../util/ajaxUtil';
import client from '../../models/client';
+1 -1
View File
@@ -16,7 +16,7 @@ import type {
SetTorrentsTagsOptions,
StartTorrentsOptions,
StopTorrentsOptions,
} from '@shared/types/Action';
} from '@shared/types/api/torrents';
import {accessDeniedError, createDirectory, isAllowedPath, sanitizePath} from '../util/fileUtil';
import BaseService from './BaseService';
-26
View File
@@ -15,29 +15,3 @@ export interface Credentials {
}
export type UserInDatabase = Required<Credentials> & {_id: string};
// POST /api/auth/authenticate
export type AuthAuthenticationOptions = Required<Pick<Credentials, 'username' | 'password'>>;
// POST /api/auth/authenticate - success response
export interface AuthAuthenticationResponse {
success: boolean;
token: string;
username: string;
isAdmin: boolean;
}
// POST /api/auth/register
export type AuthRegisterOptions = Required<
Pick<Credentials, 'username' | 'password' | 'host' | 'port' | 'socketPath' | 'isAdmin'>
>;
// PATCH /api/auth/users/{username}
export type AuthUpdateUserOptions = Partial<Credentials>;
// GET /api/auth/verify - success response
export interface AuthVerificationResponse extends Pick<AuthAuthenticationResponse, 'token'> {
initialUser: boolean;
username: string;
isAdmin: boolean;
}
+27
View File
@@ -0,0 +1,27 @@
import type {Credentials} from '../Auth';
// POST /api/auth/authenticate
export type AuthAuthenticationOptions = Required<Pick<Credentials, 'username' | 'password'>>;
// POST /api/auth/authenticate - success response
export interface AuthAuthenticationResponse {
success: boolean;
token: string;
username: string;
isAdmin: boolean;
}
// POST /api/auth/register
export type AuthRegisterOptions = Required<
Pick<Credentials, 'username' | 'password' | 'host' | 'port' | 'socketPath' | 'isAdmin'>
>;
// PATCH /api/auth/users/{username}
export type AuthUpdateUserOptions = Partial<Credentials>;
// GET /api/auth/verify - success response
export interface AuthVerificationResponse extends Pick<AuthAuthenticationResponse, 'token'> {
initialUser: boolean;
username: string;
isAdmin: boolean;
}
@@ -1,4 +1,4 @@
import {TorrentProperties} from './Torrent';
import {TorrentProperties} from '../Torrent';
// POST /api/torrents/add-urls
export interface AddTorrentByURLOptions {