Skip to content

Commit 05f28f2

Browse files
feat: Enhance @objectstack stub packages with additional protocol types
Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com>
1 parent f1fd8c2 commit 05f28f2

2 files changed

Lines changed: 187 additions & 10 deletions

File tree

packages/objectstack/runtime/src/index.ts

Lines changed: 64 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212
export interface RuntimeContext {
1313
/** The ObjectStack kernel instance */
14-
engine: any; // ObjectStackKernel
14+
engine: ObjectStackKernel;
1515
}
1616

1717
/**
@@ -35,13 +35,71 @@ export interface RuntimePlugin {
3535
* ObjectStack Kernel
3636
* The core runtime engine
3737
*/
38-
export interface ObjectStackKernel {
38+
export class ObjectStackKernel {
3939
/** Query interface (QL) */
40-
ql: any;
40+
public ql: any = null;
41+
42+
constructor(plugins: RuntimePlugin[] = []) {
43+
// Stub implementation
44+
}
45+
4146
/** Start the kernel */
42-
start(): Promise<void>;
47+
async start(): Promise<void> {
48+
// Stub implementation
49+
}
50+
4351
/** Stop the kernel */
44-
stop?(): Promise<void>;
52+
async stop(): Promise<void> {
53+
// Stub implementation
54+
}
55+
4556
/** Seed initial data */
46-
seed?(): Promise<void>;
57+
async seed(): Promise<void> {
58+
// Stub implementation
59+
}
60+
61+
/** Find records */
62+
async find(objectName: string, query: any): Promise<{ value: any[]; count: number }> {
63+
return { value: [], count: 0 };
64+
}
65+
66+
/** Get a single record */
67+
async get(objectName: string, id: string): Promise<any> {
68+
return {};
69+
}
70+
71+
/** Create a record */
72+
async create(objectName: string, data: any): Promise<any> {
73+
return data;
74+
}
75+
76+
/** Update a record */
77+
async update(objectName: string, id: string, data: any): Promise<any> {
78+
return data;
79+
}
80+
81+
/** Delete a record */
82+
async delete(objectName: string, id: string): Promise<boolean> {
83+
return true;
84+
}
85+
86+
/** Get metadata for an object */
87+
getMetadata(objectName: string): any {
88+
return {};
89+
}
90+
91+
/** Get view configuration */
92+
getView(objectName: string, viewType?: 'list' | 'form'): any {
93+
return null;
94+
}
95+
}
96+
97+
/**
98+
* ObjectStack Runtime Protocol
99+
* Base class for runtime protocol implementations
100+
*/
101+
export class ObjectStackRuntimeProtocol {
102+
// Stub implementation
47103
}
104+
105+

packages/objectstack/spec/src/index.ts

Lines changed: 123 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,57 @@
1414
* - Explicit operators: { field: { $eq: value, $gt: 10 } }
1515
* - Logical operators: { $and: [...], $or: [...] }
1616
*/
17-
export type FilterCondition =
18-
| { [key: string]: any } // Field equality or operator object
19-
| { $and?: FilterCondition[] }
20-
| { $or?: FilterCondition[] };
17+
export interface FilterCondition {
18+
[key: string]: any;
19+
$and?: FilterCondition[];
20+
$or?: FilterCondition[];
21+
$not?: FilterCondition;
22+
}
23+
24+
/**
25+
* Filter Node - AST representation of a filter condition
26+
*/
27+
export interface FilterNode {
28+
type: 'and' | 'or' | 'not' | 'comparison';
29+
operator?: string;
30+
field?: string;
31+
value?: any;
32+
children?: FilterNode[];
33+
}
34+
35+
/**
36+
* Sort Node - AST representation of sort order
37+
*/
38+
export interface SortNode {
39+
field: string;
40+
order: 'asc' | 'desc';
41+
}
42+
43+
/**
44+
* Query AST - Abstract Syntax Tree for queries
45+
*/
46+
export interface QueryAST {
47+
/** Target object name */
48+
object?: string;
49+
/** Fields to select */
50+
fields?: string[];
51+
/** Filter conditions */
52+
filters?: FilterNode;
53+
/** Sort order */
54+
sort?: SortNode[];
55+
/** Number of records to skip */
56+
skip?: number;
57+
/** Maximum number of records to return */
58+
top?: number;
59+
/** Group by fields */
60+
groupBy?: string[];
61+
/** Aggregations to perform */
62+
aggregations?: Array<{
63+
function: string;
64+
field: string;
65+
alias?: string;
66+
}>;
67+
}
2168

2269
/**
2370
* Protocol Field Types
@@ -195,3 +242,75 @@ export interface Action {
195242
/** Whether this action is internal only */
196243
internal?: boolean;
197244
}
245+
246+
/**
247+
* Application Manifest
248+
*/
249+
export interface App {
250+
/** App name */
251+
name: string;
252+
/** App version */
253+
version?: string;
254+
/** App description */
255+
description?: string;
256+
}
257+
258+
/**
259+
* ObjectStack Manifest
260+
*/
261+
export interface ObjectStackManifest {
262+
/** Manifest version */
263+
version: string;
264+
/** Application info */
265+
app?: App;
266+
/** List of objects */
267+
objects?: ServiceObject[];
268+
}
269+
270+
/**
271+
* Driver Interface
272+
*
273+
* Base interface for database drivers
274+
*/
275+
export interface DriverInterface {
276+
/** Driver name */
277+
name?: string;
278+
/** Driver version */
279+
version?: string;
280+
/** Driver capabilities */
281+
supports?: {
282+
transactions?: boolean;
283+
joins?: boolean;
284+
fullTextSearch?: boolean;
285+
jsonFields?: boolean;
286+
arrayFields?: boolean;
287+
};
288+
}
289+
290+
/**
291+
* Driver Options
292+
*
293+
* Configuration options for database drivers
294+
*/
295+
export interface DriverOptions {
296+
/** Connection string or configuration */
297+
connection?: string | any;
298+
/** Additional driver-specific options */
299+
[key: string]: any;
300+
}
301+
302+
/**
303+
* Plugin Definition
304+
*
305+
* Base interface for plugins
306+
*/
307+
export interface PluginDefinition {
308+
/** Plugin name */
309+
name: string;
310+
/** Plugin version */
311+
version?: string;
312+
/** Plugin description */
313+
description?: string;
314+
}
315+
316+

0 commit comments

Comments
 (0)