supported apps domain + some refactor of data types redundancy

This commit is contained in:
user
2026-03-28 16:19:24 +02:00
parent 6639bcd799
commit 671a712b08
26 changed files with 2052 additions and 169 deletions

View File

@@ -1,5 +1,9 @@
import { getDeviceController } from "@pkg/logic/domains/device/controller";
import { createDeviceSchema, updateDeviceSchema } from "@pkg/logic/domains/device/data";
import {
createDeviceSchema,
deviceStatusSchema,
updateDeviceSchema,
} from "@pkg/logic/domains/device/data";
import { getFlowExecCtxForRemoteFuncs, unauthorized } from "$lib/core/server.utils";
import { command, getRequestEvent, query } from "$app/server";
import * as v from "valibot";
@@ -73,14 +77,14 @@ export const deleteDeviceSC = command(
export const setDeviceStatusSC = command(
v.object({
id: v.number(),
status: v.picklist(["online", "offline", "busy", "error"]),
status: deviceStatusSchema,
}),
async (payload) => {
const event = getRequestEvent();
const fctx = await getFlowExecCtxForRemoteFuncs(event.locals);
if (!fctx.userId) return unauthorized(fctx);
const res = await dc.setStatus(fctx, payload.id, payload.status as any);
const res = await dc.setStatus(fctx, payload.id, payload.status);
return res.isOk()
? { data: res.value, error: null }
: { data: null, error: res.error };