@kopai/ui 0.0.5 → 0.1.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/README.md +137 -0
- package/dist/index.cjs +5069 -3
- package/dist/index.d.cts +301 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +302 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +5010 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +25 -7
- package/src/components/KeyboardShortcuts/KeyboardShortcutsProvider.tsx +113 -0
- package/src/components/KeyboardShortcuts/ShortcutsHelpDialog.tsx +82 -0
- package/src/components/KeyboardShortcuts/context.ts +23 -0
- package/src/components/KeyboardShortcuts/index.ts +8 -0
- package/src/components/KeyboardShortcuts/types.ts +11 -0
- package/src/components/dashboard/Badge/Badge.stories.tsx +29 -0
- package/src/components/dashboard/Badge/index.tsx +32 -0
- package/src/components/dashboard/Button/Button.stories.tsx +107 -0
- package/src/components/dashboard/Button/index.tsx +63 -0
- package/src/components/dashboard/Card/Card.stories.tsx +81 -0
- package/src/components/dashboard/Card/index.tsx +58 -0
- package/src/components/dashboard/Chart/Chart.stories.tsx +48 -0
- package/src/components/dashboard/Chart/index.tsx +74 -0
- package/src/components/dashboard/DatePicker/DatePicker.stories.tsx +33 -0
- package/src/components/dashboard/DatePicker/index.tsx +41 -0
- package/src/components/dashboard/Divider/Divider.stories.tsx +17 -0
- package/src/components/dashboard/Divider/index.tsx +49 -0
- package/src/components/dashboard/Empty/Empty.stories.tsx +48 -0
- package/src/components/dashboard/Empty/index.tsx +46 -0
- package/src/components/dashboard/Grid/Grid.stories.tsx +52 -0
- package/src/components/dashboard/Grid/index.tsx +26 -0
- package/src/components/dashboard/Heading/Heading.stories.tsx +25 -0
- package/src/components/dashboard/Heading/index.tsx +27 -0
- package/src/components/dashboard/List/List.stories.tsx +37 -0
- package/src/components/dashboard/List/index.tsx +24 -0
- package/src/components/dashboard/Metric/Metric.stories.tsx +65 -0
- package/src/components/dashboard/Metric/index.tsx +36 -0
- package/src/components/dashboard/Stack/Stack.stories.tsx +61 -0
- package/src/components/dashboard/Stack/index.tsx +33 -0
- package/src/components/dashboard/Table/Table.stories.tsx +38 -0
- package/src/components/dashboard/Table/index.tsx +104 -0
- package/src/components/dashboard/Text/Text.stories.tsx +53 -0
- package/src/components/dashboard/Text/index.tsx +18 -0
- package/src/components/dashboard/index.ts +46 -0
- package/src/components/index.ts +17 -0
- package/src/components/observability/LogTimeline/LogDetailPane/AttributesTab.tsx +56 -0
- package/src/components/observability/LogTimeline/LogDetailPane/JsonTreeView.tsx +139 -0
- package/src/components/observability/LogTimeline/LogDetailPane/index.tsx +271 -0
- package/src/components/observability/LogTimeline/LogFilter.stories.tsx +66 -0
- package/src/components/observability/LogTimeline/LogFilter.test.tsx +696 -0
- package/src/components/observability/LogTimeline/LogFilter.tsx +674 -0
- package/src/components/observability/LogTimeline/LogRow.tsx +174 -0
- package/src/components/observability/LogTimeline/LogTimeline.stories.tsx +154 -0
- package/src/components/observability/LogTimeline/index.tsx +542 -0
- package/src/components/observability/LogTimeline/shortcuts.ts +18 -0
- package/src/components/observability/MetricHistogram/MetricHistogram.stories.tsx +20 -0
- package/src/components/observability/MetricHistogram/index.tsx +303 -0
- package/src/components/observability/MetricStat/MetricStat.stories.tsx +30 -0
- package/src/components/observability/MetricStat/index.tsx +281 -0
- package/src/components/observability/MetricTable/MetricTable.stories.tsx +20 -0
- package/src/components/observability/MetricTable/index.tsx +194 -0
- package/src/components/observability/MetricTimeSeries/MetricTimeSeries.stories.tsx +28 -0
- package/src/components/observability/MetricTimeSeries/index.tsx +462 -0
- package/src/components/observability/RawDataTable/RawDataTable.stories.tsx +27 -0
- package/src/components/observability/RawDataTable/index.tsx +131 -0
- package/src/components/observability/ServiceList/ServiceList.stories.tsx +20 -0
- package/src/components/observability/ServiceList/index.tsx +60 -0
- package/src/components/observability/ServiceList/shortcuts.ts +6 -0
- package/src/components/observability/TabBar/TabBar.stories.tsx +34 -0
- package/src/components/observability/TabBar/index.tsx +46 -0
- package/src/components/observability/TraceDetail/TraceDetail.stories.tsx +51 -0
- package/src/components/observability/TraceDetail/index.tsx +53 -0
- package/src/components/observability/TraceSearch/TraceSearch.stories.tsx +49 -0
- package/src/components/observability/TraceSearch/index.tsx +292 -0
- package/src/components/observability/TraceTimeline/DetailPane/AttributesTab.tsx +152 -0
- package/src/components/observability/TraceTimeline/DetailPane/EventsTab.tsx +128 -0
- package/src/components/observability/TraceTimeline/DetailPane/LinksTab.tsx +210 -0
- package/src/components/observability/TraceTimeline/DetailPane/index.tsx +174 -0
- package/src/components/observability/TraceTimeline/SpanRow.tsx +173 -0
- package/src/components/observability/TraceTimeline/TimelineBar.tsx +41 -0
- package/src/components/observability/TraceTimeline/Tooltip.tsx +42 -0
- package/src/components/observability/TraceTimeline/TraceHeader.tsx +88 -0
- package/src/components/observability/TraceTimeline/TraceTimeline.stories.tsx +25 -0
- package/src/components/observability/TraceTimeline/index.tsx +478 -0
- package/src/components/observability/TraceTimeline/shortcuts.ts +16 -0
- package/src/components/observability/__fixtures__/logs.ts +476 -0
- package/src/components/observability/__fixtures__/metrics.ts +216 -0
- package/src/components/observability/__fixtures__/raw-table.ts +204 -0
- package/src/components/observability/__fixtures__/services.ts +8 -0
- package/src/components/observability/__fixtures__/trace-summaries.ts +81 -0
- package/src/components/observability/__fixtures__/traces.ts +396 -0
- package/src/components/observability/index.ts +66 -0
- package/src/components/observability/renderers/OtelMetricDiscovery.tsx +77 -0
- package/src/components/observability/renderers/OtelMetricHistogram.tsx +29 -0
- package/src/components/observability/renderers/OtelMetricStat.tsx +44 -0
- package/src/components/observability/renderers/OtelMetricTable.tsx +29 -0
- package/src/components/observability/renderers/OtelMetricTimeSeries.tsx +30 -0
- package/src/components/observability/renderers/index.ts +5 -0
- package/src/components/observability/shared/LoadingSkeleton.tsx +43 -0
- package/src/components/observability/types.ts +113 -0
- package/src/components/observability/utils/attributes.ts +17 -0
- package/src/components/observability/utils/colors.ts +29 -0
- package/src/components/observability/utils/flatten-tree.ts +53 -0
- package/src/components/observability/utils/lttb.ts +121 -0
- package/src/components/observability/utils/time.ts +46 -0
- package/src/hooks/use-kopai-data.test.ts +296 -0
- package/src/hooks/use-kopai-data.ts +64 -0
- package/src/hooks/use-live-logs.test.ts +193 -0
- package/src/hooks/use-live-logs.ts +113 -0
- package/src/index.ts +15 -0
- package/src/lib/__snapshots__/generate-prompt-instructions.test.ts.snap +33 -0
- package/src/lib/catalog.ts +165 -0
- package/src/lib/component-catalog.test.ts +357 -0
- package/src/lib/component-catalog.ts +171 -0
- package/src/lib/dashboard-datasource.ts +76 -0
- package/src/lib/generate-prompt-instructions.test.ts +27 -0
- package/src/lib/generate-prompt-instructions.ts +185 -0
- package/src/lib/log-buffer.test.ts +88 -0
- package/src/lib/log-buffer.ts +62 -0
- package/src/lib/observability-catalog.ts +143 -0
- package/src/lib/renderer.test.tsx +693 -0
- package/src/lib/renderer.tsx +276 -0
- package/src/pages/observability.tsx +828 -0
- package/src/providers/kopai-provider.tsx +51 -0
- package/src/styles/globals.css +46 -0
- package/src/vite-env.d.ts +1 -0
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,303 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
2
|
+
import z$1, { z } from "zod";
|
|
3
|
+
import { ComponentType, ReactNode } from "react";
|
|
4
|
+
import { KopaiClient as KopaiClient$1 } from "@kopai/sdk";
|
|
5
|
+
|
|
6
|
+
//#region src/pages/observability.d.ts
|
|
7
|
+
declare function ObservabilityPage(): react_jsx_runtime0.JSX.Element;
|
|
3
8
|
//#endregion
|
|
4
|
-
|
|
9
|
+
//#region src/lib/component-catalog.d.ts
|
|
10
|
+
declare const dataSourceSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
11
|
+
method: z.ZodLiteral<"searchTracesPage">;
|
|
12
|
+
params: z.ZodObject<{
|
|
13
|
+
traceId: z.ZodOptional<z.ZodString>;
|
|
14
|
+
spanId: z.ZodOptional<z.ZodString>;
|
|
15
|
+
parentSpanId: z.ZodOptional<z.ZodString>;
|
|
16
|
+
serviceName: z.ZodOptional<z.ZodString>;
|
|
17
|
+
spanName: z.ZodOptional<z.ZodString>;
|
|
18
|
+
spanKind: z.ZodOptional<z.ZodString>;
|
|
19
|
+
statusCode: z.ZodOptional<z.ZodString>;
|
|
20
|
+
scopeName: z.ZodOptional<z.ZodString>;
|
|
21
|
+
timestampMin: z.ZodOptional<z.ZodString>;
|
|
22
|
+
timestampMax: z.ZodOptional<z.ZodString>;
|
|
23
|
+
durationMin: z.ZodOptional<z.ZodString>;
|
|
24
|
+
durationMax: z.ZodOptional<z.ZodString>;
|
|
25
|
+
spanAttributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
26
|
+
resourceAttributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
27
|
+
eventsAttributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
28
|
+
linksAttributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
29
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
30
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
31
|
+
sortOrder: z.ZodOptional<z.ZodEnum<{
|
|
32
|
+
ASC: "ASC";
|
|
33
|
+
DESC: "DESC";
|
|
34
|
+
}>>;
|
|
35
|
+
}, z.core.$strip>;
|
|
36
|
+
refetchIntervalMs: z.ZodOptional<z.ZodNumber>;
|
|
37
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
38
|
+
method: z.ZodLiteral<"searchLogsPage">;
|
|
39
|
+
params: z.ZodObject<{
|
|
40
|
+
traceId: z.ZodOptional<z.ZodString>;
|
|
41
|
+
spanId: z.ZodOptional<z.ZodString>;
|
|
42
|
+
serviceName: z.ZodOptional<z.ZodString>;
|
|
43
|
+
scopeName: z.ZodOptional<z.ZodString>;
|
|
44
|
+
severityText: z.ZodOptional<z.ZodString>;
|
|
45
|
+
severityNumberMin: z.ZodOptional<z.ZodNumber>;
|
|
46
|
+
severityNumberMax: z.ZodOptional<z.ZodNumber>;
|
|
47
|
+
bodyContains: z.ZodOptional<z.ZodString>;
|
|
48
|
+
timestampMin: z.ZodOptional<z.ZodString>;
|
|
49
|
+
timestampMax: z.ZodOptional<z.ZodString>;
|
|
50
|
+
logAttributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
51
|
+
resourceAttributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
52
|
+
scopeAttributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
53
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
54
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
55
|
+
sortOrder: z.ZodOptional<z.ZodEnum<{
|
|
56
|
+
ASC: "ASC";
|
|
57
|
+
DESC: "DESC";
|
|
58
|
+
}>>;
|
|
59
|
+
}, z.core.$strip>;
|
|
60
|
+
refetchIntervalMs: z.ZodOptional<z.ZodNumber>;
|
|
61
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
62
|
+
method: z.ZodLiteral<"searchMetricsPage">;
|
|
63
|
+
params: z.ZodObject<{
|
|
64
|
+
metricType: z.ZodEnum<{
|
|
65
|
+
Gauge: "Gauge";
|
|
66
|
+
Sum: "Sum";
|
|
67
|
+
Histogram: "Histogram";
|
|
68
|
+
ExponentialHistogram: "ExponentialHistogram";
|
|
69
|
+
Summary: "Summary";
|
|
70
|
+
}>;
|
|
71
|
+
metricName: z.ZodOptional<z.ZodString>;
|
|
72
|
+
serviceName: z.ZodOptional<z.ZodString>;
|
|
73
|
+
scopeName: z.ZodOptional<z.ZodString>;
|
|
74
|
+
timeUnixMin: z.ZodOptional<z.ZodString>;
|
|
75
|
+
timeUnixMax: z.ZodOptional<z.ZodString>;
|
|
76
|
+
attributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
77
|
+
resourceAttributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
78
|
+
scopeAttributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
79
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
80
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
81
|
+
sortOrder: z.ZodOptional<z.ZodEnum<{
|
|
82
|
+
ASC: "ASC";
|
|
83
|
+
DESC: "DESC";
|
|
84
|
+
}>>;
|
|
85
|
+
}, z.core.$strip>;
|
|
86
|
+
refetchIntervalMs: z.ZodOptional<z.ZodNumber>;
|
|
87
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
88
|
+
method: z.ZodLiteral<"getTrace">;
|
|
89
|
+
params: z.ZodObject<{
|
|
90
|
+
traceId: z.ZodString;
|
|
91
|
+
}, z.core.$strip>;
|
|
92
|
+
refetchIntervalMs: z.ZodOptional<z.ZodNumber>;
|
|
93
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
94
|
+
method: z.ZodLiteral<"discoverMetrics">;
|
|
95
|
+
params: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
96
|
+
refetchIntervalMs: z.ZodOptional<z.ZodNumber>;
|
|
97
|
+
}, z.core.$strip>], "method">;
|
|
98
|
+
declare const componentDefinitionSchema: z.ZodObject<{
|
|
99
|
+
hasChildren: z.ZodBoolean;
|
|
100
|
+
description: z.ZodString;
|
|
101
|
+
props: z.ZodUnknown;
|
|
102
|
+
}, z.core.$strip>;
|
|
103
|
+
type ElementVariantSchema<K extends string, Props extends z.ZodTypeAny> = z.ZodObject<{
|
|
104
|
+
key: z.ZodString;
|
|
105
|
+
type: z.ZodLiteral<K>;
|
|
106
|
+
children: z.ZodArray<z.ZodString>;
|
|
107
|
+
parentKey: z.ZodString;
|
|
108
|
+
dataSource: z.ZodOptional<typeof dataSourceSchema>;
|
|
109
|
+
props: Props;
|
|
110
|
+
}>;
|
|
111
|
+
type ElementVariantSchemas<C extends Record<string, {
|
|
112
|
+
props: unknown;
|
|
113
|
+
}>> = { [K in keyof C & string]: ElementVariantSchema<K, C[K]["props"] extends z.ZodTypeAny ? C[K]["props"] : z.ZodUnknown> }[keyof C & string];
|
|
114
|
+
/**
|
|
115
|
+
* Creates a component catalog with typed UI tree schema for validation.
|
|
116
|
+
*
|
|
117
|
+
* @param catalogConfig - Catalog configuration with name and component definitions
|
|
118
|
+
* @returns Catalog object with name, components, and generated uiTreeSchema
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```ts
|
|
122
|
+
* const catalog = createCatalog({
|
|
123
|
+
* name: "my-catalog",
|
|
124
|
+
* components: {
|
|
125
|
+
* Card: {
|
|
126
|
+
* hasChildren: true,
|
|
127
|
+
* description: "Container card",
|
|
128
|
+
* props: z.object({ title: z.string() }),
|
|
129
|
+
* },
|
|
130
|
+
* },
|
|
131
|
+
* });
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
declare function createCatalog<C extends Record<string, z.infer<typeof componentDefinitionSchema>>>(catalogConfig: {
|
|
135
|
+
name: string;
|
|
136
|
+
components: C;
|
|
137
|
+
}): {
|
|
138
|
+
name: string;
|
|
139
|
+
components: C;
|
|
140
|
+
uiTreeSchema: z.ZodObject<{
|
|
141
|
+
root: z.ZodString;
|
|
142
|
+
elements: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[ElementVariantSchemas<C>, ...ElementVariantSchemas<C>[]], "type">>;
|
|
143
|
+
}, z.core.$strip>;
|
|
144
|
+
};
|
|
145
|
+
type ComponentDefinition = z.infer<typeof componentDefinitionSchema>;
|
|
146
|
+
type InferProps<P> = P extends z.ZodTypeAny ? z.infer<P> : P;
|
|
147
|
+
//#endregion
|
|
148
|
+
//#region src/lib/generate-prompt-instructions.d.ts
|
|
149
|
+
type Catalog$1 = {
|
|
150
|
+
name: string;
|
|
151
|
+
components: Record<string, {
|
|
152
|
+
hasChildren: boolean;
|
|
153
|
+
description: string;
|
|
154
|
+
props: unknown;
|
|
155
|
+
}>;
|
|
156
|
+
uiTreeSchema: z.ZodTypeAny;
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* Generates LLM prompt instructions from a catalog.
|
|
160
|
+
* Includes component docs, JSON schema, and usage examples.
|
|
161
|
+
*
|
|
162
|
+
* @param catalog - The catalog created via createCatalog
|
|
163
|
+
* @returns Markdown string with component docs, schema, and examples
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* ```ts
|
|
167
|
+
* const instructions = generatePromptInstructions(catalog);
|
|
168
|
+
* const prompt = `Build a dashboard UI.\n\n${instructions}`;
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
declare function generatePromptInstructions(catalog: Catalog$1): string;
|
|
172
|
+
//#endregion
|
|
173
|
+
//#region src/lib/renderer.d.ts
|
|
174
|
+
type RegistryFromCatalog<C extends {
|
|
175
|
+
components: Record<string, ComponentDefinition>;
|
|
176
|
+
}> = { [K in keyof C["components"]]: ComponentType<RendererComponentProps<C["components"][K]>> };
|
|
177
|
+
type Catalog = ReturnType<typeof createCatalog>;
|
|
178
|
+
type UITree = z$1.infer<Catalog["uiTreeSchema"]>;
|
|
179
|
+
type UIElement = UITree["elements"][string];
|
|
180
|
+
type RendererDataSource = {
|
|
181
|
+
method: string;
|
|
182
|
+
params?: Record<string, unknown>;
|
|
183
|
+
};
|
|
184
|
+
type BaseElement<Props> = {
|
|
185
|
+
key: string;
|
|
186
|
+
type: string;
|
|
187
|
+
children: string[];
|
|
188
|
+
parentKey: string;
|
|
189
|
+
dataSource?: RendererDataSource;
|
|
190
|
+
props: Props;
|
|
191
|
+
};
|
|
192
|
+
type WithData = {
|
|
193
|
+
hasData: true;
|
|
194
|
+
data: unknown;
|
|
195
|
+
loading: boolean;
|
|
196
|
+
error: Error | null;
|
|
197
|
+
refetch: () => void;
|
|
198
|
+
updateParams: (params: Record<string, unknown>) => void;
|
|
199
|
+
};
|
|
200
|
+
type WithoutData = {
|
|
201
|
+
hasData: false;
|
|
202
|
+
};
|
|
203
|
+
type RendererComponentProps<CD extends ComponentDefinition> = CD extends {
|
|
204
|
+
hasChildren: true;
|
|
205
|
+
props: infer P;
|
|
206
|
+
} ? ({
|
|
207
|
+
element: BaseElement<InferProps<P>>;
|
|
208
|
+
children: ReactNode;
|
|
209
|
+
} & WithoutData) | ({
|
|
210
|
+
element: BaseElement<InferProps<P>>;
|
|
211
|
+
children: ReactNode;
|
|
212
|
+
} & WithData) : CD extends {
|
|
213
|
+
props: infer P;
|
|
214
|
+
} ? ({
|
|
215
|
+
element: BaseElement<InferProps<P>>;
|
|
216
|
+
} & WithoutData) | ({
|
|
217
|
+
element: BaseElement<InferProps<P>>;
|
|
218
|
+
} & WithData) : never;
|
|
219
|
+
/**
|
|
220
|
+
* Base props (no dataSource)
|
|
221
|
+
*/
|
|
222
|
+
interface ComponentRenderPropsBase {
|
|
223
|
+
element: UIElement;
|
|
224
|
+
children?: ReactNode;
|
|
225
|
+
hasData: false;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Props with dataSource
|
|
229
|
+
*/
|
|
230
|
+
interface ComponentRenderPropsWithData {
|
|
231
|
+
element: UIElement;
|
|
232
|
+
children?: ReactNode;
|
|
233
|
+
hasData: true;
|
|
234
|
+
data: unknown;
|
|
235
|
+
loading: boolean;
|
|
236
|
+
error: Error | null;
|
|
237
|
+
refetch: () => void;
|
|
238
|
+
updateParams: (params: Record<string, unknown>) => void;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Discriminated union for component render props
|
|
242
|
+
*/
|
|
243
|
+
type ComponentRenderProps = ComponentRenderPropsBase | ComponentRenderPropsWithData;
|
|
244
|
+
/**
|
|
245
|
+
* Component renderer type
|
|
246
|
+
*/
|
|
247
|
+
type ComponentRenderer = ComponentType<ComponentRenderProps>;
|
|
248
|
+
/**
|
|
249
|
+
* Creates a typed Renderer component bound to a catalog and component implementations.
|
|
250
|
+
*
|
|
251
|
+
* @param _catalog - The catalog created via createCatalog (used for type inference)
|
|
252
|
+
* @param components - React component implementations matching catalog definitions
|
|
253
|
+
* @returns A Renderer component that only needs `tree` and optional `fallback`
|
|
254
|
+
*
|
|
255
|
+
* @example
|
|
256
|
+
* ```tsx
|
|
257
|
+
* const DashboardRenderer = createRendererFromCatalog(catalog, {
|
|
258
|
+
* Card: ({ element, children }) => <div className="card">{children}</div>,
|
|
259
|
+
* Table: ({ element, data }) => <table>...</table>,
|
|
260
|
+
* });
|
|
261
|
+
*
|
|
262
|
+
* <DashboardRenderer tree={uiTree} />
|
|
263
|
+
* ```
|
|
264
|
+
*/
|
|
265
|
+
declare function createRendererFromCatalog<C extends {
|
|
266
|
+
components: Record<string, ComponentDefinition>;
|
|
267
|
+
}>(_catalog: C, components: RegistryFromCatalog<C>): ({
|
|
268
|
+
tree,
|
|
269
|
+
fallback
|
|
270
|
+
}: {
|
|
271
|
+
tree: UITree | null;
|
|
272
|
+
fallback?: ComponentRenderer;
|
|
273
|
+
}) => react_jsx_runtime0.JSX.Element;
|
|
274
|
+
/**
|
|
275
|
+
* Renders a UITree using a component registry.
|
|
276
|
+
* Prefer using {@link createRendererFromCatalog} for type-safe rendering.
|
|
277
|
+
*/
|
|
278
|
+
declare function Renderer<C extends {
|
|
279
|
+
components: Record<string, ComponentDefinition>;
|
|
280
|
+
}>({
|
|
281
|
+
tree,
|
|
282
|
+
registry,
|
|
283
|
+
fallback
|
|
284
|
+
}: {
|
|
285
|
+
tree: z$1.infer<ReturnType<typeof createCatalog>["uiTreeSchema"]> | null;
|
|
286
|
+
registry: RegistryFromCatalog<C>;
|
|
287
|
+
fallback?: ComponentRenderer;
|
|
288
|
+
}): react_jsx_runtime0.JSX.Element | null;
|
|
289
|
+
//#endregion
|
|
290
|
+
//#region src/providers/kopai-provider.d.ts
|
|
291
|
+
type KopaiClient = Pick<KopaiClient$1, "searchTracesPage" | "searchLogsPage" | "searchMetricsPage" | "getTrace" | "discoverMetrics">;
|
|
292
|
+
interface KopaiSDKProviderProps {
|
|
293
|
+
client: KopaiClient;
|
|
294
|
+
children: ReactNode;
|
|
295
|
+
}
|
|
296
|
+
declare function KopaiSDKProvider({
|
|
297
|
+
client,
|
|
298
|
+
children
|
|
299
|
+
}: KopaiSDKProviderProps): react_jsx_runtime0.JSX.Element;
|
|
300
|
+
declare function useKopaiSDK(): KopaiClient;
|
|
301
|
+
//#endregion
|
|
302
|
+
export { type ComponentRenderProps, type ComponentRenderer, type KopaiClient, KopaiSDKProvider, ObservabilityPage, Renderer, type RendererComponentProps, createCatalog, createRendererFromCatalog, generatePromptInstructions, useKopaiSDK };
|
|
5
303
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/pages/observability.tsx","../src/lib/component-catalog.ts","../src/lib/generate-prompt-instructions.ts","../src/lib/renderer.tsx","../src/providers/kopai-provider.tsx"],"mappings":";;;;;;iBA0uBwB,iBAAA,CAAA,GAAiB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;cCruB5B,gBAAA,EAAgB,CAAA,CAAA,qBAAA,EAAA,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA8BhB,yBAAA,EAAyB,CAAA,CAAA,SAAA;;;;;KAqCjC,oBAAA,iCAEW,CAAA,CAAE,UAAA,IACd,CAAA,CAAE,SAAA;EACJ,GAAA,EAAK,CAAA,CAAE,SAAA;EACP,IAAA,EAAM,CAAA,CAAE,UAAA,CAAW,CAAA;EACnB,QAAA,EAAU,CAAA,CAAE,QAAA,CAAS,CAAA,CAAE,SAAA;EACvB,SAAA,EAAW,CAAA,CAAE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,SAAe,mBAAA;AAAA,EAAA,CAAA;EAEvC,IAAA;EACA,QAAA;EACA;AAAA;EAEA,IAAA,EAAM,GAAA,CAAE,KAAA,CAAM,UAAA,QAAkB,aAAA;EAChC,QAAA,EAAU,mBAAA,CAAoB,CAAA;EAC9B,QAAA,GAAW,iBAAA;AAAA,IACZ,kBAAA,CAAA,GAAA,CAAA,OAAA;;;KCjQW,WAAA,GAAc,IAAA,CACxB,aAAA;AAAA,UAwBQ,qBAAA;EACR,MAAA,EAAQ,WAAA;EACR,QAAA,EAAU,SAAA;AAAA;AAAA,iBAGI,gBAAA,CAAA;EAAmB,MAAA;EAAQ;AAAA,GAAY,qBAAA,GAAqB,kBAAA,CAAA,GAAA,CAAA,OAAA;AAAA,iBAU5D,WAAA,CAAA,GAAe,WAAA"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,304 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { ComponentType, ReactNode } from "react";
|
|
2
|
+
import { QueryClient } from "@tanstack/react-query";
|
|
3
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
|
+
import { KopaiClient as KopaiClient$1 } from "@kopai/sdk";
|
|
5
|
+
import z$1, { z } from "zod";
|
|
6
|
+
|
|
7
|
+
//#region src/pages/observability.d.ts
|
|
8
|
+
declare function ObservabilityPage(): react_jsx_runtime0.JSX.Element;
|
|
3
9
|
//#endregion
|
|
4
|
-
|
|
10
|
+
//#region src/lib/component-catalog.d.ts
|
|
11
|
+
declare const dataSourceSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
12
|
+
method: z.ZodLiteral<"searchTracesPage">;
|
|
13
|
+
params: z.ZodObject<{
|
|
14
|
+
traceId: z.ZodOptional<z.ZodString>;
|
|
15
|
+
spanId: z.ZodOptional<z.ZodString>;
|
|
16
|
+
parentSpanId: z.ZodOptional<z.ZodString>;
|
|
17
|
+
serviceName: z.ZodOptional<z.ZodString>;
|
|
18
|
+
spanName: z.ZodOptional<z.ZodString>;
|
|
19
|
+
spanKind: z.ZodOptional<z.ZodString>;
|
|
20
|
+
statusCode: z.ZodOptional<z.ZodString>;
|
|
21
|
+
scopeName: z.ZodOptional<z.ZodString>;
|
|
22
|
+
timestampMin: z.ZodOptional<z.ZodString>;
|
|
23
|
+
timestampMax: z.ZodOptional<z.ZodString>;
|
|
24
|
+
durationMin: z.ZodOptional<z.ZodString>;
|
|
25
|
+
durationMax: z.ZodOptional<z.ZodString>;
|
|
26
|
+
spanAttributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
27
|
+
resourceAttributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
28
|
+
eventsAttributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
29
|
+
linksAttributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
30
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
31
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
32
|
+
sortOrder: z.ZodOptional<z.ZodEnum<{
|
|
33
|
+
ASC: "ASC";
|
|
34
|
+
DESC: "DESC";
|
|
35
|
+
}>>;
|
|
36
|
+
}, z.core.$strip>;
|
|
37
|
+
refetchIntervalMs: z.ZodOptional<z.ZodNumber>;
|
|
38
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
39
|
+
method: z.ZodLiteral<"searchLogsPage">;
|
|
40
|
+
params: z.ZodObject<{
|
|
41
|
+
traceId: z.ZodOptional<z.ZodString>;
|
|
42
|
+
spanId: z.ZodOptional<z.ZodString>;
|
|
43
|
+
serviceName: z.ZodOptional<z.ZodString>;
|
|
44
|
+
scopeName: z.ZodOptional<z.ZodString>;
|
|
45
|
+
severityText: z.ZodOptional<z.ZodString>;
|
|
46
|
+
severityNumberMin: z.ZodOptional<z.ZodNumber>;
|
|
47
|
+
severityNumberMax: z.ZodOptional<z.ZodNumber>;
|
|
48
|
+
bodyContains: z.ZodOptional<z.ZodString>;
|
|
49
|
+
timestampMin: z.ZodOptional<z.ZodString>;
|
|
50
|
+
timestampMax: z.ZodOptional<z.ZodString>;
|
|
51
|
+
logAttributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
52
|
+
resourceAttributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
53
|
+
scopeAttributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
54
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
55
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
56
|
+
sortOrder: z.ZodOptional<z.ZodEnum<{
|
|
57
|
+
ASC: "ASC";
|
|
58
|
+
DESC: "DESC";
|
|
59
|
+
}>>;
|
|
60
|
+
}, z.core.$strip>;
|
|
61
|
+
refetchIntervalMs: z.ZodOptional<z.ZodNumber>;
|
|
62
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
63
|
+
method: z.ZodLiteral<"searchMetricsPage">;
|
|
64
|
+
params: z.ZodObject<{
|
|
65
|
+
metricType: z.ZodEnum<{
|
|
66
|
+
Gauge: "Gauge";
|
|
67
|
+
Sum: "Sum";
|
|
68
|
+
Histogram: "Histogram";
|
|
69
|
+
ExponentialHistogram: "ExponentialHistogram";
|
|
70
|
+
Summary: "Summary";
|
|
71
|
+
}>;
|
|
72
|
+
metricName: z.ZodOptional<z.ZodString>;
|
|
73
|
+
serviceName: z.ZodOptional<z.ZodString>;
|
|
74
|
+
scopeName: z.ZodOptional<z.ZodString>;
|
|
75
|
+
timeUnixMin: z.ZodOptional<z.ZodString>;
|
|
76
|
+
timeUnixMax: z.ZodOptional<z.ZodString>;
|
|
77
|
+
attributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
78
|
+
resourceAttributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
79
|
+
scopeAttributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
80
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
81
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
82
|
+
sortOrder: z.ZodOptional<z.ZodEnum<{
|
|
83
|
+
ASC: "ASC";
|
|
84
|
+
DESC: "DESC";
|
|
85
|
+
}>>;
|
|
86
|
+
}, z.core.$strip>;
|
|
87
|
+
refetchIntervalMs: z.ZodOptional<z.ZodNumber>;
|
|
88
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
89
|
+
method: z.ZodLiteral<"getTrace">;
|
|
90
|
+
params: z.ZodObject<{
|
|
91
|
+
traceId: z.ZodString;
|
|
92
|
+
}, z.core.$strip>;
|
|
93
|
+
refetchIntervalMs: z.ZodOptional<z.ZodNumber>;
|
|
94
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
95
|
+
method: z.ZodLiteral<"discoverMetrics">;
|
|
96
|
+
params: z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
|
|
97
|
+
refetchIntervalMs: z.ZodOptional<z.ZodNumber>;
|
|
98
|
+
}, z.core.$strip>], "method">;
|
|
99
|
+
declare const componentDefinitionSchema: z.ZodObject<{
|
|
100
|
+
hasChildren: z.ZodBoolean;
|
|
101
|
+
description: z.ZodString;
|
|
102
|
+
props: z.ZodUnknown;
|
|
103
|
+
}, z.core.$strip>;
|
|
104
|
+
type ElementVariantSchema<K extends string, Props extends z.ZodTypeAny> = z.ZodObject<{
|
|
105
|
+
key: z.ZodString;
|
|
106
|
+
type: z.ZodLiteral<K>;
|
|
107
|
+
children: z.ZodArray<z.ZodString>;
|
|
108
|
+
parentKey: z.ZodString;
|
|
109
|
+
dataSource: z.ZodOptional<typeof dataSourceSchema>;
|
|
110
|
+
props: Props;
|
|
111
|
+
}>;
|
|
112
|
+
type ElementVariantSchemas<C extends Record<string, {
|
|
113
|
+
props: unknown;
|
|
114
|
+
}>> = { [K in keyof C & string]: ElementVariantSchema<K, C[K]["props"] extends z.ZodTypeAny ? C[K]["props"] : z.ZodUnknown> }[keyof C & string];
|
|
115
|
+
/**
|
|
116
|
+
* Creates a component catalog with typed UI tree schema for validation.
|
|
117
|
+
*
|
|
118
|
+
* @param catalogConfig - Catalog configuration with name and component definitions
|
|
119
|
+
* @returns Catalog object with name, components, and generated uiTreeSchema
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```ts
|
|
123
|
+
* const catalog = createCatalog({
|
|
124
|
+
* name: "my-catalog",
|
|
125
|
+
* components: {
|
|
126
|
+
* Card: {
|
|
127
|
+
* hasChildren: true,
|
|
128
|
+
* description: "Container card",
|
|
129
|
+
* props: z.object({ title: z.string() }),
|
|
130
|
+
* },
|
|
131
|
+
* },
|
|
132
|
+
* });
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
declare function createCatalog<C extends Record<string, z.infer<typeof componentDefinitionSchema>>>(catalogConfig: {
|
|
136
|
+
name: string;
|
|
137
|
+
components: C;
|
|
138
|
+
}): {
|
|
139
|
+
name: string;
|
|
140
|
+
components: C;
|
|
141
|
+
uiTreeSchema: z.ZodObject<{
|
|
142
|
+
root: z.ZodString;
|
|
143
|
+
elements: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[ElementVariantSchemas<C>, ...ElementVariantSchemas<C>[]], "type">>;
|
|
144
|
+
}, z.core.$strip>;
|
|
145
|
+
};
|
|
146
|
+
type ComponentDefinition = z.infer<typeof componentDefinitionSchema>;
|
|
147
|
+
type InferProps<P> = P extends z.ZodTypeAny ? z.infer<P> : P;
|
|
148
|
+
//#endregion
|
|
149
|
+
//#region src/lib/generate-prompt-instructions.d.ts
|
|
150
|
+
type Catalog$1 = {
|
|
151
|
+
name: string;
|
|
152
|
+
components: Record<string, {
|
|
153
|
+
hasChildren: boolean;
|
|
154
|
+
description: string;
|
|
155
|
+
props: unknown;
|
|
156
|
+
}>;
|
|
157
|
+
uiTreeSchema: z.ZodTypeAny;
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* Generates LLM prompt instructions from a catalog.
|
|
161
|
+
* Includes component docs, JSON schema, and usage examples.
|
|
162
|
+
*
|
|
163
|
+
* @param catalog - The catalog created via createCatalog
|
|
164
|
+
* @returns Markdown string with component docs, schema, and examples
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```ts
|
|
168
|
+
* const instructions = generatePromptInstructions(catalog);
|
|
169
|
+
* const prompt = `Build a dashboard UI.\n\n${instructions}`;
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
declare function generatePromptInstructions(catalog: Catalog$1): string;
|
|
173
|
+
//#endregion
|
|
174
|
+
//#region src/lib/renderer.d.ts
|
|
175
|
+
type RegistryFromCatalog<C extends {
|
|
176
|
+
components: Record<string, ComponentDefinition>;
|
|
177
|
+
}> = { [K in keyof C["components"]]: ComponentType<RendererComponentProps<C["components"][K]>> };
|
|
178
|
+
type Catalog = ReturnType<typeof createCatalog>;
|
|
179
|
+
type UITree = z$1.infer<Catalog["uiTreeSchema"]>;
|
|
180
|
+
type UIElement = UITree["elements"][string];
|
|
181
|
+
type RendererDataSource = {
|
|
182
|
+
method: string;
|
|
183
|
+
params?: Record<string, unknown>;
|
|
184
|
+
};
|
|
185
|
+
type BaseElement<Props> = {
|
|
186
|
+
key: string;
|
|
187
|
+
type: string;
|
|
188
|
+
children: string[];
|
|
189
|
+
parentKey: string;
|
|
190
|
+
dataSource?: RendererDataSource;
|
|
191
|
+
props: Props;
|
|
192
|
+
};
|
|
193
|
+
type WithData = {
|
|
194
|
+
hasData: true;
|
|
195
|
+
data: unknown;
|
|
196
|
+
loading: boolean;
|
|
197
|
+
error: Error | null;
|
|
198
|
+
refetch: () => void;
|
|
199
|
+
updateParams: (params: Record<string, unknown>) => void;
|
|
200
|
+
};
|
|
201
|
+
type WithoutData = {
|
|
202
|
+
hasData: false;
|
|
203
|
+
};
|
|
204
|
+
type RendererComponentProps<CD extends ComponentDefinition> = CD extends {
|
|
205
|
+
hasChildren: true;
|
|
206
|
+
props: infer P;
|
|
207
|
+
} ? ({
|
|
208
|
+
element: BaseElement<InferProps<P>>;
|
|
209
|
+
children: ReactNode;
|
|
210
|
+
} & WithoutData) | ({
|
|
211
|
+
element: BaseElement<InferProps<P>>;
|
|
212
|
+
children: ReactNode;
|
|
213
|
+
} & WithData) : CD extends {
|
|
214
|
+
props: infer P;
|
|
215
|
+
} ? ({
|
|
216
|
+
element: BaseElement<InferProps<P>>;
|
|
217
|
+
} & WithoutData) | ({
|
|
218
|
+
element: BaseElement<InferProps<P>>;
|
|
219
|
+
} & WithData) : never;
|
|
220
|
+
/**
|
|
221
|
+
* Base props (no dataSource)
|
|
222
|
+
*/
|
|
223
|
+
interface ComponentRenderPropsBase {
|
|
224
|
+
element: UIElement;
|
|
225
|
+
children?: ReactNode;
|
|
226
|
+
hasData: false;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Props with dataSource
|
|
230
|
+
*/
|
|
231
|
+
interface ComponentRenderPropsWithData {
|
|
232
|
+
element: UIElement;
|
|
233
|
+
children?: ReactNode;
|
|
234
|
+
hasData: true;
|
|
235
|
+
data: unknown;
|
|
236
|
+
loading: boolean;
|
|
237
|
+
error: Error | null;
|
|
238
|
+
refetch: () => void;
|
|
239
|
+
updateParams: (params: Record<string, unknown>) => void;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Discriminated union for component render props
|
|
243
|
+
*/
|
|
244
|
+
type ComponentRenderProps = ComponentRenderPropsBase | ComponentRenderPropsWithData;
|
|
245
|
+
/**
|
|
246
|
+
* Component renderer type
|
|
247
|
+
*/
|
|
248
|
+
type ComponentRenderer = ComponentType<ComponentRenderProps>;
|
|
249
|
+
/**
|
|
250
|
+
* Creates a typed Renderer component bound to a catalog and component implementations.
|
|
251
|
+
*
|
|
252
|
+
* @param _catalog - The catalog created via createCatalog (used for type inference)
|
|
253
|
+
* @param components - React component implementations matching catalog definitions
|
|
254
|
+
* @returns A Renderer component that only needs `tree` and optional `fallback`
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* ```tsx
|
|
258
|
+
* const DashboardRenderer = createRendererFromCatalog(catalog, {
|
|
259
|
+
* Card: ({ element, children }) => <div className="card">{children}</div>,
|
|
260
|
+
* Table: ({ element, data }) => <table>...</table>,
|
|
261
|
+
* });
|
|
262
|
+
*
|
|
263
|
+
* <DashboardRenderer tree={uiTree} />
|
|
264
|
+
* ```
|
|
265
|
+
*/
|
|
266
|
+
declare function createRendererFromCatalog<C extends {
|
|
267
|
+
components: Record<string, ComponentDefinition>;
|
|
268
|
+
}>(_catalog: C, components: RegistryFromCatalog<C>): ({
|
|
269
|
+
tree,
|
|
270
|
+
fallback
|
|
271
|
+
}: {
|
|
272
|
+
tree: UITree | null;
|
|
273
|
+
fallback?: ComponentRenderer;
|
|
274
|
+
}) => react_jsx_runtime0.JSX.Element;
|
|
275
|
+
/**
|
|
276
|
+
* Renders a UITree using a component registry.
|
|
277
|
+
* Prefer using {@link createRendererFromCatalog} for type-safe rendering.
|
|
278
|
+
*/
|
|
279
|
+
declare function Renderer<C extends {
|
|
280
|
+
components: Record<string, ComponentDefinition>;
|
|
281
|
+
}>({
|
|
282
|
+
tree,
|
|
283
|
+
registry,
|
|
284
|
+
fallback
|
|
285
|
+
}: {
|
|
286
|
+
tree: z$1.infer<ReturnType<typeof createCatalog>["uiTreeSchema"]> | null;
|
|
287
|
+
registry: RegistryFromCatalog<C>;
|
|
288
|
+
fallback?: ComponentRenderer;
|
|
289
|
+
}): react_jsx_runtime0.JSX.Element | null;
|
|
290
|
+
//#endregion
|
|
291
|
+
//#region src/providers/kopai-provider.d.ts
|
|
292
|
+
type KopaiClient = Pick<KopaiClient$1, "searchTracesPage" | "searchLogsPage" | "searchMetricsPage" | "getTrace" | "discoverMetrics">;
|
|
293
|
+
interface KopaiSDKProviderProps {
|
|
294
|
+
client: KopaiClient;
|
|
295
|
+
children: ReactNode;
|
|
296
|
+
}
|
|
297
|
+
declare function KopaiSDKProvider({
|
|
298
|
+
client,
|
|
299
|
+
children
|
|
300
|
+
}: KopaiSDKProviderProps): react_jsx_runtime0.JSX.Element;
|
|
301
|
+
declare function useKopaiSDK(): KopaiClient;
|
|
302
|
+
//#endregion
|
|
303
|
+
export { type ComponentRenderProps, type ComponentRenderer, type KopaiClient, KopaiSDKProvider, ObservabilityPage, Renderer, type RendererComponentProps, createCatalog, createRendererFromCatalog, generatePromptInstructions, useKopaiSDK };
|
|
5
304
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/pages/observability.tsx","../src/lib/component-catalog.ts","../src/lib/generate-prompt-instructions.ts","../src/lib/renderer.tsx","../src/providers/kopai-provider.tsx"],"mappings":";;;;;;;iBA0uBwB,iBAAA,CAAA,GAAiB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;cCruB5B,gBAAA,EAAgB,CAAA,CAAA,qBAAA,EAAA,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA8BhB,yBAAA,EAAyB,CAAA,CAAA,SAAA;;;;;KAqCjC,oBAAA,iCAEW,CAAA,CAAE,UAAA,IACd,CAAA,CAAE,SAAA;EACJ,GAAA,EAAK,CAAA,CAAE,SAAA;EACP,IAAA,EAAM,CAAA,CAAE,UAAA,CAAW,CAAA;EACnB,QAAA,EAAU,CAAA,CAAE,QAAA,CAAS,CAAA,CAAE,SAAA;EACvB,SAAA,EAAW,CAAA,CAAE,SAAA;EACb,UAAA,EAAY,CAAA,CAAE,WAAA,QAAmB,gBAAA;EACjC,KAAA,EAAO,KAAA;AAAA;AAAA,KAIJ,qBAAA,WAAgC,MAAA;EAAiB,KAAA;AAAA,oBACxC,CAAA,YAAa,oBAAA,CACvB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