implemented the domain logic + processor endpoints

This commit is contained in:
user
2026-03-01 06:33:32 +02:00
parent c74523e4bc
commit 8aa8ddfa7d
10 changed files with 1629 additions and 32 deletions

View File

@@ -0,0 +1,131 @@
import { FlowExecCtx } from "@core/flow.execution.context";
import { ERROR_CODES, type Err } from "@pkg/result";
import { getError } from "@pkg/logger";
export const mobileErrors = {
adminOwnerNotFound: (fctx: FlowExecCtx): Err =>
getError({
flowId: fctx.flowId,
code: ERROR_CODES.NOT_FOUND,
message: "Admin owner not found",
description: "No admin user exists to own this device",
detail: "Unable to resolve an admin user for device registration",
}),
invalidPayload: (fctx: FlowExecCtx, detail: string): Err =>
getError({
flowId: fctx.flowId,
code: ERROR_CODES.VALIDATION_ERROR,
message: "Invalid mobile payload",
description: "Please validate request data and try again",
detail,
}),
deviceNotFound: (fctx: FlowExecCtx, externalDeviceId: string): Err =>
getError({
flowId: fctx.flowId,
code: ERROR_CODES.NOT_FOUND,
message: "Device not found",
description: "The device is not registered",
detail: `externalDeviceId=${externalDeviceId}`,
}),
deviceNotFoundById: (fctx: FlowExecCtx, deviceId: number): Err =>
getError({
flowId: fctx.flowId,
code: ERROR_CODES.NOT_FOUND,
message: "Device not found",
description: "The device does not exist",
detail: `deviceId=${deviceId}`,
}),
mediaAssetNotFound: (fctx: FlowExecCtx, mediaAssetId: number): Err =>
getError({
flowId: fctx.flowId,
code: ERROR_CODES.NOT_FOUND,
message: "Media asset not found",
description: "The media asset does not exist",
detail: `mediaAssetId=${mediaAssetId}`,
}),
registerDeviceFailed: (fctx: FlowExecCtx, detail: string): Err =>
getError({
flowId: fctx.flowId,
code: ERROR_CODES.DATABASE_ERROR,
message: "Failed to register device",
description: "Please try again later",
detail,
}),
pingDeviceFailed: (fctx: FlowExecCtx, detail: string): Err =>
getError({
flowId: fctx.flowId,
code: ERROR_CODES.DATABASE_ERROR,
message: "Failed to update device ping",
description: "Please try again later",
detail,
}),
syncSMSFailed: (fctx: FlowExecCtx, detail: string): Err =>
getError({
flowId: fctx.flowId,
code: ERROR_CODES.DATABASE_ERROR,
message: "Failed to sync SMS",
description: "Please try again later",
detail,
}),
syncMediaFailed: (fctx: FlowExecCtx, detail: string): Err =>
getError({
flowId: fctx.flowId,
code: ERROR_CODES.DATABASE_ERROR,
message: "Failed to sync media assets",
description: "Please try again later",
detail,
}),
listDevicesFailed: (fctx: FlowExecCtx, detail: string): Err =>
getError({
flowId: fctx.flowId,
code: ERROR_CODES.DATABASE_ERROR,
message: "Failed to list devices",
description: "Please try again later",
detail,
}),
listSMSFailed: (fctx: FlowExecCtx, detail: string): Err =>
getError({
flowId: fctx.flowId,
code: ERROR_CODES.DATABASE_ERROR,
message: "Failed to list SMS",
description: "Please try again later",
detail,
}),
listMediaFailed: (fctx: FlowExecCtx, detail: string): Err =>
getError({
flowId: fctx.flowId,
code: ERROR_CODES.DATABASE_ERROR,
message: "Failed to list media assets",
description: "Please try again later",
detail,
}),
deleteMediaFailed: (fctx: FlowExecCtx, detail: string): Err =>
getError({
flowId: fctx.flowId,
code: ERROR_CODES.DATABASE_ERROR,
message: "Failed to delete media asset",
description: "Please try again later",
detail,
}),
deleteDeviceFailed: (fctx: FlowExecCtx, detail: string): Err =>
getError({
flowId: fctx.flowId,
code: ERROR_CODES.DATABASE_ERROR,
message: "Failed to delete device",
description: "Please try again later",
detail,
}),
};