package com.easyagents.federation.sql.api;

import com.easyagents.federation.sql.federation.FederationQueryScopeDefinition;

/**
 * SQL 编辑器补全请求。
 *
 * @param queryScope 当前编辑器可见的查询范围
 * @param sql 允许不完整的 SQL 文本
 * @param cursorOffset 光标 UTF-16 字符偏移
 */
public record SqlCompletionRequest(
    FederationQueryScopeDefinition queryScope,
    String sql,
    int cursorOffset
) {

    /**
     * 校验补全请求。
     */
    public SqlCompletionRequest {
        if (queryScope == null || sql == null) {
            throw new IllegalArgumentException("queryScope and sql must be provided");
        }
        if (cursorOffset < 0 || cursorOffset > sql.length()) {
            throw new IllegalArgumentException("cursorOffset is outside the SQL text");
        }
    }
}
