@objectstack/objectql 0.9.2 → 1.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/dist/engine.js CHANGED
@@ -1,9 +1,13 @@
1
1
  import { createLogger } from '@objectstack/core';
2
+ import { CoreServiceName } from '@objectstack/spec/system';
2
3
  import { SchemaRegistry } from './registry.js';
3
4
  /**
4
5
  * ObjectQL Engine
5
6
  *
6
7
  * Implements the IDataEngine interface for data persistence.
8
+ * Acts as the reference implementation for:
9
+ * - CoreServiceName.data (CRUD)
10
+ * - CoreServiceName.metadata (Schema Registry)
7
11
  */
8
12
  export class ObjectQL {
9
13
  constructor(hostContext = {}) {
@@ -23,6 +27,18 @@ export class ObjectQL {
23
27
  this.logger = hostContext.logger || createLogger({ level: 'info', format: 'pretty' });
24
28
  this.logger.info('ObjectQL Engine Instance Created');
25
29
  }
30
+ /**
31
+ * Service Status Report
32
+ * Used by Kernel to verify health and capabilities.
33
+ */
34
+ getStatus() {
35
+ return {
36
+ name: CoreServiceName.enum.data,
37
+ status: 'running',
38
+ version: '0.9.0',
39
+ features: ['crud', 'query', 'aggregate', 'transactions', 'metadata']
40
+ };
41
+ }
26
42
  /**
27
43
  * Expose the SchemaRegistry for plugins to register metadata
28
44
  */
package/dist/plugin.d.ts CHANGED
@@ -8,7 +8,7 @@ export declare class ObjectQLPlugin implements Plugin {
8
8
  private ql;
9
9
  private hostContext?;
10
10
  constructor(ql?: ObjectQL, hostContext?: Record<string, any>);
11
- init(ctx: PluginContext): Promise<void>;
12
- start(ctx: PluginContext): Promise<void>;
11
+ init: (ctx: PluginContext) => Promise<void>;
12
+ start: (ctx: PluginContext) => Promise<void>;
13
13
  }
14
14
  //# sourceMappingURL=plugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAE1D,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC;AAEtC,qBAAa,cAAe,YAAW,MAAM;IAC3C,IAAI,SAAqC;IACzC,IAAI,EAAG,UAAU,CAAU;IAC3B,OAAO,SAAW;IAElB,OAAO,CAAC,EAAE,CAAuB;IACjC,OAAO,CAAC,WAAW,CAAC,CAAsB;gBAE9B,EAAE,CAAC,EAAE,QAAQ,EAAE,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAStD,IAAI,CAAC,GAAG,EAAE,aAAa;IAkBvB,KAAK,CAAC,GAAG,EAAE,aAAa;CAoB/B"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAE1D,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC;AAEtC,qBAAa,cAAe,YAAW,MAAM;IAC3C,IAAI,SAAqC;IACzC,IAAI,EAAG,UAAU,CAAU;IAC3B,OAAO,SAAW;IAElB,OAAO,CAAC,EAAE,CAAuB;IACjC,OAAO,CAAC,WAAW,CAAC,CAAsB;gBAE9B,EAAE,CAAC,EAAE,QAAQ,EAAE,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAS5D,IAAI,GAAU,KAAK,aAAa,mBAgB/B;IAED,KAAK,GAAU,KAAK,aAAa,mBAmBhC;CACF"}
package/dist/plugin.js CHANGED
@@ -5,6 +5,39 @@ export class ObjectQLPlugin {
5
5
  this.name = 'com.objectstack.engine.objectql';
6
6
  this.type = 'objectql';
7
7
  this.version = '1.0.0';
8
+ this.init = async (ctx) => {
9
+ if (!this.ql) {
10
+ this.ql = new ObjectQL(this.hostContext);
11
+ }
12
+ ctx.registerService('objectql', this.ql);
13
+ ctx.logger.info('ObjectQL engine registered as service');
14
+ // Register Protocol Implementation
15
+ if (!this.ql) {
16
+ throw new Error('ObjectQL engine not initialized');
17
+ }
18
+ const protocolShim = new ObjectStackProtocolImplementation(this.ql);
19
+ ctx.registerService('protocol', protocolShim);
20
+ ctx.logger.info('Protocol service registered');
21
+ };
22
+ this.start = async (ctx) => {
23
+ ctx.logger.info('ObjectQL engine initialized');
24
+ // Discover features from Kernel Services
25
+ if (ctx.getServices && this.ql) {
26
+ const services = ctx.getServices();
27
+ for (const [name, service] of services.entries()) {
28
+ if (name.startsWith('driver.')) {
29
+ // Register Driver
30
+ this.ql.registerDriver(service);
31
+ ctx.logger.debug('Discovered and registered driver service', { serviceName: name });
32
+ }
33
+ if (name.startsWith('app.')) {
34
+ // Register App
35
+ this.ql.registerApp(service); // service is Manifest
36
+ ctx.logger.debug('Discovered and registered app service', { serviceName: name });
37
+ }
38
+ }
39
+ }
40
+ };
8
41
  if (ql) {
9
42
  this.ql = ql;
10
43
  }
@@ -13,37 +46,4 @@ export class ObjectQLPlugin {
13
46
  // Lazily created in init
14
47
  }
15
48
  }
16
- async init(ctx) {
17
- if (!this.ql) {
18
- this.ql = new ObjectQL(this.hostContext);
19
- }
20
- ctx.registerService('objectql', this.ql);
21
- ctx.logger.info('ObjectQL engine registered as service');
22
- // Register Protocol Implementation
23
- if (!this.ql) {
24
- throw new Error('ObjectQL engine not initialized');
25
- }
26
- const protocolShim = new ObjectStackProtocolImplementation(this.ql);
27
- ctx.registerService('protocol', protocolShim);
28
- ctx.logger.info('Protocol service registered');
29
- }
30
- async start(ctx) {
31
- ctx.logger.info('ObjectQL engine initialized');
32
- // Discover features from Kernel Services
33
- if (ctx.getServices && this.ql) {
34
- const services = ctx.getServices();
35
- for (const [name, service] of services.entries()) {
36
- if (name.startsWith('driver.')) {
37
- // Register Driver
38
- this.ql.registerDriver(service);
39
- ctx.logger.debug('Discovered and registered driver service', { serviceName: name });
40
- }
41
- if (name.startsWith('app.')) {
42
- // Register App
43
- this.ql.registerApp(service); // service is Manifest
44
- ctx.logger.debug('Discovered and registered app service', { serviceName: name });
45
- }
46
- }
47
- }
48
- }
49
49
  }
@@ -8,8 +8,19 @@ export declare class ObjectStackProtocolImplementation implements ObjectStackPro
8
8
  getDiscovery(_request: {}): Promise<{
9
9
  version: string;
10
10
  apiName: string;
11
- capabilities: string[];
12
- endpoints: {};
11
+ capabilities: {
12
+ graphql: boolean;
13
+ search: boolean;
14
+ websockets: boolean;
15
+ files: boolean;
16
+ analytics: boolean;
17
+ hub: boolean;
18
+ };
19
+ endpoints: {
20
+ data: string;
21
+ metadata: string;
22
+ auth: string;
23
+ };
13
24
  }>;
14
25
  getMetaTypes(_request: {}): Promise<{
15
26
  types: string[];
@@ -89,6 +100,20 @@ export declare class ObjectStackProtocolImplementation implements ObjectStackPro
89
100
  records: any[];
90
101
  }): Promise<any>;
91
102
  updateManyData(_request: UpdateManyDataRequest): Promise<any>;
103
+ analyticsQuery(_request: any): Promise<any>;
104
+ getAnalyticsMeta(_request: any): Promise<any>;
105
+ triggerAutomation(_request: any): Promise<any>;
106
+ listSpaces(_request: any): Promise<any>;
107
+ createSpace(_request: any): Promise<any>;
108
+ installPlugin(_request: any): Promise<any>;
92
109
  deleteManyData(request: DeleteManyDataRequest): Promise<any>;
110
+ saveMetaItem(request: {
111
+ type: string;
112
+ name: string;
113
+ item?: any;
114
+ }): Promise<{
115
+ success: boolean;
116
+ message: string;
117
+ }>;
93
118
  }
94
119
  //# sourceMappingURL=protocol.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EACR,kBAAkB,EAClB,mBAAmB,EACnB,qBA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AC,QAAQ,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAI7C,iBAAiB,CAAC,QAAQ,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAI9C,UAAU,CAAC,QAAQ,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAIvC,WAAW,CAAC,QAAQ,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAIxC,aAAa,CAAC,QAAQ,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAI1C,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,GAAG,CAAC;IAQ5D,YAAY,CAAC,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,GAAG,CAAA;KAAE;;;;CAWzE"}
package/dist/protocol.js CHANGED
@@ -21,8 +21,19 @@ export class ObjectStackProtocolImplementation {
21
21
  return {
22
22
  version: '1.0',
23
23
  apiName: 'ObjectStack API',
24
- capabilities: ['metadata', 'data', 'ui'],
25
- endpoints: {}
24
+ capabilities: {
25
+ graphql: false,
26
+ search: false,
27
+ websockets: false,
28
+ files: true,
29
+ analytics: false,
30
+ hub: false
31
+ },
32
+ endpoints: {
33
+ data: '/api/data',
34
+ metadata: '/api/meta',
35
+ auth: '/api/auth'
36
+ }
26
37
  };
27
38
  }
28
39
  async getMetaTypes(_request) {
@@ -197,6 +208,24 @@ export class ObjectStackProtocolImplementation {
197
208
  // TODO: Implement proper updateMany in DataEngine
198
209
  throw new Error('updateManyData not implemented');
199
210
  }
211
+ async analyticsQuery(_request) {
212
+ throw new Error('analyticsQuery not implemented');
213
+ }
214
+ async getAnalyticsMeta(_request) {
215
+ throw new Error('getAnalyticsMeta not implemented');
216
+ }
217
+ async triggerAutomation(_request) {
218
+ throw new Error('triggerAutomation not implemented');
219
+ }
220
+ async listSpaces(_request) {
221
+ throw new Error('listSpaces not implemented');
222
+ }
223
+ async createSpace(_request) {
224
+ throw new Error('createSpace not implemented');
225
+ }
226
+ async installPlugin(_request) {
227
+ throw new Error('installPlugin not implemented');
228
+ }
200
229
  async deleteManyData(request) {
201
230
  // This expects deleting by IDs.
202
231
  return this.engine.delete(request.object, {
@@ -204,4 +233,15 @@ export class ObjectStackProtocolImplementation {
204
233
  ...request.options
205
234
  });
206
235
  }
236
+ async saveMetaItem(request) {
237
+ if (!request.item) {
238
+ throw new Error('Item data is required');
239
+ }
240
+ // Default implementation saves to Memory Registry
241
+ SchemaRegistry.registerItem(request.type, request.item, 'name');
242
+ return {
243
+ success: true,
244
+ message: 'Saved to memory registry'
245
+ };
246
+ }
207
247
  }