diff --git a/UPGRADING.md b/UPGRADING.md new file mode 100644 index 0000000..301f7ed --- /dev/null +++ b/UPGRADING.md @@ -0,0 +1,11 @@ +# Upgrade notes + +Each section is the upgrade-notes block of one release. Paste it into the GitHub release body and under the release's heading in `CHANGELOG.md`. The changelog generator writes only commit subjects, and some of these changes have no `!` in theirs. + +## v0.3.0 + +- **`update()` with an `any`-typed argument resolves to `never`.** Reading its result, for example `.run()`, fails to compile (TS2339). A function argument still matches only the updater overload and an object argument only the document overload, so typed calls are unchanged. Unchecked `any` writes become compile errors. `ReturnType` is now `Query`, so `await ...run()` is a `number` instead of `any` ([#65](https://github.com/AntelopeJS/interface-database/pull/65)). +- **The entries of a `FieldType` codec are typed `unknown`.** `IoTsCodec` is now a type alias with the same members, so `Object.entries` on a codec gives `[string, unknown]` instead of `[string, any]`. A consumer that passed those entries on as `FieldType` stops compiling. Narrow each entry first. Every value assignable to `FieldType` before still is ([#63](https://github.com/AntelopeJS/interface-database/pull/63)). +- **Stage operands are checked as query values.** A generic `T` operand, or a class instance with methods such as `ObjectId`, no longer compiles as a stage operand. Neither does an operand that holds a `bigint`, a `symbol`, a function or a value typed `unknown`. `eq`, `ne`, `gt`, `ge`, `lt`, `le` and `includes` check their operand against the receiver's type. `constant`, `default`, `sub`, `merge` and the default of `key` refuse an `interface`-typed record: declare it with `type`. A generic `K extends keyof T` no longer compiles as a `ValueProxy.key`. `any` stays `any` ([#62](https://github.com/AntelopeJS/interface-database/pull/62)). +- **Query stages are typed by name.** `QueryStage` is a union discriminated on `stage`, built from the new exported `QueryStageMap`, and `QueryStage(name, options, ...args)` is typed by name. The protected `StagedObject#stage(type, stage)` takes a built `QueryStage`. `ValueProxy#eq` and `#ne` take `StagedObject | T` instead of `unknown`. `pluck` answers `Pick` and `without` answers `Omit`. Key, table, index and field names are `keyof T & string`. `Table#between` bounds are `T[TK] & IndexBound`, so a field that holds no index value stops compiling as a bound. `ValueProxy#add` takes an operand that fits its receiver, so two dates, or a string on a number, stop at compile time ([#51](https://github.com/AntelopeJS/interface-database/pull/51)). +- **Written documents are typed as write values.** `DeepPartial` drops `bigint` and `symbol` leaves, maps a field typed `unknown` to `WriteValue`, keeps a field typed `any` as `any`, and maps any other non-object type to `never`. The `insert`, `update` and `replace` builders compile only while every leaf of the document is a `WriteValue`: text, a number, a boolean, `null`, `undefined`, a `Date`, a list or a nested document ([#59](https://github.com/AntelopeJS/interface-database/pull/59)).