// Generated by bynkc — do not edit by hand.
// context ops

import { Ok, Err, Some, None, type Result, type Option, type ValidationError, QueueResult, type JsonValue, type BoundaryError, type ServiceBinding, callService, boundaryError } from "../../runtime.js";

export interface Notification {
  readonly to: string;
}

export const Notification = {
};

export const sweeper = {
  async cron_sweeper_0(deps: {}): Promise<Result<void, string>> {
    return Ok(undefined);
  },
};

export const notifier = {
  async queue_notifier_0(message: Notification, deps: {}): Promise<QueueResult> {
    return QueueResult.Ack;
  },
};

export function serialise_Notification(value: Notification): JsonValue {
  return {
    to: value.to as JsonValue,
  };
}

export function deserialise_Notification(json: JsonValue, path: string = "$"): Result<Notification, BoundaryError> {
  if (typeof json !== "object" || json === null || Array.isArray(json)) {
    return Err({ kind: "StructuralMismatch", path, expected: "object", actual: typeof json });
  }
  const obj = json as { [k: string]: JsonValue };
  if (typeof obj["to"] !== "string") {
    return Err({ kind: "StructuralMismatch", path: `${path}.to`, expected: "string", actual: typeof obj["to"] });
  }
  const __to = obj["to"];
  return Ok({ to: __to } as Notification);
}


export function serialise_Result_Unit_String(value: Result<void, string>): JsonValue {
  if (value.tag === "Ok") return { kind: "Ok", value: null };
  return { kind: "Err", error: value.error as JsonValue };
}

export function deserialise_Result_Unit_String(json: JsonValue, path: string = "$"): Result<Result<void, string>, BoundaryError> {
  if (typeof json !== "object" || json === null || Array.isArray(json)) {
    return Err({ kind: "StructuralMismatch", path, expected: "object", actual: typeof json });
  }
  const obj = json as { [k: string]: JsonValue };
  if (obj["kind"] === "Ok") {
  const __v = undefined;
    return Ok(Ok(__v) as Result<void, string>);
  } else if (obj["kind"] === "Err") {
  if (typeof obj["error"] !== "string") {
    return Err({ kind: "StructuralMismatch", path: `${path}.error`, expected: "string", actual: typeof obj["error"] });
  }
  const __e = obj["error"];
    return Ok(Err(__e) as Result<void, string>);
  }
  return Err({ kind: "StructuralMismatch", path, expected: "Ok | Err", actual: String(obj["kind"]) });
}

