@objectstack/objectql 1.0.2 → 1.0.5
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 +22 -0
- package/CHANGELOG.md +42 -0
- package/dist/{registry.d.ts → index.d.mts} +433 -3
- package/dist/index.d.ts +999 -6
- package/dist/index.js +798 -9
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +768 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +5 -5
- package/src/plugin.ts +8 -4
- package/tsconfig.json +1 -3
- package/dist/engine.d.ts +0 -304
- package/dist/engine.d.ts.map +0 -1
- package/dist/engine.js +0 -445
- package/dist/index.d.ts.map +0 -1
- package/dist/plugin.d.ts +0 -14
- package/dist/plugin.d.ts.map +0 -1
- package/dist/plugin.js +0 -49
- package/dist/protocol.d.ts +0 -119
- package/dist/protocol.d.ts.map +0 -1
- package/dist/protocol.js +0 -247
- package/dist/registry.d.ts.map +0 -1
- package/dist/registry.js +0 -119
package/dist/engine.js
DELETED
|
@@ -1,445 +0,0 @@
|
|
|
1
|
-
import { createLogger } from '@objectstack/core';
|
|
2
|
-
import { CoreServiceName } from '@objectstack/spec/system';
|
|
3
|
-
import { SchemaRegistry } from './registry.js';
|
|
4
|
-
/**
|
|
5
|
-
* ObjectQL Engine
|
|
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)
|
|
11
|
-
*/
|
|
12
|
-
export class ObjectQL {
|
|
13
|
-
constructor(hostContext = {}) {
|
|
14
|
-
this.drivers = new Map();
|
|
15
|
-
this.defaultDriver = null;
|
|
16
|
-
// Hooks Registry
|
|
17
|
-
this.hooks = {
|
|
18
|
-
'beforeFind': [], 'afterFind': [],
|
|
19
|
-
'beforeInsert': [], 'afterInsert': [],
|
|
20
|
-
'beforeUpdate': [], 'afterUpdate': [],
|
|
21
|
-
'beforeDelete': [], 'afterDelete': [],
|
|
22
|
-
};
|
|
23
|
-
// Host provided context additions (e.g. Server router)
|
|
24
|
-
this.hostContext = {};
|
|
25
|
-
this.hostContext = hostContext;
|
|
26
|
-
// Use provided logger or create a new one
|
|
27
|
-
this.logger = hostContext.logger || createLogger({ level: 'info', format: 'pretty' });
|
|
28
|
-
this.logger.info('ObjectQL Engine Instance Created');
|
|
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
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Expose the SchemaRegistry for plugins to register metadata
|
|
44
|
-
*/
|
|
45
|
-
get registry() {
|
|
46
|
-
return SchemaRegistry;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Load and Register a Plugin
|
|
50
|
-
*/
|
|
51
|
-
async use(manifestPart, runtimePart) {
|
|
52
|
-
this.logger.debug('Loading plugin', {
|
|
53
|
-
hasManifest: !!manifestPart,
|
|
54
|
-
hasRuntime: !!runtimePart
|
|
55
|
-
});
|
|
56
|
-
// 1. Validate / Register Manifest
|
|
57
|
-
if (manifestPart) {
|
|
58
|
-
this.registerApp(manifestPart);
|
|
59
|
-
}
|
|
60
|
-
// 2. Execute Runtime
|
|
61
|
-
if (runtimePart) {
|
|
62
|
-
const pluginDef = runtimePart.default || runtimePart;
|
|
63
|
-
if (pluginDef.onEnable) {
|
|
64
|
-
this.logger.debug('Executing plugin runtime onEnable');
|
|
65
|
-
const context = {
|
|
66
|
-
ql: this,
|
|
67
|
-
logger: this.logger,
|
|
68
|
-
// Expose the driver registry helper explicitly if needed
|
|
69
|
-
drivers: {
|
|
70
|
-
register: (driver) => this.registerDriver(driver)
|
|
71
|
-
},
|
|
72
|
-
...this.hostContext
|
|
73
|
-
};
|
|
74
|
-
await pluginDef.onEnable(context);
|
|
75
|
-
this.logger.debug('Plugin runtime onEnable completed');
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Register a hook
|
|
81
|
-
* @param event The event name (e.g. 'beforeFind', 'afterInsert')
|
|
82
|
-
* @param handler The handler function
|
|
83
|
-
*/
|
|
84
|
-
registerHook(event, handler) {
|
|
85
|
-
if (!this.hooks[event]) {
|
|
86
|
-
this.hooks[event] = [];
|
|
87
|
-
}
|
|
88
|
-
this.hooks[event].push(handler);
|
|
89
|
-
this.logger.debug('Registered hook', { event, totalHandlers: this.hooks[event].length });
|
|
90
|
-
}
|
|
91
|
-
async triggerHooks(event, context) {
|
|
92
|
-
const handlers = this.hooks[event] || [];
|
|
93
|
-
if (handlers.length === 0) {
|
|
94
|
-
this.logger.debug('No hooks registered for event', { event });
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
this.logger.debug('Triggering hooks', { event, count: handlers.length });
|
|
98
|
-
for (const handler of handlers) {
|
|
99
|
-
await handler(context);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Register contribution (Manifest)
|
|
104
|
-
*/
|
|
105
|
-
registerApp(manifest) {
|
|
106
|
-
const id = manifest.id;
|
|
107
|
-
this.logger.debug('Registering app manifest', { id });
|
|
108
|
-
// Register objects
|
|
109
|
-
if (manifest.objects) {
|
|
110
|
-
if (Array.isArray(manifest.objects)) {
|
|
111
|
-
this.logger.debug('Registering objects from manifest (Array)', { id, objectCount: manifest.objects.length });
|
|
112
|
-
for (const objDef of manifest.objects) {
|
|
113
|
-
SchemaRegistry.registerObject(objDef);
|
|
114
|
-
this.logger.debug('Registered Object', { object: objDef.name, from: id });
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
this.logger.debug('Registering objects from manifest (Map)', { id, objectCount: Object.keys(manifest.objects).length });
|
|
119
|
-
for (const [name, objDef] of Object.entries(manifest.objects)) {
|
|
120
|
-
// Ensure name in definition matches key
|
|
121
|
-
objDef.name = name;
|
|
122
|
-
SchemaRegistry.registerObject(objDef);
|
|
123
|
-
this.logger.debug('Registered Object', { object: name, from: id });
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
// Register contributions
|
|
128
|
-
if (manifest.contributes?.kinds) {
|
|
129
|
-
this.logger.debug('Registering kinds from manifest', { id, kindCount: manifest.contributes.kinds.length });
|
|
130
|
-
for (const kind of manifest.contributes.kinds) {
|
|
131
|
-
SchemaRegistry.registerKind(kind);
|
|
132
|
-
this.logger.debug('Registered Kind', { kind: kind.name || kind.type, from: id });
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Register a new storage driver
|
|
138
|
-
*/
|
|
139
|
-
registerDriver(driver, isDefault = false) {
|
|
140
|
-
if (this.drivers.has(driver.name)) {
|
|
141
|
-
this.logger.warn('Driver already registered, skipping', { driverName: driver.name });
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
this.drivers.set(driver.name, driver);
|
|
145
|
-
this.logger.info('Registered driver', {
|
|
146
|
-
driverName: driver.name,
|
|
147
|
-
version: driver.version
|
|
148
|
-
});
|
|
149
|
-
if (isDefault || this.drivers.size === 1) {
|
|
150
|
-
this.defaultDriver = driver.name;
|
|
151
|
-
this.logger.info('Set default driver', { driverName: driver.name });
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Helper to get object definition
|
|
156
|
-
*/
|
|
157
|
-
getSchema(objectName) {
|
|
158
|
-
return SchemaRegistry.getObject(objectName);
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Helper to get the target driver
|
|
162
|
-
*/
|
|
163
|
-
getDriver(objectName) {
|
|
164
|
-
const object = SchemaRegistry.getObject(objectName);
|
|
165
|
-
// 1. If object definition exists, check for explicit datasource
|
|
166
|
-
if (object) {
|
|
167
|
-
const datasourceName = object.datasource || 'default';
|
|
168
|
-
// If configured for 'default', try to find the default driver
|
|
169
|
-
if (datasourceName === 'default') {
|
|
170
|
-
if (this.defaultDriver && this.drivers.has(this.defaultDriver)) {
|
|
171
|
-
return this.drivers.get(this.defaultDriver);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
else {
|
|
175
|
-
// Specific datasource requested
|
|
176
|
-
if (this.drivers.has(datasourceName)) {
|
|
177
|
-
return this.drivers.get(datasourceName);
|
|
178
|
-
}
|
|
179
|
-
throw new Error(`[ObjectQL] Datasource '${datasourceName}' configured for object '${objectName}' is not registered.`);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
// 2. Fallback for ad-hoc objects or missing definitions
|
|
183
|
-
if (this.defaultDriver) {
|
|
184
|
-
return this.drivers.get(this.defaultDriver);
|
|
185
|
-
}
|
|
186
|
-
throw new Error(`[ObjectQL] No driver available for object '${objectName}'`);
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Initialize the engine and all registered drivers
|
|
190
|
-
*/
|
|
191
|
-
async init() {
|
|
192
|
-
this.logger.info('Initializing ObjectQL engine', {
|
|
193
|
-
driverCount: this.drivers.size,
|
|
194
|
-
drivers: Array.from(this.drivers.keys())
|
|
195
|
-
});
|
|
196
|
-
for (const [name, driver] of this.drivers) {
|
|
197
|
-
try {
|
|
198
|
-
await driver.connect();
|
|
199
|
-
this.logger.info('Driver connected successfully', { driverName: name });
|
|
200
|
-
}
|
|
201
|
-
catch (e) {
|
|
202
|
-
this.logger.error('Failed to connect driver', e, { driverName: name });
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
this.logger.info('ObjectQL engine initialization complete');
|
|
206
|
-
}
|
|
207
|
-
async destroy() {
|
|
208
|
-
this.logger.info('Destroying ObjectQL engine', { driverCount: this.drivers.size });
|
|
209
|
-
for (const [name, driver] of this.drivers.entries()) {
|
|
210
|
-
try {
|
|
211
|
-
await driver.disconnect();
|
|
212
|
-
}
|
|
213
|
-
catch (e) {
|
|
214
|
-
this.logger.error('Error disconnecting driver', e, { driverName: name });
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
this.logger.info('ObjectQL engine destroyed');
|
|
218
|
-
}
|
|
219
|
-
// ============================================
|
|
220
|
-
// Helper: Query Conversion
|
|
221
|
-
// ============================================
|
|
222
|
-
toQueryAST(object, options) {
|
|
223
|
-
const ast = { object };
|
|
224
|
-
if (!options)
|
|
225
|
-
return ast;
|
|
226
|
-
if (options.filter) {
|
|
227
|
-
ast.where = options.filter;
|
|
228
|
-
}
|
|
229
|
-
if (options.select) {
|
|
230
|
-
ast.fields = options.select;
|
|
231
|
-
}
|
|
232
|
-
if (options.sort) {
|
|
233
|
-
// Support DataEngineSortSchema variant
|
|
234
|
-
if (Array.isArray(options.sort)) {
|
|
235
|
-
// [{ field: 'a', order: 'asc' }]
|
|
236
|
-
ast.orderBy = options.sort;
|
|
237
|
-
}
|
|
238
|
-
else {
|
|
239
|
-
// Record<string, 'asc' | 'desc' | 1 | -1>
|
|
240
|
-
ast.orderBy = Object.entries(options.sort).map(([field, order]) => ({
|
|
241
|
-
field,
|
|
242
|
-
order: (order === -1 || order === 'desc') ? 'desc' : 'asc'
|
|
243
|
-
}));
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
if (options.top !== undefined)
|
|
247
|
-
ast.limit = options.top;
|
|
248
|
-
else if (options.limit !== undefined)
|
|
249
|
-
ast.limit = options.limit;
|
|
250
|
-
if (options.skip !== undefined)
|
|
251
|
-
ast.offset = options.skip;
|
|
252
|
-
// TODO: Handle populate/joins mapping if Driver supports it in QueryAST
|
|
253
|
-
return ast;
|
|
254
|
-
}
|
|
255
|
-
// ============================================
|
|
256
|
-
// Data Access Methods (IDataEngine Interface)
|
|
257
|
-
// ============================================
|
|
258
|
-
async find(object, query) {
|
|
259
|
-
this.logger.debug('Find operation starting', { object, query });
|
|
260
|
-
const driver = this.getDriver(object);
|
|
261
|
-
const ast = this.toQueryAST(object, query);
|
|
262
|
-
const hookContext = {
|
|
263
|
-
object,
|
|
264
|
-
event: 'beforeFind',
|
|
265
|
-
input: { ast, options: undefined }, // Should map options?
|
|
266
|
-
ql: this
|
|
267
|
-
};
|
|
268
|
-
await this.triggerHooks('beforeFind', hookContext);
|
|
269
|
-
try {
|
|
270
|
-
const result = await driver.find(object, hookContext.input.ast, hookContext.input.options);
|
|
271
|
-
hookContext.event = 'afterFind';
|
|
272
|
-
hookContext.result = result;
|
|
273
|
-
await this.triggerHooks('afterFind', hookContext);
|
|
274
|
-
return hookContext.result;
|
|
275
|
-
}
|
|
276
|
-
catch (e) {
|
|
277
|
-
this.logger.error('Find operation failed', e, { object });
|
|
278
|
-
throw e;
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
async findOne(objectName, query) {
|
|
282
|
-
this.logger.debug('FindOne operation', { objectName });
|
|
283
|
-
const driver = this.getDriver(objectName);
|
|
284
|
-
const ast = this.toQueryAST(objectName, query);
|
|
285
|
-
ast.limit = 1;
|
|
286
|
-
// Reuse find logic or call generic driver.findOne if available
|
|
287
|
-
// Assuming driver has findOne
|
|
288
|
-
return driver.findOne(objectName, ast);
|
|
289
|
-
}
|
|
290
|
-
async insert(object, data, options) {
|
|
291
|
-
this.logger.debug('Insert operation starting', { object, isBatch: Array.isArray(data) });
|
|
292
|
-
const driver = this.getDriver(object);
|
|
293
|
-
const hookContext = {
|
|
294
|
-
object,
|
|
295
|
-
event: 'beforeInsert',
|
|
296
|
-
input: { data, options },
|
|
297
|
-
ql: this
|
|
298
|
-
};
|
|
299
|
-
await this.triggerHooks('beforeInsert', hookContext);
|
|
300
|
-
try {
|
|
301
|
-
let result;
|
|
302
|
-
if (Array.isArray(hookContext.input.data)) {
|
|
303
|
-
// Bulk Create
|
|
304
|
-
if (driver.bulkCreate) {
|
|
305
|
-
result = await driver.bulkCreate(object, hookContext.input.data, hookContext.input.options);
|
|
306
|
-
}
|
|
307
|
-
else {
|
|
308
|
-
// Fallback loop
|
|
309
|
-
result = await Promise.all(hookContext.input.data.map((item) => driver.create(object, item, hookContext.input.options)));
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
else {
|
|
313
|
-
result = await driver.create(object, hookContext.input.data, hookContext.input.options);
|
|
314
|
-
}
|
|
315
|
-
hookContext.event = 'afterInsert';
|
|
316
|
-
hookContext.result = result;
|
|
317
|
-
await this.triggerHooks('afterInsert', hookContext);
|
|
318
|
-
return hookContext.result;
|
|
319
|
-
}
|
|
320
|
-
catch (e) {
|
|
321
|
-
this.logger.error('Insert operation failed', e, { object });
|
|
322
|
-
throw e;
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
async update(object, data, options) {
|
|
326
|
-
// NOTE: This signature is tricky because Driver expects (obj, id, data) usually.
|
|
327
|
-
// DataEngine protocol puts filter in options.
|
|
328
|
-
this.logger.debug('Update operation starting', { object });
|
|
329
|
-
const driver = this.getDriver(object);
|
|
330
|
-
// 1. Extract ID from data or filter if it's a single update by ID
|
|
331
|
-
// This is a simplification. Real implementation needs robust filter handling.
|
|
332
|
-
let id = data.id || data._id;
|
|
333
|
-
if (!id && options?.filter) {
|
|
334
|
-
// Optimization: If filter is simple ID check, extract it
|
|
335
|
-
if (typeof options.filter === 'string')
|
|
336
|
-
id = options.filter;
|
|
337
|
-
else if (options.filter._id)
|
|
338
|
-
id = options.filter._id;
|
|
339
|
-
else if (options.filter.id)
|
|
340
|
-
id = options.filter.id;
|
|
341
|
-
}
|
|
342
|
-
const hookContext = {
|
|
343
|
-
object,
|
|
344
|
-
event: 'beforeUpdate',
|
|
345
|
-
input: { id, data, options },
|
|
346
|
-
ql: this
|
|
347
|
-
};
|
|
348
|
-
await this.triggerHooks('beforeUpdate', hookContext);
|
|
349
|
-
try {
|
|
350
|
-
let result;
|
|
351
|
-
if (hookContext.input.id) {
|
|
352
|
-
// Single update by ID
|
|
353
|
-
result = await driver.update(object, hookContext.input.id, hookContext.input.data, hookContext.input.options);
|
|
354
|
-
}
|
|
355
|
-
else if (options?.multi && driver.updateMany) {
|
|
356
|
-
// Bulk update by Query
|
|
357
|
-
const ast = this.toQueryAST(object, { filter: options.filter });
|
|
358
|
-
result = await driver.updateMany(object, ast, hookContext.input.data, hookContext.input.options);
|
|
359
|
-
}
|
|
360
|
-
else {
|
|
361
|
-
throw new Error('Update requires an ID or options.multi=true');
|
|
362
|
-
}
|
|
363
|
-
hookContext.event = 'afterUpdate';
|
|
364
|
-
hookContext.result = result;
|
|
365
|
-
await this.triggerHooks('afterUpdate', hookContext);
|
|
366
|
-
return hookContext.result;
|
|
367
|
-
}
|
|
368
|
-
catch (e) {
|
|
369
|
-
this.logger.error('Update operation failed', e, { object });
|
|
370
|
-
throw e;
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
async delete(object, options) {
|
|
374
|
-
this.logger.debug('Delete operation starting', { object });
|
|
375
|
-
const driver = this.getDriver(object);
|
|
376
|
-
// Extract ID logic similar to update
|
|
377
|
-
let id = undefined;
|
|
378
|
-
if (options?.filter) {
|
|
379
|
-
if (typeof options.filter === 'string')
|
|
380
|
-
id = options.filter;
|
|
381
|
-
else if (options.filter._id)
|
|
382
|
-
id = options.filter._id;
|
|
383
|
-
else if (options.filter.id)
|
|
384
|
-
id = options.filter.id;
|
|
385
|
-
}
|
|
386
|
-
const hookContext = {
|
|
387
|
-
object,
|
|
388
|
-
event: 'beforeDelete',
|
|
389
|
-
input: { id, options },
|
|
390
|
-
ql: this
|
|
391
|
-
};
|
|
392
|
-
await this.triggerHooks('beforeDelete', hookContext);
|
|
393
|
-
try {
|
|
394
|
-
let result;
|
|
395
|
-
if (hookContext.input.id) {
|
|
396
|
-
result = await driver.delete(object, hookContext.input.id, hookContext.input.options);
|
|
397
|
-
}
|
|
398
|
-
else if (options?.multi && driver.deleteMany) {
|
|
399
|
-
const ast = this.toQueryAST(object, { filter: options.filter });
|
|
400
|
-
result = await driver.deleteMany(object, ast, hookContext.input.options);
|
|
401
|
-
}
|
|
402
|
-
else {
|
|
403
|
-
throw new Error('Delete requires an ID or options.multi=true');
|
|
404
|
-
}
|
|
405
|
-
hookContext.event = 'afterDelete';
|
|
406
|
-
hookContext.result = result;
|
|
407
|
-
await this.triggerHooks('afterDelete', hookContext);
|
|
408
|
-
return hookContext.result;
|
|
409
|
-
}
|
|
410
|
-
catch (e) {
|
|
411
|
-
this.logger.error('Delete operation failed', e, { object });
|
|
412
|
-
throw e;
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
async count(object, query) {
|
|
416
|
-
const driver = this.getDriver(object);
|
|
417
|
-
if (driver.count) {
|
|
418
|
-
const ast = this.toQueryAST(object, { filter: query?.filter });
|
|
419
|
-
return driver.count(object, ast);
|
|
420
|
-
}
|
|
421
|
-
// Fallback to find().length
|
|
422
|
-
const res = await this.find(object, { filter: query?.filter, select: ['_id'] });
|
|
423
|
-
return res.length;
|
|
424
|
-
}
|
|
425
|
-
async aggregate(object, query) {
|
|
426
|
-
const driver = this.getDriver(object);
|
|
427
|
-
this.logger.debug(`Aggregate on ${object} using ${driver.name}`, query);
|
|
428
|
-
// Driver needs support for raw aggregation or mapped aggregation
|
|
429
|
-
// For now, if driver supports 'execute', we might pass it down, or we need to add 'aggregate' to DriverInterface
|
|
430
|
-
// In this version, we'll assume driver might handle it via special 'find' or throw not implemented
|
|
431
|
-
throw new Error('Aggregate not yet fully implemented in ObjectQL->Driver mapping');
|
|
432
|
-
}
|
|
433
|
-
async execute(command, options) {
|
|
434
|
-
// Direct pass-through implies we know which driver to use?
|
|
435
|
-
// Usually execute is tied to a specific object context OR we need a way to select driver.
|
|
436
|
-
// If command has 'object', we use that.
|
|
437
|
-
if (options?.object) {
|
|
438
|
-
const driver = this.getDriver(options.object);
|
|
439
|
-
if (driver.execute) {
|
|
440
|
-
return driver.execute(command, undefined, options);
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
throw new Error('Execute requires options.object to select driver');
|
|
444
|
-
}
|
|
445
|
-
}
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAG/C,OAAO,EAAE,iCAAiC,EAAE,MAAM,eAAe,CAAC;AAGlE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,YAAY,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAGpE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/plugin.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ObjectQL } from './engine.js';
|
|
2
|
-
import { Plugin, PluginContext } from '@objectstack/core';
|
|
3
|
-
export type { Plugin, PluginContext };
|
|
4
|
-
export declare class ObjectQLPlugin implements Plugin {
|
|
5
|
-
name: string;
|
|
6
|
-
type: "objectql";
|
|
7
|
-
version: string;
|
|
8
|
-
private ql;
|
|
9
|
-
private hostContext?;
|
|
10
|
-
constructor(ql?: ObjectQL, hostContext?: Record<string, any>);
|
|
11
|
-
init: (ctx: PluginContext) => Promise<void>;
|
|
12
|
-
start: (ctx: PluginContext) => Promise<void>;
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=plugin.d.ts.map
|
package/dist/plugin.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { ObjectQL } from './engine.js';
|
|
2
|
-
import { ObjectStackProtocolImplementation } from './protocol.js';
|
|
3
|
-
export class ObjectQLPlugin {
|
|
4
|
-
constructor(ql, hostContext) {
|
|
5
|
-
this.name = 'com.objectstack.engine.objectql';
|
|
6
|
-
this.type = 'objectql';
|
|
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
|
-
};
|
|
41
|
-
if (ql) {
|
|
42
|
-
this.ql = ql;
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
this.hostContext = hostContext;
|
|
46
|
-
// Lazily created in init
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
package/dist/protocol.d.ts
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { ObjectStackProtocol } from '@objectstack/spec/api';
|
|
2
|
-
import { IDataEngine } from '@objectstack/core';
|
|
3
|
-
import type { BatchUpdateRequest, BatchUpdateResponse, UpdateManyDataRequest, DeleteManyDataRequest } from '@objectstack/spec/api';
|
|
4
|
-
import type { MetadataCacheRequest, MetadataCacheResponse } from '@objectstack/spec/api';
|
|
5
|
-
export declare class ObjectStackProtocolImplementation implements ObjectStackProtocol {
|
|
6
|
-
private engine;
|
|
7
|
-
constructor(engine: IDataEngine);
|
|
8
|
-
getDiscovery(_request: {}): Promise<{
|
|
9
|
-
version: string;
|
|
10
|
-
apiName: string;
|
|
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
|
-
};
|
|
24
|
-
}>;
|
|
25
|
-
getMetaTypes(_request: {}): Promise<{
|
|
26
|
-
types: string[];
|
|
27
|
-
}>;
|
|
28
|
-
getMetaItems(request: {
|
|
29
|
-
type: string;
|
|
30
|
-
}): Promise<{
|
|
31
|
-
type: string;
|
|
32
|
-
items: unknown[];
|
|
33
|
-
}>;
|
|
34
|
-
getMetaItem(request: {
|
|
35
|
-
type: string;
|
|
36
|
-
name: string;
|
|
37
|
-
}): Promise<{
|
|
38
|
-
type: string;
|
|
39
|
-
name: string;
|
|
40
|
-
item: unknown;
|
|
41
|
-
}>;
|
|
42
|
-
getUiView(request: {
|
|
43
|
-
object: string;
|
|
44
|
-
type: 'list' | 'form';
|
|
45
|
-
}): Promise<any>;
|
|
46
|
-
findData(request: {
|
|
47
|
-
object: string;
|
|
48
|
-
query?: any;
|
|
49
|
-
}): Promise<{
|
|
50
|
-
object: string;
|
|
51
|
-
value: any[];
|
|
52
|
-
records: any[];
|
|
53
|
-
total: number;
|
|
54
|
-
hasMore: boolean;
|
|
55
|
-
}>;
|
|
56
|
-
getData(request: {
|
|
57
|
-
object: string;
|
|
58
|
-
id: string;
|
|
59
|
-
}): Promise<{
|
|
60
|
-
object: string;
|
|
61
|
-
id: string;
|
|
62
|
-
record: any;
|
|
63
|
-
}>;
|
|
64
|
-
createData(request: {
|
|
65
|
-
object: string;
|
|
66
|
-
data: any;
|
|
67
|
-
}): Promise<{
|
|
68
|
-
object: string;
|
|
69
|
-
id: any;
|
|
70
|
-
record: any;
|
|
71
|
-
}>;
|
|
72
|
-
updateData(request: {
|
|
73
|
-
object: string;
|
|
74
|
-
id: string;
|
|
75
|
-
data: any;
|
|
76
|
-
}): Promise<{
|
|
77
|
-
object: string;
|
|
78
|
-
id: string;
|
|
79
|
-
record: any;
|
|
80
|
-
}>;
|
|
81
|
-
deleteData(request: {
|
|
82
|
-
object: string;
|
|
83
|
-
id: string;
|
|
84
|
-
}): Promise<{
|
|
85
|
-
object: string;
|
|
86
|
-
id: string;
|
|
87
|
-
success: boolean;
|
|
88
|
-
}>;
|
|
89
|
-
getMetaItemCached(request: {
|
|
90
|
-
type: string;
|
|
91
|
-
name: string;
|
|
92
|
-
cacheRequest?: MetadataCacheRequest;
|
|
93
|
-
}): Promise<MetadataCacheResponse>;
|
|
94
|
-
batchData(_request: {
|
|
95
|
-
object: string;
|
|
96
|
-
request: BatchUpdateRequest;
|
|
97
|
-
}): Promise<BatchUpdateResponse>;
|
|
98
|
-
createManyData(request: {
|
|
99
|
-
object: string;
|
|
100
|
-
records: any[];
|
|
101
|
-
}): Promise<any>;
|
|
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>;
|
|
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
|
-
}>;
|
|
118
|
-
}
|
|
119
|
-
//# sourceMappingURL=protocol.d.ts.map
|
package/dist/protocol.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,qBAAqB,EACrB,qBAAqB,EACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAA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