'use strict';

/**
 * dialect-kit — Wrapper tipis (read-only) atas modul murni `src/core/db/dialect`.
 *
 * Tujuan: satu titik impor agar boundary tier (generator → src/core/db) terlihat
 * eksplisit. Modul `src/core/db/dialect` terbukti murni (Phase 00b E3): nol
 * `process.env` / `new Pool` / side effect, aman diimpor read-only dari tier generator.
 *
 * JANGAN impor `src/utils/db*.js` (singleton env-coupled).
 *
 * Jalur impor: generators/lib/data/dialect-kit.js → ../../../src/core/db/dialect/
 *
 * @module generators/lib/data/dialect-kit
 */

const { createDialect } = require('../../../src/core/db/dialect');

/**
 * Validasi identifier (nama tabel/kolom) via dialect.
 * @param {Object} dialect - Instance dialect
 * @param {string} name
 * @returns {string} name yang sudah divalidasi
 */
function validateIdentifier(dialect, name) {
  return dialect.validateIdentifier(name);
}

/**
 * Placeholder parameter ke-i (1-based) via dialect.
 * @param {Object} dialect - Instance dialect
 * @param {number} i - 1-based index
 * @returns {string}
 */
function placeholder(dialect, i) {
  return dialect.placeholder(i);
}

/**
 * Clause LIMIT/OFFSET (dialect-aware) via dialect.
 * @param {Object} dialect - Instance dialect
 * @param {number|null} limit
 * @param {number|null} offset
 * @returns {string}
 */
function limitOffsetClause(dialect, limit, offset) {
  return dialect.limitOffsetClause(limit, offset);
}

module.exports = {
  // Nama `createDialect` dipertahankan untuk paritas dengan src/core/db/dialect.
  createDialect,
  validateIdentifier,
  placeholder,
  limitOffsetClause
};
