@rebuy/rebuy
v3.4.0
Published
Shared zod schemas, legacy-to-CAB widget transforms, and server orchestrators for Rebuy's Shopify consumers (rebuy-api, admin-nextjs, rebuy-shopify-extensions)
Maintainers
Keywords
Readme
@rebuy/rebuy
Shared zod schemas, legacy→CAB widget transforms, and server orchestrators for Rebuy's Shopify consumers — the library rebuy-api, admin-nextjs, and rebuy-shopify-extensions all build on.
Install
npm install @rebuy/rebuy zodzod ^4.4.3 is a peer dependency: consumers install their own copy so every package in a tree composes and instanceof-checks against ONE zod instance. Yarn v1 workspaces do not auto-install peers — declare zod explicitly there. react-hook-form is an optional peer, needed only by form-layer consumers that use the SectionArrayPath/SectionPrefixPath types against their own forms (type-only — nothing is bundled).
Node ^22.14.0 || ^24.10.0 || ^26.0.0 for development; the published artifacts are plain ES2020 (ESM .mjs + CJS .cjs).
Entry points
| Subpath | Contents |
| --- | --- |
| @rebuy/rebuy | Root barrel: schemas, client helpers, utilities |
| @rebuy/rebuy/client | RebuyClient API client |
| @rebuy/rebuy/gwp | Gift-with-purchase validation helpers |
| @rebuy/rebuy/pricing | Variant pricing/discount forecast (priceVariant, currencyDecimals) |
| @rebuy/rebuy/routes | apiRoutes + the UPSTREAM_SUFFIXES upstream-host allowlist |
| @rebuy/rebuy/schema/checkout-and-beyond | The CAB section-tree schema (CABRootSection et al.) |
| @rebuy/rebuy/schema/checkout-and-beyond/constants | CAB enums/constants (SectionType, ButtonField, …) |
| @rebuy/rebuy/schema/shop-config | ShopConfig schema |
| @rebuy/rebuy/schema/user-config | UserConfig schema |
| @rebuy/rebuy/schema/widget-data | WidgetData schema |
| @rebuy/rebuy/server | Server orchestrators for rebuy-api's /cab/* routes (settings→tree conversion, data sources, gifts, analytics) + request schemas |
| @rebuy/rebuy/transforms | Legacy v1 widget → CAB tree converters |
| @rebuy/rebuy/utilities | Misc utilities (getIdFromGraphUrl, stripHtml, uuid, …) |
Every type derives from a zod schema via z.infer — defaults live in the schema (.default() at parse time), never in consumer render code.
Development
npm run lint # eslint + prettier (a misformat is a lint error)
npm run test:coverage # vitest, 100% thresholds over the coverage allowlist
npm run check-types # tsc --noEmit
npm run build # types + esbuild bundles + check:dist smoke testAfter any dependency change, regenerate the lockfile with the pinned npm 10 (npm run lock && npm run lock:verify) — never with npm 11. Versions are cut by semantic-release from ESLint-convention commits (Fix:, Update:, New:, Breaking:, …); never hand-bump version. See AGENTS.md for the full contributor contract.
