@voltro/plugin-flags 0.84.0 → 0.86.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/CHANGELOG.md +1215 -0
- package/THIRD-PARTY-NOTICES.md +5 -89
- package/dist/{define-D9Eet7wA.js → define.js} +6 -6
- package/dist/errors.d.ts +4 -5
- package/dist/evaluate.js +81 -0
- package/dist/experimentLink.js +48 -0
- package/dist/index.d.ts +6 -7
- package/dist/index.js +143 -590
- package/dist/lifecycle.js +82 -0
- package/dist/rpc.d.ts +6 -6
- package/dist/rpc.js +2 -8
- package/dist/store.js +154 -0
- package/dist/usage.js +113 -0
- package/dist/web.js +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -1,584 +1,136 @@
|
|
|
1
1
|
import { BASE_NAME as e, evaluateDescriptor as t, evaluateVariantsDescriptor as n, flagsRpcClientImports as r } from "./rpc.js";
|
|
2
|
-
import { i,
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
active: !0,
|
|
25
|
-
rollout: n
|
|
26
|
-
};
|
|
27
|
-
if (t >= s || s <= o) return {
|
|
28
|
-
active: !0,
|
|
29
|
-
rollout: r
|
|
30
|
-
};
|
|
31
|
-
let c = (t - o) / (s - o);
|
|
32
|
-
return {
|
|
33
|
-
active: !0,
|
|
34
|
-
rollout: n + (r - n) * c
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
return { active: !0 };
|
|
38
|
-
}, j = (e, t, n, r = Date.now()) => {
|
|
39
|
-
let i = w(t);
|
|
40
|
-
if (i.enabled === !1) return !1;
|
|
41
|
-
let a;
|
|
42
|
-
if (i.schedule) {
|
|
43
|
-
let e = A(i.schedule, r);
|
|
44
|
-
if (!e.active) return !1;
|
|
45
|
-
a = e.rollout;
|
|
46
|
-
}
|
|
47
|
-
if (i.targeting && i.targeting.length > 0 && !i.targeting.some((e) => D(e, n))) return !1;
|
|
48
|
-
let o = a ?? i.rollout ?? 100;
|
|
49
|
-
if (o < 100 && o > 0) {
|
|
50
|
-
if (!(E(e, k(i, n)) < o)) return !1;
|
|
51
|
-
} else if (o <= 0) return !1;
|
|
52
|
-
return i.variants && i.variants.length > 0 && i.offVariant != null ? N(e, i, n).name !== i.offVariant : !0;
|
|
53
|
-
}, M = (e) => {
|
|
54
|
-
let t = e.reduce((e, t) => e + (t.weight ?? 1), 0) || e.length, n = 0;
|
|
55
|
-
return e.map((r, i) => (n += r.weight ?? 1, i === e.length - 1 ? 1e4 : Math.round(n / t * 1e4)));
|
|
56
|
-
}, N = (e, t, n) => {
|
|
57
|
-
let r = t.variants ?? [];
|
|
58
|
-
if (r.length === 0) throw Error(`flag "${e}" has no variants`);
|
|
59
|
-
let i = ee(e, k(t, n)), a = M(r);
|
|
60
|
-
for (let e = 0; e < r.length; e++) if (i < a[e]) return r[e];
|
|
61
|
-
return r[r.length - 1];
|
|
62
|
-
}, P = (e, t, n, r = Date.now()) => {
|
|
63
|
-
let i = w(t), a = j(e, t, n, r);
|
|
64
|
-
if (!i.variants || i.variants.length === 0) return {
|
|
65
|
-
name: a ? "on" : "off",
|
|
66
|
-
value: a,
|
|
67
|
-
enabled: a
|
|
68
|
-
};
|
|
69
|
-
let o = N(e, i, n);
|
|
70
|
-
return {
|
|
71
|
-
name: o.name,
|
|
72
|
-
value: o.value,
|
|
73
|
-
enabled: a
|
|
74
|
-
};
|
|
75
|
-
}, te = (e, t, n = Date.now()) => {
|
|
76
|
-
let r = {};
|
|
77
|
-
for (let [i, a] of Object.entries(e)) r[i] = j(i, a, t, n);
|
|
78
|
-
return r;
|
|
79
|
-
}, ne = (e, t, n = Date.now()) => {
|
|
80
|
-
let r = {};
|
|
81
|
-
for (let [i, a] of Object.entries(e)) r[i] = P(i, a, t, n);
|
|
82
|
-
return r;
|
|
83
|
-
}, F = "_voltro_feature_flag_audit", I = "_voltro_feature_flags", L = x(I, {
|
|
84
|
-
id: h({ prefix: "flag" }),
|
|
85
|
-
key: S().unique(),
|
|
86
|
-
enabled: f().default(!0),
|
|
87
|
-
rollout: g().nullable(),
|
|
88
|
-
rolloutBy: S().nullable(),
|
|
89
|
-
targeting: _().nullable(),
|
|
90
|
-
variants: _().nullable(),
|
|
91
|
-
offVariant: S().nullable(),
|
|
92
|
-
schedule: _().nullable(),
|
|
93
|
-
description: S().nullable(),
|
|
94
|
-
updatedAt: C().default("now").onUpdate("now")
|
|
95
|
-
}), R = x(F, {
|
|
96
|
-
id: h({ prefix: "flagaud" }),
|
|
97
|
-
flag: S(),
|
|
98
|
-
enabled: f(),
|
|
99
|
-
previousEnabled: f().nullable(),
|
|
100
|
-
actorId: S().nullable(),
|
|
101
|
-
at: C().default("now")
|
|
102
|
-
}).index("byFlagAuditFlag", ["flag"]).index("byFlagAuditAt", ["at"]), re = (e, t) => {
|
|
103
|
-
let n = { ...e };
|
|
104
|
-
for (let e of t) {
|
|
105
|
-
let t = {
|
|
106
|
-
enabled: e.enabled,
|
|
107
|
-
...e.rollout == null ? {} : { rollout: e.rollout },
|
|
108
|
-
...e.rolloutBy === "tenant" || e.rolloutBy === "subject" ? { rolloutBy: e.rolloutBy } : {},
|
|
109
|
-
...Array.isArray(e.targeting) ? { targeting: e.targeting } : {},
|
|
110
|
-
...Array.isArray(e.variants) ? { variants: e.variants } : {},
|
|
111
|
-
...e.offVariant == null ? {} : { offVariant: e.offVariant },
|
|
112
|
-
...e.schedule != null && typeof e.schedule == "object" ? { schedule: e.schedule } : {},
|
|
113
|
-
...e.description == null ? {} : { description: e.description }
|
|
114
|
-
};
|
|
115
|
-
n[e.key] = t;
|
|
116
|
-
}
|
|
117
|
-
return n;
|
|
118
|
-
}, z = new class {
|
|
119
|
-
flags = {};
|
|
120
|
-
set(e) {
|
|
121
|
-
this.flags = e;
|
|
122
|
-
}
|
|
123
|
-
all() {
|
|
124
|
-
return this.flags;
|
|
125
|
-
}
|
|
126
|
-
get(e) {
|
|
127
|
-
return this.flags[e];
|
|
128
|
-
}
|
|
129
|
-
}(), B = (e, t) => V(e, t) !== null, V = (e, t) => {
|
|
130
|
-
let n = z.get(e);
|
|
131
|
-
if (n === void 0) return null;
|
|
132
|
-
let r = w(n), i = r.enabled !== !1;
|
|
133
|
-
return z.set({
|
|
134
|
-
...z.all(),
|
|
135
|
-
[e]: {
|
|
136
|
-
...r,
|
|
137
|
-
enabled: t
|
|
138
|
-
}
|
|
139
|
-
}), i;
|
|
140
|
-
}, H = (e) => Object.entries(e).map(([e, t]) => {
|
|
141
|
-
let n = w(t);
|
|
142
|
-
return {
|
|
143
|
-
key: e,
|
|
144
|
-
enabled: n.enabled !== !1,
|
|
145
|
-
rollout: n.rollout ?? 100,
|
|
146
|
-
variants: n.variants && n.variants.length > 0 ? n.variants.map((e) => e.name) : void 0,
|
|
147
|
-
scheduled: n.schedule != null,
|
|
148
|
-
description: n.description
|
|
149
|
-
};
|
|
150
|
-
}), ie = (e, t) => {
|
|
151
|
-
let n = w(t);
|
|
152
|
-
return {
|
|
153
|
-
key: e,
|
|
154
|
-
enabled: n.enabled !== !1,
|
|
155
|
-
rollout: n.rollout ?? null,
|
|
156
|
-
rolloutBy: n.rolloutBy ?? null,
|
|
157
|
-
targeting: n.targeting ?? null,
|
|
158
|
-
variants: n.variants ?? null,
|
|
159
|
-
offVariant: n.offVariant ?? null,
|
|
160
|
-
schedule: n.schedule ?? null,
|
|
161
|
-
description: n.description ?? null
|
|
162
|
-
};
|
|
163
|
-
}, ae = (e) => ({
|
|
164
|
-
loadOverrides: async () => (await e.query(v(L).descriptor)).map((e) => ({
|
|
165
|
-
key: String(e.key),
|
|
166
|
-
enabled: e.enabled === !0 || e.enabled === 1,
|
|
167
|
-
rollout: e.rollout == null ? null : Number(e.rollout),
|
|
168
|
-
rolloutBy: e.rolloutBy ?? null,
|
|
169
|
-
targeting: e.targeting ?? null,
|
|
170
|
-
variants: e.variants ?? null,
|
|
171
|
-
offVariant: e.offVariant ?? null,
|
|
172
|
-
schedule: e.schedule ?? null,
|
|
173
|
-
description: e.description ?? null
|
|
174
|
-
})),
|
|
175
|
-
upsertOverride: async (t) => {
|
|
176
|
-
let n = U(t);
|
|
177
|
-
await e.upsert(I, n, { conflictColumns: ["key"] });
|
|
178
|
-
}
|
|
179
|
-
}), U = (e) => ({
|
|
180
|
-
id: p("flag", e.key),
|
|
181
|
-
key: e.key,
|
|
182
|
-
enabled: e.enabled,
|
|
183
|
-
rollout: e.rollout,
|
|
184
|
-
rolloutBy: e.rolloutBy,
|
|
185
|
-
targeting: e.targeting,
|
|
186
|
-
variants: e.variants,
|
|
187
|
-
offVariant: e.offVariant,
|
|
188
|
-
schedule: e.schedule,
|
|
189
|
-
description: e.description,
|
|
190
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
191
|
-
}), oe = (e) => ({
|
|
192
|
-
flag: String(e.flag),
|
|
193
|
-
enabled: e.enabled === !0 || e.enabled === 1,
|
|
194
|
-
previousEnabled: e.previousEnabled == null ? null : e.previousEnabled === !0 || e.previousEnabled === 1,
|
|
195
|
-
actorId: e.actorId ?? null,
|
|
196
|
-
at: e.at instanceof Date ? e.at : new Date(String(e.at))
|
|
197
|
-
}), se = (e) => ({
|
|
198
|
-
record: async (t) => {
|
|
199
|
-
await e.insert(F, {
|
|
200
|
-
id: `flagaud_${t.at.getTime()}_${Math.random().toString(36).slice(2, 10)}`,
|
|
201
|
-
flag: t.flag,
|
|
202
|
-
enabled: t.enabled,
|
|
203
|
-
previousEnabled: t.previousEnabled,
|
|
204
|
-
actorId: t.actorId,
|
|
205
|
-
at: t.at
|
|
206
|
-
});
|
|
207
|
-
},
|
|
208
|
-
list: async (t) => {
|
|
209
|
-
let n = v(R).orderBy("at", "desc");
|
|
210
|
-
return t?.flag != null && (n = n.where(m("flag", t.flag))), t?.limit != null && (n = n.limit(t.limit)), (await e.query(n.descriptor)).map(oe);
|
|
211
|
-
}
|
|
212
|
-
}), ce = async (e, t, n, r, i) => {
|
|
213
|
-
await e.transactional(async (e) => {
|
|
214
|
-
await e.insertIgnore(I, {
|
|
215
|
-
...U(ie(t, n)),
|
|
216
|
-
id: p("flag", crypto.randomUUID())
|
|
217
|
-
}, { conflictColumns: ["key"] });
|
|
218
|
-
let a = (await e.query(v(L).where(m("key", t)).forUpdate().descriptor))[0];
|
|
219
|
-
if (!a) throw Error("flag override disappeared during toggle");
|
|
220
|
-
await e.update(I, String(a.id), {
|
|
221
|
-
enabled: r,
|
|
222
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
223
|
-
}), await se(e).record({
|
|
224
|
-
flag: t,
|
|
225
|
-
enabled: r,
|
|
226
|
-
previousEnabled: a.enabled === !0 || a.enabled === 1,
|
|
227
|
-
actorId: i,
|
|
228
|
-
at: /* @__PURE__ */ new Date()
|
|
229
|
-
});
|
|
230
|
-
});
|
|
231
|
-
}, W = (e, t) => {
|
|
232
|
-
let n = new Map(t.map((e) => [e.name, e])), r = [];
|
|
233
|
-
for (let t of e) {
|
|
234
|
-
let e = t.experiment;
|
|
235
|
-
if (e === void 0) continue;
|
|
236
|
-
let i = n.get(e);
|
|
237
|
-
if (i === void 0) {
|
|
238
|
-
r.push({
|
|
239
|
-
flag: t.key,
|
|
240
|
-
experiment: e,
|
|
241
|
-
problem: `no experiment named ${JSON.stringify(e)} was passed to flagsPlugin({ experiments }). Pass the defineExperiment() definitions the app declares, or drop the \`experiment\` link.`
|
|
242
|
-
});
|
|
243
|
-
continue;
|
|
244
|
-
}
|
|
245
|
-
(i.variantFrom === void 0 || i.variantFrom === null) && r.push({
|
|
246
|
-
flag: t.key,
|
|
247
|
-
experiment: e,
|
|
248
|
-
problem: `the experiment assigns its own arms (\`subject\` mode), so it would measure a split this flag never served — the two bucketings are independent hashes. Persist the served arm (\`flagVariant(ctx, ${JSON.stringify(t.key)})\`) on the watched table and declare the experiment with \`variantFrom: <that column>\`.`
|
|
249
|
-
}), typeof i.holdout == "number" && i.holdout > 0 && r.push({
|
|
250
|
-
flag: t.key,
|
|
251
|
-
experiment: e,
|
|
252
|
-
problem: `holdout ${i.holdout} is carved at ASSIGNMENT, and this flag does the assigning — the experiment can never place a row there. Declare the holdout as a flag variant instead.`
|
|
253
|
-
});
|
|
254
|
-
let a = new Set(t.variants.map((e) => e.name)), o = new Set(i.variants.map((e) => e.name));
|
|
255
|
-
if (a.size === 0) r.push({
|
|
256
|
-
flag: t.key,
|
|
257
|
-
experiment: e,
|
|
258
|
-
problem: "the flag declares no variants, so it serves one value to everyone and there is nothing to compare."
|
|
259
|
-
});
|
|
260
|
-
else {
|
|
261
|
-
let n = [...a].filter((e) => !o.has(e)), i = [...o].filter((e) => !a.has(e));
|
|
262
|
-
(n.length > 0 || i.length > 0) && r.push({
|
|
263
|
-
flag: t.key,
|
|
264
|
-
experiment: e,
|
|
265
|
-
problem: `the arms disagree — ${n.length > 0 ? `served by the flag but not declared by the experiment: ${n.join(", ")}` : ""}${n.length > 0 && i.length > 0 ? "; " : ""}${i.length > 0 ? `declared by the experiment but never served: ${i.join(", ")}` : ""}. A row assigned to an arm the experiment does not declare is EXCLUDED, so the mismatch shows up as an empty arm rather than an error.`
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
return r;
|
|
270
|
-
}, le = (e, t) => {
|
|
271
|
-
let n = W(e, t);
|
|
272
|
-
if (n.length === 0) return;
|
|
273
|
-
let r = n.map((e) => ` · flag "${e.flag}" → experiment "${e.experiment}": ${e.problem}`);
|
|
274
|
-
throw Error(`@voltro/plugin-flags: ${n.length} flag→experiment link problem(s):\n${r.join("\n")}`);
|
|
275
|
-
}, ue = 864e5, G = (e) => typeof e == "number" ? e : Date.parse(e), K = (e, t) => {
|
|
276
|
-
let n = w(e);
|
|
277
|
-
if (n.enabled === !1) return {
|
|
278
|
-
shape: "constantOff",
|
|
279
|
-
reason: "enabled: false — resolves false for every caller"
|
|
280
|
-
};
|
|
281
|
-
if (n.schedule) {
|
|
282
|
-
let { activateAt: e, deactivateAt: r } = n.schedule;
|
|
283
|
-
if (r != null && t >= G(r)) return {
|
|
284
|
-
shape: "expired",
|
|
285
|
-
reason: `schedule.deactivateAt (${String(r)}) has passed — the flag can never be on again`
|
|
286
|
-
};
|
|
287
|
-
if (e != null && t < G(e)) return {
|
|
288
|
-
shape: "notYetActive",
|
|
289
|
-
reason: `schedule.activateAt (${String(e)}) is in the future — pending, not dead`
|
|
290
|
-
};
|
|
291
|
-
}
|
|
292
|
-
let r = n.rollout ?? 100;
|
|
293
|
-
if (r <= 0) return {
|
|
294
|
-
shape: "constantOff",
|
|
295
|
-
reason: `rollout: ${r} — nobody is in the rollout`
|
|
296
|
-
};
|
|
297
|
-
let i = (n.targeting?.length ?? 0) > 0, a = (n.variants?.length ?? 0) > 1, o = n.schedule !== void 0 && (n.schedule.ramp !== void 0 || n.schedule.deactivateAt != null && t < G(n.schedule.deactivateAt));
|
|
298
|
-
return r >= 100 && !i && !a && !o ? {
|
|
299
|
-
shape: "constantOn",
|
|
300
|
-
reason: "rollout 100 with no targeting, no variants and no live schedule — resolves true for every caller"
|
|
301
|
-
} : {
|
|
302
|
-
shape: "conditional",
|
|
303
|
-
reason: `still selects between callers (${[
|
|
304
|
-
r < 100 ? `rollout ${r}%` : void 0,
|
|
305
|
-
i ? `${n.targeting?.length} targeting rule(s)` : void 0,
|
|
306
|
-
a ? `${n.variants?.length} variants` : void 0,
|
|
307
|
-
o ? "a live schedule" : void 0
|
|
308
|
-
].filter((e) => e !== void 0).join(", ")})`
|
|
309
|
-
};
|
|
310
|
-
}, de = [
|
|
311
|
-
"Reachability is not decided. \"Not evaluated since <date>\" is a measurement; \"this code path is dead\" is not decidable in general. A seasonal flag, a flag behind a route nobody visited this month, and a flag whose last call site was deleted are indistinguishable from here.",
|
|
312
|
-
"Only SERVER-side reads are counted as use: isFlagEnabled / requireFlag / flagValue and a gatedBy interception. A flag consulted only in the browser via useFlag() / useFlagValue() reads from the bulk set the server already sent, so it never reaches this report as a named read.",
|
|
313
|
-
"A \"bulk\" observation means the flag was INCLUDED in a flags.evaluate / flags.variants response. It does not mean any client read that key — one useFlags() poll evaluates the whole registry.",
|
|
314
|
-
"The window is bounded by retention (see coverage.retentionDays). Nothing older is evidence: a flag last read BEFORE the window has no observation at all and reads \"neverObserved\", which is exactly what a flag declared this morning reads.",
|
|
315
|
-
"\"neverObserved\" is not a removal candidate. A flag declared yesterday and a flag abandoned last year produce the identical row; only a flag that WAS observed and then stopped (\"stale\") is proven unused."
|
|
316
|
-
], fe = (e) => {
|
|
317
|
-
let t = e.now ?? Date.now(), n = e.staleAfterDays, r = t - n * ue, i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), o;
|
|
318
|
-
for (let t of e.usage) {
|
|
319
|
-
let e = t.lastAt.getTime();
|
|
320
|
-
if (!Number.isFinite(e)) continue;
|
|
321
|
-
(o === void 0 || e < o) && (o = e);
|
|
322
|
-
let n = t.source === "bulk" ? a : i, r = n.get(t.flag);
|
|
323
|
-
(r === void 0 || e > r) && n.set(t.flag, e);
|
|
324
|
-
}
|
|
325
|
-
let s = o === void 0 ? 0 : Math.floor((t - o) / ue);
|
|
326
|
-
return {
|
|
327
|
-
coverage: {
|
|
328
|
-
tracking: e.tracking,
|
|
329
|
-
observedSince: o === void 0 ? null : new Date(o).toISOString().slice(0, 10),
|
|
330
|
-
observedDays: s,
|
|
331
|
-
retentionDays: e.retentionDays,
|
|
332
|
-
staleAfterDays: n
|
|
333
|
-
},
|
|
334
|
-
findings: Object.entries(e.flags).map(([o, c]) => {
|
|
335
|
-
let { shape: l, reason: u } = K(c, t), d = i.get(o), f = a.get(o), p = [u], m;
|
|
336
|
-
e.tracking ? d !== void 0 && d >= r ? (m = "evaluated", p.push(`last server-side read ${new Date(d).toISOString()}`)) : d === void 0 ? (m = "neverObserved", p.push(s > 0 ? `no server-side read in the ${s}-day observation window` : "no server-side read observed yet (the observation window is empty)"), f !== void 0 && p.push("the flag WAS delivered to a client in a bulk flags.evaluate response — which does not prove it was read")) : (m = "stale", p.push(`last server-side read ${new Date(d).toISOString()}, more than ${n} day(s) ago, over an observation window of ${s} day(s)`)) : (m = "untracked", p.push("evaluation tracking is off — no usage evidence exists for this deployment"));
|
|
337
|
-
let h = l === "constantOn" || l === "constantOff" || l === "expired";
|
|
338
|
-
return h && p.push("the definition alone makes this flag a constant — it selects nothing"), {
|
|
339
|
-
key: o,
|
|
340
|
-
shape: l,
|
|
341
|
-
shapeReason: u,
|
|
342
|
-
usage: m,
|
|
343
|
-
lastTargetedAt: d === void 0 ? null : new Date(d).toISOString(),
|
|
344
|
-
lastBulkAt: f === void 0 ? null : new Date(f).toISOString(),
|
|
345
|
-
liveTargetedEvaluations: e.liveCounts?.get(o) ?? 0,
|
|
346
|
-
removalCandidate: h || m === "stale",
|
|
347
|
-
why: p
|
|
348
|
-
};
|
|
349
|
-
}),
|
|
350
|
-
limits: de
|
|
351
|
-
};
|
|
352
|
-
}, q = "_voltro_feature_flag_usage", J = x(q, {
|
|
353
|
-
id: h({ prefix: "flagusg" }),
|
|
354
|
-
flag: S(),
|
|
355
|
-
day: S(),
|
|
356
|
-
source: S(),
|
|
357
|
-
lastAt: C()
|
|
358
|
-
}).unique([
|
|
359
|
-
"flag",
|
|
360
|
-
"day",
|
|
361
|
-
"source"
|
|
362
|
-
]).index("byFlagUsageLastAt", ["lastAt"]).index("byFlagUsageFlag", ["flag"]), pe = (e) => e.toISOString().slice(0, 10), me = (e) => {
|
|
363
|
-
let t = 2166136261;
|
|
364
|
-
for (let n = 0; n < e.length; n++) t ^= e.charCodeAt(n), t = Math.imul(t, 16777619);
|
|
365
|
-
return (t >>> 0).toString(16).padStart(8, "0");
|
|
366
|
-
}, he = (e, t, n) => `flagusg_${t.replace(/-/g, "")}_${n === "targeted" ? "t" : "b"}_${me(e)}`, Y = new class {
|
|
367
|
-
on = !1;
|
|
368
|
-
pending = /* @__PURE__ */ new Map();
|
|
369
|
-
liveCounts = /* @__PURE__ */ new Map();
|
|
370
|
-
enable() {
|
|
371
|
-
this.on = !0;
|
|
372
|
-
}
|
|
373
|
-
disable() {
|
|
374
|
-
this.on = !1, this.pending.clear();
|
|
375
|
-
}
|
|
376
|
-
get enabled() {
|
|
377
|
-
return this.on;
|
|
378
|
-
}
|
|
379
|
-
record(e, t, n = Date.now()) {
|
|
380
|
-
if (!this.on) return;
|
|
381
|
-
let r = `${t}\u0000${e}`, i = this.pending.get(r);
|
|
382
|
-
i ? i.lastAt = n : this.pending.set(r, {
|
|
383
|
-
flag: e,
|
|
384
|
-
source: t,
|
|
385
|
-
lastAt: n
|
|
386
|
-
}), t === "targeted" && this.liveCounts.set(e, (this.liveCounts.get(e) ?? 0) + 1);
|
|
387
|
-
}
|
|
388
|
-
drain() {
|
|
389
|
-
let e = [...this.pending.values()];
|
|
390
|
-
return this.pending.clear(), e;
|
|
391
|
-
}
|
|
392
|
-
restore(e) {
|
|
393
|
-
if (this.on) for (let t of e) {
|
|
394
|
-
let e = `${t.source}\u0000${t.flag}`, n = this.pending.get(e);
|
|
395
|
-
(!n || n.lastAt < t.lastAt) && this.pending.set(e, { ...t });
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
liveTargetedCounts() {
|
|
399
|
-
return this.liveCounts;
|
|
400
|
-
}
|
|
401
|
-
reset() {
|
|
402
|
-
this.on = !1, this.pending.clear(), this.liveCounts.clear();
|
|
403
|
-
}
|
|
404
|
-
}(), X = (e, t, n) => Y.record(e, t, n), ge = (e) => e === "bulk" ? "bulk" : "targeted", _e = (e) => ({
|
|
405
|
-
upsertMany: async (t) => {
|
|
406
|
-
for (let n of t) {
|
|
407
|
-
let t = pe(n.lastAt);
|
|
408
|
-
await e.upsert(q, {
|
|
409
|
-
id: he(n.flag, t, n.source),
|
|
410
|
-
flag: n.flag,
|
|
411
|
-
day: t,
|
|
412
|
-
source: n.source,
|
|
413
|
-
lastAt: n.lastAt
|
|
414
|
-
}, { conflictColumns: [
|
|
415
|
-
"flag",
|
|
416
|
-
"day",
|
|
417
|
-
"source"
|
|
418
|
-
] });
|
|
419
|
-
}
|
|
420
|
-
},
|
|
421
|
-
load: async () => (await e.query(v(J).descriptor)).map((e) => ({
|
|
422
|
-
flag: String(e.flag),
|
|
423
|
-
day: String(e.day),
|
|
424
|
-
source: ge(e.source),
|
|
425
|
-
lastAt: e.lastAt instanceof Date ? e.lastAt : new Date(String(e.lastAt))
|
|
426
|
-
}))
|
|
427
|
-
}), ve = 3e5, ye = (e) => {
|
|
428
|
-
let t = e.intervalMs ?? 3e5, n = !1, r = async () => {
|
|
429
|
-
let t = Y.drain();
|
|
430
|
-
if (t.length !== 0) try {
|
|
431
|
-
await e.store.upsertMany(t.map((e) => ({
|
|
432
|
-
flag: e.flag,
|
|
433
|
-
source: e.source,
|
|
434
|
-
lastAt: new Date(e.lastAt)
|
|
435
|
-
})));
|
|
436
|
-
} catch (n) {
|
|
437
|
-
Y.restore(t), e.log?.warn?.("flag usage flush failed — observations retained for the next pass", {
|
|
438
|
-
pending: t.length,
|
|
439
|
-
cause: n.message
|
|
440
|
-
});
|
|
441
|
-
}
|
|
442
|
-
}, i = setInterval(() => {
|
|
443
|
-
r();
|
|
444
|
-
}, t);
|
|
445
|
-
return typeof i.unref == "function" && i.unref(), {
|
|
446
|
-
flushNow: r,
|
|
447
|
-
stop: async () => {
|
|
448
|
-
n || (n = !0, clearInterval(i), await r());
|
|
449
|
-
}
|
|
450
|
-
};
|
|
451
|
-
}, be = (e = process.env, t = 90) => {
|
|
452
|
-
let n = b(e.VOLTRO_FLAG_USAGE_TTL_HOURS, 24 * t);
|
|
453
|
-
return y({
|
|
454
|
-
table: q,
|
|
455
|
-
timeColumn: "lastAt",
|
|
456
|
-
source: "plugin",
|
|
457
|
-
ttlMs: n,
|
|
458
|
-
envVar: "VOLTRO_FLAG_USAGE_TTL_HOURS"
|
|
459
|
-
}), n;
|
|
460
|
-
}, Z = (e) => "request" in e && e.request?.subject || "subject" in e && e.subject || {}, Q = (e, t) => {
|
|
461
|
-
let n = z.get(t);
|
|
462
|
-
return X(t, "targeted"), n !== void 0 && j(t, n, Z(e));
|
|
463
|
-
}, xe = (e, t) => Q(e, t) ? l.void : l.fail(new c({ flag: t })), Se = (e, t) => {
|
|
464
|
-
let n = z.get(t.key);
|
|
465
|
-
return X(t.key, "targeted"), n === void 0 ? t.defaultValue : i(t, P(t.key, n, Z(e)));
|
|
466
|
-
}, Ce = (e, t) => {
|
|
467
|
-
let n = z.get(t.key);
|
|
468
|
-
return X(t.key, "targeted"), n === void 0 ? null : P(t.key, n, Z(e)).name;
|
|
469
|
-
}, we = (e, t) => e === t || e.startsWith("/") && e.endsWith("/") && new RegExp(e.slice(1, -1)).test(t), $ = e, Te = (e = {}) => {
|
|
470
|
-
let i = e.gatedBy ?? {}, o = d({
|
|
471
|
-
base: $,
|
|
2
|
+
import { evaluateAll as i, evaluateAllVariants as a, evaluateFlag as o, evaluateSchedule as s, evaluateVariant as c, resolveVariant as l, toDefinition as u } from "./evaluate.js";
|
|
3
|
+
import { dataStoreFlagAuditStore as ee, dataStoreFlagStore as d, describeFlags as f, featureFlagsTable as p, flagAuditTable as m, flipFlagEnabled as h, mergeOverrides as g, persistFlagToggle as te, registry as _, setFlagEnabled as v } from "./store.js";
|
|
4
|
+
import { defineFlag as y, gateOverride as b, isTypedFlag as x, typedValueOf as S } from "./define.js";
|
|
5
|
+
import { assertFlagExperimentLinks as C, checkFlagExperimentLinks as w } from "./experimentLink.js";
|
|
6
|
+
import { FLAG_LIFECYCLE_LIMITS as T, classifyShape as E, flagLifecycleReport as D } from "./lifecycle.js";
|
|
7
|
+
import { DEFAULT_FLAG_USAGE_FLUSH_MS as O, FLAG_USAGE_TABLE as k, dataStoreFlagUsageStore as A, flagUsageBuffer as j, flagUsageRowId as M, flagUsageTable as N, recordFlagEvaluation as P, registerFlagUsageRetention as F, startFlagUsageFlush as I, utcDay as L } from "./usage.js";
|
|
8
|
+
import { FlagDisabled as R } from "./errors.js";
|
|
9
|
+
import { Effect as z, Result as B } from "effect";
|
|
10
|
+
import { definePlugin as ne, pluginInstanceName as re } from "@voltro/protocol";
|
|
11
|
+
//#region src/index.ts
|
|
12
|
+
var V = (e) => "request" in e && e.request?.subject || "subject" in e && e.subject || {}, H = (e, t) => {
|
|
13
|
+
let n = _.get(t);
|
|
14
|
+
return P(t, "targeted"), n !== void 0 && o(t, n, V(e));
|
|
15
|
+
}, U = (e, t) => H(e, t) ? z.void : z.fail(new R({ flag: t })), W = (e, t) => {
|
|
16
|
+
let n = _.get(t.key);
|
|
17
|
+
return P(t.key, "targeted"), n === void 0 ? t.defaultValue : S(t, c(t.key, n, V(e)));
|
|
18
|
+
}, G = (e, t) => {
|
|
19
|
+
let n = _.get(t.key);
|
|
20
|
+
return P(t.key, "targeted"), n === void 0 ? null : c(t.key, n, V(e)).name;
|
|
21
|
+
}, ie = (e, t) => e === t || e.startsWith("/") && e.endsWith("/") && new RegExp(e.slice(1, -1)).test(t), K = e, q = (e = {}) => {
|
|
22
|
+
let o = e.gatedBy ?? {}, s = re({
|
|
23
|
+
base: K,
|
|
472
24
|
alias: e.alias,
|
|
473
25
|
instance: e.name
|
|
474
|
-
}),
|
|
475
|
-
for (let t of
|
|
476
|
-
if (
|
|
477
|
-
if (e.flags?.[t.key] !== void 0) throw Error(`${
|
|
478
|
-
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
let
|
|
482
|
-
for (let e of
|
|
483
|
-
let
|
|
484
|
-
if (
|
|
485
|
-
let
|
|
486
|
-
if (
|
|
487
|
-
let
|
|
488
|
-
let t =
|
|
489
|
-
for (let [e, r] of
|
|
26
|
+
}), c = e.typedFlags ?? [], l = /* @__PURE__ */ new Map();
|
|
27
|
+
for (let t of c) {
|
|
28
|
+
if (l.has(t.key)) throw Error(`${K}: two typedFlags declare the key ${JSON.stringify(t.key)}`);
|
|
29
|
+
if (e.flags?.[t.key] !== void 0) throw Error(`${K}: ${JSON.stringify(t.key)} is declared BOTH in \`flags\` and in \`typedFlags\`. One key, one declaration — the typed one would otherwise be silently overwritten by the untyped baseline.`);
|
|
30
|
+
l.set(t.key, t);
|
|
31
|
+
}
|
|
32
|
+
c.some((e) => e.experiment !== void 0) && C(c, e.experiments ?? []);
|
|
33
|
+
let u = { ...e.flags ?? {} };
|
|
34
|
+
for (let e of c) u[e.key] = e.definition;
|
|
35
|
+
let v = e.store === "postgres", y, x, S, w, T, E, O, k = [], M = e.usage ?? {}, L = M.track ?? v;
|
|
36
|
+
if (L && !v) throw Error(`${K}: usage.track requires store: 'postgres' — there is nowhere to record an evaluation on the memory tier, and a dead-flag report that silently observed nothing is exactly the defect it exists to find.`);
|
|
37
|
+
let V = M.staleAfterDays ?? 30, U = M.retentionDays ?? 90;
|
|
38
|
+
if (V > U) throw Error(`${K}: usage.staleAfterDays (${V}) exceeds usage.retentionDays (${U}), so the observation window can never be long enough to prove a flag stale and every verdict would be withheld.`);
|
|
39
|
+
let W = (e) => {
|
|
40
|
+
let t = g(u, e), n = [];
|
|
41
|
+
for (let [e, r] of l) {
|
|
490
42
|
let i = t[e];
|
|
491
43
|
if (i === void 0) continue;
|
|
492
|
-
let
|
|
493
|
-
|
|
44
|
+
let a = b(r, typeof i == "boolean" ? { enabled: i } : i);
|
|
45
|
+
a.ok || (n.push(a.refusal), t[e] = r.definition);
|
|
494
46
|
}
|
|
495
|
-
|
|
496
|
-
},
|
|
497
|
-
if (!
|
|
498
|
-
let e = ++
|
|
499
|
-
e ===
|
|
500
|
-
},
|
|
501
|
-
if (
|
|
502
|
-
if (await
|
|
503
|
-
|
|
504
|
-
let e =
|
|
505
|
-
|
|
506
|
-
store:
|
|
507
|
-
intervalMs:
|
|
47
|
+
k = n, _.set(t);
|
|
48
|
+
}, G = 0, q = async () => {
|
|
49
|
+
if (!x) return;
|
|
50
|
+
let e = ++G, t = await x.loadOverrides();
|
|
51
|
+
e === G && W(t);
|
|
52
|
+
}, J = async () => {
|
|
53
|
+
if (E && x) {
|
|
54
|
+
if (await q(), L && w && !T) {
|
|
55
|
+
O = F(process.env, U), j.enable();
|
|
56
|
+
let e = E.logger;
|
|
57
|
+
T = I({
|
|
58
|
+
store: w,
|
|
59
|
+
intervalMs: M.flushIntervalMs ?? 3e5,
|
|
508
60
|
log: { warn: (t, n) => e.warn(t, n) }
|
|
509
61
|
});
|
|
510
62
|
}
|
|
511
|
-
for (let e of
|
|
63
|
+
for (let e of k) E.logger.warn("feature flag override REFUSED — code-declared definition stands", {
|
|
512
64
|
flag: e.key,
|
|
513
65
|
reason: e.reason
|
|
514
66
|
});
|
|
515
67
|
}
|
|
516
|
-
},
|
|
517
|
-
if (
|
|
518
|
-
for (let [t, n] of Object.entries(
|
|
519
|
-
},
|
|
520
|
-
let n =
|
|
521
|
-
return n === void 0 ||
|
|
522
|
-
},
|
|
523
|
-
for (let t of e)
|
|
524
|
-
},
|
|
68
|
+
}, ae = (e) => {
|
|
69
|
+
if (o[e] !== void 0) return o[e];
|
|
70
|
+
for (let [t, n] of Object.entries(o)) if (t !== e && ie(t, e)) return n;
|
|
71
|
+
}, Y = (e, t) => {
|
|
72
|
+
let n = ae(t.tag);
|
|
73
|
+
return n === void 0 || H({ subject: t.subject }, n) ? e : z.fail(new R({ flag: n }));
|
|
74
|
+
}, X = Object.keys(o).length > 0, Z = (e) => {
|
|
75
|
+
for (let t of e) P(t, "bulk");
|
|
76
|
+
}, oe = {
|
|
525
77
|
...t,
|
|
526
78
|
description: "Resolve every feature flag for the calling subject.",
|
|
527
|
-
execute: (e, t) =>
|
|
528
|
-
let e =
|
|
529
|
-
return
|
|
79
|
+
execute: (e, t) => z.sync(() => {
|
|
80
|
+
let e = _.all();
|
|
81
|
+
return Z(Object.keys(e)), i(e, t.request.subject ?? {});
|
|
530
82
|
})
|
|
531
|
-
},
|
|
83
|
+
}, se = {
|
|
532
84
|
...n,
|
|
533
85
|
description: "Resolve every feature flag to its served variant for the calling subject.",
|
|
534
|
-
execute: (e, t) =>
|
|
535
|
-
let e =
|
|
536
|
-
return
|
|
86
|
+
execute: (e, t) => z.sync(() => {
|
|
87
|
+
let e = _.all();
|
|
88
|
+
return Z(Object.keys(e)), a(e, t.request.subject ?? {});
|
|
537
89
|
})
|
|
538
|
-
},
|
|
90
|
+
}, Q = (e) => ({
|
|
539
91
|
kind: "json",
|
|
540
92
|
data: e
|
|
541
|
-
}),
|
|
93
|
+
}), $ = (e, t) => ({
|
|
542
94
|
kind: "json",
|
|
543
95
|
status: e,
|
|
544
96
|
data: { error: t }
|
|
545
|
-
}),
|
|
97
|
+
}), ce = async () => {
|
|
546
98
|
let e = [];
|
|
547
|
-
if (
|
|
548
|
-
e = await
|
|
99
|
+
if (L && w) try {
|
|
100
|
+
e = await w.load();
|
|
549
101
|
} catch {
|
|
550
102
|
e = [];
|
|
551
103
|
}
|
|
552
|
-
return
|
|
553
|
-
flags:
|
|
104
|
+
return D({
|
|
105
|
+
flags: _.all(),
|
|
554
106
|
usage: e,
|
|
555
|
-
tracking:
|
|
556
|
-
liveCounts:
|
|
557
|
-
staleAfterDays:
|
|
558
|
-
retentionDays:
|
|
107
|
+
tracking: L,
|
|
108
|
+
liveCounts: j.liveTargetedCounts(),
|
|
109
|
+
staleAfterDays: V,
|
|
110
|
+
retentionDays: U
|
|
559
111
|
});
|
|
560
|
-
},
|
|
112
|
+
}, le = () => {
|
|
561
113
|
let e = {};
|
|
562
|
-
for (let [t, n] of
|
|
114
|
+
for (let [t, n] of l) e[t] = {
|
|
563
115
|
valueType: n.valueType,
|
|
564
116
|
variants: n.variants.map((e) => e.name),
|
|
565
117
|
experiment: n.experiment ?? null
|
|
566
118
|
};
|
|
567
119
|
return e;
|
|
568
|
-
},
|
|
120
|
+
}, ue = [
|
|
569
121
|
{
|
|
570
122
|
method: "GET",
|
|
571
123
|
path: "/list",
|
|
572
124
|
scope: "process",
|
|
573
125
|
description: "Every resolved flag (key, enabled, rollout, description) plus the dead-flag lifecycle report: per-flag shape + usage verdict, the observation coverage window, and the limits of what the report can prove.",
|
|
574
|
-
handler: () =>
|
|
575
|
-
let e = await
|
|
576
|
-
return
|
|
577
|
-
flags:
|
|
578
|
-
writeScope:
|
|
126
|
+
handler: () => z.promise(async () => {
|
|
127
|
+
let e = await ce();
|
|
128
|
+
return Q({
|
|
129
|
+
flags: f(_.all()),
|
|
130
|
+
writeScope: v ? "shared-store" : "process",
|
|
579
131
|
lifecycle: e,
|
|
580
|
-
typed:
|
|
581
|
-
overrideRefusals:
|
|
132
|
+
typed: le(),
|
|
133
|
+
overrideRefusals: k
|
|
582
134
|
});
|
|
583
135
|
})
|
|
584
136
|
},
|
|
@@ -586,44 +138,45 @@ var w = (e) => typeof e == "boolean" ? { enabled: e } : e, T = (e, t) => {
|
|
|
586
138
|
method: "POST",
|
|
587
139
|
path: "/toggle",
|
|
588
140
|
description: "Flip a flag's kill-switch on/off (live registry; durable on the postgres tier). Logs an audit row.",
|
|
589
|
-
handler: (e) =>
|
|
141
|
+
handler: (e) => z.gen(function* () {
|
|
590
142
|
let t;
|
|
591
143
|
try {
|
|
592
144
|
t = JSON.parse(e.body || "{}");
|
|
593
145
|
} catch {
|
|
594
|
-
return
|
|
146
|
+
return $(400, "invalid JSON body");
|
|
595
147
|
}
|
|
596
|
-
if (!t || typeof t.key != "string" || !t.key || typeof t.enabled != "boolean") return
|
|
597
|
-
let n = t.key, r = t.enabled, i =
|
|
598
|
-
if (i === void 0) return
|
|
599
|
-
if (
|
|
600
|
-
let e =
|
|
601
|
-
if (!e) return
|
|
602
|
-
|
|
603
|
-
await
|
|
604
|
-
}).pipe(
|
|
605
|
-
|
|
606
|
-
|
|
148
|
+
if (!t || typeof t.key != "string" || !t.key || typeof t.enabled != "boolean") return $(400, "key (string) + enabled (boolean) required");
|
|
149
|
+
let n = t.key, r = t.enabled, i = _.get(n);
|
|
150
|
+
if (i === void 0) return $(404, `unknown flag "${n}"`);
|
|
151
|
+
if (v) {
|
|
152
|
+
let e = y;
|
|
153
|
+
if (!e) return $(503, "flag store is not ready");
|
|
154
|
+
let a = yield* z.tryPromise(async () => {
|
|
155
|
+
await te(e, n, i, r, typeof t.actor == "string" ? t.actor : null), await q();
|
|
156
|
+
}).pipe(z.result);
|
|
157
|
+
if (B.isFailure(a)) return yield* z.tryPromise(q).pipe(z.ignore), $(503, "flag update could not be confirmed; reload the flag state before retrying");
|
|
158
|
+
} else h(n, r);
|
|
159
|
+
return Q({
|
|
607
160
|
ok: !0,
|
|
608
|
-
flags:
|
|
161
|
+
flags: f(_.all())
|
|
609
162
|
});
|
|
610
163
|
})
|
|
611
164
|
},
|
|
612
165
|
{
|
|
613
166
|
method: "GET",
|
|
614
167
|
path: "/audit",
|
|
615
|
-
scope:
|
|
168
|
+
scope: v ? "shared-store" : "declaration",
|
|
616
169
|
description: "The kill-switch flip audit trail, newest-first. `?flag=<key>` filters; `?limit=<n>` caps (postgres tier only).",
|
|
617
|
-
handler: (e) =>
|
|
618
|
-
if (!
|
|
170
|
+
handler: (e) => z.gen(function* () {
|
|
171
|
+
if (!S) return Q({
|
|
619
172
|
audit: [],
|
|
620
173
|
note: "audit trail requires store: \"postgres\""
|
|
621
174
|
});
|
|
622
|
-
let t = new URL(e.url, "http://local"), n = t.searchParams.get("flag"), r = t.searchParams.get("limit"), i = r != null && Number.isFinite(Number(r)) ? Number(r) : 100, a = yield*
|
|
175
|
+
let t = new URL(e.url, "http://local"), n = t.searchParams.get("flag"), r = t.searchParams.get("limit"), i = r != null && Number.isFinite(Number(r)) ? Number(r) : 100, a = yield* z.promise(() => S.list({
|
|
623
176
|
...n == null ? {} : { flag: n },
|
|
624
177
|
limit: i
|
|
625
178
|
}));
|
|
626
|
-
return
|
|
179
|
+
return Q({ audit: a.map((e) => ({
|
|
627
180
|
flag: e.flag,
|
|
628
181
|
enabled: e.enabled,
|
|
629
182
|
previousEnabled: e.previousEnabled,
|
|
@@ -632,60 +185,60 @@ var w = (e) => typeof e == "boolean" ? { enabled: e } : e, T = (e, t) => {
|
|
|
632
185
|
})) });
|
|
633
186
|
})
|
|
634
187
|
}
|
|
635
|
-
],
|
|
636
|
-
...
|
|
188
|
+
], de = [
|
|
189
|
+
...X ? [
|
|
637
190
|
"rpc:intercept:mutation",
|
|
638
191
|
"rpc:intercept:query",
|
|
639
192
|
"rpc:intercept:action",
|
|
640
193
|
"rpc:intercept:workflow"
|
|
641
194
|
] : [],
|
|
642
|
-
...
|
|
195
|
+
...v ? ["store:write", "store:changes:read"] : [],
|
|
643
196
|
"inspect:read",
|
|
644
197
|
"inspect:write"
|
|
645
198
|
];
|
|
646
|
-
return
|
|
647
|
-
name:
|
|
648
|
-
baseName:
|
|
199
|
+
return ne({
|
|
200
|
+
name: s,
|
|
201
|
+
baseName: K,
|
|
649
202
|
description: "Feature flags — targeting, % rollout, kill-switch, declarative gating + client evaluation.",
|
|
650
|
-
permissions:
|
|
651
|
-
routes: [
|
|
203
|
+
permissions: de,
|
|
204
|
+
routes: [oe, se],
|
|
652
205
|
rpcClientDescriptors: r,
|
|
653
|
-
inspectEndpoints:
|
|
206
|
+
inspectEndpoints: ue,
|
|
654
207
|
errorSchemas: [{
|
|
655
|
-
schema:
|
|
208
|
+
schema: R,
|
|
656
209
|
import: {
|
|
657
210
|
module: "@voltro/plugin-flags/errors",
|
|
658
211
|
name: "FlagDisabled"
|
|
659
212
|
}
|
|
660
213
|
}],
|
|
661
|
-
...
|
|
662
|
-
interceptMutation:
|
|
663
|
-
interceptQuery:
|
|
664
|
-
interceptAction:
|
|
665
|
-
interceptWorkflow:
|
|
214
|
+
...X ? {
|
|
215
|
+
interceptMutation: Y,
|
|
216
|
+
interceptQuery: Y,
|
|
217
|
+
interceptAction: Y,
|
|
218
|
+
interceptWorkflow: Y
|
|
666
219
|
} : {},
|
|
667
|
-
...
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
] : [
|
|
672
|
-
...
|
|
673
|
-
|
|
220
|
+
...v ? { extendSchema: { tables: L ? [
|
|
221
|
+
p,
|
|
222
|
+
m,
|
|
223
|
+
N
|
|
224
|
+
] : [p, m] } } : {},
|
|
225
|
+
...v ? { bindDataStore: async (e) => {
|
|
226
|
+
y = e, x = d(y), S = ee(e), L && (w = A(e)), await J();
|
|
674
227
|
} } : {},
|
|
675
|
-
...
|
|
676
|
-
onActivate: (t) =>
|
|
677
|
-
|
|
678
|
-
count: Object.keys(
|
|
679
|
-
typed:
|
|
680
|
-
gated: Object.keys(
|
|
228
|
+
...v ? { onChangeEvent: (e) => e.table === "_voltro_feature_flags" ? z.tryPromise(() => q()) : z.void } : {},
|
|
229
|
+
onActivate: (t) => z.gen(function* () {
|
|
230
|
+
_.set(u), E = t, x && (yield* z.promise(J)), t.logger.info("feature flags active", {
|
|
231
|
+
count: Object.keys(u).length,
|
|
232
|
+
typed: l.size,
|
|
233
|
+
gated: Object.keys(o).length,
|
|
681
234
|
store: e.store ?? "memory",
|
|
682
|
-
usage:
|
|
235
|
+
usage: L ? T ? `tracking (stale after ${V}d, observations kept ${Math.round((O ?? 0) / 864e5)}d)` : "waiting for store binding" : "off — no dead-flag evidence is collected"
|
|
683
236
|
});
|
|
684
237
|
}),
|
|
685
|
-
onDeactivate: () =>
|
|
686
|
-
|
|
238
|
+
onDeactivate: () => z.promise(async () => {
|
|
239
|
+
E = void 0, await T?.stop(), T = void 0, j.disable(), _.set({});
|
|
687
240
|
})
|
|
688
241
|
});
|
|
689
242
|
};
|
|
690
243
|
//#endregion
|
|
691
|
-
export {
|
|
244
|
+
export { O as DEFAULT_FLAG_USAGE_FLUSH_MS, T as FLAG_LIFECYCLE_LIMITS, k as FLAG_USAGE_TABLE, R as FlagDisabled, C as assertFlagExperimentLinks, w as checkFlagExperimentLinks, E as classifyShape, A as dataStoreFlagUsageStore, y as defineFlag, f as describeFlags, i as evaluateAll, a as evaluateAllVariants, o as evaluateFlag, s as evaluateSchedule, c as evaluateVariant, p as featureFlagsTable, m as flagAuditTable, D as flagLifecycleReport, _ as flagRegistry, j as flagUsageBuffer, M as flagUsageRowId, N as flagUsageTable, W as flagValue, G as flagVariant, q as flagsPlugin, h as flipFlagEnabled, b as gateOverride, H as isFlagEnabled, x as isTypedFlag, g as mergeOverrides, P as recordFlagEvaluation, F as registerFlagUsageRetention, U as requireFlag, l as resolveVariant, v as setFlagEnabled, I as startFlagUsageFlush, u as toDefinition, S as typedValueOf, L as utcDay };
|