mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-30 02:12:38 +00:00
4.7 doc update (#1068)
* fix: plugin update * feat: get current time plugin * fix: ts * perf: select app ux * fix: ts * perf: max w * move code * perf: inform tip * fix: inform * doc * fix: tool handle * perf: tmp file store * doc * fix: message file selector * feat: doc * perf: switch trigger * doc * fix: openapi import * rount the number * parse openapi schema * fix empty line after variables (#64) * doc image * image size * doc * doc * catch error --------- Co-authored-by: heheer <71265218+newfish-cmyk@users.noreply.github.com>
This commit is contained in:
@@ -4,7 +4,6 @@ import { connectToDatabase } from '@/service/mongo';
|
||||
import type { CreateOnePluginParams } from '@fastgpt/global/core/plugin/controller';
|
||||
import { authUserNotVisitor } from '@fastgpt/service/support/permission/auth/user';
|
||||
import { MongoPlugin } from '@fastgpt/service/core/plugin/schema';
|
||||
import { checkTeamPluginLimit } from '@fastgpt/service/support/permission/teamLimit';
|
||||
import { mongoSessionRun } from '@fastgpt/service/common/mongo/sessionRun';
|
||||
import { httpApiSchema2Plugins } from '@fastgpt/global/core/plugin/httpPlugin/utils';
|
||||
|
||||
@@ -31,7 +30,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
|
||||
{ session }
|
||||
);
|
||||
|
||||
const childrenPlugins = httpApiSchema2Plugins({
|
||||
const childrenPlugins = await httpApiSchema2Plugins({
|
||||
parentId,
|
||||
apiSchemaStr: body.metadata?.apiSchemaStr,
|
||||
customHeader: body.metadata?.customHeaders
|
||||
|
@@ -1,15 +1,13 @@
|
||||
import type { NextApiRequest, NextApiResponse } from 'next';
|
||||
import { jsonRes } from '@fastgpt/service/common/response';
|
||||
import SwaggerParser from '@apidevtools/swagger-parser';
|
||||
import { loadOpenAPISchemaFromUrl } from '@fastgpt/global/common/string/swagger';
|
||||
|
||||
export default async function handler(req: NextApiRequest, res: NextApiResponse<any>) {
|
||||
try {
|
||||
const apiURL = req.body.url as string;
|
||||
|
||||
const api = await SwaggerParser.validate(apiURL);
|
||||
|
||||
return jsonRes(res, {
|
||||
data: api
|
||||
data: await loadOpenAPISchemaFromUrl(apiURL)
|
||||
});
|
||||
} catch (err) {
|
||||
jsonRes(res, {
|
||||
|
@@ -75,7 +75,7 @@ const updateHttpChildrenPlugin = async ({
|
||||
'_id metadata'
|
||||
);
|
||||
|
||||
const schemaPlugins = httpApiSchema2Plugins({
|
||||
const schemaPlugins = await httpApiSchema2Plugins({
|
||||
parentId: parent.id,
|
||||
apiSchemaStr: parent.metadata?.apiSchemaStr,
|
||||
customHeader: parent.metadata?.customHeaders
|
||||
|
@@ -13,8 +13,7 @@ import {
|
||||
Tbody,
|
||||
Tr,
|
||||
Td,
|
||||
IconButton,
|
||||
useDisclosure
|
||||
IconButton
|
||||
} from '@chakra-ui/react';
|
||||
import { useSelectFile } from '@/web/common/file/hooks/useSelectFile';
|
||||
import { useForm } from 'react-hook-form';
|
||||
@@ -37,12 +36,12 @@ import {
|
||||
import { str2OpenApiSchema } from '@fastgpt/global/core/plugin/httpPlugin/utils';
|
||||
import MyIcon from '@fastgpt/web/components/common/Icon';
|
||||
import { useConfirm } from '@fastgpt/web/hooks/useConfirm';
|
||||
import { AddIcon } from '@chakra-ui/icons';
|
||||
import MyModal from '@fastgpt/web/components/common/MyModal';
|
||||
import { EditFormType } from './type';
|
||||
import { FolderImgUrl } from '@fastgpt/global/common/file/image/constants';
|
||||
import HttpInput from '@fastgpt/web/components/common/Input/HttpInput';
|
||||
import { HttpHeaders } from '@/components/core/module/Flow/components/nodes/NodeHttp';
|
||||
import { OpenApiJsonSchema } from '@fastgpt/global/core/plugin/httpPlugin/type';
|
||||
|
||||
export const defaultHttpPlugin: CreateOnePluginParams = {
|
||||
avatar: FolderImgUrl,
|
||||
@@ -85,20 +84,7 @@ const HttpPluginEditModal = ({
|
||||
defaultValues: defaultPlugin
|
||||
});
|
||||
const apiSchemaStr = watch('metadata.apiSchemaStr');
|
||||
const apiData = useMemo(() => {
|
||||
if (!apiSchemaStr) {
|
||||
return { pathData: [], serverPath: '' };
|
||||
}
|
||||
try {
|
||||
return str2OpenApiSchema(apiSchemaStr);
|
||||
} catch (err) {
|
||||
toast({
|
||||
status: 'warning',
|
||||
title: t('plugin.Invalid Schema')
|
||||
});
|
||||
return { pathData: [], serverPath: '' };
|
||||
}
|
||||
}, [apiSchemaStr, t, toast]);
|
||||
const [apiData, setApiData] = useState<OpenApiJsonSchema>({ pathData: [], serverPath: '' });
|
||||
|
||||
const { mutate: onCreate, isLoading: isCreating } = useRequest({
|
||||
mutationFn: async (data: CreateOnePluginParams) => {
|
||||
@@ -201,6 +187,23 @@ const HttpPluginEditModal = ({
|
||||
[customHeaders]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
if (!apiSchemaStr) {
|
||||
return setApiData({ pathData: [], serverPath: '' });
|
||||
}
|
||||
try {
|
||||
setApiData(await str2OpenApiSchema(apiSchemaStr));
|
||||
} catch (err) {
|
||||
toast({
|
||||
status: 'warning',
|
||||
title: t('plugin.Invalid Schema')
|
||||
});
|
||||
setApiData({ pathData: [], serverPath: '' });
|
||||
}
|
||||
})();
|
||||
}, [apiSchemaStr, t, toast]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<MyModal
|
||||
|
@@ -39,6 +39,9 @@ const ExtraPlan = () => {
|
||||
const onclickBuyDatasetSize = useCallback(
|
||||
async ({ datasetSize, month }: { datasetSize: number; month: number }) => {
|
||||
try {
|
||||
datasetSize = Math.ceil(datasetSize);
|
||||
month = Math.ceil(month);
|
||||
|
||||
const datasetSizePayAmount = datasetSize * month * extraDatasetPrice;
|
||||
if (datasetSizePayAmount === 0) {
|
||||
return toast({
|
||||
@@ -80,6 +83,8 @@ const ExtraPlan = () => {
|
||||
const onclickBuyExtraPoints = useCallback(
|
||||
async ({ points }: { points: number }) => {
|
||||
try {
|
||||
points = Math.ceil(points);
|
||||
|
||||
const month = 1;
|
||||
const payAmount = points * month * extraPointsPrice;
|
||||
|
||||
|
Reference in New Issue
Block a user