@vllnt/convex-flags 0.1.0-canary.bf53746 → 0.1.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 +84 -25
- package/dist/client/index.d.ts +62 -16
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +54 -15
- package/dist/client/index.js.map +1 -1
- package/dist/client/types.d.ts +30 -4
- package/dist/client/types.d.ts.map +1 -1
- package/dist/component/_generated/api.d.ts +19 -1
- package/dist/component/_generated/api.d.ts.map +1 -1
- package/dist/component/_generated/api.js +16 -0
- package/dist/component/_generated/api.js.map +1 -1
- package/dist/component/_generated/component.d.ts +174 -24
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/_generated/server.d.ts +12 -0
- package/dist/component/_generated/server.d.ts.map +1 -1
- package/dist/component/_generated/server.js +2 -0
- package/dist/component/_generated/server.js.map +1 -1
- package/dist/component/convex.config.d.ts.map +1 -1
- package/dist/component/mutations.d.ts +90 -5
- package/dist/component/mutations.d.ts.map +1 -1
- package/dist/component/mutations.js +144 -10
- package/dist/component/mutations.js.map +1 -1
- package/dist/component/queries.d.ts +90 -13
- package/dist/component/queries.d.ts.map +1 -1
- package/dist/component/queries.js +58 -12
- package/dist/component/queries.js.map +1 -1
- package/dist/component/schema.d.ts +138 -4
- package/dist/component/schema.d.ts.map +1 -1
- package/dist/component/schema.js +7 -1
- package/dist/component/schema.js.map +1 -1
- package/dist/component/validators.d.ts +354 -14
- package/dist/component/validators.d.ts.map +1 -1
- package/dist/component/validators.js +57 -6
- package/dist/component/validators.js.map +1 -1
- package/dist/react/index.d.ts +29 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +35 -0
- package/dist/react/index.js.map +1 -0
- package/dist/shared.d.ts +102 -4
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +126 -3
- package/dist/shared.js.map +1 -1
- package/package.json +36 -18
- package/src/client/index.ts +145 -20
- package/src/client/types.ts +48 -4
- package/src/component/_generated/api.ts +19 -1
- package/src/component/_generated/component.ts +259 -23
- package/src/component/_generated/server.ts +13 -0
- package/src/component/mutations.ts +160 -19
- package/src/component/queries.ts +74 -12
- package/src/component/schema.ts +7 -1
- package/src/component/validators.ts +87 -6
- package/src/react/index.test.ts +52 -0
- package/src/react/index.ts +69 -0
- package/src/shared.ts +235 -4
- package/src/status-backward-compat.test.ts +51 -0
package/README.md
CHANGED
|
@@ -6,24 +6,25 @@
|
|
|
6
6
|
|
|
7
7
|
# @vllnt/convex-flags
|
|
8
8
|
|
|
9
|
-
Feature flags as a Convex component —
|
|
9
|
+
Feature flags as a Convex component — backend-evaluated and streamed to every connected client in real time: boolean kill-switches, multivariate variants, percentage rollouts, attribute targeting, and per-subject overrides, with no redeploy and no third-party flag SaaS.
|
|
10
10
|
|
|
11
11
|
```ts
|
|
12
12
|
const flags = new Flags(components.flags);
|
|
13
|
+
await flags.define(ctx, { key: "new-checkout", value: false });
|
|
13
14
|
await flags.enable(ctx, "new-checkout");
|
|
14
|
-
const
|
|
15
|
+
const on = await flags.isEnabled(ctx, "new-checkout", { subjectRef: userId }); // reactive in a query
|
|
15
16
|
```
|
|
16
17
|
|
|
17
18
|
## Features
|
|
18
19
|
|
|
19
|
-
- **Boolean
|
|
20
|
-
- **
|
|
21
|
-
- **
|
|
22
|
-
- **
|
|
23
|
-
- **
|
|
24
|
-
- **
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
- **Boolean, multivariate & rollouts** — boolean kill-switches, string/number variants, and weighted percentage rollouts with stable per-subject bucketing.
|
|
21
|
+
- **Attribute targeting** — ordered rules (`eq`, `in`, `contains`, `gt`, …) over a host-supplied typed context.
|
|
22
|
+
- **Per-subject overrides** — force any flag's value for one subject.
|
|
23
|
+
- **Lifecycle** — archive (reversible) distinct from permanent delete.
|
|
24
|
+
- **Real-time** — evaluated in Convex queries, so changes stream to clients over the same reactive subscriptions as your app data.
|
|
25
|
+
- **Data isolation** — definitions and overrides live in the component's own sandboxed tables; no blast radius into your schema.
|
|
26
|
+
- **Reactive React hooks** — optional `./react` entry (`useFlag`/`useFlags`); backend-only consumers pull in zero React.
|
|
27
|
+
- **Auth-agnostic & dual-target** — the host gates every management call; runs unchanged on Convex Cloud and self-hosted `convex-backend`.
|
|
27
28
|
|
|
28
29
|
## Installation
|
|
29
30
|
|
|
@@ -42,16 +43,44 @@ app.use(flags);
|
|
|
42
43
|
export default app;
|
|
43
44
|
```
|
|
44
45
|
|
|
45
|
-
Peer dependency: `convex@^1.
|
|
46
|
+
Peer dependency: `convex@^1.36.1`. `react` is an optional peer dependency, needed only for the `./react` entry.
|
|
46
47
|
|
|
47
48
|
## Usage
|
|
48
49
|
|
|
49
50
|
```ts
|
|
50
|
-
// convex/flags.ts — instantiate once
|
|
51
|
+
// convex/flags.ts — instantiate once, then re-export the public function refs the
|
|
52
|
+
// rest of your app (and the React hooks) call. The host owns auth: gate the
|
|
53
|
+
// management mutations here before delegating to the component.
|
|
54
|
+
import { v } from "convex/values";
|
|
51
55
|
import { Flags } from "@vllnt/convex-flags";
|
|
52
56
|
import { components } from "./_generated/api";
|
|
57
|
+
import { mutation, query } from "./_generated/server";
|
|
53
58
|
|
|
54
59
|
export const flags = new Flags(components.flags);
|
|
60
|
+
|
|
61
|
+
// Evaluation queries — reactive; `api.flags.evaluate` is what the React hooks below use.
|
|
62
|
+
export const evaluate = query({
|
|
63
|
+
args: { key: v.string(), context: v.optional(v.any()), default: v.optional(v.any()) },
|
|
64
|
+
handler: (ctx, args) =>
|
|
65
|
+
flags.evaluate(ctx, args.key, { context: args.context, default: args.default }),
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
export const all = query({
|
|
69
|
+
args: { context: v.optional(v.any()) },
|
|
70
|
+
handler: (ctx, args) => flags.all(ctx, args.context),
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// Management mutations — apply your own auth check before delegating.
|
|
74
|
+
export const define = mutation({
|
|
75
|
+
args: { key: v.string(), value: v.any() /* + description/variants/rules/rollout */ },
|
|
76
|
+
handler: (ctx, args) => {
|
|
77
|
+
// assertAdmin(ctx);
|
|
78
|
+
return flags.define(ctx, args);
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// Wrap the rest the same way — `update`, `enable`, `disable`, `archive`,
|
|
83
|
+
// `restore`, `setOverride`, `clearOverride` — each gated then delegated.
|
|
55
84
|
```
|
|
56
85
|
|
|
57
86
|
```ts
|
|
@@ -60,15 +89,20 @@ export const flags = new Flags(components.flags);
|
|
|
60
89
|
import { query } from "./_generated/server";
|
|
61
90
|
import { flags } from "./flags";
|
|
62
91
|
|
|
92
|
+
// A targeted rollout: pro users get the new checkout; everyone else is a 50/50 split.
|
|
63
93
|
export const setup = async (ctx) => {
|
|
64
|
-
await flags.define(ctx, {
|
|
65
|
-
|
|
94
|
+
await flags.define(ctx, {
|
|
95
|
+
key: "new-checkout",
|
|
96
|
+
value: false,
|
|
97
|
+
rules: [{ conditions: [{ attribute: "plan", op: "eq", values: ["pro"] }], value: true }],
|
|
98
|
+
rollout: { splits: [{ value: true, weight: 50 }, { value: false, weight: 50 }] },
|
|
99
|
+
});
|
|
66
100
|
};
|
|
67
101
|
|
|
68
102
|
export const checkout = query({
|
|
69
103
|
args: {},
|
|
70
104
|
handler: async (ctx) =>
|
|
71
|
-
(await flags.isEnabled(ctx, "new-checkout"))
|
|
105
|
+
(await flags.isEnabled(ctx, "new-checkout", { subjectRef: "user-123", attributes: { plan: "free" } }))
|
|
72
106
|
? loadNewCheckout(ctx)
|
|
73
107
|
: loadLegacyCheckout(ctx),
|
|
74
108
|
});
|
|
@@ -78,16 +112,41 @@ export const checkout = query({
|
|
|
78
112
|
|
|
79
113
|
| Method | Kind | Result |
|
|
80
114
|
|--------|------|--------|
|
|
81
|
-
| `isEnabled(ctx, key)` | query | `boolean` (
|
|
82
|
-
| `evaluate(ctx, key)` | query | `FlagEvaluation` (`value` + `reason`) |
|
|
83
|
-
| `
|
|
84
|
-
| `list(ctx)` | query | `FlagDoc[]` |
|
|
85
|
-
| `all(ctx)` | query | `Record<string, FlagEvaluation>` (reactive bootstrap) |
|
|
86
|
-
| `define(ctx, definition)` | mutation | Create or
|
|
87
|
-
| `
|
|
88
|
-
| `
|
|
89
|
-
|
|
90
|
-
|
|
115
|
+
| `isEnabled(ctx, key, context?)` | query | `boolean` (value `=== true`) |
|
|
116
|
+
| `evaluate(ctx, key, options?)` | query | `FlagEvaluation` (`value` + `reason`) |
|
|
117
|
+
| `variant(ctx, key, options?)` | query | the resolved value |
|
|
118
|
+
| `get(ctx, key)` / `list(ctx)` | query | `FlagDoc \| null` / `FlagDoc[]` |
|
|
119
|
+
| `all(ctx, context?)` | query | `Record<string, FlagEvaluation>` (reactive bootstrap) |
|
|
120
|
+
| `define(ctx, definition)` | mutation | Create or **fully replace** a flag (value, variants, rules, rollout) |
|
|
121
|
+
| `update(ctx, key, patch)` | mutation | **Partially** update a flag — only supplied fields change, the rest are kept |
|
|
122
|
+
| `enable(ctx, key)` / `disable(ctx, key)` | mutation | Toggle a boolean flag (sets value `true`/`false`) |
|
|
123
|
+
| `archive(ctx, key)` / `restore(ctx, key)` | mutation | Reversibly retire / re-activate a flag |
|
|
124
|
+
| `setOverride(ctx, key, subjectRef, value)` / `clearOverride(ctx, key, subjectRef)` | mutation | Force / clear a per-subject value |
|
|
125
|
+
| `remove(ctx, key)` | mutation | Hard-delete a flag and its overrides |
|
|
126
|
+
|
|
127
|
+
`evaluate` resolves in order: override → archived → targeting rules → fallthrough rollout → flag
|
|
128
|
+
value; an unknown key serves the caller `default` or `false`. `enable`/`disable` are boolean
|
|
129
|
+
convenience (they set the value to `true`/`false`) — use `define`/`update` for multivariate flags.
|
|
130
|
+
Full reference, types, operators, and the React hooks: [docs/API.md](docs/API.md).
|
|
131
|
+
|
|
132
|
+
## React
|
|
133
|
+
|
|
134
|
+
Optional reactive hooks via the `./react` entry (`react` is an optional peer dependency). Pass the
|
|
135
|
+
`evaluate` query you exported from `convex/flags.ts` above — `api.flags.evaluate`:
|
|
136
|
+
|
|
137
|
+
```tsx
|
|
138
|
+
import { useFlag } from "@vllnt/convex-flags/react";
|
|
139
|
+
import { api } from "../convex/_generated/api";
|
|
140
|
+
|
|
141
|
+
// api.flags.evaluate is the query exported in convex/flags.ts (Usage, above).
|
|
142
|
+
const checkout = useFlag(api.flags.evaluate, "new-checkout", { context: { subjectRef: userId } });
|
|
143
|
+
if (checkout?.value === true) { /* render the new checkout */ }
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
| Hook | Returns |
|
|
147
|
+
|------|---------|
|
|
148
|
+
| `useFlag(query, key, options?)` | `FlagEvaluation \| undefined` |
|
|
149
|
+
| `useFlags(query, context?)` | `Record<string, FlagEvaluation> \| undefined` |
|
|
91
150
|
|
|
92
151
|
## Security
|
|
93
152
|
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FunctionArgs, FunctionReference, FunctionReturnType } from "convex/server";
|
|
2
|
-
import type { FlagDefinition, FlagDoc, FlagEvaluation } from "./types.js";
|
|
2
|
+
import type { EvalContext, EvalOptions, FlagDefinition, FlagDoc, FlagEvaluation, FlagUpdate, Rollout, Rule, Variant, VariantValue } from "./types.js";
|
|
3
3
|
/**
|
|
4
4
|
* The component's function references, as exposed on the host via
|
|
5
5
|
* `components.flags`.
|
|
@@ -8,9 +8,20 @@ export interface FlagsComponent {
|
|
|
8
8
|
mutations: {
|
|
9
9
|
define: FunctionReference<"mutation", "internal", {
|
|
10
10
|
key: string;
|
|
11
|
-
value:
|
|
11
|
+
value: VariantValue;
|
|
12
12
|
description?: string;
|
|
13
|
+
variants?: Variant[];
|
|
14
|
+
rules?: Rule[];
|
|
15
|
+
rollout?: Rollout;
|
|
13
16
|
}, string>;
|
|
17
|
+
update: FunctionReference<"mutation", "internal", {
|
|
18
|
+
key: string;
|
|
19
|
+
value?: VariantValue;
|
|
20
|
+
description?: string;
|
|
21
|
+
variants?: Variant[];
|
|
22
|
+
rules?: Rule[];
|
|
23
|
+
rollout?: Rollout;
|
|
24
|
+
}, null>;
|
|
14
25
|
enable: FunctionReference<"mutation", "internal", {
|
|
15
26
|
key: string;
|
|
16
27
|
}, null>;
|
|
@@ -20,6 +31,21 @@ export interface FlagsComponent {
|
|
|
20
31
|
remove: FunctionReference<"mutation", "internal", {
|
|
21
32
|
key: string;
|
|
22
33
|
}, null>;
|
|
34
|
+
archive: FunctionReference<"mutation", "internal", {
|
|
35
|
+
key: string;
|
|
36
|
+
}, null>;
|
|
37
|
+
restore: FunctionReference<"mutation", "internal", {
|
|
38
|
+
key: string;
|
|
39
|
+
}, null>;
|
|
40
|
+
setOverride: FunctionReference<"mutation", "internal", {
|
|
41
|
+
key: string;
|
|
42
|
+
subjectRef: string;
|
|
43
|
+
value: VariantValue;
|
|
44
|
+
}, null>;
|
|
45
|
+
clearOverride: FunctionReference<"mutation", "internal", {
|
|
46
|
+
key: string;
|
|
47
|
+
subjectRef: string;
|
|
48
|
+
}, null>;
|
|
23
49
|
};
|
|
24
50
|
queries: {
|
|
25
51
|
get: FunctionReference<"query", "internal", {
|
|
@@ -28,8 +54,12 @@ export interface FlagsComponent {
|
|
|
28
54
|
list: FunctionReference<"query", "internal", Record<string, never>, FlagDoc[]>;
|
|
29
55
|
evaluate: FunctionReference<"query", "internal", {
|
|
30
56
|
key: string;
|
|
57
|
+
context?: EvalContext;
|
|
58
|
+
default?: VariantValue;
|
|
31
59
|
}, FlagEvaluation>;
|
|
32
|
-
all: FunctionReference<"query", "internal",
|
|
60
|
+
all: FunctionReference<"query", "internal", {
|
|
61
|
+
context?: EvalContext;
|
|
62
|
+
}, Record<string, FlagEvaluation>>;
|
|
33
63
|
};
|
|
34
64
|
}
|
|
35
65
|
interface RunQueryCtx {
|
|
@@ -41,36 +71,52 @@ interface RunMutationCtx {
|
|
|
41
71
|
/**
|
|
42
72
|
* Consumer-facing client for `@vllnt/convex-flags`. Construct with the mounted
|
|
43
73
|
* component ref, then call from host queries/mutations/actions. The host owns
|
|
44
|
-
* auth: gate the management methods (`define`, `enable`, `disable`,
|
|
45
|
-
*
|
|
74
|
+
* auth: gate the management methods (`define`, `update`, `enable`, `disable`,
|
|
75
|
+
* `archive`, `restore`, `remove`, `setOverride`, `clearOverride`) behind your
|
|
76
|
+
* own authorized mutations.
|
|
46
77
|
*
|
|
47
78
|
* @example
|
|
48
79
|
* ```ts
|
|
49
80
|
* const flags = new Flags(components.flags);
|
|
50
|
-
* if (await flags.isEnabled(ctx, "new-checkout")) { ... }
|
|
81
|
+
* if (await flags.isEnabled(ctx, "new-checkout", { subjectRef: userId })) { ... }
|
|
51
82
|
* ```
|
|
52
83
|
*/
|
|
53
84
|
export declare class Flags {
|
|
54
85
|
private readonly component;
|
|
55
86
|
constructor(component: FlagsComponent);
|
|
56
|
-
/** Create a flag, or
|
|
87
|
+
/** Create a flag, or replace its definition if the key already exists. */
|
|
57
88
|
define(ctx: RunMutationCtx, definition: FlagDefinition): Promise<string>;
|
|
58
|
-
/**
|
|
89
|
+
/**
|
|
90
|
+
* Partially update a flag: only the supplied fields change, the rest are left
|
|
91
|
+
* untouched (unlike `define`, which fully replaces). Throws `FLAG_NOT_FOUND`.
|
|
92
|
+
*/
|
|
93
|
+
update(ctx: RunMutationCtx, key: string, patch: FlagUpdate): Promise<null>;
|
|
94
|
+
/** Turn a boolean flag on. Throws `FLAG_NOT_FOUND` if the key is undefined. */
|
|
59
95
|
enable(ctx: RunMutationCtx, key: string): Promise<null>;
|
|
60
|
-
/** Turn a flag off. Throws `FLAG_NOT_FOUND` if the key is undefined. */
|
|
96
|
+
/** Turn a boolean flag off. Throws `FLAG_NOT_FOUND` if the key is undefined. */
|
|
61
97
|
disable(ctx: RunMutationCtx, key: string): Promise<null>;
|
|
62
|
-
/**
|
|
98
|
+
/** Archive a flag (reversible). Throws `FLAG_NOT_FOUND` if the key is undefined. */
|
|
99
|
+
archive(ctx: RunMutationCtx, key: string): Promise<null>;
|
|
100
|
+
/** Restore an archived flag. Throws `FLAG_NOT_FOUND` if the key is undefined. */
|
|
101
|
+
restore(ctx: RunMutationCtx, key: string): Promise<null>;
|
|
102
|
+
/** Permanently delete a flag and its overrides. Throws `FLAG_NOT_FOUND`. */
|
|
63
103
|
remove(ctx: RunMutationCtx, key: string): Promise<null>;
|
|
104
|
+
/** Force a flag's value for one subject. Throws `FLAG_NOT_FOUND`. */
|
|
105
|
+
setOverride(ctx: RunMutationCtx, key: string, subjectRef: string, value: VariantValue): Promise<null>;
|
|
106
|
+
/** Clear a subject's override for a flag. No-op if none exists. */
|
|
107
|
+
clearOverride(ctx: RunMutationCtx, key: string, subjectRef: string): Promise<null>;
|
|
64
108
|
/** Fetch a single flag definition, or `null` if undefined. */
|
|
65
109
|
get(ctx: RunQueryCtx, key: string): Promise<FlagDoc | null>;
|
|
66
110
|
/** List every flag definition. */
|
|
67
111
|
list(ctx: RunQueryCtx): Promise<FlagDoc[]>;
|
|
68
112
|
/** Evaluate a flag, returning its value and the reason it was served. */
|
|
69
|
-
evaluate(ctx: RunQueryCtx, key: string): Promise<FlagEvaluation>;
|
|
70
|
-
/** Evaluate a flag and return just its
|
|
71
|
-
|
|
72
|
-
/** Evaluate
|
|
73
|
-
|
|
113
|
+
evaluate(ctx: RunQueryCtx, key: string, options?: EvalOptions): Promise<FlagEvaluation>;
|
|
114
|
+
/** Evaluate a flag and return just its value. */
|
|
115
|
+
variant(ctx: RunQueryCtx, key: string, options?: EvalOptions): Promise<VariantValue>;
|
|
116
|
+
/** Evaluate a boolean flag and return whether it is on (value `=== true`). */
|
|
117
|
+
isEnabled(ctx: RunQueryCtx, key: string, context?: EvalContext): Promise<boolean>;
|
|
118
|
+
/** Evaluate every flag against optional context — the reactive bootstrap. */
|
|
119
|
+
all(ctx: RunQueryCtx, context?: EvalContext): Promise<Record<string, FlagEvaluation>>;
|
|
74
120
|
}
|
|
75
|
-
export type { FlagDefinition, FlagDoc, FlagEvaluation };
|
|
121
|
+
export type { EvalContext, EvalOptions, FlagDefinition, FlagDoc, FlagEvaluation, FlagUpdate, Rollout, Rule, Variant, VariantValue, };
|
|
76
122
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,cAAc,EACd,OAAO,EACP,cAAc,EACd,UAAU,EACV,OAAO,EACP,IAAI,EACJ,OAAO,EACP,YAAY,EACb,MAAM,YAAY,CAAC;AAEpB;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE;QACT,MAAM,EAAE,iBAAiB,CACvB,UAAU,EACV,UAAU,EACV;YACE,GAAG,EAAE,MAAM,CAAC;YACZ,KAAK,EAAE,YAAY,CAAC;YACpB,WAAW,CAAC,EAAE,MAAM,CAAC;YACrB,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;YACrB,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;YACf,OAAO,CAAC,EAAE,OAAO,CAAC;SACnB,EACD,MAAM,CACP,CAAC;QACF,MAAM,EAAE,iBAAiB,CACvB,UAAU,EACV,UAAU,EACV;YACE,GAAG,EAAE,MAAM,CAAC;YACZ,KAAK,CAAC,EAAE,YAAY,CAAC;YACrB,WAAW,CAAC,EAAE,MAAM,CAAC;YACrB,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;YACrB,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;YACf,OAAO,CAAC,EAAE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AY,CAAC,CAEvB;IAED,8EAA8E;IACxE,SAAS,CACb,GAAG,EAAE,WAAW,EAChB,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,OAAO,CAAC,CAElB;IAED,6EAA6E;IAC7E,GAAG,CACD,GAAG,EAAE,WAAW,EAChB,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAEzC;CACF;AAED,YAAY,EACV,WAAW,EACX,WAAW,EACX,cAAc,EACd,OAAO,EACP,cAAc,EACd,UAAU,EACV,OAAO,EACP,IAAI,EACJ,OAAO,EACP,YAAY,GACb,CAAC"}
|
package/dist/client/index.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Consumer-facing client for `@vllnt/convex-flags`. Construct with the mounted
|
|
3
3
|
* component ref, then call from host queries/mutations/actions. The host owns
|
|
4
|
-
* auth: gate the management methods (`define`, `enable`, `disable`,
|
|
5
|
-
*
|
|
4
|
+
* auth: gate the management methods (`define`, `update`, `enable`, `disable`,
|
|
5
|
+
* `archive`, `restore`, `remove`, `setOverride`, `clearOverride`) behind your
|
|
6
|
+
* own authorized mutations.
|
|
6
7
|
*
|
|
7
8
|
* @example
|
|
8
9
|
* ```ts
|
|
9
10
|
* const flags = new Flags(components.flags);
|
|
10
|
-
* if (await flags.isEnabled(ctx, "new-checkout")) { ... }
|
|
11
|
+
* if (await flags.isEnabled(ctx, "new-checkout", { subjectRef: userId })) { ... }
|
|
11
12
|
* ```
|
|
12
13
|
*/
|
|
13
14
|
export class Flags {
|
|
@@ -15,22 +16,52 @@ export class Flags {
|
|
|
15
16
|
constructor(component) {
|
|
16
17
|
this.component = component;
|
|
17
18
|
}
|
|
18
|
-
/** Create a flag, or
|
|
19
|
+
/** Create a flag, or replace its definition if the key already exists. */
|
|
19
20
|
define(ctx, definition) {
|
|
20
21
|
return ctx.runMutation(this.component.mutations.define, definition);
|
|
21
22
|
}
|
|
22
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* Partially update a flag: only the supplied fields change, the rest are left
|
|
25
|
+
* untouched (unlike `define`, which fully replaces). Throws `FLAG_NOT_FOUND`.
|
|
26
|
+
*/
|
|
27
|
+
update(ctx, key, patch) {
|
|
28
|
+
return ctx.runMutation(this.component.mutations.update, { key, ...patch });
|
|
29
|
+
}
|
|
30
|
+
/** Turn a boolean flag on. Throws `FLAG_NOT_FOUND` if the key is undefined. */
|
|
23
31
|
enable(ctx, key) {
|
|
24
32
|
return ctx.runMutation(this.component.mutations.enable, { key });
|
|
25
33
|
}
|
|
26
|
-
/** Turn a flag off. Throws `FLAG_NOT_FOUND` if the key is undefined. */
|
|
34
|
+
/** Turn a boolean flag off. Throws `FLAG_NOT_FOUND` if the key is undefined. */
|
|
27
35
|
disable(ctx, key) {
|
|
28
36
|
return ctx.runMutation(this.component.mutations.disable, { key });
|
|
29
37
|
}
|
|
30
|
-
/**
|
|
38
|
+
/** Archive a flag (reversible). Throws `FLAG_NOT_FOUND` if the key is undefined. */
|
|
39
|
+
archive(ctx, key) {
|
|
40
|
+
return ctx.runMutation(this.component.mutations.archive, { key });
|
|
41
|
+
}
|
|
42
|
+
/** Restore an archived flag. Throws `FLAG_NOT_FOUND` if the key is undefined. */
|
|
43
|
+
restore(ctx, key) {
|
|
44
|
+
return ctx.runMutation(this.component.mutations.restore, { key });
|
|
45
|
+
}
|
|
46
|
+
/** Permanently delete a flag and its overrides. Throws `FLAG_NOT_FOUND`. */
|
|
31
47
|
remove(ctx, key) {
|
|
32
48
|
return ctx.runMutation(this.component.mutations.remove, { key });
|
|
33
49
|
}
|
|
50
|
+
/** Force a flag's value for one subject. Throws `FLAG_NOT_FOUND`. */
|
|
51
|
+
setOverride(ctx, key, subjectRef, value) {
|
|
52
|
+
return ctx.runMutation(this.component.mutations.setOverride, {
|
|
53
|
+
key,
|
|
54
|
+
subjectRef,
|
|
55
|
+
value,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/** Clear a subject's override for a flag. No-op if none exists. */
|
|
59
|
+
clearOverride(ctx, key, subjectRef) {
|
|
60
|
+
return ctx.runMutation(this.component.mutations.clearOverride, {
|
|
61
|
+
key,
|
|
62
|
+
subjectRef,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
34
65
|
/** Fetch a single flag definition, or `null` if undefined. */
|
|
35
66
|
get(ctx, key) {
|
|
36
67
|
return ctx.runQuery(this.component.queries.get, { key });
|
|
@@ -40,16 +71,24 @@ export class Flags {
|
|
|
40
71
|
return ctx.runQuery(this.component.queries.list, {});
|
|
41
72
|
}
|
|
42
73
|
/** Evaluate a flag, returning its value and the reason it was served. */
|
|
43
|
-
evaluate(ctx, key) {
|
|
44
|
-
return ctx.runQuery(this.component.queries.evaluate, {
|
|
74
|
+
evaluate(ctx, key, options) {
|
|
75
|
+
return ctx.runQuery(this.component.queries.evaluate, {
|
|
76
|
+
key,
|
|
77
|
+
context: options?.context,
|
|
78
|
+
default: options?.default,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
/** Evaluate a flag and return just its value. */
|
|
82
|
+
async variant(ctx, key, options) {
|
|
83
|
+
return (await this.evaluate(ctx, key, options)).value;
|
|
45
84
|
}
|
|
46
|
-
/** Evaluate a flag and return
|
|
47
|
-
async isEnabled(ctx, key) {
|
|
48
|
-
return (await this.evaluate(ctx, key)).value;
|
|
85
|
+
/** Evaluate a boolean flag and return whether it is on (value `=== true`). */
|
|
86
|
+
async isEnabled(ctx, key, context) {
|
|
87
|
+
return (await this.evaluate(ctx, key, { context })).value === true;
|
|
49
88
|
}
|
|
50
|
-
/** Evaluate every flag
|
|
51
|
-
all(ctx) {
|
|
52
|
-
return ctx.runQuery(this.component.queries.all, {});
|
|
89
|
+
/** Evaluate every flag against optional context — the reactive bootstrap. */
|
|
90
|
+
all(ctx, context) {
|
|
91
|
+
return ctx.runQuery(this.component.queries.all, { context });
|
|
53
92
|
}
|
|
54
93
|
}
|
|
55
94
|
//# sourceMappingURL=index.js.map
|
package/dist/client/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAoGA;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,KAAK;IACa,SAAS;IAAtC,YAA6B,SAAyB;yBAAzB,SAAS;IAAmB,CAAC;IAE1D,0EAA0E;IAC1E,MAAM,CAAC,GAAmB,EAAE,UAA0B;QACpD,OAAO,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACtE,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,GAAmB,EAAE,GAAW,EAAE,KAAiB;QACxD,OAAO,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,GAAG,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC;IAC7E,CAAC;IAED,+EAA+E;IAC/E,MAAM,CAAC,GAAmB,EAAE,GAAW;QACrC,OAAO,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;IACnE,CAAC;IAED,gFAAgF;IAChF,OAAO,CAAC,GAAmB,EAAE,GAAW;QACtC,OAAO,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;IACpE,CAAC;IAED,oFAAoF;IACpF,OAAO,CAAC,GAAmB,EAAE,GAAW;QACtC,OAAO,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,GAAG,EAAE,CA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IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE;YACnD,GAAG;YACH,OAAO,EAAE,OAAO,EAAE,OAAO;YACzB,OAAO,EAAE,OAAO,EAAE,OAAO;SAC1B,CAAC,CAAC;IACL,CAAC;IAED,iDAAiD;IACjD,KAAK,CAAC,OAAO,CACX,GAAgB,EAChB,GAAW,EACX,OAAqB;QAErB,OAAO,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;IACxD,CAAC;IAED,8EAA8E;IAC9E,KAAK,CAAC,SAAS,CACb,GAAgB,EAChB,GAAW,EACX,OAAqB;QAErB,OAAO,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,IAAI,CAAC;IACrE,CAAC;IAED,6EAA6E;IAC7E,GAAG,CACD,GAAgB,EAChB,OAAqB;QAErB,OAAO,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IAC/D,CAAC;CACF"}
|
package/dist/client/types.d.ts
CHANGED
|
@@ -1,19 +1,45 @@
|
|
|
1
|
-
import type { EvalReason, FlagEvaluation } from "../shared.js";
|
|
1
|
+
import type { EvalContext, EvalReason, FlagEvaluation, Rollout, Rule, Variant, VariantValue } from "../shared.js";
|
|
2
2
|
/** A flag document as returned by the component queries. */
|
|
3
3
|
export interface FlagDoc {
|
|
4
4
|
_id: string;
|
|
5
5
|
_creationTime: number;
|
|
6
6
|
key: string;
|
|
7
7
|
description?: string;
|
|
8
|
-
value:
|
|
8
|
+
value: VariantValue;
|
|
9
|
+
variants?: Variant[];
|
|
10
|
+
rules?: Rule[];
|
|
11
|
+
rollout?: Rollout;
|
|
12
|
+
status: "active" | "archived";
|
|
9
13
|
createdAt: number;
|
|
10
14
|
updatedAt: number;
|
|
11
15
|
}
|
|
12
16
|
/** A flag definition passed to {@link Flags.define}. */
|
|
13
17
|
export interface FlagDefinition {
|
|
14
18
|
key: string;
|
|
15
|
-
value:
|
|
19
|
+
value: VariantValue;
|
|
16
20
|
description?: string;
|
|
21
|
+
variants?: Variant[];
|
|
22
|
+
rules?: Rule[];
|
|
23
|
+
rollout?: Rollout;
|
|
17
24
|
}
|
|
18
|
-
|
|
25
|
+
/**
|
|
26
|
+
* A partial patch passed to {@link Flags.update}. Only the supplied fields are
|
|
27
|
+
* changed; omitted fields are left untouched (unlike {@link FlagDefinition},
|
|
28
|
+
* which fully replaces the definition). The key is passed separately.
|
|
29
|
+
*/
|
|
30
|
+
export interface FlagUpdate {
|
|
31
|
+
value?: VariantValue;
|
|
32
|
+
description?: string;
|
|
33
|
+
variants?: Variant[];
|
|
34
|
+
rules?: Rule[];
|
|
35
|
+
rollout?: Rollout;
|
|
36
|
+
}
|
|
37
|
+
/** Options for {@link Flags.evaluate} / {@link Flags.variant}. */
|
|
38
|
+
export interface EvalOptions {
|
|
39
|
+
/** Host-supplied targeting/bucketing context. */
|
|
40
|
+
context?: EvalContext;
|
|
41
|
+
/** Value to serve when the key is unknown (reason `default`). */
|
|
42
|
+
default?: VariantValue;
|
|
43
|
+
}
|
|
44
|
+
export type { EvalContext, EvalReason, FlagEvaluation, Rollout, Rule, Variant, VariantValue, };
|
|
19
45
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/client/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/client/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,cAAc,EACd,OAAO,EACP,IAAI,EACJ,OAAO,EACP,YAAY,EACb,MAAM,cAAc,CAAC;AAEtB,4D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.js";
|
|
10
10
|
import type * as queries from "../queries.js";
|
|
11
|
+
import type * as validators from "../validators.js";
|
|
11
12
|
import type { ApiFromModules, FilterApi, FunctionReference } from "convex/server";
|
|
12
13
|
declare const fullApi: ApiFromModules<{
|
|
13
14
|
mutations: typeof mutations;
|
|
14
15
|
queries: typeof queries;
|
|
16
|
+
validators: typeof validators;
|
|
15
17
|
}>;
|
|
18
|
+
/**
|
|
19
|
+
* A utility for referencing Convex functions in your app's public API.
|
|
20
|
+
*
|
|
21
|
+
* Usage:
|
|
22
|
+
* ```js
|
|
23
|
+
* const myFunctionReference = api.myModule.myFunction;
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
16
26
|
export declare const api: FilterApi<typeof fullApi, FunctionReference<any, "public">>;
|
|
27
|
+
/**
|
|
28
|
+
* A utility for referencing Convex functions in your app's internal API.
|
|
29
|
+
*
|
|
30
|
+
* Usage:
|
|
31
|
+
* ```js
|
|
32
|
+
* const myFunctionReference = internal.myModule.myFunction;
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
17
35
|
export declare const internal: FilterApi<typeof fullApi, FunctionReference<any, "internal">>;
|
|
18
|
-
export declare const components:
|
|
36
|
+
export declare const components: {};
|
|
19
37
|
export {};
|
|
20
38
|
//# sourceMappingURL=api.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/component/_generated/api.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,OAAO,KAAK,KAAK,SAAS,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,KAAK,OAAO,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/component/_generated/api.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,OAAO,KAAK,KAAK,SAAS,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,KAAK,OAAO,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAEpD,OAAO,KAAK,EACV,cAAc,EACd,SAAS,EACT,iBAAiB,EAClB,MAAM,eAAe,CAAC;AAGvB,QAAA,MAAM,OAAO,EAAE,cAAc,CAAC;IAC5B,SAAS,EAAE,OAAO,SAAS,CAAC;IAC5B,OAAO,EAAE,OAAO,OAAO,CAAC;IACxB,UAAU,EAAE,OAAO,UAAU,CAAC;CAC/B,CAAiB,CAAC;AAEnB;;;;;;;GAOG;AACH,eAAO,MAAM,GAAG,EAAE,SAAS,CACzB,OAAO,OAAO,EACd,iBAAiB,CAAC,GAAG,EAAE,QAAQ,CAAC,CACjB,CAAC;AAElB;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,EAAE,SAAS,CAC9B,OAAO,OAAO,EACd,iBAAiB,CAAC,GAAG,EAAE,UAAU,CAAC,CACnB,CAAC;AAElB,eAAO,MAAM,UAAU,EAAqC,EAAE,CAAC"}
|
|
@@ -9,7 +9,23 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { anyApi, componentsGeneric } from "convex/server";
|
|
11
11
|
const fullApi = anyApi;
|
|
12
|
+
/**
|
|
13
|
+
* A utility for referencing Convex functions in your app's public API.
|
|
14
|
+
*
|
|
15
|
+
* Usage:
|
|
16
|
+
* ```js
|
|
17
|
+
* const myFunctionReference = api.myModule.myFunction;
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
12
20
|
export const api = anyApi;
|
|
21
|
+
/**
|
|
22
|
+
* A utility for referencing Convex functions in your app's internal API.
|
|
23
|
+
*
|
|
24
|
+
* Usage:
|
|
25
|
+
* ```js
|
|
26
|
+
* const myFunctionReference = internal.myModule.myFunction;
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
13
29
|
export const internal = anyApi;
|
|
14
30
|
export const components = componentsGeneric();
|
|
15
31
|
//# sourceMappingURL=api.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/component/_generated/api.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/component/_generated/api.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB;;;;;;;GAOG;AAWH,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAE1D,MAAM,OAAO,GAIR,MAAa,CAAC;AAEnB;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,GAAG,GAGZ,MAAa,CAAC;AAElB;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,QAAQ,GAGjB,MAAa,CAAC;AAElB,MAAM,CAAC,MAAM,UAAU,GAAG,iBAAiB,EAAmB,CAAC"}
|