@schmock/cli 2.4.1 → 2.5.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/admin.d.ts +41 -0
- package/dist/args.d.ts +17 -0
- package/dist/bin.d.ts +0 -1
- package/dist/bin.js +492 -418
- package/dist/cli.d.ts +4 -73
- package/dist/cors.d.ts +30 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +492 -418
- package/dist/request.d.ts +38 -0
- package/dist/seed-manifest.d.ts +15 -0
- package/dist/server.d.ts +14 -0
- package/dist/types.d.ts +28 -0
- package/dist/watch.d.ts +46 -0
- package/package.json +5 -5
- package/dist/bin.d.ts.map +0 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
package/dist/cli.d.ts
CHANGED
|
@@ -1,74 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
port?: number;
|
|
6
|
-
hostname?: string;
|
|
7
|
-
seed?: string;
|
|
8
|
-
cors?: boolean;
|
|
9
|
-
debug?: boolean;
|
|
10
|
-
fakerSeed?: number;
|
|
11
|
-
errors?: boolean;
|
|
12
|
-
watch?: boolean;
|
|
13
|
-
admin?: boolean;
|
|
14
|
-
/**
|
|
15
|
-
* Bearer token required by every `/schmock-admin/*` request (`--admin-token`).
|
|
16
|
-
* When `admin` is on and this is omitted, a random token is minted once and
|
|
17
|
-
* surfaced on {@link CliServer.adminToken}.
|
|
18
|
-
*/
|
|
19
|
-
adminToken?: string;
|
|
20
|
-
/**
|
|
21
|
-
* How many requests the mock retains for `GET /schmock-admin/history`
|
|
22
|
-
* (`--admin-history-limit`, default 500). Ignored — history is disabled
|
|
23
|
-
* entirely — when `admin` is off.
|
|
24
|
-
*/
|
|
25
|
-
adminHistoryLimit?: number;
|
|
26
|
-
/** Validate the spec against the OpenAPI schema at startup (`--strict`). */
|
|
27
|
-
strict?: boolean;
|
|
28
|
-
/** Resolve `$ref`s outside the spec document (`--refs-external`). */
|
|
29
|
-
refsExternal?: boolean;
|
|
30
|
-
/**
|
|
31
|
-
* Hosts an `http(s)` `$ref` may target (`--refs-allow-http`). Supplying this
|
|
32
|
-
* also enables http resolution, which still requires `refsExternal`.
|
|
33
|
-
*/
|
|
34
|
-
refsAllowHttp?: string[];
|
|
35
|
-
/**
|
|
36
|
-
* How long {@link CliServer.close} waits for in-flight requests before the
|
|
37
|
-
* remaining sockets are destroyed (default 5000 ms). A half-sent request
|
|
38
|
-
* never completes on its own, so without a bound the close would hang.
|
|
39
|
-
*/
|
|
40
|
-
shutdownGraceMs?: number;
|
|
41
|
-
}
|
|
42
|
-
export interface CliServer {
|
|
43
|
-
server: Server;
|
|
44
|
-
port: number;
|
|
45
|
-
hostname: string;
|
|
46
|
-
/**
|
|
47
|
-
* The bearer token this server requires on `/schmock-admin/*`. Present only
|
|
48
|
-
* when admin is enabled; supply it as `Authorization: Bearer <token>`.
|
|
49
|
-
*/
|
|
50
|
-
adminToken?: string;
|
|
51
|
-
/**
|
|
52
|
-
* Stop watching, stop accepting, and settle once the socket is released —
|
|
53
|
-
* within {@link CliOptions.shutdownGraceMs}. Memoized: every call observes
|
|
54
|
-
* the same shutdown, so closing twice is safe and resolves twice.
|
|
55
|
-
*/
|
|
56
|
-
close(): Promise<void>;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Read a `--seed` manifest.
|
|
60
|
-
*
|
|
61
|
-
* Every entry shape is checked explicitly and anything unrecognised throws:
|
|
62
|
-
* silently dropping a malformed entry used to start a server whose collections
|
|
63
|
-
* were quietly empty. File entries resolve relative to the manifest rather than
|
|
64
|
-
* the process CWD, and may not escape the manifest directory.
|
|
65
|
-
*/
|
|
66
|
-
export declare function loadSeedFile(seedPath: string): Schmock.SeedConfig;
|
|
67
|
-
export declare function createCliServer(options: CliOptions): Promise<CliServer>;
|
|
68
|
-
/** Loopback binds are `127.0.0.0/8`, `::1` and `localhost`; everything else is reachable off-box. */
|
|
69
|
-
export declare function isLoopbackHost(hostname: string): boolean;
|
|
70
|
-
export declare function parseCliArgs(args: string[]): CliOptions & {
|
|
71
|
-
help: boolean;
|
|
72
|
-
};
|
|
1
|
+
export { isLoopbackHost, parseCliArgs } from "./args.js";
|
|
2
|
+
export { loadSeedFile } from "./seed-manifest.js";
|
|
3
|
+
export { createCliServer } from "./server.js";
|
|
4
|
+
export type { CliOptions, CliServer } from "./types.js";
|
|
73
5
|
export declare function run(args: string[]): Promise<void>;
|
|
74
|
-
//# sourceMappingURL=cli.d.ts.map
|
package/dist/cors.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type * as Schmock from "@schmock/core";
|
|
2
|
+
/**
|
|
3
|
+
* A request's raw headers, as Node delivers them. Structural rather than
|
|
4
|
+
* `IncomingMessage`, so it accepts the request whichever `@types/node` copy
|
|
5
|
+
* typed it.
|
|
6
|
+
*/
|
|
7
|
+
export interface HeaderSource {
|
|
8
|
+
readonly headers: {
|
|
9
|
+
readonly [header: string]: string | string[] | undefined;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A repeated header arrives as an array; treat that as "not presented" rather
|
|
14
|
+
* than joining it, so a duplicated `Authorization` cannot smuggle a token past
|
|
15
|
+
* the comparison.
|
|
16
|
+
*/
|
|
17
|
+
export declare function singleHeader(value: string | string[] | undefined): string | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* The CORS headers for one request. A dev-server convenience, not a policy:
|
|
20
|
+
* the origin is always `*`, which is why credentials are never allowed and no
|
|
21
|
+
* `Vary: Origin` is needed.
|
|
22
|
+
*/
|
|
23
|
+
export declare function corsHeadersFor(req: HeaderSource): Record<string, string>;
|
|
24
|
+
/**
|
|
25
|
+
* A browser preflight, as opposed to any other OPTIONS request: both `Origin`
|
|
26
|
+
* and `Access-Control-Request-Method` are present. Answering only these leaves
|
|
27
|
+
* a spec-declared `options` operation reachable, and keeps an unrouted path
|
|
28
|
+
* answering 404 instead of a misleading 204.
|
|
29
|
+
*/
|
|
30
|
+
export declare function isCorsPreflight(req: HeaderSource, method: Schmock.HttpMethod): boolean;
|
package/dist/index.d.ts
CHANGED