@crvouga/mockingbird-service-s3 4.3.0 → 4.4.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/CHANGELOG.md +15 -1
- package/dist/{auth-v2-RZJ4AKKC.js → auth-v2-GW4YVKRA.js} +3 -3
- package/dist/{chunk-JX5VOLFN.js → chunk-3Y4QNTW5.js} +21 -1
- package/dist/{chunk-JX5VOLFN.js.map → chunk-3Y4QNTW5.js.map} +1 -1
- package/dist/chunk-BYKRGUMG.js +67 -0
- package/dist/chunk-BYKRGUMG.js.map +7 -0
- package/dist/{chunk-BMGLD6TC.js → chunk-FXUUBO4X.js} +22 -27
- package/dist/chunk-FXUUBO4X.js.map +7 -0
- package/dist/{chunk-XPRD2L4L.js → chunk-HEDNRPCE.js} +2 -2
- package/dist/chunk-R4NNHABH.js +50 -0
- package/dist/chunk-R4NNHABH.js.map +7 -0
- package/dist/cli.js +6 -7
- package/dist/cli.js.map +1 -1
- package/dist/digest-PF5ETX6Y.js +12 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -4
- package/dist/server.d.ts +45 -37
- package/dist/server.js +5 -5
- package/dist/{types-HwqI9Aq6.d.ts → types-D35w7w0X.d.ts} +114 -106
- package/package.json +3 -2
- package/dist/admin-ui.js +0 -27
- package/dist/admin-ui.js.map +0 -7
- package/dist/chunk-AWD3L5SE.js +0 -5116
- package/dist/chunk-AWD3L5SE.js.map +0 -7
- package/dist/chunk-BMGLD6TC.js.map +0 -7
- package/dist/chunk-DIKGARCN.js +0 -9839
- package/dist/chunk-DIKGARCN.js.map +0 -7
- package/dist/digest-CFAZMYNE.js +0 -12
- /package/dist/{auth-v2-RZJ4AKKC.js.map → auth-v2-GW4YVKRA.js.map} +0 -0
- /package/dist/{chunk-XPRD2L4L.js.map → chunk-HEDNRPCE.js.map} +0 -0
- /package/dist/{digest-CFAZMYNE.js.map → digest-PF5ETX6Y.js.map} +0 -0
|
@@ -1739,7 +1739,7 @@ var authenticate = async (input) => {
|
|
|
1739
1739
|
const accessKey = claimedAccessKey(signed.headers, signed.query);
|
|
1740
1740
|
return { identity: { anonymous: false, ...accessKey ? { accessKey } : {} } };
|
|
1741
1741
|
}
|
|
1742
|
-
const { verifyV2, requestAccessKeyV2 } = await import("./auth-v2-
|
|
1742
|
+
const { verifyV2, requestAccessKeyV2 } = await import("./auth-v2-GW4YVKRA.js");
|
|
1743
1743
|
if (op === "PostObject" && auth === "post-policy") return { identity: { anonymous: false } };
|
|
1744
1744
|
if (op === "DeleteObjects") {
|
|
1745
1745
|
const md5 = signed.headers.get("content-md5");
|
|
@@ -1842,4 +1842,4 @@ export {
|
|
|
1842
1842
|
skipContentSha256,
|
|
1843
1843
|
authenticate
|
|
1844
1844
|
};
|
|
1845
|
-
//# sourceMappingURL=chunk-
|
|
1845
|
+
//# sourceMappingURL=chunk-HEDNRPCE.js.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__export,
|
|
3
|
+
__reExport,
|
|
4
|
+
define_MOCKINGBIRD_ADMIN_BRAND_default
|
|
5
|
+
} from "./chunk-3Y4QNTW5.js";
|
|
6
|
+
|
|
7
|
+
// mockingbird-service-runtime:@crvouga/mockingbird-runtime/service
|
|
8
|
+
var service_exports = {};
|
|
9
|
+
__export(service_exports, {
|
|
10
|
+
PACKAGE_VERSION: () => PACKAGE_VERSION,
|
|
11
|
+
createRuntime: () => createRuntime
|
|
12
|
+
});
|
|
13
|
+
__reExport(service_exports, service_star);
|
|
14
|
+
import * as service_star from "@crvouga/mockingbird-runtime/service";
|
|
15
|
+
import { PACKAGE_VERSION as SHARED_VERSION, createRuntime as sharedRuntime } from "@crvouga/mockingbird-runtime/service";
|
|
16
|
+
var PACKAGE_VERSION = true ? "4.4.0" : SHARED_VERSION;
|
|
17
|
+
var ADMIN_BRAND = typeof define_MOCKINGBIRD_ADMIN_BRAND_default === "object" ? define_MOCKINGBIRD_ADMIN_BRAND_default : void 0;
|
|
18
|
+
var createRuntime = (options) => sharedRuntime({
|
|
19
|
+
...options,
|
|
20
|
+
version: options.version ?? PACKAGE_VERSION,
|
|
21
|
+
adminBrand: options.adminBrand ?? ADMIN_BRAND
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// src/digest.ts
|
|
25
|
+
var md5Hex = (bytes) => (0, service_exports.awsMd5)(bytes);
|
|
26
|
+
var md5Base64 = (bytes) => {
|
|
27
|
+
const hex = (0, service_exports.awsMd5)(bytes);
|
|
28
|
+
let binary = "";
|
|
29
|
+
for (let index = 0; index < hex.length; index += 2)
|
|
30
|
+
binary += String.fromCharCode(Number.parseInt(hex.slice(index, index + 2), 16));
|
|
31
|
+
return btoa(binary);
|
|
32
|
+
};
|
|
33
|
+
var multipartEtag = (partEtags) => {
|
|
34
|
+
const bytes = new Uint8Array(partEtags.length * 16);
|
|
35
|
+
partEtags.forEach((etag, index) => {
|
|
36
|
+
const clean = etag.replace(/"/g, "");
|
|
37
|
+
for (let offset = 0; offset < 16; offset++)
|
|
38
|
+
bytes[index * 16 + offset] = Number.parseInt(clean.slice(offset * 2, offset * 2 + 2), 16);
|
|
39
|
+
});
|
|
40
|
+
return `${(0, service_exports.awsMd5)(bytes)}-${partEtags.length}`;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export {
|
|
44
|
+
createRuntime,
|
|
45
|
+
service_exports,
|
|
46
|
+
md5Hex,
|
|
47
|
+
md5Base64,
|
|
48
|
+
multipartEtag
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=chunk-R4NNHABH.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["mockingbird-service-runtime:@crvouga/mockingbird-runtime/service", "../src/digest.ts"],
|
|
4
|
+
"sourcesContent": ["export * from \"@crvouga/mockingbird-runtime/service\"\nimport { PACKAGE_VERSION as SHARED_VERSION, createRuntime as sharedRuntime } from \"@crvouga/mockingbird-runtime/service\"\nexport const PACKAGE_VERSION =\n typeof __MOCKINGBIRD_PACKAGE_VERSION__ === \"string\" ? __MOCKINGBIRD_PACKAGE_VERSION__ : SHARED_VERSION\nconst ADMIN_BRAND =\n typeof __MOCKINGBIRD_ADMIN_BRAND__ === \"object\" ? __MOCKINGBIRD_ADMIN_BRAND__ : undefined\nexport const createRuntime = (options) =>\n sharedRuntime({\n ...options,\n version: options.version ?? PACKAGE_VERSION,\n adminBrand: options.adminBrand ?? ADMIN_BRAND,\n })\n", "import { awsMd5 } from \"@crvouga/mockingbird-service\"\n\n/** Lowercase hex MD5, an S3 ETag without its quotes. */\nexport const md5Hex = (bytes: Uint8Array): string => awsMd5(bytes)\n\n/** Base64 MD5, the `Content-MD5` header form. */\nexport const md5Base64 = (bytes: Uint8Array): string => {\n const hex = awsMd5(bytes)\n let binary = \"\"\n for (let index = 0; index < hex.length; index += 2)\n binary += String.fromCharCode(Number.parseInt(hex.slice(index, index + 2), 16))\n return btoa(binary)\n}\n\n/** The multipart ETag: MD5 of the concatenated binary part MD5s, then `-<count>`. */\nexport const multipartEtag = (partEtags: readonly string[]): string => {\n const bytes = new Uint8Array(partEtags.length * 16)\n partEtags.forEach((etag, index) => {\n const clean = etag.replace(/\"/g, \"\")\n for (let offset = 0; offset < 16; offset++)\n bytes[index * 16 + offset] = Number.parseInt(clean.slice(offset * 2, offset * 2 + 2), 16)\n })\n return `${awsMd5(bytes)}-${partEtags.length}`\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAAc;AACd,SAAS,mBAAmB,gBAAgB,iBAAiB,qBAAqB;AAC3E,IAAM,kBACX,OAAsD,sBAAkC;AAC1F,IAAM,cACJ,OAAO,2CAAgC,WAAW,yCAA8B;AAC3E,IAAM,gBAAgB,CAAC,YAC5B,cAAc;AAAA,EACZ,GAAG;AAAA,EACH,SAAS,QAAQ,WAAW;AAAA,EAC5B,YAAY,QAAQ,cAAc;AACpC,CAAC;;;ACRI,IAAM,SAAS,CAAC,cAA8B,wBAAO,KAAK;AAG1D,IAAM,YAAY,CAAC,UAA8B;AACtD,QAAM,UAAM,wBAAO,KAAK;AACxB,MAAI,SAAS;AACb,WAAS,QAAQ,GAAG,QAAQ,IAAI,QAAQ,SAAS;AAC/C,cAAU,OAAO,aAAa,OAAO,SAAS,IAAI,MAAM,OAAO,QAAQ,CAAC,GAAG,EAAE,CAAC;AAChF,SAAO,KAAK,MAAM;AACpB;AAGO,IAAM,gBAAgB,CAAC,cAAyC;AACrE,QAAM,QAAQ,IAAI,WAAW,UAAU,SAAS,EAAE;AAClD,YAAU,QAAQ,CAAC,MAAM,UAAU;AACjC,UAAM,QAAQ,KAAK,QAAQ,MAAM,EAAE;AACnC,aAAS,SAAS,GAAG,SAAS,IAAI;AAChC,YAAM,QAAQ,KAAK,MAAM,IAAI,OAAO,SAAS,MAAM,MAAM,SAAS,GAAG,SAAS,IAAI,CAAC,GAAG,EAAE;AAAA,EAC5F,CAAC;AACD,SAAO,OAAG,wBAAO,KAAK,CAAC,IAAI,UAAU,MAAM;AAC7C;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/cli.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
-
runCli,
|
|
4
|
-
serveCommand,
|
|
5
3
|
serveTarget
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-BYKRGUMG.js";
|
|
5
|
+
import "./chunk-FXUUBO4X.js";
|
|
6
|
+
import "./chunk-HEDNRPCE.js";
|
|
7
|
+
import "./chunk-R4NNHABH.js";
|
|
8
|
+
import "./chunk-3Y4QNTW5.js";
|
|
11
9
|
|
|
12
10
|
// src/cli.ts
|
|
11
|
+
import { runCli, serveCommand } from "@crvouga/mockingbird-runtime/adapter-node";
|
|
13
12
|
var code = await runCli(
|
|
14
13
|
{
|
|
15
14
|
bin: "mockingbird-s3",
|
package/dist/cli.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/cli.ts"],
|
|
4
4
|
"sourcesContent": ["#!/usr/bin/env node\n/// <reference types=\"node\" />\nimport { runCli, serveCommand } from \"@crvouga/mockingbird-adapter-node\"\nimport { serveTarget } from \"./server.js\"\n\nconst code = await runCli(\n {\n bin: \"mockingbird-s3\",\n description: \"stateful Amazon S3 mock\",\n commands: { serve: serveCommand(serveTarget) },\n },\n process.argv.slice(2),\n)\nif (code !== 0) process.exitCode = code\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;AAEA,SAAS,QAAQ,oBAAoB;AAGrC,IAAM,OAAO,MAAM;AAAA,EACjB;AAAA,IACE,KAAK;AAAA,IACL,aAAa;AAAA,IACb,UAAU,EAAE,OAAO,aAAa,WAAW,EAAE;AAAA,EAC/C;AAAA,EACA,QAAQ,KAAK,MAAM,CAAC;AACtB;AACA,IAAI,SAAS,EAAG,SAAQ,WAAW;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { B as BucketRecord, M as MultipartPart, a as MultipartUpload, O as ObjectVersion, S as S3API, b as S3APIOptions, c as S3Notification, O as S3Object, d as S3Runtime, e as S3RuntimeOptions, f as S3SeedObject, g as S3_MAX_UPLOAD_BYTES, h as S3_NAMESPACE, i as S3_PRESETS, j as createRuntime } from './types-
|
|
1
|
+
export { B as BucketRecord, M as MultipartPart, a as MultipartUpload, O as ObjectVersion, S as S3API, b as S3APIOptions, c as S3Notification, O as S3Object, d as S3Runtime, e as S3RuntimeOptions, f as S3SeedObject, g as S3_MAX_UPLOAD_BYTES, h as S3_NAMESPACE, i as S3_PRESETS, j as createRuntime } from './types-D35w7w0X.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* The slice of OpenAPI 3.1 (and JSON Schema 2020-12) Mockingbird understands.
|
package/dist/index.js
CHANGED
|
@@ -8,10 +8,10 @@ import {
|
|
|
8
8
|
document,
|
|
9
9
|
operationIds,
|
|
10
10
|
supportedOperationIds
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
11
|
+
} from "./chunk-FXUUBO4X.js";
|
|
12
|
+
import "./chunk-HEDNRPCE.js";
|
|
13
|
+
import "./chunk-R4NNHABH.js";
|
|
14
|
+
import "./chunk-3Y4QNTW5.js";
|
|
15
15
|
export {
|
|
16
16
|
S3API,
|
|
17
17
|
S3_MAX_UPLOAD_BYTES,
|
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,11 +2,11 @@ import {
|
|
|
2
2
|
DEFAULT_PORT,
|
|
3
3
|
createServer,
|
|
4
4
|
serveTarget
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-BYKRGUMG.js";
|
|
6
|
+
import "./chunk-FXUUBO4X.js";
|
|
7
|
+
import "./chunk-HEDNRPCE.js";
|
|
8
|
+
import "./chunk-R4NNHABH.js";
|
|
9
|
+
import "./chunk-3Y4QNTW5.js";
|
|
10
10
|
export {
|
|
11
11
|
DEFAULT_PORT,
|
|
12
12
|
createServer,
|
|
@@ -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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crvouga/mockingbird-service-s3",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0",
|
|
4
4
|
"description": "Stateful S3 emulator that answers exactly as MinIO does: every bucket, object, multipart, versioning, object-lock, policy and auth API, verified against recorded MinIO transcripts.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -99,7 +99,8 @@
|
|
|
99
99
|
"pack:check": "bun ../../../scripts/pack-check.ts"
|
|
100
100
|
},
|
|
101
101
|
"dependencies": {
|
|
102
|
-
"@crvouga/mockingbird-
|
|
102
|
+
"@crvouga/mockingbird-runtime": "0.0.1",
|
|
103
|
+
"@crvouga/mockingbird-service-sqlite": "3.5.0"
|
|
103
104
|
},
|
|
104
105
|
"devDependencies": {
|
|
105
106
|
"@aws-sdk/client-s3": "3.1132.0",
|