fix: 120 type errors
All checks were successful
Deploy to GitHub Pages / build_site (push) Successful in 2m47s

This commit is contained in:
Max Richter
2025-11-24 00:10:38 +01:00
parent 0fa1b64d49
commit d64877666b
31 changed files with 584 additions and 467 deletions

View File

@@ -1,6 +1,6 @@
import { createWasmWrapper } from "@nodes/utils"
import fs from "fs/promises"
import path from "path"
import { createWasmWrapper } from "@nodes/utils";
import fs from "fs/promises";
import path from "path";
export async function getWasm(id: `${string}/${string}/${string}`) {
const filePath = path.resolve(`../nodes/${id}/pkg/index_bg.wasm`);
@@ -8,17 +8,15 @@ export async function getWasm(id: `${string}/${string}/${string}`) {
try {
await fs.access(filePath);
} catch (e) {
return null
return null;
}
const file = await fs.readFile(filePath);
return new Uint8Array(file);
}
export async function getNodeWasm(id: `${string}/${string}/${string}`) {
const wasmBytes = await getWasm(id);
if (!wasmBytes) return null;
@@ -27,9 +25,7 @@ export async function getNodeWasm(id: `${string}/${string}/${string}`) {
return wrapper;
}
export async function getNode(id: `${string}/${string}/${string}`) {
const wrapper = await getNodeWasm(id);
const definition = wrapper?.get_definition?.();
@@ -37,18 +33,17 @@ export async function getNode(id: `${string}/${string}/${string}`) {
if (!definition) return null;
return definition;
}
export async function getCollectionNodes(userId: `${string}/${string}`) {
const nodes = await fs.readdir(path.resolve(`../nodes/${userId}`));
return nodes
.filter(n => n !== "pkg" && n !== ".template")
.map(n => {
.filter((n) => n !== "pkg" && n !== ".template")
.map((n) => {
return {
id: `${userId}/${n}`,
}
})
};
});
}
export async function getCollection(userId: `${string}/${string}`) {
@@ -56,36 +51,40 @@ export async function getCollection(userId: `${string}/${string}`) {
return {
id: userId,
nodes,
}
};
}
export async function getUserCollections(userId: string) {
const collections = await fs.readdir(path.resolve(`../nodes/${userId}`));
return Promise.all(collections.map(async n => {
const nodes = await getCollectionNodes(`${userId}/${n}`);
return {
id: `${userId}/${n}`,
nodes,
}
}));
return Promise.all(
collections.map(async (n) => {
const nodes = await getCollectionNodes(`${userId}/${n}`);
return {
id: `${userId}/${n}`,
nodes,
};
}),
);
}
export async function getUser(userId: string) {
const collections = await getUserCollections(userId);
return {
id: userId,
collections
}
collections,
};
}
export async function getUsers() {
const nodes = await fs.readdir(path.resolve("../nodes"));
const users = await Promise.all(nodes.map(async n => {
const collections = await getUserCollections(n);
return {
id: n,
collections
}
}))
const users = await Promise.all(
nodes.map(async (n) => {
const collections = await getUserCollections(n);
return {
id: n,
collections,
};
}),
);
return users;
}