supported apps domain + some refactor of data types redundancy
This commit is contained in:
@@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user