@objectstack/runtime 1.0.4 → 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 +15 -0
- package/dist/index.cjs +1586 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +629 -0
- package/dist/index.d.ts +628 -14
- package/dist/index.js +1549 -16
- package/dist/index.js.map +1 -0
- package/package.json +6 -5
- package/src/api-registry-plugin.ts +15 -3
- package/src/rest-server.ts +3 -5
- package/src/route-manager.ts +2 -1
- package/src/runtime.ts +0 -1
- package/tsconfig.json +4 -9
- package/dist/api-registry-plugin.d.ts +0 -16
- package/dist/api-registry-plugin.js +0 -42
- package/dist/app-plugin.d.ts +0 -18
- package/dist/app-plugin.js +0 -80
- package/dist/app-plugin.test.d.ts +0 -1
- package/dist/app-plugin.test.js +0 -80
- package/dist/driver-plugin.d.ts +0 -23
- package/dist/driver-plugin.js +0 -35
- package/dist/http-dispatcher.d.ts +0 -106
- package/dist/http-dispatcher.js +0 -539
- package/dist/http-dispatcher.test.d.ts +0 -1
- package/dist/http-dispatcher.test.js +0 -79
- package/dist/http-server.d.ts +0 -84
- package/dist/http-server.js +0 -125
- package/dist/middleware.d.ts +0 -111
- package/dist/middleware.js +0 -176
- package/dist/rest-server.d.ts +0 -74
- package/dist/rest-server.js +0 -518
- package/dist/route-manager.d.ts +0 -153
- package/dist/route-manager.js +0 -251
- package/dist/runtime.d.ts +0 -45
- package/dist/runtime.js +0 -50
- package/dist/runtime.test.d.ts +0 -1
- package/dist/runtime.test.js +0 -57
package/dist/app-plugin.test.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
-
import { AppPlugin } from './app-plugin';
|
|
3
|
-
describe('AppPlugin', () => {
|
|
4
|
-
let mockContext;
|
|
5
|
-
beforeEach(() => {
|
|
6
|
-
mockContext = {
|
|
7
|
-
logger: {
|
|
8
|
-
info: vi.fn(),
|
|
9
|
-
error: vi.fn(),
|
|
10
|
-
warn: vi.fn(),
|
|
11
|
-
debug: vi.fn()
|
|
12
|
-
},
|
|
13
|
-
registerService: vi.fn(),
|
|
14
|
-
getService: vi.fn(),
|
|
15
|
-
getServices: vi.fn()
|
|
16
|
-
};
|
|
17
|
-
});
|
|
18
|
-
it('should initialize with manifest info', () => {
|
|
19
|
-
const bundle = {
|
|
20
|
-
id: 'com.test.app',
|
|
21
|
-
name: 'Test App',
|
|
22
|
-
version: '1.0.0'
|
|
23
|
-
};
|
|
24
|
-
const plugin = new AppPlugin(bundle);
|
|
25
|
-
expect(plugin.name).toBe('plugin.app.com.test.app');
|
|
26
|
-
expect(plugin.version).toBe('1.0.0');
|
|
27
|
-
});
|
|
28
|
-
it('should handle nested stack definition manifest', () => {
|
|
29
|
-
const bundle = {
|
|
30
|
-
manifest: {
|
|
31
|
-
id: 'com.test.stack',
|
|
32
|
-
version: '2.0.0'
|
|
33
|
-
},
|
|
34
|
-
objects: []
|
|
35
|
-
};
|
|
36
|
-
const plugin = new AppPlugin(bundle);
|
|
37
|
-
expect(plugin.name).toBe('plugin.app.com.test.stack');
|
|
38
|
-
expect(plugin.version).toBe('2.0.0');
|
|
39
|
-
});
|
|
40
|
-
it('registerService should register raw manifest in init phase', async () => {
|
|
41
|
-
const bundle = {
|
|
42
|
-
id: 'com.test.simple',
|
|
43
|
-
objects: []
|
|
44
|
-
};
|
|
45
|
-
const plugin = new AppPlugin(bundle);
|
|
46
|
-
await plugin.init(mockContext);
|
|
47
|
-
expect(mockContext.registerService).toHaveBeenCalledWith('app.com.test.simple', bundle);
|
|
48
|
-
});
|
|
49
|
-
it('start should do nothing if no runtime hooks', async () => {
|
|
50
|
-
const bundle = { id: 'com.test.static' };
|
|
51
|
-
const plugin = new AppPlugin(bundle);
|
|
52
|
-
vi.mocked(mockContext.getService).mockReturnValue({}); // Mock ObjectQL exists
|
|
53
|
-
await plugin.start(mockContext);
|
|
54
|
-
// Only logs, no errors
|
|
55
|
-
expect(mockContext.logger.debug).toHaveBeenCalled();
|
|
56
|
-
});
|
|
57
|
-
it('start should invoke onEnable if present', async () => {
|
|
58
|
-
const onEnableSpy = vi.fn();
|
|
59
|
-
const bundle = {
|
|
60
|
-
id: 'com.test.code',
|
|
61
|
-
onEnable: onEnableSpy
|
|
62
|
-
};
|
|
63
|
-
const plugin = new AppPlugin(bundle);
|
|
64
|
-
// Mock ObjectQL engine
|
|
65
|
-
const mockQL = { registry: {} };
|
|
66
|
-
vi.mocked(mockContext.getService).mockReturnValue(mockQL);
|
|
67
|
-
await plugin.start(mockContext);
|
|
68
|
-
expect(onEnableSpy).toHaveBeenCalled();
|
|
69
|
-
// Check context passed to onEnable
|
|
70
|
-
const callArg = onEnableSpy.mock.calls[0][0];
|
|
71
|
-
expect(callArg.ql).toBe(mockQL);
|
|
72
|
-
});
|
|
73
|
-
it('start should warn if objectql not found', async () => {
|
|
74
|
-
const bundle = { id: 'com.test.warn' };
|
|
75
|
-
const plugin = new AppPlugin(bundle);
|
|
76
|
-
vi.mocked(mockContext.getService).mockReturnValue(undefined); // No ObjectQL
|
|
77
|
-
await plugin.start(mockContext);
|
|
78
|
-
expect(mockContext.logger.warn).toHaveBeenCalledWith(expect.stringContaining('ObjectQL engine service not found'), expect.any(Object));
|
|
79
|
-
});
|
|
80
|
-
});
|
package/dist/driver-plugin.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Plugin, PluginContext } from '@objectstack/core';
|
|
2
|
-
/**
|
|
3
|
-
* Driver Plugin
|
|
4
|
-
*
|
|
5
|
-
* Generic plugin wrapper for ObjectQL drivers.
|
|
6
|
-
* Registers a driver with the ObjectQL engine.
|
|
7
|
-
*
|
|
8
|
-
* Dependencies: None (Registers service for ObjectQL to discover)
|
|
9
|
-
* Services: driver.{name}
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* const memoryDriver = new InMemoryDriver();
|
|
13
|
-
* const driverPlugin = new DriverPlugin(memoryDriver, 'memory');
|
|
14
|
-
* kernel.use(driverPlugin);
|
|
15
|
-
*/
|
|
16
|
-
export declare class DriverPlugin implements Plugin {
|
|
17
|
-
name: string;
|
|
18
|
-
version: string;
|
|
19
|
-
private driver;
|
|
20
|
-
constructor(driver: any, driverName?: string);
|
|
21
|
-
init: (ctx: PluginContext) => Promise<void>;
|
|
22
|
-
start: (ctx: PluginContext) => Promise<void>;
|
|
23
|
-
}
|
package/dist/driver-plugin.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Driver Plugin
|
|
3
|
-
*
|
|
4
|
-
* Generic plugin wrapper for ObjectQL drivers.
|
|
5
|
-
* Registers a driver with the ObjectQL engine.
|
|
6
|
-
*
|
|
7
|
-
* Dependencies: None (Registers service for ObjectQL to discover)
|
|
8
|
-
* Services: driver.{name}
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* const memoryDriver = new InMemoryDriver();
|
|
12
|
-
* const driverPlugin = new DriverPlugin(memoryDriver, 'memory');
|
|
13
|
-
* kernel.use(driverPlugin);
|
|
14
|
-
*/
|
|
15
|
-
export class DriverPlugin {
|
|
16
|
-
constructor(driver, driverName) {
|
|
17
|
-
this.version = '1.0.0';
|
|
18
|
-
this.init = async (ctx) => {
|
|
19
|
-
// Register driver as a service instead of directly to objectql
|
|
20
|
-
const serviceName = `driver.${this.driver.name || 'unknown'}`;
|
|
21
|
-
ctx.registerService(serviceName, this.driver);
|
|
22
|
-
ctx.logger.info('Driver service registered', {
|
|
23
|
-
serviceName,
|
|
24
|
-
driverName: this.driver.name,
|
|
25
|
-
driverVersion: this.driver.version
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
this.start = async (ctx) => {
|
|
29
|
-
// Drivers don't need start phase, initialization happens in init
|
|
30
|
-
ctx.logger.debug('Driver plugin started', { driverName: this.driver.name || 'unknown' });
|
|
31
|
-
};
|
|
32
|
-
this.driver = driver;
|
|
33
|
-
this.name = `com.objectstack.driver.${driverName || driver.name || 'unknown'}`;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { ObjectKernel } from '@objectstack/core';
|
|
2
|
-
export interface HttpProtocolContext {
|
|
3
|
-
request: any;
|
|
4
|
-
response?: any;
|
|
5
|
-
}
|
|
6
|
-
export interface HttpDispatcherResult {
|
|
7
|
-
handled: boolean;
|
|
8
|
-
response?: {
|
|
9
|
-
status: number;
|
|
10
|
-
body?: any;
|
|
11
|
-
headers?: Record<string, string>;
|
|
12
|
-
};
|
|
13
|
-
result?: any;
|
|
14
|
-
}
|
|
15
|
-
export declare class HttpDispatcher {
|
|
16
|
-
private kernel;
|
|
17
|
-
constructor(kernel: ObjectKernel);
|
|
18
|
-
private success;
|
|
19
|
-
private error;
|
|
20
|
-
private ensureBroker;
|
|
21
|
-
/**
|
|
22
|
-
* Generates the discovery JSON response for the API root
|
|
23
|
-
*/
|
|
24
|
-
getDiscoveryInfo(prefix: string): {
|
|
25
|
-
name: string;
|
|
26
|
-
version: string;
|
|
27
|
-
environment: string | undefined;
|
|
28
|
-
routes: {
|
|
29
|
-
data: string;
|
|
30
|
-
metadata: string;
|
|
31
|
-
auth: string;
|
|
32
|
-
graphql: string | undefined;
|
|
33
|
-
storage: string | undefined;
|
|
34
|
-
analytics: string | undefined;
|
|
35
|
-
hub: string | undefined;
|
|
36
|
-
};
|
|
37
|
-
features: {
|
|
38
|
-
graphql: boolean;
|
|
39
|
-
search: boolean;
|
|
40
|
-
websockets: boolean;
|
|
41
|
-
files: boolean;
|
|
42
|
-
analytics: boolean;
|
|
43
|
-
hub: boolean;
|
|
44
|
-
};
|
|
45
|
-
locale: {
|
|
46
|
-
default: string;
|
|
47
|
-
supported: string[];
|
|
48
|
-
timezone: string;
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
/**
|
|
52
|
-
* Handles GraphQL requests
|
|
53
|
-
*/
|
|
54
|
-
handleGraphQL(body: {
|
|
55
|
-
query: string;
|
|
56
|
-
variables?: any;
|
|
57
|
-
}, context: HttpProtocolContext): Promise<any>;
|
|
58
|
-
/**
|
|
59
|
-
* Handles Auth requests
|
|
60
|
-
* path: sub-path after /auth/
|
|
61
|
-
*/
|
|
62
|
-
handleAuth(path: string, method: string, body: any, context: HttpProtocolContext): Promise<HttpDispatcherResult>;
|
|
63
|
-
/**
|
|
64
|
-
* Handles Metadata requests
|
|
65
|
-
* Standard: /metadata/:type/:name
|
|
66
|
-
* Fallback for backward compat: /metadata (all objects), /metadata/:objectName (get object)
|
|
67
|
-
*/
|
|
68
|
-
handleMetadata(path: string, context: HttpProtocolContext, method?: string, body?: any): Promise<HttpDispatcherResult>;
|
|
69
|
-
/**
|
|
70
|
-
* Handles Data requests
|
|
71
|
-
* path: sub-path after /data/ (e.g. "contacts", "contacts/123", "contacts/query")
|
|
72
|
-
*/
|
|
73
|
-
handleData(path: string, method: string, body: any, query: any, context: HttpProtocolContext): Promise<HttpDispatcherResult>;
|
|
74
|
-
/**
|
|
75
|
-
* Handles Analytics requests
|
|
76
|
-
* path: sub-path after /analytics/
|
|
77
|
-
*/
|
|
78
|
-
handleAnalytics(path: string, method: string, body: any, context: HttpProtocolContext): Promise<HttpDispatcherResult>;
|
|
79
|
-
/**
|
|
80
|
-
* Handles Hub requests
|
|
81
|
-
* path: sub-path after /hub/
|
|
82
|
-
*/
|
|
83
|
-
handleHub(path: string, method: string, body: any, query: any, context: HttpProtocolContext): Promise<HttpDispatcherResult>;
|
|
84
|
-
/**
|
|
85
|
-
* Handles Storage requests
|
|
86
|
-
* path: sub-path after /storage/
|
|
87
|
-
*/
|
|
88
|
-
handleStorage(path: string, method: string, file: any, context: HttpProtocolContext): Promise<HttpDispatcherResult>;
|
|
89
|
-
/**
|
|
90
|
-
* Handles Automation requests
|
|
91
|
-
* path: sub-path after /automation/
|
|
92
|
-
*/
|
|
93
|
-
handleAutomation(path: string, method: string, body: any, context: HttpProtocolContext): Promise<HttpDispatcherResult>;
|
|
94
|
-
private getServicesMap;
|
|
95
|
-
private getService;
|
|
96
|
-
private capitalize;
|
|
97
|
-
/**
|
|
98
|
-
* Main Dispatcher Entry Point
|
|
99
|
-
* Routes the request to the appropriate handler based on path and precedence
|
|
100
|
-
*/
|
|
101
|
-
dispatch(method: string, path: string, body: any, query: any, context: HttpProtocolContext): Promise<HttpDispatcherResult>;
|
|
102
|
-
/**
|
|
103
|
-
* Handles Custom API Endpoints defined in metadata
|
|
104
|
-
*/
|
|
105
|
-
handleApiEndpoint(path: string, method: string, body: any, query: any, context: HttpProtocolContext): Promise<HttpDispatcherResult>;
|
|
106
|
-
}
|