@objectql/core 4.0.0 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -3
- package/README.md +13 -11
- package/dist/app.d.ts +1 -1
- package/dist/app.js +1 -1
- package/dist/app.js.map +1 -1
- package/dist/formula-plugin.d.ts +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.js.map +1 -1
- package/dist/plugin.d.ts +2 -2
- package/dist/plugin.js +40 -3
- package/dist/plugin.js.map +1 -1
- package/dist/query/filter-translator.d.ts +8 -18
- package/dist/query/filter-translator.js +6 -103
- package/dist/query/filter-translator.js.map +1 -1
- package/dist/query/query-analyzer.d.ts +3 -1
- package/dist/query/query-analyzer.js +24 -25
- package/dist/query/query-analyzer.js.map +1 -1
- package/dist/query/query-builder.d.ts +6 -3
- package/dist/query/query-builder.js +9 -35
- package/dist/query/query-builder.js.map +1 -1
- package/dist/query/query-service.d.ts +5 -3
- package/dist/query/query-service.js +5 -5
- package/dist/query/query-service.js.map +1 -1
- package/dist/repository.js +25 -6
- package/dist/repository.js.map +1 -1
- package/dist/validator-plugin.d.ts +1 -1
- package/jest.config.js +1 -1
- package/package.json +4 -5
- package/src/app.ts +3 -3
- package/src/formula-plugin.ts +1 -1
- package/src/index.ts +5 -2
- package/src/plugin.ts +50 -5
- package/src/query/filter-translator.ts +9 -115
- package/src/query/query-analyzer.ts +26 -28
- package/src/query/query-builder.ts +11 -41
- package/src/query/query-service.ts +7 -6
- package/src/repository.ts +28 -8
- package/src/validator-plugin.ts +1 -1
- package/test/__mocks__/@objectstack/runtime.ts +1 -1
- package/test/app.test.ts +2 -1
- package/test/formula-integration.test.ts +6 -6
- package/test/formula-plugin.test.ts +1 -1
- package/test/formula-spec-compliance.test.ts +258 -0
- package/test/validation-spec-compliance.test.ts +440 -0
- package/test/validator-plugin.test.ts +1 -1
- package/tsconfig.json +0 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/IMPLEMENTATION_STATUS.md +0 -364
- package/RUNTIME_INTEGRATION.md +0 -391
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
# @objectql/core
|
|
2
2
|
|
|
3
|
+
## 4.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- **Patch Release v4.0.2**
|
|
8
|
+
|
|
9
|
+
This patch release includes:
|
|
10
|
+
- Infrastructure improvements and maintenance updates
|
|
11
|
+
- Enhanced stability and reliability
|
|
12
|
+
- Bug fixes and performance optimizations
|
|
13
|
+
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
- @objectql/types@4.0.2
|
|
16
|
+
|
|
17
|
+
## 4.0.1
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- **Release Version 4.0.1**
|
|
22
|
+
|
|
23
|
+
This patch release includes the latest repository improvements and infrastructure updates:
|
|
24
|
+
- Added comprehensive GitHub workflows for CI/CD, testing, and quality assurance
|
|
25
|
+
- Enhanced documentation and developer experience
|
|
26
|
+
- Improved build and release processes with Changesets
|
|
27
|
+
- Added Excel driver for reading/writing Excel files as data sources
|
|
28
|
+
- Repository structure and tooling improvements
|
|
29
|
+
- Bug fixes and stability enhancements
|
|
30
|
+
|
|
31
|
+
- Updated dependencies
|
|
32
|
+
- @objectql/types@4.0.1
|
|
33
|
+
|
|
3
34
|
## 3.0.1
|
|
4
35
|
|
|
5
36
|
### Patch Changes
|
|
@@ -7,7 +38,6 @@
|
|
|
7
38
|
- 79d04e1: Patch release for January 2026 updates
|
|
8
39
|
|
|
9
40
|
This patch includes minor improvements and maintenance updates:
|
|
10
|
-
|
|
11
41
|
- Enhanced type safety across core packages
|
|
12
42
|
- Improved error handling in drivers
|
|
13
43
|
- Documentation updates
|
|
@@ -30,7 +60,6 @@
|
|
|
30
60
|
This is a coordinated major release that unifies all ObjectQL packages to version 2.0.0, establishing a synchronized versioning strategy across the entire ecosystem.
|
|
31
61
|
|
|
32
62
|
### 🎯 Key Changes
|
|
33
|
-
|
|
34
63
|
- **Unified Versioning**: All core packages now share the same version number (2.0.0)
|
|
35
64
|
- **Fixed Group Management**: Updated changeset configuration to include all @objectql packages in the fixed versioning group
|
|
36
65
|
- **Simplified Maintenance**: Future releases will automatically maintain version consistency across the entire monorepo
|
|
@@ -38,7 +67,6 @@
|
|
|
38
67
|
### 📦 Packages Included
|
|
39
68
|
|
|
40
69
|
All ObjectQL packages are now synchronized at version 2.0.0:
|
|
41
|
-
|
|
42
70
|
- Foundation: `@objectql/types`, `@objectql/core`, `@objectql/platform-node`
|
|
43
71
|
- Drivers: `@objectql/driver-sql`, `@objectql/driver-mongo`, `@objectql/driver-redis`, `@objectql/driver-fs`, `@objectql/driver-memory`, `@objectql/driver-localstorage`, `@objectql/driver-excel`, `@objectql/sdk`
|
|
44
72
|
- Runtime: `@objectql/server`
|
package/README.md
CHANGED
|
@@ -1,28 +1,30 @@
|
|
|
1
1
|
# @objectql/core
|
|
2
2
|
|
|
3
|
+
> **Implementation Status**: ✅ **Production Ready** - All core features fully implemented and tested. See [Implementation Status](https://github.com/objectstack-ai/objectql/blob/main/IMPLEMENTATION_STATUS.md) for complete details.
|
|
4
|
+
|
|
3
5
|
The core ORM and runtime engine for ObjectQL. This package handles object querying, CRUD operations, database driver coordination, transaction management, and **metadata-driven validation**. As of version 4.0.0, it wraps the **ObjectStackKernel** for plugin architecture and lifecycle management.
|
|
4
6
|
|
|
5
7
|
## Features
|
|
6
8
|
|
|
7
|
-
- **Plugin Architecture**: Built on top of `@
|
|
8
|
-
- **Unified Query Language**: A generic way to query data across different databases (SQL, Mongo, etc.)
|
|
9
|
-
- **Repository Pattern**: `ObjectRepository` for managing object records
|
|
10
|
-
- **Driver Agnostic**: Abstraction layer for database drivers
|
|
11
|
-
- **Dynamic Schema**: Loads object definitions from metadata
|
|
12
|
-
- **Hooks & Actions**: Runtime logic injection
|
|
13
|
-
- **Validation Engine**: Metadata-driven validation with field-level, cross-field, and state machine rules
|
|
14
|
-
- **Formula Engine**: Computed fields with dynamic formulas
|
|
15
|
-
- **AI Integration**: Built-in AI agent capabilities
|
|
9
|
+
- ✅ **Plugin Architecture**: Built on top of `@objectql/runtime` with kernel-based plugin system
|
|
10
|
+
- ✅ **Unified Query Language**: A generic way to query data across different databases (SQL, Mongo, etc.)
|
|
11
|
+
- ✅ **Repository Pattern**: `ObjectRepository` for managing object records
|
|
12
|
+
- ✅ **Driver Agnostic**: Abstraction layer for database drivers
|
|
13
|
+
- ✅ **Dynamic Schema**: Loads object definitions from metadata
|
|
14
|
+
- ✅ **Hooks & Actions**: Runtime logic injection - fully implemented
|
|
15
|
+
- ✅ **Validation Engine**: Metadata-driven validation with field-level, cross-field, and state machine rules
|
|
16
|
+
- ✅ **Formula Engine**: Computed fields with dynamic formulas
|
|
17
|
+
- ✅ **AI Integration**: Built-in AI agent capabilities for code generation
|
|
16
18
|
|
|
17
19
|
## Installation
|
|
18
20
|
|
|
19
21
|
```bash
|
|
20
|
-
npm install @objectql/core @objectql/types @
|
|
22
|
+
npm install @objectql/core @objectql/types @objectql/runtime @objectstack/spec
|
|
21
23
|
```
|
|
22
24
|
|
|
23
25
|
## Architecture
|
|
24
26
|
|
|
25
|
-
ObjectQL now wraps the `ObjectStackKernel` from `@
|
|
27
|
+
ObjectQL now wraps the `ObjectStackKernel` from `@objectql/runtime`, providing:
|
|
26
28
|
|
|
27
29
|
- **Kernel-based lifecycle management**: Initialization, startup, and shutdown
|
|
28
30
|
- **Plugin system**: Extensible architecture with `ObjectQLPlugin`
|
package/dist/app.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
import { MetadataRegistry, Driver, ObjectConfig, ObjectQLContext, ObjectQLContextOptions, IObjectQL, ObjectQLConfig, HookName, HookHandler, HookContext, ActionHandler, ActionContext } from '@objectql/types';
|
|
9
|
-
import { ObjectStackKernel, type RuntimePlugin } from '@
|
|
9
|
+
import { ObjectStackKernel, type RuntimePlugin } from '@objectql/runtime';
|
|
10
10
|
/**
|
|
11
11
|
* ObjectQL
|
|
12
12
|
*
|
package/dist/app.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.ObjectQL = void 0;
|
|
11
|
-
const runtime_1 = require("@
|
|
11
|
+
const runtime_1 = require("@objectql/runtime");
|
|
12
12
|
const repository_1 = require("./repository");
|
|
13
13
|
const plugin_1 = require("./plugin");
|
|
14
14
|
const util_1 = require("./util");
|
package/dist/app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAkBH
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAkBH,+CAA0E;AAC1E,6CAAgD;AAChD,qCAA0C;AAC1C,iCAA4D;AAE5D;;;;;GAKG;AACH,MAAa,QAAQ;IACjB,sDAAsD;IACtD,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;IAChC,CAAC;IAYD,YAAY,MAAsB;QAV1B,gBAAW,GAA2B,EAAE,CAAC;QACzC,YAAO,GAAa,EAAE,CAAC;QAIvB,kBAAa,GAAoB,EAAE,CAAC;QAMxC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,IAAI,EAAE,CAAC;QAE5C,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,6JAA6J,CAAC,CAAC;QACpL,CAAC;QAED,uDAAuD;QACvD,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,uBAAc,CAAC;YACvC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;gBACrD,OAAO,CAAC,IAAI,CAAC,8BAA8B,EAAE,KAAK,CAAC,CAAC;gBACpD,SAAS;YACb,CAAC;YAED,MAAM,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;YAEpC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;gBAC3B,IAAI,CAAC;oBACD,+CAA+C;oBAC/C,sDAAsD;oBACtD,sEAAsE;oBACtE,6DAA6D;oBAE7D,sFAAsF;oBACtF,oEAAoE;oBACpE,0CAA0C;oBAC1C,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;oBAC1B,OAAO,CAAC,GAAG,CAAC,0BAA0B,UAAU,EAAE,CAAC,CAAC;gBACxD,CAAC;gBAAC,OAAO,CAAM,EAAE,CAAC;oBACd,2CAA2C;oBAC1C,OAAO,CAAC,IAAI,CAAC,qCAAqC,UAAU,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;gBACnF,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;CACJ;AApVD,4BAoVC"}
|
package/dist/formula-plugin.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
|
-
import type { RuntimePlugin, RuntimeContext } from '@
|
|
8
|
+
import type { RuntimePlugin, RuntimeContext } from '@objectql/runtime';
|
|
9
9
|
import { FormulaEngine } from './formula-engine';
|
|
10
10
|
import type { FormulaEngineConfig } from '@objectql/types';
|
|
11
11
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -5,8 +5,11 @@
|
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
|
-
export type { ObjectStackKernel, ObjectStackRuntimeProtocol } from '@
|
|
9
|
-
|
|
8
|
+
export type { ObjectStackKernel, ObjectStackRuntimeProtocol } from '@objectql/runtime';
|
|
9
|
+
import { Data, Driver } from '@objectstack/spec';
|
|
10
|
+
export type QueryAST = Data.QueryAST;
|
|
11
|
+
export type DriverInterface = Driver.DriverInterface;
|
|
12
|
+
export type DriverOptions = Driver.DriverOptions;
|
|
10
13
|
export * from './repository';
|
|
11
14
|
export * from './app';
|
|
12
15
|
export * from './plugin';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;AAcH,kEAAkE;AAClE,+CAA6B;AAC7B,wCAAsB;AACtB,2CAAyB;AACzB,qDAAmC;AACnC,mDAAiC;AAEjC,2DAA2D;AAC3D,0CAAwB;AAExB,mBAAmB;AACnB,8CAA4B;AAC5B,yCAAuB;AACvB,6CAA2B;AAC3B,mDAAiC"}
|
package/dist/plugin.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
|
-
import type { RuntimePlugin, RuntimeContext } from '@
|
|
8
|
+
import type { RuntimePlugin, RuntimeContext } from '@objectql/runtime';
|
|
9
9
|
import { ValidatorPluginConfig } from './validator-plugin';
|
|
10
10
|
import { FormulaPluginConfig } from './formula-plugin';
|
|
11
11
|
import type { Driver } from '@objectql/types';
|
|
@@ -57,7 +57,7 @@ export interface ObjectQLPluginConfig {
|
|
|
57
57
|
/**
|
|
58
58
|
* ObjectQL Plugin
|
|
59
59
|
*
|
|
60
|
-
* Implements the RuntimePlugin interface from @
|
|
60
|
+
* Implements the RuntimePlugin interface from @objectql/runtime
|
|
61
61
|
* to provide ObjectQL's enhanced features (Repository, Validator, Formula, AI)
|
|
62
62
|
* on top of the ObjectStack kernel.
|
|
63
63
|
*/
|
package/dist/plugin.js
CHANGED
|
@@ -15,7 +15,7 @@ const query_analyzer_1 = require("./query/query-analyzer");
|
|
|
15
15
|
/**
|
|
16
16
|
* ObjectQL Plugin
|
|
17
17
|
*
|
|
18
|
-
* Implements the RuntimePlugin interface from @
|
|
18
|
+
* Implements the RuntimePlugin interface from @objectql/runtime
|
|
19
19
|
* to provide ObjectQL's enhanced features (Repository, Validator, Formula, AI)
|
|
20
20
|
* on top of the ObjectStack kernel.
|
|
21
21
|
*/
|
|
@@ -81,8 +81,45 @@ class ObjectQLPlugin {
|
|
|
81
81
|
* @private
|
|
82
82
|
*/
|
|
83
83
|
async registerRepository(kernel) {
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
if (!this.config.datasources) {
|
|
85
|
+
console.log(`[${this.name}] No datasources configured, skipping repository registration`);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const datasources = this.config.datasources;
|
|
89
|
+
// Helper function to get the driver for an object
|
|
90
|
+
const getDriver = (objectName) => {
|
|
91
|
+
const objectConfig = kernel.metadata.get('object', objectName);
|
|
92
|
+
const datasourceName = (objectConfig === null || objectConfig === void 0 ? void 0 : objectConfig.datasource) || 'default';
|
|
93
|
+
const driver = datasources[datasourceName];
|
|
94
|
+
if (!driver) {
|
|
95
|
+
throw new Error(`Datasource '${datasourceName}' not found for object '${objectName}'`);
|
|
96
|
+
}
|
|
97
|
+
return driver;
|
|
98
|
+
};
|
|
99
|
+
// Override kernel CRUD methods to use drivers
|
|
100
|
+
kernel.create = async (objectName, data) => {
|
|
101
|
+
const driver = getDriver(objectName);
|
|
102
|
+
return await driver.create(objectName, data, {});
|
|
103
|
+
};
|
|
104
|
+
kernel.update = async (objectName, id, data) => {
|
|
105
|
+
const driver = getDriver(objectName);
|
|
106
|
+
return await driver.update(objectName, id, data, {});
|
|
107
|
+
};
|
|
108
|
+
kernel.delete = async (objectName, id) => {
|
|
109
|
+
const driver = getDriver(objectName);
|
|
110
|
+
const result = await driver.delete(objectName, id, {});
|
|
111
|
+
return !!result;
|
|
112
|
+
};
|
|
113
|
+
kernel.find = async (objectName, query) => {
|
|
114
|
+
const driver = getDriver(objectName);
|
|
115
|
+
const value = await driver.find(objectName, query);
|
|
116
|
+
const count = value.length;
|
|
117
|
+
return { value, count };
|
|
118
|
+
};
|
|
119
|
+
kernel.get = async (objectName, id) => {
|
|
120
|
+
const driver = getDriver(objectName);
|
|
121
|
+
return await driver.findOne(objectName, id);
|
|
122
|
+
};
|
|
86
123
|
console.log(`[${this.name}] Repository pattern registered`);
|
|
87
124
|
}
|
|
88
125
|
/**
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAIH,yDAA4E;AAC5E,qDAAsE;AACtE,yDAAqD;AACrD,2DAAuD;AAgEvD;;;;;;GAMG;AACH,MAAa,cAAc;IAIzB,YAAoB,SAA+B,EAAE;QAAjC,WAAM,GAAN,MAAM,CAA2B;QAHrD,SAAI,GAAG,gBAAgB,CAAC;QACxB,YAAO,GAAG,OAAO,CAAC;QAGhB,eAAe;QACf,IAAI,CAAC,MAAM,GAAG;YACZ,gBAAgB,EAAE,IAAI;YACtB,eAAe,EAAE,IAAI;YACrB,cAAc,EAAE,IAAI;YACpB,QAAQ,EAAE,IAAI;YACd,kBAAkB,EAAE,IAAI;YACxB,GAAG,MAAM;SACV,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,OAAO,CAAC,GAAmB;QAC/B,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,IAAI,wBAAwB,CAAC,CAAC;QAEnD,MAAM,MAAM,GAAG,GAAG,CAAC,MAAwB,CAAC;QAE5C,qDAAqD;QACrD,IAAI,IAAI,CAAC,MAAM,CAAC,kBAAkB,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source tree.
|
|
7
7
|
*/
|
|
8
8
|
import type { Filter } from '@objectql/types';
|
|
9
|
-
import
|
|
9
|
+
import { Data } from '@objectstack/spec';
|
|
10
|
+
type FilterCondition = Data.FilterCondition;
|
|
10
11
|
/**
|
|
11
12
|
* Filter Translator
|
|
12
13
|
*
|
|
13
|
-
* Translates ObjectQL Filter
|
|
14
|
-
*
|
|
14
|
+
* Translates ObjectQL Filter to ObjectStack FilterCondition format.
|
|
15
|
+
* Since both now use the same format, this is mostly a pass-through.
|
|
15
16
|
*
|
|
16
17
|
* @example
|
|
17
18
|
* Input: { age: { $gte: 18 }, $or: [{ status: "active" }, { role: "admin" }] }
|
|
18
|
-
* Output:
|
|
19
|
+
* Output: { age: { $gte: 18 }, $or: [{ status: "active" }, { role: "admin" }] }
|
|
19
20
|
*/
|
|
20
21
|
export declare class FilterTranslator {
|
|
21
22
|
/**
|
|
22
|
-
* Translate filters from ObjectQL format to ObjectStack
|
|
23
|
+
* Translate filters from ObjectQL format to ObjectStack FilterCondition format
|
|
23
24
|
*/
|
|
24
|
-
translate(filters?: Filter):
|
|
25
|
-
/**
|
|
26
|
-
* Recursively converts FilterCondition to FilterNode array format
|
|
27
|
-
*/
|
|
28
|
-
private convertToNode;
|
|
29
|
-
/**
|
|
30
|
-
* Interleaves filter nodes with a logical operator
|
|
31
|
-
*/
|
|
32
|
-
private interleaveWithOperator;
|
|
33
|
-
/**
|
|
34
|
-
* Maps modern $-prefixed operators to legacy format
|
|
35
|
-
*/
|
|
36
|
-
private mapOperatorToLegacy;
|
|
25
|
+
translate(filters?: Filter): FilterCondition | undefined;
|
|
37
26
|
}
|
|
27
|
+
export {};
|
|
@@ -8,127 +8,30 @@
|
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.FilterTranslator = void 0;
|
|
11
|
-
const types_1 = require("@objectql/types");
|
|
12
11
|
/**
|
|
13
12
|
* Filter Translator
|
|
14
13
|
*
|
|
15
|
-
* Translates ObjectQL Filter
|
|
16
|
-
*
|
|
14
|
+
* Translates ObjectQL Filter to ObjectStack FilterCondition format.
|
|
15
|
+
* Since both now use the same format, this is mostly a pass-through.
|
|
17
16
|
*
|
|
18
17
|
* @example
|
|
19
18
|
* Input: { age: { $gte: 18 }, $or: [{ status: "active" }, { role: "admin" }] }
|
|
20
|
-
* Output:
|
|
19
|
+
* Output: { age: { $gte: 18 }, $or: [{ status: "active" }, { role: "admin" }] }
|
|
21
20
|
*/
|
|
22
21
|
class FilterTranslator {
|
|
23
22
|
/**
|
|
24
|
-
* Translate filters from ObjectQL format to ObjectStack
|
|
23
|
+
* Translate filters from ObjectQL format to ObjectStack FilterCondition format
|
|
25
24
|
*/
|
|
26
25
|
translate(filters) {
|
|
27
26
|
if (!filters) {
|
|
28
27
|
return undefined;
|
|
29
28
|
}
|
|
30
|
-
// Backward compatibility: if it's already an array (old format), pass through
|
|
31
|
-
if (Array.isArray(filters)) {
|
|
32
|
-
return filters;
|
|
33
|
-
}
|
|
34
29
|
// If it's an empty object, return undefined
|
|
35
30
|
if (typeof filters === 'object' && Object.keys(filters).length === 0) {
|
|
36
31
|
return undefined;
|
|
37
32
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Recursively converts FilterCondition to FilterNode array format
|
|
42
|
-
*/
|
|
43
|
-
convertToNode(filter) {
|
|
44
|
-
const nodes = [];
|
|
45
|
-
// Process logical operators first
|
|
46
|
-
if (filter.$and) {
|
|
47
|
-
const andNodes = filter.$and.map((f) => this.convertToNode(f));
|
|
48
|
-
nodes.push(...this.interleaveWithOperator(andNodes, 'and'));
|
|
49
|
-
}
|
|
50
|
-
if (filter.$or) {
|
|
51
|
-
const orNodes = filter.$or.map((f) => this.convertToNode(f));
|
|
52
|
-
if (nodes.length > 0) {
|
|
53
|
-
nodes.push('and');
|
|
54
|
-
}
|
|
55
|
-
nodes.push(...this.interleaveWithOperator(orNodes, 'or'));
|
|
56
|
-
}
|
|
57
|
-
// Note: $not operator is not currently supported in the legacy FilterNode format
|
|
58
|
-
if (filter.$not) {
|
|
59
|
-
throw new types_1.ObjectQLError({
|
|
60
|
-
code: 'UNSUPPORTED_OPERATOR',
|
|
61
|
-
message: '$not operator is not supported. Use $ne for field negation instead.'
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
// Process field conditions
|
|
65
|
-
for (const [field, value] of Object.entries(filter)) {
|
|
66
|
-
if (field.startsWith('$')) {
|
|
67
|
-
continue; // Skip logical operators (already processed)
|
|
68
|
-
}
|
|
69
|
-
if (nodes.length > 0) {
|
|
70
|
-
nodes.push('and');
|
|
71
|
-
}
|
|
72
|
-
// Handle field value
|
|
73
|
-
if (value === null || value === undefined) {
|
|
74
|
-
nodes.push([field, '=', value]);
|
|
75
|
-
}
|
|
76
|
-
else if (typeof value === 'object' && !Array.isArray(value) && !(value instanceof Date)) {
|
|
77
|
-
// Explicit operators - multiple operators on same field are AND-ed together
|
|
78
|
-
const entries = Object.entries(value);
|
|
79
|
-
for (let i = 0; i < entries.length; i++) {
|
|
80
|
-
const [op, opValue] = entries[i];
|
|
81
|
-
// Add 'and' before each operator (except the very first node)
|
|
82
|
-
if (nodes.length > 0 || i > 0) {
|
|
83
|
-
nodes.push('and');
|
|
84
|
-
}
|
|
85
|
-
const legacyOp = this.mapOperatorToLegacy(op);
|
|
86
|
-
nodes.push([field, legacyOp, opValue]);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
// Implicit equality
|
|
91
|
-
nodes.push([field, '=', value]);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
// Return as FilterNode (type assertion for backward compatibility)
|
|
95
|
-
return (nodes.length === 1 ? nodes[0] : nodes);
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Interleaves filter nodes with a logical operator
|
|
99
|
-
*/
|
|
100
|
-
interleaveWithOperator(nodes, operator) {
|
|
101
|
-
if (nodes.length === 0)
|
|
102
|
-
return [];
|
|
103
|
-
if (nodes.length === 1)
|
|
104
|
-
return [nodes[0]];
|
|
105
|
-
const result = [nodes[0]];
|
|
106
|
-
for (let i = 1; i < nodes.length; i++) {
|
|
107
|
-
result.push(operator, nodes[i]);
|
|
108
|
-
}
|
|
109
|
-
return result;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Maps modern $-prefixed operators to legacy format
|
|
113
|
-
*/
|
|
114
|
-
mapOperatorToLegacy(operator) {
|
|
115
|
-
const mapping = {
|
|
116
|
-
'$eq': '=',
|
|
117
|
-
'$ne': '!=',
|
|
118
|
-
'$gt': '>',
|
|
119
|
-
'$gte': '>=',
|
|
120
|
-
'$lt': '<',
|
|
121
|
-
'$lte': '<=',
|
|
122
|
-
'$in': 'in',
|
|
123
|
-
'$nin': 'nin',
|
|
124
|
-
'$contains': 'contains',
|
|
125
|
-
'$startsWith': 'startswith',
|
|
126
|
-
'$endsWith': 'endswith',
|
|
127
|
-
'$null': 'is_null',
|
|
128
|
-
'$exist': 'is_not_null',
|
|
129
|
-
'$between': 'between',
|
|
130
|
-
};
|
|
131
|
-
return mapping[operator] || operator.replace('$', '');
|
|
33
|
+
// Both ObjectQL Filter and ObjectStack FilterCondition use the same format now
|
|
34
|
+
return filters;
|
|
132
35
|
}
|
|
133
36
|
}
|
|
134
37
|
exports.FilterTranslator = FilterTranslator;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter-translator.js","sourceRoot":"","sources":["../../src/query/filter-translator.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;
|
|
1
|
+
{"version":3,"file":"filter-translator.js","sourceRoot":"","sources":["../../src/query/filter-translator.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAOH;;;;;;;;;GASG;AACH,MAAa,gBAAgB;IACzB;;OAEG;IACH,SAAS,CAAC,OAAgB;QACtB,IAAI,CAAC,OAAO,EAAE,CAAC;YACX,OAAO,SAAS,CAAC;QACrB,CAAC;QAED,4CAA4C;QAC5C,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACnE,OAAO,SAAS,CAAC;QACrB,CAAC;QAED,+EAA+E;QAC/E,OAAO,OAAqC,CAAC;IACjD,CAAC;CACJ;AAjBD,4CAiBC"}
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
import type { UnifiedQuery, MetadataRegistry } from '@objectql/types';
|
|
9
|
-
import
|
|
9
|
+
import { Data } from '@objectstack/spec';
|
|
10
|
+
type QueryAST = Data.QueryAST;
|
|
10
11
|
import { QueryService, QueryOptions } from './query-service';
|
|
11
12
|
/**
|
|
12
13
|
* Query execution plan
|
|
@@ -184,3 +185,4 @@ export declare class QueryAnalyzer {
|
|
|
184
185
|
*/
|
|
185
186
|
private recordExecution;
|
|
186
187
|
}
|
|
188
|
+
export {};
|
|
@@ -45,10 +45,10 @@ class QueryAnalyzer {
|
|
|
45
45
|
// Build the QueryAST (without executing)
|
|
46
46
|
const ast = {
|
|
47
47
|
object: objectName,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
where: query.where, // FilterCondition format
|
|
49
|
+
orderBy: query.orderBy, // Will be converted to SortNode[] format
|
|
50
|
+
limit: query.limit,
|
|
51
|
+
offset: query.offset,
|
|
52
52
|
fields: query.fields
|
|
53
53
|
};
|
|
54
54
|
// Analyze filters for index usage
|
|
@@ -144,7 +144,7 @@ class QueryAnalyzer {
|
|
|
144
144
|
*/
|
|
145
145
|
findApplicableIndexes(schema, query) {
|
|
146
146
|
const indexes = [];
|
|
147
|
-
if (!schema.indexes || !query.
|
|
147
|
+
if (!schema.indexes || !query.where) {
|
|
148
148
|
return indexes;
|
|
149
149
|
}
|
|
150
150
|
// Extract fields used in filters
|
|
@@ -170,7 +170,7 @@ class QueryAnalyzer {
|
|
|
170
170
|
filterFields.add(key);
|
|
171
171
|
}
|
|
172
172
|
};
|
|
173
|
-
extractFieldsFromFilter(query.
|
|
173
|
+
extractFieldsFromFilter(query.where);
|
|
174
174
|
// Check which indexes could be used
|
|
175
175
|
const indexesArray = Array.isArray(schema.indexes) ? schema.indexes : Object.values(schema.indexes || {});
|
|
176
176
|
for (const index of indexesArray) {
|
|
@@ -192,7 +192,7 @@ class QueryAnalyzer {
|
|
|
192
192
|
analyzeWarnings(schema, query) {
|
|
193
193
|
const warnings = [];
|
|
194
194
|
// Warning: No filters (full table scan)
|
|
195
|
-
if (!query.
|
|
195
|
+
if (!query.where || Object.keys(query.where).length === 0) {
|
|
196
196
|
warnings.push('No filters specified - this will scan all records');
|
|
197
197
|
}
|
|
198
198
|
// Warning: No limit on potentially large dataset
|
|
@@ -207,7 +207,7 @@ class QueryAnalyzer {
|
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
209
|
// Warning: Complex filters without indexes
|
|
210
|
-
if (query.
|
|
210
|
+
if (query.where && Object.keys(query.where).length > 5) {
|
|
211
211
|
const indexes = this.findApplicableIndexes(schema, query);
|
|
212
212
|
if (indexes.length === 0) {
|
|
213
213
|
warnings.push('Complex filters without matching indexes - consider adding indexes');
|
|
@@ -226,10 +226,8 @@ class QueryAnalyzer {
|
|
|
226
226
|
suggestions.push('Add a limit clause to restrict result set size');
|
|
227
227
|
}
|
|
228
228
|
// Suggest adding indexes
|
|
229
|
-
if (query.
|
|
230
|
-
const filterFields = query.
|
|
231
|
-
.filter((f) => Array.isArray(f) && f.length >= 1)
|
|
232
|
-
.map((f) => String(f[0]));
|
|
229
|
+
if (query.where && Object.keys(query.where).length > 0 && indexes.length === 0) {
|
|
230
|
+
const filterFields = Object.keys(query.where).filter(k => !k.startsWith('$'));
|
|
233
231
|
if (filterFields.length > 0) {
|
|
234
232
|
suggestions.push(`Consider adding an index on: ${filterFields.join(', ')}`);
|
|
235
233
|
}
|
|
@@ -239,10 +237,9 @@ class QueryAnalyzer {
|
|
|
239
237
|
suggestions.push('Select only required fields to reduce data transfer');
|
|
240
238
|
}
|
|
241
239
|
// Suggest composite index for multiple filters
|
|
242
|
-
if (query.
|
|
243
|
-
const filterFields = query.
|
|
244
|
-
.filter(
|
|
245
|
-
.map((f) => String(f[0]))
|
|
240
|
+
if (query.where && Object.keys(query.where).length > 1 && indexes.length < 2) {
|
|
241
|
+
const filterFields = Object.keys(query.where)
|
|
242
|
+
.filter(k => !k.startsWith('$'))
|
|
246
243
|
.slice(0, 3); // Top 3 fields
|
|
247
244
|
if (filterFields.length > 1) {
|
|
248
245
|
suggestions.push(`Consider a composite index on: (${filterFields.join(', ')})`);
|
|
@@ -259,17 +256,18 @@ class QueryAnalyzer {
|
|
|
259
256
|
// Base complexity
|
|
260
257
|
complexity += 10;
|
|
261
258
|
// Filters add complexity
|
|
262
|
-
if (query.
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
259
|
+
if (query.where) {
|
|
260
|
+
const filterCount = Object.keys(query.where).length;
|
|
261
|
+
complexity += filterCount * 5;
|
|
262
|
+
// Nested filters (OR/AND conditions) add more
|
|
263
|
+
const hasLogicalOps = query.where.$and || query.where.$or;
|
|
264
|
+
if (hasLogicalOps) {
|
|
267
265
|
complexity += 15;
|
|
268
266
|
}
|
|
269
267
|
}
|
|
270
268
|
// Sorting adds complexity
|
|
271
|
-
if (query.
|
|
272
|
-
complexity += query.
|
|
269
|
+
if (query.orderBy && query.orderBy.length > 0) {
|
|
270
|
+
complexity += query.orderBy.length * 3;
|
|
273
271
|
}
|
|
274
272
|
// Field selection reduces complexity slightly
|
|
275
273
|
if (query.fields && query.fields.length > 0 && query.fields.length < 10) {
|
|
@@ -290,12 +288,13 @@ class QueryAnalyzer {
|
|
|
290
288
|
// This is a placeholder - real implementation would need statistics
|
|
291
289
|
// from the database (row count, index selectivity, etc.)
|
|
292
290
|
// Default to unknown
|
|
293
|
-
if (!query.
|
|
291
|
+
if (!query.where || Object.keys(query.where).length === 0) {
|
|
294
292
|
return -1; // Unknown, full scan
|
|
295
293
|
}
|
|
296
294
|
// Very rough estimate based on filter count
|
|
297
295
|
const baseEstimate = 1000;
|
|
298
|
-
const
|
|
296
|
+
const filterCount = Object.keys(query.where).length;
|
|
297
|
+
const filterReduction = Math.pow(0.5, filterCount);
|
|
299
298
|
const estimated = Math.floor(baseEstimate * filterReduction);
|
|
300
299
|
// Apply limit if present
|
|
301
300
|
if (query.limit) {
|