This commit is contained in:
seb
2026-10-03 23:13:40 +02:00
parent 6520665dcf
commit 3b74c12f4e
36 changed files with 3669 additions and 2183 deletions

View File

@@ -0,0 +1,27 @@
import { LIST_BY_COMPANYUSER as MSSQL_LIST } from '../../providers/mssql/queries/modelconversation.js';
import { LIST_BY_COMPANYUSER as SQLITE_LIST } from '../../providers/sqlite3/queries/modelconversation.js';
import resolveSelectedCompanyAccess from '../companyuser/resolveSelectedCompanyAccess.js';
import makeRunner from '../runner.js';
import shape from './shape.js';
export default function list(provider) {
const access = resolveSelectedCompanyAccess(provider);
const sql = provider?.dialect === 'sqlite3' ? SQLITE_LIST : MSSQL_LIST;
/**
* Lists the user's own model conversations in the selected company, newest activity first.
*
* @param {number} googleAuthId - The id of the Google auth user.
* @param {object} [tx] - Optional transaction to run within.
* @returns {Promise<Array<{id: number, companyuser_id: number, provider: string, model: string, created_at: string, updated_at: string, state: string}>>}
*
* @example
* const conversations = await store.modelconversation.list(42);
*/
return async (googleAuthId, tx) => {
const runner = makeRunner(provider, tx);
const { companyuserId } = await access(googleAuthId, runner);
const result = await runner.query(sql, { companyuserId });
return result.rows.map(shape);
};
}