@oas-tools/oas-telemetry 0.7.0-alpha.5 → 0.7.0
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/.env.example +2 -0
- package/README.md +35 -17
- package/dist/cjs/config/bootConfig.cjs +3 -1
- package/dist/cjs/docs/openapi.yaml +1399 -0
- package/dist/cjs/routesManager.cjs +1 -1
- package/dist/cjs/telemetry/custom-implementations/exporters/InMemoryDbLogExporter.cjs +43 -13
- package/dist/cjs/telemetry/custom-implementations/exporters/InMemoryDbMetricExporter.cjs +10 -2
- package/dist/cjs/telemetry/custom-implementations/exporters/InMemoryDbSpanExporter.cjs +21 -16
- package/dist/cjs/telemetry/initializeTelemetry.cjs +39 -15
- package/dist/cjs/telemetry/telemetryConfigurator.cjs +6 -9
- package/dist/cjs/telemetry/telemetryRegistry.cjs +11 -8
- package/dist/cjs/tlm-ai/agent.cjs +54 -84
- package/dist/cjs/tlm-ai/aiController.cjs +69 -47
- package/dist/cjs/tlm-ai/aiRoutes.cjs +10 -3
- package/dist/cjs/tlm-ai/aiService.cjs +109 -0
- package/dist/cjs/tlm-ai/tools.cjs +30 -268
- package/dist/cjs/tlm-auth/authController.cjs +9 -9
- package/dist/cjs/tlm-auth/authMiddleware.cjs +1 -1
- package/dist/cjs/tlm-log/logController.cjs +30 -36
- package/dist/cjs/tlm-log/logRoutes.cjs +3 -2
- package/dist/cjs/tlm-metric/metricsController.cjs +15 -8
- package/dist/cjs/tlm-metric/metricsRoutes.cjs +2 -1
- package/dist/cjs/tlm-plugin/pluginController.cjs +11 -1
- package/dist/cjs/tlm-plugin/pluginProcess.cjs +4 -2
- package/dist/cjs/tlm-plugin/pluginService.cjs +3 -0
- package/dist/cjs/tlm-trace/traceController.cjs +16 -9
- package/dist/cjs/tlm-trace/traceRoutes.cjs +2 -1
- package/dist/cjs/tlm-util/utilController.cjs +23 -2
- package/dist/cjs/tlm-util/utilRoutes.cjs +44 -5
- package/dist/cjs/utils/logger.cjs +35 -13
- package/dist/esm/config/bootConfig.js +2 -0
- package/dist/esm/docs/openapi.yaml +1399 -0
- package/dist/esm/routesManager.js +1 -1
- package/dist/esm/telemetry/custom-implementations/exporters/InMemoryDbLogExporter.js +32 -11
- package/dist/esm/telemetry/custom-implementations/exporters/InMemoryDbMetricExporter.js +10 -2
- package/dist/esm/telemetry/custom-implementations/exporters/InMemoryDbSpanExporter.js +20 -13
- package/dist/esm/telemetry/initializeTelemetry.js +22 -14
- package/dist/esm/telemetry/telemetryConfigurator.js +7 -10
- package/dist/esm/telemetry/telemetryRegistry.js +10 -7
- package/dist/esm/tlm-ai/agent.js +37 -78
- package/dist/esm/tlm-ai/aiController.js +56 -39
- package/dist/esm/tlm-ai/aiRoutes.js +11 -4
- package/dist/esm/tlm-ai/aiService.js +94 -0
- package/dist/esm/tlm-ai/tools.js +29 -255
- package/dist/esm/tlm-auth/authController.js +8 -8
- package/dist/esm/tlm-auth/authMiddleware.js +1 -1
- package/dist/esm/tlm-log/logController.js +26 -28
- package/dist/esm/tlm-log/logRoutes.js +4 -3
- package/dist/esm/tlm-metric/metricsController.js +10 -6
- package/dist/esm/tlm-metric/metricsRoutes.js +3 -2
- package/dist/esm/tlm-plugin/pluginController.js +2 -1
- package/dist/esm/tlm-plugin/pluginProcess.js +4 -2
- package/dist/esm/tlm-plugin/pluginService.js +4 -0
- package/dist/esm/tlm-trace/traceController.js +11 -7
- package/dist/esm/tlm-trace/traceRoutes.js +3 -2
- package/dist/esm/tlm-util/utilController.js +22 -0
- package/dist/esm/tlm-util/utilRoutes.js +40 -5
- package/dist/esm/utils/logger.js +35 -12
- package/dist/types/config/bootConfig.d.ts +1 -0
- package/dist/types/telemetry/custom-implementations/exporters/InMemoryDbLogExporter.d.ts +7 -1
- package/dist/types/telemetry/custom-implementations/exporters/InMemoryDbMetricExporter.d.ts +1 -0
- package/dist/types/telemetry/custom-implementations/exporters/InMemoryDbSpanExporter.d.ts +1 -0
- package/dist/types/telemetry/telemetryRegistry.d.ts +22 -6
- package/dist/types/tlm-ai/agent.d.ts +2 -2
- package/dist/types/tlm-ai/aiController.d.ts +5 -4
- package/dist/types/tlm-ai/aiRoutes.d.ts +1 -1
- package/dist/types/tlm-ai/aiService.d.ts +38 -0
- package/dist/types/tlm-ai/tools.d.ts +5 -14
- package/dist/types/tlm-log/logController.d.ts +2 -2
- package/dist/types/tlm-metric/metricsController.d.ts +2 -1
- package/dist/types/tlm-plugin/pluginService.d.ts +2 -0
- package/dist/types/tlm-trace/traceController.d.ts +2 -1
- package/dist/types/tlm-util/utilController.d.ts +1 -0
- package/dist/types/utils/logger.d.ts +5 -5
- package/dist/ui/assets/ApiDocsPage-C_VVPPHa.js +16 -0
- package/dist/ui/assets/CollapsibleCard-B3KR_8mL.js +1 -0
- package/dist/ui/assets/DevToolsPage-OyZcDcmw.js +1 -0
- package/dist/ui/assets/LandingPage-CppFBA6K.js +6 -0
- package/dist/ui/assets/LogsPage-9Fq8GArS.js +26 -0
- package/dist/ui/assets/NotFoundPage-B3quk3P1.js +1 -0
- package/dist/ui/assets/PluginCreatePage-X_aCH4t4.js +50 -0
- package/dist/ui/assets/PluginPage-DMDSihrZ.js +27 -0
- package/dist/ui/assets/alert-jQ9HCPIf.js +1133 -0
- package/dist/ui/assets/badge-CNq0-mH5.js +1 -0
- package/dist/ui/assets/card-DFAwwhN3.js +1 -0
- package/dist/ui/assets/chevron-down-CPsvsmqj.js +6 -0
- package/dist/ui/assets/chevron-up-Df9jMo1X.js +6 -0
- package/dist/ui/assets/circle-alert-DOPQPvU8.js +6 -0
- package/dist/ui/assets/index-BkD6DijD.js +15 -0
- package/dist/ui/assets/index-CERGVYZK.js +292 -0
- package/dist/ui/assets/index-CSIPf9qw.css +1 -0
- package/dist/ui/assets/input-Dzvg_ZEZ.js +1 -0
- package/dist/ui/assets/label-DuVnkZ4q.js +1 -0
- package/dist/ui/assets/loader-circle-CrvlRy5o.js +6 -0
- package/dist/ui/assets/loginPage-qa4V-B70.js +6 -0
- package/dist/ui/assets/select-DhS8YUtJ.js +1 -0
- package/dist/ui/assets/separator-isK4chBP.js +6 -0
- package/dist/ui/assets/severityOptions-O38dSOfk.js +11 -0
- package/dist/ui/assets/switch-Z3mImG9n.js +1 -0
- package/dist/ui/assets/tabs-_77MUUQe.js +16 -0
- package/dist/ui/assets/upload-C1LT4Gkb.js +16 -0
- package/dist/ui/assets/utilService-DNyqzwj0.js +1 -0
- package/dist/ui/index.html +2 -2
- package/package.json +17 -6
- package/dist/ui/assets/index-Bgd7fFFH.js +0 -1743
- package/dist/ui/assets/index-Cz3N1n1Q.css +0 -1
|
@@ -5,7 +5,8 @@ import logger from "../utils/logger.js";
|
|
|
5
5
|
import { pluginService } from "./pluginService.js";
|
|
6
6
|
import { fileURLToPath } from "url";
|
|
7
7
|
export const listPlugins = (req, res) => {
|
|
8
|
-
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
9
|
+
const plugins = pluginService.getPlugins().map(({ process, ...rest }) => rest);
|
|
9
10
|
res.send({
|
|
10
11
|
pluginsCount: plugins.length,
|
|
11
12
|
plugins,
|
|
@@ -14,12 +14,14 @@ process.on("message", async (msg) => {
|
|
|
14
14
|
if (pluginResource.install && Array.isArray(pluginResource.install.dependencies) && pluginResource.install.dependencies.length > 0) {
|
|
15
15
|
log("Installing dependencies for plugin: " + pluginResource.name);
|
|
16
16
|
const dependenciesStatus = await installDependencies(pluginResource.install);
|
|
17
|
+
console.dir(dependenciesStatus);
|
|
17
18
|
if (!dependenciesStatus.success) {
|
|
19
|
+
const detailsFailed = dependenciesStatus.details.filter(detail => detail.success === false);
|
|
18
20
|
if (pluginResource.install.ignoreErrors === true) {
|
|
19
|
-
log(`Warning: Error installing dependencies: ${JSON.stringify(
|
|
21
|
+
log(`Warning: Error installing dependencies: ${JSON.stringify(detailsFailed)}. Continuing as ignoreErrors is true.`);
|
|
20
22
|
}
|
|
21
23
|
else {
|
|
22
|
-
process.send?.({ event: "error", error: `Error installing dependencies: ${JSON.stringify(
|
|
24
|
+
process.send?.({ event: "error", error: `Error installing dependencies: ${JSON.stringify(detailsFailed)}` });
|
|
23
25
|
return;
|
|
24
26
|
}
|
|
25
27
|
}
|
|
@@ -2,6 +2,7 @@ import logger from "../utils/logger.js";
|
|
|
2
2
|
class PluginService {
|
|
3
3
|
constructor() {
|
|
4
4
|
this.plugins = [];
|
|
5
|
+
this.enabled = false;
|
|
5
6
|
}
|
|
6
7
|
getPlugins() {
|
|
7
8
|
return this.plugins;
|
|
@@ -29,6 +30,8 @@ class PluginService {
|
|
|
29
30
|
this.plugins = this.plugins.filter((p) => p.id !== pluginId);
|
|
30
31
|
}
|
|
31
32
|
broadcastToPlugins(type, payload) {
|
|
33
|
+
if (!this.enabled)
|
|
34
|
+
return;
|
|
32
35
|
this.plugins.forEach((plugin, i) => {
|
|
33
36
|
if (!plugin.active)
|
|
34
37
|
return;
|
|
@@ -65,6 +68,7 @@ class PluginService {
|
|
|
65
68
|
}
|
|
66
69
|
/**
|
|
67
70
|
* Broadcast a new trace to all active plugins
|
|
71
|
+
* TODO: rename to span (trace is the whole trace, span is a single unit of work within a trace)
|
|
68
72
|
*/
|
|
69
73
|
broadcastTrace(trace) {
|
|
70
74
|
this.broadcastToPlugins("newTrace", trace);
|
|
@@ -41,7 +41,7 @@ export const findTraces = (req, res) => {
|
|
|
41
41
|
inMemoryDbSpanExporter.find(processedQuery, (err, docs) => {
|
|
42
42
|
if (err) {
|
|
43
43
|
console.error(err);
|
|
44
|
-
res.status(
|
|
44
|
+
res.status(400).send({ spansCount: 0, spans: [], error: err.message });
|
|
45
45
|
return; // Exit the function to prevent further execution
|
|
46
46
|
}
|
|
47
47
|
const spans = docs;
|
|
@@ -52,7 +52,7 @@ export const insertTracesToDb = async (req, res) => {
|
|
|
52
52
|
const jsonContent = req.body.spans;
|
|
53
53
|
const resetData = req.query.reset === 'true';
|
|
54
54
|
if (!Array.isArray(jsonContent)) {
|
|
55
|
-
res.status(400).send({ error: 'Invalid data format.
|
|
55
|
+
res.status(400).send({ error: 'Invalid data format.' });
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
58
|
const cleanedTraces = jsonContent.map((trace) => {
|
|
@@ -83,12 +83,16 @@ export const insertTracesToDb = async (req, res) => {
|
|
|
83
83
|
res.status(500).send({ error: 'Failed to reset and insert data', details: err.message });
|
|
84
84
|
}
|
|
85
85
|
};
|
|
86
|
-
export const
|
|
87
|
-
const
|
|
88
|
-
if (typeof
|
|
86
|
+
export const setTraceRetentionTime = (req, res) => {
|
|
87
|
+
const retentionTimeInSeconds = req.body.retentionTimeInSeconds;
|
|
88
|
+
if (typeof retentionTimeInSeconds !== 'number' || retentionTimeInSeconds <= 0) {
|
|
89
89
|
res.status(400).send({ error: 'Invalid retention time. Must be a positive number.' });
|
|
90
90
|
return;
|
|
91
91
|
}
|
|
92
|
-
inMemoryDbSpanExporter.retentionTimeInSeconds =
|
|
93
|
-
res.send({ message: `Retention time set to ${
|
|
92
|
+
inMemoryDbSpanExporter.retentionTimeInSeconds = retentionTimeInSeconds;
|
|
93
|
+
res.send({ message: `Retention time set to ${retentionTimeInSeconds} seconds.` });
|
|
94
|
+
};
|
|
95
|
+
export const getTraceRetentionTime = (req, res) => {
|
|
96
|
+
const retentionTimeInSeconds = inMemoryDbSpanExporter.retentionTimeInSeconds || 0;
|
|
97
|
+
res.send({ retentionTimeInSeconds: retentionTimeInSeconds });
|
|
94
98
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Router } from 'express';
|
|
2
|
-
import { startTraces, stopTraces, statusTraces, resetTraces, listTraces, findTraces, insertTracesToDb,
|
|
2
|
+
import { startTraces, stopTraces, statusTraces, resetTraces, listTraces, findTraces, insertTracesToDb, setTraceRetentionTime, getTraceRetentionTime } from './traceController.js';
|
|
3
3
|
export const getTraceRoutes = () => {
|
|
4
4
|
const router = Router();
|
|
5
5
|
// Telemetry Control
|
|
@@ -10,7 +10,8 @@ export const getTraceRoutes = () => {
|
|
|
10
10
|
router.get('/', listTraces);
|
|
11
11
|
router.post('/', insertTracesToDb);
|
|
12
12
|
router.post('/find', findTraces);
|
|
13
|
-
router.post('/retention-time',
|
|
13
|
+
router.post('/retention-time', setTraceRetentionTime);
|
|
14
|
+
router.get('/retention-time', getTraceRetentionTime);
|
|
14
15
|
return router;
|
|
15
16
|
};
|
|
16
17
|
export default getTraceRoutes;
|
|
@@ -2,6 +2,7 @@ import { readFileSync } from 'fs';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import yaml from 'js-yaml';
|
|
4
4
|
import v8 from 'node:v8';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
5
6
|
export const specLoader = (_req, res, oasTlmConfig) => {
|
|
6
7
|
if (oasTlmConfig.general.specFileName) {
|
|
7
8
|
try {
|
|
@@ -54,3 +55,24 @@ export const heapStats = (req, res) => {
|
|
|
54
55
|
roundedHeapStats['units'] = 'MB';
|
|
55
56
|
res.send(roundedHeapStats);
|
|
56
57
|
};
|
|
58
|
+
const isCjs = typeof __filename !== "undefined" && typeof __dirname !== "undefined";
|
|
59
|
+
const __filenameUniversal = isCjs
|
|
60
|
+
? __filename
|
|
61
|
+
: fileURLToPath(import.meta.url);
|
|
62
|
+
const __dirnameUniversal = isCjs
|
|
63
|
+
? __dirname
|
|
64
|
+
: path.dirname(__filenameUniversal);
|
|
65
|
+
export const getOasTelemetrySpec = (_req, res) => {
|
|
66
|
+
try {
|
|
67
|
+
const specPath = path.join(__dirnameUniversal, '../docs/openapi.yaml');
|
|
68
|
+
const data = readFileSync(specPath, { encoding: 'utf8', flag: 'r' });
|
|
69
|
+
let json = data;
|
|
70
|
+
json = JSON.stringify(yaml.load(data), null, 2);
|
|
71
|
+
res.setHeader('Content-Type', 'application/json');
|
|
72
|
+
res.send(json);
|
|
73
|
+
}
|
|
74
|
+
catch (e) {
|
|
75
|
+
console.error(`ERROR loading OAS Telemetry OpenAPI spec file: ${e}`);
|
|
76
|
+
res.status(500).send(`ERROR loading OAS Telemetry OpenAPI spec file: ${e}`);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
@@ -1,15 +1,33 @@
|
|
|
1
1
|
import { Router } from 'express';
|
|
2
|
-
import { specLoader, heapStats } from './utilController.js';
|
|
2
|
+
import { specLoader, heapStats, getOasTelemetrySpec } from './utilController.js';
|
|
3
3
|
export const getUtilsRoutes = (oasTlmConfig) => {
|
|
4
4
|
const router = Router();
|
|
5
5
|
router.get('/spec', (req, res) => specLoader(req, res, oasTlmConfig));
|
|
6
|
+
router.get('/oas-telemetry-spec', (req, res) => getOasTelemetrySpec(req, res));
|
|
6
7
|
router.get('/heapStats', heapStats);
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
//This route is NOT ignored by the spanExporter (includes "generate")
|
|
9
|
+
router.post('/generate-log', async (req, res) => {
|
|
10
|
+
const log = req.body.log || 'Default log message';
|
|
11
|
+
const repeat = parseInt(req.body.repeat) || 1;
|
|
12
|
+
const method = req.body.method?.toLowerCase() || 'log';
|
|
13
|
+
if (!['log', 'warn', 'error', 'info', 'debug'].includes(method)) {
|
|
14
|
+
res.status(400).send({ error: 'Invalid method. Use log, warn, error, info, or debug.' });
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
10
17
|
res.send({ message: 'Log generated', log: log });
|
|
18
|
+
for (let i = 0; i < repeat; i++) {
|
|
19
|
+
console[method](log);
|
|
20
|
+
await new Promise(resolve => setTimeout(resolve, 50)); // Slight delay between logs
|
|
21
|
+
}
|
|
11
22
|
});
|
|
12
|
-
|
|
23
|
+
// This route is NOT ignored by the spanExporter (includes "generate")
|
|
24
|
+
router.post('/generate-mock-logs', async (req, res) => {
|
|
25
|
+
const count = parseInt(req.body.count) || 50;
|
|
26
|
+
generateMockLogs(count);
|
|
27
|
+
res.send({ message: 'Started generating mock logs' });
|
|
28
|
+
});
|
|
29
|
+
// This route is NOT ignored by the spanExporter
|
|
30
|
+
router.get('/generate-wait/:seconds?', async (req, res) => {
|
|
13
31
|
const seconds = parseInt(req.params.seconds ?? "1", 10);
|
|
14
32
|
const waitTime = isNaN(seconds) ? 1 : seconds;
|
|
15
33
|
await new Promise(resolve => setTimeout(resolve, waitTime * 1000));
|
|
@@ -17,3 +35,20 @@ export const getUtilsRoutes = (oasTlmConfig) => {
|
|
|
17
35
|
});
|
|
18
36
|
return router;
|
|
19
37
|
};
|
|
38
|
+
const generateMockLogs = async (count) => {
|
|
39
|
+
const methodMessages = {
|
|
40
|
+
log: ['User logged in', 'Data fetched successfully'],
|
|
41
|
+
warn: ['Warning: Disk space low', 'Warning: High memory usage'],
|
|
42
|
+
error: ['Error connecting to database', 'Error: Invalid credentials'],
|
|
43
|
+
info: ['Info: Scheduled job started', 'Info: Configuration loaded'],
|
|
44
|
+
debug: ['Debugging mode enabled', 'Debug: Variable x = 42'],
|
|
45
|
+
};
|
|
46
|
+
const methods = Object.keys(methodMessages);
|
|
47
|
+
for (let i = 0; i < count; i++) {
|
|
48
|
+
await new Promise(resolve => setTimeout(resolve, 50)); // Slight delay between logs
|
|
49
|
+
const method = methods[Math.floor(Math.random() * methods.length)];
|
|
50
|
+
const messages = methodMessages[method];
|
|
51
|
+
const message = messages[Math.floor(Math.random() * messages.length)];
|
|
52
|
+
console[method](`[${new Date().toISOString()}][MOCK LOG][${method.toUpperCase()}] -${i + 1}- ${message}`);
|
|
53
|
+
}
|
|
54
|
+
};
|
package/dist/esm/utils/logger.js
CHANGED
|
@@ -1,18 +1,41 @@
|
|
|
1
1
|
import { bootEnvVariables } from "../config/bootConfig.js";
|
|
2
|
+
import { originalConsoleMethods } from "../telemetry/telemetryRegistry.js";
|
|
2
3
|
const LOG_LEVELS = ['DEBUG', 'INFO', 'WARN', 'ERROR', 'NONE'];
|
|
3
|
-
const currentLogLevel = (bootEnvVariables.OASTLM_BOOT_LOG_LEVEL
|
|
4
|
-
const serviceName = 'OAS-
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
const timestamp = new Date().toISOString();
|
|
8
|
-
console.log(`${timestamp} [${serviceName}] [${level}]:`, ...messages);
|
|
9
|
-
}
|
|
4
|
+
const currentLogLevel = (bootEnvVariables.OASTLM_BOOT_LOG_LEVEL).toUpperCase();
|
|
5
|
+
const serviceName = 'OAS-TLM-@-' + bootEnvVariables.OASTLM_BOOT_SERVICE_NAME;
|
|
6
|
+
function shouldLog(level) {
|
|
7
|
+
return LOG_LEVELS.indexOf(level) >= LOG_LEVELS.indexOf(currentLogLevel);
|
|
10
8
|
}
|
|
11
9
|
export default {
|
|
12
|
-
debug: (...messages) =>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
debug: (...messages) => {
|
|
11
|
+
if (shouldLog('DEBUG')) {
|
|
12
|
+
const timestamp = new Date().toISOString();
|
|
13
|
+
originalConsoleMethods.debug(`${timestamp} [${serviceName}] [DEBUG]:`, ...messages);
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
info: (...messages) => {
|
|
17
|
+
if (shouldLog('INFO')) {
|
|
18
|
+
const timestamp = new Date().toISOString();
|
|
19
|
+
originalConsoleMethods.info(`${timestamp} [${serviceName}] [INFO]:`, ...messages);
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
log: (...messages) => {
|
|
23
|
+
if (shouldLog('INFO')) {
|
|
24
|
+
const timestamp = new Date().toISOString();
|
|
25
|
+
originalConsoleMethods.log(`${timestamp} [${serviceName}] [INFO]:`, ...messages);
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
warn: (...messages) => {
|
|
29
|
+
if (shouldLog('WARN')) {
|
|
30
|
+
const timestamp = new Date().toISOString();
|
|
31
|
+
originalConsoleMethods.warn(`${timestamp} [${serviceName}] [WARN]:`, ...messages);
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
error: (...messages) => {
|
|
35
|
+
if (shouldLog('ERROR')) {
|
|
36
|
+
const timestamp = new Date().toISOString();
|
|
37
|
+
originalConsoleMethods.error(`${timestamp} [${serviceName}] [ERROR]:`, ...messages);
|
|
38
|
+
}
|
|
39
|
+
},
|
|
17
40
|
currentLogLevel
|
|
18
41
|
};
|
|
@@ -17,7 +17,12 @@ export declare class InMemoryDbLogExporter extends Enabler implements LogRecordE
|
|
|
17
17
|
* Shutdown the exporter.
|
|
18
18
|
*/
|
|
19
19
|
shutdown(): Promise<void>;
|
|
20
|
-
find(
|
|
20
|
+
find(findConfig: {
|
|
21
|
+
query: any;
|
|
22
|
+
messageSearch: string | null;
|
|
23
|
+
limit: number;
|
|
24
|
+
sortOrder?: any;
|
|
25
|
+
}): Promise<any[]>;
|
|
21
26
|
insert(data: any[], callback: (err: any, newDocs: any[]) => void): void;
|
|
22
27
|
getFinishedLogs(): any[];
|
|
23
28
|
/**
|
|
@@ -28,6 +33,7 @@ export declare class InMemoryDbLogExporter extends Enabler implements LogRecordE
|
|
|
28
33
|
*/
|
|
29
34
|
private _formatLogRecord;
|
|
30
35
|
set retentionTimeInSeconds(retentionTimeInSeconds: number);
|
|
36
|
+
get retentionTimeInSeconds(): number;
|
|
31
37
|
private _insertLogs;
|
|
32
38
|
private _startCleanupJob;
|
|
33
39
|
}
|
|
@@ -17,5 +17,6 @@ export declare class InMemoryDbMetricExporter extends Enabler implements PushMet
|
|
|
17
17
|
*/
|
|
18
18
|
insert(metrics: any[], callback: (err: any, newDocs: any[]) => void): void;
|
|
19
19
|
set retentionTimeInSeconds(retentionTimeInSeconds: number);
|
|
20
|
+
get retentionTimeInSeconds(): number;
|
|
20
21
|
private _startCleanupJob;
|
|
21
22
|
}
|
|
@@ -8,6 +8,7 @@ export declare class InMemoryDbSpanExporter extends Enabler implements SpanExpor
|
|
|
8
8
|
constructor(retentionTimeInSeconds?: number);
|
|
9
9
|
set baseUrl(baseUrl: string);
|
|
10
10
|
set retentionTimeInSeconds(retentionTimeInSeconds: number);
|
|
11
|
+
get retentionTimeInSeconds(): number;
|
|
11
12
|
export(readableSpans: ReadableSpan[], resultCallback: (arg0: {
|
|
12
13
|
code: ExportResultCode;
|
|
13
14
|
error?: Error;
|
|
@@ -4,17 +4,33 @@ import { InMemoryDbLogExporter } from "./custom-implementations/exporters/InMemo
|
|
|
4
4
|
import { InMemoryDbMetricExporter } from "./custom-implementations/exporters/InMemoryDbMetricExporter.js";
|
|
5
5
|
import { DynamicMultiSpanProcessor } from "./custom-implementations/processors/dynamicMultiSpanProcessor.js";
|
|
6
6
|
import { DynamicMultiLogRecordProcessor } from "./custom-implementations/processors/dynamicMultiLogProcessor.js";
|
|
7
|
-
import { PluginSpanExporter } from "./custom-implementations/exporters/PluginSpanExporter.js";
|
|
8
|
-
import { PluginLogExporter } from "./custom-implementations/exporters/PluginLogExporter.js";
|
|
9
|
-
import { PluginMetricExporter } from "./custom-implementations/exporters/PluginMetricExporter.js";
|
|
10
7
|
export declare const oasTelemetryResource: import("@opentelemetry/resources").Resource;
|
|
11
8
|
export declare const inMemoryDbSpanExporter: InMemoryDbSpanExporter;
|
|
12
9
|
export declare const multiSpanExporter: EnablerMultiSpanExporter;
|
|
13
10
|
export declare const dynamicMultiSpanProcessor: DynamicMultiSpanProcessor;
|
|
14
|
-
export declare const pluginSpanExporter: PluginSpanExporter;
|
|
15
11
|
export declare const inMemoryDbLogExporter: InMemoryDbLogExporter;
|
|
16
12
|
export declare const multiLogExporter: EnablerMultiLogExporter;
|
|
17
13
|
export declare const dynamicMultiLogProcessor: DynamicMultiLogRecordProcessor;
|
|
18
|
-
export declare const
|
|
14
|
+
export declare const originalConsoleMethods: {
|
|
15
|
+
log: {
|
|
16
|
+
(...data: any[]): void;
|
|
17
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
18
|
+
};
|
|
19
|
+
warn: {
|
|
20
|
+
(...data: any[]): void;
|
|
21
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
22
|
+
};
|
|
23
|
+
error: {
|
|
24
|
+
(...data: any[]): void;
|
|
25
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
26
|
+
};
|
|
27
|
+
info: {
|
|
28
|
+
(...data: any[]): void;
|
|
29
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
30
|
+
};
|
|
31
|
+
debug: {
|
|
32
|
+
(...data: any[]): void;
|
|
33
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
19
36
|
export declare const inMemoryDbMetricExporter: InMemoryDbMetricExporter;
|
|
20
|
-
export declare const pluginMetricExporter: PluginMetricExporter;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
export declare function
|
|
1
|
+
import OpenAI from 'openai';
|
|
2
|
+
export declare function agent(openai: OpenAI, messages: any[], model?: string, extraPrompts?: string[]): Promise<void>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Request, Response } from 'express';
|
|
2
|
-
|
|
3
|
-
export declare
|
|
4
|
-
export declare
|
|
5
|
-
export declare
|
|
2
|
+
export declare function createConversation(req: Request, res: Response): Promise<void>;
|
|
3
|
+
export declare function listConversations(req: Request, res: Response): Promise<void>;
|
|
4
|
+
export declare function getConversationHistory(req: Request, res: Response): Promise<void>;
|
|
5
|
+
export declare function deleteConversation(req: Request, res: Response): Promise<void>;
|
|
6
|
+
export declare function sendMessage(req: Request, res: Response): Promise<void>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { OasTlmConfig } from
|
|
1
|
+
import { OasTlmConfig } from '../config/config.types.js';
|
|
2
2
|
export declare const getAIRoutes: (oasTlmConfig: OasTlmConfig) => import("express-serve-static-core").Router;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { OasTlmConfig } from '../config/config.types';
|
|
2
|
+
type Message = {
|
|
3
|
+
role: 'user' | 'assistant' | 'function' | 'system';
|
|
4
|
+
content: string;
|
|
5
|
+
name?: string;
|
|
6
|
+
timestamp: string;
|
|
7
|
+
};
|
|
8
|
+
type Conversation = {
|
|
9
|
+
id: string;
|
|
10
|
+
messages: Message[];
|
|
11
|
+
name?: string;
|
|
12
|
+
};
|
|
13
|
+
declare class AIService {
|
|
14
|
+
private config;
|
|
15
|
+
private conversations;
|
|
16
|
+
private openai;
|
|
17
|
+
private model;
|
|
18
|
+
private extraPrompts;
|
|
19
|
+
constructor(config: {
|
|
20
|
+
apiKey: string;
|
|
21
|
+
model: string;
|
|
22
|
+
extraPrompts?: string[];
|
|
23
|
+
});
|
|
24
|
+
createConversation(): Conversation;
|
|
25
|
+
listConversations(): Conversation[];
|
|
26
|
+
getConversation(id: string): Conversation | undefined;
|
|
27
|
+
deleteConversation(id: string): boolean;
|
|
28
|
+
sendMessage(conversationId: string, content: string, model?: string): Promise<Message[]>;
|
|
29
|
+
listConversationsMinimal(): {
|
|
30
|
+
id: string;
|
|
31
|
+
name?: string;
|
|
32
|
+
}[];
|
|
33
|
+
listModels(): Promise<string[]>;
|
|
34
|
+
isValidModel(modelId: string): Promise<boolean>;
|
|
35
|
+
}
|
|
36
|
+
export declare function configureAiService(config: OasTlmConfig): void;
|
|
37
|
+
export declare function getAiService(): AIService;
|
|
38
|
+
export {};
|
|
@@ -13,19 +13,16 @@ declare const availableTools: {
|
|
|
13
13
|
_duration: any;
|
|
14
14
|
}[];
|
|
15
15
|
}>;
|
|
16
|
-
getLogs: (startDate:
|
|
16
|
+
getLogs: (startDate: string | undefined, endDate: string | undefined) => Promise<{
|
|
17
17
|
logs: {
|
|
18
18
|
service: any;
|
|
19
|
-
timestamp:
|
|
19
|
+
timestamp: string;
|
|
20
|
+
severityText: any;
|
|
20
21
|
message: any;
|
|
21
22
|
traceId: any;
|
|
22
|
-
spanId: any;
|
|
23
23
|
source: any;
|
|
24
24
|
}[];
|
|
25
25
|
}>;
|
|
26
|
-
getMetrics: (searchInput: Record<string, any>) => Promise<{
|
|
27
|
-
metrics: any[];
|
|
28
|
-
}>;
|
|
29
26
|
startTelemetry: () => void;
|
|
30
27
|
stopTelemetry: () => void;
|
|
31
28
|
resetTelemetry: () => void;
|
|
@@ -34,14 +31,8 @@ declare const availableTools: {
|
|
|
34
31
|
logsEnabled: boolean;
|
|
35
32
|
metricsEnabled: boolean;
|
|
36
33
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
currentTimestampInEpochSeconds: number;
|
|
34
|
+
getCurrentDate: () => {
|
|
35
|
+
currentDateISO: string;
|
|
40
36
|
};
|
|
41
|
-
talkToExternalMicroserviceAgent: (message: string, microserviceId: string) => Promise<{
|
|
42
|
-
microservice: string;
|
|
43
|
-
response: any;
|
|
44
|
-
}>;
|
|
45
|
-
getMicroserviceAgents: () => import("./knownMicroservices.js").KnownMicroservice[];
|
|
46
37
|
};
|
|
47
38
|
export { tools, availableTools, };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Request, Response } from 'express';
|
|
2
|
-
export declare const listLogs: (req: Request, res: Response) => Promise<void>;
|
|
3
2
|
export declare const findLogs: (req: Request, res: Response) => Promise<void>;
|
|
4
3
|
export declare const resetLogs: (req: Request, res: Response) => void;
|
|
5
4
|
export declare const insertLogsToDb: (req: Request, res: Response) => Promise<void>;
|
|
6
5
|
export declare const startLogs: (req: Request, res: Response) => void;
|
|
7
6
|
export declare const stopLogs: (req: Request, res: Response) => void;
|
|
8
7
|
export declare const statusLogs: (req: Request, res: Response) => void;
|
|
9
|
-
export declare const
|
|
8
|
+
export declare const setLogRetentionTime: (req: Request, res: Response) => void;
|
|
9
|
+
export declare const getLogRetentionTime: (req: Request, res: Response) => void;
|
|
@@ -6,4 +6,5 @@ export declare const insertMetricsToDb: (req: Request, res: Response) => Promise
|
|
|
6
6
|
export declare const startMetrics: (req: Request, res: Response) => void;
|
|
7
7
|
export declare const stopMetrics: (req: Request, res: Response) => void;
|
|
8
8
|
export declare const statusMetrics: (req: Request, res: Response) => void;
|
|
9
|
-
export declare const
|
|
9
|
+
export declare const setMetricRetentionTime: (req: Request, res: Response) => void;
|
|
10
|
+
export declare const getMetricRetentionTime: (req: Request, res: Response) => void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PluginResource } from "../types/index.js";
|
|
2
2
|
declare class PluginService {
|
|
3
3
|
private plugins;
|
|
4
|
+
enabled: boolean;
|
|
4
5
|
getPlugins(): PluginResource[];
|
|
5
6
|
pushPlugin(plugin: PluginResource): void;
|
|
6
7
|
activatePlugin(pluginId: string): void;
|
|
@@ -17,6 +18,7 @@ declare class PluginService {
|
|
|
17
18
|
broadcastLog(log: any): void;
|
|
18
19
|
/**
|
|
19
20
|
* Broadcast a new trace to all active plugins
|
|
21
|
+
* TODO: rename to span (trace is the whole trace, span is a single unit of work within a trace)
|
|
20
22
|
*/
|
|
21
23
|
broadcastTrace(trace: any): void;
|
|
22
24
|
}
|
|
@@ -6,4 +6,5 @@ export declare const resetTraces: (req: Request, res: Response) => void;
|
|
|
6
6
|
export declare const listTraces: (req: Request, res: Response) => Promise<void>;
|
|
7
7
|
export declare const findTraces: (req: Request, res: Response) => void;
|
|
8
8
|
export declare const insertTracesToDb: (req: Request, res: Response) => Promise<void>;
|
|
9
|
-
export declare const
|
|
9
|
+
export declare const setTraceRetentionTime: (req: Request, res: Response) => void;
|
|
10
|
+
export declare const getTraceRetentionTime: (req: Request, res: Response) => void;
|
|
@@ -2,3 +2,4 @@ import { Request, Response } from 'express';
|
|
|
2
2
|
import { OasTlmConfig } from '../config/config.types.js';
|
|
3
3
|
export declare const specLoader: (_req: Request, res: Response, oasTlmConfig: OasTlmConfig) => void;
|
|
4
4
|
export declare const heapStats: (req: Request, res: Response) => void;
|
|
5
|
+
export declare const getOasTelemetrySpec: (_req: Request, res: Response) => void;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
|
-
debug: (...messages: any) => void;
|
|
3
|
-
info: (...messages: any) => void;
|
|
4
|
-
log: (...messages: any) => void;
|
|
5
|
-
warn: (...messages: any) => void;
|
|
6
|
-
error: (...messages: any) => void;
|
|
2
|
+
debug: (...messages: any[]) => void;
|
|
3
|
+
info: (...messages: any[]) => void;
|
|
4
|
+
log: (...messages: any[]) => void;
|
|
5
|
+
warn: (...messages: any[]) => void;
|
|
6
|
+
error: (...messages: any[]) => void;
|
|
7
7
|
currentLogLevel: string;
|
|
8
8
|
};
|
|
9
9
|
export default _default;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import{c as w,r as d,j as e,I,B,y as O,F as P}from"./index-CERGVYZK.js";import{u as R}from"./utilService-DNyqzwj0.js";import{I as M}from"./input-Dzvg_ZEZ.js";import{b as z,c as D,C as T,a as $}from"./card-DFAwwhN3.js";import{C as J}from"./CollapsibleCard-B3KR_8mL.js";import{S as L,T as _}from"./separator-isK4chBP.js";import{S as U,U as A,D as F}from"./upload-C1LT4Gkb.js";import"./chevron-up-Df9jMo1X.js";import"./chevron-down-CPsvsmqj.js";/**
|
|
2
|
+
* @license lucide-react v0.515.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const H=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],V=w("eye",H);/**
|
|
7
|
+
* @license lucide-react v0.515.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const W=[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]],G=w("list",W);/**
|
|
12
|
+
* @license lucide-react v0.515.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const K=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],Q=w("shield",K);function X(c,g){var x;return(x=c.tags)==null?void 0:x.find(N=>N.name===g)}const ie=()=>{const[c,g]=d.useState(null),[x,N]=d.useState(null),[u,v]=d.useState({}),[y,k]=d.useState(""),[m,h]=d.useState(null),[p,C]=d.useState(!1);if(d.useEffect(()=>{R.getOasTelemetryOpenApiSpec().then(g)},[]),!c)return e.jsx("div",{className:"flex items-center justify-center h-screen bg-background",children:e.jsx("span",{className:"text-lg text-muted-foreground",children:"Loading API spec..."})});const f={};Object.entries(c.paths).forEach(([r,a])=>{const l=(a==null?void 0:a.parameters)||[];Object.entries(a).forEach(([t,n])=>{if(t==="parameters")return;const i={...n||{},parameters:[...l||[],...(n==null?void 0:n.parameters)||[]]};(i.tags||["default"]).forEach(o=>{f[o]||(f[o]=[]),f[o].push({path:r,method:t,details:i})})})});const q=(r,a)=>{v(l=>({...l,[r]:a}))},E=async r=>{var i;C(!0),h(null);let a=r.path;const l=r.details;l.parameters&&l.parameters.forEach(s=>{s.in==="path"&&(a=a.replace(`{${s.name}}`,u[s.name]||""))});const t=[];l.parameters&&l.parameters.forEach(s=>{s.in==="query"&&u[s.name]&&t.push(`${encodeURIComponent(s.name)}=${encodeURIComponent(u[s.name])}`)}),t.length&&(a+="?"+t.join("&"));const n={method:r.method,url:a,headers:{},data:void 0};l.requestBody&&(n.headers["Content-Type"]="application/json",n.data=y.trim()?y:"{}");try{const s=await O.request(n);h({status:s.status,data:s.data})}catch(s){h({error:((i=s==null?void 0:s.response)==null?void 0:i.data)||(s==null?void 0:s.message)||"Unknown error"})}C(!1)};function b(r){var l,t;if(!r)return"";const a=(l=r.content)==null?void 0:l["application/json"];return a!=null&&a.example?JSON.stringify(a.example,null,2):(t=a==null?void 0:a.schema)!=null&&t.example?JSON.stringify(a.schema.example,null,2):""}return e.jsx("div",{className:"min-h-screen bg-background",children:e.jsxs("main",{className:"container mx-auto px-4 py-4 md:py-8 space-y-4 md:space-y-6",children:[e.jsx(z,{children:e.jsxs(D,{children:[e.jsx(T,{className:"text-xl sm:text-2xl font-bold",children:c.info.title}),e.jsx($,{className:"text-xs sm:text-sm",children:c.info.version}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:c.info.description})]})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-3",children:"Endpoints"}),e.jsx("div",{className:"flex flex-col gap-8",children:Object.entries(f).map(([r,a])=>{var l;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center mb-2",children:[e.jsx("span",{className:"font-bold text-base",children:r}),e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:(l=X(c,r))==null?void 0:l.description})]}),e.jsx("div",{className:"flex flex-col gap-4",children:a.map((t,n)=>{var i;return e.jsxs(J,{isOpen:x===`${r}-${n}`,onToggle:()=>{N(x===`${r}-${n}`?null:`${r}-${n}`),v({});const s=b(t.details.requestBody);k(s),h(null)},className:`border shadow-sm rounded-lg transition-all ${x===`${r}-${n}`?"border-primary":"border-muted"} bg-card`,header:e.jsxs(e.Fragment,{children:[e.jsxs(T,{className:"flex items-center gap-2",children:[Z(t.method),e.jsx("span",{className:`font-bold uppercase text-xs sm:text-sm ${Y(t.method)}`,children:t.method}),e.jsx("span",{className:"font-mono text-xs sm:text-sm break-all",children:t.path}),p&&e.jsx("svg",{className:"animate-spin h-4 w-4 text-muted-foreground ml-2",viewBox:"0 0 24 24",children:e.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4",fill:"none"})})]}),e.jsx($,{children:t.details.summary||t.details.description})]}),children:[e.jsx(L,{className:"mb-2"}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold text-xs",children:"Description:"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:t.details.description||t.details.summary})]}),t.details.security&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-semibold",children:"Security:"})," ",t.details.security.map(s=>Object.keys(s).join(", ")).join(" | ")]}),t.details.tags&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-semibold",children:"Tags:"})," ",t.details.tags.join(", ")]}),e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold mb-2 text-xs",children:"Parameters"}),((i=t.details.parameters)==null?void 0:i.length)>0?e.jsx("ul",{className:"space-y-2",children:t.details.parameters.map(s=>{var o;return e.jsxs("li",{className:"flex flex-col gap-1 border rounded px-3 py-2 bg-muted/40",children:[e.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[e.jsx("span",{className:"font-mono font-bold text-xs",children:s.name}),e.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground",children:s.in}),e.jsx("span",{className:"text-xs text-muted-foreground",children:((o=s.schema)==null?void 0:o.type)||"-"}),s.required&&e.jsx("span",{className:"text-xs text-red-500 font-semibold",children:"required"})]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:s.description}),e.jsx(M,{value:u[s.name]||"",onChange:j=>q(s.name,j.target.value),className:"w-full sm:w-32 h-7 text-xs mt-1",placeholder:s.name})]},s.name)})}):e.jsx("div",{className:"text-muted-foreground text-xs",children:"No parameters"})]}),t.details.requestBody&&e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold mb-2 text-xs",children:"Request Body"}),e.jsx(I,{value:y,onChange:s=>k(s.target.value),className:"w-full font-mono text-xs h-40",placeholder:"JSON body"}),b(t.details.requestBody)&&e.jsxs("div",{className:"mt-2 text-xs",children:[e.jsx("span",{className:"font-semibold",children:"Example:"}),e.jsx("pre",{className:"bg-muted p-2 rounded text-xs whitespace-pre-wrap break-words",children:b(t.details.requestBody)})]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold mb-2 text-xs",children:"Responses"}),e.jsx("ul",{className:"space-y-2",children:Object.entries(t.details.responses||{}).map(([s,o])=>{var j,S;return e.jsxs("li",{className:"flex flex-col gap-1 border rounded px-3 py-2 bg-muted/40",children:[e.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[e.jsx("span",{className:"font-mono text-xs font-bold",children:s}),e.jsx("span",{className:"text-xs text-muted-foreground",children:o.description})]}),((S=(j=o.content)==null?void 0:j["application/json"])==null?void 0:S.example)&&e.jsx("pre",{className:"bg-black text-white p-2 rounded text-xs mt-1 whitespace-pre-wrap break-words overflow-x-auto",children:JSON.stringify(o.content["application/json"].example,null,2)})]},s)})})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-3 mb-2",children:[e.jsx(B,{onClick:()=>E(t),disabled:p,className:"h-8 px-4 text-xs shadow w-full sm:w-auto",children:p?"Calling...":"Try it out"}),p&&e.jsx("span",{className:"text-muted-foreground text-xs",children:"Calling API..."})]}),m&&e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"font-semibold mb-1 text-xs",children:"Result"}),e.jsx("pre",{className:"bg-black text-white p-3 rounded text-xs overflow-x-auto max-h-48 whitespace-pre-wrap break-words",children:m.error?"Error: "+(typeof m.error=="string"?m.error:JSON.stringify(m.error,null,2)):JSON.stringify(m,null,2)})]})]})]},t.method+t.path)})})]},r)})})]})]})})};function Y(c){switch(c.toLowerCase()){case"get":return"text-green-600";case"post":return"text-blue-600";case"put":return"text-yellow-600";case"delete":return"text-red-600";case"patch":return"text-purple-600";default:return"text-gray-600"}}function Z(c){switch(c.toLowerCase()){case"get":return e.jsx(F,{className:"h-4 w-4 text-green-600"});case"post":return e.jsx(A,{className:"h-4 w-4 text-blue-600"});case"put":return e.jsx(U,{className:"h-4 w-4 text-yellow-600"});case"delete":return e.jsx(_,{className:"h-4 w-4 text-red-600"});case"patch":return e.jsx(Q,{className:"h-4 w-4 text-purple-600"});case"options":return e.jsx(G,{className:"h-4 w-4 text-gray-600"});case"head":return e.jsx(V,{className:"h-4 w-4 text-gray-600"});default:return e.jsx(P,{className:"h-4 w-4 text-gray-600"})}}export{ie as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as s,B as l}from"./index-CERGVYZK.js";import{b as n,c as i,d as m}from"./card-DFAwwhN3.js";import{C as c}from"./chevron-up-Df9jMo1X.js";import{C as x}from"./chevron-down-CPsvsmqj.js";const p=({isOpen:a,onToggle:r,header:e,children:o,className:t})=>s.jsxs(n,{className:t,children:[s.jsxs(i,{className:"flex flex-row items-center justify-between cursor-pointer",onClick:r,children:[s.jsx("div",{children:e}),s.jsx(l,{variant:"ghost",size:"icon","aria-label":a?"Collapse":"Expand",tabIndex:-1,className:"ml-2",children:a?s.jsx(c,{className:"h-5 w-5"}):s.jsx(x,{className:"h-5 w-5"})})]}),a&&s.jsx(m,{children:o})]});export{p as C};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as a,j as e,I as M,B as g,a0 as F,t}from"./index-CERGVYZK.js";import{C as G,a as I}from"./card-DFAwwhN3.js";import{I as x}from"./input-Dzvg_ZEZ.js";import{L as r}from"./label-DuVnkZ4q.js";import{T as D,a as E,b as u,c as h,W as p}from"./tabs-_77MUUQe.js";import{S as P,a as O,b as R,c as V,d as W}from"./select-DhS8YUtJ.js";import{s as n,l as b}from"./severityOptions-O38dSOfk.js";import{C as B}from"./CollapsibleCard-B3KR_8mL.js";import"./chevron-down-CPsvsmqj.js";import"./chevron-up-Df9jMo1X.js";import"./circle-alert-DOPQPvU8.js";const H=[{value:"info",label:"Info",icon:n[2].icon},{value:"warn",label:"Warn",icon:n[3].icon},{value:"error",label:"Error",icon:n[4].icon},{value:"debug",label:"Debug",icon:n[1].icon}];function U(){const[j,f]=a.useState("custom"),[c,v]=a.useState("Hello Oas Telemetry!"),[i,N]=a.useState("info"),[m,k]=a.useState(1),[d,C]=a.useState(50),[l,o]=a.useState(!1),[w,L]=a.useState(!1),S=async()=>{o(!0);try{await b.generateCustomLog({log:c,method:i,repeat:m}),t.success("Log(s) generated. Please wait a few seconds for them to appear.")}catch{t.error("Failed to generate log(s).")}finally{o(!1)}},y=async()=>{o(!0);try{await b.generateMockLogs(d),t.success("Mock logs generation started.")}catch{t.error("Failed to generate mock logs.")}finally{o(!1)}};return e.jsx(B,{isOpen:w,onToggle:()=>L(s=>!s),header:e.jsxs(e.Fragment,{children:[e.jsxs(G,{className:"flex items-center gap-2",children:[e.jsx(p,{className:"h-5 w-5"}),"Log Generator"]}),e.jsx(I,{children:"Generate logs for testing and demonstration purposes."})]}),children:e.jsxs(D,{value:j,onValueChange:s=>f(s),children:[e.jsxs(E,{className:"mb-4 grid grid-cols-2 w-full",children:[e.jsx(u,{value:"custom",children:"Custom Log"}),e.jsx(u,{value:"mock",children:"Mock Logs"})]}),e.jsx(h,{value:"custom",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{children:[e.jsx(r,{htmlFor:"log-message",className:"mb-1 block",children:"Message"}),e.jsx(M,{id:"log-message",value:c,onChange:s=>v(s.target.value),placeholder:"Log text",disabled:l,className:"mb-2"})]}),e.jsxs("div",{className:"flex gap-4 flex-col sm:flex-row sm:items-end",children:[e.jsxs("div",{className:"flex gap-4 flex-row",children:[e.jsxs("div",{children:[e.jsx(r,{htmlFor:"log-method",className:"mb-1 block",children:"Method"}),e.jsxs(P,{value:i,onValueChange:N,disabled:l,children:[e.jsx(O,{className:"min-w-[120px]",children:e.jsx(R,{placeholder:"Method"})}),e.jsx(V,{children:H.map(s=>{const T=s.icon;return e.jsxs(W,{value:s.value,className:"flex items-center gap-2",children:[e.jsx(T,{className:"h-4 w-4 mr-1"}),s.label]},s.value)})})]})]}),e.jsxs("div",{children:[e.jsx(r,{htmlFor:"log-repeat",className:"mb-1 block",children:"Repeat"}),e.jsx(x,{id:"log-repeat",type:"number",min:1,value:m,onChange:s=>k(Number(s.target.value)),disabled:l,className:"w-20"})]})]}),e.jsxs(g,{onClick:S,disabled:l,children:[e.jsx(F,{className:"h-4 w-4 mr-2"}),"Generate"]})]})]})}),e.jsx(h,{value:"mock",children:e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 sm:items-end",children:[e.jsxs("div",{children:[e.jsx(r,{htmlFor:"mock-count",className:"mb-1 block",children:"Number of Mock Logs"}),e.jsx(x,{id:"mock-count",type:"number",min:1,value:d,onChange:s=>C(Number(s.target.value)),disabled:l,className:"w-32"})]}),e.jsxs(g,{onClick:y,disabled:l,className:"mt-2 sm:mt-0",children:[e.jsx(p,{className:"h-4 w-4 mr-2"}),"Generate Mock Logs"]})]})})]})})}function ee(){return e.jsx("div",{className:"min-h-screen bg-background",children:e.jsxs("main",{className:"container mx-auto px-4 py-4 md:py-8 space-y-4 md:space-y-6",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Dev Tools"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"Utilities for testing and development."}),e.jsx(U,{})]})})}export{ee as default};
|