@guidelytech/flags 0.7.0 → 0.9.0

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/README.md CHANGED
@@ -102,7 +102,8 @@ your fallback, and afterwards the last good payload.
102
102
  | `payload` / `remoteResults` | — | Bootstrap: used immediately (`ready` at once). |
103
103
  | `remoteEval` | `false` | Evaluate on the server (`POST /flags/evaluate`) for environments that hide their rules. Switched on automatically when a public key gets `remote_evaluation_required`. Re-evaluates (debounced) when attributes change; results are cached per attribute set. |
104
104
  | `decryptionKey` | — | For encrypted payloads (AES-256-GCM via WebCrypto). |
105
- | `overrides` / `overrideBehaviour` | — / `localOverRemote` | `localOnly` (never fetch), `localOverRemote` (overrides win), `remoteOverLocal` (only for flags missing remotely). |
105
+ | `overrides` / `overrideBehaviour` | — / `localOverRemote` | `localOnly` (never fetch; overrides, then the bootstrap `payload`), `localOverRemote` (overrides win), `remoteOverLocal` (only for flags missing remotely). |
106
+ | `devOverrides` | `true` | Read [dev overrides](#dev-overrides-ci-and-tests) from environment variables and test globals. |
106
107
  | `enableUrlOverrides` | `false` | Browser QA: `?guidely_flags=new-checkout:true,checkout-button-color:"green"`. |
107
108
  | `stickyBucketService` | — | `InMemoryStickyBucketStore` / `LocalStorageStickyBucketStore`: users keep their experiment variation. |
108
109
  | `storage` | `localStorage` in browsers | Any `getItem`/`setItem` store, sync or async (AsyncStorage). `false` disables. |
@@ -115,6 +116,52 @@ your fallback, and afterwards the last good payload.
115
116
  `createStaticFlags({ payload, attributes })` gives the same getters over a payload with no network
116
117
  or tracking — framework bindings use it to server-render and hydrate.
117
118
 
119
+ ## Dev overrides (CI and tests)
120
+
121
+ Pin flag values without touching the app. Every client reads these once, when it is created:
122
+
123
+ | Source | Example |
124
+ |---|---|
125
+ | `GUIDELY_FLAG_OVERRIDES` | `new-checkout:true,limit:5,theme:"dark"` or `{"new-checkout":true}` |
126
+ | `GUIDELY_FLAG_OVERRIDES_FILE` | path to a file holding the same text (JSON object or one `key:value` per line) |
127
+ | `GUIDELY_FLAG_OVERRIDE_BEHAVIOUR` | `localOnly` — no network, no cached payload: hermetic tests |
128
+ | `globalThis.__GUIDELY_FLAG_OVERRIDES__` / `__GUIDELY_FLAG_OVERRIDE_BEHAVIOUR__` | an object or the same text, set by a test runner in the page |
129
+
130
+ ```bash
131
+ GUIDELY_FLAG_OVERRIDES='new-checkout:true' GUIDELY_FLAG_OVERRIDE_BEHAVIOUR=localOnly pnpm test
132
+ GUIDELY_FLAG_OVERRIDES_FILE=ci/flags.json pnpm test
133
+ ```
134
+
135
+ A sample `ci/flags.json` (keys are flag keys; give each value the flag's type, since a value of the
136
+ wrong type or `null` makes the getter return its fallback):
137
+
138
+ ```json
139
+ {
140
+ "new-checkout": true,
141
+ "checkout-button-color": "green",
142
+ "max-cart-items": 25,
143
+ "pricing-page": { "layout": "grid", "plans": ["starter", "pro", "team"] },
144
+ "holiday-banner": null
145
+ }
146
+ ```
147
+
148
+ ```ts
149
+ // Playwright: set before the page's scripts run.
150
+ await page.addInitScript(() => {
151
+ (window as any).__GUIDELY_FLAG_OVERRIDES__ = { "new-checkout": true };
152
+ });
153
+ // Cypress: cy.visit("/", { onBeforeLoad: (win) => { win.__GUIDELY_FLAG_OVERRIDES__ = { "new-checkout": true }; } });
154
+ ```
155
+
156
+ Per flag, later wins: `overrides` / `setOverrides()` → file → variable → global → `?guidely_flags=`.
157
+ `setOverrides()` only replaces the first. Values are served with reason `OVERRIDE`. The client
158
+ logs one warning listing the sources in use, so a variable left set in production shows up in
159
+ logs; malformed sources go to `onError` and are ignored. `devOverrides: false` turns it all off.
160
+
161
+ With server rendering, set both: the variable for server code and the global for the browser
162
+ (React and Svelte server renders read the bootstrap payload, which carries no overrides).
163
+ `parseOverrides(text)` is exported for reading the same format elsewhere.
164
+
118
165
  ## CLI
119
166
 
120
167
  ```bash
@@ -132,4 +179,4 @@ commit default to the current git checkout (or `GITHUB_REF_NAME` / `GITHUB_SHA`)
132
179
  prints the references instead. `guidely-flags --help` lists every option.
133
180
 
134
181
  The evaluation semantics are specified in
135
- [docs/feature-flags-spec.md](https://github.com/parmarg/Guidely/blob/main/docs/feature-flags-spec.md).
182
+ [docs/feature-flags-spec.md](https://github.com/GuidelyTech/Guidely/blob/main/docs/feature-flags-spec.md).