diff --git a/.changeset/union-no-class-form.md b/.changeset/union-no-class-form.md deleted file mode 100644 index f074f42..0000000 --- a/.changeset/union-no-class-form.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -"@btravstack/entity": minor ---- - -`Entity.union(...)` returns a value, not a class. - -## Breaking: the class form is gone - -```ts -// before -class Payment extends Entity.union("method", [Card, BankTransfer]) {} - -// after -export const Payment = Entity.union("method", [Card, BankTransfer]); -export type Payment = Entity.Instance; -``` - -The class form typed as the members' shared _root_, not as the member union, so -it could not narrow — and it failed late, at the first call site that touched a -member-only field. A class's instance type cannot be a union (`TS2509`), so no -version of it could have narrowed; and its type was always redundant with the -root the author had already named. `class X extends Entity.union(...) {}` is now -`TS2507` at the declaration. - -Statics that lived in the class body become plain functions: - -```ts -export const parsePayment = (row: unknown) => Payment.make(row); -``` - -## Breaking: `__base` is removed - -The phantom `__base` carrier is gone from `EntityStatic` and `UnionMember`. It -existed only to compute the class form's root type. Nothing writes it by hand; -it is listed because it is part of the emitted public surface. diff --git a/packages/entity/CHANGELOG.md b/packages/entity/CHANGELOG.md index 8517a02..da6cf9c 100644 --- a/packages/entity/CHANGELOG.md +++ b/packages/entity/CHANGELOG.md @@ -1,5 +1,41 @@ # @btravstack/entity +## 0.7.0 + +### Minor Changes + +- 5844dd4: `Entity.union(...)` returns a value, not a class. + + ## Breaking: the class form is gone + + ```ts + // before + class Payment extends Entity.union("method", [Card, BankTransfer]) {} + + // after + export const Payment = Entity.union("method", [Card, BankTransfer]); + export type Payment = Entity.Instance; + ``` + + The class form typed as the members' shared _root_, not as the member union, so + it could not narrow — and it failed late, at the first call site that touched a + member-only field. A class's instance type cannot be a union (`TS2509`), so no + version of it could have narrowed; and its type was always redundant with the + root the author had already named. `class X extends Entity.union(...) {}` is now + `TS2507` at the declaration. + + Statics that lived in the class body become plain functions: + + ```ts + export const parsePayment = (row: unknown) => Payment.make(row); + ``` + + ## Breaking: `__base` is removed + + The phantom `__base` carrier is gone from `EntityStatic` and `UnionMember`. It + existed only to compute the class form's root type. Nothing writes it by hand; + it is listed because it is part of the emitted public surface. + ## 0.6.0 ### Minor Changes diff --git a/packages/entity/package.json b/packages/entity/package.json index 1195d4c..fdd5542 100644 --- a/packages/entity/package.json +++ b/packages/entity/package.json @@ -1,6 +1,6 @@ { "name": "@btravstack/entity", - "version": "0.6.0", + "version": "0.7.0", "description": "A domain-entity builder on zod v4: branded fields, immutable data, sealed construction, and Result instead of throws", "keywords": [ "ddd",