Unify records model and add notification center

This commit is contained in:
Amer Agovic
2026-05-05 12:24:13 -05:00
parent 166ddcc803
commit 2157e1aea6
18 changed files with 962 additions and 544 deletions
@@ -1,6 +1,6 @@
import { describe, test } from 'node:test';
import assert from 'node:assert';
import { GridDataModel } from '../src/ui/components/grid/model.js';
import { RecordsModel } from '../src/data/index.js';
const rows = [
{ id: 1, name: 'Northwind', status: 'open', total: 1200 },
@@ -9,9 +9,9 @@ const rows = [
{ id: 4, name: 'Lattice', status: 'closed', total: 400 }
];
describe('GridDataModel', () => {
describe('RecordsModel', () => {
test('queryStructure infers columns from row data', async () => {
const model = new GridDataModel({ rows });
const model = new RecordsModel({ rows });
const result = await model.queryStructure();
assert.ok(result.columns.name);
@@ -21,7 +21,7 @@ describe('GridDataModel', () => {
});
test('queryRecords filters, sorts, and paginates', async () => {
const model = new GridDataModel({ rows });
const model = new RecordsModel({ rows });
const result = await model.queryRecords({
filter_by: { status: 'open' },
sort_by: [{ field: 'total', direction: 'desc' }],
@@ -35,7 +35,7 @@ describe('GridDataModel', () => {
});
test('queryRecords supports text search through search filter', async () => {
const model = new GridDataModel({ rows });
const model = new RecordsModel({ rows });
const result = await model.queryRecords({
filter_by: { search: 'harbor' }
});
@@ -44,14 +44,14 @@ describe('GridDataModel', () => {
assert.strictEqual(result.rows[0].name, 'Blue Harbor');
});
test('queryAggregates supports count and sum metrics', async () => {
const model = new GridDataModel({ rows });
const result = await model.queryAggregates({
metrics: ['count', 'sum:total'],
filter_by: { status: 'open' }
});
test('querySummary supports count and sum metrics', async () => {
const model = new RecordsModel({ rows });
const result = await model.querySummary(
{ filter_by: { status: 'open' } },
['count', 'sum:total']
);
assert.strictEqual(result.count, 2);
assert.strictEqual(result['sum:total'], 3600);
assert.strictEqual(result.values.count, 2);
assert.strictEqual(result.values['sum:total'], 3600);
});
});