/** 后端 `{ code, msg, data }`；约定 `code === 0` 表示成功 */
export type ApiEnvelope<T = unknown> = {
  code: number;
  msg: string;
  data: T;
};

export function isApiEnvelope(v: unknown): v is ApiEnvelope {
  if (v === null || typeof v !== "object") {
    return false;
  }
  const o = v as Record<string, unknown>;
  return (
    typeof o.code === "number" &&
    typeof o.msg === "string" &&
    "data" in o
  );
}
