openai-api-mock 0.1.26 → 0.1.27
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.cjs.js → index.cjs} +1 -1
- package/dist/index.cjs.map +1 -0
- package/dist/{index.es.js → index.js} +1 -1
- package/dist/index.js.map +1 -0
- package/package.json +5 -5
- package/src/index.js +3 -5
- package/vite.config.js +2 -1
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.es.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openai-api-mock",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.27",
|
|
4
4
|
"description": "A Node.js module for mocking OpenAI API responses in a development environment",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
},
|
|
30
30
|
"author": "Chiheb Nabil",
|
|
31
31
|
"license": "MIT",
|
|
32
|
-
"main": "./dist/index.cjs
|
|
33
|
-
"module": "./dist/index.
|
|
32
|
+
"main": "./dist/index.cjs",
|
|
33
|
+
"module": "./dist/index.js",
|
|
34
34
|
"exports": {
|
|
35
35
|
".": {
|
|
36
|
-
"
|
|
37
|
-
"
|
|
36
|
+
"require": "./dist/index.cjs",
|
|
37
|
+
"import": "./dist/index.js"
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
package/src/index.js
CHANGED
|
@@ -16,7 +16,7 @@ const customScopes = []; // Track custom scopes
|
|
|
16
16
|
* @param {boolean} options.logRequests - Whether to log incoming requests
|
|
17
17
|
* @returns {Object} An object with control methods for the mocks
|
|
18
18
|
*/
|
|
19
|
-
function mockOpenAIResponse(force = false, options = {}) {
|
|
19
|
+
export function mockOpenAIResponse(force = false, options = {}) {
|
|
20
20
|
const {
|
|
21
21
|
includeErrors = false,
|
|
22
22
|
latency = 0,
|
|
@@ -119,9 +119,7 @@ function mockOpenAIResponse(force = false, options = {}) {
|
|
|
119
119
|
};
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
function stopMocking() {
|
|
122
|
+
export function stopMocking() {
|
|
123
123
|
nock.cleanAll();
|
|
124
124
|
customScopes.forEach(scope => scope.persist(false)); // Disable persistence
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export { mockOpenAIResponse, stopMocking };
|
|
125
|
+
}
|
package/vite.config.js
CHANGED
|
@@ -10,7 +10,7 @@ export default defineConfig({
|
|
|
10
10
|
entry: './src/index.js',
|
|
11
11
|
name: 'openai-api-mock',
|
|
12
12
|
formats: ['es', 'cjs'],
|
|
13
|
-
fileName: (format) => `index.${format}
|
|
13
|
+
fileName: (format) => `index.${format === 'es' ? 'js' : 'cjs'}`
|
|
14
14
|
},
|
|
15
15
|
rollupOptions: {
|
|
16
16
|
external: [
|
|
@@ -21,6 +21,7 @@ export default defineConfig({
|
|
|
21
21
|
'openai'
|
|
22
22
|
],
|
|
23
23
|
output: {
|
|
24
|
+
exports: "auto",
|
|
24
25
|
// Provide global variables to use in UMD build
|
|
25
26
|
globals: {
|
|
26
27
|
nock: 'nock',
|