@crvouga/mockingbird-service-slack 3.13.0 → 3.15.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
@@ -282,98 +282,6 @@ interface FetchAPI {
282
282
  /** A bare function form of {@link FetchAPI}, compatible with `Bun.serve`, workerd, and Deno. */
283
283
  type FetchHandler = (request: Request) => Promise<Response>;
284
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
- private readonly statements;
336
- private prepare;
337
- constructor(sqlite: SqliteClient$1,
338
- /** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
339
- namespace: string,
340
- /** Table name inside the namespace. Stable across resets of the rows themselves. */
341
- collectionName: string);
342
- private bumpCollectionSeq;
343
- nextSequence(): number;
344
- get(id: string): T | undefined;
345
- has(id: string): boolean;
346
- /** Insert a new record, assigning it the next sequence number. */
347
- insert(id: string, value: T): Stored<T>;
348
- /** Replace an existing record's value, keeping its position. */
349
- update(id: string, value: T): Stored<T> | undefined;
350
- delete(id: string): boolean;
351
- /** How many records the collection holds, without reading them. */
352
- count(): number;
353
- list(options?: ListRecordsOptions<T>): Array<Stored<T> & {
354
- id: string;
355
- }>;
356
- }
357
-
358
- /**
359
- * What names an id base: a non-negative safe integer (or its decimal string) or `"boot"`,
360
- * which derives the base from the wall clock when the runtime is created.
361
- */
362
- type IdBase = number | string;
363
-
364
- /** Options every provider constructor accepts. */
365
- type APIOptions = {
366
- /** Sync SQLite client. Defaults to `@crvouga/mockingbird-service-sqlite`. */
367
- sqlite?: SqliteClient$1;
368
- /** Clock used for `created`-style fields. Default `Date.now`. */
369
- now?: () => number;
370
- /**
371
- * Storage namespace for this instance's records. Instances sharing one SQLite
372
- * client stay isolated when their namespaces differ. Defaults to the service name.
373
- */
374
- namespace?: string;
375
- };
376
-
377
285
  /**
378
286
  * The single source of time for a service.
379
287
  *
@@ -404,6 +312,11 @@ type Clock = {
404
312
  state(): ClockState;
405
313
  };
406
314
 
315
+ type UpstreamState = {
316
+ mode: "emulated" | "forward";
317
+ baseUrl: string;
318
+ };
319
+
407
320
  /**
408
321
  * Seeded pseudo-random numbers, so anything a mock invents — ids, jitter, which
409
322
  * request a percentage fault hits — is reproducible from a seed.
@@ -680,6 +593,7 @@ declare const SNAPSHOT_FORMAT = "mockingbird.snapshot/v1";
680
593
  * `records` are required, so a hand-written seed file is a valid snapshot.
681
594
  */
682
595
  type SnapshotDocument = {
596
+ upstream?: UpstreamState;
683
597
  format: typeof SNAPSHOT_FORMAT;
684
598
  /** The service that wrote it. A snapshot is rejected by any other service. */
685
599
  service?: string;
@@ -753,6 +667,7 @@ type LatencyState = LatencyRule & {
753
667
  };
754
668
  /** What {@link controlHeaders} turns into request headers. */
755
669
  type ControlHeaderInput = {
670
+ upstream?: "emulated" | "forward";
756
671
  namespace?: string;
757
672
  adminKey?: string;
758
673
  branch?: string;
@@ -770,6 +685,48 @@ type ControlHeaderInput = {
770
685
  snapshot?: string;
771
686
  };
772
687
 
688
+ /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
689
+ type SqliteValue$1 = null | number | bigint | string | Uint8Array | boolean;
690
+ /** Mutation counters returned by {@link SqliteStatement.run}. */
691
+ type SqliteRunResult$1 = {
692
+ changes: number;
693
+ lastInsertRowid: number | bigint;
694
+ };
695
+ /**
696
+ * Prepared statement bound to a {@link SqliteClient}.
697
+ *
698
+ * Pass bind values as rest arguments on each call (no sticky `bind()`).
699
+ */
700
+ interface SqliteStatement$1 {
701
+ run(...params: SqliteValue$1[]): SqliteRunResult$1;
702
+ all<T = Record<string, unknown>>(...params: SqliteValue$1[]): T[];
703
+ get<T = Record<string, unknown>>(...params: SqliteValue$1[]): T | undefined;
704
+ }
705
+ /**
706
+ * Sync SQLite client port owned by Mockingbird.
707
+ *
708
+ * Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
709
+ * `bun:sqlite` instances all work when they expose this surface.
710
+ */
711
+ interface SqliteClient$1 {
712
+ exec(sql: string): void;
713
+ prepare(sql: string): SqliteStatement$1;
714
+ transaction<T>(fn: () => T): T;
715
+ }
716
+
717
+ /** Options every provider constructor accepts. */
718
+ type APIOptions = {
719
+ /** Sync SQLite client. Defaults to `@crvouga/mockingbird-service-sqlite`. */
720
+ sqlite?: SqliteClient$1;
721
+ /** Clock used for `created`-style fields. Default `Date.now`. */
722
+ now?: () => number;
723
+ /**
724
+ * Storage namespace for this instance's records. Instances sharing one SQLite
725
+ * client stay isolated when their namespaces differ. Defaults to the service name.
726
+ */
727
+ namespace?: string;
728
+ };
729
+
773
730
  /**
774
731
  * One problem with a request body, at a dotted path (`patient.address.city`, `items.0.sku`).
775
732
  * `kind` is `media_type` when the body is present but its media type is not one the operation
@@ -796,6 +753,7 @@ type RejectedRequest = {
796
753
  };
797
754
  /** One handled request, as the structured log sees it. */
798
755
  type RequestLog = {
756
+ upstream?: boolean;
799
757
  service: string;
800
758
  namespace: string;
801
759
  operationId: string | undefined;
@@ -930,8 +888,6 @@ type CredentialRegistry = {
930
888
  }[];
931
889
  };
932
890
 
933
- type OwnedTransport = (request: Request, namespace: string, send: typeof fetch) => Promise<Response>;
934
-
935
891
  /**
936
892
  * A point-in-time copy of everything a service namespace holds.
937
893
  *
@@ -954,6 +910,50 @@ type NamespaceSnapshot = {
954
910
  }[];
955
911
  };
956
912
 
913
+ /** Every stored record carries a monotonically increasing sequence for stable ordering. */
914
+ type Stored<T> = {
915
+ seq: number;
916
+ value: T;
917
+ };
918
+ type ListRecordsOptions<T> = {
919
+ /** Keep only records passing the predicate. */
920
+ where?: (value: T, seq: number) => boolean;
921
+ /** Sort order; default newest first. */
922
+ order?: "newest" | "oldest";
923
+ };
924
+ /**
925
+ * A SQLite-backed table of JSON records addressed by id. Ordering is by insertion
926
+ * sequence, never by id lexicographic order, so list semantics stay stable.
927
+ */
928
+ declare class Collection<T> {
929
+ private readonly sqlite;
930
+ /** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
931
+ readonly namespace: string;
932
+ /** Table name inside the namespace. Stable across resets of the rows themselves. */
933
+ readonly collectionName: string;
934
+ private readonly statements;
935
+ private prepare;
936
+ constructor(sqlite: SqliteClient$1,
937
+ /** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
938
+ namespace: string,
939
+ /** Table name inside the namespace. Stable across resets of the rows themselves. */
940
+ collectionName: string);
941
+ private bumpCollectionSeq;
942
+ nextSequence(): number;
943
+ get(id: string): T | undefined;
944
+ has(id: string): boolean;
945
+ /** Insert a new record, assigning it the next sequence number. */
946
+ insert(id: string, value: T): Stored<T>;
947
+ /** Replace an existing record's value, keeping its position. */
948
+ update(id: string, value: T): Stored<T> | undefined;
949
+ delete(id: string): boolean;
950
+ /** How many records the collection holds, without reading them. */
951
+ count(): number;
952
+ list(options?: ListRecordsOptions<T>): Array<Stored<T> & {
953
+ id: string;
954
+ }>;
955
+ }
956
+
957
957
  declare const STATE_FIELD_KINDS: readonly ["string", "number", "boolean", "null", "object", "array", "unknown"];
958
958
  type StateFieldKind = (typeof STATE_FIELD_KINDS)[number];
959
959
  /** JSON-safe annotations a bespoke admin UI may read. The default UI shows them as text. */
@@ -984,6 +984,14 @@ type StateView = {
984
984
  collections: StateCollectionView[];
985
985
  };
986
986
 
987
+ /**
988
+ * What names an id base: a non-negative safe integer (or its decimal string) or `"boot"`,
989
+ * which derives the base from the wall clock when the runtime is created.
990
+ */
991
+ type IdBase = number | string;
992
+
993
+ type OwnedTransport = (request: Request, namespace: string, send: typeof fetch) => Promise<Response>;
994
+
987
995
  type WebhookEndpoint = {
988
996
  /** Stable id; generated when omitted. */
989
997
  id?: string;
package/dist/index.js CHANGED
@@ -11,9 +11,7 @@ import {
11
11
  operationIds,
12
12
  slackCredential,
13
13
  supportedOperationIds
14
- } from "./chunk-BIGZEVCR.js";
15
- import "./chunk-BQ74Q6RF.js";
16
- import "./chunk-3FOAQLKT.js";
14
+ } from "./chunk-JBHAW5J2.js";
17
15
  export {
18
16
  DEFAULT_CHANNELS,
19
17
  DEFAULT_FILES,
package/dist/server.d.ts CHANGED
@@ -105,41 +105,6 @@ interface FetchAPI {
105
105
  /** A bare function form of {@link FetchAPI}, compatible with `Bun.serve`, workerd, and Deno. */
106
106
  type FetchHandler = (request: Request) => Promise<Response>;
107
107
 
108
- /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
109
- type SqliteValue = null | number | bigint | string | Uint8Array | boolean;
110
- /** Mutation counters returned by {@link SqliteStatement.run}. */
111
- type SqliteRunResult = {
112
- changes: number;
113
- lastInsertRowid: number | bigint;
114
- };
115
- /**
116
- * Prepared statement bound to a {@link SqliteClient}.
117
- *
118
- * Pass bind values as rest arguments on each call (no sticky `bind()`).
119
- */
120
- interface SqliteStatement {
121
- run(...params: SqliteValue[]): SqliteRunResult;
122
- all<T = Record<string, unknown>>(...params: SqliteValue[]): T[];
123
- get<T = Record<string, unknown>>(...params: SqliteValue[]): T | undefined;
124
- }
125
- /**
126
- * Sync SQLite client port owned by Mockingbird.
127
- *
128
- * Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
129
- * `bun:sqlite` instances all work when they expose this surface.
130
- */
131
- interface SqliteClient {
132
- exec(sql: string): void;
133
- prepare(sql: string): SqliteStatement;
134
- transaction<T>(fn: () => T): T;
135
- }
136
-
137
- /**
138
- * What names an id base: a non-negative safe integer (or its decimal string) or `"boot"`,
139
- * which derives the base from the wall clock when the runtime is created.
140
- */
141
- type IdBase = number | string;
142
-
143
108
  /**
144
109
  * The single source of time for a service.
145
110
  *
@@ -170,6 +135,11 @@ type Clock = {
170
135
  state(): ClockState;
171
136
  };
172
137
 
138
+ type UpstreamState = {
139
+ mode: "emulated" | "forward";
140
+ baseUrl: string;
141
+ };
142
+
173
143
  /**
174
144
  * Seeded pseudo-random numbers, so anything a mock invents — ids, jitter, which
175
145
  * request a percentage fault hits — is reproducible from a seed.
@@ -433,6 +403,7 @@ declare const SNAPSHOT_FORMAT = "mockingbird.snapshot/v1";
433
403
  * `records` are required, so a hand-written seed file is a valid snapshot.
434
404
  */
435
405
  type SnapshotDocument = {
406
+ upstream?: UpstreamState;
436
407
  format: typeof SNAPSHOT_FORMAT;
437
408
  /** The service that wrote it. A snapshot is rejected by any other service. */
438
409
  service?: string;
@@ -506,6 +477,7 @@ type LatencyState = LatencyRule & {
506
477
  };
507
478
  /** What {@link controlHeaders} turns into request headers. */
508
479
  type ControlHeaderInput = {
480
+ upstream?: "emulated" | "forward";
509
481
  namespace?: string;
510
482
  adminKey?: string;
511
483
  branch?: string;
@@ -523,6 +495,35 @@ type ControlHeaderInput = {
523
495
  snapshot?: string;
524
496
  };
525
497
 
498
+ /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
499
+ type SqliteValue = null | number | bigint | string | Uint8Array | boolean;
500
+ /** Mutation counters returned by {@link SqliteStatement.run}. */
501
+ type SqliteRunResult = {
502
+ changes: number;
503
+ lastInsertRowid: number | bigint;
504
+ };
505
+ /**
506
+ * Prepared statement bound to a {@link SqliteClient}.
507
+ *
508
+ * Pass bind values as rest arguments on each call (no sticky `bind()`).
509
+ */
510
+ interface SqliteStatement {
511
+ run(...params: SqliteValue[]): SqliteRunResult;
512
+ all<T = Record<string, unknown>>(...params: SqliteValue[]): T[];
513
+ get<T = Record<string, unknown>>(...params: SqliteValue[]): T | undefined;
514
+ }
515
+ /**
516
+ * Sync SQLite client port owned by Mockingbird.
517
+ *
518
+ * Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
519
+ * `bun:sqlite` instances all work when they expose this surface.
520
+ */
521
+ interface SqliteClient {
522
+ exec(sql: string): void;
523
+ prepare(sql: string): SqliteStatement;
524
+ transaction<T>(fn: () => T): T;
525
+ }
526
+
526
527
  /**
527
528
  * One problem with a request body, at a dotted path (`patient.address.city`, `items.0.sku`).
528
529
  * `kind` is `media_type` when the body is present but its media type is not one the operation
@@ -549,6 +550,7 @@ type RejectedRequest = {
549
550
  };
550
551
  /** One handled request, as the structured log sees it. */
551
552
  type RequestLog = {
553
+ upstream?: boolean;
552
554
  service: string;
553
555
  namespace: string;
554
556
  operationId: string | undefined;
@@ -683,8 +685,6 @@ type CredentialRegistry = {
683
685
  }[];
684
686
  };
685
687
 
686
- type OwnedTransport = (request: Request, namespace: string, send: typeof fetch) => Promise<Response>;
687
-
688
688
  /**
689
689
  * A point-in-time copy of everything a service namespace holds.
690
690
  *
@@ -737,6 +737,14 @@ type StateView = {
737
737
  collections: StateCollectionView[];
738
738
  };
739
739
 
740
+ /**
741
+ * What names an id base: a non-negative safe integer (or its decimal string) or `"boot"`,
742
+ * which derives the base from the wall clock when the runtime is created.
743
+ */
744
+ type IdBase = number | string;
745
+
746
+ type OwnedTransport = (request: Request, namespace: string, send: typeof fetch) => Promise<Response>;
747
+
740
748
  type WebhookEndpoint = {
741
749
  /** Stable id; generated when omitted. */
742
750
  id?: string;
package/dist/server.js CHANGED
@@ -2,10 +2,8 @@ import {
2
2
  DEFAULT_PORT,
3
3
  createServer,
4
4
  serveTarget
5
- } from "./chunk-5NRPYAM3.js";
6
- import "./chunk-BIGZEVCR.js";
7
- import "./chunk-BQ74Q6RF.js";
8
- import "./chunk-3FOAQLKT.js";
5
+ } from "./chunk-KQ42UMHX.js";
6
+ import "./chunk-JBHAW5J2.js";
9
7
  export {
10
8
  DEFAULT_PORT,
11
9
  createServer,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crvouga/mockingbird-service-slack",
3
- "version": "3.13.0",
3
+ "version": "3.15.0",
4
4
  "description": "Stateful emulator of Slack incoming webhooks, the Web API, and the Socket Mode control plane, with an outbox of every alert the app sent.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -101,7 +101,8 @@
101
101
  "pack:check": "bun ../../../scripts/pack-check.ts"
102
102
  },
103
103
  "dependencies": {
104
- "@crvouga/mockingbird-service-sqlite": "3.4.2",
104
+ "@crvouga/mockingbird-runtime": "0.0.1",
105
+ "@crvouga/mockingbird-service-sqlite": "3.5.0",
105
106
  "hono": "4.13.11",
106
107
  "buffer": "6.0.3",
107
108
  "@noble/hashes": "2.4.0",