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

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 UserId = string & { readonly __brand: "api.UserId" };

export const UserId = {
  of(value: string): Result<UserId, ValidationError> {
    if (!(value.length > 0)) {
      return Err({ field: "UserId", message: "must be non-empty", value });
    }
    return Ok(value as UserId);
  },
  unsafe(value: string): UserId {
    return value as UserId;
  },
};

export interface View {
  readonly ok: boolean;
}

export const View = {
};

export const api = {
  async http_GET_ping(deps: {}): Promise<HttpResult<View>> {
    return HttpResult.Ok({ ok: true });
  },
  async http_GET_healthz(deps: {}): Promise<HttpResult<View>> {
    return HttpResult.Ok({ ok: true });
  },
};

export function serialise_View(value: View): JsonValue {
  return {
    ok: value.ok as JsonValue,
  };
}

export function deserialise_View(json: JsonValue, path: string = "$"): Result<View, 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["ok"] !== "boolean") {
    return Err({ kind: "StructuralMismatch", path: `${path}.ok`, expected: "boolean", actual: typeof obj["ok"] });
  }
  const __ok = obj["ok"];
  return Ok({ ok: __ok } as View);
}


