npx skills add ...
npx skills add stahura/domo-ai-vibe-rules --skill sql-query
Use SqlClient for raw SQL against mapped dataset aliases and parse columnar SQL responses safely.
npx skills add stahura/domo-ai-vibe-rules --skill sql-query
Apply when executing SQL queries against Domo datasets, using AI-generated SQL from AIClient.text_to_sql, or any time you need to run raw SQL against a dataset alias. Use SqlClient from @domoinc/toolkit instead of domo.post('/sql/v1/').
SqlClient is the toolkit wrapper for Domo's SQL API. Use it to execute SQL queries against datasets mapped in manifest.json.
get(alias, query)Executes a SQL query against a dataset.
Parameters:
alias (string): dataset alias from manifest.json mappingsquery (string): SQL query stringReturns: Promise<Response<SqlResponse>>
parsePageFilters(datasets, produceClauses?)Transforms Domo page filters into SQL predicates.
CRITICAL: SQL API returns a columnar format, not an array of row objects.
You must zip columns + rows into objects for UI rendering:
Use AIClient to generate SQL, then SqlClient to execute it:
SqlClient instead of domo.post('/sql/v1/').parsePageFilters() to inject filters manually when needed.FROM must match manifest alias (example: SELECT * FROM vendorPayments).columns + rows), never a flat array of objects..body, .data, or directly on result; parse defensively.// Get predicates as objects
const predicates = sqlClient.parsePageFilters(['datasetAlias']);
// Get predicates as WHERE/HAVING clause strings
const clauses = sqlClient.parsePageFilters(['datasetAlias'], true);// Response shape:
{
columns: ['vendor', 'Total Spend'],
rows: [
['Sysco Utah', 1880794.74],
['Intermountain Meats', 809389.15]
],
metadata: [...],
numRows: 8,
numColumns: 2,
datasource: 'dataset-uuid',
fromcache: true
}const result = await sqlClient.get('myAlias', sql);
const res = result?.body || result?.data || result;
const colNames: string[] = res?.columns || [];
const rawRows: unknown[][] = res?.rows || [];
const rows = rawRows.map((row) => {
const obj: Record<string, unknown> = {};
colNames.forEach((col, i) => {
obj[col] = row[i];
});
return obj;
});
// rows => [{ vendor: 'Sysco Utah', 'Total Spend': 1880794.74 }, ...]import { AIClient, SqlClient } from '@domoinc/toolkit';
// 1) Generate SQL from natural language
const aiResponse = await AIClient.text_to_sql(question, [
{
dataSourceName: 'myAlias',
description: 'Description of the dataset',
columns: [
{ name: 'vendor', type: 'string' },
{ name: 'amount', type: 'number' }
]
}
]);
const responseBody = aiResponse.data || aiResponse.body || aiResponse;
const sql = responseBody.output || responseBody.choices?.[0]?.output;
// 2) Execute SQL
const sqlClient = new SqlClient();
const result = await sqlClient.get('myAlias', sql);
// 3) Parse columnar response into row objects
const res = result?.body || result?.data || result;
const colNames: string[] = res?.columns || [];
const rawRows: unknown[][] = res?.rows || [];
const rows = rawRows.map((row) => {
const obj: Record<string, unknown> = {};
colNames.forEach((col, i) => {
obj[col] = row[i];
});
return obj;
});