@dhaneshpurohit/mockstar 0.1.3

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.
Files changed (156) hide show
  1. package/CHANGELOG.md +180 -0
  2. package/LICENSE +21 -0
  3. package/README.md +260 -0
  4. package/dist/cli/commands/init.d.ts +13 -0
  5. package/dist/cli/commands/init.d.ts.map +1 -0
  6. package/dist/cli/commands/migrate.d.ts +13 -0
  7. package/dist/cli/commands/migrate.d.ts.map +1 -0
  8. package/dist/cli.d.ts +3 -0
  9. package/dist/cli.d.ts.map +1 -0
  10. package/dist/cli.js +15076 -0
  11. package/dist/core/config/index.d.ts +5 -0
  12. package/dist/core/config/index.d.ts.map +1 -0
  13. package/dist/core/config/loader.d.ts +14 -0
  14. package/dist/core/config/loader.d.ts.map +1 -0
  15. package/dist/core/config/schema.d.ts +5706 -0
  16. package/dist/core/config/schema.d.ts.map +1 -0
  17. package/dist/core/config/snapshot.d.ts +52 -0
  18. package/dist/core/config/snapshot.d.ts.map +1 -0
  19. package/dist/core/config/watcher.d.ts +13 -0
  20. package/dist/core/config/watcher.d.ts.map +1 -0
  21. package/dist/core/errors/boundary.d.ts +22 -0
  22. package/dist/core/errors/boundary.d.ts.map +1 -0
  23. package/dist/core/errors/index.d.ts +3 -0
  24. package/dist/core/errors/index.d.ts.map +1 -0
  25. package/dist/core/errors/process.d.ts +17 -0
  26. package/dist/core/errors/process.d.ts.map +1 -0
  27. package/dist/core/handlers/index.d.ts +4 -0
  28. package/dist/core/handlers/index.d.ts.map +1 -0
  29. package/dist/core/handlers/registry.d.ts +22 -0
  30. package/dist/core/handlers/registry.d.ts.map +1 -0
  31. package/dist/core/handlers/types.d.ts +42 -0
  32. package/dist/core/handlers/types.d.ts.map +1 -0
  33. package/dist/core/journal/index.d.ts +2 -0
  34. package/dist/core/journal/index.d.ts.map +1 -0
  35. package/dist/core/journal/ring-buffer.d.ts +46 -0
  36. package/dist/core/journal/ring-buffer.d.ts.map +1 -0
  37. package/dist/core/matching/discriminators.d.ts +29 -0
  38. package/dist/core/matching/discriminators.d.ts.map +1 -0
  39. package/dist/core/matching/index.d.ts +24 -0
  40. package/dist/core/matching/index.d.ts.map +1 -0
  41. package/dist/core/matching/path-trie.d.ts +21 -0
  42. package/dist/core/matching/path-trie.d.ts.map +1 -0
  43. package/dist/core/observability/index.d.ts +3 -0
  44. package/dist/core/observability/index.d.ts.map +1 -0
  45. package/dist/core/observability/logger.d.ts +18 -0
  46. package/dist/core/observability/logger.d.ts.map +1 -0
  47. package/dist/core/observability/metrics.d.ts +23 -0
  48. package/dist/core/observability/metrics.d.ts.map +1 -0
  49. package/dist/core/preflight.d.ts +18 -0
  50. package/dist/core/preflight.d.ts.map +1 -0
  51. package/dist/core/scenarios/evaluator.d.ts +52 -0
  52. package/dist/core/scenarios/evaluator.d.ts.map +1 -0
  53. package/dist/core/scenarios/index.d.ts +5 -0
  54. package/dist/core/scenarios/index.d.ts.map +1 -0
  55. package/dist/core/scenarios/merger.d.ts +45 -0
  56. package/dist/core/scenarios/merger.d.ts.map +1 -0
  57. package/dist/core/templating/compiler.d.ts +118 -0
  58. package/dist/core/templating/compiler.d.ts.map +1 -0
  59. package/dist/core/templating/faker.d.ts +14 -0
  60. package/dist/core/templating/faker.d.ts.map +1 -0
  61. package/dist/core/templating/index.d.ts +4 -0
  62. package/dist/core/templating/index.d.ts.map +1 -0
  63. package/dist/core/templating/tier2/id.d.ts +27 -0
  64. package/dist/core/templating/tier2/id.d.ts.map +1 -0
  65. package/dist/core/templating/tier2/index.d.ts +4 -0
  66. package/dist/core/templating/tier2/index.d.ts.map +1 -0
  67. package/dist/core/templating/tier2/now.d.ts +15 -0
  68. package/dist/core/templating/tier2/now.d.ts.map +1 -0
  69. package/dist/core/templating/tier2/walker.d.ts +43 -0
  70. package/dist/core/templating/tier2/walker.d.ts.map +1 -0
  71. package/dist/core/tenancy/extractor.d.ts +20 -0
  72. package/dist/core/tenancy/extractor.d.ts.map +1 -0
  73. package/dist/core/tenancy/index.d.ts +2 -0
  74. package/dist/core/tenancy/index.d.ts.map +1 -0
  75. package/dist/features/admin/auth.d.ts +19 -0
  76. package/dist/features/admin/auth.d.ts.map +1 -0
  77. package/dist/features/admin/endpoints.d.ts +21 -0
  78. package/dist/features/admin/endpoints.d.ts.map +1 -0
  79. package/dist/features/admin/index.d.ts +3 -0
  80. package/dist/features/admin/index.d.ts.map +1 -0
  81. package/dist/features/dynamic-mock.d.ts +16 -0
  82. package/dist/features/dynamic-mock.d.ts.map +1 -0
  83. package/dist/features/enhance/boundary.d.ts +26 -0
  84. package/dist/features/enhance/boundary.d.ts.map +1 -0
  85. package/dist/features/enhance/field-mapping.d.ts +23 -0
  86. package/dist/features/enhance/field-mapping.d.ts.map +1 -0
  87. package/dist/features/enhance/index.d.ts +21 -0
  88. package/dist/features/enhance/index.d.ts.map +1 -0
  89. package/dist/features/openapi/converter.d.ts +55 -0
  90. package/dist/features/openapi/converter.d.ts.map +1 -0
  91. package/dist/features/openapi/importer.d.ts +11 -0
  92. package/dist/features/openapi/importer.d.ts.map +1 -0
  93. package/dist/features/openapi/index.d.ts +3 -0
  94. package/dist/features/openapi/index.d.ts.map +1 -0
  95. package/dist/features/pass-through.d.ts +9 -0
  96. package/dist/features/pass-through.d.ts.map +1 -0
  97. package/dist/features/proxy/ca.d.ts +49 -0
  98. package/dist/features/proxy/ca.d.ts.map +1 -0
  99. package/dist/features/proxy/cert-cache.d.ts +34 -0
  100. package/dist/features/proxy/cert-cache.d.ts.map +1 -0
  101. package/dist/features/proxy/cli.d.ts +2 -0
  102. package/dist/features/proxy/cli.d.ts.map +1 -0
  103. package/dist/features/proxy/config.d.ts +71 -0
  104. package/dist/features/proxy/config.d.ts.map +1 -0
  105. package/dist/features/proxy/dns.d.ts +18 -0
  106. package/dist/features/proxy/dns.d.ts.map +1 -0
  107. package/dist/features/proxy/env-detector.d.ts +7 -0
  108. package/dist/features/proxy/env-detector.d.ts.map +1 -0
  109. package/dist/features/proxy/index.d.ts +15 -0
  110. package/dist/features/proxy/index.d.ts.map +1 -0
  111. package/dist/features/proxy/install-journal.d.ts +51 -0
  112. package/dist/features/proxy/install-journal.d.ts.map +1 -0
  113. package/dist/features/proxy/port-bind.d.ts +33 -0
  114. package/dist/features/proxy/port-bind.d.ts.map +1 -0
  115. package/dist/features/proxy/server.d.ts +19 -0
  116. package/dist/features/proxy/server.d.ts.map +1 -0
  117. package/dist/features/proxy/sni-gate.d.ts +17 -0
  118. package/dist/features/proxy/sni-gate.d.ts.map +1 -0
  119. package/dist/features/proxy/tls-adapter.d.ts +52 -0
  120. package/dist/features/proxy/tls-adapter.d.ts.map +1 -0
  121. package/dist/features/proxy/types.d.ts +103 -0
  122. package/dist/features/proxy/types.d.ts.map +1 -0
  123. package/dist/features/proxy/upstream.d.ts +23 -0
  124. package/dist/features/proxy/upstream.d.ts.map +1 -0
  125. package/dist/features/spec/index.d.ts +17 -0
  126. package/dist/features/spec/index.d.ts.map +1 -0
  127. package/dist/features/static-mock.d.ts +23 -0
  128. package/dist/features/static-mock.d.ts.map +1 -0
  129. package/dist/features/url-validator.d.ts +53 -0
  130. package/dist/features/url-validator.d.ts.map +1 -0
  131. package/dist/features/webhooks/circuit-breaker.d.ts +49 -0
  132. package/dist/features/webhooks/circuit-breaker.d.ts.map +1 -0
  133. package/dist/features/webhooks/compile.d.ts +16 -0
  134. package/dist/features/webhooks/compile.d.ts.map +1 -0
  135. package/dist/features/webhooks/dispatcher.d.ts +45 -0
  136. package/dist/features/webhooks/dispatcher.d.ts.map +1 -0
  137. package/dist/features/webhooks/event-registry.d.ts +36 -0
  138. package/dist/features/webhooks/event-registry.d.ts.map +1 -0
  139. package/dist/features/webhooks/index.d.ts +13 -0
  140. package/dist/features/webhooks/index.d.ts.map +1 -0
  141. package/dist/features/webhooks/journal.d.ts +32 -0
  142. package/dist/features/webhooks/journal.d.ts.map +1 -0
  143. package/dist/features/webhooks/queue.d.ts +93 -0
  144. package/dist/features/webhooks/queue.d.ts.map +1 -0
  145. package/dist/features/webhooks/signing.d.ts +35 -0
  146. package/dist/features/webhooks/signing.d.ts.map +1 -0
  147. package/dist/features/webhooks/types.d.ts +96 -0
  148. package/dist/features/webhooks/types.d.ts.map +1 -0
  149. package/dist/index.d.ts +30 -0
  150. package/dist/index.d.ts.map +1 -0
  151. package/dist/index.js +12813 -0
  152. package/dist/server.d.ts +62 -0
  153. package/dist/server.d.ts.map +1 -0
  154. package/dist/version.d.ts +2 -0
  155. package/dist/version.d.ts.map +1 -0
  156. package/package.json +62 -0
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Three-state breaker per webhook. State transitions:
3
+ *
4
+ * CLOSED --(failureThreshold consecutive failures)--> OPEN
5
+ * OPEN --(cooldownMs elapsed)--> HALF_OPEN
6
+ * HALF_OPEN --(one success)--> CLOSED
7
+ * HALF_OPEN --(one failure)--> OPEN (cooldown restarts)
8
+ *
9
+ * Pure state machine; no HTTP, no timers. The queue calls `gate()` before each
10
+ * attempt and `record()` after. Time is sampled from `Date.now()` for cooldown
11
+ * comparisons — deterministic given a clock.
12
+ *
13
+ * Half-open probe limiting (F2): the canonical pattern (Fowler; Microsoft Azure
14
+ * "Circuit Breaker") admits only a *limited number of trial requests* in half-open
15
+ * so a recovering upstream is not flooded the instant cooldown elapses. `gate()` is
16
+ * therefore an ATOMIC acquire: it hands out at most `halfOpenMaxProbes` (default 1)
17
+ * permits while half-open and returns "open" (deny) to any caller beyond that until a
18
+ * `record()` resolves an outstanding probe. Use `peek()` for non-consuming reads
19
+ * (metrics), which never spend a probe permit.
20
+ */
21
+ export interface CircuitBreakerOptions {
22
+ failureThreshold: number;
23
+ cooldownMs: number;
24
+ /** Max concurrent trial requests admitted in half-open before a record() resolves one. Default: 1. */
25
+ halfOpenMaxProbes?: number;
26
+ /** Optional clock injection for deterministic tests. */
27
+ now?: () => number;
28
+ }
29
+ export type CircuitState = "closed" | "open" | "half-open";
30
+ export declare class CircuitBreaker {
31
+ #private;
32
+ constructor(opts: CircuitBreakerOptions);
33
+ /**
34
+ * Non-consuming read of the effective state. Triggers the OPEN→HALF_OPEN transition
35
+ * if cooldown elapsed but NEVER spends a half-open probe permit. Use for metrics.
36
+ */
37
+ peek(): CircuitState;
38
+ /**
39
+ * Atomic "may I attempt?" acquire. Triggers OPEN→HALF_OPEN if cooldown elapsed.
40
+ * In half-open, hands out at most `halfOpenMaxProbes` permits and returns "open"
41
+ * (deny) once exhausted, so concurrent deliveries can't flood a recovering upstream.
42
+ */
43
+ gate(): CircuitState;
44
+ /** Record an attempt outcome. Releases an outstanding half-open probe and drives transitions. */
45
+ record(success: boolean): void;
46
+ /** For metrics export — gauge value 0=closed, 1=open, 2=half-open (O2). Non-consuming. */
47
+ metricValue(): 0 | 1 | 2;
48
+ }
49
+ //# sourceMappingURL=circuit-breaker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"circuit-breaker.d.ts","sourceRoot":"","sources":["../../../src/features/webhooks/circuit-breaker.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,qBAAqB;IACpC,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,sGAAsG;IACtG,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,wDAAwD;IACxD,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAC;AAE3D,qBAAa,cAAc;;gBAWb,IAAI,EAAE,qBAAqB;IAevC;;;OAGG;IACH,IAAI,IAAI,YAAY;IAKpB;;;;OAIG;IACH,IAAI,IAAI,YAAY;IAapB,iGAAiG;IACjG,MAAM,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IA0B9B,0FAA0F;IAC1F,WAAW,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;CAIzB"}
@@ -0,0 +1,16 @@
1
+ import type { Entry } from "../../core/config/schema.ts";
2
+ import type { CompiledWebhookSpec } from "./types.ts";
3
+ /**
4
+ * Compile webhook specs for every entry that declares them. Returns a map keyed
5
+ * by entry id so the dispatcher can look up the matched mock's webhooks in O(1).
6
+ *
7
+ * Body templating handles two shapes:
8
+ * - string body: compiled directly (whole-string rendering)
9
+ * - object/array body: serialised once at compile time with placeholder tokens
10
+ * intact, then compileTemplate'd as a string. This is sufficient for v0.x;
11
+ * it loses type-preservation for JSON bodies (numbers in templates render
12
+ * as strings) but matches T7's stated reuse of the existing engine.
13
+ * Type-preserving JSON bodies (renderCompiledJson) can be added later.
14
+ */
15
+ export declare function compileWebhookSpecs(entries: readonly Entry[]): Map<string, readonly CompiledWebhookSpec[]>;
16
+ //# sourceMappingURL=compile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../../src/features/webhooks/compile.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAgB,MAAM,6BAA6B,CAAC;AAEvE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,SAAS,KAAK,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,SAAS,mBAAmB,EAAE,CAAC,CAQ1G"}
@@ -0,0 +1,45 @@
1
+ import type { Metrics } from "../../core/observability/metrics.ts";
2
+ import type { TemplateContext } from "../../core/templating/index.ts";
3
+ import type { CircuitBreaker } from "./circuit-breaker.ts";
4
+ import type { DeliveryEventRegistry } from "./event-registry.ts";
5
+ import type { WebhookJournalRegistry } from "./journal.ts";
6
+ import type { BoundedRetryQueue } from "./queue.ts";
7
+ import type { CompiledWebhookSpec } from "./types.ts";
8
+ export interface DispatcherDeps {
9
+ metrics: Metrics;
10
+ journal: WebhookJournalRegistry;
11
+ events: DeliveryEventRegistry;
12
+ /** Per-tenant queue. Created lazily on first webhook for a tenant. */
13
+ queueForTenant: (tenant: string) => BoundedRetryQueue;
14
+ /** Per-webhook circuit breaker. Created lazily; keyed (tenant, webhookId). */
15
+ circuitFor: (tenant: string, webhookId: string, spec: CompiledWebhookSpec) => CircuitBreaker;
16
+ /** Server-level flag: --allow-webhook-url-header (B5, TN5). When false, header URL is ignored. */
17
+ allowWebhookUrlHeader: boolean;
18
+ }
19
+ export interface DispatcherTriggerInput {
20
+ tenant: string;
21
+ /** The triggering inbound request's path — used for the admin-skip check. */
22
+ matchPath: string;
23
+ /** The inbound request id (RT-15 — links inbound request to outbound deliveries). */
24
+ triggerRequestId: string;
25
+ /** Mock-entry id whose match scheduled these webhooks (used for journal entry → spec lookup at replay time, INT-2). */
26
+ entryId: string;
27
+ /** Webhook specs attached to the matched mock entry (post-config-load compiled form). */
28
+ webhooks: readonly CompiledWebhookSpec[];
29
+ /** Templating context for rendering URL/body/headers — same shape as response rendering. */
30
+ templateContext: TemplateContext;
31
+ /** Inbound headers, lowercased — for the optional X-Mockstar-Webhook-Url override. */
32
+ requestHeaders: ReadonlyMap<string, string>;
33
+ /** True when this dispatch was triggered by an admin /replay call rather than an inbound match. */
34
+ replay?: boolean;
35
+ }
36
+ /**
37
+ * Schedule deliveries for all webhooks attached to a matched mock entry.
38
+ *
39
+ * Called from server.ts INSIDE the post-response queueMicrotask block, so this
40
+ * function NEVER adds latency to the served-request flush path (T4).
41
+ *
42
+ * Returns the deliveryIds enqueued — useful for tests that want to await specific deliveries.
43
+ */
44
+ export declare function dispatchWebhooks(deps: DispatcherDeps, input: DispatcherTriggerInput): readonly string[];
45
+ //# sourceMappingURL=dispatcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatcher.d.ts","sourceRoot":"","sources":["../../../src/features/webhooks/dispatcher.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEtE,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 @@
1
+ import type { DeliverySummary } from "./types.ts";
2
+ /**
3
+ * Promise-registry for delivery terminal-state subscription.
4
+ *
5
+ * Why a Map<id, Deferred> rather than EventEmitter:
6
+ * - Single-subscriber-per-id semantics (one await call per deliveryId).
7
+ * - Terminal-once: each delivery resolves exactly one outcome.
8
+ * - No leakage risk from forgotten subscribers — the registry self-cleans on resolve.
9
+ *
10
+ * Late subscriber handling:
11
+ * - If the delivery already terminated before await(deliveryId) is called,
12
+ * we keep the summary in #completed for a short retention window (default 60s).
13
+ * This handles the natural test pattern: trigger request returns, then test
14
+ * calls /webhooks/await — without retention, fast deliveries would race past
15
+ * the await and never resolve.
16
+ */
17
+ export interface DeliveryEventRegistryOptions {
18
+ /** How long to retain terminal summaries for late subscribers. Default: 60_000ms. */
19
+ retentionMs?: number;
20
+ }
21
+ export declare class DeliveryEventRegistry {
22
+ #private;
23
+ constructor(opts?: DeliveryEventRegistryOptions);
24
+ /**
25
+ * Subscribe to a delivery's terminal-state. Resolves with the summary or null on timeout.
26
+ * If the delivery already terminated within the retention window, resolves immediately.
27
+ */
28
+ await(deliveryId: string, timeoutMs: number): Promise<DeliverySummary | null>;
29
+ /** Called by the queue when a delivery reaches a terminal state. */
30
+ publish(summary: DeliverySummary): void;
31
+ /** Test-helper: number of awaiters currently waiting. */
32
+ pendingCount(): number;
33
+ /** Test-helper: number of cached terminal summaries. */
34
+ completedCount(): number;
35
+ }
36
+ //# sourceMappingURL=event-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-registry.d.ts","sourceRoot":"","sources":["../../../src/features/webhooks/event-registry.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,4BAA4B;IAC3C,qFAAqF;IACrF,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAUD,qBAAa,qBAAqB;;gBAKpB,IAAI,GAAE,4BAAiC;IAInD;;;OAGG;IACG,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;IAwBnF,oEAAoE;IACpE,OAAO,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;IAwBvC,yDAAyD;IACzD,YAAY,IAAI,MAAM;IAItB,wDAAwD;IACxD,cAAc,IAAI,MAAM;CAGzB"}
@@ -0,0 +1,13 @@
1
+ export type { CompiledWebhookSpec, WebhookSigningSpec, WebhookRetrySpec, WebhookCircuitSpec, WebhookExpectSpec, WebhookJournalEntry, DeliveryOutcome, DeliverySummary, } from "./types.ts";
2
+ export { BoundedRetryQueue } from "./queue.ts";
3
+ export type { QueuedDelivery, BoundedRetryQueueOptions, AttemptRecord } from "./queue.ts";
4
+ export { CircuitBreaker } from "./circuit-breaker.ts";
5
+ export type { CircuitBreakerOptions, CircuitState } from "./circuit-breaker.ts";
6
+ export { DeliveryEventRegistry } from "./event-registry.ts";
7
+ export type { DeliveryEventRegistryOptions } from "./event-registry.ts";
8
+ export { WebhookJournalRegistry } from "./journal.ts";
9
+ export type { WebhookJournalOptions } from "./journal.ts";
10
+ export { dispatchWebhooks } from "./dispatcher.ts";
11
+ export type { DispatcherDeps, DispatcherTriggerInput } from "./dispatcher.ts";
12
+ export { signPayload, verifySignature, withinReplayWindow, resolveSecret } from "./signing.ts";
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/features/webhooks/index.ts"],"names":[],"mappings":"AAIA,YAAY,EACV,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EACf,eAAe,GAChB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,YAAY,EAAE,cAAc,EAAE,wBAAwB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE1F,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,YAAY,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEhF,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,YAAY,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAExE,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,YAAY,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAE1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,YAAY,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAE9E,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,32 @@
1
+ import type { WebhookJournalEntry } from "./types.ts";
2
+ export interface WebhookJournalOptions {
3
+ /**
4
+ * Optional path for an append-only JSONL log (INT-1). When set, every record() call
5
+ * synchronously appends `JSON.stringify(entry) + "\n"`. Loss model: at most the
6
+ * last attempt if the process is killed mid-syscall — acceptable for a mock server,
7
+ * not acceptable for a production broker (which Mockstar isn't claiming to be).
8
+ *
9
+ * Typical use: post-restart forensic replay via `cat <file> | jq` or a future
10
+ * `mockstar webhooks replay-file` subcommand.
11
+ */
12
+ journalFile?: string;
13
+ }
14
+ /**
15
+ * Per-tenant ring buffer of webhook delivery attempts.
16
+ *
17
+ * Why a sibling registry (not a discriminated journal entry on the existing
18
+ * RingBuffer<JournalEntry>): the request-side JournalEntry is request-shaped
19
+ * (method, path, status, matchedMockId, …); webhook rows are delivery-shaped
20
+ * (deliveryId, attempt, outcome, …). Mixing them as a discriminated union would
21
+ * push every consumer of the request journal to handle a 'kind' field that
22
+ * never existed before. A sibling registry has zero ripple cost.
23
+ */
24
+ export declare class WebhookJournalRegistry {
25
+ #private;
26
+ constructor(capacityFor: (tenant: string) => number, opts?: WebhookJournalOptions);
27
+ record(entry: WebhookJournalEntry): void;
28
+ snapshot(tenant: string): readonly WebhookJournalEntry[];
29
+ /** Look up the most recent entry for a deliveryId — used by the replay endpoint (O4). */
30
+ findLatestByDeliveryId(tenant: string, deliveryId: string): WebhookJournalEntry | null;
31
+ }
32
+ //# sourceMappingURL=journal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"journal.d.ts","sourceRoot":"","sources":["../../../src/features/webhooks/journal.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD,MAAM,WAAW,qBAAqB;IACpC;;;;;;;;OAQG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;GASG;AACH,qBAAa,sBAAsB;;gBAKrB,WAAW,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,EAAE,IAAI,GAAE,qBAA0B;IAKrF,MAAM,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI;IAiBxC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,mBAAmB,EAAE;IAMxD,yFAAyF;IACzF,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,mBAAmB,GAAG,IAAI;CAkBvF"}
@@ -0,0 +1,93 @@
1
+ import type { DeliveryOutcome, DeliverySummary } from "./types.ts";
2
+ /**
3
+ * One delivery as the queue sees it. The queue does NOT know how to make HTTP calls,
4
+ * sign, or render templates — the dispatcher hands in an `attempt` closure and a
5
+ * terminal-state callback. This keeps the queue pure FIFO + retry mechanics.
6
+ */
7
+ export interface QueuedDelivery {
8
+ /** Stable id, identical across all retry attempts of one delivery (B3 idempotency). */
9
+ deliveryId: string;
10
+ /** Tenant this delivery belongs to. Each tenant has its own BoundedRetryQueue instance (per-tenant isolation). */
11
+ tenant: string;
12
+ /** Webhook config id (mock-entry id) for journal/metrics labelling. */
13
+ webhookId: string;
14
+ /** Inbound request id that triggered the delivery — captured at schedule time (U4, RT-15). */
15
+ triggerRequestId: string;
16
+ /** Single delivery attempt. Throws on transient failure (caught and retried). */
17
+ attempt: () => Promise<{
18
+ httpStatus: number;
19
+ durationUs: number;
20
+ resolvedUrl: string;
21
+ }>;
22
+ /** Retry config: explicit backoff ladder; length = attempts - 1. */
23
+ retry: {
24
+ attempts: number;
25
+ backoff: readonly number[];
26
+ jitterRatio: number;
27
+ };
28
+ /** Per-attempt callback for journalling/metrics — fires for EVERY attempt, terminal or not. */
29
+ onAttempt: (record: AttemptRecord) => void;
30
+ /** Terminal-state callback — fires exactly once per delivery, for the await endpoint (RT-14). */
31
+ onTerminal: (summary: DeliverySummary) => void;
32
+ /** Circuit gate — checked before each HTTP attempt; if it returns 'open', delivery short-circuits (O3). */
33
+ circuitGate: () => "closed" | "open" | "half-open";
34
+ /** Attempt success/failure feeds back into the circuit. */
35
+ recordCircuitOutcome: (success: boolean) => void;
36
+ }
37
+ export interface AttemptRecord {
38
+ attempt: number;
39
+ outcome: DeliveryOutcome;
40
+ httpStatus?: number;
41
+ durationUs: number;
42
+ resolvedUrl?: string;
43
+ error?: string;
44
+ }
45
+ export interface BoundedRetryQueueOptions {
46
+ /** Max simultaneous in-flight deliveries for this tenant. Default: 8. */
47
+ concurrency: number;
48
+ /** Total cap (waiting + in-flight). Default: 1024 (O1). */
49
+ cap: number;
50
+ /** Counter increment hook — wired to Metrics.incCounter for observability (O2). */
51
+ onDropped?: (dropped: QueuedDelivery) => void;
52
+ /**
53
+ * Fires AFTER every state mutation that could change `size()` — enqueue, drop,
54
+ * waiting→inflight transition, terminal completion. Receiver sees the post-mutation
55
+ * size. Used by the dispatcher to keep the `webhook_queue_depth` gauge in sync
56
+ * with reality (instead of sampling only at enqueue time).
57
+ */
58
+ onSizeChange?: (size: number) => void;
59
+ }
60
+ /**
61
+ * Per-tenant bounded retry queue.
62
+ *
63
+ * Why a wrapper around p-queue and not p-queue alone:
64
+ * - p-queue caps in-flight (`concurrency`) but its internal queue is UNBOUNDED.
65
+ * - O1 demands a total depth cap with drop-oldest eviction on overflow.
66
+ * - p-queue does not expose its internal queue for eviction.
67
+ * - So we maintain our own FIFO (#waiting) and only push tasks to p-queue
68
+ * when there is in-flight slack — meaning p-queue's internal queue stays
69
+ * empty in steady state. Eviction happens on OUR FIFO before delegation.
70
+ *
71
+ * Drop semantics (TN2 resolution):
72
+ * - Evicted entries' onTerminal fires with outcome:'dropped' (DOES NOT reject).
73
+ * This preserves the await endpoint's terminal-state contract: every delivery
74
+ * terminates via the same callback path. The await endpoint never has to
75
+ * try/catch — every terminal state is `resolve()`-shaped.
76
+ */
77
+ export declare class BoundedRetryQueue {
78
+ #private;
79
+ constructor(opts?: Partial<BoundedRetryQueueOptions>);
80
+ /** Total deliveries occupying a slot (waiting + in-flight). */
81
+ size(): number;
82
+ /** Count of waiting (not yet dispatched) deliveries. */
83
+ waiting(): number;
84
+ /** Count of in-flight (currently executing) deliveries. */
85
+ inflight(): number;
86
+ /**
87
+ * Enqueue a delivery. If queue is at cap, evict OLDEST waiting entries first
88
+ * (resolved with outcome:'dropped'). If still no slack — i.e. cap entries are
89
+ * all in-flight — the new entry itself drops (we cannot abort in-flight tasks).
90
+ */
91
+ enqueue(req: QueuedDelivery): void;
92
+ }
93
+ //# sourceMappingURL=queue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../../src/features/webhooks/queue.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEnE;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,uFAAuF;IACvF,UAAU,EAAE,MAAM,CAAC;IACnB,kHAAkH;IAClH,MAAM,EAAE,MAAM,CAAC;IACf,uEAAuE;IACvE,SAAS,EAAE,MAAM,CAAC;IAClB,8FAA8F;IAC9F,gBAAgB,EAAE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C,wBAAwB,CAAM;IAkBxD,+DAA+D;IAC/D,IAAI,IAAI,MAAM;IAId,wDAAwD;IACxD,OAAO,IAAI,MAAM;IAIjB,2DAA2D;IAC3D,QAAQ,IAAI,MAAM;IAIlB;;;;OAIG;IACH,OAAO,CAAC,GAAG,EAAE,cAAc,GAAG,IAAI;CA0InC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Sign a webhook payload.
3
+ *
4
+ * The signed string is `${timestamp}.${rawBody}` (Stripe's pattern). Receivers
5
+ * verify by reconstructing this string with the timestamp from the header,
6
+ * computing HMAC-SHA256 with the shared secret, and comparing constant-time.
7
+ *
8
+ * Replay-window enforcement is the receiver's responsibility — but we emit the
9
+ * timestamp so they CAN enforce it. Our default replay window in WebhookSigningSpec
10
+ * is 300_000ms (5 minutes), matching industry default.
11
+ */
12
+ export declare function signPayload(rawBody: string, secret: string, timestampMs: number): string;
13
+ /**
14
+ * Verify a signature constant-time. Used by tests; receivers will implement
15
+ * equivalent logic in their own language. Exposed so tests against this module
16
+ * can verify what we sent matches what we documented (S1 + RT-2 evidence).
17
+ *
18
+ * Returns false on length mismatch or timing-safe-compare miss. Never throws.
19
+ */
20
+ export declare function verifySignature(rawBody: string, secret: string, timestampMs: number, signatureHex: string): boolean;
21
+ /** Replay-window check helper — returns false if `timestampMs` is outside `[now - windowMs, now + skewMs]`. */
22
+ export declare function withinReplayWindow(timestampMs: number, windowMs: number, nowMs?: number, futureSkewMs?: number): boolean;
23
+ /**
24
+ * Resolve a `secretRef` string to the actual secret material.
25
+ *
26
+ * Accepted forms (S3 — strict):
27
+ * - `{{ env.NAME }}` — read process.env.NAME at delivery time (not config-load)
28
+ * - `file:/absolute/path` — read file content (trimmed) at delivery time
29
+ *
30
+ * Inline strings are REJECTED at config validation time (Zod refine, see schema.ts).
31
+ * This function should never see an inline string in practice; if it does, it
32
+ * throws so the failure is loud rather than silently signing with the literal.
33
+ */
34
+ export declare function resolveSecret(secretRef: string): string;
35
+ //# sourceMappingURL=signing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signing.d.ts","sourceRoot":"","sources":["../../../src/features/webhooks/signing.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAGxF;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,GACnB,OAAO,CAST;AAED,+GAA+G;AAC/G,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,KAAK,GAAE,MAAmB,EAC1B,YAAY,SAAS,GACpB,OAAO,CAGT;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAsBvD"}
@@ -0,0 +1,96 @@
1
+ import type { CompiledTemplate } from "../../core/templating/index.ts";
2
+ /** Terminal outcome of a delivery — every delivery resolves to exactly one of these. */
3
+ export type DeliveryOutcome = "success" | "failed" | "dropped" | "circuit-open";
4
+ /** Signing config for a single webhook. Off unless explicitly enabled (S1). */
5
+ export interface WebhookSigningSpec {
6
+ enabled: boolean;
7
+ /** Algorithm — only sha256 supported in v0.x. */
8
+ algorithm: "sha256";
9
+ /** Secret reference: must be `{{ env.NAME }}` form OR a file:// path. Inline strings rejected at config load (S3). */
10
+ secretRef: string;
11
+ /** Header carrying the hex signature. Default: x-mockstar-signature. */
12
+ signatureHeader: string;
13
+ /** Header carrying the unix-millis timestamp. Default: x-mockstar-timestamp. */
14
+ timestampHeader: string;
15
+ /** Replay window in ms. Default: 300_000 (5 minutes). Receiver should check timestamp delta. */
16
+ replayWindowMs: number;
17
+ }
18
+ /** Retry config — explicit backoff array preferred (T3 default: [1000,2000,4000,8000,16000,32000]). */
19
+ export interface WebhookRetrySpec {
20
+ attempts: number;
21
+ backoff: readonly number[];
22
+ jitterRatio: number;
23
+ }
24
+ /** Circuit-breaker tunables per webhook (O3). */
25
+ export interface WebhookCircuitSpec {
26
+ failureThreshold: number;
27
+ cooldownMs: number;
28
+ }
29
+ /** Optional response assertion — only matching responses count as success (U2). */
30
+ export interface WebhookExpectSpec {
31
+ status?: number | readonly number[];
32
+ body?: unknown;
33
+ }
34
+ /**
35
+ * Compiled webhook spec — all template strings pre-compiled at config-load time
36
+ * (mirroring the response compilation pattern; on the hot path we only render).
37
+ *
38
+ * Satisfies: T5 (per-route shape), T7 (template reuse via CompiledTemplate), S3 (secret-ref is a template),
39
+ * U2 (expectResponse), B5 (acceptHeaderOverride flag landed here)
40
+ */
41
+ export interface CompiledWebhookSpec {
42
+ id: string;
43
+ /** Compiled URL template — re-rendered each attempt (per-attempt URL re-validation, S2). */
44
+ urlTemplate: CompiledTemplate;
45
+ method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
46
+ /** Compiled body template OR a JSON tree with leaf templates (T7). null = no body (GET/HEAD). */
47
+ body: CompiledTemplate | null;
48
+ /** Compiled header values; keys are lowercased. */
49
+ headers: ReadonlyMap<string, CompiledTemplate>;
50
+ retry: WebhookRetrySpec;
51
+ signing: WebhookSigningSpec | null;
52
+ circuit: WebhookCircuitSpec;
53
+ expectResponse: WebhookExpectSpec | null;
54
+ timeoutMs: number;
55
+ allowHttp: boolean;
56
+ allowPrivateNetworks: boolean;
57
+ acceptHeaderOverride: boolean;
58
+ }
59
+ /**
60
+ * Single attempt record stored in the per-tenant webhook journal (RT-11).
61
+ * Mirrors the request-journal shape but discriminated as kind: 'webhook'.
62
+ */
63
+ export interface WebhookJournalEntry {
64
+ kind: "webhook";
65
+ timestamp: number;
66
+ tenant: string;
67
+ /** Stable per-delivery id; same value across all retry attempts of one delivery (B3 idempotency). */
68
+ deliveryId: string;
69
+ /** Mock-entry id (NOT the WebhookSpec.id) — used by replay to relocate the spec in the current snapshot. */
70
+ entryId: string;
71
+ /** WebhookSpec.id within the mock entry's webhooks[] array. */
72
+ webhookId: string;
73
+ /** Inbound request id that triggered the delivery (U4 linkage; RT-15). */
74
+ triggerRequestId: string;
75
+ /** 1-indexed attempt counter; final entry has attempt === total. */
76
+ attempt: number;
77
+ outcome: DeliveryOutcome;
78
+ /** HTTP status from the receiver — undefined for outcomes 'dropped' / 'circuit-open' / network errors. */
79
+ httpStatus?: number;
80
+ durationUs: number;
81
+ /** Resolved URL for this attempt (templates rendered). Surface for debug/replay. */
82
+ resolvedUrl?: string;
83
+ /** Short error description for failed attempts; never includes secret material. */
84
+ error?: string;
85
+ /** True when this entry was emitted by an admin /replay trigger rather than an inbound match. */
86
+ replay?: boolean;
87
+ }
88
+ /** Summary delivered to the await endpoint and event-registry subscribers (U1). */
89
+ export interface DeliverySummary {
90
+ deliveryId: string;
91
+ outcome: DeliveryOutcome;
92
+ totalAttempts: number;
93
+ lastHttpStatus?: number;
94
+ totalDurationUs: number;
95
+ }
96
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/features/webhooks/types.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAEvE,wFAAwF;AACxF,MAAM,MAAM,eAAe,GACvB,SAAS,GACT,QAAQ,GACR,SAAS,GACT,cAAc,CAAC;AAEnB,+EAA+E;AAC/E,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,iDAAiD;IACjD,SAAS,EAAE,QAAQ,CAAC;IACpB,sHAAsH;IACtH,SAAS,EAAE,MAAM,CAAC;IAClB,wEAAwE;IACxE,eAAe,EAAE,MAAM,CAAC;IACxB,gFAAgF;IAChF,eAAe,EAAE,MAAM,CAAC;IACxB,gGAAgG;IAChG,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,uGAAuG;AACvG,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,+DAA+D;IAC/D,SAAS,EAAE,MAAM,CAAC;IAClB,0EAA0E;IAC1E,gBAAgB,EAAE,MAAM,CAAC;IACzB,oEAAoE;IACpE,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,eAAe,CAAC;IACzB,0GAA0G;IAC1G,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,oFAAoF;IACpF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mFAAmF;IACnF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iGAAiG;IACjG,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,mFAAmF;AACnF,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,eAAe,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;CACzB"}
@@ -0,0 +1,30 @@
1
+ import { SnapshotHolder } from "./core/config/index.ts";
2
+ import { type StructuredLogger } from "./core/observability/index.ts";
3
+ import { type RunningServer } from "./server.ts";
4
+ export interface LaunchOptions {
5
+ configRoot: string;
6
+ handlersDir?: string;
7
+ server?: Record<string, unknown>;
8
+ deterministic?: boolean;
9
+ logger?: StructuredLogger;
10
+ installCrashHandlers?: boolean;
11
+ watch?: boolean;
12
+ handlerTimeoutMs?: number;
13
+ /** B5/TN5: honour X-Mockstar-Webhook-Url request header. Default false. */
14
+ allowWebhookUrlHeader?: boolean;
15
+ /** INT-1: optional JSONL append-only log of webhook deliveries (post-restart forensic replay). */
16
+ webhookJournalFile?: string;
17
+ }
18
+ export interface Launched {
19
+ readonly server: RunningServer;
20
+ readonly stop: () => Promise<void>;
21
+ readonly holder: SnapshotHolder;
22
+ }
23
+ /**
24
+ * Bootstrap a Mockstar instance. Returns the composed Hono app plus a `stop()`
25
+ * to tear down watchers and handlers.
26
+ */
27
+ export declare function launch(opts: LaunchOptions): Promise<Launched>;
28
+ export type { RunningServer, CreateServerOptions } from "./server.ts";
29
+ export { SnapshotHolder } from "./core/config/index.ts";
30
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAiD,MAAM,wBAAwB,CAAC;AAEvG,OAAO,EAAE,KAAK,gBAAgB,EAAgB,MAAM,+BAA+B,CAAC;AAEpF,OAAO,EAA4B,KAAK,aAAa,EAAgB,MAAM,aAAa,CAAC;AAEzF,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,2EAA2E;IAC3E,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,kGAAkG;IAClG,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;CACjC;AAED;;;GAGG;AACH,wBAAsB,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,QAAQ,CAAC,CAmDnE;AAED,YAAY,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC"}