modelfusion 0.57.0 → 0.57.1
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/core/api/ApiCallError.cjs +11 -0
- package/core/api/ApiCallError.d.ts +9 -0
- package/core/api/ApiCallError.js +11 -0
- package/core/api/LoadAPIKeyError.cjs +16 -0
- package/core/api/LoadAPIKeyError.d.ts +9 -0
- package/core/api/LoadAPIKeyError.js +12 -0
- package/core/api/RetryError.cjs +8 -0
- package/core/api/RetryError.d.ts +6 -0
- package/core/api/RetryError.js +8 -0
- package/core/api/loadApiKey.cjs +7 -2
- package/core/api/loadApiKey.js +7 -2
- package/package.json +1 -1
- package/server/fastify/FileSystemLogger.cjs +7 -6
- package/server/fastify/FileSystemLogger.d.ts +1 -1
- package/server/fastify/FileSystemLogger.js +7 -6
- package/server/fastify/modelFusionFlowPlugin.cjs +1 -0
- package/server/fastify/modelFusionFlowPlugin.js +1 -0
- package/util/JSONParseError.cjs +8 -0
- package/util/JSONParseError.d.ts +6 -0
- package/util/JSONParseError.js +8 -0
@@ -41,5 +41,16 @@ class ApiCallError extends Error {
|
|
41
41
|
this.cause = cause;
|
42
42
|
this.isRetryable = isRetryable;
|
43
43
|
}
|
44
|
+
toJSON() {
|
45
|
+
return {
|
46
|
+
name: this.name,
|
47
|
+
message: this.message,
|
48
|
+
url: this.url,
|
49
|
+
requestBodyValues: this.requestBodyValues,
|
50
|
+
statusCode: this.statusCode,
|
51
|
+
cause: this.cause,
|
52
|
+
isRetryable: this.isRetryable,
|
53
|
+
};
|
54
|
+
}
|
44
55
|
}
|
45
56
|
exports.ApiCallError = ApiCallError;
|
@@ -12,4 +12,13 @@ export declare class ApiCallError extends Error {
|
|
12
12
|
cause?: unknown;
|
13
13
|
isRetryable?: boolean;
|
14
14
|
});
|
15
|
+
toJSON(): {
|
16
|
+
name: string;
|
17
|
+
message: string;
|
18
|
+
url: string;
|
19
|
+
requestBodyValues: unknown;
|
20
|
+
statusCode: number;
|
21
|
+
cause: unknown;
|
22
|
+
isRetryable: boolean;
|
23
|
+
};
|
15
24
|
}
|
package/core/api/ApiCallError.js
CHANGED
@@ -38,4 +38,15 @@ export class ApiCallError extends Error {
|
|
38
38
|
this.cause = cause;
|
39
39
|
this.isRetryable = isRetryable;
|
40
40
|
}
|
41
|
+
toJSON() {
|
42
|
+
return {
|
43
|
+
name: this.name,
|
44
|
+
message: this.message,
|
45
|
+
url: this.url,
|
46
|
+
requestBodyValues: this.requestBodyValues,
|
47
|
+
statusCode: this.statusCode,
|
48
|
+
cause: this.cause,
|
49
|
+
isRetryable: this.isRetryable,
|
50
|
+
};
|
51
|
+
}
|
41
52
|
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.LoadAPIKeyError = void 0;
|
4
|
+
class LoadAPIKeyError extends Error {
|
5
|
+
constructor({ message }) {
|
6
|
+
super(message);
|
7
|
+
this.name = "LoadAPIKeyError";
|
8
|
+
}
|
9
|
+
toJSON() {
|
10
|
+
return {
|
11
|
+
name: this.name,
|
12
|
+
message: this.message,
|
13
|
+
};
|
14
|
+
}
|
15
|
+
}
|
16
|
+
exports.LoadAPIKeyError = LoadAPIKeyError;
|
package/core/api/RetryError.cjs
CHANGED
@@ -20,5 +20,13 @@ class RetryError extends Error {
|
|
20
20
|
this.reason = reason;
|
21
21
|
this.errors = errors;
|
22
22
|
}
|
23
|
+
toJSON() {
|
24
|
+
return {
|
25
|
+
name: this.name,
|
26
|
+
message: this.message,
|
27
|
+
reason: this.reason,
|
28
|
+
errors: this.errors,
|
29
|
+
};
|
30
|
+
}
|
23
31
|
}
|
24
32
|
exports.RetryError = RetryError;
|
package/core/api/RetryError.d.ts
CHANGED
package/core/api/RetryError.js
CHANGED
package/core/api/loadApiKey.cjs
CHANGED
@@ -1,16 +1,21 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.loadApiKey = void 0;
|
4
|
+
const LoadAPIKeyError_1 = require("./LoadAPIKeyError");
|
4
5
|
function loadApiKey({ apiKey, environmentVariableName, apiKeyParameterName = "apiKey", description, }) {
|
5
6
|
if (apiKey != null) {
|
6
7
|
return apiKey;
|
7
8
|
}
|
8
9
|
if (typeof process === "undefined") {
|
9
|
-
throw new
|
10
|
+
throw new LoadAPIKeyError_1.LoadAPIKeyError({
|
11
|
+
message: `${description} API key is missing. Pass it using the '${apiKeyParameterName}' parameter into the API configuration. Environment variables is not supported in this environment.`,
|
12
|
+
});
|
10
13
|
}
|
11
14
|
apiKey = process.env[environmentVariableName];
|
12
15
|
if (apiKey == null) {
|
13
|
-
throw new
|
16
|
+
throw new LoadAPIKeyError_1.LoadAPIKeyError({
|
17
|
+
message: `${description} API key is missing. Pass it using the '${apiKeyParameterName}' parameter into the API configuration or set it as an environment variable named ${environmentVariableName}.`,
|
18
|
+
});
|
14
19
|
}
|
15
20
|
return apiKey;
|
16
21
|
}
|
package/core/api/loadApiKey.js
CHANGED
@@ -1,13 +1,18 @@
|
|
1
|
+
import { LoadAPIKeyError } from "./LoadAPIKeyError";
|
1
2
|
export function loadApiKey({ apiKey, environmentVariableName, apiKeyParameterName = "apiKey", description, }) {
|
2
3
|
if (apiKey != null) {
|
3
4
|
return apiKey;
|
4
5
|
}
|
5
6
|
if (typeof process === "undefined") {
|
6
|
-
throw new
|
7
|
+
throw new LoadAPIKeyError({
|
8
|
+
message: `${description} API key is missing. Pass it using the '${apiKeyParameterName}' parameter into the API configuration. Environment variables is not supported in this environment.`,
|
9
|
+
});
|
7
10
|
}
|
8
11
|
apiKey = process.env[environmentVariableName];
|
9
12
|
if (apiKey == null) {
|
10
|
-
throw new
|
13
|
+
throw new LoadAPIKeyError({
|
14
|
+
message: `${description} API key is missing. Pass it using the '${apiKeyParameterName}' parameter into the API configuration or set it as an environment variable named ${environmentVariableName}.`,
|
15
|
+
});
|
11
16
|
}
|
12
17
|
return apiKey;
|
13
18
|
}
|
package/package.json
CHANGED
@@ -28,15 +28,16 @@ class FileSystemLogger {
|
|
28
28
|
});
|
29
29
|
}
|
30
30
|
}
|
31
|
-
async logError(
|
31
|
+
async logError({ run, error, message, }) {
|
32
32
|
const timestamp = Date.now();
|
33
33
|
try {
|
34
|
-
const logPath = this.logPath(
|
35
|
-
|
34
|
+
const logPath = this.logPath(run);
|
35
|
+
await node_fs_1.promises.mkdir(logPath, { recursive: true });
|
36
|
+
await node_fs_1.promises.writeFile((0, node_path_1.join)(logPath, `${timestamp}-error.json`), JSON.stringify({
|
36
37
|
timestamp: new Date(timestamp).toISOString(),
|
37
|
-
runId:
|
38
|
-
message
|
39
|
-
error
|
38
|
+
runId: run.runId,
|
39
|
+
message,
|
40
|
+
error,
|
40
41
|
}));
|
41
42
|
}
|
42
43
|
catch (error) {
|
@@ -25,15 +25,16 @@ export class FileSystemLogger {
|
|
25
25
|
});
|
26
26
|
}
|
27
27
|
}
|
28
|
-
async logError(
|
28
|
+
async logError({ run, error, message, }) {
|
29
29
|
const timestamp = Date.now();
|
30
30
|
try {
|
31
|
-
const logPath = this.logPath(
|
32
|
-
|
31
|
+
const logPath = this.logPath(run);
|
32
|
+
await fs.mkdir(logPath, { recursive: true });
|
33
|
+
await fs.writeFile(join(logPath, `${timestamp}-error.json`), JSON.stringify({
|
33
34
|
timestamp: new Date(timestamp).toISOString(),
|
34
|
-
runId:
|
35
|
-
message
|
36
|
-
error
|
35
|
+
runId: run.runId,
|
36
|
+
message,
|
37
|
+
error,
|
37
38
|
}));
|
38
39
|
}
|
39
40
|
catch (error) {
|
package/util/JSONParseError.cjs
CHANGED
@@ -29,5 +29,13 @@ class JSONParseError extends Error {
|
|
29
29
|
this.cause = cause;
|
30
30
|
this.valueText = valueText;
|
31
31
|
}
|
32
|
+
toJSON() {
|
33
|
+
return {
|
34
|
+
name: this.name,
|
35
|
+
message: this.message,
|
36
|
+
cause: this.cause,
|
37
|
+
valueText: this.valueText,
|
38
|
+
};
|
39
|
+
}
|
32
40
|
}
|
33
41
|
exports.JSONParseError = JSONParseError;
|
package/util/JSONParseError.d.ts
CHANGED
package/util/JSONParseError.js
CHANGED