Skip to content

Commit

Permalink
[breadboard] Remove InspectableGraph.kits.
Browse files Browse the repository at this point in the history
- **Make `InspectableKit` an breadboard-internal type.**
- **docs(changeset): Remove `InspectableGraph.kits`.**

Progress on #3965.
  • Loading branch information
dglazkov authored Dec 10, 2024
1 parent de75b63 commit b685d49
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 499 deletions.
6 changes: 6 additions & 0 deletions .changeset/orange-turkeys-judge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@google-labs/breadboard": patch
"@breadboard-ai/shared-ui": patch
---

Remove `InspectableGraph.kits`.
20 changes: 1 addition & 19 deletions packages/breadboard/src/inspector/graph-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
GraphStoreEventTarget,
InspectableGraph,
InspectableGraphOptions,
InspectableKit,
MainGraphIdentifier,
MutableGraph,
MutableGraphStore,
Expand All @@ -30,7 +29,7 @@ import { Sandbox } from "@breadboard-ai/jsandbox";
import { createLoader } from "../loader/index.js";
import { SnapshotUpdater } from "../utils/snapshot-updater.js";
import { UpdateEvent } from "./graph/event.js";
import { collectCustomNodeTypes, createBuiltInKit } from "./graph/kits.js";
import { createBuiltInKit } from "./graph/kits.js";
import { graphUrlLike } from "../utils/graph-url-like.js";

export { GraphStore, makeTerribleOptions, contextFromStore };
Expand Down Expand Up @@ -351,23 +350,6 @@ class GraphStore
get(id: MainGraphIdentifier): MutableGraph | undefined {
return this.#mutables.get(id)?.current();
}

addKits(kits: Kit[], dependencies: MainGraphIdentifier[]): InspectableKit[] {
return [
...kits.map((kit) => {
const descriptor = {
title: kit.title,
description: kit.description,
url: kit.url,
tags: kit.tags || [],
};
return {
descriptor,
nodeTypes: collectCustomNodeTypes(kit.handlers, dependencies, this),
};
}),
];
}
}

function error<T>(message: string): Result<T> {
Expand Down
5 changes: 0 additions & 5 deletions packages/breadboard/src/inspector/graph/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
import {
InspectableEdge,
InspectableGraph,
InspectableKit,
InspectableModules,
InspectableNode,
InspectableNodeType,
Expand Down Expand Up @@ -94,10 +93,6 @@ class Graph implements InspectableGraph {
return this.#mutable.edges.hasByValue(edge, this.#graphId);
}

kits(): InspectableKit[] {
return this.#mutable.kits.kits();
}

typeForNode(id: NodeIdentifier): InspectableNodeType | undefined {
return new GraphQueries(this.#mutable, this.#graphId).typeForNode(id);
}
Expand Down
6 changes: 0 additions & 6 deletions packages/breadboard/src/inspector/graph/kits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ class CustomNodeType implements InspectableNodeType {

class KitCache implements InspectableKitCache {
#types: Map<NodeTypeIdentifier, InspectableNodeType> = new Map();
#kits: InspectableKit[] = [];
#mutable: MutableGraph;

constructor(mutable: MutableGraph) {
Expand All @@ -347,16 +346,11 @@ class KitCache implements InspectableKitCache {
this.#types.set(id, type);
}

kits(): InspectableKit[] {
return this.#kits;
}

rebuild(graph: GraphDescriptor) {
const kits = collectKits(this.#mutable, graph);

this.#types = new Map(
kits.flatMap((kit) => kit.nodeTypes.map((type) => [type.type(), type]))
);
this.#kits = kits;
}
}
7 changes: 0 additions & 7 deletions packages/breadboard/src/inspector/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,6 @@ export type InspectableGraph = {
* Returns true if the edge exists in the graph.
*/
hasEdge(edge: Edge): boolean;
/**
* Returns all kits in the graph.
*/
kits(): InspectableKit[];
/**
* Returns all nodes of the given type.
* @param type type of the nodes to find
Expand Down Expand Up @@ -680,7 +676,6 @@ export type InspectableDescriberResultCache = {
export type InspectableKitCache = {
getType(id: NodeTypeIdentifier): InspectableNodeType | undefined;
addType(id: NodeTypeIdentifier, type: InspectableNodeType): void;
kits(): InspectableKit[];
rebuild(graph: GraphDescriptor): void;
};

Expand Down Expand Up @@ -754,8 +749,6 @@ export type MutableGraphStore = TypedEventTargetType<GraphsStoreEventMap> & {
graph: GraphDescriptor,
graphId: GraphIdentifier
): InspectableGraph | undefined;

addKits(kits: Kit[], dependencies: MainGraphIdentifier[]): InspectableKit[];
};

export type PortIdentifier = string;
Expand Down
1 change: 0 additions & 1 deletion packages/shared-ui/src/elements/elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export { CodeEditor } from "./input/code-editor/code-editor.js";
export { CommandPalette } from "./command-palette/command-palette.js";
export { CommentOverlay } from "./overlay/comment.js";
export { ComponentSelector } from "./component-selector/component-selector.js";
export { ComponentSelectorOverlay } from "./overlay/component-selector.js";
export { ConnectionBroker } from "./connection/connection-broker.js";
export { ConnectionInput } from "./connection/connection-input.js";
export { ConnectionSettings } from "./connection/connection-settings.js";
Expand Down
Loading

0 comments on commit b685d49

Please sign in to comment.