Skip to content

Feat/implementation phase 1#67

Open
codewizdave wants to merge 20 commits into
mainfrom
feat/implementation-phase-1
Open

Feat/implementation phase 1#67
codewizdave wants to merge 20 commits into
mainfrom
feat/implementation-phase-1

Conversation

@codewizdave
Copy link
Copy Markdown
Member

No description provided.

codewizdave and others added 11 commits April 15, 2026 11:45
- Add @deessejs/fp integration with Result, Maybe, Try, and error() patterns
- Refactor CRUD operations to return Result/Maybe instead of throwing
- Add structured errors (RecordNotFoundError, InsertFailedError)
- Add PostgreSQL and SQLite schema builders (createPostgresSchema, createSqliteSchema)
- Add full CRUD operations (create, findOne, findMany, update, remove, count, exists)
- Add collection validators using Result<Unit, Error> pattern
- Update CLAUDE.md with @deessejs/fp integration guidelines
- Add examples (basic-blog, blog-with-relations, all-field-types, etc.)

Co-Authored-By: martyy-code <nesalia.inc@gmail.com>
- Add $push() method to createCollections() to allow pushing schema changes
  and creating tables before running CRUD operations
- Fix SQLite UUID column not having $defaultFn for auto-generated IDs
  (NOT NULL constraint failed: posts.id)
- Fix predicate SQL conversion in dbAccess (RangeError: Too few parameter
  values)
- Update examples to call db.$push() before CRUD operations

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The issue was that drizzleDb.execute(sql`${stmt}`) treated the SQL statement
as a parameter ($1) instead of executing it directly. Using rawDb.query()
passes the SQL string directly to PostgreSQL.

Co-Authored-By: martyy-code <nesalia.inc@gmail.com>
BREAKING CHANGE: postgres() now only accepts connection strings, not Pool instances

Changes:
- postgres(connectionString) creates Pool internally with default settings
- Added PostgresOptions interface for pool configuration (max, idleTimeoutMillis)
- Removed db.$push() - schema push is now CLI only via npx @deessejs/collections push
- Removed PushContext and related code
- Updated postgres-demo example to use new simplified API
- Updated to use DATABASE_URL env var (industry standard)

Before:
  const pool = new Pool({ connectionString: process.env.POSTGRES_URL })
  createCollections({ db: postgres(pool), collections })

After:
  createCollections({ db: postgres(process.env.DATABASE_URL!), collections })

Co-Authored-By: martyy-code <nesalia.inc@gmail.com>
Fixes:
- SQLite: detect Database instance vs file path for :memory: support
- MySQL: detect Pool instance vs connection string
- postgres-demo: works correctly with Neon, incremental IDs

Co-Authored-By: martyy-code <nesalia.inc@gmail.com>
Added:
- reports/dx-improvement/createCollections-simplification.md
- reports/payload/database/columns/columns-and-types.md
- reports/payload/database/migrations/migrations-system.md

Co-Authored-By: martyy-code <nesalia.inc@gmail.com>
Removed:
- examples/all-field-types.ts
- examples/basic-blog.ts
- examples/blog-with-relations.ts
- examples/error-cases.ts
- examples/features/hooks/*
- examples/features/pagination/*
- examples/indexes-constraints.ts
- examples/postgresql-vs-sqlite.ts
- examples/snippets/02-field-types.ts through 04-order-by.ts
- examples/snippets/08-hooks-basic.ts through validation-hooks.ts
- examples/validation-hooks.ts

Updated (to new API):
- examples/snippets/01-basic-collection.ts
- examples/snippets/05-select.ts
- examples/snippets/10-relations.ts
- examples/snippets/11-auth-setup.ts
- examples/apps/todos-basic/*

Added (new demos):
- examples/apps/postgres-demo/ (PostgreSQL with Neon)
- examples/apps/mysql-demo/ (MySQL)
- examples/lib/ (shared db utilities)

Co-Authored-By: martyy-code <nesalia.inc@gmail.com>
…ration

Phase 1 - Core Type Inference:
- Update createDbAccess to accept TCollections instead of RawTable
- Add explicit casts using GetCollectionType<T> for proper type inference
- DbAccess<TCollections> now properly typed through createCollections()

Phase 2 - CLI Type Generation:
- Add generate:types command for generating collections-types.ts
- Supports --config and --output options
- Generates TypeScript interfaces from collection config

Type safety now works:
- db.users.create() validates input types
- db.users.findMany() returns properly typed records
- generate:types outputs explicit interfaces for external packages

Co-Authored-By: martyy-code <nesalia.inc@gmail.com>
Inline tests (in source files):
- InferCreateType, InferUpdateType in operations/database/types.ts
- GetCollectionType in collections/types.ts
- InferFieldType in collections/hooks/types.ts

Tests/types/ directory structure:
- infer-field-types.test.ts - InferFieldTypes tests
- infer-create-type.test.ts - InferCreateType tests
- get-collection-type.test.ts - GetCollectionType tests
- db-access-types.test.ts - DbAccess type construction
- field-requirement.test.ts - required vs optional handling
- select-field-types.test.ts - select field union types
- index.test.ts - entry point
- README.md - documentation

Also fix ZodEnum type assertion in generate-types.ts.

Uses @deessejs/type-testing with check<Equal<>> pattern.

Co-Authored-By: martyy-code <nesalia.inc@gmail.com>
After tsx --eval + JSON.stringify, Zod schemas become plain objects with
def instead of _def (underscore prefix lost). Also handle double-default
wrapping from config serialization.

Co-Authored-By: martyy-code <nesalia.inc@gmail.com>
- Add next-basic example showing collections integration with Next.js App Router
- Include users and posts collections with full CRUD API routes
- Add interactive CreateUserForm and CreatePostForm components
- Add DeleteButton component with confirmation
- Update main page to display and manage collections data
- Configure PostgreSQL connection via .env
- Add collection.config.ts for CLI schema management

Co-Authored-By: martyy-code <nesalia.inc@gmail.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
collections Error Error Apr 21, 2026 1:00pm

Co-Authored-By: martyy-code <nesalia.inc@gmail.com>
Co-Authored-By: martyy-code <nesalia.inc@gmail.com>
- Add init, push, and generate CLI commands
- Add MySQL adapter with buildDrizzleTable and createMysqlSchema
- Add runtime module with createCollections factory
- Add sqlBuilder for database operations
- Add comprehensive tests for new modules

Co-Authored-By: martyy-code <nesalia.inc@gmail.com>
- Move public docs to docs/internal for internal reference
- Add DEP (Design Enhancement Proposal) documents for architectural decisions
- Add implementation reports for adapter system and DX improvements
- Add deesse-fp skill for functional programming patterns
- Add commit and push skills for CI workflow
- Add skills-lock.json for skill version management

Co-Authored-By: martyy-code <nesalia.inc@gmail.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 30, 2026

Deployment failed with the following error:

Resource is limited - try again in 24 hours (more than 100, code: "api-deployments-free-per-day").

Learn More: https://vercel.com/aliiibenns-projects?upgradeToPro=build-rate-limit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant