@voltagent/internal 0.0.5 → 0.0.7
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 +105 -104
- package/dist/main/index.d.ts +105 -104
- package/dist/main/index.js +29 -186
- package/dist/main/index.js.map +1 -1
- package/dist/main/index.mjs +29 -185
- package/dist/main/index.mjs.map +1 -1
- package/dist/test/index.js +21 -78
- package/dist/test/index.js.map +1 -1
- package/dist/test/index.mjs +21 -78
- package/dist/test/index.mjs.map +1 -1
- package/dist/utils/index.d.mts +42 -1
- package/dist/utils/index.d.ts +42 -1
- package/dist/utils/index.js +8 -124
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +8 -125
- package/dist/utils/index.mjs.map +1 -1
- package/package.json +54 -26
- 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.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,MA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