@nifrajs/mock 2.2.0 → 2.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 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/package.json +3 -3
- package/src/index.ts +3 -3
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ fixed seed when responses must be replayable across local development and CI.
|
|
|
20
20
|
|
|
21
21
|
## For AI agents
|
|
22
22
|
|
|
23
|
-
Start with [`LLM.md`](./LLM.md)
|
|
23
|
+
Start with [`LLM.md`](./LLM.md) - this package's contract card (the exports you call + its footguns),
|
|
24
24
|
one cheap read instead of the whole corpus. For the wider framework: the repo's
|
|
25
25
|
[`AGENTS.md`](../../AGENTS.md) is the copy-paste quick reference, and
|
|
26
26
|
[`llms-full.txt`](../../llms-full.txt) is the full machine-readable corpus. Run `nifra check` as the
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `@nifrajs/mock`
|
|
2
|
+
* `@nifrajs/mock` - contract-based mock server.
|
|
3
3
|
*
|
|
4
4
|
* Reads a Nifra app's registered routes and their Standard Schema / JSON Schema
|
|
5
5
|
* response definitions, then generates fake responses from supported JSON Schema keywords. Use it
|
|
@@ -28,7 +28,7 @@ export interface MockableRoute {
|
|
|
28
28
|
readonly response?: unknown;
|
|
29
29
|
} | undefined;
|
|
30
30
|
}
|
|
31
|
-
/** App shape
|
|
31
|
+
/** App shape - anything with a `routes()` method. */
|
|
32
32
|
export interface MockableApp {
|
|
33
33
|
routes(): readonly MockableRoute[];
|
|
34
34
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `@nifrajs/mock`
|
|
2
|
+
* `@nifrajs/mock` - contract-based mock server.
|
|
3
3
|
*
|
|
4
4
|
* Reads a Nifra app's registered routes and their Standard Schema / JSON Schema
|
|
5
5
|
* response definitions, then generates fake responses from supported JSON Schema keywords. Use it
|
|
@@ -114,7 +114,7 @@ export function generateMockValue(schema, fieldName, rng) {
|
|
|
114
114
|
return first;
|
|
115
115
|
throw new UnsupportedMockSchemaError("allOf", "Could not prove that a scalar satisfies every intersection branch");
|
|
116
116
|
}
|
|
117
|
-
// Enum
|
|
117
|
+
// Enum - pick the first value (deterministic) or random
|
|
118
118
|
const enumValues = raw.enum;
|
|
119
119
|
if (enumValues && Array.isArray(enumValues) && enumValues.length > 0) {
|
|
120
120
|
return enumValues[randomIndex(rand, enumValues.length)];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nifrajs/mock",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "Contract-based mock server
|
|
3
|
+
"version": "2.3.0",
|
|
4
|
+
"description": "Contract-based mock server - reads route schemas and generates fake responses.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"access": "public"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@nifrajs/core": "2.
|
|
29
|
+
"@nifrajs/core": "2.3.0"
|
|
30
30
|
},
|
|
31
31
|
"repository": {
|
|
32
32
|
"type": "git",
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `@nifrajs/mock`
|
|
2
|
+
* `@nifrajs/mock` - contract-based mock server.
|
|
3
3
|
*
|
|
4
4
|
* Reads a Nifra app's registered routes and their Standard Schema / JSON Schema
|
|
5
5
|
* response definitions, then generates fake responses from supported JSON Schema keywords. Use it
|
|
@@ -156,7 +156,7 @@ export function generateMockValue(
|
|
|
156
156
|
)
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
-
// Enum
|
|
159
|
+
// Enum - pick the first value (deterministic) or random
|
|
160
160
|
const enumValues = raw.enum as readonly unknown[] | undefined
|
|
161
161
|
if (enumValues && Array.isArray(enumValues) && enumValues.length > 0) {
|
|
162
162
|
return enumValues[randomIndex(rand, enumValues.length)]
|
|
@@ -274,7 +274,7 @@ export interface MockableRoute {
|
|
|
274
274
|
| undefined
|
|
275
275
|
}
|
|
276
276
|
|
|
277
|
-
/** App shape
|
|
277
|
+
/** App shape - anything with a `routes()` method. */
|
|
278
278
|
export interface MockableApp {
|
|
279
279
|
routes(): readonly MockableRoute[]
|
|
280
280
|
}
|