Compare commits
No commits in common. "a99040f42e9a2e418f51dcff6f047a998b745cf4" and "05e89704755660956e2745d10ea6eece16973899" have entirely different histories.
a99040f42e
...
05e8970475
@ -34,7 +34,7 @@
|
||||
const registryCache = new IndexDBCache("node-registry");
|
||||
const nodeRegistry = new RemoteNodeRegistry(
|
||||
"https://node-store.app.max-richter.dev",
|
||||
/// "http://localhost:8000",
|
||||
// "http://localhost:8000",
|
||||
registryCache,
|
||||
);
|
||||
const workerRuntime = new WorkerRuntimeExecutor();
|
||||
|
@ -53,17 +53,21 @@ export async function createNode(
|
||||
}
|
||||
|
||||
export async function getNodeDefinitionsByUser(userName: string) {
|
||||
const nodes = await db
|
||||
.select({
|
||||
const nodes = await db.select({
|
||||
definition: nodeTable.definition,
|
||||
hash: nodeTable.hash,
|
||||
})
|
||||
.from(nodeTable)
|
||||
.where(and(eq(nodeTable.userId, userName)));
|
||||
}).from(
|
||||
nodeTable,
|
||||
)
|
||||
.where(
|
||||
and(
|
||||
eq(nodeTable.userId, userName),
|
||||
),
|
||||
);
|
||||
|
||||
return nodes.map((n) => ({
|
||||
...n.definition,
|
||||
// id: n.definition.id + "@" + n.hash,
|
||||
id: n.definition.id + "@" + n.hash,
|
||||
}));
|
||||
}
|
||||
|
||||
@ -79,18 +83,16 @@ export async function getNodesBySystem(
|
||||
.from(nodeTable)
|
||||
.where(
|
||||
and(eq(nodeTable.systemId, systemId), eq(nodeTable.userId, username)),
|
||||
)
|
||||
.orderBy(nodeTable.userId, nodeTable.systemId, nodeTable.nodeId);
|
||||
).orderBy(nodeTable.userId, nodeTable.systemId, nodeTable.nodeId);
|
||||
|
||||
const definitions = nodes
|
||||
.map(
|
||||
(node) =>
|
||||
[NodeDefinitionSchema.safeParse(node.definition), node.hash] as const,
|
||||
.map((node) =>
|
||||
[NodeDefinitionSchema.safeParse(node.definition), node.hash] as const
|
||||
)
|
||||
.filter(([v]) => v.success)
|
||||
.map(([v, hash]) => ({
|
||||
...v.data,
|
||||
// id: v?.data?.id + "@" + hash,
|
||||
id: v?.data?.id + "@" + hash,
|
||||
}));
|
||||
|
||||
return definitions;
|
||||
@ -101,9 +103,7 @@ export async function getNodeWasmById(
|
||||
systemId: string,
|
||||
nodeId: string,
|
||||
) {
|
||||
const node = await db
|
||||
.select({ content: nodeTable.content })
|
||||
.from(nodeTable)
|
||||
const node = await db.select({ content: nodeTable.content }).from(nodeTable)
|
||||
.where(
|
||||
and(
|
||||
eq(nodeTable.userId, userName),
|
||||
@ -126,13 +126,12 @@ export async function getNodeDefinitionById(
|
||||
systemId: string,
|
||||
nodeId: string,
|
||||
) {
|
||||
const node = await db
|
||||
.select({
|
||||
const node = await db.select({
|
||||
definition: nodeTable.definition,
|
||||
hash: nodeTable.hash,
|
||||
})
|
||||
.from(nodeTable)
|
||||
.where(
|
||||
}).from(
|
||||
nodeTable,
|
||||
).where(
|
||||
and(
|
||||
eq(nodeTable.userId, userName),
|
||||
eq(nodeTable.systemId, systemId),
|
||||
@ -152,10 +151,7 @@ export async function getNodeDefinitionById(
|
||||
throw new InvalidNodeDefinitionError();
|
||||
}
|
||||
|
||||
return {
|
||||
...definition.data,
|
||||
// id: definition.data.id + "@" + node[0].hash
|
||||
};
|
||||
return { ...definition.data, id: definition.data.id + "@" + node[0].hash };
|
||||
}
|
||||
|
||||
export async function getNodeVersions(
|
||||
@ -163,13 +159,12 @@ export async function getNodeVersions(
|
||||
system: string,
|
||||
nodeId: string,
|
||||
) {
|
||||
const nodes = await db
|
||||
.select({
|
||||
const nodes = await db.select({
|
||||
definition: nodeTable.definition,
|
||||
hash: nodeTable.hash,
|
||||
})
|
||||
.from(nodeTable)
|
||||
.where(
|
||||
}).from(
|
||||
nodeTable,
|
||||
).where(
|
||||
and(
|
||||
eq(nodeTable.userId, user),
|
||||
eq(nodeTable.systemId, system),
|
||||
@ -180,7 +175,7 @@ export async function getNodeVersions(
|
||||
|
||||
return nodes.map((node) => ({
|
||||
...node.definition,
|
||||
// id: node.definition.id + "@" + node.hash,
|
||||
id: node.definition.id + "@" + node.hash,
|
||||
}));
|
||||
}
|
||||
|
||||
@ -190,20 +185,18 @@ export async function getNodeVersion(
|
||||
nodeId: string,
|
||||
hash: string,
|
||||
) {
|
||||
const nodes = await db
|
||||
.select({
|
||||
const nodes = await db.select({
|
||||
definition: nodeTable.definition,
|
||||
})
|
||||
.from(nodeTable)
|
||||
.where(
|
||||
}).from(
|
||||
nodeTable,
|
||||
).where(
|
||||
and(
|
||||
eq(nodeTable.userId, user),
|
||||
eq(nodeTable.systemId, system),
|
||||
eq(nodeTable.nodeId, nodeId),
|
||||
eq(nodeTable.hash, hash),
|
||||
),
|
||||
)
|
||||
.limit(1);
|
||||
).limit(1);
|
||||
|
||||
if (nodes.length === 0) {
|
||||
throw new NodeNotFoundError();
|
||||
@ -218,20 +211,18 @@ export async function getNodeVersionWasm(
|
||||
nodeId: string,
|
||||
hash: string,
|
||||
) {
|
||||
const node = await db
|
||||
.select({
|
||||
const node = await db.select({
|
||||
content: nodeTable.content,
|
||||
})
|
||||
.from(nodeTable)
|
||||
.where(
|
||||
}).from(
|
||||
nodeTable,
|
||||
).where(
|
||||
and(
|
||||
eq(nodeTable.userId, user),
|
||||
eq(nodeTable.systemId, system),
|
||||
eq(nodeTable.nodeId, nodeId),
|
||||
eq(nodeTable.hash, hash),
|
||||
),
|
||||
)
|
||||
.limit(1);
|
||||
).limit(1);
|
||||
|
||||
if (node.length === 0) {
|
||||
throw new NodeNotFoundError();
|
||||
|
Loading…
x
Reference in New Issue
Block a user