|
| 1 | +# Type System Migration - Phase 1 Summary |
| 2 | + |
| 3 | +## Overview |
| 4 | +This document tracks the migration of `@objectql/types` to delegate general types to `@objectstack/spec` and `@objectstack/runtime` packages. |
| 5 | + |
| 6 | +## Version Changes |
| 7 | +- **@objectql/types**: `3.0.1` → `4.0.0-beta.1` |
| 8 | +- **Dependency Model**: Changed from `dependencies` to `peerDependencies` + `devDependencies` (workspace) |
| 9 | + |
| 10 | +## Type Mapping |
| 11 | + |
| 12 | +### Types Delegated to @objectstack/spec |
| 13 | + |
| 14 | +| Type Name | Source (Before) | Source (After) | Re-exported | Deprecated | |
| 15 | +|-----------|----------------|----------------|-------------|------------| |
| 16 | +| `Field` | Local definition | `@objectstack/spec` | Yes (as `SpecField`) | Yes | |
| 17 | +| `FieldType` | Local definition | `@objectstack/spec` | Yes (as `ProtocolFieldType`) | Yes | |
| 18 | +| `SelectOption` | Local definition | `@objectstack/spec` | Yes (as `SpecSelectOption`) | Yes | |
| 19 | +| `ServiceObject` | Local definition | `@objectstack/spec` | Yes (as `SpecObject`) | Yes | |
| 20 | +| `IndexSchema` | Local definition | `@objectstack/spec` | Yes | Yes | |
| 21 | +| `Action` | Local definition | `@objectstack/spec` | Yes (as `SpecAction`) | Yes | |
| 22 | +| `FilterCondition` | Local definition | `@objectstack/spec` | Direct import | No | |
| 23 | +| `QueryAST` | N/A | `@objectstack/spec` | Via imports | No | |
| 24 | +| `FilterNode` | N/A | `@objectstack/spec` | Via imports | No | |
| 25 | +| `SortNode` | N/A | `@objectstack/spec` | Via imports | No | |
| 26 | + |
| 27 | +### Types Delegated to @objectstack/runtime |
| 28 | + |
| 29 | +| Type Name | Source (Before) | Source (After) | Re-exported | Deprecated | |
| 30 | +|-----------|----------------|----------------|-------------|------------| |
| 31 | +| `RuntimePlugin` | N/A | `@objectstack/runtime` | Direct import | No | |
| 32 | +| `RuntimeContext` | N/A | `@objectstack/runtime` | Direct import | No | |
| 33 | +| `ObjectStackKernel` | N/A | `@objectstack/runtime` | Direct import | No | |
| 34 | +| `ObjectStackRuntimeProtocol` | N/A | `@objectstack/runtime` | Direct import | No | |
| 35 | + |
| 36 | +### ObjectQL-Specific Types (Retained) |
| 37 | + |
| 38 | +The following types remain fully defined in `@objectql/types` as they are ObjectQL-specific extensions: |
| 39 | + |
| 40 | +#### Field Extensions (`src/field.ts`) |
| 41 | +- `FieldConfig` - Extends protocol Field with runtime properties |
| 42 | +- `FieldType` - Extends protocol FieldType with runtime types (`vector`, `grid`, `location`, `object`) |
| 43 | +- `FieldOption` - Extends SelectOption to allow number values |
| 44 | +- `AttachmentData` - File metadata structure |
| 45 | +- `ImageAttachmentData` - Image-specific metadata |
| 46 | + |
| 47 | +#### Object Extensions (`src/object.ts`) |
| 48 | +- `ObjectConfig` - Extends ServiceObject with runtime properties |
| 49 | +- `IndexConfig` - Simplified alias for IndexSchema |
| 50 | +- `AiSearchConfig` - AI/semantic search configuration |
| 51 | +- `ObjectAiConfig` - Object-level AI configuration |
| 52 | +- `ObjectDoc` - Document instance interface |
| 53 | + |
| 54 | +#### Query Types (`src/query.ts`) |
| 55 | +- `UnifiedQuery` - ObjectQL's unified query interface |
| 56 | +- `AggregateFunction` - Aggregation function types |
| 57 | +- `AggregateOption` - Aggregation configuration |
| 58 | + |
| 59 | +#### Runtime Types |
| 60 | +- `ObjectQLContext` (`src/context.ts`) - ObjectQL execution context |
| 61 | +- `ObjectQLContextOptions` (`src/context.ts`) - Context options |
| 62 | +- `Driver` (`src/driver.ts`) - ObjectQL driver interface |
| 63 | +- `IntrospectedColumn`, `IntrospectedTable`, `IntrospectedSchema` (`src/driver.ts`) - Schema introspection |
| 64 | + |
| 65 | +## Workspace Structure Changes |
| 66 | + |
| 67 | +### New Packages Created |
| 68 | +``` |
| 69 | +packages/objectstack/ |
| 70 | +├── spec/ # @objectstack/spec stub |
| 71 | +│ ├── src/index.ts |
| 72 | +│ ├── package.json |
| 73 | +│ ├── tsconfig.json |
| 74 | +│ └── README.md |
| 75 | +└── runtime/ # @objectstack/runtime stub |
| 76 | + ├── src/index.ts |
| 77 | + ├── package.json |
| 78 | + ├── tsconfig.json |
| 79 | + └── README.md |
| 80 | +``` |
| 81 | + |
| 82 | +### Workspace Configuration |
| 83 | +Updated `pnpm-workspace.yaml` to include: |
| 84 | +```yaml |
| 85 | +packages: |
| 86 | + - packages/objectstack/* |
| 87 | +``` |
| 88 | +
|
| 89 | +## Breaking Changes |
| 90 | +
|
| 91 | +### For Consumers |
| 92 | +- No breaking changes for typical usage (backward compatible re-exports) |
| 93 | +- Advanced users importing protocol types should prefer importing directly from `@objectstack/spec` |
| 94 | +- All re-exported types are marked `@deprecated` with migration hints |
| 95 | + |
| 96 | +### Package Dependencies |
| 97 | +- `@objectstack/spec` and `@objectstack/runtime` are now **peerDependencies** |
| 98 | +- Consumers must ensure these packages are available in their project |
| 99 | + |
| 100 | +## Migration Guide for Consumers |
| 101 | + |
| 102 | +### Before (v3.x) |
| 103 | +```typescript |
| 104 | +import { Field, FieldType, ServiceObject } from '@objectql/types'; |
| 105 | +``` |
| 106 | + |
| 107 | +### After (v4.0) |
| 108 | +```typescript |
| 109 | +// Option 1: Continue using re-exports (deprecated but works) |
| 110 | +import { SpecField, ProtocolFieldType, SpecObject } from '@objectql/types'; |
| 111 | +
|
| 112 | +// Option 2: Import directly from protocol (recommended) |
| 113 | +import { Field, FieldType, ServiceObject } from '@objectstack/spec'; |
| 114 | +
|
| 115 | +// Option 3: Use ObjectQL runtime extensions |
| 116 | +import { FieldConfig, ObjectConfig } from '@objectql/types'; |
| 117 | +``` |
| 118 | + |
| 119 | +## Build Status |
| 120 | + |
| 121 | +### ✅ Successfully Building |
| 122 | +- `@objectstack/spec` - All protocol types compile |
| 123 | +- `@objectstack/runtime` - All runtime types compile |
| 124 | +- `@objectql/types` - All types compile, 32 tests passing |
| 125 | + |
| 126 | +### ⚠️ Known Issues |
| 127 | +- External package `@objectstack/objectql@0.2.0` in node_modules has compatibility issues |
| 128 | +- Some type mismatches in `@objectql/core` repository.ts (FilterNode usage) |
| 129 | +- These are expected during migration and will be resolved in subsequent phases |
| 130 | + |
| 131 | +## Next Steps |
| 132 | + |
| 133 | +1. **Phase 2**: Update `@objectql/core` to properly use new type structure |
| 134 | +2. **Phase 3**: Update driver packages to use delegated types |
| 135 | +3. **Phase 4**: Publish updated packages with proper semver |
| 136 | +4. **Phase 5**: Update documentation and migration guides |
| 137 | + |
| 138 | +## Notes |
| 139 | + |
| 140 | +- This is a **preparation phase** for the full ObjectStack v4.0 migration |
| 141 | +- Stub packages created in workspace will be replaced by published npm packages |
| 142 | +- All changes maintain backward compatibility through re-exports |
| 143 | +- Types are properly marked with deprecation notices |
0 commit comments