Add typed multipart uploads and lossless JSONB documents - #236
Conversation
| `jsonValue()` accepts JSON null and writes it as a JSON value. A nullable | ||
| `jsonObject()` column uses SQL NULL for `null`; an omitted optional column follows | ||
| the existing SQL-default/null rules. Reads expose either null representation as | ||
| JavaScript `null`. No separate null sentinel is introduced. |
There was a problem hiding this comment.
I don't like an idea to have jsonValue and jsonObject schema builders, we should use object() with .jsonb() to express jsonb values. If you need some modifiers/changes of behavior, we could use some extension functions (specific for the knex-schema).
There was a problem hiding this comment.
Addressed in 9f39f09. JSONB documents now use ordinary object({...}).jsonb() schemas, with .acceptUnknownProps() at nodes that preserve extension data. Removed jsonValue()/jsonObject() and their metadata. This revision supports object roots, including nested arrays/scalars/nulls, and retains typed declared fields, column-name overrides, projections and ORM tracking. Updated the examples and tests; all local quality gates and PostgreSQL integration tests pass.
Description
Add F01–F03: schema-based single/multiple multipart uploads, typed client serialization and OpenAPI, and lossless JSONB object documents. Uploads enforce file, request, field and part limits, reject truncated content, and support file-only requests. Typed contracts reject invalid uploads before invoking handlers; options-only uploads retain their single-file shape and MIME rejection reporting.
Declare document columns with ordinary
object({...}).jsonb()schemas and use.acceptUnknownProps()where undeclared JSON fields must be preserved. JSONB reads, projections, returning rows, bulk operations and upserts preserve nested extension data. The database layer validates JSON extensions and aligns nullable object column DDL with reads. ORM tracking snapshots documents independently and detects nested edits. Object columns support.hasColumnName(), and projections retain their nested schema types. Fix the PostgreSQL upsert returning path exercised by the integration tests.Document roots are objects; nested values can include arrays, scalars and nulls. JSON storage behavior lives in
knex-schemaandorm. Includes feature candidates, current API guides, and a minor changeset covering five published packages. Uploads remain buffered. The server's default 5 MiBmaxBodySizeapplies to the complete multipart request and can be configured alongside file/field/part limits.Type of Change
Validation
npm run lint— passednpm run build— 22 tasks passednpm run test— 4,433 tests across 223 files passed; no type errorsnpm run typecheck:schema-site— passednpm run typecheck:docs-site— passednpm run test:queries:integration— 59 tests across 5 files passed against disposable PostgreSQL 16git diff --check— passedCoverage includes real typed-client uploads, exact limit boundaries, malformed bodies, disconnect cleanup, legacy behavior, file type inference, OpenAPI, PostgreSQL round trips, nested open/strict objects, SQL nullability, declared dates, mapping and ORM nested edits/reset.
Checklist
npm run lintand fixed any issuesnpm run testand all tests pass