@crvouga/mockingbird-service-slack 3.1.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -11,9 +11,9 @@ interface FetchAPI$1 {
11
11
  }
12
12
 
13
13
  /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
14
- type SqliteValue$1 = null | number | bigint | string | Uint8Array | boolean;
14
+ type SqliteValue$2 = null | number | bigint | string | Uint8Array | boolean;
15
15
  /** Mutation counters returned by {@link SqliteStatement.run}. */
16
- type SqliteRunResult$1 = {
16
+ type SqliteRunResult$2 = {
17
17
  changes: number;
18
18
  lastInsertRowid: number | bigint;
19
19
  };
@@ -22,10 +22,10 @@ type SqliteRunResult$1 = {
22
22
  *
23
23
  * Pass bind values as rest arguments on each call (no sticky `bind()`).
24
24
  */
25
- interface SqliteStatement$1 {
26
- run(...params: SqliteValue$1[]): SqliteRunResult$1;
27
- all<T = Record<string, unknown>>(...params: SqliteValue$1[]): T[];
28
- get<T = Record<string, unknown>>(...params: SqliteValue$1[]): T | undefined;
25
+ interface SqliteStatement$2 {
26
+ run(...params: SqliteValue$2[]): SqliteRunResult$2;
27
+ all<T = Record<string, unknown>>(...params: SqliteValue$2[]): T[];
28
+ get<T = Record<string, unknown>>(...params: SqliteValue$2[]): T | undefined;
29
29
  }
30
30
  /**
31
31
  * Sync SQLite client port owned by Mockingbird.
@@ -33,54 +33,163 @@ interface SqliteStatement$1 {
33
33
  * Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
34
34
  * `bun:sqlite` instances all work when they expose this surface.
35
35
  */
36
- interface SqliteClient$1 {
36
+ interface SqliteClient$2 {
37
37
  exec(sql: string): void;
38
- prepare(sql: string): SqliteStatement$1;
38
+ prepare(sql: string): SqliteStatement$2;
39
39
  transaction<T>(fn: () => T): T;
40
40
  }
41
41
 
42
- /** Every stored record carries a monotonically increasing sequence for stable ordering. */
43
- type Stored<T> = {
44
- seq: number;
45
- value: T;
46
- };
47
- type ListRecordsOptions<T> = {
48
- /** Keep only records passing the predicate. */
49
- where?: (value: T, seq: number) => boolean;
50
- /** Sort order; default newest first. */
51
- order?: "newest" | "oldest";
42
+ /** Options every provider constructor accepts. */
43
+ type APIOptions$1 = {
44
+ /** Sync SQLite client. Defaults to `@crvouga/mockingbird-service-sqlite`. */
45
+ sqlite?: SqliteClient$2;
46
+ /** Clock used for `created`-style fields. Default `Date.now`. */
47
+ now?: () => number;
48
+ /**
49
+ * Storage namespace for this instance's records. Instances sharing one SQLite
50
+ * client stay isolated when their namespaces differ. Defaults to the service name.
51
+ */
52
+ namespace?: string;
52
53
  };
53
- /**
54
- * A SQLite-backed table of JSON records addressed by id. Ordering is by insertion
55
- * sequence, never by id lexicographic order, so list semantics stay stable.
56
- */
57
- declare class Collection<T> {
58
- private readonly sqlite;
59
- /** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
60
- readonly namespace: string;
61
- /** Table name inside the namespace. Stable across resets of the rows themselves. */
62
- readonly collectionName: string;
63
- constructor(sqlite: SqliteClient$1,
64
- /** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
65
- namespace: string,
66
- /** Table name inside the namespace. Stable across resets of the rows themselves. */
67
- collectionName: string);
68
- private bumpCollectionSeq;
69
- nextSequence(): number;
70
- get(id: string): T | undefined;
71
- has(id: string): boolean;
72
- /** Insert a new record, assigning it the next sequence number. */
73
- insert(id: string, value: T): Stored<T>;
74
- /** Replace an existing record's value, keeping its position. */
75
- update(id: string, value: T): Stored<T> | undefined;
76
- delete(id: string): boolean;
77
- /** How many records the collection holds, without reading them. */
78
- count(): number;
79
- list(options?: ListRecordsOptions<T>): Array<Stored<T> & {
80
- id: string;
54
+
55
+ interface AuthUser {
56
+ login: string;
57
+ id: number;
58
+ scopes: string[];
59
+ installation?: AuthInstallation;
60
+ }
61
+ interface AuthInstallation {
62
+ installationId: number;
63
+ appId: number;
64
+ accountId: number;
65
+ accountType: "User" | "Organization";
66
+ permissions: Record<string, string>;
67
+ repositoryIds: number[];
68
+ repositorySelection: "all" | "selected";
69
+ }
70
+ interface AuthFallback {
71
+ login: string;
72
+ id: number;
73
+ scopes: string[];
74
+ }
75
+
76
+ /*! Adapted from vercel-labs/emulate (Apache-2.0), modified for Mockingbird. See port.json, LICENSE_EMULATE and THIRD_PARTY_NOTICES.md. */
77
+
78
+ interface SlackUserProfile {
79
+ display_name: string;
80
+ real_name: string;
81
+ email: string;
82
+ image_48: string;
83
+ image_192: string;
84
+ title?: string;
85
+ phone?: string;
86
+ skype?: string;
87
+ real_name_normalized?: string;
88
+ display_name_normalized?: string;
89
+ fields?: Record<string, {
90
+ value: string;
91
+ alt?: string;
92
+ label?: string;
93
+ }>;
94
+ status_text?: string;
95
+ status_emoji?: string;
96
+ status_emoji_display_info?: Record<string, unknown>[];
97
+ status_expiration?: number;
98
+ avatar_hash?: string;
99
+ start_date?: string;
100
+ pronouns?: string;
101
+ huddle_state?: string;
102
+ huddle_state_expiration_ts?: number;
103
+ first_name?: string;
104
+ last_name?: string;
105
+ image_24?: string;
106
+ image_32?: string;
107
+ image_72?: string;
108
+ image_512?: string;
109
+ }
110
+ type SlackPresence = "active" | "away";
111
+ type SlackTokenType = "bot" | "user" | "test";
112
+
113
+ interface SlackSeedConfig {
114
+ port?: number;
115
+ team?: {
116
+ name?: string;
117
+ domain?: string;
118
+ };
119
+ users?: Array<{
120
+ name: string;
121
+ real_name?: string;
122
+ email?: string;
123
+ is_admin?: boolean;
124
+ profile?: Partial<SlackUserProfile>;
125
+ presence?: SlackPresence;
126
+ }>;
127
+ channels?: Array<{
128
+ name: string;
129
+ topic?: string;
130
+ purpose?: string;
131
+ is_private?: boolean;
132
+ }>;
133
+ bots?: Array<{
134
+ name: string;
135
+ }>;
136
+ oauth_apps?: Array<{
137
+ app_id?: string;
138
+ client_id: string;
139
+ client_secret: string;
140
+ name: string;
141
+ redirect_uris: string[];
142
+ scopes?: string[] | string;
143
+ user_scopes?: string[] | string;
144
+ bot_id?: string;
145
+ bot_user_id?: string;
146
+ bot_name?: string;
147
+ }>;
148
+ tokens?: Array<{
149
+ token: string;
150
+ type?: SlackTokenType;
151
+ user?: string;
152
+ user_id?: string;
153
+ scopes?: string[] | string;
154
+ app_id?: string;
155
+ client_id?: string;
156
+ team_id?: string;
157
+ bot_id?: string;
158
+ bot_user_id?: string;
159
+ authed_user_id?: string;
160
+ }>;
161
+ incoming_webhooks?: Array<{
162
+ channel: string;
163
+ label?: string;
81
164
  }>;
165
+ strict_scopes?: boolean;
166
+ signing_secret?: string;
82
167
  }
83
168
 
169
+ type ProviderOptions = APIOptions$1 & {
170
+ baseUrl?: string;
171
+ tokens?: Record<string, AuthUser>;
172
+ fallbackUser?: AuthFallback;
173
+ publicNamespace?: string;
174
+ adminPrefix?: string;
175
+ /**
176
+ * A seeded stream of `[0, 1)` that ids and tokens are minted from, so a run replays from
177
+ * its seed. Default: the platform's randomness.
178
+ */
179
+ random?: () => number;
180
+ };
181
+
182
+ type MountedAPI = FetchAPI & {
183
+ readonly prefix: string;
184
+ GET: FetchHandler;
185
+ POST: FetchHandler;
186
+ PUT: FetchHandler;
187
+ PATCH: FetchHandler;
188
+ DELETE: FetchHandler;
189
+ HEAD: FetchHandler;
190
+ OPTIONS: FetchHandler;
191
+ };
192
+
84
193
  /** A stable identifier for a point in a {@link Timeline}. */
85
194
  type CheckpointId = string;
86
195
  /** An immutable node in a timeline's checkpoint DAG. */
@@ -170,6 +279,79 @@ declare class Timeline<T> {
170
279
  interface FetchAPI {
171
280
  fetch(request: Request): Promise<Response>;
172
281
  }
282
+ /** A bare function form of {@link FetchAPI}, compatible with `Bun.serve`, workerd, and Deno. */
283
+ type FetchHandler = (request: Request) => Promise<Response>;
284
+
285
+ /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
286
+ type SqliteValue$1 = null | number | bigint | string | Uint8Array | boolean;
287
+ /** Mutation counters returned by {@link SqliteStatement.run}. */
288
+ type SqliteRunResult$1 = {
289
+ changes: number;
290
+ lastInsertRowid: number | bigint;
291
+ };
292
+ /**
293
+ * Prepared statement bound to a {@link SqliteClient}.
294
+ *
295
+ * Pass bind values as rest arguments on each call (no sticky `bind()`).
296
+ */
297
+ interface SqliteStatement$1 {
298
+ run(...params: SqliteValue$1[]): SqliteRunResult$1;
299
+ all<T = Record<string, unknown>>(...params: SqliteValue$1[]): T[];
300
+ get<T = Record<string, unknown>>(...params: SqliteValue$1[]): T | undefined;
301
+ }
302
+ /**
303
+ * Sync SQLite client port owned by Mockingbird.
304
+ *
305
+ * Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
306
+ * `bun:sqlite` instances all work when they expose this surface.
307
+ */
308
+ interface SqliteClient$1 {
309
+ exec(sql: string): void;
310
+ prepare(sql: string): SqliteStatement$1;
311
+ transaction<T>(fn: () => T): T;
312
+ }
313
+
314
+ /** Every stored record carries a monotonically increasing sequence for stable ordering. */
315
+ type Stored<T> = {
316
+ seq: number;
317
+ value: T;
318
+ };
319
+ type ListRecordsOptions<T> = {
320
+ /** Keep only records passing the predicate. */
321
+ where?: (value: T, seq: number) => boolean;
322
+ /** Sort order; default newest first. */
323
+ order?: "newest" | "oldest";
324
+ };
325
+ /**
326
+ * A SQLite-backed table of JSON records addressed by id. Ordering is by insertion
327
+ * sequence, never by id lexicographic order, so list semantics stay stable.
328
+ */
329
+ declare class Collection<T> {
330
+ private readonly sqlite;
331
+ /** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
332
+ readonly namespace: string;
333
+ /** Table name inside the namespace. Stable across resets of the rows themselves. */
334
+ readonly collectionName: string;
335
+ constructor(sqlite: SqliteClient$1,
336
+ /** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
337
+ namespace: string,
338
+ /** Table name inside the namespace. Stable across resets of the rows themselves. */
339
+ collectionName: string);
340
+ private bumpCollectionSeq;
341
+ nextSequence(): number;
342
+ get(id: string): T | undefined;
343
+ has(id: string): boolean;
344
+ /** Insert a new record, assigning it the next sequence number. */
345
+ insert(id: string, value: T): Stored<T>;
346
+ /** Replace an existing record's value, keeping its position. */
347
+ update(id: string, value: T): Stored<T> | undefined;
348
+ delete(id: string): boolean;
349
+ /** How many records the collection holds, without reading them. */
350
+ count(): number;
351
+ list(options?: ListRecordsOptions<T>): Array<Stored<T> & {
352
+ id: string;
353
+ }>;
354
+ }
173
355
 
174
356
  /** Options every provider constructor accepts. */
175
357
  type APIOptions = {
@@ -196,7 +378,7 @@ type ClockState = {
196
378
  now: number;
197
379
  /** True while time does not advance on its own. */
198
380
  frozen: boolean;
199
- /** Milliseconds this clock adds to its underlying source. */
381
+ /** Milliseconds a running clock adds to its underlying source. `0` while frozen. */
200
382
  offsetMs: number;
201
383
  };
202
384
  type Clock = {
@@ -232,7 +414,10 @@ type Rng = {
232
414
  state(): number;
233
415
  /** Restore a state previously returned by {@link state}. */
234
416
  setState(state: number): void;
235
- seed: number;
417
+ /** Restart the stream from a new seed. `reset` then returns to this seed. */
418
+ reseed(seed: number | string): void;
419
+ /** The seed the stream currently starts from. */
420
+ readonly seed: number;
236
421
  };
237
422
 
238
423
  /**
@@ -241,44 +426,83 @@ type Rng = {
241
426
  * This is how a suite reaches the vendor's failure modes without the vendor: the
242
427
  * quota error that only appears when a shared sandbox is full, the 429 that only
243
428
  * appears under load, the 5xx that proves a retry path works.
429
+ *
430
+ * A rule has three parts. What it **matches** (`operationId`, `method`, `path`, …), **when**
431
+ * it fires among the matching requests (`after`, `every`, `count`, `rate`, `from`, `until`),
432
+ * and what it **does** (`status`, `delay`, `timeout`, `drop`, `truncate`, `effect`).
244
433
  */
245
434
  type FaultRule = {
246
- /** Stable id, so a suite can retire exactly the rule it added. */
435
+ /** Stable id, so a suite can retire exactly the rule it added. Unique within a namespace. */
247
436
  id: string;
248
437
  /** Fault only this operation. Omit to match every operation. */
249
438
  operationId?: string;
250
439
  /** Fault only this HTTP method, case-insensitive. Omit to match every method. */
251
440
  method?: string;
441
+ /** Fault only this exact path. */
442
+ path?: string;
252
443
  /** Fault only paths starting with this prefix. Omit to match every path. */
253
444
  pathPrefix?: string;
445
+ /** Fault only paths matching this regular expression (JavaScript syntax, unanchored). */
446
+ pathPattern?: string;
447
+ /** Fault only requests carrying these headers. `"*"` matches any value. */
448
+ requestHeaders?: Record<string, string>;
449
+ /** Fault only requests carrying these query parameters. `"*"` matches any value. */
450
+ query?: Record<string, string>;
254
451
  /**
255
452
  * Fault only this namespace. Omit (or `"*"`) to fault every namespace — which is what
256
453
  * an in-process caller usually wants, and what a parallel worker usually does not:
257
454
  * rules added through `POST /__admin/faults` default to the calling namespace.
258
455
  */
259
456
  namespace?: string;
457
+ /** Let this many matching requests through first. */
458
+ after?: number;
459
+ /** Then fault only every nth matching request: `3` faults the 3rd, 6th, 9th. */
460
+ every?: number;
461
+ /** Retire the rule after this many faults. Omit to keep it until removed. */
462
+ count?: number;
463
+ /** Fault this fraction of the remaining requests, `0`–`1`, drawn from the seed. Default `1`. */
464
+ rate?: number;
260
465
  /**
261
- * Status of the injected response. Omit for a rule that only delays (`delayMs` /
262
- * `latencyMs`), only drops the connection (`drop`), or only switches on an `effect`:
263
- * the request then still reaches the service.
466
+ * Fault only from this instant on the namespace clock. A duration (`"5m"`) counts from the
467
+ * clock when the rule was added. Listed as epoch ms.
468
+ */
469
+ from?: Instant | Duration;
470
+ /** Stop faulting at this instant on the namespace clock. A duration counts from when added. */
471
+ until?: Instant | Duration;
472
+ /**
473
+ * Status of the injected response. Omit for a rule that only delays, times out, drops,
474
+ * truncates, or switches on an `effect`: the request then still reaches the service.
264
475
  */
265
476
  status?: number;
266
477
  /** Response body, serialized as JSON. A string is sent as-is. */
267
478
  body?: unknown;
479
+ /** Response headers. */
268
480
  headers?: Record<string, string>;
269
- /** Retire the rule after this many faults. Omit to keep it until removed. */
270
- count?: number;
271
- /** Fault this fraction of matching requests, `0`–`1`. Default `1`. */
272
- rate?: number;
273
- /** Hold the response back this long, to exercise timeouts. */
481
+ /** Hold the response back this long. Listed as `delayMs`. */
482
+ delay?: Duration;
483
+ /** `delay`, in milliseconds. */
274
484
  delayMs?: number;
275
485
  /** Alias of `delayMs`. */
276
486
  latencyMs?: number;
487
+ /** Extra seeded delay in `[0, jitter]`. Listed as `jitterMs`. */
488
+ jitter?: Duration;
489
+ jitterMs?: number;
490
+ /**
491
+ * Never answer: hold the request this long, then drop the connection. Listed as
492
+ * `timeoutMs`. With virtual time the wait is spent on the mock clock.
493
+ */
494
+ timeout?: Duration;
495
+ timeoutMs?: number;
277
496
  /**
278
497
  * Drop the connection instead of answering: an in-process `fetch` rejects with a
279
498
  * `TypeError`, and a served mock destroys the socket. Models "unknown outcome" failures.
280
499
  */
281
500
  drop?: boolean;
501
+ /**
502
+ * Cut the response body off after this many bytes: the status and headers arrive, then
503
+ * the connection dies mid-body.
504
+ */
505
+ truncate?: number;
282
506
  /**
283
507
  * A named service behaviour to switch on for the matching request instead of (or
284
508
  * before) a canned response, e.g. `created_but_500` or `numeric_tracking_id`. Services
@@ -287,8 +511,8 @@ type FaultRule = {
287
511
  effect?: string;
288
512
  /** Parameters for `effect`. */
289
513
  params?: Record<string, unknown>;
290
- /** From the preset this rule was expanded from, if any. */
291
- preset?: string;
514
+ /** The preset this rule was expanded from, if any. */
515
+ fromPreset?: string;
292
516
  };
293
517
  /** A fault that fired for one request. */
294
518
  type FaultHit = {
@@ -296,6 +520,10 @@ type FaultHit = {
296
520
  /** The injected response; absent when the rule only delays, drops, or sets an effect. */
297
521
  response?: Response;
298
522
  drop?: boolean;
523
+ /** Set with `drop` when the rule held the request for its `timeout` first. */
524
+ timeout?: boolean;
525
+ /** Bytes of response body to let through before the connection dies. */
526
+ truncate?: number;
299
527
  effect?: {
300
528
  name: string;
301
529
  params: Record<string, unknown>;
@@ -320,38 +548,200 @@ type FaultCandidate = {
320
548
  method: string;
321
549
  path: string;
322
550
  namespace: string;
551
+ /** Request headers and query, for rules that match on them. */
552
+ headers?: Headers;
553
+ query?: URLSearchParams;
554
+ /** The namespace clock, for `from` / `until`. Rules with a window are skipped without it. */
555
+ now?: number;
556
+ /** How to spend a delay for this request. Default: the registry's own sleep. */
557
+ wait?: (ms: number) => Promise<void>;
558
+ };
559
+ /** A stored rule and how often it was consulted. */
560
+ type FaultListing = FaultRule & {
561
+ /** Faults left before the rule retires. `null` when it has no `count`. */
562
+ remaining: number | null;
563
+ /** Times the rule faulted a request. */
564
+ hits: number;
565
+ /** Requests that matched the rule, faulted or not. */
566
+ seen: number;
567
+ };
568
+ /** A namespace's own rules, with their counters, in the order they are tried. */
569
+ type FaultSnapshot = {
570
+ /**
571
+ * `position` is how many `"*"` rules are tried before the rule, which is what its place
572
+ * in the order means to a request and holds in any process.
573
+ */
574
+ rules: (FaultListing & {
575
+ position?: number;
576
+ })[];
577
+ /** How many `fault_<n>` ids the namespace has handed out. */
578
+ nextId?: number;
323
579
  };
324
580
  type FaultRegistry = {
325
- isolateNamespaces(): void;
326
- snapshot(namespace: string): {
327
- rules: (FaultRule & {
328
- remaining: number | null;
329
- hits: number;
330
- position: number;
331
- })[];
332
- rngState: number;
333
- };
581
+ snapshot(namespace: string): FaultSnapshot;
582
+ /** Add a rule, or replace the rule with the same id in the same namespace. */
334
583
  add(rule: FaultRule): FaultRule;
335
- list(): (FaultRule & {
336
- remaining: number | null;
337
- hits: number;
338
- })[];
339
- remove(id: string): boolean;
340
- clear(): void;
341
- restore(namespace: string, state: {
342
- rules: (FaultRule & {
343
- remaining: number | null;
344
- hits: number;
345
- position: number;
346
- })[];
347
- rngState: number;
348
- }): void;
584
+ /** The next unused `fault_<n>` id in `namespace`. */
585
+ nextId(namespace: string): string;
586
+ /** Every rule, or the rules a namespace's requests can hit: its own and the global ones. */
587
+ list(namespace?: string): FaultListing[];
588
+ get(id: string, namespace?: string): FaultListing | undefined;
589
+ /** Remove a rule by id: from `namespace` (its own, then a global one), or wherever it is. */
590
+ remove(id: string, namespace?: string): boolean;
591
+ /** Remove every rule, or one namespace's own rules. */
592
+ clear(namespace?: string): void;
593
+ /** Replace a namespace's own rules with a snapshot's, wherever the snapshot was taken. */
594
+ restore(namespace: string, state: FaultSnapshot): void;
349
595
  /**
350
596
  * Every fault this request should get, in rule order, stopping at the first that answers
351
597
  * or drops (effect-only and delay-only rules let later rules match too). Consumes one of
352
598
  * each matching rule's remaining uses.
353
599
  */
354
600
  take(candidate: FaultCandidate): Promise<FaultHit[]>;
601
+ /**
602
+ * Fire these rules at one request without storing them: no matching, no schedule, in order,
603
+ * stopping at the first that answers or drops. Jitter draws from the namespace's stream.
604
+ */
605
+ fire(rules: readonly FaultRule[], candidate: FaultCandidate): Promise<FaultHit[]>;
606
+ };
607
+
608
+ /**
609
+ * The admin controls every mock shares, as one document.
610
+ *
611
+ * The same shape is accepted in three places, and means the same thing in each:
612
+ *
613
+ * - at boot: `createRuntime({ adminControls })`, `serve --admin-controls`,
614
+ * `MOCKINGBIRD_ADMIN_CONTROLS`
615
+ * - over HTTP: `PUT /__admin/controls`
616
+ * - per request: the `x-mockingbird-*` headers in {@link CONTROL_HEADERS}
617
+ *
618
+ * Every control is deterministic: given the same seed, clock and requests, a mock answers
619
+ * the same bytes. Nothing here reads the wall clock or `Math.random`.
620
+ */
621
+ /** Milliseconds, or a string like `"250ms"`, `"2s"`, `"15m"`, `"1h"`, `"3d"`. */
622
+ type Duration = number | string;
623
+ /** Epoch milliseconds, or an ISO-8601 string. */
624
+ type Instant = number | string;
625
+ type ClockControls = {
626
+ /** Move the clock to this instant. */
627
+ now?: Instant;
628
+ /** Stop time. A frozen clock moves only when told to, so timestamps replay exactly. */
629
+ frozen?: boolean;
630
+ /**
631
+ * Step the clock forward by this much before every vendor request. With a frozen clock
632
+ * each request still gets its own, reproducible timestamp.
633
+ */
634
+ autoAdvance?: Duration;
635
+ };
636
+ /** How long a response takes: a fixed delay plus seeded jitter in `[0, jitter]`. */
637
+ type LatencyRuleInput = {
638
+ delay?: Duration;
639
+ jitter?: Duration;
640
+ };
641
+ type LatencyControls = LatencyRuleInput & {
642
+ /** Per-operation overrides, keyed by operationId. A bare duration is its `delay`. */
643
+ operations?: Record<string, Duration | LatencyRuleInput>;
644
+ };
645
+ /** A fault to add: a rule (the id is assigned when omitted), or a named preset with overrides. */
646
+ type FaultInput = (Omit<FaultRule, "id"> & {
647
+ id?: string;
648
+ }) | ({
649
+ preset: string;
650
+ } & Partial<FaultRule>);
651
+ /** Identifies a {@link SnapshotDocument}. */
652
+ declare const SNAPSHOT_FORMAT = "mockingbird.snapshot/v1";
653
+ /**
654
+ * A namespace, as portable JSON: what `GET /__admin/snapshots/:id` returns and what
655
+ * `PUT /__admin/snapshots/:id` and the boot `snapshot` control accept. Only `format` and
656
+ * `records` are required, so a hand-written seed file is a valid snapshot.
657
+ */
658
+ type SnapshotDocument = {
659
+ format: typeof SNAPSHOT_FORMAT;
660
+ /** The service that wrote it. A snapshot is rejected by any other service. */
661
+ service?: string;
662
+ /**
663
+ * Stored rows. `seq` orders a collection; omitted, rows keep their listed order. `raw` is
664
+ * the stored text of a row that is not a plain record, and replaces `value` when present.
665
+ */
666
+ records: {
667
+ collection: string;
668
+ id: string;
669
+ seq?: number;
670
+ value?: unknown;
671
+ raw?: string;
672
+ }[];
673
+ /** Id counters, so the next generated id continues where the snapshot left off. */
674
+ sequences?: {
675
+ name: string;
676
+ kind: string;
677
+ value: number;
678
+ }[];
679
+ clock?: {
680
+ now: number;
681
+ frozen: boolean;
682
+ autoAdvanceMs?: number;
683
+ };
684
+ seed?: number | string;
685
+ /** Positions of the seeded random streams. */
686
+ rng?: {
687
+ state: number;
688
+ faults?: number;
689
+ latency?: number;
690
+ };
691
+ faults?: unknown;
692
+ latency?: unknown;
693
+ virtualTime?: boolean;
694
+ };
695
+ /** Controls for one namespace. */
696
+ type NamespaceControls = {
697
+ /** Seeds every random choice: fault rates, jitter, and whatever the service invents. */
698
+ seed?: number | string;
699
+ clock?: ClockControls;
700
+ /**
701
+ * Spend injected waits (latency, fault delays, timeouts) on the mock clock instead of the
702
+ * wall clock: the request returns at once, the clock has moved, and the journal records
703
+ * the wait exactly. Default `false`: waits are real, so a client's own timeout can fire.
704
+ */
705
+ virtualTime?: boolean;
706
+ /** Baseline response time for every vendor request. A bare duration is its `delay`. */
707
+ latency?: Duration | LatencyControls;
708
+ faults?: readonly FaultInput[];
709
+ /** Start from this state instead of the service's own seed data. */
710
+ snapshot?: SnapshotDocument;
711
+ };
712
+ /** {@link NamespaceControls} for every namespace, with per-namespace overrides. */
713
+ type MockControls = NamespaceControls & {
714
+ /** Vendor credential → namespace, for SDKs that cannot send a namespace header. */
715
+ credentials?: Record<string, string>;
716
+ /** Overrides for named namespaces. A key given here replaces the shared value. */
717
+ namespaces?: Record<string, NamespaceControls>;
718
+ };
719
+ /** A latency rule in milliseconds. */
720
+ type LatencyRule = {
721
+ delayMs: number;
722
+ jitterMs: number;
723
+ };
724
+ /** Baseline latency for a namespace, normalized. */
725
+ type LatencyState = LatencyRule & {
726
+ operations: Record<string, LatencyRule>;
727
+ };
728
+ /** What {@link controlHeaders} turns into request headers. */
729
+ type ControlHeaderInput = {
730
+ namespace?: string;
731
+ adminKey?: string;
732
+ branch?: string;
733
+ at?: string;
734
+ reset?: boolean;
735
+ restore?: string;
736
+ seed?: number | string;
737
+ time?: Instant | Date;
738
+ advance?: Duration;
739
+ virtualTime?: boolean;
740
+ delay?: Duration;
741
+ timeout?: Duration;
742
+ /** A status, `"drop"`, a preset name, or a fault rule. */
743
+ fault?: number | string | Record<string, unknown>;
744
+ snapshot?: string;
355
745
  };
356
746
 
357
747
  /**
@@ -391,6 +781,8 @@ type RequestLog = {
391
781
  unmatched: boolean;
392
782
  /** Set when a fault rule produced the response. */
393
783
  faultId?: string;
784
+ /** Milliseconds of injected wait: latency, fault delays and timeouts. Absent when none. */
785
+ delayMs?: number;
394
786
  /** Resource ids the handler touched (`userId`, `orderId`, …), when the service reports them. */
395
787
  ids?: Record<string, string>;
396
788
  /** Set when the service created a resource the request referred to but that did not exist. */
@@ -436,6 +828,12 @@ type JournalQuery = {
436
828
  /** Only this namespace. Omit for every namespace, oldest first across all of them. */
437
829
  namespace?: string;
438
830
  operationId?: string;
831
+ /** Only this HTTP method, case-insensitive. */
832
+ method?: string;
833
+ /** Only this exact path. */
834
+ path?: string;
835
+ /** Only requests this fault rule answered or shaped. */
836
+ faultId?: string;
439
837
  status?: number;
440
838
  /** Only entries at or after this instant (epoch ms). */
441
839
  since?: number;
@@ -450,6 +848,50 @@ type Journal = {
450
848
  clear(namespace?: string): void;
451
849
  };
452
850
 
851
+ /**
852
+ * Baseline response time, per namespace: how long every vendor request takes before any
853
+ * fault is considered. Jitter draws from a stream the caller owns, one per namespace and
854
+ * separate from the fault stream, so adding latency never shifts which requests a `rate`
855
+ * fault hits.
856
+ */
857
+ type LatencyRegistry = {
858
+ get(namespace: string): LatencyState;
859
+ set(namespace: string, state: LatencyState): LatencyState;
860
+ /** Remove one namespace's latency, or every namespace's. */
861
+ clear(namespace?: string): void;
862
+ /** Milliseconds this request waits. Draws jitter, so call it once per request. */
863
+ take(namespace: string, operationId: string | undefined): number;
864
+ };
865
+
866
+ /** Clock state as the admin API reports it. */
867
+ type ControlClock = ClockState & {
868
+ /** `now`, as ISO-8601. */
869
+ iso: string;
870
+ /** Milliseconds the clock steps before every vendor request. */
871
+ autoAdvanceMs: number;
872
+ };
873
+ /** One namespace's controls: the body of `GET /__admin/controls`. */
874
+ type ControlState = {
875
+ namespace: string;
876
+ seed: number | string;
877
+ clock: ControlClock;
878
+ virtualTime: boolean;
879
+ latency: LatencyState;
880
+ faults: FaultListing[];
881
+ };
882
+
883
+ /** What `GET /__admin/snapshots` lists for each snapshot. */
884
+ type SnapshotInfo = {
885
+ id: string;
886
+ namespace: string;
887
+ /** Stored rows in the snapshot. */
888
+ records: number;
889
+ /** The namespace clock when it was taken, epoch ms. */
890
+ at: number;
891
+ /** Whether `GET /snapshots/:id` can return it as a {@link SnapshotDocument}. */
892
+ portable: boolean;
893
+ };
894
+
453
895
  /** Credential → namespace mapping behind `PUT /__admin/credentials`. */
454
896
  type CredentialRegistry = {
455
897
  set(credential: string, namespace: string): void;
@@ -604,7 +1046,10 @@ type ServiceInstance = FetchAPI & {
604
1046
  };
605
1047
  type ServiceTimelineState = Readonly<{
606
1048
  snapshot: NamespaceSnapshot;
607
- clock: Readonly<ReturnType<Clock["state"]>>;
1049
+ /** `pinned`: the namespace's clock was frozen itself, not just following a frozen base. */
1050
+ clock: Readonly<ClockState & {
1051
+ pinned?: boolean;
1052
+ }>;
608
1053
  rngState: number;
609
1054
  }>;
610
1055
  type ServiceCheckpoint = Checkpoint<ServiceTimelineState>;
@@ -612,17 +1057,23 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI & {
612
1057
  /** Stop package-owned lifecycle timers when a supervisor closes the runtime. */
613
1058
  stop?(): void;
614
1059
  readonly name: string;
1060
+ /** Same-origin Fetch handler and App Router method exports, sharing this runtime. */
1061
+ mount(prefix: string): MountedAPI;
615
1062
  readonly sqlite: SqliteClient$1;
616
1063
  readonly clock: Clock;
617
1064
  readonly faults: FaultRegistry;
1065
+ /** Baseline response time per namespace. */
1066
+ readonly latency: LatencyRegistry;
618
1067
  readonly metrics: Metrics;
619
1068
  readonly journal: Journal;
620
1069
  readonly rng: Rng;
621
1070
  readonly credentials: CredentialRegistry;
622
1071
  /** The webhook hub, when the service has outbound webhooks. */
623
1072
  readonly webhooks: WebhookHub | undefined;
624
- /** Enable independent namespace clocks and PRNGs before serving a fleet. */
625
- isolateNamespaces(): void;
1073
+ /**
1074
+ * A namespace's clock. Each follows the base clock, {@link ServiceRuntime.clock}, with an
1075
+ * offset and a freeze of its own, so moving one never moves another.
1076
+ */
626
1077
  namespaceClock(namespace?: string): Clock;
627
1078
  namespaceOf(request: Request): string;
628
1079
  /** Opaque in-process checkpoint including records, controls and webhook history. */
@@ -634,8 +1085,38 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI & {
634
1085
  instance(namespace?: string): T;
635
1086
  /** Public names of every namespace created so far. */
636
1087
  namespaces(): string[];
637
- /** Reset one namespace, or every namespace with `"*"`. */
1088
+ /** Return one namespace to its boot state, or every namespace with `"*"`. */
638
1089
  reset(namespace?: string): Promise<void>;
1090
+ /** Reset a namespace and forget it, releasing everything it held. */
1091
+ dropNamespace(namespace: string): Promise<void>;
1092
+ /** A namespace's controls: seed, clock, virtual time, latency, faults and snapshots. */
1093
+ controls(namespace?: string): ControlState & {
1094
+ snapshots: SnapshotInfo[];
1095
+ };
1096
+ /** Apply a control document to a namespace. A given key replaces that control. */
1097
+ configure(controls: NamespaceControls, namespace?: string): ControlState & {
1098
+ snapshots: SnapshotInfo[];
1099
+ };
1100
+ /** Named snapshots of a namespace: records, clock, random streams, faults and latency. */
1101
+ readonly snapshots: {
1102
+ /** Capture the namespace now. Reusing a name replaces that snapshot. */
1103
+ create(options?: {
1104
+ name?: string;
1105
+ namespace?: string;
1106
+ }): SnapshotInfo;
1107
+ list(namespace?: string): SnapshotInfo[];
1108
+ /** The snapshot as portable JSON, to commit beside a suite or boot another mock from. */
1109
+ export(id: string, namespace?: string): SnapshotDocument;
1110
+ /** Store a document as a snapshot without restoring it. */
1111
+ import(document: SnapshotDocument, options?: {
1112
+ name?: string;
1113
+ namespace?: string;
1114
+ }): SnapshotInfo;
1115
+ restore(id: string, namespace?: string): void;
1116
+ delete(id: string, namespace?: string): boolean;
1117
+ };
1118
+ /** Request headers that carry controls, checked: spread them into a `fetch` or an SDK's defaults. */
1119
+ headers(input: ControlHeaderInput): Record<string, string>;
639
1120
  snapshot(namespace?: string): NamespaceSnapshot;
640
1121
  restore(snapshot: NamespaceSnapshot, namespace?: string): void;
641
1122
  /** Capture the current branch. Mutating HTTP calls do this automatically. */
@@ -1019,22 +1500,24 @@ type OpenAPIDocument = {
1019
1500
  };
1020
1501
 
1021
1502
  declare const document: OpenAPIDocument;
1022
- type OperationId = "PostIncomingWebhook" | "ChatPostMessage" | "ChatUpdate" | "ChatPostEphemeral" | "ChatGetPermalinkGet" | "ChatGetPermalink" | "ReactionsAdd" | "ReactionsRemove" | "ReactionsGetGet" | "ReactionsGet" | "AuthTestGet" | "AuthTest" | "ConversationsJoin" | "UsersInfoGet" | "UsersInfo" | "UsersLookupByEmailGet" | "UsersLookupByEmail" | "FilesInfoGet" | "FilesInfo" | "ViewsOpen" | "AppsConnectionsOpen";
1023
- type SupportedOperationId = "PostIncomingWebhook" | "ChatPostMessage" | "ChatUpdate" | "ChatPostEphemeral" | "ChatGetPermalinkGet" | "ChatGetPermalink" | "ReactionsAdd" | "ReactionsRemove" | "ReactionsGetGet" | "ReactionsGet" | "AuthTestGet" | "AuthTest" | "ConversationsJoin" | "UsersInfoGet" | "UsersInfo" | "UsersLookupByEmailGet" | "UsersLookupByEmail" | "FilesInfoGet" | "FilesInfo" | "ViewsOpen" | "AppsConnectionsOpen";
1024
- declare const operationIds: readonly ["PostIncomingWebhook", "ChatPostMessage", "ChatUpdate", "ChatPostEphemeral", "ChatGetPermalinkGet", "ChatGetPermalink", "ReactionsAdd", "ReactionsRemove", "ReactionsGetGet", "ReactionsGet", "AuthTestGet", "AuthTest", "ConversationsJoin", "UsersInfoGet", "UsersInfo", "UsersLookupByEmailGet", "UsersLookupByEmail", "FilesInfoGet", "FilesInfo", "ViewsOpen", "AppsConnectionsOpen"];
1025
- declare const supportedOperationIds: readonly ["PostIncomingWebhook", "ChatPostMessage", "ChatUpdate", "ChatPostEphemeral", "ChatGetPermalinkGet", "ChatGetPermalink", "ReactionsAdd", "ReactionsRemove", "ReactionsGetGet", "ReactionsGet", "AuthTestGet", "AuthTest", "ConversationsJoin", "UsersInfoGet", "UsersInfo", "UsersLookupByEmailGet", "UsersLookupByEmail", "FilesInfoGet", "FilesInfo", "ViewsOpen", "AppsConnectionsOpen"];
1503
+ type OperationId = "PostIncomingWebhook" | "ChatPostMessage" | "ChatUpdate" | "ChatPostEphemeral" | "ChatGetPermalinkGet" | "ChatGetPermalink" | "ReactionsAdd" | "ReactionsRemove" | "ReactionsGetGet" | "ReactionsGet" | "AuthTestGet" | "AuthTest" | "ConversationsJoin" | "UsersInfoGet" | "UsersInfo" | "UsersLookupByEmailGet" | "UsersLookupByEmail" | "FilesInfoGet" | "FilesInfo" | "ViewsOpen" | "AppsConnectionsOpen" | "GET /" | "GET /api/files.list" | "POST /api/files.list" | "GET /api/pins.list" | "POST /api/pins.list" | "GET /api/users.getPresence" | "POST /api/users.getPresence" | "GET /api/users.profile.get" | "POST /api/users.profile.get" | "GET /files-pri/:fileId/:filename" | "GET /oauth/v2/authorize" | "POST /api/bookmarks.add" | "POST /api/bookmarks.edit" | "POST /api/bookmarks.list" | "POST /api/bookmarks.remove" | "POST /api/bots.info" | "POST /api/chat.delete" | "POST /api/chat.deleteScheduledMessage" | "POST /api/chat.meMessage" | "POST /api/chat.scheduleMessage" | "POST /api/chat.scheduledMessages.list" | "POST /api/conversations.archive" | "POST /api/conversations.close" | "POST /api/conversations.create" | "POST /api/conversations.history" | "POST /api/conversations.info" | "POST /api/conversations.invite" | "POST /api/conversations.kick" | "POST /api/conversations.leave" | "POST /api/conversations.list" | "POST /api/conversations.mark" | "POST /api/conversations.members" | "POST /api/conversations.open" | "POST /api/conversations.rename" | "POST /api/conversations.replies" | "POST /api/conversations.setPurpose" | "POST /api/conversations.setTopic" | "POST /api/conversations.unarchive" | "POST /api/files.completeUploadExternal" | "POST /api/files.delete" | "POST /api/files.getUploadURLExternal" | "POST /api/oauth.v2.access" | "POST /api/pins.add" | "POST /api/pins.remove" | "POST /api/team.info" | "POST /api/users.list" | "POST /api/users.profile.set" | "POST /api/users.setPresence" | "POST /api/views.generateTriggerId" | "POST /api/views.publish" | "POST /api/views.push" | "POST /api/views.update" | "POST /oauth/v2/authorize/callback" | "POST /upload/v1/:fileId";
1504
+ type SupportedOperationId = "PostIncomingWebhook" | "ChatPostMessage" | "ChatUpdate" | "ChatPostEphemeral" | "ChatGetPermalinkGet" | "ChatGetPermalink" | "ReactionsAdd" | "ReactionsRemove" | "ReactionsGetGet" | "ReactionsGet" | "AuthTestGet" | "AuthTest" | "ConversationsJoin" | "UsersInfoGet" | "UsersInfo" | "UsersLookupByEmailGet" | "UsersLookupByEmail" | "FilesInfoGet" | "FilesInfo" | "ViewsOpen" | "AppsConnectionsOpen" | "GET /" | "GET /api/files.list" | "POST /api/files.list" | "GET /api/pins.list" | "POST /api/pins.list" | "GET /api/users.getPresence" | "POST /api/users.getPresence" | "GET /api/users.profile.get" | "POST /api/users.profile.get" | "GET /files-pri/:fileId/:filename" | "GET /oauth/v2/authorize" | "POST /api/bookmarks.add" | "POST /api/bookmarks.edit" | "POST /api/bookmarks.list" | "POST /api/bookmarks.remove" | "POST /api/bots.info" | "POST /api/chat.delete" | "POST /api/chat.deleteScheduledMessage" | "POST /api/chat.meMessage" | "POST /api/chat.scheduleMessage" | "POST /api/chat.scheduledMessages.list" | "POST /api/conversations.archive" | "POST /api/conversations.close" | "POST /api/conversations.create" | "POST /api/conversations.history" | "POST /api/conversations.info" | "POST /api/conversations.invite" | "POST /api/conversations.kick" | "POST /api/conversations.leave" | "POST /api/conversations.list" | "POST /api/conversations.mark" | "POST /api/conversations.members" | "POST /api/conversations.open" | "POST /api/conversations.rename" | "POST /api/conversations.replies" | "POST /api/conversations.setPurpose" | "POST /api/conversations.setTopic" | "POST /api/conversations.unarchive" | "POST /api/files.completeUploadExternal" | "POST /api/files.delete" | "POST /api/files.getUploadURLExternal" | "POST /api/oauth.v2.access" | "POST /api/pins.add" | "POST /api/pins.remove" | "POST /api/team.info" | "POST /api/users.list" | "POST /api/users.profile.set" | "POST /api/users.setPresence" | "POST /api/views.generateTriggerId" | "POST /api/views.publish" | "POST /api/views.push" | "POST /api/views.update" | "POST /oauth/v2/authorize/callback" | "POST /upload/v1/:fileId";
1505
+ declare const operationIds: readonly ["PostIncomingWebhook", "ChatPostMessage", "ChatUpdate", "ChatPostEphemeral", "ChatGetPermalinkGet", "ChatGetPermalink", "ReactionsAdd", "ReactionsRemove", "ReactionsGetGet", "ReactionsGet", "AuthTestGet", "AuthTest", "ConversationsJoin", "UsersInfoGet", "UsersInfo", "UsersLookupByEmailGet", "UsersLookupByEmail", "FilesInfoGet", "FilesInfo", "ViewsOpen", "AppsConnectionsOpen", "GET /", "GET /api/files.list", "POST /api/files.list", "GET /api/pins.list", "POST /api/pins.list", "GET /api/users.getPresence", "POST /api/users.getPresence", "GET /api/users.profile.get", "POST /api/users.profile.get", "GET /files-pri/:fileId/:filename", "GET /oauth/v2/authorize", "POST /api/bookmarks.add", "POST /api/bookmarks.edit", "POST /api/bookmarks.list", "POST /api/bookmarks.remove", "POST /api/bots.info", "POST /api/chat.delete", "POST /api/chat.deleteScheduledMessage", "POST /api/chat.meMessage", "POST /api/chat.scheduleMessage", "POST /api/chat.scheduledMessages.list", "POST /api/conversations.archive", "POST /api/conversations.close", "POST /api/conversations.create", "POST /api/conversations.history", "POST /api/conversations.info", "POST /api/conversations.invite", "POST /api/conversations.kick", "POST /api/conversations.leave", "POST /api/conversations.list", "POST /api/conversations.mark", "POST /api/conversations.members", "POST /api/conversations.open", "POST /api/conversations.rename", "POST /api/conversations.replies", "POST /api/conversations.setPurpose", "POST /api/conversations.setTopic", "POST /api/conversations.unarchive", "POST /api/files.completeUploadExternal", "POST /api/files.delete", "POST /api/files.getUploadURLExternal", "POST /api/oauth.v2.access", "POST /api/pins.add", "POST /api/pins.remove", "POST /api/team.info", "POST /api/users.list", "POST /api/users.profile.set", "POST /api/users.setPresence", "POST /api/views.generateTriggerId", "POST /api/views.publish", "POST /api/views.push", "POST /api/views.update", "POST /oauth/v2/authorize/callback", "POST /upload/v1/:fileId"];
1506
+ declare const supportedOperationIds: readonly ["PostIncomingWebhook", "ChatPostMessage", "ChatUpdate", "ChatPostEphemeral", "ChatGetPermalinkGet", "ChatGetPermalink", "ReactionsAdd", "ReactionsRemove", "ReactionsGetGet", "ReactionsGet", "AuthTestGet", "AuthTest", "ConversationsJoin", "UsersInfoGet", "UsersInfo", "UsersLookupByEmailGet", "UsersLookupByEmail", "FilesInfoGet", "FilesInfo", "ViewsOpen", "AppsConnectionsOpen", "GET /", "GET /api/files.list", "POST /api/files.list", "GET /api/pins.list", "POST /api/pins.list", "GET /api/users.getPresence", "POST /api/users.getPresence", "GET /api/users.profile.get", "POST /api/users.profile.get", "GET /files-pri/:fileId/:filename", "GET /oauth/v2/authorize", "POST /api/bookmarks.add", "POST /api/bookmarks.edit", "POST /api/bookmarks.list", "POST /api/bookmarks.remove", "POST /api/bots.info", "POST /api/chat.delete", "POST /api/chat.deleteScheduledMessage", "POST /api/chat.meMessage", "POST /api/chat.scheduleMessage", "POST /api/chat.scheduledMessages.list", "POST /api/conversations.archive", "POST /api/conversations.close", "POST /api/conversations.create", "POST /api/conversations.history", "POST /api/conversations.info", "POST /api/conversations.invite", "POST /api/conversations.kick", "POST /api/conversations.leave", "POST /api/conversations.list", "POST /api/conversations.mark", "POST /api/conversations.members", "POST /api/conversations.open", "POST /api/conversations.rename", "POST /api/conversations.replies", "POST /api/conversations.setPurpose", "POST /api/conversations.setTopic", "POST /api/conversations.unarchive", "POST /api/files.completeUploadExternal", "POST /api/files.delete", "POST /api/files.getUploadURLExternal", "POST /api/oauth.v2.access", "POST /api/pins.add", "POST /api/pins.remove", "POST /api/team.info", "POST /api/users.list", "POST /api/users.profile.set", "POST /api/users.setPresence", "POST /api/views.generateTriggerId", "POST /api/views.publish", "POST /api/views.push", "POST /api/views.update", "POST /oauth/v2/authorize/callback", "POST /upload/v1/:fileId"];
1026
1507
 
1027
1508
  /**
1028
1509
  * Every named Slack misbehaviour our consumers branch on, switched on with
1029
1510
  * `POST /__admin/faults {"preset": "<name>"}` (add `count` to limit it, `params` to tune it).
1030
1511
  */
1031
1512
  declare const SLACK_PRESETS: Record<string, FaultPreset>;
1032
- type SlackRuntimeOptions = {
1513
+ type SlackRuntimeOptions = Pick<SlackAPIOptions, "fixtures" | "baseUrl" | "tokens"> & {
1033
1514
  sqlite?: SqliteClient;
1034
1515
  clock?: Clock;
1035
1516
  seed?: number | string;
1036
1517
  adminPrefix?: string;
1037
1518
  adminKey?: string;
1519
+ /** Admin controls to boot with: clock, latency, faults, seed, a starting snapshot. */
1520
+ adminControls?: MockControls;
1038
1521
  onLog?: (entry: RequestLog) => void;
1039
1522
  settings?: Partial<Settings>;
1040
1523
  };
@@ -1047,7 +1530,8 @@ type SlackRuntime = ServiceRuntime<SlackAPI>;
1047
1530
  declare const createRuntime: (options?: SlackRuntimeOptions) => SlackRuntime;
1048
1531
 
1049
1532
  declare const SLACK_NAMESPACE = "slack";
1050
- type SlackAPIOptions = APIOptions & {
1533
+ type SlackAPIOptions = APIOptions & Pick<ProviderOptions, "tokens" | "baseUrl" | "publicNamespace" | "adminPrefix" | "random"> & {
1534
+ fixtures?: SlackSeedConfig;
1051
1535
  /** Initial per-namespace settings (workspace identity, accepted tokens, strict channels). */
1052
1536
  settings?: Partial<Settings>;
1053
1537
  /**
@@ -1071,11 +1555,14 @@ declare class SlackAPI implements FetchAPI$1 {
1071
1555
  readonly app: Hono;
1072
1556
  readonly sqlite: SqliteClient;
1073
1557
  readonly state: SlackState;
1558
+ private tail;
1559
+ private readonly expansion;
1074
1560
  private readonly service;
1075
1561
  private readonly now;
1076
1562
  private readonly namespaceName;
1077
1563
  constructor(options?: SlackAPIOptions);
1078
1564
  fetch(request: Request): Promise<Response>;
1565
+ private handleFetch;
1079
1566
  reset(): Promise<void>;
1080
1567
  /** Every message in the outbox, oldest first. */
1081
1568
  messages(): SlackMessage[];