|
24 | 24 | import { describe, it, expect, beforeEach } from 'vitest'; |
25 | 25 | import { ObjectStackProtocolImplementation } from '@objectstack/metadata-protocol'; |
26 | 26 | import { QuerySchema, FullTextSearchSchema } from '@objectstack/spec/data'; |
| 27 | +import type { EngineQueryOptions, EngineCountOptions, EngineAggregateOptions } from '@objectstack/spec/data'; |
27 | 28 | import { mapDataError } from '@objectstack/types'; |
28 | 29 | import { ObjectQL } from './engine.js'; |
29 | 30 |
|
@@ -119,13 +120,17 @@ const COUNT = [{ function: 'count' as const, alias: 'n' }]; |
119 | 120 | type Verb = 'find' | 'findOne' | 'count' | 'aggregate'; |
120 | 121 | const VERBS: readonly Verb[] = ['find', 'findOne', 'count', 'aggregate']; |
121 | 122 |
|
122 | | -/** Run one verb with the search keys in `bag`. */ |
| 123 | +/** |
| 124 | + * Run one verb with the search keys in `bag`. Deliberately off-contract: the |
| 125 | + * bags carry the comma-string and `null` spellings the engine-side declaration |
| 126 | + * does not admit, as the wire path hands them over. |
| 127 | + */ |
123 | 128 | function run(engine: ObjectQL, verb: Verb, bag: Record<string, unknown>): Promise<unknown> { |
124 | 129 | switch (verb) { |
125 | | - case 'find': return engine.find(account.name, bag as any); |
126 | | - case 'findOne': return engine.findOne(account.name, bag as any); |
127 | | - case 'count': return engine.count(account.name, bag as any); |
128 | | - case 'aggregate': return engine.aggregate(account.name, { groupBy: ['region'], aggregations: COUNT, ...bag } as any); |
| 130 | + case 'find': return engine.find(account.name, bag as unknown as EngineQueryOptions); |
| 131 | + case 'findOne': return engine.findOne(account.name, bag as unknown as EngineQueryOptions); |
| 132 | + case 'count': return engine.count(account.name, bag as unknown as EngineCountOptions); |
| 133 | + case 'aggregate': return engine.aggregate(account.name, { groupBy: ['region'], aggregations: COUNT, ...bag } as unknown as EngineAggregateOptions); |
129 | 134 | } |
130 | 135 | } |
131 | 136 |
|
|
0 commit comments