@crvouga/mockingbird-service-textract 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
@@ -101,110 +101,6 @@ interface FetchAPI {
101
101
  /** A bare function form of {@link FetchAPI}, compatible with `Bun.serve`, workerd, and Deno. */
102
102
  type FetchHandler = (request: Request) => Promise<Response>;
103
103
 
104
- /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
105
- type SqliteValue$1 = null | number | bigint | string | Uint8Array | boolean;
106
- /** Mutation counters returned by {@link SqliteStatement.run}. */
107
- type SqliteRunResult$1 = {
108
- changes: number;
109
- lastInsertRowid: number | bigint;
110
- };
111
- /**
112
- * Prepared statement bound to a {@link SqliteClient}.
113
- *
114
- * Pass bind values as rest arguments on each call (no sticky `bind()`).
115
- */
116
- interface SqliteStatement$1 {
117
- run(...params: SqliteValue$1[]): SqliteRunResult$1;
118
- all<T = Record<string, unknown>>(...params: SqliteValue$1[]): T[];
119
- get<T = Record<string, unknown>>(...params: SqliteValue$1[]): T | undefined;
120
- }
121
- /**
122
- * Sync SQLite client port owned by Mockingbird.
123
- *
124
- * Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
125
- * `bun:sqlite` instances all work when they expose this surface.
126
- */
127
- interface SqliteClient$1 {
128
- exec(sql: string): void;
129
- prepare(sql: string): SqliteStatement$1;
130
- transaction<T>(fn: () => T): T;
131
- }
132
-
133
- /** Every stored record carries a monotonically increasing sequence for stable ordering. */
134
- type Stored<T> = {
135
- seq: number;
136
- value: T;
137
- };
138
- type ListRecordsOptions<T> = {
139
- /** Keep only records passing the predicate. */
140
- where?: (value: T, seq: number) => boolean;
141
- /** Sort order; default newest first. */
142
- order?: "newest" | "oldest";
143
- };
144
- /**
145
- * A SQLite-backed table of JSON records addressed by id. Ordering is by insertion
146
- * sequence, never by id lexicographic order, so list semantics stay stable.
147
- */
148
- declare class Collection<T> {
149
- private readonly sqlite;
150
- /** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
151
- readonly namespace: string;
152
- /** Table name inside the namespace. Stable across resets of the rows themselves. */
153
- readonly collectionName: string;
154
- private readonly statements;
155
- private prepare;
156
- constructor(sqlite: SqliteClient$1,
157
- /** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
158
- namespace: string,
159
- /** Table name inside the namespace. Stable across resets of the rows themselves. */
160
- collectionName: string);
161
- private bumpCollectionSeq;
162
- nextSequence(): number;
163
- get(id: string): T | undefined;
164
- has(id: string): boolean;
165
- /** Insert a new record, assigning it the next sequence number. */
166
- insert(id: string, value: T): Stored<T>;
167
- /** Replace an existing record's value, keeping its position. */
168
- update(id: string, value: T): Stored<T> | undefined;
169
- delete(id: string): boolean;
170
- /** How many records the collection holds, without reading them. */
171
- count(): number;
172
- list(options?: ListRecordsOptions<T>): Array<Stored<T> & {
173
- id: string;
174
- }>;
175
- }
176
-
177
- /**
178
- * What names an id base: a non-negative safe integer (or its decimal string) or `"boot"`,
179
- * which derives the base from the wall clock when the runtime is created.
180
- */
181
- type IdBase = number | string;
182
- /**
183
- * Sequential id source persisted in SQLite. Ids are deterministic for a given
184
- * sequence history (`cus_` + 14 opaque chars), so reproductions stay stable.
185
- * A runtime's `idBase` is mixed in, so a different base reissues none of another's ids.
186
- */
187
- declare class IdSequence {
188
- private readonly sqlite;
189
- private readonly namespace;
190
- private readonly salt;
191
- constructor(sqlite: SqliteClient$1, namespace: string, salt?: string);
192
- next(prefix: string, length?: number): string;
193
- }
194
-
195
- /** Options every provider constructor accepts. */
196
- type APIOptions = {
197
- /** Sync SQLite client. Defaults to `@crvouga/mockingbird-service-sqlite`. */
198
- sqlite?: SqliteClient$1;
199
- /** Clock used for `created`-style fields. Default `Date.now`. */
200
- now?: () => number;
201
- /**
202
- * Storage namespace for this instance's records. Instances sharing one SQLite
203
- * client stay isolated when their namespaces differ. Defaults to the service name.
204
- */
205
- namespace?: string;
206
- };
207
-
208
104
  /**
209
105
  * The single source of time for a service.
210
106
  *
@@ -235,6 +131,11 @@ type Clock = {
235
131
  state(): ClockState;
236
132
  };
237
133
 
134
+ type UpstreamState = {
135
+ mode: "emulated" | "forward";
136
+ baseUrl: string;
137
+ };
138
+
238
139
  /**
239
140
  * Seeded pseudo-random numbers, so anything a mock invents — ids, jitter, which
240
141
  * request a percentage fault hits — is reproducible from a seed.
@@ -511,6 +412,7 @@ declare const SNAPSHOT_FORMAT = "mockingbird.snapshot/v1";
511
412
  * `records` are required, so a hand-written seed file is a valid snapshot.
512
413
  */
513
414
  type SnapshotDocument = {
415
+ upstream?: UpstreamState;
514
416
  format: typeof SNAPSHOT_FORMAT;
515
417
  /** The service that wrote it. A snapshot is rejected by any other service. */
516
418
  service?: string;
@@ -584,6 +486,7 @@ type LatencyState = LatencyRule & {
584
486
  };
585
487
  /** What {@link controlHeaders} turns into request headers. */
586
488
  type ControlHeaderInput = {
489
+ upstream?: "emulated" | "forward";
587
490
  namespace?: string;
588
491
  adminKey?: string;
589
492
  branch?: string;
@@ -601,6 +504,48 @@ type ControlHeaderInput = {
601
504
  snapshot?: string;
602
505
  };
603
506
 
507
+ /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
508
+ type SqliteValue$1 = null | number | bigint | string | Uint8Array | boolean;
509
+ /** Mutation counters returned by {@link SqliteStatement.run}. */
510
+ type SqliteRunResult$1 = {
511
+ changes: number;
512
+ lastInsertRowid: number | bigint;
513
+ };
514
+ /**
515
+ * Prepared statement bound to a {@link SqliteClient}.
516
+ *
517
+ * Pass bind values as rest arguments on each call (no sticky `bind()`).
518
+ */
519
+ interface SqliteStatement$1 {
520
+ run(...params: SqliteValue$1[]): SqliteRunResult$1;
521
+ all<T = Record<string, unknown>>(...params: SqliteValue$1[]): T[];
522
+ get<T = Record<string, unknown>>(...params: SqliteValue$1[]): T | undefined;
523
+ }
524
+ /**
525
+ * Sync SQLite client port owned by Mockingbird.
526
+ *
527
+ * Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
528
+ * `bun:sqlite` instances all work when they expose this surface.
529
+ */
530
+ interface SqliteClient$1 {
531
+ exec(sql: string): void;
532
+ prepare(sql: string): SqliteStatement$1;
533
+ transaction<T>(fn: () => T): T;
534
+ }
535
+
536
+ /** Options every provider constructor accepts. */
537
+ type APIOptions = {
538
+ /** Sync SQLite client. Defaults to `@crvouga/mockingbird-service-sqlite`. */
539
+ sqlite?: SqliteClient$1;
540
+ /** Clock used for `created`-style fields. Default `Date.now`. */
541
+ now?: () => number;
542
+ /**
543
+ * Storage namespace for this instance's records. Instances sharing one SQLite
544
+ * client stay isolated when their namespaces differ. Defaults to the service name.
545
+ */
546
+ namespace?: string;
547
+ };
548
+
604
549
  /**
605
550
  * One problem with a request body, at a dotted path (`patient.address.city`, `items.0.sku`).
606
551
  * `kind` is `media_type` when the body is present but its media type is not one the operation
@@ -627,6 +572,7 @@ type RejectedRequest = {
627
572
  };
628
573
  /** One handled request, as the structured log sees it. */
629
574
  type RequestLog = {
575
+ upstream?: boolean;
630
576
  service: string;
631
577
  namespace: string;
632
578
  operationId: string | undefined;
@@ -761,8 +707,6 @@ type CredentialRegistry = {
761
707
  }[];
762
708
  };
763
709
 
764
- type OwnedTransport = (request: Request, namespace: string, send: typeof fetch) => Promise<Response>;
765
-
766
710
  /**
767
711
  * A point-in-time copy of everything a service namespace holds.
768
712
  *
@@ -785,6 +729,50 @@ type NamespaceSnapshot = {
785
729
  }[];
786
730
  };
787
731
 
732
+ /** Every stored record carries a monotonically increasing sequence for stable ordering. */
733
+ type Stored<T> = {
734
+ seq: number;
735
+ value: T;
736
+ };
737
+ type ListRecordsOptions<T> = {
738
+ /** Keep only records passing the predicate. */
739
+ where?: (value: T, seq: number) => boolean;
740
+ /** Sort order; default newest first. */
741
+ order?: "newest" | "oldest";
742
+ };
743
+ /**
744
+ * A SQLite-backed table of JSON records addressed by id. Ordering is by insertion
745
+ * sequence, never by id lexicographic order, so list semantics stay stable.
746
+ */
747
+ declare class Collection<T> {
748
+ private readonly sqlite;
749
+ /** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
750
+ readonly namespace: string;
751
+ /** Table name inside the namespace. Stable across resets of the rows themselves. */
752
+ readonly collectionName: string;
753
+ private readonly statements;
754
+ private prepare;
755
+ constructor(sqlite: SqliteClient$1,
756
+ /** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
757
+ namespace: string,
758
+ /** Table name inside the namespace. Stable across resets of the rows themselves. */
759
+ collectionName: string);
760
+ private bumpCollectionSeq;
761
+ nextSequence(): number;
762
+ get(id: string): T | undefined;
763
+ has(id: string): boolean;
764
+ /** Insert a new record, assigning it the next sequence number. */
765
+ insert(id: string, value: T): Stored<T>;
766
+ /** Replace an existing record's value, keeping its position. */
767
+ update(id: string, value: T): Stored<T> | undefined;
768
+ delete(id: string): boolean;
769
+ /** How many records the collection holds, without reading them. */
770
+ count(): number;
771
+ list(options?: ListRecordsOptions<T>): Array<Stored<T> & {
772
+ id: string;
773
+ }>;
774
+ }
775
+
788
776
  declare const STATE_FIELD_KINDS: readonly ["string", "number", "boolean", "null", "object", "array", "unknown"];
789
777
  type StateFieldKind = (typeof STATE_FIELD_KINDS)[number];
790
778
  /** JSON-safe annotations a bespoke admin UI may read. The default UI shows them as text. */
@@ -815,6 +803,26 @@ type StateView = {
815
803
  collections: StateCollectionView[];
816
804
  };
817
805
 
806
+ /**
807
+ * What names an id base: a non-negative safe integer (or its decimal string) or `"boot"`,
808
+ * which derives the base from the wall clock when the runtime is created.
809
+ */
810
+ type IdBase = number | string;
811
+ /**
812
+ * Sequential id source persisted in SQLite. Ids are deterministic for a given
813
+ * sequence history (`cus_` + 14 opaque chars), so reproductions stay stable.
814
+ * A runtime's `idBase` is mixed in, so a different base reissues none of another's ids.
815
+ */
816
+ declare class IdSequence {
817
+ private readonly sqlite;
818
+ private readonly namespace;
819
+ private readonly salt;
820
+ constructor(sqlite: SqliteClient$1, namespace: string, salt?: string);
821
+ next(prefix: string, length?: number): string;
822
+ }
823
+
824
+ type OwnedTransport = (request: Request, namespace: string, send: typeof fetch) => Promise<Response>;
825
+
818
826
  type WebhookEndpoint = {
819
827
  /** Stable id; generated when omitted. */
820
828
  id?: string;
package/dist/index.js CHANGED
@@ -7,8 +7,7 @@ import {
7
7
  document,
8
8
  operationIds,
9
9
  supportedOperationIds
10
- } from "./chunk-TIIQEPPL.js";
11
- import "./chunk-K2BAVPFL.js";
10
+ } from "./chunk-XKCZKCGQ.js";
12
11
  export {
13
12
  TEXTRACT_NAMESPACE,
14
13
  TEXTRACT_PRESETS,
package/dist/server.d.ts CHANGED
@@ -104,41 +104,6 @@ interface FetchAPI {
104
104
  /** A bare function form of {@link FetchAPI}, compatible with `Bun.serve`, workerd, and Deno. */
105
105
  type FetchHandler = (request: Request) => Promise<Response>;
106
106
 
107
- /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
108
- type SqliteValue = null | number | bigint | string | Uint8Array | boolean;
109
- /** Mutation counters returned by {@link SqliteStatement.run}. */
110
- type SqliteRunResult = {
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 {
120
- run(...params: SqliteValue[]): SqliteRunResult;
121
- all<T = Record<string, unknown>>(...params: SqliteValue[]): T[];
122
- get<T = Record<string, unknown>>(...params: SqliteValue[]): 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 {
131
- exec(sql: string): void;
132
- prepare(sql: string): SqliteStatement;
133
- transaction<T>(fn: () => T): T;
134
- }
135
-
136
- /**
137
- * What names an id base: a non-negative safe integer (or its decimal string) or `"boot"`,
138
- * which derives the base from the wall clock when the runtime is created.
139
- */
140
- type IdBase = number | string;
141
-
142
107
  /**
143
108
  * The single source of time for a service.
144
109
  *
@@ -169,6 +134,11 @@ type Clock = {
169
134
  state(): ClockState;
170
135
  };
171
136
 
137
+ type UpstreamState = {
138
+ mode: "emulated" | "forward";
139
+ baseUrl: string;
140
+ };
141
+
172
142
  /**
173
143
  * Seeded pseudo-random numbers, so anything a mock invents — ids, jitter, which
174
144
  * request a percentage fault hits — is reproducible from a seed.
@@ -432,6 +402,7 @@ declare const SNAPSHOT_FORMAT = "mockingbird.snapshot/v1";
432
402
  * `records` are required, so a hand-written seed file is a valid snapshot.
433
403
  */
434
404
  type SnapshotDocument = {
405
+ upstream?: UpstreamState;
435
406
  format: typeof SNAPSHOT_FORMAT;
436
407
  /** The service that wrote it. A snapshot is rejected by any other service. */
437
408
  service?: string;
@@ -505,6 +476,7 @@ type LatencyState = LatencyRule & {
505
476
  };
506
477
  /** What {@link controlHeaders} turns into request headers. */
507
478
  type ControlHeaderInput = {
479
+ upstream?: "emulated" | "forward";
508
480
  namespace?: string;
509
481
  adminKey?: string;
510
482
  branch?: string;
@@ -522,6 +494,35 @@ type ControlHeaderInput = {
522
494
  snapshot?: string;
523
495
  };
524
496
 
497
+ /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
498
+ type SqliteValue = null | number | bigint | string | Uint8Array | boolean;
499
+ /** Mutation counters returned by {@link SqliteStatement.run}. */
500
+ type SqliteRunResult = {
501
+ changes: number;
502
+ lastInsertRowid: number | bigint;
503
+ };
504
+ /**
505
+ * Prepared statement bound to a {@link SqliteClient}.
506
+ *
507
+ * Pass bind values as rest arguments on each call (no sticky `bind()`).
508
+ */
509
+ interface SqliteStatement {
510
+ run(...params: SqliteValue[]): SqliteRunResult;
511
+ all<T = Record<string, unknown>>(...params: SqliteValue[]): T[];
512
+ get<T = Record<string, unknown>>(...params: SqliteValue[]): T | undefined;
513
+ }
514
+ /**
515
+ * Sync SQLite client port owned by Mockingbird.
516
+ *
517
+ * Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
518
+ * `bun:sqlite` instances all work when they expose this surface.
519
+ */
520
+ interface SqliteClient {
521
+ exec(sql: string): void;
522
+ prepare(sql: string): SqliteStatement;
523
+ transaction<T>(fn: () => T): T;
524
+ }
525
+
525
526
  /**
526
527
  * One problem with a request body, at a dotted path (`patient.address.city`, `items.0.sku`).
527
528
  * `kind` is `media_type` when the body is present but its media type is not one the operation
@@ -548,6 +549,7 @@ type RejectedRequest = {
548
549
  };
549
550
  /** One handled request, as the structured log sees it. */
550
551
  type RequestLog = {
552
+ upstream?: boolean;
551
553
  service: string;
552
554
  namespace: string;
553
555
  operationId: string | undefined;
@@ -682,8 +684,6 @@ type CredentialRegistry = {
682
684
  }[];
683
685
  };
684
686
 
685
- type OwnedTransport = (request: Request, namespace: string, send: typeof fetch) => Promise<Response>;
686
-
687
687
  /**
688
688
  * A point-in-time copy of everything a service namespace holds.
689
689
  *
@@ -736,6 +736,14 @@ type StateView = {
736
736
  collections: StateCollectionView[];
737
737
  };
738
738
 
739
+ /**
740
+ * What names an id base: a non-negative safe integer (or its decimal string) or `"boot"`,
741
+ * which derives the base from the wall clock when the runtime is created.
742
+ */
743
+ type IdBase = number | string;
744
+
745
+ type OwnedTransport = (request: Request, namespace: string, send: typeof fetch) => Promise<Response>;
746
+
739
747
  type WebhookEndpoint = {
740
748
  /** Stable id; generated when omitted. */
741
749
  id?: string;
package/dist/server.js CHANGED
@@ -2,9 +2,8 @@ import {
2
2
  DEFAULT_PORT,
3
3
  createServer,
4
4
  serveTarget
5
- } from "./chunk-V2MWBWWO.js";
6
- import "./chunk-TIIQEPPL.js";
7
- import "./chunk-K2BAVPFL.js";
5
+ } from "./chunk-N36QOZXR.js";
6
+ import "./chunk-XKCZKCGQ.js";
8
7
  export {
9
8
  DEFAULT_PORT,
10
9
  createServer,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crvouga/mockingbird-service-textract",
3
- "version": "3.13.0",
3
+ "version": "3.15.0",
4
4
  "description": "Stateful Amazon Textract emulator with document analysis jobs, graph blocks, pagination, and deterministic notifications.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -98,7 +98,8 @@
98
98
  "pack:check": "bun ../../../scripts/pack-check.ts"
99
99
  },
100
100
  "dependencies": {
101
- "@crvouga/mockingbird-service-sqlite": "3.4.2"
101
+ "@crvouga/mockingbird-runtime": "0.1.0",
102
+ "@crvouga/mockingbird-service-sqlite": "3.5.1"
102
103
  },
103
104
  "devDependencies": {
104
105
  "@aws-sdk/client-textract": "3.1132.0",