feat(plugin): add plugin_from field to support plugin source tracking
This commit is contained in:
@ -30,10 +30,8 @@ export const ActivatePopover: FC<PropsWithChildren<ActivatePopoverProps>> = ({
|
||||
children,
|
||||
url,
|
||||
show = true,
|
||||
}) => {
|
||||
console.log('children');
|
||||
|
||||
return !show ? (
|
||||
}) =>
|
||||
!show ? (
|
||||
children
|
||||
) : (
|
||||
<Popover
|
||||
@ -67,4 +65,3 @@ export const ActivatePopover: FC<PropsWithChildren<ActivatePopoverProps>> = ({
|
||||
{children}
|
||||
</Popover>
|
||||
);
|
||||
};
|
||||
|
||||
@ -20,6 +20,7 @@ import type {
|
||||
ApiDetailData,
|
||||
BlockInput,
|
||||
} from '@coze-workflow/base';
|
||||
import { type PluginFrom } from '@coze-arch/bot-api/playground_api';
|
||||
import type {
|
||||
PluginProductStatus,
|
||||
ProductUnlistType,
|
||||
@ -99,7 +100,7 @@ export interface ApiNodeDataDTO {
|
||||
apiParam: BlockInput[];
|
||||
inputParameters?: BlockInput[];
|
||||
inputDefs?: DTODefine.InputVariableDTO[];
|
||||
pluginSource?: number;
|
||||
pluginFrom?: PluginFrom;
|
||||
batch?: {
|
||||
batchEnable: boolean;
|
||||
batchSize: number;
|
||||
|
||||
@ -18,7 +18,7 @@ import semver from 'semver';
|
||||
import { type ApiNodeDataDTO } from '@coze-workflow/nodes';
|
||||
import { type BotPluginWorkFlowItem } from '@coze-workflow/components';
|
||||
import { BlockInput } from '@coze-workflow/base';
|
||||
import { type PluginSource } from '@coze-arch/bot-api/playground_api';
|
||||
import { type PluginFrom } from '@coze-arch/bot-api/playground_api';
|
||||
|
||||
interface PluginApi {
|
||||
name: string;
|
||||
@ -30,7 +30,7 @@ interface PluginApi {
|
||||
plugin_product_status: number;
|
||||
version_name?: string;
|
||||
version_ts?: string;
|
||||
plugin_source?: PluginSource;
|
||||
plugin_from?: PluginFrom;
|
||||
}
|
||||
|
||||
export const createApiNodeInfo = (
|
||||
@ -44,7 +44,7 @@ export const createApiNodeInfo = (
|
||||
plugin_id,
|
||||
desc,
|
||||
version_ts,
|
||||
plugin_source,
|
||||
plugin_from,
|
||||
} = apiParams || {};
|
||||
|
||||
const result: ApiNodeDataDTO = {
|
||||
@ -71,7 +71,7 @@ export const createApiNodeInfo = (
|
||||
|
||||
// 开源版本,如果选择来自 Coze.cn 插件,设置 pluginSource 为 1
|
||||
if (IS_OPEN_SOURCE) {
|
||||
result.data.inputs.pluginSource = plugin_source;
|
||||
result.data.inputs.pluginFrom = plugin_from;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@ -49,6 +49,10 @@ const getPluginNodeService = (context: WorkflowPlaygroundContext) =>
|
||||
const getApiDetailApiParam = (nodeJson: any) =>
|
||||
nodeJson.data?.inputs?.apiParam || nodeJson?.inputs?.apiParam || [];
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const getPluginFrom = (nodeJson: any) =>
|
||||
nodeJson.data?.inputs?.pluginFrom || nodeJson?.inputs?.pluginFrom;
|
||||
|
||||
export const PLUGIN_NODE_REGISTRY: WorkflowNodeRegistry<NodeTestMeta> = {
|
||||
type: StandardNodeType.Api,
|
||||
meta: {
|
||||
@ -71,10 +75,11 @@ export const PLUGIN_NODE_REGISTRY: WorkflowNodeRegistry<NodeTestMeta> = {
|
||||
}
|
||||
|
||||
const pluginService = getPluginNodeService(context);
|
||||
const pluginFrom = getPluginFrom(nodeJson);
|
||||
const identifier = getApiNodeIdentifier(
|
||||
getApiDetailApiParam(nodeJson as ApiNodeData),
|
||||
);
|
||||
await pluginService.load(identifier);
|
||||
await pluginService.load(identifier, pluginFrom);
|
||||
},
|
||||
|
||||
checkError: (nodeJson, context: WorkflowPlaygroundContext) => {
|
||||
|
||||
@ -50,6 +50,7 @@ export function getSkillsQueryParams(boundSkills?: BoundSkills) {
|
||||
api_name: item.api_name,
|
||||
is_draft: item.is_draft,
|
||||
plugin_version: item.plugin_version,
|
||||
plugin_from: item.plugin_from,
|
||||
})),
|
||||
workflow_list: boundSkills?.workflowFCParam?.workflowList?.map(item => ({
|
||||
workflow_id: item.workflow_id,
|
||||
|
||||
@ -27,6 +27,7 @@ import {
|
||||
ProductUnlistType,
|
||||
} from '@coze-arch/idl/developer_api';
|
||||
import { I18n } from '@coze-arch/i18n';
|
||||
import { type PluginFrom } from '@coze-arch/bot-api/playground_api';
|
||||
|
||||
import { WorkflowGlobalStateEntity } from '@/entities';
|
||||
|
||||
@ -141,7 +142,7 @@ export class PluginNodeService {
|
||||
this.state.clearError(identifier);
|
||||
}
|
||||
|
||||
async fetchData(identifier: ApiNodeIdentifier) {
|
||||
async fetchData(identifier: ApiNodeIdentifier, pluginFrom?: PluginFrom) {
|
||||
const { spaceId, projectId } = this.globalState;
|
||||
return workflowQueryClient.fetchQuery({
|
||||
queryKey: [
|
||||
@ -152,6 +153,7 @@ export class PluginNodeService {
|
||||
identifier.apiName,
|
||||
identifier.api_id,
|
||||
projectId,
|
||||
pluginFrom,
|
||||
],
|
||||
// 1. Set up a 5s cache to ensure that the same request is only sent once in a process, and there will be no excessive performance degradation.
|
||||
// 2. api detail contains the input and output, version information of the plug-in, the data has real-time sensitivity, and there is no data lag.
|
||||
@ -162,6 +164,7 @@ export class PluginNodeService {
|
||||
...identifier,
|
||||
space_id: spaceId,
|
||||
project_id: projectId,
|
||||
plugin_from: pluginFrom,
|
||||
},
|
||||
{
|
||||
__disableErrorToast: true,
|
||||
@ -208,13 +211,13 @@ export class PluginNodeService {
|
||||
return false;
|
||||
}
|
||||
|
||||
async load(identifier: ApiNodeIdentifier) {
|
||||
async load(identifier: ApiNodeIdentifier, pluginFrom?: PluginFrom) {
|
||||
let apiDetail: ApiNodeDetailDTO | undefined;
|
||||
let errorMessage = '';
|
||||
|
||||
try {
|
||||
this.loading = true;
|
||||
const response = await this.fetchData(identifier);
|
||||
const response = await this.fetchData(identifier, pluginFrom);
|
||||
apiDetail = response.data as ApiNodeDetailDTO;
|
||||
} catch (error) {
|
||||
errorMessage = error.message;
|
||||
|
||||
Reference in New Issue
Block a user