@objectstack/objectql 0.6.0 → 0.6.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/index.d.ts CHANGED
@@ -1,199 +1,6 @@
1
- import { HookContext } from '@objectstack/spec/data';
2
- import { DriverOptions } from '@objectstack/spec/system';
3
- import { DriverInterface, IDataEngine, DataEngineQueryOptions } from '@objectstack/core';
4
1
  export { SchemaRegistry } from './registry';
5
2
  export { ObjectStackProtocolImplementation } from './protocol';
6
- export type HookHandler = (context: HookContext) => Promise<void> | void;
7
- /**
8
- * Host Context provided to plugins
9
- */
10
- export interface PluginContext {
11
- ql: ObjectQL;
12
- logger: Console;
13
- [key: string]: any;
14
- }
15
- /**
16
- * ObjectQL Engine
17
- *
18
- * Implements the IDataEngine interface for data persistence.
19
- */
20
- export declare class ObjectQL implements IDataEngine {
21
- private drivers;
22
- private defaultDriver;
23
- private hooks;
24
- private hostContext;
25
- constructor(hostContext?: Record<string, any>);
26
- /**
27
- * Load and Register a Plugin
28
- */
29
- use(manifestPart: any, runtimePart?: any): Promise<void>;
30
- /**
31
- * Register a hook
32
- * @param event The event name (e.g. 'beforeFind', 'afterInsert')
33
- * @param handler The handler function
34
- */
35
- registerHook(event: string, handler: HookHandler): void;
36
- private triggerHooks;
37
- registerApp(manifestPart: any): void;
38
- /**
39
- * Register a new storage driver
40
- */
41
- registerDriver(driver: DriverInterface, isDefault?: boolean): void;
42
- /**
43
- * Helper to get object definition
44
- */
45
- getSchema(objectName: string): {
46
- fields: Record<string, {
47
- type: "number" | "boolean" | "code" | "date" | "text" | "textarea" | "email" | "url" | "phone" | "password" | "markdown" | "html" | "richtext" | "currency" | "percent" | "datetime" | "time" | "toggle" | "select" | "multiselect" | "radio" | "checkboxes" | "lookup" | "master_detail" | "tree" | "image" | "file" | "avatar" | "video" | "audio" | "formula" | "summary" | "autonumber" | "location" | "address" | "json" | "color" | "rating" | "slider" | "signature" | "qrcode" | "progress" | "tags" | "vector";
48
- required: boolean;
49
- searchable: boolean;
50
- multiple: boolean;
51
- unique: boolean;
52
- deleteBehavior: "set_null" | "cascade" | "restrict";
53
- hidden: boolean;
54
- readonly: boolean;
55
- encryption: boolean;
56
- index: boolean;
57
- externalId: boolean;
58
- options?: {
59
- value: string;
60
- label: string;
61
- color?: string | undefined;
62
- default?: boolean | undefined;
63
- }[] | undefined;
64
- min?: number | undefined;
65
- max?: number | undefined;
66
- formula?: string | undefined;
67
- label?: string | undefined;
68
- precision?: number | undefined;
69
- name?: string | undefined;
70
- description?: string | undefined;
71
- format?: string | undefined;
72
- defaultValue?: any;
73
- maxLength?: number | undefined;
74
- minLength?: number | undefined;
75
- scale?: number | undefined;
76
- reference?: string | undefined;
77
- referenceFilters?: string[] | undefined;
78
- writeRequiresMasterRead?: boolean | undefined;
79
- expression?: string | undefined;
80
- summaryOperations?: {
81
- object: string;
82
- function: "count" | "sum" | "avg" | "min" | "max";
83
- field: string;
84
- } | undefined;
85
- language?: string | undefined;
86
- theme?: string | undefined;
87
- lineNumbers?: boolean | undefined;
88
- maxRating?: number | undefined;
89
- allowHalf?: boolean | undefined;
90
- displayMap?: boolean | undefined;
91
- allowGeocoding?: boolean | undefined;
92
- addressFormat?: "us" | "uk" | "international" | undefined;
93
- colorFormat?: "hex" | "rgb" | "rgba" | "hsl" | undefined;
94
- allowAlpha?: boolean | undefined;
95
- presetColors?: string[] | undefined;
96
- step?: number | undefined;
97
- showValue?: boolean | undefined;
98
- marks?: Record<string, string> | undefined;
99
- barcodeFormat?: "qr" | "ean13" | "ean8" | "code128" | "code39" | "upca" | "upce" | undefined;
100
- qrErrorCorrection?: "L" | "M" | "Q" | "H" | undefined;
101
- displayValue?: boolean | undefined;
102
- allowScanning?: boolean | undefined;
103
- currencyConfig?: {
104
- precision: number;
105
- currencyMode: "dynamic" | "fixed";
106
- defaultCurrency: string;
107
- } | undefined;
108
- vectorConfig?: {
109
- dimensions: number;
110
- distanceMetric: "cosine" | "euclidean" | "dotProduct" | "manhattan";
111
- normalized: boolean;
112
- indexed: boolean;
113
- indexType?: "flat" | "hnsw" | "ivfflat" | undefined;
114
- } | undefined;
115
- }>;
116
- name: string;
117
- active: boolean;
118
- isSystem: boolean;
119
- abstract: boolean;
120
- datasource: string;
121
- tags?: string[] | undefined;
122
- label?: string | undefined;
123
- description?: string | undefined;
124
- search?: {
125
- fields: string[];
126
- displayFields?: string[] | undefined;
127
- filters?: string[] | undefined;
128
- } | undefined;
129
- pluralLabel?: string | undefined;
130
- icon?: string | undefined;
131
- tableName?: string | undefined;
132
- indexes?: {
133
- fields: string[];
134
- type?: "hash" | "btree" | "gin" | "gist" | undefined;
135
- name?: string | undefined;
136
- unique?: boolean | undefined;
137
- }[] | undefined;
138
- validations?: any[] | undefined;
139
- titleFormat?: string | undefined;
140
- compactLayout?: string[] | undefined;
141
- enable?: {
142
- searchable: boolean;
143
- trackHistory: boolean;
144
- apiEnabled: boolean;
145
- files: boolean;
146
- feeds: boolean;
147
- activities: boolean;
148
- trash: boolean;
149
- mru: boolean;
150
- clone: boolean;
151
- apiMethods?: ("update" | "delete" | "get" | "list" | "create" | "upsert" | "bulk" | "aggregate" | "history" | "search" | "restore" | "purge" | "import" | "export")[] | undefined;
152
- } | undefined;
153
- } | undefined;
154
- /**
155
- * Helper to get the target driver
156
- */
157
- private getDriver;
158
- /**
159
- * Initialize the engine and all registered drivers
160
- */
161
- init(): Promise<void>;
162
- destroy(): Promise<void>;
163
- /**
164
- * Find records matching a query (IDataEngine interface)
165
- *
166
- * @param object - Object name
167
- * @param query - Query options (IDataEngine format)
168
- * @returns Promise resolving to array of records
169
- */
170
- find(object: string, query?: DataEngineQueryOptions): Promise<any[]>;
171
- findOne(object: string, idOrQuery: string | any, options?: DriverOptions): Promise<any>;
172
- /**
173
- * Insert a new record (IDataEngine interface)
174
- *
175
- * @param object - Object name
176
- * @param data - Data to insert
177
- * @returns Promise resolving to the created record
178
- */
179
- insert(object: string, data: any): Promise<any>;
180
- /**
181
- * Update a record by ID (IDataEngine interface)
182
- *
183
- * @param object - Object name
184
- * @param id - Record ID
185
- * @param data - Updated data
186
- * @returns Promise resolving to the updated record
187
- */
188
- update(object: string, id: any, data: any): Promise<any>;
189
- /**
190
- * Delete a record by ID (IDataEngine interface)
191
- *
192
- * @param object - Object name
193
- * @param id - Record ID
194
- * @returns Promise resolving to true if deleted, false otherwise
195
- */
196
- delete(object: string, id: any): Promise<boolean>;
197
- }
198
- export * from './plugin';
3
+ export { ObjectQL } from './engine';
4
+ export type { ObjectQLHostContext, HookHandler } from './engine';
5
+ export { ObjectQLPlugin } from './plugin';
199
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE/D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAIzF,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,iCAAiC,EAAE,MAAM,YAAY,CAAC;AAG/D,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AAEzE;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,QAAQ,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAEhB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED;;;;GAIG;AACH,qBAAa,QAAS,YAAW,WAAW;IAC1C,OAAO,CAAC,OAAO,CAAsC;IACrD,OAAO,CAAC,aAAa,CAAuB;IAG5C,OAAO,CAAC,KAAK,CAKX;IAGF,OAAO,CAAC,WAAW,CAA2B;gBAElC,WAAW,GAAE,MAAM,CAAC,MAA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MAAM,EAAE,KAAK,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IA4DpE,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,GAAG,EAAE,OAAO,CAAC,EAAE,aAAa;IAwB9E;;;;;;OAMG;IACG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IA+BrD;;;;;;;OAOG;IACG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAoB9D;;;;;;OAMG;IACG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC;CAoBxD;AACD,cAAc,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAG5C,OAAO,EAAE,iCAAiC,EAAE,MAAM,YAAY,CAAC;AAG/D,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,YAAY,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAGjE,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC"}
package/dist/index.js CHANGED
@@ -1,344 +1,9 @@
1
- import { SchemaRegistry } from './registry';
2
- // Export Registry for consumers
1
+ // Export Registry
3
2
  export { SchemaRegistry } from './registry';
3
+ // Export Protocol Implementation
4
4
  export { ObjectStackProtocolImplementation } from './protocol';
5
- /**
6
- * ObjectQL Engine
7
- *
8
- * Implements the IDataEngine interface for data persistence.
9
- */
10
- export class ObjectQL {
11
- constructor(hostContext = {}) {
12
- this.drivers = new Map();
13
- this.defaultDriver = null;
14
- // Hooks Registry
15
- this.hooks = {
16
- 'beforeFind': [], 'afterFind': [],
17
- 'beforeInsert': [], 'afterInsert': [],
18
- 'beforeUpdate': [], 'afterUpdate': [],
19
- 'beforeDelete': [], 'afterDelete': [],
20
- };
21
- // Host provided context additions (e.g. Server router)
22
- this.hostContext = {};
23
- this.hostContext = hostContext;
24
- console.log(`[ObjectQL] Engine Instance Created`);
25
- }
26
- /**
27
- * Load and Register a Plugin
28
- */
29
- async use(manifestPart, runtimePart) {
30
- // 1. Validate / Register Manifest
31
- if (manifestPart) {
32
- this.registerApp(manifestPart);
33
- }
34
- // 2. Execute Runtime
35
- if (runtimePart) {
36
- const pluginDef = runtimePart.default || runtimePart;
37
- if (pluginDef.onEnable) {
38
- const context = {
39
- ql: this,
40
- logger: console,
41
- // Expose the driver registry helper explicitly if needed
42
- drivers: {
43
- register: (driver) => this.registerDriver(driver)
44
- },
45
- ...this.hostContext
46
- };
47
- await pluginDef.onEnable(context);
48
- }
49
- }
50
- }
51
- /**
52
- * Register a hook
53
- * @param event The event name (e.g. 'beforeFind', 'afterInsert')
54
- * @param handler The handler function
55
- */
56
- registerHook(event, handler) {
57
- if (!this.hooks[event]) {
58
- this.hooks[event] = [];
59
- }
60
- this.hooks[event].push(handler);
61
- console.log(`[ObjectQL] Registered hook for ${event}`);
62
- }
63
- async triggerHooks(event, context) {
64
- const handlers = this.hooks[event] || [];
65
- for (const handler of handlers) {
66
- // In a real system, we might want to catch errors here or allow them to bubble up
67
- await handler(context);
68
- }
69
- }
70
- registerApp(manifestPart) {
71
- // 1. Handle Module Imports (commonjs/esm interop)
72
- // If the passed object is a module namespace with a default export, use that.
73
- const raw = manifestPart.default || manifestPart;
74
- // Support nested manifest property (Stack Definition)
75
- // We merge the inner manifest metadata (id, version, etc) with the outer container (objects, apps)
76
- const manifest = raw.manifest ? { ...raw, ...raw.manifest } : raw;
77
- // In a real scenario, we might strictly parse this using Zod
78
- // For now, simple ID check
79
- const id = manifest.id || manifest.name;
80
- if (!id) {
81
- console.warn(`[ObjectQL] Plugin manifest missing ID (keys: ${Object.keys(manifest)})`, manifest);
82
- // Don't return, try to proceed if it looks like an App (Apps might use 'name' instead of 'id')
83
- // return;
84
- }
85
- console.log(`[ObjectQL] Loading App: ${id}`);
86
- SchemaRegistry.registerPlugin(manifest);
87
- // Register Objects from App/Plugin
88
- if (manifest.objects) {
89
- for (const obj of manifest.objects) {
90
- // Ensure object name is registered globally
91
- SchemaRegistry.registerObject(obj);
92
- console.log(`[ObjectQL] Registered Object: ${obj.name}`);
93
- }
94
- }
95
- // Register contributions
96
- if (manifest.contributes?.kinds) {
97
- for (const kind of manifest.contributes.kinds) {
98
- SchemaRegistry.registerKind(kind);
99
- }
100
- }
101
- }
102
- /**
103
- * Register a new storage driver
104
- */
105
- registerDriver(driver, isDefault = false) {
106
- if (this.drivers.has(driver.name)) {
107
- console.warn(`[ObjectQL] Driver ${driver.name} is already registered. Skipping.`);
108
- return;
109
- }
110
- this.drivers.set(driver.name, driver);
111
- console.log(`[ObjectQL] Registered driver: ${driver.name} v${driver.version}`);
112
- if (isDefault || this.drivers.size === 1) {
113
- this.defaultDriver = driver.name;
114
- }
115
- }
116
- /**
117
- * Helper to get object definition
118
- */
119
- getSchema(objectName) {
120
- return SchemaRegistry.getObject(objectName);
121
- }
122
- /**
123
- * Helper to get the target driver
124
- */
125
- getDriver(objectName) {
126
- const object = SchemaRegistry.getObject(objectName);
127
- // 1. If object definition exists, check for explicit datasource
128
- if (object) {
129
- const datasourceName = object.datasource || 'default';
130
- // If configured for 'default', try to find the default driver
131
- if (datasourceName === 'default') {
132
- if (this.defaultDriver && this.drivers.has(this.defaultDriver)) {
133
- return this.drivers.get(this.defaultDriver);
134
- }
135
- // Fallback: If 'default' not explicitly set, use the first available driver?
136
- // Better to be strict.
137
- }
138
- else {
139
- // Specific datasource requested
140
- if (this.drivers.has(datasourceName)) {
141
- return this.drivers.get(datasourceName);
142
- }
143
- // If not found, fall back to default? Or error?
144
- // Standard behavior: Error if specific datasource is missing.
145
- throw new Error(`[ObjectQL] Datasource '${datasourceName}' configured for object '${objectName}' is not registered.`);
146
- }
147
- }
148
- // 2. Fallback for ad-hoc objects or missing definitions
149
- // If we have a default driver, use it.
150
- if (this.defaultDriver) {
151
- if (!object) {
152
- console.warn(`[ObjectQL] Object '${objectName}' not found in registry. Using default driver.`);
153
- }
154
- return this.drivers.get(this.defaultDriver);
155
- }
156
- throw new Error(`[ObjectQL] No driver available for object '${objectName}'`);
157
- }
158
- /**
159
- * Initialize the engine and all registered drivers
160
- */
161
- async init() {
162
- console.log('[ObjectQL] Initializing drivers...');
163
- for (const [name, driver] of this.drivers) {
164
- try {
165
- await driver.connect();
166
- }
167
- catch (e) {
168
- console.error(`[ObjectQL] Failed to connect driver ${name}`, e);
169
- }
170
- }
171
- // In a real app, we would sync schemas here
172
- }
173
- async destroy() {
174
- for (const driver of this.drivers.values()) {
175
- await driver.disconnect();
176
- }
177
- }
178
- // ============================================
179
- // Data Access Methods (IDataEngine Interface)
180
- // ============================================
181
- /**
182
- * Find records matching a query (IDataEngine interface)
183
- *
184
- * @param object - Object name
185
- * @param query - Query options (IDataEngine format)
186
- * @returns Promise resolving to array of records
187
- */
188
- async find(object, query) {
189
- const driver = this.getDriver(object);
190
- // Convert DataEngineQueryOptions to QueryAST
191
- let ast = { object };
192
- if (query) {
193
- // Map DataEngineQueryOptions to QueryAST
194
- if (query.filter) {
195
- ast.where = query.filter;
196
- }
197
- if (query.select) {
198
- ast.fields = query.select;
199
- }
200
- if (query.sort) {
201
- // Convert sort Record to orderBy array
202
- // sort: { createdAt: -1, name: 'asc' } => orderBy: [{ field: 'createdAt', order: 'desc' }, { field: 'name', order: 'asc' }]
203
- ast.orderBy = Object.entries(query.sort).map(([field, order]) => ({
204
- field,
205
- order: (order === -1 || order === 'desc') ? 'desc' : 'asc'
206
- }));
207
- }
208
- // Handle both limit and top (top takes precedence)
209
- if (query.top !== undefined) {
210
- ast.limit = query.top;
211
- }
212
- else if (query.limit !== undefined) {
213
- ast.limit = query.limit;
214
- }
215
- if (query.skip !== undefined) {
216
- ast.offset = query.skip;
217
- }
218
- }
219
- // Set default limit if not specified
220
- if (ast.limit === undefined)
221
- ast.limit = 100;
222
- // Trigger Before Hook
223
- const hookContext = {
224
- object,
225
- event: 'beforeFind',
226
- input: { ast, options: undefined },
227
- ql: this
228
- };
229
- await this.triggerHooks('beforeFind', hookContext);
230
- try {
231
- const result = await driver.find(object, hookContext.input.ast, hookContext.input.options);
232
- // Trigger After Hook
233
- hookContext.event = 'afterFind';
234
- hookContext.result = result;
235
- await this.triggerHooks('afterFind', hookContext);
236
- return hookContext.result;
237
- }
238
- catch (e) {
239
- // hookContext.error = e;
240
- throw e;
241
- }
242
- }
243
- async findOne(object, idOrQuery, options) {
244
- const driver = this.getDriver(object);
245
- let ast;
246
- if (typeof idOrQuery === 'string') {
247
- ast = {
248
- object,
249
- where: { _id: idOrQuery }
250
- };
251
- }
252
- else {
253
- // Assume query object
254
- // reuse logic from find() or just wrap it
255
- if (idOrQuery.where || idOrQuery.fields) {
256
- ast = { object, ...idOrQuery };
257
- }
258
- else {
259
- ast = { object, where: idOrQuery };
260
- }
261
- }
262
- // Limit 1 for findOne
263
- ast.limit = 1;
264
- return driver.findOne(object, ast, options);
265
- }
266
- /**
267
- * Insert a new record (IDataEngine interface)
268
- *
269
- * @param object - Object name
270
- * @param data - Data to insert
271
- * @returns Promise resolving to the created record
272
- */
273
- async insert(object, data) {
274
- const driver = this.getDriver(object);
275
- // 1. Get Schema
276
- const schema = SchemaRegistry.getObject(object);
277
- if (schema) {
278
- // TODO: Validation Logic
279
- // validate(schema, data);
280
- }
281
- // 2. Trigger Before Hook
282
- const hookContext = {
283
- object,
284
- event: 'beforeInsert',
285
- input: { data, options: undefined },
286
- ql: this
287
- };
288
- await this.triggerHooks('beforeInsert', hookContext);
289
- // 3. Execute Driver
290
- const result = await driver.create(object, hookContext.input.data, hookContext.input.options);
291
- // 4. Trigger After Hook
292
- hookContext.event = 'afterInsert';
293
- hookContext.result = result;
294
- await this.triggerHooks('afterInsert', hookContext);
295
- return hookContext.result;
296
- }
297
- /**
298
- * Update a record by ID (IDataEngine interface)
299
- *
300
- * @param object - Object name
301
- * @param id - Record ID
302
- * @param data - Updated data
303
- * @returns Promise resolving to the updated record
304
- */
305
- async update(object, id, data) {
306
- const driver = this.getDriver(object);
307
- const hookContext = {
308
- object,
309
- event: 'beforeUpdate',
310
- input: { id, data, options: undefined },
311
- ql: this
312
- };
313
- await this.triggerHooks('beforeUpdate', hookContext);
314
- const result = await driver.update(object, hookContext.input.id, hookContext.input.data, hookContext.input.options);
315
- hookContext.event = 'afterUpdate';
316
- hookContext.result = result;
317
- await this.triggerHooks('afterUpdate', hookContext);
318
- return hookContext.result;
319
- }
320
- /**
321
- * Delete a record by ID (IDataEngine interface)
322
- *
323
- * @param object - Object name
324
- * @param id - Record ID
325
- * @returns Promise resolving to true if deleted, false otherwise
326
- */
327
- async delete(object, id) {
328
- const driver = this.getDriver(object);
329
- const hookContext = {
330
- object,
331
- event: 'beforeDelete',
332
- input: { id, options: undefined },
333
- ql: this
334
- };
335
- await this.triggerHooks('beforeDelete', hookContext);
336
- const result = await driver.delete(object, hookContext.input.id, hookContext.input.options);
337
- hookContext.event = 'afterDelete';
338
- hookContext.result = result;
339
- await this.triggerHooks('afterDelete', hookContext);
340
- // Driver.delete() already returns boolean per DriverInterface spec
341
- return hookContext.result;
342
- }
343
- }
344
- export * from './plugin';
5
+ // Export Engine
6
+ export { ObjectQL } from './engine';
7
+ // Export Plugin Shim
8
+ export { ObjectQLPlugin } from './plugin';
9
+ // Moved logic to engine.ts
package/dist/plugin.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ObjectQL } from './index';
1
+ import { ObjectQL } from './engine';
2
2
  import { Plugin, PluginContext } from '@objectstack/core';
3
3
  export type { Plugin, PluginContext };
4
4
  export declare class ObjectQLPlugin implements Plugin {
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,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,UAAU,CAAC;AAEpC,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"}
package/dist/plugin.js CHANGED
@@ -1,4 +1,4 @@
1
- import { ObjectQL } from './index';
1
+ import { ObjectQL } from './engine';
2
2
  import { ObjectStackProtocolImplementation } from './protocol';
3
3
  export class ObjectQLPlugin {
4
4
  constructor(ql, hostContext) {
@@ -13,6 +13,10 @@ export declare class SchemaRegistry {
13
13
  * @param keyField The property to use as the unique key (default: 'name')
14
14
  */
15
15
  static registerItem<T>(type: string, item: T, keyField?: keyof T): void;
16
+ /**
17
+ * Universal Unregister Method
18
+ */
19
+ static unregisterItem(type: string, name: string): void;
16
20
  /**
17
21
  * Universal Get Method
18
22
  */
@@ -1 +1 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D;;;GAGG;AACH,qBAAa,cAAc;IAEzB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAuC;IAE9D;;;;;OAKG;IACH,MAAM,CAAC,YAAY,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,QAAQ,GAAE,MAAM,CAAqB;IAcnF;;OAEG;IACH,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAI5D;;OAEG;IACH,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,EAAE;IAItC;;OAEG;IACH,MAAM,CAAC,kBAAkB,IAAI,MAAM,EAAE;IAQrC;;OAEG;IACH,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,aAAa;IAI3C,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;IAIzD,MAAM,CAAC,aAAa,IAAI,aAAa,EAAE;IAIvC;;OAEG;IACH,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,mBAAmB;IAInD,MAAM,CAAC,aAAa,IAAI,mBAAmB,EAAE;IAI7C;;OAEG;IACH,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,IAAI,mBAAmB,EAAE;IAI7C;;OAEG;IACH,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,EAAE,CAAA;KAAE;IAIzD,MAAM,CAAC,WAAW,IAAI;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE;CAGxD"}
package/dist/registry.js CHANGED
@@ -21,6 +21,19 @@ export class SchemaRegistry {
21
21
  collection.set(key, item);
22
22
  console.log(`[Registry] Registered ${type}: ${key}`);
23
23
  }
24
+ /**
25
+ * Universal Unregister Method
26
+ */
27
+ static unregisterItem(type, name) {
28
+ const collection = this.metadata.get(type);
29
+ if (collection && collection.has(name)) {
30
+ collection.delete(name);
31
+ console.log(`[Registry] Unregistered ${type}: ${name}`);
32
+ }
33
+ else {
34
+ console.warn(`[Registry] Attempted to unregister non-existent ${type}: ${name}`);
35
+ }
36
+ }
24
37
  /**
25
38
  * Universal Get Method
26
39
  */
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@objectstack/objectql",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Isomorphic ObjectQL Engine for ObjectStack",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
7
7
  "dependencies": {
8
- "@objectstack/core": "0.6.0",
9
- "@objectstack/spec": "0.6.0",
10
- "@objectstack/types": "0.6.0"
8
+ "@objectstack/core": "0.6.1",
9
+ "@objectstack/spec": "0.6.1",
10
+ "@objectstack/types": "0.6.1"
11
11
  },
12
12
  "devDependencies": {
13
13
  "typescript": "^5.0.0",