@objectstack/objectql 4.0.4 → 4.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/src/index.ts DELETED
@@ -1,41 +0,0 @@
1
- // Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
2
-
3
- // Export Registry
4
- export {
5
- SchemaRegistry,
6
- computeFQN,
7
- parseFQN,
8
- RESERVED_NAMESPACES,
9
- DEFAULT_OWNER_PRIORITY,
10
- DEFAULT_EXTENDER_PRIORITY,
11
- } from './registry.js';
12
- export type { ObjectContributor } from './registry.js';
13
-
14
- // Export Protocol Implementation
15
- export { ObjectStackProtocolImplementation } from './protocol.js';
16
-
17
- // Export Engine
18
- export { ObjectQL, ObjectRepository, ScopedContext } from './engine.js';
19
- export type { ObjectQLHostContext, HookHandler, HookEntry, OperationContext, EngineMiddleware } from './engine.js';
20
-
21
- // Export MetadataFacade
22
- export { MetadataFacade } from './metadata-facade.js';
23
-
24
- // Export Plugin Shim
25
- export { ObjectQLPlugin } from './plugin.js';
26
-
27
- // Export Kernel Factory
28
- export { createObjectQLKernel } from './kernel-factory.js';
29
- export type { ObjectQLKernelOptions } from './kernel-factory.js';
30
-
31
- // Export Utilities
32
- export {
33
- toTitleCase,
34
- convertIntrospectedSchemaToObjects,
35
- } from './util.js';
36
- export type {
37
- IntrospectedColumn,
38
- IntrospectedForeignKey,
39
- IntrospectedTable,
40
- IntrospectedSchema,
41
- } from './util.js';
@@ -1,48 +0,0 @@
1
- // Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
2
-
3
- import { ObjectKernel } from '@objectstack/core';
4
- import { ObjectQLPlugin } from './plugin.js';
5
- import type { Plugin } from '@objectstack/core';
6
-
7
- /**
8
- * Options for creating an ObjectQL Kernel.
9
- */
10
- export interface ObjectQLKernelOptions {
11
- /**
12
- * Additional plugins to register with the kernel.
13
- */
14
- plugins?: Plugin[];
15
- }
16
-
17
- /**
18
- * Convenience factory for creating an ObjectQL-ready kernel.
19
- *
20
- * Creates an ObjectKernel pre-configured with the ObjectQLPlugin
21
- * (data engine, schema registry, protocol implementation) plus any
22
- * additional plugins provided.
23
- *
24
- * @example
25
- * ```typescript
26
- * import { createObjectQLKernel } from '@objectstack/objectql';
27
- *
28
- * const kernel = createObjectQLKernel({
29
- * plugins: [myDriverPlugin, myAuthPlugin],
30
- * });
31
- * await kernel.bootstrap();
32
- * ```
33
- */
34
- export async function createObjectQLKernel(options: ObjectQLKernelOptions = {}): Promise<ObjectKernel> {
35
- const kernel = new ObjectKernel();
36
-
37
- // Register the core ObjectQLPlugin first
38
- await kernel.use(new ObjectQLPlugin());
39
-
40
- // Register any additional plugins
41
- if (options.plugins) {
42
- for (const plugin of options.plugins) {
43
- await kernel.use(plugin);
44
- }
45
- }
46
-
47
- return kernel;
48
- }
@@ -1,96 +0,0 @@
1
- // Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
2
-
3
- import { SchemaRegistry } from './registry.js';
4
-
5
- /**
6
- * MetadataFacade
7
- *
8
- * Provides a clean, injectable interface over SchemaRegistry.
9
- * Registered as the 'metadata' kernel service to eliminate
10
- * downstream packages needing to manually wrap SchemaRegistry.
11
- *
12
- * Implements the async IMetadataService interface.
13
- * Internally delegates to SchemaRegistry (in-memory) with Promise wrappers.
14
- */
15
- export class MetadataFacade {
16
- /**
17
- * Register a metadata item
18
- */
19
- async register(type: string, name: string, data: any): Promise<void> {
20
- const definition = typeof data === 'object' && data !== null
21
- ? { ...data, name: data.name ?? name }
22
- : data;
23
- if (type === 'object') {
24
- SchemaRegistry.registerItem(type, definition, 'name' as any);
25
- } else {
26
- SchemaRegistry.registerItem(type, definition, definition.id ? 'id' as any : 'name' as any);
27
- }
28
- }
29
-
30
- /**
31
- * Get a metadata item by type and name
32
- */
33
- async get(type: string, name: string): Promise<any> {
34
- const item = SchemaRegistry.getItem(type, name) as any;
35
- return item?.content ?? item;
36
- }
37
-
38
- /**
39
- * Get the raw entry (with metadata wrapper)
40
- */
41
- getEntry(type: string, name: string): any {
42
- return SchemaRegistry.getItem(type, name);
43
- }
44
-
45
- /**
46
- * List all items of a type
47
- */
48
- async list(type: string): Promise<any[]> {
49
- const items = SchemaRegistry.listItems(type);
50
- return items.map((item: any) => item?.content ?? item);
51
- }
52
-
53
- /**
54
- * Unregister a metadata item
55
- */
56
- async unregister(type: string, name: string): Promise<void> {
57
- SchemaRegistry.unregisterItem(type, name);
58
- }
59
-
60
- /**
61
- * Check if a metadata item exists
62
- */
63
- async exists(type: string, name: string): Promise<boolean> {
64
- const item = SchemaRegistry.getItem(type, name);
65
- return item !== undefined && item !== null;
66
- }
67
-
68
- /**
69
- * List all names of metadata items of a given type
70
- */
71
- async listNames(type: string): Promise<string[]> {
72
- const items = SchemaRegistry.listItems(type);
73
- return items.map((item: any) => item?.name ?? item?.content?.name ?? '').filter(Boolean);
74
- }
75
-
76
- /**
77
- * Unregister all metadata from a package
78
- */
79
- async unregisterPackage(packageName: string): Promise<void> {
80
- SchemaRegistry.unregisterObjectsByPackage(packageName);
81
- }
82
-
83
- /**
84
- * Convenience: get object definition
85
- */
86
- async getObject(name: string): Promise<any> {
87
- return SchemaRegistry.getObject(name);
88
- }
89
-
90
- /**
91
- * Convenience: list all objects
92
- */
93
- async listObjects(): Promise<any[]> {
94
- return SchemaRegistry.getAllObjects();
95
- }
96
- }