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

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 body: string;
}

export const Notification = {
};

export interface Sender {
  send(text: string): Promise<void>;
}

export const SenderToken: unique symbol = Symbol("Sender");

export class StubSender implements Sender {
  async send(text: string): Promise<void> {
    return undefined;
  }
}

export const StubSenderProvider = { token: SenderToken, factory: () => new StubSender() };

export const notify = {
  async queue_notify_0(message: Notification, deps: { Sender: Sender }): Promise<QueueResult> {
    const __r0 = await deps.Sender.send(message.body);
    return QueueResult.Ack;
  },
};

export function serialise_Notification(value: Notification): JsonValue {
  return {
    body: value.body 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["body"] !== "string") {
    return Err({ kind: "StructuralMismatch", path: `${path}.body`, expected: "string", actual: typeof obj["body"] });
  }
  const __body = obj["body"];
  return Ok({ body: __body } as Notification);
}


