@crvouga/mockingbird-service-s3 3.9.0 → 4.0.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
@@ -1,3 +1,172 @@
1
+ /**
2
+ * The slice of OpenAPI 3.1 (and JSON Schema 2020-12) Mockingbird understands.
3
+ * Unknown keys (including `x-*` extensions) are preserved on every object.
4
+ */
5
+ type JsonPrimitive = string | number | boolean | null;
6
+ type JsonValue = JsonPrimitive | JsonValue[] | {
7
+ [key: string]: JsonValue;
8
+ };
9
+ type ReferenceObject = {
10
+ $ref: string;
11
+ description?: string;
12
+ summary?: string;
13
+ };
14
+ type SchemaType = "string" | "number" | "integer" | "boolean" | "object" | "array" | "null";
15
+ type SchemaObject = {
16
+ $ref?: string;
17
+ type?: SchemaType | SchemaType[];
18
+ title?: string;
19
+ description?: string;
20
+ format?: string;
21
+ enum?: JsonValue[];
22
+ const?: JsonValue;
23
+ default?: JsonValue;
24
+ example?: JsonValue;
25
+ examples?: JsonValue[];
26
+ nullable?: boolean;
27
+ deprecated?: boolean;
28
+ readOnly?: boolean;
29
+ writeOnly?: boolean;
30
+ minimum?: number;
31
+ maximum?: number;
32
+ exclusiveMinimum?: number;
33
+ exclusiveMaximum?: number;
34
+ multipleOf?: number;
35
+ minLength?: number;
36
+ maxLength?: number;
37
+ pattern?: string;
38
+ minItems?: number;
39
+ maxItems?: number;
40
+ uniqueItems?: boolean;
41
+ items?: SchemaObject;
42
+ prefixItems?: SchemaObject[];
43
+ minProperties?: number;
44
+ maxProperties?: number;
45
+ required?: string[];
46
+ properties?: Record<string, SchemaObject>;
47
+ additionalProperties?: boolean | SchemaObject;
48
+ propertyNames?: SchemaObject;
49
+ oneOf?: SchemaObject[];
50
+ anyOf?: SchemaObject[];
51
+ allOf?: SchemaObject[];
52
+ not?: SchemaObject;
53
+ discriminator?: {
54
+ propertyName: string;
55
+ mapping?: Record<string, string>;
56
+ };
57
+ [extension: `x-${string}`]: unknown;
58
+ };
59
+ type ParameterLocation = "path" | "query" | "header" | "cookie";
60
+ type ParameterObject = {
61
+ name: string;
62
+ in: ParameterLocation;
63
+ description?: string;
64
+ required?: boolean;
65
+ deprecated?: boolean;
66
+ style?: string;
67
+ explode?: boolean;
68
+ schema?: SchemaObject;
69
+ content?: Record<string, MediaTypeObject>;
70
+ example?: JsonValue;
71
+ [extension: `x-${string}`]: unknown;
72
+ };
73
+ type MediaTypeObject = {
74
+ schema?: SchemaObject;
75
+ example?: JsonValue;
76
+ examples?: Record<string, unknown>;
77
+ encoding?: Record<string, unknown>;
78
+ [extension: `x-${string}`]: unknown;
79
+ };
80
+ type RequestBodyObject = {
81
+ description?: string;
82
+ required?: boolean;
83
+ content: Record<string, MediaTypeObject>;
84
+ [extension: `x-${string}`]: unknown;
85
+ };
86
+ type HeaderObject = {
87
+ description?: string;
88
+ required?: boolean;
89
+ schema?: SchemaObject;
90
+ [extension: `x-${string}`]: unknown;
91
+ };
92
+ type ResponseObject = {
93
+ description: string;
94
+ headers?: Record<string, HeaderObject | ReferenceObject>;
95
+ content?: Record<string, MediaTypeObject>;
96
+ [extension: `x-${string}`]: unknown;
97
+ };
98
+ type ResponsesObject = Record<string, ResponseObject | ReferenceObject>;
99
+ type SecurityRequirementObject = Record<string, string[]>;
100
+ type OperationObject = {
101
+ operationId?: string;
102
+ summary?: string;
103
+ description?: string;
104
+ tags?: string[];
105
+ deprecated?: boolean;
106
+ parameters?: Array<ParameterObject | ReferenceObject>;
107
+ requestBody?: RequestBodyObject | ReferenceObject;
108
+ responses: ResponsesObject;
109
+ security?: SecurityRequirementObject[];
110
+ [extension: `x-${string}`]: unknown;
111
+ };
112
+ declare const HTTP_METHODS: readonly ["get", "put", "post", "delete", "options", "head", "patch", "trace"];
113
+ type HttpMethod = (typeof HTTP_METHODS)[number];
114
+ type PathItemObject = {
115
+ summary?: string;
116
+ description?: string;
117
+ parameters?: Array<ParameterObject | ReferenceObject>;
118
+ [extension: `x-${string}`]: unknown;
119
+ } & Partial<Record<HttpMethod, OperationObject>>;
120
+ type SecuritySchemeObject = {
121
+ type: "apiKey" | "http" | "oauth2" | "openIdConnect" | "mutualTLS";
122
+ description?: string;
123
+ name?: string;
124
+ in?: ParameterLocation;
125
+ scheme?: string;
126
+ bearerFormat?: string;
127
+ flows?: Record<string, unknown>;
128
+ openIdConnectUrl?: string;
129
+ [extension: `x-${string}`]: unknown;
130
+ };
131
+ type ComponentsObject = {
132
+ schemas?: Record<string, SchemaObject>;
133
+ responses?: Record<string, ResponseObject>;
134
+ parameters?: Record<string, ParameterObject>;
135
+ requestBodies?: Record<string, RequestBodyObject>;
136
+ headers?: Record<string, HeaderObject>;
137
+ securitySchemes?: Record<string, SecuritySchemeObject>;
138
+ [extension: `x-${string}`]: unknown;
139
+ };
140
+ type ServerObject = {
141
+ url: string;
142
+ description?: string;
143
+ variables?: Record<string, unknown>;
144
+ [extension: `x-${string}`]: unknown;
145
+ };
146
+ type InfoObject = {
147
+ title: string;
148
+ version: string;
149
+ description?: string;
150
+ [extension: `x-${string}`]: unknown;
151
+ };
152
+ type OpenAPIDocument = {
153
+ openapi: string;
154
+ info: InfoObject;
155
+ servers?: ServerObject[];
156
+ paths: Record<string, PathItemObject>;
157
+ components?: ComponentsObject;
158
+ security?: SecurityRequirementObject[];
159
+ tags?: Array<{
160
+ name: string;
161
+ description?: string;
162
+ }>;
163
+ [extension: `x-${string}`]: unknown;
164
+ };
165
+
166
+ declare const document: OpenAPIDocument;
167
+ declare const operationIds: readonly ["ListObjectsV2", "CreateBucket", "BucketPost", "HeadBucket", "GetObject", "PutObject", "MultipartPost", "DeleteObject", "HeadObject"];
168
+ declare const supportedOperationIds: readonly ["ListObjectsV2", "CreateBucket", "BucketPost", "HeadBucket", "GetObject", "PutObject", "MultipartPost", "DeleteObject", "HeadObject"];
169
+
1
170
  type MountedAPI = FetchAPI & {
2
171
  readonly prefix: string;
3
172
  GET: FetchHandler;
@@ -151,6 +320,8 @@ declare class Collection<T> {
151
320
  readonly namespace: string;
152
321
  /** Table name inside the namespace. Stable across resets of the rows themselves. */
153
322
  readonly collectionName: string;
323
+ private readonly statements;
324
+ private prepare;
154
325
  constructor(sqlite: SqliteClient$1,
155
326
  /** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
156
327
  namespace: string,
@@ -1010,175 +1181,6 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI & {
1010
1181
  state(namespace?: string): StateView;
1011
1182
  };
1012
1183
 
1013
- /**
1014
- * The slice of OpenAPI 3.1 (and JSON Schema 2020-12) Mockingbird understands.
1015
- * Unknown keys (including `x-*` extensions) are preserved on every object.
1016
- */
1017
- type JsonPrimitive = string | number | boolean | null;
1018
- type JsonValue = JsonPrimitive | JsonValue[] | {
1019
- [key: string]: JsonValue;
1020
- };
1021
- type ReferenceObject = {
1022
- $ref: string;
1023
- description?: string;
1024
- summary?: string;
1025
- };
1026
- type SchemaType = "string" | "number" | "integer" | "boolean" | "object" | "array" | "null";
1027
- type SchemaObject = {
1028
- $ref?: string;
1029
- type?: SchemaType | SchemaType[];
1030
- title?: string;
1031
- description?: string;
1032
- format?: string;
1033
- enum?: JsonValue[];
1034
- const?: JsonValue;
1035
- default?: JsonValue;
1036
- example?: JsonValue;
1037
- examples?: JsonValue[];
1038
- nullable?: boolean;
1039
- deprecated?: boolean;
1040
- readOnly?: boolean;
1041
- writeOnly?: boolean;
1042
- minimum?: number;
1043
- maximum?: number;
1044
- exclusiveMinimum?: number;
1045
- exclusiveMaximum?: number;
1046
- multipleOf?: number;
1047
- minLength?: number;
1048
- maxLength?: number;
1049
- pattern?: string;
1050
- minItems?: number;
1051
- maxItems?: number;
1052
- uniqueItems?: boolean;
1053
- items?: SchemaObject;
1054
- prefixItems?: SchemaObject[];
1055
- minProperties?: number;
1056
- maxProperties?: number;
1057
- required?: string[];
1058
- properties?: Record<string, SchemaObject>;
1059
- additionalProperties?: boolean | SchemaObject;
1060
- propertyNames?: SchemaObject;
1061
- oneOf?: SchemaObject[];
1062
- anyOf?: SchemaObject[];
1063
- allOf?: SchemaObject[];
1064
- not?: SchemaObject;
1065
- discriminator?: {
1066
- propertyName: string;
1067
- mapping?: Record<string, string>;
1068
- };
1069
- [extension: `x-${string}`]: unknown;
1070
- };
1071
- type ParameterLocation = "path" | "query" | "header" | "cookie";
1072
- type ParameterObject = {
1073
- name: string;
1074
- in: ParameterLocation;
1075
- description?: string;
1076
- required?: boolean;
1077
- deprecated?: boolean;
1078
- style?: string;
1079
- explode?: boolean;
1080
- schema?: SchemaObject;
1081
- content?: Record<string, MediaTypeObject>;
1082
- example?: JsonValue;
1083
- [extension: `x-${string}`]: unknown;
1084
- };
1085
- type MediaTypeObject = {
1086
- schema?: SchemaObject;
1087
- example?: JsonValue;
1088
- examples?: Record<string, unknown>;
1089
- encoding?: Record<string, unknown>;
1090
- [extension: `x-${string}`]: unknown;
1091
- };
1092
- type RequestBodyObject = {
1093
- description?: string;
1094
- required?: boolean;
1095
- content: Record<string, MediaTypeObject>;
1096
- [extension: `x-${string}`]: unknown;
1097
- };
1098
- type HeaderObject = {
1099
- description?: string;
1100
- required?: boolean;
1101
- schema?: SchemaObject;
1102
- [extension: `x-${string}`]: unknown;
1103
- };
1104
- type ResponseObject = {
1105
- description: string;
1106
- headers?: Record<string, HeaderObject | ReferenceObject>;
1107
- content?: Record<string, MediaTypeObject>;
1108
- [extension: `x-${string}`]: unknown;
1109
- };
1110
- type ResponsesObject = Record<string, ResponseObject | ReferenceObject>;
1111
- type SecurityRequirementObject = Record<string, string[]>;
1112
- type OperationObject = {
1113
- operationId?: string;
1114
- summary?: string;
1115
- description?: string;
1116
- tags?: string[];
1117
- deprecated?: boolean;
1118
- parameters?: Array<ParameterObject | ReferenceObject>;
1119
- requestBody?: RequestBodyObject | ReferenceObject;
1120
- responses: ResponsesObject;
1121
- security?: SecurityRequirementObject[];
1122
- [extension: `x-${string}`]: unknown;
1123
- };
1124
- declare const HTTP_METHODS: readonly ["get", "put", "post", "delete", "options", "head", "patch", "trace"];
1125
- type HttpMethod = (typeof HTTP_METHODS)[number];
1126
- type PathItemObject = {
1127
- summary?: string;
1128
- description?: string;
1129
- parameters?: Array<ParameterObject | ReferenceObject>;
1130
- [extension: `x-${string}`]: unknown;
1131
- } & Partial<Record<HttpMethod, OperationObject>>;
1132
- type SecuritySchemeObject = {
1133
- type: "apiKey" | "http" | "oauth2" | "openIdConnect" | "mutualTLS";
1134
- description?: string;
1135
- name?: string;
1136
- in?: ParameterLocation;
1137
- scheme?: string;
1138
- bearerFormat?: string;
1139
- flows?: Record<string, unknown>;
1140
- openIdConnectUrl?: string;
1141
- [extension: `x-${string}`]: unknown;
1142
- };
1143
- type ComponentsObject = {
1144
- schemas?: Record<string, SchemaObject>;
1145
- responses?: Record<string, ResponseObject>;
1146
- parameters?: Record<string, ParameterObject>;
1147
- requestBodies?: Record<string, RequestBodyObject>;
1148
- headers?: Record<string, HeaderObject>;
1149
- securitySchemes?: Record<string, SecuritySchemeObject>;
1150
- [extension: `x-${string}`]: unknown;
1151
- };
1152
- type ServerObject = {
1153
- url: string;
1154
- description?: string;
1155
- variables?: Record<string, unknown>;
1156
- [extension: `x-${string}`]: unknown;
1157
- };
1158
- type InfoObject = {
1159
- title: string;
1160
- version: string;
1161
- description?: string;
1162
- [extension: `x-${string}`]: unknown;
1163
- };
1164
- type OpenAPIDocument = {
1165
- openapi: string;
1166
- info: InfoObject;
1167
- servers?: ServerObject[];
1168
- paths: Record<string, PathItemObject>;
1169
- components?: ComponentsObject;
1170
- security?: SecurityRequirementObject[];
1171
- tags?: Array<{
1172
- name: string;
1173
- description?: string;
1174
- }>;
1175
- [extension: `x-${string}`]: unknown;
1176
- };
1177
-
1178
- declare const document: OpenAPIDocument;
1179
- declare const operationIds: readonly ["ListObjectsV2", "CreateBucket", "BucketPost", "HeadBucket", "GetObject", "PutObject", "MultipartPost", "DeleteObject", "HeadObject"];
1180
- declare const supportedOperationIds: readonly ["ListObjectsV2", "CreateBucket", "BucketPost", "HeadBucket", "GetObject", "PutObject", "MultipartPost", "DeleteObject", "HeadObject"];
1181
-
1182
1184
  /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
1183
1185
  type SqliteValue = null | number | bigint | string | Uint8Array | boolean;
1184
1186
  /** Mutation counters returned by {@link SqliteStatement.run}. */
@@ -1208,82 +1210,294 @@ interface SqliteClient {
1208
1210
  transaction<T>(fn: () => T): T;
1209
1211
  }
1210
1212
 
1211
- type S3Object = {
1213
+ type VersioningStatus = "Enabled" | "Suspended";
1214
+ type BucketRecord = {
1215
+ createdAt: number;
1216
+ versioning?: VersioningStatus;
1217
+ /** Created with `x-amz-bucket-object-lock-enabled: true`. */
1218
+ objectLock?: boolean;
1219
+ /** MinIO's versioning extension: prefixes (wildcard patterns) that stay unversioned. */
1220
+ versioningExcludedPrefixes?: string[];
1221
+ /** MinIO's versioning extension: keys ending in `/` stay unversioned. */
1222
+ versioningExcludeFolders?: boolean;
1223
+ /** The object-lock configuration's default retention, applied to new versions. */
1224
+ defaultRetention?: {
1225
+ mode: "GOVERNANCE" | "COMPLIANCE";
1226
+ days?: number;
1227
+ years?: number;
1228
+ };
1229
+ };
1230
+ type ChecksumAlgorithmName = "CRC32" | "CRC32C" | "CRC64NVME" | "SHA1" | "SHA256";
1231
+ type StoredChecksum = {
1232
+ algorithm: ChecksumAlgorithmName;
1233
+ /** base64 digest, with `-<parts>` for a composite multipart checksum. */
1234
+ value: string;
1235
+ type: "FULL_OBJECT" | "COMPOSITE";
1236
+ };
1237
+ type PartInfo = {
1238
+ number: number;
1239
+ size: number;
1240
+ /** Unquoted. */
1241
+ etag: string;
1242
+ checksum?: string;
1243
+ };
1244
+ /** One version of an object (or a delete marker). The unversioned object is version `"null"`. */
1245
+ type ObjectVersion = {
1212
1246
  bucket: string;
1213
1247
  key: string;
1214
- bytes: Uint8Array;
1248
+ versionId: string;
1249
+ deleteMarker?: boolean;
1250
+ /** Blob id of the bytes; absent for delete markers. */
1251
+ blob?: string;
1252
+ size: number;
1253
+ /** Unquoted ETag (`<md5 hex>` or `<md5 hex>-<parts>`); "" for delete markers. */
1215
1254
  etag: string;
1216
1255
  lastModified: number;
1217
1256
  contentType?: string;
1218
- cacheControl?: string;
1257
+ contentEncoding?: string;
1219
1258
  contentDisposition?: string;
1220
- versionId?: string;
1221
- deleteMarker?: boolean;
1222
- storageClass?: string;
1223
- tags?: Record<string, string>;
1224
- checksums?: Record<string, string>;
1259
+ contentLanguage?: string;
1260
+ cacheControl?: string;
1261
+ /** The `Expires` header as sent. */
1262
+ expires?: string;
1263
+ websiteRedirect?: string;
1264
+ /** User metadata, names lowercased without the `x-amz-meta-` prefix. */
1225
1265
  metadata: Record<string, string>;
1266
+ /** URL-encoded tag set (`a=1&b=2`), as S3 stores `x-amz-tagging`. */
1267
+ tagging?: string;
1268
+ storageClass?: string;
1269
+ checksum?: StoredChecksum;
1270
+ /** Present when the object was assembled by CompleteMultipartUpload. */
1271
+ parts?: PartInfo[];
1272
+ retention?: {
1273
+ mode: "GOVERNANCE" | "COMPLIANCE";
1274
+ until: string;
1275
+ };
1276
+ legalHold?: "ON" | "OFF";
1277
+ /** Server-side encryption the object was written with. */
1278
+ sse?: {
1279
+ algorithm: "AES256" | "aws:kms";
1280
+ kmsKeyId?: string;
1281
+ bucketKey?: boolean;
1282
+ };
1283
+ /** Any other stored headers to replay verbatim (lowercased name → value). */
1284
+ extra?: Record<string, string>;
1226
1285
  };
1227
- type MultipartUpload = {
1286
+ /** The object fields a multipart upload carries until completion. */
1287
+ type MultipartUpload = Omit<ObjectVersion, "versionId" | "blob" | "size" | "etag" | "lastModified" | "deleteMarker" | "parts" | "checksum"> & {
1228
1288
  id: string;
1229
- bucket: string;
1230
- key: string;
1231
1289
  initiated: number;
1232
- metadata?: Record<string, string>;
1233
- contentType?: string;
1234
- cacheControl?: string;
1235
- contentDisposition?: string;
1290
+ checksumAlgorithm?: ChecksumAlgorithmName;
1291
+ checksumType?: "FULL_OBJECT" | "COMPOSITE";
1236
1292
  };
1237
1293
  type MultipartPart = {
1238
1294
  uploadId: string;
1239
1295
  partNumber: number;
1240
- bytes: Uint8Array;
1296
+ blob: string;
1297
+ size: number;
1298
+ /** Unquoted. */
1241
1299
  etag: string;
1300
+ lastModified: number;
1301
+ checksums?: Partial<Record<ChecksumAlgorithmName, string>>;
1242
1302
  };
1243
- type S3SeedObject = Omit<S3Object, "etag" | "lastModified" | "bytes"> & {
1244
- body: Uint8Array | string;
1245
- etag?: string;
1246
- lastModified?: number;
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
- }> {
1303
+ /** Object bytes, base64 in a row, written once and shared by every version that points at them. */
1304
+ declare class BlobStore {
1305
+ private readonly ids;
1256
1306
  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
- }[];
1307
+ constructor(sqlite: SqliteClient, namespace: string, ids: IdSequence);
1308
+ put(bytes: Uint8Array): string;
1309
+ get(id: string | undefined): Uint8Array<ArrayBuffer>;
1310
+ retain(id: string | undefined): void;
1311
+ release(id: string | undefined): void;
1271
1312
  }
1272
1313
  declare class S3State {
1273
- readonly buckets: Collection<{
1274
- createdAt: number;
1314
+ readonly buckets: Collection<BucketRecord>;
1315
+ /** Every version, keyed `[bucket, key, versionId]`. Sequence order is write order. */
1316
+ readonly versions: Collection<ObjectVersion>;
1317
+ /** The latest version of each key, keyed `[bucket, key]`. */
1318
+ readonly heads: Collection<{
1319
+ bucket: string;
1320
+ key: string;
1321
+ versionId: string;
1275
1322
  }>;
1276
- readonly objects: BlobCollection<S3Object>;
1277
- readonly versions: BlobCollection<S3Object>;
1323
+ /** Bucket sub-resources (policy, lifecycle, tagging, ...), keyed `[bucket, kind]`. */
1278
1324
  readonly configurations: Collection<{
1325
+ bucket: string;
1326
+ kind: string;
1279
1327
  body: string;
1280
1328
  }>;
1281
1329
  readonly uploads: Collection<MultipartUpload>;
1282
- readonly parts: BlobCollection<MultipartPart>;
1330
+ readonly parts: Collection<MultipartPart>;
1331
+ readonly blobs: BlobStore;
1283
1332
  readonly ids: IdSequence;
1284
1333
  constructor(sqlite: SqliteClient, namespace: string);
1285
- objectId(bucket: string, key: string): string;
1286
- object(bucket: string, key: string): S3Object | undefined;
1334
+ versionId(bucket: string, key: string, versionId: string): string;
1335
+ headId(bucket: string, key: string): string;
1336
+ configId(bucket: string, kind: string): string;
1337
+ partId(uploadId: string, partNumber: number): string;
1338
+ }
1339
+
1340
+ /**
1341
+ * The object store over S3State: buckets, versions and their latest-version pointers, with the
1342
+ * versioning rules every write and delete shares (null versions, delete markers, head repair).
1343
+ */
1344
+
1345
+ type S3Notification = {
1346
+ eventName: "ObjectCreated:Put" | "ObjectCreated:Post" | "ObjectCreated:Copy" | "ObjectCreated:CompleteMultipartUpload" | "ObjectRemoved:Delete" | "ObjectRemoved:DeleteMarkerCreated";
1347
+ bucket: string;
1348
+ key: string;
1349
+ etag?: string;
1350
+ size?: number;
1351
+ versionId?: string;
1352
+ occurredAt: string;
1353
+ };
1354
+ type CoreOptions = {
1355
+ sqlite: SqliteClient;
1356
+ namespace: string;
1357
+ now: () => number;
1358
+ random: () => number;
1359
+ region: string;
1360
+ /** access key → secret key. */
1361
+ credentials: Readonly<Record<string, string>>;
1362
+ /** `strict`: MinIO's auth exactly. `lenient`: unsigned requests act as the owner. */
1363
+ authentication: "strict" | "lenient";
1364
+ onNotification?: (event: S3Notification) => void;
1365
+ };
1366
+ /** Shared state and rules; handlers reach it as `ctx.core`. */
1367
+ declare class S3Core {
1368
+ readonly options: CoreOptions;
1369
+ readonly state: S3State;
1370
+ constructor(options: CoreOptions);
1371
+ get region(): string;
1372
+ now(): number;
1373
+ /** A random-looking hex string from the seeded stream. */
1374
+ randomHex(length: number): string;
1375
+ /** A UUID v4 from the seeded stream (MinIO's version id format). */
1376
+ uuid(): string;
1377
+ notify(event: Omit<S3Notification, "occurredAt">): void;
1378
+ bucket(name: string): BucketRecord | undefined;
1379
+ requireBucket(name: string): BucketRecord;
1380
+ saveBucket(name: string, record: BucketRecord): void;
1381
+ config(bucket: string, kind: string): string | undefined;
1382
+ setConfig(bucket: string, kind: string, body: string | undefined): void;
1383
+ /** Remove a bucket and everything it holds. */
1384
+ dropBucket(name: string): void;
1385
+ /** The latest version of a key (possibly a delete marker). */
1386
+ head(bucket: string, key: string): ObjectVersion | undefined;
1387
+ version(bucket: string, key: string, versionId: string): ObjectVersion | undefined;
1388
+ /** Every version of a key, newest first. */
1389
+ versionsOf(bucket: string, key: string): ObjectVersion[];
1390
+ bytes(version: ObjectVersion): Uint8Array<ArrayBuffer>;
1391
+ private setHead;
1392
+ /**
1393
+ * MinIO's `PrefixEnabled`: versioning is Enabled and `key` matches none of the bucket's
1394
+ * excluded prefixes (nor, with ExcludeFolders, ends in `/`).
1395
+ */
1396
+ versioned(bucket: string, key?: string): boolean;
1397
+ /** Versioning is Suspended at the bucket level. */
1398
+ suspended(bucket: string): boolean;
1399
+ /** The id a new write of `key` gets: a fresh UUID when versioning applies, else `"null"`. */
1400
+ nextVersionId(bucket: string, key?: string): string;
1401
+ /**
1402
+ * DeleteObject's versioning rules (MinIO's `erasureServerPools.DeleteObject`): with a version
1403
+ * id, remove exactly that version; without one, a latest delete marker is returned as is, a
1404
+ * versioned key gets a new delete marker, a suspended bucket a `null` delete marker (replacing
1405
+ * the null version), and anything else loses its `null` version. A key with no versions at all
1406
+ * is left alone (`undefined`). The result is the removed version or the marker written/found.
1407
+ */
1408
+ deleteObject(bucket: string, key: string, versionId: string, now: number): {
1409
+ version: ObjectVersion;
1410
+ marker: boolean;
1411
+ } | undefined;
1412
+ /**
1413
+ * Store a new version as the latest. In an unversioned or suspended bucket it replaces the
1414
+ * `null` version; in a versioned bucket it is added with a fresh id.
1415
+ */
1416
+ write(input: Omit<ObjectVersion, "versionId" | "blob" | "size"> & {
1417
+ versionId?: string;
1418
+ }, bytes: Uint8Array): ObjectVersion;
1419
+ /** Store a version that shares an existing blob (copies keep one copy of the bytes). */
1420
+ writeShared(input: Omit<ObjectVersion, "versionId"> & {
1421
+ versionId?: string;
1422
+ }): ObjectVersion;
1423
+ /**
1424
+ * MinIO's `checkPutObjectLockAllowed` default: in an object-lock bucket with a default
1425
+ * retention rule, a new version written without its own retention or legal hold is retained
1426
+ * until now + the rule's period.
1427
+ */
1428
+ private withDefaultRetention;
1429
+ /** Change a stored version in place (tags, retention, legal hold) without reordering it. */
1430
+ update(version: ObjectVersion): void;
1431
+ /** Permanently delete one version and repoint the key's head. */
1432
+ removeVersion(bucket: string, key: string, versionId: string): ObjectVersion | undefined;
1433
+ /** The current object of every key in a bucket (delete markers excluded). */
1434
+ currentObjects(bucket: string): ObjectVersion[];
1435
+ /** Every version in a bucket, newest first. */
1436
+ allVersions(bucket: string): ObjectVersion[];
1437
+ isLatest(version: ObjectVersion): boolean;
1438
+ /** No versions at all. Pending multipart uploads do not count: MinIO deletes them with the bucket. */
1439
+ bucketIsEmpty(bucket: string): boolean;
1440
+ }
1441
+
1442
+ type S3SeedObject = {
1443
+ bucket: string;
1444
+ key: string;
1445
+ body: Uint8Array | string;
1446
+ metadata?: Record<string, string>;
1447
+ contentType?: string;
1448
+ cacheControl?: string;
1449
+ contentDisposition?: string;
1450
+ contentEncoding?: string;
1451
+ /** URL-encoded tag set, or a record of tags. */
1452
+ tags?: Record<string, string> | string;
1453
+ storageClass?: string;
1454
+ etag?: string;
1455
+ lastModified?: number;
1456
+ };
1457
+ type S3APIOptions = APIOptions & {
1458
+ buckets?: readonly string[];
1459
+ objects?: readonly S3SeedObject[];
1460
+ /** access key → secret key. Default `{ fixture: "fixture" }`. */
1461
+ credentials?: Readonly<Record<string, string>>;
1462
+ /**
1463
+ * `lenient` (default): unsigned requests act as the bucket owner and header signatures are not
1464
+ * checked; presigned URLs still are. `strict`: MinIO's authentication exactly — every request
1465
+ * must be signed by a known key (or allowed anonymously by a bucket policy).
1466
+ */
1467
+ authentication?: "lenient" | "strict";
1468
+ /** The server region (`x-amz-bucket-region`, signature scope). Default `us-east-1`. */
1469
+ region?: string;
1470
+ /**
1471
+ * Base hosts for virtual-hosted-style addressing: `Host: <bucket>.<base>` names the bucket and
1472
+ * the path is the key. Default `["localhost"]`; `[]` leaves every request path-style.
1473
+ */
1474
+ virtualHosts?: readonly string[];
1475
+ onNotification?: (event: S3Notification) => void;
1476
+ /** A seeded stream of `[0, 1)` for request and version ids. */
1477
+ random?: () => number;
1478
+ };
1479
+ declare const S3_NAMESPACE = "s3";
1480
+ /** S3 accepts at most 5 GiB in a single PUT and in each multipart part. */
1481
+ declare const S3_MAX_UPLOAD_BYTES: number;
1482
+ declare class S3API {
1483
+ private readonly options;
1484
+ readonly core: S3Core;
1485
+ private readonly sqlite;
1486
+ private readonly namespace;
1487
+ private readonly ready;
1488
+ constructor(options?: S3APIOptions);
1489
+ get state(): S3State;
1490
+ private seed;
1491
+ reset(): Promise<void>;
1492
+ /** Store an object directly (fixtures, the admin plane), creating its bucket if needed. */
1493
+ putSeed(input: S3SeedObject): Promise<ObjectVersion>;
1494
+ private requestId;
1495
+ fetch(input: Request): Promise<Response>;
1496
+ private renderError;
1497
+ /** MinIO's `setCommonHeaders` plus the request ids, filled into the error body too. */
1498
+ private finish;
1499
+ private handle;
1500
+ private authenticate;
1287
1501
  }
1288
1502
 
1289
1503
  declare const S3_PRESETS: Record<string, FaultPreset>;
@@ -1299,6 +1513,10 @@ type S3RuntimeOptions = {
1299
1513
  buckets?: readonly string[];
1300
1514
  objects?: readonly S3SeedObject[];
1301
1515
  credentials?: Readonly<Record<string, string>>;
1516
+ /** `lenient` (default) or `strict` (MinIO's SigV4 checks on every request). */
1517
+ authentication?: "lenient" | "strict";
1518
+ /** Server region. Default `us-east-1`. */
1519
+ region?: string;
1302
1520
  /**
1303
1521
  * Base hosts for virtual-hosted-style addressing: `Host: <bucket>.<base>` names the bucket and
1304
1522
  * the path is the key. Default `["localhost"]`; `[]` leaves every request path-style.
@@ -1315,86 +1533,7 @@ type S3Runtime = ServiceRuntime<S3API> & {
1315
1533
  };
1316
1534
  declare const createRuntime: (options?: S3RuntimeOptions) => S3Runtime;
1317
1535
 
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;
1321
1536
  declare const accessKeyCredential: (request: Request) => string | undefined;
1322
- type S3APIOptions = APIOptions & {
1323
- buckets?: readonly string[];
1324
- objects?: readonly S3SeedObject[];
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[];
1331
- onNotification?: (event: S3Notification) => void;
1332
- /** A seeded stream of `[0, 1)` for request ids, so an error body replays from its seed. */
1333
- random?: () => number;
1334
- };
1335
- type S3Notification = {
1336
- eventName: "ObjectCreated:Put" | "ObjectCreated:Copy" | "ObjectCreated:CompleteMultipartUpload" | "ObjectRemoved:Delete";
1337
- bucket: string;
1338
- key: string;
1339
- etag?: string;
1340
- size?: number;
1341
- occurredAt: string;
1342
- };
1343
- declare class S3API {
1344
- private readonly options;
1345
- readonly state: S3State;
1346
- private readonly sqlite;
1347
- private readonly namespace;
1348
- private readonly now;
1349
- private readonly ready;
1350
- constructor(options?: S3APIOptions);
1351
- private seed;
1352
- reset(): Promise<void>;
1353
- putSeed(input: S3SeedObject): Promise<S3Object>;
1354
- private error;
1355
- private notify;
1356
- private verifyPresign;
1357
- private objectHeaders;
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;
1367
- private put;
1368
- private get;
1369
- private list;
1370
- private compareKeys;
1371
- private uploadPart;
1372
- private complete;
1373
- private deleteMany;
1374
- private versionKey;
1375
- private versioning;
1376
- private removeObject;
1377
- private conditions;
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;
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;
1393
- private objectTagging;
1394
- private listParts;
1395
- private listUploads;
1396
- private listVersions;
1397
- }
1398
1537
 
1399
1538
  export { S3API, S3_MAX_UPLOAD_BYTES, S3_NAMESPACE, S3_PRESETS, accessKeyCredential, createRuntime, document, operationIds, supportedOperationIds };
1400
- export type { S3APIOptions, S3Notification, S3Object, S3Runtime, S3RuntimeOptions, S3SeedObject };
1539
+ export type { BucketRecord, MultipartPart, MultipartUpload, ObjectVersion, S3APIOptions, S3Notification, ObjectVersion as S3Object, S3Runtime, S3RuntimeOptions, S3SeedObject };