From 77fc83725333bed5b1bcf2807eb5e2a30d2df538 Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Wed, 8 May 2024 09:10:06 -0700 Subject: [PATCH] Remove `public/` imports in `common/` (#147) (#148) ------ Signed-off-by: Tyler Ohlsen (cherry picked from commit 23f222c070e0306b204d2750adeb33fbe1b4ccae) Co-authored-by: Tyler Ohlsen --- common/constants.ts | 41 +++++++++ common/index.ts | 3 - common/interfaces.ts | 87 +++++++++++++++++- public/component_types/base_component.tsx | 5 +- public/component_types/index.ts | 1 - public/component_types/indexer/indexer.ts | 2 +- public/component_types/interfaces.ts | 91 ------------------- public/component_types/other/document.tsx | 2 +- .../other/query/match_query.tsx | 2 +- .../other/query/neural_query.tsx | 2 +- public/component_types/other/query/query.tsx | 2 +- public/component_types/other/results.tsx | 2 +- .../transformer/base_transformer.ts | 2 +- .../transformer/ml_transformer.ts | 2 +- .../transformer/normalization_transformer.ts | 2 +- .../transformer/results_transformer.ts | 2 +- .../input_fields/model_field.tsx | 2 +- .../input_fields/select_field.tsx | 9 +- .../input_fields/text_field.tsx | 7 +- .../workflow_detail/prototype/ingestor.tsx | 5 +- .../prototype/query_executor.tsx | 5 +- .../utils/data_extractor_utils.ts | 3 +- .../utils/workflow_to_template_utils.ts | 3 +- .../workspace/resizable_workspace.tsx | 10 +- .../pages/workflows/new_workflow/use_case.tsx | 3 +- public/pages/workflows/new_workflow/utils.ts | 11 ++- public/pages/workflows/workflows.tsx | 2 +- public/utils/constants.ts | 43 --------- 28 files changed, 165 insertions(+), 186 deletions(-) delete mode 100644 public/component_types/interfaces.ts diff --git a/common/constants.ts b/common/constants.ts index 762436fe..29fe1f95 100644 --- a/common/constants.ts +++ b/common/constants.ts @@ -119,6 +119,47 @@ export const NEURAL_SPARSE_TOKENIZER_TRANSFORMER = { version: '1.0.1', } as PretrainedSparseEncodingModel; +/** + * Various constants pertaining to the drag-and-drop UI components + */ +export enum COMPONENT_CATEGORY { + INGEST = 'Ingest', + SEARCH = 'Search', +} + +export enum NODE_CATEGORY { + CUSTOM = 'custom', + INGEST_GROUP = 'ingestGroup', + SEARCH_GROUP = 'searchGroup', +} + +/** + * A base set of component classes / types. + */ +export enum COMPONENT_CLASS { + // Indexer-related classes + INDEXER = 'indexer', + KNN_INDEXER = 'knn_indexer', + // Retriever-related classes + RETRIEVER = 'retriever', + // Transformer-related classes + TRANSFORMER = 'transformer', + JSON_TO_JSON_TRANSFORMER = 'json_to_json_transformer', + ML_TRANSFORMER = 'ml_transformer', + TEXT_EMBEDDING_TRANSFORMER = 'text_embedding_transformer', + SPARSE_ENCODER_TRANSFORMER = 'sparse_encoder_transformer', + RESULTS_TRANSFORMER = 'results_transformer', + NORMALIZATION_TRANSFORMER = 'normalization_transformer', + // Query-related classes + QUERY = 'query', + MATCH_QUERY = 'match_query', + NEURAL_QUERY = 'neural_query', + // Document-related classes + DOCUMENT = 'document', + // Results-related classes + RESULTS = 'results', +} + /** * MISCELLANEOUS */ diff --git a/common/index.ts b/common/index.ts index 78615eb2..60c81c4e 100644 --- a/common/index.ts +++ b/common/index.ts @@ -6,6 +6,3 @@ export * from './constants'; export * from './interfaces'; export * from './utils'; -export * from '../public/component_types'; -export * from '../public/utils'; -export * from '../public/pages/workflow_detail/utils'; diff --git a/common/interfaces.ts b/common/interfaces.ts index e5bd4080..39952e6c 100644 --- a/common/interfaces.ts +++ b/common/interfaces.ts @@ -4,8 +4,9 @@ */ import { Node, Edge } from 'reactflow'; -import { IComponentData } from '../public/component_types'; -import { COMPONENT_CLASS } from '../public/utils'; +import { FormikValues } from 'formik'; +import { ObjectSchema } from 'yup'; +import { COMPONENT_CLASS, COMPONENT_CATEGORY } from './constants'; export type Index = { name: string; @@ -13,9 +14,89 @@ export type Index = { }; /** - ********** REACTFLOW TYPES/INTERFACES ********** + ********** WORKSPACE TYPES/INTERFACES ********** */ +export type FieldType = 'string' | 'json' | 'select' | 'model'; +export type SelectType = 'model'; +export type FieldValue = string | {}; +export type ComponentFormValues = FormikValues; +export type WorkspaceFormValues = { + [componentId: string]: ComponentFormValues; +}; +export type WorkspaceSchemaObj = { + [componentId: string]: ObjectSchema; +}; +export type WorkspaceSchema = ObjectSchema; + +/** + * Represents a single base class as an input handle for a component. + * It may accept multiples of that class. + */ +export interface IComponentInput { + id: string; + label: string; + baseClass: COMPONENT_CLASS; + acceptMultiple: boolean; +} + +/** + * An input field for a component. Specifies enough configuration for the + * UI node to render it properly (help text, links, etc.) + */ +export interface IComponentField { + label: string; + type: FieldType; + id: string; + value?: FieldValue; + placeholder?: string; + helpText?: string; + helpLink?: string; + selectType?: SelectType; +} + +/** + * Represents the list of base classes as a single output handle for + * a component. + */ +export interface IComponentOutput { + label: string; + baseClasses: COMPONENT_CLASS[]; +} + +/** + * The base interface the components will implement. + */ +export interface IComponent { + type: COMPONENT_CLASS; + label: string; + description: string; + // will be used for grouping together in the drag-and-drop component library + // and determining which flows the component can be drug into the workspace flows + categories: COMPONENT_CATEGORY[]; + // determines if this component allows for new creation. this means to + // allow a "create" option on the UI component, as well as potentially + // include in the use case template construction ('provisioning' flow) + allowsCreation: boolean; + // the list of base classes that will be used in the component output + baseClasses?: COMPONENT_CLASS[]; + inputs?: IComponentInput[]; + fields?: IComponentField[]; + // if the component supports creation, we will have a different set of input fields + // the user needs to fill out + createFields?: IComponentField[]; + outputs?: IComponentOutput[]; +} + +/** + * We need to include some extra instance-specific data to the ReactFlow component + * to perform extra functionality, such as deleting the node from the ReactFlowInstance. + */ +export interface IComponentData extends IComponent { + id: string; + selected?: boolean; +} + export type ReactFlowComponent = Node; export type ReactFlowEdge = Edge<{}> & { key: string; diff --git a/public/component_types/base_component.tsx b/public/component_types/base_component.tsx index d4540d76..df75e682 100644 --- a/public/component_types/base_component.tsx +++ b/public/component_types/base_component.tsx @@ -3,13 +3,14 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { COMPONENT_CATEGORY, COMPONENT_CLASS } from '../utils'; import { + COMPONENT_CATEGORY, + COMPONENT_CLASS, IComponent, IComponentField, IComponentInput, IComponentOutput, -} from './interfaces'; +} from '../../common'; /** * A base UI drag-and-drop component class. diff --git a/public/component_types/index.ts b/public/component_types/index.ts index e713518e..ebdc369f 100644 --- a/public/component_types/index.ts +++ b/public/component_types/index.ts @@ -3,7 +3,6 @@ * SPDX-License-Identifier: Apache-2.0 */ -export * from './interfaces'; export * from './transformer'; export * from './indexer'; export * from './other'; diff --git a/public/component_types/indexer/indexer.ts b/public/component_types/indexer/indexer.ts index c3323a23..f23ccc5f 100644 --- a/public/component_types/indexer/indexer.ts +++ b/public/component_types/indexer/indexer.ts @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { COMPONENT_CATEGORY, COMPONENT_CLASS } from '../../utils'; +import { COMPONENT_CATEGORY, COMPONENT_CLASS } from '../../../common'; import { BaseComponent } from '../base_component'; /** diff --git a/public/component_types/interfaces.ts b/public/component_types/interfaces.ts deleted file mode 100644 index 055f44ff..00000000 --- a/public/component_types/interfaces.ts +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { FormikValues } from 'formik'; -import { ObjectSchema } from 'yup'; -import { COMPONENT_CATEGORY, COMPONENT_CLASS } from '../utils'; - -/** - * ************ Types ************************* - */ -export type FieldType = 'string' | 'json' | 'select' | 'model'; -export type SelectType = 'model'; -export type FieldValue = string | {}; -export type ComponentFormValues = FormikValues; -export type WorkspaceFormValues = { - [componentId: string]: ComponentFormValues; -}; -export type WorkspaceSchemaObj = { - [componentId: string]: ObjectSchema; -}; -export type WorkspaceSchema = ObjectSchema; - -/** - * Represents a single base class as an input handle for a component. - * It may accept multiples of that class. - */ -export interface IComponentInput { - id: string; - label: string; - baseClass: COMPONENT_CLASS; - acceptMultiple: boolean; -} - -/** - * An input field for a component. Specifies enough configuration for the - * UI node to render it properly (help text, links, etc.) - */ -export interface IComponentField { - label: string; - type: FieldType; - id: string; - value?: FieldValue; - placeholder?: string; - helpText?: string; - helpLink?: string; - selectType?: SelectType; -} - -/** - * Represents the list of base classes as a single output handle for - * a component. - */ -export interface IComponentOutput { - label: string; - baseClasses: COMPONENT_CLASS[]; -} - -/** - * The base interface the components will implement. - */ -export interface IComponent { - type: COMPONENT_CLASS; - label: string; - description: string; - // will be used for grouping together in the drag-and-drop component library - // and determining which flows the component can be drug into the workspace flows - categories: COMPONENT_CATEGORY[]; - // determines if this component allows for new creation. this means to - // allow a "create" option on the UI component, as well as potentially - // include in the use case template construction ('provisioning' flow) - allowsCreation: boolean; - // the list of base classes that will be used in the component output - baseClasses?: COMPONENT_CLASS[]; - inputs?: IComponentInput[]; - fields?: IComponentField[]; - // if the component supports creation, we will have a different set of input fields - // the user needs to fill out - createFields?: IComponentField[]; - outputs?: IComponentOutput[]; -} - -/** - * We need to include some extra instance-specific data to the ReactFlow component - * to perform extra functionality, such as deleting the node from the ReactFlowInstance. - */ -export interface IComponentData extends IComponent { - id: string; - selected?: boolean; -} diff --git a/public/component_types/other/document.tsx b/public/component_types/other/document.tsx index 2552b8d2..e1cda879 100644 --- a/public/component_types/other/document.tsx +++ b/public/component_types/other/document.tsx @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { COMPONENT_CATEGORY, COMPONENT_CLASS } from '../../utils'; +import { COMPONENT_CATEGORY, COMPONENT_CLASS } from '../../../common'; import { BaseComponent } from '../base_component'; /** diff --git a/public/component_types/other/query/match_query.tsx b/public/component_types/other/query/match_query.tsx index 4bd08098..1cb60984 100644 --- a/public/component_types/other/query/match_query.tsx +++ b/public/component_types/other/query/match_query.tsx @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { COMPONENT_CLASS } from '../../../utils'; +import { COMPONENT_CLASS } from '../../../../common'; import { Query } from './query'; /** diff --git a/public/component_types/other/query/neural_query.tsx b/public/component_types/other/query/neural_query.tsx index 57ea301c..51fabb28 100644 --- a/public/component_types/other/query/neural_query.tsx +++ b/public/component_types/other/query/neural_query.tsx @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { COMPONENT_CLASS } from '../../../utils'; +import { COMPONENT_CLASS } from '../../../../common'; import { Query } from './query'; /** diff --git a/public/component_types/other/query/query.tsx b/public/component_types/other/query/query.tsx index 24611979..f347218e 100644 --- a/public/component_types/other/query/query.tsx +++ b/public/component_types/other/query/query.tsx @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { COMPONENT_CATEGORY, COMPONENT_CLASS } from '../../../utils'; +import { COMPONENT_CATEGORY, COMPONENT_CLASS } from '../../../../common'; import { BaseComponent } from '../../base_component'; /** diff --git a/public/component_types/other/results.tsx b/public/component_types/other/results.tsx index 972a8b88..9c6ad3fb 100644 --- a/public/component_types/other/results.tsx +++ b/public/component_types/other/results.tsx @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { COMPONENT_CATEGORY, COMPONENT_CLASS } from '../../utils'; +import { COMPONENT_CATEGORY, COMPONENT_CLASS } from '../../../common'; import { BaseComponent } from '../base_component'; /** diff --git a/public/component_types/transformer/base_transformer.ts b/public/component_types/transformer/base_transformer.ts index c46ee89c..fe372ad1 100644 --- a/public/component_types/transformer/base_transformer.ts +++ b/public/component_types/transformer/base_transformer.ts @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { COMPONENT_CATEGORY, COMPONENT_CLASS } from '../../utils'; +import { COMPONENT_CATEGORY, COMPONENT_CLASS } from '../../../common'; import { BaseComponent } from '../base_component'; /** diff --git a/public/component_types/transformer/ml_transformer.ts b/public/component_types/transformer/ml_transformer.ts index 09a51fba..0cb29d7c 100644 --- a/public/component_types/transformer/ml_transformer.ts +++ b/public/component_types/transformer/ml_transformer.ts @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { COMPONENT_CLASS } from '../../utils'; +import { COMPONENT_CLASS } from '../../../common'; import { BaseTransformer } from './base_transformer'; /** diff --git a/public/component_types/transformer/normalization_transformer.ts b/public/component_types/transformer/normalization_transformer.ts index d04cff1f..01026f64 100644 --- a/public/component_types/transformer/normalization_transformer.ts +++ b/public/component_types/transformer/normalization_transformer.ts @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { COMPONENT_CATEGORY, COMPONENT_CLASS } from '../../utils'; +import { COMPONENT_CATEGORY, COMPONENT_CLASS } from '../../../common'; import { ResultsTransformer } from './results_transformer'; /** diff --git a/public/component_types/transformer/results_transformer.ts b/public/component_types/transformer/results_transformer.ts index 8908bb13..7d92ef00 100644 --- a/public/component_types/transformer/results_transformer.ts +++ b/public/component_types/transformer/results_transformer.ts @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { COMPONENT_CLASS } from '../../utils'; +import { COMPONENT_CLASS } from '../../../common'; import { BaseTransformer } from './base_transformer'; /** diff --git a/public/pages/workflow_detail/component_details/input_fields/model_field.tsx b/public/pages/workflow_detail/component_details/input_fields/model_field.tsx index d3a0eee1..1da7aa05 100644 --- a/public/pages/workflow_detail/component_details/input_fields/model_field.tsx +++ b/public/pages/workflow_detail/component_details/input_fields/model_field.tsx @@ -22,7 +22,6 @@ import { MODEL_STATE, ROBERTA_SENTENCE_TRANSFORMER, WorkspaceFormValues, - isFieldInvalid, ModelFormValue, MODEL_CATEGORY, MPNET_SENTENCE_TRANSFORMER, @@ -30,6 +29,7 @@ import { NEURAL_SPARSE_DOC_TRANSFORMER, NEURAL_SPARSE_TOKENIZER_TRANSFORMER, } from '../../../../../common'; +import { isFieldInvalid } from '../../../../utils'; import { AppState } from '../../../../store'; interface ModelFieldProps { diff --git a/public/pages/workflow_detail/component_details/input_fields/select_field.tsx b/public/pages/workflow_detail/component_details/input_fields/select_field.tsx index 38017e04..9687989d 100644 --- a/public/pages/workflow_detail/component_details/input_fields/select_field.tsx +++ b/public/pages/workflow_detail/component_details/input_fields/select_field.tsx @@ -4,7 +4,6 @@ */ import React, { useEffect, useState } from 'react'; -import { useSelector } from 'react-redux'; import { Field, FieldProps, useFormikContext } from 'formik'; import { EuiFormRow, @@ -13,12 +12,8 @@ import { EuiSuperSelectOption, EuiText, } from '@elastic/eui'; -import { - IComponentField, - WorkspaceFormValues, - getInitialValue, - isFieldInvalid, -} from '../../../../../common'; +import { IComponentField, WorkspaceFormValues } from '../../../../../common'; +import { getInitialValue, isFieldInvalid } from '../../../../utils'; interface SelectFieldProps { field: IComponentField; diff --git a/public/pages/workflow_detail/component_details/input_fields/text_field.tsx b/public/pages/workflow_detail/component_details/input_fields/text_field.tsx index 4c3e5dec..038051f1 100644 --- a/public/pages/workflow_detail/component_details/input_fields/text_field.tsx +++ b/public/pages/workflow_detail/component_details/input_fields/text_field.tsx @@ -6,13 +6,12 @@ import React from 'react'; import { Field, FieldProps, useFormikContext } from 'formik'; import { EuiFieldText, EuiFormRow, EuiLink, EuiText } from '@elastic/eui'; +import { IComponentField, WorkspaceFormValues } from '../../../../../common'; import { - IComponentField, - WorkspaceFormValues, - getFieldError, getInitialValue, isFieldInvalid, -} from '../../../../../common'; + getFieldError, +} from '../../../../utils'; interface TextFieldProps { field: IComponentField; diff --git a/public/pages/workflow_detail/prototype/ingestor.tsx b/public/pages/workflow_detail/prototype/ingestor.tsx index 8cfcfec4..a907a88b 100644 --- a/public/pages/workflow_detail/prototype/ingestor.tsx +++ b/public/pages/workflow_detail/prototype/ingestor.tsx @@ -12,12 +12,11 @@ import { EuiFlexItem, EuiText, } from '@elastic/eui'; +import { USE_CASE, Workflow } from '../../../../common'; import { - USE_CASE, - Workflow, getIndexName, getNeuralSearchValues, -} from '../../../../common'; +} from '../utils/data_extractor_utils'; import { ingest, useAppDispatch } from '../../../store'; import { getCore } from '../../../services'; import { diff --git a/public/pages/workflow_detail/prototype/query_executor.tsx b/public/pages/workflow_detail/prototype/query_executor.tsx index cc5f6d68..6ee80421 100644 --- a/public/pages/workflow_detail/prototype/query_executor.tsx +++ b/public/pages/workflow_detail/prototype/query_executor.tsx @@ -12,12 +12,11 @@ import { EuiFlexItem, EuiText, } from '@elastic/eui'; +import { USE_CASE, Workflow } from '../../../../common'; import { - USE_CASE, - Workflow, getIndexName, getNeuralSearchValues, -} from '../../../../common'; +} from '../utils/data_extractor_utils'; import { searchIndex, useAppDispatch } from '../../../store'; import { getCore } from '../../../services'; import { diff --git a/public/pages/workflow_detail/utils/data_extractor_utils.ts b/public/pages/workflow_detail/utils/data_extractor_utils.ts index be03b207..596c0ffb 100644 --- a/public/pages/workflow_detail/utils/data_extractor_utils.ts +++ b/public/pages/workflow_detail/utils/data_extractor_utils.ts @@ -6,17 +6,16 @@ import { ReactFlowComponent, COMPONENT_CLASS, - componentDataToFormik, ModelFormValue, MODEL_CATEGORY, WorkspaceFormValues, Workflow, WORKFLOW_RESOURCE_TYPE, - WorkflowResource, NODE_CATEGORY, WORKFLOW_STEP_TYPE, } from '../../../../common'; import { getNodesAndEdgesUnderParent } from './workflow_to_template_utils'; +import { componentDataToFormik } from '../../../utils'; /** * Collection of utility fns to extract diff --git a/public/pages/workflow_detail/utils/workflow_to_template_utils.ts b/public/pages/workflow_detail/utils/workflow_to_template_utils.ts index ce356a3d..098cabcc 100644 --- a/public/pages/workflow_detail/utils/workflow_to_template_utils.ts +++ b/public/pages/workflow_detail/utils/workflow_to_template_utils.ts @@ -13,7 +13,6 @@ import { COMPONENT_CLASS, CreateIngestPipelineNode, TextEmbeddingProcessor, - componentDataToFormik, ReactFlowEdge, CreateIndexNode, TemplateFlow, @@ -25,7 +24,6 @@ import { ROBERTA_SENTENCE_TRANSFORMER, MPNET_SENTENCE_TRANSFORMER, BERT_SENTENCE_TRANSFORMER, - generateId, NEURAL_SPARSE_TRANSFORMER, NEURAL_SPARSE_DOC_TRANSFORMER, NEURAL_SPARSE_TOKENIZER_TRANSFORMER, @@ -34,6 +32,7 @@ import { CreateSearchPipelineNode, WORKFLOW_STEP_TYPE, } from '../../../../common'; +import { componentDataToFormik, generateId } from '../../../utils'; /** * Given a ReactFlow workspace flow with fully populated input values, diff --git a/public/pages/workflow_detail/workspace/resizable_workspace.tsx b/public/pages/workflow_detail/workspace/resizable_workspace.tsx index e304dc76..10641a4a 100644 --- a/public/pages/workflow_detail/workspace/resizable_workspace.tsx +++ b/public/pages/workflow_detail/workspace/resizable_workspace.tsx @@ -26,15 +26,17 @@ import { WorkspaceSchema, ReactFlowComponent, WorkspaceSchemaObj, - componentDataToFormik, - getComponentSchema, WorkspaceFlowState, WORKFLOW_STATE, + ReactFlowEdge, +} from '../../../../common'; +import { + componentDataToFormik, + getComponentSchema, processNodes, reduceToTemplate, - ReactFlowEdge, APP_PATH, -} from '../../../../common'; +} from '../../../utils'; import { validateWorkspaceFlow, toTemplateFlows } from '../utils'; import { AppState, diff --git a/public/pages/workflows/new_workflow/use_case.tsx b/public/pages/workflows/new_workflow/use_case.tsx index a6eceacf..aafaadac 100644 --- a/public/pages/workflows/new_workflow/use_case.tsx +++ b/public/pages/workflows/new_workflow/use_case.tsx @@ -13,7 +13,8 @@ import { EuiHorizontalRule, EuiButton, } from '@elastic/eui'; -import { APP_PATH, NEW_WORKFLOW_ID_URL, PLUGIN_ID } from '../../../../common'; +import { NEW_WORKFLOW_ID_URL, PLUGIN_ID } from '../../../../common'; +import { APP_PATH } from '../../../utils'; interface UseCaseProps { title: string; diff --git a/public/pages/workflows/new_workflow/utils.ts b/public/pages/workflows/new_workflow/utils.ts index 9fd7deb4..320a09f2 100644 --- a/public/pages/workflows/new_workflow/utils.ts +++ b/public/pages/workflows/new_workflow/utils.ts @@ -7,10 +7,6 @@ import { MarkerType } from 'reactflow'; import { WorkspaceFlowState, ReactFlowComponent, - initComponentData, - TextEmbeddingTransformer, - KnnIndexer, - generateId, ReactFlowEdge, COMPONENT_CATEGORY, NODE_CATEGORY, @@ -19,12 +15,17 @@ import { COMPONENT_CLASS, START_FROM_SCRATCH_WORKFLOW_NAME, DEFAULT_NEW_WORKFLOW_NAME, +} from '../../../../common'; +import { initComponentData, generateId } from '../../../utils'; +import { + TextEmbeddingTransformer, + KnnIndexer, Document, SparseEncoderTransformer, NeuralQuery, MatchQuery, NormalizationTransformer, -} from '../../../../common'; +} from '../../../component_types'; // Fn to produce the complete preset template with all necessary UI metadata. // Some UI metadata we want to generate on-the-fly using our component classes we have on client-side. diff --git a/public/pages/workflows/workflows.tsx b/public/pages/workflows/workflows.tsx index 90ae6d92..d4c27e1e 100644 --- a/public/pages/workflows/workflows.tsx +++ b/public/pages/workflows/workflows.tsx @@ -137,7 +137,7 @@ export function Workflows(props: WorkflowsProps) { {selectedTabId === WORKFLOWS_TAB.MANAGE && } {selectedTabId === WORKFLOWS_TAB.CREATE && } {selectedTabId === WORKFLOWS_TAB.MANAGE && - Object.values(workflows).length === 0 && + Object.keys(workflows || {}).length === 0 && !loading && ( { diff --git a/public/utils/constants.ts b/public/utils/constants.ts index a248b33d..45647716 100644 --- a/public/utils/constants.ts +++ b/public/utils/constants.ts @@ -18,46 +18,3 @@ export const BREADCRUMBS = Object.freeze({ FLOW_FRAMEWORK: { text: 'Flow Framework' }, WORKFLOWS: { text: 'Workflows', href: `#${APP_PATH.WORKFLOWS}` }, }); - -/** - * The static set of available categories that can be used to organize - * the component library. Sets guardrails on what components can be - * drag-and-dropped into the ingest and/or search flows. - */ -export enum COMPONENT_CATEGORY { - INGEST = 'Ingest', - SEARCH = 'Search', -} - -export enum NODE_CATEGORY { - CUSTOM = 'custom', - INGEST_GROUP = 'ingestGroup', - SEARCH_GROUP = 'searchGroup', -} - -/** - * A base set of component classes / types. - */ -export enum COMPONENT_CLASS { - // Indexer-related classes - INDEXER = 'indexer', - KNN_INDEXER = 'knn_indexer', - // Retriever-related classes - RETRIEVER = 'retriever', - // Transformer-related classes - TRANSFORMER = 'transformer', - JSON_TO_JSON_TRANSFORMER = 'json_to_json_transformer', - ML_TRANSFORMER = 'ml_transformer', - TEXT_EMBEDDING_TRANSFORMER = 'text_embedding_transformer', - SPARSE_ENCODER_TRANSFORMER = 'sparse_encoder_transformer', - RESULTS_TRANSFORMER = 'results_transformer', - NORMALIZATION_TRANSFORMER = 'normalization_transformer', - // Query-related classes - QUERY = 'query', - MATCH_QUERY = 'match_query', - NEURAL_QUERY = 'neural_query', - // Document-related classes - DOCUMENT = 'document', - // Results-related classes - RESULTS = 'results', -}