Skip to content

feat: native Date/Map/Set Encoded; query adapters convert to JSON - #874

Merged
omegent-app[bot] merged 15 commits into
mainfrom
feat/query-native-encoded-types
Sep 6, 2026
Merged

feat: native Date/Map/Set Encoded; query adapters convert to JSON#874
omegent-app[bot] merged 15 commits into
mainfrom
feat/query-native-encoded-types

Conversation

@omegent-app

@omegent-app omegent-app Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Schema.Date, ReadonlySet, and ReadonlyMap no longer rewrite Encoded to JSON (string / array). Encoded is the native value (Date / Set / Map).

The query DSL types filter values as Encoded, so where("n", "gt", new Date(...)) typechecks. Document-store adapters convert Encoded to JSON at the schema boundary (Schema.toCodecJson(toEncoded(schema))):

  • Query paths are Encoded field names (including encodeKeys renames)
  • in / includes-any encode through union element schemas
  • Date → ISO string, Set → array, Map → array of entries
  • App types such as DateOnly stay native Encoded and JSON-lower via the same document schema — not a type registry

Memory, Disk, SQL, and Cosmos use that codec for documents, query parameters, and defaults.

JSON Encoded codecs remain as explicit helpers: DateFromString, ReadonlySetFromArray, ReadonlyMapFromArray. OmegaForm date inputs that take strings should use DateFromString.

Map query ops

JSON-encoded maps are arrays of [key, value] tuples. Query DSL additions on ReadonlyMap fields:

  • hasKey / notHasKey
  • hasValue / notHasValue
  • hasKeyValue / notHasKeyValue (pair is readonly [K, V])
  • *-any / *-all variants for multiple keys, values, or pairs

Adapters compile these against the encoded tuple array (EXISTS / p[0] / p[1] in Cosmos, json_each + $[0]/$[1] in SQLite, jsonb_array_elements in Postgres, in-memory after toCodecJson).

Breaking

  • S.Date Encoded is Date, not string
  • S.ReadonlySet Encoded is Set, not array
  • S.ReadonlyMap Encoded is Map, not array of tuples
  • Query filters on those fields take native values, not JSON

opened by patroza in chat thread Discord · Discord · T3


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

omegent-app Bot and others added 2 commits August 22, 2026 08:20
Query filters now take Date/Set/Map values. Cosmos/SQL/memory adapters
lower those to JSON (ISO strings, arrays, entries), and repository
persistence round-trips through Schema.toCodecJson.

Use DateFromString / ReadonlySetFromArray / ReadonlyMapFromArray when
Encoded must be JSON.

Co-authored-by: Patrick Roza <42661+patroza@users.noreply.github.com>
Co-authored-by: Patrick Roza <42661+patroza@users.noreply.github.com>
@omegent-app
omegent-app Bot marked this pull request as ready for review August 22, 2026 08:22
@pkg-pr-new

pkg-pr-new Bot commented Aug 22, 2026

Copy link
Copy Markdown

Open in StackBlitz

@effect-app/cli

npm i https://pkg.pr.new/effect-app/libs/@effect-app/cli@874

effect-app

npm i https://pkg.pr.new/effect-app/libs/effect-app@874

@effect-app/eslint-codegen-model

npm i https://pkg.pr.new/effect-app/libs/@effect-app/eslint-codegen-model@874

@effect-app/eslint-shared-config

npm i https://pkg.pr.new/effect-app/libs/@effect-app/eslint-shared-config@874

@effect-app/infra

npm i https://pkg.pr.new/effect-app/libs/@effect-app/infra@874

@effect-app/vue

npm i https://pkg.pr.new/effect-app/libs/@effect-app/vue@874

@effect-app/vue-components

npm i https://pkg.pr.new/effect-app/libs/@effect-app/vue-components@874

commit: 920c1c1

omegent-app Bot and others added 3 commits August 22, 2026 09:25
Unwrap ReadonlySet in includes/includes-any and accept Set or array
needles for in. Adapters already JSON-convert those values.

Co-authored-by: Patrick Roza <42661+patroza@users.noreply.github.com>
Memory and Disk now convert documents with Schema.toCodecJson(toEncoded)
instead of JSON.parse/stringify (which dropped Map/Set). SQL and Cosmos
use the same codec on write/read. Repository encode stays Type→Encoded;
adapters own JSON.

Co-authored-by: Patrick Roza <42661+patroza@users.noreply.github.com>
JSON-encoded maps are arrays of [key, value] tuples. Add hasKey,
hasValue, hasKeyValue (and not*/any/all variants) on the query DSL,
implemented in memory, SQLite, Postgres, and Cosmos.

Co-authored-by: Patrick Roza <42661+patroza@users.noreply.github.com>
omegent-app Bot and others added 10 commits September 2, 2026 12:00
Cosmos/SQL merged StoreConfig.defaultValues (now native Date/Map/Set)
into stored JSON before toCodecJson decode. Lower defaults the same way
Memory already does. Also use globalThis.Date in schema helpers, Reflect
for Error.stackTraceLimit, and Sendgrid send ReturnType so linked-source
app typechecks.

Co-authored-by: Patrick Roza <42661+patroza@users.noreply.github.com>
Restore Error.stackTraceLimit assignment and Sendgrid ClientResponse
callback types. They are unrelated to native Encoded query work.

Co-authored-by: Patrick Roza <42661+patroza@users.noreply.github.com>
Date/Map/Set stay built-in. App schemas (DateOnly, …) register via
JsonValues, StoreConfig.jsonValues, or registerJsonSchema so query
params and schemaless documents lower through toCodecJson without
special-casing those types in effect-app.

Co-authored-by: Patrick Roza <42661+patroza@users.noreply.github.com>
Co-authored-by: Patrick Roza <42661+patroza@users.noreply.github.com>
errorReporter.ts imports @sentry/node statically. Linked --prod Docker
installs skip peer/dev copies, so Node cannot resolve it from source.

Co-authored-by: Patrick Roza <42661+patroza@users.noreply.github.com>
App types like DateOnly keep Encoded as the native value; only
toCodecJson lowers it to a string.

Co-authored-by: Patrick Roza <42661+patroza@users.noreply.github.com>
Drop JsonValues / StoreConfig.jsonValues. makeRepo already passes
the schema; adapters toCodecJson documents, query params, and
defaults from field paths. Date/Map/Set remain a schemaless fallback.

Co-authored-by: Patrick Roza <42661+patroza@users.noreply.github.com>
… values

Opaque/class Encoded AST is a Declaration; `in`/scalar compares on
array fields must use the element schema.

Co-authored-by: Patrick Roza <42661+patroza@users.noreply.github.com>
S.is guards encode so an `in`/`includes` value is not forced through
an array/Set codec.

Co-authored-by: Patrick Roza <42661+patroza@users.noreply.github.com>
Query paths are Encoded names. Walking Type `.fields` (or Class typeParameters)
misses `encodeKeys` renames and can bind a scalar to the wrong field schema.
`includes-any` on a tagged union of array fields must unwrap the union to the
element schema; otherwise each element is encoded as an array.

Co-authored-by: Patrick Roza <42661+patroza@users.noreply.github.com>
@omegent-app
omegent-app Bot merged commit 186de3a into main Sep 6, 2026
6 checks passed
@omegent-app
omegent-app Bot deleted the feat/query-native-encoded-types branch September 6, 2026 06:51
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.

0 participants