@schmock/faker 1.9.4 → 1.9.5
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/index.js +1 -161
- package/package.json +3 -3
- package/src/constants.d.ts +6 -0
- package/src/constants.d.ts.map +1 -0
- package/src/index.d.ts +19 -0
- package/src/index.d.ts.map +1 -0
- package/src/jsf-config.d.ts +10 -0
- package/src/jsf-config.d.ts.map +1 -0
- package/src/overrides.d.ts +21 -0
- package/src/overrides.d.ts.map +1 -0
- package/src/schema-enhancement.d.ts +3 -0
- package/src/schema-enhancement.d.ts.map +1 -0
- package/src/validation.d.ts +20 -0
- package/src/validation.d.ts.map +1 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schmock/faker",
|
|
3
3
|
"description": "Faker-powered automatic data generation for Schmock",
|
|
4
|
-
"version": "1.9.
|
|
4
|
+
"version": "1.9.5",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"scripts": {
|
|
21
21
|
"build": "bun build:lib && bun build:types",
|
|
22
|
-
"build:lib": "bun build --minify --target
|
|
22
|
+
"build:lib": "bun build --minify --target browser --outdir=dist src/index.ts --external @faker-js/faker --external json-schema-faker --external @schmock/core",
|
|
23
23
|
"build:types": "tsc -p tsconfig.json",
|
|
24
24
|
"test": "vitest",
|
|
25
25
|
"test:watch": "vitest --watch",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"json-schema-faker": "^0.5.6"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@schmock/core": "^1.9.
|
|
37
|
+
"@schmock/core": "^1.9.5"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@amiceli/vitest-cucumber": "^6.2.0",
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const MAX_ARRAY_SIZE = 10000;
|
|
2
|
+
export declare const MAX_NESTING_DEPTH = 10;
|
|
3
|
+
export declare const DEFAULT_ARRAY_COUNT = 3;
|
|
4
|
+
export declare const DEEP_NESTING_THRESHOLD = 3;
|
|
5
|
+
export declare const LARGE_ARRAY_THRESHOLD = 100;
|
|
6
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["constants.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,cAAc,QAAQ,CAAC;AACpC,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,eAAO,MAAM,mBAAmB,IAAI,CAAC;AACrC,eAAO,MAAM,sBAAsB,IAAI,CAAC;AACxC,eAAO,MAAM,qBAAqB,MAAM,CAAC"}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { JSONSchema7 } from "json-schema";
|
|
2
|
+
export interface SchemaGenerationContext {
|
|
3
|
+
schema: JSONSchema7;
|
|
4
|
+
count?: number;
|
|
5
|
+
overrides?: Record<string, any>;
|
|
6
|
+
params?: Record<string, string>;
|
|
7
|
+
state?: any;
|
|
8
|
+
query?: Record<string, string>;
|
|
9
|
+
seed?: number;
|
|
10
|
+
}
|
|
11
|
+
export interface FakerPluginOptions {
|
|
12
|
+
schema: JSONSchema7;
|
|
13
|
+
count?: number;
|
|
14
|
+
overrides?: Record<string, any>;
|
|
15
|
+
seed?: number;
|
|
16
|
+
}
|
|
17
|
+
export declare function fakerPlugin(options: FakerPluginOptions): Schmock.Plugin;
|
|
18
|
+
export declare function generateFromSchema(options: SchemaGenerationContext): any;
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAO/C,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,WAAW,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,WAAW,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CA+CvE;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,uBAAuB,GAAG,GAAG,CA6CxE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Faker } from "@faker-js/faker";
|
|
2
|
+
import jsf from "json-schema-faker";
|
|
3
|
+
/**
|
|
4
|
+
* Create isolated faker instance to avoid race conditions
|
|
5
|
+
* Each generation gets its own faker instance to ensure thread-safety
|
|
6
|
+
* @returns Fresh Faker instance with English locale
|
|
7
|
+
*/
|
|
8
|
+
export declare function createFakerInstance(seed?: number): Faker;
|
|
9
|
+
export declare function getJsf(seed?: number): typeof jsf;
|
|
10
|
+
//# sourceMappingURL=jsf-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsf-config.d.ts","sourceRoot":"","sources":["jsf-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAM,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,GAAG,MAAM,mBAAmB,CAAC;AAEpC;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,CAAC,EAAE,MAAM,SAMhD;AAoBD,wBAAgB,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,CAuBhD"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { JSONSchema7 } from "json-schema";
|
|
2
|
+
/**
|
|
3
|
+
* Determine number of items to generate for array schema
|
|
4
|
+
* Prefers explicit count, then schema minItems/maxItems, with sane defaults
|
|
5
|
+
* @param schema - Array schema with optional minItems/maxItems
|
|
6
|
+
* @param explicitCount - Explicit count override from plugin options
|
|
7
|
+
* @returns Number of array items to generate
|
|
8
|
+
*/
|
|
9
|
+
export declare function determineArrayCount(schema: JSONSchema7, explicitCount?: number, random?: () => number): number;
|
|
10
|
+
/**
|
|
11
|
+
* Apply overrides to generated data with support for templates
|
|
12
|
+
* Supports nested paths (dot notation), templates with {{params.id}}, and state access
|
|
13
|
+
* @param data - Generated data to apply overrides to
|
|
14
|
+
* @param overrides - Override values (can use templates)
|
|
15
|
+
* @param params - Route parameters for template expansion
|
|
16
|
+
* @param state - Plugin state for template expansion
|
|
17
|
+
* @param query - Query parameters for template expansion
|
|
18
|
+
* @returns Data with overrides applied
|
|
19
|
+
*/
|
|
20
|
+
export declare function applyOverrides(data: any, overrides?: Record<string, any>, params?: Record<string, string>, state?: any, query?: Record<string, string>): any;
|
|
21
|
+
//# sourceMappingURL=overrides.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overrides.d.ts","sourceRoot":"","sources":["overrides.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAK/C;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,WAAW,EACnB,aAAa,CAAC,EAAE,MAAM,EACtB,MAAM,GAAE,MAAM,MAAoB,GACjC,MAAM,CAyBR;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,GAAG,EACT,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC/B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,KAAK,CAAC,EAAE,GAAG,EACX,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC7B,GAAG,CAuCL"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-enhancement.d.ts","sourceRoot":"","sources":["schema-enhancement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAQ/C,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,WAAW,GAClB,WAAW,CAwBb"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { JSONSchema7 } from "json-schema";
|
|
2
|
+
export declare function isJSONSchema7(value: unknown): value is JSONSchema7;
|
|
3
|
+
/**
|
|
4
|
+
* Validate JSON Schema structure and enforce resource limits
|
|
5
|
+
* Checks for malformed schemas, circular references, excessive nesting,
|
|
6
|
+
* and dangerous patterns that could cause memory issues
|
|
7
|
+
* @param schema - JSON Schema to validate
|
|
8
|
+
* @param path - Current path in schema tree (for error messages)
|
|
9
|
+
* @throws {SchemaValidationError} When schema structure is invalid
|
|
10
|
+
* @throws {ResourceLimitError} When schema exceeds safety limits
|
|
11
|
+
*/
|
|
12
|
+
export declare function validateSchema(schema: JSONSchema7, path?: string): void;
|
|
13
|
+
/**
|
|
14
|
+
* Validate that faker method string references a valid Faker.js API
|
|
15
|
+
* Checks format (namespace.method) and validates against known namespaces
|
|
16
|
+
* @param fakerMethod - Faker method string (e.g., "person.fullName")
|
|
17
|
+
* @throws {SchemaValidationError} When faker method format or namespace is invalid
|
|
18
|
+
*/
|
|
19
|
+
export declare function validateFakerMethod(fakerMethod: string): void;
|
|
20
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["validation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAY/C,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAElE;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,SAAM,GAAG,IAAI,CAiJpE;AAwMD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAmC7D"}
|