@crvouga/mockingbird-service-posthog 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.
@@ -5,7 +5,7 @@ import {
5
5
  parseDuration,
6
6
  resolveAdminPrefix,
7
7
  specsFromState
8
- } from "./chunk-SOC56HS3.js";
8
+ } from "./chunk-DBFEFLR4.js";
9
9
 
10
10
  // ../../adapters/node/dist/cli.js
11
11
  import { readFile as readFile2 } from "node:fs/promises";
@@ -844,4 +844,4 @@ export {
844
844
  createServer2 as createServer,
845
845
  serveTarget
846
846
  };
847
- //# sourceMappingURL=chunk-DSIEW2HP.js.map
847
+ //# sourceMappingURL=chunk-NCOO3LKB.js.map
package/dist/cli.js CHANGED
@@ -3,8 +3,8 @@ import {
3
3
  runCli,
4
4
  serveCommand,
5
5
  serveTarget
6
- } from "./chunk-DSIEW2HP.js";
7
- import "./chunk-SOC56HS3.js";
6
+ } from "./chunk-NCOO3LKB.js";
7
+ import "./chunk-DBFEFLR4.js";
8
8
 
9
9
  // src/cli.ts
10
10
  var code = await runCli(
package/dist/index.d.ts CHANGED
@@ -74,36 +74,6 @@ interface FetchAPI$1 {
74
74
  fetch(request: Request): Promise<Response>;
75
75
  }
76
76
 
77
- /**
78
- * The single source of time for a service.
79
- *
80
- * Every timestamp a mock writes reads from here, so a suite moves time instead of
81
- * sleeping: appointment windows, result delays and expiries become reachable in
82
- * milliseconds. A frozen clock also makes timestamps reproducible from a seed.
83
- */
84
- type ClockState = {
85
- /** Current epoch milliseconds. */
86
- now: number;
87
- /** True while time does not advance on its own. */
88
- frozen: boolean;
89
- /** Milliseconds this clock adds to its underlying source. */
90
- offsetMs: number;
91
- };
92
- type Clock = {
93
- now(): number;
94
- /** Pin the clock to an exact instant, keeping it frozen if it already was. */
95
- set(epochMs: number): void;
96
- /** Move the clock forward, or back with a negative delta. */
97
- advance(deltaMs: number): void;
98
- /** Stop time at the current instant. */
99
- freeze(): void;
100
- /** Resume from the current instant. */
101
- unfreeze(): void;
102
- /** Drop back to the underlying source, live. */
103
- reset(): void;
104
- state(): ClockState;
105
- };
106
-
107
77
  /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
108
78
  type SqliteValue$1 = null | number | bigint | string | Uint8Array | boolean;
109
79
  /** Mutation counters returned by {@link SqliteStatement.run}. */
@@ -175,6 +145,151 @@ declare class Collection<T> {
175
145
  }>;
176
146
  }
177
147
 
148
+ /**
149
+ * Sequential id source persisted in SQLite. Ids are deterministic for a given
150
+ * sequence history (`cus_` + 14 opaque chars), so reproductions stay stable.
151
+ */
152
+ declare class IdSequence {
153
+ private readonly sqlite;
154
+ private readonly namespace;
155
+ private readonly salt;
156
+ constructor(sqlite: SqliteClient$1, namespace: string, salt?: string);
157
+ next(prefix: string, length?: number): string;
158
+ }
159
+
160
+ /** A stable identifier for a point in a {@link Timeline}. */
161
+ type CheckpointId = string;
162
+ /** An immutable node in a timeline's checkpoint DAG. */
163
+ type Checkpoint<T> = Readonly<{
164
+ id: CheckpointId;
165
+ branch: string;
166
+ parent: CheckpointId | null;
167
+ /** Logical time supplied by the timeline's injected clock. */
168
+ at: number;
169
+ value: T;
170
+ }>;
171
+ type TimelineOptions = {
172
+ /** Logical clock used to stamp checkpoints. Defaults to a deterministic counter. */
173
+ now?: () => number;
174
+ /** Maximum retained checkpoints. Branch heads are never collected. Default 1,000. */
175
+ maxCheckpoints?: number;
176
+ /** Customize deterministic checkpoint IDs. */
177
+ id?: (sequence: number) => CheckpointId;
178
+ };
179
+ type CommitOptions = {
180
+ branch?: string;
181
+ /** Parent checkpoint. Defaults to the selected branch's current head. */
182
+ parent?: CheckpointId | null;
183
+ };
184
+ type ForkOptions = {
185
+ /** Checkpoint to fork from. Defaults to the main branch's head. */
186
+ from?: CheckpointId;
187
+ };
188
+ /**
189
+ * Small, storage-agnostic checkpoint DAG shared by service runtimes. Its values may be immutable
190
+ * records, namespace images, or copy-on-write SQL engine snapshots.
191
+ *
192
+ * Values are retained by reference. Engines can therefore use persistent/COW snapshots while
193
+ * simpler services can use immutable values. IDs and GC order are deterministic, and all IO
194
+ * (the logical clock) is injected.
195
+ */
196
+ declare class Timeline<T> {
197
+ readonly maxCheckpoints: number;
198
+ private readonly now;
199
+ private readonly makeId;
200
+ private readonly nodes;
201
+ private readonly heads;
202
+ /** Unreferenced nodes in the exact order they became collectible. */
203
+ private readonly evictable;
204
+ /** Branch heads plus explicit retainers. Absent means zero. */
205
+ private readonly references;
206
+ private readonly explicitPins;
207
+ private sequence;
208
+ constructor(options?: TimelineOptions);
209
+ /** Capture a new immutable value and move `branch` to it. */
210
+ commit(value: T, options?: CommitOptions): Checkpoint<T>;
211
+ /** Create a branch pointer without copying its checkpoint value. */
212
+ fork(branch: string, options?: ForkOptions): Checkpoint<T> | undefined;
213
+ /** Move a branch pointer to an existing checkpoint. */
214
+ checkout(branch: string, id: CheckpointId): Checkpoint<T>;
215
+ get(id: CheckpointId): Checkpoint<T>;
216
+ head(branch?: string): Checkpoint<T> | undefined;
217
+ hasBranch(branch: string): boolean;
218
+ branches(): Readonly<Record<string, CheckpointId>>;
219
+ checkpoints(): readonly Checkpoint<T>[];
220
+ /** Number of retained checkpoints without allocating an array. */
221
+ get size(): number;
222
+ /** Pin a checkpoint independently of branch heads (used by compatibility snapshot handles). */
223
+ retain(id: CheckpointId): Checkpoint<T>;
224
+ /** Release one explicit pin. Branch heads remain pinned until moved or deleted. */
225
+ release(id: CheckpointId): boolean;
226
+ deleteBranch(branch: string): boolean;
227
+ /**
228
+ * Deterministically discard oldest unpinned checkpoints. Collection is O(number removed):
229
+ * commits never scan pinned nodes or the retained history. Parents are metadata rather than a
230
+ * storage dependency, so a retained node remains usable after pruning.
231
+ */
232
+ gc(max?: number): CheckpointId[];
233
+ private collect;
234
+ private moveHead;
235
+ private addReference;
236
+ private removeReference;
237
+ private assertBranch;
238
+ }
239
+
240
+ /**
241
+ * Anything that can answer a Fetch `Request` with a `Response`.
242
+ *
243
+ * Every Mockingbird service implements this, and every runtime adapter consumes it.
244
+ * It is the only contract shared across the whole graph.
245
+ */
246
+ interface FetchAPI {
247
+ fetch(request: Request): Promise<Response>;
248
+ }
249
+
250
+ /** Options every provider constructor accepts. */
251
+ type APIOptions = {
252
+ /** Sync SQLite client. Defaults to `@crvouga/mockingbird-service-sqlite`. */
253
+ sqlite?: SqliteClient$1;
254
+ /** Clock used for `created`-style fields. Default `Date.now`. */
255
+ now?: () => number;
256
+ /**
257
+ * Storage namespace for this instance's records. Instances sharing one SQLite
258
+ * client stay isolated when their namespaces differ. Defaults to the service name.
259
+ */
260
+ namespace?: string;
261
+ };
262
+
263
+ /**
264
+ * The single source of time for a service.
265
+ *
266
+ * Every timestamp a mock writes reads from here, so a suite moves time instead of
267
+ * sleeping: appointment windows, result delays and expiries become reachable in
268
+ * milliseconds. A frozen clock also makes timestamps reproducible from a seed.
269
+ */
270
+ type ClockState = {
271
+ /** Current epoch milliseconds. */
272
+ now: number;
273
+ /** True while time does not advance on its own. */
274
+ frozen: boolean;
275
+ /** Milliseconds this clock adds to its underlying source. */
276
+ offsetMs: number;
277
+ };
278
+ type Clock = {
279
+ now(): number;
280
+ /** Pin the clock to an exact instant, keeping it frozen if it already was. */
281
+ set(epochMs: number): void;
282
+ /** Move the clock forward, or back with a negative delta. */
283
+ advance(deltaMs: number): void;
284
+ /** Stop time at the current instant. */
285
+ freeze(): void;
286
+ /** Resume from the current instant. */
287
+ unfreeze(): void;
288
+ /** Drop back to the underlying source, live. */
289
+ reset(): void;
290
+ state(): ClockState;
291
+ };
292
+
178
293
  /**
179
294
  * Seeded pseudo-random numbers, so anything a mock invents — ids, jitter, which
180
295
  * request a percentage fault hits — is reproducible from a seed.
@@ -315,109 +430,6 @@ type FaultRegistry = {
315
430
  take(candidate: FaultCandidate): Promise<FaultHit[]>;
316
431
  };
317
432
 
318
- /** A stable identifier for a point in a {@link Timeline}. */
319
- type CheckpointId = string;
320
- /** An immutable node in a timeline's checkpoint DAG. */
321
- type Checkpoint<T> = Readonly<{
322
- id: CheckpointId;
323
- branch: string;
324
- parent: CheckpointId | null;
325
- /** Logical time supplied by the timeline's injected clock. */
326
- at: number;
327
- value: T;
328
- }>;
329
- type TimelineOptions = {
330
- /** Logical clock used to stamp checkpoints. Defaults to a deterministic counter. */
331
- now?: () => number;
332
- /** Maximum retained checkpoints. Branch heads are never collected. Default 1,000. */
333
- maxCheckpoints?: number;
334
- /** Customize deterministic checkpoint IDs. */
335
- id?: (sequence: number) => CheckpointId;
336
- };
337
- type CommitOptions = {
338
- branch?: string;
339
- /** Parent checkpoint. Defaults to the selected branch's current head. */
340
- parent?: CheckpointId | null;
341
- };
342
- type ForkOptions = {
343
- /** Checkpoint to fork from. Defaults to the main branch's head. */
344
- from?: CheckpointId;
345
- };
346
- /**
347
- * Small, storage-agnostic checkpoint DAG shared by service runtimes. Its values may be immutable
348
- * records, namespace images, or copy-on-write SQL engine snapshots.
349
- *
350
- * Values are retained by reference. Engines can therefore use persistent/COW snapshots while
351
- * simpler services can use immutable values. IDs and GC order are deterministic, and all IO
352
- * (the logical clock) is injected.
353
- */
354
- declare class Timeline<T> {
355
- readonly maxCheckpoints: number;
356
- private readonly now;
357
- private readonly makeId;
358
- private readonly nodes;
359
- private readonly heads;
360
- /** Unreferenced nodes in the exact order they became collectible. */
361
- private readonly evictable;
362
- /** Branch heads plus explicit retainers. Absent means zero. */
363
- private readonly references;
364
- private readonly explicitPins;
365
- private sequence;
366
- constructor(options?: TimelineOptions);
367
- /** Capture a new immutable value and move `branch` to it. */
368
- commit(value: T, options?: CommitOptions): Checkpoint<T>;
369
- /** Create a branch pointer without copying its checkpoint value. */
370
- fork(branch: string, options?: ForkOptions): Checkpoint<T> | undefined;
371
- /** Move a branch pointer to an existing checkpoint. */
372
- checkout(branch: string, id: CheckpointId): Checkpoint<T>;
373
- get(id: CheckpointId): Checkpoint<T>;
374
- head(branch?: string): Checkpoint<T> | undefined;
375
- hasBranch(branch: string): boolean;
376
- branches(): Readonly<Record<string, CheckpointId>>;
377
- checkpoints(): readonly Checkpoint<T>[];
378
- /** Number of retained checkpoints without allocating an array. */
379
- get size(): number;
380
- /** Pin a checkpoint independently of branch heads (used by compatibility snapshot handles). */
381
- retain(id: CheckpointId): Checkpoint<T>;
382
- /** Release one explicit pin. Branch heads remain pinned until moved or deleted. */
383
- release(id: CheckpointId): boolean;
384
- deleteBranch(branch: string): boolean;
385
- /**
386
- * Deterministically discard oldest unpinned checkpoints. Collection is O(number removed):
387
- * commits never scan pinned nodes or the retained history. Parents are metadata rather than a
388
- * storage dependency, so a retained node remains usable after pruning.
389
- */
390
- gc(max?: number): CheckpointId[];
391
- private collect;
392
- private moveHead;
393
- private addReference;
394
- private removeReference;
395
- private assertBranch;
396
- }
397
-
398
- /**
399
- * Anything that can answer a Fetch `Request` with a `Response`.
400
- *
401
- * Every Mockingbird service implements this, and every runtime adapter consumes it.
402
- * It is the only contract shared across the whole graph.
403
- */
404
- interface FetchAPI {
405
- fetch(request: Request): Promise<Response>;
406
- }
407
-
408
- /** Options every provider constructor accepts. */
409
- type APIOptions = {
410
- /** Sync SQLite client. Defaults to `@crvouga/mockingbird-service-sqlite`. */
411
- sqlite?: SqliteClient$1;
412
- /** Clock used for `created`-style fields. Default `Date.now`. */
413
- now?: () => number;
414
- /**
415
- * Storage namespace for this instance's records. Instances sharing one SQLite
416
- * client stay isolated when their namespaces differ. Defaults to the service name.
417
- */
418
- namespace?: string;
419
- };
420
-
421
433
  /**
422
434
  * One problem with a request body, at a dotted path (`patient.address.city`, `items.0.sku`).
423
435
  * `kind` is `media_type` when the body is present but its media type is not one the operation
@@ -459,6 +471,10 @@ type RequestLog = {
459
471
  ids?: Record<string, string>;
460
472
  /** Set when the service created a resource the request referred to but that did not exist. */
461
473
  adopted?: boolean;
474
+ /** Explicit durable acceptance, independent of response delivery. */
475
+ accepted?: boolean;
476
+ /** Checkpoint captured at explicit acceptance. */
477
+ checkpoint?: string;
462
478
  /** Set on a rejection (status ≥ 400) the mock produced itself, never on a scripted fault. */
463
479
  request?: RejectedRequest;
464
480
  /** The validation issues behind a rejection, when the service found any. */
@@ -522,18 +538,6 @@ type CredentialRegistry = {
522
538
  }[];
523
539
  };
524
540
 
525
- /**
526
- * Sequential id source persisted in SQLite. Ids are deterministic for a given
527
- * sequence history (`cus_` + 14 opaque chars), so reproductions stay stable.
528
- */
529
- declare class IdSequence {
530
- private readonly sqlite;
531
- private readonly namespace;
532
- private readonly salt;
533
- constructor(sqlite: SqliteClient$1, namespace: string, salt?: string);
534
- next(prefix: string, length?: number): string;
535
- }
536
-
537
541
  /**
538
542
  * A point-in-time copy of everything a service namespace holds.
539
543
  *
package/dist/index.js CHANGED
@@ -15,7 +15,7 @@ import {
15
15
  supportedOperationIds,
16
16
  tokenFromBody,
17
17
  valueForState
18
- } from "./chunk-SOC56HS3.js";
18
+ } from "./chunk-DBFEFLR4.js";
19
19
  export {
20
20
  ACME_FLAG_STATE,
21
21
  POSTHOG_NAMESPACE,