@shivaedev/server 0.22.0 → 0.24.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/CHANGELOG.md +26 -0
- package/README.md +46 -18
- package/dist/AppHostFactory.d.ts +2 -2
- package/dist/AppHostFactory.d.ts.map +1 -1
- package/dist/adapters/localTraceDatabase.d.ts +6 -0
- package/dist/adapters/localTraceDatabase.d.ts.map +1 -0
- package/dist/adapters/localTraceDatabase.js +75 -0
- package/dist/adapters/localTraceDatabase.js.map +1 -0
- package/dist/appHost.d.ts +3 -6
- package/dist/appHost.d.ts.map +1 -1
- package/dist/appHost.js +2 -2
- package/dist/appHost.js.map +1 -1
- package/dist/appHostHttp.d.ts +129 -75
- package/dist/appHostHttp.d.ts.map +1 -1
- package/dist/appHostHttp.js +5 -5
- package/dist/appHostHttp.js.map +1 -1
- package/dist/development.js +1 -1
- package/dist/development.js.map +1 -1
- package/dist/hostOptions.d.ts +11 -2
- package/dist/hostOptions.d.ts.map +1 -1
- package/dist/hostRpcRoutes.d.ts +18 -9
- package/dist/hostRpcRoutes.d.ts.map +1 -1
- package/dist/hostRpcRoutes.js +6 -3
- package/dist/hostRpcRoutes.js.map +1 -1
- package/dist/hostSensitiveKeys.d.ts +12 -0
- package/dist/hostSensitiveKeys.d.ts.map +1 -0
- package/dist/hostSensitiveKeys.js +8 -0
- package/dist/hostSensitiveKeys.js.map +1 -0
- package/dist/hostVersionLayer.d.ts +2 -0
- package/dist/hostVersionLayer.d.ts.map +1 -0
- package/dist/hostVersionLayer.js +8 -0
- package/dist/hostVersionLayer.js.map +1 -0
- package/dist/localTraceRow.d.ts +29 -0
- package/dist/localTraceRow.d.ts.map +1 -0
- package/dist/localTraceRow.js +51 -0
- package/dist/localTraceRow.js.map +1 -0
- package/dist/localTracing.d.ts +10 -0
- package/dist/localTracing.d.ts.map +1 -0
- package/dist/localTracing.js +44 -0
- package/dist/localTracing.js.map +1 -0
- package/dist/otlpTracing.d.ts.map +1 -1
- package/dist/otlpTracing.js +14 -1
- package/dist/otlpTracing.js.map +1 -1
- package/package.json +20 -20
- package/src/AppHostFactory.ts +8 -8
- package/src/adapters/localTraceDatabase.ts +74 -0
- package/src/appHost.ts +21 -23
- package/src/appHostHttp.ts +5 -5
- package/src/development.ts +1 -1
- package/src/hostOptions.ts +10 -6
- package/src/hostRpcRoutes.ts +7 -2
- package/src/hostSensitiveKeys.ts +11 -0
- package/src/hostVersionLayer.ts +8 -0
- package/src/localTraceRow.ts +58 -0
- package/src/localTracing.ts +63 -0
- package/src/otlpTracing.ts +18 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.24.0 - 2026-11-04
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Announce the host's configured build version over native live RPC so loaded tabs detect a deploy without polling health.
|
|
8
|
+
- Record development spans and correlated logs in a local SQLite store without an OpenTelemetry collector, using the host redaction policy. Configure indexed attributes and compose `localTracing` directly with scoped flushing and run retention.
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- Start development server and worker processes with `NODE_ENV=development`. Hosts without an OTLP endpoint record locally in this mode.
|
|
13
|
+
|
|
14
|
+
### Breaking
|
|
15
|
+
|
|
16
|
+
- TypeScript source exports now use `@shivaedev/source` instead of `source`. Replace `source` with `@shivaedev/source` in Node `--conditions`, TypeScript `customConditions`, and Vite/Vitest `resolve.conditions`. Bare `source` selects built JavaScript; no compatibility alias is provided.
|
|
17
|
+
|
|
18
|
+
## 0.23.0 - 2026-11-04
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
|
|
22
|
+
- Allow `appHost` to omit both the native RPC `group` and `handlers` while serving an existing HTTP API through `routes`, as a migration step towards native RPC. Host services, migrations, body-limit configuration, proxy trust, health and tracing retain their existing behavior; the existing API owns authentication and CORS. No native RPC endpoint or RPC preflight policy is installed without a group.
|
|
23
|
+
- `appHost` accepts `config.socketPath` for Unix HTTP and WebSocket RPC, alone or beside an explicit TCP `port`. Socket files are published with mode `0600`, stale sockets are reclaimed at startup, and shutdown removes the socket.
|
|
24
|
+
|
|
25
|
+
### Breaking
|
|
26
|
+
|
|
27
|
+
- Host option types include the HTTP-only shape. Consumers that inspect native RPC options must narrow with `options.group !== undefined` before reading the group or handlers. Existing native `appHost` calls retain their options.
|
|
28
|
+
|
|
3
29
|
## 0.22.0 - 2026-11-04
|
|
4
30
|
|
|
5
31
|
### Added
|
package/README.md
CHANGED
|
@@ -29,6 +29,39 @@ The RPC host composes contract's `CommandGuard` with `publishCommand` and the `C
|
|
|
29
29
|
|
|
30
30
|
The optional modules solve different boundaries. `runtime/` carries Effect services into Promise callers, and `node-http/` combines subscription cancellation sources. Choose the modules that match the application rather than adopting every integration.
|
|
31
31
|
|
|
32
|
+
### Adopt the host before replacing an existing API
|
|
33
|
+
|
|
34
|
+
For an app migrating from tRPC or another HTTP API, omit both `group` and `handlers` and mount the existing API through `routes`. This is a supported migration step towards native RPC; new apps use native contracts and handlers. Without a group the host installs no native RPC endpoint or RPC preflight policy, so an existing API can keep `/rpc`. The existing API continues to own its authentication and CORS policy. Supply `sessions` only if application routes or browser error reporting need the host's session policy.
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { Effect } from "effect";
|
|
38
|
+
import { HttpRouter, HttpServerRequest, HttpServerResponse } from "effect/http";
|
|
39
|
+
import { readBoundedBody } from "@shivaedev/http/server/boundedBody.ts";
|
|
40
|
+
import { appHost } from "@shivaedev/server/appHost.ts";
|
|
41
|
+
import { handleRequest } from "./existing-api.ts";
|
|
42
|
+
|
|
43
|
+
const Routes = HttpRouter.add("POST", "/api/trpc/*", () =>
|
|
44
|
+
Effect.gen(function* () {
|
|
45
|
+
const body = yield* readBoundedBody();
|
|
46
|
+
const request = yield* HttpServerRequest.HttpServerRequest;
|
|
47
|
+
const web = yield* HttpServerRequest.toWeb(request);
|
|
48
|
+
const response = yield* Effect.promise(() => handleRequest(new Request(web, { body })));
|
|
49
|
+
return HttpServerResponse.fromWeb(response);
|
|
50
|
+
}),
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
const Server = appHost({
|
|
54
|
+
routes: Routes,
|
|
55
|
+
config: { host: "0.0.0.0", trustedProxy: "127.0.0.1", maxBodySize: 1024 * 1024 },
|
|
56
|
+
});
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
`handleRequest` is the app's existing `(request: Request) => Promise<Response>`. Use `readBoundedBody` when forwarding bodies; `routes` receives the host's `MAX_BODY_SIZE` or `config.maxBodySize`, and that reader returns 413 on overflow. Merely converting a request to a Web request does not bound its body. Configure the actual proxy peer in `trustedProxy`; the host still requires trust when binding publicly and applies it at its own transport boundaries, including browser error reports. This setting does not install authentication or an Origin guard around application routes.
|
|
60
|
+
|
|
61
|
+
The same host composition provides scoped `services`, migration ordering (including deferred `application` construction), `/health`, HTTP tracing with incoming W3C trace context, and diagnostic redaction. Health still returns 503 without SQL and 200 with reachable PostgreSQL. Add the native `group`, `handlers` and session policy as the app adopts native RPC, alongside any remaining HTTP routes.
|
|
62
|
+
|
|
63
|
+
Host option types include this HTTP-only shape. A wrapper that reads native RPC options first narrows with `options.group !== undefined` before reading `group` or `handlers`. Existing native `appHost` calls keep their options.
|
|
64
|
+
|
|
32
65
|
### Prepare local development
|
|
33
66
|
|
|
34
67
|
`setupDatabases()` from `@shivaedev/server/setupDatabases.ts` reads `DATABASE_URL` and `TEST_DATABASE_URL` through Effect Config and prepares both local databases with `@shivaedev/local-postgres`. Database names come from those URLs. `DOCKER_HOST` and `DOCKER_CONTEXT` are optional. Missing database URLs fail with a typed Config error; setup command failures retain their local-postgres error tags. Provide `ChildProcessSpawner` at the setup entry point, for example with `Effect.provide(NodeServices.layer)` before `NodeRuntime.runMain`. Migrations remain the application's responsibility.
|
|
@@ -148,6 +181,8 @@ For local tools, use `policy: "loopback"` with contracts that do not use session
|
|
|
148
181
|
|
|
149
182
|
Omit `migrations` to host an app without a database. This form creates no SQL pool and reads no `DATABASE_URL`; `AppHttpHostOptions` describes it. `AppHostOptions` requires migrations for database-backed hosts. A service that needs SQL still requires a SQL Layer. Provide `appDatabase` to the application’s service Layer when it owns database composition.
|
|
150
183
|
|
|
184
|
+
Set `config.buildVersion` to the deployed build ID to announce it over the host's native RPC socket. `platform.hostVersion.watch` sends that opaque string when subscribed and stays open; a reconnected subscriber receives the replacement host's ID. Omitting the option leaves the stream silent. Embed the same ID in the browser bundle and use React's `deployUpdate` controller to expose a superseded bundle without polling health. The application supplies staged-update activation, blockers, reload wording and confirmation.
|
|
185
|
+
|
|
151
186
|
`appHost` serves unauthenticated `GET /health`. It queries its SQL client on each request and returns `200` only when the query succeeds within two seconds; a missing SQL client, query failure or timeout returns `503`. Both responses have an empty body and `Cache-Control: no-store`. This route also works when the SQL client comes from the application’s `services` Layer. Use it for database readiness checks.
|
|
152
187
|
|
|
153
188
|
Set `migrations.mode: "check"` on `appDatabase` or a database-backed `appHost` when a separate pre-deploy command owns migrations. Startup reads the ledger and fails with native `MigrationError` (`kind: "BadState"`) if any required migration ID or name is missing or a schema component is pending; it does not run migrations or create a ledger. Later ledger entries are allowed for rolling deployments. Use `migrations.mode: "wait"` for services that can start before that pre-deploy command finishes. It re-reads the ledger and every registered component every second until all are current, then starts the application. Set `migrations.pollInterval` and `migrations.waitTimeout` with Effect duration inputs to change the interval and five-minute timeout. If the first check finds pending work, Effect’s logger emits `Waiting for database migrations` at info, then `Still waiting for database migrations` every 30 seconds independently of polling. Set `migrations.progressInterval` with an Effect duration input to change that progress interval. These lines carry `pendingMigrations` (ID and name) and `pendingComponents` (name and detail) annotations. A later successful check logs `Database migrations current` once; timeout logs `Timed out waiting for database migrations` with the pending annotations before failing. An initially current schema emits none of these lines. The host adds no connection details or secrets to these diagnostics. Timeout fails with the same `MigrationError` as `"check"`; interruption stops polling and closes the pool. SQL failures fail immediately. With `mode` omitted or `"migrate"`, startup applies pending ledger migrations with a five-second lock timeout unless `migrations.lockTimeout` overrides it, then applies schema components outside the ledger transaction.
|
|
@@ -176,7 +211,7 @@ const host = appHost({
|
|
|
176
211
|
|
|
177
212
|
Construct Better Auth inside `application`, since its constructor starts schema validation. Keep validation enabled so a current migration ledger with missing auth columns still reports drift. The starter uses this form after its pre-deploy migrations.
|
|
178
213
|
|
|
179
|
-
Railway tracing is the default error and trace destination. The starter enables tracing for both services in `.railway/railway.ts`; Railway injects the endpoint, authentication headers and service identity. `appHost` exports through the redacting Effect OTLP/HTTP pipeline. Leave exporter endpoints unset on Railway so its injected configuration takes effect.
|
|
214
|
+
Railway tracing is the default error and trace destination. The starter enables tracing for both services in `.railway/railway.ts`; Railway injects the endpoint, authentication headers and service identity. `appHost` exports through the redacting Effect OTLP/HTTP pipeline. Leave exporter endpoints unset on Railway so its injected configuration takes effect. Outside development mode, without an endpoint, no exporter or export loop is built, even when service metadata is set. The `http/protobuf` default follows the [OpenTelemetry recommendation](https://opentelemetry.io/docs/specs/otel/protocol/exporter/#specify-protocol); unsupported protocols, including `grpc`, fail startup with a `ConfigError` naming the value. Header and resource-attribute values are `key=value` pairs with URL-encoded values. Configuration is read through Effect Config.
|
|
180
215
|
|
|
181
216
|
The supported tracing variables and defaults are:
|
|
182
217
|
|
|
@@ -205,25 +240,17 @@ For existing Railway services, enable manual tracing per service and environment
|
|
|
205
240
|
Set `browserErrors: { log: true, includeUserId: true, requireSession: true }` on `appHost` for the recommended signed-in application setting. `log` writes one Error log with the masked message and stack per accepted report, including when OTLP export is off. `includeUserId` resolves the session and adds `user.id` to the HTTP span and error report when signed in. `requireSession` rejects signed-out reports with 401; a session-provider outage returns 503. Session lookups use the host's session and origin policy. With no session policy, requiring a session rejects reports. All three options default to false, preserving reports before sign-in without session lookups or an extra log line. `browserErrorRoute(trustedProxy?, options?)` accepts the same options when composed directly.
|
|
206
241
|
|
|
207
242
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
exporters:
|
|
217
|
-
debug:
|
|
218
|
-
verbosity: detailed
|
|
219
|
-
service:
|
|
220
|
-
pipelines:
|
|
221
|
-
traces:
|
|
222
|
-
receivers: [ otlp ]
|
|
223
|
-
exporters: [ debug ]
|
|
243
|
+
With `NODE_ENV=development` and no OTLP endpoint, `appHost` and `otlpTracing` record to `.platform/traces.db` using Node's SQLite support. `runDevelopment` sets this mode for its child processes. Add `.platform/` to the application's ignore file. Set `PLATFORM_TRACE_STORE` to choose another file and `PLATFORM_TRACE_INDEXED_ATTRIBUTES=orderId,projectId` to index application attributes. Indexed values use the same redaction as the stored spans. An explicit OTLP endpoint takes precedence; other modes without an endpoint keep export disabled.
|
|
244
|
+
|
|
245
|
+
Records flush every second on a live maintenance clock and when their scope closes. Application clock jumps do not replay flush intervals. The store retains the latest five completed recorder runs, deleting older spans, logs and attribute indexes when a recorder closes. Active recorders remain writable until their scopes close. Logs use the existing `effect.log` diagnostic spans; the `logs` view exposes their parent span ID and trace ID. Open the file with any SQLite viewer, or inspect it directly:
|
|
246
|
+
|
|
247
|
+
```sh
|
|
248
|
+
sqlite3 .platform/traces.db "SELECT name, trace_id, span_id, data FROM spans ORDER BY started_at_millis DESC LIMIT 20"
|
|
249
|
+
sqlite3 .platform/traces.db "SELECT trace_id, span_id, data FROM logs ORDER BY at_millis DESC LIMIT 20"
|
|
250
|
+
sqlite3 .platform/traces.db "SELECT span_id FROM span_attributes WHERE key = 'orderId' AND value = 'order-42'"
|
|
224
251
|
```
|
|
225
252
|
|
|
226
|
-
|
|
253
|
+
For explicit composition, provide `localTracing({ path, indexedAttributes, retainedRuns, flushInterval, clock })` from `@shivaedev/server/localTracing.ts` to the application's Layer. All options are optional; `flushInterval` is milliseconds, and `retainedRuns` is a positive integer. Supply a native `clock` to control flush timing in stories; span timestamps still follow the application clock. It uses `RedactionPolicy`, including host schema sensitivity, and preserves the application's installed tracer and console loggers. Local recording and OTLP export are alternative sinks; compose one per application scope.
|
|
227
254
|
|
|
228
255
|
Exported HTTP server spans use `{method} {route}` with `http.route` for matched RPC and router paths, including parameter templates; unmatched requests use the method alone. `appHost` continues incoming W3C `traceparent` context in RPC handling, including one sent by an edge proxy, whether or not an exporter is configured.
|
|
229
256
|
|
|
@@ -464,6 +491,7 @@ Import the module that defines the name; there is no package-root entry. Paths b
|
|
|
464
491
|
| `setupDatabases.ts` | `setupDatabases()`: prepare the local development and test databases. |
|
|
465
492
|
| `development.ts` | `development({ server, worker, conditions? })`, `runDevelopment(options)`: run the server, worker and Vite in watch mode. |
|
|
466
493
|
| `rpc-server/publicConfigLayer.ts` | `publicConfigLayer(declaration, path?)`: serve a `publicConfig` declaration from native Config. |
|
|
494
|
+
| `localTracing.ts` | `localTracing(options?)`: scoped local SQLite spans and correlated logs with configurable attribute indexes and run retention. |
|
|
467
495
|
| `otlpTracing.ts` | `otlpTracing`: redacting Railway OTLP export for worker spans, logs and error reports. |
|
|
468
496
|
| `RedactionPolicy.ts` | `RedactionPolicy`: provide the app's diagnostic key predicate derived by errors. |
|
|
469
497
|
| `redactingDiagnostics.ts`, `redactingTracer.ts`, `redactingRpcSerialization.ts` | `redactingDiagnostics(sensitive)`, `redactingTracer(sensitive)`, `redactingRpcSerialization(wire, sensitive)`: compose native diagnostic and NDJSON boundaries. |
|
package/dist/AppHostFactory.d.ts
CHANGED
|
@@ -6,10 +6,10 @@ import type { appHostHttp, deferredHost } from "#appHostHttp.ts";
|
|
|
6
6
|
import type { HostRouteRequirements } from "#hostOptions.ts";
|
|
7
7
|
type PreflightHost<THost extends Layer.Any, TServices, TError, TRequirements> = Layer.Layer<Layer.Success<THost> | TServices, Layer.Error<THost> | TError, Exclude<Layer.Services<THost>, TServices | Crypto.Crypto> | Exclude<TRequirements, Crypto.Crypto>>;
|
|
8
8
|
export interface AppHostFactory {
|
|
9
|
-
<TRpcs extends Rpc.Any, THandlers, THandlerError, THandlerRequirements, TServices = never, TServiceError = never, TServiceRequirements = never, TMigrations = never, TApplicationError = never, TApplicationRequirements = never, TPreflight = never, TPreflightError = never, TPreflightRequirements = never, TRouteError = never, TRouteRequirements = HostRouteRequirements, TMigrationError = never>(options: AppHostInput<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TMigrations, TApplicationError, TApplicationRequirements, TPreflight, TPreflightError, TPreflightRequirements, TRouteError, TRouteRequirements, TMigrationError> & {
|
|
9
|
+
<TRpcs extends Rpc.Any = never, THandlers = never, THandlerError = never, THandlerRequirements = never, TServices = never, TServiceError = never, TServiceRequirements = never, TMigrations = never, TApplicationError = never, TApplicationRequirements = never, TPreflight = never, TPreflightError = never, TPreflightRequirements = never, TRouteError = never, TRouteRequirements = HostRouteRequirements, TMigrationError = never>(options: AppHostInput<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TMigrations, TApplicationError, TApplicationRequirements, TPreflight, TPreflightError, TPreflightRequirements, TRouteError, TRouteRequirements, TMigrationError> & {
|
|
10
10
|
readonly migrations: AppDatabaseOptions<TMigrations, TMigrationError>["migrations"];
|
|
11
11
|
}): PreflightHost<ReturnType<typeof deferredHost<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TMigrations, TApplicationError, TApplicationRequirements, TRouteError, TRouteRequirements, TMigrationError>>, NoInfer<TPreflight>, NoInfer<TPreflightError>, NoInfer<TPreflightRequirements>>;
|
|
12
|
-
<TRpcs extends Rpc.Any, THandlers, THandlerError, THandlerRequirements, TServices = never, TServiceError = never, TServiceRequirements = never, TPreflight = never, TPreflightError = never, TPreflightRequirements = never, TRouteError = never, TRouteRequirements = HostRouteRequirements>(options: AppHttpHostOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TPreflight, TPreflightError, TPreflightRequirements, TRouteError, TRouteRequirements>): PreflightHost<ReturnType<typeof appHostHttp<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TRouteError, TRouteRequirements>>, NoInfer<TPreflight>, NoInfer<TPreflightError>, NoInfer<TPreflightRequirements>>;
|
|
12
|
+
<TRpcs extends Rpc.Any = never, THandlers = never, THandlerError = never, THandlerRequirements = never, TServices = never, TServiceError = never, TServiceRequirements = never, TPreflight = never, TPreflightError = never, TPreflightRequirements = never, TRouteError = never, TRouteRequirements = HostRouteRequirements>(options: AppHttpHostOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TPreflight, TPreflightError, TPreflightRequirements, TRouteError, TRouteRequirements>): PreflightHost<ReturnType<typeof appHostHttp<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements, TRouteError, TRouteRequirements>>, NoInfer<TPreflight>, NoInfer<TPreflightError>, NoInfer<TPreflightRequirements>>;
|
|
13
13
|
}
|
|
14
14
|
export {};
|
|
15
15
|
//# sourceMappingURL=AppHostFactory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppHostFactory.d.ts","sourceRoot":"","sources":["../src/AppHostFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAE7D,KAAK,aAAa,CAAC,KAAK,SAAS,KAAK,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,IAAI,KAAK,CAAC,KAAK,CAC1F,K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AAG,KAAK,EACrB,oBAAoB,GAAG,KAAK,EAC5B,UAAU,GAAG,KAAK,EAClB,eAAe,GAAG,KAAK,EACvB,sBAAsB,GAAG,KAAK,EAC9B,WAAW,GAAG,KAAK,EACnB,kBAAkB,GAAG,qBAAqB,EAE1C,OAAO,EAAE,kBAAkB,CAC1B,KAAK,EACL,SAAS,EACT,aAAa,EACb,oBAAoB,EACpB,SAAS,EACT,aAAa,EACb,oBAAoB,EACpB,UAAU,EACV,eAAe,EACf,sBAAsB,EACtB,WAAW,EACX,kBAAkB,CAClB,GACC,aAAa,CACf,UAAU,CACT,OAAO,WAAW,CACjB,KAAK,EACL,SAAS,EACT,aAAa,EACb,oBAAoB,EACpB,SAAS,EACT,aAAa,EACb,oBAAoB,EACpB,WAAW,EACX,kBAAkB,CAClB,CACD,EACD,OAAO,CAAC,UAAU,CAAC,EACnB,OAAO,CAAC,eAAe,CAAC,EACxB,OAAO,CAAC,sBAAsB,CAAC,CAC/B,CAAC;CACF"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type LocalTraceRow } from "#localTraceRow.ts";
|
|
2
|
+
export declare function localTraceDatabase(path: string, retainedRuns: number, indexedAttributes: readonly string[], startedAtMillis: number): {
|
|
3
|
+
close: () => void;
|
|
4
|
+
write: (rows: readonly LocalTraceRow[]) => void;
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=localTraceDatabase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localTraceDatabase.d.ts","sourceRoot":"","sources":["../../src/adapters/localTraceDatabase.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,aAAa,EAAa,MAAM,mBAAmB,CAAC;AAElE,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,iBAAiB,EAAE,SAAS,MAAM,EAAE,EAAE,eAAe,EAAE,MAAM;;kBAkDnH,SAAS,aAAa,EAAE;EAiBxC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { mkdirSync } from "node:fs";
|
|
3
|
+
import { dirname } from "node:path";
|
|
4
|
+
import { DatabaseSync } from "node:sqlite";
|
|
5
|
+
import { traceJson } from "#localTraceRow.ts";
|
|
6
|
+
export function localTraceDatabase(path, retainedRuns, indexedAttributes, startedAtMillis) {
|
|
7
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
8
|
+
const db = new DatabaseSync(path, { timeout: 1000 });
|
|
9
|
+
try {
|
|
10
|
+
db.exec(`
|
|
11
|
+
PRAGMA journal_mode = WAL;
|
|
12
|
+
PRAGMA foreign_keys = ON;
|
|
13
|
+
CREATE TABLE IF NOT EXISTS runs (id TEXT PRIMARY KEY, started_at_millis INTEGER NOT NULL, completed INTEGER NOT NULL DEFAULT 0);
|
|
14
|
+
CREATE TABLE IF NOT EXISTS spans (
|
|
15
|
+
run_id TEXT NOT NULL REFERENCES runs(id) ON DELETE CASCADE,
|
|
16
|
+
span_id TEXT PRIMARY KEY, trace_id TEXT NOT NULL, parent_span_id TEXT,
|
|
17
|
+
name TEXT NOT NULL, started_at_millis INTEGER NOT NULL, data TEXT NOT NULL
|
|
18
|
+
);
|
|
19
|
+
CREATE INDEX IF NOT EXISTS spans_trace ON spans(trace_id, started_at_millis);
|
|
20
|
+
CREATE TABLE IF NOT EXISTS span_attributes (
|
|
21
|
+
span_id TEXT NOT NULL REFERENCES spans(span_id) ON DELETE CASCADE,
|
|
22
|
+
key TEXT NOT NULL, value TEXT NOT NULL
|
|
23
|
+
);
|
|
24
|
+
CREATE INDEX IF NOT EXISTS span_attributes_lookup ON span_attributes(key, value, span_id);
|
|
25
|
+
CREATE VIEW IF NOT EXISTS logs AS
|
|
26
|
+
SELECT run_id, trace_id, parent_span_id AS span_id, started_at_millis AS at_millis,
|
|
27
|
+
json_extract(data, '$.events[0].attributes') AS data FROM spans WHERE name = 'effect.log';
|
|
28
|
+
`);
|
|
29
|
+
const runId = randomUUID();
|
|
30
|
+
db.prepare("INSERT INTO runs(id, started_at_millis) VALUES (?, ?)").run(runId, startedAtMillis);
|
|
31
|
+
const complete = db.prepare("UPDATE runs SET completed = (SELECT coalesce(max(completed), 0) + 1 FROM runs) WHERE id = ?");
|
|
32
|
+
const prune = db.prepare("DELETE FROM runs WHERE completed > 0 AND id NOT IN (SELECT id FROM runs WHERE completed > 0 ORDER BY completed DESC LIMIT ?)");
|
|
33
|
+
const insert = db.prepare("INSERT INTO spans VALUES (?, ?, ?, ?, ?, ?, ?)");
|
|
34
|
+
const index = db.prepare("INSERT INTO span_attributes VALUES (?, ?, ?)");
|
|
35
|
+
const indexed = new Set(indexedAttributes);
|
|
36
|
+
function append(row) {
|
|
37
|
+
insert.run(runId, row.spanId, row.traceId, row.parentSpanId, row.name, row.startedAtMillis, traceJson(row));
|
|
38
|
+
for (const key of indexed) {
|
|
39
|
+
const value = row.attributes[key];
|
|
40
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
41
|
+
index.run(row.spanId, key, String(value));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
close: () => {
|
|
47
|
+
try {
|
|
48
|
+
complete.run(runId);
|
|
49
|
+
prune.run(retainedRuns);
|
|
50
|
+
}
|
|
51
|
+
finally {
|
|
52
|
+
db.close();
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
write: (rows) => {
|
|
56
|
+
db.exec("BEGIN");
|
|
57
|
+
try {
|
|
58
|
+
for (const row of rows) {
|
|
59
|
+
append(row);
|
|
60
|
+
}
|
|
61
|
+
db.exec("COMMIT");
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
db.exec("ROLLBACK");
|
|
65
|
+
throw error;
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
db.close();
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=localTraceDatabase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localTraceDatabase.js","sourceRoot":"","sources":["../../src/adapters/localTraceDatabase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAsB,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAElE,MAAM,UAAU,kBAAkB,CAAC,IAAY,EAAE,YAAoB,EAAE,iBAAoC,EAAE,eAAuB;IACnI,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9C,MAAM,EAAE,GAAG,IAAI,YAAY,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IACrD,IAAI,CAAC;QACJ,EAAE,CAAC,IAAI,CAAC;;;;;;;;;;;;;;;;;;GAkBP,CAAC,CAAC;QACH,MAAM,KAAK,GAAG,UAAU,EAAE,CAAC;QAC3B,EAAE,CAAC,OAAO,CAAC,uDAAuD,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC;QAChG,MAAM,QAAQ,GAAG,EAAE,CAAC,OAAO,CAAC,6FAA6F,CAAC,CAAC;QAC3H,MAAM,KAAK,GAAG,EAAE,CAAC,OAAO,CACvB,8HAA8H,CAC9H,CAAC;QACF,MAAM,MAAM,GAAG,EAAE,CAAC,OAAO,CAAC,gDAAgD,CAAC,CAAC;QAC5E,MAAM,KAAK,GAAG,EAAE,CAAC,OAAO,CAAC,8CAA8C,CAAC,CAAC;QACzE,MAAM,OAAO,GAAG,IAAI,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BACpB,MAAM,KAAK,CAAC;gBACb,CAAC;YACF,CAAC;SACD,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,EAAE,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,KAAK,CAAC;IACb,CAAC;AACF,CAAC"}
|
package/dist/appHost.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { Layer } from "effect";
|
|
2
1
|
import type { Rpc } from "effect/rpc";
|
|
3
|
-
import type { SessionPolicy } from "@shivaedev/identity/server/SessionPolicy.ts";
|
|
4
2
|
import type { AppHostFactory } from "#AppHostFactory.ts";
|
|
5
3
|
import type { HostPreflight } from "#AppHostInput.ts";
|
|
6
4
|
import { type DatabaseConfig } from "#appDatabase.ts";
|
|
@@ -10,17 +8,16 @@ export interface AppDatabaseOptions<R = never, E = never> {
|
|
|
10
8
|
readonly config?: DatabaseConfig;
|
|
11
9
|
readonly migrations: MigrationOptions<R, E>;
|
|
12
10
|
}
|
|
13
|
-
export type AppHostOptions<TRpcs extends Rpc.Any, THandlers, THandlerError, THandlerRequirements, TServices = never, TServiceError = never, TServiceRequirements = never, TMigrations = never, TPreflight = never, TPreflightError = never, TPreflightRequirements = never, TRouteError = never, TRouteRequirements = HostRouteRequirements, TMigrationError = never> = HostPreflight<TPreflight, TPreflightError, TPreflightRequirements> & HostCoreOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements> & HostRoutes<TRouteError, TRouteRequirements> & {
|
|
11
|
+
export type AppHostOptions<TRpcs extends Rpc.Any = never, THandlers = never, THandlerError = never, THandlerRequirements = never, TServices = never, TServiceError = never, TServiceRequirements = never, TMigrations = never, TPreflight = never, TPreflightError = never, TPreflightRequirements = never, TRouteError = never, TRouteRequirements = HostRouteRequirements, TMigrationError = never> = HostPreflight<TPreflight, TPreflightError, TPreflightRequirements> & HostCoreOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements> & HostRoutes<TRouteError, TRouteRequirements> & HostPolicy & {
|
|
14
12
|
readonly migrations: AppDatabaseOptions<TMigrations, TMigrationError>["migrations"];
|
|
15
13
|
readonly policy?: undefined;
|
|
16
|
-
readonly sessions: Layer.Layer<SessionPolicy>;
|
|
17
14
|
};
|
|
18
|
-
export type AppLocalHostOptions<TRpcs extends Rpc.Any, THandlers, THandlerError, THandlerRequirements, TServices = never, TServiceError = never, TServiceRequirements = never, TMigrations = never, TPreflight = never, TPreflightError = never, TPreflightRequirements = never, TRouteError = never, TRouteRequirements = HostRouteRequirements, TMigrationError = never> = HostPreflight<TPreflight, TPreflightError, TPreflightRequirements> & HostCoreOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements> & HostRoutes<TRouteError, TRouteRequirements> & {
|
|
15
|
+
export type AppLocalHostOptions<TRpcs extends Rpc.Any = never, THandlers = never, THandlerError = never, THandlerRequirements = never, TServices = never, TServiceError = never, TServiceRequirements = never, TMigrations = never, TPreflight = never, TPreflightError = never, TPreflightRequirements = never, TRouteError = never, TRouteRequirements = HostRouteRequirements, TMigrationError = never> = HostPreflight<TPreflight, TPreflightError, TPreflightRequirements> & HostCoreOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements> & HostRoutes<TRouteError, TRouteRequirements> & {
|
|
19
16
|
readonly migrations: AppDatabaseOptions<TMigrations, TMigrationError>["migrations"];
|
|
20
17
|
readonly policy: "loopback";
|
|
21
18
|
readonly sessions?: never;
|
|
22
19
|
};
|
|
23
|
-
export type AppHttpHostOptions<TRpcs extends Rpc.Any, THandlers, THandlerError, THandlerRequirements, TServices = never, TServiceError = never, TServiceRequirements = never, TPreflight = never, TPreflightError = never, TPreflightRequirements = never, TRouteError = never, TRouteRequirements = HostRouteRequirements> = HostPreflight<TPreflight, TPreflightError, TPreflightRequirements> & HostCoreOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements> & HostRoutes<TRouteError, TRouteRequirements> & HostPolicy & {
|
|
20
|
+
export type AppHttpHostOptions<TRpcs extends Rpc.Any = never, THandlers = never, THandlerError = never, THandlerRequirements = never, TServices = never, TServiceError = never, TServiceRequirements = never, TPreflight = never, TPreflightError = never, TPreflightRequirements = never, TRouteError = never, TRouteRequirements = HostRouteRequirements> = HostPreflight<TPreflight, TPreflightError, TPreflightRequirements> & HostCoreOptions<TRpcs, THandlers, THandlerError, THandlerRequirements, TServices, TServiceError, TServiceRequirements> & HostRoutes<TRouteError, TRouteRequirements> & HostPolicy & {
|
|
24
21
|
readonly migrations?: undefined;
|
|
25
22
|
};
|
|
26
23
|
export declare const appHost: AppHostFactory;
|
package/dist/appHost.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appHost.d.ts","sourceRoot":"","sources":["../src/appHost.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"appHost.d.ts","sourceRoot":"","sources":["../src/appHost.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAgB,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAe,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEnE,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAEtG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG7D,MAAM,WAAW,kBAAkB,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,KAAK;IACvD,QAAQ,CAAC,MAAM,CAAC,EAAE,cAAc,CAAC;IACjC,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CAC5C;AAED,MAA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B,CAAC,GACrE,eAAe,CAAC,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,oBAAoB,EAAE,SAAS,EAAE,aAAa,EAAE,oBAAoB,CAAC,GACtH,UAAU,CAAC,WAAW,EAAE,kBAAkB,CAAC,GAAG;IAC7C,QAAQ,CAAC,UAAU,EAAE,kBAAkB,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC,YAAY,CAAC,CAAC;IACpF,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC;CAC1B,CAAC;AAEH,MAAM,MAAM,kBAAkB,CAC7B,KAAK,SAAS,GAAG,CAAC,GAAG,GAAG,KAAK,EAC7B,SAAS,GAAG,KAAK,EACjB,aAAa,GAAG,KAAK,EACrB,oBAAoB,GAAG,KAAK,EAC5B,SAAS,GAAG,KAAK,EACjB,aAAa,GAAG,KAAK,EACrB,oBAAoB,GAAG,KAAK,EAC5B,UAAU,GAAG,KAAK,EAClB,eAAe,GAAG,KAAK,EACvB,sBAAsB,GAAG,KAAK,EAC9B,WAAW,GAAG,KAAK,EACnB,kBAAkB,GAAG,qBAAqB,IACvC,aAAa,CAAC,UAAU,EAAE,eAAe,EAAE,sBAAsB,CAAC,GACrE,eAAe,CAAC,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,oBAAoB,EAAE,SAAS,EAAE,aAAa,EAAE,oBAAoB,CAAC,GACtH,UAAU,CAAC,WAAW,EAAE,kBAAkB,CAAC,GAC3C,UAAU,GAAG;IAAE,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,CAAA;CAAE,CAAC;AAClD,eAAO,MAAM,OAAO,EAAE,cAuDrB,CAAC"}
|
package/dist/appHost.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import * as NodeCrypto from "@effect/platform-node/NodeCrypto";
|
|
2
2
|
import { Effect, Layer } from "effect";
|
|
3
|
-
import { schemaSensitiveKeys } from "@shivaedev/errors/schemaSensitiveKeys.ts";
|
|
4
3
|
import { isSensitiveKey } from "@shivaedev/errors/sensitive.ts";
|
|
5
4
|
import { appDatabase } from "#appDatabase.ts";
|
|
6
5
|
import { appHostHttp, deferredHost, migratedHost } from "#appHostHttp.ts";
|
|
6
|
+
import { hostSensitiveKeys } from "#hostSensitiveKeys.ts";
|
|
7
7
|
import { redactingDiagnostics } from "#redactingDiagnostics.ts";
|
|
8
8
|
export const appHost = (options) => {
|
|
9
9
|
const startup = options.preflight;
|
|
10
10
|
const preflight = startup === undefined
|
|
11
11
|
? Layer.empty
|
|
12
|
-
: Layer.unwrap(Effect.map("application" in options ? Effect.succeed(isSensitiveKey) :
|
|
12
|
+
: Layer.unwrap(Effect.map("application" in options ? Effect.succeed(isSensitiveKey) : hostSensitiveKeys(options), (sensitive) => startup.pipe(Layer.provide(redactingDiagnostics(sensitive)))));
|
|
13
13
|
if ("application" in options) {
|
|
14
14
|
return deferredHost(options.application, appDatabase(options)).pipe(Layer.provideMerge(preflight), Layer.provide(NodeCrypto.layer));
|
|
15
15
|
}
|
package/dist/appHost.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appHost.js","sourceRoot":"","sources":["../src/appHost.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAEvC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"appHost.js","sourceRoot":"","sources":["../src/appHost.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAEvC,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAGhE,OAAO,EAAE,WAAW,EAAuB,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE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