@oas-tools/oas-telemetry 0.7.1 → 0.8.0-alpha.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 +21 -2
- package/README.md +1 -2
- package/dist/cjs/config/bootConfig.cjs +19 -14
- package/dist/cjs/config/config.cjs +112 -125
- package/dist/cjs/config/config.types.cjs +1 -4
- package/dist/cjs/docs/openapi.yaml +158 -4
- package/dist/cjs/index.cjs +27 -30
- package/dist/cjs/routesManager.cjs +62 -70
- package/dist/cjs/telemetry/custom-implementations/exporters/InMemoryDbLogExporter.cjs +202 -190
- package/dist/cjs/telemetry/custom-implementations/exporters/InMemoryDbMetricExporter.cjs +204 -99
- package/dist/cjs/telemetry/custom-implementations/exporters/InMemoryDbSpanExporter.cjs +152 -116
- package/dist/cjs/telemetry/custom-implementations/instrumentations/logsInstrumentation.cjs +92 -0
- package/dist/cjs/telemetry/custom-implementations/metrics/tsdb/Chunk.cjs +159 -0
- package/dist/cjs/telemetry/custom-implementations/metrics/tsdb/Series.cjs +168 -0
- package/dist/cjs/telemetry/custom-implementations/metrics/tsdb/SeriesRegistry.cjs +389 -0
- package/dist/cjs/telemetry/custom-implementations/metrics/tsdb/types.cjs +2 -0
- package/dist/cjs/telemetry/custom-implementations/metrics/tsdb/utils.cjs +77 -0
- package/dist/cjs/telemetry/custom-implementations/processors/dynamicMultiLogProcessor.cjs +65 -63
- package/dist/cjs/telemetry/custom-implementations/processors/dynamicMultiSpanProcessor.cjs +63 -62
- package/dist/cjs/telemetry/custom-implementations/utils/circular.cjs +47 -47
- package/dist/cjs/telemetry/custom-implementations/utils/storagePath.cjs +39 -0
- package/dist/cjs/telemetry/custom-implementations/wrappers.cjs +141 -138
- package/dist/cjs/telemetry/initializeTelemetry.cjs +35 -91
- package/dist/cjs/telemetry/telemetryConfigurator.cjs +70 -72
- package/dist/cjs/telemetry/telemetryRegistry.cjs +45 -31
- package/dist/cjs/tlm-ai/agent.cjs +49 -64
- package/dist/cjs/tlm-ai/aiController.cjs +54 -76
- package/dist/cjs/tlm-ai/aiRoutes.cjs +17 -20
- package/dist/cjs/tlm-ai/aiService.cjs +91 -95
- package/dist/cjs/tlm-ai/tools.cjs +177 -174
- package/dist/cjs/tlm-auth/authController.cjs +80 -123
- package/dist/cjs/tlm-auth/authMiddleware.cjs +25 -30
- package/dist/cjs/tlm-auth/authRoutes.cjs +11 -14
- package/dist/cjs/tlm-log/logController.cjs +171 -116
- package/dist/cjs/tlm-log/logRoutes.cjs +20 -20
- package/dist/cjs/tlm-metric/metricsController.cjs +211 -121
- package/dist/cjs/tlm-metric/metricsRoutes.cjs +23 -20
- package/dist/cjs/tlm-plugin/pluginController.cjs +128 -140
- package/dist/cjs/tlm-plugin/pluginProcess.cjs +89 -94
- package/dist/cjs/tlm-plugin/pluginRoutes.cjs +11 -14
- package/dist/cjs/tlm-plugin/pluginService.cjs +73 -74
- package/dist/cjs/tlm-trace/traceController.cjs +169 -117
- package/dist/cjs/tlm-trace/traceRoutes.cjs +20 -20
- package/dist/cjs/tlm-ui/uiRoutes.cjs +63 -32
- package/dist/cjs/tlm-util/utilController.cjs +68 -70
- package/dist/cjs/tlm-util/utilRoutes.cjs +51 -63
- package/dist/cjs/types/index.cjs +2 -5
- package/dist/cjs/utils/logger.cjs +38 -43
- package/dist/cjs/utils/regexUtils.cjs +22 -22
- package/dist/esm/config/bootConfig.js +6 -0
- package/dist/esm/config/config.js +1 -2
- package/dist/esm/docs/openapi.yaml +158 -4
- package/dist/esm/index.js +9 -8
- package/dist/esm/routesManager.js +6 -10
- package/dist/esm/telemetry/custom-implementations/exporters/InMemoryDbLogExporter.js +47 -8
- package/dist/esm/telemetry/custom-implementations/exporters/InMemoryDbMetricExporter.js +164 -48
- package/dist/esm/telemetry/custom-implementations/exporters/InMemoryDbSpanExporter.js +69 -29
- package/dist/esm/telemetry/custom-implementations/instrumentations/logsInstrumentation.js +85 -0
- package/dist/esm/telemetry/custom-implementations/metrics/tsdb/Chunk.js +155 -0
- package/dist/esm/telemetry/custom-implementations/metrics/tsdb/Series.js +164 -0
- package/dist/esm/telemetry/custom-implementations/metrics/tsdb/SeriesRegistry.js +382 -0
- package/dist/esm/telemetry/custom-implementations/metrics/tsdb/types.js +1 -0
- package/dist/esm/telemetry/custom-implementations/metrics/tsdb/utils.js +74 -0
- package/dist/esm/telemetry/custom-implementations/processors/dynamicMultiLogProcessor.js +2 -1
- package/dist/esm/telemetry/custom-implementations/processors/dynamicMultiSpanProcessor.js +1 -1
- package/dist/esm/telemetry/custom-implementations/utils/storagePath.js +33 -0
- package/dist/esm/telemetry/custom-implementations/wrappers.js +5 -2
- package/dist/esm/telemetry/initializeTelemetry.js +27 -69
- package/dist/esm/telemetry/telemetryConfigurator.js +42 -40
- package/dist/esm/telemetry/telemetryRegistry.js +12 -1
- package/dist/esm/tlm-ai/agent.js +5 -3
- package/dist/esm/tlm-ai/aiController.js +3 -3
- package/dist/esm/tlm-ai/aiService.js +6 -2
- package/dist/esm/tlm-ai/tools.js +5 -9
- package/dist/esm/tlm-auth/authController.js +3 -2
- package/dist/esm/tlm-log/logController.js +84 -4
- package/dist/esm/tlm-log/logRoutes.js +5 -2
- package/dist/esm/tlm-metric/metricsController.js +172 -49
- package/dist/esm/tlm-metric/metricsRoutes.js +10 -4
- package/dist/esm/tlm-plugin/pluginController.js +6 -11
- package/dist/esm/tlm-plugin/pluginService.js +2 -4
- package/dist/esm/tlm-trace/traceController.js +102 -16
- package/dist/esm/tlm-trace/traceRoutes.js +5 -2
- package/dist/esm/tlm-ui/uiRoutes.js +5 -5
- package/dist/esm/tlm-util/utilController.js +3 -9
- package/dist/esm/tlm-util/utilRoutes.js +2 -2
- package/dist/types/config/bootConfig.d.ts +4 -0
- package/dist/types/config/config.d.ts +36 -7
- package/dist/types/config/config.types.d.ts +6 -0
- package/dist/types/index.d.ts +2 -3
- package/dist/types/telemetry/custom-implementations/exporters/InMemoryDbLogExporter.d.ts +4 -1
- package/dist/types/telemetry/custom-implementations/exporters/InMemoryDbMetricExporter.d.ts +60 -15
- package/dist/types/telemetry/custom-implementations/exporters/InMemoryDbSpanExporter.d.ts +9 -4
- package/dist/types/telemetry/custom-implementations/instrumentations/logsInstrumentation.d.ts +23 -0
- package/dist/types/telemetry/custom-implementations/metrics/tsdb/Chunk.d.ts +49 -0
- package/dist/types/telemetry/custom-implementations/metrics/tsdb/Series.d.ts +67 -0
- package/dist/types/telemetry/custom-implementations/metrics/tsdb/SeriesRegistry.d.ts +69 -0
- package/dist/types/telemetry/custom-implementations/metrics/tsdb/types.d.ts +68 -0
- package/dist/types/telemetry/custom-implementations/metrics/tsdb/utils.d.ts +21 -0
- package/dist/types/telemetry/custom-implementations/processors/dynamicMultiLogProcessor.d.ts +2 -2
- package/dist/types/telemetry/custom-implementations/utils/storagePath.d.ts +12 -0
- package/dist/types/telemetry/custom-implementations/wrappers.d.ts +1 -1
- package/dist/types/telemetry/telemetryConfigurator.d.ts +1 -1
- package/dist/types/telemetry/telemetryRegistry.d.ts +8 -0
- package/dist/types/tlm-ai/agent.d.ts +1 -1
- package/dist/types/tlm-ai/aiService.d.ts +1 -1
- package/dist/types/tlm-log/logController.d.ts +2 -0
- package/dist/types/tlm-metric/metricsController.d.ts +16 -2
- package/dist/types/tlm-trace/traceController.d.ts +3 -1
- package/dist/types/types/index.d.ts +2 -2
- package/dist/ui/assets/{ApiDocsPage-C_VVPPHa.js → ApiDocsPage-BFUrXE5F.js} +2 -2
- package/dist/ui/assets/CollapsibleCard-STA1GVQO.js +1 -0
- package/dist/ui/assets/DevToolsPage-BRSfZqO_.js +1 -0
- package/dist/ui/assets/LandingPage-DzeDy7q7.js +6 -0
- package/dist/ui/assets/LogsPage-BeiFrV2X.js +1 -0
- package/dist/ui/assets/{NotFoundPage-B3quk3P1.js → NotFoundPage-fRNOatbM.js} +1 -1
- package/dist/ui/assets/PluginCreatePage-Ch_RXsdf.js +50 -0
- package/dist/ui/assets/PluginPage-Cl65ZZ_n.js +27 -0
- package/dist/ui/assets/TraceSpansPage-BoK4M5Hh.js +6 -0
- package/dist/ui/assets/VirtualizedListPanel-zcj0v7DL.js +16 -0
- package/dist/ui/assets/alert-BkNVKxJN.js +1133 -0
- package/dist/ui/assets/badge-CN7FeufU.js +1 -0
- package/dist/ui/assets/{chevron-down-CPsvsmqj.js → chevron-down-CG--ounh.js} +1 -1
- package/dist/ui/assets/{chevron-up-Df9jMo1X.js → chevron-up-B6tzMAOm.js} +1 -1
- package/dist/ui/assets/{circle-alert-DOPQPvU8.js → circle-alert-BDF8Tq9y.js} +1 -1
- package/dist/ui/assets/dialog-BrpWNk36.js +15 -0
- package/dist/ui/assets/index-6xOVKwKn.js +305 -0
- package/dist/ui/assets/index-D6f1KjWV.css +1 -0
- package/dist/ui/assets/index-D96rVSkR.js +1 -0
- package/dist/ui/assets/info-99kuqpbx.js +6 -0
- package/dist/ui/assets/{input-Dzvg_ZEZ.js → input-B-01QDg_.js} +1 -1
- package/dist/ui/assets/label-CQLeZjM1.js +1 -0
- package/dist/ui/assets/{loader-circle-CrvlRy5o.js → loader-circle-BoDGk-BO.js} +1 -1
- package/dist/ui/assets/{loginPage-qa4V-B70.js → loginPage-8F4EEd1B.js} +1 -1
- package/dist/ui/assets/metrics-page-D1GxaB_c.css +1 -0
- package/dist/ui/assets/metrics-page-DPtteXqY.js +31 -0
- package/dist/ui/assets/popover-DS_8DYYt.js +11 -0
- package/dist/ui/assets/select-DYjegiXi.js +6 -0
- package/dist/ui/assets/separator-DGsRxIrl.js +6 -0
- package/dist/ui/assets/severityOptions-DEOvJqC9.js +11 -0
- package/dist/ui/assets/square-pen-DPhgYz6O.js +6 -0
- package/dist/ui/assets/switch-Di9NJH2A.js +1 -0
- package/dist/ui/assets/trace-DJq1miYa.js +1 -0
- package/dist/ui/assets/upload-BiLTpCnX.js +11 -0
- package/dist/ui/assets/{utilService-DNyqzwj0.js → utilService-CNZOmadC.js} +1 -1
- package/dist/ui/assets/wand-sparkles-CPoBNFFg.js +6 -0
- package/dist/ui/index.html +2 -2
- package/package.json +44 -48
- package/dist/ui/assets/CollapsibleCard-B3KR_8mL.js +0 -1
- package/dist/ui/assets/DevToolsPage-OyZcDcmw.js +0 -1
- package/dist/ui/assets/LandingPage-CppFBA6K.js +0 -6
- package/dist/ui/assets/LogsPage-9Fq8GArS.js +0 -26
- package/dist/ui/assets/PluginCreatePage-X_aCH4t4.js +0 -50
- package/dist/ui/assets/PluginPage-DMDSihrZ.js +0 -27
- package/dist/ui/assets/alert-jQ9HCPIf.js +0 -1133
- package/dist/ui/assets/badge-CNq0-mH5.js +0 -1
- package/dist/ui/assets/card-DFAwwhN3.js +0 -1
- package/dist/ui/assets/index-BkD6DijD.js +0 -15
- package/dist/ui/assets/index-CERGVYZK.js +0 -292
- package/dist/ui/assets/index-CSIPf9qw.css +0 -1
- package/dist/ui/assets/label-DuVnkZ4q.js +0 -1
- package/dist/ui/assets/select-DhS8YUtJ.js +0 -1
- package/dist/ui/assets/separator-isK4chBP.js +0 -6
- package/dist/ui/assets/severityOptions-O38dSOfk.js +0 -11
- package/dist/ui/assets/switch-Z3mImG9n.js +0 -1
- package/dist/ui/assets/tabs-_77MUUQe.js +0 -16
- package/dist/ui/assets/upload-C1LT4Gkb.js +0 -16
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get storage path for disk-based persistence
|
|
3
|
+
* Returns null if storage is in-memory (when OASTLM_BOOT_STORAGE_PATH is empty or not set)
|
|
4
|
+
*
|
|
5
|
+
* Environment variables (BOOT - set at startup):
|
|
6
|
+
* - OASTLM_BOOT_STORAGE_PATH: empty or not set = in-memory, else = disk path
|
|
7
|
+
* Examples:
|
|
8
|
+
* - OASTLM_BOOT_STORAGE_PATH="" (or not set) -> in-memory
|
|
9
|
+
* - OASTLM_BOOT_STORAGE_PATH="data/telemetry" -> disk at ./data/telemetry
|
|
10
|
+
* - OASTLM_BOOT_STORAGE_PATH="/var/lib/telemetry" -> disk at /var/lib/telemetry
|
|
11
|
+
*/
|
|
12
|
+
export declare function getStoragePath(name: 'traces' | 'logs' | 'metrics'): string | null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ExportResult } from "@opentelemetry/core";
|
|
2
2
|
import { LogRecordExporter, ReadableLogRecord } from "@opentelemetry/sdk-logs";
|
|
3
3
|
import { AggregationOption, AggregationTemporality, CollectionResult, IMetricReader, InstrumentType, MetricProducer } from "@opentelemetry/sdk-metrics";
|
|
4
|
-
import { CollectionOptions, ForceFlushOptions, ShutdownOptions } from "@opentelemetry/sdk-metrics/build/src/types";
|
|
4
|
+
import { CollectionOptions, ForceFlushOptions, ShutdownOptions } from "@opentelemetry/sdk-metrics/build/src/types.js";
|
|
5
5
|
import { ReadableSpan, SpanExporter } from "@opentelemetry/sdk-trace-node";
|
|
6
6
|
export declare abstract class Enabler {
|
|
7
7
|
protected _enabled: boolean;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { OasTlmConfig } from '../config/config.types.js';
|
|
2
|
-
export declare
|
|
2
|
+
export declare function configureTelemetry(oasTlmConfig: OasTlmConfig): boolean;
|
|
@@ -4,6 +4,13 @@ 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 { type Instrumentation } from "@opentelemetry/instrumentation";
|
|
8
|
+
export declare function isBootInitialized(): boolean;
|
|
9
|
+
export declare function setBootInitialized(v: boolean): void;
|
|
10
|
+
export declare function isTelemetryConfigured(): boolean;
|
|
11
|
+
export declare function setTelemetryConfigured(v: boolean): void;
|
|
12
|
+
export declare function setTelemetryRouter(router: any): void;
|
|
13
|
+
export declare function getTelemetryRouter(): any;
|
|
7
14
|
export declare const oasTelemetryResource: import("@opentelemetry/resources").Resource;
|
|
8
15
|
export declare const inMemoryDbSpanExporter: InMemoryDbSpanExporter;
|
|
9
16
|
export declare const multiSpanExporter: EnablerMultiSpanExporter;
|
|
@@ -34,3 +41,4 @@ export declare const originalConsoleMethods: {
|
|
|
34
41
|
};
|
|
35
42
|
};
|
|
36
43
|
export declare const inMemoryDbMetricExporter: InMemoryDbMetricExporter;
|
|
44
|
+
export declare const instrumentations: Instrumentation[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import OpenAI from 'openai';
|
|
2
|
-
export declare function agent(openai: OpenAI, messages: any[], model?: string
|
|
2
|
+
export declare function agent(openai: OpenAI, messages: any[], model?: string): Promise<void>;
|
|
@@ -2,8 +2,10 @@ import { Request, Response } from 'express';
|
|
|
2
2
|
export declare const findLogs: (req: Request, res: Response) => Promise<void>;
|
|
3
3
|
export declare const resetLogs: (req: Request, res: Response) => void;
|
|
4
4
|
export declare const insertLogsToDb: (req: Request, res: Response) => Promise<void>;
|
|
5
|
+
export declare const importLogs: (req: Request, res: Response) => Promise<void>;
|
|
5
6
|
export declare const startLogs: (req: Request, res: Response) => void;
|
|
6
7
|
export declare const stopLogs: (req: Request, res: Response) => void;
|
|
7
8
|
export declare const statusLogs: (req: Request, res: Response) => void;
|
|
8
9
|
export declare const setLogRetentionTime: (req: Request, res: Response) => void;
|
|
9
10
|
export declare const getLogRetentionTime: (req: Request, res: Response) => void;
|
|
11
|
+
export declare const exportLogs: (req: Request, res: Response) => Promise<void>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Request, Response } from 'express';
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const findMetrics: (req: Request, res: Response) => void;
|
|
2
|
+
export declare const getMetricsStats: (req: Request, res: Response) => Promise<void>;
|
|
4
3
|
export declare const resetMetrics: (req: Request, res: Response) => void;
|
|
5
4
|
export declare const insertMetricsToDb: (req: Request, res: Response) => Promise<void>;
|
|
6
5
|
export declare const startMetrics: (req: Request, res: Response) => void;
|
|
@@ -8,3 +7,18 @@ export declare const stopMetrics: (req: Request, res: Response) => void;
|
|
|
8
7
|
export declare const statusMetrics: (req: Request, res: Response) => void;
|
|
9
8
|
export declare const setMetricRetentionTime: (req: Request, res: Response) => void;
|
|
10
9
|
export declare const getMetricRetentionTime: (req: Request, res: Response) => void;
|
|
10
|
+
/**
|
|
11
|
+
* Find metrics by scope+metric queries with filters (POST /metrics/find or GET /metrics)
|
|
12
|
+
* All parameters are optional:
|
|
13
|
+
* - If scopeMetrics is not provided or empty, returns all metrics
|
|
14
|
+
* - If startTime/endTime not provided, returns all available data
|
|
15
|
+
* - format can be 'raw' (default) or 'otel'
|
|
16
|
+
*/
|
|
17
|
+
export declare const findMetrics: (req: Request, res: Response) => Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Check data consistency between rawDataDB and queried data
|
|
20
|
+
* Compares raw exports with findMetrics(format=otel) without filters
|
|
21
|
+
*/
|
|
22
|
+
export declare const checkMetricsConsistency: (req: Request, res: Response) => Promise<void>;
|
|
23
|
+
export declare const exportMetrics: (req: Request, res: Response) => void;
|
|
24
|
+
export declare const importMetrics: (req: Request, res: Response) => Promise<void>;
|
|
@@ -4,7 +4,9 @@ export declare const stopTraces: (req: Request, res: Response) => void;
|
|
|
4
4
|
export declare const statusTraces: (req: Request, res: Response) => void;
|
|
5
5
|
export declare const resetTraces: (req: Request, res: Response) => void;
|
|
6
6
|
export declare const listTraces: (req: Request, res: Response) => Promise<void>;
|
|
7
|
-
export declare const findTraces: (req: Request, res: Response) => void
|
|
7
|
+
export declare const findTraces: (req: Request, res: Response) => Promise<void>;
|
|
8
8
|
export declare const insertTracesToDb: (req: Request, res: Response) => Promise<void>;
|
|
9
|
+
export declare const importTraces: (req: Request, res: Response) => Promise<void>;
|
|
9
10
|
export declare const setTraceRetentionTime: (req: Request, res: Response) => void;
|
|
10
11
|
export declare const getTraceRetentionTime: (req: Request, res: Response) => void;
|
|
12
|
+
export declare const exportTraces: (req: Request, res: Response) => Promise<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReadableSpan } from '@opentelemetry/sdk-trace-base';
|
|
2
2
|
import { ResourceMetrics } from '@opentelemetry/sdk-metrics';
|
|
3
|
-
import {
|
|
3
|
+
import { SdkLogRecord } from '@opentelemetry/sdk-logs';
|
|
4
4
|
import { ChildProcess } from 'child_process';
|
|
5
5
|
export interface PluginResource {
|
|
6
6
|
url?: string;
|
|
@@ -22,5 +22,5 @@ export interface PluginImpl {
|
|
|
22
22
|
unload?(): (Promise<boolean> | boolean);
|
|
23
23
|
newTrace?: (span: ReadableSpan[]) => void;
|
|
24
24
|
newMetric?: (metric: ResourceMetrics) => void;
|
|
25
|
-
newLog?: (log:
|
|
25
|
+
newLog?: (log: SdkLogRecord) => void;
|
|
26
26
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as w,r as d,j as e,
|
|
1
|
+
import{c as w,r as d,j as e,T as B,B as I,o as O,F as P}from"./index-6xOVKwKn.js";import{u as R}from"./utilService-CNZOmadC.js";import{I as M}from"./input-B-01QDg_.js";import{b as z,c as D,C as T,a as $}from"./index-D96rVSkR.js";import{C as J}from"./CollapsibleCard-STA1GVQO.js";import{S as L,T as _}from"./separator-DGsRxIrl.js";import{S as U}from"./square-pen-DPhgYz6O.js";import{U as A,D as F}from"./upload-BiLTpCnX.js";import"./chevron-up-B6tzMAOm.js";import"./chevron-down-CG--ounh.js";/**
|
|
2
2
|
* @license lucide-react v0.515.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -13,4 +13,4 @@ import{c as w,r as d,j as e,I,B,y as O,F as P}from"./index-CERGVYZK.js";import{u
|
|
|
13
13
|
*
|
|
14
14
|
* This source code is licensed under the ISC license.
|
|
15
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
|
|
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 de=()=>{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(B,{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(I,{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{de as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as s,B as l}from"./index-6xOVKwKn.js";import{b as n,c as i,d as m}from"./index-D96rVSkR.js";import{C as c}from"./chevron-up-B6tzMAOm.js";import{C as x}from"./chevron-down-CG--ounh.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,T as M,B as g,Z as F,t}from"./index-6xOVKwKn.js";import{C as G,a as I}from"./index-D96rVSkR.js";import{I as x}from"./input-B-01QDg_.js";import{L as r}from"./label-CQLeZjM1.js";import{T as D,a as E,b as u,c as h,S as P,d as O,e as R,f as V,g as W}from"./select-DYjegiXi.js";import{s as n,l as p}from"./severityOptions-DEOvJqC9.js";import{C as B}from"./CollapsibleCard-STA1GVQO.js";import{W as j}from"./wand-sparkles-CPoBNFFg.js";import"./chevron-down-CG--ounh.js";import"./chevron-up-B6tzMAOm.js";import"./info-99kuqpbx.js";import"./circle-alert-BDF8Tq9y.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[b,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 p.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)}},T=async()=>{o(!0);try{await p.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(j,{className:"h-5 w-5"}),"Log Generator"]}),e.jsx(I,{children:"Generate logs for testing and demonstration purposes."})]}),children:e.jsxs(D,{value:b,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 y=s.icon;return e.jsxs(W,{value:s.value,className:"flex items-center gap-2",children:[e.jsx(y,{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:T,disabled:l,className:"mt-2 sm:mt-0",children:[e.jsx(j,{className:"h-4 w-4 mr-2"}),"Generate Mock Logs"]})]})})]})})}function se(){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{se as default};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{c as re,r as a,j as e,a as oe,u as ae,b as ie,R as le,d as W,A as ce,e as b,P as V,f as de,g as ue,h as U,D as xe,C as pe,i as me,k as fe,l as F,F as $,M as he,W as ge,m as ve,B as ye,n as je,U as be}from"./index-6xOVKwKn.js";import{B as Ce}from"./badge-CN7FeufU.js";import{C as _,a as R,b as z,c as B,d as G}from"./index-D96rVSkR.js";import{L as Ne}from"./label-CQLeZjM1.js";import{S as we}from"./switch-Di9NJH2A.js";import{u as Te}from"./utilService-CNZOmadC.js";import{g as Ee}from"./trace-DJq1miYa.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 Pe=[["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"}]],D=re("external-link",Pe);function _e(t,n=[]){let s=[];function o(l,c){const u=a.createContext(c),d=s.length;s=[...s,c];const p=x=>{var y;const{scope:f,children:m,...h}=x,g=((y=f==null?void 0:f[t])==null?void 0:y[d])||u,v=a.useMemo(()=>h,Object.values(h));return e.jsx(g.Provider,{value:v,children:m})};p.displayName=l+"Provider";function i(x,f){var g;const m=((g=f==null?void 0:f[t])==null?void 0:g[d])||u,h=a.useContext(m);if(h)return h;if(c!==void 0)return c;throw new Error(`\`${x}\` must be used within \`${l}\``)}return[p,i]}const r=()=>{const l=s.map(c=>a.createContext(c));return function(u){const d=(u==null?void 0:u[t])||l;return a.useMemo(()=>({[`__scope${t}`]:{...u,[t]:d}}),[u,d])}};return r.scopeName=t,[o,Re(r,...n)]}function Re(...t){const n=t[0];if(t.length===1)return n;const s=()=>{const o=t.map(r=>({useScope:r(),scopeName:r.scopeName}));return function(l){const c=o.reduce((u,{useScope:d,scopeName:p})=>{const x=d(l)[`__scope${p}`];return{...u,...x}},{});return a.useMemo(()=>({[`__scope${n.scopeName}`]:c}),[c])}};return s.scopeName=n.scopeName,s}function Se(t){const n=ke(t),s=a.forwardRef((o,r)=>{const{children:l,...c}=o,u=a.Children.toArray(l),d=u.find(Le);if(d){const p=d.props.children,i=u.map(x=>x===d?a.Children.count(p)>1?a.Children.only(null):a.isValidElement(p)?p.props.children:null:x);return e.jsx(n,{...c,ref:r,children:a.isValidElement(p)?a.cloneElement(p,void 0,i):null})}return e.jsx(n,{...c,ref:r,children:l})});return s.displayName=`${t}.Slot`,s}function ke(t){const n=a.forwardRef((s,o)=>{const{children:r,...l}=s;if(a.isValidElement(r)){const c=Ae(r),u=Me(l,r.props);return r.type!==a.Fragment&&(u.ref=o?oe(o,c):c),a.cloneElement(r,u)}return a.Children.count(r)>1?a.Children.only(null):null});return n.displayName=`${t}.SlotClone`,n}var q=Symbol("radix.slottable");function De(t){const n=({children:s})=>e.jsx(e.Fragment,{children:s});return n.displayName=`${t}.Slottable`,n.__radixId=q,n}function Le(t){return a.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===q}function Me(t,n){const s={...n};for(const o in n){const r=t[o],l=n[o];/^on[A-Z]/.test(o)?r&&l?s[o]=(...u)=>{const d=l(...u);return r(...u),d}:r&&(s[o]=r):o==="style"?s[o]={...r,...l}:o==="className"&&(s[o]=[r,l].filter(Boolean).join(" "))}return{...t,...s}}function Ae(t){var o,r;let n=(o=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:o.get,s=n&&"isReactWarning"in n&&n.isReactWarning;return s?t.ref:(n=(r=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:r.get,s=n&&"isReactWarning"in n&&n.isReactWarning,s?t.props.ref:t.props.ref||t.ref)}var Oe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],He=Oe.reduce((t,n)=>{const s=Se(`Primitive.${n}`),o=a.forwardRef((r,l)=>{const{asChild:c,...u}=r,d=c?s:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(d,{...u,ref:l})});return o.displayName=`Primitive.${n}`,{...t,[n]:o}},{}),[S]=_e("Tooltip",[U]),k=U(),Y="TooltipProvider",Ie=700,L="tooltip.open",[Fe,A]=S(Y),X=t=>{const{__scopeTooltip:n,delayDuration:s=Ie,skipDelayDuration:o=300,disableHoverableContent:r=!1,children:l}=t,c=a.useRef(!0),u=a.useRef(!1),d=a.useRef(0);return a.useEffect(()=>{const p=d.current;return()=>window.clearTimeout(p)},[]),e.jsx(Fe,{scope:n,isOpenDelayedRef:c,delayDuration:s,onOpen:a.useCallback(()=>{window.clearTimeout(d.current),c.current=!1},[]),onClose:a.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>c.current=!0,o)},[o]),isPointerInTransitRef:u,onPointerInTransitChange:a.useCallback(p=>{u.current=p},[]),disableHoverableContent:r,children:l})};X.displayName=Y;var E="Tooltip",[$e,P]=S(E),K=t=>{const{__scopeTooltip:n,children:s,open:o,defaultOpen:r,onOpenChange:l,disableHoverableContent:c,delayDuration:u}=t,d=A(E,t.__scopeTooltip),p=k(n),[i,x]=a.useState(null),f=ae(),m=a.useRef(0),h=c??d.disableHoverableContent,g=u??d.delayDuration,v=a.useRef(!1),[y,j]=ie({prop:o,defaultProp:r??!1,onChange:I=>{I?(d.onOpen(),document.dispatchEvent(new CustomEvent(L))):d.onClose(),l==null||l(I)},caller:E}),N=a.useMemo(()=>y?v.current?"delayed-open":"instant-open":"closed",[y]),w=a.useCallback(()=>{window.clearTimeout(m.current),m.current=0,v.current=!1,j(!0)},[j]),T=a.useCallback(()=>{window.clearTimeout(m.current),m.current=0,j(!1)},[j]),H=a.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>{v.current=!0,j(!0),m.current=0},g)},[g,j]);return a.useEffect(()=>()=>{m.current&&(window.clearTimeout(m.current),m.current=0)},[]),e.jsx(le,{...p,children:e.jsx($e,{scope:n,contentId:f,open:y,stateAttribute:N,trigger:i,onTriggerChange:x,onTriggerEnter:a.useCallback(()=>{d.isOpenDelayedRef.current?H():w()},[d.isOpenDelayedRef,H,w]),onTriggerLeave:a.useCallback(()=>{h?T():(window.clearTimeout(m.current),m.current=0)},[T,h]),onOpen:w,onClose:T,disableHoverableContent:h,children:s})})};K.displayName=E;var M="TooltipTrigger",Z=a.forwardRef((t,n)=>{const{__scopeTooltip:s,...o}=t,r=P(M,s),l=A(M,s),c=k(s),u=a.useRef(null),d=W(n,u,r.onTriggerChange),p=a.useRef(!1),i=a.useRef(!1),x=a.useCallback(()=>p.current=!1,[]);return a.useEffect(()=>()=>document.removeEventListener("pointerup",x),[x]),e.jsx(ce,{asChild:!0,...c,children:e.jsx(He.button,{"aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute,...o,ref:d,onPointerMove:b(t.onPointerMove,f=>{f.pointerType!=="touch"&&!i.current&&!l.isPointerInTransitRef.current&&(r.onTriggerEnter(),i.current=!0)}),onPointerLeave:b(t.onPointerLeave,()=>{r.onTriggerLeave(),i.current=!1}),onPointerDown:b(t.onPointerDown,()=>{r.open&&r.onClose(),p.current=!0,document.addEventListener("pointerup",x,{once:!0})}),onFocus:b(t.onFocus,()=>{p.current||r.onOpen()}),onBlur:b(t.onBlur,r.onClose),onClick:b(t.onClick,r.onClose)})})});Z.displayName=M;var O="TooltipPortal",[ze,Be]=S(O,{forceMount:void 0}),J=t=>{const{__scopeTooltip:n,forceMount:s,children:o,container:r}=t,l=P(O,n);return e.jsx(ze,{scope:n,forceMount:s,children:e.jsx(V,{present:s||l.open,children:e.jsx(de,{asChild:!0,container:r,children:o})})})};J.displayName=O;var C="TooltipContent",Q=a.forwardRef((t,n)=>{const s=Be(C,t.__scopeTooltip),{forceMount:o=s.forceMount,side:r="top",...l}=t,c=P(C,t.__scopeTooltip);return e.jsx(V,{present:o||c.open,children:c.disableHoverableContent?e.jsx(ee,{side:r,...l,ref:n}):e.jsx(Ge,{side:r,...l,ref:n})})}),Ge=a.forwardRef((t,n)=>{const s=P(C,t.__scopeTooltip),o=A(C,t.__scopeTooltip),r=a.useRef(null),l=W(n,r),[c,u]=a.useState(null),{trigger:d,onClose:p}=s,i=r.current,{onPointerInTransitChange:x}=o,f=a.useCallback(()=>{u(null),x(!1)},[x]),m=a.useCallback((h,g)=>{const v=h.currentTarget,y={x:h.clientX,y:h.clientY},j=qe(y,v.getBoundingClientRect()),N=Ye(y,j),w=Xe(g.getBoundingClientRect()),T=Ze([...N,...w]);u(T),x(!0)},[x]);return a.useEffect(()=>()=>f(),[f]),a.useEffect(()=>{if(d&&i){const h=v=>m(v,i),g=v=>m(v,d);return d.addEventListener("pointerleave",h),i.addEventListener("pointerleave",g),()=>{d.removeEventListener("pointerleave",h),i.removeEventListener("pointerleave",g)}}},[d,i,m,f]),a.useEffect(()=>{if(c){const h=g=>{const v=g.target,y={x:g.clientX,y:g.clientY},j=(d==null?void 0:d.contains(v))||(i==null?void 0:i.contains(v)),N=!Ke(y,c);j?f():N&&(f(),p())};return document.addEventListener("pointermove",h),()=>document.removeEventListener("pointermove",h)}},[d,i,c,p,f]),e.jsx(ee,{...t,ref:l})}),[We,Ve]=S(E,{isInside:!1}),Ue=De("TooltipContent"),ee=a.forwardRef((t,n)=>{const{__scopeTooltip:s,children:o,"aria-label":r,onEscapeKeyDown:l,onPointerDownOutside:c,...u}=t,d=P(C,s),p=k(s),{onClose:i}=d;return a.useEffect(()=>(document.addEventListener(L,i),()=>document.removeEventListener(L,i)),[i]),a.useEffect(()=>{if(d.trigger){const x=f=>{const m=f.target;m!=null&&m.contains(d.trigger)&&i()};return window.addEventListener("scroll",x,{capture:!0}),()=>window.removeEventListener("scroll",x,{capture:!0})}},[d.trigger,i]),e.jsx(xe,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:x=>x.preventDefault(),onDismiss:i,children:e.jsxs(pe,{"data-state":d.stateAttribute,...p,...u,ref:n,style:{...u.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:[e.jsx(Ue,{children:o}),e.jsx(We,{scope:s,isInside:!0,children:e.jsx(me,{id:d.contentId,role:"tooltip",children:r||o})})]})})});Q.displayName=C;var te="TooltipArrow",se=a.forwardRef((t,n)=>{const{__scopeTooltip:s,...o}=t,r=k(s);return Ve(te,s).isInside?null:e.jsx(ue,{...r,...o,ref:n})});se.displayName=te;function qe(t,n){const s=Math.abs(n.top-t.y),o=Math.abs(n.bottom-t.y),r=Math.abs(n.right-t.x),l=Math.abs(n.left-t.x);switch(Math.min(s,o,r,l)){case l:return"left";case r:return"right";case s:return"top";case o:return"bottom";default:throw new Error("unreachable")}}function Ye(t,n,s=5){const o=[];switch(n){case"top":o.push({x:t.x-s,y:t.y+s},{x:t.x+s,y:t.y+s});break;case"bottom":o.push({x:t.x-s,y:t.y-s},{x:t.x+s,y:t.y-s});break;case"left":o.push({x:t.x+s,y:t.y-s},{x:t.x+s,y:t.y+s});break;case"right":o.push({x:t.x-s,y:t.y-s},{x:t.x-s,y:t.y+s});break}return o}function Xe(t){const{top:n,right:s,bottom:o,left:r}=t;return[{x:r,y:n},{x:s,y:n},{x:s,y:o},{x:r,y:o}]}function Ke(t,n){const{x:s,y:o}=t;let r=!1;for(let l=0,c=n.length-1;l<n.length;c=l++){const u=n[l],d=n[c],p=u.x,i=u.y,x=d.x,f=d.y;i>o!=f>o&&s<(x-p)*(o-i)/(f-i)+p&&(r=!r)}return r}function Ze(t){const n=t.slice();return n.sort((s,o)=>s.x<o.x?-1:s.x>o.x?1:s.y<o.y?-1:s.y>o.y?1:0),Je(n)}function Je(t){if(t.length<=1)return t.slice();const n=[];for(let o=0;o<t.length;o++){const r=t[o];for(;n.length>=2;){const l=n[n.length-1],c=n[n.length-2];if((l.x-c.x)*(r.y-c.y)>=(l.y-c.y)*(r.x-c.x))n.pop();else break}n.push(r)}n.pop();const s=[];for(let o=t.length-1;o>=0;o--){const r=t[o];for(;s.length>=2;){const l=s[s.length-1],c=s[s.length-2];if((l.x-c.x)*(r.y-c.y)>=(l.y-c.y)*(r.x-c.x))s.pop();else break}s.push(r)}return s.pop(),n.length===1&&s.length===1&&n[0].x===s[0].x&&n[0].y===s[0].y?n:n.concat(s)}var Qe=X,et=K,tt=Z,st=J,nt=Q,rt=se;function ne({delayDuration:t=0,...n}){return e.jsx(Qe,{"data-slot":"tooltip-provider",delayDuration:t,...n})}function ot({...t}){return e.jsx(ne,{children:e.jsx(et,{"data-slot":"tooltip",...t})})}function at({...t}){return e.jsx(tt,{"data-slot":"tooltip-trigger",...t})}function it({className:t,sideOffset:n=0,children:s,...o}){return e.jsx(st,{children:e.jsxs(nt,{"data-slot":"tooltip-content",sideOffset:n,className:fe("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",t),...o,children:[s,e.jsx(rt,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function lt({content:t,timestamp:n,isUser:s}){return e.jsxs("div",{className:`flex items-end gap-2 ${s?"justify-end":"justify-start"}`,children:[!s&&e.jsx("div",{className:"flex-shrink-0 w-7 h-7 rounded-full border m-1 p-1 flex items-center justify-center",children:e.jsx(je,{className:"w-4 h-4"})}),e.jsxs("div",{className:`max-w-[70%] rounded-md px-2 py-1 break-words ${s?"bg-primary text-primary-foreground":"bg-muted text-foreground"} text-xs`,children:[t,e.jsx("span",{className:"text-[10px] opacity-60 mt-0.5 block",children:n.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"})})]}),s&&e.jsx("div",{className:"flex-shrink-0 w-7 h-7 rounded-full border m-1 p-1 flex items-center justify-center",children:e.jsx(be,{className:"w-4 h-4"})})]})}function ht(){F();const[t,n]=a.useState(null),[s,o]=a.useState(!1);a.useEffect(()=>{r()},[]),a.useEffect(()=>{if(!s)return;const i=setInterval(r,2e3);return()=>clearInterval(i)},[s]);const r=async()=>{try{const i=await Te.getHeapStats();n(i)}catch{}},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"}],c=[{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}],u=[{key:"logs",to:"/logs",hoverMessage:"Go to logs page",header:e.jsxs(e.Fragment,{children:[e.jsxs(_,{className:"flex items-center gap-2",children:[e.jsx($,{className:"h-5 w-5 text-purple-600"}),"Logs",e.jsx(D,{className:"h-4 w-4 text-gray-400"})]}),e.jsx(R,{children:"Latest system events and messages."})]}),content:e.jsx("div",{className:"space-y-3",children:l.map((i,x)=>e.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[e.jsx(Ce,{className:`${Ee(i.level)} border rounded-sm text-xs`,children:i.level}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-gray-900",children:i.message}),e.jsx("div",{className:"text-gray-500 text-[10px]",children:i.time})]})]},x))})},{key:"chat",to:"/chat",hoverMessage:"Go to chat page",header:e.jsxs(e.Fragment,{children:[e.jsxs(_,{className:"flex items-center gap-2",children:[e.jsx(he,{className:"h-5 w-5 text-blue-600"}),"AI Chat",e.jsx(D,{className:"h-4 w-4 text-gray-400"})]}),e.jsx(R,{children:"Ask the AI about logs and server requests."})]}),content:e.jsx("div",{className:"space-y-2",children:c.map((i,x)=>e.jsx(lt,{content:i.content,timestamp:i.timestamp,isUser:i.role==="user"},x))})},{key:"plugins",to:"/plugins",hoverMessage:"Go to plugins page",header:e.jsxs(e.Fragment,{children:[e.jsxs(_,{className:"flex items-center gap-2",children:[e.jsx(ve,{className:"h-5 w-5 text-green-600"}),"Plugin System",e.jsx(D,{className:"h-4 w-4 text-gray-400"})]}),e.jsx(R,{children:"Extend telemetry with custom plugins."})]}),content:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ge,{className:"h-4 w-4 text-yellow-700"}),e.jsx("span",{className:"font-semibold text-sm",children:"Error Detector Plugin"})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Monitors logs and traces for critical errors and sends notifications."}),e.jsxs("div",{className:"bg-gray-100 rounded p-2 mt-2 text-xs font-mono",children:[e.jsx("span",{className:"text-green-700",children:"Plugin active"}),": ",e.jsx("span",{className:"text-gray-700",children:'Detects "ERROR" logs and alerts team.'})]}),e.jsxs("div",{className:"bg-gray-100 rounded p-2 text-xs font-mono",children:[e.jsx("span",{className:"text-blue-700",children:"Plugin detected"}),": ",e.jsx("span",{className:"text-gray-700",children:"5 logs of error caused by the same endpoint."})]}),e.jsxs("div",{className:"bg-gray-100 rounded p-2 text-xs font-mono",children:[e.jsx("span",{className:"text-purple-700",children:"Plugin info"}),": ",e.jsx("span",{className:"text-gray-700",children:"No critical errors detected in the last 24h."})]})]})}];function d({children:i,header:x,hoverMessage:f,to:m}){const[h,g]=a.useState(!1),v=F();return e.jsxs(z,{className:"relative group cursor-pointer",tabIndex:0,role:"button",onClick:()=>v(m),onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),children:[e.jsx(B,{children:x}),e.jsxs(G,{className:"relative min-h-[260px] rounded-lg overflow-hidden flex flex-col justify-center px-10",children:[i,e.jsx("div",{className:`absolute inset-0 flex items-center justify-center z-10 transition-opacity duration-200 rounded-lg mx-6 ${h?"bg-gray-900 opacity-100":"bg-gray-900 opacity-5"}`,children:e.jsx("span",{className:"text-white font-semibold text-lg transition-opacity duration-200",children:h?f:""})})]})]})}function p(){return e.jsx("div",{className:"flex flex-col gap-8 xl:grid xl:grid-cols-3 xl:gap-8 ",children:u.map(i=>e.jsx(d,{header:i.header,hoverMessage:i.hoverMessage,to:i.to,children:i.content},i.key))})}return e.jsx("div",{className:"min-h-screen bg-gray-50",children:e.jsx(ne,{children:e.jsx("section",{className:"py-16",children:e.jsxs("div",{className:"container mx-auto px-6",children:[e.jsxs(z,{children:[e.jsxs(B,{children:[e.jsxs(_,{className:"flex items-center gap-2",children:[e.jsx($,{className:"h-5 w-5"}),"Heap Statistics"]}),e.jsx(R,{children:"Memory usage and performance metrics"})]}),e.jsxs(G,{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(we,{id:"auto-update-heap",checked:s,onCheckedChange:o}),e.jsxs(Ne,{htmlFor:"auto-update-heap",children:["Auto Update: ",s?"Enabled":"Manual"]})]}),e.jsxs(ot,{children:[e.jsx(at,{asChild:!0,children:e.jsx(ye,{onClick:r,variant:"outline",size:"sm",disabled:s,className:s?"opacity-50 cursor-not-allowed":"",children:"Update"})}),e.jsx(it,{children:s?"Disabled while auto update is enabled":"Click to manually update heap stats"})]})]}),t&&e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"bg-blue-50 p-4 rounded-lg",children:[e.jsx("div",{className:"text-sm font-medium text-blue-600",children:"Used Heap"}),e.jsxs("div",{className:"text-2xl font-bold text-blue-900",children:[t.used_heap_size.toFixed(2)," ",t.units]})]}),e.jsxs("div",{className:"bg-green-50 p-4 rounded-lg",children:[e.jsx("div",{className:"text-sm font-medium text-green-600",children:"Total Heap"}),e.jsxs("div",{className:"text-2xl font-bold text-green-900",children:[t.total_heap_size.toFixed(2)," ",t.units]})]}),e.jsxs("div",{className:"bg-yellow-50 p-4 rounded-lg",children:[e.jsx("div",{className:"text-sm font-medium text-yellow-600",children:"Available"}),e.jsxs("div",{className:"text-2xl font-bold text-yellow-900",children:[t.total_available_size.toFixed(2)," ",t.units]})]}),e.jsxs("div",{className:"bg-purple-50 p-4 rounded-lg",children:[e.jsx("div",{className:"text-sm font-medium text-purple-600",children:"External Memory"}),e.jsxs("div",{className:"text-2xl font-bold text-purple-900",children:[t.external_memory.toFixed(2)," ",t.units]})]}),e.jsxs("div",{className:"bg-red-50 p-4 rounded-lg",children:[e.jsx("div",{className:"text-sm font-medium text-red-600",children:"Heap Limit"}),e.jsxs("div",{className:"text-2xl font-bold text-red-900",children:[t.heap_size_limit.toFixed(2)," ",t.units]})]}),e.jsxs("div",{className:"bg-indigo-50 p-4 rounded-lg",children:[e.jsx("div",{className:"text-sm font-medium text-indigo-600",children:"Peak Malloc"}),e.jsxs("div",{className:"text-2xl font-bold text-indigo-900",children:[t.peak_malloced_memory.toFixed(2)," ",t.units]})]}),e.jsxs("div",{className:"bg-pink-50 p-4 rounded-lg",children:[e.jsx("div",{className:"text-sm font-medium text-pink-600",children:"Native Contexts"}),e.jsx("div",{className:"text-2xl font-bold text-pink-900",children:t.number_of_native_contexts})]}),e.jsxs("div",{className:"bg-cyan-50 p-4 rounded-lg",children:[e.jsx("div",{className:"text-sm font-medium text-cyan-600",children:"Global Handles"}),e.jsxs("div",{className:"text-2xl font-bold text-cyan-900",children:[t.used_global_handles_size.toFixed(3)," ",t.units]})]})]})]})]}),e.jsx("div",{className:"mt-10"}),e.jsx(p,{})]})})})})}export{ht as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as a,J as $,j as e,T as z,B as O,p as H,t as C,q as G,K,s as X}from"./index-6xOVKwKn.js";import{s as _,l as u}from"./severityOptions-DEOvJqC9.js";import{C as W,a as Y}from"./index-D96rVSkR.js";import{I as M}from"./input-B-01QDg_.js";import{L as I}from"./label-CQLeZjM1.js";import{M as B,S as E,C as Z,V as ee}from"./VirtualizedListPanel-zcj0v7DL.js";import{T as se,a as te,b as V,c as J}from"./select-DYjegiXi.js";import{C as ae}from"./CollapsibleCard-STA1GVQO.js";import{B as re}from"./badge-CN7FeufU.js";import{C as oe}from"./popover-DS_8DYYt.js";import"./info-99kuqpbx.js";import"./circle-alert-BDF8Tq9y.js";import"./separator-DGsRxIrl.js";import"./dialog-BrpWNk36.js";import"./chevron-down-CG--ounh.js";import"./wand-sparkles-CPoBNFFg.js";import"./chevron-up-B6tzMAOm.js";import"./upload-BiLTpCnX.js";const ne="normal",le="advanced",ie=({uniqueServices:s,loading:r,onFiltersChange:o,initialTraceId:i="",...S})=>{const[y,d]=a.useState("normal"),[p,h]=a.useState(""),[f,b]=a.useState([]),[g,F]=a.useState([]),[v,k]=a.useState(""),[R,T]=a.useState(i),[A,q]=a.useState(!1),x=()=>{let t={},L="";if(y===le)try{t=v?JSON.parse(v):{},L=p}catch{C.error("Invalid JSON in advanced query");return}else f.length>0&&(t={...t,severityText:{$in:f}}),g.length>0&&(t={...t,"resource.attributes.service.name":{$in:g}}),R.trim().length>0&&(t={...t,traceId:R.trim()}),L=p;o(t,L)},D=()=>{h(""),b([]),F([]),k(""),T(""),d(ne),o({},"")};return $.useEffect(()=>{i&&(T(i),x())},[i]),e.jsx(ae,{isOpen:A,onToggle:()=>q(t=>!t),header:e.jsxs(e.Fragment,{children:[e.jsxs(W,{className:"flex items-center gap-2",children:[e.jsx(E,{className:"h-5 w-5"}),"Search & Filters"]}),e.jsx(Y,{children:"Filter logs by text, severity, service, or advanced query."})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(I,{htmlFor:"search",className:"text-sm",children:"Text Search"}),e.jsx(M,{id:"search",placeholder:"Search logs...",value:p,onChange:t=>h(t.target.value),className:"mt-1",disabled:r})]}),e.jsxs(se,{value:y,onValueChange:t=>d(t),children:[e.jsxs(te,{className:"grid w-full grid-cols-2",children:[e.jsx(V,{value:"normal",children:"Normal Filters"}),e.jsx(V,{value:"advanced",children:"Advanced Query"})]}),e.jsx(J,{value:"normal",className:"space-y-4",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-[160px]",children:[e.jsx(I,{htmlFor:"service",className:"text-sm",children:"Service"}),e.jsx(B,{id:"service",options:s.map(t=>({label:t,value:t})),value:g,onValueChange:F,disabled:r})]}),e.jsxs("div",{className:"flex-1 min-w-[160px]",children:[e.jsx(I,{htmlFor:"severity",className:"text-sm",children:"Severity"}),e.jsx(B,{id:"severity",options:_,value:f,onValueChange:b,disabled:r})]}),e.jsxs("div",{className:"flex-1 min-w-[160px]",children:[e.jsx(I,{htmlFor:"traceId",className:"text-sm",children:"Trace ID"}),e.jsx(M,{id:"traceId",placeholder:"Filter by Trace ID...",value:R,onChange:t=>T(t.target.value),className:"mt-1",disabled:r})]})]})}),e.jsx(J,{value:"advanced",className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(I,{htmlFor:"advanced-query",className:"text-sm",children:"Advanced Query (JSON)"}),e.jsx(z,{id:"advanced-query",placeholder:"{ }",value:v,onChange:t=>k(t.target.value),className:"mt-1 font-mono",rows:4,disabled:r})]})})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsxs(O,{onClick:x,disabled:r,className:"w-full sm:w-auto",variant:"default",children:[e.jsx(E,{className:`h-4 w-4 mr-2 ${r?"animate-spin":""}`}),"Apply"]}),e.jsxs(O,{onClick:D,disabled:r,className:"w-full sm:w-auto",variant:"outline",children:[e.jsx(H,{className:"h-4 w-4 mr-2"}),"Clear"]})]})]})})},ce=({traceId:s})=>{if(!s)return null;const o=`${G()}/traces?traceId=${encodeURIComponent(s)}`;return e.jsx(O,{variant:"ghost",size:"sm",className:"flex-shrink-0 h-7 w-7 p-0","aria-label":"Show trace for this log",title:"Show trace for this log in a new tab",onClick:i=>{i.stopPropagation(),window.open(o,"_blank")},children:e.jsx(K,{className:"h-4 w-4"})})};function de(s){return _.find(r=>r.value===s)||_[0]}function me(s){const r=Math.floor(typeof s=="number"?s/1e3:Number(s)/1e3);return new Date(r).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function ue(s){navigator.clipboard.writeText(s).then(()=>C.success("Copied to clipboard")).catch(()=>C.error("Failed to copy"))}const pe=({log:s})=>{var d,p,h;const[r,o]=a.useState(!1),i=de(s.severityText||s.severity),S=i.icon,y=((h=(p=(d=s.resource)==null?void 0:d.attributes)==null?void 0:p.service)==null?void 0:h.name)||"unknown-service";return e.jsxs("div",{className:"group hover:bg-muted/50 rounded-lg px-2 py-2 transition-colors border-b border-muted font-mono text-[13px]",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap text-xs text-muted-foreground font-mono",children:[e.jsx("span",{children:me(s.timestamp)}),e.jsx("span",{className:"text-blue-700 dark:text-blue-400",children:y}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(S,{className:i.color+" h-4 w-4"}),s.severityText||s.severity]}),e.jsxs("span",{className:"flex items-center gap-2 ml-auto",children:[s.traceId&&e.jsxs(e.Fragment,{children:[e.jsx(re,{variant:"outline",className:"px-2 py-0.5 text-[10px] cursor-pointer font-mono",onClick:()=>ue(s.traceId||""),title:"Copy Trace ID",children:s.traceId.slice(0,8)}),e.jsx(ce,{traceId:s.traceId})]}),e.jsx(O,{variant:"ghost",size:"sm",className:"flex-shrink-0 h-7 w-7 p-0","aria-label":"Show more Context",onClick:()=>o(f=>!f),children:e.jsx(Z,{className:"h-4 w-4"})})]})]}),r&&e.jsx("div",{className:"mt-2 mb-2 bg-muted/30 rounded p-2 font-mono text-xs overflow-x-auto border",children:e.jsx("pre",{className:"whitespace-pre-wrap break-words",children:JSON.stringify(s,null,2)})}),e.jsx("div",{className:"text-sm text-foreground break-words font-mono mt-1",children:s.body})]})};function he({logs:s,loadOlderLogs:r,loadNewerLogs:o}){return e.jsx(ee,{items:s,itemContent:(i,S)=>e.jsx(pe,{log:S}),title:"Logs History",description:"View and scroll through log entries",emptyMessage:"No logs to display. Please update your filter or try again later.",loadOlderItems:r,loadNewerItems:o,panelName:"LogsListPanel"})}const xe=({onLogsReset:s})=>{const r=a.useMemo(()=>({getStatus:()=>u.getStatus(),startCollection:()=>u.startCollection(),stopCollection:()=>u.stopCollection(),resetCollection:()=>u.resetLogs(),setRetentionTime:o=>u.setRetentionTime(o),getRetentionTime:()=>u.getRetentionTime()}),[]);return e.jsx(oe,{service:r,resourceType:"logs",onDownload:()=>(u.download(),Promise.resolve()),onImport:(o,i)=>u.import(o,i),onReset:s})},P=30,N=s=>typeof s.timestamp=="number"?s.timestamp:Number(s.timestamp);function De(){const s=X(),o=new URLSearchParams(s.search).get("traceId")||"",[i,S]=a.useState(!0),[y,d]=a.useState([]),[p,h]=a.useState(null),[f,b]=a.useState(null),[g,F]=a.useState({}),[v,k]=a.useState(""),[R,T]=a.useState(!1),[A,q]=a.useState(o),x=a.useCallback(async(j={},m="",n=!1)=>{S(!0),F(j),k(m),T(n);try{const c=(await u.findLogs({query:j,textSearch:m,limit:P})).logs;d(c),c.length>0?(h(N(c[0])),b(N(c[c.length-1]))):n&&c.length===0&&C.info("No logs found")}catch{C.error("Failed to load logs")}finally{S(!1)}},[]),D=a.useCallback(async()=>{if(p)try{const m=(await u.findOlderLogs({query:g,textSearch:v,limit:P},p)).logs.sort((l,c)=>N(l)-N(c));let n=[];d(l=>{if(l.length===0)return l;const c=new Set(l.map(w=>w._id));return n=m.filter(w=>!c.has(w._id)),[...n,...l]}),n.length>0&&h(N(n[0]))}catch{C.error("Failed to load older logs")}},[p,g,v]),t=a.useCallback(async()=>{if(!f)return x(g,v,!1);try{const m=(await u.findNewerLogs({query:g,textSearch:v,limit:P},f)).logs.sort((l,c)=>N(l)-N(c));let n=[];d(l=>{const c=new Set(l.map(w=>w._id));return n=m.filter(w=>!c.has(w._id)),[...l,...n]}),n.length>0&&b(N(n[n.length-1]))}catch{C.error("Failed to load newer logs")}},[f,g,v,x]);a.useEffect(()=>{x(o?{traceId:o}:{},"",!1)},[x,o]);const L=a.useMemo(()=>Array.from(new Set(y.map(j=>{var m,n,l;return(l=(n=(m=j.resource)==null?void 0:m.attributes)==null?void 0:n.service)==null?void 0:l.name}))).filter(Boolean),[y]),Q=()=>{d([]),h(null),b(null),T(!1),x({},"",!1)},U=(j,m)=>{d([]),h(null),b(null),x(j,m,!0)};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(xe,{onLogsReset:Q}),e.jsx(ie,{uniqueServices:L,loading:i,onFiltersChange:U,initialTraceId:A}),e.jsx(he,{logs:y,loadOlderLogs:D,loadNewerLogs:t})]})})}export{De as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{l as a,j as e,B as s}from"./index-6xOVKwKn.js";function n(){const t=a();return e.jsxs("div",{className:"min-h-screen bg-gray-50",children:[e.jsx("section",{className:"bg-gradient-to-r from-blue-600 to-purple-700 text-white py-20",children:e.jsxs("div",{className:"container mx-auto px-6 text-center",children:[e.jsx("h1",{className:"text-5xl font-bold mb-6",children:"Page Not Found"}),e.jsx("p",{className:"text-xl mb-8 max-w-3xl mx-auto",children:"The page you are looking for does not exist. You can return to the home page using the button below."}),e.jsx(s,{variant:"default",size:"lg",onClick:()=>t("/"),className:"bg-white text-blue-600 hover:bg-gray-200",children:"Go to Home"})]})}),e.jsx("div",{className:"my-56"})]})}export{n as default};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import{c as _,l as q,s as z,r as l,j as e,B as d,t as j}from"./index-6xOVKwKn.js";import{a as M,b as A,C as G,G as W,A as v,g as R}from"./alert-BkNVKxJN.js";import{I as b}from"./input-B-01QDg_.js";import{L as a}from"./label-CQLeZjM1.js";import{S as U,d as H,e as V,f as B,g as S,T as Q,a as Y,b as E,c as k}from"./select-DYjegiXi.js";import{b as K,c as X,C as Z,a as $,d as ee}from"./index-D96rVSkR.js";import{S as L}from"./switch-Di9NJH2A.js";import{W as se}from"./wand-sparkles-CPoBNFFg.js";import{C as ne}from"./circle-alert-BDF8Tq9y.js";import{I as ie}from"./info-99kuqpbx.js";import{L as ae}from"./loader-circle-BoDGk-BO.js";import"./chevron-down-CG--ounh.js";import"./chevron-up-B6tzMAOm.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 re=[["path",{d:"M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21",key:"g5wo59"}],["path",{d:"m5.082 11.09 8.828 8.828",key:"1wx5vj"}]],le=_("eraser",re),te={globalOptions:["--no-save"],verbose:!1,ignoreErrors:!1,dependencies:[{name:"lodash@latest"}]},oe=`
|
|
7
|
+
import _ from "lodash";
|
|
8
|
+
|
|
9
|
+
let text = "hello world";
|
|
10
|
+
let capital = _.capitalize(text);
|
|
11
|
+
//
|
|
12
|
+
let loaded = false;
|
|
13
|
+
|
|
14
|
+
const plugin = {
|
|
15
|
+
async load(config) {
|
|
16
|
+
//
|
|
17
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
18
|
+
loaded = true;
|
|
19
|
+
//
|
|
20
|
+
},
|
|
21
|
+
unload() {
|
|
22
|
+
//
|
|
23
|
+
},
|
|
24
|
+
isConfigured() {
|
|
25
|
+
return loaded;
|
|
26
|
+
},
|
|
27
|
+
newLog(log) {
|
|
28
|
+
// Do not worry this logs will not be captured by the telemetry system
|
|
29
|
+
//
|
|
30
|
+
},
|
|
31
|
+
newTrace(trace) {
|
|
32
|
+
//
|
|
33
|
+
},
|
|
34
|
+
newMetric(metric) {
|
|
35
|
+
//
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default {plugin};
|
|
40
|
+
`.trim(),ce={setting1:"value1",setting2:"value2",setting3:"value3"},de="Sample Plugin",me="This plugin demonstrates all available features: it reads configuration, imports a dependency (lodash) to capitalize the first letter of a message, and logs when it receives traces, metrics, or logs. You can extend it to perform any custom logic, such as sending a message to Slack or Telegram when a log matches a specific regex.";function Ee(){const y=q(),N=z(),[x,w]=l.useState(!1),[C,g]=l.useState(null),[o,F]=l.useState("code"),[m,u]=l.useState(!1),[p,h]=l.useState(!1),[O,P]=l.useState(!1),[n,i]=l.useState({id:"",name:"",description:"",moduleFormat:"esm",url:"",code:"",dependencies:"",config:""});l.useEffect(()=>{var c;const s=(c=N.state)==null?void 0:c.plugin;s&&(i({id:s.id||"",name:s.name||"",description:s.description||"",moduleFormat:s.moduleFormat||"esm",url:s.url||"",code:s.sourceCode||s.code||"",dependencies:s.install?JSON.stringify(s.install,null,2):"",config:s.config?JSON.stringify(s.config,null,2):""}),u(!!s.install),h(!!s.config))},[N.state]);const D=()=>{i({id:"sample-plugin",name:de,description:me,moduleFormat:"esm",url:"",code:oe,dependencies:JSON.stringify(te,null,2),config:JSON.stringify(ce,null,2)}),u(!0),h(!0)},T=()=>{i({id:"",name:"",description:"",moduleFormat:"esm",url:"",code:"",dependencies:"",config:""}),u(!1),h(!1)},I=async s=>{var c;s.preventDefault(),w(!0),g(null);try{if(!n.id.trim())throw new Error("Plugin ID is required");if(!n.name.trim())throw new Error("Plugin name is required");if(o==="url"&&!n.url.trim())throw new Error("URL is required");if(o==="code"&&!n.code.trim())throw new Error("Code is required");let r;if(p)if(n.config.trim())try{r=JSON.parse(n.config)}catch{throw new Error("Invalid JSON in config field")}else r={};else r={};let t={};if(m)if(n.dependencies.trim())try{t=JSON.parse(n.dependencies)}catch{throw new Error("Invalid JSON in dependencies field")}else t={};else t={};const J={id:n.id.trim(),name:n.name.trim(),...((c=n.description)==null?void 0:c.trim())&&{description:n.description.trim()},moduleFormat:n.moduleFormat,...o==="url"?{url:n.url.trim()}:{code:n.code.trim()},install:t,...r&&{config:r}},f=await R().createPlugin(J);if(f.status!=="success"){g(f.message),j.error(e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold",children:"Error creating plugin"}),e.jsx("div",{className:"text-xs whitespace-pre-line mt-1",children:f.message})]}),{duration:1e4});return}j.success("Plugin created successfully!"),y("/plugins")}catch(r){const t=r instanceof Error?r.message:"Failed to create plugin";g(t),j.error(e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold",children:"Error creating plugin"}),e.jsx("div",{className:"text-xs whitespace-pre-line mt-1",children:t})]}),{duration:1e4})}finally{w(!1)}};return e.jsx("div",{className:"min-h-screen bg-gray-50",children:e.jsx("main",{className:"container mx-auto px-6 py-8 space-y-6",children:e.jsxs(K,{children:[e.jsx(X,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Z,{className:"flex items-center gap-2",children:"Create New Plugin"}),e.jsx($,{children:"Add a new plugin to your telemetry system."})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(d,{type:"button",variant:"outline",onClick:D,className:"gap-2",title:"Load Example",children:[e.jsx(se,{className:"h-4 w-4"}),"Load Example"]}),e.jsxs(d,{type:"button",variant:"outline",onClick:T,className:"gap-2",title:"Clear",children:[e.jsx(le,{className:"h-4 w-4"}),"Clear"]})]})]})}),e.jsx(ee,{children:e.jsxs("form",{onSubmit:I,className:"space-y-6",children:[C&&e.jsxs(M,{variant:"destructive",children:[e.jsx(ne,{className:"h-4 w-4"}),e.jsx(A,{children:C})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(a,{htmlFor:"plugin-id",children:"Plugin ID *"}),e.jsx(b,{id:"plugin-id",placeholder:"my-plugin-unique-id",value:n.id,onChange:s=>i({...n,id:s.target.value}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(a,{htmlFor:"plugin-name",children:"Name *"}),e.jsx(b,{id:"plugin-name",placeholder:"My Plugin",value:n.name,onChange:s=>i({...n,name:s.target.value}),required:!0})]}),e.jsxs("div",{className:"col-span-2 space-y-2",children:[e.jsx(a,{htmlFor:"plugin-description",children:"Description"}),e.jsx("textarea",{id:"plugin-description",placeholder:"Describe what this plugin does (optional)",value:n.description,onChange:s=>i({...n,description:s.target.value}),className:"w-full min-h-20 border rounded px-3 py-2 text-sm font-mono resize-y"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(a,{htmlFor:"module-format",children:"Module Format *"}),e.jsxs(U,{value:n.moduleFormat,onValueChange:s=>i({...n,moduleFormat:s}),children:[e.jsx(H,{children:e.jsx(V,{})}),e.jsxs(B,{children:[e.jsx(S,{value:"esm",children:"ESM (ES Modules)"}),e.jsx(S,{value:"cjs",children:"CJS (CommonJS)"})]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(a,{children:"Plugin Source *"}),e.jsxs(Q,{value:o,onValueChange:s=>F(s),children:[e.jsxs(Y,{className:"grid w-full grid-cols-2",children:[e.jsxs(E,{value:"code",className:"gap-2",children:[e.jsx(G,{className:"h-4 w-4"}),"Code"]}),e.jsxs(E,{value:"url",className:"gap-2",children:[e.jsx(W,{className:"h-4 w-4"}),"URL"]})]}),e.jsxs(k,{value:"code",className:"space-y-4",children:[e.jsx(a,{htmlFor:"plugin-code",children:"Source Code"}),e.jsx(v,{mode:"javascript",theme:"monokai",value:n.code,name:"plugin_code_editor",width:"100%",fontSize:14,showPrintMargin:!1,showGutter:!0,setOptions:{useWorker:!1},minLines:8,maxLines:24,onChange:s=>i({...n,code:s}),className:"font-mono text-sm resize-y border rounded-lg"})]}),e.jsxs(k,{value:"url",className:"space-y-2",children:[e.jsx(a,{htmlFor:"plugin-url",children:"Source URL"}),e.jsx(b,{id:"plugin-url",type:"url",placeholder:"https://example.com/my-plugin.js",value:n.url,onChange:s=>i({...n,url:s.target.value}),required:o==="url"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a,{htmlFor:"dependencies",children:"Dependencies"}),e.jsx(L,{id:"dependencies-switch",checked:m,onCheckedChange:u}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Enable"})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Optional dependencies to install (dynamic installer syntax)",e.jsx(d,{type:"button",size:"sm",variant:"ghost",onClick:()=>P(s=>!s),title:"Dynamic installer syntax info",children:e.jsx(ie,{className:"h-2 w-2"})})]}),O&&e.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded p-3 text-xs text-blue-900 mb-2",children:[e.jsx("div",{className:"font-semibold mb-1",children:"Dynamic Installer: quick guide"}),e.jsxs("div",{className:"mb-2",children:["This syntax configures programmatic npm installs. Use ",e.jsx("b",{children:"globalOptions"})," to pass flags applied to every install (for example ",e.jsx("code",{children:"--no-save"}),"). Each dependency can include its own ",e.jsx("b",{children:"options"}),", and set ",e.jsx("b",{children:"override"})," to true to ignore globalOptions for that dependency. Enable ",e.jsx("b",{children:"verbose"})," to get detailed logs and set ",e.jsx("b",{children:"ignoreErrors"})," to true to continue installing even if one package fails."]}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium mb-1",children:"Detailed example"}),e.jsx("pre",{className:"bg-blue-100 border rounded p-2 overflow-x-auto text-xs",children:`{
|
|
41
|
+
"globalOptions": ["--no-save"],
|
|
42
|
+
"verbose": true,
|
|
43
|
+
"ignoreErrors": false,
|
|
44
|
+
"dependencies": [
|
|
45
|
+
{ "name": "eslint@8.0.0", "options": ["--save-dev"] },
|
|
46
|
+
{ "name": "lodash@latest", "options": ["-E"] },
|
|
47
|
+
{ "name": "axios@latest", "options": ["--save-exact"], "override": true },
|
|
48
|
+
{ "name": "typescript", "options": ["--save-optional"] }
|
|
49
|
+
]
|
|
50
|
+
}`}),e.jsxs("div",{className:"mt-2",children:["Quick notes:",e.jsxs("ul",{className:"list-disc ml-5",children:[e.jsxs("li",{children:[e.jsx("b",{children:"globalOptions"})," (here ",e.jsx("code",{children:"--no-save"}),") are applied to all installs unless a dependency sets ",e.jsx("b",{children:"override"}),"."]}),e.jsxs("li",{children:["In the example, ",e.jsx("code",{children:"axios"})," sets ",e.jsx("b",{children:"override"})," true → it will install only with its own options."]}),e.jsxs("li",{children:[e.jsx("b",{children:"verbose"})," produces console logs for each command; ",e.jsx("b",{children:"ignoreErrors"})," controls whether the installer stops on first failure."]})]})]}),e.jsx("a",{href:"https://github.com/motero2k/dynamic-installer",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-blue-600 underline ml-2",children:"GitHub: dynamic-installer"})]})]}),m&&e.jsx(v,{mode:"json",theme:"monokai",value:n.dependencies,name:"plugin_dependencies_editor",width:"100%",fontSize:14,wrapEnabled:!0,showPrintMargin:!1,showGutter:!0,setOptions:{useWorker:!1},minLines:8,maxLines:16,onChange:s=>i({...n,dependencies:s}),className:"font-mono text-sm resize-y border rounded-lg",readOnly:!m})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a,{htmlFor:"plugin-config",children:"Plugin Configuration"}),e.jsx(L,{id:"config-switch",checked:p,onCheckedChange:h}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Enable"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"JSON configuration object"}),p&&e.jsx(v,{mode:"json",theme:"monokai",value:n.config,name:"plugin_config_editor",width:"100%",fontSize:14,wrapEnabled:!0,showPrintMargin:!1,showGutter:!0,setOptions:{useWorker:!1},minLines:8,maxLines:16,onChange:s=>i({...n,config:s}),className:"font-mono text-sm resize-y border rounded-lg",readOnly:!p})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(d,{type:"button",variant:"outline",onClick:()=>y("/plugins"),disabled:x,children:"Cancel"}),e.jsxs(d,{type:"submit",disabled:x,children:[x&&e.jsx(ae,{className:"h-4 w-4 mr-2 animate-spin"}),"Create Plugin"]})]})]})})]})})})}export{Ee as default};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import{c as z,r as i,j as e,a as K,b as Z,u as Q,e as X,P as Y,d as ee,v as se,l as W,B as b,w as te,F as ne,S as re,t as S,m as ae}from"./index-6xOVKwKn.js";import{b as C,d as P,c as k,C as L,a as A}from"./index-D96rVSkR.js";import{B as D}from"./badge-CN7FeufU.js";import{G as ie,C as le,g as O,A as I,a as M,b as B}from"./alert-BkNVKxJN.js";import{L as R}from"./loader-circle-BoDGk-BO.js";import{C as oe}from"./chevron-down-CG--ounh.js";import{P as ce,a as de,D as ue,b as me,c as xe,d as fe,e as he,f as pe}from"./dialog-BrpWNk36.js";import{D as J,U as je}from"./upload-BiLTpCnX.js";import{S as ge}from"./square-pen-DPhgYz6O.js";import{I as ve}from"./input-B-01QDg_.js";import{L as we}from"./label-CQLeZjM1.js";import{C as Ne}from"./circle-alert-BDF8Tq9y.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 ye=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],be=z("chevron-right",ye);/**
|
|
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 Ce=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Se=z("circle-check-big",Ce);function Pe(s){return s.code?"code":"url"}function Ee(s){const t=s.map(n=>({id:n.id,name:n.name,...n.url&&{url:n.url},...n.code&&{code:n.code},moduleFormat:n.moduleFormat,active:n.active,...n.install&&{install:n.install},...n.config&&{config:n.config}}));return JSON.stringify(t,null,2)}function ke(s){return Array.isArray(s)?s.every(t=>typeof t.id=="string"&&typeof t.moduleFormat=="string"&&["cjs","esm"].includes(t.moduleFormat)&&(t.url||t.code)):!1}function Oe(s,t=[]){let n=[];function l(d,o){const c=i.createContext(o),m=n.length;n=[...n,o];const x=w=>{var h;const{scope:a,children:g,...f}=w,j=((h=a==null?void 0:a[s])==null?void 0:h[m])||c,u=i.useMemo(()=>f,Object.values(f));return e.jsx(j.Provider,{value:u,children:g})};x.displayName=d+"Provider";function v(w,a){var j;const g=((j=a==null?void 0:a[s])==null?void 0:j[m])||c,f=i.useContext(g);if(f)return f;if(o!==void 0)return o;throw new Error(`\`${w}\` must be used within \`${d}\``)}return[x,v]}const r=()=>{const d=n.map(o=>i.createContext(o));return function(c){const m=(c==null?void 0:c[s])||d;return i.useMemo(()=>({[`__scope${s}`]:{...c,[s]:m}}),[c,m])}};return r.scopeName=s,[l,Le(r,...t)]}function Le(...s){const t=s[0];if(s.length===1)return t;const n=()=>{const l=s.map(r=>({useScope:r(),scopeName:r.scopeName}));return function(d){const o=l.reduce((c,{useScope:m,scopeName:x})=>{const w=m(d)[`__scope${x}`];return{...c,...w}},{});return i.useMemo(()=>({[`__scope${t.scopeName}`]:o}),[o])}};return n.scopeName=t.scopeName,n}function De(s){const t=Re(s),n=i.forwardRef((l,r)=>{const{children:d,...o}=l,c=i.Children.toArray(d),m=c.find(Ie);if(m){const x=m.props.children,v=c.map(w=>w===m?i.Children.count(x)>1?i.Children.only(null):i.isValidElement(x)?x.props.children:null:w);return e.jsx(t,{...o,ref:r,children:i.isValidElement(x)?i.cloneElement(x,void 0,v):null})}return e.jsx(t,{...o,ref:r,children:d})});return n.displayName=`${s}.Slot`,n}function Re(s){const t=i.forwardRef((n,l)=>{const{children:r,...d}=n;if(i.isValidElement(r)){const o=$e(r),c=Ae(d,r.props);return r.type!==i.Fragment&&(c.ref=l?K(l,o):o),i.cloneElement(r,c)}return i.Children.count(r)>1?i.Children.only(null):null});return t.displayName=`${s}.SlotClone`,t}var _e=Symbol("radix.slottable");function Ie(s){return i.isValidElement(s)&&typeof s.type=="function"&&"__radixId"in s.type&&s.type.__radixId===_e}function Ae(s,t){const n={...t};for(const l in t){const r=s[l],d=t[l];/^on[A-Z]/.test(l)?r&&d?n[l]=(...c)=>{const m=d(...c);return r(...c),m}:r&&(n[l]=r):l==="style"?n[l]={...r,...d}:l==="className"&&(n[l]=[r,d].filter(Boolean).join(" "))}return{...s,...n}}function $e(s){var l,r;let t=(l=Object.getOwnPropertyDescriptor(s.props,"ref"))==null?void 0:l.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?s.ref:(t=(r=Object.getOwnPropertyDescriptor(s,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?s.props.ref:s.props.ref||s.ref)}var Fe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],$=Fe.reduce((s,t)=>{const n=De(`Primitive.${t}`),l=i.forwardRef((r,d)=>{const{asChild:o,...c}=r,m=o?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(m,{...c,ref:d})});return l.displayName=`Primitive.${t}`,{...s,[t]:l}},{}),_="Collapsible",[Te]=Oe(_),[Ue,F]=Te(_),G=i.forwardRef((s,t)=>{const{__scopeCollapsible:n,open:l,defaultOpen:r,disabled:d,onOpenChange:o,...c}=s,[m,x]=Z({prop:l,defaultProp:r??!1,onChange:o,caller:_});return e.jsx(Ue,{scope:n,disabled:d,contentId:Q(),open:m,onOpenToggle:i.useCallback(()=>x(v=>!v),[x]),children:e.jsx($.div,{"data-state":U(m),"data-disabled":d?"":void 0,...c,ref:t})})});G.displayName=_;var H="CollapsibleTrigger",V=i.forwardRef((s,t)=>{const{__scopeCollapsible:n,...l}=s,r=F(H,n);return e.jsx($.button,{type:"button","aria-controls":r.contentId,"aria-expanded":r.open||!1,"data-state":U(r.open),"data-disabled":r.disabled?"":void 0,disabled:r.disabled,...l,ref:t,onClick:X(s.onClick,r.onOpenToggle)})});V.displayName=H;var T="CollapsibleContent",q=i.forwardRef((s,t)=>{const{forceMount:n,...l}=s,r=F(T,s.__scopeCollapsible);return e.jsx(Y,{present:n||r.open,children:({present:d})=>e.jsx(Me,{...l,ref:t,present:d})})});q.displayName=T;var Me=i.forwardRef((s,t)=>{const{__scopeCollapsible:n,present:l,children:r,...d}=s,o=F(T,n),[c,m]=i.useState(l),x=i.useRef(null),v=ee(t,x),w=i.useRef(0),a=w.current,g=i.useRef(0),f=g.current,j=o.open||c,u=i.useRef(j),h=i.useRef(void 0);return i.useEffect(()=>{const p=requestAnimationFrame(()=>u.current=!1);return()=>cancelAnimationFrame(p)},[]),se(()=>{const p=x.current;if(p){h.current=h.current||{transitionDuration:p.style.transitionDuration,animationName:p.style.animationName},p.style.transitionDuration="0s",p.style.animationName="none";const y=p.getBoundingClientRect();w.current=y.height,g.current=y.width,u.current||(p.style.transitionDuration=h.current.transitionDuration,p.style.animationName=h.current.animationName),m(l)}},[o.open,l]),e.jsx($.div,{"data-state":U(o.open),"data-disabled":o.disabled?"":void 0,id:o.contentId,hidden:!j,...d,ref:v,style:{"--radix-collapsible-content-height":a?`${a}px`:void 0,"--radix-collapsible-content-width":f?`${f}px`:void 0,...s.style},children:j&&r})});function U(s){return s?"open":"closed"}var Be=G;function ze({...s}){return e.jsx(Be,{"data-slot":"collapsible",...s})}function We({...s}){return e.jsx(V,{"data-slot":"collapsible-trigger",...s})}function Je({...s}){return e.jsx(q,{"data-slot":"collapsible-content",...s})}function Ge({plugin:s}){const[t,n]=i.useState(s.sourceCode),[l,r]=i.useState(s.install?JSON.stringify(s.install,null,2):""),[d,o]=i.useState(s.config?JSON.stringify(s.config,null,2):"");return i.useEffect(()=>{n(s.sourceCode),r(s.install?JSON.stringify(s.install,null,2):""),o(s.config?JSON.stringify(s.config,null,2):"")},[s]),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h5",{className:"text-xs font-medium text-muted-foreground mb-2",children:"Source Code"}),e.jsx(I,{mode:"javascript",theme:"monokai",value:t,name:`source_${s.id}`,readOnly:!0,width:"100%",fontSize:14,wrapEnabled:!0,showPrintMargin:!1,showGutter:!0,setOptions:{useWorker:!1},minLines:5,maxLines:20,onChange:n})]}),s.install&&e.jsxs("div",{children:[e.jsx("h5",{className:"text-xs font-medium text-muted-foreground mb-2",children:"Dependencies"}),e.jsx(I,{mode:"json",theme:"monokai",value:l,name:`install_${s.id}`,readOnly:!0,width:"100%",fontSize:14,wrapEnabled:!0,showPrintMargin:!1,showGutter:!0,setOptions:{useWorker:!1},minLines:5,maxLines:20,onChange:r})]}),s.config&&Object.keys(s.config).length>0&&e.jsxs("div",{children:[e.jsx("h5",{className:"text-xs font-medium text-muted-foreground mb-2",children:"Plugin Configuration"}),e.jsx(I,{mode:"json",theme:"monokai",value:d,name:`config_${s.id}`,readOnly:!0,width:"100%",fontSize:14,wrapEnabled:!0,showPrintMargin:!1,showGutter:!0,setOptions:{useWorker:!1},minLines:5,maxLines:20,onChange:o})]})]})}function He({plugins:s,onRefresh:t,loading:n=!1}){const[l,r]=i.useState(new Set),[d,o]=i.useState(new Set),c=W(),m=async a=>{const g=a.id;o(u=>new Set(u).add(g));const f=O();let j;a.active?j=await f.deactivatePlugin(g):j=await f.activatePlugin(g),j.status,t==null||t(),o(u=>{const h=new Set(u);return h.delete(g),h})},x=async a=>{if(!confirm("Are you sure you want to delete this plugin?"))return;o(j=>new Set(j).add(a)),(await O().deletePlugin(a)).status,t==null||t(),o(j=>{const u=new Set(j);return u.delete(a),u})},v=a=>{const g={...a,exportedAt:new Date().toISOString()};delete g.process;const f=new Blob([JSON.stringify([g],null,2)],{type:"application/json"}),j=URL.createObjectURL(f),u=document.createElement("a"),h=new Date().toISOString().split("T")[0];u.href=j,u.download=`plugin-${a.id}-${h}.json`,document.body.appendChild(u),u.click(),document.body.removeChild(u),URL.revokeObjectURL(j)},w=a=>{r(g=>{const f=new Set(g);return f.has(a)?f.delete(a):f.add(a),f})};return n?e.jsx(C,{children:e.jsx(P,{className:"flex items-center justify-center py-12",children:e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(R,{className:"h-4 w-4 animate-spin"}),"Loading plugins..."]})})}):s.length===0?e.jsx(C,{children:e.jsxs(k,{children:[e.jsx(L,{children:"No Plugins Found"}),e.jsx(A,{children:"Get started by creating your first plugin."})]})}):e.jsxs(C,{className:"rounded-lg",children:[e.jsxs(k,{children:[e.jsxs(L,{children:["Plugins (",s.length,")"]}),e.jsx(A,{children:"Manage your telemetry plugins."})]}),e.jsx(P,{className:"space-y-4",children:s.map(a=>{const g=l.has(a.id),f=d.has(a.id),j=Pe(a);return e.jsx(ze,{open:g,onOpenChange:()=>w(a.id),children:e.jsxs(C,{className:"rounded-lg border-l-4 border-l-transparent data-[state=open]:border-l-primary transition-all",children:[e.jsx(k,{className:"pb-3",children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"flex items-start gap-3 flex-1 min-w-0",children:[e.jsx(We,{asChild:!0,children:e.jsx(b,{variant:"ghost",size:"sm",className:"rounded-md h-9 w-9 p-0 flex-shrink-0 mt-0.5",children:g?e.jsx(oe,{className:"h-4 w-4"}):e.jsx(be,{className:"h-4 w-4"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2",children:[e.jsx("h3",{className:"font-semibold text-base",children:a.name||a.id}),e.jsx(D,{variant:a.active?"default":"secondary",children:a.active?"Active":"Inactive"}),e.jsx(D,{variant:"outline",className:"font-mono text-xs",children:a.moduleFormat.toUpperCase()})]}),e.jsx("p",{className:"text-sm text-muted-foreground font-mono mb-2",children:a.id}),a.description&&e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:a.description}),e.jsx("div",{className:"flex items-center gap-2",children:j==="url"?e.jsxs("div",{className:"flex items-center gap-1 min-w-0",children:[e.jsx(ie,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),a.url&&e.jsx("a",{href:a.url,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-blue-600 hover:underline truncate",children:a.url})]}):e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(le,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Inline Code"})]})})]})]}),e.jsx("div",{className:"flex items-center gap-3 sm:ml-4 self-start w-full sm:w-auto",children:e.jsxs("div",{className:"flex flex-wrap sm:flex-row gap-2 w-auto",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(b,{variant:a.active?"secondary":"default",size:"sm",onClick:()=>m(a),disabled:f,className:"rounded-md h-9 sm:w-9 p-0",title:a.active?"Pause Plugin":"Run Plugin",children:a.active?e.jsx(ce,{className:"h-4 w-4"}):e.jsx(de,{className:"h-4 w-4"})}),f&&e.jsx(R,{className:"h-4 w-4 animate-spin"})]}),e.jsx(b,{variant:"secondary",size:"sm",onClick:()=>v(a),className:"rounded-md h-9 sm:w-9 p-0",title:"Export Plugin",children:e.jsx(J,{className:"h-4 w-4"})}),e.jsx(b,{variant:"secondary",size:"sm",onClick:()=>x(a.id),title:"Delete Plugin",disabled:f,className:"text-destructive hover:text-destructive rounded-md h-9 sm:w-9 p-0",children:e.jsx(te,{className:"h-4 w-4"})}),e.jsx(b,{variant:"secondary",size:"sm",className:"rounded-md h-9 sm:w-9 p-0",title:"Edit Plugin",onClick:()=>{if(window.confirm("Warning: Editing a plugin will delete and re-register it to properly kill the process. Do you agree?"))try{O().deletePlugin(a.id),c("/plugins/create",{state:{plugin:a}})}catch{}},children:e.jsx(ge,{className:"h-4 w-4"})})]})})]})}),e.jsx(Je,{children:e.jsx(P,{className:"pt-0 rounded-b-lg",children:e.jsx(Ge,{plugin:a})})})]})},a.id)})})]})}function Ve({plugins:s}){const[t,n]=i.useState(!1),l=async()=>{n(!0);try{const r=Ee(s),d=new Blob([r],{type:"application/json"}),o=URL.createObjectURL(d),c=document.createElement("a");c.href=o,c.download=`plugins-export-${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(c),c.click(),document.body.removeChild(c),URL.revokeObjectURL(o),S.success(e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold",children:"Plugins exported"}),e.jsxs("div",{className:"text-xs whitespace-pre-line mt-1",children:["Exported ",s.length," plugin",s.length===1?"":"s"," successfully."]})]}))}catch(r){S.error(e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold",children:"Error exporting plugins"}),e.jsx("div",{className:"text-xs whitespace-pre-line mt-1",children:r instanceof Error?r.message:"Export failed"})]}),{duration:1e4})}finally{n(!1)}};return e.jsxs(b,{variant:"outline",className:"gap-2 bg-transparent",onClick:l,disabled:t||s.length===0,children:[t?e.jsx(R,{className:"h-4 w-4 animate-spin"}):e.jsx(J,{className:"h-4 w-4"}),"Export (",s.length,")"]})}function qe({onPluginsImported:s}){const[t,n]=i.useState(!1),[l,r]=i.useState(!1),[d,o]=i.useState(null),[c,m]=i.useState(null),[x,v]=i.useState(null),w=i.useRef(null),a=()=>{o(null),m(null),v(null),w.current&&(w.current.value="")},g=async u=>{var p;const h=(p=u.target.files)==null?void 0:p[0];if(h){a();try{const y=await h.text(),N=JSON.parse(y);if(!ke(N))throw new Error("Invalid plugin data format");v(N)}catch(y){o(y instanceof Error?y.message:"Failed to parse file")}}},f=async()=>{if(x){r(!0),o(null);try{const u=O(),h=[];for(const N of x)try{const E=await u.createPlugin(N);E.status==="success"?h.push({id:N.id,success:!0}):h.push({id:N.id,success:!1,error:E.message||"Unknown error"})}catch(E){h.push({id:N.id,success:!1,error:E instanceof Error?E.message:"Unknown error"})}const p=h.filter(N=>N.success).length,y=h.length-p;y===0?(m(`Successfully imported ${p} plugins`),S.success(e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold",children:"Plugins imported"}),e.jsxs("div",{className:"text-xs whitespace-pre-line mt-1",children:["Imported ",p," plugin",p===1?"":"s"," successfully."]})]}))):(m(`Imported ${p} plugins (${y} failed)`),S.error(e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold",children:"Some plugins failed to import"}),e.jsxs("div",{className:"text-xs whitespace-pre-line mt-1",children:["Imported ",p," plugin",p===1?"":"s",", ",y," failed.",h.filter(N=>!N.success).map(N=>`
|
|
12
|
+
${N.id}: ${N.error}`).join("")]})]}),{duration:1e4})),s==null||s(),setTimeout(()=>{n(!1)},2e3)}catch(u){o(u instanceof Error?u.message:"Import failed"),S.error(e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold",children:"Error importing plugins"}),e.jsx("div",{className:"text-xs whitespace-pre-line mt-1",children:u instanceof Error?u.message:"Import failed"})]}),{duration:1e4})}finally{r(!1)}}},j=u=>{n(u),u||a()};return e.jsxs(ue,{open:t,onOpenChange:j,children:[e.jsx(me,{asChild:!0,children:e.jsxs(b,{variant:"outline",className:"gap-2 bg-transparent",children:[e.jsx(je,{className:"h-4 w-4"}),"Import"]})}),e.jsxs(xe,{className:"max-w-2xl max-h-[90vh]",children:[e.jsxs(fe,{children:[e.jsx(he,{children:"Import Plugins"}),e.jsx(pe,{children:"Upload a JSON file to import plugins in bulk."})]}),e.jsxs("div",{className:"space-y-6",children:[d&&e.jsxs(M,{variant:"destructive",children:[e.jsx(Ne,{className:"h-4 w-4"}),e.jsx(B,{children:d})]}),c&&e.jsxs(M,{children:[e.jsx(Se,{className:"h-4 w-4"}),e.jsx(B,{children:c})]}),!x&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(we,{htmlFor:"plugin-file",children:"Select Plugin File"}),e.jsx(ve,{id:"plugin-file",type:"file",accept:".json",onChange:g,ref:w})]}),e.jsxs(C,{children:[e.jsx(k,{children:e.jsxs(L,{className:"text-base flex items-center gap-2",children:[e.jsx(ne,{className:"h-4 w-4"}),"Expected Format"]})}),e.jsx(P,{children:e.jsx("pre",{className:"text-xs bg-muted rounded p-3 overflow-x-auto",children:e.jsx("code",{children:`[
|
|
13
|
+
{
|
|
14
|
+
"id": "my-plugin",
|
|
15
|
+
"name": "My Plugin",
|
|
16
|
+
"moduleFormat": "esm",
|
|
17
|
+
"code": "export default function...",
|
|
18
|
+
"active": true,
|
|
19
|
+
"install": {
|
|
20
|
+
"dependencies": ["lodash"],
|
|
21
|
+
"ignoreErrors": false
|
|
22
|
+
},
|
|
23
|
+
"config": {
|
|
24
|
+
"option": true
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
]`})})})]})]}),x&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"font-medium",children:["Preview (",x.length," plugins)"]}),e.jsx(b,{variant:"outline",size:"sm",onClick:a,children:"Choose Different File"})]}),e.jsx(re,{className:"h-64 border rounded-lg",children:e.jsx("div",{className:"p-4 space-y-3",children:x.map((u,h)=>{var p;return e.jsx(C,{children:e.jsx(P,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:u.id}),e.jsx("div",{className:"text-sm text-muted-foreground",children:u.url?`URL: ${u.url}`:"Code provided"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(D,{variant:"outline",className:"font-mono text-xs",children:u.moduleFormat.toUpperCase()}),((p=u.install)==null?void 0:p.dependencies)&&e.jsxs(D,{variant:"secondary",className:"text-xs",children:[u.install.dependencies.length," deps"]})]})]})})},h)})})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(b,{variant:"outline",onClick:()=>n(!1),disabled:l,children:"Cancel"}),e.jsxs(b,{onClick:f,disabled:l,children:[l&&e.jsx(R,{className:"h-4 w-4 mr-2 animate-spin"}),"Import ",x.length," Plugins"]})]})]})]})]})]})}function ls(){const[s,t]=i.useState(0),[n,l]=i.useState([]),[r,d]=i.useState(!0),o=W();i.useEffect(()=>{c()},[s]);const c=async()=>{d(!0);try{const v=await O().listPlugins();v.status==="success"?l(v.data):(l([]),S.error(e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Error loading Plugins:"})," ",v.message||"Unknown error"]})))}catch{l([]),S.error(e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Error loading Plugins:"}),' "Unknown error"']}))}d(!1)},m=()=>{t(x=>x+1)};return e.jsx("div",{className:" bg-gray-50",children:e.jsxs("main",{className:"container mx-auto px-6 py-8 space-y-6",children:[e.jsxs(C,{children:[e.jsx(k,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsxs(L,{className:"flex items-center gap-2",children:[e.jsx(ae,{className:"h-5 w-5"}),"Plugin Management"]}),e.jsx(A,{children:"Control and manage telemetry system plugins"})]})})}),e.jsx(P,{children:e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:e.jsx(b,{className:"gap-2 w-full sm:w-auto",onClick:()=>o("/plugins/create"),children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),"Add Plugin"]})})}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsx(qe,{onPluginsImported:m}),e.jsx(Ve,{plugins:n})]})]})})]}),e.jsx(He,{plugins:n,loading:r,onRefresh:m})]})})}export{ls as default};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{c as Q,o as w,r as o,j as e,B as E,T as V,p as J,t as v,q as z,s as W}from"./index-6xOVKwKn.js";import{C as G,a as K}from"./index-D96rVSkR.js";import{L as F}from"./label-CQLeZjM1.js";import{M as U,S as X,C as Y,V as Z}from"./VirtualizedListPanel-zcj0v7DL.js";import{I as O}from"./input-B-01QDg_.js";import{T as ee,a as te,b as q,c as H}from"./select-DYjegiXi.js";import{C as se}from"./CollapsibleCard-STA1GVQO.js";import{H as ae,p as B,a as ne,b as re}from"./trace-DJq1miYa.js";import{u as oe}from"./utilService-CNZOmadC.js";import{W as le}from"./wand-sparkles-CPoBNFFg.js";import{B as $}from"./badge-CN7FeufU.js";import{C as ie}from"./popover-DS_8DYYt.js";import"./separator-DGsRxIrl.js";import"./dialog-BrpWNk36.js";import"./chevron-down-CG--ounh.js";import"./chevron-up-B6tzMAOm.js";import"./upload-BiLTpCnX.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 ce=[["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M3 12h1",key:"lp3yf2"}],["path",{d:"M3 18h1",key:"1eiwyy"}],["path",{d:"M3 6h1",key:"rgxa97"}],["path",{d:"M8 12h1",key:"1con00"}],["path",{d:"M8 18h1",key:"13wk12"}],["path",{d:"M8 6h1",key:"tn6mkg"}]],de=Q("logs",ce);class me{async fetchTraces(){try{return(await w.get("/traces")).data}catch{return null}}async findSpans(t){const{limit:n=50,query:r={}}=t,i={timestamp:-1},d={...r};return Object.prototype.hasOwnProperty.call(d,"attributes.http.method")||(d["attributes.http.method"]={$exists:!0}),{spans:((await w.post("/traces/find",{query:d,limit:n,sort:i})).data.spans||[]).reverse()}}async getStatus(){return{active:!!(await w.get("/traces/status")).data.active}}async startCollection(){await w.post("/traces/start")}async stopCollection(){await w.post("/traces/stop")}async resetTraces(){await w.post("/traces/reset")}async setRetentionTime(t){return{message:(await w.post("/traces/retention-time",{retentionTimeInSeconds:t})).data.message}}async getRetentionTime(){return(await w.get("/traces/retention-time")).data.retentionTimeInSeconds||0}download(){const n=`${w.defaults.baseURL}/traces/export`;window.open(n,"_blank")}async import(t,n){const r=await t.text(),d=`${w.defaults.baseURL}/traces/import?reset=${n.reset}`,m=await fetch(d,{method:"POST",headers:{"Content-Type":"application/x-ndjson"},body:r});if(!m.ok)throw new Error(`Import failed: ${m.statusText}`)}}const S=new me,pe="normal",ue="advanced",he=({uniqueEndpoints:a,loading:t,onFiltersChange:n,initialTraceId:r=""})=>{const[i,d]=o.useState(r),[m,u]=o.useState("normal"),[b,T]=o.useState([]),[f,g]=o.useState([]),[N,k]=o.useState(""),[I,y]=o.useState(""),[_,A]=o.useState(!1),[L,P]=o.useState([]),[M,p]=o.useState(!1),c=o.useCallback(async()=>{p(!0);try{const s=new Set(a.filter(Boolean));try{const x=await oe.getOpenApiSpec();x!=null&&x.paths&&Object.keys(x.paths).forEach(D=>s.add(D))}catch{}const j=Array.from(s).sort();P(j)}finally{p(!1)}},[a]);o.useEffect(()=>{c()},[c]);const h=()=>{let s={};if(m===ue)try{s=I?JSON.parse(I):{}}catch{v.error("Invalid JSON in advanced query");return}else{if(b.length>0&&(s={...s,"attributes.http.target":{$in:b}}),f.length>0&&(s={...s,"attributes.http.method":{$in:f}}),N.trim().length>0){const j=B(N);if(j.length>0)s={...s,"attributes.http.status_code":{$in:j}};else{v.error("No valid status codes found. Use format: 200, 301, 404");return}}i.trim().length>0&&(s={...s,traceId:i.trim()})}n(s)},l=()=>{T([]),g([]),k(""),y(""),d(""),u(pe),n({})};return o.useEffect(()=>{r&&(d(r),h())},[r]),e.jsx(se,{isOpen:_,onToggle:()=>A(s=>!s),header:e.jsxs(e.Fragment,{children:[e.jsxs(G,{className:"flex items-center gap-2",children:[e.jsx(X,{className:"h-5 w-5"}),"Span Filters"]}),e.jsx(K,{children:"Filter spans by endpoint, HTTP method, or status code."})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs(ee,{value:m,onValueChange:s=>u(s),children:[e.jsxs(te,{className:"grid w-full grid-cols-2",children:[e.jsx(q,{value:"normal",children:"Normal Filters"}),e.jsx(q,{value:"advanced",children:"Advanced Query"})]}),e.jsx(H,{value:"normal",className:"space-y-4",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-[160px]",children:[e.jsxs(F,{htmlFor:"endpoint",className:"text-sm",children:["Endpoint / Target",M&&e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:"(loading...)"})]}),e.jsx(U,{id:"endpoint",options:L.map(s=>({label:s||"(no target)",value:s})),value:b,onValueChange:T,disabled:t||M})]}),e.jsxs("div",{className:"flex-1 min-w-[160px] flex gap-4 flex-col sm:flex-row",children:[e.jsxs("div",{className:"flex-1 min-w-[160px]",children:[e.jsx(F,{htmlFor:"traceId",className:"text-sm",children:"Trace ID"}),e.jsx(O,{id:"traceId",placeholder:"Filter by Trace ID...",value:i,onChange:s=>d(s.target.value),className:"mt-1",disabled:t})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx(F,{htmlFor:"method",className:"text-sm",children:"HTTP Method"}),e.jsx(U,{id:"method",options:ae.map(s=>({label:s,value:s})),value:f,onValueChange:g,disabled:t})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx(F,{htmlFor:"status",className:"text-sm",children:"Status Codes"}),e.jsx(O,{id:"status",placeholder:"200, 301, 404",value:N,onChange:s=>k(s.target.value),className:"font-mono text-sm",disabled:t,title:"Enter HTTP status codes separated by commas or spaces"}),N&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Will query: ",B(N).join(", ")||"none"]})]})]})]})}),e.jsx(H,{value:"advanced",className:"space-y-4",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx(F,{htmlFor:"mongo-query",className:"text-sm",children:"Advanced Query (JSON)"}),e.jsxs(E,{type:"button",variant:"outline",onClick:()=>y(JSON.stringify({"attributes.http.method":"GET","attributes.http.status_code":{$gte:400}},null,2)),disabled:t,children:[e.jsx(le,{className:"h-4 w-4"}),"Load Example"]})]}),e.jsx(V,{id:"mongo-query",placeholder:'{"attributes.http.method": "GET"}',value:I,onChange:s=>y(s.target.value),className:"min-h-[120px] font-mono text-sm",disabled:t})]})})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsxs(E,{onClick:h,disabled:t,className:"w-full sm:w-auto",children:[e.jsx(J,{className:`h-4 w-4 mr-2 ${t?"animate-spin":""}`}),"Apply and Update"]}),e.jsx(E,{variant:"outline",onClick:l,className:"w-full sm:w-auto bg-transparent",disabled:t,children:"Clear"})]})]})})},xe=({traceId:a})=>{if(!a)return null;const n=`${z()}/logs?traceId=${encodeURIComponent(a)}`;return e.jsx(E,{variant:"ghost",size:"sm",className:"flex-shrink-0 h-7 w-7 p-0","aria-label":"Show logs for this trace",title:"Show logs for this trace in a new tab",onClick:r=>{r.stopPropagation(),window.open(n,"_blank")},children:e.jsx(de,{className:"h-4 w-4"})})};function fe(a){let t;if(Array.isArray(a)){const[r,i]=a;t=r*1e3+i/1e6}else typeof a=="string"?t=Number(a):t=a;t>1e15&&(t=Math.floor(t/1e6));const n=new Date(t);return isNaN(n.getTime())?"Invalid timestamp":n.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function ge(a){let t;if(Array.isArray(a)){const[n,r]=a;t=n*1e3+r/1e6}else t=a;return t<1?`${(t*1e3).toFixed(1)}µs`:t<1e3?`${t.toFixed(2)}ms`:`${(t/1e3).toFixed(2)}s`}function ye(a){navigator.clipboard.writeText(a).then(()=>v.success("Copied to clipboard")).catch(()=>v.error("Failed to copy"))}const Se=({span:a})=>{var f,g;const[t,n]=o.useState(!1),r=(f=a.attributes)==null?void 0:f.http,i=(r==null?void 0:r.method)||"UNKNOWN",d=(r==null?void 0:r.target)||"/",m=(r==null?void 0:r.status_code)||0,u=a.traceId||((g=a._spanContext)==null?void 0:g.traceId)||"",b=a.startTime||a.timestamp||0,T=a._duration||a.duration||0;return e.jsxs("div",{className:"group hover:bg-muted/50 rounded-lg px-2 py-2 transition-colors border-b border-muted font-mono text-[13px]",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap text-xs text-muted-foreground font-mono",children:[e.jsx("span",{children:fe(b)}),e.jsx($,{className:`${ne(i)} border rounded-sm text-[10px]`,children:i.toUpperCase()}),e.jsx($,{className:`${re(m)} border rounded-sm text-[10px]`,children:m}),e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:ge(T)}),e.jsxs("span",{className:"flex items-center gap-2 ml-auto",children:[u&&e.jsxs(e.Fragment,{children:[e.jsx($,{variant:"outline",className:"px-2 py-0.5 text-[10px] cursor-pointer font-mono",onClick:()=>ye(u),title:"Copy Trace ID",children:u.slice(0,8)}),e.jsx(xe,{traceId:u})]}),e.jsx(E,{variant:"ghost",size:"sm",className:"flex-shrink-0 h-7 w-7 p-0","aria-label":"Show raw span data",onClick:()=>n(N=>!N),children:e.jsx(Y,{className:"h-4 w-4"})})]})]}),t&&e.jsx("div",{className:"mt-2 mb-2 bg-muted/30 rounded p-2 font-mono text-xs overflow-x-auto border",children:e.jsx("pre",{className:"whitespace-pre-wrap break-words",children:JSON.stringify(a,null,2)})}),e.jsx("div",{className:"text-sm text-foreground break-words font-mono mt-1",children:d})]})};function be({spans:a,loadOlderSpans:t,loadNewerSpans:n}){return e.jsx(Z,{items:a,itemContent:(r,i)=>e.jsx(Se,{span:i}),title:"Spans History",description:"View and scroll through HTTP spans",emptyMessage:"No spans to display. Please update your filter or try again later.",loadOlderItems:t,loadNewerItems:n,panelName:"SpansListPanel"})}const we=({onTracesReset:a})=>{const t=o.useMemo(()=>({getStatus:()=>S.getStatus(),startCollection:()=>S.startCollection(),stopCollection:()=>S.stopCollection(),resetCollection:()=>S.resetTraces(),setRetentionTime:n=>S.setRetentionTime(n),getRetentionTime:()=>S.getRetentionTime()}),[]);return e.jsx(ie,{service:t,resourceType:"traces",onDownload:()=>(S.download(),Promise.resolve()),onImport:(n,r)=>S.import(n,r),onReset:a})},R=30,C=a=>typeof a.timestamp=="number"?a.timestamp:Number(a.timestamp);function qe(){const a=W(),n=new URLSearchParams(a.search).get("traceId")||"",[r,i]=o.useState(!0),[d,m]=o.useState([]),[u,b]=o.useState(null),[T,f]=o.useState(null),[g,N]=o.useState({}),[k,I]=o.useState(!1),y=o.useCallback(async(p={},c=!1)=>{i(!0),N(p),I(c);try{const l=(await S.findSpans({query:p,limit:R})).spans;m(l),l.length>0?(b(C(l[0])),f(C(l[l.length-1]))):c&&l.length===0&&v.info("No spans found")}catch{v.error("Failed to load spans")}finally{i(!1)}},[]),_=o.useCallback(async()=>{if(u)try{const p={...g,timestamp:{$lt:u}},h=(await S.findSpans({query:p,limit:R})).spans.sort((l,s)=>C(l)-C(s));m(l=>{if(l.length===0)return l;const s=new Set(l.map(x=>x._id));return[...h.filter(x=>!s.has(x._id)),...l]}),b(l=>h.length>0?C(h[0]):l)}catch{v.error("Failed to load older spans")}},[u,g,k]),A=o.useCallback(async()=>{if(!T)return y(g,!1);try{const p={...g,timestamp:{$gt:T}},h=(await S.findSpans({query:p,limit:R})).spans.sort((s,j)=>C(s)-C(j));let l=[];m(s=>{const j=new Set(s.map(x=>x._id));return l=h.filter(x=>!j.has(x._id)),[...s,...l]}),l.length>0&&f(C(l[l.length-1]))}catch{v.error("Failed to load newer spans")}},[T,g,y,k]);o.useEffect(()=>{y(n?{"_spanContext.traceId":n}:{},!1)},[y,n]);const L=o.useMemo(()=>Array.from(new Set(d.map(p=>{var c,h;return(h=(c=p.attributes)==null?void 0:c.http)==null?void 0:h.target}))).filter(Boolean),[d]),P=()=>{m([]),b(null),f(null),I(!1),y({},!1)},M=p=>{const c={...p};c.traceId&&(c["_spanContext.traceId"]=c.traceId,delete c.traceId),m([]),b(null),f(null),y(c,!0)};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(we,{onTracesReset:P}),e.jsx(he,{uniqueEndpoints:L,loading:r,onFiltersChange:M,initialTraceId:n}),e.jsx(be,{spans:d,loadOlderSpans:_,loadNewerSpans:A})]})})}export{qe as default};
|