@krak-stack/registry 0.1.50 → 0.1.51
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 +16 -0
- package/README.md +16 -424
- package/dist/lib/docs.js +2 -2
- package/dist/services/agent/client/index.js +1 -1
- package/dist/services/events/browser.d.ts +26 -0
- package/dist/services/events/browser.js +423 -0
- package/dist/services/events/index.d.ts +82 -0
- package/dist/services/events/index.js +798 -0
- package/dist/services/events/migrations.d.ts +4 -0
- package/dist/services/events/migrations.js +42 -0
- package/dist/services/events/request-context.d.ts +6 -0
- package/dist/services/events/schema.d.ts +196 -0
- package/dist/services/opentelemetry/api.d.ts +3 -1
- package/dist/services/opentelemetry/api.js +133 -64
- package/dist/services/opentelemetry/browser.d.ts +17 -20
- package/dist/services/opentelemetry/browser.js +58 -162
- package/dist/services/opentelemetry/events.d.ts +3 -1
- package/dist/services/opentelemetry/{server.d.ts → index.d.ts} +8 -5
- package/dist/services/opentelemetry/{server.js → index.js} +66 -48
- package/dist/services/opentelemetry/processor.d.ts +19 -0
- package/dist/services/opentelemetry/schema.d.ts +8 -20
- package/dist/services/opentelemetry/web-vitals.d.ts +15 -0
- package/dist/services/opentelemetry/web-vitals.js +229 -0
- package/package.json +23 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @krak-stack/registry
|
|
2
2
|
|
|
3
|
+
## 0.1.51
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0e67ce7: Add application events, server audit recording, and cookieless browser analytics through the OTLP/HTTP JSON logs endpoint.
|
|
8
|
+
- Install: `service-events`, or the `@krak-stack/registry/events`, `/events/browser`, and `/events/migrations` exports.
|
|
9
|
+
- Default OTLP: forward analytics to your telemetry backend; use `Otlp.event` for server telemetry.
|
|
10
|
+
- Optional SQL: PostgreSQL/SQLite persistence for in-app queries, visit timelines, and transactional audit records. `Events.track` requires SQL and supports verified actor context.
|
|
11
|
+
- Browser: `BrowserEvents` provides event/page tracking, automatic SPA views, DNT/GPC support, and path sanitization.
|
|
12
|
+
- Enrichment: trusted Cloudflare/custom geolocation and daily visitor IDs, without browser storage or automatic raw IP storage.
|
|
13
|
+
- Web Vitals: a separate `BrowserWebVitals` layer reuses the browser event exporter, respects DNT/GPC, and keeps `web-vitals` out of base browser imports.
|
|
14
|
+
- Dependencies: Bowser and Web Vitals are regular package dependencies, so package consumers do not need to declare them separately.
|
|
15
|
+
- Composition: `BrowserEvents` and `BrowserWebVitals` consume `BrowserOtlp`; server-side `Events` and `HttpApiOtlp` consume `Otlp`. Browser event export is enabled by default, batching is shared, and `Events.ingestionLayer` connects HTTP ingestion to application recording.
|
|
16
|
+
|
|
17
|
+
SQL is authoritative for persisted events; collector forwarding is best effort. Audit classification provides an application audit trail, not immutable archival storage or a compliance guarantee.
|
|
18
|
+
|
|
3
19
|
## 0.1.50
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,449 +1,41 @@
|
|
|
1
1
|
# @krak-stack/registry
|
|
2
2
|
|
|
3
|
-
Tree-shakable
|
|
3
|
+
Tree-shakable components and Effect services from the KrakStack registry.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
4
6
|
|
|
5
7
|
```bash
|
|
6
8
|
bun add @krak-stack/registry
|
|
7
9
|
```
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
Applications using Effect forms need `@lucas-barake/effect-form@1.1.0` and
|
|
12
|
-
`@lucas-barake/effect-form-react@1.1.0`, which support stable Effect 4 without
|
|
13
|
-
compatibility patches:
|
|
14
|
-
|
|
15
|
-
```sh
|
|
16
|
-
bun add @lucas-barake/effect-form@1.1.0 @lucas-barake/effect-form-react@1.1.0
|
|
17
|
-
```
|
|
11
|
+
Install the peer dependencies required by the items you use. Each item's registry documentation lists its dependencies and setup.
|
|
18
12
|
|
|
19
|
-
|
|
20
|
-
entries and patch files, update any form version overrides to `1.1.0`, and run
|
|
21
|
-
`bun install`. Preserve unrelated dependency patches.
|
|
13
|
+
## Use
|
|
22
14
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
Import only the subpaths used by the application:
|
|
15
|
+
Import from the specific package subpaths you need:
|
|
26
16
|
|
|
27
17
|
```tsx
|
|
28
18
|
import { DataTable } from "@krak-stack/registry/data-table";
|
|
29
|
-
import {
|
|
30
|
-
import { AgentService } from "@krak-stack/registry/agent";
|
|
31
|
-
import { AgentWidget, makeAgentAtoms } from "@krak-stack/registry/agent/client";
|
|
32
|
-
import { makeAgentApiGroup } from "@krak-stack/registry/agent/schema";
|
|
33
|
-
import { makeHttpApiToolkit } from "@krak-stack/registry/httpapi/toolkit";
|
|
34
|
-
import { makeHttpApiCli } from "@krak-stack/registry/httpapi/cli";
|
|
35
|
-
import { HttpApiAdapter } from "@krak-stack/registry/httpapi/adapter";
|
|
36
|
-
import { HttpApiOtlp } from "@krak-stack/registry/opentelemetry/api";
|
|
19
|
+
import { Otlp } from "@krak-stack/registry/opentelemetry";
|
|
37
20
|
import { BrowserOtlp } from "@krak-stack/registry/opentelemetry/browser";
|
|
38
|
-
import { createDocsSource, makeDocs } from "@krak-stack/registry/docs";
|
|
39
|
-
import { loadMdxDocsDirectory } from "@krak-stack/registry/docs/server";
|
|
40
|
-
import {
|
|
41
|
-
DocumentationToolkit,
|
|
42
|
-
DocumentationToolkitLayer,
|
|
43
|
-
} from "@krak-stack/registry/documentation-toolkit";
|
|
44
|
-
import {
|
|
45
|
-
WebFetchToolkit,
|
|
46
|
-
WebFetchToolkitLayer,
|
|
47
|
-
} from "@krak-stack/registry/webfetch-toolkit";
|
|
48
|
-
import { Query } from "@krak-stack/registry/query";
|
|
49
|
-
import { createSeo } from "@krak-stack/registry/seo";
|
|
50
|
-
import { FileExtractionService } from "@krak-stack/registry/service-file-extraction";
|
|
51
|
-
import { FileExtractedTextSchema } from "@krak-stack/registry/service-file-extraction/schema";
|
|
52
|
-
import {
|
|
53
|
-
HealthApiGroup,
|
|
54
|
-
healthHandler,
|
|
55
|
-
HealthService,
|
|
56
|
-
} from "@krak-stack/registry/service-health";
|
|
57
|
-
import { NotificationService } from "@krak-stack/registry/service-notification";
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
## OpenTelemetry
|
|
61
|
-
|
|
62
|
-
| Export | Purpose |
|
|
63
|
-
| --------------------------------------------------------- | --------------------------------------------------------------------------------------- |
|
|
64
|
-
| `HttpApiOtlp.layer` from `opentelemetry/api` | Server exporters and same-origin browser ingestion routes. Includes `ServerOtlp.layer`. |
|
|
65
|
-
| `ServerOtlp.layer` from `opentelemetry/server` | Exporters for workers, workflows, and CLIs without an HTTP server. |
|
|
66
|
-
| `BrowserOtlp.layer(options)` from `opentelemetry/browser` | Browser tracing and optional events, logs, and metrics. |
|
|
67
|
-
|
|
68
|
-
### Setup
|
|
69
|
-
|
|
70
|
-
Provide the HTTP layer once at the application composition root:
|
|
71
|
-
|
|
72
|
-
```ts
|
|
73
|
-
import { Layer } from "effect";
|
|
74
|
-
import { HttpApiOtlp } from "@krak-stack/registry/opentelemetry/api";
|
|
75
|
-
|
|
76
|
-
const appLayer = appRoutes.pipe(Layer.provideMerge(HttpApiOtlp.layer));
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
Configure an OTLP/HTTP collector on the server:
|
|
80
|
-
|
|
81
|
-
```dotenv
|
|
82
|
-
OTEL_SERVICE_NAME=my-app-api
|
|
83
|
-
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
|
|
84
|
-
OTEL_TRACES_EXPORTER=otlp
|
|
85
|
-
OTEL_METRICS_EXPORTER=otlp
|
|
86
|
-
OTEL_LOGS_EXPORTER=otlp
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
Browser events require the logs signal. The proxy forwards enabled signals from
|
|
90
|
-
`/api/otel/v1/{traces,metrics,logs}` to the collector. Keep collector credentials
|
|
91
|
-
server-side. Server log endpoint/header overrides use
|
|
92
|
-
`OTEL_EXPORTER_OTLP_LOGS_ENDPOINT` / `OTEL_EXPORTER_OTLP_LOGS_HEADERS`, falling
|
|
93
|
-
back to the shared endpoint/headers; these overrides do not change proxy routing.
|
|
94
|
-
`OTEL_SDK_DISABLED=true` disables server export, not browser collection.
|
|
95
|
-
|
|
96
|
-
Install one browser layer on the Atom context passed to `AtomHttpApi.Service`:
|
|
97
|
-
|
|
98
|
-
```ts
|
|
99
|
-
import { Atom } from "effect/reactivity";
|
|
100
|
-
import { BrowserOtlp } from "@krak-stack/registry/opentelemetry/browser";
|
|
101
|
-
|
|
102
|
-
const apiRuntime = Atom.context();
|
|
103
|
-
if (!import.meta.env.SSR) {
|
|
104
|
-
apiRuntime.addGlobalLayer(
|
|
105
|
-
BrowserOtlp.layer({ serviceName: "my-app-web", events: {} }),
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
Mount/read `ApiClient.runtime` in the root layout to start it. Browser methods
|
|
111
|
-
target the active layer even when run from another Effect runtime. Calls before
|
|
112
|
-
startup or after disposal are no-ops, not buffered. Dispose long-lived server and
|
|
113
|
-
browser runtimes on shutdown to flush pending data.
|
|
114
|
-
|
|
115
|
-
### Browser API
|
|
116
|
-
|
|
117
|
-
All methods return Effects. Use `yield*` inside Effect code or
|
|
118
|
-
`Effect.runPromise(...)` / `Effect.runFork(...)` from application callbacks.
|
|
119
|
-
|
|
120
|
-
| Method | Behavior |
|
|
121
|
-
| ---------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
|
|
122
|
-
| `identify({ userId?, organizationId? })` | Replace identity for future events; omitted fields clear old values. Emits no event. |
|
|
123
|
-
| `identify(null)` | Clear identity, for example on logout. |
|
|
124
|
-
| `track(name, properties?, options?)` | Record a named event. |
|
|
125
|
-
| `page(options?)` | Record `browser.page_view`. Accepts `path`, `name`, `category`, `properties`, and event `options`. `pageView` is an alias. |
|
|
126
|
-
|
|
127
|
-
`identify` has no typed failure: invalid input warns without including supplied
|
|
128
|
-
values and leaves identity unchanged. `track` and `page` fail with an Effect
|
|
129
|
-
schema error on invalid input. Identity is in memory only, applies to events
|
|
130
|
-
rather than automatic traces/logs, and never rewrites queued events.
|
|
131
|
-
|
|
132
|
-
### Auth example
|
|
133
|
-
|
|
134
|
-
Mount this once under the application's Atom registry. `ApiClient` and
|
|
135
|
-
`authSessionAtom` are application-owned; the telemetry package has no auth
|
|
136
|
-
dependency. The session atom in this example exposes KrakStack Auth session data.
|
|
137
|
-
|
|
138
|
-
```tsx
|
|
139
|
-
import { useAtomSubscribe, useAtomValue } from "@effect/atom-react";
|
|
140
|
-
import { BrowserOtlp } from "@krak-stack/registry/opentelemetry/browser";
|
|
141
|
-
import { Effect } from "effect";
|
|
142
|
-
import { AsyncResult } from "effect/reactivity";
|
|
143
|
-
import { ApiClient } from "@/lib/api-client";
|
|
144
|
-
import { authSessionAtom } from "@/services/auth/client";
|
|
145
|
-
|
|
146
|
-
export const AuthTelemetry = () => {
|
|
147
|
-
const runtime = useAtomValue(ApiClient.runtime);
|
|
148
|
-
|
|
149
|
-
useAtomSubscribe(
|
|
150
|
-
authSessionAtom,
|
|
151
|
-
(session) => {
|
|
152
|
-
if (!AsyncResult.isSuccess(runtime)) return;
|
|
153
|
-
|
|
154
|
-
Effect.runFork(
|
|
155
|
-
BrowserOtlp.identify(
|
|
156
|
-
AsyncResult.isSuccess(session) && !session.waiting && session.value
|
|
157
|
-
? {
|
|
158
|
-
userId: session.value.user.id,
|
|
159
|
-
organizationId:
|
|
160
|
-
session.value.session.activeOrganizationId ?? undefined,
|
|
161
|
-
}
|
|
162
|
-
: null,
|
|
163
|
-
),
|
|
164
|
-
);
|
|
165
|
-
},
|
|
166
|
-
{ immediate: true },
|
|
167
|
-
);
|
|
168
|
-
|
|
169
|
-
return null;
|
|
170
|
-
};
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
This identifies after startup and clears identity during auth loading, failure,
|
|
174
|
-
and logout. The first page view may be anonymous. For other auth libraries, pass
|
|
175
|
-
the same two IDs or `null` when auth state changes. Apply your own consent policy;
|
|
176
|
-
do not send names, emails, or session tokens as identity.
|
|
177
|
-
|
|
178
|
-
### Page views and browser options
|
|
179
|
-
|
|
180
|
-
`events: {}` enables custom events and one page view on startup, then on pathname
|
|
181
|
-
changes through `pushState`, `replaceState`, and back/forward navigation.
|
|
182
|
-
Same-path and query/hash-only changes are ignored. Tracking follows URL changes,
|
|
183
|
-
not loader completion. Paths exclude query strings/fragments but may still
|
|
184
|
-
contain personal IDs.
|
|
185
|
-
|
|
186
|
-
For sanitized route templates or custom timing, use
|
|
187
|
-
`events: { pageViews: false }` and call `page({ path: "/orders/:id" })` manually.
|
|
188
|
-
Do not combine automatic and manual tracking for the same view.
|
|
189
|
-
|
|
190
|
-
| Layer option | Default |
|
|
191
|
-
| ----------------------------------------- | --------------------------------------------------------------- |
|
|
192
|
-
| `serviceName` | Required |
|
|
193
|
-
| `traces` | `{}`; includes global exception capture. `false` disables both. |
|
|
194
|
-
| `events`, `logs`, `metrics` | `false`; enable each independently with `{}`. |
|
|
195
|
-
| `baseUrl` | `/api/otel` |
|
|
196
|
-
| `serviceVersion`, `attributes`, `headers` | Optional resource/transport metadata. |
|
|
197
|
-
|
|
198
|
-
Browser events batch every 30 seconds, up to 100 records by default. Override
|
|
199
|
-
`exportInterval`, `maxBatchSize`, and `shutdownTimeout` under `events`.
|
|
200
|
-
|
|
201
|
-
### Server events and shared options
|
|
202
|
-
|
|
203
|
-
Define server events as Effects and run them inside the runtime with
|
|
204
|
-
`ServerOtlp.layer` (or the HTTP layer):
|
|
205
|
-
|
|
206
|
-
```ts
|
|
207
|
-
import { Effect } from "effect";
|
|
208
|
-
import { ServerOtlp } from "@krak-stack/registry/opentelemetry/server";
|
|
209
|
-
|
|
210
|
-
const orderCompleted = Effect.gen(function* () {
|
|
211
|
-
yield* ServerOtlp.track("app.order.completed", { "order.total": 49 });
|
|
212
|
-
});
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
Authenticated handlers inherit `user.id` and `organization.id` from
|
|
216
|
-
`AuthMiddleware` log annotations. Server identity is fiber-scoped; there is no
|
|
217
|
-
server `identify` method. Background jobs can supply identity per event.
|
|
218
|
-
|
|
219
|
-
Both `track` methods accept `options`:
|
|
220
|
-
|
|
221
|
-
| Option | OTLP attribute / meaning |
|
|
222
|
-
| ------------------------------------------------- | ------------------------------------------------------------------- |
|
|
223
|
-
| `userId`, `anonymousId`, `sessionId`, `messageId` | `user.id`, `analytics.anonymous_id`, `session.id`, `log.record.uid` |
|
|
224
|
-
| `context` | Additional flat attributes |
|
|
225
|
-
| `timestamp` | Effect `DateTime.Utc` occurrence time; otherwise recorded now |
|
|
226
|
-
|
|
227
|
-
Attribute precedence, lowest to highest: context, properties, explicit identity
|
|
228
|
-
options, browser identified identity, scoped log annotations. Values support
|
|
229
|
-
strings, finite numbers, booleans, and homogeneous arrays, not nested objects.
|
|
230
|
-
Use stable event names and put dynamic values in attributes. Message IDs support
|
|
231
|
-
correlation, not guaranteed deduplication.
|
|
232
|
-
|
|
233
|
-
Events are OTLP log records with `eventName`, INFO severity, and active trace/span
|
|
234
|
-
IDs when available; they do not create spans. `browser.page_view`, `url.path`,
|
|
235
|
-
`analytics.page.name`, and `analytics.page.category` describe page events; the
|
|
236
|
-
analytics names are project conventions, not standardized OTel semantics.
|
|
237
|
-
|
|
238
|
-
Configure collector/storage separately. Browser identity is untrusted analytics
|
|
239
|
-
metadata, not authorization or an audit trail. No visitor/session IDs or cookies
|
|
240
|
-
are generated. Browser flushing on hidden/pagehide is best-effort. Apply payload
|
|
241
|
-
and rate limits at ingestion, and keep sensitive data out of events and
|
|
242
|
-
high-cardinality fields out of Loki labels.
|
|
243
|
-
|
|
244
|
-
## Other services
|
|
245
|
-
|
|
246
|
-
`@krak-stack/registry/service-notification` is the source-compatible direct
|
|
247
|
-
dispatcher. Use the separate `@krak-stack/notifications` package for a durable
|
|
248
|
-
inbox, package-owned migrations, persisted delivery jobs, retries, workers, and
|
|
249
|
-
one-shot reminders.
|
|
250
|
-
|
|
251
|
-
Create a configured SEO helper once with site-wide defaults, then use it for each page:
|
|
252
|
-
|
|
253
|
-
```tsx
|
|
254
|
-
const siteSeo = createSeo({
|
|
255
|
-
origin: "https://krakstack.net",
|
|
256
|
-
locales: ["en", "fr"],
|
|
257
|
-
siteName: "KrakStack",
|
|
258
|
-
sameAs: ["https://github.com/krakcons/krakstack"],
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
<Route
|
|
262
|
-
head={() =>
|
|
263
|
-
siteSeo({
|
|
264
|
-
title: "KrakStack",
|
|
265
|
-
description: "Production-ready building blocks for TanStack apps.",
|
|
266
|
-
locale: "en",
|
|
267
|
-
})
|
|
268
|
-
}
|
|
269
|
-
/>;
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
The returned object contains `meta`, `links`, and derived JSON-LD `scripts`. Website pages receive `WebSite` and `Organization` data; documentation pages can pass `type: "article"` for `Article` data. Use the lower-level `seo` function directly when a configured factory is not useful.
|
|
273
|
-
|
|
274
|
-
HTTP API adapter, AI tool, and CLI utilities are available under
|
|
275
|
-
the `@krak-stack/registry/httpapi/*` subpaths. Keep application-specific API
|
|
276
|
-
layers, handlers, authentication, and client bindings in the application.
|
|
277
|
-
|
|
278
|
-
Use `@krak-stack/registry/httpapi/toolkit` for HTTP API tools.
|
|
279
|
-
|
|
280
|
-
### HTTP API tools and MCP
|
|
281
|
-
|
|
282
|
-
Static toolkits keep definitions and implementations separate:
|
|
283
|
-
`DocumentationToolkit` / `DocumentationToolkitLayer({ docs, locale })` and
|
|
284
|
-
`WebFetchToolkit` / `WebFetchToolkitLayer(options?)`. Merge the definitions with
|
|
285
|
-
`Toolkit.merge`, then provide their handler layers. Web-fetch options are
|
|
286
|
-
validated during layer acquisition through the Effect error channel.
|
|
287
|
-
|
|
288
|
-
HTTP API tools are generated dynamically, so `makeHttpApiToolkit()` returns
|
|
289
|
-
matching definitions and handlers together.
|
|
290
|
-
|
|
291
|
-
CLI, toolkit, and MCP registration share `HttpApiAdapter.operations`. Each operation
|
|
292
|
-
contains its tool name, typed `inputSchema`, derived `inputJsonSchema`, and method
|
|
293
|
-
annotations. Inputs use `{ params, query, headers, body }`; only the CLI turns
|
|
294
|
-
terminal arguments into that shape. The generated HTTP client handles wire
|
|
295
|
-
encoding, and payload codecs retain their transformations.
|
|
296
|
-
|
|
297
|
-
Use `makeHttpApiToolkit(config)` to construct matching tools and handlers once:
|
|
298
|
-
|
|
299
|
-
```ts
|
|
300
|
-
import { makeHttpApiToolkit } from "@krak-stack/registry/httpapi/toolkit";
|
|
301
|
-
|
|
302
|
-
const { toolkit, handlers } = yield * makeHttpApiToolkit();
|
|
303
|
-
const tools = yield * toolkit.pipe(Effect.provide(handlers));
|
|
304
|
-
```
|
|
305
|
-
|
|
306
|
-
Provide one `HttpApiAdapter` layer through the surrounding Effect layers:
|
|
307
|
-
|
|
308
|
-
```ts
|
|
309
|
-
const adapterLayer = HttpApiAdapter.layer({
|
|
310
|
-
api: AppApi,
|
|
311
|
-
baseUrl: "https://example.com",
|
|
312
|
-
methods: ["get"],
|
|
313
|
-
}).pipe(Layer.provide(FetchHttpClient.layer));
|
|
314
21
|
```
|
|
315
22
|
|
|
316
|
-
|
|
317
|
-
input/success codecs, execution client, and result encoder all use the same API.
|
|
318
|
-
Import from `@krak-stack/registry/httpapi/adapter`, or install
|
|
319
|
-
`@krak-stack/httpapi-adapter` with shadcn. The old client/helper package subpaths
|
|
320
|
-
and client registry item have been removed.
|
|
321
|
-
Configuration is optional. Construct once and use the returned pair for agents
|
|
322
|
-
or MCP; the separate `HttpApiToolkit` and `HttpApiToolkitLayer` factories have
|
|
323
|
-
been removed.
|
|
324
|
-
|
|
325
|
-
For CLI commands, `makeHttpApiCli()` returns `{ command, run }`. Provide the same
|
|
326
|
-
`HttpApiAdapter` layer and supply the platform CLI services when
|
|
327
|
-
running commands. `run` derives the CLI version from the API metadata:
|
|
328
|
-
|
|
329
|
-
```ts
|
|
330
|
-
const { command, run } = yield * makeHttpApiCli();
|
|
331
|
-
yield * run(args);
|
|
332
|
-
```
|
|
333
|
-
|
|
334
|
-
`makeHttpApiCli` is the only public CLI export. `HttpApiCli`, its layer, and the
|
|
335
|
-
custom runners have been removed. Process arguments, platform services, error
|
|
336
|
-
reporting, and exit handling belong to the application's Effect runtime:
|
|
337
|
-
|
|
338
|
-
```ts
|
|
339
|
-
import { NodeRuntime, NodeServices } from "@effect/platform-node";
|
|
340
|
-
|
|
341
|
-
Effect.gen(function* () {
|
|
342
|
-
const { run } = yield* makeHttpApiCli();
|
|
343
|
-
yield* run(process.argv.slice(2));
|
|
344
|
-
}).pipe(
|
|
345
|
-
Effect.provide(adapterLayer),
|
|
346
|
-
Effect.provide(NodeServices.layer),
|
|
347
|
-
NodeRuntime.runMain,
|
|
348
|
-
);
|
|
349
|
-
```
|
|
350
|
-
|
|
351
|
-
Install `@effect/platform-node` matching your Effect version for this example;
|
|
352
|
-
`adapterLayer` supplies the application's `HttpApiAdapter`.
|
|
353
|
-
|
|
354
|
-
For an HTTP MCP server, register the toolkit directly with Effect. Keep the
|
|
355
|
-
transport and server identity in the application:
|
|
356
|
-
|
|
357
|
-
```ts
|
|
358
|
-
import { Effect, Layer } from "effect";
|
|
359
|
-
import { McpProtocol, McpServer } from "effect/ai";
|
|
360
|
-
import { FetchHttpClient } from "effect/http";
|
|
361
|
-
import { HttpApiAdapter } from "@krak-stack/registry/httpapi/adapter";
|
|
362
|
-
import { makeHttpApiToolkit } from "@krak-stack/registry/httpapi/toolkit";
|
|
363
|
-
import { AppApi } from "@/api";
|
|
364
|
-
|
|
365
|
-
export const mcpLayer = Layer.effectDiscard(
|
|
366
|
-
Effect.gen(function* () {
|
|
367
|
-
const { toolkit, handlers } = yield* makeHttpApiToolkit({});
|
|
368
|
-
yield* McpServer.registerToolkit(toolkit).pipe(Effect.provide(handlers));
|
|
369
|
-
}),
|
|
370
|
-
).pipe(
|
|
371
|
-
Layer.provideMerge(
|
|
372
|
-
McpServer.layerHttp({
|
|
373
|
-
name: "app",
|
|
374
|
-
version: "1.0.0",
|
|
375
|
-
path: "/api/mcp",
|
|
376
|
-
protocols: [McpProtocol.v2025_11_25],
|
|
377
|
-
}),
|
|
378
|
-
),
|
|
379
|
-
Layer.provide(
|
|
380
|
-
HttpApiAdapter.layer({
|
|
381
|
-
api: AppApi,
|
|
382
|
-
baseUrl: "http://localhost:3000",
|
|
383
|
-
methods: ["get"],
|
|
384
|
-
}),
|
|
385
|
-
),
|
|
386
|
-
Layer.provide(FetchHttpClient.layer),
|
|
387
|
-
);
|
|
388
|
-
```
|
|
389
|
-
|
|
390
|
-
This example explicitly selects GET operations; `HttpApiAdapter` otherwise includes
|
|
391
|
-
all supported methods. Use `include` to narrow exposure further. Supply an
|
|
392
|
-
authenticated `HttpClient` instead of `FetchHttpClient.layer` when the downstream
|
|
393
|
-
API requires credentials. Inbound MCP authentication and authorization remain
|
|
394
|
-
application-owned; tool annotations are not access controls.
|
|
395
|
-
|
|
396
|
-
If intentionally exposing writes, enforce authorization or confirmation in the
|
|
397
|
-
application before opting out of agent approval with `needsApproval: () => false`.
|
|
398
|
-
Approval requirements are no longer silently disabled by an MCP adapter.
|
|
399
|
-
|
|
400
|
-
The `HttpApiMcp` service, `@krak-stack/registry/httpapi/mcp` export, and
|
|
401
|
-
`@krak-stack/httpapi-mcp` registry item have been removed. Replace them with the
|
|
402
|
-
composition above. Any Effect toolkit can be registered this way; it does not
|
|
403
|
-
need to originate from an HttpApi.
|
|
404
|
-
|
|
405
|
-
Documentation consumers load and compile their application-owned MDX on the
|
|
406
|
-
server, then pass the validated page records to `createDocsSource` and
|
|
407
|
-
`makeDocs`:
|
|
408
|
-
|
|
409
|
-
```ts
|
|
410
|
-
const pages = await loadMdxDocsDirectory("src/content/docs");
|
|
411
|
-
const source = createDocsSource({ pages, locales: ["en", "fr"] });
|
|
412
|
-
```
|
|
413
|
-
|
|
414
|
-
The `@krak-stack/registry/docs/server` export requires the Bun runtime. Keep it
|
|
415
|
-
behind a server-only module or server function so it is not included in browser
|
|
416
|
-
bundles.
|
|
417
|
-
|
|
418
|
-
Add the package's Tailwind source to the application stylesheet:
|
|
23
|
+
For packaged UI components, include the Tailwind source in your application stylesheet:
|
|
419
24
|
|
|
420
25
|
```css
|
|
421
26
|
@import "@krak-stack/registry/tailwind.css";
|
|
422
27
|
```
|
|
423
28
|
|
|
424
|
-
|
|
29
|
+
To install editable source instead of importing the package, use the shadcn registry:
|
|
425
30
|
|
|
426
31
|
```bash
|
|
427
|
-
bunx shadcn@latest add
|
|
32
|
+
bunx shadcn@latest add https://krakstack.net/r/data-table.json
|
|
428
33
|
```
|
|
429
34
|
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
## Oxlint Plugin
|
|
433
|
-
|
|
434
|
-
Projects that prefer centrally versioned rules can load the compiled anti-slop
|
|
435
|
-
plugin directly from the package:
|
|
436
|
-
|
|
437
|
-
```json
|
|
438
|
-
{
|
|
439
|
-
"jsPlugins": [
|
|
440
|
-
{
|
|
441
|
-
"name": "anti-slop",
|
|
442
|
-
"specifier": "@krak-stack/registry/oxlint/anti-slop"
|
|
443
|
-
}
|
|
444
|
-
]
|
|
445
|
-
}
|
|
446
|
-
```
|
|
35
|
+
## Find components and documentation
|
|
447
36
|
|
|
448
|
-
|
|
449
|
-
|
|
37
|
+
- [KrakStack registry and docs](https://krakstack.net): browse items, dependencies, setup and usage.
|
|
38
|
+
- [Package exports](./package.json): available import subpaths.
|
|
39
|
+
- [Registry definitions](../../registry.json): item names, source files and documentation.
|
|
40
|
+
- [Source code](https://github.com/krakcons/krakstack): implementations and examples.
|
|
41
|
+
- [Changelog](./CHANGELOG.md): package releases.
|
package/dist/lib/docs.js
CHANGED
|
@@ -410,7 +410,7 @@ var MarkdownContent = ({
|
|
|
410
410
|
dangerouslySetInnerHTML: { __html: remainingHtml }
|
|
411
411
|
}, "html-final"));
|
|
412
412
|
return /* @__PURE__ */ jsx5("div", {
|
|
413
|
-
className: cn("[&_a:hover]:text-primary [&_a]:decoration-border [&_blockquote]:border-primary/40 [&_blockquote]:bg-muted/40 [&_h2_a]:text-muted-foreground [&_h3_a]:text-muted-foreground [&_[data-inline-code]]:bg-muted text-[0.98rem] leading-7 [&_[data-markdown-table]]:overflow-x-auto [&_[data-inline-code]]:rounded [&_[data-inline-code]]:px-1.5 [&_[data-inline-code]]:py-0.5 [&_[data-inline-code]]:font-mono [&_[data-inline-code]]:text-[0.875em] [&_a]:font-medium [&_a]:underline [&_a]:decoration-1 [&_a]:underline-offset-4 [&_a]:transition-colors [&_blockquote]:my-5 [&_blockquote]:rounded-r-lg [&_blockquote]:border-l-4 [&_blockquote]:px-5 [&_blockquote]:py-1 [&_h2]:mt-12 [&_h2]:scroll-mt-20 [&_h2]:border-t [&_h2]:pt-8 [&_h2]:text-2xl [&_h2]:font-bold [&_h2]:tracking-tight [&_h2_a]:ml-2 [&_h2_a]:no-underline [&_h2:first-of-type]:mt-0 [&_h2:first-of-type]:border-t-0 [&_h2:first-of-type]:pt-0 [&_h3]:mt-8 [&_h3]:scroll-mt-20 [&_h3]:text-xl [&_h3]:font-semibold [&_h3]:tracking-tight [&_h3_a]:ml-2 [&_h3_a]:no-underline [&_ol]:my-5 [&_p]:my-5 [&_table]:w-full [&_table]:text-sm [&_td]:border-b [&_td]:p-2 [&_th]:border-b [&_th]:p-2 [&_th]:text-left [&_ul]:my-5", className),
|
|
413
|
+
className: cn("[&_a:hover]:text-primary [&_a]:decoration-border [&_blockquote]:border-primary/40 [&_blockquote]:bg-muted/40 [&_h2_a]:text-muted-foreground [&_h3_a]:text-muted-foreground [&_[data-inline-code]]:bg-muted text-[0.98rem] leading-7 [&_[data-markdown-table]]:overflow-x-auto [&_[data-inline-code]]:rounded [&_[data-inline-code]]:px-1.5 [&_[data-inline-code]]:py-0.5 [&_[data-inline-code]]:font-mono [&_[data-inline-code]]:text-[0.875em] [&_a]:font-medium [&_a]:underline [&_a]:decoration-1 [&_a]:underline-offset-4 [&_a]:transition-colors [&_blockquote]:my-5 [&_blockquote]:rounded-r-lg [&_blockquote]:border-l-4 [&_blockquote]:px-5 [&_blockquote]:py-1 [&_h2]:mt-12 [&_h2]:scroll-mt-20 [&_h2]:border-t [&_h2]:pt-8 [&_h2]:text-2xl [&_h2]:font-bold [&_h2]:tracking-tight [&_h2_a]:ml-2 [&_h2_a]:no-underline [&_h2:first-of-type]:mt-0 [&_h2:first-of-type]:border-t-0 [&_h2:first-of-type]:pt-0 [&_h3]:mt-8 [&_h3]:scroll-mt-20 [&_h3]:text-xl [&_h3]:font-semibold [&_h3]:tracking-tight [&_h3_a]:ml-2 [&_h3_a]:no-underline [&_ol]:my-5 [&_p]:my-5 [&_table]:w-full [&_table]:text-sm [&_td]:border-b [&_td]:p-2 [&_th]:border-b [&_th]:p-2 [&_th]:text-left [&_ul]:my-5", "[&_li]:my-1 [&_li>ol]:my-2 [&_li>p]:my-2 [&_li>ul]:my-2 [&_ol]:list-decimal [&_ol]:ps-6 [&_ul]:list-disc [&_ul]:ps-6", className),
|
|
414
414
|
children: content
|
|
415
415
|
});
|
|
416
416
|
};
|
|
@@ -2011,7 +2011,7 @@ var DocsArticle = ({
|
|
|
2011
2011
|
});
|
|
2012
2012
|
};
|
|
2013
2013
|
var useActiveDocsHeading = (headings) => {
|
|
2014
|
-
const [activeHeadingId, setActiveHeadingId] = useState6(
|
|
2014
|
+
const [activeHeadingId, setActiveHeadingId] = useState6();
|
|
2015
2015
|
useEffect5(() => {
|
|
2016
2016
|
const elements = headings.flatMap((heading) => {
|
|
2017
2017
|
const element = document.getElementById(heading.id);
|
|
@@ -413,7 +413,7 @@ var MarkdownContent = ({
|
|
|
413
413
|
dangerouslySetInnerHTML: { __html: remainingHtml }
|
|
414
414
|
}, "html-final"));
|
|
415
415
|
return /* @__PURE__ */ jsx4("div", {
|
|
416
|
-
className: cn("[&_a:hover]:text-primary [&_a]:decoration-border [&_blockquote]:border-primary/40 [&_blockquote]:bg-muted/40 [&_h2_a]:text-muted-foreground [&_h3_a]:text-muted-foreground [&_[data-inline-code]]:bg-muted text-[0.98rem] leading-7 [&_[data-markdown-table]]:overflow-x-auto [&_[data-inline-code]]:rounded [&_[data-inline-code]]:px-1.5 [&_[data-inline-code]]:py-0.5 [&_[data-inline-code]]:font-mono [&_[data-inline-code]]:text-[0.875em] [&_a]:font-medium [&_a]:underline [&_a]:decoration-1 [&_a]:underline-offset-4 [&_a]:transition-colors [&_blockquote]:my-5 [&_blockquote]:rounded-r-lg [&_blockquote]:border-l-4 [&_blockquote]:px-5 [&_blockquote]:py-1 [&_h2]:mt-12 [&_h2]:scroll-mt-20 [&_h2]:border-t [&_h2]:pt-8 [&_h2]:text-2xl [&_h2]:font-bold [&_h2]:tracking-tight [&_h2_a]:ml-2 [&_h2_a]:no-underline [&_h2:first-of-type]:mt-0 [&_h2:first-of-type]:border-t-0 [&_h2:first-of-type]:pt-0 [&_h3]:mt-8 [&_h3]:scroll-mt-20 [&_h3]:text-xl [&_h3]:font-semibold [&_h3]:tracking-tight [&_h3_a]:ml-2 [&_h3_a]:no-underline [&_ol]:my-5 [&_p]:my-5 [&_table]:w-full [&_table]:text-sm [&_td]:border-b [&_td]:p-2 [&_th]:border-b [&_th]:p-2 [&_th]:text-left [&_ul]:my-5", className),
|
|
416
|
+
className: cn("[&_a:hover]:text-primary [&_a]:decoration-border [&_blockquote]:border-primary/40 [&_blockquote]:bg-muted/40 [&_h2_a]:text-muted-foreground [&_h3_a]:text-muted-foreground [&_[data-inline-code]]:bg-muted text-[0.98rem] leading-7 [&_[data-markdown-table]]:overflow-x-auto [&_[data-inline-code]]:rounded [&_[data-inline-code]]:px-1.5 [&_[data-inline-code]]:py-0.5 [&_[data-inline-code]]:font-mono [&_[data-inline-code]]:text-[0.875em] [&_a]:font-medium [&_a]:underline [&_a]:decoration-1 [&_a]:underline-offset-4 [&_a]:transition-colors [&_blockquote]:my-5 [&_blockquote]:rounded-r-lg [&_blockquote]:border-l-4 [&_blockquote]:px-5 [&_blockquote]:py-1 [&_h2]:mt-12 [&_h2]:scroll-mt-20 [&_h2]:border-t [&_h2]:pt-8 [&_h2]:text-2xl [&_h2]:font-bold [&_h2]:tracking-tight [&_h2_a]:ml-2 [&_h2_a]:no-underline [&_h2:first-of-type]:mt-0 [&_h2:first-of-type]:border-t-0 [&_h2:first-of-type]:pt-0 [&_h3]:mt-8 [&_h3]:scroll-mt-20 [&_h3]:text-xl [&_h3]:font-semibold [&_h3]:tracking-tight [&_h3_a]:ml-2 [&_h3_a]:no-underline [&_ol]:my-5 [&_p]:my-5 [&_table]:w-full [&_table]:text-sm [&_td]:border-b [&_td]:p-2 [&_th]:border-b [&_th]:p-2 [&_th]:text-left [&_ul]:my-5", "[&_li]:my-1 [&_li>ol]:my-2 [&_li>p]:my-2 [&_li>ul]:my-2 [&_ol]:list-decimal [&_ol]:ps-6 [&_ul]:list-disc [&_ul]:ps-6", className),
|
|
417
417
|
children: content
|
|
418
418
|
});
|
|
419
419
|
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { EventAttributes } from "../opentelemetry/schema.js";
|
|
2
|
+
import { OtlpEvents } from "../opentelemetry/events.js";
|
|
3
|
+
import { Context, Effect, Layer, Schema } from "effect";
|
|
4
|
+
import { BrowserEventOptions, type BrowserPageOptions } from "./schema.js";
|
|
5
|
+
export type { BrowserEventOptions, BrowserPageOptions } from "./schema.js";
|
|
6
|
+
export type { EventAttributes } from "../opentelemetry/schema.js";
|
|
7
|
+
export interface BrowserEventsOptions {
|
|
8
|
+
readonly enabled?: boolean;
|
|
9
|
+
readonly respectDoNotTrack?: boolean;
|
|
10
|
+
readonly pageViews?: boolean;
|
|
11
|
+
readonly locale?: () => string;
|
|
12
|
+
/** Replace paths containing personal identifiers with route templates. */
|
|
13
|
+
readonly sanitizePath?: (path: string) => string;
|
|
14
|
+
}
|
|
15
|
+
declare const BrowserEventsClient_base: Context.ServiceClass<BrowserEventsClient, "krakstack/events/BrowserEventsClient", {
|
|
16
|
+
readonly events: OtlpEvents["Service"];
|
|
17
|
+
readonly context: (name: string, properties?: EventAttributes) => EventAttributes;
|
|
18
|
+
}>;
|
|
19
|
+
declare class BrowserEventsClient extends BrowserEventsClient_base {
|
|
20
|
+
}
|
|
21
|
+
export declare class BrowserEvents {
|
|
22
|
+
static readonly track: (name: string, properties?: EventAttributes, options?: BrowserEventOptions) => Effect.Effect<void, Schema.SchemaError, never>;
|
|
23
|
+
static readonly page: (options?: BrowserPageOptions) => Effect.Effect<void, Schema.SchemaError, never>;
|
|
24
|
+
/** Requires BrowserOtlp; no identifiers are persisted. */
|
|
25
|
+
static readonly layer: ({ enabled, respectDoNotTrack, pageViews, locale, sanitizePath, }?: BrowserEventsOptions) => Layer.Layer<BrowserEventsClient, never, OtlpEvents>;
|
|
26
|
+
}
|