Skip to content

Commit

Permalink
rename IGraphAPI to IGraph
Browse files Browse the repository at this point in the history
  • Loading branch information
bhouston committed Jul 25, 2023
1 parent 87e18ac commit c79278b
Show file tree
Hide file tree
Showing 22 changed files with 58 additions and 61 deletions.
6 changes: 3 additions & 3 deletions packages/core/src/Graphs/Graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { Variable } from '../Values/Variables/Variable.js';
// Purpose:
// - stores the node graph

export interface IGraphApi {
export interface IGraph {
readonly variables: { [id: string]: Variable };
readonly customEvents: { [id: string]: CustomEvent };
readonly values: ValueTypeMap;
Expand All @@ -37,7 +37,7 @@ export const createNode = ({
nodeTypeName,
nodeConfiguration = {}
}: {
graph: IGraphApi;
graph: IGraph;
registry: IRegistry;
nodeTypeName: string;
nodeConfiguration?: NodeConfiguration;
Expand Down Expand Up @@ -74,7 +74,7 @@ export const makeGraphApi = ({
variables?: GraphVariables;
values: ValueTypeMap;
dependencies: Dependencies;
}): IGraphApi => ({
}): IGraph => ({
variables,
customEvents,
values,
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/Graphs/IO/readGraphFromJSON.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
GraphInstance,
GraphNodes,
GraphVariables,
IGraphApi,
IGraph,
makeGraphApi
} from '../Graph.js';
import {
Expand Down Expand Up @@ -167,7 +167,7 @@ function readNodeJSON({
registry,
nodeJson
}: {
graph: IGraphApi;
graph: IGraph;
registry: IRegistry;
nodeJson: NodeJSON;
}) {
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/Nodes/AsyncNode.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Assert } from '../Diagnostics/Assert.js';
import { Engine } from '../Execution/Engine.js';
import { IGraphApi } from '../Graphs/Graph.js';
import { IGraph } from '../Graphs/Graph.js';
import { Socket } from '../Sockets/Socket.js';
import { Node, NodeConfiguration } from './Node.js';
import { IAsyncNodeDefinition, NodeCategory } from './NodeDefinitions.js';
Expand All @@ -11,7 +11,7 @@ import { NodeDescription } from './Registry/NodeDescription.js';
export class AsyncNode extends Node<NodeType.Async> {
constructor(
description: NodeDescription,
graph: IGraphApi,
graph: IGraph,
inputs: Socket[] = [],
outputs: Socket[] = [],
configuration: NodeConfiguration = {}
Expand Down Expand Up @@ -56,7 +56,7 @@ export class AsyncNode extends Node<NodeType.Async> {
export class AsyncNode2 extends AsyncNode {
constructor(props: {
description: NodeDescription;
graph: IGraphApi;
graph: IGraph;
inputs?: Socket[];
outputs?: Socket[];
}) {
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/Nodes/EventNode.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Assert } from '../Diagnostics/Assert.js';
import { Engine } from '../Execution/Engine.js';
import { IGraphApi } from '../Graphs/Graph.js';
import { IGraph } from '../Graphs/Graph.js';
import { Socket } from '../Sockets/Socket.js';
import { Node, NodeConfiguration } from './Node.js';
import { IEventNodeDefinition, NodeCategory } from './NodeDefinitions.js';
Expand All @@ -11,7 +11,7 @@ import { NodeDescription } from './Registry/NodeDescription.js';
export class EventNode extends Node<NodeType.Event> implements IEventNode {
constructor(
description: NodeDescription,
graph: IGraphApi,
graph: IGraph,
inputs: Socket[] = [],
outputs: Socket[] = [],
configuration: NodeConfiguration = {}
Expand Down Expand Up @@ -53,7 +53,7 @@ export class EventNode extends Node<NodeType.Event> implements IEventNode {
export class EventNode2 extends EventNode {
constructor(props: {
description: NodeDescription;
graph: IGraphApi;
graph: IGraph;
inputs?: Socket[];
outputs?: Socket[];
configuration?: NodeConfiguration;
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/Nodes/FlowNode.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Assert } from '../Diagnostics/Assert.js';
import { Fiber } from '../Execution/Fiber.js';
import { IGraphApi } from '../Graphs/Graph.js';
import { IGraph } from '../Graphs/Graph.js';
import { Socket } from '../Sockets/Socket.js';
import { Node, NodeConfiguration } from './Node.js';
import { IFlowNodeDefinition, NodeCategory } from './NodeDefinitions.js';
Expand All @@ -10,7 +10,7 @@ import { NodeDescription } from './Registry/NodeDescription.js';
export class FlowNode extends Node<NodeType.Flow> implements IFlowNode {
constructor(
description: NodeDescription,
graph: IGraphApi,
graph: IGraph,
inputs: Socket[] = [],
outputs: Socket[] = [],
configuration: NodeConfiguration = {}
Expand Down Expand Up @@ -43,7 +43,7 @@ export class FlowNode extends Node<NodeType.Flow> implements IFlowNode {
export class FlowNode2 extends FlowNode {
constructor(props: {
description: NodeDescription;
graph: IGraphApi;
graph: IGraph;
inputs?: Socket[];
outputs?: Socket[];
configuration?: NodeConfiguration;
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/Nodes/FunctionNode.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Assert } from '../Diagnostics/Assert.js';
import { IGraphApi } from '../Graphs/Graph.js';
import { IGraph } from '../Graphs/Graph.js';
import { Socket } from '../Sockets/Socket.js';
import { Node, NodeConfiguration } from './Node.js';
import {
Expand All @@ -19,7 +19,7 @@ export abstract class FunctionNode
{
constructor(
description: NodeDescription,
graph: IGraphApi,
graph: IGraph,
inputs: Socket[] = [],
outputs: Socket[] = [],
public readonly exec: (node: INode) => void,
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/Nodes/Node.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IGraphApi } from '../Graphs/Graph.js';
import { IGraph } from '../Graphs/Graph.js';
import { Socket } from '../Sockets/Socket.js';
import { INode, NodeType } from './NodeInstance.js';
import { readInputFromSockets, writeOutputsToSocket } from './NodeSockets.js';
Expand All @@ -15,7 +15,7 @@ export abstract class Node<TNodeType extends NodeType> implements INode {
// public typeName: string;
public nodeType: TNodeType;
public readonly otherTypeNames: string[] | undefined;
public graph: IGraphApi;
public graph: IGraph;
public label?: string;
public metadata: any;
public readonly configuration: NodeConfiguration;
Expand Down
17 changes: 7 additions & 10 deletions packages/core/src/Nodes/NodeDefinitions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IGraphApi } from '../Graphs/Graph.js';
import { IGraph } from '../Graphs/Graph.js';
import { Choices } from '../Sockets/Socket.js';
import { AsyncNodeInstance } from './AsyncNode.js';
import { EventNodeInstance } from './EventNode.js';
Expand All @@ -21,22 +21,19 @@ export type SocketsMap = Record<
string,
| SocketDefinition
| string
| ((nodeConfig: NodeConfiguration, graph: IGraphApi) => SocketDefinition)
| ((nodeConfig: NodeConfiguration, graph: IGraph) => SocketDefinition)
>;
export type SocketListDefinition = SocketDefinition & { key: string };
export type SocketsList = SocketListDefinition[];

export type SocketsGeneratorFromConfig = (
nodeConfig: NodeConfiguration,
graph: IGraphApi
graph: IGraph
) => SocketsList;

export type SocketsDefinition = SocketsMap | SocketsGeneratorFromConfig;

export type NodeFactory = (
graph: IGraphApi,
config: NodeConfiguration
) => INode;
export type NodeFactory = (graph: IGraph, config: NodeConfiguration) => INode;

export interface IHasNodeFactory {
readonly nodeFactory: NodeFactory;
Expand Down Expand Up @@ -81,7 +78,7 @@ export type TriggeredFn<
// state of the node.
state: TState;

graph: IGraphApi;
graph: IGraph;
configuration: NodeConfiguration;
finished?: () => void;
}) => StateReturn<TState>;
Expand Down Expand Up @@ -124,7 +121,7 @@ export interface IHasInit<
}

export interface IHasDispose<TState> {
dispose: (params: { state: TState; graph: IGraphApi }) => StateReturn<TState>;
dispose: (params: { state: TState; graph: IGraph }) => StateReturn<TState>;
}

export interface IFlowNodeDefinition<
Expand Down Expand Up @@ -161,7 +158,7 @@ export interface FunctionNodeExecParams<
// write and commit only allows keys from the output type
write<T>(outValueName: SocketNames<TOutput>, value: T): void;

graph: IGraphApi;
graph: IGraph;
configuration: NodeConfiguration;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/Nodes/NodeInstance.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Engine } from '../Execution/Engine.js';
import { Fiber } from '../Execution/Fiber.js';
import { IGraphApi } from '../Graphs/Graph.js';
import { IGraph } from '../Graphs/Graph.js';
import { Socket } from '../Sockets/Socket.js';
import { NodeConfiguration } from './Node.js';
import { readInputFromSockets, writeOutputsToSocket } from './NodeSockets.js';
Expand All @@ -16,7 +16,7 @@ export enum NodeType {
export interface INode {
readonly inputs: Socket[];
readonly outputs: Socket[];
readonly graph: IGraphApi;
readonly graph: IGraph;
description: INodeDescription;
configuration: NodeConfiguration;
nodeType: NodeType;
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/Nodes/Registry/NodeDescription.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IGraphApi } from '../../Graphs/Graph.js';
import { IGraph } from '../../Graphs/Graph.js';
import {
IHasNodeFactory,
INodeDefinition,
Expand Down Expand Up @@ -32,7 +32,7 @@ export interface INodeDescription {

export type NodeFactoryWithDescription = (
entry: NodeDescription,
graph: IGraphApi,
graph: IGraph,
config: NodeConfiguration
) => INode;

Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/Nodes/nodeFactory.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IGraphApi } from '../Graphs/Graph.js';
import { IGraph } from '../Graphs/Graph.js';
import { Socket } from '../Sockets/Socket.js';
import { NodeConfiguration } from './Node.js';
import {
Expand All @@ -20,7 +20,7 @@ const makeSocketsFromMap = <TSockets extends SocketsMap>(
socketConfig: TSockets,
keys: (keyof TSockets)[],
configuration: NodeConfiguration,
graphApi: IGraphApi
graphApi: IGraph
): Socket[] => {
return keys.map((key) => {
const definition = socketConfig[key];
Expand Down Expand Up @@ -50,7 +50,7 @@ const makeSocketsFromArray = (sockets: SocketsList) =>
export function makeOrGenerateSockets(
socketConfigOrFactory: SocketsDefinition,
nodeConfig: NodeConfiguration,
graph: IGraphApi
graph: IGraph
): Socket[] {
// if sockets definition is dynamic, then use the node config to generate it;
// otherwise, use the static definition
Expand Down Expand Up @@ -91,7 +91,7 @@ export const makeCommonProps = (
| 'label'
>,
configuration: NodeConfiguration,
graph: IGraphApi
graph: IGraph
): INode => ({
description: {
typeName: typeName,
Expand Down
10 changes: 5 additions & 5 deletions packages/core/src/Nodes/testUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IGraphApi, makeGraphApi } from '../Graphs/Graph.js';
import { IGraph, makeGraphApi } from '../Graphs/Graph.js';
import { NodeConfiguration } from './Node.js';
import {
IFunctionNodeDefinition,
Expand All @@ -9,7 +9,7 @@ import {
import { makeOrGenerateSockets } from './nodeFactory.js';
import { NodeConfigurationDescription } from './Registry/NodeDescription.js';

const makeEmptyGraph = (): IGraphApi => {
const makeEmptyGraph = (): IGraph => {
return makeGraphApi({
dependencies: {},
values: {}
Expand Down Expand Up @@ -39,7 +39,7 @@ export const testExec = <
configuration?: NodeConfiguration;
/** Simulated input values the input sockets have */
nodeInputVals?: SocketValues<TInput>;
makeGraph?: () => IGraphApi;
makeGraph?: () => IGraph;
}): SocketValues<TOutput> => {
const outputs: SocketValues<TOutput> = {};

Expand Down Expand Up @@ -91,7 +91,7 @@ export const generateTriggerTester = <
/** Triggered function from the node defintion */
/** Runtime configuration of the node */
configuration?: NodeConfiguration;
makeGraph?: () => IGraphApi;
makeGraph?: () => IGraph;
} & Pick<
IHasTriggered<TInput, TOutput, TState>,
'initialState' | 'triggered'
Expand Down Expand Up @@ -167,7 +167,7 @@ function getOutputSocketKeys<TSockets extends SocketsDefinition>({
}: {
outputs: TSockets;
config: NodeConfiguration;
graph: IGraphApi;
graph: IGraph;
}): SocketNames<TSockets>[] {
const sockets = makeOrGenerateSockets(outputs, config, graph);

Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/Profiles/Core/CustomEvents/OnCustomEvent.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Assert } from '../../../Diagnostics/Assert.js';
import { CustomEvent } from '../../../Events/CustomEvent.js';
import { Engine } from '../../../Execution/Engine.js';
import { IGraphApi } from '../../../Graphs/Graph.js';
import { IGraph } from '../../../Graphs/Graph.js';
import { EventNode2 } from '../../../Nodes/EventNode.js';
import { NodeConfiguration } from '../../../Nodes/Node.js';
import {
Expand Down Expand Up @@ -29,7 +29,7 @@ export class OnCustomEvent extends EventNode2 {

constructor(
description: NodeDescription,
graph: IGraphApi,
graph: IGraph,
configuration: NodeConfiguration
) {
const customEvent =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CustomEvent } from '../../../Events/CustomEvent.js';
import { Fiber } from '../../../Execution/Fiber.js';
import { IGraphApi } from '../../../Graphs/Graph.js';
import { IGraph } from '../../../Graphs/Graph.js';
import { FlowNode2 } from '../../../Nodes/FlowNode.js';
import { NodeConfiguration } from '../../../Nodes/Node.js';
import {
Expand Down Expand Up @@ -28,7 +28,7 @@ export class TriggerCustomEvent extends FlowNode2 {

constructor(
description: NodeDescription,
graph: IGraphApi,
graph: IGraph,
configuration: NodeConfiguration
) {
const customEvent =
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/Profiles/Core/Debug/AssertExpectTrue.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Assert } from '../../../Diagnostics/Assert.js';
import { Fiber } from '../../../Execution/Fiber.js';
import { IGraphApi } from '../../../Graphs/Graph.js';
import { IGraph } from '../../../Graphs/Graph.js';
import { FlowNode } from '../../../Nodes/FlowNode.js';
import { NodeDescription } from '../../../Nodes/Registry/NodeDescription.js';
import { Socket } from '../../../Sockets/Socket.js';
Expand All @@ -13,7 +13,7 @@ export class ExpectTrue extends FlowNode {
(description, graph) => new ExpectTrue(description, graph)
);

constructor(description: NodeDescription, graph: IGraphApi) {
constructor(description: NodeDescription, graph: IGraph) {
super(
description,
graph,
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/Profiles/Core/Flow/Debounce.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Engine } from '../../../Execution/Engine.js';
import { IGraphApi } from '../../../Graphs/Graph.js';
import { IGraph } from '../../../Graphs/Graph.js';
import { AsyncNode } from '../../../Nodes/AsyncNode.js';
import { NodeDescription } from '../../../Nodes/Registry/NodeDescription.js';
import { Socket } from '../../../Sockets/Socket.js';
Expand All @@ -15,7 +15,7 @@ export class Debounce extends AsyncNode {
(description, graph) => new Debounce(description, graph)
);

constructor(description: NodeDescription, graph: IGraphApi) {
constructor(description: NodeDescription, graph: IGraph) {
super(
description,
graph,
Expand Down
Loading

0 comments on commit c79278b

Please sign in to comment.