Skip to main content
Glama
viz.store.ts2.91 kB
import { defineStore } from "pinia"; import { ApiRequest, addStoreHooks } from "@si/vue-lib/pinia"; import { reactive } from "vue"; import { useChangeSetsStore } from "@/store/change_sets.store"; import { Visibility } from "@/api/sdf/dal/visibility"; import { nilId } from "@/utils/nilId"; export type NodeKind = | "Category" | "Content" | "Func" | "Ordering" | "Prop" | "Component"; export type ContentKind = | "Root" | "ActionPrototype" | "AttributePrototype" | "AttributePrototypeArgument" | "AttributeValue" | "Component" | "FuncArg" | "Func" | "InputSocket" | "OutputSocket" | "Prop" | "Schema" | "SchemaVariant" | "StaticArgumentValue" | "ValidationPrototype"; export interface VizResponse { edges: { from: string; to: string; edgeWeightKind: string; }[]; nodes: { id: string; nodeKind: NodeKind; contentKind: ContentKind | null; name: string | null; }[]; rootNodeId: string; } export const useVizStore = addStoreHooks( undefined, undefined, // TODO look into whether this ID on the store needs to be more dynamic defineStore(`ws/viz`, () => { const changeSetStore = useChangeSetsStore(); const selectedChangeSetId = changeSetStore.selectedChangeSetId; // TODO(nick): we need to allow for empty visibility here. Temporarily send down "nil" to mean that we want the // query to find the default change set. const visibility: Visibility = { visibility_change_set_pk: selectedChangeSetId ?? changeSetStore.headChangeSetId ?? nilId(), }; const data: VizResponse = reactive({ edges: [], nodes: [], rootNodeId: "", }); function onSuccess(response: VizResponse): void { data.nodes.splice(0, data.nodes.length); data.edges.splice(0, data.edges.length); data.edges.push(...response.edges); data.nodes.push(...response.nodes); data.rootNodeId = response.rootNodeId; } async function LOAD_COMPONENTS() { return new ApiRequest<VizResponse>({ url: "/graphviz/components", params: { ...visibility }, onSuccess, }); } async function LOAD_VARIANTS(schemaVariantId: string | null) { return schemaVariantId === null ? new ApiRequest<VizResponse>({ url: "/graphviz/nodes_edges", params: { ...visibility }, onSuccess, }) : new ApiRequest<VizResponse>({ url: "/graphviz/schema_variant", params: { schemaVariantId, ...visibility }, onSuccess, }); } async function DEBUG_NODE(nodeId: string) { return new ApiRequest({ url: "/node_debug", params: { id: nodeId, ...visibility }, }); } return { edges: data.edges, nodes: data.nodes, LOAD_VARIANTS, LOAD_COMPONENTS, DEBUG_NODE, }; }), );

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/systeminit/si'

If you have feedback or need assistance with the MCP directory API, please join our Discord server