@blueking/bkflow-canvas-editor 1.1.0-beta.5 → 1.1.0-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import { AxiosInstance, AxiosRequestConfig } from 'axios';
2
2
 
3
- type NodeExecutionStatus = 'CREATED' | 'RUNNING' | 'FINISHED' | 'FAILED' | 'SUSPENDED' | 'REVOKED';
3
+ type NodeExecutionStatus = 'CREATED' | 'RUNNING' | 'FINISHED' | 'FAILED' | 'SUSPENDED' | 'REVOKED' | 'SKIP';
4
4
  type ExecutionNodeAction = 'retry' | 'skip' | 'resume' | 'approve' | 'forceFail' | 'gatewaySkip';
5
5
  interface NodeExecutionState {
6
6
  status: NodeExecutionStatus;
@@ -600,6 +600,184 @@ interface CustomVariableType {
600
600
  code: string;
601
601
  }
602
602
 
603
+ type DebugContextStatus = 'idle' | 'running' | 'terminating';
604
+ type DebugNodeStatus = 'not_run' | 'running' | 'waiting' | 'paused' | 'finished' | 'failed' | 'suspended' | 'skipped';
605
+ type DebugExecutionMode = 'real' | 'mock';
606
+ interface DebugMissingVar {
607
+ key: string;
608
+ source_node_id: string | null;
609
+ }
610
+ type DebugRunMode = DebugExecutionMode | 'mixed';
611
+ type DebugRunType = 'global' | 'step';
612
+ type DebugRunStatus = 'not_run' | 'running' | 'waiting' | 'paused' | 'terminating' | 'finished' | 'failed' | 'revoked';
613
+ /** 运行级 / 节点级错误详情(last_error_detail、nodes[].error_detail)。 */
614
+ interface DebugErrorFailure {
615
+ message: string;
616
+ node_id?: string;
617
+ template_node_id?: string;
618
+ [key: string]: unknown;
619
+ }
620
+ interface DebugErrorDetail {
621
+ type?: string;
622
+ message?: string;
623
+ task_id?: number | string;
624
+ failures?: DebugErrorFailure[];
625
+ [key: string]: unknown;
626
+ }
627
+ interface DebugContextNode {
628
+ node_id: string;
629
+ node_type: string;
630
+ execution_mode: DebugExecutionMode;
631
+ status: DebugNodeStatus;
632
+ can_step: boolean;
633
+ missing_vars: DebugMissingVar[];
634
+ waiting_reason?: string | null;
635
+ mock_result?: 'success' | 'fail' | null;
636
+ error_detail?: DebugErrorDetail | string | null;
637
+ duration_ms?: number | null;
638
+ log_ref?: {
639
+ instance_id: number | string;
640
+ node_id: string;
641
+ version: string;
642
+ } | null;
643
+ mock_outputs?: Record<string, unknown> | null;
644
+ mock_error?: string | null;
645
+ outputs?: Record<string, unknown> | null;
646
+ }
647
+ /**
648
+ * /debug_context/ 顶层结构。
649
+ *
650
+ * 前端按 status 分支:
651
+ * - running:任务定位用 active_*,进度用 last_run_status
652
+ * - terminating:继续用 active_*,UI 展示「终止中」并轮询
653
+ * - idle:active_* 为空,结果摘要用 last_*;last_task_id=null 表示尚无调试记录
654
+ */
655
+ interface DebugContext {
656
+ template_id: number;
657
+ status: DebugContextStatus;
658
+ locked_by: string;
659
+ active_task_id: number | string | null;
660
+ active_run_type: DebugRunType | null;
661
+ active_node_id: string | null;
662
+ last_task_id: number | string | null;
663
+ last_run_type: DebugRunType | null;
664
+ last_run_status: DebugRunStatus | null;
665
+ last_error_detail?: DebugErrorDetail | null;
666
+ last_inputs?: Record<string, unknown>;
667
+ global_vars: Record<string, unknown>;
668
+ missing_vars?: DebugMissingVar[];
669
+ nodes: DebugContextNode[];
670
+ }
671
+ interface DebugInputSchemaField {
672
+ key: string;
673
+ name: string;
674
+ type: string;
675
+ default?: unknown;
676
+ required?: boolean;
677
+ [key: string]: unknown;
678
+ }
679
+ interface DebugInputSchema {
680
+ fields?: DebugInputSchemaField[];
681
+ constants?: Record<string, unknown>;
682
+ [key: string]: unknown;
683
+ }
684
+ interface DebugHistoryRun {
685
+ task_id?: number | string | null;
686
+ operator?: string;
687
+ started_at?: string;
688
+ finished_at?: string;
689
+ status?: DebugRunStatus | string;
690
+ run_type?: DebugRunType;
691
+ run_mode?: DebugRunMode;
692
+ [key: string]: unknown;
693
+ }
694
+ interface DebugHistory {
695
+ runs?: DebugHistoryRun[];
696
+ [key: string]: unknown;
697
+ }
698
+ interface DebugResetImpact {
699
+ reset_node_ids: string[];
700
+ reasons?: Record<string, string>;
701
+ }
702
+ interface DebugGlobalVarsResult {
703
+ global_vars: Record<string, unknown>;
704
+ [key: string]: unknown;
705
+ }
706
+ interface UpdateNodeDebugMockResult {
707
+ node_id: string;
708
+ execution_mode: DebugExecutionMode;
709
+ updated_global_vars?: Record<string, unknown>;
710
+ [key: string]: unknown;
711
+ }
712
+ interface RunNodeDebugStepResult {
713
+ node_id: string;
714
+ status: DebugNodeStatus;
715
+ outputs?: Record<string, unknown> | null;
716
+ error_detail?: unknown;
717
+ updated_global_vars?: Record<string, unknown>;
718
+ log_ref?: DebugContextNode['log_ref'];
719
+ [key: string]: unknown;
720
+ }
721
+ interface RunGlobalDebugResult {
722
+ task_id: number | string;
723
+ status: DebugContextStatus;
724
+ [key: string]: unknown;
725
+ }
726
+ interface TerminateDebugResult {
727
+ status?: DebugContextStatus;
728
+ [key: string]: unknown;
729
+ }
730
+ interface DebugResetResult {
731
+ reset_node_ids?: string[];
732
+ [key: string]: unknown;
733
+ }
734
+ interface UpdateDebugContextVariableParams {
735
+ templateId: string | number;
736
+ key: string;
737
+ value: unknown;
738
+ }
739
+ interface UpdateNodeDebugMockParams {
740
+ templateId: string | number;
741
+ nodeId: string;
742
+ enable: boolean;
743
+ mockResult?: 'success' | 'fail';
744
+ mockOutputs?: Record<string, unknown>;
745
+ mockError?: string;
746
+ }
747
+ interface RunNodeDebugStepParams {
748
+ templateId: string | number;
749
+ nodeId: string;
750
+ mode: 'real' | 'mock';
751
+ inputOverrides?: Record<string, unknown>;
752
+ mockResult?: 'success' | 'fail';
753
+ mockOutputs?: Record<string, unknown>;
754
+ mockError?: string;
755
+ }
756
+ interface RunGlobalDebugParams {
757
+ templateId: string | number;
758
+ inputs: Record<string, unknown>;
759
+ }
760
+ interface TerminateDebugParams {
761
+ templateId: string | number;
762
+ nodeId?: string;
763
+ }
764
+ interface ResetDebugResultParams {
765
+ templateId: string | number;
766
+ nodeIds?: string[];
767
+ }
768
+ interface DebugApiServices {
769
+ fetchDebugContext(templateId: string | number): Promise<DebugContext>;
770
+ fetchDebugInputSchema(templateId: string | number): Promise<DebugInputSchema>;
771
+ fetchDebugHistory(templateId: string | number): Promise<DebugHistory>;
772
+ fetchDebugResetImpact(templateId: string | number): Promise<DebugResetImpact>;
773
+ updateDebugContextVariable(params: UpdateDebugContextVariableParams): Promise<DebugGlobalVarsResult>;
774
+ updateNodeDebugMock(params: UpdateNodeDebugMockParams): Promise<UpdateNodeDebugMockResult>;
775
+ runNodeDebugStep(params: RunNodeDebugStepParams): Promise<RunNodeDebugStepResult>;
776
+ runGlobalDebug(params: RunGlobalDebugParams): Promise<RunGlobalDebugResult>;
777
+ terminateDebug(params: TerminateDebugParams): Promise<TerminateDebugResult>;
778
+ resetDebugResult(params: ResetDebugResultParams): Promise<DebugResetResult>;
779
+ }
780
+
603
781
  /**
604
782
  * Flow API 配置接口
605
783
  */
@@ -616,6 +794,8 @@ interface FlowApiConfig {
616
794
  scopeData: {
617
795
  scope_type: string;
618
796
  scope_value: number;
797
+ /** 业务方传入的空间 ID,调试接口专用,语义独立于 scope_value */
798
+ space_id: number;
619
799
  };
620
800
  /**
621
801
  * 用户查询 API 地址(可选)
@@ -682,6 +862,35 @@ interface FlowTaskDetail {
682
862
  pipeline_tree: PipelineTree;
683
863
  [key: string]: unknown;
684
864
  }
865
+ interface CreateFlowTaskParams {
866
+ template_id: number;
867
+ name: string;
868
+ creator: string;
869
+ constants: Record<string, any>;
870
+ label_ids?: number[];
871
+ [key: string]: unknown;
872
+ }
873
+ interface CreateFlowTaskResult {
874
+ data: {
875
+ id: number | string;
876
+ template_id?: number;
877
+ [key: string]: unknown;
878
+ };
879
+ [key: string]: unknown;
880
+ }
881
+ interface ExecuteFlowTaskResult {
882
+ result?: boolean;
883
+ code?: number;
884
+ data?: {
885
+ /** 任务详情页跳转地址(含正确的 bkflow task id 与 templateId) */
886
+ url?: string;
887
+ [key: string]: unknown;
888
+ };
889
+ message?: string | null;
890
+ request_id?: string;
891
+ trace_id?: string | null;
892
+ [key: string]: unknown;
893
+ }
685
894
  interface TaskStateResult {
686
895
  state?: string;
687
896
  status?: string;
@@ -707,6 +916,8 @@ interface FlowViewApiConfig {
707
916
  scopeData: {
708
917
  scope_type: string;
709
918
  scope_value: number;
919
+ /** 业务方传入的空间 ID,调试接口专用,语义独立于 scope_value */
920
+ space_id: number;
710
921
  };
711
922
  fetchFlowDraftDetail?: (id: string) => Promise<FlowDraftDetail>;
712
923
  fetchFlowDetailByVersion?: (id: string, version: string) => Promise<FlowDetailByVersion>;
@@ -726,23 +937,13 @@ interface FlowViewApiConfig {
726
937
  data: any[];
727
938
  };
728
939
  }>;
729
- createFlowTask?: (params: {
730
- template_id: number;
731
- name: string;
732
- creator: string;
733
- constants: Record<string, any>;
734
- }) => Promise<{
735
- data: {
736
- id: number;
737
- template_id: number;
738
- };
739
- }>;
940
+ createFlowTask?: (params: CreateFlowTaskParams) => Promise<CreateFlowTaskResult>;
740
941
  executeFlowTask?: (params: {
741
942
  task_id: number | string;
742
943
  resource_type: string;
743
944
  resource_id: number | string;
744
945
  permission_type: string;
745
- }) => Promise<any>;
946
+ }) => Promise<ExecuteFlowTaskResult>;
746
947
  revokeFlowTask?: (params: {
747
948
  task_id: number | string;
748
949
  resource_type: string;
@@ -799,23 +1000,13 @@ interface FlowEditApiConfig extends FlowViewApiConfig {
799
1000
  drawPipeline?: (params: DrawPipelineParams) => Promise<{
800
1001
  pipeline_tree: PipelineTree;
801
1002
  }>;
802
- createFlowTask?: (params: {
803
- template_id: number;
804
- name: string;
805
- creator: string;
806
- constants: Record<string, any>;
807
- }) => Promise<{
808
- data: {
809
- id: number;
810
- template_id: number;
811
- };
812
- }>;
1003
+ createFlowTask?: (params: CreateFlowTaskParams) => Promise<CreateFlowTaskResult>;
813
1004
  executeFlowTask?: (params: {
814
1005
  task_id: number | string;
815
1006
  resource_type: string;
816
1007
  resource_id: number | string;
817
1008
  permission_type: string;
818
- }) => Promise<any>;
1009
+ }) => Promise<ExecuteFlowTaskResult>;
819
1010
  revokeFlowTask?: (params: {
820
1011
  task_id: number | string;
821
1012
  resource_type: string;
@@ -835,14 +1026,16 @@ interface FlowEditApiConfig extends FlowViewApiConfig {
835
1026
  fetchTaskNodeLog?: (params: FetchTaskNodeLogParams) => Promise<unknown>;
836
1027
  getFlowTaskDetail?: (params: GetFlowTaskDetailParams) => Promise<FlowTaskDetail>;
837
1028
  }
1029
+ interface FlowDetailApiConfig extends FlowEditApiConfig, Partial<DebugApiServices> {
1030
+ }
838
1031
 
839
1032
  declare const PLUGIN_GROUP_ICON_MAP: Record<string, string>;
840
1033
 
841
1034
  /**
842
1035
  * 使用 Flow API 的 composable
843
- * 返回所有 API 方法,兼容 FlowEditApiConfig 接口
1036
+ * 返回所有 API 方法,兼容 FlowDetailApiConfig 接口(含调试 API)
844
1037
  */
845
- declare function useFlowApi(config: FlowApiConfig): FlowEditApiConfig;
1038
+ declare function useFlowApi(config: FlowApiConfig): FlowDetailApiConfig;
846
1039
 
847
1040
  export { PLUGIN_GROUP_ICON_MAP, useFlowApi };
848
- export type { CustomVariableType, EndEvent, Flow, FlowEditApiConfig, FlowListItem, FlowViewApiConfig, GatewayType, Line, Location, NodeConfigData, NodeType, NotifyConfig, PluginGroupConfig, PluginOutputItem, PortOrientation, StartEvent, TemplateConfigs, UniformApiPluginConfig, UniformApiPluginInputsItem, VariableRefRequestParams };
1041
+ export type { CustomVariableType, DebugApiServices, DebugContext, DebugContextNode, DebugContextStatus, DebugErrorDetail, DebugExecutionMode, DebugInputSchema, DebugMissingVar, DebugNodeStatus, DebugRunStatus, DebugRunType, EndEvent, Flow, FlowDetailApiConfig, FlowEditApiConfig, FlowListItem, FlowViewApiConfig, GatewayType, Line, Location, NodeConfigData, NodeType, NotifyConfig, PluginGroupConfig, PluginOutputItem, PortOrientation, StartEvent, TemplateConfigs, UniformApiPluginConfig, UniformApiPluginInputsItem, VariableRefRequestParams };
@@ -1,4 +1,4 @@
1
- import { P as s, u as _ } from "./composable-CmXOtkXh.js";
1
+ import { P as s, u as _ } from "./composable-Cf47ka9M.js";
2
2
  export {
3
3
  s as PLUGIN_GROUP_ICON_MAP,
4
4
  _ as useFlowApi