@crvouga/mockingbird-service-s3 2.2.0 → 2.3.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/cli.js CHANGED
@@ -3,8 +3,8 @@ import {
3
3
  runCli,
4
4
  serveCommand,
5
5
  serveTarget
6
- } from "./chunk-4VLIKLQA.js";
7
- import "./chunk-VMROW22S.js";
6
+ } from "./chunk-UABSY7RG.js";
7
+ import "./chunk-UNNPPRK3.js";
8
8
 
9
9
  // src/cli.ts
10
10
  var code = await runCli(
package/dist/index.d.ts CHANGED
@@ -1,33 +1,3 @@
1
- /**
2
- * The single source of time for a service.
3
- *
4
- * Every timestamp a mock writes reads from here, so a suite moves time instead of
5
- * sleeping: appointment windows, result delays and expiries become reachable in
6
- * milliseconds. A frozen clock also makes timestamps reproducible from a seed.
7
- */
8
- type ClockState = {
9
- /** Current epoch milliseconds. */
10
- now: number;
11
- /** True while time does not advance on its own. */
12
- frozen: boolean;
13
- /** Milliseconds this clock adds to its underlying source. */
14
- offsetMs: number;
15
- };
16
- type Clock = {
17
- now(): number;
18
- /** Pin the clock to an exact instant, keeping it frozen if it already was. */
19
- set(epochMs: number): void;
20
- /** Move the clock forward, or back with a negative delta. */
21
- advance(deltaMs: number): void;
22
- /** Stop time at the current instant. */
23
- freeze(): void;
24
- /** Resume from the current instant. */
25
- unfreeze(): void;
26
- /** Drop back to the underlying source, live. */
27
- reset(): void;
28
- state(): ClockState;
29
- };
30
-
31
1
  /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
32
2
  type SqliteValue$1 = null | number | bigint | string | Uint8Array | boolean;
33
3
  /** Mutation counters returned by {@link SqliteStatement.run}. */
@@ -99,6 +69,151 @@ declare class Collection<T> {
99
69
  }>;
100
70
  }
101
71
 
72
+ /**
73
+ * Sequential id source persisted in SQLite. Ids are deterministic for a given
74
+ * sequence history (`cus_` + 14 opaque chars), so reproductions stay stable.
75
+ */
76
+ declare class IdSequence {
77
+ private readonly sqlite;
78
+ private readonly namespace;
79
+ private readonly salt;
80
+ constructor(sqlite: SqliteClient$1, namespace: string, salt?: string);
81
+ next(prefix: string, length?: number): string;
82
+ }
83
+
84
+ /** A stable identifier for a point in a {@link Timeline}. */
85
+ type CheckpointId = string;
86
+ /** An immutable node in a timeline's checkpoint DAG. */
87
+ type Checkpoint<T> = Readonly<{
88
+ id: CheckpointId;
89
+ branch: string;
90
+ parent: CheckpointId | null;
91
+ /** Logical time supplied by the timeline's injected clock. */
92
+ at: number;
93
+ value: T;
94
+ }>;
95
+ type TimelineOptions = {
96
+ /** Logical clock used to stamp checkpoints. Defaults to a deterministic counter. */
97
+ now?: () => number;
98
+ /** Maximum retained checkpoints. Branch heads are never collected. Default 1,000. */
99
+ maxCheckpoints?: number;
100
+ /** Customize deterministic checkpoint IDs. */
101
+ id?: (sequence: number) => CheckpointId;
102
+ };
103
+ type CommitOptions = {
104
+ branch?: string;
105
+ /** Parent checkpoint. Defaults to the selected branch's current head. */
106
+ parent?: CheckpointId | null;
107
+ };
108
+ type ForkOptions = {
109
+ /** Checkpoint to fork from. Defaults to the main branch's head. */
110
+ from?: CheckpointId;
111
+ };
112
+ /**
113
+ * Small, storage-agnostic checkpoint DAG shared by service runtimes. Its values may be immutable
114
+ * records, namespace images, or copy-on-write SQL engine snapshots.
115
+ *
116
+ * Values are retained by reference. Engines can therefore use persistent/COW snapshots while
117
+ * simpler services can use immutable values. IDs and GC order are deterministic, and all IO
118
+ * (the logical clock) is injected.
119
+ */
120
+ declare class Timeline<T> {
121
+ readonly maxCheckpoints: number;
122
+ private readonly now;
123
+ private readonly makeId;
124
+ private readonly nodes;
125
+ private readonly heads;
126
+ /** Unreferenced nodes in the exact order they became collectible. */
127
+ private readonly evictable;
128
+ /** Branch heads plus explicit retainers. Absent means zero. */
129
+ private readonly references;
130
+ private readonly explicitPins;
131
+ private sequence;
132
+ constructor(options?: TimelineOptions);
133
+ /** Capture a new immutable value and move `branch` to it. */
134
+ commit(value: T, options?: CommitOptions): Checkpoint<T>;
135
+ /** Create a branch pointer without copying its checkpoint value. */
136
+ fork(branch: string, options?: ForkOptions): Checkpoint<T> | undefined;
137
+ /** Move a branch pointer to an existing checkpoint. */
138
+ checkout(branch: string, id: CheckpointId): Checkpoint<T>;
139
+ get(id: CheckpointId): Checkpoint<T>;
140
+ head(branch?: string): Checkpoint<T> | undefined;
141
+ hasBranch(branch: string): boolean;
142
+ branches(): Readonly<Record<string, CheckpointId>>;
143
+ checkpoints(): readonly Checkpoint<T>[];
144
+ /** Number of retained checkpoints without allocating an array. */
145
+ get size(): number;
146
+ /** Pin a checkpoint independently of branch heads (used by compatibility snapshot handles). */
147
+ retain(id: CheckpointId): Checkpoint<T>;
148
+ /** Release one explicit pin. Branch heads remain pinned until moved or deleted. */
149
+ release(id: CheckpointId): boolean;
150
+ deleteBranch(branch: string): boolean;
151
+ /**
152
+ * Deterministically discard oldest unpinned checkpoints. Collection is O(number removed):
153
+ * commits never scan pinned nodes or the retained history. Parents are metadata rather than a
154
+ * storage dependency, so a retained node remains usable after pruning.
155
+ */
156
+ gc(max?: number): CheckpointId[];
157
+ private collect;
158
+ private moveHead;
159
+ private addReference;
160
+ private removeReference;
161
+ private assertBranch;
162
+ }
163
+
164
+ /**
165
+ * Anything that can answer a Fetch `Request` with a `Response`.
166
+ *
167
+ * Every Mockingbird service implements this, and every runtime adapter consumes it.
168
+ * It is the only contract shared across the whole graph.
169
+ */
170
+ interface FetchAPI {
171
+ fetch(request: Request): Promise<Response>;
172
+ }
173
+
174
+ /** Options every provider constructor accepts. */
175
+ type APIOptions = {
176
+ /** Sync SQLite client. Defaults to `@crvouga/mockingbird-service-sqlite`. */
177
+ sqlite?: SqliteClient$1;
178
+ /** Clock used for `created`-style fields. Default `Date.now`. */
179
+ now?: () => number;
180
+ /**
181
+ * Storage namespace for this instance's records. Instances sharing one SQLite
182
+ * client stay isolated when their namespaces differ. Defaults to the service name.
183
+ */
184
+ namespace?: string;
185
+ };
186
+
187
+ /**
188
+ * The single source of time for a service.
189
+ *
190
+ * Every timestamp a mock writes reads from here, so a suite moves time instead of
191
+ * sleeping: appointment windows, result delays and expiries become reachable in
192
+ * milliseconds. A frozen clock also makes timestamps reproducible from a seed.
193
+ */
194
+ type ClockState = {
195
+ /** Current epoch milliseconds. */
196
+ now: number;
197
+ /** True while time does not advance on its own. */
198
+ frozen: boolean;
199
+ /** Milliseconds this clock adds to its underlying source. */
200
+ offsetMs: number;
201
+ };
202
+ type Clock = {
203
+ now(): number;
204
+ /** Pin the clock to an exact instant, keeping it frozen if it already was. */
205
+ set(epochMs: number): void;
206
+ /** Move the clock forward, or back with a negative delta. */
207
+ advance(deltaMs: number): void;
208
+ /** Stop time at the current instant. */
209
+ freeze(): void;
210
+ /** Resume from the current instant. */
211
+ unfreeze(): void;
212
+ /** Drop back to the underlying source, live. */
213
+ reset(): void;
214
+ state(): ClockState;
215
+ };
216
+
102
217
  /**
103
218
  * Seeded pseudo-random numbers, so anything a mock invents — ids, jitter, which
104
219
  * request a percentage fault hits — is reproducible from a seed.
@@ -239,109 +354,6 @@ type FaultRegistry = {
239
354
  take(candidate: FaultCandidate): Promise<FaultHit[]>;
240
355
  };
241
356
 
242
- /** A stable identifier for a point in a {@link Timeline}. */
243
- type CheckpointId = string;
244
- /** An immutable node in a timeline's checkpoint DAG. */
245
- type Checkpoint<T> = Readonly<{
246
- id: CheckpointId;
247
- branch: string;
248
- parent: CheckpointId | null;
249
- /** Logical time supplied by the timeline's injected clock. */
250
- at: number;
251
- value: T;
252
- }>;
253
- type TimelineOptions = {
254
- /** Logical clock used to stamp checkpoints. Defaults to a deterministic counter. */
255
- now?: () => number;
256
- /** Maximum retained checkpoints. Branch heads are never collected. Default 1,000. */
257
- maxCheckpoints?: number;
258
- /** Customize deterministic checkpoint IDs. */
259
- id?: (sequence: number) => CheckpointId;
260
- };
261
- type CommitOptions = {
262
- branch?: string;
263
- /** Parent checkpoint. Defaults to the selected branch's current head. */
264
- parent?: CheckpointId | null;
265
- };
266
- type ForkOptions = {
267
- /** Checkpoint to fork from. Defaults to the main branch's head. */
268
- from?: CheckpointId;
269
- };
270
- /**
271
- * Small, storage-agnostic checkpoint DAG shared by service runtimes. Its values may be immutable
272
- * records, namespace images, or copy-on-write SQL engine snapshots.
273
- *
274
- * Values are retained by reference. Engines can therefore use persistent/COW snapshots while
275
- * simpler services can use immutable values. IDs and GC order are deterministic, and all IO
276
- * (the logical clock) is injected.
277
- */
278
- declare class Timeline<T> {
279
- readonly maxCheckpoints: number;
280
- private readonly now;
281
- private readonly makeId;
282
- private readonly nodes;
283
- private readonly heads;
284
- /** Unreferenced nodes in the exact order they became collectible. */
285
- private readonly evictable;
286
- /** Branch heads plus explicit retainers. Absent means zero. */
287
- private readonly references;
288
- private readonly explicitPins;
289
- private sequence;
290
- constructor(options?: TimelineOptions);
291
- /** Capture a new immutable value and move `branch` to it. */
292
- commit(value: T, options?: CommitOptions): Checkpoint<T>;
293
- /** Create a branch pointer without copying its checkpoint value. */
294
- fork(branch: string, options?: ForkOptions): Checkpoint<T> | undefined;
295
- /** Move a branch pointer to an existing checkpoint. */
296
- checkout(branch: string, id: CheckpointId): Checkpoint<T>;
297
- get(id: CheckpointId): Checkpoint<T>;
298
- head(branch?: string): Checkpoint<T> | undefined;
299
- hasBranch(branch: string): boolean;
300
- branches(): Readonly<Record<string, CheckpointId>>;
301
- checkpoints(): readonly Checkpoint<T>[];
302
- /** Number of retained checkpoints without allocating an array. */
303
- get size(): number;
304
- /** Pin a checkpoint independently of branch heads (used by compatibility snapshot handles). */
305
- retain(id: CheckpointId): Checkpoint<T>;
306
- /** Release one explicit pin. Branch heads remain pinned until moved or deleted. */
307
- release(id: CheckpointId): boolean;
308
- deleteBranch(branch: string): boolean;
309
- /**
310
- * Deterministically discard oldest unpinned checkpoints. Collection is O(number removed):
311
- * commits never scan pinned nodes or the retained history. Parents are metadata rather than a
312
- * storage dependency, so a retained node remains usable after pruning.
313
- */
314
- gc(max?: number): CheckpointId[];
315
- private collect;
316
- private moveHead;
317
- private addReference;
318
- private removeReference;
319
- private assertBranch;
320
- }
321
-
322
- /**
323
- * Anything that can answer a Fetch `Request` with a `Response`.
324
- *
325
- * Every Mockingbird service implements this, and every runtime adapter consumes it.
326
- * It is the only contract shared across the whole graph.
327
- */
328
- interface FetchAPI {
329
- fetch(request: Request): Promise<Response>;
330
- }
331
-
332
- /** Options every provider constructor accepts. */
333
- type APIOptions = {
334
- /** Sync SQLite client. Defaults to `@crvouga/mockingbird-service-sqlite`. */
335
- sqlite?: SqliteClient$1;
336
- /** Clock used for `created`-style fields. Default `Date.now`. */
337
- now?: () => number;
338
- /**
339
- * Storage namespace for this instance's records. Instances sharing one SQLite
340
- * client stay isolated when their namespaces differ. Defaults to the service name.
341
- */
342
- namespace?: string;
343
- };
344
-
345
357
  /**
346
358
  * One problem with a request body, at a dotted path (`patient.address.city`, `items.0.sku`).
347
359
  * `kind` is `media_type` when the body is present but its media type is not one the operation
@@ -383,6 +395,10 @@ type RequestLog = {
383
395
  ids?: Record<string, string>;
384
396
  /** Set when the service created a resource the request referred to but that did not exist. */
385
397
  adopted?: boolean;
398
+ /** Explicit durable acceptance, independent of response delivery. */
399
+ accepted?: boolean;
400
+ /** Checkpoint captured at explicit acceptance. */
401
+ checkpoint?: string;
386
402
  /** Set on a rejection (status ≥ 400) the mock produced itself, never on a scripted fault. */
387
403
  request?: RejectedRequest;
388
404
  /** The validation issues behind a rejection, when the service found any. */
@@ -446,18 +462,6 @@ type CredentialRegistry = {
446
462
  }[];
447
463
  };
448
464
 
449
- /**
450
- * Sequential id source persisted in SQLite. Ids are deterministic for a given
451
- * sequence history (`cus_` + 14 opaque chars), so reproductions stay stable.
452
- */
453
- declare class IdSequence {
454
- private readonly sqlite;
455
- private readonly namespace;
456
- private readonly salt;
457
- constructor(sqlite: SqliteClient$1, namespace: string, salt?: string);
458
- next(prefix: string, length?: number): string;
459
- }
460
-
461
465
  /**
462
466
  * A point-in-time copy of everything a service namespace holds.
463
467
  *
@@ -859,6 +863,11 @@ type S3Object = {
859
863
  contentType?: string;
860
864
  cacheControl?: string;
861
865
  contentDisposition?: string;
866
+ versionId?: string;
867
+ deleteMarker?: boolean;
868
+ storageClass?: string;
869
+ tags?: Record<string, string>;
870
+ checksums?: Record<string, string>;
862
871
  metadata: Record<string, string>;
863
872
  };
864
873
  type MultipartUpload = {
@@ -866,6 +875,10 @@ type MultipartUpload = {
866
875
  bucket: string;
867
876
  key: string;
868
877
  initiated: number;
878
+ metadata?: Record<string, string>;
879
+ contentType?: string;
880
+ cacheControl?: string;
881
+ contentDisposition?: string;
869
882
  };
870
883
  type MultipartPart = {
871
884
  uploadId: string;
@@ -883,6 +896,10 @@ declare class S3State {
883
896
  createdAt: number;
884
897
  }>;
885
898
  readonly objects: Collection<S3Object>;
899
+ readonly versions: Collection<S3Object>;
900
+ readonly configurations: Collection<{
901
+ body: string;
902
+ }>;
886
903
  readonly uploads: Collection<MultipartUpload>;
887
904
  readonly parts: Collection<MultipartPart>;
888
905
  readonly ids: IdSequence;
@@ -935,6 +952,7 @@ declare class S3API {
935
952
  private readonly sqlite;
936
953
  private readonly namespace;
937
954
  private readonly now;
955
+ private readonly ready;
938
956
  constructor(options?: S3APIOptions);
939
957
  private seed;
940
958
  reset(): Promise<void>;
@@ -947,9 +965,20 @@ declare class S3API {
947
965
  private put;
948
966
  private get;
949
967
  private list;
968
+ private compareKeys;
950
969
  private uploadPart;
951
970
  private complete;
952
971
  private deleteMany;
972
+ private versionKey;
973
+ private versioning;
974
+ private removeObject;
975
+ private conditions;
976
+ private validateChecksums;
977
+ private bucketConfiguration;
978
+ private objectTagging;
979
+ private listParts;
980
+ private listUploads;
981
+ private listVersions;
953
982
  }
954
983
 
955
984
  export { S3API, S3_NAMESPACE, S3_PRESETS, accessKeyCredential, createRuntime, document, operationIds, supportedOperationIds };
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  document,
8
8
  operationIds,
9
9
  supportedOperationIds
10
- } from "./chunk-VMROW22S.js";
10
+ } from "./chunk-UNNPPRK3.js";
11
11
  export {
12
12
  S3API,
13
13
  S3_NAMESPACE,