@scenarist/express-adapter 0.2.0 → 0.3.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/README.md +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/setup/impl.d.ts.map +1 -1
- package/dist/setup/impl.js +4 -1
- package/dist/setup/production.d.ts +9 -1
- package/dist/setup/production.d.ts.map +1 -1
- package/dist/setup/production.js +10 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -18,6 +18,7 @@ Express.js adapter for [Scenarist](https://scenarist.io) - manage MSW mock scena
|
|
|
18
18
|
| **Request Matching** | [scenarist.io/scenarios/request-matching](https://scenarist.io/scenarios/request-matching) |
|
|
19
19
|
| **Response Sequences** | [scenarist.io/scenarios/response-sequences](https://scenarist.io/scenarios/response-sequences) |
|
|
20
20
|
| **State-Aware Mocking** | [scenarist.io/scenarios/state-aware-mocking](https://scenarist.io/scenarios/state-aware-mocking) |
|
|
21
|
+
| **Logging & Debugging** | [scenarist.io/reference/logging](https://scenarist.io/reference/logging) |
|
|
21
22
|
|
|
22
23
|
## What is Scenarist?
|
|
23
24
|
|
package/dist/index.d.ts
CHANGED
|
@@ -5,4 +5,6 @@ export { createTestIdMiddleware, testIdStorage, } from "./middleware/test-id-mid
|
|
|
5
5
|
export { createScenarioEndpoints } from "./endpoints/scenario-endpoints.js";
|
|
6
6
|
export { SCENARIST_TEST_ID_HEADER } from "@scenarist/core";
|
|
7
7
|
export type { ScenaristScenario, ScenaristMock, ScenaristResponse, ScenaristSequence, ScenaristMatch, ScenaristCaptureConfig, ScenaristScenarios, ScenaristConfig, ScenaristResult, } from "@scenarist/core";
|
|
8
|
+
export { noOpLogger, createNoOpLogger, createConsoleLogger, } from "@scenarist/core";
|
|
9
|
+
export type { Logger, LogLevel, LogCategory, LogContext, ConsoleLoggerConfig, LogFormat, } from "@scenarist/core";
|
|
8
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,YAAY,EACV,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EACL,sBAAsB,EACtB,aAAa,GACd,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAG5E,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,YAAY,EACV,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,sBAAsB,EACtB,kBAAkB,EAClB,eAAe,EACf,eAAe,GAChB,MAAM,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,YAAY,EACV,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EACL,sBAAsB,EACtB,aAAa,GACd,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAG5E,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,YAAY,EACV,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,sBAAsB,EACtB,kBAAkB,EAClB,eAAe,EACf,eAAe,GAChB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,MAAM,EACN,QAAQ,EACR,WAAW,EACX,UAAU,EACV,mBAAmB,EACnB,SAAS,GACV,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -6,3 +6,5 @@ export { createTestIdMiddleware, testIdStorage, } from "./middleware/test-id-mid
|
|
|
6
6
|
export { createScenarioEndpoints } from "./endpoints/scenario-endpoints.js";
|
|
7
7
|
// Re-export core types and constants for user convenience (users should only install this adapter)
|
|
8
8
|
export { SCENARIST_TEST_ID_HEADER } from "@scenarist/core";
|
|
9
|
+
// Logger exports - for debugging and observability
|
|
10
|
+
export { noOpLogger, createNoOpLogger, createConsoleLogger, } from "@scenarist/core";
|
package/dist/setup/impl.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"impl.d.ts","sourceRoot":"","sources":["../../src/setup/impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,OAAO,
|
|
1
|
+
{"version":3,"file":"impl.d.ts","sourceRoot":"","sources":["../../src/setup/impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,OAAO,EASL,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACxB,MAAM,iBAAiB,CAAC;AAMzB;;;;;;GAMG;AACH,MAAM,MAAM,qBAAqB,CAC/B,CAAC,SAAS,kBAAkB,GAAG,kBAAkB,IAC/C,kBAAkB,CAAC,CAAC,CAAC,CAAC;AAE1B;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,CAC1B,CAAC,SAAS,kBAAkB,GAAG,kBAAkB,IAC/C,gBAAgB,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,mBAAmB,GAAI,CAAC,SAAS,kBAAkB,EAC9D,SAAS,qBAAqB,CAAC,CAAC,CAAC,KAChC,gBAAgB,CAAC,CAAC,CAsDpB,CAAC"}
|
package/dist/setup/impl.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Router } from "express";
|
|
2
2
|
import { setupServer } from "msw/node";
|
|
3
|
-
import { buildConfig, createScenarioManager, createResponseSelector, InMemoryScenarioRegistry, InMemoryScenarioStore, createInMemorySequenceTracker, createInMemoryStateManager, } from "@scenarist/core";
|
|
3
|
+
import { buildConfig, createScenarioManager, createResponseSelector, InMemoryScenarioRegistry, InMemoryScenarioStore, createInMemorySequenceTracker, createInMemoryStateManager, noOpLogger, } from "@scenarist/core";
|
|
4
4
|
import { createDynamicHandler } from "@scenarist/msw-adapter";
|
|
5
5
|
import { testIdStorage } from "../middleware/test-id-middleware.js";
|
|
6
6
|
import { createTestIdMiddleware } from "../middleware/test-id-middleware.js";
|
|
@@ -37,6 +37,7 @@ import { createScenarioEndpoints } from "../endpoints/scenario-endpoints.js";
|
|
|
37
37
|
*/
|
|
38
38
|
export const createScenaristImpl = (options) => {
|
|
39
39
|
const config = buildConfig(options);
|
|
40
|
+
const logger = options.logger ?? noOpLogger;
|
|
40
41
|
const registry = options.registry ?? new InMemoryScenarioRegistry();
|
|
41
42
|
const store = options.store ?? new InMemoryScenarioStore();
|
|
42
43
|
const stateManager = createInMemoryStateManager();
|
|
@@ -46,6 +47,7 @@ export const createScenaristImpl = (options) => {
|
|
|
46
47
|
store,
|
|
47
48
|
stateManager,
|
|
48
49
|
sequenceTracker,
|
|
50
|
+
logger,
|
|
49
51
|
});
|
|
50
52
|
// Register all scenarios upfront from the scenarios object
|
|
51
53
|
Object.values(options.scenarios).forEach((scenario) => {
|
|
@@ -54,6 +56,7 @@ export const createScenaristImpl = (options) => {
|
|
|
54
56
|
const responseSelector = createResponseSelector({
|
|
55
57
|
sequenceTracker,
|
|
56
58
|
stateManager,
|
|
59
|
+
logger,
|
|
57
60
|
});
|
|
58
61
|
const handler = createDynamicHandler({
|
|
59
62
|
getTestId: (_request) => testIdStorage.getStore() ?? config.defaultTestId,
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
export type { ExpressAdapterOptions, ExpressScenarist, } from "./setup-scenarist.js";
|
|
2
|
+
export type { Logger, LogLevel, LogCategory, LogContext, ConsoleLoggerConfig, } from "@scenarist/core";
|
|
2
3
|
/**
|
|
3
4
|
* Production-only entry point that returns undefined without loading any dependencies.
|
|
4
5
|
*
|
|
5
|
-
* This file provides
|
|
6
|
+
* This file provides safe stub implementations for all Scenarist functions to prevent
|
|
6
7
|
* MSW and test code from being included in production bundles. Conditional exports
|
|
7
8
|
* ensure this file is used when NODE_ENV=production, achieving 100% tree-shaking
|
|
8
9
|
* of test infrastructure.
|
|
9
10
|
*/
|
|
10
11
|
export declare const createScenarist: (_options: import("./setup-scenarist.js").ExpressAdapterOptions) => import("./setup-scenarist.js").ExpressScenarist | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Production stub: Returns undefined (logging disabled in production)
|
|
14
|
+
*
|
|
15
|
+
* This allows application code to conditionally create loggers without
|
|
16
|
+
* importing the full logger implementation in production builds.
|
|
17
|
+
*/
|
|
18
|
+
export declare const createConsoleLogger: (_config: import("@scenarist/core").ConsoleLoggerConfig) => import("@scenarist/core").Logger | undefined;
|
|
11
19
|
//# sourceMappingURL=production.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"production.d.ts","sourceRoot":"","sources":["../../src/setup/production.ts"],"names":[],"mappings":"AACA,YAAY,EACV,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"production.d.ts","sourceRoot":"","sources":["../../src/setup/production.ts"],"names":[],"mappings":"AACA,YAAY,EACV,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAG9B,YAAY,EACV,MAAM,EACN,QAAQ,EACR,WAAW,EACX,UAAU,EACV,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AAEzB;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,GAC1B,UAAU,OAAO,sBAAsB,EAAE,qBAAqB,KAC7D,OAAO,sBAAsB,EAAE,gBAAgB,GAAG,SAEpD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAC9B,SAAS,OAAO,iBAAiB,EAAE,mBAAmB,KACrD,OAAO,iBAAiB,EAAE,MAAM,GAAG,SAErC,CAAC"}
|
package/dist/setup/production.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Production-only entry point that returns undefined without loading any dependencies.
|
|
3
3
|
*
|
|
4
|
-
* This file provides
|
|
4
|
+
* This file provides safe stub implementations for all Scenarist functions to prevent
|
|
5
5
|
* MSW and test code from being included in production bundles. Conditional exports
|
|
6
6
|
* ensure this file is used when NODE_ENV=production, achieving 100% tree-shaking
|
|
7
7
|
* of test infrastructure.
|
|
@@ -9,3 +9,12 @@
|
|
|
9
9
|
export const createScenarist = (_options) => {
|
|
10
10
|
return undefined;
|
|
11
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* Production stub: Returns undefined (logging disabled in production)
|
|
14
|
+
*
|
|
15
|
+
* This allows application code to conditionally create loggers without
|
|
16
|
+
* importing the full logger implementation in production builds.
|
|
17
|
+
*/
|
|
18
|
+
export const createConsoleLogger = (_config) => {
|
|
19
|
+
return undefined;
|
|
20
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scenarist/express-adapter",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Express middleware adapter for Scenarist",
|
|
5
5
|
"author": "Paul Hammond (citypaul) <paul@packsoftware.co.uk>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
],
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"zod": "^4.1.13",
|
|
51
|
-
"@scenarist/core": "0.
|
|
52
|
-
"@scenarist/msw-adapter": "0.
|
|
51
|
+
"@scenarist/core": "0.3.0",
|
|
52
|
+
"@scenarist/msw-adapter": "0.3.0"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"express": "^4.18.0 || ^5.0.0",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"msw": "^2.12.3",
|
|
66
66
|
"supertest": "^7.0.0",
|
|
67
67
|
"typescript": "^5.9.3",
|
|
68
|
-
"vitest": "^4.0.
|
|
68
|
+
"vitest": "^4.0.15",
|
|
69
69
|
"@scenarist/eslint-config": "^0.0.0",
|
|
70
70
|
"@scenarist/typescript-config": "0.0.0"
|
|
71
71
|
},
|