Skip to content

Commit cafaf88

Browse files
committed
test(rest): type the aggregate options in the groupBy door pin instead of erasing them
Claude-Session: https://claude.ai/code/session_01DEvba2nBuD4tWzfq8r8NFY Co-authored-by: Claude <noreply@anthropic.com>
1 parent 1eacad5 commit cafaf88

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎packages/rest/src/data-group-by-json-door.test.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
*/
3636

3737
import { describe, it, expect, beforeAll, afterAll } from 'vitest';
38+
import type { EngineAggregateOptions } from '@objectstack/spec/data';
3839
import { ObjectQL } from '@objectstack/objectql';
3940
import { SqlDriver } from '@objectstack/driver-sql';
4041
import { ObjectStackProtocolImplementation } from '@objectstack/metadata-protocol';
@@ -68,7 +69,7 @@ const ROWS = [
6869
{ id: 'd3', title: 'y', meta: { b: 1 }, spec: { k: 1 }, rep: [{ q: 1 }], rec: { r: 1 }, loc: { lat: 1, lng: 2 }, ship_to: { city: 'Paris' }, vec: [1, 2] },
6970
];
7071

71-
const COUNT = [{ function: 'count', alias: 'n' }];
72+
const COUNT: EngineAggregateOptions['aggregations'] = [{ function: 'count', alias: 'n' }];
7273

7374
/** The route the refusal names — asserted on the REST body, so it must land inside the door's 500-character bound. */
7475
const ROUTE = 'Group by a field that stores one scalar value: store the part you group on in a field of its own and group by that field.';
@@ -169,7 +170,7 @@ for (const cell of CELLS) {
169170
expect(res.body.code, field).toBe('INVALID_FIELD');
170171
expect(res.body.error, field).toContain(`groupBy[0] names '${field}', a declared ${type} field`);
171172
expect(res.body.error, field).toContain(ROUTE);
172-
const err = await engine.aggregate(OBJECT, { groupBy: [field], aggregations: COUNT } as any).then(() => null, (e: any) => e);
173+
const err = await engine.aggregate(OBJECT, { groupBy: [field], aggregations: COUNT }).then(() => null, (e: any) => e);
173174
expect({ code: err?.code, status: err?.status }, `engine.aggregate, ${field}`).toEqual({ code: 'INVALID_FIELD', status: 400 });
174175
}
175176
expect(reads.n - before, 'no read of the object — every refusal precedes the driver').toBe(0);

0 commit comments

Comments
 (0)