Skip to content
This repository was archived by the owner on Jun 12, 2026. It is now read-only.

feat: migrate to new database schema API (AQL2) - #20

Merged
Upd4ting merged 5 commits into
mainfrom
feat/aql2
Feb 28, 2026
Merged

feat: migrate to new database schema API (AQL2)#20
Upd4ting merged 5 commits into
mainfrom
feat/aql2

Conversation

@Upd4ting

@Upd4ting Upd4ting commented Feb 28, 2026

Copy link
Copy Markdown
Member

🔗 Linked issue

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

  • Migrate from Database/InitializeDatabase/DeleteDatabase to new Schema/SchemaInstance/CreateDatabaseSchemaInstance API
  • Replace ValueProxy.Proxy<T> with ValueProxy<T> and ValueProxy.ProxyOrVal<T> with ValueProxyOrValue<T>
  • Update DataController to infer schema name from table metadata instead of requiring an explicit schemaName parameter
  • Replace GetTablesFromSchema/DEFAULT_SCHEMA with getTablesForSchema
  • Adapt Query.Foreign to use instanceof Stream check instead of duck-typing (query.lookup)
  • Update Query.Get, Query.List, Query.Delete for new Table<any> generics and revised getAll/orderBy signatures
  • Update insert return type from { generated_keys } to string[]
  • Update Delete return type from Result.Write<any> to number
  • Update all tests to use the new schema-based database initialization pattern
  • Playground updated: use CreateDatabaseSchemaInstance and schemaName convention, switch module sources from package to git

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

Greptile Summary

Successfully migrated from the old Database API to the new Schema/SchemaInstance API (AQL2). This is a comprehensive migration that updates all core components, tests, and playground code to use the new database schema patterns.

Key Changes:

  • Replaced Database/InitializeDatabase/DeleteDatabase with Schema/SchemaInstance/CreateDatabaseSchemaInstance
  • Updated ValueProxy types from ValueProxy.Proxy<T> to ValueProxy<T> and ValueProxy.ProxyOrVal<T> to ValueProxyOrValue<T>
  • DataController now automatically infers schema name from table metadata instead of requiring it as a parameter
  • Improved type checking in Query.Foreign using instanceof Stream instead of duck-typing
  • Updated API signatures: getAll(value, index) instead of getAll(index, value), orderBy with 2 params instead of 3
  • Changed insert return type from { generated_keys: string[] } to string[]
  • Changed delete return type from Result.Write<any> to number
  • All tests updated to use schema-based initialization pattern

Migration Quality:
The migration is thorough and consistent across all files. Type definitions are properly updated, tests pass the new patterns, and the playground demonstrates correct usage.

Confidence Score: 5/5

  • This PR is safe to merge - it's a well-executed API migration with comprehensive updates across the entire codebase
  • All changes are consistent and correctly implement the new AQL2 schema API. The migration touches core files, tests, playground, and type definitions uniformly. No logical errors or inconsistencies detected. The breaking changes are intentional and well-documented.
  • No files require special attention

Important Files Changed

Filename Overview
src/interfaces/data-api/beta/components.ts Updated Query.Foreign to use instanceof Stream check, replaced ValueProxy.Proxy<T> with ValueProxy<T>, updated API signatures for Get, List, and Delete functions
src/interfaces/data-api/beta/index.ts Removed schemaName parameter from DataController, now infers from table metadata; updated imports from GetTablesFromSchema to getTablesForSchema; changed insert return type from object to array
src/interfaces/data-api/beta/metadata.ts Updated type references from ValueProxy.Proxy<T> to ValueProxy<T> and ValueProxy.ProxyOrVal<T> to ValueProxyOrValue<T>; changed import from GetTablesFromSchema to getTablesForSchema
src/test/interfaces/data-api/beta/integration.test.ts Migrated from InitializeDatabase to CreateDatabaseSchemaInstance pattern; added schema name parameter to table registration; updated insert result handling from .generated_keys to direct array access
playground/src/index.ts Replaced InitializeDatabaseFromSchema with CreateDatabaseSchemaInstance; removed config parameter from construct function; simplified module initialization
output/data-api/beta/index.d.ts Updated DataController signature to remove schemaName parameter; corrected return types for New and Delete routes

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Old API: Database/InitializeDatabase] --> B[New API: Schema/SchemaInstance]
    B --> C[CreateDatabaseSchemaInstance schemaName, instanceName]
    C --> D[Schema.get schemaName]
    D --> E[instance instanceName]
    E --> F[table tableName]
    
    G[DataController tableClass, def, base, schemaName?] --> H[DataController tableClass, def, base]
    H --> I[Infer schemaName from table metadata]
    
    J[ValueProxy.Proxy T] --> K[ValueProxy T]
    L[ValueProxy.ProxyOrVal T] --> M[ValueProxyOrValue T]
    
    N[insert returns generated_keys] --> O[insert returns string array]
    P[delete returns Result.Write] --> Q[delete returns number]
    
    R[getAll index, value] --> S[getAll value, index]
    T[orderBy key, dir, indexed] --> U[orderBy key, dir]
Loading

Last reviewed commit: 12ab3b2

@Upd4ting
Upd4ting merged commit 98b2050 into main Feb 28, 2026
4 checks passed
@Upd4ting
Upd4ting deleted the feat/aql2 branch February 28, 2026 23:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant