forked from opensearch-project/dashboards-flow-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterfaces.ts
177 lines (150 loc) · 3.83 KB
/
interfaces.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
import { Node, Edge } from 'reactflow';
import { IComponentData } from '../public/component_types';
export type Index = {
name: string;
health: 'green' | 'yellow' | 'red';
};
/**
********** REACTFLOW TYPES/INTERFACES **********
*/
export type ReactFlowComponent = Node<IComponentData>;
export type ReactFlowEdge = Edge<{}> & {};
type ReactFlowViewport = {
x: number;
y: number;
zoom: number;
};
export type UIState = {
workspace_flow: WorkspaceFlowState;
};
export type WorkspaceFlowState = {
nodes: ReactFlowComponent[];
edges: ReactFlowEdge[];
viewport?: ReactFlowViewport;
};
/**
********** USE CASE TEMPLATE TYPES/INTERFACES **********
*/
export type IngestProcessor = {
description?: string;
};
export type TextEmbeddingProcessor = IngestProcessor & {
text_embedding: {
model_id: string;
field_map: {};
};
};
export type TemplateNode = {
id: string;
type: string;
previous_node_inputs?: {};
user_inputs?: {};
};
export type CreateIngestPipelineNode = TemplateNode & {
user_inputs: {
pipeline_id: string;
model_id?: string;
input_field?: string;
output_field?: string;
configurations: {
description?: string;
processors: IngestProcessor[];
};
};
};
export type CreateIndexNode = TemplateNode & {
previous_node_inputs?: {
[ingest_pipeline_step_id: string]: string;
};
user_inputs: {
index_name: string;
configurations: {
settings: {};
mappings: {};
};
};
};
export type TemplateEdge = {
source: string;
dest: string;
};
export type TemplateFlow = {
nodes: TemplateNode[];
edges?: TemplateEdge[];
};
export type TemplateFlows = {
provision: TemplateFlow;
};
// A stateless template of a workflow
export type WorkflowTemplate = {
name: string;
description: string;
use_case: USE_CASE;
// TODO: finalize on version type when that is implemented
// https://github.com/opensearch-project/flow-framework/issues/526
version: any;
workflows: TemplateFlows;
// UI state and any ReactFlow state may not exist if a workflow is created via API/backend-only.
ui_metadata?: UIState;
};
// An instance of a workflow based on a workflow template
export type Workflow = WorkflowTemplate & {
// won't exist until created in backend
id?: string;
// won't exist until created in backend
lastUpdated?: number;
// won't exist until launched/provisioned in backend
lastLaunched?: number;
// won't exist until launched/provisioned in backend
state?: WORKFLOW_STATE;
// won't exist until launched/provisioned in backend
resourcesCreated?: WorkflowResource[];
};
export enum USE_CASE {
SEMANTIC_SEARCH = 'SEMANTIC_SEARCH',
}
/**
********** ML PLUGIN TYPES/INTERFACES **********
*/
export type Model = {
id: string;
algorithm: string;
};
/**
********** MISC TYPES/INTERFACES ************
*/
// TODO: finalize how we have the launch data model
export type WorkflowLaunch = {
id: string;
state: WORKFLOW_STATE;
lastUpdated: number;
};
// Based off of https://github.com/opensearch-project/flow-framework/blob/main/src/main/java/org/opensearch/flowframework/model/State.java
export enum WORKFLOW_STATE {
NOT_STARTED = 'Not started',
PROVISIONING = 'Provisioning',
FAILED = 'Failed',
COMPLETED = 'Completed',
}
export type WorkflowResource = {
id: string;
type: WORKFLOW_RESOURCE_TYPE;
};
// Based off of https://github.com/opensearch-project/flow-framework/blob/main/src/main/java/org/opensearch/flowframework/common/WorkflowResources.java
export enum WORKFLOW_RESOURCE_TYPE {
PIPELINE_ID = 'Ingest pipeline',
INDEX_NAME = 'Index',
MODEL_ID = 'Model',
MODEL_GROUP_ID = 'Model group',
CONNECTOR_ID = 'Connector',
}
export type WorkflowDict = {
[workflowId: string]: Workflow;
};
export type ModelDict = {
[modelId: string]: Model;
};