mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-04-23 03:00:31 -04:00
feat(ui): expose id property on Graph class
This commit is contained in:
committed by
Kent Keirsey
parent
4c58703797
commit
add2b41322
@@ -2,7 +2,6 @@ import { deepClone } from 'common/util/deepClone';
|
||||
import { Graph } from 'features/nodes/util/graph/generation/Graph';
|
||||
import type { AnyInvocation, Invocation } from 'services/api/types';
|
||||
import { assert, AssertionError, is } from 'tsafe';
|
||||
import { validate } from 'uuid';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { z } from 'zod';
|
||||
|
||||
@@ -11,11 +10,12 @@ describe('Graph', () => {
|
||||
it('should create a new graph with the correct id', () => {
|
||||
const g = new Graph('test-id');
|
||||
expect(g._graph.id).toBe('test-id');
|
||||
expect(g.id).toBe('test-id');
|
||||
});
|
||||
it('should create a new graph with a uuid id if none is provided', () => {
|
||||
it('should create an id if none is provided', () => {
|
||||
const g = new Graph();
|
||||
expect(g._graph.id).not.toBeUndefined();
|
||||
expect(validate(g._graph.id)).toBeTruthy();
|
||||
expect(g.id).not.toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -32,10 +32,12 @@ export type GraphType = { id: string; nodes: Record<string, AnyInvocation>; edge
|
||||
export class Graph {
|
||||
_graph: GraphType;
|
||||
_metadataNodeId = getPrefixedId('core_metadata');
|
||||
id: string;
|
||||
|
||||
constructor(id?: string) {
|
||||
this.id = id ?? Graph.getId('graph');
|
||||
this._graph = {
|
||||
id: id ?? uuidv4(),
|
||||
id: this.id,
|
||||
nodes: {},
|
||||
edges: [],
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user