@crvouga/mockingbird-service-intercom 1.8.0 → 1.9.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-SXYGIA7F.js";
7
- import "./chunk-IECVMRLO.js";
6
+ } from "./chunk-6ZFVOGHR.js";
7
+ import "./chunk-PB2BRO3M.js";
8
8
 
9
9
  // src/cli.ts
10
10
  var code = await runCli(
package/dist/index.d.ts CHANGED
@@ -219,6 +219,15 @@ type FaultCandidate = {
219
219
  namespace: string;
220
220
  };
221
221
  type FaultRegistry = {
222
+ isolateNamespaces(): void;
223
+ snapshot(namespace: string): {
224
+ rules: (FaultRule & {
225
+ remaining: number | null;
226
+ hits: number;
227
+ position: number;
228
+ })[];
229
+ rngState: number;
230
+ };
222
231
  add(rule: FaultRule): FaultRule;
223
232
  list(): (FaultRule & {
224
233
  remaining: number | null;
@@ -226,6 +235,14 @@ type FaultRegistry = {
226
235
  })[];
227
236
  remove(id: string): boolean;
228
237
  clear(): void;
238
+ restore(namespace: string, state: {
239
+ rules: (FaultRule & {
240
+ remaining: number | null;
241
+ hits: number;
242
+ position: number;
243
+ })[];
244
+ rngState: number;
245
+ }): void;
229
246
  /**
230
247
  * Every fault this request should get, in rule order, stopping at the first that answers
231
248
  * or drops (effect-only and delay-only rules let later rules match too). Consumes one of
@@ -403,8 +420,8 @@ type MetricsReport = {
403
420
  };
404
421
  type Metrics = {
405
422
  record(entry: RequestLog): void;
406
- report(): MetricsReport;
407
- reset(): void;
423
+ report(namespace?: string): MetricsReport;
424
+ reset(namespace?: string): void;
408
425
  };
409
426
 
410
427
  /** One journal entry: a request log stamped with when (on the mock clock) it was handled. */
@@ -558,6 +575,9 @@ type PublishInput = {
558
575
  id?: string;
559
576
  };
560
577
  type WebhookHub = {
578
+ pending(namespace: string): number;
579
+ snapshot(namespace: string): unknown;
580
+ restore(namespace: string, snapshot: unknown): void;
561
581
  publish(input: PublishInput): WebhookMessage;
562
582
  /** Replace a namespace's own endpoints (`PUT /__admin/webhook-endpoints`). */
563
583
  setEndpoints(namespace: string, endpoints: WebhookEndpoint[]): WebhookEndpoint[];
@@ -585,6 +605,8 @@ type ServiceTimelineState = Readonly<{
585
605
  }>;
586
606
  type ServiceCheckpoint = Checkpoint<ServiceTimelineState>;
587
607
  type ServiceRuntime<T extends ServiceInstance> = FetchAPI & {
608
+ /** Stop package-owned lifecycle timers when a supervisor closes the runtime. */
609
+ stop?(): void;
588
610
  readonly name: string;
589
611
  readonly sqlite: SqliteClient$1;
590
612
  readonly clock: Clock;
@@ -595,6 +617,13 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI & {
595
617
  readonly credentials: CredentialRegistry;
596
618
  /** The webhook hub, when the service has outbound webhooks. */
597
619
  readonly webhooks: WebhookHub | undefined;
620
+ /** Enable independent namespace clocks and PRNGs before serving a fleet. */
621
+ isolateNamespaces(): void;
622
+ namespaceClock(namespace?: string): Clock;
623
+ namespaceOf(request: Request): string;
624
+ /** Opaque in-process checkpoint including records, controls and webhook history. */
625
+ fleetSnapshot(namespace: string): object;
626
+ fleetRestore(snapshot: unknown, namespace: string): void;
598
627
  /** Expand a named preset into fault rules (and webhook faults) for `namespace`. */
599
628
  applyPreset(name: string, namespace?: string, overrides?: Partial<FaultRule>): FaultRule[];
600
629
  /** The instance behind `namespace` (the default one when omitted), created on first use. */
package/dist/index.js CHANGED
@@ -16,7 +16,7 @@ import {
16
16
  supportedOperationIds,
17
17
  toHtml,
18
18
  toPlaintext
19
- } from "./chunk-IECVMRLO.js";
19
+ } from "./chunk-PB2BRO3M.js";
20
20
  export {
21
21
  DEFAULT_ADMINS,
22
22
  DEFAULT_SETTINGS,
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. */
@@ -1120,6 +1166,9 @@ type PublishInput = {
1120
1166
  id?: string;
1121
1167
  };
1122
1168
  type WebhookHub = {
1169
+ pending(namespace: string): number;
1170
+ snapshot(namespace: string): unknown;
1171
+ restore(namespace: string, snapshot: unknown): void;
1123
1172
  publish(input: PublishInput): WebhookMessage;
1124
1173
  /** Replace a namespace's own endpoints (`PUT /__admin/webhook-endpoints`). */
1125
1174
  setEndpoints(namespace: string, endpoints: WebhookEndpoint[]): WebhookEndpoint[];
@@ -1147,6 +1196,8 @@ type ServiceTimelineState = Readonly<{
1147
1196
  }>;
1148
1197
  type ServiceCheckpoint = Checkpoint<ServiceTimelineState>;
1149
1198
  type ServiceRuntime<T extends ServiceInstance> = FetchAPI$1 & {
1199
+ /** Stop package-owned lifecycle timers when a supervisor closes the runtime. */
1200
+ stop?(): void;
1150
1201
  readonly name: string;
1151
1202
  readonly sqlite: SqliteClient$1;
1152
1203
  readonly clock: Clock;
@@ -1157,6 +1208,13 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI$1 & {
1157
1208
  readonly credentials: CredentialRegistry;
1158
1209
  /** The webhook hub, when the service has outbound webhooks. */
1159
1210
  readonly webhooks: WebhookHub | undefined;
1211
+ /** Enable independent namespace clocks and PRNGs before serving a fleet. */
1212
+ isolateNamespaces(): void;
1213
+ namespaceClock(namespace?: string): Clock;
1214
+ namespaceOf(request: Request): string;
1215
+ /** Opaque in-process checkpoint including records, controls and webhook history. */
1216
+ fleetSnapshot(namespace: string): object;
1217
+ fleetRestore(snapshot: unknown, namespace: string): void;
1160
1218
  /** Expand a named preset into fault rules (and webhook faults) for `namespace`. */
1161
1219
  applyPreset(name: string, namespace?: string, overrides?: Partial<FaultRule>): FaultRule[];
1162
1220
  /** 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-SXYGIA7F.js";
6
- import "./chunk-IECVMRLO.js";
5
+ } from "./chunk-6ZFVOGHR.js";
6
+ import "./chunk-PB2BRO3M.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-intercom",
3
- "version": "1.8.0",
3
+ "version": "1.9.0",
4
4
  "description": "Stateful mock of the Intercom REST API 2.11: contacts (search, create with 409 on duplicates, update, get), conversations (create with Idempotency-Key, reply as JSON or multipart, close/open, get, cursor search), admins, and X-Hub-Signature-signed admin reply/close/open webhooks.",
5
5
  "license": "MIT",
6
6
  "type": "module",