@crvouga/mockingbird-service-mailosaur 3.0.0 → 3.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.
package/dist/server.d.ts CHANGED
@@ -1,34 +1,16 @@
1
1
  import { Server } from 'node:http';
2
2
  import { Hono } from 'hono';
3
3
 
4
- /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
5
- type SqliteValue$2 = null | number | bigint | string | Uint8Array | boolean;
6
- /** Mutation counters returned by {@link SqliteStatement.run}. */
7
- type SqliteRunResult$2 = {
8
- changes: number;
9
- lastInsertRowid: number | bigint;
4
+ type MountedAPI$1 = FetchAPI$2 & {
5
+ readonly prefix: string;
6
+ GET: FetchHandler$1;
7
+ POST: FetchHandler$1;
8
+ PUT: FetchHandler$1;
9
+ PATCH: FetchHandler$1;
10
+ DELETE: FetchHandler$1;
11
+ HEAD: FetchHandler$1;
12
+ OPTIONS: FetchHandler$1;
10
13
  };
11
- /**
12
- * Prepared statement bound to a {@link SqliteClient}.
13
- *
14
- * Pass bind values as rest arguments on each call (no sticky `bind()`).
15
- */
16
- interface SqliteStatement$2 {
17
- run(...params: SqliteValue$2[]): SqliteRunResult$2;
18
- all<T = Record<string, unknown>>(...params: SqliteValue$2[]): T[];
19
- get<T = Record<string, unknown>>(...params: SqliteValue$2[]): T | undefined;
20
- }
21
- /**
22
- * Sync SQLite client port owned by Mockingbird.
23
- *
24
- * Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
25
- * `bun:sqlite` instances all work when they expose this surface.
26
- */
27
- interface SqliteClient$2 {
28
- exec(sql: string): void;
29
- prepare(sql: string): SqliteStatement$2;
30
- transaction<T>(fn: () => T): T;
31
- }
32
14
 
33
15
  /** A stable identifier for a point in a {@link Timeline}. */
34
16
  type CheckpointId$1 = string;
@@ -119,6 +101,37 @@ declare class Timeline$1<T> {
119
101
  interface FetchAPI$2 {
120
102
  fetch(request: Request): Promise<Response>;
121
103
  }
104
+ /** A bare function form of {@link FetchAPI}, compatible with `Bun.serve`, workerd, and Deno. */
105
+ type FetchHandler$1 = (request: Request) => Promise<Response>;
106
+
107
+ /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
108
+ type SqliteValue$2 = null | number | bigint | string | Uint8Array | boolean;
109
+ /** Mutation counters returned by {@link SqliteStatement.run}. */
110
+ type SqliteRunResult$2 = {
111
+ changes: number;
112
+ lastInsertRowid: number | bigint;
113
+ };
114
+ /**
115
+ * Prepared statement bound to a {@link SqliteClient}.
116
+ *
117
+ * Pass bind values as rest arguments on each call (no sticky `bind()`).
118
+ */
119
+ interface SqliteStatement$2 {
120
+ run(...params: SqliteValue$2[]): SqliteRunResult$2;
121
+ all<T = Record<string, unknown>>(...params: SqliteValue$2[]): T[];
122
+ get<T = Record<string, unknown>>(...params: SqliteValue$2[]): T | undefined;
123
+ }
124
+ /**
125
+ * Sync SQLite client port owned by Mockingbird.
126
+ *
127
+ * Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
128
+ * `bun:sqlite` instances all work when they expose this surface.
129
+ */
130
+ interface SqliteClient$2 {
131
+ exec(sql: string): void;
132
+ prepare(sql: string): SqliteStatement$2;
133
+ transaction<T>(fn: () => T): T;
134
+ }
122
135
 
123
136
  /**
124
137
  * The single source of time for a service.
@@ -535,6 +548,8 @@ type ServiceRuntime$1<T extends ServiceInstance$1> = FetchAPI$2 & {
535
548
  /** Stop package-owned lifecycle timers when a supervisor closes the runtime. */
536
549
  stop?(): void;
537
550
  readonly name: string;
551
+ /** Same-origin Fetch handler and App Router method exports, sharing this runtime. */
552
+ mount(prefix: string): MountedAPI$1;
538
553
  readonly sqlite: SqliteClient$2;
539
554
  readonly clock: Clock$1;
540
555
  readonly faults: FaultRegistry$1;
@@ -601,6 +616,9 @@ type CommonServeOptions = {
601
616
  adminKey: string | undefined;
602
617
  seed: string | undefined;
603
618
  onLog: ((entry: RequestLog$1) => void) | undefined;
619
+ /** Synthetic provider fixture objects supplied by a fleet entry. */
620
+ fixtures?: Record<string, unknown>;
621
+ baseUrl?: string;
604
622
  };
605
623
  /**
606
624
  * What a service contributes to `serve`: how to build its runtime from CLI flags,
@@ -619,88 +637,16 @@ type ServeTarget = {
619
637
  listening?(server: Listening): void;
620
638
  };
621
639
 
622
- /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
623
- type SqliteValue$1 = null | number | bigint | string | Uint8Array | boolean;
624
- /** Mutation counters returned by {@link SqliteStatement.run}. */
625
- type SqliteRunResult$1 = {
626
- changes: number;
627
- lastInsertRowid: number | bigint;
640
+ type MountedAPI = FetchAPI$1 & {
641
+ readonly prefix: string;
642
+ GET: FetchHandler;
643
+ POST: FetchHandler;
644
+ PUT: FetchHandler;
645
+ PATCH: FetchHandler;
646
+ DELETE: FetchHandler;
647
+ HEAD: FetchHandler;
648
+ OPTIONS: FetchHandler;
628
649
  };
629
- /**
630
- * Prepared statement bound to a {@link SqliteClient}.
631
- *
632
- * Pass bind values as rest arguments on each call (no sticky `bind()`).
633
- */
634
- interface SqliteStatement$1 {
635
- run(...params: SqliteValue$1[]): SqliteRunResult$1;
636
- all<T = Record<string, unknown>>(...params: SqliteValue$1[]): T[];
637
- get<T = Record<string, unknown>>(...params: SqliteValue$1[]): T | undefined;
638
- }
639
- /**
640
- * Sync SQLite client port owned by Mockingbird.
641
- *
642
- * Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
643
- * `bun:sqlite` instances all work when they expose this surface.
644
- */
645
- interface SqliteClient$1 {
646
- exec(sql: string): void;
647
- prepare(sql: string): SqliteStatement$1;
648
- transaction<T>(fn: () => T): T;
649
- }
650
-
651
- /** Every stored record carries a monotonically increasing sequence for stable ordering. */
652
- type Stored<T> = {
653
- seq: number;
654
- value: T;
655
- };
656
- type ListRecordsOptions<T> = {
657
- /** Keep only records passing the predicate. */
658
- where?: (value: T, seq: number) => boolean;
659
- /** Sort order; default newest first. */
660
- order?: "newest" | "oldest";
661
- };
662
- /**
663
- * A SQLite-backed table of JSON records addressed by id. Ordering is by insertion
664
- * sequence, never by id lexicographic order, so list semantics stay stable.
665
- */
666
- declare class Collection<T> {
667
- private readonly sqlite;
668
- /** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
669
- readonly namespace: string;
670
- /** Table name inside the namespace. Stable across resets of the rows themselves. */
671
- readonly collectionName: string;
672
- constructor(sqlite: SqliteClient$1,
673
- /** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
674
- namespace: string,
675
- /** Table name inside the namespace. Stable across resets of the rows themselves. */
676
- collectionName: string);
677
- private bumpCollectionSeq;
678
- nextSequence(): number;
679
- get(id: string): T | undefined;
680
- has(id: string): boolean;
681
- /** Insert a new record, assigning it the next sequence number. */
682
- insert(id: string, value: T): Stored<T>;
683
- /** Replace an existing record's value, keeping its position. */
684
- update(id: string, value: T): Stored<T> | undefined;
685
- delete(id: string): boolean;
686
- /** How many records the collection holds, without reading them. */
687
- count(): number;
688
- list(options?: ListRecordsOptions<T>): Array<Stored<T> & {
689
- id: string;
690
- }>;
691
- }
692
-
693
- /**
694
- * Sequential id source persisted in SQLite. Ids are deterministic for a given
695
- * sequence history (`cus_` + 14 opaque chars), so reproductions stay stable.
696
- */
697
- declare class IdSequence {
698
- private readonly sqlite;
699
- private readonly namespace;
700
- private readonly salt;
701
- constructor(sqlite: SqliteClient$1, namespace: string, salt?: string);
702
- next(prefix: string, length?: number): string;
703
- }
704
650
 
705
651
  /** A stable identifier for a point in a {@link Timeline}. */
706
652
  type CheckpointId = string;
@@ -791,6 +737,91 @@ declare class Timeline<T> {
791
737
  interface FetchAPI$1 {
792
738
  fetch(request: Request): Promise<Response>;
793
739
  }
740
+ /** A bare function form of {@link FetchAPI}, compatible with `Bun.serve`, workerd, and Deno. */
741
+ type FetchHandler = (request: Request) => Promise<Response>;
742
+
743
+ /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
744
+ type SqliteValue$1 = null | number | bigint | string | Uint8Array | boolean;
745
+ /** Mutation counters returned by {@link SqliteStatement.run}. */
746
+ type SqliteRunResult$1 = {
747
+ changes: number;
748
+ lastInsertRowid: number | bigint;
749
+ };
750
+ /**
751
+ * Prepared statement bound to a {@link SqliteClient}.
752
+ *
753
+ * Pass bind values as rest arguments on each call (no sticky `bind()`).
754
+ */
755
+ interface SqliteStatement$1 {
756
+ run(...params: SqliteValue$1[]): SqliteRunResult$1;
757
+ all<T = Record<string, unknown>>(...params: SqliteValue$1[]): T[];
758
+ get<T = Record<string, unknown>>(...params: SqliteValue$1[]): T | undefined;
759
+ }
760
+ /**
761
+ * Sync SQLite client port owned by Mockingbird.
762
+ *
763
+ * Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
764
+ * `bun:sqlite` instances all work when they expose this surface.
765
+ */
766
+ interface SqliteClient$1 {
767
+ exec(sql: string): void;
768
+ prepare(sql: string): SqliteStatement$1;
769
+ transaction<T>(fn: () => T): T;
770
+ }
771
+
772
+ /** Every stored record carries a monotonically increasing sequence for stable ordering. */
773
+ type Stored<T> = {
774
+ seq: number;
775
+ value: T;
776
+ };
777
+ type ListRecordsOptions<T> = {
778
+ /** Keep only records passing the predicate. */
779
+ where?: (value: T, seq: number) => boolean;
780
+ /** Sort order; default newest first. */
781
+ order?: "newest" | "oldest";
782
+ };
783
+ /**
784
+ * A SQLite-backed table of JSON records addressed by id. Ordering is by insertion
785
+ * sequence, never by id lexicographic order, so list semantics stay stable.
786
+ */
787
+ declare class Collection<T> {
788
+ private readonly sqlite;
789
+ /** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
790
+ readonly namespace: string;
791
+ /** Table name inside the namespace. Stable across resets of the rows themselves. */
792
+ readonly collectionName: string;
793
+ constructor(sqlite: SqliteClient$1,
794
+ /** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
795
+ namespace: string,
796
+ /** Table name inside the namespace. Stable across resets of the rows themselves. */
797
+ collectionName: string);
798
+ private bumpCollectionSeq;
799
+ nextSequence(): number;
800
+ get(id: string): T | undefined;
801
+ has(id: string): boolean;
802
+ /** Insert a new record, assigning it the next sequence number. */
803
+ insert(id: string, value: T): Stored<T>;
804
+ /** Replace an existing record's value, keeping its position. */
805
+ update(id: string, value: T): Stored<T> | undefined;
806
+ delete(id: string): boolean;
807
+ /** How many records the collection holds, without reading them. */
808
+ count(): number;
809
+ list(options?: ListRecordsOptions<T>): Array<Stored<T> & {
810
+ id: string;
811
+ }>;
812
+ }
813
+
814
+ /**
815
+ * Sequential id source persisted in SQLite. Ids are deterministic for a given
816
+ * sequence history (`cus_` + 14 opaque chars), so reproductions stay stable.
817
+ */
818
+ declare class IdSequence {
819
+ private readonly sqlite;
820
+ private readonly namespace;
821
+ private readonly salt;
822
+ constructor(sqlite: SqliteClient$1, namespace: string, salt?: string);
823
+ next(prefix: string, length?: number): string;
824
+ }
794
825
 
795
826
  /** Options every provider constructor accepts. */
796
827
  type APIOptions = {
@@ -1220,6 +1251,8 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI$1 & {
1220
1251
  /** Stop package-owned lifecycle timers when a supervisor closes the runtime. */
1221
1252
  stop?(): void;
1222
1253
  readonly name: string;
1254
+ /** Same-origin Fetch handler and App Router method exports, sharing this runtime. */
1255
+ mount(prefix: string): MountedAPI;
1223
1256
  readonly sqlite: SqliteClient$1;
1224
1257
  readonly clock: Clock;
1225
1258
  readonly faults: FaultRegistry;
package/dist/server.js CHANGED
@@ -4,8 +4,8 @@ import {
4
4
  createServer,
5
5
  selfSignedCertificate,
6
6
  serveTarget
7
- } from "./chunk-NWHF63LJ.js";
8
- import "./chunk-3QF4WQTT.js";
7
+ } from "./chunk-X6FOBGVH.js";
8
+ import "./chunk-UW6DSYMU.js";
9
9
  export {
10
10
  CERTIFICATE_HOSTS,
11
11
  DEFAULT_PORT,
package/openapi.yaml CHANGED
@@ -2,7 +2,7 @@ openapi: 3.1.0
2
2
  info:
3
3
  title: Mailosaur API (Mockingbird subset)
4
4
  description: |
5
- Stateful mock subset of the Mailosaur email/SMS testing API: message search (the SDK's
5
+ Stateful emulator subset of the Mailosaur email/SMS testing API: message search (the SDK's
6
6
  client-side long-poll behind `messages.get`), list, get by id, delete, delete-all, create,
7
7
  and the server-side `await` long-poll. Hand-authored from the `mailosaur@11.1.0` Node SDK
8
8
  (the exact requests it sends and the fields its models read) and our consumer's
@@ -22,7 +22,7 @@ paths:
22
22
  operationId: SearchMessages
23
23
  description: >-
24
24
  Message summaries matching the criteria, newest first. Answers at once; when nothing
25
- matches, `x-ms-delay` tells the SDK how long to wait before polling again (the mock's
25
+ matches, `x-ms-delay` tells the SDK how long to wait before polling again (the emulator's
26
26
  default is 20 ms, so `messages.get` returns within ~20 ms of a message arriving).
27
27
  x-mockingbird:
28
28
  supported: true
@@ -207,7 +207,7 @@ paths:
207
207
  operationId: CreateMessage
208
208
  description: >-
209
209
  `messages.create`: a new message in the server's inbox (the vendor would also send it to
210
- a verified address when `send` is true; the mock only stores it).
210
+ a verified address when `send` is true; the emulator only stores it).
211
211
  x-mockingbird:
212
212
  supported: true
213
213
  parity:
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@crvouga/mockingbird-service-mailosaur",
3
- "version": "3.0.0",
4
- "description": "Stateful mock of the Mailosaur email/SMS testing API (messages search, get, delete, long-poll) with an HTTP ingest so other mocks can drop mail in (Mockingbird service contract).",
3
+ "version": "3.2.0",
4
+ "description": "Stateful emulator of the Mailosaur email/SMS testing API (messages search, get, delete, long-poll) with an HTTP ingest so other emulators can drop mail in (Mockingbird service contract).",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "sideEffects": false,
@@ -45,7 +45,7 @@
45
45
  "email",
46
46
  "inbox",
47
47
  "testing",
48
- "mock"
48
+ "emulator"
49
49
  ],
50
50
  "mockingbird": {
51
51
  "runtime": "portable",
@@ -98,7 +98,7 @@
98
98
  "pack:check": "bun ../../../scripts/pack-check.ts"
99
99
  },
100
100
  "dependencies": {
101
- "@crvouga/mockingbird-service-sqlite": "3.0.0",
101
+ "@crvouga/mockingbird-service-sqlite": "3.2.0",
102
102
  "hono": "4.11.9"
103
103
  },
104
104
  "devDependencies": {