@voltagent/internal 0.0.5 → 0.0.6
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/README.md +6 -4
- package/dist/main/index.d.mts +107 -104
- package/dist/main/index.d.ts +107 -104
- package/dist/main/index.js +4 -88
- package/dist/main/index.js.map +1 -1
- package/dist/main/index.mjs +4 -86
- package/dist/main/index.mjs.map +1 -1
- package/dist/utils/index.d.mts +44 -1
- package/dist/utils/index.d.ts +44 -1
- package/dist/utils/index.js +4 -84
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +4 -84
- package/dist/utils/index.mjs.map +1 -1
- package/package.json +1 -6
- package/dist/dev/index.d.mts +0 -103
- package/dist/dev/index.d.ts +0 -103
- package/dist/dev/index.js +0 -115
- package/dist/dev/index.js.map +0 -1
- package/dist/dev/index.mjs +0 -89
- package/dist/dev/index.mjs.map +0 -1
package/dist/dev/index.d.mts
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
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
|
-
debug: (_message?: any, ..._args: any[]) => void;
|
|
56
|
-
};
|
|
57
|
-
declare const _default: {
|
|
58
|
-
/**
|
|
59
|
-
* Log a message to the console if the environment is development. This will NOT be logged if process.env.NODE_ENV is not "development".
|
|
60
|
-
*
|
|
61
|
-
* @example
|
|
62
|
-
* ```typescript
|
|
63
|
-
* devLogger.info("Hello, world!");
|
|
64
|
-
*
|
|
65
|
-
* // output: [VoltAgent] [2021-01-01T00:00:00.000Z] INFO: Hello, world!
|
|
66
|
-
* ```
|
|
67
|
-
*
|
|
68
|
-
* @param message - The message to log.
|
|
69
|
-
* @param args - The arguments to log.
|
|
70
|
-
*/
|
|
71
|
-
info: (message?: any, ...args: any[]) => void;
|
|
72
|
-
/**
|
|
73
|
-
* 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".
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* ```typescript
|
|
77
|
-
* devLogger.warn("Hello, world!");
|
|
78
|
-
*
|
|
79
|
-
* // output: [VoltAgent] [2021-01-01T00:00:00.000Z] WARN: Hello, world!
|
|
80
|
-
* ```
|
|
81
|
-
*
|
|
82
|
-
* @param message - The message to log.
|
|
83
|
-
* @param args - The arguments to log.
|
|
84
|
-
*/
|
|
85
|
-
warn: (message?: any, ...args: any[]) => void;
|
|
86
|
-
/**
|
|
87
|
-
* Log a warning message to the console if the environment is development.
|
|
88
|
-
*
|
|
89
|
-
* @example
|
|
90
|
-
* ```typescript
|
|
91
|
-
* devLogger.error("Hello, world!");
|
|
92
|
-
*
|
|
93
|
-
* // output: [VoltAgent] [2021-01-01T00:00:00.000Z] ERROR: Hello, world!
|
|
94
|
-
* ```
|
|
95
|
-
*
|
|
96
|
-
* @param message - The message to log.
|
|
97
|
-
* @param args - The arguments to log.
|
|
98
|
-
*/
|
|
99
|
-
error: (message?: any, ...args: any[]) => void;
|
|
100
|
-
debug: (_message?: any, ..._args: any[]) => void;
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
export { type DevLoggerOptions, createDevLogger, _default as devLogger };
|
package/dist/dev/index.d.ts
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
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
|
-
debug: (_message?: any, ..._args: any[]) => void;
|
|
56
|
-
};
|
|
57
|
-
declare const _default: {
|
|
58
|
-
/**
|
|
59
|
-
* Log a message to the console if the environment is development. This will NOT be logged if process.env.NODE_ENV is not "development".
|
|
60
|
-
*
|
|
61
|
-
* @example
|
|
62
|
-
* ```typescript
|
|
63
|
-
* devLogger.info("Hello, world!");
|
|
64
|
-
*
|
|
65
|
-
* // output: [VoltAgent] [2021-01-01T00:00:00.000Z] INFO: Hello, world!
|
|
66
|
-
* ```
|
|
67
|
-
*
|
|
68
|
-
* @param message - The message to log.
|
|
69
|
-
* @param args - The arguments to log.
|
|
70
|
-
*/
|
|
71
|
-
info: (message?: any, ...args: any[]) => void;
|
|
72
|
-
/**
|
|
73
|
-
* 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".
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* ```typescript
|
|
77
|
-
* devLogger.warn("Hello, world!");
|
|
78
|
-
*
|
|
79
|
-
* // output: [VoltAgent] [2021-01-01T00:00:00.000Z] WARN: Hello, world!
|
|
80
|
-
* ```
|
|
81
|
-
*
|
|
82
|
-
* @param message - The message to log.
|
|
83
|
-
* @param args - The arguments to log.
|
|
84
|
-
*/
|
|
85
|
-
warn: (message?: any, ...args: any[]) => void;
|
|
86
|
-
/**
|
|
87
|
-
* Log a warning message to the console if the environment is development.
|
|
88
|
-
*
|
|
89
|
-
* @example
|
|
90
|
-
* ```typescript
|
|
91
|
-
* devLogger.error("Hello, world!");
|
|
92
|
-
*
|
|
93
|
-
* // output: [VoltAgent] [2021-01-01T00:00:00.000Z] ERROR: Hello, world!
|
|
94
|
-
* ```
|
|
95
|
-
*
|
|
96
|
-
* @param message - The message to log.
|
|
97
|
-
* @param args - The arguments to log.
|
|
98
|
-
*/
|
|
99
|
-
error: (message?: any, ...args: any[]) => void;
|
|
100
|
-
debug: (_message?: any, ..._args: any[]) => void;
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
export { type DevLoggerOptions, createDevLogger, _default as devLogger };
|
package/dist/dev/index.js
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
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
|
-
debug: /* @__PURE__ */ __name((_message, ..._args) => {
|
|
91
|
-
return;
|
|
92
|
-
}, "debug")
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
__name(createDevLogger, "createDevLogger");
|
|
96
|
-
var logger_default = createDevLogger();
|
|
97
|
-
function isDevNodeEnv() {
|
|
98
|
-
const nodeEnv = process.env.NODE_ENV;
|
|
99
|
-
return nodeEnv !== "production" && nodeEnv !== "test" && nodeEnv !== "ci";
|
|
100
|
-
}
|
|
101
|
-
__name(isDevNodeEnv, "isDevNodeEnv");
|
|
102
|
-
function formatLogPrefix(level) {
|
|
103
|
-
return `[VoltAgent] [${timestamp()}] ${level}: `;
|
|
104
|
-
}
|
|
105
|
-
__name(formatLogPrefix, "formatLogPrefix");
|
|
106
|
-
function timestamp() {
|
|
107
|
-
return (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").slice(0, -1);
|
|
108
|
-
}
|
|
109
|
-
__name(timestamp, "timestamp");
|
|
110
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
111
|
-
0 && (module.exports = {
|
|
112
|
-
createDevLogger,
|
|
113
|
-
devLogger
|
|
114
|
-
});
|
|
115
|
-
//# sourceMappingURL=index.js.map
|
package/dist/dev/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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 debug: (_message?: any, ..._args: any[]) => {\n // todo: implement debug logging with pino\n return;\n },\n };\n}\n\nexport default createDevLogger();\n\nfunction isDevNodeEnv() {\n const nodeEnv = process.env.NODE_ENV;\n return nodeEnv !== \"production\" && nodeEnv !== \"test\" && nodeEnv !== \"ci\";\n}\n\nfunction formatLogPrefix(level: \"INFO\" | \"WARN\" | \"ERROR\" | \"DEBUG\"): 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,IAMP,OAAO,wBAAC,aAAmB,UAAiB;AAE1C;AAAA,IACF,GAHO;AAAA,EAIT;AACF;AAjEgB;AAmEhB,IAAO,iBAAQ,gBAAgB;AAE/B,SAAS,eAAe;AACtB,QAAM,UAAU,QAAQ,IAAI;AAC5B,SAAO,YAAY,gBAAgB,YAAY,UAAU,YAAY;AACvE;AAHS;AAKT,SAAS,gBAAgB,OAAoD;AAC3E,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":[]}
|
package/dist/dev/index.mjs
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
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
|
-
debug: /* @__PURE__ */ __name((_message, ..._args) => {
|
|
66
|
-
return;
|
|
67
|
-
}, "debug")
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
__name(createDevLogger, "createDevLogger");
|
|
71
|
-
var logger_default = createDevLogger();
|
|
72
|
-
function isDevNodeEnv() {
|
|
73
|
-
const nodeEnv = process.env.NODE_ENV;
|
|
74
|
-
return nodeEnv !== "production" && nodeEnv !== "test" && nodeEnv !== "ci";
|
|
75
|
-
}
|
|
76
|
-
__name(isDevNodeEnv, "isDevNodeEnv");
|
|
77
|
-
function formatLogPrefix(level) {
|
|
78
|
-
return `[VoltAgent] [${timestamp()}] ${level}: `;
|
|
79
|
-
}
|
|
80
|
-
__name(formatLogPrefix, "formatLogPrefix");
|
|
81
|
-
function timestamp() {
|
|
82
|
-
return (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").slice(0, -1);
|
|
83
|
-
}
|
|
84
|
-
__name(timestamp, "timestamp");
|
|
85
|
-
export {
|
|
86
|
-
createDevLogger,
|
|
87
|
-
logger_default as devLogger
|
|
88
|
-
};
|
|
89
|
-
//# sourceMappingURL=index.mjs.map
|
package/dist/dev/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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 debug: (_message?: any, ..._args: any[]) => {\n // todo: implement debug logging with pino\n return;\n },\n };\n}\n\nexport default createDevLogger();\n\nfunction isDevNodeEnv() {\n const nodeEnv = process.env.NODE_ENV;\n return nodeEnv !== \"production\" && nodeEnv !== \"test\" && nodeEnv !== \"ci\";\n}\n\nfunction formatLogPrefix(level: \"INFO\" | \"WARN\" | \"ERROR\" | \"DEBUG\"): 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,IAMP,OAAO,wBAAC,aAAmB,UAAiB;AAE1C;AAAA,IACF,GAHO;AAAA,EAIT;AACF;AAjEgB;AAmEhB,IAAO,iBAAQ,gBAAgB;AAE/B,SAAS,eAAe;AACtB,QAAM,UAAU,QAAQ,IAAI;AAC5B,SAAO,YAAY,gBAAgB,YAAY,UAAU,YAAY;AACvE;AAHS;AAKT,SAAS,gBAAgB,OAAoD;AAC3E,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":[]}
|