File tree Expand file tree Collapse file tree 9 files changed +48
-46
lines changed
projects/app/src/pages/api/core/app/plugin Expand file tree Collapse file tree 9 files changed +48
-46
lines changed Original file line number Diff line number Diff line change 1
1
import { type StoreNodeItemType } from '../../workflow/type/node' ;
2
2
import { type FlowNodeInputItemType } from '../../workflow/type/io' ;
3
3
import { FlowNodeTypeEnum } from '../../workflow/node/constant' ;
4
+ import { PluginSourceEnum } from './constants' ;
4
5
5
6
export const getPluginInputsFromStoreNodes = ( nodes : StoreNodeItemType [ ] ) => {
6
7
return nodes . find ( ( node ) => node . flowNodeType === FlowNodeTypeEnum . pluginInput ) ?. inputs || [ ] ;
@@ -22,3 +23,34 @@ export const getPluginRunContent = ({
22
23
} ) ;
23
24
return JSON . stringify ( pluginInputsWithValue ) ;
24
25
} ;
26
+
27
+ /**
28
+ plugin id rule:
29
+ - personal: ObjectId
30
+ - commercial: commercial-ObjectId
31
+ - systemtool: systemTool-id
32
+ (deprecated) community: community-id
33
+ */
34
+ export function splitCombinePluginId ( id : string ) {
35
+ const splitRes = id . split ( '-' ) ;
36
+ if ( splitRes . length === 1 ) {
37
+ // app id
38
+ return {
39
+ source : PluginSourceEnum . personal ,
40
+ pluginId : id
41
+ } ;
42
+ }
43
+
44
+ const [ source , pluginId ] = id . split ( '-' ) as [ PluginSourceEnum , string | undefined ] ;
45
+ if ( ! source || ! pluginId ) throw new Error ( 'pluginId not found' ) ;
46
+
47
+ // 兼容4.10.0 之前的插件
48
+ if ( source === 'community' || id === 'commercial-dalle3' ) {
49
+ return {
50
+ source : PluginSourceEnum . systemTool ,
51
+ pluginId : `${ PluginSourceEnum . systemTool } -${ pluginId } `
52
+ } ;
53
+ }
54
+
55
+ return { source, pluginId : id } ;
56
+ }
Original file line number Diff line number Diff line change @@ -37,37 +37,7 @@ import type {
37
37
} from '@fastgpt/global/core/workflow/type/io' ;
38
38
import { isProduction } from '@fastgpt/global/common/system/constants' ;
39
39
import type { RuntimeNodeItemType } from '@fastgpt/global/core/workflow/runtime/type' ;
40
-
41
- /**
42
- plugin id rule:
43
- - personal: ObjectId
44
- - commercial: commercial-ObjectId
45
- - systemtool: systemTool-id
46
- (deprecated) community: community-id
47
- */
48
- export function splitCombinePluginId ( id : string ) {
49
- const splitRes = id . split ( '-' ) ;
50
- if ( splitRes . length === 1 ) {
51
- // app id
52
- return {
53
- source : PluginSourceEnum . personal ,
54
- pluginId : id
55
- } ;
56
- }
57
-
58
- const [ source , pluginId ] = id . split ( '-' ) as [ PluginSourceEnum , string | undefined ] ;
59
- if ( ! source || ! pluginId ) throw new Error ( 'pluginId not found' ) ;
60
-
61
- // 兼容4.10.0 之前的插件
62
- if ( source === 'community' || id === 'commercial-dalle3' ) {
63
- return {
64
- source : PluginSourceEnum . systemTool ,
65
- pluginId : `${ PluginSourceEnum . systemTool } -${ pluginId } `
66
- } ;
67
- }
68
-
69
- return { source, pluginId : id } ;
70
- }
40
+ import { splitCombinePluginId } from '@fastgpt/global/core/app/plugin/utils' ;
71
41
72
42
type ChildAppType = SystemPluginTemplateItemType & {
73
43
teamId ?: string ;
Original file line number Diff line number Diff line change 1
1
import { type ChatNodeUsageType } from '@fastgpt/global/support/wallet/bill/type' ;
2
2
import { type PluginRuntimeType } from '@fastgpt/global/core/app/plugin/type' ;
3
- import { splitCombinePluginId } from './controller' ;
4
3
import { PluginSourceEnum } from '@fastgpt/global/core/app/plugin/constants' ;
4
+ import { splitCombinePluginId } from '@fastgpt/global/core/app/plugin/utils' ;
5
5
6
- /*
6
+ /*
7
7
Plugin points calculation:
8
8
1. 系统插件/商业版插件:
9
9
- 有错误:返回 0
Original file line number Diff line number Diff line change @@ -3,11 +3,12 @@ import { getEmbeddingModel } from '../ai/model';
3
3
import { FlowNodeTypeEnum } from '@fastgpt/global/core/workflow/node/constant' ;
4
4
import { NodeInputKeyEnum } from '@fastgpt/global/core/workflow/constants' ;
5
5
import type { StoreNodeItemType } from '@fastgpt/global/core/workflow/type/node' ;
6
- import { getChildAppPreviewNode , splitCombinePluginId } from './plugin/controller' ;
6
+ import { getChildAppPreviewNode } from './plugin/controller' ;
7
7
import { PluginSourceEnum } from '@fastgpt/global/core/app/plugin/constants' ;
8
8
import { authAppByTmbId } from '../../support/permission/app/auth' ;
9
9
import { ReadPermissionVal } from '@fastgpt/global/support/permission/constant' ;
10
10
import { getErrText } from '@fastgpt/global/common/error/utils' ;
11
+ import { splitCombinePluginId } from '@fastgpt/global/core/app/plugin/utils' ;
11
12
12
13
export async function listAppDatasetDataByTeamIdAndDatasetIds ( {
13
14
teamId,
Original file line number Diff line number Diff line change 1
- import { getPluginInputsFromStoreNodes } from '@fastgpt/global/core/app/plugin/utils' ;
1
+ import {
2
+ getPluginInputsFromStoreNodes ,
3
+ splitCombinePluginId
4
+ } from '@fastgpt/global/core/app/plugin/utils' ;
2
5
import { chatValue2RuntimePrompt } from '@fastgpt/global/core/chat/adapt' ;
3
6
import { PluginSourceEnum } from '@fastgpt/global/core/app/plugin/constants' ;
4
7
import { FlowNodeTypeEnum } from '@fastgpt/global/core/workflow/node/constant' ;
@@ -16,7 +19,7 @@ import { computedPluginUsage } from '../../../app/plugin/utils';
16
19
import { filterSystemVariables } from '../utils' ;
17
20
import { getPluginRunUserQuery } from '@fastgpt/global/core/workflow/utils' ;
18
21
import type { NodeInputKeyEnum } from '@fastgpt/global/core/workflow/constants' ;
19
- import { getChildAppRuntimeById , splitCombinePluginId } from '../../../app/plugin/controller' ;
22
+ import { getChildAppRuntimeById } from '../../../app/plugin/controller' ;
20
23
import { dispatchWorkFlow } from '../index' ;
21
24
import { getUserChatInfoAndAuthTeamPoints } from '../../../../support/permission/auth/team' ;
22
25
import { dispatchRunTool } from './runTool' ;
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ import { APIRunTool } from '../../../app/tool/api';
13
13
import { MongoSystemPlugin } from '../../../app/plugin/systemPluginSchema' ;
14
14
import { SystemToolInputTypeEnum } from '@fastgpt/global/core/app/systemTool/constants' ;
15
15
import type { StoreSecretValueType } from '@fastgpt/global/common/secret/type' ;
16
- import { getSystemToolById , splitCombinePluginId } from '../../../app/plugin/controller' ;
16
+ import { getSystemToolById } from '../../../app/plugin/controller' ;
17
17
18
18
type SystemInputConfigType = {
19
19
type : SystemToolInputTypeEnum ;
Original file line number Diff line number Diff line change @@ -10,10 +10,10 @@ import { AppPermission } from '@fastgpt/global/support/permission/app/controller
10
10
import { type PermissionValueType } from '@fastgpt/global/support/permission/type' ;
11
11
import { AppFolderTypeList } from '@fastgpt/global/core/app/constants' ;
12
12
import { type ParentIdType } from '@fastgpt/global/common/parentFolder/type' ;
13
- import { splitCombinePluginId } from '../../../core/app/plugin/controller' ;
14
13
import { PluginSourceEnum } from '@fastgpt/global/core/app/plugin/constants' ;
15
14
import { type AuthModeType , type AuthResponseType } from '../type' ;
16
15
import { AppDefaultPermissionVal } from '@fastgpt/global/support/permission/app/constant' ;
16
+ import { splitCombinePluginId } from '@fastgpt/global/core/app/plugin/utils' ;
17
17
18
18
export const authPluginByTmbId = async ( {
19
19
tmbId,
Original file line number Diff line number Diff line change 3
3
*/
4
4
import { PluginSourceEnum } from '@fastgpt/global/core/app/plugin/constants' ;
5
5
import { ReadPermissionVal } from '@fastgpt/global/support/permission/constant' ;
6
- import {
7
- getChildAppPreviewNode ,
8
- splitCombinePluginId
9
- } from '@fastgpt/service/core/app/plugin/controller' ;
6
+ import { getChildAppPreviewNode } from '@fastgpt/service/core/app/plugin/controller' ;
10
7
import { type FlowNodeTemplateType } from '@fastgpt/global/core/workflow/type/node.d' ;
11
8
import { NextAPI } from '@/service/middleware/entry' ;
12
9
import { type ApiRequestProps } from '@fastgpt/service/type/next' ;
13
10
import { authApp } from '@fastgpt/service/support/permission/app/auth' ;
14
11
import type { NextApiResponse } from 'next' ;
15
12
import { getLocale } from '@fastgpt/service/common/middle/i18n' ;
13
+ import { splitCombinePluginId } from '@fastgpt/global/core/app/plugin/utils' ;
16
14
17
15
export type GetPreviewNodeQuery = { appId : string ; versionId ?: string } ;
18
16
Original file line number Diff line number Diff line change @@ -6,13 +6,11 @@ import { type ApiRequestProps } from '@fastgpt/service/type/next';
6
6
import { authApp } from '@fastgpt/service/support/permission/app/auth' ;
7
7
import { ReadPermissionVal } from '@fastgpt/global/support/permission/constant' ;
8
8
import { parsePaginationRequest } from '@fastgpt/service/common/api/pagination' ;
9
- import {
10
- getSystemPluginByIdAndVersionId ,
11
- splitCombinePluginId
12
- } from '@fastgpt/service/core/app/plugin/controller' ;
9
+ import { getSystemPluginByIdAndVersionId } from '@fastgpt/service/core/app/plugin/controller' ;
13
10
import { PluginSourceEnum } from '@fastgpt/global/core/app/plugin/constants' ;
14
11
import { PluginErrEnum } from '@fastgpt/global/common/error/code/plugin' ;
15
12
import { Types } from '@fastgpt/service/common/mongo' ;
13
+ import { splitCombinePluginId } from '@fastgpt/global/core/app/plugin/utils' ;
16
14
17
15
export type getToolVersionListProps = PaginationProps < {
18
16
pluginId ?: string ;
You can’t perform that action at this time.
0 commit comments