Skip to content

Commit a43bf0a

Browse files
committed
test(objectql): name the contract the off-contract search bags bypass
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cyzHgmAWpXVdUctRKU
1 parent bdbb479 commit a43bf0a

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

‎packages/objectql/src/engine-empty-search-fields-refusal.test.ts‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import { describe, it, expect, beforeEach } from 'vitest';
2525
import { ObjectStackProtocolImplementation } from '@objectstack/metadata-protocol';
2626
import { QuerySchema, FullTextSearchSchema } from '@objectstack/spec/data';
27+
import type { EngineQueryOptions, EngineCountOptions, EngineAggregateOptions } from '@objectstack/spec/data';
2728
import { mapDataError } from '@objectstack/types';
2829
import { ObjectQL } from './engine.js';
2930

@@ -119,13 +120,17 @@ const COUNT = [{ function: 'count' as const, alias: 'n' }];
119120
type Verb = 'find' | 'findOne' | 'count' | 'aggregate';
120121
const VERBS: readonly Verb[] = ['find', 'findOne', 'count', 'aggregate'];
121122

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+
*/
123128
function run(engine: ObjectQL, verb: Verb, bag: Record<string, unknown>): Promise<unknown> {
124129
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);
129134
}
130135
}
131136

0 commit comments

Comments
 (0)