@molecule/api-mock-server 1.0.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/LICENSE +115 -0
- package/README.md +853 -0
- package/dist/browser-guard.d.ts +2 -0
- package/dist/browser-guard.d.ts.map +1 -0
- package/dist/browser-guard.js +19 -0
- package/dist/browser-guard.js.map +1 -0
- package/dist/cli.d.ts +11 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +152 -0
- package/dist/cli.js.map +1 -0
- package/dist/fixtures/app-fixtures.d.ts +54 -0
- package/dist/fixtures/app-fixtures.d.ts.map +1 -0
- package/dist/fixtures/app-fixtures.js +601 -0
- package/dist/fixtures/app-fixtures.js.map +1 -0
- package/dist/fixtures/index.d.ts +9 -0
- package/dist/fixtures/index.d.ts.map +1 -0
- package/dist/fixtures/index.js +9 -0
- package/dist/fixtures/index.js.map +1 -0
- package/dist/fixtures/seed.d.ts +74 -0
- package/dist/fixtures/seed.d.ts.map +1 -0
- package/dist/fixtures/seed.js +112 -0
- package/dist/fixtures/seed.js.map +1 -0
- package/dist/fixtures/semantic-generator.d.ts +20 -0
- package/dist/fixtures/semantic-generator.d.ts.map +1 -0
- package/dist/fixtures/semantic-generator.js +539 -0
- package/dist/fixtures/semantic-generator.js.map +1 -0
- package/dist/fixtures/zod-walker.d.ts +34 -0
- package/dist/fixtures/zod-walker.d.ts.map +1 -0
- package/dist/fixtures/zod-walker.js +183 -0
- package/dist/fixtures/zod-walker.js.map +1 -0
- package/dist/index.d.ts +78 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +78 -0
- package/dist/index.js.map +1 -0
- package/dist/scanner/index.d.ts +6 -0
- package/dist/scanner/index.d.ts.map +1 -0
- package/dist/scanner/index.js +6 -0
- package/dist/scanner/index.js.map +1 -0
- package/dist/scanner/scanner.d.ts +21 -0
- package/dist/scanner/scanner.d.ts.map +1 -0
- package/dist/scanner/scanner.js +463 -0
- package/dist/scanner/scanner.js.map +1 -0
- package/dist/server/index.d.ts +7 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +7 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/middleware.d.ts +51 -0
- package/dist/server/middleware.d.ts.map +1 -0
- package/dist/server/middleware.js +124 -0
- package/dist/server/middleware.js.map +1 -0
- package/dist/server/server.d.ts +29 -0
- package/dist/server/server.d.ts.map +1 -0
- package/dist/server/server.js +314 -0
- package/dist/server/server.js.map +1 -0
- package/dist/states/index.d.ts +6 -0
- package/dist/states/index.d.ts.map +1 -0
- package/dist/states/index.js +6 -0
- package/dist/states/index.js.map +1 -0
- package/dist/states/states.d.ts +57 -0
- package/dist/states/states.d.ts.map +1 -0
- package/dist/states/states.js +89 -0
- package/dist/states/states.js.map +1 -0
- package/dist/types.d.ts +214 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/package.json +66 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configurable response states for the mock server.
|
|
3
|
+
* Provides standard response shapes for success, empty, error, and unauthorized states.
|
|
4
|
+
*/
|
|
5
|
+
/** Default response states for each scenario */
|
|
6
|
+
export const DEFAULT_STATES = {
|
|
7
|
+
success: { state: 'success' },
|
|
8
|
+
empty: { state: 'empty' },
|
|
9
|
+
error: { state: 'error', statusCode: 500 },
|
|
10
|
+
unauthorized: { state: 'unauthorized', statusCode: 401 },
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Get the HTTP status code for a given state and method.
|
|
14
|
+
* @param state - The response state
|
|
15
|
+
* @param method - The HTTP method
|
|
16
|
+
* @returns The appropriate HTTP status code
|
|
17
|
+
*/
|
|
18
|
+
export function getStatusCode(state, method) {
|
|
19
|
+
if (state.statusCode) {
|
|
20
|
+
return state.statusCode;
|
|
21
|
+
}
|
|
22
|
+
switch (state.state) {
|
|
23
|
+
case 'success':
|
|
24
|
+
if (method === 'POST')
|
|
25
|
+
return 201;
|
|
26
|
+
if (method === 'DELETE')
|
|
27
|
+
return 204;
|
|
28
|
+
return 200;
|
|
29
|
+
case 'empty':
|
|
30
|
+
return 200;
|
|
31
|
+
case 'error':
|
|
32
|
+
return 500;
|
|
33
|
+
case 'unauthorized':
|
|
34
|
+
return 401;
|
|
35
|
+
default:
|
|
36
|
+
return 200;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Get the response body for a given state, using the endpoint fixture data.
|
|
41
|
+
* @param state - The response state
|
|
42
|
+
* @param method - The HTTP method
|
|
43
|
+
* @param fixture - The fixture data containing success, empty, and error responses
|
|
44
|
+
* @param fixture.successResponse
|
|
45
|
+
* @param fixture.emptyResponse
|
|
46
|
+
* @param fixture.errorResponse
|
|
47
|
+
* @param fixture.errorResponse.error
|
|
48
|
+
* @returns The response body, or null for 204 responses
|
|
49
|
+
*/
|
|
50
|
+
export function getResponseBody(state, method, fixture) {
|
|
51
|
+
switch (state.state) {
|
|
52
|
+
case 'success':
|
|
53
|
+
if (method === 'DELETE')
|
|
54
|
+
return null;
|
|
55
|
+
return fixture.successResponse;
|
|
56
|
+
case 'empty':
|
|
57
|
+
return fixture.emptyResponse;
|
|
58
|
+
case 'error':
|
|
59
|
+
return fixture.errorResponse;
|
|
60
|
+
case 'unauthorized':
|
|
61
|
+
return { error: 'Unauthorized' };
|
|
62
|
+
default:
|
|
63
|
+
return fixture.successResponse;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Parse a state string into a ResponseState object.
|
|
68
|
+
* @param stateStr - The state string (e.g. 'success', 'error', 'empty', 'unauthorized')
|
|
69
|
+
* @returns The parsed ResponseState. An unrecognized string falls back to
|
|
70
|
+
* `DEFAULT_STATES.success` — the same forgiving behavior as the per-request
|
|
71
|
+
* `?_state` middleware (which additionally labels the response with an
|
|
72
|
+
* `X-Mock-Invalid-State` header so typos are detectable).
|
|
73
|
+
*/
|
|
74
|
+
export function parseState(stateStr) {
|
|
75
|
+
const normalized = stateStr.toLowerCase().trim();
|
|
76
|
+
switch (normalized) {
|
|
77
|
+
case 'success':
|
|
78
|
+
return DEFAULT_STATES.success;
|
|
79
|
+
case 'empty':
|
|
80
|
+
return DEFAULT_STATES.empty;
|
|
81
|
+
case 'error':
|
|
82
|
+
return DEFAULT_STATES.error;
|
|
83
|
+
case 'unauthorized':
|
|
84
|
+
return DEFAULT_STATES.unauthorized;
|
|
85
|
+
default:
|
|
86
|
+
return DEFAULT_STATES.success;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=states.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"states.js","sourceRoot":"","sources":["../../src/states/states.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,gDAAgD;AAChD,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,OAAO,EAAE,EAAE,KAAK,EAAE,SAAkB,EAAE;IACtC,KAAK,EAAE,EAAE,KAAK,EAAE,OAAgB,EAAE;IAClC,KAAK,EAAE,EAAE,KAAK,EAAE,OAAgB,EAAE,UAAU,EAAE,GAAG,EAAE;IACnD,YAAY,EAAE,EAAE,KAAK,EAAE,cAAuB,EAAE,UAAU,EAAE,GAAG,EAAE;CACzD,CAAA;AAEV;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,KAAoB,EAAE,MAAkB;IACpE,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC;QACrB,OAAO,KAAK,CAAC,UAAU,CAAA;IACzB,CAAC;IAED,QAAQ,KAAK,CAAC,KAAK,EAAE,CAAC;QACpB,KAAK,SAAS;YACZ,IAAI,MAAM,KAAK,MAAM;gBAAE,OAAO,GAAG,CAAA;YACjC,IAAI,MAAM,KAAK,QAAQ;gBAAE,OAAO,GAAG,CAAA;YACnC,OAAO,GAAG,CAAA;QAEZ,KAAK,OAAO;YACV,OAAO,GAAG,CAAA;QAEZ,KAAK,OAAO;YACV,OAAO,GAAG,CAAA;QAEZ,KAAK,cAAc;YACjB,OAAO,GAAG,CAAA;QAEZ;YACE,OAAO,GAAG,CAAA;IACd,CAAC;AACH,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,eAAe,CAC7B,KAAoB,EACpB,MAAkB,EAClB,OAIC;IAED,QAAQ,KAAK,CAAC,KAAK,EAAE,CAAC;QACpB,KAAK,SAAS;YACZ,IAAI,MAAM,KAAK,QAAQ;gBAAE,OAAO,IAAI,CAAA;YACpC,OAAO,OAAO,CAAC,eAAe,CAAA;QAEhC,KAAK,OAAO;YACV,OAAO,OAAO,CAAC,aAAa,CAAA;QAE9B,KAAK,OAAO;YACV,OAAO,OAAO,CAAC,aAAa,CAAA;QAE9B,KAAK,cAAc;YACjB,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,CAAA;QAElC;YACE,OAAO,OAAO,CAAC,eAAe,CAAA;IAClC,CAAC;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAC,QAAgB;IACzC,MAAM,UAAU,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAA;IAChD,QAAQ,UAAU,EAAE,CAAC;QACnB,KAAK,SAAS;YACZ,OAAO,cAAc,CAAC,OAAO,CAAA;QAC/B,KAAK,OAAO;YACV,OAAO,cAAc,CAAC,KAAK,CAAA;QAC7B,KAAK,OAAO;YACV,OAAO,cAAc,CAAC,KAAK,CAAA;QAC7B,KAAK,cAAc;YACjB,OAAO,cAAc,CAAC,YAAY,CAAA;QACpC;YACE,OAAO,cAAc,CAAC,OAAO,CAAA;IACjC,CAAC;AACH,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core type definitions for the mock API server.
|
|
3
|
+
* @module
|
|
4
|
+
*/
|
|
5
|
+
/** HTTP methods supported by the mock server */
|
|
6
|
+
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
7
|
+
/** Hints about the response shape extracted from handler analysis */
|
|
8
|
+
export interface ResponseHint {
|
|
9
|
+
/** Whether the response is an array (list endpoint) */
|
|
10
|
+
isList: boolean;
|
|
11
|
+
/** Whether the response is paginated ({ data, total, page, limit }) */
|
|
12
|
+
isPaginated: boolean;
|
|
13
|
+
/** Whether the response includes nested resources */
|
|
14
|
+
hasNestedResources: boolean;
|
|
15
|
+
/** Resource name (e.g. 'accounts', 'transactions') */
|
|
16
|
+
resourceName: string;
|
|
17
|
+
/**
|
|
18
|
+
* Whether the success response is a single bare object literal
|
|
19
|
+
* (`res.json({ a, b, c })`) rather than a list or `{ data: [] }`
|
|
20
|
+
* envelope — e.g. `/analytics/summary`, `/profile/me`. When true,
|
|
21
|
+
* `responseFields` holds its top-level keys.
|
|
22
|
+
*/
|
|
23
|
+
isSingleObject?: boolean;
|
|
24
|
+
/** Top-level field names of the success `res.json({...})` object, if extracted */
|
|
25
|
+
responseFields?: string[];
|
|
26
|
+
}
|
|
27
|
+
/** Serialized Zod schema definition for fixture generation */
|
|
28
|
+
export interface ZodSchemaDefinition {
|
|
29
|
+
/** Schema type name (e.g. 'ZodObject', 'ZodString') */
|
|
30
|
+
type: string;
|
|
31
|
+
/** Schema shape for objects: field name -> nested schema def */
|
|
32
|
+
shape?: Record<string, ZodSchemaDefinition>;
|
|
33
|
+
/** Enum values if applicable */
|
|
34
|
+
enumValues?: string[];
|
|
35
|
+
/** Default value if specified */
|
|
36
|
+
defaultValue?: unknown;
|
|
37
|
+
/** Inner type for optional/nullable wrappers */
|
|
38
|
+
innerType?: ZodSchemaDefinition;
|
|
39
|
+
/** Element type for arrays */
|
|
40
|
+
elementType?: ZodSchemaDefinition;
|
|
41
|
+
/** Constraints (min, max, positive, int, etc.) */
|
|
42
|
+
constraints?: {
|
|
43
|
+
min?: number;
|
|
44
|
+
max?: number;
|
|
45
|
+
positive?: boolean;
|
|
46
|
+
int?: boolean;
|
|
47
|
+
minLength?: number;
|
|
48
|
+
maxLength?: number;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/** A single discovered endpoint from handler scanning */
|
|
52
|
+
export interface EndpointDefinition {
|
|
53
|
+
/** HTTP method (GET, POST, PUT, DELETE) */
|
|
54
|
+
method: HttpMethod;
|
|
55
|
+
/** Full route path (e.g. '/accounts', '/accounts/:id', '/reports/net-worth') */
|
|
56
|
+
path: string;
|
|
57
|
+
/** Zod schema for request body (if any) */
|
|
58
|
+
bodySchema?: ZodSchemaDefinition;
|
|
59
|
+
/** Whether the endpoint requires authentication */
|
|
60
|
+
requiresAuth: boolean;
|
|
61
|
+
/** Expected response shape hints */
|
|
62
|
+
responseHints: ResponseHint;
|
|
63
|
+
}
|
|
64
|
+
/** Result of scanning all handlers for an app type */
|
|
65
|
+
export interface HandlerScanResult {
|
|
66
|
+
/** App type (e.g. 'personal-finance', 'online-store') */
|
|
67
|
+
appType: string;
|
|
68
|
+
/** All discovered endpoints */
|
|
69
|
+
endpoints: EndpointDefinition[];
|
|
70
|
+
/** Resource names discovered (accounts, transactions, etc.) */
|
|
71
|
+
resources: string[];
|
|
72
|
+
}
|
|
73
|
+
/** Configuration for fixture generation */
|
|
74
|
+
export interface FixtureConfig {
|
|
75
|
+
/** Number of items to generate for list endpoints */
|
|
76
|
+
listCount?: number;
|
|
77
|
+
/** Seed override (default: derived from app type + path) */
|
|
78
|
+
seed?: number;
|
|
79
|
+
/** App type for domain-specific data pools */
|
|
80
|
+
appType?: string;
|
|
81
|
+
}
|
|
82
|
+
/** A semantic rule for generating realistic values based on field names */
|
|
83
|
+
export interface SemanticRule {
|
|
84
|
+
/** Field name pattern (regex) */
|
|
85
|
+
pattern: RegExp;
|
|
86
|
+
/** Generator function that produces a realistic value */
|
|
87
|
+
generate: (rng: () => number, index: number) => unknown;
|
|
88
|
+
}
|
|
89
|
+
/** Fixture data for a single endpoint */
|
|
90
|
+
export interface EndpointFixture {
|
|
91
|
+
/** The endpoint definition */
|
|
92
|
+
endpoint: EndpointDefinition;
|
|
93
|
+
/** Success response body */
|
|
94
|
+
successResponse: unknown;
|
|
95
|
+
/** Empty state response body */
|
|
96
|
+
emptyResponse: unknown;
|
|
97
|
+
/** Error response */
|
|
98
|
+
errorResponse: {
|
|
99
|
+
error: string;
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/** Fixture set for an entire app type */
|
|
103
|
+
export interface AppFixtureSet {
|
|
104
|
+
/** App type name */
|
|
105
|
+
appType: string;
|
|
106
|
+
/** Endpoint key -> fixture data */
|
|
107
|
+
endpoints: Map<string, EndpointFixture>;
|
|
108
|
+
}
|
|
109
|
+
/** Response state for controlling mock behavior */
|
|
110
|
+
export interface ResponseState {
|
|
111
|
+
/** The state of the response */
|
|
112
|
+
state: 'success' | 'empty' | 'error' | 'unauthorized';
|
|
113
|
+
/**
|
|
114
|
+
* Additional delay in ms before responding. Clamped to `MAX_MOCK_DELAY_MS`
|
|
115
|
+
* (60s, see {@link applyDelay}) — an oversized value is capped and logged
|
|
116
|
+
* rather than honored verbatim, so it cannot hang a request indefinitely.
|
|
117
|
+
*/
|
|
118
|
+
delay?: number;
|
|
119
|
+
/** Custom status code override */
|
|
120
|
+
statusCode?: number;
|
|
121
|
+
}
|
|
122
|
+
/** Configuration for the mock HTTP server */
|
|
123
|
+
export interface MockServerConfig {
|
|
124
|
+
/** App type to serve fixtures for (used for display and handler resolution) */
|
|
125
|
+
appType: string;
|
|
126
|
+
/** Path to a directory of JSON fixture files (takes priority over appType for data) */
|
|
127
|
+
fixturesPath?: string;
|
|
128
|
+
/** Port to listen on (default 4000) */
|
|
129
|
+
port?: number;
|
|
130
|
+
/** Default response delay in ms (default 0) */
|
|
131
|
+
defaultDelay?: number;
|
|
132
|
+
/** Default state for all endpoints */
|
|
133
|
+
defaultState?: 'success' | 'empty' | 'error' | 'unauthorized';
|
|
134
|
+
/** Per-endpoint state overrides (key: "METHOD /path") */
|
|
135
|
+
endpointStates?: Record<string, ResponseState>;
|
|
136
|
+
/** Path to handler templates directory (auto-detected from appType) */
|
|
137
|
+
handlersPath?: string;
|
|
138
|
+
/** Custom fixture data to use instead of auto-generated */
|
|
139
|
+
customFixtures?: AppFixtureSet;
|
|
140
|
+
/** Whether to log requests (default true) */
|
|
141
|
+
logging?: boolean;
|
|
142
|
+
}
|
|
143
|
+
/** Running mock server instance with control methods */
|
|
144
|
+
export interface MockServer {
|
|
145
|
+
/** The port the server is listening on */
|
|
146
|
+
port: number;
|
|
147
|
+
/** The app type being served */
|
|
148
|
+
appType: string;
|
|
149
|
+
/**
|
|
150
|
+
* Set a persistent state override for one endpoint (key: `"METHOD /path"`,
|
|
151
|
+
* e.g. `'GET /accounts'` — the bare and `/api/`-prefixed forms are
|
|
152
|
+
* equivalent keys). This is the HIGHEST-priority source of state for that
|
|
153
|
+
* endpoint. Full per-request precedence (highest first):
|
|
154
|
+
*
|
|
155
|
+
* 1. `setState(endpointKey, ...)` (this method)
|
|
156
|
+
* 2. per-request `?_state` query param / `X-Mock-State` header
|
|
157
|
+
* 3. `setDefaultState(...)` / the server's configured `defaultState`
|
|
158
|
+
*
|
|
159
|
+
* So a forgotten `setState('GET /accounts', { state: 'error' })` left over
|
|
160
|
+
* from an earlier test SILENTLY beats every later `?_state=success` on
|
|
161
|
+
* that endpoint — the request looks like `?_state` is being ignored.
|
|
162
|
+
* **Calling `setState(key, { state: 'success' })` does NOT remove the
|
|
163
|
+
* override** — it replaces it with an override that happens to look like
|
|
164
|
+
* the default, but per-request `?_state`/`X-Mock-State` still can't reach
|
|
165
|
+
* that endpoint (the override still outranks them). Use
|
|
166
|
+
* {@link MockServer.clearState} to actually remove the override and hand
|
|
167
|
+
* control back to per-request/default state. `setDefaultState()` never
|
|
168
|
+
* clears endpoint overrides either — the default is only the fallback used
|
|
169
|
+
* when no endpoint override exists at all.
|
|
170
|
+
* @param endpointKey - `"METHOD /path"`, e.g. `'GET /accounts'`.
|
|
171
|
+
* @param state - The state this endpoint returns for every request until
|
|
172
|
+
* `setState` is called again, or `clearState`d, for the same key.
|
|
173
|
+
*/
|
|
174
|
+
setState: (endpointKey: string, state: ResponseState) => void;
|
|
175
|
+
/**
|
|
176
|
+
* Remove a persistent per-endpoint override previously set with
|
|
177
|
+
* {@link MockServer.setState}, restoring per-request `?_state`/
|
|
178
|
+
* `X-Mock-State` (and ultimately `setDefaultState()`) control over that
|
|
179
|
+
* endpoint. Pass the EXACT same key string used in the matching
|
|
180
|
+
* `setState()` call — keys are matched as opaque strings, not normalized,
|
|
181
|
+
* so `setState('GET /accounts', ...)` and `setState('GET /api/accounts',
|
|
182
|
+
* ...)` are independent overrides and each needs its own `clearState()`.
|
|
183
|
+
* Clearing a key with no active override is a harmless no-op.
|
|
184
|
+
* @param endpointKey - The same `"METHOD /path"` key passed to `setState`.
|
|
185
|
+
*/
|
|
186
|
+
clearState: (endpointKey: string) => void;
|
|
187
|
+
/**
|
|
188
|
+
* Set the fallback state used for any endpoint that has no per-endpoint
|
|
189
|
+
* `setState()` override — see {@link MockServer.setState} for the full
|
|
190
|
+
* precedence chain. A per-request `?_state`/`X-Mock-State` value still
|
|
191
|
+
* wins over this default; only an active `setState()` override outranks
|
|
192
|
+
* both.
|
|
193
|
+
* @param state - The fallback response state for endpoints with no override.
|
|
194
|
+
*/
|
|
195
|
+
setDefaultState: (state: 'success' | 'empty' | 'error' | 'unauthorized') => void;
|
|
196
|
+
/** Get the fixture set being served */
|
|
197
|
+
getFixtures: () => AppFixtureSet;
|
|
198
|
+
/** Close the server */
|
|
199
|
+
close: () => Promise<void>;
|
|
200
|
+
}
|
|
201
|
+
/** Pre-built fixture record for a specific resource */
|
|
202
|
+
export interface FixtureRecord {
|
|
203
|
+
[key: string]: unknown;
|
|
204
|
+
}
|
|
205
|
+
/** App-specific fixture data pools */
|
|
206
|
+
export interface AppDataPool {
|
|
207
|
+
/** App type name */
|
|
208
|
+
appType: string;
|
|
209
|
+
/** Resource-keyed fixture data: resource name -> array of records */
|
|
210
|
+
resources: Record<string, FixtureRecord[]>;
|
|
211
|
+
/** Report endpoints: endpoint path suffix -> response data */
|
|
212
|
+
reports?: Record<string, unknown>;
|
|
213
|
+
}
|
|
214
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,gDAAgD;AAChD,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAA;AAEpE,qEAAqE;AACrE,MAAM,WAAW,YAAY;IAC3B,uDAAuD;IACvD,MAAM,EAAE,OAAO,CAAA;IACf,uEAAuE;IACvE,WAAW,EAAE,OAAO,CAAA;IACpB,qDAAqD;IACrD,kBAAkB,EAAE,OAAO,CAAA;IAC3B,sDAAsD;IACtD,YAAY,EAAE,MAAM,CAAA;IACpB;;;;;OAKG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,kFAAkF;IAClF,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;CAC1B;AAED,8DAA8D;AAC9D,MAAM,WAAW,mBAAmB;IAClC,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAA;IACZ,gEAAgE;IAChE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAA;IAC3C,gCAAgC;IAChC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;IACrB,iCAAiC;IACjC,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,gDAAgD;IAChD,SAAS,CAAC,EAAE,mBAAmB,CAAA;IAC/B,8BAA8B;IAC9B,WAAW,CAAC,EAAE,mBAAmB,CAAA;IACjC,kDAAkD;IAClD,WAAW,CAAC,EAAE;QACZ,GAAG,CAAC,EAAE,MAAM,CAAA;QACZ,GAAG,CAAC,EAAE,MAAM,CAAA;QACZ,QAAQ,CAAC,EAAE,OAAO,CAAA;QAClB,GAAG,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;;;;;OAUG;IACH,UAAU,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAA;IACzC;;;;;;;OAOG;IACH,eAAe,EAAE,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,GAAG,OAAO,GAAG,cAAc,KAAK,IAAI,CAAA;IAChF,uCAAuC;IACvC,WAAW,EAAE,MAAM,aAAa,CAAA;IAChC,uBAAuB;IACvB,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAC3B;AAMD,uDAAuD;AACvD,MAAM,WAAW,aAAa;IAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED,sCAAsC;AACtC,MAAM,WAAW,WAAW;IAC1B,oBAAoB;IACpB,OAAO,EAAE,MAAM,CAAA;IACf,qEAAqE;IACrE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,EAAE,CAAC,CAAA;IAC1C,8DAA8D;IAC9D,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAClC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@molecule/api-mock-server",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Mock API server with deterministic fixture data for testing, screenshots, and E2E",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"molecule-mock-server": "dist/cli.js"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"test": "vitest run",
|
|
14
|
+
"test:watch": "vitest"
|
|
15
|
+
},
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./fixtures": {
|
|
22
|
+
"types": "./dist/fixtures/index.d.ts",
|
|
23
|
+
"import": "./dist/fixtures/index.js"
|
|
24
|
+
},
|
|
25
|
+
"./server": {
|
|
26
|
+
"types": "./dist/server/index.d.ts",
|
|
27
|
+
"import": "./dist/server/index.js"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist"
|
|
32
|
+
],
|
|
33
|
+
"keywords": [
|
|
34
|
+
"molecule",
|
|
35
|
+
"mock",
|
|
36
|
+
"api",
|
|
37
|
+
"testing",
|
|
38
|
+
"fixtures",
|
|
39
|
+
"server"
|
|
40
|
+
],
|
|
41
|
+
"license": "Apache-2.0",
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"express": "5.2.1"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"zod": ">=4.0.0"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@types/express": "5.0.6",
|
|
50
|
+
"@types/node": "26.1.2",
|
|
51
|
+
"ts-morph": "28.0.0",
|
|
52
|
+
"typescript": "6.0.3",
|
|
53
|
+
"vitest": "4.1.10",
|
|
54
|
+
"zod": "4.4.3"
|
|
55
|
+
},
|
|
56
|
+
"repository": {
|
|
57
|
+
"type": "git",
|
|
58
|
+
"url": "https://github.com/molecule-dev/molecule.git",
|
|
59
|
+
"directory": "packages/api/testing/mock-server"
|
|
60
|
+
},
|
|
61
|
+
"homepage": "https://github.com/molecule-dev/molecule/tree/main/packages/api/testing/mock-server",
|
|
62
|
+
"bugs": "https://github.com/molecule-dev/molecule/issues",
|
|
63
|
+
"publishConfig": {
|
|
64
|
+
"access": "public"
|
|
65
|
+
}
|
|
66
|
+
}
|