Skip to content

Commit 6946f22

Browse files
authored
Merge pull request #150 from objectstack-ai/copilot/execute-phase-1-migration
2 parents a46967f + d63ded2 commit 6946f22

File tree

16 files changed

+1145
-0
lines changed

16 files changed

+1145
-0
lines changed

PHASE_1_COMPLETE.md

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
# Phase 1 Migration Complete: Foundation & Core Types
2+
3+
## Overview
4+
5+
Phase 1 of the ObjectQL v4.0 migration has been completed. This phase establishes the foundation for the new plugin-based architecture.
6+
7+
## What Changed
8+
9+
### 1. New Directory Structure
10+
11+
```
12+
packages/
13+
├── core/
14+
│ └── types/ # NEW: @objectql/types v4.0.0
15+
├── plugins/ # NEW: Plugin directory (empty, ready for plugins)
16+
├── foundation/ # EXISTING: v3.x packages (unchanged)
17+
│ ├── types/ # Will be deprecated in future
18+
│ ├── core/
19+
│ └── platform-node/
20+
├── drivers/ # EXISTING: Will be migrated to plugins
21+
└── tools/ # EXISTING: Will be updated
22+
```
23+
24+
### 2. New Package: @objectql/types v4.0.0
25+
26+
A new types package has been created at `packages/core/types/` with:
27+
28+
#### Plugin Interfaces
29+
30+
- **`BasePlugin`** - Base interface for all plugins
31+
- **`QueryProcessorPlugin`** - For query validation, optimization, transformation
32+
- **`RepositoryPlugin`** - For extending repositories with batch ops, audit tracking
33+
- **`PluginMetadata`** - Plugin metadata and dependencies
34+
- **`PluginLifecycle`** - Setup and teardown hooks
35+
36+
#### Query Types
37+
38+
- **`UnifiedQuery`** - Core query structure
39+
- **`FilterExpression`** - Type-safe filter expressions
40+
- **`QueryResult`** - Query results with pagination metadata
41+
- **`QueryOptions`** - Query execution options
42+
43+
#### Runtime Types
44+
45+
- **`RuntimeContext`** - Context available to plugins
46+
- **`ValidationResult`** - Query validation results
47+
- **`ValidationError`** - Validation error details
48+
49+
### 3. Type Removals
50+
51+
The following types have been removed from the new v4.0 package as they are now provided by `@objectstack/spec` or `@objectstack/runtime`:
52+
53+
#### Removed (Now in @objectstack/spec):
54+
- `Driver` interface → Use `DriverInterface` from `@objectstack/spec`
55+
56+
#### Removed (Now in @objectstack/runtime):
57+
- `MetadataRegistry` class
58+
- `Context` types
59+
- `Hook` types
60+
- `Action` types
61+
62+
### 4. Workspace Configuration
63+
64+
- **pnpm-workspace.yaml**: Added `packages/core/*` and `packages/plugins/*`
65+
- **tsconfig.json**: Added reference to `packages/core/types`
66+
67+
## Migration Impact
68+
69+
### For Plugin Developers
70+
71+
If you're developing plugins, use the new interfaces:
72+
73+
```typescript
74+
// New v4.0 plugin
75+
import { QueryProcessorPlugin } from '@objectql/types';
76+
77+
export function myPlugin(): QueryProcessorPlugin {
78+
return {
79+
name: '@myorg/plugin',
80+
version: '1.0.0',
81+
type: 'query-processor',
82+
83+
async validateQuery(ast, context) {
84+
return { valid: true, errors: [] };
85+
},
86+
87+
async beforeQuery(ast, context) {
88+
return ast;
89+
}
90+
};
91+
}
92+
```
93+
94+
### For Application Developers
95+
96+
**No immediate action required.** The existing `@objectql/types` (v3.x) in `packages/foundation/types` remains unchanged and will continue to work.
97+
98+
The new package at `packages/core/types` is for new plugin development and will be used by migrated packages in future phases.
99+
100+
## Dependencies
101+
102+
The new `@objectql/types` v4.0.0 depends on:
103+
104+
- `@objectstack/spec` ^0.2.0 - Protocol specifications
105+
- `@objectstack/runtime` ^0.2.0 - Runtime types
106+
107+
These packages provide the foundation for driver interfaces, metadata management, and runtime context.
108+
109+
## Build Verification
110+
111+
The new package has been built and verified:
112+
113+
✅ TypeScript compilation successful
114+
✅ All type definitions generated
115+
✅ No circular dependencies
116+
✅ Strict type checking enabled
117+
118+
## Next Steps
119+
120+
### Phase 2: Core Plugin Migration (Week 3-4)
121+
122+
The following will be migrated in the next phase:
123+
124+
- Create `@objectql/query-validation` plugin
125+
- Create `@objectql/advanced-repository` plugin
126+
- Extract functionality from `@objectql/core`
127+
128+
### Phase 3: Driver Migration (Week 5-6)
129+
130+
Drivers will be migrated to the plugin architecture:
131+
132+
- `@objectql/driver-sql`
133+
- `@objectql/driver-memory`
134+
- `@objectql/driver-mongo`
135+
- `@objectql/driver-sdk`
136+
137+
## Documentation
138+
139+
- **Plugin Architecture**: See [PLUGIN_ARCHITECTURE.md](./PLUGIN_ARCHITECTURE.md)
140+
- **Package Restructuring**: See [PACKAGE_RESTRUCTURING.md](./PACKAGE_RESTRUCTURING.md)
141+
- **Implementation Roadmap**: See [IMPLEMENTATION_ROADMAP.md](./IMPLEMENTATION_ROADMAP.md)
142+
- **Plugin Directory**: See [packages/plugins/README.md](./packages/plugins/README.md)
143+
- **New Types Package**: See [packages/core/types/README.md](./packages/core/types/README.md)
144+
145+
## Questions or Issues?
146+
147+
If you encounter any issues with the new type definitions or have questions about plugin development, please open an issue on GitHub.
148+
149+
---
150+
151+
**Phase 1 Status**: ✅ Complete
152+
**Date**: 2026-01-21
153+
**Next Phase**: Week 3-4 (Core Plugin Migration)

packages/core/types/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
dist
3+
*.tsbuildinfo
4+
coverage
5+
.DS_Store

packages/core/types/CHANGELOG.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# @objectql/types v4.0.0
2+
3+
## [4.0.0] - 2026-01-21
4+
5+
### Breaking Changes
6+
7+
- Complete rewrite of type system for plugin-based architecture
8+
- Removed types now in @objectstack/spec:
9+
- `Driver` interface (use `DriverInterface` from @objectstack/spec)
10+
- Removed types now in @objectstack/runtime:
11+
- `MetadataRegistry` class
12+
- `Context` types
13+
- `Hook` types
14+
- `Action` types
15+
16+
### Added
17+
18+
- New plugin interfaces:
19+
- `QueryProcessorPlugin` - For query validation, optimization, and transformation
20+
- `RepositoryPlugin` - For extending repository with batch operations, audit tracking
21+
- `BasePlugin` - Base interface for all plugins
22+
- Query-specific types:
23+
- `UnifiedQuery` - Core query structure
24+
- `FilterExpression` - Type-safe filter expressions
25+
- `QueryResult` - Query result wrapper with pagination
26+
- `QueryOptions` - Query execution options
27+
- Runtime types:
28+
- `RuntimeContext` - Context available to plugins during execution
29+
- `ValidationResult` - Query validation result
30+
- `ValidationError` - Validation error details
31+
32+
### Dependencies
33+
34+
- Added `@objectstack/spec` ^0.2.0
35+
- Added `@objectstack/runtime` ^0.2.0
36+
37+
### Migration Guide
38+
39+
If you were using types that are now removed:
40+
41+
```typescript
42+
// Old (v3.x)
43+
import { Driver, MetadataRegistry, Hook } from '@objectql/types';
44+
45+
// New (v4.x)
46+
import { DriverInterface } from '@objectstack/spec';
47+
// MetadataRegistry, Hook, Action are now part of @objectstack/runtime
48+
```
49+
50+
For plugin development:
51+
52+
```typescript
53+
// New in v4.x
54+
import { QueryProcessorPlugin, RepositoryPlugin } from '@objectql/types';
55+
56+
export function myPlugin(): QueryProcessorPlugin {
57+
return {
58+
name: '@myorg/plugin',
59+
version: '1.0.0',
60+
type: 'query-processor',
61+
async beforeQuery(ast, context) {
62+
// Transform query
63+
return ast;
64+
}
65+
};
66+
}
67+
```

packages/core/types/README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# @objectql/types
2+
3+
Type definitions and plugin interfaces for ObjectQL v4.0.
4+
5+
## Overview
6+
7+
This package provides the core TypeScript type definitions for ObjectQL's plugin architecture. It includes:
8+
9+
- **Plugin Interfaces**: Define custom query plugins, repository extensions, and query processors
10+
- **Query Types**: Type-safe query construction and manipulation
11+
- **Helper Types**: Utility types for working with ObjectQL queries
12+
13+
## Key Principles
14+
15+
1. **Zero Dependencies on Internal Packages**: This package depends only on `@objectstack/spec` and `@objectstack/runtime`
16+
2. **Protocol-Driven**: Types define the contract, implementation follows
17+
3. **Strict Type Safety**: All types use TypeScript strict mode
18+
19+
## Installation
20+
21+
```bash
22+
npm install @objectql/types
23+
```
24+
25+
## Usage
26+
27+
```typescript
28+
import { QueryPlugin, RepositoryPlugin, UnifiedQuery } from '@objectql/types';
29+
30+
// Define a custom query plugin
31+
export function myQueryPlugin(): QueryPlugin {
32+
return {
33+
name: '@myorg/query-plugin',
34+
version: '1.0.0',
35+
type: 'query-processor',
36+
async beforeQuery(ast, context) {
37+
// Transform query before execution
38+
return ast;
39+
}
40+
};
41+
}
42+
```
43+
44+
## Migration from v3.x
45+
46+
In v4.0, ObjectQL has transitioned to a plugin-based architecture built on `@objectstack/runtime`:
47+
48+
- **Driver Interface**: Now uses `DriverInterface` from `@objectstack/spec`
49+
- **Metadata & Context**: Now managed by `@objectstack/runtime`
50+
- **Hooks & Actions**: Now part of `@objectstack/runtime`
51+
52+
This package focuses exclusively on query-specific types and plugin interfaces.
53+
54+
## License
55+
56+
MIT © ObjectStack Inc.

packages/core/types/jest.config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
preset: 'ts-jest',
3+
testEnvironment: 'node',
4+
testMatch: ['**/__tests__/**/*.test.ts'],
5+
collectCoverageFrom: [
6+
'src/**/*.ts',
7+
'!src/**/*.d.ts',
8+
],
9+
};

packages/core/types/package-lock.json

Lines changed: 64 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/core/types/package.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "@objectql/types",
3+
"version": "4.0.0",
4+
"description": "Type definitions and plugin interfaces for ObjectQL - Query-specific types and plugin architecture",
5+
"keywords": [
6+
"objectql",
7+
"types",
8+
"typescript",
9+
"interfaces",
10+
"plugin",
11+
"query",
12+
"ai-native"
13+
],
14+
"license": "MIT",
15+
"main": "dist/index.js",
16+
"types": "dist/index.d.ts",
17+
"files": [
18+
"dist"
19+
],
20+
"scripts": {
21+
"build": "tsc",
22+
"test": "jest --passWithNoTests"
23+
},
24+
"dependencies": {
25+
"@objectstack/spec": "^0.2.0",
26+
"@objectstack/runtime": "^0.2.0"
27+
}
28+
}

0 commit comments

Comments
 (0)