Repository navigation
chore: release packages - #66
Conversation
There was a problem hiding this comment.
Pull request overview
Release automation PR for @btravstack/entity that prepares the repository metadata for publishing version 0.7.1 to npm (per Changesets), reflecting a documentation-only patch associated with issue #60.
Changes:
- Bump
@btravstack/entityversion to0.7.1. - Add
0.7.1release notes to the package changelog. - Remove the consumed changeset file now that it has been released.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/entity/package.json | Updates the package version to 0.7.1 for publication. |
| packages/entity/CHANGELOG.md | Adds the 0.7.1 patch entry describing the documentation-only change. |
| .changeset/computed-self-reference-annotation.md | Removes the changeset after it has been applied to the release. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
084e1df to
6ac4a27
Compare
6746d53 to
12be092
Compare
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (3)
💤 Files with no reviewable changes (2)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe package version changed from 0.7.0 to 0.8.0. The changelog records equality behavior and its Node.js requirement, branded declaration emit, self-referencing annotations, and synchronous generator failure handling. Two changesets were removed. ChangesEntity package release
Priority: ⬇️ Low Estimated code review effort: 1 (Trivial) | ~5 minutes Merge Risk: ⚪ Minimal · up to This release-metadata change bumps the package to 0.8.0 and records the changelog entries. No merge-blocking issues were found. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
d883bb9 to
f022682
Compare
fa4c8f9 to
7153633
Compare
8df35db to
73ed9d1
Compare
829d90b to
a84f436
Compare
37c87ae to
c6bc031
Compare
f5ade23 to
488da27
Compare
488da27 to
5db244b
Compare
This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.
Releases
@btravstack/entity@0.8.0
Minor Changes
83af66b:
Entity.aggregate(tag)(fields)(options)declares an aggregate root whose statechanges only through events. The options declare the
events(a zoddiscriminated union on
type), anopenshandler per creation event and anevolvehandler per other event; omitting one is a compile error.update()and no factories. A command checks itsbusiness rules and calls
this.emit(...events), which parses the events,folds them, verifies the result with one
make, and returns a sealedEntity.Decision: the events and the verified state. Onlyemitandstartcan build one, and events that break an invariant are a defect.SomeAggregate.start(event)creates from a creation event.SomeAggregate.replay(events)parses and folds a stored stream;makestill rehydrates a snapshot or a state row. Neither emits events.
without changing its declaration.
Entitykeeps its API. Four new top-level declaration-emit names:AggregateStatic,AggregateInstance,Decision,DecisionKey, plusEntity.Decision,Entity.EventandEntity.Aggregatein the namespace.1729958: Breaking: structural
equalsis removed, and entities compare by declaredidentity instead.
Entity.field(schema, { identity: true })marks a field as part of theentity's business identity. Several flagged fields form a composite
identity. It implies
immutable, and the value must be a required primitive.entity.sameIdentityAs(other)is true whenotheris in the same identityscope and every identity field is equal by
Object.is. The scope is theclass that declares the identity, or the abstract root when it is declared
there, so a root's variants (a draft and the document it became) share it.
On an entity with no identity field, calling it is a compile error.
equalsis gone, and with it the package's only Node import(
node:util'sisDeepStrictEqual), so the package now bundles for thebrowser. To compare two whole states, compare their
toJSON()with your owndeep-equality function.
sameIdentityAsreplacesequalsas a reserved field name.To migrate, flag your id fields
identity: trueand replacea.equals(b)witha.sameIdentityAs(b)where you meant "the same entity", or with a deepcomparison of
toJSON()where you meant "the same state".aab342b: Add
SomeEntity.inspect(state), a read-side door for stored rows written before a rule existed. It validates the field schemas strictly and re-derivescomputedlikemake, then reports every broken invariant instead of refusing the row:Result<Inspection<Output>, InvalidEntity>, whereInspectionis{ data, violations }.datais plain frozen data, never an entity instance, so a row that breaks today's rules cannot reach a command by accident. The way back is a migration, thenmake, which stays strict.violationsare the issuesmakewould have failed with, soEntity.codeOfreads them. A field failure is stillInvalidEntity, a throwing predicate is still a defect, and a nested entity field is inspected strictly.Entity.uniongainsinspecttoo, dispatching on the discriminant.Inspectionjoins the top-level declaration-emit names, withEntity.Inspectionfor annotations. The new how-to, "Add a stricter rule without an outage", covers the rollout.20dcfc2: Breaking:
Entity.invariantnow takes one object with a required stablecode:The code is the rule's identity, which a caller keys behaviour off (an error
code in a response, a field to highlight, a localised string), while the
message may vary with the data. A failing rule's issue is now
{ message, params: { code } }; the code survives nested entities, arrays andunions with the path prefixed, and the new
Entity.codeOf(issue)reads it back.To migrate, wrap each
Entity.invariant(ensure, message)asEntity.invariant({ code, ensure, message }). A missing code is a compileerror.
4d79b0e: Breaking:
input,output,createInputandupdateInputare plain allthe way down, so an entity with a nested-entity field converts to JSON Schema
(No wire projection: nested entities break z.toJSONSchema, and undefined/null is bridged by hand at every boundary #72).
nullable one, or an
Entity.union(...)now embeds the nested entity's ownplain schema in each member: its
inputininput,createInputandupdateInput, itsoutput(computed fields included) inoutput. A unionbecomes a discriminated union of its members' plain schemas. Every member
converts with
z.toJSONSchemain both directions, at any depth; before, allof them threw.
make,updateand the factories are unchanged: they parse through aninternal schema that keeps the classes, so a nested field still holds a real
instance.
updateInputis now derived frominputrather thanoutput. Its keys arethe same; only a nested entity's schema differs.
Entity.union(...)value'sinputandoutputare typed from itsmembers' schemas instead of
z.ZodType<unknown>.To migrate: parsing with a member now yields plain data at every depth, so
Order.output.parse(x).lines[0]is an object, not anOrderLine. Code thatrelied on a member to construct nested instances should call
makeinstead,which is the entry point for building entities. Types follow suit:
z.output<typeof Order.output>describes plain nested data, whileEntity.Output<typeof Order>and the instance types still carry the nestedentities.
f3b42e3:
Entity.field(schema, { unbranded: true })exempts one field from the rulethat every field be branded, an entity or a narrow literal. It is meant for a
descriptive leaf (a label, a display name) with no second value it could be
confused with, whose brand would otherwise leak into every consumer of the
derived schemas. The field is still validated and still honours
immutable;only the branding rule is relaxed, and only for that field. Existing
declarations are unchanged, and their emitted declarations do not grow.
Patch Changes
8d928cd: A downstream library compiling with
declaration: truecan now export a valuewhose inferred type runs a branded object through the package's deep-readonly
data type. That includes
SomeEntity.factory(...)for an entity with anested-entity field. Declaration emit used to fail with
TS4023($brandcannot be named); the brand now prints as
z.$brand<…>.02c29e3: Document the self-referencing deriver idiom (computed derivers cannot reference the entity's own statics (TS2506) #60): a
computedderiver or anEntity.invariantpredicate may call the entity's own statics, given anexplicit return annotation —
(d): boolean => Doc.isActive(d.tags). Theunannotated form is
TS2506, which is TypeScript resolving the deriver'sinferred return type inside the class's own base expression, not a rule of
the library. The annotation is still checked against both the body and the
schema.
computed.test-d.tspins the idiom, the wrong-annotation errors, andthe
this-parameter dead end (TS2502).Documentation only; no runtime or API change.
08aca24: A synchronous generator that throws no longer escapes
factory(...)'s returnedfunction: the factory now returns a
Defectcarrying the original cause, thesame channel a rejecting generator already takes under
factoryAsync.