@vllnt/convex-flags 0.1.0 → 0.1.1-canary.4efa5b8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,113 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here. The format is based on
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to
5
+ [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+
8
+ ## [0.1.1] - Unreleased
9
+
10
+ ### Fixed
11
+
12
+ - The published tarball no longer includes the React and status test files.
13
+ - Management mutations reject an empty flag `key`, and `setOverride` / `clearOverride` an empty
14
+ `subjectRef`, with `ConvexError({ code: "INVALID_ARGUMENT" })`.
15
+ - `define` and `update` reject rollout weights (flag-level and rule-level) that are `NaN`,
16
+ infinite or negative with `INVALID_ARGUMENT`; previously they were silently ignored or skewed
17
+ bucketing.
18
+ - Rollouts with a non-whole-number weight now split subjects by their weights. In 0.1.0 some of
19
+ these weights bucketed unevenly: weights summing to 1 (such as `0.5` / `0.5`) sent every subject
20
+ to the first split, other sets were skewed (`1.5` / `1.5` served about 67% / 33%), and a split
21
+ could get no subjects at all (`0.25` / `0.75` / `1` never served its middle split). These
22
+ rollouts are re-bucketed once on upgrade, so some of their subjects change value. Rollouts whose
23
+ weights are all whole numbers, and rows stored with an `Infinity` weight before weights were
24
+ validated, bucket exactly as before.
25
+
26
+ ### Changed
27
+
28
+ - Management mutations (`define`, `update`, `enable`, `disable`, `archive`, `restore`,
29
+ `setOverride`) skip the write when nothing changed, so idempotent re-defines no longer bump
30
+ `updatedAt` or re-run every `evaluate`/`all` subscription.
31
+ - Upgrade dev tooling (vitest 5.1.1, vite 8.3, convex 1.51, convex-test 0.0.73, prettier 3.10,
32
+ jsdom 31, `@vllnt/typescript` 3 with `exactOptionalPropertyTypes` kept off), and override the
33
+ vulnerable transitive `handlebars`, `deepmerge-ts` and `minimatch` releases.
34
+ - Adopt pnpm 10 with a release-age gate; releases are published only from CI with npm trusted
35
+ publishing and provenance.
36
+ - Document the component error codes and how to use `/test` in a consuming app.
37
+ - The package now ships `docs/API.md`, `CHANGELOG.md` and `llms.txt`, so the docs in
38
+ `node_modules/@vllnt/convex-flags/` match the installed version. `llms.txt` links to these
39
+ files with relative paths, and a `test:package` CI check fails when a required file is missing
40
+ from the tarball or a contributor-only file is included.
41
+ - `docs/API.md` lists every entry point and its exports, the `./react` option and ref types, and
42
+ how a rollout that cannot bucket inside a matched rule falls back to the flag value.
43
+ - Canary builds publish on every qualifying push to `main` (dist-tag `canary` only, never
44
+ `latest`), including docs-only changes to the shipped files.
45
+ - `engines.node` is now `>=20`, matching what `convex` itself requires (no `convex` version in
46
+ the peer range supports Node 18).
47
+ - README rewritten in a fixed, agent-first order (when to use, install, quick start, an API table
48
+ linking every export and `Flags` method to `docs/API.md`, common tasks, every error code with its
49
+ fix, limits and gotchas, compatibility), with one `docs/API.md` heading per export, a
50
+ "When to use" section and the errors link in `llms.txt`, and a shorter `package.json`
51
+ description and keywords; `pnpm test:package` now installs the packed tarball in a temporary app,
52
+ checks this docs contract (`scripts/check-documentation.mjs`), type-checks the README examples
53
+ against convex 1.45.0 and React 18 and runs the README test example.
54
+
55
+ ## [0.1.0] - 2026-09-01
56
+
57
+ ### Added
58
+
59
+ - First release of `@vllnt/convex-flags` — feature flags as a sandboxed Convex component, evaluated
60
+ on the backend and streamed to clients over Convex's reactive queries.
61
+ - `Flags` client class: `define`, `enable`, `disable`, `remove`, `get`, `list`, `evaluate`,
62
+ `isEnabled`, and `all`.
63
+ - Sandboxed `flags` table keyed by an opaque, host-chosen flag key (`by_key` index).
64
+ - `example/convex/` host-app harness with 100% end-to-end coverage via `convex-test`.
65
+
66
+ - **Multivariate variants** — a flag value is now a typed primitive (`boolean | string | number`);
67
+ `define` accepts `variants` metadata. Added `variant(ctx, key, options?)` returning just the value.
68
+ - **Attribute targeting** — `define` accepts ordered `rules` (`{ conditions, value | rollout }`) with
69
+ operators `eq`, `neq`, `in`, `nin`, `contains`, `gt`, `gte`, `lt`, `lte`. First matching rule wins;
70
+ conditions within a rule AND together; an empty condition list is a catch-all.
71
+ - **Percentage rollouts** — `define` accepts a `rollout` of weighted `splits`, bucketed
72
+ deterministically (FNV-1a) by `context.subjectRef` or a named `by` attribute, so a subject always
73
+ resolves to the same value.
74
+ - **Evaluation context** — `evaluate` / `isEnabled` / `all` / `variant` take an optional host-supplied
75
+ `EvalContext` (`{ subjectRef?, attributes? }`); `evaluate` takes an optional `default` for unknown keys.
76
+ - **Per-subject overrides** — `setOverride(key, subjectRef, value)` / `clearOverride(key, subjectRef)`;
77
+ an override wins over targeting in `evaluate` and `all`.
78
+ - **Lifecycle** — `archive(key)` (reversible; serves the base value with reason `disabled`) and
79
+ `restore(key)`, distinct from `remove` (which now also deletes a flag's overrides).
80
+ - **React** — optional `@vllnt/convex-flags/react` entry exporting `useFlag` / `useFlags`; `react` is
81
+ an optional peer dependency.
82
+ - New evaluation reason codes: `rule`, `rollout`, `override`, `disabled`, `default` (alongside
83
+ `flag`, `unknown`).
84
+ - **Partial update** — `update(ctx, key, patch)` patches only the supplied fields, leaving the rest
85
+ untouched (the opposite of `define`, which fully replaces a definition).
86
+
87
+ ### Changed
88
+
89
+ - Treat Convex `_generated` output as CLI-owned, exclude it from formatting, and expose a
90
+ dedicated codegen script.
91
+ - Refresh all direct dependencies to their latest compatible releases for canary validation.
92
+ - Require `convex@^1.45.0` and update `convex-test` to `^0.0.56`.
93
+ - **Docs polish** — refreshed the package tagline; the README Usage section now shows a complete
94
+ `convex/flags.ts` host module (the `evaluate`/`all` queries the React hooks consume, plus gated
95
+ management wrappers); documented `define` (full replace) vs `update` (partial) and that
96
+ `enable`/`disable` are boolean convenience.
97
+
98
+ ### Fixed
99
+
100
+ - **Backward-compatible `status`** — the stored `flags.status` column is now optional, so a
101
+ deployment holding flag rows written before `status` existed no longer fails schema validation on
102
+ the next `convex deploy` (`Object is missing the required field status`). Reads materialize an
103
+ absent status as `"active"` — `get`/`list` return a concrete `status` and evaluation treats a
104
+ legacy flag as active — so the public `FlagDoc` shape is unchanged. `define` still writes
105
+ `status: "active"` for new flags; `restore(key)` stamps it onto legacy rows in storage.
106
+ ([#5](https://github.com/vllnt/convex-flags/issues/5))
107
+
108
+ ### Notes
109
+
110
+ - Backward compatible: the boolean kill-switch API (`define({ key, value })`, `enable`/`disable`,
111
+ `isEnabled(key)`, `evaluate(key)`, `get`/`list`/`all`/`remove`) is unchanged.
112
+ - Deferred: named reusable segments, JSON-object variant values, scheduled/progressive rollouts,
113
+ stale-flag detection, and audit-event emission — see `ROADMAP.md`.