@objectql/core 3.0.1 → 4.0.1
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 +17 -3
- package/README.md +31 -9
- package/dist/ai-agent.d.ts +4 -3
- package/dist/ai-agent.js +10 -3
- package/dist/ai-agent.js.map +1 -1
- package/dist/app.d.ts +29 -6
- package/dist/app.js +117 -58
- package/dist/app.js.map +1 -1
- package/dist/formula-engine.d.ts +7 -0
- package/dist/formula-engine.js +9 -2
- package/dist/formula-engine.js.map +1 -1
- package/dist/formula-plugin.d.ts +52 -0
- package/dist/formula-plugin.js +107 -0
- package/dist/formula-plugin.js.map +1 -0
- package/dist/index.d.ts +16 -3
- package/dist/index.js +14 -3
- package/dist/index.js.map +1 -1
- package/dist/plugin.d.ts +89 -0
- package/dist/plugin.js +136 -0
- package/dist/plugin.js.map +1 -0
- package/dist/query/filter-translator.d.ts +39 -0
- package/dist/query/filter-translator.js +135 -0
- package/dist/query/filter-translator.js.map +1 -0
- package/dist/query/index.d.ts +22 -0
- package/dist/query/index.js +39 -0
- package/dist/query/index.js.map +1 -0
- package/dist/query/query-analyzer.d.ts +188 -0
- package/dist/query/query-analyzer.js +349 -0
- package/dist/query/query-analyzer.js.map +1 -0
- package/dist/query/query-builder.d.ts +29 -0
- package/dist/query/query-builder.js +71 -0
- package/dist/query/query-builder.js.map +1 -0
- package/dist/query/query-service.d.ts +152 -0
- package/dist/query/query-service.js +268 -0
- package/dist/query/query-service.js.map +1 -0
- package/dist/repository.d.ts +23 -2
- package/dist/repository.js +81 -14
- package/dist/repository.js.map +1 -1
- package/dist/util.d.ts +7 -0
- package/dist/util.js +18 -3
- package/dist/util.js.map +1 -1
- package/dist/validator-plugin.d.ts +56 -0
- package/dist/validator-plugin.js +106 -0
- package/dist/validator-plugin.js.map +1 -0
- package/dist/validator.d.ts +7 -0
- package/dist/validator.js +10 -8
- package/dist/validator.js.map +1 -1
- package/jest.config.js +16 -0
- package/package.json +7 -5
- package/src/ai-agent.ts +8 -0
- package/src/app.ts +136 -72
- package/src/formula-engine.ts +8 -0
- package/src/formula-plugin.ts +141 -0
- package/src/index.ts +28 -3
- package/src/plugin.ts +224 -0
- package/src/query/filter-translator.ts +148 -0
- package/src/query/index.ts +24 -0
- package/src/query/query-analyzer.ts +537 -0
- package/src/query/query-builder.ts +81 -0
- package/src/query/query-service.ts +393 -0
- package/src/repository.ts +101 -18
- package/src/util.ts +19 -3
- package/src/validator-plugin.ts +140 -0
- package/src/validator.ts +12 -5
- package/test/__mocks__/@objectstack/runtime.ts +255 -0
- package/test/app.test.ts +23 -35
- package/test/filter-syntax.test.ts +233 -0
- package/test/formula-engine.test.ts +8 -0
- package/test/formula-integration.test.ts +8 -0
- package/test/formula-plugin.test.ts +197 -0
- package/test/introspection.test.ts +8 -0
- package/test/mock-driver.ts +8 -0
- package/test/plugin-integration.test.ts +213 -0
- package/test/repository-validation.test.ts +8 -0
- package/test/repository.test.ts +8 -0
- package/test/util.test.ts +9 -1
- package/test/utils.ts +8 -0
- package/test/validator-plugin.test.ts +126 -0
- package/test/validator.test.ts +8 -0
- package/tsconfig.json +8 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/action.d.ts +0 -7
- package/dist/action.js +0 -23
- package/dist/action.js.map +0 -1
- package/dist/hook.d.ts +0 -8
- package/dist/hook.js +0 -25
- package/dist/hook.js.map +0 -1
- package/dist/object.d.ts +0 -3
- package/dist/object.js +0 -28
- package/dist/object.js.map +0 -1
- package/src/action.ts +0 -40
- package/src/hook.ts +0 -42
- package/src/object.ts +0 -26
- package/test/action.test.ts +0 -276
- package/test/hook.test.ts +0 -343
- package/test/object.test.ts +0 -183
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ObjectQL
|
|
3
|
+
* Copyright (c) 2026-present ObjectStack Inc.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
|
|
1
9
|
import { ObjectQL } from '../src/index';
|
|
2
10
|
import { MockDriver } from './mock-driver';
|
|
3
11
|
import { ObjectConfig, ValidationError } from '@objectql/types';
|
package/test/repository.test.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ObjectQL
|
|
3
|
+
* Copyright (c) 2026-present ObjectStack Inc.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
|
|
1
9
|
import { ObjectQL } from '../src/index';
|
|
2
10
|
import { MockDriver } from './mock-driver';
|
|
3
11
|
import { ObjectConfig, HookContext, ObjectQLContext } from '@objectql/types';
|
package/test/util.test.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ObjectQL
|
|
3
|
+
* Copyright (c) 2026-present ObjectStack Inc.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
|
|
1
9
|
import { toTitleCase, convertIntrospectedSchemaToObjects } from '../src/util';
|
|
2
10
|
import { IntrospectedSchema } from '@objectql/types';
|
|
3
11
|
|
|
@@ -319,7 +327,7 @@ describe('Utility Functions', () => {
|
|
|
319
327
|
const objects = convertIntrospectedSchemaToObjects(schema);
|
|
320
328
|
const fields = objects[0].fields!;
|
|
321
329
|
|
|
322
|
-
expect(fields.short_text.
|
|
330
|
+
expect(fields.short_text.maxLength).toBe(100);
|
|
323
331
|
});
|
|
324
332
|
|
|
325
333
|
it('should add default value when present', () => {
|
package/test/utils.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ObjectQL
|
|
3
|
+
* Copyright (c) 2026-present ObjectStack Inc.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
|
|
1
9
|
import { Driver } from '@objectql/types';
|
|
2
10
|
|
|
3
11
|
export class MockDriver implements Driver {
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ObjectQL Validator Plugin Tests
|
|
3
|
+
* Copyright (c) 2026-present ObjectStack Inc.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { ValidatorPlugin } from '../src/validator-plugin';
|
|
10
|
+
import { ObjectStackKernel } from '@objectql/runtime';
|
|
11
|
+
|
|
12
|
+
describe('ValidatorPlugin', () => {
|
|
13
|
+
let plugin: ValidatorPlugin;
|
|
14
|
+
let mockKernel: any;
|
|
15
|
+
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
// Create a mock kernel with middleware support
|
|
18
|
+
mockKernel = {
|
|
19
|
+
use: jest.fn(),
|
|
20
|
+
};
|
|
21
|
+
plugin = new ValidatorPlugin();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
describe('Plugin Metadata', () => {
|
|
25
|
+
it('should have correct name and version', () => {
|
|
26
|
+
expect(plugin.name).toBe('@objectql/validator');
|
|
27
|
+
expect(plugin.version).toBe('4.0.0');
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
describe('Constructor', () => {
|
|
32
|
+
it('should create plugin with default config', () => {
|
|
33
|
+
const defaultPlugin = new ValidatorPlugin();
|
|
34
|
+
expect(defaultPlugin).toBeDefined();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('should create plugin with custom config', () => {
|
|
38
|
+
const customPlugin = new ValidatorPlugin({
|
|
39
|
+
language: 'zh-CN',
|
|
40
|
+
enableQueryValidation: false,
|
|
41
|
+
enableMutationValidation: true,
|
|
42
|
+
});
|
|
43
|
+
expect(customPlugin).toBeDefined();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('should accept language options', () => {
|
|
47
|
+
const customPlugin = new ValidatorPlugin({
|
|
48
|
+
language: 'fr',
|
|
49
|
+
languageFallback: ['en', 'zh-CN'],
|
|
50
|
+
});
|
|
51
|
+
expect(customPlugin).toBeDefined();
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
describe('Installation', () => {
|
|
56
|
+
it('should install successfully with mock kernel', async () => {
|
|
57
|
+
const ctx = { engine: mockKernel };
|
|
58
|
+
await plugin.install(ctx);
|
|
59
|
+
|
|
60
|
+
// Verify that middleware hooks were registered
|
|
61
|
+
expect(mockKernel.use).toHaveBeenCalled();
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('should register query validation when enabled', async () => {
|
|
65
|
+
const pluginWithQuery = new ValidatorPlugin({ enableQueryValidation: true });
|
|
66
|
+
const ctx = { engine: mockKernel };
|
|
67
|
+
|
|
68
|
+
await pluginWithQuery.install(ctx);
|
|
69
|
+
|
|
70
|
+
// Check that use was called (for query validation)
|
|
71
|
+
expect(mockKernel.use).toHaveBeenCalledWith('beforeQuery', expect.any(Function));
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('should register mutation validation when enabled', async () => {
|
|
75
|
+
const pluginWithMutation = new ValidatorPlugin({ enableMutationValidation: true });
|
|
76
|
+
const ctx = { engine: mockKernel };
|
|
77
|
+
|
|
78
|
+
await pluginWithMutation.install(ctx);
|
|
79
|
+
|
|
80
|
+
// Check that use was called (for mutation validation)
|
|
81
|
+
expect(mockKernel.use).toHaveBeenCalledWith('beforeMutation', expect.any(Function));
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('should not register query validation when disabled', async () => {
|
|
85
|
+
const pluginNoQuery = new ValidatorPlugin({ enableQueryValidation: false });
|
|
86
|
+
const ctx = { engine: mockKernel };
|
|
87
|
+
|
|
88
|
+
await pluginNoQuery.install(ctx);
|
|
89
|
+
|
|
90
|
+
// Should not have registered beforeQuery hook
|
|
91
|
+
const beforeQueryCalls = mockKernel.use.mock.calls.filter(
|
|
92
|
+
(call: any[]) => call[0] === 'beforeQuery'
|
|
93
|
+
);
|
|
94
|
+
expect(beforeQueryCalls.length).toBe(0);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('should not register mutation validation when disabled', async () => {
|
|
98
|
+
const pluginNoMutation = new ValidatorPlugin({ enableMutationValidation: false });
|
|
99
|
+
const ctx = { engine: mockKernel };
|
|
100
|
+
|
|
101
|
+
await pluginNoMutation.install(ctx);
|
|
102
|
+
|
|
103
|
+
// Should not have registered beforeMutation hook
|
|
104
|
+
const beforeMutationCalls = mockKernel.use.mock.calls.filter(
|
|
105
|
+
(call: any[]) => call[0] === 'beforeMutation'
|
|
106
|
+
);
|
|
107
|
+
expect(beforeMutationCalls.length).toBe(0);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('should handle kernel without middleware support', async () => {
|
|
111
|
+
const kernelNoMiddleware = {};
|
|
112
|
+
const ctx = { engine: kernelNoMiddleware };
|
|
113
|
+
|
|
114
|
+
// Should not throw error
|
|
115
|
+
await expect(plugin.install(ctx)).resolves.not.toThrow();
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
describe('Validator Access', () => {
|
|
120
|
+
it('should expose validator instance', () => {
|
|
121
|
+
const validator = plugin.getValidator();
|
|
122
|
+
expect(validator).toBeDefined();
|
|
123
|
+
expect(typeof validator.validate).toBe('function');
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
});
|
package/test/validator.test.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ObjectQL
|
|
3
|
+
* Copyright (c) 2026-present ObjectStack Inc.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
|
|
1
9
|
import { Validator } from '../src/validator';
|
|
2
10
|
import {
|
|
3
11
|
ValidationContext,
|
package/tsconfig.json
CHANGED
|
@@ -5,7 +5,15 @@
|
|
|
5
5
|
"rootDir": "src"
|
|
6
6
|
},
|
|
7
7
|
"include": ["src/**/*"],
|
|
8
|
+
"exclude": [
|
|
9
|
+
"node_modules",
|
|
10
|
+
"dist",
|
|
11
|
+
// Exclude external @objectstack/objectql package that has type incompatibilities
|
|
12
|
+
// with our stub packages during migration phase
|
|
13
|
+
"../../../node_modules/@objectstack+objectql"
|
|
14
|
+
],
|
|
8
15
|
"references": [
|
|
16
|
+
{ "path": "../../objectstack/runtime" },
|
|
9
17
|
{ "path": "../types" }
|
|
10
18
|
]
|
|
11
19
|
}
|