@schmock/core 1.0.1 → 1.0.2
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/builder.d.ts +1 -1
- package/dist/builder.d.ts.map +1 -1
- package/dist/builder.js +2 -2
- package/dist/errors.d.ts +3 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +42 -1
- package/dist/parser.d.ts +2 -1
- package/dist/parser.d.ts.map +1 -1
- package/dist/parser.js +1 -1
- package/dist/types.d.ts +14 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/builder.ts +3 -3
- package/src/index.ts +4 -4
- package/src/parser.ts +2 -2
- package/src/types.ts +14 -2
package/dist/builder.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Generator, GlobalConfig, HttpMethod, Plugin, RequestOptions, Response, RouteConfig, RouteKey } from "./types";
|
|
1
|
+
import type { Generator, GlobalConfig, HttpMethod, Plugin, RequestOptions, Response, RouteConfig, RouteKey } from "./types.js";
|
|
2
2
|
/**
|
|
3
3
|
* Callable mock instance that implements the new API.
|
|
4
4
|
*
|
package/dist/builder.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,SAAS,EAET,YAAY,EACZ,UAAU,EACV,MAAM,EAGN,cAAc,EACd,QAAQ,EACR,WAAW,EACX,QAAQ,EACT,MAAM,
|
|
1
|
+
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,SAAS,EAET,YAAY,EACZ,UAAU,EACV,MAAM,EAGN,cAAc,EACd,QAAQ,EACR,WAAW,EACX,QAAQ,EACT,MAAM,YAAY,CAAC;AA4CpB;;;;GAIG;AACH,qBAAa,oBAAoB;IAKnB,OAAO,CAAC,YAAY;IAJhC,OAAO,CAAC,MAAM,CAA+B;IAC7C,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,MAAM,CAAc;gBAER,YAAY,GAAE,YAAiB;IAanD,WAAW,CACT,KAAK,EAAE,QAAQ,EACf,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,WAAW,GAClB,IAAI;IA4DP,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAepB,MAAM,CACV,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,QAAQ,CAAC;IAiLpB;;;;OAIG;YACW,UAAU;IAcxB;;;;;;;OAOG;IACH,OAAO,CAAC,aAAa;IA0DrB;;;;;;;;;;OAUG;YACW,iBAAiB;IAmF/B;;;;;;;;OAQG;IACH,OAAO,CAAC,SAAS;IA+BjB;;;;;;;OAOG;IACH,OAAO,CAAC,aAAa;CActB"}
|
package/dist/builder.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PluginError, RouteDefinitionError, RouteNotFoundError, SchmockError, } from "./errors";
|
|
2
|
-
import { parseRouteKey } from "./parser";
|
|
1
|
+
import { PluginError, RouteDefinitionError, RouteNotFoundError, SchmockError, } from "./errors.js";
|
|
2
|
+
import { parseRouteKey } from "./parser.js";
|
|
3
3
|
/**
|
|
4
4
|
* Debug logger that respects debug mode configuration
|
|
5
5
|
*/
|
package/dist/errors.d.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export declare class SchmockError extends Error {
|
|
5
5
|
readonly code: string;
|
|
6
|
-
readonly context?: unknown;
|
|
7
|
-
constructor(message: string, code: string, context?: unknown);
|
|
6
|
+
readonly context?: unknown | undefined;
|
|
7
|
+
constructor(message: string, code: string, context?: unknown | undefined);
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* Error thrown when a route is not found
|
|
@@ -54,3 +54,4 @@ export declare class SchemaGenerationError extends SchmockError {
|
|
|
54
54
|
export declare class ResourceLimitError extends SchmockError {
|
|
55
55
|
constructor(resource: string, limit: number, actual?: number);
|
|
56
56
|
}
|
|
57
|
+
//# sourceMappingURL=errors.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CallableMockInstance, GlobalConfig } from "./types";
|
|
1
|
+
import type { CallableMockInstance, GlobalConfig } from "./types.js";
|
|
2
2
|
/**
|
|
3
3
|
* Create a new Schmock mock instance with callable API.
|
|
4
4
|
*
|
|
@@ -23,6 +23,6 @@ import type { CallableMockInstance, GlobalConfig } from "./types";
|
|
|
23
23
|
* @returns A callable mock instance
|
|
24
24
|
*/
|
|
25
25
|
export declare function schmock(config?: GlobalConfig): CallableMockInstance;
|
|
26
|
-
export { PluginError, ResourceLimitError, ResponseGenerationError, RouteDefinitionError, RouteNotFoundError, RouteParseError, SchemaGenerationError, SchemaValidationError, SchmockError, } from "./errors";
|
|
27
|
-
export type { CallableMockInstance, Generator, GeneratorFunction, GlobalConfig, HttpMethod, Plugin, PluginContext, PluginResult, RequestContext, RequestOptions, Response, ResponseResult, RouteConfig, RouteKey, } from "./types";
|
|
26
|
+
export { PluginError, ResourceLimitError, ResponseGenerationError, RouteDefinitionError, RouteNotFoundError, RouteParseError, SchemaGenerationError, SchemaValidationError, SchmockError, } from "./errors.js";
|
|
27
|
+
export type { CallableMockInstance, Generator, GeneratorFunction, GlobalConfig, HttpMethod, Plugin, PluginContext, PluginResult, RequestContext, RequestOptions, Response, ResponseResult, RouteConfig, RouteKey, } from "./types.js";
|
|
28
28
|
//# 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,KAAK,EACV,oBAAoB,EAEpB,YAAY,EAIb,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,oBAAoB,EAEpB,YAAY,EAIb,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,OAAO,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG,oBAAoB,CAsBnE;AAGD,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,uBAAuB,EACvB,oBAAoB,EACpB,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACrB,YAAY,GACb,MAAM,aAAa,CAAC;AAGrB,YAAY,EACV,oBAAoB,EACpB,SAAS,EACT,iBAAiB,EACjB,YAAY,EACZ,UAAU,EACV,MAAM,EACN,aAAa,EACb,YAAY,EACZ,cAAc,EACd,cAAc,EACd,QAAQ,EACR,cAAc,EACd,WAAW,EACX,QAAQ,GACT,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1 +1,42 @@
|
|
|
1
|
-
|
|
1
|
+
import { CallableMockInstance as CallableMockInstanceImpl } from "./builder.js";
|
|
2
|
+
/**
|
|
3
|
+
* Create a new Schmock mock instance with callable API.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* // New callable API (default)
|
|
8
|
+
* const mock = schmock({ debug: true })
|
|
9
|
+
* mock('GET /users', () => [{ id: 1, name: 'John' }])
|
|
10
|
+
* .pipe(authPlugin())
|
|
11
|
+
*
|
|
12
|
+
* const response = await mock.handle('GET', '/users')
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* // Simple usage with defaults
|
|
18
|
+
* const mock = schmock()
|
|
19
|
+
* mock('GET /users', [{ id: 1, name: 'John' }])
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @param config Optional global configuration
|
|
23
|
+
* @returns A callable mock instance
|
|
24
|
+
*/
|
|
25
|
+
export function schmock(config) {
|
|
26
|
+
// Always use new callable API
|
|
27
|
+
const instance = new CallableMockInstanceImpl(config || {});
|
|
28
|
+
// Create a callable function that wraps the instance
|
|
29
|
+
const callableInstance = ((route, generator, routeConfig = {}) => {
|
|
30
|
+
instance.defineRoute(route, generator, routeConfig);
|
|
31
|
+
return callableInstance; // Return the callable function for chaining
|
|
32
|
+
});
|
|
33
|
+
// Manually bind all instance methods to the callable function with proper return values
|
|
34
|
+
callableInstance.pipe = (plugin) => {
|
|
35
|
+
instance.pipe(plugin);
|
|
36
|
+
return callableInstance; // Return callable function for chaining
|
|
37
|
+
};
|
|
38
|
+
callableInstance.handle = instance.handle.bind(instance);
|
|
39
|
+
return callableInstance;
|
|
40
|
+
}
|
|
41
|
+
// Re-export errors
|
|
42
|
+
export { PluginError, ResourceLimitError, ResponseGenerationError, RouteDefinitionError, RouteNotFoundError, RouteParseError, SchemaGenerationError, SchemaValidationError, SchmockError, } from "./errors.js";
|
package/dist/parser.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { HttpMethod } from "./types";
|
|
1
|
+
import type { HttpMethod } from "./types.js";
|
|
2
2
|
export interface ParsedRoute {
|
|
3
3
|
method: HttpMethod;
|
|
4
4
|
path: string;
|
|
@@ -17,3 +17,4 @@ export interface ParsedRoute {
|
|
|
17
17
|
* // => { method: 'GET', path: '/users/:id', pattern: /^\/users\/([^/]+)$/, params: ['id'] }
|
|
18
18
|
*/
|
|
19
19
|
export declare function parseRouteKey(routeKey: string): ParsedRoute;
|
|
20
|
+
//# sourceMappingURL=parser.d.ts.map
|
package/dist/parser.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAgB7C,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,UAAU,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,CA4C3D"}
|
package/dist/parser.js
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* JSON Schema type (simplified for core package)
|
|
3
|
+
* Full schema support available via @schmock/schema
|
|
4
|
+
*/
|
|
5
|
+
export interface JSONSchema {
|
|
6
|
+
type?: string | string[];
|
|
7
|
+
properties?: Record<string, JSONSchema>;
|
|
8
|
+
items?: JSONSchema | JSONSchema[];
|
|
9
|
+
required?: string[];
|
|
10
|
+
enum?: any[];
|
|
11
|
+
const?: any;
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
}
|
|
2
14
|
/**
|
|
3
15
|
* HTTP methods supported by Schmock
|
|
4
16
|
*/
|
|
@@ -94,7 +106,7 @@ export interface RouteConfig {
|
|
|
94
106
|
/**
|
|
95
107
|
* Generator types that can be passed to route definitions
|
|
96
108
|
*/
|
|
97
|
-
export type Generator = GeneratorFunction | StaticData |
|
|
109
|
+
export type Generator = GeneratorFunction | StaticData | JSONSchema;
|
|
98
110
|
/**
|
|
99
111
|
* Function that generates responses
|
|
100
112
|
*/
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH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G;IACH,MAAM,CACJ,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,QAAQ,CAAC,CAAC;CACtB"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schmock/core",
|
|
3
3
|
"description": "Core functionality for Schmock",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -18,16 +18,16 @@
|
|
|
18
18
|
"./package.json": "./package.json"
|
|
19
19
|
},
|
|
20
20
|
"scripts": {
|
|
21
|
-
"build": "
|
|
22
|
-
"build:
|
|
23
|
-
"build:types": "tsc -p tsconfig.json",
|
|
21
|
+
"build": "rm -rf dist tsconfig.tsbuildinfo && tsc --build",
|
|
22
|
+
"build:types": "rm -f tsconfig.tsbuildinfo && tsc --build",
|
|
24
23
|
"pretest": "rm -f src/*.js src/*.d.ts || true",
|
|
25
24
|
"test": "vitest",
|
|
26
25
|
"test:watch": "vitest --watch",
|
|
27
26
|
"pretest:bdd": "rm -f src/*.js src/*.d.ts || true",
|
|
28
27
|
"test:bdd": "vitest run --config vitest.config.bdd.ts",
|
|
29
28
|
"lint": "biome check src/*.ts",
|
|
30
|
-
"lint:fix": "biome check --write --unsafe src/*.ts"
|
|
29
|
+
"lint:fix": "biome check --write --unsafe src/*.ts",
|
|
30
|
+
"check:publish": "publint && attw --pack --ignore-rules cjs-resolves-to-esm"
|
|
31
31
|
},
|
|
32
32
|
"license": "MIT",
|
|
33
33
|
"devDependencies": {
|
package/src/builder.ts
CHANGED
|
@@ -3,8 +3,8 @@ import {
|
|
|
3
3
|
RouteDefinitionError,
|
|
4
4
|
RouteNotFoundError,
|
|
5
5
|
SchmockError,
|
|
6
|
-
} from "./errors";
|
|
7
|
-
import { parseRouteKey } from "./parser";
|
|
6
|
+
} from "./errors.js";
|
|
7
|
+
import { parseRouteKey } from "./parser.js";
|
|
8
8
|
import type {
|
|
9
9
|
Generator,
|
|
10
10
|
GeneratorFunction,
|
|
@@ -17,7 +17,7 @@ import type {
|
|
|
17
17
|
Response,
|
|
18
18
|
RouteConfig,
|
|
19
19
|
RouteKey,
|
|
20
|
-
} from "./types";
|
|
20
|
+
} from "./types.js";
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Debug logger that respects debug mode configuration
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CallableMockInstance as CallableMockInstanceImpl } from "./builder";
|
|
1
|
+
import { CallableMockInstance as CallableMockInstanceImpl } from "./builder.js";
|
|
2
2
|
import type {
|
|
3
3
|
CallableMockInstance,
|
|
4
4
|
Generator,
|
|
@@ -6,7 +6,7 @@ import type {
|
|
|
6
6
|
Plugin,
|
|
7
7
|
RouteConfig,
|
|
8
8
|
RouteKey,
|
|
9
|
-
} from "./types";
|
|
9
|
+
} from "./types.js";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Create a new Schmock mock instance with callable API.
|
|
@@ -66,7 +66,7 @@ export {
|
|
|
66
66
|
SchemaGenerationError,
|
|
67
67
|
SchemaValidationError,
|
|
68
68
|
SchmockError,
|
|
69
|
-
} from "./errors";
|
|
69
|
+
} from "./errors.js";
|
|
70
70
|
|
|
71
71
|
// Re-export types
|
|
72
72
|
export type {
|
|
@@ -84,4 +84,4 @@ export type {
|
|
|
84
84
|
ResponseResult,
|
|
85
85
|
RouteConfig,
|
|
86
86
|
RouteKey,
|
|
87
|
-
} from "./types";
|
|
87
|
+
} from "./types.js";
|
package/src/parser.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* JSON Schema type (simplified for core package)
|
|
3
|
+
* Full schema support available via @schmock/schema
|
|
4
|
+
*/
|
|
5
|
+
export interface JSONSchema {
|
|
6
|
+
type?: string | string[];
|
|
7
|
+
properties?: Record<string, JSONSchema>;
|
|
8
|
+
items?: JSONSchema | JSONSchema[];
|
|
9
|
+
required?: string[];
|
|
10
|
+
enum?: any[];
|
|
11
|
+
const?: any;
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
}
|
|
2
14
|
|
|
3
15
|
/**
|
|
4
16
|
* HTTP methods supported by Schmock
|
|
@@ -121,7 +133,7 @@ export interface RouteConfig {
|
|
|
121
133
|
/**
|
|
122
134
|
* Generator types that can be passed to route definitions
|
|
123
135
|
*/
|
|
124
|
-
export type Generator = GeneratorFunction | StaticData |
|
|
136
|
+
export type Generator = GeneratorFunction | StaticData | JSONSchema;
|
|
125
137
|
|
|
126
138
|
/**
|
|
127
139
|
* Function that generates responses
|