@krak-stack/registry 0.10.17 → 0.10.19
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/CHANGELOG.md +12 -0
- package/dist/components/ui/copy-value.d.ts +4 -1
- package/dist/components/ui/copy-value.js +42 -9
- package/dist/services/opentelemetry/api.d.ts +4 -0
- package/dist/services/opentelemetry/api.js +14 -9
- package/dist/services/opentelemetry/browser.d.ts +3 -1
- package/dist/services/opentelemetry/browser.js +11 -3
- package/dist/services/opentelemetry/paths.d.ts +5 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @krak-stack/registry
|
|
2
2
|
|
|
3
|
+
## 0.10.19
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Add optional `showLabel` and `icon` props to `CopyValue` for a visible input label and a leading decorative icon.
|
|
8
|
+
|
|
9
|
+
## 0.10.18
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Default browser OpenTelemetry exports and ingestion to `/api/diagnostics/{events,spans,measurements}`. Collector endpoints are unchanged. Use explicit browser `urls` and server `HttpApiOtlp.layerWith` paths to keep a custom deployment or the old `/api/otel/v1/*` routes.
|
|
14
|
+
|
|
3
15
|
## 0.10.17
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type LucideIcon } from "lucide-react";
|
|
1
2
|
import { type CopyButtonMessageTranslations } from "./copy-button.js";
|
|
2
3
|
export type CopyValueMessages = {
|
|
3
4
|
show: string;
|
|
@@ -7,6 +8,8 @@ export type CopyValueMessages = {
|
|
|
7
8
|
export type CopyValueProps = {
|
|
8
9
|
value: string;
|
|
9
10
|
label: string;
|
|
11
|
+
showLabel?: boolean;
|
|
12
|
+
icon?: LucideIcon;
|
|
10
13
|
secret?: boolean;
|
|
11
14
|
variant?: "outline" | "ghost";
|
|
12
15
|
disabled?: boolean;
|
|
@@ -18,4 +21,4 @@ export type CopyValueProps = {
|
|
|
18
21
|
copyMessages?: CopyButtonMessageTranslations;
|
|
19
22
|
};
|
|
20
23
|
/** Masking is presentation, not a security boundary. Never logs the value. */
|
|
21
|
-
export declare const CopyValue: ({ value, label, secret, variant, disabled, copyable, autoHideDelay, className, locale: override, messages, copyMessages, }: CopyValueProps) => import("react").JSX.Element;
|
|
24
|
+
export declare const CopyValue: ({ value, label, showLabel, icon: Icon, secret, variant, disabled, copyable, autoHideDelay, className, locale: override, messages, copyMessages, }: CopyValueProps) => import("react").JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// ../../src/components/ui/copy-value.tsx
|
|
2
2
|
import { Eye, EyeOff } from "lucide-react";
|
|
3
|
-
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
3
|
+
import { useEffect as useEffect2, useId, useState as useState2 } from "react";
|
|
4
4
|
|
|
5
5
|
// ../../src/components/ui/input-group.tsx
|
|
6
6
|
import { cva as cva2 } from "class-variance-authority";
|
|
@@ -231,7 +231,20 @@ function CopyButton({
|
|
|
231
231
|
|
|
232
232
|
// ../../src/components/ui/copy-value.tsx
|
|
233
233
|
import { useKrakstackLocale as useKrakstackLocale2 } from "@krak-stack/registry/krakstack-provider";
|
|
234
|
-
|
|
234
|
+
|
|
235
|
+
// ../../src/components/ui/label.tsx
|
|
236
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
237
|
+
"use client";
|
|
238
|
+
function Label({ className, ...props }) {
|
|
239
|
+
return /* @__PURE__ */ jsx5("label", {
|
|
240
|
+
"data-slot": "label",
|
|
241
|
+
className: cn("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50", className),
|
|
242
|
+
...props
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// ../../src/components/ui/copy-value.tsx
|
|
247
|
+
import { jsx as jsx6, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
235
248
|
var labels = {
|
|
236
249
|
en: { show: "Show", hide: "Hide", hidden: "Hidden value" },
|
|
237
250
|
fr: { show: "Afficher", hide: "Masquer", hidden: "Valeur masquée" }
|
|
@@ -239,6 +252,8 @@ var labels = {
|
|
|
239
252
|
var CopyValue = ({
|
|
240
253
|
value,
|
|
241
254
|
label,
|
|
255
|
+
showLabel = false,
|
|
256
|
+
icon: Icon,
|
|
242
257
|
secret = false,
|
|
243
258
|
variant = "outline",
|
|
244
259
|
disabled,
|
|
@@ -249,6 +264,7 @@ var CopyValue = ({
|
|
|
249
264
|
messages,
|
|
250
265
|
copyMessages
|
|
251
266
|
}) => {
|
|
267
|
+
const inputId = useId();
|
|
252
268
|
const locale = useKrakstackLocale2(override);
|
|
253
269
|
const copy = {
|
|
254
270
|
...locale.startsWith("fr") ? labels.fr : labels.en,
|
|
@@ -268,12 +284,13 @@ var CopyValue = ({
|
|
|
268
284
|
const timer = setTimeout(() => setRevealedValue(null), autoHideDelay);
|
|
269
285
|
return () => clearTimeout(timer);
|
|
270
286
|
}, [revealed, autoHideDelay, value]);
|
|
271
|
-
|
|
287
|
+
const input = /* @__PURE__ */ jsxs2(InputGroup, {
|
|
272
288
|
className: cn("min-w-0", variant === "ghost" && "border-0 bg-transparent shadow-none dark:bg-transparent", className),
|
|
273
289
|
children: [
|
|
274
|
-
/* @__PURE__ */
|
|
290
|
+
/* @__PURE__ */ jsx6(InputGroupInput, {
|
|
291
|
+
id: showLabel ? inputId : undefined,
|
|
275
292
|
className: variant === "ghost" ? "pl-0 font-mono" : undefined,
|
|
276
|
-
"aria-label": secret && !revealed ? `${label}: ${copy.hidden}` : label,
|
|
293
|
+
"aria-label": secret && !revealed ? `${label}: ${copy.hidden}` : showLabel ? undefined : label,
|
|
277
294
|
value,
|
|
278
295
|
type: secret && !revealed ? "password" : "text",
|
|
279
296
|
autoComplete: secret ? "off" : undefined,
|
|
@@ -281,11 +298,17 @@ var CopyValue = ({
|
|
|
281
298
|
disabled,
|
|
282
299
|
onFocus: (event) => event.currentTarget.select()
|
|
283
300
|
}),
|
|
301
|
+
Icon && /* @__PURE__ */ jsx6(InputGroupAddon, {
|
|
302
|
+
align: "inline-start",
|
|
303
|
+
children: /* @__PURE__ */ jsx6(Icon, {
|
|
304
|
+
"aria-hidden": "true"
|
|
305
|
+
})
|
|
306
|
+
}),
|
|
284
307
|
/* @__PURE__ */ jsxs2(InputGroupAddon, {
|
|
285
308
|
align: "inline-end",
|
|
286
309
|
className: "gap-0",
|
|
287
310
|
children: [
|
|
288
|
-
secret ? /* @__PURE__ */
|
|
311
|
+
secret ? /* @__PURE__ */ jsx6(InputGroupButton, {
|
|
289
312
|
type: "button",
|
|
290
313
|
size: "icon-sm",
|
|
291
314
|
variant: "ghost",
|
|
@@ -293,13 +316,13 @@ var CopyValue = ({
|
|
|
293
316
|
"aria-label": `${revealed ? copy.hide : copy.show} ${label}`,
|
|
294
317
|
"aria-pressed": revealed,
|
|
295
318
|
onClick: () => setRevealedValue(revealed ? null : value),
|
|
296
|
-
children: revealed ? /* @__PURE__ */
|
|
319
|
+
children: revealed ? /* @__PURE__ */ jsx6(EyeOff, {
|
|
297
320
|
"aria-hidden": "true"
|
|
298
|
-
}) : /* @__PURE__ */
|
|
321
|
+
}) : /* @__PURE__ */ jsx6(Eye, {
|
|
299
322
|
"aria-hidden": "true"
|
|
300
323
|
})
|
|
301
324
|
}) : null,
|
|
302
|
-
copyable ? /* @__PURE__ */
|
|
325
|
+
copyable ? /* @__PURE__ */ jsx6(CopyButton, {
|
|
303
326
|
type: "button",
|
|
304
327
|
value,
|
|
305
328
|
valueDescription: label,
|
|
@@ -313,6 +336,16 @@ var CopyValue = ({
|
|
|
313
336
|
})
|
|
314
337
|
]
|
|
315
338
|
});
|
|
339
|
+
return showLabel ? /* @__PURE__ */ jsxs2("div", {
|
|
340
|
+
className: "flex min-w-0 flex-col gap-2",
|
|
341
|
+
children: [
|
|
342
|
+
/* @__PURE__ */ jsx6(Label, {
|
|
343
|
+
htmlFor: inputId,
|
|
344
|
+
children: label
|
|
345
|
+
}),
|
|
346
|
+
input
|
|
347
|
+
]
|
|
348
|
+
}) : input;
|
|
316
349
|
};
|
|
317
350
|
export {
|
|
318
351
|
CopyValue
|
|
@@ -2,6 +2,10 @@ import { Config, Layer } from "effect";
|
|
|
2
2
|
import { HttpRouter } from "effect/http";
|
|
3
3
|
import { Otlp } from "./index.js";
|
|
4
4
|
export { OtlpLogsProcessor, OtlpProcessingError } from "./processor.js";
|
|
5
|
+
type OtlpSignal = "traces" | "metrics" | "logs";
|
|
6
|
+
type OtlpPaths = Record<OtlpSignal, `/${string}`>;
|
|
5
7
|
export declare class HttpApiOtlp {
|
|
8
|
+
/** Override the browser-facing paths without changing the collector URLs. */
|
|
9
|
+
static readonly layerWith: (overrides: Partial<OtlpPaths>) => Layer.Layer<import("effect/FileSystem").FileSystem | import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/Path").Path, Config.ConfigError, HttpRouter.HttpRouter | Otlp>;
|
|
6
10
|
static readonly layer: Layer.Layer<import("effect/FileSystem").FileSystem | import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/Path").Path, Config.ConfigError, HttpRouter.HttpRouter | Otlp>;
|
|
7
11
|
}
|
|
@@ -194,6 +194,13 @@ class Otlp extends Context2.Service()("krakstack/opentelemetry/Otlp") {
|
|
|
194
194
|
static layer = Layer2.mergeAll(Layer2.succeed(this, { resource: OtlpResource2.fromConfig() }), ServerEventsLive).pipe(Layer2.provideMerge(EffectOtlp.layerFromConfig()), Layer2.provideMerge(OtlpExporter2.layerFlusher), Layer2.provide(OtlpSerialization2.layerJson), Layer2.provide(FetchHttpClient.layer));
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
+
// ../../src/services/opentelemetry/paths.ts
|
|
198
|
+
var defaultTelemetryPaths = {
|
|
199
|
+
logs: "/api/diagnostics/events",
|
|
200
|
+
traces: "/api/diagnostics/spans",
|
|
201
|
+
metrics: "/api/diagnostics/measurements"
|
|
202
|
+
};
|
|
203
|
+
|
|
197
204
|
// ../../src/services/opentelemetry/processor.ts
|
|
198
205
|
import { Context as Context3, Schema as Schema4 } from "effect";
|
|
199
206
|
|
|
@@ -206,11 +213,6 @@ class OtlpLogsProcessor extends Context3.Service()("krakstack/opentelemetry/Otlp
|
|
|
206
213
|
}
|
|
207
214
|
|
|
208
215
|
// ../../src/services/opentelemetry/api.ts
|
|
209
|
-
var otlpProxyPaths = [
|
|
210
|
-
"/api/otel/v1/traces",
|
|
211
|
-
"/api/otel/v1/metrics",
|
|
212
|
-
"/api/otel/v1/logs"
|
|
213
|
-
];
|
|
214
216
|
var exporterConfig = (signal) => Config2.Array(Schema5.String, `OTEL_${signal}_EXPORTER`).pipe(Config2.map((exporters) => exporters.map((exporter) => exporter.toLowerCase().trim())), Config2.withDefault([]));
|
|
215
217
|
var readProcessorBody = Effect4.fnUntraced(function* () {
|
|
216
218
|
const incoming = yield* HttpServerRequest.HttpServerRequest;
|
|
@@ -266,7 +268,7 @@ var proxyOtlp = (baseUrl, signal, processor) => Effect4.gen(function* () {
|
|
|
266
268
|
return yield* forward;
|
|
267
269
|
return yield* forward.pipe(Effect4.timeout("5 seconds"), Effect4.catch((error) => Effect4.logWarning("Collector delivery failed after analytics commit", error).pipe(Effect4.as(HttpServerResponse.jsonUnsafe({})))));
|
|
268
270
|
}).pipe(Effect4.withTracerEnabled(false), HttpMiddleware.withLoggerDisabled, Effect4.catchTag("OtlpProcessingError", (error) => Effect4.succeed(HttpServerResponse.empty({ status: error.status }))), Effect4.catch((error) => Effect4.logError("Failed to proxy browser telemetry", error).pipe(Effect4.as(HttpServerResponse.empty({ status: 502 })))), Effect4.provide(FetchHttpClient2.layer));
|
|
269
|
-
var otlpProxyLayer = Layer3.unwrap(Effect4.gen(function* () {
|
|
271
|
+
var otlpProxyLayer = (paths) => Layer3.unwrap(Effect4.gen(function* () {
|
|
270
272
|
yield* Otlp;
|
|
271
273
|
const baseUrl = yield* Config2.URL("OTEL_EXPORTER_OTLP_ENDPOINT");
|
|
272
274
|
const processor = yield* Effect4.serviceOption(OtlpLogsProcessor);
|
|
@@ -275,12 +277,15 @@ var otlpProxyLayer = Layer3.unwrap(Effect4.gen(function* () {
|
|
|
275
277
|
metrics: exporterConfig("METRICS"),
|
|
276
278
|
traces: exporterConfig("TRACES")
|
|
277
279
|
});
|
|
278
|
-
return Layer3.mergeAll(exporters.traces.includes("otlp") ? HttpRouter.add("POST",
|
|
280
|
+
return Layer3.mergeAll(exporters.traces.includes("otlp") ? HttpRouter.add("POST", paths.traces, proxyOtlp(baseUrl, "traces", processor)) : Layer3.empty, exporters.metrics.includes("otlp") ? HttpRouter.add("POST", paths.metrics, proxyOtlp(baseUrl, "metrics", processor)) : Layer3.empty, exporters.logs.includes("otlp") ? HttpRouter.add("POST", paths.logs, proxyOtlp(baseUrl, "logs", processor)) : Layer3.empty);
|
|
279
281
|
}));
|
|
280
|
-
var serverServices = HttpServer.layerServices.pipe(Layer3.provideMerge(HttpMiddleware.layerTracerDisabledForUrls(otlpProxyPaths)));
|
|
281
282
|
|
|
282
283
|
class HttpApiOtlp {
|
|
283
|
-
static
|
|
284
|
+
static layerWith = (overrides) => {
|
|
285
|
+
const paths = { ...defaultTelemetryPaths, ...overrides };
|
|
286
|
+
return Layer3.mergeAll(otlpProxyLayer(paths), HttpServer.layerServices.pipe(Layer3.provideMerge(HttpMiddleware.layerTracerDisabledForUrls(Object.values(paths)))));
|
|
287
|
+
};
|
|
288
|
+
static layer = HttpApiOtlp.layerWith({});
|
|
284
289
|
}
|
|
285
290
|
export {
|
|
286
291
|
HttpApiOtlp,
|
|
@@ -17,6 +17,8 @@ export interface BrowserOtlpOptions {
|
|
|
17
17
|
readonly serviceVersion?: string;
|
|
18
18
|
readonly attributes?: NonNullable<OtlpOptions["resource"]>["attributes"];
|
|
19
19
|
readonly baseUrl?: string;
|
|
20
|
+
/** Exact endpoints, overriding the URLs derived from baseUrl. Events use logs. */
|
|
21
|
+
readonly urls?: Partial<Record<"logs" | "metrics" | "traces", string>>;
|
|
20
22
|
readonly headers?: OtlpOptions["headers"];
|
|
21
23
|
readonly traces?: false | SignalOptions<Parameters<typeof OtlpTracer.layer>[0]>;
|
|
22
24
|
readonly metrics?: false | SignalOptions<Parameters<typeof OtlpMetrics.layer>[0]>;
|
|
@@ -37,5 +39,5 @@ export declare class BrowserOtlp {
|
|
|
37
39
|
readonly [x: string]: string | number | boolean | readonly string[] | readonly number[] | readonly boolean[];
|
|
38
40
|
} | undefined;
|
|
39
41
|
} | undefined) => Effect.Effect<void, Schema.SchemaError, OtlpEvents>;
|
|
40
|
-
static readonly layer: ({ attributes, baseUrl, logs, events, metrics, serviceName, serviceVersion, traces, headers, }: BrowserOtlpOptions) => Layer.Layer<OtlpExporter.Flusher | OtlpEvents, never, never>;
|
|
42
|
+
static readonly layer: ({ attributes, baseUrl, logs, events, metrics, serviceName, serviceVersion, traces, urls, headers, }: BrowserOtlpOptions) => Layer.Layer<OtlpExporter.Flusher | OtlpEvents, never, never>;
|
|
41
43
|
}
|
|
@@ -152,6 +152,13 @@ var event = Effect.fnUntraced(function* (name, properties, options) {
|
|
|
152
152
|
});
|
|
153
153
|
});
|
|
154
154
|
|
|
155
|
+
// ../../src/services/opentelemetry/paths.ts
|
|
156
|
+
var defaultTelemetryPaths = {
|
|
157
|
+
logs: "/api/diagnostics/events",
|
|
158
|
+
traces: "/api/diagnostics/spans",
|
|
159
|
+
metrics: "/api/diagnostics/measurements"
|
|
160
|
+
};
|
|
161
|
+
|
|
155
162
|
// ../../src/services/opentelemetry/browser.ts
|
|
156
163
|
class BrowserReportedError extends Schema3.TaggedError()("BrowserReportedError", {
|
|
157
164
|
type: Schema3.Literals(["window.error", "unhandledrejection"]),
|
|
@@ -226,19 +233,20 @@ class BrowserOtlp {
|
|
|
226
233
|
static event = event;
|
|
227
234
|
static layer = ({
|
|
228
235
|
attributes,
|
|
229
|
-
baseUrl
|
|
236
|
+
baseUrl,
|
|
230
237
|
logs = false,
|
|
231
238
|
events = {},
|
|
232
239
|
metrics = false,
|
|
233
240
|
serviceName,
|
|
234
241
|
serviceVersion,
|
|
235
242
|
traces = {},
|
|
243
|
+
urls,
|
|
236
244
|
headers
|
|
237
245
|
}) => {
|
|
238
246
|
const eventOptions = events === false ? undefined : events;
|
|
239
247
|
const resource = { attributes, serviceName, serviceVersion };
|
|
240
|
-
const request = HttpClientRequest.get(baseUrl);
|
|
241
|
-
const signalUrl = (signal) => HttpClientRequest.appendUrl(request, `/v1/${signal}`).url;
|
|
248
|
+
const request = baseUrl === undefined ? undefined : HttpClientRequest.get(baseUrl);
|
|
249
|
+
const signalUrl = (signal) => urls?.[signal] ?? (request ? HttpClientRequest.appendUrl(request, `/v1/${signal}`).url : defaultTelemetryPaths[signal]);
|
|
242
250
|
const exporters = Layer2.mergeAll(events !== false ? OtlpEvents.layer({
|
|
243
251
|
exportInterval: "30 seconds",
|
|
244
252
|
maxBatchSize: 100,
|