mirror of
https://github.com/bitbaum/petvity.git
synced 2026-12-04 07:50:03 +01:00
f8512e94de384aa3333fb602d805088d6496243b
2
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
c65ac4b7d7 |
chore: add a formatter (#71)
* chore: add a formatter, matching the style this repo already writes singleQuote=false was chosen by counting this repo's own imports, not by fleet decree. The fleet is genuinely split and the two repos that already had a .prettierrc disagreed with each other, so there was no standard to restore. Quote style does not cross repo boundaries; having a gate does. Markdown is ignored for now — prettier rewraps prose, which would bury the real diff. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * style: format with prettier (252 files) Mechanical. No behaviour change. This SHA is listed in .git-blame-ignore-revs so `git blame` skips it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * chore: teach git blame to skip the reformat Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
02d847a016 |
feat(commerce): extract commercekit, and adopt it here (#53)
* feat(health): track what actually matters, per species The seven metrics in health-metrics.ts are applied uniformly to all ten species. That is tidy and, for several of them, wrong in ways that matter. Body temperature is not a property a fish or a reptile has in the sense the field implies. They are ectotherms: a fish's body temperature IS the water temperature, and a reptile's depends on where it is sitting in a thermal gradient. Heart rate is not measurable at home for a bird, a fish or a hamster. Asking for either produces an empty field, and empty fields teach owners to skip — a habit that generalises to the field that mattered. Worse, none of the seven capture what actually kills these animals. A rabbit that has not eaten and produced no droppings for twelve hours is a medical emergency; gut stasis is the leading cause of death in pet rabbits. A male cat straining without producing urine is fatal in 24-48 hours. A horse whose manure output drops is the earliest practical warning of colic. A UVB bulb keeps emitting visible light long after its UVB output has decayed, so the enclosure looks fine while the animal develops metabolic bone disease. lib/config/observations.ts is the SSOT for what is worth observing and for which species. Each observation declares its species, cadence, whether an owner can actually produce the answer, why it earns a tap, and what answer means "call a vet" — with the reason, because an alert nobody believes is an alert everybody dismisses. Records (microchip, parasite schedule, diet, farrier, water changes) are modelled separately, since they are durable facts rather than things that changed today. The daily set is capped at five and the cap is a test that FAILS rather than a slice that truncates. Printing the sets caught three real design faults that the first round of tests passed: fish had an empty daily check-in because water temperature is device-sourced and I was filtering device readings out; dogs and cats had seven candidates silently cut to five by array order; and reptiles were being asked about mood while the enclosure gradient that actually kills them was excluded. Priority is now explicit and cadence can be overridden per species — a snake fed weekly should not be asked daily whether it ate. Clinical values are typical published ranges compiled for product design, NOT clinically reviewed. REVIEW_STATUS records that, so it cannot quietly be presented to an owner as authority. Also adds docs/pet-health-science.md (the reasoning, species by species), docs/digital-twin-and-legacy.md (twin staging, memorialisation, gamification and revenue, including an explicit list of what not to build), and a first blog draft. Nothing is published — that is a deliberate decision, not a side effect. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * feat(commerce): extract commercekit, and adopt it here Three shops in the fleet: evig, petvity and fitfoot. Before proposing anything shared I checked what is actually duplicated rather than assuming — revampit turned out to be a second clone of evig, so it is three codebases, not four, which is exactly the rule of three. They have three incompatible foundations, so a single shared "webshop" adopted by all of them would be a rewrite of two. What IS shared is narrower and is the part every shop rewrites and gets subtly wrong. That is what this extracts. packages/commercekit — zero runtime dependencies, framework-free core, React bindings behind a separate entry point. money Integer minor units. `12.55 * 100` is 1254.9999999999998, so fromDecimal works on digits. The currency carries its own exponent, so JPY has no decimals and KWD has three without a special case. allocate() is largest-remainder: splitting 100 three ways gives [34,33,33] and never loses or invents a unit — asserted across 200 amounts x 5 weight patterns. percent() takes an explicit rounding mode, because a marketplace computing its own commission should round down rather than over-charge a seller. cart A line is an id and a quantity. Never a price — a cart open for a week would otherwise show one number and charge another. Cross-tab sync, clamping, and corrupt storage yielding an empty cart rather than a crashed shop. Stable snapshot reference, which is what useSyncExternalStore needs to avoid an infinite render loop. inventory Conditional decrement, all-or-nothing, with compensation on partial failure and sorted lock order so opposite carts cannot deadlock. Duplicate lines are merged, or the availability check for the second is made against stock the first already took. The test suite demonstrates the bug it prevents: a read-then-write adapter tells 50 buyers "yes" against 10 units while recorded stock falls by one. buyer Account XOR guest as a discriminated union rather than two nullable columns, so an order belonging to nobody cannot be represented. A type is a claim, so the matching Postgres CHECK ships beside it. Receipt tokens use the platform CSPRNG and refuse to run without one. address ISO-3166 codes with names from Intl.DisplayNames — every locale the runtime supports, no translation files, no way for the German list to drift from the English one. Petvity adopts all of it, which is the proof: lib/shop/cart.ts and lib/config/countries.ts become thin bindings, and placeOrder's hand-rolled reservation is replaced by reserveAll over a Drizzle adapter that is the only Petvity-specific part. Cancellation goes through releaseAll, so there is now one implementation of giving stock back instead of two. One behaviour change worth naming: the old code skipped the UPDATE entirely for unlimited-stock products, so the shared db mock's default empty return was never exercised on that path. The new adapter always issues the conditional update (`stock IS NULL OR stock >= n`, and NULL - n stays NULL), which is correct against a real database but made the mock read as "sold out". The mock was modelling an UPDATE that matches nothing; two tests now say what a matching UPDATE returns. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com> |