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

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

export type OrderId = string & { readonly __brand: "orders.OrderId" };

export const OrderId = {
  of(value: string): Result<OrderId, ValidationError> {
    return Ok(value as OrderId);
  },
  unsafe(value: string): OrderId {
    return value as OrderId;
  },
};

export const api = {
  async http_GET_orders_Param_id(id: OrderId, deps: {}): Promise<HttpResult<string>> {
    return HttpResult.Ok("an order");
  },
};

export function serialise_OrderId(value: OrderId): JsonValue {
  return value as unknown as string;
}

export function deserialise_OrderId(json: JsonValue, path: string = "$"): Result<OrderId, BoundaryError> {
  if (typeof json !== "string") {
    return Err({ kind: "StructuralMismatch", path, expected: "string", actual: typeof json });
  }
  const validated = (typeof (OrderId as any).of === "function")
    ? (OrderId as any).of(json)
    : Ok(json as unknown as OrderId);
  if (validated.tag === "Err") {
    return Err({ kind: "RefinementViolation", path, violation: validated.error });
  }
  return Ok(validated.value as OrderId);
}


