interface.ts


Overview

The interface.ts file is a TypeScript module that defines a set of interfaces and types representing data structures and contracts for form handling, node metadata, parameter generation, and input configurations within an application. These interfaces serve as strong typing aids, ensuring that components and modules interacting with certain data maintain consistent shape and behavior. The file primarily focuses on defining types related to operators, nodes, and query inputs, which are likely utilized in a UI context involving forms and flow nodes, particularly in conjunction with the Ant Design (antd) form system and a flow node model named RAGFlowNodeType.


Interfaces and Types

1. IOperatorForm

export interface IOperatorForm {
  onValuesChange?(changedValues: any, values: any): void;
  form?: FormInstance;
  node?: RAGFlowNodeType;
  nodeId?: string;
}

Purpose

Defines the contract for properties related to an operator form component or handler. This interface is intended to describe props or parameters for a form connected to a flow node.

Properties

Usage Example

const operatorFormProps: IOperatorForm = {
  onValuesChange: (changedValues, values) => {
    console.log('Form changed:', changedValues, values);
  },
  form: antdFormInstance,
  node: someFlowNode,
  nodeId: "node-123"
};

2. INextOperatorForm

export interface INextOperatorForm {
  node?: RAGFlowNodeType;
  nodeId?: string;
}

Purpose

A simplified interface that represents the next operator form's node information. This may be used when only node metadata is required without form-specific callbacks or instances.

Properties


3. IGenerateParameter

export interface IGenerateParameter {
  id?: string;
  key: string;
  component_id?: string;
}

Purpose

Represents parameters used for generating or identifying components or elements in the system. This interface contains basic identification keys and optional component references.

Properties


4. IInvokeVariable

export interface IInvokeVariable extends IGenerateParameter {
  value?: string;
}

Purpose

Extends IGenerateParameter to include an optional value property. This interface is likely used when a parameter needs to carry an assignable or mutable value, such as variables invoked during runtime or configuration.

Properties


5. IPosition

export type IPosition = { top: number; right: number; idx: number };

Purpose

Defines a positional data type used to represent coordinates or ordering in a UI or data structure.

Properties


6. BeginQuery

export interface BeginQuery {
  key: string;
  type: string;
  value: string;
  optional: boolean;
  name: string;
  options: (number | string | boolean)[];
}

Purpose

Models a query parameter or input field configuration used at the beginning of some process or form.

Properties


7. IInputs

export type IInputs = {
  avatar: string;
  title: string;
  inputs: Record<string, BeginQuery>;
  prologue: string;
  mode: string;
};

Purpose

Represents a structured input configuration, possibly for a form or UI widget. It groups metadata (avatar, title, prologue, mode) with a set of input queries.

Properties


Important Implementation Details


Interaction with Other Parts of the System


Mermaid Diagram: Class & Interface Structure

classDiagram
    class IOperatorForm {
        +onValuesChange?(changedValues: any, values: any): void
        +form?: FormInstance
        +node?: RAGFlowNodeType
        +nodeId?: string
    }

    class INextOperatorForm {
        +node?: RAGFlowNodeType
        +nodeId?: string
    }

    class IGenerateParameter {
        +id?: string
        +key: string
        +component_id?: string
    }

    class IInvokeVariable {
        +id?: string
        +key: string
        +component_id?: string
        +value?: string
    }

    class BeginQuery {
        +key: string
        +type: string
        +value: string
        +optional: boolean
        +name: string
        +options: (number | string | boolean)[]
    }

    class IInputs {
        +avatar: string
        +title: string
        +inputs: Record<string, BeginQuery>
        +prologue: string
        +mode: string
    }

    IInvokeVariable --|> IGenerateParameter : extends

Summary

The interface.ts file defines foundational TypeScript interfaces and types that standardize data structures related to operator forms, flow nodes, parameters, and dynamic input queries in the application. It enables consistent development of UI forms and flow interactions, leveraging Ant Design form instances and flow node metadata. This file acts as a core typing module that other components and modules rely on to function correctly with these data contracts.