@dhaneshpurohit/mockstar 0.2.2 → 0.4.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/CHANGELOG.md +47 -0
- package/dist/cli.js +786 -178
- package/dist/core/config/schema.d.ts +486 -320
- package/dist/core/config/schema.d.ts.map +1 -1
- package/dist/core/http/body-cap.d.ts +37 -0
- package/dist/core/http/body-cap.d.ts.map +1 -0
- package/dist/core/http/rate-limit.d.ts +55 -0
- package/dist/core/http/rate-limit.d.ts.map +1 -0
- package/dist/core/matching/discriminators.d.ts +25 -0
- package/dist/core/matching/discriminators.d.ts.map +1 -1
- package/dist/core/matching/index.d.ts +3 -1
- package/dist/core/matching/index.d.ts.map +1 -1
- package/dist/features/openapi/converter.d.ts.map +1 -1
- package/dist/features/pass-through.d.ts +7 -0
- package/dist/features/pass-through.d.ts.map +1 -1
- package/dist/features/proxy/cli.d.ts +11 -0
- package/dist/features/proxy/cli.d.ts.map +1 -1
- package/dist/features/proxy/dns.d.ts +21 -3
- package/dist/features/proxy/dns.d.ts.map +1 -1
- package/dist/features/proxy/index.d.ts +1 -1
- package/dist/features/proxy/index.d.ts.map +1 -1
- package/dist/features/proxy/port-bind.d.ts +18 -1
- package/dist/features/proxy/port-bind.d.ts.map +1 -1
- package/dist/features/proxy/sni-gate.d.ts +4 -3
- package/dist/features/proxy/sni-gate.d.ts.map +1 -1
- package/dist/features/url-validator.d.ts +48 -0
- package/dist/features/url-validator.d.ts.map +1 -1
- package/dist/features/webhooks/dispatcher.d.ts.map +1 -1
- package/dist/features/webhooks/event-registry.d.ts +7 -0
- package/dist/features/webhooks/event-registry.d.ts.map +1 -1
- package/dist/features/webhooks/index.d.ts +3 -1
- package/dist/features/webhooks/index.d.ts.map +1 -1
- package/dist/features/webhooks/journal.d.ts +23 -0
- package/dist/features/webhooks/journal.d.ts.map +1 -1
- package/dist/features/webhooks/queue.d.ts +18 -0
- package/dist/features/webhooks/queue.d.ts.map +1 -1
- package/dist/features/webhooks/scheme.d.ts +46 -0
- package/dist/features/webhooks/scheme.d.ts.map +1 -0
- package/dist/features/webhooks/signing.d.ts +24 -13
- package/dist/features/webhooks/signing.d.ts.map +1 -1
- package/dist/features/webhooks/types.d.ts +32 -5
- package/dist/features/webhooks/types.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +628 -133
- package/dist/server.d.ts +17 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +2 -1
package/dist/server.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Hono } from "hono";
|
|
2
2
|
import type { SnapshotHolder } from "./core/config/snapshot.ts";
|
|
3
3
|
import type { HandlerRegistry } from "./core/handlers/index.ts";
|
|
4
|
+
import { TenantRateLimiter } from "./core/http/rate-limit.ts";
|
|
4
5
|
import { JournalRegistry } from "./core/journal/index.ts";
|
|
5
6
|
import { Metrics, type StructuredLogger } from "./core/observability/index.ts";
|
|
6
7
|
import { DeliveryEventRegistry, WebhookJournalRegistry } from "./features/webhooks/index.ts";
|
|
@@ -30,11 +31,19 @@ export interface CreateServerOptions {
|
|
|
30
31
|
allowWebhookUrlHeader?: boolean;
|
|
31
32
|
/** INT-1: optional JSONL append-only log of webhook delivery attempts. */
|
|
32
33
|
webhookJournalFile?: string;
|
|
34
|
+
/**
|
|
35
|
+
* S5 / #35: overridable time source for the per-tenant rate limiter (ms epoch). Defaults
|
|
36
|
+
* to `Date.now`. Test-only hook — lets the rate-limit test matrix advance the token-bucket
|
|
37
|
+
* window deterministically instead of relying on wall-clock sleeps.
|
|
38
|
+
*/
|
|
39
|
+
rateLimiterNow?: () => number;
|
|
33
40
|
}
|
|
34
41
|
export interface RunningServer {
|
|
35
42
|
readonly hono: Hono;
|
|
36
43
|
readonly journal: JournalRegistry;
|
|
37
44
|
readonly metrics: Metrics;
|
|
45
|
+
/** S5 / #35: per-tenant request-rate limiter. Exposed so tests can assert bucket count stays bounded (mirrors #34). */
|
|
46
|
+
readonly rateLimiter: TenantRateLimiter;
|
|
38
47
|
readonly ready: {
|
|
39
48
|
current: () => boolean;
|
|
40
49
|
set: (v: boolean) => void;
|
|
@@ -50,6 +59,14 @@ export interface RunningServer {
|
|
|
50
59
|
* fresh delivery. Returns the new deliveryId on success or an error code.
|
|
51
60
|
*/
|
|
52
61
|
readonly replayWebhook: (tenant: string, deliveryId: string) => ReplayResult;
|
|
62
|
+
/**
|
|
63
|
+
* Issue #40: stop every per-tenant webhook queue (cancels live backoff timers,
|
|
64
|
+
* settles any promise awaiting one, terminates never-run deliveries) AND the
|
|
65
|
+
* delivery-event registry (settles every pending `await()` caller with null).
|
|
66
|
+
* Called from `launch().stop()` so a library-embed test process never hangs on
|
|
67
|
+
* a webhook retry timer after the server it started has "stopped".
|
|
68
|
+
*/
|
|
69
|
+
readonly stopWebhooks: () => void;
|
|
53
70
|
}
|
|
54
71
|
export type ReplayResult = {
|
|
55
72
|
ok: true;
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAIA,OAAO,EAAgB,IAAI,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,KAAK,EAAkB,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEhF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAIA,OAAO,EAAgB,IAAI,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,KAAK,EAAkB,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEhF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAEhE,OAAO,EAAwB,iBAAiB,EAAuB,MAAM,2BAA2B,CAAC;AACzG,OAAO,EAAq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,GAAG,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;KAAE,CAAC;IACtE,QAAQ,CAAC,sBAAsB,EAAE,MAAM,IAAI,CAAC;IAC5C,0EAA0E;IAC1E,QAAQ,CAAC,cAAc,EAAE,sBAAsB,CAAC;IAChD,8EAA8E;IAC9E,QAAQ,CAAC,aAAa,EAAE,qBAAqB,CAAC;IAC9C;;;;OAIG;IACH,QAAQ,CAAC,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,KAAK,YAAY,CAAC;IAC7E;;;;;;OAMG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,IAAI,CAAC;CACnC;AAED,MAAM,MAAM,YAAY,GACpB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,GACnC;IACE,EAAE,EAAE,KAAK,CAAC;IACV,IAAI,EAAE,kBAAkB,GAAG,yBAAyB,GAAG,oBAAoB,GAAG,sBAAsB,CAAC;CACtG,CAAC;AAEN,wBAAgB,YAAY,CAAC,IAAI,EAAE,mBAAmB,GAAG,aAAa,CAqLrE"}
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const MOCKSTAR_VERSION = "0.
|
|
1
|
+
export declare const MOCKSTAR_VERSION = "0.4.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dhaneshpurohit/mockstar",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Bun-based mock server with static + dynamic mocking, JSON config, named JS handlers, pass-through, multi-tenancy, and test-data utilities.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"bench": "bun run bench/harness.ts",
|
|
40
40
|
"bench:proxy": "bun run bench/proxy.bench.ts",
|
|
41
41
|
"typecheck": "tsc --noEmit",
|
|
42
|
+
"verify": "bun run lint && bun run typecheck && bun run build && bun run test",
|
|
42
43
|
"lint": "bunx @biomejs/biome check src tests bench",
|
|
43
44
|
"format": "bunx @biomejs/biome format --write src tests bench"
|
|
44
45
|
},
|