@voltagent/internal 0.0.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/LICENCE +21 -0
- package/README.md +31 -0
- package/dist/dev/index.d.mts +101 -0
- package/dist/dev/index.d.ts +101 -0
- package/dist/dev/index.js +111 -0
- package/dist/dev/index.js.map +1 -0
- package/dist/dev/index.mjs +85 -0
- package/dist/dev/index.mjs.map +1 -0
- package/dist/main/index.d.mts +132 -0
- package/dist/main/index.d.ts +132 -0
- package/dist/main/index.js +227 -0
- package/dist/main/index.js.map +1 -0
- package/dist/main/index.mjs +196 -0
- package/dist/main/index.mjs.map +1 -0
- package/dist/test/index.d.mts +32 -0
- package/dist/test/index.d.ts +32 -0
- package/dist/test/index.js +145 -0
- package/dist/test/index.js.map +1 -0
- package/dist/test/index.mjs +116 -0
- package/dist/test/index.mjs.map +1 -0
- package/package.json +48 -0
package/LICENCE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 VoltAgent Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# `@voltagent/internal`
|
|
2
|
+
|
|
3
|
+
An internal set of tools for the VoltAgent packages.
|
|
4
|
+
|
|
5
|
+
## 🚀 Quick Start
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @voltagent/internal
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import { devLogger } from "@voltagent/internal";
|
|
13
|
+
|
|
14
|
+
// will only log if process.env.NODE_ENV is "development"
|
|
15
|
+
devLogger.info("Hello, world!");
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## 📦 Imports
|
|
19
|
+
|
|
20
|
+
You can also import specific subsets of the package:
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { devLogger } from "@voltagent/internal/dev";
|
|
24
|
+
import { convertArrayToAsyncIterable } from "@voltagent/internal/test";
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Allowing you to only import the tools you need.
|
|
28
|
+
|
|
29
|
+
## 📄 License
|
|
30
|
+
|
|
31
|
+
MIT License - see LICENSE file for details.
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
interface DevLoggerOptions {
|
|
2
|
+
dev: boolean | (() => boolean);
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* A logger for development purposes, that will not pollute the production logs (aka if process.env.NODE_ENV is not "development").
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* devLogger.info("Hello, world!");
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
declare function createDevLogger(options?: DevLoggerOptions): {
|
|
13
|
+
/**
|
|
14
|
+
* Log a message to the console if the environment is development. This will NOT be logged if process.env.NODE_ENV is not "development".
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* devLogger.info("Hello, world!");
|
|
19
|
+
*
|
|
20
|
+
* // output: [VoltAgent] [2021-01-01T00:00:00.000Z] INFO: Hello, world!
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @param message - The message to log.
|
|
24
|
+
* @param args - The arguments to log.
|
|
25
|
+
*/
|
|
26
|
+
info: (message?: any, ...args: any[]) => void;
|
|
27
|
+
/**
|
|
28
|
+
* Log a warning message to the console if the environment is development. This will NOT be logged if process.env.NODE_ENV is not "development".
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* devLogger.warn("Hello, world!");
|
|
33
|
+
*
|
|
34
|
+
* // output: [VoltAgent] [2021-01-01T00:00:00.000Z] WARN: Hello, world!
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @param message - The message to log.
|
|
38
|
+
* @param args - The arguments to log.
|
|
39
|
+
*/
|
|
40
|
+
warn: (message?: any, ...args: any[]) => void;
|
|
41
|
+
/**
|
|
42
|
+
* Log a warning message to the console if the environment is development.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* devLogger.error("Hello, world!");
|
|
47
|
+
*
|
|
48
|
+
* // output: [VoltAgent] [2021-01-01T00:00:00.000Z] ERROR: Hello, world!
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @param message - The message to log.
|
|
52
|
+
* @param args - The arguments to log.
|
|
53
|
+
*/
|
|
54
|
+
error: (message?: any, ...args: any[]) => void;
|
|
55
|
+
};
|
|
56
|
+
declare const _default: {
|
|
57
|
+
/**
|
|
58
|
+
* Log a message to the console if the environment is development. This will NOT be logged if process.env.NODE_ENV is not "development".
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* devLogger.info("Hello, world!");
|
|
63
|
+
*
|
|
64
|
+
* // output: [VoltAgent] [2021-01-01T00:00:00.000Z] INFO: Hello, world!
|
|
65
|
+
* ```
|
|
66
|
+
*
|
|
67
|
+
* @param message - The message to log.
|
|
68
|
+
* @param args - The arguments to log.
|
|
69
|
+
*/
|
|
70
|
+
info: (message?: any, ...args: any[]) => void;
|
|
71
|
+
/**
|
|
72
|
+
* Log a warning message to the console if the environment is development. This will NOT be logged if process.env.NODE_ENV is not "development".
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* devLogger.warn("Hello, world!");
|
|
77
|
+
*
|
|
78
|
+
* // output: [VoltAgent] [2021-01-01T00:00:00.000Z] WARN: Hello, world!
|
|
79
|
+
* ```
|
|
80
|
+
*
|
|
81
|
+
* @param message - The message to log.
|
|
82
|
+
* @param args - The arguments to log.
|
|
83
|
+
*/
|
|
84
|
+
warn: (message?: any, ...args: any[]) => void;
|
|
85
|
+
/**
|
|
86
|
+
* Log a warning message to the console if the environment is development.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* devLogger.error("Hello, world!");
|
|
91
|
+
*
|
|
92
|
+
* // output: [VoltAgent] [2021-01-01T00:00:00.000Z] ERROR: Hello, world!
|
|
93
|
+
* ```
|
|
94
|
+
*
|
|
95
|
+
* @param message - The message to log.
|
|
96
|
+
* @param args - The arguments to log.
|
|
97
|
+
*/
|
|
98
|
+
error: (message?: any, ...args: any[]) => void;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export { type DevLoggerOptions, createDevLogger, _default as devLogger };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
interface DevLoggerOptions {
|
|
2
|
+
dev: boolean | (() => boolean);
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* A logger for development purposes, that will not pollute the production logs (aka if process.env.NODE_ENV is not "development").
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* devLogger.info("Hello, world!");
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
declare function createDevLogger(options?: DevLoggerOptions): {
|
|
13
|
+
/**
|
|
14
|
+
* Log a message to the console if the environment is development. This will NOT be logged if process.env.NODE_ENV is not "development".
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* devLogger.info("Hello, world!");
|
|
19
|
+
*
|
|
20
|
+
* // output: [VoltAgent] [2021-01-01T00:00:00.000Z] INFO: Hello, world!
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @param message - The message to log.
|
|
24
|
+
* @param args - The arguments to log.
|
|
25
|
+
*/
|
|
26
|
+
info: (message?: any, ...args: any[]) => void;
|
|
27
|
+
/**
|
|
28
|
+
* Log a warning message to the console if the environment is development. This will NOT be logged if process.env.NODE_ENV is not "development".
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* devLogger.warn("Hello, world!");
|
|
33
|
+
*
|
|
34
|
+
* // output: [VoltAgent] [2021-01-01T00:00:00.000Z] WARN: Hello, world!
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @param message - The message to log.
|
|
38
|
+
* @param args - The arguments to log.
|
|
39
|
+
*/
|
|
40
|
+
warn: (message?: any, ...args: any[]) => void;
|
|
41
|
+
/**
|
|
42
|
+
* Log a warning message to the console if the environment is development.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* devLogger.error("Hello, world!");
|
|
47
|
+
*
|
|
48
|
+
* // output: [VoltAgent] [2021-01-01T00:00:00.000Z] ERROR: Hello, world!
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @param message - The message to log.
|
|
52
|
+
* @param args - The arguments to log.
|
|
53
|
+
*/
|
|
54
|
+
error: (message?: any, ...args: any[]) => void;
|
|
55
|
+
};
|
|
56
|
+
declare const _default: {
|
|
57
|
+
/**
|
|
58
|
+
* Log a message to the console if the environment is development. This will NOT be logged if process.env.NODE_ENV is not "development".
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* devLogger.info("Hello, world!");
|
|
63
|
+
*
|
|
64
|
+
* // output: [VoltAgent] [2021-01-01T00:00:00.000Z] INFO: Hello, world!
|
|
65
|
+
* ```
|
|
66
|
+
*
|
|
67
|
+
* @param message - The message to log.
|
|
68
|
+
* @param args - The arguments to log.
|
|
69
|
+
*/
|
|
70
|
+
info: (message?: any, ...args: any[]) => void;
|
|
71
|
+
/**
|
|
72
|
+
* Log a warning message to the console if the environment is development. This will NOT be logged if process.env.NODE_ENV is not "development".
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* devLogger.warn("Hello, world!");
|
|
77
|
+
*
|
|
78
|
+
* // output: [VoltAgent] [2021-01-01T00:00:00.000Z] WARN: Hello, world!
|
|
79
|
+
* ```
|
|
80
|
+
*
|
|
81
|
+
* @param message - The message to log.
|
|
82
|
+
* @param args - The arguments to log.
|
|
83
|
+
*/
|
|
84
|
+
warn: (message?: any, ...args: any[]) => void;
|
|
85
|
+
/**
|
|
86
|
+
* Log a warning message to the console if the environment is development.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* devLogger.error("Hello, world!");
|
|
91
|
+
*
|
|
92
|
+
* // output: [VoltAgent] [2021-01-01T00:00:00.000Z] ERROR: Hello, world!
|
|
93
|
+
* ```
|
|
94
|
+
*
|
|
95
|
+
* @param message - The message to log.
|
|
96
|
+
* @param args - The arguments to log.
|
|
97
|
+
*/
|
|
98
|
+
error: (message?: any, ...args: any[]) => void;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export { type DevLoggerOptions, createDevLogger, _default as devLogger };
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/dev/index.ts
|
|
22
|
+
var index_exports = {};
|
|
23
|
+
__export(index_exports, {
|
|
24
|
+
createDevLogger: () => createDevLogger,
|
|
25
|
+
devLogger: () => logger_default
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(index_exports);
|
|
28
|
+
|
|
29
|
+
// src/dev/logger.ts
|
|
30
|
+
function createDevLogger(options) {
|
|
31
|
+
const isDev = typeof (options == null ? void 0 : options.dev) === "function" ? options.dev : () => {
|
|
32
|
+
var _a;
|
|
33
|
+
return (_a = options == null ? void 0 : options.dev) != null ? _a : isDevNodeEnv();
|
|
34
|
+
};
|
|
35
|
+
return {
|
|
36
|
+
/**
|
|
37
|
+
* Log a message to the console if the environment is development. This will NOT be logged if process.env.NODE_ENV is not "development".
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* devLogger.info("Hello, world!");
|
|
42
|
+
*
|
|
43
|
+
* // output: [VoltAgent] [2021-01-01T00:00:00.000Z] INFO: Hello, world!
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @param message - The message to log.
|
|
47
|
+
* @param args - The arguments to log.
|
|
48
|
+
*/
|
|
49
|
+
info: /* @__PURE__ */ __name((message, ...args) => {
|
|
50
|
+
if (isDev()) {
|
|
51
|
+
console.info(formatLogPrefix("INFO"), message, ...args);
|
|
52
|
+
}
|
|
53
|
+
}, "info"),
|
|
54
|
+
/**
|
|
55
|
+
* Log a warning message to the console if the environment is development. This will NOT be logged if process.env.NODE_ENV is not "development".
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* devLogger.warn("Hello, world!");
|
|
60
|
+
*
|
|
61
|
+
* // output: [VoltAgent] [2021-01-01T00:00:00.000Z] WARN: Hello, world!
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @param message - The message to log.
|
|
65
|
+
* @param args - The arguments to log.
|
|
66
|
+
*/
|
|
67
|
+
warn: /* @__PURE__ */ __name((message, ...args) => {
|
|
68
|
+
if (isDev()) {
|
|
69
|
+
console.warn(formatLogPrefix("WARN"), message, ...args);
|
|
70
|
+
}
|
|
71
|
+
}, "warn"),
|
|
72
|
+
/**
|
|
73
|
+
* Log a warning message to the console if the environment is development.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* devLogger.error("Hello, world!");
|
|
78
|
+
*
|
|
79
|
+
* // output: [VoltAgent] [2021-01-01T00:00:00.000Z] ERROR: Hello, world!
|
|
80
|
+
* ```
|
|
81
|
+
*
|
|
82
|
+
* @param message - The message to log.
|
|
83
|
+
* @param args - The arguments to log.
|
|
84
|
+
*/
|
|
85
|
+
error: /* @__PURE__ */ __name((message, ...args) => {
|
|
86
|
+
if (isDev()) {
|
|
87
|
+
console.error(formatLogPrefix("ERROR"), message, ...args);
|
|
88
|
+
}
|
|
89
|
+
}, "error")
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
__name(createDevLogger, "createDevLogger");
|
|
93
|
+
var logger_default = createDevLogger();
|
|
94
|
+
function isDevNodeEnv() {
|
|
95
|
+
return process.env.NODE_ENV === "development";
|
|
96
|
+
}
|
|
97
|
+
__name(isDevNodeEnv, "isDevNodeEnv");
|
|
98
|
+
function formatLogPrefix(level) {
|
|
99
|
+
return `[VoltAgent] [${timestamp()}] ${level}: `;
|
|
100
|
+
}
|
|
101
|
+
__name(formatLogPrefix, "formatLogPrefix");
|
|
102
|
+
function timestamp() {
|
|
103
|
+
return (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").slice(0, -1);
|
|
104
|
+
}
|
|
105
|
+
__name(timestamp, "timestamp");
|
|
106
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
107
|
+
0 && (module.exports = {
|
|
108
|
+
createDevLogger,
|
|
109
|
+
devLogger
|
|
110
|
+
});
|
|
111
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/dev/index.ts","../../src/dev/logger.ts"],"sourcesContent":["export { createDevLogger, default as devLogger } from \"./logger\";\nexport type { DevLoggerOptions } from \"./logger\";\n","export interface DevLoggerOptions {\n dev: boolean | (() => boolean);\n}\n\n/**\n * A logger for development purposes, that will not pollute the production logs (aka if process.env.NODE_ENV is not \"development\").\n *\n * @example\n * ```typescript\n * devLogger.info(\"Hello, world!\");\n * ```\n */\nexport function createDevLogger(options?: DevLoggerOptions) {\n const isDev =\n typeof options?.dev === \"function\" ? options.dev : () => options?.dev ?? isDevNodeEnv();\n\n return {\n /**\n * Log a message to the console if the environment is development. This will NOT be logged if process.env.NODE_ENV is not \"development\".\n *\n * @example\n * ```typescript\n * devLogger.info(\"Hello, world!\");\n *\n * // output: [VoltAgent] [2021-01-01T00:00:00.000Z] INFO: Hello, world!\n * ```\n *\n * @param message - The message to log.\n * @param args - The arguments to log.\n */\n info: (message?: any, ...args: any[]) => {\n if (isDev()) {\n console.info(formatLogPrefix(\"INFO\"), message, ...args);\n }\n },\n /**\n * Log a warning message to the console if the environment is development. This will NOT be logged if process.env.NODE_ENV is not \"development\".\n *\n * @example\n * ```typescript\n * devLogger.warn(\"Hello, world!\");\n *\n * // output: [VoltAgent] [2021-01-01T00:00:00.000Z] WARN: Hello, world!\n * ```\n *\n * @param message - The message to log.\n * @param args - The arguments to log.\n */\n warn: (message?: any, ...args: any[]) => {\n if (isDev()) {\n console.warn(formatLogPrefix(\"WARN\"), message, ...args);\n }\n },\n /**\n * Log a warning message to the console if the environment is development.\n *\n * @example\n * ```typescript\n * devLogger.error(\"Hello, world!\");\n *\n * // output: [VoltAgent] [2021-01-01T00:00:00.000Z] ERROR: Hello, world!\n * ```\n *\n * @param message - The message to log.\n * @param args - The arguments to log.\n */\n error: (message?: any, ...args: any[]) => {\n if (isDev()) {\n console.error(formatLogPrefix(\"ERROR\"), message, ...args);\n }\n },\n };\n}\n\nexport default createDevLogger();\n\nfunction isDevNodeEnv() {\n return process.env.NODE_ENV === \"development\";\n}\n\nfunction formatLogPrefix(level: \"INFO\" | \"WARN\" | \"ERROR\"): string {\n return `[VoltAgent] [${timestamp()}] ${level}: `;\n}\n\nfunction timestamp(): string {\n return new Date().toISOString().replace(\"T\", \" \").slice(0, -1);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACYO,SAAS,gBAAgB,SAA4B;AAC1D,QAAM,QACJ,QAAO,mCAAS,SAAQ,aAAa,QAAQ,MAAM,MAAG;AAd1D;AAc6D,oDAAS,QAAT,YAAgB,aAAa;AAAA;AAExF,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAcL,MAAM,wBAAC,YAAkB,SAAgB;AACvC,UAAI,MAAM,GAAG;AACX,gBAAQ,KAAK,gBAAgB,MAAM,GAAG,SAAS,GAAG,IAAI;AAAA,MACxD;AAAA,IACF,GAJM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAkBN,MAAM,wBAAC,YAAkB,SAAgB;AACvC,UAAI,MAAM,GAAG;AACX,gBAAQ,KAAK,gBAAgB,MAAM,GAAG,SAAS,GAAG,IAAI;AAAA,MACxD;AAAA,IACF,GAJM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAkBN,OAAO,wBAAC,YAAkB,SAAgB;AACxC,UAAI,MAAM,GAAG;AACX,gBAAQ,MAAM,gBAAgB,OAAO,GAAG,SAAS,GAAG,IAAI;AAAA,MAC1D;AAAA,IACF,GAJO;AAAA,EAKT;AACF;AA5DgB;AA8DhB,IAAO,iBAAQ,gBAAgB;AAE/B,SAAS,eAAe;AACtB,SAAO,QAAQ,IAAI,aAAa;AAClC;AAFS;AAIT,SAAS,gBAAgB,OAA0C;AACjE,SAAO,gBAAgB,UAAU,CAAC,KAAK,KAAK;AAC9C;AAFS;AAIT,SAAS,YAAoB;AAC3B,UAAO,oBAAI,KAAK,GAAE,YAAY,EAAE,QAAQ,KAAK,GAAG,EAAE,MAAM,GAAG,EAAE;AAC/D;AAFS;","names":[]}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// src/dev/logger.ts
|
|
5
|
+
function createDevLogger(options) {
|
|
6
|
+
const isDev = typeof (options == null ? void 0 : options.dev) === "function" ? options.dev : () => {
|
|
7
|
+
var _a;
|
|
8
|
+
return (_a = options == null ? void 0 : options.dev) != null ? _a : isDevNodeEnv();
|
|
9
|
+
};
|
|
10
|
+
return {
|
|
11
|
+
/**
|
|
12
|
+
* Log a message to the console if the environment is development. This will NOT be logged if process.env.NODE_ENV is not "development".
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* devLogger.info("Hello, world!");
|
|
17
|
+
*
|
|
18
|
+
* // output: [VoltAgent] [2021-01-01T00:00:00.000Z] INFO: Hello, world!
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @param message - The message to log.
|
|
22
|
+
* @param args - The arguments to log.
|
|
23
|
+
*/
|
|
24
|
+
info: /* @__PURE__ */ __name((message, ...args) => {
|
|
25
|
+
if (isDev()) {
|
|
26
|
+
console.info(formatLogPrefix("INFO"), message, ...args);
|
|
27
|
+
}
|
|
28
|
+
}, "info"),
|
|
29
|
+
/**
|
|
30
|
+
* Log a warning message to the console if the environment is development. This will NOT be logged if process.env.NODE_ENV is not "development".
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* devLogger.warn("Hello, world!");
|
|
35
|
+
*
|
|
36
|
+
* // output: [VoltAgent] [2021-01-01T00:00:00.000Z] WARN: Hello, world!
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @param message - The message to log.
|
|
40
|
+
* @param args - The arguments to log.
|
|
41
|
+
*/
|
|
42
|
+
warn: /* @__PURE__ */ __name((message, ...args) => {
|
|
43
|
+
if (isDev()) {
|
|
44
|
+
console.warn(formatLogPrefix("WARN"), message, ...args);
|
|
45
|
+
}
|
|
46
|
+
}, "warn"),
|
|
47
|
+
/**
|
|
48
|
+
* Log a warning message to the console if the environment is development.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* devLogger.error("Hello, world!");
|
|
53
|
+
*
|
|
54
|
+
* // output: [VoltAgent] [2021-01-01T00:00:00.000Z] ERROR: Hello, world!
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* @param message - The message to log.
|
|
58
|
+
* @param args - The arguments to log.
|
|
59
|
+
*/
|
|
60
|
+
error: /* @__PURE__ */ __name((message, ...args) => {
|
|
61
|
+
if (isDev()) {
|
|
62
|
+
console.error(formatLogPrefix("ERROR"), message, ...args);
|
|
63
|
+
}
|
|
64
|
+
}, "error")
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
__name(createDevLogger, "createDevLogger");
|
|
68
|
+
var logger_default = createDevLogger();
|
|
69
|
+
function isDevNodeEnv() {
|
|
70
|
+
return process.env.NODE_ENV === "development";
|
|
71
|
+
}
|
|
72
|
+
__name(isDevNodeEnv, "isDevNodeEnv");
|
|
73
|
+
function formatLogPrefix(level) {
|
|
74
|
+
return `[VoltAgent] [${timestamp()}] ${level}: `;
|
|
75
|
+
}
|
|
76
|
+
__name(formatLogPrefix, "formatLogPrefix");
|
|
77
|
+
function timestamp() {
|
|
78
|
+
return (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").slice(0, -1);
|
|
79
|
+
}
|
|
80
|
+
__name(timestamp, "timestamp");
|
|
81
|
+
export {
|
|
82
|
+
createDevLogger,
|
|
83
|
+
logger_default as devLogger
|
|
84
|
+
};
|
|
85
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/dev/logger.ts"],"sourcesContent":["export interface DevLoggerOptions {\n dev: boolean | (() => boolean);\n}\n\n/**\n * A logger for development purposes, that will not pollute the production logs (aka if process.env.NODE_ENV is not \"development\").\n *\n * @example\n * ```typescript\n * devLogger.info(\"Hello, world!\");\n * ```\n */\nexport function createDevLogger(options?: DevLoggerOptions) {\n const isDev =\n typeof options?.dev === \"function\" ? options.dev : () => options?.dev ?? isDevNodeEnv();\n\n return {\n /**\n * Log a message to the console if the environment is development. This will NOT be logged if process.env.NODE_ENV is not \"development\".\n *\n * @example\n * ```typescript\n * devLogger.info(\"Hello, world!\");\n *\n * // output: [VoltAgent] [2021-01-01T00:00:00.000Z] INFO: Hello, world!\n * ```\n *\n * @param message - The message to log.\n * @param args - The arguments to log.\n */\n info: (message?: any, ...args: any[]) => {\n if (isDev()) {\n console.info(formatLogPrefix(\"INFO\"), message, ...args);\n }\n },\n /**\n * Log a warning message to the console if the environment is development. This will NOT be logged if process.env.NODE_ENV is not \"development\".\n *\n * @example\n * ```typescript\n * devLogger.warn(\"Hello, world!\");\n *\n * // output: [VoltAgent] [2021-01-01T00:00:00.000Z] WARN: Hello, world!\n * ```\n *\n * @param message - The message to log.\n * @param args - The arguments to log.\n */\n warn: (message?: any, ...args: any[]) => {\n if (isDev()) {\n console.warn(formatLogPrefix(\"WARN\"), message, ...args);\n }\n },\n /**\n * Log a warning message to the console if the environment is development.\n *\n * @example\n * ```typescript\n * devLogger.error(\"Hello, world!\");\n *\n * // output: [VoltAgent] [2021-01-01T00:00:00.000Z] ERROR: Hello, world!\n * ```\n *\n * @param message - The message to log.\n * @param args - The arguments to log.\n */\n error: (message?: any, ...args: any[]) => {\n if (isDev()) {\n console.error(formatLogPrefix(\"ERROR\"), message, ...args);\n }\n },\n };\n}\n\nexport default createDevLogger();\n\nfunction isDevNodeEnv() {\n return process.env.NODE_ENV === \"development\";\n}\n\nfunction formatLogPrefix(level: \"INFO\" | \"WARN\" | \"ERROR\"): string {\n return `[VoltAgent] [${timestamp()}] ${level}: `;\n}\n\nfunction timestamp(): string {\n return new Date().toISOString().replace(\"T\", \" \").slice(0, -1);\n}\n"],"mappings":";;;;AAYO,SAAS,gBAAgB,SAA4B;AAC1D,QAAM,QACJ,QAAO,mCAAS,SAAQ,aAAa,QAAQ,MAAM,MAAG;AAd1D;AAc6D,oDAAS,QAAT,YAAgB,aAAa;AAAA;AAExF,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAcL,MAAM,wBAAC,YAAkB,SAAgB;AACvC,UAAI,MAAM,GAAG;AACX,gBAAQ,KAAK,gBAAgB,MAAM,GAAG,SAAS,GAAG,IAAI;AAAA,MACxD;AAAA,IACF,GAJM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAkBN,MAAM,wBAAC,YAAkB,SAAgB;AACvC,UAAI,MAAM,GAAG;AACX,gBAAQ,KAAK,gBAAgB,MAAM,GAAG,SAAS,GAAG,IAAI;AAAA,MACxD;AAAA,IACF,GAJM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAkBN,OAAO,wBAAC,YAAkB,SAAgB;AACxC,UAAI,MAAM,GAAG;AACX,gBAAQ,MAAM,gBAAgB,OAAO,GAAG,SAAS,GAAG,IAAI;AAAA,MAC1D;AAAA,IACF,GAJO;AAAA,EAKT;AACF;AA5DgB;AA8DhB,IAAO,iBAAQ,gBAAgB;AAE/B,SAAS,eAAe;AACtB,SAAO,QAAQ,IAAI,aAAa;AAClC;AAFS;AAIT,SAAS,gBAAgB,OAA0C;AACjE,SAAO,gBAAgB,UAAU,CAAC,KAAK,KAAK;AAC9C;AAFS;AAIT,SAAS,YAAoB;AAC3B,UAAO,oBAAI,KAAK,GAAE,YAAY,EAAE,QAAQ,KAAK,GAAG,EAAE,MAAM,GAAG,EAAE;AAC/D;AAFS;","names":[]}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
interface DevLoggerOptions {
|
|
2
|
+
dev: boolean | (() => boolean);
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* A logger for development purposes, that will not pollute the production logs (aka if process.env.NODE_ENV is not "development").
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* devLogger.info("Hello, world!");
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
declare function createDevLogger(options?: DevLoggerOptions): {
|
|
13
|
+
/**
|
|
14
|
+
* Log a message to the console if the environment is development. This will NOT be logged if process.env.NODE_ENV is not "development".
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* devLogger.info("Hello, world!");
|
|
19
|
+
*
|
|
20
|
+
* // output: [VoltAgent] [2021-01-01T00:00:00.000Z] INFO: Hello, world!
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @param message - The message to log.
|
|
24
|
+
* @param args - The arguments to log.
|
|
25
|
+
*/
|
|
26
|
+
info: (message?: any, ...args: any[]) => void;
|
|
27
|
+
/**
|
|
28
|
+
* Log a warning message to the console if the environment is development. This will NOT be logged if process.env.NODE_ENV is not "development".
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* devLogger.warn("Hello, world!");
|
|
33
|
+
*
|
|
34
|
+
* // output: [VoltAgent] [2021-01-01T00:00:00.000Z] WARN: Hello, world!
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @param message - The message to log.
|
|
38
|
+
* @param args - The arguments to log.
|
|
39
|
+
*/
|
|
40
|
+
warn: (message?: any, ...args: any[]) => void;
|
|
41
|
+
/**
|
|
42
|
+
* Log a warning message to the console if the environment is development.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* devLogger.error("Hello, world!");
|
|
47
|
+
*
|
|
48
|
+
* // output: [VoltAgent] [2021-01-01T00:00:00.000Z] ERROR: Hello, world!
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @param message - The message to log.
|
|
52
|
+
* @param args - The arguments to log.
|
|
53
|
+
*/
|
|
54
|
+
error: (message?: any, ...args: any[]) => void;
|
|
55
|
+
};
|
|
56
|
+
declare const _default: {
|
|
57
|
+
/**
|
|
58
|
+
* Log a message to the console if the environment is development. This will NOT be logged if process.env.NODE_ENV is not "development".
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* devLogger.info("Hello, world!");
|
|
63
|
+
*
|
|
64
|
+
* // output: [VoltAgent] [2021-01-01T00:00:00.000Z] INFO: Hello, world!
|
|
65
|
+
* ```
|
|
66
|
+
*
|
|
67
|
+
* @param message - The message to log.
|
|
68
|
+
* @param args - The arguments to log.
|
|
69
|
+
*/
|
|
70
|
+
info: (message?: any, ...args: any[]) => void;
|
|
71
|
+
/**
|
|
72
|
+
* Log a warning message to the console if the environment is development. This will NOT be logged if process.env.NODE_ENV is not "development".
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* devLogger.warn("Hello, world!");
|
|
77
|
+
*
|
|
78
|
+
* // output: [VoltAgent] [2021-01-01T00:00:00.000Z] WARN: Hello, world!
|
|
79
|
+
* ```
|
|
80
|
+
*
|
|
81
|
+
* @param message - The message to log.
|
|
82
|
+
* @param args - The arguments to log.
|
|
83
|
+
*/
|
|
84
|
+
warn: (message?: any, ...args: any[]) => void;
|
|
85
|
+
/**
|
|
86
|
+
* Log a warning message to the console if the environment is development.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* devLogger.error("Hello, world!");
|
|
91
|
+
*
|
|
92
|
+
* // output: [VoltAgent] [2021-01-01T00:00:00.000Z] ERROR: Hello, world!
|
|
93
|
+
* ```
|
|
94
|
+
*
|
|
95
|
+
* @param message - The message to log.
|
|
96
|
+
* @param args - The arguments to log.
|
|
97
|
+
*/
|
|
98
|
+
error: (message?: any, ...args: any[]) => void;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Convert a readable stream to an array
|
|
103
|
+
* @param stream - The readable stream to convert
|
|
104
|
+
* @returns The array of values
|
|
105
|
+
*/
|
|
106
|
+
declare function convertReadableStreamToArray<T>(stream: ReadableStream<T>): Promise<T[]>;
|
|
107
|
+
/**
|
|
108
|
+
* Convert an array to an async iterable
|
|
109
|
+
* @param values - The array to convert
|
|
110
|
+
* @returns The async iterable
|
|
111
|
+
*/
|
|
112
|
+
declare function convertArrayToAsyncIterable<T>(values: T[]): AsyncIterable<T>;
|
|
113
|
+
/**
|
|
114
|
+
* Convert an async iterable to an array
|
|
115
|
+
* @param iterable - The async iterable to convert
|
|
116
|
+
* @returns The array of values
|
|
117
|
+
*/
|
|
118
|
+
declare function convertAsyncIterableToArray<T>(iterable: AsyncIterable<T>): Promise<T[]>;
|
|
119
|
+
/**
|
|
120
|
+
* Convert an array to a readable stream
|
|
121
|
+
* @param values - The array to convert
|
|
122
|
+
* @returns The readable stream
|
|
123
|
+
*/
|
|
124
|
+
declare function convertArrayToReadableStream<T>(values: T[]): ReadableStream<T>;
|
|
125
|
+
/**
|
|
126
|
+
* Convert a response stream to an array
|
|
127
|
+
* @param response - The response to convert
|
|
128
|
+
* @returns The array of values
|
|
129
|
+
*/
|
|
130
|
+
declare function convertResponseStreamToArray(response: Response): Promise<string[]>;
|
|
131
|
+
|
|
132
|
+
export { type DevLoggerOptions, convertArrayToAsyncIterable, convertArrayToReadableStream, convertAsyncIterableToArray, convertReadableStreamToArray, convertResponseStreamToArray, createDevLogger, _default as devLogger };
|