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