@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
|
@@ -1,3 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A flag/variant value — typed primitives only (boolean, string, number). The
|
|
3
|
+
* client class is generic over the host's concrete value type; the component
|
|
4
|
+
* stores the typed union. No `v.any()`.
|
|
5
|
+
*/
|
|
6
|
+
export declare const variantValue: import("convex/values").VUnion<string | number | boolean, [import("convex/values").VBoolean<boolean, "required">, import("convex/values").VString<string, "required">, import("convex/values").VFloat64<number, "required">], "required", never>;
|
|
7
|
+
/** An attribute value usable in a targeting comparison. */
|
|
8
|
+
export declare const attributeValue: import("convex/values").VUnion<string | number | boolean, [import("convex/values").VBoolean<boolean, "required">, import("convex/values").VString<string, "required">, import("convex/values").VFloat64<number, "required">], "required", never>;
|
|
9
|
+
/** Comparison operators available to a targeting condition. */
|
|
10
|
+
export declare const conditionOp: import("convex/values").VUnion<"contains" | "eq" | "gt" | "gte" | "in" | "lt" | "lte" | "neq" | "nin", [import("convex/values").VLiteral<"eq", "required">, import("convex/values").VLiteral<"neq", "required">, import("convex/values").VLiteral<"in", "required">, import("convex/values").VLiteral<"nin", "required">, import("convex/values").VLiteral<"contains", "required">, import("convex/values").VLiteral<"gt", "required">, import("convex/values").VLiteral<"gte", "required">, import("convex/values").VLiteral<"lt", "required">, import("convex/values").VLiteral<"lte", "required">], "required", never>;
|
|
11
|
+
/** One targeting condition: `<attribute> <op> <values>`. */
|
|
12
|
+
export declare const condition: import("convex/values").VObject<{
|
|
13
|
+
attribute: string;
|
|
14
|
+
op: "contains" | "eq" | "gt" | "gte" | "in" | "lt" | "lte" | "neq" | "nin";
|
|
15
|
+
values: (string | number | boolean)[];
|
|
16
|
+
}, {
|
|
17
|
+
attribute: import("convex/values").VString<string, "required">;
|
|
18
|
+
op: import("convex/values").VUnion<"contains" | "eq" | "gt" | "gte" | "in" | "lt" | "lte" | "neq" | "nin", [import("convex/values").VLiteral<"eq", "required">, import("convex/values").VLiteral<"neq", "required">, import("convex/values").VLiteral<"in", "required">, import("convex/values").VLiteral<"nin", "required">, import("convex/values").VLiteral<"contains", "required">, import("convex/values").VLiteral<"gt", "required">, import("convex/values").VLiteral<"gte", "required">, import("convex/values").VLiteral<"lt", "required">, import("convex/values").VLiteral<"lte", "required">], "required", never>;
|
|
19
|
+
values: import("convex/values").VArray<(string | number | boolean)[], import("convex/values").VUnion<string | number | boolean, [import("convex/values").VBoolean<boolean, "required">, import("convex/values").VString<string, "required">, import("convex/values").VFloat64<number, "required">], "required", never>, "required">;
|
|
20
|
+
}, "required", "attribute" | "op" | "values">;
|
|
21
|
+
/** One weighted entry in a rollout's distribution. */
|
|
22
|
+
export declare const split: import("convex/values").VObject<{
|
|
23
|
+
value: string | number | boolean;
|
|
24
|
+
weight: number;
|
|
25
|
+
}, {
|
|
26
|
+
value: import("convex/values").VUnion<string | number | boolean, [import("convex/values").VBoolean<boolean, "required">, import("convex/values").VString<string, "required">, import("convex/values").VFloat64<number, "required">], "required", never>;
|
|
27
|
+
weight: import("convex/values").VFloat64<number, "required">;
|
|
28
|
+
}, "required", "value" | "weight">;
|
|
29
|
+
/** A deterministic weighted distribution across variant values. */
|
|
30
|
+
export declare const rollout: import("convex/values").VObject<{
|
|
31
|
+
by?: string | undefined;
|
|
32
|
+
splits: {
|
|
33
|
+
value: string | number | boolean;
|
|
34
|
+
weight: number;
|
|
35
|
+
}[];
|
|
36
|
+
}, {
|
|
37
|
+
splits: import("convex/values").VArray<{
|
|
38
|
+
value: string | number | boolean;
|
|
39
|
+
weight: number;
|
|
40
|
+
}[], import("convex/values").VObject<{
|
|
41
|
+
value: string | number | boolean;
|
|
42
|
+
weight: number;
|
|
43
|
+
}, {
|
|
44
|
+
value: import("convex/values").VUnion<string | number | boolean, [import("convex/values").VBoolean<boolean, "required">, import("convex/values").VString<string, "required">, import("convex/values").VFloat64<number, "required">], "required", never>;
|
|
45
|
+
weight: import("convex/values").VFloat64<number, "required">;
|
|
46
|
+
}, "required", "value" | "weight">, "required">;
|
|
47
|
+
by: import("convex/values").VString<string | undefined, "optional">;
|
|
48
|
+
}, "required", "by" | "splits">;
|
|
49
|
+
/** A declared variant (metadata for tooling / labels). */
|
|
50
|
+
export declare const variant: import("convex/values").VObject<{
|
|
51
|
+
label?: string | undefined;
|
|
52
|
+
value: string | number | boolean;
|
|
53
|
+
}, {
|
|
54
|
+
value: import("convex/values").VUnion<string | number | boolean, [import("convex/values").VBoolean<boolean, "required">, import("convex/values").VString<string, "required">, import("convex/values").VFloat64<number, "required">], "required", never>;
|
|
55
|
+
label: import("convex/values").VString<string | undefined, "optional">;
|
|
56
|
+
}, "required", "label" | "value">;
|
|
57
|
+
/** A targeting rule: all conditions AND; first matching rule (in order) wins. */
|
|
58
|
+
export declare const rule: import("convex/values").VObject<{
|
|
59
|
+
conditions: {
|
|
60
|
+
attribute: string;
|
|
61
|
+
op: "contains" | "eq" | "gt" | "gte" | "in" | "lt" | "lte" | "neq" | "nin";
|
|
62
|
+
values: (string | number | boolean)[];
|
|
63
|
+
}[];
|
|
64
|
+
rollout?: {
|
|
65
|
+
by?: string | undefined;
|
|
66
|
+
splits: {
|
|
67
|
+
value: string | number | boolean;
|
|
68
|
+
weight: number;
|
|
69
|
+
}[];
|
|
70
|
+
} | undefined;
|
|
71
|
+
value?: string | number | boolean | undefined;
|
|
72
|
+
}, {
|
|
73
|
+
conditions: import("convex/values").VArray<{
|
|
74
|
+
attribute: string;
|
|
75
|
+
op: "contains" | "eq" | "gt" | "gte" | "in" | "lt" | "lte" | "neq" | "nin";
|
|
76
|
+
values: (string | number | boolean)[];
|
|
77
|
+
}[], import("convex/values").VObject<{
|
|
78
|
+
attribute: string;
|
|
79
|
+
op: "contains" | "eq" | "gt" | "gte" | "in" | "lt" | "lte" | "neq" | "nin";
|
|
80
|
+
values: (string | number | boolean)[];
|
|
81
|
+
}, {
|
|
82
|
+
attribute: import("convex/values").VString<string, "required">;
|
|
83
|
+
op: import("convex/values").VUnion<"contains" | "eq" | "gt" | "gte" | "in" | "lt" | "lte" | "neq" | "nin", [import("convex/values").VLiteral<"eq", "required">, import("convex/values").VLiteral<"neq", "required">, import("convex/values").VLiteral<"in", "required">, import("convex/values").VLiteral<"nin", "required">, import("convex/values").VLiteral<"contains", "required">, import("convex/values").VLiteral<"gt", "required">, import("convex/values").VLiteral<"gte", "required">, import("convex/values").VLiteral<"lt", "required">, import("convex/values").VLiteral<"lte", "required">], "required", never>;
|
|
84
|
+
values: import("convex/values").VArray<(string | number | boolean)[], import("convex/values").VUnion<string | number | boolean, [import("convex/values").VBoolean<boolean, "required">, import("convex/values").VString<string, "required">, import("convex/values").VFloat64<number, "required">], "required", never>, "required">;
|
|
85
|
+
}, "required", "attribute" | "op" | "values">, "required">;
|
|
86
|
+
value: import("convex/values").VUnion<string | number | boolean | undefined, [import("convex/values").VBoolean<boolean, "required">, import("convex/values").VString<string, "required">, import("convex/values").VFloat64<number, "required">], "optional", never>;
|
|
87
|
+
rollout: import("convex/values").VObject<{
|
|
88
|
+
by?: string | undefined;
|
|
89
|
+
splits: {
|
|
90
|
+
value: string | number | boolean;
|
|
91
|
+
weight: number;
|
|
92
|
+
}[];
|
|
93
|
+
} | undefined, {
|
|
94
|
+
splits: import("convex/values").VArray<{
|
|
95
|
+
value: string | number | boolean;
|
|
96
|
+
weight: number;
|
|
97
|
+
}[], import("convex/values").VObject<{
|
|
98
|
+
value: string | number | boolean;
|
|
99
|
+
weight: number;
|
|
100
|
+
}, {
|
|
101
|
+
value: import("convex/values").VUnion<string | number | boolean, [import("convex/values").VBoolean<boolean, "required">, import("convex/values").VString<string, "required">, import("convex/values").VFloat64<number, "required">], "required", never>;
|
|
102
|
+
weight: import("convex/values").VFloat64<number, "required">;
|
|
103
|
+
}, "required", "value" | "weight">, "required">;
|
|
104
|
+
by: import("convex/values").VString<string | undefined, "optional">;
|
|
105
|
+
}, "optional", "by" | "splits">;
|
|
106
|
+
}, "required", "conditions" | "rollout" | "rollout.by" | "rollout.splits" | "value">;
|
|
107
|
+
/** Lifecycle status of a flag. */
|
|
108
|
+
export declare const flagStatus: import("convex/values").VUnion<"active" | "archived", [import("convex/values").VLiteral<"active", "required">, import("convex/values").VLiteral<"archived", "required">], "required", never>;
|
|
1
109
|
/**
|
|
2
110
|
* Column validators for a stored flag document (excluding Convex system fields).
|
|
3
111
|
* Shared between the schema and the query return validators.
|
|
@@ -5,34 +113,266 @@
|
|
|
5
113
|
export declare const flagFields: {
|
|
6
114
|
key: import("convex/values").VString<string, "required">;
|
|
7
115
|
description: import("convex/values").VString<string | undefined, "optional">;
|
|
8
|
-
value: import("convex/values").VBoolean<boolean, "required">;
|
|
116
|
+
value: import("convex/values").VUnion<string | number | boolean, [import("convex/values").VBoolean<boolean, "required">, import("convex/values").VString<string, "required">, import("convex/values").VFloat64<number, "required">], "required", never>;
|
|
117
|
+
variants: import("convex/values").VArray<{
|
|
118
|
+
label?: string | undefined;
|
|
119
|
+
value: string | number | boolean;
|
|
120
|
+
}[] | undefined, import("convex/values").VObject<{
|
|
121
|
+
label?: string | undefined;
|
|
122
|
+
value: string | number | boolean;
|
|
123
|
+
}, {
|
|
124
|
+
value: import("convex/values").VUnion<string | number | boolean, [import("convex/values").VBoolean<boolean, "required">, import("convex/values").VString<string, "required">, import("convex/values").VFloat64<number, "required">], "required", never>;
|
|
125
|
+
label: import("convex/values").VString<string | undefined, "optional">;
|
|
126
|
+
}, "required", "label" | "value">, "optional">;
|
|
127
|
+
rules: import("convex/values").VArray<{
|
|
128
|
+
conditions: {
|
|
129
|
+
attribute: string;
|
|
130
|
+
op: "contains" | "eq" | "gt" | "gte" | "in" | "lt" | "lte" | "neq" | "nin";
|
|
131
|
+
values: (string | number | boolean)[];
|
|
132
|
+
}[];
|
|
133
|
+
rollout?: {
|
|
134
|
+
by?: string | undefined;
|
|
135
|
+
splits: {
|
|
136
|
+
value: string | number | boolean;
|
|
137
|
+
weight: number;
|
|
138
|
+
}[];
|
|
139
|
+
} | undefined;
|
|
140
|
+
value?: string | number | boolean | undefined;
|
|
141
|
+
}[] | undefined, import("convex/values").VObject<{
|
|
142
|
+
conditions: {
|
|
143
|
+
attribute: string;
|
|
144
|
+
op: "contains" | "eq" | "gt" | "gte" | "in" | "lt" | "lte" | "neq" | "nin";
|
|
145
|
+
values: (string | number | boolean)[];
|
|
146
|
+
}[];
|
|
147
|
+
rollout?: {
|
|
148
|
+
by?: string | undefined;
|
|
149
|
+
splits: {
|
|
150
|
+
value: string | number | boolean;
|
|
151
|
+
weight: number;
|
|
152
|
+
}[];
|
|
153
|
+
} | undefined;
|
|
154
|
+
value?: string | number | boolean | undefined;
|
|
155
|
+
}, {
|
|
156
|
+
conditions: import("convex/values").VArray<{
|
|
157
|
+
attribute: string;
|
|
158
|
+
op: "contains" | "eq" | "gt" | "gte" | "in" | "lt" | "lte" | "neq" | "nin";
|
|
159
|
+
values: (string | number | boolean)[];
|
|
160
|
+
}[], import("convex/values").VObject<{
|
|
161
|
+
attribute: string;
|
|
162
|
+
op: "contains" | "eq" | "gt" | "gte" | "in" | "lt" | "lte" | "neq" | "nin";
|
|
163
|
+
values: (string | number | boolean)[];
|
|
164
|
+
}, {
|
|
165
|
+
attribute: import("convex/values").VString<string, "required">;
|
|
166
|
+
op: import("convex/values").VUnion<"contains" | "eq" | "gt" | "gte" | "in" | "lt" | "lte" | "neq" | "nin", [import("convex/values").VLiteral<"eq", "required">, import("convex/values").VLiteral<"neq", "required">, import("convex/values").VLiteral<"in", "required">, import("convex/values").VLiteral<"nin", "required">, import("convex/values").VLiteral<"contains", "required">, import("convex/values").VLiteral<"gt", "required">, import("convex/values").VLiteral<"gte", "required">, import("convex/values").VLiteral<"lt", "required">, import("convex/values").VLiteral<"lte", "required">], "required", never>;
|
|
167
|
+
values: import("convex/values").VArray<(string | number | boolean)[], import("convex/values").VUnion<string | number | boolean, [import("convex/values").VBoolean<boolean, "required">, import("convex/values").VString<string, "required">, import("convex/values").VFloat64<number, "required">], "required", never>, "required">;
|
|
168
|
+
}, "required", "attribute" | "op" | "values">, "required">;
|
|
169
|
+
value: import("convex/values").VUnion<string | number | boolean | undefined, [import("convex/values").VBoolean<boolean, "required">, import("convex/values").VString<string, "required">, import("convex/values").VFloat64<number, "required">], "optional", never>;
|
|
170
|
+
rollout: import("convex/values").VObject<{
|
|
171
|
+
by?: string | undefined;
|
|
172
|
+
splits: {
|
|
173
|
+
value: string | number | boolean;
|
|
174
|
+
weight: number;
|
|
175
|
+
}[];
|
|
176
|
+
} | undefined, {
|
|
177
|
+
splits: import("convex/values").VArray<{
|
|
178
|
+
value: string | number | boolean;
|
|
179
|
+
weight: number;
|
|
180
|
+
}[], import("convex/values").VObject<{
|
|
181
|
+
value: string | number | boolean;
|
|
182
|
+
weight: number;
|
|
183
|
+
}, {
|
|
184
|
+
value: import("convex/values").VUnion<string | number | boolean, [import("convex/values").VBoolean<boolean, "required">, import("convex/values").VString<string, "required">, import("convex/values").VFloat64<number, "required">], "required", never>;
|
|
185
|
+
weight: import("convex/values").VFloat64<number, "required">;
|
|
186
|
+
}, "required", "value" | "weight">, "required">;
|
|
187
|
+
by: import("convex/values").VString<string | undefined, "optional">;
|
|
188
|
+
}, "optional", "by" | "splits">;
|
|
189
|
+
}, "required", "conditions" | "rollout" | "rollout.by" | "rollout.splits" | "value">, "optional">;
|
|
190
|
+
rollout: import("convex/values").VObject<{
|
|
191
|
+
by?: string | undefined;
|
|
192
|
+
splits: {
|
|
193
|
+
value: string | number | boolean;
|
|
194
|
+
weight: number;
|
|
195
|
+
}[];
|
|
196
|
+
} | undefined, {
|
|
197
|
+
splits: import("convex/values").VArray<{
|
|
198
|
+
value: string | number | boolean;
|
|
199
|
+
weight: number;
|
|
200
|
+
}[], import("convex/values").VObject<{
|
|
201
|
+
value: string | number | boolean;
|
|
202
|
+
weight: number;
|
|
203
|
+
}, {
|
|
204
|
+
value: import("convex/values").VUnion<string | number | boolean, [import("convex/values").VBoolean<boolean, "required">, import("convex/values").VString<string, "required">, import("convex/values").VFloat64<number, "required">], "required", never>;
|
|
205
|
+
weight: import("convex/values").VFloat64<number, "required">;
|
|
206
|
+
}, "required", "value" | "weight">, "required">;
|
|
207
|
+
by: import("convex/values").VString<string | undefined, "optional">;
|
|
208
|
+
}, "optional", "by" | "splits">;
|
|
209
|
+
status: import("convex/values").VUnion<"active" | "archived" | undefined, [import("convex/values").VLiteral<"active", "required">, import("convex/values").VLiteral<"archived", "required">], "optional", never>;
|
|
9
210
|
createdAt: import("convex/values").VFloat64<number, "required">;
|
|
10
211
|
updatedAt: import("convex/values").VFloat64<number, "required">;
|
|
11
212
|
};
|
|
12
|
-
/** Public shape of a flag document returned by queries.
|
|
213
|
+
/** Public shape of a flag document returned by queries. `status` is materialized
|
|
214
|
+
* (a legacy row's absent status reads as active), so it is required here even
|
|
215
|
+
* though the stored column is optional. */
|
|
13
216
|
export declare const flagDoc: import("convex/values").VObject<{
|
|
14
|
-
description?: string | undefined;
|
|
15
|
-
key: string;
|
|
16
|
-
value: boolean;
|
|
17
|
-
_id: import("convex/values").GenericId<"flags">;
|
|
18
217
|
_creationTime: number;
|
|
218
|
+
_id: import("convex/values").GenericId<"flags">;
|
|
19
219
|
createdAt: number;
|
|
220
|
+
description?: string | undefined;
|
|
221
|
+
key: string;
|
|
222
|
+
rollout?: {
|
|
223
|
+
by?: string | undefined;
|
|
224
|
+
splits: {
|
|
225
|
+
value: string | number | boolean;
|
|
226
|
+
weight: number;
|
|
227
|
+
}[];
|
|
228
|
+
} | undefined;
|
|
229
|
+
rules?: {
|
|
230
|
+
conditions: {
|
|
231
|
+
attribute: string;
|
|
232
|
+
op: "contains" | "eq" | "gt" | "gte" | "in" | "lt" | "lte" | "neq" | "nin";
|
|
233
|
+
values: (string | number | boolean)[];
|
|
234
|
+
}[];
|
|
235
|
+
rollout?: {
|
|
236
|
+
by?: string | undefined;
|
|
237
|
+
splits: {
|
|
238
|
+
value: string | number | boolean;
|
|
239
|
+
weight: number;
|
|
240
|
+
}[];
|
|
241
|
+
} | undefined;
|
|
242
|
+
value?: string | number | boolean | undefined;
|
|
243
|
+
}[] | undefined;
|
|
244
|
+
status: "active" | "archived";
|
|
20
245
|
updatedAt: number;
|
|
246
|
+
value: string | number | boolean;
|
|
247
|
+
variants?: {
|
|
248
|
+
label?: string | undefined;
|
|
249
|
+
value: string | number | boolean;
|
|
250
|
+
}[] | undefined;
|
|
21
251
|
}, {
|
|
22
252
|
key: import("convex/values").VString<string, "required">;
|
|
23
253
|
description: import("convex/values").VString<string | undefined, "optional">;
|
|
24
|
-
value: import("convex/values").VBoolean<boolean, "required">;
|
|
254
|
+
value: import("convex/values").VUnion<string | number | boolean, [import("convex/values").VBoolean<boolean, "required">, import("convex/values").VString<string, "required">, import("convex/values").VFloat64<number, "required">], "required", never>;
|
|
255
|
+
variants: import("convex/values").VArray<{
|
|
256
|
+
label?: string | undefined;
|
|
257
|
+
value: string | number | boolean;
|
|
258
|
+
}[] | undefined, import("convex/values").VObject<{
|
|
259
|
+
label?: string | undefined;
|
|
260
|
+
value: string | number | boolean;
|
|
261
|
+
}, {
|
|
262
|
+
value: import("convex/values").VUnion<string | number | boolean, [import("convex/values").VBoolean<boolean, "required">, import("convex/values").VString<string, "required">, import("convex/values").VFloat64<number, "required">], "required", never>;
|
|
263
|
+
label: import("convex/values").VString<string | undefined, "optional">;
|
|
264
|
+
}, "required", "label" | "value">, "optional">;
|
|
265
|
+
rules: import("convex/values").VArray<{
|
|
266
|
+
conditions: {
|
|
267
|
+
attribute: string;
|
|
268
|
+
op: "contains" | "eq" | "gt" | "gte" | "in" | "lt" | "lte" | "neq" | "nin";
|
|
269
|
+
values: (string | number | boolean)[];
|
|
270
|
+
}[];
|
|
271
|
+
rollout?: {
|
|
272
|
+
by?: string | undefined;
|
|
273
|
+
splits: {
|
|
274
|
+
value: string | number | boolean;
|
|
275
|
+
weight: number;
|
|
276
|
+
}[];
|
|
277
|
+
} | undefined;
|
|
278
|
+
value?: string | number | boolean | undefined;
|
|
279
|
+
}[] | undefined, import("convex/values").VObject<{
|
|
280
|
+
conditions: {
|
|
281
|
+
attribute: string;
|
|
282
|
+
op: "contains" | "eq" | "gt" | "gte" | "in" | "lt" | "lte" | "neq" | "nin";
|
|
283
|
+
values: (string | number | boolean)[];
|
|
284
|
+
}[];
|
|
285
|
+
rollout?: {
|
|
286
|
+
by?: string | undefined;
|
|
287
|
+
splits: {
|
|
288
|
+
value: string | number | boolean;
|
|
289
|
+
weight: number;
|
|
290
|
+
}[];
|
|
291
|
+
} | undefined;
|
|
292
|
+
value?: string | number | boolean | undefined;
|
|
293
|
+
}, {
|
|
294
|
+
conditions: import("convex/values").VArray<{
|
|
295
|
+
attribute: string;
|
|
296
|
+
op: "contains" | "eq" | "gt" | "gte" | "in" | "lt" | "lte" | "neq" | "nin";
|
|
297
|
+
values: (string | number | boolean)[];
|
|
298
|
+
}[], import("convex/values").VObject<{
|
|
299
|
+
attribute: string;
|
|
300
|
+
op: "contains" | "eq" | "gt" | "gte" | "in" | "lt" | "lte" | "neq" | "nin";
|
|
301
|
+
values: (string | number | boolean)[];
|
|
302
|
+
}, {
|
|
303
|
+
attribute: import("convex/values").VString<string, "required">;
|
|
304
|
+
op: import("convex/values").VUnion<"contains" | "eq" | "gt" | "gte" | "in" | "lt" | "lte" | "neq" | "nin", [import("convex/values").VLiteral<"eq", "required">, import("convex/values").VLiteral<"neq", "required">, import("convex/values").VLiteral<"in", "required">, import("convex/values").VLiteral<"nin", "required">, import("convex/values").VLiteral<"contains", "required">, import("convex/values").VLiteral<"gt", "required">, import("convex/values").VLiteral<"gte", "required">, import("convex/values").VLiteral<"lt", "required">, import("convex/values").VLiteral<"lte", "required">], "required", never>;
|
|
305
|
+
values: import("convex/values").VArray<(string | number | boolean)[], import("convex/values").VUnion<string | number | boolean, [import("convex/values").VBoolean<boolean, "required">, import("convex/values").VString<string, "required">, import("convex/values").VFloat64<number, "required">], "required", never>, "required">;
|
|
306
|
+
}, "required", "attribute" | "op" | "values">, "required">;
|
|
307
|
+
value: import("convex/values").VUnion<string | number | boolean | undefined, [import("convex/values").VBoolean<boolean, "required">, import("convex/values").VString<string, "required">, import("convex/values").VFloat64<number, "required">], "optional", never>;
|
|
308
|
+
rollout: import("convex/values").VObject<{
|
|
309
|
+
by?: string | undefined;
|
|
310
|
+
splits: {
|
|
311
|
+
value: string | number | boolean;
|
|
312
|
+
weight: number;
|
|
313
|
+
}[];
|
|
314
|
+
} | undefined, {
|
|
315
|
+
splits: import("convex/values").VArray<{
|
|
316
|
+
value: string | number | boolean;
|
|
317
|
+
weight: number;
|
|
318
|
+
}[], import("convex/values").VObject<{
|
|
319
|
+
value: string | number | boolean;
|
|
320
|
+
weight: number;
|
|
321
|
+
}, {
|
|
322
|
+
value: import("convex/values").VUnion<string | number | boolean, [import("convex/values").VBoolean<boolean, "required">, import("convex/values").VString<string, "required">, import("convex/values").VFloat64<number, "required">], "required", never>;
|
|
323
|
+
weight: import("convex/values").VFloat64<number, "required">;
|
|
324
|
+
}, "required", "value" | "weight">, "required">;
|
|
325
|
+
by: import("convex/values").VString<string | undefined, "optional">;
|
|
326
|
+
}, "optional", "by" | "splits">;
|
|
327
|
+
}, "required", "conditions" | "rollout" | "rollout.by" | "rollout.splits" | "value">, "optional">;
|
|
328
|
+
rollout: import("convex/values").VObject<{
|
|
329
|
+
by?: string | undefined;
|
|
330
|
+
splits: {
|
|
331
|
+
value: string | number | boolean;
|
|
332
|
+
weight: number;
|
|
333
|
+
}[];
|
|
334
|
+
} | undefined, {
|
|
335
|
+
splits: import("convex/values").VArray<{
|
|
336
|
+
value: string | number | boolean;
|
|
337
|
+
weight: number;
|
|
338
|
+
}[], import("convex/values").VObject<{
|
|
339
|
+
value: string | number | boolean;
|
|
340
|
+
weight: number;
|
|
341
|
+
}, {
|
|
342
|
+
value: import("convex/values").VUnion<string | number | boolean, [import("convex/values").VBoolean<boolean, "required">, import("convex/values").VString<string, "required">, import("convex/values").VFloat64<number, "required">], "required", never>;
|
|
343
|
+
weight: import("convex/values").VFloat64<number, "required">;
|
|
344
|
+
}, "required", "value" | "weight">, "required">;
|
|
345
|
+
by: import("convex/values").VString<string | undefined, "optional">;
|
|
346
|
+
}, "optional", "by" | "splits">;
|
|
25
347
|
createdAt: import("convex/values").VFloat64<number, "required">;
|
|
26
348
|
updatedAt: import("convex/values").VFloat64<number, "required">;
|
|
27
349
|
_id: import("convex/values").VId<import("convex/values").GenericId<"flags">, "required">;
|
|
28
350
|
_creationTime: import("convex/values").VFloat64<number, "required">;
|
|
29
|
-
|
|
30
|
-
|
|
351
|
+
status: import("convex/values").VUnion<"active" | "archived", [import("convex/values").VLiteral<"active", "required">, import("convex/values").VLiteral<"archived", "required">], "required", never>;
|
|
352
|
+
}, "required", "_creationTime" | "_id" | "createdAt" | "description" | "key" | "rollout" | "rollout.by" | "rollout.splits" | "rules" | "status" | "updatedAt" | "value" | "variants">;
|
|
353
|
+
/** Column validators for a stored per-subject override. */
|
|
354
|
+
export declare const overrideFields: {
|
|
355
|
+
key: import("convex/values").VString<string, "required">;
|
|
356
|
+
subjectRef: import("convex/values").VString<string, "required">;
|
|
357
|
+
value: import("convex/values").VUnion<string | number | boolean, [import("convex/values").VBoolean<boolean, "required">, import("convex/values").VString<string, "required">, import("convex/values").VFloat64<number, "required">], "required", never>;
|
|
358
|
+
createdAt: import("convex/values").VFloat64<number, "required">;
|
|
359
|
+
};
|
|
360
|
+
/** Host-supplied, per-evaluation context. */
|
|
361
|
+
export declare const evalContext: import("convex/values").VObject<{
|
|
362
|
+
attributes?: Record<string, string | number | boolean> | undefined;
|
|
363
|
+
subjectRef?: string | undefined;
|
|
364
|
+
}, {
|
|
365
|
+
subjectRef: import("convex/values").VString<string | undefined, "optional">;
|
|
366
|
+
attributes: import("convex/values").VRecord<Record<string, string | number | boolean> | undefined, import("convex/values").VString<string, "required">, import("convex/values").VUnion<string | number | boolean, [import("convex/values").VBoolean<boolean, "required">, import("convex/values").VString<string, "required">, import("convex/values").VFloat64<number, "required">], "required", never>, "optional", string>;
|
|
367
|
+
}, "required", "attributes" | "subjectRef" | `attributes.${string}`>;
|
|
368
|
+
/** Stable evaluation reason codes (kept in sync with `EVAL_REASON` in shared.ts). */
|
|
369
|
+
export declare const evalReason: import("convex/values").VUnion<"default" | "disabled" | "flag" | "override" | "rollout" | "rule" | "unknown", [import("convex/values").VLiteral<"flag", "required">, import("convex/values").VLiteral<"rule", "required">, import("convex/values").VLiteral<"rollout", "required">, import("convex/values").VLiteral<"override", "required">, import("convex/values").VLiteral<"disabled", "required">, import("convex/values").VLiteral<"default", "required">, import("convex/values").VLiteral<"unknown", "required">], "required", never>;
|
|
370
|
+
/** Result of evaluating one flag: the value plus a reason code. */
|
|
31
371
|
export declare const evaluation: import("convex/values").VObject<{
|
|
32
|
-
|
|
33
|
-
|
|
372
|
+
reason: "default" | "disabled" | "flag" | "override" | "rollout" | "rule" | "unknown";
|
|
373
|
+
value: string | number | boolean;
|
|
34
374
|
}, {
|
|
35
|
-
value: import("convex/values").VBoolean<boolean, "required">;
|
|
36
|
-
reason: import("convex/values").
|
|
37
|
-
}, "required", "
|
|
375
|
+
value: import("convex/values").VUnion<string | number | boolean, [import("convex/values").VBoolean<boolean, "required">, import("convex/values").VString<string, "required">, import("convex/values").VFloat64<number, "required">], "required", never>;
|
|
376
|
+
reason: import("convex/values").VUnion<"default" | "disabled" | "flag" | "override" | "rollout" | "rule" | "unknown", [import("convex/values").VLiteral<"flag", "required">, import("convex/values").VLiteral<"rule", "required">, import("convex/values").VLiteral<"rollout", "required">, import("convex/values").VLiteral<"override", "required">, import("convex/values").VLiteral<"disabled", "required">, import("convex/values").VLiteral<"default", "required">, import("convex/values").VLiteral<"unknown", "required">], "required", never>;
|
|
377
|
+
}, "required", "reason" | "value">;
|
|
38
378
|
//# sourceMappingURL=validators.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../src/component/validators.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,UAAU
|
|
1
|
+
{"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../src/component/validators.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,YAAY,kPAA+C,CAAC;AAEzE,2DAA2D;AAC3D,eAAO,MAAM,cAAc,kPAA+C,CAAC;AAE3E,+DAA+D;AAC/D,eAAO,MAAM,WAAW,2lBAUvB,CAAC;AAEF,4DAA4D;AAC5D,eAAO,MAAM,SAAS;;;;;;;;6CAIpB,CAAC;AAEH,sDAAsD;AACtD,eAAO,MAAM,KAAK;;;;;;kCAAwD,CAAC;AAE3E,mEAAmE;AACnE,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;+BAGlB,CAAC;AAEH,0DAA0D;AAC1D,eAAO,MAAM,OAAO;;;;;;iCAAmE,CAAC;AAExF,iFAAiF;AACjF,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oFAIf,CAAC;AAEH,kCAAkC;AAClC,eAAO,MAAM,UAAU,8LAAsD,CAAC;AAE9E;;;GAGG;AACH,eAAO,MAAM,UAAU;IACrB,GAAG;IACH,WAAW;IACX,KAAK;IACL,QAAQ;;;;;;;;;;IACR,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IACL,OAAO;;;;;;;;;;;;;;;;;;;IACP,MAAM;IACN,SAAS;IACT,SAAS;CACV,CAAC;AAEF;;2CAE2C;AAC3C,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qLAKlB,CAAC;AAEH,2DAA2D;AAC3D,eAAO,MAAM,cAAc;IACzB,GAAG;IACH,UAAU;IACV,KAAK;IACL,SAAS;CACV,CAAC;AAEF,6CAA6C;AAC7C,eAAO,MAAM,WAAW;;;;;;oEAGtB,CAAC;AAEH,qFAAqF;AACrF,eAAO,MAAM,UAAU,+gBAQtB,CAAC;AAEF,mEAAmE;AACnE,eAAO,MAAM,UAAU;;;;;;kCAAwD,CAAC"}
|
|
@@ -1,4 +1,37 @@
|
|
|
1
1
|
import { v } from "convex/values";
|
|
2
|
+
/**
|
|
3
|
+
* A flag/variant value — typed primitives only (boolean, string, number). The
|
|
4
|
+
* client class is generic over the host's concrete value type; the component
|
|
5
|
+
* stores the typed union. No `v.any()`.
|
|
6
|
+
*/
|
|
7
|
+
export const variantValue = v.union(v.boolean(), v.string(), v.number());
|
|
8
|
+
/** An attribute value usable in a targeting comparison. */
|
|
9
|
+
export const attributeValue = v.union(v.boolean(), v.string(), v.number());
|
|
10
|
+
/** Comparison operators available to a targeting condition. */
|
|
11
|
+
export const conditionOp = v.union(v.literal("eq"), v.literal("neq"), v.literal("in"), v.literal("nin"), v.literal("contains"), v.literal("gt"), v.literal("gte"), v.literal("lt"), v.literal("lte"));
|
|
12
|
+
/** One targeting condition: `<attribute> <op> <values>`. */
|
|
13
|
+
export const condition = v.object({
|
|
14
|
+
attribute: v.string(),
|
|
15
|
+
op: conditionOp,
|
|
16
|
+
values: v.array(attributeValue),
|
|
17
|
+
});
|
|
18
|
+
/** One weighted entry in a rollout's distribution. */
|
|
19
|
+
export const split = v.object({ value: variantValue, weight: v.number() });
|
|
20
|
+
/** A deterministic weighted distribution across variant values. */
|
|
21
|
+
export const rollout = v.object({
|
|
22
|
+
splits: v.array(split),
|
|
23
|
+
by: v.optional(v.string()),
|
|
24
|
+
});
|
|
25
|
+
/** A declared variant (metadata for tooling / labels). */
|
|
26
|
+
export const variant = v.object({ value: variantValue, label: v.optional(v.string()) });
|
|
27
|
+
/** A targeting rule: all conditions AND; first matching rule (in order) wins. */
|
|
28
|
+
export const rule = v.object({
|
|
29
|
+
conditions: v.array(condition),
|
|
30
|
+
value: v.optional(variantValue),
|
|
31
|
+
rollout: v.optional(rollout),
|
|
32
|
+
});
|
|
33
|
+
/** Lifecycle status of a flag. */
|
|
34
|
+
export const flagStatus = v.union(v.literal("active"), v.literal("archived"));
|
|
2
35
|
/**
|
|
3
36
|
* Column validators for a stored flag document (excluding Convex system fields).
|
|
4
37
|
* Shared between the schema and the query return validators.
|
|
@@ -6,19 +39,37 @@ import { v } from "convex/values";
|
|
|
6
39
|
export const flagFields = {
|
|
7
40
|
key: v.string(),
|
|
8
41
|
description: v.optional(v.string()),
|
|
9
|
-
value:
|
|
42
|
+
value: variantValue,
|
|
43
|
+
variants: v.optional(v.array(variant)),
|
|
44
|
+
rules: v.optional(v.array(rule)),
|
|
45
|
+
rollout: v.optional(rollout),
|
|
46
|
+
status: v.optional(flagStatus),
|
|
10
47
|
createdAt: v.number(),
|
|
11
48
|
updatedAt: v.number(),
|
|
12
49
|
};
|
|
13
|
-
/** Public shape of a flag document returned by queries.
|
|
50
|
+
/** Public shape of a flag document returned by queries. `status` is materialized
|
|
51
|
+
* (a legacy row's absent status reads as active), so it is required here even
|
|
52
|
+
* though the stored column is optional. */
|
|
14
53
|
export const flagDoc = v.object({
|
|
15
54
|
_id: v.id("flags"),
|
|
16
55
|
_creationTime: v.number(),
|
|
17
56
|
...flagFields,
|
|
57
|
+
status: flagStatus,
|
|
18
58
|
});
|
|
19
|
-
/**
|
|
20
|
-
export const
|
|
21
|
-
|
|
22
|
-
|
|
59
|
+
/** Column validators for a stored per-subject override. */
|
|
60
|
+
export const overrideFields = {
|
|
61
|
+
key: v.string(),
|
|
62
|
+
subjectRef: v.string(),
|
|
63
|
+
value: variantValue,
|
|
64
|
+
createdAt: v.number(),
|
|
65
|
+
};
|
|
66
|
+
/** Host-supplied, per-evaluation context. */
|
|
67
|
+
export const evalContext = v.object({
|
|
68
|
+
subjectRef: v.optional(v.string()),
|
|
69
|
+
attributes: v.optional(v.record(v.string(), attributeValue)),
|
|
23
70
|
});
|
|
71
|
+
/** Stable evaluation reason codes (kept in sync with `EVAL_REASON` in shared.ts). */
|
|
72
|
+
export const evalReason = v.union(v.literal("flag"), v.literal("rule"), v.literal("rollout"), v.literal("override"), v.literal("disabled"), v.literal("default"), v.literal("unknown"));
|
|
73
|
+
/** Result of evaluating one flag: the value plus a reason code. */
|
|
74
|
+
export const evaluation = v.object({ value: variantValue, reason: evalReason });
|
|
24
75
|
//# sourceMappingURL=validators.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validators.js","sourceRoot":"","sources":["../../src/component/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAElC;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;IACf,WAAW,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACnC,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE;
|
|
1
|
+
{"version":3,"file":"validators.js","sourceRoot":"","sources":["../../src/component/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAElC;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;AAEzE,2DAA2D;AAC3D,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;AAE3E,+DAA+D;AAC/D,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAChC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EACf,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAChB,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EACf,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAChB,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,EACrB,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EACf,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAChB,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EACf,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CACjB,CAAC;AAEF,4DAA4D;AAC5D,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC;IAChC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,EAAE,EAAE,WAAW;IACf,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC;CAChC,CAAC,CAAC;AAEH,sDAAsD;AACtD,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAE3E,mEAAmE;AACnE,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9B,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC;IACtB,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;CAC3B,CAAC,CAAC;AAEH,0DAA0D;AAC1D,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;AAExF,iFAAiF;AACjF,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3B,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC;IAC9B,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAC;IAC/B,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC;CAC7B,CAAC,CAAC;AAEH,kCAAkC;AAClC,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;AAE9E;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;IACf,WAAW,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACnC,KAAK,EAAE,YAAY;IACnB,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACtC,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAChC,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC;IAC5B,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC;IAC9B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;CACtB,CAAC;AAEF;;2CAE2C;AAC3C,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9B,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC;IAClB,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE;IACzB,GAAG,UAAU;IACb,MAAM,EAAE,UAAU;CACnB,CAAC,CAAC;AAEH,2DAA2D;AAC3D,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;IACf,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB,KAAK,EAAE,YAAY;IACnB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;CACtB,CAAC;AAEF,6CAA6C;AAC7C,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAClC,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,cAAc,CAAC,CAAC;CAC7D,CAAC,CAAC;AAEH,qFAAqF;AACrF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAC/B,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EACjB,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EACjB,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,EACpB,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,EACrB,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,EACrB,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,EACpB,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CACrB,CAAC;AAEF,mEAAmE;AACnE,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { FunctionReference } from "convex/server";
|
|
2
|
+
import type { EvalContext, FlagEvaluation, VariantValue } from "../shared.js";
|
|
3
|
+
/** The host's re-exported `evaluate` query reference. */
|
|
4
|
+
export type EvaluateRef = FunctionReference<"query", "public", {
|
|
5
|
+
key: string;
|
|
6
|
+
context?: EvalContext;
|
|
7
|
+
default?: VariantValue;
|
|
8
|
+
}, FlagEvaluation>;
|
|
9
|
+
/** The host's re-exported `all` query reference. */
|
|
10
|
+
export type AllRef = FunctionReference<"query", "public", {
|
|
11
|
+
context?: EvalContext;
|
|
12
|
+
}, Record<string, FlagEvaluation>>;
|
|
13
|
+
/** Options for {@link useFlag}. */
|
|
14
|
+
export interface UseFlagOptions {
|
|
15
|
+
context?: EvalContext;
|
|
16
|
+
default?: VariantValue;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Reactively evaluate a single flag. Returns `undefined` while the query loads,
|
|
20
|
+
* then the {@link FlagEvaluation}. Re-renders whenever the flag changes.
|
|
21
|
+
*/
|
|
22
|
+
export declare function useFlag(query: EvaluateRef, key: string, options?: UseFlagOptions): FlagEvaluation | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Reactively evaluate every flag against optional context. Returns `undefined`
|
|
25
|
+
* while loading, then a map of flag key → {@link FlagEvaluation}.
|
|
26
|
+
*/
|
|
27
|
+
export declare function useFlags(query: AllRef, context?: EvalContext): Record<string, FlagEvaluation> | undefined;
|
|
28
|
+
export type { EvalContext, FlagEvaluation, VariantValue };
|
|
29
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE9E,yDAAyD;AACzD,MAAM,MAAM,WAAW,GAAG,iBAAiB,CACzC,OAAO,EACP,QAAQ,EACR;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,WAAW,CAAC;IAAC,OAAO,CAAC,EAAE,YAAY,CAAA;CAAE,EAC9D,cAAc,CACf,CAAC;AAEF,oDAAoD;AACpD,MAAM,MAAM,MAAM,GAAG,iBAAiB,CACpC,OAAO,EACP,QAAQ,EACR;IAAE,OAAO,CAAC,EAAE,WAAW,CAAA;CAAE,EACzB,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAC/B,CAAC;AAEF,mCAAmC;AACnC,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,OAAO,CAAC,EAAE,YAAY,CAAC;CACxB;AAED;;;GAGG;AACH,wBAAgB,OAAO,CACrB,KAAK,EAAE,WAAW,EAClB,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,cAAc,GACvB,cAAc,GAAG,SAAS,CAM5B;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CACtB,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,WAAW,GACpB,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,SAAS,CAE5C;AAED,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optional React layer for `@vllnt/convex-flags`.
|
|
3
|
+
*
|
|
4
|
+
* Thin, tree-shakeable hooks over `convex/react`'s `useQuery`. They wrap the
|
|
5
|
+
* host's own re-exported `evaluate` / `all` query refs — the component never
|
|
6
|
+
* owns the host's `api`. `react` and `convex/react` are optional peer deps: a
|
|
7
|
+
* backend-only consumer never imports this entry and pulls in zero React.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* // convex/flags.ts (host) re-exports the query refs from its wrappers, then:
|
|
12
|
+
* const evaluation = useFlag(api.flags.evaluate, "new-checkout", { context: { subjectRef } });
|
|
13
|
+
* if (evaluation?.value === true) { ... }
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
import { useQuery } from "convex/react";
|
|
17
|
+
/**
|
|
18
|
+
* Reactively evaluate a single flag. Returns `undefined` while the query loads,
|
|
19
|
+
* then the {@link FlagEvaluation}. Re-renders whenever the flag changes.
|
|
20
|
+
*/
|
|
21
|
+
export function useFlag(query, key, options) {
|
|
22
|
+
return useQuery(query, {
|
|
23
|
+
key,
|
|
24
|
+
context: options?.context,
|
|
25
|
+
default: options?.default,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Reactively evaluate every flag against optional context. Returns `undefined`
|
|
30
|
+
* while loading, then a map of flag key → {@link FlagEvaluation}.
|
|
31
|
+
*/
|
|
32
|
+
export function useFlags(query, context) {
|
|
33
|
+
return useQuery(query, { context });
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AA0BxC;;;GAGG;AACH,MAAM,UAAU,OAAO,CACrB,KAAkB,EAClB,GAAW,EACX,OAAwB;IAExB,OAAO,QAAQ,CAAC,KAAK,EAAE;QACrB,GAAG;QACH,OAAO,EAAE,OAAO,EAAE,OAAO;QACzB,OAAO,EAAE,OAAO,EAAE,OAAO;KAC1B,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,QAAQ,CACtB,KAAa,EACb,OAAqB;IAErB,OAAO,QAAQ,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;AACtC,CAAC"}
|