openai-api-mock 0.2.0 → 0.2.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/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  export interface MockOptions {
3
2
  /**
4
3
  * When true, randomly simulates API errors
@@ -20,6 +19,11 @@ export interface MockOptions {
20
19
  * Whether to use predefined fixed response templates
21
20
  */
22
21
  useFixedResponses?: boolean;
22
+ /**
23
+ * Base URL for the OpenAI API or OpenAI-compatible service
24
+ * @default 'https://api.openai.com'
25
+ */
26
+ baseUrl?: string;
23
27
  }
24
28
 
25
29
  export interface MockControl {
@@ -46,11 +50,14 @@ export interface MockControl {
46
50
  /**
47
51
  * Create a custom response template
48
52
  */
49
- createResponseTemplate: (templateType: string, overrides?: Record<string, any>) => Record<string, any>;
53
+ createResponseTemplate: (
54
+ templateType: string,
55
+ overrides?: Record<string, any>
56
+ ) => Record<string, any>;
50
57
  /**
51
58
  * Adds a custom endpoint mock
52
59
  * @param method - HTTP method (GET, POST, etc.)
53
- * @param path - Endpoint path (will be appended to api.openai.com)
60
+ * @param path - Endpoint path (will be appended to the configured base URL)
54
61
  * @param handler - Function to handle the request and return response
55
62
  */
56
63
  addCustomEndpoint: (
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "openai-api-mock",
3
- "version": "0.2.0",
4
- "description": "A Node.js module for mocking OpenAI API responses in a development environment with consistency mechanisms for deterministic testing",
3
+ "version": "0.2.2",
4
+ "description": "A Node.js module for mocking OpenAI-compatible API responses in a development environment with consistency mechanisms for deterministic testing",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/chihebnabil/openai-api-mock.git"
@@ -32,7 +32,10 @@
32
32
  "pretest": "npm run build",
33
33
  "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
34
34
  "coverage": "node --experimental-vm-modules node_modules/jest/bin/jest.js --coverage",
35
- "prepublishOnly": "npm run build"
35
+ "prepublishOnly": "npm run build",
36
+ "format": "prettier --write .",
37
+ "format:check": "prettier --check .",
38
+ "format:src": "prettier --write src/**/*.js __tests__/**/*.js"
36
39
  },
37
40
  "author": "Chiheb Nabil",
38
41
  "license": "MIT",
@@ -49,14 +52,15 @@
49
52
  "index.d.ts"
50
53
  ],
51
54
  "dependencies": {
52
- "@faker-js/faker": "^9.0.0",
55
+ "@faker-js/faker": "^10.0.0",
53
56
  "nock": "^14.0.0"
54
57
  },
55
58
  "devDependencies": {
56
59
  "jest": "^30.0.0",
57
60
  "node-fetch": "^3.3.2",
58
61
  "openai": "^4.52.4",
59
- "vite": "^6.2.0"
62
+ "prettier": "^3.0.0",
63
+ "vite": "^7.0.0"
60
64
  },
61
65
  "engines": {
62
66
  "node": ">=18.0.0"