feat: node store interface
This commit is contained in:
1
app/src/routes/+layout.server.ts
Normal file
1
app/src/routes/+layout.server.ts
Normal file
@ -0,0 +1 @@
|
||||
export const prerender = true;
|
@ -5,7 +5,3 @@
|
||||
</script>
|
||||
|
||||
<slot />
|
||||
|
||||
{#if false}
|
||||
<span class="absolute i-tabler-settings w-6 h-6 block"></span>
|
||||
{/if}
|
||||
|
@ -2,17 +2,20 @@
|
||||
import Grid from "$lib/grid";
|
||||
import GraphInterface from "$lib/graph-interface";
|
||||
import { MemoryRuntimeExecutor } from "$lib/runtime-executor";
|
||||
import { RemoteNodeRegistry } from "$lib/node-registry";
|
||||
import { RemoteNodeRegistry } from "$lib/node-registry-client";
|
||||
import * as templates from "$lib/graph-templates";
|
||||
import type { Graph } from "@nodes/types";
|
||||
import Viewer from "$lib/viewer/Viewer.svelte";
|
||||
import Viewer from "$lib/result-viewer/Viewer.svelte";
|
||||
import Settings from "$lib/settings/Settings.svelte";
|
||||
import { AppSettings, AppSettingTypes } from "$lib/settings/app-settings";
|
||||
import { get, writable, type Writable } from "svelte/store";
|
||||
import Keymap from "$lib/settings/Keymap.svelte";
|
||||
import type { createKeyMap } from "$lib/helpers/createKeyMap";
|
||||
import NodeStore from "$lib/node-store/NodeStore.svelte";
|
||||
import type { GraphManager } from "$lib/graph-interface/graph-manager";
|
||||
import { setContext } from "svelte";
|
||||
|
||||
const nodeRegistry = new RemoteNodeRegistry("http://localhost:3001");
|
||||
const nodeRegistry = new RemoteNodeRegistry("");
|
||||
const runtimeExecutor = new MemoryRuntimeExecutor(nodeRegistry);
|
||||
|
||||
let res: Int32Array;
|
||||
@ -21,7 +24,11 @@
|
||||
? JSON.parse(localStorage.getItem("graph")!)
|
||||
: templates.grid(3, 3);
|
||||
|
||||
let manager: GraphManager;
|
||||
let managerStatus: Writable<"loading" | "error" | "idle">;
|
||||
$: if (manager) {
|
||||
setContext("graphManager", manager);
|
||||
}
|
||||
|
||||
let keymap: ReturnType<typeof createKeyMap>;
|
||||
|
||||
@ -41,6 +48,7 @@
|
||||
definition: AppSettingTypes,
|
||||
},
|
||||
shortcuts: {},
|
||||
nodeStore: {},
|
||||
graph: {},
|
||||
};
|
||||
|
||||
@ -53,7 +61,16 @@
|
||||
};
|
||||
|
||||
settings = settings;
|
||||
console.log({ settings });
|
||||
}
|
||||
|
||||
$: if (manager) {
|
||||
settings.nodeStore = {
|
||||
id: "Node Store",
|
||||
icon: "i-tabler-database",
|
||||
props: { nodeRegistry, manager },
|
||||
component: NodeStore,
|
||||
};
|
||||
settings = settings;
|
||||
}
|
||||
|
||||
function handleSettings(
|
||||
@ -91,10 +108,10 @@
|
||||
<Grid.Cell>
|
||||
{#key graph}
|
||||
<GraphInterface
|
||||
bind:manager
|
||||
registry={nodeRegistry}
|
||||
{graph}
|
||||
bind:keymap
|
||||
bind:status={managerStatus}
|
||||
settings={settings?.graph?.settings}
|
||||
on:settings={handleSettings}
|
||||
on:result={handleResult}
|
||||
|
22
app/src/routes/nodes/[user].json/+server.ts
Normal file
22
app/src/routes/nodes/[user].json/+server.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import { json } from "@sveltejs/kit";
|
||||
import type { EntryGenerator, RequestHandler } from "./$types";
|
||||
import * as registry from "$lib/node-registry";
|
||||
|
||||
|
||||
export const prerender = true;
|
||||
|
||||
export const entries: EntryGenerator = async () => {
|
||||
const users = await registry.getUsers();
|
||||
return users.map(user => {
|
||||
return { user: user.id }
|
||||
}).flat(2);
|
||||
}
|
||||
|
||||
|
||||
export const GET: RequestHandler = async function GET({ params }) {
|
||||
|
||||
const namespaces = await registry.getUser(params.user)
|
||||
|
||||
return json(namespaces);
|
||||
|
||||
}
|
22
app/src/routes/nodes/[user]/[collection].json/+server.ts
Normal file
22
app/src/routes/nodes/[user]/[collection].json/+server.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import { json } from "@sveltejs/kit";
|
||||
import type { EntryGenerator, RequestHandler } from "./$types";
|
||||
import * as registry from "$lib/node-registry";
|
||||
|
||||
export const prerender = true;
|
||||
|
||||
export const entries: EntryGenerator = async () => {
|
||||
const users = await registry.getUsers();
|
||||
return users.map(user => {
|
||||
return user.collections.map(collection => {
|
||||
return { user: user.id, collection: collection.id }
|
||||
})
|
||||
}).flat(2);
|
||||
}
|
||||
|
||||
export const GET: RequestHandler = async function GET({ params }) {
|
||||
|
||||
const namespaces = await registry.getCollection(`${params.user}/${params.collection}`);
|
||||
|
||||
return json(namespaces);
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
import { json } from "@sveltejs/kit";
|
||||
import type { EntryGenerator, RequestHandler } from "./$types";
|
||||
import { getNode } from "$lib/node-registry";
|
||||
import * as registry from "$lib/node-registry";
|
||||
|
||||
export const prerender = true;
|
||||
|
||||
|
||||
export const entries: EntryGenerator = async () => {
|
||||
const users = await registry.getUsers();
|
||||
return users.map(user => {
|
||||
return user.collections.map(collection => {
|
||||
return collection.nodes.map(node => {
|
||||
return { user: user.id, collection: collection.id, node: node.id }
|
||||
});
|
||||
})
|
||||
}).flat(2);
|
||||
}
|
||||
|
||||
export const GET: RequestHandler = async function GET({ params }) {
|
||||
|
||||
const nodeId = `${params.user}/${params.collection}/${params.node}` as const;
|
||||
|
||||
try {
|
||||
const node = await getNode(nodeId);
|
||||
return json(node);
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
return new Response("Not found", { status: 404 });
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
import type { RequestHandler } from "./$types";
|
||||
import * as registry from "$lib/node-registry";
|
||||
import type { EntryGenerator } from "../$types";
|
||||
|
||||
export const prerender = true;
|
||||
|
||||
export const entries: EntryGenerator = async () => {
|
||||
const users = await registry.getUsers();
|
||||
return users.map(user => {
|
||||
return user.collections.map(collection => {
|
||||
return collection.nodes.map(node => {
|
||||
return { user: user.id, collection: collection.id, node: node.id }
|
||||
});
|
||||
})
|
||||
}).flat(2);
|
||||
}
|
||||
|
||||
export const GET: RequestHandler = async function GET({ params }) {
|
||||
|
||||
const wasm = await registry.getWasm(`${params.user}/${params.collection}/${params.node}`);
|
||||
|
||||
if (!wasm) {
|
||||
return new Response("Not found", { status: 404 });
|
||||
}
|
||||
|
||||
return new Response(wasm, { status: 200, headers: { "Content-Type": "application/wasm" } });
|
||||
}
|
14
app/src/routes/nodes/users.json/+server.ts
Normal file
14
app/src/routes/nodes/users.json/+server.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import { json } from "@sveltejs/kit";
|
||||
import type { RequestHandler } from "./$types";
|
||||
|
||||
import * as registry from "$lib/node-registry";
|
||||
|
||||
export const prerender = true;
|
||||
|
||||
export const GET: RequestHandler = async function GET() {
|
||||
|
||||
const users = await registry.getUsers();
|
||||
|
||||
return json(users);
|
||||
|
||||
}
|
Reference in New Issue
Block a user