@crvouga/mockingbird-service-customerio 1.0.0 → 1.0.2

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-Q4XUB3JI.js";
7
- import "./chunk-KS44GSGC.js";
6
+ } from "./chunk-2WKT52HW.js";
7
+ import "./chunk-F2KPDA6X.js";
8
8
 
9
9
  // src/cli.ts
10
10
  var code = await runCli(
package/dist/index.d.ts CHANGED
@@ -228,94 +228,6 @@ type FaultRegistry = {
228
228
  take(candidate: FaultCandidate): Promise<FaultHit[]>;
229
229
  };
230
230
 
231
- /** One handled request, as the structured log sees it. */
232
- type RequestLog = {
233
- service: string;
234
- namespace: string;
235
- operationId: string | undefined;
236
- method: string;
237
- path: string;
238
- status: number;
239
- durationMs: number;
240
- /** True when the path matched no operation in the contract. */
241
- unmatched: boolean;
242
- /** Set when a fault rule produced the response. */
243
- faultId?: string;
244
- /** Resource ids the handler touched (`userId`, `orderId`, …), when the service reports them. */
245
- ids?: Record<string, string>;
246
- /** Set when the service created a resource the request referred to but that did not exist. */
247
- adopted?: boolean;
248
- };
249
- type MetricsReport = {
250
- requests: number;
251
- /** Counts keyed `<operationId> <status>`. */
252
- byOperation: Record<string, number>;
253
- /**
254
- * Paths that matched no operation, most frequent first.
255
- *
256
- * This is the early-warning signal: a consumer calling something the mock does
257
- * not implement shows up here as a count, before it fails a suite as a 404.
258
- */
259
- unmatched: {
260
- method: string;
261
- path: string;
262
- count: number;
263
- }[];
264
- faults: number;
265
- totalDurationMs: number;
266
- };
267
- type Metrics = {
268
- record(entry: RequestLog): void;
269
- report(): MetricsReport;
270
- reset(): void;
271
- };
272
-
273
- /** One journal entry: a request log stamped with when (on the mock clock) it was handled. */
274
- type JournalEntry = RequestLog & {
275
- at: string;
276
- };
277
- type JournalQuery = {
278
- /** Only this namespace. Omit for every namespace, oldest first across all of them. */
279
- namespace?: string;
280
- operationId?: string;
281
- status?: number;
282
- /** Only entries at or after this instant (epoch ms). */
283
- since?: number;
284
- /** At most this many, the most recent kept. */
285
- limit?: number;
286
- };
287
- type Journal = {
288
- readonly size: number;
289
- record(entry: JournalEntry): void;
290
- list(query?: JournalQuery): JournalEntry[];
291
- /** Forget one namespace's entries, or every namespace's. */
292
- clear(namespace?: string): void;
293
- };
294
-
295
- /** Credential → namespace mapping behind `PUT /__admin/credentials`. */
296
- type CredentialRegistry = {
297
- set(credential: string, namespace: string): void;
298
- get(credential: string): string | undefined;
299
- remove(credential: string): boolean;
300
- clear(): void;
301
- entries(): {
302
- credential: string;
303
- namespace: string;
304
- }[];
305
- };
306
-
307
- /**
308
- * Sequential id source persisted in SQLite. Ids are deterministic for a given
309
- * sequence history (`cus_` + 14 opaque chars), so reproductions stay stable.
310
- */
311
- declare class IdSequence {
312
- private readonly sqlite;
313
- private readonly namespace;
314
- private readonly salt;
315
- constructor(sqlite: SqliteClient$1, namespace: string, salt?: string);
316
- next(prefix: string, length?: number): string;
317
- }
318
-
319
231
  /** A stable identifier for a point in a {@link Timeline}. */
320
232
  type CheckpointId = string;
321
233
  /** An immutable node in a timeline's checkpoint DAG. */
@@ -406,6 +318,135 @@ interface FetchAPI {
406
318
  fetch(request: Request): Promise<Response>;
407
319
  }
408
320
 
321
+ /** Options every provider constructor accepts. */
322
+ type APIOptions = {
323
+ /** Sync SQLite client. Defaults to `@crvouga/mockingbird-service-sqlite`. */
324
+ sqlite?: SqliteClient$1;
325
+ /** Clock used for `created`-style fields. Default `Date.now`. */
326
+ now?: () => number;
327
+ /**
328
+ * Storage namespace for this instance's records. Instances sharing one SQLite
329
+ * client stay isolated when their namespaces differ. Defaults to the service name.
330
+ */
331
+ namespace?: string;
332
+ };
333
+
334
+ /**
335
+ * One problem with a request body, at a dotted path (`patient.address.city`, `items.0.sku`).
336
+ * `kind` is `media_type` when the body is present but its media type is not one the operation
337
+ * accepts (a `415` on most vendors), `syntax` when it could not be decoded, `required` when
338
+ * the operation needs a body and none arrived, and `schema` for a contract violation.
339
+ */
340
+ type BodyIssue = {
341
+ path: string;
342
+ message: string;
343
+ kind?: "media_type" | "syntax" | "required" | "schema";
344
+ };
345
+
346
+ /**
347
+ * What the mock received from a request it rejected, so a 4xx can be attributed after the
348
+ * fact (an empty body, a missing `content-type`, a schema violation) without logging the body.
349
+ */
350
+ type RejectedRequest = {
351
+ /** The raw `content-type` header, or `null` when the request sent none. */
352
+ contentType: string | null;
353
+ /** Bytes of body received from `content-length` (`0` for none), or `null` when the client sent no length (a streamed / chunked body). */
354
+ bodyBytes: number | null;
355
+ /** The raw `transfer-encoding` header (`chunked`), or `null`. */
356
+ transferEncoding: string | null;
357
+ };
358
+ /** One handled request, as the structured log sees it. */
359
+ type RequestLog = {
360
+ service: string;
361
+ namespace: string;
362
+ operationId: string | undefined;
363
+ method: string;
364
+ path: string;
365
+ status: number;
366
+ durationMs: number;
367
+ /** True when the path matched no operation in the contract. */
368
+ unmatched: boolean;
369
+ /** Set when a fault rule produced the response. */
370
+ faultId?: string;
371
+ /** Resource ids the handler touched (`userId`, `orderId`, …), when the service reports them. */
372
+ ids?: Record<string, string>;
373
+ /** Set when the service created a resource the request referred to but that did not exist. */
374
+ adopted?: boolean;
375
+ /** Set on a rejection (status ≥ 400) the mock produced itself, never on a scripted fault. */
376
+ request?: RejectedRequest;
377
+ /** The validation issues behind a rejection, when the service found any. */
378
+ issues?: BodyIssue[];
379
+ };
380
+ type MetricsReport = {
381
+ requests: number;
382
+ /** Counts keyed `<operationId> <status>`. */
383
+ byOperation: Record<string, number>;
384
+ /**
385
+ * Paths that matched no operation, most frequent first.
386
+ *
387
+ * This is the early-warning signal: a consumer calling something the mock does
388
+ * not implement shows up here as a count, before it fails a suite as a 404.
389
+ */
390
+ unmatched: {
391
+ method: string;
392
+ path: string;
393
+ count: number;
394
+ }[];
395
+ faults: number;
396
+ totalDurationMs: number;
397
+ };
398
+ type Metrics = {
399
+ record(entry: RequestLog): void;
400
+ report(): MetricsReport;
401
+ reset(): void;
402
+ };
403
+
404
+ /** One journal entry: a request log stamped with when (on the mock clock) it was handled. */
405
+ type JournalEntry = RequestLog & {
406
+ at: string;
407
+ };
408
+ type JournalQuery = {
409
+ /** Only this namespace. Omit for every namespace, oldest first across all of them. */
410
+ namespace?: string;
411
+ operationId?: string;
412
+ status?: number;
413
+ /** Only entries at or after this instant (epoch ms). */
414
+ since?: number;
415
+ /** At most this many, the most recent kept. */
416
+ limit?: number;
417
+ };
418
+ type Journal = {
419
+ readonly size: number;
420
+ record(entry: JournalEntry): void;
421
+ list(query?: JournalQuery): JournalEntry[];
422
+ /** Forget one namespace's entries, or every namespace's. */
423
+ clear(namespace?: string): void;
424
+ };
425
+
426
+ /** Credential → namespace mapping behind `PUT /__admin/credentials`. */
427
+ type CredentialRegistry = {
428
+ set(credential: string, namespace: string): void;
429
+ get(credential: string): string | undefined;
430
+ remove(credential: string): boolean;
431
+ clear(): void;
432
+ entries(): {
433
+ credential: string;
434
+ namespace: string;
435
+ }[];
436
+ };
437
+
438
+ /**
439
+ * Sequential id source persisted in SQLite. Ids are deterministic for a given
440
+ * sequence history (`cus_` + 14 opaque chars), so reproductions stay stable.
441
+ */
442
+ declare class IdSequence {
443
+ private readonly sqlite;
444
+ private readonly namespace;
445
+ private readonly salt;
446
+ constructor(sqlite: SqliteClient$1, namespace: string, salt?: string);
447
+ next(prefix: string, length?: number): string;
448
+ }
449
+
409
450
  /**
410
451
  * A point-in-time copy of everything a service namespace holds.
411
452
  *
@@ -587,19 +628,6 @@ declare class OutboxStore<T extends OutboxItem = OutboxItem> {
587
628
  list(query?: OutboxQuery): T[];
588
629
  }
589
630
 
590
- /** Options every provider constructor accepts. */
591
- type APIOptions = {
592
- /** Sync SQLite client. Defaults to `@crvouga/mockingbird-service-sqlite`. */
593
- sqlite?: SqliteClient$1;
594
- /** Clock used for `created`-style fields. Default `Date.now`. */
595
- now?: () => number;
596
- /**
597
- * Storage namespace for this instance's records. Instances sharing one SQLite
598
- * client stay isolated when their namespaces differ. Defaults to the service name.
599
- */
600
- namespace?: string;
601
- };
602
-
603
631
  /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
604
632
  type SqliteValue = null | number | bigint | string | Uint8Array | boolean;
605
633
  /** Mutation counters returned by {@link SqliteStatement.run}. */
package/dist/index.js CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  operationIds,
13
13
  signReporting,
14
14
  supportedOperationIds
15
- } from "./chunk-KS44GSGC.js";
15
+ } from "./chunk-F2KPDA6X.js";
16
16
  export {
17
17
  CUSTOMERIO_NAMESPACE,
18
18
  CUSTOMERIO_PRESETS,