mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(ui): organize node utils
This commit is contained in:
@ -10,8 +10,8 @@ import { blobToDataURL } from 'features/canvas/util/blobToDataURL';
|
|||||||
import { getCanvasData } from 'features/canvas/util/getCanvasData';
|
import { getCanvasData } from 'features/canvas/util/getCanvasData';
|
||||||
import { getCanvasGenerationMode } from 'features/canvas/util/getCanvasGenerationMode';
|
import { getCanvasGenerationMode } from 'features/canvas/util/getCanvasGenerationMode';
|
||||||
import { canvasGraphBuilt } from 'features/nodes/store/actions';
|
import { canvasGraphBuilt } from 'features/nodes/store/actions';
|
||||||
import { buildCanvasGraph } from 'features/nodes/util/graphBuilders/buildCanvasGraph';
|
import { buildCanvasGraph } from 'features/nodes/util/graph/buildCanvasGraph';
|
||||||
import { prepareLinearUIBatch } from 'features/nodes/util/graphBuilders/buildLinearBatchConfig';
|
import { prepareLinearUIBatch } from 'features/nodes/util/graph/buildLinearBatchConfig';
|
||||||
import { imagesApi } from 'services/api/endpoints/images';
|
import { imagesApi } from 'services/api/endpoints/images';
|
||||||
import { queueApi } from 'services/api/endpoints/queue';
|
import { queueApi } from 'services/api/endpoints/queue';
|
||||||
import { ImageDTO } from 'services/api/types';
|
import { ImageDTO } from 'services/api/types';
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import { enqueueRequested } from 'app/store/actions';
|
import { enqueueRequested } from 'app/store/actions';
|
||||||
import { prepareLinearUIBatch } from 'features/nodes/util/graphBuilders/buildLinearBatchConfig';
|
import { prepareLinearUIBatch } from 'features/nodes/util/graph/buildLinearBatchConfig';
|
||||||
import { buildLinearImageToImageGraph } from 'features/nodes/util/graphBuilders/buildLinearImageToImageGraph';
|
import { buildLinearImageToImageGraph } from 'features/nodes/util/graph/buildLinearImageToImageGraph';
|
||||||
import { buildLinearSDXLImageToImageGraph } from 'features/nodes/util/graphBuilders/buildLinearSDXLImageToImageGraph';
|
import { buildLinearSDXLImageToImageGraph } from 'features/nodes/util/graph/buildLinearSDXLImageToImageGraph';
|
||||||
import { buildLinearSDXLTextToImageGraph } from 'features/nodes/util/graphBuilders/buildLinearSDXLTextToImageGraph';
|
import { buildLinearSDXLTextToImageGraph } from 'features/nodes/util/graph/buildLinearSDXLTextToImageGraph';
|
||||||
import { buildLinearTextToImageGraph } from 'features/nodes/util/graphBuilders/buildLinearTextToImageGraph';
|
import { buildLinearTextToImageGraph } from 'features/nodes/util/graph/buildLinearTextToImageGraph';
|
||||||
import { queueApi } from 'services/api/endpoints/queue';
|
import { queueApi } from 'services/api/endpoints/queue';
|
||||||
import { startAppListening } from '..';
|
import { startAppListening } from '..';
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { enqueueRequested } from 'app/store/actions';
|
import { enqueueRequested } from 'app/store/actions';
|
||||||
import { buildNodesGraph } from 'features/nodes/util/graphBuilders/buildNodesGraph';
|
import { buildNodesGraph } from 'features/nodes/util/graph/buildNodesGraph';
|
||||||
import { queueApi } from 'services/api/endpoints/queue';
|
import { queueApi } from 'services/api/endpoints/queue';
|
||||||
import { BatchConfig } from 'services/api/types';
|
import { BatchConfig } from 'services/api/types';
|
||||||
import { startAppListening } from '..';
|
import { startAppListening } from '..';
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { logger } from 'app/logging/logger';
|
import { logger } from 'app/logging/logger';
|
||||||
import { parseify } from 'common/util/serialize';
|
import { parseify } from 'common/util/serialize';
|
||||||
import { nodeTemplatesBuilt } from 'features/nodes/store/nodesSlice';
|
import { nodeTemplatesBuilt } from 'features/nodes/store/nodesSlice';
|
||||||
import { parseSchema } from 'features/nodes/util/parseSchema';
|
import { parseSchema } from 'features/nodes/util/schema/parseSchema';
|
||||||
import { size } from 'lodash-es';
|
import { size } from 'lodash-es';
|
||||||
import { receivedOpenAPISchema } from 'services/api/thunks/schema';
|
import { receivedOpenAPISchema } from 'services/api/thunks/schema';
|
||||||
import { startAppListening } from '..';
|
import { startAppListening } from '..';
|
||||||
|
@ -10,7 +10,7 @@ import { IMAGE_CATEGORIES } from 'features/gallery/store/types';
|
|||||||
import {
|
import {
|
||||||
LINEAR_UI_OUTPUT,
|
LINEAR_UI_OUTPUT,
|
||||||
nodeIDDenyList,
|
nodeIDDenyList,
|
||||||
} from 'features/nodes/util/graphBuilders/constants';
|
} from 'features/nodes/util/graph/constants';
|
||||||
import { boardsApi } from 'services/api/endpoints/boards';
|
import { boardsApi } from 'services/api/endpoints/boards';
|
||||||
import { imagesApi } from 'services/api/endpoints/images';
|
import { imagesApi } from 'services/api/endpoints/images';
|
||||||
import { imagesAdapter } from 'services/api/util';
|
import { imagesAdapter } from 'services/api/util';
|
||||||
|
@ -4,7 +4,7 @@ import { nodeReplaced } from 'features/nodes/store/nodesSlice';
|
|||||||
import {
|
import {
|
||||||
getNeedsUpdate,
|
getNeedsUpdate,
|
||||||
updateNode,
|
updateNode,
|
||||||
} from 'features/nodes/store/util/nodeUpdate';
|
} from 'features/nodes/util/node/nodeUpdate';
|
||||||
import { NodeUpdateError } from 'features/nodes/types/error';
|
import { NodeUpdateError } from 'features/nodes/types/error';
|
||||||
import { isInvocationNode } from 'features/nodes/types/invocation';
|
import { isInvocationNode } from 'features/nodes/types/invocation';
|
||||||
import { addToast } from 'features/system/store/systemSlice';
|
import { addToast } from 'features/system/store/systemSlice';
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { createAction } from '@reduxjs/toolkit';
|
import { createAction } from '@reduxjs/toolkit';
|
||||||
import { logger } from 'app/logging/logger';
|
import { logger } from 'app/logging/logger';
|
||||||
import { parseify } from 'common/util/serialize';
|
import { parseify } from 'common/util/serialize';
|
||||||
import { buildAdHocUpscaleGraph } from 'features/nodes/util/graphBuilders/buildAdHocUpscaleGraph';
|
import { buildAdHocUpscaleGraph } from 'features/nodes/util/graph/buildAdHocUpscaleGraph';
|
||||||
import { addToast } from 'features/system/store/systemSlice';
|
import { addToast } from 'features/system/store/systemSlice';
|
||||||
import { t } from 'i18next';
|
import { t } from 'i18next';
|
||||||
import { queueApi } from 'services/api/endpoints/queue';
|
import { queueApi } from 'services/api/endpoints/queue';
|
||||||
|
@ -4,7 +4,7 @@ import { workflowLoadRequested } from 'features/nodes/store/actions';
|
|||||||
import { workflowLoaded } from 'features/nodes/store/nodesSlice';
|
import { workflowLoaded } from 'features/nodes/store/nodesSlice';
|
||||||
import { $flow } from 'features/nodes/store/reactFlowInstance';
|
import { $flow } from 'features/nodes/store/reactFlowInstance';
|
||||||
import { WorkflowVersionError } from 'features/nodes/types/error';
|
import { WorkflowVersionError } from 'features/nodes/types/error';
|
||||||
import { validateWorkflow } from 'features/nodes/util/validateWorkflow';
|
import { validateWorkflow } from 'features/nodes/util/workflow/validateWorkflow';
|
||||||
import { addToast } from 'features/system/store/systemSlice';
|
import { addToast } from 'features/system/store/systemSlice';
|
||||||
import { makeToast } from 'features/system/util/makeToast';
|
import { makeToast } from 'features/system/util/makeToast';
|
||||||
import { setActiveTab } from 'features/ui/store/uiSlice';
|
import { setActiveTab } from 'features/ui/store/uiSlice';
|
||||||
|
@ -11,7 +11,7 @@ import { stateSelector } from 'app/store/store';
|
|||||||
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
|
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
|
||||||
import { defaultSelectorOptions } from 'app/store/util/defaultMemoizeOptions';
|
import { defaultSelectorOptions } from 'app/store/util/defaultMemoizeOptions';
|
||||||
import IAIMantineSearchableSelect from 'common/components/IAIMantineSearchableSelect';
|
import IAIMantineSearchableSelect from 'common/components/IAIMantineSearchableSelect';
|
||||||
import { useBuildNodeData } from 'features/nodes/hooks/useBuildNodeData';
|
import { useBuildNode } from 'features/nodes/hooks/useBuildNode';
|
||||||
import {
|
import {
|
||||||
addNodePopoverClosed,
|
addNodePopoverClosed,
|
||||||
addNodePopoverOpened,
|
addNodePopoverOpened,
|
||||||
@ -51,7 +51,7 @@ const selectFilter = (value: string, item: NodeTemplate) => {
|
|||||||
|
|
||||||
const AddNodePopover = () => {
|
const AddNodePopover = () => {
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const buildInvocation = useBuildNodeData();
|
const buildInvocation = useBuildNode();
|
||||||
const toaster = useAppToaster();
|
const toaster = useAppToaster();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ import { stateSelector } from 'app/store/store';
|
|||||||
import { useAppSelector } from 'app/store/storeHooks';
|
import { useAppSelector } from 'app/store/storeHooks';
|
||||||
import { defaultSelectorOptions } from 'app/store/util/defaultMemoizeOptions';
|
import { defaultSelectorOptions } from 'app/store/util/defaultMemoizeOptions';
|
||||||
import { IAINoContentFallback } from 'common/components/IAIImageFallback';
|
import { IAINoContentFallback } from 'common/components/IAIImageFallback';
|
||||||
import { getNeedsUpdate } from 'features/nodes/store/util/nodeUpdate';
|
import { getNeedsUpdate } from 'features/nodes/util/node/nodeUpdate';
|
||||||
import {
|
import {
|
||||||
InvocationNodeData,
|
InvocationNodeData,
|
||||||
InvocationTemplate,
|
InvocationTemplate,
|
||||||
|
@ -5,8 +5,8 @@ import { defaultSelectorOptions } from 'app/store/util/defaultMemoizeOptions';
|
|||||||
import { keys, map } from 'lodash-es';
|
import { keys, map } from 'lodash-es';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { isInvocationNode } from '../types/invocation';
|
import { isInvocationNode } from '../types/invocation';
|
||||||
import { getSortedFilteredFieldNames } from '../util/getSortedFilteredFieldNames';
|
import { getSortedFilteredFieldNames } from '../util/node/getSortedFilteredFieldNames';
|
||||||
import { TEMPLATE_BUILDER_MAP } from '../util/buildFieldInputTemplate';
|
import { TEMPLATE_BUILDER_MAP } from '../util/schema/buildFieldInputTemplate';
|
||||||
|
|
||||||
export const useAnyOrDirectInputFieldNames = (nodeId: string) => {
|
export const useAnyOrDirectInputFieldNames = (nodeId: string) => {
|
||||||
const selector = useMemo(
|
const selector = useMemo(
|
||||||
|
@ -3,13 +3,12 @@ import { RootState } from 'app/store/store';
|
|||||||
import { useAppSelector } from 'app/store/storeHooks';
|
import { useAppSelector } from 'app/store/storeHooks';
|
||||||
import { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
import { Node, useReactFlow } from 'reactflow';
|
import { Node, useReactFlow } from 'reactflow';
|
||||||
import {
|
|
||||||
buildCurrentImageNode,
|
|
||||||
buildInvocationNode,
|
|
||||||
buildNotesNode,
|
|
||||||
} from '../store/util/buildNodeData';
|
|
||||||
import { DRAG_HANDLE_CLASSNAME, NODE_WIDTH } from '../types/constants';
|
import { DRAG_HANDLE_CLASSNAME, NODE_WIDTH } from '../types/constants';
|
||||||
import { AnyNode, InvocationTemplate } from '../types/invocation';
|
import { AnyNode, InvocationTemplate } from '../types/invocation';
|
||||||
|
import { buildCurrentImageNode } from '../util/node/buildCurrentImageNode';
|
||||||
|
import { buildInvocationNode } from '../util/node/buildInvocationNode';
|
||||||
|
import { buildNotesNode } from '../util/node/buildNotesNode';
|
||||||
|
|
||||||
const templatesSelector = createSelector(
|
const templatesSelector = createSelector(
|
||||||
[(state: RootState) => state.nodes],
|
[(state: RootState) => state.nodes],
|
||||||
(nodes) => nodes.nodeTemplates
|
(nodes) => nodes.nodeTemplates
|
||||||
@ -19,7 +18,7 @@ export const SHARED_NODE_PROPERTIES: Partial<Node> = {
|
|||||||
dragHandle: `.${DRAG_HANDLE_CLASSNAME}`,
|
dragHandle: `.${DRAG_HANDLE_CLASSNAME}`,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useBuildNodeData = () => {
|
export const useBuildNode = () => {
|
||||||
const nodeTemplates = useAppSelector(templatesSelector);
|
const nodeTemplates = useAppSelector(templatesSelector);
|
||||||
|
|
||||||
const flow = useReactFlow();
|
const flow = useReactFlow();
|
@ -5,8 +5,8 @@ import { defaultSelectorOptions } from 'app/store/util/defaultMemoizeOptions';
|
|||||||
import { keys, map } from 'lodash-es';
|
import { keys, map } from 'lodash-es';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { isInvocationNode } from '../types/invocation';
|
import { isInvocationNode } from '../types/invocation';
|
||||||
import { getSortedFilteredFieldNames } from '../util/getSortedFilteredFieldNames';
|
import { getSortedFilteredFieldNames } from '../util/node/getSortedFilteredFieldNames';
|
||||||
import { TEMPLATE_BUILDER_MAP } from '../util/buildFieldInputTemplate';
|
import { TEMPLATE_BUILDER_MAP } from '../util/schema/buildFieldInputTemplate';
|
||||||
|
|
||||||
export const useConnectionInputFieldNames = (nodeId: string) => {
|
export const useConnectionInputFieldNames = (nodeId: string) => {
|
||||||
const selector = useMemo(
|
const selector = useMemo(
|
||||||
|
@ -2,7 +2,7 @@ import { createSelector } from '@reduxjs/toolkit';
|
|||||||
import { stateSelector } from 'app/store/store';
|
import { stateSelector } from 'app/store/store';
|
||||||
import { useAppSelector } from 'app/store/storeHooks';
|
import { useAppSelector } from 'app/store/storeHooks';
|
||||||
import { defaultSelectorOptions } from 'app/store/util/defaultMemoizeOptions';
|
import { defaultSelectorOptions } from 'app/store/util/defaultMemoizeOptions';
|
||||||
import { getNeedsUpdate } from '../store/util/nodeUpdate';
|
import { getNeedsUpdate } from '../util/node/nodeUpdate';
|
||||||
import { isInvocationNode } from '../types/invocation';
|
import { isInvocationNode } from '../types/invocation';
|
||||||
|
|
||||||
const selector = createSelector(
|
const selector = createSelector(
|
||||||
|
@ -4,7 +4,7 @@ import { useAppSelector } from 'app/store/storeHooks';
|
|||||||
import { defaultSelectorOptions } from 'app/store/util/defaultMemoizeOptions';
|
import { defaultSelectorOptions } from 'app/store/util/defaultMemoizeOptions';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { isInvocationNode } from '../types/invocation';
|
import { isInvocationNode } from '../types/invocation';
|
||||||
import { getNeedsUpdate } from '../store/util/nodeUpdate';
|
import { getNeedsUpdate } from '../util/node/nodeUpdate';
|
||||||
|
|
||||||
export const useNodeNeedsUpdate = (nodeId: string) => {
|
export const useNodeNeedsUpdate = (nodeId: string) => {
|
||||||
const selector = useMemo(
|
const selector = useMemo(
|
||||||
|
@ -5,7 +5,7 @@ import { defaultSelectorOptions } from 'app/store/util/defaultMemoizeOptions';
|
|||||||
import { map } from 'lodash-es';
|
import { map } from 'lodash-es';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { isInvocationNode } from '../types/invocation';
|
import { isInvocationNode } from '../types/invocation';
|
||||||
import { getSortedFilteredFieldNames } from '../util/getSortedFilteredFieldNames';
|
import { getSortedFilteredFieldNames } from '../util/node/getSortedFilteredFieldNames';
|
||||||
|
|
||||||
export const useOutputFieldNames = (nodeId: string) => {
|
export const useOutputFieldNames = (nodeId: string) => {
|
||||||
const selector = useMemo(
|
const selector = useMemo(
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { RootState } from 'app/store/store';
|
import { RootState } from 'app/store/store';
|
||||||
import { useAppSelector } from 'app/store/storeHooks';
|
import { useAppSelector } from 'app/store/storeHooks';
|
||||||
import { buildWorkflow } from 'features/nodes/util/buildWorkflow';
|
import { buildWorkflow } from 'features/nodes/util/workflow/buildWorkflow';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { useDebounce } from 'use-debounce';
|
import { useDebounce } from 'use-debounce';
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import { cloneDeep, omit, reduce } from 'lodash-es';
|
|||||||
import { Graph } from 'services/api/types';
|
import { Graph } from 'services/api/types';
|
||||||
import { AnyInvocation } from 'services/events/types';
|
import { AnyInvocation } from 'services/events/types';
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
import { buildWorkflow } from '../buildWorkflow';
|
import { buildWorkflow } from '../workflow/buildWorkflow';
|
||||||
import {
|
import {
|
||||||
FieldInputInstance,
|
FieldInputInstance,
|
||||||
isColorFieldInputInstance,
|
isColorFieldInputInstance,
|
@ -0,0 +1,23 @@
|
|||||||
|
import { SHARED_NODE_PROPERTIES } from 'features/nodes/types/constants';
|
||||||
|
import { CurrentImageNode } from 'features/nodes/types/invocation';
|
||||||
|
import { XYPosition } from 'reactflow';
|
||||||
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
|
|
||||||
|
export const buildCurrentImageNode = (
|
||||||
|
position: XYPosition
|
||||||
|
): CurrentImageNode => {
|
||||||
|
const nodeId = uuidv4();
|
||||||
|
const node: CurrentImageNode = {
|
||||||
|
...SHARED_NODE_PROPERTIES,
|
||||||
|
id: nodeId,
|
||||||
|
type: 'current_image',
|
||||||
|
position,
|
||||||
|
data: {
|
||||||
|
id: nodeId,
|
||||||
|
type: 'current_image',
|
||||||
|
isOpen: true,
|
||||||
|
label: 'Current Image',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
return node;
|
||||||
|
};
|
@ -4,57 +4,18 @@ import {
|
|||||||
FieldOutputInstance,
|
FieldOutputInstance,
|
||||||
} from 'features/nodes/types/field';
|
} from 'features/nodes/types/field';
|
||||||
import {
|
import {
|
||||||
CurrentImageNodeData,
|
InvocationNode,
|
||||||
InvocationNodeData,
|
|
||||||
InvocationTemplate,
|
InvocationTemplate,
|
||||||
NotesNodeData,
|
|
||||||
} from 'features/nodes/types/invocation';
|
} from 'features/nodes/types/invocation';
|
||||||
import { buildFieldInputInstance } from 'features/nodes/util/buildFieldInputInstance';
|
import { buildFieldInputInstance } from 'features/nodes/util/schema/buildFieldInputInstance';
|
||||||
import { reduce } from 'lodash-es';
|
import { reduce } from 'lodash-es';
|
||||||
import { Node, XYPosition } from 'reactflow';
|
import { XYPosition } from 'reactflow';
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
|
|
||||||
export const buildNotesNode = (position: XYPosition): Node<NotesNodeData> => {
|
|
||||||
const nodeId = uuidv4();
|
|
||||||
const node: Node<NotesNodeData> = {
|
|
||||||
...SHARED_NODE_PROPERTIES,
|
|
||||||
id: nodeId,
|
|
||||||
type: 'notes',
|
|
||||||
position,
|
|
||||||
data: {
|
|
||||||
id: nodeId,
|
|
||||||
isOpen: true,
|
|
||||||
label: 'Notes',
|
|
||||||
notes: '',
|
|
||||||
type: 'notes',
|
|
||||||
},
|
|
||||||
};
|
|
||||||
return node;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const buildCurrentImageNode = (
|
|
||||||
position: XYPosition
|
|
||||||
): Node<CurrentImageNodeData> => {
|
|
||||||
const nodeId = uuidv4();
|
|
||||||
const node: Node<CurrentImageNodeData> = {
|
|
||||||
...SHARED_NODE_PROPERTIES,
|
|
||||||
id: nodeId,
|
|
||||||
type: 'current_image',
|
|
||||||
position,
|
|
||||||
data: {
|
|
||||||
id: nodeId,
|
|
||||||
type: 'current_image',
|
|
||||||
isOpen: true,
|
|
||||||
label: 'Current Image',
|
|
||||||
},
|
|
||||||
};
|
|
||||||
return node;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const buildInvocationNode = (
|
export const buildInvocationNode = (
|
||||||
position: XYPosition,
|
position: XYPosition,
|
||||||
template: InvocationTemplate
|
template: InvocationTemplate
|
||||||
): Node<InvocationNodeData> => {
|
): InvocationNode => {
|
||||||
const nodeId = uuidv4();
|
const nodeId = uuidv4();
|
||||||
const { type } = template;
|
const { type } = template;
|
||||||
|
|
||||||
@ -94,7 +55,7 @@ export const buildInvocationNode = (
|
|||||||
{} as Record<string, FieldOutputInstance>
|
{} as Record<string, FieldOutputInstance>
|
||||||
);
|
);
|
||||||
|
|
||||||
const node: Node<InvocationNodeData> = {
|
const node: InvocationNode = {
|
||||||
...SHARED_NODE_PROPERTIES,
|
...SHARED_NODE_PROPERTIES,
|
||||||
id: nodeId,
|
id: nodeId,
|
||||||
type: 'invocation',
|
type: 'invocation',
|
@ -0,0 +1,22 @@
|
|||||||
|
import { SHARED_NODE_PROPERTIES } from 'features/nodes/types/constants';
|
||||||
|
import { NotesNode } from 'features/nodes/types/invocation';
|
||||||
|
import { XYPosition } from 'reactflow';
|
||||||
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
|
|
||||||
|
export const buildNotesNode = (position: XYPosition): NotesNode => {
|
||||||
|
const nodeId = uuidv4();
|
||||||
|
const node: NotesNode = {
|
||||||
|
...SHARED_NODE_PROPERTIES,
|
||||||
|
id: nodeId,
|
||||||
|
type: 'notes',
|
||||||
|
position,
|
||||||
|
data: {
|
||||||
|
id: nodeId,
|
||||||
|
isOpen: true,
|
||||||
|
label: 'Notes',
|
||||||
|
notes: '',
|
||||||
|
type: 'notes',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
return node;
|
||||||
|
};
|
@ -1,5 +1,5 @@
|
|||||||
import { isNil } from 'lodash-es';
|
import { isNil } from 'lodash-es';
|
||||||
import { FieldInputTemplate, FieldOutputTemplate } from '../types/field';
|
import { FieldInputTemplate, FieldOutputTemplate } from '../../types/field';
|
||||||
|
|
||||||
export const getSortedFilteredFieldNames = (
|
export const getSortedFilteredFieldNames = (
|
||||||
fields: FieldInputTemplate[] | FieldOutputTemplate[]
|
fields: FieldInputTemplate[] | FieldOutputTemplate[]
|
@ -7,7 +7,7 @@ import {
|
|||||||
import { zParsedSemver } from 'features/nodes/types/semver';
|
import { zParsedSemver } from 'features/nodes/types/semver';
|
||||||
import { cloneDeep, defaultsDeep } from 'lodash-es';
|
import { cloneDeep, defaultsDeep } from 'lodash-es';
|
||||||
import { Node } from 'reactflow';
|
import { Node } from 'reactflow';
|
||||||
import { buildInvocationNode } from './buildNodeData';
|
import { buildInvocationNode } from './buildInvocationNode';
|
||||||
|
|
||||||
export const getNeedsUpdate = (
|
export const getNeedsUpdate = (
|
||||||
node: Node<InvocationNodeData>,
|
node: Node<InvocationNodeData>,
|
@ -1,5 +1,5 @@
|
|||||||
import { get } from 'lodash-es';
|
import { get } from 'lodash-es';
|
||||||
import { FieldInputInstance, FieldInputTemplate } from '../types/field';
|
import { FieldInputInstance, FieldInputTemplate } from '../../types/field';
|
||||||
|
|
||||||
const FIELD_VALUE_FALLBACK_MAP = {
|
const FIELD_VALUE_FALLBACK_MAP = {
|
||||||
EnumField: '',
|
EnumField: '',
|
@ -22,8 +22,8 @@ import {
|
|||||||
T2IAdapterModelFieldInputTemplate,
|
T2IAdapterModelFieldInputTemplate,
|
||||||
VAEModelFieldInputTemplate,
|
VAEModelFieldInputTemplate,
|
||||||
isStatefulFieldType,
|
isStatefulFieldType,
|
||||||
} from '../types/field';
|
} from '../../types/field';
|
||||||
import { InvocationFieldSchema } from '../types/openapi';
|
import { InvocationFieldSchema } from '../../types/openapi';
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
type FieldInputTemplateBuilder<T extends FieldInputTemplate = any> = // valid `any`!
|
type FieldInputTemplateBuilder<T extends FieldInputTemplate = any> = // valid `any`!
|
@ -1,6 +1,6 @@
|
|||||||
import { startCase } from 'lodash-es';
|
import { startCase } from 'lodash-es';
|
||||||
import { FieldOutputTemplate, FieldType } from '../types/field';
|
import { FieldOutputTemplate, FieldType } from '../../types/field';
|
||||||
import { InvocationFieldSchema } from '../types/openapi';
|
import { InvocationFieldSchema } from '../../types/openapi';
|
||||||
|
|
||||||
export const buildFieldOutputTemplate = (
|
export const buildFieldOutputTemplate = (
|
||||||
fieldSchema: InvocationFieldSchema,
|
fieldSchema: InvocationFieldSchema,
|
@ -1,8 +1,11 @@
|
|||||||
import { t } from 'i18next';
|
import { t } from 'i18next';
|
||||||
import { isArray } from 'lodash-es';
|
import { isArray } from 'lodash-es';
|
||||||
import { OpenAPIV3_1 } from 'openapi-types';
|
import { OpenAPIV3_1 } from 'openapi-types';
|
||||||
import { FieldTypeParseError, UnsupportedFieldTypeError } from '../types/error';
|
import {
|
||||||
import { FieldType } from '../types/field';
|
FieldTypeParseError,
|
||||||
|
UnsupportedFieldTypeError,
|
||||||
|
} from '../../types/error';
|
||||||
|
import { FieldType } from '../../types/field';
|
||||||
import {
|
import {
|
||||||
OpenAPIV3_1SchemaOrRef,
|
OpenAPIV3_1SchemaOrRef,
|
||||||
isArraySchemaObject,
|
isArraySchemaObject,
|
||||||
@ -10,7 +13,7 @@ import {
|
|||||||
isNonArraySchemaObject,
|
isNonArraySchemaObject,
|
||||||
isRefObject,
|
isRefObject,
|
||||||
isSchemaObject,
|
isSchemaObject,
|
||||||
} from '../types/openapi';
|
} from '../../types/openapi';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transforms an invocation output ref object to field type.
|
* Transforms an invocation output ref object to field type.
|
@ -3,15 +3,18 @@ import { parseify } from 'common/util/serialize';
|
|||||||
import { t } from 'i18next';
|
import { t } from 'i18next';
|
||||||
import { reduce } from 'lodash-es';
|
import { reduce } from 'lodash-es';
|
||||||
import { OpenAPIV3_1 } from 'openapi-types';
|
import { OpenAPIV3_1 } from 'openapi-types';
|
||||||
import { FieldTypeParseError, UnsupportedFieldTypeError } from '../types/error';
|
import {
|
||||||
import { FieldInputTemplate, FieldOutputTemplate } from '../types/field';
|
FieldTypeParseError,
|
||||||
import { InvocationTemplate } from '../types/invocation';
|
UnsupportedFieldTypeError,
|
||||||
|
} from '../../types/error';
|
||||||
|
import { FieldInputTemplate, FieldOutputTemplate } from '../../types/field';
|
||||||
|
import { InvocationTemplate } from '../../types/invocation';
|
||||||
import {
|
import {
|
||||||
InvocationSchemaObject,
|
InvocationSchemaObject,
|
||||||
isInvocationFieldSchema,
|
isInvocationFieldSchema,
|
||||||
isInvocationOutputSchemaObject,
|
isInvocationOutputSchemaObject,
|
||||||
isInvocationSchemaObject,
|
isInvocationSchemaObject,
|
||||||
} from '../types/openapi';
|
} from '../../types/openapi';
|
||||||
import { buildFieldInputTemplate } from './buildFieldInputTemplate';
|
import { buildFieldInputTemplate } from './buildFieldInputTemplate';
|
||||||
import { buildFieldOutputTemplate } from './buildFieldOutputTemplate';
|
import { buildFieldOutputTemplate } from './buildFieldOutputTemplate';
|
||||||
import { parseFieldType } from './parseFieldType';
|
import { parseFieldType } from './parseFieldType';
|
@ -1,6 +1,6 @@
|
|||||||
import { logger } from 'app/logging/logger';
|
import { logger } from 'app/logging/logger';
|
||||||
import { NodesState } from '../store/types';
|
import { NodesState } from '../../store/types';
|
||||||
import { WorkflowV2, zWorkflowEdge, zWorkflowNode } from '../types/workflow';
|
import { WorkflowV2, zWorkflowEdge, zWorkflowNode } from '../../types/workflow';
|
||||||
import { fromZodError } from 'zod-validation-error';
|
import { fromZodError } from 'zod-validation-error';
|
||||||
import { parseify } from 'common/util/serialize';
|
import { parseify } from 'common/util/serialize';
|
||||||
import i18n from 'i18next';
|
import i18n from 'i18next';
|
@ -2,10 +2,10 @@ import { parseify } from 'common/util/serialize';
|
|||||||
import { t } from 'i18next';
|
import { t } from 'i18next';
|
||||||
import { keyBy } from 'lodash-es';
|
import { keyBy } from 'lodash-es';
|
||||||
import { JsonObject } from 'type-fest';
|
import { JsonObject } from 'type-fest';
|
||||||
import { getNeedsUpdate } from '../store/util/nodeUpdate';
|
import { getNeedsUpdate } from '../node/nodeUpdate';
|
||||||
import { InvocationTemplate } from '../types/invocation';
|
import { InvocationTemplate } from '../../types/invocation';
|
||||||
import { parseAndMigrateWorkflow } from '../types/migration/migrations';
|
import { parseAndMigrateWorkflow } from '../../types/migration/migrations';
|
||||||
import { WorkflowV2, isWorkflowInvocationNode } from '../types/workflow';
|
import { WorkflowV2, isWorkflowInvocationNode } from '../../types/workflow';
|
||||||
|
|
||||||
type WorkflowWarning = {
|
type WorkflowWarning = {
|
||||||
message: string;
|
message: string;
|
Reference in New Issue
Block a user