@objectql/core 4.2.0 → 4.2.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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +34 -0
- package/README.md +5 -2
- package/dist/app.d.ts +61 -52
- package/dist/app.js +100 -435
- package/dist/app.js.map +1 -1
- package/dist/index.d.ts +14 -20
- package/dist/index.js +21 -20
- package/dist/index.js.map +1 -1
- package/dist/kernel-factory.d.ts +38 -0
- package/dist/kernel-factory.js +38 -0
- package/dist/kernel-factory.js.map +1 -0
- package/dist/plugin.d.ts +9 -16
- package/dist/plugin.js +71 -48
- package/dist/plugin.js.map +1 -1
- package/dist/repository.d.ts +4 -31
- package/dist/repository.js +7 -283
- package/dist/repository.js.map +1 -1
- package/dist/util.js +4 -2
- package/dist/util.js.map +1 -1
- package/package.json +14 -12
- package/src/app.ts +156 -539
- package/src/index.ts +18 -42
- package/src/kernel-factory.ts +47 -0
- package/src/plugin.ts +77 -85
- package/src/repository.ts +4 -320
- package/src/util.ts +5 -3
- package/test/__mocks__/@objectstack/core.ts +250 -1
- package/test/__mocks__/@objectstack/objectql.ts +273 -0
- package/test/__mocks__/@objectstack/runtime.ts +14 -5
- package/test/introspection.test.ts +1 -1
- package/test/mock-driver.ts +5 -5
- package/test/optimizations.test.ts +2 -2
- package/test/plugin-integration.test.ts +1 -3
- package/test/utils.ts +6 -6
- package/tsconfig.json +3 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/ai/index.d.ts +0 -8
- package/dist/ai/index.js +0 -25
- package/dist/ai/index.js.map +0 -1
- package/dist/ai/registry.d.ts +0 -23
- package/dist/ai/registry.js +0 -78
- package/dist/ai/registry.js.map +0 -1
- package/dist/gateway.d.ts +0 -37
- package/dist/gateway.js +0 -93
- package/dist/gateway.js.map +0 -1
- package/dist/optimizations/CompiledHookManager.d.ts +0 -56
- package/dist/optimizations/CompiledHookManager.js +0 -170
- package/dist/optimizations/CompiledHookManager.js.map +0 -1
- package/dist/optimizations/DependencyGraph.d.ts +0 -82
- package/dist/optimizations/DependencyGraph.js +0 -211
- package/dist/optimizations/DependencyGraph.js.map +0 -1
- package/dist/optimizations/GlobalConnectionPool.d.ts +0 -89
- package/dist/optimizations/GlobalConnectionPool.js +0 -193
- package/dist/optimizations/GlobalConnectionPool.js.map +0 -1
- package/dist/optimizations/LazyMetadataLoader.d.ts +0 -75
- package/dist/optimizations/LazyMetadataLoader.js +0 -149
- package/dist/optimizations/LazyMetadataLoader.js.map +0 -1
- package/dist/optimizations/OptimizedMetadataRegistry.d.ts +0 -26
- package/dist/optimizations/OptimizedMetadataRegistry.js +0 -117
- package/dist/optimizations/OptimizedMetadataRegistry.js.map +0 -1
- package/dist/optimizations/OptimizedValidationEngine.d.ts +0 -73
- package/dist/optimizations/OptimizedValidationEngine.js +0 -141
- package/dist/optimizations/OptimizedValidationEngine.js.map +0 -1
- package/dist/optimizations/QueryCompiler.d.ts +0 -51
- package/dist/optimizations/QueryCompiler.js +0 -216
- package/dist/optimizations/QueryCompiler.js.map +0 -1
- package/dist/optimizations/SQLQueryOptimizer.d.ts +0 -96
- package/dist/optimizations/SQLQueryOptimizer.js +0 -265
- package/dist/optimizations/SQLQueryOptimizer.js.map +0 -1
- package/dist/optimizations/index.d.ts +0 -32
- package/dist/optimizations/index.js +0 -44
- package/dist/optimizations/index.js.map +0 -1
- package/dist/protocol.d.ts +0 -191
- package/dist/protocol.js +0 -272
- package/dist/protocol.js.map +0 -1
- package/dist/query/filter-translator.d.ts +0 -24
- package/dist/query/filter-translator.js +0 -38
- package/dist/query/filter-translator.js.map +0 -1
- package/dist/query/index.d.ts +0 -22
- package/dist/query/index.js +0 -39
- package/dist/query/index.js.map +0 -1
- package/dist/query/query-analyzer.d.ts +0 -186
- package/dist/query/query-analyzer.js +0 -348
- package/dist/query/query-analyzer.js.map +0 -1
- package/dist/query/query-builder.d.ts +0 -27
- package/dist/query/query-builder.js +0 -69
- package/dist/query/query-builder.js.map +0 -1
- package/dist/query/query-service.d.ts +0 -151
- package/dist/query/query-service.js +0 -272
- package/dist/query/query-service.js.map +0 -1
- package/src/ai/index.ts +0 -9
- package/src/ai/registry.ts +0 -81
- package/src/gateway.ts +0 -105
- package/src/optimizations/CompiledHookManager.ts +0 -193
- package/src/optimizations/DependencyGraph.ts +0 -255
- package/src/optimizations/GlobalConnectionPool.ts +0 -251
- package/src/optimizations/LazyMetadataLoader.ts +0 -180
- package/src/optimizations/OptimizedMetadataRegistry.ts +0 -132
- package/src/optimizations/OptimizedValidationEngine.ts +0 -172
- package/src/optimizations/QueryCompiler.ts +0 -242
- package/src/optimizations/SQLQueryOptimizer.ts +0 -329
- package/src/optimizations/index.ts +0 -34
- package/src/protocol.ts +0 -304
- package/src/query/filter-translator.ts +0 -41
- package/src/query/index.ts +0 -24
- package/src/query/query-analyzer.ts +0 -532
- package/src/query/query-builder.ts +0 -64
- package/src/query/query-service.ts +0 -397
- package/test/ai-registry.test.ts +0 -42
- package/test/app.test.ts +0 -578
- package/test/filter-syntax.test.ts +0 -233
- package/test/gateway.test.ts +0 -88
- package/test/protocol.test.ts +0 -143
- package/test/repository-validation.test.ts +0 -351
- package/test/repository.test.ts +0 -151
package/src/index.ts
CHANGED
|
@@ -1,53 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* ObjectQL
|
|
2
|
+
* ObjectQL Core — DEPRECATED
|
|
3
3
|
* Copyright (c) 2026-present ObjectStack Inc.
|
|
4
4
|
*
|
|
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
|
+
*
|
|
8
|
+
* @deprecated This package is deprecated. Migrate to `@objectstack/objectql`.
|
|
9
|
+
* See: https://github.com/objectstack-ai/spec/blob/main/content/docs/guides/objectql-migration.mdx
|
|
7
10
|
*/
|
|
8
11
|
|
|
9
|
-
//
|
|
10
|
-
|
|
11
|
-
export type
|
|
12
|
-
|
|
13
|
-
// Re-export new @objectstack/objectql 1.1.0 FQN (Fully Qualified Name) utilities
|
|
14
|
-
export {
|
|
15
|
-
computeFQN,
|
|
16
|
-
parseFQN,
|
|
17
|
-
RESERVED_NAMESPACES,
|
|
18
|
-
DEFAULT_OWNER_PRIORITY,
|
|
19
|
-
DEFAULT_EXTENDER_PRIORITY,
|
|
20
|
-
SchemaRegistry,
|
|
21
|
-
} from '@objectstack/objectql';
|
|
22
|
-
export type { ObjectContributor } from '@objectstack/objectql';
|
|
12
|
+
// ── Bridge engine (deprecated — use @objectstack/objectql ObjectQL directly) ──
|
|
13
|
+
/** @deprecated Import ObjectQL from `@objectstack/objectql` instead. This bridge class will be removed in a future version. */
|
|
14
|
+
export { ObjectQL, type ObjectQLConfig } from './app';
|
|
23
15
|
|
|
24
|
-
//
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
export { QueryAST } from '@objectql/types';
|
|
28
|
-
export type DriverInterface = z.infer<typeof Data.DriverInterfaceSchema>;
|
|
29
|
-
export type DriverOptions = z.infer<typeof Data.DriverOptionsSchema>;
|
|
16
|
+
// ── Convenience factory (local implementation — wraps upstream kernel) ──
|
|
17
|
+
export { createObjectQLKernel } from './kernel-factory';
|
|
18
|
+
export type { ObjectQLKernelOptions } from './kernel-factory';
|
|
30
19
|
|
|
31
|
-
// Re-
|
|
32
|
-
|
|
33
|
-
export
|
|
34
|
-
|
|
20
|
+
// ── Re-exports from @objectstack/objectql (deprecated — import directly from upstream) ──
|
|
21
|
+
/** @deprecated Import from `@objectstack/objectql` instead. */
|
|
22
|
+
export { ObjectRepository, ScopedContext, SchemaRegistry } from '@objectstack/objectql';
|
|
23
|
+
/** @deprecated Import from `@objectstack/objectql` instead. */
|
|
24
|
+
export { toTitleCase, convertIntrospectedSchemaToObjects } from '@objectstack/objectql';
|
|
25
|
+
/** @deprecated Import from `@objectstack/objectql` instead. */
|
|
26
|
+
export type { HookHandler, HookEntry, OperationContext, EngineMiddleware, ObjectQLHostContext } from '@objectstack/objectql';
|
|
35
27
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
// Export our enhanced runtime components (actual implementations)
|
|
39
|
-
export * from './repository';
|
|
40
|
-
export * from './app';
|
|
28
|
+
// ── Plugin orchestration (downstream — stays in @objectql ecosystem) ──
|
|
41
29
|
export * from './plugin';
|
|
42
|
-
|
|
43
|
-
// Export query-specific modules (ObjectQL core competency)
|
|
44
|
-
export * from './query';
|
|
45
|
-
|
|
46
|
-
// Export utilities
|
|
47
|
-
export * from './util';
|
|
48
|
-
|
|
49
|
-
// Export kernel optimizations
|
|
50
|
-
export * from './optimizations';
|
|
51
|
-
|
|
52
|
-
// Export AI runtime
|
|
53
|
-
export * from './ai';
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ObjectQL Kernel Factory
|
|
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 { ObjectKernel } from '@objectstack/runtime';
|
|
10
|
+
import { ObjectQLPlugin as UpstreamObjectQLPlugin } from '@objectstack/objectql';
|
|
11
|
+
import type { Plugin } from '@objectstack/core';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Options for creating an ObjectQL Kernel
|
|
15
|
+
*/
|
|
16
|
+
export interface ObjectQLKernelOptions {
|
|
17
|
+
/**
|
|
18
|
+
* Additional plugins to register with the kernel
|
|
19
|
+
*/
|
|
20
|
+
plugins?: Plugin[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Convenience factory for creating an ObjectQL-ready kernel.
|
|
25
|
+
*
|
|
26
|
+
* Creates an ObjectStackKernel pre-configured with the upstream ObjectQLPlugin
|
|
27
|
+
* (data engine, schema registry, protocol implementation) plus any additional
|
|
28
|
+
* plugins provided.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* import { createObjectQLKernel } from '@objectql/core';
|
|
33
|
+
* import { QueryPlugin } from '@objectql/plugin-query';
|
|
34
|
+
* import { OptimizationsPlugin } from '@objectql/plugin-optimizations';
|
|
35
|
+
*
|
|
36
|
+
* const kernel = createObjectQLKernel({
|
|
37
|
+
* plugins: [new QueryPlugin(), new OptimizationsPlugin()],
|
|
38
|
+
* });
|
|
39
|
+
* await kernel.start();
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export function createObjectQLKernel(options: ObjectQLKernelOptions = {}): ObjectKernel {
|
|
43
|
+
return new (ObjectKernel as any)([
|
|
44
|
+
new UpstreamObjectQLPlugin(),
|
|
45
|
+
...(options.plugins || []),
|
|
46
|
+
]);
|
|
47
|
+
}
|
package/src/plugin.ts
CHANGED
|
@@ -7,32 +7,13 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import type { RuntimePlugin, RuntimeContext } from '@objectql/types';
|
|
10
|
-
import { ConsoleLogger } from '@objectql/types';
|
|
10
|
+
import { ConsoleLogger, ObjectQLError } from '@objectql/types';
|
|
11
11
|
import type { Logger } from '@objectql/types';
|
|
12
12
|
import { ValidatorPlugin, ValidatorPluginConfig } from '@objectql/plugin-validator';
|
|
13
13
|
import { FormulaPlugin, FormulaPluginConfig } from '@objectql/plugin-formula';
|
|
14
|
-
import {
|
|
15
|
-
import { QueryAnalyzer } from './query/query-analyzer';
|
|
16
|
-
import { ObjectStackProtocolImplementation } from './protocol';
|
|
14
|
+
import { QueryPlugin } from '@objectql/plugin-query';
|
|
17
15
|
import type { Driver } from '@objectql/types';
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Extended kernel with ObjectQL services
|
|
22
|
-
*/
|
|
23
|
-
interface ExtendedKernel {
|
|
24
|
-
metadata?: any;
|
|
25
|
-
actions?: any;
|
|
26
|
-
hooks?: any;
|
|
27
|
-
getAllDrivers?: () => Driver[];
|
|
28
|
-
create?: (objectName: string, data: any) => Promise<any>;
|
|
29
|
-
update?: (objectName: string, id: string, data: any) => Promise<any>;
|
|
30
|
-
delete?: (objectName: string, id: string) => Promise<any>;
|
|
31
|
-
find?: (objectName: string, query: any) => Promise<any>;
|
|
32
|
-
get?: (objectName: string, id: string) => Promise<any>;
|
|
33
|
-
queryService?: QueryService;
|
|
34
|
-
queryAnalyzer?: QueryAnalyzer;
|
|
35
|
-
}
|
|
16
|
+
import { SchemaRegistry } from '@objectstack/objectql';
|
|
36
17
|
|
|
37
18
|
/**
|
|
38
19
|
* Configuration for the ObjectQL Plugin
|
|
@@ -68,12 +49,6 @@ export interface ObjectQLPluginConfig {
|
|
|
68
49
|
*/
|
|
69
50
|
formulaConfig?: FormulaPluginConfig;
|
|
70
51
|
|
|
71
|
-
/**
|
|
72
|
-
* Enable AI integration
|
|
73
|
-
* @default true
|
|
74
|
-
*/
|
|
75
|
-
enableAI?: boolean;
|
|
76
|
-
|
|
77
52
|
/**
|
|
78
53
|
* Enable query service and analyzer
|
|
79
54
|
* @default true
|
|
@@ -90,21 +65,23 @@ export interface ObjectQLPluginConfig {
|
|
|
90
65
|
/**
|
|
91
66
|
* ObjectQL Plugin
|
|
92
67
|
*
|
|
93
|
-
*
|
|
94
|
-
* (
|
|
68
|
+
* Thin orchestrator that composes ObjectQL's extension plugins
|
|
69
|
+
* (QueryPlugin, ValidatorPlugin, FormulaPlugin, AI) on top of the microkernel.
|
|
70
|
+
*
|
|
71
|
+
* Delegates query execution to @objectql/plugin-query and provides
|
|
72
|
+
* repository-pattern CRUD bridging to the kernel.
|
|
95
73
|
*/
|
|
96
74
|
export class ObjectQLPlugin implements RuntimePlugin {
|
|
97
75
|
name = '@objectql/core';
|
|
98
|
-
version = '4.0
|
|
76
|
+
version = '4.2.0';
|
|
99
77
|
private logger: Logger;
|
|
100
78
|
|
|
101
|
-
constructor(private config: ObjectQLPluginConfig = {},
|
|
79
|
+
constructor(private config: ObjectQLPluginConfig = {}, _ql?: any) {
|
|
102
80
|
// Set defaults
|
|
103
81
|
this.config = {
|
|
104
82
|
enableRepository: true,
|
|
105
83
|
enableValidator: true,
|
|
106
84
|
enableFormulas: true,
|
|
107
|
-
enableAI: true,
|
|
108
85
|
enableQueryService: true,
|
|
109
86
|
...config
|
|
110
87
|
};
|
|
@@ -118,7 +95,7 @@ export class ObjectQLPlugin implements RuntimePlugin {
|
|
|
118
95
|
async install(ctx: RuntimeContext): Promise<void> {
|
|
119
96
|
this.logger.info('Installing plugin...');
|
|
120
97
|
|
|
121
|
-
const kernel = ctx.engine as
|
|
98
|
+
const kernel = ctx.engine as any;
|
|
122
99
|
|
|
123
100
|
// Get datasources - either from config or from kernel drivers
|
|
124
101
|
let datasources = this.config.datasources;
|
|
@@ -140,21 +117,11 @@ export class ObjectQLPlugin implements RuntimePlugin {
|
|
|
140
117
|
}
|
|
141
118
|
}
|
|
142
119
|
|
|
143
|
-
//
|
|
120
|
+
// Delegate query service registration to QueryPlugin
|
|
144
121
|
if (this.config.enableQueryService !== false && datasources) {
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
);
|
|
149
|
-
kernel.queryService = queryService;
|
|
150
|
-
|
|
151
|
-
const queryAnalyzer = new QueryAnalyzer(
|
|
152
|
-
queryService,
|
|
153
|
-
kernel.metadata
|
|
154
|
-
);
|
|
155
|
-
kernel.queryAnalyzer = queryAnalyzer;
|
|
156
|
-
|
|
157
|
-
this.logger.info('QueryService and QueryAnalyzer registered');
|
|
122
|
+
const queryPlugin = new QueryPlugin({ datasources });
|
|
123
|
+
await queryPlugin.install(ctx);
|
|
124
|
+
this.logger.info('QueryPlugin installed (QueryService + QueryAnalyzer)');
|
|
158
125
|
}
|
|
159
126
|
|
|
160
127
|
// Register components based on configuration
|
|
@@ -174,10 +141,6 @@ export class ObjectQLPlugin implements RuntimePlugin {
|
|
|
174
141
|
await formulaPlugin.install?.(ctx);
|
|
175
142
|
}
|
|
176
143
|
|
|
177
|
-
if (this.config.enableAI !== false) {
|
|
178
|
-
await this.registerAI(kernel);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
144
|
// Register system service aliases
|
|
182
145
|
if (typeof (ctx as any).registerService === 'function') {
|
|
183
146
|
const registerService = (ctx as any).registerService.bind(ctx);
|
|
@@ -192,6 +155,12 @@ export class ObjectQLPlugin implements RuntimePlugin {
|
|
|
192
155
|
const dataService = kernel.queryService || kernel;
|
|
193
156
|
registerService('data', dataService);
|
|
194
157
|
this.logger.debug('Registered data service alias');
|
|
158
|
+
|
|
159
|
+
// 3. Analytics service (via QueryService)
|
|
160
|
+
if (kernel.queryService) {
|
|
161
|
+
registerService('analytics', kernel.queryService);
|
|
162
|
+
this.logger.debug('Registered analytics service alias');
|
|
163
|
+
}
|
|
195
164
|
}
|
|
196
165
|
|
|
197
166
|
this.logger.info('Plugin installed successfully');
|
|
@@ -201,7 +170,7 @@ export class ObjectQLPlugin implements RuntimePlugin {
|
|
|
201
170
|
* Called when the kernel starts
|
|
202
171
|
* This is the initialization phase
|
|
203
172
|
*/
|
|
204
|
-
async onStart(
|
|
173
|
+
async onStart(_ctx: RuntimeContext): Promise<void> {
|
|
205
174
|
this.logger.debug('Starting plugin...');
|
|
206
175
|
// Additional startup logic can be added here
|
|
207
176
|
}
|
|
@@ -220,7 +189,7 @@ export class ObjectQLPlugin implements RuntimePlugin {
|
|
|
220
189
|
const datasourceName = objectConfig?.datasource || 'default';
|
|
221
190
|
const driver = datasources[datasourceName];
|
|
222
191
|
if (!driver) {
|
|
223
|
-
throw new
|
|
192
|
+
throw new ObjectQLError({ code: 'NOT_FOUND', message: `Datasource '${datasourceName}' not found for object '${objectName}'` });
|
|
224
193
|
}
|
|
225
194
|
return driver;
|
|
226
195
|
};
|
|
@@ -273,8 +242,6 @@ export class ObjectQLPlugin implements RuntimePlugin {
|
|
|
273
242
|
kernel.count = async (objectName: string, filters?: any): Promise<number> => {
|
|
274
243
|
// Use QueryService if available
|
|
275
244
|
if ((kernel as any).queryService) {
|
|
276
|
-
// QueryService.count expects a UnifiedQuery filter or just filter object?
|
|
277
|
-
// Looking at QueryService.count signature: count(objectName: string, where?: Filter, options?: QueryOptions)
|
|
278
245
|
const result = await (kernel as any).queryService.count(objectName, filters);
|
|
279
246
|
return result.value;
|
|
280
247
|
}
|
|
@@ -286,45 +253,70 @@ export class ObjectQLPlugin implements RuntimePlugin {
|
|
|
286
253
|
this.logger.info('Repository pattern registered');
|
|
287
254
|
}
|
|
288
255
|
|
|
289
|
-
/**
|
|
290
|
-
* Register AI integration
|
|
291
|
-
* @private
|
|
292
|
-
*/
|
|
293
|
-
private async registerAI(kernel: any): Promise<void> {
|
|
294
|
-
if (!(kernel as any).ai) {
|
|
295
|
-
(kernel as any).ai = createDefaultAiRegistry();
|
|
296
|
-
}
|
|
297
|
-
this.logger.debug('AI integration registered');
|
|
298
|
-
}
|
|
299
|
-
|
|
300
256
|
// --- Adapter for @objectstack/core compatibility ---
|
|
301
|
-
init = async (
|
|
302
|
-
// The
|
|
303
|
-
// We
|
|
257
|
+
init = async (pluginCtx: any): Promise<void> => {
|
|
258
|
+
// The @objectstack/core kernel passes a PluginContext (with registerService, getKernel, etc.)
|
|
259
|
+
// We extract the actual kernel and build a RuntimeContext wrapper that proxies registerService.
|
|
260
|
+
const actualKernel = typeof pluginCtx.getKernel === 'function'
|
|
261
|
+
? pluginCtx.getKernel()
|
|
262
|
+
: pluginCtx;
|
|
263
|
+
|
|
264
|
+
// Create metadata facade on the kernel if not already present.
|
|
265
|
+
// The raw ObjectKernel from @objectstack/core has no .metadata property;
|
|
266
|
+
// it's normally created by the ObjectQL wrapper (app.ts).
|
|
267
|
+
// When running via `objectstack serve`, we must create it here.
|
|
268
|
+
if (!actualKernel.metadata) {
|
|
269
|
+
const unwrapContent = (item: any) => (item && item.content) ? item.content : item;
|
|
270
|
+
actualKernel.metadata = {
|
|
271
|
+
register: (type: string, item: any) => SchemaRegistry.registerItem(type, item, item.id ? 'id' : 'name'),
|
|
272
|
+
get: (type: string, name: string) => {
|
|
273
|
+
const item = SchemaRegistry.getItem(type, name) as any;
|
|
274
|
+
return unwrapContent(item);
|
|
275
|
+
},
|
|
276
|
+
getEntry: (type: string, name: string) => SchemaRegistry.getItem(type, name),
|
|
277
|
+
list: (type: string) => {
|
|
278
|
+
const items = SchemaRegistry.listItems(type);
|
|
279
|
+
return items.map(unwrapContent);
|
|
280
|
+
},
|
|
281
|
+
unregister: (type: string, name: string) => {
|
|
282
|
+
if (typeof SchemaRegistry.unregisterItem === 'function') {
|
|
283
|
+
SchemaRegistry.unregisterItem(type, name);
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
unregisterPackage: (packageName: string) => {
|
|
287
|
+
if (typeof (SchemaRegistry as any).unregisterObjectsByPackage === 'function') {
|
|
288
|
+
(SchemaRegistry as any).unregisterObjectsByPackage(packageName);
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
};
|
|
292
|
+
this.logger.info('Created metadata facade on kernel');
|
|
293
|
+
}
|
|
294
|
+
|
|
304
295
|
const ctx: any = {
|
|
305
|
-
engine:
|
|
306
|
-
getKernel: () =>
|
|
296
|
+
engine: actualKernel,
|
|
297
|
+
getKernel: () => actualKernel,
|
|
298
|
+
// Proxy registerService from PluginContext so install() can register metadata/data/analytics
|
|
299
|
+
registerService: typeof pluginCtx.registerService === 'function'
|
|
300
|
+
? pluginCtx.registerService.bind(pluginCtx)
|
|
301
|
+
: undefined,
|
|
307
302
|
};
|
|
308
303
|
|
|
309
|
-
// Register
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
this.logger.
|
|
313
|
-
const protocolShim = new ObjectStackProtocolImplementation(kernel);
|
|
314
|
-
kernel.registerService('protocol', protocolShim);
|
|
315
|
-
|
|
316
|
-
// Register 'objectql' service for AppPlugin compatibility
|
|
317
|
-
kernel.registerService('objectql', this);
|
|
318
|
-
this.logger.debug('Registered objectql service');
|
|
304
|
+
// Register 'objectql' service for AppPlugin compatibility
|
|
305
|
+
if (typeof pluginCtx.registerService === 'function') {
|
|
306
|
+
pluginCtx.registerService('objectql', this);
|
|
307
|
+
this.logger.debug('Registered objectql service');
|
|
319
308
|
}
|
|
320
309
|
|
|
321
310
|
return this.install(ctx);
|
|
322
311
|
}
|
|
323
312
|
|
|
324
|
-
start = async (
|
|
313
|
+
start = async (pluginCtx: any): Promise<void> => {
|
|
314
|
+
const actualKernel = typeof pluginCtx.getKernel === 'function'
|
|
315
|
+
? pluginCtx.getKernel()
|
|
316
|
+
: pluginCtx;
|
|
325
317
|
const ctx: any = {
|
|
326
|
-
engine:
|
|
327
|
-
getKernel: () =>
|
|
318
|
+
engine: actualKernel,
|
|
319
|
+
getKernel: () => actualKernel,
|
|
328
320
|
};
|
|
329
321
|
return this.onStart(ctx);
|
|
330
322
|
}
|