@terreno/feature-flags 57.8.0 → 57.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.
@@ -89,9 +89,14 @@ class FeatureFlagsApp {
89
89
  throw new api_1.APIError({ status: 401, title: "Authentication required" });
90
90
  }
91
91
  const targetingKey = String(user._id ?? user.id);
92
- const flags = await featureFlagModel_1.FeatureFlag.find({ archived: { $ne: true }, enabled: true });
92
+ const flags = await featureFlagModel_1.FeatureFlag.find({ archived: { $ne: true } });
93
93
  const config = {};
94
94
  for (const flag of flags) {
95
+ // Disabled boolean flags are sent as `off` so clients can tell a turned-off
96
+ // flag from one that was never created. Disabled variant flags stay omitted.
97
+ if (!flag.enabled && flag.type !== "boolean") {
98
+ continue;
99
+ }
95
100
  config[flag.key] = (0, flagConfiguration_1.buildFlagDefinition)(flag, targetingKey, user, this.segments);
96
101
  }
97
102
  const body = { data: config };
package/package.json CHANGED
@@ -5,14 +5,14 @@
5
5
  },
6
6
  "dependencies": {
7
7
  "@openfeature/server-sdk": "^1.22.0",
8
- "@terreno/api": "57.8.0",
8
+ "@terreno/api": "57.9.0",
9
9
  "express": "^5.2.1",
10
10
  "lodash": "^4.18.1"
11
11
  },
12
12
  "description": "Feature flags and A/B testing plugin for @terreno/api — part of Terreno, the batteries-included TypeScript framework for universal apps.",
13
13
  "devDependencies": {
14
14
  "@biomejs/biome": "^2.3.6",
15
- "@terreno/test": "57.8.0",
15
+ "@terreno/test": "57.9.0",
16
16
  "@types/bun": "^1.4.0",
17
17
  "@types/express": "^5.0.6",
18
18
  "@types/lodash": "^4.17.17",
@@ -53,5 +53,5 @@
53
53
  "test:coverage": "bun run ../scripts/check-coverage.ts"
54
54
  },
55
55
  "types": "dist/index.d.ts",
56
- "version": "57.8.0"
56
+ "version": "57.9.0"
57
57
  }
@@ -123,10 +123,15 @@ export class FeatureFlagsApp implements TerrenoPlugin {
123
123
  }
124
124
 
125
125
  const targetingKey = String(user._id ?? user.id);
126
- const flags = await FeatureFlag.find({archived: {$ne: true}, enabled: true});
126
+ const flags = await FeatureFlag.find({archived: {$ne: true}});
127
127
  const config: Record<string, FlagDefinition> = {};
128
128
 
129
129
  for (const flag of flags) {
130
+ // Disabled boolean flags are sent as `off` so clients can tell a turned-off
131
+ // flag from one that was never created. Disabled variant flags stay omitted.
132
+ if (!flag.enabled && flag.type !== "boolean") {
133
+ continue;
134
+ }
130
135
  config[flag.key] = buildFlagDefinition(flag, targetingKey, user, this.segments);
131
136
  }
132
137
 
@@ -230,7 +230,7 @@ describe("FeatureFlagsApp", () => {
230
230
  await unauth.get("/feature-flags/flagConfiguration").expect(401);
231
231
  });
232
232
 
233
- it("returns OpenFeature-shaped entries for enabled flags and omits disabled and archived", async () => {
233
+ it("returns OpenFeature-shaped entries and resolves disabled boolean flags to off", async () => {
234
234
  await FeatureFlag.create({
235
235
  enabled: true,
236
236
  key: "bool-active",
@@ -281,7 +281,11 @@ describe("FeatureFlagsApp", () => {
281
281
  expect(data.profile?.disabled).toBe(false);
282
282
  expect(["compact", "detailed"].includes(data.profile?.defaultVariant ?? "")).toBe(true);
283
283
  expect(data.profile?.variants.compact).toBe("compact");
284
- expect(data["disabled-one"]).toBeUndefined();
284
+ expect(data["disabled-one"]).toEqual({
285
+ defaultVariant: "off",
286
+ disabled: false,
287
+ variants: {off: false, on: true},
288
+ });
285
289
  expect(data["archived-one"]).toBeUndefined();
286
290
  });
287
291