Skip to content

Add typed multipart uploads and lossless JSONB documents - #236

Merged
andrewzolotukhin merged 4 commits into
developmentfrom
feat/typed-uploads-jsonb
Oct 2, 2026
Merged

andrewzolotukhin merged 4 commits into
developmentfrom
feat/typed-uploads-jsonb

Conversation

@andrewzolotukhin

@andrewzolotukhin andrewzolotukhin commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

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-schema and orm. Includes feature candidates, current API guides, and a minor changeset covering five published packages. Uploads remain buffered. The server's default 5 MiB maxBodySize applies to the complete multipart request and can be configured alongside file/field/part limits.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Refactor / internal improvement

Validation

  • npm run lint — passed
  • npm run build — 22 tasks passed
  • npm run test — 4,433 tests across 223 files passed; no type errors
  • npm run typecheck:schema-site — passed
  • npm run typecheck:docs-site — passed
  • npm run test:queries:integration — 59 tests across 5 files passed against disposable PostgreSQL 16
  • git diff --check — passed

Coverage 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

  • I've added tests for my changes
  • I've run npm run lint and fixed any issues
  • I've run npm run test and all tests pass
  • I've added a changeset if this changes package behavior

Comment thread libs/knex-schema/README.md Outdated
Comment on lines +987 to +990
`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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread libs/knex-schema/src/json-validation.ts
@andrewzolotukhin
andrewzolotukhin merged commit a0a78d6 into development Oct 2, 2026
2 checks passed
@andrewzolotukhin
andrewzolotukhin deleted the feat/typed-uploads-jsonb branch October 2, 2026 12:54
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