@crvouga/mockingbird-service-s3 3.7.0 → 3.8.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 +8 -1
- package/README.md +13 -1
- package/dist/{chunk-THIFXCQ2.js → chunk-2B5OVZSH.js} +53 -11
- package/dist/chunk-2B5OVZSH.js.map +7 -0
- package/dist/{chunk-XFKAVTM2.js → chunk-NNRVXV6X.js} +532 -106
- package/dist/{chunk-XFKAVTM2.js.map → chunk-NNRVXV6X.js.map} +4 -4
- package/dist/cli.js +2 -2
- package/dist/index.d.ts +65 -8
- package/dist/index.js +3 -1
- package/dist/server.d.ts +66 -7
- package/dist/server.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-THIFXCQ2.js.map +0 -7
package/dist/cli.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1211,7 +1211,7 @@ interface SqliteClient {
|
|
|
1211
1211
|
type S3Object = {
|
|
1212
1212
|
bucket: string;
|
|
1213
1213
|
key: string;
|
|
1214
|
-
bytes:
|
|
1214
|
+
bytes: Uint8Array;
|
|
1215
1215
|
etag: string;
|
|
1216
1216
|
lastModified: number;
|
|
1217
1217
|
contentType?: string;
|
|
@@ -1237,7 +1237,7 @@ type MultipartUpload = {
|
|
|
1237
1237
|
type MultipartPart = {
|
|
1238
1238
|
uploadId: string;
|
|
1239
1239
|
partNumber: number;
|
|
1240
|
-
bytes:
|
|
1240
|
+
bytes: Uint8Array;
|
|
1241
1241
|
etag: string;
|
|
1242
1242
|
};
|
|
1243
1243
|
type S3SeedObject = Omit<S3Object, "etag" | "lastModified" | "bytes"> & {
|
|
@@ -1245,17 +1245,41 @@ type S3SeedObject = Omit<S3Object, "etag" | "lastModified" | "bytes"> & {
|
|
|
1245
1245
|
etag?: string;
|
|
1246
1246
|
lastModified?: number;
|
|
1247
1247
|
};
|
|
1248
|
+
/**
|
|
1249
|
+
* Records with a `bytes` body, kept as base64 so a large object is a string in the row instead of
|
|
1250
|
+
* one JSON number per byte. Filters see the record without its body, which is only decoded for
|
|
1251
|
+
* the records that pass.
|
|
1252
|
+
*/
|
|
1253
|
+
declare class BlobCollection<T extends {
|
|
1254
|
+
bytes: Uint8Array;
|
|
1255
|
+
}> {
|
|
1256
|
+
private readonly inner;
|
|
1257
|
+
constructor(sqlite: SqliteClient, namespace: string, name: string);
|
|
1258
|
+
private decode;
|
|
1259
|
+
get(id: string): T | undefined;
|
|
1260
|
+
has(id: string): boolean;
|
|
1261
|
+
insert(id: string, value: T): void;
|
|
1262
|
+
delete(id: string): boolean;
|
|
1263
|
+
list(options?: {
|
|
1264
|
+
where?: (value: Omit<T, "bytes">) => boolean;
|
|
1265
|
+
order?: "newest" | "oldest";
|
|
1266
|
+
}): {
|
|
1267
|
+
value: T;
|
|
1268
|
+
seq: number;
|
|
1269
|
+
id: string;
|
|
1270
|
+
}[];
|
|
1271
|
+
}
|
|
1248
1272
|
declare class S3State {
|
|
1249
1273
|
readonly buckets: Collection<{
|
|
1250
1274
|
createdAt: number;
|
|
1251
1275
|
}>;
|
|
1252
|
-
readonly objects:
|
|
1253
|
-
readonly versions:
|
|
1276
|
+
readonly objects: BlobCollection<S3Object>;
|
|
1277
|
+
readonly versions: BlobCollection<S3Object>;
|
|
1254
1278
|
readonly configurations: Collection<{
|
|
1255
1279
|
body: string;
|
|
1256
1280
|
}>;
|
|
1257
1281
|
readonly uploads: Collection<MultipartUpload>;
|
|
1258
|
-
readonly parts:
|
|
1282
|
+
readonly parts: BlobCollection<MultipartPart>;
|
|
1259
1283
|
readonly ids: IdSequence;
|
|
1260
1284
|
constructor(sqlite: SqliteClient, namespace: string);
|
|
1261
1285
|
objectId(bucket: string, key: string): string;
|
|
@@ -1275,6 +1299,11 @@ type S3RuntimeOptions = {
|
|
|
1275
1299
|
buckets?: readonly string[];
|
|
1276
1300
|
objects?: readonly S3SeedObject[];
|
|
1277
1301
|
credentials?: Readonly<Record<string, string>>;
|
|
1302
|
+
/**
|
|
1303
|
+
* Base hosts for virtual-hosted-style addressing: `Host: <bucket>.<base>` names the bucket and
|
|
1304
|
+
* the path is the key. Default `["localhost"]`; `[]` leaves every request path-style.
|
|
1305
|
+
*/
|
|
1306
|
+
virtualHosts?: readonly string[];
|
|
1278
1307
|
webhooks?: {
|
|
1279
1308
|
endpoints?: WebhookEndpoint[];
|
|
1280
1309
|
retryDelaysMs?: readonly number[];
|
|
@@ -1287,11 +1316,18 @@ type S3Runtime = ServiceRuntime<S3API> & {
|
|
|
1287
1316
|
declare const createRuntime: (options?: S3RuntimeOptions) => S3Runtime;
|
|
1288
1317
|
|
|
1289
1318
|
declare const S3_NAMESPACE = "s3";
|
|
1319
|
+
/** S3 accepts at most 5 GB in a single PUT and in each multipart part. */
|
|
1320
|
+
declare const S3_MAX_UPLOAD_BYTES: number;
|
|
1290
1321
|
declare const accessKeyCredential: (request: Request) => string | undefined;
|
|
1291
1322
|
type S3APIOptions = APIOptions & {
|
|
1292
1323
|
buckets?: readonly string[];
|
|
1293
1324
|
objects?: readonly S3SeedObject[];
|
|
1294
1325
|
credentials?: Readonly<Record<string, string>>;
|
|
1326
|
+
/**
|
|
1327
|
+
* Base hosts for virtual-hosted-style addressing: `Host: <bucket>.<base>` names the bucket and
|
|
1328
|
+
* the path is the key. Default `["localhost"]`; `[]` leaves every request path-style.
|
|
1329
|
+
*/
|
|
1330
|
+
virtualHosts?: readonly string[];
|
|
1295
1331
|
onNotification?: (event: S3Notification) => void;
|
|
1296
1332
|
/** A seeded stream of `[0, 1)` for request ids, so an error body replays from its seed. */
|
|
1297
1333
|
random?: () => number;
|
|
@@ -1319,7 +1355,15 @@ declare class S3API {
|
|
|
1319
1355
|
private notify;
|
|
1320
1356
|
private verifyPresign;
|
|
1321
1357
|
private objectHeaders;
|
|
1322
|
-
fetch(
|
|
1358
|
+
fetch(input: Request): Promise<Response>;
|
|
1359
|
+
private handle;
|
|
1360
|
+
/** `response-*` query parameters replace the stored headers on a 200 or 206. */
|
|
1361
|
+
private overridden;
|
|
1362
|
+
/**
|
|
1363
|
+
* `x-amz-copy-source-if-*`, evaluated as the CopyObject reference describes: a true if-match
|
|
1364
|
+
* overrides a false if-unmodified-since, and a failed condition is always 412, never 304.
|
|
1365
|
+
*/
|
|
1366
|
+
private copyConditions;
|
|
1323
1367
|
private put;
|
|
1324
1368
|
private get;
|
|
1325
1369
|
private list;
|
|
@@ -1331,13 +1375,26 @@ declare class S3API {
|
|
|
1331
1375
|
private versioning;
|
|
1332
1376
|
private removeObject;
|
|
1333
1377
|
private conditions;
|
|
1334
|
-
|
|
1378
|
+
/**
|
|
1379
|
+
* The object bytes of a PutObject or UploadPart: an `aws-chunked` stream is decoded (the framing
|
|
1380
|
+
* and trailers are not part of the object), the decoded length and every supplied checksum are
|
|
1381
|
+
* verified, and the checksums to keep come back as the `x-amz-checksum-*` headers they were.
|
|
1382
|
+
*/
|
|
1383
|
+
private payload;
|
|
1335
1384
|
private bucketConfiguration;
|
|
1385
|
+
private corsRules;
|
|
1386
|
+
/**
|
|
1387
|
+
* The browser preflight (`OPTIONS` on a bucket or object URL). S3 refuses one it cannot match
|
|
1388
|
+
* with 403 AccessForbidden "CORSResponse: ..." and no `Access-Control-*` headers.
|
|
1389
|
+
*/
|
|
1390
|
+
private preflight;
|
|
1391
|
+
/** A matching rule adds the `Access-Control-*` headers to an actual cross-origin response. */
|
|
1392
|
+
private withCors;
|
|
1336
1393
|
private objectTagging;
|
|
1337
1394
|
private listParts;
|
|
1338
1395
|
private listUploads;
|
|
1339
1396
|
private listVersions;
|
|
1340
1397
|
}
|
|
1341
1398
|
|
|
1342
|
-
export { S3API, S3_NAMESPACE, S3_PRESETS, accessKeyCredential, createRuntime, document, operationIds, supportedOperationIds };
|
|
1399
|
+
export { S3API, S3_MAX_UPLOAD_BYTES, S3_NAMESPACE, S3_PRESETS, accessKeyCredential, createRuntime, document, operationIds, supportedOperationIds };
|
|
1343
1400
|
export type { S3APIOptions, S3Notification, S3Object, S3Runtime, S3RuntimeOptions, S3SeedObject };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
S3API,
|
|
3
|
+
S3_MAX_UPLOAD_BYTES,
|
|
3
4
|
S3_NAMESPACE,
|
|
4
5
|
S3_PRESETS,
|
|
5
6
|
accessKeyCredential,
|
|
@@ -7,9 +8,10 @@ import {
|
|
|
7
8
|
document,
|
|
8
9
|
operationIds,
|
|
9
10
|
supportedOperationIds
|
|
10
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-NNRVXV6X.js";
|
|
11
12
|
export {
|
|
12
13
|
S3API,
|
|
14
|
+
S3_MAX_UPLOAD_BYTES,
|
|
13
15
|
S3_NAMESPACE,
|
|
14
16
|
S3_PRESETS,
|
|
15
17
|
accessKeyCredential,
|
package/dist/server.d.ts
CHANGED
|
@@ -985,6 +985,8 @@ type ServeTarget = {
|
|
|
985
985
|
*/
|
|
986
986
|
parseSettings?(settings: Record<string, unknown>): Record<string, unknown>;
|
|
987
987
|
create(values: CliValues, common: CommonServeOptions): Promise<ServiceRuntime$1<ServiceInstance$1>> | ServiceRuntime$1<ServiceInstance$1>;
|
|
988
|
+
/** Largest request body the HTTP server accepts. Default 16 MiB. */
|
|
989
|
+
maxBodyBytes?: number;
|
|
988
990
|
/** Startup lines after the listen address, e.g. the loaded corpus version. */
|
|
989
991
|
banner?(runtime: ServiceRuntime$1<ServiceInstance$1>): string[];
|
|
990
992
|
/** After the HTTP server is bound. A service that speaks more than HTTP attaches it here. */
|
|
@@ -2022,7 +2024,7 @@ interface SqliteClient {
|
|
|
2022
2024
|
type S3Object = {
|
|
2023
2025
|
bucket: string;
|
|
2024
2026
|
key: string;
|
|
2025
|
-
bytes:
|
|
2027
|
+
bytes: Uint8Array;
|
|
2026
2028
|
etag: string;
|
|
2027
2029
|
lastModified: number;
|
|
2028
2030
|
contentType?: string;
|
|
@@ -2048,7 +2050,7 @@ type MultipartUpload = {
|
|
|
2048
2050
|
type MultipartPart = {
|
|
2049
2051
|
uploadId: string;
|
|
2050
2052
|
partNumber: number;
|
|
2051
|
-
bytes:
|
|
2053
|
+
bytes: Uint8Array;
|
|
2052
2054
|
etag: string;
|
|
2053
2055
|
};
|
|
2054
2056
|
type S3SeedObject = Omit<S3Object, "etag" | "lastModified" | "bytes"> & {
|
|
@@ -2056,17 +2058,41 @@ type S3SeedObject = Omit<S3Object, "etag" | "lastModified" | "bytes"> & {
|
|
|
2056
2058
|
etag?: string;
|
|
2057
2059
|
lastModified?: number;
|
|
2058
2060
|
};
|
|
2061
|
+
/**
|
|
2062
|
+
* Records with a `bytes` body, kept as base64 so a large object is a string in the row instead of
|
|
2063
|
+
* one JSON number per byte. Filters see the record without its body, which is only decoded for
|
|
2064
|
+
* the records that pass.
|
|
2065
|
+
*/
|
|
2066
|
+
declare class BlobCollection<T extends {
|
|
2067
|
+
bytes: Uint8Array;
|
|
2068
|
+
}> {
|
|
2069
|
+
private readonly inner;
|
|
2070
|
+
constructor(sqlite: SqliteClient, namespace: string, name: string);
|
|
2071
|
+
private decode;
|
|
2072
|
+
get(id: string): T | undefined;
|
|
2073
|
+
has(id: string): boolean;
|
|
2074
|
+
insert(id: string, value: T): void;
|
|
2075
|
+
delete(id: string): boolean;
|
|
2076
|
+
list(options?: {
|
|
2077
|
+
where?: (value: Omit<T, "bytes">) => boolean;
|
|
2078
|
+
order?: "newest" | "oldest";
|
|
2079
|
+
}): {
|
|
2080
|
+
value: T;
|
|
2081
|
+
seq: number;
|
|
2082
|
+
id: string;
|
|
2083
|
+
}[];
|
|
2084
|
+
}
|
|
2059
2085
|
declare class S3State {
|
|
2060
2086
|
readonly buckets: Collection<{
|
|
2061
2087
|
createdAt: number;
|
|
2062
2088
|
}>;
|
|
2063
|
-
readonly objects:
|
|
2064
|
-
readonly versions:
|
|
2089
|
+
readonly objects: BlobCollection<S3Object>;
|
|
2090
|
+
readonly versions: BlobCollection<S3Object>;
|
|
2065
2091
|
readonly configurations: Collection<{
|
|
2066
2092
|
body: string;
|
|
2067
2093
|
}>;
|
|
2068
2094
|
readonly uploads: Collection<MultipartUpload>;
|
|
2069
|
-
readonly parts:
|
|
2095
|
+
readonly parts: BlobCollection<MultipartPart>;
|
|
2070
2096
|
readonly ids: IdSequence;
|
|
2071
2097
|
constructor(sqlite: SqliteClient, namespace: string);
|
|
2072
2098
|
objectId(bucket: string, key: string): string;
|
|
@@ -2077,6 +2103,11 @@ type S3APIOptions = APIOptions & {
|
|
|
2077
2103
|
buckets?: readonly string[];
|
|
2078
2104
|
objects?: readonly S3SeedObject[];
|
|
2079
2105
|
credentials?: Readonly<Record<string, string>>;
|
|
2106
|
+
/**
|
|
2107
|
+
* Base hosts for virtual-hosted-style addressing: `Host: <bucket>.<base>` names the bucket and
|
|
2108
|
+
* the path is the key. Default `["localhost"]`; `[]` leaves every request path-style.
|
|
2109
|
+
*/
|
|
2110
|
+
virtualHosts?: readonly string[];
|
|
2080
2111
|
onNotification?: (event: S3Notification) => void;
|
|
2081
2112
|
/** A seeded stream of `[0, 1)` for request ids, so an error body replays from its seed. */
|
|
2082
2113
|
random?: () => number;
|
|
@@ -2104,7 +2135,15 @@ declare class S3API {
|
|
|
2104
2135
|
private notify;
|
|
2105
2136
|
private verifyPresign;
|
|
2106
2137
|
private objectHeaders;
|
|
2107
|
-
fetch(
|
|
2138
|
+
fetch(input: Request): Promise<Response>;
|
|
2139
|
+
private handle;
|
|
2140
|
+
/** `response-*` query parameters replace the stored headers on a 200 or 206. */
|
|
2141
|
+
private overridden;
|
|
2142
|
+
/**
|
|
2143
|
+
* `x-amz-copy-source-if-*`, evaluated as the CopyObject reference describes: a true if-match
|
|
2144
|
+
* overrides a false if-unmodified-since, and a failed condition is always 412, never 304.
|
|
2145
|
+
*/
|
|
2146
|
+
private copyConditions;
|
|
2108
2147
|
private put;
|
|
2109
2148
|
private get;
|
|
2110
2149
|
private list;
|
|
@@ -2116,8 +2155,21 @@ declare class S3API {
|
|
|
2116
2155
|
private versioning;
|
|
2117
2156
|
private removeObject;
|
|
2118
2157
|
private conditions;
|
|
2119
|
-
|
|
2158
|
+
/**
|
|
2159
|
+
* The object bytes of a PutObject or UploadPart: an `aws-chunked` stream is decoded (the framing
|
|
2160
|
+
* and trailers are not part of the object), the decoded length and every supplied checksum are
|
|
2161
|
+
* verified, and the checksums to keep come back as the `x-amz-checksum-*` headers they were.
|
|
2162
|
+
*/
|
|
2163
|
+
private payload;
|
|
2120
2164
|
private bucketConfiguration;
|
|
2165
|
+
private corsRules;
|
|
2166
|
+
/**
|
|
2167
|
+
* The browser preflight (`OPTIONS` on a bucket or object URL). S3 refuses one it cannot match
|
|
2168
|
+
* with 403 AccessForbidden "CORSResponse: ..." and no `Access-Control-*` headers.
|
|
2169
|
+
*/
|
|
2170
|
+
private preflight;
|
|
2171
|
+
/** A matching rule adds the `Access-Control-*` headers to an actual cross-origin response. */
|
|
2172
|
+
private withCors;
|
|
2121
2173
|
private objectTagging;
|
|
2122
2174
|
private listParts;
|
|
2123
2175
|
private listUploads;
|
|
@@ -2136,6 +2188,11 @@ type S3RuntimeOptions = {
|
|
|
2136
2188
|
buckets?: readonly string[];
|
|
2137
2189
|
objects?: readonly S3SeedObject[];
|
|
2138
2190
|
credentials?: Readonly<Record<string, string>>;
|
|
2191
|
+
/**
|
|
2192
|
+
* Base hosts for virtual-hosted-style addressing: `Host: <bucket>.<base>` names the bucket and
|
|
2193
|
+
* the path is the key. Default `["localhost"]`; `[]` leaves every request path-style.
|
|
2194
|
+
*/
|
|
2195
|
+
virtualHosts?: readonly string[];
|
|
2139
2196
|
webhooks?: {
|
|
2140
2197
|
endpoints?: WebhookEndpoint[];
|
|
2141
2198
|
retryDelaysMs?: readonly number[];
|
|
@@ -2150,6 +2207,8 @@ declare const DEFAULT_PORT = 8812;
|
|
|
2150
2207
|
type S3ServerOptions = S3RuntimeOptions & {
|
|
2151
2208
|
port?: number;
|
|
2152
2209
|
host?: string;
|
|
2210
|
+
/** Largest request body accepted. Default 5 GiB, the most S3 takes in one PUT or part. */
|
|
2211
|
+
maxBodyBytes?: number;
|
|
2153
2212
|
};
|
|
2154
2213
|
declare const createServer: (options?: S3ServerOptions) => Promise<Listening & {
|
|
2155
2214
|
runtime: S3Runtime;
|
package/dist/server.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crvouga/mockingbird-service-s3",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.0",
|
|
4
4
|
"description": "Stateful Amazon S3 emulator with binary objects, listing, copies, multipart uploads, presigned URLs, and canonical XML errors.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|