@oas-tools/oas-telemetry 0.7.0-alpha.4 → 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.
Files changed (112) hide show
  1. package/.env.example +6 -2
  2. package/README.md +35 -17
  3. package/dist/cjs/config/bootConfig.cjs +3 -1
  4. package/dist/cjs/config/config.cjs +7 -5
  5. package/dist/cjs/docs/openapi.yaml +1399 -0
  6. package/dist/cjs/routesManager.cjs +36 -48
  7. package/dist/cjs/telemetry/custom-implementations/exporters/InMemoryDbLogExporter.cjs +43 -13
  8. package/dist/cjs/telemetry/custom-implementations/exporters/InMemoryDbMetricExporter.cjs +10 -2
  9. package/dist/cjs/telemetry/custom-implementations/exporters/InMemoryDbSpanExporter.cjs +21 -16
  10. package/dist/cjs/telemetry/initializeTelemetry.cjs +39 -15
  11. package/dist/cjs/telemetry/telemetryConfigurator.cjs +6 -9
  12. package/dist/cjs/telemetry/telemetryRegistry.cjs +11 -8
  13. package/dist/cjs/tlm-ai/agent.cjs +54 -84
  14. package/dist/cjs/tlm-ai/aiController.cjs +69 -47
  15. package/dist/cjs/tlm-ai/aiRoutes.cjs +10 -3
  16. package/dist/cjs/tlm-ai/aiService.cjs +109 -0
  17. package/dist/cjs/tlm-ai/tools.cjs +30 -268
  18. package/dist/cjs/tlm-auth/authController.cjs +91 -26
  19. package/dist/cjs/tlm-auth/authMiddleware.cjs +20 -7
  20. package/dist/cjs/tlm-auth/authRoutes.cjs +3 -2
  21. package/dist/cjs/tlm-log/logController.cjs +30 -36
  22. package/dist/cjs/tlm-log/logRoutes.cjs +3 -2
  23. package/dist/cjs/tlm-metric/metricsController.cjs +15 -8
  24. package/dist/cjs/tlm-metric/metricsRoutes.cjs +2 -1
  25. package/dist/cjs/tlm-plugin/pluginController.cjs +11 -1
  26. package/dist/cjs/tlm-plugin/pluginProcess.cjs +4 -2
  27. package/dist/cjs/tlm-plugin/pluginService.cjs +3 -0
  28. package/dist/cjs/tlm-trace/traceController.cjs +16 -9
  29. package/dist/cjs/tlm-trace/traceRoutes.cjs +2 -1
  30. package/dist/cjs/tlm-util/utilController.cjs +23 -2
  31. package/dist/cjs/tlm-util/utilRoutes.cjs +44 -5
  32. package/dist/cjs/utils/logger.cjs +35 -13
  33. package/dist/esm/config/bootConfig.js +2 -0
  34. package/dist/esm/config/config.js +4 -2
  35. package/dist/esm/docs/openapi.yaml +1399 -0
  36. package/dist/esm/routesManager.js +37 -49
  37. package/dist/esm/telemetry/custom-implementations/exporters/InMemoryDbLogExporter.js +32 -11
  38. package/dist/esm/telemetry/custom-implementations/exporters/InMemoryDbMetricExporter.js +10 -2
  39. package/dist/esm/telemetry/custom-implementations/exporters/InMemoryDbSpanExporter.js +20 -13
  40. package/dist/esm/telemetry/initializeTelemetry.js +22 -14
  41. package/dist/esm/telemetry/telemetryConfigurator.js +7 -10
  42. package/dist/esm/telemetry/telemetryRegistry.js +10 -7
  43. package/dist/esm/tlm-ai/agent.js +37 -78
  44. package/dist/esm/tlm-ai/aiController.js +56 -39
  45. package/dist/esm/tlm-ai/aiRoutes.js +11 -4
  46. package/dist/esm/tlm-ai/aiService.js +94 -0
  47. package/dist/esm/tlm-ai/tools.js +29 -255
  48. package/dist/esm/tlm-auth/authController.js +62 -20
  49. package/dist/esm/tlm-auth/authMiddleware.js +18 -9
  50. package/dist/esm/tlm-auth/authRoutes.js +4 -3
  51. package/dist/esm/tlm-log/logController.js +26 -28
  52. package/dist/esm/tlm-log/logRoutes.js +4 -3
  53. package/dist/esm/tlm-metric/metricsController.js +10 -6
  54. package/dist/esm/tlm-metric/metricsRoutes.js +3 -2
  55. package/dist/esm/tlm-plugin/pluginController.js +2 -1
  56. package/dist/esm/tlm-plugin/pluginProcess.js +4 -2
  57. package/dist/esm/tlm-plugin/pluginService.js +4 -0
  58. package/dist/esm/tlm-trace/traceController.js +11 -7
  59. package/dist/esm/tlm-trace/traceRoutes.js +3 -2
  60. package/dist/esm/tlm-util/utilController.js +22 -0
  61. package/dist/esm/tlm-util/utilRoutes.js +40 -5
  62. package/dist/esm/utils/logger.js +35 -12
  63. package/dist/types/config/bootConfig.d.ts +1 -0
  64. package/dist/types/config/config.d.ts +6 -3
  65. package/dist/types/telemetry/custom-implementations/exporters/InMemoryDbLogExporter.d.ts +7 -1
  66. package/dist/types/telemetry/custom-implementations/exporters/InMemoryDbMetricExporter.d.ts +1 -0
  67. package/dist/types/telemetry/custom-implementations/exporters/InMemoryDbSpanExporter.d.ts +1 -0
  68. package/dist/types/telemetry/telemetryRegistry.d.ts +22 -6
  69. package/dist/types/tlm-ai/agent.d.ts +2 -2
  70. package/dist/types/tlm-ai/aiController.d.ts +5 -4
  71. package/dist/types/tlm-ai/aiRoutes.d.ts +1 -1
  72. package/dist/types/tlm-ai/aiService.d.ts +38 -0
  73. package/dist/types/tlm-ai/tools.d.ts +5 -14
  74. package/dist/types/tlm-auth/authController.d.ts +2 -1
  75. package/dist/types/tlm-log/logController.d.ts +2 -2
  76. package/dist/types/tlm-metric/metricsController.d.ts +2 -1
  77. package/dist/types/tlm-plugin/pluginService.d.ts +2 -0
  78. package/dist/types/tlm-trace/traceController.d.ts +2 -1
  79. package/dist/types/tlm-util/utilController.d.ts +1 -0
  80. package/dist/types/utils/logger.d.ts +5 -5
  81. package/dist/ui/assets/ApiDocsPage-C_VVPPHa.js +16 -0
  82. package/dist/ui/assets/CollapsibleCard-B3KR_8mL.js +1 -0
  83. package/dist/ui/assets/DevToolsPage-OyZcDcmw.js +1 -0
  84. package/dist/ui/assets/LandingPage-CppFBA6K.js +6 -0
  85. package/dist/ui/assets/LogsPage-9Fq8GArS.js +26 -0
  86. package/dist/ui/assets/NotFoundPage-B3quk3P1.js +1 -0
  87. package/dist/ui/assets/PluginCreatePage-X_aCH4t4.js +50 -0
  88. package/dist/ui/assets/PluginPage-DMDSihrZ.js +27 -0
  89. package/dist/ui/assets/alert-jQ9HCPIf.js +1133 -0
  90. package/dist/ui/assets/badge-CNq0-mH5.js +1 -0
  91. package/dist/ui/assets/card-DFAwwhN3.js +1 -0
  92. package/dist/ui/assets/chevron-down-CPsvsmqj.js +6 -0
  93. package/dist/ui/assets/chevron-up-Df9jMo1X.js +6 -0
  94. package/dist/ui/assets/circle-alert-DOPQPvU8.js +6 -0
  95. package/dist/ui/assets/index-BkD6DijD.js +15 -0
  96. package/dist/ui/assets/index-CERGVYZK.js +292 -0
  97. package/dist/ui/assets/index-CSIPf9qw.css +1 -0
  98. package/dist/ui/assets/input-Dzvg_ZEZ.js +1 -0
  99. package/dist/ui/assets/label-DuVnkZ4q.js +1 -0
  100. package/dist/ui/assets/loader-circle-CrvlRy5o.js +6 -0
  101. package/dist/ui/assets/loginPage-qa4V-B70.js +6 -0
  102. package/dist/ui/assets/select-DhS8YUtJ.js +1 -0
  103. package/dist/ui/assets/separator-isK4chBP.js +6 -0
  104. package/dist/ui/assets/severityOptions-O38dSOfk.js +11 -0
  105. package/dist/ui/assets/switch-Z3mImG9n.js +1 -0
  106. package/dist/ui/assets/tabs-_77MUUQe.js +16 -0
  107. package/dist/ui/assets/upload-C1LT4Gkb.js +16 -0
  108. package/dist/ui/assets/utilService-DNyqzwj0.js +1 -0
  109. package/dist/ui/index.html +2 -2
  110. package/package.json +18 -7
  111. package/dist/ui/assets/index-BzIdRox6.js +0 -1733
  112. package/dist/ui/assets/index-CkoHzrrt.css +0 -1
@@ -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 pluginLogExporter: PluginLogExporter;
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 { OasTlmConfig } from "../config/config.types.js";
2
- export declare function getAgent(oasTlmConfig: OasTlmConfig): (question: string) => Promise<any>;
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
- import { OasTlmConfig } from "../config/config.types.js";
3
- export declare const answerQuestion: (oasTlmConfig: OasTlmConfig) => (req: Request, res: Response) => Promise<void>;
4
- export declare const setKnownMicroservicesHandler: () => (req: Request, res: Response) => void;
5
- export declare const getKnownMicroservicesHandler: () => (req: Request, res: Response) => void;
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 "../config/config.types.js";
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: Date, endDate: Date) => Promise<{
16
+ getLogs: (startDate: string | undefined, endDate: string | undefined) => Promise<{
17
17
  logs: {
18
18
  service: any;
19
- timestamp: any;
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
- getCurrentTimestampInEpoch: () => {
38
- currentTimestampInEpoch: number;
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, };
@@ -2,4 +2,5 @@ import { Request, Response } from 'express';
2
2
  import { OasTlmConfig } from "../config/config.types.js";
3
3
  export declare const getLogin: (oasTlmConfig: OasTlmConfig) => (req: Request, res: Response) => void;
4
4
  export declare const getLogout: (oasTlmConfig: OasTlmConfig) => (req: Request, res: Response) => void;
5
- export declare const getCheck: (oasTlmConfig: OasTlmConfig) => (req: Request, res: Response) => void;
5
+ export declare const getRefresh: (oasTlmConfig: OasTlmConfig) => (req: Request, res: Response) => void;
6
+ export declare const getAuthEnabled: (oasTlmConfig: OasTlmConfig) => (req: Request, res: Response) => void;
@@ -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 setRetentionTimeLogs: (req: Request, res: Response) => void;
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 setRetentionTimeMetrics: (req: Request, res: Response) => void;
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 setRetentionTimeTraces: (req: Request, res: Response) => void;
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};
@@ -0,0 +1,6 @@
1
+ import{c as he,r as i,u as O,a as ve,j as t,P as W,b as te,d as ge,e as V,f as ye,g as ne,h as be,i as Ne,R as je,A as Ce,k as we,l as Ee,C as Te,m as Pe,n as Re,o as Oe,p as Y,F as X,M as De,W as Le,q as Ae,B as _e,s as Me,U as ke}from"./index-CERGVYZK.js";import{B as Se}from"./badge-CNq0-mH5.js";import{C as A,a as _,b as K,c as J,d as Q}from"./card-DFAwwhN3.js";import{L as Ie}from"./label-DuVnkZ4q.js";import{S as Fe}from"./switch-Z3mImG9n.js";import{u as Ue}from"./utilService-DNyqzwj0.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 He=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],F=he("external-link",He);function j(e,s,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return s==null?void 0:s(o)}}var Be="DismissableLayer",U="dismissableLayer.update",We="dismissableLayer.pointerDownOutside",ze="dismissableLayer.focusOutside",Z,se=i.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),re=i.forwardRef((e,s)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:l,onInteractOutside:u,onDismiss:m,...d}=e,c=i.useContext(se),[a,x]=i.useState(null),f=(a==null?void 0:a.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=i.useState({}),v=O(s,h=>x(h)),g=Array.from(c.layers),[y]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),N=g.indexOf(y),b=a?g.indexOf(a):-1,w=c.layersWithOutsidePointerEventsDisabled.size>0,C=b>=N,E=qe(h=>{const L=h.target,q=[...c.branches].some(I=>I.contains(L));!C||q||(o==null||o(h),u==null||u(h),h.defaultPrevented||m==null||m())},f),P=Ve(h=>{const L=h.target;[...c.branches].some(I=>I.contains(L))||(l==null||l(h),u==null||u(h),h.defaultPrevented||m==null||m())},f);return ve(h=>{b===c.layers.size-1&&(r==null||r(h),!h.defaultPrevented&&m&&(h.preventDefault(),m()))},f),i.useEffect(()=>{if(a)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(Z=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(a)),c.layers.add(a),ee(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=Z)}},[a,f,n,c]),i.useEffect(()=>()=>{a&&(c.layers.delete(a),c.layersWithOutsidePointerEventsDisabled.delete(a),ee())},[a,c]),i.useEffect(()=>{const h=()=>p({});return document.addEventListener(U,h),()=>document.removeEventListener(U,h)},[]),t.jsx(W.div,{...d,ref:v,style:{pointerEvents:w?C?"auto":"none":void 0,...e.style},onFocusCapture:j(e.onFocusCapture,P.onFocusCapture),onBlurCapture:j(e.onBlurCapture,P.onBlurCapture),onPointerDownCapture:j(e.onPointerDownCapture,E.onPointerDownCapture)})});re.displayName=Be;var Ge="DismissableLayerBranch",$e=i.forwardRef((e,s)=>{const n=i.useContext(se),r=i.useRef(null),o=O(s,r);return i.useEffect(()=>{const l=r.current;if(l)return n.branches.add(l),()=>{n.branches.delete(l)}},[n.branches]),t.jsx(W.div,{...e,ref:o})});$e.displayName=Ge;function qe(e,s=globalThis==null?void 0:globalThis.document){const n=te(e),r=i.useRef(!1),o=i.useRef(()=>{});return i.useEffect(()=>{const l=m=>{if(m.target&&!r.current){let d=function(){oe(We,n,c,{discrete:!0})};const c={originalEvent:m};m.pointerType==="touch"?(s.removeEventListener("click",o.current),o.current=d,s.addEventListener("click",o.current,{once:!0})):d()}else s.removeEventListener("click",o.current);r.current=!1},u=window.setTimeout(()=>{s.addEventListener("pointerdown",l)},0);return()=>{window.clearTimeout(u),s.removeEventListener("pointerdown",l),s.removeEventListener("click",o.current)}},[s,n]),{onPointerDownCapture:()=>r.current=!0}}function Ve(e,s=globalThis==null?void 0:globalThis.document){const n=te(e),r=i.useRef(!1);return i.useEffect(()=>{const o=l=>{l.target&&!r.current&&oe(ze,n,{originalEvent:l},{discrete:!1})};return s.addEventListener("focusin",o),()=>s.removeEventListener("focusin",o)},[s,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function ee(){const e=new CustomEvent(U);document.dispatchEvent(e)}function oe(e,s,n,{discrete:r}){const o=n.originalEvent.target,l=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});s&&o.addEventListener(e,s,{once:!0}),r?ge(o,l):o.dispatchEvent(l)}function Ye(e,s){return i.useReducer((n,r)=>s[n][r]??n,e)}var z=e=>{const{present:s,children:n}=e,r=Xe(s),o=typeof n=="function"?n({present:r.isPresent}):i.Children.only(n),l=O(r.ref,Ke(o));return typeof n=="function"||r.isPresent?i.cloneElement(o,{ref:l}):null};z.displayName="Presence";function Xe(e){const[s,n]=i.useState(),r=i.useRef(null),o=i.useRef(e),l=i.useRef("none"),u=e?"mounted":"unmounted",[m,d]=Ye(u,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return i.useEffect(()=>{const c=M(r.current);l.current=m==="mounted"?c:"none"},[m]),V(()=>{const c=r.current,a=o.current;if(a!==e){const f=l.current,p=M(c);e?d("MOUNT"):p==="none"||(c==null?void 0:c.display)==="none"?d("UNMOUNT"):d(a&&f!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,d]),V(()=>{if(s){let c;const a=s.ownerDocument.defaultView??window,x=p=>{const g=M(r.current).includes(CSS.escape(p.animationName));if(p.target===s&&g&&(d("ANIMATION_END"),!o.current)){const y=s.style.animationFillMode;s.style.animationFillMode="forwards",c=a.setTimeout(()=>{s.style.animationFillMode==="forwards"&&(s.style.animationFillMode=y)})}},f=p=>{p.target===s&&(l.current=M(r.current))};return s.addEventListener("animationstart",f),s.addEventListener("animationcancel",x),s.addEventListener("animationend",x),()=>{a.clearTimeout(c),s.removeEventListener("animationstart",f),s.removeEventListener("animationcancel",x),s.removeEventListener("animationend",x)}}else d("ANIMATION_END")},[s,d]),{isPresent:["mounted","unmountSuspended"].includes(m),ref:i.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function M(e){return(e==null?void 0:e.animationName)||"none"}function Ke(e){var r,o;let s=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=s&&"isReactWarning"in s&&s.isReactWarning;return n?e.ref:(s=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=s&&"isReactWarning"in s&&s.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var[k,Ot]=ye("Tooltip",[ne]),S=ne(),ae="TooltipProvider",Je=700,H="tooltip.open",[Qe,G]=k(ae),ie=e=>{const{__scopeTooltip:s,delayDuration:n=Je,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:l}=e,u=i.useRef(!0),m=i.useRef(!1),d=i.useRef(0);return i.useEffect(()=>{const c=d.current;return()=>window.clearTimeout(c)},[]),t.jsx(Qe,{scope:s,isOpenDelayedRef:u,delayDuration:n,onOpen:i.useCallback(()=>{window.clearTimeout(d.current),u.current=!1},[]),onClose:i.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>u.current=!0,r)},[r]),isPointerInTransitRef:m,onPointerInTransitChange:i.useCallback(c=>{m.current=c},[]),disableHoverableContent:o,children:l})};ie.displayName=ae;var R="Tooltip",[Ze,D]=k(R),le=e=>{const{__scopeTooltip:s,children:n,open:r,defaultOpen:o,onOpenChange:l,disableHoverableContent:u,delayDuration:m}=e,d=G(R,e.__scopeTooltip),c=S(s),[a,x]=i.useState(null),f=be(),p=i.useRef(0),v=u??d.disableHoverableContent,g=m??d.delayDuration,y=i.useRef(!1),[N,b]=Ne({prop:r,defaultProp:o??!1,onChange:h=>{h?(d.onOpen(),document.dispatchEvent(new CustomEvent(H))):d.onClose(),l==null||l(h)},caller:R}),w=i.useMemo(()=>N?y.current?"delayed-open":"instant-open":"closed",[N]),C=i.useCallback(()=>{window.clearTimeout(p.current),p.current=0,y.current=!1,b(!0)},[b]),E=i.useCallback(()=>{window.clearTimeout(p.current),p.current=0,b(!1)},[b]),P=i.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{y.current=!0,b(!0),p.current=0},g)},[g,b]);return i.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),t.jsx(je,{...c,children:t.jsx(Ze,{scope:s,contentId:f,open:N,stateAttribute:w,trigger:a,onTriggerChange:x,onTriggerEnter:i.useCallback(()=>{d.isOpenDelayedRef.current?P():C()},[d.isOpenDelayedRef,P,C]),onTriggerLeave:i.useCallback(()=>{v?E():(window.clearTimeout(p.current),p.current=0)},[E,v]),onOpen:C,onClose:E,disableHoverableContent:v,children:n})})};le.displayName=R;var B="TooltipTrigger",ce=i.forwardRef((e,s)=>{const{__scopeTooltip:n,...r}=e,o=D(B,n),l=G(B,n),u=S(n),m=i.useRef(null),d=O(s,m,o.onTriggerChange),c=i.useRef(!1),a=i.useRef(!1),x=i.useCallback(()=>c.current=!1,[]);return i.useEffect(()=>()=>document.removeEventListener("pointerup",x),[x]),t.jsx(Ce,{asChild:!0,...u,children:t.jsx(W.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:d,onPointerMove:j(e.onPointerMove,f=>{f.pointerType!=="touch"&&!a.current&&!l.isPointerInTransitRef.current&&(o.onTriggerEnter(),a.current=!0)}),onPointerLeave:j(e.onPointerLeave,()=>{o.onTriggerLeave(),a.current=!1}),onPointerDown:j(e.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",x,{once:!0})}),onFocus:j(e.onFocus,()=>{c.current||o.onOpen()}),onBlur:j(e.onBlur,o.onClose),onClick:j(e.onClick,o.onClose)})})});ce.displayName=B;var $="TooltipPortal",[et,tt]=k($,{forceMount:void 0}),de=e=>{const{__scopeTooltip:s,forceMount:n,children:r,container:o}=e,l=D($,s);return t.jsx(et,{scope:s,forceMount:n,children:t.jsx(z,{present:n||l.open,children:t.jsx(we,{asChild:!0,container:o,children:r})})})};de.displayName=$;var T="TooltipContent",ue=i.forwardRef((e,s)=>{const n=tt(T,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...l}=e,u=D(T,e.__scopeTooltip);return t.jsx(z,{present:r||u.open,children:u.disableHoverableContent?t.jsx(me,{side:o,...l,ref:s}):t.jsx(nt,{side:o,...l,ref:s})})}),nt=i.forwardRef((e,s)=>{const n=D(T,e.__scopeTooltip),r=G(T,e.__scopeTooltip),o=i.useRef(null),l=O(s,o),[u,m]=i.useState(null),{trigger:d,onClose:c}=n,a=o.current,{onPointerInTransitChange:x}=r,f=i.useCallback(()=>{m(null),x(!1)},[x]),p=i.useCallback((v,g)=>{const y=v.currentTarget,N={x:v.clientX,y:v.clientY},b=at(N,y.getBoundingClientRect()),w=it(N,b),C=lt(g.getBoundingClientRect()),E=dt([...w,...C]);m(E),x(!0)},[x]);return i.useEffect(()=>()=>f(),[f]),i.useEffect(()=>{if(d&&a){const v=y=>p(y,a),g=y=>p(y,d);return d.addEventListener("pointerleave",v),a.addEventListener("pointerleave",g),()=>{d.removeEventListener("pointerleave",v),a.removeEventListener("pointerleave",g)}}},[d,a,p,f]),i.useEffect(()=>{if(u){const v=g=>{const y=g.target,N={x:g.clientX,y:g.clientY},b=(d==null?void 0:d.contains(y))||(a==null?void 0:a.contains(y)),w=!ct(N,u);b?f():w&&(f(),c())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[d,a,u,c,f]),t.jsx(me,{...e,ref:l})}),[st,rt]=k(R,{isInside:!1}),ot=Pe("TooltipContent"),me=i.forwardRef((e,s)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:l,onPointerDownOutside:u,...m}=e,d=D(T,n),c=S(n),{onClose:a}=d;return i.useEffect(()=>(document.addEventListener(H,a),()=>document.removeEventListener(H,a)),[a]),i.useEffect(()=>{if(d.trigger){const x=f=>{const p=f.target;p!=null&&p.contains(d.trigger)&&a()};return window.addEventListener("scroll",x,{capture:!0}),()=>window.removeEventListener("scroll",x,{capture:!0})}},[d.trigger,a]),t.jsx(re,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:x=>x.preventDefault(),onDismiss:a,children:t.jsxs(Te,{"data-state":d.stateAttribute,...c,...m,ref:s,style:{...m.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[t.jsx(ot,{children:r}),t.jsx(st,{scope:n,isInside:!0,children:t.jsx(Re,{id:d.contentId,role:"tooltip",children:o||r})})]})})});ue.displayName=T;var pe="TooltipArrow",xe=i.forwardRef((e,s)=>{const{__scopeTooltip:n,...r}=e,o=S(n);return rt(pe,n).isInside?null:t.jsx(Ee,{...o,...r,ref:s})});xe.displayName=pe;function at(e,s){const n=Math.abs(s.top-e.y),r=Math.abs(s.bottom-e.y),o=Math.abs(s.right-e.x),l=Math.abs(s.left-e.x);switch(Math.min(n,r,o,l)){case l:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function it(e,s,n=5){const r=[];switch(s){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function lt(e){const{top:s,right:n,bottom:r,left:o}=e;return[{x:o,y:s},{x:n,y:s},{x:n,y:r},{x:o,y:r}]}function ct(e,s){const{x:n,y:r}=e;let o=!1;for(let l=0,u=s.length-1;l<s.length;u=l++){const m=s[l],d=s[u],c=m.x,a=m.y,x=d.x,f=d.y;a>r!=f>r&&n<(x-c)*(r-a)/(f-a)+c&&(o=!o)}return o}function dt(e){const s=e.slice();return s.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),ut(s)}function ut(e){if(e.length<=1)return e.slice();const s=[];for(let r=0;r<e.length;r++){const o=e[r];for(;s.length>=2;){const l=s[s.length-1],u=s[s.length-2];if((l.x-u.x)*(o.y-u.y)>=(l.y-u.y)*(o.x-u.x))s.pop();else break}s.push(o)}s.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const l=n[n.length-1],u=n[n.length-2];if((l.x-u.x)*(o.y-u.y)>=(l.y-u.y)*(o.x-u.x))n.pop();else break}n.push(o)}return n.pop(),s.length===1&&n.length===1&&s[0].x===n[0].x&&s[0].y===n[0].y?s:s.concat(n)}var mt=ie,pt=le,xt=ce,ft=de,ht=ue,vt=xe;function fe({delayDuration:e=0,...s}){return t.jsx(mt,{"data-slot":"tooltip-provider",delayDuration:e,...s})}function gt({...e}){return t.jsx(fe,{children:t.jsx(pt,{"data-slot":"tooltip",...e})})}function yt({...e}){return t.jsx(xt,{"data-slot":"tooltip-trigger",...e})}function bt({className:e,sideOffset:s=0,children:n,...r}){return t.jsx(ft,{children:t.jsxs(ht,{"data-slot":"tooltip-content",sideOffset:s,className:Oe("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...r,children:[n,t.jsx(vt,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}const Nt=e=>{switch(e){case"INFO":return"bg-blue-100 text-blue-800 border-blue-200";case"WARN":return"bg-yellow-100 text-yellow-800 border-yellow-200";case"ERROR":return"bg-red-100 text-red-800 border-red-200";default:return"bg-gray-100 text-gray-800 border-gray-200"}};function jt({content:e,timestamp:s,isUser:n}){return t.jsxs("div",{className:`flex items-end gap-2 ${n?"justify-end":"justify-start"}`,children:[!n&&t.jsx("div",{className:"flex-shrink-0 w-7 h-7 rounded-full border m-1 p-1 flex items-center justify-center",children:t.jsx(Me,{className:"w-4 h-4"})}),t.jsxs("div",{className:`max-w-[70%] rounded-md px-2 py-1 break-words ${n?"bg-primary text-primary-foreground":"bg-muted text-foreground"} text-xs`,children:[e,t.jsx("span",{className:"text-[10px] opacity-60 mt-0.5 block",children:s.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"})})]}),n&&t.jsx("div",{className:"flex-shrink-0 w-7 h-7 rounded-full border m-1 p-1 flex items-center justify-center",children:t.jsx(ke,{className:"w-4 h-4"})})]})}function Dt(){Y();const[e,s]=i.useState(null),[n,r]=i.useState(!1);i.useEffect(()=>{o()},[]),i.useEffect(()=>{if(!n)return;const a=setInterval(o,2e3);return()=>clearInterval(a)},[n]);const o=async()=>{try{const a=await Ue.getHeapStats();s(a)}catch(a){console.error("Failed to load heap stats:",a)}},l=[{level:"INFO",message:"Server started on port 3000",time:"12:30:00"},{level:"WARN",message:"High memory usage detected",time:"12:32:15"},{level:"ERROR",message:"Database connection timeout",time:"12:33:42"},{level:"ERROR",message:"Endpoint /api/v1/orders failed with status 500",time:"12:34:10"},{level:"WARN",message:"Slow response detected on /api/v1/users",time:"12:34:30"}],u=[{role:"user",content:"What happened in the last error?",timestamp:new Date(Date.now()-6e4)},{role:"assistant",content:"The last error was a database connection timeout at 12:33.",timestamp:new Date(Date.now()-3e4)},{role:"user",content:"Any critical issues?",timestamp:new Date(Date.now()-2e4)},{role:"assistant",content:"Detected that endpoint /api/v1/orders consistently generates error logs.",timestamp:new Date}],m=[{key:"logs",to:"/logs",hoverMessage:"Go to logs page",header:t.jsxs(t.Fragment,{children:[t.jsxs(A,{className:"flex items-center gap-2",children:[t.jsx(X,{className:"h-5 w-5 text-purple-600"}),"Logs",t.jsx(F,{className:"h-4 w-4 text-gray-400"})]}),t.jsx(_,{children:"Latest system events and messages."})]}),content:t.jsx("div",{className:"space-y-3",children:l.map((a,x)=>t.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[t.jsx(Se,{className:`${Nt(a.level)} border rounded-sm text-xs`,children:a.level}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"text-gray-900",children:a.message}),t.jsx("div",{className:"text-gray-500 text-[10px]",children:a.time})]})]},x))})},{key:"chat",to:"/chat",hoverMessage:"Go to chat page",header:t.jsxs(t.Fragment,{children:[t.jsxs(A,{className:"flex items-center gap-2",children:[t.jsx(De,{className:"h-5 w-5 text-blue-600"}),"AI Chat",t.jsx(F,{className:"h-4 w-4 text-gray-400"})]}),t.jsx(_,{children:"Ask the AI about logs and server requests."})]}),content:t.jsx("div",{className:"space-y-2",children:u.map((a,x)=>t.jsx(jt,{content:a.content,timestamp:a.timestamp,isUser:a.role==="user"},x))})},{key:"plugins",to:"/plugins",hoverMessage:"Go to plugins page",header:t.jsxs(t.Fragment,{children:[t.jsxs(A,{className:"flex items-center gap-2",children:[t.jsx(Ae,{className:"h-5 w-5 text-green-600"}),"Plugin System",t.jsx(F,{className:"h-4 w-4 text-gray-400"})]}),t.jsx(_,{children:"Extend telemetry with custom plugins."})]}),content:t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Le,{className:"h-4 w-4 text-yellow-700"}),t.jsx("span",{className:"font-semibold text-sm",children:"Error Detector Plugin"})]}),t.jsx("div",{className:"text-xs text-muted-foreground",children:"Monitors logs and traces for critical errors and sends notifications."}),t.jsxs("div",{className:"bg-gray-100 rounded p-2 mt-2 text-xs font-mono",children:[t.jsx("span",{className:"text-green-700",children:"Plugin active"}),": ",t.jsx("span",{className:"text-gray-700",children:'Detects "ERROR" logs and alerts team.'})]}),t.jsxs("div",{className:"bg-gray-100 rounded p-2 text-xs font-mono",children:[t.jsx("span",{className:"text-blue-700",children:"Plugin detected"}),": ",t.jsx("span",{className:"text-gray-700",children:"5 logs of error caused by the same endpoint."})]}),t.jsxs("div",{className:"bg-gray-100 rounded p-2 text-xs font-mono",children:[t.jsx("span",{className:"text-purple-700",children:"Plugin info"}),": ",t.jsx("span",{className:"text-gray-700",children:"No critical errors detected in the last 24h."})]})]})}];function d({children:a,header:x,hoverMessage:f,to:p}){const[v,g]=i.useState(!1),y=Y();return t.jsxs(K,{className:"relative group cursor-pointer",tabIndex:0,role:"button",onClick:()=>y(p),onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),children:[t.jsx(J,{children:x}),t.jsxs(Q,{className:"relative min-h-[260px] rounded-lg overflow-hidden flex flex-col justify-center px-10",children:[a,t.jsx("div",{className:`absolute inset-0 flex items-center justify-center z-10 transition-opacity duration-200 rounded-lg mx-6 ${v?"bg-gray-900 opacity-100":"bg-gray-900 opacity-5"}`,children:t.jsx("span",{className:"text-white font-semibold text-lg transition-opacity duration-200",children:v?f:""})})]})]})}function c(){return t.jsx("div",{className:"flex flex-col gap-8 xl:grid xl:grid-cols-3 xl:gap-8 ",children:m.map(a=>t.jsx(d,{header:a.header,hoverMessage:a.hoverMessage,to:a.to,children:a.content},a.key))})}return t.jsx("div",{className:"min-h-screen bg-gray-50",children:t.jsx(fe,{children:t.jsx("section",{className:"py-16",children:t.jsxs("div",{className:"container mx-auto px-6",children:[t.jsxs(K,{children:[t.jsxs(J,{children:[t.jsxs(A,{className:"flex items-center gap-2",children:[t.jsx(X,{className:"h-5 w-5"}),"Heap Statistics"]}),t.jsx(_,{children:"Memory usage and performance metrics"})]}),t.jsxs(Q,{children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx(Fe,{id:"auto-update-heap",checked:n,onCheckedChange:r}),t.jsxs(Ie,{htmlFor:"auto-update-heap",children:["Auto Update: ",n?"Enabled":"Manual"]})]}),t.jsxs(gt,{children:[t.jsx(yt,{asChild:!0,children:t.jsx(_e,{onClick:o,variant:"outline",size:"sm",disabled:n,className:n?"opacity-50 cursor-not-allowed":"",children:"Update"})}),t.jsx(bt,{children:n?"Disabled while auto update is enabled":"Click to manually update heap stats"})]})]}),e&&t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[t.jsxs("div",{className:"bg-blue-50 p-4 rounded-lg",children:[t.jsx("div",{className:"text-sm font-medium text-blue-600",children:"Used Heap"}),t.jsxs("div",{className:"text-2xl font-bold text-blue-900",children:[e.used_heap_size.toFixed(2)," ",e.units]})]}),t.jsxs("div",{className:"bg-green-50 p-4 rounded-lg",children:[t.jsx("div",{className:"text-sm font-medium text-green-600",children:"Total Heap"}),t.jsxs("div",{className:"text-2xl font-bold text-green-900",children:[e.total_heap_size.toFixed(2)," ",e.units]})]}),t.jsxs("div",{className:"bg-yellow-50 p-4 rounded-lg",children:[t.jsx("div",{className:"text-sm font-medium text-yellow-600",children:"Available"}),t.jsxs("div",{className:"text-2xl font-bold text-yellow-900",children:[e.total_available_size.toFixed(2)," ",e.units]})]}),t.jsxs("div",{className:"bg-purple-50 p-4 rounded-lg",children:[t.jsx("div",{className:"text-sm font-medium text-purple-600",children:"External Memory"}),t.jsxs("div",{className:"text-2xl font-bold text-purple-900",children:[e.external_memory.toFixed(2)," ",e.units]})]}),t.jsxs("div",{className:"bg-red-50 p-4 rounded-lg",children:[t.jsx("div",{className:"text-sm font-medium text-red-600",children:"Heap Limit"}),t.jsxs("div",{className:"text-2xl font-bold text-red-900",children:[e.heap_size_limit.toFixed(2)," ",e.units]})]}),t.jsxs("div",{className:"bg-indigo-50 p-4 rounded-lg",children:[t.jsx("div",{className:"text-sm font-medium text-indigo-600",children:"Peak Malloc"}),t.jsxs("div",{className:"text-2xl font-bold text-indigo-900",children:[e.peak_malloced_memory.toFixed(2)," ",e.units]})]}),t.jsxs("div",{className:"bg-pink-50 p-4 rounded-lg",children:[t.jsx("div",{className:"text-sm font-medium text-pink-600",children:"Native Contexts"}),t.jsx("div",{className:"text-2xl font-bold text-pink-900",children:e.number_of_native_contexts})]}),t.jsxs("div",{className:"bg-cyan-50 p-4 rounded-lg",children:[t.jsx("div",{className:"text-sm font-medium text-cyan-600",children:"Global Handles"}),t.jsxs("div",{className:"text-2xl font-bold text-cyan-900",children:[e.used_global_handles_size.toFixed(3)," ",e.units]})]})]})]})]}),t.jsx("div",{className:"mt-10"}),t.jsx(c,{})]})})})})}export{Dt as default};