@shivaedev/platform 0.14.1 → 0.14.2
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 +6 -0
- package/README.md +6 -6
- package/docs/roadmap.md +7 -6
- package/package.json +6 -5
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -86,11 +86,11 @@ RPC uses the existing `localRpcGuard`: it requires a loopback peer and Host, sam
|
|
|
86
86
|
|
|
87
87
|
For local tools, use `policy: "loopback"` with contracts that do not use session middleware to serve RPC without a session provider. The guard requires a loopback peer and Host, absent or same-origin Origin, and NDJSON content type. This policy does not use `TRUSTED_PROXY` or `config.trustedProxy`. Set `rpcPath` to choose another native RPC route; `/rpc` remains the default.
|
|
88
88
|
|
|
89
|
-
Omit `migrations` to host an app without a database. This form creates no SQL pool and reads no `DATABASE_URL`; `AppHttpHostOptions` describes it. `AppHostOptions`
|
|
89
|
+
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, as Fleet's daemon does with its migration loader and namespace ledger. Real HTTP tests cover the custom route, session-free loopback guard and database-free startup; Fleet's PostgreSQL daemon tests cover the adopted composition.
|
|
90
90
|
|
|
91
91
|
`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.
|
|
92
92
|
|
|
93
|
-
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; it does not run migrations or create a ledger. Later ledger entries are allowed for rolling deployments. With `mode` omitted or `"migrate"`,
|
|
93
|
+
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; it does not run migrations or create a ledger. Later ledger entries are allowed for rolling deployments. With `mode` omitted or `"migrate"`, startup applies pending migrations with a five-second lock timeout unless `migrations.lockTimeout` overrides it.
|
|
94
94
|
|
|
95
95
|
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.
|
|
96
96
|
|
|
@@ -113,7 +113,7 @@ On Railway, enable the per-service tracing setting separately for the web servic
|
|
|
113
113
|
|
|
114
114
|
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. The production host continues incoming W3C `traceparent` context, including one sent by an edge proxy.
|
|
115
115
|
|
|
116
|
-
Both JSON and protobuf export serialization apply
|
|
116
|
+
Both JSON and protobuf export serialization apply sensitive-key and credential-text redaction to span attributes, events, links, error details and resource attributes. Exporter headers stay in the collector request, outside the spans. Applications must still avoid placing secrets in span names, free text or custom attributes.
|
|
117
117
|
|
|
118
118
|
Set `config.maxConnections` on `appDatabase` or a migrated `appHost` to bound the pool. A daemon with long-lived RPC streams can use `config.disablePreemptiveShutdown: true` to let scope closure interrupt those streams before closing the listener; omitting it keeps Node's native graceful-shutdown default. Fleet's daemon tests cover one bounded pool and scoped provider and listener cleanup, including follower reconnection after shutdown.
|
|
119
119
|
|
|
@@ -337,9 +337,7 @@ await runtime.dispose();
|
|
|
337
337
|
|
|
338
338
|
`base` is `"application"` and `request` is `"request"`. The application's resource Layer is acquired once across calls. An explicit `developmentCacheKey` shares a runtime between calls with that key during development. Each key belongs to one application runtime definition.
|
|
339
339
|
|
|
340
|
-
A nested `runWithServices` call replaces the outer invocation's overrides for
|
|
341
|
-
its callback. Merge the contexts explicitly when the nested call must retain
|
|
342
|
-
those overrides.
|
|
340
|
+
A nested `runWithServices` call replaces the outer invocation's overrides for its callback. Merge the contexts explicitly when the nested call must retain those overrides.
|
|
343
341
|
|
|
344
342
|
### Node subscriptions: combine cancellation and clean up
|
|
345
343
|
|
|
@@ -442,6 +440,7 @@ Import the module that defines the name; there is no package-root entry. Paths b
|
|
|
442
440
|
| Module | Names and purpose |
|
|
443
441
|
| --- | --- |
|
|
444
442
|
| `otlpTracing.ts` | `otlpTracing`: scoped, opt-in Effect OTLP trace export configured through standard exporter variables; provide it to worker Layers. |
|
|
443
|
+
| `boundedBody.ts` | `readBoundedBody`, `RequestBodyTooLarge`: bounded body bytes and a typed HTTP 413 failure. |
|
|
445
444
|
| `appHost.ts` | `appHost({ group, handlers, services, migrations?, sessions?, policy?, rpcPath?, assets?, routes?, config? })` or `appHost({ application, migrations, config? })`, `appDatabase({ migrations, config? })`, `AppChanges`, `AppHostOptions`, `AppHttpHostOptions`, `AppLocalHostOptions`, `AppDatabaseOptions`: scoped HTTP and PostgreSQL composition with loopback defaults and optional proxy trust. |
|
|
446
445
|
| `errors/taxonomy.ts` | `NotFound`, `Unauthorized`, `Forbidden`, `BadRequest`, `Conflict`, `PreconditionFailed`, `TooManyRequests`, `AuthUnavailable`, `InternalServerError`, `ServiceUnavailable`: Schema tagged error classes with a `message`; `BadRequest` and `Conflict` also accept an optional `field`. |
|
|
447
446
|
| `errors/rejected-field.ts` | `rejectedField(unknown): Option<RejectedField>`; `RejectedField` is `{ field: string, message: string }`. |
|
|
@@ -480,6 +479,7 @@ Install the optional peers for the selected integration:
|
|
|
480
479
|
|
|
481
480
|
| Integration | Additional peers |
|
|
482
481
|
| --- | --- |
|
|
482
|
+
| `boundedBody.ts` | `@effect/platform-node` |
|
|
483
483
|
| `appHost.ts` | `@effect/platform-node`, `@effect/sql-pg` |
|
|
484
484
|
| `better-auth/adapter.ts` | `better-auth`, `@shivaedev/effect-prisma`, `@prisma-next/sql-orm-client` |
|
|
485
485
|
| `testing/vitest.ts` | `@effect/vitest`, `@shivaedev/effect-prisma`, `@shivaedev/effect-trpc`, `@trpc/server` |
|
package/docs/roadmap.md
CHANGED
|
@@ -9,22 +9,23 @@ This file owns Platform's module implementation, package tests and scope questio
|
|
|
9
9
|
- [x] Shared Schema tagged errors and field-rejection extraction, with native RPC JSON and tRPC rejection tests.
|
|
10
10
|
- [x] Browser-safe native RPC middleware declarations and request-id, identity and optional-identity services, with compile-time checks on guarded handlers.
|
|
11
11
|
- [x] Request-local session middleware, a Better Auth session-provider boundary and an explicit Origin policy. Tests cover concurrent identities, anonymous callers, provider failures and rejection before provider lookup.
|
|
12
|
-
- [x] HTTP transport-header authentication and a WebSocket protocol fixture that uses upgrade-request headers instead of RPC message credentials.
|
|
13
|
-
- [x] Request-id log/span annotations and redaction of failure payloads, defects, reported causes and credential-shaped strings, with bounded collection and string output.
|
|
14
|
-
- [x] An application runtime that acquires its Layer once, shares an explicit development cache key and carries service overrides across Promise calls.
|
|
12
|
+
- [x] HTTP transport-header authentication, direct tests of the RPC-header fallback and HTTP-header precedence, and a WebSocket protocol fixture that uses upgrade-request headers instead of RPC message credentials. [Header selection evidence](https://github.com/ShivaeDev/platform/blob/main/packages/platform/src/server/rpc-server/transportHeaders.test.ts).
|
|
13
|
+
- [x] Request-id log/span annotations and redaction of failure payloads, defects, reported causes and credential-shaped strings, with bounded collection and string output. [Tracing tests](https://github.com/ShivaeDev/platform/blob/main/packages/platform/src/server/rpc-server/tracing.test.ts) cover successful requests and interruption without failure logs.
|
|
14
|
+
- [x] An application runtime that acquires its Layer once, releases it exactly once, shares an explicit development cache key and recreates disposed cache entries, bypasses caching in production, and carries service overrides across Promise calls. [Runtime tests](https://github.com/ShivaeDev/platform/blob/main/packages/platform/src/server/runtime/makePlatform.test.ts) cover typed Layer build failures, Promise rejection, signal interruption with finalization, and nested override replacement and restoration.
|
|
15
15
|
- [x] Node subscription cancellation from Web/procedure signals and simulated request/socket close events, with listener cleanup.
|
|
16
16
|
- [x] A Better Auth Effect Prisma database adapter and Prisma/tRPC rollback harness. Real PostgreSQL tests cover shared transactions, failed transaction rollback, selected row operations and harness types; they require `PLATFORM_EFFECT_PRISMA_TEST_DATABASE_URL`.
|
|
17
|
+
- [x] Better Auth adapter filters, ordering, pagination, projection, native-join rejection and configured model mapping have [PostgreSQL regression tests](https://github.com/ShivaeDev/platform/blob/main/packages/platform/src/server/better-auth/filterBoundaries.spec.ts).
|
|
17
18
|
- [x] Packed-consumer checks for defining-module imports, types and core entries installed without optional peers.
|
|
18
19
|
- [x] A local app host Layer and reusable database Layer, extracted from the PostgreSQL composition: migrations before services, guarded NDJSON RPC, session policy, static assets, scoped shutdown and commit-bound live delivery. The composed fixture covers two HTTP server processes and a worker. Fleet’s daemon adopts `appHost` and `appDatabase` with a custom RPC route, session-free loopback policy and its existing migration ledger. Platform’s real HTTP option tests cover hosting without a database, while Fleet’s PostgreSQL daemon tests cover pool limits, migration upgrades and existing clients.
|
|
19
20
|
|
|
20
21
|
## Next
|
|
21
22
|
|
|
22
|
-
- [ ] Add
|
|
23
|
-
- [ ] Extend adapter tests to the remaining public options and filter, selection, ordering and pagination paths. Add a regression test for the rejection of experimental native joins.
|
|
24
|
-
- [ ] Exercise the no-HTTP-request `transportHeaders` fallback directly and the tracing boundary's successful and interrupted paths.
|
|
23
|
+
- [ ] Add adapter coverage for the `usePlural` option.
|
|
25
24
|
|
|
26
25
|
## Open questions
|
|
27
26
|
|
|
27
|
+
- What comprehensive application redaction policy should cover span names, free text and custom attributes, and how should request/action correlation work across boundaries?
|
|
28
|
+
|
|
28
29
|
- Should the package keep the optional Better Auth storage adapter and Prisma/tRPC harness beside its native request-context modules, or should those compositions live with the integration packages? Both serve real boundary work, but they give this package a wider surface than its request-identity job alone.
|
|
29
30
|
- If an application needs Better Auth storage on native Effect SQL, should Platform own that adapter or should the provider retain separate storage? The request middleware needs a session provider, not a particular database.
|
|
30
31
|
- The exports make Better Auth translation helpers importable beside the adapter. Are these helpers intended as supported consumer APIs, or should a future public API change narrow the surface to the adapter?
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shivaedev/platform",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.2",
|
|
4
4
|
"description": "Opinionated Effect application infrastructure for ShivaeDev services",
|
|
5
5
|
"homepage": "https://github.com/ShivaeDev/platform/tree/main/packages/platform#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -386,12 +386,13 @@
|
|
|
386
386
|
"@prisma-next/sql-contract": "0.16.0",
|
|
387
387
|
"@prisma-next/sql-orm-client": "0.16.0",
|
|
388
388
|
"@prisma-next/target-postgres": "0.16.0",
|
|
389
|
-
"@shivaedev/effect-prisma": "0.9.
|
|
389
|
+
"@shivaedev/effect-prisma": "0.9.2",
|
|
390
390
|
"@shivaedev/effect-trpc": "0.7.1",
|
|
391
|
-
"@shivaedev/quality": "0.
|
|
391
|
+
"@shivaedev/quality": "0.23.0",
|
|
392
|
+
"@shivaedev/test-story": "0.5.0",
|
|
392
393
|
"@trpc/client": "11.19.0",
|
|
393
394
|
"@trpc/server": "11.19.0",
|
|
394
|
-
"@types/node": "24.19.
|
|
395
|
+
"@types/node": "24.19.2",
|
|
395
396
|
"@typescript/native": "npm:typescript@7.0.2",
|
|
396
397
|
"better-auth": "1.7.7",
|
|
397
398
|
"effect": "4.0.4",
|
|
@@ -404,7 +405,7 @@
|
|
|
404
405
|
"@effect/sql-pg": "4.0.4",
|
|
405
406
|
"@effect/vitest": "4.0.4",
|
|
406
407
|
"@prisma-next/sql-orm-client": "0.16.0",
|
|
407
|
-
"@shivaedev/effect-prisma": "0.9.
|
|
408
|
+
"@shivaedev/effect-prisma": "0.9.2",
|
|
408
409
|
"@shivaedev/effect-trpc": "0.7.1",
|
|
409
410
|
"@trpc/server": "11.19.0",
|
|
410
411
|
"better-auth": "1.7.7",
|