@productcraft/flags 0.0.0 → 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.
@@ -0,0 +1,1307 @@
1
+ import { FlagsClient, setOverride } from './chunk-UI25HRYK.js';
2
+ export { signWebhook } from '@productcraft/core';
3
+
4
+ var ROUTES = [
5
+ { op: "webhooks.eventTypes.list", method: "GET", pattern: /^\/v1\/workspaces\/[^\/]+\/webhooks\/event-types$/, status: 200, contentType: "application/json", body: {
6
+ data: [
7
+ {
8
+ category: "Users",
9
+ description: "A user signed up or was created by an admin.",
10
+ example: {},
11
+ type: "config.published"
12
+ }
13
+ ]
14
+ } },
15
+ { op: "webhooks.endpoints.create", method: "POST", pattern: /^\/v1\/workspaces\/[^\/]+\/webhooks\/endpoints$/, status: 201, contentType: "application/json", body: {
16
+ config_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
17
+ consecutive_failures: 1,
18
+ created_at: "2026-01-01T00:00:00.000Z",
19
+ description: "Production receiver",
20
+ disabled_at: "2026-01-01T00:00:00.000Z",
21
+ disabled_reason: "manual",
22
+ enabled: true,
23
+ environment_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
24
+ event_types: [],
25
+ first_failure_at: "2026-01-01T00:00:00.000Z",
26
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
27
+ legacy_signature: true,
28
+ prev_signing_secret_active: true,
29
+ prev_signing_secret_expires_at: "2026-01-01T00:00:00.000Z",
30
+ project_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
31
+ scope_id: "string",
32
+ scope_type: "workspace",
33
+ signing_secret: "whsec_MfKQ9r8GKYqrTwjUPD8ILPZIo2LaLaSw",
34
+ signing_secret_hint: "x9Q=",
35
+ status: "enabled",
36
+ updated_at: "2026-01-01T00:00:00.000Z",
37
+ url: "https://api.acme.com/webhooks"
38
+ } },
39
+ { op: "webhooks.endpoints.list", method: "GET", pattern: /^\/v1\/workspaces\/[^\/]+\/webhooks\/endpoints$/, status: 200, contentType: "application/json", body: {
40
+ data: [
41
+ {
42
+ config_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
43
+ consecutive_failures: 1,
44
+ created_at: "2026-01-01T00:00:00.000Z",
45
+ description: "Production receiver",
46
+ disabled_at: "2026-01-01T00:00:00.000Z",
47
+ disabled_reason: "manual",
48
+ enabled: true,
49
+ environment_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
50
+ event_types: [],
51
+ first_failure_at: "2026-01-01T00:00:00.000Z",
52
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
53
+ legacy_signature: true,
54
+ prev_signing_secret_active: true,
55
+ prev_signing_secret_expires_at: "2026-01-01T00:00:00.000Z",
56
+ project_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
57
+ scope_id: "string",
58
+ scope_type: "workspace",
59
+ signing_secret_hint: "x9Q=",
60
+ status: "enabled",
61
+ updated_at: "2026-01-01T00:00:00.000Z",
62
+ url: "https://api.acme.com/webhooks"
63
+ }
64
+ ],
65
+ pagination: { next_cursor: null, has_more: false }
66
+ } },
67
+ { op: "webhooks.events.list", method: "GET", pattern: /^\/v1\/workspaces\/[^\/]+\/webhooks\/events$/, status: 200, contentType: "application/json", body: {
68
+ data: [
69
+ {
70
+ config_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
71
+ created_at: "2026-01-01T00:00:00.000Z",
72
+ deliveries: [
73
+ {
74
+ attempt_number: 1,
75
+ attempted_at: "2026-01-01T00:00:00.000Z",
76
+ endpoint_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
77
+ next_attempt_at: "2026-01-01T00:00:00.000Z",
78
+ status_code: 1,
79
+ succeeded: true
80
+ }
81
+ ],
82
+ environment_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
83
+ id: "evt_3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f",
84
+ payload: {},
85
+ project_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
86
+ status: "pending",
87
+ test: true,
88
+ type: "config.published"
89
+ }
90
+ ],
91
+ pagination: { next_cursor: null, has_more: false }
92
+ } },
93
+ { op: "projects.create", method: "POST", pattern: /^\/v1\/workspaces\/[^\/]+\/projects$/, status: 201, contentType: "application/json", body: {
94
+ configs: [
95
+ {
96
+ created_at: "2026-01-01T00:00:00.000Z",
97
+ description: "",
98
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
99
+ key: "main",
100
+ name: "Main",
101
+ ordinal: 0,
102
+ project_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
103
+ updated_at: "2026-01-01T00:00:00.000Z",
104
+ workspace_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b"
105
+ }
106
+ ],
107
+ created_at: "2026-01-01T00:00:00.000Z",
108
+ description: "",
109
+ environments: [
110
+ {
111
+ color: "#c92a2a",
112
+ created_at: "2026-01-01T00:00:00.000Z",
113
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
114
+ key: "production",
115
+ name: "Production",
116
+ ordinal: 1,
117
+ project_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
118
+ protected: true,
119
+ require_note: false,
120
+ updated_at: "2026-01-01T00:00:00.000Z",
121
+ workspace_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b"
122
+ }
123
+ ],
124
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
125
+ name: "Storefront",
126
+ ordinal: 0,
127
+ updated_at: "2026-01-01T00:00:00.000Z",
128
+ workspace_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b"
129
+ } },
130
+ { op: "projects.list", method: "GET", pattern: /^\/v1\/workspaces\/[^\/]+\/projects$/, status: 200, contentType: "application/json", body: {
131
+ data: [
132
+ {
133
+ configs: [
134
+ {
135
+ created_at: "2026-01-01T00:00:00.000Z",
136
+ description: "",
137
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
138
+ key: "main",
139
+ name: "Main",
140
+ ordinal: 0,
141
+ project_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
142
+ updated_at: "2026-01-01T00:00:00.000Z",
143
+ workspace_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b"
144
+ }
145
+ ],
146
+ created_at: "2026-01-01T00:00:00.000Z",
147
+ description: "",
148
+ environments: [
149
+ {
150
+ color: "#c92a2a",
151
+ created_at: "2026-01-01T00:00:00.000Z",
152
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
153
+ key: "production",
154
+ name: "Production",
155
+ ordinal: 1,
156
+ project_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
157
+ protected: true,
158
+ require_note: false,
159
+ updated_at: "2026-01-01T00:00:00.000Z",
160
+ workspace_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b"
161
+ }
162
+ ],
163
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
164
+ name: "Storefront",
165
+ ordinal: 0,
166
+ updated_at: "2026-01-01T00:00:00.000Z",
167
+ workspace_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b"
168
+ }
169
+ ],
170
+ pagination: { next_cursor: null, has_more: false }
171
+ } },
172
+ { op: "imports.create", method: "POST", pattern: /^\/v1\/workspaces\/[^\/]+\/imports$/, status: 200, contentType: "application/json", body: {
173
+ configcat_product_id: "08d8a0b0-0000-4c1f-8a1c-1a2b3c4d5e6f",
174
+ dry_run: true,
175
+ project: {
176
+ configs: [
177
+ {
178
+ created_at: "2026-01-01T00:00:00.000Z",
179
+ description: "",
180
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
181
+ key: "main",
182
+ name: "Main",
183
+ ordinal: 0,
184
+ project_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
185
+ updated_at: "2026-01-01T00:00:00.000Z",
186
+ workspace_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b"
187
+ }
188
+ ],
189
+ created_at: "2026-01-01T00:00:00.000Z",
190
+ description: "",
191
+ environments: [
192
+ {
193
+ color: "#c92a2a",
194
+ created_at: "2026-01-01T00:00:00.000Z",
195
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
196
+ key: "production",
197
+ name: "Production",
198
+ ordinal: 1,
199
+ project_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
200
+ protected: true,
201
+ require_note: false,
202
+ updated_at: "2026-01-01T00:00:00.000Z",
203
+ workspace_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b"
204
+ }
205
+ ],
206
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
207
+ name: "Storefront",
208
+ ordinal: 0,
209
+ updated_at: "2026-01-01T00:00:00.000Z",
210
+ workspace_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b"
211
+ },
212
+ report: {
213
+ counts: { configs: 1, environments: 2, rules: 9, segments: 2, settings: 12 },
214
+ mapped: [
215
+ {
216
+ config: "main",
217
+ key: "new_checkout",
218
+ name: "New checkout",
219
+ source: "1234",
220
+ type: "setting"
221
+ }
222
+ ],
223
+ unsupported: [
224
+ {
225
+ config: "Main",
226
+ environment: "Production",
227
+ reason: 'The ConfigCat comparator "regexMatches" has no Flags equivalent.',
228
+ rule_index: 1,
229
+ segment: null,
230
+ setting_key: "new_checkout"
231
+ }
232
+ ],
233
+ warnings: [
234
+ {
235
+ code: "predefined_variations",
236
+ message: "Flags has no predefined variations yet: these were imported as plain values."
237
+ }
238
+ ]
239
+ }
240
+ } },
241
+ { op: "limits.retrieve", method: "GET", pattern: /^\/v1\/workspaces\/[^\/]+\/limits$/, status: 200, contentType: "application/json", body: {
242
+ limits: [{ limit: "projects", max: 3, scope: "workspace" }],
243
+ usage: {
244
+ per_project: [
245
+ {
246
+ configs: 1,
247
+ environments: 2,
248
+ name: "Storefront",
249
+ project_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
250
+ segments: 0
251
+ }
252
+ ],
253
+ projects: 1
254
+ }
255
+ } },
256
+ { op: "stats.retrieve", method: "GET", pattern: /^\/v1\/workspaces\/[^\/]+\/stats$/, status: 200, contentType: "application/json", body: {
257
+ changes_last_week: 12,
258
+ configs: 2,
259
+ history_usage: [
260
+ {
261
+ bytes: 524288,
262
+ max_bytes: 209715200,
263
+ max_rows: 5e4,
264
+ name: "Storefront",
265
+ project_id: "3f9a1c52-7b1e-4d4a-9f0e-2a6c8b1d5e70",
266
+ rows: 1240,
267
+ warning: false
268
+ }
269
+ ],
270
+ last_change_at: "2026-11-10T09:30:00.000Z",
271
+ projects: 1,
272
+ segments: 4,
273
+ settings: 37
274
+ } },
275
+ { op: "webhooks.endpoints.rotateSecret", method: "POST", pattern: /^\/v1\/workspaces\/[^\/]+\/webhooks\/endpoints\/[^\/]+\/rotate-secret$/, status: 200, contentType: "application/json", body: {
276
+ config_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
277
+ consecutive_failures: 1,
278
+ created_at: "2026-01-01T00:00:00.000Z",
279
+ description: "Production receiver",
280
+ disabled_at: "2026-01-01T00:00:00.000Z",
281
+ disabled_reason: "manual",
282
+ enabled: true,
283
+ environment_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
284
+ event_types: [],
285
+ first_failure_at: "2026-01-01T00:00:00.000Z",
286
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
287
+ legacy_signature: true,
288
+ prev_signing_secret_active: true,
289
+ prev_signing_secret_expires_at: "2026-01-01T00:00:00.000Z",
290
+ project_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
291
+ scope_id: "string",
292
+ scope_type: "workspace",
293
+ signing_secret: "whsec_MfKQ9r8GKYqrTwjUPD8ILPZIo2LaLaSw",
294
+ signing_secret_hint: "x9Q=",
295
+ status: "enabled",
296
+ updated_at: "2026-01-01T00:00:00.000Z",
297
+ url: "https://api.acme.com/webhooks"
298
+ } },
299
+ { op: "projects.changes.export", method: "GET", pattern: /^\/v1\/workspaces\/[^\/]+\/projects\/[^\/]+\/changes\/export$/, status: 200, contentType: "application/x-ndjson", body: "" },
300
+ { op: "webhooks.endpoints.test", method: "POST", pattern: /^\/v1\/workspaces\/[^\/]+\/webhooks\/endpoints\/[^\/]+\/test$/, status: 200, contentType: "application/json", body: {
301
+ attempt_number: 1,
302
+ attempted_at: "2026-01-01T00:00:00.000Z",
303
+ endpoint_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
304
+ error_message: "request timed out",
305
+ event_id: "evt_3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f",
306
+ event_type: "user.created",
307
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
308
+ latency_ms: 1,
309
+ response_body: "string",
310
+ status_code: 1,
311
+ succeeded: true,
312
+ trigger: "automatic",
313
+ url: "https://example.com"
314
+ } },
315
+ { op: "webhooks.events.replay", method: "POST", pattern: /^\/v1\/workspaces\/[^\/]+\/webhooks\/events\/[^\/]+\/replay$/, status: 200, contentType: "application/json", body: {
316
+ attempts: [
317
+ {
318
+ attempt_number: 1,
319
+ attempted_at: "2026-01-01T00:00:00.000Z",
320
+ endpoint_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
321
+ error_message: "request timed out",
322
+ event_id: "evt_3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f",
323
+ event_type: "user.created",
324
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
325
+ latency_ms: 1,
326
+ response_body: "string",
327
+ status_code: 1,
328
+ succeeded: true,
329
+ trigger: "automatic",
330
+ url: "https://example.com"
331
+ }
332
+ ],
333
+ event_id: "string"
334
+ } },
335
+ { op: "projects.environments.create", method: "POST", pattern: /^\/v1\/workspaces\/[^\/]+\/projects\/[^\/]+\/environments$/, status: 201, contentType: "application/json", body: {
336
+ color: "#c92a2a",
337
+ created_at: "2026-01-01T00:00:00.000Z",
338
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
339
+ key: "production",
340
+ name: "Production",
341
+ ordinal: 1,
342
+ project_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
343
+ protected: true,
344
+ require_note: false,
345
+ updated_at: "2026-01-01T00:00:00.000Z",
346
+ workspace_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b"
347
+ } },
348
+ { op: "projects.environments.list", method: "GET", pattern: /^\/v1\/workspaces\/[^\/]+\/projects\/[^\/]+\/environments$/, status: 200, contentType: "application/json", body: {
349
+ data: [
350
+ {
351
+ color: "#c92a2a",
352
+ created_at: "2026-01-01T00:00:00.000Z",
353
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
354
+ key: "production",
355
+ name: "Production",
356
+ ordinal: 1,
357
+ project_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
358
+ protected: true,
359
+ require_note: false,
360
+ updated_at: "2026-01-01T00:00:00.000Z",
361
+ workspace_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b"
362
+ }
363
+ ]
364
+ } },
365
+ { op: "segments.revealConfidential", method: "GET", pattern: /^\/v1\/workspaces\/[^\/]+\/segments\/[^\/]+\/confidential$/, status: 200, contentType: "application/json", body: {
366
+ data: [
367
+ {
368
+ attribute: "email",
369
+ comparator: "ends_with_any_hashed",
370
+ condition_index: 0,
371
+ list_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
372
+ revealable: true,
373
+ rule_index: 0,
374
+ values: ["@acme.test"]
375
+ }
376
+ ]
377
+ } },
378
+ { op: "webhooks.endpoints.delete", method: "DELETE", pattern: /^\/v1\/workspaces\/[^\/]+\/webhooks\/endpoints\/[^\/]+$/, status: 204, contentType: null, body: null },
379
+ { op: "webhooks.endpoints.retrieve", method: "GET", pattern: /^\/v1\/workspaces\/[^\/]+\/webhooks\/endpoints\/[^\/]+$/, status: 200, contentType: "application/json", body: {
380
+ config_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
381
+ consecutive_failures: 1,
382
+ created_at: "2026-01-01T00:00:00.000Z",
383
+ description: "Production receiver",
384
+ disabled_at: "2026-01-01T00:00:00.000Z",
385
+ disabled_reason: "manual",
386
+ enabled: true,
387
+ environment_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
388
+ event_types: [],
389
+ first_failure_at: "2026-01-01T00:00:00.000Z",
390
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
391
+ legacy_signature: true,
392
+ prev_signing_secret_active: true,
393
+ prev_signing_secret_expires_at: "2026-01-01T00:00:00.000Z",
394
+ project_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
395
+ scope_id: "string",
396
+ scope_type: "workspace",
397
+ signing_secret_hint: "x9Q=",
398
+ status: "enabled",
399
+ updated_at: "2026-01-01T00:00:00.000Z",
400
+ url: "https://api.acme.com/webhooks"
401
+ } },
402
+ { op: "webhooks.endpoints.update", method: "PATCH", pattern: /^\/v1\/workspaces\/[^\/]+\/webhooks\/endpoints\/[^\/]+$/, status: 200, contentType: "application/json", body: {
403
+ config_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
404
+ consecutive_failures: 1,
405
+ created_at: "2026-01-01T00:00:00.000Z",
406
+ description: "Production receiver",
407
+ disabled_at: "2026-01-01T00:00:00.000Z",
408
+ disabled_reason: "manual",
409
+ enabled: true,
410
+ environment_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
411
+ event_types: [],
412
+ first_failure_at: "2026-01-01T00:00:00.000Z",
413
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
414
+ legacy_signature: true,
415
+ prev_signing_secret_active: true,
416
+ prev_signing_secret_expires_at: "2026-01-01T00:00:00.000Z",
417
+ project_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
418
+ scope_id: "string",
419
+ scope_type: "workspace",
420
+ signing_secret_hint: "x9Q=",
421
+ status: "enabled",
422
+ updated_at: "2026-01-01T00:00:00.000Z",
423
+ url: "https://api.acme.com/webhooks"
424
+ } },
425
+ { op: "projects.segments.create", method: "POST", pattern: /^\/v1\/workspaces\/[^\/]+\/projects\/[^\/]+\/segments$/, status: 201, contentType: "application/json", body: {
426
+ conditions: [
427
+ {
428
+ user: {
429
+ attribute: "app_version",
430
+ comparator: "semver_gte",
431
+ list_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
432
+ values: ["2.0.0"],
433
+ values_add: ["@beta.test"],
434
+ values_hashed: ["string"],
435
+ values_remove: ["string"]
436
+ }
437
+ }
438
+ ],
439
+ created_at: "2026-01-01T00:00:00.000Z",
440
+ created_by: "string",
441
+ description: "",
442
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
443
+ key: "qa_staff",
444
+ name: "QA staff",
445
+ project_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
446
+ seed: "qa_staff",
447
+ updated_at: "2026-01-01T00:00:00.000Z",
448
+ usage_count: 2,
449
+ used_by: [
450
+ {
451
+ config_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
452
+ config_key: "main",
453
+ environment_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
454
+ environment_key: "production",
455
+ setting_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
456
+ setting_key: "new_checkout"
457
+ }
458
+ ],
459
+ version: 1,
460
+ workspace_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b"
461
+ } },
462
+ { op: "projects.segments.list", method: "GET", pattern: /^\/v1\/workspaces\/[^\/]+\/projects\/[^\/]+\/segments$/, status: 200, contentType: "application/json", body: {
463
+ data: [
464
+ {
465
+ conditions: [
466
+ {
467
+ user: {
468
+ attribute: "app_version",
469
+ comparator: "semver_gte",
470
+ list_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
471
+ values: ["2.0.0"],
472
+ values_add: ["@beta.test"],
473
+ values_hashed: ["string"],
474
+ values_remove: ["string"]
475
+ }
476
+ }
477
+ ],
478
+ created_at: "2026-01-01T00:00:00.000Z",
479
+ created_by: "string",
480
+ description: "",
481
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
482
+ key: "qa_staff",
483
+ name: "QA staff",
484
+ project_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
485
+ seed: "qa_staff",
486
+ updated_at: "2026-01-01T00:00:00.000Z",
487
+ usage_count: 2,
488
+ version: 1,
489
+ workspace_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b"
490
+ }
491
+ ],
492
+ pagination: { next_cursor: null, has_more: false }
493
+ } },
494
+ { op: "configs.settings.create", method: "POST", pattern: /^\/v1\/workspaces\/[^\/]+\/configs\/[^\/]+\/settings$/, status: 201, contentType: "application/json", body: {
495
+ config_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
496
+ created_at: "2026-01-01T00:00:00.000Z",
497
+ created_by: "string",
498
+ dependents: {
499
+ prerequisite_of: [
500
+ {
501
+ environment_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
502
+ environment_key: "production",
503
+ setting_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
504
+ setting_key: "new_checkout"
505
+ }
506
+ ],
507
+ segments_used: ["qa_staff"]
508
+ },
509
+ description: "",
510
+ hint: "",
511
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
512
+ key: "new_checkout",
513
+ lifecycle: "temporary",
514
+ name: "New checkout",
515
+ ordinal: 0,
516
+ owner_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
517
+ project_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
518
+ seed: "new_checkout",
519
+ tags: ["checkout"],
520
+ type: "boolean",
521
+ updated_at: "2026-01-01T00:00:00.000Z",
522
+ values: [
523
+ {
524
+ environment_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
525
+ environment_key: "production",
526
+ percentage_attribute: null,
527
+ percentages: [{ percentage: 10, value: true }],
528
+ rules: [{ conditions: [null], serve: true }],
529
+ setting_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
530
+ updated_at: "2026-01-01T00:00:00.000Z",
531
+ updated_by: { id: "string", type: "user" },
532
+ value: false,
533
+ version: 3
534
+ }
535
+ ],
536
+ workspace_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b"
537
+ } },
538
+ { op: "configs.settings.list", method: "GET", pattern: /^\/v1\/workspaces\/[^\/]+\/configs\/[^\/]+\/settings$/, status: 200, contentType: "application/json", body: {
539
+ data: [
540
+ {
541
+ config_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
542
+ created_at: "2026-01-01T00:00:00.000Z",
543
+ created_by: "string",
544
+ description: "",
545
+ hint: "",
546
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
547
+ key: "new_checkout",
548
+ lifecycle: "temporary",
549
+ name: "New checkout",
550
+ ordinal: 0,
551
+ owner_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
552
+ project_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
553
+ seed: "new_checkout",
554
+ tags: ["checkout"],
555
+ type: "boolean",
556
+ updated_at: "2026-01-01T00:00:00.000Z",
557
+ workspace_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b"
558
+ }
559
+ ],
560
+ pagination: { next_cursor: null, has_more: false }
561
+ } },
562
+ { op: "projects.changes.list", method: "GET", pattern: /^\/v1\/workspaces\/[^\/]+\/projects\/[^\/]+\/changes$/, status: 200, contentType: "application/json", body: {
563
+ data: [
564
+ {
565
+ action: "setting_value.updated",
566
+ actor: {
567
+ client_id: "string",
568
+ id: "string",
569
+ label: "ada@example.com",
570
+ on_behalf_of_user_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
571
+ type: "user"
572
+ },
573
+ config_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
574
+ created_at: "2026-01-01T00:00:00.000Z",
575
+ diff_too_large: true,
576
+ entity_id: "5b1f0c2e-8d4a-4e6b-9f3a-1c2d3e4f5a6b",
577
+ entity_key: "new_checkout",
578
+ entity_type: "setting_value",
579
+ environment_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
580
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
581
+ note: "Ticket FLAG-142",
582
+ project_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
583
+ reverts_change_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
584
+ revisions: [
585
+ {
586
+ config_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
587
+ environment_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
588
+ previous_url: "https://example.com",
589
+ revision: 7,
590
+ url: "https://api.flags.productcraft.co/v1/workspaces/9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b/configs/1f0c\u2026/environments/7a2e\u2026/revisions/7"
591
+ }
592
+ ],
593
+ size_bytes: 1,
594
+ summary: ["Production: value false \u2192 true"]
595
+ }
596
+ ],
597
+ pagination: { next_cursor: null, has_more: false }
598
+ } },
599
+ { op: "projects.configs.create", method: "POST", pattern: /^\/v1\/workspaces\/[^\/]+\/projects\/[^\/]+\/configs$/, status: 201, contentType: "application/json", body: {
600
+ created_at: "2026-01-01T00:00:00.000Z",
601
+ description: "",
602
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
603
+ key: "main",
604
+ name: "Main",
605
+ ordinal: 0,
606
+ project_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
607
+ updated_at: "2026-01-01T00:00:00.000Z",
608
+ workspace_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b"
609
+ } },
610
+ { op: "projects.configs.list", method: "GET", pattern: /^\/v1\/workspaces\/[^\/]+\/projects\/[^\/]+\/configs$/, status: 200, contentType: "application/json", body: {
611
+ data: [
612
+ {
613
+ created_at: "2026-01-01T00:00:00.000Z",
614
+ description: "",
615
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
616
+ key: "main",
617
+ name: "Main",
618
+ ordinal: 0,
619
+ project_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
620
+ updated_at: "2026-01-01T00:00:00.000Z",
621
+ workspace_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b"
622
+ }
623
+ ],
624
+ pagination: { next_cursor: null, has_more: false }
625
+ } },
626
+ { op: "configs.compare", method: "GET", pattern: /^\/v1\/workspaces\/[^\/]+\/configs\/[^\/]+\/compare$/, status: 200, contentType: "application/json", body: {
627
+ data: [
628
+ {
629
+ differs: true,
630
+ setting: {
631
+ config_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
632
+ created_at: "2026-01-01T00:00:00.000Z",
633
+ created_by: "string",
634
+ description: "",
635
+ hint: "",
636
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
637
+ key: "new_checkout",
638
+ lifecycle: "temporary",
639
+ name: "New checkout",
640
+ ordinal: 0,
641
+ owner_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
642
+ project_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
643
+ seed: "new_checkout",
644
+ tags: ["checkout"],
645
+ type: "boolean",
646
+ updated_at: "2026-01-01T00:00:00.000Z",
647
+ workspace_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b"
648
+ },
649
+ values: [
650
+ {
651
+ environment_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
652
+ environment_key: "production",
653
+ percentage_attribute: null,
654
+ percentages: [{ percentage: 10, value: true }],
655
+ rules: [{ conditions: null, serve: null }],
656
+ setting_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
657
+ updated_at: "2026-01-01T00:00:00.000Z",
658
+ updated_by: { id: "string", type: null },
659
+ value: false,
660
+ version: 3
661
+ }
662
+ ]
663
+ }
664
+ ],
665
+ environments: [{ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b", key: "production", name: "Production" }],
666
+ pagination: { next_cursor: null, has_more: false }
667
+ } },
668
+ { op: "webhooks.events.retrieve", method: "GET", pattern: /^\/v1\/workspaces\/[^\/]+\/webhooks\/events\/[^\/]+$/, status: 200, contentType: "application/json", body: {
669
+ attempts: [
670
+ {
671
+ attempt_number: 1,
672
+ attempted_at: "2026-01-01T00:00:00.000Z",
673
+ endpoint_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
674
+ error_message: "request timed out",
675
+ event_id: "evt_3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f",
676
+ event_type: "user.created",
677
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
678
+ latency_ms: 1,
679
+ response_body: "string",
680
+ status_code: 1,
681
+ succeeded: true,
682
+ trigger: "automatic",
683
+ url: "https://example.com"
684
+ }
685
+ ],
686
+ config_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
687
+ created_at: "2026-01-01T00:00:00.000Z",
688
+ deliveries: [
689
+ {
690
+ attempt_number: 1,
691
+ attempted_at: "2026-01-01T00:00:00.000Z",
692
+ endpoint_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
693
+ next_attempt_at: "2026-01-01T00:00:00.000Z",
694
+ status_code: 1,
695
+ succeeded: true
696
+ }
697
+ ],
698
+ environment_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
699
+ id: "evt_3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f",
700
+ payload: {},
701
+ project_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
702
+ status: "pending",
703
+ test: true,
704
+ type: "config.published"
705
+ } },
706
+ { op: "changes.revert", method: "POST", pattern: /^\/v1\/workspaces\/[^\/]+\/changes\/[^\/]+\/revert$/, status: 201, contentType: "application/json", body: {
707
+ action: "setting_value.updated",
708
+ actor: {
709
+ client_id: "string",
710
+ id: "string",
711
+ label: "ada@example.com",
712
+ on_behalf_of_user_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
713
+ type: "user"
714
+ },
715
+ after: {},
716
+ before: {},
717
+ config_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
718
+ created_at: "2026-01-01T00:00:00.000Z",
719
+ diff: [{ op: "add", path: "/rules/1/percentages/0/percentage", value: 25 }],
720
+ diff_too_large: true,
721
+ entity_id: "5b1f0c2e-8d4a-4e6b-9f3a-1c2d3e4f5a6b",
722
+ entity_key: "new_checkout",
723
+ entity_type: "setting_value",
724
+ environment_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
725
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
726
+ note: "Ticket FLAG-142",
727
+ project_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
728
+ reverts_change_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
729
+ revisions: [
730
+ {
731
+ config_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
732
+ environment_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
733
+ previous_url: "https://example.com",
734
+ revision: 7,
735
+ url: "https://api.flags.productcraft.co/v1/workspaces/9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b/configs/1f0c\u2026/environments/7a2e\u2026/revisions/7"
736
+ }
737
+ ],
738
+ size_bytes: 1,
739
+ summary: ["Production: value false \u2192 true"]
740
+ } },
741
+ { op: "projects.delete", method: "DELETE", pattern: /^\/v1\/workspaces\/[^\/]+\/projects\/[^\/]+$/, status: 204, contentType: null, body: null },
742
+ { op: "projects.retrieve", method: "GET", pattern: /^\/v1\/workspaces\/[^\/]+\/projects\/[^\/]+$/, status: 200, contentType: "application/json", body: {
743
+ configs: [
744
+ {
745
+ created_at: "2026-01-01T00:00:00.000Z",
746
+ description: "",
747
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
748
+ key: "main",
749
+ name: "Main",
750
+ ordinal: 0,
751
+ project_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
752
+ updated_at: "2026-01-01T00:00:00.000Z",
753
+ workspace_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b"
754
+ }
755
+ ],
756
+ created_at: "2026-01-01T00:00:00.000Z",
757
+ description: "",
758
+ environments: [
759
+ {
760
+ color: "#c92a2a",
761
+ created_at: "2026-01-01T00:00:00.000Z",
762
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
763
+ key: "production",
764
+ name: "Production",
765
+ ordinal: 1,
766
+ project_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
767
+ protected: true,
768
+ require_note: false,
769
+ updated_at: "2026-01-01T00:00:00.000Z",
770
+ workspace_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b"
771
+ }
772
+ ],
773
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
774
+ name: "Storefront",
775
+ ordinal: 0,
776
+ updated_at: "2026-01-01T00:00:00.000Z",
777
+ workspace_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b"
778
+ } },
779
+ { op: "projects.update", method: "PATCH", pattern: /^\/v1\/workspaces\/[^\/]+\/projects\/[^\/]+$/, status: 200, contentType: "application/json", body: {
780
+ configs: [
781
+ {
782
+ created_at: "2026-01-01T00:00:00.000Z",
783
+ description: "",
784
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
785
+ key: "main",
786
+ name: "Main",
787
+ ordinal: 0,
788
+ project_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
789
+ updated_at: "2026-01-01T00:00:00.000Z",
790
+ workspace_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b"
791
+ }
792
+ ],
793
+ created_at: "2026-01-01T00:00:00.000Z",
794
+ description: "",
795
+ environments: [
796
+ {
797
+ color: "#c92a2a",
798
+ created_at: "2026-01-01T00:00:00.000Z",
799
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
800
+ key: "production",
801
+ name: "Production",
802
+ ordinal: 1,
803
+ project_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
804
+ protected: true,
805
+ require_note: false,
806
+ updated_at: "2026-01-01T00:00:00.000Z",
807
+ workspace_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b"
808
+ }
809
+ ],
810
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
811
+ name: "Storefront",
812
+ ordinal: 0,
813
+ updated_at: "2026-01-01T00:00:00.000Z",
814
+ workspace_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b"
815
+ } },
816
+ { op: "segments.delete", method: "DELETE", pattern: /^\/v1\/workspaces\/[^\/]+\/segments\/[^\/]+$/, status: 204, contentType: null, body: null },
817
+ { op: "segments.retrieve", method: "GET", pattern: /^\/v1\/workspaces\/[^\/]+\/segments\/[^\/]+$/, status: 200, contentType: "application/json", body: {
818
+ conditions: [
819
+ {
820
+ user: {
821
+ attribute: "app_version",
822
+ comparator: "semver_gte",
823
+ list_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
824
+ values: ["2.0.0"],
825
+ values_add: ["@beta.test"],
826
+ values_hashed: ["string"],
827
+ values_remove: ["string"]
828
+ }
829
+ }
830
+ ],
831
+ created_at: "2026-01-01T00:00:00.000Z",
832
+ created_by: "string",
833
+ description: "",
834
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
835
+ key: "qa_staff",
836
+ name: "QA staff",
837
+ project_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
838
+ seed: "qa_staff",
839
+ updated_at: "2026-01-01T00:00:00.000Z",
840
+ usage_count: 2,
841
+ used_by: [
842
+ {
843
+ config_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
844
+ config_key: "main",
845
+ environment_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
846
+ environment_key: "production",
847
+ setting_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
848
+ setting_key: "new_checkout"
849
+ }
850
+ ],
851
+ version: 1,
852
+ workspace_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b"
853
+ } },
854
+ { op: "segments.update", method: "PATCH", pattern: /^\/v1\/workspaces\/[^\/]+\/segments\/[^\/]+$/, status: 200, contentType: "application/json", body: {
855
+ conditions: [
856
+ {
857
+ user: {
858
+ attribute: "app_version",
859
+ comparator: "semver_gte",
860
+ list_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
861
+ values: ["2.0.0"],
862
+ values_add: ["@beta.test"],
863
+ values_hashed: ["string"],
864
+ values_remove: ["string"]
865
+ }
866
+ }
867
+ ],
868
+ created_at: "2026-01-01T00:00:00.000Z",
869
+ created_by: "string",
870
+ description: "",
871
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
872
+ key: "qa_staff",
873
+ name: "QA staff",
874
+ project_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
875
+ seed: "qa_staff",
876
+ updated_at: "2026-01-01T00:00:00.000Z",
877
+ usage_count: 2,
878
+ used_by: [
879
+ {
880
+ config_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
881
+ config_key: "main",
882
+ environment_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
883
+ environment_key: "production",
884
+ setting_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
885
+ setting_key: "new_checkout"
886
+ }
887
+ ],
888
+ version: 1,
889
+ workspace_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b"
890
+ } },
891
+ { op: "settings.delete", method: "DELETE", pattern: /^\/v1\/workspaces\/[^\/]+\/settings\/[^\/]+$/, status: 204, contentType: null, body: null },
892
+ { op: "settings.retrieve", method: "GET", pattern: /^\/v1\/workspaces\/[^\/]+\/settings\/[^\/]+$/, status: 200, contentType: "application/json", body: {
893
+ config_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
894
+ created_at: "2026-01-01T00:00:00.000Z",
895
+ created_by: "string",
896
+ dependents: {
897
+ prerequisite_of: [
898
+ {
899
+ environment_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
900
+ environment_key: "production",
901
+ setting_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
902
+ setting_key: "new_checkout"
903
+ }
904
+ ],
905
+ segments_used: ["qa_staff"]
906
+ },
907
+ description: "",
908
+ hint: "",
909
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
910
+ key: "new_checkout",
911
+ lifecycle: "temporary",
912
+ name: "New checkout",
913
+ ordinal: 0,
914
+ owner_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
915
+ project_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
916
+ seed: "new_checkout",
917
+ tags: ["checkout"],
918
+ type: "boolean",
919
+ updated_at: "2026-01-01T00:00:00.000Z",
920
+ values: [
921
+ {
922
+ environment_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
923
+ environment_key: "production",
924
+ percentage_attribute: null,
925
+ percentages: [{ percentage: 10, value: true }],
926
+ rules: [{ conditions: [null], serve: true }],
927
+ setting_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
928
+ updated_at: "2026-01-01T00:00:00.000Z",
929
+ updated_by: { id: "string", type: "user" },
930
+ value: false,
931
+ version: 3
932
+ }
933
+ ],
934
+ workspace_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b"
935
+ } },
936
+ { op: "settings.update", method: "PATCH", pattern: /^\/v1\/workspaces\/[^\/]+\/settings\/[^\/]+$/, status: 200, contentType: "application/json", body: {
937
+ config_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
938
+ created_at: "2026-01-01T00:00:00.000Z",
939
+ created_by: "string",
940
+ dependents: {
941
+ prerequisite_of: [
942
+ {
943
+ environment_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
944
+ environment_key: "production",
945
+ setting_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
946
+ setting_key: "new_checkout"
947
+ }
948
+ ],
949
+ segments_used: ["qa_staff"]
950
+ },
951
+ description: "",
952
+ hint: "",
953
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
954
+ key: "new_checkout",
955
+ lifecycle: "temporary",
956
+ name: "New checkout",
957
+ ordinal: 0,
958
+ owner_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
959
+ project_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
960
+ seed: "new_checkout",
961
+ tags: ["checkout"],
962
+ type: "boolean",
963
+ updated_at: "2026-01-01T00:00:00.000Z",
964
+ values: [
965
+ {
966
+ environment_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
967
+ environment_key: "production",
968
+ percentage_attribute: null,
969
+ percentages: [{ percentage: 10, value: true }],
970
+ rules: [{ conditions: [null], serve: true }],
971
+ setting_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
972
+ updated_at: "2026-01-01T00:00:00.000Z",
973
+ updated_by: { id: "string", type: "user" },
974
+ value: false,
975
+ version: 3
976
+ }
977
+ ],
978
+ workspace_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b"
979
+ } },
980
+ { op: "changes.retrieve", method: "GET", pattern: /^\/v1\/workspaces\/[^\/]+\/changes\/[^\/]+$/, status: 200, contentType: "application/json", body: {
981
+ action: "setting_value.updated",
982
+ actor: {
983
+ client_id: "string",
984
+ id: "string",
985
+ label: "ada@example.com",
986
+ on_behalf_of_user_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
987
+ type: "user"
988
+ },
989
+ after: {},
990
+ before: {},
991
+ config_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
992
+ created_at: "2026-01-01T00:00:00.000Z",
993
+ diff: [{ op: "add", path: "/rules/1/percentages/0/percentage", value: 25 }],
994
+ diff_too_large: true,
995
+ entity_id: "5b1f0c2e-8d4a-4e6b-9f3a-1c2d3e4f5a6b",
996
+ entity_key: "new_checkout",
997
+ entity_type: "setting_value",
998
+ environment_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
999
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
1000
+ note: "Ticket FLAG-142",
1001
+ project_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
1002
+ reverts_change_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
1003
+ revisions: [
1004
+ {
1005
+ config_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
1006
+ environment_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
1007
+ previous_url: "https://example.com",
1008
+ revision: 7,
1009
+ url: "https://api.flags.productcraft.co/v1/workspaces/9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b/configs/1f0c\u2026/environments/7a2e\u2026/revisions/7"
1010
+ }
1011
+ ],
1012
+ size_bytes: 1,
1013
+ summary: ["Production: value false \u2192 true"]
1014
+ } },
1015
+ { op: "configs.delete", method: "DELETE", pattern: /^\/v1\/workspaces\/[^\/]+\/configs\/[^\/]+$/, status: 204, contentType: null, body: null },
1016
+ { op: "configs.retrieve", method: "GET", pattern: /^\/v1\/workspaces\/[^\/]+\/configs\/[^\/]+$/, status: 200, contentType: "application/json", body: {
1017
+ created_at: "2026-01-01T00:00:00.000Z",
1018
+ description: "",
1019
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
1020
+ key: "main",
1021
+ name: "Main",
1022
+ ordinal: 0,
1023
+ project_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
1024
+ updated_at: "2026-01-01T00:00:00.000Z",
1025
+ workspace_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b"
1026
+ } },
1027
+ { op: "configs.update", method: "PATCH", pattern: /^\/v1\/workspaces\/[^\/]+\/configs\/[^\/]+$/, status: 200, contentType: "application/json", body: {
1028
+ created_at: "2026-01-01T00:00:00.000Z",
1029
+ description: "",
1030
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
1031
+ key: "main",
1032
+ name: "Main",
1033
+ ordinal: 0,
1034
+ project_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
1035
+ updated_at: "2026-01-01T00:00:00.000Z",
1036
+ workspace_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b"
1037
+ } },
1038
+ { op: "configs.environments.sdkKeys.endGracePeriod", method: "DELETE", pattern: /^\/v1\/workspaces\/[^\/]+\/configs\/[^\/]+\/environments\/[^\/]+\/sdk-keys\/secondary$/, status: 200, contentType: "application/json", body: {
1039
+ data: [
1040
+ {
1041
+ created_at: "2026-01-01T00:00:00.000Z",
1042
+ expires_at: "2026-01-01T00:00:00.000Z",
1043
+ key_prefix: "pcf_sdk_4fQx",
1044
+ last4: "k9Zt",
1045
+ slot: "primary"
1046
+ }
1047
+ ]
1048
+ } },
1049
+ { op: "configs.environments.sdkKeys.reveal", method: "POST", pattern: /^\/v1\/workspaces\/[^\/]+\/configs\/[^\/]+\/environments\/[^\/]+\/sdk-keys\/reveal$/, status: 200, contentType: "application/json", body: {
1050
+ data: [
1051
+ {
1052
+ created_at: "2026-01-01T00:00:00.000Z",
1053
+ expires_at: "2026-01-01T00:00:00.000Z",
1054
+ key: "pcf_sdk_4fQxV2mB8cJ0nR7tW1yZ3aD5gH6kL9pS0q1Uk9Zt",
1055
+ key_prefix: "pcf_sdk_4fQx",
1056
+ last4: "k9Zt",
1057
+ slot: "primary"
1058
+ }
1059
+ ]
1060
+ } },
1061
+ { op: "configs.environments.sdkKeys.rotate", method: "POST", pattern: /^\/v1\/workspaces\/[^\/]+\/configs\/[^\/]+\/environments\/[^\/]+\/sdk-keys\/rotate$/, status: 200, contentType: "application/json", body: {
1062
+ data: [
1063
+ {
1064
+ created_at: "2026-01-01T00:00:00.000Z",
1065
+ expires_at: "2026-01-01T00:00:00.000Z",
1066
+ key_prefix: "pcf_sdk_4fQx",
1067
+ last4: "k9Zt",
1068
+ slot: "primary"
1069
+ }
1070
+ ]
1071
+ } },
1072
+ { op: "configs.environments.revisions.list", method: "GET", pattern: /^\/v1\/workspaces\/[^\/]+\/configs\/[^\/]+\/environments\/[^\/]+\/revisions$/, status: 200, contentType: "application/json", body: {
1073
+ data: [
1074
+ {
1075
+ change_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
1076
+ current: true,
1077
+ etag: "q8w4Yb0cJ0dY2t1vUo3n7A",
1078
+ generation: 1,
1079
+ published_at: "2026-01-01T00:00:00.000Z",
1080
+ revision: 2,
1081
+ size_bytes: 412
1082
+ }
1083
+ ],
1084
+ pagination: { next_cursor: null, has_more: false }
1085
+ } },
1086
+ { op: "configs.environments.evaluate", method: "POST", pattern: /^\/v1\/workspaces\/[^\/]+\/configs\/[^\/]+\/environments\/[^\/]+\/evaluate$/, status: 200, contentType: "application/json", body: {
1087
+ data: [
1088
+ {
1089
+ error_code: null,
1090
+ error_message: null,
1091
+ is_default_value: false,
1092
+ key: "new_checkout",
1093
+ percentage_index: 0,
1094
+ reason: "SPLIT",
1095
+ rule_index: 1,
1096
+ value: true,
1097
+ variant: "rule:1/pct:0",
1098
+ warnings: [
1099
+ {
1100
+ attribute: "app_version",
1101
+ code: "missing_attribute",
1102
+ key: "new_checkout",
1103
+ message: 'The user has no attribute "app_version".',
1104
+ rule_index: 1
1105
+ }
1106
+ ]
1107
+ }
1108
+ ],
1109
+ revision: 42
1110
+ } },
1111
+ { op: "configs.environments.sdkKeys.list", method: "GET", pattern: /^\/v1\/workspaces\/[^\/]+\/configs\/[^\/]+\/environments\/[^\/]+\/sdk-keys$/, status: 200, contentType: "application/json", body: {
1112
+ data: [
1113
+ {
1114
+ created_at: "2026-01-01T00:00:00.000Z",
1115
+ expires_at: "2026-01-01T00:00:00.000Z",
1116
+ key_prefix: "pcf_sdk_4fQx",
1117
+ last4: "k9Zt",
1118
+ slot: "primary"
1119
+ }
1120
+ ]
1121
+ } },
1122
+ { op: "settings.values.revealConfidential", method: "GET", pattern: /^\/v1\/workspaces\/[^\/]+\/settings\/[^\/]+\/values\/[^\/]+\/confidential$/, status: 200, contentType: "application/json", body: {
1123
+ data: [
1124
+ {
1125
+ attribute: "email",
1126
+ comparator: "ends_with_any_hashed",
1127
+ condition_index: 0,
1128
+ list_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
1129
+ revealable: true,
1130
+ rule_index: 0,
1131
+ values: ["@acme.test"]
1132
+ }
1133
+ ]
1134
+ } },
1135
+ { op: "configs.environments.values.list", method: "GET", pattern: /^\/v1\/workspaces\/[^\/]+\/configs\/[^\/]+\/environments\/[^\/]+\/values$/, status: 200, contentType: "application/json", body: {
1136
+ data: [
1137
+ {
1138
+ setting: {
1139
+ config_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
1140
+ created_at: "2026-01-01T00:00:00.000Z",
1141
+ created_by: "string",
1142
+ description: "",
1143
+ hint: "",
1144
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
1145
+ key: "new_checkout",
1146
+ lifecycle: "temporary",
1147
+ name: "New checkout",
1148
+ ordinal: 0,
1149
+ owner_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
1150
+ project_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
1151
+ seed: "new_checkout",
1152
+ tags: ["checkout"],
1153
+ type: "boolean",
1154
+ updated_at: "2026-01-01T00:00:00.000Z",
1155
+ workspace_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b"
1156
+ },
1157
+ states: {
1158
+ development: { has_rules: false, value: true },
1159
+ production: { has_rules: true, value: false }
1160
+ },
1161
+ value: {
1162
+ environment_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
1163
+ environment_key: "production",
1164
+ percentage_attribute: null,
1165
+ percentages: [{ percentage: 10, value: true }],
1166
+ rules: [{ conditions: null, serve: null }],
1167
+ setting_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
1168
+ updated_at: "2026-01-01T00:00:00.000Z",
1169
+ updated_by: { id: "string", type: null },
1170
+ value: false,
1171
+ version: 3
1172
+ }
1173
+ }
1174
+ ],
1175
+ pagination: { next_cursor: null, has_more: false }
1176
+ } },
1177
+ { op: "configs.environments.copy", method: "POST", pattern: /^\/v1\/workspaces\/[^\/]+\/configs\/[^\/]+\/environments\/[^\/]+\/copy$/, status: 200, contentType: "application/json", body: {
1178
+ data: [
1179
+ {
1180
+ change_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
1181
+ key: "new_checkout",
1182
+ setting_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
1183
+ version: 4
1184
+ }
1185
+ ],
1186
+ revision: 12
1187
+ } },
1188
+ { op: "projects.environments.delete", method: "DELETE", pattern: /^\/v1\/workspaces\/[^\/]+\/projects\/[^\/]+\/environments\/[^\/]+$/, status: 204, contentType: null, body: null },
1189
+ { op: "projects.environments.retrieve", method: "GET", pattern: /^\/v1\/workspaces\/[^\/]+\/projects\/[^\/]+\/environments\/[^\/]+$/, status: 200, contentType: "application/json", body: {
1190
+ color: "#c92a2a",
1191
+ created_at: "2026-01-01T00:00:00.000Z",
1192
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
1193
+ key: "production",
1194
+ name: "Production",
1195
+ ordinal: 1,
1196
+ project_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
1197
+ protected: true,
1198
+ require_note: false,
1199
+ updated_at: "2026-01-01T00:00:00.000Z",
1200
+ workspace_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b"
1201
+ } },
1202
+ { op: "projects.environments.update", method: "PATCH", pattern: /^\/v1\/workspaces\/[^\/]+\/projects\/[^\/]+\/environments\/[^\/]+$/, status: 200, contentType: "application/json", body: {
1203
+ color: "#c92a2a",
1204
+ created_at: "2026-01-01T00:00:00.000Z",
1205
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
1206
+ key: "production",
1207
+ name: "Production",
1208
+ ordinal: 1,
1209
+ project_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
1210
+ protected: true,
1211
+ require_note: false,
1212
+ updated_at: "2026-01-01T00:00:00.000Z",
1213
+ workspace_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b"
1214
+ } },
1215
+ { op: "settings.values.replace", method: "PUT", pattern: /^\/v1\/workspaces\/[^\/]+\/settings\/[^\/]+\/values\/[^\/]+$/, status: 200, contentType: "application/json", body: {
1216
+ environment_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
1217
+ environment_key: "production",
1218
+ percentage_attribute: null,
1219
+ percentages: [{ percentage: 10, value: true }],
1220
+ rules: [{ conditions: [{ user: null }], serve: true }],
1221
+ setting_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
1222
+ updated_at: "2026-01-01T00:00:00.000Z",
1223
+ updated_by: { id: "string", type: "user" },
1224
+ value: false,
1225
+ version: 3
1226
+ } },
1227
+ { op: "settings.values.retrieve", method: "GET", pattern: /^\/v1\/workspaces\/[^\/]+\/settings\/[^\/]+\/values\/[^\/]+$/, status: 200, contentType: "application/json", body: {
1228
+ environment_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
1229
+ environment_key: "production",
1230
+ percentage_attribute: null,
1231
+ percentages: [{ percentage: 10, value: true }],
1232
+ rules: [{ conditions: [{ user: null }], serve: true }],
1233
+ setting_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
1234
+ updated_at: "2026-01-01T00:00:00.000Z",
1235
+ updated_by: { id: "string", type: "user" },
1236
+ value: false,
1237
+ version: 3
1238
+ } },
1239
+ { op: "settings.values.update", method: "PATCH", pattern: /^\/v1\/workspaces\/[^\/]+\/settings\/[^\/]+\/values\/[^\/]+$/, status: 200, contentType: "application/json", body: {
1240
+ environment_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
1241
+ environment_key: "production",
1242
+ percentage_attribute: null,
1243
+ percentages: [{ percentage: 10, value: true }],
1244
+ rules: [{ conditions: [{ user: null }], serve: true }],
1245
+ setting_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
1246
+ updated_at: "2026-01-01T00:00:00.000Z",
1247
+ updated_by: { id: "string", type: "user" },
1248
+ value: false,
1249
+ version: 3
1250
+ } },
1251
+ { op: "configs.environments.revisions.retrieve", method: "GET", pattern: /^\/v1\/workspaces\/[^\/]+\/configs\/[^\/]+\/environments\/[^\/]+\/revisions\/[^\/]+$/, status: 200, contentType: "application/json", body: {} }
1252
+ ];
1253
+ function createMockFetch(overrides = {}) {
1254
+ const calls = [];
1255
+ const mock = async (input, init) => {
1256
+ const request = input instanceof Request ? input : void 0;
1257
+ const url = new URL(request ? request.url : String(input));
1258
+ const method = (init?.method ?? request?.method ?? "GET").toUpperCase();
1259
+ const headers = new Headers(init?.headers ?? request?.headers);
1260
+ const raw = init?.body ?? (request ? await request.text() : void 0);
1261
+ let body = raw;
1262
+ if (typeof raw === "string") {
1263
+ try {
1264
+ body = JSON.parse(raw);
1265
+ } catch {
1266
+ body = raw;
1267
+ }
1268
+ }
1269
+ const route = ROUTES.find((r) => r.method === method && r.pattern.test(url.pathname));
1270
+ const call = { operation: route?.op, method, url, headers, body };
1271
+ calls.push(call);
1272
+ const requestId = `req_mock_${calls.length}`;
1273
+ if (!route) {
1274
+ return Response.json({ statusCode: 404, code: "NOT_FOUND", message: `No mock for ${method} ${url.pathname}` }, { status: 404, headers: { "x-request-id": requestId } });
1275
+ }
1276
+ let value = route.body;
1277
+ if (route.op in overrides) {
1278
+ const o = overrides[route.op];
1279
+ value = typeof o === "function" ? await o(call) : o;
1280
+ if (value instanceof Response) return value;
1281
+ }
1282
+ if (route.contentType === null || route.status === 204) return new Response(null, { status: route.status, headers: { "x-request-id": requestId } });
1283
+ const text = route.contentType === "application/json" ? JSON.stringify(value) : String(value);
1284
+ return new Response(text, { status: route.status, headers: { "content-type": route.contentType, "x-request-id": requestId } });
1285
+ };
1286
+ return Object.assign(mock, { calls });
1287
+ }
1288
+
1289
+ // src/client/testing.ts
1290
+ var TestFlagsClient = class extends FlagsClient {
1291
+ /** Changes one value; emits `configChanged`. */
1292
+ set(key, value) {
1293
+ setOverride(this, key, value);
1294
+ }
1295
+ };
1296
+ function createTestClient(options = {}) {
1297
+ return new TestFlagsClient({
1298
+ overrides: { values: options.values ?? {}, behaviour: "local_only" },
1299
+ defaultUser: options.user,
1300
+ polling: { mode: "manual" },
1301
+ logger: null
1302
+ });
1303
+ }
1304
+
1305
+ export { TestFlagsClient, createMockFetch, createTestClient };
1306
+ //# sourceMappingURL=testing.js.map
1307
+ //# sourceMappingURL=testing.js.map