@productcraft/flags 0.4.0 → 0.5.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.
Files changed (52) hide show
  1. package/README.md +35 -0
  2. package/api.md +5 -16
  3. package/dist/{chunk-7237IZU3.js → browser/chunk-OOX7EUCT.js} +8 -19
  4. package/dist/browser/chunk-OOX7EUCT.js.map +1 -0
  5. package/dist/browser/{chunk-72WU42RU.js → chunk-WUZAG2E3.js} +11 -4
  6. package/dist/browser/chunk-WUZAG2E3.js.map +1 -0
  7. package/dist/browser/{chunk-CXYODDHM.cjs → chunk-XZK57G7L.cjs} +8 -19
  8. package/dist/browser/chunk-XZK57G7L.cjs.map +1 -0
  9. package/dist/browser/{chunk-4XCQBTYE.cjs → chunk-YM5K4NHA.cjs} +11 -4
  10. package/dist/browser/chunk-YM5K4NHA.cjs.map +1 -0
  11. package/dist/browser/index.cjs +8 -8
  12. package/dist/browser/index.js +2 -2
  13. package/dist/browser/management.cjs +2 -2
  14. package/dist/browser/management.js +1 -1
  15. package/dist/browser/testing.cjs +3 -3
  16. package/dist/browser/testing.cjs.map +1 -1
  17. package/dist/browser/testing.js +1 -1
  18. package/dist/browser/testing.js.map +1 -1
  19. package/dist/{chunk-NB7OGN6R.js → chunk-CGVDMKEE.js} +12 -5
  20. package/dist/chunk-CGVDMKEE.js.map +1 -0
  21. package/dist/{chunk-Q3P66XRI.cjs → chunk-L3AOANTB.cjs} +12 -5
  22. package/dist/chunk-L3AOANTB.cjs.map +1 -0
  23. package/dist/{chunk-NSAKFGTJ.cjs → chunk-RJIVAOBG.cjs} +8 -19
  24. package/dist/{browser/chunk-CXYODDHM.cjs.map → chunk-RJIVAOBG.cjs.map} +1 -1
  25. package/dist/{browser/chunk-TCVKCN3S.js → chunk-XNJ5OX4X.js} +8 -19
  26. package/dist/{browser/chunk-TCVKCN3S.js.map → chunk-XNJ5OX4X.js.map} +1 -1
  27. package/dist/{client-K2zALPGD.d.cts → client-BBiIKiGW.d.cts} +18 -14
  28. package/dist/{client-K2zALPGD.d.ts → client-BBiIKiGW.d.ts} +18 -14
  29. package/dist/{client-BwoMpm8_.d.cts → client-BWi7PASW.d.cts} +94 -33
  30. package/dist/{client-BwoMpm8_.d.ts → client-BWi7PASW.d.ts} +94 -33
  31. package/dist/index.cjs +8 -8
  32. package/dist/index.d.cts +3 -3
  33. package/dist/index.d.ts +3 -3
  34. package/dist/index.js +2 -2
  35. package/dist/management.cjs +2 -2
  36. package/dist/management.d.cts +1 -1
  37. package/dist/management.d.ts +1 -1
  38. package/dist/management.js +1 -1
  39. package/dist/testing.cjs +3 -3
  40. package/dist/testing.cjs.map +1 -1
  41. package/dist/testing.d.cts +3 -3
  42. package/dist/testing.d.ts +3 -3
  43. package/dist/testing.js +1 -1
  44. package/dist/testing.js.map +1 -1
  45. package/manifest.json +1 -1
  46. package/package.json +2 -2
  47. package/dist/browser/chunk-4XCQBTYE.cjs.map +0 -1
  48. package/dist/browser/chunk-72WU42RU.js.map +0 -1
  49. package/dist/chunk-7237IZU3.js.map +0 -1
  50. package/dist/chunk-NB7OGN6R.js.map +0 -1
  51. package/dist/chunk-NSAKFGTJ.cjs.map +0 -1
  52. package/dist/chunk-Q3P66XRI.cjs.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { Logger, ProductCraftError } from '@productcraft/core';
2
- import { SettingValue, User, EvaluationDetails, ParsedConfig } from '@productcraft/flags-engine';
2
+ import { SettingValue, UserInput, EvaluationDetails, ParsedConfig } from '@productcraft/flags-engine';
3
3
 
4
4
  type Layer = "CACHED" | "STALE" | null;
5
5
 
@@ -63,12 +63,16 @@ interface FlagsClientOptions {
63
63
  bootstrap?: string | object;
64
64
  overrides?: FlagsOverrides;
65
65
  /** The user evaluations are for when a call passes none. A call's own user replaces it as a whole. */
66
- defaultUser?: User;
67
- /** Where warnings and errors are logged. Default `console`. Pass `null` to log nothing. */
66
+ defaultUser?: UserInput;
67
+ /** Where warnings and errors are logged. Default `console`. Pass `null` to log nothing. Evaluation warnings (soft misses such as a missing attribute) are logged once per attribute for the life of the client. */
68
68
  logger?: Logger | null;
69
69
  /** Custom `fetch`. Defaults to the global `fetch`. */
70
70
  fetch?: typeof fetch;
71
- /** Delivery host. Defaults to `https://api.flags.productcraft.co`; when set, `delivery.base_urls` hints are ignored. */
71
+ /**
72
+ * Delivery host. Defaults to `https://api.flags.productcraft.co`. Set it for an in-cluster or self-hosted address,
73
+ * an egress proxy or your own CDN; when set, the config's `delivery.base_urls` hints are ignored, so the client only
74
+ * ever downloads from this host.
75
+ */
72
76
  baseUrl?: string;
73
77
  /** Start without network access (the cache, `bootstrap` and overrides still apply). `setOnline()` starts fetching. */
74
78
  offline?: boolean;
@@ -118,17 +122,17 @@ declare class FlagsClientError extends ProductCraftError {
118
122
  declare class FlagsSnapshot {
119
123
  #private;
120
124
  /** @internal */
121
- constructor(config: ParsedConfig | null, raw: Obj | null, user: User | undefined, layer: Layer);
125
+ constructor(config: ParsedConfig | null, raw: Obj | null, user: UserInput | undefined, layer: Layer);
122
126
  /** Revision of the config, 0 when there is none. */
123
127
  get revision(): number;
124
128
  /** Generation of the config (bumped after a database restore), 0 when there is none. */
125
129
  get generation(): number;
126
130
  /** Setting keys in config order. */
127
131
  keys(): string[];
128
- getValue<D extends Def>(key: string, defaultValue: D, user?: User | null): FlagValue<D>;
129
- getValueDetails<D extends Def>(key: string, defaultValue: D, user?: User | null): EvaluationDetails<FlagValue<D>>;
130
- getJson<T = unknown>(key: string, defaultValue: T, user?: User | null): T;
131
- getAllValues(user?: User | null): Record<string, unknown>;
132
+ getValue<D extends Def>(key: string, defaultValue: D, user?: UserInput | null): FlagValue<D>;
133
+ getValueDetails<D extends Def>(key: string, defaultValue: D, user?: UserInput | null): EvaluationDetails<FlagValue<D>>;
134
+ getJson<T = unknown>(key: string, defaultValue: T, user?: UserInput | null): T;
135
+ getAllValues(user?: UserInput | null): Record<string, unknown>;
132
136
  /** The config JSON this snapshot evaluates (overrides included), or null: pass it as another client's `bootstrap`. */
133
137
  toJSON(): Obj | null;
134
138
  }
@@ -151,15 +155,15 @@ declare class FlagsClient {
151
155
  on<E extends keyof FlagsClientEvents>(event: E, listener: FlagsClientEvents[E]): () => void;
152
156
  off<E extends keyof FlagsClientEvents>(event: E, listener: FlagsClientEvents[E]): void;
153
157
  /** The user evaluations use when a call passes none. */
154
- setDefaultUser(user: User | undefined): void;
158
+ setDefaultUser(user: UserInput | undefined): void;
155
159
  /** The value of a flag or setting for a user; the default on any failure. Never throws. */
156
- getValue<D extends Def>(key: string, defaultValue: D, user?: User | null): Promise<FlagValue<D>>;
160
+ getValue<D extends Def>(key: string, defaultValue: D, user?: UserInput | null): Promise<FlagValue<D>>;
157
161
  /** The value plus why: reason, matched rule or split, error code, warnings and revision. Never throws. */
158
- getValueDetails<D extends Def>(key: string, defaultValue: D, user?: User | null): Promise<EvaluationDetails<FlagValue<D>>>;
162
+ getValueDetails<D extends Def>(key: string, defaultValue: D, user?: UserInput | null): Promise<EvaluationDetails<FlagValue<D>>>;
159
163
  /** A json (or string) setting, parsed. A parse failure, a missing key or another type returns the default. Never throws. */
160
- getJson<T = unknown>(key: string, defaultValue: T, user?: User | null): Promise<T>;
164
+ getJson<T = unknown>(key: string, defaultValue: T, user?: UserInput | null): Promise<T>;
161
165
  /** Every setting's value for a user (json settings parsed), as a null-prototype object. Never throws. */
162
- getAllValues(user?: User | null): Promise<Record<string, unknown>>;
166
+ getAllValues(user?: UserInput | null): Promise<Record<string, unknown>>;
163
167
  /** The config as it is now, for synchronous evaluation. Does not wait for the first download. */
164
168
  snapshot(): FlagsSnapshot;
165
169
  /** Resolves when start-up has settled: the first download finished or `maxInitWaitSeconds` passed. Never rejects. */
@@ -1,5 +1,5 @@
1
1
  import { Logger, ProductCraftError } from '@productcraft/core';
2
- import { SettingValue, User, EvaluationDetails, ParsedConfig } from '@productcraft/flags-engine';
2
+ import { SettingValue, UserInput, EvaluationDetails, ParsedConfig } from '@productcraft/flags-engine';
3
3
 
4
4
  type Layer = "CACHED" | "STALE" | null;
5
5
 
@@ -63,12 +63,16 @@ interface FlagsClientOptions {
63
63
  bootstrap?: string | object;
64
64
  overrides?: FlagsOverrides;
65
65
  /** The user evaluations are for when a call passes none. A call's own user replaces it as a whole. */
66
- defaultUser?: User;
67
- /** Where warnings and errors are logged. Default `console`. Pass `null` to log nothing. */
66
+ defaultUser?: UserInput;
67
+ /** Where warnings and errors are logged. Default `console`. Pass `null` to log nothing. Evaluation warnings (soft misses such as a missing attribute) are logged once per attribute for the life of the client. */
68
68
  logger?: Logger | null;
69
69
  /** Custom `fetch`. Defaults to the global `fetch`. */
70
70
  fetch?: typeof fetch;
71
- /** Delivery host. Defaults to `https://api.flags.productcraft.co`; when set, `delivery.base_urls` hints are ignored. */
71
+ /**
72
+ * Delivery host. Defaults to `https://api.flags.productcraft.co`. Set it for an in-cluster or self-hosted address,
73
+ * an egress proxy or your own CDN; when set, the config's `delivery.base_urls` hints are ignored, so the client only
74
+ * ever downloads from this host.
75
+ */
72
76
  baseUrl?: string;
73
77
  /** Start without network access (the cache, `bootstrap` and overrides still apply). `setOnline()` starts fetching. */
74
78
  offline?: boolean;
@@ -118,17 +122,17 @@ declare class FlagsClientError extends ProductCraftError {
118
122
  declare class FlagsSnapshot {
119
123
  #private;
120
124
  /** @internal */
121
- constructor(config: ParsedConfig | null, raw: Obj | null, user: User | undefined, layer: Layer);
125
+ constructor(config: ParsedConfig | null, raw: Obj | null, user: UserInput | undefined, layer: Layer);
122
126
  /** Revision of the config, 0 when there is none. */
123
127
  get revision(): number;
124
128
  /** Generation of the config (bumped after a database restore), 0 when there is none. */
125
129
  get generation(): number;
126
130
  /** Setting keys in config order. */
127
131
  keys(): string[];
128
- getValue<D extends Def>(key: string, defaultValue: D, user?: User | null): FlagValue<D>;
129
- getValueDetails<D extends Def>(key: string, defaultValue: D, user?: User | null): EvaluationDetails<FlagValue<D>>;
130
- getJson<T = unknown>(key: string, defaultValue: T, user?: User | null): T;
131
- getAllValues(user?: User | null): Record<string, unknown>;
132
+ getValue<D extends Def>(key: string, defaultValue: D, user?: UserInput | null): FlagValue<D>;
133
+ getValueDetails<D extends Def>(key: string, defaultValue: D, user?: UserInput | null): EvaluationDetails<FlagValue<D>>;
134
+ getJson<T = unknown>(key: string, defaultValue: T, user?: UserInput | null): T;
135
+ getAllValues(user?: UserInput | null): Record<string, unknown>;
132
136
  /** The config JSON this snapshot evaluates (overrides included), or null: pass it as another client's `bootstrap`. */
133
137
  toJSON(): Obj | null;
134
138
  }
@@ -151,15 +155,15 @@ declare class FlagsClient {
151
155
  on<E extends keyof FlagsClientEvents>(event: E, listener: FlagsClientEvents[E]): () => void;
152
156
  off<E extends keyof FlagsClientEvents>(event: E, listener: FlagsClientEvents[E]): void;
153
157
  /** The user evaluations use when a call passes none. */
154
- setDefaultUser(user: User | undefined): void;
158
+ setDefaultUser(user: UserInput | undefined): void;
155
159
  /** The value of a flag or setting for a user; the default on any failure. Never throws. */
156
- getValue<D extends Def>(key: string, defaultValue: D, user?: User | null): Promise<FlagValue<D>>;
160
+ getValue<D extends Def>(key: string, defaultValue: D, user?: UserInput | null): Promise<FlagValue<D>>;
157
161
  /** The value plus why: reason, matched rule or split, error code, warnings and revision. Never throws. */
158
- getValueDetails<D extends Def>(key: string, defaultValue: D, user?: User | null): Promise<EvaluationDetails<FlagValue<D>>>;
162
+ getValueDetails<D extends Def>(key: string, defaultValue: D, user?: UserInput | null): Promise<EvaluationDetails<FlagValue<D>>>;
159
163
  /** A json (or string) setting, parsed. A parse failure, a missing key or another type returns the default. Never throws. */
160
- getJson<T = unknown>(key: string, defaultValue: T, user?: User | null): Promise<T>;
164
+ getJson<T = unknown>(key: string, defaultValue: T, user?: UserInput | null): Promise<T>;
161
165
  /** Every setting's value for a user (json settings parsed), as a null-prototype object. Never throws. */
162
- getAllValues(user?: User | null): Promise<Record<string, unknown>>;
166
+ getAllValues(user?: UserInput | null): Promise<Record<string, unknown>>;
163
167
  /** The config as it is now, for synchronous evaluation. Does not wait for the first download. */
164
168
  snapshot(): FlagsSnapshot;
165
169
  /** Resolves when start-up has settled: the first download finished or `maxInitWaitSeconds` passed. Never rejects. */
@@ -570,7 +570,7 @@ type paths = {
570
570
  head?: never;
571
571
  /**
572
572
  * Update a segment
573
- * @description Key, name, description or conditions; only the fields you send change. Edit a confidential list with `list_id` plus `values_add` / `values_remove`. A segment used in a protected environment also needs `flags.protected.update` there.
573
+ * @description Key, name, description or conditions; only the fields you send change. To add or remove values in one list condition without re-sending the others, send `condition_edits` (with the `version` you read). Edit a confidential list with `list_id` plus `values_add` / `values_remove`, or with `condition_edits`. A segment used in a protected environment also needs `flags.protected.update` there.
574
574
  */
575
575
  patch: operations["SegmentsController_update"];
576
576
  trace?: never;
@@ -646,7 +646,7 @@ type paths = {
646
646
  head?: never;
647
647
  /**
648
648
  * Update a value
649
- * @description The quick edits: `value` (the toggle), `percentage_attribute`, and `clear_rules: true` to drop every rule and split so `value` is served to everyone (the kill switch). Send the `version` you read.
649
+ * @description The quick edits: `value` (the toggle), `percentage_attribute`, `rule_edits` to add or remove values in a list condition of an existing rule (a tester, a QA account) without re-sending the other rules, and `clear_rules: true` to drop every rule and split so `value` is served to everyone (the kill switch). Send the `version` you read. A protected environment needs `flags.protected.update`; one change and one revision per request, none when nothing changed.
650
650
  */
651
651
  patch: operations["SettingsController_patchValue"];
652
652
  trace?: never;
@@ -1110,6 +1110,27 @@ type components = {
1110
1110
  /** @description Its value in each requested environment, in the order of `environment_ids`. */
1111
1111
  values: components["schemas"]["SettingValueResponseDto"][];
1112
1112
  };
1113
+ ConditionListEditDto: {
1114
+ /**
1115
+ * @description The condition to edit (0-based, in the order the conditions are listed).
1116
+ * @example 0
1117
+ */
1118
+ condition_index: number;
1119
+ /**
1120
+ * @description Values to add. A value already in the list is ignored (no change, no new version).
1121
+ * @example [
1122
+ * "qa-bot@example.com"
1123
+ * ]
1124
+ */
1125
+ values_add?: string[];
1126
+ /**
1127
+ * @description Values to remove, applied before `values_add`. A value not in the list is ignored. The list cannot become empty (remove the condition with a full PUT).
1128
+ * @example [
1129
+ * "old-bot@example.com"
1130
+ * ]
1131
+ */
1132
+ values_remove?: string[];
1133
+ };
1113
1134
  ConfidentialListDto: {
1114
1135
  /**
1115
1136
  * @description The user attribute the condition compares.
@@ -2325,6 +2346,19 @@ type components = {
2325
2346
  note?: string;
2326
2347
  /** @description The attribute splits hash; null for `identifier`. */
2327
2348
  percentage_attribute?: string | null;
2349
+ /**
2350
+ * @description Add or remove values in list conditions of the existing rules without re-sending the targeting: each edit names a rule and a condition by index (as `GET` returns them, so send the `version` you read) and changes only that condition's values, with set semantics. A 422 `INVALID_TARGETING` names an index with no rule or condition, or a condition that is not a list. Re-adding a present value or removing an absent one is not a change: the current value comes back with the same `version` and no history entry. Cannot be combined with `clear_rules`.
2351
+ * @example [
2352
+ * {
2353
+ * "condition_index": 0,
2354
+ * "rule_index": 0,
2355
+ * "values_add": [
2356
+ * "qa-bot@example.com"
2357
+ * ]
2358
+ * }
2359
+ * ]
2360
+ */
2361
+ rule_edits?: components["schemas"]["RuleListEditDto"][];
2328
2362
  /**
2329
2363
  * @description The new plain value (the on/off toggle for a flag). Must match the setting type: `boolean` true/false; `string` a string; `integer` a safe integer; `number` a finite number; `json` a string holding JSON text (for example `"{\"limit\":5}"`). At most 100 KB. Strings are stored and returned byte for byte.
2330
2364
  * @example true
@@ -2542,6 +2576,32 @@ type components = {
2542
2576
  */
2543
2577
  grace_hours?: number;
2544
2578
  };
2579
+ RuleListEditDto: {
2580
+ /**
2581
+ * @description The condition to edit (0-based, in the order the conditions are listed).
2582
+ * @example 0
2583
+ */
2584
+ condition_index: number;
2585
+ /**
2586
+ * @description The rule the condition is in (0-based, in evaluation order).
2587
+ * @example 0
2588
+ */
2589
+ rule_index: number;
2590
+ /**
2591
+ * @description Values to add. A value already in the list is ignored (no change, no new version).
2592
+ * @example [
2593
+ * "qa-bot@example.com"
2594
+ * ]
2595
+ */
2596
+ values_add?: string[];
2597
+ /**
2598
+ * @description Values to remove, applied before `values_add`. A value not in the list is ignored. The list cannot become empty (remove the condition with a full PUT).
2599
+ * @example [
2600
+ * "old-bot@example.com"
2601
+ * ]
2602
+ */
2603
+ values_remove?: string[];
2604
+ };
2545
2605
  SdkKeyListResponseDto: {
2546
2606
  /** @description The primary key, then the secondary key while a grace period runs. */
2547
2607
  data: components["schemas"]["SdkKeyResponseDto"][];
@@ -3226,6 +3286,18 @@ type components = {
3226
3286
  ordinal?: number;
3227
3287
  };
3228
3288
  UpdateSegmentDto: {
3289
+ /**
3290
+ * @description Instead of `conditions`: add or remove values in list conditions without re-sending the others. Each edit names a condition by index and changes only its values, with set semantics (`values_remove` first). A 422 `INVALID_TARGETING` names an index with no condition, or a condition that is not a list. Re-adding a present value or removing an absent one is not a change (same `version`, no history entry). Send `version` so an edit against a stale read is refused.
3291
+ * @example [
3292
+ * {
3293
+ * "condition_index": 0,
3294
+ * "values_add": [
3295
+ * "qa-bot@example.com"
3296
+ * ]
3297
+ * }
3298
+ * ]
3299
+ */
3300
+ condition_edits?: components["schemas"]["ConditionListEditDto"][];
3229
3301
  /**
3230
3302
  * @description Replaces the conditions. 1-20 conditions, ANDed in order; each is `{user: {attribute, comparator, values}}` (segments hold user conditions only). Confidential comparators take cleartext `values` (stored hashed with the segment's seed and the project salt, and encrypted at rest), `values_hashed`, or `list_id` with `values_add` / `values_remove` to edit a stored list. To keep a confidential list, send its `list_id` (or echo the `{hashed: true, list_id, …}` object as `values`).
3231
3303
  * @example [
@@ -3966,7 +4038,7 @@ interface operations {
3966
4038
  parameters: {
3967
4039
  query?: never;
3968
4040
  header?: {
3969
- /** @description Idempotency key (1-256 characters, `[A-Za-z0-9_-:]`). A retry with the same key and body returns the first response for 24 h. */
4041
+ /** @description Idempotency key (1-256 characters, `[A-Za-z0-9._:-]`). A retry with the same key and body returns the first response for 24 h. */
3970
4042
  "Idempotency-Key"?: string;
3971
4043
  };
3972
4044
  path: {
@@ -4459,7 +4531,7 @@ interface operations {
4459
4531
  parameters: {
4460
4532
  query?: never;
4461
4533
  header?: {
4462
- /** @description Idempotency key (1-256 characters, `[A-Za-z0-9_-:]`). A retry with the same key and body returns the first response for 24 h. */
4534
+ /** @description Idempotency key (1-256 characters, `[A-Za-z0-9._:-]`). A retry with the same key and body returns the first response for 24 h. */
4463
4535
  "Idempotency-Key"?: string;
4464
4536
  };
4465
4537
  path: {
@@ -5072,7 +5144,7 @@ interface operations {
5072
5144
  parameters: {
5073
5145
  query?: never;
5074
5146
  header?: {
5075
- /** @description Idempotency key (1-256 characters, `[A-Za-z0-9_-:]`). A retry with the same key and body returns the first response for 24 h. */
5147
+ /** @description Idempotency key (1-256 characters, `[A-Za-z0-9._:-]`). A retry with the same key and body returns the first response for 24 h. */
5076
5148
  "Idempotency-Key"?: string;
5077
5149
  };
5078
5150
  path: {
@@ -5510,7 +5582,7 @@ interface operations {
5510
5582
  parameters: {
5511
5583
  query?: never;
5512
5584
  header?: {
5513
- /** @description Idempotency key (1-256 characters, `[A-Za-z0-9_-:]`). A retry with the same key and body returns the first response for 24 h. */
5585
+ /** @description Idempotency key (1-256 characters, `[A-Za-z0-9._:-]`). A retry with the same key and body returns the first response for 24 h. */
5514
5586
  "Idempotency-Key"?: string;
5515
5587
  };
5516
5588
  path: {
@@ -5913,7 +5985,7 @@ interface operations {
5913
5985
  parameters: {
5914
5986
  query?: never;
5915
5987
  header?: {
5916
- /** @description Idempotency key (1-256 characters, `[A-Za-z0-9_-:]`). A retry with the same key and body returns the first response for 24 h. */
5988
+ /** @description Idempotency key (1-256 characters, `[A-Za-z0-9._:-]`). A retry with the same key and body returns the first response for 24 h. */
5917
5989
  "Idempotency-Key"?: string;
5918
5990
  };
5919
5991
  path: {
@@ -6663,7 +6735,7 @@ interface operations {
6663
6735
  parameters: {
6664
6736
  query?: never;
6665
6737
  header?: {
6666
- /** @description Idempotency key (1-256 characters, `[A-Za-z0-9_-:]`). A retry with the same key and body returns the first response for 24 h. */
6738
+ /** @description Idempotency key (1-256 characters, `[A-Za-z0-9._:-]`). A retry with the same key and body returns the first response for 24 h. */
6667
6739
  "Idempotency-Key"?: string;
6668
6740
  };
6669
6741
  path: {
@@ -6862,7 +6934,7 @@ interface operations {
6862
6934
  parameters: {
6863
6935
  query?: never;
6864
6936
  header?: {
6865
- /** @description Idempotency key (1-256 characters, `[A-Za-z0-9_-:]`). A retry with the same key and body returns the first response for 24 h. */
6937
+ /** @description Idempotency key (1-256 characters, `[A-Za-z0-9._:-]`). A retry with the same key and body returns the first response for 24 h. */
6866
6938
  "Idempotency-Key"?: string;
6867
6939
  };
6868
6940
  path: {
@@ -7365,7 +7437,7 @@ interface operations {
7365
7437
  parameters: {
7366
7438
  query?: never;
7367
7439
  header?: {
7368
- /** @description Idempotency key (1-256 characters, `[A-Za-z0-9_-:]`). A retry with the same key and body returns the first response for 24 h. */
7440
+ /** @description Idempotency key (1-256 characters, `[A-Za-z0-9._:-]`). A retry with the same key and body returns the first response for 24 h. */
7369
7441
  "Idempotency-Key"?: string;
7370
7442
  };
7371
7443
  path: {
@@ -7694,7 +7766,7 @@ interface operations {
7694
7766
  "application/json": components["schemas"]["SegmentDetailResponseDto"];
7695
7767
  };
7696
7768
  };
7697
- /** @description `VALIDATION_ERROR`: a field is invalid. */
7769
+ /** @description `VALIDATION_ERROR`: a field is invalid, an edit has no values, or both `conditions` and `condition_edits` were sent. */
7698
7770
  400: {
7699
7771
  headers: {
7700
7772
  "X-Request-Id": components["headers"]["RequestId"];
@@ -8391,7 +8463,7 @@ interface operations {
8391
8463
  "application/json": components["schemas"]["SettingValueResponseDto"];
8392
8464
  };
8393
8465
  };
8394
- /** @description `VALIDATION_ERROR`: nothing to change, or `version` is missing. */
8466
+ /** @description `VALIDATION_ERROR`: nothing to change, `version` is missing, an edit has no values, or `rule_edits` sent with `clear_rules`. */
8395
8467
  400: {
8396
8468
  headers: {
8397
8469
  "X-Request-Id": components["headers"]["RequestId"];
@@ -8705,7 +8777,7 @@ interface operations {
8705
8777
  parameters: {
8706
8778
  query?: never;
8707
8779
  header?: {
8708
- /** @description Opaque client-generated string (1-256 chars, `[A-Za-z0-9_-:]`) that makes a retry of this request safe for 24 hours. The same key with a different body returns 409 `IDEMPOTENCY_KEY_REUSE`. */
8780
+ /** @description Opaque client-generated string (1-256 chars, `[A-Za-z0-9._:-]`) that makes a retry of this request safe for 24 hours. The same key with a different body returns 409 `IDEMPOTENCY_KEY_REUSE`. */
8709
8781
  "Idempotency-Key"?: string;
8710
8782
  };
8711
8783
  path: {
@@ -8985,7 +9057,7 @@ interface operations {
8985
9057
  parameters: {
8986
9058
  query?: never;
8987
9059
  header?: {
8988
- /** @description Opaque client-generated string (1-256 chars, `[A-Za-z0-9_-:]`) that makes a retry of this request safe for 24 hours. The same key with a different body returns 409 `IDEMPOTENCY_KEY_REUSE`. */
9060
+ /** @description Opaque client-generated string (1-256 chars, `[A-Za-z0-9._:-]`) that makes a retry of this request safe for 24 hours. The same key with a different body returns 409 `IDEMPOTENCY_KEY_REUSE`. */
8989
9061
  "Idempotency-Key"?: string;
8990
9062
  };
8991
9063
  path: {
@@ -9101,7 +9173,7 @@ interface operations {
9101
9173
  parameters: {
9102
9174
  query?: never;
9103
9175
  header?: {
9104
- /** @description Opaque client-generated string (1-256 chars, `[A-Za-z0-9_-:]`) that makes a retry of this request safe for 24 hours. The same key with a different body returns 409 `IDEMPOTENCY_KEY_REUSE`. */
9176
+ /** @description Opaque client-generated string (1-256 chars, `[A-Za-z0-9._:-]`) that makes a retry of this request safe for 24 hours. The same key with a different body returns 409 `IDEMPOTENCY_KEY_REUSE`. */
9105
9177
  "Idempotency-Key"?: string;
9106
9178
  };
9107
9179
  path: {
@@ -9209,7 +9281,7 @@ interface operations {
9209
9281
  parameters: {
9210
9282
  query?: never;
9211
9283
  header?: {
9212
- /** @description Opaque client-generated string (1-256 chars, `[A-Za-z0-9_-:]`) that makes a retry of this request safe for 24 hours. The same key with a different body returns 409 `IDEMPOTENCY_KEY_REUSE`. */
9284
+ /** @description Opaque client-generated string (1-256 chars, `[A-Za-z0-9._:-]`) that makes a retry of this request safe for 24 hours. The same key with a different body returns 409 `IDEMPOTENCY_KEY_REUSE`. */
9213
9285
  "Idempotency-Key"?: string;
9214
9286
  };
9215
9287
  path: {
@@ -9607,7 +9679,7 @@ interface operations {
9607
9679
  endpoint_id?: string;
9608
9680
  };
9609
9681
  header?: {
9610
- /** @description Opaque client-generated string (1-256 chars, `[A-Za-z0-9_-:]`) that makes a retry of this request safe for 24 hours. The same key with a different body returns 409 `IDEMPOTENCY_KEY_REUSE`. */
9682
+ /** @description Opaque client-generated string (1-256 chars, `[A-Za-z0-9._:-]`) that makes a retry of this request safe for 24 hours. The same key with a different body returns 409 `IDEMPOTENCY_KEY_REUSE`. */
9611
9683
  "Idempotency-Key"?: string;
9612
9684
  };
9613
9685
  path: {
@@ -11055,12 +11127,12 @@ declare class SegmentsResource extends APIResource {
11055
11127
  /**
11056
11128
  * Update a segment
11057
11129
  *
11058
- * Key, name, description or conditions; only the fields you send change. Edit a confidential list with `list_id` plus `values_add` / `values_remove`. A segment used in a protected environment also needs `flags.protected.update` there.
11130
+ * Key, name, description or conditions; only the fields you send change. To add or remove values in one list condition without re-sending the others, send `condition_edits` (with the `version` you read). Edit a confidential list with `list_id` plus `values_add` / `values_remove`, or with `condition_edits`. A segment used in a protected environment also needs `flags.protected.update` there.
11059
11131
  *
11060
11132
  * @param segmentId - Id of the segment.
11061
11133
  * @param params - `Flags.SegmentUpdateParams`.
11062
11134
  * @param options - Per-request options.
11063
- * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `VALIDATION_ERROR`: a field is invalid.
11135
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `VALIDATION_ERROR`: a field is invalid, an edit has no values, or both `conditions` and `condition_edits` were sent.
11064
11136
  * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token (`UNAUTHORIZED`). Send a workspace API key or a platform session token as `Authorization: Bearer <token>`.
11065
11137
  * @throws {PermissionDeniedError} 403 FORBIDDEN, SERVICE_NOT_ENABLED: The caller lacks the action this route needs (`message` names it), or the workspace has not enabled Flags (`SERVICE_NOT_ENABLED`). A segment used in a protected environment also needs `flags.protected.update` on it.
11066
11138
  * @throws {NotFoundError} 404 NOT_FOUND, SEGMENT_NOT_FOUND: `SEGMENT_NOT_FOUND`: no such segment in this workspace.
@@ -11072,18 +11144,7 @@ declare class SegmentsResource extends APIResource {
11072
11144
  * @see https://productcraft.co/docs/flags/api-reference#patch-v1-workspaces-workspace-id-segments-segment-id
11073
11145
  * @example
11074
11146
  * ```ts
11075
- * const segmentDetail = await flags.segments.update("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", {
11076
- * conditions: [
11077
- * {
11078
- * user: {
11079
- * attribute: "email",
11080
- * comparator: "ends_with_any_hashed",
11081
- * list_id: "3f0c6a3e-0f5e-4b8e-9d1a-2c7b9f1e8a10",
11082
- * values_add: ["@beta.test"],
11083
- * },
11084
- * },
11085
- * ],
11086
- * });
11147
+ * const segmentDetail = await flags.segments.update("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", { condition_edits: [{ condition_index: 0, values_add: ["qa-bot@example.com"] }] });
11087
11148
  * ```
11088
11149
  */
11089
11150
  update(segmentId: string, params?: SegmentUpdateParams, options?: RequestOptions): APIPromise<WithLastResponse<SegmentDetail>>;
@@ -11161,13 +11222,13 @@ declare class SettingsValuesResource extends APIResource {
11161
11222
  /**
11162
11223
  * Update a value
11163
11224
  *
11164
- * The quick edits: `value` (the toggle), `percentage_attribute`, and `clear_rules: true` to drop every rule and split so `value` is served to everyone (the kill switch). Send the `version` you read.
11225
+ * The quick edits: `value` (the toggle), `percentage_attribute`, `rule_edits` to add or remove values in a list condition of an existing rule (a tester, a QA account) without re-sending the other rules, and `clear_rules: true` to drop every rule and split so `value` is served to everyone (the kill switch). Send the `version` you read. A protected environment needs `flags.protected.update`; one change and one revision per request, none when nothing changed.
11165
11226
  *
11166
11227
  * @param settingId - Id of the setting.
11167
11228
  * @param environmentId - Id of an environment of the same project.
11168
11229
  * @param params - `Flags.SettingsValueUpdateParams`.
11169
11230
  * @param options - Per-request options.
11170
- * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `VALIDATION_ERROR`: nothing to change, or `version` is missing.
11231
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `VALIDATION_ERROR`: nothing to change, `version` is missing, an edit has no values, or `rule_edits` sent with `clear_rules`.
11171
11232
  * @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token (`UNAUTHORIZED`). Send a workspace API key or a platform session token as `Authorization: Bearer <token>`.
11172
11233
  * @throws {PermissionDeniedError} 403 FORBIDDEN, SERVICE_NOT_ENABLED: The caller lacks the action this route needs (`message` names it), or the workspace has not enabled Flags (`SERVICE_NOT_ENABLED`). Value writes need `flags.value.update` on the environment and the setting, plus `flags.protected.update` in a protected environment.
11173
11234
  * @throws {NotFoundError} 404 NOT_FOUND, SETTING_NOT_FOUND, ENVIRONMENT_NOT_FOUND: `SETTING_NOT_FOUND` or `ENVIRONMENT_NOT_FOUND`.