@crvouga/mockingbird-service-docker 1.0.0 → 1.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,
@@ -629,76 +647,16 @@ interface FetchAPI$1 {
629
647
  fetch(request: Request): Promise<Response>;
630
648
  }
631
649
 
632
- /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
633
- type SqliteValue$1 = null | number | bigint | string | Uint8Array | boolean;
634
- /** Mutation counters returned by {@link SqliteStatement.run}. */
635
- type SqliteRunResult$1 = {
636
- changes: number;
637
- lastInsertRowid: number | bigint;
650
+ type MountedAPI = FetchAPI & {
651
+ readonly prefix: string;
652
+ GET: FetchHandler;
653
+ POST: FetchHandler;
654
+ PUT: FetchHandler;
655
+ PATCH: FetchHandler;
656
+ DELETE: FetchHandler;
657
+ HEAD: FetchHandler;
658
+ OPTIONS: FetchHandler;
638
659
  };
639
- /**
640
- * Prepared statement bound to a {@link SqliteClient}.
641
- *
642
- * Pass bind values as rest arguments on each call (no sticky `bind()`).
643
- */
644
- interface SqliteStatement$1 {
645
- run(...params: SqliteValue$1[]): SqliteRunResult$1;
646
- all<T = Record<string, unknown>>(...params: SqliteValue$1[]): T[];
647
- get<T = Record<string, unknown>>(...params: SqliteValue$1[]): T | undefined;
648
- }
649
- /**
650
- * Sync SQLite client port owned by Mockingbird.
651
- *
652
- * Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
653
- * `bun:sqlite` instances all work when they expose this surface.
654
- */
655
- interface SqliteClient$1 {
656
- exec(sql: string): void;
657
- prepare(sql: string): SqliteStatement$1;
658
- transaction<T>(fn: () => T): T;
659
- }
660
-
661
- /** Every stored record carries a monotonically increasing sequence for stable ordering. */
662
- type Stored<T> = {
663
- seq: number;
664
- value: T;
665
- };
666
- type ListRecordsOptions<T> = {
667
- /** Keep only records passing the predicate. */
668
- where?: (value: T, seq: number) => boolean;
669
- /** Sort order; default newest first. */
670
- order?: "newest" | "oldest";
671
- };
672
- /**
673
- * A SQLite-backed table of JSON records addressed by id. Ordering is by insertion
674
- * sequence, never by id lexicographic order, so list semantics stay stable.
675
- */
676
- declare class Collection<T> {
677
- private readonly sqlite;
678
- /** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
679
- readonly namespace: string;
680
- /** Table name inside the namespace. Stable across resets of the rows themselves. */
681
- readonly collectionName: string;
682
- constructor(sqlite: SqliteClient$1,
683
- /** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
684
- namespace: string,
685
- /** Table name inside the namespace. Stable across resets of the rows themselves. */
686
- collectionName: string);
687
- private bumpCollectionSeq;
688
- nextSequence(): number;
689
- get(id: string): T | undefined;
690
- has(id: string): boolean;
691
- /** Insert a new record, assigning it the next sequence number. */
692
- insert(id: string, value: T): Stored<T>;
693
- /** Replace an existing record's value, keeping its position. */
694
- update(id: string, value: T): Stored<T> | undefined;
695
- delete(id: string): boolean;
696
- /** How many records the collection holds, without reading them. */
697
- count(): number;
698
- list(options?: ListRecordsOptions<T>): Array<Stored<T> & {
699
- id: string;
700
- }>;
701
- }
702
660
 
703
661
  /** A stable identifier for a point in a {@link Timeline}. */
704
662
  type CheckpointId = string;
@@ -789,6 +747,79 @@ declare class Timeline<T> {
789
747
  interface FetchAPI {
790
748
  fetch(request: Request): Promise<Response>;
791
749
  }
750
+ /** A bare function form of {@link FetchAPI}, compatible with `Bun.serve`, workerd, and Deno. */
751
+ type FetchHandler = (request: Request) => Promise<Response>;
752
+
753
+ /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
754
+ type SqliteValue$1 = null | number | bigint | string | Uint8Array | boolean;
755
+ /** Mutation counters returned by {@link SqliteStatement.run}. */
756
+ type SqliteRunResult$1 = {
757
+ changes: number;
758
+ lastInsertRowid: number | bigint;
759
+ };
760
+ /**
761
+ * Prepared statement bound to a {@link SqliteClient}.
762
+ *
763
+ * Pass bind values as rest arguments on each call (no sticky `bind()`).
764
+ */
765
+ interface SqliteStatement$1 {
766
+ run(...params: SqliteValue$1[]): SqliteRunResult$1;
767
+ all<T = Record<string, unknown>>(...params: SqliteValue$1[]): T[];
768
+ get<T = Record<string, unknown>>(...params: SqliteValue$1[]): T | undefined;
769
+ }
770
+ /**
771
+ * Sync SQLite client port owned by Mockingbird.
772
+ *
773
+ * Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
774
+ * `bun:sqlite` instances all work when they expose this surface.
775
+ */
776
+ interface SqliteClient$1 {
777
+ exec(sql: string): void;
778
+ prepare(sql: string): SqliteStatement$1;
779
+ transaction<T>(fn: () => T): T;
780
+ }
781
+
782
+ /** Every stored record carries a monotonically increasing sequence for stable ordering. */
783
+ type Stored<T> = {
784
+ seq: number;
785
+ value: T;
786
+ };
787
+ type ListRecordsOptions<T> = {
788
+ /** Keep only records passing the predicate. */
789
+ where?: (value: T, seq: number) => boolean;
790
+ /** Sort order; default newest first. */
791
+ order?: "newest" | "oldest";
792
+ };
793
+ /**
794
+ * A SQLite-backed table of JSON records addressed by id. Ordering is by insertion
795
+ * sequence, never by id lexicographic order, so list semantics stay stable.
796
+ */
797
+ declare class Collection<T> {
798
+ private readonly sqlite;
799
+ /** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
800
+ readonly namespace: string;
801
+ /** Table name inside the namespace. Stable across resets of the rows themselves. */
802
+ readonly collectionName: string;
803
+ constructor(sqlite: SqliteClient$1,
804
+ /** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
805
+ namespace: string,
806
+ /** Table name inside the namespace. Stable across resets of the rows themselves. */
807
+ collectionName: string);
808
+ private bumpCollectionSeq;
809
+ nextSequence(): number;
810
+ get(id: string): T | undefined;
811
+ has(id: string): boolean;
812
+ /** Insert a new record, assigning it the next sequence number. */
813
+ insert(id: string, value: T): Stored<T>;
814
+ /** Replace an existing record's value, keeping its position. */
815
+ update(id: string, value: T): Stored<T> | undefined;
816
+ delete(id: string): boolean;
817
+ /** How many records the collection holds, without reading them. */
818
+ count(): number;
819
+ list(options?: ListRecordsOptions<T>): Array<Stored<T> & {
820
+ id: string;
821
+ }>;
822
+ }
792
823
 
793
824
  /**
794
825
  * The slice of OpenAPI 3.1 (and JSON Schema 2020-12) Mockingbird understands.
@@ -1554,6 +1585,8 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI & {
1554
1585
  /** Stop package-owned lifecycle timers when a supervisor closes the runtime. */
1555
1586
  stop?(): void;
1556
1587
  readonly name: string;
1588
+ /** Same-origin Fetch handler and App Router method exports, sharing this runtime. */
1589
+ mount(prefix: string): MountedAPI;
1557
1590
  readonly sqlite: SqliteClient$1;
1558
1591
  readonly clock: Clock;
1559
1592
  readonly faults: FaultRegistry;
package/dist/server.js CHANGED
@@ -2,8 +2,8 @@ import {
2
2
  DEFAULT_PORT,
3
3
  createServer,
4
4
  serveTarget
5
- } from "./chunk-AKUOBY2M.js";
6
- import "./chunk-3YOE2S2B.js";
5
+ } from "./chunk-TR75ZFCZ.js";
6
+ import "./chunk-5I542RFL.js";
7
7
  export {
8
8
  DEFAULT_PORT,
9
9
  createServer,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@crvouga/mockingbird-service-docker",
3
- "version": "1.0.0",
4
- "description": "Stateful Docker Engine API v1.52 mock with portable controls and Node transport.",
3
+ "version": "1.2.0",
4
+ "description": "Stateful Docker Engine API v1.52 emulator with portable controls and Node transport.",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "sideEffects": false,
@@ -104,7 +104,7 @@
104
104
  "pack:check": "bun ../../../scripts/pack-check.ts"
105
105
  },
106
106
  "dependencies": {
107
- "@crvouga/mockingbird-service-sqlite": "3.0.0",
107
+ "@crvouga/mockingbird-service-sqlite": "3.2.0",
108
108
  "hono": "4.11.9"
109
109
  },
110
110
  "devDependencies": {