@shivaedev/server 0.10.0 → 0.11.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.
Files changed (72) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +23 -18
  3. package/dist/appDatabase.d.ts +14 -0
  4. package/dist/appDatabase.d.ts.map +1 -0
  5. package/dist/{databaseLayer.js → appDatabase.js} +6 -6
  6. package/dist/appDatabase.js.map +1 -0
  7. package/dist/appHost.d.ts +1 -14
  8. package/dist/appHost.d.ts.map +1 -1
  9. package/dist/appHost.js +5 -10
  10. package/dist/appHost.js.map +1 -1
  11. package/dist/appHostHttp.d.ts +29 -29
  12. package/dist/appHostHttp.d.ts.map +1 -1
  13. package/dist/appHostHttp.js +7 -7
  14. package/dist/appHostHttp.js.map +1 -1
  15. package/dist/bearerSocketRpc.d.ts +5 -0
  16. package/dist/bearerSocketRpc.d.ts.map +1 -0
  17. package/dist/bearerSocketRpc.js +69 -0
  18. package/dist/bearerSocketRpc.js.map +1 -0
  19. package/dist/hostChanges.d.ts +1 -2
  20. package/dist/hostChanges.d.ts.map +1 -1
  21. package/dist/hostChanges.js +4 -3
  22. package/dist/hostChanges.js.map +1 -1
  23. package/dist/hostRpcRoutes.d.ts +2 -3
  24. package/dist/hostRpcRoutes.d.ts.map +1 -1
  25. package/dist/hostRpcRoutes.js +4 -2
  26. package/dist/hostRpcRoutes.js.map +1 -1
  27. package/dist/otlpHttpClient.js +2 -2
  28. package/dist/otlpHttpClient.js.map +1 -1
  29. package/dist/redactingDiagnostics.d.ts +0 -2
  30. package/dist/redactingDiagnostics.d.ts.map +1 -1
  31. package/dist/redactingDiagnostics.js +1 -4
  32. package/dist/redactingDiagnostics.js.map +1 -1
  33. package/dist/redactingTracer.d.ts.map +1 -1
  34. package/dist/redactingTracer.js +6 -5
  35. package/dist/redactingTracer.js.map +1 -1
  36. package/dist/safeOtlpSerialization.d.ts +0 -2
  37. package/dist/safeOtlpSerialization.d.ts.map +1 -1
  38. package/dist/safeOtlpSerialization.js +5 -12
  39. package/dist/safeOtlpSerialization.js.map +1 -1
  40. package/dist/socketRpc.d.ts.map +1 -1
  41. package/dist/socketRpc.js +6 -4
  42. package/dist/socketRpc.js.map +1 -1
  43. package/package.json +9 -9
  44. package/src/{databaseLayer.ts → appDatabase.ts} +6 -6
  45. package/src/appHost.ts +5 -11
  46. package/src/appHostHttp.ts +8 -11
  47. package/src/bearerSocketRpc.ts +80 -0
  48. package/src/hostChanges.ts +4 -8
  49. package/src/hostRpcRoutes.ts +4 -6
  50. package/src/otlpHttpClient.ts +2 -2
  51. package/src/redactingDiagnostics.ts +1 -5
  52. package/src/redactingTracer.ts +7 -5
  53. package/src/safeOtlpSerialization.ts +5 -12
  54. package/src/socketRpc.ts +6 -6
  55. package/dist/databaseLayer.d.ts +0 -14
  56. package/dist/databaseLayer.d.ts.map +0 -1
  57. package/dist/databaseLayer.js.map +0 -1
  58. package/dist/redactOtlpUrl.d.ts +0 -2
  59. package/dist/redactOtlpUrl.d.ts.map +0 -1
  60. package/dist/redactOtlpUrl.js +0 -41
  61. package/dist/redactOtlpUrl.js.map +0 -1
  62. package/dist/schemaSensitiveAst.d.ts +0 -7
  63. package/dist/schemaSensitiveAst.d.ts.map +0 -1
  64. package/dist/schemaSensitiveAst.js +0 -102
  65. package/dist/schemaSensitiveAst.js.map +0 -1
  66. package/dist/schemaSensitiveKeys.d.ts +0 -6
  67. package/dist/schemaSensitiveKeys.d.ts.map +0 -1
  68. package/dist/schemaSensitiveKeys.js +0 -47
  69. package/dist/schemaSensitiveKeys.js.map +0 -1
  70. package/src/redactOtlpUrl.ts +0 -48
  71. package/src/schemaSensitiveAst.ts +0 -106
  72. package/src/schemaSensitiveKeys.ts +0 -49
package/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.11.0 - 2026-10-31
4
+
5
+ ### Added
6
+
7
+ - Native clients can pass `bearerToken` to `makeClient` to authenticate the shared RPC WebSocket in its first frame, without upgrade headers or credentials in URLs. The server applies its existing session and read policies, closes invalid or expired authentication with code 1008, and closes authenticated bearer sockets when their session is revoked. Native resume reconciles live query values.
8
+ - Contract exports the `signedIn` read policy and `validateReadPolicies(group)` for native hosts to validate their RPC group during Layer construction.
9
+ - Contract exposes `LiveServer` through `defineService`, with a native `.layer` requiring Reactivity. Its `stream` and `subscribe` methods return Effects containing native Streams, retaining subscription failures and caller requirements.
10
+ - `@shivaedev/errors/taxonomy.ts` exports class guards (`isConflict`, `isNotFound` and one `is<Class>` guard for every other taxonomy error). They narrow actual class instances and reject objects with matching tags.
11
+
12
+ ### Changed
13
+
14
+ - Server and the platform dependency shell no longer declare `pg` as an optional peer; its PostgreSQL integration uses the native pool from sql.
15
+
16
+ ### Fixed
17
+
18
+ - Admin's built-in Users and Jobs queries and Work Board's daemon diagnostics queries explicitly declare read policies; existing permission and loopback boundaries continue to own access.
19
+ - Logs, error reports, RPC failure data and exported spans share errors' database-key and URL policy. Database users and connection strings are masked under their diagnostic keys; URL user information, query values and fragments are masked in structured values and text.
20
+
21
+ ### Breaking
22
+
23
+ - Replace `authDatabase(url, { max, application_name })` from identity's `server/better-auth/mount.ts` with `yield* betterAuthDatabase()` from `server/better-auth/adapters/database.ts`, inside the application's SQL environment. Pass the result as Better Auth's `database`. Use sql's `postgresLayer` for standalone processes; database-backed `appHost` exposes the client inside its `application` Effect. Move connection settings to `maxConnections` and `applicationName` on that SQL Layer. Auth now shares its connection budget and lifecycle; remove direct `pg` dependencies when no longer used.
24
+ - Replace `authTestDatabase(pool)` with `yield* authTestDatabase` in identity test fixtures, provided with the application's `SqlClient`.
25
+ - When applying the generated starter update, replace `poolSizes.auth` with the shared `poolSizes.sql` budget. Auth migrations use the application SQL environment; remove custom `AuthMigrationDatabase` providers.
26
+ - Every contract query requires a `readPolicy`, including plain RPC reads. Add `readPolicy: signedIn` for any signed-in viewer, an explicit `() => Effect.succeed(true)` for public reads, or an application policy for restricted reads. Plain calls without a policy now fail closed with `MissingReadPolicy` even on native servers that bypass startup validation.
27
+ - The application server Layer fails with typed `MissingReadPolicies` before listening when untyped queries omit policies. Handle this boot error if your application narrows startup failures; its `queries` field lists every affected RPC. Query atom error types now follow their native RPC errors without an extra client-side `MissingReadPolicy` branch. Custom `ChangesQueries` annotations must now include their query definitions in `queries` alongside `resolve`.
28
+ - Server's `AppChanges` is replaced by `LiveServer` from `@shivaedev/contract/LiveServer.ts`. Replace `AppChanges` imports and requirements with `LiveServer` (use `Context.Service.Identifier<typeof LiveServer>` for its identifier type). PostgreSQL `appHost` and `appDatabase` provide it automatically; HTTP-only apps provide `LiveServer.layer` with Reactivity instead of `Layer.effect(AppChanges, makeLiveServer)`. Call `resync()` instead of reading `resync`, and use `Stream.unwrap` around the Effects returned by `stream` and `subscribe`.
29
+ - Server composition helpers (`appHostHttp`, `migratedHost`, `deferredHost`, `hostRpcRoutes` and `hostChanges`) resolve the contract service directly. Remove their live-service tag argument; calls to the former `databaseLayer(options, tag)` become `appDatabase(options)`.
30
+ - Work Board's `publishChanges` and Work Fleet's `daemonSnapshots` now require contract's `LiveServer` instead of server's `AppChanges`. Custom compositions must provide `LiveServer.layer` with Reactivity; their standard hosts already do so.
31
+ - Import server's `appDatabase` and `DatabaseConfig` directly from `@shivaedev/server/appDatabase.ts`; `appHost.ts` no longer forwards `appDatabase`, and `databaseLayer.ts` is removed.
32
+ - Import `schemaSensitiveKeys` from `@shivaedev/errors/schemaSensitiveKeys.ts` instead of server, and `redactRecord` from `@shivaedev/errors/redact.ts` instead of server's `redactingDiagnostics.ts`.
33
+ - Import schema sensitivity AST helpers from `@shivaedev/errors/schemaSensitiveAst.ts` instead of `@shivaedev/server/schemaSensitiveAst.ts`.
34
+ - Replace server's `redactOtlpUrl` with `redactUrl` from `@shivaedev/errors/sensitive.ts`. Replace server's `redactOtlpText(value, key, sensitive)` with `redactText(value, sensitive, undefined, key)` from `@shivaedev/errors/sensitive.ts`.
35
+ - Errors' redaction helpers now apply the same URL and database-key masking previously applied only to exported traces. Consumers should expect `<redacted>` for URL user information, query values and fragments, and for `db.user`, `db.user.name` and `db.connection_string` values.
36
+
3
37
  ## 0.10.0 - 2026-10-31
4
38
 
5
39
  ### Fixed
package/README.md CHANGED
@@ -35,7 +35,7 @@ The optional modules solve different boundaries. `runtime/` carries Effect servi
35
35
 
36
36
  ### Host the application
37
37
 
38
- `appHost` is the server entry point for an Effect app. For a PostgreSQL app, supply the native RPC group, handler and service Layers, migration loader, session policy and static asset directory. The host completes migrations before acquiring application services, starts Node HTTP with native Effect RPC over a WebSocket upgrade at `/rpc`, and provides SQL, Reactivity and `AppChanges` to those Layers.
38
+ `appHost` is the server entry point for an Effect app. For a PostgreSQL app, supply the native RPC group, handler and service Layers, migration loader, session policy and static asset directory. The host completes migrations before acquiring application services, starts Node HTTP with native Effect RPC over a WebSocket upgrade at `/rpc`, and provides SQL, Reactivity and `LiveServer` from `@shivaedev/contract/LiveServer.ts` to those Layers.
39
39
 
40
40
  ```ts
41
41
  import { NodeRuntime } from "@effect/platform-node";
@@ -89,7 +89,11 @@ RPC request bodies are limited to 1 MiB by default. Set `MAX_BODY_SIZE` to a byt
89
89
 
90
90
  For a native Node HTTP route outside RPC, read the request body with `readBoundedBody` from [`@shivaedev/http`](https://github.com/ShivaeDev/platform/tree/main/packages/http#readme), which rejects oversized bodies with a typed 413 failure.
91
91
 
92
- Ordinary POST RPC uses `localRpcGuard` from `@shivaedev/identity/server/local.ts`: it requires a loopback peer and Host, same-origin or absent Origin, and the NDJSON content type. The WebSocket upgrade uses the same loopback, origin and trusted-proxy checks without an HTTP body content type. Session lookup uses the upgrade's transport headers; RPC message headers cannot replace its cookie or Origin. Session middleware revalidates authenticated streams at `streamRevalidationInterval` and ends revoked subscriptions with typed `Unauthorized`. The shared socket remains open; later protected calls use the same session checks. Automatic live subscriptions also recheck the session and query policy before each hint. POST RPC has no `$changes` stream. The host applies `RequestTracing` last to every served RPC, including loopback RPC, so it wraps authentication and handlers without a per-contract tracing declaration. Existing tracing declarations run once at that outermost boundary. With a session policy, contracts declare `Authenticated` and `MaybeAuthenticated` as needed; the host supplies their implementations. For `AuthenticatedUser`, merge `authenticatedUserLayer(sessions)` from `@shivaedev/identity/server/session.ts` beside the handlers. Declared errors retain their Schema types. Applications still own resource authorization and use `rpcBoundary` when they need to map unexpected failures.
92
+ Ordinary POST RPC uses `localRpcGuard` from `@shivaedev/identity/server/local.ts`: it requires a loopback peer and Host, same-origin or absent Origin, and the NDJSON content type. The WebSocket upgrade uses the same loopback, origin and trusted-proxy checks without an HTTP body content type. Session lookup uses the upgrade's transport headers; RPC message headers cannot replace its cookie or Origin. Session middleware revalidates authenticated streams at `streamRevalidationInterval` and ends revoked subscriptions with typed `Unauthorized`. Cookie-authenticated sockets remain open; later protected calls use the same session checks. Automatic live subscriptions also recheck the session and query policy before each hint. POST RPC has no `$changes` stream. The host applies `RequestTracing` last to every served RPC, including loopback RPC, so it wraps authentication and handlers without a per-contract tracing declaration. Existing tracing declarations run once at that outermost boundary. With a session policy, contracts declare `Authenticated` and `MaybeAuthenticated` as needed; the host supplies their implementations. For `AuthenticatedUser`, merge `authenticatedUserLayer(sessions)` from `@shivaedev/identity/server/session.ts` beside the handlers. Declared errors retain their Schema types. Applications still own resource authorization and use `rpcBoundary` when they need to map unexpected failures.
93
+
94
+ Native clients that cannot set upgrade headers use `makeClient`'s `bearerToken` option from `@shivaedev/contract/bind.ts`. On session hosts, `GET /rpc?auth=frame` requires a first text frame shaped as `{"_tag":"Authenticate","token":"<credential>"}` within five seconds, with at most 8192 characters. The host consumes that frame before starting native RPC and supplies its bearer as the socket's transport Authorization header. The existing session provider, identity middleware, Origin policy and query read policies apply to every call and live read. RPC message headers cannot replace the authenticated credential. Configure bearer admission on the session provider and the WebView Origin through `nativeOrigins`. A long-lived bearer is never placed in a URL.
95
+
96
+ Invalid, expired, malformed, oversized or missing first-frame credentials close the socket with code 1008 and reason `Authentication required`; session-provider failures close it with code 1011 and reason `Authentication unavailable`. The host checks the bearer socket's session at `streamRevalidationInterval`, including when no subscription is active, and closes it with code 1008 when the session is revoked, expires or changes identity. The session remains subject to the same per-call and per-hint checks as cookie sessions.
93
97
 
94
98
  Every response from the host's native RPC endpoint carries `Cache-Control: private, no-store`, including mixed public and authenticated batches, typed failures, transport rejections, body-read failures and streams. The host sets this at the outer response boundary without inspecting batch contents.
95
99
 
@@ -107,7 +111,7 @@ The host provides Effect's native `Crypto` service (`effect/Crypto`) to prefligh
107
111
 
108
112
  Supply `preflight: AppConfigLive` to `appHost` to build a native Layer before checking or applying migrations, or constructing the application. Use it to validate configuration such as app IDs, keys and invite lists. Its errors stay in the returned Layer's typed error channel, its requirements other than `Crypto` remain external requirements, and its services are available to migrations, application construction, services and RPC handlers as well as callers of the host Layer. Preflight resources close with the host scope. The option also works without migrations.
109
113
 
110
- When construction itself touches the schema, use `appHost({ migrations, config, application })`. `application` is a native Effect that returns the HTTP host options (`group`, handler and service Layers, session policy, and optional HTTP config). The host first builds `appDatabase`, then evaluates this Effect in the host scope with SQL, Reactivity and `AppChanges` available. A failed migration or schema-current check prevents construction. Initialization requirements and errors stay in the returned Layer's types, and acquired resources close with the host scope.
114
+ When construction itself touches the schema, use `appHost({ migrations, config, application })`. `application` is a native Effect that returns the HTTP host options (`group`, handler and service Layers, session policy, and optional HTTP config). The host first builds `appDatabase`, then evaluates this Effect in the host scope with SQL, Reactivity and `LiveServer` from `@shivaedev/contract/LiveServer.ts` available. A failed migration or schema-current check prevents construction. Initialization requirements and errors stay in the returned Layer's types, and acquired resources close with the host scope.
111
115
 
112
116
  ```ts
113
117
  const host = appHost({
@@ -212,7 +216,7 @@ Render inside the application's native registry provider. The query's `data` is
212
216
 
213
217
  Tracing logs declared failures with `RPC failure` and their tag, and defects with `RPC defect`. Interrupt-only causes emit `RPC interrupted` at debug instead, with `rpc.method`, `requestId`, the `rpc.duration` log span and the same redacted payload. The RPC trace span carries `rpc.interrupted: true`; Effect exports interruption with an unset span status. Completed and failed RPCs receive no interruption marker. The diagnostic payload masks nested credential-shaped keys and Effect `Redacted` values. Credential-shaped strings, such as bearer tokens, URL passwords and sensitive `key=value` text, are masked too. Strings retain at most 2,048 characters before a truncation marker; collections retain at most 50 entries with a marker for the remainder, and binary values become size summaries.
214
218
 
215
- `appHost` derives sensitive field names from the served RPC group's payload, success, error, defect and middleware error schemas, including nested schemas. Use `Schema.Redacted(...)`, `Schema.RedactedFromValue(...)`, or annotate a field with `sensitive: true`. The host treats those names as sensitive throughout that app, even when a diagnostic contains an unwrapped value. Add other exact, case-sensitive names once in `config.sensitiveKeys`:
219
+ `appHost` derives sensitive field names from the served RPC group's payload, success, error, defect and middleware error schemas, including nested schemas. Use `Schema.Redacted(...)`, `Schema.RedactedFromValue(...)`, or annotate a field with `sensitive: true`. The host applies each RPC's schema-derived names to that RPC's diagnostics and failures, even when a diagnostic contains an unwrapped value. Application-wide keys configured below apply to every RPC. Add other exact, case-sensitive names once in `config.sensitiveKeys`:
216
220
 
217
221
  ```ts
218
222
  import { Schema } from "effect";
@@ -236,11 +240,11 @@ A sensitive error encoded to a top-level scalar or record has no fixed output fi
236
240
 
237
241
  Diagnostic failure, defect and interruption reasons are rebuilt with sanitized annotations. When `stack` is sensitive, native `Cause.StackTrace` and `Cause.InterruptorStackTrace` annotations are omitted before reporters or trace exporters receive the cause. Other annotations and interruption identities are preserved. Public native stack frames keep callable stack suppliers and valid parent links; a truncated parent chain ends with `undefined` so reporters and trace exporters can still format it.
238
242
 
239
- The policy matches field names, not arbitrary occurrences of their values in prose. Free text uses only the existing credential-shaped string and key-assignment rules; it does not scan for personal data. Keep sensitive values out of ordinary prose and span names.
243
+ The shared errors policy also masks `db.user`, `db.user.name` and `db.connection_string` in logs, error reports and exported traces. It matches field names, not arbitrary occurrences of their values in prose. Free text uses credential-shaped string, key-assignment and URL rules; it does not scan for personal data. Keep sensitive values out of ordinary prose and span names.
240
244
 
241
- For native RPC serialization, `schemaSensitiveKeys(group, extraKeys?)` returns a key predicate with `maskFailure(tag: string | undefined, reason: "Fail" | "Die")`. Pass both to `redactingRpcSerialization(wire, sensitive, sensitive.maskFailure)`. The serializer correlates request tags and response IDs, including batches, before masking a whole error or defect root. Unassociated defects use the conservative policy across the host's defect schemas.
245
+ For native RPC serialization, `schemaSensitiveKeys(group, extraKeys?)` from `@shivaedev/errors/schemaSensitiveKeys.ts` returns a key predicate with `forRpc(tag)` and `maskFailure(tag: string | undefined, reason: "Fail" | "Die")`. Pass them to `redactingRpcSerialization(wire, sensitive, sensitive.maskFailure, sensitive.forRpc)`. The serializer correlates request tags and response IDs, including batches, before masking a whole error or defect root. Unassociated defects use the conservative policy across the host's defect schemas.
242
246
 
243
- The masking primitives, `redact`, `redactWire`, `redactText`, `redactCause` and `isSensitiveKey`, live in [`@shivaedev/errors`](https://github.com/ShivaeDev/platform/tree/main/packages/errors#readme).
247
+ The masking primitives, `redact`, `redactWire`, `redactRecord`, `redactText`, `redactUrl`, `redactCause`, `schemaSensitiveKeys` and `isSensitiveKey`, live in [`@shivaedev/errors`](https://github.com/ShivaeDev/platform/tree/main/packages/errors#readme).
244
248
 
245
249
  For a native RPC server composed without `appHost`, `requestTracingLayer({ sensitive })` from `@shivaedev/identity/server/tracing.ts` accepts a key predicate; `isSensitiveKey` from `@shivaedev/errors/sensitive.ts` supplies the default credential rules. `redactingErrorReporter(reporter, sensitive?)` from `@shivaedev/errors/redactCause.ts` wraps an Effect error reporter and passes it redacted failure and defect causes while preserving reporting hints such as severity and redacted attributes.
246
250
 
@@ -304,17 +308,18 @@ The signal aborts on an additional signal, socket close, incomplete request clos
304
308
 
305
309
  Import the module that defines the name; there is no package-root entry. Paths below follow `@shivaedev/server/`.
306
310
 
307
- | Module | Names and purpose |
308
- | ------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
309
- | `appHost.ts` | `appHost`, `appDatabase`, `AppChanges`: scoped HTTP and PostgreSQL composition with loopback defaults and optional proxy trust. |
310
- | `setupDatabases.ts` | `setupDatabases()`: prepare the local development and test databases. |
311
- | `development.ts` | `development({ server, worker, conditions? })`, `runDevelopment(options)`: run the server, worker and Vite in watch mode. |
312
- | `rpc-server/publicConfigLayer.ts` | `publicConfigLayer(declaration, path?)`: serve a `publicConfig` declaration from native Config. |
313
- | `otlpTracing.ts` | `otlpTracing`: opt-in Effect OTLP trace export for worker Layers. |
314
- | `schemaSensitiveKeys.ts`, `RedactionPolicy.ts` | `schemaSensitiveKeys(group, extraKeys?)`, `RedactionPolicy`: derive and provide an app's diagnostic key predicate. |
315
- | `redactingDiagnostics.ts`, `redactingTracer.ts`, `redactingRpcSerialization.ts` | `redactingDiagnostics(sensitive)`, `redactRecord(values, sensitive)`, `redactingTracer(sensitive)`, `redactingRpcSerialization(wire, sensitive, maskFailure?)`: compose native diagnostic and NDJSON boundaries. |
316
- | `runtime/makePlatform.ts` | `makePlatformRuntime(layer, { developmentCacheKey? })`. |
317
- | `node-http/subscriptionSignal.ts` | `nodeSubscriptionSignal({ nodeRequest?, request?, signals? })`, returning `{ signal, dispose }`. |
311
+ | Module | Names and purpose |
312
+ | ------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
313
+ | `appHost.ts` | `appHost`: scoped HTTP and PostgreSQL composition with loopback defaults and optional proxy trust. |
314
+ | `appDatabase.ts` | `appDatabase`, `DatabaseConfig`: PostgreSQL composition with migrations, Reactivity and contract's `LiveServer`. |
315
+ | `setupDatabases.ts` | `setupDatabases()`: prepare the local development and test databases. |
316
+ | `development.ts` | `development({ server, worker, conditions? })`, `runDevelopment(options)`: run the server, worker and Vite in watch mode. |
317
+ | `rpc-server/publicConfigLayer.ts` | `publicConfigLayer(declaration, path?)`: serve a `publicConfig` declaration from native Config. |
318
+ | `otlpTracing.ts` | `otlpTracing`: opt-in Effect OTLP trace export for worker Layers. |
319
+ | `RedactionPolicy.ts` | `RedactionPolicy`: provide the app's diagnostic key predicate derived by errors. |
320
+ | `redactingDiagnostics.ts`, `redactingTracer.ts`, `redactingRpcSerialization.ts` | `redactingDiagnostics(sensitive)`, `redactingTracer(sensitive)`, `redactingRpcSerialization(wire, sensitive, maskFailure?)`: compose native diagnostic and NDJSON boundaries. |
321
+ | `runtime/makePlatform.ts` | `makePlatformRuntime(layer, { developmentCacheKey? })`. |
322
+ | `node-http/subscriptionSignal.ts` | `nodeSubscriptionSignal({ nodeRequest?, request?, signals? })`, returning `{ signal, dispose }`. |
318
323
 
319
324
  ### Install, setup and limits
320
325
 
@@ -0,0 +1,14 @@
1
+ import * as PgClient from "@effect/sql-pg/PgClient";
2
+ import { Config, Layer, Redacted } from "effect";
3
+ import * as Reactivity from "effect/reactivity/Reactivity";
4
+ import { Migrator } from "effect/sql";
5
+ import { type PostgresChangesOptions } from "@shivaedev/sql/postgresChanges.ts";
6
+ import { type PostgresOptions } from "@shivaedev/sql/postgresLayer.ts";
7
+ import type { AppDatabaseOptions } from "#appHost.ts";
8
+ export interface DatabaseConfig extends PostgresOptions {
9
+ readonly changes?: Partial<Omit<PostgresChangesOptions, "client" | "listenerClient" | "connectionSetting" | "resync">>;
10
+ readonly databaseUrl?: Redacted.Redacted<string>;
11
+ readonly listenDatabaseUrl?: Redacted.Redacted<string>;
12
+ }
13
+ export declare function appDatabase<R, E = never>(options: AppDatabaseOptions<R, E>): Layer.Layer<"@shivaedev/contract/LiveServer" | PgClient.PgClient | import("@effect/sql-pg/PgPool").PgPool | Reactivity.Reactivity | import("effect/sql/SqlClient").SqlClient, E | Config.ConfigError | Migrator.MigrationError | import("@shivaedev/sql/PostgresListenerError.ts").PostgresListenerError | import("effect/Schema").SchemaError | import("effect/sql/SqlError").SqlError, Exclude<Exclude<R, import("effect/Scope").Scope>, PgClient.PgClient | import("@effect/sql-pg/PgPool").PgPool | import("effect/sql/SqlClient").SqlClient>>;
14
+ //# sourceMappingURL=appDatabase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"appDatabase.d.ts","sourceRoot":"","sources":["../src/appDatabase.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAoC,KAAK,EAAU,QAAQ,EAAY,MAAM,QAAQ,CAAC;AACrG,OAAO,KAAK,UAAU,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAMtC,OAAO,EAAE,KAAK,sBAAsB,EAAmB,MAAM,mCAAmC,CAAC;AACjG,OAAO,EAAE,KAAK,eAAe,EAAiB,MAAM,iCAAiC,CAAC;AAEtF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,MAAM,WAAW,cAAe,SAAQ,eAAe;IACtD,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,sBAAsB,EAAE,QAAQ,GAAG,gBAAgB,GAAG,mBAAmB,GAAG,QAAQ,CAAC,CAAC,CAAC;IACvH,QAAQ,CAAC,WAAW,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACjD,QAAQ,CAAC,iBAAiB,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;CACvD;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,OAAO,EAAE,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,shBAqC1E"}
@@ -3,7 +3,7 @@ import * as PgClient from "@effect/sql-pg/PgClient";
3
3
  import { Config, Context, Duration, Effect, Fiber, Layer, Option, Redacted, Schedule } from "effect";
4
4
  import * as Reactivity from "effect/reactivity/Reactivity";
5
5
  import { Migrator } from "effect/sql";
6
- import { makeLiveServer } from "@shivaedev/contract/makeLiveServer.ts";
6
+ import { LiveServer } from "@shivaedev/contract/LiveServer.ts";
7
7
  import { assertPostgresMigrations, postgresMigrationError } from "@shivaedev/sql/assertPostgresMigrations.ts";
8
8
  import { coordinateWorkerRelease } from "@shivaedev/sql/coordinateWorkerRelease.ts";
9
9
  import { migratePostgres } from "@shivaedev/sql/migrations.ts";
@@ -11,10 +11,10 @@ import { pendingPostgresMigrations } from "@shivaedev/sql/pendingPostgresMigrati
11
11
  import { postgresChanges } from "@shivaedev/sql/postgresChanges.ts";
12
12
  import { postgresLayer } from "@shivaedev/sql/postgresLayer.ts";
13
13
  import { WorkerRelease } from "@shivaedev/sql/WorkerRelease.ts";
14
- export function databaseLayer(options, changesService) {
14
+ export function appDatabase(options) {
15
15
  const pool = Layer.unwrap(Effect.map(options.config?.databaseUrl === undefined ? Config.Redacted("DATABASE_URL") : Effect.succeed(options.config.databaseUrl), (url) => postgresLayer(url, options.config)));
16
16
  const prepared = Layer.effectDiscard(prepareMigrations(options.migrations)).pipe(Layer.provideMerge(pool));
17
- const live = Layer.effect(changesService, makeLiveServer).pipe(Layer.provideMerge(Reactivity.layer));
17
+ const live = LiveServer.layer.pipe(Layer.provideMerge(Reactivity.layer));
18
18
  const migrations = options.migrations;
19
19
  const worker = migrations.mode === "wait" && migrations.release !== undefined
20
20
  ? Layer.effect(WorkerRelease, coordinateWorkerRelease(migrations.release, migrations.pollInterval, migrations.table))
@@ -23,7 +23,7 @@ export function databaseLayer(options, changesService) {
23
23
  const changes = options.config?.changes;
24
24
  return Layer.unwrap(Effect.gen(function* () {
25
25
  const client = yield* PgClient.PgClient;
26
- const hints = yield* changesService;
26
+ const hints = yield* LiveServer;
27
27
  const url = options.config?.databaseUrl ?? (yield* Config.Redacted("DATABASE_URL"));
28
28
  const name = yield* Config.String("APP_NAME").pipe(Config.withDefault(new URL(Redacted.value(url)).pathname));
29
29
  const channel = changes?.channel ?? `changes_${createHash("sha256").update(name).digest("hex").slice(0, 32)}`;
@@ -35,7 +35,7 @@ export function databaseLayer(options, changesService) {
35
35
  if (listenUrl !== undefined) {
36
36
  connectionSetting = options.config?.listenDatabaseUrl === undefined ? "LISTEN_DATABASE_URL" : "config.listenDatabaseUrl";
37
37
  }
38
- return postgresChanges({ ...changes, channel, client, connectionSetting, listenerClient, resync: hints.resync });
38
+ return postgresChanges({ ...changes, channel, client, connectionSetting, listenerClient, resync: hints.resync() });
39
39
  })).pipe(Layer.provideMerge(base));
40
40
  }
41
41
  function prepareMigrations(migrations) {
@@ -79,4 +79,4 @@ function waitForMigrations(migrations) {
79
79
  }
80
80
  }).pipe(Effect.scoped);
81
81
  }
82
- //# sourceMappingURL=databaseLayer.js.map
82
+ //# sourceMappingURL=appDatabase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"appDatabase.js","sourceRoot":"","sources":["../src/appDatabase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACrG,OAAO,KAAK,UAAU,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAC/D,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AAC9G,OAAO,EAAE,uBAAuB,EAAE,MAAM,2CAA2C,CAAC;AACpF,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAkC,yBAAyB,EAAE,MAAM,6CAA6C,CAAC;AACxH,OAAO,EAA+B,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACjG,OAAO,EAAwB,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACtF,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAShE,MAAM,UAAU,WAAW,CAAe,OAAiC;IAC1E,MAAM,IAAI,G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CAAC,YAAY,IAAI,UAAU,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,IAAI,WAAW,CAAC,CAAC,CAAC;YACxI,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,YAAY,QAAQ,CAAC,cAAc,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU;SACvF,CAAC,EACF,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CACzB,KAAK,YAAY,QAAQ,CAAC,cAAc,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,2CAA2C,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CACtI,CACD,CAAC;QACF,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC5B,KAAK,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;YACjC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,6BAA6B,CAAC,CAAC;QACtD,CAAC;IACF,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AACxB,CAAC"}
package/dist/appHost.d.ts CHANGED
@@ -1,26 +1,14 @@
1
- import { Context, type Effect, Layer } from "effect";
2
1
  import type { Rpc } from "effect/rpc";
3
2
  import type { SessionPolicy, SessionShape } from "@shivaedev/identity/server/session.ts";
4
3
  import type { AppHostFactory } from "#AppHostFactory.ts";
5
4
  import type { HostPreflight } from "#AppHostInput.ts";
6
- import { type DatabaseConfig } from "#databaseLayer.ts";
5
+ import { type DatabaseConfig } from "#appDatabase.ts";
7
6
  import type { HostCoreOptions, HostPolicy, HostRouteRequirements, HostRoutes } from "#hostOptions.ts";
8
7
  import type { MigrationOptions } from "#MigrationOptions.ts";
9
- declare const AppChanges_base: Context.ServiceClass<AppChanges, "@shivaedev/server/AppChanges", {
10
- resync: Effect.Effect<number, never, never>;
11
- stream: (keys: readonly import("@shivaedev/changes/keys.ts").Key[], context?: import("@shivaedev/changes/keys.ts").KeyContext) => import("effect/Stream").Stream<import("@shivaedev/contract/live.ts").LiveHint>;
12
- subscribe: {
13
- <E, R>(subscription: import("@shivaedev/contract/querySubscription.ts").QuerySubscription<E, R>, context?: import("@shivaedev/changes/keys.ts").KeyContext): import("effect/Stream").Stream<import("@shivaedev/contract/live.ts").LiveHint, E | import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, R>;
14
- <E, R>(subscription: import("@shivaedev/contract/querySubscription.ts").QuerySubscription<E, R>, context: import("@shivaedev/changes/keys.ts").KeyContext | undefined, read: import("@shivaedev/contract/querySubscription.ts").QueryRerun<E, R>): import("effect/Stream").Stream<import("@shivaedev/contract/queryUpdate.ts").QueryUpdate, E | import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, R>;
15
- };
16
- }>;
17
- export declare class AppChanges extends AppChanges_base {
18
- }
19
8
  export interface AppDatabaseOptions<R = never, E = never> {
20
9
  readonly config?: DatabaseConfig;
21
10
  readonly migrations: MigrationOptions<R, E>;
22
11
  }
23
- export declare function appDatabase<R, E = never>(options: AppDatabaseOptions<R, E>): Layer.Layer<AppChanges | import("@effect/sql-pg/PgClient").PgClient | import("@effect/sql-pg/PgPool").PgPool | import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient, E | import("effect/Config").ConfigError | import("effect/sql/Migrator").MigrationError | import("@shivaedev/sql/PostgresListenerError.ts").PostgresListenerError | import("effect/Schema").SchemaError | import("effect/sql/SqlError").SqlError, Exclude<Exclude<R, import("effect/Scope").Scope>, import("@effect/sql-pg/PgClient").PgClient | import("@effect/sql-pg/PgPool").PgPool | import("effect/sql/SqlClient").SqlClient>>;
24
12
  export type AppHostOptions<TRpcs extends Rpc.Any, THandlers, THandlerError, THandlerRequirements, TServices = never, TServiceError = never, TServiceRequirements = never, TMigrations = never, TSession extends SessionShape = SessionShape, 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> & {
25
13
  readonly migrations: AppDatabaseOptions<TMigrations, TMigrationError>["migrations"];
26
14
  readonly policy?: undefined;
@@ -35,5 +23,4 @@ export type AppHttpHostOptions<TRpcs extends Rpc.Any, THandlers, THandlerError,
35
23
  readonly migrations?: undefined;
36
24
  };
37
25
  export declare const appHost: AppHostFactory;
38
- export {};
39
26
  //# sourceMappingURL=appHost.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"appHost.d.ts","sourceRoot":"","sources":["../src/appHost.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACrD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AACzF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAgB,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEpE,OAAO,EAAE,KAAK,cAAc,EAAiB,MAAM,mBAAmB,CAAC;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACtG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;;;;;;;;;AAE7D,qBAAa,UAAW,SAAQ,eAAoG;CAAG;AACvI,MAAM,WAAW,kBAAkB,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,KAAK;IACvD,QAAQ,CAAC,MAAM,CAAC,EAAE,cAAc,CAAC;IACjC,QAAQ,CAAC,UAAU,EAAE,gBAA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AK,EACrB,oBAAoB,GAAG,KAAK,EAC5B,QAAQ,SAAS,YAAY,GAAG,YAAY,EAC5C,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,CAAC,QAAQ,CAAC,GAAG;IAAE,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,CAAA;CAAE,CAAC;AAC5D,eAAO,MAAM,OAAO,EAAE,cAmDrB,CAAC"}
package/dist/appHost.js CHANGED
@@ -1,18 +1,13 @@
1
1
  import * as NodeCrypto from "@effect/platform-node/NodeCrypto";
2
- import { Context, Layer } from "effect";
2
+ import { Layer } from "effect";
3
+ import { appDatabase } from "#appDatabase.ts";
3
4
  import { appHostHttp, deferredHost, migratedHost } from "#appHostHttp.ts";
4
- import { databaseLayer } from "#databaseLayer.ts";
5
- export class AppChanges extends Context.Service()("@shivaedev/server/AppChanges") {
6
- }
7
- export function appDatabase(options) {
8
- return databaseLayer(options, AppChanges);
9
- }
10
5
  export const appHost = (options) => {
11
6
  if ("application" in options) {
12
- return deferredHost(options.application, appDatabase(options), AppChanges).pipe(Layer.provideMerge(options.preflight ?? Layer.empty), Layer.provide(NodeCrypto.layer));
7
+ return deferredHost(options.application, appDatabase(options)).pipe(Layer.provideMerge(options.preflight ?? Layer.empty), Layer.provide(NodeCrypto.layer));
13
8
  }
14
9
  return options.migrations === undefined
15
- ? appHostHttp(options, AppChanges).pipe(Layer.provideMerge(options.preflight ?? Layer.empty), Layer.provide(NodeCrypto.layer))
16
- : migratedHost({ ...options, migrations: options.migrations }, appDatabase({ ...options, migrations: options.migrations }), AppChanges).pipe(Layer.provideMerge(options.preflight ?? Layer.empty), Layer.provide(NodeCrypto.layer));
10
+ ? appHostHttp(options).pipe(Layer.provideMerge(options.preflight ?? Layer.empty), Layer.provide(NodeCrypto.layer))
11
+ : migratedHost({ ...options, migrations: options.migrations }, appDatabase({ ...options, migrations: options.migrations })).pipe(Layer.provideMerge(options.preflight ?? Layer.empty), Layer.provide(NodeCrypto.layer));
17
12
  };
18
13
  //# sourceMappingURL=appHost.js.map
@@ -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,OAAO,EAAe,KAAK,EAAE,MAAM,QAAQ,CAAC;AAMrD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAAuB,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAIvE,MAAM,OAAO,UAAW,SAAQ,OAAO,CAAC,OAAO,EAAqD,CAAC,8BAA8B,CAAC;CAAG;AAMvI,MAAM,UAAU,WAAW,CAAe,OAAiC;IAC1E,OAAO,aAAa,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;AAC3C,CAAC;AAmED,MAAM,CAAC,MAAM,OAAO,GAAmB,CAmBtC,OAkBC,EACA,EAAE;IACH,IAAI,aAAa,IAAI,OAAO,EAAE,CAAC;QAC9B,OAAO,YAAY,CAAC,OAAO,CAAC,WAAW,EAAE,WAAW,CAAC,OAAO,CAAC,EAAE,UAAU,CAAC,CAAC,IAAI,CAC9E,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,SAAS,IAAI,KAAK,CAAC,KAAK,CAAC,EACpD,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAC/B,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC,UAAU,K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