@crvouga/mockingbird-service-posthog 1.7.0 → 1.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/dist/cli.js CHANGED
@@ -3,8 +3,8 @@ import {
3
3
  runCli,
4
4
  serveCommand,
5
5
  serveTarget
6
- } from "./chunk-IZQTAJ72.js";
7
- import "./chunk-IZLY3267.js";
6
+ } from "./chunk-LKPLI7YI.js";
7
+ import "./chunk-Y3KAEWE2.js";
8
8
 
9
9
  // src/cli.ts
10
10
  var code = await runCli(
package/dist/index.d.ts CHANGED
@@ -280,6 +280,15 @@ type FaultCandidate = {
280
280
  namespace: string;
281
281
  };
282
282
  type FaultRegistry = {
283
+ isolateNamespaces(): void;
284
+ snapshot(namespace: string): {
285
+ rules: (FaultRule & {
286
+ remaining: number | null;
287
+ hits: number;
288
+ position: number;
289
+ })[];
290
+ rngState: number;
291
+ };
283
292
  add(rule: FaultRule): FaultRule;
284
293
  list(): (FaultRule & {
285
294
  remaining: number | null;
@@ -287,6 +296,14 @@ type FaultRegistry = {
287
296
  })[];
288
297
  remove(id: string): boolean;
289
298
  clear(): void;
299
+ restore(namespace: string, state: {
300
+ rules: (FaultRule & {
301
+ remaining: number | null;
302
+ hits: number;
303
+ position: number;
304
+ })[];
305
+ rngState: number;
306
+ }): void;
290
307
  /**
291
308
  * Every fault this request should get, in rule order, stopping at the first that answers
292
309
  * or drops (effect-only and delay-only rules let later rules match too). Consumes one of
@@ -464,8 +481,8 @@ type MetricsReport = {
464
481
  };
465
482
  type Metrics = {
466
483
  record(entry: RequestLog): void;
467
- report(): MetricsReport;
468
- reset(): void;
484
+ report(namespace?: string): MetricsReport;
485
+ reset(namespace?: string): void;
469
486
  };
470
487
 
471
488
  /** One journal entry: a request log stamped with when (on the mock clock) it was handled. */
@@ -631,6 +648,9 @@ type PublishInput = {
631
648
  id?: string;
632
649
  };
633
650
  type WebhookHub = {
651
+ pending(namespace: string): number;
652
+ snapshot(namespace: string): unknown;
653
+ restore(namespace: string, snapshot: unknown): void;
634
654
  publish(input: PublishInput): WebhookMessage;
635
655
  /** Replace a namespace's own endpoints (`PUT /__admin/webhook-endpoints`). */
636
656
  setEndpoints(namespace: string, endpoints: WebhookEndpoint[]): WebhookEndpoint[];
@@ -658,6 +678,8 @@ type ServiceTimelineState = Readonly<{
658
678
  }>;
659
679
  type ServiceCheckpoint = Checkpoint<ServiceTimelineState>;
660
680
  type ServiceRuntime<T extends ServiceInstance> = FetchAPI & {
681
+ /** Stop package-owned lifecycle timers when a supervisor closes the runtime. */
682
+ stop?(): void;
661
683
  readonly name: string;
662
684
  readonly sqlite: SqliteClient$1;
663
685
  readonly clock: Clock;
@@ -668,6 +690,13 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI & {
668
690
  readonly credentials: CredentialRegistry;
669
691
  /** The webhook hub, when the service has outbound webhooks. */
670
692
  readonly webhooks: WebhookHub | undefined;
693
+ /** Enable independent namespace clocks and PRNGs before serving a fleet. */
694
+ isolateNamespaces(): void;
695
+ namespaceClock(namespace?: string): Clock;
696
+ namespaceOf(request: Request): string;
697
+ /** Opaque in-process checkpoint including records, controls and webhook history. */
698
+ fleetSnapshot(namespace: string): object;
699
+ fleetRestore(snapshot: unknown, namespace: string): void;
671
700
  /** Expand a named preset into fault rules (and webhook faults) for `namespace`. */
672
701
  applyPreset(name: string, namespace?: string, overrides?: Partial<FaultRule>): FaultRule[];
673
702
  /** The instance behind `namespace` (the default one when omitted), created on first use. */
package/dist/index.js CHANGED
@@ -15,7 +15,7 @@ import {
15
15
  supportedOperationIds,
16
16
  tokenFromBody,
17
17
  valueForState
18
- } from "./chunk-IZLY3267.js";
18
+ } from "./chunk-Y3KAEWE2.js";
19
19
  export {
20
20
  ACME_FLAG_STATE,
21
21
  POSTHOG_NAMESPACE,
package/dist/server.d.ts CHANGED
@@ -155,6 +155,15 @@ type FaultCandidate$1 = {
155
155
  namespace: string;
156
156
  };
157
157
  type FaultRegistry$1 = {
158
+ isolateNamespaces(): void;
159
+ snapshot(namespace: string): {
160
+ rules: (FaultRule$1 & {
161
+ remaining: number | null;
162
+ hits: number;
163
+ position: number;
164
+ })[];
165
+ rngState: number;
166
+ };
158
167
  add(rule: FaultRule$1): FaultRule$1;
159
168
  list(): (FaultRule$1 & {
160
169
  remaining: number | null;
@@ -162,6 +171,14 @@ type FaultRegistry$1 = {
162
171
  })[];
163
172
  remove(id: string): boolean;
164
173
  clear(): void;
174
+ restore(namespace: string, state: {
175
+ rules: (FaultRule$1 & {
176
+ remaining: number | null;
177
+ hits: number;
178
+ position: number;
179
+ })[];
180
+ rngState: number;
181
+ }): void;
165
182
  /**
166
183
  * Every fault this request should get, in rule order, stopping at the first that answers
167
184
  * or drops (effect-only and delay-only rules let later rules match too). Consumes one of
@@ -326,8 +343,8 @@ type MetricsReport$1 = {
326
343
  };
327
344
  type Metrics$1 = {
328
345
  record(entry: RequestLog$1): void;
329
- report(): MetricsReport$1;
330
- reset(): void;
346
+ report(namespace?: string): MetricsReport$1;
347
+ reset(namespace?: string): void;
331
348
  };
332
349
 
333
350
  /** One journal entry: a request log stamped with when (on the mock clock) it was handled. */
@@ -481,6 +498,9 @@ type PublishInput$1 = {
481
498
  id?: string;
482
499
  };
483
500
  type WebhookHub$1 = {
501
+ pending(namespace: string): number;
502
+ snapshot(namespace: string): unknown;
503
+ restore(namespace: string, snapshot: unknown): void;
484
504
  publish(input: PublishInput$1): WebhookMessage$1;
485
505
  /** Replace a namespace's own endpoints (`PUT /__admin/webhook-endpoints`). */
486
506
  setEndpoints(namespace: string, endpoints: WebhookEndpoint$1[]): WebhookEndpoint$1[];
@@ -508,6 +528,8 @@ type ServiceTimelineState$1 = Readonly<{
508
528
  }>;
509
529
  type ServiceCheckpoint$1 = Checkpoint$1<ServiceTimelineState$1>;
510
530
  type ServiceRuntime$1<T extends ServiceInstance$1> = FetchAPI$2 & {
531
+ /** Stop package-owned lifecycle timers when a supervisor closes the runtime. */
532
+ stop?(): void;
511
533
  readonly name: string;
512
534
  readonly sqlite: SqliteClient$2;
513
535
  readonly clock: Clock$1;
@@ -518,6 +540,13 @@ type ServiceRuntime$1<T extends ServiceInstance$1> = FetchAPI$2 & {
518
540
  readonly credentials: CredentialRegistry$1;
519
541
  /** The webhook hub, when the service has outbound webhooks. */
520
542
  readonly webhooks: WebhookHub$1 | undefined;
543
+ /** Enable independent namespace clocks and PRNGs before serving a fleet. */
544
+ isolateNamespaces(): void;
545
+ namespaceClock(namespace?: string): Clock$1;
546
+ namespaceOf(request: Request): string;
547
+ /** Opaque in-process checkpoint including records, controls and webhook history. */
548
+ fleetSnapshot(namespace: string): object;
549
+ fleetRestore(snapshot: unknown, namespace: string): void;
521
550
  /** Expand a named preset into fault rules (and webhook faults) for `namespace`. */
522
551
  applyPreset(name: string, namespace?: string, overrides?: Partial<FaultRule$1>): FaultRule$1[];
523
552
  /** The instance behind `namespace` (the default one when omitted), created on first use. */
@@ -781,6 +810,15 @@ type FaultCandidate = {
781
810
  namespace: string;
782
811
  };
783
812
  type FaultRegistry = {
813
+ isolateNamespaces(): void;
814
+ snapshot(namespace: string): {
815
+ rules: (FaultRule & {
816
+ remaining: number | null;
817
+ hits: number;
818
+ position: number;
819
+ })[];
820
+ rngState: number;
821
+ };
784
822
  add(rule: FaultRule): FaultRule;
785
823
  list(): (FaultRule & {
786
824
  remaining: number | null;
@@ -788,6 +826,14 @@ type FaultRegistry = {
788
826
  })[];
789
827
  remove(id: string): boolean;
790
828
  clear(): void;
829
+ restore(namespace: string, state: {
830
+ rules: (FaultRule & {
831
+ remaining: number | null;
832
+ hits: number;
833
+ position: number;
834
+ })[];
835
+ rngState: number;
836
+ }): void;
791
837
  /**
792
838
  * Every fault this request should get, in rule order, stopping at the first that answers
793
839
  * or drops (effect-only and delay-only rules let later rules match too). Consumes one of
@@ -965,8 +1011,8 @@ type MetricsReport = {
965
1011
  };
966
1012
  type Metrics = {
967
1013
  record(entry: RequestLog): void;
968
- report(): MetricsReport;
969
- reset(): void;
1014
+ report(namespace?: string): MetricsReport;
1015
+ reset(namespace?: string): void;
970
1016
  };
971
1017
 
972
1018
  /** One journal entry: a request log stamped with when (on the mock clock) it was handled. */
@@ -1132,6 +1178,9 @@ type PublishInput = {
1132
1178
  id?: string;
1133
1179
  };
1134
1180
  type WebhookHub = {
1181
+ pending(namespace: string): number;
1182
+ snapshot(namespace: string): unknown;
1183
+ restore(namespace: string, snapshot: unknown): void;
1135
1184
  publish(input: PublishInput): WebhookMessage;
1136
1185
  /** Replace a namespace's own endpoints (`PUT /__admin/webhook-endpoints`). */
1137
1186
  setEndpoints(namespace: string, endpoints: WebhookEndpoint[]): WebhookEndpoint[];
@@ -1159,6 +1208,8 @@ type ServiceTimelineState = Readonly<{
1159
1208
  }>;
1160
1209
  type ServiceCheckpoint = Checkpoint<ServiceTimelineState>;
1161
1210
  type ServiceRuntime<T extends ServiceInstance> = FetchAPI$1 & {
1211
+ /** Stop package-owned lifecycle timers when a supervisor closes the runtime. */
1212
+ stop?(): void;
1162
1213
  readonly name: string;
1163
1214
  readonly sqlite: SqliteClient$1;
1164
1215
  readonly clock: Clock;
@@ -1169,6 +1220,13 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI$1 & {
1169
1220
  readonly credentials: CredentialRegistry;
1170
1221
  /** The webhook hub, when the service has outbound webhooks. */
1171
1222
  readonly webhooks: WebhookHub | undefined;
1223
+ /** Enable independent namespace clocks and PRNGs before serving a fleet. */
1224
+ isolateNamespaces(): void;
1225
+ namespaceClock(namespace?: string): Clock;
1226
+ namespaceOf(request: Request): string;
1227
+ /** Opaque in-process checkpoint including records, controls and webhook history. */
1228
+ fleetSnapshot(namespace: string): object;
1229
+ fleetRestore(snapshot: unknown, namespace: string): void;
1172
1230
  /** Expand a named preset into fault rules (and webhook faults) for `namespace`. */
1173
1231
  applyPreset(name: string, namespace?: string, overrides?: Partial<FaultRule>): FaultRule[];
1174
1232
  /** The instance behind `namespace` (the default one when omitted), created on first use. */
package/dist/server.js CHANGED
@@ -2,8 +2,8 @@ import {
2
2
  DEFAULT_PORT,
3
3
  createServer,
4
4
  serveTarget
5
- } from "./chunk-IZQTAJ72.js";
6
- import "./chunk-IZLY3267.js";
5
+ } from "./chunk-LKPLI7YI.js";
6
+ import "./chunk-Y3KAEWE2.js";
7
7
  export {
8
8
  DEFAULT_PORT,
9
9
  createServer,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crvouga/mockingbird-service-posthog",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "description": "Stateful mock of PostHog: /flags v2 and legacy /decide evaluation with per-test flag, variant and payload control, remote config, gzip/base64 capture (/batch/, /e/, /i/v0/e/), recordings intake, and the feature-flag management and HogQL API slice.",
5
5
  "license": "MIT",
6
6
  "type": "module",