feat(ui): add autocomplete for Graph.addEdgeToMetadata

This commit is contained in:
psychedelicious
2025-07-07 16:16:45 +10:00
parent 66991334fc
commit 067026a0d0
2 changed files with 11 additions and 1 deletions

View File

@@ -9,6 +9,7 @@ import type {
AnyInvocationInputField,
AnyInvocationOutputField,
AnyModelConfig,
CoreMetadataFields,
InputFields,
Invocation,
InvocationType,
@@ -433,7 +434,7 @@ export class Graph {
addEdgeToMetadata<TFrom extends AnyInvocation>(
fromNode: TFrom,
fromField: OutputFields<TFrom>,
metadataField: string
metadataField: CoreMetadataFields | (string & Record<string, never>)
): Edge {
// @ts-expect-error `Graph` excludes `core_metadata` nodes due to its excessively wide typing
return this.addEdge(fromNode, fromField, this.getMetadataNode(), metadataField);

View File

@@ -322,6 +322,15 @@ type NonInputFields = 'id' | 'type' | 'is_intermediate' | 'use_cache' | 'board'
export type AnyInvocationInputField = Exclude<KeysOfUnion<Required<AnyInvocation>>, NonInputFields>;
export type InputFields<T extends AnyInvocation> = Extract<keyof T, AnyInvocationInputField>;
type ExcludeIndexSignature<T> = {
[K in keyof T as string extends K ? never : K]: T[K];
};
export type CoreMetadataFields = Exclude<
keyof ExcludeIndexSignature<components['schemas']['CoreMetadataInvocation']>,
NonInputFields
>;
type NonOutputFields = 'type';
export type AnyInvocationOutputField = Exclude<KeysOfUnion<Required<AnyInvocationOutput>>, NonOutputFields>;
export type OutputFields<T extends AnyInvocation> = Extract<