feat: partial user platform support + statusMessage -> message

This commit is contained in:
DecDuck
2025-08-27 11:25:23 +10:00
parent 3af00e085e
commit 8efddc07bc
143 changed files with 831 additions and 593 deletions

View File

@ -1,18 +1,27 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import type { EventHandlerRequest, H3Event } from "h3";
import type { Dump, Pull, Register } from "../objects/transactional";
import { ObjectTransactionalHandler } from "../objects/transactional";
type RecursiveType =
| { [key: string]: RecursiveType }
| string
| number
| Array<RecursiveType>;
export async function handleFileUpload(
h3: H3Event<EventHandlerRequest>,
metadata: { [key: string]: string },
permissions: Array<string>,
max = -1,
): Promise<[string[], { [key: string]: string }, Pull, Dump, Register] | undefined> {
): Promise<
[string[], { [key: string]: RecursiveType }, Pull, Dump, Register] | undefined
> {
const formData = await readMultipartFormData(h3);
if (!formData) return undefined;
const transactionalHandler = new ObjectTransactionalHandler();
const [add, pull, dump] = transactionalHandler.new(metadata, permissions);
const options: { [key: string]: string } = {};
const options: any = {};
const ids = [];
for (const entry of formData) {
@ -25,7 +34,14 @@ export async function handleFileUpload(
}
if (!entry.name) continue;
options[entry.name] = entry.data.toString("utf-8");
const path = entry.name.split(".");
let v = options;
for (const pathPart of path.slice(0, -1)) {
(v as any)[pathPart] ??= {};
v = (v as any)[pathPart];
}
(v as any)[path.at(-1)!] = entry.data.toString("utf-8");
}
return [ids, options, pull, dump, add];