Skip to content

Commit e0b0a78

Browse files
Copilothotlong
andcommitted
fix: normalize top→limit in protocol, add changeset, fix studio integration tests
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com> Agent-Logs-Url: https://github.com/objectstack-ai/spec/sessions/4edae9dd-77f3-4fb8-b504-51c1ee902836
1 parent e652547 commit e0b0a78

File tree

4 files changed

+37
-6
lines changed

4 files changed

+37
-6
lines changed

.changeset/queryast-convergence.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
"@objectstack/spec": minor
3+
"@objectstack/core": minor
4+
"@objectstack/objectql": minor
5+
"@objectstack/client": minor
6+
"@objectstack/runtime": patch
7+
"@objectstack/plugin-auth": patch
8+
---
9+
10+
Deprecate DataEngineQueryOptions in favor of QueryAST-aligned EngineQueryOptions.
11+
12+
Engine, Protocol, and Client now use standard QueryAST parameter names:
13+
- `filter``where`
14+
- `select``fields`
15+
- `sort``orderBy`
16+
- `skip``offset`
17+
- `populate``expand`
18+
- `top``limit`
19+
20+
The old DataEngine* schemas and types are preserved with `@deprecated` markers for backward compatibility.

packages/objectql/src/engine.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,11 @@ export class ObjectQL implements IDataEngine {
752752
const ast: QueryAST = { object, ...query };
753753
// Remove context from the AST — it's not a driver concern
754754
delete (ast as any).context;
755+
// Normalize OData `top` alias → standard `limit`
756+
if ((ast as any).top != null && ast.limit == null) {
757+
ast.limit = (ast as any).top;
758+
}
759+
delete (ast as any).top;
755760

756761
const opCtx: OperationContext = {
757762
object,
@@ -799,8 +804,9 @@ export class ObjectQL implements IDataEngine {
799804
this.logger.debug('FindOne operation', { objectName });
800805
const driver = this.getDriver(objectName);
801806
const ast: QueryAST = { object: objectName, ...query, limit: 1 };
802-
// Remove context from the AST — it's not a driver concern
807+
// Remove context and top alias from the AST
803808
delete (ast as any).context;
809+
delete (ast as any).top;
804810

805811
const opCtx: OperationContext = {
806812
object: objectName,

packages/objectql/src/protocol-data.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ describe('ObjectStackProtocolImplementation - Data Operations', () => {
118118
expect(mockEngine.find).toHaveBeenCalledWith(
119119
'task',
120120
expect.objectContaining({
121-
top: 10,
121+
limit: 10,
122122
offset: 20,
123123
}),
124124
);

packages/objectql/src/protocol.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,10 +283,15 @@ export class ObjectStackProtocolImplementation implements ObjectStackProtocol {
283283
// Normalize legacy params → QueryAST standard (where/fields/orderBy/offset/expand)
284284
// ====================================================================
285285

286-
// Numeric fields
287-
if (options.top != null) options.top = Number(options.top);
288-
if (options.skip != null) options.offset = Number(options.skip);
289-
delete options.skip;
286+
// Numeric fields — normalize top → limit, skip → offset
287+
if (options.top != null) {
288+
options.limit = Number(options.top);
289+
delete options.top;
290+
}
291+
if (options.skip != null) {
292+
options.offset = Number(options.skip);
293+
delete options.skip;
294+
}
290295
if (options.limit != null) options.limit = Number(options.limit);
291296
if (options.offset != null) options.offset = Number(options.offset);
292297

0 commit comments

Comments
 (0)